@xeokit/xeokit-sdk 2.4.0-alpha-17 → 2.4.0-alpha-19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -11497,6 +11497,9 @@ class Annotation extends Marker {
|
|
|
11497
11497
|
this._marker.addEventListener("mouseleave", () => {
|
|
11498
11498
|
this.plugin.fire("markerMouseLeave", this);
|
|
11499
11499
|
});
|
|
11500
|
+
this._marker.addEventListener('wheel', (event) => {
|
|
11501
|
+
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel', event));
|
|
11502
|
+
});
|
|
11500
11503
|
}
|
|
11501
11504
|
if (!this._labelExternal) {
|
|
11502
11505
|
if (this._label) {
|
|
@@ -11512,6 +11515,9 @@ class Annotation extends Marker {
|
|
|
11512
11515
|
this._label = labelFragment.firstChild;
|
|
11513
11516
|
this._container.appendChild(this._label);
|
|
11514
11517
|
this._label.style.visibility = (this._markerShown && this._labelShown) ? "visible" : "hidden";
|
|
11518
|
+
this._label.addEventListener('wheel', (event) => {
|
|
11519
|
+
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel', event));
|
|
11520
|
+
});
|
|
11515
11521
|
}
|
|
11516
11522
|
}
|
|
11517
11523
|
|
|
@@ -113439,6 +113445,16 @@ class NavCubePlugin extends Plugin {
|
|
|
113439
113445
|
this.setIsProjectNorth(cfg.isProjectNorth);
|
|
113440
113446
|
this.setProjectNorthOffsetAngle(cfg.projectNorthOffsetAngle);
|
|
113441
113447
|
|
|
113448
|
+
const rotateTrueNorth = (function () {
|
|
113449
|
+
const trueNorthMatrix = math.mat4();
|
|
113450
|
+
const resultVec = math.vec3();
|
|
113451
|
+
return function (dir, vec) {
|
|
113452
|
+
math.identityMat4(trueNorthMatrix);
|
|
113453
|
+
math.rotationMat4v(dir * self._projectNorthOffsetAngle * math.DEGTORAD, [0, 1, 0], trueNorthMatrix);
|
|
113454
|
+
return math.transformVec3(trueNorthMatrix, vec, resultVec)
|
|
113455
|
+
}
|
|
113456
|
+
}());
|
|
113457
|
+
|
|
113442
113458
|
this._synchCamera = (function () {
|
|
113443
113459
|
var matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
|
|
113444
113460
|
var eyeLookVec = math.vec3();
|
|
@@ -113449,6 +113465,11 @@ class NavCubePlugin extends Plugin {
|
|
|
113449
113465
|
var look = viewer.camera.look;
|
|
113450
113466
|
var up = viewer.camera.up;
|
|
113451
113467
|
eyeLookVec = math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 5);
|
|
113468
|
+
|
|
113469
|
+
if (self._isProjectNorth && self._projectNorthOffsetAngle) {
|
|
113470
|
+
eyeLookVec = rotateTrueNorth(-1, eyeLookVec);
|
|
113471
|
+
}
|
|
113472
|
+
|
|
113452
113473
|
if (self._zUp) { // +Z up
|
|
113453
113474
|
math.transformVec3(matrix, eyeLookVec, eyeLookVecCube);
|
|
113454
113475
|
math.transformVec3(matrix, up, upCube);
|
|
@@ -113460,9 +113481,6 @@ class NavCubePlugin extends Plugin {
|
|
|
113460
113481
|
self._navCubeCamera.eye = eyeLookVec;
|
|
113461
113482
|
self._navCubeCamera.up = up;
|
|
113462
113483
|
}
|
|
113463
|
-
if (self._isProjectNorth && self._projectNorthOffsetAngle) {
|
|
113464
|
-
self._navCubeCamera.orbitYaw(self._projectNorthOffsetAngle);
|
|
113465
|
-
}
|
|
113466
113484
|
};
|
|
113467
113485
|
}());
|
|
113468
113486
|
|
|
@@ -113657,6 +113675,9 @@ class NavCubePlugin extends Plugin {
|
|
|
113657
113675
|
}
|
|
113658
113676
|
var dir = self._cubeTextureCanvas.getAreaDir(areaId);
|
|
113659
113677
|
if (dir) {
|
|
113678
|
+
if (self._isProjectNorth && self._projectNorthOffsetAngle) {
|
|
113679
|
+
dir = rotateTrueNorth(+1, dir);
|
|
113680
|
+
}
|
|
113660
113681
|
var up = self._cubeTextureCanvas.getAreaUp(areaId);
|
|
113661
113682
|
flyTo(dir, up, function () {
|
|
113662
113683
|
if (lastAreaId >= 0) {
|
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -11493,6 +11493,9 @@ class Annotation extends Marker {
|
|
|
11493
11493
|
this._marker.addEventListener("mouseleave", () => {
|
|
11494
11494
|
this.plugin.fire("markerMouseLeave", this);
|
|
11495
11495
|
});
|
|
11496
|
+
this._marker.addEventListener('wheel', (event) => {
|
|
11497
|
+
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel', event));
|
|
11498
|
+
});
|
|
11496
11499
|
}
|
|
11497
11500
|
if (!this._labelExternal) {
|
|
11498
11501
|
if (this._label) {
|
|
@@ -11508,6 +11511,9 @@ class Annotation extends Marker {
|
|
|
11508
11511
|
this._label = labelFragment.firstChild;
|
|
11509
11512
|
this._container.appendChild(this._label);
|
|
11510
11513
|
this._label.style.visibility = (this._markerShown && this._labelShown) ? "visible" : "hidden";
|
|
11514
|
+
this._label.addEventListener('wheel', (event) => {
|
|
11515
|
+
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel', event));
|
|
11516
|
+
});
|
|
11511
11517
|
}
|
|
11512
11518
|
}
|
|
11513
11519
|
|
|
@@ -113435,6 +113441,16 @@ class NavCubePlugin extends Plugin {
|
|
|
113435
113441
|
this.setIsProjectNorth(cfg.isProjectNorth);
|
|
113436
113442
|
this.setProjectNorthOffsetAngle(cfg.projectNorthOffsetAngle);
|
|
113437
113443
|
|
|
113444
|
+
const rotateTrueNorth = (function () {
|
|
113445
|
+
const trueNorthMatrix = math.mat4();
|
|
113446
|
+
const resultVec = math.vec3();
|
|
113447
|
+
return function (dir, vec) {
|
|
113448
|
+
math.identityMat4(trueNorthMatrix);
|
|
113449
|
+
math.rotationMat4v(dir * self._projectNorthOffsetAngle * math.DEGTORAD, [0, 1, 0], trueNorthMatrix);
|
|
113450
|
+
return math.transformVec3(trueNorthMatrix, vec, resultVec)
|
|
113451
|
+
}
|
|
113452
|
+
}());
|
|
113453
|
+
|
|
113438
113454
|
this._synchCamera = (function () {
|
|
113439
113455
|
var matrix = math.rotationMat4c(-90 * math.DEGTORAD, 1, 0, 0);
|
|
113440
113456
|
var eyeLookVec = math.vec3();
|
|
@@ -113445,6 +113461,11 @@ class NavCubePlugin extends Plugin {
|
|
|
113445
113461
|
var look = viewer.camera.look;
|
|
113446
113462
|
var up = viewer.camera.up;
|
|
113447
113463
|
eyeLookVec = math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye, look, eyeLookVec)), 5);
|
|
113464
|
+
|
|
113465
|
+
if (self._isProjectNorth && self._projectNorthOffsetAngle) {
|
|
113466
|
+
eyeLookVec = rotateTrueNorth(-1, eyeLookVec);
|
|
113467
|
+
}
|
|
113468
|
+
|
|
113448
113469
|
if (self._zUp) { // +Z up
|
|
113449
113470
|
math.transformVec3(matrix, eyeLookVec, eyeLookVecCube);
|
|
113450
113471
|
math.transformVec3(matrix, up, upCube);
|
|
@@ -113456,9 +113477,6 @@ class NavCubePlugin extends Plugin {
|
|
|
113456
113477
|
self._navCubeCamera.eye = eyeLookVec;
|
|
113457
113478
|
self._navCubeCamera.up = up;
|
|
113458
113479
|
}
|
|
113459
|
-
if (self._isProjectNorth && self._projectNorthOffsetAngle) {
|
|
113460
|
-
self._navCubeCamera.orbitYaw(self._projectNorthOffsetAngle);
|
|
113461
|
-
}
|
|
113462
113480
|
};
|
|
113463
113481
|
}());
|
|
113464
113482
|
|
|
@@ -113653,6 +113671,9 @@ class NavCubePlugin extends Plugin {
|
|
|
113653
113671
|
}
|
|
113654
113672
|
var dir = self._cubeTextureCanvas.getAreaDir(areaId);
|
|
113655
113673
|
if (dir) {
|
|
113674
|
+
if (self._isProjectNorth && self._projectNorthOffsetAngle) {
|
|
113675
|
+
dir = rotateTrueNorth(+1, dir);
|
|
113676
|
+
}
|
|
113656
113677
|
var up = self._cubeTextureCanvas.getAreaUp(areaId);
|
|
113657
113678
|
flyTo(dir, up, function () {
|
|
113658
113679
|
if (lastAreaId >= 0) {
|
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -2859,8 +2859,8 @@ _this13._currentAngleMeasurement.targetVisible=true;_this13._currentAngleMeasure
|
|
|
2859
2859
|
*/_this16.projection=cfg.projection;return _this16;}/**
|
|
2860
2860
|
* @private
|
|
2861
2861
|
*/_createClass(Annotation,[{key:"_buildHTML",value:function _buildHTML(){var _this17=this;if(!this._markerExternal){if(this._marker){this._container.removeChild(this._marker);this._marker=null;}var markerHTML=this._markerHTML||"<p></p>";// Make marker
|
|
2862
|
-
if(utils.isArray(markerHTML)){markerHTML=markerHTML.join("");}markerHTML=this._renderTemplate(markerHTML);var markerFragment=document.createRange().createContextualFragment(markerHTML);this._marker=markerFragment.firstChild;this._container.appendChild(this._marker);this._marker.style.visibility=this._markerShown?"visible":"hidden";this._marker.addEventListener("click",function(){_this17.plugin.fire("markerClicked",_this17);});this._marker.addEventListener("mouseenter",function(){_this17.plugin.fire("markerMouseEnter",_this17);});this._marker.addEventListener("mouseleave",function(){_this17.plugin.fire("markerMouseLeave",_this17);});}if(!this._labelExternal){if(this._label){this._container.removeChild(this._label);this._label=null;}var labelHTML=this._labelHTML||"<p></p>";// Make label
|
|
2863
|
-
if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._renderTemplate(labelHTML);var labelFragment=document.createRange().createContextualFragment(labelHTML);this._label=labelFragment.firstChild;this._container.appendChild(this._label);this._label.style.visibility=this._markerShown&&this._labelShown?"visible":"hidden";}}/**
|
|
2862
|
+
if(utils.isArray(markerHTML)){markerHTML=markerHTML.join("");}markerHTML=this._renderTemplate(markerHTML);var markerFragment=document.createRange().createContextualFragment(markerHTML);this._marker=markerFragment.firstChild;this._container.appendChild(this._marker);this._marker.style.visibility=this._markerShown?"visible":"hidden";this._marker.addEventListener("click",function(){_this17.plugin.fire("markerClicked",_this17);});this._marker.addEventListener("mouseenter",function(){_this17.plugin.fire("markerMouseEnter",_this17);});this._marker.addEventListener("mouseleave",function(){_this17.plugin.fire("markerMouseLeave",_this17);});this._marker.addEventListener('wheel',function(event){_this17.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel',event));});}if(!this._labelExternal){if(this._label){this._container.removeChild(this._label);this._label=null;}var labelHTML=this._labelHTML||"<p></p>";// Make label
|
|
2863
|
+
if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._renderTemplate(labelHTML);var labelFragment=document.createRange().createContextualFragment(labelHTML);this._label=labelFragment.firstChild;this._container.appendChild(this._label);this._label.style.visibility=this._markerShown&&this._labelShown?"visible":"hidden";this._label.addEventListener('wheel',function(event){_this17.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel',event));});}}/**
|
|
2864
2864
|
* @private
|
|
2865
2865
|
*/},{key:"_updatePosition",value:function _updatePosition(){var boundary=this.scene.canvas.boundary;var left=boundary[0];var top=boundary[1];var canvasPos=this.canvasPos;this._marker.style.left=Math.floor(left+canvasPos[0])-12+"px";this._marker.style.top=Math.floor(top+canvasPos[1])-12+"px";this._marker.style["z-index"]=90005+Math.floor(this._viewPos[2])+1;var offsetX=20;var offsetY=-17;this._label.style.left=20+Math.floor(left+canvasPos[0]+offsetX)+"px";this._label.style.top=Math.floor(top+canvasPos[1]+offsetY)+"px";this._label.style["z-index"]=90005+Math.floor(this._viewPos[2])+1;}/**
|
|
2866
2866
|
* @private
|
|
@@ -24576,10 +24576,10 @@ for(var i=0,len=areas.length;i<len;i++){var _area3=areas[i];var boundaries=_area
|
|
|
24576
24576
|
* @param {Boolean} [cfg.isProjectNorth] sets whether the NavCube switches between true north and project north - using the project north offset angle.
|
|
24577
24577
|
* @param {number} [cfg.projectNorthOffsetAngle] sets the NavCube project north offset angle - when the {@link isProjectNorth} is true.
|
|
24578
24578
|
*/function NavCubePlugin(viewer){var _this119;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,NavCubePlugin);_this119=_super79.call(this,"NavCube",viewer,cfg);viewer.navCube=_assertThisInitialized(_this119);var visible=true;try{_this119._navCubeScene=new Scene(viewer,{canvasId:cfg.canvasId,canvasElement:cfg.canvasElement,transparent:true});_this119._navCubeCanvas=_this119._navCubeScene.canvas.canvas;_this119._navCubeScene.input.keyboardEnabled=false;// Don't want keyboard input in the NavCube
|
|
24579
|
-
}catch(error){_this119.error(error);return _possibleConstructorReturn(_this119);}var navCubeScene=_this119._navCubeScene;navCubeScene.clearLights();new DirLight(navCubeScene,{dir:[0.4,-0.4,0.8],color:[0.8,1.0,1.0],intensity:1.0,space:"view"});new DirLight(navCubeScene,{dir:[-0.8,-0.3,-0.4],color:[0.8,0.8,0.8],intensity:1.0,space:"view"});new DirLight(navCubeScene,{dir:[0.8,-0.6,-0.8],color:[1.0,1.0,1.0],intensity:1.0,space:"view"});_this119._navCubeCamera=navCubeScene.camera;_this119._navCubeCamera.ortho.scale=7.0;_this119._navCubeCamera.ortho.near=0.1;_this119._navCubeCamera.ortho.far=2000;navCubeScene.edgeMaterial.edgeColor=[0.2,0.2,0.2];navCubeScene.edgeMaterial.edgeAlpha=0.6;_this119._zUp=Boolean(viewer.camera.zUp);var self=_assertThisInitialized(_this119);_this119.setIsProjectNorth(cfg.isProjectNorth);_this119.setProjectNorthOffsetAngle(cfg.projectNorthOffsetAngle);_this119._synchCamera=function(){var matrix=math.rotationMat4c(-90*math.DEGTORAD,1,0,0);var eyeLookVec=math.vec3();var eyeLookVecCube=math.vec3();var upCube=math.vec3();return function(){var eye=viewer.camera.eye;var look=viewer.camera.look;var up=viewer.camera.up;eyeLookVec=math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye,look,eyeLookVec)),5);if(self._zUp){// +Z up
|
|
24579
|
+
}catch(error){_this119.error(error);return _possibleConstructorReturn(_this119);}var navCubeScene=_this119._navCubeScene;navCubeScene.clearLights();new DirLight(navCubeScene,{dir:[0.4,-0.4,0.8],color:[0.8,1.0,1.0],intensity:1.0,space:"view"});new DirLight(navCubeScene,{dir:[-0.8,-0.3,-0.4],color:[0.8,0.8,0.8],intensity:1.0,space:"view"});new DirLight(navCubeScene,{dir:[0.8,-0.6,-0.8],color:[1.0,1.0,1.0],intensity:1.0,space:"view"});_this119._navCubeCamera=navCubeScene.camera;_this119._navCubeCamera.ortho.scale=7.0;_this119._navCubeCamera.ortho.near=0.1;_this119._navCubeCamera.ortho.far=2000;navCubeScene.edgeMaterial.edgeColor=[0.2,0.2,0.2];navCubeScene.edgeMaterial.edgeAlpha=0.6;_this119._zUp=Boolean(viewer.camera.zUp);var self=_assertThisInitialized(_this119);_this119.setIsProjectNorth(cfg.isProjectNorth);_this119.setProjectNorthOffsetAngle(cfg.projectNorthOffsetAngle);var rotateTrueNorth=function(){var trueNorthMatrix=math.mat4();var resultVec=math.vec3();return function(dir,vec){math.identityMat4(trueNorthMatrix);math.rotationMat4v(dir*self._projectNorthOffsetAngle*math.DEGTORAD,[0,1,0],trueNorthMatrix);return math.transformVec3(trueNorthMatrix,vec,resultVec);};}();_this119._synchCamera=function(){var matrix=math.rotationMat4c(-90*math.DEGTORAD,1,0,0);var eyeLookVec=math.vec3();var eyeLookVecCube=math.vec3();var upCube=math.vec3();return function(){var eye=viewer.camera.eye;var look=viewer.camera.look;var up=viewer.camera.up;eyeLookVec=math.mulVec3Scalar(math.normalizeVec3(math.subVec3(eye,look,eyeLookVec)),5);if(self._isProjectNorth&&self._projectNorthOffsetAngle){eyeLookVec=rotateTrueNorth(-1,eyeLookVec);}if(self._zUp){// +Z up
|
|
24580
24580
|
math.transformVec3(matrix,eyeLookVec,eyeLookVecCube);math.transformVec3(matrix,up,upCube);self._navCubeCamera.look=[0,0,0];self._navCubeCamera.eye=math.transformVec3(matrix,eyeLookVec,eyeLookVecCube);self._navCubeCamera.up=math.transformPoint3(matrix,up,upCube);}else{// +Y up
|
|
24581
|
-
self._navCubeCamera.look=[0,0,0];self._navCubeCamera.eye=eyeLookVec;self._navCubeCamera.up=up;}
|
|
24582
|
-
return;}down=false;if(downX===null){return;}var canvasPos=getCoordsWithinElement(e);var hit=navCubeScene.pick({canvasPos:canvasPos,pickSurface:true});if(hit){if(hit.uv){var areaId=self._cubeTextureCanvas.getArea(hit.uv);if(areaId>=0){document.body.style.cursor="pointer";if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}if(areaId>=0){self._cubeTextureCanvas.setAreaHighlighted(areaId,true);lastAreaId=areaId;self._repaint();if(e.x<downX-3||e.x>downX+3||e.y<downY-3||e.y>downY+3){return;}var dir=self._cubeTextureCanvas.getAreaDir(areaId);if(dir){var up=self._cubeTextureCanvas.getAreaUp(areaId);flyTo(dir,up,function(){if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}document.body.style.cursor="pointer";if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}if(areaId>=0){self._cubeTextureCanvas.setAreaHighlighted(areaId,false);lastAreaId=-1;self._repaint();}});}}}}}});document.addEventListener("mousemove",self._onMouseMove=function(e){if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}if(e.buttons===1&&!down){return;}if(down){var posX=e.clientX;var posY=e.clientY;document.body.style.cursor="move";actionMove(posX,posY);return;}if(!over){return;}var canvasPos=getCoordsWithinElement(e);var hit=navCubeScene.pick({canvasPos:canvasPos,pickSurface:true});if(hit){if(hit.uv){document.body.style.cursor="pointer";var areaId=self._cubeTextureCanvas.getArea(hit.uv);if(areaId===lastAreaId){return;}if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);}if(areaId>=0){self._cubeTextureCanvas.setAreaHighlighted(areaId,true);self._repaint();lastAreaId=areaId;}}}else{document.body.style.cursor="default";if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}}});var flyTo=function(){var center=math.vec3();return function(dir,up,ok){var aabb=self._fitVisible?viewer.scene.getAABB(viewer.scene.visibleObjectIds):viewer.scene.aabb;var diag=math.getAABB3Diag(aabb);math.getAABB3Center(aabb,center);var dist=Math.abs(diag/Math.tan(self._cameraFitFOV*math.DEGTORAD));viewer.cameraControl.pivotPos=center;if(self._cameraFly){viewer.cameraFlight.flyTo({look:center,eye:[center[0]-dist*dir[0],center[1]-dist*dir[1],center[2]-dist*dir[2]],up:up||[0,1,0],orthoScale:diag*1.1,fitFOV:self._cameraFitFOV,duration:self._cameraFlyDuration},ok);}else{viewer.cameraFlight.jumpTo({look:center,eye:[center[0]-dist*dir[0],center[1]-dist*dir[1],center[2]-dist*dir[2]],up:up||[0,1,0],orthoScale:diag*1.1,fitFOV:self._cameraFitFOV},ok);}};}();}_this119._onUpdated=viewer.localeService.on("updated",function(){_this119._cubeTextureCanvas.clear();_this119._repaint();});_this119.setVisible(cfg.visible);_this119.setCameraFitFOV(cfg.cameraFitFOV);_this119.setCameraFly(cfg.cameraFly);_this119.setCameraFlyDuration(cfg.cameraFlyDuration);_this119.setFitVisible(cfg.fitVisible);_this119.setSynchProjection(cfg.synchProjection);return _this119;}_createClass(NavCubePlugin,[{key:"send",value:function send(name,value){switch(name){case"language":this._cubeTextureCanvas.clear();this._repaint();// CubeTextureCanvas gets language from Viewer
|
|
24581
|
+
self._navCubeCamera.look=[0,0,0];self._navCubeCamera.eye=eyeLookVec;self._navCubeCamera.up=up;}};}();_this119._cubeTextureCanvas=new CubeTextureCanvas(viewer,cfg);_this119._cubeSampler=new Texture(navCubeScene,{image:_this119._cubeTextureCanvas.getImage(),flipY:true,wrapS:ClampToEdgeWrapping,wrapT:ClampToEdgeWrapping});_this119._cubeMesh=new Mesh(navCubeScene,{geometry:new ReadableGeometry(navCubeScene,{primitive:"triangles",normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],uv:[0.5,0.6666,0.25,0.6666,0.25,0.3333,0.5,0.3333,0.5,0.6666,0.5,0.3333,0.75,0.3333,0.75,0.6666,0.5,0.6666,0.5,1,0.25,1,0.25,0.6666,0.25,0.6666,0.0,0.6666,0.0,0.3333,0.25,0.3333,0.25,0,0.50,0,0.50,0.3333,0.25,0.3333,0.75,0.3333,1.0,0.3333,1.0,0.6666,0.75,0.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),material:new PhongMaterial(navCubeScene,{diffuse:[0.4,0.4,0.4],specular:[0.4,0.4,0.4],emissive:[.6,.6,.6],diffuseMap:_this119._cubeSampler,emissiveMap:_this119._cubeSampler}),visible:!!visible,edges:true});_this119._shadow=cfg.shadowVisible===false?null:new Mesh(navCubeScene,{geometry:new ReadableGeometry(navCubeScene,buildCylinderGeometry({center:[0,0,0],radiusTop:0.001,radiusBottom:1.4,height:0.01,radialSegments:20,heightSegments:1,openEnded:true})),material:new PhongMaterial(navCubeScene,{diffuse:[0.0,0.0,0.0],specular:[0,0,0],emissive:[0.0,0.0,0.0],alpha:0.5}),position:[0,-1.5,0],visible:!!visible,pickable:false,backfaces:false});_this119._onCameraMatrix=viewer.camera.on("matrix",_this119._synchCamera);_this119._onCameraWorldAxis=viewer.camera.on("worldAxis",function(){if(viewer.camera.zUp){_this119._zUp=true;_this119._cubeTextureCanvas.setZUp();_this119._repaint();_this119._synchCamera();}else if(viewer.camera.yUp){_this119._zUp=false;_this119._cubeTextureCanvas.setYUp();_this119._repaint();_this119._synchCamera();}});_this119._onCameraFOV=viewer.camera.perspective.on("fov",function(fov){if(_this119._synchProjection){_this119._navCubeCamera.perspective.fov=fov;}});_this119._onCameraProjection=viewer.camera.on("projection",function(projection){if(_this119._synchProjection){_this119._navCubeCamera.projection=projection==="ortho"||projection==="perspective"?projection:"perspective";}});var lastAreaId=-1;function actionMove(posX,posY){var yawInc=(posX-lastX)*-sensitivity;var pitchInc=(posY-lastY)*-sensitivity;viewer.camera.orbitYaw(yawInc);viewer.camera.orbitPitch(-pitchInc);lastX=posX;lastY=posY;}function getCoordsWithinElement(event){var coords=[0,0];if(!event){event=window.event;coords[0]=event.x;coords[1]=event.y;}else{var element=event.target;var totalOffsetLeft=0;var totalOffsetTop=0;while(element.offsetParent){totalOffsetLeft+=element.offsetLeft;totalOffsetTop+=element.offsetTop;element=element.offsetParent;}coords[0]=event.pageX-totalOffsetLeft;coords[1]=event.pageY-totalOffsetTop;}return coords;}{var downX=null;var downY=null;var down=false;var over=false;var sensitivity=0.5;var lastX;var lastY;self._navCubeCanvas.addEventListener("mouseenter",self._onMouseEnter=function(e){over=true;});self._navCubeCanvas.addEventListener("mouseleave",self._onMouseLeave=function(e){over=false;});self._navCubeCanvas.addEventListener("mousedown",self._onMouseDown=function(e){if(e.which!==1){return;}downX=e.x;downY=e.y;lastX=e.clientX;lastY=e.clientY;var canvasPos=getCoordsWithinElement(e);var hit=navCubeScene.pick({canvasPos:canvasPos});if(hit){down=true;}else{down=false;}});document.addEventListener("mouseup",self._onMouseUp=function(e){if(e.which!==1){// Left button
|
|
24582
|
+
return;}down=false;if(downX===null){return;}var canvasPos=getCoordsWithinElement(e);var hit=navCubeScene.pick({canvasPos:canvasPos,pickSurface:true});if(hit){if(hit.uv){var areaId=self._cubeTextureCanvas.getArea(hit.uv);if(areaId>=0){document.body.style.cursor="pointer";if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}if(areaId>=0){self._cubeTextureCanvas.setAreaHighlighted(areaId,true);lastAreaId=areaId;self._repaint();if(e.x<downX-3||e.x>downX+3||e.y<downY-3||e.y>downY+3){return;}var dir=self._cubeTextureCanvas.getAreaDir(areaId);if(dir){if(self._isProjectNorth&&self._projectNorthOffsetAngle){dir=rotateTrueNorth(+1,dir);}var up=self._cubeTextureCanvas.getAreaUp(areaId);flyTo(dir,up,function(){if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}document.body.style.cursor="pointer";if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}if(areaId>=0){self._cubeTextureCanvas.setAreaHighlighted(areaId,false);lastAreaId=-1;self._repaint();}});}}}}}});document.addEventListener("mousemove",self._onMouseMove=function(e){if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}if(e.buttons===1&&!down){return;}if(down){var posX=e.clientX;var posY=e.clientY;document.body.style.cursor="move";actionMove(posX,posY);return;}if(!over){return;}var canvasPos=getCoordsWithinElement(e);var hit=navCubeScene.pick({canvasPos:canvasPos,pickSurface:true});if(hit){if(hit.uv){document.body.style.cursor="pointer";var areaId=self._cubeTextureCanvas.getArea(hit.uv);if(areaId===lastAreaId){return;}if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);}if(areaId>=0){self._cubeTextureCanvas.setAreaHighlighted(areaId,true);self._repaint();lastAreaId=areaId;}}}else{document.body.style.cursor="default";if(lastAreaId>=0){self._cubeTextureCanvas.setAreaHighlighted(lastAreaId,false);self._repaint();lastAreaId=-1;}}});var flyTo=function(){var center=math.vec3();return function(dir,up,ok){var aabb=self._fitVisible?viewer.scene.getAABB(viewer.scene.visibleObjectIds):viewer.scene.aabb;var diag=math.getAABB3Diag(aabb);math.getAABB3Center(aabb,center);var dist=Math.abs(diag/Math.tan(self._cameraFitFOV*math.DEGTORAD));viewer.cameraControl.pivotPos=center;if(self._cameraFly){viewer.cameraFlight.flyTo({look:center,eye:[center[0]-dist*dir[0],center[1]-dist*dir[1],center[2]-dist*dir[2]],up:up||[0,1,0],orthoScale:diag*1.1,fitFOV:self._cameraFitFOV,duration:self._cameraFlyDuration},ok);}else{viewer.cameraFlight.jumpTo({look:center,eye:[center[0]-dist*dir[0],center[1]-dist*dir[1],center[2]-dist*dir[2]],up:up||[0,1,0],orthoScale:diag*1.1,fitFOV:self._cameraFitFOV},ok);}};}();}_this119._onUpdated=viewer.localeService.on("updated",function(){_this119._cubeTextureCanvas.clear();_this119._repaint();});_this119.setVisible(cfg.visible);_this119.setCameraFitFOV(cfg.cameraFitFOV);_this119.setCameraFly(cfg.cameraFly);_this119.setCameraFlyDuration(cfg.cameraFlyDuration);_this119.setFitVisible(cfg.fitVisible);_this119.setSynchProjection(cfg.synchProjection);return _this119;}_createClass(NavCubePlugin,[{key:"send",value:function send(name,value){switch(name){case"language":this._cubeTextureCanvas.clear();this._repaint();// CubeTextureCanvas gets language from Viewer
|
|
24583
24583
|
break;}}},{key:"_repaint",value:function _repaint(){var image=this._cubeTextureCanvas.getImage();this._cubeMesh.material.diffuseMap.image=image;this._cubeMesh.material.emissiveMap.image=image;}/**
|
|
24584
24584
|
* Sets if the NavCube is visible.
|
|
24585
24585
|
*
|