diff --git a/assets/models/xkt/v10/ifc/IfcOpenHouse2x3.ifc.v10.xkt b/assets/models/xkt/v10/ifc/IfcOpenHouse2x3.ifc.v10.xkt new file mode 100644 index 0000000000..6f343b5a6a Binary files /dev/null and b/assets/models/xkt/v10/ifc/IfcOpenHouse2x3.ifc.v10.xkt differ diff --git a/assets/models/xkt/v10/ifc/rac_advanced_sample_project.ifc.v10.xkt b/assets/models/xkt/v10/ifc/rac_advanced_sample_project.ifc.v10.xkt new file mode 100644 index 0000000000..8cae870df9 Binary files /dev/null and b/assets/models/xkt/v10/ifc/rac_advanced_sample_project.ifc.v10.xkt differ diff --git a/assets/models/xkt/v10/laz/autzen.laz.v10.xkt b/assets/models/xkt/v10/laz/autzen.laz.v10.xkt new file mode 100644 index 0000000000..7d553c6c28 Binary files /dev/null and b/assets/models/xkt/v10/laz/autzen.laz.v10.xkt differ diff --git a/assets/models/xkt/v11/ifc/IfcOpenHouse2x3.ifc.v11.xkt b/assets/models/xkt/v11/ifc/IfcOpenHouse2x3.ifc.v11.xkt new file mode 100644 index 0000000000..ddc0e1cd15 Binary files /dev/null and b/assets/models/xkt/v11/ifc/IfcOpenHouse2x3.ifc.v11.xkt differ diff --git a/assets/models/xkt/v11/ifc/IfcOpenHouse2x3.ifc.v11.xkt.txt b/assets/models/xkt/v11/ifc/IfcOpenHouse2x3.ifc.v11.xkt.txt new file mode 100644 index 0000000000..ddc0e1cd15 Binary files /dev/null and b/assets/models/xkt/v11/ifc/IfcOpenHouse2x3.ifc.v11.xkt.txt differ diff --git a/assets/models/xkt/v11/ifc/rac_advanced_sample_project.ifc.v11.xkt b/assets/models/xkt/v11/ifc/rac_advanced_sample_project.ifc.v11.xkt new file mode 100644 index 0000000000..1191cd7a33 Binary files /dev/null and b/assets/models/xkt/v11/ifc/rac_advanced_sample_project.ifc.v11.xkt differ diff --git a/assets/models/xkt/v11/ifc/rac_advanced_sample_project.ifc.v11.xkt.txt b/assets/models/xkt/v11/ifc/rac_advanced_sample_project.ifc.v11.xkt.txt new file mode 100644 index 0000000000..1191cd7a33 Binary files /dev/null and b/assets/models/xkt/v11/ifc/rac_advanced_sample_project.ifc.v11.xkt.txt differ diff --git a/assets/models/xkt/v11/laz/autzen.laz.v11.xkt b/assets/models/xkt/v11/laz/autzen.laz.v11.xkt new file mode 100644 index 0000000000..0b75507774 Binary files /dev/null and b/assets/models/xkt/v11/laz/autzen.laz.v11.xkt differ diff --git a/assets/models/xkt/v11/laz/autzen.laz.v11.xkt.txt b/assets/models/xkt/v11/laz/autzen.laz.v11.xkt.txt new file mode 100644 index 0000000000..0b75507774 Binary files /dev/null and b/assets/models/xkt/v11/laz/autzen.laz.v11.xkt.txt differ diff --git a/dist/xeokit-sdk.cjs.js b/dist/xeokit-sdk.cjs.js index 6c75fdfa1d..647b42f1a2 100644 --- a/dist/xeokit-sdk.cjs.js +++ b/dist/xeokit-sdk.cjs.js @@ -10687,8 +10687,8 @@ class SceneModelEntity { } } -const tempVec4a$a = math.vec4(); -const tempVec4b$6 = math.vec4(); +const tempVec4a$b = math.vec4(); +const tempVec4b$7 = math.vec4(); /** @@ -10847,12 +10847,12 @@ class Marker extends Component { this.fire("viewPos", this._viewPos); } if (this._canvasPosDirty) { - tempVec4a$a.set(this._viewPos); - tempVec4a$a[3] = 1.0; - math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$a, tempVec4b$6); + tempVec4a$b.set(this._viewPos); + tempVec4a$b[3] = 1.0; + math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$b, tempVec4b$7); const aabb = this.scene.canvas.boundary; - this._canvasPos[0] = Math.floor((1 + tempVec4b$6[0] / tempVec4b$6[3]) * aabb[2] / 2); - this._canvasPos[1] = Math.floor((1 - tempVec4b$6[1] / tempVec4b$6[3]) * aabb[3] / 2); + this._canvasPos[0] = Math.floor((1 + tempVec4b$7[0] / tempVec4b$7[3]) * aabb[2] / 2); + this._canvasPos[1] = Math.floor((1 - tempVec4b$7[1] / tempVec4b$7[3]) * aabb[3] / 2); this._canvasPosDirty = false; this.fire("canvasPos", this._canvasPos); } @@ -11183,7 +11183,7 @@ function activateDraggableDot(dot, cfg) { const onChange = event => { const canvasPos = math.vec2([ event.clientX, event.clientY ]); - transformToNode(canvas.ownerDocument.body, canvas, canvasPos); + transformToNode(canvas.ownerDocument.documentElement, canvas, canvasPos); onMove(canvasPos, pickWorldPos(canvasPos)); }; @@ -23520,8 +23520,8 @@ const tempVec3c$u = math.vec3(); const tempVec3d$d = math.vec3(); const tempVec3e$2 = math.vec3(); const tempVec3f$2 = math.vec3(); -const tempVec4a$9 = math.vec4(); -const tempVec4b$5 = math.vec4(); +const tempVec4a$a = math.vec4(); +const tempVec4b$6 = math.vec4(); const tempVec4c$2 = math.vec4(); const tempMat = math.mat4(); const tempMatb = math.mat4(); @@ -24386,8 +24386,8 @@ class Camera extends Component { * @returns {[number, number]} the canvas position */ projectWorldPos(worldPos) { - const _worldPos = tempVec4a$9; - const viewPos = tempVec4b$5; + const _worldPos = tempVec4a$a; + const viewPos = tempVec4b$6; const screenPos = tempVec4c$2; _worldPos[0] = worldPos[0]; _worldPos[1] = worldPos[1]; @@ -56194,7 +56194,7 @@ function octDecodeVec2(oct) { // Decode an oct-encoded normal const tempMat4$1 = math.mat4(); const tempMat4b = math.mat4(); -const tempVec4a$8 = math.vec4([0, 0, 0, 1]); +const tempVec4a$9 = math.vec4([0, 0, 0, 1]); const tempVec3a$z = math.vec3(); const tempVec3b$v = math.vec3(); @@ -57003,7 +57003,7 @@ class VBOBatchingTrianglesLayer { const offsetX = origin[0] ; const offsetY = origin[1] ; const offsetZ = origin[2] ; - const worldPos = tempVec4a$8; + const worldPos = tempVec4a$9; const sceneModelMatrix = this.model.matrix; const positionsDecodeMatrix = state.positionsDecodeMatrix; for (let i = 0, len = positions.length; i < len; i += 3) { @@ -61366,7 +61366,7 @@ function getRenderers$6(scene) { const tempUint8Vec4$2 = new Uint8Array(4); const tempFloat32$2 = new Float32Array(1); -const tempVec4a$7 = math.vec4([0, 0, 0, 1]); +const tempVec4a$8 = math.vec4([0, 0, 0, 1]); const tempVec3fa$2 = new Float32Array(3); const tempVec3a$w = math.vec3(); @@ -62070,7 +62070,7 @@ class VBOInstancingTrianglesLayer { const offsetX = origin[0]; const offsetY = origin[1]; const offsetZ = origin[2]; - const worldPos = tempVec4a$7; + const worldPos = tempVec4a$8; const portionMatrix = portion.matrix; const sceneModelMatrix = this.model.matrix; const positionsDecodeMatrix = state.positionsDecodeMatrix; @@ -72776,7 +72776,7 @@ const tempVec3b$i = math.vec3(); const tempVec3c$e = math.vec3(); math.vec3(); -const tempVec4a$6 = math.vec4(); +const tempVec4a$7 = math.vec4(); const tempMat4a$c = math.mat4(); @@ -73055,11 +73055,11 @@ class DTXTrianglesColorRenderer { if (saoEnabled) { const viewportWidth = gl.drawingBufferWidth; const viewportHeight = gl.drawingBufferHeight; - tempVec4a$6[0] = viewportWidth; - tempVec4a$6[1] = viewportHeight; - tempVec4a$6[2] = sao.blendCutoff; - tempVec4a$6[3] = sao.blendFactor; - gl.uniform4fv(this._uSAOParams, tempVec4a$6); + tempVec4a$7[0] = viewportWidth; + tempVec4a$7[1] = viewportHeight; + tempVec4a$7[2] = sao.blendCutoff; + tempVec4a$7[3] = sao.blendFactor; + gl.uniform4fv(this._uSAOParams, tempVec4a$7); this._program.bindTexture(this._uOcclusionTexture, frameCtx.occlusionTexture, 10); } } @@ -74718,6 +74718,12 @@ class DTXTrianglesPickMeshRenderer { const textureState = state.textureState; const origin = dataTextureLayer._state.origin; const {position, rotationMatrix, rotationMatrixConjugate} = model; + + const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix; + const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix; + const eye = frameCtx.pickOrigin || camera.eye; + const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far; + textureState.bindCommonTextures( this._program, this.uTexturePerObjectPositionsDecodeMatrix, @@ -74744,24 +74750,24 @@ class DTXTrianglesPickMeshRenderer { rtcOrigin[0] += position[0]; rtcOrigin[1] += position[1]; rtcOrigin[2] += position[2]; - rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a$8); + rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$8); rtcCameraEye = tempVec3c$c; - rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0]; - rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1]; - rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2]; + rtcCameraEye[0] = eye[0] - rtcOrigin[0]; + rtcCameraEye[1] = eye[1] - rtcOrigin[1]; + rtcCameraEye[2] = eye[2] - rtcOrigin[2]; } else { - rtcViewMatrix = camera.viewMatrix; - rtcCameraEye = camera.eye; + rtcViewMatrix = viewMatrix; + rtcCameraEye = eye; } gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos); gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight); gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate); gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix); - gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix); + gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix); gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye); gl.uniform1i(this._uRenderPass, renderPass); if (scene.logarithmicDepthBufferEnabled) { - const logDepthBufFC = 2.0 / (Math.log(camera.project.far + 1.0) / Math.LN2); // TODO: Far from pick project matrix? + const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2); gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC); } const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); @@ -75138,7 +75144,11 @@ class DTXTrianglesPickDepthRenderer { const textureState = state.textureState; const origin = dataTextureLayer._state.origin; const {position, rotationMatrix, rotationMatrixConjugate} = model; + const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix; + const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix; + const eye = frameCtx.pickOrigin || camera.eye; + const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far; if (!this._program) { this._allocate(); @@ -75178,15 +75188,15 @@ class DTXTrianglesPickDepthRenderer { rtcOrigin[2] += position[2]; rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$7); rtcCameraEye = tempVec3c$b; - rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0]; - rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1]; - rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2]; + rtcCameraEye[0] = eye[0] - rtcOrigin[0]; + rtcCameraEye[1] = eye[1] - rtcOrigin[1]; + rtcCameraEye[2] = 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; + rtcCameraEye = eye; frameCtx.snapPickOrigin[0] = 0; frameCtx.snapPickOrigin[1] = 0; frameCtx.snapPickOrigin[2] = 0; @@ -75201,9 +75211,9 @@ class DTXTrianglesPickDepthRenderer { gl.uniform1f(this._uPickZFar, frameCtx.pickZFar); gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate); gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix); - gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix); + gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix); if (scene.logarithmicDepthBufferEnabled) { - const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2); // TODO: Far from pick project matrix? + const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2); gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC); } @@ -77713,6 +77723,11 @@ class DTXTrianglesPickNormalsFlatRenderer { this._bindProgram(frameCtx, state); } + const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix; + const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix; + const eye = frameCtx.pickOrigin || camera.eye; + const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far; + textureState.bindCommonTextures( this._program, this.uTexturePerObjectPositionsDecodeMatrix, @@ -77741,24 +77756,24 @@ class DTXTrianglesPickNormalsFlatRenderer { rtcOrigin[0] += position[0]; rtcOrigin[1] += position[1]; rtcOrigin[2] += position[2]; - rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a$1); + rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$1); rtcCameraEye = tempVec3c$5; - rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0]; - rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1]; - rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2]; + rtcCameraEye[0] = eye[0] - rtcOrigin[0]; + rtcCameraEye[1] = eye[1] - rtcOrigin[1]; + rtcCameraEye[2] = eye[2] - rtcOrigin[2]; } else { - rtcViewMatrix = camera.viewMatrix; // TODO: make pickMatrix - rtcCameraEye = camera.eye; + rtcViewMatrix = viewMatrix; + rtcCameraEye = eye; } gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos); gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight); gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate); gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix); - gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix); // TODO: pickProjMatrix + gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix); gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye); gl.uniform1i(this._uRenderPass, renderPass); if (scene.logarithmicDepthBufferEnabled) { - const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2); + const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2); gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC); } const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); @@ -79302,7 +79317,7 @@ const INDICES_EDGE_INDICES_ALIGNEMENT_SIZE = 8; */ const MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE = 10; -const tempVec4a$5 = math.vec4(); +const tempVec4a$6 = math.vec4(); const tempMat4a = new Float32Array(16); const tempUint8Array4 = new Uint8Array(4); const tempFloat32Array3 = new Float32Array(3); @@ -80379,7 +80394,7 @@ class DTXTrianglesLayer { const offsetX = origin[0] ; const offsetY = origin[1] ; const offsetZ = origin[2] ; - const worldPos = tempVec4a$5; + const worldPos = tempVec4a$6; for (let i = 0, len = positions.length; i < len; i += 3) { worldPos[0] = positions[i]; worldPos[1] = positions[i + 1]; @@ -96493,8 +96508,8 @@ const tempVec3a$7 = math.vec3(); const tempVec3b$4 = math.vec3(); const tempVec3c$3 = math.vec3(); -const tempVec4a$4 = math.vec4(); -const tempVec4b$4 = math.vec4(); +const tempVec4a$5 = math.vec4(); +const tempVec4b$5 = math.vec4(); const tempVec4c$1 = math.vec4(); /** @@ -96533,7 +96548,7 @@ class PanController { camera.ortho.scale = camera.ortho.scale - dollyDelta; - const unprojectedWorldPos = this._unproject(targetCanvasPos, tempVec4a$4); + const unprojectedWorldPos = this._unproject(targetCanvasPos, tempVec4a$5); const offset = math.subVec3(unprojectedWorldPos, camera.eye, tempVec4c$1); const moveVec = math.mulVec3Scalar(math.normalizeVec3(offset), -dollyDelta, []); @@ -96560,12 +96575,12 @@ class PanController { // - get the vector in which we're dollying; // - add both vectors to camera eye and look. - const worldPos1 = this._unproject(targetCanvasPos, tempVec4a$4); + const worldPos1 = this._unproject(targetCanvasPos, tempVec4a$5); camera.ortho.scale = camera.ortho.scale - dollyDelta; camera.ortho._update(); // HACK - const worldPos2 = this._unproject(targetCanvasPos, tempVec4b$4); + const worldPos2 = this._unproject(targetCanvasPos, tempVec4b$5); const offset = math.subVec3(worldPos2, worldPos1, tempVec4c$1); const eyeLookMoveVec = math.mulVec3Scalar(math.normalizeVec3(math.subVec3(camera.look, camera.eye, tempVec3a$7)), -dollyDelta, tempVec3b$4); const moveVec = math.addVec3(offset, eyeLookMoveVec, tempVec3c$3); @@ -96599,8 +96614,8 @@ const tempVec3a$6 = math.vec3(); const tempVec3b$3 = math.vec3(); const tempVec3c$2 = math.vec3(); -const tempVec4a$3 = math.vec4(); -const tempVec4b$3 = math.vec4(); +const tempVec4a$4 = math.vec4(); +const tempVec4b$4 = math.vec4(); const tempVec4c = math.vec4(); @@ -96853,8 +96868,8 @@ class PivotController { const Pt4 = transposedProjectMat.subarray(12); const D = [0, 0, -1.0, 1]; const screenZ = math.dotVec4(D, Pt3) / math.dotVec4(D, Pt4); - const worldPos = tempVec4a$3; - camera.project.unproject(canvasPos, screenZ, tempVec4b$3, tempVec4c, worldPos); + const worldPos = tempVec4a$4; + camera.project.unproject(canvasPos, screenZ, tempVec4b$4, tempVec4c, worldPos); const eyeWorldPosVec = math.normalizeVec3(math.subVec3(worldPos, camera.eye, tempVec3a$6)); const posOnSphere = math.addVec3(camera.eye, math.mulVec3Scalar(eyeWorldPosVec, pivotShereRadius, tempVec3b$3), tempVec3c$2); this.setPivotPos(posOnSphere); @@ -128132,7 +128147,7 @@ if (!pako$9.inflate) { // See https://github.com/nodeca/pako/issues/97 pako$9 = pako$9.default; } -const decompressColor$9 = (function () { +const decompressColor$a = (function () { const color2 = new Float32Array(3); return function (color) { color2[0] = color[0] / 255.0; @@ -128176,7 +128191,7 @@ function inflate$9(deflatedData) { }; } -function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$a(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { manifestCtx.getNextId(); @@ -128245,7 +128260,7 @@ function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const lastMesh = (j === (numMeshes - 1)); const meshId = entityId + ".mesh." + j; - const color = decompressColor$9(meshColors.subarray((j * 4), (j * 4) + 3)); + const color = decompressColor$a(meshColors.subarray((j * 4), (j * 4) + 3)); const opacity = meshColors[(j * 4) + 3] / 255.0; sceneModel.createMesh(utils.apply(meshDefaults, { @@ -128277,7 +128292,7 @@ const ParserV1 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$9(elements); const inflatedData = inflate$9(deflatedData); - load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$a(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -128345,6 +128360,222 @@ function inflate$8(deflatedData) { }; } +const decompressColor$9 = (function () { + const color2 = new Float32Array(3); + return function (color) { + color2[0] = color[0] / 255.0; + color2[1] = color[1] / 255.0; + color2[2] = color[2] / 255.0; + return color2; + }; +})(); + +function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { + + const modelPartId = manifestCtx.getNextId(); + + sceneModel.positionsCompression = "precompressed"; + sceneModel.normalsCompression = "precompressed"; + + const positions = inflatedData.positions; + const normals = inflatedData.normals; + const indices = inflatedData.indices; + const edgeIndices = inflatedData.edgeIndices; + const meshPositions = inflatedData.meshPositions; + const meshIndices = inflatedData.meshIndices; + const meshEdgesIndices = inflatedData.meshEdgesIndices; + const meshColors = inflatedData.meshColors; + const entityIDs = JSON.parse(inflatedData.entityIDs); + const entityMeshes = inflatedData.entityMeshes; + const entityIsObjects = inflatedData.entityIsObjects; + const entityMeshIds = inflatedData.entityMeshIds; + const entityMatrices = inflatedData.entityMatrices; + const entityUsesInstancing = inflatedData.entityUsesInstancing; + + const numMeshes = meshPositions.length; + const numEntities = entityMeshes.length; + + const alreadyCreatedGeometries = {}; + + for (let i = 0; i < numEntities; i++) { + + const xktEntityId = entityIDs [i]; + const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId; + const metaObject = viewer.metaScene.metaObjects[entityId]; + const entityDefaults = {}; + const meshDefaults = {}; + const entityMatrix = entityMatrices.subarray((i * 16), (i * 16) + 16); + + if (metaObject) { + if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) { + continue; + } + if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) { + continue; + } + const 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; + } + } + } else { + if (options.excludeUnclassifiedObjects) { + continue; + } + } + + const lastEntity = (i === numEntities - 1); + + const meshIds = []; + + for (let j = entityMeshes [i], jlen = lastEntity ? entityMeshIds.length : entityMeshes [i + 1]; j < jlen; j++) { + + const jj = entityMeshIds [j]; + + const lastMesh = (jj === (numMeshes - 1)); + const meshId = manifestCtx.getNextId(); + + const color = decompressColor$9(meshColors.subarray((jj * 4), (jj * 4) + 3)); + const opacity = meshColors[(jj * 4) + 3] / 255.0; + + const tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); + const tmpNormals = normals.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); + const tmpIndices = indices.subarray(meshIndices [jj], lastMesh ? indices.length : meshIndices [jj + 1]); + const tmpEdgeIndices = edgeIndices.subarray(meshEdgesIndices [jj], lastMesh ? edgeIndices.length : meshEdgesIndices [jj + 1]); + + if (entityUsesInstancing [i] === 1) { + + const geometryId = `${modelPartId}.geometry.${meshId}.${jj}`; + + if (!(geometryId in alreadyCreatedGeometries)) { + + sceneModel.createGeometry({ + id: geometryId, + positionsCompressed: tmpPositions, + normalsCompressed: tmpNormals, + indices: tmpIndices, + edgeIndices: tmpEdgeIndices, + primitive: "triangles", + positionsDecodeMatrix: inflatedData.positionsDecodeMatrix, + }); + + alreadyCreatedGeometries [geometryId] = true; + } + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + color: color, + opacity: opacity, + matrix: entityMatrix, + geometryId, + })); + + meshIds.push(meshId); + + } else { + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + primitive: "triangles", + positionsCompressed: tmpPositions, + normalsCompressed: tmpNormals, + indices: tmpIndices, + edgeIndices: tmpEdgeIndices, + positionsDecodeMatrix: inflatedData.positionsDecodeMatrix, + color: color, + opacity: opacity + })); + + meshIds.push(meshId); + } + } + + if (meshIds.length) { + + sceneModel.createEntity(utils.apply(entityDefaults, { + id: entityId, + isObject: (entityIsObjects [i] === 1), + meshIds: meshIds + })); + } + } +} + +/** @private */ +const ParserV2 = { + version: 2, + parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { + const deflatedData = extract$8(elements); + const inflatedData = inflate$8(deflatedData); + load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + } +}; + +/* + +Parser for .XKT Format V3 + +.XKT specifications: https://github.com/xeokit/xeokit-sdk/wiki/XKT-Format + + */ + +let pako$7 = window.pako || p; +if (!pako$7.inflate) { // See https://github.com/nodeca/pako/issues/97 + pako$7 = pako$7.default; +} + +function extract$7(elements) { + return { + positions: elements[0], + normals: elements[1], + indices: elements[2], + edgeIndices: elements[3], + meshPositions: elements[4], + meshIndices: elements[5], + meshEdgesIndices: elements[6], + meshColors: elements[7], + entityIDs: elements[8], + entityMeshes: elements[9], + entityIsObjects: elements[10], + instancedPositionsDecodeMatrix: elements[11], + batchedPositionsDecodeMatrix: elements[12], + entityMeshIds: elements[13], + entityMatrices: elements[14], + entityUsesInstancing: elements[15] + }; +} + +function inflate$7(deflatedData) { + return { + positions: new Uint16Array(pako$7.inflate(deflatedData.positions).buffer), + normals: new Int8Array(pako$7.inflate(deflatedData.normals).buffer), + indices: new Uint32Array(pako$7.inflate(deflatedData.indices).buffer), + edgeIndices: new Uint32Array(pako$7.inflate(deflatedData.edgeIndices).buffer), + meshPositions: new Uint32Array(pako$7.inflate(deflatedData.meshPositions).buffer), + meshIndices: new Uint32Array(pako$7.inflate(deflatedData.meshIndices).buffer), + meshEdgesIndices: new Uint32Array(pako$7.inflate(deflatedData.meshEdgesIndices).buffer), + meshColors: new Uint8Array(pako$7.inflate(deflatedData.meshColors).buffer), + entityIDs: pako$7.inflate(deflatedData.entityIDs, {to: 'string'}), + entityMeshes: new Uint32Array(pako$7.inflate(deflatedData.entityMeshes).buffer), + entityIsObjects: new Uint8Array(pako$7.inflate(deflatedData.entityIsObjects).buffer), + instancedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.instancedPositionsDecodeMatrix).buffer), + batchedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.batchedPositionsDecodeMatrix).buffer), + entityMeshIds: new Uint32Array(pako$7.inflate(deflatedData.entityMeshIds).buffer), + entityMatrices: new Float32Array(pako$7.inflate(deflatedData.entityMatrices).buffer), + entityUsesInstancing: new Uint8Array(pako$7.inflate(deflatedData.entityUsesInstancing).buffer) + }; +} + const decompressColor$8 = (function () { const color2 = new Float32Array(3); return function (color) { @@ -128380,222 +128611,6 @@ function load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const numMeshes = meshPositions.length; const numEntities = entityMeshes.length; - const alreadyCreatedGeometries = {}; - - for (let i = 0; i < numEntities; i++) { - - const xktEntityId = entityIDs [i]; - const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId; - const metaObject = viewer.metaScene.metaObjects[entityId]; - const entityDefaults = {}; - const meshDefaults = {}; - const entityMatrix = entityMatrices.subarray((i * 16), (i * 16) + 16); - - if (metaObject) { - if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) { - continue; - } - if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) { - continue; - } - const 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; - } - } - } else { - if (options.excludeUnclassifiedObjects) { - continue; - } - } - - const lastEntity = (i === numEntities - 1); - - const meshIds = []; - - for (let j = entityMeshes [i], jlen = lastEntity ? entityMeshIds.length : entityMeshes [i + 1]; j < jlen; j++) { - - const jj = entityMeshIds [j]; - - const lastMesh = (jj === (numMeshes - 1)); - const meshId = manifestCtx.getNextId(); - - const color = decompressColor$8(meshColors.subarray((jj * 4), (jj * 4) + 3)); - const opacity = meshColors[(jj * 4) + 3] / 255.0; - - const tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); - const tmpNormals = normals.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); - const tmpIndices = indices.subarray(meshIndices [jj], lastMesh ? indices.length : meshIndices [jj + 1]); - const tmpEdgeIndices = edgeIndices.subarray(meshEdgesIndices [jj], lastMesh ? edgeIndices.length : meshEdgesIndices [jj + 1]); - - if (entityUsesInstancing [i] === 1) { - - const geometryId = `${modelPartId}.geometry.${meshId}.${jj}`; - - if (!(geometryId in alreadyCreatedGeometries)) { - - sceneModel.createGeometry({ - id: geometryId, - positionsCompressed: tmpPositions, - normalsCompressed: tmpNormals, - indices: tmpIndices, - edgeIndices: tmpEdgeIndices, - primitive: "triangles", - positionsDecodeMatrix: inflatedData.positionsDecodeMatrix, - }); - - alreadyCreatedGeometries [geometryId] = true; - } - - sceneModel.createMesh(utils.apply(meshDefaults, { - id: meshId, - color: color, - opacity: opacity, - matrix: entityMatrix, - geometryId, - })); - - meshIds.push(meshId); - - } else { - - sceneModel.createMesh(utils.apply(meshDefaults, { - id: meshId, - primitive: "triangles", - positionsCompressed: tmpPositions, - normalsCompressed: tmpNormals, - indices: tmpIndices, - edgeIndices: tmpEdgeIndices, - positionsDecodeMatrix: inflatedData.positionsDecodeMatrix, - color: color, - opacity: opacity - })); - - meshIds.push(meshId); - } - } - - if (meshIds.length) { - - sceneModel.createEntity(utils.apply(entityDefaults, { - id: entityId, - isObject: (entityIsObjects [i] === 1), - meshIds: meshIds - })); - } - } -} - -/** @private */ -const ParserV2 = { - version: 2, - parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { - const deflatedData = extract$8(elements); - const inflatedData = inflate$8(deflatedData); - load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); - } -}; - -/* - -Parser for .XKT Format V3 - -.XKT specifications: https://github.com/xeokit/xeokit-sdk/wiki/XKT-Format - - */ - -let pako$7 = window.pako || p; -if (!pako$7.inflate) { // See https://github.com/nodeca/pako/issues/97 - pako$7 = pako$7.default; -} - -function extract$7(elements) { - return { - positions: elements[0], - normals: elements[1], - indices: elements[2], - edgeIndices: elements[3], - meshPositions: elements[4], - meshIndices: elements[5], - meshEdgesIndices: elements[6], - meshColors: elements[7], - entityIDs: elements[8], - entityMeshes: elements[9], - entityIsObjects: elements[10], - instancedPositionsDecodeMatrix: elements[11], - batchedPositionsDecodeMatrix: elements[12], - entityMeshIds: elements[13], - entityMatrices: elements[14], - entityUsesInstancing: elements[15] - }; -} - -function inflate$7(deflatedData) { - return { - positions: new Uint16Array(pako$7.inflate(deflatedData.positions).buffer), - normals: new Int8Array(pako$7.inflate(deflatedData.normals).buffer), - indices: new Uint32Array(pako$7.inflate(deflatedData.indices).buffer), - edgeIndices: new Uint32Array(pako$7.inflate(deflatedData.edgeIndices).buffer), - meshPositions: new Uint32Array(pako$7.inflate(deflatedData.meshPositions).buffer), - meshIndices: new Uint32Array(pako$7.inflate(deflatedData.meshIndices).buffer), - meshEdgesIndices: new Uint32Array(pako$7.inflate(deflatedData.meshEdgesIndices).buffer), - meshColors: new Uint8Array(pako$7.inflate(deflatedData.meshColors).buffer), - entityIDs: pako$7.inflate(deflatedData.entityIDs, {to: 'string'}), - entityMeshes: new Uint32Array(pako$7.inflate(deflatedData.entityMeshes).buffer), - entityIsObjects: new Uint8Array(pako$7.inflate(deflatedData.entityIsObjects).buffer), - instancedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.instancedPositionsDecodeMatrix).buffer), - batchedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.batchedPositionsDecodeMatrix).buffer), - entityMeshIds: new Uint32Array(pako$7.inflate(deflatedData.entityMeshIds).buffer), - entityMatrices: new Float32Array(pako$7.inflate(deflatedData.entityMatrices).buffer), - entityUsesInstancing: new Uint8Array(pako$7.inflate(deflatedData.entityUsesInstancing).buffer) - }; -} - -const decompressColor$7 = (function () { - const color2 = new Float32Array(3); - return function (color) { - color2[0] = color[0] / 255.0; - color2[1] = color[1] / 255.0; - color2[2] = color[2] / 255.0; - return color2; - }; -})(); - -function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { - - const modelPartId = manifestCtx.getNextId(); - - sceneModel.positionsCompression = "precompressed"; - sceneModel.normalsCompression = "precompressed"; - - const positions = inflatedData.positions; - const normals = inflatedData.normals; - const indices = inflatedData.indices; - const edgeIndices = inflatedData.edgeIndices; - const meshPositions = inflatedData.meshPositions; - const meshIndices = inflatedData.meshIndices; - const meshEdgesIndices = inflatedData.meshEdgesIndices; - const meshColors = inflatedData.meshColors; - const entityIDs = JSON.parse(inflatedData.entityIDs); - const entityMeshes = inflatedData.entityMeshes; - const entityIsObjects = inflatedData.entityIsObjects; - const entityMeshIds = inflatedData.entityMeshIds; - const entityMatrices = inflatedData.entityMatrices; - const entityUsesInstancing = inflatedData.entityUsesInstancing; - - const numMeshes = meshPositions.length; - const numEntities = entityMeshes.length; - const _alreadyCreatedGeometries = {}; for (let i = 0; i < numEntities; i++) { @@ -128649,7 +128664,7 @@ function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const lastMesh = (jj === (numMeshes - 1)); const meshId = `${modelPartId}.${entityId}.mesh.${jj}`; - const color = decompressColor$7(meshColors.subarray((jj * 4), (jj * 4) + 3)); + const color = decompressColor$8(meshColors.subarray((jj * 4), (jj * 4) + 3)); const opacity = meshColors[(jj * 4) + 3] / 255.0; var tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); @@ -128720,7 +128735,7 @@ const ParserV3 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$7(elements); const inflatedData = inflate$7(deflatedData); - load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -128778,7 +128793,7 @@ function inflate$6(deflatedData) { }; } -const decompressColor$6 = (function () { +const decompressColor$7 = (function () { const color2 = new Float32Array(3); return function (color) { color2[0] = color[0] / 255.0; @@ -128788,7 +128803,7 @@ const decompressColor$6 = (function () { }; })(); -function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -128884,7 +128899,7 @@ function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const primitiveInstanceCount = primitiveInstanceCounts[orderedPrimitiveIndex]; const isInstancedPrimitive = (primitiveInstanceCount > 1); - const color = decompressColor$6(eachPrimitiveColor.subarray((orderedPrimitiveIndex * 4), (orderedPrimitiveIndex * 4) + 3)); + const color = decompressColor$7(eachPrimitiveColor.subarray((orderedPrimitiveIndex * 4), (orderedPrimitiveIndex * 4) + 3)); const opacity = eachPrimitiveColor[(orderedPrimitiveIndex * 4) + 3] / 255.0; const primitivePositions = positions.subarray(eachPrimitivePositionsAndNormalsPortion [orderedPrimitiveIndex], atLastPrimitive ? positions.length : eachPrimitivePositionsAndNormalsPortion [orderedPrimitiveIndex + 1]); @@ -128994,7 +129009,7 @@ const ParserV4 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$6(elements); const inflatedData = inflate$6(deflatedData); - load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -129047,7 +129062,7 @@ function inflate$5(deflatedData) { }; } -const decompressColor$5 = (function () { +const decompressColor$6 = (function () { const color2 = new Float32Array(3); return function (color) { color2[0] = color[0] / 255.0; @@ -129057,7 +129072,7 @@ const decompressColor$5 = (function () { }; })(); -function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -129126,7 +129141,7 @@ function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const primitiveInstanceCount = primitiveInstanceCounts[primitiveIndex]; const isInstancedPrimitive = (primitiveInstanceCount > 1); - const color = decompressColor$5(eachPrimitiveColor.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3)); + const color = decompressColor$6(eachPrimitiveColor.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3)); const opacity = eachPrimitiveColor[(primitiveIndex * 4) + 3] / 255.0; const primitivePositions = positions.subarray(eachPrimitivePositionsAndNormalsPortion [primitiveIndex], atLastPrimitive ? positions.length : eachPrimitivePositionsAndNormalsPortion [primitiveIndex + 1]); @@ -129232,7 +129247,7 @@ const ParserV5 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$5(elements); const inflatedData = inflate$5(deflatedData); - load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -129295,7 +129310,7 @@ function inflate$4(deflatedData) { }; } -const decompressColor$4 = (function () { +const decompressColor$5 = (function () { const floatColor = new Float32Array(3); return function (intColor) { floatColor[0] = intColor[0] / 255.0; @@ -129305,7 +129320,7 @@ const decompressColor$4 = (function () { }; })(); -function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -129453,7 +129468,7 @@ function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const primitiveIndices = indices.subarray(eachPrimitiveIndicesPortion [primitiveIndex], atLastPrimitive ? indices.length : eachPrimitiveIndicesPortion [primitiveIndex + 1]); const primitiveEdgeIndices = edgeIndices.subarray(eachPrimitiveEdgeIndicesPortion [primitiveIndex], atLastPrimitive ? edgeIndices.length : eachPrimitiveEdgeIndicesPortion [primitiveIndex + 1]); - const color = decompressColor$4(eachPrimitiveColorAndOpacity.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3)); + const color = decompressColor$5(eachPrimitiveColorAndOpacity.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3)); const opacity = eachPrimitiveColorAndOpacity[(primitiveIndex * 4) + 3] / 255.0; const meshId = manifestCtx.getNextId(); @@ -129527,7 +129542,7 @@ const ParserV6 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$4(elements); const inflatedData = inflate$4(deflatedData); - load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -129625,7 +129640,7 @@ function inflate$3(deflatedData) { }; } -const decompressColor$3 = (function () { +const decompressColor$4 = (function () { const floatColor = new Float32Array(3); return function (intColor) { floatColor[0] = intColor[0] / 255.0; @@ -129646,7 +129661,7 @@ function convertColorsRGBToRGBA$1(colorsRGB) { return colorsRGBA; } -function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -129797,7 +129812,7 @@ function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const atLastGeometry = (geometryIndex === (numGeometries - 1)); - const meshColor = decompressColor$3(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); + const meshColor = decompressColor$4(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0; const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0; const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0; @@ -129958,7 +129973,7 @@ const ParserV7 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$3(elements); const inflatedData = inflate$3(deflatedData); - load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -129973,8 +129988,8 @@ if (!pako$2.inflate) { // See https://github.com/nodeca/pako/issues/97 pako$2 = pako$2.default; } -const tempVec4a$2 = math.vec4(); -const tempVec4b$2 = math.vec4(); +const tempVec4a$3 = math.vec4(); +const tempVec4b$3 = math.vec4(); function extract$2(elements) { @@ -130066,7 +130081,7 @@ function inflate$2(deflatedData) { }; } -const decompressColor$2 = (function () { +const decompressColor$3 = (function () { const floatColor = new Float32Array(3); return function (intColor) { floatColor[0] = intColor[0] / 255.0; @@ -130087,7 +130102,7 @@ function convertColorsRGBToRGBA(colorsRGB) { return colorsRGBA; } -function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -130273,7 +130288,7 @@ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const atLastGeometry = (geometryIndex === (numGeometries - 1)); - const meshColor = decompressColor$2(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); + const meshColor = decompressColor$3(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0; const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0; const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0; @@ -130362,15 +130377,15 @@ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const decompressedPositions = geometryArrays.decompressedPositions; const positions = new Uint16Array(decompressedPositions.length); for (let i = 0, len = decompressedPositions.length; i < len; i += 3) { - tempVec4a$2[0] = decompressedPositions[i + 0]; - tempVec4a$2[1] = decompressedPositions[i + 1]; - tempVec4a$2[2] = decompressedPositions[i + 2]; - tempVec4a$2[3] = 1; - math.transformVec4(meshMatrix, tempVec4a$2, tempVec4b$2); - geometryCompressionUtils.compressPosition(tempVec4b$2, rtcAABB, tempVec4a$2); - positions[i + 0] = tempVec4a$2[0]; - positions[i + 1] = tempVec4a$2[1]; - positions[i + 2] = tempVec4a$2[2]; + tempVec4a$3[0] = decompressedPositions[i + 0]; + tempVec4a$3[1] = decompressedPositions[i + 1]; + tempVec4a$3[2] = decompressedPositions[i + 2]; + tempVec4a$3[3] = 1; + math.transformVec4(meshMatrix, tempVec4a$3, tempVec4b$3); + geometryCompressionUtils.compressPosition(tempVec4b$3, rtcAABB, tempVec4a$3); + positions[i + 0] = tempVec4a$3[0]; + positions[i + 1] = tempVec4a$3[1]; + positions[i + 2] = tempVec4a$3[2]; } sceneModel.createMesh(utils.apply(meshDefaults, { @@ -130510,7 +130525,7 @@ const ParserV8 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$2(elements); const inflatedData = inflate$2(deflatedData); - load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -130525,8 +130540,8 @@ if (!pako$1.inflate) { // See https://github.com/nodeca/pako/issues/97 pako$1 = pako$1.default; } -const tempVec4a$1 = math.vec4(); -const tempVec4b$1 = math.vec4(); +const tempVec4a$2 = math.vec4(); +const tempVec4b$2 = math.vec4(); function extract$1(elements) { @@ -130610,7 +130625,7 @@ function inflate$1(deflatedData) { }; } -const decompressColor$1 = (function () { +const decompressColor$2 = (function () { const floatColor = new Float32Array(3); return function (intColor) { floatColor[0] = intColor[0] / 255.0; @@ -130620,7 +130635,7 @@ const decompressColor$1 = (function () { }; })(); -function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -130782,7 +130797,7 @@ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const atLastGeometry = (geometryIndex === (numGeometries - 1)); - const meshColor = decompressColor$1(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); + const meshColor = decompressColor$2(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0; const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0; const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0; @@ -130869,15 +130884,15 @@ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const transformedAndRecompressedPositions = geometryArrays.transformedAndRecompressedPositions; for (let i = 0, len = decompressedPositions.length; i < len; i += 3) { - tempVec4a$1[0] = decompressedPositions[i + 0]; - tempVec4a$1[1] = decompressedPositions[i + 1]; - tempVec4a$1[2] = decompressedPositions[i + 2]; - tempVec4a$1[3] = 1; - math.transformVec4(meshMatrix, tempVec4a$1, tempVec4b$1); - geometryCompressionUtils.compressPosition(tempVec4b$1, rtcAABB, tempVec4a$1); - transformedAndRecompressedPositions[i + 0] = tempVec4a$1[0]; - transformedAndRecompressedPositions[i + 1] = tempVec4a$1[1]; - transformedAndRecompressedPositions[i + 2] = tempVec4a$1[2]; + tempVec4a$2[0] = decompressedPositions[i + 0]; + tempVec4a$2[1] = decompressedPositions[i + 1]; + tempVec4a$2[2] = decompressedPositions[i + 2]; + tempVec4a$2[3] = 1; + math.transformVec4(meshMatrix, tempVec4a$2, tempVec4b$2); + geometryCompressionUtils.compressPosition(tempVec4b$2, rtcAABB, tempVec4a$2); + transformedAndRecompressedPositions[i + 0] = tempVec4a$2[0]; + transformedAndRecompressedPositions[i + 1] = tempVec4a$2[1]; + transformedAndRecompressedPositions[i + 2] = tempVec4a$2[2]; } sceneModel.createMesh(utils.apply(meshDefaults, { @@ -131017,7 +131032,7 @@ const ParserV9 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$1(elements); const inflatedData = inflate$1(deflatedData); - load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -131030,10 +131045,10 @@ if (!pako.inflate) { // See https://github.com/nodeca/pako/issues/97 pako = pako.default; } -const tempVec4a = math.vec4(); -const tempVec4b = math.vec4(); +const tempVec4a$1 = math.vec4(); +const tempVec4b$1 = math.vec4(); -const NUM_TEXTURE_ATTRIBUTES = 9; +const NUM_TEXTURE_ATTRIBUTES$1 = 9; function extract(elements) { @@ -131109,6 +131124,648 @@ function inflate(deflatedData) { }; } +const decompressColor$1 = (function () { + const floatColor = new Float32Array(3); + return function (intColor) { + floatColor[0] = intColor[0] / 255.0; + floatColor[1] = intColor[1] / 255.0; + floatColor[2] = intColor[2] / 255.0; + return floatColor; + }; +})(); + +((function () { + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + return function (imagedata) { + canvas.width = imagedata.width; + canvas.height = imagedata.height; + context.putImageData(imagedata, 0, 0); + return canvas.toDataURL(); + }; +}))(); + +function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { + + const modelPartId = manifestCtx.getNextId(); + + const metadata = inflatedData.metadata; + const textureData = inflatedData.textureData; + const eachTextureDataPortion = inflatedData.eachTextureDataPortion; + const eachTextureAttributes = inflatedData.eachTextureAttributes; + const positions = inflatedData.positions; + const normals = inflatedData.normals; + const colors = inflatedData.colors; + const uvs = inflatedData.uvs; + const indices = inflatedData.indices; + const edgeIndices = inflatedData.edgeIndices; + const eachTextureSetTextures = inflatedData.eachTextureSetTextures; + const matrices = inflatedData.matrices; + const reusedGeometriesDecodeMatrix = inflatedData.reusedGeometriesDecodeMatrix; + const eachGeometryPrimitiveType = inflatedData.eachGeometryPrimitiveType; + const eachGeometryPositionsPortion = inflatedData.eachGeometryPositionsPortion; + const eachGeometryNormalsPortion = inflatedData.eachGeometryNormalsPortion; + const eachGeometryColorsPortion = inflatedData.eachGeometryColorsPortion; + const eachGeometryUVsPortion = inflatedData.eachGeometryUVsPortion; + const eachGeometryIndicesPortion = inflatedData.eachGeometryIndicesPortion; + const eachGeometryEdgeIndicesPortion = inflatedData.eachGeometryEdgeIndicesPortion; + const eachMeshGeometriesPortion = inflatedData.eachMeshGeometriesPortion; + const eachMeshMatricesPortion = inflatedData.eachMeshMatricesPortion; + const eachMeshTextureSet = inflatedData.eachMeshTextureSet; + const eachMeshMaterialAttributes = inflatedData.eachMeshMaterialAttributes; + const eachEntityId = inflatedData.eachEntityId; + const eachEntityMeshesPortion = inflatedData.eachEntityMeshesPortion; + const eachTileAABB = inflatedData.eachTileAABB; + const eachTileEntitiesPortion = inflatedData.eachTileEntitiesPortion; + + const numTextures = eachTextureDataPortion.length; + const numTextureSets = eachTextureSetTextures.length / 5; + const numGeometries = eachGeometryPositionsPortion.length; + const numMeshes = eachMeshGeometriesPortion.length; + const numEntities = eachEntityMeshesPortion.length; + const numTiles = eachTileEntitiesPortion.length; + + if (metaModel) { + metaModel.loadData(metadata, { + includeTypes: options.includeTypes, + excludeTypes: options.excludeTypes, + globalizeObjectIds: options.globalizeObjectIds + }); // Can be empty + } + + // Create textures + + for (let textureIndex = 0; textureIndex < numTextures; textureIndex++) { + const atLastTexture = (textureIndex === (numTextures - 1)); + const textureDataPortionStart = eachTextureDataPortion[textureIndex]; + const textureDataPortionEnd = atLastTexture ? textureData.length : (eachTextureDataPortion[textureIndex + 1]); + + const textureDataPortionSize = textureDataPortionEnd - textureDataPortionStart; + const textureDataPortionExists = (textureDataPortionSize > 0); + + const textureAttrBaseIdx = (textureIndex * NUM_TEXTURE_ATTRIBUTES$1); + + const compressed = (eachTextureAttributes[textureAttrBaseIdx + 0] === 1); + const mediaType = eachTextureAttributes[textureAttrBaseIdx + 1]; + eachTextureAttributes[textureAttrBaseIdx + 2]; + eachTextureAttributes[textureAttrBaseIdx + 3]; + const minFilter = eachTextureAttributes[textureAttrBaseIdx + 4]; + const magFilter = eachTextureAttributes[textureAttrBaseIdx + 5]; // LinearFilter | NearestFilter + const wrapS = eachTextureAttributes[textureAttrBaseIdx + 6]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping + const wrapT = eachTextureAttributes[textureAttrBaseIdx + 7]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping + const wrapR = eachTextureAttributes[textureAttrBaseIdx + 8]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping + + if (textureDataPortionExists) { + + const imageDataSubarray = new Uint8Array(textureData.subarray(textureDataPortionStart, textureDataPortionEnd)); + const arrayBuffer = imageDataSubarray.buffer; + const textureId = `${modelPartId}-texture-${textureIndex}`; + + if (compressed) { + + sceneModel.createTexture({ + id: textureId, + buffers: [arrayBuffer], + minFilter, + magFilter, + wrapS, + wrapT, + wrapR + }); + + } else { + + const mimeType = mediaType === JPEGMediaType ? "image/jpeg" : (mediaType === PNGMediaType ? "image/png" : "image/gif"); + const blob = new Blob([arrayBuffer], {type: mimeType}); + const urlCreator = window.URL || window.webkitURL; + const imageUrl = urlCreator.createObjectURL(blob); + const img = document.createElement('img'); + img.src = imageUrl; + + sceneModel.createTexture({ + id: textureId, + image: img, + //mediaType, + minFilter, + magFilter, + wrapS, + wrapT, + wrapR + }); + } + } + } + + // Create texture sets + + for (let textureSetIndex = 0; textureSetIndex < numTextureSets; textureSetIndex++) { + const eachTextureSetTexturesIndex = textureSetIndex * 5; + const textureSetId = `${modelPartId}-textureSet-${textureSetIndex}`; + const colorTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 0]; + const metallicRoughnessTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 1]; + const normalsTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 2]; + const emissiveTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 3]; + const occlusionTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 4]; + sceneModel.createTextureSet({ + id: textureSetId, + colorTextureId: colorTextureIndex >= 0 ? `${modelPartId}-texture-${colorTextureIndex}` : null, + normalsTextureId: normalsTextureIndex >= 0 ? `${modelPartId}-texture-${normalsTextureIndex}` : null, + metallicRoughnessTextureId: metallicRoughnessTextureIndex >= 0 ? `${modelPartId}-texture-${metallicRoughnessTextureIndex}` : null, + emissiveTextureId: emissiveTextureIndex >= 0 ? `${modelPartId}-texture-${emissiveTextureIndex}` : null, + occlusionTextureId: occlusionTextureIndex >= 0 ? `${modelPartId}-texture-${occlusionTextureIndex}` : null + }); + } + + // Count instances of each geometry + + const geometryReuseCounts = new Uint32Array(numGeometries); + + for (let meshIndex = 0; meshIndex < numMeshes; meshIndex++) { + const geometryIndex = eachMeshGeometriesPortion[meshIndex]; + if (geometryReuseCounts[geometryIndex] !== undefined) { + geometryReuseCounts[geometryIndex]++; + } else { + geometryReuseCounts[geometryIndex] = 1; + } + } + + // Iterate over tiles + + const tileCenter = math.vec3(); + const rtcAABB = math.AABB3(); + + const geometryArraysCache = {}; + + for (let tileIndex = 0; tileIndex < numTiles; tileIndex++) { + + const lastTileIndex = (numTiles - 1); + + const atLastTile = (tileIndex === lastTileIndex); + + const firstTileEntityIndex = eachTileEntitiesPortion [tileIndex]; + const lastTileEntityIndex = atLastTile ? (numEntities - 1) : (eachTileEntitiesPortion[tileIndex + 1] - 1); + + const tileAABBIndex = tileIndex * 6; + const tileAABB = eachTileAABB.subarray(tileAABBIndex, tileAABBIndex + 6); + + math.getAABB3Center(tileAABB, tileCenter); + + rtcAABB[0] = tileAABB[0] - tileCenter[0]; + rtcAABB[1] = tileAABB[1] - tileCenter[1]; + rtcAABB[2] = tileAABB[2] - tileCenter[2]; + rtcAABB[3] = tileAABB[3] - tileCenter[0]; + rtcAABB[4] = tileAABB[4] - tileCenter[1]; + rtcAABB[5] = tileAABB[5] - tileCenter[2]; + + const tileDecodeMatrix = geometryCompressionUtils.createPositionsDecodeMatrix(rtcAABB); + + const geometryCreatedInTile = {}; + + // Iterate over each tile's entities + + for (let tileEntityIndex = firstTileEntityIndex; tileEntityIndex <= lastTileEntityIndex; tileEntityIndex++) { + + const xktEntityId = eachEntityId[tileEntityIndex]; + + const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId; + + const finalTileEntityIndex = (numEntities - 1); + const atLastTileEntity = (tileEntityIndex === finalTileEntityIndex); + const firstMeshIndex = eachEntityMeshesPortion [tileEntityIndex]; + const lastMeshIndex = atLastTileEntity ? (eachMeshGeometriesPortion.length - 1) : (eachEntityMeshesPortion[tileEntityIndex + 1] - 1); + + const meshIds = []; + + const metaObject = viewer.metaScene.metaObjects[entityId]; + const entityDefaults = {}; + const meshDefaults = {}; + + if (metaObject) { + + // Mask loading of object types + + if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) { + continue; + } + + if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) { + continue; + } + + // Get initial property values for object types + + const 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 + + for (let meshIndex = firstMeshIndex; meshIndex <= lastMeshIndex; meshIndex++) { + + const geometryIndex = eachMeshGeometriesPortion[meshIndex]; + const geometryReuseCount = geometryReuseCounts[geometryIndex]; + const isReusedGeometry = (geometryReuseCount > 1); + + const atLastGeometry = (geometryIndex === (numGeometries - 1)); + + const textureSetIndex = eachMeshTextureSet[meshIndex]; + + const textureSetId = (textureSetIndex >= 0) ? `${modelPartId}-textureSet-${textureSetIndex}` : null; + + const meshColor = decompressColor$1(eachMeshMaterialAttributes.subarray((meshIndex * 6), (meshIndex * 6) + 3)); + const meshOpacity = eachMeshMaterialAttributes[(meshIndex * 6) + 3] / 255.0; + const meshMetallic = eachMeshMaterialAttributes[(meshIndex * 6) + 4] / 255.0; + const meshRoughness = eachMeshMaterialAttributes[(meshIndex * 6) + 5] / 255.0; + + const meshId = manifestCtx.getNextId(); + + if (isReusedGeometry) { + + // Create mesh for multi-use geometry - create (or reuse) geometry, create mesh using that geometry + + const meshMatrixIndex = eachMeshMatricesPortion[meshIndex]; + const meshMatrix = matrices.slice(meshMatrixIndex, meshMatrixIndex + 16); + + const geometryId = `${modelPartId}-geometry.${tileIndex}.${geometryIndex}`; // These IDs are local to the SceneModel + + let geometryArrays = geometryArraysCache[geometryId]; + + if (!geometryArrays) { + geometryArrays = { + batchThisMesh: (!options.reuseGeometries) + }; + const primitiveType = eachGeometryPrimitiveType[geometryIndex]; + let geometryValid = false; + switch (primitiveType) { + case 0: + geometryArrays.primitiveName = "solid"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]); + geometryArrays.geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]); + geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryArrays.geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0); + break; + case 1: + geometryArrays.primitiveName = "surface"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]); + geometryArrays.geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]); + geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryArrays.geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0); + break; + case 2: + geometryArrays.primitiveName = "points"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryColors = colors.subarray(eachGeometryColorsPortion [geometryIndex], atLastGeometry ? colors.length : eachGeometryColorsPortion [geometryIndex + 1]); + geometryValid = (geometryArrays.geometryPositions.length > 0); + break; + case 3: + geometryArrays.primitiveName = "lines"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0); + break; + case 4: + geometryArrays.primitiveName = "lines"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryIndices = lineStripToLines$1( + geometryArrays.geometryPositions, + indices.subarray(eachGeometryIndicesPortion [geometryIndex], + atLastGeometry + ? indices.length + : eachGeometryIndicesPortion [geometryIndex + 1])); + geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0); + break; + default: + continue; + } + + if (!geometryValid) { + geometryArrays = null; + } + + if (geometryArrays) { + if (geometryArrays.geometryPositions.length > 1000) ; + if (geometryArrays.batchThisMesh) { + geometryArrays.decompressedPositions = new Float32Array(geometryArrays.geometryPositions.length); + geometryArrays.transformedAndRecompressedPositions = new Uint16Array(geometryArrays.geometryPositions.length); + const geometryPositions = geometryArrays.geometryPositions; + const decompressedPositions = geometryArrays.decompressedPositions; + for (let i = 0, len = geometryPositions.length; i < len; i += 3) { + decompressedPositions[i + 0] = geometryPositions[i + 0] * reusedGeometriesDecodeMatrix[0] + reusedGeometriesDecodeMatrix[12]; + decompressedPositions[i + 1] = geometryPositions[i + 1] * reusedGeometriesDecodeMatrix[5] + reusedGeometriesDecodeMatrix[13]; + decompressedPositions[i + 2] = geometryPositions[i + 2] * reusedGeometriesDecodeMatrix[10] + reusedGeometriesDecodeMatrix[14]; + } + geometryArrays.geometryPositions = null; + geometryArraysCache[geometryId] = geometryArrays; + } + } + } + + if (geometryArrays) { + + if (geometryArrays.batchThisMesh) { + + const decompressedPositions = geometryArrays.decompressedPositions; + const transformedAndRecompressedPositions = geometryArrays.transformedAndRecompressedPositions; + + for (let i = 0, len = decompressedPositions.length; i < len; i += 3) { + tempVec4a$1[0] = decompressedPositions[i + 0]; + tempVec4a$1[1] = decompressedPositions[i + 1]; + tempVec4a$1[2] = decompressedPositions[i + 2]; + tempVec4a$1[3] = 1; + math.transformVec4(meshMatrix, tempVec4a$1, tempVec4b$1); + geometryCompressionUtils.compressPosition(tempVec4b$1, rtcAABB, tempVec4a$1); + transformedAndRecompressedPositions[i + 0] = tempVec4a$1[0]; + transformedAndRecompressedPositions[i + 1] = tempVec4a$1[1]; + transformedAndRecompressedPositions[i + 2] = tempVec4a$1[2]; + } + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + textureSetId, + 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]) { + + sceneModel.createGeometry({ + id: geometryId, + primitive: geometryArrays.primitiveName, + positionsCompressed: geometryArrays.geometryPositions, + normalsCompressed: geometryArrays.geometryNormals, + uv: geometryArrays.geometryUVs, + colorsCompressed: geometryArrays.geometryColors, + indices: geometryArrays.geometryIndices, + edgeIndices: geometryArrays.geometryEdgeIndices, + positionsDecodeMatrix: reusedGeometriesDecodeMatrix + }); + + geometryCreatedInTile[geometryId] = true; + } + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + geometryId, + textureSetId, + matrix: meshMatrix, + color: meshColor, + metallic: meshMetallic, + roughness: meshRoughness, + opacity: meshOpacity, + origin: tileCenter + })); + + meshIds.push(meshId); + } + } + + } else { // Do not reuse geometry + + const primitiveType = eachGeometryPrimitiveType[geometryIndex]; + + let primitiveName; + let geometryPositions; + let geometryNormals; + let geometryUVs; + let geometryColors; + let geometryIndices; + let geometryEdgeIndices; + let geometryValid = false; + + switch (primitiveType) { + case 0: + primitiveName = "solid"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]); + geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]); + geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0); + break; + case 1: + primitiveName = "surface"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]); + geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]); + geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0); + break; + case 2: + primitiveName = "points"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryColors = colors.subarray(eachGeometryColorsPortion [geometryIndex], atLastGeometry ? colors.length : eachGeometryColorsPortion [geometryIndex + 1]); + geometryValid = (geometryPositions.length > 0); + break; + case 3: + primitiveName = "lines"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0); + break; + case 4: + primitiveName = "lines"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryIndices = lineStripToLines$1( + geometryPositions, + indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry + ? indices.length + : eachGeometryIndicesPortion [geometryIndex + 1])); + geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0); + break; + default: + continue; + } + + if (geometryValid) { + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + textureSetId, + origin: tileCenter, + primitive: primitiveName, + positionsCompressed: geometryPositions, + normalsCompressed: geometryNormals, + uv: geometryUVs && geometryUVs.length > 0 ? geometryUVs : null, + colorsCompressed: geometryColors, + indices: geometryIndices, + edgeIndices: geometryEdgeIndices, + positionsDecodeMatrix: tileDecodeMatrix, + color: meshColor, + metallic: meshMetallic, + roughness: meshRoughness, + opacity: meshOpacity + })); + + meshIds.push(meshId); + } + } + } + + if (meshIds.length > 0) { + + sceneModel.createEntity(utils.apply(entityDefaults, { + id: entityId, + isObject: true, + meshIds: meshIds + })); + } + } + } +} + +function lineStripToLines$1(positions, indices) { + const linesIndices = []; + if (indices.length > 1) { + for (let i = 0, len = indices.length - 1; i < len; i++) { + linesIndices.push(indices[i]); + linesIndices.push(indices[i + 1]); + } + } else if (positions.length > 1) { + for (let i = 0, len = (positions.length / 3) - 1; i < len; i++) { + linesIndices.push(i); + linesIndices.push(i + 1); + } + } + return linesIndices; +} + +/** @private */ +const ParserV10 = { + version: 10, + parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { + const deflatedData = extract(elements); + const inflatedData = inflate(deflatedData); + load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + } +}; + +/* + Parser for .XKT Format V11 +*/ + +const tempVec4a = math.vec4(); +const tempVec4b = math.vec4(); + +const NUM_TEXTURE_ATTRIBUTES = 9; + +function decodeData(arrayBuffer) { + const requiresSwapFromLittleEndian = (function() { + const buffer = new ArrayBuffer(2); + new Uint16Array(buffer)[0] = 1; + return new Uint8Array(buffer)[0] !== 1; + })(); + + const nextArray = (function() { + let i = 0; + const dataView = new DataView(arrayBuffer); + return function(type) { + const idx = 1 + 2 * i++; // `1' for the version nr + const byteOffset = dataView.getUint32(idx * 4, true); + const byteLength = dataView.getUint32((idx + 1) * 4, true); + + const BPE = type.BYTES_PER_ELEMENT; + if (requiresSwapFromLittleEndian && (BPE > 1)) { + const subarray = new Uint8Array(arrayBuffer, byteOffset, byteLength); + const swaps = BPE / 2; + const cnt = subarray.length / BPE; + for (let b = 0; b < cnt; b++) { + const offset = b * BPE; + for (let j = 0; j < swaps; j++) { + const i1 = offset + j; + const i2 = offset - j + BPE - 1; + const tmp = subarray[i1]; + subarray[i1] = subarray[i2]; + subarray[i2] = tmp; + } + } + } + + return new type(arrayBuffer, byteOffset, byteLength / BPE); + }; + })(); + + const nextObject = (function() { + const decoder = new TextDecoder(); + return () => JSON.parse(decoder.decode(nextArray(Uint8Array))); + })(); + + return { + metadata: nextObject(), + textureData: nextArray(Uint8Array), // <<----------------------------- ??? ZIPPing to blame? + eachTextureDataPortion: nextArray(Uint32Array), + eachTextureAttributes: nextArray(Uint16Array), + positions: nextArray(Uint16Array), + normals: nextArray(Int8Array), + colors: nextArray(Uint8Array), + uvs: nextArray(Float32Array), + indices: nextArray(Uint32Array), + edgeIndices: nextArray(Uint32Array), + eachTextureSetTextures: nextArray(Int32Array), + matrices: nextArray(Float32Array), + reusedGeometriesDecodeMatrix: nextArray(Float32Array), + eachGeometryPrimitiveType: nextArray(Uint8Array), + eachGeometryPositionsPortion: nextArray(Uint32Array), + eachGeometryNormalsPortion: nextArray(Uint32Array), + eachGeometryColorsPortion: nextArray(Uint32Array), + eachGeometryUVsPortion: nextArray(Uint32Array), + eachGeometryIndicesPortion: nextArray(Uint32Array), + eachGeometryEdgeIndicesPortion: nextArray(Uint32Array), + eachMeshGeometriesPortion: nextArray(Uint32Array), + eachMeshMatricesPortion: nextArray(Uint32Array), + eachMeshTextureSet: nextArray(Int32Array), // Can be -1 + eachMeshMaterialAttributes: nextArray(Uint8Array), + eachEntityId: nextObject(), + eachEntityMeshesPortion: nextArray(Uint32Array), + eachTileAABB: nextArray(Float64Array), + eachTileEntitiesPortion: nextArray(Uint32Array), + }; +} + const decompressColor = (function () { const floatColor = new Float32Array(3); return function (intColor) { @@ -131660,11 +132317,15 @@ function lineStripToLines(positions, indices) { } /** @private */ -const ParserV10 = { - version: 10, - parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { - const deflatedData = extract(elements); - const inflatedData = inflate(deflatedData); +// V11 uses a single uncompressed Uint8Array buffer to store arrays of different types. +// To efficiently create typed arrays from this buffer, +// each typed array's source data needs to be aligned with its element byte size. +// This sometimes requires padding subarrays inside the single Uint8Array, so the byteOffset needs to be stored alongside element count. +// It is a different encoding than used in earlier versions, and requires different approach to parsing elements. +const ParserV11 = { + version: 11, + parseArrayBuffer: function (viewer, options, arrayBuffer, sceneModel, metaModel, manifestCtx) { + const inflatedData = decodeData(arrayBuffer); load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -131681,6 +132342,7 @@ parsers[ParserV7.version] = ParserV7; parsers[ParserV8.version] = ParserV8; parsers[ParserV9.version] = ParserV9; parsers[ParserV10.version] = ParserV10; +parsers[ParserV11.version] = ParserV11; /** * {@link Viewer} plugin that loads models from xeokit's optimized *````.XKT````* format. @@ -132798,6 +133460,12 @@ class XKTLoaderPlugin extends Plugin { return; } // this.log("Loading .xkt V" + xktVersion); + + if (parser.parseArrayBuffer) { + parser.parseArrayBuffer(this.viewer, options, arrayBuffer, sceneModel, metaModel, manifestCtx); + return; + } + const numElements = dataView.getUint32(4, true); const elements = []; let byteOffset = (numElements + 2) * 4; @@ -139863,7 +140531,7 @@ const mousePointSelector = function(viewer, ray2WorldPos) { const copyCanvasPos = (event, vec2) => { vec2[0] = event.clientX; vec2[1] = event.clientY; - transformToNode(canvas.ownerDocument.body, canvas, vec2); + transformToNode(canvas.ownerDocument.documentElement, canvas, vec2); return vec2; }; @@ -139938,7 +140606,7 @@ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) { const copyCanvasPos = (event, vec2) => { vec2[0] = event.clientX; vec2[1] = event.clientY; - transformToNode(canvas.ownerDocument.body, canvas, vec2); + transformToNode(canvas.ownerDocument.documentElement, canvas, vec2); return vec2; }; @@ -141232,7 +141900,7 @@ class ZoneTranslateControl extends Component { const copyCanvasPos = (event, vec2) => { vec2[0] = event.clientX; vec2[1] = event.clientY; - transformToNode(canvas.ownerDocument.body, canvas, vec2); + transformToNode(canvas.ownerDocument.documentElement, canvas, vec2); return vec2; }; diff --git a/dist/xeokit-sdk.es.js b/dist/xeokit-sdk.es.js index 6626861e36..b84920a42c 100644 --- a/dist/xeokit-sdk.es.js +++ b/dist/xeokit-sdk.es.js @@ -10683,8 +10683,8 @@ class SceneModelEntity { } } -const tempVec4a$a = math.vec4(); -const tempVec4b$6 = math.vec4(); +const tempVec4a$b = math.vec4(); +const tempVec4b$7 = math.vec4(); /** @@ -10843,12 +10843,12 @@ class Marker extends Component { this.fire("viewPos", this._viewPos); } if (this._canvasPosDirty) { - tempVec4a$a.set(this._viewPos); - tempVec4a$a[3] = 1.0; - math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$a, tempVec4b$6); + tempVec4a$b.set(this._viewPos); + tempVec4a$b[3] = 1.0; + math.transformPoint4(this.scene.camera.projMatrix, tempVec4a$b, tempVec4b$7); const aabb = this.scene.canvas.boundary; - this._canvasPos[0] = Math.floor((1 + tempVec4b$6[0] / tempVec4b$6[3]) * aabb[2] / 2); - this._canvasPos[1] = Math.floor((1 - tempVec4b$6[1] / tempVec4b$6[3]) * aabb[3] / 2); + this._canvasPos[0] = Math.floor((1 + tempVec4b$7[0] / tempVec4b$7[3]) * aabb[2] / 2); + this._canvasPos[1] = Math.floor((1 - tempVec4b$7[1] / tempVec4b$7[3]) * aabb[3] / 2); this._canvasPosDirty = false; this.fire("canvasPos", this._canvasPos); } @@ -11179,7 +11179,7 @@ function activateDraggableDot(dot, cfg) { const onChange = event => { const canvasPos = math.vec2([ event.clientX, event.clientY ]); - transformToNode(canvas.ownerDocument.body, canvas, canvasPos); + transformToNode(canvas.ownerDocument.documentElement, canvas, canvasPos); onMove(canvasPos, pickWorldPos(canvasPos)); }; @@ -23516,8 +23516,8 @@ const tempVec3c$u = math.vec3(); const tempVec3d$d = math.vec3(); const tempVec3e$2 = math.vec3(); const tempVec3f$2 = math.vec3(); -const tempVec4a$9 = math.vec4(); -const tempVec4b$5 = math.vec4(); +const tempVec4a$a = math.vec4(); +const tempVec4b$6 = math.vec4(); const tempVec4c$2 = math.vec4(); const tempMat = math.mat4(); const tempMatb = math.mat4(); @@ -24382,8 +24382,8 @@ class Camera extends Component { * @returns {[number, number]} the canvas position */ projectWorldPos(worldPos) { - const _worldPos = tempVec4a$9; - const viewPos = tempVec4b$5; + const _worldPos = tempVec4a$a; + const viewPos = tempVec4b$6; const screenPos = tempVec4c$2; _worldPos[0] = worldPos[0]; _worldPos[1] = worldPos[1]; @@ -56190,7 +56190,7 @@ function octDecodeVec2(oct) { // Decode an oct-encoded normal const tempMat4$1 = math.mat4(); const tempMat4b = math.mat4(); -const tempVec4a$8 = math.vec4([0, 0, 0, 1]); +const tempVec4a$9 = math.vec4([0, 0, 0, 1]); const tempVec3a$z = math.vec3(); const tempVec3b$v = math.vec3(); @@ -56999,7 +56999,7 @@ class VBOBatchingTrianglesLayer { const offsetX = origin[0] ; const offsetY = origin[1] ; const offsetZ = origin[2] ; - const worldPos = tempVec4a$8; + const worldPos = tempVec4a$9; const sceneModelMatrix = this.model.matrix; const positionsDecodeMatrix = state.positionsDecodeMatrix; for (let i = 0, len = positions.length; i < len; i += 3) { @@ -61362,7 +61362,7 @@ function getRenderers$6(scene) { const tempUint8Vec4$2 = new Uint8Array(4); const tempFloat32$2 = new Float32Array(1); -const tempVec4a$7 = math.vec4([0, 0, 0, 1]); +const tempVec4a$8 = math.vec4([0, 0, 0, 1]); const tempVec3fa$2 = new Float32Array(3); const tempVec3a$w = math.vec3(); @@ -62066,7 +62066,7 @@ class VBOInstancingTrianglesLayer { const offsetX = origin[0]; const offsetY = origin[1]; const offsetZ = origin[2]; - const worldPos = tempVec4a$7; + const worldPos = tempVec4a$8; const portionMatrix = portion.matrix; const sceneModelMatrix = this.model.matrix; const positionsDecodeMatrix = state.positionsDecodeMatrix; @@ -72772,7 +72772,7 @@ const tempVec3b$i = math.vec3(); const tempVec3c$e = math.vec3(); math.vec3(); -const tempVec4a$6 = math.vec4(); +const tempVec4a$7 = math.vec4(); const tempMat4a$c = math.mat4(); @@ -73051,11 +73051,11 @@ class DTXTrianglesColorRenderer { if (saoEnabled) { const viewportWidth = gl.drawingBufferWidth; const viewportHeight = gl.drawingBufferHeight; - tempVec4a$6[0] = viewportWidth; - tempVec4a$6[1] = viewportHeight; - tempVec4a$6[2] = sao.blendCutoff; - tempVec4a$6[3] = sao.blendFactor; - gl.uniform4fv(this._uSAOParams, tempVec4a$6); + tempVec4a$7[0] = viewportWidth; + tempVec4a$7[1] = viewportHeight; + tempVec4a$7[2] = sao.blendCutoff; + tempVec4a$7[3] = sao.blendFactor; + gl.uniform4fv(this._uSAOParams, tempVec4a$7); this._program.bindTexture(this._uOcclusionTexture, frameCtx.occlusionTexture, 10); } } @@ -74714,6 +74714,12 @@ class DTXTrianglesPickMeshRenderer { const textureState = state.textureState; const origin = dataTextureLayer._state.origin; const {position, rotationMatrix, rotationMatrixConjugate} = model; + + const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix; + const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix; + const eye = frameCtx.pickOrigin || camera.eye; + const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far; + textureState.bindCommonTextures( this._program, this.uTexturePerObjectPositionsDecodeMatrix, @@ -74740,24 +74746,24 @@ class DTXTrianglesPickMeshRenderer { rtcOrigin[0] += position[0]; rtcOrigin[1] += position[1]; rtcOrigin[2] += position[2]; - rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a$8); + rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$8); rtcCameraEye = tempVec3c$c; - rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0]; - rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1]; - rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2]; + rtcCameraEye[0] = eye[0] - rtcOrigin[0]; + rtcCameraEye[1] = eye[1] - rtcOrigin[1]; + rtcCameraEye[2] = eye[2] - rtcOrigin[2]; } else { - rtcViewMatrix = camera.viewMatrix; - rtcCameraEye = camera.eye; + rtcViewMatrix = viewMatrix; + rtcCameraEye = eye; } gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos); gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight); gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate); gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix); - gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix); + gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix); gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye); gl.uniform1i(this._uRenderPass, renderPass); if (scene.logarithmicDepthBufferEnabled) { - const logDepthBufFC = 2.0 / (Math.log(camera.project.far + 1.0) / Math.LN2); // TODO: Far from pick project matrix? + const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2); gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC); } const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); @@ -75134,7 +75140,11 @@ class DTXTrianglesPickDepthRenderer { const textureState = state.textureState; const origin = dataTextureLayer._state.origin; const {position, rotationMatrix, rotationMatrixConjugate} = model; + const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix; + const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix; + const eye = frameCtx.pickOrigin || camera.eye; + const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far; if (!this._program) { this._allocate(); @@ -75174,15 +75184,15 @@ class DTXTrianglesPickDepthRenderer { rtcOrigin[2] += position[2]; rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$7); rtcCameraEye = tempVec3c$b; - rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0]; - rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1]; - rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2]; + rtcCameraEye[0] = eye[0] - rtcOrigin[0]; + rtcCameraEye[1] = eye[1] - rtcOrigin[1]; + rtcCameraEye[2] = 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; + rtcCameraEye = eye; frameCtx.snapPickOrigin[0] = 0; frameCtx.snapPickOrigin[1] = 0; frameCtx.snapPickOrigin[2] = 0; @@ -75197,9 +75207,9 @@ class DTXTrianglesPickDepthRenderer { gl.uniform1f(this._uPickZFar, frameCtx.pickZFar); gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate); gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix); - gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix); + gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix); if (scene.logarithmicDepthBufferEnabled) { - const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2); // TODO: Far from pick project matrix? + const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2); gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC); } @@ -77709,6 +77719,11 @@ class DTXTrianglesPickNormalsFlatRenderer { this._bindProgram(frameCtx, state); } + const viewMatrix = frameCtx.pickViewMatrix || camera.viewMatrix; + const projMatrix = frameCtx.pickProjMatrix || camera.projMatrix; + const eye = frameCtx.pickOrigin || camera.eye; + const far = frameCtx.pickProjMatrix ? frameCtx.pickZFar : camera.project.far; + textureState.bindCommonTextures( this._program, this.uTexturePerObjectPositionsDecodeMatrix, @@ -77737,24 +77752,24 @@ class DTXTrianglesPickNormalsFlatRenderer { rtcOrigin[0] += position[0]; rtcOrigin[1] += position[1]; rtcOrigin[2] += position[2]; - rtcViewMatrix = createRTCViewMat(camera.viewMatrix, rtcOrigin, tempMat4a$1); + rtcViewMatrix = createRTCViewMat(viewMatrix, rtcOrigin, tempMat4a$1); rtcCameraEye = tempVec3c$5; - rtcCameraEye[0] = camera.eye[0] - rtcOrigin[0]; - rtcCameraEye[1] = camera.eye[1] - rtcOrigin[1]; - rtcCameraEye[2] = camera.eye[2] - rtcOrigin[2]; + rtcCameraEye[0] = eye[0] - rtcOrigin[0]; + rtcCameraEye[1] = eye[1] - rtcOrigin[1]; + rtcCameraEye[2] = eye[2] - rtcOrigin[2]; } else { - rtcViewMatrix = camera.viewMatrix; // TODO: make pickMatrix - rtcCameraEye = camera.eye; + rtcViewMatrix = viewMatrix; + rtcCameraEye = eye; } gl.uniform2fv(this._uPickClipPos, frameCtx.pickClipPos); gl.uniform2f(this._uDrawingBufferSize, gl.drawingBufferWidth, gl.drawingBufferHeight); gl.uniformMatrix4fv(this._uSceneModelMatrix, false, rotationMatrixConjugate); gl.uniformMatrix4fv(this._uViewMatrix, false, rtcViewMatrix); - gl.uniformMatrix4fv(this._uProjMatrix, false, camera.projMatrix); // TODO: pickProjMatrix + gl.uniformMatrix4fv(this._uProjMatrix, false, projMatrix); gl.uniform3fv(this._uCameraEyeRtc, rtcCameraEye); gl.uniform1i(this._uRenderPass, renderPass); if (scene.logarithmicDepthBufferEnabled) { - const logDepthBufFC = 2.0 / (Math.log(frameCtx.pickZFar + 1.0) / Math.LN2); + const logDepthBufFC = 2.0 / (Math.log(far + 1.0) / Math.LN2); gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC); } const numAllocatedSectionPlanes = scene._sectionPlanesState.getNumAllocatedSectionPlanes(); @@ -79298,7 +79313,7 @@ const INDICES_EDGE_INDICES_ALIGNEMENT_SIZE = 8; */ const MAX_OBJECT_UPDATES_IN_FRAME_WITHOUT_BATCHED_UPDATE = 10; -const tempVec4a$5 = math.vec4(); +const tempVec4a$6 = math.vec4(); const tempMat4a = new Float32Array(16); const tempUint8Array4 = new Uint8Array(4); const tempFloat32Array3 = new Float32Array(3); @@ -80375,7 +80390,7 @@ class DTXTrianglesLayer { const offsetX = origin[0] ; const offsetY = origin[1] ; const offsetZ = origin[2] ; - const worldPos = tempVec4a$5; + const worldPos = tempVec4a$6; for (let i = 0, len = positions.length; i < len; i += 3) { worldPos[0] = positions[i]; worldPos[1] = positions[i + 1]; @@ -96489,8 +96504,8 @@ const tempVec3a$7 = math.vec3(); const tempVec3b$4 = math.vec3(); const tempVec3c$3 = math.vec3(); -const tempVec4a$4 = math.vec4(); -const tempVec4b$4 = math.vec4(); +const tempVec4a$5 = math.vec4(); +const tempVec4b$5 = math.vec4(); const tempVec4c$1 = math.vec4(); /** @@ -96529,7 +96544,7 @@ class PanController { camera.ortho.scale = camera.ortho.scale - dollyDelta; - const unprojectedWorldPos = this._unproject(targetCanvasPos, tempVec4a$4); + const unprojectedWorldPos = this._unproject(targetCanvasPos, tempVec4a$5); const offset = math.subVec3(unprojectedWorldPos, camera.eye, tempVec4c$1); const moveVec = math.mulVec3Scalar(math.normalizeVec3(offset), -dollyDelta, []); @@ -96556,12 +96571,12 @@ class PanController { // - get the vector in which we're dollying; // - add both vectors to camera eye and look. - const worldPos1 = this._unproject(targetCanvasPos, tempVec4a$4); + const worldPos1 = this._unproject(targetCanvasPos, tempVec4a$5); camera.ortho.scale = camera.ortho.scale - dollyDelta; camera.ortho._update(); // HACK - const worldPos2 = this._unproject(targetCanvasPos, tempVec4b$4); + const worldPos2 = this._unproject(targetCanvasPos, tempVec4b$5); const offset = math.subVec3(worldPos2, worldPos1, tempVec4c$1); const eyeLookMoveVec = math.mulVec3Scalar(math.normalizeVec3(math.subVec3(camera.look, camera.eye, tempVec3a$7)), -dollyDelta, tempVec3b$4); const moveVec = math.addVec3(offset, eyeLookMoveVec, tempVec3c$3); @@ -96595,8 +96610,8 @@ const tempVec3a$6 = math.vec3(); const tempVec3b$3 = math.vec3(); const tempVec3c$2 = math.vec3(); -const tempVec4a$3 = math.vec4(); -const tempVec4b$3 = math.vec4(); +const tempVec4a$4 = math.vec4(); +const tempVec4b$4 = math.vec4(); const tempVec4c = math.vec4(); @@ -96849,8 +96864,8 @@ class PivotController { const Pt4 = transposedProjectMat.subarray(12); const D = [0, 0, -1.0, 1]; const screenZ = math.dotVec4(D, Pt3) / math.dotVec4(D, Pt4); - const worldPos = tempVec4a$3; - camera.project.unproject(canvasPos, screenZ, tempVec4b$3, tempVec4c, worldPos); + const worldPos = tempVec4a$4; + camera.project.unproject(canvasPos, screenZ, tempVec4b$4, tempVec4c, worldPos); const eyeWorldPosVec = math.normalizeVec3(math.subVec3(worldPos, camera.eye, tempVec3a$6)); const posOnSphere = math.addVec3(camera.eye, math.mulVec3Scalar(eyeWorldPosVec, pivotShereRadius, tempVec3b$3), tempVec3c$2); this.setPivotPos(posOnSphere); @@ -128128,7 +128143,7 @@ if (!pako$9.inflate) { // See https://github.com/nodeca/pako/issues/97 pako$9 = pako$9.default; } -const decompressColor$9 = (function () { +const decompressColor$a = (function () { const color2 = new Float32Array(3); return function (color) { color2[0] = color[0] / 255.0; @@ -128172,7 +128187,7 @@ function inflate$9(deflatedData) { }; } -function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$a(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { manifestCtx.getNextId(); @@ -128241,7 +128256,7 @@ function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const lastMesh = (j === (numMeshes - 1)); const meshId = entityId + ".mesh." + j; - const color = decompressColor$9(meshColors.subarray((j * 4), (j * 4) + 3)); + const color = decompressColor$a(meshColors.subarray((j * 4), (j * 4) + 3)); const opacity = meshColors[(j * 4) + 3] / 255.0; sceneModel.createMesh(utils.apply(meshDefaults, { @@ -128273,7 +128288,7 @@ const ParserV1 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$9(elements); const inflatedData = inflate$9(deflatedData); - load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$a(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -128341,6 +128356,222 @@ function inflate$8(deflatedData) { }; } +const decompressColor$9 = (function () { + const color2 = new Float32Array(3); + return function (color) { + color2[0] = color[0] / 255.0; + color2[1] = color[1] / 255.0; + color2[2] = color[2] / 255.0; + return color2; + }; +})(); + +function load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { + + const modelPartId = manifestCtx.getNextId(); + + sceneModel.positionsCompression = "precompressed"; + sceneModel.normalsCompression = "precompressed"; + + const positions = inflatedData.positions; + const normals = inflatedData.normals; + const indices = inflatedData.indices; + const edgeIndices = inflatedData.edgeIndices; + const meshPositions = inflatedData.meshPositions; + const meshIndices = inflatedData.meshIndices; + const meshEdgesIndices = inflatedData.meshEdgesIndices; + const meshColors = inflatedData.meshColors; + const entityIDs = JSON.parse(inflatedData.entityIDs); + const entityMeshes = inflatedData.entityMeshes; + const entityIsObjects = inflatedData.entityIsObjects; + const entityMeshIds = inflatedData.entityMeshIds; + const entityMatrices = inflatedData.entityMatrices; + const entityUsesInstancing = inflatedData.entityUsesInstancing; + + const numMeshes = meshPositions.length; + const numEntities = entityMeshes.length; + + const alreadyCreatedGeometries = {}; + + for (let i = 0; i < numEntities; i++) { + + const xktEntityId = entityIDs [i]; + const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId; + const metaObject = viewer.metaScene.metaObjects[entityId]; + const entityDefaults = {}; + const meshDefaults = {}; + const entityMatrix = entityMatrices.subarray((i * 16), (i * 16) + 16); + + if (metaObject) { + if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) { + continue; + } + if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) { + continue; + } + const 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; + } + } + } else { + if (options.excludeUnclassifiedObjects) { + continue; + } + } + + const lastEntity = (i === numEntities - 1); + + const meshIds = []; + + for (let j = entityMeshes [i], jlen = lastEntity ? entityMeshIds.length : entityMeshes [i + 1]; j < jlen; j++) { + + const jj = entityMeshIds [j]; + + const lastMesh = (jj === (numMeshes - 1)); + const meshId = manifestCtx.getNextId(); + + const color = decompressColor$9(meshColors.subarray((jj * 4), (jj * 4) + 3)); + const opacity = meshColors[(jj * 4) + 3] / 255.0; + + const tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); + const tmpNormals = normals.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); + const tmpIndices = indices.subarray(meshIndices [jj], lastMesh ? indices.length : meshIndices [jj + 1]); + const tmpEdgeIndices = edgeIndices.subarray(meshEdgesIndices [jj], lastMesh ? edgeIndices.length : meshEdgesIndices [jj + 1]); + + if (entityUsesInstancing [i] === 1) { + + const geometryId = `${modelPartId}.geometry.${meshId}.${jj}`; + + if (!(geometryId in alreadyCreatedGeometries)) { + + sceneModel.createGeometry({ + id: geometryId, + positionsCompressed: tmpPositions, + normalsCompressed: tmpNormals, + indices: tmpIndices, + edgeIndices: tmpEdgeIndices, + primitive: "triangles", + positionsDecodeMatrix: inflatedData.positionsDecodeMatrix, + }); + + alreadyCreatedGeometries [geometryId] = true; + } + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + color: color, + opacity: opacity, + matrix: entityMatrix, + geometryId, + })); + + meshIds.push(meshId); + + } else { + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + primitive: "triangles", + positionsCompressed: tmpPositions, + normalsCompressed: tmpNormals, + indices: tmpIndices, + edgeIndices: tmpEdgeIndices, + positionsDecodeMatrix: inflatedData.positionsDecodeMatrix, + color: color, + opacity: opacity + })); + + meshIds.push(meshId); + } + } + + if (meshIds.length) { + + sceneModel.createEntity(utils.apply(entityDefaults, { + id: entityId, + isObject: (entityIsObjects [i] === 1), + meshIds: meshIds + })); + } + } +} + +/** @private */ +const ParserV2 = { + version: 2, + parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { + const deflatedData = extract$8(elements); + const inflatedData = inflate$8(deflatedData); + load$9(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + } +}; + +/* + +Parser for .XKT Format V3 + +.XKT specifications: https://github.com/xeokit/xeokit-sdk/wiki/XKT-Format + + */ + +let pako$7 = window.pako || p; +if (!pako$7.inflate) { // See https://github.com/nodeca/pako/issues/97 + pako$7 = pako$7.default; +} + +function extract$7(elements) { + return { + positions: elements[0], + normals: elements[1], + indices: elements[2], + edgeIndices: elements[3], + meshPositions: elements[4], + meshIndices: elements[5], + meshEdgesIndices: elements[6], + meshColors: elements[7], + entityIDs: elements[8], + entityMeshes: elements[9], + entityIsObjects: elements[10], + instancedPositionsDecodeMatrix: elements[11], + batchedPositionsDecodeMatrix: elements[12], + entityMeshIds: elements[13], + entityMatrices: elements[14], + entityUsesInstancing: elements[15] + }; +} + +function inflate$7(deflatedData) { + return { + positions: new Uint16Array(pako$7.inflate(deflatedData.positions).buffer), + normals: new Int8Array(pako$7.inflate(deflatedData.normals).buffer), + indices: new Uint32Array(pako$7.inflate(deflatedData.indices).buffer), + edgeIndices: new Uint32Array(pako$7.inflate(deflatedData.edgeIndices).buffer), + meshPositions: new Uint32Array(pako$7.inflate(deflatedData.meshPositions).buffer), + meshIndices: new Uint32Array(pako$7.inflate(deflatedData.meshIndices).buffer), + meshEdgesIndices: new Uint32Array(pako$7.inflate(deflatedData.meshEdgesIndices).buffer), + meshColors: new Uint8Array(pako$7.inflate(deflatedData.meshColors).buffer), + entityIDs: pako$7.inflate(deflatedData.entityIDs, {to: 'string'}), + entityMeshes: new Uint32Array(pako$7.inflate(deflatedData.entityMeshes).buffer), + entityIsObjects: new Uint8Array(pako$7.inflate(deflatedData.entityIsObjects).buffer), + instancedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.instancedPositionsDecodeMatrix).buffer), + batchedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.batchedPositionsDecodeMatrix).buffer), + entityMeshIds: new Uint32Array(pako$7.inflate(deflatedData.entityMeshIds).buffer), + entityMatrices: new Float32Array(pako$7.inflate(deflatedData.entityMatrices).buffer), + entityUsesInstancing: new Uint8Array(pako$7.inflate(deflatedData.entityUsesInstancing).buffer) + }; +} + const decompressColor$8 = (function () { const color2 = new Float32Array(3); return function (color) { @@ -128376,222 +128607,6 @@ function load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const numMeshes = meshPositions.length; const numEntities = entityMeshes.length; - const alreadyCreatedGeometries = {}; - - for (let i = 0; i < numEntities; i++) { - - const xktEntityId = entityIDs [i]; - const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId; - const metaObject = viewer.metaScene.metaObjects[entityId]; - const entityDefaults = {}; - const meshDefaults = {}; - const entityMatrix = entityMatrices.subarray((i * 16), (i * 16) + 16); - - if (metaObject) { - if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) { - continue; - } - if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) { - continue; - } - const 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; - } - } - } else { - if (options.excludeUnclassifiedObjects) { - continue; - } - } - - const lastEntity = (i === numEntities - 1); - - const meshIds = []; - - for (let j = entityMeshes [i], jlen = lastEntity ? entityMeshIds.length : entityMeshes [i + 1]; j < jlen; j++) { - - const jj = entityMeshIds [j]; - - const lastMesh = (jj === (numMeshes - 1)); - const meshId = manifestCtx.getNextId(); - - const color = decompressColor$8(meshColors.subarray((jj * 4), (jj * 4) + 3)); - const opacity = meshColors[(jj * 4) + 3] / 255.0; - - const tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); - const tmpNormals = normals.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); - const tmpIndices = indices.subarray(meshIndices [jj], lastMesh ? indices.length : meshIndices [jj + 1]); - const tmpEdgeIndices = edgeIndices.subarray(meshEdgesIndices [jj], lastMesh ? edgeIndices.length : meshEdgesIndices [jj + 1]); - - if (entityUsesInstancing [i] === 1) { - - const geometryId = `${modelPartId}.geometry.${meshId}.${jj}`; - - if (!(geometryId in alreadyCreatedGeometries)) { - - sceneModel.createGeometry({ - id: geometryId, - positionsCompressed: tmpPositions, - normalsCompressed: tmpNormals, - indices: tmpIndices, - edgeIndices: tmpEdgeIndices, - primitive: "triangles", - positionsDecodeMatrix: inflatedData.positionsDecodeMatrix, - }); - - alreadyCreatedGeometries [geometryId] = true; - } - - sceneModel.createMesh(utils.apply(meshDefaults, { - id: meshId, - color: color, - opacity: opacity, - matrix: entityMatrix, - geometryId, - })); - - meshIds.push(meshId); - - } else { - - sceneModel.createMesh(utils.apply(meshDefaults, { - id: meshId, - primitive: "triangles", - positionsCompressed: tmpPositions, - normalsCompressed: tmpNormals, - indices: tmpIndices, - edgeIndices: tmpEdgeIndices, - positionsDecodeMatrix: inflatedData.positionsDecodeMatrix, - color: color, - opacity: opacity - })); - - meshIds.push(meshId); - } - } - - if (meshIds.length) { - - sceneModel.createEntity(utils.apply(entityDefaults, { - id: entityId, - isObject: (entityIsObjects [i] === 1), - meshIds: meshIds - })); - } - } -} - -/** @private */ -const ParserV2 = { - version: 2, - parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { - const deflatedData = extract$8(elements); - const inflatedData = inflate$8(deflatedData); - load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); - } -}; - -/* - -Parser for .XKT Format V3 - -.XKT specifications: https://github.com/xeokit/xeokit-sdk/wiki/XKT-Format - - */ - -let pako$7 = window.pako || p; -if (!pako$7.inflate) { // See https://github.com/nodeca/pako/issues/97 - pako$7 = pako$7.default; -} - -function extract$7(elements) { - return { - positions: elements[0], - normals: elements[1], - indices: elements[2], - edgeIndices: elements[3], - meshPositions: elements[4], - meshIndices: elements[5], - meshEdgesIndices: elements[6], - meshColors: elements[7], - entityIDs: elements[8], - entityMeshes: elements[9], - entityIsObjects: elements[10], - instancedPositionsDecodeMatrix: elements[11], - batchedPositionsDecodeMatrix: elements[12], - entityMeshIds: elements[13], - entityMatrices: elements[14], - entityUsesInstancing: elements[15] - }; -} - -function inflate$7(deflatedData) { - return { - positions: new Uint16Array(pako$7.inflate(deflatedData.positions).buffer), - normals: new Int8Array(pako$7.inflate(deflatedData.normals).buffer), - indices: new Uint32Array(pako$7.inflate(deflatedData.indices).buffer), - edgeIndices: new Uint32Array(pako$7.inflate(deflatedData.edgeIndices).buffer), - meshPositions: new Uint32Array(pako$7.inflate(deflatedData.meshPositions).buffer), - meshIndices: new Uint32Array(pako$7.inflate(deflatedData.meshIndices).buffer), - meshEdgesIndices: new Uint32Array(pako$7.inflate(deflatedData.meshEdgesIndices).buffer), - meshColors: new Uint8Array(pako$7.inflate(deflatedData.meshColors).buffer), - entityIDs: pako$7.inflate(deflatedData.entityIDs, {to: 'string'}), - entityMeshes: new Uint32Array(pako$7.inflate(deflatedData.entityMeshes).buffer), - entityIsObjects: new Uint8Array(pako$7.inflate(deflatedData.entityIsObjects).buffer), - instancedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.instancedPositionsDecodeMatrix).buffer), - batchedPositionsDecodeMatrix: new Float32Array(pako$7.inflate(deflatedData.batchedPositionsDecodeMatrix).buffer), - entityMeshIds: new Uint32Array(pako$7.inflate(deflatedData.entityMeshIds).buffer), - entityMatrices: new Float32Array(pako$7.inflate(deflatedData.entityMatrices).buffer), - entityUsesInstancing: new Uint8Array(pako$7.inflate(deflatedData.entityUsesInstancing).buffer) - }; -} - -const decompressColor$7 = (function () { - const color2 = new Float32Array(3); - return function (color) { - color2[0] = color[0] / 255.0; - color2[1] = color[1] / 255.0; - color2[2] = color[2] / 255.0; - return color2; - }; -})(); - -function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { - - const modelPartId = manifestCtx.getNextId(); - - sceneModel.positionsCompression = "precompressed"; - sceneModel.normalsCompression = "precompressed"; - - const positions = inflatedData.positions; - const normals = inflatedData.normals; - const indices = inflatedData.indices; - const edgeIndices = inflatedData.edgeIndices; - const meshPositions = inflatedData.meshPositions; - const meshIndices = inflatedData.meshIndices; - const meshEdgesIndices = inflatedData.meshEdgesIndices; - const meshColors = inflatedData.meshColors; - const entityIDs = JSON.parse(inflatedData.entityIDs); - const entityMeshes = inflatedData.entityMeshes; - const entityIsObjects = inflatedData.entityIsObjects; - const entityMeshIds = inflatedData.entityMeshIds; - const entityMatrices = inflatedData.entityMatrices; - const entityUsesInstancing = inflatedData.entityUsesInstancing; - - const numMeshes = meshPositions.length; - const numEntities = entityMeshes.length; - const _alreadyCreatedGeometries = {}; for (let i = 0; i < numEntities; i++) { @@ -128645,7 +128660,7 @@ function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const lastMesh = (jj === (numMeshes - 1)); const meshId = `${modelPartId}.${entityId}.mesh.${jj}`; - const color = decompressColor$7(meshColors.subarray((jj * 4), (jj * 4) + 3)); + const color = decompressColor$8(meshColors.subarray((jj * 4), (jj * 4) + 3)); const opacity = meshColors[(jj * 4) + 3] / 255.0; var tmpPositions = positions.subarray(meshPositions [jj], lastMesh ? positions.length : meshPositions [jj + 1]); @@ -128716,7 +128731,7 @@ const ParserV3 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$7(elements); const inflatedData = inflate$7(deflatedData); - load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$8(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -128774,7 +128789,7 @@ function inflate$6(deflatedData) { }; } -const decompressColor$6 = (function () { +const decompressColor$7 = (function () { const color2 = new Float32Array(3); return function (color) { color2[0] = color[0] / 255.0; @@ -128784,7 +128799,7 @@ const decompressColor$6 = (function () { }; })(); -function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -128880,7 +128895,7 @@ function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const primitiveInstanceCount = primitiveInstanceCounts[orderedPrimitiveIndex]; const isInstancedPrimitive = (primitiveInstanceCount > 1); - const color = decompressColor$6(eachPrimitiveColor.subarray((orderedPrimitiveIndex * 4), (orderedPrimitiveIndex * 4) + 3)); + const color = decompressColor$7(eachPrimitiveColor.subarray((orderedPrimitiveIndex * 4), (orderedPrimitiveIndex * 4) + 3)); const opacity = eachPrimitiveColor[(orderedPrimitiveIndex * 4) + 3] / 255.0; const primitivePositions = positions.subarray(eachPrimitivePositionsAndNormalsPortion [orderedPrimitiveIndex], atLastPrimitive ? positions.length : eachPrimitivePositionsAndNormalsPortion [orderedPrimitiveIndex + 1]); @@ -128990,7 +129005,7 @@ const ParserV4 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$6(elements); const inflatedData = inflate$6(deflatedData); - load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$7(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -129043,7 +129058,7 @@ function inflate$5(deflatedData) { }; } -const decompressColor$5 = (function () { +const decompressColor$6 = (function () { const color2 = new Float32Array(3); return function (color) { color2[0] = color[0] / 255.0; @@ -129053,7 +129068,7 @@ const decompressColor$5 = (function () { }; })(); -function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -129122,7 +129137,7 @@ function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const primitiveInstanceCount = primitiveInstanceCounts[primitiveIndex]; const isInstancedPrimitive = (primitiveInstanceCount > 1); - const color = decompressColor$5(eachPrimitiveColor.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3)); + const color = decompressColor$6(eachPrimitiveColor.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3)); const opacity = eachPrimitiveColor[(primitiveIndex * 4) + 3] / 255.0; const primitivePositions = positions.subarray(eachPrimitivePositionsAndNormalsPortion [primitiveIndex], atLastPrimitive ? positions.length : eachPrimitivePositionsAndNormalsPortion [primitiveIndex + 1]); @@ -129228,7 +129243,7 @@ const ParserV5 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$5(elements); const inflatedData = inflate$5(deflatedData); - load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$6(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -129291,7 +129306,7 @@ function inflate$4(deflatedData) { }; } -const decompressColor$4 = (function () { +const decompressColor$5 = (function () { const floatColor = new Float32Array(3); return function (intColor) { floatColor[0] = intColor[0] / 255.0; @@ -129301,7 +129316,7 @@ const decompressColor$4 = (function () { }; })(); -function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -129449,7 +129464,7 @@ function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const primitiveIndices = indices.subarray(eachPrimitiveIndicesPortion [primitiveIndex], atLastPrimitive ? indices.length : eachPrimitiveIndicesPortion [primitiveIndex + 1]); const primitiveEdgeIndices = edgeIndices.subarray(eachPrimitiveEdgeIndicesPortion [primitiveIndex], atLastPrimitive ? edgeIndices.length : eachPrimitiveEdgeIndicesPortion [primitiveIndex + 1]); - const color = decompressColor$4(eachPrimitiveColorAndOpacity.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3)); + const color = decompressColor$5(eachPrimitiveColorAndOpacity.subarray((primitiveIndex * 4), (primitiveIndex * 4) + 3)); const opacity = eachPrimitiveColorAndOpacity[(primitiveIndex * 4) + 3] / 255.0; const meshId = manifestCtx.getNextId(); @@ -129523,7 +129538,7 @@ const ParserV6 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$4(elements); const inflatedData = inflate$4(deflatedData); - load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$5(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -129621,7 +129636,7 @@ function inflate$3(deflatedData) { }; } -const decompressColor$3 = (function () { +const decompressColor$4 = (function () { const floatColor = new Float32Array(3); return function (intColor) { floatColor[0] = intColor[0] / 255.0; @@ -129642,7 +129657,7 @@ function convertColorsRGBToRGBA$1(colorsRGB) { return colorsRGBA; } -function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -129793,7 +129808,7 @@ function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const atLastGeometry = (geometryIndex === (numGeometries - 1)); - const meshColor = decompressColor$3(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); + const meshColor = decompressColor$4(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0; const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0; const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0; @@ -129954,7 +129969,7 @@ const ParserV7 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$3(elements); const inflatedData = inflate$3(deflatedData); - load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$4(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -129969,8 +129984,8 @@ if (!pako$2.inflate) { // See https://github.com/nodeca/pako/issues/97 pako$2 = pako$2.default; } -const tempVec4a$2 = math.vec4(); -const tempVec4b$2 = math.vec4(); +const tempVec4a$3 = math.vec4(); +const tempVec4b$3 = math.vec4(); function extract$2(elements) { @@ -130062,7 +130077,7 @@ function inflate$2(deflatedData) { }; } -const decompressColor$2 = (function () { +const decompressColor$3 = (function () { const floatColor = new Float32Array(3); return function (intColor) { floatColor[0] = intColor[0] / 255.0; @@ -130083,7 +130098,7 @@ function convertColorsRGBToRGBA(colorsRGB) { return colorsRGBA; } -function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -130269,7 +130284,7 @@ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const atLastGeometry = (geometryIndex === (numGeometries - 1)); - const meshColor = decompressColor$2(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); + const meshColor = decompressColor$3(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0; const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0; const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0; @@ -130358,15 +130373,15 @@ function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const decompressedPositions = geometryArrays.decompressedPositions; const positions = new Uint16Array(decompressedPositions.length); for (let i = 0, len = decompressedPositions.length; i < len; i += 3) { - tempVec4a$2[0] = decompressedPositions[i + 0]; - tempVec4a$2[1] = decompressedPositions[i + 1]; - tempVec4a$2[2] = decompressedPositions[i + 2]; - tempVec4a$2[3] = 1; - math.transformVec4(meshMatrix, tempVec4a$2, tempVec4b$2); - geometryCompressionUtils.compressPosition(tempVec4b$2, rtcAABB, tempVec4a$2); - positions[i + 0] = tempVec4a$2[0]; - positions[i + 1] = tempVec4a$2[1]; - positions[i + 2] = tempVec4a$2[2]; + tempVec4a$3[0] = decompressedPositions[i + 0]; + tempVec4a$3[1] = decompressedPositions[i + 1]; + tempVec4a$3[2] = decompressedPositions[i + 2]; + tempVec4a$3[3] = 1; + math.transformVec4(meshMatrix, tempVec4a$3, tempVec4b$3); + geometryCompressionUtils.compressPosition(tempVec4b$3, rtcAABB, tempVec4a$3); + positions[i + 0] = tempVec4a$3[0]; + positions[i + 1] = tempVec4a$3[1]; + positions[i + 2] = tempVec4a$3[2]; } sceneModel.createMesh(utils.apply(meshDefaults, { @@ -130506,7 +130521,7 @@ const ParserV8 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$2(elements); const inflatedData = inflate$2(deflatedData); - load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$3(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -130521,8 +130536,8 @@ if (!pako$1.inflate) { // See https://github.com/nodeca/pako/issues/97 pako$1 = pako$1.default; } -const tempVec4a$1 = math.vec4(); -const tempVec4b$1 = math.vec4(); +const tempVec4a$2 = math.vec4(); +const tempVec4b$2 = math.vec4(); function extract$1(elements) { @@ -130606,7 +130621,7 @@ function inflate$1(deflatedData) { }; } -const decompressColor$1 = (function () { +const decompressColor$2 = (function () { const floatColor = new Float32Array(3); return function (intColor) { floatColor[0] = intColor[0] / 255.0; @@ -130616,7 +130631,7 @@ const decompressColor$1 = (function () { }; })(); -function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { +function load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { const modelPartId = manifestCtx.getNextId(); @@ -130778,7 +130793,7 @@ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const atLastGeometry = (geometryIndex === (numGeometries - 1)); - const meshColor = decompressColor$1(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); + const meshColor = decompressColor$2(eachMeshMaterial.subarray((meshIndex * 6), (meshIndex * 6) + 3)); const meshOpacity = eachMeshMaterial[(meshIndex * 6) + 3] / 255.0; const meshMetallic = eachMeshMaterial[(meshIndex * 6) + 4] / 255.0; const meshRoughness = eachMeshMaterial[(meshIndex * 6) + 5] / 255.0; @@ -130865,15 +130880,15 @@ function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCt const transformedAndRecompressedPositions = geometryArrays.transformedAndRecompressedPositions; for (let i = 0, len = decompressedPositions.length; i < len; i += 3) { - tempVec4a$1[0] = decompressedPositions[i + 0]; - tempVec4a$1[1] = decompressedPositions[i + 1]; - tempVec4a$1[2] = decompressedPositions[i + 2]; - tempVec4a$1[3] = 1; - math.transformVec4(meshMatrix, tempVec4a$1, tempVec4b$1); - geometryCompressionUtils.compressPosition(tempVec4b$1, rtcAABB, tempVec4a$1); - transformedAndRecompressedPositions[i + 0] = tempVec4a$1[0]; - transformedAndRecompressedPositions[i + 1] = tempVec4a$1[1]; - transformedAndRecompressedPositions[i + 2] = tempVec4a$1[2]; + tempVec4a$2[0] = decompressedPositions[i + 0]; + tempVec4a$2[1] = decompressedPositions[i + 1]; + tempVec4a$2[2] = decompressedPositions[i + 2]; + tempVec4a$2[3] = 1; + math.transformVec4(meshMatrix, tempVec4a$2, tempVec4b$2); + geometryCompressionUtils.compressPosition(tempVec4b$2, rtcAABB, tempVec4a$2); + transformedAndRecompressedPositions[i + 0] = tempVec4a$2[0]; + transformedAndRecompressedPositions[i + 1] = tempVec4a$2[1]; + transformedAndRecompressedPositions[i + 2] = tempVec4a$2[2]; } sceneModel.createMesh(utils.apply(meshDefaults, { @@ -131013,7 +131028,7 @@ const ParserV9 = { parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { const deflatedData = extract$1(elements); const inflatedData = inflate$1(deflatedData); - load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + load$2(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -131026,10 +131041,10 @@ if (!pako.inflate) { // See https://github.com/nodeca/pako/issues/97 pako = pako.default; } -const tempVec4a = math.vec4(); -const tempVec4b = math.vec4(); +const tempVec4a$1 = math.vec4(); +const tempVec4b$1 = math.vec4(); -const NUM_TEXTURE_ATTRIBUTES = 9; +const NUM_TEXTURE_ATTRIBUTES$1 = 9; function extract(elements) { @@ -131105,6 +131120,648 @@ function inflate(deflatedData) { }; } +const decompressColor$1 = (function () { + const floatColor = new Float32Array(3); + return function (intColor) { + floatColor[0] = intColor[0] / 255.0; + floatColor[1] = intColor[1] / 255.0; + floatColor[2] = intColor[2] / 255.0; + return floatColor; + }; +})(); + +((function () { + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + return function (imagedata) { + canvas.width = imagedata.width; + canvas.height = imagedata.height; + context.putImageData(imagedata, 0, 0); + return canvas.toDataURL(); + }; +}))(); + +function load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx) { + + const modelPartId = manifestCtx.getNextId(); + + const metadata = inflatedData.metadata; + const textureData = inflatedData.textureData; + const eachTextureDataPortion = inflatedData.eachTextureDataPortion; + const eachTextureAttributes = inflatedData.eachTextureAttributes; + const positions = inflatedData.positions; + const normals = inflatedData.normals; + const colors = inflatedData.colors; + const uvs = inflatedData.uvs; + const indices = inflatedData.indices; + const edgeIndices = inflatedData.edgeIndices; + const eachTextureSetTextures = inflatedData.eachTextureSetTextures; + const matrices = inflatedData.matrices; + const reusedGeometriesDecodeMatrix = inflatedData.reusedGeometriesDecodeMatrix; + const eachGeometryPrimitiveType = inflatedData.eachGeometryPrimitiveType; + const eachGeometryPositionsPortion = inflatedData.eachGeometryPositionsPortion; + const eachGeometryNormalsPortion = inflatedData.eachGeometryNormalsPortion; + const eachGeometryColorsPortion = inflatedData.eachGeometryColorsPortion; + const eachGeometryUVsPortion = inflatedData.eachGeometryUVsPortion; + const eachGeometryIndicesPortion = inflatedData.eachGeometryIndicesPortion; + const eachGeometryEdgeIndicesPortion = inflatedData.eachGeometryEdgeIndicesPortion; + const eachMeshGeometriesPortion = inflatedData.eachMeshGeometriesPortion; + const eachMeshMatricesPortion = inflatedData.eachMeshMatricesPortion; + const eachMeshTextureSet = inflatedData.eachMeshTextureSet; + const eachMeshMaterialAttributes = inflatedData.eachMeshMaterialAttributes; + const eachEntityId = inflatedData.eachEntityId; + const eachEntityMeshesPortion = inflatedData.eachEntityMeshesPortion; + const eachTileAABB = inflatedData.eachTileAABB; + const eachTileEntitiesPortion = inflatedData.eachTileEntitiesPortion; + + const numTextures = eachTextureDataPortion.length; + const numTextureSets = eachTextureSetTextures.length / 5; + const numGeometries = eachGeometryPositionsPortion.length; + const numMeshes = eachMeshGeometriesPortion.length; + const numEntities = eachEntityMeshesPortion.length; + const numTiles = eachTileEntitiesPortion.length; + + if (metaModel) { + metaModel.loadData(metadata, { + includeTypes: options.includeTypes, + excludeTypes: options.excludeTypes, + globalizeObjectIds: options.globalizeObjectIds + }); // Can be empty + } + + // Create textures + + for (let textureIndex = 0; textureIndex < numTextures; textureIndex++) { + const atLastTexture = (textureIndex === (numTextures - 1)); + const textureDataPortionStart = eachTextureDataPortion[textureIndex]; + const textureDataPortionEnd = atLastTexture ? textureData.length : (eachTextureDataPortion[textureIndex + 1]); + + const textureDataPortionSize = textureDataPortionEnd - textureDataPortionStart; + const textureDataPortionExists = (textureDataPortionSize > 0); + + const textureAttrBaseIdx = (textureIndex * NUM_TEXTURE_ATTRIBUTES$1); + + const compressed = (eachTextureAttributes[textureAttrBaseIdx + 0] === 1); + const mediaType = eachTextureAttributes[textureAttrBaseIdx + 1]; + eachTextureAttributes[textureAttrBaseIdx + 2]; + eachTextureAttributes[textureAttrBaseIdx + 3]; + const minFilter = eachTextureAttributes[textureAttrBaseIdx + 4]; + const magFilter = eachTextureAttributes[textureAttrBaseIdx + 5]; // LinearFilter | NearestFilter + const wrapS = eachTextureAttributes[textureAttrBaseIdx + 6]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping + const wrapT = eachTextureAttributes[textureAttrBaseIdx + 7]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping + const wrapR = eachTextureAttributes[textureAttrBaseIdx + 8]; // ClampToEdgeWrapping | MirroredRepeatWrapping | RepeatWrapping + + if (textureDataPortionExists) { + + const imageDataSubarray = new Uint8Array(textureData.subarray(textureDataPortionStart, textureDataPortionEnd)); + const arrayBuffer = imageDataSubarray.buffer; + const textureId = `${modelPartId}-texture-${textureIndex}`; + + if (compressed) { + + sceneModel.createTexture({ + id: textureId, + buffers: [arrayBuffer], + minFilter, + magFilter, + wrapS, + wrapT, + wrapR + }); + + } else { + + const mimeType = mediaType === JPEGMediaType ? "image/jpeg" : (mediaType === PNGMediaType ? "image/png" : "image/gif"); + const blob = new Blob([arrayBuffer], {type: mimeType}); + const urlCreator = window.URL || window.webkitURL; + const imageUrl = urlCreator.createObjectURL(blob); + const img = document.createElement('img'); + img.src = imageUrl; + + sceneModel.createTexture({ + id: textureId, + image: img, + //mediaType, + minFilter, + magFilter, + wrapS, + wrapT, + wrapR + }); + } + } + } + + // Create texture sets + + for (let textureSetIndex = 0; textureSetIndex < numTextureSets; textureSetIndex++) { + const eachTextureSetTexturesIndex = textureSetIndex * 5; + const textureSetId = `${modelPartId}-textureSet-${textureSetIndex}`; + const colorTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 0]; + const metallicRoughnessTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 1]; + const normalsTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 2]; + const emissiveTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 3]; + const occlusionTextureIndex = eachTextureSetTextures[eachTextureSetTexturesIndex + 4]; + sceneModel.createTextureSet({ + id: textureSetId, + colorTextureId: colorTextureIndex >= 0 ? `${modelPartId}-texture-${colorTextureIndex}` : null, + normalsTextureId: normalsTextureIndex >= 0 ? `${modelPartId}-texture-${normalsTextureIndex}` : null, + metallicRoughnessTextureId: metallicRoughnessTextureIndex >= 0 ? `${modelPartId}-texture-${metallicRoughnessTextureIndex}` : null, + emissiveTextureId: emissiveTextureIndex >= 0 ? `${modelPartId}-texture-${emissiveTextureIndex}` : null, + occlusionTextureId: occlusionTextureIndex >= 0 ? `${modelPartId}-texture-${occlusionTextureIndex}` : null + }); + } + + // Count instances of each geometry + + const geometryReuseCounts = new Uint32Array(numGeometries); + + for (let meshIndex = 0; meshIndex < numMeshes; meshIndex++) { + const geometryIndex = eachMeshGeometriesPortion[meshIndex]; + if (geometryReuseCounts[geometryIndex] !== undefined) { + geometryReuseCounts[geometryIndex]++; + } else { + geometryReuseCounts[geometryIndex] = 1; + } + } + + // Iterate over tiles + + const tileCenter = math.vec3(); + const rtcAABB = math.AABB3(); + + const geometryArraysCache = {}; + + for (let tileIndex = 0; tileIndex < numTiles; tileIndex++) { + + const lastTileIndex = (numTiles - 1); + + const atLastTile = (tileIndex === lastTileIndex); + + const firstTileEntityIndex = eachTileEntitiesPortion [tileIndex]; + const lastTileEntityIndex = atLastTile ? (numEntities - 1) : (eachTileEntitiesPortion[tileIndex + 1] - 1); + + const tileAABBIndex = tileIndex * 6; + const tileAABB = eachTileAABB.subarray(tileAABBIndex, tileAABBIndex + 6); + + math.getAABB3Center(tileAABB, tileCenter); + + rtcAABB[0] = tileAABB[0] - tileCenter[0]; + rtcAABB[1] = tileAABB[1] - tileCenter[1]; + rtcAABB[2] = tileAABB[2] - tileCenter[2]; + rtcAABB[3] = tileAABB[3] - tileCenter[0]; + rtcAABB[4] = tileAABB[4] - tileCenter[1]; + rtcAABB[5] = tileAABB[5] - tileCenter[2]; + + const tileDecodeMatrix = geometryCompressionUtils.createPositionsDecodeMatrix(rtcAABB); + + const geometryCreatedInTile = {}; + + // Iterate over each tile's entities + + for (let tileEntityIndex = firstTileEntityIndex; tileEntityIndex <= lastTileEntityIndex; tileEntityIndex++) { + + const xktEntityId = eachEntityId[tileEntityIndex]; + + const entityId = options.globalizeObjectIds ? math.globalizeObjectId(sceneModel.id, xktEntityId) : xktEntityId; + + const finalTileEntityIndex = (numEntities - 1); + const atLastTileEntity = (tileEntityIndex === finalTileEntityIndex); + const firstMeshIndex = eachEntityMeshesPortion [tileEntityIndex]; + const lastMeshIndex = atLastTileEntity ? (eachMeshGeometriesPortion.length - 1) : (eachEntityMeshesPortion[tileEntityIndex + 1] - 1); + + const meshIds = []; + + const metaObject = viewer.metaScene.metaObjects[entityId]; + const entityDefaults = {}; + const meshDefaults = {}; + + if (metaObject) { + + // Mask loading of object types + + if (options.excludeTypesMap && metaObject.type && options.excludeTypesMap[metaObject.type]) { + continue; + } + + if (options.includeTypesMap && metaObject.type && (!options.includeTypesMap[metaObject.type])) { + continue; + } + + // Get initial property values for object types + + const 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 + + for (let meshIndex = firstMeshIndex; meshIndex <= lastMeshIndex; meshIndex++) { + + const geometryIndex = eachMeshGeometriesPortion[meshIndex]; + const geometryReuseCount = geometryReuseCounts[geometryIndex]; + const isReusedGeometry = (geometryReuseCount > 1); + + const atLastGeometry = (geometryIndex === (numGeometries - 1)); + + const textureSetIndex = eachMeshTextureSet[meshIndex]; + + const textureSetId = (textureSetIndex >= 0) ? `${modelPartId}-textureSet-${textureSetIndex}` : null; + + const meshColor = decompressColor$1(eachMeshMaterialAttributes.subarray((meshIndex * 6), (meshIndex * 6) + 3)); + const meshOpacity = eachMeshMaterialAttributes[(meshIndex * 6) + 3] / 255.0; + const meshMetallic = eachMeshMaterialAttributes[(meshIndex * 6) + 4] / 255.0; + const meshRoughness = eachMeshMaterialAttributes[(meshIndex * 6) + 5] / 255.0; + + const meshId = manifestCtx.getNextId(); + + if (isReusedGeometry) { + + // Create mesh for multi-use geometry - create (or reuse) geometry, create mesh using that geometry + + const meshMatrixIndex = eachMeshMatricesPortion[meshIndex]; + const meshMatrix = matrices.slice(meshMatrixIndex, meshMatrixIndex + 16); + + const geometryId = `${modelPartId}-geometry.${tileIndex}.${geometryIndex}`; // These IDs are local to the SceneModel + + let geometryArrays = geometryArraysCache[geometryId]; + + if (!geometryArrays) { + geometryArrays = { + batchThisMesh: (!options.reuseGeometries) + }; + const primitiveType = eachGeometryPrimitiveType[geometryIndex]; + let geometryValid = false; + switch (primitiveType) { + case 0: + geometryArrays.primitiveName = "solid"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]); + geometryArrays.geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]); + geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryArrays.geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0); + break; + case 1: + geometryArrays.primitiveName = "surface"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]); + geometryArrays.geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]); + geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryArrays.geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0); + break; + case 2: + geometryArrays.primitiveName = "points"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryColors = colors.subarray(eachGeometryColorsPortion [geometryIndex], atLastGeometry ? colors.length : eachGeometryColorsPortion [geometryIndex + 1]); + geometryValid = (geometryArrays.geometryPositions.length > 0); + break; + case 3: + geometryArrays.primitiveName = "lines"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0); + break; + case 4: + geometryArrays.primitiveName = "lines"; + geometryArrays.geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryArrays.geometryIndices = lineStripToLines$1( + geometryArrays.geometryPositions, + indices.subarray(eachGeometryIndicesPortion [geometryIndex], + atLastGeometry + ? indices.length + : eachGeometryIndicesPortion [geometryIndex + 1])); + geometryValid = (geometryArrays.geometryPositions.length > 0 && geometryArrays.geometryIndices.length > 0); + break; + default: + continue; + } + + if (!geometryValid) { + geometryArrays = null; + } + + if (geometryArrays) { + if (geometryArrays.geometryPositions.length > 1000) ; + if (geometryArrays.batchThisMesh) { + geometryArrays.decompressedPositions = new Float32Array(geometryArrays.geometryPositions.length); + geometryArrays.transformedAndRecompressedPositions = new Uint16Array(geometryArrays.geometryPositions.length); + const geometryPositions = geometryArrays.geometryPositions; + const decompressedPositions = geometryArrays.decompressedPositions; + for (let i = 0, len = geometryPositions.length; i < len; i += 3) { + decompressedPositions[i + 0] = geometryPositions[i + 0] * reusedGeometriesDecodeMatrix[0] + reusedGeometriesDecodeMatrix[12]; + decompressedPositions[i + 1] = geometryPositions[i + 1] * reusedGeometriesDecodeMatrix[5] + reusedGeometriesDecodeMatrix[13]; + decompressedPositions[i + 2] = geometryPositions[i + 2] * reusedGeometriesDecodeMatrix[10] + reusedGeometriesDecodeMatrix[14]; + } + geometryArrays.geometryPositions = null; + geometryArraysCache[geometryId] = geometryArrays; + } + } + } + + if (geometryArrays) { + + if (geometryArrays.batchThisMesh) { + + const decompressedPositions = geometryArrays.decompressedPositions; + const transformedAndRecompressedPositions = geometryArrays.transformedAndRecompressedPositions; + + for (let i = 0, len = decompressedPositions.length; i < len; i += 3) { + tempVec4a$1[0] = decompressedPositions[i + 0]; + tempVec4a$1[1] = decompressedPositions[i + 1]; + tempVec4a$1[2] = decompressedPositions[i + 2]; + tempVec4a$1[3] = 1; + math.transformVec4(meshMatrix, tempVec4a$1, tempVec4b$1); + geometryCompressionUtils.compressPosition(tempVec4b$1, rtcAABB, tempVec4a$1); + transformedAndRecompressedPositions[i + 0] = tempVec4a$1[0]; + transformedAndRecompressedPositions[i + 1] = tempVec4a$1[1]; + transformedAndRecompressedPositions[i + 2] = tempVec4a$1[2]; + } + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + textureSetId, + 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]) { + + sceneModel.createGeometry({ + id: geometryId, + primitive: geometryArrays.primitiveName, + positionsCompressed: geometryArrays.geometryPositions, + normalsCompressed: geometryArrays.geometryNormals, + uv: geometryArrays.geometryUVs, + colorsCompressed: geometryArrays.geometryColors, + indices: geometryArrays.geometryIndices, + edgeIndices: geometryArrays.geometryEdgeIndices, + positionsDecodeMatrix: reusedGeometriesDecodeMatrix + }); + + geometryCreatedInTile[geometryId] = true; + } + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + geometryId, + textureSetId, + matrix: meshMatrix, + color: meshColor, + metallic: meshMetallic, + roughness: meshRoughness, + opacity: meshOpacity, + origin: tileCenter + })); + + meshIds.push(meshId); + } + } + + } else { // Do not reuse geometry + + const primitiveType = eachGeometryPrimitiveType[geometryIndex]; + + let primitiveName; + let geometryPositions; + let geometryNormals; + let geometryUVs; + let geometryColors; + let geometryIndices; + let geometryEdgeIndices; + let geometryValid = false; + + switch (primitiveType) { + case 0: + primitiveName = "solid"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]); + geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]); + geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0); + break; + case 1: + primitiveName = "surface"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryNormals = normals.subarray(eachGeometryNormalsPortion [geometryIndex], atLastGeometry ? normals.length : eachGeometryNormalsPortion [geometryIndex + 1]); + geometryUVs = uvs.subarray(eachGeometryUVsPortion [geometryIndex], atLastGeometry ? uvs.length : eachGeometryUVsPortion [geometryIndex + 1]); + geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryEdgeIndices = edgeIndices.subarray(eachGeometryEdgeIndicesPortion [geometryIndex], atLastGeometry ? edgeIndices.length : eachGeometryEdgeIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0); + break; + case 2: + primitiveName = "points"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryColors = colors.subarray(eachGeometryColorsPortion [geometryIndex], atLastGeometry ? colors.length : eachGeometryColorsPortion [geometryIndex + 1]); + geometryValid = (geometryPositions.length > 0); + break; + case 3: + primitiveName = "lines"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryIndices = indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry ? indices.length : eachGeometryIndicesPortion [geometryIndex + 1]); + geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0); + break; + case 4: + primitiveName = "lines"; + geometryPositions = positions.subarray(eachGeometryPositionsPortion [geometryIndex], atLastGeometry ? positions.length : eachGeometryPositionsPortion [geometryIndex + 1]); + geometryIndices = lineStripToLines$1( + geometryPositions, + indices.subarray(eachGeometryIndicesPortion [geometryIndex], atLastGeometry + ? indices.length + : eachGeometryIndicesPortion [geometryIndex + 1])); + geometryValid = (geometryPositions.length > 0 && geometryIndices.length > 0); + break; + default: + continue; + } + + if (geometryValid) { + + sceneModel.createMesh(utils.apply(meshDefaults, { + id: meshId, + textureSetId, + origin: tileCenter, + primitive: primitiveName, + positionsCompressed: geometryPositions, + normalsCompressed: geometryNormals, + uv: geometryUVs && geometryUVs.length > 0 ? geometryUVs : null, + colorsCompressed: geometryColors, + indices: geometryIndices, + edgeIndices: geometryEdgeIndices, + positionsDecodeMatrix: tileDecodeMatrix, + color: meshColor, + metallic: meshMetallic, + roughness: meshRoughness, + opacity: meshOpacity + })); + + meshIds.push(meshId); + } + } + } + + if (meshIds.length > 0) { + + sceneModel.createEntity(utils.apply(entityDefaults, { + id: entityId, + isObject: true, + meshIds: meshIds + })); + } + } + } +} + +function lineStripToLines$1(positions, indices) { + const linesIndices = []; + if (indices.length > 1) { + for (let i = 0, len = indices.length - 1; i < len; i++) { + linesIndices.push(indices[i]); + linesIndices.push(indices[i + 1]); + } + } else if (positions.length > 1) { + for (let i = 0, len = (positions.length / 3) - 1; i < len; i++) { + linesIndices.push(i); + linesIndices.push(i + 1); + } + } + return linesIndices; +} + +/** @private */ +const ParserV10 = { + version: 10, + parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { + const deflatedData = extract(elements); + const inflatedData = inflate(deflatedData); + load$1(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); + } +}; + +/* + Parser for .XKT Format V11 +*/ + +const tempVec4a = math.vec4(); +const tempVec4b = math.vec4(); + +const NUM_TEXTURE_ATTRIBUTES = 9; + +function decodeData(arrayBuffer) { + const requiresSwapFromLittleEndian = (function() { + const buffer = new ArrayBuffer(2); + new Uint16Array(buffer)[0] = 1; + return new Uint8Array(buffer)[0] !== 1; + })(); + + const nextArray = (function() { + let i = 0; + const dataView = new DataView(arrayBuffer); + return function(type) { + const idx = 1 + 2 * i++; // `1' for the version nr + const byteOffset = dataView.getUint32(idx * 4, true); + const byteLength = dataView.getUint32((idx + 1) * 4, true); + + const BPE = type.BYTES_PER_ELEMENT; + if (requiresSwapFromLittleEndian && (BPE > 1)) { + const subarray = new Uint8Array(arrayBuffer, byteOffset, byteLength); + const swaps = BPE / 2; + const cnt = subarray.length / BPE; + for (let b = 0; b < cnt; b++) { + const offset = b * BPE; + for (let j = 0; j < swaps; j++) { + const i1 = offset + j; + const i2 = offset - j + BPE - 1; + const tmp = subarray[i1]; + subarray[i1] = subarray[i2]; + subarray[i2] = tmp; + } + } + } + + return new type(arrayBuffer, byteOffset, byteLength / BPE); + }; + })(); + + const nextObject = (function() { + const decoder = new TextDecoder(); + return () => JSON.parse(decoder.decode(nextArray(Uint8Array))); + })(); + + return { + metadata: nextObject(), + textureData: nextArray(Uint8Array), // <<----------------------------- ??? ZIPPing to blame? + eachTextureDataPortion: nextArray(Uint32Array), + eachTextureAttributes: nextArray(Uint16Array), + positions: nextArray(Uint16Array), + normals: nextArray(Int8Array), + colors: nextArray(Uint8Array), + uvs: nextArray(Float32Array), + indices: nextArray(Uint32Array), + edgeIndices: nextArray(Uint32Array), + eachTextureSetTextures: nextArray(Int32Array), + matrices: nextArray(Float32Array), + reusedGeometriesDecodeMatrix: nextArray(Float32Array), + eachGeometryPrimitiveType: nextArray(Uint8Array), + eachGeometryPositionsPortion: nextArray(Uint32Array), + eachGeometryNormalsPortion: nextArray(Uint32Array), + eachGeometryColorsPortion: nextArray(Uint32Array), + eachGeometryUVsPortion: nextArray(Uint32Array), + eachGeometryIndicesPortion: nextArray(Uint32Array), + eachGeometryEdgeIndicesPortion: nextArray(Uint32Array), + eachMeshGeometriesPortion: nextArray(Uint32Array), + eachMeshMatricesPortion: nextArray(Uint32Array), + eachMeshTextureSet: nextArray(Int32Array), // Can be -1 + eachMeshMaterialAttributes: nextArray(Uint8Array), + eachEntityId: nextObject(), + eachEntityMeshesPortion: nextArray(Uint32Array), + eachTileAABB: nextArray(Float64Array), + eachTileEntitiesPortion: nextArray(Uint32Array), + }; +} + const decompressColor = (function () { const floatColor = new Float32Array(3); return function (intColor) { @@ -131656,11 +132313,15 @@ function lineStripToLines(positions, indices) { } /** @private */ -const ParserV10 = { - version: 10, - parse: function (viewer, options, elements, sceneModel, metaModel, manifestCtx) { - const deflatedData = extract(elements); - const inflatedData = inflate(deflatedData); +// V11 uses a single uncompressed Uint8Array buffer to store arrays of different types. +// To efficiently create typed arrays from this buffer, +// each typed array's source data needs to be aligned with its element byte size. +// This sometimes requires padding subarrays inside the single Uint8Array, so the byteOffset needs to be stored alongside element count. +// It is a different encoding than used in earlier versions, and requires different approach to parsing elements. +const ParserV11 = { + version: 11, + parseArrayBuffer: function (viewer, options, arrayBuffer, sceneModel, metaModel, manifestCtx) { + const inflatedData = decodeData(arrayBuffer); load(viewer, options, inflatedData, sceneModel, metaModel, manifestCtx); } }; @@ -131677,6 +132338,7 @@ parsers[ParserV7.version] = ParserV7; parsers[ParserV8.version] = ParserV8; parsers[ParserV9.version] = ParserV9; parsers[ParserV10.version] = ParserV10; +parsers[ParserV11.version] = ParserV11; /** * {@link Viewer} plugin that loads models from xeokit's optimized *````.XKT````* format. @@ -132794,6 +133456,12 @@ class XKTLoaderPlugin extends Plugin { return; } // this.log("Loading .xkt V" + xktVersion); + + if (parser.parseArrayBuffer) { + parser.parseArrayBuffer(this.viewer, options, arrayBuffer, sceneModel, metaModel, manifestCtx); + return; + } + const numElements = dataView.getUint32(4, true); const elements = []; let byteOffset = (numElements + 2) * 4; @@ -139859,7 +140527,7 @@ const mousePointSelector = function(viewer, ray2WorldPos) { const copyCanvasPos = (event, vec2) => { vec2[0] = event.clientX; vec2[1] = event.clientY; - transformToNode(canvas.ownerDocument.body, canvas, vec2); + transformToNode(canvas.ownerDocument.documentElement, canvas, vec2); return vec2; }; @@ -139934,7 +140602,7 @@ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) { const copyCanvasPos = (event, vec2) => { vec2[0] = event.clientX; vec2[1] = event.clientY; - transformToNode(canvas.ownerDocument.body, canvas, vec2); + transformToNode(canvas.ownerDocument.documentElement, canvas, vec2); return vec2; }; @@ -141228,7 +141896,7 @@ class ZoneTranslateControl extends Component { const copyCanvasPos = (event, vec2) => { vec2[0] = event.clientX; vec2[1] = event.clientY; - transformToNode(canvas.ownerDocument.body, canvas, vec2); + transformToNode(canvas.ownerDocument.documentElement, canvas, vec2); return vec2; }; diff --git a/dist/xeokit-sdk.es5.js b/dist/xeokit-sdk.es5.js index 8acbe08cd6..608b621093 100644 --- a/dist/xeokit-sdk.es5.js +++ b/dist/xeokit-sdk.es5.js @@ -2573,7 +2573,7 @@ if(lastOpacityQuantized===opacityQuantized){return;}}else{opacityQuantized=255.0 * SceneModelEntity contains triangle meshes; returns `0` otherwise. * * @returns {number} - */},{key:"surfaceArea",get:function get(){var surfaceArea=0;for(var _i43=0,len=this.meshes.length;_i43=0){surfaceArea+=_meshSurfaceArea;}}return surfaceArea>0?surfaceArea:-1;}},{key:"_getFlag",value:function _getFlag(flag){return!!(this._flags&flag);}},{key:"_finalize",value:function _finalize(){var scene=this.model.scene;if(this._isObject){if(this.visible){scene._objectVisibilityUpdated(this);}if(this.highlighted){scene._objectHighlightedUpdated(this);}if(this.xrayed){scene._objectXRayedUpdated(this);}if(this.selected){scene._objectSelectedUpdated(this);}}for(var _i44=0,len=this.meshes.length;_i44=0){surfaceArea+=_meshSurfaceArea;}}return surfaceArea>0?surfaceArea:-1;}},{key:"_getFlag",value:function _getFlag(flag){return!!(this._flags&flag);}},{key:"_finalize",value:function _finalize(){var scene=this.model.scene;if(this._isObject){if(this.visible){scene._objectVisibilityUpdated(this);}if(this.highlighted){scene._objectHighlightedUpdated(this);}if(this.xrayed){scene._objectXRayedUpdated(this);}if(this.selected){scene._objectSelectedUpdated(this);}}for(var _i44=0,len=this.meshes.length;_i44