diff --git a/js/CameraContainer.js b/js/CameraContainer.js index 32afc85..c6f2fb8 100644 --- a/js/CameraContainer.js +++ b/js/CameraContainer.js @@ -37,8 +37,8 @@ CameraContainer.prototype.get = function(i) { CameraContainer.prototype.getById = function(id) { for (var i in this.cameras) { - if (this.cameras[i].mesh !== undefined) { - if (this.cameras[i].mesh.id == id) { + if (this.cameras[i].object3D !== undefined) { + if (this.cameras[i].object3D.id == id) { return this.get(i); } } diff --git a/js/FixedCamera.js b/js/FixedCamera.js index 4cd0a4b..bcda238 100644 --- a/js/FixedCamera.js +++ b/js/FixedCamera.js @@ -100,6 +100,10 @@ var FixedCamera = function(arg1, arg2, arg3, arg4, position, target) { // this.arrow = new THREE.Line(new THREE.Geometry(), new THREE.LineBasicMaterial({color: 0xff0000}), THREE.LinePieces); this.arrow = new THREE.Mesh(new THREE.Geometry(), new THREE.MeshLambertMaterial({color: 0xff0000, side:THREE.DoubleSide})); + this.object3D = new THREE.Object3D(); + this.object3D.add(this.mesh); + this.object3D.add(this.arrow); + this.fullArrow = false; } FixedCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype); @@ -180,6 +184,8 @@ FixedCamera.prototype.regenerateArrow = function(mainCamera) { this.arrow.geometry.mergeVertices(); this.arrow.geometry.computeFaceNormals(); + // this.arrow.geometry.computeVertexNormals(); + this.arrow.geometry.computeBoundingSphere(); // this.arrow.geometry.vertices[0] = new THREE.Vector3(); // mainCamera.position.clone(); // this.arrow.geometry.vertices[1] = this.position.clone(); @@ -200,12 +206,9 @@ FixedCamera.prototype.look = function() { FixedCamera.prototype.addToScene = function(scene) { scene.add(this); - scene.add(this.mesh); - scene.add(this.border); - scene.add(this.arrow); + scene.add(this.object3D); } FixedCamera.prototype.traverse = function(callback) { - callback(this.mesh); - callback(this.border); + this.object3D.traverse(callback); } diff --git a/prototype/js/main.js b/prototype/js/main.js index 4be1937..14b3efb 100644 --- a/prototype/js/main.js +++ b/prototype/js/main.js @@ -86,8 +86,8 @@ function init() { // THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() ); var loader = new THREE.OBJMTLLoader(); - loader.load( '/data/castle/princess peaches castle (outside).obj', - '/data/castle/princess peaches castle (outside).mtl', + loader.load( static_path + 'data/castle/princess peaches castle (outside).obj', + static_path + 'data/castle/princess peaches castle (outside).mtl', function ( object ) { object.up = new THREE.Vector3(0,0,1); scene.add(object); @@ -103,8 +103,8 @@ function init() { }); }, onProgress, onError ); - loader.load( '/data/first/Floor 1.obj', - '/data/first/Floor 1.mtl', + loader.load( static_path + 'data/first/Floor 1.obj', + static_path + 'data/first/Floor 1.mtl', function ( object ) { object.position.z -= 10.9; object.position.y += 0.555; @@ -128,8 +128,8 @@ function init() { }); }, onProgress, onError ); - // loader.load( '/data/bobomb/bobomb battlefeild.obj', - // '/data/bobomb/bobomb battlefeild.mtl', + // loader.load( static_path + 'data/bobomb/bobomb battlefeild.obj', + // static_path + 'data/bobomb/bobomb battlefeild.mtl', // function ( object ) { // // object.position.z -= 10.9; // // object.position.y += 0.555; @@ -274,8 +274,8 @@ function click(event) { } if (bestIndex !== undefined) { - if (cameras.getById(intersects[bestIndex].object.id) !== undefined) { - var new_camera = cameras.getById(intersects[bestIndex].object.id); + if (cameras.getById(intersects[bestIndex].object.parent.id) !== undefined) { + var new_camera = cameras.getById(intersects[bestIndex].object.parent.id); // hide(new_camera); cameras.get(0).move(new_camera); }