@xeokit/xeokit-sdk 2.4.0-alpha-61 → 2.4.0-alpha-64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -59836,6 +59836,7 @@ class SnapBatchingDepthRenderer {
|
|
|
59836
59836
|
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
59837
59837
|
}
|
|
59838
59838
|
src.push("gl_Position = clipPos;");
|
|
59839
|
+
src.push("gl_PointSize = 1.0;"); // Windows needs this?
|
|
59839
59840
|
src.push(" }");
|
|
59840
59841
|
src.push("}");
|
|
59841
59842
|
return src;
|
|
@@ -64576,7 +64577,7 @@ class SnapInstancingDepthBufInitRenderer {
|
|
|
64576
64577
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
64577
64578
|
const src = [];
|
|
64578
64579
|
src.push ('#version 300 es');
|
|
64579
|
-
src.push("//
|
|
64580
|
+
src.push("// SnapInstancingDepthBufInitRenderer vertex shader");
|
|
64580
64581
|
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
64581
64582
|
src.push("precision highp float;");
|
|
64582
64583
|
src.push("precision highp int;");
|
|
@@ -64946,7 +64947,7 @@ class SnapInstancingDepthRenderer {
|
|
|
64946
64947
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
64947
64948
|
const src = [];
|
|
64948
64949
|
src.push ('#version 300 es');
|
|
64949
|
-
src.push("//
|
|
64950
|
+
src.push("// SnapInstancingDepthRenderer vertex shader");
|
|
64950
64951
|
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
64951
64952
|
src.push("precision highp float;");
|
|
64952
64953
|
src.push("precision highp int;");
|
|
@@ -65023,6 +65024,7 @@ class SnapInstancingDepthRenderer {
|
|
|
65023
65024
|
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
65024
65025
|
}
|
|
65025
65026
|
src.push("gl_Position = clipPos;");
|
|
65027
|
+
src.push("gl_PointSize = 1.0;"); // Windows needs this?
|
|
65026
65028
|
src.push("}");
|
|
65027
65029
|
src.push("}");
|
|
65028
65030
|
return src;
|
|
@@ -65034,7 +65036,7 @@ class SnapInstancingDepthRenderer {
|
|
|
65034
65036
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
65035
65037
|
const src = [];
|
|
65036
65038
|
src.push ('#version 300 es');
|
|
65037
|
-
src.push("//
|
|
65039
|
+
src.push("// SnapInstancingDepthRenderer fragment shader");
|
|
65038
65040
|
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
65039
65041
|
src.push("precision highp float;");
|
|
65040
65042
|
src.push("precision highp int;");
|
|
@@ -65074,7 +65076,7 @@ class SnapInstancingDepthRenderer {
|
|
|
65074
65076
|
src.push("}");
|
|
65075
65077
|
}
|
|
65076
65078
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
65077
|
-
src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
65079
|
+
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
65078
65080
|
}
|
|
65079
65081
|
src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, layerNumber);");
|
|
65080
65082
|
src.push("}");
|
|
@@ -76485,6 +76487,7 @@ class TrianglesDataTextureSnapDepthRenderer {
|
|
|
76485
76487
|
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
76486
76488
|
}
|
|
76487
76489
|
src.push("gl_Position = clipPos;");
|
|
76490
|
+
src.push("gl_PointSize = 1.0;"); // Windows needs this?
|
|
76488
76491
|
src.push(" }");
|
|
76489
76492
|
src.push("}");
|
|
76490
76493
|
return src;
|
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -59832,6 +59832,7 @@ class SnapBatchingDepthRenderer {
|
|
|
59832
59832
|
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
59833
59833
|
}
|
|
59834
59834
|
src.push("gl_Position = clipPos;");
|
|
59835
|
+
src.push("gl_PointSize = 1.0;"); // Windows needs this?
|
|
59835
59836
|
src.push(" }");
|
|
59836
59837
|
src.push("}");
|
|
59837
59838
|
return src;
|
|
@@ -64572,7 +64573,7 @@ class SnapInstancingDepthBufInitRenderer {
|
|
|
64572
64573
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
64573
64574
|
const src = [];
|
|
64574
64575
|
src.push ('#version 300 es');
|
|
64575
|
-
src.push("//
|
|
64576
|
+
src.push("// SnapInstancingDepthBufInitRenderer vertex shader");
|
|
64576
64577
|
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
64577
64578
|
src.push("precision highp float;");
|
|
64578
64579
|
src.push("precision highp int;");
|
|
@@ -64942,7 +64943,7 @@ class SnapInstancingDepthRenderer {
|
|
|
64942
64943
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
64943
64944
|
const src = [];
|
|
64944
64945
|
src.push ('#version 300 es');
|
|
64945
|
-
src.push("//
|
|
64946
|
+
src.push("// SnapInstancingDepthRenderer vertex shader");
|
|
64946
64947
|
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
64947
64948
|
src.push("precision highp float;");
|
|
64948
64949
|
src.push("precision highp int;");
|
|
@@ -65019,6 +65020,7 @@ class SnapInstancingDepthRenderer {
|
|
|
65019
65020
|
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
65020
65021
|
}
|
|
65021
65022
|
src.push("gl_Position = clipPos;");
|
|
65023
|
+
src.push("gl_PointSize = 1.0;"); // Windows needs this?
|
|
65022
65024
|
src.push("}");
|
|
65023
65025
|
src.push("}");
|
|
65024
65026
|
return src;
|
|
@@ -65030,7 +65032,7 @@ class SnapInstancingDepthRenderer {
|
|
|
65030
65032
|
const clipping = sectionPlanesState.sectionPlanes.length > 0;
|
|
65031
65033
|
const src = [];
|
|
65032
65034
|
src.push ('#version 300 es');
|
|
65033
|
-
src.push("//
|
|
65035
|
+
src.push("// SnapInstancingDepthRenderer fragment shader");
|
|
65034
65036
|
src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");
|
|
65035
65037
|
src.push("precision highp float;");
|
|
65036
65038
|
src.push("precision highp int;");
|
|
@@ -65070,7 +65072,7 @@ class SnapInstancingDepthRenderer {
|
|
|
65070
65072
|
src.push("}");
|
|
65071
65073
|
}
|
|
65072
65074
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
65073
|
-
src.push("gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
65075
|
+
src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
65074
65076
|
}
|
|
65075
65077
|
src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, layerNumber);");
|
|
65076
65078
|
src.push("}");
|
|
@@ -76481,6 +76483,7 @@ class TrianglesDataTextureSnapDepthRenderer {
|
|
|
76481
76483
|
src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");
|
|
76482
76484
|
}
|
|
76483
76485
|
src.push("gl_Position = clipPos;");
|
|
76486
|
+
src.push("gl_PointSize = 1.0;"); // Windows needs this?
|
|
76484
76487
|
src.push(" }");
|
|
76485
76488
|
src.push("}");
|
|
76486
76489
|
return src;
|
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -16176,7 +16176,8 @@ gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,batchingLayer._state.posi
|
|
|
16176
16176
|
}else{gl.drawArrays(gl.POINTS,0,state.positionsBuf.numItems);}}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i213=0,len=scene._sectionPlanesState.sectionPlanes.length;_i213<len;_i213++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i213),pos:program.getLocation("sectionPlanePos"+_i213),dir:program.getLocation("sectionPlaneDir"+_i213)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.sectionPlanes.length>0;scene.pointsMaterial._state;var src=[];src.push('#version 300 es');src.push("// SnapBatchingDepthRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("uniform bool pickInvisible;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
|
|
16177
16177
|
// renderPass = PICK
|
|
16178
16178
|
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
|
|
16179
|
-
src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("
|
|
16179
|
+
src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("gl_PointSize = 1.0;");// Windows needs this?
|
|
16180
|
+
src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// SnapBatchingDepthRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i214=0;_i214<sectionPlanesState.sectionPlanes.length;_i214++){src.push("uniform bool sectionPlaneActive"+_i214+";");src.push("uniform vec3 sectionPlanePos"+_i214+";");src.push("uniform vec3 sectionPlaneDir"+_i214+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, layerNumber);");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return SnapBatchingDepthRenderer;}();/**
|
|
16180
16181
|
* @private
|
|
16181
16182
|
*/var SnapBatchingRenderers=/*#__PURE__*/function(){function SnapBatchingRenderers(scene){_classCallCheck(this,SnapBatchingRenderers);this._scene=scene;}_createClass(SnapBatchingRenderers,[{key:"_compile",value:function _compile(){if(this._snapDepthBufInitRenderer&&!this._snapDepthBufInitRenderer.getValid()){this._snapDepthBufInitRenderer.destroy();this._snapDepthBufInitRenderer=null;}if(this._snapDepthRenderer&&!this._snapDepthRenderer.getValid()){this._snapDepthRenderer.destroy();this._snapDepthRenderer=null;}}},{key:"snapDepthBufInitRenderer",get:function get(){if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapBatchingDepthBufInitRenderer(this._scene,false);}return this._snapDepthBufInitRenderer;}},{key:"snapDepthRenderer",get:function get(){if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapBatchingDepthRenderer(this._scene);}return this._snapDepthRenderer;}},{key:"_destroy",value:function _destroy(){if(this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer.destroy();}if(this._snapDepthRenderer){this._snapDepthRenderer.destroy();}}}]);return SnapBatchingRenderers;}();var cachedRenderers$6={};/**
|
|
16182
16183
|
* @private
|
|
@@ -16399,7 +16400,7 @@ src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewp
|
|
|
16399
16400
|
* @private
|
|
16400
16401
|
*/var SnapInstancingDepthBufInitRenderer=/*#__PURE__*/function(){function SnapInstancingDepthBufInitRenderer(scene){_classCallCheck(this,SnapInstancingDepthBufInitRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapInstancingDepthBufInitRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){var model=instancingLayer.model;var scene=model.scene;var gl=scene.canvas.gl;var state=instancingLayer._state;var origin=instancingLayer._state.origin;frameCtx.snapPickOrigin[0]=origin[0];frameCtx.snapPickOrigin[1]=origin[1];frameCtx.snapPickOrigin[2]=origin[2];var aabb=instancingLayer.aabb;var coordinateDivider=[math.safeInv(aabb[3]-aabb[0])*math.MAX_INT,math.safeInv(aabb[4]-aabb[1])*math.MAX_INT,math.safeInv(aabb[5]-aabb[2])*math.MAX_INT];frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateDivider[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateDivider[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateDivider[2]);if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var camera=scene.camera;var cameraEye=camera.eye;if(frameCtx.pickViewMatrix){cameraEye=frameCtx.pickOrigin||cameraEye;}var originCameraEye=[cameraEye[0]-origin[0],cameraEye[1]-origin[1],cameraEye[2]-origin[2]];gl.uniform3fv(this._uCameraEyeRtc,originCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateDivider);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);var pickViewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var rtcPickViewMatrix=origin?createRTCViewMat(pickViewMatrix,origin):pickViewMatrix;gl.uniformMatrix4fv(this._uViewMatrix,false,rtcPickViewMatrix);gl.uniformMatrix4fv(this._uWorldMatrix,false,model.worldMatrix);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
|
|
16401
16402
|
gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=instancingLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos$1(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$o);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,state.positionsDecodeMatrix);this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);gl.vertexAttribDivisor(this._aOffset.location,1);}state.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);state.indicesBuf.unbind();// Cleanup
|
|
16402
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);if(this._aFlags){gl.vertexAttribDivisor(this._aFlags.location,0);}if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i265=0,len=scene._sectionPlanesState.sectionPlanes.length;_i265<len;_i265++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i265),pos:program.getLocation("sectionPlanePos"+_i265),dir:program.getLocation("sectionPlaneDir"+_i265)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("//
|
|
16403
|
+
gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);if(this._aFlags){gl.vertexAttribDivisor(this._aFlags.location,0);}if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i265=0,len=scene._sectionPlanesState.sectionPlanes.length;_i265<len;_i265++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i265),pos:program.getLocation("sectionPlanePos"+_i265),dir:program.getLocation("sectionPlaneDir"+_i265)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// SnapInstancingDepthBufInitRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
|
|
16403
16404
|
src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
|
|
16404
16405
|
// renderPass = PICK
|
|
16405
16406
|
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
|
|
@@ -16409,11 +16410,12 @@ src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.pus
|
|
|
16409
16410
|
*/var SnapInstancingDepthRenderer=/*#__PURE__*/function(){function SnapInstancingDepthRenderer(scene){_classCallCheck(this,SnapInstancingDepthRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(SnapInstancingDepthRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){var model=instancingLayer.model;var scene=model.scene;var gl=scene.canvas.gl;var state=instancingLayer._state;var origin=instancingLayer._state.origin;frameCtx.snapPickOrigin[0]=origin[0];frameCtx.snapPickOrigin[1]=origin[1];frameCtx.snapPickOrigin[2]=origin[2];var aabb=instancingLayer.aabb;var coordinateDivider=[math.safeInv(aabb[3]-aabb[0])*math.MAX_INT,math.safeInv(aabb[4]-aabb[1])*math.MAX_INT,math.safeInv(aabb[5]-aabb[2])*math.MAX_INT];frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateDivider[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateDivider[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateDivider[2]);if(!this._program){this._allocate(instancingLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var camera=scene.camera;var cameraEye=camera.eye;if(frameCtx.pickViewMatrix){cameraEye=frameCtx.pickOrigin||cameraEye;}var originCameraEye=[cameraEye[0]-origin[0],cameraEye[1]-origin[1],cameraEye[2]-origin[2]];gl.uniform3fv(this._uCameraEyeRtc,originCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateDivider);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);var pickViewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var rtcPickViewMatrix=origin?createRTCViewMat(pickViewMatrix,origin):pickViewMatrix;gl.uniformMatrix4fv(this._uViewMatrix,false,rtcPickViewMatrix);gl.uniformMatrix4fv(this._uWorldMatrix,false,model.worldMatrix);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
|
|
16410
16411
|
gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=instancingLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos$1(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$n);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,state.positionsDecodeMatrix);this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);this._aPosition.bindArrayBuffer(state.positionsBuf);this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);gl.vertexAttribDivisor(this._aOffset.location,1);}if(frameCtx.snapMode==="edge"){state.edgeIndicesBuf.bind();gl.drawElementsInstanced(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0,state.numInstances);state.edgeIndicesBuf.unbind();// needed?
|
|
16411
16412
|
}else{gl.drawArraysInstanced(gl.POINTS,0,state.positionsBuf.numItems,state.numInstances);}// Cleanup
|
|
16412
|
-
gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);gl.vertexAttribDivisor(this._aFlags.location,0);if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i268=0,len=scene._sectionPlanesState.sectionPlanes.length;_i268<len;_i268++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i268),pos:program.getLocation("sectionPlanePos"+_i268),dir:program.getLocation("sectionPlaneDir"+_i268)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("//
|
|
16413
|
+
gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);gl.vertexAttribDivisor(this._aFlags.location,0);if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uPickInvisible=program.getLocation("pickInvisible");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i268=0,len=scene._sectionPlanesState.sectionPlanes.length;_i268<len;_i268++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i268),pos:program.getLocation("sectionPlanePos"+_i268),dir:program.getLocation("sectionPlaneDir"+_i268)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aFlags=program.getAttribute("flags");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// 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
|
|
16413
16414
|
src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");if(clipping){src.push("out vec4 vWorldPosition;");src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
|
|
16414
16415
|
// renderPass = PICK
|
|
16415
16416
|
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
|
|
16416
|
-
src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("
|
|
16417
|
+
src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags = flags;");}src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("gl_PointSize = 1.0;");// Windows needs this?
|
|
16418
|
+
src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// SnapInstancingDepthRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");if(clipping){src.push("in vec4 vWorldPosition;");src.push("in float vFlags;");for(var _i269=0;_i269<sectionPlanesState.sectionPlanes.length;_i269++){src.push("uniform bool sectionPlaneActive"+_i269+";");src.push("uniform vec3 sectionPlanePos"+_i269+";");src.push("uniform vec3 sectionPlaneDir"+_i269+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i270=0;_i270<sectionPlanesState.sectionPlanes.length;_i270++){src.push("if (sectionPlaneActive"+_i270+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i270+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i270+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, layerNumber);");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return SnapInstancingDepthRenderer;}();/**
|
|
16417
16419
|
* @private
|
|
16418
16420
|
*/var SnapInstancingRenderers=/*#__PURE__*/function(){function SnapInstancingRenderers(scene){_classCallCheck(this,SnapInstancingRenderers);this._scene=scene;}_createClass(SnapInstancingRenderers,[{key:"_compile",value:function _compile(){if(this._snapDepthBufInitRenderer&&!this._snapDepthBufInitRenderer.getValid()){this._snapDepthBufInitRenderer.destroy();this._snapDepthBufInitRenderer=null;}if(this._snapDepthRenderer&&!this._snapDepthRenderer.getValid()){this._snapDepthRenderer.destroy();this._snapDepthRenderer=null;}}},{key:"snapDepthBufInitRenderer",get:function get(){if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapInstancingDepthBufInitRenderer(this._scene,false);}return this._snapDepthBufInitRenderer;}},{key:"snapDepthRenderer",get:function get(){if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapInstancingDepthRenderer(this._scene);}return this._snapDepthRenderer;}},{key:"_destroy",value:function _destroy(){if(this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer.destroy();}if(this._snapDepthRenderer){this._snapDepthRenderer.destroy();}}}]);return SnapInstancingRenderers;}();var cachedRenderers$4={};/**
|
|
16419
16421
|
* @private
|
|
@@ -17388,7 +17390,8 @@ src.push("uvec4 flags = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(obj
|
|
|
17388
17390
|
src.push("ivec4 packedVertexBase = ivec4(texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");src.push("ivec4 packedEdgeIndexBaseOffset = ivec4(texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+6, objectIndexCoords.y), 0));");src.push("int edgeIndexBaseOffset = (packedEdgeIndexBaseOffset.r << 24) + (packedEdgeIndexBaseOffset.g << 16) + (packedEdgeIndexBaseOffset.b << 8) + packedEdgeIndexBaseOffset.a;");src.push("int h_index = (edgeIndex - edgeIndexBaseOffset) & 4095;");src.push("int v_index = (edgeIndex - edgeIndexBaseOffset) >> 12;");src.push("ivec3 vertexIndices = ivec3(texelFetch(uTexturePerPolygonIdEdgeIndices, ivec2(h_index, v_index), 0));");src.push("ivec3 uniqueVertexIndexes = vertexIndices + (packedVertexBase.r << 24) + (packedVertexBase.g << 16) + (packedVertexBase.b << 8) + packedVertexBase.a;");src.push("int indexPositionH = uniqueVertexIndexes[gl_VertexID % 2] & 4095;");src.push("int indexPositionV = uniqueVertexIndexes[gl_VertexID % 2] >> 12;");src.push("mat4 positionsDecodeMatrix = mat4 (texelFetch (uTexturePerObjectIdPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectIdPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectIdPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectIdPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");// get flags & flags2
|
|
17389
17391
|
src.push("uvec4 flags = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uTexturePerObjectIdColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// get position
|
|
17390
17392
|
src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");// get XYZ offset
|
|
17391
|
-
src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vViewPosition = viewPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");src.push("vViewPosition = clipPos;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("
|
|
17393
|
+
src.push("vec4 offset = vec4(texelFetch (uTexturePerObjectIdOffsets, objectIndexCoords, 0).rgb, 0.0);");src.push("worldPosition.xyz = worldPosition.xyz + offset.xyz;");src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vViewPosition = viewPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");src.push("vViewPosition = clipPos;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("gl_PointSize = 1.0;");// Windows needs this?
|
|
17394
|
+
src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push('#version 300 es');src.push("// Triangles dataTexture pick depth fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int uLayerNumber;");src.push("uniform vec3 uCoordinateLayer;");if(clipping){src.push("in vec4 vWorldPosition;");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("in highp vec3 relativeToOriginPosition;");src.push("out highp ivec4 outCoords;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*uCoordinateLayer.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();/**
|
|
17392
17395
|
* @private
|
|
17393
17396
|
*/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){var model=dataTextureLayer.model;var scene=model.scene;var camera=scene.camera;/**
|
|
17394
17397
|
* @type {WebGL2RenderingContext}
|