@xeokit/xeokit-sdk 2.4.0-alpha-101 → 2.4.0-alpha-105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +144 -140
- package/dist/xeokit-sdk.es.js +144 -140
- package/dist/xeokit-sdk.es5.js +40 -35
- package/dist/xeokit-sdk.min.cjs.js +3 -3
- package/dist/xeokit-sdk.min.es.js +4 -4
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +1 -0
- package/src/viewer/scene/Bitmap/Bitmap.js +4 -1
- package/src/viewer/scene/CameraControl/lib/handlers/MousePickHandler.js +2 -1
- package/src/viewer/scene/LineSet/LineSet.js +7 -4
- package/src/viewer/scene/LineSet/LineSet.new.js +160 -0
- package/src/viewer/scene/model/SceneModel.js +1 -1
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureColorRenderer.js +3 -3
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesColorRenderer.js +2 -3
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesRenderer.js +5 -7
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -2550,7 +2550,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._cornerDot.s
|
|
|
2550
2550
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
2551
2551
|
*/function get(){return this._snapping;}/**
|
|
2552
2552
|
* Activates this AngleMeasurementsMouseControl, ready to respond to input.
|
|
2553
|
-
*/,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 _this15=this;if(this._active){return;}this.angleMeasurementsPlugin;var scene=this.scene;scene.input;var canvas=scene.canvas.canvas;var clickTolerance=20;var cameraControl=this.angleMeasurementsPlugin.viewer.cameraControl;var pointerLens=this.pointerLens;var mouseHovering=false;var mouseHoverEntity=false;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(event.snappedToVertex||event.snappedToEdge){if(pointerLens){pointerLens.visible=true;pointerLens.centerPos=event.cursorPos||event.canvasPos;pointerLens.cursorPos=event.canvasPos;pointerLens.snapped=true;}_this15.markerDiv.style.background="greenyellow";_this15.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.centerPos=event.cursorPos||event.canvasPos;pointerLens.cursorPos=event.canvasPos;pointerLens.snapped=false;}_this15.markerDiv.style.background="pink";_this15.markerDiv.style.border="2px solid red";}mouseHovering=true;mouseHoverEntity=event.entity;mouseWorldPos.set(event.worldPos);mouseHoverCanvasPos.set(event.canvasPos);switch(_this15._mouseState){case MOUSE_FINDING_ORIGIN:_this15.markerDiv.style.marginLeft="".concat(event.canvasPos[0]-5,"px");_this15.markerDiv.style.marginTop="".concat(event.canvasPos[1]-5,"px");break;case MOUSE_FINDING_CORNER:if(_this15._currentAngleMeasurement){_this15._currentAngleMeasurement.originWireVisible=true;_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.cornerVisible=true;_this15._currentAngleMeasurement.angleVisible=false;_this15._currentAngleMeasurement.corner.worldPos=event.worldPos;}_this15.markerDiv.style.marginLeft="-10000px";_this15.markerDiv.style.marginTop="-10000px";canvas.style.cursor="pointer";break;case MOUSE_FINDING_TARGET:if(_this15._currentAngleMeasurement){_this15._currentAngleMeasurement.targetWireVisible=true;_this15._currentAngleMeasurement.targetVisible=true;_this15._currentAngleMeasurement.angleVisible=true;_this15._currentAngleMeasurement.target.worldPos=event.worldPos;}_this15.markerDiv.style.marginLeft="-10000px";_this15.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(e.which!==1){return;}if(e.clientX>lastMouseCanvasX+clickTolerance||e.clientX<lastMouseCanvasX-clickTolerance||e.clientY>lastMouseCanvasY+clickTolerance||e.clientY<lastMouseCanvasY-clickTolerance){return;}switch(_this15._mouseState){case MOUSE_FINDING_ORIGIN:if(mouseHovering){_this15._currentAngleMeasurement=_this15.angleMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{entity:mouseHoverEntity,worldPos:mouseWorldPos},corner:{entity:mouseHoverEntity,worldPos:mouseWorldPos},target:{entity:mouseHoverEntity,worldPos:mouseWorldPos},approximate:true});_this15._currentAngleMeasurement.clickable=false;_this15._currentAngleMeasurement.originVisible=true;_this15._currentAngleMeasurement.originWireVisible=true;_this15._currentAngleMeasurement.cornerVisible=false;_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.targetVisible=false;_this15._currentAngleMeasurement.angleVisible=false;_this15._mouseState=MOUSE_FINDING_CORNER;_this15.angleMeasurementsPlugin.fire("measurementStart",_this15._currentAngleMeasurement);}break;case MOUSE_FINDING_CORNER:if(mouseHovering){_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.targetVisible=true;_this15._currentAngleMeasurement.angleVisible=true;_this15._mouseState=MOUSE_FINDING_TARGET;}else{if(_this15._currentAngleMeasurement){_this15._currentAngleMeasurement.destroy();_this15._currentAngleMeasurement=null;_this15._mouseState=MOUSE_FINDING_ORIGIN;_this15.angleMeasurementsPlugin.fire("measurementCancel",_this15._currentAngleMeasurement);}}break;case MOUSE_FINDING_TARGET:if(mouseHovering){_this15._currentAngleMeasurement.targetVisible=true;_this15._currentAngleMeasurement.angleVisible=true;_this15.angleMeasurementsPlugin.fire("measurementEnd",_this15._currentAngleMeasurement);_this15._currentAngleMeasurement=null;_this15._mouseState=MOUSE_FINDING_ORIGIN;}else{if(_this15._currentAngleMeasurement){_this15._currentAngleMeasurement.destroy();_this15._currentAngleMeasurement=null;_this15._mouseState=MOUSE_FINDING_ORIGIN;_this15.angleMeasurementsPlugin.fire("measurementCancel",_this15._currentAngleMeasurement);}}break;}});this._onMouseHoverOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){mouseHovering=false;if(pointerLens){pointerLens.visible=true;pointerLens.centerPos=event.cursorPos;pointerLens.cursorPos=event.cursorPos;pointerLens.snapped=false;}_this15.markerDiv.style.marginLeft="-100px";_this15.markerDiv.style.marginTop="-100px";if(_this15._currentAngleMeasurement){switch(_this15._mouseState){case MOUSE_FINDING_ORIGIN:_this15._currentAngleMeasurement.originVisible=false;break;case MOUSE_FINDING_CORNER:_this15._currentAngleMeasurement.cornerVisible=false;_this15._currentAngleMeasurement.originWireVisible=false;_this15._currentAngleMeasurement.targetVisible=false;_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.angleVisible=false;break;case MOUSE_FINDING_TARGET:_this15._currentAngleMeasurement.targetVisible=false;_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.angleVisible=false;break;}canvas.style.cursor="default";}});this._active=true;}/**
|
|
2553
|
+
*/,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 _this15=this;if(this._active){return;}this.angleMeasurementsPlugin;var scene=this.scene;scene.input;var canvas=scene.canvas.canvas;var clickTolerance=20;var cameraControl=this.angleMeasurementsPlugin.viewer.cameraControl;var pointerLens=this.pointerLens;var mouseHovering=false;var mouseHoverEntity=false;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(event.snappedToVertex||event.snappedToEdge){if(pointerLens){pointerLens.visible=true;pointerLens.centerPos=event.cursorPos||event.canvasPos;pointerLens.cursorPos=event.canvasPos;pointerLens.snapped=true;}_this15.markerDiv.style.background="greenyellow";_this15.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.centerPos=event.cursorPos||event.canvasPos;pointerLens.cursorPos=event.canvasPos;pointerLens.snapped=false;}_this15.markerDiv.style.background="pink";_this15.markerDiv.style.border="2px solid red";}mouseHovering=true;mouseHoverEntity=event.entity;mouseWorldPos.set(event.worldPos);mouseHoverCanvasPos.set(event.canvasPos);switch(_this15._mouseState){case MOUSE_FINDING_ORIGIN:_this15.markerDiv.style.marginLeft="".concat(event.canvasPos[0]-5,"px");_this15.markerDiv.style.marginTop="".concat(event.canvasPos[1]-5,"px");break;case MOUSE_FINDING_CORNER:if(_this15._currentAngleMeasurement){_this15._currentAngleMeasurement.originWireVisible=true;_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.cornerVisible=true;_this15._currentAngleMeasurement.angleVisible=false;_this15._currentAngleMeasurement.corner.worldPos=event.worldPos;}_this15.markerDiv.style.marginLeft="-10000px";_this15.markerDiv.style.marginTop="-10000px";canvas.style.cursor="pointer";break;case MOUSE_FINDING_TARGET:if(_this15._currentAngleMeasurement){_this15._currentAngleMeasurement.targetWireVisible=true;_this15._currentAngleMeasurement.targetVisible=true;_this15._currentAngleMeasurement.angleVisible=true;_this15._currentAngleMeasurement.target.worldPos=event.worldPos;}_this15.markerDiv.style.marginLeft="-10000px";_this15.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(e.which!==1){return;}if(e.clientX>lastMouseCanvasX+clickTolerance||e.clientX<lastMouseCanvasX-clickTolerance||e.clientY>lastMouseCanvasY+clickTolerance||e.clientY<lastMouseCanvasY-clickTolerance){return;}switch(_this15._mouseState){case MOUSE_FINDING_ORIGIN:if(mouseHovering){_this15._currentAngleMeasurement=_this15.angleMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{entity:mouseHoverEntity,worldPos:mouseWorldPos},corner:{entity:mouseHoverEntity,worldPos:mouseWorldPos},target:{entity:mouseHoverEntity,worldPos:mouseWorldPos},approximate:true});_this15._currentAngleMeasurement.clickable=false;_this15._currentAngleMeasurement.originVisible=true;_this15._currentAngleMeasurement.originWireVisible=true;_this15._currentAngleMeasurement.cornerVisible=false;_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.targetVisible=false;_this15._currentAngleMeasurement.angleVisible=false;_this15._mouseState=MOUSE_FINDING_CORNER;_this15.angleMeasurementsPlugin.fire("measurementStart",_this15._currentAngleMeasurement);}break;case MOUSE_FINDING_CORNER:if(mouseHovering){_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.targetVisible=true;_this15._currentAngleMeasurement.angleVisible=true;_this15._mouseState=MOUSE_FINDING_TARGET;}else{if(_this15._currentAngleMeasurement){_this15._currentAngleMeasurement.destroy();_this15._currentAngleMeasurement=null;_this15._mouseState=MOUSE_FINDING_ORIGIN;_this15.angleMeasurementsPlugin.fire("measurementCancel",_this15._currentAngleMeasurement);}}break;case MOUSE_FINDING_TARGET:if(mouseHovering){_this15._currentAngleMeasurement.targetVisible=true;_this15._currentAngleMeasurement.angleVisible=true;_this15._currentAngleMeasurement.clickable=true;_this15.angleMeasurementsPlugin.fire("measurementEnd",_this15._currentAngleMeasurement);_this15._currentAngleMeasurement=null;_this15._mouseState=MOUSE_FINDING_ORIGIN;}else{if(_this15._currentAngleMeasurement){_this15._currentAngleMeasurement.destroy();_this15._currentAngleMeasurement=null;_this15._mouseState=MOUSE_FINDING_ORIGIN;_this15.angleMeasurementsPlugin.fire("measurementCancel",_this15._currentAngleMeasurement);}}break;}});this._onMouseHoverOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){mouseHovering=false;if(pointerLens){pointerLens.visible=true;pointerLens.centerPos=event.cursorPos;pointerLens.cursorPos=event.cursorPos;pointerLens.snapped=false;}_this15.markerDiv.style.marginLeft="-100px";_this15.markerDiv.style.marginTop="-100px";if(_this15._currentAngleMeasurement){switch(_this15._mouseState){case MOUSE_FINDING_ORIGIN:_this15._currentAngleMeasurement.originVisible=false;break;case MOUSE_FINDING_CORNER:_this15._currentAngleMeasurement.cornerVisible=false;_this15._currentAngleMeasurement.originWireVisible=false;_this15._currentAngleMeasurement.targetVisible=false;_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.angleVisible=false;break;case MOUSE_FINDING_TARGET:_this15._currentAngleMeasurement.targetVisible=false;_this15._currentAngleMeasurement.targetWireVisible=false;_this15._currentAngleMeasurement.angleVisible=false;break;}canvas.style.cursor="default";}});this._active=true;}/**
|
|
2554
2554
|
* Deactivates this AngleMeasurementsMouseControl, making it unresponsive to input.
|
|
2555
2555
|
*
|
|
2556
2556
|
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsMouseControl.
|
|
@@ -13140,7 +13140,7 @@ var positions=K3D.edit.unwrap(m.i_verts,m.c_verts,3);var normals=K3D.edit.unwrap
|
|
|
13140
13140
|
* @param {HTMLImageElement} [cfg.image] An ````HTMLImageElement```` to source the image from. Overrides ````src````.
|
|
13141
13141
|
* @param {String} [cfg.imageData] Image data as a base64 encoded string.
|
|
13142
13142
|
* @param {String} [cfg.type="jpg"] Image MIME type. Accepted values are "jpg" and "png". Default is "jpg". Normally only needed with ````image```` or ````imageData````. Automatically inferred from file extension of ````src````, if the file has a recognized extension.
|
|
13143
|
-
*/function Bitmap(owner){var _this58;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Bitmap);_this58=_super42.call(this,owner,cfg);_this58._type=cfg.type||(cfg.src?cfg.src.split('.').pop():null)||"jpg";_this58._pos=math.vec3(cfg.pos||[0,0,0]);_this58._up=math.vec3(cfg.up||[0,1,0]);_this58._normal=math.vec3(cfg.normal||[0,0,1]);_this58._height=cfg.height||1.0;_this58._origin=math.vec3();_this58._rtcPos=math.vec3();_this58._imageSize=math.vec2();_this58._texture=new Texture(_assertThisInitialized(_this58));_this58._image=new Image();if(_this58._type!=="jpg"&&_this58._type!=="png"){_this58.error("Unsupported type - defaulting to \"jpg\"");_this58._type="jpg";}_this58._node=new Node$2(_assertThisInitialized(_this58),{matrix:math.inverseMat4(math.lookAtMat4v(_this58._pos,math.subVec3(_this58._pos,_this58._normal,math.mat4()),_this58._up,math.mat4())),children:[_this58._bitmapMesh=new Mesh(_assertThisInitialized(_this58),{scale:[1,1,1],rotation:[-90,0,0],collidable:cfg.collidable,pickable:cfg.pickable,opacity:cfg.opacity,clippable:cfg.clippable,geometry:new ReadableGeometry(_assertThisInitialized(_this58),buildPlaneGeometry({center:[0,0,0],xSize:1,zSize:1,xSegments:2,zSegments:2})),material:new PhongMaterial(_assertThisInitialized(_this58),{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:_this58._texture,emissiveMap:_this58._texture,backfaces:true})})]});if(cfg.image){_this58.image=cfg.image;}else if(cfg.src){_this58.src=cfg.src;}else if(cfg.imageData){_this58.imageData=cfg.imageData;}_this58.scene._bitmapCreated(_assertThisInitialized(_this58));return _this58;}/**
|
|
13143
|
+
*/function Bitmap(owner){var _this58;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Bitmap);_this58=_super42.call(this,owner,cfg);_this58._type=cfg.type||(cfg.src?cfg.src.split('.').pop():null)||"jpg";_this58._pos=math.vec3(cfg.pos||[0,0,0]);_this58._up=math.vec3(cfg.up||[0,1,0]);_this58._normal=math.vec3(cfg.normal||[0,0,1]);_this58._height=cfg.height||1.0;_this58._origin=math.vec3();_this58._rtcPos=math.vec3();_this58._imageSize=math.vec2();_this58._texture=new Texture(_assertThisInitialized(_this58),{flipY:true});_this58._image=new Image();if(_this58._type!=="jpg"&&_this58._type!=="png"){_this58.error("Unsupported type - defaulting to \"jpg\"");_this58._type="jpg";}_this58._node=new Node$2(_assertThisInitialized(_this58),{matrix:math.inverseMat4(math.lookAtMat4v(_this58._pos,math.subVec3(_this58._pos,_this58._normal,math.mat4()),_this58._up,math.mat4())),children:[_this58._bitmapMesh=new Mesh(_assertThisInitialized(_this58),{scale:[1,1,1],rotation:[-90,0,0],collidable:cfg.collidable,pickable:cfg.pickable,opacity:cfg.opacity,clippable:cfg.clippable,geometry:new ReadableGeometry(_assertThisInitialized(_this58),buildPlaneGeometry({center:[0,0,0],xSize:1,zSize:1,xSegments:2,zSegments:2})),material:new PhongMaterial(_assertThisInitialized(_this58),{diffuse:[0,0,0],ambient:[0,0,0],specular:[0,0,0],diffuseMap:_this58._texture,emissiveMap:_this58._texture,backfaces:true})})]});if(cfg.image){_this58.image=cfg.image;}else if(cfg.src){_this58.src=cfg.src;}else if(cfg.imageData){_this58.imageData=cfg.imageData;}_this58.scene._bitmapCreated(_assertThisInitialized(_this58));return _this58;}/**
|
|
13144
13144
|
* Sets if this ````Bitmap```` is visible or not.
|
|
13145
13145
|
*
|
|
13146
13146
|
* Default value is ````true````.
|
|
@@ -13290,7 +13290,11 @@ var positions=K3D.edit.unwrap(m.i_verts,m.c_verts,3);var normals=K3D.edit.unwrap
|
|
|
13290
13290
|
* Destroys this ````Bitmap````.
|
|
13291
13291
|
*
|
|
13292
13292
|
* Removes the ```Bitmap```` from {@link Scene#bitmaps}; causes Scene to fire a "bitmapDestroyed" event.
|
|
13293
|
-
*/,set:function set(opacity){this._bitmapMesh.opacity=opacity;}},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(Bitmap.prototype),"destroy",this).call(this);this.scene._bitmapDestroyed(this);}},{key:"_updateBitmapMeshScale",value:function _updateBitmapMeshScale(){var aspect=this._imageSize[1]/this._imageSize[0];this._bitmapMesh.scale=[this._height*aspect,1.0,this._height];}}]);return Bitmap;}(Component);/**
|
|
13293
|
+
*/,set:function set(opacity){this._bitmapMesh.opacity=opacity;}},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(Bitmap.prototype),"destroy",this).call(this);this.scene._bitmapDestroyed(this);}},{key:"_updateBitmapMeshScale",value:function _updateBitmapMeshScale(){var aspect=this._imageSize[1]/this._imageSize[0];this._bitmapMesh.scale=[this._height*aspect,1.0,this._height];}}]);return Bitmap;}(Component);var tempVec3a$v=math.vec3();var tempVec3b$q=math.vec3();var tempMat4a$h=math.mat4();/**
|
|
13294
|
+
* @private
|
|
13295
|
+
*/var FrustumPlane=/*#__PURE__*/function(){function FrustumPlane(){_classCallCheck(this,FrustumPlane);this.normal=math.vec3();this.offset=0;this.testVertex=math.vec3();}_createClass(FrustumPlane,[{key:"set",value:function set(nx,ny,nz,offset){var s=1.0/Math.sqrt(nx*nx+ny*ny+nz*nz);this.normal[0]=nx*s;this.normal[1]=ny*s;this.normal[2]=nz*s;this.offset=offset*s;this.testVertex[0]=this.normal[0]>=0.0?1:0;this.testVertex[1]=this.normal[1]>=0.0?1:0;this.testVertex[2]=this.normal[2]>=0.0?1:0;}}]);return FrustumPlane;}();/**
|
|
13296
|
+
* @private
|
|
13297
|
+
*/var Frustum=/*#__PURE__*/_createClass(function Frustum(){_classCallCheck(this,Frustum);this.planes=[new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane()];});Frustum.INSIDE=0;Frustum.INTERSECT=1;Frustum.OUTSIDE=2;/** @private */function setFrustum(frustum,viewMat,projMat){var m=math.mulMat4(projMat,viewMat,tempMat4a$h);var m0=m[0];var m1=m[1];var m2=m[2];var m3=m[3];var m4=m[4];var m5=m[5];var m6=m[6];var m7=m[7];var m8=m[8];var m9=m[9];var m10=m[10];var m11=m[11];var m12=m[12];var m13=m[13];var m14=m[14];var m15=m[15];frustum.planes[0].set(m3-m0,m7-m4,m11-m8,m15-m12);frustum.planes[1].set(m3+m0,m7+m4,m11+m8,m15+m12);frustum.planes[2].set(m3-m1,m7-m5,m11-m9,m15-m13);frustum.planes[3].set(m3+m1,m7+m5,m11+m9,m15+m13);frustum.planes[4].set(m3-m2,m7-m6,m11-m10,m15-m14);frustum.planes[5].set(m3+m2,m7+m6,m11+m10,m15+m14);}/** @private */function frustumIntersectsAABB3(frustum,aabb){var ret=Frustum.INSIDE;var min=tempVec3a$v;var max=tempVec3b$q;min[0]=aabb[0];min[1]=aabb[1];min[2]=aabb[2];max[0]=aabb[3];max[1]=aabb[4];max[2]=aabb[5];var bminmax=[min,max];for(var _i148=0;_i148<6;++_i148){var plane=frustum.planes[_i148];if(plane.normal[0]*bminmax[plane.testVertex[0]][0]+plane.normal[1]*bminmax[plane.testVertex[1]][1]+plane.normal[2]*bminmax[plane.testVertex[2]][2]+plane.offset<0.0){return Frustum.OUTSIDE;}if(plane.normal[0]*bminmax[1-plane.testVertex[0]][0]+plane.normal[1]*bminmax[1-plane.testVertex[1]][1]+plane.normal[2]*bminmax[1-plane.testVertex[2]][2]+plane.offset<0.0){ret=Frustum.INTERSECT;}}return ret;}/**
|
|
13294
13298
|
* A set of 3D line segments.
|
|
13295
13299
|
*
|
|
13296
13300
|
* * Creates a set of 3D line segments.
|
|
@@ -13355,7 +13359,7 @@ var positions=K3D.edit.unwrap(m.i_verts,m.c_verts,3);var normals=K3D.edit.unwrap
|
|
|
13355
13359
|
* @param {Number[]} [cfg.color=[0,0,0]] The color of this ````LineSet````. This is both emissive and diffuse.
|
|
13356
13360
|
* @param {Boolean} [cfg.visible=true] Indicates whether or not this ````LineSet```` is visible.
|
|
13357
13361
|
* @param {Number} [cfg.opacity=1.0] ````LineSet````'s initial opacity factor.
|
|
13358
|
-
*/function LineSet(owner){var _this61;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,LineSet);_this61=_super43.call(this,owner,cfg);_this61._positions=cfg.positions||[];_this61.
|
|
13362
|
+
*/function LineSet(owner){var _this61;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,LineSet);_this61=_super43.call(this,owner,cfg);_this61._positions=cfg.positions||[];var rtcPositions=new Float32Array(_this61._positions.length);var rtcCenter=math.vec3();var cellSize=100;var rtcNeeded=worldToRTCPositions(_this61._positions,new Float32Array(_this61._positions.length),rtcCenter,cellSize);if(cfg.indices){_this61._indices=cfg.indices;}else{_this61._indices=[];for(var _i149=0,len=_this61._positions.length/3-1;_i149<len;_i149+=2){_this61._indices.push(_i149);_this61._indices.push(_i149+1);}}_this61._mesh=new Mesh(_assertThisInitialized(_this61),{visible:cfg.visible,clippable:cfg.clippable,collidable:cfg.collidable,geometry:new VBOGeometry(_assertThisInitialized(_this61),{primitive:"lines",positions:rtcNeeded?rtcPositions:_this61._positions,indices:_this61._indices,origin:rtcNeeded?rtcCenter:null}),material:new PhongMaterial(_assertThisInitialized(_this61),{diffuse:cfg.color||[0,0,0],emissive:cfg.color||[0,0,0]})});_this61.scene._lineSetCreated(_assertThisInitialized(_this61));return _this61;}/**
|
|
13359
13363
|
* Sets if this ````LineSet```` is visible.
|
|
13360
13364
|
*
|
|
13361
13365
|
* Default value is ````true````.
|
|
@@ -13379,7 +13383,7 @@ var positions=K3D.edit.unwrap(m.i_verts,m.c_verts,3);var normals=K3D.edit.unwrap
|
|
|
13379
13383
|
* Destroys this ````LineSet````.
|
|
13380
13384
|
*
|
|
13381
13385
|
* Removes the ```LineSet```` from {@link Scene#lineSets}; causes Scene to fire a "lineSetDestroyed" event.
|
|
13382
|
-
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(LineSet.prototype),"destroy",this).call(this);this.scene._lineSetDestroyed(this);}}]);return LineSet;}(Component);var tempVec3$5=math.vec3();var tempVec3a$
|
|
13386
|
+
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(LineSet.prototype),"destroy",this).call(this);this.scene._lineSetDestroyed(this);}}]);return LineSet;}(Component);var tempVec3$5=math.vec3();var tempVec3a$u=math.vec3();var tempVec3b$p=math.vec3();var tempVec3c$m=math.vec3();/**
|
|
13383
13387
|
* {@link Viewer} plugin that saves and loads BCF viewpoints as JSON objects.
|
|
13384
13388
|
*
|
|
13385
13389
|
* [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/BCFViewpointsPlugin.png">](/examples/#BCF_SaveViewpoint)
|
|
@@ -13711,11 +13715,11 @@ var lookDirection=math.normalizeVec3(math.subVec3(camera.look,camera.eye,math.ve
|
|
|
13711
13715
|
lookDirection=YToZ(lookDirection);eye=YToZ(eye);up=YToZ(up);}var camera_view_point=xyzArrayToObject(math.addVec3(eye,realWorldOffset));if(camera.projection==="ortho"){bcfViewpoint.orthogonal_camera={camera_view_point:camera_view_point,camera_direction:xyzArrayToObject(lookDirection),camera_up_vector:xyzArrayToObject(up),view_to_world_scale:camera.ortho.scale};}else{bcfViewpoint.perspective_camera={camera_view_point:camera_view_point,camera_direction:xyzArrayToObject(lookDirection),camera_up_vector:xyzArrayToObject(up),field_of_view:camera.perspective.fov};}// Section planes
|
|
13712
13716
|
var sectionPlanes=scene.sectionPlanes;for(var id in sectionPlanes){if(sectionPlanes.hasOwnProperty(id)){var sectionPlane=sectionPlanes[id];if(!sectionPlane.active){continue;}var location=sectionPlane.pos;var _direction=void 0;if(reverseClippingPlanes){_direction=math.negateVec3(sectionPlane.dir,math.vec3());}else{_direction=sectionPlane.dir;}if(camera.yUp){// BCF is Z up
|
|
13713
13717
|
location=YToZ(location);_direction=YToZ(_direction);}math.addVec3(location,realWorldOffset);location=xyzArrayToObject(location);_direction=xyzArrayToObject(_direction);if(!bcfViewpoint.clipping_planes){bcfViewpoint.clipping_planes=[];}bcfViewpoint.clipping_planes.push({location:location,direction:_direction});}}// Lines
|
|
13714
|
-
var lineSets=scene.lineSets;for(var _id2 in lineSets){if(lineSets.hasOwnProperty(_id2)){var lineSet=lineSets[_id2];if(!bcfViewpoint.lines){bcfViewpoint.lines=[];}var positions=lineSet.positions;var indices=lineSet.indices;for(var
|
|
13718
|
+
var lineSets=scene.lineSets;for(var _id2 in lineSets){if(lineSets.hasOwnProperty(_id2)){var lineSet=lineSets[_id2];if(!bcfViewpoint.lines){bcfViewpoint.lines=[];}var positions=lineSet.positions;var indices=lineSet.indices;for(var _i150=0,len=indices.length/2;_i150<len;_i150++){var _a2=indices[_i150*2];var b=indices[_i150*2+1];bcfViewpoint.lines.push({start_point:{x:positions[_a2*3+0],y:positions[_a2*3+1],z:positions[_a2*3+2]},end_point:{x:positions[b*3+0],y:positions[b*3+1],z:positions[b*3+2]}});}}}// Bitmaps
|
|
13715
13719
|
var bitmaps=scene.bitmaps;for(var _id3 in bitmaps){if(bitmaps.hasOwnProperty(_id3)){var bitmap=bitmaps[_id3];var _location=bitmap.pos;var normal=bitmap.normal;var _up=bitmap.up;if(camera.yUp){// BCF is Z up
|
|
13716
13720
|
_location=YToZ(_location);normal=YToZ(normal);_up=YToZ(_up);}math.addVec3(_location,realWorldOffset);if(!bcfViewpoint.bitmaps){bcfViewpoint.bitmaps=[];}bcfViewpoint.bitmaps.push({bitmap_type:bitmap.type,bitmap_data:bitmap.imageData,location:xyzArrayToObject(_location),normal:xyzArrayToObject(normal),up:xyzArrayToObject(_up),height:bitmap.height});}}// Entity states
|
|
13717
13721
|
bcfViewpoint.components={visibility:{view_setup_hints:{spaces_visible:!!options.spacesVisible,space_boundaries_visible:!!options.spaceBoundariesVisible,openings_visible:!!options.openingsVisible}}};var opacityObjectIds=new Set(scene.opacityObjectIds);var xrayedObjectIds=new Set(scene.xrayedObjectIds);var colorizedObjectIds=new Set(scene.colorizedObjectIds);var coloringMap=Object.values(scene.objects).filter(function(entity){return opacityObjectIds.has(entity.id)||colorizedObjectIds.has(entity.id)||xrayedObjectIds.has(entity.id);}).reduce(function(coloringMap,entity){var color=colorizeToRGB(entity.colorize);var alpha;if(entity.xrayed){if(scene.xrayMaterial.fillAlpha===0.0&&scene.xrayMaterial.edgeAlpha!==0.0){// BCF can't deal with edges. If xRay is implemented only with edges, set an arbitrary opacity
|
|
13718
|
-
alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}alpha=Math.round(alpha*255).toString(16).padStart(2,"0");color=alpha+color;}else if(opacityObjectIds.has(entity.id)){alpha=Math.round(entity.opacity*255).toString(16).padStart(2,"0");color=alpha+color;}if(!coloringMap[color]){coloringMap[color]=[];}var objectId=entity.id;var originalSystemId=entity.originalSystemId;var component={ifc_guid:originalSystemId,originating_system:_this63.originatingSystem};if(originalSystemId!==objectId){component.authoring_tool_id=objectId;}coloringMap[color].push(component);return coloringMap;},{});var coloringArray=Object.entries(coloringMap).map(function(_ref6){var _ref7=_slicedToArray(_ref6,2),color=_ref7[0],components=_ref7[1];return{color:color,components:components};});bcfViewpoint.components.coloring=coloringArray;var objectIds=scene.objectIds;var visibleObjects=scene.visibleObjects;var visibleObjectIds=scene.visibleObjectIds;var invisibleObjectIds=objectIds.filter(function(id){return!visibleObjects[id];});var selectedObjectIds=scene.selectedObjectIds;if(options.defaultInvisible||visibleObjectIds.length<invisibleObjectIds.length){bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(visibleObjectIds);bcfViewpoint.components.visibility.default_visibility=false;}else{bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(invisibleObjectIds);bcfViewpoint.components.visibility.default_visibility=true;}bcfViewpoint.components.selection=this._createBCFComponents(selectedObjectIds);if(options.snapshot!==false){bcfViewpoint.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})};}return bcfViewpoint;}},{key:"_createBCFComponents",value:function _createBCFComponents(objectIds){var scene=this.viewer.scene;var components=[];for(var
|
|
13722
|
+
alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}alpha=Math.round(alpha*255).toString(16).padStart(2,"0");color=alpha+color;}else if(opacityObjectIds.has(entity.id)){alpha=Math.round(entity.opacity*255).toString(16).padStart(2,"0");color=alpha+color;}if(!coloringMap[color]){coloringMap[color]=[];}var objectId=entity.id;var originalSystemId=entity.originalSystemId;var component={ifc_guid:originalSystemId,originating_system:_this63.originatingSystem};if(originalSystemId!==objectId){component.authoring_tool_id=objectId;}coloringMap[color].push(component);return coloringMap;},{});var coloringArray=Object.entries(coloringMap).map(function(_ref6){var _ref7=_slicedToArray(_ref6,2),color=_ref7[0],components=_ref7[1];return{color:color,components:components};});bcfViewpoint.components.coloring=coloringArray;var objectIds=scene.objectIds;var visibleObjects=scene.visibleObjects;var visibleObjectIds=scene.visibleObjectIds;var invisibleObjectIds=objectIds.filter(function(id){return!visibleObjects[id];});var selectedObjectIds=scene.selectedObjectIds;if(options.defaultInvisible||visibleObjectIds.length<invisibleObjectIds.length){bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(visibleObjectIds);bcfViewpoint.components.visibility.default_visibility=false;}else{bcfViewpoint.components.visibility.exceptions=this._createBCFComponents(invisibleObjectIds);bcfViewpoint.components.visibility.default_visibility=true;}bcfViewpoint.components.selection=this._createBCFComponents(selectedObjectIds);if(options.snapshot!==false){bcfViewpoint.snapshot={snapshot_type:"png",snapshot_data:this.viewer.getSnapshot({format:"png"})};}return bcfViewpoint;}},{key:"_createBCFComponents",value:function _createBCFComponents(objectIds){var scene=this.viewer.scene;var components=[];for(var _i151=0,len=objectIds.length;_i151<len;_i151++){var objectId=objectIds[_i151];var entity=scene.objects[objectId];if(entity){var component={ifc_guid:entity.originalSystemId,originating_system:this.originatingSystem};if(entity.originalSystemId!==objectId){component.authoring_tool_id=objectId;}components.push(component);}}return components;}/**
|
|
13719
13723
|
* Sets viewer state to the given BCF viewpoint.
|
|
13720
13724
|
*
|
|
13721
13725
|
* Note that xeokit's {@link Camera#look} is the **point-of-interest**, whereas the BCF ````camera_direction```` is a
|
|
@@ -13737,9 +13741,9 @@ alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}alpha=Math.round(alpha*255).
|
|
|
13737
13741
|
* @param {Boolean} [options.reverseClippingPlanes=false] When ````true````, clipping planes are reversed (https://github.com/buildingSMART/BCF-XML/issues/193)
|
|
13738
13742
|
* @param {Boolean} [options.updateCompositeObjects=false] When ````true````, then when visibility and selection updates refer to composite objects (eg. an IfcBuildingStorey),
|
|
13739
13743
|
* then this method will apply the updates to objects within those composites.
|
|
13740
|
-
*/},{key:"setViewpoint",value:function setViewpoint(bcfViewpoint){var _this64=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(!bcfViewpoint){return;}var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;var rayCast=options.rayCast!==false;var immediate=options.immediate!==false;var reset=options.reset!==false;var realWorldOffset=scene.realWorldOffset;var reverseClippingPlanes=options.reverseClippingPlanes===true;scene.clearSectionPlanes();if(bcfViewpoint.clipping_planes&&bcfViewpoint.clipping_planes.length>0){bcfViewpoint.clipping_planes.forEach(function(e){var pos=xyzObjectToArray(e.location,tempVec3$5);var dir=xyzObjectToArray(e.direction,tempVec3$5);if(reverseClippingPlanes){math.negateVec3(dir);}math.subVec3(pos,realWorldOffset);if(camera.yUp){pos=ZToY(pos);dir=ZToY(dir);}new SectionPlane(scene,{pos:pos,dir:dir});});}scene.clearLines();if(bcfViewpoint.lines&&bcfViewpoint.lines.length>0){var positions=[];var indices=[];var
|
|
13744
|
+
*/},{key:"setViewpoint",value:function setViewpoint(bcfViewpoint){var _this64=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(!bcfViewpoint){return;}var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;var rayCast=options.rayCast!==false;var immediate=options.immediate!==false;var reset=options.reset!==false;var realWorldOffset=scene.realWorldOffset;var reverseClippingPlanes=options.reverseClippingPlanes===true;scene.clearSectionPlanes();if(bcfViewpoint.clipping_planes&&bcfViewpoint.clipping_planes.length>0){bcfViewpoint.clipping_planes.forEach(function(e){var pos=xyzObjectToArray(e.location,tempVec3$5);var dir=xyzObjectToArray(e.direction,tempVec3$5);if(reverseClippingPlanes){math.negateVec3(dir);}math.subVec3(pos,realWorldOffset);if(camera.yUp){pos=ZToY(pos);dir=ZToY(dir);}new SectionPlane(scene,{pos:pos,dir:dir});});}scene.clearLines();if(bcfViewpoint.lines&&bcfViewpoint.lines.length>0){var positions=[];var indices=[];var _i152=0;bcfViewpoint.lines.forEach(function(e){if(!e.start_point){return;}if(!e.end_point){return;}positions.push(e.start_point.x);positions.push(e.start_point.y);positions.push(e.start_point.z);positions.push(e.end_point.x);positions.push(e.end_point.y);positions.push(e.end_point.z);indices.push(_i152++);indices.push(_i152++);});new LineSet(scene,{positions:positions,indices:indices,clippable:false,collidable:true});}scene.clearBitmaps();if(bcfViewpoint.bitmaps&&bcfViewpoint.bitmaps.length>0){bcfViewpoint.bitmaps.forEach(function(e){var bitmap_type=e.bitmap_type||"jpg";// "jpg" | "png"
|
|
13741
13745
|
var bitmap_data=e.bitmap_data;// base64
|
|
13742
|
-
var location=xyzObjectToArray(e.location,tempVec3a$
|
|
13746
|
+
var location=xyzObjectToArray(e.location,tempVec3a$u);var normal=xyzObjectToArray(e.normal,tempVec3b$p);var up=xyzObjectToArray(e.up,tempVec3c$m);var height=e.height||1;if(!bitmap_type){return;}if(!bitmap_data){return;}if(!location){return;}if(!normal){return;}if(!up){return;}if(camera.yUp){location=ZToY(location);normal=ZToY(normal);up=ZToY(up);}new Bitmap(scene,{src:bitmap_data,type:bitmap_type,pos:location,normal:normal,up:up,clippable:false,collidable:true,height:height});});}if(reset){scene.setObjectsXRayed(scene.xrayedObjectIds,false);scene.setObjectsHighlighted(scene.highlightedObjectIds,false);scene.setObjectsSelected(scene.selectedObjectIds,false);}if(bcfViewpoint.components){if(bcfViewpoint.components.visibility){if(!bcfViewpoint.components.visibility.default_visibility){scene.setObjectsVisible(scene.objectIds,false);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this64._withBCFComponent(options,component,function(entity){return entity.visible=true;});});}}else{scene.setObjectsVisible(scene.objectIds,true);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this64._withBCFComponent(options,component,function(entity){return entity.visible=false;});});}}var view_setup_hints=bcfViewpoint.components.visibility.view_setup_hints;if(view_setup_hints){if(view_setup_hints.spaces_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"),false);}if(view_setup_hints.openings_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"),false);}if(view_setup_hints.space_boundaries_visible!==undefined);}}if(bcfViewpoint.components.selection){scene.setObjectsSelected(scene.selectedObjectIds,false);bcfViewpoint.components.selection.forEach(function(component){return _this64._withBCFComponent(options,component,function(entity){return entity.selected=true;});});}if(bcfViewpoint.components.coloring){bcfViewpoint.components.coloring.forEach(function(coloring){var color=coloring.color;var alpha=0;var alphaDefined=false;if(color.length===8){alpha=parseInt(color.substring(0,2),16)/256;if(alpha<=1.0&&alpha>=0.95){alpha=1.0;}color=color.substring(2);alphaDefined=true;}var colorize=[parseInt(color.substring(0,2),16)/256,parseInt(color.substring(2,4),16)/256,parseInt(color.substring(4,6),16)/256];coloring.components.map(function(component){return _this64._withBCFComponent(options,component,function(entity){entity.colorize=colorize;if(alphaDefined){entity.opacity=alpha;}});});});}}if(bcfViewpoint.perspective_camera||bcfViewpoint.orthogonal_camera){var eye;var look;var up;var projection;if(bcfViewpoint.perspective_camera){eye=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_up_vector,tempVec3$5);camera.perspective.fov=bcfViewpoint.perspective_camera.field_of_view;projection="perspective";}else{eye=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_up_vector,tempVec3$5);camera.ortho.scale=bcfViewpoint.orthogonal_camera.view_to_world_scale;projection="ortho";}math.subVec3(eye,realWorldOffset);if(camera.yUp){eye=ZToY(eye);look=ZToY(look);up=ZToY(up);}if(rayCast){var hit=scene.pick({pickSurface:true,// <<------ This causes picking to find the intersection point on the entity
|
|
13743
13747
|
origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3$5);}else{look=math.addVec3(eye,look,tempVec3$5);}if(immediate){camera.eye=eye;camera.look=look;camera.up=up;camera.projection=projection;}else{viewer.cameraFlight.flyTo({eye:eye,look:look,up:up,duration:options.duration,projection:projection});}}}},{key:"_withBCFComponent",value:function _withBCFComponent(options,component,callback){var viewer=this.viewer;var scene=viewer.scene;if(component.authoring_tool_id&&component.originating_system===this.originatingSystem){var id=component.authoring_tool_id;var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var metaObject=viewer.metaScene.metaObjects[id];if(metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);return;}}}if(component.ifc_guid){var originalSystemId=component.ifc_guid;var _entity=scene.objects[originalSystemId];if(_entity){callback(_entity);return;}if(options.updateCompositeObjects){var _metaObject=viewer.metaScene.metaObjects[originalSystemId];if(_metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(originalSystemId),callback);return;}}Object.keys(scene.models).forEach(function(modelId){var id=math.globalizeObjectId(modelId,originalSystemId);var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var _metaObject2=viewer.metaScene.metaObjects[id];if(_metaObject2){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);}}});}}/**
|
|
13744
13748
|
* Destroys this BCFViewpointsPlugin.
|
|
13745
13749
|
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(BCFViewpointsPlugin.prototype),"destroy",this).call(this);}}]);return BCFViewpointsPlugin;}(Plugin);function xyzArrayToObject(arr){return{"x":arr[0],"y":arr[1],"z":arr[2]};}function xyzObjectToArray(xyz,arry){arry=new Float64Array(3);arry[0]=xyz.x;arry[1]=xyz.y;arry[2]=xyz.z;return arry;}function YToZ(vec){return new Float64Array([vec[0],-vec[2],vec[1]]);}function ZToY(vec){return new Float64Array([vec[0],vec[2],-vec[1]]);}function colorizeToRGB(color){var rgb="";rgb+=Math.round(color[0]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[1]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[2]*255).toString(16).padStart(2,"0");return rgb;}var distVec3=math.vec3();var lengthWire=function lengthWire(x1,y1,x2,y2){var a=x1-x2;var b=y1-y2;return Math.sqrt(a*a+b*b);};/**
|
|
@@ -14328,11 +14332,11 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
14328
14332
|
* Shows all or hides the angle label of each {@link DistanceMeasurement}.
|
|
14329
14333
|
*
|
|
14330
14334
|
* @param {Boolean} labelsShown Whether or not to show the labels.
|
|
14331
|
-
*/},{key:"setLabelsShown",value:function setLabelsShown(labelsShown){for(var
|
|
14335
|
+
*/},{key:"setLabelsShown",value:function setLabelsShown(labelsShown){for(var _i153=0,_Object$entries2=Object.entries(this.measurements);_i153<_Object$entries2.length;_i153++){var _Object$entries2$_i=_slicedToArray(_Object$entries2[_i153],2),key=_Object$entries2$_i[0],measurement=_Object$entries2$_i[1];measurement.labelShown=labelsShown;}}/**
|
|
14332
14336
|
* Shows all or hides the axis wires of each {@link DistanceMeasurement}.
|
|
14333
14337
|
*
|
|
14334
14338
|
* @param {Boolean} labelsShown Whether or not to show the axis wires.
|
|
14335
|
-
*/},{key:"setAxisVisible",value:function setAxisVisible(axisVisible){for(var
|
|
14339
|
+
*/},{key:"setAxisVisible",value:function setAxisVisible(axisVisible){for(var _i154=0,_Object$entries3=Object.entries(this.measurements);_i154<_Object$entries3.length;_i154++){var _Object$entries3$_i=_slicedToArray(_Object$entries3[_i154],2),key=_Object$entries3$_i[0],measurement=_Object$entries3$_i[1];measurement.axisVisible=axisVisible;}this.defaultAxisVisible=axisVisible;}/**
|
|
14336
14340
|
* Gets if the axis wires of each {@link DistanceMeasurement} are visible.
|
|
14337
14341
|
*
|
|
14338
14342
|
* @returns {Boolean} Whether or not the axis wires are visible.
|
|
@@ -14892,7 +14896,7 @@ subs[subId]={callback:callback};this._eventSubEvents[subId]=event;var value=this
|
|
|
14892
14896
|
*
|
|
14893
14897
|
* @param {String} subId Subscription ID
|
|
14894
14898
|
*/},{key:"off",value:function off(subId){if(subId===undefined||subId===null){return;}if(!this._eventSubEvents){return;}var event=this._eventSubEvents[subId];if(event){delete this._eventSubEvents[subId];var subs=this._eventSubs[event];if(subs){delete subs[subId];}this._eventSubIDMap.removeItem(subId);// Release subId
|
|
14895
|
-
}}}]);return LocaleService;}();function resolvePath$1(key,json){if(json[key]){return json[key];}var parts=key.split(".");var obj=json;for(var
|
|
14899
|
+
}}}]);return LocaleService;}();function resolvePath$1(key,json){if(json[key]){return json[key];}var parts=key.split(".");var obj=json;for(var _i155=0,len=parts.length;obj&&_i155<len;_i155++){var part=parts[_i155];obj=obj[part];}return obj;}function vsprintf(msg){var args=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];return msg.replace(/\{\{|\}\}|\{(\d+)\}/g,function(m,n){if(m==="{{"){return"{";}if(m==="}}"){return"}";}return args[n];});}/**
|
|
14896
14900
|
* @desc Abstract base class for curve classes.
|
|
14897
14901
|
*/var Curve=/*#__PURE__*/function(_Component28){_inherits(Curve,_Component28);var _super50=_createSuper(Curve);/**
|
|
14898
14902
|
* @constructor
|
|
@@ -14993,7 +14997,7 @@ comparison=arcLengths[i]-targetArcLength;if(comparison<0){low=i+1;}else if(compa
|
|
|
14993
14997
|
*
|
|
14994
14998
|
* @param {Number} t Position to get point at.
|
|
14995
14999
|
* @returns {Number[]} Point at the given position.
|
|
14996
|
-
*/},{key:"getPoint",value:function getPoint(t){var points=this.points;if(points.length<3){this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].");return;}var point=(points.length-1)*t;var intPoint=Math.floor(point);var weight=point-intPoint;var point0=points[intPoint===0?intPoint:intPoint-1];var point1=points[intPoint];var point2=points[intPoint>points.length-2?points.length-1:intPoint+1];var point3=points[intPoint>points.length-3?points.length-1:intPoint+2];var vector=math.vec3();vector[0]=math.catmullRomInterpolate(point0[0],point1[0],point2[0],point3[0],weight);vector[1]=math.catmullRomInterpolate(point0[1],point1[1],point2[1],point3[1],weight);vector[2]=math.catmullRomInterpolate(point0[2],point1[2],point2[2],point3[2],weight);return vector;}},{key:"getJSON",value:function getJSON(){return{points:points,t:this._t};}}]);return SplineCurve;}(Curve);var tempVec3a$
|
|
15000
|
+
*/},{key:"getPoint",value:function getPoint(t){var points=this.points;if(points.length<3){this.error("Can't sample point from SplineCurve - not enough points on curve - returning [0,0,0].");return;}var point=(points.length-1)*t;var intPoint=Math.floor(point);var weight=point-intPoint;var point0=points[intPoint===0?intPoint:intPoint-1];var point1=points[intPoint];var point2=points[intPoint>points.length-2?points.length-1:intPoint+1];var point3=points[intPoint>points.length-3?points.length-1:intPoint+2];var vector=math.vec3();vector[0]=math.catmullRomInterpolate(point0[0],point1[0],point2[0],point3[0],weight);vector[1]=math.catmullRomInterpolate(point0[1],point1[1],point2[1],point3[1],weight);vector[2]=math.catmullRomInterpolate(point0[2],point1[2],point2[2],point3[2],weight);return vector;}},{key:"getJSON",value:function getJSON(){return{points:points,t:this._t};}}]);return SplineCurve;}(Curve);var tempVec3a$t=math.vec3();/**
|
|
14997
15001
|
* @desc Defines a sequence of frames along which a {@link CameraPathAnimation} can animate a {@link Camera}.
|
|
14998
15002
|
*
|
|
14999
15003
|
* See {@link CameraPathAnimation} for usage.
|
|
@@ -15037,11 +15041,11 @@ comparison=arcLengths[i]-targetArcLength;if(comparison<0){low=i+1;}else if(compa
|
|
|
15037
15041
|
* Adds multiple frames to this CameraPath, each frame specified as a set of values for eye, look and up vectors at a given time instant.
|
|
15038
15042
|
*
|
|
15039
15043
|
* @param {{t:Number, eye:Object, look:Object, up: Object}[]} frames Frames to add to this CameraPath.
|
|
15040
|
-
*/},{key:"addFrames",value:function addFrames(frames){var frame;for(var
|
|
15044
|
+
*/},{key:"addFrames",value:function addFrames(frames){var frame;for(var _i156=0,len=frames.length;_i156<len;_i156++){frame=frames[_i156];this.addFrame(frame.t||0,frame.eye,frame.look,frame.up);}}/**
|
|
15041
15045
|
* Sets the position of the {@link Camera} to a position interpolated within this CameraPath at the given time instant.
|
|
15042
15046
|
*
|
|
15043
15047
|
* @param {Number} t Time instant.
|
|
15044
|
-
*/},{key:"loadFrame",value:function loadFrame(t){var camera=this.scene.camera;t=t/(this._frames[this._frames.length-1].t-this._frames[0].t);t=t<0.0?0.0:t>1.0?1.0:t;camera.eye=this._eyeCurve.getPoint(t,tempVec3a$
|
|
15048
|
+
*/},{key:"loadFrame",value:function loadFrame(t){var camera=this.scene.camera;t=t/(this._frames[this._frames.length-1].t-this._frames[0].t);t=t<0.0?0.0:t>1.0?1.0:t;camera.eye=this._eyeCurve.getPoint(t,tempVec3a$t);camera.look=this._lookCurve.getPoint(t,tempVec3a$t);camera.up=this._upCurve.getPoint(t,tempVec3a$t);}/**
|
|
15045
15049
|
* Gets eye, look and up vectors on this CameraPath at a given instant.
|
|
15046
15050
|
*
|
|
15047
15051
|
* @param {Number} t Time instant.
|
|
@@ -15053,7 +15057,7 @@ comparison=arcLengths[i]-targetArcLength;if(comparison<0){low=i+1;}else if(compa
|
|
|
15053
15057
|
* when animated by {@link CameraPathAnimation}, the {@link Camera} will move along the path at a constant rate.
|
|
15054
15058
|
*
|
|
15055
15059
|
* @param {Number} duration The total duration for this CameraPath.
|
|
15056
|
-
*/},{key:"smoothFrameTimes",value:function smoothFrameTimes(duration){var numFrames=this._frames.length;if(numFrames===0){return;}var vec=math.vec3();var totalLen=0;this._frames[0].t=0;var lens=[];for(var
|
|
15060
|
+
*/},{key:"smoothFrameTimes",value:function smoothFrameTimes(duration){var numFrames=this._frames.length;if(numFrames===0){return;}var vec=math.vec3();var totalLen=0;this._frames[0].t=0;var lens=[];for(var _i157=1,len=this._frames.length;_i157<len;_i157++){var lenVec=math.lenVec3(math.subVec3(this._frames[_i157].eye,this._frames[_i157-1].eye,vec));lens[_i157]=lenVec;totalLen+=lenVec;}for(var _i158=1,_len17=this._frames.length;_i158<_len17;_i158++){var interFrameRate=lens[_i158]/totalLen*duration;this._frames[_i158].t=this._frames[_i158-1].t+interFrameRate;}}/**
|
|
15057
15061
|
* Removes all frames from this CameraPath.
|
|
15058
15062
|
*/},{key:"clearFrames",value:function clearFrames(){this._frames=[];this._eyeCurve.points=[];this._lookCurve.points=[];this._upCurve.points=[];}}]);return CameraPath;}(Component);var tempVec3$4=math.vec3();var newLook=math.vec3();var newEye=math.vec3();var newUp=math.vec3();var newLookEyeVec=math.vec3();/**
|
|
15059
15063
|
* @desc Jumps or flies the {@link Scene}'s {@link Camera} to a given target.
|
|
@@ -15391,7 +15395,7 @@ t/=d;return-c*t*(t-2)+b;}},{key:"_easeInCubic",value:function _easeInCubic(t,b,c
|
|
|
15391
15395
|
* @param {Number} frameIdx Index of the frame to scrub to.
|
|
15392
15396
|
*/},{key:"scrubToFrame",value:function scrubToFrame(frameIdx){var cameraPath=this._cameraPath;if(!cameraPath){return;}var camera=this.scene.camera;if(!camera){return;}var frame=cameraPath.frames[frameIdx];if(!frame){this.error("playToFrame - frame index out of range: "+frameIdx);return;}cameraPath.loadFrame(this._t);this.state=CameraPathAnimation.SCRUBBING;}/**
|
|
15393
15397
|
* Stops playing this CameraPathAnimation.
|
|
15394
|
-
*/},{key:"stop",value:function stop(){this.state=CameraPathAnimation.SCRUBBING;this.fire("stopped");}},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CameraPathAnimation.prototype),"destroy",this).call(this);this.scene.off(this._tick);}}]);return CameraPathAnimation;}(Component);CameraPathAnimation.STOPPED=0;CameraPathAnimation.SCRUBBING=1;CameraPathAnimation.PLAYING=2;CameraPathAnimation.PLAYING_TO=3;var tempVec3$3=math.vec3();var tempVec3b$
|
|
15398
|
+
*/},{key:"stop",value:function stop(){this.state=CameraPathAnimation.SCRUBBING;this.fire("stopped");}},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CameraPathAnimation.prototype),"destroy",this).call(this);this.scene.off(this._tick);}}]);return CameraPathAnimation;}(Component);CameraPathAnimation.STOPPED=0;CameraPathAnimation.SCRUBBING=1;CameraPathAnimation.PLAYING=2;CameraPathAnimation.PLAYING_TO=3;var tempVec3$3=math.vec3();var tempVec3b$o=math.vec3();math.vec3();var zeroVec$2=math.vec3([0,-1,0]);var tempQuat=math.vec4([0,0,0,1]);/**
|
|
15395
15399
|
* @desc A plane-shaped 3D object containing a bitmap image.
|
|
15396
15400
|
*
|
|
15397
15401
|
* Use ````ImagePlane```` to embed bitmap images in your scenes.
|
|
@@ -15627,7 +15631,7 @@ t/=d;return-c*t*(t-2)+b;}},{key:"_easeInCubic",value:function _easeInCubic(t,b,c
|
|
|
15627
15631
|
* Default is ````true````.
|
|
15628
15632
|
*
|
|
15629
15633
|
* @type {Boolean}
|
|
15630
|
-
*/,set:function set(dir){this._dir.set(dir||[0,0,-1]);if(dir){var _origin5=this.scene.center;var negDir=[-this._dir[0],-this._dir[1],-this._dir[2]];math.subVec3(_origin5,this.position,tempVec3$3);var dist=-math.dotVec3(negDir,tempVec3$3);math.normalizeVec3(negDir);math.mulVec3Scalar(negDir,dist,tempVec3b$
|
|
15634
|
+
*/,set:function set(dir){this._dir.set(dir||[0,0,-1]);if(dir){var _origin5=this.scene.center;var negDir=[-this._dir[0],-this._dir[1],-this._dir[2]];math.subVec3(_origin5,this.position,tempVec3$3);var dist=-math.dotVec3(negDir,tempVec3$3);math.normalizeVec3(negDir);math.mulVec3Scalar(negDir,dist,tempVec3b$o);math.vec3PairToQuaternion(zeroVec$2,dir,tempQuat);this._node.quaternion=tempQuat;}}},{key:"collidable",get:/**
|
|
15631
15635
|
* Gets if this ````ImagePlane```` is included in boundary calculations.
|
|
15632
15636
|
*
|
|
15633
15637
|
* Default is ````true````.
|
|
@@ -15872,7 +15876,7 @@ if(!self._shadowProjMatrix){self._shadowProjMatrix=math.identityMat4();}var _can
|
|
|
15872
15876
|
* @returns {Boolean} ````true```` if this PointLight casts shadows.
|
|
15873
15877
|
*/function get(){return this._state.castsShadow;}/**
|
|
15874
15878
|
* Destroys this PointLight.
|
|
15875
|
-
*/,set:function set(castsShadow){castsShadow=!!castsShadow;if(this._state.castsShadow===castsShadow){return;}this._state.castsShadow=castsShadow;this._shadowViewMatrixDirty=true;this.glRedraw();}},{key:"destroy",value:function destroy(){var camera=this.scene.camera;var canvas=this.scene.canvas;camera.off(this._onCameraViewMatrix);camera.off(this._onCameraProjMatrix);canvas.off(this._onCanvasBoundary);_get(_getPrototypeOf(PointLight.prototype),"destroy",this).call(this);this._state.destroy();if(this._shadowRenderBuf){this._shadowRenderBuf.destroy();}this.scene._lightDestroyed(this);this.glRedraw();}}]);return PointLight;}(Light);function ensureImageSizePowerOfTwo(image){if(!isPowerOfTwo(image.width)||!isPowerOfTwo(image.height)){var _canvas5=document.createElement("canvas");_canvas5.width=nextHighestPowerOfTwo(image.width);_canvas5.height=nextHighestPowerOfTwo(image.height);var ctx=_canvas5.getContext("2d");ctx.drawImage(image,0,0,image.width,image.height,0,0,_canvas5.width,_canvas5.height);image=_canvas5;}return image;}function isPowerOfTwo(x){return(x&x-1)===0;}function nextHighestPowerOfTwo(x){--x;for(var
|
|
15879
|
+
*/,set:function set(castsShadow){castsShadow=!!castsShadow;if(this._state.castsShadow===castsShadow){return;}this._state.castsShadow=castsShadow;this._shadowViewMatrixDirty=true;this.glRedraw();}},{key:"destroy",value:function destroy(){var camera=this.scene.camera;var canvas=this.scene.canvas;camera.off(this._onCameraViewMatrix);camera.off(this._onCameraProjMatrix);canvas.off(this._onCanvasBoundary);_get(_getPrototypeOf(PointLight.prototype),"destroy",this).call(this);this._state.destroy();if(this._shadowRenderBuf){this._shadowRenderBuf.destroy();}this.scene._lightDestroyed(this);this.glRedraw();}}]);return PointLight;}(Light);function ensureImageSizePowerOfTwo(image){if(!isPowerOfTwo(image.width)||!isPowerOfTwo(image.height)){var _canvas5=document.createElement("canvas");_canvas5.width=nextHighestPowerOfTwo(image.width);_canvas5.height=nextHighestPowerOfTwo(image.height);var ctx=_canvas5.getContext("2d");ctx.drawImage(image,0,0,image.width,image.height,0,0,_canvas5.width,_canvas5.height);image=_canvas5;}return image;}function isPowerOfTwo(x){return(x&x-1)===0;}function nextHighestPowerOfTwo(x){--x;for(var _i159=1;_i159<32;_i159<<=1){x=x|x>>_i159;}return x+1;}/**
|
|
15876
15880
|
* @desc A cube texture map.
|
|
15877
15881
|
*/var CubeTexture=/*#__PURE__*/function(_Component33){_inherits(CubeTexture,_Component33);var _super57=_createSuper(CubeTexture);/**
|
|
15878
15882
|
* @constructor
|
|
@@ -15889,7 +15893,7 @@ if(!self._shadowProjMatrix){self._shadowProjMatrix=math.identityMat4();}var _can
|
|
|
15889
15893
|
// this._state.texture.setImage(this._images, this._state);
|
|
15890
15894
|
// this._state.texture.setProps(this._state);
|
|
15891
15895
|
// } else
|
|
15892
|
-
if(this._src){this._loadSrc(this._src);}}},{key:"_loadSrc",value:function _loadSrc(src){var self=this;var gl=this.scene.canvas.gl;this._images=[];var loadFailed=false;var numLoaded=0;var _loop3=function _loop3(
|
|
15896
|
+
if(this._src){this._loadSrc(this._src);}}},{key:"_loadSrc",value:function _loadSrc(src){var self=this;var gl=this.scene.canvas.gl;this._images=[];var loadFailed=false;var numLoaded=0;var _loop3=function _loop3(_i160){var image=new Image();image.onload=function(){var _image=image;var index=_i160;return function(){if(loadFailed){return;}_image=ensureImageSizePowerOfTwo(_image);self._images[index]=_image;numLoaded++;if(numLoaded===6){var texture=self._state.texture;if(!texture){texture=new Texture2D({gl:gl,target:gl.TEXTURE_CUBE_MAP});self._state.texture=texture;}texture.setImage(self._images,self._state);self.fire("loaded",self._src,false);self.glRedraw();}};}();image.onerror=function(){loadFailed=true;};image.src=src[_i160];};for(var _i160=0;_i160<src.length;_i160++){_loop3(_i160);}}/**
|
|
15893
15897
|
* Destroys this CubeTexture
|
|
15894
15898
|
*
|
|
15895
15899
|
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CubeTexture.prototype),"destroy",this).call(this);if(this._state.texture){this._state.texture.destroy();}stats.memory.textures--;this._state.destroy();}}]);return CubeTexture;}(Component);/**
|
|
@@ -16158,11 +16162,7 @@ this._occluded=!visible;this._mesh.visible=this._visible&&!this._occluded;_get(_
|
|
|
16158
16162
|
* This is a factor in range ````[0..1]```` which multiplies by the rendered fragment alphas.
|
|
16159
16163
|
*
|
|
16160
16164
|
* @type {Number}
|
|
16161
|
-
*/function get(){return this._mesh.opacity;},set:function set(opacity){this._mesh.opacity=opacity;}},{key:"_updatePlaneSizeFromImage",value:function _updatePlaneSizeFromImage(){var halfSize=this._size*0.5;var width=this._imageSize[0];var height=this._imageSize[1];var aspect=height/width;if(width>height){this._geometry.positions=[halfSize,halfSize*aspect,0,-halfSize,halfSize*aspect,0,-halfSize,-halfSize*aspect,0,halfSize,-halfSize*aspect,0];}else{this._geometry.positions=[halfSize/aspect,halfSize,0,-halfSize/aspect,halfSize,0,-halfSize/aspect,-halfSize,0,halfSize/aspect,-halfSize,0];}}}]);return SpriteMarker;}(Marker)
|
|
16162
|
-
* @private
|
|
16163
|
-
*/var FrustumPlane=/*#__PURE__*/function(){function FrustumPlane(){_classCallCheck(this,FrustumPlane);this.normal=math.vec3();this.offset=0;this.testVertex=math.vec3();}_createClass(FrustumPlane,[{key:"set",value:function set(nx,ny,nz,offset){var s=1.0/Math.sqrt(nx*nx+ny*ny+nz*nz);this.normal[0]=nx*s;this.normal[1]=ny*s;this.normal[2]=nz*s;this.offset=offset*s;this.testVertex[0]=this.normal[0]>=0.0?1:0;this.testVertex[1]=this.normal[1]>=0.0?1:0;this.testVertex[2]=this.normal[2]>=0.0?1:0;}}]);return FrustumPlane;}();/**
|
|
16164
|
-
* @private
|
|
16165
|
-
*/var Frustum=/*#__PURE__*/_createClass(function Frustum(){_classCallCheck(this,Frustum);this.planes=[new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane(),new FrustumPlane()];});Frustum.INSIDE=0;Frustum.INTERSECT=1;Frustum.OUTSIDE=2;/** @private */function setFrustum(frustum,viewMat,projMat){var m=math.mulMat4(projMat,viewMat,tempMat4a$h);var m0=m[0];var m1=m[1];var m2=m[2];var m3=m[3];var m4=m[4];var m5=m[5];var m6=m[6];var m7=m[7];var m8=m[8];var m9=m[9];var m10=m[10];var m11=m[11];var m12=m[12];var m13=m[13];var m14=m[14];var m15=m[15];frustum.planes[0].set(m3-m0,m7-m4,m11-m8,m15-m12);frustum.planes[1].set(m3+m0,m7+m4,m11+m8,m15+m12);frustum.planes[2].set(m3-m1,m7-m5,m11-m9,m15-m13);frustum.planes[3].set(m3+m1,m7+m5,m11+m9,m15+m13);frustum.planes[4].set(m3-m2,m7-m6,m11-m10,m15-m14);frustum.planes[5].set(m3+m2,m7+m6,m11+m10,m15+m14);}/** @private */function frustumIntersectsAABB3(frustum,aabb){var ret=Frustum.INSIDE;var min=tempVec3a$t;var max=tempVec3b$o;min[0]=aabb[0];min[1]=aabb[1];min[2]=aabb[2];max[0]=aabb[3];max[1]=aabb[4];max[2]=aabb[5];var bminmax=[min,max];for(var _i160=0;_i160<6;++_i160){var plane=frustum.planes[_i160];if(plane.normal[0]*bminmax[plane.testVertex[0]][0]+plane.normal[1]*bminmax[plane.testVertex[1]][1]+plane.normal[2]*bminmax[plane.testVertex[2]][2]+plane.offset<0.0){return Frustum.OUTSIDE;}if(plane.normal[0]*bminmax[1-plane.testVertex[0]][0]+plane.normal[1]*bminmax[1-plane.testVertex[1]][1]+plane.normal[2]*bminmax[1-plane.testVertex[2]][2]+plane.offset<0.0){ret=Frustum.INTERSECT;}}return ret;}/**
|
|
16165
|
+
*/function get(){return this._mesh.opacity;},set:function set(opacity){this._mesh.opacity=opacity;}},{key:"_updatePlaneSizeFromImage",value:function _updatePlaneSizeFromImage(){var halfSize=this._size*0.5;var width=this._imageSize[0];var height=this._imageSize[1];var aspect=height/width;if(width>height){this._geometry.positions=[halfSize,halfSize*aspect,0,-halfSize,halfSize*aspect,0,-halfSize,-halfSize*aspect,0,halfSize,-halfSize*aspect,0];}else{this._geometry.positions=[halfSize/aspect,halfSize,0,-halfSize/aspect,halfSize,0,-halfSize/aspect,-halfSize,0,halfSize/aspect,-halfSize,0];}}}]);return SpriteMarker;}(Marker);/**
|
|
16166
16166
|
* @desc Saves and restores the state of a {@link Scene}'s {@link Camera}.
|
|
16167
16167
|
*
|
|
16168
16168
|
* ## See Also
|
|
@@ -17915,7 +17915,10 @@ var edgeIndex=void 0;if((edgeIndex=edgeSearch(ii0,ii1))>=0){if(alreadyOutputEdge
|
|
|
17915
17915
|
*/var TrianglesDataTextureColorRenderer=/*#__PURE__*/function(){function TrianglesDataTextureColorRenderer(scene,withSAO){_classCallCheck(this,TrianglesDataTextureColorRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureColorRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this._uTexturePerObjectIdPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this._uTexturePerObjectIdColorsAndFlags,this._uTextureModelMatrices,this._uTexturePerObjectIdOffsets);var rtcViewMatrix;var rtcCameraEye;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$k;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$g);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(camera.viewMatrix,rtcOrigin,tempMat4a$b);rtcCameraEye=tempVec3c$e;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=camera.viewMatrix;rtcCameraEye=camera.eye;}gl.uniformMatrix4fv(this._uSceneModelWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3d$a);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
|
|
17916
17916
|
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
|
|
17917
17917
|
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
|
|
17918
|
-
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];var lights=lightsState.lights;var light;for(var _i328=0,len=lights.length;_i328<len;_i328++){light=lights[_i328];switch(light.type){case"dir":this._uLightColor[_i328]=program.getLocation("lightColor"+_i328);this._uLightPos[_i328]=null;this._uLightDir[_i328]=program.getLocation("lightDir"+_i328);break;case"point":this._uLightColor[_i328]=program.getLocation("lightColor"+_i328);this._uLightPos[_i328]=program.getLocation("lightPos"+_i328);this._uLightDir[_i328]=null;this._uLightAttenuation[_i328]=program.getLocation("lightAttenuation"+_i328);break;case"spot":this._uLightColor[_i328]=program.getLocation("lightColor"+_i328);this._uLightPos[_i328]=program.getLocation("lightPos"+_i328);this._uLightDir[_i328]=program.getLocation("lightDir"+_i328);this._uLightAttenuation[_i328]=program.getLocation("lightAttenuation"+_i328);break;}}this._uSceneModelWorldMatrix=program.getLocation("sceneModelWorldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i329=0,_len81=scene._sectionPlanesState.sectionPlanes.length;_i329<_len81;_i329++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i329),pos:program.getLocation("sectionPlanePos"+_i329),dir:program.getLocation("sectionPlaneDir"+_i329)});}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uTexturePerObjectIdPositionsDecodeMatrix="uTexturePerObjectIdPositionsDecodeMatrix";this._uTexturePerObjectIdColorsAndFlags="uTexturePerObjectIdColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTextureModelMatrices="uTextureModelMatrices";this._uTexturePerObjectIdOffsets="uTexturePerObjectIdOffsets";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lights=scene._lightsState.lights;var project=scene.camera.project;program.bind();if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,scene._lightsState.getAmbientColorAndIntensity());}for(var _i330=0,len=lights.length;_i330<len;_i330++){var light=lights[_i330];if(this._uLightColor[_i330]){gl.uniform4f(this._uLightColor[_i330],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i330]){gl.uniform3fv(this._uLightPos[_i330],light.pos);if(this._uLightAttenuation[_i330]){gl.uniform1f(this._uLightAttenuation[_i330],light.attenuation);}}if(this._uLightDir[_i330]){gl.uniform3fv(this._uLightDir[_i330],light.dir);}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4a$6[0]=viewportWidth;tempVec4a$6[1]=viewportHeight;tempVec4a$6[2]=sao.blendCutoff;tempVec4a$6[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4a$6);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,10);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.sectionPlanes.length>0;var light;var src=[];src.push("#version 300 es");src.push("// TrianglesDataTextureColorRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;")
|
|
17918
|
+
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];var lights=lightsState.lights;var light;for(var _i328=0,len=lights.length;_i328<len;_i328++){light=lights[_i328];switch(light.type){case"dir":this._uLightColor[_i328]=program.getLocation("lightColor"+_i328);this._uLightPos[_i328]=null;this._uLightDir[_i328]=program.getLocation("lightDir"+_i328);break;case"point":this._uLightColor[_i328]=program.getLocation("lightColor"+_i328);this._uLightPos[_i328]=program.getLocation("lightPos"+_i328);this._uLightDir[_i328]=null;this._uLightAttenuation[_i328]=program.getLocation("lightAttenuation"+_i328);break;case"spot":this._uLightColor[_i328]=program.getLocation("lightColor"+_i328);this._uLightPos[_i328]=program.getLocation("lightPos"+_i328);this._uLightDir[_i328]=program.getLocation("lightDir"+_i328);this._uLightAttenuation[_i328]=program.getLocation("lightAttenuation"+_i328);break;}}this._uSceneModelWorldMatrix=program.getLocation("sceneModelWorldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i329=0,_len81=scene._sectionPlanesState.sectionPlanes.length;_i329<_len81;_i329++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i329),pos:program.getLocation("sectionPlanePos"+_i329),dir:program.getLocation("sectionPlaneDir"+_i329)});}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uTexturePerObjectIdPositionsDecodeMatrix="uTexturePerObjectIdPositionsDecodeMatrix";this._uTexturePerObjectIdColorsAndFlags="uTexturePerObjectIdColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTextureModelMatrices="uTextureModelMatrices";this._uTexturePerObjectIdOffsets="uTexturePerObjectIdOffsets";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lights=scene._lightsState.lights;var project=scene.camera.project;program.bind();if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,scene._lightsState.getAmbientColorAndIntensity());}for(var _i330=0,len=lights.length;_i330<len;_i330++){var light=lights[_i330];if(this._uLightColor[_i330]){gl.uniform4f(this._uLightColor[_i330],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i330]){gl.uniform3fv(this._uLightPos[_i330],light.pos);if(this._uLightAttenuation[_i330]){gl.uniform1f(this._uLightAttenuation[_i330],light.attenuation);}}if(this._uLightDir[_i330]){gl.uniform3fv(this._uLightDir[_i330],light.dir);}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4a$6[0]=viewportWidth;tempVec4a$6[1]=viewportHeight;tempVec4a$6[2]=sao.blendCutoff;tempVec4a$6[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4a$6);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,10);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.sectionPlanes.length>0;var light;var src=[];src.push("#version 300 es");src.push("// TrianglesDataTextureColorRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");// if (scene.entityOffsetsEnabled) {
|
|
17919
|
+
// src.push("in vec3 offset;");
|
|
17920
|
+
// }
|
|
17921
|
+
src.push("uniform mat4 sceneModelWorldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uTexturePerObjectIdPositionsDecodeMatrix;");src.push("uniform lowp usampler2D uTexturePerObjectIdColorsAndFlags;");src.push("uniform highp sampler2D uTexturePerObjectIdOffsets;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform highp sampler2D uTextureModelMatrices;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("uniform vec4 lightAmbient;");for(var _i331=0,len=lightsState.lights.length;_i331<len;_i331++){light=lightsState.lights[_i331];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i331+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i331+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i331+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i331+";");src.push("uniform vec3 lightDir"+_i331+";");}}if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vColor;");src.push("void main(void) {");// constants
|
|
17919
17922
|
src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
|
|
17920
17923
|
src.push("int h_packed_object_id_index = (polygonIndex >> 3) & 4095;");src.push("int v_packed_object_id_index = (polygonIndex >> 3) >> 12;");src.push("int objectIndex = int(texelFetch(uTexturePerPolygonIdPortionIds, ivec2(h_packed_object_id_index, v_packed_object_id_index), 0).r);");src.push("ivec2 objectIndexCoords = ivec2(objectIndex % 512, objectIndex / 512);");// get flags & flags2
|
|
17921
17924
|
src.push("uvec4 flags = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
@@ -17952,12 +17955,15 @@ src.push("ivec4 packedVertexBase = ivec4(texelFetch (uTexturePerObjectIdColorsAn
|
|
|
17952
17955
|
src.push("positions[0] = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH.r, indexPositionV.r), 0));");src.push("positions[1] = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH.g, indexPositionV.g), 0));");src.push("positions[2] = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH.b, indexPositionV.b), 0));");// get normal
|
|
17953
17956
|
src.push("vec3 normal = normalize(cross(positions[2] - positions[0], positions[1] - positions[0]));");src.push("vec3 position;");src.push("position = positions[gl_VertexID % 3];");src.push("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*positionsDecodeMatrix)) * vec4(normal,1)).xyz);");// when the geometry is not solid, if needed, flip the triangle winding
|
|
17954
17957
|
src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(worldMatrix * positionsDecodeMatrix) * vec4(uCameraEyeRtc, 1)).xyz;");src.push("if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("viewNormal = -viewNormal;");src.push("}");src.push("} else {");src.push("if (viewNormal.z < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("viewNormal = -viewNormal;");src.push("}");src.push("}");src.push("}");src.push("vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");// get XYZ offset
|
|
17955
|
-
src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Triangles dataTexture draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i336=0,len=sectionPlanesState.sectionPlanes.length;_i336<len;_i336++){src.push("uniform bool sectionPlaneActive"+_i336+";");src.push("uniform vec3 sectionPlanePos"+_i336+";");src.push("uniform vec3 sectionPlaneDir"+_i336+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i337=0,_len84=sectionPlanesState.sectionPlanes.length;_i337<_len84;_i337++){src.push("if (sectionPlaneActive"+_i337+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i337+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i337+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = color;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureSilhouetteRenderer;}();var defaultColor=new Float32Array([0,0,0,1]);var tempVec3a$i=math.vec3();var tempVec3b$e=math.vec3();
|
|
17958
|
+
src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Triangles dataTexture draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i336=0,len=sectionPlanesState.sectionPlanes.length;_i336<len;_i336++){src.push("uniform bool sectionPlaneActive"+_i336+";");src.push("uniform vec3 sectionPlanePos"+_i336+";");src.push("uniform vec3 sectionPlaneDir"+_i336+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i337=0,_len84=sectionPlanesState.sectionPlanes.length;_i337<_len84;_i337++){src.push("if (sectionPlaneActive"+_i337+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i337+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i337+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = color;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureSilhouetteRenderer;}();var defaultColor=new Float32Array([0,0,0,1]);var tempVec3a$i=math.vec3();var tempVec3b$e=math.vec3();var tempVec3d$8=math.vec3();var tempMat4a$9=math.mat4();/**
|
|
17956
17959
|
* @private
|
|
17957
|
-
*/var TrianglesDataTextureEdgesRenderer=/*#__PURE__*/function(){function TrianglesDataTextureEdgesRenderer(scene){_classCallCheck(this,TrianglesDataTextureEdgesRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureEdgesRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var model=dataTextureLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate(dataTextureLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this._uTexturePerObjectIdPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this._uTexturePerObjectIdColorsAndFlags,this._uTextureModelMatrices,this._uTexturePerObjectIdOffsets);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$i;if(gotOrigin){var rotatedOrigin=
|
|
17960
|
+
*/var TrianglesDataTextureEdgesRenderer=/*#__PURE__*/function(){function TrianglesDataTextureEdgesRenderer(scene){_classCallCheck(this,TrianglesDataTextureEdgesRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureEdgesRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var model=dataTextureLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate(dataTextureLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this._uTexturePerObjectIdPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this._uTexturePerObjectIdColorsAndFlags,this._uTextureModelMatrices,this._uTexturePerObjectIdOffsets);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$i;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$e);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$9);}else{rtcViewMatrix=viewMatrix;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uSceneModelWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);if(renderPass===RENDER_PASSES.EDGES_XRAYED){var material=scene.xrayMaterial._state;var edgeColor=material.edgeColor;var edgeAlpha=material.edgeAlpha;gl.uniform4f(this._uColor,edgeColor[0],edgeColor[1],edgeColor[2],edgeAlpha);}else if(renderPass===RENDER_PASSES.EDGES_HIGHLIGHTED){var _material5=scene.highlightMaterial._state;var _edgeColor=_material5.edgeColor;var _edgeAlpha=_material5.edgeAlpha;gl.uniform4f(this._uColor,_edgeColor[0],_edgeColor[1],_edgeColor[2],_edgeAlpha);}else if(renderPass===RENDER_PASSES.EDGES_SELECTED){var _material6=scene.selectedMaterial._state;var _edgeColor2=_material6.edgeColor;var _edgeAlpha2=_material6.edgeAlpha;gl.uniform4f(this._uColor,_edgeColor2[0],_edgeColor2[1],_edgeColor2[2],_edgeAlpha2);}else{gl.uniform4fv(this._uColor,defaultColor);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3d$8);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}if(state.numEdgeIndices8Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,8// 8 bits edge indices
|
|
17958
17961
|
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices8Bits);}if(state.numEdgeIndices16Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,16// 16 bits edge indices
|
|
17959
17962
|
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices16Bits);}if(state.numEdgeIndices32Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,32// 32 bits edge indices
|
|
17960
|
-
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uColor=program.getLocation("color");this._uSceneModelWorldMatrix=program.getLocation("sceneModelWorldMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i338=0,len=scene._sectionPlanesState.sectionPlanes.length;_i338<len;_i338++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i338),pos:program.getLocation("sectionPlanePos"+_i338),dir:program.getLocation("sectionPlaneDir"+_i338)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uTexturePerObjectIdPositionsDecodeMatrix="uTexturePerObjectIdPositionsDecodeMatrix";this._uTexturePerObjectIdColorsAndFlags="uTexturePerObjectIdColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdEdgeIndices="uTexturePerPolygonIdEdgeIndices";this._uTexturePerEdgeIdPortionIds="uTexturePerEdgeIdPortionIds";this._uTextureModelMatrices="uTextureModelMatrices";this._uTexturePerObjectIdOffsets="uTexturePerObjectIdOffsets";}},{key:"_bindProgram",value:function _bindProgram(){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var project=scene.camera.project;program.bind();if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry edges drawing vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;")
|
|
17963
|
+
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uColor=program.getLocation("color");this._uSceneModelWorldMatrix=program.getLocation("sceneModelWorldMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i338=0,len=scene._sectionPlanesState.sectionPlanes.length;_i338<len;_i338++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i338),pos:program.getLocation("sectionPlanePos"+_i338),dir:program.getLocation("sectionPlaneDir"+_i338)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uTexturePerObjectIdPositionsDecodeMatrix="uTexturePerObjectIdPositionsDecodeMatrix";this._uTexturePerObjectIdColorsAndFlags="uTexturePerObjectIdColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdEdgeIndices="uTexturePerPolygonIdEdgeIndices";this._uTexturePerEdgeIdPortionIds="uTexturePerEdgeIdPortionIds";this._uTextureModelMatrices="uTextureModelMatrices";this._uTexturePerObjectIdOffsets="uTexturePerObjectIdOffsets";}},{key:"_bindProgram",value:function _bindProgram(){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var project=scene.camera.project;program.bind();if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry edges drawing vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");// if (scene.entityOffsetsEnabled) {
|
|
17964
|
+
// src.push("in vec3 offset;");
|
|
17965
|
+
// }
|
|
17966
|
+
src.push("uniform mat4 sceneModelWorldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uTexturePerObjectIdPositionsDecodeMatrix;");src.push("uniform lowp usampler2D uTexturePerObjectIdColorsAndFlags;");src.push("uniform highp sampler2D uTexturePerObjectIdOffsets;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdEdgeIndices;");src.push("uniform mediump usampler2D uTexturePerEdgeIdPortionIds;");src.push("uniform highp sampler2D uTextureModelMatrices;");src.push("uniform vec4 color;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vColor;");src.push("void main(void) {");// constants
|
|
17961
17967
|
src.push("int edgeIndex = gl_VertexID / 2;");// get packed object-id
|
|
17962
17968
|
src.push("int h_packed_object_id_index = (edgeIndex >> 3) & 4095;");src.push("int v_packed_object_id_index = (edgeIndex >> 3) >> 12;");src.push("int objectIndex = int(texelFetch(uTexturePerEdgeIdPortionIds, ivec2(h_packed_object_id_index, v_packed_object_id_index), 0).r);");src.push("ivec2 objectIndexCoords = ivec2(objectIndex % 512, objectIndex / 512);");// get flags & flags2
|
|
17963
17969
|
src.push("uvec4 flags = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// flags.z = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
|
|
@@ -17968,9 +17974,9 @@ src.push("} else {");// get vertex base
|
|
|
17968
17974
|
src.push("ivec4 packedVertexBase = ivec4(texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");src.push("ivec4 packedEdgeIndexBaseOffset = ivec4(texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+6, objectIndexCoords.y), 0));");src.push("int edgeIndexBaseOffset = (packedEdgeIndexBaseOffset.r << 24) + (packedEdgeIndexBaseOffset.g << 16) + (packedEdgeIndexBaseOffset.b << 8) + packedEdgeIndexBaseOffset.a;");src.push("int h_index = (edgeIndex - edgeIndexBaseOffset) & 4095;");src.push("int v_index = (edgeIndex - edgeIndexBaseOffset) >> 12;");src.push("ivec3 vertexIndices = ivec3(texelFetch(uTexturePerPolygonIdEdgeIndices, ivec2(h_index, v_index), 0));");src.push("ivec3 uniqueVertexIndexes = vertexIndices + (packedVertexBase.r << 24) + (packedVertexBase.g << 16) + (packedVertexBase.b << 8) + packedVertexBase.a;");src.push("int indexPositionH = uniqueVertexIndexes[gl_VertexID % 2] & 4095;");src.push("int indexPositionV = uniqueVertexIndexes[gl_VertexID % 2] >> 12;");src.push("mat4 positionsDecodeMatrix = mat4 (texelFetch (uTexturePerObjectIdPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectIdPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectIdPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectIdPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");// get flags & flags2
|
|
17969
17975
|
src.push("uvec4 flags = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// get position
|
|
17970
17976
|
src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");src.push("vec4 worldPosition = sceneModelWorldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");// get XYZ offset
|
|
17971
|
-
src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("vColor = vec4(color.r, color.g, color.b, color.a);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Batched geometry edges drawing fragment shader");if(scene.logarithmicDepthBufferEnabled){src.push("#extension GL_EXT_frag_depth : enable");}src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i339=0,len=sectionPlanesState.sectionPlanes.length;_i339<len;_i339++){src.push("uniform bool sectionPlaneActive"+_i339+";");src.push("uniform vec3 sectionPlanePos"+_i339+";");src.push("uniform vec3 sectionPlaneDir"+_i339+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i340=0,_len85=sectionPlanesState.sectionPlanes.length;_i340<_len85;_i340++){src.push("if (sectionPlaneActive"+_i340+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i340+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i340+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vColor;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureEdgesRenderer;}();var tempVec3a$h=math.vec3();var tempVec3b$d=math.vec3();var tempVec3c$c=math.vec3();var tempMat4a$8=math.mat4();/**
|
|
17977
|
+
src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz + vec3(110.0,50.0, 10.0);");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("vColor = vec4(color.r, color.g, color.b, color.a);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Batched geometry edges drawing fragment shader");if(scene.logarithmicDepthBufferEnabled){src.push("#extension GL_EXT_frag_depth : enable");}src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i339=0,len=sectionPlanesState.sectionPlanes.length;_i339<len;_i339++){src.push("uniform bool sectionPlaneActive"+_i339+";");src.push("uniform vec3 sectionPlanePos"+_i339+";");src.push("uniform vec3 sectionPlaneDir"+_i339+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i340=0,_len85=sectionPlanesState.sectionPlanes.length;_i340<_len85;_i340++){src.push("if (sectionPlaneActive"+_i340+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i340+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i340+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vColor;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureEdgesRenderer;}();var tempVec3a$h=math.vec3();var tempVec3b$d=math.vec3();var tempVec3c$c=math.vec3();var tempMat4a$8=math.mat4();/**
|
|
17972
17978
|
* @private
|
|
17973
|
-
*/var TrianglesDataTextureEdgesColorRenderer=/*#__PURE__*/function(){function TrianglesDataTextureEdgesColorRenderer(scene){_classCallCheck(this,TrianglesDataTextureEdgesColorRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureEdgesColorRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var model=dataTextureLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this._uTexturePerObjectIdPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this._uTexturePerObjectIdColorsAndFlags,this._uTextureModelMatrices,this._uTexturePerObjectIdOffsets);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$h;if(gotOrigin){var rotatedOrigin=
|
|
17979
|
+
*/var TrianglesDataTextureEdgesColorRenderer=/*#__PURE__*/function(){function TrianglesDataTextureEdgesColorRenderer(scene){_classCallCheck(this,TrianglesDataTextureEdgesColorRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureEdgesColorRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var model=dataTextureLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this._uTexturePerObjectIdPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this._uTexturePerObjectIdColorsAndFlags,this._uTextureModelMatrices,this._uTexturePerObjectIdOffsets);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$h;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$d);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$8);}else{rtcViewMatrix=viewMatrix;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uSceneModelWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3c$c);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}if(state.numEdgeIndices8Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,8// 8 bits edge indices
|
|
17974
17980
|
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices8Bits);}if(state.numEdgeIndices16Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,16// 16 bits edge indices
|
|
17975
17981
|
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices16Bits);}if(state.numEdgeIndices32Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,32// 32 bits edge indices
|
|
17976
17982
|
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uSceneModelWorldMatrix=program.getLocation("sceneModelWorldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i341=0,len=scene._sectionPlanesState.sectionPlanes.length;_i341<len;_i341++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i341),pos:program.getLocation("sectionPlanePos"+_i341),dir:program.getLocation("sectionPlaneDir"+_i341)});}//this._aOffset = program.getAttribute("offset");
|
|
@@ -17988,8 +17994,7 @@ src.push("uvec4 flags = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(obj
|
|
|
17988
17994
|
src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");// get color
|
|
17989
17995
|
src.push("uvec4 color = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+0, objectIndexCoords.y), 0);");src.push("if (color.a == 0u) {");src.push(" gl_Position = vec4(3.0, 3.0, 3.0, 1.0);");// Cull vertex
|
|
17990
17996
|
src.push(" return;");src.push("};");src.push(" vec4 worldPosition = sceneModelWorldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");// get XYZ offset
|
|
17991
|
-
src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);")
|
|
17992
|
-
src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("vec4 rgb = vec4(color.rgba);");//src.push("vColor = vec4(float(color.r-100.0) / 255.0, float(color.g-100.0) / 255.0, float(color.b-100.0) / 255.0, float(color.a) / 255.0);");
|
|
17997
|
+
src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("vec4 rgb = vec4(color.rgba);");//src.push("vColor = vec4(float(color.r-100.0) / 255.0, float(color.g-100.0) / 255.0, float(color.b-100.0) / 255.0, float(color.a) / 255.0);");
|
|
17993
17998
|
src.push("vColor = vec4(float(rgb.r*0.5) / 255.0, float(rgb.g*0.5) / 255.0, float(rgb.b*0.5) / 255.0, float(rgb.a) / 255.0);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// TrianglesDataTextureEdgesColorRenderer");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i342=0,len=sectionPlanesState.sectionPlanes.length;_i342<len;_i342++){src.push("uniform bool sectionPlaneActive"+_i342+";");src.push("uniform vec3 sectionPlanePos"+_i342+";");src.push("uniform vec3 sectionPlaneDir"+_i342+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i343=0,_len86=sectionPlanesState.sectionPlanes.length;_i343<_len86;_i343++){src.push("if (sectionPlaneActive"+_i343+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i343+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i343+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){// src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
17994
17999
|
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vColor;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureEdgesColorRenderer;}();var tempVec3a$g=math.vec3();var tempVec3b$c=math.vec3();var tempVec3c$b=math.vec3();var tempMat4a$7=math.mat4();/**
|
|
17995
18000
|
* @private
|
|
@@ -20025,7 +20030,7 @@ var defaultColorTexture=new SceneModelTexture({id:DEFAULT_COLOR_TEXTURE_ID,textu
|
|
|
20025
20030
|
* @param {Number[]} [cfg.uvDecodeMatrix] A 3x3 matrix for decompressing ````uvCompressed````.
|
|
20026
20031
|
* @param {Number[]} [cfg.indices] Array of primitive connectivity indices. Not required for `points` primitives.
|
|
20027
20032
|
* @param {Number[]} [cfg.edgeIndices] Array of edge line indices. Used only with 'triangles', 'solid' and 'surface' primitives. Automatically generated internally if not supplied, using the optional ````edgeThreshold```` given to the ````SceneModel```` constructor.
|
|
20028
|
-
*/},{key:"createGeometry",value:function createGeometry(cfg){if(cfg.id===undefined||cfg.id===null){this.error("[createGeometry] Config missing: id");return;}if(this._geometries[cfg.id]){this.error("[createGeometry] Geometry already created: "+cfg.id);return;}if(cfg.primitive===undefined||cfg.primitive===null){cfg.primitive="triangles";}if(cfg.primitive!=="points"&&cfg.primitive!=="lines"&&cfg.primitive!=="triangles"&&cfg.primitive!=="solid"&&cfg.primitive!=="surface"){this.error("[createGeometry] Unsupported value for 'primitive': '".concat(primitive,"' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'."));return;}if(!cfg.positions&&!cfg.positionsCompressed&&!cfg.buckets){this.error("[createGeometry] Param expected: `positions`, `positionsCompressed' or 'buckets");return null;}if(cfg.positionsCompressed&&!cfg.positionsDecodeMatrix&&!cfg.positionsDecodeBoundary){this.error("[createGeometry] Param expected: `positionsDecodeMatrix` or 'positionsDecodeBoundary' (required for `positionsCompressed')");return null;}if(cfg.positionsDecodeMatrix&&cfg.positionsDecodeBoundary){this.error("[createGeometry] Only one of these params expected: `positionsDecodeMatrix` or 'positionsDecodeBoundary' (required for `positionsCompressed')");return null;}if(cfg.uvCompressed&&!cfg.uvDecodeMatrix){this.error("[createGeometry] Param expected: `uvDecodeMatrix` (required for `uvCompressed')");return null;}if(!cfg.buckets&&!cfg.indices&&cfg.primitive!=="points"){this.error("[createGeometry] Param expected: indices (required for '".concat(cfg.primitive,"' primitive type)"));return null;}if(cfg.positionsDecodeBoundary){cfg.positionsDecodeMatrix=createPositionsDecodeMatrix(cfg.positionsDecodeBoundary,math.mat4());}if(cfg.positions){var aabb=math.collapseAABB3();cfg.positionsDecodeMatrix=math.mat4();math.expandAABB3Points3(aabb,cfg.positions);cfg.positionsCompressed=quantizePositions(cfg.positions,aabb,cfg.positionsDecodeMatrix);}else{cfg.positionsDecodeMatrix=new Float64Array(cfg.positionsDecodeMatrix);cfg.positionsCompressed=new Uint16Array(cfg.positionsCompressed);}if(cfg.colorsCompressed&&cfg.colorsCompressed.length>0){cfg.colorsCompressed=new Uint8Array(cfg.colorsCompressed);}else if(cfg.colors&&cfg.colors.length>0){var colors=cfg.colors;var colorsCompressed=new Uint8Array(colors.length);for(var _i387=0,len=colors.length;_i387<len;_i387++){colorsCompressed[_i387]=colors[_i387]*255;}cfg.colorsCompressed=colorsCompressed;}if(!cfg.buckets&&!cfg.edgeIndices&&(cfg.primitive==="triangles"||cfg.primitive==="solid"||cfg.primitive==="surface")){if(cfg.positions){cfg.edgeIndices=buildEdgeIndices(cfg.positions,cfg.indices,null,5.0);}else{cfg.edgeIndices=buildEdgeIndices(cfg.positionsCompressed,cfg.indices,cfg.positionsDecodeMatrix,2.0);}}if(cfg.buckets){this._dtxBuckets[cfg.id]=cfg.buckets;}if(cfg.uv){var bounds=geometryCompressionUtils.getUVBounds(cfg.uv);var result=geometryCompressionUtils.compressUVs(cfg.uv,bounds.min,bounds.max);cfg.uvCompressed=result.quantized;cfg.uvDecodeMatrix=result.decodeMatrix;}else if(cfg.uvCompressed){cfg.uvCompressed=new Uint16Array(cfg.uvCompressed);cfg.uvDecodeMatrix=new Float64Array(cfg.uvDecodeMatrix);}if(cfg.normals){// HACK
|
|
20033
|
+
*/},{key:"createGeometry",value:function createGeometry(cfg){if(cfg.id===undefined||cfg.id===null){this.error("[createGeometry] Config missing: id");return;}if(this._geometries[cfg.id]){this.error("[createGeometry] Geometry already created: "+cfg.id);return;}if(cfg.primitive===undefined||cfg.primitive===null){cfg.primitive="triangles";}if(cfg.primitive!=="points"&&cfg.primitive!=="lines"&&cfg.primitive!=="triangles"&&cfg.primitive!=="solid"&&cfg.primitive!=="surface"){this.error("[createGeometry] Unsupported value for 'primitive': '".concat(cfg.primitive,"' - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'. Defaulting to 'triangles'."));return;}if(!cfg.positions&&!cfg.positionsCompressed&&!cfg.buckets){this.error("[createGeometry] Param expected: `positions`, `positionsCompressed' or 'buckets");return null;}if(cfg.positionsCompressed&&!cfg.positionsDecodeMatrix&&!cfg.positionsDecodeBoundary){this.error("[createGeometry] Param expected: `positionsDecodeMatrix` or 'positionsDecodeBoundary' (required for `positionsCompressed')");return null;}if(cfg.positionsDecodeMatrix&&cfg.positionsDecodeBoundary){this.error("[createGeometry] Only one of these params expected: `positionsDecodeMatrix` or 'positionsDecodeBoundary' (required for `positionsCompressed')");return null;}if(cfg.uvCompressed&&!cfg.uvDecodeMatrix){this.error("[createGeometry] Param expected: `uvDecodeMatrix` (required for `uvCompressed')");return null;}if(!cfg.buckets&&!cfg.indices&&cfg.primitive!=="points"){this.error("[createGeometry] Param expected: indices (required for '".concat(cfg.primitive,"' primitive type)"));return null;}if(cfg.positionsDecodeBoundary){cfg.positionsDecodeMatrix=createPositionsDecodeMatrix(cfg.positionsDecodeBoundary,math.mat4());}if(cfg.positions){var aabb=math.collapseAABB3();cfg.positionsDecodeMatrix=math.mat4();math.expandAABB3Points3(aabb,cfg.positions);cfg.positionsCompressed=quantizePositions(cfg.positions,aabb,cfg.positionsDecodeMatrix);}else{cfg.positionsDecodeMatrix=new Float64Array(cfg.positionsDecodeMatrix);cfg.positionsCompressed=new Uint16Array(cfg.positionsCompressed);}if(cfg.colorsCompressed&&cfg.colorsCompressed.length>0){cfg.colorsCompressed=new Uint8Array(cfg.colorsCompressed);}else if(cfg.colors&&cfg.colors.length>0){var colors=cfg.colors;var colorsCompressed=new Uint8Array(colors.length);for(var _i387=0,len=colors.length;_i387<len;_i387++){colorsCompressed[_i387]=colors[_i387]*255;}cfg.colorsCompressed=colorsCompressed;}if(!cfg.buckets&&!cfg.edgeIndices&&(cfg.primitive==="triangles"||cfg.primitive==="solid"||cfg.primitive==="surface")){if(cfg.positions){cfg.edgeIndices=buildEdgeIndices(cfg.positions,cfg.indices,null,5.0);}else{cfg.edgeIndices=buildEdgeIndices(cfg.positionsCompressed,cfg.indices,cfg.positionsDecodeMatrix,2.0);}}if(cfg.buckets){this._dtxBuckets[cfg.id]=cfg.buckets;}if(cfg.uv){var bounds=geometryCompressionUtils.getUVBounds(cfg.uv);var result=geometryCompressionUtils.compressUVs(cfg.uv,bounds.min,bounds.max);cfg.uvCompressed=result.quantized;cfg.uvDecodeMatrix=result.decodeMatrix;}else if(cfg.uvCompressed){cfg.uvCompressed=new Uint16Array(cfg.uvCompressed);cfg.uvDecodeMatrix=new Float64Array(cfg.uvDecodeMatrix);}if(cfg.normals){// HACK
|
|
20029
20034
|
cfg.normals=null;}this._geometries[cfg.id]=cfg;this._numTriangles+=cfg.indices?Math.round(cfg.indices.length/3):0;this.numGeometries++;}/**
|
|
20030
20035
|
* Creates a texture within this SceneModel.
|
|
20031
20036
|
*
|
|
@@ -20452,7 +20457,7 @@ var camera=scene.camera;math.subVec3(camera.eye,camera.look,[]);controllers.came
|
|
|
20452
20457
|
// up: camera.up,
|
|
20453
20458
|
aabb:aabb});// TODO: Option to back off to fit AABB in view
|
|
20454
20459
|
}else{// Fly to fit target boundary in view
|
|
20455
|
-
controllers.cameraFlight.flyTo({aabb:aabb});}};canvas.addEventListener("mousemove",this._canvasMouseMoveHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}if(leftDown||rightDown){return;}var hoverSubs=cameraControl.hasSubs("hover");var hoverOutSubs=cameraControl.hasSubs("hoverOut");var hoverOffSubs=cameraControl.hasSubs("hoverOff");var hoverSurfaceSubs=cameraControl.hasSubs("hoverSurface");var hoverSnapOrSurfaceSubs=cameraControl.hasSubs("hoverSnapOrSurface");if(hoverSubs||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(_this97._lastPickedEntityId!==pickedEntityId){if(_this97._lastPickedEntityId!==undefined){cameraControl.fire("hoverOut",{// Hovered off an entity
|
|
20460
|
+
controllers.cameraFlight.flyTo({aabb:aabb});}};canvas.addEventListener("mousemove",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(_this97._lastPickedEntityId!==pickedEntityId){if(_this97._lastPickedEntityId!==undefined){cameraControl.fire("hoverOut",{// Hovered off an entity
|
|
20456
20461
|
entity:scene.objects[_this97._lastPickedEntityId]},true);}cameraControl.fire("hoverEnter",pickController.pickResult,true);// Hovering over a new entity
|
|
20457
20462
|
_this97._lastPickedEntityId=pickedEntityId;}}cameraControl.fire("hover",pickController.pickResult,true);if(pickController.pickResult.worldPos||pickController.pickResult.snappedWorldPos){// Hovering the surface of an entity
|
|
20458
20463
|
cameraControl.fire("hoverSurface",pickController.pickResult,true);}}else{if(_this97._lastPickedEntityId!==undefined){cameraControl.fire("hoverOut",{// Hovered off an entity
|