@xeokit/xeokit-sdk 2.3.0 → 2.3.1
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
|
@@ -63846,7 +63846,7 @@ class TrianglesInstancingOcclusionRenderer {
|
|
|
63846
63846
|
src.push("uniform mat4 positionsDecodeMatrix;");
|
|
63847
63847
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
63848
63848
|
src.push("uniform float logDepthBufFC;");
|
|
63849
|
-
src.push("
|
|
63849
|
+
src.push("out float vFragDepth;");
|
|
63850
63850
|
src.push("bool isPerspectiveMatrix(mat4 m) {");
|
|
63851
63851
|
src.push(" return (m[2][3] == - 1.0);");
|
|
63852
63852
|
src.push("}");
|
|
@@ -63901,9 +63901,9 @@ class TrianglesInstancingOcclusionRenderer {
|
|
|
63901
63901
|
src.push("precision mediump int;");
|
|
63902
63902
|
src.push("#endif");
|
|
63903
63903
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
63904
|
-
src.push("
|
|
63904
|
+
src.push("in float isPerspective;");
|
|
63905
63905
|
src.push("uniform float logDepthBufFC;");
|
|
63906
|
-
src.push("
|
|
63906
|
+
src.push("in float vFragDepth;");
|
|
63907
63907
|
}
|
|
63908
63908
|
if (clipping) {
|
|
63909
63909
|
src.push("in vec4 vWorldPosition;");
|
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -63842,7 +63842,7 @@ class TrianglesInstancingOcclusionRenderer {
|
|
|
63842
63842
|
src.push("uniform mat4 positionsDecodeMatrix;");
|
|
63843
63843
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
63844
63844
|
src.push("uniform float logDepthBufFC;");
|
|
63845
|
-
src.push("
|
|
63845
|
+
src.push("out float vFragDepth;");
|
|
63846
63846
|
src.push("bool isPerspectiveMatrix(mat4 m) {");
|
|
63847
63847
|
src.push(" return (m[2][3] == - 1.0);");
|
|
63848
63848
|
src.push("}");
|
|
@@ -63897,9 +63897,9 @@ class TrianglesInstancingOcclusionRenderer {
|
|
|
63897
63897
|
src.push("precision mediump int;");
|
|
63898
63898
|
src.push("#endif");
|
|
63899
63899
|
if (scene.logarithmicDepthBufferEnabled) {
|
|
63900
|
-
src.push("
|
|
63900
|
+
src.push("in float isPerspective;");
|
|
63901
63901
|
src.push("uniform float logDepthBufFC;");
|
|
63902
|
-
src.push("
|
|
63902
|
+
src.push("in float vFragDepth;");
|
|
63903
63903
|
}
|
|
63904
63904
|
if (clipping) {
|
|
63905
63905
|
src.push("in vec4 vWorldPosition;");
|
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -16623,9 +16623,9 @@ src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * ve
|
|
|
16623
16623
|
*/var TrianglesInstancingOcclusionRenderer=/*#__PURE__*/function(){function TrianglesInstancingOcclusionRenderer(scene){_classCallCheck(this,TrianglesInstancingOcclusionRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesInstancingOcclusionRenderer,[{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 camera=scene.camera;var gl=scene.canvas.gl;var state=instancingLayer._state;var geometry=state.geometry;var origin=instancingLayer._state.origin;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uViewMatrix,false,origin?createRTCViewMat(camera.viewMatrix,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uWorldMatrix,false,model.worldMatrix);var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=instancingLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$x);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometry.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);if(this._aColor){this._aColor.bindArrayBuffer(state.colorsBuf);gl.vertexAttribDivisor(this._aColor.location,1);}this._aPosition.bindArrayBuffer(geometry.positionsBuf);if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);gl.vertexAttribDivisor(this._aOffset.location,1);}this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);if(this._aFlags2){this._aFlags2.bindArrayBuffer(state.flags2Buf);gl.vertexAttribDivisor(this._aFlags2.location,1);}geometry.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,geometry.indicesBuf.numItems,geometry.indicesBuf.itemType,0,state.numInstances);// Cleanup
|
|
16624
16624
|
gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);if(this._aColor){gl.vertexAttribDivisor(this._aColor.location,0);}gl.vertexAttribDivisor(this._aFlags.location,0);if(this._aFlags2){// Won't be in shader when not clipping
|
|
16625
16625
|
gl.vertexAttribDivisor(this._aFlags2.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;var sectionPlanesState=scene._sectionPlanesState;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("positionsDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];var clips=sectionPlanesState.sectionPlanes;for(var _i250=0,len=clips.length;_i250<len;_i250++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i250),pos:program.getLocation("sectionPlanePos"+_i250),dir:program.getLocation("sectionPlaneDir"+_i250)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aColor=program.getAttribute("color");this._aFlags=program.getAttribute("flags");this._aFlags2=program.getAttribute("flags2");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");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 sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// 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 vec4 flags;");src.push("in vec4 flags2;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
|
|
16626
|
-
src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("
|
|
16626
|
+
src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");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("in float isPerspective;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out vec4 vFlags2;");}src.push("void main(void) {");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
|
|
16627
16627
|
// renderPass = COLOR_OPAQUE
|
|
16628
|
-
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 = 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("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 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("
|
|
16628
|
+
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 = 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("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 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("in vec4 vWorldPosition;");src.push("in vec4 vFlags2;");for(var _i251=0;_i251<sectionPlanesState.sectionPlanes.length;_i251++){src.push("uniform bool sectionPlaneActive"+_i251+";");src.push("uniform vec3 sectionPlanePos"+_i251+";");src.push("uniform vec3 sectionPlaneDir"+_i251+";");}}src.push("out vec4 outColor;");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 _i252=0;_i252<sectionPlanesState.sectionPlanes.length;_i252++){src.push("if (sectionPlaneActive"+_i252+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i252+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i252+".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
|
|
16629
16629
|
if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}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 TrianglesInstancingOcclusionRenderer;}();var tempVec3a$w=math.vec3();/**
|
|
16630
16630
|
* @private
|
|
16631
16631
|
*/var TrianglesInstancingDepthRenderer=/*#__PURE__*/function(){function TrianglesInstancingDepthRenderer(scene){_classCallCheck(this,TrianglesInstancingDepthRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesInstancingDepthRenderer,[{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 camera=scene.camera;var gl=scene.canvas.gl;var state=instancingLayer._state;var geometry=state.geometry;var origin=instancingLayer._state.origin;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uWorldMatrix,false,model.worldMatrix);gl.uniformMatrix4fv(this._uViewMatrix,false,origin?createRTCViewMat(camera.viewMatrix,origin):camera.viewMatrix);var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=instancingLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$w);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}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);gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometry.positionsDecodeMatrix);this._aPosition.bindArrayBuffer(geometry.positionsBuf);if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);gl.vertexAttribDivisor(this._aOffset.location,1);}this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);if(this._aFlags2){this._aFlags2.bindArrayBuffer(state.flags2Buf);gl.vertexAttribDivisor(this._aFlags2.location,1);}geometry.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,geometry.indicesBuf.numItems,geometry.indicesBuf.itemType,0,state.numInstances);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._aFlags2){// Won't be in shader when not clipping
|