Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions js/IndoorMap3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 ) {

Expand All @@ -269,18 +273,22 @@ IndoorMap3d = function(mapdiv){
if ( _selected ) {
_selected.material.color.setHex( _selected.currentHex );
}
var foundSolidRoom = false;
for(var i=0; i<intersects.length; i++) {
_selected = intersects[ i ].object;
if(_selected.type && _selected.type == "solidroom") {
var obj = intersects[ i ].object;
if(obj.type && obj.type == "solidroom") {
_selected = obj;
select(_selected);
if(_selectionListener) {
_selectionListener(_selected.id); //notify the listener
}
foundSolidRoom = true;
break;
}else{
_selected = null;
}
if(_selected == null && _selectionListener != null){
}
if(!foundSolidRoom) {
_selected = null;
if(_selectionListener != null){
_selectionListener(-1);
}
}
Expand Down Expand Up @@ -396,14 +404,14 @@ IndoorMap3d = function(mapdiv){
var imgWidthHalf1 = sprite.width / 2;
var imgHeightHalf1 = sprite.height / 2;
var rect1 = new Rect(sprite.position.x - imgWidthHalf1, sprite.position.y - imgHeightHalf1,
sprite.position.x + imgHeightHalf1, sprite.position.y + imgHeightHalf1 );
sprite.position.x + imgWidthHalf1, sprite.position.y + imgHeightHalf1 );

var sprite2 = spritelist.children[j];
var sprite2Pos = sprite2.position;
var imgWidthHalf2 = sprite2.width / 2;
var imgHeightHalf2 = sprite2.height / 2;
var rect2 = new Rect(sprite2Pos.x - imgWidthHalf2, sprite2Pos.y - imgHeightHalf2,
sprite2Pos.x + imgHeightHalf2, sprite2Pos.y + imgHeightHalf2 );
sprite2Pos.x + imgWidthHalf2, sprite2Pos.y + imgHeightHalf2 );

if(sprite2.visible && rect1.isCollide(rect2)){
visible = false;
Expand All @@ -412,8 +420,12 @@ IndoorMap3d = function(mapdiv){

rect1.tl[0] -= visibleMargin;
rect1.tl[1] -= visibleMargin;
rect1.br[0] += visibleMargin;
rect1.br[1] += visibleMargin;
rect2.tl[0] -= visibleMargin;
rect2.tl[1] -= visibleMargin;
rect2.br[0] += visibleMargin;
rect2.br[1] += visibleMargin;


if(sprite.visible == false && rect1.isCollide(rect2)){
Expand Down
5 changes: 5 additions & 0 deletions js/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ THREE.OrbitControls = function ( object, domElement ) {

switch ( event.touches.length ) {

case 0:
state = STATE.NONE;
break;

case 2:

state = STATE.TOUCH_ROTATE;
Expand All @@ -452,6 +456,7 @@ THREE.OrbitControls = function ( object, domElement ) {

default:
state = STATE.NONE;
return;

}
document.addEventListener( 'touchend', touchend, false );
Expand Down