Commits

Anonymous committed 522d3a4

add indicators for required pattern

Comments (0)

Files changed (1)

         return result;
     }
 
+    var createBallHolderModel = function(color) {
+        var result = new THREE.Object3D();
+        var material = new THREE.MeshLambertMaterial( {emissive:color, side:THREE.DoubleSide, transparent:true} );
+        material.opacity = 0.5;
+
+        var mesh = new THREE.Mesh( new THREE.SphereGeometry( 2 ), material);
+        result.add(mesh);
+        return result;
+    }
+
     var createReticule = function() {
         var result = new THREE.Object3D();
         var mesh = new THREE.Mesh(
             var geometry = new THREE.CubeGeometry( width, d, 5 );
             var mesh = new THREE.Mesh(geometry, material);
             mesh.position.set(0, s*d/2, 0 );
-            var mark_geometry = new THREE.PlaneGeometry(16, 32);
+            var size = 32;
+            var mark_geometry = new THREE.PlaneGeometry(size, size*2);
             var mark_material = new THREE.MeshBasicMaterial({map: image, transparent:true});
             var mark_plane = new THREE.Mesh(mark_geometry, mark_material);
-            mark_plane.position.set(0,s*d-s*16/2,-5);
+            mark_plane.position.set(0,s*d-s*size/2,-5);
             mark_plane.rotation.set(0,0,Math.PI/2);
             object.add(mark_plane);
             object.add(mesh);
         2: pentagonImages,
     }
 
+    var ballHolders = [];
+    var ballHolderPosition = 0;
+    var addBallHolder = function(ballType) {
+        var ball = createBallHolderModel( ballTypes[ballType] );
+        ballHolders.push(ball);
+        scene.add(ball);
+        ball.position.set( -15+5*(ballHolderPosition++), -14, 100 );
+    }
+
+    var clearBallHolders = function() {
+        ballHolders.forEach( function(object) {
+            scene.remove(object);
+        });
+        ballHolders.length = 0;
+        ballHolderPosition = 0;
+    }
+
     var ballPosition = 0;
     var addBall = function(ballType) {
         var ball = createBallModel( ballTypes[ballType] );
     var objectiveIndex = 0;
     var objective = undefined;
     var loadWorld = function(level) {
+        clearBallHolders();
+        
         balls.forEach( function(ball) { 
             scene.remove(ball);
         });
         state.length = 0;
         objectiveIndex = 0;
         objective = level.objective;
+        objective.forEach( function(color) {
+            addBallHolder(color);
+        });
     }
 
     var updateObjective = function() {