@xeokit/xeokit-sdk 2.6.3 → 2.6.6
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 +136 -124
- package/dist/xeokit-sdk.es.js +136 -124
- package/dist/xeokit-sdk.es5.js +63 -64
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +4 -4
- package/dist/xeokit-sdk.min.es5.js +2 -2
- package/package.json +1 -1
- package/src/extras/ContextMenu/ContextMenu.js +21 -0
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.js +47 -52
- package/src/plugins/BCFViewpointsPlugin/BCFViewpointsPlugin.js +1 -1
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +22 -23
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.js +40 -47
- package/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +4 -0
- package/src/viewer/scene/model/SceneModelTransform.js +1 -1
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsControl.d.ts +9 -0
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.d.ts +1 -2
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.d.ts +4 -0
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.d.ts +92 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.d.ts +1 -1
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.d.ts +13 -2
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.d.ts +70 -0
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -337,7 +337,7 @@ var groups=menu.groups;var html=[];html.push('<div class="xeokit-context-menu '+
|
|
|
337
337
|
var self=this;var lastSubMenu=null;if(groups){for(var _i7=0,_len2=groups.length;_i7<_len2;_i7++){var _group=groups[_i7];var _groupItems=_group.items;if(_groupItems){var _loop2=function _loop2(_j2,_lenj){var item=_groupItems[_j2];var itemSubMenu=item.subMenu;item.itemElement=document.getElementById(item.id);if(!item.itemElement){console.error("ContextMenu item element not found: "+item.id);return"continue";}item.itemElement.addEventListener("mouseenter",function(event){event.preventDefault();var subMenu=item.subMenu;if(!subMenu){if(lastSubMenu){self._hideMenu(lastSubMenu.id);lastSubMenu=null;}return;}if(lastSubMenu&&lastSubMenu.id!==subMenu.id){self._hideMenu(lastSubMenu.id);lastSubMenu=null;}if(item.enabled===false){return;}var itemElement=item.itemElement;var subMenuElement=subMenu.menuElement;var itemRect=itemElement.getBoundingClientRect();subMenuElement.getBoundingClientRect();var subMenuWidth=200;// TODO
|
|
338
338
|
var showOnLeft=itemRect.right+subMenuWidth>window.innerWidth;if(showOnLeft){self._showMenu(subMenu.id,itemRect.left-subMenuWidth,itemRect.top-1);}else{self._showMenu(subMenu.id,itemRect.right-5,itemRect.top-1);}lastSubMenu=subMenu;});if(!itemSubMenu){// Item without sub-menu
|
|
339
339
|
// clicking item fires the item's action callback
|
|
340
|
-
item.itemElement.addEventListener("click",function(event){event.preventDefault();if(!self._context){return;}if(item.enabled===false){return;}if(item.doAction){item.doAction(self._context);}if(_this5._hideOnAction){self.hide();}else{self._updateItemsTitles();self._updateItemsEnabledStatus();}});item.itemElement.addEventListener("mouseenter",function(event){event.preventDefault();if(item.enabled===false){return;}if(item.doHover){item.doHover(self._context);}});}};for(var _j2=0,_lenj=_groupItems.length;_j2<_lenj;_j2++){var _ret=_loop2(_j2,_lenj);if(_ret==="continue")continue;}}}}}},{key:"_updateItemsTitles",value:function _updateItemsTitles(){// Dynamically updates the title of each Item to the result of Item#getTitle()
|
|
340
|
+
item.itemElement.addEventListener("click",function(event){event.preventDefault();if(!self._context){return;}if(item.enabled===false){return;}if(item.doAction){item.doAction(self._context);}if(_this5._hideOnAction){self.hide();}else{self._updateItemsTitles();self._updateItemsEnabledStatus();}});item.itemElement.addEventListener("mouseup",function(event){if(event.which!==3){return;}event.preventDefault();if(!self._context){return;}if(item.enabled===false){return;}if(item.doAction){item.doAction(self._context);}if(_this5._hideOnAction){self.hide();}else{self._updateItemsTitles();self._updateItemsEnabledStatus();}});item.itemElement.addEventListener("mouseenter",function(event){event.preventDefault();if(item.enabled===false){return;}if(item.doHover){item.doHover(self._context);}});}};for(var _j2=0,_lenj=_groupItems.length;_j2<_lenj;_j2++){var _ret=_loop2(_j2,_lenj);if(_ret==="continue")continue;}}}}}},{key:"_updateItemsTitles",value:function _updateItemsTitles(){// Dynamically updates the title of each Item to the result of Item#getTitle()
|
|
341
341
|
if(!this._context){return;}for(var _i8=0,len=this._itemList.length;_i8<len;_i8++){var item=this._itemList[_i8];var itemElement=item.itemElement;if(!itemElement){continue;}var getShown=item.getShown;if(!getShown||!getShown(this._context)){continue;}var title=item.getTitle(this._context);if(item.subMenu){itemElement.innerText=title;}else{itemElement.innerText=title;}}}},{key:"_updateItemsEnabledStatus",value:function _updateItemsEnabledStatus(){// Enables or disables each Item, depending on the result of Item#getEnabled()
|
|
342
342
|
if(!this._context){return;}for(var _i9=0,len=this._itemList.length;_i9<len;_i9++){var item=this._itemList[_i9];var itemElement=item.itemElement;if(!itemElement){continue;}var getEnabled=item.getEnabled;if(!getEnabled){continue;}var getShown=item.getShown;if(!getShown){continue;}var shown=getShown(this._context);item.shown=shown;if(!shown){itemElement.style.visibility="hidden";itemElement.style.height="0";itemElement.style.padding="0";continue;}else{itemElement.style.visibility="visible";itemElement.style.height="auto";itemElement.style.padding=null;}var enabled=getEnabled(this._context);item.enabled=enabled;if(!enabled){itemElement.classList.add("disabled");}else{itemElement.classList.remove("disabled");}}}},{key:"_showMenu",value:function _showMenu(menuId,pageX,pageY){// Shows the given menu, at the specified page coordinates
|
|
343
343
|
var menu=this._menuMap[menuId];if(!menu){console.error("Menu not found: "+menuId);return;}if(menu.shown){return;}var menuElement=menu.menuElement;if(menuElement){this._showMenuElement(menuElement,pageX,pageY);menu.shown=true;}}},{key:"_hideMenu",value:function _hideMenu(menuId){// Hides the given menu
|
|
@@ -3326,7 +3326,7 @@ _this19._initMarkerDiv();_this19._onMouseHoverSurface=null;_this19._onHoverNothi
|
|
|
3326
3326
|
*
|
|
3327
3327
|
*/var AngleMeasurementsTouchControl=/*#__PURE__*/function(_AngleMeasurementsCon2){_inherits(AngleMeasurementsTouchControl,_AngleMeasurementsCon2);var _super9=_createSuper(AngleMeasurementsTouchControl);/**
|
|
3328
3328
|
* Creates a AngleMeasurementsTouchControl bound to the given AngleMeasurementsPlugin.
|
|
3329
|
-
*/function AngleMeasurementsTouchControl(angleMeasurementsPlugin){var _this23;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsTouchControl);_this23=_super9.call(this,angleMeasurementsPlugin.viewer.scene);_this23.pointerLens=cfg.pointerLens;_this23.pointerCircle=new PointerCircle(angleMeasurementsPlugin.viewer);_this23._active=false;var markerDiv=document.createElement('div');var canvas=_this23.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";_this23.markerDiv=markerDiv;_this23._currentAngleMeasurement=null;_this23._onCanvasTouchStart=null;_this23._onCanvasTouchEnd=null;_this23._longTouchTimeoutMs=300;_this23.
|
|
3329
|
+
*/function AngleMeasurementsTouchControl(angleMeasurementsPlugin){var _this23;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsTouchControl);_this23=_super9.call(this,angleMeasurementsPlugin.viewer.scene);_this23.pointerLens=cfg.pointerLens;_this23.pointerCircle=new PointerCircle(angleMeasurementsPlugin.viewer);_this23._active=false;var markerDiv=document.createElement('div');var canvas=_this23.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";_this23.markerDiv=markerDiv;_this23._currentAngleMeasurement=null;_this23._onCanvasTouchStart=null;_this23._onCanvasTouchEnd=null;_this23._longTouchTimeoutMs=300;_this23._snapping=cfg.snapping!==false;_this23._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;_this23._attachPlugin(angleMeasurementsPlugin,cfg);return _this23;}_createClass(AngleMeasurementsTouchControl,[{key:"_attachPlugin",value:function _attachPlugin(angleMeasurementsPlugin){/**
|
|
3330
3330
|
* The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsTouchControl.
|
|
3331
3331
|
* @type {AngleMeasurementsPlugin}
|
|
3332
3332
|
*/this.angleMeasurementsPlugin=angleMeasurementsPlugin;/**
|
|
@@ -3336,25 +3336,25 @@ _this19._initMarkerDiv();_this19._onMouseHoverSurface=null;_this19._onHoverNothi
|
|
|
3336
3336
|
*
|
|
3337
3337
|
* @returns {Boolean}
|
|
3338
3338
|
*/},{key:"active",get:function get(){return this._active;}/**
|
|
3339
|
-
* Sets whether snap-to-vertex
|
|
3340
|
-
*
|
|
3341
|
-
* @param snapToVertex
|
|
3342
|
-
*/},{key:"snapToVertex",get:/**
|
|
3343
|
-
* Gets whether snap-to-vertex is enabled for this AngleMeasurementsTouchControl.
|
|
3344
|
-
* This is `true` by default.
|
|
3345
|
-
* @returns {*}
|
|
3346
|
-
*/function get(){return this._snapToVertex;}/**
|
|
3347
|
-
* Sets whether snap-to-edge is enabled for this AngleMeasurementsTouchControl.
|
|
3339
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
3340
|
+
*
|
|
3348
3341
|
* This is `true` by default.
|
|
3349
|
-
*
|
|
3350
|
-
|
|
3351
|
-
*
|
|
3342
|
+
*
|
|
3343
|
+
* Internally, this deactivates then activates the AngleMeasurementsMouseControl when changed, which means that
|
|
3344
|
+
* it will destroy any AngleMeasurements currently under construction, and incurs some overhead, since it unbinds
|
|
3345
|
+
* and rebinds various input handlers.
|
|
3346
|
+
*
|
|
3347
|
+
* @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this AngleMeasurementsMouseControl.
|
|
3348
|
+
*/},{key:"snapping",get:/**
|
|
3349
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
3350
|
+
*
|
|
3352
3351
|
* This is `true` by default.
|
|
3353
|
-
*
|
|
3354
|
-
|
|
3352
|
+
*
|
|
3353
|
+
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
3354
|
+
*/function get(){return this._snapping;}/**
|
|
3355
3355
|
* Activates this AngleMeasurementsTouchControl, ready to respond to input.
|
|
3356
|
-
*/,set:function set(
|
|
3357
|
-
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24.
|
|
3356
|
+
*/,set:function set(snapping){if(snapping!==this._snapping){this._snapping=snapping;this.deactivate();this.activate();}else{this._snapping=snapping;}}},{key:"activate",value:function activate(){var _this24=this;if(this._active){return;}var plugin=this.plugin;var scene=this.scene;var canvas=scene.canvas.canvas;plugin.pointerLens;var pointerWorldPos=math.vec3();var touchTolerance=20;var longTouchTimeout=null;this._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;var touchStartCanvasPos=math.vec2();var touchMoveCanvasPos=math.vec2();var touchEndCanvasPos=math.vec2();var touchId=null;var disableCameraNavigation=function disableCameraNavigation(){_this24.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this24.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this24._currentAngleMeasurement){_this24._currentAngleMeasurement.destroy();_this24._currentAngleMeasurement=null;}enableCameraNavigation();_this24._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){var currentNumTouches=event.touches.length;if(currentNumTouches!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;touchStartCanvasPos.set([touchX,touchY]);touchMoveCanvasPos.set([touchX,touchY]);switch(_this24._touchState){case WAITING_FOR_ORIGIN_TOUCH_START$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3357
|
+
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapping,snapToEdge:_this24._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this24.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this24.pointerCircle.start(pickResult.canvasPos);}else{return;}}longTouchTimeout=setTimeout(function(){if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){return;// Has moved
|
|
3358
3358
|
}// Long touch
|
|
3359
3359
|
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.cursorPos=touchStartCanvasPos;}if(_this24.pointerLens){_this24.pointerLens.canvasPos=touchMoveCanvasPos;_this24.pointerLens.snapped=false;}if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.canvasPos;_this24.pointerLens.snapped=true;}// pointerWorldPos.set(snapPickResult.worldPos);
|
|
3360
3360
|
if(!_this24._currentAngleMeasurement){_this24._currentAngleMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},corner:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity}});_this24._currentAngleMeasurement.clickable=false;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=false;_this24._currentAngleMeasurement.cornerVisible=false;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;}else{_this24._currentAngleMeasurement.origin.worldPos=pointerWorldPos;}_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);// if (this.pointerLens) {
|
|
@@ -3362,36 +3362,36 @@ if(!_this24._currentAngleMeasurement){_this24._currentAngleMeasurement=plugin.cr
|
|
|
3362
3362
|
// this.pointerLens.snapped = false;
|
|
3363
3363
|
// }
|
|
3364
3364
|
_this24._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_ORIGIN_TOUCH_START -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
3365
|
-
|
|
3365
|
+
disableCameraNavigation();},_this24._longTouchTimeoutMs);_this24._touchState=WAITING_FOR_ORIGIN_QUICK_TOUCH_END$1;//console.log("touchstart: this._touchState= WAITING_FOR_ORIGIN_TOUCH_START -> WAITING_FOR_ORIGIN_QUICK_TOUCH_END")
|
|
3366
3366
|
touchId=touch.identifier;break;case WAITING_FOR_CORNER_TOUCH_START:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3367
3367
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;return;}if(currentNumTouches===1){// One finger down
|
|
3368
3368
|
longTouchTimeout=setTimeout(function(){longTouchTimeout=null;if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){// Has moved
|
|
3369
3369
|
return;}// Long touch
|
|
3370
|
-
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24.
|
|
3371
|
-
|
|
3370
|
+
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapping,snapToEdge:_this24._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}_this24.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this24._currentAngleMeasurement.corner.worldPos=snapPickResult.worldPos;_this24._currentAngleMeasurement.corner.entity=snapPickResult.entity;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{var _pickResult2=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult2&&_pickResult2.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=_pickResult2.canvasPos;_this24.pointerLens.snapped=false;}_this24.pointerCircle.start(_pickResult2.canvasPos);pointerWorldPos.set(_pickResult2.worldPos);_this24._currentAngleMeasurement.corner.worldPos=_pickResult2.worldPos;_this24._currentAngleMeasurement.corner.entity=_pickResult2.entity;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{if(_this24.pointerLens){_this24.pointerLens.cursorPos=null;_this24.pointerLens.snapped=false;}}}_this24._touchState=WAITING_FOR_CORNER_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_CORNER_LONG_TOUCH_END")
|
|
3371
|
+
disableCameraNavigation();},_this24._longTouchTimeoutMs);_this24._touchState=WAITING_FOR_CORNER_QUICK_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_CORNER_QUICK_TOUCH_END")
|
|
3372
3372
|
}touchId=touch.identifier;break;case WAITING_FOR_TARGET_TOUCH_START$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3373
3373
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;return;}if(currentNumTouches===1){// One finger down
|
|
3374
3374
|
longTouchTimeout=setTimeout(function(){longTouchTimeout=null;if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){// Has moved
|
|
3375
3375
|
return;}// Long touch
|
|
3376
|
-
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24.
|
|
3377
|
-
|
|
3376
|
+
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapping,snapToEdge:_this24._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}_this24.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this24._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this24._currentAngleMeasurement.target.entity=snapPickResult.entity;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=true;_this24._currentAngleMeasurement.targetVisible=true;_this24._currentAngleMeasurement.targetWireVisible=true;_this24._currentAngleMeasurement.angleVisible=true;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{var _pickResult3=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult3&&_pickResult3.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=_pickResult3.canvasPos;_this24.pointerLens.snapped=false;}_this24.pointerCircle.start(_pickResult3.canvasPos);pointerWorldPos.set(_pickResult3.worldPos);_this24._currentAngleMeasurement.target.worldPos=_pickResult3.worldPos;_this24._currentAngleMeasurement.target.entity=_pickResult3.entity;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=true;_this24._currentAngleMeasurement.targetVisible=true;_this24._currentAngleMeasurement.targetWireVisible=true;_this24._currentAngleMeasurement.angleVisible=true;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{if(_this24.pointerLens){_this24.pointerLens.cursorPos=null;_this24.pointerLens.snapped=false;}}}_this24._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
3377
|
+
disableCameraNavigation();},_this24._longTouchTimeoutMs);_this24._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
3378
3378
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this24._touchState=TOUCH_CANCELING$1;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
3379
|
-
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this24.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}touchMoveCanvasPos.set([touchX,touchY]);var snapPickResult;var pickResult;switch(_this24._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this24.pointerLens){_this24.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24.
|
|
3379
|
+
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this24.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}touchMoveCanvasPos.set([touchX,touchY]);var snapPickResult;var pickResult;switch(_this24._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this24.pointerLens){_this24.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapping,snapToEdge:_this24._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this24.pointerLens){_this24.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);_this24._currentAngleMeasurement.origin.worldPos=snapPickResult.worldPos;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=pickResult.canvasPos;_this24.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);_this24._currentAngleMeasurement.origin.worldPos=pickResult.worldPos;}else{if(_this24.pointerLens){_this24.pointerLens.cursorPos=null;_this24.pointerLens.snapped=false;}}}_this24._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END$1;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
3380
3380
|
break;case WAITING_FOR_CORNER_LONG_TOUCH_END:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3381
3381
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this24.pointerLens){_this24.pointerLens.visible=false;}_this24._touchState=TOUCH_CANCELING$1;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_CORNER -> TOUCH_CANCELING")
|
|
3382
|
-
return;}if(_this24.pointerLens){_this24.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24.
|
|
3382
|
+
return;}if(_this24.pointerLens){_this24.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapping,snapToEdge:_this24._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}_this24._currentAngleMeasurement.corner.worldPos=snapPickResult.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=pickResult.canvasPos;_this24.pointerLens.snapped=false;}_this24._currentAngleMeasurement.corner.worldPos=pickResult.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;}}_this24._touchState=WAITING_FOR_CORNER_LONG_TOUCH_END;break;case WAITING_FOR_TARGET_LONG_TOUCH_END$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3383
3383
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this24.pointerLens){_this24.pointerLens.visible=false;}_this24._touchState=TOUCH_CANCELING$1;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_TARGET -> TOUCH_CANCELING")
|
|
3384
|
-
return;}if(_this24.pointerLens){_this24.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24.
|
|
3384
|
+
return;}if(_this24.pointerLens){_this24.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapping,snapToEdge:_this24._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}_this24._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=true;_this24._currentAngleMeasurement.targetVisible=true;_this24._currentAngleMeasurement.targetWireVisible=true;_this24._currentAngleMeasurement.angleVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=pickResult.canvasPos;_this24.pointerLens.snapped=false;}_this24._currentAngleMeasurement.target.worldPos=pickResult.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=true;_this24._currentAngleMeasurement.targetVisible=true;_this24._currentAngleMeasurement.targetWireVisible=true;_this24._currentAngleMeasurement.angleVisible=true;}}_this24._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this24.pointerCircle.stop();var numChangedTouches=event.changedTouches.length;if(numChangedTouches!==1){return;}var touch=event.changedTouches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}touchEndCanvasPos.set([touchX,touchY]);switch(_this24._touchState){case WAITING_FOR_ORIGIN_QUICK_TOUCH_END$1:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this24._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this24._currentAngleMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos},corner:{worldPos:pickResult.worldPos},target:{worldPos:pickResult.worldPos}});_this24._currentAngleMeasurement.clickable=false;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=false;_this24._currentAngleMeasurement.cornerVisible=false;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;_this24._touchState=WAITING_FOR_CORNER_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_CORNER_TOUCH_START")
|
|
3385
3385
|
}else{if(_this24._currentAngleMeasurement){_this24._currentAngleMeasurement.destroy();_this24._currentAngleMeasurement=null;}_this24._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3386
|
-
}}
|
|
3386
|
+
}}enableCameraNavigation();break;case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this24.pointerLens){_this24.pointerLens.visible=false;}if(!_this24._currentAngleMeasurement){if(_this24.pointerLens){_this24.pointerLens.snapped=false;_this24.pointerLens.visible=false;}_this24._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (no measurement) -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3387
3387
|
}else{_this24._touchState=WAITING_FOR_CORNER_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (picked, begin measurement) -> WAITING_FOR_CORNER_TOUCH_START")
|
|
3388
|
-
}
|
|
3388
|
+
}enableCameraNavigation();break;case WAITING_FOR_CORNER_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this24._touchState=WAITING_FOR_CORNER_TOUCH_START;return;}var _pickResult4=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult4&&_pickResult4.worldPos){_this24._currentAngleMeasurement.corner.worldPos=_pickResult4.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;_this24._touchState=WAITING_FOR_TARGET_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3389
3389
|
}else{if(_this24._currentAngleMeasurement){_this24._currentAngleMeasurement.destroy();_this24._currentAngleMeasurement=null;}_this24._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3390
|
-
}}
|
|
3391
|
-
|
|
3392
|
-
}
|
|
3390
|
+
}}enableCameraNavigation();break;case WAITING_FOR_CORNER_LONG_TOUCH_END:if(_this24.pointerLens){_this24.pointerLens.visible=false;}_this24._touchState=WAITING_FOR_TARGET_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_CORNER_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3391
|
+
enableCameraNavigation();break;case WAITING_FOR_TARGET_QUICK_TOUCH_END$1:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this24._touchState=WAITING_FOR_TARGET_TOUCH_START$1;return;}var _pickResult5=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult5&&_pickResult5.worldPos){_this24._currentAngleMeasurement.target.worldPos=_pickResult5.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=true;_this24._currentAngleMeasurement.targetVisible=true;_this24._currentAngleMeasurement.targetWireVisible=true;_this24._currentAngleMeasurement.angleVisible=true;_this24.angleMeasurementsPlugin.fire("measurementEnd",_this24._currentAngleMeasurement);_this24._currentAngleMeasurement=null;}else{if(_this24._currentAngleMeasurement){_this24._currentAngleMeasurement.destroy();_this24._currentAngleMeasurement=null;}}_this24._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3392
|
+
}enableCameraNavigation();break;case WAITING_FOR_TARGET_LONG_TOUCH_END$1:if(_this24.pointerLens){_this24.pointerLens.visible=false;}if(!_this24._currentAngleMeasurement||!_this24._currentAngleMeasurement.targetVisible){if(_this24._currentAngleMeasurement){_this24._currentAngleMeasurement.destroy();_this24._currentAngleMeasurement=null;}_this24._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END (no target found) -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3393
3393
|
}else{_this24._currentAngleMeasurement.clickable=true;_this24.angleMeasurementsPlugin.fire("measurementEnd",_this24._currentAngleMeasurement);_this24._currentAngleMeasurement=null;_this24._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3394
|
-
}
|
|
3394
|
+
}enableCameraNavigation();break;}},{passive:true});this._active=true;}/**
|
|
3395
3395
|
* Deactivates this AngleMeasurementsTouchControl, making it unresponsive to input.
|
|
3396
3396
|
*
|
|
3397
3397
|
* Destroys any {@link AngleMeasurement} under construction.
|
|
@@ -10155,7 +10155,7 @@ gl.drawArrays(geometryState.primitive,0,positionsBuf.numItems/3);};PickTriangleR
|
|
|
10155
10155
|
*/var tempVec3a$D=math.vec3();// No ID, because there is exactly one PickMeshRenderer per scene
|
|
10156
10156
|
/**
|
|
10157
10157
|
* @private
|
|
10158
|
-
*/var OcclusionRenderer=function OcclusionRenderer(hash,mesh){this._hash=hash;this._shaderSource=new OcclusionShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$1={};OcclusionRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.occlusionHash].join(";");var renderer=renderers$1[hash];if(!renderer){renderer=new OcclusionRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$1[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};OcclusionRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$1[this._hash];stats.memory.programs--;}};OcclusionRenderer.prototype.webglContextRestored=function(){this._program=null;};OcclusionRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var materialState=mesh._material._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}this._lastMaterialId=materialState.id;}var camera=scene.camera;gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$D);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}gl.uniformMatrix4fv(this._uProjMatrix,false,camera._project._state.matrix);gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);}};OcclusionRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var clips=scene._sectionPlanesState.sectionPlanes;for(var _i119=0,len=clips.length;_i119<len;_i119++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i119),pos:program.getLocation("sectionPlanePos"+_i119),dir:program.getLocation("sectionPlaneDir"+_i119)});}this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};OcclusionRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var project=scene.camera.project;var gl=scene.canvas.gl;this._program.bind();frameCtx.useProgram++;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};/**
|
|
10158
|
+
*/var OcclusionRenderer=function OcclusionRenderer(hash,mesh){this._hash=hash;this._shaderSource=new OcclusionShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$1={};OcclusionRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.occlusionHash].join(";");var renderer=renderers$1[hash];if(!renderer){renderer=new OcclusionRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$1[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};OcclusionRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$1[this._hash];stats.memory.programs--;}};OcclusionRenderer.prototype.webglContextRestored=function(){this._program=null;};OcclusionRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var materialState=mesh._material._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(materialState.alpha<1.0){return;}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}this._lastMaterialId=materialState.id;}var camera=scene.camera;gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$D);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}gl.uniformMatrix4fv(this._uProjMatrix,false,camera._project._state.matrix);gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);}};OcclusionRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var clips=scene._sectionPlanesState.sectionPlanes;for(var _i119=0,len=clips.length;_i119<len;_i119++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i119),pos:program.getLocation("sectionPlanePos"+_i119),dir:program.getLocation("sectionPlaneDir"+_i119)});}this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};OcclusionRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var project=scene.camera.project;var gl=scene.canvas.gl;this._program.bind();frameCtx.useProgram++;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};/**
|
|
10159
10159
|
* @private
|
|
10160
10160
|
*/var ShadowShaderSource=/*#__PURE__*/_createClass(function ShadowShaderSource(mesh){_classCallCheck(this,ShadowShaderSource);this.vertex=buildVertex(mesh);this.fragment=buildFragment(mesh);});function buildVertex(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var src=[];src.push("// Mesh shadow vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("worldPosition = modelMatrix * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");}src.push(" gl_Position = shadowProjMatrix * viewPosition;");src.push("}");return src;}function buildFragment(mesh){var scene=mesh.scene;scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("// Mesh shadow fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("vec4 encodeFloat( const in float depth ) {");src.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);");src.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);");src.push(" vec4 comp = fract(depth * bitShift);");src.push(" comp -= comp.xxyz * bitMask;");src.push(" return comp;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}src.push("outColor = encodeFloat(gl_FragCoord.z);");src.push("}");return src;}/**
|
|
10161
10161
|
* @private
|
|
@@ -16791,7 +16791,7 @@ var edgeIndex=void 0;if((edgeIndex=edgeSearch(ii0,ii1))>=0){if(alreadyOutputEdge
|
|
|
16791
16791
|
* Unique ID of this SceneModelTransform.
|
|
16792
16792
|
*
|
|
16793
16793
|
* The SceneModelTransform is registered against this ID in {@link SceneModel#transforms}.
|
|
16794
|
-
*/this.id=cfg.id;this._parentTransform=cfg.parent;this._childTransforms=[];this._meshes=[];this._scale=new Float32Array([1,1,1]);this._quaternion=math.identityQuaternion(new Float32Array(4));this._rotation=new Float32Array(3);this._position=new Float32Array(3);this._localMatrix=math.identityMat4(new Float32Array(16));this._worldMatrix=math.identityMat4(new Float32Array(16));this._localMatrixDirty=true;this._worldMatrixDirty=true;if(cfg.matrix){this.matrix=cfg.matrix;}else{this.scale=cfg.scale;this.position=cfg.position;if(cfg.quaternion);else{this.rotation=cfg.rotation;}}if(cfg.parent){cfg.parent._addChildTransform(this);}}_createClass(SceneModelTransform,[{key:"_addChildTransform",value:function _addChildTransform(childTransform){this._childTransforms.push(childTransform);childTransform._parentTransform=this;childTransform._transformDirty();childTransform.
|
|
16794
|
+
*/this.id=cfg.id;this._parentTransform=cfg.parent;this._childTransforms=[];this._meshes=[];this._scale=new Float32Array([1,1,1]);this._quaternion=math.identityQuaternion(new Float32Array(4));this._rotation=new Float32Array(3);this._position=new Float32Array(3);this._localMatrix=math.identityMat4(new Float32Array(16));this._worldMatrix=math.identityMat4(new Float32Array(16));this._localMatrixDirty=true;this._worldMatrixDirty=true;if(cfg.matrix){this.matrix=cfg.matrix;}else{this.scale=cfg.scale;this.position=cfg.position;if(cfg.quaternion);else{this.rotation=cfg.rotation;}}if(cfg.parent){cfg.parent._addChildTransform(this);}}_createClass(SceneModelTransform,[{key:"_addChildTransform",value:function _addChildTransform(childTransform){this._childTransforms.push(childTransform);childTransform._parentTransform=this;childTransform._transformDirty();childTransform._setSubtreeAABBsDirty(this);}},{key:"_addMesh",value:function _addMesh(mesh){this._meshes.push(mesh);mesh.transform=this;// childTransform._setWorldMatrixDirty();
|
|
16795
16795
|
// childTransform._setAABBDirty();
|
|
16796
16796
|
}/**
|
|
16797
16797
|
* The optional parent SceneModelTransform.
|
|
@@ -19115,7 +19115,7 @@ alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}alpha=Math.round(alpha*255).
|
|
|
19115
19115
|
* then this method will apply the updates to objects within those composites.
|
|
19116
19116
|
*/},{key:"setViewpoint",value:function setViewpoint(bcfViewpoint){var _this82=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(!bcfViewpoint){return;}var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;var rayCast=options.rayCast!==false;var immediate=options.immediate!==false;var reset=options.reset!==false;var realWorldOffset=scene.realWorldOffset;var reverseClippingPlanes=options.reverseClippingPlanes===true;scene.clearSectionPlanes();if(bcfViewpoint.clipping_planes&&bcfViewpoint.clipping_planes.length>0){bcfViewpoint.clipping_planes.forEach(function(e){var pos=xyzObjectToArray(e.location,tempVec3$5);var dir=xyzObjectToArray(e.direction,tempVec3$5);if(reverseClippingPlanes){math.negateVec3(dir);}math.subVec3(pos,realWorldOffset);if(camera.yUp){pos=ZToY(pos);dir=ZToY(dir);}new SectionPlane(scene,{pos:pos,dir:dir});});}scene.clearLines();if(bcfViewpoint.lines&&bcfViewpoint.lines.length>0){var positions=[];var indices=[];var _i450=0;bcfViewpoint.lines.forEach(function(e){if(!e.start_point){return;}if(!e.end_point){return;}positions.push(e.start_point.x);positions.push(e.start_point.y);positions.push(e.start_point.z);positions.push(e.end_point.x);positions.push(e.end_point.y);positions.push(e.end_point.z);indices.push(_i450++);indices.push(_i450++);});new LineSet(scene,{positions:positions,indices:indices,clippable:false,collidable:true});}scene.clearBitmaps();if(bcfViewpoint.bitmaps&&bcfViewpoint.bitmaps.length>0){bcfViewpoint.bitmaps.forEach(function(e){var bitmap_type=e.bitmap_type||"jpg";// "jpg" | "png"
|
|
19117
19117
|
var bitmap_data=e.bitmap_data;// base64
|
|
19118
|
-
var location=xyzObjectToArray(e.location,tempVec3a$9);var normal=xyzObjectToArray(e.normal,tempVec3b$6);var up=xyzObjectToArray(e.up,tempVec3c$4);var height=e.height||1;if(!bitmap_type){return;}if(!bitmap_data){return;}if(!location){return;}if(!normal){return;}if(!up){return;}if(camera.yUp){location=ZToY(location);normal=ZToY(normal);up=ZToY(up);}new Bitmap(scene,{src:bitmap_data,type:bitmap_type,pos:location,normal:normal,up:up,clippable:false,collidable:true,height:height});});}if(reset){scene.setObjectsXRayed(scene.xrayedObjectIds,false);scene.setObjectsHighlighted(scene.highlightedObjectIds,false);scene.setObjectsSelected(scene.selectedObjectIds,false);}if(bcfViewpoint.components){if(bcfViewpoint.components.visibility){if(!bcfViewpoint.components.visibility.default_visibility){scene.setObjectsVisible(scene.objectIds,false);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this82._withBCFComponent(options,component,function(entity){return entity.visible=true;});});}}else{scene.setObjectsVisible(scene.objectIds,true);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this82._withBCFComponent(options,component,function(entity){return entity.visible=false;});});}}var view_setup_hints=bcfViewpoint.components.visibility.view_setup_hints;if(view_setup_hints){if(view_setup_hints.spaces_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"),
|
|
19118
|
+
var location=xyzObjectToArray(e.location,tempVec3a$9);var normal=xyzObjectToArray(e.normal,tempVec3b$6);var up=xyzObjectToArray(e.up,tempVec3c$4);var height=e.height||1;if(!bitmap_type){return;}if(!bitmap_data){return;}if(!location){return;}if(!normal){return;}if(!up){return;}if(camera.yUp){location=ZToY(location);normal=ZToY(normal);up=ZToY(up);}new Bitmap(scene,{src:bitmap_data,type:bitmap_type,pos:location,normal:normal,up:up,clippable:false,collidable:true,height:height});});}if(reset){scene.setObjectsXRayed(scene.xrayedObjectIds,false);scene.setObjectsHighlighted(scene.highlightedObjectIds,false);scene.setObjectsSelected(scene.selectedObjectIds,false);}if(bcfViewpoint.components){if(bcfViewpoint.components.visibility){if(!bcfViewpoint.components.visibility.default_visibility){scene.setObjectsVisible(scene.objectIds,false);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this82._withBCFComponent(options,component,function(entity){return entity.visible=true;});});}}else{scene.setObjectsVisible(scene.objectIds,true);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this82._withBCFComponent(options,component,function(entity){return entity.visible=false;});});}}var view_setup_hints=bcfViewpoint.components.visibility.view_setup_hints;if(view_setup_hints){if(view_setup_hints.spaces_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"),false);}if(view_setup_hints.spaces_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcSpace"),true);}if(view_setup_hints.space_boundaries_visible!==undefined);if(view_setup_hints.openings_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}if(view_setup_hints.space_boundaries_translucent!==undefined);if(view_setup_hints.openings_translucent!==undefined){scene.setObjectsXRayed(viewer.metaScene.getObjectIDsByType("IfcOpening"),true);}}}if(bcfViewpoint.components.selection){scene.setObjectsSelected(scene.selectedObjectIds,false);bcfViewpoint.components.selection.forEach(function(component){return _this82._withBCFComponent(options,component,function(entity){return entity.selected=true;});});}if(bcfViewpoint.components.translucency){scene.setObjectsXRayed(scene.xrayedObjectIds,false);bcfViewpoint.components.translucency.forEach(function(component){return _this82._withBCFComponent(options,component,function(entity){return entity.xrayed=true;});});}if(bcfViewpoint.components.coloring){bcfViewpoint.components.coloring.forEach(function(coloring){var color=coloring.color;var alpha=0;var alphaDefined=false;if(color.length===8){alpha=parseInt(color.substring(0,2),16)/256;if(alpha<=1.0&&alpha>=0.95){alpha=1.0;}color=color.substring(2);alphaDefined=true;}var colorize=[parseInt(color.substring(0,2),16)/256,parseInt(color.substring(2,4),16)/256,parseInt(color.substring(4,6),16)/256];coloring.components.map(function(component){return _this82._withBCFComponent(options,component,function(entity){entity.colorize=colorize;if(alphaDefined){entity.opacity=alpha;}});});});}}if(bcfViewpoint.perspective_camera||bcfViewpoint.orthogonal_camera){var eye;var look;var up;var projection;if(bcfViewpoint.perspective_camera){eye=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_up_vector,tempVec3$5);camera.perspective.fov=bcfViewpoint.perspective_camera.field_of_view;projection="perspective";}else{eye=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_up_vector,tempVec3$5);camera.ortho.scale=bcfViewpoint.orthogonal_camera.view_to_world_scale;projection="ortho";}math.subVec3(eye,realWorldOffset);if(camera.yUp){eye=ZToY(eye);look=ZToY(look);up=ZToY(up);}if(rayCast){var hit=scene.pick({pickSurface:true,// <<------ This causes picking to find the intersection point on the entity
|
|
19119
19119
|
origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3$5);}else{look=math.addVec3(eye,look,tempVec3$5);}if(immediate){camera.eye=eye;camera.look=look;camera.up=up;camera.projection=projection;}else{viewer.cameraFlight.flyTo({eye:eye,look:look,up:up,duration:options.duration,projection:projection});}}}},{key:"_withBCFComponent",value:function _withBCFComponent(options,component,callback){var viewer=this.viewer;var scene=viewer.scene;if(component.authoring_tool_id&&component.originating_system===this.originatingSystem){var id=component.authoring_tool_id;var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var metaObject=viewer.metaScene.metaObjects[id];if(metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);return;}}}if(component.ifc_guid){var originalSystemId=component.ifc_guid;var _entity2=scene.objects[originalSystemId];if(_entity2){callback(_entity2);return;}if(options.updateCompositeObjects){var _metaObject=viewer.metaScene.metaObjects[originalSystemId];if(_metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(originalSystemId),callback);return;}}Object.keys(scene.models).forEach(function(modelId){var id=math.globalizeObjectId(modelId,originalSystemId);var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var _metaObject2=viewer.metaScene.metaObjects[id];if(_metaObject2){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);}}});}}/**
|
|
19120
19120
|
* Destroys this BCFViewpointsPlugin.
|
|
19121
19121
|
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(BCFViewpointsPlugin.prototype),"destroy",this).call(this);}}]);return BCFViewpointsPlugin;}(Plugin);function xyzArrayToObject(arr){return{"x":arr[0],"y":arr[1],"z":arr[2]};}function xyzObjectToArray(xyz,arry){arry=new Float64Array(3);arry[0]=xyz.x;arry[1]=xyz.y;arry[2]=xyz.z;return arry;}function YToZ(vec){return new Float64Array([vec[0],-vec[2],vec[1]]);}function ZToY(vec){return new Float64Array([vec[0],vec[2],-vec[1]]);}function colorizeToRGB(color){var rgb="";rgb+=Math.round(color[0]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[1]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[2]*255).toString(16).padStart(2,"0");return rgb;}var distVec3=math.vec3();var lengthWire=function lengthWire(x1,y1,x2,y2){var a=x1-x2;var b=y1-y2;return Math.sqrt(a*a+b*b);};/**
|
|
@@ -19392,13 +19392,12 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
19392
19392
|
* it will destroy any DistanceMeasurements currently under construction, and incurs some overhead, since it unbinds
|
|
19393
19393
|
* and rebinds various input handlers.
|
|
19394
19394
|
*
|
|
19395
|
-
* @param
|
|
19395
|
+
* @param snapping
|
|
19396
19396
|
*/},{key:"snapping",get:/**
|
|
19397
19397
|
* Gets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
19398
19398
|
*
|
|
19399
19399
|
* This is `true` by default.
|
|
19400
|
-
*
|
|
19401
|
-
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
19400
|
+
* @returns {*}
|
|
19402
19401
|
*/function get(){return this._snapping;}/**
|
|
19403
19402
|
* Activates this DistanceMeasurementsMouseControl, ready to respond to input.
|
|
19404
19403
|
*/,set:function set(snapping){if(snapping!==this._snapping){this._snapping=snapping;this.deactivate();this.activate();}else{this._snapping=snapping;}}},{key:"activate",value:function activate(){var _this85=this;if(this._active){return;}if(!this._markerDiv){this._initMarkerDiv();}this.fire("activated",true);var distanceMeasurementsPlugin=this.distanceMeasurementsPlugin;var scene=this.scene;var cameraControl=distanceMeasurementsPlugin.viewer.cameraControl;var canvas=scene.canvas.canvas;scene.input;var mouseHovering=false;var pointerWorldPos=math.vec3();var pointerCanvasPos=math.vec2();var pointerDownCanvasX;var pointerDownCanvasY;var clickTolerance=20;var hoveredEntity=null;this._mouseState=MOUSE_FIRST_CLICK_EXPECTED;var getTop=function getTop(el){return el.offsetTop+(el.offsetParent&&getTop(el.offsetParent));};var getLeft=function getLeft(el){return el.offsetLeft+(el.offsetParent&&getLeft(el.offsetParent));};var pagePos=math.vec2();this._onCameraControlHoverSnapOrSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){var canvasPos=event.snappedCanvasPos||event.canvasPos;mouseHovering=true;pointerWorldPos.set(event.worldPos);pointerCanvasPos.set(event.canvasPos);if(_this85._mouseState===MOUSE_FIRST_CLICK_EXPECTED){if(_this85._canvasToPagePos){_this85._canvasToPagePos(canvas,canvasPos,pagePos);_this85._markerDiv.style.left="".concat(pagePos[0]-5,"px");_this85._markerDiv.style.top="".concat(pagePos[1]-5,"px");}else{_this85._markerDiv.style.left="".concat(getLeft(canvas)+canvasPos[0]-5,"px");_this85._markerDiv.style.top="".concat(getTop(canvas)+canvasPos[1]-5,"px");}_this85._markerDiv.style.background="pink";if(event.snappedToVertex||event.snappedToEdge){if(_this85.pointerLens){_this85.pointerLens.visible=true;_this85.pointerLens.canvasPos=event.canvasPos;_this85.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;_this85.pointerLens.snapped=true;}_this85._markerDiv.style.background="greenyellow";_this85._markerDiv.style.border="2px solid green";}else{if(_this85.pointerLens){_this85.pointerLens.visible=true;_this85.pointerLens.canvasPos=event.canvasPos;_this85.pointerLens.snappedCanvasPos=event.canvasPos;_this85.pointerLens.snapped=false;}_this85._markerDiv.style.background="pink";_this85._markerDiv.style.border="2px solid red";}hoveredEntity=event.entity;}else{_this85._markerDiv.style.left="-10000px";_this85._markerDiv.style.top="-10000px";}canvas.style.cursor="pointer";if(_this85._currentDistanceMeasurement){_this85._currentDistanceMeasurement.wireVisible=_this85._currentDistanceMeasurementInitState.wireVisible;_this85._currentDistanceMeasurement.axisVisible=_this85._currentDistanceMeasurementInitState.axisVisible&&_this85.distanceMeasurementsPlugin.defaultAxisVisible;_this85._currentDistanceMeasurement.xAxisVisible=_this85._currentDistanceMeasurementInitState.xAxisVisible&&_this85.distanceMeasurementsPlugin.defaultXAxisVisible;_this85._currentDistanceMeasurement.yAxisVisible=_this85._currentDistanceMeasurementInitState.yAxisVisible&&_this85.distanceMeasurementsPlugin.defaultYAxisVisible;_this85._currentDistanceMeasurement.zAxisVisible=_this85._currentDistanceMeasurementInitState.zAxisVisible&&_this85.distanceMeasurementsPlugin.defaultZAxisVisible;_this85._currentDistanceMeasurement.targetVisible=_this85._currentDistanceMeasurementInitState.targetVisible;_this85._currentDistanceMeasurement.target.worldPos=pointerWorldPos.slice();_this85._markerDiv.style.left="-10000px";_this85._markerDiv.style.top="-10000px";}});canvas.addEventListener('mousedown',this._onMouseDown=function(e){if(e.which!==1){return;}pointerDownCanvasX=e.clientX;pointerDownCanvasY=e.clientY;});canvas.addEventListener("mouseup",this._onMouseUp=function(e){if(e.which!==1){return;}if(e.clientX>pointerDownCanvasX+clickTolerance||e.clientX<pointerDownCanvasX-clickTolerance||e.clientY>pointerDownCanvasY+clickTolerance||e.clientY<pointerDownCanvasY-clickTolerance){return;}if(_this85._currentDistanceMeasurement){if(mouseHovering){_this85._currentDistanceMeasurement.target.entity=hoveredEntity;hoveredEntity=null;_this85._currentDistanceMeasurement.clickable=true;_this85.distanceMeasurementsPlugin.fire("measurementEnd",_this85._currentDistanceMeasurement);_this85._currentDistanceMeasurement=null;}else{_this85._currentDistanceMeasurement.destroy();_this85.distanceMeasurementsPlugin.fire("measurementCancel",_this85._currentDistanceMeasurement);_this85._currentDistanceMeasurement=null;hoveredEntity=null;}}else{if(mouseHovering){_this85._currentDistanceMeasurement=distanceMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos.slice(),entity:hoveredEntity},target:{worldPos:pointerWorldPos.slice(),entity:hoveredEntity},approximate:true});_this85._currentDistanceMeasurementInitState.axisVisible=_this85._currentDistanceMeasurement.axisVisible&&_this85.distanceMeasurementsPlugin.defaultAxisVisible;_this85._currentDistanceMeasurementInitState.xAxisVisible=_this85._currentDistanceMeasurement.xAxisVisible&&_this85.distanceMeasurementsPlugin.defaultXAxisVisible;_this85._currentDistanceMeasurementInitState.yAxisVisible=_this85._currentDistanceMeasurement.yAxisVisible&&_this85.distanceMeasurementsPlugin.defaultYAxisVisible;_this85._currentDistanceMeasurementInitState.zAxisVisible=_this85._currentDistanceMeasurement.zAxisVisible&&_this85.distanceMeasurementsPlugin.defaultZAxisVisible;_this85._currentDistanceMeasurementInitState.wireVisible=_this85._currentDistanceMeasurement.wireVisible;_this85._currentDistanceMeasurementInitState.targetVisible=_this85._currentDistanceMeasurement.targetVisible;_this85._currentDistanceMeasurement.clickable=false;_this85._currentDistanceMeasurement.origin.entity=hoveredEntity;hoveredEntity=null;_this85.distanceMeasurementsPlugin.fire("measurementStart",_this85._currentDistanceMeasurement);}}});this._onCameraControlHoverSnapOrSurfaceOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(_this85.pointerLens){_this85.pointerLens.visible=true;_this85.pointerLens.canvasPos=event.canvasPos;_this85.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;}mouseHovering=false;_this85._markerDiv.style.left="-100px";_this85._markerDiv.style.top="-100px";if(_this85._currentDistanceMeasurement){_this85._currentDistanceMeasurement.wireVisible=false;_this85._currentDistanceMeasurement.targetVisible=false;_this85._currentDistanceMeasurement.axisVisible=false;}canvas.style.cursor="default";});this._active=true;}/**
|
|
@@ -19776,7 +19775,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
19776
19775
|
*
|
|
19777
19776
|
*/var DistanceMeasurementsTouchControl=/*#__PURE__*/function(_DistanceMeasurements2){_inherits(DistanceMeasurementsTouchControl,_DistanceMeasurements2);var _super120=_createSuper(DistanceMeasurementsTouchControl);/**
|
|
19778
19777
|
* Creates a DistanceMeasurementsTouchControl bound to the given DistanceMeasurementsPlugin.
|
|
19779
|
-
*/function DistanceMeasurementsTouchControl(distanceMeasurementsPlugin){var _this88;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DistanceMeasurementsTouchControl);_this88=_super120.call(this,distanceMeasurementsPlugin.viewer.scene);_this88.pointerLens=cfg.pointerLens;_this88.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer);_this88._active=false;var markerDiv=document.createElement('div');var canvas=_this88.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";_this88.markerDiv=markerDiv;_this88._currentDistanceMeasurement=null;_this88._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this88._onCanvasTouchStart=null;_this88._onCanvasTouchEnd=null;_this88._longTouchTimeoutMs=300;_this88.
|
|
19778
|
+
*/function DistanceMeasurementsTouchControl(distanceMeasurementsPlugin){var _this88;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DistanceMeasurementsTouchControl);_this88=_super120.call(this,distanceMeasurementsPlugin.viewer.scene);_this88.pointerLens=cfg.pointerLens;_this88.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer);_this88._active=false;var markerDiv=document.createElement('div');var canvas=_this88.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";_this88.markerDiv=markerDiv;_this88._currentDistanceMeasurement=null;_this88._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this88._onCanvasTouchStart=null;_this88._onCanvasTouchEnd=null;_this88._longTouchTimeoutMs=300;_this88._snapping=cfg.snapping!==false;_this88._touchState=WAITING_FOR_ORIGIN_TOUCH_START;_this88._attachPlugin(distanceMeasurementsPlugin,cfg);return _this88;}_createClass(DistanceMeasurementsTouchControl,[{key:"_attachPlugin",value:function _attachPlugin(distanceMeasurementsPlugin){/**
|
|
19780
19779
|
* The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsTouchControl.
|
|
19781
19780
|
* @type {DistanceMeasurementsPlugin}
|
|
19782
19781
|
*/this.distanceMeasurementsPlugin=distanceMeasurementsPlugin;/**
|
|
@@ -19786,25 +19785,25 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
19786
19785
|
*
|
|
19787
19786
|
* @returns {Boolean}
|
|
19788
19787
|
*/},{key:"active",get:function get(){return this._active;}/**
|
|
19789
|
-
* Sets whether snap-to-vertex
|
|
19790
|
-
*
|
|
19791
|
-
* @param snapToVertex
|
|
19792
|
-
*/},{key:"snapToVertex",get:/**
|
|
19793
|
-
* Gets whether snap-to-vertex is enabled for this DistanceMeasurementsTouchControl.
|
|
19794
|
-
* This is `true` by default.
|
|
19795
|
-
* @returns {*}
|
|
19796
|
-
*/function get(){return this._snapToVertex;}/**
|
|
19797
|
-
* Sets whether snap-to-edge is enabled for this DistanceMeasurementsTouchControl.
|
|
19788
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
|
|
19789
|
+
*
|
|
19798
19790
|
* This is `true` by default.
|
|
19799
|
-
*
|
|
19800
|
-
|
|
19801
|
-
*
|
|
19791
|
+
*
|
|
19792
|
+
* Internally, this deactivates then activates the DistanceMeasurementsTouchControl when changed, which means that
|
|
19793
|
+
* it will destroy any DistanceMeasurements currently under construction, and incurs some overhead, since it unbinds
|
|
19794
|
+
* and rebinds various input handlers.
|
|
19795
|
+
*
|
|
19796
|
+
* @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this DistanceMeasurementsTouchControl.
|
|
19797
|
+
*/},{key:"snapping",get:/**
|
|
19798
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
|
|
19799
|
+
*
|
|
19802
19800
|
* This is `true` by default.
|
|
19803
|
-
*
|
|
19804
|
-
|
|
19801
|
+
*
|
|
19802
|
+
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
|
|
19803
|
+
*/function get(){return this._snapping;}/**
|
|
19805
19804
|
* Activates this DistanceMeasurementsTouchControl, ready to respond to input.
|
|
19806
|
-
*/,set:function set(
|
|
19807
|
-
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,
|
|
19805
|
+
*/,set:function set(snapping){if(snapping!==this._snapping){this._snapping=snapping;this.deactivate();this.activate();}else{this._snapping=snapping;}}},{key:"activate",value:function activate(){var _this89=this;if(this._active){return;}var plugin=this.plugin;var scene=this.scene;var canvas=scene.canvas.canvas;plugin.pointerLens;var pointerWorldPos=math.vec3();var touchTolerance=20;var longTouchTimeout=null;this._touchState=WAITING_FOR_ORIGIN_TOUCH_START;var touchStartCanvasPos=math.vec2();var touchMoveCanvasPos=math.vec2();var touchEndCanvasPos=math.vec2();var touchId=null;var disableCameraNavigation=function disableCameraNavigation(){_this89.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this89.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement.destroy();_this89._currentDistanceMeasurement=null;}enableCameraNavigation();_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){var currentNumTouches=event.touches.length;if(currentNumTouches!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;touchStartCanvasPos.set([touchX,touchY]);touchMoveCanvasPos.set([touchX,touchY]);switch(_this89._touchState){case WAITING_FOR_ORIGIN_TOUCH_START:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
19806
|
+
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapping:_this89._snapping,snapToEdge:_this89._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this89.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this89.pointerCircle.start(pickResult.canvasPos);}else{return;}}longTouchTimeout=setTimeout(function(){if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){return;// Has moved
|
|
19808
19807
|
}// Long touch
|
|
19809
19808
|
if(_this89.pointerLens){_this89.pointerLens.visible=true;_this89.pointerLens.canvasPos=touchStartCanvasPos;_this89.pointerLens.cursorPos=touchStartCanvasPos;}if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;_this89.pointerLens.snapped=false;}if(_this89.pointerLens){_this89.pointerLens.cursorPos=snapPickResult.canvasPos;_this89.pointerLens.snapped=true;}// pointerWorldPos.set(snapPickResult.snappedWorldPos);
|
|
19810
19809
|
if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos,entity:snapPickResult.entity},target:{worldPos:pointerWorldPos,entity:snapPickResult.entity}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;}else{_this89._currentDistanceMeasurement.origin.worldPos=pointerWorldPos;}_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);// if (this.pointerLens) {
|
|
@@ -19812,29 +19811,29 @@ if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plu
|
|
|
19812
19811
|
// this.pointerLens.snapped = false;
|
|
19813
19812
|
// }
|
|
19814
19813
|
_this89._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_ORIGIN_TOUCH_START -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
19815
|
-
|
|
19814
|
+
disableCameraNavigation();},_this89._longTouchTimeoutMs);_this89._touchState=WAITING_FOR_ORIGIN_QUICK_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_ORIGIN_TOUCH_START -> WAITING_FOR_ORIGIN_QUICK_TOUCH_END")
|
|
19816
19815
|
touchId=touch.identifier;break;case WAITING_FOR_TARGET_TOUCH_START:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
19817
19816
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;return;}if(currentNumTouches===1){// One finger down
|
|
19818
19817
|
longTouchTimeout=setTimeout(function(){longTouchTimeout=null;if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){// Has moved
|
|
19819
19818
|
return;}// Long touch
|
|
19820
|
-
if(_this89.pointerLens){_this89.pointerLens.visible=true;_this89.pointerLens.canvasPos=touchStartCanvasPos;_this89.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89.
|
|
19821
|
-
|
|
19819
|
+
if(_this89.pointerLens){_this89.pointerLens.visible=true;_this89.pointerLens.canvasPos=touchStartCanvasPos;_this89.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapping,snapToEdge:_this89._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this89.pointerLens){_this89.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this89.pointerLens.snapped=true;}_this89.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this89._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this89._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{var _pickResult6=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult6&&_pickResult6.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=_pickResult6.canvasPos;_this89.pointerLens.snapped=false;}_this89.pointerCircle.start(_pickResult6.canvasPos);pointerWorldPos.set(_pickResult6.worldPos);_this89._currentDistanceMeasurement.target.worldPos=_pickResult6.worldPos;_this89._currentDistanceMeasurement.target.entity=_pickResult6.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{if(_this89.pointerLens){_this89.pointerLens.cursorPos=null;_this89.pointerLens.snapped=false;}}}_this89._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
19820
|
+
disableCameraNavigation();},_this89._longTouchTimeoutMs);_this89._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
19822
19821
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this89._touchState=TOUCH_CANCELING;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
19823
|
-
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this89.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}touchMoveCanvasPos.set([touchX,touchY]);var snapPickResult;var pickResult;switch(_this89._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89.
|
|
19822
|
+
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this89.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}touchMoveCanvasPos.set([touchX,touchY]);var snapPickResult;var pickResult;switch(_this89._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapping,snapToEdge:_this89._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this89.pointerLens){_this89.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this89.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;}else{_this89._currentDistanceMeasurement.origin.worldPos=snapPickResult.worldPos;}_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=pickResult.canvasPos;_this89.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;}else{_this89._currentDistanceMeasurement.origin.worldPos=pickResult.worldPos;}_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{if(_this89.pointerLens){_this89.pointerLens.cursorPos=null;_this89.pointerLens.snapped=false;}}}_this89._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
19824
19823
|
break;// case WAITING_FOR_TARGET_TOUCH_START:
|
|
19825
19824
|
// this._touchState = WAITING_FOR_TARGET_TOUCH_START;
|
|
19826
19825
|
// console.log("touchmove: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_TOUCH_START")
|
|
19827
19826
|
// break;
|
|
19828
19827
|
case WAITING_FOR_TARGET_LONG_TOUCH_END:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
19829
19828
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this89.pointerLens){_this89.pointerLens.visible=false;}_this89._touchState=TOUCH_CANCELING;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_TARGET -> TOUCH_CANCELING")
|
|
19830
|
-
return;}if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89.
|
|
19829
|
+
return;}if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapping,snapToEdge:_this89._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this89.pointerLens.snapped=true;}_this89._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this89._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=pickResult.canvasPos;_this89.pointerLens.snapped=false;}_this89._currentDistanceMeasurement.target.worldPos=pickResult.worldPos;_this89._currentDistanceMeasurement.target.entity=pickResult.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;}}_this89._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this89.pointerCircle.stop();var numChangedTouches=event.changedTouches.length;if(numChangedTouches!==1){return;}var touch=event.changedTouches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}touchEndCanvasPos.set([touchX,touchY]);switch(_this89._touchState){case WAITING_FOR_ORIGIN_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;_this89._touchState=WAITING_FOR_TARGET_TOUCH_START;_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19831
19830
|
}else{if(_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement.destroy();}_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19832
|
-
}}
|
|
19831
|
+
}}enableCameraNavigation();break;case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this89.pointerLens){_this89.pointerLens.visible=false;}if(!_this89._currentDistanceMeasurement){if(_this89.pointerLens){_this89.pointerLens.snapped=false;_this89.pointerLens.visible=false;}_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (no measurement) -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19833
19832
|
}else{_this89._touchState=WAITING_FOR_TARGET_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (picked, begin measurement) -> WAITING_FOR_TARGET_TOUCH_START")
|
|
19834
|
-
}
|
|
19835
|
-
}
|
|
19833
|
+
}enableCameraNavigation();break;case WAITING_FOR_TARGET_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this89._touchState=WAITING_FOR_TARGET_TOUCH_START;return;}var _pickResult7=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult7&&_pickResult7.worldPos){_this89._currentDistanceMeasurement.target.worldPos=_pickResult7.worldPos;_this89._currentDistanceMeasurement.target.entity=_pickResult7.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;_this89.distanceMeasurementsPlugin.fire("measurementEnd",_this89._currentDistanceMeasurement);_this89._currentDistanceMeasurement=null;}else{if(_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement.destroy();_this89._currentDistanceMeasurement=null;}}_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19834
|
+
}enableCameraNavigation();break;case WAITING_FOR_TARGET_LONG_TOUCH_END:if(_this89.pointerLens){_this89.pointerLens.visible=false;}if(!_this89._currentDistanceMeasurement||!_this89._currentDistanceMeasurement.targetVisible){if(_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement.destroy();_this89._currentDistanceMeasurement=null;}_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END (no target found) -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19836
19835
|
}else{_this89._currentDistanceMeasurement.clickable=true;_this89.distanceMeasurementsPlugin.fire("measurementEnd",_this89._currentDistanceMeasurement);_this89._currentDistanceMeasurement=null;_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19837
|
-
}
|
|
19836
|
+
}enableCameraNavigation();break;}},{passive:true});this._active=true;}/**
|
|
19838
19837
|
* Deactivates this DistanceMeasurementsTouchControl, making it unresponsive to input.
|
|
19839
19838
|
*
|
|
19840
19839
|
* Destroys any {@link DistanceMeasurement} under construction.
|