@xeokit/xeokit-sdk 2.6.62 → 2.6.63
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 +19 -11
- package/dist/xeokit-sdk.es.js +19 -11
- package/dist/xeokit-sdk.es5.js +7 -7
- package/dist/xeokit-sdk.min.cjs.js +1 -1
- package/dist/xeokit-sdk.min.es.js +1 -1
- package/dist/xeokit-sdk.min.es5.js +1 -1
- package/package.json +1 -1
- package/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +10 -0
- package/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +10 -0
- package/src/viewer/scene/model/vbo/VBORenderer.js +2 -2
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesBatchingRenderer.js +3 -1
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/TrianglesSnapRenderer.js +5 -3
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesInstancingRenderer.js +3 -1
- package/src/viewer/scene/model/vbo/instancing/triangles/renderers/TrianglesSnapRenderer.js +6 -4
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -52178,7 +52178,7 @@ class VBORenderer {
|
|
|
52178
52178
|
}
|
|
52179
52179
|
|
|
52180
52180
|
if (this._instancing) {
|
|
52181
|
-
if (this._edges) {
|
|
52181
|
+
if (this._edges && state.edgeIndicesBuf) {
|
|
52182
52182
|
state.edgeIndicesBuf.bind();
|
|
52183
52183
|
} else {
|
|
52184
52184
|
if (state.indicesBuf) {
|
|
@@ -52186,7 +52186,7 @@ class VBORenderer {
|
|
|
52186
52186
|
}
|
|
52187
52187
|
}
|
|
52188
52188
|
} else {
|
|
52189
|
-
if (this._edges) {
|
|
52189
|
+
if (this._edges && state.edgeIndicesBuf) {
|
|
52190
52190
|
state.edgeIndicesBuf.bind();
|
|
52191
52191
|
} else {
|
|
52192
52192
|
if (state.indicesBuf) {
|
|
@@ -52453,7 +52453,9 @@ class TrianglesBatchingRenderer extends VBORenderer {
|
|
|
52453
52453
|
} = drawCfg;
|
|
52454
52454
|
|
|
52455
52455
|
if (this._edges) {
|
|
52456
|
-
|
|
52456
|
+
if (state.edgeIndicesBuf) {
|
|
52457
|
+
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
|
|
52458
|
+
}
|
|
52457
52459
|
} else {
|
|
52458
52460
|
const count = frameCtx.pickElementsCount || state.indicesBuf.numItems;
|
|
52459
52461
|
const offset = frameCtx.pickElementsOffset ? frameCtx.pickElementsOffset * state.indicesBuf.itemByteSize : 0;
|
|
@@ -55618,9 +55620,11 @@ class TrianglesSnapRenderer$1 extends VBORenderer{
|
|
|
55618
55620
|
//=============================================================
|
|
55619
55621
|
|
|
55620
55622
|
if (frameCtx.snapMode === "edge") {
|
|
55621
|
-
state.edgeIndicesBuf
|
|
55622
|
-
|
|
55623
|
-
|
|
55623
|
+
if (state.edgeIndicesBuf) {
|
|
55624
|
+
state.edgeIndicesBuf.bind();
|
|
55625
|
+
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
|
|
55626
|
+
state.edgeIndicesBuf.unbind(); // needed?
|
|
55627
|
+
}
|
|
55624
55628
|
} else {
|
|
55625
55629
|
gl.drawArrays(gl.POINTS, 0, state.positionsBuf.numItems);
|
|
55626
55630
|
}
|
|
@@ -57789,7 +57793,9 @@ class TrianglesInstancingRenderer extends VBORenderer {
|
|
|
57789
57793
|
} = drawCfg;
|
|
57790
57794
|
|
|
57791
57795
|
if (this._edges) {
|
|
57792
|
-
|
|
57796
|
+
if (state.edgeIndicesBuf) {
|
|
57797
|
+
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
|
|
57798
|
+
}
|
|
57793
57799
|
} else {
|
|
57794
57800
|
gl.drawElementsInstanced(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
|
|
57795
57801
|
|
|
@@ -61081,10 +61087,12 @@ class TrianglesSnapRenderer extends VBORenderer {
|
|
|
61081
61087
|
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
61082
61088
|
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
61083
61089
|
|
|
61084
|
-
if (frameCtx.snapMode === "edge") {
|
|
61085
|
-
state.edgeIndicesBuf
|
|
61086
|
-
|
|
61087
|
-
|
|
61090
|
+
if (frameCtx.snapMode === "edge" ) {
|
|
61091
|
+
if (state.edgeIndicesBuf) {
|
|
61092
|
+
state.edgeIndicesBuf.bind();
|
|
61093
|
+
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
|
|
61094
|
+
state.edgeIndicesBuf.unbind(); // needed?
|
|
61095
|
+
}
|
|
61088
61096
|
} else {
|
|
61089
61097
|
gl.drawArraysInstanced(gl.POINTS, 0, state.positionsBuf.numItems, state.numInstances);
|
|
61090
61098
|
}
|
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -52174,7 +52174,7 @@ class VBORenderer {
|
|
|
52174
52174
|
}
|
|
52175
52175
|
|
|
52176
52176
|
if (this._instancing) {
|
|
52177
|
-
if (this._edges) {
|
|
52177
|
+
if (this._edges && state.edgeIndicesBuf) {
|
|
52178
52178
|
state.edgeIndicesBuf.bind();
|
|
52179
52179
|
} else {
|
|
52180
52180
|
if (state.indicesBuf) {
|
|
@@ -52182,7 +52182,7 @@ class VBORenderer {
|
|
|
52182
52182
|
}
|
|
52183
52183
|
}
|
|
52184
52184
|
} else {
|
|
52185
|
-
if (this._edges) {
|
|
52185
|
+
if (this._edges && state.edgeIndicesBuf) {
|
|
52186
52186
|
state.edgeIndicesBuf.bind();
|
|
52187
52187
|
} else {
|
|
52188
52188
|
if (state.indicesBuf) {
|
|
@@ -52449,7 +52449,9 @@ class TrianglesBatchingRenderer extends VBORenderer {
|
|
|
52449
52449
|
} = drawCfg;
|
|
52450
52450
|
|
|
52451
52451
|
if (this._edges) {
|
|
52452
|
-
|
|
52452
|
+
if (state.edgeIndicesBuf) {
|
|
52453
|
+
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
|
|
52454
|
+
}
|
|
52453
52455
|
} else {
|
|
52454
52456
|
const count = frameCtx.pickElementsCount || state.indicesBuf.numItems;
|
|
52455
52457
|
const offset = frameCtx.pickElementsOffset ? frameCtx.pickElementsOffset * state.indicesBuf.itemByteSize : 0;
|
|
@@ -55614,9 +55616,11 @@ class TrianglesSnapRenderer$1 extends VBORenderer{
|
|
|
55614
55616
|
//=============================================================
|
|
55615
55617
|
|
|
55616
55618
|
if (frameCtx.snapMode === "edge") {
|
|
55617
|
-
state.edgeIndicesBuf
|
|
55618
|
-
|
|
55619
|
-
|
|
55619
|
+
if (state.edgeIndicesBuf) {
|
|
55620
|
+
state.edgeIndicesBuf.bind();
|
|
55621
|
+
gl.drawElements(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0);
|
|
55622
|
+
state.edgeIndicesBuf.unbind(); // needed?
|
|
55623
|
+
}
|
|
55620
55624
|
} else {
|
|
55621
55625
|
gl.drawArrays(gl.POINTS, 0, state.positionsBuf.numItems);
|
|
55622
55626
|
}
|
|
@@ -57785,7 +57789,9 @@ class TrianglesInstancingRenderer extends VBORenderer {
|
|
|
57785
57789
|
} = drawCfg;
|
|
57786
57790
|
|
|
57787
57791
|
if (this._edges) {
|
|
57788
|
-
|
|
57792
|
+
if (state.edgeIndicesBuf) {
|
|
57793
|
+
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
|
|
57794
|
+
}
|
|
57789
57795
|
} else {
|
|
57790
57796
|
gl.drawElementsInstanced(gl.TRIANGLES, state.indicesBuf.numItems, state.indicesBuf.itemType, 0, state.numInstances);
|
|
57791
57797
|
|
|
@@ -61077,10 +61083,12 @@ class TrianglesSnapRenderer extends VBORenderer {
|
|
|
61077
61083
|
this._aFlags.bindArrayBuffer(state.flagsBuf);
|
|
61078
61084
|
gl.vertexAttribDivisor(this._aFlags.location, 1);
|
|
61079
61085
|
|
|
61080
|
-
if (frameCtx.snapMode === "edge") {
|
|
61081
|
-
state.edgeIndicesBuf
|
|
61082
|
-
|
|
61083
|
-
|
|
61086
|
+
if (frameCtx.snapMode === "edge" ) {
|
|
61087
|
+
if (state.edgeIndicesBuf) {
|
|
61088
|
+
state.edgeIndicesBuf.bind();
|
|
61089
|
+
gl.drawElementsInstanced(gl.LINES, state.edgeIndicesBuf.numItems, state.edgeIndicesBuf.itemType, 0, state.numInstances);
|
|
61090
|
+
state.edgeIndicesBuf.unbind(); // needed?
|
|
61091
|
+
}
|
|
61084
61092
|
} else {
|
|
61085
61093
|
gl.drawArraysInstanced(gl.POINTS, 0, state.positionsBuf.numItems, state.numInstances);
|
|
61086
61094
|
}
|
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -14861,10 +14861,10 @@ PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=ne
|
|
|
14861
14861
|
* @returns { string }
|
|
14862
14862
|
*/_createClass(VBORenderer,[{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;if(scene.crossSections){gl.uniform4fv(this._uSliceColor,scene.crossSections.sliceColor);gl.uniform1f(this._uSliceThickness,scene.crossSections.sliceThickness);}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 origin=layer._state.origin;if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$C,model.matrix);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
|
|
14863
14863
|
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 ?
|
|
14864
|
-
var lights=lightsState.lights;var light;for(var _i167=0,len=lights.length;_i167<len;_i167++){light=lights[_i167];switch(light.type){case"dir":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=null;this._uLightDir[_i167]=program.getLocation("lightDir"+_i167);break;case"point":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=program.getLocation("lightPos"+_i167);this._uLightDir[_i167]=null;this._uLightAttenuation[_i167]=program.getLocation("lightAttenuation"+_i167);break;case"spot":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=program.getLocation("lightPos"+_i167);this._uLightDir[_i167]=program.getLocation("lightDir"+_i167);this._uLightAttenuation[_i167]=program.getLocation("lightAttenuation"+_i167);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i168=0,_len20=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i168<_len20;_i168++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i168),pos:program.getLocation("sectionPlanePos"+_i168),dir:program.getLocation("sectionPlaneDir"+_i168)});}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(this._useAlphaCutoff){this._alphaCutoffLocation=program.getLocation("materialAlphaCutoff");}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");if(scene.crossSections){this._uSliceColor=program.getLocation("sliceColor");this._uSliceThickness=program.getLocation("sliceThickness");}}},{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 _i169=0,len=lights.length;_i169<len;_i169++){var light=lights[_i169];if(this._uLightColor[_i169]){gl.uniform4f(this._uLightColor[_i169],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i169]){gl.uniform3fv(this._uLightPos[_i169],light.pos);if(this._uLightAttenuation[_i169]){gl.uniform1f(this._uLightAttenuation[_i169],light.attenuation);}}if(this._uLightDir[_i169]){gl.uniform3fv(this._uLightDir[_i169],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 _ref7=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},_ref7$colorUniform=_ref7.colorUniform,colorUniform=_ref7$colorUniform===void 0?false:_ref7$colorUniform,_ref7$incrementDrawSt=_ref7.incrementDrawState,incrementDrawState=_ref7$incrementDrawSt===void 0?false:_ref7$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,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(rotationMatrix,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$C;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$t);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$r),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?
|
|
14864
|
+
var lights=lightsState.lights;var light;for(var _i167=0,len=lights.length;_i167<len;_i167++){light=lights[_i167];switch(light.type){case"dir":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=null;this._uLightDir[_i167]=program.getLocation("lightDir"+_i167);break;case"point":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=program.getLocation("lightPos"+_i167);this._uLightDir[_i167]=null;this._uLightAttenuation[_i167]=program.getLocation("lightAttenuation"+_i167);break;case"spot":this._uLightColor[_i167]=program.getLocation("lightColor"+_i167);this._uLightPos[_i167]=program.getLocation("lightPos"+_i167);this._uLightDir[_i167]=program.getLocation("lightDir"+_i167);this._uLightAttenuation[_i167]=program.getLocation("lightAttenuation"+_i167);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i168=0,_len20=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i168<_len20;_i168++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i168),pos:program.getLocation("sectionPlanePos"+_i168),dir:program.getLocation("sectionPlaneDir"+_i168)});}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(this._useAlphaCutoff){this._alphaCutoffLocation=program.getLocation("materialAlphaCutoff");}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");if(scene.crossSections){this._uSliceColor=program.getLocation("sliceColor");this._uSliceThickness=program.getLocation("sliceThickness");}}},{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 _i169=0,len=lights.length;_i169<len;_i169++){var light=lights[_i169];if(this._uLightColor[_i169]){gl.uniform4f(this._uLightColor[_i169],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i169]){gl.uniform3fv(this._uLightPos[_i169],light.pos);if(this._uLightAttenuation[_i169]){gl.uniform1f(this._uLightAttenuation[_i169],light.attenuation);}}if(this._uLightDir[_i169]){gl.uniform3fv(this._uLightDir[_i169],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){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}else{if(this._edges&&state.edgeIndicesBuf){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}return vao;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){var _ref7=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},_ref7$colorUniform=_ref7.colorUniform,colorUniform=_ref7$colorUniform===void 0?false:_ref7$colorUniform,_ref7$incrementDrawSt=_ref7.incrementDrawState,incrementDrawState=_ref7$incrementDrawSt===void 0?false:_ref7$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,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(rotationMatrix,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$C;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$t);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$r),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?
|
|
14865
14865
|
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(this._useAlphaCutoff){gl.uniform1f(this._alphaCutoffLocation,textureSet.alphaCutoff);}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 VBORenderer;}();/**
|
|
14866
14866
|
* @private
|
|
14867
|
-
*/var TrianglesBatchingRenderer=/*#__PURE__*/function(_VBORenderer){_inherits(TrianglesBatchingRenderer,_VBORenderer);var _super51=_createSuper(TrianglesBatchingRenderer);function TrianglesBatchingRenderer(scene,withSAO){var _ref8=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref8$edges=_ref8.edges,edges=_ref8$edges===void 0?false:_ref8$edges,_ref8$useAlphaCutoff=_ref8.useAlphaCutoff,useAlphaCutoff=_ref8$useAlphaCutoff===void 0?false:_ref8$useAlphaCutoff;_classCallCheck(this,TrianglesBatchingRenderer);return _super51.call(this,scene,withSAO,{instancing:false,edges:edges,useAlphaCutoff:useAlphaCutoff});}_createClass(TrianglesBatchingRenderer,[{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 TrianglesBatchingRenderer;}(VBORenderer);/**
|
|
14867
|
+
*/var TrianglesBatchingRenderer=/*#__PURE__*/function(_VBORenderer){_inherits(TrianglesBatchingRenderer,_VBORenderer);var _super51=_createSuper(TrianglesBatchingRenderer);function TrianglesBatchingRenderer(scene,withSAO){var _ref8=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref8$edges=_ref8.edges,edges=_ref8$edges===void 0?false:_ref8$edges,_ref8$useAlphaCutoff=_ref8.useAlphaCutoff,useAlphaCutoff=_ref8$useAlphaCutoff===void 0?false:_ref8$useAlphaCutoff;_classCallCheck(this,TrianglesBatchingRenderer);return _super51.call(this,scene,withSAO,{instancing:false,edges:edges,useAlphaCutoff:useAlphaCutoff});}_createClass(TrianglesBatchingRenderer,[{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){if(state.edgeIndicesBuf){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 TrianglesBatchingRenderer;}(VBORenderer);/**
|
|
14868
14868
|
* @private
|
|
14869
14869
|
*/var TrianglesColorRenderer$1=/*#__PURE__*/function(_TrianglesBatchingRen){_inherits(TrianglesColorRenderer$1,_TrianglesBatchingRen);var _super52=_createSuper(TrianglesColorRenderer$1);function TrianglesColorRenderer$1(){_classCallCheck(this,TrianglesColorRenderer$1);return _super52.apply(this,arguments);}_createClass(TrianglesColorRenderer$1,[{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(TrianglesColorRenderer$1.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 _i170=0,len=lightsState.lights.length;_i170<len;_i170++){light=lightsState.lights[_i170];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i170+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i170+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i170+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i170+";");src.push("uniform vec3 lightDir"+_i170+";");}}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
|
|
14870
14870
|
// renderPass = COLOR_OPAQUE
|
|
@@ -14985,8 +14985,8 @@ var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;if(this._vaoCache.has(
|
|
|
14985
14985
|
gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(batchingLayer);//=============================================================
|
|
14986
14986
|
// TODO: Use drawElements count and offset to draw only one entity
|
|
14987
14987
|
//=============================================================
|
|
14988
|
-
if(frameCtx.snapMode==="edge"){state.edgeIndicesBuf.bind();gl.drawElements(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0);state.edgeIndicesBuf.unbind();// needed?
|
|
14989
|
-
}else{gl.drawArrays(gl.POINTS,0,state.positionsBuf.numItems);}}},{key:"_allocate",value:function _allocate(){_get(_getPrototypeOf(TrianglesSnapRenderer$1.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
|
|
14988
|
+
if(frameCtx.snapMode==="edge"){if(state.edgeIndicesBuf){state.edgeIndicesBuf.bind();gl.drawElements(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0);state.edgeIndicesBuf.unbind();// needed?
|
|
14989
|
+
}}else{gl.drawArrays(gl.POINTS,0,state.positionsBuf.numItems);}}},{key:"_allocate",value:function _allocate(){_get(_getPrototypeOf(TrianglesSnapRenderer$1.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
|
|
14990
14990
|
// renderPass = PICK
|
|
14991
14991
|
src.push("int pickFlag = int(flags) >> 12 & 0xF;");src.push("if (pickFlag != renderPass) {");src.push(" gl_Position = vec4(2.0, 0.0, 0.0, 0.0);");// Cull vertex
|
|
14992
14992
|
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?
|
|
@@ -15195,7 +15195,7 @@ var a=tempVec3d$a;var b=tempVec3e$1;var c=tempVec3f$1;var gotIntersect=false;var
|
|
|
15195
15195
|
math.triangleNormal(a,b,c,worldNormal);}gotIntersect=true;}}}if(gotIntersect&&worldNormal){math.transformVec3(this.model.worldNormalMatrix,worldNormal,worldNormal);math.normalizeVec3(worldNormal);}return gotIntersect;}// ---------
|
|
15196
15196
|
},{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 VBOBatchingTrianglesLayer;}();/**
|
|
15197
15197
|
* @private
|
|
15198
|
-
*/var TrianglesInstancingRenderer=/*#__PURE__*/function(_VBORenderer4){_inherits(TrianglesInstancingRenderer,_VBORenderer4);var _super70=_createSuper(TrianglesInstancingRenderer);function TrianglesInstancingRenderer(scene,withSAO){var _ref9=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref9$edges=_ref9.edges,edges=_ref9$edges===void 0?false:_ref9$edges,_ref9$useAlphaCutoff=_ref9.useAlphaCutoff,useAlphaCutoff=_ref9$useAlphaCutoff===void 0?false:_ref9$useAlphaCutoff;_classCallCheck(this,TrianglesInstancingRenderer);return _super70.call(this,scene,withSAO,{instancing:true,edges:edges,useAlphaCutoff:useAlphaCutoff});}_createClass(TrianglesInstancingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;if(this._edges){gl.drawElementsInstanced(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0,state.numInstances);}else{gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);if(incrementDrawState){frameCtx.drawElements++;}}}}]);return TrianglesInstancingRenderer;}(VBORenderer);/**
|
|
15198
|
+
*/var TrianglesInstancingRenderer=/*#__PURE__*/function(_VBORenderer4){_inherits(TrianglesInstancingRenderer,_VBORenderer4);var _super70=_createSuper(TrianglesInstancingRenderer);function TrianglesInstancingRenderer(scene,withSAO){var _ref9=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref9$edges=_ref9.edges,edges=_ref9$edges===void 0?false:_ref9$edges,_ref9$useAlphaCutoff=_ref9.useAlphaCutoff,useAlphaCutoff=_ref9$useAlphaCutoff===void 0?false:_ref9$useAlphaCutoff;_classCallCheck(this,TrianglesInstancingRenderer);return _super70.call(this,scene,withSAO,{instancing:true,edges:edges,useAlphaCutoff:useAlphaCutoff});}_createClass(TrianglesInstancingRenderer,[{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){if(state.edgeIndicesBuf){gl.drawElementsInstanced(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0,state.numInstances);}}else{gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);if(incrementDrawState){frameCtx.drawElements++;}}}}]);return TrianglesInstancingRenderer;}(VBORenderer);/**
|
|
15199
15199
|
* @private
|
|
15200
15200
|
*/var TrianglesColorRenderer=/*#__PURE__*/function(_TrianglesInstancingR){_inherits(TrianglesColorRenderer,_TrianglesInstancingR);var _super71=_createSuper(TrianglesColorRenderer);function TrianglesColorRenderer(){_classCallCheck(this,TrianglesColorRenderer);return _super71.apply(this,arguments);}_createClass(TrianglesColorRenderer,[{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(TrianglesColorRenderer.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
|
|
15201
15201
|
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
|
|
@@ -15320,8 +15320,8 @@ src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * ve
|
|
|
15320
15320
|
* @private
|
|
15321
15321
|
*/var TrianglesSnapRenderer=/*#__PURE__*/function(_VBORenderer6){_inherits(TrianglesSnapRenderer,_VBORenderer6);var _super88=_createSuper(TrianglesSnapRenderer);function TrianglesSnapRenderer(scene){_classCallCheck(this,TrianglesSnapRenderer);return _super88.call(this,scene,false,{instancing:true});}_createClass(TrianglesSnapRenderer,[{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;var aabb=instancingLayer.aabb;// Per-layer AABB for best RTC accuracy
|
|
15322
15322
|
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$x;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$t;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$o);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$n);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(rotationMatrix,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
|
|
15323
|
-
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?
|
|
15324
|
-
}else{gl.drawArraysInstanced(gl.POINTS,0,state.positionsBuf.numItems,state.numInstances);}// Cleanup
|
|
15323
|
+
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"){if(state.edgeIndicesBuf){state.edgeIndicesBuf.bind();gl.drawElementsInstanced(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0,state.numInstances);state.edgeIndicesBuf.unbind();// needed?
|
|
15324
|
+
}}else{gl.drawArraysInstanced(gl.POINTS,0,state.positionsBuf.numItems,state.numInstances);}// Cleanup
|
|
15325
15325
|
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(TrianglesSnapRenderer.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
|
|
15326
15326
|
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
|
|
15327
15327
|
// renderPass = PICK
|