diff --git a/js/IndoorMap3d.js b/js/IndoorMap3d.js index 612762a..02ea6fa 100644 --- a/js/IndoorMap3d.js +++ b/js/IndoorMap3d.js @@ -238,7 +238,8 @@ IndoorMap3d = function(mapdiv){ //select object(just hight light it) function select(obj){ - obj.currentHex = _selected.material.color.getHex(); + if(!obj || !obj.material) return; + obj.currentHex = obj.material.color.getHex(); obj.material.color = new THREE.Color(_theme.selected); obj.scale = new THREE.Vector3(2,2,2); } @@ -260,7 +261,10 @@ IndoorMap3d = function(mapdiv){ _rayCaster.set( _this.camera.position, vector.sub( _this.camera.position ).normalize() ); - var intersects = _rayCaster.intersectObjects( _this.mall.root.children[0].children ); + var intersects = []; + if (_this.mall && _this.mall.root && _this.mall.root.children[0] && _this.mall.root.children[0].children) { + intersects = _rayCaster.intersectObjects( _this.mall.root.children[0].children ); + } if ( intersects.length > 0 ) { @@ -269,18 +273,22 @@ IndoorMap3d = function(mapdiv){ if ( _selected ) { _selected.material.color.setHex( _selected.currentHex ); } + var foundSolidRoom = false; for(var i=0; i