@xtctwins/tctwins-core 1.0.47 → 1.0.49
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/tctwins-core.es5.js +388 -380
- package/dist/tctwins-core.min.es5.js +2 -2
- package/package.json +1 -1
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsControl.d.ts +74 -72
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.d.ts +1 -0
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.d.ts +3 -0
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.d.ts +1 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsControl.d.ts +80 -81
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.d.ts +1 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.d.ts +8 -0
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.d.ts +1 -0
- package/types/plugins/SectionPlanesPlugin/SectionPlanesPlugin.d.ts +2 -1
- package/types/plugins/SkyboxesPlugin/SkyboxesPlugin.d.ts +1 -0
- package/types/viewer/scene/sectionPlane/SectionPlane.d.ts +78 -75
package/dist/tctwins-core.es5.js
CHANGED
|
@@ -2357,51 +2357,51 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._cornerDot.s
|
|
|
2357
2357
|
* @interface
|
|
2358
2358
|
* @abstract
|
|
2359
2359
|
*/var AngleMeasurementsControl=/*#__PURE__*/function(_Component3){function AngleMeasurementsControl(){_classCallCheck(this,AngleMeasurementsControl);return _callSuper(this,AngleMeasurementsControl,arguments);}_inherits(AngleMeasurementsControl,_Component3);return _createClass(AngleMeasurementsControl,[{key:"active",get:/**
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2360
|
+
* Gets if this AngleMeasurementsControl is currently active, where it is responding to input.
|
|
2361
|
+
*
|
|
2362
|
+
* @returns {boolean} True if this AngleMeassurementsControl is active.
|
|
2363
|
+
* @abstract
|
|
2364
|
+
*/function get(){},set:function set(active){}/**
|
|
2365
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsControl.
|
|
2366
|
+
*
|
|
2367
|
+
* This is `true` by default.
|
|
2368
|
+
*
|
|
2369
|
+
* Internally, this deactivates then activates the AngleMeasurementsControl when changed, which means that
|
|
2370
|
+
* it will destroy any AngleMeasurements currently under construction, and incurs some overhead, since it unbinds
|
|
2371
|
+
* and rebinds various input handlers.
|
|
2372
|
+
*
|
|
2373
|
+
* @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this AngleMeasurementsControl.
|
|
2374
|
+
*/},{key:"snapping",get:/**
|
|
2375
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsControl.
|
|
2376
|
+
*
|
|
2377
|
+
* This is `true` by default.
|
|
2378
|
+
*
|
|
2379
|
+
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsControl.
|
|
2380
|
+
*/function get(){return true;}/**
|
|
2381
|
+
* Activates this AngleMeasurementsMouseControl, ready to respond to input.
|
|
2382
|
+
*
|
|
2383
|
+
* @abstract
|
|
2384
|
+
*/,set:function set(snapping){}},{key:"activate",value:function activate(){}/**
|
|
2385
|
+
* Deactivates this AngleMeasurementsControl, making it unresponsive to input.
|
|
2386
|
+
*
|
|
2387
|
+
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsControl.
|
|
2388
|
+
*
|
|
2389
|
+
* @abstract
|
|
2390
|
+
*/},{key:"deactivate",value:function deactivate(){}/**
|
|
2391
|
+
* Resets this AngleMeasurementsControl.
|
|
2392
|
+
*
|
|
2393
|
+
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsControl.
|
|
2394
|
+
*
|
|
2395
|
+
* Does nothing if the AngleMeasurementsControl is not active.
|
|
2396
|
+
*
|
|
2397
|
+
* @abstract
|
|
2398
|
+
*/},{key:"reset",value:function reset(){}/**
|
|
2399
|
+
* Destroys this AngleMeasurementsMouseControl.
|
|
2400
|
+
*
|
|
2401
|
+
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsControl.
|
|
2402
|
+
*
|
|
2403
|
+
* @abstract
|
|
2404
|
+
*/},{key:"destroy",value:function destroy(){}}]);}(Component);var MOUSE_FINDING_ORIGIN=0;var MOUSE_FINDING_CORNER=1;var MOUSE_FINDING_TARGET=2;/**
|
|
2405
2405
|
* Creates {@link AngleMeasurement}s in an {@link AngleMeasurementsPlugin} from mouse input.
|
|
2406
2406
|
*
|
|
2407
2407
|
* ## Usage
|
|
@@ -2447,7 +2447,7 @@ s * @param {function} [cfg.canvasToPagePos] Optional function to map canvas-spa
|
|
|
2447
2447
|
* @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsMouseControl.
|
|
2448
2448
|
* @param {_offsetX} [cfg._offsetX] _offsetX of the mouse
|
|
2449
2449
|
* @param {_offsetY} [cfg._offsetY] _offsetY of the mouse
|
|
2450
|
-
* */function AngleMeasurementsMouseControl(angleMeasurementsPlugin){var _this11;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsMouseControl);_this11=_callSuper(this,AngleMeasurementsMouseControl,[angleMeasurementsPlugin.viewer.scene]);_this11.cfg=cfg;_this11._canvasToPagePos=cfg.canvasToPagePos;_this11.pointerLens=cfg.pointerLens;_this11._active=false;_this11._mouseState=MOUSE_FINDING_ORIGIN;_this11._currentAngleMeasurement=null;// init markerDiv element (think about making its style configurable)
|
|
2450
|
+
* */function AngleMeasurementsMouseControl(angleMeasurementsPlugin){var _this11;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsMouseControl);_this11=_callSuper(this,AngleMeasurementsMouseControl,[angleMeasurementsPlugin.viewer.scene]);_this11.cfg=cfg;_this11._canvasToPagePos=cfg.canvasToPagePos;_this11.pointerLens=cfg.pointerLens;_this11._active=false;_this11._activate=false;_this11._mouseState=MOUSE_FINDING_ORIGIN;_this11._currentAngleMeasurement=null;// init markerDiv element (think about making its style configurable)
|
|
2451
2451
|
_this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothing=null;_this11._onPickedNothing=null;_this11._onPickedSurface=null;_this11._onInputMouseDown=null;_this11._onInputMouseUp=null;_this11._snapping=cfg.snapping!==false;_this11._attachPlugin(angleMeasurementsPlugin,cfg);_this11._offsetX=cfg._offsetX|0;_this11._offsetY=cfg._offsetY|0;return _this11;}_inherits(AngleMeasurementsMouseControl,_AngleMeasurementsCon);return _createClass(AngleMeasurementsMouseControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myAnglePivotMarker");var canvas=this.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";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(angleMeasurementsPlugin){var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};/**
|
|
2452
2452
|
* The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsMouseControl.
|
|
2453
2453
|
*
|
|
@@ -2468,7 +2468,7 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2468
2468
|
* Gets if this AngleMeasurementsMouseControl is currently active, where it is responding to input.
|
|
2469
2469
|
*
|
|
2470
2470
|
* @returns {boolean}
|
|
2471
|
-
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;}/**
|
|
2471
|
+
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;},set:function set(active){this._active=active;}/**
|
|
2472
2472
|
* Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
2473
2473
|
*
|
|
2474
2474
|
* This is `true` by default.
|
|
@@ -2486,8 +2486,8 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2486
2486
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
2487
2487
|
*/function get(){return this._snapping;}/**
|
|
2488
2488
|
* Activates this AngleMeasurementsMouseControl, ready to respond to input.
|
|
2489
|
-
*/,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 _this12=this;if(this.
|
|
2490
|
-
}var angleMeasurementsPlugin=this.angleMeasurementsPlugin;var hover=false;angleMeasurementsPlugin.on("mouseOver",function(e){hover=true;});angleMeasurementsPlugin.on("mouseLeave",function(e){hover=false;});angleMeasurementsPlugin.on("measureDelete",function(e){hover=false;});var scene=this.scene;scene.input;var canvas=scene.canvas.canvas;var clickTolerance=20;var cameraControl=angleMeasurementsPlugin.viewer.cameraControl;var pointerLens=this.pointerLens;var mouseHovering=false;var hoveredEntity=null;var lastMouseCanvasX=0;var lastMouseCanvasY=0;var mouseWorldPos=math.vec3();var mouseHoverCanvasPos=math.vec2();this._currentAngleMeasurement=null;this._onMouseHoverSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){if(hover)return;if(event.snappedToVertex||event.snappedToEdge){if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=true;}_this12.markerDiv.style.background="greenyellow";_this12.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.canvasPos;pointerLens.snapped=false;}_this12.markerDiv.style.background="pink";_this12.markerDiv.style.border="2px solid red";}var canvasPos=event.snappedCanvasPos||event.canvasPos;mouseHovering=true;hoveredEntity=event.entity;mouseWorldPos.set(event.worldPos);mouseHoverCanvasPos.set(canvasPos);switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:canvas.getBoundingClientRect();var scrollLeft=window.pageXOffset||document.documentElement.scrollLeft;var scrollTop=window.pageYOffset||document.documentElement.scrollTop;var canvasLeftEdge=scrollLeft;var canvasTopEdge=scrollTop;_this12.markerDiv.style.marginLeft="".concat(_this12._offsetX+canvasLeftEdge+canvasPos[0]-5,"px");_this12.markerDiv.style.marginTop="".concat(_this12._offsetY+canvasTopEdge+canvasPos[1]-5,"px");break;case MOUSE_FINDING_CORNER:if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.originWireVisible=true;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.cornerVisible=true;_this12._currentAngleMeasurement.angleVisible=false;_this12._currentAngleMeasurement.corner.worldPos=event.worldPos;_this12._currentAngleMeasurement.corner.entity=event.entity;}_this12.markerDiv.style.marginLeft="-10000px";_this12.markerDiv.style.marginTop="-10000px";canvas.style.cursor="pointer";break;case MOUSE_FINDING_TARGET:if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.targetWireVisible=true;_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.target.worldPos=event.worldPos;_this12._currentAngleMeasurement.target.entity=event.entity;}_this12.markerDiv.style.marginLeft="-10000px";_this12.markerDiv.style.marginTop="-10000px";canvas.style.cursor="pointer";break;}});canvas.addEventListener("mousedown",this._onMouseDown=function(e){if(e.which!==1){return;}lastMouseCanvasX=e.clientX;lastMouseCanvasY=e.clientY;});canvas.addEventListener("mouseup",this._onMouseUp=function(e){if(hover)return;if(e.which!==1){return;}if(e.clientX>lastMouseCanvasX+clickTolerance||e.clientX<lastMouseCanvasX-clickTolerance||e.clientY>lastMouseCanvasY+clickTolerance||e.clientY<lastMouseCanvasY-clickTolerance){return;}switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:if(mouseHovering){_this12._currentAngleMeasurement=angleMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:mouseWorldPos},corner:{worldPos:mouseWorldPos},target:{worldPos:mouseWorldPos},precision:angleMeasurementsPlugin.precision,approximate:true});_this12._currentAngleMeasurement.clickable=false;_this12._currentAngleMeasurement.originVisible=true;_this12._currentAngleMeasurement.originWireVisible=true;_this12._currentAngleMeasurement.cornerVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.angleVisible=false;_this12._currentAngleMeasurement.origin.entity=hoveredEntity;_this12._mouseState=MOUSE_FINDING_CORNER;angleMeasurementsPlugin.fire("measurementStart",_this12._currentAngleMeasurement);}break;case MOUSE_FINDING_CORNER:if(mouseHovering){_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.corner.entity=hoveredEntity;_this12._mouseState=MOUSE_FINDING_TARGET;}else{if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.destroy();_this12._currentAngleMeasurement=null;hoveredEntity=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;angleMeasurementsPlugin.fire("measurementCancel",_this12._currentAngleMeasurement);}}break;case MOUSE_FINDING_TARGET:if(mouseHovering){_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.target.entity=hoveredEntity;_this12._currentAngleMeasurement.clickable=true;hoveredEntity=null;angleMeasurementsPlugin.fire("measurementEnd",_this12._currentAngleMeasurement);_this12._currentAngleMeasurement=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;}else{if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.destroy();_this12._currentAngleMeasurement=null;hoveredEntity=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;angleMeasurementsPlugin.fire("measurementCancel",_this12._currentAngleMeasurement);}}break;}});this._onMouseHoverOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(hover)return;mouseHovering=false;if(pointerLens){pointerLens.visible=true;pointerLens.pointerPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=false;}_this12.markerDiv.style.marginLeft="-100px";_this12.markerDiv.style.marginTop="-100px";if(_this12._currentAngleMeasurement){switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:_this12._currentAngleMeasurement.originVisible=false;break;case MOUSE_FINDING_CORNER:_this12._currentAngleMeasurement.cornerVisible=false;_this12._currentAngleMeasurement.originWireVisible=false;_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.angleVisible=false;break;case MOUSE_FINDING_TARGET:_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.angleVisible=false;break;}canvas.style.cursor="default";}});this.
|
|
2489
|
+
*/,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 _this12=this;if(this._activate){return;}if(!this.markerDiv){this._initMarkerDiv();// if the marker is destroyed after deactivation, we recreate it
|
|
2490
|
+
}var angleMeasurementsPlugin=this.angleMeasurementsPlugin;var hover=false;angleMeasurementsPlugin.on("mouseOver",function(e){if(!_this12._active){return;}hover=true;});angleMeasurementsPlugin.on("mouseLeave",function(e){if(!_this12._active){return;}hover=false;});angleMeasurementsPlugin.on("measureDelete",function(e){if(!_this12._active){return;}hover=false;});var scene=this.scene;scene.input;var canvas=scene.canvas.canvas;var clickTolerance=20;var cameraControl=angleMeasurementsPlugin.viewer.cameraControl;var pointerLens=this.pointerLens;var mouseHovering=false;var hoveredEntity=null;var lastMouseCanvasX=0;var lastMouseCanvasY=0;var mouseWorldPos=math.vec3();var mouseHoverCanvasPos=math.vec2();this._currentAngleMeasurement=null;this._onMouseHoverSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){if(!_this12._active){return;}if(hover)return;if(event.snappedToVertex||event.snappedToEdge){if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=true;}_this12.markerDiv.style.background="greenyellow";_this12.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.canvasPos;pointerLens.snapped=false;}_this12.markerDiv.style.background="pink";_this12.markerDiv.style.border="2px solid red";}var canvasPos=event.snappedCanvasPos||event.canvasPos;mouseHovering=true;hoveredEntity=event.entity;mouseWorldPos.set(event.worldPos);mouseHoverCanvasPos.set(canvasPos);switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:canvas.getBoundingClientRect();var scrollLeft=window.pageXOffset||document.documentElement.scrollLeft;var scrollTop=window.pageYOffset||document.documentElement.scrollTop;var canvasLeftEdge=scrollLeft;var canvasTopEdge=scrollTop;_this12.markerDiv.style.marginLeft="".concat(_this12._offsetX+canvasLeftEdge+canvasPos[0]-5,"px");_this12.markerDiv.style.marginTop="".concat(_this12._offsetY+canvasTopEdge+canvasPos[1]-5,"px");break;case MOUSE_FINDING_CORNER:if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.originWireVisible=true;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.cornerVisible=true;_this12._currentAngleMeasurement.angleVisible=false;_this12._currentAngleMeasurement.corner.worldPos=event.worldPos;_this12._currentAngleMeasurement.corner.entity=event.entity;}_this12.markerDiv.style.marginLeft="-10000px";_this12.markerDiv.style.marginTop="-10000px";canvas.style.cursor="pointer";break;case MOUSE_FINDING_TARGET:if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.targetWireVisible=true;_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.target.worldPos=event.worldPos;_this12._currentAngleMeasurement.target.entity=event.entity;}_this12.markerDiv.style.marginLeft="-10000px";_this12.markerDiv.style.marginTop="-10000px";canvas.style.cursor="pointer";break;}});canvas.addEventListener("mousedown",this._onMouseDown=function(e){if(!_this12._active){return;}if(e.which!==1){return;}lastMouseCanvasX=e.clientX;lastMouseCanvasY=e.clientY;});canvas.addEventListener("mouseup",this._onMouseUp=function(e){if(!_this12._active){return;}if(hover)return;if(e.which!==1){return;}if(e.clientX>lastMouseCanvasX+clickTolerance||e.clientX<lastMouseCanvasX-clickTolerance||e.clientY>lastMouseCanvasY+clickTolerance||e.clientY<lastMouseCanvasY-clickTolerance){return;}switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:if(mouseHovering){_this12._currentAngleMeasurement=angleMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:mouseWorldPos},corner:{worldPos:mouseWorldPos},target:{worldPos:mouseWorldPos},precision:angleMeasurementsPlugin.precision,approximate:true});_this12._currentAngleMeasurement.clickable=false;_this12._currentAngleMeasurement.originVisible=true;_this12._currentAngleMeasurement.originWireVisible=true;_this12._currentAngleMeasurement.cornerVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.angleVisible=false;_this12._currentAngleMeasurement.origin.entity=hoveredEntity;_this12._mouseState=MOUSE_FINDING_CORNER;angleMeasurementsPlugin.fire("measurementStart",_this12._currentAngleMeasurement);}break;case MOUSE_FINDING_CORNER:if(mouseHovering){_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.corner.entity=hoveredEntity;_this12._mouseState=MOUSE_FINDING_TARGET;}else{if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.destroy();_this12._currentAngleMeasurement=null;hoveredEntity=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;angleMeasurementsPlugin.fire("measurementCancel",_this12._currentAngleMeasurement);}}break;case MOUSE_FINDING_TARGET:if(mouseHovering){_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.target.entity=hoveredEntity;_this12._currentAngleMeasurement.clickable=true;hoveredEntity=null;angleMeasurementsPlugin.fire("measurementEnd",_this12._currentAngleMeasurement);_this12._currentAngleMeasurement=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;}else{if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.destroy();_this12._currentAngleMeasurement=null;hoveredEntity=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;angleMeasurementsPlugin.fire("measurementCancel",_this12._currentAngleMeasurement);}}break;}});this._onMouseHoverOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(!_this12._active){return;}if(hover)return;mouseHovering=false;if(pointerLens){pointerLens.visible=true;pointerLens.pointerPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=false;}_this12.markerDiv.style.marginLeft="-100px";_this12.markerDiv.style.marginTop="-100px";if(_this12._currentAngleMeasurement){switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:_this12._currentAngleMeasurement.originVisible=false;break;case MOUSE_FINDING_CORNER:_this12._currentAngleMeasurement.cornerVisible=false;_this12._currentAngleMeasurement.originWireVisible=false;_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.angleVisible=false;break;case MOUSE_FINDING_TARGET:_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.angleVisible=false;break;}canvas.style.cursor="default";}});this._activate=true;}/**
|
|
2491
2491
|
* Deactivates this AngleMeasurementsMouseControl, making it unresponsive to input.
|
|
2492
2492
|
*
|
|
2493
2493
|
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsMouseControl.
|
|
@@ -2791,6 +2791,9 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2791
2791
|
*
|
|
2792
2792
|
* @param {Boolean} labelsShown Whether or not to show the labels.
|
|
2793
2793
|
*/},{key:"setLabelsShown",value:function setLabelsShown(labelsShown){for(var _i34=0,_Object$entries=Object.entries(this.measurements);_i34<_Object$entries.length;_i34++){var _Object$entries$_i=_slicedToArray(_Object$entries[_i34],2),key=_Object$entries$_i[0],measurement=_Object$entries$_i[1];measurement.labelShown=labelsShown;}}/**
|
|
2794
|
+
* 控制所有测量对象显示隐藏
|
|
2795
|
+
* @param {*} visible
|
|
2796
|
+
*/},{key:"setMeasurementsShown",value:function setMeasurementsShown(visible){for(var key in this.measurements){this.measurements[key].visible=visible;}}/**
|
|
2794
2797
|
* Destroys all {@link AngleMeasurement}s.
|
|
2795
2798
|
*/},{key:"clear",value:function clear(){var ids=Object.keys(this._measurements);for(var i=0,len=ids.length;i<len;i++){this.destroyMeasurement(ids[i]);}}/**
|
|
2796
2799
|
* Destroys this AngleMeasurementsPlugin.
|
|
@@ -2835,7 +2838,7 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2835
2838
|
* @param {boolean} [cfg.snapToVertex=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsMouseControl.
|
|
2836
2839
|
* @param {_offsetX} [cfg._offsetX] _offsetX of the mouse
|
|
2837
2840
|
* @param {_offsetY} [cfg._offsetY] _offsetY of the mouse
|
|
2838
|
-
*/function AngleMeasurementsTouchControl(angleMeasurementsPlugin){var _this16;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsTouchControl);_this16=_callSuper(this,AngleMeasurementsTouchControl,[angleMeasurementsPlugin.viewer.scene]);_this16.pointerLens=cfg.pointerLens;_this16.pointerCircle=new PointerCircle(angleMeasurementsPlugin.viewer,{id:"angleMeasure_Circle"});_this16._active=false;_this16._initMarkerDiv();_this16._currentAngleMeasurement=null;_this16._onCanvasTouchStart=null;_this16._onCanvasTouchEnd=null;_this16._longTouchTimeoutMs=300;_this16._snapping=cfg.snapping!==false;_this16._snapToEdge=cfg.snapping!==false;_this16._snapToVertex=cfg.snapping!==false;_this16._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;_this16._attachPlugin(angleMeasurementsPlugin,cfg);_this16._offsetX=cfg._offsetX|0;_this16._offsetY=cfg._offsetY|0;return _this16;}_inherits(AngleMeasurementsTouchControl,_AngleMeasurementsCon2);return _createClass(AngleMeasurementsTouchControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myAngleMeasureTouchMarker");var canvas=this.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";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(angleMeasurementsPlugin){/**
|
|
2841
|
+
*/function AngleMeasurementsTouchControl(angleMeasurementsPlugin){var _this16;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsTouchControl);_this16=_callSuper(this,AngleMeasurementsTouchControl,[angleMeasurementsPlugin.viewer.scene]);_this16.pointerLens=cfg.pointerLens;_this16.pointerCircle=new PointerCircle(angleMeasurementsPlugin.viewer,{id:"angleMeasure_Circle"});_this16._active=false;_this16._activate=false;_this16._initMarkerDiv();_this16._currentAngleMeasurement=null;_this16._onCanvasTouchStart=null;_this16._onCanvasTouchEnd=null;_this16._longTouchTimeoutMs=300;_this16._snapping=cfg.snapping!==false;_this16._snapToEdge=cfg.snapping!==false;_this16._snapToVertex=cfg.snapping!==false;_this16._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;_this16._attachPlugin(angleMeasurementsPlugin,cfg);_this16._offsetX=cfg._offsetX|0;_this16._offsetY=cfg._offsetY|0;return _this16;}_inherits(AngleMeasurementsTouchControl,_AngleMeasurementsCon2);return _createClass(AngleMeasurementsTouchControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myAngleMeasureTouchMarker");var canvas=this.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";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(angleMeasurementsPlugin){/**
|
|
2839
2842
|
* The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsTouchControl.
|
|
2840
2843
|
* @type {AngleMeasurementsPlugin}
|
|
2841
2844
|
*/this.angleMeasurementsPlugin=angleMeasurementsPlugin;/**
|
|
@@ -2852,7 +2855,7 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2852
2855
|
*/function get(){return this._offsetY;}/** Gets if this AngleMeasurementsTouchControl is currently active, where it is responding to input.
|
|
2853
2856
|
*
|
|
2854
2857
|
* @returns {Boolean}
|
|
2855
|
-
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;}/**
|
|
2858
|
+
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;},set:function set(active){this._active=active;}/**
|
|
2856
2859
|
* Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
2857
2860
|
*
|
|
2858
2861
|
* This is `true` by default.
|
|
@@ -2870,7 +2873,7 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2870
2873
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
2871
2874
|
*/function get(){return this._snapping;}/**
|
|
2872
2875
|
* Activates this AngleMeasurementsTouchControl, ready to respond to input.
|
|
2873
|
-
*/,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 _this17=this;if(this.
|
|
2876
|
+
*/,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 _this17=this;if(this._activate){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(){_this17.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this17.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this17._currentAngleMeasurement){_this17._currentAngleMeasurement.destroy();_this17._currentAngleMeasurement=null;}enableCameraNavigation();_this17._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){if(!_this17._active){return;}if(!event.isTrusted)return;var currentNumTouches=event.touches.length;//多指触碰
|
|
2874
2877
|
if(currentNumTouches!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}//touch--0
|
|
2875
2878
|
var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;touchStartCanvasPos.set([touchX+_this17.offsetX,touchY+_this17.offsetY]);touchMoveCanvasPos.set([touchX+_this17.offsetX,touchY+_this17.offsetY]);switch(_this17._touchState){case WAITING_FOR_ORIGIN_TOUCH_START$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
2876
2879
|
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this17.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this17.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
|
|
@@ -2895,12 +2898,12 @@ return;}// Long touch
|
|
|
2895
2898
|
if(_this17.pointerLens){_this17.pointerLens.visible=true;_this17.pointerLens.canvasPos=touchStartCanvasPos;_this17.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this17.pointerLens){_this17.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}_this17.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this17._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this17._currentAngleMeasurement.target.entity=snapPickResult.entity;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;_this17.angleMeasurementsPlugin.fire("measurementStart",_this17._currentAngleMeasurement);}else{var _pickResult3=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult3&&_pickResult3.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=_pickResult3.canvasPos;_this17.pointerLens.snapped=false;}_this17.pointerCircle.start(_pickResult3.canvasPos);pointerWorldPos.set(_pickResult3.worldPos);_this17._currentAngleMeasurement.target.worldPos=_pickResult3.worldPos;_this17._currentAngleMeasurement.target.entity=_pickResult3.entity;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;plugin.fire("measurementStart",_this17._currentAngleMeasurement);}else{if(_this17.pointerLens){_this17.pointerLens.cursorPos=null;_this17.pointerLens.snapped=false;}}}_this17._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
2896
2899
|
disableCameraNavigation();},_this17._longTouchTimeoutMs);_this17._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
2897
2900
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this17._touchState=TOUCH_CANCELING$1;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
2898
|
-
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this17.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+_this17.offsetX,touchY+_this17.offsetY]);var snapPickResult;var pickResult;switch(_this17._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this17.pointerLens){_this17.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);_this17._currentAngleMeasurement.origin.worldPos=snapPickResult.worldPos;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);_this17._currentAngleMeasurement.origin.worldPos=pickResult.worldPos;}else{if(_this17.pointerLens){_this17.pointerLens.cursorPos=null;_this17.pointerLens.snapped=false;}}}_this17._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")
|
|
2901
|
+
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){if(!_this17._active){return;}_this17.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+_this17.offsetX,touchY+_this17.offsetY]);var snapPickResult;var pickResult;switch(_this17._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this17.pointerLens){_this17.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);_this17._currentAngleMeasurement.origin.worldPos=snapPickResult.worldPos;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);_this17._currentAngleMeasurement.origin.worldPos=pickResult.worldPos;}else{if(_this17.pointerLens){_this17.pointerLens.cursorPos=null;_this17.pointerLens.snapped=false;}}}_this17._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")
|
|
2899
2902
|
break;case WAITING_FOR_CORNER_LONG_TOUCH_END:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
2900
2903
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this17.pointerLens){_this17.pointerLens.visible=false;}_this17._touchState=TOUCH_CANCELING$1;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_CORNER -> TOUCH_CANCELING")
|
|
2901
2904
|
return;}if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}_this17._currentAngleMeasurement.corner.worldPos=snapPickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=false;_this17._currentAngleMeasurement.targetVisible=false;_this17._currentAngleMeasurement.targetWireVisible=false;_this17._currentAngleMeasurement.angleVisible=false;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}_this17._currentAngleMeasurement.corner.worldPos=pickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=false;_this17._currentAngleMeasurement.targetVisible=false;_this17._currentAngleMeasurement.targetWireVisible=false;_this17._currentAngleMeasurement.angleVisible=false;}}_this17._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
|
|
2902
2905
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this17.pointerLens){_this17.pointerLens.visible=false;}_this17._touchState=TOUCH_CANCELING$1;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_TARGET -> TOUCH_CANCELING")
|
|
2903
|
-
return;}if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}_this17._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}_this17._currentAngleMeasurement.target.worldPos=pickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;}}_this17._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this17.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(_this17._touchState){//起点短按
|
|
2906
|
+
return;}if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}_this17._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}_this17._currentAngleMeasurement.target.worldPos=pickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;}}_this17._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){if(!_this17._active){return;}_this17.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(_this17._touchState){//起点短按
|
|
2904
2907
|
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){_this17._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this17._currentAngleMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos},corner:{worldPos:pickResult.worldPos},target:{worldPos:pickResult.worldPos},precision:plugin.precision});// this._currentAngleMeasurement.clickable = false;
|
|
2905
2908
|
_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=false;_this17._currentAngleMeasurement.cornerVisible=false;_this17._currentAngleMeasurement.cornerWireVisible=false;_this17._currentAngleMeasurement.targetVisible=false;_this17._currentAngleMeasurement.targetWireVisible=false;_this17._currentAngleMeasurement.angleVisible=false;_this17._touchState=WAITING_FOR_CORNER_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_CORNER_TOUCH_START")
|
|
2906
2909
|
}else{if(_this17._currentAngleMeasurement){_this17._currentAngleMeasurement.destroy();_this17._currentAngleMeasurement=null;}_this17._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
@@ -2917,7 +2920,7 @@ case WAITING_FOR_TARGET_QUICK_TOUCH_END$1:{if(numChangedTouches!==1||touchX>touc
|
|
|
2917
2920
|
}enableCameraNavigation();break;//终点长按
|
|
2918
2921
|
case WAITING_FOR_TARGET_LONG_TOUCH_END$1:if(_this17.pointerLens){_this17.pointerLens.visible=false;}if(!_this17._currentAngleMeasurement||!_this17._currentAngleMeasurement.targetVisible){if(_this17._currentAngleMeasurement){_this17._currentAngleMeasurement.destroy();_this17._currentAngleMeasurement=null;}_this17._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")
|
|
2919
2922
|
}else{_this17._currentAngleMeasurement.clickable=true;_this17.angleMeasurementsPlugin.fire("measurementEnd",_this17._currentAngleMeasurement);_this17._currentAngleMeasurement=null;_this17._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
2920
|
-
}enableCameraNavigation();break;}},{passive:true});canvas.addEventListener("touchcancel",this._onCanvasTouchEnd);this.
|
|
2923
|
+
}enableCameraNavigation();break;}},{passive:true});canvas.addEventListener("touchcancel",this._onCanvasTouchEnd);this._activate=true;}/**
|
|
2921
2924
|
* Deactivates this AngleMeasurementsTouchControl, making it unresponsive to input.
|
|
2922
2925
|
*
|
|
2923
2926
|
* Destroys any {@link AngleMeasurement} under construction.
|
|
@@ -3642,51 +3645,51 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
3642
3645
|
* @interface
|
|
3643
3646
|
* @abstract
|
|
3644
3647
|
*/var DistanceMeasurementsControl=/*#__PURE__*/function(_Component5){function DistanceMeasurementsControl(){_classCallCheck(this,DistanceMeasurementsControl);return _callSuper(this,DistanceMeasurementsControl,arguments);}_inherits(DistanceMeasurementsControl,_Component5);return _createClass(DistanceMeasurementsControl,[{key:"active",get:/**
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3648
|
+
* Gets if this DistanceMeasurementsControl is currently active, where it is responding to input.
|
|
3649
|
+
*
|
|
3650
|
+
* @returns {boolean} True if this DistanceMeasurementsControl is active.
|
|
3651
|
+
* @abstract
|
|
3652
|
+
*/function get(){},set:function set(active){}/**
|
|
3653
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsControl.
|
|
3654
|
+
*
|
|
3655
|
+
* This is `true` by default.
|
|
3656
|
+
*
|
|
3657
|
+
* Internally, this deactivates then activates the DistanceMeasurementsControl when changed, which means that
|
|
3658
|
+
* it will destroy any DistanceMeasurements currently under construction, and incurs some overhead, since it unbinds
|
|
3659
|
+
* and rebinds various input handlers.
|
|
3660
|
+
*
|
|
3661
|
+
* @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this DistanceMeasurementsControl.
|
|
3662
|
+
*/},{key:"snapping",get:/**
|
|
3663
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsControl.
|
|
3664
|
+
*
|
|
3665
|
+
* This is `true` by default.
|
|
3666
|
+
*
|
|
3667
|
+
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsControl.
|
|
3668
|
+
*/function get(){return true;}/**
|
|
3669
|
+
* Activates this DistanceMeasurementsControl, ready to respond to input.
|
|
3670
|
+
*
|
|
3671
|
+
* @abstract
|
|
3672
|
+
*/,set:function set(snapping){}},{key:"activate",value:function activate(){}/**
|
|
3673
|
+
* Deactivates this DistanceMeasurementsControl, making it unresponsive to input.
|
|
3674
|
+
*
|
|
3675
|
+
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsControl.
|
|
3676
|
+
*
|
|
3677
|
+
* @abstract
|
|
3678
|
+
*/},{key:"deactivate",value:function deactivate(){}/**
|
|
3679
|
+
* Resets this DistanceMeasurementsControl.
|
|
3680
|
+
*
|
|
3681
|
+
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsControl.
|
|
3682
|
+
*
|
|
3683
|
+
* Does nothing if the DistanceMeasurementsControl is not active.
|
|
3684
|
+
*
|
|
3685
|
+
* @abstract
|
|
3686
|
+
*/},{key:"reset",value:function reset(){}/**
|
|
3687
|
+
* Destroys this DistanceMeasurementsControl.
|
|
3688
|
+
*
|
|
3689
|
+
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsControl.
|
|
3690
|
+
*
|
|
3691
|
+
* @abstract
|
|
3692
|
+
*/},{key:"destroy",value:function destroy(){}}]);}(Component);var MOUSE_FIRST_CLICK_EXPECTED=0;/**
|
|
3690
3693
|
* Creates {@link DistanceMeasurement}s in a {@link DistanceMeasurementsPlugin} from mouse input.
|
|
3691
3694
|
*
|
|
3692
3695
|
* ## Usage
|
|
@@ -3731,7 +3734,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
3731
3734
|
* @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsMouseControl.
|
|
3732
3735
|
* @param {_offsetX} [cfg._offsetX] _offsetX of the mouse
|
|
3733
3736
|
* @param {_offsetY} [cfg._offsetY] _offsetY of the mouse
|
|
3734
|
-
*/function DistanceMeasurementsMouseControl(distanceMeasurementsPlugin){var _this23;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DistanceMeasurementsMouseControl);_this23=_callSuper(this,DistanceMeasurementsMouseControl,[distanceMeasurementsPlugin.viewer.scene]);_this23.cfg=cfg;_this23.pointerLens=cfg.pointerLens;_this23._active=false;_this23._currentDistanceMeasurement=null;_this23._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this23._initMarkerDiv();_this23._onCameraControlHoverSnapOrSurface=null;_this23._onCameraControlHoverSnapOrSurfaceOff=null;_this23._onMouseDown=null;_this23._onMouseUp=null;_this23._onCanvasTouchStart=null;_this23._onCanvasTouchEnd=null;_this23._snapping=cfg.snapping!==false;_this23._mouseState=MOUSE_FIRST_CLICK_EXPECTED;_this23._attachPlugin(distanceMeasurementsPlugin,cfg);_this23._offsetX=cfg._offsetX|0;_this23._offsetY=cfg._offsetY|0;return _this23;}_inherits(DistanceMeasurementsMouseControl,_DistanceMeasurements);return _createClass(DistanceMeasurementsMouseControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myDistancePivotMarker");var canvas=this.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";this._markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this._markerDiv){this._markerDiv.parentNode.removeChild(this._markerDiv);this._markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(distanceMeasurementsPlugin){var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};/**
|
|
3737
|
+
*/function DistanceMeasurementsMouseControl(distanceMeasurementsPlugin){var _this23;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DistanceMeasurementsMouseControl);_this23=_callSuper(this,DistanceMeasurementsMouseControl,[distanceMeasurementsPlugin.viewer.scene]);_this23.cfg=cfg;_this23.pointerLens=cfg.pointerLens;_this23._active=false;_this23._activate=false;_this23._currentDistanceMeasurement=null;_this23._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this23._initMarkerDiv();_this23._onCameraControlHoverSnapOrSurface=null;_this23._onCameraControlHoverSnapOrSurfaceOff=null;_this23._onMouseDown=null;_this23._onMouseUp=null;_this23._onCanvasTouchStart=null;_this23._onCanvasTouchEnd=null;_this23._snapping=cfg.snapping!==false;_this23._mouseState=MOUSE_FIRST_CLICK_EXPECTED;_this23._attachPlugin(distanceMeasurementsPlugin,cfg);_this23._offsetX=cfg._offsetX|0;_this23._offsetY=cfg._offsetY|0;return _this23;}_inherits(DistanceMeasurementsMouseControl,_DistanceMeasurements);return _createClass(DistanceMeasurementsMouseControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myDistancePivotMarker");var canvas=this.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";this._markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this._markerDiv){this._markerDiv.parentNode.removeChild(this._markerDiv);this._markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(distanceMeasurementsPlugin){var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};/**
|
|
3735
3738
|
* The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsMouseControl.
|
|
3736
3739
|
* @type {DistanceMeasurementsPlugin}
|
|
3737
3740
|
*/this.distanceMeasurementsPlugin=distanceMeasurementsPlugin;/**
|
|
@@ -3749,7 +3752,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
3749
3752
|
* Gets if this DistanceMeasurementsMouseControl is currently active, where it is responding to input.
|
|
3750
3753
|
*
|
|
3751
3754
|
* @returns {boolean} True if this DistanceMeasurementsMouseControl is active.
|
|
3752
|
-
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;}/**
|
|
3755
|
+
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;},set:function set(active){this._active=active;}/**
|
|
3753
3756
|
* Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
3754
3757
|
*
|
|
3755
3758
|
* This is `true` by default.
|
|
@@ -3767,7 +3770,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
3767
3770
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
3768
3771
|
*/function get(){return this._snapping;}/**
|
|
3769
3772
|
* Activates this DistanceMeasurementsMouseControl, ready to respond to input.
|
|
3770
|
-
*/,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.
|
|
3773
|
+
*/,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._activate){return;}if(!this._markerDiv){this._initMarkerDiv();}this.fire("activated",true);var distanceMeasurementsPlugin=this.distanceMeasurementsPlugin;var hover=false;distanceMeasurementsPlugin.on("mouseOver",function(e){if(!_this24._active){return;}hover=true;});distanceMeasurementsPlugin.on("mouseLeave",function(e){if(!_this24._active){return;}hover=false;});distanceMeasurementsPlugin.on("measureDelete",function(e){if(!_this24._active){return;}hover=false;});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;this._onCameraControlHoverSnapOrSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){if(!_this24._active){return;}if(hover)return;var canvasPos=event.snappedCanvasPos||event.canvasPos;mouseHovering=true;pointerWorldPos.set(event.worldPos);pointerCanvasPos.set(event.canvasPos);if(_this24._mouseState===MOUSE_FIRST_CLICK_EXPECTED){canvas.getBoundingClientRect();var scrollLeft=window.pageXOffset||document.documentElement.scrollLeft;var scrollTop=window.pageYOffset||document.documentElement.scrollTop;var canvasLeftEdge=scrollLeft;var canvasTopEdge=scrollTop;_this24._markerDiv.style.marginLeft="".concat(_this24._offsetX+canvasLeftEdge+canvasPos[0]-5,"px");_this24._markerDiv.style.marginTop="".concat(_this24._offsetY+canvasTopEdge+canvasPos[1]-5,"px");_this24._markerDiv.style.background="pink";if(event.snappedToVertex||event.snappedToEdge){if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=event.canvasPos;_this24.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;_this24.pointerLens.snapped=true;}_this24._markerDiv.style.background="greenyellow";_this24._markerDiv.style.border="2px solid green";}else{if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=event.canvasPos;_this24.pointerLens.snappedCanvasPos=event.canvasPos;_this24.pointerLens.snapped=false;}_this24._markerDiv.style.background="pink";_this24._markerDiv.style.border="2px solid red";}hoveredEntity=event.entity;}else{_this24._markerDiv.style.marginLeft="-10000px";_this24._markerDiv.style.marginTop="-10000px";}canvas.style.cursor="pointer";if(_this24._currentDistanceMeasurement){_this24._currentDistanceMeasurement.wireVisible=_this24._currentDistanceMeasurementInitState.wireVisible;_this24._currentDistanceMeasurement.axisVisible=_this24._currentDistanceMeasurementInitState.axisVisible&&_this24.distanceMeasurementsPlugin.defaultAxisVisible;_this24._currentDistanceMeasurement.xAxisVisible=_this24._currentDistanceMeasurementInitState.xAxisVisible&&_this24.distanceMeasurementsPlugin.defaultXAxisVisible;_this24._currentDistanceMeasurement.yAxisVisible=_this24._currentDistanceMeasurementInitState.yAxisVisible&&_this24.distanceMeasurementsPlugin.defaultYAxisVisible;_this24._currentDistanceMeasurement.zAxisVisible=_this24._currentDistanceMeasurementInitState.zAxisVisible&&_this24.distanceMeasurementsPlugin.defaultZAxisVisible;_this24._currentDistanceMeasurement.targetVisible=_this24._currentDistanceMeasurementInitState.targetVisible;_this24._currentDistanceMeasurement.target.worldPos=pointerWorldPos.slice();_this24._markerDiv.style.marginLeft="-10000px";_this24._markerDiv.style.marginTop="-10000px";}});canvas.addEventListener("mousedown",this._onMouseDown=function(e){if(!_this24._active){return;}if(e.which!==1){return;}pointerDownCanvasX=e.clientX;pointerDownCanvasY=e.clientY;});canvas.addEventListener("mouseup",this._onMouseUp=function(e){if(!_this24._active){return;}if(hover)return;if(e.which!==1){return;}if(e.clientX>pointerDownCanvasX+clickTolerance||e.clientX<pointerDownCanvasX-clickTolerance||e.clientY>pointerDownCanvasY+clickTolerance||e.clientY<pointerDownCanvasY-clickTolerance){return;}if(_this24._currentDistanceMeasurement){if(mouseHovering){_this24._currentDistanceMeasurement.target.entity=hoveredEntity;hoveredEntity=null;_this24._currentDistanceMeasurement.clickable=true;_this24.distanceMeasurementsPlugin.fire("measurementEnd",_this24._currentDistanceMeasurement);_this24._currentDistanceMeasurement=null;}else{_this24._currentDistanceMeasurement.destroy();_this24.distanceMeasurementsPlugin.fire("measurementCancel",_this24._currentDistanceMeasurement);_this24._currentDistanceMeasurement=null;hoveredEntity=null;}}else{if(mouseHovering){_this24._currentDistanceMeasurement=distanceMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos.slice()},target:{worldPos:pointerWorldPos.slice()},precision:distanceMeasurementsPlugin.precision,approximate:true});_this24._currentDistanceMeasurementInitState.axisVisible=_this24._currentDistanceMeasurement.axisVisible&&_this24.distanceMeasurementsPlugin.defaultAxisVisible;_this24._currentDistanceMeasurementInitState.xAxisVisible=_this24._currentDistanceMeasurement.xAxisVisible&&_this24.distanceMeasurementsPlugin.defaultXAxisVisible;_this24._currentDistanceMeasurementInitState.yAxisVisible=_this24._currentDistanceMeasurement.yAxisVisible&&_this24.distanceMeasurementsPlugin.defaultYAxisVisible;_this24._currentDistanceMeasurementInitState.zAxisVisible=_this24._currentDistanceMeasurement.zAxisVisible&&_this24.distanceMeasurementsPlugin.defaultZAxisVisible;_this24._currentDistanceMeasurementInitState.wireVisible=_this24._currentDistanceMeasurement.wireVisible;_this24._currentDistanceMeasurementInitState.targetVisible=_this24._currentDistanceMeasurement.targetVisible;_this24._currentDistanceMeasurement.clickable=false;_this24._currentDistanceMeasurement.origin.entity=hoveredEntity;hoveredEntity=null;_this24.fire("measurementStart",_this24._currentDistanceMeasurement);}}});this._onCameraControlHoverSnapOrSurfaceOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(!_this24._active){return;}if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=event.canvasPos;_this24.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;}mouseHovering=false;_this24._markerDiv.style.marginLeft="-100px";_this24._markerDiv.style.marginTop="-100px";if(_this24._currentDistanceMeasurement){_this24._currentDistanceMeasurement.wireVisible=false;_this24._currentDistanceMeasurement.targetVisible=false;_this24._currentDistanceMeasurement.axisVisible=false;}canvas.style.cursor="default";});this._activate=true;}/**
|
|
3771
3774
|
* Deactivates this DistanceMeasurementsMouseControl, making it unresponsive to input.
|
|
3772
3775
|
*
|
|
3773
3776
|
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
|
|
@@ -4128,6 +4131,9 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
4128
4131
|
*
|
|
4129
4132
|
* @param {Boolean} labelsShown Whether or not to show the labels.
|
|
4130
4133
|
*/},{key:"setLabelsShown",value:function setLabelsShown(labelsShown){for(var _i36=0,_Object$entries2=Object.entries(this.measurements);_i36<_Object$entries2.length;_i36++){var _Object$entries2$_i=_slicedToArray(_Object$entries2[_i36],2),key=_Object$entries2$_i[0],measurement=_Object$entries2$_i[1];measurement.labelShown=labelsShown;}}/**
|
|
4134
|
+
* 控制所有测量对象显示隐藏
|
|
4135
|
+
* @param {*} visible
|
|
4136
|
+
*/},{key:"setMeasurementsShown",value:function setMeasurementsShown(visible){for(var key in this.measurements){this.measurements[key].visible=visible;}}/**
|
|
4131
4137
|
* Shows all or hides the axis wires of each {@link DistanceMeasurement}.
|
|
4132
4138
|
*
|
|
4133
4139
|
* @param {Boolean} labelsShown Whether or not to show the axis wires.
|
|
@@ -4155,7 +4161,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
4155
4161
|
* @param {_offsetX} [cfg._offsetX] _offsetX of the mouse
|
|
4156
4162
|
* @param {_offsetY} [cfg._offsetY] _offsetY of the mouse
|
|
4157
4163
|
*/function DistanceMeasurementsTouchControl(distanceMeasurementsPlugin){var _this27;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DistanceMeasurementsTouchControl);_this27=_callSuper(this,DistanceMeasurementsTouchControl,[distanceMeasurementsPlugin.viewer.scene]);_this27.pointerLens=cfg.pointerLens;// this.PointerLens = new PointerLens(distanceMeasurementsPlugin.viewer, { active: true });
|
|
4158
|
-
_this27.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer,{id:"distanceMeasure_Circle"});_this27._active=false;_this27._initMarkerDiv();_this27._currentDistanceMeasurement=null;_this27._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this27._onCanvasTouchStart=null;_this27._onCanvasTouchEnd=null;_this27._longTouchTimeoutMs=300;_this27._snapping=cfg.snapping!==false;_this27._snapToEdge=cfg.snapping!==false;_this27._snapToVertex=cfg.snapping!==false;_this27._touchState=WAITING_FOR_ORIGIN_TOUCH_START;_this27._attachPlugin(distanceMeasurementsPlugin,cfg);_this27._offsetX=cfg._offsetX|0;_this27._offsetY=cfg._offsetY|0;return _this27;}_inherits(DistanceMeasurementsTouchControl,_DistanceMeasurements2);return _createClass(DistanceMeasurementsTouchControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myDistanceMeasureTouchMarker");var canvas=this.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";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(distanceMeasurementsPlugin){/**
|
|
4164
|
+
_this27.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer,{id:"distanceMeasure_Circle"});_this27._active=false;_this27._activate=false;_this27._initMarkerDiv();_this27._currentDistanceMeasurement=null;_this27._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this27._onCanvasTouchStart=null;_this27._onCanvasTouchEnd=null;_this27._longTouchTimeoutMs=300;_this27._snapping=cfg.snapping!==false;_this27._snapToEdge=cfg.snapping!==false;_this27._snapToVertex=cfg.snapping!==false;_this27._touchState=WAITING_FOR_ORIGIN_TOUCH_START;_this27._attachPlugin(distanceMeasurementsPlugin,cfg);_this27._offsetX=cfg._offsetX|0;_this27._offsetY=cfg._offsetY|0;return _this27;}_inherits(DistanceMeasurementsTouchControl,_DistanceMeasurements2);return _createClass(DistanceMeasurementsTouchControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myDistanceMeasureTouchMarker");var canvas=this.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";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(distanceMeasurementsPlugin){/**
|
|
4159
4165
|
* The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsTouchControl.
|
|
4160
4166
|
* @type {DistanceMeasurementsPlugin}
|
|
4161
4167
|
*/this.distanceMeasurementsPlugin=distanceMeasurementsPlugin;/**
|
|
@@ -4172,7 +4178,7 @@ _this27.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer,{id:"d
|
|
|
4172
4178
|
*/function get(){return this._offsetY;}/** Gets if this DistanceMeasurementsTouchControl is currently active, where it is responding to input.
|
|
4173
4179
|
*
|
|
4174
4180
|
* @returns {Boolean}
|
|
4175
|
-
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;}/**
|
|
4181
|
+
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;},set:function set(active){this._active=active;}/**
|
|
4176
4182
|
* Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
|
|
4177
4183
|
*
|
|
4178
4184
|
* This is `true` by default.
|
|
@@ -4190,7 +4196,7 @@ _this27.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer,{id:"d
|
|
|
4190
4196
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
|
|
4191
4197
|
*/function get(){return this._snapping;}/**
|
|
4192
4198
|
* Activates this DistanceMeasurementsTouchControl, ready to respond to input.
|
|
4193
|
-
*/,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 _this28=this;if(this.
|
|
4199
|
+
*/,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 _this28=this;if(this._activate){return;}var plugin=this.plugin;var scene=this.scene;var canvas=scene.canvas.canvas;this.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(){_this28.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this28.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement.destroy();_this28._currentDistanceMeasurement=null;}enableCameraNavigation();_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){if(!_this28._active){return;}if(!event.isTrusted)return;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+_this28.offsetX,touchY+_this28.offsetY]);touchMoveCanvasPos.set([touchX+_this28.offsetX,touchY+_this28.offsetY]);switch(_this28._touchState){case WAITING_FOR_ORIGIN_TOUCH_START:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
4194
4200
|
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapping:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this28.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this28.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
|
|
4195
4201
|
}// Long touch
|
|
4196
4202
|
if(_this28.pointerLens){_this28.pointerLens.visible=true;_this28.pointerLens.canvasPos=touchStartCanvasPos;_this28.pointerLens.cursorPos=touchStartCanvasPos;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;_this28.pointerLens.snapped=false;}if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.canvasPos;_this28.pointerLens.snapped=true;}// pointerWorldPos.set(snapPickResult.snappedWorldPos);
|
|
@@ -4207,14 +4213,14 @@ return;}// Long touch
|
|
|
4207
4213
|
if(_this28.pointerLens){_this28.pointerLens.visible=true;_this28.pointerLens.canvasPos=touchStartCanvasPos;_this28.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this28._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{var _pickResult6=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult6&&_pickResult6.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=_pickResult6.canvasPos;_this28.pointerLens.snapped=false;}_this28.pointerCircle.start(_pickResult6.canvasPos);pointerWorldPos.set(_pickResult6.worldPos);_this28._currentDistanceMeasurement.target.worldPos=_pickResult6.worldPos;_this28._currentDistanceMeasurement.target.entity=_pickResult6.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
4208
4214
|
disableCameraNavigation();},_this28._longTouchTimeoutMs);_this28._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
4209
4215
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this28._touchState=TOUCH_CANCELING;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
4210
|
-
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this28.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+_this28.offsetX,touchY+_this28.offsetY]);var snapPickResult;var pickResult;switch(_this28._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);if(!_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;_this28._currentDistanceMeasurement.clickable=false;}else{_this28._currentDistanceMeasurement.origin.worldPos=snapPickResult.worldPos;}_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);if(!_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;_this28._currentDistanceMeasurement.clickable=false;}else{_this28._currentDistanceMeasurement.origin.worldPos=pickResult.worldPos;}_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
4216
|
+
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){if(!_this28._active){return;}_this28.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+_this28.offsetX,touchY+_this28.offsetY]);var snapPickResult;var pickResult;switch(_this28._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);if(!_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;_this28._currentDistanceMeasurement.clickable=false;}else{_this28._currentDistanceMeasurement.origin.worldPos=snapPickResult.worldPos;}_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);if(!_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;_this28._currentDistanceMeasurement.clickable=false;}else{_this28._currentDistanceMeasurement.origin.worldPos=pickResult.worldPos;}_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
4211
4217
|
break;// case WAITING_FOR_TARGET_TOUCH_START:
|
|
4212
4218
|
// this._touchState = WAITING_FOR_TARGET_TOUCH_START;
|
|
4213
4219
|
// console.log("touchmove: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_TOUCH_START")
|
|
4214
4220
|
// break;
|
|
4215
4221
|
case WAITING_FOR_TARGET_LONG_TOUCH_END:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
4216
4222
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this28.pointerLens){_this28.pointerLens.visible=false;}_this28._touchState=TOUCH_CANCELING;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_TARGET -> TOUCH_CANCELING")
|
|
4217
|
-
return;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}_this28._currentDistanceMeasurement.target.worldPos=pickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=pickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this28.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(_this28._touchState){//等待起点短按
|
|
4223
|
+
return;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}_this28._currentDistanceMeasurement.target.worldPos=pickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=pickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){if(!_this28._active){return;}_this28.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(_this28._touchState){//等待起点短按
|
|
4218
4224
|
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){_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;// this._currentDistanceMeasurement.clickable = false;
|
|
4219
4225
|
_this28._touchState=WAITING_FOR_TARGET_TOUCH_START;_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
4220
4226
|
}else{if(_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement.destroy();}_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
@@ -4226,7 +4232,7 @@ case WAITING_FOR_TARGET_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchS
|
|
|
4226
4232
|
}enableCameraNavigation();break;//终点长按
|
|
4227
4233
|
case WAITING_FOR_TARGET_LONG_TOUCH_END:if(_this28.pointerLens){_this28.pointerLens.visible=false;}if(!_this28._currentDistanceMeasurement||!_this28._currentDistanceMeasurement.targetVisible){if(_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement.destroy();_this28._currentDistanceMeasurement=null;}_this28._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")
|
|
4228
4234
|
}else{_this28._currentDistanceMeasurement.clickable=true;_this28.distanceMeasurementsPlugin.fire("measurementEnd",_this28._currentDistanceMeasurement);_this28._currentDistanceMeasurement=null;_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
4229
|
-
}enableCameraNavigation();break;}},{passive:true});canvas.addEventListener("touchcancel",this._onCanvasTouchEnd);this.
|
|
4235
|
+
}enableCameraNavigation();break;}},{passive:true});canvas.addEventListener("touchcancel",this._onCanvasTouchEnd);this._activate=true;}/**
|
|
4230
4236
|
* Deactivates this DistanceMeasurementsTouchControl, making it unresponsive to input.
|
|
4231
4237
|
*
|
|
4232
4238
|
* Destroys any {@link DistanceMeasurement} under construction.
|
|
@@ -7987,7 +7993,7 @@ if(this._normalMap){hash.push("/nm");if(this._normalMap.hasMatrix){hash.push("/m
|
|
|
7987
7993
|
* @type {String}
|
|
7988
7994
|
*/function get(){return this._state.frontface?"ccw":"cw";}/**
|
|
7989
7995
|
* Destroys this PhongMaterial.
|
|
7990
|
-
*/,set:function set(value){value=value!=="cw";if(this._state.frontface===value){return;}this._state.frontface=value;this.glRedraw();}},{key:"destroy",value:function destroy(){_superPropGet(PhongMaterial,"destroy",this,3)([]);this._state.destroy();}}]);}(Material);var PRESETS$3={"default":{fill:true,fillColor:[0.4,0.4,0.4],fillAlpha:0.2,edges:true,edgeColor:[0.2,0.2,0.2],edgeAlpha:0.5,edgeWidth:1},defaultWhiteBG:{fill:true,fillColor:[1,1,1],fillAlpha:0.6,edgeColor:[0.2,0.2,0.2],edgeAlpha:1.0,edgeWidth:1},defaultLightBG:{fill:true,fillColor:[0.4,0.4,0.4],fillAlpha:0.2,edges:true,edgeColor:[0.2,0.2,0.2],edgeAlpha:0.5,edgeWidth:1},defaultDarkBG:{fill:true,fillColor:[0.4,0.4,0.4],fillAlpha:0.2,edges:true,edgeColor:[0.5,0.5,0.5],edgeAlpha:0.5,edgeWidth:1},phosphorous:{fill:true,fillColor:[0.0,0.0,0.0],fillAlpha:0.4,edges:true,edgeColor:[0.9,0.9,0.9],edgeAlpha:0.5,edgeWidth:2},sunset:{fill:true,fillColor:[0.9,0.9,0.6],fillAlpha:0.2,edges:true,edgeColor:[0.9,0.9,0.9],edgeAlpha:0.5,edgeWidth:1},vectorscope:{fill:true,fillColor:[0.0,0.0,0.0],fillAlpha:0.7,edges:true,edgeColor:[0.2,1.0,0.2],edgeAlpha:1,edgeWidth:2},battlezone:{fill:true,fillColor:[0.0,0.0,0.0],fillAlpha:1.0,edges:true,edgeColor:[0.2,1.0,0.2],edgeAlpha:1,edgeWidth:3},xraylightblue:{fill:true,fillColor:[0.2,0.3,0.4],fillAlpha:0.2,edges:true,edgeColor:[0.1,0.2,0.3],edgeAlpha:1.0,edgeWidth:1},blueHighlight:{fill:true,fillColor:[0.6,0.7,0.8],fillAlpha:0.2,edges:true,edgeColor:[1.0,1.0,1.0],edgeAlpha:1.0,edgeWidth:1},greenSelected:{fill:true,fillColor:[0.0,1.0,0.0],fillAlpha:0.5,edges:true,edgeColor:[1.0,1.0,1.0],edgeAlpha:1.0,edgeWidth:1},gamegrid:{fill:true,fillColor:[0.2,0.2,0.7],fillAlpha:0.9,edges:true,edgeColor:[0.4,0.4,1.6],edgeAlpha:0.8,edgeWidth:3}};/**
|
|
7996
|
+
*/,set:function set(value){value=value!=="cw";if(this._state.frontface===value){return;}this._state.frontface=value;this.glRedraw();}},{key:"destroy",value:function destroy(){_superPropGet(PhongMaterial,"destroy",this,3)([]);this._state.destroy();}}]);}(Material);var PRESETS$3={"default":{fill:true,fillColor:[0.4,0.4,0.4],fillAlpha:0.2,edges:true,edgeColor:[0.2,0.2,0.2],edgeAlpha:0.5,edgeWidth:1},defaultWhiteBG:{fill:true,fillColor:[1,1,1],fillAlpha:0.6,edgeColor:[0.2,0.2,0.2],edgeAlpha:1.0,edgeWidth:1},defaultLightBG:{fill:true,fillColor:[0.4,0.4,0.4],fillAlpha:0.2,edges:true,edgeColor:[0.2,0.2,0.2],edgeAlpha:0.5,edgeWidth:1},defaultDarkBG:{fill:true,fillColor:[0.4,0.4,0.4],fillAlpha:0.2,edges:true,edgeColor:[0.5,0.5,0.5],edgeAlpha:0.5,edgeWidth:1},phosphorous:{fill:true,fillColor:[0.0,0.0,0.0],fillAlpha:0.4,edges:true,edgeColor:[0.9,0.9,0.9],edgeAlpha:0.5,edgeWidth:2},sunset:{fill:true,fillColor:[0.9,0.9,0.6],fillAlpha:0.2,edges:true,edgeColor:[0.9,0.9,0.9],edgeAlpha:0.5,edgeWidth:1},vectorscope:{fill:true,fillColor:[0.0,0.0,0.0],fillAlpha:0.7,edges:true,edgeColor:[0.2,1.0,0.2],edgeAlpha:1,edgeWidth:2},battlezone:{fill:true,fillColor:[0.0,0.0,0.0],fillAlpha:1.0,edges:true,edgeColor:[0.2,1.0,0.2],edgeAlpha:1,edgeWidth:3},xraylightblue:{fill:true,fillColor:[0.2,0.3,0.4],fillAlpha:0.2,edges:true,edgeColor:[0.1,0.2,0.3],edgeAlpha:1.0,edgeWidth:1},blueHighlight:{fill:true,fillColor:[0.6,0.7,0.8],fillAlpha:0.2,edges:true,edgeColor:[1.0,1.0,1.0],edgeAlpha:1.0,edgeWidth:1},greenSelected:{fill:true,fillColor:[0.0,1.0,0.0],fillAlpha:0.5,edges:true,edgeColor:[1.0,1.0,1.0],edgeAlpha:1.0,edgeWidth:1},blueSelected:{fill:true,fillColor:[0.2,0.6,0.9],fillAlpha:0.3,edges:false,edgeColor:[1.0,1.0,1.0],edgeAlpha:1.0,edgeWidth:1},gamegrid:{fill:true,fillColor:[0.2,0.2,0.7],fillAlpha:0.9,edges:true,edgeColor:[0.4,0.4,1.6],edgeAlpha:0.8,edgeWidth:3}};/**
|
|
7991
7997
|
* Configures the appearance of {@link Entity}s when they are xrayed, highlighted or selected.
|
|
7992
7998
|
*
|
|
7993
7999
|
* * XRay an {@link Entity} by setting {@link Entity#xrayed} ````true````.
|
|
@@ -9932,7 +9938,7 @@ dontClear:true});}/**
|
|
|
9932
9938
|
* {@link Mesh}s are highlighted while {@link Mesh#highlighted} is ````true````.
|
|
9933
9939
|
*
|
|
9934
9940
|
* @type {EmphasisMaterial}
|
|
9935
|
-
*/},{key:"selectedMaterial",get:function get(){return this.components["default.selectedMaterial"]||new EmphasisMaterial(this,{id:"default.selectedMaterial",preset:"
|
|
9941
|
+
*/},{key:"selectedMaterial",get:function get(){return this.components["default.selectedMaterial"]||new EmphasisMaterial(this,{id:"default.selectedMaterial",preset:"blueSelected",dontClear:true});}/**
|
|
9936
9942
|
* Gets the default {@link EdgeMaterial} for this Scene.
|
|
9937
9943
|
*
|
|
9938
9944
|
* Has {@link EdgeMaterial#id} set to "default.edgeMaterial".
|
|
@@ -11468,224 +11474,224 @@ if(p===UnsignedInt248Type){return gl.UNSIGNED_INT_24_8;}if(p===RepeatWrapping){r
|
|
|
11468
11474
|
if(props.format!==undefined){this.format=props.format;}if(props.internalFormat!==undefined){this.internalFormat=props.internalFormat;}if(props.encoding!==undefined){this.encoding=props.encoding;}if(props.type!==undefined){this.type=props.type;}if(props.flipY!==undefined){this.flipY=props.flipY;}if(props.premultiplyAlpha!==undefined){this.premultiplyAlpha=props.premultiplyAlpha;}if(props.unpackAlignment!==undefined){this.unpackAlignment=props.unpackAlignment;}if(props.minFilter!==undefined){this.minFilter=props.minFilter;}if(props.magFilter!==undefined){this.magFilter=props.magFilter;}if(props.wrapS!==undefined){this.wrapS=props.wrapS;}if(props.wrapT!==undefined){this.wrapT=props.wrapT;}if(props.wrapR!==undefined){this.wrapR=props.wrapR;}gl.activeTexture(gl.TEXTURE0+0);gl.bindTexture(this.target,this.texture);var supportsMips=mipmaps.length>1;gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,this.flipY);gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha);gl.pixelStorei(gl.UNPACK_ALIGNMENT,this.unpackAlignment);gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,gl.NONE);var wrapS=convertConstant(gl,this.wrapS);if(wrapS){gl.texParameteri(this.target,gl.TEXTURE_WRAP_S,wrapS);}var wrapT=convertConstant(gl,this.wrapT);if(wrapT){gl.texParameteri(this.target,gl.TEXTURE_WRAP_T,wrapT);}if(this.type===gl.TEXTURE_3D||this.type===gl.TEXTURE_2D_ARRAY){var wrapR=convertConstant(gl,this.wrapR);if(wrapR){gl.texParameteri(this.target,gl.TEXTURE_WRAP_R,wrapR);}gl.texParameteri(this.type,gl.TEXTURE_WRAP_R,wrapR);}if(supportsMips){gl.texParameteri(this.target,gl.TEXTURE_MIN_FILTER,filterFallback(gl,this.minFilter));gl.texParameteri(this.target,gl.TEXTURE_MAG_FILTER,filterFallback(gl,this.magFilter));}else{gl.texParameteri(this.target,gl.TEXTURE_MIN_FILTER,convertConstant(gl,this.minFilter));gl.texParameteri(this.target,gl.TEXTURE_MAG_FILTER,convertConstant(gl,this.magFilter));}var glFormat=convertConstant(gl,this.format,this.encoding);var glType=convertConstant(gl,this.type);var glInternalFormat=getInternalFormat(gl,this.internalFormat,glFormat,glType,this.encoding,false);gl.texStorage2D(gl.TEXTURE_2D,levels,glInternalFormat,mipmaps[0].width,mipmaps[0].height);for(var _i127=0,len=mipmaps.length;_i127<len;_i127++){var mipmap=mipmaps[_i127];if(this.format!==RGBAFormat){if(glFormat!==null){gl.compressedTexSubImage2D(gl.TEXTURE_2D,_i127,0,0,mipmap.width,mipmap.height,glFormat,mipmap.data);}else{console.warn('Attempt to load unsupported compressed texture format in .setCompressedData()');}}else{gl.texSubImage2D(gl.TEXTURE_2D,_i127,0,0,mipmap.width,mipmap.height,glFormat,glType,mipmap.data);}}// if (generateMipMap) {
|
|
11469
11475
|
// // gl.generateMipmap(this.target); // Only for roughness textures?
|
|
11470
11476
|
// }
|
|
11471
|
-
gl.bindTexture(this.target,null);}},{key:"setProps",value:function setProps(props){var gl=this.gl;gl.bindTexture(this.target,this.texture);this._uploadProps(props);gl.bindTexture(this.target,null);}},{key:"_uploadProps",value:function _uploadProps(props){var gl=this.gl;if(props.format!==undefined){this.format=props.format;}if(props.internalFormat!==undefined){this.internalFormat=props.internalFormat;}if(props.encoding!==undefined){this.encoding=props.encoding;}if(props.type!==undefined){this.type=props.type;}if(props.minFilter!==undefined){var minFilter=convertConstant(gl,props.minFilter);if(minFilter){this.minFilter=props.minFilter;gl.texParameteri(this.target,gl.TEXTURE_MIN_FILTER,minFilter);if(minFilter===gl.NEAREST_MIPMAP_NEAREST||minFilter===gl.LINEAR_MIPMAP_NEAREST||minFilter===gl.NEAREST_MIPMAP_LINEAR||minFilter===gl.LINEAR_MIPMAP_LINEAR){gl.generateMipmap(this.target);}}}if(props.magFilter!==undefined){var magFilter=convertConstant(gl,props.magFilter);if(magFilter){this.magFilter=props.magFilter;gl.texParameteri(this.target,gl.TEXTURE_MAG_FILTER,magFilter);}}if(props.wrapS!==undefined){var wrapS=convertConstant(gl,props.wrapS);if(wrapS){this.wrapS=props.wrapS;gl.texParameteri(this.target,gl.TEXTURE_WRAP_S,wrapS);}}if(props.wrapT!==undefined){var wrapT=convertConstant(gl,props.wrapT);if(wrapT){this.wrapT=props.wrapT;gl.texParameteri(this.target,gl.TEXTURE_WRAP_T,wrapT);}}}},{key:"bind",value:function bind(unit){if(!this.allocated){return;}if(this.texture){var _gl2=this.gl;_gl2.activeTexture(_gl2["TEXTURE"+unit]);_gl2.bindTexture(this.target,this.texture);return true;}return false;}},{key:"unbind",value:function unbind(unit){if(!this.allocated){return;}if(this.texture){var _gl3=this.gl;_gl3.activeTexture(_gl3["TEXTURE"+unit]);_gl3.bindTexture(this.target,null);}}},{key:"destroy",value:function destroy(){if(!this.allocated){return;}if(this.texture){this.gl.deleteTexture(this.texture);this.texture=null;}}}]);}();function getInternalFormat(gl,internalFormatName,glFormat,glType,encoding){var isVideoTexture=arguments.length>5&&arguments[5]!==undefined?arguments[5]:false;if(internalFormatName!==null){if(gl[internalFormatName]!==undefined){return gl[internalFormatName];}console.warn('Attempt to use non-existing WebGL internal format \''+internalFormatName+'\'');}var internalFormat=glFormat;if(glFormat===gl.RED){if(glType===gl.FLOAT)internalFormat=gl.R32F;if(glType===gl.HALF_FLOAT)internalFormat=gl.R16F;if(glType===gl.UNSIGNED_BYTE)internalFormat=gl.R8;}if(glFormat===gl.RG){if(glType===gl.FLOAT)internalFormat=gl.RG32F;if(glType===gl.HALF_FLOAT)internalFormat=gl.RG16F;if(glType===gl.UNSIGNED_BYTE)internalFormat=gl.RG8;}if(glFormat===gl.RGBA){if(glType===gl.FLOAT)internalFormat=gl.RGBA32F;if(glType===gl.HALF_FLOAT)internalFormat=gl.RGBA16F;if(glType===gl.UNSIGNED_BYTE)internalFormat=encoding===sRGBEncoding&&isVideoTexture===false?gl.SRGB8_ALPHA8:gl.RGBA8;if(glType===gl.UNSIGNED_SHORT_4_4_4_4)internalFormat=gl.RGBA4;if(glType===gl.UNSIGNED_SHORT_5_5_5_1)internalFormat=gl.RGB5_A1;}if(internalFormat===gl.R16F||internalFormat===gl.R32F||internalFormat===gl.RG16F||internalFormat===gl.RG32F||internalFormat===gl.RGBA16F||internalFormat===gl.RGBA32F){getExtension(gl,'EXT_color_buffer_float');}return internalFormat;}function filterFallback(gl,f){if(f===NearestFilter||f===NearestMipmapNearestFilter||f===NearestMipmapLinearFilter){return gl.NEAREST;}return gl.LINEAR;}function ensureImageSizePowerOfTwo$1(image){if(!isPowerOfTwo$1(image.width)||!isPowerOfTwo$1(image.height)){var _canvas3=document.createElement("canvas");_canvas3.width=nextHighestPowerOfTwo$1(image.width);_canvas3.height=nextHighestPowerOfTwo$1(image.height);var ctx=_canvas3.getContext("2d");ctx.drawImage(image,0,0,image.width,image.height,0,0,_canvas3.width,_canvas3.height);image=_canvas3;}return image;}function isPowerOfTwo$1(x){return(x&x-1)===0;}function nextHighestPowerOfTwo$1(x){--x;for(var _i128=1;_i128<32;_i128<<=1){x=x|x>>_i128;}return x+1;}/**
|
|
11472
|
-
* @desc A 2D texture map.
|
|
11473
|
-
*
|
|
11474
|
-
* * Textures are attached to {@link Material}s, which are attached to {@link Mesh}es.
|
|
11475
|
-
* * To create a Texture from an image file, set {@link Texture#src} to the image file path.
|
|
11476
|
-
* * To create a Texture from an HTMLImageElement, set the Texture's {@link Texture#image} to the HTMLImageElement.
|
|
11477
|
-
*
|
|
11478
|
-
* ## Usage
|
|
11479
|
-
*
|
|
11480
|
-
* In this example we have a Mesh with a {@link PhongMaterial} which applies diffuse {@link Texture}, and a {@link buildTorusGeometry} which builds a {@link ReadableGeometry}.
|
|
11481
|
-
*
|
|
11482
|
-
* Note that xeokit will ignore {@link PhongMaterial#diffuse} and {@link PhongMaterial#specular}, since we override those
|
|
11483
|
-
* with {@link PhongMaterial#diffuseMap} and {@link PhongMaterial#specularMap}. The {@link Texture} pixel colors directly
|
|
11484
|
-
* provide the diffuse and specular components for each fragment across the {@link ReadableGeometry} surface.
|
|
11485
|
-
*
|
|
11486
|
-
* [[Run this example](/examples/#materials_Texture)]
|
|
11487
|
-
*
|
|
11488
|
-
* ```` javascript
|
|
11489
|
-
* import {Viewer, Mesh, buildTorusGeometry,
|
|
11490
|
-
* ReadableGeometry, PhongMaterial, Texture} from "xeokit-sdk.es.js";
|
|
11491
|
-
*
|
|
11492
|
-
* const viewer = new Viewer({
|
|
11493
|
-
* canvasId: "myCanvas"
|
|
11494
|
-
* });
|
|
11495
|
-
*
|
|
11496
|
-
* viewer.camera.eye = [0, 0, 5];
|
|
11497
|
-
* viewer.camera.look = [0, 0, 0];
|
|
11498
|
-
* viewer.camera.up = [0, 1, 0];
|
|
11499
|
-
*
|
|
11500
|
-
* new Mesh(viewer.scene, {
|
|
11501
|
-
* geometry: new ReadableGeometry(viewer.scene, buildTorusGeometry({
|
|
11502
|
-
* center: [0, 0, 0],
|
|
11503
|
-
* radius: 1.5,
|
|
11504
|
-
* tube: 0.5,
|
|
11505
|
-
* radialSegments: 32,
|
|
11506
|
-
* tubeSegments: 24,
|
|
11507
|
-
* arc: Math.PI * 2.0
|
|
11508
|
-
* }),
|
|
11509
|
-
* material: new PhongMaterial(viewer.scene, {
|
|
11510
|
-
* ambient: [0.9, 0.3, 0.9],
|
|
11511
|
-
* shininess: 30,
|
|
11512
|
-
* diffuseMap: new Texture(viewer.scene, {
|
|
11513
|
-
* src: "textures/diffuse/uvGrid2.jpg"
|
|
11514
|
-
* })
|
|
11515
|
-
* })
|
|
11516
|
-
* });
|
|
11517
|
-
*````
|
|
11518
|
-
*/var Texture=/*#__PURE__*/function(_Component23){/**
|
|
11519
|
-
* @constructor
|
|
11520
|
-
* @param {Component} owner Owner component. When destroyed, the owner will destroy this Texture as well.
|
|
11521
|
-
* @param {*} [cfg] Configs
|
|
11522
|
-
* @param {String} [cfg.id] Optional ID for this Texture, unique among all components in the parent scene, generated automatically when omitted.
|
|
11523
|
-
* @param {String} [cfg.src=null] Path to image file to load into this Texture. See the {@link Texture#src} property for more info.
|
|
11524
|
-
* @param {HTMLImageElement} [cfg.image=null] HTML Image object to load into this Texture. See the {@link Texture#image} property for more info.
|
|
11525
|
-
* @param {Number} [cfg.minFilter=LinearMipmapLinearFilter] How the texture is sampled when a texel covers less than one pixel.
|
|
11526
|
-
* Supported values are {@link LinearMipmapLinearFilter}, {@link LinearMipMapNearestFilter}, {@link NearestMipMapNearestFilter}, {@link NearestMipMapLinearFilter} and {@link LinearMipMapLinearFilter}.
|
|
11527
|
-
* @param {Number} [cfg.magFilter=LinearFilter] How the texture is sampled when a texel covers more than one pixel. Supported values are {@link LinearFilter} and {@link NearestFilter}.
|
|
11528
|
-
* @param {Number} [cfg.wrapS=RepeatWrapping] Wrap parameter for texture coordinate *S*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}.
|
|
11529
|
-
* @param {Number} [cfg.wrapT=RepeatWrapping] Wrap parameter for texture coordinate *T*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}..
|
|
11530
|
-
* @param {Boolean} [cfg.flipY=false] Flips this Texture's source data along its vertical axis when ````true````.
|
|
11531
|
-
* @param {Number} [cfg.encoding=LinearEncoding] Encoding format. Supported values are {@link LinearEncoding} and {@link sRGBEncoding}.
|
|
11532
|
-
* @param {Number[]} [cfg.translate=[0,0]] 2D translation vector that will be added to texture's *S* and *T* coordinates.
|
|
11533
|
-
* @param {Number[]} [cfg.scale=[1,1]] 2D scaling vector that will be applied to texture's *S* and *T* coordinates.
|
|
11534
|
-
* @param {Number} [cfg.rotate=0] Rotation, in degrees, that will be applied to texture's *S* and *T* coordinates.
|
|
11477
|
+
gl.bindTexture(this.target,null);}},{key:"setProps",value:function setProps(props){var gl=this.gl;gl.bindTexture(this.target,this.texture);this._uploadProps(props);gl.bindTexture(this.target,null);}},{key:"_uploadProps",value:function _uploadProps(props){var gl=this.gl;if(props.format!==undefined){this.format=props.format;}if(props.internalFormat!==undefined){this.internalFormat=props.internalFormat;}if(props.encoding!==undefined){this.encoding=props.encoding;}if(props.type!==undefined){this.type=props.type;}if(props.minFilter!==undefined){var minFilter=convertConstant(gl,props.minFilter);if(minFilter){this.minFilter=props.minFilter;gl.texParameteri(this.target,gl.TEXTURE_MIN_FILTER,minFilter);if(minFilter===gl.NEAREST_MIPMAP_NEAREST||minFilter===gl.LINEAR_MIPMAP_NEAREST||minFilter===gl.NEAREST_MIPMAP_LINEAR||minFilter===gl.LINEAR_MIPMAP_LINEAR){gl.generateMipmap(this.target);}}}if(props.magFilter!==undefined){var magFilter=convertConstant(gl,props.magFilter);if(magFilter){this.magFilter=props.magFilter;gl.texParameteri(this.target,gl.TEXTURE_MAG_FILTER,magFilter);}}if(props.wrapS!==undefined){var wrapS=convertConstant(gl,props.wrapS);if(wrapS){this.wrapS=props.wrapS;gl.texParameteri(this.target,gl.TEXTURE_WRAP_S,wrapS);}}if(props.wrapT!==undefined){var wrapT=convertConstant(gl,props.wrapT);if(wrapT){this.wrapT=props.wrapT;gl.texParameteri(this.target,gl.TEXTURE_WRAP_T,wrapT);}}}},{key:"bind",value:function bind(unit){if(!this.allocated){return;}if(this.texture){var _gl2=this.gl;_gl2.activeTexture(_gl2["TEXTURE"+unit]);_gl2.bindTexture(this.target,this.texture);return true;}return false;}},{key:"unbind",value:function unbind(unit){if(!this.allocated){return;}if(this.texture){var _gl3=this.gl;_gl3.activeTexture(_gl3["TEXTURE"+unit]);_gl3.bindTexture(this.target,null);}}},{key:"destroy",value:function destroy(){if(!this.allocated){return;}if(this.texture){this.gl.deleteTexture(this.texture);this.texture=null;}}}]);}();function getInternalFormat(gl,internalFormatName,glFormat,glType,encoding){var isVideoTexture=arguments.length>5&&arguments[5]!==undefined?arguments[5]:false;if(internalFormatName!==null){if(gl[internalFormatName]!==undefined){return gl[internalFormatName];}console.warn('Attempt to use non-existing WebGL internal format \''+internalFormatName+'\'');}var internalFormat=glFormat;if(glFormat===gl.RED){if(glType===gl.FLOAT)internalFormat=gl.R32F;if(glType===gl.HALF_FLOAT)internalFormat=gl.R16F;if(glType===gl.UNSIGNED_BYTE)internalFormat=gl.R8;}if(glFormat===gl.RG){if(glType===gl.FLOAT)internalFormat=gl.RG32F;if(glType===gl.HALF_FLOAT)internalFormat=gl.RG16F;if(glType===gl.UNSIGNED_BYTE)internalFormat=gl.RG8;}if(glFormat===gl.RGBA){if(glType===gl.FLOAT)internalFormat=gl.RGBA32F;if(glType===gl.HALF_FLOAT)internalFormat=gl.RGBA16F;if(glType===gl.UNSIGNED_BYTE)internalFormat=encoding===sRGBEncoding&&isVideoTexture===false?gl.SRGB8_ALPHA8:gl.RGBA8;if(glType===gl.UNSIGNED_SHORT_4_4_4_4)internalFormat=gl.RGBA4;if(glType===gl.UNSIGNED_SHORT_5_5_5_1)internalFormat=gl.RGB5_A1;}if(internalFormat===gl.R16F||internalFormat===gl.R32F||internalFormat===gl.RG16F||internalFormat===gl.RG32F||internalFormat===gl.RGBA16F||internalFormat===gl.RGBA32F){getExtension(gl,'EXT_color_buffer_float');}return internalFormat;}function filterFallback(gl,f){if(f===NearestFilter||f===NearestMipmapNearestFilter||f===NearestMipmapLinearFilter){return gl.NEAREST;}return gl.LINEAR;}function ensureImageSizePowerOfTwo$1(image){if(!isPowerOfTwo$1(image.width)||!isPowerOfTwo$1(image.height)){var _canvas3=document.createElement("canvas");_canvas3.width=nextHighestPowerOfTwo$1(image.width);_canvas3.height=nextHighestPowerOfTwo$1(image.height);var ctx=_canvas3.getContext("2d");ctx.drawImage(image,0,0,image.width,image.height,0,0,_canvas3.width,_canvas3.height);image=_canvas3;}return image;}function isPowerOfTwo$1(x){return(x&x-1)===0;}function nextHighestPowerOfTwo$1(x){--x;for(var _i128=1;_i128<32;_i128<<=1){x=x|x>>_i128;}return x+1;}/**
|
|
11478
|
+
* @desc A 2D texture map.
|
|
11479
|
+
*
|
|
11480
|
+
* * Textures are attached to {@link Material}s, which are attached to {@link Mesh}es.
|
|
11481
|
+
* * To create a Texture from an image file, set {@link Texture#src} to the image file path.
|
|
11482
|
+
* * To create a Texture from an HTMLImageElement, set the Texture's {@link Texture#image} to the HTMLImageElement.
|
|
11483
|
+
*
|
|
11484
|
+
* ## Usage
|
|
11485
|
+
*
|
|
11486
|
+
* In this example we have a Mesh with a {@link PhongMaterial} which applies diffuse {@link Texture}, and a {@link buildTorusGeometry} which builds a {@link ReadableGeometry}.
|
|
11487
|
+
*
|
|
11488
|
+
* Note that xeokit will ignore {@link PhongMaterial#diffuse} and {@link PhongMaterial#specular}, since we override those
|
|
11489
|
+
* with {@link PhongMaterial#diffuseMap} and {@link PhongMaterial#specularMap}. The {@link Texture} pixel colors directly
|
|
11490
|
+
* provide the diffuse and specular components for each fragment across the {@link ReadableGeometry} surface.
|
|
11491
|
+
*
|
|
11492
|
+
* [[Run this example](/examples/#materials_Texture)]
|
|
11493
|
+
*
|
|
11494
|
+
* ```` javascript
|
|
11495
|
+
* import {Viewer, Mesh, buildTorusGeometry,
|
|
11496
|
+
* ReadableGeometry, PhongMaterial, Texture} from "xeokit-sdk.es.js";
|
|
11497
|
+
*
|
|
11498
|
+
* const viewer = new Viewer({
|
|
11499
|
+
* canvasId: "myCanvas"
|
|
11500
|
+
* });
|
|
11501
|
+
*
|
|
11502
|
+
* viewer.camera.eye = [0, 0, 5];
|
|
11503
|
+
* viewer.camera.look = [0, 0, 0];
|
|
11504
|
+
* viewer.camera.up = [0, 1, 0];
|
|
11505
|
+
*
|
|
11506
|
+
* new Mesh(viewer.scene, {
|
|
11507
|
+
* geometry: new ReadableGeometry(viewer.scene, buildTorusGeometry({
|
|
11508
|
+
* center: [0, 0, 0],
|
|
11509
|
+
* radius: 1.5,
|
|
11510
|
+
* tube: 0.5,
|
|
11511
|
+
* radialSegments: 32,
|
|
11512
|
+
* tubeSegments: 24,
|
|
11513
|
+
* arc: Math.PI * 2.0
|
|
11514
|
+
* }),
|
|
11515
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
11516
|
+
* ambient: [0.9, 0.3, 0.9],
|
|
11517
|
+
* shininess: 30,
|
|
11518
|
+
* diffuseMap: new Texture(viewer.scene, {
|
|
11519
|
+
* src: "textures/diffuse/uvGrid2.jpg"
|
|
11520
|
+
* })
|
|
11521
|
+
* })
|
|
11522
|
+
* });
|
|
11523
|
+
*````
|
|
11524
|
+
*/var Texture=/*#__PURE__*/function(_Component23){/**
|
|
11525
|
+
* @constructor
|
|
11526
|
+
* @param {Component} owner Owner component. When destroyed, the owner will destroy this Texture as well.
|
|
11527
|
+
* @param {*} [cfg] Configs
|
|
11528
|
+
* @param {String} [cfg.id] Optional ID for this Texture, unique among all components in the parent scene, generated automatically when omitted.
|
|
11529
|
+
* @param {String} [cfg.src=null] Path to image file to load into this Texture. See the {@link Texture#src} property for more info.
|
|
11530
|
+
* @param {HTMLImageElement} [cfg.image=null] HTML Image object to load into this Texture. See the {@link Texture#image} property for more info.
|
|
11531
|
+
* @param {Number} [cfg.minFilter=LinearMipmapLinearFilter] How the texture is sampled when a texel covers less than one pixel.
|
|
11532
|
+
* Supported values are {@link LinearMipmapLinearFilter}, {@link LinearMipMapNearestFilter}, {@link NearestMipMapNearestFilter}, {@link NearestMipMapLinearFilter} and {@link LinearMipMapLinearFilter}.
|
|
11533
|
+
* @param {Number} [cfg.magFilter=LinearFilter] How the texture is sampled when a texel covers more than one pixel. Supported values are {@link LinearFilter} and {@link NearestFilter}.
|
|
11534
|
+
* @param {Number} [cfg.wrapS=RepeatWrapping] Wrap parameter for texture coordinate *S*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}.
|
|
11535
|
+
* @param {Number} [cfg.wrapT=RepeatWrapping] Wrap parameter for texture coordinate *T*. Supported values are {@link ClampToEdgeWrapping}, {@link MirroredRepeatWrapping} and {@link RepeatWrapping}..
|
|
11536
|
+
* @param {Boolean} [cfg.flipY=false] Flips this Texture's source data along its vertical axis when ````true````.
|
|
11537
|
+
* @param {Number} [cfg.encoding=LinearEncoding] Encoding format. Supported values are {@link LinearEncoding} and {@link sRGBEncoding}.
|
|
11538
|
+
* @param {Number[]} [cfg.translate=[0,0]] 2D translation vector that will be added to texture's *S* and *T* coordinates.
|
|
11539
|
+
* @param {Number[]} [cfg.scale=[1,1]] 2D scaling vector that will be applied to texture's *S* and *T* coordinates.
|
|
11540
|
+
* @param {Number} [cfg.rotate=0] Rotation, in degrees, that will be applied to texture's *S* and *T* coordinates.
|
|
11535
11541
|
*/function Texture(owner){var _this59;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Texture);_this59=_callSuper(this,Texture,[owner,cfg]);_this59._state=new RenderState({texture:new Texture2D({gl:_this59.scene.canvas.gl}),matrix:math.identityMat4(),hasMatrix:cfg.translate&&(cfg.translate[0]!==0||cfg.translate[1]!==0)||!!cfg.rotate||cfg.scale&&(cfg.scale[0]!==0||cfg.scale[1]!==0),minFilter:_this59._checkMinFilter(cfg.minFilter||1008),magFilter:_this59._checkMagFilter(cfg.magFilter||1006),wrapS:_this59._checkWrapS(cfg.wrapS||1000),wrapT:_this59._checkWrapT(cfg.wrapT||1000),flipY:_this59._checkFlipY(cfg.flipY||1000),encoding:_this59._checkEncoding(cfg.encoding)});// Data source
|
|
11536
11542
|
_this59._src=null;_this59._image=null;// Transformation
|
|
11537
11543
|
_this59._translate=math.vec2([0,0]);_this59._scale=math.vec2([1,1]);_this59._rotate=math.vec2([0,0]);_this59._matrixDirty=false;// Transform
|
|
11538
11544
|
_this59.translate=cfg.translate;_this59.scale=cfg.scale;_this59.rotate=cfg.rotate;// Data source
|
|
11539
11545
|
if(cfg.src){_this59.src=cfg.src;// Image file
|
|
11540
11546
|
}else if(cfg.image){_this59.image=cfg.image;// Image object
|
|
11541
|
-
}stats.memory.textures++;return _this59;}_inherits(Texture,_Component23);return _createClass(Texture,[{key:"type",get:/**
|
|
11542
|
-
@private
|
|
11543
|
-
*/function get(){return"Texture";}},{key:"_checkMinFilter",value:function _checkMinFilter(value){value=value||LinearMipMapLinearFilter;if(value!==LinearFilter&&value!==LinearMipMapNearestFilter&&value!==LinearMipMapLinearFilter&&value!==NearestMipMapLinearFilter&&value!==NearestMipMapNearestFilter){this.error("Unsupported value for 'minFilter' - supported values are LinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, "+"NearestMipMapLinearFilter and LinearMipMapLinearFilter. Defaulting to LinearMipMapLinearFilter.");value=LinearMipMapLinearFilter;}return value;}},{key:"_checkMagFilter",value:function _checkMagFilter(value){value=value||LinearFilter;if(value!==LinearFilter&&value!==NearestFilter){this.error("Unsupported value for 'magFilter' - supported values are LinearFilter and NearestFilter. Defaulting to LinearFilter.");value=LinearFilter;}return value;}},{key:"_checkWrapS",value:function _checkWrapS(value){value=value||RepeatWrapping;if(value!==ClampToEdgeWrapping&&value!==MirroredRepeatWrapping&&value!==RepeatWrapping){this.error("Unsupported value for 'wrapS' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping.");value=RepeatWrapping;}return value;}},{key:"_checkWrapT",value:function _checkWrapT(value){value=value||RepeatWrapping;if(value!==ClampToEdgeWrapping&&value!==MirroredRepeatWrapping&&value!==RepeatWrapping){this.error("Unsupported value for 'wrapT' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping.");value=RepeatWrapping;}return value;}},{key:"_checkFlipY",value:function _checkFlipY(value){return!!value;}},{key:"_checkEncoding",value:function _checkEncoding(value){value=value||LinearEncoding;if(value!==LinearEncoding&&value!==sRGBEncoding){this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding.");value=LinearEncoding;}return value;}},{key:"_webglContextRestored",value:function _webglContextRestored(){this._state.texture=new Texture2D({gl:this.scene.canvas.gl});if(this._image){this.image=this._image;}else if(this._src){this.src=this._src;}}},{key:"_update",value:function _update(){var state=this._state;if(this._matrixDirty){var _matrix;var t;if(this._translate[0]!==0||this._translate[1]!==0){_matrix=math.translationMat4v([this._translate[0],this._translate[1],0],this._state.matrix);}if(this._scale[0]!==1||this._scale[1]!==1){t=math.scalingMat4v([this._scale[0],this._scale[1],1]);_matrix=_matrix?math.mulMat4(_matrix,t):t;}if(this._rotate!==0){t=math.rotationMat4v(this._rotate*0.0174532925,[0,0,1]);_matrix=_matrix?math.mulMat4(_matrix,t):t;}if(_matrix){state.matrix=_matrix;}this._matrixDirty=false;}this.glRedraw();}/**
|
|
11544
|
-
* Sets an HTML DOM Image object to source this Texture from.
|
|
11545
|
-
*
|
|
11546
|
-
* Sets {@link Texture#src} null.
|
|
11547
|
-
*
|
|
11548
|
-
* @type {HTMLImageElement}
|
|
11549
|
-
*/},{key:"image",get:/**
|
|
11550
|
-
* Gets HTML DOM Image object this Texture is sourced from, if any.
|
|
11551
|
-
*
|
|
11552
|
-
* Returns null if not set.
|
|
11553
|
-
*
|
|
11554
|
-
* @type {HTMLImageElement}
|
|
11555
|
-
*/function get(){return this._image;}/**
|
|
11556
|
-
* Sets path to an image file to source this Texture from.
|
|
11557
|
-
*
|
|
11558
|
-
* Sets {@link Texture#image} null.
|
|
11559
|
-
*
|
|
11560
|
-
* @type {String}
|
|
11561
|
-
*/,set:function set(value){this._image=ensureImageSizePowerOfTwo$1(value);this._image.crossOrigin="Anonymous";this._state.texture.setImage(this._image,this._state);this._src=null;this.glRedraw();}},{key:"src",get:/**
|
|
11562
|
-
* Gets path to the image file this Texture from, if any.
|
|
11563
|
-
*
|
|
11564
|
-
* Returns null if not set.
|
|
11565
|
-
*
|
|
11566
|
-
* @type {String}
|
|
11567
|
-
*/function get(){return this._src;}/**
|
|
11568
|
-
* Sets the 2D translation vector added to this Texture's *S* and *T* UV coordinates.
|
|
11569
|
-
*
|
|
11570
|
-
* Default value is ````[0, 0]````.
|
|
11571
|
-
*
|
|
11572
|
-
* @type {Number[]}
|
|
11573
|
-
*/,set:function set(src){this.scene.loading++;this.scene.canvas.spinner.processes++;var self=this;var image=new Image();image.onload=function(){image=ensureImageSizePowerOfTwo$1(image);self._state.texture.setImage(image,self._state);self.scene.loading--;self.glRedraw();self.scene.canvas.spinner.processes--;};image.src=src;this._src=src;this._image=null;}},{key:"translate",get:/**
|
|
11574
|
-
* Gets the 2D translation vector added to this Texture's *S* and *T* UV coordinates.
|
|
11575
|
-
*
|
|
11576
|
-
* Default value is ````[0, 0]````.
|
|
11577
|
-
*
|
|
11578
|
-
* @type {Number[]}
|
|
11579
|
-
*/function get(){return this._translate;}/**
|
|
11580
|
-
* Sets the 2D scaling vector that will be applied to this Texture's *S* and *T* UV coordinates.
|
|
11581
|
-
*
|
|
11582
|
-
* Default value is ````[1, 1]````.
|
|
11583
|
-
*
|
|
11584
|
-
* @type {Number[]}
|
|
11585
|
-
*/,set:function set(value){this._translate.set(value||[0,0]);this._matrixDirty=true;this._needUpdate();}},{key:"scale",get:/**
|
|
11586
|
-
* Gets the 2D scaling vector that will be applied to this Texture's *S* and *T* UV coordinates.
|
|
11587
|
-
*
|
|
11588
|
-
* Default value is ````[1, 1]````.
|
|
11589
|
-
*
|
|
11590
|
-
* @type {Number[]}
|
|
11591
|
-
*/function get(){return this._scale;}/**
|
|
11592
|
-
* Sets the rotation angles, in degrees, that will be applied to this Texture's *S* and *T* UV coordinates.
|
|
11593
|
-
*
|
|
11594
|
-
* Default value is ````0````.
|
|
11595
|
-
*
|
|
11596
|
-
* @type {Number}
|
|
11597
|
-
*/,set:function set(value){this._scale.set(value||[1,1]);this._matrixDirty=true;this._needUpdate();}},{key:"rotate",get:/**
|
|
11598
|
-
* Gets the rotation angles, in degrees, that will be applied to this Texture's *S* and *T* UV coordinates.
|
|
11599
|
-
*
|
|
11600
|
-
* Default value is ````0````.
|
|
11601
|
-
*
|
|
11602
|
-
* @type {Number}
|
|
11603
|
-
*/function get(){return this._rotate;}/**
|
|
11604
|
-
* Gets how this Texture is sampled when a texel covers less than one pixel.
|
|
11605
|
-
*
|
|
11606
|
-
* Options are:
|
|
11607
|
-
*
|
|
11608
|
-
* * NearestFilter - Uses the value of the texture element that is nearest
|
|
11609
|
-
* (in Manhattan distance) to the center of the pixel being textured.
|
|
11610
|
-
*
|
|
11611
|
-
* * LinearFilter - Uses the weighted average of the four texture elements that are
|
|
11612
|
-
* closest to the center of the pixel being textured.
|
|
11613
|
-
*
|
|
11614
|
-
* * NearestMipMapNearestFilter - Chooses the mipmap that most closely matches the
|
|
11615
|
-
* size of the pixel being textured and uses the "nearest" criterion (the texture
|
|
11616
|
-
* element nearest to the center of the pixel) to produce a texture value.
|
|
11617
|
-
*
|
|
11618
|
-
* * LinearMipMapNearestFilter - Chooses the mipmap that most closely matches the size of
|
|
11619
|
-
* the pixel being textured and uses the "linear" criterion (a weighted average of the
|
|
11620
|
-
* four texture elements that are closest to the center of the pixel) to produce a
|
|
11621
|
-
* texture value.
|
|
11622
|
-
*
|
|
11623
|
-
* * NearestMipMapLinearFilter - Chooses the two mipmaps that most closely
|
|
11624
|
-
* match the size of the pixel being textured and uses the "nearest" criterion
|
|
11625
|
-
* (the texture element nearest to the center of the pixel) to produce a texture
|
|
11626
|
-
* value from each mipmap. The final texture value is a weighted average of those two
|
|
11627
|
-
* values.
|
|
11628
|
-
*
|
|
11629
|
-
* * LinearMipMapLinearFilter - (default) - Chooses the two mipmaps that most closely match the size
|
|
11630
|
-
* of the pixel being textured and uses the "linear" criterion (a weighted average
|
|
11631
|
-
* of the four texture elements that are closest to the center of the pixel) to
|
|
11632
|
-
* produce a texture value from each mipmap. The final texture value is a weighted
|
|
11633
|
-
* average of those two values.
|
|
11634
|
-
*
|
|
11635
|
-
* Default value is LinearMipMapLinearFilter.
|
|
11636
|
-
*
|
|
11637
|
-
* @type {Number}
|
|
11638
|
-
*/,set:function set(value){value=value||0;if(this._rotate===value){return;}this._rotate=value;this._matrixDirty=true;this._needUpdate();}},{key:"minFilter",get:function get(){return this._state.minFilter;}/**
|
|
11639
|
-
* Gets how this Texture is sampled when a texel covers more than one pixel.
|
|
11640
|
-
*
|
|
11641
|
-
* * NearestFilter - Uses the value of the texture element that is nearest
|
|
11642
|
-
* (in Manhattan distance) to the center of the pixel being textured.
|
|
11643
|
-
* * LinearFilter - (default) - Uses the weighted average of the four texture elements that are
|
|
11644
|
-
* closest to the center of the pixel being textured.
|
|
11645
|
-
*
|
|
11646
|
-
* Default value is LinearMipMapLinearFilter.
|
|
11647
|
-
*
|
|
11648
|
-
* @type {Number}
|
|
11649
|
-
*/},{key:"magFilter",get:function get(){return this._state.magFilter;}/**
|
|
11650
|
-
* Gets the wrap parameter for this Texture's *S* coordinate.
|
|
11651
|
-
*
|
|
11652
|
-
* Values can be:
|
|
11653
|
-
*
|
|
11654
|
-
* * ClampToEdgeWrapping - causes *S* coordinates to be clamped to the size of the texture.
|
|
11655
|
-
* * MirroredRepeatWrapping - causes the *S* coordinate to be set to the fractional part of the texture coordinate
|
|
11656
|
-
* if the integer part of *S* is even; if the integer part of *S* is odd, then the *S* texture coordinate is
|
|
11657
|
-
* set to *1 - frac S* , where *frac S* represents the fractional part of *S*.
|
|
11658
|
-
* * RepeatWrapping - (default) - causes the integer part of the *S* coordinate to be ignored; xeokit uses only the
|
|
11659
|
-
* fractional part, thereby creating a repeating pattern.
|
|
11660
|
-
*
|
|
11661
|
-
* Default value is RepeatWrapping.
|
|
11662
|
-
*
|
|
11663
|
-
* @type {Number}
|
|
11664
|
-
*/},{key:"wrapS",get:function get(){return this._state.wrapS;}/**
|
|
11665
|
-
* Gets the wrap parameter for this Texture's *T* coordinate.
|
|
11666
|
-
*
|
|
11667
|
-
* Values can be:
|
|
11668
|
-
*
|
|
11669
|
-
* * ClampToEdgeWrapping - causes *S* coordinates to be clamped to the size of the texture.
|
|
11670
|
-
* * MirroredRepeatWrapping - causes the *S* coordinate to be set to the fractional part of the texture coordinate
|
|
11671
|
-
* if the integer part of *S* is even; if the integer part of *S* is odd, then the *S* texture coordinate is
|
|
11672
|
-
* set to *1 - frac S* , where *frac S* represents the fractional part of *S*.
|
|
11673
|
-
* * RepeatWrapping - (default) - causes the integer part of the *S* coordinate to be ignored; xeokit uses only the
|
|
11674
|
-
* fractional part, thereby creating a repeating pattern.
|
|
11675
|
-
*
|
|
11676
|
-
* Default value is RepeatWrapping.
|
|
11677
|
-
*
|
|
11678
|
-
* @type {Number}
|
|
11679
|
-
*/},{key:"wrapT",get:function get(){return this._state.wrapT;}/**
|
|
11680
|
-
* Gets if this Texture's source data is flipped along its vertical axis.
|
|
11681
|
-
*
|
|
11682
|
-
* @type {Number}
|
|
11683
|
-
*/},{key:"flipY",get:function get(){return this._state.flipY;}/**
|
|
11684
|
-
* Gets the Texture's encoding format.
|
|
11685
|
-
*
|
|
11686
|
-
* @type {Number}
|
|
11687
|
-
*/},{key:"encoding",get:function get(){return this._state.encoding;}/**
|
|
11688
|
-
* Destroys this Texture
|
|
11547
|
+
}stats.memory.textures++;return _this59;}_inherits(Texture,_Component23);return _createClass(Texture,[{key:"type",get:/**
|
|
11548
|
+
@private
|
|
11549
|
+
*/function get(){return"Texture";}},{key:"_checkMinFilter",value:function _checkMinFilter(value){value=value||LinearMipMapLinearFilter;if(value!==LinearFilter&&value!==LinearMipMapNearestFilter&&value!==LinearMipMapLinearFilter&&value!==NearestMipMapLinearFilter&&value!==NearestMipMapNearestFilter){this.error("Unsupported value for 'minFilter' - supported values are LinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, "+"NearestMipMapLinearFilter and LinearMipMapLinearFilter. Defaulting to LinearMipMapLinearFilter.");value=LinearMipMapLinearFilter;}return value;}},{key:"_checkMagFilter",value:function _checkMagFilter(value){value=value||LinearFilter;if(value!==LinearFilter&&value!==NearestFilter){this.error("Unsupported value for 'magFilter' - supported values are LinearFilter and NearestFilter. Defaulting to LinearFilter.");value=LinearFilter;}return value;}},{key:"_checkWrapS",value:function _checkWrapS(value){value=value||RepeatWrapping;if(value!==ClampToEdgeWrapping&&value!==MirroredRepeatWrapping&&value!==RepeatWrapping){this.error("Unsupported value for 'wrapS' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping.");value=RepeatWrapping;}return value;}},{key:"_checkWrapT",value:function _checkWrapT(value){value=value||RepeatWrapping;if(value!==ClampToEdgeWrapping&&value!==MirroredRepeatWrapping&&value!==RepeatWrapping){this.error("Unsupported value for 'wrapT' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping.");value=RepeatWrapping;}return value;}},{key:"_checkFlipY",value:function _checkFlipY(value){return!!value;}},{key:"_checkEncoding",value:function _checkEncoding(value){value=value||LinearEncoding;if(value!==LinearEncoding&&value!==sRGBEncoding){this.error("Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding.");value=LinearEncoding;}return value;}},{key:"_webglContextRestored",value:function _webglContextRestored(){this._state.texture=new Texture2D({gl:this.scene.canvas.gl});if(this._image){this.image=this._image;}else if(this._src){this.src=this._src;}}},{key:"_update",value:function _update(){var state=this._state;if(this._matrixDirty){var _matrix;var t;if(this._translate[0]!==0||this._translate[1]!==0){_matrix=math.translationMat4v([this._translate[0],this._translate[1],0],this._state.matrix);}if(this._scale[0]!==1||this._scale[1]!==1){t=math.scalingMat4v([this._scale[0],this._scale[1],1]);_matrix=_matrix?math.mulMat4(_matrix,t):t;}if(this._rotate!==0){t=math.rotationMat4v(this._rotate*0.0174532925,[0,0,1]);_matrix=_matrix?math.mulMat4(_matrix,t):t;}if(_matrix){state.matrix=_matrix;}this._matrixDirty=false;}this.glRedraw();}/**
|
|
11550
|
+
* Sets an HTML DOM Image object to source this Texture from.
|
|
11551
|
+
*
|
|
11552
|
+
* Sets {@link Texture#src} null.
|
|
11553
|
+
*
|
|
11554
|
+
* @type {HTMLImageElement}
|
|
11555
|
+
*/},{key:"image",get:/**
|
|
11556
|
+
* Gets HTML DOM Image object this Texture is sourced from, if any.
|
|
11557
|
+
*
|
|
11558
|
+
* Returns null if not set.
|
|
11559
|
+
*
|
|
11560
|
+
* @type {HTMLImageElement}
|
|
11561
|
+
*/function get(){return this._image;}/**
|
|
11562
|
+
* Sets path to an image file to source this Texture from.
|
|
11563
|
+
*
|
|
11564
|
+
* Sets {@link Texture#image} null.
|
|
11565
|
+
*
|
|
11566
|
+
* @type {String}
|
|
11567
|
+
*/,set:function set(value){this._image=ensureImageSizePowerOfTwo$1(value);this._image.crossOrigin="Anonymous";this._state.texture.setImage(this._image,this._state);this._src=null;this.glRedraw();}},{key:"src",get:/**
|
|
11568
|
+
* Gets path to the image file this Texture from, if any.
|
|
11569
|
+
*
|
|
11570
|
+
* Returns null if not set.
|
|
11571
|
+
*
|
|
11572
|
+
* @type {String}
|
|
11573
|
+
*/function get(){return this._src;}/**
|
|
11574
|
+
* Sets the 2D translation vector added to this Texture's *S* and *T* UV coordinates.
|
|
11575
|
+
*
|
|
11576
|
+
* Default value is ````[0, 0]````.
|
|
11577
|
+
*
|
|
11578
|
+
* @type {Number[]}
|
|
11579
|
+
*/,set:function set(src){this.scene.loading++;this.scene.canvas.spinner.processes++;var self=this;var image=new Image();image.onload=function(){image=ensureImageSizePowerOfTwo$1(image);self._state.texture.setImage(image,self._state);self.scene.loading--;self.glRedraw();self.scene.canvas.spinner.processes--;};image.src=src;this._src=src;this._image=null;}},{key:"translate",get:/**
|
|
11580
|
+
* Gets the 2D translation vector added to this Texture's *S* and *T* UV coordinates.
|
|
11581
|
+
*
|
|
11582
|
+
* Default value is ````[0, 0]````.
|
|
11583
|
+
*
|
|
11584
|
+
* @type {Number[]}
|
|
11585
|
+
*/function get(){return this._translate;}/**
|
|
11586
|
+
* Sets the 2D scaling vector that will be applied to this Texture's *S* and *T* UV coordinates.
|
|
11587
|
+
*
|
|
11588
|
+
* Default value is ````[1, 1]````.
|
|
11589
|
+
*
|
|
11590
|
+
* @type {Number[]}
|
|
11591
|
+
*/,set:function set(value){this._translate.set(value||[0,0]);this._matrixDirty=true;this._needUpdate();}},{key:"scale",get:/**
|
|
11592
|
+
* Gets the 2D scaling vector that will be applied to this Texture's *S* and *T* UV coordinates.
|
|
11593
|
+
*
|
|
11594
|
+
* Default value is ````[1, 1]````.
|
|
11595
|
+
*
|
|
11596
|
+
* @type {Number[]}
|
|
11597
|
+
*/function get(){return this._scale;}/**
|
|
11598
|
+
* Sets the rotation angles, in degrees, that will be applied to this Texture's *S* and *T* UV coordinates.
|
|
11599
|
+
*
|
|
11600
|
+
* Default value is ````0````.
|
|
11601
|
+
*
|
|
11602
|
+
* @type {Number}
|
|
11603
|
+
*/,set:function set(value){this._scale.set(value||[1,1]);this._matrixDirty=true;this._needUpdate();}},{key:"rotate",get:/**
|
|
11604
|
+
* Gets the rotation angles, in degrees, that will be applied to this Texture's *S* and *T* UV coordinates.
|
|
11605
|
+
*
|
|
11606
|
+
* Default value is ````0````.
|
|
11607
|
+
*
|
|
11608
|
+
* @type {Number}
|
|
11609
|
+
*/function get(){return this._rotate;}/**
|
|
11610
|
+
* Gets how this Texture is sampled when a texel covers less than one pixel.
|
|
11611
|
+
*
|
|
11612
|
+
* Options are:
|
|
11613
|
+
*
|
|
11614
|
+
* * NearestFilter - Uses the value of the texture element that is nearest
|
|
11615
|
+
* (in Manhattan distance) to the center of the pixel being textured.
|
|
11616
|
+
*
|
|
11617
|
+
* * LinearFilter - Uses the weighted average of the four texture elements that are
|
|
11618
|
+
* closest to the center of the pixel being textured.
|
|
11619
|
+
*
|
|
11620
|
+
* * NearestMipMapNearestFilter - Chooses the mipmap that most closely matches the
|
|
11621
|
+
* size of the pixel being textured and uses the "nearest" criterion (the texture
|
|
11622
|
+
* element nearest to the center of the pixel) to produce a texture value.
|
|
11623
|
+
*
|
|
11624
|
+
* * LinearMipMapNearestFilter - Chooses the mipmap that most closely matches the size of
|
|
11625
|
+
* the pixel being textured and uses the "linear" criterion (a weighted average of the
|
|
11626
|
+
* four texture elements that are closest to the center of the pixel) to produce a
|
|
11627
|
+
* texture value.
|
|
11628
|
+
*
|
|
11629
|
+
* * NearestMipMapLinearFilter - Chooses the two mipmaps that most closely
|
|
11630
|
+
* match the size of the pixel being textured and uses the "nearest" criterion
|
|
11631
|
+
* (the texture element nearest to the center of the pixel) to produce a texture
|
|
11632
|
+
* value from each mipmap. The final texture value is a weighted average of those two
|
|
11633
|
+
* values.
|
|
11634
|
+
*
|
|
11635
|
+
* * LinearMipMapLinearFilter - (default) - Chooses the two mipmaps that most closely match the size
|
|
11636
|
+
* of the pixel being textured and uses the "linear" criterion (a weighted average
|
|
11637
|
+
* of the four texture elements that are closest to the center of the pixel) to
|
|
11638
|
+
* produce a texture value from each mipmap. The final texture value is a weighted
|
|
11639
|
+
* average of those two values.
|
|
11640
|
+
*
|
|
11641
|
+
* Default value is LinearMipMapLinearFilter.
|
|
11642
|
+
*
|
|
11643
|
+
* @type {Number}
|
|
11644
|
+
*/,set:function set(value){value=value||0;if(this._rotate===value){return;}this._rotate=value;this._matrixDirty=true;this._needUpdate();}},{key:"minFilter",get:function get(){return this._state.minFilter;}/**
|
|
11645
|
+
* Gets how this Texture is sampled when a texel covers more than one pixel.
|
|
11646
|
+
*
|
|
11647
|
+
* * NearestFilter - Uses the value of the texture element that is nearest
|
|
11648
|
+
* (in Manhattan distance) to the center of the pixel being textured.
|
|
11649
|
+
* * LinearFilter - (default) - Uses the weighted average of the four texture elements that are
|
|
11650
|
+
* closest to the center of the pixel being textured.
|
|
11651
|
+
*
|
|
11652
|
+
* Default value is LinearMipMapLinearFilter.
|
|
11653
|
+
*
|
|
11654
|
+
* @type {Number}
|
|
11655
|
+
*/},{key:"magFilter",get:function get(){return this._state.magFilter;}/**
|
|
11656
|
+
* Gets the wrap parameter for this Texture's *S* coordinate.
|
|
11657
|
+
*
|
|
11658
|
+
* Values can be:
|
|
11659
|
+
*
|
|
11660
|
+
* * ClampToEdgeWrapping - causes *S* coordinates to be clamped to the size of the texture.
|
|
11661
|
+
* * MirroredRepeatWrapping - causes the *S* coordinate to be set to the fractional part of the texture coordinate
|
|
11662
|
+
* if the integer part of *S* is even; if the integer part of *S* is odd, then the *S* texture coordinate is
|
|
11663
|
+
* set to *1 - frac S* , where *frac S* represents the fractional part of *S*.
|
|
11664
|
+
* * RepeatWrapping - (default) - causes the integer part of the *S* coordinate to be ignored; xeokit uses only the
|
|
11665
|
+
* fractional part, thereby creating a repeating pattern.
|
|
11666
|
+
*
|
|
11667
|
+
* Default value is RepeatWrapping.
|
|
11668
|
+
*
|
|
11669
|
+
* @type {Number}
|
|
11670
|
+
*/},{key:"wrapS",get:function get(){return this._state.wrapS;}/**
|
|
11671
|
+
* Gets the wrap parameter for this Texture's *T* coordinate.
|
|
11672
|
+
*
|
|
11673
|
+
* Values can be:
|
|
11674
|
+
*
|
|
11675
|
+
* * ClampToEdgeWrapping - causes *S* coordinates to be clamped to the size of the texture.
|
|
11676
|
+
* * MirroredRepeatWrapping - causes the *S* coordinate to be set to the fractional part of the texture coordinate
|
|
11677
|
+
* if the integer part of *S* is even; if the integer part of *S* is odd, then the *S* texture coordinate is
|
|
11678
|
+
* set to *1 - frac S* , where *frac S* represents the fractional part of *S*.
|
|
11679
|
+
* * RepeatWrapping - (default) - causes the integer part of the *S* coordinate to be ignored; xeokit uses only the
|
|
11680
|
+
* fractional part, thereby creating a repeating pattern.
|
|
11681
|
+
*
|
|
11682
|
+
* Default value is RepeatWrapping.
|
|
11683
|
+
*
|
|
11684
|
+
* @type {Number}
|
|
11685
|
+
*/},{key:"wrapT",get:function get(){return this._state.wrapT;}/**
|
|
11686
|
+
* Gets if this Texture's source data is flipped along its vertical axis.
|
|
11687
|
+
*
|
|
11688
|
+
* @type {Number}
|
|
11689
|
+
*/},{key:"flipY",get:function get(){return this._state.flipY;}/**
|
|
11690
|
+
* Gets the Texture's encoding format.
|
|
11691
|
+
*
|
|
11692
|
+
* @type {Number}
|
|
11693
|
+
*/},{key:"encoding",get:function get(){return this._state.encoding;}/**
|
|
11694
|
+
* Destroys this Texture
|
|
11689
11695
|
*/},{key:"destroy",value:function destroy(){_superPropGet(Texture,"destroy",this,3)([]);if(this._state.texture){this._state.texture.destroy();}this._state.destroy();stats.memory.textures--;}}]);}(Component);/**
|
|
11690
11696
|
* @desc Creates a cylinder-shaped {@link Geometry}.
|
|
11691
11697
|
*
|
|
@@ -13353,7 +13359,7 @@ this.setVisible(cfg.overviewVisible);}/** Called by SectionPlanesPlugin#createSe
|
|
|
13353
13359
|
* @param {String} [cfg.id="SectionPlanes"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
|
|
13354
13360
|
* @param {String} [cfg.overviewCanvasId] ID of a canvas element to display the overview.
|
|
13355
13361
|
* @param {String} [cfg.overviewVisible=true] Initial visibility of the overview canvas.
|
|
13356
|
-
*/function SectionPlanesPlugin(viewer){var _this73;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,SectionPlanesPlugin);_this73=_callSuper(this,SectionPlanesPlugin,["SectionPlanes",viewer]);_this73._freeControls=[];_this73._sectionPlanes=viewer.scene.sectionPlanes;_this73._controls={};_this73._currentControl=null;_this73._shownControlId=null;if(cfg.overviewCanvasId!==null&&cfg.overviewCanvasId!==undefined){var overviewCanvas=document.getElementById(cfg.overviewCanvasId);if(!overviewCanvas){_this73.warn("Can't find overview canvas: '"+cfg.overviewCanvasId+"' - will create plugin without overview");}else{_this73._overview=new Overview(_this73,{overviewCanvas:overviewCanvas,visible:cfg.overviewVisible,onHoverEnterPlane:function onHoverEnterPlane(id){_this73._overview.setPlaneHighlighted(id,true);},onHoverLeavePlane:function onHoverLeavePlane(id){_this73._overview.setPlaneHighlighted(id,false);},onClickedPlane:function onClickedPlane(id){if(_this73.getShownControl()===id){_this73.hideControl();return;}_this73.showControl(id);var sectionPlane=_this73.sectionPlanes[id];var sectionPlanePos=sectionPlane.pos;tempAABB$1.set(_this73.viewer.scene.aabb);math.getAABB3Center(tempAABB$1,tempVec3$3);tempAABB$1[0]+=sectionPlanePos[0]-tempVec3$3[0];tempAABB$1[1]+=sectionPlanePos[1]-tempVec3$3[1];tempAABB$1[2]+=sectionPlanePos[2]-tempVec3$3[2];tempAABB$1[3]+=sectionPlanePos[0]-tempVec3$3[0];tempAABB$1[4]+=sectionPlanePos[1]-tempVec3$3[1];tempAABB$1[5]+=sectionPlanePos[2]-tempVec3$3[2];_this73.viewer.cameraFlight.flyTo({aabb:tempAABB$1,fitFOV:65});},onClickedNothing:function onClickedNothing(){_this73.hideControl();}});}}_this73._onSceneSectionPlaneCreated=viewer.scene.on("sectionPlaneCreated",function(sectionPlane){// SectionPlane created, either via SectionPlanesPlugin#createSectionPlane(), or by directly
|
|
13362
|
+
*/function SectionPlanesPlugin(viewer){var _this73;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,SectionPlanesPlugin);_this73=_callSuper(this,SectionPlanesPlugin,["SectionPlanes",viewer]);_this73._freeControls=[];_this73._sectionPlanes=viewer.scene.sectionPlanes;_this73._controls={};_this73._currentControl=null;_this73._shownControlId=null;_this73._shownControlIds=[];if(cfg.overviewCanvasId!==null&&cfg.overviewCanvasId!==undefined){var overviewCanvas=document.getElementById(cfg.overviewCanvasId);if(!overviewCanvas){_this73.warn("Can't find overview canvas: '"+cfg.overviewCanvasId+"' - will create plugin without overview");}else{_this73._overview=new Overview(_this73,{overviewCanvas:overviewCanvas,visible:cfg.overviewVisible,onHoverEnterPlane:function onHoverEnterPlane(id){_this73._overview.setPlaneHighlighted(id,true);},onHoverLeavePlane:function onHoverLeavePlane(id){_this73._overview.setPlaneHighlighted(id,false);},onClickedPlane:function onClickedPlane(id){if(_this73.getShownControl()===id){_this73.hideControl();return;}_this73.showControl(id);var sectionPlane=_this73.sectionPlanes[id];var sectionPlanePos=sectionPlane.pos;tempAABB$1.set(_this73.viewer.scene.aabb);math.getAABB3Center(tempAABB$1,tempVec3$3);tempAABB$1[0]+=sectionPlanePos[0]-tempVec3$3[0];tempAABB$1[1]+=sectionPlanePos[1]-tempVec3$3[1];tempAABB$1[2]+=sectionPlanePos[2]-tempVec3$3[2];tempAABB$1[3]+=sectionPlanePos[0]-tempVec3$3[0];tempAABB$1[4]+=sectionPlanePos[1]-tempVec3$3[1];tempAABB$1[5]+=sectionPlanePos[2]-tempVec3$3[2];_this73.viewer.cameraFlight.flyTo({aabb:tempAABB$1,fitFOV:65});},onClickedNothing:function onClickedNothing(){_this73.hideControl();}});}}_this73._onSceneSectionPlaneCreated=viewer.scene.on("sectionPlaneCreated",function(sectionPlane){// SectionPlane created, either via SectionPlanesPlugin#createSectionPlane(), or by directly
|
|
13357
13363
|
// instantiating a SectionPlane independently of SectionPlanesPlugin, which can be done
|
|
13358
13364
|
// by BCFViewpointsPlugin#loadViewpoint().
|
|
13359
13365
|
_this73._sectionPlaneCreated(sectionPlane);});_this73._onSceneSectionBoxCreated=viewer.scene.on("sectionBoxCreated",function(sectionBox){_this73._sectionBoxCreated(sectionBox);});return _this73;}/**
|
|
@@ -13382,7 +13388,7 @@ _this73._sectionPlaneCreated(sectionPlane);});_this73._onSceneSectionBoxCreated=
|
|
|
13382
13388
|
*/},{key:"createSectionPlane",value:function createSectionPlane(){var params=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(params.id!==undefined&¶ms.id!==null&&this.viewer.scene.components[params.id]){this.error("Viewer component with this ID already exists: "+params.id);delete params.id;}// Note that SectionPlane constructor fires "sectionPlaneCreated" on the Scene,
|
|
13383
13389
|
// which SectionPlanesPlugin handles and calls #_sectionPlaneCreated to create gizmo and add to overview canvas.
|
|
13384
13390
|
var sectionPlane=new SectionPlane(this.viewer.scene,{id:params.id,pos:params.pos,dir:params.dir,active:true});return sectionPlane;}//剖切面创建后,创建一个控制器
|
|
13385
|
-
},{key:"_sectionPlaneCreated",value:function _sectionPlaneCreated(sectionPlane){var _this74=this;var newControl;switch(this._sectionWay){case"plane":newControl=new ClippingPlane(this,this._controlsConfig);break;default:newControl=new Control$1(this);break;}var control=this._freeControls.length>0?this._freeControls.pop():newControl;control._setSectionPlane(sectionPlane);control.setVisible(true);this._currentControl=control;this._controls[sectionPlane.id]=control;if(this._overview){this._overview.addSectionPlane(sectionPlane);}sectionPlane.once("destroyed",function(){_this74._sectionPlaneDestroyed(sectionPlane);});}//剖切盒创建后,创建一个控制器
|
|
13391
|
+
},{key:"_sectionPlaneCreated",value:function _sectionPlaneCreated(sectionPlane){var _this74=this;var newControl;switch(this._sectionWay){case"plane":newControl=new ClippingPlane(this,this._controlsConfig);break;default:newControl=new Control$1(this);break;}var control=this._freeControls.length>0?this._freeControls.pop():newControl;control._setSectionPlane(sectionPlane);control.setVisible(true);sectionPlane.control=control;this._currentControl=control;this._controls[sectionPlane.id]=control;if(this._overview){this._overview.addSectionPlane(sectionPlane);}sectionPlane.once("destroyed",function(){_this74._sectionPlaneDestroyed(sectionPlane);});}//剖切盒创建后,创建一个控制器
|
|
13386
13392
|
},{key:"_sectionBoxCreated",value:function _sectionBoxCreated(sectionBox){var _this75=this;var newControl;newControl=new ClippingBox(this,this._controlsConfig);var control=this._freeControls.length>0?this._freeControls.pop():newControl;control._setSectionBox(sectionBox);control.setVisible(true);this._currentControl=control;this._controls[sectionBox.id]=control;if(this._overview){this._overview.setSectionBox(sectionBox);}sectionBox.once("destroyed",function(){_this75._sectionPlaneDestroyed(sectionBox);});}/**
|
|
13387
13393
|
* 设置是否是触屏模式
|
|
13388
13394
|
* @param {boolean} touch
|
|
@@ -13415,7 +13421,7 @@ var sectionPlane=new SectionPlane(this.viewer.scene,{id:params.id,pos:params.pos
|
|
|
13415
13421
|
* Shows the 3D editing gizmo for a {@link SectionPlane}.
|
|
13416
13422
|
*
|
|
13417
13423
|
* @param {String} id ID of the {@link SectionPlane}.
|
|
13418
|
-
*/},{key:"showControl",value:function showControl(id){var control=this._controls[id];if(!control){this.error("Control not found: "+id);return;}
|
|
13424
|
+
*/},{key:"showControl",value:function showControl(id){var control=this._controls[id];if(!control){this.error("Control not found: "+id);return;}control.setVisible(true);if(this._overview){this._overview.setPlaneSelected(id,true);}this._shownControlId=id;this._shownControlIds=[id];}/**
|
|
13419
13425
|
* 设置剖切对象的尺寸
|
|
13420
13426
|
* @param {*} size
|
|
13421
13427
|
*/},{key:"setControlsSize",value:function setControlsSize(size){for(var id in this._controls){this._controls[id].controlSize=size;}}/**
|
|
@@ -13429,13 +13435,13 @@ var sectionPlane=new SectionPlane(this.viewer.scene,{id:params.id,pos:params.pos
|
|
|
13429
13435
|
* Returns ````null```` when the editing gizmo is not shown.
|
|
13430
13436
|
*
|
|
13431
13437
|
* @returns {String} ID of the the {@link SectionPlane} that the 3D editing gizmo is shown for, if shown, else ````null````.
|
|
13432
|
-
*/},{key:"getShownControl",value:function getShownControl(){return this._shownControlId;}/**
|
|
13438
|
+
*/},{key:"getShownControl",value:function getShownControl(){return this._shownControlId;}},{key:"getShownControls",value:function getShownControls(){return this._shownControlIds;}},{key:"showAllControl",value:function showAllControl(){for(var id in this._controls){if(this._controls.hasOwnProperty(id)){this._shownControlIds.push(id);this._controls[id].setVisible(false);if(this._overview){this._overview.setPlaneSelected(id,false);}}}}/**
|
|
13433
13439
|
* Hides the 3D {@link SectionPlane} editing gizmo if shown.
|
|
13434
|
-
*/},{key:"hideControl",value:function hideControl(){for(var id in this._controls){if(this._controls.hasOwnProperty(id)){this._controls[id].setVisible(false);if(this._overview){this._overview.setPlaneSelected(id,false);}}}this._shownControlId=null;}/**
|
|
13440
|
+
*/},{key:"hideControl",value:function hideControl(){for(var id in this._controls){if(this._controls.hasOwnProperty(id)){this._controls[id].setVisible(false);if(this._overview){this._overview.setPlaneSelected(id,false);}}}this._shownControlId=null;this._shownControlIds=[];}/**
|
|
13435
13441
|
* Destroys a {@link SectionPlane} created by this SectionPlanesPlugin.
|
|
13436
13442
|
*
|
|
13437
13443
|
* @param {String} id ID of the {@link SectionPlane}.
|
|
13438
|
-
*/},{key:"destroySectionPlane",value:function destroySectionPlane(id){var sectionPlane=this.viewer.scene.sectionPlanes[id];if(!sectionPlane){this.error("SectionPlane not found: "+id);return;}this._sectionPlaneDestroyed(sectionPlane);sectionPlane.destroy();if(id===this._shownControlId){this._shownControlId=null;}}},{key:"_sectionPlaneDestroyed",value:function _sectionPlaneDestroyed(sectionPlane){if(this._overview){this._overview.removeSectionPlane(sectionPlane);}var control=this._controls[sectionPlane.id];if(!control){return;}control.setVisible(false);control._setSectionPlane(null);delete this._controls[sectionPlane.id];this._freeControls.push(control);}/**
|
|
13444
|
+
*/},{key:"destroySectionPlane",value:function destroySectionPlane(id){var sectionPlane=this.viewer.scene.sectionPlanes[id];if(!sectionPlane){this.error("SectionPlane not found: "+id);return;}this._sectionPlaneDestroyed(sectionPlane);sectionPlane.destroy();if(id===this._shownControlId){this._shownControlId=null;this._shownControlIds=[];}}},{key:"_sectionPlaneDestroyed",value:function _sectionPlaneDestroyed(sectionPlane){if(this._overview){this._overview.removeSectionPlane(sectionPlane);}var control=this._controls[sectionPlane.id];if(!control){return;}control.setVisible(false);control._setSectionPlane(null);delete this._controls[sectionPlane.id];this._freeControls.push(control);}/**
|
|
13439
13445
|
* Destroys all {@link SectionPlane}s created by this SectionPlanesPlugin.
|
|
13440
13446
|
*/},{key:"clear",value:function clear(){var ids=Object.keys(this._sectionPlanes);for(var i=0,len=ids.length;i<len;i++){this.destroySectionPlane(ids[i]);}}/**
|
|
13441
13447
|
* @private
|
|
@@ -14030,7 +14036,7 @@ primitive:"triangles",positions:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,// v0-v1-v2-v3 fron
|
|
|
14030
14036
|
-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,// v7-v4-v3-v2 bottom
|
|
14031
14037
|
1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1// v4-v7-v6-v5 back
|
|
14032
14038
|
],uv:[0.5,0.6666,0.25,0.6666,0.25,0.3333,0.5,0.3333,0.5,0.6666,0.5,0.3333,0.75,0.3333,0.75,0.6666,0.5,0.6666,0.5,1,0.25,1,0.25,0.6666,0.25,0.6666,0.0,0.6666,0.0,0.3333,0.25,0.3333,0.25,0,0.5,0,0.5,0.3333,0.25,0.3333,0.75,0.3333,1.0,0.3333,1.0,0.6666,0.75,0.6666],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}),background:true,scale:[2000,2000,2000],// Overridden when we initialize the 'size' property, below
|
|
14033
|
-
rotation:[0,-90,0],material:new PhongMaterial(_this78,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Texture(_this78,{scale:cfg.scale,src:cfg.src,flipY:true,wrapS:1000,wrapT:1000,encoding:cfg.encoding||"sRGB"}),backfaces:true// Show interior faces of our skybox geometry
|
|
14039
|
+
rotation:[0,-90,0],material:new PhongMaterial(_this78,{ambient:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],emissive:[1,1,1],emissiveMap:new Texture(_this78,{scale:cfg.scale,src:cfg.src,image:cfg.image,flipY:true,wrapS:1000,wrapT:1000,encoding:cfg.encoding||"sRGB"}),backfaces:true// Show interior faces of our skybox geometry
|
|
14034
14040
|
}),// stationary: true,
|
|
14035
14041
|
visible:false,pickable:false,clippable:false,collidable:false});_this78.size=cfg.size;// Sets 'xyz' property on the Mesh's Scale transform
|
|
14036
14042
|
_this78.active=cfg.active;return _this78;}/**
|
|
@@ -14120,18 +14126,18 @@ _this78.active=cfg.active;return _this78;}/**
|
|
|
14120
14126
|
@param {Object} params Skybox configuration.
|
|
14121
14127
|
@param {Boolean} [params.active=true] Whether the skybox plane is initially active. Only skyboxes while this is true.
|
|
14122
14128
|
@returns {Skybox} The new skybox.
|
|
14123
|
-
*/},{key:"createSkybox",value:function createSkybox(id,params){if(this.viewer.scene.components[id]){this.error("Component with this ID already exists: "+id);return this;}var skybox=new Skybox(this.viewer.scene,{id:id,size:params.size,scale:params.scale,src:params.src,active:params.active,encoding:3000});this.skyboxes[id]=skybox;return skybox;}},{key:"setSkyBoxActiveById",value:function setSkyBoxActiveById(id,active){this.skyboxes[id].active=active;}/**
|
|
14129
|
+
*/},{key:"createSkybox",value:function createSkybox(id,params){if(this.viewer.scene.components[id]){this.error("Component with this ID already exists: "+id);return this;}if(!params.src&&!params.image){this.error("No legal skybox image or src: "+id);return this;}if(params.src){var skybox=new Skybox(this.viewer.scene,{id:id,size:params.size,scale:params.scale,src:params.src,active:params.active,encoding:3000});this.skyboxes[id]=skybox;return skybox;}else if(params.image){var skybox=new Skybox(this.viewer.scene,{id:id,size:params.size,scale:params.scale,image:params.image,active:params.active,encoding:3000});this.skyboxes[id]=skybox;return skybox;}}},{key:"setSkyBoxActiveById",value:function setSkyBoxActiveById(id,active){this.skyboxes[id].active=active;}/**
|
|
14124
14130
|
* 设置开启天空盒
|
|
14125
14131
|
*/},{key:"active",get:function get(){return this._active;},set:function set(active){this._active=active;for(var _i158=0;_i158<this.skyboxes.length;_i158++)this.skyboxes[_i158].active=active;}},{key:"getSkyBoxById",value:function getSkyBoxById(id){return this.skyboxes[id];}/**
|
|
14126
14132
|
Destroys a skybox.
|
|
14127
14133
|
@param id
|
|
14128
14134
|
*/},{key:"destroySkybox",value:function destroySkybox(id){var skybox=this.skyboxes[id];if(!skybox){this.error("Skybox not found: "+id);return;}skybox.destroy();}/**
|
|
14129
14135
|
Destroys all skyboxes.
|
|
14130
|
-
*/},{key:"clear",value:function clear(){var ids=Object.keys(this.
|
|
14136
|
+
*/},{key:"clear",value:function clear(){var ids=Object.keys(this.skyboxes);for(var i=0,len=ids.length;i<len;i++){this.destroySkybox(ids[i]);}}/**
|
|
14131
14137
|
* Destroys this plugin.
|
|
14132
14138
|
*
|
|
14133
14139
|
* Clears skyboxes from the Viewer first.
|
|
14134
|
-
*/},{key:"destroy",value:function destroy(){this.clear();
|
|
14140
|
+
*/},{key:"destroy",value:function destroy(){this.clear();}}]);}(Plugin);var treeViews=[];/**
|
|
14135
14141
|
* @desc A {@link Viewer} plugin that provides an HTML tree view to navigate the IFC elements in models.
|
|
14136
14142
|
* <br>
|
|
14137
14143
|
*
|
|
@@ -24490,7 +24496,8 @@ mouseDownLeft=false;mouseDownMiddle=false;mouseDownRight=false;break;}});this.ca
|
|
|
24490
24496
|
getCanvasPosFromEvent$3(e,canvasPos);var x=canvasPos[0];var y=canvasPos[1];if(Math.abs(x-lastXDown)<3&&Math.abs(y-lastYDown)<3){controllers.cameraControl.fire("rightClick",{// For context menus
|
|
24491
24497
|
pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:canvasPos,event:e},true);}break;}_this123.canvas.style.removeProperty("cursor");});this.canvas.addEventListener("mouseenter",this._mouseEnterHandler=function(){if(!(configs.active&&configs.pointerEnabled)){return;}});var maxElapsed=1/20;var minElapsed=1/60;var secsNowLast=null;var enableMove=true;this._scene.on("collideWithEntity",function(collideWithEntity){enableMove=!collideWithEntity;});this.canvas.addEventListener("wheel",this._mouseWheelHandler=function(e){e.preventDefault();if(!(configs.active&&configs.pointerEnabled)){return;}if(e.deltaY<0&&!enableMove)return;var secsNow=performance.now()/1000.0;var secsElapsed=secsNowLast!==null?secsNow-secsNowLast:0;secsNowLast=secsNow;if(secsElapsed>maxElapsed){secsElapsed=maxElapsed;}if(secsElapsed<minElapsed){secsElapsed=minElapsed;}var delta=Math.max(-1,Math.min(1,-e.deltaY*40));if(delta===0){return;}var normalizedDelta=delta/Math.abs(delta);updates.dollyDelta+=-normalizedDelta*secsElapsed*configs.mouseWheelDollyRate;if(mouseMovedOnCanvasSinceLastWheel){states.followPointerDirty=true;mouseMovedOnCanvasSinceLastWheel=false;}});}return _createClass(MousePanRotateDollyHandler,[{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){if(this.canvas!=null){this.canvas.removeEventListener("mousedown",this._mouseDownHandler);this.canvas.removeEventListener("mousemove",this._canvasMouseMoveHandler);this.canvas.removeEventListener("mouseup",this._mouseUpHandler);this.canvas.removeEventListener("mouseenter",this._mouseEnterHandler);this.canvas.removeEventListener("wheel",this._mouseWheelHandler);}document.removeEventListener("keydown",this._documentKeyDownHandler);document.removeEventListener("keyup",this._documentKeyUpHandler);document.removeEventListener("mousemove",this._documentMouseMoveHandler);document.removeEventListener("mouseup",this._documentMouseUpHandler);}}]);}();var center=math.vec3();var tempVec3a=math.vec3();var tempVec3b=math.vec3();var tempVec3c=math.vec3();var tempVec3d=math.vec3();var tempCameraTarget={eye:math.vec3(),look:math.vec3(),up:math.vec3()};/**
|
|
24492
24498
|
* @private
|
|
24493
|
-
*/var KeyboardAxisViewHandler=/*#__PURE__*/function(){function KeyboardAxisViewHandler(scene,controllers,configs,states){_classCallCheck(this,KeyboardAxisViewHandler);this._scene=scene;this.input=scene.input;var cameraControl=controllers.cameraControl;var camera=scene.camera;this._onSceneKeyDown=scene.input.on("keydown",function(){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}var axisViewRight=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_RIGHT);var axisViewBack=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BACK);var axisViewLeft=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_LEFT);var axisViewFront=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_FRONT);var axisViewTop=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_TOP);var axisViewBottom=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BOTTOM);if(!axisViewRight&&!axisViewBack&&!axisViewLeft&&!axisViewFront&&!axisViewTop&&!axisViewBottom){return;}var aabb=scene.aabb;var diag=math.getAABB3Diag(aabb);math.getAABB3Center(aabb,center);var perspectiveDist=Math.abs(diag/Math.tan(controllers.cameraFlight.fitFOV*math.DEGTORAD));var orthoScale=diag*1.1;tempCameraTarget.orthoScale=orthoScale
|
|
24499
|
+
*/var KeyboardAxisViewHandler=/*#__PURE__*/function(){function KeyboardAxisViewHandler(scene,controllers,configs,states){_classCallCheck(this,KeyboardAxisViewHandler);this._scene=scene;this.input=scene.input;var cameraControl=controllers.cameraControl;var camera=scene.camera;this._onSceneKeyDown=scene.input.on("keydown",function(){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}var axisViewRight=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_RIGHT);var axisViewBack=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BACK);var axisViewLeft=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_LEFT);var axisViewFront=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_FRONT);var axisViewTop=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_TOP);var axisViewBottom=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BOTTOM);if(!axisViewRight&&!axisViewBack&&!axisViewLeft&&!axisViewFront&&!axisViewTop&&!axisViewBottom){return;}var aabb=scene.aabb;var diag=math.getAABB3Diag(aabb);math.getAABB3Center(aabb,center);var perspectiveDist=Math.abs(diag/Math.tan(controllers.cameraFlight.fitFOV*math.DEGTORAD));var orthoScale=diag*1.1;tempCameraTarget.orthoScale=orthoScale;// 点击键盘切换相机方向
|
|
24500
|
+
if(axisViewRight){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldRight,perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(camera.worldUp);}else if(axisViewBack){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldForward,perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(camera.worldUp);}else if(axisViewLeft){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldRight,-perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(camera.worldUp);}else if(axisViewFront){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldForward,-perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(camera.worldUp);}else if(axisViewTop){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldUp,perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward,1,tempVec3b),tempVec3c));}else if(axisViewBottom){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldUp,-perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward,-1,tempVec3b)));}if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.setPivotPos(center);}if(controllers.cameraFlight.duration>0){controllers.cameraFlight.flyTo(tempCameraTarget,function(){if(controllers.pivotController.getPivoting()&&configs.followPointer){controllers.pivotController.showPivot();}});}else{controllers.cameraFlight.jumpTo(tempCameraTarget);if(controllers.pivotController.getPivoting()&&configs.followPointer){controllers.pivotController.showPivot();}}});}return _createClass(KeyboardAxisViewHandler,[{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){this.input.off(this._onSceneKeyDown);}}]);}();/**
|
|
24494
24501
|
* @private
|
|
24495
24502
|
*/var MousePickHandler=/*#__PURE__*/function(){function MousePickHandler(scene,controllers,configs,states,updates){var _this124=this;_classCallCheck(this,MousePickHandler);this._scene=scene;var pickController=controllers.pickController;var pivotController=controllers.pivotController;var cameraControl=controllers.cameraControl;this._clicks=0;this._timeout=null;this._lastPickedEntityId=null;var leftDown=false;var rightDown=false;this.canvas=this._scene.canvas.canvas;var tickifiedMouseMoveFn=scene.tickify(this._canvasMouseMoveHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}if(leftDown||rightDown){return;}var hoverSubs=cameraControl.hasSubs("hover");var hoverEnterSubs=cameraControl.hasSubs("hoverEnter");var hoverOutSubs=cameraControl.hasSubs("hoverOut");var hoverOffSubs=cameraControl.hasSubs("hoverOff");var hoverSurfaceSubs=cameraControl.hasSubs("hoverSurface");var hoverSnapOrSurfaceSubs=cameraControl.hasSubs("hoverSnapOrSurface");if(hoverSubs||hoverEnterSubs||hoverOutSubs||hoverOffSubs||hoverSurfaceSubs||hoverSnapOrSurfaceSubs){pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePickEntity=true;pickController.schedulePickSurface=hoverSurfaceSubs;pickController.scheduleSnapOrPick=hoverSnapOrSurfaceSubs;pickController.update();if(pickController.pickResult){if(pickController.pickResult.entity){var pickedEntityId=pickController.pickResult.entity.id;if(_this124._lastPickedEntityId!==pickedEntityId){if(_this124._lastPickedEntityId!==undefined){cameraControl.fire("hoverOut",{// Hovered off an entity
|
|
24496
24503
|
entity:scene.objects[_this124._lastPickedEntityId]},true);}cameraControl.fire("hoverEnter",pickController.pickResult,true);// Hovering over a new entity
|
|
@@ -24555,14 +24562,18 @@ pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePick
|
|
|
24555
24562
|
// }
|
|
24556
24563
|
},false);}return _createClass(MousePickHandler,[{key:"reset",value:function reset(){this._clicks=0;this._lastPickedEntityId=null;if(this._timeout){window.clearTimeout(this._timeout);this._timeout=null;}}},{key:"destroy",value:function destroy(){if(this.canvas!=null){this.canvas.removeEventListener("mousemove",this._canvasMouseMoveHandler);this.canvas.removeEventListener("mousedown",this._canvasMouseDownHandler);this.canvas.removeEventListener("dblclick",this._canvasDblClickHandler);this.canvas.removeEventListener("mouseup",this._canvasMouseUpHandler);}document.removeEventListener("mouseup",this._documentMouseUpHandler);if(this._timeout){window.clearTimeout(this._timeout);this._timeout=null;}}}]);}();/**
|
|
24557
24564
|
* @private
|
|
24558
|
-
*/var KeyboardPanRotateDollyHandler=/*#__PURE__*/function(){function KeyboardPanRotateDollyHandler(scene,controllers,configs,states,updates){_classCallCheck(this,KeyboardPanRotateDollyHandler);this._scene=scene;this._updates=updates;var input=scene.input;this.input=input;var keyDownMap=[];var canvas=scene.canvas.canvas;var mouseMovedSinceLastKeyboardDolly=true;this._onSceneMouseMove=input.on("mousemove",function(){mouseMovedSinceLastKeyboardDolly=true;});this._onSceneKeyDown=input.on("keydown",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}keyDownMap[keyCode]=true;if(keyCode===input.KEY_SHIFT){canvas.style.cursor="move";}});this._onSceneKeyUp=input.on("keyup",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}keyDownMap[keyCode]=false;if(keyCode===input.KEY_SHIFT){canvas.style.cursor=null;}if(controllers.pivotController.getPivoting()){controllers.pivotController.endPivot();}
|
|
24565
|
+
*/var KeyboardPanRotateDollyHandler=/*#__PURE__*/function(){function KeyboardPanRotateDollyHandler(scene,controllers,configs,states,updates,moveRate){var _this125=this;_classCallCheck(this,KeyboardPanRotateDollyHandler);this._scene=scene;this._updates=updates;var input=scene.input;this.input=input;var keyDownMap=[];this._movespeed=moveRate?moveRate:1;var canvas=scene.canvas.canvas;var enableSetSpeedUp=false;var enableSetSpeedDown=false;var mouseMovedSinceLastKeyboardDolly=true;this._onSceneMouseMove=input.on("mousemove",function(){mouseMovedSinceLastKeyboardDolly=true;});this._onSceneKeyDown=input.on("keydown",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}keyDownMap[keyCode]=true;if(keyCode===input.KEY_SHIFT){canvas.style.cursor="move";}if(keyCode===input.KEY_ADD){enableSetSpeedUp=true;}if(keyCode===input.KEY_SUBTRACT){enableSetSpeedDown=true;}});this._onSceneKeyUp=input.on("keyup",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}keyDownMap[keyCode]=false;if(keyCode===input.KEY_SHIFT){canvas.style.cursor=null;}if(controllers.pivotController.getPivoting()){controllers.pivotController.endPivot();}if(keyCode===input.KEY_ADD){enableSetSpeedUp=false;}if(keyCode===input.KEY_SUBTRACT){enableSetSpeedDown=false;}});//碰撞停止
|
|
24566
|
+
var enableForward=true;this._scene.on("collideWithEntity",function(collideWithEntity){enableForward=!collideWithEntity;});this._onTick=scene.on("tick",function(e){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}var cameraControl=controllers.cameraControl;var elapsedSecs=e.deltaTime/1000.0;//-------------------------------------------------------------------------------------------------
|
|
24559
24567
|
// Keyboard rotation
|
|
24560
24568
|
//-------------------------------------------------------------------------------------------------
|
|
24561
|
-
if(!configs.planView){var rotateYPos=cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_POS,keyDownMap);var rotateYNeg=cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_NEG,keyDownMap);var rotateXPos=cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_POS,keyDownMap);var rotateXNeg=cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_NEG,keyDownMap);var orbitDelta=elapsedSecs*configs.keyboardRotationRate;if(rotateYPos||rotateYNeg||rotateXPos||rotateXNeg){if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(rotateYPos){updates.rotateDeltaY+=orbitDelta;}else if(rotateYNeg){updates.rotateDeltaY-=orbitDelta;}if(rotateXPos){updates.rotateDeltaX+=orbitDelta;}else if(rotateXNeg){updates.rotateDeltaX-=orbitDelta;}if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}}}//-------------------------------------------------------------------------------------------------
|
|
24569
|
+
if(!configs.planView){var rotateYPos=cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_POS,keyDownMap);var rotateYNeg=cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_NEG,keyDownMap);var rotateXPos=cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_POS,keyDownMap);var rotateXNeg=cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_NEG,keyDownMap);var orbitDelta=elapsedSecs*configs.keyboardRotationRate;if(rotateYPos||rotateYNeg||rotateXPos||rotateXNeg){if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(rotateYPos){updates.rotateDeltaY+=orbitDelta*_this125._movespeed;}else if(rotateYNeg){updates.rotateDeltaY-=orbitDelta*_this125._movespeed;}if(rotateXPos){updates.rotateDeltaX+=orbitDelta*_this125._movespeed;}else if(rotateXNeg){updates.rotateDeltaX-=orbitDelta*_this125._movespeed;}if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}}}//-------------------------------------------------------------------------------------------------
|
|
24562
24570
|
// Keyboard panning
|
|
24563
24571
|
//-------------------------------------------------------------------------------------------------
|
|
24564
|
-
if(!keyDownMap[input.KEY_CTRL]&&!keyDownMap[input.KEY_ALT]){var dollyBackwards=cameraControl._isKeyDownForAction(cameraControl.DOLLY_BACKWARDS,keyDownMap);var dollyForwards=cameraControl._isKeyDownForAction(cameraControl.DOLLY_FORWARDS,keyDownMap);if(dollyBackwards||dollyForwards){var dollyDelta=elapsedSecs*configs.keyboardDollyRate;if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(dollyForwards){if(!enableForward)return;updates.dollyDelta-=dollyDelta;}else if(dollyBackwards){updates.dollyDelta+=dollyDelta;}if(mouseMovedSinceLastKeyboardDolly){states.followPointerDirty=true;mouseMovedSinceLastKeyboardDolly=false;}}}
|
|
24565
|
-
|
|
24572
|
+
if(!keyDownMap[input.KEY_CTRL]&&!keyDownMap[input.KEY_ALT]){var dollyBackwards=cameraControl._isKeyDownForAction(cameraControl.DOLLY_BACKWARDS,keyDownMap);var dollyForwards=cameraControl._isKeyDownForAction(cameraControl.DOLLY_FORWARDS,keyDownMap);if(dollyBackwards||dollyForwards){var dollyDelta=elapsedSecs*configs.keyboardDollyRate;if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(dollyForwards){if(!enableForward)return;updates.dollyDelta-=dollyDelta*_this125._movespeed;}else if(dollyBackwards){updates.dollyDelta+=dollyDelta*_this125._movespeed;}if(mouseMovedSinceLastKeyboardDolly){states.followPointerDirty=true;mouseMovedSinceLastKeyboardDolly=false;}}}// 调整移动速度
|
|
24573
|
+
var speedUP=cameraControl._isKeyDownForAction(cameraControl.SPEED_UP,keyDownMap);var speedDown=cameraControl._isKeyDownForAction(cameraControl.SPEED_DOWN,keyDownMap);if(speedUP||speedDown){if(enableSetSpeedUp){if(_this125._movespeed<2){console.log(111);_this125._movespeed+=0.5;}enableSetSpeedUp=false;}if(enableSetSpeedDown){if(_this125._movespeed>0.5){console.log(222);_this125._movespeed-=0.5;}enableSetSpeedDown=false;}}//判断是否能用
|
|
24574
|
+
var panForwards=cameraControl._isKeyDownForAction(cameraControl.PAN_FORWARDS,keyDownMap);var panBackwards=cameraControl._isKeyDownForAction(cameraControl.PAN_BACKWARDS,keyDownMap);var panLeft=cameraControl._isKeyDownForAction(cameraControl.PAN_LEFT,keyDownMap);var panRight=cameraControl._isKeyDownForAction(cameraControl.PAN_RIGHT,keyDownMap);var panUp=cameraControl._isKeyDownForAction(cameraControl.PAN_UP,keyDownMap);var panDown=cameraControl._isKeyDownForAction(cameraControl.SPEED_UP,keyDownMap);// const panDelta = (keyDownMap[input.KEY_ALT] ? 0.3 : 1.0) * elapsedSecs * configs.keyboardPanRate; // ALT for slower pan rate
|
|
24575
|
+
var panDelta=_this125._movespeed*elapsedSecs*configs.keyboardPanRate;// ALT for slower pan rate
|
|
24576
|
+
if(panForwards||panBackwards||panLeft||panRight||panUp||panDown){if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(panDown){updates.panDeltaZ+=panDelta;}else if(panUp){updates.panDeltaZ+=-panDelta;}if(panRight){updates.panDeltaX+=-panDelta;}else if(panLeft){updates.panDeltaX+=panDelta;}if(panBackwards){updates.panDeltaY+=panDelta;}else if(panForwards){updates.panDeltaY+=-panDelta;}}});}return _createClass(KeyboardPanRotateDollyHandler,[{key:"movespeed",get:function get(){return this._movespeed;},set:function set(value){this._movespeed=value;}},{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){this._scene.off(this._onTick);this.input.off(this._onSceneMouseMove);this.input.off(this._onSceneKeyDown);this.input.off(this._onSceneKeyUp);}}]);}();var SCALE_DOLLY_EACH_FRAME=1;// Recalculate dolly speed for eye->target distance on each Nth frame
|
|
24566
24577
|
var EPSILON=0.001;var tempVec3=math.vec3();/**
|
|
24567
24578
|
* Handles camera updates on each "tick" that were scheduled by the various controllers.
|
|
24568
24579
|
*
|
|
@@ -24599,7 +24610,7 @@ if(Math.abs(updates.panDeltaX)<EPSILON){updates.panDeltaX=0;}if(Math.abs(updates
|
|
|
24599
24610
|
if(dollyDeltaForDist!==0){if(dollyDeltaForDist<0){cursorType="zoom-in";}else{cursorType="zoom-out";}if(configs.firstPerson){var _verticalEye;var _verticalLook;if(configs.constrainVertical){if(camera.xUp){_verticalEye=camera.eye[0];_verticalLook=camera.look[0];}else if(camera.yUp){_verticalEye=camera.eye[1];_verticalLook=camera.look[1];}else if(camera.zUp){_verticalEye=camera.eye[2];_verticalLook=camera.look[2];}}if(configs.followPointer){var dolliedThroughSurface=panController.dollyToCanvasPos(followPointerWorldPos,states.pointerCanvasPos,-dollyDeltaForDist);if(dolliedThroughSurface){states.followPointerDirty=true;}}else{camera.pan([0,0,dollyDeltaForDist]);camera.ortho.scale=camera.ortho.scale-dollyDeltaForDist;}if(configs.constrainVertical){var _eye=camera.eye;var _look=camera.look;if(camera.xUp){_eye[0]=_verticalEye;_look[0]=_verticalLook;}else if(camera.yUp){_eye[1]=_verticalEye;_look[1]=_verticalLook;}else if(camera.zUp){_eye[2]=_verticalEye;_look[2]=_verticalLook;}camera.eye=_eye;camera.look=_look;}}else if(configs.planView){if(configs.followPointer){var _dolliedThroughSurface=panController.dollyToCanvasPos(followPointerWorldPos,states.pointerCanvasPos,-dollyDeltaForDist);if(_dolliedThroughSurface){states.followPointerDirty=true;}}else{camera.ortho.scale=camera.ortho.scale+dollyDeltaForDist;camera.zoom(dollyDeltaForDist);}}else{// Orbiting
|
|
24600
24611
|
if(configs.followPointer){var _dolliedThroughSurface2=panController.dollyToCanvasPos(followPointerWorldPos,states.pointerCanvasPos,-dollyDeltaForDist);if(_dolliedThroughSurface2){states.followPointerDirty=true;}}else{camera.ortho.scale=camera.ortho.scale+dollyDeltaForDist;camera.zoom(dollyDeltaForDist);}}updates.dollyDelta*=configs.dollyInertia;}pickController.fireEvents();document.body.style.cursor=cursorType;});}return _createClass(CameraUpdater,[{key:"destroy",value:function destroy(){this._scene.off(this._onTick);}}]);}();/**
|
|
24601
24612
|
* @private
|
|
24602
|
-
*/var MouseMiscHandler=/*#__PURE__*/function(){function MouseMiscHandler(scene,controllers,configs,states,updates){var
|
|
24613
|
+
*/var MouseMiscHandler=/*#__PURE__*/function(){function MouseMiscHandler(scene,controllers,configs,states,updates){var _this126=this;_classCallCheck(this,MouseMiscHandler);this._scene=scene;this.canvas=this._scene.canvas.canvas;this.canvas.addEventListener("mouseenter",this._mouseEnterHandler=function(){states.mouseover=true;});this.canvas.addEventListener("mouseleave",this._mouseLeaveHandler=function(){states.mouseover=false;_this126.canvas.style.cursor=null;});document.addEventListener("mousemove",this._mouseMoveHandler=function(e){getCanvasPosFromEvent$2(e,_this126.canvas,states.pointerCanvasPos);});this.canvas.addEventListener("mousedown",this._mouseDownHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}getCanvasPosFromEvent$2(e,_this126.canvas,states.pointerCanvasPos);states.mouseover=true;});this.canvas.addEventListener("mouseup",this._mouseUpHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}});}return _createClass(MouseMiscHandler,[{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){//网络问题导致的模型加载失败等情况时,如果切换模型,会找不到canvas
|
|
24603
24614
|
//因此暂时在此加判断
|
|
24604
24615
|
if(this.canvas!=null){this.canvas.removeEventListener("mouseenter",this._mouseEnterHandler);this.canvas.removeEventListener("mouseleave",this._mouseLeaveHandler);this.canvas.removeEventListener("mousedown",this._mouseDownHandler);this.canvas.removeEventListener("mouseup",this._mouseUpHandler);}document.removeEventListener("mousemove",this._mouseMoveHandler);}}]);}();function getCanvasPosFromEvent$2(event,canvas,canvasPos){if(!event){event=window.event;canvasPos[0]=event.x;canvasPos[1]=event.y;}else{var _canvas$getBoundingCl=canvas.getBoundingClientRect(),x=_canvas$getBoundingCl.x,y=_canvas$getBoundingCl.y;canvasPos[0]=event.clientX-x;canvasPos[1]=event.clientY-y;}return canvasPos;}var getCanvasPosFromEvent$1=function getCanvasPosFromEvent$1(event,canvasPos){if(!event){event=window.event;canvasPos[0]=event.x;canvasPos[1]=event.y;}else{var element=event.target;var totalOffsetLeft=0;var totalOffsetTop=0;while(element.offsetParent){totalOffsetLeft+=element.offsetLeft;totalOffsetTop+=element.offsetTop;element=element.offsetParent;}canvasPos[0]=event.pageX-totalOffsetLeft;canvasPos[1]=event.pageY-totalOffsetTop;}return canvasPos;};/**
|
|
24605
24616
|
* @private
|
|
@@ -25111,81 +25122,81 @@ cameraControl.fire("touchPickedNothing");}lastTapTime=currentTime;}tapStartTime=
|
|
|
25111
25122
|
*/var CameraControl=/*#__PURE__*/function(_Component38){/**
|
|
25112
25123
|
* @private
|
|
25113
25124
|
* @constructor
|
|
25114
|
-
*/function CameraControl(owner){var
|
|
25125
|
+
*/function CameraControl(owner){var _this127;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,CameraControl);_this127=_callSuper(this,CameraControl,[owner,cfg]);/**
|
|
25115
25126
|
* Identifies the XX action.
|
|
25116
25127
|
* @final
|
|
25117
25128
|
* @type {Number}
|
|
25118
|
-
*/
|
|
25129
|
+
*/_this127.PAN_LEFT=0;/**
|
|
25119
25130
|
* Identifies the XX action.
|
|
25120
25131
|
* @final
|
|
25121
25132
|
* @type {Number}
|
|
25122
|
-
*/
|
|
25133
|
+
*/_this127.PAN_RIGHT=1;/**
|
|
25123
25134
|
* Identifies the XX action.
|
|
25124
25135
|
* @final
|
|
25125
25136
|
* @type {Number}
|
|
25126
|
-
*/
|
|
25137
|
+
*/_this127.PAN_UP=2;/**
|
|
25127
25138
|
* Identifies the XX action.
|
|
25128
25139
|
* @final
|
|
25129
25140
|
* @type {Number}
|
|
25130
|
-
*/
|
|
25141
|
+
*/_this127.PAN_DOWN=3;/**
|
|
25131
25142
|
* Identifies the XX action.
|
|
25132
25143
|
* @final
|
|
25133
25144
|
* @type {Number}
|
|
25134
|
-
*/
|
|
25145
|
+
*/_this127.PAN_FORWARDS=4;/**
|
|
25135
25146
|
* Identifies the XX action.
|
|
25136
25147
|
* @final
|
|
25137
25148
|
* @type {Number}
|
|
25138
|
-
*/
|
|
25149
|
+
*/_this127.PAN_BACKWARDS=5;/**
|
|
25139
25150
|
* Identifies the XX action.
|
|
25140
25151
|
* @final
|
|
25141
25152
|
* @type {Number}
|
|
25142
|
-
*/
|
|
25153
|
+
*/_this127.ROTATE_X_POS=6;/**
|
|
25143
25154
|
* Identifies the XX action.
|
|
25144
25155
|
* @final
|
|
25145
25156
|
* @type {Number}
|
|
25146
|
-
*/
|
|
25157
|
+
*/_this127.ROTATE_X_NEG=7;/**
|
|
25147
25158
|
* Identifies the XX action.
|
|
25148
25159
|
* @final
|
|
25149
25160
|
* @type {Number}
|
|
25150
|
-
*/
|
|
25161
|
+
*/_this127.ROTATE_Y_POS=8;/**
|
|
25151
25162
|
* Identifies the XX action.
|
|
25152
25163
|
* @final
|
|
25153
25164
|
* @type {Number}
|
|
25154
|
-
*/
|
|
25165
|
+
*/_this127.ROTATE_Y_NEG=9;/**
|
|
25155
25166
|
* Identifies the XX action.
|
|
25156
25167
|
* @final
|
|
25157
25168
|
* @type {Number}
|
|
25158
|
-
*/
|
|
25169
|
+
*/_this127.DOLLY_FORWARDS=10;/**
|
|
25159
25170
|
* Identifies the XX action.
|
|
25160
25171
|
* @final
|
|
25161
25172
|
* @type {Number}
|
|
25162
|
-
*/
|
|
25173
|
+
*/_this127.DOLLY_BACKWARDS=11;/**
|
|
25163
25174
|
* Identifies the XX action.
|
|
25164
25175
|
* @final
|
|
25165
25176
|
* @type {Number}
|
|
25166
|
-
*/
|
|
25177
|
+
*/_this127.AXIS_VIEW_RIGHT=12;/**
|
|
25167
25178
|
* Identifies the XX action.
|
|
25168
25179
|
* @final
|
|
25169
25180
|
* @type {Number}
|
|
25170
|
-
*/
|
|
25181
|
+
*/_this127.AXIS_VIEW_BACK=13;/**
|
|
25171
25182
|
* Identifies the XX action.
|
|
25172
25183
|
* @final
|
|
25173
25184
|
* @type {Number}
|
|
25174
|
-
*/
|
|
25185
|
+
*/_this127.AXIS_VIEW_LEFT=14;/**
|
|
25175
25186
|
* Identifies the XX action.
|
|
25176
25187
|
* @final
|
|
25177
25188
|
* @type {Number}
|
|
25178
|
-
*/
|
|
25189
|
+
*/_this127.AXIS_VIEW_FRONT=15;/**
|
|
25179
25190
|
* Identifies the XX action.
|
|
25180
25191
|
* @final
|
|
25181
25192
|
* @type {Number}
|
|
25182
|
-
*/
|
|
25193
|
+
*/_this127.AXIS_VIEW_TOP=16;/**
|
|
25183
25194
|
* Identifies the XX action.
|
|
25184
25195
|
* @final
|
|
25185
25196
|
* @type {Number}
|
|
25186
|
-
*/
|
|
25187
|
-
|
|
25188
|
-
|
|
25197
|
+
*/_this127.AXIS_VIEW_BOTTOM=17;_this127.SPEED_UP=107;_this127.SPEED_DOWN=109;_this127._keyMap={};// Maps key codes to the above actions
|
|
25198
|
+
_this127.scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault();};// User-settable CameraControl configurations
|
|
25199
|
+
_this127._configs={// Private
|
|
25189
25200
|
longTapTimeout:600,// Millisecs
|
|
25190
25201
|
longTapRadius:5,// Pixels
|
|
25191
25202
|
// General
|
|
@@ -25193,16 +25204,13 @@ active:true,keyboardLayout:"qwerty",navMode:"orbit",planView:false,firstPerson:f
|
|
|
25193
25204
|
dragRotationRate:360.0,keyboardRotationRate:90.0,rotationInertia:0.0,// Panning
|
|
25194
25205
|
keyboardPanRate:1.0,touchPanRate:1.0,panInertia:0.5,// Dollying
|
|
25195
25206
|
keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:0.2,dollyInertia:0,dollyProximityThreshold:30.0,dollyMinSpeed:0.04};// Current runtime state of the CameraControl
|
|
25196
|
-
|
|
25197
|
-
|
|
25198
|
-
var scene=
|
|
25199
|
-
|
|
25200
|
-
|
|
25201
|
-
|
|
25202
|
-
}else{
|
|
25203
|
-
// if (!this._states.mouseover) return;
|
|
25204
|
-
if(!(_this126._goLeft||_this126._goRight||_this126._goUp||_this126._goDown||_this126._goForward||_this126._goBackward)){// this._inputDirectionCommand = false;
|
|
25205
|
-
return;}if(_this126._goRight){_this126._updates.panDeltaX+=-0.1*_this126._moveRate;}else if(_this126._goLeft){_this126._updates.panDeltaX+=0.1*_this126._moveRate;}if(_this126._goUp){_this126._updates.panDeltaY+=0.1*_this126._moveRate;}else if(_this126._goDown){_this126._updates.panDeltaY+=-0.1*_this126._moveRate;}if(_this126._goForward){_this126._updates.panDeltaZ+=-0.1*_this126._moveRate;}else if(_this126._goBackward){_this126._updates.panDeltaZ+=+0.1*_this126._moveRate;}_this126._inputDirectionCommand=true;});return _this126;}/**
|
|
25207
|
+
_this127._states={pointerCanvasPos:math.vec2(),mouseover:false,followPointerDirty:true,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,touchEndTime:null,activeTouches:[],tapStartPos:math.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null};// Updates for CameraUpdater to process on next Scene "tick" event
|
|
25208
|
+
_this127._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};// Controllers to assist input event handlers with controlling the Camera
|
|
25209
|
+
var scene=_this127.scene;_this127._controllers={cameraControl:_this127,pickController:new PickController(_this127,_this127._configs),pivotController:new PivotController(scene,_this127._configs),panController:new PanController(scene),cameraFlight:new CameraFlightAnimation(_this127,{duration:0.5})};// Input event handlers
|
|
25210
|
+
_this127._handlers=[new MouseMiscHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new TouchPanRotateAndDollyHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new MousePanRotateDollyHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new KeyboardAxisViewHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new MousePickHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new TouchPickHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new KeyboardPanRotateDollyHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates)];// Applies scheduled updates to the Camera on each Scene "tick" event
|
|
25211
|
+
_this127._cameraUpdater=new CameraUpdater(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates);// Set initial user configurations
|
|
25212
|
+
_this127.navMode=cfg.navMode;if(cfg.planView){_this127.planView=cfg.planView;}_this127.constrainVertical=cfg.constrainVertical;if(cfg.keyboardLayout){_this127.keyboardLayout=cfg.keyboardLayout;// Deprecated
|
|
25213
|
+
}else{_this127.keyMap=cfg.keyMap;}_this127.doublePickFlyTo=cfg.doublePickFlyTo;_this127.panRightClick=cfg.panRightClick;_this127.active=cfg.active;_this127.followPointer=cfg.followPointer;_this127.rotationInertia=cfg.rotationInertia;_this127.keyboardPanRate=cfg.keyboardPanRate;_this127.touchPanRate=cfg.touchPanRate;_this127.keyboardRotationRate=cfg.keyboardRotationRate;_this127.dragRotationRate=cfg.dragRotationRate;_this127.touchDollyRate=cfg.touchDollyRate;_this127.dollyInertia=cfg.dollyInertia;_this127.dollyProximityThreshold=cfg.dollyProximityThreshold;_this127.dollyMinSpeed=cfg.dollyMinSpeed;_this127.panInertia=cfg.panInertia;_this127.pointerEnabled=true;_this127.keyboardDollyRate=cfg.keyboardDollyRate;_this127.mouseWheelDollyRate=cfg.mouseWheelDollyRate;_this127._moveRate=1;_this127.scene.on("tick",function(){if(!(_this127._goLeft||_this127._goRight||_this127._goUp||_this127._goDown||_this127._goForward||_this127._goBackward)){return;}if(_this127._goRight){_this127._updates.panDeltaX+=-0.1*_this127._moveRate;}else if(_this127._goLeft){_this127._updates.panDeltaX+=0.1*_this127._moveRate;}if(_this127._goUp){_this127._updates.panDeltaY+=0.1*_this127._moveRate;}else if(_this127._goDown){_this127._updates.panDeltaY+=-0.1*_this127._moveRate;}if(_this127._goForward){_this127._updates.panDeltaZ+=-0.1*_this127._moveRate;}else if(_this127._goBackward){_this127._updates.panDeltaZ+=+0.1*_this127._moveRate;}});return _this127;}/**
|
|
25206
25214
|
* 停止漫游
|
|
25207
25215
|
*/_inherits(CameraControl,_Component38);return _createClass(CameraControl,[{key:"setdirectionChangeCancel",value:function setdirectionChangeCancel(){this._goLeft=false;this._goRight=false;this._goUp=false;this._goDown=false;this._goForward=false;this._goBackward=false;}/**
|
|
25208
25216
|
* 设置漫游移动速率
|
|
@@ -25210,7 +25218,7 @@ return;}if(_this126._goRight){_this126._updates.panDeltaX+=-0.1*_this126._moveRa
|
|
|
25210
25218
|
*/},{key:"moveRate",get:function get(){return this._moveRate;}/**
|
|
25211
25219
|
* 漫游向右
|
|
25212
25220
|
* @param {boolean} go
|
|
25213
|
-
*/,set:function set(rate){this._moveRate=rate;}},{key:"goRight",set:function set(go){this._goRight=go;}/**
|
|
25221
|
+
*/,set:function set(rate){this._moveRate=rate;this._handlers[6].movespeed=rate;}},{key:"goRight",set:function set(go){this._goRight=go;}/**
|
|
25214
25222
|
* 漫游向左
|
|
25215
25223
|
* @param {boolean} go
|
|
25216
25224
|
*/},{key:"goLeft",set:function set(go){this._goLeft=go;}/**
|
|
@@ -25242,7 +25250,7 @@ return;}if(_this126._goRight){_this126._updates.panDeltaX+=-0.1*_this126._moveRa
|
|
|
25242
25250
|
* @param keyDownMap
|
|
25243
25251
|
* @private
|
|
25244
25252
|
*/,set:function set(value){value=value||"qwerty";if(utils.isString(value)){var input=this.scene.input;var keyMap={};switch(value){default:this.error("Unsupported value for 'keyMap': "+value+" defaulting to 'qwerty'");// Intentional fall-through to "qwerty"
|
|
25245
|
-
case"qwerty":keyMap[this.PAN_LEFT]=[input.KEY_A];keyMap[this.PAN_RIGHT]=[input.KEY_D];keyMap[this.PAN_UP]=[input.KEY_Z];keyMap[this.PAN_DOWN]=[input.KEY_X];keyMap[this.PAN_BACKWARDS]=[];keyMap[this.PAN_FORWARDS]=[];keyMap[this.DOLLY_FORWARDS]=[input.KEY_W
|
|
25253
|
+
case"qwerty":keyMap[this.PAN_LEFT]=[input.KEY_A];keyMap[this.PAN_RIGHT]=[input.KEY_D];keyMap[this.PAN_UP]=[input.KEY_Z];keyMap[this.PAN_DOWN]=[input.KEY_X];keyMap[this.PAN_BACKWARDS]=[input.KEY_J];keyMap[this.PAN_FORWARDS]=[input.KEY_K];keyMap[this.DOLLY_FORWARDS]=[input.KEY_W];keyMap[this.DOLLY_BACKWARDS]=[input.KEY_S];keyMap[this.ROTATE_X_POS]=[input.KEY_DOWN_ARROW];keyMap[this.ROTATE_X_NEG]=[input.KEY_UP_ARROW];keyMap[this.ROTATE_Y_POS]=[input.KEY_Q,input.KEY_LEFT_ARROW];keyMap[this.ROTATE_Y_NEG]=[input.KEY_E,input.KEY_RIGHT_ARROW];keyMap[this.AXIS_VIEW_RIGHT]=[input.KEY_NUM_1];keyMap[this.AXIS_VIEW_BACK]=[input.KEY_NUM_2];keyMap[this.AXIS_VIEW_LEFT]=[input.KEY_NUM_3];keyMap[this.AXIS_VIEW_FRONT]=[input.KEY_NUM_4];keyMap[this.AXIS_VIEW_TOP]=[input.KEY_NUM_5];keyMap[this.AXIS_VIEW_BOTTOM]=[input.KEY_NUM_6];keyMap[this.SPEED_UP]=[input.KEY_ADD];keyMap[this.SPEED_DOWN]=[input.KEY_SUBTRACT];break;case"azerty":keyMap[this.PAN_LEFT]=[input.KEY_Q];keyMap[this.PAN_RIGHT]=[input.KEY_D];keyMap[this.PAN_UP]=[input.KEY_W];keyMap[this.PAN_DOWN]=[input.KEY_X];keyMap[this.PAN_BACKWARDS]=[input.KEY_J];keyMap[this.PAN_FORWARDS]=[input.KEY_K];keyMap[this.DOLLY_FORWARDS]=[input.KEY_Z];keyMap[this.DOLLY_BACKWARDS]=[input.KEY_S];keyMap[this.ROTATE_X_POS]=[input.KEY_DOWN_ARROW];keyMap[this.ROTATE_X_NEG]=[input.KEY_UP_ARROW];keyMap[this.ROTATE_Y_POS]=[input.KEY_A,input.KEY_LEFT_ARROW];keyMap[this.ROTATE_Y_NEG]=[input.KEY_E,input.KEY_RIGHT_ARROW];keyMap[this.AXIS_VIEW_RIGHT]=[input.KEY_NUM_1];keyMap[this.AXIS_VIEW_BACK]=[input.KEY_NUM_2];keyMap[this.AXIS_VIEW_LEFT]=[input.KEY_NUM_3];keyMap[this.AXIS_VIEW_FRONT]=[input.KEY_NUM_4];keyMap[this.AXIS_VIEW_TOP]=[input.KEY_NUM_5];keyMap[this.AXIS_VIEW_BOTTOM]=[input.KEY_NUM_6];keyMap[this.SPEED_UP]=[input.KEY_ADD];keyMap[this.SPEED_DOWN]=[input.KEY_SUBTRACT];break;}this._keyMap=keyMap;}else{var _keyMap=value;this._keyMap=_keyMap;}}},{key:"_isKeyDownForAction",value:function _isKeyDownForAction(action,keyDownMap){var keys=this._keyMap[action];if(!keys){return false;}if(!keyDownMap){keyDownMap=this.scene.input.keyDown;}for(var _i503=0,len=keys.length;_i503<len;_i503++){var key=keys[_i503];if(keyDownMap[key]){return true;}}return false;}/**
|
|
25246
25254
|
* Sets the HTMl element to represent the pivot point when {@link CameraControl#followPointer} is true.
|
|
25247
25255
|
*
|
|
25248
25256
|
* See class comments for an example.
|
|
@@ -26235,7 +26243,7 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
|
|
|
26235
26243
|
* configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
|
|
26236
26244
|
* responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
|
|
26237
26245
|
* your expected usage.
|
|
26238
|
-
*/function Viewer(cfg){var
|
|
26246
|
+
*/function Viewer(cfg){var _this128=this;_classCallCheck(this,Viewer);this.container=cfg.viewerElement;/**
|
|
26239
26247
|
* The Viewer's current language setting.
|
|
26240
26248
|
* @property language
|
|
26241
26249
|
* @deprecated
|
|
@@ -26280,7 +26288,7 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
|
|
|
26280
26288
|
* @property cameraControl
|
|
26281
26289
|
* @type {CameraControl}
|
|
26282
26290
|
*/this.cameraControl=new CameraControl(this.scene,{// panToPointer: true,
|
|
26283
|
-
snapRadius:cfg.snapRadius,doublePickFlyTo:true});this.scene.canvas.on("boundary",function(event){
|
|
26291
|
+
snapRadius:cfg.snapRadius,doublePickFlyTo:true});this.scene.canvas.on("boundary",function(event){_this128.cameraControl.updatePivotElement();});this._plugins=[];/**
|
|
26284
26292
|
* Subscriptions to events sent with {@link fire}.
|
|
26285
26293
|
* @private
|
|
26286
26294
|
*/this._eventSubs={};}/**
|
|
@@ -26757,7 +26765,7 @@ if(plugins.length>0){for(var _i518=0,len=plugins.length;_i518<len;_i518++){var p
|
|
|
26757
26765
|
* @param {String[]} [cfg.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
26758
26766
|
* @param {String[]} [cfg.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
26759
26767
|
* @param {Boolean} [cfg.excludeUnclassifiedObjects=false] When loading metadata and this is ````true````, will only load {@link Entity}s that have {@link MetaObject}s (that are not excluded). This is useful when we don't want Entitys in the Scene that are not represented within IFC navigation components, such as {@link TreeViewPlugin}.
|
|
26760
|
-
*/function WebIFCLoaderPlugin(viewer){var
|
|
26768
|
+
*/function WebIFCLoaderPlugin(viewer){var _this129;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,WebIFCLoaderPlugin);_this129=_callSuper(this,WebIFCLoaderPlugin,["ifcLoader",viewer,cfg]);_this129.dataSource=cfg.dataSource;_this129.objectDefaults=cfg.objectDefaults;_this129.includeTypes=cfg.includeTypes;_this129.excludeTypes=cfg.excludeTypes;_this129.excludeUnclassifiedObjects=cfg.excludeUnclassifiedObjects;if(cfg.WebIFC){_this129._webIFC=cfg.WebIFC;_this129._ifcAPI=cfg.IfcAPI;_this129.webIfcFroMOutside=true;}// else {
|
|
26761
26769
|
// this._webIFC = WebIFC;
|
|
26762
26770
|
// this.webIfcFroMOutside = false;
|
|
26763
26771
|
// this._ifcAPI = new this._webIFC.IfcAPI();
|
|
@@ -26773,7 +26781,7 @@ if(plugins.length>0){for(var _i518=0,len=plugins.length;_i518<len;_i518++){var p
|
|
|
26773
26781
|
// this.error(e);
|
|
26774
26782
|
// });
|
|
26775
26783
|
// }
|
|
26776
|
-
return
|
|
26784
|
+
return _this129;}/**
|
|
26777
26785
|
* Gets the ````IFC```` format versions supported by this WebIFCLoaderPlugin.
|
|
26778
26786
|
* @returns {string[]}
|
|
26779
26787
|
*/_inherits(WebIFCLoaderPlugin,_Plugin10);return _createClass(WebIFCLoaderPlugin,[{key:"supportedVersions",get:function get(){return["2x3","4"];}/**
|
|
@@ -26918,12 +26926,12 @@ return _this128;}/**
|
|
|
26918
26926
|
// sceneModel.fire("error", e);
|
|
26919
26927
|
// }
|
|
26920
26928
|
// });
|
|
26921
|
-
return sceneModel;}},{key:"_loadModel",value:function _loadModel(src,params,options,sceneModel){var
|
|
26929
|
+
return sceneModel;}},{key:"_loadModel",value:function _loadModel(src,params,options,sceneModel){var _this130=this;var spinner=this.viewer.scene.canvas.spinner;spinner.processes++;this._dataSource.getIFC(params.src,function(arrayBuffer){_this130._parseModel(arrayBuffer,params,options,sceneModel);spinner.processes--;},function(errMsg){spinner.processes--;_this130.error(errMsg);sceneModel.fire("error",errMsg);});}},{key:"_parseModel",value:function _parseModel(arrayBuffer,params,options,sceneModel){if(sceneModel.destroyed){return;}var stats=params.stats||{};stats.sourceFormat="IFC";stats.schemaVersion="";stats.title="";stats.author="";stats.created="";stats.numMetaObjects=0;stats.numPropertySets=0;stats.numObjects=0;stats.numGeometries=0;stats.numTriangles=0;stats.numVertices=0;if(this.webIfcFroMOutside){if(!this._ifcAPI){throw"WebIFCLoaderPlugin has no WebIFC instance configured - please inject via WebIFCLoaderPlugin constructor";}}else{if(options.wasmPath){this._ifcAPI.SetWasmPath(options.wasmPath);}}var dataArray=new Uint8Array(arrayBuffer);var modelID=this._ifcAPI.OpenModel(dataArray);var modelSchema=this._ifcAPI.GetModelSchema(modelID);var lines=this._ifcAPI.GetLineIDsWithType(modelID,this._webIFC.IFCPROJECT);var ifcProjectId=lines.get(0);var loadMetadata=params.loadMetadata!==false;var useOutsideMetadata=params.metadata!==undefined&¶ms.metadata!==null;var outMetadata;if(useOutsideMetadata){outMetadata=params.metadata;}else outMetadata=null;var metadata=loadMetadata?{id:"",projectId:""+ifcProjectId,author:"",createdAt:"",schema:"",creatingApplication:"",metaObjects:[],propertySets:[]}:outMetadata;var ctx={ifcProjectId:ifcProjectId,modelID:modelID,modelSchema:modelSchema,sceneModel:sceneModel,loadMetadata:loadMetadata,metadata:metadata,metaObjects:useOutsideMetadata?sceneModel.metaObjects:{},options:options,// log: function (msg) {},
|
|
26922
26930
|
nextId:0,stats:stats};if(loadMetadata){if(options.includeTypes){ctx.includeTypes={};for(var _i521=0,len=options.includeTypes.length;_i521<len;_i521++){ctx.includeTypes[options.includeTypes[_i521]]=true;}}if(options.excludeTypes){ctx.excludeTypes={};for(var _i522=0,_len106=options.excludeTypes.length;_i522<_len106;_i522++){ctx.excludeTypes[options.excludeTypes[_i522]]=true;}}this._parseMetaObjects(ctx);this._parsePropertySets(ctx);}this._parseGeometry(ctx);sceneModel.finalize();if(loadMetadata||useOutsideMetadata){var metaModelId=sceneModel.id;this.viewer.metaScene.createMetaModel(metaModelId,ctx.metadata,options);}sceneModel.scene.once("tick",function(){if(sceneModel.destroyed){return;}sceneModel.scene.fire("modelLoaded",sceneModel.id);// FIXME: Assumes listeners know order of these two events
|
|
26923
26931
|
sceneModel.fire("loaded",true,false);// Don't forget the event, for late subscribers
|
|
26924
|
-
});}},{key:"_parseMetaObjects",value:function _parseMetaObjects(ctx){var ifcProject=this._ifcAPI.GetLine(ctx.modelID,ctx.ifcProjectId);this._parseSpatialChildren(ctx,ifcProject);}},{key:"_parseSpatialChildren",value:function _parseSpatialChildren(ctx,ifcElement,parentMetaObjectId){var metaObjectType=this._ifcAPI.GetNameFromTypeCode(ifcElement.type);if(ctx.includeTypes&&!ctx.includeTypes[metaObjectType]){return;}if(ctx.excludeTypes&&ctx.excludeTypes[metaObjectType]){return;}this._createMetaObject(ctx,ifcElement,parentMetaObjectId);var metaObjectId=ifcElement.GlobalId.value;this._parseRelatedItemsOfType(ctx,ifcElement.expressID,"RelatingObject","RelatedObjects",this._webIFC.IFCRELAGGREGATES,metaObjectId);this._parseRelatedItemsOfType(ctx,ifcElement.expressID,"RelatingStructure","RelatedElements",this._webIFC.IFCRELCONTAINEDINSPATIALSTRUCTURE,metaObjectId);}},{key:"_createMetaObject",value:function _createMetaObject(ctx,ifcElement,parentMetaObjectId){var id=ifcElement.GlobalId.value;var metaObjectType;if(this.webIfcFroMOutside)metaObjectType=this._ifcAPI.GetNameFromTypeCode(ifcElement.type);else metaObjectType=ifcElement.__proto__.constructor.name;var metaObjectName=ifcElement.Name&&ifcElement.Name.value!==""?ifcElement.Name.value:metaObjectType;var metaObject={id:id,name:metaObjectName,type:metaObjectType,parent:parentMetaObjectId};ctx.metadata.metaObjects.push(metaObject);ctx.metaObjects[id]=metaObject;ctx.stats.numMetaObjects++;}},{key:"_parseRelatedItemsOfType",value:function _parseRelatedItemsOfType(ctx,id,relation,related,type,parentMetaObjectId){var
|
|
26925
|
-
var flatMeshExpressID=flatMesh.expressID;var placedGeometries=flatMesh.geometries;var meshIds=[];var properties=
|
|
26932
|
+
});}},{key:"_parseMetaObjects",value:function _parseMetaObjects(ctx){var ifcProject=this._ifcAPI.GetLine(ctx.modelID,ctx.ifcProjectId);this._parseSpatialChildren(ctx,ifcProject);}},{key:"_parseSpatialChildren",value:function _parseSpatialChildren(ctx,ifcElement,parentMetaObjectId){var metaObjectType=this._ifcAPI.GetNameFromTypeCode(ifcElement.type);if(ctx.includeTypes&&!ctx.includeTypes[metaObjectType]){return;}if(ctx.excludeTypes&&ctx.excludeTypes[metaObjectType]){return;}this._createMetaObject(ctx,ifcElement,parentMetaObjectId);var metaObjectId=ifcElement.GlobalId.value;this._parseRelatedItemsOfType(ctx,ifcElement.expressID,"RelatingObject","RelatedObjects",this._webIFC.IFCRELAGGREGATES,metaObjectId);this._parseRelatedItemsOfType(ctx,ifcElement.expressID,"RelatingStructure","RelatedElements",this._webIFC.IFCRELCONTAINEDINSPATIALSTRUCTURE,metaObjectId);}},{key:"_createMetaObject",value:function _createMetaObject(ctx,ifcElement,parentMetaObjectId){var id=ifcElement.GlobalId.value;var metaObjectType;if(this.webIfcFroMOutside)metaObjectType=this._ifcAPI.GetNameFromTypeCode(ifcElement.type);else metaObjectType=ifcElement.__proto__.constructor.name;var metaObjectName=ifcElement.Name&&ifcElement.Name.value!==""?ifcElement.Name.value:metaObjectType;var metaObject={id:id,name:metaObjectName,type:metaObjectType,parent:parentMetaObjectId};ctx.metadata.metaObjects.push(metaObject);ctx.metaObjects[id]=metaObject;ctx.stats.numMetaObjects++;}},{key:"_parseRelatedItemsOfType",value:function _parseRelatedItemsOfType(ctx,id,relation,related,type,parentMetaObjectId){var _this131=this;var lines=this._ifcAPI.GetLineIDsWithType(ctx.modelID,type);for(var _i523=0;_i523<lines.size();_i523++){var relID=lines.get(_i523);var rel=this._ifcAPI.GetLine(ctx.modelID,relID);if(rel==null)return;var relatedItems=rel[relation];var foundElement=false;if(Array.isArray(relatedItems)){var values=relatedItems.map(function(item){return item.value;});foundElement=values.includes(id);}else{foundElement=relatedItems.value===id;}if(foundElement){var element=rel[related];if(!Array.isArray(element)){var ifcElement=this._ifcAPI.GetLine(ctx.modelID,element.value);if(ifcElement==null)return;this._parseSpatialChildren(ctx,ifcElement,parentMetaObjectId);}else{element.forEach(function(element2){var ifcElement=_this131._ifcAPI.GetLine(ctx.modelID,element2.value);if(ifcElement==null)return;_this131._parseSpatialChildren(ctx,ifcElement,parentMetaObjectId);});}}}}},{key:"_parsePropertySets",value:function _parsePropertySets(ctx){this.log("start parse property...");var lines=this._ifcAPI.GetLineIDsWithType(ctx.modelID,this._webIFC.IFCRELDEFINESBYPROPERTIES);for(var _i524=0;_i524<lines.size();_i524++){var relID=lines.get(_i524);var rel=this._ifcAPI.GetLine(ctx.modelID,relID,true);if(rel){var relatingPropertyDefinition=rel.RelatingPropertyDefinition;if(!relatingPropertyDefinition){continue;}var propertySetId=relatingPropertyDefinition.GlobalId.value;var props=relatingPropertyDefinition.HasProperties;if(props&&props.length>0){var propertySetType="Default";var propertySetName=relatingPropertyDefinition.Name.value;var properties=[];for(var _i525=0,len=props.length;_i525<len;_i525++){var prop=props[_i525];var name=prop.Name;var nominalValue=prop.NominalValue;if(name&&nominalValue){var property={name:name.value,type:nominalValue.type,value:nominalValue.value,valueType:nominalValue.valueType};if(prop.Description){property.description=prop.Description.value;}else if(nominalValue.description){property.description=nominalValue.description;}properties.push(property);}}var propertySet={id:propertySetId,type:propertySetType,name:propertySetName,properties:properties};ctx.metadata.propertySets.push(propertySet);ctx.stats.numPropertySets++;var relatedObjects=rel.RelatedObjects;if(!relatedObjects||relatedObjects.length===0){return;}for(var _i526=0,_len107=relatedObjects.length;_i526<_len107;_i526++){var relatedObject=relatedObjects[_i526];var metaObjectId=relatedObject.GlobalId.value;var metaObject=ctx.metaObjects[metaObjectId];if(metaObject){if(!metaObject.propertySetIds){metaObject.propertySetIds=[];}metaObject.propertySetIds.push(propertySetId);}}}}}}},{key:"_parseGeometry",value:function _parseGeometry(ctx){var _this132=this;this.log("start parse geometry");this._ifcAPI.StreamAllMeshes(ctx.modelID,function(flatMesh){// TODO: Can we do geometry reuse with web-ifc?
|
|
26933
|
+
var flatMeshExpressID=flatMesh.expressID;var placedGeometries=flatMesh.geometries;var meshIds=[];var properties=_this132._ifcAPI.GetLine(ctx.modelID,flatMeshExpressID);if(properties==null)return;var globalId=properties.GlobalId.value;if(ctx.loadMetadata){var metaObjectId=globalId;var metaObject=ctx.metaObjects[metaObjectId];if(ctx.includeTypes&&(!metaObject||!ctx.includeTypes[metaObject.type])){return;}if(ctx.excludeTypes&&(!metaObject||ctx.excludeTypes[metaObject.type])){return;}}var matrix=math.mat4();var origin=math.vec3();for(var j=0,lenj=placedGeometries.size();j<lenj;j++){var placedGeometry=placedGeometries.get(j);var geometry=_this132._ifcAPI.GetGeometry(ctx.modelID,placedGeometry.geometryExpressID);var vertexData=_this132._ifcAPI.GetVertexArray(geometry.GetVertexData(),geometry.GetVertexDataSize());var indices=_this132._ifcAPI.GetIndexArray(geometry.GetIndexData(),geometry.GetIndexDataSize());// De-interleave vertex arrays
|
|
26926
26934
|
var positions=new Float64Array(vertexData.length/2);var normals=new Float32Array(vertexData.length/2);for(var k=0,l=0,lenk=vertexData.length/6;k<lenk;k++,l+=3){positions[l+0]=vertexData[k*6+0];positions[l+1]=vertexData[k*6+1];positions[l+2]=vertexData[k*6+2];}matrix.set(placedGeometry.flatTransformation);math.transformPositions3(matrix,positions);var rtcNeeded=worldToRTCPositions(positions,positions,origin);if(!ctx.options.autoNormals){for(var _k2=0,_l2=0,_lenk=vertexData.length/6;_k2<_lenk;_k2++,_l2+=3){normals[_l2+0]=vertexData[_k2*6+3];normals[_l2+1]=vertexData[_k2*6+4];normals[_l2+2]=vertexData[_k2*6+5];}}ctx.stats.numGeometries++;ctx.stats.numVertices+=positions.length/3;ctx.stats.numTriangles+=indices.length/3;var meshId="mesh"+ctx.nextId++;ctx.sceneModel.createMesh({id:meshId,primitive:"triangles",// TODO
|
|
26927
|
-
origin:rtcNeeded?origin:null,positions:positions,normals:ctx.options.autoNormals?null:normals,indices:indices,color:[placedGeometry.color.x,placedGeometry.color.y,placedGeometry.color.z],opacity:placedGeometry.color.w});meshIds.push(meshId);}var entityId=ctx.options.globalizeObjectIds?math.globalizeObjectId(ctx.sceneModel.id,globalId):globalId;ctx.sceneModel.createEntity({id:entityId,meshIds:meshIds,isObject:true});ctx.stats.numObjects++;});this._ifcAPI.StreamAllMeshesWithTypes(ctx.modelID,[3856911033],function(mesh,index,total){var flatMeshExpressID=mesh.expressID;var properties=
|
|
26935
|
+
origin:rtcNeeded?origin:null,positions:positions,normals:ctx.options.autoNormals?null:normals,indices:indices,color:[placedGeometry.color.x,placedGeometry.color.y,placedGeometry.color.z],opacity:placedGeometry.color.w});meshIds.push(meshId);}var entityId=ctx.options.globalizeObjectIds?math.globalizeObjectId(ctx.sceneModel.id,globalId):globalId;ctx.sceneModel.createEntity({id:entityId,meshIds:meshIds,isObject:true});ctx.stats.numObjects++;});this._ifcAPI.StreamAllMeshesWithTypes(ctx.modelID,[3856911033],function(mesh,index,total){var flatMeshExpressID=mesh.expressID;var properties=_this132._ifcAPI.GetLine(ctx.modelID,flatMeshExpressID);if(properties==null)return;var globalId=properties.GlobalId.value;var placedGeometries=mesh.geometries;var meshIds=[];var matrix=math.mat4();var origin=math.vec3();for(var j=0,lenj=placedGeometries.size();j<lenj;j++){var placedGeometry=placedGeometries.get(j);var geometry=_this132._ifcAPI.GetGeometry(ctx.modelID,placedGeometry.geometryExpressID);var vertexData=_this132._ifcAPI.GetVertexArray(geometry.GetVertexData(),geometry.GetVertexDataSize());var indices=_this132._ifcAPI.GetIndexArray(geometry.GetIndexData(),geometry.GetIndexDataSize());// De-interleave vertex arrays
|
|
26928
26936
|
var positions=new Float64Array(vertexData.length/2);var normals=new Float32Array(vertexData.length/2);for(var k=0,l=0,lenk=vertexData.length/6;k<lenk;k++,l+=3){positions[l+0]=vertexData[k*6+0];positions[l+1]=vertexData[k*6+1];positions[l+2]=vertexData[k*6+2];}matrix.set(placedGeometry.flatTransformation);math.transformPositions3(matrix,positions);var rtcNeeded=worldToRTCPositions(positions,positions,origin);if(!ctx.options.autoNormals){for(var _k3=0,_l3=0,_lenk2=vertexData.length/6;_k3<_lenk2;_k3++,_l3+=3){normals[_l3+0]=vertexData[_k3*6+3];normals[_l3+1]=vertexData[_k3*6+4];normals[_l3+2]=vertexData[_k3*6+5];}}ctx.stats.numGeometries++;ctx.stats.numVertices+=positions.length/3;ctx.stats.numTriangles+=indices.length/3;var meshId="mesh"+ctx.nextId++;ctx.sceneModel.createMesh({id:meshId,primitive:"triangles",// TODO
|
|
26929
26937
|
origin:rtcNeeded?origin:null,positions:positions,normals:ctx.options.autoNormals?null:normals,indices:indices,color:[placedGeometry.color.x,placedGeometry.color.y,placedGeometry.color.z],opacity:placedGeometry.color.w<1?placedGeometry.color.w:0.1});meshIds.push(meshId);}var entityId=ctx.options.globalizeObjectIds?math.globalizeObjectId(ctx.sceneModel.id,globalId):globalId;ctx.sceneModel.createEntity({id:entityId,meshIds:meshIds,isObject:true});ctx.stats.numObjects++;});}}]);}(Plugin);export{AlphaFormat,AmbientLight,AngleMeasurementsControl,AngleMeasurementsMouseControl,AngleMeasurementsPlugin,AngleMeasurementsTouchControl,AnnotationsPlugin,Bitmap,ByteType,CameraMemento,CameraPath,CameraPathAnimation,Canvas,ClampToEdgeWrapping,Component,CompressedMediaType,Configs,CubicBezierCurve,Curve,DefaultLoadingManager,DepthFormat,DepthStencilFormat,DirLight,DistanceMeasurementsControl,DistanceMeasurementsMouseControl,DistanceMeasurementsPlugin,DistanceMeasurementsTouchControl,EdgeMaterial,EmphasisMaterial,FloatType,Fresnel,Frustum$1 as Frustum,FrustumPlane,GIFMediaType,HalfFloatType,ImagePlane,IntType,JPEGMediaType,KTX2TextureTranscoder,LambertMaterial,LightMap,LineSet,LinearEncoding,LinearFilter,LinearMipMapLinearFilter,LinearMipMapNearestFilter,LinearMipmapLinearFilter,LinearMipmapNearestFilter,Loader,LoadingManager,LocaleService,LuminanceAlphaFormat,LuminanceFormat,Map,Marker,Mesh,MetallicMaterial,MirroredRepeatWrapping,ModelMemento,NavCubePlugin,NearestFilter,NearestMipMapLinearFilter,NearestMipMapNearestFilter,NearestMipmapLinearFilter,NearestMipmapNearestFilter,Node$1 as Node,ObjectsKdTree3,ObjectsMemento,PNGMediaType,Path,PerformanceModel,PhongMaterial,Plugin,PointLight,PointerLens,QuadraticBezierCurve,Queue,RGBAFormat,RGBAIntegerFormat,RGBA_ASTC_10x10_Format,RGBA_ASTC_10x5_Format,RGBA_ASTC_10x6_Format,RGBA_ASTC_10x8_Format,RGBA_ASTC_12x10_Format,RGBA_ASTC_12x12_Format,RGBA_ASTC_4x4_Format,RGBA_ASTC_5x4_Format,RGBA_ASTC_5x5_Format,RGBA_ASTC_6x5_Format,RGBA_ASTC_6x6_Format,RGBA_ASTC_8x5_Format,RGBA_ASTC_8x6_Format,RGBA_ASTC_8x8_Format,RGBA_BPTC_Format,RGBA_ETC2_EAC_Format,RGBA_PVRTC_2BPPV1_Format,RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format,RGBA_S3TC_DXT3_Format,RGBA_S3TC_DXT5_Format,RGBFormat,RGB_ETC1_Format,RGB_ETC2_Format,RGB_PVRTC_2BPPV1_Format,RGB_PVRTC_4BPPV1_Format,RGB_S3TC_DXT1_Format,RGFormat,RGIntegerFormat,ReadableGeometry,RedFormat,RedIntegerFormat,ReflectionMap,Renderer$1 as Renderer,RepeatWrapping,Scene,SceneModel,SceneModelMesh,SceneModelTransform,SectionBox,SectionPlane,SectionPlanesPlugin,ShortType,Skybox,SkyboxesPlugin,SpecularMaterial,SplineCurve,SpriteMarker,StoreyViewsPlugin,Texture,TextureTranscoder,TreeViewPlugin,UnsignedByteType,UnsignedInt248Type,UnsignedIntType,UnsignedShort4444Type,UnsignedShort5551Type,UnsignedShortType,VBOGeometry,Viewer,WebIFCLoaderPlugin,WorkerPool,XTCDefaultDataSource,XTCLoaderPlugin,buildBoxGeometry,buildBoxLinesGeometry,buildCylinderGeometry,buildGridGeometry,buildPlaneGeometry,buildSphereGeometry,buildTorusGeometry,buildVectorTextGeometry,createRTCViewMat,frustumIntersectsAABB3,getKTX2TextureTranscoder,getPlaneRTCPos,load3DSGeometry,loadOBJGeometry,math,rtcToWorldPos,sRGBEncoding,setFrustum,stats,utils,worldToRTCPos,worldToRTCPositions};
|