@xeokit/xeokit-sdk 2.4.2-beta-21 → 2.4.2-beta-23

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.
Files changed (90) hide show
  1. package/dist/xeokit-sdk.cjs.js +750 -598
  2. package/dist/xeokit-sdk.es.js +750 -598
  3. package/dist/xeokit-sdk.es5.js +227 -198
  4. package/dist/xeokit-sdk.min.cjs.js +4 -4
  5. package/dist/xeokit-sdk.min.es.js +4 -4
  6. package/dist/xeokit-sdk.min.es5.js +3 -3
  7. package/package.json +1 -1
  8. package/src/viewer/Viewer.js +7 -1
  9. package/src/viewer/scene/mesh/draw/DrawRenderer.js +18 -8
  10. package/src/viewer/scene/mesh/draw/DrawShaderSource.js +8 -8
  11. package/src/viewer/scene/mesh/emphasis/EmphasisEdgesRenderer.js +19 -9
  12. package/src/viewer/scene/mesh/emphasis/EmphasisEdgesShaderSource.js +3 -3
  13. package/src/viewer/scene/mesh/emphasis/EmphasisFillRenderer.js +19 -9
  14. package/src/viewer/scene/mesh/emphasis/EmphasisFillShaderSource.js +3 -3
  15. package/src/viewer/scene/mesh/occlusion/OcclusionRenderer.js +18 -8
  16. package/src/viewer/scene/mesh/occlusion/OcclusionShaderSource.js +3 -3
  17. package/src/viewer/scene/mesh/pick/PickMeshRenderer.js +18 -8
  18. package/src/viewer/scene/mesh/pick/PickMeshShaderSource.js +3 -3
  19. package/src/viewer/scene/mesh/pick/PickTriangleRenderer.js +18 -8
  20. package/src/viewer/scene/mesh/pick/PickTriangleShaderSource.js +3 -3
  21. package/src/viewer/scene/mesh/shadow/ShadowRenderer.js +1 -1
  22. package/src/viewer/scene/mesh/shadow/ShadowShaderSource.js +3 -3
  23. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureColorRenderer.js +22 -17
  24. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureDepthRenderer.js +22 -21
  25. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesColorRenderer.js +7 -10
  26. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesRenderer.js +22 -19
  27. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureNormalsRenderer.js +22 -18
  28. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureOcclusionRenderer.js +22 -17
  29. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickDepthRenderer.js +22 -18
  30. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickMeshRenderer.js +59 -55
  31. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsFlatRenderer.js +22 -20
  32. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTexturePickNormalsRenderer.js +22 -18
  33. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSilhouetteRenderer.js +22 -19
  34. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthBufInitRenderer.js +22 -19
  35. package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureSnapDepthRenderer.js +22 -19
  36. package/src/viewer/scene/model/vbo/VBOSceneModelRenderers.js +21 -16
  37. package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingColorRenderer.js +4 -4
  38. package/src/viewer/scene/model/vbo/linesBatching/renderers/LinesBatchingSilhouetteRenderer.js +4 -4
  39. package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingColorRenderer.js +4 -4
  40. package/src/viewer/scene/model/vbo/linesInstancing/renderers/LinesInstancingSilhouetteRenderer.js +4 -4
  41. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingColorRenderer.js +4 -4
  42. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingOcclusionRenderer.js +4 -4
  43. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickDepthRenderer.js +4 -4
  44. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingPickMeshRenderer.js +4 -4
  45. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingShadowRenderer.js +4 -4
  46. package/src/viewer/scene/model/vbo/pointsBatching/renderers/PointsBatchingSilhouetteRenderer.js +4 -4
  47. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingColorRenderer.js +4 -4
  48. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingDepthRenderer.js +4 -4
  49. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingOcclusionRenderer.js +4 -4
  50. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickDepthRenderer.js +4 -4
  51. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingPickMeshRenderer.js +4 -4
  52. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingShadowRenderer.js +4 -4
  53. package/src/viewer/scene/model/vbo/pointsInstancing/renderers/PointsInstancingSilhouetteRenderer.js +4 -4
  54. package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthBufInitRenderer.js +4 -4
  55. package/src/viewer/scene/model/vbo/snapBatching/SnapBatchingDepthRenderer.js +4 -4
  56. package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthBufInitRenderer.js +4 -4
  57. package/src/viewer/scene/model/vbo/snapInstancing/SnapInstancingDepthRenderer.js +4 -4
  58. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorRenderer.js +4 -4
  59. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingColorTextureRenderer.js +4 -4
  60. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingDepthRenderer.js +4 -4
  61. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesColorRenderer.js +4 -4
  62. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingEdgesRenderer.js +4 -4
  63. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingFlatColorRenderer.js +4 -4
  64. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingNormalsRenderer.js +4 -4
  65. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingOcclusionRenderer.js +4 -4
  66. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPBRRenderer.js +4 -4
  67. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickDepthRenderer.js +4 -4
  68. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickMeshRenderer.js +4 -4
  69. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsFlatRenderer.js +4 -4
  70. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingPickNormalsRenderer.js +4 -4
  71. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingShadowRenderer.js +4 -4
  72. package/src/viewer/scene/model/vbo/trianglesBatching/renderers/TrianglesBatchingSilhouetteRenderer.js +4 -4
  73. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorRenderer.js +4 -4
  74. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingColorTextureRenderer.js +4 -4
  75. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingDepthRenderer.js +4 -4
  76. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesColorRenderer.js +4 -4
  77. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingEdgesRenderer.js +4 -4
  78. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatColorRenderer.js +4 -4
  79. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingFlatNormalsRenderer.js +4 -4
  80. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingNormalsRenderer.js +4 -4
  81. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingOcclusionRenderer.js +4 -4
  82. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPBRRenderer.js +4 -4
  83. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickDepthRenderer.js +4 -4
  84. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickMeshRenderer.js +4 -4
  85. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsFlatRenderer.js +4 -4
  86. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingPickNormalsRenderer.js +4 -4
  87. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingShadowRenderer.js +4 -4
  88. package/src/viewer/scene/model/vbo/trianglesInstancing/renderers/TrianglesInstancingSilhouetteRenderer.js +4 -4
  89. package/src/viewer/scene/scene/Scene.js +57 -11
  90. package/src/viewer/scene/sectionPlane/SectionPlaneCache.js +101 -0
@@ -5936,7 +5936,7 @@ _this37.left=cfg.left;_this37.right=cfg.right;_this37.bottom=cfg.bottom;_this37.
5936
5936
  * @param {Number[]} worldPos Outputs un-projected 3D World-space coordinates.
5937
5937
  */},{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
5938
5938
  *
5939
- */},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CustomProjection.prototype),"destroy",this).call(this);this._state.destroy();}}]);return CustomProjection;}(Component);var tempVec3$6=math.vec3();var tempVec3b$q=math.vec3();var tempVec3c$n=math.vec3();var tempVec3d$h=math.vec3();var tempVec3e$4=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();/**
5939
+ */},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CustomProjection.prototype),"destroy",this).call(this);this._state.destroy();}}]);return CustomProjection;}(Component);var tempVec3$6=math.vec3();var tempVec3b$q=math.vec3();var tempVec3c$n=math.vec3();var tempVec3d$9=math.vec3();var tempVec3e$2=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();/**
5940
5940
  * @desc Manages viewing and projection transforms for its {@link Scene}.
5941
5941
  *
5942
5942
  * * One Camera per {@link Scene}
@@ -6140,28 +6140,28 @@ var eye;if(this.projection==="ortho"){math.subVec3(this._eye,this._look,eyeLookV
6140
6140
  *
6141
6141
  * @param {Number} angleInc Angle of rotation in degrees
6142
6142
  */},{key:"orbitYaw",value:function orbitYaw(angleInc){var lookEyeVec=math.subVec3(this._eye,this._look,tempVec3$6);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$n);// Set eye position as 'look' plus 'eye' vector
6143
- this.up=math.transformPoint3(tempMat,this._up,tempVec3d$h);// Rotate 'up' vector
6143
+ this.up=math.transformPoint3(tempMat,this._up,tempVec3d$9);// Rotate 'up' vector
6144
6144
  }/**
6145
6145
  * Rotates {@link Camera#eye} about {@link Camera#look} around the right axis (orthogonal to {@link Camera#up} and "look").
6146
6146
  *
6147
6147
  * @param {Number} angleInc Angle of rotation in degrees
6148
- */},{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$6);var left=math.cross3Vec3(math.normalizeVec3(eye2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$n));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);eye2=math.transformPoint3(tempMat,eye2,tempVec3d$h);this.up=math.transformPoint3(tempMat,this._up,tempVec3e$4);this.eye=math.addVec3(eye2,this._look,tempVec3f$2);}/**
6148
+ */},{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$6);var left=math.cross3Vec3(math.normalizeVec3(eye2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$n));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);eye2=math.transformPoint3(tempMat,eye2,tempVec3d$9);this.up=math.transformPoint3(tempMat,this._up,tempVec3e$2);this.eye=math.addVec3(eye2,this._look,tempVec3f$2);}/**
6149
6149
  * Rotates {@link Camera#look} about {@link Camera#eye}, around the {@link Camera#up} vector.
6150
6150
  *
6151
6151
  * @param {Number} angleInc Angle of rotation in degrees
6152
- */},{key:"yaw",value:function yaw(angleInc){var look2=math.subVec3(this._look,this._eye,tempVec3$6);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$n);if(this._gimbalLock){this.up=math.transformPoint3(tempMat,this._up,tempVec3d$h);}}/**
6152
+ */},{key:"yaw",value:function yaw(angleInc){var look2=math.subVec3(this._look,this._eye,tempVec3$6);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$n);if(this._gimbalLock){this.up=math.transformPoint3(tempMat,this._up,tempVec3d$9);}}/**
6153
6153
  * Rotates {@link Camera#look} about {@link Camera#eye}, around the right axis (orthogonal to {@link Camera#up} and "look").
6154
6154
 
6155
6155
  * @param {Number} angleInc Angle of rotation in degrees
6156
- */},{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$6);var left=math.cross3Vec3(math.normalizeVec3(look2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$n));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);this.up=math.transformPoint3(tempMat,this._up,tempVec3f$2);look2=math.transformPoint3(tempMat,look2,tempVec3d$h);this.look=math.addVec3(look2,this._eye,tempVec3e$4);}/**
6156
+ */},{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$6);var left=math.cross3Vec3(math.normalizeVec3(look2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$n));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);this.up=math.transformPoint3(tempMat,this._up,tempVec3f$2);look2=math.transformPoint3(tempMat,look2,tempVec3d$9);this.look=math.addVec3(look2,this._eye,tempVec3e$2);}/**
6157
6157
  * Pans the Camera along its local X, Y and Z axis.
6158
6158
  *
6159
6159
  * @param pan The pan vector
6160
- */},{key:"pan",value:function pan(_pan){var eye2=math.subVec3(this._eye,this._look,tempVec3$6);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$n),_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$h),_pan[2]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}this.eye=math.addVec3(this._eye,vec,tempVec3e$4);this.look=math.addVec3(this._look,vec,tempVec3f$2);}/**
6160
+ */},{key:"pan",value:function pan(_pan){var eye2=math.subVec3(this._eye,this._look,tempVec3$6);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$n),_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$9),_pan[2]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}this.eye=math.addVec3(this._eye,vec,tempVec3e$2);this.look=math.addVec3(this._look,vec,tempVec3f$2);}/**
6161
6161
  * Increments/decrements the Camera's zoom factor, which is the distance between {@link Camera#eye} and {@link Camera#look}.
6162
6162
  *
6163
6163
  * @param {Number} delta Zoom factor increment.
6164
- */},{key:"zoom",value:function zoom(delta){var vec=math.subVec3(this._eye,this._look,tempVec3$6);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$n);this.eye=math.addVec3(this._look,math.mulVec3Scalar(dir,newLenLook),tempVec3d$h);}/**
6164
+ */},{key:"zoom",value:function zoom(delta){var vec=math.subVec3(this._eye,this._look,tempVec3$6);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$n);this.eye=math.addVec3(this._look,math.mulVec3Scalar(dir,newLenLook),tempVec3d$9);}/**
6165
6165
  * Sets the position of the Camera's eye.
6166
6166
  *
6167
6167
  * Default value is ````[0,0,10]````.
@@ -8812,12 +8812,17 @@ function getEntityIDMap(scene,entityIds){var map={};var entityId;var entity;for(
8812
8812
  * @param {Viewer} viewer The Viewer this Scene belongs to.
8813
8813
  * @param {Object} cfg Scene configuration.
8814
8814
  * @param {String} [cfg.canvasId] ID of an existing HTML canvas for the {@link Scene#canvas} - either this or canvasElement is mandatory. When both values are given, the element reference is always preferred to the ID.
8815
- * @param {HTMLCanvasElement} [cfg.canvasElement] Reference of an existing HTML canvas for the {@link Scene#canvas} - either this or canvasId is mandatory. When both values are given, the element reference is always preferred to the ID.
8815
+ * @param {HTMLCanvasElement} [cfg.canvasElement] Reference of an existing HTML canvas for the {@link Scene#canvas} - either this or canvasId is mandatory. When both values are given, the element reference is always preferred to the ID.
8816
8816
  * @param {HTMLElement} [cfg.keyboardEventsElement] Optional reference to HTML element on which key events should be handled. Defaults to the HTML Document.
8817
+ * @param {number} [cfg.numCachedSectionPlanes=0] Enhances the efficiency of SectionPlane creation by proactively allocating Viewer resources for a specified quantity
8818
+ * of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
8819
+ * configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
8820
+ * responsiveness. It is important to consider that each SectionPlane imposes rendering performance, so it is recommended to set this value to a quantity that aligns with
8821
+ * your expected usage.
8817
8822
  * @throws {String} Throws an exception when both canvasId or canvasElement are missing or they aren't pointing to a valid HTMLCanvasElement.
8818
8823
  */function Scene(viewer){var _this52;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Scene);_this52=_super33.call(this,null,cfg);var canvas=cfg.canvasElement||document.getElementById(cfg.canvasId);if(!(canvas instanceof HTMLCanvasElement)){throw"Mandatory config expected: valid canvasId or canvasElement";}/**
8819
8824
  * @type {{[key: string]: {wrapperFunc: Function, tickSubId: string}}}
8820
- */_this52._tickifiedFunctions={};var transparent=!!cfg.transparent;var alphaDepthMask=!!cfg.alphaDepthMask;_this52._aabbDirty=true;/**
8825
+ */_this52._tickifiedFunctions={};var transparent=!!cfg.transparent;var alphaDepthMask=!!cfg.alphaDepthMask;_this52._aabbDirty=true;_this52._numCachedSectionPlanes=cfg.numCachedSectionPlanes||0;/**
8821
8826
  * The {@link Viewer} this Scene belongs to.
8822
8827
  * @type {Viewer}
8823
8828
  */_this52.viewer=viewer;/** Decremented each frame, triggers occlusion test for occludable {@link Marker}s when zero.
@@ -8965,7 +8970,7 @@ _this52._needRecompile=false;/**
8965
8970
  *
8966
8971
  * @type {Canvas}
8967
8972
  */_this52.canvas=new Canvas(_assertThisInitialized(_this52),{dontClear:true,// Never destroy this component with Scene#clear();
8968
- canvas:canvas,spinnerElementId:cfg.spinnerElementId,transparent:transparent,webgl2:cfg.webgl2!==false,contextAttr:cfg.contextAttr||{},backgroundColor:cfg.backgroundColor,backgroundColorFromAmbientLight:cfg.backgroundColorFromAmbientLight,premultipliedAlpha:cfg.premultipliedAlpha});_this52.canvas.on("boundary",function(){_this52.glRedraw();});_this52.canvas.on("webglContextFailed",function(){alert("xeokit failed to find WebGL!");});_this52._renderer=new Renderer$1(_assertThisInitialized(_this52),{transparent:transparent,alphaDepthMask:alphaDepthMask});_this52._sectionPlanesState=new function(){this.sectionPlanes=[];this.clippingCaps=false;var hash=null;this.getHash=function(){if(hash){return hash;}var sectionPlanes=this.sectionPlanes;if(sectionPlanes.length===0){return this.hash=";";}var hashParts=[];for(var _i80=0,len=sectionPlanes.length;_i80<len;_i80++){hashParts.push("cp");}hashParts.push(";");hash=hashParts.join("");return hash;};this.addSectionPlane=function(sectionPlane){this.sectionPlanes.push(sectionPlane);hash=null;};this.removeSectionPlane=function(sectionPlane){for(var _i81=0,len=this.sectionPlanes.length;_i81<len;_i81++){if(this.sectionPlanes[_i81].id===sectionPlane.id){this.sectionPlanes.splice(_i81,1);hash=null;return;}}};}();_this52._lightsState=new function(){var DEFAULT_AMBIENT=math.vec4([0,0,0,0]);var ambientColorIntensity=math.vec4();this.lights=[];this.reflectionMaps=[];this.lightMaps=[];var hash=null;var ambientLight=null;this.getHash=function(){if(hash){return hash;}var hashParts=[];var lights=this.lights;var light;for(var _i82=0,len=lights.length;_i82<len;_i82++){light=lights[_i82];hashParts.push("/");hashParts.push(light.type);hashParts.push(light.space==="world"?"w":"v");if(light.castsShadow){hashParts.push("sh");}}if(this.lightMaps.length>0){hashParts.push("/lm");}if(this.reflectionMaps.length>0){hashParts.push("/rm");}hashParts.push(";");hash=hashParts.join("");return hash;};this.addLight=function(state){this.lights.push(state);ambientLight=null;hash=null;};this.removeLight=function(state){for(var _i83=0,len=this.lights.length;_i83<len;_i83++){var light=this.lights[_i83];if(light.id===state.id){this.lights.splice(_i83,1);if(ambientLight&&ambientLight.id===state.id){ambientLight=null;}hash=null;return;}}};this.addReflectionMap=function(state){this.reflectionMaps.push(state);hash=null;};this.removeReflectionMap=function(state){for(var _i84=0,len=this.reflectionMaps.length;_i84<len;_i84++){if(this.reflectionMaps[_i84].id===state.id){this.reflectionMaps.splice(_i84,1);hash=null;return;}}};this.addLightMap=function(state){this.lightMaps.push(state);hash=null;};this.removeLightMap=function(state){for(var _i85=0,len=this.lightMaps.length;_i85<len;_i85++){if(this.lightMaps[_i85].id===state.id){this.lightMaps.splice(_i85,1);hash=null;return;}}};this.getAmbientColorAndIntensity=function(){if(!ambientLight){for(var _i86=0,len=this.lights.length;_i86<len;_i86++){var light=this.lights[_i86];if(light.type==="ambient"){ambientLight=light;break;}}}if(ambientLight){var _color2=ambientLight.color;var intensity=ambientLight.intensity;ambientColorIntensity[0]=_color2[0];ambientColorIntensity[1]=_color2[1];ambientColorIntensity[2]=_color2[2];ambientColorIntensity[3]=intensity;return ambientColorIntensity;}else{return DEFAULT_AMBIENT;}};}();/**
8973
+ canvas:canvas,spinnerElementId:cfg.spinnerElementId,transparent:transparent,webgl2:cfg.webgl2!==false,contextAttr:cfg.contextAttr||{},backgroundColor:cfg.backgroundColor,backgroundColorFromAmbientLight:cfg.backgroundColorFromAmbientLight,premultipliedAlpha:cfg.premultipliedAlpha});_this52.canvas.on("boundary",function(){_this52.glRedraw();});_this52.canvas.on("webglContextFailed",function(){alert("xeokit failed to find WebGL!");});_this52._renderer=new Renderer$1(_assertThisInitialized(_this52),{transparent:transparent,alphaDepthMask:alphaDepthMask});var numCachedSectionPlanes=_this52._numCachedSectionPlanes;_this52._sectionPlanesState=new function(){this.sectionPlanes=[];this.clippingCaps=false;var hash=null;this.getHash=function(){if(hash){return hash;}var numAllocatedSectionPlanes=this.getNumAllocatedSectionPlanes();this.sectionPlanes;if(numAllocatedSectionPlanes===0){return this.hash=";";}var hashParts=[];for(var _i80=0,len=numAllocatedSectionPlanes;_i80<len;_i80++){hashParts.push("cp");}hashParts.push(";");hash=hashParts.join("");return hash;};this.addSectionPlane=function(sectionPlane){this.sectionPlanes.push(sectionPlane);hash=null;};this.removeSectionPlane=function(sectionPlane){for(var _i81=0,len=this.sectionPlanes.length;_i81<len;_i81++){if(this.sectionPlanes[_i81].id===sectionPlane.id){this.sectionPlanes.splice(_i81,1);hash=null;return;}}};this.getNumAllocatedSectionPlanes=function(){var num=this.sectionPlanes.length;return num>numCachedSectionPlanes?num:numCachedSectionPlanes;};}();_this52._lightsState=new function(){var DEFAULT_AMBIENT=math.vec4([0,0,0,0]);var ambientColorIntensity=math.vec4();this.lights=[];this.reflectionMaps=[];this.lightMaps=[];var hash=null;var ambientLight=null;this.getHash=function(){if(hash){return hash;}var hashParts=[];var lights=this.lights;var light;for(var _i82=0,len=lights.length;_i82<len;_i82++){light=lights[_i82];hashParts.push("/");hashParts.push(light.type);hashParts.push(light.space==="world"?"w":"v");if(light.castsShadow){hashParts.push("sh");}}if(this.lightMaps.length>0){hashParts.push("/lm");}if(this.reflectionMaps.length>0){hashParts.push("/rm");}hashParts.push(";");hash=hashParts.join("");return hash;};this.addLight=function(state){this.lights.push(state);ambientLight=null;hash=null;};this.removeLight=function(state){for(var _i83=0,len=this.lights.length;_i83<len;_i83++){var light=this.lights[_i83];if(light.id===state.id){this.lights.splice(_i83,1);if(ambientLight&&ambientLight.id===state.id){ambientLight=null;}hash=null;return;}}};this.addReflectionMap=function(state){this.reflectionMaps.push(state);hash=null;};this.removeReflectionMap=function(state){for(var _i84=0,len=this.reflectionMaps.length;_i84<len;_i84++){if(this.reflectionMaps[_i84].id===state.id){this.reflectionMaps.splice(_i84,1);hash=null;return;}}};this.addLightMap=function(state){this.lightMaps.push(state);hash=null;};this.removeLightMap=function(state){for(var _i85=0,len=this.lightMaps.length;_i85<len;_i85++){if(this.lightMaps[_i85].id===state.id){this.lightMaps.splice(_i85,1);hash=null;return;}}};this.getAmbientColorAndIntensity=function(){if(!ambientLight){for(var _i86=0,len=this.lights.length;_i86<len;_i86++){var light=this.lights[_i86];if(light.type==="ambient"){ambientLight=light;break;}}}if(ambientLight){var _color2=ambientLight.color;var intensity=ambientLight.intensity;ambientColorIntensity[0]=_color2[0];ambientColorIntensity[1]=_color2[1];ambientColorIntensity[2]=_color2[2];ambientColorIntensity[3]=intensity;return ambientColorIntensity;}else{return DEFAULT_AMBIENT;}};}();/**
8969
8974
  * Publishes input events that occur on this Scene's canvas.
8970
8975
  *
8971
8976
  * @property input
@@ -9039,12 +9044,32 @@ this.canvas.spinner.processes--;}/**
9039
9044
  *
9040
9045
  * @returns {Boolean} True if logarithmic depth buffer is enabled.
9041
9046
  */},{key:"logarithmicDepthBufferEnabled",get:function get(){return this._logarithmicDepthBufferEnabled;}/**
9047
+ * Sets the number of {@link SectionPlane}s for which this Scene pre-caches resources.
9048
+ *
9049
+ * This property enhances the efficiency of SectionPlane creation by proactively allocating and caching Viewer resources for a specified quantity
9050
+ * of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
9051
+ * configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
9052
+ * responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
9053
+ * your expected usage.
9054
+ *
9055
+ * Default is ````0````.
9056
+ */},{key:"numCachedSectionPlanes",get:/**
9057
+ * Gets the number of {@link SectionPlane}s for which this Scene pre-caches resources.
9058
+ *
9059
+ * This property enhances the efficiency of SectionPlane creation by proactively allocating and caching Viewer resources for a specified quantity
9060
+ * of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
9061
+ * configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
9062
+ * responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
9063
+ * your expected usage.
9064
+ *
9065
+ * Default is ````0````.
9066
+ *
9067
+ * @returns {number} The number of {@link SectionPlane}s for which this Scene pre-caches resources.
9068
+ */function get(){return this._numCachedSectionPlanes;}/**
9042
9069
  * Sets whether physically-based rendering is enabled.
9043
9070
  *
9044
9071
  * Default is ````false````.
9045
- *
9046
- * @returns {Boolean} True if quality rendering is enabled.
9047
- */},{key:"pbrEnabled",get:/**
9072
+ */,set:function set(numCachedSectionPlanes){this._numCachedSectionPlanes=numCachedSectionPlanes;this._recompile();}},{key:"pbrEnabled",get:/**
9048
9073
  * Gets whether physically-based rendering is enabled.
9049
9074
  *
9050
9075
  * Default is ````false````.
@@ -9584,23 +9609,23 @@ return entity.aabb;}ids=[ids];// Must be an entity type
9584
9609
  * @returns {Boolean} True if any {@link Entity}s were updated, else false if all updates were redundant and not applied.
9585
9610
  */},{key:"withObjects",value:function withObjects(ids,callback){if(utils.isString(ids)){ids=[ids];}var changed=false;for(var _i91=0,len=ids.length;_i91<len;_i91++){var id=ids[_i91];var entity=this.objects[id];if(entity){changed=callback(entity)||changed;}else{var modelIds=this.modelIds;for(var _i92=0,_len6=modelIds.length;_i92<_len6;_i92++){var modelId=modelIds[_i92];var globalObjectId=math.globalizeObjectId(modelId,id);entity=this.objects[globalObjectId];if(entity){changed=callback(entity)||changed;}}}}return changed;}/**
9586
9611
  * This method will "tickify" the provided `cb` function.
9587
- *
9612
+ *
9588
9613
  * This means, the function will be wrapped so:
9589
- *
9614
+ *
9590
9615
  * - it runs time-aligned to scene ticks
9591
9616
  * - it runs maximum once per scene-tick
9592
- *
9617
+ *
9593
9618
  * @param {Function} cb The function to tickify
9594
9619
  * @returns {Function)}
9595
9620
  */},{key:"tickify",value:function tickify(cb){var cbString=cb.toString();/**
9596
9621
  * Check if the function is already tickified, and if so return the cached one.
9597
9622
  */if(cbString in this._tickifiedFunctions){return this._tickifiedFunctions[cbString].wrapperFunc;}var alreadyRun=0;var needToRun=0;var lastArgs;/**
9598
9623
  * The provided `cb` function is replaced with a "set-dirty" function
9599
- *
9624
+ *
9600
9625
  * @type {Function}
9601
9626
  */var wrapperFunc=function wrapperFunc(){for(var _len7=arguments.length,args=new Array(_len7),_key4=0;_key4<_len7;_key4++){args[_key4]=arguments[_key4];}lastArgs=args;needToRun++;};/**
9602
9627
  * An each scene tick, if the "dirty-flag" is set, run the `cb` function.
9603
- *
9628
+ *
9604
9629
  * This will make it run time-aligned to the scene tick.
9605
9630
  */var tickSubId=this.on("tick",function(){var tmp=needToRun;if(tmp>alreadyRun){alreadyRun=tmp;cb.apply(void 0,_toConsumableArray(lastArgs));}});/**
9606
9631
  * And, store the list of subscribers.
@@ -9777,12 +9802,12 @@ this.components=null;this.models=null;this.objects=null;this.visibleObjects=null
9777
9802
  * Media type for compressed texture data.
9778
9803
  */var CompressedMediaType=10003;/**
9779
9804
  * @private
9780
- */var DrawShaderSource=function DrawShaderSource(mesh){if(mesh._material._state.type==="LambertMaterial"){this.vertex=buildVertexLambert(mesh);this.fragment=buildFragmentLambert(mesh);}else{this.vertex=buildVertexDraw(mesh);this.fragment=buildFragmentDraw(mesh);}};var TEXTURE_DECODE_FUNCS$1={};TEXTURE_DECODE_FUNCS$1[LinearEncoding]="linearToLinear";TEXTURE_DECODE_FUNCS$1[sRGBEncoding]="sRGBToLinear";function getReceivesShadow(mesh){if(!mesh.receivesShadow){return false;}var lights=mesh.scene._lightsState.lights;if(!lights||lights.length===0){return false;}for(var _i93=0,len=lights.length;_i93<len;_i93++){if(lights[_i93].castsShadow){return true;}}return false;}function hasTextures(mesh){if(!mesh._geometry._state.uvBuf){return false;}var material=mesh._material;return!!(material._ambientMap||material._occlusionMap||material._baseColorMap||material._diffuseMap||material._alphaMap||material._specularMap||material._glossinessMap||material._specularGlossinessMap||material._emissiveMap||material._metallicMap||material._roughnessMap||material._metallicRoughnessMap||material._reflectivityMap||material._normalMap);}function hasNormals$1(mesh){var primitive=mesh._geometry._state.primitiveName;if((mesh._geometry._state.autoVertexNormals||mesh._geometry._state.normalsBuf)&&(primitive==="triangles"||primitive==="triangle-strip"||primitive==="triangle-fan")){return true;}return false;}function buildVertexLambert(mesh){var scene=mesh.scene;var sectionPlanesState=mesh.scene._sectionPlanesState;var lightsState=mesh.scene._lightsState;var geometryState=mesh._geometry._state;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var clipping=sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!geometryState.compressGeometry;var src=[];src.push("#version 300 es");src.push("// Lambertian drawing vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec4 colorize;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}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("uniform vec4 lightAmbient;");src.push("uniform vec4 materialColor;");src.push("uniform vec3 materialEmissive;");if(geometryState.normalsBuf){src.push("in vec3 normal;");src.push("uniform mat4 modelNormalMatrix;");src.push("uniform mat4 viewNormalMatrix;");for(var _i94=0,len=lightsState.lights.length;_i94<len;_i94++){var light=lightsState.lights[_i94];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i94+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i94+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i94+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i94+";");src.push("uniform vec3 lightDir"+_i94+";");}}if(quantizedGeometry){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("}");}}src.push("out vec4 vColor;");if(geometryState.primitiveName==="points"){src.push("uniform float pointSize;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}if(geometryState.normalsBuf){if(quantizedGeometry){src.push("vec4 localNormal = vec4(octDecode(normal.xy), 0.0); ");}else{src.push("vec4 localNormal = vec4(normal, 0.0); ");}src.push("mat4 modelNormalMatrix2 = modelNormalMatrix;");src.push("mat4 viewNormalMatrix2 = viewNormalMatrix;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");if(geometryState.normalsBuf){src.push("mat4 modelViewNormalMatrix = viewNormalMatrix2 * modelNormalMatrix2;");src.push("billboard(modelNormalMatrix2);");src.push("billboard(viewNormalMatrix2);");src.push("billboard(modelViewNormalMatrix);");}src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}if(geometryState.normalsBuf){src.push("vec3 viewNormal = normalize((viewNormalMatrix2 * modelNormalMatrix2 * localNormal).xyz);");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");if(geometryState.normalsBuf){for(var _i95=0,_len8=lightsState.lights.length;_i95<_len8;_i95++){var _light=lightsState.lights[_i95];if(_light.type==="ambient"){continue;}if(_light.type==="dir"){if(_light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i95+");");}else{src.push("viewLightDir = normalize((viewMatrix2 * vec4(lightDir"+_i95+", 0.0)).xyz);");}}else if(_light.type==="point"){if(_light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i95+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix2 * vec4(lightPos"+_i95+", 0.0)).xyz);");}}else if(_light.type==="spot"){if(_light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i95+");");}else{src.push("viewLightDir = normalize((viewMatrix2 * vec4(lightDir"+_i95+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i95+".rgb * lightColor"+_i95+".a);");}}src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * materialColor.rgb) + materialEmissive.rgb + (reflectedColor * materialColor.rgb), materialColor.a) * colorize;");// TODO: How to have ambient bright enough for canvas BG but not too bright for scene?
9781
- if(clipping){src.push("vWorldPosition = worldPosition;");}if(geometryState.primitiveName==="points"){src.push("gl_PointSize = pointSize;");}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("}");return src;}function buildFragmentLambert(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;mesh._material._state;var geometryState=mesh._geometry._state;var clipping=sectionPlanesState.sectionPlanes.length>0;var gammaOutput=scene.gammaOutput;// If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
9782
- var src=[];src.push("#version 300 es");src.push("// Lambertian drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");for(var _i96=0,len=sectionPlanesState.sectionPlanes.length;_i96<len;_i96++){src.push("uniform bool sectionPlaneActive"+_i96+";");src.push("uniform vec3 sectionPlanePos"+_i96+";");src.push("uniform vec3 sectionPlaneDir"+_i96+";");}}src.push("in vec4 vColor;");if(gammaOutput){src.push("uniform float gammaFactor;");src.push(" vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i97=0,_len9=sectionPlanesState.sectionPlanes.length;_i97<_len9;_i97++){src.push("if (sectionPlaneActive"+_i97+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i97+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i97+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(geometryState.primitiveName==="points"){src.push("vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push("float r = dot(cxy, cxy);");src.push("if (r > 1.0) {");src.push(" discard;");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}if(gammaOutput){src.push("outColor = linearToGamma(vColor, gammaFactor);");}else{src.push("outColor = vColor;");}src.push("}");return src;}function buildVertexDraw(mesh){var scene=mesh.scene;mesh._material;var meshState=mesh._state;var sectionPlanesState=scene._sectionPlanesState;var geometryState=mesh._geometry._state;var lightsState=scene._lightsState;var light;var billboard=meshState.billboard;var background=meshState.background;var stationary=meshState.stationary;var texturing=hasTextures(mesh);var normals=hasNormals$1(mesh);var clipping=sectionPlanesState.sectionPlanes.length>0;var receivesShadow=getReceivesShadow(mesh);var quantizedGeometry=!!geometryState.compressGeometry;var src=[];src.push("#version 300 es");src.push("// Drawing vertex shader");src.push("in vec3 position;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("out vec3 vViewPosition;");src.push("uniform vec3 offset;");if(clipping){src.push("out vec4 vWorldPosition;");}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(lightsState.lightMaps.length>0){src.push("out vec3 vWorldNormal;");}if(normals){src.push("in vec3 normal;");src.push("uniform mat4 modelNormalMatrix;");src.push("uniform mat4 viewNormalMatrix;");src.push("out vec3 vViewNormal;");for(var _i98=0,len=lightsState.lights.length;_i98<len;_i98++){light=lightsState.lights[_i98];if(light.type==="ambient"){continue;}if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i98+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i98+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i98+";");src.push("uniform vec3 lightDir"+_i98+";");}if(!(light.type==="dir"&&light.space==="view")){src.push("out vec4 vViewLightReverseDirAndDist"+_i98+";");}}if(quantizedGeometry){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(texturing){src.push("in vec2 uv;");src.push("out vec2 vUV;");if(quantizedGeometry){src.push("uniform mat3 uvDecodeMatrix;");}}if(geometryState.colors){src.push("in vec4 color;");src.push("out vec4 vColor;");}if(geometryState.primitiveName==="points"){src.push("uniform float pointSize;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}if(receivesShadow){src.push("const mat4 texUnitConverter = mat4(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);");for(var _i99=0,_len10=lightsState.lights.length;_i99<_len10;_i99++){// Light sources
9805
+ */var DrawShaderSource=function DrawShaderSource(mesh){if(mesh._material._state.type==="LambertMaterial"){this.vertex=buildVertexLambert(mesh);this.fragment=buildFragmentLambert(mesh);}else{this.vertex=buildVertexDraw(mesh);this.fragment=buildFragmentDraw(mesh);}};var TEXTURE_DECODE_FUNCS$1={};TEXTURE_DECODE_FUNCS$1[LinearEncoding]="linearToLinear";TEXTURE_DECODE_FUNCS$1[sRGBEncoding]="sRGBToLinear";function getReceivesShadow(mesh){if(!mesh.receivesShadow){return false;}var lights=mesh.scene._lightsState.lights;if(!lights||lights.length===0){return false;}for(var _i93=0,len=lights.length;_i93<len;_i93++){if(lights[_i93].castsShadow){return true;}}return false;}function hasTextures(mesh){if(!mesh._geometry._state.uvBuf){return false;}var material=mesh._material;return!!(material._ambientMap||material._occlusionMap||material._baseColorMap||material._diffuseMap||material._alphaMap||material._specularMap||material._glossinessMap||material._specularGlossinessMap||material._emissiveMap||material._metallicMap||material._roughnessMap||material._metallicRoughnessMap||material._reflectivityMap||material._normalMap);}function hasNormals$1(mesh){var primitive=mesh._geometry._state.primitiveName;if((mesh._geometry._state.autoVertexNormals||mesh._geometry._state.normalsBuf)&&(primitive==="triangles"||primitive==="triangle-strip"||primitive==="triangle-fan")){return true;}return false;}function buildVertexLambert(mesh){var scene=mesh.scene;var sectionPlanesState=mesh.scene._sectionPlanesState;var lightsState=mesh.scene._lightsState;var geometryState=mesh._geometry._state;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var quantizedGeometry=!!geometryState.compressGeometry;var src=[];src.push("#version 300 es");src.push("// Lambertian drawing vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec4 colorize;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}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("uniform vec4 lightAmbient;");src.push("uniform vec4 materialColor;");src.push("uniform vec3 materialEmissive;");if(geometryState.normalsBuf){src.push("in vec3 normal;");src.push("uniform mat4 modelNormalMatrix;");src.push("uniform mat4 viewNormalMatrix;");for(var _i94=0,len=lightsState.lights.length;_i94<len;_i94++){var light=lightsState.lights[_i94];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i94+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i94+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i94+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i94+";");src.push("uniform vec3 lightDir"+_i94+";");}}if(quantizedGeometry){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("}");}}src.push("out vec4 vColor;");if(geometryState.primitiveName==="points"){src.push("uniform float pointSize;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}if(geometryState.normalsBuf){if(quantizedGeometry){src.push("vec4 localNormal = vec4(octDecode(normal.xy), 0.0); ");}else{src.push("vec4 localNormal = vec4(normal, 0.0); ");}src.push("mat4 modelNormalMatrix2 = modelNormalMatrix;");src.push("mat4 viewNormalMatrix2 = viewNormalMatrix;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");if(geometryState.normalsBuf){src.push("mat4 modelViewNormalMatrix = viewNormalMatrix2 * modelNormalMatrix2;");src.push("billboard(modelNormalMatrix2);");src.push("billboard(viewNormalMatrix2);");src.push("billboard(modelViewNormalMatrix);");}src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}if(geometryState.normalsBuf){src.push("vec3 viewNormal = normalize((viewNormalMatrix2 * modelNormalMatrix2 * localNormal).xyz);");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");if(geometryState.normalsBuf){for(var _i95=0,_len8=lightsState.lights.length;_i95<_len8;_i95++){var _light=lightsState.lights[_i95];if(_light.type==="ambient"){continue;}if(_light.type==="dir"){if(_light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i95+");");}else{src.push("viewLightDir = normalize((viewMatrix2 * vec4(lightDir"+_i95+", 0.0)).xyz);");}}else if(_light.type==="point"){if(_light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i95+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix2 * vec4(lightPos"+_i95+", 0.0)).xyz);");}}else if(_light.type==="spot"){if(_light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i95+");");}else{src.push("viewLightDir = normalize((viewMatrix2 * vec4(lightDir"+_i95+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i95+".rgb * lightColor"+_i95+".a);");}}src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * materialColor.rgb) + materialEmissive.rgb + (reflectedColor * materialColor.rgb), materialColor.a) * colorize;");// TODO: How to have ambient bright enough for canvas BG but not too bright for scene?
9806
+ if(clipping){src.push("vWorldPosition = worldPosition;");}if(geometryState.primitiveName==="points"){src.push("gl_PointSize = pointSize;");}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("}");return src;}function buildFragmentLambert(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;mesh._material._state;var geometryState=mesh._geometry._state;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var gammaOutput=scene.gammaOutput;// If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
9807
+ var src=[];src.push("#version 300 es");src.push("// Lambertian drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");for(var _i96=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i96<len;_i96++){src.push("uniform bool sectionPlaneActive"+_i96+";");src.push("uniform vec3 sectionPlanePos"+_i96+";");src.push("uniform vec3 sectionPlaneDir"+_i96+";");}}src.push("in vec4 vColor;");if(gammaOutput){src.push("uniform float gammaFactor;");src.push(" vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i97=0,_len9=sectionPlanesState.getNumAllocatedSectionPlanes();_i97<_len9;_i97++){src.push("if (sectionPlaneActive"+_i97+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i97+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i97+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(geometryState.primitiveName==="points"){src.push("vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push("float r = dot(cxy, cxy);");src.push("if (r > 1.0) {");src.push(" discard;");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}if(gammaOutput){src.push("outColor = linearToGamma(vColor, gammaFactor);");}else{src.push("outColor = vColor;");}src.push("}");return src;}function buildVertexDraw(mesh){var scene=mesh.scene;mesh._material;var meshState=mesh._state;var sectionPlanesState=scene._sectionPlanesState;var geometryState=mesh._geometry._state;var lightsState=scene._lightsState;var light;var billboard=meshState.billboard;var background=meshState.background;var stationary=meshState.stationary;var texturing=hasTextures(mesh);var normals=hasNormals$1(mesh);var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var receivesShadow=getReceivesShadow(mesh);var quantizedGeometry=!!geometryState.compressGeometry;var src=[];src.push("#version 300 es");src.push("// Drawing vertex shader");src.push("in vec3 position;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("out vec3 vViewPosition;");src.push("uniform vec3 offset;");if(clipping){src.push("out vec4 vWorldPosition;");}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(lightsState.lightMaps.length>0){src.push("out vec3 vWorldNormal;");}if(normals){src.push("in vec3 normal;");src.push("uniform mat4 modelNormalMatrix;");src.push("uniform mat4 viewNormalMatrix;");src.push("out vec3 vViewNormal;");for(var _i98=0,len=lightsState.lights.length;_i98<len;_i98++){light=lightsState.lights[_i98];if(light.type==="ambient"){continue;}if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i98+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i98+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i98+";");src.push("uniform vec3 lightDir"+_i98+";");}if(!(light.type==="dir"&&light.space==="view")){src.push("out vec4 vViewLightReverseDirAndDist"+_i98+";");}}if(quantizedGeometry){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(texturing){src.push("in vec2 uv;");src.push("out vec2 vUV;");if(quantizedGeometry){src.push("uniform mat3 uvDecodeMatrix;");}}if(geometryState.colors){src.push("in vec4 color;");src.push("out vec4 vColor;");}if(geometryState.primitiveName==="points"){src.push("uniform float pointSize;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}if(receivesShadow){src.push("const mat4 texUnitConverter = mat4(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);");for(var _i99=0,_len10=lightsState.lights.length;_i99<_len10;_i99++){// Light sources
9783
9808
  if(lightsState.lights[_i99].castsShadow){src.push("uniform mat4 shadowViewMatrix"+_i99+";");src.push("uniform mat4 shadowProjMatrix"+_i99+";");src.push("out vec4 vShadowPosFromLight"+_i99+";");}}}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}if(normals){if(quantizedGeometry){src.push("vec4 localNormal = vec4(octDecode(normal.xy), 0.0); ");}else{src.push("vec4 localNormal = vec4(normal, 0.0); ");}src.push("mat4 modelNormalMatrix2 = modelNormalMatrix;");src.push("mat4 viewNormalMatrix2 = viewNormalMatrix;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}else if(background){src.push("viewMatrix2[3] = vec4(0.0, 0.0, 0.0 ,1.0);");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");if(normals){src.push("mat4 modelViewNormalMatrix = viewNormalMatrix2 * modelNormalMatrix2;");src.push("billboard(modelNormalMatrix2);");src.push("billboard(viewNormalMatrix2);");src.push("billboard(modelViewNormalMatrix);");}src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}if(normals){src.push("vec3 worldNormal = (modelNormalMatrix2 * localNormal).xyz; ");if(lightsState.lightMaps.length>0){src.push("vWorldNormal = worldNormal;");}src.push("vViewNormal = normalize((viewNormalMatrix2 * vec4(worldNormal, 1.0)).xyz);");src.push("vec3 tmpVec3;");src.push("float lightDist;");for(var _i100=0,_len11=lightsState.lights.length;_i100<_len11;_i100++){// Lights
9784
9809
  light=lightsState.lights[_i100];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="world"){src.push("tmpVec3 = vec3(viewMatrix2 * vec4(lightDir"+_i100+", 0.0) ).xyz;");src.push("vViewLightReverseDirAndDist"+_i100+" = vec4(-tmpVec3, 0.0);");}}if(light.type==="point"){if(light.space==="world"){src.push("tmpVec3 = (viewMatrix2 * vec4(lightPos"+_i100+", 1.0)).xyz - viewPosition.xyz;");src.push("lightDist = abs(length(tmpVec3));");}else{src.push("tmpVec3 = lightPos"+_i100+".xyz - viewPosition.xyz;");src.push("lightDist = abs(length(tmpVec3));");}src.push("vViewLightReverseDirAndDist"+_i100+" = vec4(tmpVec3, lightDist);");}}}if(texturing){if(quantizedGeometry){src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");}else{src.push("vUV = uv;");}}if(geometryState.colors){src.push("vColor = color;");}if(geometryState.primitiveName==="points"){src.push("gl_PointSize = pointSize;");}if(clipping){src.push("vWorldPosition = worldPosition;");}src.push(" vViewPosition = viewPosition.xyz;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(background){src.push("clipPos.z = clipPos.w;");}src.push("gl_Position = clipPos;");if(receivesShadow){src.push("const mat4 texUnitConverter = mat4(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);");src.push("vec4 tempx; ");for(var _i101=0,_len12=lightsState.lights.length;_i101<_len12;_i101++){// Light sources
9785
- if(lightsState.lights[_i101].castsShadow){src.push("vShadowPosFromLight"+_i101+" = texUnitConverter * shadowProjMatrix"+_i101+" * (shadowViewMatrix"+_i101+" * worldPosition); ");}}}src.push("}");return src;}function buildFragmentDraw(mesh){var scene=mesh.scene;scene.canvas.gl;var material=mesh._material;var geometryState=mesh._geometry._state;var sectionPlanesState=mesh.scene._sectionPlanesState;var lightsState=mesh.scene._lightsState;var materialState=mesh._material._state;var clipping=sectionPlanesState.sectionPlanes.length>0;var normals=hasNormals$1(mesh);var uvs=geometryState.uvBuf;var phongMaterial=materialState.type==="PhongMaterial";var metallicMaterial=materialState.type==="MetallicMaterial";var specularMaterial=materialState.type==="SpecularMaterial";var receivesShadow=getReceivesShadow(mesh);scene.gammaInput;// If set, then it expects that all textures and colors are premultiplied gamma. Default is false.
9810
+ if(lightsState.lights[_i101].castsShadow){src.push("vShadowPosFromLight"+_i101+" = texUnitConverter * shadowProjMatrix"+_i101+" * (shadowViewMatrix"+_i101+" * worldPosition); ");}}}src.push("}");return src;}function buildFragmentDraw(mesh){var scene=mesh.scene;scene.canvas.gl;var material=mesh._material;var geometryState=mesh._geometry._state;var sectionPlanesState=mesh.scene._sectionPlanesState;var lightsState=mesh.scene._lightsState;var materialState=mesh._material._state;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var normals=hasNormals$1(mesh);var uvs=geometryState.uvBuf;var phongMaterial=materialState.type==="PhongMaterial";var metallicMaterial=materialState.type==="MetallicMaterial";var specularMaterial=materialState.type==="SpecularMaterial";var receivesShadow=getReceivesShadow(mesh);scene.gammaInput;// If set, then it expects that all textures and colors are premultiplied gamma. Default is false.
9786
9811
  var gammaOutput=scene.gammaOutput;// If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
9787
9812
  var src=[];src.push("#version 300 es");src.push("// Drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(receivesShadow){src.push("float unpackDepth (vec4 color) {");src.push(" const vec4 bitShift = vec4(1.0, 1.0/256.0, 1.0/(256.0 * 256.0), 1.0/(256.0*256.0*256.0));");src.push(" return dot(color, bitShift);");src.push("}");}//--------------------------------------------------------------------------------
9788
9813
  // GAMMA CORRECTION
@@ -9790,7 +9815,7 @@ var src=[];src.push("#version 300 es");src.push("// Drawing fragment shader");sr
9790
9815
  src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}//--------------------------------------------------------------------------------
9791
9816
  // USER CLIP PLANES
9792
9817
  //--------------------------------------------------------------------------------
9793
- if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");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+";");}}if(normals){//--------------------------------------------------------------------------------
9818
+ if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}if(normals){//--------------------------------------------------------------------------------
9794
9819
  // LIGHT AND REFLECTION MAP INPUTS
9795
9820
  // Define here so available globally to shader functions
9796
9821
  //--------------------------------------------------------------------------------
@@ -9845,7 +9870,7 @@ for(var _i103=0,_len13=lightsState.lights.length;_i103<_len13;_i103++){// Light
9845
9870
  if(lightsState.lights[_i103].castsShadow){src.push("in vec4 vShadowPosFromLight"+_i103+";");src.push("uniform sampler2D shadowMap"+_i103+";");}}}src.push("uniform vec4 colorize;");//================================================================================
9846
9871
  // MAIN
9847
9872
  //================================================================================
9848
- src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.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(geometryState.primitiveName==="points"){src.push("vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push("float r = dot(cxy, cxy);");src.push("if (r > 1.0) {");src.push(" discard;");src.push("}");}src.push("float occlusion = 1.0;");if(materialState.ambient){src.push("vec3 ambientColor = materialAmbient;");}else{src.push("vec3 ambientColor = vec3(1.0, 1.0, 1.0);");}if(materialState.diffuse){src.push("vec3 diffuseColor = materialDiffuse;");}else if(materialState.baseColor){src.push("vec3 diffuseColor = materialBaseColor;");}else{src.push("vec3 diffuseColor = vec3(1.0, 1.0, 1.0);");}if(geometryState.colors){src.push("diffuseColor *= vColor.rgb;");}if(materialState.emissive){src.push("vec3 emissiveColor = materialEmissive;");// Emissive default is (0,0,0), so initializing here
9873
+ src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(geometryState.primitiveName==="points"){src.push("vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push("float r = dot(cxy, cxy);");src.push("if (r > 1.0) {");src.push(" discard;");src.push("}");}src.push("float occlusion = 1.0;");if(materialState.ambient){src.push("vec3 ambientColor = materialAmbient;");}else{src.push("vec3 ambientColor = vec3(1.0, 1.0, 1.0);");}if(materialState.diffuse){src.push("vec3 diffuseColor = materialDiffuse;");}else if(materialState.baseColor){src.push("vec3 diffuseColor = materialBaseColor;");}else{src.push("vec3 diffuseColor = vec3(1.0, 1.0, 1.0);");}if(geometryState.colors){src.push("diffuseColor *= vColor.rgb;");}if(materialState.emissive){src.push("vec3 emissiveColor = materialEmissive;");// Emissive default is (0,0,0), so initializing here
9849
9874
  }else{src.push("vec3 emissiveColor = vec3(0.0, 0.0, 0.0);");}if(materialState.specular){src.push("vec3 specular = materialSpecular;");}else{src.push("vec3 specular = vec3(1.0, 1.0, 1.0);");}if(materialState.alpha!==undefined){src.push("float alpha = materialAlphaModeCutoff[0];");}else{src.push("float alpha = 1.0;");}if(geometryState.colors){src.push("alpha *= vColor.a;");}if(materialState.glossiness!==undefined){src.push("float glossiness = materialGlossiness;");}else{src.push("float glossiness = 1.0;");}if(materialState.metallic!==undefined){src.push("float metallic = materialMetallic;");}else{src.push("float metallic = 1.0;");}if(materialState.roughness!==undefined){src.push("float roughness = materialRoughness;");}else{src.push("float roughness = 1.0;");}if(materialState.specularF0!==undefined){src.push("float specularF0 = materialSpecularF0;");}else{src.push("float specularF0 = 1.0;");}//--------------------------------------------------------------------------------
9850
9875
  // TEXTURING
9851
9876
  //--------------------------------------------------------------------------------
@@ -9903,61 +9928,61 @@ src.push("ambientColor *= (lightAmbient.rgb * lightAmbient.a);");src.push("vec3
9903
9928
  * @author xeolabs / https://github.com/xeolabs
9904
9929
  */var tempVec3a$A=math.vec3();var ids$2=new Map$1({});/**
9905
9930
  * @private
9906
- */var DrawRenderer=function DrawRenderer(hash,mesh){this.id=ids$2.addItem({});this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new DrawShaderSource(mesh);this._allocate(mesh);};var drawRenderers={};DrawRenderer.get=function(mesh){var scene=mesh.scene;var hash=[scene.canvas.canvas.id,(scene.gammaInput?"gi;":";")+(scene.gammaOutput?"go":""),scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._material._state.hash,mesh._state.drawHash].join(";");var renderer=drawRenderers[hash];if(!renderer){renderer=new DrawRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}drawRenderers[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};DrawRenderer.prototype.put=function(){if(--this._useCount===0){ids$2.removeItem(this.id);if(this._program){this._program.destroy();}delete drawRenderers[this._hash];stats.memory.programs--;}};DrawRenderer.prototype.webglContextRestored=function(){this._program=null;};DrawRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_UNITS;var scene=mesh.scene;var material=mesh._material;var gl=scene.canvas.gl;var program=this._program;var meshState=mesh._state;var materialState=mesh._material._state;var geometryState=mesh._geometry._state;var camera=scene.camera;var origin=mesh.origin;var background=meshState.background;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;if(background){gl.depthFunc(gl.LEQUAL);}this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);if(meshState.clippable){var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];gl.uniform3fv(sectionPlaneUniforms.pos,origin?getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$A):sectionPlane.pos);gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}}if(materialState.id!==this._lastMaterialId){frameCtx.textureUnit=this._baseTextureUnit;var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}if(frameCtx.lineWidth!==materialState.lineWidth){gl.lineWidth(materialState.lineWidth);frameCtx.lineWidth=materialState.lineWidth;}if(this._uPointSize){gl.uniform1f(this._uPointSize,materialState.pointSize);}switch(materialState.type){case"LambertMaterial":if(this._uMaterialAmbient){gl.uniform3fv(this._uMaterialAmbient,materialState.ambient);}if(this._uMaterialColor){gl.uniform4f(this._uMaterialColor,materialState.color[0],materialState.color[1],materialState.color[2],materialState.alpha);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}break;case"PhongMaterial":if(this._uMaterialShininess){gl.uniform1f(this._uMaterialShininess,materialState.shininess);}if(this._uMaterialAmbient){gl.uniform3fv(this._uMaterialAmbient,materialState.ambient);}if(this._uMaterialDiffuse){gl.uniform3fv(this._uMaterialDiffuse,materialState.diffuse);}if(this._uMaterialSpecular){gl.uniform3fv(this._uMaterialSpecular,materialState.specular);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0);}if(material._ambientMap&&material._ambientMap._state.texture&&this._uMaterialAmbientMap){program.bindTexture(this._uMaterialAmbientMap,material._ambientMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMaterialAmbientMapMatrix){gl.uniformMatrix4fv(this._uMaterialAmbientMapMatrix,false,material._ambientMap._state.matrix);}}if(material._diffuseMap&&material._diffuseMap._state.texture&&this._uDiffuseMap){program.bindTexture(this._uDiffuseMap,material._diffuseMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uDiffuseMapMatrix){gl.uniformMatrix4fv(this._uDiffuseMapMatrix,false,material._diffuseMap._state.matrix);}}if(material._specularMap&&material._specularMap._state.texture&&this._uSpecularMap){program.bindTexture(this._uSpecularMap,material._specularMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularMapMatrix){gl.uniformMatrix4fv(this._uSpecularMapMatrix,false,material._specularMap._state.matrix);}}if(material._emissiveMap&&material._emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,material._emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,material._emissiveMap._state.matrix);}}if(material._alphaMap&&material._alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,material._alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,material._alphaMap._state.matrix);}}if(material._reflectivityMap&&material._reflectivityMap._state.texture&&this._uReflectivityMap){program.bindTexture(this._uReflectivityMap,material._reflectivityMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;if(this._uReflectivityMapMatrix){gl.uniformMatrix4fv(this._uReflectivityMapMatrix,false,material._reflectivityMap._state.matrix);}}if(material._normalMap&&material._normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,material._normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,material._normalMap._state.matrix);}}if(material._occlusionMap&&material._occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,material._occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,material._occlusionMap._state.matrix);}}if(material._diffuseFresnel){if(this._uDiffuseFresnelEdgeBias){gl.uniform1f(this._uDiffuseFresnelEdgeBias,material._diffuseFresnel.edgeBias);}if(this._uDiffuseFresnelCenterBias){gl.uniform1f(this._uDiffuseFresnelCenterBias,material._diffuseFresnel.centerBias);}if(this._uDiffuseFresnelEdgeColor){gl.uniform3fv(this._uDiffuseFresnelEdgeColor,material._diffuseFresnel.edgeColor);}if(this._uDiffuseFresnelCenterColor){gl.uniform3fv(this._uDiffuseFresnelCenterColor,material._diffuseFresnel.centerColor);}if(this._uDiffuseFresnelPower){gl.uniform1f(this._uDiffuseFresnelPower,material._diffuseFresnel.power);}}if(material._specularFresnel){if(this._uSpecularFresnelEdgeBias){gl.uniform1f(this._uSpecularFresnelEdgeBias,material._specularFresnel.edgeBias);}if(this._uSpecularFresnelCenterBias){gl.uniform1f(this._uSpecularFresnelCenterBias,material._specularFresnel.centerBias);}if(this._uSpecularFresnelEdgeColor){gl.uniform3fv(this._uSpecularFresnelEdgeColor,material._specularFresnel.edgeColor);}if(this._uSpecularFresnelCenterColor){gl.uniform3fv(this._uSpecularFresnelCenterColor,material._specularFresnel.centerColor);}if(this._uSpecularFresnelPower){gl.uniform1f(this._uSpecularFresnelPower,material._specularFresnel.power);}}if(material._alphaFresnel){if(this._uAlphaFresnelEdgeBias){gl.uniform1f(this._uAlphaFresnelEdgeBias,material._alphaFresnel.edgeBias);}if(this._uAlphaFresnelCenterBias){gl.uniform1f(this._uAlphaFresnelCenterBias,material._alphaFresnel.centerBias);}if(this._uAlphaFresnelEdgeColor){gl.uniform3fv(this._uAlphaFresnelEdgeColor,material._alphaFresnel.edgeColor);}if(this._uAlphaFresnelCenterColor){gl.uniform3fv(this._uAlphaFresnelCenterColor,material._alphaFresnel.centerColor);}if(this._uAlphaFresnelPower){gl.uniform1f(this._uAlphaFresnelPower,material._alphaFresnel.power);}}if(material._reflectivityFresnel){if(this._uReflectivityFresnelEdgeBias){gl.uniform1f(this._uReflectivityFresnelEdgeBias,material._reflectivityFresnel.edgeBias);}if(this._uReflectivityFresnelCenterBias){gl.uniform1f(this._uReflectivityFresnelCenterBias,material._reflectivityFresnel.centerBias);}if(this._uReflectivityFresnelEdgeColor){gl.uniform3fv(this._uReflectivityFresnelEdgeColor,material._reflectivityFresnel.edgeColor);}if(this._uReflectivityFresnelCenterColor){gl.uniform3fv(this._uReflectivityFresnelCenterColor,material._reflectivityFresnel.centerColor);}if(this._uReflectivityFresnelPower){gl.uniform1f(this._uReflectivityFresnelPower,material._reflectivityFresnel.power);}}if(material._emissiveFresnel){if(this._uEmissiveFresnelEdgeBias){gl.uniform1f(this._uEmissiveFresnelEdgeBias,material._emissiveFresnel.edgeBias);}if(this._uEmissiveFresnelCenterBias){gl.uniform1f(this._uEmissiveFresnelCenterBias,material._emissiveFresnel.centerBias);}if(this._uEmissiveFresnelEdgeColor){gl.uniform3fv(this._uEmissiveFresnelEdgeColor,material._emissiveFresnel.edgeColor);}if(this._uEmissiveFresnelCenterColor){gl.uniform3fv(this._uEmissiveFresnelCenterColor,material._emissiveFresnel.centerColor);}if(this._uEmissiveFresnelPower){gl.uniform1f(this._uEmissiveFresnelPower,material._emissiveFresnel.power);}}break;case"MetallicMaterial":if(this._uBaseColor){gl.uniform3fv(this._uBaseColor,materialState.baseColor);}if(this._uMaterialMetallic){gl.uniform1f(this._uMaterialMetallic,materialState.metallic);}if(this._uMaterialRoughness){gl.uniform1f(this._uMaterialRoughness,materialState.roughness);}if(this._uMaterialSpecularF0){gl.uniform1f(this._uMaterialSpecularF0,materialState.specularF0);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0.0);}var baseColorMap=material._baseColorMap;if(baseColorMap&&baseColorMap._state.texture&&this._uBaseColorMap){program.bindTexture(this._uBaseColorMap,baseColorMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uBaseColorMapMatrix){gl.uniformMatrix4fv(this._uBaseColorMapMatrix,false,baseColorMap._state.matrix);}}var metallicMap=material._metallicMap;if(metallicMap&&metallicMap._state.texture&&this._uMetallicMap){program.bindTexture(this._uMetallicMap,metallicMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMetallicMapMatrix){gl.uniformMatrix4fv(this._uMetallicMapMatrix,false,metallicMap._state.matrix);}}var roughnessMap=material._roughnessMap;if(roughnessMap&&roughnessMap._state.texture&&this._uRoughnessMap){program.bindTexture(this._uRoughnessMap,roughnessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uRoughnessMapMatrix){gl.uniformMatrix4fv(this._uRoughnessMapMatrix,false,roughnessMap._state.matrix);}}var metallicRoughnessMap=material._metallicRoughnessMap;if(metallicRoughnessMap&&metallicRoughnessMap._state.texture&&this._uMetallicRoughnessMap){program.bindTexture(this._uMetallicRoughnessMap,metallicRoughnessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMetallicRoughnessMapMatrix){gl.uniformMatrix4fv(this._uMetallicRoughnessMapMatrix,false,metallicRoughnessMap._state.matrix);}}var emissiveMap=material._emissiveMap;if(emissiveMap&&emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,emissiveMap._state.matrix);}}var occlusionMap=material._occlusionMap;if(occlusionMap&&material._occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,occlusionMap._state.matrix);}}var alphaMap=material._alphaMap;if(alphaMap&&alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,alphaMap._state.matrix);}}var normalMap=material._normalMap;if(normalMap&&normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,normalMap._state.matrix);}}break;case"SpecularMaterial":if(this._uMaterialDiffuse){gl.uniform3fv(this._uMaterialDiffuse,materialState.diffuse);}if(this._uMaterialSpecular){gl.uniform3fv(this._uMaterialSpecular,materialState.specular);}if(this._uMaterialGlossiness){gl.uniform1f(this._uMaterialGlossiness,materialState.glossiness);}if(this._uMaterialReflectivity){gl.uniform1f(this._uMaterialReflectivity,materialState.reflectivity);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0.0);}var diffuseMap=material._diffuseMap;if(diffuseMap&&diffuseMap._state.texture&&this._uDiffuseMap){program.bindTexture(this._uDiffuseMap,diffuseMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uDiffuseMapMatrix){gl.uniformMatrix4fv(this._uDiffuseMapMatrix,false,diffuseMap._state.matrix);}}var specularMap=material._specularMap;if(specularMap&&specularMap._state.texture&&this._uSpecularMap){program.bindTexture(this._uSpecularMap,specularMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularMapMatrix){gl.uniformMatrix4fv(this._uSpecularMapMatrix,false,specularMap._state.matrix);}}var glossinessMap=material._glossinessMap;if(glossinessMap&&glossinessMap._state.texture&&this._uGlossinessMap){program.bindTexture(this._uGlossinessMap,glossinessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uGlossinessMapMatrix){gl.uniformMatrix4fv(this._uGlossinessMapMatrix,false,glossinessMap._state.matrix);}}var specularGlossinessMap=material._specularGlossinessMap;if(specularGlossinessMap&&specularGlossinessMap._state.texture&&this._uSpecularGlossinessMap){program.bindTexture(this._uSpecularGlossinessMap,specularGlossinessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularGlossinessMapMatrix){gl.uniformMatrix4fv(this._uSpecularGlossinessMapMatrix,false,specularGlossinessMap._state.matrix);}}var emissiveMap=material._emissiveMap;if(emissiveMap&&emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,emissiveMap._state.matrix);}}var occlusionMap=material._occlusionMap;if(occlusionMap&&occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,occlusionMap._state.matrix);}}var alphaMap=material._alphaMap;if(alphaMap&&alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,alphaMap._state.matrix);}}var normalMap=material._normalMap;if(normalMap&&normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,normalMap._state.matrix);}}break;}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uModelNormalMatrix){gl.uniformMatrix4fv(this._uModelNormalMatrix,gl.FALSE,mesh.worldNormalMatrix);}if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}if(this._uColorize){var colorize=meshState.colorize;var lastColorize=this._lastColorize;if(lastColorize[0]!==colorize[0]||lastColorize[1]!==colorize[1]||lastColorize[2]!==colorize[2]||lastColorize[3]!==colorize[3]){gl.uniform4fv(this._uColorize,colorize);lastColorize[0]=colorize[0];lastColorize[1]=colorize[1];lastColorize[2]=colorize[2];lastColorize[3]=colorize[3];}}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
9931
+ */var DrawRenderer=function DrawRenderer(hash,mesh){this.id=ids$2.addItem({});this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new DrawShaderSource(mesh);this._allocate(mesh);};var drawRenderers={};DrawRenderer.get=function(mesh){var scene=mesh.scene;var hash=[scene.canvas.canvas.id,(scene.gammaInput?"gi;":";")+(scene.gammaOutput?"go":""),scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._material._state.hash,mesh._state.drawHash].join(";");var renderer=drawRenderers[hash];if(!renderer){renderer=new DrawRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}drawRenderers[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};DrawRenderer.prototype.put=function(){if(--this._useCount===0){ids$2.removeItem(this.id);if(this._program){this._program.destroy();}delete drawRenderers[this._hash];stats.memory.programs--;}};DrawRenderer.prototype.webglContextRestored=function(){this._program=null;};DrawRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_UNITS;var scene=mesh.scene;var material=mesh._material;var gl=scene.canvas.gl;var program=this._program;var meshState=mesh._state;var materialState=mesh._material._state;var geometryState=mesh._geometry._state;var camera=scene.camera;var origin=mesh.origin;var background=meshState.background;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;if(background){gl.depthFunc(gl.LEQUAL);}this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$A);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}if(materialState.id!==this._lastMaterialId){frameCtx.textureUnit=this._baseTextureUnit;var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}if(frameCtx.lineWidth!==materialState.lineWidth){gl.lineWidth(materialState.lineWidth);frameCtx.lineWidth=materialState.lineWidth;}if(this._uPointSize){gl.uniform1f(this._uPointSize,materialState.pointSize);}switch(materialState.type){case"LambertMaterial":if(this._uMaterialAmbient){gl.uniform3fv(this._uMaterialAmbient,materialState.ambient);}if(this._uMaterialColor){gl.uniform4f(this._uMaterialColor,materialState.color[0],materialState.color[1],materialState.color[2],materialState.alpha);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}break;case"PhongMaterial":if(this._uMaterialShininess){gl.uniform1f(this._uMaterialShininess,materialState.shininess);}if(this._uMaterialAmbient){gl.uniform3fv(this._uMaterialAmbient,materialState.ambient);}if(this._uMaterialDiffuse){gl.uniform3fv(this._uMaterialDiffuse,materialState.diffuse);}if(this._uMaterialSpecular){gl.uniform3fv(this._uMaterialSpecular,materialState.specular);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0);}if(material._ambientMap&&material._ambientMap._state.texture&&this._uMaterialAmbientMap){program.bindTexture(this._uMaterialAmbientMap,material._ambientMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMaterialAmbientMapMatrix){gl.uniformMatrix4fv(this._uMaterialAmbientMapMatrix,false,material._ambientMap._state.matrix);}}if(material._diffuseMap&&material._diffuseMap._state.texture&&this._uDiffuseMap){program.bindTexture(this._uDiffuseMap,material._diffuseMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uDiffuseMapMatrix){gl.uniformMatrix4fv(this._uDiffuseMapMatrix,false,material._diffuseMap._state.matrix);}}if(material._specularMap&&material._specularMap._state.texture&&this._uSpecularMap){program.bindTexture(this._uSpecularMap,material._specularMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularMapMatrix){gl.uniformMatrix4fv(this._uSpecularMapMatrix,false,material._specularMap._state.matrix);}}if(material._emissiveMap&&material._emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,material._emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,material._emissiveMap._state.matrix);}}if(material._alphaMap&&material._alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,material._alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,material._alphaMap._state.matrix);}}if(material._reflectivityMap&&material._reflectivityMap._state.texture&&this._uReflectivityMap){program.bindTexture(this._uReflectivityMap,material._reflectivityMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;if(this._uReflectivityMapMatrix){gl.uniformMatrix4fv(this._uReflectivityMapMatrix,false,material._reflectivityMap._state.matrix);}}if(material._normalMap&&material._normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,material._normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,material._normalMap._state.matrix);}}if(material._occlusionMap&&material._occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,material._occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,material._occlusionMap._state.matrix);}}if(material._diffuseFresnel){if(this._uDiffuseFresnelEdgeBias){gl.uniform1f(this._uDiffuseFresnelEdgeBias,material._diffuseFresnel.edgeBias);}if(this._uDiffuseFresnelCenterBias){gl.uniform1f(this._uDiffuseFresnelCenterBias,material._diffuseFresnel.centerBias);}if(this._uDiffuseFresnelEdgeColor){gl.uniform3fv(this._uDiffuseFresnelEdgeColor,material._diffuseFresnel.edgeColor);}if(this._uDiffuseFresnelCenterColor){gl.uniform3fv(this._uDiffuseFresnelCenterColor,material._diffuseFresnel.centerColor);}if(this._uDiffuseFresnelPower){gl.uniform1f(this._uDiffuseFresnelPower,material._diffuseFresnel.power);}}if(material._specularFresnel){if(this._uSpecularFresnelEdgeBias){gl.uniform1f(this._uSpecularFresnelEdgeBias,material._specularFresnel.edgeBias);}if(this._uSpecularFresnelCenterBias){gl.uniform1f(this._uSpecularFresnelCenterBias,material._specularFresnel.centerBias);}if(this._uSpecularFresnelEdgeColor){gl.uniform3fv(this._uSpecularFresnelEdgeColor,material._specularFresnel.edgeColor);}if(this._uSpecularFresnelCenterColor){gl.uniform3fv(this._uSpecularFresnelCenterColor,material._specularFresnel.centerColor);}if(this._uSpecularFresnelPower){gl.uniform1f(this._uSpecularFresnelPower,material._specularFresnel.power);}}if(material._alphaFresnel){if(this._uAlphaFresnelEdgeBias){gl.uniform1f(this._uAlphaFresnelEdgeBias,material._alphaFresnel.edgeBias);}if(this._uAlphaFresnelCenterBias){gl.uniform1f(this._uAlphaFresnelCenterBias,material._alphaFresnel.centerBias);}if(this._uAlphaFresnelEdgeColor){gl.uniform3fv(this._uAlphaFresnelEdgeColor,material._alphaFresnel.edgeColor);}if(this._uAlphaFresnelCenterColor){gl.uniform3fv(this._uAlphaFresnelCenterColor,material._alphaFresnel.centerColor);}if(this._uAlphaFresnelPower){gl.uniform1f(this._uAlphaFresnelPower,material._alphaFresnel.power);}}if(material._reflectivityFresnel){if(this._uReflectivityFresnelEdgeBias){gl.uniform1f(this._uReflectivityFresnelEdgeBias,material._reflectivityFresnel.edgeBias);}if(this._uReflectivityFresnelCenterBias){gl.uniform1f(this._uReflectivityFresnelCenterBias,material._reflectivityFresnel.centerBias);}if(this._uReflectivityFresnelEdgeColor){gl.uniform3fv(this._uReflectivityFresnelEdgeColor,material._reflectivityFresnel.edgeColor);}if(this._uReflectivityFresnelCenterColor){gl.uniform3fv(this._uReflectivityFresnelCenterColor,material._reflectivityFresnel.centerColor);}if(this._uReflectivityFresnelPower){gl.uniform1f(this._uReflectivityFresnelPower,material._reflectivityFresnel.power);}}if(material._emissiveFresnel){if(this._uEmissiveFresnelEdgeBias){gl.uniform1f(this._uEmissiveFresnelEdgeBias,material._emissiveFresnel.edgeBias);}if(this._uEmissiveFresnelCenterBias){gl.uniform1f(this._uEmissiveFresnelCenterBias,material._emissiveFresnel.centerBias);}if(this._uEmissiveFresnelEdgeColor){gl.uniform3fv(this._uEmissiveFresnelEdgeColor,material._emissiveFresnel.edgeColor);}if(this._uEmissiveFresnelCenterColor){gl.uniform3fv(this._uEmissiveFresnelCenterColor,material._emissiveFresnel.centerColor);}if(this._uEmissiveFresnelPower){gl.uniform1f(this._uEmissiveFresnelPower,material._emissiveFresnel.power);}}break;case"MetallicMaterial":if(this._uBaseColor){gl.uniform3fv(this._uBaseColor,materialState.baseColor);}if(this._uMaterialMetallic){gl.uniform1f(this._uMaterialMetallic,materialState.metallic);}if(this._uMaterialRoughness){gl.uniform1f(this._uMaterialRoughness,materialState.roughness);}if(this._uMaterialSpecularF0){gl.uniform1f(this._uMaterialSpecularF0,materialState.specularF0);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0.0);}var baseColorMap=material._baseColorMap;if(baseColorMap&&baseColorMap._state.texture&&this._uBaseColorMap){program.bindTexture(this._uBaseColorMap,baseColorMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uBaseColorMapMatrix){gl.uniformMatrix4fv(this._uBaseColorMapMatrix,false,baseColorMap._state.matrix);}}var metallicMap=material._metallicMap;if(metallicMap&&metallicMap._state.texture&&this._uMetallicMap){program.bindTexture(this._uMetallicMap,metallicMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMetallicMapMatrix){gl.uniformMatrix4fv(this._uMetallicMapMatrix,false,metallicMap._state.matrix);}}var roughnessMap=material._roughnessMap;if(roughnessMap&&roughnessMap._state.texture&&this._uRoughnessMap){program.bindTexture(this._uRoughnessMap,roughnessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uRoughnessMapMatrix){gl.uniformMatrix4fv(this._uRoughnessMapMatrix,false,roughnessMap._state.matrix);}}var metallicRoughnessMap=material._metallicRoughnessMap;if(metallicRoughnessMap&&metallicRoughnessMap._state.texture&&this._uMetallicRoughnessMap){program.bindTexture(this._uMetallicRoughnessMap,metallicRoughnessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uMetallicRoughnessMapMatrix){gl.uniformMatrix4fv(this._uMetallicRoughnessMapMatrix,false,metallicRoughnessMap._state.matrix);}}var emissiveMap=material._emissiveMap;if(emissiveMap&&emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,emissiveMap._state.matrix);}}var occlusionMap=material._occlusionMap;if(occlusionMap&&material._occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,occlusionMap._state.matrix);}}var alphaMap=material._alphaMap;if(alphaMap&&alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,alphaMap._state.matrix);}}var normalMap=material._normalMap;if(normalMap&&normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,normalMap._state.matrix);}}break;case"SpecularMaterial":if(this._uMaterialDiffuse){gl.uniform3fv(this._uMaterialDiffuse,materialState.diffuse);}if(this._uMaterialSpecular){gl.uniform3fv(this._uMaterialSpecular,materialState.specular);}if(this._uMaterialGlossiness){gl.uniform1f(this._uMaterialGlossiness,materialState.glossiness);}if(this._uMaterialReflectivity){gl.uniform1f(this._uMaterialReflectivity,materialState.reflectivity);}if(this._uMaterialEmissive){gl.uniform3fv(this._uMaterialEmissive,materialState.emissive);}if(this._uAlphaModeCutoff){gl.uniform4f(this._uAlphaModeCutoff,1.0*materialState.alpha,materialState.alphaMode===1?1.0:0.0,materialState.alphaCutoff,0.0);}var diffuseMap=material._diffuseMap;if(diffuseMap&&diffuseMap._state.texture&&this._uDiffuseMap){program.bindTexture(this._uDiffuseMap,diffuseMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uDiffuseMapMatrix){gl.uniformMatrix4fv(this._uDiffuseMapMatrix,false,diffuseMap._state.matrix);}}var specularMap=material._specularMap;if(specularMap&&specularMap._state.texture&&this._uSpecularMap){program.bindTexture(this._uSpecularMap,specularMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularMapMatrix){gl.uniformMatrix4fv(this._uSpecularMapMatrix,false,specularMap._state.matrix);}}var glossinessMap=material._glossinessMap;if(glossinessMap&&glossinessMap._state.texture&&this._uGlossinessMap){program.bindTexture(this._uGlossinessMap,glossinessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uGlossinessMapMatrix){gl.uniformMatrix4fv(this._uGlossinessMapMatrix,false,glossinessMap._state.matrix);}}var specularGlossinessMap=material._specularGlossinessMap;if(specularGlossinessMap&&specularGlossinessMap._state.texture&&this._uSpecularGlossinessMap){program.bindTexture(this._uSpecularGlossinessMap,specularGlossinessMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uSpecularGlossinessMapMatrix){gl.uniformMatrix4fv(this._uSpecularGlossinessMapMatrix,false,specularGlossinessMap._state.matrix);}}var emissiveMap=material._emissiveMap;if(emissiveMap&&emissiveMap._state.texture&&this._uEmissiveMap){program.bindTexture(this._uEmissiveMap,emissiveMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uEmissiveMapMatrix){gl.uniformMatrix4fv(this._uEmissiveMapMatrix,false,emissiveMap._state.matrix);}}var occlusionMap=material._occlusionMap;if(occlusionMap&&occlusionMap._state.texture&&this._uOcclusionMap){program.bindTexture(this._uOcclusionMap,occlusionMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uOcclusionMapMatrix){gl.uniformMatrix4fv(this._uOcclusionMapMatrix,false,occlusionMap._state.matrix);}}var alphaMap=material._alphaMap;if(alphaMap&&alphaMap._state.texture&&this._uAlphaMap){program.bindTexture(this._uAlphaMap,alphaMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uAlphaMapMatrix){gl.uniformMatrix4fv(this._uAlphaMapMatrix,false,alphaMap._state.matrix);}}var normalMap=material._normalMap;if(normalMap&&normalMap._state.texture&&this._uNormalMap){program.bindTexture(this._uNormalMap,normalMap._state.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;if(this._uNormalMapMatrix){gl.uniformMatrix4fv(this._uNormalMapMatrix,false,normalMap._state.matrix);}}break;}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uModelNormalMatrix){gl.uniformMatrix4fv(this._uModelNormalMatrix,gl.FALSE,mesh.worldNormalMatrix);}if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}if(this._uColorize){var colorize=meshState.colorize;var lastColorize=this._lastColorize;if(lastColorize[0]!==colorize[0]||lastColorize[1]!==colorize[1]||lastColorize[2]!==colorize[2]||lastColorize[3]!==colorize[3]){gl.uniform4fv(this._uColorize,colorize);lastColorize[0]=colorize[0];lastColorize[1]=colorize[1];lastColorize[2]=colorize[2];lastColorize[3]=colorize[3];}}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
9907
9932
  if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,geometryState.uvDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf);frameCtx.bindArray++;}if(this._aNormal){this._aNormal.bindArrayBuffer(geometryState.normalsBuf);frameCtx.bindArray++;}if(this._aUV){this._aUV.bindArrayBuffer(geometryState.uvBuf);frameCtx.bindArray++;}if(this._aColor){this._aColor.bindArrayBuffer(geometryState.colorsBuf);frameCtx.bindArray++;}if(this._aFlags){this._aFlags.bindArrayBuffer(geometryState.flagsBuf);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}// Draw (indices bound in prev step)
9908
9933
  if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);frameCtx.drawArrays++;}if(background){gl.depthFunc(gl.LESS);}};DrawRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;var material=mesh._material;var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var materialState=mesh._material._state;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uUVDecodeMatrix=program.getLocation("uvDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uModelNormalMatrix=program.getLocation("modelNormalMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uViewNormalMatrix=program.getLocation("viewNormalMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uGammaFactor=program.getLocation("gammaFactor");this._uLightAmbient=[];this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];this._uShadowViewMatrix=[];this._uShadowProjMatrix=[];if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}var lights=lightsState.lights;var light;for(var i=0,len=lights.length;i<len;i++){light=lights[i];switch(light.type){case"ambient":this._uLightAmbient[i]=program.getLocation("lightAmbient");break;case"dir":this._uLightColor[i]=program.getLocation("lightColor"+i);this._uLightPos[i]=null;this._uLightDir[i]=program.getLocation("lightDir"+i);break;case"point":this._uLightColor[i]=program.getLocation("lightColor"+i);this._uLightPos[i]=program.getLocation("lightPos"+i);this._uLightDir[i]=null;this._uLightAttenuation[i]=program.getLocation("lightAttenuation"+i);break;case"spot":this._uLightColor[i]=program.getLocation("lightColor"+i);this._uLightPos[i]=program.getLocation("lightPos"+i);this._uLightDir[i]=program.getLocation("lightDir"+i);this._uLightAttenuation[i]=program.getLocation("lightAttenuation"+i);break;}if(light.castsShadow){this._uShadowViewMatrix[i]=program.getLocation("shadowViewMatrix"+i);this._uShadowProjMatrix[i]=program.getLocation("shadowProjMatrix"+i);}}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}this._uSectionPlanes=[];var sectionPlanes=sectionPlanesState.sectionPlanes;for(var i=0,len=sectionPlanes.length;i<len;i++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+i),pos:program.getLocation("sectionPlanePos"+i),dir:program.getLocation("sectionPlaneDir"+i)});}this._uPointSize=program.getLocation("pointSize");switch(materialState.type){case"LambertMaterial":this._uMaterialColor=program.getLocation("materialColor");this._uMaterialEmissive=program.getLocation("materialEmissive");this._uAlphaModeCutoff=program.getLocation("materialAlphaModeCutoff");break;case"PhongMaterial":this._uMaterialAmbient=program.getLocation("materialAmbient");this._uMaterialDiffuse=program.getLocation("materialDiffuse");this._uMaterialSpecular=program.getLocation("materialSpecular");this._uMaterialEmissive=program.getLocation("materialEmissive");this._uAlphaModeCutoff=program.getLocation("materialAlphaModeCutoff");this._uMaterialShininess=program.getLocation("materialShininess");if(material._ambientMap){this._uMaterialAmbientMap="ambientMap";this._uMaterialAmbientMapMatrix=program.getLocation("ambientMapMatrix");}if(material._diffuseMap){this._uDiffuseMap="diffuseMap";this._uDiffuseMapMatrix=program.getLocation("diffuseMapMatrix");}if(material._specularMap){this._uSpecularMap="specularMap";this._uSpecularMapMatrix=program.getLocation("specularMapMatrix");}if(material._emissiveMap){this._uEmissiveMap="emissiveMap";this._uEmissiveMapMatrix=program.getLocation("emissiveMapMatrix");}if(material._alphaMap){this._uAlphaMap="alphaMap";this._uAlphaMapMatrix=program.getLocation("alphaMapMatrix");}if(material._reflectivityMap){this._uReflectivityMap="reflectivityMap";this._uReflectivityMapMatrix=program.getLocation("reflectivityMapMatrix");}if(material._normalMap){this._uNormalMap="normalMap";this._uNormalMapMatrix=program.getLocation("normalMapMatrix");}if(material._occlusionMap){this._uOcclusionMap="occlusionMap";this._uOcclusionMapMatrix=program.getLocation("occlusionMapMatrix");}if(material._diffuseFresnel){this._uDiffuseFresnelEdgeBias=program.getLocation("diffuseFresnelEdgeBias");this._uDiffuseFresnelCenterBias=program.getLocation("diffuseFresnelCenterBias");this._uDiffuseFresnelEdgeColor=program.getLocation("diffuseFresnelEdgeColor");this._uDiffuseFresnelCenterColor=program.getLocation("diffuseFresnelCenterColor");this._uDiffuseFresnelPower=program.getLocation("diffuseFresnelPower");}if(material._specularFresnel){this._uSpecularFresnelEdgeBias=program.getLocation("specularFresnelEdgeBias");this._uSpecularFresnelCenterBias=program.getLocation("specularFresnelCenterBias");this._uSpecularFresnelEdgeColor=program.getLocation("specularFresnelEdgeColor");this._uSpecularFresnelCenterColor=program.getLocation("specularFresnelCenterColor");this._uSpecularFresnelPower=program.getLocation("specularFresnelPower");}if(material._alphaFresnel){this._uAlphaFresnelEdgeBias=program.getLocation("alphaFresnelEdgeBias");this._uAlphaFresnelCenterBias=program.getLocation("alphaFresnelCenterBias");this._uAlphaFresnelEdgeColor=program.getLocation("alphaFresnelEdgeColor");this._uAlphaFresnelCenterColor=program.getLocation("alphaFresnelCenterColor");this._uAlphaFresnelPower=program.getLocation("alphaFresnelPower");}if(material._reflectivityFresnel){this._uReflectivityFresnelEdgeBias=program.getLocation("reflectivityFresnelEdgeBias");this._uReflectivityFresnelCenterBias=program.getLocation("reflectivityFresnelCenterBias");this._uReflectivityFresnelEdgeColor=program.getLocation("reflectivityFresnelEdgeColor");this._uReflectivityFresnelCenterColor=program.getLocation("reflectivityFresnelCenterColor");this._uReflectivityFresnelPower=program.getLocation("reflectivityFresnelPower");}if(material._emissiveFresnel){this._uEmissiveFresnelEdgeBias=program.getLocation("emissiveFresnelEdgeBias");this._uEmissiveFresnelCenterBias=program.getLocation("emissiveFresnelCenterBias");this._uEmissiveFresnelEdgeColor=program.getLocation("emissiveFresnelEdgeColor");this._uEmissiveFresnelCenterColor=program.getLocation("emissiveFresnelCenterColor");this._uEmissiveFresnelPower=program.getLocation("emissiveFresnelPower");}break;case"MetallicMaterial":this._uBaseColor=program.getLocation("materialBaseColor");this._uMaterialMetallic=program.getLocation("materialMetallic");this._uMaterialRoughness=program.getLocation("materialRoughness");this._uMaterialSpecularF0=program.getLocation("materialSpecularF0");this._uMaterialEmissive=program.getLocation("materialEmissive");this._uAlphaModeCutoff=program.getLocation("materialAlphaModeCutoff");if(material._baseColorMap){this._uBaseColorMap="baseColorMap";this._uBaseColorMapMatrix=program.getLocation("baseColorMapMatrix");}if(material._metallicMap){this._uMetallicMap="metallicMap";this._uMetallicMapMatrix=program.getLocation("metallicMapMatrix");}if(material._roughnessMap){this._uRoughnessMap="roughnessMap";this._uRoughnessMapMatrix=program.getLocation("roughnessMapMatrix");}if(material._metallicRoughnessMap){this._uMetallicRoughnessMap="metallicRoughnessMap";this._uMetallicRoughnessMapMatrix=program.getLocation("metallicRoughnessMapMatrix");}if(material._emissiveMap){this._uEmissiveMap="emissiveMap";this._uEmissiveMapMatrix=program.getLocation("emissiveMapMatrix");}if(material._occlusionMap){this._uOcclusionMap="occlusionMap";this._uOcclusionMapMatrix=program.getLocation("occlusionMapMatrix");}if(material._alphaMap){this._uAlphaMap="alphaMap";this._uAlphaMapMatrix=program.getLocation("alphaMapMatrix");}if(material._normalMap){this._uNormalMap="normalMap";this._uNormalMapMatrix=program.getLocation("normalMapMatrix");}break;case"SpecularMaterial":this._uMaterialDiffuse=program.getLocation("materialDiffuse");this._uMaterialSpecular=program.getLocation("materialSpecular");this._uMaterialGlossiness=program.getLocation("materialGlossiness");this._uMaterialReflectivity=program.getLocation("reflectivityFresnel");this._uMaterialEmissive=program.getLocation("materialEmissive");this._uAlphaModeCutoff=program.getLocation("materialAlphaModeCutoff");if(material._diffuseMap){this._uDiffuseMap="diffuseMap";this._uDiffuseMapMatrix=program.getLocation("diffuseMapMatrix");}if(material._specularMap){this._uSpecularMap="specularMap";this._uSpecularMapMatrix=program.getLocation("specularMapMatrix");}if(material._glossinessMap){this._uGlossinessMap="glossinessMap";this._uGlossinessMapMatrix=program.getLocation("glossinessMapMatrix");}if(material._specularGlossinessMap){this._uSpecularGlossinessMap="materialSpecularGlossinessMap";this._uSpecularGlossinessMapMatrix=program.getLocation("materialSpecularGlossinessMapMatrix");}if(material._emissiveMap){this._uEmissiveMap="emissiveMap";this._uEmissiveMapMatrix=program.getLocation("emissiveMapMatrix");}if(material._occlusionMap){this._uOcclusionMap="occlusionMap";this._uOcclusionMapMatrix=program.getLocation("occlusionMapMatrix");}if(material._alphaMap){this._uAlphaMap="alphaMap";this._uAlphaMapMatrix=program.getLocation("alphaMapMatrix");}if(material._normalMap){this._uNormalMap="normalMap";this._uNormalMapMatrix=program.getLocation("normalMapMatrix");}break;}this._aPosition=program.getAttribute("position");this._aNormal=program.getAttribute("normal");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aFlags=program.getAttribute("flags");this._uClippable=program.getLocation("clippable");this._uColorize=program.getLocation("colorize");this._uOffset=program.getLocation("offset");this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;this._lastColorize=new Float32Array(4);this._baseTextureUnit=0;};DrawRenderer.prototype._bindProgram=function(frameCtx){var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_UNITS;var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;var project=scene.camera.project;var light;var program=this._program;program.bind();frameCtx.useProgram++;frameCtx.textureUnit=0;this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;this._lastColorize[0]=-1;this._lastColorize[1]=-1;this._lastColorize[2]=-1;this._lastColorize[3]=-1;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}for(var i=0,len=lightsState.lights.length;i<len;i++){light=lightsState.lights[i];if(this._uLightAmbient[i]){gl.uniform4f(this._uLightAmbient[i],light.color[0],light.color[1],light.color[2],light.intensity);}else{if(this._uLightColor[i]){gl.uniform4f(this._uLightColor[i],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[i]){gl.uniform3fv(this._uLightPos[i],light.pos);if(this._uLightAttenuation[i]){gl.uniform1f(this._uLightAttenuation[i],light.attenuation);}}if(this._uLightDir[i]){gl.uniform3fv(this._uLightDir[i],light.dir);}if(light.castsShadow){if(this._uShadowViewMatrix[i]){gl.uniformMatrix4fv(this._uShadowViewMatrix[i],false,light.getShadowViewMatrix());}if(this._uShadowProjMatrix[i]){gl.uniformMatrix4fv(this._uShadowProjMatrix[i],false,light.getShadowProjMatrix());}var shadowRenderBuf=light.getShadowRenderBuf();if(shadowRenderBuf){program.bindTexture("shadowMap"+i,shadowRenderBuf.getTexture(),frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}}}}if(lightsState.lightMaps.length>0&&lightsState.lightMaps[0].texture&&this._uLightMap){program.bindTexture(this._uLightMap,lightsState.lightMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(lightsState.reflectionMaps.length>0&&lightsState.reflectionMaps[0].texture&&this._uReflectionMap){program.bindTexture(this._uReflectionMap,lightsState.reflectionMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}this._baseTextureUnit=frameCtx.textureUnit;};/**
9909
9934
  * @private
9910
9935
  */var EmphasisFillShaderSource=/*#__PURE__*/_createClass(function EmphasisFillShaderSource(mesh){_classCallCheck(this,EmphasisFillShaderSource);this.vertex=buildVertex$5(mesh);this.fragment=buildFragment$5(mesh);});function buildVertex$5(mesh){var scene=mesh.scene;var lightsState=scene._lightsState;var normals=hasNormals(mesh);var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push("#version 300 es");src.push("// EmphasisFillShaderSource vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec4 colorize;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}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("uniform vec4 lightAmbient;");src.push("uniform vec4 fillColor;");if(normals){src.push("in vec3 normal;");src.push("uniform mat4 modelNormalMatrix;");src.push("uniform mat4 viewNormalMatrix;");for(var _i105=0,len=lightsState.lights.length;_i105<len;_i105++){var light=lightsState.lights[_i105];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i105+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i105+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i105+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i105+";");}}if(quantizedGeometry){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("}");}}src.push("out vec4 vColor;");if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}if(normals){if(quantizedGeometry){src.push("vec4 localNormal = vec4(octDecode(normal.xy), 0.0); ");}else{src.push("vec4 localNormal = vec4(normal, 0.0); ");}src.push("mat4 modelNormalMatrix2 = modelNormalMatrix;");src.push("mat4 viewNormalMatrix2 = viewNormalMatrix;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");if(normals){src.push("mat4 modelViewNormalMatrix = viewNormalMatrix2 * modelNormalMatrix2;");src.push("billboard(modelNormalMatrix2);");src.push("billboard(viewNormalMatrix2);");src.push("billboard(modelViewNormalMatrix);");}src.push("worldPosition = modelMatrix2 * localPosition;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}if(normals){src.push("vec3 viewNormal = normalize((viewNormalMatrix2 * modelNormalMatrix2 * localNormal).xyz);");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");if(normals){for(var _i106=0,_len15=lightsState.lights.length;_i106<_len15;_i106++){var _light3=lightsState.lights[_i106];if(_light3.type==="ambient"){continue;}if(_light3.type==="dir"){if(_light3.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i106+");");}else{src.push("viewLightDir = normalize((viewMatrix2 * vec4(lightDir"+_i106+", 0.0)).xyz);");}}else if(_light3.type==="point"){if(_light3.space==="view"){src.push("viewLightDir = normalize(lightPos"+_i106+" - viewPosition.xyz);");}else{src.push("viewLightDir = normalize((viewMatrix2 * vec4(lightPos"+_i106+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i106+".rgb * lightColor"+_i106+".a);");}}// TODO: A blending mode for emphasis materials, to select add/multiply/mix
9911
9936
  //src.push("vColor = vec4((mix(reflectedColor, fillColor.rgb, 0.7)), fillColor.a);");
9912
9937
  src.push("vColor = vec4(reflectedColor * fillColor.rgb, fillColor.a);");//src.push("vColor = vec4(reflectedColor + fillColor.rgb, fillColor.a);");
9913
- if(clipping){src.push("vWorldPosition = worldPosition;");}if(mesh._geometry._state.primitiveName==="points"){src.push("gl_PointSize = pointSize;");}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("}");return src;}function hasNormals(mesh){var primitive=mesh._geometry._state.primitiveName;if((mesh._geometry._state.autoVertexNormals||mesh._geometry._state.normalsBuf)&&(primitive==="triangles"||primitive==="triangle-strip"||primitive==="triangle-fan")){return true;}return false;}function buildFragment$5(mesh){var scene=mesh.scene;var sectionPlanesState=mesh.scene._sectionPlanesState;var gammaOutput=mesh.scene.gammaOutput;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Lambertian drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(gammaOutput){src.push("uniform float gammaFactor;");src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");for(var _i107=0,len=sectionPlanesState.sectionPlanes.length;_i107<len;_i107++){src.push("uniform bool sectionPlaneActive"+_i107+";");src.push("uniform vec3 sectionPlanePos"+_i107+";");src.push("uniform vec3 sectionPlaneDir"+_i107+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i108=0,_len16=sectionPlanesState.sectionPlanes.length;_i108<_len16;_i108++){src.push("if (sectionPlaneActive"+_i108+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i108+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i108+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(mesh._geometry._state.primitiveName==="points"){src.push("vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push("float r = dot(cxy, cxy);");src.push("if (r > 1.0) {");src.push(" discard;");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}if(gammaOutput){src.push("outColor = linearToGamma(vColor, gammaFactor);");}else{src.push("outColor = vColor;");}src.push("}");return src;}/**
9938
+ if(clipping){src.push("vWorldPosition = worldPosition;");}if(mesh._geometry._state.primitiveName==="points"){src.push("gl_PointSize = pointSize;");}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("}");return src;}function hasNormals(mesh){var primitive=mesh._geometry._state.primitiveName;if((mesh._geometry._state.autoVertexNormals||mesh._geometry._state.normalsBuf)&&(primitive==="triangles"||primitive==="triangle-strip"||primitive==="triangle-fan")){return true;}return false;}function buildFragment$5(mesh){var scene=mesh.scene;var sectionPlanesState=mesh.scene._sectionPlanesState;var gammaOutput=mesh.scene.gammaOutput;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Lambertian drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(gammaOutput){src.push("uniform float gammaFactor;");src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");for(var _i107=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i107<len;_i107++){src.push("uniform bool sectionPlaneActive"+_i107+";");src.push("uniform vec3 sectionPlanePos"+_i107+";");src.push("uniform vec3 sectionPlaneDir"+_i107+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i108=0,_len16=sectionPlanesState.getNumAllocatedSectionPlanes();_i108<_len16;_i108++){src.push("if (sectionPlaneActive"+_i108+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i108+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i108+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(mesh._geometry._state.primitiveName==="points"){src.push("vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push("float r = dot(cxy, cxy);");src.push("if (r > 1.0) {");src.push(" discard;");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}if(gammaOutput){src.push("outColor = linearToGamma(vColor, gammaFactor);");}else{src.push("outColor = vColor;");}src.push("}");return src;}/**
9914
9939
  * @author xeolabs / https://github.com/xeolabs
9915
9940
  */var ids$1=new Map$1({});var tempVec3a$z=math.vec3();/**
9916
9941
  * @private
9917
9942
  */var EmphasisFillRenderer=function EmphasisFillRenderer(hash,mesh){this.id=ids$1.addItem({});this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new EmphasisFillShaderSource(mesh);this._allocate(mesh);};var xrayFillRenderers={};EmphasisFillRenderer.get=function(mesh){var hash=[mesh.scene.id,mesh.scene.gammaOutput?"go":"",// Gamma input not needed
9918
- mesh.scene._sectionPlanesState.getHash(),!!mesh._geometry._state.normalsBuf?"n":"",mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=xrayFillRenderers[hash];if(!renderer){renderer=new EmphasisFillRenderer(hash,mesh);xrayFillRenderers[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};EmphasisFillRenderer.prototype.put=function(){if(--this._useCount===0){ids$1.removeItem(this.id);if(this._program){this._program.destroy();}delete xrayFillRenderers[this._hash];stats.memory.programs--;}};EmphasisFillRenderer.prototype.webglContextRestored=function(){this._program=null;};EmphasisFillRenderer.prototype.drawMesh=function(frameCtx,mesh,mode){if(!this._program){this._allocate(mesh);}var scene=this._scene;var camera=scene.camera;var gl=scene.canvas.gl;var materialState=mode===0?mesh._xrayMaterial._state:mode===1?mesh._highlightMaterial._state:mesh._selectedMaterial._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);if(meshState.clippable){var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];gl.uniform3fv(sectionPlaneUniforms.pos,origin?getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$z):sectionPlane.pos);gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}}if(materialState.id!==this._lastMaterialId){var fillColor=materialState.fillColor;var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}gl.uniform4f(this._uFillColor,fillColor[0],fillColor[1],fillColor[2],materialState.fillAlpha);this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uModelNormalMatrix){gl.uniformMatrix4fv(this._uModelNormalMatrix,gl.FALSE,mesh.worldNormalMatrix);}if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
9943
+ mesh.scene._sectionPlanesState.getHash(),!!mesh._geometry._state.normalsBuf?"n":"",mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=xrayFillRenderers[hash];if(!renderer){renderer=new EmphasisFillRenderer(hash,mesh);xrayFillRenderers[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};EmphasisFillRenderer.prototype.put=function(){if(--this._useCount===0){ids$1.removeItem(this.id);if(this._program){this._program.destroy();}delete xrayFillRenderers[this._hash];stats.memory.programs--;}};EmphasisFillRenderer.prototype.webglContextRestored=function(){this._program=null;};EmphasisFillRenderer.prototype.drawMesh=function(frameCtx,mesh,mode){if(!this._program){this._allocate(mesh);}var scene=this._scene;var camera=scene.camera;var gl=scene.canvas.gl;var materialState=mode===0?mesh._xrayMaterial._state:mode===1?mesh._highlightMaterial._state:mesh._selectedMaterial._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$z);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}if(materialState.id!==this._lastMaterialId){var fillColor=materialState.fillColor;var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}gl.uniform4f(this._uFillColor,fillColor[0],fillColor[1],fillColor[2],materialState.fillAlpha);this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uModelNormalMatrix){gl.uniformMatrix4fv(this._uModelNormalMatrix,gl.FALSE,mesh.worldNormalMatrix);}if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
9919
9944
  if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,geometryState.uvDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf);frameCtx.bindArray++;}if(this._aNormal){this._aNormal.bindArrayBuffer(geometryState.normalsBuf);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;// gl.drawElements(geometryState.primitive, geometryState.indicesBuf.numItems, geometryState.indicesBuf.itemType, 0);
9920
9945
  // frameCtx.drawElements++;
9921
- }else if(geometryState.positionsBuf);this._lastGeometryId=geometryState.id;}if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positionsBuf){gl.drawArrays(gl.TRIANGLES,0,geometryState.positionsBuf.numItems);frameCtx.drawArrays++;}};EmphasisFillRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uModelNormalMatrix=program.getLocation("modelNormalMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uViewNormalMatrix=program.getLocation("viewNormalMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uLightAmbient=[];this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];for(var _i109=0,len=lightsState.lights.length;_i109<len;_i109++){var light=lightsState.lights[_i109];switch(light.type){case"ambient":this._uLightAmbient[_i109]=program.getLocation("lightAmbient");break;case"dir":this._uLightColor[_i109]=program.getLocation("lightColor"+_i109);this._uLightPos[_i109]=null;this._uLightDir[_i109]=program.getLocation("lightDir"+_i109);break;case"point":this._uLightColor[_i109]=program.getLocation("lightColor"+_i109);this._uLightPos[_i109]=program.getLocation("lightPos"+_i109);this._uLightDir[_i109]=null;this._uLightAttenuation[_i109]=program.getLocation("lightAttenuation"+_i109);break;}}this._uSectionPlanes=[];for(var _i110=0,_len17=sectionPlanesState.sectionPlanes.length;_i110<_len17;_i110++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i110),pos:program.getLocation("sectionPlanePos"+_i110),dir:program.getLocation("sectionPlaneDir"+_i110)});}this._uFillColor=program.getLocation("fillColor");this._aPosition=program.getAttribute("position");this._aNormal=program.getAttribute("normal");this._uClippable=program.getLocation("clippable");this._uGammaFactor=program.getLocation("gammaFactor");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};EmphasisFillRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;var camera=scene.camera;var project=camera.project;var program=this._program;program.bind();frameCtx.useProgram++;frameCtx.textureUnit=0;this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;this._lastIndicesBufId=null;gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.normalMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}for(var _i111=0,len=lightsState.lights.length;_i111<len;_i111++){var light=lightsState.lights[_i111];if(this._uLightAmbient[_i111]){gl.uniform4f(this._uLightAmbient[_i111],light.color[0],light.color[1],light.color[2],light.intensity);}else{if(this._uLightColor[_i111]){gl.uniform4f(this._uLightColor[_i111],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i111]){gl.uniform3fv(this._uLightPos[_i111],light.pos);if(this._uLightAttenuation[_i111]){gl.uniform1f(this._uLightAttenuation[_i111],light.attenuation);}}if(this._uLightDir[_i111]){gl.uniform3fv(this._uLightDir[_i111],light.dir);}}}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}};/**
9946
+ }else if(geometryState.positionsBuf);this._lastGeometryId=geometryState.id;}if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positionsBuf){gl.drawArrays(gl.TRIANGLES,0,geometryState.positionsBuf.numItems);frameCtx.drawArrays++;}};EmphasisFillRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uModelNormalMatrix=program.getLocation("modelNormalMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uViewNormalMatrix=program.getLocation("viewNormalMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uLightAmbient=[];this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];for(var _i109=0,len=lightsState.lights.length;_i109<len;_i109++){var light=lightsState.lights[_i109];switch(light.type){case"ambient":this._uLightAmbient[_i109]=program.getLocation("lightAmbient");break;case"dir":this._uLightColor[_i109]=program.getLocation("lightColor"+_i109);this._uLightPos[_i109]=null;this._uLightDir[_i109]=program.getLocation("lightDir"+_i109);break;case"point":this._uLightColor[_i109]=program.getLocation("lightColor"+_i109);this._uLightPos[_i109]=program.getLocation("lightPos"+_i109);this._uLightDir[_i109]=null;this._uLightAttenuation[_i109]=program.getLocation("lightAttenuation"+_i109);break;}}this._uSectionPlanes=[];for(var _i110=0,_len17=sectionPlanesState.getNumAllocatedSectionPlanes();_i110<_len17;_i110++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i110),pos:program.getLocation("sectionPlanePos"+_i110),dir:program.getLocation("sectionPlaneDir"+_i110)});}this._uFillColor=program.getLocation("fillColor");this._aPosition=program.getAttribute("position");this._aNormal=program.getAttribute("normal");this._uClippable=program.getLocation("clippable");this._uGammaFactor=program.getLocation("gammaFactor");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};EmphasisFillRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;var camera=scene.camera;var project=camera.project;var program=this._program;program.bind();frameCtx.useProgram++;frameCtx.textureUnit=0;this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;this._lastIndicesBufId=null;gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.normalMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}for(var _i111=0,len=lightsState.lights.length;_i111<len;_i111++){var light=lightsState.lights[_i111];if(this._uLightAmbient[_i111]){gl.uniform4f(this._uLightAmbient[_i111],light.color[0],light.color[1],light.color[2],light.intensity);}else{if(this._uLightColor[_i111]){gl.uniform4f(this._uLightColor[_i111],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i111]){gl.uniform3fv(this._uLightPos[_i111],light.pos);if(this._uLightAttenuation[_i111]){gl.uniform1f(this._uLightAttenuation[_i111],light.attenuation);}}if(this._uLightDir[_i111]){gl.uniform3fv(this._uLightDir[_i111],light.dir);}}}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}};/**
9922
9947
  * @private
9923
- */var EmphasisEdgesShaderSource=/*#__PURE__*/_createClass(function EmphasisEdgesShaderSource(mesh){_classCallCheck(this,EmphasisEdgesShaderSource);this.vertex=buildVertex$4(mesh);this.fragment=buildFragment$4(mesh);});function buildVertex$4(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push("#version 300 es");src.push("// Edges drawing vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec4 edgeColor;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}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("out vec4 vColor;");if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}src.push("vColor = edgeColor;");if(clipping){src.push("vWorldPosition = worldPosition;");}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("}");return src;}function buildFragment$4(mesh){var scene=mesh.scene;var sectionPlanesState=mesh.scene._sectionPlanesState;var gammaOutput=mesh.scene.gammaOutput;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Edges drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(gammaOutput){src.push("uniform float gammaFactor;");src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");for(var _i112=0,len=sectionPlanesState.sectionPlanes.length;_i112<len;_i112++){src.push("uniform bool sectionPlaneActive"+_i112+";");src.push("uniform vec3 sectionPlanePos"+_i112+";");src.push("uniform vec3 sectionPlaneDir"+_i112+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i113=0,_len18=sectionPlanesState.sectionPlanes.length;_i113<_len18;_i113++){src.push("if (sectionPlaneActive"+_i113+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i113+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i113+".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;");}if(gammaOutput){src.push("outColor = linearToGamma(vColor, gammaFactor);");}else{src.push("outColor = vColor;");}src.push("}");return src;}/**
9948
+ */var EmphasisEdgesShaderSource=/*#__PURE__*/_createClass(function EmphasisEdgesShaderSource(mesh){_classCallCheck(this,EmphasisEdgesShaderSource);this.vertex=buildVertex$4(mesh);this.fragment=buildFragment$4(mesh);});function buildVertex$4(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push("#version 300 es");src.push("// Edges drawing vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec4 edgeColor;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}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("out vec4 vColor;");if(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}src.push("vColor = edgeColor;");if(clipping){src.push("vWorldPosition = worldPosition;");}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("}");return src;}function buildFragment$4(mesh){var scene=mesh.scene;var sectionPlanesState=mesh.scene._sectionPlanesState;var gammaOutput=mesh.scene.gammaOutput;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Edges drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(gammaOutput){src.push("uniform float gammaFactor;");src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("uniform bool clippable;");for(var _i112=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i112<len;_i112++){src.push("uniform bool sectionPlaneActive"+_i112+";");src.push("uniform vec3 sectionPlanePos"+_i112+";");src.push("uniform vec3 sectionPlaneDir"+_i112+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i113=0,_len18=sectionPlanesState.getNumAllocatedSectionPlanes();_i113<_len18;_i113++){src.push("if (sectionPlaneActive"+_i113+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i113+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i113+".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;");}if(gammaOutput){src.push("outColor = linearToGamma(vColor, gammaFactor);");}else{src.push("outColor = vColor;");}src.push("}");return src;}/**
9924
9949
  * @author xeolabs / https://github.com/xeolabs
9925
9950
  */var ids=new Map$1({});var tempVec3a$y=math.vec3();/**
9926
9951
  * @private
9927
9952
  */var EmphasisEdgesRenderer=function EmphasisEdgesRenderer(hash,mesh){this.id=ids.addItem({});this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new EmphasisEdgesShaderSource(mesh);this._allocate(mesh);};var renderers$4={};EmphasisEdgesRenderer.get=function(mesh){var hash=[mesh.scene.id,mesh.scene.gammaOutput?"go":"",// Gamma input not needed
9928
- mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=renderers$4[hash];if(!renderer){renderer=new EmphasisEdgesRenderer(hash,mesh);renderers$4[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};EmphasisEdgesRenderer.prototype.put=function(){if(--this._useCount===0){ids.removeItem(this.id);if(this._program){this._program.destroy();}delete renderers$4[this._hash];stats.memory.programs--;}};EmphasisEdgesRenderer.prototype.webglContextRestored=function(){this._program=null;};EmphasisEdgesRenderer.prototype.drawMesh=function(frameCtx,mesh,mode){if(!this._program){this._allocate(mesh);}var scene=this._scene;var camera=scene.camera;var gl=scene.canvas.gl;var materialState;var meshState=mesh._state;var geometry=mesh._geometry;var geometryState=geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];gl.uniform3fv(sectionPlaneUniforms.pos,origin?getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$y):sectionPlane.pos);gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}}switch(mode){case 0:materialState=mesh._xrayMaterial._state;break;case 1:materialState=mesh._highlightMaterial._state;break;case 2:materialState=mesh._selectedMaterial._state;break;case 3:default:materialState=mesh._edgeMaterial._state;break;}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}if(frameCtx.lineWidth!==materialState.edgeWidth){gl.lineWidth(materialState.edgeWidth);frameCtx.lineWidth=materialState.edgeWidth;}if(this._uEdgeColor){var edgeColor=materialState.edgeColor;var edgeAlpha=materialState.edgeAlpha;gl.uniform4f(this._uEdgeColor,edgeColor[0],edgeColor[1],edgeColor[2],edgeAlpha);}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
9929
- var indicesBuf;if(geometryState.primitive===gl.TRIANGLES){indicesBuf=geometry._getEdgeIndices();}else if(geometryState.primitive===gl.LINES){indicesBuf=geometryState.indicesBuf;}if(indicesBuf){if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}indicesBuf.bind();frameCtx.bindArray++;this._lastGeometryId=geometryState.id;}gl.drawElements(gl.LINES,indicesBuf.numItems,indicesBuf.itemType,0);frameCtx.drawElements++;}};EmphasisEdgesRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i114=0,len=sectionPlanesState.sectionPlanes.length;_i114<len;_i114++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i114),pos:program.getLocation("sectionPlanePos"+_i114),dir:program.getLocation("sectionPlaneDir"+_i114)});}this._uEdgeColor=program.getLocation("edgeColor");this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uGammaFactor=program.getLocation("gammaFactor");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};EmphasisEdgesRenderer.prototype._bindProgram=function(frameCtx){var program=this._program;var scene=this._scene;var gl=scene.canvas.gl;var camera=scene.camera;var project=camera.project;program.bind();frameCtx.useProgram++;this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}};/**
9953
+ mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=renderers$4[hash];if(!renderer){renderer=new EmphasisEdgesRenderer(hash,mesh);renderers$4[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};EmphasisEdgesRenderer.prototype.put=function(){if(--this._useCount===0){ids.removeItem(this.id);if(this._program){this._program.destroy();}delete renderers$4[this._hash];stats.memory.programs--;}};EmphasisEdgesRenderer.prototype.webglContextRestored=function(){this._program=null;};EmphasisEdgesRenderer.prototype.drawMesh=function(frameCtx,mesh,mode){if(!this._program){this._allocate(mesh);}var scene=this._scene;var camera=scene.camera;var gl=scene.canvas.gl;var materialState;var meshState=mesh._state;var geometry=mesh._geometry;var geometryState=geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$y);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}switch(mode){case 0:materialState=mesh._xrayMaterial._state;break;case 1:materialState=mesh._highlightMaterial._state;break;case 2:materialState=mesh._selectedMaterial._state;break;case 3:default:materialState=mesh._edgeMaterial._state;break;}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}if(frameCtx.lineWidth!==materialState.edgeWidth){gl.lineWidth(materialState.edgeWidth);frameCtx.lineWidth=materialState.edgeWidth;}if(this._uEdgeColor){var edgeColor=materialState.edgeColor;var edgeAlpha=materialState.edgeAlpha;gl.uniform4f(this._uEdgeColor,edgeColor[0],edgeColor[1],edgeColor[2],edgeAlpha);}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,meshState.clippable);}gl.uniform3fv(this._uOffset,meshState.offset);// Bind VBOs
9954
+ var indicesBuf;if(geometryState.primitive===gl.TRIANGLES){indicesBuf=geometry._getEdgeIndices();}else if(geometryState.primitive===gl.LINES){indicesBuf=geometryState.indicesBuf;}if(indicesBuf){if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}indicesBuf.bind();frameCtx.bindArray++;this._lastGeometryId=geometryState.id;}gl.drawElements(gl.LINES,indicesBuf.numItems,indicesBuf.itemType,0);frameCtx.drawElements++;}};EmphasisEdgesRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i114=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i114<len;_i114++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i114),pos:program.getLocation("sectionPlanePos"+_i114),dir:program.getLocation("sectionPlaneDir"+_i114)});}this._uEdgeColor=program.getLocation("edgeColor");this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uGammaFactor=program.getLocation("gammaFactor");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};EmphasisEdgesRenderer.prototype._bindProgram=function(frameCtx){var program=this._program;var scene=this._scene;var gl=scene.canvas.gl;var camera=scene.camera;var project=camera.project;program.bind();frameCtx.useProgram++;this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}};/**
9930
9955
  * @author xeolabs / https://github.com/xeolabs
9931
9956
  */ /**
9932
9957
  * @private
9933
- */var PickMeshShaderSource=/*#__PURE__*/_createClass(function PickMeshShaderSource(mesh){_classCallCheck(this,PickMeshShaderSource);this.vertex=buildVertex$3(mesh);this.fragment=buildFragment$3(mesh);});function buildVertex$3(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push('#version 300 es');src.push("// Mesh picking vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("out vec4 vViewPosition;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}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(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("uniform vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy -= pickClipPos;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");}src.push(" vec4 worldPosition = modelMatrix2 * localPosition;");src.push(" worldPosition.xyz = worldPosition.xyz + offset;");src.push(" vec4 viewPosition = viewMatrix2 * worldPosition;");if(clipping){src.push(" vWorldPosition = worldPosition;");}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 = remapClipPos(clipPos);");src.push("}");return src;}function buildFragment$3(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Mesh picking 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 vec4 pickColor;");if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");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("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.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(" outColor = pickColor; ");src.push("}");return src;}/**
9958
+ */var PickMeshShaderSource=/*#__PURE__*/_createClass(function PickMeshShaderSource(mesh){_classCallCheck(this,PickMeshShaderSource);this.vertex=buildVertex$3(mesh);this.fragment=buildFragment$3(mesh);});function buildVertex$3(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push('#version 300 es');src.push("// Mesh picking vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("out vec4 vViewPosition;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}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(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("uniform vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy -= pickClipPos;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");}src.push(" vec4 worldPosition = modelMatrix2 * localPosition;");src.push(" worldPosition.xyz = worldPosition.xyz + offset;");src.push(" vec4 viewPosition = viewMatrix2 * worldPosition;");if(clipping){src.push(" vWorldPosition = worldPosition;");}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 = remapClipPos(clipPos);");src.push("}");return src;}function buildFragment$3(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Mesh picking 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 vec4 pickColor;");if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = pickColor; ");src.push("}");return src;}/**
9934
9959
  * @author xeolabs / https://github.com/xeolabs
9935
9960
  */var tempVec3a$x=math.vec3();// No ID, because there is exactly one PickMeshRenderer per scene
9936
9961
  /**
9937
9962
  * @private
9938
- */var PickMeshRenderer=function PickMeshRenderer(hash,mesh){this._hash=hash;this._shaderSource=new PickMeshShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$3={};PickMeshRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.hash].join(";");var renderer=renderers$3[hash];if(!renderer){renderer=new PickMeshRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$3[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};PickMeshRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$3[this._hash];stats.memory.programs--;}};PickMeshRenderer.prototype.webglContextRestored=function(){this._program=null;};PickMeshRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var meshState=mesh._state;var materialState=mesh._material._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCPickViewMatrix(meshState.originHash,origin):frameCtx.pickViewMatrix);if(meshState.clippable){var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];gl.uniform3fv(sectionPlaneUniforms.pos,origin?getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$x):sectionPlane.pos);gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uProjMatrix,false,frameCtx.pickProjMatrix);gl.uniformMatrix4fv(this._uModelMatrix,false,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}// Mesh-indexed color
9963
+ */var PickMeshRenderer=function PickMeshRenderer(hash,mesh){this._hash=hash;this._shaderSource=new PickMeshShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$3={};PickMeshRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.hash].join(";");var renderer=renderers$3[hash];if(!renderer){renderer=new PickMeshRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$3[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};PickMeshRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$3[this._hash];stats.memory.programs--;}};PickMeshRenderer.prototype.webglContextRestored=function(){this._program=null;};PickMeshRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var meshState=mesh._state;var materialState=mesh._material._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCPickViewMatrix(meshState.originHash,origin):frameCtx.pickViewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$x);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uProjMatrix,false,frameCtx.pickProjMatrix);gl.uniformMatrix4fv(this._uModelMatrix,false,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}// Mesh-indexed color
9939
9964
  var pickID=mesh._state.pickID;var a=pickID>>24&0xFF;var b=pickID>>16&0xFF;var g=pickID>>8&0xFF;var r=pickID&0xFF;gl.uniform4f(this._uPickColor,r/255,g/255,b/255,a/255);gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);}};PickMeshRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var clips=scene._sectionPlanesState.sectionPlanes;for(var _i115=0,len=clips.length;_i115<len;_i115++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i115),pos:program.getLocation("sectionPlanePos"+_i115),dir:program.getLocation("sectionPlaneDir"+_i115)});}this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uPickColor=program.getLocation("pickColor");this._uPickClipPos=program.getLocation("pickClipPos");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastGeometryId=null;};PickMeshRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var project=scene.camera.project;this._program.bind();frameCtx.useProgram++;if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this._lastMaterialId=null;this._lastGeometryId=null;};/**
9940
9965
  * @private
9941
- */var PickTriangleShaderSource=/*#__PURE__*/_createClass(function PickTriangleShaderSource(mesh){_classCallCheck(this,PickTriangleShaderSource);this.vertex=buildVertex$2(mesh);this.fragment=buildFragment$2(mesh);});function buildVertex$2(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var src=[];src.push('#version 300 es');src.push("// Surface picking vertex shader");src.push("in vec3 position;");src.push("in vec4 color;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec3 offset;");if(clipping){src.push("uniform bool clippable;");src.push("out vec4 vWorldPosition;");}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 vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy -= pickClipPos;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("out vec4 vColor;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push(" vec4 worldPosition = modelMatrix * localPosition; ");src.push(" worldPosition.xyz = worldPosition.xyz + offset;");src.push(" vec4 viewPosition = viewMatrix * worldPosition;");if(clipping){src.push(" vWorldPosition = worldPosition;");}src.push(" vColor = color;");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 = remapClipPos(clipPos);");src.push("}");return src;}function buildFragment$2(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Surface picking 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 vec4 vColor;");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var _i116=0;_i116<sectionPlanesState.sectionPlanes.length;_i116++){src.push("uniform bool sectionPlaneActive"+_i116+";");src.push("uniform vec3 sectionPlanePos"+_i116+";");src.push("uniform vec3 sectionPlaneDir"+_i116+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i117=0;_i117<sectionPlanesState.sectionPlanes.length;_i117++){src.push("if (sectionPlaneActive"+_i117+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i117+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i117+".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;}/**
9966
+ */var PickTriangleShaderSource=/*#__PURE__*/_createClass(function PickTriangleShaderSource(mesh){_classCallCheck(this,PickTriangleShaderSource);this.vertex=buildVertex$2(mesh);this.fragment=buildFragment$2(mesh);});function buildVertex$2(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var src=[];src.push('#version 300 es');src.push("// Surface picking vertex shader");src.push("in vec3 position;");src.push("in vec4 color;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec3 offset;");if(clipping){src.push("uniform bool clippable;");src.push("out vec4 vWorldPosition;");}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 vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy -= pickClipPos;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("out vec4 vColor;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push(" vec4 worldPosition = modelMatrix * localPosition; ");src.push(" worldPosition.xyz = worldPosition.xyz + offset;");src.push(" vec4 viewPosition = viewMatrix * worldPosition;");if(clipping){src.push(" vWorldPosition = worldPosition;");}src.push(" vColor = color;");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 = remapClipPos(clipPos);");src.push("}");return src;}function buildFragment$2(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Surface picking 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 vec4 vColor;");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var _i116=0;_i116<sectionPlanesState.getNumAllocatedSectionPlanes();_i116++){src.push("uniform bool sectionPlaneActive"+_i116+";");src.push("uniform vec3 sectionPlanePos"+_i116+";");src.push("uniform vec3 sectionPlaneDir"+_i116+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var _i117=0;_i117<sectionPlanesState.getNumAllocatedSectionPlanes();_i117++){src.push("if (sectionPlaneActive"+_i117+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i117+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i117+".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;}/**
9942
9967
  * @author xeolabs / https://github.com/xeolabs
9943
9968
  */var tempVec3a$w=math.vec3();/**
9944
9969
  * @private
9945
- */var PickTriangleRenderer=function PickTriangleRenderer(hash,mesh){this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new PickTriangleShaderSource(mesh);this._allocate(mesh);};var renderers$2={};PickTriangleRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=renderers$2[hash];if(!renderer){renderer=new PickTriangleRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$2[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};PickTriangleRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$2[this._hash];stats.memory.programs--;}};PickTriangleRenderer.prototype.webglContextRestored=function(){this._program=null;};PickTriangleRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var meshState=mesh._state;var materialState=mesh._material._state;var geometry=mesh._geometry;var geometryState=mesh._geometry._state;var origin=mesh.origin;var backfaces=materialState.backfaces;var frontface=materialState.frontface;var project=scene.camera.project;var positionsBuf=geometry._getPickTrianglePositions();var pickColorsBuf=geometry._getPickTriangleColors();this._program.bind();frameCtx.useProgram++;if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCPickViewMatrix(meshState.originHash,origin):frameCtx.pickViewMatrix);if(meshState.clippable){var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];gl.uniform3fv(sectionPlaneUniforms.pos,origin?getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$w):sectionPlane.pos);gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}}gl.uniformMatrix4fv(this._uProjMatrix,false,frameCtx.pickProjMatrix);if(scene.logarithmicDepthBufferEnabled){gl.uniform1f(this._uZFar,scene.camera.project.far);}if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}gl.uniformMatrix4fv(this._uModelMatrix,false,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);this._aPosition.bindArrayBuffer(positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);}else{this._aPosition.bindArrayBuffer(positionsBuf);}gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);pickColorsBuf.bind();gl.enableVertexAttribArray(this._aColor.location);gl.vertexAttribPointer(this._aColor.location,pickColorsBuf.itemSize,pickColorsBuf.itemType,true,0,0);// Normalize
9970
+ */var PickTriangleRenderer=function PickTriangleRenderer(hash,mesh){this._hash=hash;this._scene=mesh.scene;this._useCount=0;this._shaderSource=new PickTriangleShaderSource(mesh);this._allocate(mesh);};var renderers$2={};PickTriangleRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.compressGeometry?"cp":"",mesh._state.hash].join(";");var renderer=renderers$2[hash];if(!renderer){renderer=new PickTriangleRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$2[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};PickTriangleRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$2[this._hash];stats.memory.programs--;}};PickTriangleRenderer.prototype.webglContextRestored=function(){this._program=null;};PickTriangleRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var meshState=mesh._state;var materialState=mesh._material._state;var geometry=mesh._geometry;var geometryState=mesh._geometry._state;var origin=mesh.origin;var backfaces=materialState.backfaces;var frontface=materialState.frontface;var project=scene.camera.project;var positionsBuf=geometry._getPickTrianglePositions();var pickColorsBuf=geometry._getPickTriangleColors();this._program.bind();frameCtx.useProgram++;if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCPickViewMatrix(meshState.originHash,origin):frameCtx.pickViewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$w);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}gl.uniformMatrix4fv(this._uProjMatrix,false,frameCtx.pickProjMatrix);if(scene.logarithmicDepthBufferEnabled){gl.uniform1f(this._uZFar,scene.camera.project.far);}if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}gl.uniformMatrix4fv(this._uModelMatrix,false,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);this._aPosition.bindArrayBuffer(positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);}else{this._aPosition.bindArrayBuffer(positionsBuf);}gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);pickColorsBuf.bind();gl.enableVertexAttribArray(this._aColor.location);gl.vertexAttribPointer(this._aColor.location,pickColorsBuf.itemSize,pickColorsBuf.itemType,true,0,0);// Normalize
9946
9971
  gl.drawArrays(geometryState.primitive,0,positionsBuf.numItems/3);};PickTriangleRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);this._useCount=0;if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var sectionPlanes=scene._sectionPlanesState.sectionPlanes;for(var _i118=0,len=sectionPlanes.length;_i118<len;_i118++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i118),pos:program.getLocation("sectionPlanePos"+_i118),dir:program.getLocation("sectionPlaneDir"+_i118)});}this._aPosition=program.getAttribute("position");this._aColor=program.getAttribute("color");this._uPickClipPos=program.getLocation("pickClipPos");this._uClippable=program.getLocation("clippable");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}};/**
9947
9972
  * @author xeolabs / https://github.com/xeolabs
9948
9973
  */ /**
9949
9974
  * @private
9950
- */var OcclusionShaderSource=/*#__PURE__*/_createClass(function OcclusionShaderSource(mesh){_classCallCheck(this,OcclusionShaderSource);this.vertex=buildVertex$1(mesh);this.fragment=buildFragment$1(mesh);});function buildVertex$1(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push('#version 300 es');src.push("// Mesh occlusion vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}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(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}if(clipping){src.push(" vWorldPosition = worldPosition;");}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("}");return src;}function buildFragment$1(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Mesh occlusion fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");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("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.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(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}/**
9975
+ */var OcclusionShaderSource=/*#__PURE__*/_createClass(function OcclusionShaderSource(mesh){_classCallCheck(this,OcclusionShaderSource);this.vertex=buildVertex$1(mesh);this.fragment=buildFragment$1(mesh);});function buildVertex$1(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var billboard=mesh._state.billboard;var stationary=mesh._state.stationary;var src=[];src.push('#version 300 es');src.push("// Mesh occlusion vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}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(billboard==="spherical"||billboard==="cylindrical"){src.push("void billboard(inout mat4 mat) {");src.push(" mat[0][0] = 1.0;");src.push(" mat[0][1] = 0.0;");src.push(" mat[0][2] = 0.0;");if(billboard==="spherical"){src.push(" mat[1][0] = 0.0;");src.push(" mat[1][1] = 1.0;");src.push(" mat[1][2] = 0.0;");}src.push(" mat[2][0] = 0.0;");src.push(" mat[2][1] = 0.0;");src.push(" mat[2][2] =1.0;");src.push("}");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("mat4 viewMatrix2 = viewMatrix;");src.push("mat4 modelMatrix2 = modelMatrix;");if(stationary){src.push("viewMatrix2[3][0] = viewMatrix2[3][1] = viewMatrix2[3][2] = 0.0;");}if(billboard==="spherical"||billboard==="cylindrical"){src.push("mat4 modelViewMatrix = viewMatrix2 * modelMatrix2;");src.push("billboard(modelMatrix2);");src.push("billboard(viewMatrix2);");src.push("billboard(modelViewMatrix);");src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = modelViewMatrix * localPosition;");}else{src.push("worldPosition = modelMatrix2 * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = viewMatrix2 * worldPosition; ");}if(clipping){src.push(" vWorldPosition = worldPosition;");}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("}");return src;}function buildFragment$1(mesh){var scene=mesh.scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Mesh occlusion fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}/**
9951
9976
  * @author xeolabs / https://github.com/xeolabs
9952
9977
  */var tempVec3a$v=math.vec3();// No ID, because there is exactly one PickMeshRenderer per scene
9953
9978
  /**
9954
9979
  * @private
9955
- */var OcclusionRenderer=function OcclusionRenderer(hash,mesh){this._hash=hash;this._shaderSource=new OcclusionShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$1={};OcclusionRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.occlusionHash].join(";");var renderer=renderers$1[hash];if(!renderer){renderer=new OcclusionRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$1[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};OcclusionRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$1[this._hash];stats.memory.programs--;}};OcclusionRenderer.prototype.webglContextRestored=function(){this._program=null;};OcclusionRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var materialState=mesh._material._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}this._lastMaterialId=materialState.id;}var camera=scene.camera;gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];gl.uniform3fv(sectionPlaneUniforms.pos,origin?getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$v):sectionPlane.pos);gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}}gl.uniformMatrix4fv(this._uProjMatrix,false,camera._project._state.matrix);gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);}};OcclusionRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var clips=scene._sectionPlanesState.sectionPlanes;for(var _i119=0,len=clips.length;_i119<len;_i119++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i119),pos:program.getLocation("sectionPlanePos"+_i119),dir:program.getLocation("sectionPlaneDir"+_i119)});}this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};OcclusionRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var project=scene.camera.project;var gl=scene.canvas.gl;this._program.bind();frameCtx.useProgram++;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};/**
9980
+ */var OcclusionRenderer=function OcclusionRenderer(hash,mesh){this._hash=hash;this._shaderSource=new OcclusionShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers$1={};OcclusionRenderer.get=function(mesh){var hash=[mesh.scene.canvas.canvas.id,mesh.scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.occlusionHash].join(";");var renderer=renderers$1[hash];if(!renderer){renderer=new OcclusionRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers$1[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};OcclusionRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers$1[this._hash];stats.memory.programs--;}};OcclusionRenderer.prototype.webglContextRestored=function(){this._program=null;};OcclusionRenderer.prototype.drawMesh=function(frameCtx,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var materialState=mesh._material._state;var meshState=mesh._state;var geometryState=mesh._geometry._state;var origin=mesh.origin;if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frameCtx.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frameCtx.backfaces=backfaces;}var frontface=materialState.frontface;if(frameCtx.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frameCtx.frontface=frontface;}this._lastMaterialId=materialState.id;}var camera=scene.camera;gl.uniformMatrix4fv(this._uViewMatrix,false,origin?frameCtx.getRTCViewMatrix(meshState.originHash,origin):camera.viewMatrix);if(meshState.clippable){var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var renderFlags=mesh.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$v);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}gl.uniformMatrix4fv(this._uProjMatrix,false,camera._project._state.matrix);gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frameCtx.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frameCtx.bindArray++;}this._lastGeometryId=geometryState.id;}if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frameCtx.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);}};OcclusionRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var clips=scene._sectionPlanesState.sectionPlanes;for(var _i119=0,len=clips.length;_i119<len;_i119++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i119),pos:program.getLocation("sectionPlanePos"+_i119),dir:program.getLocation("sectionPlaneDir"+_i119)});}this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uOffset=program.getLocation("offset");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};OcclusionRenderer.prototype._bindProgram=function(frameCtx){var scene=this._scene;var project=scene.camera.project;var gl=scene.canvas.gl;this._program.bind();frameCtx.useProgram++;gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};/**
9956
9981
  * @private
9957
- */var ShadowShaderSource=/*#__PURE__*/_createClass(function ShadowShaderSource(mesh){_classCallCheck(this,ShadowShaderSource);this.vertex=buildVertex(mesh);this.fragment=buildFragment(mesh);});function buildVertex(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var src=[];src.push("// Mesh shadow vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("worldPosition = modelMatrix * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");}src.push(" gl_Position = shadowProjMatrix * viewPosition;");src.push("}");return src;}function buildFragment(mesh){var scene=mesh.scene;scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("// Mesh shadow fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("vec4 encodeFloat( const in float depth ) {");src.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);");src.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);");src.push(" vec4 comp = fract(depth * bitShift);");src.push(" comp -= comp.xxyz * bitMask;");src.push(" return comp;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.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("outColor = encodeFloat(gl_FragCoord.z);");src.push("}");return src;}/**
9982
+ */var ShadowShaderSource=/*#__PURE__*/_createClass(function ShadowShaderSource(mesh){_classCallCheck(this,ShadowShaderSource);this.vertex=buildVertex(mesh);this.fragment=buildFragment(mesh);});function buildVertex(mesh){var scene=mesh.scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var quantizedGeometry=!!mesh._geometry._state.compressGeometry;var src=[];src.push("// Mesh shadow vertex shader");src.push("in vec3 position;");src.push("uniform mat4 modelMatrix;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");src.push("uniform vec3 offset;");if(quantizedGeometry){src.push("uniform mat4 positionsDecodeMatrix;");}if(clipping){src.push("out vec4 vWorldPosition;");}src.push("void main(void) {");src.push("vec4 localPosition = vec4(position, 1.0); ");src.push("vec4 worldPosition;");if(quantizedGeometry){src.push("localPosition = positionsDecodeMatrix * localPosition;");}src.push("worldPosition = modelMatrix * localPosition;");src.push("worldPosition.xyz = worldPosition.xyz + offset;");src.push("vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");}src.push(" gl_Position = shadowProjMatrix * viewPosition;");src.push("}");return src;}function buildFragment(mesh){var scene=mesh.scene;scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("// Mesh shadow fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("uniform bool clippable;");src.push("in vec4 vWorldPosition;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("vec4 encodeFloat( const in float depth ) {");src.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);");src.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);");src.push(" vec4 comp = fract(depth * bitShift);");src.push(" comp -= comp.xxyz * bitMask;");src.push(" return comp;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push("if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}src.push("outColor = encodeFloat(gl_FragCoord.z);");src.push("}");return src;}/**
9958
9983
  * @private
9959
9984
  */var ShadowRenderer=function ShadowRenderer(hash,mesh){this._hash=hash;this._shaderSource=new ShadowShaderSource(mesh);this._scene=mesh.scene;this._useCount=0;this._allocate(mesh);};var renderers={};ShadowRenderer.get=function(mesh){var scene=mesh.scene;var hash=[scene.canvas.canvas.id,scene._sectionPlanesState.getHash(),mesh._geometry._state.hash,mesh._state.hash].join(";");var renderer=renderers[hash];if(!renderer){renderer=new ShadowRenderer(hash,mesh);if(renderer.errors){console.log(renderer.errors.join("\n"));return null;}renderers[hash]=renderer;stats.memory.programs++;}renderer._useCount++;return renderer;};ShadowRenderer.prototype.put=function(){if(--this._useCount===0){if(this._program){this._program.destroy();}delete renderers[this._hash];stats.memory.programs--;}};ShadowRenderer.prototype.webglContextRestored=function(){this._program=null;};ShadowRenderer.prototype.drawMesh=function(frame,mesh){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var materialState=mesh._material._state;var geometryState=mesh._geometry._state;if(frame.lastProgramId!==this._program.id){frame.lastProgramId=this._program.id;this._bindProgram(frame);}if(materialState.id!==this._lastMaterialId){var backfaces=materialState.backfaces;if(frame.backfaces!==backfaces){if(backfaces){gl.disable(gl.CULL_FACE);}else{gl.enable(gl.CULL_FACE);}frame.backfaces=backfaces;}var frontface=materialState.frontface;if(frame.frontface!==frontface){if(frontface){gl.frontFace(gl.CCW);}else{gl.frontFace(gl.CW);}frame.frontface=frontface;}if(frame.lineWidth!==materialState.lineWidth){gl.lineWidth(materialState.lineWidth);frame.lineWidth=materialState.lineWidth;}if(this._uPointSize){gl.uniform1i(this._uPointSize,materialState.pointSize);}this._lastMaterialId=materialState.id;}gl.uniformMatrix4fv(this._uModelMatrix,gl.FALSE,mesh.worldMatrix);if(geometryState.combineGeometry){var vertexBufs=mesh.vertexBufs;if(vertexBufs.id!==this._lastVertexBufsId){if(vertexBufs.positionsBuf&&this._aPosition){this._aPosition.bindArrayBuffer(vertexBufs.positionsBuf,vertexBufs.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frame.bindArray++;}this._lastVertexBufsId=vertexBufs.id;}}if(this._uClippable){gl.uniform1i(this._uClippable,mesh._state.clippable);}gl.uniform3fv(this._uOffset,mesh._state.offset);if(geometryState.id!==this._lastGeometryId){if(this._uPositionsDecodeMatrix){gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometryState.positionsDecodeMatrix);}if(geometryState.combineGeometry){// VBOs were bound by the preceding VertexBufs chunk
9960
- if(geometryState.indicesBufCombined){geometryState.indicesBufCombined.bind();frame.bindArray++;}}else{if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frame.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frame.bindArray++;}}this._lastGeometryId=geometryState.id;}if(geometryState.combineGeometry){if(geometryState.indicesBufCombined){gl.drawElements(geometryState.primitive,geometryState.indicesBufCombined.numItems,geometryState.indicesBufCombined.itemType,0);frame.drawElements++;}}else{if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frame.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);frame.drawArrays++;}}};ShadowRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);this._scene=scene;this._useCount=0;if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uShadowViewMatrix=program.getLocation("shadowViewMatrix");this._uShadowProjMatrix=program.getLocation("shadowProjMatrix");this._uSectionPlanes={};var clips=scene._sectionPlanesState.sectionPlanes;for(var _i120=0,len=clips.length;_i120<len;_i120++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i120),pos:program.getLocation("sectionPlanePos"+_i120),dir:program.getLocation("sectionPlaneDir"+_i120)});}this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uOffset=program.getLocation("offset");this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};ShadowRenderer.prototype._bindProgram=function(frame){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;this._program.bind();frame.useProgram++;gl.uniformMatrix4fv(this._uShadowViewMatrix,false,frame.shadowViewMatrix);gl.uniformMatrix4fv(this._uShadowProjMatrix,false,frame.shadowProjMatrix);this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;if(sectionPlanesState.sectionPlanes.length>0){var sectionPlaneUniforms;var uSectionPlaneActive;var sectionPlane;var uSectionPlanePos;var uSectionPlaneDir;for(var _i121=0,len=this._uSectionPlanes.length;_i121<len;_i121++){sectionPlaneUniforms=this._uSectionPlanes[_i121];uSectionPlaneActive=sectionPlaneUniforms.active;sectionPlane=sectionPlanesState.sectionPlanes[_i121];if(uSectionPlaneActive){gl.uniform1i(uSectionPlaneActive,sectionPlane.active);}uSectionPlanePos=sectionPlaneUniforms.pos;if(uSectionPlanePos){gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}uSectionPlaneDir=sectionPlaneUniforms.dir;if(uSectionPlaneDir){gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}};/**
9985
+ if(geometryState.indicesBufCombined){geometryState.indicesBufCombined.bind();frame.bindArray++;}}else{if(this._aPosition){this._aPosition.bindArrayBuffer(geometryState.positionsBuf,geometryState.compressGeometry?gl.UNSIGNED_SHORT:gl.FLOAT);frame.bindArray++;}if(geometryState.indicesBuf){geometryState.indicesBuf.bind();frame.bindArray++;}}this._lastGeometryId=geometryState.id;}if(geometryState.combineGeometry){if(geometryState.indicesBufCombined){gl.drawElements(geometryState.primitive,geometryState.indicesBufCombined.numItems,geometryState.indicesBufCombined.itemType,0);frame.drawElements++;}}else{if(geometryState.indicesBuf){gl.drawElements(geometryState.primitive,geometryState.indicesBuf.numItems,geometryState.indicesBuf.itemType,0);frame.drawElements++;}else if(geometryState.positions){gl.drawArrays(gl.TRIANGLES,0,geometryState.positions.numItems);frame.drawArrays++;}}};ShadowRenderer.prototype._allocate=function(mesh){var scene=mesh.scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._shaderSource);this._scene=scene;this._useCount=0;if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uModelMatrix=program.getLocation("modelMatrix");this._uShadowViewMatrix=program.getLocation("shadowViewMatrix");this._uShadowProjMatrix=program.getLocation("shadowProjMatrix");this._uSectionPlanes={};var clips=scene._sectionPlanesState.sectionPlanes;for(var _i120=0,len=clips.length;_i120<len;_i120++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i120),pos:program.getLocation("sectionPlanePos"+_i120),dir:program.getLocation("sectionPlaneDir"+_i120)});}this._aPosition=program.getAttribute("position");this._uClippable=program.getLocation("clippable");this._uOffset=program.getLocation("offset");this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;};ShadowRenderer.prototype._bindProgram=function(frame){if(!this._program){this._allocate(mesh);}var scene=this._scene;var gl=scene.canvas.gl;var sectionPlanesState=scene._sectionPlanesState;this._program.bind();frame.useProgram++;gl.uniformMatrix4fv(this._uShadowViewMatrix,false,frame.shadowViewMatrix);gl.uniformMatrix4fv(this._uShadowProjMatrix,false,frame.shadowProjMatrix);this._lastMaterialId=null;this._lastVertexBufsId=null;this._lastGeometryId=null;if(sectionPlanesState.getNumAllocatedSectionPlanes()>0){var sectionPlaneUniforms;var uSectionPlaneActive;var sectionPlane;var uSectionPlanePos;var uSectionPlaneDir;for(var _i121=0,len=this._uSectionPlanes.length;_i121<len;_i121++){sectionPlaneUniforms=this._uSectionPlanes[_i121];uSectionPlaneActive=sectionPlaneUniforms.active;sectionPlane=sectionPlanesState.sectionPlanes[_i121];if(uSectionPlaneActive){gl.uniform1i(uSectionPlaneActive,sectionPlane.active);}uSectionPlanePos=sectionPlaneUniforms.pos;if(uSectionPlanePos){gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}uSectionPlaneDir=sectionPlaneUniforms.dir;if(uSectionPlaneDir){gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}};/**
9961
9986
  * Indicates what rendering needs to be done for the layers within a {@link Drawable}.
9962
9987
  *
9963
9988
  * Each Drawable has a RenderFlags in {@link Drawable#renderFlags}.
@@ -17249,9 +17274,9 @@ PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=ne
17249
17274
  */this._vaoCache=new WeakMap();this._allocate();}/**
17250
17275
  * Should be overrided by subclasses if it does not only "depend" on section planes state.
17251
17276
  * @returns { string }
17252
- */_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:"_addRemapClipPosLines",value:function _addRemapClipPosLines(src){var viewportSize=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;src.push("uniform vec2 drawingBufferSize;");src.push("uniform vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");if(viewportSize===1){src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");}else{src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * (drawingBufferSize / float(".concat(viewportSize,"));"));}src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");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
17277
+ */_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:"_addRemapClipPosLines",value:function _addRemapClipPosLines(src){var viewportSize=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;src.push("uniform vec2 drawingBufferSize;");src.push("uniform vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");if(viewportSize===1){src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");}else{src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * (drawingBufferSize / float(".concat(viewportSize,"));"));}src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");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 numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}},{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
17253
17278
  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 ?
17254
- var lights=lightsState.lights;var light;for(var _i170=0,len=lights.length;_i170<len;_i170++){light=lights[_i170];switch(light.type){case"dir":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=null;this._uLightDir[_i170]=program.getLocation("lightDir"+_i170);break;case"point":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=program.getLocation("lightPos"+_i170);this._uLightDir[_i170]=null;this._uLightAttenuation[_i170]=program.getLocation("lightAttenuation"+_i170);break;case"spot":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=program.getLocation("lightPos"+_i170);this._uLightDir[_i170]=program.getLocation("lightDir"+_i170);this._uLightAttenuation[_i170]=program.getLocation("lightAttenuation"+_i170);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i171=0,_len20=scene._sectionPlanesState.sectionPlanes.length;_i171<_len20;_i171++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i171),pos:program.getLocation("sectionPlanePos"+_i171),dir:program.getLocation("sectionPlaneDir"+_i171)});}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._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uColorMap="uColorMap";this._uMetallicRoughMap="uMetallicRoughMap";this._uEmissiveMap="uEmissiveMap";this._uNormalMap="uNormalMap";this._uAOMap="uAOMap";if(this._instancing){this._aModelMatrix=program.getAttribute("modelMatrix");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;program.bind();frameCtx.textureUnit=0;if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,lightsState.getAmbientColorAndIntensity());}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}for(var _i172=0,len=lights.length;_i172<len;_i172++){var light=lights[_i172];if(this._uLightColor[_i172]){gl.uniform4f(this._uLightColor[_i172],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i172]){gl.uniform3fv(this._uLightPos[_i172],light.pos);if(this._uLightAttenuation[_i172]){gl.uniform1f(this._uLightAttenuation[_i172],light.attenuation);}}if(this._uLightDir[_i172]){gl.uniform3fv(this._uLightDir[_i172],light.dir);}}}},{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(state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(state.uvBuf);}if(this._aNormal){this._aNormal.bindArrayBuffer(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);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$l);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$h),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?
17279
+ var lights=lightsState.lights;var light;for(var _i170=0,len=lights.length;_i170<len;_i170++){light=lights[_i170];switch(light.type){case"dir":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=null;this._uLightDir[_i170]=program.getLocation("lightDir"+_i170);break;case"point":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=program.getLocation("lightPos"+_i170);this._uLightDir[_i170]=null;this._uLightAttenuation[_i170]=program.getLocation("lightAttenuation"+_i170);break;case"spot":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=program.getLocation("lightPos"+_i170);this._uLightDir[_i170]=program.getLocation("lightDir"+_i170);this._uLightAttenuation[_i170]=program.getLocation("lightAttenuation"+_i170);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i171=0,_len20=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i171<_len20;_i171++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i171),pos:program.getLocation("sectionPlanePos"+_i171),dir:program.getLocation("sectionPlaneDir"+_i171)});}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._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uColorMap="uColorMap";this._uMetallicRoughMap="uMetallicRoughMap";this._uEmissiveMap="uEmissiveMap";this._uNormalMap="uNormalMap";this._uAOMap="uAOMap";if(this._instancing){this._aModelMatrix=program.getAttribute("modelMatrix");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;program.bind();frameCtx.textureUnit=0;if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,lightsState.getAmbientColorAndIntensity());}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}for(var _i172=0,len=lights.length;_i172<len;_i172++){var light=lights[_i172];if(this._uLightColor[_i172]){gl.uniform4f(this._uLightColor[_i172],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i172]){gl.uniform3fv(this._uLightPos[_i172],light.pos);if(this._uLightAttenuation[_i172]){gl.uniform1f(this._uLightAttenuation[_i172],light.attenuation);}}if(this._uLightDir[_i172]){gl.uniform3fv(this._uLightDir[_i172],light.dir);}}}},{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(state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(state.uvBuf);}if(this._aNormal){this._aNormal.bindArrayBuffer(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);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$l);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$h),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?
17255
17280
  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._uPickClipPos){gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);}if(this._uDrawingBufferSize){gl.uniform2f(this._uDrawingBufferSize,gl.drawingBufferWidth,gl.drawingBufferHeight);}if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,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;}();/**
17256
17281
  * @private
17257
17282
  */var VBOSceneModelTriangleBatchingRenderer=/*#__PURE__*/function(_VBOSceneModelRendere){_inherits(VBOSceneModelTriangleBatchingRenderer,_VBOSceneModelRendere);var _super66=_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 _super66.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);/**
@@ -17270,80 +17295,80 @@ gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uZFar){gl.uniform1f(t
17270
17295
  * @private
17271
17296
  */var VBOSceneModelLineInstancingRenderer=/*#__PURE__*/function(_VBOSceneModelRendere6){_inherits(VBOSceneModelLineInstancingRenderer,_VBOSceneModelRendere6);var _super73=_createSuper(VBOSceneModelLineInstancingRenderer);function VBOSceneModelLineInstancingRenderer(scene,withSAO){_classCallCheck(this,VBOSceneModelLineInstancingRenderer);return _super73.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);/**
17272
17297
  * @private
17273
- */var TrianglesBatchingColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl3){_inherits(TrianglesBatchingColorRenderer,_VBOSceneModelTriangl3);var _super74=_createSuper(TrianglesBatchingColorRenderer);function TrianglesBatchingColorRenderer(){_classCallCheck(this,TrianglesBatchingColorRenderer);return _super74.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 _i173=0,len=lightsState.lights.length;_i173<len;_i173++){light=lightsState.lights[_i173];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i173+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i173+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i173+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i173+";");src.push("uniform vec3 lightDir"+_i173+";");}}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
17298
+ */var TrianglesBatchingColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl3){_inherits(TrianglesBatchingColorRenderer,_VBOSceneModelTriangl3);var _super74=_createSuper(TrianglesBatchingColorRenderer);function TrianglesBatchingColorRenderer(){_classCallCheck(this,TrianglesBatchingColorRenderer);return _super74.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.getNumAllocatedSectionPlanes()>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 _i173=0,len=lightsState.lights.length;_i173<len;_i173++){light=lightsState.lights[_i173];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i173+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i173+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i173+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i173+";");src.push("uniform vec3 lightDir"+_i173+";");}}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
17274
17299
  // renderPass = COLOR_OPAQUE
17275
17300
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17276
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push("vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(var _i174=0,_len21=lightsState.lights.length;_i174<_len21;_i174++){light=lightsState.lights[_i174];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i174+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i174+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i174+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i174+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i174+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i174+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i174+".rgb * lightColor"+_i174+".a);");}src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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 batching draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i175=0,len=sectionPlanesState.sectionPlanes.length;_i175<len;_i175++){src.push("uniform bool sectionPlaneActive"+_i175+";");src.push("uniform vec3 sectionPlanePos"+_i175+";");src.push("uniform vec3 sectionPlaneDir"+_i175+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i176=0,_len22=sectionPlanesState.sectionPlanes.length;_i176<_len22;_i176++){src.push("if (sectionPlaneActive"+_i176+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i176+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i176+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17301
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push("vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(var _i174=0,_len21=lightsState.lights.length;_i174<_len21;_i174++){light=lightsState.lights[_i174];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i174+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i174+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i174+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i174+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i174+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i174+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i174+".rgb * lightColor"+_i174+".a);");}src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i175=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i175<len;_i175++){src.push("uniform bool sectionPlaneActive"+_i175+";");src.push("uniform vec3 sectionPlanePos"+_i175+";");src.push("uniform vec3 sectionPlaneDir"+_i175+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i176=0,_len22=sectionPlanesState.getNumAllocatedSectionPlanes();_i176<_len22;_i176++){src.push("if (sectionPlaneActive"+_i176+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i176+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i176+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17277
17302
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
17278
17303
  src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");}else{src.push(" outColor = vColor;");}src.push("}");return src;}}]);return TrianglesBatchingColorRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17279
17304
  * @private
17280
- */var TrianglesBatchingFlatColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl4){_inherits(TrianglesBatchingFlatColorRenderer,_VBOSceneModelTriangl4);var _super75=_createSuper(TrianglesBatchingFlatColorRenderer);function TrianglesBatchingFlatColorRenderer(){_classCallCheck(this,TrianglesBatchingFlatColorRenderer);return _super75.apply(this,arguments);}_createClass(TrianglesBatchingFlatColorRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{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("// Triangles batching flat-shading draw vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("out vec4 vColor;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17305
+ */var TrianglesBatchingFlatColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl4){_inherits(TrianglesBatchingFlatColorRenderer,_VBOSceneModelTriangl4);var _super75=_createSuper(TrianglesBatchingFlatColorRenderer);function TrianglesBatchingFlatColorRenderer(){_classCallCheck(this,TrianglesBatchingFlatColorRenderer);return _super75.apply(this,arguments);}_createClass(TrianglesBatchingFlatColorRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching flat-shading draw vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("out vec4 vColor;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17281
17306
  // renderPass = COLOR_OPAQUE
17282
17307
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17283
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching flat-shading draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i177=0,len=sectionPlanesState.sectionPlanes.length;_i177<len;_i177++){src.push("uniform bool sectionPlaneActive"+_i177+";");src.push("uniform vec3 sectionPlanePos"+_i177+";");src.push("uniform vec3 sectionPlaneDir"+_i177+";");}}this._addMatricesUniformBlockLines(src);src.push("uniform vec4 lightAmbient;");for(var _i178=0,_len23=lightsState.lights.length;_i178<_len23;_i178++){var light=lightsState.lights[_i178];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i178+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i178+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i178+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i178+";");src.push("uniform vec3 lightDir"+_i178+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i179=0,_len24=sectionPlanesState.sectionPlanes.length;_i179<_len24;_i179++){src.push("if (sectionPlaneActive"+_i179+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i179+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i179+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(var _i180=0,_len25=lightsState.lights.length;_i180<_len25;_i180++){var _light4=lightsState.lights[_i180];if(_light4.type==="ambient"){continue;}if(_light4.type==="dir"){if(_light4.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i180+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i180+", 0.0)).xyz);");}}else if(_light4.type==="point"){if(_light4.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i180+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i180+", 0.0)).xyz);");}}else if(_light4.type==="spot"){if(_light4.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i180+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i180+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i180+".rgb * lightColor"+_i180+".a);");}src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17308
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching flat-shading draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i177=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i177<len;_i177++){src.push("uniform bool sectionPlaneActive"+_i177+";");src.push("uniform vec3 sectionPlanePos"+_i177+";");src.push("uniform vec3 sectionPlaneDir"+_i177+";");}}this._addMatricesUniformBlockLines(src);src.push("uniform vec4 lightAmbient;");for(var _i178=0,_len23=lightsState.lights.length;_i178<_len23;_i178++){var light=lightsState.lights[_i178];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i178+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i178+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i178+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i178+";");src.push("uniform vec3 lightDir"+_i178+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i179=0,_len24=sectionPlanesState.getNumAllocatedSectionPlanes();_i179<_len24;_i179++){src.push("if (sectionPlaneActive"+_i179+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i179+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i179+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(var _i180=0,_len25=lightsState.lights.length;_i180<_len25;_i180++){var _light4=lightsState.lights[_i180];if(_light4.type==="ambient"){continue;}if(_light4.type==="dir"){if(_light4.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i180+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i180+", 0.0)).xyz);");}}else if(_light4.type==="point"){if(_light4.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i180+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i180+", 0.0)).xyz);");}}else if(_light4.type==="spot"){if(_light4.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i180+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i180+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i180+".rgb * lightColor"+_i180+".a);");}src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17284
17309
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
17285
17310
  src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(fragColor.rgb * ambient, 1.0);");}else{src.push(" outColor = fragColor;");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return TrianglesBatchingFlatColorRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17286
17311
  * @private
17287
- */var TrianglesBatchingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl5){_inherits(TrianglesBatchingSilhouetteRenderer,_VBOSceneModelTriangl5);var _super76=_createSuper(TrianglesBatchingSilhouetteRenderer);function TrianglesBatchingSilhouetteRenderer(){_classCallCheck(this,TrianglesBatchingSilhouetteRenderer);return _super76.apply(this,arguments);}_createClass(TrianglesBatchingSilhouetteRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){_get(_getPrototypeOf(TrianglesBatchingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,batchingLayer,renderPass,{colorUniform:true});}},{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("// Triangles batching silhouette vertex shader");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 color;");this._addMatricesUniformBlockLines(src);src.push("uniform vec4 silhouetteColor;");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("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// silhouetteFlag = NOT_RENDERED | SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | SILHOUETTE_XRAYED
17312
+ */var TrianglesBatchingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl5){_inherits(TrianglesBatchingSilhouetteRenderer,_VBOSceneModelTriangl5);var _super76=_createSuper(TrianglesBatchingSilhouetteRenderer);function TrianglesBatchingSilhouetteRenderer(){_classCallCheck(this,TrianglesBatchingSilhouetteRenderer);return _super76.apply(this,arguments);}_createClass(TrianglesBatchingSilhouetteRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){_get(_getPrototypeOf(TrianglesBatchingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,batchingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching silhouette vertex shader");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 color;");this._addMatricesUniformBlockLines(src);src.push("uniform vec4 silhouetteColor;");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("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// silhouetteFlag = NOT_RENDERED | SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | SILHOUETTE_XRAYED
17288
17313
  // renderPass = SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
17289
17314
  src.push("int silhouetteFlag = int(flags) >> 4 & 0xF;");src.push("if (silhouetteFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17290
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, float(color.a) / 255.0));");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 i;var len;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching silhouette fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;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("outColor = vColor;");src.push("}");return src;}}]);return TrianglesBatchingSilhouetteRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17315
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, float(color.a) / 255.0));");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 i;var len;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching silhouette fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;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("outColor = vColor;");src.push("}");return src;}}]);return TrianglesBatchingSilhouetteRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17291
17316
  * @private
17292
- */var TrianglesBatchingEdgesRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl6){_inherits(TrianglesBatchingEdgesRenderer,_VBOSceneModelTriangl6);var _super77=_createSuper(TrianglesBatchingEdgesRenderer);function TrianglesBatchingEdgesRenderer(){_classCallCheck(this,TrianglesBatchingEdgesRenderer);return _super77.apply(this,arguments);}_createClass(TrianglesBatchingEdgesRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){_get(_getPrototypeOf(TrianglesBatchingEdgesRenderer.prototype),"drawLayer",this).call(this,frameCtx,batchingLayer,renderPass,{colorUniform:true});}},{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("uniform int renderPass;");src.push("uniform vec4 color;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
17317
+ */var TrianglesBatchingEdgesRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl6){_inherits(TrianglesBatchingEdgesRenderer,_VBOSceneModelTriangl6);var _super77=_createSuper(TrianglesBatchingEdgesRenderer);function TrianglesBatchingEdgesRenderer(){_classCallCheck(this,TrianglesBatchingEdgesRenderer);return _super77.apply(this,arguments);}_createClass(TrianglesBatchingEdgesRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){_get(_getPrototypeOf(TrianglesBatchingEdgesRenderer.prototype),"drawLayer",this).call(this,frameCtx,batchingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry edges drawing vertex shader");src.push("uniform int renderPass;");src.push("uniform vec4 color;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
17293
17318
  // renderPass = EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
17294
17319
  src.push("int edgeFlag = int(flags) >> 8 & 0xF;");src.push("if (edgeFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17295
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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");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("in float vFlags;");for(var _i181=0,len=sectionPlanesState.sectionPlanes.length;_i181<len;_i181++){src.push("uniform bool sectionPlaneActive"+_i181+";");src.push("uniform vec3 sectionPlanePos"+_i181+";");src.push("uniform vec3 sectionPlaneDir"+_i181+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i182=0,_len26=sectionPlanesState.sectionPlanes.length;_i182<_len26;_i182++){src.push("if (sectionPlaneActive"+_i182+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i182+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i182+".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;}}]);return TrianglesBatchingEdgesRenderer;}(VBOSceneModelTriangleBatchingEdgesRenderer);/**
17320
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry edges drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i181=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i181<len;_i181++){src.push("uniform bool sectionPlaneActive"+_i181+";");src.push("uniform vec3 sectionPlanePos"+_i181+";");src.push("uniform vec3 sectionPlaneDir"+_i181+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i182=0,_len26=sectionPlanesState.getNumAllocatedSectionPlanes();_i182<_len26;_i182++){src.push("if (sectionPlaneActive"+_i182+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i182+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i182+".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;}}]);return TrianglesBatchingEdgesRenderer;}(VBOSceneModelTriangleBatchingEdgesRenderer);/**
17296
17321
  * @private
17297
- */var TrianglesBatchingEdgesColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl7){_inherits(TrianglesBatchingEdgesColorRenderer,_VBOSceneModelTriangl7);var _super78=_createSuper(TrianglesBatchingEdgesColorRenderer);function TrianglesBatchingEdgesColorRenderer(){_classCallCheck(this,TrianglesBatchingEdgesColorRenderer);return _super78.apply(this,arguments);}_createClass(TrianglesBatchingEdgesColorRenderer,[{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("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
17322
+ */var TrianglesBatchingEdgesColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl7){_inherits(TrianglesBatchingEdgesColorRenderer,_VBOSceneModelTriangl7);var _super78=_createSuper(TrianglesBatchingEdgesColorRenderer);function TrianglesBatchingEdgesColorRenderer(){_classCallCheck(this,TrianglesBatchingEdgesColorRenderer);return _super78.apply(this,arguments);}_createClass(TrianglesBatchingEdgesColorRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry edges drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
17298
17323
  // renderPass = EDGES_COLOR_OPAQUE | EDGES_COLOR_TRANSPARENT
17299
17324
  src.push("int edgeFlag = int(flags) >> 8 & 0xF;");src.push("if (edgeFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17300
17325
  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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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(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);");
17301
- src.push("vColor = vec4(float(color.r*0.5) / 255.0, float(color.g*0.5) / 255.0, float(color.b*0.5) / 255.0, float(color.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");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("in float vFlags;");for(var _i183=0,len=sectionPlanesState.sectionPlanes.length;_i183<len;_i183++){src.push("uniform bool sectionPlaneActive"+_i183+";");src.push("uniform vec3 sectionPlanePos"+_i183+";");src.push("uniform vec3 sectionPlaneDir"+_i183+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i184=0,_len27=sectionPlanesState.sectionPlanes.length;_i184<_len27;_i184++){src.push("if (sectionPlaneActive"+_i184+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i184+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i184+".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;}}]);return TrianglesBatchingEdgesColorRenderer;}(VBOSceneModelTriangleBatchingEdgesRenderer);/**
17326
+ src.push("vColor = vec4(float(color.r*0.5) / 255.0, float(color.g*0.5) / 255.0, float(color.b*0.5) / 255.0, float(color.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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry edges drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i183=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i183<len;_i183++){src.push("uniform bool sectionPlaneActive"+_i183+";");src.push("uniform vec3 sectionPlanePos"+_i183+";");src.push("uniform vec3 sectionPlaneDir"+_i183+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i184=0,_len27=sectionPlanesState.getNumAllocatedSectionPlanes();_i184<_len27;_i184++){src.push("if (sectionPlaneActive"+_i184+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i184+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i184+".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;}}]);return TrianglesBatchingEdgesColorRenderer;}(VBOSceneModelTriangleBatchingEdgesRenderer);/**
17302
17327
  * @private
17303
- */var TrianglesBatchingPickMeshRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl8){_inherits(TrianglesBatchingPickMeshRenderer,_VBOSceneModelTriangl8);var _super79=_createSuper(TrianglesBatchingPickMeshRenderer);function TrianglesBatchingPickMeshRenderer(){_classCallCheck(this,TrianglesBatchingPickMeshRenderer);return _super79.apply(this,arguments);}_createClass(TrianglesBatchingPickMeshRenderer,[{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("// Batched geometry picking vertex shader");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 pickColor;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}this._addRemapClipPosLines(src);src.push("out vec4 vPickColor;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17328
+ */var TrianglesBatchingPickMeshRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl8){_inherits(TrianglesBatchingPickMeshRenderer,_VBOSceneModelTriangl8);var _super79=_createSuper(TrianglesBatchingPickMeshRenderer);function TrianglesBatchingPickMeshRenderer(){_classCallCheck(this,TrianglesBatchingPickMeshRenderer);return _super79.apply(this,arguments);}_createClass(TrianglesBatchingPickMeshRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry picking vertex shader");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 pickColor;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}this._addRemapClipPosLines(src);src.push("out vec4 vPickColor;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17304
17329
  // renderPass = PICK
17305
17330
  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
17306
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vPickColor = vec4(float(pickColor.r) / 255.0, float(pickColor.g) / 255.0, float(pickColor.b) / 255.0, float(pickColor.a) / 255.0);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(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("// Batched geometry picking fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");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 vPickColor;");src.push("out vec4 outColor;");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 _i185=0;_i185<sectionPlanesState.sectionPlanes.length;_i185++){src.push(" if (sectionPlaneActive"+_i185+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i185+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i185+".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 = vPickColor; ");src.push("}");return src;}}]);return TrianglesBatchingPickMeshRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17331
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vPickColor = vec4(float(pickColor.r) / 255.0, float(pickColor.g) / 255.0, float(pickColor.b) / 255.0, float(pickColor.a) / 255.0);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(clipPos);");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry picking fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec4 vPickColor;");src.push("out vec4 outColor;");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 _i185=0;_i185<sectionPlanesState.getNumAllocatedSectionPlanes();_i185++){src.push(" if (sectionPlaneActive"+_i185+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i185+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i185+".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 = vPickColor; ");src.push("}");return src;}}]);return TrianglesBatchingPickMeshRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17307
17332
  * @private
17308
- */var TrianglesBatchingPickDepthRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl9){_inherits(TrianglesBatchingPickDepthRenderer,_VBOSceneModelTriangl9);var _super80=_createSuper(TrianglesBatchingPickDepthRenderer);function TrianglesBatchingPickDepthRenderer(){_classCallCheck(this,TrianglesBatchingPickDepthRenderer);return _super80.apply(this,arguments);}_createClass(TrianglesBatchingPickDepthRenderer,[{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("// Triangles batching pick depth vertex shader");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;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}this._addRemapClipPosLines(src);src.push("out vec4 vViewPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17333
+ */var TrianglesBatchingPickDepthRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl9){_inherits(TrianglesBatchingPickDepthRenderer,_VBOSceneModelTriangl9);var _super80=_createSuper(TrianglesBatchingPickDepthRenderer);function TrianglesBatchingPickDepthRenderer(){_classCallCheck(this,TrianglesBatchingPickDepthRenderer);return _super80.apply(this,arguments);}_createClass(TrianglesBatchingPickDepthRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching pick depth vertex shader");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;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}this._addRemapClipPosLines(src);src.push("out vec4 vViewPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17309
17334
  // renderPass = PICK
17310
17335
  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
17311
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(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 batching 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("in float vFlags;");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 outColor;");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 _i186=0;_i186<sectionPlanesState.sectionPlanes.length;_i186++){src.push(" if (sectionPlaneActive"+_i186+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i186+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i186+".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(" outColor = packDepth(zNormalizedDepth); ");// Must be linear depth
17336
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(clipPos);");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching 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("in float vFlags;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("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 outColor;");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 _i186=0;_i186<sectionPlanesState.getNumAllocatedSectionPlanes();_i186++){src.push(" if (sectionPlaneActive"+_i186+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i186+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i186+".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(" outColor = packDepth(zNormalizedDepth); ");// Must be linear depth
17312
17337
  src.push("}");return src;}}]);return TrianglesBatchingPickDepthRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17313
17338
  * @private
17314
- */var TrianglesBatchingPickNormalsRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl10){_inherits(TrianglesBatchingPickNormalsRenderer,_VBOSceneModelTriangl10);var _super81=_createSuper(TrianglesBatchingPickNormalsRenderer);function TrianglesBatchingPickNormalsRenderer(){_classCallCheck(this,TrianglesBatchingPickNormalsRenderer);return _super81.apply(this,arguments);}_createClass(TrianglesBatchingPickNormalsRenderer,[{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("// Triangles batching pick normals vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec3 normal;");src.push("in float flags;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src,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("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 vec3 vWorldNormal;");src.push("out vec4 outColor;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17339
+ */var TrianglesBatchingPickNormalsRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl10){_inherits(TrianglesBatchingPickNormalsRenderer,_VBOSceneModelTriangl10);var _super81=_createSuper(TrianglesBatchingPickNormalsRenderer);function TrianglesBatchingPickNormalsRenderer(){_classCallCheck(this,TrianglesBatchingPickNormalsRenderer);return _super81.apply(this,arguments);}_createClass(TrianglesBatchingPickNormalsRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching pick normals vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec3 normal;");src.push("in float flags;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src,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("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 vec3 vWorldNormal;");src.push("out vec4 outColor;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17315
17340
  // renderPass = PICK
17316
17341
  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
17317
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec3 worldNormal = octDecode(normal.xy); ");src.push(" vWorldNormal = worldNormal;");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(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 batching pick normals fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");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 vec3 vWorldNormal;");src.push("out highp ivec4 outNormal;");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 _i187=0;_i187<sectionPlanesState.sectionPlanes.length;_i187++){src.push(" if (sectionPlaneActive"+_i187+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i187+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i187+".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(" outNormal = ivec4(vWorldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("}");return src;}}]);return TrianglesBatchingPickNormalsRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17342
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec3 worldNormal = octDecode(normal.xy); ");src.push(" vWorldNormal = worldNormal;");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(clipPos);");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching pick normals fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec3 vWorldNormal;");src.push("out highp ivec4 outNormal;");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 _i187=0;_i187<sectionPlanesState.getNumAllocatedSectionPlanes();_i187++){src.push(" if (sectionPlaneActive"+_i187+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i187+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i187+".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(" outNormal = ivec4(vWorldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("}");return src;}}]);return TrianglesBatchingPickNormalsRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17318
17343
  * @private
17319
- */var TrianglesBatchingOcclusionRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl11){_inherits(TrianglesBatchingOcclusionRenderer,_VBOSceneModelTriangl11);var _super82=_createSuper(TrianglesBatchingOcclusionRenderer);function TrianglesBatchingOcclusionRenderer(){_classCallCheck(this,TrianglesBatchingOcclusionRenderer);return _super82.apply(this,arguments);}_createClass(TrianglesBatchingOcclusionRenderer,[{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("// Triangles batching occlusion vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");this._addMatricesUniformBlockLines(src);if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17344
+ */var TrianglesBatchingOcclusionRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl11){_inherits(TrianglesBatchingOcclusionRenderer,_VBOSceneModelTriangl11);var _super82=_createSuper(TrianglesBatchingOcclusionRenderer);function TrianglesBatchingOcclusionRenderer(){_classCallCheck(this,TrianglesBatchingOcclusionRenderer);return _super82.apply(this,arguments);}_createClass(TrianglesBatchingOcclusionRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching occlusion vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");this._addMatricesUniformBlockLines(src);if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17320
17345
  // renderPass = COLOR_OPAQUE
17321
17346
  // Only opaque objects can be occluders
17322
17347
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17323
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");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 batching occlusion fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i188=0;_i188<sectionPlanesState.sectionPlanes.length;_i188++){src.push("uniform bool sectionPlaneActive"+_i188+";");src.push("uniform vec3 sectionPlanePos"+_i188+";");src.push("uniform vec3 sectionPlaneDir"+_i188+";");}}src.push("out vec4 outColor;");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 _i189=0;_i189<sectionPlanesState.sectionPlanes.length;_i189++){src.push(" if (sectionPlaneActive"+_i189+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i189+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i189+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
17348
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching occlusion fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i188=0;_i188<sectionPlanesState.getNumAllocatedSectionPlanes();_i188++){src.push("uniform bool sectionPlaneActive"+_i188+";");src.push("uniform vec3 sectionPlanePos"+_i188+";");src.push("uniform vec3 sectionPlaneDir"+_i188+";");}}src.push("out vec4 outColor;");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 _i189=0;_i189<sectionPlanesState.getNumAllocatedSectionPlanes();_i189++){src.push(" if (sectionPlaneActive"+_i189+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i189+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i189+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
17324
17349
  src.push("}");return src;}}]);return TrianglesBatchingOcclusionRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17325
17350
  * @private
17326
- */var TrianglesBatchingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl12){_inherits(TrianglesBatchingDepthRenderer,_VBOSceneModelTriangl12);var _super83=_createSuper(TrianglesBatchingDepthRenderer);function TrianglesBatchingDepthRenderer(){_classCallCheck(this,TrianglesBatchingDepthRenderer);return _super83.apply(this,arguments);}_createClass(TrianglesBatchingDepthRenderer,[{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("// Triangles batching depth vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec2 vHighPrecisionZW;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17351
+ */var TrianglesBatchingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl12){_inherits(TrianglesBatchingDepthRenderer,_VBOSceneModelTriangl12);var _super83=_createSuper(TrianglesBatchingDepthRenderer);function TrianglesBatchingDepthRenderer(){_classCallCheck(this,TrianglesBatchingDepthRenderer);return _super83.apply(this,arguments);}_createClass(TrianglesBatchingDepthRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching depth vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec2 vHighPrecisionZW;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17327
17352
  // renderPass = COLOR_OPAQUE
17328
17353
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17329
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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("vHighPrecisionZW = gl_Position.zw;");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 batching depth fragment shader");src.push("precision highp float;");src.push("precision highp int;");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("in float vFlags;");for(var _i190=0;_i190<sectionPlanesState.sectionPlanes.length;_i190++){src.push("uniform bool sectionPlaneActive"+_i190+";");src.push("uniform vec3 sectionPlanePos"+_i190+";");src.push("uniform vec3 sectionPlaneDir"+_i190+";");}}src.push("const float packUpScale = 256. / 255.;");src.push("const float unpackDownscale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unpackFactors = unpackDownscale / vec4( packFactors, 1. );");src.push("const float shiftRight8 = 1.0 / 256.;");src.push("vec4 packDepthToRGBA( const in float v ) {");src.push(" vec4 r = vec4( fract( v * packFactors ), v );");src.push(" r.yzw -= r.xyz * shiftRight8;");src.push(" return r * packUpScale;");src.push("}");src.push("in vec2 vHighPrecisionZW;");src.push("out vec4 outColor;");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("float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");src.push(" outColor = vec4(vec3(1.0 - fragCoordZ), 1.0); ");src.push("}");return src;}}]);return TrianglesBatchingDepthRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17354
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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("vHighPrecisionZW = gl_Position.zw;");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching depth fragment shader");src.push("precision highp float;");src.push("precision highp int;");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("in float vFlags;");for(var _i190=0;_i190<sectionPlanesState.getNumAllocatedSectionPlanes();_i190++){src.push("uniform bool sectionPlaneActive"+_i190+";");src.push("uniform vec3 sectionPlanePos"+_i190+";");src.push("uniform vec3 sectionPlaneDir"+_i190+";");}}src.push("const float packUpScale = 256. / 255.;");src.push("const float unpackDownscale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unpackFactors = unpackDownscale / vec4( packFactors, 1. );");src.push("const float shiftRight8 = 1.0 / 256.;");src.push("vec4 packDepthToRGBA( const in float v ) {");src.push(" vec4 r = vec4( fract( v * packFactors ), v );");src.push(" r.yzw -= r.xyz * shiftRight8;");src.push(" return r * packUpScale;");src.push("}");src.push("in vec2 vHighPrecisionZW;");src.push("out vec4 outColor;");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.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");src.push(" outColor = vec4(vec3(1.0 - fragCoordZ), 1.0); ");src.push("}");return src;}}]);return TrianglesBatchingDepthRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17330
17355
  * @private
17331
- */var TrianglesBatchingNormalsRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl13){_inherits(TrianglesBatchingNormalsRenderer,_VBOSceneModelTriangl13);var _super84=_createSuper(TrianglesBatchingNormalsRenderer);function TrianglesBatchingNormalsRenderer(){_classCallCheck(this,TrianglesBatchingNormalsRenderer);return _super84.apply(this,arguments);}_createClass(TrianglesBatchingNormalsRenderer,[{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("// Batched geometry normals vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec3 normal;");src.push("in vec4 color;");src.push("in float flags;");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("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 vec3 vViewNormal;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17356
+ */var TrianglesBatchingNormalsRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl13){_inherits(TrianglesBatchingNormalsRenderer,_VBOSceneModelTriangl13);var _super84=_createSuper(TrianglesBatchingNormalsRenderer);function TrianglesBatchingNormalsRenderer(){_classCallCheck(this,TrianglesBatchingNormalsRenderer);return _super84.apply(this,arguments);}_createClass(TrianglesBatchingNormalsRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry normals vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec3 normal;");src.push("in vec4 color;");src.push("in float flags;");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("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 vec3 vViewNormal;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17332
17357
  // renderPass = COLOR_OPAQUE
17333
- src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push(" vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push(" vViewNormal = viewNormal;");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("// Batched geometry normals fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i191=0;_i191<sectionPlanesState.sectionPlanes.length;_i191++){src.push("uniform bool sectionPlaneActive"+_i191+";");src.push("uniform vec3 sectionPlanePos"+_i191+";");src.push("uniform vec3 sectionPlaneDir"+_i191+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("out vec4 outColor;");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(" outColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");src.push("}");return src;}}]);return TrianglesBatchingNormalsRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17358
+ src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push(" vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push(" vViewNormal = viewNormal;");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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry normals fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i191=0;_i191<sectionPlanesState.getNumAllocatedSectionPlanes();_i191++){src.push("uniform bool sectionPlaneActive"+_i191+";");src.push("uniform vec3 sectionPlanePos"+_i191+";");src.push("uniform vec3 sectionPlaneDir"+_i191+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("out vec4 outColor;");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.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");src.push("}");return src;}}]);return TrianglesBatchingNormalsRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17334
17359
  * Renders BatchingLayer fragment depths to a shadow map.
17335
17360
  *
17336
17361
  * @private
17337
- */var TrianglesBatchingShadowRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl14){_inherits(TrianglesBatchingShadowRenderer,_VBOSceneModelTriangl14);var _super85=_createSuper(TrianglesBatchingShadowRenderer);function TrianglesBatchingShadowRenderer(){_classCallCheck(this,TrianglesBatchingShadowRenderer);return _super85.apply(this,arguments);}_createClass(TrianglesBatchingShadowRenderer,[{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("// Batched geometry shadow vertex shader");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");this._addMatricesUniformBlockLines(src);if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("out vec4 outColor;");src.push("void main(void) {");src.push(" int colorFlag = int(flags) & 0xF;");src.push(" bool visible = (colorFlag > 0);");src.push(" bool transparent = ((float(color.a) / 255.0) < 1.0);");src.push(" if (!visible || transparent) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");src.push(" } else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push(" vViewPosition = viewPosition;");src.push(" gl_Position = shadowProjMatrix * viewPosition;");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 shadow fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i192=0;_i192<sectionPlanesState.sectionPlanes.length;_i192++){src.push("uniform bool sectionPlaneActive"+_i192+";");src.push("uniform vec3 sectionPlanePos"+_i192+";");src.push("uniform vec3 sectionPlaneDir"+_i192+";");}}src.push("in vec4 vViewPosition;");src.push("vec4 encodeFloat( const in float v ) {");src.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);");src.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);");src.push(" vec4 comp = fract(v * bitShift);");src.push(" comp -= comp.xxyz * bitMask;");src.push(" return comp;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" 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(" outColor = encodeFloat( gl_FragCoord.z); ");src.push("}");return src;}}]);return TrianglesBatchingShadowRenderer;}(VBOSceneModelTriangleBatchingRenderer);// const TEXTURE_DECODE_FUNCS = {};
17362
+ */var TrianglesBatchingShadowRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl14){_inherits(TrianglesBatchingShadowRenderer,_VBOSceneModelTriangl14);var _super85=_createSuper(TrianglesBatchingShadowRenderer);function TrianglesBatchingShadowRenderer(){_classCallCheck(this,TrianglesBatchingShadowRenderer);return _super85.apply(this,arguments);}_createClass(TrianglesBatchingShadowRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry shadow vertex shader");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");this._addMatricesUniformBlockLines(src);if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("out vec4 outColor;");src.push("void main(void) {");src.push(" int colorFlag = int(flags) & 0xF;");src.push(" bool visible = (colorFlag > 0);");src.push(" bool transparent = ((float(color.a) / 255.0) < 1.0);");src.push(" if (!visible || transparent) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");src.push(" } else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push(" vViewPosition = viewPosition;");src.push(" gl_Position = shadowProjMatrix * viewPosition;");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry shadow fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i192=0;_i192<sectionPlanesState.getNumAllocatedSectionPlanes();_i192++){src.push("uniform bool sectionPlaneActive"+_i192+";");src.push("uniform vec3 sectionPlanePos"+_i192+";");src.push("uniform vec3 sectionPlaneDir"+_i192+";");}}src.push("in vec4 vViewPosition;");src.push("vec4 encodeFloat( const in float v ) {");src.push(" const vec4 bitShift = vec4(256 * 256 * 256, 256 * 256, 256, 1.0);");src.push(" const vec4 bitMask = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);");src.push(" vec4 comp = fract(v * bitShift);");src.push(" comp -= comp.xxyz * bitMask;");src.push(" return comp;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}src.push(" outColor = encodeFloat( gl_FragCoord.z); ");src.push("}");return src;}}]);return TrianglesBatchingShadowRenderer;}(VBOSceneModelTriangleBatchingRenderer);// const TEXTURE_DECODE_FUNCS = {};
17338
17363
  // TEXTURE_DECODE_FUNCS[LinearEncoding] = "linearToLinear";
17339
17364
  // TEXTURE_DECODE_FUNCS[sRGBEncoding] = "sRGBToLinear";
17340
17365
  /**
17341
17366
  * @private
17342
- */var TrianglesBatchingPBRRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl15){_inherits(TrianglesBatchingPBRRenderer,_VBOSceneModelTriangl15);var _super86=_createSuper(TrianglesBatchingPBRRenderer);function TrianglesBatchingPBRRenderer(){_classCallCheck(this,TrianglesBatchingPBRRenderer);return _super86.apply(this,arguments);}_createClass(TrianglesBatchingPBRRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesBatchingPBRRenderer.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 clippingCaps=sectionPlanesState.clippingCaps;var src=[];src.push("#version 300 es");src.push("// Triangles batching quality draw 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;");src.push("in vec3 normal;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in vec2 metallicRoughness;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src,true);src.push("uniform mat3 uvDecodeMatrix;");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("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("}");src.push("out vec4 vViewPosition;");src.push("out vec3 vViewNormal;");src.push("out vec4 vColor;");src.push("out vec2 vUV;");src.push("out vec2 vMetallicRoughness;");if(lightsState.lightMaps.length>0){src.push("out vec3 vWorldNormal;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");if(clippingCaps){src.push("out vec4 vClipPosition;");}}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17367
+ */var TrianglesBatchingPBRRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl15){_inherits(TrianglesBatchingPBRRenderer,_VBOSceneModelTriangl15);var _super86=_createSuper(TrianglesBatchingPBRRenderer);function TrianglesBatchingPBRRenderer(){_classCallCheck(this,TrianglesBatchingPBRRenderer);return _super86.apply(this,arguments);}_createClass(TrianglesBatchingPBRRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesBatchingPBRRenderer.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.getNumAllocatedSectionPlanes()>0;var clippingCaps=sectionPlanesState.clippingCaps;var src=[];src.push("#version 300 es");src.push("// Triangles batching quality draw 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;");src.push("in vec3 normal;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in vec2 metallicRoughness;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src,true);src.push("uniform mat3 uvDecodeMatrix;");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("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("}");src.push("out vec4 vViewPosition;");src.push("out vec3 vViewNormal;");src.push("out vec4 vColor;");src.push("out vec2 vUV;");src.push("out vec2 vMetallicRoughness;");if(lightsState.lightMaps.length>0){src.push("out vec3 vWorldNormal;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");if(clippingCaps){src.push("out vec4 vClipPosition;");}}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17343
17368
  // renderPass = COLOR_OPAQUE
17344
17369
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17345
17370
  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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push("vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");src.push("vFragDepth = 1.0 + clipPos.w;");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");if(clippingCaps){src.push("vClipPosition = clipPos;");}}src.push("vViewPosition = viewPosition;");src.push("vViewNormal = viewNormal;");src.push("vColor = color;");src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");src.push("vMetallicRoughness = metallicRoughness;");if(lightsState.lightMaps.length>0){src.push("vWorldNormal = worldNormal.xyz;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var gammaOutput=scene.gammaOutput;// If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
17346
- var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.sectionPlanes.length>0;var clippingCaps=sectionPlanesState.clippingCaps;var src=[];src.push('#version 300 es');src.push("// Triangles batching quality draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform sampler2D uColorMap;");src.push("uniform sampler2D uMetallicRoughMap;");src.push("uniform sampler2D uEmissiveMap;");src.push("uniform sampler2D uNormalMap;");src.push("uniform sampler2D uAOMap;");src.push("in vec4 vViewPosition;");src.push("in vec3 vViewNormal;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("in vec2 vMetallicRoughness;");if(lightsState.lightMaps.length>0){src.push("in vec3 vWorldNormal;");}this._addMatricesUniformBlockLines(src,true);if(lightsState.reflectionMaps.length>0){src.push("uniform samplerCube reflectionMap;");}if(lightsState.lightMaps.length>0){src.push("uniform samplerCube lightMap;");}src.push("uniform vec4 lightAmbient;");for(var _i193=0,len=lightsState.lights.length;_i193<len;_i193++){var light=lightsState.lights[_i193];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i193+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i193+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i193+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i193+";");src.push("uniform vec3 lightDir"+_i193+";");}}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");if(clippingCaps){src.push("in vec4 vClipPosition;");}for(var _i194=0,_len28=sectionPlanesState.sectionPlanes.length;_i194<_len28;_i194++){src.push("uniform bool sectionPlaneActive"+_i194+";");src.push("uniform vec3 sectionPlanePos"+_i194+";");src.push("uniform vec3 sectionPlaneDir"+_i194+";");}}// CONSTANT DEFINITIONS
17371
+ var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var clippingCaps=sectionPlanesState.clippingCaps;var src=[];src.push('#version 300 es');src.push("// Triangles batching quality draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform sampler2D uColorMap;");src.push("uniform sampler2D uMetallicRoughMap;");src.push("uniform sampler2D uEmissiveMap;");src.push("uniform sampler2D uNormalMap;");src.push("uniform sampler2D uAOMap;");src.push("in vec4 vViewPosition;");src.push("in vec3 vViewNormal;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("in vec2 vMetallicRoughness;");if(lightsState.lightMaps.length>0){src.push("in vec3 vWorldNormal;");}this._addMatricesUniformBlockLines(src,true);if(lightsState.reflectionMaps.length>0){src.push("uniform samplerCube reflectionMap;");}if(lightsState.lightMaps.length>0){src.push("uniform samplerCube lightMap;");}src.push("uniform vec4 lightAmbient;");for(var _i193=0,len=lightsState.lights.length;_i193<len;_i193++){var light=lightsState.lights[_i193];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i193+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i193+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i193+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i193+";");src.push("uniform vec3 lightDir"+_i193+";");}}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");if(clippingCaps){src.push("in vec4 vClipPosition;");}for(var _i194=0,_len28=sectionPlanesState.getNumAllocatedSectionPlanes();_i194<_len28;_i194++){src.push("uniform bool sectionPlaneActive"+_i194+";");src.push("uniform vec3 sectionPlanePos"+_i194+";");src.push("uniform vec3 sectionPlaneDir"+_i194+";");}}// CONSTANT DEFINITIONS
17347
17372
  src.push("#define PI 3.14159265359");src.push("#define RECIPROCAL_PI 0.31830988618");src.push("#define RECIPROCAL_PI2 0.15915494");src.push("#define EPSILON 1e-6");src.push("#define saturate(a) clamp( a, 0.0, 1.0 )");// UTILITY DEFINITIONS
17348
17373
  src.push("vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {");src.push(" vec3 texel = texture( uNormalMap, uv ).xyz;");src.push(" if (texel.x == 0.0 && texel.y == 0.0 && texel.z == 0.0) {");src.push(" return surf_norm;");src.push(" }");src.push(" vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );");src.push(" vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );");src.push(" vec2 st0 = dFdx( uv.st );");src.push(" vec2 st1 = dFdy( uv.st );");src.push(" vec3 S = normalize( q0 * st1.t - q1 * st0.t );");src.push(" vec3 T = normalize( -q0 * st1.s + q1 * st0.s );");src.push(" vec3 N = normalize( surf_norm );");src.push(" vec3 mapN = texel.xyz * 2.0 - 1.0;");src.push(" mat3 tsn = mat3( S, T, N );");//src.push(" mapN *= 3.0;");
17349
17374
  src.push(" return normalize( tsn * mapN );");src.push("}");src.push("vec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {");src.push(" return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );");src.push("}");// STRUCTURES
@@ -17352,23 +17377,23 @@ src.push("};");// IRRADIANCE EVALUATION
17352
17377
  src.push("float GGXRoughnessToBlinnExponent(const in float ggxRoughness) {");src.push(" float r = ggxRoughness + 0.0001;");src.push(" return (2.0 / (r * r) - 2.0);");src.push("}");src.push("float getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {");src.push(" float maxMIPLevelScalar = float( maxMIPLevel );");src.push(" float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( ( blinnShininessExponent * blinnShininessExponent ) + 1.0 );");src.push(" return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );");src.push("}");if(lightsState.reflectionMaps.length>0){src.push("vec3 getLightProbeIndirectRadiance(const in vec3 reflectVec, const in float blinnShininessExponent, const in int maxMIPLevel) {");src.push(" float mipLevel = 0.5 * getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);");//TODO: a random factor - fix this
17353
17378
  src.push(" vec3 envMapColor = sRGBToLinear(texture(reflectionMap, reflectVec, mipLevel)).rgb;");src.push(" return envMapColor;");src.push("}");}// SPECULAR BRDF EVALUATION
17354
17379
  src.push("vec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {");src.push(" float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );");src.push(" return ( 1.0 - specularColor ) * fresnel + specularColor;");src.push("}");src.push("float G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {");src.push(" float a2 = ( alpha * alpha );");src.push(" float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );");src.push(" float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );");src.push(" return 1.0 / ( gl * gv );");src.push("}");src.push("float G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {");src.push(" float a2 = ( alpha * alpha );");src.push(" float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );");src.push(" float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );");src.push(" return 0.5 / max( gv + gl, EPSILON );");src.push("}");src.push("float D_GGX(const in float alpha, const in float dotNH) {");src.push(" float a2 = ( alpha * alpha );");src.push(" float denom = ( dotNH * dotNH) * ( a2 - 1.0 ) + 1.0;");src.push(" return RECIPROCAL_PI * a2 / ( denom * denom);");src.push("}");src.push("vec3 BRDF_Specular_GGX(const in IncidentLight incidentLight, const in Geometry geometry, const in vec3 specularColor, const in float roughness) {");src.push(" float alpha = ( roughness * roughness );");src.push(" vec3 halfDir = normalize( incidentLight.direction + geometry.viewEyeDir );");src.push(" float dotNL = saturate( dot( geometry.viewNormal, incidentLight.direction ) );");src.push(" float dotNV = saturate( dot( geometry.viewNormal, geometry.viewEyeDir ) );");src.push(" float dotNH = saturate( dot( geometry.viewNormal, halfDir ) );");src.push(" float dotLH = saturate( dot( incidentLight.direction, halfDir ) );");src.push(" vec3 F = F_Schlick( specularColor, dotLH );");src.push(" float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );");src.push(" float D = D_GGX( alpha, dotNH );");src.push(" return F * (G * D);");src.push("}");src.push("vec3 BRDF_Specular_GGX_Environment(const in Geometry geometry, const in vec3 specularColor, const in float roughness) {");src.push(" float dotNV = saturate(dot(geometry.viewNormal, geometry.viewEyeDir));");src.push(" const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022);");src.push(" const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04);");src.push(" vec4 r = roughness * c0 + c1;");src.push(" float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;");src.push(" vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;");src.push(" return specularColor * AB.x + AB.y;");src.push("}");if(lightsState.lightMaps.length>0||lightsState.reflectionMaps.length>0){src.push("void computePBRLightMapping(const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");if(lightsState.lightMaps.length>0){src.push(" vec3 irradiance = sRGBToLinear(texture(lightMap, geometry.worldNormal)).rgb;");src.push(" irradiance *= PI;");src.push(" vec3 diffuseBRDFContrib = (RECIPROCAL_PI * material.diffuseColor);");src.push(" reflectedLight.diffuse += irradiance * diffuseBRDFContrib;");}if(lightsState.reflectionMaps.length>0){src.push(" vec3 reflectVec = reflect(geometry.viewEyeDir, geometry.viewNormal);");src.push(" reflectVec = inverseTransformDirection(reflectVec, viewMatrix);");src.push(" float blinnExpFromRoughness = GGXRoughnessToBlinnExponent(material.specularRoughness);");src.push(" vec3 radiance = getLightProbeIndirectRadiance(reflectVec, blinnExpFromRoughness, 8);");src.push(" vec3 specularBRDFContrib = BRDF_Specular_GGX_Environment(geometry, material.specularColor, material.specularRoughness);");src.push(" reflectedLight.specular += radiance * specularBRDFContrib;");}src.push("}");}// MAIN LIGHTING COMPUTATION FUNCTION
17355
- src.push("void computePBRLighting(const in IncidentLight incidentLight, const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");src.push(" float dotNL = saturate(dot(geometry.viewNormal, incidentLight.direction));");src.push(" vec3 irradiance = dotNL * incidentLight.color * PI;");src.push(" reflectedLight.diffuse += irradiance * (RECIPROCAL_PI * material.diffuseColor);");src.push(" reflectedLight.specular += irradiance * BRDF_Specular_GGX(incidentLight, geometry, material.specularColor, material.specularRoughness);");src.push("}");src.push("out vec4 outColor;");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 _i195=0,_len29=sectionPlanesState.sectionPlanes.length;_i195<_len29;_i195++){src.push("if (sectionPlaneActive"+_i195+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i195+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i195+".xyz), 0.0, 1000.0);");src.push("}");}if(clippingCaps){src.push(" if (dist > (0.002 * vClipPosition.w)) {");src.push(" discard;");src.push(" }");src.push(" if (dist > 0.0) { ");src.push(" outColor=vec4(1.0, 0.0, 0.0, 1.0);");if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" return;");src.push("}");}else{src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");}src.push("}");}src.push("IncidentLight light;");src.push("Material material;");src.push("Geometry geometry;");src.push("ReflectedLight reflectedLight = ReflectedLight(vec3(0.0,0.0,0.0), vec3(0.0,0.0,0.0));");src.push("vec3 rgb = (vec3(float(vColor.r) / 255.0, float(vColor.g) / 255.0, float(vColor.b) / 255.0));");src.push("float opacity = float(vColor.a) / 255.0;");src.push("vec3 baseColor = rgb;");src.push("float specularF0 = 1.0;");src.push("float metallic = float(vMetallicRoughness.r) / 255.0;");src.push("float roughness = float(vMetallicRoughness.g) / 255.0;");src.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;");src.push("vec4 colorTexel = sRGBToLinear(texture(uColorMap, vUV));");src.push("baseColor *= colorTexel.rgb;");// src.push("opacity *= colorTexel.a;");
17380
+ src.push("void computePBRLighting(const in IncidentLight incidentLight, const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");src.push(" float dotNL = saturate(dot(geometry.viewNormal, incidentLight.direction));");src.push(" vec3 irradiance = dotNL * incidentLight.color * PI;");src.push(" reflectedLight.diffuse += irradiance * (RECIPROCAL_PI * material.diffuseColor);");src.push(" reflectedLight.specular += irradiance * BRDF_Specular_GGX(incidentLight, geometry, material.specularColor, material.specularRoughness);");src.push("}");src.push("out vec4 outColor;");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 _i195=0,_len29=sectionPlanesState.getNumAllocatedSectionPlanes();_i195<_len29;_i195++){src.push("if (sectionPlaneActive"+_i195+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i195+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i195+".xyz), 0.0, 1000.0);");src.push("}");}if(clippingCaps){src.push(" if (dist > (0.002 * vClipPosition.w)) {");src.push(" discard;");src.push(" }");src.push(" if (dist > 0.0) { ");src.push(" outColor=vec4(1.0, 0.0, 0.0, 1.0);");if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" return;");src.push("}");}else{src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");}src.push("}");}src.push("IncidentLight light;");src.push("Material material;");src.push("Geometry geometry;");src.push("ReflectedLight reflectedLight = ReflectedLight(vec3(0.0,0.0,0.0), vec3(0.0,0.0,0.0));");src.push("vec3 rgb = (vec3(float(vColor.r) / 255.0, float(vColor.g) / 255.0, float(vColor.b) / 255.0));");src.push("float opacity = float(vColor.a) / 255.0;");src.push("vec3 baseColor = rgb;");src.push("float specularF0 = 1.0;");src.push("float metallic = float(vMetallicRoughness.r) / 255.0;");src.push("float roughness = float(vMetallicRoughness.g) / 255.0;");src.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;");src.push("vec4 colorTexel = sRGBToLinear(texture(uColorMap, vUV));");src.push("baseColor *= colorTexel.rgb;");// src.push("opacity *= colorTexel.a;");
17356
17381
  src.push("vec3 metalRoughTexel = texture(uMetallicRoughMap, vUV).rgb;");src.push("metallic *= metalRoughTexel.b;");src.push("roughness *= metalRoughTexel.g;");src.push("vec3 viewNormal = perturbNormal2Arb(vViewPosition.xyz, normalize(vViewNormal), vUV );");src.push("material.diffuseColor = baseColor * (1.0 - dielectricSpecular) * (1.0 - metallic);");src.push("material.specularRoughness = clamp(roughness, 0.04, 1.0);");src.push("material.specularColor = mix(vec3(dielectricSpecular), baseColor, metallic);");src.push("geometry.position = vViewPosition.xyz;");src.push("geometry.viewNormal = -normalize(viewNormal);");src.push("geometry.viewEyeDir = normalize(vViewPosition.xyz);");if(lightsState.lightMaps.length>0){src.push("geometry.worldNormal = normalize(vWorldNormal);");}if(lightsState.lightMaps.length>0||lightsState.reflectionMaps.length>0){src.push("computePBRLightMapping(geometry, material, reflectedLight);");}for(var _i196=0,_len30=lightsState.lights.length;_i196<_len30;_i196++){var _light5=lightsState.lights[_i196];if(_light5.type==="ambient"){continue;}if(_light5.type==="dir"){if(_light5.space==="view"){src.push("light.direction = normalize(lightDir"+_i196+");");}else{src.push("light.direction = normalize((viewMatrix * vec4(lightDir"+_i196+", 0.0)).xyz);");}}else if(_light5.type==="point"){if(_light5.space==="view"){src.push("light.direction = normalize(lightPos"+_i196+" - vViewPosition.xyz);");}else{src.push("light.direction = normalize((viewMatrix * vec4(lightPos"+_i196+", 0.0)).xyz);");}}else if(_light5.type==="spot"){if(_light5.space==="view"){src.push("light.direction = normalize(lightDir"+_i196+");");}else{src.push("light.direction = normalize((viewMatrix * vec4(lightDir"+_i196+", 0.0)).xyz);");}}else{continue;}src.push("light.color = lightColor"+_i196+".rgb * lightColor"+_i196+".a;");// a is intensity
17357
17382
  src.push("computePBRLighting(light, geometry, material, reflectedLight);");}src.push("vec3 emissiveColor = sRGBToLinear(texture(uEmissiveMap, vUV)).rgb;");// TODO: correct gamma function
17358
17383
  src.push("float aoFactor = texture(uAOMap, vUV).r;");src.push("vec3 outgoingLight = (lightAmbient.rgb * lightAmbient.a * baseColor * opacity * rgb) + (reflectedLight.diffuse) + (reflectedLight.specular) + emissiveColor;");src.push("vec4 fragColor;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17359
17384
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
17360
17385
  src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" fragColor = vec4(outgoingLight.rgb * ambient * aoFactor, opacity);");}else{src.push(" fragColor = vec4(outgoingLight.rgb * aoFactor, opacity);");}if(gammaOutput){src.push("fragColor = linearToGamma(fragColor, gammaFactor);");}src.push("outColor = fragColor;");if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return TrianglesBatchingPBRRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17361
17386
  * @private
17362
- */var TrianglesBatchingPickNormalsFlatRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl16){_inherits(TrianglesBatchingPickNormalsFlatRenderer,_VBOSceneModelTriangl16);var _super87=_createSuper(TrianglesBatchingPickNormalsFlatRenderer);function TrianglesBatchingPickNormalsFlatRenderer(){_classCallCheck(this,TrianglesBatchingPickNormalsFlatRenderer);return _super87.apply(this,arguments);}_createClass(TrianglesBatchingPickNormalsFlatRenderer,[{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("// Triangles batching pick flat normals vertex shader");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;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src,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("out vec4 vWorldPosition;");if(clipping){src.push("out float vFlags;");}src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17387
+ */var TrianglesBatchingPickNormalsFlatRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl16){_inherits(TrianglesBatchingPickNormalsFlatRenderer,_VBOSceneModelTriangl16);var _super87=_createSuper(TrianglesBatchingPickNormalsFlatRenderer);function TrianglesBatchingPickNormalsFlatRenderer(){_classCallCheck(this,TrianglesBatchingPickNormalsFlatRenderer);return _super87.apply(this,arguments);}_createClass(TrianglesBatchingPickNormalsFlatRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching pick flat normals vertex shader");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;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src,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("out vec4 vWorldPosition;");if(clipping){src.push("out float vFlags;");}src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17363
17388
  // renderPass = PICK
17364
17389
  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
17365
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}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 = remapClipPos(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 batching pick flat normals 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("in vec4 vWorldPosition;");if(clipping){src.push("in float vFlags;");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("out highp ivec4 outNormal;");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 _i197=0;_i197<sectionPlanesState.sectionPlanes.length;_i197++){src.push(" if (sectionPlaneActive"+_i197+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i197+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i197+".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(" vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push(" vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push(" outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("}");return src;}}]);return TrianglesBatchingPickNormalsFlatRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17390
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}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 = remapClipPos(clipPos);");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching pick flat normals 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("in vec4 vWorldPosition;");if(clipping){src.push("in float vFlags;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("out highp ivec4 outNormal;");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 _i197=0;_i197<sectionPlanesState.getNumAllocatedSectionPlanes();_i197++){src.push(" if (sectionPlaneActive"+_i197+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i197+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i197+".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(" vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push(" vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push(" outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("}");return src;}}]);return TrianglesBatchingPickNormalsFlatRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17366
17391
  * @private
17367
- */var TrianglesBatchingColorTextureRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl17){_inherits(TrianglesBatchingColorTextureRenderer,_VBOSceneModelTriangl17);var _super88=_createSuper(TrianglesBatchingColorTextureRenderer);function TrianglesBatchingColorTextureRenderer(){_classCallCheck(this,TrianglesBatchingColorTextureRenderer);return _super88.apply(this,arguments);}_createClass(TrianglesBatchingColorTextureRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesBatchingColorTextureRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{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("// Triangles batching color texture vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src);src.push("uniform mat3 uvDecodeMatrix;");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("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("out vec4 vColor;");src.push("out vec2 vUV;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17392
+ */var TrianglesBatchingColorTextureRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl17){_inherits(TrianglesBatchingColorTextureRenderer,_VBOSceneModelTriangl17);var _super88=_createSuper(TrianglesBatchingColorTextureRenderer);function TrianglesBatchingColorTextureRenderer(){_classCallCheck(this,TrianglesBatchingColorTextureRenderer);return _super88.apply(this,arguments);}_createClass(TrianglesBatchingColorTextureRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesBatchingColorTextureRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching color texture vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src);src.push("uniform mat3 uvDecodeMatrix;");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("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("out vec4 vColor;");src.push("out vec2 vUV;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17368
17393
  // renderPass = COLOR_OPAQUE
17369
17394
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17370
17395
  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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var gammaOutput=scene.gammaOutput;// If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
17371
- var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching color texture 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 sampler2D uColorMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i198=0,len=sectionPlanesState.sectionPlanes.length;_i198<len;_i198++){src.push("uniform bool sectionPlaneActive"+_i198+";");src.push("uniform vec3 sectionPlanePos"+_i198+";");src.push("uniform vec3 sectionPlaneDir"+_i198+";");}}this._addMatricesUniformBlockLines(src);src.push("uniform vec4 lightAmbient;");for(var _i199=0,_len31=lightsState.lights.length;_i199<_len31;_i199++){var light=lightsState.lights[_i199];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i199+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i199+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i199+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i199+";");src.push("uniform vec3 lightDir"+_i199+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("out vec4 outColor;");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 _i200=0,_len32=sectionPlanesState.sectionPlanes.length;_i200<_len32;_i200++){src.push("if (sectionPlaneActive"+_i200+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i200+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i200+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(var _i201=0,_len33=lightsState.lights.length;_i201<_len33;_i201++){var _light6=lightsState.lights[_i201];if(_light6.type==="ambient"){continue;}if(_light6.type==="dir"){if(_light6.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i201+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i201+", 0.0)).xyz);");}}else if(_light6.type==="point"){if(_light6.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i201+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i201+", 0.0)).xyz);");}}else if(_light6.type==="spot"){if(_light6.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i201+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i201+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i201+".rgb * lightColor"+_i201+".a);");}src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(gammaOutput){src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");}else{src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");}src.push("float opacity = color.a;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17396
+ var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching color texture 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 sampler2D uColorMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i198=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i198<len;_i198++){src.push("uniform bool sectionPlaneActive"+_i198+";");src.push("uniform vec3 sectionPlanePos"+_i198+";");src.push("uniform vec3 sectionPlaneDir"+_i198+";");}}this._addMatricesUniformBlockLines(src);src.push("uniform vec4 lightAmbient;");for(var _i199=0,_len31=lightsState.lights.length;_i199<_len31;_i199++){var light=lightsState.lights[_i199];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i199+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i199+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i199+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i199+";");src.push("uniform vec3 lightDir"+_i199+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("out vec4 outColor;");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 _i200=0,_len32=sectionPlanesState.getNumAllocatedSectionPlanes();_i200<_len32;_i200++){src.push("if (sectionPlaneActive"+_i200+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i200+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i200+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(var _i201=0,_len33=lightsState.lights.length;_i201<_len33;_i201++){var _light6=lightsState.lights[_i201];if(_light6.type==="ambient"){continue;}if(_light6.type==="dir"){if(_light6.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i201+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i201+", 0.0)).xyz);");}}else if(_light6.type==="point"){if(_light6.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i201+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i201+", 0.0)).xyz);");}}else if(_light6.type==="spot"){if(_light6.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i201+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i201+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i201+".rgb * lightColor"+_i201+".a);");}src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(gammaOutput){src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");}else{src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");}src.push("float opacity = color.a;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17372
17397
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
17373
17398
  src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(colorTexel.rgb * ambient, opacity);");}else{src.push(" outColor = vec4(colorTexel.rgb, opacity);");}if(gammaOutput){src.push("outColor = linearToGamma(outColor, gammaFactor);");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return TrianglesBatchingColorTextureRenderer;}(VBOSceneModelTriangleBatchingRenderer);/**
17374
17399
  * @private
@@ -17401,34 +17426,34 @@ best=oct=octEncodeVec3(worldNormal,"floor","floor");dec=octDecodeVec2(oct);curre
17401
17426
  var x=p[0]/(Math.abs(p[0])+Math.abs(p[1])+Math.abs(p[2]));var y=p[1]/(Math.abs(p[0])+Math.abs(p[1])+Math.abs(p[2]));if(p[2]<0){var tempx=x;var tempy=y;tempx=(1-Math.abs(y))*(x>=0?1:-1);tempy=(1-Math.abs(x))*(y>=0?1:-1);x=tempx;y=tempy;}return new Int8Array([Math[xfunc](x*127.5+(x<0?-1:0)),Math[yfunc](y*127.5+(y<0?-1:0))]);}/**
17402
17427
  * @private
17403
17428
  */function octDecodeVec2(oct){// Decode an oct-encoded normal
17404
- 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$n=math.vec3();var tempVec3c$k=math.vec3();var tempVec3d$g=math.vec3();var tempMat4a$g=math.mat4();/**
17429
+ 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$n=math.vec3();var tempVec3c$k=math.vec3();var tempVec3d$8=math.vec3();var tempMat4a$g=math.mat4();/**
17405
17430
  * @private
17406
- */var SnapBatchingDepthBufInitRenderer=/*#__PURE__*/function(_VBOSceneModelRendere7){_inherits(SnapBatchingDepthBufInitRenderer,_VBOSceneModelRendere7);var _super89=_createSuper(SnapBatchingDepthBufInitRenderer);function SnapBatchingDepthBufInitRenderer(){_classCallCheck(this,SnapBatchingDepthBufInitRenderer);return _super89.apply(this,arguments);}_createClass(SnapBatchingDepthBufInitRenderer,[{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;if(this._vaoCache.has(batchingLayer)){gl.bindVertexArray(this._vaoCache.get(batchingLayer));}else{this._vaoCache.set(batchingLayer,this._makeVAO(state));}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$n;if(origin){var rotatedOrigin=tempVec3c$k;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$g);rtcCameraEye=tempVec3d$g;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);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,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);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
17431
+ */var SnapBatchingDepthBufInitRenderer=/*#__PURE__*/function(_VBOSceneModelRendere7){_inherits(SnapBatchingDepthBufInitRenderer,_VBOSceneModelRendere7);var _super89=_createSuper(SnapBatchingDepthBufInitRenderer);function SnapBatchingDepthBufInitRenderer(){_classCallCheck(this,SnapBatchingDepthBufInitRenderer);return _super89.apply(this,arguments);}_createClass(SnapBatchingDepthBufInitRenderer,[{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;if(this._vaoCache.has(batchingLayer)){gl.bindVertexArray(this._vaoCache.get(batchingLayer));}else{this._vaoCache.set(batchingLayer,this._makeVAO(state));}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$n;if(origin){var rotatedOrigin=tempVec3c$k;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$g);rtcCameraEye=tempVec3d$8;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);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,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);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
17407
17432
  gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(batchingLayer);//=============================================================
17408
17433
  // TODO: Use drawElements count and offset to draw only one entity
17409
17434
  //=============================================================
17410
- state.indicesBuf.bind();gl.drawElements(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0);state.indicesBuf.unbind();}},{key:"_allocate",value:function _allocate(){_get(_getPrototypeOf(SnapBatchingDepthBufInitRenderer.prototype),"_allocate",this).call(this);var program=this._program;{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:"_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 vec4 pickColor;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);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("}");src.push("flat out vec4 vPickColor;");src.push("out vec4 vWorldPosition;");if(clipping){src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17435
+ state.indicesBuf.bind();gl.drawElements(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0);state.indicesBuf.unbind();}},{key:"_allocate",value:function _allocate(){_get(_getPrototypeOf(SnapBatchingDepthBufInitRenderer.prototype),"_allocate",this).call(this);var program=this._program;{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:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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 vec4 pickColor;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);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("}");src.push("flat out vec4 vPickColor;");src.push("out vec4 vWorldPosition;");if(clipping){src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17411
17436
  // renderPass = PICK
17412
17437
  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
17413
- 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; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}src.push("vPickColor = pickColor;");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(" }");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;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("in float vFlags;");for(var _i203=0;_i203<sectionPlanesState.sectionPlanes.length;_i203++){src.push("uniform bool sectionPlaneActive"+_i203+";");src.push("uniform vec3 sectionPlanePos"+_i203+";");src.push("uniform vec3 sectionPlaneDir"+_i203+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");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(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");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;}(VBOSceneModelRenderer);var tempVec3a$q=math.vec3();var tempVec3b$m=math.vec3();var tempVec3c$j=math.vec3();var tempVec3d$f=math.vec3();var tempMat4a$f=math.mat4();/**
17438
+ 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; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}src.push("vPickColor = pickColor;");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(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>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;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("in float vFlags;");for(var _i203=0;_i203<sectionPlanesState.getNumAllocatedSectionPlanes();_i203++){src.push("uniform bool sectionPlaneActive"+_i203+";");src.push("uniform vec3 sectionPlanePos"+_i203+";");src.push("uniform vec3 sectionPlaneDir"+_i203+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");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.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");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;}(VBOSceneModelRenderer);var tempVec3a$q=math.vec3();var tempVec3b$m=math.vec3();var tempVec3c$j=math.vec3();var tempVec3d$7=math.vec3();var tempMat4a$f=math.mat4();/**
17414
17439
  * @private
17415
- */var SnapBatchingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelRendere8){_inherits(SnapBatchingDepthRenderer,_VBOSceneModelRendere8);var _super90=_createSuper(SnapBatchingDepthRenderer);function SnapBatchingDepthRenderer(){_classCallCheck(this,SnapBatchingDepthRenderer);return _super90.apply(this,arguments);}_createClass(SnapBatchingDepthRenderer,[{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;if(this._vaoCache.has(batchingLayer)){gl.bindVertexArray(this._vaoCache.get(batchingLayer));}else{this._vaoCache.set(batchingLayer,this._makeVAO(state));}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$m;if(origin){var rotatedOrigin=tempVec3c$j;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$f);rtcCameraEye=tempVec3d$f;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);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,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);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
17440
+ */var SnapBatchingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelRendere8){_inherits(SnapBatchingDepthRenderer,_VBOSceneModelRendere8);var _super90=_createSuper(SnapBatchingDepthRenderer);function SnapBatchingDepthRenderer(){_classCallCheck(this,SnapBatchingDepthRenderer);return _super90.apply(this,arguments);}_createClass(SnapBatchingDepthRenderer,[{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;if(this._vaoCache.has(batchingLayer)){gl.bindVertexArray(this._vaoCache.get(batchingLayer));}else{this._vaoCache.set(batchingLayer,this._makeVAO(state));}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$m;if(origin){var rotatedOrigin=tempVec3c$j;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$f);rtcCameraEye=tempVec3d$7;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);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,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);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
17416
17441
  gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(batchingLayer);//=============================================================
17417
17442
  // TODO: Use drawElements count and offset to draw only one entity
17418
17443
  //=============================================================
17419
17444
  if(frameCtx.snapMode==="edge"){state.edgeIndicesBuf.bind();gl.drawElements(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0);state.edgeIndicesBuf.unbind();// needed?
17420
- }else{gl.drawArrays(gl.POINTS,0,state.positionsBuf.numItems);}}},{key:"_allocate",value:function _allocate(){_get(_getPrototypeOf(SnapBatchingDepthRenderer.prototype),"_allocate",this).call(this);var program=this._program;{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:"_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;");this._addMatricesUniformBlockLines(src);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
17445
+ }else{gl.drawArrays(gl.POINTS,0,state.positionsBuf.numItems);}}},{key:"_allocate",value:function _allocate(){_get(_getPrototypeOf(SnapBatchingDepthRenderer.prototype),"_allocate",this).call(this);var program=this._program;{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:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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;");this._addMatricesUniformBlockLines(src);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
17421
17446
  // renderPass = PICK
17422
17447
  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
17423
17448
  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?
17424
- 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 _i204=0;_i204<sectionPlanesState.sectionPlanes.length;_i204++){src.push("uniform bool sectionPlaneActive"+_i204+";");src.push("uniform vec3 sectionPlanePos"+_i204+";");src.push("uniform vec3 sectionPlaneDir"+_i204+";");}}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;}(VBOSceneModelRenderer);/**
17449
+ src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>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 _i204=0;_i204<sectionPlanesState.getNumAllocatedSectionPlanes();_i204++){src.push("uniform bool sectionPlaneActive"+_i204+";");src.push("uniform vec3 sectionPlanePos"+_i204+";");src.push("uniform vec3 sectionPlaneDir"+_i204+";");}}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.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" 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;}(VBOSceneModelRenderer);/**
17425
17450
  * @private
17426
17451
  */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:"eagerCreateRenders",value:function eagerCreateRenders(){// Pre-initialize renderers that would otherwise be lazy-initialised
17427
17452
  // on user interaction, such as picking or emphasis, so that there is no delay
17428
17453
  // when user first begins interacting with the viewer.
17429
17454
  if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapBatchingDepthBufInitRenderer(this._scene,false);}if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapBatchingDepthRenderer(this._scene);}}},{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={};/**
17430
17455
  * @private
17431
- */function getSnapBatchingRenderers(scene){var sceneId=scene.id;var batchingRenderers=cachedRenderers$6[sceneId];if(!batchingRenderers){batchingRenderers=new SnapBatchingRenderers(scene);cachedRenderers$6[sceneId]=batchingRenderers;batchingRenderers._compile();batchingRenderers.eagerCreateRenders();scene.on("compile",function(){batchingRenderers._compile();batchingRenderers.eagerCreateRenders();});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$l=math.vec3();var tempVec3c$i=math.vec3();var tempVec3d$e=math.vec3();var tempVec3e$3=math.vec3();var tempVec3f$1=math.vec3();var tempVec3g$1=math.vec3();/**
17456
+ */function getSnapBatchingRenderers(scene){var sceneId=scene.id;var batchingRenderers=cachedRenderers$6[sceneId];if(!batchingRenderers){batchingRenderers=new SnapBatchingRenderers(scene);cachedRenderers$6[sceneId]=batchingRenderers;batchingRenderers._compile();batchingRenderers.eagerCreateRenders();scene.on("compile",function(){batchingRenderers._compile();batchingRenderers.eagerCreateRenders();});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$l=math.vec3();var tempVec3c$i=math.vec3();var tempVec3d$6=math.vec3();var tempVec3e$1=math.vec3();var tempVec3f$1=math.vec3();var tempVec3g$1=math.vec3();/**
17432
17457
  * @private
17433
17458
  */var TrianglesBatchingLayer=/*#__PURE__*/function(){/**
17434
17459
  * @param model
@@ -17525,91 +17550,91 @@ if(this._batchingRenderers.pickNormalsFlatRenderer){this._batchingRenderers.pick
17525
17550
  }},{key:"drawSnapInitDepthBuf",value:function drawSnapInitDepthBuf(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._snapBatchingRenderers.snapDepthBufInitRenderer){this._snapBatchingRenderers.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._snapBatchingRenderers.snapDepthRenderer){this._snapBatchingRenderers.snapDepthRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}//------------------------------------------------------------------------------------------------
17526
17551
  },{key:"precisionRayPickSurface",value:function precisionRayPickSurface(portionId,worldRayOrigin,worldRayDir,worldSurfacePos,worldNormal){if(!this.model.scene.pickSurfacePrecisionEnabled){return false;}var state=this._state;var portion=this._portions[portionId];if(!portion){this.model.error("portion not found: "+portionId);return false;}var positions=portion.quantizedPositions;var indices=portion.indices;var origin=state.origin;var offset=portion.offset;var rtcRayOrigin=tempVec3a$p;var rtcRayDir=tempVec3b$l;rtcRayOrigin.set(origin?math.subVec3(worldRayOrigin,origin,tempVec3c$i):worldRayOrigin);// World -> RTC
17527
17552
  rtcRayDir.set(worldRayDir);if(offset){math.subVec3(rtcRayOrigin,offset);}math.transformRay(this.model.worldNormalMatrix,rtcRayOrigin,rtcRayDir,rtcRayOrigin,rtcRayDir);// RTC -> local
17528
- var a=tempVec3d$e;var b=tempVec3e$3;var c=tempVec3f$1;var gotIntersect=false;var closestDist=0;var closestIntersectPos=tempVec3g$1;for(var _i226=0,len=indices.length;_i226<len;_i226+=3){var ia=indices[_i226]*3;var ib=indices[_i226+1]*3;var ic=indices[_i226+2]*3;a[0]=positions[ia];a[1]=positions[ia+1];a[2]=positions[ia+2];b[0]=positions[ib];b[1]=positions[ib+1];b[2]=positions[ib+2];c[0]=positions[ic];c[1]=positions[ic+1];c[2]=positions[ic+2];math.decompressPosition(a,state.positionsDecodeMatrix);math.decompressPosition(b,state.positionsDecodeMatrix);math.decompressPosition(c,state.positionsDecodeMatrix);if(math.rayTriangleIntersect(rtcRayOrigin,rtcRayDir,a,b,c,closestIntersectPos)){math.transformPoint3(this.model.worldMatrix,closestIntersectPos,closestIntersectPos);if(offset){math.addVec3(closestIntersectPos,offset);}if(origin){math.addVec3(closestIntersectPos,origin);}var dist=Math.abs(math.lenVec3(math.subVec3(closestIntersectPos,worldRayOrigin,[])));if(!gotIntersect||dist>closestDist){closestDist=dist;worldSurfacePos.set(closestIntersectPos);if(worldNormal){// Not that wasteful to eagerly compute - unlikely to hit >2 surfaces on most geometry
17553
+ var a=tempVec3d$6;var b=tempVec3e$1;var c=tempVec3f$1;var gotIntersect=false;var closestDist=0;var closestIntersectPos=tempVec3g$1;for(var _i226=0,len=indices.length;_i226<len;_i226+=3){var ia=indices[_i226]*3;var ib=indices[_i226+1]*3;var ic=indices[_i226+2]*3;a[0]=positions[ia];a[1]=positions[ia+1];a[2]=positions[ia+2];b[0]=positions[ib];b[1]=positions[ib+1];b[2]=positions[ib+2];c[0]=positions[ic];c[1]=positions[ic+1];c[2]=positions[ic+2];math.decompressPosition(a,state.positionsDecodeMatrix);math.decompressPosition(b,state.positionsDecodeMatrix);math.decompressPosition(c,state.positionsDecodeMatrix);if(math.rayTriangleIntersect(rtcRayOrigin,rtcRayDir,a,b,c,closestIntersectPos)){math.transformPoint3(this.model.worldMatrix,closestIntersectPos,closestIntersectPos);if(offset){math.addVec3(closestIntersectPos,offset);}if(origin){math.addVec3(closestIntersectPos,origin);}var dist=Math.abs(math.lenVec3(math.subVec3(closestIntersectPos,worldRayOrigin,[])));if(!gotIntersect||dist>closestDist){closestDist=dist;worldSurfacePos.set(closestIntersectPos);if(worldNormal){// Not that wasteful to eagerly compute - unlikely to hit >2 surfaces on most geometry
17529
17554
  math.triangleNormal(a,b,c,worldNormal);}gotIntersect=true;}}}if(gotIntersect&&worldNormal){math.transformVec3(this.model.worldNormalMatrix,worldNormal,worldNormal);math.normalizeVec3(worldNormal);}return gotIntersect;}// ---------
17530
17555
  },{key:"destroy",value:function destroy(){var state=this._state;if(state.positionsBuf){state.positionsBuf.destroy();state.positionsBuf=null;}if(state.offsetsBuf){state.offsetsBuf.destroy();state.offsetsBuf=null;}if(state.normalsBuf){state.normalsBuf.destroy();state.normalsBuf=null;}if(state.colorsBuf){state.colorsBuf.destroy();state.colorsBuf=null;}if(state.metallicRoughnessBuf){state.metallicRoughnessBuf.destroy();state.metallicRoughnessBuf=null;}if(state.flagsBuf){state.flagsBuf.destroy();state.flagsBuf=null;}if(state.pickColorsBuf){state.pickColorsBuf.destroy();state.pickColorsBuf=null;}if(state.indicesBuf){state.indicesBuf.destroy();state.indicessBuf=null;}if(state.edgeIndicesBuf){state.edgeIndicesBuf.destroy();state.edgeIndicessBuf=null;}state.destroy();}}]);return TrianglesBatchingLayer;}();/**
17531
17556
  * @private
17532
- */var TrianglesInstancingColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl18){_inherits(TrianglesInstancingColorRenderer,_VBOSceneModelTriangl18);var _super91=_createSuper(TrianglesInstancingColorRenderer);function TrianglesInstancingColorRenderer(){_classCallCheck(this,TrianglesInstancingColorRenderer);return _super91.apply(this,arguments);}_createClass(TrianglesInstancingColorRenderer,[{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(TrianglesInstancingColorRenderer.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 i;var len;var light;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec2 normal;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17557
+ */var TrianglesInstancingColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl18){_inherits(TrianglesInstancingColorRenderer,_VBOSceneModelTriangl18);var _super91=_createSuper(TrianglesInstancingColorRenderer);function TrianglesInstancingColorRenderer(){_classCallCheck(this,TrianglesInstancingColorRenderer);return _super91.apply(this,arguments);}_createClass(TrianglesInstancingColorRenderer,[{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(TrianglesInstancingColorRenderer.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.getNumAllocatedSectionPlanes()>0;var i;var len;var light;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec2 normal;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17533
17558
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("in vec4 modelNormalMatrixCol0;");src.push("in vec4 modelNormalMatrixCol1;");src.push("in vec4 modelNormalMatrixCol2;");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(i=0,len=lightsState.lights.length;i<len;i++){light=lightsState.lights[i];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+i+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+i+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+i+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+i+";");src.push("uniform vec3 lightDir"+i+";");}}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
17534
17559
  // renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
17535
17560
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17536
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 modelNormal = vec4(octDecode(normal.xy), 0.0); ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2), 0.0);");src.push("vec3 viewNormal = normalize(vec4(viewNormalMatrix * worldNormal).xyz);");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(i=0,len=lightsState.lights.length;i<len;i++){light=lightsState.lights[i];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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("// Instancing geometry drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i227=0,len=sectionPlanesState.sectionPlanes.length;_i227<len;_i227++){src.push("uniform bool sectionPlaneActive"+_i227+";");src.push("uniform vec3 sectionPlanePos"+_i227+";");src.push("uniform vec3 sectionPlaneDir"+_i227+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i228=0,_len45=sectionPlanesState.sectionPlanes.length;_i228<_len45;_i228++){src.push("if (sectionPlaneActive"+_i228+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i228+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i228+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17561
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 modelNormal = vec4(octDecode(normal.xy), 0.0); ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2), 0.0);");src.push("vec3 viewNormal = normalize(vec4(viewNormalMatrix * worldNormal).xyz);");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(i=0,len=lightsState.lights.length;i<len;i++){light=lightsState.lights[i];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec3 rgb = (vec3(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0));");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i227=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i227<len;_i227++){src.push("uniform bool sectionPlaneActive"+_i227+";");src.push("uniform vec3 sectionPlanePos"+_i227+";");src.push("uniform vec3 sectionPlaneDir"+_i227+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i228=0,_len45=sectionPlanesState.getNumAllocatedSectionPlanes();_i228<_len45;_i228++){src.push("if (sectionPlaneActive"+_i228+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i228+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i228+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17537
17562
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
17538
17563
  if(this._withSAO){src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");}else{src.push(" outColor = vColor;");}src.push("}");return src;}}]);return TrianglesInstancingColorRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17539
17564
  * @private
17540
- */var TrianglesInstancingFlatColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl19){_inherits(TrianglesInstancingFlatColorRenderer,_VBOSceneModelTriangl19);var _super92=_createSuper(TrianglesInstancingFlatColorRenderer);function TrianglesInstancingFlatColorRenderer(){_classCallCheck(this,TrianglesInstancingFlatColorRenderer);return _super92.apply(this,arguments);}_createClass(TrianglesInstancingFlatColorRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{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("// Instancing geometry flat-shading drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17565
+ */var TrianglesInstancingFlatColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl19){_inherits(TrianglesInstancingFlatColorRenderer,_VBOSceneModelTriangl19);var _super92=_createSuper(TrianglesInstancingFlatColorRenderer);function TrianglesInstancingFlatColorRenderer(){_classCallCheck(this,TrianglesInstancingFlatColorRenderer);return _super92.apply(this,arguments);}_createClass(TrianglesInstancingFlatColorRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry flat-shading drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17541
17566
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("out vec4 vColor;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17542
17567
  // renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
17543
17568
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17544
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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 lightsState=scene._lightsState;var i;var len;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry flat-shading drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i229=0,_len46=sectionPlanesState.sectionPlanes.length;_i229<_len46;_i229++){src.push("uniform bool sectionPlaneActive"+_i229+";");src.push("uniform vec3 sectionPlanePos"+_i229+";");src.push("uniform vec3 sectionPlaneDir"+_i229+";");}}this._addMatricesUniformBlockLines(src);src.push("uniform vec4 lightAmbient;");for(i=0,len=lightsState.lights.length;i<len;i++){var light=lightsState.lights[i];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+i+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+i+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+i+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+i+";");src.push("uniform vec3 lightDir"+i+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i230=0,_len47=sectionPlanesState.sectionPlanes.length;_i230<_len47;_i230++){src.push("if (sectionPlaneActive"+_i230+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i230+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i230+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(i=0,len=lightsState.lights.length;i<len;i++){var _light7=lightsState.lights[i];if(_light7.type==="ambient"){continue;}if(_light7.type==="dir"){if(_light7.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(_light7.type==="point"){if(_light7.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(_light7.type==="spot"){if(_light7.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17569
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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 lightsState=scene._lightsState;var i;var len;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry flat-shading drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i229=0,_len46=sectionPlanesState.getNumAllocatedSectionPlanes();_i229<_len46;_i229++){src.push("uniform bool sectionPlaneActive"+_i229+";");src.push("uniform vec3 sectionPlanePos"+_i229+";");src.push("uniform vec3 sectionPlaneDir"+_i229+";");}}this._addMatricesUniformBlockLines(src);src.push("uniform vec4 lightAmbient;");for(i=0,len=lightsState.lights.length;i<len;i++){var light=lightsState.lights[i];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+i+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+i+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+i+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+i+";");src.push("uniform vec3 lightDir"+i+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i230=0,_len47=sectionPlanesState.getNumAllocatedSectionPlanes();_i230<_len47;_i230++){src.push("if (sectionPlaneActive"+_i230+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i230+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i230+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(i=0,len=lightsState.lights.length;i<len;i++){var _light7=lightsState.lights[i];if(_light7.type==="ambient"){continue;}if(_light7.type==="dir"){if(_light7.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(_light7.type==="point"){if(_light7.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(_light7.type==="spot"){if(_light7.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec4 fragColor = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17545
17570
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
17546
17571
  src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(fragColor.rgb * ambient, 1.0);");}else{src.push(" outColor = fragColor;");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return TrianglesInstancingFlatColorRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17547
17572
  * @private
17548
17573
  */var TrianglesInstancingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl20){_inherits(TrianglesInstancingSilhouetteRenderer,_VBOSceneModelTriangl20);var _super93=_createSuper(TrianglesInstancingSilhouetteRenderer);function TrianglesInstancingSilhouetteRenderer(){_classCallCheck(this,TrianglesInstancingSilhouetteRenderer);return _super93.apply(this,arguments);}_createClass(TrianglesInstancingSilhouetteRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){// TODO color uniform true ???
17549
- _get(_getPrototypeOf(TrianglesInstancingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,instancingLayer,renderPass,{colorUniform:true});}},{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("// Instancing silhouette vertex shader");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 color;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17574
+ _get(_getPrototypeOf(TrianglesInstancingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,instancingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing silhouette vertex shader");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 color;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17550
17575
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);src.push("uniform vec4 silhouetteColor;");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("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// silhouetteFlag = NOT_RENDERED | SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
17551
17576
  // renderPass = SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
17552
17577
  src.push("int silhouetteFlag = int(flags) >> 4 & 0xF;");src.push("if (silhouetteFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17553
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, float(color.a) / 255.0));");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("// Instancing fill fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i231=0,len=sectionPlanesState.sectionPlanes.length;_i231<len;_i231++){src.push("uniform bool sectionPlaneActive"+_i231+";");src.push("uniform vec3 sectionPlanePos"+_i231+";");src.push("uniform vec3 sectionPlaneDir"+_i231+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i232=0,_len48=sectionPlanesState.sectionPlanes.length;_i232<_len48;_i232++){src.push("if (sectionPlaneActive"+_i232+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i232+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i232+".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;}}]);return TrianglesInstancingSilhouetteRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17578
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vColor = vec4(silhouetteColor.r, silhouetteColor.g, silhouetteColor.b, min(silhouetteColor.a, float(color.a) / 255.0));");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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing fill fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i231=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i231<len;_i231++){src.push("uniform bool sectionPlaneActive"+_i231+";");src.push("uniform vec3 sectionPlanePos"+_i231+";");src.push("uniform vec3 sectionPlaneDir"+_i231+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i232=0,_len48=sectionPlanesState.getNumAllocatedSectionPlanes();_i232<_len48;_i232++){src.push("if (sectionPlaneActive"+_i232+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i232+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i232+".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;}}]);return TrianglesInstancingSilhouetteRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17554
17579
  * @private
17555
- */var TrianglesInstancingEdgesRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl21){_inherits(TrianglesInstancingEdgesRenderer,_VBOSceneModelTriangl21);var _super94=_createSuper(TrianglesInstancingEdgesRenderer);function TrianglesInstancingEdgesRenderer(){_classCallCheck(this,TrianglesInstancingEdgesRenderer);return _super94.apply(this,arguments);}_createClass(TrianglesInstancingEdgesRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){_get(_getPrototypeOf(TrianglesInstancingEdgesRenderer.prototype),"drawLayer",this).call(this,frameCtx,instancingLayer,renderPass,{colorUniform:true});}},{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("// Triangles instancing edges vertex shader");src.push("uniform int renderPass;");src.push("uniform vec4 color;");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
17580
+ */var TrianglesInstancingEdgesRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl21){_inherits(TrianglesInstancingEdgesRenderer,_VBOSceneModelTriangl21);var _super94=_createSuper(TrianglesInstancingEdgesRenderer);function TrianglesInstancingEdgesRenderer(){_classCallCheck(this,TrianglesInstancingEdgesRenderer);return _super94.apply(this,arguments);}_createClass(TrianglesInstancingEdgesRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){_get(_getPrototypeOf(TrianglesInstancingEdgesRenderer.prototype),"drawLayer",this).call(this,frameCtx,instancingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles instancing edges vertex shader");src.push("uniform int renderPass;");src.push("uniform vec4 color;");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
17556
17581
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
17557
17582
  // renderPass = EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
17558
17583
  src.push("int edgeFlag = int(flags) >> 8 & 0xF;");src.push("if (edgeFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17559
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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");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("in float vFlags;");for(var _i233=0,len=sectionPlanesState.sectionPlanes.length;_i233<len;_i233++){src.push("uniform bool sectionPlaneActive"+_i233+";");src.push("uniform vec3 sectionPlanePos"+_i233+";");src.push("uniform vec3 sectionPlaneDir"+_i233+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i234=0,_len49=sectionPlanesState.sectionPlanes.length;_i234<_len49;_i234++){src.push("if (sectionPlaneActive"+_i234+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i234+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i234+".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;}}]);return TrianglesInstancingEdgesRenderer;}(VBOSceneModelTriangleInstancingEdgesRenderer);/**
17584
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry edges drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i233=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i233<len;_i233++){src.push("uniform bool sectionPlaneActive"+_i233+";");src.push("uniform vec3 sectionPlanePos"+_i233+";");src.push("uniform vec3 sectionPlaneDir"+_i233+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i234=0,_len49=sectionPlanesState.getNumAllocatedSectionPlanes();_i234<_len49;_i234++){src.push("if (sectionPlaneActive"+_i234+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i234+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i234+".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;}}]);return TrianglesInstancingEdgesRenderer;}(VBOSceneModelTriangleInstancingEdgesRenderer);/**
17560
17585
  * @private
17561
- */var TrianglesInstancingEdgesColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl22){_inherits(TrianglesInstancingEdgesColorRenderer,_VBOSceneModelTriangl22);var _super95=_createSuper(TrianglesInstancingEdgesColorRenderer);function TrianglesInstancingEdgesColorRenderer(){_classCallCheck(this,TrianglesInstancingEdgesColorRenderer);return _super95.apply(this,arguments);}_createClass(TrianglesInstancingEdgesColorRenderer,[{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("// Triangles instancing edges vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17586
+ */var TrianglesInstancingEdgesColorRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl22){_inherits(TrianglesInstancingEdgesColorRenderer,_VBOSceneModelTriangl22);var _super95=_createSuper(TrianglesInstancingEdgesColorRenderer);function TrianglesInstancingEdgesColorRenderer(){_classCallCheck(this,TrianglesInstancingEdgesColorRenderer);return _super95.apply(this,arguments);}_createClass(TrianglesInstancingEdgesColorRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles instancing edges vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17562
17587
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// edgeFlag = NOT_RENDERED | EDGES_COLOR_OPAQUE | EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
17563
17588
  // renderPass = EDGES_HIGHLIGHTED | EDGES_XRAYED | EDGES_SELECTED
17564
17589
  src.push("int edgeFlag = int(flags) >> 8 & 0xF;");src.push("if (edgeFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17565
17590
  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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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(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);");
17566
- src.push("vColor = vec4(float(color.r*0.5) / 255.0, float(color.g*0.5) / 255.0, float(color.b*0.5) / 255.0, float(color.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");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("in float vFlags;");for(var _i235=0,len=sectionPlanesState.sectionPlanes.length;_i235<len;_i235++){src.push("uniform bool sectionPlaneActive"+_i235+";");src.push("uniform vec3 sectionPlanePos"+_i235+";");src.push("uniform vec3 sectionPlaneDir"+_i235+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i236=0,_len50=sectionPlanesState.sectionPlanes.length;_i236<_len50;_i236++){src.push("if (sectionPlaneActive"+_i236+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i236+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i236+".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;}}]);return TrianglesInstancingEdgesColorRenderer;}(VBOSceneModelTriangleInstancingEdgesRenderer);/**
17591
+ src.push("vColor = vec4(float(color.r*0.5) / 255.0, float(color.g*0.5) / 255.0, float(color.b*0.5) / 255.0, float(color.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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry edges drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i235=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i235<len;_i235++){src.push("uniform bool sectionPlaneActive"+_i235+";");src.push("uniform vec3 sectionPlanePos"+_i235+";");src.push("uniform vec3 sectionPlaneDir"+_i235+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i236=0,_len50=sectionPlanesState.getNumAllocatedSectionPlanes();_i236<_len50;_i236++){src.push("if (sectionPlaneActive"+_i236+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i236+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i236+".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;}}]);return TrianglesInstancingEdgesColorRenderer;}(VBOSceneModelTriangleInstancingEdgesRenderer);/**
17567
17592
  * @private
17568
- */var TrianglesInstancingPickMeshRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl23){_inherits(TrianglesInstancingPickMeshRenderer,_VBOSceneModelTriangl23);var _super96=_createSuper(TrianglesInstancingPickMeshRenderer);function TrianglesInstancingPickMeshRenderer(){_classCallCheck(this,TrianglesInstancingPickMeshRenderer);return _super96.apply(this,arguments);}_createClass(TrianglesInstancingPickMeshRenderer,[{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("// Instancing geometry picking vertex shader");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 pickColor;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17593
+ */var TrianglesInstancingPickMeshRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl23){_inherits(TrianglesInstancingPickMeshRenderer,_VBOSceneModelTriangl23);var _super96=_createSuper(TrianglesInstancingPickMeshRenderer);function TrianglesInstancingPickMeshRenderer(){_classCallCheck(this,TrianglesInstancingPickMeshRenderer);return _super96.apply(this,arguments);}_createClass(TrianglesInstancingPickMeshRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry picking vertex shader");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 pickColor;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17569
17594
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src);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("out float vFlags;");}src.push("out vec4 vPickColor;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17570
17595
  // renderPass = PICK
17571
17596
  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
17572
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vPickColor = vec4(float(pickColor.r) / 255.0, float(pickColor.g) / 255.0, float(pickColor.b) / 255.0, float(pickColor.a) / 255.0);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(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("// Batched geometry picking fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i237=0;_i237<sectionPlanesState.sectionPlanes.length;_i237++){src.push("uniform bool sectionPlaneActive"+_i237+";");src.push("uniform vec3 sectionPlanePos"+_i237+";");src.push("uniform vec3 sectionPlaneDir"+_i237+";");}}src.push("in vec4 vPickColor;");src.push("out vec4 outColor;");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 _i238=0;_i238<sectionPlanesState.sectionPlanes.length;_i238++){src.push("if (sectionPlaneActive"+_i238+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i238+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i238+".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 = vPickColor; ");src.push("}");return src;}}]);return TrianglesInstancingPickMeshRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17597
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vPickColor = vec4(float(pickColor.r) / 255.0, float(pickColor.g) / 255.0, float(pickColor.b) / 255.0, float(pickColor.a) / 255.0);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(clipPos);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry picking fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i237=0;_i237<sectionPlanesState.getNumAllocatedSectionPlanes();_i237++){src.push("uniform bool sectionPlaneActive"+_i237+";");src.push("uniform vec3 sectionPlanePos"+_i237+";");src.push("uniform vec3 sectionPlaneDir"+_i237+";");}}src.push("in vec4 vPickColor;");src.push("out vec4 outColor;");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 _i238=0;_i238<sectionPlanesState.getNumAllocatedSectionPlanes();_i238++){src.push("if (sectionPlaneActive"+_i238+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i238+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i238+".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 = vPickColor; ");src.push("}");return src;}}]);return TrianglesInstancingPickMeshRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17573
17598
  * @private
17574
- */var TrianglesInstancingPickDepthRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl24){_inherits(TrianglesInstancingPickDepthRenderer,_VBOSceneModelTriangl24);var _super97=_createSuper(TrianglesInstancingPickDepthRenderer);function TrianglesInstancingPickDepthRenderer(){_classCallCheck(this,TrianglesInstancingPickDepthRenderer);return _super97.apply(this,arguments);}_createClass(TrianglesInstancingPickDepthRenderer,[{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("// Instancing geometry depth vertex shader");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
17599
+ */var TrianglesInstancingPickDepthRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl24){_inherits(TrianglesInstancingPickDepthRenderer,_VBOSceneModelTriangl24);var _super97=_createSuper(TrianglesInstancingPickDepthRenderer);function TrianglesInstancingPickDepthRenderer(){_classCallCheck(this,TrianglesInstancingPickDepthRenderer);return _super97.apply(this,arguments);}_createClass(TrianglesInstancingPickDepthRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry depth vertex shader");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
17575
17600
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src);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("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17576
17601
  // renderPass = PICK
17577
17602
  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
17578
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(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("// Batched geometry 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("in float vFlags;");for(var _i239=0;_i239<sectionPlanesState.sectionPlanes.length;_i239++){src.push("uniform bool sectionPlaneActive"+_i239+";");src.push("uniform vec3 sectionPlanePos"+_i239+";");src.push("uniform vec3 sectionPlaneDir"+_i239+";");}}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 outColor;");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 _i240=0;_i240<sectionPlanesState.sectionPlanes.length;_i240++){src.push("if (sectionPlaneActive"+_i240+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i240+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i240+".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(" outColor = packDepth(zNormalizedDepth); ");// Must be linear depth
17603
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}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 = remapClipPos(clipPos);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry 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("in float vFlags;");for(var _i239=0;_i239<sectionPlanesState.getNumAllocatedSectionPlanes();_i239++){src.push("uniform bool sectionPlaneActive"+_i239+";");src.push("uniform vec3 sectionPlanePos"+_i239+";");src.push("uniform vec3 sectionPlaneDir"+_i239+";");}}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 outColor;");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 _i240=0;_i240<sectionPlanesState.getNumAllocatedSectionPlanes();_i240++){src.push("if (sectionPlaneActive"+_i240+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i240+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i240+".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(" outColor = packDepth(zNormalizedDepth); ");// Must be linear depth
17579
17604
  src.push("}");return src;}}]);return TrianglesInstancingPickDepthRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17580
17605
  * @private
17581
- */var TrianglesInstancingPickNormalsRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl25){_inherits(TrianglesInstancingPickNormalsRenderer,_VBOSceneModelTriangl25);var _super98=_createSuper(TrianglesInstancingPickNormalsRenderer);function TrianglesInstancingPickNormalsRenderer(){_classCallCheck(this,TrianglesInstancingPickNormalsRenderer);return _super98.apply(this,arguments);}_createClass(TrianglesInstancingPickNormalsRenderer,[{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("// Instancing geometry normals vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec2 normal;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17606
+ */var TrianglesInstancingPickNormalsRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl25){_inherits(TrianglesInstancingPickNormalsRenderer,_VBOSceneModelTriangl25);var _super98=_createSuper(TrianglesInstancingPickNormalsRenderer);function TrianglesInstancingPickNormalsRenderer(){_classCallCheck(this,TrianglesInstancingPickNormalsRenderer);return _super98.apply(this,arguments);}_createClass(TrianglesInstancingPickNormalsRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry normals vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec2 normal;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17582
17607
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("in vec4 modelNormalMatrixCol0;");src.push("in vec4 modelNormalMatrixCol1;");src.push("in vec4 modelNormalMatrixCol2;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src,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("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 vec3 vWorldNormal;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17583
17608
  // renderPass = PICK
17584
17609
  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
17585
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec4 modelNormal = vec4(octDecode(normal.xy), 0.0); ");src.push(" vec3 worldNormal = vec3(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2));");src.push(" vWorldNormal = worldNormal;");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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 = remapClipPos(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("// Batched geometry normals fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i241=0;_i241<sectionPlanesState.sectionPlanes.length;_i241++){src.push("uniform bool sectionPlaneActive"+_i241+";");src.push("uniform vec3 sectionPlanePos"+_i241+";");src.push("uniform vec3 sectionPlaneDir"+_i241+";");}}src.push("in vec3 vWorldNormal;");src.push("out highp ivec4 outNormal;");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(" outNormal = ivec4(vWorldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("}");return src;}}]);return TrianglesInstancingPickNormalsRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17610
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec4 modelNormal = vec4(octDecode(normal.xy), 0.0); ");src.push(" vec3 worldNormal = vec3(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2));");src.push(" vWorldNormal = worldNormal;");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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 = remapClipPos(clipPos);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry normals fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i241=0;_i241<sectionPlanesState.getNumAllocatedSectionPlanes();_i241++){src.push("uniform bool sectionPlaneActive"+_i241+";");src.push("uniform vec3 sectionPlanePos"+_i241+";");src.push("uniform vec3 sectionPlaneDir"+_i241+";");}}src.push("in vec3 vWorldNormal;");src.push("out highp ivec4 outNormal;");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.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outNormal = ivec4(vWorldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("}");return src;}}]);return TrianglesInstancingPickNormalsRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17586
17611
  * @private
17587
- */var TrianglesInstancingOcclusionRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl26){_inherits(TrianglesInstancingOcclusionRenderer,_VBOSceneModelTriangl26);var _super99=_createSuper(TrianglesInstancingOcclusionRenderer);function TrianglesInstancingOcclusionRenderer(){_classCallCheck(this,TrianglesInstancingOcclusionRenderer);return _super99.apply(this,arguments);}_createClass(TrianglesInstancingOcclusionRenderer,[{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("// TrianglesInstancingOcclusionRenderer vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17612
+ */var TrianglesInstancingOcclusionRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl26){_inherits(TrianglesInstancingOcclusionRenderer,_VBOSceneModelTriangl26);var _super99=_createSuper(TrianglesInstancingOcclusionRenderer);function TrianglesInstancingOcclusionRenderer(){_classCallCheck(this,TrianglesInstancingOcclusionRenderer);return _super99.apply(this,arguments);}_createClass(TrianglesInstancingOcclusionRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// TrianglesInstancingOcclusionRenderer vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17588
17613
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17589
17614
  // renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
17590
- src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");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("// TrianglesInstancingOcclusionRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i242=0;_i242<sectionPlanesState.sectionPlanes.length;_i242++){src.push("uniform bool sectionPlaneActive"+_i242+";");src.push("uniform vec3 sectionPlanePos"+_i242+";");src.push("uniform vec3 sectionPlaneDir"+_i242+";");}}src.push("out vec4 outColor;");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 _i243=0;_i243<sectionPlanesState.sectionPlanes.length;_i243++){src.push("if (sectionPlaneActive"+_i243+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i243+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i243+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
17615
+ src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// TrianglesInstancingOcclusionRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i242=0;_i242<sectionPlanesState.getNumAllocatedSectionPlanes();_i242++){src.push("uniform bool sectionPlaneActive"+_i242+";");src.push("uniform vec3 sectionPlanePos"+_i242+";");src.push("uniform vec3 sectionPlaneDir"+_i242+";");}}src.push("out vec4 outColor;");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 _i243=0;_i243<sectionPlanesState.getNumAllocatedSectionPlanes();_i243++){src.push("if (sectionPlaneActive"+_i243+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i243+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i243+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
17591
17616
  src.push("}");return src;}}]);return TrianglesInstancingOcclusionRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17592
17617
  * @private
17593
- */var TrianglesInstancingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl27){_inherits(TrianglesInstancingDepthRenderer,_VBOSceneModelTriangl27);var _super100=_createSuper(TrianglesInstancingDepthRenderer);function TrianglesInstancingDepthRenderer(){_classCallCheck(this,TrianglesInstancingDepthRenderer);return _super100.apply(this,arguments);}_createClass(TrianglesInstancingDepthRenderer,[{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("// Instancing geometry depth drawing vertex shader");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;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec2 vHighPrecisionZW;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17618
+ */var TrianglesInstancingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl27){_inherits(TrianglesInstancingDepthRenderer,_VBOSceneModelTriangl27);var _super100=_createSuper(TrianglesInstancingDepthRenderer);function TrianglesInstancingDepthRenderer(){_classCallCheck(this,TrianglesInstancingDepthRenderer);return _super100.apply(this,arguments);}_createClass(TrianglesInstancingDepthRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry depth drawing vertex shader");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;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);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("out float vFlags;");}src.push("out vec2 vHighPrecisionZW;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17594
17619
  // renderPass = COLOR_OPAQUE
17595
17620
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17596
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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("vHighPrecisionZW = gl_Position.zw;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var i;var len;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry depth drawing fragment shader");src.push("precision highp float;");src.push("precision highp int;");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("in float vFlags;");for(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec2 vHighPrecisionZW;");src.push("out vec4 outColor;");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(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;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 fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");src.push(" outColor = vec4(vec3(1.0 - fragCoordZ), 1.0); ");src.push("}");return src;}}]);return TrianglesInstancingDepthRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17621
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}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("vHighPrecisionZW = gl_Position.zw;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var i;var len;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry depth drawing fragment shader");src.push("precision highp float;");src.push("precision highp int;");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("in float vFlags;");for(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec2 vHighPrecisionZW;");src.push("out vec4 outColor;");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(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;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 fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");src.push(" outColor = vec4(vec3(1.0 - fragCoordZ), 1.0); ");src.push("}");return src;}}]);return TrianglesInstancingDepthRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17597
17622
  * @private
17598
- */var TrianglesInstancingNormalsRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl28){_inherits(TrianglesInstancingNormalsRenderer,_VBOSceneModelTriangl28);var _super101=_createSuper(TrianglesInstancingNormalsRenderer);function TrianglesInstancingNormalsRenderer(){_classCallCheck(this,TrianglesInstancingNormalsRenderer);return _super101.apply(this,arguments);}_createClass(TrianglesInstancingNormalsRenderer,[{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("// Instancing geometry normals drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec3 normal;");src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");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("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 vec3 vViewNormal;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17623
+ */var TrianglesInstancingNormalsRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl28){_inherits(TrianglesInstancingNormalsRenderer,_VBOSceneModelTriangl28);var _super101=_createSuper(TrianglesInstancingNormalsRenderer);function TrianglesInstancingNormalsRenderer(){_classCallCheck(this,TrianglesInstancingNormalsRenderer);return _super101.apply(this,arguments);}_createClass(TrianglesInstancingNormalsRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry normals drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec3 normal;");src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");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("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 vec3 vViewNormal;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17599
17624
  // renderPass = COLOR_OPAQUE
17600
- src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push(" vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push(" vViewNormal = viewNormal;");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("// Instancing geometry depth drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i244=0,len=sectionPlanesState.sectionPlanes.length;_i244<len;_i244++){src.push("uniform bool sectionPlaneActive"+_i244+";");src.push("uniform vec3 sectionPlanePos"+_i244+";");src.push("uniform vec3 sectionPlaneDir"+_i244+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("out vec4 outColor;");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 _i245=0,_len51=sectionPlanesState.sectionPlanes.length;_i245<_len51;_i245++){src.push("if (sectionPlaneActive"+_i245+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i245+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i245+".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 = vec4(packNormalToRGB(vViewNormal), 1.0); ");src.push("}");return src;}}]);return TrianglesInstancingNormalsRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17625
+ src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push(" vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push(" vViewNormal = viewNormal;");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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry depth drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i244=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i244<len;_i244++){src.push("uniform bool sectionPlaneActive"+_i244+";");src.push("uniform vec3 sectionPlanePos"+_i244+";");src.push("uniform vec3 sectionPlaneDir"+_i244+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("out vec4 outColor;");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 _i245=0,_len51=sectionPlanesState.getNumAllocatedSectionPlanes();_i245<_len51;_i245++){src.push("if (sectionPlaneActive"+_i245+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i245+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i245+".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 = vec4(packNormalToRGB(vViewNormal), 1.0); ");src.push("}");return src;}}]);return TrianglesInstancingNormalsRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17601
17626
  * Renders InstancingLayer fragment depths to a shadow map.
17602
17627
  *
17603
17628
  * @private
17604
- */var TrianglesInstancingShadowRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl29){_inherits(TrianglesInstancingShadowRenderer,_VBOSceneModelTriangl29);var _super102=_createSuper(TrianglesInstancingShadowRenderer);function TrianglesInstancingShadowRenderer(){_classCallCheck(this,TrianglesInstancingShadowRenderer);return _super102.apply(this,arguments);}_createClass(TrianglesInstancingShadowRenderer,[{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("// Instancing geometry shadow drawing vertex shader");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");this._addMatricesUniformBlockLines(src);if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");src.push("int colorFlag = int(flags) & 0xF;");src.push("bool visible = (colorFlag > 0);");src.push("bool transparent = ((float(color.a) / 255.0) < 1.0);");src.push("if (!visible || transparent) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17605
- src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push(" gl_Position = shadowProjMatrix * viewPosition;");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("// Instancing geometry depth drawing 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i246=0,len=sectionPlanesState.sectionPlanes.length;_i246<len;_i246++){src.push("uniform bool sectionPlaneActive"+_i246+";");src.push("uniform vec3 sectionPlanePos"+_i246+";");src.push("uniform vec3 sectionPlaneDir"+_i246+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("out vec4 outColor;");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 _i247=0,_len52=sectionPlanesState.sectionPlanes.length;_i247<_len52;_i247++){src.push("if (sectionPlaneActive"+_i247+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i247+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i247+".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;");}src.push(" outColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");src.push("}");return src;}}]);return TrianglesInstancingShadowRenderer;}(VBOSceneModelTriangleInstancingRenderer);var TEXTURE_DECODE_FUNCS={};TEXTURE_DECODE_FUNCS[LinearEncoding]="linearToLinear";TEXTURE_DECODE_FUNCS[sRGBEncoding]="sRGBToLinear";/**
17629
+ */var TrianglesInstancingShadowRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl29){_inherits(TrianglesInstancingShadowRenderer,_VBOSceneModelTriangl29);var _super102=_createSuper(TrianglesInstancingShadowRenderer);function TrianglesInstancingShadowRenderer(){_classCallCheck(this,TrianglesInstancingShadowRenderer);return _super102.apply(this,arguments);}_createClass(TrianglesInstancingShadowRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry shadow drawing vertex shader");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");this._addMatricesUniformBlockLines(src);if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");src.push("int colorFlag = int(flags) & 0xF;");src.push("bool visible = (colorFlag > 0);");src.push("bool transparent = ((float(color.a) / 255.0) < 1.0);");src.push("if (!visible || transparent) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17630
+ src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push(" gl_Position = shadowProjMatrix * viewPosition;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry depth drawing 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i246=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i246<len;_i246++){src.push("uniform bool sectionPlaneActive"+_i246+";");src.push("uniform vec3 sectionPlanePos"+_i246+";");src.push("uniform vec3 sectionPlaneDir"+_i246+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("out vec4 outColor;");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 _i247=0,_len52=sectionPlanesState.getNumAllocatedSectionPlanes();_i247<_len52;_i247++){src.push("if (sectionPlaneActive"+_i247+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i247+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i247+".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;");}src.push(" outColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");src.push("}");return src;}}]);return TrianglesInstancingShadowRenderer;}(VBOSceneModelTriangleInstancingRenderer);var TEXTURE_DECODE_FUNCS={};TEXTURE_DECODE_FUNCS[LinearEncoding]="linearToLinear";TEXTURE_DECODE_FUNCS[sRGBEncoding]="sRGBToLinear";/**
17606
17631
  * @private
17607
- */var TrianglesInstancingPBRRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl30){_inherits(TrianglesInstancingPBRRenderer,_VBOSceneModelTriangl30);var _super103=_createSuper(TrianglesInstancingPBRRenderer);function TrianglesInstancingPBRRenderer(){_classCallCheck(this,TrianglesInstancingPBRRenderer);return _super103.apply(this,arguments);}_createClass(TrianglesInstancingPBRRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesInstancingPBRRenderer.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 clippingCaps=sectionPlanesState.clippingCaps;var src=[];src.push("#version 300 es");src.push("// Instancing geometry quality drawing 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 vec2 uv;");src.push("in vec2 metallicRoughness;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17632
+ */var TrianglesInstancingPBRRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl30){_inherits(TrianglesInstancingPBRRenderer,_VBOSceneModelTriangl30);var _super103=_createSuper(TrianglesInstancingPBRRenderer);function TrianglesInstancingPBRRenderer(){_classCallCheck(this,TrianglesInstancingPBRRenderer);return _super103.apply(this,arguments);}_createClass(TrianglesInstancingPBRRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesInstancingPBRRenderer.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.getNumAllocatedSectionPlanes()>0;var clippingCaps=sectionPlanesState.clippingCaps;var src=[];src.push("#version 300 es");src.push("// Instancing geometry quality drawing 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 vec2 uv;");src.push("in vec2 metallicRoughness;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17608
17633
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("in vec4 modelNormalMatrixCol0;");src.push("in vec4 modelNormalMatrixCol1;");src.push("in vec4 modelNormalMatrixCol2;");this._addMatricesUniformBlockLines(src,true);src.push("uniform mat3 uvDecodeMatrix;");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("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("}");src.push("out vec4 vViewPosition;");src.push("out vec3 vViewNormal;");src.push("out vec4 vColor;");src.push("out vec2 vUV;");src.push("out vec2 vMetallicRoughness;");if(lightsState.lightMaps.length>0){src.push("out vec3 vWorldNormal;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");if(clippingCaps){src.push("out vec4 vClipPosition;");}}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17609
17634
  // renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
17610
17635
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17611
17636
  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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 modelNormal = vec4(octDecode(normal.xy), 0.0); ");src.push("vec4 worldNormal = worldNormalMatrix * vec4(dot(modelNormal, modelNormalMatrixCol0), dot(modelNormal, modelNormalMatrixCol1), dot(modelNormal, modelNormalMatrixCol2), 1.0);");src.push("vec3 viewNormal = vec4(viewNormalMatrix * worldNormal).xyz;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");if(clippingCaps){src.push("vClipPosition = clipPos;");}}src.push("vViewPosition = viewPosition;");src.push("vViewNormal = viewNormal;");src.push("vColor = color;");src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");src.push("vMetallicRoughness = metallicRoughness;");if(lightsState.lightMaps.length>0){src.push("vWorldNormal = worldNormal.xyz;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var gammaOutput=scene.gammaOutput;// If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
17612
- var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.sectionPlanes.length>0;var clippingCaps=sectionPlanesState.clippingCaps;var src=[];src.push("#version 300 es");src.push("// Instancing geometry quality drawing 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 sampler2D uColorMap;");src.push("uniform sampler2D uMetallicRoughMap;");src.push("uniform sampler2D uEmissiveMap;");src.push("uniform sampler2D uNormalMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(lightsState.reflectionMaps.length>0){src.push("uniform samplerCube reflectionMap;");}if(lightsState.lightMaps.length>0){src.push("uniform samplerCube lightMap;");}src.push("uniform vec4 lightAmbient;");for(var _i248=0,len=lightsState.lights.length;_i248<len;_i248++){var light=lightsState.lights[_i248];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i248+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i248+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i248+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i248+";");src.push("uniform vec3 lightDir"+_i248+";");}}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");if(clippingCaps){src.push("in vec4 vClipPosition;");}for(var _i249=0,_len53=sectionPlanesState.sectionPlanes.length;_i249<_len53;_i249++){src.push("uniform bool sectionPlaneActive"+_i249+";");src.push("uniform vec3 sectionPlanePos"+_i249+";");src.push("uniform vec3 sectionPlaneDir"+_i249+";");}}src.push("in vec4 vViewPosition;");src.push("in vec3 vViewNormal;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("in vec2 vMetallicRoughness;");if(lightsState.lightMaps.length>0){src.push("in vec3 vWorldNormal;");}this._addMatricesUniformBlockLines(src,true);// CONSTANT DEFINITIONS
17637
+ var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var clippingCaps=sectionPlanesState.clippingCaps;var src=[];src.push("#version 300 es");src.push("// Instancing geometry quality drawing 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 sampler2D uColorMap;");src.push("uniform sampler2D uMetallicRoughMap;");src.push("uniform sampler2D uEmissiveMap;");src.push("uniform sampler2D uNormalMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(lightsState.reflectionMaps.length>0){src.push("uniform samplerCube reflectionMap;");}if(lightsState.lightMaps.length>0){src.push("uniform samplerCube lightMap;");}src.push("uniform vec4 lightAmbient;");for(var _i248=0,len=lightsState.lights.length;_i248<len;_i248++){var light=lightsState.lights[_i248];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i248+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i248+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i248+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i248+";");src.push("uniform vec3 lightDir"+_i248+";");}}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");if(clippingCaps){src.push("in vec4 vClipPosition;");}for(var _i249=0,_len53=sectionPlanesState.getNumAllocatedSectionPlanes();_i249<_len53;_i249++){src.push("uniform bool sectionPlaneActive"+_i249+";");src.push("uniform vec3 sectionPlanePos"+_i249+";");src.push("uniform vec3 sectionPlaneDir"+_i249+";");}}src.push("in vec4 vViewPosition;");src.push("in vec3 vViewNormal;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("in vec2 vMetallicRoughness;");if(lightsState.lightMaps.length>0){src.push("in vec3 vWorldNormal;");}this._addMatricesUniformBlockLines(src,true);// CONSTANT DEFINITIONS
17613
17638
  src.push("#define PI 3.14159265359");src.push("#define RECIPROCAL_PI 0.31830988618");src.push("#define RECIPROCAL_PI2 0.15915494");src.push("#define EPSILON 1e-6");src.push("#define saturate(a) clamp( a, 0.0, 1.0 )");// UTILITY DEFINITIONS
17614
17639
  src.push("vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {");src.push(" vec3 texel = texture( uNormalMap, uv ).xyz;");src.push(" if (texel.r == 0.0 && texel.g == 0.0 && texel.b == 0.0) {");src.push(" return normalize(surf_norm );");src.push(" }");src.push(" vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );");src.push(" vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );");src.push(" vec2 st0 = dFdx( uv.st );");src.push(" vec2 st1 = dFdy( uv.st );");src.push(" vec3 S = normalize( q0 * st1.t - q1 * st0.t );");src.push(" vec3 T = normalize( -q0 * st1.s + q1 * st0.s );");src.push(" vec3 N = normalize( surf_norm );");src.push(" vec3 mapN = texel.xyz * 2.0 - 1.0;");src.push(" mat3 tsn = mat3( S, T, N );");// src.push(" mapN *= 3.0;");
17615
17640
  src.push(" return normalize( tsn * mapN );");src.push("}");src.push("vec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {");src.push(" return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );");src.push("}");// STRUCTURES
@@ -17618,25 +17643,25 @@ src.push("};");// IRRADIANCE EVALUATION
17618
17643
  src.push("float GGXRoughnessToBlinnExponent(const in float ggxRoughness) {");src.push(" float r = ggxRoughness + 0.0001;");src.push(" return (2.0 / (r * r) - 2.0);");src.push("}");src.push("float getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {");src.push(" float maxMIPLevelScalar = float( maxMIPLevel );");src.push(" float desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( ( blinnShininessExponent * blinnShininessExponent ) + 1.0 );");src.push(" return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );");src.push("}");if(lightsState.reflectionMaps.length>0){src.push("vec3 getLightProbeIndirectRadiance(const in vec3 reflectVec, const in float blinnShininessExponent, const in int maxMIPLevel) {");src.push(" float mipLevel = 0.5 * getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);");//TODO: a random factor - fix this
17619
17644
  src.push(" vec3 envMapColor = "+TEXTURE_DECODE_FUNCS[lightsState.reflectionMaps[0].encoding]+"(texture(reflectionMap, reflectVec, mipLevel)).rgb;");src.push(" return envMapColor;");src.push("}");}// SPECULAR BRDF EVALUATION
17620
17645
  src.push("vec3 F_Schlick(const in vec3 specularColor, const in float dotLH) {");src.push(" float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );");src.push(" return ( 1.0 - specularColor ) * fresnel + specularColor;");src.push("}");src.push("float G_GGX_Smith(const in float alpha, const in float dotNL, const in float dotNV) {");src.push(" float a2 = ( alpha * alpha );");src.push(" float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );");src.push(" float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );");src.push(" return 1.0 / ( gl * gv );");src.push("}");src.push("float G_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {");src.push(" float a2 = ( alpha * alpha );");src.push(" float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * ( dotNV * dotNV ) );");src.push(" float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * ( dotNL * dotNL ) );");src.push(" return 0.5 / max( gv + gl, EPSILON );");src.push("}");src.push("float D_GGX(const in float alpha, const in float dotNH) {");src.push(" float a2 = ( alpha * alpha );");src.push(" float denom = ( dotNH * dotNH) * ( a2 - 1.0 ) + 1.0;");src.push(" return RECIPROCAL_PI * a2 / ( denom * denom);");src.push("}");src.push("vec3 BRDF_Specular_GGX(const in IncidentLight incidentLight, const in Geometry geometry, const in vec3 specularColor, const in float roughness) {");src.push(" float alpha = ( roughness * roughness );");src.push(" vec3 halfDir = normalize( incidentLight.direction + geometry.viewEyeDir );");src.push(" float dotNL = saturate( dot( geometry.viewNormal, incidentLight.direction ) );");src.push(" float dotNV = saturate( dot( geometry.viewNormal, geometry.viewEyeDir ) );");src.push(" float dotNH = saturate( dot( geometry.viewNormal, halfDir ) );");src.push(" float dotLH = saturate( dot( incidentLight.direction, halfDir ) );");src.push(" vec3 F = F_Schlick( specularColor, dotLH );");src.push(" float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );");src.push(" float D = D_GGX( alpha, dotNH );");src.push(" return F * (G * D);");src.push("}");src.push("vec3 BRDF_Specular_GGX_Environment(const in Geometry geometry, const in vec3 specularColor, const in float roughness) {");src.push(" float dotNV = saturate(dot(geometry.viewNormal, geometry.viewEyeDir));");src.push(" const vec4 c0 = vec4( -1, -0.0275, -0.572, 0.022);");src.push(" const vec4 c1 = vec4( 1, 0.0425, 1.04, -0.04);");src.push(" vec4 r = roughness * c0 + c1;");src.push(" float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;");src.push(" vec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;");src.push(" return specularColor * AB.x + AB.y;");src.push("}");if(lightsState.lightMaps.length>0||lightsState.reflectionMaps.length>0){src.push("void computePBRLightMapping(const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");if(lightsState.lightMaps.length>0){src.push(" vec3 irradiance = "+TEXTURE_DECODE_FUNCS[lightsState.lightMaps[0].encoding]+"(texture(lightMap, geometry.worldNormal)).rgb;");src.push(" irradiance *= PI;");src.push(" vec3 diffuseBRDFContrib = (RECIPROCAL_PI * material.diffuseColor);");src.push(" reflectedLight.diffuse += irradiance * diffuseBRDFContrib;");}if(lightsState.reflectionMaps.length>0){src.push(" vec3 reflectVec = reflect(geometry.viewEyeDir, geometry.viewNormal);");src.push(" reflectVec = inverseTransformDirection(reflectVec, viewMatrix);");src.push(" float blinnExpFromRoughness = GGXRoughnessToBlinnExponent(material.specularRoughness);");src.push(" vec3 radiance = getLightProbeIndirectRadiance(reflectVec, blinnExpFromRoughness, 8);");src.push(" vec3 specularBRDFContrib = BRDF_Specular_GGX_Environment(geometry, material.specularColor, material.specularRoughness);");src.push(" reflectedLight.specular += radiance * specularBRDFContrib;");}src.push("}");}// MAIN LIGHTING COMPUTATION FUNCTION
17621
- src.push("void computePBRLighting(const in IncidentLight incidentLight, const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");src.push(" float dotNL = saturate(dot(geometry.viewNormal, incidentLight.direction));");src.push(" vec3 irradiance = dotNL * incidentLight.color * PI;");src.push(" reflectedLight.diffuse += irradiance * (RECIPROCAL_PI * material.diffuseColor);");src.push(" reflectedLight.specular += irradiance * BRDF_Specular_GGX(incidentLight, geometry, material.specularColor, material.specularRoughness);");src.push("}");src.push("out vec4 outColor;");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 _i250=0,_len54=sectionPlanesState.sectionPlanes.length;_i250<_len54;_i250++){src.push("if (sectionPlaneActive"+_i250+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i250+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i250+".xyz), 0.0, 1000.0);");src.push("}");}if(clippingCaps){src.push(" if (dist > (0.002 * vClipPosition.w)) {");src.push(" discard;");src.push(" }");src.push(" if (dist > 0.0) { ");src.push(" outColor=vec4(1.0, 0.0, 0.0, 1.0);");if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" return;");src.push("}");}else{src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");}src.push("}");}src.push("IncidentLight light;");src.push("Material material;");src.push("Geometry geometry;");src.push("ReflectedLight reflectedLight = ReflectedLight(vec3(0.0,0.0,0.0), vec3(0.0,0.0,0.0));");src.push("vec3 rgb = (vec3(float(vColor.r) / 255.0, float(vColor.g) / 255.0, float(vColor.b) / 255.0));");src.push("float opacity = float(vColor.a) / 255.0;");src.push("vec3 baseColor = rgb;");src.push("float specularF0 = 1.0;");src.push("float metallic = float(vMetallicRoughness.r) / 255.0;");src.push("float roughness = float(vMetallicRoughness.g) / 255.0;");src.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;");src.push("vec4 colorTexel = sRGBToLinear(texture(uColorMap, vUV));");src.push("baseColor *= colorTexel.rgb;");// src.push("opacity = colorTexel.a;");
17646
+ src.push("void computePBRLighting(const in IncidentLight incidentLight, const in Geometry geometry, const in Material material, inout ReflectedLight reflectedLight) {");src.push(" float dotNL = saturate(dot(geometry.viewNormal, incidentLight.direction));");src.push(" vec3 irradiance = dotNL * incidentLight.color * PI;");src.push(" reflectedLight.diffuse += irradiance * (RECIPROCAL_PI * material.diffuseColor);");src.push(" reflectedLight.specular += irradiance * BRDF_Specular_GGX(incidentLight, geometry, material.specularColor, material.specularRoughness);");src.push("}");src.push("out vec4 outColor;");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 _i250=0,_len54=sectionPlanesState.getNumAllocatedSectionPlanes();_i250<_len54;_i250++){src.push("if (sectionPlaneActive"+_i250+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i250+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i250+".xyz), 0.0, 1000.0);");src.push("}");}if(clippingCaps){src.push(" if (dist > (0.002 * vClipPosition.w)) {");src.push(" discard;");src.push(" }");src.push(" if (dist > 0.0) { ");src.push(" outColor=vec4(1.0, 0.0, 0.0, 1.0);");if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" return;");src.push("}");}else{src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");}src.push("}");}src.push("IncidentLight light;");src.push("Material material;");src.push("Geometry geometry;");src.push("ReflectedLight reflectedLight = ReflectedLight(vec3(0.0,0.0,0.0), vec3(0.0,0.0,0.0));");src.push("vec3 rgb = (vec3(float(vColor.r) / 255.0, float(vColor.g) / 255.0, float(vColor.b) / 255.0));");src.push("float opacity = float(vColor.a) / 255.0;");src.push("vec3 baseColor = rgb;");src.push("float specularF0 = 1.0;");src.push("float metallic = float(vMetallicRoughness.r) / 255.0;");src.push("float roughness = float(vMetallicRoughness.g) / 255.0;");src.push("float dielectricSpecular = 0.16 * specularF0 * specularF0;");src.push("vec4 colorTexel = sRGBToLinear(texture(uColorMap, vUV));");src.push("baseColor *= colorTexel.rgb;");// src.push("opacity = colorTexel.a;");
17622
17647
  src.push("vec3 metalRoughTexel = texture(uMetallicRoughMap, vUV).rgb;");src.push("metallic *= metalRoughTexel.b;");src.push("roughness *= metalRoughTexel.g;");src.push("vec3 viewNormal = perturbNormal2Arb( vViewPosition.xyz, normalize(vViewNormal), vUV );");src.push("material.diffuseColor = baseColor * (1.0 - dielectricSpecular) * (1.0 - metallic);");src.push("material.specularRoughness = clamp(roughness, 0.04, 1.0);");src.push("material.specularColor = mix(vec3(dielectricSpecular), baseColor, metallic);");src.push("geometry.position = vViewPosition.xyz;");src.push("geometry.viewNormal = -normalize(viewNormal);");src.push("geometry.viewEyeDir = normalize(vViewPosition.xyz);");if(lightsState.lightMaps.length>0){src.push("geometry.worldNormal = normalize(vWorldNormal);");}if(lightsState.lightMaps.length>0||lightsState.reflectionMaps.length>0){src.push("computePBRLightMapping(geometry, material, reflectedLight);");}for(var _i251=0,_len55=lightsState.lights.length;_i251<_len55;_i251++){var _light8=lightsState.lights[_i251];if(_light8.type==="ambient"){continue;}if(_light8.type==="dir"){if(_light8.space==="view"){src.push("light.direction = normalize(lightDir"+_i251+");");}else{src.push("light.direction = normalize((viewMatrix * vec4(lightDir"+_i251+", 0.0)).xyz);");}}else if(_light8.type==="point"){if(_light8.space==="view"){src.push("light.direction = normalize(lightPos"+_i251+" - vViewPosition.xyz);");}else{src.push("light.direction = normalize((viewMatrix * vec4(lightPos"+_i251+", 0.0)).xyz);");}}else if(_light8.type==="spot"){if(_light8.space==="view"){src.push("light.direction = normalize(lightDir"+_i251+");");}else{src.push("light.direction = normalize((viewMatrix * vec4(lightDir"+_i251+", 0.0)).xyz);");}}else{continue;}src.push("light.color = lightColor"+_i251+".rgb * lightColor"+_i251+".a;");// a is intensity
17623
17648
  src.push("computePBRLighting(light, geometry, material, reflectedLight);");}src.push("vec3 emissiveColor = sRGBToLinear(texture(uEmissiveMap, vUV)).rgb;");// TODO: correct gamma function
17624
17649
  src.push("vec3 outgoingLight = (lightAmbient.rgb * lightAmbient.a * baseColor * opacity * rgb) + (reflectedLight.diffuse) + (reflectedLight.specular) + emissiveColor;");src.push("vec4 fragColor;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17625
17650
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
17626
17651
  src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" fragColor = vec4(outgoingLight.rgb * ambient, opacity);");}else{src.push(" fragColor = vec4(outgoingLight.rgb, opacity);");}if(gammaOutput){src.push("fragColor = linearToGamma(fragColor, gammaFactor);");}src.push("outColor = fragColor;");if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return TrianglesInstancingPBRRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17627
17652
  * @private
17628
- */var TrianglesInstancingPickNormalsFlatRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl31){_inherits(TrianglesInstancingPickNormalsFlatRenderer,_VBOSceneModelTriangl31);var _super104=_createSuper(TrianglesInstancingPickNormalsFlatRenderer);function TrianglesInstancingPickNormalsFlatRenderer(){_classCallCheck(this,TrianglesInstancingPickNormalsFlatRenderer);return _super104.apply(this,arguments);}_createClass(TrianglesInstancingPickNormalsFlatRenderer,[{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("// Instancing geometry normals vertex shader");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
17653
+ */var TrianglesInstancingPickNormalsFlatRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl31){_inherits(TrianglesInstancingPickNormalsFlatRenderer,_VBOSceneModelTriangl31);var _super104=_createSuper(TrianglesInstancingPickNormalsFlatRenderer);function TrianglesInstancingPickNormalsFlatRenderer(){_classCallCheck(this,TrianglesInstancingPickNormalsFlatRenderer);return _super104.apply(this,arguments);}_createClass(TrianglesInstancingPickNormalsFlatRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry normals vertex shader");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
17629
17654
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src,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;");}if(clipping){src.push("out float vFlags;");}src.push("out vec4 vWorldPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17630
17655
  // renderPass = PICK
17631
17656
  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
17632
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vFlags = flags;");}src.push("gl_Position = remapClipPos(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("// Batched geometry normals 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("in vec4 vWorldPosition;");if(clipping){src.push("in float vFlags;");for(var _i252=0;_i252<sectionPlanesState.sectionPlanes.length;_i252++){src.push("uniform bool sectionPlaneActive"+_i252+";");src.push("uniform vec3 sectionPlanePos"+_i252+";");src.push("uniform vec3 sectionPlaneDir"+_i252+";");}}src.push("out highp ivec4 outNormal;");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(" vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push(" vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push(" outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("}");return src;}}]);return TrianglesInstancingPickNormalsFlatRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17657
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vFlags = flags;");}src.push("gl_Position = remapClipPos(clipPos);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry normals 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("in vec4 vWorldPosition;");if(clipping){src.push("in float vFlags;");for(var _i252=0;_i252<sectionPlanesState.getNumAllocatedSectionPlanes();_i252++){src.push("uniform bool sectionPlaneActive"+_i252+";");src.push("uniform vec3 sectionPlanePos"+_i252+";");src.push("uniform vec3 sectionPlaneDir"+_i252+";");}}src.push("out highp ivec4 outNormal;");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.getNumAllocatedSectionPlanes();i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push(" vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push(" outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("}");return src;}}]);return TrianglesInstancingPickNormalsFlatRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17633
17658
  * @private
17634
- */var TrianglesInstancingColorTextureRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl32){_inherits(TrianglesInstancingColorTextureRenderer,_VBOSceneModelTriangl32);var _super105=_createSuper(TrianglesInstancingColorTextureRenderer);function TrianglesInstancingColorTextureRenderer(){_classCallCheck(this,TrianglesInstancingColorTextureRenderer);return _super105.apply(this,arguments);}_createClass(TrianglesInstancingColorTextureRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesInstancingColorTextureRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{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("// Instancing geometry drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17659
+ */var TrianglesInstancingColorTextureRenderer=/*#__PURE__*/function(_VBOSceneModelTriangl32){_inherits(TrianglesInstancingColorTextureRenderer,_VBOSceneModelTriangl32);var _super105=_createSuper(TrianglesInstancingColorTextureRenderer);function TrianglesInstancingColorTextureRenderer(){_classCallCheck(this,TrianglesInstancingColorTextureRenderer);return _super105.apply(this,arguments);}_createClass(TrianglesInstancingColorTextureRenderer,[{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(TrianglesInstancingColorTextureRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17635
17660
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);src.push("uniform mat3 uvDecodeMatrix;");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("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("out vec4 vColor;");src.push("out vec2 vUV;");src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17636
17661
  // renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
17637
17662
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17638
17663
  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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var gammaOutput=scene.gammaOutput;// If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
17639
- var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var i;var len;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing 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 sampler2D uColorMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i253=0,_len56=sectionPlanesState.sectionPlanes.length;_i253<_len56;_i253++){src.push("uniform bool sectionPlaneActive"+_i253+";");src.push("uniform vec3 sectionPlanePos"+_i253+";");src.push("uniform vec3 sectionPlaneDir"+_i253+";");}}this._addMatricesUniformBlockLines(src);src.push("uniform vec4 lightAmbient;");for(i=0,len=lightsState.lights.length;i<len;i++){var light=lightsState.lights[i];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+i+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+i+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+i+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+i+";");src.push("uniform vec3 lightDir"+i+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("out vec4 outColor;");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 _i254=0,_len57=sectionPlanesState.sectionPlanes.length;_i254<_len57;_i254++){src.push("if (sectionPlaneActive"+_i254+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i254+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i254+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(i=0,len=lightsState.lights.length;i<len;i++){var _light9=lightsState.lights[i];if(_light9.type==="ambient"){continue;}if(_light9.type==="dir"){if(_light9.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(_light9.type==="point"){if(_light9.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(_light9.type==="spot"){if(_light9.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(gammaOutput){src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");}else{src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");}src.push("float opacity = color.a;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17664
+ var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var i;var len;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing 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 sampler2D uColorMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i253=0,_len56=sectionPlanesState.getNumAllocatedSectionPlanes();_i253<_len56;_i253++){src.push("uniform bool sectionPlaneActive"+_i253+";");src.push("uniform vec3 sectionPlanePos"+_i253+";");src.push("uniform vec3 sectionPlaneDir"+_i253+";");}}this._addMatricesUniformBlockLines(src);src.push("uniform vec4 lightAmbient;");for(i=0,len=lightsState.lights.length;i<len;i++){var light=lightsState.lights[i];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+i+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+i+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+i+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+i+";");src.push("uniform vec3 lightDir"+i+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("out vec4 outColor;");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 _i254=0,_len57=sectionPlanesState.getNumAllocatedSectionPlanes();_i254<_len57;_i254++){src.push("if (sectionPlaneActive"+_i254+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i254+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i254+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(i=0,len=lightsState.lights.length;i<len;i++){var _light9=lightsState.lights[i];if(_light9.type==="ambient"){continue;}if(_light9.type==="dir"){if(_light9.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(_light9.type==="point"){if(_light9.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(_light9.type==="spot"){if(_light9.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(gammaOutput){src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");}else{src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");}src.push("float opacity = color.a;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17640
17665
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
17641
17666
  src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb * ambient, opacity);");}else{src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");}if(gammaOutput){src.push("outColor = linearToGamma(outColor, gammaFactor);");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return TrianglesInstancingColorTextureRenderer;}(VBOSceneModelTriangleInstancingRenderer);/**
17642
17667
  * @private
@@ -17646,31 +17671,31 @@ src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewp
17646
17671
  if(!this._silhouetteRenderer){// Used for highlighting and selection
17647
17672
  this._silhouetteRenderer=new TrianglesInstancingSilhouetteRenderer(this._scene);}if(!this._pickMeshRenderer){this._pickMeshRenderer=new TrianglesInstancingPickMeshRenderer(this._scene);}if(!this._pickDepthRenderer){this._pickDepthRenderer=new TrianglesInstancingPickDepthRenderer(this._scene);}}},{key:"colorRenderer",get:function get(){if(!this._colorRenderer){this._colorRenderer=new TrianglesInstancingColorRenderer(this._scene,false);}return this._colorRenderer;}},{key:"colorRendererWithSAO",get:function get(){if(!this._colorRendererWithSAO){this._colorRendererWithSAO=new TrianglesInstancingColorRenderer(this._scene,true);}return this._colorRendererWithSAO;}},{key:"flatColorRenderer",get:function get(){if(!this._flatColorRenderer){this._flatColorRenderer=new TrianglesInstancingFlatColorRenderer(this._scene,false);}return this._flatColorRenderer;}},{key:"flatColorRendererWithSAO",get:function get(){if(!this._flatColorRendererWithSAO){this._flatColorRendererWithSAO=new TrianglesInstancingFlatColorRenderer(this._scene,true);}return this._flatColorRendererWithSAO;}},{key:"pbrRenderer",get:function get(){if(!this._pbrRenderer){this._pbrRenderer=new TrianglesInstancingPBRRenderer(this._scene,false);}return this._pbrRenderer;}},{key:"pbrRendererWithSAO",get:function get(){if(!this._pbrRendererWithSAO){this._pbrRendererWithSAO=new TrianglesInstancingPBRRenderer(this._scene,true);}return this._pbrRendererWithSAO;}},{key:"colorTextureRenderer",get:function get(){if(!this._colorTextureRenderer){this._colorTextureRenderer=new TrianglesInstancingColorTextureRenderer(this._scene,false);}return this._colorTextureRenderer;}},{key:"colorTextureRendererWithSAO",get:function get(){if(!this._colorTextureRendererWithSAO){this._colorTextureRendererWithSAO=new TrianglesInstancingColorTextureRenderer(this._scene,true);}return this._colorTextureRendererWithSAO;}},{key:"silhouetteRenderer",get:function get(){if(!this._silhouetteRenderer){this._silhouetteRenderer=new TrianglesInstancingSilhouetteRenderer(this._scene);}return this._silhouetteRenderer;}},{key:"depthRenderer",get:function get(){if(!this._depthRenderer){this._depthRenderer=new TrianglesInstancingDepthRenderer(this._scene);}return this._depthRenderer;}},{key:"normalsRenderer",get:function get(){if(!this._normalsRenderer){this._normalsRenderer=new TrianglesInstancingNormalsRenderer(this._scene);}return this._normalsRenderer;}},{key:"edgesRenderer",get:function get(){if(!this._edgesRenderer){this._edgesRenderer=new TrianglesInstancingEdgesRenderer(this._scene);}return this._edgesRenderer;}},{key:"edgesColorRenderer",get:function get(){if(!this._edgesColorRenderer){this._edgesColorRenderer=new TrianglesInstancingEdgesColorRenderer(this._scene);}return this._edgesColorRenderer;}},{key:"pickMeshRenderer",get:function get(){if(!this._pickMeshRenderer){this._pickMeshRenderer=new TrianglesInstancingPickMeshRenderer(this._scene);}return this._pickMeshRenderer;}},{key:"pickNormalsRenderer",get:function get(){if(!this._pickNormalsRenderer){this._pickNormalsRenderer=new TrianglesInstancingPickNormalsRenderer(this._scene);}return this._pickNormalsRenderer;}},{key:"pickNormalsFlatRenderer",get:function get(){if(!this._pickNormalsFlatRenderer){this._pickNormalsFlatRenderer=new TrianglesInstancingPickNormalsFlatRenderer(this._scene);}return this._pickNormalsFlatRenderer;}},{key:"pickDepthRenderer",get:function get(){if(!this._pickDepthRenderer){this._pickDepthRenderer=new TrianglesInstancingPickDepthRenderer(this._scene);}return this._pickDepthRenderer;}},{key:"occlusionRenderer",get:function get(){if(!this._occlusionRenderer){this._occlusionRenderer=new TrianglesInstancingOcclusionRenderer(this._scene);}return this._occlusionRenderer;}},{key:"shadowRenderer",get:function get(){if(!this._shadowRenderer){this._shadowRenderer=new TrianglesInstancingShadowRenderer(this._scene);}return this._shadowRenderer;}},{key:"_destroy",value:function _destroy(){if(this._colorRenderer){this._colorRenderer.destroy();}if(this._colorRendererWithSAO){this._colorRendererWithSAO.destroy();}if(this._flatColorRenderer){this._flatColorRenderer.destroy();}if(this._flatColorRendererWithSAO){this._flatColorRendererWithSAO.destroy();}if(this._pbrRenderer){this._pbrRenderer.destroy();}if(this._pbrRendererWithSAO){this._pbrRendererWithSAO.destroy();}if(this._colorTextureRenderer){this._colorTextureRenderer.destroy();}if(this._colorTextureRendererWithSAO){this._colorTextureRendererWithSAO.destroy();}if(this._depthRenderer){this._depthRenderer.destroy();}if(this._normalsRenderer){this._normalsRenderer.destroy();}if(this._silhouetteRenderer){this._silhouetteRenderer.destroy();}if(this._edgesRenderer){this._edgesRenderer.destroy();}if(this._edgesColorRenderer){this._edgesColorRenderer.destroy();}if(this._pickMeshRenderer){this._pickMeshRenderer.destroy();}if(this._pickDepthRenderer){this._pickDepthRenderer.destroy();}if(this._pickNormalsRenderer){this._pickNormalsRenderer.destroy();}if(this._pickNormalsFlatRenderer){this._pickNormalsFlatRenderer.destroy();}if(this._occlusionRenderer){this._occlusionRenderer.destroy();}if(this._shadowRenderer){this._shadowRenderer.destroy();}}}]);return TrianglesInstancingRenderers;}();var cachedRenderers$5={};/**
17648
17673
  * @private
17649
- */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();instancingRenderers.eagerCreateRenders();scene.on("compile",function(){instancingRenderers._compile();instancingRenderers.eagerCreateRenders();});scene.on("destroyed",function(){delete cachedRenderers$5[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempVec3a$o=math.vec3();var tempVec3b$k=math.vec3();var tempVec3c$h=math.vec3();var tempVec3d$d=math.vec3();var tempMat4a$e=math.mat4();/**
17674
+ */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();instancingRenderers.eagerCreateRenders();scene.on("compile",function(){instancingRenderers._compile();instancingRenderers.eagerCreateRenders();});scene.on("destroyed",function(){delete cachedRenderers$5[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempVec3a$o=math.vec3();var tempVec3b$k=math.vec3();var tempVec3c$h=math.vec3();var tempVec3d$5=math.vec3();var tempMat4a$e=math.mat4();/**
17650
17675
  * @private
17651
- */var SnapInstancingDepthBufInitRenderer=/*#__PURE__*/function(_VBOSceneModelRendere9){_inherits(SnapInstancingDepthBufInitRenderer,_VBOSceneModelRendere9);var _super106=_createSuper(SnapInstancingDepthBufInitRenderer);function SnapInstancingDepthBufInitRenderer(scene){_classCallCheck(this,SnapInstancingDepthBufInitRenderer);return _super106.call(this,scene,false,{instancing:true});}_createClass(SnapInstancingDepthBufInitRenderer,[{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;if(this._vaoCache.has(instancingLayer)){gl.bindVertexArray(this._vaoCache.get(instancingLayer));}else{this._vaoCache.set(instancingLayer,this._makeVAO(state));}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$k;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$h);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$e);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);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,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);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(instancingLayer);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._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);}state.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);state.indicesBuf.unbind();// Cleanup
17652
- 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(){_get(_getPrototypeOf(SnapInstancingDepthBufInitRenderer.prototype),"_allocate",this).call(this);var program=this._program;{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:"_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 vec4 pickColor;");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
17676
+ */var SnapInstancingDepthBufInitRenderer=/*#__PURE__*/function(_VBOSceneModelRendere9){_inherits(SnapInstancingDepthBufInitRenderer,_VBOSceneModelRendere9);var _super106=_createSuper(SnapInstancingDepthBufInitRenderer);function SnapInstancingDepthBufInitRenderer(scene){_classCallCheck(this,SnapInstancingDepthBufInitRenderer);return _super106.call(this,scene,false,{instancing:true});}_createClass(SnapInstancingDepthBufInitRenderer,[{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;if(this._vaoCache.has(instancingLayer)){gl.bindVertexArray(this._vaoCache.get(instancingLayer));}else{this._vaoCache.set(instancingLayer,this._makeVAO(state));}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$k;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$h);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$e);rtcCameraEye=tempVec3d$5;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);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,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);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(instancingLayer);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._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);}state.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);state.indicesBuf.unbind();// Cleanup
17677
+ 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(){_get(_getPrototypeOf(SnapInstancingDepthBufInitRenderer.prototype),"_allocate",this).call(this);var program=this._program;{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:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>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 vec4 pickColor;");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
17653
17678
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);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("}");src.push("flat out vec4 vPickColor;");src.push("out vec4 vWorldPosition;");if(clipping){src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17654
17679
  // renderPass = PICK
17655
17680
  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
17656
- 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; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}src.push("vPickColor = pickColor;");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("}");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;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("in float vFlags;");for(var _i255=0;_i255<sectionPlanesState.sectionPlanes.length;_i255++){src.push("uniform bool sectionPlaneActive"+_i255+";");src.push("uniform vec3 sectionPlanePos"+_i255+";");src.push("uniform vec3 sectionPlaneDir"+_i255+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");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 _i256=0;_i256<sectionPlanesState.sectionPlanes.length;_i256++){src.push("if (sectionPlaneActive"+_i256+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i256+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i256+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}{src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");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;}(VBOSceneModelRenderer);var tempVec3a$n=math.vec3();var tempVec3b$j=math.vec3();var tempVec3c$g=math.vec3();var tempVec3d$c=math.vec3();var tempMat4a$d=math.mat4();/**
17681
+ 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; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}src.push("vPickColor = pickColor;");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("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>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;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("in float vFlags;");for(var _i255=0;_i255<sectionPlanesState.getNumAllocatedSectionPlanes();_i255++){src.push("uniform bool sectionPlaneActive"+_i255+";");src.push("uniform vec3 sectionPlanePos"+_i255+";");src.push("uniform vec3 sectionPlaneDir"+_i255+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");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 _i256=0;_i256<sectionPlanesState.getNumAllocatedSectionPlanes();_i256++){src.push("if (sectionPlaneActive"+_i256+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i256+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i256+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}{src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");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;}(VBOSceneModelRenderer);var tempVec3a$n=math.vec3();var tempVec3b$j=math.vec3();var tempVec3c$g=math.vec3();var tempVec3d$4=math.vec3();var tempMat4a$d=math.mat4();/**
17657
17682
  * @private
17658
- */var SnapInstancingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelRendere10){_inherits(SnapInstancingDepthRenderer,_VBOSceneModelRendere10);var _super107=_createSuper(SnapInstancingDepthRenderer);function SnapInstancingDepthRenderer(scene){_classCallCheck(this,SnapInstancingDepthRenderer);return _super107.call(this,scene,false,{instancing:true});}_createClass(SnapInstancingDepthRenderer,[{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;if(this._vaoCache.has(instancingLayer)){gl.bindVertexArray(this._vaoCache.get(instancingLayer));}else{this._vaoCache.set(instancingLayer,this._makeVAO(state));}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$j;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$g);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$d);rtcCameraEye=tempVec3d$c;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);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,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);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix
17683
+ */var SnapInstancingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelRendere10){_inherits(SnapInstancingDepthRenderer,_VBOSceneModelRendere10);var _super107=_createSuper(SnapInstancingDepthRenderer);function SnapInstancingDepthRenderer(scene){_classCallCheck(this,SnapInstancingDepthRenderer);return _super107.call(this,scene,false,{instancing:true});}_createClass(SnapInstancingDepthRenderer,[{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;if(this._vaoCache.has(instancingLayer)){gl.bindVertexArray(this._vaoCache.get(instancingLayer));}else{this._vaoCache.set(instancingLayer,this._makeVAO(state));}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$j;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$g);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$d);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);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,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);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix
17659
17684
  gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(instancingLayer);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._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.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?
17660
17685
  }else{gl.drawArraysInstanced(gl.POINTS,0,state.positionsBuf.numItems,state.numInstances);}// Cleanup
17661
- 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(){_get(_getPrototypeOf(SnapInstancingDepthRenderer.prototype),"_allocate",this).call(this);var program=this._program;{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:"_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
17686
+ 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(){_get(_getPrototypeOf(SnapInstancingDepthRenderer.prototype),"_allocate",this).call(this);var program=this._program;{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:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>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
17662
17687
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);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
17663
17688
  // renderPass = PICK
17664
17689
  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
17665
17690
  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?
17666
- 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 _i257=0;_i257<sectionPlanesState.sectionPlanes.length;_i257++){src.push("uniform bool sectionPlaneActive"+_i257+";");src.push("uniform vec3 sectionPlanePos"+_i257+";");src.push("uniform vec3 sectionPlaneDir"+_i257+";");}}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 _i258=0;_i258<sectionPlanesState.sectionPlanes.length;_i258++){src.push("if (sectionPlaneActive"+_i258+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i258+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i258+".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;}(VBOSceneModelRenderer);/**
17691
+ src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>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 _i257=0;_i257<sectionPlanesState.getNumAllocatedSectionPlanes();_i257++){src.push("uniform bool sectionPlaneActive"+_i257+";");src.push("uniform vec3 sectionPlanePos"+_i257+";");src.push("uniform vec3 sectionPlaneDir"+_i257+";");}}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 _i258=0;_i258<sectionPlanesState.getNumAllocatedSectionPlanes();_i258++){src.push("if (sectionPlaneActive"+_i258+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i258+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i258+".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;}(VBOSceneModelRenderer);/**
17667
17692
  * @private
17668
17693
  */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:"eagerCreateRenders",value:function eagerCreateRenders(){// Pre-initialize renderers that would otherwise be lazy-initialised
17669
17694
  // on user interaction, such as picking or emphasis, so that there is no delay
17670
17695
  // when user first begins interacting with the viewer.
17671
17696
  if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapInstancingDepthBufInitRenderer(this._scene,false);}if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapInstancingDepthRenderer(this._scene);}}},{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={};/**
17672
17697
  * @private
17673
- */function getSnapInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$4[sceneId];if(!instancingRenderers){instancingRenderers=new SnapInstancingRenderers(scene);cachedRenderers$4[sceneId]=instancingRenderers;instancingRenderers._compile();instancingRenderers.eagerCreateRenders();scene.on("compile",function(){instancingRenderers._compile();instancingRenderers.eagerCreateRenders();});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$i=math.vec3();var tempVec3c$f=math.vec3();var tempVec3d$b=math.vec3();var tempVec3e$2=math.vec3();var tempVec3f=math.vec3();var tempVec3g=math.vec3();var tempFloat32Vec4$2=new Float32Array(4);/**
17698
+ */function getSnapInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$4[sceneId];if(!instancingRenderers){instancingRenderers=new SnapInstancingRenderers(scene);cachedRenderers$4[sceneId]=instancingRenderers;instancingRenderers._compile();instancingRenderers.eagerCreateRenders();scene.on("compile",function(){instancingRenderers._compile();instancingRenderers.eagerCreateRenders();});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$i=math.vec3();var tempVec3c$f=math.vec3();var tempVec3d$3=math.vec3();var tempVec3e=math.vec3();var tempVec3f=math.vec3();var tempVec3g=math.vec3();var tempFloat32Vec4$2=new Float32Array(4);/**
17674
17699
  * @private
17675
17700
  */var TrianglesInstancingLayer=/*#__PURE__*/function(){/**
17676
17701
  * @param cfg
@@ -17797,18 +17822,18 @@ this._instancingRenderers.occlusionRenderer.drawLayer(frameCtx,this,RENDER_PASSE
17797
17822
  if(this._instancingRenderers.pickNormalsFlatRenderer){this._instancingRenderers.pickNormalsFlatRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}// }
17798
17823
  }},{key:"drawSnapInitDepthBuf",value:function drawSnapInitDepthBuf(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._snapInstancingRenderers.snapDepthBufInitRenderer){this._snapInstancingRenderers.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._snapInstancingRenderers.snapDepthRenderer){this._snapInstancingRenderers.snapDepthRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}//-----------------------------------------------------------------------------------------
17799
17824
  },{key:"precisionRayPickSurface",value:function precisionRayPickSurface(portionId,worldRayOrigin,worldRayDir,worldSurfacePos,worldNormal){if(!this.model.scene.pickSurfacePrecisionEnabled){return false;}var geometry=this._state.geometry;var state=this._state;var portion=this._portions[portionId];if(!portion){this.model.error("portion not found: "+portionId);return false;}if(!portion.inverseMatrix){portion.inverseMatrix=math.inverseMat4(portion.matrix,math.mat4());}if(worldNormal&&!portion.normalMatrix){portion.normalMatrix=math.transposeMat4(portion.inverseMatrix,math.mat4());}var quantizedPositions=geometry.quantizedPositions;var indices=geometry.indices;var origin=state.origin;var offset=portion.offset;var rtcRayOrigin=tempVec3a$m;var rtcRayDir=tempVec3b$i;rtcRayOrigin.set(origin?math.subVec3(worldRayOrigin,origin,tempVec3c$f):worldRayOrigin);// World -> RTC
17800
- rtcRayDir.set(worldRayDir);if(offset){math.subVec3(rtcRayOrigin,offset);}math.transformRay(this.model.worldNormalMatrix,rtcRayOrigin,rtcRayDir,rtcRayOrigin,rtcRayDir);math.transformRay(portion.inverseMatrix,rtcRayOrigin,rtcRayDir,rtcRayOrigin,rtcRayDir);var a=tempVec3d$b;var b=tempVec3e$2;var c=tempVec3f;var gotIntersect=false;var closestDist=0;var closestIntersectPos=tempVec3g;for(var _i261=0,len=indices.length;_i261<len;_i261+=3){var ia=indices[_i261+0]*3;var ib=indices[_i261+1]*3;var ic=indices[_i261+2]*3;a[0]=quantizedPositions[ia];a[1]=quantizedPositions[ia+1];a[2]=quantizedPositions[ia+2];b[0]=quantizedPositions[ib];b[1]=quantizedPositions[ib+1];b[2]=quantizedPositions[ib+2];c[0]=quantizedPositions[ic];c[1]=quantizedPositions[ic+1];c[2]=quantizedPositions[ic+2];var positionsDecodeMatrix=state.geometry.positionsDecodeMatrix;math.decompressPosition(a,positionsDecodeMatrix);math.decompressPosition(b,positionsDecodeMatrix);math.decompressPosition(c,positionsDecodeMatrix);if(math.rayTriangleIntersect(rtcRayOrigin,rtcRayDir,a,b,c,closestIntersectPos)){math.transformPoint3(portion.matrix,closestIntersectPos,closestIntersectPos);math.transformPoint3(this.model.worldMatrix,closestIntersectPos,closestIntersectPos);if(offset){math.addVec3(closestIntersectPos,offset);}if(origin){math.addVec3(closestIntersectPos,origin);}var dist=Math.abs(math.lenVec3(math.subVec3(closestIntersectPos,worldRayOrigin,[])));if(!gotIntersect||dist>closestDist){closestDist=dist;worldSurfacePos.set(closestIntersectPos);if(worldNormal){// Not that wasteful to eagerly compute - unlikely to hit >2 surfaces on most geometry
17825
+ rtcRayDir.set(worldRayDir);if(offset){math.subVec3(rtcRayOrigin,offset);}math.transformRay(this.model.worldNormalMatrix,rtcRayOrigin,rtcRayDir,rtcRayOrigin,rtcRayDir);math.transformRay(portion.inverseMatrix,rtcRayOrigin,rtcRayDir,rtcRayOrigin,rtcRayDir);var a=tempVec3d$3;var b=tempVec3e;var c=tempVec3f;var gotIntersect=false;var closestDist=0;var closestIntersectPos=tempVec3g;for(var _i261=0,len=indices.length;_i261<len;_i261+=3){var ia=indices[_i261+0]*3;var ib=indices[_i261+1]*3;var ic=indices[_i261+2]*3;a[0]=quantizedPositions[ia];a[1]=quantizedPositions[ia+1];a[2]=quantizedPositions[ia+2];b[0]=quantizedPositions[ib];b[1]=quantizedPositions[ib+1];b[2]=quantizedPositions[ib+2];c[0]=quantizedPositions[ic];c[1]=quantizedPositions[ic+1];c[2]=quantizedPositions[ic+2];var positionsDecodeMatrix=state.geometry.positionsDecodeMatrix;math.decompressPosition(a,positionsDecodeMatrix);math.decompressPosition(b,positionsDecodeMatrix);math.decompressPosition(c,positionsDecodeMatrix);if(math.rayTriangleIntersect(rtcRayOrigin,rtcRayDir,a,b,c,closestIntersectPos)){math.transformPoint3(portion.matrix,closestIntersectPos,closestIntersectPos);math.transformPoint3(this.model.worldMatrix,closestIntersectPos,closestIntersectPos);if(offset){math.addVec3(closestIntersectPos,offset);}if(origin){math.addVec3(closestIntersectPos,origin);}var dist=Math.abs(math.lenVec3(math.subVec3(closestIntersectPos,worldRayOrigin,[])));if(!gotIntersect||dist>closestDist){closestDist=dist;worldSurfacePos.set(closestIntersectPos);if(worldNormal){// Not that wasteful to eagerly compute - unlikely to hit >2 surfaces on most geometry
17801
17826
  math.triangleNormal(a,b,c,worldNormal);}gotIntersect=true;}}}if(gotIntersect&&worldNormal){math.transformVec3(portion.normalMatrix,worldNormal,worldNormal);math.transformVec3(this.model.worldNormalMatrix,worldNormal,worldNormal);math.normalizeVec3(worldNormal);}return gotIntersect;}},{key:"destroy",value:function destroy(){var state=this._state;if(state.colorsBuf){state.colorsBuf.destroy();state.colorsBuf=null;}if(state.metallicRoughnessBuf){state.metallicRoughnessBuf.destroy();state.metallicRoughnessBuf=null;}if(state.flagsBuf){state.flagsBuf.destroy();state.flagsBuf=null;}if(state.offsetsBuf){state.offsetsBuf.destroy();state.offsetsBuf=null;}if(state.modelMatrixCol0Buf){state.modelMatrixCol0Buf.destroy();state.modelMatrixCol0Buf=null;}if(state.modelMatrixCol1Buf){state.modelMatrixCol1Buf.destroy();state.modelMatrixCol1Buf=null;}if(state.modelMatrixCol2Buf){state.modelMatrixCol2Buf.destroy();state.modelMatrixCol2Buf=null;}if(state.modelNormalMatrixCol0Buf){state.modelNormalMatrixCol0Buf.destroy();state.modelNormalMatrixCol0Buf=null;}if(state.modelNormalMatrixCol1Buf){state.modelNormalMatrixCol1Buf.destroy();state.modelNormalMatrixCol1Buf=null;}if(state.modelNormalMatrixCol2Buf){state.modelNormalMatrixCol2Buf.destroy();state.modelNormalMatrixCol2Buf=null;}if(state.pickColorsBuf){state.pickColorsBuf.destroy();state.pickColorsBuf=null;}state.destroy();this._state=null;}}]);return TrianglesInstancingLayer;}();/**
17802
17827
  * @private
17803
- */var LinesBatchingColorRenderer=/*#__PURE__*/function(_VBOSceneModelLineBat){_inherits(LinesBatchingColorRenderer,_VBOSceneModelLineBat);var _super108=_createSuper(LinesBatchingColorRenderer);function LinesBatchingColorRenderer(){_classCallCheck(this,LinesBatchingColorRenderer);return _super108.apply(this,arguments);}_createClass(LinesBatchingColorRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(LinesBatchingColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{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("// Lines batching color vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src);if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}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
17828
+ */var LinesBatchingColorRenderer=/*#__PURE__*/function(_VBOSceneModelLineBat){_inherits(LinesBatchingColorRenderer,_VBOSceneModelLineBat);var _super108=_createSuper(LinesBatchingColorRenderer);function LinesBatchingColorRenderer(){_classCallCheck(this,LinesBatchingColorRenderer);return _super108.apply(this,arguments);}_createClass(LinesBatchingColorRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(LinesBatchingColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Lines batching color vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src);if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}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
17804
17829
  // renderPass = COLOR_OPAQUE
17805
17830
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17806
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}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("// Lines batching color 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i262=0,len=sectionPlanesState.sectionPlanes.length;_i262<len;_i262++){src.push("uniform bool sectionPlaneActive"+_i262+";");src.push("uniform vec3 sectionPlanePos"+_i262+";");src.push("uniform vec3 sectionPlaneDir"+_i262+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i263=0,_len58=sectionPlanesState.sectionPlanes.length;_i263<_len58;_i263++){src.push("if (sectionPlaneActive"+_i263+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i263+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i263+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vColor;");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return LinesBatchingColorRenderer;}(VBOSceneModelLineBatchingRenderer);/**
17831
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}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.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Lines batching color 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i262=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i262<len;_i262++){src.push("uniform bool sectionPlaneActive"+_i262+";");src.push("uniform vec3 sectionPlanePos"+_i262+";");src.push("uniform vec3 sectionPlaneDir"+_i262+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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 _i263=0,_len58=sectionPlanesState.getNumAllocatedSectionPlanes();_i263<_len58;_i263++){src.push("if (sectionPlaneActive"+_i263+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i263+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i263+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vColor;");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return LinesBatchingColorRenderer;}(VBOSceneModelLineBatchingRenderer);/**
17807
17832
  * @private
17808
- */var LinesBatchingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelLineBat2){_inherits(LinesBatchingSilhouetteRenderer,_VBOSceneModelLineBat2);var _super109=_createSuper(LinesBatchingSilhouetteRenderer);function LinesBatchingSilhouetteRenderer(){_classCallCheck(this,LinesBatchingSilhouetteRenderer);return _super109.apply(this,arguments);}_createClass(LinesBatchingSilhouetteRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){_get(_getPrototypeOf(LinesBatchingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,batchingLayer,renderPass,{colorUniform:true});}},{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("// Lines batching silhouette vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);src.push("uniform vec4 color;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// silhouetteFlag = NOT_RENDERED | SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
17833
+ */var LinesBatchingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelLineBat2){_inherits(LinesBatchingSilhouetteRenderer,_VBOSceneModelLineBat2);var _super109=_createSuper(LinesBatchingSilhouetteRenderer);function LinesBatchingSilhouetteRenderer(){_classCallCheck(this,LinesBatchingSilhouetteRenderer);return _super109.apply(this,arguments);}_createClass(LinesBatchingSilhouetteRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){_get(_getPrototypeOf(LinesBatchingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,batchingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Lines batching silhouette vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);src.push("uniform vec4 color;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// silhouetteFlag = NOT_RENDERED | SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
17809
17834
  // renderPass = SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
17810
17835
  src.push("int silhouetteFlag = int(flags) >> 4 & 0xF;");src.push("if (silhouetteFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17811
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}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("// Lines batching silhouette 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i264=0,len=sectionPlanesState.sectionPlanes.length;_i264<len;_i264++){src.push("uniform bool sectionPlaneActive"+_i264+";");src.push("uniform vec3 sectionPlanePos"+_i264+";");src.push("uniform vec3 sectionPlaneDir"+_i264+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");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 _i265=0,_len59=sectionPlanesState.sectionPlanes.length;_i265<_len59;_i265++){src.push("if (sectionPlaneActive"+_i265+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i265+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i265+".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;");}src.push("outColor = color;");src.push("}");return src;}}]);return LinesBatchingSilhouetteRenderer;}(VBOSceneModelLineBatchingRenderer);/**
17836
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}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.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Lines batching silhouette 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i264=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i264<len;_i264++){src.push("uniform bool sectionPlaneActive"+_i264+";");src.push("uniform vec3 sectionPlanePos"+_i264+";");src.push("uniform vec3 sectionPlaneDir"+_i264+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");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 _i265=0,_len59=sectionPlanesState.getNumAllocatedSectionPlanes();_i265<_len59;_i265++){src.push("if (sectionPlaneActive"+_i265+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i265+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i265+".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;");}src.push("outColor = color;");src.push("}");return src;}}]);return LinesBatchingSilhouetteRenderer;}(VBOSceneModelLineBatchingRenderer);/**
17812
17837
  * @private
17813
17838
  */var LinesBatchingRenderers=/*#__PURE__*/function(){function LinesBatchingRenderers(scene){_classCallCheck(this,LinesBatchingRenderers);this._scene=scene;}_createClass(LinesBatchingRenderers,[{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 LinesBatchingColorRenderer(this._scene,false);}return this._colorRenderer;}},{key:"silhouetteRenderer",get:function get(){if(!this._silhouetteRenderer){this._silhouetteRenderer=new LinesBatchingSilhouetteRenderer(this._scene);}return this._silhouetteRenderer;}},{key:"_destroy",value:function _destroy(){if(this._colorRenderer){this._colorRenderer.destroy();}if(this._silhouetteRenderer){this._silhouetteRenderer.destroy();}}}]);return LinesBatchingRenderers;}();var cachedRenderers$3={};/**
17814
17839
  * @private
@@ -17868,19 +17893,19 @@ _vertFlag2|=pickFlag<<12;_vertFlag2|=clippableFlag<<16;tempArray[_i275]=_vertFla
17868
17893
  return;}var portionsIdx=portionId*2;var vertexBase=this._portions[portionsIdx];var numVerts=this._portions[portionsIdx+1];var firstOffset=vertexBase*3;var lenOffsets=numVerts*3;var tempArray=this._scratchMemory.getFloat32Array(lenOffsets);var x=offset[0];var y=offset[1];var z=offset[2];for(var _i276=0;_i276<lenOffsets;_i276+=3){tempArray[_i276+0]=x;tempArray[_i276+1]=y;tempArray[_i276+2]=z;}this._state.offsetsBuf.setData(tempArray,firstOffset,lenOffsets);}//-- RENDERING ----------------------------------------------------------------------------------------------
17869
17894
  },{key:"drawColorOpaque",value:function drawColorOpaque(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numTransparentLayerPortions===this._numPortions||this._numXRayedLayerPortions===this._numPortions){return;}if(this._batchingRenderers.colorRenderer){this._batchingRenderers.colorRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_OPAQUE);}}},{key:"drawColorTransparent",value:function drawColorTransparent(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numTransparentLayerPortions===0||this._numXRayedLayerPortions===this._numPortions){return;}if(this._batchingRenderers.colorRenderer){this._batchingRenderers.colorRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_TRANSPARENT);}}},{key:"drawDepth",value:function drawDepth(renderFlags,frameCtx){}},{key:"drawNormals",value:function drawNormals(renderFlags,frameCtx){}},{key:"drawSilhouetteXRayed",value:function drawSilhouetteXRayed(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0||this._numXRayedLayerPortions===0){return;}if(this._batchingRenderers.silhouetteRenderer){this._batchingRenderers.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;}if(this._batchingRenderers.silhouetteRenderer){this._batchingRenderers.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;}if(this._batchingRenderers.silhouetteRenderer){this._batchingRenderers.silhouetteRenderer.drawLayer(frameCtx,this,RENDER_PASSES.SILHOUETTE_SELECTED);}}},{key:"drawEdgesColorOpaque",value:function drawEdgesColorOpaque(renderFlags,frameCtx){}},{key:"drawEdgesColorTransparent",value:function drawEdgesColorTransparent(renderFlags,frameCtx){}},{key:"drawEdgesHighlighted",value:function drawEdgesHighlighted(renderFlags,frameCtx){}},{key:"drawEdgesSelected",value:function drawEdgesSelected(renderFlags,frameCtx){}},{key:"drawEdgesXRayed",value:function drawEdgesXRayed(renderFlags,frameCtx){}},{key:"drawPickMesh",value:function drawPickMesh(frameCtx){}},{key:"drawPickDepths",value:function drawPickDepths(frameCtx){}},{key:"drawPickNormals",value:function drawPickNormals(frameCtx){}},{key:"drawOcclusion",value:function drawOcclusion(frameCtx){}},{key:"drawShadow",value:function drawShadow(frameCtx){}},{key:"destroy",value:function destroy(){var state=this._state;if(state.positionsBuf){state.positionsBuf.destroy();state.positionsBuf=null;}if(state.offsetsBuf){state.offsetsBuf.destroy();state.offsetsBuf=null;}if(state.colorsBuf){state.colorsBuf.destroy();state.colorsBuf=null;}if(state.flagsBuf){state.flagsBuf.destroy();state.flagsBuf=null;}if(state.indicesBuf){state.indicesBuf.destroy();state.indicesBuf=null;}state.destroy();}}]);return LinesBatchingLayer;}();/**
17870
17895
  * @private
17871
- */var LinesInstancingColorRenderer=/*#__PURE__*/function(_VBOSceneModelLineIns){_inherits(LinesInstancingColorRenderer,_VBOSceneModelLineIns);var _super110=_createSuper(LinesInstancingColorRenderer);function LinesInstancingColorRenderer(){_classCallCheck(this,LinesInstancingColorRenderer);return _super110.apply(this,arguments);}_createClass(LinesInstancingColorRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(LinesInstancingColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{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("// Lines instancing color vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17896
+ */var LinesInstancingColorRenderer=/*#__PURE__*/function(_VBOSceneModelLineIns){_inherits(LinesInstancingColorRenderer,_VBOSceneModelLineIns);var _super110=_createSuper(LinesInstancingColorRenderer);function LinesInstancingColorRenderer(){_classCallCheck(this,LinesInstancingColorRenderer);return _super110.apply(this,arguments);}_createClass(LinesInstancingColorRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(LinesInstancingColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Lines instancing color vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
17872
17897
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}src.push("uniform vec4 lightAmbient;");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
17873
17898
  // renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
17874
17899
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17875
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}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 i;var len;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Lines instancing color 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;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("}");}// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17900
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}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 i;var len;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Lines instancing color 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");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(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;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("}");}// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
17876
17901
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
17877
17902
  if(this._withSAO){src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBAToDepth(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * ambient, vColor.a);");}else{src.push(" outColor = vColor;");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return LinesInstancingColorRenderer;}(VBOSceneModelLineInstancingRenderer);/**
17878
17903
  * @private
17879
- */var LinesInstancingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelLineIns2){_inherits(LinesInstancingSilhouetteRenderer,_VBOSceneModelLineIns2);var _super111=_createSuper(LinesInstancingSilhouetteRenderer);function LinesInstancingSilhouetteRenderer(){_classCallCheck(this,LinesInstancingSilhouetteRenderer);return _super111.apply(this,arguments);}_createClass(LinesInstancingSilhouetteRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){_get(_getPrototypeOf(LinesInstancingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,instancingLayer,renderPass,{colorUniform:true});}},{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("// Lines instancing silhouette vertex shader");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
17904
+ */var LinesInstancingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelLineIns2){_inherits(LinesInstancingSilhouetteRenderer,_VBOSceneModelLineIns2);var _super111=_createSuper(LinesInstancingSilhouetteRenderer);function LinesInstancingSilhouetteRenderer(){_classCallCheck(this,LinesInstancingSilhouetteRenderer);return _super111.apply(this,arguments);}_createClass(LinesInstancingSilhouetteRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){_get(_getPrototypeOf(LinesInstancingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,instancingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Lines instancing silhouette vertex shader");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
17880
17905
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}src.push("uniform vec4 color;");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// silhouetteFlag = NOT_RENDERED | SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
17881
17906
  // renderPass = SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
17882
17907
  src.push("int silhouetteFlag = int(flags) >> 4 & 0xF;");src.push("if (silhouetteFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17883
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}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("// Lines instancing silhouette 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i277=0,len=sectionPlanesState.sectionPlanes.length;_i277<len;_i277++){src.push("uniform bool sectionPlaneActive"+_i277+";");src.push("uniform vec3 sectionPlanePos"+_i277+";");src.push("uniform vec3 sectionPlaneDir"+_i277+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");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 _i278=0,_len64=sectionPlanesState.sectionPlanes.length;_i278<_len64;_i278++){src.push("if (sectionPlaneActive"+_i278+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i278+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i278+".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;");}src.push("outColor = color;");src.push("}");return src;}}]);return LinesInstancingSilhouetteRenderer;}(VBOSceneModelLineInstancingRenderer);/**
17908
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}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.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Lines instancing silhouette 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i277=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i277<len;_i277++){src.push("uniform bool sectionPlaneActive"+_i277+";");src.push("uniform vec3 sectionPlanePos"+_i277+";");src.push("uniform vec3 sectionPlaneDir"+_i277+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");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 _i278=0,_len64=sectionPlanesState.getNumAllocatedSectionPlanes();_i278<_len64;_i278++){src.push("if (sectionPlaneActive"+_i278+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i278+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i278+".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;");}src.push("outColor = color;");src.push("}");return src;}}]);return LinesInstancingSilhouetteRenderer;}(VBOSceneModelLineInstancingRenderer);/**
17884
17909
  * @private
17885
17910
  */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={};/**
17886
17911
  * @private
@@ -17950,33 +17975,33 @@ if(!this._finalized){throw"Not finalized";}var offset=portionId*4;tempFloat32Vec
17950
17975
  },{key:"drawShadow",value:function drawShadow(renderFlags,frameCtx){}//---- PICKING ----------------------------------------------------------------------------------------------------
17951
17976
  },{key:"drawPickMesh",value:function drawPickMesh(renderFlags,frameCtx){}},{key:"drawPickDepths",value:function drawPickDepths(renderFlags,frameCtx){}},{key:"drawPickNormals",value:function drawPickNormals(renderFlags,frameCtx){}},{key:"destroy",value:function destroy(){var state=this._state;if(state.positionsBuf){state.positionsBuf.destroy();state.positionsBuf=null;}if(state.colorsBuf){state.colorsBuf.destroy();state.colorsBuf=null;}if(state.flagsBuf){state.flagsBuf.destroy();state.flagsBuf=null;}if(state.offsetsBuf){state.offsetsBuf.destroy();state.offsetsBuf=null;}if(state.modelMatrixCol0Buf){state.modelMatrixCol0Buf.destroy();state.modelMatrixCol0Buf=null;}if(state.modelMatrixCol1Buf){state.modelMatrixCol1Buf.destroy();state.modelMatrixCol1Buf=null;}if(state.modelMatrixCol2Buf){state.modelMatrixCol2Buf.destroy();state.modelMatrixCol2Buf=null;}state.destroy();}}]);return LinesInstancingLayer;}();/**
17952
17977
  * @private
17953
- */var PointsBatchingColorRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa){_inherits(PointsBatchingColorRenderer,_VBOSceneModelPointBa);var _super112=_createSuper(PointsBatchingColorRenderer);function PointsBatchingColorRenderer(){_classCallCheck(this,PointsBatchingColorRenderer);return _super112.apply(this,arguments);}_createClass(PointsBatchingColorRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(PointsBatchingColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial;var src=[];src.push('#version 300 es');src.push("// Points batching color vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(pointsMaterial.filterIntensity){src.push("uniform vec2 intensityRange;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}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
17978
+ */var PointsBatchingColorRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa){_inherits(PointsBatchingColorRenderer,_VBOSceneModelPointBa);var _super112=_createSuper(PointsBatchingColorRenderer);function PointsBatchingColorRenderer(){_classCallCheck(this,PointsBatchingColorRenderer);return _super112.apply(this,arguments);}_createClass(PointsBatchingColorRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(PointsBatchingColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial;var src=[];src.push('#version 300 es');src.push("// Points batching color vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(pointsMaterial.filterIntensity){src.push("uniform vec2 intensityRange;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}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
17954
17979
  // renderPass = COLOR_OPAQUE
17955
17980
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17956
17981
  src.push("} else {");if(pointsMaterial.filterIntensity){src.push("float intensity = float(color.a) / 255.0;");src.push("if (intensity < intensityRange[0] || intensity > intensityRange[1]) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17957
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, 1.0);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");if(pointsMaterial.filterIntensity){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 batching color 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i280=0,len=sectionPlanesState.sectionPlanes.length;_i280<len;_i280++){src.push("uniform bool sectionPlaneActive"+_i280+";");src.push("uniform vec3 sectionPlanePos"+_i280+";");src.push("uniform vec3 sectionPlaneDir"+_i280+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i281=0,_len65=sectionPlanesState.sectionPlanes.length;_i281<_len65;_i281++){src.push("if (sectionPlaneActive"+_i281+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i281+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i281+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vColor;");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return PointsBatchingColorRenderer;}(VBOSceneModelPointBatchingRenderer);/**
17982
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, 1.0);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");if(pointsMaterial.filterIntensity){src.push("}");}src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points batching color 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i280=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i280<len;_i280++){src.push("uniform bool sectionPlaneActive"+_i280+";");src.push("uniform vec3 sectionPlanePos"+_i280+";");src.push("uniform vec3 sectionPlaneDir"+_i280+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i281=0,_len65=sectionPlanesState.getNumAllocatedSectionPlanes();_i281<_len65;_i281++){src.push("if (sectionPlaneActive"+_i281+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i281+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i281+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vColor;");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return PointsBatchingColorRenderer;}(VBOSceneModelPointBatchingRenderer);/**
17958
17983
  * @private
17959
- */var PointsBatchingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa2){_inherits(PointsBatchingSilhouetteRenderer,_VBOSceneModelPointBa2);var _super113=_createSuper(PointsBatchingSilhouetteRenderer);function PointsBatchingSilhouetteRenderer(){_classCallCheck(this,PointsBatchingSilhouetteRenderer);return _super113.apply(this,arguments);}_createClass(PointsBatchingSilhouetteRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,pointsBatchingLayer,renderPass){_get(_getPrototypeOf(PointsBatchingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,pointsBatchingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points batching silhouette vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);src.push("uniform vec4 color;");src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// silhouetteFlag = NOT_RENDERED | SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | SILHOUETTE_XRAYED
17984
+ */var PointsBatchingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa2){_inherits(PointsBatchingSilhouetteRenderer,_VBOSceneModelPointBa2);var _super113=_createSuper(PointsBatchingSilhouetteRenderer);function PointsBatchingSilhouetteRenderer(){_classCallCheck(this,PointsBatchingSilhouetteRenderer);return _super113.apply(this,arguments);}_createClass(PointsBatchingSilhouetteRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,pointsBatchingLayer,renderPass){_get(_getPrototypeOf(PointsBatchingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,pointsBatchingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points batching silhouette vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);src.push("uniform vec4 color;");src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// silhouetteFlag = NOT_RENDERED | SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | SILHOUETTE_XRAYED
17960
17985
  // renderPass = SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
17961
17986
  src.push("int silhouetteFlag = int(flags) >> 4 & 0xF;");src.push("if (silhouetteFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17962
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var i;var len;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Points batching silhouette vertex 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;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 = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outColor = color;");src.push("}");return src;}}]);return PointsBatchingSilhouetteRenderer;}(VBOSceneModelPointBatchingRenderer);/**
17987
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var i;var len;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points batching silhouette vertex 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;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 = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outColor = color;");src.push("}");return src;}}]);return PointsBatchingSilhouetteRenderer;}(VBOSceneModelPointBatchingRenderer);/**
17963
17988
  * @private
17964
- */var PointsBatchingPickMeshRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa3){_inherits(PointsBatchingPickMeshRenderer,_VBOSceneModelPointBa3);var _super114=_createSuper(PointsBatchingPickMeshRenderer);function PointsBatchingPickMeshRenderer(){_classCallCheck(this,PointsBatchingPickMeshRenderer);return _super114.apply(this,arguments);}_createClass(PointsBatchingPickMeshRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points batching pick mesh vertex shader");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 pickColor;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vPickColor;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17989
+ */var PointsBatchingPickMeshRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa3){_inherits(PointsBatchingPickMeshRenderer,_VBOSceneModelPointBa3);var _super114=_createSuper(PointsBatchingPickMeshRenderer);function PointsBatchingPickMeshRenderer(){_classCallCheck(this,PointsBatchingPickMeshRenderer);return _super114.apply(this,arguments);}_createClass(PointsBatchingPickMeshRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points batching pick mesh vertex shader");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 pickColor;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vPickColor;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17965
17990
  // renderPass = PICK
17966
17991
  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
17967
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vPickColor = vec4(float(pickColor.r) / 255.0, float(pickColor.g) / 255.0, float(pickColor.b) / 255.0, float(pickColor.a) / 255.0);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = remapClipPos(clipPos);");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("gl_PointSize += 10.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("// Points batching pick mesh vertex 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");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 vPickColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i282=0;_i282<sectionPlanesState.sectionPlanes.length;_i282++){src.push(" if (sectionPlaneActive"+_i282+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i282+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i282+".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;");}src.push(" outColor = vPickColor; ");src.push("}");return src;}}]);return PointsBatchingPickMeshRenderer;}(VBOSceneModelPointBatchingRenderer);/**
17992
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vPickColor = vec4(float(pickColor.r) / 255.0, float(pickColor.g) / 255.0, float(pickColor.b) / 255.0, float(pickColor.a) / 255.0);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = remapClipPos(clipPos);");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("gl_PointSize += 10.0;");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points batching pick mesh vertex 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec4 vPickColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i282=0;_i282<sectionPlanesState.getNumAllocatedSectionPlanes();_i282++){src.push(" if (sectionPlaneActive"+_i282+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i282+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i282+".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;");}src.push(" outColor = vPickColor; ");src.push("}");return src;}}]);return PointsBatchingPickMeshRenderer;}(VBOSceneModelPointBatchingRenderer);/**
17968
17993
  * @private
17969
- */var PointsBatchingPickDepthRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa4){_inherits(PointsBatchingPickDepthRenderer,_VBOSceneModelPointBa4);var _super115=_createSuper(PointsBatchingPickDepthRenderer);function PointsBatchingPickDepthRenderer(){_classCallCheck(this,PointsBatchingPickDepthRenderer);return _super115.apply(this,arguments);}_createClass(PointsBatchingPickDepthRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points batched pick depth vertex shader");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;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17994
+ */var PointsBatchingPickDepthRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa4){_inherits(PointsBatchingPickDepthRenderer,_VBOSceneModelPointBa4);var _super115=_createSuper(PointsBatchingPickDepthRenderer);function PointsBatchingPickDepthRenderer(){_classCallCheck(this,PointsBatchingPickDepthRenderer);return _super115.apply(this,arguments);}_createClass(PointsBatchingPickDepthRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points batched pick depth vertex shader");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;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
17970
17995
  // renderPass = PICK
17971
17996
  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
17972
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vViewPosition = viewPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = remapClipPos(clipPos);");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("gl_PointSize += 10.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("// Points batched 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("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("in float vFlags;");for(var _i283=0;_i283<sectionPlanesState.sectionPlanes.length;_i283++){src.push("uniform bool sectionPlaneActive"+_i283+";");src.push("uniform vec3 sectionPlanePos"+_i283+";");src.push("uniform vec3 sectionPlaneDir"+_i283+";");}}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 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}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 = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");src.push(" outColor = packDepth(zNormalizedDepth); ");// Must be linear depth
17997
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vViewPosition = viewPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = remapClipPos(clipPos);");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("gl_PointSize += 10.0;");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points batched 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("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("in float vFlags;");for(var _i283=0;_i283<sectionPlanesState.getNumAllocatedSectionPlanes();_i283++){src.push("uniform bool sectionPlaneActive"+_i283+";");src.push("uniform vec3 sectionPlanePos"+_i283+";");src.push("uniform vec3 sectionPlaneDir"+_i283+";");}}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 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}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.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");src.push(" outColor = packDepth(zNormalizedDepth); ");// Must be linear depth
17973
17998
  src.push("}");return src;}}]);return PointsBatchingPickDepthRenderer;}(VBOSceneModelPointBatchingRenderer);/**
17974
17999
  * @private
17975
- */var PointsBatchingOcclusionRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa5){_inherits(PointsBatchingOcclusionRenderer,_VBOSceneModelPointBa5);var _super116=_createSuper(PointsBatchingOcclusionRenderer);function PointsBatchingOcclusionRenderer(){_classCallCheck(this,PointsBatchingOcclusionRenderer);return _super116.apply(this,arguments);}_createClass(PointsBatchingOcclusionRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points batching occlusion vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
18000
+ */var PointsBatchingOcclusionRenderer=/*#__PURE__*/function(_VBOSceneModelPointBa5){_inherits(PointsBatchingOcclusionRenderer,_VBOSceneModelPointBa5);var _super116=_createSuper(PointsBatchingOcclusionRenderer);function PointsBatchingOcclusionRenderer(){_classCallCheck(this,PointsBatchingOcclusionRenderer);return _super116.apply(this,arguments);}_createClass(PointsBatchingOcclusionRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points batching occlusion vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
17976
18001
  // renderPass = COLOR_OPAQUE
17977
18002
  // Only opaque objects can be occluders
17978
18003
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
17979
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push(" gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}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 batching occlusion 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i284=0;_i284<sectionPlanesState.sectionPlanes.length;_i284++){src.push("uniform bool sectionPlaneActive"+_i284+";");src.push("uniform vec3 sectionPlanePos"+_i284+";");src.push("uniform vec3 sectionPlaneDir"+_i284+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i285=0;_i285<sectionPlanesState.sectionPlanes.length;_i285++){src.push(" if (sectionPlaneActive"+_i285+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i285+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i285+".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;");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
18004
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push(" gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points batching occlusion 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i284=0;_i284<sectionPlanesState.getNumAllocatedSectionPlanes();_i284++){src.push("uniform bool sectionPlaneActive"+_i284+";");src.push("uniform vec3 sectionPlanePos"+_i284+";");src.push("uniform vec3 sectionPlaneDir"+_i284+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i285=0;_i285<sectionPlanesState.getNumAllocatedSectionPlanes();_i285++){src.push(" if (sectionPlaneActive"+_i285+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i285+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i285+".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;");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
17980
18005
  src.push("}");return src;}}]);return PointsBatchingOcclusionRenderer;}(VBOSceneModelPointBatchingRenderer);/**
17981
18006
  * @private
17982
18007
  */var PointsBatchingRenderers=/*#__PURE__*/function(){function PointsBatchingRenderers(scene){_classCallCheck(this,PointsBatchingRenderers);this._scene=scene;}_createClass(PointsBatchingRenderers,[{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;}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;}}},{key:"colorRenderer",get:function get(){if(!this._colorRenderer){this._colorRenderer=new PointsBatchingColorRenderer(this._scene);}return this._colorRenderer;}},{key:"silhouetteRenderer",get:function get(){if(!this._silhouetteRenderer){this._silhouetteRenderer=new PointsBatchingSilhouetteRenderer(this._scene);}return this._silhouetteRenderer;}},{key:"pickMeshRenderer",get:function get(){if(!this._pickMeshRenderer){this._pickMeshRenderer=new PointsBatchingPickMeshRenderer(this._scene);}return this._pickMeshRenderer;}},{key:"pickDepthRenderer",get:function get(){if(!this._pickDepthRenderer){this._pickDepthRenderer=new PointsBatchingPickDepthRenderer(this._scene);}return this._pickDepthRenderer;}},{key:"occlusionRenderer",get:function get(){if(!this._occlusionRenderer){this._occlusionRenderer=new PointsBatchingOcclusionRenderer(this._scene);}return this._occlusionRenderer;}},{key:"_destroy",value:function _destroy(){if(this._colorRenderer){this._colorRenderer.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();}}}]);return PointsBatchingRenderers;}();var cachedRenderers$1={};/**
@@ -18046,48 +18071,48 @@ return;}var portionsIdx=portionId*2;var vertexBase=this._portions[portionsIdx];v
18046
18071
  },{key:"drawOcclusion",value:function drawOcclusion(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}if(this._pointsBatchingRenderers.occlusionRenderer){this._pointsBatchingRenderers.occlusionRenderer.drawLayer(frameCtx,this,RENDER_PASSES.COLOR_OPAQUE);}}//---- SHADOWS -----------------------------------------------------------------------------------------------------
18047
18072
  },{key:"drawShadow",value:function drawShadow(renderFlags,frameCtx){}},{key:"destroy",value:function destroy(){var state=this._state;if(state.positionsBuf){state.positionsBuf.destroy();state.positionsBuf=null;}if(state.offsetsBuf){state.offsetsBuf.destroy();state.offsetsBuf=null;}if(state.colorsBuf){state.colorsBuf.destroy();state.colorsBuf=null;}if(state.flagsBuf){state.flagsBuf.destroy();state.flagsBuf=null;}if(state.pickColorsBuf){state.pickColorsBuf.destroy();state.pickColorsBuf=null;}state.destroy();}}]);return PointsBatchingLayer;}();/**
18048
18073
  * @private
18049
- */var PointsInstancingColorRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn){_inherits(PointsInstancingColorRenderer,_VBOSceneModelPointIn);var _super117=_createSuper(PointsInstancingColorRenderer);function PointsInstancingColorRenderer(){_classCallCheck(this,PointsInstancingColorRenderer);return _super117.apply(this,arguments);}_createClass(PointsInstancingColorRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(PointsInstancingColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing color vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
18074
+ */var PointsInstancingColorRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn){_inherits(PointsInstancingColorRenderer,_VBOSceneModelPointIn);var _super117=_createSuper(PointsInstancingColorRenderer);function PointsInstancingColorRenderer(){_classCallCheck(this,PointsInstancingColorRenderer);return _super117.apply(this,arguments);}_createClass(PointsInstancingColorRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){_get(_getPrototypeOf(PointsInstancingColorRenderer.prototype),"drawLayer",this).call(this,frameCtx,layer,renderPass,{incrementDrawState:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing color vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in float flags;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
18050
18075
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(pointsMaterial.filterIntensity){src.push("uniform vec2 intensityRange;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}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
18051
18076
  // renderPass = COLOR_OPAQUE
18052
18077
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
18053
18078
  src.push("} else {");if(pointsMaterial.filterIntensity){src.push("float intensity = float(color.a) / 255.0;");src.push("if (intensity < intensityRange[0] || intensity > intensityRange[1]) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
18054
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, 1.0);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");if(pointsMaterial.filterIntensity){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 color 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i298=0,len=sectionPlanesState.sectionPlanes.length;_i298<len;_i298++){src.push("uniform bool sectionPlaneActive"+_i298+";");src.push("uniform vec3 sectionPlanePos"+_i298+";");src.push("uniform vec3 sectionPlaneDir"+_i298+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i299=0,_len72=sectionPlanesState.sectionPlanes.length;_i299<_len72;_i299++){src.push("if (sectionPlaneActive"+_i299+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i299+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i299+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vColor;");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return PointsInstancingColorRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18079
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, 1.0);");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");if(pointsMaterial.filterIntensity){src.push("}");}src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points instancing color 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i298=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i298<len;_i298++){src.push("uniform bool sectionPlaneActive"+_i298+";");src.push("uniform vec3 sectionPlanePos"+_i298+";");src.push("uniform vec3 sectionPlaneDir"+_i298+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i299=0,_len72=sectionPlanesState.getNumAllocatedSectionPlanes();_i299<_len72;_i299++){src.push("if (sectionPlaneActive"+_i299+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i299+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i299+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vColor;");if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return PointsInstancingColorRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18055
18080
  * @private
18056
- */var PointsInstancingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn2){_inherits(PointsInstancingSilhouetteRenderer,_VBOSceneModelPointIn2);var _super118=_createSuper(PointsInstancingSilhouetteRenderer);function PointsInstancingSilhouetteRenderer(){_classCallCheck(this,PointsInstancingSilhouetteRenderer);return _super118.apply(this,arguments);}_createClass(PointsInstancingSilhouetteRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){_get(_getPrototypeOf(PointsInstancingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,instancingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing silhouette vertex shader");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 color;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
18081
+ */var PointsInstancingSilhouetteRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn2){_inherits(PointsInstancingSilhouetteRenderer,_VBOSceneModelPointIn2);var _super118=_createSuper(PointsInstancingSilhouetteRenderer);function PointsInstancingSilhouetteRenderer(){_classCallCheck(this,PointsInstancingSilhouetteRenderer);return _super118.apply(this,arguments);}_createClass(PointsInstancingSilhouetteRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){_get(_getPrototypeOf(PointsInstancingSilhouetteRenderer.prototype),"drawLayer",this).call(this,frameCtx,instancingLayer,renderPass,{colorUniform:true});}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing silhouette vertex shader");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 color;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
18057
18082
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}src.push("uniform vec4 silhouetteColor;");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vColor;");src.push("void main(void) {");// silhouetteFlag = NOT_RENDERED | SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
18058
18083
  // renderPass = SILHOUETTE_HIGHLIGHTED | SILHOUETTE_SELECTED | | SILHOUETTE_XRAYED
18059
18084
  src.push("int silhouetteFlag = int(flags) >> 4 & 0xF;");src.push("if (silhouetteFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
18060
- 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("vColor = vec4(float(silhouetteColor.r) / 255.0, float(silhouetteColor.g) / 255.0, float(silhouetteColor.b) / 255.0, float(color.a) / 255.0);");src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}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 silhouette 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i300=0,len=sectionPlanesState.sectionPlanes.length;_i300<len;_i300++){src.push("uniform bool sectionPlaneActive"+_i300+";");src.push("uniform vec3 sectionPlanePos"+_i300+";");src.push("uniform vec3 sectionPlaneDir"+_i300+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i301=0,_len73=sectionPlanesState.sectionPlanes.length;_i301<_len73;_i301++){src.push("if (sectionPlaneActive"+_i301+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i301+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i301+".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;");}src.push("outColor = vColor;");src.push("}");return src;}}]);return PointsInstancingSilhouetteRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18085
+ 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("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("vColor = vec4(float(silhouetteColor.r) / 255.0, float(silhouetteColor.g) / 255.0, float(silhouetteColor.b) / 255.0, float(color.a) / 255.0);");src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points instancing silhouette 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i300=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i300<len;_i300++){src.push("uniform bool sectionPlaneActive"+_i300+";");src.push("uniform vec3 sectionPlanePos"+_i300+";");src.push("uniform vec3 sectionPlaneDir"+_i300+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i301=0,_len73=sectionPlanesState.getNumAllocatedSectionPlanes();_i301<_len73;_i301++){src.push("if (sectionPlaneActive"+_i301+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i301+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i301+".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;");}src.push("outColor = vColor;");src.push("}");return src;}}]);return PointsInstancingSilhouetteRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18061
18086
  * @private
18062
- */var PointsInstancingPickMeshRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn3){_inherits(PointsInstancingPickMeshRenderer,_VBOSceneModelPointIn3);var _super119=_createSuper(PointsInstancingPickMeshRenderer);function PointsInstancingPickMeshRenderer(){_classCallCheck(this,PointsInstancingPickMeshRenderer);return _super119.apply(this,arguments);}_createClass(PointsInstancingPickMeshRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing pick mesh vertex shader");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 pickColor;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
18087
+ */var PointsInstancingPickMeshRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn3){_inherits(PointsInstancingPickMeshRenderer,_VBOSceneModelPointIn3);var _super119=_createSuper(PointsInstancingPickMeshRenderer);function PointsInstancingPickMeshRenderer(){_classCallCheck(this,PointsInstancingPickMeshRenderer);return _super119.apply(this,arguments);}_createClass(PointsInstancingPickMeshRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing pick mesh vertex shader");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 pickColor;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
18063
18088
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vPickColor;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
18064
18089
  // renderPass = PICK
18065
18090
  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
18066
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vPickColor = vec4(float(pickColor.r) / 255.0, float(pickColor.g) / 255.0, float(pickColor.b) / 255.0, float(pickColor.a) / 255.0);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("gl_Position = remapClipPos(clipPos);");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}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 mesh 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i302=0;_i302<sectionPlanesState.sectionPlanes.length;_i302++){src.push("uniform bool sectionPlaneActive"+_i302+";");src.push("uniform vec3 sectionPlanePos"+_i302+";");src.push("uniform vec3 sectionPlaneDir"+_i302+";");}}src.push("in vec4 vPickColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i303=0;_i303<sectionPlanesState.sectionPlanes.length;_i303++){src.push("if (sectionPlaneActive"+_i303+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i303+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i303+".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;");}src.push("outColor = vPickColor; ");src.push("}");return src;}}]);return PointsInstancingPickMeshRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18091
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vPickColor = vec4(float(pickColor.r) / 255.0, float(pickColor.g) / 255.0, float(pickColor.b) / 255.0, float(pickColor.a) / 255.0);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("gl_Position = remapClipPos(clipPos);");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points instancing pick mesh 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i302=0;_i302<sectionPlanesState.getNumAllocatedSectionPlanes();_i302++){src.push("uniform bool sectionPlaneActive"+_i302+";");src.push("uniform vec3 sectionPlanePos"+_i302+";");src.push("uniform vec3 sectionPlaneDir"+_i302+";");}}src.push("in vec4 vPickColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i303=0;_i303<sectionPlanesState.getNumAllocatedSectionPlanes();_i303++){src.push("if (sectionPlaneActive"+_i303+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i303+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i303+".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;");}src.push("outColor = vPickColor; ");src.push("}");return src;}}]);return PointsInstancingPickMeshRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18067
18092
  * @private
18068
- */var PointsInstancingPickDepthRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn4){_inherits(PointsInstancingPickDepthRenderer,_VBOSceneModelPointIn4);var _super120=_createSuper(PointsInstancingPickDepthRenderer);function PointsInstancingPickDepthRenderer(){_classCallCheck(this,PointsInstancingPickDepthRenderer);return _super120.apply(this,arguments);}_createClass(PointsInstancingPickDepthRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing pick depth vertex shader");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
18093
+ */var PointsInstancingPickDepthRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn4){_inherits(PointsInstancingPickDepthRenderer,_VBOSceneModelPointIn4);var _super120=_createSuper(PointsInstancingPickDepthRenderer);function PointsInstancingPickDepthRenderer(){_classCallCheck(this,PointsInstancingPickDepthRenderer);return _super120.apply(this,arguments);}_createClass(PointsInstancingPickDepthRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing pick depth vertex shader");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
18069
18094
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);this._addRemapClipPosLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out vec4 vViewPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
18070
18095
  // renderPass = PICK
18071
18096
  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
18072
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push(" vViewPosition = viewPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("gl_Position = remapClipPos(clipPos);");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = remapClipPos(clipPos);");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}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("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("in float vFlags;");for(var _i304=0;_i304<sectionPlanesState.sectionPlanes.length;_i304++){src.push("uniform bool sectionPlaneActive"+_i304+";");src.push("uniform vec3 sectionPlanePos"+_i304+";");src.push("uniform vec3 sectionPlaneDir"+_i304+";");}}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 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i305=0;_i305<sectionPlanesState.sectionPlanes.length;_i305++){src.push("if (sectionPlaneActive"+_i305+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i305+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i305+".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;");}src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");src.push(" outColor = packDepth(zNormalizedDepth); ");// Must be linear depth
18097
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push(" vViewPosition = viewPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("gl_Position = remapClipPos(clipPos);");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = remapClipPos(clipPos);");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>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("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("in float vFlags;");for(var _i304=0;_i304<sectionPlanesState.getNumAllocatedSectionPlanes();_i304++){src.push("uniform bool sectionPlaneActive"+_i304+";");src.push("uniform vec3 sectionPlanePos"+_i304+";");src.push("uniform vec3 sectionPlaneDir"+_i304+";");}}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 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i305=0;_i305<sectionPlanesState.getNumAllocatedSectionPlanes();_i305++){src.push("if (sectionPlaneActive"+_i305+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i305+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i305+".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;");}src.push(" float zNormalizedDepth = abs((pickZNear + vViewPosition.z) / (pickZFar - pickZNear));");src.push(" outColor = packDepth(zNormalizedDepth); ");// Must be linear depth
18073
18098
  src.push("}");return src;}}]);return PointsInstancingPickDepthRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18074
18099
  * @private
18075
- */var PointsInstancingOcclusionRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn5){_inherits(PointsInstancingOcclusionRenderer,_VBOSceneModelPointIn5);var _super121=_createSuper(PointsInstancingOcclusionRenderer);function PointsInstancingOcclusionRenderer(){_classCallCheck(this,PointsInstancingOcclusionRenderer);return _super121.apply(this,arguments);}_createClass(PointsInstancingOcclusionRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing occlusion vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
18100
+ */var PointsInstancingOcclusionRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn5){_inherits(PointsInstancingOcclusionRenderer,_VBOSceneModelPointIn5);var _super121=_createSuper(PointsInstancingOcclusionRenderer);function PointsInstancingOcclusionRenderer(){_classCallCheck(this,PointsInstancingOcclusionRenderer);return _super121.apply(this,arguments);}_createClass(PointsInstancingOcclusionRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing occlusion vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
18076
18101
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
18077
18102
  // renderPass = COLOR_OPAQUE
18078
- src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}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 occlusion vertex 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i306=0;_i306<sectionPlanesState.sectionPlanes.length;_i306++){src.push("uniform bool sectionPlaneActive"+_i306+";");src.push("uniform vec3 sectionPlanePos"+_i306+";");src.push("uniform vec3 sectionPlaneDir"+_i306+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i307=0;_i307<sectionPlanesState.sectionPlanes.length;_i307++){src.push("if (sectionPlaneActive"+_i307+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i307+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i307+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
18103
+ src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points instancing occlusion vertex 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i306=0;_i306<sectionPlanesState.getNumAllocatedSectionPlanes();_i306++){src.push("uniform bool sectionPlaneActive"+_i306+";");src.push("uniform vec3 sectionPlanePos"+_i306+";");src.push("uniform vec3 sectionPlaneDir"+_i306+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i307=0;_i307<sectionPlanesState.getNumAllocatedSectionPlanes();_i307++){src.push("if (sectionPlaneActive"+_i307+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i307+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i307+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
18079
18104
  if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return PointsInstancingOcclusionRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18080
18105
  * @private
18081
- */var PointsInstancingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn6){_inherits(PointsInstancingDepthRenderer,_VBOSceneModelPointIn6);var _super122=_createSuper(PointsInstancingDepthRenderer);function PointsInstancingDepthRenderer(){_classCallCheck(this,PointsInstancingDepthRenderer);return _super122.apply(this,arguments);}_createClass(PointsInstancingDepthRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing depth vertex shader");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;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
18106
+ */var PointsInstancingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn6){_inherits(PointsInstancingDepthRenderer,_VBOSceneModelPointIn6);var _super122=_createSuper(PointsInstancingDepthRenderer);function PointsInstancingDepthRenderer(){_classCallCheck(this,PointsInstancingDepthRenderer);return _super122.apply(this,arguments);}_createClass(PointsInstancingDepthRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var pointsMaterial=scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// Points instancing depth vertex shader");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;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(pointsMaterial.perspectivePoints){src.push("uniform float nearPlaneHeight;");}if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");// colorFlag = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
18082
18107
  // renderPass = COLOR_OPAQUE
18083
18108
  src.push("int colorFlag = int(flags) & 0xF;");src.push("if (colorFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
18084
- 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var i;var len;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Points instancing depth vertex 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("const float packUpScale = 256. / 255.;");src.push("const float unpackDownscale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unpackFactors = unpackDownscale / vec4( packFactors, 1. );");src.push("const float shiftRight8 = 1.0 / 256.;");src.push("vec4 packDepthToRGBA( const in float v ) {");src.push(" vec4 r = vec4( fract( v * packFactors ), v );");src.push(" r.yzw -= r.xyz * shiftRight8;");src.push(" return r * packUpScale;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(i=0,len=sectionPlanesState.sectionPlanes.length;i<len;i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = packDepthToRGBA( gl_FragCoord.z); ");// Must be linear depth
18109
+ 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(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");}src.push("gl_Position = clipPos;");if(pointsMaterial.perspectivePoints){src.push("gl_PointSize = (nearPlaneHeight * pointSize) / clipPos.w;");src.push("gl_PointSize = max(gl_PointSize, "+Math.floor(pointsMaterial.minPerspectivePointSize)+".0);");src.push("gl_PointSize = min(gl_PointSize, "+Math.floor(pointsMaterial.maxPerspectivePointSize)+".0);");}else{src.push("gl_PointSize = pointSize;");}src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var i;var len;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points instancing depth vertex 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("const float packUpScale = 256. / 255.;");src.push("const float unpackDownscale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unpackFactors = unpackDownscale / vec4( packFactors, 1. );");src.push("const float shiftRight8 = 1.0 / 256.;");src.push("vec4 packDepthToRGBA( const in float v ) {");src.push(" vec4 r = vec4( fract( v * packFactors ), v );");src.push(" r.yzw -= r.xyz * shiftRight8;");src.push(" return r * packUpScale;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");if(scene.pointsMaterial.roundPoints){src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");}if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(i=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();i<len;i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}src.push(" outColor = packDepthToRGBA( gl_FragCoord.z); ");// Must be linear depth
18085
18110
  if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}}]);return PointsInstancingDepthRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18086
18111
  * Renders InstancingLayer fragment depths to a shadow map.
18087
18112
  *
18088
18113
  * @private
18089
- */var PointsInstancingShadowRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn7){_inherits(PointsInstancingShadowRenderer,_VBOSceneModelPointIn7);var _super123=_createSuper(PointsInstancingShadowRenderer);function PointsInstancingShadowRenderer(){_classCallCheck(this,PointsInstancingShadowRenderer);return _super123.apply(this,arguments);}_createClass(PointsInstancingShadowRenderer,[{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("// Instancing geometry shadow drawing vertex shader");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");src.push("int colorFlag = int(flags) & 0xF;");src.push("bool visible = (colorFlag > 0);");src.push("bool transparent = ((float(color.a) / 255.0) < 1.0);");src.push("if (!visible || transparent) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
18090
- src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push(" gl_Position = shadowProjMatrix * viewPosition;");src.push("}");src.push("gl_PointSize = pointSize;");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("// Instancing geometry depth drawing 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i308=0,len=sectionPlanesState.sectionPlanes.length;_i308<len;_i308++){src.push("uniform bool sectionPlaneActive"+_i308+";");src.push("uniform vec3 sectionPlanePos"+_i308+";");src.push("uniform vec3 sectionPlaneDir"+_i308+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i309=0,_len74=sectionPlanesState.sectionPlanes.length;_i309<_len74;_i309++){src.push("if (sectionPlaneActive"+_i309+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i309+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i309+".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;");}src.push(" outColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");src.push("}");return src;}}]);return PointsInstancingShadowRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18114
+ */var PointsInstancingShadowRenderer=/*#__PURE__*/function(_VBOSceneModelPointIn7){_inherits(PointsInstancingShadowRenderer,_VBOSceneModelPointIn7);var _super123=_createSuper(PointsInstancingShadowRenderer);function PointsInstancingShadowRenderer(){_classCallCheck(this,PointsInstancingShadowRenderer);return _super123.apply(this,arguments);}_createClass(PointsInstancingShadowRenderer,[{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Instancing geometry shadow drawing vertex shader");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 color;");src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform mat4 shadowViewMatrix;");src.push("uniform mat4 shadowProjMatrix;");this._addMatricesUniformBlockLines(src);src.push("uniform float pointSize;");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("void main(void) {");src.push("int colorFlag = int(flags) & 0xF;");src.push("bool visible = (colorFlag > 0);");src.push("bool transparent = ((float(color.a) / 255.0) < 1.0);");src.push("if (!visible || transparent) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
18115
+ src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = shadowViewMatrix * worldPosition; ");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags = flags;");}src.push(" gl_Position = shadowProjMatrix * viewPosition;");src.push("}");src.push("gl_PointSize = pointSize;");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Instancing geometry depth drawing 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("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i308=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i308<len;_i308++){src.push("uniform bool sectionPlaneActive"+_i308+";");src.push("uniform vec3 sectionPlanePos"+_i308+";");src.push("uniform vec3 sectionPlaneDir"+_i308+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("out vec4 outColor;");src.push("void main(void) {");src.push(" vec2 cxy = 2.0 * gl_PointCoord - 1.0;");src.push(" float r = dot(cxy, cxy);");src.push(" if (r > 1.0) {");src.push(" discard;");src.push(" }");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i309=0,_len74=sectionPlanesState.getNumAllocatedSectionPlanes();_i309<_len74;_i309++){src.push("if (sectionPlaneActive"+_i309+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i309+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i309+".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;");}src.push(" outColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");src.push("}");return src;}}]);return PointsInstancingShadowRenderer;}(VBOSceneModelPointInstancingRenderer);/**
18091
18116
  * @private
18092
18117
  */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={};/**
18093
18118
  * @private
@@ -18554,12 +18579,12 @@ var edgeIndex=void 0;if((edgeIndex=edgeSearch(ii0,ii1))>=0){if(alreadyOutputEdge
18554
18579
  // // throw "Ohhhh2!";
18555
18580
  // }
18556
18581
  // }
18557
- }}var tempVec3a$k=math.vec3();var tempVec3b$g=math.vec3();var tempVec3c$e=math.vec3();var tempVec3d$a=math.vec3();var tempVec4a$6=math.vec4();var tempMat4a$c=math.mat4();/**
18582
+ }}var tempVec3a$k=math.vec3();var tempVec3b$g=math.vec3();var tempVec3c$e=math.vec3();math.vec3();var tempVec4a$6=math.vec4();var tempMat4a$c=math.mat4();/**
18558
18583
  * @private
18559
- */var TrianglesDataTextureColorRenderer=/*#__PURE__*/function(){function TrianglesDataTextureColorRenderer(scene,withSAO){_classCallCheck(this,TrianglesDataTextureColorRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureColorRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$k;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$g);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(camera.viewMatrix,rtcOrigin,tempMat4a$c);rtcCameraEye=tempVec3c$e;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=camera.viewMatrix;rtcCameraEye=camera.eye;}gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3d$a);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
18584
+ */var TrianglesDataTextureColorRenderer=/*#__PURE__*/function(){function TrianglesDataTextureColorRenderer(scene,withSAO){_classCallCheck(this,TrianglesDataTextureColorRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureColorRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$k;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$g);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(camera.viewMatrix,rtcOrigin,tempMat4a$c);rtcCameraEye=tempVec3c$e;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=camera.viewMatrix;rtcCameraEye=camera.eye;}gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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$k);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
18560
18585
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
18561
18586
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
18562
- );gl.drawArrays(gl.TRIANGLES,0,state.numIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;console.error(this.errors);return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];var lights=lightsState.lights;var light;for(var _i334=0,len=lights.length;_i334<len;_i334++){light=lights[_i334];switch(light.type){case"dir":this._uLightColor[_i334]=program.getLocation("lightColor"+_i334);this._uLightPos[_i334]=null;this._uLightDir[_i334]=program.getLocation("lightDir"+_i334);break;case"point":this._uLightColor[_i334]=program.getLocation("lightColor"+_i334);this._uLightPos[_i334]=program.getLocation("lightPos"+_i334);this._uLightDir[_i334]=null;this._uLightAttenuation[_i334]=program.getLocation("lightAttenuation"+_i334);break;case"spot":this._uLightColor[_i334]=program.getLocation("lightColor"+_i334);this._uLightPos[_i334]=program.getLocation("lightPos"+_i334);this._uLightDir[_i334]=program.getLocation("lightDir"+_i334);this._uLightAttenuation[_i334]=program.getLocation("lightAttenuation"+_i334);break;}}this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i335=0,_len83=scene._sectionPlanesState.sectionPlanes.length;_i335<_len83;_i335++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i335),pos:program.getLocation("sectionPlanePos"+_i335),dir:program.getLocation("sectionPlaneDir"+_i335)});}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lights=scene._lightsState.lights;var project=scene.camera.project;program.bind();if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,scene._lightsState.getAmbientColorAndIntensity());}for(var _i336=0,len=lights.length;_i336<len;_i336++){var light=lights[_i336];if(this._uLightColor[_i336]){gl.uniform4f(this._uLightColor[_i336],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i336]){gl.uniform3fv(this._uLightPos[_i336],light.pos);if(this._uLightAttenuation[_i336]){gl.uniform1f(this._uLightAttenuation[_i336],light.attenuation);}}if(this._uLightDir[_i336]){gl.uniform3fv(this._uLightDir[_i336],light.dir);}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4a$6[0]=viewportWidth;tempVec4a$6[1]=viewportHeight;tempVec4a$6[2]=sao.blendCutoff;tempVec4a$6[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4a$6);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,10);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.sectionPlanes.length>0;var light;var src=[];src.push("#version 300 es");src.push("// TrianglesDataTextureColorRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");src.push("uniform mat4 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("uniform vec4 lightAmbient;");for(var _i337=0,len=lightsState.lights.length;_i337<len;_i337++){light=lightsState.lights[_i337];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i337+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i337+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i337+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i337+";");src.push("uniform vec3 lightDir"+_i337+";");}}if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vColor;");src.push("void main(void) {");// constants
18587
+ );gl.drawArrays(gl.TRIANGLES,0,state.numIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;console.error(this.errors);return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];var lights=lightsState.lights;var light;for(var _i334=0,len=lights.length;_i334<len;_i334++){light=lights[_i334];switch(light.type){case"dir":this._uLightColor[_i334]=program.getLocation("lightColor"+_i334);this._uLightPos[_i334]=null;this._uLightDir[_i334]=program.getLocation("lightDir"+_i334);break;case"point":this._uLightColor[_i334]=program.getLocation("lightColor"+_i334);this._uLightPos[_i334]=program.getLocation("lightPos"+_i334);this._uLightDir[_i334]=null;this._uLightAttenuation[_i334]=program.getLocation("lightAttenuation"+_i334);break;case"spot":this._uLightColor[_i334]=program.getLocation("lightColor"+_i334);this._uLightPos[_i334]=program.getLocation("lightPos"+_i334);this._uLightDir[_i334]=program.getLocation("lightDir"+_i334);this._uLightAttenuation[_i334]=program.getLocation("lightAttenuation"+_i334);break;}}this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i335=0,_len83=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i335<_len83;_i335++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i335),pos:program.getLocation("sectionPlanePos"+_i335),dir:program.getLocation("sectionPlaneDir"+_i335)});}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lights=scene._lightsState.lights;var project=scene.camera.project;program.bind();if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,scene._lightsState.getAmbientColorAndIntensity());}for(var _i336=0,len=lights.length;_i336<len;_i336++){var light=lights[_i336];if(this._uLightColor[_i336]){gl.uniform4f(this._uLightColor[_i336],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i336]){gl.uniform3fv(this._uLightPos[_i336],light.pos);if(this._uLightAttenuation[_i336]){gl.uniform1f(this._uLightAttenuation[_i336],light.attenuation);}}if(this._uLightDir[_i336]){gl.uniform3fv(this._uLightDir[_i336],light.dir);}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4a$6[0]=viewportWidth;tempVec4a$6[1]=viewportHeight;tempVec4a$6[2]=sao.blendCutoff;tempVec4a$6[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4a$6);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,10);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var light;var src=[];src.push("#version 300 es");src.push("// TrianglesDataTextureColorRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");src.push("uniform mat4 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("uniform vec4 lightAmbient;");for(var _i337=0,len=lightsState.lights.length;_i337<len;_i337++){light=lightsState.lights[_i337];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i337+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i337+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i337+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i337+";");src.push("uniform vec3 lightDir"+_i337+";");}}if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vColor;");src.push("void main(void) {");// constants
18563
18588
  src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
18564
18589
  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
18565
18590
  src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
@@ -18570,15 +18595,15 @@ src.push("} else {");src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjec
18570
18595
  src.push(" return;");src.push("};");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*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");// when the geometry is not solid, if needed, flip the triangle winding
18571
18596
  src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;");// src.push("vColor = vec4(vec3(1, -1, 0)*dot(normalize(position.xyz - uCameraEyeRtcInQuantizedSpace), normal), 1);")
18572
18597
  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("vColor = vec4(vec3(1, -1, 0)*viewNormal.z, 1);")
18573
- 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 = sceneModelMatrix * ((objectDecodeAndInstanceMatrix * vec4(position, 1.0))); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(var _i338=0,_len84=lightsState.lights.length;_i338<_len84;_i338++){light=lightsState.lights[_i338];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i338+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i338+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i338+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i338+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i338+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i338+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i338+".rgb * lightColor"+_i338+".a);");}src.push("vec3 rgb = vec3(color.rgb) / 255.0;");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// TrianglesDataTextureColorRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i339=0,len=sectionPlanesState.sectionPlanes.length;_i339<len;_i339++){src.push("uniform bool sectionPlaneActive"+_i339+";");src.push("uniform vec3 sectionPlanePos"+_i339+";");src.push("uniform vec3 sectionPlaneDir"+_i339+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i340=0,_len85=sectionPlanesState.sectionPlanes.length;_i340<_len85;_i340++){src.push("if (sectionPlaneActive"+_i340+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i340+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i340+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");//src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
18598
+ 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 = sceneModelMatrix * ((objectDecodeAndInstanceMatrix * vec4(position, 1.0))); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(var _i338=0,_len84=lightsState.lights.length;_i338<_len84;_i338++){light=lightsState.lights[_i338];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i338+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i338+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i338+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i338+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i338+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i338+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i338+".rgb * lightColor"+_i338+".a);");}src.push("vec3 rgb = vec3(color.rgb) / 255.0;");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// TrianglesDataTextureColorRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i339=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i339<len;_i339++){src.push("uniform bool sectionPlaneActive"+_i339+";");src.push("uniform vec3 sectionPlanePos"+_i339+";");src.push("uniform vec3 sectionPlaneDir"+_i339+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i340=0,_len85=sectionPlanesState.getNumAllocatedSectionPlanes();_i340<_len85;_i340++){src.push("if (sectionPlaneActive"+_i340+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i340+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i340+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");//src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
18574
18599
  }if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
18575
18600
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
18576
- src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");}else{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 TrianglesDataTextureColorRenderer;}();var defaultColor$1=new Float32Array([1,1,1]);var tempVec3a$j=math.vec3();var tempVec3b$f=math.vec3();var tempVec3c$d=math.vec3();var tempVec3d$9=math.vec3();var tempMat4a$b=math.mat4();/**
18601
+ src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");}else{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 TrianglesDataTextureColorRenderer;}();var defaultColor$1=new Float32Array([1,1,1]);var tempVec3a$j=math.vec3();var tempVec3b$f=math.vec3();var tempVec3c$d=math.vec3();math.vec3();var tempMat4a$b=math.mat4();/**
18577
18602
  * @private
18578
- */var TrianglesDataTextureSilhouetteRenderer=/*#__PURE__*/function(){function TrianglesDataTextureSilhouetteRenderer(scene,primitiveType){_classCallCheck(this,TrianglesDataTextureSilhouetteRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureSilhouetteRenderer,[{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 scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;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(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3a$j;if(origin){var rotatedOrigin=tempVec3b$f;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$b);rtcCameraEye=tempVec3c$d;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);if(renderPass===RENDER_PASSES.SILHOUETTE_XRAYED){var material=scene.xrayMaterial._state;var fillColor=material.fillColor;var fillAlpha=material.fillAlpha;gl.uniform4f(this._uColor,fillColor[0],fillColor[1],fillColor[2],fillAlpha);}else if(renderPass===RENDER_PASSES.SILHOUETTE_HIGHLIGHTED){var _material3=scene.highlightMaterial._state;var _fillColor=_material3.fillColor;var _fillAlpha=_material3.fillAlpha;gl.uniform4f(this._uColor,_fillColor[0],_fillColor[1],_fillColor[2],_fillAlpha);}else if(renderPass===RENDER_PASSES.SILHOUETTE_SELECTED){var _material4=scene.selectedMaterial._state;var _fillColor2=_material4.fillColor;var _fillAlpha2=_material4.fillAlpha;gl.uniform4f(this._uColor,_fillColor2[0],_fillColor2[1],_fillColor2[2],_fillAlpha2);}else{gl.uniform4fv(this._uColor,defaultColor$1);}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3d$9);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
18603
+ */var TrianglesDataTextureSilhouetteRenderer=/*#__PURE__*/function(){function TrianglesDataTextureSilhouetteRenderer(scene,primitiveType){_classCallCheck(this,TrianglesDataTextureSilhouetteRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureSilhouetteRenderer,[{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 scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;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(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3a$j;if(origin){var rotatedOrigin=tempVec3b$f;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$b);rtcCameraEye=tempVec3c$d;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);if(renderPass===RENDER_PASSES.SILHOUETTE_XRAYED){var material=scene.xrayMaterial._state;var fillColor=material.fillColor;var fillAlpha=material.fillAlpha;gl.uniform4f(this._uColor,fillColor[0],fillColor[1],fillColor[2],fillAlpha);}else if(renderPass===RENDER_PASSES.SILHOUETTE_HIGHLIGHTED){var _material3=scene.highlightMaterial._state;var _fillColor=_material3.fillColor;var _fillAlpha=_material3.fillAlpha;gl.uniform4f(this._uColor,_fillColor[0],_fillColor[1],_fillColor[2],_fillAlpha);}else if(renderPass===RENDER_PASSES.SILHOUETTE_SELECTED){var _material4=scene.selectedMaterial._state;var _fillColor2=_material4.fillColor;var _fillAlpha2=_material4.fillAlpha;gl.uniform4f(this._uColor,_fillColor2[0],_fillColor2[1],_fillColor2[2],_fillAlpha2);}else{gl.uniform4fv(this._uColor,defaultColor$1);}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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$j);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
18579
18604
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
18580
18605
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
18581
- );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._uColor=program.getLocation("color");this._uWorldMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i341=0,len=scene._sectionPlanesState.sectionPlanes.length;_i341<len;_i341++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i341),pos:program.getLocation("sectionPlanePos"+_i341),dir:program.getLocation("sectionPlaneDir"+_i341)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var project=scene.camera.project;this._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("// Triangles dataTexture silhouette 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");// src.push("uniform sampler2D uOcclusionTexture;");
18606
+ );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._uColor=program.getLocation("color");this._uWorldMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i341=0,len=scene.getMaxSectionPlanes();_i341<len;_i341++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i341),pos:program.getLocation("sectionPlanePos"+_i341),dir:program.getLocation("sectionPlaneDir"+_i341)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var project=scene.camera.project;this._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 clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles dataTexture silhouette 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");// src.push("uniform sampler2D uOcclusionTexture;");
18582
18607
  src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("void main(void) {");// constants
18583
18608
  src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
18584
18609
  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
@@ -18590,12 +18615,12 @@ src.push("} else {");// get vertex base
18590
18615
  src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");src.push("ivec4 packedIndexBaseOffset = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+5, objectIndexCoords.y), 0));");src.push("int indexBaseOffset = (packedIndexBaseOffset.r << 24) + (packedIndexBaseOffset.g << 16) + (packedIndexBaseOffset.b << 8) + packedIndexBaseOffset.a;");src.push("int h_index = (polygonIndex - indexBaseOffset) & 4095;");src.push("int v_index = (polygonIndex - indexBaseOffset) >> 12;");src.push("ivec3 vertexIndices = ivec3(texelFetch(uTexturePerPolygonIdIndices, ivec2(h_index, v_index), 0));");src.push("ivec3 uniqueVertexIndexes = vertexIndices + (packedVertexBase.r << 24) + (packedVertexBase.g << 16) + (packedVertexBase.b << 8) + packedVertexBase.a;");src.push("ivec3 indexPositionH = uniqueVertexIndexes & 4095;");src.push("ivec3 indexPositionV = uniqueVertexIndexes >> 12;");src.push("mat4 objectInstanceMatrix = mat4 (texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("mat4 objectDecodeAndInstanceMatrix = objectInstanceMatrix * mat4 (texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("uint solid = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+7, objectIndexCoords.y), 0).r;");// get position
18591
18616
  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
18592
18617
  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*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");// when the geometry is not solid, if needed, flip the triangle winding
18593
- src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * 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 = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Triangles dataTexture draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i342=0,len=sectionPlanesState.sectionPlanes.length;_i342<len;_i342++){src.push("uniform bool sectionPlaneActive"+_i342+";");src.push("uniform vec3 sectionPlanePos"+_i342+";");src.push("uniform vec3 sectionPlaneDir"+_i342+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i343=0,_len86=sectionPlanesState.sectionPlanes.length;_i343<_len86;_i343++){src.push("if (sectionPlaneActive"+_i343+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i343+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i343+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = color;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureSilhouetteRenderer;}();var defaultColor=new Float32Array([0,0,0,1]);var tempVec3a$i=math.vec3();var tempVec3b$e=math.vec3();var tempVec3d$8=math.vec3();var tempMat4a$a=math.mat4();/**
18618
+ src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * 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 = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Triangles dataTexture draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i342=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i342<len;_i342++){src.push("uniform bool sectionPlaneActive"+_i342+";");src.push("uniform vec3 sectionPlanePos"+_i342+";");src.push("uniform vec3 sectionPlaneDir"+_i342+";");}}src.push("uniform vec4 color;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i343=0,_len86=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i343<_len86;_i343++){src.push("if (sectionPlaneActive"+_i343+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i343+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i343+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = color;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureSilhouetteRenderer;}();var defaultColor=new Float32Array([0,0,0,1]);var tempVec3a$i=math.vec3();var tempVec3b$e=math.vec3();math.vec3();var tempMat4a$a=math.mat4();/**
18594
18619
  * @private
18595
- */var TrianglesDataTextureEdgesRenderer=/*#__PURE__*/function(){function TrianglesDataTextureEdgesRenderer(scene){_classCallCheck(this,TrianglesDataTextureEdgesRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureEdgesRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var model=dataTextureLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate(dataTextureLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$i;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$e);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$a);}else{rtcViewMatrix=viewMatrix;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);if(renderPass===RENDER_PASSES.EDGES_XRAYED){var material=scene.xrayMaterial._state;var edgeColor=material.edgeColor;var edgeAlpha=material.edgeAlpha;gl.uniform4f(this._uColor,edgeColor[0],edgeColor[1],edgeColor[2],edgeAlpha);}else if(renderPass===RENDER_PASSES.EDGES_HIGHLIGHTED){var _material5=scene.highlightMaterial._state;var _edgeColor=_material5.edgeColor;var _edgeAlpha=_material5.edgeAlpha;gl.uniform4f(this._uColor,_edgeColor[0],_edgeColor[1],_edgeColor[2],_edgeAlpha);}else if(renderPass===RENDER_PASSES.EDGES_SELECTED){var _material6=scene.selectedMaterial._state;var _edgeColor2=_material6.edgeColor;var _edgeAlpha2=_material6.edgeAlpha;gl.uniform4f(this._uColor,_edgeColor2[0],_edgeColor2[1],_edgeColor2[2],_edgeAlpha2);}else{gl.uniform4fv(this._uColor,defaultColor);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3d$8);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}if(state.numEdgeIndices8Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,8// 8 bits edge indices
18620
+ */var TrianglesDataTextureEdgesRenderer=/*#__PURE__*/function(){function TrianglesDataTextureEdgesRenderer(scene){_classCallCheck(this,TrianglesDataTextureEdgesRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureEdgesRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var model=dataTextureLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate(dataTextureLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$i;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$e);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$a);}else{rtcViewMatrix=viewMatrix;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);if(renderPass===RENDER_PASSES.EDGES_XRAYED){var material=scene.xrayMaterial._state;var edgeColor=material.edgeColor;var edgeAlpha=material.edgeAlpha;gl.uniform4f(this._uColor,edgeColor[0],edgeColor[1],edgeColor[2],edgeAlpha);}else if(renderPass===RENDER_PASSES.EDGES_HIGHLIGHTED){var _material5=scene.highlightMaterial._state;var _edgeColor=_material5.edgeColor;var _edgeAlpha=_material5.edgeAlpha;gl.uniform4f(this._uColor,_edgeColor[0],_edgeColor[1],_edgeColor[2],_edgeAlpha);}else if(renderPass===RENDER_PASSES.EDGES_SELECTED){var _material6=scene.selectedMaterial._state;var _edgeColor2=_material6.edgeColor;var _edgeAlpha2=_material6.edgeAlpha;gl.uniform4f(this._uColor,_edgeColor2[0],_edgeColor2[1],_edgeColor2[2],_edgeAlpha2);}else{gl.uniform4fv(this._uColor,defaultColor);}var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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$i);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numEdgeIndices8Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,8// 8 bits edge indices
18596
18621
  );gl.drawArrays(gl.LINES,0,state.numEdgeIndices8Bits);}if(state.numEdgeIndices16Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,16// 16 bits edge indices
18597
18622
  );gl.drawArrays(gl.LINES,0,state.numEdgeIndices16Bits);}if(state.numEdgeIndices32Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,32// 32 bits edge indices
18598
- );gl.drawArrays(gl.LINES,0,state.numEdgeIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uColor=program.getLocation("color");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i344=0,len=scene._sectionPlanesState.sectionPlanes.length;_i344<len;_i344++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i344),pos:program.getLocation("sectionPlanePos"+_i344),dir:program.getLocation("sectionPlaneDir"+_i344)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdEdgeIndices="uTexturePerPolygonIdEdgeIndices";this._uTexturePerEdgeIdPortionIds="uTexturePerEdgeIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";}},{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) {
18623
+ );gl.drawArrays(gl.LINES,0,state.numEdgeIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uColor=program.getLocation("color");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i344=0,len=scene.getMaxSectionPlanes();_i344<len;_i344++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i344),pos:program.getLocation("sectionPlanePos"+_i344),dir:program.getLocation("sectionPlaneDir"+_i344)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdEdgeIndices="uTexturePerPolygonIdEdgeIndices";this._uTexturePerEdgeIdPortionIds="uTexturePerEdgeIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";}},{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 clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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) {
18599
18624
  // src.push("in vec3 offset;");
18600
18625
  // }
18601
18626
  src.push("uniform mat4 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdEdgeIndices;");src.push("uniform mediump usampler2D uTexturePerEdgeIdPortionIds;");src.push("uniform vec4 color;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vColor;");src.push("void main(void) {");// constants
@@ -18608,13 +18633,13 @@ src.push(" return;");// Cull vertex
18608
18633
  src.push("} else {");// get vertex base
18609
18634
  src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");src.push("ivec4 packedEdgeIndexBaseOffset = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, 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 objectInstanceMatrix = mat4 (texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("mat4 objectDecodeAndInstanceMatrix = objectInstanceMatrix * mat4 (texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");// get flags & flags2
18610
18635
  src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// get position
18611
- src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");src.push("mat4 matrix = mat4 (texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("vColor = vec4(color.r, color.g, color.b, color.a);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Batched geometry edges drawing fragment shader");if(scene.logarithmicDepthBufferEnabled){src.push("#extension GL_EXT_frag_depth : enable");}src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i345=0,len=sectionPlanesState.sectionPlanes.length;_i345<len;_i345++){src.push("uniform bool sectionPlaneActive"+_i345+";");src.push("uniform vec3 sectionPlanePos"+_i345+";");src.push("uniform vec3 sectionPlaneDir"+_i345+";");}}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 _i346=0,_len87=sectionPlanesState.sectionPlanes.length;_i346<_len87;_i346++){src.push("if (sectionPlaneActive"+_i346+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i346+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i346+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vColor;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureEdgesRenderer;}();var tempVec3a$h=math.vec3();var tempVec3b$d=math.vec3();var tempVec3c$c=math.vec3();var tempMat4a$9=math.mat4();/**
18636
+ src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");src.push("mat4 matrix = mat4 (texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("vColor = vec4(color.r, color.g, color.b, color.a);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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 _i345=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i345<len;_i345++){src.push("uniform bool sectionPlaneActive"+_i345+";");src.push("uniform vec3 sectionPlanePos"+_i345+";");src.push("uniform vec3 sectionPlaneDir"+_i345+";");}}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 _i346=0,_len87=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i346<_len87;_i346++){src.push("if (sectionPlaneActive"+_i346+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i346+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i346+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vColor;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureEdgesRenderer;}();var tempVec3a$h=math.vec3();var tempVec3b$d=math.vec3();var tempVec3c$c=math.vec3();var tempMat4a$9=math.mat4();/**
18612
18637
  * @private
18613
- */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.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$h;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$d);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$9);}else{rtcViewMatrix=viewMatrix;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3c$c);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}if(state.numEdgeIndices8Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,8// 8 bits edge indices
18638
+ */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.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$h;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$d);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$9);}else{rtcViewMatrix=viewMatrix;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);var numSectionPlanes=scene.getMaxSectionPlanes();if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3c$c);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}if(state.numEdgeIndices8Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,8// 8 bits edge indices
18614
18639
  );gl.drawArrays(gl.LINES,0,state.numEdgeIndices8Bits);}if(state.numEdgeIndices16Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,16// 16 bits edge indices
18615
18640
  );gl.drawArrays(gl.LINES,0,state.numEdgeIndices16Bits);}if(state.numEdgeIndices32Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,32// 32 bits edge indices
18616
- );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._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i347=0,len=scene._sectionPlanesState.sectionPlanes.length;_i347<len;_i347++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i347),pos:program.getLocation("sectionPlanePos"+_i347),dir:program.getLocation("sectionPlaneDir"+_i347)});}//this._aOffset = program.getAttribute("offset");
18617
- if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdEdgeIndices="uTexturePerPolygonIdEdgeIndices";this._uTexturePerEdgeIdPortionIds="uTexturePerEdgeIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";}},{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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform highp sampler2D uObjectPerObjectOffsets;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdEdgeIndices;");src.push("uniform mediump usampler2D uTexturePerEdgeIdPortionIds;");// src.push("uniform vec4 color;");
18641
+ );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._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i347=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i347<len;_i347++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i347),pos:program.getLocation("sectionPlanePos"+_i347),dir:program.getLocation("sectionPlaneDir"+_i347)});}//this._aOffset = program.getAttribute("offset");
18642
+ if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdEdgeIndices="uTexturePerPolygonIdEdgeIndices";this._uTexturePerEdgeIdPortionIds="uTexturePerEdgeIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";}},{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 clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform highp sampler2D uObjectPerObjectOffsets;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdEdgeIndices;");src.push("uniform mediump usampler2D uTexturePerEdgeIdPortionIds;");// src.push("uniform vec4 color;");
18618
18643
  if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vColor;");src.push("void main(void) {");// constants
18619
18644
  src.push("int edgeIndex = gl_VertexID / 2;");// get packed object-id
18620
18645
  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
@@ -18628,14 +18653,13 @@ src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(object
18628
18653
  src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");// get color
18629
18654
  src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, 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
18630
18655
  src.push(" return;");src.push("};");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("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);");
18631
- 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 _i348=0,len=sectionPlanesState.sectionPlanes.length;_i348<len;_i348++){src.push("uniform bool sectionPlaneActive"+_i348+";");src.push("uniform vec3 sectionPlanePos"+_i348+";");src.push("uniform vec3 sectionPlaneDir"+_i348+";");}}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 _i349=0,_len88=sectionPlanesState.sectionPlanes.length;_i349<_len88;_i349++){src.push("if (sectionPlaneActive"+_i349+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i349+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i349+".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;");
18632
- src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vColor;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureEdgesColorRenderer;}();var tempVec3a$g=math.vec3();var tempVec3b$c=math.vec3();var tempVec3c$b=math.vec3();var tempMat4a$8=math.mat4();/**
18656
+ 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 clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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 _i348=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i348<len;_i348++){src.push("uniform bool sectionPlaneActive"+_i348+";");src.push("uniform vec3 sectionPlanePos"+_i348+";");src.push("uniform vec3 sectionPlaneDir"+_i348+";");}}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 _i349=0,_len88=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i349<_len88;_i349++){src.push("if (sectionPlaneActive"+_i349+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i349+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i349+".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$c=math.vec3();var tempVec3c$b=math.vec3();var tempMat4a$8=math.mat4();/**
18633
18657
  * @private
18634
18658
  */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.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);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$c);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$8);rtcCameraEye=tempVec3c$b;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.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);gl.uniform2f(this._uDrawingBufferSize,gl.drawingBufferWidth,gl.drawingBufferHeight);gl.uniformMatrix4fv(this._uSceneModelMatrix,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?
18635
- 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
18659
+ gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
18636
18660
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
18637
18661
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
18638
- );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._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i350=0,len=scene._sectionPlanesState.sectionPlanes.length;_i350<len;_i350++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i350),pos:program.getLocation("sectionPlanePos"+_i350),dir:program.getLocation("sectionPlaneDir"+_i350)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;this._program.bind();gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);}},{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("// Batched geometry picking 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform bool pickInvisible;");// src.push("uniform sampler2D uOcclusionTexture;");
18662
+ );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._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i350=0,len=scene.getMaxSectionPlanes();_i350<len;_i350++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i350),pos:program.getLocation("sectionPlanePos"+_i350),dir:program.getLocation("sectionPlaneDir"+_i350)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;this._program.bind();gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);}},{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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry picking 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform bool pickInvisible;");// src.push("uniform sampler2D uOcclusionTexture;");
18639
18663
  src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("uniform vec2 pickClipPos;");src.push("uniform vec2 drawingBufferSize;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");if(clipping){src.push("smooth out vec4 vWorldPosition;");src.push("flat out uvec4 vFlags2;");}src.push("out vec4 vPickColor;");src.push("void main(void) {");src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
18640
18664
  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
18641
18665
  src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// flags.w = NOT_RENDERED | PICK
@@ -18649,14 +18673,14 @@ src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(object
18649
18673
  src.push(" return;");src.push("};");// get pick-color
18650
18674
  src.push("vPickColor = vec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+1, objectIndexCoords.y), 0)) / 255.0;");// get normal
18651
18675
  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];");// when the geometry is not solid, if needed, flip the triangle winding
18652
- src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;");src.push("if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("} else {");src.push("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");src.push("if (viewNormal.z < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("}");src.push("}");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2;");}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 = remapClipPos(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("// Batched geometry picking fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uvec4 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 vPickColor;");src.push("out vec4 outPickColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");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(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
18653
- }src.push(" outPickColor = vPickColor; ");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 TrianglesDataTexturePickMeshRenderer;}();var tempVec3a$f=math.vec3();var tempVec3b$b=math.vec3();var tempVec3c$a=math.vec3();var tempVec3d$7=math.vec3();var tempMat4a$7=math.mat4();/**
18676
+ src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;");src.push("if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("} else {");src.push("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");src.push("if (viewNormal.z < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("}");src.push("}");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2;");}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 = remapClipPos(clipPos);");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Batched geometry picking fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uvec4 vFlags2;");for(var i=0;i<scene._sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("in vec4 vPickColor;");src.push("out vec4 outPickColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<scene._sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");//src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
18677
+ }src.push(" outPickColor = vPickColor; ");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 TrianglesDataTexturePickMeshRenderer;}();var tempVec3a$f=math.vec3();var tempVec3b$b=math.vec3();var tempVec3c$a=math.vec3();math.vec3();var tempMat4a$7=math.mat4();/**
18654
18678
  * @private
18655
18679
  */var TrianglesDataTexturePickDepthRenderer=/*#__PURE__*/function(){function TrianglesDataTexturePickDepthRenderer(scene){_classCallCheck(this,TrianglesDataTexturePickDepthRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTexturePickDepthRenderer,[{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=frameCtx.pickViewMatrix||camera.viewMatrix;if(!this._program){this._allocate();}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3a$f;if(origin){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$7);rtcCameraEye=tempVec3c$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.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);gl.uniform2f(this._uDrawingBufferSize,gl.drawingBufferWidth,gl.drawingBufferHeight);gl.uniform1f(this._uPickZNear,frameCtx.pickZNear);gl.uniform1f(this._uPickZFar,frameCtx.pickZFar);gl.uniformMatrix4fv(this._uSceneModelMatrix,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?
18656
- gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3d$7);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
18680
+ gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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$f);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
18657
18681
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
18658
18682
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
18659
- );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._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i351=0,len=scene._sectionPlanesState.sectionPlanes.length;_i351<len;_i351++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i351),pos:program.getLocation("sectionPlanePos"+_i351),dir:program.getLocation("sectionPlaneDir"+_i351)});}this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{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("// Triangles dataTexture pick depth 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform bool pickInvisible;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("uniform vec2 pickClipPos;");src.push("uniform vec2 drawingBufferSize;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vViewPosition;");src.push("void main(void) {");// constants
18683
+ );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._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i351=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i351<len;_i351++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i351),pos:program.getLocation("sectionPlanePos"+_i351),dir:program.getLocation("sectionPlaneDir"+_i351)});}this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles dataTexture pick depth 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform bool pickInvisible;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("uniform vec2 pickClipPos;");src.push("uniform vec2 drawingBufferSize;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vViewPosition;");src.push("void main(void) {");// constants
18660
18684
  src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
18661
18685
  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
18662
18686
  src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// flags.w = NOT_RENDERED | PICK
@@ -18669,23 +18693,23 @@ src.push("positions[0] = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(i
18669
18693
  src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, 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
18670
18694
  src.push(" return;");src.push("};");// get normal
18671
18695
  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];");// when the geometry is not solid, if needed, flip the triangle winding
18672
- src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;");src.push("if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("} else {");src.push("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");src.push("if (viewNormal.z < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("}");src.push("}");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");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 = remapClipPos(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
18673
- 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$a=math.vec3();var tempVec3c$9=math.vec3();var tempVec3d$6=math.vec3();var tempVec3e$1=math.vec3();var tempMat4a$6=math.mat4();/**
18696
+ src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;");src.push("if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("} else {");src.push("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");src.push("if (viewNormal.z < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("}");src.push("}");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");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 = remapClipPos(clipPos);");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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<scene._sectionPlanesState.getNumAllocatedSectionPlanes();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<scene._sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}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
18697
+ 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$a=math.vec3();var tempVec3c$9=math.vec3();var tempVec3d$2=math.vec3();math.vec3();var tempMat4a$6=math.mat4();/**
18674
18698
  * @private
18675
- */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.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);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$a;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$9);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);rtcCameraEye=tempVec3d$6;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._uSceneModelMatrix,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
18699
+ */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.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);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$a;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$9);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);rtcCameraEye=tempVec3d$2;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._uSceneModelMatrix,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 numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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$e);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}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
18676
18700
  );gl.drawArrays(glMode,0,state.numEdgeIndices8Bits);}if(state.numEdgeIndices16Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,16// 16 bits edge indices
18677
18701
  );gl.drawArrays(glMode,0,state.numEdgeIndices16Bits);}if(state.numEdgeIndices32Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,32// 32 bits edge indices
18678
- );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._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i352=0,len=scene._sectionPlanesState.sectionPlanes.length;_i352<len;_i352++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i352),pos:program.getLocation("sectionPlanePos"+_i352),dir:program.getLocation("sectionPlaneDir"+_i352)});}{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdEdgeIndices="uTexturePerPolygonIdEdgeIndices";this._uTexturePerEdgeIdPortionIds="uTexturePerEdgeIdPortionIds";this._uTextureModelMatrices="uTextureModelMatrices";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdEdgeIndices;");src.push("uniform mediump usampler2D uTexturePerEdgeIdPortionIds;");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
18702
+ );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._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i352=0,len=scene.getMaxSectionPlanes();_i352<len;_i352++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i352),pos:program.getLocation("sectionPlanePos"+_i352),dir:program.getLocation("sectionPlaneDir"+_i352)});}{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdEdgeIndices="uTexturePerPolygonIdEdgeIndices";this._uTexturePerEdgeIdPortionIds="uTexturePerEdgeIdPortionIds";this._uTextureModelMatrices="uTextureModelMatrices";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";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 clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdEdgeIndices;");src.push("uniform mediump usampler2D uTexturePerEdgeIdPortionIds;");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
18679
18703
  src.push("int edgeIndex = gl_VertexID / 2;");// get packed object-id
18680
18704
  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
18681
18705
  src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");src.push("{");// get vertex base
18682
18706
  src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");src.push("ivec4 packedEdgeIndexBaseOffset = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, 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 objectInstanceMatrix = mat4 (texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("mat4 objectDecodeAndInstanceMatrix = objectInstanceMatrix * mat4 (texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");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?
18683
- 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 _i353=0,len=sectionPlanesState.sectionPlanes.length;_i353<len;_i353++){src.push("uniform bool sectionPlaneActive"+_i353+";");src.push("uniform vec3 sectionPlanePos"+_i353+";");src.push("uniform vec3 sectionPlaneDir"+_i353+";");}}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$9=math.vec3();var tempVec3c$8=math.vec3();var tempVec3d$5=math.vec3();var tempVec3e=math.vec3();var tempMat4a$5=math.mat4();/**
18707
+ src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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 _i353=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i353<len;_i353++){src.push("uniform bool sectionPlaneActive"+_i353+";");src.push("uniform vec3 sectionPlanePos"+_i353+";");src.push("uniform vec3 sectionPlaneDir"+_i353+";");}}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<scene._sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" 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$9=math.vec3();var tempVec3c$8=math.vec3();var tempVec3d$1=math.vec3();math.vec3();var tempMat4a$5=math.mat4();/**
18684
18708
  * @private
18685
- */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.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);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$9;if(gotOrigin){var rotatedOrigin=tempVec3c$8;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$5);rtcCameraEye=tempVec3d$5;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
18709
+ */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.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);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$9;if(gotOrigin){var rotatedOrigin=tempVec3c$8;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$5);rtcCameraEye=tempVec3d$1;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 numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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$d);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
18686
18710
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
18687
18711
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
18688
- );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("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i354=0,len=scene._sectionPlanesState.sectionPlanes.length;_i354<len;_i354++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i354),pos:program.getLocation("sectionPlanePos"+_i354),dir:program.getLocation("sectionPlaneDir"+_i354)});}{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");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("}");src.push("flat out vec4 vPickColor;");src.push("out vec4 vWorldPosition;");if(clipping){src.push("flat out uint vFlags2;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// constants
18712
+ );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("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i354=0,len=scene.getMaxSectionPlanes();_i354<len;_i354++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i354),pos:program.getLocation("sectionPlanePos"+_i354),dir:program.getLocation("sectionPlaneDir"+_i354)});}{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";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 clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");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("}");src.push("flat out vec4 vPickColor;");src.push("out vec4 vWorldPosition;");if(clipping){src.push("flat out uint vFlags2;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// constants
18689
18713
  src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
18690
18714
  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
18691
18715
  src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");src.push("{");// get color
@@ -18694,12 +18718,12 @@ src.push(" return;");src.push("};");// get vertex base
18694
18718
  src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");src.push("ivec4 packedIndexBaseOffset = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+5, objectIndexCoords.y), 0));");src.push("int indexBaseOffset = (packedIndexBaseOffset.r << 24) + (packedIndexBaseOffset.g << 16) + (packedIndexBaseOffset.b << 8) + packedIndexBaseOffset.a;");src.push("int h_index = (polygonIndex - indexBaseOffset) & 4095;");src.push("int v_index = (polygonIndex - indexBaseOffset) >> 12;");src.push("ivec3 vertexIndices = ivec3(texelFetch(uTexturePerPolygonIdIndices, ivec2(h_index, v_index), 0));");src.push("ivec3 uniqueVertexIndexes = vertexIndices + (packedVertexBase.r << 24) + (packedVertexBase.g << 16) + (packedVertexBase.b << 8) + packedVertexBase.a;");src.push("ivec3 indexPositionH = uniqueVertexIndexes & 4095;");src.push("ivec3 indexPositionV = uniqueVertexIndexes >> 12;");src.push("mat4 objectInstanceMatrix = mat4 (texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("mat4 objectDecodeAndInstanceMatrix = objectInstanceMatrix * mat4 (texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("uint solid = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+7, objectIndexCoords.y), 0).r;");// get position
18695
18719
  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
18696
18720
  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*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");// when the geometry is not solid, if needed, flip the triangle winding
18697
- src.push("if (solid != 1u) {");src.push(" if (isPerspectiveMatrix(projMatrix)) {");src.push(" vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * 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 = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("relativeToOriginPosition = worldPosition.xyz;");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vWorldPosition = worldPosition;");if(clipping){src.push("vFlags2 = flags2.r;");}src.push("vPickColor = vec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+1, objectIndexCoords.y), 0));");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(" }");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;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("flat in uint vFlags2;");for(var _i355=0,len=sectionPlanesState.sectionPlanes.length;_i355<len;_i355++){src.push("uniform bool sectionPlaneActive"+_i355+";");src.push("uniform vec3 sectionPlanePos"+_i355+";");src.push("uniform vec3 sectionPlaneDir"+_i355+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");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(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz * uCoordinateScaler.xyz, - uLayerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");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();var tempVec3b$8=math.vec3();var tempVec3c$7=math.vec3();var tempVec3d$4=math.vec3();var tempMat4a$4=math.mat4();/**
18721
+ src.push("if (solid != 1u) {");src.push(" if (isPerspectiveMatrix(projMatrix)) {");src.push(" vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * 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 = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("relativeToOriginPosition = worldPosition.xyz;");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vWorldPosition = worldPosition;");if(clipping){src.push("vFlags2 = flags2.r;");}src.push("vPickColor = vec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+1, objectIndexCoords.y), 0));");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(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>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;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("flat in uint vFlags2;");for(var _i355=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i355<len;_i355++){src.push("uniform bool sectionPlaneActive"+_i355+";");src.push("uniform vec3 sectionPlanePos"+_i355+";");src.push("uniform vec3 sectionPlaneDir"+_i355+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");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<scene._sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz * uCoordinateScaler.xyz, - uLayerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");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();var tempVec3b$8=math.vec3();var tempVec3c$7=math.vec3();math.vec3();var tempMat4a$4=math.mat4();/**
18698
18722
  * @private
18699
- */var TrianglesDataTextureOcclusionRenderer=/*#__PURE__*/function(){function TrianglesDataTextureOcclusionRenderer(scene){_classCallCheck(this,TrianglesDataTextureOcclusionRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureOcclusionRenderer,[{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=frameCtx.pickViewMatrix||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.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3a$c;if(origin){var rotatedOrigin=tempVec3b$8;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$4);rtcCameraEye=tempVec3c$7;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uWorldMatrix,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,tempVec3d$4);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
18723
+ */var TrianglesDataTextureOcclusionRenderer=/*#__PURE__*/function(){function TrianglesDataTextureOcclusionRenderer(scene){_classCallCheck(this,TrianglesDataTextureOcclusionRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureOcclusionRenderer,[{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=frameCtx.pickViewMatrix||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.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3a$c;if(origin){var rotatedOrigin=tempVec3b$8;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$4);rtcCameraEye=tempVec3c$7;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
18700
18724
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
18701
18725
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
18702
- );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._uWorldMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i356=0,len=scene._sectionPlanesState.sectionPlanes.length;_i356<len;_i356++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i356),pos:program.getLocation("sectionPlanePos"+_i356),dir:program.getLocation("sectionPlaneDir"+_i356)});}this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(){var scene=this._scene;scene.canvas.gl;scene.camera.project;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("// TrianglesDataTextureOcclusionRenderer 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("void main(void) {");// constants
18726
+ );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._uWorldMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i356=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i356<len;_i356++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i356),pos:program.getLocation("sectionPlanePos"+_i356),dir:program.getLocation("sectionPlaneDir"+_i356)});}this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(){var scene=this._scene;scene.canvas.gl;scene.camera.project;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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// TrianglesDataTextureOcclusionRenderer 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("void main(void) {");// constants
18703
18727
  src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
18704
18728
  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
18705
18729
  src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
@@ -18711,13 +18735,13 @@ src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFl
18711
18735
  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 color
18712
18736
  src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, 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
18713
18737
  src.push(" return;");src.push("};");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];");// when the geometry is not solid, if needed, flip the triangle winding
18714
- src.push("if (solid != 1u) {");src.push(" if (isPerspectiveMatrix(projMatrix)) {");src.push(" vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;");src.push(" if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");src.push(" position = positions[2 - (gl_VertexID % 3)];");src.push(" }");src.push(" } else {");src.push(" vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");src.push(" if (viewNormal.z < 0.0) {");src.push(" position = positions[2 - (gl_VertexID % 3)];");src.push(" }");src.push(" }");src.push("}");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// TrianglesDataTextureColorRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i357=0;_i357<sectionPlanesState.sectionPlanes.length;_i357++){src.push("uniform bool sectionPlaneActive"+_i357+";");src.push("uniform vec3 sectionPlanePos"+_i357+";");src.push("uniform vec3 sectionPlaneDir"+_i357+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i358=0;_i358<sectionPlanesState.sectionPlanes.length;_i358++){src.push(" if (sectionPlaneActive"+_i358+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i358+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i358+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
18715
- 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 TrianglesDataTextureOcclusionRenderer;}();var tempVec3a$b=math.vec3();var tempVec3b$7=math.vec3();var tempVec3c$6=math.vec3();var tempVec3d$3=math.vec3();var tempMat4a$3=math.mat4();/**
18738
+ src.push("if (solid != 1u) {");src.push(" if (isPerspectiveMatrix(projMatrix)) {");src.push(" vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;");src.push(" if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {");src.push(" position = positions[2 - (gl_VertexID % 3)];");src.push(" }");src.push(" } else {");src.push(" vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");src.push(" if (viewNormal.z < 0.0) {");src.push(" position = positions[2 - (gl_VertexID % 3)];");src.push(" }");src.push(" }");src.push("}");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// TrianglesDataTextureColorRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i357=0;_i357<sectionPlanesState.getNumAllocatedSectionPlanes();_i357++){src.push("uniform bool sectionPlaneActive"+_i357+";");src.push("uniform vec3 sectionPlanePos"+_i357+";");src.push("uniform vec3 sectionPlaneDir"+_i357+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i358=0;_i358<sectionPlanesState.getNumAllocatedSectionPlanes();_i358++){src.push(" if (sectionPlaneActive"+_i358+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i358+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i358+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}src.push(" outColor = vec4(0.0, 0.0, 1.0, 1.0); ");// Occluders are blue
18739
+ 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 TrianglesDataTextureOcclusionRenderer;}();var tempVec3a$b=math.vec3();var tempVec3b$7=math.vec3();var tempVec3c$6=math.vec3();math.vec3();var tempMat4a$3=math.mat4();/**
18716
18740
  * @private
18717
- */var TrianglesDataTextureDepthRenderer=/*#__PURE__*/function(){function TrianglesDataTextureDepthRenderer(scene){_classCallCheck(this,TrianglesDataTextureDepthRenderer);this._scene=scene;this._allocate();this._hash=this._getHash();}_createClass(TrianglesDataTextureDepthRenderer,[{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 scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);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$b;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$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(camera.viewMatrix,rtcOrigin,tempMat4a$3);rtcCameraEye=tempVec3c$6;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._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3d$3);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
18741
+ */var TrianglesDataTextureDepthRenderer=/*#__PURE__*/function(){function TrianglesDataTextureDepthRenderer(scene){_classCallCheck(this,TrianglesDataTextureDepthRenderer);this._scene=scene;this._allocate();this._hash=this._getHash();}_createClass(TrianglesDataTextureDepthRenderer,[{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 scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);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$b;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$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(camera.viewMatrix,rtcOrigin,tempMat4a$3);rtcCameraEye=tempVec3c$6;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._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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$b);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
18718
18742
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
18719
18743
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
18720
- );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._uPositionsDecodeMatrix=program.getLocation("objectDecodeAndInstanceMatrix");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i359=0,len=scene._sectionPlanesState.sectionPlanes.length;_i359<len;_i359++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i359),pos:program.getLocation("sectionPlanePos"+_i359),dir:program.getLocation("sectionPlaneDir"+_i359)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var project=scene.camera.project;program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{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;scene._lightsState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Triangles dataTexture draw 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out highp vec2 vHighPrecisionZW;");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("void main(void) {");// constants
18744
+ );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._uPositionsDecodeMatrix=program.getLocation("objectDecodeAndInstanceMatrix");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i359=0,len=scene.getMaxSectionPlanes();_i359<len;_i359++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i359),pos:program.getLocation("sectionPlanePos"+_i359),dir:program.getLocation("sectionPlaneDir"+_i359)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var project=scene.camera.project;program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles dataTexture draw 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out highp vec2 vHighPrecisionZW;");if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("void main(void) {");// constants
18721
18745
  src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
18722
18746
  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
18723
18747
  src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
@@ -18730,21 +18754,21 @@ src.push("positions[0] = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(i
18730
18754
  src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, 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
18731
18755
  src.push(" return;");src.push("};");// get normal
18732
18756
  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*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");// when the geometry is not solid, if needed, flip the triangle winding
18733
- src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * 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 = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push("vHighPrecisionZW = gl_Position.zw;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Triangles dataTexture draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");src.push("in highp vec2 vHighPrecisionZW;");src.push("out vec4 outColor;");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("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) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");//src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
18734
- }src.push("float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");src.push(" outColor = vec4(vec3(1.0 - fragCoordZ), 1.0); ");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 TrianglesDataTextureDepthRenderer;}();var tempVec3a$a=math.vec3();var tempVec3b$6=math.vec3();var tempVec3c$5=math.vec3();var tempVec3d$2=math.vec3();var tempMat4a$2=math.mat4();/**
18757
+ src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * 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 = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push("vHighPrecisionZW = gl_Position.zw;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Triangles dataTexture draw fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");src.push("in highp vec2 vHighPrecisionZW;");src.push("out vec4 outColor;");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=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i360<len;_i360++){src.push("uniform bool sectionPlaneActive"+_i360+";");src.push("uniform vec3 sectionPlanePos"+_i360+";");src.push("uniform vec3 sectionPlaneDir"+_i360+";");}}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=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_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) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");//src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
18758
+ }src.push("float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;");src.push(" outColor = vec4(vec3(1.0 - fragCoordZ), 1.0); ");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 TrianglesDataTextureDepthRenderer;}();var tempVec3a$a=math.vec3();var tempVec3b$6=math.vec3();var tempVec3c$5=math.vec3();math.vec3();var tempMat4a$2=math.mat4();/**
18735
18759
  * @private
18736
- */var TrianglesDataTextureNormalsRenderer=/*#__PURE__*/function(){function TrianglesDataTextureNormalsRenderer(scene){_classCallCheck(this,TrianglesDataTextureNormalsRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureNormalsRenderer,[{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 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(dataTextureLayer);}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$a;if(gotOrigin){var rotatedOrigin=tempVec3b$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=tempVec3c$5;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);gl.uniformMatrix4fv(this._uWorldNormalMatrix,false,model.worldNormalMatrix);var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3d$2);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,dataTextureLayer._state.objectDecodeAndInstanceMatrix);this._aPosition.bindArrayBuffer(state.positionsBuf);this._aOffset.bindArrayBuffer(state.offsetsBuf);this._aNormal.bindArrayBuffer(state.normalsBuf);this._aColor.bindArrayBuffer(state.colorsBuf);// Needed for masking out transparent entities using alpha channel
18737
- this._aFlags.bindArrayBuffer(state.flagsBuf);if(this._aFlags2){this._aFlags2.bindArrayBuffer(state.flags2Buf);}state.indicesBuf.bind();gl.drawElements(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,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._uPositionsDecodeMatrix=program.getLocation("objectDecodeAndInstanceMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uWorldNormalMatrix=program.getLocation("worldNormalMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uViewNormalMatrix=program.getLocation("viewNormalMatrix");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._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aNormal=program.getAttribute("normal");this._aColor=program.getAttribute("color");this._aFlags=program.getAttribute("flags");if(this._aFlags2){// Won't be in shader when not clipping
18738
- this._aFlags2=program.getAttribute("flags2");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}}},{key:"_bindProgram",value:function _bindProgram(){var scene=this._scene;var gl=scene.canvas.gl;var project=scene.camera.project;this._program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{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("// Batched geometry normals vertex shader");if(scene.logarithmicDepthBufferEnabled&&WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push("#extension GL_EXT_frag_depth : enable");}src.push("uniform int renderPass;");src.push("attribute vec3 position;");if(scene.entityOffsetsEnabled){src.push("attribute vec3 offset;");}src.push("attribute vec3 normal;");src.push("attribute vec4 color;");src.push("attribute vec4 flags;");src.push("attribute vec4 flags2;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 worldNormalMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 viewNormalMatrix;");src.push("uniform mat4 objectDecodeAndInstanceMatrix;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");if(WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push("out float vFragDepth;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("varying float isPerspective;");}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 vec4 vFlags2;");}src.push("out vec3 vViewNormal;");src.push("void main(void) {");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
18760
+ */var TrianglesDataTextureNormalsRenderer=/*#__PURE__*/function(){function TrianglesDataTextureNormalsRenderer(scene){_classCallCheck(this,TrianglesDataTextureNormalsRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureNormalsRenderer,[{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 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(dataTextureLayer);}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$a;if(gotOrigin){var rotatedOrigin=tempVec3b$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=tempVec3c$5;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);gl.uniformMatrix4fv(this._uViewNormalMatrix,false,camera.viewNormalMatrix);gl.uniformMatrix4fv(this._uWorldNormalMatrix,false,model.worldNormalMatrix);var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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$a);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,dataTextureLayer._state.objectDecodeAndInstanceMatrix);this._aPosition.bindArrayBuffer(state.positionsBuf);this._aOffset.bindArrayBuffer(state.offsetsBuf);this._aNormal.bindArrayBuffer(state.normalsBuf);this._aColor.bindArrayBuffer(state.colorsBuf);// Needed for masking out transparent entities using alpha channel
18761
+ this._aFlags.bindArrayBuffer(state.flagsBuf);if(this._aFlags2){this._aFlags2.bindArrayBuffer(state.flags2Buf);}state.indicesBuf.bind();gl.drawElements(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,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._uPositionsDecodeMatrix=program.getLocation("objectDecodeAndInstanceMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uWorldNormalMatrix=program.getLocation("worldNormalMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uViewNormalMatrix=program.getLocation("viewNormalMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i362=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i362<len;_i362++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i362),pos:program.getLocation("sectionPlanePos"+_i362),dir:program.getLocation("sectionPlaneDir"+_i362)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aNormal=program.getAttribute("normal");this._aColor=program.getAttribute("color");this._aFlags=program.getAttribute("flags");if(this._aFlags2){// Won't be in shader when not clipping
18762
+ this._aFlags2=program.getAttribute("flags2");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}}},{key:"_bindProgram",value:function _bindProgram(){var scene=this._scene;var gl=scene.canvas.gl;var project=scene.camera.project;this._program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{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.getNumAllocatedSectionPlanes()>0;var src=[];src.push("// Batched geometry normals vertex shader");if(scene.logarithmicDepthBufferEnabled&&WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push("#extension GL_EXT_frag_depth : enable");}src.push("uniform int renderPass;");src.push("attribute vec3 position;");if(scene.entityOffsetsEnabled){src.push("attribute vec3 offset;");}src.push("attribute vec3 normal;");src.push("attribute vec4 color;");src.push("attribute vec4 flags;");src.push("attribute vec4 flags2;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 worldNormalMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 viewNormalMatrix;");src.push("uniform mat4 objectDecodeAndInstanceMatrix;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");if(WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push("out float vFragDepth;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("varying float isPerspective;");}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 vec4 vFlags2;");}src.push("out vec3 vViewNormal;");src.push("void main(void) {");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
18739
18763
  // renderPass = COLOR_OPAQUE
18740
- src.push("if (int(flags.x) != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push(" vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2;");}src.push(" vViewNormal = viewNormal;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){if(WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push("vFragDepth = 1.0 + clipPos.w;");}else{src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");src.push("clipPos.z *= 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("// Batched geometry normals fragment shader");if(scene.logarithmicDepthBufferEnabled&&WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){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&&WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in vec4 vFlags2;");for(var _i363=0;_i363<sectionPlanesState.sectionPlanes.length;_i363++){src.push("uniform bool sectionPlaneActive"+_i363+";");src.push("uniform vec3 sectionPlanePos"+_i363+";");src.push("uniform vec3 sectionPlaneDir"+_i363+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");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&&WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" gl_FragColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");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 TrianglesDataTextureNormalsRenderer;}();var tempVec3a$9=math.vec3();var tempVec3b$5=math.vec3();var tempVec3c$4=math.vec3();var tempVec3d$1=math.vec3();math.vec4();var tempMat4a$1=math.mat4();/**
18764
+ src.push("if (int(flags.x) != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vec4 worldNormal = worldNormalMatrix * vec4(octDecode(normal.xy), 0.0); ");src.push(" vec3 viewNormal = normalize((viewNormalMatrix * worldNormal).xyz);");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2;");}src.push(" vViewNormal = viewNormal;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){if(WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push("vFragDepth = 1.0 + clipPos.w;");}else{src.push("clipPos.z = log2( max( 1e-6, clipPos.w + 1.0 ) ) * logDepthBufFC - 1.0;");src.push("clipPos.z *= 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 clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry normals fragment shader");if(scene.logarithmicDepthBufferEnabled&&WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){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&&WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in vec4 vFlags2;");for(var _i363=0;_i363<scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i363++){src.push("uniform bool sectionPlaneActive"+_i363+";");src.push("uniform vec3 sectionPlanePos"+_i363+";");src.push("uniform vec3 sectionPlaneDir"+_i363+";");}}src.push("in vec3 vViewNormal;");src.push("vec3 packNormalToRGB( const in vec3 normal ) {");src.push(" return normalize( normal ) * 0.5 + 0.5;");src.push("}");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<scene._sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled&&WEBGL_INFO.SUPPORTED_EXTENSIONS["EXT_frag_depth"]){src.push(" gl_FragDepthEXT = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" gl_FragColor = vec4(packNormalToRGB(vViewNormal), 1.0); ");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 TrianglesDataTextureNormalsRenderer;}();var tempVec3a$9=math.vec3();var tempVec3b$5=math.vec3();var tempVec3c$4=math.vec3();math.vec3();math.vec4();var tempMat4a$1=math.mat4();/**
18741
18765
  * @private
18742
18766
  */var TrianglesDataTexturePickNormalsFlatRenderer=/*#__PURE__*/function(){function TrianglesDataTexturePickNormalsFlatRenderer(scene,withSAO){_classCallCheck(this,TrianglesDataTexturePickNormalsFlatRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTexturePickNormalsFlatRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);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$9;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$5);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$1);rtcCameraEye=tempVec3c$4;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;// TODO: make pickMatrix
18743
18767
  rtcCameraEye=camera.eye;}gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);gl.uniform2f(this._uDrawingBufferSize,gl.drawingBufferWidth,gl.drawingBufferHeight);gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);// TODO: pickProjMatrix
18744
- gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3d$1);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
18768
+ gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){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$9);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
18745
18769
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
18746
18770
  );gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
18747
- );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._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i364=0,len=scene._sectionPlanesState.sectionPlanes.length;_i364<len;_i364++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i364),pos:program.getLocation("sectionPlanePos"+_i364),dir:program.getLocation("sectionPlaneDir"+_i364)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var 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;scene._lightsState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// trianglesDatatextureNormalsRenderer 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("uniform vec2 pickClipPos;");src.push("uniform vec2 drawingBufferSize;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out vec4 vWorldPosition;");if(clipping){src.push("flat out uint vFlags2;");}src.push("void main(void) {");// constants
18771
+ );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._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i364=0,len=scene.getMaxSectionPlanes();_i364<len;_i364++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i364),pos:program.getLocation("sectionPlanePos"+_i364),dir:program.getLocation("sectionPlaneDir"+_i364)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var 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 clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// trianglesDatatextureNormalsRenderer 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 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("uniform vec2 pickClipPos;");src.push("uniform vec2 drawingBufferSize;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out vec4 vWorldPosition;");if(clipping){src.push("flat out uint vFlags2;");}src.push("void main(void) {");// constants
18748
18772
  src.push("int polygonIndex = gl_VertexID / 3;");// get packed object-id
18749
18773
  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
18750
18774
  src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// pickFlag = NOT_RENDERED | PICK
@@ -18758,7 +18782,7 @@ src.push("uvec4 color = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(object
18758
18782
  src.push(" return;");src.push("};");// get normal
18759
18783
  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*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");// when the geometry is not solid, if needed, flip the triangle winding
18760
18784
  src.push("if (solid != 1u) {");src.push("if (isPerspectiveMatrix(projMatrix)) {");src.push("vec3 uCameraEyeRtcInQuantizedSpace = (inverse(sceneModelMatrix * objectDecodeAndInstanceMatrix) * vec4(uCameraEyeRtc, 1)).xyz;");// src.push("vColor = vec4(vec3(1, -1, 0)*dot(normalize(position.xyz - uCameraEyeRtcInQuantizedSpace), normal), 1);")
18761
- 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("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");src.push("if (viewNormal.z < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("}");src.push("}");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("vWorldPosition = worldPosition;");if(clipping){src.push("vFlags2 = flags2.r;");}src.push("gl_Position = remapClipPos(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("// TrianglesDataTexturePickNormalsRenderer 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("in vec4 vWorldPosition;");if(clipping){src.push("flat in uint vFlags2;");for(var _i365=0,len=sectionPlanesState.sectionPlanes.length;_i365<len;_i365++){src.push("uniform bool sectionPlaneActive"+_i365+";");src.push("uniform vec3 sectionPlanePos"+_i365+";");src.push("uniform vec3 sectionPlaneDir"+_i365+";");}}src.push("out highp ivec4 outNormal;");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 _i366=0,_len90=sectionPlanesState.sectionPlanes.length;_i366<_len90;_i366++){src.push("if (sectionPlaneActive"+_i366+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i366+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i366+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push(" vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push(" outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));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 TrianglesDataTexturePickNormalsFlatRenderer;}();/**
18785
+ 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("vec3 viewNormal = -normalize((transpose(inverse(viewMatrix*objectDecodeAndInstanceMatrix)) * vec4(normal,1)).xyz);");src.push("if (viewNormal.z < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("}");src.push("}");src.push("}");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("vWorldPosition = worldPosition;");if(clipping){src.push("vFlags2 = flags2.r;");}src.push("gl_Position = remapClipPos(clipPos);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// TrianglesDataTexturePickNormalsRenderer 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("in vec4 vWorldPosition;");if(clipping){src.push("flat in uint vFlags2;");for(var _i365=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i365<len;_i365++){src.push("uniform bool sectionPlaneActive"+_i365+";");src.push("uniform vec3 sectionPlanePos"+_i365+";");src.push("uniform vec3 sectionPlaneDir"+_i365+";");}}src.push("out highp ivec4 outNormal;");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 _i366=0,_len90=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i366<_len90;_i366++){src.push("if (sectionPlaneActive"+_i366+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i366+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i366+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push(" vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push(" outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));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 TrianglesDataTexturePickNormalsFlatRenderer;}();/**
18762
18786
  * @private
18763
18787
  */var TrianglesDataTextureRenderers=/*#__PURE__*/function(){function TrianglesDataTextureRenderers(scene){_classCallCheck(this,TrianglesDataTextureRenderers);this._scene=scene;}_createClass(TrianglesDataTextureRenderers,[{key:"_compile",value:function _compile(){if(this._colorRenderer&&!this._colorRenderer.getValid()){this._colorRenderer.destroy();this._colorRenderer=null;}if(this._colorRendererWithSAO&&!this._colorRendererWithSAO.getValid()){this._colorRendererWithSAO.destroy();this._colorRendererWithSAO=null;}if(this._flatColorRenderer&&!this._flatColorRenderer.getValid()){this._flatColorRenderer.destroy();this._flatColorRenderer=null;}if(this._flatColorRendererWithSAO&&!this._flatColorRendererWithSAO.getValid()){this._flatColorRendererWithSAO.destroy();this._flatColorRendererWithSAO=null;}if(this._colorQualityRendererWithSAO&&!this._colorQualityRendererWithSAO.getValid()){this._colorQualityRendererWithSAO.destroy();this._colorQualityRendererWithSAO=null;}if(this._depthRenderer&&!this._depthRenderer.getValid()){this._depthRenderer.destroy();this._depthRenderer=null;}if(this._normalsRenderer&&!this._normalsRenderer.getValid()){this._normalsRenderer.destroy();this._normalsRenderer=null;}if(this._silhouetteRenderer&&!this._silhouetteRenderer.getValid()){this._silhouetteRenderer.destroy();this._silhouetteRenderer=null;}if(this._edgesRenderer&&!this._edgesRenderer.getValid()){this._edgesRenderer.destroy();this._edgesRenderer=null;}if(this._edgesColorRenderer&&!this._edgesColorRenderer.getValid()){this._edgesColorRenderer.destroy();this._edgesColorRenderer=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._vertexDepthRenderer&&!this._vertexDepthRenderer.getValid()){this._vertexDepthRenderer.destroy();this._vertexDepthRenderer=null;}if(this._snapDepthBufInitRenderer&&!this._snapDepthBufInitRenderer.getValid()){this._snapDepthBufInitRenderer.destroy();this._snapDepthBufInitRenderer=null;}if(this._pickNormalsRenderer&&this._pickNormalsRenderer.getValid()===false){this._pickNormalsRenderer.destroy();this._pickNormalsRenderer=null;}if(this._pickNormalsFlatRenderer&&this._pickNormalsFlatRenderer.getValid()===false){this._pickNormalsFlatRenderer.destroy();this._pickNormalsFlatRenderer=null;}if(this._occlusionRenderer&&this._occlusionRenderer.getValid()===false){this._occlusionRenderer.destroy();this._occlusionRenderer=null;}}},{key:"eagerCreateRenders",value:function eagerCreateRenders(){// Pre-initialize certain renderers that would otherwise be lazy-initialised
18764
18788
  // on user interaction, such as picking or emphasis, so that there is no delay
@@ -23215,6 +23239,11 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
23215
23239
  * store geometry on the GPU for triangle meshes that don't have textures. This gives a much lower memory footprint for these types of model element. This mode may not perform well on low-end GPUs that are optimized
23216
23240
  * to use textures to hold geometry data. Works great on most medium/high-end GPUs found in desktop computers, including the nVIDIA and Intel HD chipsets. Set this false to use the default vertex buffer object (VBO)
23217
23241
  * mode for storing geometry, which is the standard technique used in most graphics engines, and will work adequately on most low-end GPUs.
23242
+ * @param {number} [cfg.numCachedSectionPlanes=0] Enhances the efficiency of SectionPlane creation by proactively allocating Viewer resources for a specified quantity
23243
+ * of SectionPlanes. Introducing this parameter streamlines the initial creation speed of SectionPlanes, particularly up to the designated quantity. This parameter internally
23244
+ * configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
23245
+ * responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
23246
+ * your expected usage.
23218
23247
  */function Viewer(cfg){_classCallCheck(this,Viewer);/**
23219
23248
  * The Viewer's current language setting.
23220
23249
  * @property language
@@ -23235,7 +23264,7 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
23235
23264
  * The Viewer's {@link Scene}.
23236
23265
  * @property scene
23237
23266
  * @type {Scene}
23238
- */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,colorTextureEnabled:cfg.colorTextureEnabled!==false,dtxEnabled:!!cfg.dtxEnabled});/**
23267
+ */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,colorTextureEnabled:cfg.colorTextureEnabled!==false,dtxEnabled:!!cfg.dtxEnabled,numCachedSectionPlanes:cfg.numCachedSectionPlanes});/**
23239
23268
  * Metadata about the {@link Scene} and the models and objects within it.
23240
23269
  * @property metaScene
23241
23270
  * @type {MetaScene}