@xeokit/xeokit-sdk 2.4.0-alpha-78 → 2.4.0-alpha-79

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.
@@ -2715,7 +2715,7 @@ if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._rende
2715
2715
  * Destroys this Annotation.
2716
2716
  *
2717
2717
  * You can also call {@link AnnotationsPlugin#destroyAnnotation}.
2718
- */},{key:"destroy",value:function destroy(){if(this._marker){if(!this._markerExternal){this._marker.parentNode.removeChild(this._marker);}else{this._marker.removeEventListener("click",this._onMouseClickedExternalMarker);this._marker.removeEventListener("mouseenter",this._onMouseEnterExternalMarker);this._marker.removeEventListener("mouseleave",this._onMouseLeaveExternalMarker);this._marker=null;}}if(this._label){if(!this._labelExternal){this._label.parentNode.removeChild(this._label);}this._label=null;}this.scene.off(this._onTick);_get(_getPrototypeOf(Annotation.prototype),"destroy",this).call(this);}}]);return Annotation;}(Marker);var tempVec3a$D=math.vec3();var tempVec3b$r=math.vec3();var tempVec3c$m=math.vec3();/**
2718
+ */},{key:"destroy",value:function destroy(){if(this._marker){if(!this._markerExternal){this._marker.parentNode.removeChild(this._marker);}else{this._marker.removeEventListener("click",this._onMouseClickedExternalMarker);this._marker.removeEventListener("mouseenter",this._onMouseEnterExternalMarker);this._marker.removeEventListener("mouseleave",this._onMouseLeaveExternalMarker);this._marker=null;}}if(this._label){if(!this._labelExternal){this._label.parentNode.removeChild(this._label);}this._label=null;}this.scene.off(this._onTick);_get(_getPrototypeOf(Annotation.prototype),"destroy",this).call(this);}}]);return Annotation;}(Marker);var tempVec3a$D=math.vec3();var tempVec3b$q=math.vec3();var tempVec3c$m=math.vec3();/**
2719
2719
  * {@link Viewer} plugin that creates {@link Annotation}s.
2720
2720
  *
2721
2721
  * [<img src="https://user-images.githubusercontent.com/83100/58403089-26589280-8062-11e9-8652-aed61a4e8c64.gif">](https://xeokit.github.io/xeokit-sdk/examples/#annotations_clickFlyToPosition)
@@ -3137,7 +3137,7 @@ if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._rende
3137
3137
  * @param {Number[]} [params.up] Optional World-space position for {@link Camera#up}, used when this Annotation is associated with a {@link Camera} position.
3138
3138
  * @param {String} [params.projection] Optional projection type for {@link Camera#projection}, used when this Annotation is associated with a {@link Camera} position.
3139
3139
  * @returns {Annotation} The new {@link Annotation}.
3140
- */,set:function set(surfaceOffset){if(surfaceOffset===undefined||surfaceOffset===null){surfaceOffset=0.3;}this._surfaceOffset=surfaceOffset;}},{key:"createAnnotation",value:function createAnnotation(params){var _this20=this;if(this.viewer.scene.components[params.id]){this.error("Viewer component with this ID already exists: "+params.id);delete params.id;}var worldPos;var entity;params.pickResult=params.pickResult||params.pickRecord;if(params.pickResult){var pickResult=params.pickResult;if(!pickResult.worldPos||!pickResult.worldNormal){this.error("Param 'pickResult' does not have both worldPos and worldNormal");}else{var normalizedWorldNormal=math.normalizeVec3(pickResult.worldNormal,tempVec3a$D);var offsetVec=math.mulVec3Scalar(normalizedWorldNormal,this._surfaceOffset,tempVec3b$r);var offsetWorldPos=math.addVec3(pickResult.worldPos,offsetVec,tempVec3c$m);worldPos=offsetWorldPos;entity=pickResult.entity;}}else{worldPos=params.worldPos;entity=params.entity;}var markerElement=null;if(params.markerElementId){markerElement=document.getElementById(params.markerElementId);if(!markerElement){this.error("Can't find DOM element for 'markerElementId' value '"+params.markerElementId+"' - defaulting to internally-generated empty DIV");}}var labelElement=null;if(params.labelElementId){labelElement=document.getElementById(params.labelElementId);if(!labelElement){this.error("Can't find DOM element for 'labelElementId' value '"+params.labelElementId+"' - defaulting to internally-generated empty DIV");}}var annotation=new Annotation(this.viewer.scene,{id:params.id,plugin:this,entity:entity,worldPos:worldPos,container:this._container,markerElement:markerElement,labelElement:labelElement,markerHTML:params.markerHTML||this._markerHTML,labelHTML:params.labelHTML||this._labelHTML,occludable:params.occludable,values:utils.apply(params.values,utils.apply(this._values,{})),markerShown:params.markerShown,labelShown:params.labelShown,eye:params.eye,look:params.look,up:params.up,projection:params.projection,visible:params.visible!==false});this.annotations[annotation.id]=annotation;annotation.on("destroyed",function(){delete _this20.annotations[annotation.id];_this20.fire("annotationDestroyed",annotation.id);});this.fire("annotationCreated",annotation.id);return annotation;}/**
3140
+ */,set:function set(surfaceOffset){if(surfaceOffset===undefined||surfaceOffset===null){surfaceOffset=0.3;}this._surfaceOffset=surfaceOffset;}},{key:"createAnnotation",value:function createAnnotation(params){var _this20=this;if(this.viewer.scene.components[params.id]){this.error("Viewer component with this ID already exists: "+params.id);delete params.id;}var worldPos;var entity;params.pickResult=params.pickResult||params.pickRecord;if(params.pickResult){var pickResult=params.pickResult;if(!pickResult.worldPos||!pickResult.worldNormal){this.error("Param 'pickResult' does not have both worldPos and worldNormal");}else{var normalizedWorldNormal=math.normalizeVec3(pickResult.worldNormal,tempVec3a$D);var offsetVec=math.mulVec3Scalar(normalizedWorldNormal,this._surfaceOffset,tempVec3b$q);var offsetWorldPos=math.addVec3(pickResult.worldPos,offsetVec,tempVec3c$m);worldPos=offsetWorldPos;entity=pickResult.entity;}}else{worldPos=params.worldPos;entity=params.entity;}var markerElement=null;if(params.markerElementId){markerElement=document.getElementById(params.markerElementId);if(!markerElement){this.error("Can't find DOM element for 'markerElementId' value '"+params.markerElementId+"' - defaulting to internally-generated empty DIV");}}var labelElement=null;if(params.labelElementId){labelElement=document.getElementById(params.labelElementId);if(!labelElement){this.error("Can't find DOM element for 'labelElementId' value '"+params.labelElementId+"' - defaulting to internally-generated empty DIV");}}var annotation=new Annotation(this.viewer.scene,{id:params.id,plugin:this,entity:entity,worldPos:worldPos,container:this._container,markerElement:markerElement,labelElement:labelElement,markerHTML:params.markerHTML||this._markerHTML,labelHTML:params.labelHTML||this._labelHTML,occludable:params.occludable,values:utils.apply(params.values,utils.apply(this._values,{})),markerShown:params.markerShown,labelShown:params.labelShown,eye:params.eye,look:params.look,up:params.up,projection:params.projection,visible:params.visible!==false});this.annotations[annotation.id]=annotation;annotation.on("destroyed",function(){delete _this20.annotations[annotation.id];_this20.fire("annotationDestroyed",annotation.id);});this.fire("annotationCreated",annotation.id);return annotation;}/**
3141
3141
  * Destroys an {@link Annotation}.
3142
3142
  *
3143
3143
  * @param {String} id ID of Annotation to destroy.
@@ -5276,7 +5276,7 @@ _this31.left=cfg.left;_this31.right=cfg.right;_this31.bottom=cfg.bottom;_this31.
5276
5276
  * @param {Number[]} worldPos Outputs un-projected 3D World-space coordinates.
5277
5277
  */},{key:"unproject",value:function unproject(canvasPos,screenZ,screenPos,viewPos,worldPos){var canvas=this.scene.canvas.canvas;var halfCanvasWidth=canvas.offsetWidth/2.0;var halfCanvasHeight=canvas.offsetHeight/2.0;screenPos[0]=(canvasPos[0]-halfCanvasWidth)/halfCanvasWidth;screenPos[1]=(canvasPos[1]-halfCanvasHeight)/halfCanvasHeight;screenPos[2]=screenZ;screenPos[3]=1.0;math.mulMat4v4(this.inverseMatrix,screenPos,viewPos);math.mulVec3Scalar(viewPos,1.0/viewPos[3]);viewPos[3]=1.0;viewPos[1]*=-1;math.mulMat4v4(this.camera.inverseViewMatrix,viewPos,worldPos);return worldPos;}/** @private
5278
5278
  *
5279
- */},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CustomProjection.prototype),"destroy",this).call(this);this._state.destroy();}}]);return CustomProjection;}(Component);var tempVec3$7=math.vec3();var tempVec3b$q=math.vec3();var tempVec3c$l=math.vec3();var tempVec3d$f=math.vec3();var tempVec3e$8=math.vec3();var tempVec3f$2=math.vec3();var tempVec4a$d=math.vec4();var tempVec4b$c=math.vec4();var tempVec4c$9=math.vec4();var tempMat=math.mat4();var tempMatb=math.mat4();var eyeLookVec=math.vec3();var eyeLookVecNorm=math.vec3();var eyeLookOffset=math.vec3();var offsetEye=math.vec3();/**
5279
+ */},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CustomProjection.prototype),"destroy",this).call(this);this._state.destroy();}}]);return CustomProjection;}(Component);var tempVec3$7=math.vec3();var tempVec3b$p=math.vec3();var tempVec3c$l=math.vec3();var tempVec3d$f=math.vec3();var tempVec3e$8=math.vec3();var tempVec3f$2=math.vec3();var tempVec4a$d=math.vec4();var tempVec4b$c=math.vec4();var tempVec4c$2=math.vec4();var tempMat=math.mat4();var tempMatb=math.mat4();var eyeLookVec=math.vec3();var eyeLookVecNorm=math.vec3();var eyeLookOffset=math.vec3();var offsetEye=math.vec3();/**
5280
5280
  * @desc Manages viewing and projection transforms for its {@link Scene}.
5281
5281
  *
5282
5282
  * * One Camera per {@link Scene}
@@ -5479,29 +5479,29 @@ var eye;if(this.projection==="ortho"){math.subVec3(this._eye,this._look,eyeLookV
5479
5479
  * Rotates {@link Camera#eye} about {@link Camera#look}, around the {@link Camera#up} vector
5480
5480
  *
5481
5481
  * @param {Number} angleInc Angle of rotation in degrees
5482
- */},{key:"orbitYaw",value:function orbitYaw(angleInc){var lookEyeVec=math.subVec3(this._eye,this._look,tempVec3$7);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);lookEyeVec=math.transformPoint3(tempMat,lookEyeVec,tempVec3b$q);this.eye=math.addVec3(this._look,lookEyeVec,tempVec3c$l);// Set eye position as 'look' plus 'eye' vector
5482
+ */},{key:"orbitYaw",value:function orbitYaw(angleInc){var lookEyeVec=math.subVec3(this._eye,this._look,tempVec3$7);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);lookEyeVec=math.transformPoint3(tempMat,lookEyeVec,tempVec3b$p);this.eye=math.addVec3(this._look,lookEyeVec,tempVec3c$l);// Set eye position as 'look' plus 'eye' vector
5483
5483
  this.up=math.transformPoint3(tempMat,this._up,tempVec3d$f);// Rotate 'up' vector
5484
5484
  }/**
5485
5485
  * Rotates {@link Camera#eye} about {@link Camera#look} around the right axis (orthogonal to {@link Camera#up} and "look").
5486
5486
  *
5487
5487
  * @param {Number} angleInc Angle of rotation in degrees
5488
- */},{key:"orbitPitch",value:function orbitPitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var eye2=math.subVec3(this._eye,this._look,tempVec3$7);var left=math.cross3Vec3(math.normalizeVec3(eye2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$l));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);eye2=math.transformPoint3(tempMat,eye2,tempVec3d$f);this.up=math.transformPoint3(tempMat,this._up,tempVec3e$8);this.eye=math.addVec3(eye2,this._look,tempVec3f$2);}/**
5488
+ */},{key:"orbitPitch",value:function orbitPitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var eye2=math.subVec3(this._eye,this._look,tempVec3$7);var left=math.cross3Vec3(math.normalizeVec3(eye2,tempVec3b$p),math.normalizeVec3(this._up,tempVec3c$l));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);eye2=math.transformPoint3(tempMat,eye2,tempVec3d$f);this.up=math.transformPoint3(tempMat,this._up,tempVec3e$8);this.eye=math.addVec3(eye2,this._look,tempVec3f$2);}/**
5489
5489
  * Rotates {@link Camera#look} about {@link Camera#eye}, around the {@link Camera#up} vector.
5490
5490
  *
5491
5491
  * @param {Number} angleInc Angle of rotation in degrees
5492
- */},{key:"yaw",value:function yaw(angleInc){var look2=math.subVec3(this._look,this._eye,tempVec3$7);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);look2=math.transformPoint3(tempMat,look2,tempVec3b$q);this.look=math.addVec3(look2,this._eye,tempVec3c$l);if(this._gimbalLock){this.up=math.transformPoint3(tempMat,this._up,tempVec3d$f);}}/**
5492
+ */},{key:"yaw",value:function yaw(angleInc){var look2=math.subVec3(this._look,this._eye,tempVec3$7);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);look2=math.transformPoint3(tempMat,look2,tempVec3b$p);this.look=math.addVec3(look2,this._eye,tempVec3c$l);if(this._gimbalLock){this.up=math.transformPoint3(tempMat,this._up,tempVec3d$f);}}/**
5493
5493
  * Rotates {@link Camera#look} about {@link Camera#eye}, around the right axis (orthogonal to {@link Camera#up} and "look").
5494
5494
 
5495
5495
  * @param {Number} angleInc Angle of rotation in degrees
5496
- */},{key:"pitch",value:function pitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var look2=math.subVec3(this._look,this._eye,tempVec3$7);var left=math.cross3Vec3(math.normalizeVec3(look2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$l));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);this.up=math.transformPoint3(tempMat,this._up,tempVec3f$2);look2=math.transformPoint3(tempMat,look2,tempVec3d$f);this.look=math.addVec3(look2,this._eye,tempVec3e$8);}/**
5496
+ */},{key:"pitch",value:function pitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var look2=math.subVec3(this._look,this._eye,tempVec3$7);var left=math.cross3Vec3(math.normalizeVec3(look2,tempVec3b$p),math.normalizeVec3(this._up,tempVec3c$l));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);this.up=math.transformPoint3(tempMat,this._up,tempVec3f$2);look2=math.transformPoint3(tempMat,look2,tempVec3d$f);this.look=math.addVec3(look2,this._eye,tempVec3e$8);}/**
5497
5497
  * Pans the Camera along its local X, Y and Z axis.
5498
5498
  *
5499
5499
  * @param pan The pan vector
5500
- */},{key:"pan",value:function pan(_pan){var eye2=math.subVec3(this._eye,this._look,tempVec3$7);var vec=[0,0,0];var v;if(_pan[0]!==0){var left=math.cross3Vec3(math.normalizeVec3(eye2,[]),math.normalizeVec3(this._up,tempVec3b$q));v=math.mulVec3Scalar(left,_pan[0]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}if(_pan[1]!==0){v=math.mulVec3Scalar(math.normalizeVec3(this._up,tempVec3c$l),_pan[1]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}if(_pan[2]!==0){v=math.mulVec3Scalar(math.normalizeVec3(eye2,tempVec3d$f),_pan[2]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}this.eye=math.addVec3(this._eye,vec,tempVec3e$8);this.look=math.addVec3(this._look,vec,tempVec3f$2);}/**
5500
+ */},{key:"pan",value:function pan(_pan){var eye2=math.subVec3(this._eye,this._look,tempVec3$7);var vec=[0,0,0];var v;if(_pan[0]!==0){var left=math.cross3Vec3(math.normalizeVec3(eye2,[]),math.normalizeVec3(this._up,tempVec3b$p));v=math.mulVec3Scalar(left,_pan[0]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}if(_pan[1]!==0){v=math.mulVec3Scalar(math.normalizeVec3(this._up,tempVec3c$l),_pan[1]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}if(_pan[2]!==0){v=math.mulVec3Scalar(math.normalizeVec3(eye2,tempVec3d$f),_pan[2]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}this.eye=math.addVec3(this._eye,vec,tempVec3e$8);this.look=math.addVec3(this._look,vec,tempVec3f$2);}/**
5501
5501
  * Increments/decrements the Camera's zoom factor, which is the distance between {@link Camera#eye} and {@link Camera#look}.
5502
5502
  *
5503
5503
  * @param {Number} delta Zoom factor increment.
5504
- */},{key:"zoom",value:function zoom(delta){var vec=math.subVec3(this._eye,this._look,tempVec3$7);var lenLook=Math.abs(math.lenVec3(vec,tempVec3b$q));var newLenLook=Math.abs(lenLook+delta);if(newLenLook<0.5){return;}var dir=math.normalizeVec3(vec,tempVec3c$l);this.eye=math.addVec3(this._look,math.mulVec3Scalar(dir,newLenLook),tempVec3d$f);}/**
5504
+ */},{key:"zoom",value:function zoom(delta){var vec=math.subVec3(this._eye,this._look,tempVec3$7);var lenLook=Math.abs(math.lenVec3(vec,tempVec3b$p));var newLenLook=Math.abs(lenLook+delta);if(newLenLook<0.5){return;}var dir=math.normalizeVec3(vec,tempVec3c$l);this.eye=math.addVec3(this._look,math.mulVec3Scalar(dir,newLenLook),tempVec3d$f);}/**
5505
5505
  * Sets the position of the Camera's eye.
5506
5506
  *
5507
5507
  * Default value is ````[0,0,10]````.
@@ -5723,7 +5723,7 @@ this.fire("dirty");this.fire("projection",this._projectionType);this.fire("projM
5723
5723
  *
5724
5724
  * @param {[number, number, number]} worldPos
5725
5725
  * @returns {[number, number]} the canvas position
5726
- */},{key:"projectWorldPos",value:function projectWorldPos(worldPos){var _worldPos=tempVec4a$d;var viewPos=tempVec4b$c;var screenPos=tempVec4c$9;_worldPos[0]=worldPos[0];_worldPos[1]=worldPos[1];_worldPos[2]=worldPos[2];_worldPos[3]=1;math.mulMat4v4(this.viewMatrix,_worldPos,viewPos);math.mulMat4v4(this.projMatrix,viewPos,screenPos);math.mulVec3Scalar(screenPos,1.0/screenPos[3]);screenPos[3]=1.0;screenPos[1]*=-1;var canvas=this.scene.canvas.canvas;var halfCanvasWidth=canvas.offsetWidth/2.0;var halfCanvasHeight=canvas.offsetHeight/2.0;var canvasPos=[screenPos[0]*halfCanvasWidth+halfCanvasWidth,screenPos[1]*halfCanvasHeight+halfCanvasHeight];return canvasPos;}/**
5726
+ */},{key:"projectWorldPos",value:function projectWorldPos(worldPos){var _worldPos=tempVec4a$d;var viewPos=tempVec4b$c;var screenPos=tempVec4c$2;_worldPos[0]=worldPos[0];_worldPos[1]=worldPos[1];_worldPos[2]=worldPos[2];_worldPos[3]=1;math.mulMat4v4(this.viewMatrix,_worldPos,viewPos);math.mulMat4v4(this.projMatrix,viewPos,screenPos);math.mulVec3Scalar(screenPos,1.0/screenPos[3]);screenPos[3]=1.0;screenPos[1]*=-1;var canvas=this.scene.canvas.canvas;var halfCanvasWidth=canvas.offsetWidth/2.0;var halfCanvasHeight=canvas.offsetHeight/2.0;var canvasPos=[screenPos[0]*halfCanvasWidth+halfCanvasWidth,screenPos[1]*halfCanvasHeight+halfCanvasHeight];return canvasPos;}/**
5727
5727
  * Destroys this Camera.
5728
5728
  */},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(Camera.prototype),"destroy",this).call(this);this._state.destroy();}}]);return Camera;}(Component);/**
5729
5729
  * @desc A dynamic light source within a {@link Scene}.
@@ -7873,11 +7873,11 @@ _this45.preset=cfg.preset;if(cfg.lineWidth!==undefined){_this45.lineWidth=cfg.li
7873
7873
  * @return {string}
7874
7874
  */,set:function set(value){value=value||"default";if(this._preset===value){return;}var preset=PRESETS[value];if(!preset){this.error("unsupported preset: '"+value+"' - supported values are "+Object.keys(PRESETS).join(", "));return;}this.lineWidth=preset.lineWidth;this._preset=value;}},{key:"hash",get:function get(){return[""+this.lineWidth].join(";");}/**
7875
7875
  * Destroys this LinesMaterial.
7876
- */},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(LinesMaterial.prototype),"destroy",this).call(this);this._state.destroy();}}]);return LinesMaterial;}(Material);var tempVec3a$B=math.vec3();var tempVec3b$p=math.vec3();var tempMat4a$f=math.mat4();/**
7876
+ */},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(LinesMaterial.prototype),"destroy",this).call(this);this._state.destroy();}}]);return LinesMaterial;}(Material);var tempVec3a$B=math.vec3();var tempVec3b$o=math.vec3();var tempMat4a$f=math.mat4();/**
7877
7877
  * @private
7878
7878
  */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;}();/**
7879
7879
  * @private
7880
- */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$f);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$B;var max=tempVec3b$p;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 _i73=0;_i73<6;++_i73){var plane=frustum.planes[_i73];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;}/**
7880
+ */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$f);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$B;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 _i73=0;_i73<6;++_i73){var plane=frustum.planes[_i73];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;}/**
7881
7881
  * Data structure containing pre-initialized `LOD` data.
7882
7882
  *
7883
7883
  * Will be used by the rest of `LOD` related code.
@@ -13441,7 +13441,7 @@ var positions=K3D.edit.unwrap(m.i_verts,m.c_verts,3);var normals=K3D.edit.unwrap
13441
13441
  * Destroys this ````LineSet````.
13442
13442
  *
13443
13443
  * Removes the ```LineSet```` from {@link Scene#lineSets}; causes Scene to fire a "lineSetDestroyed" event.
13444
- */},{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$o=math.vec3();var tempVec3c$k=math.vec3();/**
13444
+ */},{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$n=math.vec3();var tempVec3c$k=math.vec3();/**
13445
13445
  * {@link Viewer} plugin that saves and loads BCF viewpoints as JSON objects.
13446
13446
  *
13447
13447
  * [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/BCFViewpointsPlugin.png">](/examples/#BCF_SaveViewpoint)
@@ -13801,7 +13801,7 @@ alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}alpha=Math.round(alpha*255).
13801
13801
  * then this method will apply the updates to objects within those composites.
13802
13802
  */},{key:"setViewpoint",value:function setViewpoint(bcfViewpoint){var _this69=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.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){var positions=[];var indices=[];var _i171=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(_i171++);indices.push(_i171++);});new LineSet(scene,{positions:positions,indices:indices,clippable:false,collidable:true});}scene.clearBitmaps();if(bcfViewpoint.bitmaps){bcfViewpoint.bitmaps.forEach(function(e){var bitmap_type=e.bitmap_type||"jpg";// "jpg" | "png"
13803
13803
  var bitmap_data=e.bitmap_data;// base64
13804
- var location=xyzObjectToArray(e.location,tempVec3a$u);var normal=xyzObjectToArray(e.normal,tempVec3b$o);var up=xyzObjectToArray(e.up,tempVec3c$k);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 _this69._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 _this69._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 _this69._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 _this69._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
13804
+ var location=xyzObjectToArray(e.location,tempVec3a$u);var normal=xyzObjectToArray(e.normal,tempVec3b$n);var up=xyzObjectToArray(e.up,tempVec3c$k);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 _this69._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 _this69._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 _this69._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 _this69._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
13805
13805
  origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3$5);}else{look=math.addVec3(eye,look,tempVec3$5);}if(immediate){camera.eye=eye;camera.look=look;camera.up=up;camera.projection=projection;}else{viewer.cameraFlight.flyTo({eye:eye,look:look,up:up,duration:options.duration,projection:projection});}}}},{key:"_withBCFComponent",value:function _withBCFComponent(options,component,callback){var viewer=this.viewer;var scene=viewer.scene;if(component.authoring_tool_id&&component.originating_system===this.originatingSystem){var id=component.authoring_tool_id;var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var metaObject=viewer.metaScene.metaObjects[id];if(metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);return;}}}if(component.ifc_guid){var originalSystemId=component.ifc_guid;var _entity2=scene.objects[originalSystemId];if(_entity2){callback(_entity2);return;}if(options.updateCompositeObjects){var _metaObject=viewer.metaScene.metaObjects[originalSystemId];if(_metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(originalSystemId),callback);return;}}Object.keys(scene.models).forEach(function(modelId){var id=math.globalizeObjectId(modelId,originalSystemId);var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var _metaObject2=viewer.metaScene.metaObjects[id];if(_metaObject2){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);}}});}}/**
13806
13806
  * Destroys this BCFViewpointsPlugin.
13807
13807
  */},{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);};/**
@@ -14736,7 +14736,7 @@ t/=d;return-c*t*(t-2)+b;}},{key:"_easeInCubic",value:function _easeInCubic(t,b,c
14736
14736
  * @param {Number} frameIdx Index of the frame to scrub to.
14737
14737
  */},{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;}/**
14738
14738
  * Stops playing this CameraPathAnimation.
14739
- */},{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$n=math.vec3();math.vec3();var zeroVec$2=math.vec3([0,-1,0]);var tempQuat=math.vec4([0,0,0,1]);/**
14739
+ */},{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$m=math.vec3();math.vec3();var zeroVec$2=math.vec3([0,-1,0]);var tempQuat=math.vec4([0,0,0,1]);/**
14740
14740
  * @desc A plane-shaped 3D object containing a bitmap image.
14741
14741
  *
14742
14742
  * Use ````ImagePlane```` to embed bitmap images in your scenes.
@@ -14972,7 +14972,7 @@ t/=d;return-c*t*(t-2)+b;}},{key:"_easeInCubic",value:function _easeInCubic(t,b,c
14972
14972
  * Default is ````true````.
14973
14973
  *
14974
14974
  * @type {Boolean}
14975
- */,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$n);math.vec3PairToQuaternion(zeroVec$2,dir,tempQuat);this._node.quaternion=tempQuat;}}},{key:"collidable",get:/**
14975
+ */,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$m);math.vec3PairToQuaternion(zeroVec$2,dir,tempQuat);this._node.quaternion=tempQuat;}}},{key:"collidable",get:/**
14976
14976
  * Gets if this ````ImagePlane```` is included in boundary calculations.
14977
14977
  *
14978
14978
  * Default is ````true````.
@@ -16014,7 +16014,7 @@ NOT_RENDERED:0,// Normal rendering - mutually exclusive modes
16014
16014
  COLOR_OPAQUE:1,COLOR_TRANSPARENT:2,// Emphasis silhouette rendering - mutually exclusive modes
16015
16015
  SILHOUETTE_HIGHLIGHTED:3,SILHOUETTE_SELECTED:4,SILHOUETTE_XRAYED:5,// Edges rendering - mutually exclusive modes
16016
16016
  EDGES_COLOR_OPAQUE:6,EDGES_COLOR_TRANSPARENT:7,EDGES_HIGHLIGHTED:8,EDGES_SELECTED:9,EDGES_XRAYED:10,// Picking
16017
- PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=new Float32Array([0,0,0,1]);var tempVec4=math.vec4();var tempVec3a$s=math.vec3();var tempVec3b$m=math.vec3();var tempVec3c$j=math.vec3();var tempMat4a$e=math.mat4();var VBOSceneModelRenderer=/*#__PURE__*/function(){function VBOSceneModelRenderer(scene){var withSAO=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var _ref8=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref8$instancing=_ref8.instancing,instancing=_ref8$instancing===void 0?false:_ref8$instancing,_ref8$edges=_ref8.edges,edges=_ref8$edges===void 0?false:_ref8$edges;_classCallCheck(this,VBOSceneModelRenderer);this._scene=scene;this._withSAO=withSAO;this._instancing=instancing;this._edges=edges;this._hash=this._getHash();/**
16017
+ PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=new Float32Array([0,0,0,1]);var tempVec4=math.vec4();var tempVec3a$s=math.vec3();math.vec3();var tempVec3c$j=math.vec3();var tempMat4a$e=math.mat4();var VBOSceneModelRenderer=/*#__PURE__*/function(){function VBOSceneModelRenderer(scene){var withSAO=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var _ref8=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref8$instancing=_ref8.instancing,instancing=_ref8$instancing===void 0?false:_ref8$instancing,_ref8$edges=_ref8.edges,edges=_ref8$edges===void 0?false:_ref8$edges;_classCallCheck(this,VBOSceneModelRenderer);this._scene=scene;this._withSAO=withSAO;this._instancing=instancing;this._edges=edges;this._hash=this._getHash();/**
16018
16018
  * Matrices Uniform Block Buffer
16019
16019
  *
16020
16020
  * In shaders, matrices in the Matrices Uniform Block MUST be set in this order:
@@ -16032,7 +16032,7 @@ PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=ne
16032
16032
  * @returns { string }
16033
16033
  */_createClass(VBOSceneModelRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){return[""];}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){return[""];}},{key:"_addMatricesUniformBlockLines",value:function _addMatricesUniformBlockLines(src){var normals=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;src.push("uniform Matrices {");src.push(" mat4 worldMatrix;");src.push(" mat4 viewMatrix;");src.push(" mat4 projMatrix;");src.push(" mat4 positionsDecodeMatrix;");if(normals){src.push(" mat4 worldNormalMatrix;");src.push(" mat4 viewNormalMatrix;");}src.push("};");return src;}},{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"setSectionPlanesStateUniforms",value:function setSectionPlanesStateUniforms(layer){var scene=this._scene;var gl=scene.canvas.gl;var model=layer.model,layerIndex=layer.layerIndex;var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=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];var _origin6=layer._state.origin;if(_origin6){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,_origin6,tempVec3a$s);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}}},{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._uColor=program.getLocation("color");if(!this._uColor){// some shader may have color as attribute, in this case the uniform must be renamed silhouetteColor
16034
16034
  this._uColor=program.getLocation("silhouetteColor");}this._uUVDecodeMatrix=program.getLocation("uvDecodeMatrix");this._uPickInvisible=program.getLocation("pickInvisible");this._uGammaFactor=program.getLocation("gammaFactor");gl.uniformBlockBinding(program.handle,gl.getUniformBlockIndex(program.handle,"Matrices"),this._matricesUniformBlockBufferBindingPoint);this._uShadowViewMatrix=program.getLocation("shadowViewMatrix");this._uShadowProjMatrix=program.getLocation("shadowProjMatrix");if(scene.logarithmicDepthBufferEnabled){this._uZFar=program.getLocation("zFar");}this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];// TODO add a gard to prevent light params if not affected by light ?
16035
- var lights=lightsState.lights;var light;for(var _i181=0,len=lights.length;_i181<len;_i181++){light=lights[_i181];switch(light.type){case"dir":this._uLightColor[_i181]=program.getLocation("lightColor"+_i181);this._uLightPos[_i181]=null;this._uLightDir[_i181]=program.getLocation("lightDir"+_i181);break;case"point":this._uLightColor[_i181]=program.getLocation("lightColor"+_i181);this._uLightPos[_i181]=program.getLocation("lightPos"+_i181);this._uLightDir[_i181]=null;this._uLightAttenuation[_i181]=program.getLocation("lightAttenuation"+_i181);break;case"spot":this._uLightColor[_i181]=program.getLocation("lightColor"+_i181);this._uLightPos[_i181]=program.getLocation("lightPos"+_i181);this._uLightDir[_i181]=program.getLocation("lightDir"+_i181);this._uLightAttenuation[_i181]=program.getLocation("lightAttenuation"+_i181);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i182=0,_len22=scene._sectionPlanesState.sectionPlanes.length;_i182<_len22;_i182++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i182),pos:program.getLocation("sectionPlanePos"+_i182),dir:program.getLocation("sectionPlaneDir"+_i182)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aNormal=program.getAttribute("normal");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aMetallicRoughness=program.getAttribute("metallicRoughness");this._aFlags=program.getAttribute("flags");this._aPickColor=program.getAttribute("pickColor");this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");this._uColorMap="uColorMap";this._uMetallicRoughMap="uMetallicRoughMap";this._uEmissiveMap="uEmissiveMap";this._uNormalMap="uNormalMap";this._uAOMap="uAOMap";if(this._instancing){this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");this._aModelNormalMatrixCol0=program.getAttribute("modelNormalMatrixCol0");this._aModelNormalMatrixCol1=program.getAttribute("modelNormalMatrixCol1");this._aModelNormalMatrixCol2=program.getAttribute("modelNormalMatrixCol2");}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}if(scene.pointsMaterial._state.filterIntensity){this._uIntensityRange=program.getLocation("intensityRange");}this._uPointSize=program.getLocation("pointSize");this._uNearPlaneHeight=program.getLocation("nearPlaneHeight");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lightsState=scene._lightsState;var lights=lightsState.lights;var project=scene.camera.project;program.bind();frameCtx.textureUnit=0;if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,lightsState.getAmbientColorAndIntensity());}for(var _i183=0,len=lights.length;_i183<len;_i183++){var light=lights[_i183];if(this._uLightColor[_i183]){gl.uniform4f(this._uLightColor[_i183],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i183]){gl.uniform3fv(this._uLightPos[_i183],light.pos);if(this._uLightAttenuation[_i183]){gl.uniform1f(this._uLightAttenuation[_i183],light.attenuation);}}if(this._uLightDir[_i183]){gl.uniform3fv(this._uLightDir[_i183],light.dir);}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4[0]=viewportWidth;tempVec4[1]=viewportHeight;tempVec4[2]=sao.blendCutoff;tempVec4[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,0);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}if(this._uPickInvisible){gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);}if(this._uShadowViewMatrix){gl.uniformMatrix4fv(this._uShadowViewMatrix,false,frameCtx.shadowViewMatrix);}if(this._uShadowProjMatrix){gl.uniformMatrix4fv(this._uShadowProjMatrix,false,frameCtx.shadowProjMatrix);}}},{key:"_makeVAO",value:function _makeVAO(state){var gl=this._scene.canvas.gl;var vao=gl.createVertexArray();gl.bindVertexArray(vao);if(this._instancing){this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);if(this._aModelNormalMatrixCol0){this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location,1);}if(this._aModelNormalMatrixCol1){this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location,1);}if(this._aModelNormalMatrixCol2){this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location,1);}}this._aPosition.bindArrayBuffer(this._instancing?state.positionsBuf:state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(this._instancing?state.uvBuf:state.uvBuf);}if(this._aNormal){this._aNormal.bindArrayBuffer(this._instancing?state.normalsBuf:state.normalsBuf);}if(this._aMetallicRoughness){this._aMetallicRoughness.bindArrayBuffer(state.metallicRoughnessBuf);if(this._instancing){gl.vertexAttribDivisor(this._aMetallicRoughness.location,1);}}if(this._aColor){this._aColor.bindArrayBuffer(state.colorsBuf?state.colorsBuf:state.colorsBuf);if(this._instancing&&state.colorsBuf){gl.vertexAttribDivisor(this._aColor.location,1);}}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aFlags.location,1);}}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aOffset.location,1);}}if(this._aPickColor){this._aPickColor.bindArrayBuffer(state.pickColorsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aPickColor.location,1);}}if(this._instancing){if(this._edges){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}else{if(this._edges){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}return vao;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){var _ref9=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},_ref9$colorUniform=_ref9.colorUniform,colorUniform=_ref9$colorUniform===void 0?false:_ref9$colorUniform,_ref9$incrementDrawSt=_ref9.incrementDrawState,incrementDrawState=_ref9$incrementDrawSt===void 0?false:_ref9$incrementDrawSt;var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;var scene=this._scene;var gl=scene.canvas.gl;var state=layer._state,model=layer.model;var textureSet=state.textureSet,origin=state.origin,positionsDecodeMatrix=state.positionsDecodeMatrix;var lightsState=scene._lightsState;var pointsMaterial=scene.pointsMaterial;var camera=model.scene.camera;var viewNormalMatrix=camera.viewNormalMatrix,project=camera.project;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate,worldNormalMatrix=model.worldNormalMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(this._vaoCache.has(layer)){gl.bindVertexArray(this._vaoCache.get(layer));}else{this._vaoCache.set(layer,this._makeVAO(state));}var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var layerOrigin=tempVec3b$m;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$j);layerOrigin[0]=rotatedOrigin[0];layerOrigin[1]=rotatedOrigin[1];layerOrigin[2]=rotatedOrigin[2];}else{layerOrigin[0]=0;layerOrigin[1]=0;layerOrigin[2]=0;}layerOrigin[0]+=position[0];layerOrigin[1]+=position[1];layerOrigin[2]+=position[2];this._matricesUniformBlockBufferData.set(createRTCViewMat(viewMatrix,layerOrigin,tempMat4a$e),offset+=mat4Size);}else{this._matricesUniformBlockBufferData.set(viewMatrix,offset+=mat4Size);}this._matricesUniformBlockBufferData.set(frameCtx.pickProjMatrix||project.matrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(positionsDecodeMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(worldNormalMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(viewNormalMatrix,offset+=mat4Size);gl.bindBuffer(gl.UNIFORM_BUFFER,this._matricesUniformBlockBuffer);gl.bufferData(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferData,gl.DYNAMIC_DRAW);gl.bindBufferBase(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferBindingPoint,this._matricesUniformBlockBuffer);gl.uniform1i(this._uRenderPass,renderPass);this.setSectionPlanesStateUniforms(layer);if(scene.logarithmicDepthBufferEnabled){if(this._uLogDepthBufFC){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
16035
+ var lights=lightsState.lights;var light;for(var _i181=0,len=lights.length;_i181<len;_i181++){light=lights[_i181];switch(light.type){case"dir":this._uLightColor[_i181]=program.getLocation("lightColor"+_i181);this._uLightPos[_i181]=null;this._uLightDir[_i181]=program.getLocation("lightDir"+_i181);break;case"point":this._uLightColor[_i181]=program.getLocation("lightColor"+_i181);this._uLightPos[_i181]=program.getLocation("lightPos"+_i181);this._uLightDir[_i181]=null;this._uLightAttenuation[_i181]=program.getLocation("lightAttenuation"+_i181);break;case"spot":this._uLightColor[_i181]=program.getLocation("lightColor"+_i181);this._uLightPos[_i181]=program.getLocation("lightPos"+_i181);this._uLightDir[_i181]=program.getLocation("lightDir"+_i181);this._uLightAttenuation[_i181]=program.getLocation("lightAttenuation"+_i181);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i182=0,_len22=scene._sectionPlanesState.sectionPlanes.length;_i182<_len22;_i182++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i182),pos:program.getLocation("sectionPlanePos"+_i182),dir:program.getLocation("sectionPlaneDir"+_i182)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aNormal=program.getAttribute("normal");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aMetallicRoughness=program.getAttribute("metallicRoughness");this._aFlags=program.getAttribute("flags");this._aPickColor=program.getAttribute("pickColor");this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");this._uColorMap="uColorMap";this._uMetallicRoughMap="uMetallicRoughMap";this._uEmissiveMap="uEmissiveMap";this._uNormalMap="uNormalMap";this._uAOMap="uAOMap";if(this._instancing){this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");this._aModelNormalMatrixCol0=program.getAttribute("modelNormalMatrixCol0");this._aModelNormalMatrixCol1=program.getAttribute("modelNormalMatrixCol1");this._aModelNormalMatrixCol2=program.getAttribute("modelNormalMatrixCol2");}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}if(scene.pointsMaterial._state.filterIntensity){this._uIntensityRange=program.getLocation("intensityRange");}this._uPointSize=program.getLocation("pointSize");this._uNearPlaneHeight=program.getLocation("nearPlaneHeight");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lightsState=scene._lightsState;var lights=lightsState.lights;var project=scene.camera.project;program.bind();frameCtx.textureUnit=0;if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,lightsState.getAmbientColorAndIntensity());}for(var _i183=0,len=lights.length;_i183<len;_i183++){var light=lights[_i183];if(this._uLightColor[_i183]){gl.uniform4f(this._uLightColor[_i183],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i183]){gl.uniform3fv(this._uLightPos[_i183],light.pos);if(this._uLightAttenuation[_i183]){gl.uniform1f(this._uLightAttenuation[_i183],light.attenuation);}}if(this._uLightDir[_i183]){gl.uniform3fv(this._uLightDir[_i183],light.dir);}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4[0]=viewportWidth;tempVec4[1]=viewportHeight;tempVec4[2]=sao.blendCutoff;tempVec4[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,0);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}if(this._uPickInvisible){gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);}if(this._uShadowViewMatrix){gl.uniformMatrix4fv(this._uShadowViewMatrix,false,frameCtx.shadowViewMatrix);}if(this._uShadowProjMatrix){gl.uniformMatrix4fv(this._uShadowProjMatrix,false,frameCtx.shadowProjMatrix);}}},{key:"_makeVAO",value:function _makeVAO(state){var gl=this._scene.canvas.gl;var vao=gl.createVertexArray();gl.bindVertexArray(vao);if(this._instancing){this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);if(this._aModelNormalMatrixCol0){this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location,1);}if(this._aModelNormalMatrixCol1){this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location,1);}if(this._aModelNormalMatrixCol2){this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location,1);}}this._aPosition.bindArrayBuffer(this._instancing?state.positionsBuf:state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(this._instancing?state.uvBuf:state.uvBuf);}if(this._aNormal){this._aNormal.bindArrayBuffer(this._instancing?state.normalsBuf:state.normalsBuf);}if(this._aMetallicRoughness){this._aMetallicRoughness.bindArrayBuffer(state.metallicRoughnessBuf);if(this._instancing){gl.vertexAttribDivisor(this._aMetallicRoughness.location,1);}}if(this._aColor){this._aColor.bindArrayBuffer(state.colorsBuf?state.colorsBuf:state.colorsBuf);if(this._instancing&&state.colorsBuf){gl.vertexAttribDivisor(this._aColor.location,1);}}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aFlags.location,1);}}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aOffset.location,1);}}if(this._aPickColor){this._aPickColor.bindArrayBuffer(state.pickColorsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aPickColor.location,1);}}if(this._instancing){if(this._edges){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}else{if(this._edges){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}return vao;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){var _ref9=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},_ref9$colorUniform=_ref9.colorUniform,colorUniform=_ref9$colorUniform===void 0?false:_ref9$colorUniform,_ref9$incrementDrawSt=_ref9.incrementDrawState,incrementDrawState=_ref9$incrementDrawSt===void 0?false:_ref9$incrementDrawSt;var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;var scene=this._scene;var gl=scene.canvas.gl;var state=layer._state,model=layer.model;var textureSet=state.textureSet,origin=state.origin,positionsDecodeMatrix=state.positionsDecodeMatrix;var lightsState=scene._lightsState;var pointsMaterial=scene.pointsMaterial;var camera=model.scene.camera;var viewNormalMatrix=camera.viewNormalMatrix,project=camera.project;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate,worldNormalMatrix=model.worldNormalMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(this._vaoCache.has(layer)){gl.bindVertexArray(this._vaoCache.get(layer));}else{this._vaoCache.set(layer,this._makeVAO(state));}var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);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$s;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$j);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];this._matricesUniformBlockBufferData.set(createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$e),offset+=mat4Size);}else{this._matricesUniformBlockBufferData.set(viewMatrix,offset+=mat4Size);}this._matricesUniformBlockBufferData.set(frameCtx.pickProjMatrix||project.matrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(positionsDecodeMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(worldNormalMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(viewNormalMatrix,offset+=mat4Size);gl.bindBuffer(gl.UNIFORM_BUFFER,this._matricesUniformBlockBuffer);gl.bufferData(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferData,gl.DYNAMIC_DRAW);gl.bindBufferBase(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferBindingPoint,this._matricesUniformBlockBuffer);gl.uniform1i(this._uRenderPass,renderPass);this.setSectionPlanesStateUniforms(layer);if(scene.logarithmicDepthBufferEnabled){if(this._uLogDepthBufFC){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
16036
16036
  gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uZFar){gl.uniform1f(this._uZFar,scene.camera.project.far);}}if(this._uPickInvisible){gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);}if(this._uPickZNear){gl.uniform1f(this._uPickZNear,frameCtx.pickZNear);}if(this._uPickZFar){gl.uniform1f(this._uPickZFar,frameCtx.pickZFar);}if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,state.positionsDecodeMatrix);}if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,this._instancing?state.uvDecodeMatrix:state.uvDecodeMatrix);}if(this._uIntensityRange&&pointsMaterial.filterIntensity){gl.uniform2f(this._uIntensityRange,pointsMaterial.minIntensity,pointsMaterial.maxIntensity);}if(this._uPointSize){gl.uniform1f(this._uPointSize,pointsMaterial.pointSize);}if(this._uNearPlaneHeight){var nearPlaneHeight=scene.camera.projection==="ortho"?1.0:gl.drawingBufferHeight/(2*Math.tan(0.5*scene.camera.perspective.fov*Math.PI/180.0));gl.uniform1f(this._uNearPlaneHeight,nearPlaneHeight);}if(textureSet){var colorTexture=textureSet.colorTexture,metallicRoughnessTexture=textureSet.metallicRoughnessTexture,emissiveTexture=textureSet.emissiveTexture,normalsTexture=textureSet.normalsTexture,occlusionTexture=textureSet.occlusionTexture;if(this._uColorMap&&colorTexture){this._program.bindTexture(this._uColorMap,colorTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uMetallicRoughMap&&metallicRoughnessTexture){this._program.bindTexture(this._uMetallicRoughMap,metallicRoughnessTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uEmissiveMap&&emissiveTexture){this._program.bindTexture(this._uEmissiveMap,emissiveTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uNormalMap&&normalsTexture){this._program.bindTexture(this._uNormalMap,normalsTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uAOMap&&occlusionTexture){this._program.bindTexture(this._uAOMap,occlusionTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}}if(lightsState.reflectionMaps.length>0&&lightsState.reflectionMaps[0].texture&&this._uReflectionMap){this._program.bindTexture(this._uReflectionMap,lightsState.reflectionMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(lightsState.lightMaps.length>0&&lightsState.lightMaps[0].texture&&this._uLightMap){this._program.bindTexture(this._uLightMap,lightsState.lightMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4[0]=viewportWidth;tempVec4[1]=viewportHeight;tempVec4[2]=sao.blendCutoff;tempVec4[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}}if(colorUniform){var colorKey=this._edges?"edgeColor":"fillColor";var alphaKey=this._edges?"edgeAlpha":"fillAlpha";if(renderPass===RENDER_PASSES["".concat(this._edges?"EDGES":"SILHOUETTE","_XRAYED")]){var material=scene.xrayMaterial._state;var _color3=material[colorKey];var alpha=material[alphaKey];gl.uniform4f(this._uColor,_color3[0],_color3[1],_color3[2],alpha);}else if(renderPass===RENDER_PASSES["".concat(this._edges?"EDGES":"SILHOUETTE","_HIGHLIGHTED")]){var _material=scene.highlightMaterial._state;var _color4=_material[colorKey];var _alpha=_material[alphaKey];gl.uniform4f(this._uColor,_color4[0],_color4[1],_color4[2],_alpha);}else if(renderPass===RENDER_PASSES["".concat(this._edges?"EDGES":"SILHOUETTE","_SELECTED")]){var _material2=scene.selectedMaterial._state;var _color5=_material2[colorKey];var _alpha2=_material2[alphaKey];gl.uniform4f(this._uColor,_color5[0],_color5[1],_color5[2],_alpha2);}else{gl.uniform4fv(this._uColor,this._edges?edgesDefaultColor:defaultColor$2);}}this._draw({state:state,frameCtx:frameCtx,incrementDrawState:incrementDrawState});gl.bindVertexArray(null);}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;stats.memory.programs--;}}]);return VBOSceneModelRenderer;}();var VBOSceneModelTriangleBatchingRenderer=/*#__PURE__*/function(_VBOSceneModelRendere){_inherits(VBOSceneModelTriangleBatchingRenderer,_VBOSceneModelRendere);var _super61=_createSuper(VBOSceneModelTriangleBatchingRenderer);function VBOSceneModelTriangleBatchingRenderer(scene,withSAO){var _ref10=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref10$instancing=_ref10.instancing,instancing=_ref10$instancing===void 0?false:_ref10$instancing,_ref10$edges=_ref10.edges,edges=_ref10$edges===void 0?false:_ref10$edges;_classCallCheck(this,VBOSceneModelTriangleBatchingRenderer);return _super61.call(this,scene,withSAO,{instancing:instancing,edges:edges});}_createClass(VBOSceneModelTriangleBatchingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;if(this._edges){gl.drawElements(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0);}else{var count=frameCtx.pickElementsCount||state.indicesBuf.numItems;var offset=frameCtx.pickElementsOffset?frameCtx.pickElementsOffset*state.indicesBuf.itemByteSize:0;gl.drawElements(gl.TRIANGLES,count,state.indicesBuf.itemType,offset);if(incrementDrawState){frameCtx.drawElements++;}}}}]);return VBOSceneModelTriangleBatchingRenderer;}(VBOSceneModelRenderer);var VBOSceneModelTriangleBatchingEdgesRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl){_inherits(VBOSceneModelTriangleBatchingEdgesRenderer,_VBOSceneModelTriangl);var _super62=_createSuper(VBOSceneModelTriangleBatchingEdgesRenderer);function VBOSceneModelTriangleBatchingEdgesRenderer(scene,withSAO){_classCallCheck(this,VBOSceneModelTriangleBatchingEdgesRenderer);return _super62.call(this,scene,withSAO,{instancing:false,edges:true});}return _createClass(VBOSceneModelTriangleBatchingEdgesRenderer);}(VBOSceneModelTriangleBatchingRenderer);var VBOSceneModelTriangleInstancingRenderer=/*#__PURE__*/function(_VBOSceneModelRendere2){_inherits(VBOSceneModelTriangleInstancingRenderer,_VBOSceneModelRendere2);var _super63=_createSuper(VBOSceneModelTriangleInstancingRenderer);function VBOSceneModelTriangleInstancingRenderer(scene,withSAO){var _ref11=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref11$edges=_ref11.edges,edges=_ref11$edges===void 0?false:_ref11$edges;_classCallCheck(this,VBOSceneModelTriangleInstancingRenderer);return _super63.call(this,scene,withSAO,{instancing:true,edges:edges});}_createClass(VBOSceneModelTriangleInstancingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;if(this._edges){gl.drawElementsInstanced(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0,state.numInstances);}else{gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);if(incrementDrawState){frameCtx.drawElements++;}}}}]);return VBOSceneModelTriangleInstancingRenderer;}(VBOSceneModelRenderer);var VBOSceneModelTriangleInstancingEdgesRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl2){_inherits(VBOSceneModelTriangleInstancingEdgesRenderer,_VBOSceneModelTriangl2);var _super64=_createSuper(VBOSceneModelTriangleInstancingEdgesRenderer);function VBOSceneModelTriangleInstancingEdgesRenderer(scene,withSAO){_classCallCheck(this,VBOSceneModelTriangleInstancingEdgesRenderer);return _super64.call(this,scene,withSAO,{instancing:true,edges:true});}return _createClass(VBOSceneModelTriangleInstancingEdgesRenderer);}(VBOSceneModelTriangleInstancingRenderer);var VBOSceneModelPointBatchingRenderer=/*#__PURE__*/function(_VBOSceneModelRendere3){_inherits(VBOSceneModelPointBatchingRenderer,_VBOSceneModelRendere3);var _super65=_createSuper(VBOSceneModelPointBatchingRenderer);function VBOSceneModelPointBatchingRenderer(){_classCallCheck(this,VBOSceneModelPointBatchingRenderer);return _super65.apply(this,arguments);}_createClass(VBOSceneModelPointBatchingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;gl.drawArrays(gl.POINTS,0,state.positionsBuf.numItems);if(incrementDrawState){frameCtx.drawArrays++;}}}]);return VBOSceneModelPointBatchingRenderer;}(VBOSceneModelRenderer);var VBOSceneModelPointInstancingRenderer=/*#__PURE__*/function(_VBOSceneModelRendere4){_inherits(VBOSceneModelPointInstancingRenderer,_VBOSceneModelRendere4);var _super66=_createSuper(VBOSceneModelPointInstancingRenderer);function VBOSceneModelPointInstancingRenderer(scene,withSAO){_classCallCheck(this,VBOSceneModelPointInstancingRenderer);return _super66.call(this,scene,withSAO,{instancing:true});}_createClass(VBOSceneModelPointInstancingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;gl.drawArraysInstanced(gl.POINTS,0,state.positionsBuf.numItems,state.numInstances);if(incrementDrawState){frameCtx.drawArrays++;}}}]);return VBOSceneModelPointInstancingRenderer;}(VBOSceneModelRenderer);var VBOSceneModelLineBatchingRenderer=/*#__PURE__*/function(_VBOSceneModelRendere5){_inherits(VBOSceneModelLineBatchingRenderer,_VBOSceneModelRendere5);var _super67=_createSuper(VBOSceneModelLineBatchingRenderer);function VBOSceneModelLineBatchingRenderer(){_classCallCheck(this,VBOSceneModelLineBatchingRenderer);return _super67.apply(this,arguments);}_createClass(VBOSceneModelLineBatchingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;gl.drawElements(gl.LINES,state.indicesBuf.numItems,state.indicesBuf.itemType,0);if(incrementDrawState){frameCtx.drawElements++;}}}]);return VBOSceneModelLineBatchingRenderer;}(VBOSceneModelRenderer);var VBOSceneModelLineInstancingRenderer=/*#__PURE__*/function(_VBOSceneModelRendere6){_inherits(VBOSceneModelLineInstancingRenderer,_VBOSceneModelRendere6);var _super68=_createSuper(VBOSceneModelLineInstancingRenderer);function VBOSceneModelLineInstancingRenderer(scene,withSAO){_classCallCheck(this,VBOSceneModelLineInstancingRenderer);return _super68.call(this,scene,withSAO,{instancing:true});}_createClass(VBOSceneModelLineInstancingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;gl.drawElementsInstanced(gl.LINES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);if(incrementDrawState){frameCtx.drawElements++;}}}]);return VBOSceneModelLineInstancingRenderer;}(VBOSceneModelRenderer);/**
16037
16037
  * @private
16038
16038
  */var TrianglesBatchingColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl3){_inherits(TrianglesBatchingColorRenderer,_VBOSceneModelTriangl3);var _super69=_createSuper(TrianglesBatchingColorRenderer);function TrianglesBatchingColorRenderer(){_classCallCheck(this,TrianglesBatchingColorRenderer);return _super69.apply(this,arguments);}_createClass(TrianglesBatchingColorRenderer,[{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,layer,renderPass){_get(_getPrototypeOf(TrianglesBatchingColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{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("// Triangles batching draw vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec3 normal;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src,true);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;");}src.push("uniform vec4 lightAmbient;");for(var _i184=0,len=lightsState.lights.length;_i184<len;_i184++){light=lightsState.lights[_i184];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i184+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i184+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i184+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i184+";");src.push("uniform vec3 lightDir"+_i184+";");}}src.push("vec3 octDecode(vec2 oct) {");src.push(" vec3 v = vec3(oct.xy, 1.0 - abs(oct.x) - abs(oct.y));");src.push(" if (v.z < 0.0) {");src.push(" v.xy = (1.0 - abs(v.yx)) * vec2(v.x >= 0.0 ? 1.0 : -1.0, v.y >= 0.0 ? 1.0 : -1.0);");src.push(" }");src.push(" return normalize(v);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
@@ -16164,30 +16164,30 @@ var x=p[0]/(Math.abs(p[0])+Math.abs(p[1])+Math.abs(p[2]));var y=p[1]/(Math.abs(p
16164
16164
  */function octDecodeVec2(oct){// Decode an oct-encoded normal
16165
16165
  var x=oct[0];var y=oct[1];x/=x<0?127:128;y/=y<0?127:128;var z=1-Math.abs(x)-Math.abs(y);if(z<0){x=(1-Math.abs(y))*(x>=0?1:-1);y=(1-Math.abs(x))*(y>=0?1:-1);}var length=Math.sqrt(x*x+y*y+z*z);return[x/length,y/length,z/length];}var tempVec3a$r=math.vec3();var tempVec3b$l=math.vec3();var tempVec3c$i=math.vec3();var tempVec3d$e=math.vec3();var tempVec3e$7=math.vec3();var tempMat4a$d=math.mat4();/**
16166
16166
  * @private
16167
- */var SnapBatchingDepthBufInitRenderer=/*#__PURE__*/function(){function SnapBatchingDepthBufInitRenderer(scene){_classCallCheck(this,SnapBatchingDepthBufInitRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapBatchingDepthBufInitRenderer,[{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,batchingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=batchingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=batchingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$r;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$l;if(origin){var rotatedOrigin=tempVec3c$i;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);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$d);rtcCameraEye=tempVec3d$e;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniform1i(this._uSolid,batchingLayer.solid);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
16167
+ */var SnapBatchingDepthBufInitRenderer=/*#__PURE__*/function(){function SnapBatchingDepthBufInitRenderer(scene){_classCallCheck(this,SnapBatchingDepthBufInitRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapBatchingDepthBufInitRenderer,[{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,batchingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=batchingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=batchingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$r;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$l;if(origin){var rotatedOrigin=tempVec3c$i;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);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$d);rtcCameraEye=tempVec3d$e;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniform1i(this._uSolid,batchingLayer.solid);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
16168
16168
  gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=batchingLayer.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,tempVec3e$7);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}//=============================================================
16169
16169
  // TODO: Use drawElements count and offset to draw only one entity
16170
16170
  //=============================================================
16171
- gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,batchingLayer._state.positionsDecodeMatrix);this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);}state.indicesBuf.bind();gl.drawElements(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0);state.indicesBuf.unbind();}},{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._uPickInvisible=program.getLocation("pickInvisible");this._uSolid=program.getLocation("solid");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i214=0,len=scene._sectionPlanesState.sectionPlanes.length;_i214<len;_i214++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i214),pos:program.getLocation("sectionPlanePos"+_i214),dir:program.getLocation("sectionPlaneDir"+_i214)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// VBO SnapBatchingDepthBufInitRenderer 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;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("uniform bool pickInvisible;");src.push("uniform bool solid;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");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("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
16171
+ gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,batchingLayer._state.positionsDecodeMatrix);this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);}state.indicesBuf.bind();gl.drawElements(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0);state.indicesBuf.unbind();}},{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._uPickInvisible=program.getLocation("pickInvisible");this._uSolid=program.getLocation("solid");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i214=0,len=scene._sectionPlanesState.sectionPlanes.length;_i214<len;_i214++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i214),pos:program.getLocation("sectionPlanePos"+_i214),dir:program.getLocation("sectionPlaneDir"+_i214)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// VBO SnapBatchingDepthBufInitRenderer 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;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("uniform bool pickInvisible;");src.push("uniform bool solid;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");{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("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
16172
16172
  // renderPass = PICK
16173
16173
  src.push("int pickFlag = int(flags) >> 12 & 0xF;");src.push("if (pickFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
16174
16174
  src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.z += 0.0001;");// small Z offset
16175
- src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}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("// VBO SnapBatchingDepthBufInitRenderer 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;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i215=0;_i215<sectionPlanesState.sectionPlanes.length;_i215++){src.push("uniform bool sectionPlaneActive"+_i215+";");src.push("uniform vec3 sectionPlanePos"+_i215+";");src.push("uniform vec3 sectionPlaneDir"+_i215+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");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 SnapBatchingDepthBufInitRenderer;}();var tempVec3a$q=math.vec3();var tempVec3b$k=math.vec3();var tempVec3c$h=math.vec3();var tempVec3d$d=math.vec3();var tempVec3e$6=math.vec3();var tempMat4a$c=math.mat4();/**
16175
+ src.push("clipPos.xyzw *= tmp;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}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("// VBO SnapBatchingDepthBufInitRenderer 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");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i215=0;_i215<sectionPlanesState.sectionPlanes.length;_i215++){src.push("uniform bool sectionPlaneActive"+_i215+";");src.push("uniform vec3 sectionPlanePos"+_i215+";");src.push("uniform vec3 sectionPlaneDir"+_i215+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");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 SnapBatchingDepthBufInitRenderer;}();var tempVec3a$q=math.vec3();var tempVec3b$k=math.vec3();var tempVec3c$h=math.vec3();var tempVec3d$d=math.vec3();var tempVec3e$6=math.vec3();var tempMat4a$c=math.mat4();/**
16176
16176
  * @private
16177
- */var SnapBatchingDepthRenderer=/*#__PURE__*/function(){function SnapBatchingDepthRenderer(scene){_classCallCheck(this,SnapBatchingDepthRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapBatchingDepthRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=batchingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=batchingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$q;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$k;if(origin){var rotatedOrigin=tempVec3c$h;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);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$c);rtcCameraEye=tempVec3d$d;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
16177
+ */var SnapBatchingDepthRenderer=/*#__PURE__*/function(){function SnapBatchingDepthRenderer(scene){_classCallCheck(this,SnapBatchingDepthRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapBatchingDepthRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=batchingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=batchingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$q;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$k;if(origin){var rotatedOrigin=tempVec3c$h;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);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$c);rtcCameraEye=tempVec3d$d;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
16178
16178
  gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=batchingLayer.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,tempVec3e$6);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}//=============================================================
16179
16179
  // TODO: Use drawElements count and offset to draw only one entity
16180
16180
  //=============================================================
16181
16181
  gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,batchingLayer._state.positionsDecodeMatrix);this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);}if(frameCtx.snapMode==="edge"){state.edgeIndicesBuf.bind();gl.drawElements(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0);state.edgeIndicesBuf.unbind();// needed?
16182
- }else{gl.drawArrays(gl.POINTS,0,state.positionsBuf.numItems);}}},{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._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i216=0,len=scene._sectionPlanesState.sectionPlanes.length;_i216<len;_i216++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i216),pos:program.getLocation("sectionPlanePos"+_i216),dir:program.getLocation("sectionPlaneDir"+_i216)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// SnapBatchingDepthRenderer 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;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("uniform bool pickInvisible;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");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;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
16182
+ }else{gl.drawArrays(gl.POINTS,0,state.positionsBuf.numItems);}}},{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._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i216=0,len=scene._sectionPlanesState.sectionPlanes.length;_i216<len;_i216++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i216),pos:program.getLocation("sectionPlanePos"+_i216),dir:program.getLocation("sectionPlaneDir"+_i216)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// SnapBatchingDepthRenderer 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;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("uniform bool pickInvisible;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");{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;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
16183
16183
  // renderPass = PICK
