@xeokit/xeokit-sdk 2.6.67 → 2.6.69
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 +15 -6
- package/dist/xeokit-sdk.es.js +15 -6
- package/dist/xeokit-sdk.es5.js +7 -5
- package/dist/xeokit-sdk.min.cjs.js +2 -2
- package/dist/xeokit-sdk.min.es.js +2 -2
- package/dist/xeokit-sdk.min.es5.js +2 -2
- package/package.json +1 -1
- package/src/plugins/XKTLoaderPlugin/parsers/ParserV12.js +2 -2
- package/src/viewer/scene/math/math.js +4 -3
- package/src/viewer/scene/webgl/sao/SAOOcclusionRenderer.js +9 -1
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -6258,9 +6258,10 @@ const math = {
|
|
|
6258
6258
|
|
|
6259
6259
|
// Calculate clip space coordinates, which will be in range
|
|
6260
6260
|
// of x=[-1..1] and y=[-1..1], with y=(+1) at top
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
const
|
|
6261
|
+
// clientWidth/Height needs to be used in case canvas.width/height is scaled down,
|
|
6262
|
+
// but not reflecting client dimensions (e.g. when using FastNavPlugin)
|
|
6263
|
+
const clipX = 2 * canvasPos[0] / canvas.clientWidth - 1; // Calculate clip space coordinates
|
|
6264
|
+
const clipY = 1 - 2 * canvasPos[1] / canvas.clientHeight;
|
|
6264
6265
|
|
|
6265
6266
|
clipToWorld(clipX, clipY, -1, isOrtho, vec4Near);
|
|
6266
6267
|
|
|
@@ -18428,6 +18429,12 @@ class SAOOcclusionRenderer {
|
|
|
18428
18429
|
this._uvBuf = null;
|
|
18429
18430
|
this._positionsBuf = null;
|
|
18430
18431
|
this._indicesBuf = null;
|
|
18432
|
+
|
|
18433
|
+
this.init();
|
|
18434
|
+
}
|
|
18435
|
+
|
|
18436
|
+
init() {
|
|
18437
|
+
this._rebuild = true;
|
|
18431
18438
|
}
|
|
18432
18439
|
|
|
18433
18440
|
render(depthRenderBuffer) {
|
|
@@ -18518,10 +18525,12 @@ class SAOOcclusionRenderer {
|
|
|
18518
18525
|
dirty = true;
|
|
18519
18526
|
}
|
|
18520
18527
|
|
|
18521
|
-
if (!dirty) {
|
|
18528
|
+
if (! (dirty || this._rebuild)) {
|
|
18522
18529
|
return;
|
|
18523
18530
|
}
|
|
18524
18531
|
|
|
18532
|
+
this._rebuild = false;
|
|
18533
|
+
|
|
18525
18534
|
const gl = this._scene.canvas.gl;
|
|
18526
18535
|
|
|
18527
18536
|
if (this._program) {
|
|
@@ -137201,7 +137210,7 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
|
|
|
137201
137210
|
case 7:
|
|
137202
137211
|
geometryArrays.primitiveName = "lines";
|
|
137203
137212
|
geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
|
|
137204
|
-
geometryArrays.decompressedPositions = geometryCompressionUtils.decompressPositions(geometryArrays.geometryPositions,
|
|
137213
|
+
geometryArrays.decompressedPositions = geometryCompressionUtils.decompressPositions(geometryArrays.geometryPositions, reusedGeometriesDecodeMatrix);
|
|
137205
137214
|
ifcLabel = buildVectorTextGeometry({
|
|
137206
137215
|
origin: geometryArrays.decompressedPositions,
|
|
137207
137216
|
text: axisLabel,
|
|
@@ -137223,7 +137232,7 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
|
|
|
137223
137232
|
}
|
|
137224
137233
|
|
|
137225
137234
|
if (geometryArrays) {
|
|
137226
|
-
if (geometryArrays.geometryPositions.length > 1000) ;
|
|
137235
|
+
if (geometryArrays.geometryPositions && geometryArrays.geometryPositions.length > 1000) ;
|
|
137227
137236
|
if (geometryArrays.batchThisMesh) {
|
|
137228
137237
|
if(primitiveType === 7) {
|
|
137229
137238
|
geometryArrays.transformedAndRecompressedPositions = new Uint16Array(geometryArrays.decompressedPositions.length);
|
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -6254,9 +6254,10 @@ const math = {
|
|
|
6254
6254
|
|
|
6255
6255
|
// Calculate clip space coordinates, which will be in range
|
|
6256
6256
|
// of x=[-1..1] and y=[-1..1], with y=(+1) at top
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
const
|
|
6257
|
+
// clientWidth/Height needs to be used in case canvas.width/height is scaled down,
|
|
6258
|
+
// but not reflecting client dimensions (e.g. when using FastNavPlugin)
|
|
6259
|
+
const clipX = 2 * canvasPos[0] / canvas.clientWidth - 1; // Calculate clip space coordinates
|
|
6260
|
+
const clipY = 1 - 2 * canvasPos[1] / canvas.clientHeight;
|
|
6260
6261
|
|
|
6261
6262
|
clipToWorld(clipX, clipY, -1, isOrtho, vec4Near);
|
|
6262
6263
|
|
|
@@ -18424,6 +18425,12 @@ class SAOOcclusionRenderer {
|
|
|
18424
18425
|
this._uvBuf = null;
|
|
18425
18426
|
this._positionsBuf = null;
|
|
18426
18427
|
this._indicesBuf = null;
|
|
18428
|
+
|
|
18429
|
+
this.init();
|
|
18430
|
+
}
|
|
18431
|
+
|
|
18432
|
+
init() {
|
|
18433
|
+
this._rebuild = true;
|
|
18427
18434
|
}
|
|
18428
18435
|
|
|
18429
18436
|
render(depthRenderBuffer) {
|
|
@@ -18514,10 +18521,12 @@ class SAOOcclusionRenderer {
|
|
|
18514
18521
|
dirty = true;
|
|
18515
18522
|
}
|
|
18516
18523
|
|
|
18517
|
-
if (!dirty) {
|
|
18524
|
+
if (! (dirty || this._rebuild)) {
|
|
18518
18525
|
return;
|
|
18519
18526
|
}
|
|
18520
18527
|
|
|
18528
|
+
this._rebuild = false;
|
|
18529
|
+
|
|
18521
18530
|
const gl = this._scene.canvas.gl;
|
|
18522
18531
|
|
|
18523
18532
|
if (this._program) {
|
|
@@ -137197,7 +137206,7 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
|
|
|
137197
137206
|
case 7:
|
|
137198
137207
|
geometryArrays.primitiveName = "lines";
|
|
137199
137208
|
geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]);
|
|
137200
|
-
geometryArrays.decompressedPositions = geometryCompressionUtils.decompressPositions(geometryArrays.geometryPositions,
|
|
137209
|
+
geometryArrays.decompressedPositions = geometryCompressionUtils.decompressPositions(geometryArrays.geometryPositions, reusedGeometriesDecodeMatrix);
|
|
137201
137210
|
ifcLabel = buildVectorTextGeometry({
|
|
137202
137211
|
origin: geometryArrays.decompressedPositions,
|
|
137203
137212
|
text: axisLabel,
|
|
@@ -137219,7 +137228,7 @@ function load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx)
|
|
|
137219
137228
|
}
|
|
137220
137229
|
|
|
137221
137230
|
if (geometryArrays) {
|
|
137222
|
-
if (geometryArrays.geometryPositions.length > 1000) ;
|
|
137231
|
+
if (geometryArrays.geometryPositions && geometryArrays.geometryPositions.length > 1000) ;
|
|
137223
137232
|
if (geometryArrays.batchThisMesh) {
|
|
137224
137233
|
if(primitiveType === 7) {
|
|
137225
137234
|
geometryArrays.transformedAndRecompressedPositions = new Uint16Array(geometryArrays.decompressedPositions.length);
|
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -1423,8 +1423,10 @@ var precision=Math.pow(10,precisionPoints);var posi;var i;var j;var len;var a;va
|
|
|
1423
1423
|
@param {Number[]} worldRayDir The World-space ray direction.
|
|
1424
1424
|
*/canvasPosToWorldRay:function(){var pvMatInv=new FloatArrayType(16);var vec4Near=new FloatArrayType(4);var vec4Far=new FloatArrayType(4);var clipToWorld=function clipToWorld(clipX,clipY,clipZ,isOrtho,outVec4){outVec4[0]=clipX;outVec4[1]=clipY;outVec4[2]=clipZ;outVec4[3]=1;math.transformVec4(pvMatInv,outVec4,outVec4);if(!isOrtho)math.mulVec4Scalar(outVec4,1/outVec4[3]);};return function(canvas,viewMatrix,projMatrix,projection,canvasPos,worldRayOrigin,worldRayDir){var isOrtho=projection==="ortho";math.mulMat4(projMatrix,viewMatrix,pvMatInv);math.inverseMat4(pvMatInv,pvMatInv);// Calculate clip space coordinates, which will be in range
|
|
1425
1425
|
// of x=[-1..1] and y=[-1..1], with y=(+1) at top
|
|
1426
|
-
|
|
1427
|
-
|
|
1426
|
+
// clientWidth/Height needs to be used in case canvas.width/height is scaled down,
|
|
1427
|
+
// but not reflecting client dimensions (e.g. when using FastNavPlugin)
|
|
1428
|
+
var clipX=2*canvasPos[0]/canvas.clientWidth-1;// Calculate clip space coordinates
|
|
1429
|
+
var clipY=1-2*canvasPos[1]/canvas.clientHeight;clipToWorld(clipX,clipY,-1,isOrtho,vec4Near);clipToWorld(clipX,clipY,1,isOrtho,vec4Far);worldRayOrigin[0]=vec4Near[0];worldRayOrigin[1]=vec4Near[1];worldRayOrigin[2]=vec4Near[2];math.subVec3(vec4Far,vec4Near,worldRayDir);math.normalizeVec3(worldRayDir);};}(),/**
|
|
1428
1430
|
Transforms a Canvas-space position to a Mesh's Local-space coordinate system, in the context of a Camera.
|
|
1429
1431
|
@method canvasPosToLocalRay
|
|
1430
1432
|
@static
|
|
@@ -4791,8 +4793,8 @@ this._markersToOcclusionLayersMap={};this._onCameraViewMatrix=scene.camera.on("v
|
|
|
4791
4793
|
*/var SAOOcclusionRenderer=/*#__PURE__*/function(){function SAOOcclusionRenderer(scene){_classCallCheck(this,SAOOcclusionRenderer);this._scene=scene;this._numSamples=null;// The program
|
|
4792
4794
|
this._program=null;this._programError=false;// Variable locations
|
|
4793
4795
|
this._aPosition=null;this._aUV=null;this._uDepthTexture="uDepthTexture";this._uCameraNear=null;this._uCameraFar=null;this._uCameraProjectionMatrix=null;this._uCameraInverseProjectionMatrix=null;this._uScale=null;this._uIntensity=null;this._uBias=null;this._uKernelRadius=null;this._uMinResolution=null;this._uRandomSeed=null;// VBOs
|
|
4794
|
-
this._uvBuf=null;this._positionsBuf=null;this._indicesBuf=null;}_createClass(SAOOcclusionRenderer,[{key:"render",value:function render(depthRenderBuffer){var _this39=this;this._build();if(this._programError){return;}if(!this._getInverseProjectMat){// HACK: scene.camera not defined until render time
|
|
4795
|
-
this._getInverseProjectMat=function(){var projMatDirty=true;_this39._scene.camera.on("projMatrix",function(){projMatDirty=true;});var inverseProjectMat=math.mat4();return function(){if(projMatDirty){math.inverseMat4(scene.camera.projMatrix,inverseProjectMat);}return inverseProjectMat;};}();}var gl=this._scene.canvas.gl;var program=this._program;var scene=this._scene;var sao=scene.sao;var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;var projectState=scene.camera.project._state;var near=projectState.near;var far=projectState.far;var projectionMatrix=projectState.matrix;var inverseProjectionMatrix=this._getInverseProjectMat();var randomSeed=Math.random();var perspective=scene.camera.projection==="perspective";tempVec2[0]=viewportWidth;tempVec2[1]=viewportHeight;gl.viewport(0,0,viewportWidth,viewportHeight);gl.clearColor(0,0,0,1);gl.disable(gl.DEPTH_TEST);gl.disable(gl.BLEND);gl.frontFace(gl.CCW);gl.clear(gl.COLOR_BUFFER_BIT);program.bind();gl.uniform1f(this._uCameraNear,near);gl.uniform1f(this._uCameraFar,far);gl.uniformMatrix4fv(this._uCameraProjectionMatrix,false,projectionMatrix);gl.uniformMatrix4fv(this._uCameraInverseProjectionMatrix,false,inverseProjectionMatrix);gl.uniform1i(this._uPerspective,perspective);gl.uniform1f(this._uScale,sao.scale*(far/5));gl.uniform1f(this._uIntensity,sao.intensity);gl.uniform1f(this._uBias,sao.bias);gl.uniform1f(this._uKernelRadius,sao.kernelRadius);gl.uniform1f(this._uMinResolution,sao.minResolution);gl.uniform2fv(this._uViewport,tempVec2);gl.uniform1f(this._uRandomSeed,randomSeed);var depthTexture=depthRenderBuffer.getDepthTexture();program.bindTexture(this._uDepthTexture,depthTexture,0);this._aUV.bindArrayBuffer(this._uvBuf);this._aPosition.bindArrayBuffer(this._positionsBuf);this._indicesBuf.bind();gl.drawElements(gl.TRIANGLES,this._indicesBuf.numItems,this._indicesBuf.itemType,0);}},{key:"_build",value:function _build(){var dirty=false;var sao=this._scene.sao;if(sao.numSamples!==this._numSamples){this._numSamples=Math.floor(sao.numSamples);dirty=true;}if(!dirty){return;}var gl=this._scene.canvas.gl;if(this._program){this._program.destroy();this._program=null;}this._program=new Program(gl,{vertex:["#version 300 es\n precision highp float;\n precision highp int;\n \n in vec3 aPosition;\n in vec2 aUV; \n \n out vec2 vUV;\n \n void main () {\n gl_Position = vec4(aPosition, 1.0);\n vUV = aUV;\n }"],fragment:["#version 300 es \n precision highp float;\n precision highp int; \n \n #define NORMAL_TEXTURE 0\n #define PI 3.14159265359\n #define PI2 6.28318530718\n #define EPSILON 1e-6\n #define NUM_SAMPLES ".concat(this._numSamples,"\n #define NUM_RINGS 4 \n \n in vec2 vUV;\n \n uniform sampler2D uDepthTexture;\n \n uniform float uCameraNear;\n uniform float uCameraFar;\n uniform mat4 uProjectMatrix;\n uniform mat4 uInverseProjectMatrix;\n \n uniform bool uPerspective;\n\n uniform float uScale;\n uniform float uIntensity;\n uniform float uBias;\n uniform float uKernelRadius;\n uniform float uMinResolution;\n uniform vec2 uViewport;\n uniform float uRandomSeed;\n\n float pow2( const in float x ) { return x*x; }\n \n highp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract(sin(sn) * c);\n }\n\n vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n }\n\n vec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n }\n\n const float packUpscale = 256. / 255.;\n const float unpackDownScale = 255. / 256.; \n\n const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\n const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. ); \n\n const float shiftRights = 1. / 256.;\n\n vec4 packFloatToRGBA( const in float v ) {\n vec4 r = vec4( fract( v * packFactors ), v );\n r.yzw -= r.xyz * shiftRights; \n return r * packUpscale;\n }\n\n float unpackRGBAToFloat( const in vec4 v ) { \n return dot( floor( v * 255.0 + 0.5 ) / 255.0, unPackFactors );\n }\n \n float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n }\n\n float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n }\n \n float getDepth( const in vec2 screenPosition ) {\n return vec4(texture(uDepthTexture, screenPosition)).r;\n }\n\n float getViewZ( const in float depth ) {\n if (uPerspective) {\n return perspectiveDepthToViewZ( depth, uCameraNear, uCameraFar );\n } else {\n return orthographicDepthToViewZ( depth, uCameraNear, uCameraFar );\n }\n }\n\n vec3 getViewPos( const in vec2 screenPos, const in float depth, const in float viewZ ) {\n \tfloat clipW = uProjectMatrix[2][3] * viewZ + uProjectMatrix[3][3];\n \tvec4 clipPosition = vec4( ( vec3( screenPos, depth ) - 0.5 ) * 2.0, 1.0 );\n \tclipPosition *= clipW; \n \treturn ( uInverseProjectMatrix * clipPosition ).xyz;\n }\n\n vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPos ) { \n return normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );\n }\n\n float scaleDividedByCameraFar;\n float minResolutionMultipliedByCameraFar;\n\n float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n \tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n \tfloat viewDistance = length( viewDelta );\n \tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n \treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - uBias) / (1.0 + pow2( scaledScreenDistance ) );\n }\n\n const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n float getAmbientOcclusion( const in vec3 centerViewPosition ) {\n \n \tscaleDividedByCameraFar = uScale / uCameraFar;\n \tminResolutionMultipliedByCameraFar = uMinResolution * uCameraFar;\n \tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUV );\n\n \tfloat angle = rand( vUV + uRandomSeed ) * PI2;\n \tvec2 radius = vec2( uKernelRadius * INV_NUM_SAMPLES ) / uViewport;\n \tvec2 radiusStep = radius;\n\n \tfloat occlusionSum = 0.0;\n \tfloat weightSum = 0.0;\n\n \tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n \t\tvec2 sampleUv = vUV + vec2( cos( angle ), sin( angle ) ) * radius;\n \t\tradius += radiusStep;\n \t\tangle += ANGLE_STEP;\n\n \t\tfloat sampleDepth = getDepth( sampleUv );\n \t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n \t\t\tcontinue;\n \t\t}\n\n \t\tfloat sampleViewZ = getViewZ( sampleDepth );\n \t\tvec3 sampleViewPosition = getViewPos( sampleUv, sampleDepth, sampleViewZ );\n \t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n \t\tweightSum += 1.0;\n \t}\n\n \tif( weightSum == 0.0 ) discard;\n\n \treturn occlusionSum * ( uIntensity / weightSum );\n }\n\n out vec4 outColor;\n \n void main() {\n \n \tfloat centerDepth = getDepth( vUV );\n \t\n \tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n \t\tdiscard;\n \t}\n\n \tfloat centerViewZ = getViewZ( centerDepth );\n \tvec3 viewPosition = getViewPos( vUV, centerDepth, centerViewZ );\n\n \tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n \n \toutColor = packFloatToRGBA( 1.0- ambientOcclusion );\n }")]});if(this._program.errors){console.error(this._program.errors.join("\n"));this._programError=true;return;}var uv=new Float32Array([1,1,0,1,0,0,1,0]);var positions=new Float32Array([1,1,0,-1,1,0,-1,-1,0,1,-1,0]);// Mitigation: if Uint8Array is used, the geometry is corrupted on OSX when using Chrome with data-textures
|
|
4796
|
+
this._uvBuf=null;this._positionsBuf=null;this._indicesBuf=null;this.init();}_createClass(SAOOcclusionRenderer,[{key:"init",value:function init(){this._rebuild=true;}},{key:"render",value:function render(depthRenderBuffer){var _this39=this;this._build();if(this._programError){return;}if(!this._getInverseProjectMat){// HACK: scene.camera not defined until render time
|
|
4797
|
+
this._getInverseProjectMat=function(){var projMatDirty=true;_this39._scene.camera.on("projMatrix",function(){projMatDirty=true;});var inverseProjectMat=math.mat4();return function(){if(projMatDirty){math.inverseMat4(scene.camera.projMatrix,inverseProjectMat);}return inverseProjectMat;};}();}var gl=this._scene.canvas.gl;var program=this._program;var scene=this._scene;var sao=scene.sao;var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;var projectState=scene.camera.project._state;var near=projectState.near;var far=projectState.far;var projectionMatrix=projectState.matrix;var inverseProjectionMatrix=this._getInverseProjectMat();var randomSeed=Math.random();var perspective=scene.camera.projection==="perspective";tempVec2[0]=viewportWidth;tempVec2[1]=viewportHeight;gl.viewport(0,0,viewportWidth,viewportHeight);gl.clearColor(0,0,0,1);gl.disable(gl.DEPTH_TEST);gl.disable(gl.BLEND);gl.frontFace(gl.CCW);gl.clear(gl.COLOR_BUFFER_BIT);program.bind();gl.uniform1f(this._uCameraNear,near);gl.uniform1f(this._uCameraFar,far);gl.uniformMatrix4fv(this._uCameraProjectionMatrix,false,projectionMatrix);gl.uniformMatrix4fv(this._uCameraInverseProjectionMatrix,false,inverseProjectionMatrix);gl.uniform1i(this._uPerspective,perspective);gl.uniform1f(this._uScale,sao.scale*(far/5));gl.uniform1f(this._uIntensity,sao.intensity);gl.uniform1f(this._uBias,sao.bias);gl.uniform1f(this._uKernelRadius,sao.kernelRadius);gl.uniform1f(this._uMinResolution,sao.minResolution);gl.uniform2fv(this._uViewport,tempVec2);gl.uniform1f(this._uRandomSeed,randomSeed);var depthTexture=depthRenderBuffer.getDepthTexture();program.bindTexture(this._uDepthTexture,depthTexture,0);this._aUV.bindArrayBuffer(this._uvBuf);this._aPosition.bindArrayBuffer(this._positionsBuf);this._indicesBuf.bind();gl.drawElements(gl.TRIANGLES,this._indicesBuf.numItems,this._indicesBuf.itemType,0);}},{key:"_build",value:function _build(){var dirty=false;var sao=this._scene.sao;if(sao.numSamples!==this._numSamples){this._numSamples=Math.floor(sao.numSamples);dirty=true;}if(!(dirty||this._rebuild)){return;}this._rebuild=false;var gl=this._scene.canvas.gl;if(this._program){this._program.destroy();this._program=null;}this._program=new Program(gl,{vertex:["#version 300 es\n precision highp float;\n precision highp int;\n \n in vec3 aPosition;\n in vec2 aUV; \n \n out vec2 vUV;\n \n void main () {\n gl_Position = vec4(aPosition, 1.0);\n vUV = aUV;\n }"],fragment:["#version 300 es \n precision highp float;\n precision highp int; \n \n #define NORMAL_TEXTURE 0\n #define PI 3.14159265359\n #define PI2 6.28318530718\n #define EPSILON 1e-6\n #define NUM_SAMPLES ".concat(this._numSamples,"\n #define NUM_RINGS 4 \n \n in vec2 vUV;\n \n uniform sampler2D uDepthTexture;\n \n uniform float uCameraNear;\n uniform float uCameraFar;\n uniform mat4 uProjectMatrix;\n uniform mat4 uInverseProjectMatrix;\n \n uniform bool uPerspective;\n\n uniform float uScale;\n uniform float uIntensity;\n uniform float uBias;\n uniform float uKernelRadius;\n uniform float uMinResolution;\n uniform vec2 uViewport;\n uniform float uRandomSeed;\n\n float pow2( const in float x ) { return x*x; }\n \n highp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract(sin(sn) * c);\n }\n\n vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n }\n\n vec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n }\n\n const float packUpscale = 256. / 255.;\n const float unpackDownScale = 255. / 256.; \n\n const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\n const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. ); \n\n const float shiftRights = 1. / 256.;\n\n vec4 packFloatToRGBA( const in float v ) {\n vec4 r = vec4( fract( v * packFactors ), v );\n r.yzw -= r.xyz * shiftRights; \n return r * packUpscale;\n }\n\n float unpackRGBAToFloat( const in vec4 v ) { \n return dot( floor( v * 255.0 + 0.5 ) / 255.0, unPackFactors );\n }\n \n float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n }\n\n float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n }\n \n float getDepth( const in vec2 screenPosition ) {\n return vec4(texture(uDepthTexture, screenPosition)).r;\n }\n\n float getViewZ( const in float depth ) {\n if (uPerspective) {\n return perspectiveDepthToViewZ( depth, uCameraNear, uCameraFar );\n } else {\n return orthographicDepthToViewZ( depth, uCameraNear, uCameraFar );\n }\n }\n\n vec3 getViewPos( const in vec2 screenPos, const in float depth, const in float viewZ ) {\n \tfloat clipW = uProjectMatrix[2][3] * viewZ + uProjectMatrix[3][3];\n \tvec4 clipPosition = vec4( ( vec3( screenPos, depth ) - 0.5 ) * 2.0, 1.0 );\n \tclipPosition *= clipW; \n \treturn ( uInverseProjectMatrix * clipPosition ).xyz;\n }\n\n vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPos ) { \n return normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );\n }\n\n float scaleDividedByCameraFar;\n float minResolutionMultipliedByCameraFar;\n\n float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n \tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n \tfloat viewDistance = length( viewDelta );\n \tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n \treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - uBias) / (1.0 + pow2( scaledScreenDistance ) );\n }\n\n const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n float getAmbientOcclusion( const in vec3 centerViewPosition ) {\n \n \tscaleDividedByCameraFar = uScale / uCameraFar;\n \tminResolutionMultipliedByCameraFar = uMinResolution * uCameraFar;\n \tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUV );\n\n \tfloat angle = rand( vUV + uRandomSeed ) * PI2;\n \tvec2 radius = vec2( uKernelRadius * INV_NUM_SAMPLES ) / uViewport;\n \tvec2 radiusStep = radius;\n\n \tfloat occlusionSum = 0.0;\n \tfloat weightSum = 0.0;\n\n \tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n \t\tvec2 sampleUv = vUV + vec2( cos( angle ), sin( angle ) ) * radius;\n \t\tradius += radiusStep;\n \t\tangle += ANGLE_STEP;\n\n \t\tfloat sampleDepth = getDepth( sampleUv );\n \t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n \t\t\tcontinue;\n \t\t}\n\n \t\tfloat sampleViewZ = getViewZ( sampleDepth );\n \t\tvec3 sampleViewPosition = getViewPos( sampleUv, sampleDepth, sampleViewZ );\n \t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n \t\tweightSum += 1.0;\n \t}\n\n \tif( weightSum == 0.0 ) discard;\n\n \treturn occlusionSum * ( uIntensity / weightSum );\n }\n\n out vec4 outColor;\n \n void main() {\n \n \tfloat centerDepth = getDepth( vUV );\n \t\n \tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n \t\tdiscard;\n \t}\n\n \tfloat centerViewZ = getViewZ( centerDepth );\n \tvec3 viewPosition = getViewPos( vUV, centerDepth, centerViewZ );\n\n \tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n \n \toutColor = packFloatToRGBA( 1.0- ambientOcclusion );\n }")]});if(this._program.errors){console.error(this._program.errors.join("\n"));this._programError=true;return;}var uv=new Float32Array([1,1,0,1,0,0,1,0]);var positions=new Float32Array([1,1,0,-1,1,0,-1,-1,0,1,-1,0]);// Mitigation: if Uint8Array is used, the geometry is corrupted on OSX when using Chrome with data-textures
|
|
4796
4798
|
var indices=new Uint32Array([0,1,2,0,2,3]);this._positionsBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,positions,positions.length,3,gl.STATIC_DRAW);this._uvBuf=new ArrayBuf(gl,gl.ARRAY_BUFFER,uv,uv.length,2,gl.STATIC_DRAW);this._indicesBuf=new ArrayBuf(gl,gl.ELEMENT_ARRAY_BUFFER,indices,indices.length,1,gl.STATIC_DRAW);this._program.bind();this._uCameraNear=this._program.getLocation("uCameraNear");this._uCameraFar=this._program.getLocation("uCameraFar");this._uCameraProjectionMatrix=this._program.getLocation("uProjectMatrix");this._uCameraInverseProjectionMatrix=this._program.getLocation("uInverseProjectMatrix");this._uPerspective=this._program.getLocation("uPerspective");this._uScale=this._program.getLocation("uScale");this._uIntensity=this._program.getLocation("uIntensity");this._uBias=this._program.getLocation("uBias");this._uKernelRadius=this._program.getLocation("uKernelRadius");this._uMinResolution=this._program.getLocation("uMinResolution");this._uViewport=this._program.getLocation("uViewport");this._uRandomSeed=this._program.getLocation("uRandomSeed");this._aPosition=this._program.getAttribute("aPosition");this._aUV=this._program.getAttribute("aUV");this._dirty=false;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();this._program=null;}}}]);return SAOOcclusionRenderer;}();var blurStdDev=4;var blurDepthCutoff=0.01;var KERNEL_RADIUS=16;var sampleOffsetsVert=new Float32Array(createSampleOffsets(KERNEL_RADIUS+1,[0,1]));var sampleOffsetsHor=new Float32Array(createSampleOffsets(KERNEL_RADIUS+1,[1,0]));var sampleWeights=new Float32Array(createSampleWeights(KERNEL_RADIUS+1,blurStdDev));var tempVec2a$1=new Float32Array(2);/**
|
|
4797
4799
|
* SAO implementation inspired from previous SAO work in THREE.js by ludobaka / ludobaka.github.io and bhouston
|
|
4798
4800
|
* @private
|
|
@@ -31069,7 +31071,7 @@ if(options.includeIdsMap&&metaObject.id&&!options.includeIdsMap[metaObject.id]){
|
|
|
31069
31071
|
var props=options.objectDefaults?options.objectDefaults[metaObject.type]||options.objectDefaults["DEFAULT"]:null;if(props){if(props.visible===false){entityDefaults.visible=false;}if(props.pickable===false){entityDefaults.pickable=false;}if(props.colorize){meshDefaults.color=props.colorize;}if(props.opacity!==undefined&&props.opacity!==null){meshDefaults.opacity=props.opacity;}if(props.metallic!==undefined&&props.metallic!==null){meshDefaults.metallic=props.metallic;}if(props.roughness!==undefined&&props.roughness!==null){meshDefaults.roughness=props.roughness;}}}else{if(options.excludeUnclassifiedObjects){continue;}}// Iterate each entity's meshes
|
|
31070
31072
|
for(var _meshIndex6=firstMeshIndex;_meshIndex6<=lastMeshIndex;_meshIndex6++){var _geometryIndex6=eachMeshGeometriesPortion[_meshIndex6];var geometryReuseCount=geometryReuseCounts[_geometryIndex6];var isReusedGeometry=geometryReuseCount>1;var atLastGeometry=_geometryIndex6===numGeometries-1;var _textureSetIndex3=eachMeshTextureSet[_meshIndex6];var _textureSetId3=_textureSetIndex3>=0?"".concat(modelPartId,"-textureSet-").concat(_textureSetIndex3):null;var meshColor=decompressColor(eachMeshMaterialAttributes.subarray(_meshIndex6*6,_meshIndex6*6+3));var meshOpacity=eachMeshMaterialAttributes[_meshIndex6*6+3]/255.0;var meshMetallic=eachMeshMaterialAttributes[_meshIndex6*6+4]/255.0;var meshRoughness=eachMeshMaterialAttributes[_meshIndex6*6+5]/255.0;var meshId=manifestCtx.getNextId();if(isReusedGeometry){// Create mesh for multi-use geometry - create (or reuse) geometry, create mesh using that geometry
|
|
31071
31073
|
var meshMatrixIndex=eachMeshMatricesPortion[_meshIndex6];var meshMatrix=matrices.slice(meshMatrixIndex,meshMatrixIndex+16);var geometryId="".concat(modelPartId,"-geometry.").concat(tileIndex,".").concat(_geometryIndex6);// These IDs are local to the SceneModel
|
|
31072
|
-
var geometryArrays=geometryArraysCache[geometryId];if(!geometryArrays){geometryArrays={batchThisMesh:!options.reuseGeometries};var primitiveType=eachGeometryPrimitiveType[_geometryIndex6];var axisLabel=eachGeometryAxisLabel[_geometryIndex6];var geometryValid=false;var ifcLabel=void 0;switch(primitiveType){case 0:geometryArrays.primitiveName="solid";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryNormals=normals.subarray(eachGeometryNormalsPortion[_geometryIndex6],atLastGeometry?normals.length:eachGeometryNormalsPortion[_geometryIndex6+1]);geometryArrays.geometryUVs=uvs.subarray(eachGeometryUVsPortion[_geometryIndex6],atLastGeometry?uvs.length:eachGeometryUVsPortion[_geometryIndex6+1]);geometryArrays.geometryIndices=indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]);geometryArrays.geometryEdgeIndices=edgeIndices.subarray(eachGeometryEdgeIndicesPortion[_geometryIndex6],atLastGeometry?edgeIndices.length:eachGeometryEdgeIndicesPortion[_geometryIndex6+1]);geometryValid=geometryArrays.geometryPositions.length>0&&geometryArrays.geometryIndices.length>0;break;case 1:geometryArrays.primitiveName="surface";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryNormals=normals.subarray(eachGeometryNormalsPortion[_geometryIndex6],atLastGeometry?normals.length:eachGeometryNormalsPortion[_geometryIndex6+1]);geometryArrays.geometryUVs=uvs.subarray(eachGeometryUVsPortion[_geometryIndex6],atLastGeometry?uvs.length:eachGeometryUVsPortion[_geometryIndex6+1]);geometryArrays.geometryIndices=indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]);geometryArrays.geometryEdgeIndices=edgeIndices.subarray(eachGeometryEdgeIndicesPortion[_geometryIndex6],atLastGeometry?edgeIndices.length:eachGeometryEdgeIndicesPortion[_geometryIndex6+1]);geometryValid=geometryArrays.geometryPositions.length>0&&geometryArrays.geometryIndices.length>0;break;case 2:geometryArrays.primitiveName="points";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryColors=colors.subarray(eachGeometryColorsPortion[_geometryIndex6],atLastGeometry?colors.length:eachGeometryColorsPortion[_geometryIndex6+1]);geometryValid=geometryArrays.geometryPositions.length>0;break;case 3:geometryArrays.primitiveName="lines";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryIndices=indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]);geometryValid=geometryArrays.geometryPositions.length>0&&geometryArrays.geometryIndices.length>0;break;case 4:geometryArrays.primitiveName="lines";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryIndices=lineStripToLines(geometryArrays.geometryPositions,indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]));geometryValid=geometryArrays.geometryPositions.length>0&&geometryArrays.geometryIndices.length>0;break;case 7:geometryArrays.primitiveName="lines";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.decompressedPositions=geometryCompressionUtils.decompressPositions(geometryArrays.geometryPositions,
|
|
31074
|
+
var geometryArrays=geometryArraysCache[geometryId];if(!geometryArrays){geometryArrays={batchThisMesh:!options.reuseGeometries};var primitiveType=eachGeometryPrimitiveType[_geometryIndex6];var axisLabel=eachGeometryAxisLabel[_geometryIndex6];var geometryValid=false;var ifcLabel=void 0;switch(primitiveType){case 0:geometryArrays.primitiveName="solid";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryNormals=normals.subarray(eachGeometryNormalsPortion[_geometryIndex6],atLastGeometry?normals.length:eachGeometryNormalsPortion[_geometryIndex6+1]);geometryArrays.geometryUVs=uvs.subarray(eachGeometryUVsPortion[_geometryIndex6],atLastGeometry?uvs.length:eachGeometryUVsPortion[_geometryIndex6+1]);geometryArrays.geometryIndices=indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]);geometryArrays.geometryEdgeIndices=edgeIndices.subarray(eachGeometryEdgeIndicesPortion[_geometryIndex6],atLastGeometry?edgeIndices.length:eachGeometryEdgeIndicesPortion[_geometryIndex6+1]);geometryValid=geometryArrays.geometryPositions.length>0&&geometryArrays.geometryIndices.length>0;break;case 1:geometryArrays.primitiveName="surface";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryNormals=normals.subarray(eachGeometryNormalsPortion[_geometryIndex6],atLastGeometry?normals.length:eachGeometryNormalsPortion[_geometryIndex6+1]);geometryArrays.geometryUVs=uvs.subarray(eachGeometryUVsPortion[_geometryIndex6],atLastGeometry?uvs.length:eachGeometryUVsPortion[_geometryIndex6+1]);geometryArrays.geometryIndices=indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]);geometryArrays.geometryEdgeIndices=edgeIndices.subarray(eachGeometryEdgeIndicesPortion[_geometryIndex6],atLastGeometry?edgeIndices.length:eachGeometryEdgeIndicesPortion[_geometryIndex6+1]);geometryValid=geometryArrays.geometryPositions.length>0&&geometryArrays.geometryIndices.length>0;break;case 2:geometryArrays.primitiveName="points";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryColors=colors.subarray(eachGeometryColorsPortion[_geometryIndex6],atLastGeometry?colors.length:eachGeometryColorsPortion[_geometryIndex6+1]);geometryValid=geometryArrays.geometryPositions.length>0;break;case 3:geometryArrays.primitiveName="lines";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryIndices=indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]);geometryValid=geometryArrays.geometryPositions.length>0&&geometryArrays.geometryIndices.length>0;break;case 4:geometryArrays.primitiveName="lines";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.geometryIndices=lineStripToLines(geometryArrays.geometryPositions,indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]));geometryValid=geometryArrays.geometryPositions.length>0&&geometryArrays.geometryIndices.length>0;break;case 7:geometryArrays.primitiveName="lines";geometryArrays.geometryPositions=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryArrays.decompressedPositions=geometryCompressionUtils.decompressPositions(geometryArrays.geometryPositions,reusedGeometriesDecodeMatrix);ifcLabel=buildVectorTextGeometry({origin:geometryArrays.decompressedPositions,text:axisLabel,size:2});geometryArrays.decompressedPositions=ifcLabel.positions;geometryArrays.geometryIndices=ifcLabel.indices;geometryArrays.geometryPositions=null;geometryValid=geometryArrays.decompressedPositions.length>0&&geometryArrays.geometryIndices.length>0;break;default:continue;}if(!geometryValid){geometryArrays=null;}if(geometryArrays){if(geometryArrays.geometryPositions&&geometryArrays.geometryPositions.length>1000);if(geometryArrays.batchThisMesh){if(primitiveType===7){geometryArrays.transformedAndRecompressedPositions=new Uint16Array(geometryArrays.decompressedPositions.length);}else{geometryArrays.decompressedPositions=new Float32Array(geometryArrays.geometryPositions.length);geometryArrays.transformedAndRecompressedPositions=new Uint16Array(geometryArrays.geometryPositions.length);var geometryPositions=geometryArrays.geometryPositions;var decompressedPositions=geometryArrays.decompressedPositions;for(var _i640=0,len=geometryPositions.length;_i640<len;_i640+=3){decompressedPositions[_i640+0]=geometryPositions[_i640+0]*reusedGeometriesDecodeMatrix[0]+reusedGeometriesDecodeMatrix[12];decompressedPositions[_i640+1]=geometryPositions[_i640+1]*reusedGeometriesDecodeMatrix[5]+reusedGeometriesDecodeMatrix[13];decompressedPositions[_i640+2]=geometryPositions[_i640+2]*reusedGeometriesDecodeMatrix[10]+reusedGeometriesDecodeMatrix[14];}geometryArrays.geometryPositions=null;}geometryArraysCache[geometryId]=geometryArrays;}}}if(geometryArrays){if(geometryArrays.batchThisMesh){var _decompressedPositions5=geometryArrays.decompressedPositions;var transformedAndRecompressedPositions=geometryArrays.transformedAndRecompressedPositions;for(var _i641=0,_len119=_decompressedPositions5.length;_i641<_len119;_i641+=3){tempVec4a[0]=_decompressedPositions5[_i641+0];tempVec4a[1]=_decompressedPositions5[_i641+1];tempVec4a[2]=_decompressedPositions5[_i641+2];tempVec4a[3]=1;math.transformVec4(meshMatrix,tempVec4a,tempVec4b);geometryCompressionUtils.compressPosition(tempVec4b,rtcAABB,tempVec4a);transformedAndRecompressedPositions[_i641+0]=tempVec4a[0];transformedAndRecompressedPositions[_i641+1]=tempVec4a[1];transformedAndRecompressedPositions[_i641+2]=tempVec4a[2];}sceneModel.createMesh(utils.apply(meshDefaults,{id:meshId,textureSetId:_textureSetId3,origin:tileCenter,primitive:geometryArrays.primitiveName,positionsCompressed:transformedAndRecompressedPositions,normalsCompressed:geometryArrays.geometryNormals,uv:geometryArrays.geometryUVs,colorsCompressed:geometryArrays.geometryColors,indices:geometryArrays.geometryIndices,edgeIndices:geometryArrays.geometryEdgeIndices,positionsDecodeMatrix:tileDecodeMatrix,color:meshColor,metallic:meshMetallic,roughness:meshRoughness,opacity:meshOpacity}));meshIds.push(meshId);}else{if(!geometryCreatedInTile[geometryId]){var geometryCfg={id:geometryId,primitive:geometryArrays.primitiveName,normalsCompressed:geometryArrays.geometryNormals,uv:geometryArrays.geometryUVs,colorsCompressed:geometryArrays.geometryColors,indices:geometryArrays.geometryIndices,edgeIndices:geometryArrays.geometryEdgeIndices};if(geometryArrays.geometryPositions){geometryCfg=_objectSpread(_objectSpread({},geometryCfg),{},{positionsCompressed:geometryArrays.geometryPositions,positionsDecodeMatrix:reusedGeometriesDecodeMatrix});}else{geometryCfg=_objectSpread(_objectSpread({},geometryCfg),{},{positions:geometryArrays.decompressedPositions});}sceneModel.createGeometry(geometryCfg);geometryCreatedInTile[geometryId]=true;}sceneModel.createMesh(utils.apply(meshDefaults,{id:meshId,geometryId:geometryId,textureSetId:_textureSetId3,matrix:meshMatrix,color:meshColor,metallic:meshMetallic,roughness:meshRoughness,opacity:meshOpacity,origin:tileCenter}));meshIds.push(meshId);}}}else{// Do not reuse geometry
|
|
31073
31075
|
var _primitiveType6=eachGeometryPrimitiveType[_geometryIndex6];var _axisLabel=eachGeometryAxisLabel[_geometryIndex6];var primitiveName=void 0;var _geometryPositions6=void 0;var geometryNormals=void 0;var geometryUVs=void 0;var geometryColors=void 0;var geometryIndices=void 0;var geometryEdgeIndices=void 0;var _geometryValid5=false;var _ifcLabel=void 0;switch(_primitiveType6){case 0:primitiveName="solid";_geometryPositions6=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryNormals=normals.subarray(eachGeometryNormalsPortion[_geometryIndex6],atLastGeometry?normals.length:eachGeometryNormalsPortion[_geometryIndex6+1]);geometryUVs=uvs.subarray(eachGeometryUVsPortion[_geometryIndex6],atLastGeometry?uvs.length:eachGeometryUVsPortion[_geometryIndex6+1]);geometryIndices=indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]);geometryEdgeIndices=edgeIndices.subarray(eachGeometryEdgeIndicesPortion[_geometryIndex6],atLastGeometry?edgeIndices.length:eachGeometryEdgeIndicesPortion[_geometryIndex6+1]);_geometryValid5=_geometryPositions6.length>0&&geometryIndices.length>0;break;case 1:primitiveName="surface";_geometryPositions6=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryNormals=normals.subarray(eachGeometryNormalsPortion[_geometryIndex6],atLastGeometry?normals.length:eachGeometryNormalsPortion[_geometryIndex6+1]);geometryUVs=uvs.subarray(eachGeometryUVsPortion[_geometryIndex6],atLastGeometry?uvs.length:eachGeometryUVsPortion[_geometryIndex6+1]);geometryIndices=indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]);geometryEdgeIndices=edgeIndices.subarray(eachGeometryEdgeIndicesPortion[_geometryIndex6],atLastGeometry?edgeIndices.length:eachGeometryEdgeIndicesPortion[_geometryIndex6+1]);_geometryValid5=_geometryPositions6.length>0&&geometryIndices.length>0;break;case 2:primitiveName="points";_geometryPositions6=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryColors=colors.subarray(eachGeometryColorsPortion[_geometryIndex6],atLastGeometry?colors.length:eachGeometryColorsPortion[_geometryIndex6+1]);_geometryValid5=_geometryPositions6.length>0;break;case 3:primitiveName="lines";_geometryPositions6=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryIndices=indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]);_geometryValid5=_geometryPositions6.length>0&&geometryIndices.length>0;break;case 4:primitiveName="lines";_geometryPositions6=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);geometryIndices=lineStripToLines(_geometryPositions6,indices.subarray(eachGeometryIndicesPortion[_geometryIndex6],atLastGeometry?indices.length:eachGeometryIndicesPortion[_geometryIndex6+1]));_geometryValid5=_geometryPositions6.length>0&&geometryIndices.length>0;break;//Ifc Labels
|
|
31074
31076
|
case 7:primitiveName="lines";_geometryPositions6=positions.subarray(eachGeometryPositionsPortion[_geometryIndex6],atLastGeometry?positions.length:eachGeometryPositionsPortion[_geometryIndex6+1]);_geometryPositions6=geometryCompressionUtils.decompressPositions(_geometryPositions6,tileDecodeMatrix);_ifcLabel=buildVectorTextGeometry({origin:_geometryPositions6,text:_axisLabel,size:2});_geometryPositions6=_ifcLabel.positions;geometryIndices=_ifcLabel.indices;_geometryValid5=_geometryPositions6.length>0&&geometryIndices.length>0;break;default:continue;}if(_geometryValid5){var meshCfg=utils.apply(meshDefaults,{id:meshId,textureSetId:_textureSetId3,origin:tileCenter,primitive:primitiveName,normalsCompressed:geometryNormals,uv:geometryUVs&&geometryUVs.length>0?geometryUVs:null,colorsCompressed:geometryColors,indices:geometryIndices,edgeIndices:geometryEdgeIndices,color:meshColor,metallic:meshMetallic,roughness:meshRoughness,opacity:meshOpacity});if(_primitiveType6!==7){meshCfg=_objectSpread(_objectSpread({},meshCfg),{},{positionsCompressed:_geometryPositions6,positionsDecodeMatrix:tileDecodeMatrix});}else{meshCfg=_objectSpread(_objectSpread({},meshCfg),{},{positions:_geometryPositions6});}sceneModel.createMesh(meshCfg);meshIds.push(meshId);}}}if(meshIds.length>0){sceneModel.createEntity(utils.apply(entityDefaults,{id:entityId,isObject:true,meshIds:meshIds}));}}}}function lineStripToLines(positions,indices){var linesIndices=[];if(indices.length>1){for(var _i642=0,len=indices.length-1;_i642<len;_i642++){linesIndices.push(indices[_i642]);linesIndices.push(indices[_i642+1]);}}else if(positions.length>1){for(var _i643=0,_len120=positions.length/3-1;_i643<_len120;_i643++){linesIndices.push(_i643);linesIndices.push(_i643+1);}}return linesIndices;}/** @private */ // V11 uses a single uncompressed Uint8Array buffer to store arrays of different types.
|
|
31075
31077
|
// To efficiently create typed arrays from this buffer,
|