Skip to content

Commit

Permalink
Add tests for mirrored objects
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpeiris committed Apr 16, 2016
1 parent 7af637b commit ad6ac22
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions examples/tests/material-side.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
</style>
</head>
<body>
<script src="../../../UnityClient/js/src/altspace-schema.js"></script>
<script src="../../../UnityClient/js/src/AltGeoMatSerializer.js"></script>
<script src="https://cdn.rawgit.com/mrdoob/three.js/r74/build/three.js"></script>
<script src="https://cdn.rawgit.com/mrdoob/three.js/r74/examples/js/controls/FlyControls.js"></script>
<script src="http://code.jquery.com/jquery-2.2.3.min.js"></script>
Expand All @@ -25,28 +23,46 @@

scene = new THREE.Scene();

function sideLabel (side, xs) {
return ['F', 'B', 'D'][side] + (xs < 0 ? "'":'');
function sideLabel (side, xs, ys, zs) {
mirrored = xs < 0 || ys < 0 || zs < 0;
return ['F', 'B', 'D'][side] + (mirrored ? "'":'');
}

function makeSphere (side, x, xs) {
function makeSphere (side, x, y, xs, ys, zs) {
var texture = new THREE.TextureLoader().load('../images/UV_Grid_Sm.jpg');
var material = new THREE.MeshBasicMaterial({color:'#ff00ff', map: texture});
material.side = side;
var sphere = new THREE.Mesh(new THREE.SphereGeometry(), material);
sphere.position.x = x;
sphere.scale.x = xs;
sphere.position.set(x, y, 0);
ys = ys || 1;
zs = zs || 1;
sphere.scale.set(xs, ys, zs);
scene.add(sphere);
sphere.userData.label = $('<label>').text(sideLabel(side, xs)).css('left', x / 1.2 + 400).appendTo('body');
sphere.userData.label = $('<label>').
text(sideLabel(side, xs, ys, zs)).
css('left', x / 1.2 + 400).
appendTo('body');
return sphere;
}
makeSphere(THREE.FrontSide, -400, 1);
makeSphere(THREE.DoubleSide, -300, 1);
makeSphere(THREE.BackSide, -200, 1);
makeSphere(THREE.FrontSide, -100, -1);
makeSphere(THREE.DoubleSide, 0, -1);
makeSphere(THREE.BackSide, 100, -1);
var flipper = makeSphere(THREE.BackSide, 200, 1);

makeSphere(THREE.FrontSide, -400, 0, 1);
makeSphere(THREE.DoubleSide, -300, 0, 1);
makeSphere(THREE.BackSide, -200, 0, 1);

makeSphere(THREE.FrontSide, -100, 0, -1);
makeSphere(THREE.DoubleSide, 0, 0, -1);
makeSphere(THREE.BackSide, 100, 0, -1);

makeSphere(THREE.FrontSide, -100, 100, 1, -1);
makeSphere(THREE.DoubleSide, 0, 100, 1, -1);
makeSphere(THREE.BackSide, 100, 100, 1, -1);

makeSphere(THREE.FrontSide, -100, -100, 1, 1, -1);
makeSphere(THREE.DoubleSide, 0, -100, 1, 1, -1);
makeSphere(THREE.BackSide, 100, -100, 1, 1, -1);

// FIXME: Material side is not dynamic
var flipper = makeSphere(THREE.BackSide, 200, 0, 1);


if (window.altspace) {
Expand Down

0 comments on commit ad6ac22

Please sign in to comment.