16184
16184
  src.push("int pickFlag = int(flags) >> 12 & 0xF;");src.push("if (pickFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
16185
- src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("gl_PointSize = 1.0;");// Windows needs this?
16186
- 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("// SnapBatchingDepthRenderer 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;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i217=0;_i217<sectionPlanesState.sectionPlanes.length;_i217++){src.push("uniform bool sectionPlaneActive"+_i217+";");src.push("uniform vec3 sectionPlanePos"+_i217+";");src.push("uniform vec3 sectionPlaneDir"+_i217+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, layerNumber);");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 SnapBatchingDepthRenderer;}();/**
16185
+ src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("gl_PointSize = 1.0;");// Windows needs this?
16186
+ 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("// SnapBatchingDepthRenderer 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");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i217=0;_i217<sectionPlanesState.sectionPlanes.length;_i217++){src.push("uniform bool sectionPlaneActive"+_i217+";");src.push("uniform vec3 sectionPlanePos"+_i217+";");src.push("uniform vec3 sectionPlaneDir"+_i217+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, layerNumber);");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 SnapBatchingDepthRenderer;}();/**
16187
16187
  * @private
16188
16188
  */var SnapBatchingRenderers=/*#__PURE__*/function(){function SnapBatchingRenderers(scene){_classCallCheck(this,SnapBatchingRenderers);this._scene=scene;}_createClass(SnapBatchingRenderers,[{key:"_compile",value:function _compile(){if(this._snapDepthBufInitRenderer&&!this._snapDepthBufInitRenderer.getValid()){this._snapDepthBufInitRenderer.destroy();this._snapDepthBufInitRenderer=null;}if(this._snapDepthRenderer&&!this._snapDepthRenderer.getValid()){this._snapDepthRenderer.destroy();this._snapDepthRenderer=null;}}},{key:"snapDepthBufInitRenderer",get:function get(){if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapBatchingDepthBufInitRenderer(this._scene,false);}return this._snapDepthBufInitRenderer;}},{key:"snapDepthRenderer",get:function get(){if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapBatchingDepthRenderer(this._scene);}return this._snapDepthRenderer;}},{key:"_destroy",value:function _destroy(){if(this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer.destroy();}if(this._snapDepthRenderer){this._snapDepthRenderer.destroy();}}}]);return SnapBatchingRenderers;}();var cachedRenderers$6={};/**
16189
16189
  * @private
16190
- */function getSnapBatchingRenderers(scene){var sceneId=scene.id;var batchingRenderers=cachedRenderers$6[sceneId];if(!batchingRenderers){batchingRenderers=new SnapBatchingRenderers(scene);cachedRenderers$6[sceneId]=batchingRenderers;batchingRenderers._compile();scene.on("compile",function(){batchingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers$6[sceneId];batchingRenderers._destroy();});}return batchingRenderers;}var tempMat4$1=math.mat4();var tempMat4b=math.mat4();var tempVec4a$c=math.vec4([0,0,0,1]);var tempVec4b$b=math.vec4([0,0,0,1]);var tempVec4c$8=math.vec4([0,0,0,1]);var tempOBB3$2=math.OBB3();var tempVec3a$p=math.vec3();var tempVec3b$j=math.vec3();var tempVec3c$g=math.vec3();var tempVec3d$c=math.vec3();var tempVec3e$5=math.vec3();var tempVec3f$1=math.vec3();var tempVec3g$1=math.vec3();/**
16190
+ */function getSnapBatchingRenderers(scene){var sceneId=scene.id;var batchingRenderers=cachedRenderers$6[sceneId];if(!batchingRenderers){batchingRenderers=new SnapBatchingRenderers(scene);cachedRenderers$6[sceneId]=batchingRenderers;batchingRenderers._compile();scene.on("compile",function(){batchingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers$6[sceneId];batchingRenderers._destroy();});}return batchingRenderers;}var tempMat4$1=math.mat4();var tempMat4b=math.mat4();var tempVec4a$c=math.vec4([0,0,0,1]);var tempVec4b$b=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);math.OBB3();var tempVec3a$p=math.vec3();var tempVec3b$j=math.vec3();var tempVec3c$g=math.vec3();var tempVec3d$c=math.vec3();var tempVec3e$5=math.vec3();var tempVec3f$1=math.vec3();var tempVec3g$1=math.vec3();/**
16191
16191
  * @private
16192
16192
  */var TrianglesBatchingLayer=/*#__PURE__*/function(){/**
16193
16193
  * @param model
@@ -16245,11 +16245,10 @@ this._portions=[];this._numVerts=0;this._finalized=false;if(cfg.positionsDecodeM
16245
16245
  * @param cfg.roughness Roughness factor [0..255]
16246
16246
  * @param cfg.opacity Opacity [0..255]
16247
16247
  * @param [cfg.meshMatrix] Flat float 4x4 matrix
16248
- * @param [cfg.sceneModelMatrix] Flat float 4x4 matrix
16249
16248
  * @param cfg.worldAABB Flat float AABB World-space AABB
16250
16249
  * @param cfg.pickColor Quantized pick color
16251
16250
  * @returns {number} Portion ID
16252
- */},{key:"createPortion",value:function createPortion(cfg){if(this._finalized){throw"Already finalized";}var positions=cfg.positions;var positionsCompressed=cfg.positionsCompressed;var normals=cfg.normals;var normalsCompressed=cfg.normalsCompressed;var uv=cfg.uv;var uvCompressed=cfg.uvCompressed;var colors=cfg.colors;var colorsCompressed=cfg.colorsCompressed;var indices=cfg.indices;var edgeIndices=cfg.edgeIndices;var color=cfg.color;var metallic=cfg.metallic;var roughness=cfg.roughness;var opacity=cfg.opacity;var meshMatrix=cfg.meshMatrix;var sceneModelMatrix=cfg.sceneModelMatrix;var worldAABB=cfg.worldAABB;var pickColor=cfg.pickColor;var scene=this.model.scene;var buffer=this._buffer;var vertsBaseIndex=buffer.positions.length/3;var numVerts;if(this._state.positionsDecodeMatrix){if(!positionsCompressed){throw"positionsCompressed expected";}numVerts=positionsCompressed.length/3;for(var _i218=0,len=positionsCompressed.length;_i218<len;_i218++){buffer.positions.push(positionsCompressed[_i218]);}var bounds=geometryCompressionUtils.getPositionsBounds(positionsCompressed);var min=geometryCompressionUtils.decompressPosition(bounds.min,this._state.positionsDecodeMatrix,[]);var _max=geometryCompressionUtils.decompressPosition(bounds.max,this._state.positionsDecodeMatrix,[]);worldAABB[0]=min[0];worldAABB[1]=min[1];worldAABB[2]=min[2];worldAABB[3]=_max[0];worldAABB[4]=_max[1];worldAABB[5]=_max[2];if(sceneModelMatrix){math.AABB3ToOBB3(worldAABB,tempOBB3$2);math.transformOBB3(sceneModelMatrix,tempOBB3$2);math.OBB3ToAABB3(tempOBB3$2,worldAABB);}}else{if(!positions){throw"positions expected";}numVerts=positions.length/3;var lenPositions=positions.length;var positionsBase=buffer.positions.length;for(var _i219=0,_len36=positions.length;_i219<_len36;_i219++){buffer.positions.push(positions[_i219]);}if(meshMatrix){for(var _i220=positionsBase,_len37=positionsBase+lenPositions;_i220<_len37;_i220+=3){tempVec4a$c[0]=buffer.positions[_i220+0];tempVec4a$c[1]=buffer.positions[_i220+1];tempVec4a$c[2]=buffer.positions[_i220+2];math.transformPoint4(meshMatrix,tempVec4a$c,tempVec4b$b);buffer.positions[_i220+0]=tempVec4b$b[0];buffer.positions[_i220+1]=tempVec4b$b[1];buffer.positions[_i220+2]=tempVec4b$b[2];math.expandAABB3Point3(this._modelAABB,tempVec4b$b);if(sceneModelMatrix){math.transformPoint4(sceneModelMatrix,tempVec4b$b,tempVec4c$8);math.expandAABB3Point3(worldAABB,tempVec4c$8);}else{math.expandAABB3Point3(worldAABB,tempVec4b$b);}}}else{for(var _i221=positionsBase,_len38=positionsBase+lenPositions;_i221<_len38;_i221+=3){tempVec4a$c[0]=buffer.positions[_i221+0];tempVec4a$c[1]=buffer.positions[_i221+1];tempVec4a$c[2]=buffer.positions[_i221+2];math.expandAABB3Point3(this._modelAABB,tempVec4a$c);if(sceneModelMatrix){math.transformPoint4(sceneModelMatrix,tempVec4a$c,tempVec4b$b);math.expandAABB3Point3(worldAABB,tempVec4b$b);}else{math.expandAABB3Point3(worldAABB,tempVec4a$c);}}}}if(this._state.origin){var _origin7=this._state.origin;worldAABB[0]+=_origin7[0];worldAABB[1]+=_origin7[1];worldAABB[2]+=_origin7[2];worldAABB[3]+=_origin7[0];worldAABB[4]+=_origin7[1];worldAABB[5]+=_origin7[2];}math.expandAABB3(this.aabb,worldAABB);if(normalsCompressed&&normalsCompressed.length>0){for(var _i222=0,_len39=normalsCompressed.length;_i222<_len39;_i222++){buffer.normals.push(normalsCompressed[_i222]);}}else if(normals&&normals.length>0){var worldNormalMatrix=tempMat4$1;if(meshMatrix){math.inverseMat4(math.transposeMat4(meshMatrix,tempMat4b),worldNormalMatrix);// Note: order of inverse and transpose doesn't matter
16251
+ */},{key:"createPortion",value:function createPortion(cfg){if(this._finalized){throw"Already finalized";}var positions=cfg.positions;var positionsCompressed=cfg.positionsCompressed;var normals=cfg.normals;var normalsCompressed=cfg.normalsCompressed;var uv=cfg.uv;var uvCompressed=cfg.uvCompressed;var colors=cfg.colors;var colorsCompressed=cfg.colorsCompressed;var indices=cfg.indices;var edgeIndices=cfg.edgeIndices;var color=cfg.color;var metallic=cfg.metallic;var roughness=cfg.roughness;var opacity=cfg.opacity;var meshMatrix=cfg.meshMatrix;var worldAABB=cfg.worldAABB;var pickColor=cfg.pickColor;var scene=this.model.scene;var buffer=this._buffer;var vertsBaseIndex=buffer.positions.length/3;var numVerts;if(this._state.positionsDecodeMatrix){if(!positionsCompressed){throw"positionsCompressed expected";}numVerts=positionsCompressed.length/3;for(var _i218=0,len=positionsCompressed.length;_i218<len;_i218++){buffer.positions.push(positionsCompressed[_i218]);}var bounds=geometryCompressionUtils.getPositionsBounds(positionsCompressed);var min=geometryCompressionUtils.decompressPosition(bounds.min,this._state.positionsDecodeMatrix,[]);var _max=geometryCompressionUtils.decompressPosition(bounds.max,this._state.positionsDecodeMatrix,[]);worldAABB[0]=min[0];worldAABB[1]=min[1];worldAABB[2]=min[2];worldAABB[3]=_max[0];worldAABB[4]=_max[1];worldAABB[5]=_max[2];}else{if(!positions){throw"positions expected";}numVerts=positions.length/3;var lenPositions=positions.length;var positionsBase=buffer.positions.length;for(var _i219=0,_len36=positions.length;_i219<_len36;_i219++){buffer.positions.push(positions[_i219]);}if(meshMatrix){for(var _i220=positionsBase,_len37=positionsBase+lenPositions;_i220<_len37;_i220+=3){tempVec4a$c[0]=buffer.positions[_i220+0];tempVec4a$c[1]=buffer.positions[_i220+1];tempVec4a$c[2]=buffer.positions[_i220+2];math.transformPoint4(meshMatrix,tempVec4a$c,tempVec4b$b);buffer.positions[_i220+0]=tempVec4b$b[0];buffer.positions[_i220+1]=tempVec4b$b[1];buffer.positions[_i220+2]=tempVec4b$b[2];math.expandAABB3Point3(this._modelAABB,tempVec4b$b);math.expandAABB3Point3(worldAABB,tempVec4b$b);}}else{for(var _i221=positionsBase,_len38=positionsBase+lenPositions;_i221<_len38;_i221+=3){tempVec4a$c[0]=buffer.positions[_i221+0];tempVec4a$c[1]=buffer.positions[_i221+1];tempVec4a$c[2]=buffer.positions[_i221+2];math.expandAABB3Point3(this._modelAABB,tempVec4a$c);math.expandAABB3Point3(worldAABB,tempVec4a$c);}}}if(this._state.origin){var _origin7=this._state.origin;worldAABB[0]+=_origin7[0];worldAABB[1]+=_origin7[1];worldAABB[2]+=_origin7[2];worldAABB[3]+=_origin7[0];worldAABB[4]+=_origin7[1];worldAABB[5]+=_origin7[2];}math.expandAABB3(this.aabb,worldAABB);if(normalsCompressed&&normalsCompressed.length>0){for(var _i222=0,_len39=normalsCompressed.length;_i222<_len39;_i222++){buffer.normals.push(normalsCompressed[_i222]);}}else if(normals&&normals.length>0){var worldNormalMatrix=tempMat4$1;if(meshMatrix){math.inverseMat4(math.transposeMat4(meshMatrix,tempMat4b),worldNormalMatrix);// Note: order of inverse and transpose doesn't matter
16253
16252
  }else{math.identityMat4(worldNormalMatrix,worldNormalMatrix);}transformAndOctEncodeNormals(worldNormalMatrix,normals,normals.length,buffer.normals,buffer.normals.length);}if(colors){for(var _i223=0,_len40=colors.length;_i223<_len40;_i223+=3){buffer.colors.push(colors[_i223]*255);buffer.colors.push(colors[_i223+1]*255);buffer.colors.push(colors[_i223+2]*255);buffer.colors.push(255);}}else if(colorsCompressed){for(var _i224=0,_len41=colors.length;_i224<_len41;_i224+=3){buffer.colors.push(colors[_i224]);buffer.colors.push(colors[_i224+1]);buffer.colors.push(colors[_i224+2]);buffer.colors.push(255);}}else if(color){var _r3=color[0];// Color is pre-quantized by VBOSceneModel
16254
16253
  var g=color[1];var b=color[2];var _a3=opacity;for(var _i225=0;_i225<numVerts;_i225++){buffer.colors.push(_r3);buffer.colors.push(g);buffer.colors.push(b);buffer.colors.push(_a3);}}var metallicValue=metallic!==null&&metallic!==undefined?metallic:0;var roughnessValue=roughness!==null&&roughness!==undefined?roughness:255;for(var _i226=0;_i226<numVerts;_i226++){buffer.metallicRoughness.push(metallicValue);buffer.metallicRoughness.push(roughnessValue);}if(uv&&uv.length>0){for(var _i227=0,_len42=uv.length;_i227<_len42;_i227++){buffer.uv.push(uv[_i227]);}}else if(uvCompressed&&uvCompressed.length>0){for(var _i228=0,_len43=uvCompressed.length;_i228<_len43;_i228++){buffer.uv.push(uvCompressed[_i228]);}}for(var _i229=0,_len44=indices.length;_i229<_len44;_i229++){buffer.indices.push(vertsBaseIndex+indices[_i229]);}if(edgeIndices){for(var _i230=0,_len45=edgeIndices.length;_i230<_len45;_i230++){buffer.edgeIndices.push(vertsBaseIndex+edgeIndices[_i230]);}}{var pickColorsBase=buffer.pickColors.length;var lenPickColors=numVerts*4;for(var _i231=pickColorsBase,_len46=pickColorsBase+lenPickColors;_i231<_len46;_i231+=4){buffer.pickColors.push(pickColor[0]);buffer.pickColors.push(pickColor[1]);buffer.pickColors.push(pickColor[2]);buffer.pickColors.push(pickColor[3]);}}if(scene.entityOffsetsEnabled){for(var _i232=0;_i232<numVerts;_i232++){buffer.offsets.push(0);buffer.offsets.push(0);buffer.offsets.push(0);}}var portionId=this._portions.length;var portion={vertsBaseIndex:vertsBaseIndex,numVerts:numVerts,indicesBaseIndex:buffer.indices.length-indices.length,numIndices:indices.length};if(scene.pickSurfacePrecisionEnabled){// Quantized in-memory positions are initialized in finalize()
16255
16254
  portion.indices=indices;if(scene.entityOffsetsEnabled){portion.offset=new Float32Array(3);}}this._portions.push(portion);this._numPortions++;this.model.numPortions++;this._numVerts+=portion.numVerts;return portionId;}/**
@@ -16404,27 +16403,27 @@ src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewp
16404
16403
  * @private
16405
16404
  */function getInstancingRenderers$1(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$5[sceneId];if(!instancingRenderers){instancingRenderers=new TrianglesInstancingRenderers(scene);cachedRenderers$5[sceneId]=instancingRenderers;instancingRenderers._compile();scene.on("compile",function(){instancingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers$5[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempVec3a$o=math.vec3();var tempVec3b$i=math.vec3();var tempVec3c$f=math.vec3();var tempVec3d$b=math.vec3();var tempVec3e$4=math.vec3();var tempMat4a$b=math.mat4();/**
16406
16405
  * @private
16407
- */var SnapInstancingDepthBufInitRenderer=/*#__PURE__*/function(){function SnapInstancingDepthBufInitRenderer(scene){_classCallCheck(this,SnapInstancingDepthBufInitRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapInstancingDepthBufInitRenderer,[{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,instancingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=instancingLayer.model;var scene=model.scene;var gl=scene.canvas.gl;var camera=scene.camera;var state=instancingLayer._state;var origin=instancingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=instancingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$o;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$i;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$f);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$b);rtcCameraEye=tempVec3d$b;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);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=instancingLayer.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,tempVec3e$4);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,state.positionsDecodeMatrix);this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);gl.vertexAttribDivisor(this._aOffset.location,1);}state.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);state.indicesBuf.unbind();// Cleanup
16408
- gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);if(this._aFlags){gl.vertexAttribDivisor(this._aFlags.location,0);}if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{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._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i268=0,len=scene._sectionPlanesState.sectionPlanes.length;_i268<len;_i268++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i268),pos:program.getLocation("sectionPlanePos"+_i268),dir:program.getLocation("sectionPlaneDir"+_i268)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{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("// SnapInstancingDepthBufInitRenderer 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;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
16409
- src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");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;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
16406
+ */var SnapInstancingDepthBufInitRenderer=/*#__PURE__*/function(){function SnapInstancingDepthBufInitRenderer(scene){_classCallCheck(this,SnapInstancingDepthBufInitRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapInstancingDepthBufInitRenderer,[{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,instancingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=instancingLayer.model;var scene=model.scene;var gl=scene.canvas.gl;var camera=scene.camera;var state=instancingLayer._state;var origin=instancingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=instancingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$o;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$i;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$f);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$b);rtcCameraEye=tempVec3d$b;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);{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=instancingLayer.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,tempVec3e$4);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,state.positionsDecodeMatrix);this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);gl.vertexAttribDivisor(this._aOffset.location,1);}state.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);state.indicesBuf.unbind();// Cleanup
16407
+ gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);if(this._aFlags){gl.vertexAttribDivisor(this._aFlags.location,0);}if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{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._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i268=0,len=scene._sectionPlanesState.sectionPlanes.length;_i268<len;_i268++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i268),pos:program.getLocation("sectionPlanePos"+_i268),dir:program.getLocation("sectionPlaneDir"+_i268)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{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("// SnapInstancingDepthBufInitRenderer 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;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
16408
+ src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");{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;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
16410
16409
  // renderPass = PICK
16411
16410
  src.push("int pickFlag = int(flags) >> 12 & 0xF;");src.push("if (pickFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
16412
16411
  src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.z += 0.0001;");// small Z offset
16413
- src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}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("// Points instancing pick depth 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;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i269=0;_i269<sectionPlanesState.sectionPlanes.length;_i269++){src.push("uniform bool sectionPlaneActive"+_i269+";");src.push("uniform vec3 sectionPlanePos"+_i269+";");src.push("uniform vec3 sectionPlaneDir"+_i269+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i270=0;_i270<sectionPlanesState.sectionPlanes.length;_i270++){src.push("if (sectionPlaneActive"+_i270+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i270+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i270+".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("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");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 SnapInstancingDepthBufInitRenderer;}();var tempVec3a$n=math.vec3();var tempVec3b$h=math.vec3();var tempVec3c$e=math.vec3();var tempVec3d$a=math.vec3();var tempVec3e$3=math.vec3();var tempMat4a$a=math.mat4();/**
16412
+ src.push("clipPos.xyzw *= tmp;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}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("// Points instancing pick depth 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");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i269=0;_i269<sectionPlanesState.sectionPlanes.length;_i269++){src.push("uniform bool sectionPlaneActive"+_i269+";");src.push("uniform vec3 sectionPlanePos"+_i269+";");src.push("uniform vec3 sectionPlaneDir"+_i269+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i270=0;_i270<sectionPlanesState.sectionPlanes.length;_i270++){src.push("if (sectionPlaneActive"+_i270+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i270+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i270+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}{src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");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 SnapInstancingDepthBufInitRenderer;}();var tempVec3a$n=math.vec3();var tempVec3b$h=math.vec3();var tempVec3c$e=math.vec3();var tempVec3d$a=math.vec3();var tempVec3e$3=math.vec3();var tempMat4a$a=math.mat4();/**
16414
16413
  * @private
16415
- */var SnapInstancingDepthRenderer=/*#__PURE__*/function(){function SnapInstancingDepthRenderer(scene){_classCallCheck(this,SnapInstancingDepthRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapInstancingDepthRenderer,[{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,instancingLayer,renderPass){if(!this._program){this._allocate(instancingLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=instancingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=instancingLayer._state;var origin=instancingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=instancingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$n;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$h;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$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$a);rtcCameraEye=tempVec3d$a;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix
16414
+ */var SnapInstancingDepthRenderer=/*#__PURE__*/function(){function SnapInstancingDepthRenderer(scene){_classCallCheck(this,SnapInstancingDepthRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapInstancingDepthRenderer,[{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,instancingLayer,renderPass){if(!this._program){this._allocate(instancingLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=instancingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=instancingLayer._state;var origin=instancingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=instancingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$n;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$h;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$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$a);rtcCameraEye=tempVec3d$a;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix
16416
16415
  gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=instancingLayer.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,tempVec3e$3);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,state.positionsDecodeMatrix);this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);this._aPosition.bindArrayBuffer(state.positionsBuf);this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);gl.vertexAttribDivisor(this._aOffset.location,1);}if(frameCtx.snapMode==="edge"){state.edgeIndicesBuf.bind();gl.drawElementsInstanced(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0,state.numInstances);state.edgeIndicesBuf.unbind();// needed?
16417
16416
  }else{gl.drawArraysInstanced(gl.POINTS,0,state.positionsBuf.numItems,state.numInstances);}// Cleanup
16418
- gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);gl.vertexAttribDivisor(this._aFlags.location,0);if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{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._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i271=0,len=scene._sectionPlanesState.sectionPlanes.length;_i271<len;_i271++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i271),pos:program.getLocation("sectionPlanePos"+_i271),dir:program.getLocation("sectionPlaneDir"+_i271)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{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("// SnapInstancingDepthRenderer 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;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
16419
- src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");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;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
16417
+ gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);gl.vertexAttribDivisor(this._aFlags.location,0);if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{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._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i271=0,len=scene._sectionPlanesState.sectionPlanes.length;_i271<len;_i271++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i271),pos:program.getLocation("sectionPlanePos"+_i271),dir:program.getLocation("sectionPlaneDir"+_i271)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{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("// SnapInstancingDepthRenderer 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;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
16418
+ src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");{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;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
16420
16419
  // renderPass = PICK
16421
16420
  src.push("int pickFlag = int(flags) >> 12 & 0xF;");src.push("if (pickFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
16422
- src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("gl_PointSize = 1.0;");// Windows needs this?
16423
- 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("// SnapInstancingDepthRenderer 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;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i272=0;_i272<sectionPlanesState.sectionPlanes.length;_i272++){src.push("uniform bool sectionPlaneActive"+_i272+";");src.push("uniform vec3 sectionPlanePos"+_i272+";");src.push("uniform vec3 sectionPlaneDir"+_i272+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i273=0;_i273<sectionPlanesState.sectionPlanes.length;_i273++){src.push("if (sectionPlaneActive"+_i273+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i273+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i273+".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("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, layerNumber);");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 SnapInstancingDepthRenderer;}();/**
16421
+ src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("gl_PointSize = 1.0;");// Windows needs this?
16422
+ 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("// SnapInstancingDepthRenderer 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");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i272=0;_i272<sectionPlanesState.sectionPlanes.length;_i272++){src.push("uniform bool sectionPlaneActive"+_i272+";");src.push("uniform vec3 sectionPlanePos"+_i272+";");src.push("uniform vec3 sectionPlaneDir"+_i272+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i273=0;_i273<sectionPlanesState.sectionPlanes.length;_i273++){src.push("if (sectionPlaneActive"+_i273+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i273+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i273+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}{src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, layerNumber);");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 SnapInstancingDepthRenderer;}();/**
16424
16423
  * @private
16425
16424
  */var SnapInstancingRenderers=/*#__PURE__*/function(){function SnapInstancingRenderers(scene){_classCallCheck(this,SnapInstancingRenderers);this._scene=scene;}_createClass(SnapInstancingRenderers,[{key:"_compile",value:function _compile(){if(this._snapDepthBufInitRenderer&&!this._snapDepthBufInitRenderer.getValid()){this._snapDepthBufInitRenderer.destroy();this._snapDepthBufInitRenderer=null;}if(this._snapDepthRenderer&&!this._snapDepthRenderer.getValid()){this._snapDepthRenderer.destroy();this._snapDepthRenderer=null;}}},{key:"snapDepthBufInitRenderer",get:function get(){if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapInstancingDepthBufInitRenderer(this._scene,false);}return this._snapDepthBufInitRenderer;}},{key:"snapDepthRenderer",get:function get(){if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapInstancingDepthRenderer(this._scene);}return this._snapDepthRenderer;}},{key:"_destroy",value:function _destroy(){if(this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer.destroy();}if(this._snapDepthRenderer){this._snapDepthRenderer.destroy();}}}]);return SnapInstancingRenderers;}();var cachedRenderers$4={};/**
16426
16425
  * @private
16427
- */function getSnapInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$4[sceneId];if(!instancingRenderers){instancingRenderers=new SnapInstancingRenderers(scene);cachedRenderers$4[sceneId]=instancingRenderers;instancingRenderers._compile();scene.on("compile",function(){instancingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers$4[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempUint8Vec4$2=new Uint8Array(4);var tempFloat32$2=new Float32Array(1);var tempVec4a$b=math.vec4([0,0,0,1]);var tempVec4b$a=math.vec4([0,0,0,1]);var tempVec4c$7=math.vec4([0,0,0,1]);var tempVec3fa$2=new Float32Array(3);var tempVec3a$m=math.vec3();var tempVec3b$g=math.vec3();var tempVec3c$d=math.vec3();var tempVec3d$9=math.vec3();var tempVec3e$2=math.vec3();var tempVec3f=math.vec3();var tempVec3g=math.vec3();/**
16426
+ */function getSnapInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$4[sceneId];if(!instancingRenderers){instancingRenderers=new SnapInstancingRenderers(scene);cachedRenderers$4[sceneId]=instancingRenderers;instancingRenderers._compile();scene.on("compile",function(){instancingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers$4[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempUint8Vec4$2=new Uint8Array(4);var tempFloat32$2=new Float32Array(1);var tempVec4a$b=math.vec4([0,0,0,1]);var tempVec4b$a=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);var tempVec3fa$2=new Float32Array(3);var tempVec3a$m=math.vec3();var tempVec3b$g=math.vec3();var tempVec3c$d=math.vec3();var tempVec3d$9=math.vec3();var tempVec3e$2=math.vec3();var tempVec3f=math.vec3();var tempVec3g=math.vec3();/**
16428
16427
  * @private
16429
16428
  */var TrianglesInstancingLayer=/*#__PURE__*/function(){/**
16430
16429
  * @param cfg
@@ -16470,18 +16469,17 @@ this._modelNormalMatrixCol0=[];this._modelNormalMatrixCol1=[];this._modelNormalM
16470
16469
  * @param cfg.roughness Roughness factor [0..255]
16471
16470
  * @param cfg.opacity Opacity [0..255].
16472
16471
  * @param cfg.meshMatrix Flat float 4x4 matrix.
16473
- * @param [cfg.sceneModelMatrix] Flat float 4x4 matrix.
16474
16472
  * @param [cfg.worldMatrix] Flat float 4x4 matrix.
16475
16473
  * @param cfg.worldAABB Flat float AABB.
16476
16474
  * @param cfg.pickColor Quantized pick color
16477
16475
  * @returns {number} Portion ID.
16478
- */_createClass(TrianglesInstancingLayer,[{key:"createPortion",value:function createPortion(cfg){var color=cfg.color;var metallic=cfg.metallic;var roughness=cfg.roughness;var opacity=cfg.opacity!==null&&cfg.opacity!==undefined?cfg.opacity:255;var meshMatrix=cfg.meshMatrix;var sceneModelMatrix=cfg.sceneModelMatrix;var worldAABB=cfg.aabb;var pickColor=cfg.pickColor;if(this._finalized){throw"Already finalized";}// TODO: find AABB for portion by transforming the geometry local AABB by the given meshMatrix?
16476
+ */_createClass(TrianglesInstancingLayer,[{key:"createPortion",value:function createPortion(cfg){var color=cfg.color;var metallic=cfg.metallic;var roughness=cfg.roughness;var opacity=cfg.opacity!==null&&cfg.opacity!==undefined?cfg.opacity:255;var meshMatrix=cfg.meshMatrix;var worldAABB=cfg.aabb;var pickColor=cfg.pickColor;if(this._finalized){throw"Already finalized";}// TODO: find AABB for portion by transforming the geometry local AABB by the given meshMatrix?
16479
16477
  var r=color[0];// Color is pre-quantized by SceneModel
16480
16478
  var g=color[1];var b=color[2];this._colors.push(r);this._colors.push(g);this._colors.push(b);this._colors.push(opacity);this._metallicRoughness.push(metallic!==null&&metallic!==undefined?metallic:0);this._metallicRoughness.push(roughness!==null&&roughness!==undefined?roughness:255);if(this.model.scene.entityOffsetsEnabled){this._offsets.push(0);this._offsets.push(0);this._offsets.push(0);}this._modelMatrixCol0.push(meshMatrix[0]);this._modelMatrixCol0.push(meshMatrix[4]);this._modelMatrixCol0.push(meshMatrix[8]);this._modelMatrixCol0.push(meshMatrix[12]);this._modelMatrixCol1.push(meshMatrix[1]);this._modelMatrixCol1.push(meshMatrix[5]);this._modelMatrixCol1.push(meshMatrix[9]);this._modelMatrixCol1.push(meshMatrix[13]);this._modelMatrixCol2.push(meshMatrix[2]);this._modelMatrixCol2.push(meshMatrix[6]);this._modelMatrixCol2.push(meshMatrix[10]);this._modelMatrixCol2.push(meshMatrix[14]);if(this._state.geometry.normals){// Note: order of inverse and transpose doesn't matter
16481
16479
  var transposedMat=math.transposeMat4(meshMatrix,math.mat4());// TODO: Use cached matrix
16482
16480
  var normalMatrix=math.inverseMat4(transposedMat);this._modelNormalMatrixCol0.push(normalMatrix[0]);this._modelNormalMatrixCol0.push(normalMatrix[4]);this._modelNormalMatrixCol0.push(normalMatrix[8]);this._modelNormalMatrixCol0.push(normalMatrix[12]);this._modelNormalMatrixCol1.push(normalMatrix[1]);this._modelNormalMatrixCol1.push(normalMatrix[5]);this._modelNormalMatrixCol1.push(normalMatrix[9]);this._modelNormalMatrixCol1.push(normalMatrix[13]);this._modelNormalMatrixCol2.push(normalMatrix[2]);this._modelNormalMatrixCol2.push(normalMatrix[6]);this._modelNormalMatrixCol2.push(normalMatrix[10]);this._modelNormalMatrixCol2.push(normalMatrix[14]);}// Per-vertex pick colors
16483
16481
  this._pickColors.push(pickColor[0]);this._pickColors.push(pickColor[1]);this._pickColors.push(pickColor[2]);this._pickColors.push(pickColor[3]);// Expand AABB
16484
- var lenPositions=this._state.geometry.positionsCompressed.length;var positions=this._state.geometry.positionsCompressed;var positionsDecodeMatrix=this._state.geometry.positionsDecodeMatrix;for(var _i274=0;_i274<lenPositions;_i274+=3){tempVec4a$b[0]=positions[_i274+0];tempVec4a$b[1]=positions[_i274+1];tempVec4a$b[2]=positions[_i274+2];math.transformPoint4(positionsDecodeMatrix,tempVec4a$b,tempVec4b$a);math.transformPoint4(meshMatrix,tempVec4b$a,tempVec4a$b);if(sceneModelMatrix){math.transformPoint4(sceneModelMatrix,tempVec4a$b,tempVec4c$7);math.expandAABB3Point3(worldAABB,tempVec4c$7);}else{math.expandAABB3Point3(worldAABB,tempVec4a$b);}}if(this._state.origin){var _origin8=this._state.origin;worldAABB[0]+=_origin8[0];worldAABB[1]+=_origin8[1];worldAABB[2]+=_origin8[2];worldAABB[3]+=_origin8[0];worldAABB[4]+=_origin8[1];worldAABB[5]+=_origin8[2];}math.expandAABB3(this.aabb,worldAABB);this._state.numInstances++;var portionId=this._portions.length;var portion={};if(this.model.scene.pickSurfacePrecisionEnabled){portion.matrix=meshMatrix.slice();portion.inverseMatrix=null;// Lazy-computed in precisionRayPickSurface
16482
+ var lenPositions=this._state.geometry.positionsCompressed.length;var positions=this._state.geometry.positionsCompressed;var positionsDecodeMatrix=this._state.geometry.positionsDecodeMatrix;for(var _i274=0;_i274<lenPositions;_i274+=3){tempVec4a$b[0]=positions[_i274+0];tempVec4a$b[1]=positions[_i274+1];tempVec4a$b[2]=positions[_i274+2];math.transformPoint4(positionsDecodeMatrix,tempVec4a$b,tempVec4b$a);math.transformPoint4(meshMatrix,tempVec4b$a,tempVec4a$b);math.expandAABB3Point3(worldAABB,tempVec4a$b);}if(this._state.origin){var _origin8=this._state.origin;worldAABB[0]+=_origin8[0];worldAABB[1]+=_origin8[1];worldAABB[2]+=_origin8[2];worldAABB[3]+=_origin8[0];worldAABB[4]+=_origin8[1];worldAABB[5]+=_origin8[2];}math.expandAABB3(this.aabb,worldAABB);this._state.numInstances++;var portionId=this._portions.length;var portion={};if(this.model.scene.pickSurfacePrecisionEnabled){portion.matrix=meshMatrix.slice();portion.inverseMatrix=null;// Lazy-computed in precisionRayPickSurface
16485
16483
  portion.normalMatrix=null;// Lazy-computed in precisionRayPickSurface
16486
16484
  }this._portions.push(portion);this._numPortions++;this.model.numPortions++;return portionId;}},{key:"finalize",value:function finalize(){if(this._finalized){return;}var state=this._state;var geometry=state.geometry;var textureSet=state.textureSet;var gl=this.model.scene.canvas.gl;var colorsLength=this._colors.length;var flagsLength=colorsLength/4;if(colorsLength>0){var notNormalized=false;state.colorsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Uint8Array(this._colors),this._colors.length,4,gl.DYNAMIC_DRAW,notNormalized);this._colors=[];// Release memory
16487
16485
  }if(this._metallicRoughness.length>0){var metallicRoughness=new Uint8Array(this._metallicRoughness);var normalized=false;state.metallicRoughnessBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,metallicRoughness,this._metallicRoughness.length,2,gl.STATIC_DRAW,normalized);}if(flagsLength>0){// Because we only build flags arrays here,
@@ -16557,7 +16555,7 @@ src.push("} else {");src.push(" vec4 worldPosition = worldMatrix * (positio
16557
16555
  */function getBatchingRenderers(scene){var sceneId=scene.id;var batchingRenderers=cachedRenderers$3[sceneId];if(!batchingRenderers){batchingRenderers=new LinesBatchingRenderers(scene);cachedRenderers$3[sceneId]=batchingRenderers;batchingRenderers._compile();scene.on("compile",function(){batchingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers$3[sceneId];batchingRenderers._destroy();});}return batchingRenderers;}/**
16558
16556
  * @private
16559
16557
  */var LinesBatchingBuffer=/*#__PURE__*/_createClass(function LinesBatchingBuffer(){var maxGeometryBatchSize=arguments.length>0&&arguments[0]!==undefined?arguments[0]:5000000;_classCallCheck(this,LinesBatchingBuffer);if(maxGeometryBatchSize>5000000){maxGeometryBatchSize=5000000;}this.maxVerts=maxGeometryBatchSize;this.maxIndices=maxGeometryBatchSize*3;// Rough rule-of-thumb
16560
- this.positions=[];this.colors=[];this.offsets=[];this.indices=[];});var tempVec4a$a=math.vec4([0,0,0,1]);var tempVec4b$9=math.vec4([0,0,0,1]);var tempVec4c$6=math.vec4([0,0,0,1]);var tempOBB3$1=math.OBB3();/**
16558
+ this.positions=[];this.colors=[];this.offsets=[];this.indices=[];});var tempVec4a$a=math.vec4([0,0,0,1]);var tempVec4b$9=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);math.OBB3();/**
16561
16559
  * @private
16562
16560
  */var LinesBatchingLayer=/*#__PURE__*/function(){/**
16563
16561
  * @param model
@@ -16592,11 +16590,10 @@ this._portions=[];this._numVerts=0;this._finalized=false;if(cfg.positionsDecodeM
16592
16590
  * @param cfg.color Quantized RGB color [0..255,0..255,0..255,0..255]
16593
16591
  * @param cfg.opacity Opacity [0..255]
16594
16592
  * @param [cfg.meshMatrix] Flat float 4x4 matrix
16595
- * @param [cfg.worldMatrix] Flat float 4x4 matrix
16596
16593
  * @param cfg.worldAABB Flat float AABB World-space AABB
16597
16594
  * @param cfg.pickColor Quantized pick color
16598
16595
  * @returns {number} Portion ID
16599
- */},{key:"createPortion",value:function createPortion(cfg){if(this._finalized){throw"Already finalized";}var positions=cfg.positions;var positionsCompressed=cfg.positionsCompressed;var indices=cfg.indices;var color=cfg.color;var opacity=cfg.opacity;var meshMatrix=cfg.meshMatrix;var worldMatrix=cfg.worldMatrix;var worldAABB=cfg.worldAABB;cfg.pickColor;var buffer=this._buffer;var positionsIndex=buffer.positions.length;var vertsIndex=positionsIndex/3;var numVerts;if(this._preCompressedPositionsExpected){if(!positionsCompressed){throw"positionsCompressed expected";}numVerts=positionsCompressed.length/3;for(var _i281=0,len=positionsCompressed.length;_i281<len;_i281++){buffer.positions.push(positionsCompressed[_i281]);}var bounds=geometryCompressionUtils.getPositionsBounds(positionsCompressed);var min=geometryCompressionUtils.decompressPosition(bounds.min,this._state.positionsDecodeMatrix,[]);var _max2=geometryCompressionUtils.decompressPosition(bounds.max,this._state.positionsDecodeMatrix,[]);worldAABB[0]=min[0];worldAABB[1]=min[1];worldAABB[2]=min[2];worldAABB[3]=_max2[0];worldAABB[4]=_max2[1];worldAABB[5]=_max2[2];if(worldMatrix){math.AABB3ToOBB3(worldAABB,tempOBB3$1);math.transformOBB3(worldMatrix,tempOBB3$1);math.OBB3ToAABB3(tempOBB3$1,worldAABB);}}else{if(!positions){throw"positions expected";}numVerts=positions.length/3;var lenPositions=positions.length;var positionsBase=buffer.positions.length;for(var _i282=0,_len62=positions.length;_i282<_len62;_i282++){buffer.positions.push(positions[_i282]);}if(meshMatrix){for(var _i283=positionsBase,_len63=positionsBase+lenPositions;_i283<_len63;_i283+=3){tempVec4a$a[0]=buffer.positions[_i283+0];tempVec4a$a[1]=buffer.positions[_i283+1];tempVec4a$a[2]=buffer.positions[_i283+2];math.transformPoint4(meshMatrix,tempVec4a$a,tempVec4b$9);buffer.positions[_i283+0]=tempVec4b$9[0];buffer.positions[_i283+1]=tempVec4b$9[1];buffer.positions[_i283+2]=tempVec4b$9[2];math.expandAABB3Point3(this._modelAABB,tempVec4b$9);if(worldMatrix){math.transformPoint4(worldMatrix,tempVec4b$9,tempVec4c$6);math.expandAABB3Point3(worldAABB,tempVec4c$6);}else{math.expandAABB3Point3(worldAABB,tempVec4b$9);}}}else{for(var _i284=positionsBase,_len64=positionsBase+lenPositions;_i284<_len64;_i284+=3){tempVec4a$a[0]=buffer.positions[_i284+0];tempVec4a$a[1]=buffer.positions[_i284+1];tempVec4a$a[2]=buffer.positions[_i284+2];math.expandAABB3Point3(this._modelAABB,tempVec4a$a);if(worldMatrix){math.transformPoint4(worldMatrix,tempVec4a$a,tempVec4b$9);math.expandAABB3Point3(worldAABB,tempVec4b$9);}else{math.expandAABB3Point3(worldAABB,tempVec4a$a);}}}}if(this._state.origin){var _origin9=this._state.origin;worldAABB[0]+=_origin9[0];worldAABB[1]+=_origin9[1];worldAABB[2]+=_origin9[2];worldAABB[3]+=_origin9[0];worldAABB[4]+=_origin9[1];worldAABB[5]+=_origin9[2];}math.expandAABB3(this.aabb,worldAABB);if(color){var _r4=color[0];// Color is pre-quantized by VBOSceneModel
16596
+ */},{key:"createPortion",value:function createPortion(cfg){if(this._finalized){throw"Already finalized";}var positions=cfg.positions;var positionsCompressed=cfg.positionsCompressed;var indices=cfg.indices;var color=cfg.color;var opacity=cfg.opacity;var meshMatrix=cfg.meshMatrix;var worldAABB=cfg.worldAABB;cfg.pickColor;var buffer=this._buffer;var positionsIndex=buffer.positions.length;var vertsIndex=positionsIndex/3;var numVerts;if(this._preCompressedPositionsExpected){if(!positionsCompressed){throw"positionsCompressed expected";}numVerts=positionsCompressed.length/3;for(var _i281=0,len=positionsCompressed.length;_i281<len;_i281++){buffer.positions.push(positionsCompressed[_i281]);}var bounds=geometryCompressionUtils.getPositionsBounds(positionsCompressed);var min=geometryCompressionUtils.decompressPosition(bounds.min,this._state.positionsDecodeMatrix,[]);var _max2=geometryCompressionUtils.decompressPosition(bounds.max,this._state.positionsDecodeMatrix,[]);worldAABB[0]=min[0];worldAABB[1]=min[1];worldAABB[2]=min[2];worldAABB[3]=_max2[0];worldAABB[4]=_max2[1];worldAABB[5]=_max2[2];}else{if(!positions){throw"positions expected";}numVerts=positions.length/3;var lenPositions=positions.length;var positionsBase=buffer.positions.length;for(var _i282=0,_len62=positions.length;_i282<_len62;_i282++){buffer.positions.push(positions[_i282]);}if(meshMatrix){for(var _i283=positionsBase,_len63=positionsBase+lenPositions;_i283<_len63;_i283+=3){tempVec4a$a[0]=buffer.positions[_i283+0];tempVec4a$a[1]=buffer.positions[_i283+1];tempVec4a$a[2]=buffer.positions[_i283+2];math.transformPoint4(meshMatrix,tempVec4a$a,tempVec4b$9);buffer.positions[_i283+0]=tempVec4b$9[0];buffer.positions[_i283+1]=tempVec4b$9[1];buffer.positions[_i283+2]=tempVec4b$9[2];math.expandAABB3Point3(this._modelAABB,tempVec4b$9);math.expandAABB3Point3(worldAABB,tempVec4b$9);}}else{for(var _i284=positionsBase,_len64=positionsBase+lenPositions;_i284<_len64;_i284+=3){tempVec4a$a[0]=buffer.positions[_i284+0];tempVec4a$a[1]=buffer.positions[_i284+1];tempVec4a$a[2]=buffer.positions[_i284+2];math.expandAABB3Point3(this._modelAABB,tempVec4a$a);math.expandAABB3Point3(worldAABB,tempVec4a$a);}}}if(this._state.origin){var _origin9=this._state.origin;worldAABB[0]+=_origin9[0];worldAABB[1]+=_origin9[1];worldAABB[2]+=_origin9[2];worldAABB[3]+=_origin9[0];worldAABB[4]+=_origin9[1];worldAABB[5]+=_origin9[2];}math.expandAABB3(this.aabb,worldAABB);if(color){var _r4=color[0];// Color is pre-quantized by VBOSceneModel
16600
16597
  var g=color[1];var b=color[2];var _a4=opacity;for(var _i285=0;_i285<numVerts;_i285++){buffer.colors.push(_r4);buffer.colors.push(g);buffer.colors.push(b);buffer.colors.push(_a4);}}if(indices){for(var _i286=0,_len65=indices.length;_i286<_len65;_i286++){buffer.indices.push(indices[_i286]+vertsIndex);}}if(this.model.scene.entityOffsetsEnabled){for(var _i287=0;_i287<numVerts;_i287++){buffer.offsets.push(0);buffer.offsets.push(0);buffer.offsets.push(0);}}var portionId=this._portions.length/2;this._portions.push(vertsIndex);this._portions.push(numVerts);this._numPortions++;this.model.numPortions++;this._numVerts+=numVerts;return portionId;}/**
16601
16598
  * Builds batch VBOs from appended geometries.
16602
16599
  * No more portions can then be created.
@@ -16627,7 +16624,7 @@ src.push("} else {");src.push("vec4 worldPosition = positionsDecodeMatrix * vec4
16627
16624
  * @private
16628
16625
  */var LinesInstancingRenderers=/*#__PURE__*/function(){function LinesInstancingRenderers(scene){_classCallCheck(this,LinesInstancingRenderers);this._scene=scene;}_createClass(LinesInstancingRenderers,[{key:"_compile",value:function _compile(){if(this._colorRenderer&&!this._colorRenderer.getValid()){this._colorRenderer.destroy();this._colorRenderer=null;}if(this._silhouetteRenderer&&!this._silhouetteRenderer.getValid()){this._silhouetteRenderer.destroy();this._silhouetteRenderer=null;}}},{key:"colorRenderer",get:function get(){if(!this._colorRenderer){this._colorRenderer=new LinesInstancingColorRenderer(this._scene);}return this._colorRenderer;}},{key:"silhouetteRenderer",get:function get(){if(!this._silhouetteRenderer){this._silhouetteRenderer=new LinesInstancingSilhouetteRenderer(this._scene);}return this._silhouetteRenderer;}},{key:"_destroy",value:function _destroy(){if(this._colorRenderer){this._colorRenderer.destroy();}if(this._silhouetteRenderer){this._silhouetteRenderer.destroy();}}}]);return LinesInstancingRenderers;}();var cachedRenderers$2={};/**
16629
16626
  * @private
16630
- */function getInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$2[sceneId];if(!instancingRenderers){instancingRenderers=new LinesInstancingRenderers(scene);cachedRenderers$2[sceneId]=instancingRenderers;instancingRenderers._compile();scene.on("compile",function(){instancingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers$2[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempUint8Vec4$1=new Uint8Array(4);var tempFloat32$1=new Float32Array(1);var tempVec4a$9=math.vec4([0,0,0,1]);var tempVec4b$8=math.vec4([0,0,0,1]);var tempVec4c$5=math.vec4([0,0,0,1]);var tempVec3fa$1=new Float32Array(3);/**
16627
+ */function getInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$2[sceneId];if(!instancingRenderers){instancingRenderers=new LinesInstancingRenderers(scene);cachedRenderers$2[sceneId]=instancingRenderers;instancingRenderers._compile();scene.on("compile",function(){instancingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers$2[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempUint8Vec4$1=new Uint8Array(4);var tempFloat32$1=new Float32Array(1);var tempVec4a$9=math.vec4([0,0,0,1]);var tempVec4b$8=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);var tempVec3fa$1=new Float32Array(3);/**
16631
16628
  * @private
16632
16629
  */var LinesInstancingLayer=/*#__PURE__*/function(){/**
16633
16630
  * @param cfg
@@ -16666,13 +16663,12 @@ this._modelMatrixCol0=[];this._modelMatrixCol1=[];this._modelMatrixCol2=[];this.
16666
16663
  * @param cfg.color Color [0..255,0..255,0..255]
16667
16664
  * @param cfg.opacity Opacity [0..255].
16668
16665
  * @param cfg.meshMatrix Flat float 4x4 matrix.
16669
- * @param [cfg.worldMatrix] Flat float 4x4 matrix.
16670
16666
  * @param cfg.aabb Flat float AABB.
16671
16667
  * @returns {number} Portion ID.
16672
- */_createClass(LinesInstancingLayer,[{key:"createPortion",value:function createPortion(cfg){var color=cfg.color;var opacity=cfg.opacity;var meshMatrix=cfg.meshMatrix;var worldMatrix=cfg.worldMatrix;var worldAABB=cfg.aabb;if(this._finalized){throw"Already finalized";}// TODO: find AABB for portion by transforming the geometry local AABB by the given meshMatrix?
16668
+ */_createClass(LinesInstancingLayer,[{key:"createPortion",value:function createPortion(cfg){var color=cfg.color;var opacity=cfg.opacity;var meshMatrix=cfg.meshMatrix;var worldAABB=cfg.aabb;if(this._finalized){throw"Already finalized";}// TODO: find AABB for portion by transforming the geometry local AABB by the given meshMatrix?
16673
16669
  var r=color[0];// Color is pre-quantized by VBOSceneModel
16674
16670
  var g=color[1];var b=color[2];color[3];this._colors.push(r);this._colors.push(g);this._colors.push(b);this._colors.push(opacity);if(this.model.scene.entityOffsetsEnabled){this._offsets.push(0);this._offsets.push(0);this._offsets.push(0);}this._modelMatrixCol0.push(meshMatrix[0]);this._modelMatrixCol0.push(meshMatrix[4]);this._modelMatrixCol0.push(meshMatrix[8]);this._modelMatrixCol0.push(meshMatrix[12]);this._modelMatrixCol1.push(meshMatrix[1]);this._modelMatrixCol1.push(meshMatrix[5]);this._modelMatrixCol1.push(meshMatrix[9]);this._modelMatrixCol1.push(meshMatrix[13]);this._modelMatrixCol2.push(meshMatrix[2]);this._modelMatrixCol2.push(meshMatrix[6]);this._modelMatrixCol2.push(meshMatrix[10]);this._modelMatrixCol2.push(meshMatrix[14]);// Expand AABB
16675
- math.collapseAABB3(worldAABB);var obb=this._state.obb;var lenPositions=obb.length;for(var _i294=0;_i294<lenPositions;_i294+=4){tempVec4a$9[0]=obb[_i294+0];tempVec4a$9[1]=obb[_i294+1];tempVec4a$9[2]=obb[_i294+2];math.transformPoint4(meshMatrix,tempVec4a$9,tempVec4b$8);if(worldMatrix){math.transformPoint4(worldMatrix,tempVec4b$8,tempVec4c$5);math.expandAABB3Point3(worldAABB,tempVec4c$5);}else{math.expandAABB3Point3(worldAABB,tempVec4b$8);}}if(this._state.origin){var _origin10=this._state.origin;worldAABB[0]+=_origin10[0];worldAABB[1]+=_origin10[1];worldAABB[2]+=_origin10[2];worldAABB[3]+=_origin10[0];worldAABB[4]+=_origin10[1];worldAABB[5]+=_origin10[2];}math.expandAABB3(this.aabb,worldAABB);this._state.numInstances++;var portionId=this._portions.length;this._portions.push({});this._numPortions++;this.model.numPortions++;return portionId;}},{key:"finalize",value:function finalize(){if(this._finalized){throw"Already finalized";}var gl=this.model.scene.canvas.gl;var colorsLength=this._colors.length;var flagsLength=colorsLength/4;if(colorsLength>0){var notNormalized=false;this._state.colorsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Uint8Array(this._colors),this._colors.length,4,gl.DYNAMIC_DRAW,notNormalized);this._colors=[];// Release memory
16671
+ math.collapseAABB3(worldAABB);var obb=this._state.obb;var lenPositions=obb.length;for(var _i294=0;_i294<lenPositions;_i294+=4){tempVec4a$9[0]=obb[_i294+0];tempVec4a$9[1]=obb[_i294+1];tempVec4a$9[2]=obb[_i294+2];math.transformPoint4(meshMatrix,tempVec4a$9,tempVec4b$8);math.expandAABB3Point3(worldAABB,tempVec4b$8);}if(this._state.origin){var _origin10=this._state.origin;worldAABB[0]+=_origin10[0];worldAABB[1]+=_origin10[1];worldAABB[2]+=_origin10[2];worldAABB[3]+=_origin10[0];worldAABB[4]+=_origin10[1];worldAABB[5]+=_origin10[2];}math.expandAABB3(this.aabb,worldAABB);this._state.numInstances++;var portionId=this._portions.length;this._portions.push({});this._numPortions++;this.model.numPortions++;return portionId;}},{key:"finalize",value:function finalize(){if(this._finalized){throw"Already finalized";}var gl=this.model.scene.canvas.gl;var colorsLength=this._colors.length;var flagsLength=colorsLength/4;if(colorsLength>0){var notNormalized=false;this._state.colorsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Uint8Array(this._colors),this._colors.length,4,gl.DYNAMIC_DRAW,notNormalized);this._colors=[];// Release memory
16676
16672
  }if(flagsLength>0){// Because we only build flags arrays here,
16677
16673
  // get their length from the colors array
16678
16674
  var _notNormalized6=false;this._state.flagsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(flagsLength),flagsLength,1,gl.DYNAMIC_DRAW,_notNormalized6);}if(this.model.scene.entityOffsetsEnabled){if(this._offsets.length>0){var _notNormalized7=false;this._state.offsetsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._offsets),this._offsets.length,3,gl.DYNAMIC_DRAW,_notNormalized7);this._offsets=[];// Release memory
@@ -16725,7 +16721,7 @@ src.push("}");return src;}}]);return PointsBatchingOcclusionRenderer;}(VBOSceneM
16725
16721
  */function getPointsBatchingRenderers(scene){var sceneId=scene.id;var renderers=cachedRenderers$1[sceneId];if(!renderers){renderers=new PointsBatchingRenderers(scene);cachedRenderers$1[sceneId]=renderers;renderers._compile();scene.on("compile",function(){renderers._compile();});scene.on("destroyed",function(){delete cachedRenderers$1[sceneId];renderers._destroy();});}return renderers;}/**
16726
16722
  * @private
16727
16723
  */var PointsBatchingBuffer=/*#__PURE__*/_createClass(function PointsBatchingBuffer(){var maxGeometryBatchSize=arguments.length>0&&arguments[0]!==undefined?arguments[0]:5000000;_classCallCheck(this,PointsBatchingBuffer);if(maxGeometryBatchSize>5000000){maxGeometryBatchSize=5000000;}this.maxVerts=maxGeometryBatchSize;this.maxIndices=maxGeometryBatchSize*3;// Rough rule-of-thumb
16728
- this.positions=[];this.colors=[];this.intensities=[];this.pickColors=[];this.offsets=[];});var tempVec3a$l=math.vec4();var tempVec3b$f=math.vec4();var tempVec4a$8=math.vec4([0,0,0,1]);var tempVec4b$7=math.vec4([0,0,0,1]);var tempVec4c$4=math.vec4([0,0,0,1]);var tempOBB3=math.OBB3();/**
16724
+ this.positions=[];this.colors=[];this.intensities=[];this.pickColors=[];this.offsets=[];});var tempVec3a$l=math.vec4();var tempVec3b$f=math.vec4();var tempVec4a$8=math.vec4([0,0,0,1]);var tempVec4b$7=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);math.OBB3();/**
16729
16725
  * @private
16730
16726
  */var PointsBatchingLayer=/*#__PURE__*/function(){/**
16731
16727
  * @param model
@@ -16765,11 +16761,10 @@ this._portions=[];this._finalized=false;if(cfg.positionsDecodeMatrix){this._stat
16765
16761
  * @param [cfg.colors] Flat float colors array.
16766
16762
  * @param cfg.color Float RGB color [0..1,0..1,0..1]
16767
16763
  * @param [cfg.meshMatrix] Flat float 4x4 matrix
16768
- * @param [cfg.worldMatrix] Flat float 4x4 matrix
16769
16764
  * @param cfg.worldAABB Flat float AABB World-space AABB
16770
16765
  * @param cfg.pickColor Quantized pick color
16771
16766
  * @returns {number} Portion ID
16772
- */},{key:"createPortion",value:function createPortion(cfg){if(this._finalized){throw"Already finalized";}var positions=cfg.positions;var positionsCompressed=cfg.positionsCompressed;var color=cfg.color;var colorsCompressed=cfg.colorsCompressed;var colors=cfg.colors;var meshMatrix=cfg.meshMatrix;var worldMatrix=cfg.worldMatrix;var worldAABB=cfg.worldAABB;var pickColor=cfg.pickColor;var buffer=this._buffer;var positionsIndex=buffer.positions.length;var vertsIndex=positionsIndex/3;var numVerts;if(this._preCompressedPositionsExpected){if(!positionsCompressed){throw"positionsCompressed expected";}for(var _i301=0,len=positionsCompressed.length;_i301<len;_i301++){buffer.positions.push(positionsCompressed[_i301]);}var bounds=geometryCompressionUtils.getPositionsBounds(positionsCompressed);var min=geometryCompressionUtils.decompressPosition(bounds.min,this._state.positionsDecodeMatrix,tempVec3a$l);var _max3=geometryCompressionUtils.decompressPosition(bounds.max,this._state.positionsDecodeMatrix,tempVec3b$f);worldAABB[0]=min[0];worldAABB[1]=min[1];worldAABB[2]=min[2];worldAABB[3]=_max3[0];worldAABB[4]=_max3[1];worldAABB[5]=_max3[2];if(worldMatrix){math.AABB3ToOBB3(worldAABB,tempOBB3);math.transformOBB3(worldMatrix,tempOBB3);math.OBB3ToAABB3(tempOBB3,worldAABB);}numVerts=positionsCompressed.length/3;}else{if(!positions){throw"positions expected";}numVerts=positions.length/3;var lenPositions=positions.length;var positionsBase=buffer.positions.length;for(var _i302=0,_len68=positions.length;_i302<_len68;_i302++){buffer.positions.push(positions[_i302]);}if(meshMatrix){for(var _i303=positionsBase,_len69=positionsBase+lenPositions;_i303<_len69;_i303+=3){tempVec4a$8[0]=buffer.positions[_i303+0];tempVec4a$8[1]=buffer.positions[_i303+1];tempVec4a$8[2]=buffer.positions[_i303+2];math.transformPoint4(meshMatrix,tempVec4a$8,tempVec4b$7);buffer.positions[_i303+0]=tempVec4b$7[0];buffer.positions[_i303+1]=tempVec4b$7[1];buffer.positions[_i303+2]=tempVec4b$7[2];math.expandAABB3Point3(this._modelAABB,tempVec4b$7);if(worldMatrix){math.transformPoint4(worldMatrix,tempVec4b$7,tempVec4c$4);math.expandAABB3Point3(worldAABB,tempVec4c$4);}else{math.expandAABB3Point3(worldAABB,tempVec4b$7);}}}else{for(var _i304=positionsBase,_len70=positionsBase+lenPositions;_i304<_len70;_i304+=3){tempVec4a$8[0]=buffer.positions[_i304+0];tempVec4a$8[1]=buffer.positions[_i304+1];tempVec4a$8[2]=buffer.positions[_i304+2];math.expandAABB3Point3(this._modelAABB,tempVec4a$8);if(worldMatrix){math.transformPoint4(worldMatrix,tempVec4a$8,tempVec4b$7);math.expandAABB3Point3(worldAABB,tempVec4b$7);}else{math.expandAABB3Point3(worldAABB,tempVec4a$8);}}}}if(this._state.origin){var _origin11=this._state.origin;worldAABB[0]+=_origin11[0];worldAABB[1]+=_origin11[1];worldAABB[2]+=_origin11[2];worldAABB[3]+=_origin11[0];worldAABB[4]+=_origin11[1];worldAABB[5]+=_origin11[2];}math.expandAABB3(this.aabb,worldAABB);if(colorsCompressed){for(var _i305=0,_len71=colorsCompressed.length;_i305<_len71;_i305++){buffer.colors.push(colorsCompressed[_i305]);}}else if(colors){for(var _i306=0,_len72=colors.length;_i306<_len72;_i306++){buffer.colors.push(colors[_i306]*255);}}else if(color){var _r5=color[0];// Color is pre-quantized by VBOSceneModel
16767
+ */},{key:"createPortion",value:function createPortion(cfg){if(this._finalized){throw"Already finalized";}var positions=cfg.positions;var positionsCompressed=cfg.positionsCompressed;var color=cfg.color;var colorsCompressed=cfg.colorsCompressed;var colors=cfg.colors;var meshMatrix=cfg.meshMatrix;var worldAABB=cfg.worldAABB;var pickColor=cfg.pickColor;var buffer=this._buffer;var positionsIndex=buffer.positions.length;var vertsIndex=positionsIndex/3;var numVerts;if(this._preCompressedPositionsExpected){if(!positionsCompressed){throw"positionsCompressed expected";}for(var _i301=0,len=positionsCompressed.length;_i301<len;_i301++){buffer.positions.push(positionsCompressed[_i301]);}var bounds=geometryCompressionUtils.getPositionsBounds(positionsCompressed);var min=geometryCompressionUtils.decompressPosition(bounds.min,this._state.positionsDecodeMatrix,tempVec3a$l);var _max3=geometryCompressionUtils.decompressPosition(bounds.max,this._state.positionsDecodeMatrix,tempVec3b$f);worldAABB[0]=min[0];worldAABB[1]=min[1];worldAABB[2]=min[2];worldAABB[3]=_max3[0];worldAABB[4]=_max3[1];worldAABB[5]=_max3[2];numVerts=positionsCompressed.length/3;}else{if(!positions){throw"positions expected";}numVerts=positions.length/3;var lenPositions=positions.length;var positionsBase=buffer.positions.length;for(var _i302=0,_len68=positions.length;_i302<_len68;_i302++){buffer.positions.push(positions[_i302]);}if(meshMatrix){for(var _i303=positionsBase,_len69=positionsBase+lenPositions;_i303<_len69;_i303+=3){tempVec4a$8[0]=buffer.positions[_i303+0];tempVec4a$8[1]=buffer.positions[_i303+1];tempVec4a$8[2]=buffer.positions[_i303+2];math.transformPoint4(meshMatrix,tempVec4a$8,tempVec4b$7);buffer.positions[_i303+0]=tempVec4b$7[0];buffer.positions[_i303+1]=tempVec4b$7[1];buffer.positions[_i303+2]=tempVec4b$7[2];math.expandAABB3Point3(this._modelAABB,tempVec4b$7);math.expandAABB3Point3(worldAABB,tempVec4b$7);}}else{for(var _i304=positionsBase,_len70=positionsBase+lenPositions;_i304<_len70;_i304+=3){tempVec4a$8[0]=buffer.positions[_i304+0];tempVec4a$8[1]=buffer.positions[_i304+1];tempVec4a$8[2]=buffer.positions[_i304+2];math.expandAABB3Point3(this._modelAABB,tempVec4a$8);math.expandAABB3Point3(worldAABB,tempVec4a$8);}}}if(this._state.origin){var _origin11=this._state.origin;worldAABB[0]+=_origin11[0];worldAABB[1]+=_origin11[1];worldAABB[2]+=_origin11[2];worldAABB[3]+=_origin11[0];worldAABB[4]+=_origin11[1];worldAABB[5]+=_origin11[2];}math.expandAABB3(this.aabb,worldAABB);if(colorsCompressed){for(var _i305=0,_len71=colorsCompressed.length;_i305<_len71;_i305++){buffer.colors.push(colorsCompressed[_i305]);}}else if(colors){for(var _i306=0,_len72=colors.length;_i306<_len72;_i306++){buffer.colors.push(colors[_i306]*255);}}else if(color){var _r5=color[0];// Color is pre-quantized by VBOSceneModel
16773
16768
  var g=color[1];var b=color[2];var _a5=1.0;for(var _i307=0;_i307<numVerts;_i307++){buffer.colors.push(_r5);buffer.colors.push(g);buffer.colors.push(b);buffer.colors.push(_a5);}}{var pickColorsBase=buffer.pickColors.length;var lenPickColors=numVerts*4;for(var _i308=pickColorsBase,_len73=pickColorsBase+lenPickColors;_i308<_len73;_i308+=4){buffer.pickColors.push(pickColor[0]);buffer.pickColors.push(pickColor[1]);buffer.pickColors.push(pickColor[2]);buffer.pickColors.push(pickColor[3]);}}if(this.model.scene.entityOffsetsEnabled){for(var _i309=0;_i309<numVerts;_i309++){buffer.offsets.push(0);buffer.offsets.push(0);buffer.offsets.push(0);}}var portionId=this._portions.length/2;this._portions.push(vertsIndex);this._portions.push(numVerts);this._numPortions++;this.model.numPortions++;return portionId;}/**
16774
16769
  * Builds batch VBOs from appended geometries.
16775
16770
  * No more portions can then be created.
@@ -16833,7 +16828,7 @@ src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * ve
16833
16828
  * @private
16834
16829
  */var PointsInstancingRenderers=/*#__PURE__*/function(){function PointsInstancingRenderers(scene){_classCallCheck(this,PointsInstancingRenderers);this._scene=scene;}_createClass(PointsInstancingRenderers,[{key:"_compile",value:function _compile(){if(this._colorRenderer&&!this._colorRenderer.getValid()){this._colorRenderer.destroy();this._colorRenderer=null;}if(this._depthRenderer&&!this._depthRenderer.getValid()){this._depthRenderer.destroy();this._depthRenderer=null;}if(this._silhouetteRenderer&&!this._silhouetteRenderer.getValid()){this._silhouetteRenderer.destroy();this._silhouetteRenderer=null;}if(this._pickMeshRenderer&&!this._pickMeshRenderer.getValid()){this._pickMeshRenderer.destroy();this._pickMeshRenderer=null;}if(this._pickDepthRenderer&&!this._pickDepthRenderer.getValid()){this._pickDepthRenderer.destroy();this._pickDepthRenderer=null;}if(this._occlusionRenderer&&this._occlusionRenderer.getValid()===false){this._occlusionRenderer.destroy();this._occlusionRenderer=null;}if(this._shadowRenderer&&!this._shadowRenderer.getValid()){this._shadowRenderer.destroy();this._shadowRenderer=null;}}},{key:"colorRenderer",get:function get(){if(!this._colorRenderer){this._colorRenderer=new PointsInstancingColorRenderer(this._scene,false);}return this._colorRenderer;}},{key:"silhouetteRenderer",get:function get(){if(!this._silhouetteRenderer){this._silhouetteRenderer=new PointsInstancingSilhouetteRenderer(this._scene);}return this._silhouetteRenderer;}},{key:"depthRenderer",get:function get(){if(!this._depthRenderer){this._depthRenderer=new PointsInstancingDepthRenderer(this._scene);}return this._depthRenderer;}},{key:"pickMeshRenderer",get:function get(){if(!this._pickMeshRenderer){this._pickMeshRenderer=new PointsInstancingPickMeshRenderer(this._scene);}return this._pickMeshRenderer;}},{key:"pickDepthRenderer",get:function get(){if(!this._pickDepthRenderer){this._pickDepthRenderer=new PointsInstancingPickDepthRenderer(this._scene);}return this._pickDepthRenderer;}},{key:"occlusionRenderer",get:function get(){if(!this._occlusionRenderer){this._occlusionRenderer=new PointsInstancingOcclusionRenderer(this._scene);}return this._occlusionRenderer;}},{key:"shadowRenderer",get:function get(){if(!this._shadowRenderer){this._shadowRenderer=new PointsInstancingShadowRenderer(this._scene);}return this._shadowRenderer;}},{key:"_destroy",value:function _destroy(){if(this._colorRenderer){this._colorRenderer.destroy();}if(this._depthRenderer){this._depthRenderer.destroy();}if(this._silhouetteRenderer){this._silhouetteRenderer.destroy();}if(this._pickMeshRenderer){this._pickMeshRenderer.destroy();}if(this._pickDepthRenderer){this._pickDepthRenderer.destroy();}if(this._occlusionRenderer){this._occlusionRenderer.destroy();}if(this._shadowRenderer){this._shadowRenderer.destroy();}}}]);return PointsInstancingRenderers;}();var cachedRenderers={};/**
16835
16830
  * @private
16836
- */function getPointsInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers[sceneId];if(!instancingRenderers){instancingRenderers=new PointsInstancingRenderers(scene);cachedRenderers[sceneId]=instancingRenderers;instancingRenderers._compile();scene.on("compile",function(){instancingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempUint8Vec4=new Uint8Array(4);var tempFloat32=new Float32Array(1);var tempVec4a$7=math.vec4([0,0,0,1]);var tempVec4b$6=math.vec4([0,0,0,1]);var tempVec4c$3=math.vec4([0,0,0,1]);var tempVec3fa=new Float32Array(3);/**
16831
+ */function getPointsInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers[sceneId];if(!instancingRenderers){instancingRenderers=new PointsInstancingRenderers(scene);cachedRenderers[sceneId]=instancingRenderers;instancingRenderers._compile();scene.on("compile",function(){instancingRenderers._compile();});scene.on("destroyed",function(){delete cachedRenderers[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempUint8Vec4=new Uint8Array(4);var tempFloat32=new Float32Array(1);var tempVec4a$7=math.vec4([0,0,0,1]);var tempVec4b$6=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);var tempVec3fa=new Float32Array(3);/**
16837
16832
  * @private
16838
16833
  */var PointsInstancingLayer=/*#__PURE__*/function(){/**
16839
16834
  * @param cfg
@@ -16873,9 +16868,9 @@ this._modelMatrixCol0=[];this._modelMatrixCol1=[];this._modelMatrixCol2=[];this.
16873
16868
  * @param cfg.aabb Flat float AABB.
16874
16869
  * @param cfg.pickColor Quantized pick color
16875
16870
  * @returns {number} Portion ID.
16876
- */_createClass(PointsInstancingLayer,[{key:"createPortion",value:function createPortion(cfg){var meshMatrix=cfg.meshMatrix;var worldMatrix=cfg.worldMatrix;var worldAABB=cfg.aabb;var pickColor=cfg.pickColor;if(this._finalized){throw"Already finalized";}if(this.model.scene.entityOffsetsEnabled){this._offsets.push(0);this._offsets.push(0);this._offsets.push(0);}this._modelMatrixCol0.push(meshMatrix[0]);this._modelMatrixCol0.push(meshMatrix[4]);this._modelMatrixCol0.push(meshMatrix[8]);this._modelMatrixCol0.push(meshMatrix[12]);this._modelMatrixCol1.push(meshMatrix[1]);this._modelMatrixCol1.push(meshMatrix[5]);this._modelMatrixCol1.push(meshMatrix[9]);this._modelMatrixCol1.push(meshMatrix[13]);this._modelMatrixCol2.push(meshMatrix[2]);this._modelMatrixCol2.push(meshMatrix[6]);this._modelMatrixCol2.push(meshMatrix[10]);this._modelMatrixCol2.push(meshMatrix[14]);// Per-instance pick colors
16871
+ */_createClass(PointsInstancingLayer,[{key:"createPortion",value:function createPortion(cfg){var meshMatrix=cfg.meshMatrix;var worldAABB=cfg.aabb;var pickColor=cfg.pickColor;if(this._finalized){throw"Already finalized";}if(this.model.scene.entityOffsetsEnabled){this._offsets.push(0);this._offsets.push(0);this._offsets.push(0);}this._modelMatrixCol0.push(meshMatrix[0]);this._modelMatrixCol0.push(meshMatrix[4]);this._modelMatrixCol0.push(meshMatrix[8]);this._modelMatrixCol0.push(meshMatrix[12]);this._modelMatrixCol1.push(meshMatrix[1]);this._modelMatrixCol1.push(meshMatrix[5]);this._modelMatrixCol1.push(meshMatrix[9]);this._modelMatrixCol1.push(meshMatrix[13]);this._modelMatrixCol2.push(meshMatrix[2]);this._modelMatrixCol2.push(meshMatrix[6]);this._modelMatrixCol2.push(meshMatrix[10]);this._modelMatrixCol2.push(meshMatrix[14]);// Per-instance pick colors
16877
16872
  this._pickColors.push(pickColor[0]);this._pickColors.push(pickColor[1]);this._pickColors.push(pickColor[2]);this._pickColors.push(pickColor[3]);// Expand AABB
16878
- math.collapseAABB3(worldAABB);var obb=this._state.obb;var lenPositions=obb.length;for(var _i325=0;_i325<lenPositions;_i325+=4){tempVec4a$7[0]=obb[_i325+0];tempVec4a$7[1]=obb[_i325+1];tempVec4a$7[2]=obb[_i325+2];math.transformPoint4(meshMatrix,tempVec4a$7,tempVec4b$6);if(worldMatrix){math.transformPoint4(worldMatrix,tempVec4b$6,tempVec4c$3);math.expandAABB3Point3(worldAABB,tempVec4c$3);}else{math.expandAABB3Point3(worldAABB,tempVec4b$6);}}if(this._state.origin){var _origin12=this._state.origin;worldAABB[0]+=_origin12[0];worldAABB[1]+=_origin12[1];worldAABB[2]+=_origin12[2];worldAABB[3]+=_origin12[0];worldAABB[4]+=_origin12[1];worldAABB[5]+=_origin12[2];}math.expandAABB3(this.aabb,worldAABB);this._state.numInstances++;var portionId=this._portions.length;this._portions.push({});this._numPortions++;this.model.numPortions++;return portionId;}},{key:"finalize",value:function finalize(){if(this._finalized){throw"Already finalized";}var gl=this.model.scene.canvas.gl;var flagsLength=this._pickColors.length/4;if(flagsLength>0){// Because we only build flags arrays here,
16873
+ math.collapseAABB3(worldAABB);var obb=this._state.obb;var lenPositions=obb.length;for(var _i325=0;_i325<lenPositions;_i325+=4){tempVec4a$7[0]=obb[_i325+0];tempVec4a$7[1]=obb[_i325+1];tempVec4a$7[2]=obb[_i325+2];math.transformPoint4(meshMatrix,tempVec4a$7,tempVec4b$6);math.expandAABB3Point3(worldAABB,tempVec4b$6);}if(this._state.origin){var _origin12=this._state.origin;worldAABB[0]+=_origin12[0];worldAABB[1]+=_origin12[1];worldAABB[2]+=_origin12[2];worldAABB[3]+=_origin12[0];worldAABB[4]+=_origin12[1];worldAABB[5]+=_origin12[2];}math.expandAABB3(this.aabb,worldAABB);this._state.numInstances++;var portionId=this._portions.length;this._portions.push({});this._numPortions++;this.model.numPortions++;return portionId;}},{key:"finalize",value:function finalize(){if(this._finalized){throw"Already finalized";}var gl=this.model.scene.canvas.gl;var flagsLength=this._pickColors.length/4;if(flagsLength>0){// Because we only build flags arrays here,
16879
16874
  // get their length from the colors array
16880
16875
  var notNormalized=false;this._state.flagsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(flagsLength),flagsLength,1,gl.DYNAMIC_DRAW,notNormalized);}if(this.model.scene.entityOffsetsEnabled){if(this._offsets.length>0){var _notNormalized8=false;this._state.offsetsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._offsets),this._offsets.length,3,gl.DYNAMIC_DRAW,_notNormalized8);this._offsets=[];// Release memory
16881
16876
  }}if(this._modelMatrixCol0.length>0){var normalized=false;this._state.modelMatrixCol0Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol0),this._modelMatrixCol0.length,4,gl.STATIC_DRAW,normalized);this._state.modelMatrixCol1Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol1),this._modelMatrixCol1.length,4,gl.STATIC_DRAW,normalized);this._state.modelMatrixCol2Buf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Float32Array(this._modelMatrixCol2),this._modelMatrixCol2.length,4,gl.STATIC_DRAW,normalized);this._modelMatrixCol0=[];this._modelMatrixCol1=[];this._modelMatrixCol2=[];}if(this._pickColors.length>0){var _normalized8=false;this._state.pickColorsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,new Uint8Array(this._pickColors),this._pickColors.length,4,gl.STATIC_DRAW,_normalized8);this._pickColors=[];// Release memory
@@ -17304,11 +17299,11 @@ src.push("uvec4 flags = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(obj
17304
17299
  src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");// get XYZ offset
17305
17300
  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 _i360=0,len=sectionPlanesState.sectionPlanes.length;_i360<len;_i360++){src.push("uniform bool sectionPlaneActive"+_i360+";");src.push("uniform vec3 sectionPlanePos"+_i360+";");src.push("uniform vec3 sectionPlaneDir"+_i360+";");}}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 _i361=0,_len89=sectionPlanesState.sectionPlanes.length;_i361<_len89;_i361++){src.push("if (sectionPlaneActive"+_i361+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i361+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i361+".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$b=math.vec3();var tempVec3c$a=math.vec3();var tempMat4a$6=math.mat4();/**
17306
17301
  * @private
17307
- */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(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$h;if(gotOrigin){var rotatedOrigin=tempVec3b$b;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);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$6);}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$a);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
17302
+ */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=tempVec3b$b;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);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$6);}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$a);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
17308
17303
  );gl.drawArrays(gl.LINES,0,state.numEdgeIndices8Bits);}if(state.numEdgeIndices16Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,16// 16 bits edge indices
17309
17304
  );gl.drawArrays(gl.LINES,0,state.numEdgeIndices16Bits);}if(state.numEdgeIndices32Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,32// 32 bits edge indices
17310
- );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._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i362=0,len=scene._sectionPlanesState.sectionPlanes.length;_i362<len;_i362++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i362),pos:program.getLocation("sectionPlanePos"+_i362),dir:program.getLocation("sectionPlaneDir"+_i362)});}//this._aOffset = program.getAttribute("offset");
17311
- 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){src.push("in vec3 offset;");}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;");
17305
+ );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 _i362=0,len=scene._sectionPlanesState.sectionPlanes.length;_i362<len;_i362++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i362),pos:program.getLocation("sectionPlanePos"+_i362),dir:program.getLocation("sectionPlaneDir"+_i362)});}//this._aOffset = program.getAttribute("offset");
17306
+ 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("// TrianglesDataTextureEdgesColorRenderer");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);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;");
17312
17307
  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) {");// model matrices
17313
17308
  src.push("mat4 worldMatrix = sceneModelWorldMatrix * mat4 (texelFetch (uTextureModelMatrices, ivec2(0, 0), 0), texelFetch (uTextureModelMatrices, ivec2(1, 0), 0), texelFetch (uTextureModelMatrices, ivec2(2, 0), 0), texelFetch (uTextureModelMatrices, ivec2(3, 0), 0));");// constants
17314
17309
  src.push("int edgeIndex = gl_VertexID / 2;");// get packed object-id
@@ -17323,8 +17318,10 @@ src.push("uvec4 flags = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(obj
17323
17318
  src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");// get color
17324
17319
  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
17325
17320
  src.push(" return;");src.push("};");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");// get XYZ offset
17326
- 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);");
17327
- 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("// 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 _i363=0,len=sectionPlanesState.sectionPlanes.length;_i363<len;_i363++){src.push("uniform bool sectionPlaneActive"+_i363+";");src.push("uniform vec3 sectionPlanePos"+_i363+";");src.push("uniform vec3 sectionPlaneDir"+_i363+";");}}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 _i364=0,_len90=sectionPlanesState.sectionPlanes.length;_i364<_len90;_i364++){src.push("if (sectionPlaneActive"+_i364+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i364+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i364+".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 TrianglesDataTextureEdgesColorRenderer;}();var tempVec3a$g=math.vec3();var tempVec3b$a=math.vec3();var tempVec3c$9=math.vec3();var tempMat4a$5=math.mat4();/**
17321
+ src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");// src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");
17322
+ 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);");
17323
+ 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 _i363=0,len=sectionPlanesState.sectionPlanes.length;_i363<len;_i363++){src.push("uniform bool sectionPlaneActive"+_i363+";");src.push("uniform vec3 sectionPlanePos"+_i363+";");src.push("uniform vec3 sectionPlaneDir"+_i363+";");}}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 _i364=0,_len90=sectionPlanesState.sectionPlanes.length;_i364<_len90;_i364++){src.push("if (sectionPlaneActive"+_i364+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i364+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i364+".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;");
17324
+ 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$a=math.vec3();var tempVec3c$9=math.vec3();var tempMat4a$5=math.mat4();/**
17328
17325
  * @private
17329
17326
  */var TrianglesDataTexturePickMeshRenderer=/*#__PURE__*/function(){function TrianglesDataTexturePickMeshRenderer(scene){_classCallCheck(this,TrianglesDataTexturePickMeshRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTexturePickMeshRenderer,[{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){if(!this._program){this._allocate(dataTextureLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}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;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$g;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$a);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$5);rtcCameraEye=tempVec3c$9;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(camera.project.far+1.0)/Math.LN2);// TODO: Far from pick project matrix?
17330
17327
  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,tempVec3a$g);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
@@ -17371,23 +17368,23 @@ src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {"
17371
17368
  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("vViewPosition = viewPosition;");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(" }");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 pick depth 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;");}src.push("uniform float pickZNear;");src.push("uniform float pickZFar;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec4 vViewPosition;");src.push("vec4 packDepth(const in float depth) {");src.push(" const vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);");src.push(" const vec4 bitMask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);");src.push(" vec4 res = fract(depth * bitShift);");src.push(" res -= res.xxyz * bitMask;");src.push(" return res;");src.push("}");src.push("out vec4 outPackedDepth;");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 i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");src.push(" outPackedDepth = packDepth(zNormalizedDepth); ");// Must be linear depth
17372
17369
  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 TrianglesDataTexturePickDepthRenderer;}();var tempVec3a$e=math.vec3();var tempVec3b$8=math.vec3();var tempVec3c$7=math.vec3();var tempVec3d$4=math.vec3();var tempVec3e$1=math.vec3();var tempMat4a$3=math.mat4();/**
17373
17370
  * @private
17374
- */var TrianglesDataTextureSnapDepthRenderer=/*#__PURE__*/function(){function TrianglesDataTextureSnapDepthRenderer(scene){_classCallCheck(this,TrianglesDataTextureSnapDepthRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureSnapDepthRenderer,[{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){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}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 aabb=dataTextureLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$e;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);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=tempVec3b$8;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$7);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$3);rtcCameraEye=tempVec3d$4;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uSceneModelWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);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,tempVec3e$1);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}var glMode=frameCtx.snapMode==="edge"?gl.LINES:gl.POINTS;if(state.numEdgeIndices8Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,8// 8 bits edge indices
17371
+ */var TrianglesDataTextureSnapDepthRenderer=/*#__PURE__*/function(){function TrianglesDataTextureSnapDepthRenderer(scene){_classCallCheck(this,TrianglesDataTextureSnapDepthRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureSnapDepthRenderer,[{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){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}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 aabb=dataTextureLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$e;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);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=tempVec3b$8;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$7);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$3);rtcCameraEye=tempVec3d$4;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uSceneModelWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);{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,tempVec3e$1);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}var glMode=frameCtx.snapMode==="edge"?gl.LINES:gl.POINTS;if(state.numEdgeIndices8Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,8// 8 bits edge indices
17375
17372
  );gl.drawArrays(glMode,0,state.numEdgeIndices8Bits);}if(state.numEdgeIndices16Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,16// 16 bits edge indices
17376
17373
  );gl.drawArrays(glMode,0,state.numEdgeIndices16Bits);}if(state.numEdgeIndices32Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,32// 32 bits edge indices
17377
- );gl.drawArrays(glMode,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._uPickInvisible=program.getLocation("pickInvisible");this._uSceneModelWorldMatrix=program.getLocation("sceneModelWorldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i367=0,len=scene._sectionPlanesState.sectionPlanes.length;_i367<len;_i367++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i367),pos:program.getLocation("sectionPlanePos"+_i367),dir:program.getLocation("sectionPlaneDir"+_i367)});}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";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("uSnapVectorA");this.uInverseVectorAB=program.getLocation("uSnapInvVectorAB");this._uLayerNumber=program.getLocation("uLayerNumber");this._uCoordinateScaler=program.getLocation("uCoordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{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){src.push("in vec3 offset;");}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 vec3 uCameraEyeRtc;");src.push("uniform vec2 uSnapVectorA;");src.push("uniform vec2 uSnapInvVectorAB;");src.push("vec3 positions[3];");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;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - uSnapVectorA.x) * uSnapInvVectorAB.x;");src.push(" float y = (clipPos.y - uSnapVectorA.y) * uSnapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vViewPosition;");src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// constants
17374
+ );gl.drawArrays(glMode,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._uPickInvisible=program.getLocation("pickInvisible");this._uSceneModelWorldMatrix=program.getLocation("sceneModelWorldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i367=0,len=scene._sectionPlanesState.sectionPlanes.length;_i367<len;_i367++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i367),pos:program.getLocation("sectionPlanePos"+_i367),dir:program.getLocation("sectionPlaneDir"+_i367)});}{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";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("uSnapVectorA");this.uInverseVectorAB=program.getLocation("uSnapInvVectorAB");this._uLayerNumber=program.getLocation("uLayerNumber");this._uCoordinateScaler=program.getLocation("uCoordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{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){src.push("in vec3 offset;");}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 vec3 uCameraEyeRtc;");src.push("uniform vec2 uSnapVectorA;");src.push("uniform vec2 uSnapInvVectorAB;");src.push("vec3 positions[3];");{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;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - uSnapVectorA.x) * uSnapInvVectorAB.x;");src.push(" float y = (clipPos.y - uSnapVectorA.y) * uSnapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vViewPosition;");src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// constants
17378
17375
  src.push("int edgeIndex = gl_VertexID / 2;");// get packed object-id
17379
17376
  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
17380
17377
  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);");src.push("{");src.push("mat4 worldMatrix = sceneModelWorldMatrix * mat4 (texelFetch (uTextureModelMatrices, ivec2(0, 0), 0), texelFetch (uTextureModelMatrices, ivec2(1, 0), 0), texelFetch (uTextureModelMatrices, ivec2(2, 0), 0), texelFetch (uTextureModelMatrices, ivec2(3, 0), 0));");// get vertex base
17381
17378
  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
17382
17379
  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
17383
17380
  src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");// get XYZ offset
17384
- src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vViewPosition = viewPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");src.push("vViewPosition = clipPos;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("gl_PointSize = 1.0;");// Windows needs this?
17385
- 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 pick depth 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;");}src.push("uniform int uLayerNumber;");src.push("uniform vec3 uCoordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i368=0,len=sectionPlanesState.sectionPlanes.length;_i368<len;_i368++){src.push("uniform bool sectionPlaneActive"+_i368+";");src.push("uniform vec3 sectionPlanePos"+_i368+";");src.push("uniform vec3 sectionPlaneDir"+_i368+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");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 i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz * uCoordinateScaler.xyz, uLayerNumber);");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 TrianglesDataTextureSnapDepthRenderer;}();var tempVec3a$d=math.vec3();var tempVec3b$7=math.vec3();var tempVec3c$6=math.vec3();var tempVec3d$3=math.vec3();var tempVec3e=math.vec3();var tempMat4a$2=math.mat4();/**
17381
+ src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vViewPosition = viewPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");src.push("vViewPosition = clipPos;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("gl_PointSize = 1.0;");// Windows needs this?
17382
+ 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 pick depth 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");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int uLayerNumber;");src.push("uniform vec3 uCoordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i368=0,len=sectionPlanesState.sectionPlanes.length;_i368<len;_i368++){src.push("uniform bool sectionPlaneActive"+_i368+";");src.push("uniform vec3 sectionPlanePos"+_i368+";");src.push("uniform vec3 sectionPlaneDir"+_i368+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");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 i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz * uCoordinateScaler.xyz, uLayerNumber);");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 TrianglesDataTextureSnapDepthRenderer;}();var tempVec3a$d=math.vec3();var tempVec3b$7=math.vec3();var tempVec3c$6=math.vec3();var tempVec3d$3=math.vec3();var tempVec3e=math.vec3();var tempMat4a$2=math.mat4();/**
17386
17383
  * @private
17387
- */var TrianglesDataTextureSnapDepthBufInitRenderer=/*#__PURE__*/function(){function TrianglesDataTextureSnapDepthBufInitRenderer(scene){_classCallCheck(this,TrianglesDataTextureSnapDepthBufInitRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureSnapDepthBufInitRenderer,[{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){if(!this._program){this._allocate();}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}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 aabb=dataTextureLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$d;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);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=tempVec3b$7;if(gotOrigin){var rotatedOrigin=tempVec3c$6;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);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$2);rtcCameraEye=tempVec3d$3;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this._uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this._uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uSceneWorldModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);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,tempVec3e);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
17384
+ */var TrianglesDataTextureSnapDepthBufInitRenderer=/*#__PURE__*/function(){function TrianglesDataTextureSnapDepthBufInitRenderer(scene){_classCallCheck(this,TrianglesDataTextureSnapDepthBufInitRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureSnapDepthBufInitRenderer,[{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){if(!this._program){this._allocate();}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}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 aabb=dataTextureLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var coordinateScaler=tempVec3a$d;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);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=tempVec3b$7;if(gotOrigin){var rotatedOrigin=tempVec3c$6;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);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$2);rtcCameraEye=tempVec3d$3;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this._uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this._uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniformMatrix4fv(this._uSceneWorldModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);{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,tempVec3e);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
17388
17385
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
17389
17386
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
17390
- );gl.drawArrays(gl.TRIANGLES,0,state.numIndices32Bits);}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._uPickInvisible=program.getLocation("pickInvisible");this._uSceneWorldModelMatrix=program.getLocation("sceneModelWorldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i369=0,len=scene._sectionPlanesState.sectionPlanes.length;_i369<len;_i369++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i369),pos:program.getLocation("sectionPlanePos"+_i369),dir:program.getLocation("sectionPlaneDir"+_i369)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uTexturePerObjectIdPositionsDecodeMatrix="uTexturePerObjectIdPositionsDecodeMatrix";this._uTexturePerObjectIdColorsAndFlags="uTexturePerObjectIdColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTextureModelMatrices="uTextureModelMatrices";this._uTexturePerObjectIdOffsets="uTexturePerObjectIdOffsets";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this._uVectorA=program.getLocation("uVectorAB");this._uInverseVectorAB=program.getLocation("uInverseVectorAB");this._uLayerNumber=program.getLocation("uLayerNumber");this._uCoordinateScaler=program.getLocation("uCoordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{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("// TrianglesDataTextureSnapDepthBufInitRenderer 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){src.push("in vec3 offset;");}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("uniform vec2 uVectorAB;");src.push("uniform vec2 uInverseVectorAB;");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("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - uVectorAB.x) * uInverseVectorAB.x;");src.push(" float y = (clipPos.y - uVectorAB.y) * uInverseVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// constants
17387
+ );gl.drawArrays(gl.TRIANGLES,0,state.numIndices32Bits);}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._uPickInvisible=program.getLocation("pickInvisible");this._uSceneWorldModelMatrix=program.getLocation("sceneModelWorldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i369=0,len=scene._sectionPlanesState.sectionPlanes.length;_i369<len;_i369++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i369),pos:program.getLocation("sectionPlanePos"+_i369),dir:program.getLocation("sectionPlaneDir"+_i369)});}{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uTexturePerObjectIdPositionsDecodeMatrix="uTexturePerObjectIdPositionsDecodeMatrix";this._uTexturePerObjectIdColorsAndFlags="uTexturePerObjectIdColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTextureModelMatrices="uTextureModelMatrices";this._uTexturePerObjectIdOffsets="uTexturePerObjectIdOffsets";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this._uVectorA=program.getLocation("uVectorAB");this._uInverseVectorAB=program.getLocation("uInverseVectorAB");this._uLayerNumber=program.getLocation("uLayerNumber");this._uCoordinateScaler=program.getLocation("uCoordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{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("// TrianglesDataTextureSnapDepthBufInitRenderer 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){src.push("in vec3 offset;");}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("uniform vec2 uVectorAB;");src.push("uniform vec2 uInverseVectorAB;");src.push("vec3 positions[3];");{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("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - uVectorAB.x) * uInverseVectorAB.x;");src.push(" float y = (clipPos.y - uVectorAB.y) * uInverseVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// constants
17391
17388
  src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
17392
17389
  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
17393
17390
  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);");src.push("{");src.push("mat4 worldMatrix = sceneModelWorldMatrix * mat4 (texelFetch (uTextureModelMatrices, ivec2(0, 0), 0), texelFetch (uTextureModelMatrices, ivec2(1, 0), 0), texelFetch (uTextureModelMatrices, ivec2(2, 0), 0), texelFetch (uTextureModelMatrices, ivec2(3, 0), 0));");// get color
@@ -17397,7 +17394,7 @@ src.push("ivec4 packedVertexBase = ivec4(texelFetch (uTexturePerObjectIdColorsAn
17397
17394
  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
17398
17395
  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
17399
17396
  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)); ");src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");src.push("relativeToOriginPosition = worldPosition.xyz;");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.z += 0.0001;");// small Z offset
17400
- src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}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("// TrianglesDataTextureSnapDepthBufInitRenderer 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;");}src.push("uniform int uLayerNumber;");src.push("uniform vec3 uCoordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i370=0,len=sectionPlanesState.sectionPlanes.length;_i370<len;_i370++){src.push("uniform bool sectionPlaneActive"+_i370+";");src.push("uniform vec3 sectionPlanePos"+_i370+";");src.push("uniform vec3 sectionPlaneDir"+_i370+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");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 i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz * uCoordinateScaler.xyz, - uLayerNumber);");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 TrianglesDataTextureSnapDepthBufInitRenderer;}();var tempVec3a$c=math.vec3();/**
17397
+ src.push("clipPos.xyzw *= tmp;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}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("// TrianglesDataTextureSnapDepthBufInitRenderer 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");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int uLayerNumber;");src.push("uniform vec3 uCoordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i370=0,len=sectionPlanesState.sectionPlanes.length;_i370<len;_i370++){src.push("uniform bool sectionPlaneActive"+_i370+";");src.push("uniform vec3 sectionPlanePos"+_i370+";");src.push("uniform vec3 sectionPlaneDir"+_i370+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");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 i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz * uCoordinateScaler.xyz, - uLayerNumber);");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 TrianglesDataTextureSnapDepthBufInitRenderer;}();var tempVec3a$c=math.vec3();/**
17401
17398
  * @private
17402
17399
  */var TrianglesDataTexturePickNormalsRenderer=/*#__PURE__*/function(){function TrianglesDataTexturePickNormalsRenderer(scene){_classCallCheck(this,TrianglesDataTexturePickNormalsRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTexturePickNormalsRenderer,[{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;if(!this._program){this._allocate(dataTextureLayer);}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this._uTexturePerObjectIdPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this._uTexturePerObjectIdColorsAndFlags,this._uTextureCameraMatrices,this._uTextureModelMatrices,this._uTexturePerObjectIdOffsets);var cameraEye=camera.eye;if(frameCtx.pickViewMatrix){textureState.bindPickCameraTexture(this._program,this._uTextureCameraMatrices);cameraEye=frameCtx.pickOrigin||cameraEye;}var originCameraEye=[cameraEye[0]-origin[0],cameraEye[1]-origin[1],cameraEye[2]-origin[2]];gl.uniform3fv(this._uCameraEyeRtc,originCameraEye);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform3fv(this._uCameraEyeRtc,originCameraEye);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(camera.project.far+1.0)/Math.LN2);// TODO: Far should be from projection matrix?
17403
17400
  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,tempVec3a$c);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
@@ -17794,7 +17791,7 @@ texArray.set(math.mulMat4(instanceMatrices[_i382],positionDecodeMatrices[_i382],
17794
17791
  */var INDICES_EDGE_INDICES_ALIGNEMENT_SIZE=8;/**
17795
17792
  * Number of maximum allowed per-object flags update per render frame
17796
17793
  * before switching to batch update mode.
17797
- */var MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE=10;var tempVec4a$5=math.vec4([0,0,0,1]);var tempVec4b$5=math.vec4([0,0,0,1]);var tempVec4c$2=math.vec4([0,0,0,1]);var tempUint8Array4=new Uint8Array(4);var tempFloat32Array3=new Float32Array(3);var tempAABB3b=math.AABB3();var numLayers=0;var DEFAULT_MATRIX$1=math.identityMat4();/**
17794
+ */var MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE=10;var tempVec4a$5=math.vec4([0,0,0,1]);var tempVec4b$5=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);var tempUint8Array4=new Uint8Array(4);var tempFloat32Array3=new Float32Array(3);var tempAABB3b=math.AABB3();var numLayers=0;var DEFAULT_MATRIX$1=math.identityMat4();/**
17798
17795
  * @private
17799
17796
  */var TrianglesDataTextureLayer=/*#__PURE__*/function(){function TrianglesDataTextureLayer(model,cfg){_classCallCheck(this,TrianglesDataTextureLayer);dataTextureRamStats.numberOfLayers++;this._layerNumber=numLayers++;this.sortId="TriDTX-".concat(this._layerNumber);// State sorting key.
17800
17797
  this.layerIndex=cfg.layerIndex;// Index of this TrianglesDataTextureLayer in {@link SceneModel#_layerList}.
@@ -17834,8 +17831,7 @@ var bucketGeometryId=portionCfg.geometryId!==undefined&&portionCfg.geometryId!==
17834
17831
  * @param portionCfg.metallic Metalness factor [0..255]
17835
17832
  * @param portionCfg.roughness Roughness factor [0..255]
17836
17833
  * @param portionCfg.opacity Opacity [0..255]
17837
- * @param [portionCfg.meshMatrix] Flat float 4x4 matrix
17838
- * @param [portionCfg.sceneModelMatrix] Flat float 4x4 matrix
17834
+ * @param [portionCfg.meshMatrix] Flat float 4x4 matrix - transforms the portion within the coordinate system that's local to the SceneModel
17839
17835
  * @param portionCfg.worldAABB Flat float AABB World-space AABB
17840
17836
  * @param portionCfg.pickColor Quantized pick color
17841
17837
  * @returns {number} Portion ID
@@ -17852,14 +17848,11 @@ if(bucket.indices){var alignedIndicesLen=Math.ceil(bucket.indices.length/3/INDIC
17852
17848
  // - in exchange for a small RAM overhead
17853
17849
  // (by adding some padding until a size that is multiple of INDICES_EDGE_INDICES_ALIGNEMENT_SIZE)
17854
17850
  if(bucket.edgeIndices){var alignedEdgeIndicesLen=Math.ceil(bucket.edgeIndices.length/2/INDICES_EDGE_INDICES_ALIGNEMENT_SIZE)*INDICES_EDGE_INDICES_ALIGNEMENT_SIZE*2;dataTextureRamStats.overheadSizeAlignementEdgeIndices+=2*(alignedEdgeIndicesLen-bucket.edgeIndices.length);var alignedEdgeIndices=new Uint32Array(alignedEdgeIndicesLen);alignedEdgeIndices.fill(0);alignedEdgeIndices.set(bucket.edgeIndices);bucket.edgeIndices=alignedEdgeIndices;}var positionsCompressed=bucket.positionsCompressed;var indices=bucket.indices;var edgeIndices=bucket.edgeIndices;var buffer=this._buffer;var vertexBase=buffer.positionsCompressed.length/3;var numVertices=positionsCompressed.length/3;for(var _i383=0,len=positionsCompressed.length;_i383<len;_i383++){buffer.positionsCompressed.push(positionsCompressed[_i383]);}var indicesBase;var numTriangles=0;if(indices){numTriangles=indices.length/3;var indicesBuffer;if(numVertices<=1<<8){indicesBuffer=buffer.indices8Bits;}else if(numVertices<=1<<16){indicesBuffer=buffer.indices16Bits;}else{indicesBuffer=buffer.indices32Bits;}indicesBase=indicesBuffer.length/3;for(var _i384=0,_len92=indices.length;_i384<_len92;_i384++){indicesBuffer.push(indices[_i384]);}}var edgeIndicesBase;var numEdges=0;if(edgeIndices){numEdges=edgeIndices.length/2;var edgeIndicesBuffer;if(numVertices<=1<<8){edgeIndicesBuffer=buffer.edgeIndices8Bits;}else if(numVertices<=1<<16){edgeIndicesBuffer=buffer.edgeIndices16Bits;}else{edgeIndicesBuffer=buffer.edgeIndices32Bits;}edgeIndicesBase=edgeIndicesBuffer.length/2;for(var _i385=0,_len93=edgeIndices.length;_i385<_len93;_i385++){edgeIndicesBuffer.push(edgeIndices[_i385]);}}this._state.numVertices+=numVertices;dataTextureRamStats.numberOfGeometries++;var aabb=math.collapseAABB3();math.expandAABB3Points3(aabb,bucket.positionsCompressed);geometryCompressionUtils.decompressAABB(aabb,portionCfg.positionsDecodeMatrix);var bucketGeometry={vertexBase:vertexBase,numVertices:numVertices,numTriangles:numTriangles,numEdges:numEdges,indicesBase:indicesBase,edgeIndicesBase:edgeIndicesBase,aabb:aabb,obb:null// Lazy-created in _createSubPortion if needed
17855
- };return bucketGeometry;}},{key:"_createSubPortion",value:function _createSubPortion(portionCfg,bucketGeometry,bucket,subPortionAABB){var color=portionCfg.color;portionCfg.metallic;portionCfg.roughness;var colors=portionCfg.colors;var opacity=portionCfg.opacity;var meshMatrix=portionCfg.meshMatrix;var sceneModelMatrix=portionCfg.sceneModelMatrix;var pickColor=portionCfg.pickColor;var buffer=this._buffer;var state=this._state;buffer.perObjectPositionsDecodeMatrices.push(portionCfg.positionsDecodeMatrix);buffer.perObjectInstancePositioningMatrices.push(meshMatrix||DEFAULT_MATRIX$1);if(meshMatrix||sceneModelMatrix){// TODO: optimize for identity scene model matrix
17856
- if(!bucketGeometry.obb){bucketGeometry.obb=math.AABB3ToOBB3(bucketGeometry.aabb);}var geometryOBB=bucketGeometry.obb;for(var _i386=0,len=geometryOBB.length;_i386<len;_i386+=4){tempVec4a$5[0]=geometryOBB[_i386+0];tempVec4a$5[1]=geometryOBB[_i386+1];tempVec4a$5[2]=geometryOBB[_i386+2];tempVec4a$5[3]=1.0;if(meshMatrix){math.transformPoint4(meshMatrix,tempVec4a$5,tempVec4b$5);}if(sceneModelMatrix){math.transformPoint4(sceneModelMatrix,tempVec4b$5,tempVec4c$2);math.expandAABB3Point3(subPortionAABB,tempVec4c$2);}else{math.expandAABB3Point3(subPortionAABB,tempVec4b$5);}}}else{math.expandAABB3(subPortionAABB,bucketGeometry.aabb);}buffer.perObjectSolid.push(!!portionCfg.solid);if(colors){buffer.perObjectColors.push([colors[0]*255,colors[1]*255,colors[2]*255,255]);}else if(color){// Color is pre-quantized by SceneModel
17851
+ };return bucketGeometry;}},{key:"_createSubPortion",value:function _createSubPortion(portionCfg,bucketGeometry,bucket,subPortionAABB){var color=portionCfg.color;portionCfg.metallic;portionCfg.roughness;var colors=portionCfg.colors;var opacity=portionCfg.opacity;var meshMatrix=portionCfg.meshMatrix;var pickColor=portionCfg.pickColor;var buffer=this._buffer;var state=this._state;buffer.perObjectPositionsDecodeMatrices.push(portionCfg.positionsDecodeMatrix);buffer.perObjectInstancePositioningMatrices.push(meshMatrix||DEFAULT_MATRIX$1);if(meshMatrix){// NB: SceneModel world matrix is used in shaders and SceneModelMesh.aabb
17852
+ if(!bucketGeometry.obb){bucketGeometry.obb=math.AABB3ToOBB3(bucketGeometry.aabb);}var geometryOBB=bucketGeometry.obb;for(var _i386=0,len=geometryOBB.length;_i386<len;_i386+=4){tempVec4a$5[0]=geometryOBB[_i386+0];tempVec4a$5[1]=geometryOBB[_i386+1];tempVec4a$5[2]=geometryOBB[_i386+2];tempVec4a$5[3]=1.0;if(meshMatrix){math.transformPoint4(meshMatrix,tempVec4a$5,tempVec4b$5);}math.expandAABB3Point3(subPortionAABB,tempVec4b$5);}}else{math.expandAABB3(subPortionAABB,bucketGeometry.aabb);}buffer.perObjectSolid.push(!!portionCfg.solid);if(colors){buffer.perObjectColors.push([colors[0]*255,colors[1]*255,colors[2]*255,255]);}else if(color){// Color is pre-quantized by SceneModel
17857
17853
  buffer.perObjectColors.push([color[0],color[1],color[2],opacity]);}buffer.perObjectPickColors.push(pickColor);buffer.perObjectVertexBases.push(bucketGeometry.vertexBase);{var currentNumIndices;if(bucketGeometry.numVertices<=1<<8){currentNumIndices=state.numIndices8Bits;}else if(bucketGeometry.numVertices<=1<<16){currentNumIndices=state.numIndices16Bits;}else{currentNumIndices=state.numIndices32Bits;}buffer.perObjectIndexBaseOffsets.push(currentNumIndices/3-bucketGeometry.indicesBase);}{var currentNumEdgeIndices;if(bucketGeometry.numVertices<=1<<8){currentNumEdgeIndices=state.numEdgeIndices8Bits;}else if(bucketGeometry.numVertices<=1<<16){currentNumEdgeIndices=state.numEdgeIndices16Bits;}else{currentNumEdgeIndices=state.numEdgeIndices32Bits;}buffer.perObjectEdgeIndexBaseOffsets.push(currentNumEdgeIndices/2-bucketGeometry.edgeIndicesBase);}var subPortionId=this._subPortions.length;if(bucketGeometry.numTriangles>0){var numIndices=bucketGeometry.numTriangles*3;var indicesPortionIdBuffer;if(bucketGeometry.numVertices<=1<<8){indicesPortionIdBuffer=buffer.perTriangleNumberPortionId8Bits;state.numIndices8Bits+=numIndices;dataTextureRamStats.totalPolygons8Bits+=bucketGeometry.numTriangles;}else if(bucketGeometry.numVertices<=1<<16){indicesPortionIdBuffer=buffer.perTriangleNumberPortionId16Bits;state.numIndices16Bits+=numIndices;dataTextureRamStats.totalPolygons16Bits+=bucketGeometry.numTriangles;}else{indicesPortionIdBuffer=buffer.perTriangleNumberPortionId32Bits;state.numIndices32Bits+=numIndices;dataTextureRamStats.totalPolygons32Bits+=bucketGeometry.numTriangles;}dataTextureRamStats.totalPolygons+=bucketGeometry.numTriangles;for(var _i387=0;_i387<bucketGeometry.numTriangles;_i387+=INDICES_EDGE_INDICES_ALIGNEMENT_SIZE){indicesPortionIdBuffer.push(subPortionId);}}if(bucketGeometry.numEdges>0){var numEdgeIndices=bucketGeometry.numEdges*2;var edgeIndicesPortionIdBuffer;if(bucketGeometry.numVertices<=1<<8){edgeIndicesPortionIdBuffer=buffer.perEdgeNumberPortionId8Bits;state.numEdgeIndices8Bits+=numEdgeIndices;dataTextureRamStats.totalEdges8Bits+=bucketGeometry.numEdges;}else if(bucketGeometry.numVertices<=1<<16){edgeIndicesPortionIdBuffer=buffer.perEdgeNumberPortionId16Bits;state.numEdgeIndices16Bits+=numEdgeIndices;dataTextureRamStats.totalEdges16Bits+=bucketGeometry.numEdges;}else{edgeIndicesPortionIdBuffer=buffer.perEdgeNumberPortionId32Bits;state.numEdgeIndices32Bits+=numEdgeIndices;dataTextureRamStats.totalEdges32Bits+=bucketGeometry.numEdges;}dataTextureRamStats.totalEdges+=bucketGeometry.numEdges;for(var _i388=0;_i388<bucketGeometry.numEdges;_i388+=INDICES_EDGE_INDICES_ALIGNEMENT_SIZE){edgeIndicesPortionIdBuffer.push(subPortionId);}}// buffer.perObjectOffsets.push([0, 0, 0]);
17858
17854
  this._subPortions.push({// vertsBase: vertsIndex,
17859
- numVertices:bucketGeometry.numTriangles});this._numPortions++;dataTextureRamStats.numberOfPortions++;return subPortionId;}// updatePickCameratexture(pickViewMatrix, pickCameraMatrix) {
17860
- // this._dataTextureState.texturePickCameraMatrices.updateViewMatrix(pickViewMatrix, pickCameraMatrix);
17861
- // }
17862
- /**
17855
+ numVertices:bucketGeometry.numTriangles});this._numPortions++;dataTextureRamStats.numberOfPortions++;return subPortionId;}/**
17863
17856
  * Builds data textures from the appended geometries and loads them into the GPU.
17864
17857
  *
17865
17858
  * No more portions can then be created.
@@ -17956,7 +17949,7 @@ gl.RGB,gl.FLOAT,tempFloat32Array3);// gl.bindTexture (gl.TEXTURE_2D, null);
17956
17949
  }}},{key:"drawNormals",value:function drawNormals(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numTransparentLayerPortions===this._numPortions||this._numXRayedLayerPortions===this._numPortions){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.normalsRenderer){this._dataTextureRenderers.normalsRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_OPAQUE);// Assume whatever post-effect uses normals (eg SAO) does not apply to transparent objects
17957
17950
  }}// ---------------------- SILHOUETTE RENDERING -----------------------------------
17958
17951
  },{key:"drawSilhouetteXRayed",value:function drawSilhouetteXRayed(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numXRayedLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.silhouetteRenderer){this._dataTextureRenderers.silhouetteRenderer.drawLayer(frameCtx,this,RENDER_PASSES.SILHOUETTE_XRAYED);}}},{key:"drawSilhouetteHighlighted",value:function drawSilhouetteHighlighted(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numHighlightedLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.silhouetteRenderer){this._dataTextureRenderers.silhouetteRenderer.drawLayer(frameCtx,this,RENDER_PASSES.SILHOUETTE_HIGHLIGHTED);}}},{key:"drawSilhouetteSelected",value:function drawSilhouetteSelected(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numSelectedLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.silhouetteRenderer){this._dataTextureRenderers.silhouetteRenderer.drawLayer(frameCtx,this,RENDER_PASSES.SILHOUETTE_SELECTED);}}// ---------------------- EDGES RENDERING -----------------------------------
17959
- },{key:"drawEdgesColorOpaque",value:function drawEdgesColorOpaque(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numEdgesLayerPortions===0){return;}if(this._dataTextureRenderers.edgesColorRenderer){this._dataTextureRenderers.edgesColorRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_COLOR_OPAQUE);}}},{key:"drawEdgesColorTransparent",value:function drawEdgesColorTransparent(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numEdgesLayerPortions===0||this._numTransparentLayerPortions===0){return;}if(this._dataTextureRenderers.edgesColorRenderer){this._dataTextureRenderers.edgesColorRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_COLOR_TRANSPARENT);}}},{key:"drawEdgesHighlighted",value:function drawEdgesHighlighted(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numHighlightedLayerPortions===0){return;}if(this._dataTextureRenderers.edgesRenderer){this._dataTextureRenderers.edgesRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_HIGHLIGHTED);}}},{key:"drawEdgesSelected",value:function drawEdgesSelected(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numSelectedLayerPortions===0){return;}if(this._dataTextureRenderers.edgesRenderer){this._dataTextureRenderers.edgesRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_SELECTED);}}},{key:"drawEdgesXRayed",value:function drawEdgesXRayed(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numXRayedLayerPortions===0){return;}if(this._dataTextureRenderers.edgesRenderer){this._dataTextureRenderers.edgesRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_XRAYED);}}// ---------------------- OCCLUSION CULL RENDERING -----------------------------------
17952
+ },{key:"drawEdgesColorOpaque",value:function drawEdgesColorOpaque(renderFlags,frameCtx){if(this.model.scene.logarithmicDepthBufferEnabled){if(!this.model.scene._loggedWarning){console.log("Edge enhancement for SceneModel data texture layers currently disabled with logarithmic depth buffer");this.model.scene._loggedWarning=true;}return;}if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numEdgesLayerPortions===0){return;}if(this._dataTextureRenderers.edgesColorRenderer){this._dataTextureRenderers.edgesColorRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_COLOR_OPAQUE);}}},{key:"drawEdgesColorTransparent",value:function drawEdgesColorTransparent(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numEdgesLayerPortions===0||this._numTransparentLayerPortions===0){return;}if(this._dataTextureRenderers.edgesColorRenderer){this._dataTextureRenderers.edgesColorRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_COLOR_TRANSPARENT);}}},{key:"drawEdgesHighlighted",value:function drawEdgesHighlighted(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numHighlightedLayerPortions===0){return;}if(this._dataTextureRenderers.edgesRenderer){this._dataTextureRenderers.edgesRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_HIGHLIGHTED);}}},{key:"drawEdgesSelected",value:function drawEdgesSelected(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numSelectedLayerPortions===0){return;}if(this._dataTextureRenderers.edgesRenderer){this._dataTextureRenderers.edgesRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_SELECTED);}}},{key:"drawEdgesXRayed",value:function drawEdgesXRayed(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numXRayedLayerPortions===0){return;}if(this._dataTextureRenderers.edgesRenderer){this._dataTextureRenderers.edgesRenderer.drawLayer(frameCtx,this,RENDER_PASSES.EDGES_XRAYED);}}// ---------------------- OCCLUSION CULL RENDERING -----------------------------------
17960
17953
  },{key:"drawOcclusion",value:function drawOcclusion(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.occlusionRenderer){this._dataTextureRenderers.occlusionRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_OPAQUE);}}// ---------------------- SHADOW BUFFER RENDERING -----------------------------------
17961
17954
  },{key:"drawShadow",value:function drawShadow(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.shadowRenderer){this._dataTextureRenderers.shadowRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_OPAQUE);}}//---- PICKING ----------------------------------------------------------------------------------------------------
17962
17955
  },{key:"setPickMatrices",value:function setPickMatrices(pickViewMatrix,pickProjMatrix){if(this._numVisibleLayerPortions===0){return;}this._dataTextureState.texturePickCameraMatrices.updateViewMatrix(pickViewMatrix,pickProjMatrix);}},{key:"drawPickMesh",value:function drawPickMesh(renderFlags,frameCtx){if(this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.pickMeshRenderer){this._dataTextureRenderers.pickMeshRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}},{key:"drawPickDepths",value:function drawPickDepths(renderFlags,frameCtx){if(this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.pickDepthRenderer){this._dataTextureRenderers.pickDepthRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}},{key:"drawSnapInitDepthBuf",value:function drawSnapInitDepthBuf(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.snapDepthBufInitRenderer){this._dataTextureRenderers.snapDepthBufInitRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}},{key:"drawSnapDepths",value:function drawSnapDepths(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.vertexDepthRenderer){this._dataTextureRenderers.vertexDepthRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}},{key:"drawPickNormals",value:function drawPickNormals(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._dataTextureRenderers.pickNormalsRenderer){this._dataTextureRenderers.pickNormalsRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}},{key:"destroy",value:function destroy(){if(this._destroyed){return;}var state=this._state;if(state.metallicRoughnessBuf){state.metallicRoughnessBuf.destroy();state.metallicRoughnessBuf=null;}this.model.scene.off(this._onSceneRendering);state.destroy();this._destroyed=true;}}]);return TrianglesDataTextureLayer;}();var tempVec3a$8=math.vec3();math.mat4();var DEFAULT_SCALE=math.vec3([1,1,1]);var DEFAULT_POSITION=math.vec3([0,0,0]);var DEFAULT_ROTATION=math.vec3([0,0,0]);var DEFAULT_QUATERNION=math.identityQuaternion();var DEFAULT_MATRIX=math.identityMat4();var DEFAULT_COLOR_TEXTURE_ID="defaultColorTexture";var DEFAULT_METAL_ROUGH_TEXTURE_ID="defaultMetalRoughTexture";var DEFAULT_NORMALS_TEXTURE_ID="defaultNormalsTexture";var DEFAULT_EMISSIVE_TEXTURE_ID="defaultEmissiveTexture";var DEFAULT_OCCLUSION_TEXTURE_ID="defaultOcclusionTexture";var DEFAULT_TEXTURE_SET_ID="defaultTextureSet";var defaultCompressedColor=new Uint8Array([255,255,255]);var VBO_INSTANCED=0;var VBO_BATCHED=1;var DTX=2;/**
@@ -19518,8 +19511,8 @@ if(!this._textureTranscoder){this.error("[createTexture] Can't create texture fr
19518
19511
  * @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
19519
19512
  * @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
19520
19513
  * @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
19521
- */},{key:"createMesh",value:function createMesh(cfg){if(cfg.id===undefined||cfg.id===null){this.error("[createMesh] SceneModel.createMesh() config missing: id");return;}if(this._scheduledMeshes[cfg.id]){this.error("[createMesh] SceneModel already has a mesh with this ID: ".concat(cfg.id));return;}var instancing=cfg.geometryId!==undefined;var batching=!instancing;cfg.sceneModelMatrix=this._matrixNonIdentity?this._matrix:null;if(batching){// Batched geometry
19522
- var useDTX=!!this._dtxEnabled;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("Unsupported value for 'primitive': '".concat(primitive,"' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'."));return;}if(!cfg.positions&&!cfg.positionsCompressed&&!cfg.buckets){this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)");return null;}if(cfg.positions&&(cfg.positionsDecodeMatrix||cfg.positionsDecodeBoundary)){this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");return null;}if(cfg.positionsCompressed&&!cfg.positionsDecodeMatrix&&!cfg.positionsDecodeBoundary){this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");return null;}if(cfg.uvCompressed&&!cfg.uvDecodeMatrix){this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)");return null;}if(!cfg.buckets&&!cfg.indices&&cfg.primitive!=="points"){this.error("Param expected: indices (required for '".concat(cfg.primitive,"' primitive type)"));return null;}if((cfg.matrix||cfg.position||cfg.rotation||cfg.scale)&&(cfg.positionsCompressed||cfg.positionsDecodeBoundary)){this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'");return null;}cfg.origin=cfg.origin?math.addVec3(this._origin,cfg.origin,math.vec3()):this._origin;// MATRIX - optional for batching
19514
+ */},{key:"createMesh",value:function createMesh(cfg){if(cfg.id===undefined||cfg.id===null){this.error("[createMesh] SceneModel.createMesh() config missing: id");return;}if(this._scheduledMeshes[cfg.id]){this.error("[createMesh] SceneModel already has a mesh with this ID: ".concat(cfg.id));return;}var instancing=cfg.geometryId!==undefined;var batching=!instancing;if(batching){// Batched geometry
19515
+ 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("Unsupported value for 'primitive': '".concat(primitive,"' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'."));return;}if(!cfg.positions&&!cfg.positionsCompressed&&!cfg.buckets){this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)");return null;}if(cfg.positions&&(cfg.positionsDecodeMatrix||cfg.positionsDecodeBoundary)){this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");return null;}if(cfg.positionsCompressed&&!cfg.positionsDecodeMatrix&&!cfg.positionsDecodeBoundary){this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");return null;}if(cfg.uvCompressed&&!cfg.uvDecodeMatrix){this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)");return null;}if(!cfg.buckets&&!cfg.indices&&cfg.primitive!=="points"){this.error("Param expected: indices (required for '".concat(cfg.primitive,"' primitive type)"));return null;}if((cfg.matrix||cfg.position||cfg.rotation||cfg.scale)&&(cfg.positionsCompressed||cfg.positionsDecodeBoundary)){this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'");return null;}var useDTX=!!this._dtxEnabled&&(cfg.primitive==="triangles"||cfg.primitive==="solid"||cfg.primitive==="surface");cfg.origin=cfg.origin?math.addVec3(this._origin,cfg.origin,math.vec3()):this._origin;// MATRIX - optional for batching
19523
19516
  if(cfg.matrix){cfg.meshMatrix=cfg.matrix;}else if(cfg.scale||cfg.rotation||cfg.position){var _scale4=cfg.scale||DEFAULT_SCALE;var _position=cfg.position||DEFAULT_POSITION;var rotation=cfg.rotation||DEFAULT_ROTATION;math.eulerToQuaternion(rotation,"XYZ",DEFAULT_QUATERNION);cfg.meshMatrix=math.composeMat4(_position,DEFAULT_QUATERNION,_scale4,math.mat4());}if(cfg.positionsDecodeBoundary){cfg.positionsDecodeMatrix=createPositionsDecodeMatrix(cfg.positionsDecodeBoundary,math.mat4());}if(useDTX){// DTX
19524
19517
  cfg.type=DTX;// NPR
19525
19518
  cfg.color=cfg.color?new Uint8Array([Math.floor(cfg.color[0]*255),Math.floor(cfg.color[1]*255),Math.floor(cfg.color[2]*255)]):defaultCompressedColor;cfg.opacity=cfg.opacity!==undefined&&cfg.opacity!==null?Math.floor(cfg.opacity*255):255;// RTC
@@ -19535,8 +19528,7 @@ if(!cfg.buckets&&!cfg.edgeIndices&&(cfg.primitive==="triangles"||cfg.primitive==
19535
19528
  // cfg.textureSetId = cfg.textureSetId || DEFAULT_TEXTURE_SET_ID;
19536
19529
  if(cfg.textureSetId){cfg.textureSet=this._textureSets[cfg.textureSetId];if(!cfg.textureSet){this.error("[createMesh] Texture set not found: ".concat(cfg.textureSetId," - ensure that you create it first with createTextureSet()"));return;}}}}else{// INSTANCING
19537
19530
  if(cfg.positions||cfg.positionsCompressed||cfg.indices||cfg.edgeIndices||cfg.normals||cfg.normalsCompressed||cfg.uv||cfg.uvCompressed||cfg.positionsDecodeMatrix){this.error("Mesh geometry parameters not expected when instancing a geometry (not expected: positions, positionsCompressed, indices, edgeIndices, normals, normalsCompressed, uv, uvCompressed, positionsDecodeMatrix)");return;}cfg.geometry=this._geometries[cfg.geometryId];if(!cfg.geometry){this.error("[createMesh] Geometry not found: ".concat(cfg.geometryId," - ensure that you create it first with createGeometry()"));return;}cfg.origin=cfg.origin?math.addVec3(this._origin,cfg.origin,math.vec3()):this._origin;cfg.positionsDecodeMatrix=cfg.geometry.positionsDecodeMatrix;// MATRIX - always have a matrix for instancing
19538
- if(cfg.matrix){cfg.meshMatrix=cfg.matrix.slice();}else{var _scale5=cfg.scale||DEFAULT_SCALE;var _position2=cfg.position||DEFAULT_POSITION;var _rotation=cfg.rotation||DEFAULT_ROTATION;math.eulerToQuaternion(_rotation,"XYZ",DEFAULT_QUATERNION);cfg.meshMatrix=math.composeMat4(_position2,DEFAULT_QUATERNION,_scale5,math.mat4());}var _useDTX=!!this._dtxEnabled;// Data textures - disabled by default for now
19539
- if(_useDTX){// DTX
19531
+ if(cfg.matrix){cfg.meshMatrix=cfg.matrix.slice();}else{var _scale5=cfg.scale||DEFAULT_SCALE;var _position2=cfg.position||DEFAULT_POSITION;var _rotation=cfg.rotation||DEFAULT_ROTATION;math.eulerToQuaternion(_rotation,"XYZ",DEFAULT_QUATERNION);cfg.meshMatrix=math.composeMat4(_position2,DEFAULT_QUATERNION,_scale5,math.mat4());}var _useDTX=!!this._dtxEnabled&&(cfg.geometry.primitive==="triangles"||cfg.geometry.primitive==="solid"||cfg.geometry.primitive==="surface");if(_useDTX){// DTX
19540
19532
  cfg.type=DTX;// NPR
19541
19533
  cfg.color=cfg.color?new Uint8Array([Math.floor(cfg.color[0]*255),Math.floor(cfg.color[1]*255),Math.floor(cfg.color[2]*255)]):defaultCompressedColor;cfg.opacity=cfg.opacity!==undefined&&cfg.opacity!==null?Math.floor(cfg.opacity*255):255;// BUCKETING - lazy generated, reused
19542
19534
  var buckets=this._dtxBuckets[cfg.geometryId];if(!buckets){buckets=createDTXBuckets(cfg.geometry,this._enableVertexWelding,this._enableIndexBucketing);this._dtxBuckets[cfg.geometryId]=buckets;}cfg.buckets=buckets;}else{// VBO
@@ -19605,7 +19597,7 @@ this._entityList.push(entity);this._entities[cfg.id]=entity;this.numEntities++;}
19605
19597
  * Once finalized, you can't add anything more to this SceneModel.
19606
19598
  */},{key:"finalize",value:function finalize(){if(this.destroyed){return;}if(this._vfcManager){this._vfcManager.finalize(function(){// Makes deferred calls to #_createEntity() and #_createMesh()
19607
19599
  });}for(var _i414=0,len=this.layerList.length;_i414<len;_i414++){var layer=this.layerList[_i414];layer.finalize();}this._geometries={};this._dtxBuckets={};this._textures={};this._textureSets={};this._dtxLayers={};this._vboInstancingLayers={};this._vboBatchingLayers={};for(var _i415=0,_len96=this._entityList.length;_i415<_len96;_i415++){var entity=this._entityList[_i415];entity._finalize();}for(var _i416=0,_len97=this._entityList.length;_i416<_len97;_i416++){var _entity3=this._entityList[_i416];_entity3._finalize2();}// Sort layers to reduce WebGL shader switching when rendering them
19608
- this.layerList.sort(function(a,b){if(a.sortId<b.sortId){return-1;}if(a.sortId>b.sortId){return 1;}return 0;});for(var _i417=0,_len98=this.layerList.length;_i417<_len98;_i417++){var _layer=this.layerList[_i417];_layer.layerIndex=_i417;}this.glRedraw();this.scene._aabbDirty=true;if(this.scene.lod.enabled){this._lodManager=this.scene.lod.getLODManager(this);}}/** @private */},{key:"stateSortCompare",value:function stateSortCompare(drawable1,drawable2){}/** @private */},{key:"rebuildRenderFlags",value:function rebuildRenderFlags(){this.renderFlags.reset();this._updateRenderFlagsVisibleLayers();if(this.renderFlags.numLayers>0&&this.renderFlags.numVisibleLayers===0){this.renderFlags.culled=true;return;}this._updateRenderFlags();}/**
19600
+ this.layerList.sort(function(a,b){if(a.sortId<b.sortId){return-1;}if(a.sortId>b.sortId){return 1;}return 0;});for(var _i417=0,_len98=this.layerList.length;_i417<_len98;_i417++){var _layer=this.layerList[_i417];_layer.layerIndex=_i417;}this.glRedraw();this.scene._aabbDirty=true;if(this.scene.lod.enabled){this._lodManager=this.scene.lod.getLODManager(this);}this._viewMatrixDirty=true;this._matrixDirty=true;this._aabbDirty=true;this._setWorldMatrixDirty();this._setWorldAABBDirty();this.position=this._position;}/** @private */},{key:"stateSortCompare",value:function stateSortCompare(drawable1,drawable2){}/** @private */},{key:"rebuildRenderFlags",value:function rebuildRenderFlags(){this.renderFlags.reset();this._updateRenderFlagsVisibleLayers();if(this.renderFlags.numLayers>0&&this.renderFlags.numVisibleLayers===0){this.renderFlags.culled=true;return;}this._updateRenderFlags();}/**
19609
19601
  * @private
19610
19602
  */},{key:"_updateRenderFlagsVisibleLayers",value:function _updateRenderFlagsVisibleLayers(){var renderFlags=this.renderFlags;renderFlags.numLayers=this.layerList.length;renderFlags.numVisibleLayers=0;for(var layerIndex=0,len=this.layerList.length;layerIndex<len;layerIndex++){var layer=this.layerList[layerIndex];var layerVisible=this._getActiveSectionPlanesForLayer(layer);if(layerVisible){renderFlags.visibleLayers[renderFlags.numVisibleLayers++]=layerIndex;}}}},{key:"_getActiveSectionPlanesForLayer",value:function _getActiveSectionPlanesForLayer(layer){var renderFlags=this.renderFlags;var sectionPlanes=this.scene._sectionPlanesState.sectionPlanes;var numSectionPlanes=sectionPlanes.length;var baseIndex=layer.layerIndex*numSectionPlanes;if(numSectionPlanes>0){for(var _i418=0;_i418<numSectionPlanes;_i418++){var sectionPlane=sectionPlanes[_i418];if(!sectionPlane.active){renderFlags.sectionPlanesActivePerLayer[baseIndex+_i418]=false;}else{renderFlags.sectionPlanesActivePerLayer[baseIndex+_i418]=true;renderFlags.sectioned=true;}}}return true;}},{key:"_updateRenderFlags",value:function _updateRenderFlags(){if(this.numVisibleLayerPortions===0){return;}if(this.numCulledLayerPortions===this.numPortions){return;}var renderFlags=this.renderFlags;renderFlags.colorOpaque=this.numTransparentLayerPortions<this.numPortions;if(this.numTransparentLayerPortions>0){renderFlags.colorTransparent=true;}if(this.numXRayedLayerPortions>0){var xrayMaterial=this.scene.xrayMaterial._state;if(xrayMaterial.fill){if(xrayMaterial.fillAlpha<1.0){renderFlags.xrayedSilhouetteTransparent=true;}else{renderFlags.xrayedSilhouetteOpaque=true;}}if(xrayMaterial.edges){if(xrayMaterial.edgeAlpha<1.0){renderFlags.xrayedEdgesTransparent=true;}else{renderFlags.xrayedEdgesOpaque=true;}}}if(this.numEdgesLayerPortions>0){var edgeMaterial=this.scene.edgeMaterial._state;if(edgeMaterial.edges){renderFlags.edgesOpaque=this.numTransparentLayerPortions<this.numPortions;if(this.numTransparentLayerPortions>0){renderFlags.edgesTransparent=true;}}}if(this.numSelectedLayerPortions>0){var selectedMaterial=this.scene.selectedMaterial._state;if(selectedMaterial.fill){if(selectedMaterial.fillAlpha<1.0){renderFlags.selectedSilhouetteTransparent=true;}else{renderFlags.selectedSilhouetteOpaque=true;}}if(selectedMaterial.edges){if(selectedMaterial.edgeAlpha<1.0){renderFlags.selectedEdgesTransparent=true;}else{renderFlags.selectedEdgesOpaque=true;}}}if(this.numHighlightedLayerPortions>0){var highlightMaterial=this.scene.highlightMaterial._state;if(highlightMaterial.fill){if(highlightMaterial.fillAlpha<1.0){renderFlags.highlightedSilhouetteTransparent=true;}else{renderFlags.highlightedSilhouetteOpaque=true;}}if(highlightMaterial.edges){if(highlightMaterial.edgeAlpha<1.0){renderFlags.highlightedEdgesTransparent=true;}else{renderFlags.highlightedEdgesOpaque=true;}}}}// -------------- RENDERING ---------------------------------------------------------------------------------------
19611
19603
  /** @private */},{key:"drawColorOpaque",value:function drawColorOpaque(frameCtx){var renderFlags=this.renderFlags;for(var _i419=0,len=renderFlags.visibleLayers.length;_i419<len;_i419++){var layerIndex=renderFlags.visibleLayers[_i419];this.layerList[layerIndex].drawColorOpaque(renderFlags,frameCtx);}}/** @private */},{key:"drawColorTransparent",value:function drawColorTransparent(frameCtx){var renderFlags=this.renderFlags;for(var _i420=0,len=renderFlags.visibleLayers.length;_i420<len;_i420++){var layerIndex=renderFlags.visibleLayers[_i420];this.layerList[layerIndex].drawColorTransparent(renderFlags,frameCtx);}}/** @private */},{key:"drawDepth",value:function drawDepth(frameCtx){// Dedicated to SAO because it skips transparent objects
@@ -21727,9 +21719,9 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
21727
21719
  * @param {Boolean} [cfg.alphaDepthMask=true] Whether writing into the depth buffer is enabled or disabled when rendering transparent objects.
21728
21720
  * @param {Boolean} [cfg.entityOffsetsEnabled=false] Whether to enable {@link Entity#offset}. For best performance, only set this ````true```` when you need to use {@link Entity#offset}.
21729
21721
  * @param {Boolean} [cfg.pickSurfacePrecisionEnabled=false] Whether to enable full-precision accuracy when surface picking with {@link Scene#pick}. Note that when ````true````, this configuration will increase the amount of browser memory used by the Viewer. The ````pickSurfacePrecision```` option for ````Scene#pick```` only works if this is set ````true````.
21730
- * @param {Boolean} [cfg.logarithmicDepthBufferEnabled=true] Whether to enable logarithmic depth buffer. When this is true,
21722
+ * @param {Boolean} [cfg.logarithmicDepthBufferEnabled=false] Whether to enable logarithmic depth buffer. When this is true,
21731
21723
  * you can set huge values for {@link Perspective#far} and {@link Ortho#far}, to push the far clipping plane back so
21732
- * that it does not clip huge models. Enabling this also allows snap-picking to work more accurately when the model is far from the viewpoint.
21724
+ * that it does not clip huge models.
21733
21725
  * @param {Boolean} [cfg.colorTextureEnabled=true] Whether to enable base color texture rendering.
21734
21726
  * @param {Boolean} [cfg.pbrEnabled=false] Whether to enable physically-based rendering.
21735
21727
  * @param {LocaleService} [cfg.localeService=null] Optional locale-based translation service.
@@ -21757,7 +21749,7 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
21757
21749
  * The Viewer's {@link Scene}.
21758
21750
  * @property scene
21759
21751
  * @type {Scene}
21760
- */this.scene=new Scene(this,{canvasId:cfg.canvasId,canvasElement:cfg.canvasElement,keyboardEventsElement:cfg.keyboardEventsElement,contextAttr:{preserveDrawingBuffer:cfg.preserveDrawingBuffer!==false,premultipliedAlpha:!!cfg.premultipliedAlpha,antialias:cfg.antialias!==false},spinnerElementId:cfg.spinnerElementId,transparent:cfg.transparent!==false,gammaInput:true,gammaOutput:false,backgroundColor:cfg.backgroundColor,backgroundColorFromAmbientLight:cfg.backgroundColorFromAmbientLight,ticksPerRender:1,ticksPerOcclusionTest:20,units:cfg.units,scale:cfg.scale,origin:cfg.origin,saoEnabled:cfg.saoEnabled,alphaDepthMask:cfg.alphaDepthMask!==false,entityOffsetsEnabled:!!cfg.entityOffsetsEnabled,pickSurfacePrecisionEnabled:!!cfg.pickSurfacePrecisionEnabled,logarithmicDepthBufferEnabled:cfg.logarithmicDepthBufferEnabled!==false,pbrEnabled:!!cfg.pbrEnabled,lodEnabled:!!cfg.lodEnabled,vfcCulling:!!cfg.vfcEnabled,colorTextureEnabled:cfg.colorTextureEnabled!==false,dtxEnabled:!!cfg.dtxEnabled});/**
21752
+ */this.scene=new Scene(this,{canvasId:cfg.canvasId,canvasElement:cfg.canvasElement,keyboardEventsElement:cfg.keyboardEventsElement,contextAttr:{preserveDrawingBuffer:cfg.preserveDrawingBuffer!==false,premultipliedAlpha:!!cfg.premultipliedAlpha,antialias:cfg.antialias!==false},spinnerElementId:cfg.spinnerElementId,transparent:cfg.transparent!==false,gammaInput:true,gammaOutput:false,backgroundColor:cfg.backgroundColor,backgroundColorFromAmbientLight:cfg.backgroundColorFromAmbientLight,ticksPerRender:1,ticksPerOcclusionTest:20,units:cfg.units,scale:cfg.scale,origin:cfg.origin,saoEnabled:cfg.saoEnabled,alphaDepthMask:cfg.alphaDepthMask!==false,entityOffsetsEnabled:!!cfg.entityOffsetsEnabled,pickSurfacePrecisionEnabled:!!cfg.pickSurfacePrecisionEnabled,logarithmicDepthBufferEnabled:!!cfg.logarithmicDepthBufferEnabled,pbrEnabled:!!cfg.pbrEnabled,lodEnabled:!!cfg.lodEnabled,vfcCulling:!!cfg.vfcEnabled,colorTextureEnabled:cfg.colorTextureEnabled!==false,dtxEnabled:!!cfg.dtxEnabled});/**
21761
21753
  * Metadata about the {@link Scene} and the models and objects within it.
21762
21754
  * @property metaScene
21763
21755
  * @type {MetaScene}