@xeokit/xeokit-sdk 2.5.2-beta-5 → 2.5.2-beta-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17515,9 +17515,9 @@ return this;}/**
17515
17515
  * primitives. Only works while {@link DTX#enabled} is also ````true````.
17516
17516
  */function SceneModel(owner){var _this74;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,SceneModel);_this74=_super112.call(this,owner,cfg);_this74._dtxEnabled=_this74.scene.dtxEnabled&&cfg.dtxEnabled!==false;_this74._enableVertexWelding=false;// Not needed for most objects, and very expensive, so disabled
17517
17517
  _this74._enableIndexBucketing=false;// Until fixed: https://github.com/xeokit/xeokit-sdk/issues/1204
17518
- _this74._vboBatchingLayerScratchMemory=getScratchMemory();_this74._textureTranscoder=cfg.textureTranscoder||getKTX2TextureTranscoder(_this74.scene.viewer);_this74._maxGeometryBatchSize=cfg.maxGeometryBatchSize;_this74._aabb=math.collapseAABB3();_this74._aabbDirty=true;_this74._quantizationRanges={};_this74._vboInstancingLayers={};_this74._vboBatchingLayers={};_this74._dtxLayers={};_this74._meshList=[];_this74.layerList=[];// For GL state efficiency when drawing, InstancingLayers are in first part, BatchingLayers are in second
17518
+ _this74._vboBatchingLayerScratchMemory=getScratchMemory();_this74._textureTranscoder=cfg.textureTranscoder||getKTX2TextureTranscoder(_this74.scene.viewer);_this74._maxGeometryBatchSize=cfg.maxGeometryBatchSize;_this74._aabb=math.collapseAABB3();_this74._aabbDirty=true;_this74._quantizationRanges={};_this74._vboInstancingLayers={};_this74._vboBatchingLayers={};_this74._dtxLayers={};_this74.layerList=[];// For GL state efficiency when drawing, InstancingLayers are in first part, BatchingLayers are in second
17519
17519
  _this74._entityList=[];_this74._geometries={};_this74._dtxBuckets={};// Geometries with optimizations used for data texture representation
17520
- _this74._textures={};_this74._textureSets={};_this74._transforms={};_this74._meshes={};_this74._entities={};_this74._scheduledMeshes={};/** @private **/_this74.renderFlags=new RenderFlags();/**
17520
+ _this74._textures={};_this74._textureSets={};_this74._transforms={};_this74._meshes={};_this74._entities={};_this74._scheduledMeshes={};_this74._meshesCfgsBeforeMeshCreation={};/** @private **/_this74.renderFlags=new RenderFlags();/**
17521
17521
  * @private
17522
17522
  */_this74.numGeometries=0;// Number of geometries created with createGeometry()
17523
17523
  // These counts are used to avoid unnecessary render passes
@@ -18028,7 +18028,7 @@ if(!this._textureTranscoder){this.error("[createTexture] Can't create texture fr
18028
18028
  */},{key:"createTransform",value:function createTransform(cfg){if(cfg.id===undefined||cfg.id===null){this.error("[createTransform] SceneModel.createTransform() config missing: id");return;}if(this._transforms[cfg.id]){this.error("[createTransform] SceneModel already has a transform with this ID: ".concat(cfg.id));return;}var parentTransform;if(this.parentTransformId){parentTransform=this._transforms[cfg.parentTransformId];if(!parentTransform){this.error("[createTransform] SceneModel.createTransform() config missing: id");return;}}var transform=new SceneModelTransform({id:cfg.id,model:this,parentTransform:parentTransform,matrix:cfg.matrix,position:cfg.position,scale:cfg.scale,rotation:cfg.rotation,quaternion:cfg.quaternion});this._transforms[transform.id]=transform;return transform;}/**
18029
18029
  * Creates a new {@link SceneModelMesh} within this SceneModel.
18030
18030
  *
18031
- * * Stores the new SceneModelMesh in {@link SceneModel#meshes}.
18031
+ * * It prepares and saves data for a SceneModelMesh {@link SceneModel#meshes} creation. SceneModelMesh will be created only once the SceneModelEntity (which references this particular SceneModelMesh) will be created.
18032
18032
  * * The SceneModelMesh can either define its own geometry or share it with other SceneModelMeshes. To define own geometry, provide the
18033
18033
  * various geometry arrays to this method. To share a geometry, provide the ID of a geometry created earlier
18034
18034
  * with {@link SceneModel#createGeometry}.
@@ -18063,9 +18063,9 @@ if(!this._textureTranscoder){this.error("[createTexture] Can't create texture fr
18063
18063
  * @param {Number} [cfg.opacity=1] Opacity in range ````[0..1]````. Overridden by texture set ````colorTexture````.
18064
18064
  * @param {Number} [cfg.metallic=0] Metallic factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
18065
18065
  * @param {Number} [cfg.roughness=1] Roughness factor in range ````[0..1]````. Overridden by texture set ````metallicRoughnessTexture````.
18066
- * @returns {SceneModelMesh} The new mesh.
18067
- */},{key:"createMesh",value:function createMesh(cfg){if(cfg.id===undefined||cfg.id===null){this.error("[createMesh] SceneModel.createMesh() config missing: id");return;}if(this._scheduledMeshes[cfg.id]){this.error("[createMesh] SceneModel already has a mesh with this ID: ".concat(cfg.id));return;}var instancing=cfg.geometryId!==undefined;var batching=!instancing;if(batching){// Batched geometry
18068
- if(cfg.primitive===undefined||cfg.primitive===null){cfg.primitive="triangles";}if(cfg.primitive!=="points"&&cfg.primitive!=="lines"&&cfg.primitive!=="triangles"&&cfg.primitive!=="solid"&&cfg.primitive!=="surface"){this.error("Unsupported value for 'primitive': '".concat(primitive,"' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'."));return;}if(!cfg.positions&&!cfg.positionsCompressed&&!cfg.buckets){this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)");return null;}if(cfg.positions&&(cfg.positionsDecodeMatrix||cfg.positionsDecodeBoundary)){this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");return null;}if(cfg.positionsCompressed&&!cfg.positionsDecodeMatrix&&!cfg.positionsDecodeBoundary){this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");return null;}if(cfg.uvCompressed&&!cfg.uvDecodeMatrix){this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)");return null;}if(!cfg.buckets&&!cfg.indices&&cfg.primitive!=="points"){this.error("Param expected: indices (required for '".concat(cfg.primitive,"' primitive type)"));return null;}if((cfg.matrix||cfg.position||cfg.rotation||cfg.scale)&&(cfg.positionsCompressed||cfg.positionsDecodeBoundary)){this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'");return null;}var useDTX=!!this._dtxEnabled&&(cfg.primitive==="triangles"||cfg.primitive==="solid"||cfg.primitive==="surface");cfg.origin=cfg.origin?math.addVec3(this._origin,cfg.origin,math.vec3()):this._origin;// MATRIX - optional for batching
18066
+ * @returns {Boolean} True = successfully mesh was created. False = error during creation of a mesh.
18067
+ */},{key:"createMesh",value:function createMesh(cfg){if(cfg.id===undefined||cfg.id===null){this.error("[createMesh] SceneModel.createMesh() config missing: id");return false;}if(this._scheduledMeshes[cfg.id]){this.error("[createMesh] SceneModel already has a mesh with this ID: ".concat(cfg.id));return false;}var instancing=cfg.geometryId!==undefined;var batching=!instancing;if(batching){// Batched geometry
18068
+ if(cfg.primitive===undefined||cfg.primitive===null){cfg.primitive="triangles";}if(cfg.primitive!=="points"&&cfg.primitive!=="lines"&&cfg.primitive!=="triangles"&&cfg.primitive!=="solid"&&cfg.primitive!=="surface"){this.error("Unsupported value for 'primitive': '".concat(primitive,"' ('geometryId' is absent) - supported values are 'points', 'lines', 'triangles', 'solid' and 'surface'."));return false;}if(!cfg.positions&&!cfg.positionsCompressed&&!cfg.buckets){this.error("Param expected: 'positions', 'positionsCompressed' or `buckets` ('geometryId' is absent)");return false;}if(cfg.positions&&(cfg.positionsDecodeMatrix||cfg.positionsDecodeBoundary)){this.error("Illegal params: 'positions' not expected with 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");return false;}if(cfg.positionsCompressed&&!cfg.positionsDecodeMatrix&&!cfg.positionsDecodeBoundary){this.error("Param expected: 'positionsCompressed' should be accompanied by 'positionsDecodeMatrix'/'positionsDecodeBoundary' ('geometryId' is absent)");return false;}if(cfg.uvCompressed&&!cfg.uvDecodeMatrix){this.error("Param expected: 'uvCompressed' should be accompanied by `uvDecodeMatrix` ('geometryId' is absent)");return false;}if(!cfg.buckets&&!cfg.indices&&cfg.primitive!=="points"){this.error("Param expected: indices (required for '".concat(cfg.primitive,"' primitive type)"));return false;}if((cfg.matrix||cfg.position||cfg.rotation||cfg.scale)&&(cfg.positionsCompressed||cfg.positionsDecodeBoundary)){this.error("Unexpected params: 'matrix', 'rotation', 'scale', 'position' not allowed with 'positionsCompressed'");return false;}var useDTX=!!this._dtxEnabled&&(cfg.primitive==="triangles"||cfg.primitive==="solid"||cfg.primitive==="surface");cfg.origin=cfg.origin?math.addVec3(this._origin,cfg.origin,math.vec3()):this._origin;// MATRIX - optional for batching
18069
18069
  if(cfg.matrix){cfg.meshMatrix=cfg.matrix;}else if(cfg.scale||cfg.rotation||cfg.position){var _scale3=cfg.scale||DEFAULT_SCALE;var _position=cfg.position||DEFAULT_POSITION;var rotation=cfg.rotation||DEFAULT_ROTATION;math.eulerToQuaternion(rotation,"XYZ",DEFAULT_QUATERNION);cfg.meshMatrix=math.composeMat4(_position,DEFAULT_QUATERNION,_scale3,math.mat4());}if(cfg.positionsDecodeBoundary){cfg.positionsDecodeMatrix=createPositionsDecodeMatrix(cfg.positionsDecodeBoundary,math.mat4());}if(useDTX){// DTX
18070
18070
  cfg.type=DTX;// NPR
18071
18071
  cfg.color=cfg.color?new Uint8Array([Math.floor(cfg.color[0]*255),Math.floor(cfg.color[1]*255),Math.floor(cfg.color[2]*255)]):defaultCompressedColor;cfg.opacity=cfg.opacity!==undefined&&cfg.opacity!==null?Math.floor(cfg.opacity*255):255;// RTC
@@ -18080,9 +18080,9 @@ if(cfg.positions){var _rtcPositions=[];var _rtcNeeded=worldToRTCPositions(cfg.po
18080
18080
  }math.expandAABB3Points3(_aabb5,cfg.positions);cfg.aabb=_aabb5;}else{var _aabb6=math.collapseAABB3();math.expandAABB3Points3(_aabb6,cfg.positionsCompressed);geometryCompressionUtils.decompressAABB(_aabb6,cfg.positionsDecodeMatrix);cfg.aabb=_aabb6;}if(cfg.meshMatrix){math.AABB3ToOBB3(cfg.aabb,tempOBB3);math.transformOBB3(cfg.meshMatrix,tempOBB3);math.OBB3ToAABB3(tempOBB3,cfg.aabb);}// EDGES
18081
18081
  if(!cfg.buckets&&!cfg.edgeIndices&&(cfg.primitive==="triangles"||cfg.primitive==="solid"||cfg.primitive==="surface")){if(cfg.positions){cfg.edgeIndices=buildEdgeIndices(cfg.positions,cfg.indices,null,2.0);}else{cfg.edgeIndices=buildEdgeIndices(cfg.positionsCompressed,cfg.indices,cfg.positionsDecodeMatrix,2.0);}}// TEXTURE
18082
18082
  // cfg.textureSetId = cfg.textureSetId || DEFAULT_TEXTURE_SET_ID;
18083
- if(cfg.textureSetId){cfg.textureSet=this._textureSets[cfg.textureSetId];if(!cfg.textureSet){this.error("[createMesh] Texture set not found: ".concat(cfg.textureSetId," - ensure that you create it first with createTextureSet()"));return;}}}}else{// INSTANCING
18084
- if(cfg.positions||cfg.positionsCompressed||cfg.indices||cfg.edgeIndices||cfg.normals||cfg.normalsCompressed||cfg.uv||cfg.uvCompressed||cfg.positionsDecodeMatrix){this.error("Mesh geometry parameters not expected when instancing a geometry (not expected: positions, positionsCompressed, indices, edgeIndices, normals, normalsCompressed, uv, uvCompressed, positionsDecodeMatrix)");return;}cfg.geometry=this._geometries[cfg.geometryId];if(!cfg.geometry){this.error("[createMesh] Geometry not found: ".concat(cfg.geometryId," - ensure that you create it first with createGeometry()"));return;}cfg.origin=cfg.origin?math.addVec3(this._origin,cfg.origin,math.vec3()):this._origin;cfg.positionsDecodeMatrix=cfg.geometry.positionsDecodeMatrix;if(cfg.transformId){// TRANSFORM
18085
- cfg.transform=this._transforms[cfg.transformId];if(!cfg.transform){this.error("[createMesh] Transform not found: ".concat(cfg.transformId," - ensure that you create it first with createTransform()"));return;}cfg.aabb=cfg.geometry.aabb;}else{// MATRIX
18083
+ if(cfg.textureSetId){cfg.textureSet=this._textureSets[cfg.textureSetId];if(!cfg.textureSet){this.error("[createMesh] Texture set not found: ".concat(cfg.textureSetId," - ensure that you create it first with createTextureSet()"));return false;}}}}else{// INSTANCING
18084
+ if(cfg.positions||cfg.positionsCompressed||cfg.indices||cfg.edgeIndices||cfg.normals||cfg.normalsCompressed||cfg.uv||cfg.uvCompressed||cfg.positionsDecodeMatrix){this.error("Mesh geometry parameters not expected when instancing a geometry (not expected: positions, positionsCompressed, indices, edgeIndices, normals, normalsCompressed, uv, uvCompressed, positionsDecodeMatrix)");return false;}cfg.geometry=this._geometries[cfg.geometryId];if(!cfg.geometry){this.error("[createMesh] Geometry not found: ".concat(cfg.geometryId," - ensure that you create it first with createGeometry()"));return false;}cfg.origin=cfg.origin?math.addVec3(this._origin,cfg.origin,math.vec3()):this._origin;cfg.positionsDecodeMatrix=cfg.geometry.positionsDecodeMatrix;if(cfg.transformId){// TRANSFORM
18085
+ cfg.transform=this._transforms[cfg.transformId];if(!cfg.transform){this.error("[createMesh] Transform not found: ".concat(cfg.transformId," - ensure that you create it first with createTransform()"));return false;}cfg.aabb=cfg.geometry.aabb;}else{// MATRIX
18086
18086
  if(cfg.matrix){cfg.meshMatrix=cfg.matrix.slice();}else{var _scale4=cfg.scale||DEFAULT_SCALE;var _position2=cfg.position||DEFAULT_POSITION;var _rotation=cfg.rotation||DEFAULT_ROTATION;math.eulerToQuaternion(_rotation,"XYZ",DEFAULT_QUATERNION);cfg.meshMatrix=math.composeMat4(_position2,DEFAULT_QUATERNION,_scale4,math.mat4());}math.AABB3ToOBB3(cfg.geometry.aabb,tempOBB3);math.transformOBB3(cfg.meshMatrix,tempOBB3);cfg.aabb=math.OBB3ToAABB3(tempOBB3,math.AABB3());}var _useDTX=!!this._dtxEnabled&&(cfg.geometry.primitive==="triangles"||cfg.geometry.primitive==="solid"||cfg.geometry.primitive==="surface");if(_useDTX){// DTX
18087
18087
  cfg.type=DTX;// NPR
18088
18088
  cfg.color=cfg.color?new Uint8Array([Math.floor(cfg.color[0]*255),Math.floor(cfg.color[1]*255),Math.floor(cfg.color[2]*255)]):defaultCompressedColor;cfg.opacity=cfg.opacity!==undefined&&cfg.opacity!==null?Math.floor(cfg.opacity*255):255;// BUCKETING - lazy generated, reused
@@ -18091,10 +18091,10 @@ cfg.type=VBO_INSTANCED;// PBR
18091
18091
  cfg.color=cfg.color?new Uint8Array([Math.floor(cfg.color[0]*255),Math.floor(cfg.color[1]*255),Math.floor(cfg.color[2]*255)]):defaultCompressedColor;cfg.opacity=cfg.opacity!==undefined&&cfg.opacity!==null?Math.floor(cfg.opacity*255):255;cfg.metallic=cfg.metallic!==undefined&&cfg.metallic!==null?Math.floor(cfg.metallic*255):0;cfg.roughness=cfg.roughness!==undefined&&cfg.roughness!==null?Math.floor(cfg.roughness*255):255;// TEXTURE
18092
18092
  if(cfg.textureSetId){cfg.textureSet=this._textureSets[cfg.textureSetId];// if (!cfg.textureSet) {
18093
18093
  // this.error(`[createMesh] Texture set not found: ${cfg.textureSetId} - ensure that you create it first with createTextureSet()`);
18094
- // return;
18094
+ // return false;
18095
18095
  // }
18096
- }}}cfg.numPrimitives=this._getNumPrimitives(cfg);return this._createMesh(cfg);}},{key:"_createMesh",value:function _createMesh(cfg){var mesh=new SceneModelMesh(this,cfg.id,cfg.color,cfg.opacity,cfg.transform,cfg.textureSet);mesh.pickId=this.scene._renderer.getPickID(mesh);var pickId=mesh.pickId;var a=pickId>>24&0xFF;var b=pickId>>16&0xFF;var g=pickId>>8&0xFF;var r=pickId&0xFF;cfg.pickColor=new Uint8Array([r,g,b,a]);// Quantized pick color
18097
- cfg.solid=cfg.primitive==="solid";mesh.origin=math.vec3(cfg.origin);switch(cfg.type){case DTX:mesh.layer=this._getDTXLayer(cfg);mesh.aabb=cfg.aabb;break;case VBO_BATCHED:mesh.layer=this._getVBOBatchingLayer(cfg);mesh.aabb=cfg.aabb;break;case VBO_INSTANCED:mesh.layer=this._getVBOInstancingLayer(cfg);mesh.aabb=cfg.aabb;break;}if(cfg.transform){cfg.meshMatrix=cfg.transform.worldMatrix;}mesh.portionId=mesh.layer.createPortion(mesh,cfg);this._meshes[cfg.id]=mesh;this._meshList.push(mesh);return mesh;}},{key:"_getNumPrimitives",value:function _getNumPrimitives(cfg){var countIndices=0;var primitive=cfg.geometry?cfg.geometry.primitive:cfg.primitive;switch(primitive){case"triangles":case"solid":case"surface":switch(cfg.type){case DTX:for(var _i414=0,len=cfg.buckets.length;_i414<len;_i414++){countIndices+=cfg.buckets[_i414].indices.length;}break;case VBO_BATCHED:countIndices+=cfg.indices.length;break;case VBO_INSTANCED:countIndices+=cfg.geometry.indices.length;break;}return Math.round(countIndices/3);case"points":switch(cfg.type){case DTX:for(var _i415=0,_len86=cfg.buckets.length;_i415<_len86;_i415++){countIndices+=cfg.buckets[_i415].positionsCompressed.length;}break;case VBO_BATCHED:countIndices+=cfg.positions?cfg.positions.length:cfg.positionsCompressed.length;break;case VBO_INSTANCED:var geometry=cfg.geometry;countIndices+=geometry.positions?geometry.positions.length:geometry.positionsCompressed.length;break;}return Math.round(countIndices);case"lines":case"line-strip":switch(cfg.type){case DTX:for(var _i416=0,_len87=cfg.buckets.length;_i416<_len87;_i416++){countIndices+=cfg.buckets[_i416].indices.length;}break;case VBO_BATCHED:countIndices+=cfg.indices.length;break;case VBO_INSTANCED:countIndices+=cfg.geometry.indices.length;break;}return Math.round(countIndices/2);}return 0;}},{key:"_getDTXLayer",value:function _getDTXLayer(cfg){var origin=cfg.origin;var primitive=cfg.geometry?cfg.geometry.primitive:cfg.primitive;var layerId=".".concat(primitive,".").concat(Math.round(origin[0]),".").concat(Math.round(origin[1]),".").concat(Math.round(origin[2]));var dtxLayer=this._dtxLayers[layerId];if(dtxLayer){if(!dtxLayer.canCreatePortion(cfg)){dtxLayer.finalize();delete this._dtxLayers[layerId];dtxLayer=null;}else{return dtxLayer;}}switch(primitive){case"triangles":case"solid":case"surface":dtxLayer=new DTXTrianglesLayer(this,{layerIndex:0,origin:origin});// layerIndex is set in #finalize()
18096
+ }}}cfg.numPrimitives=this._getNumPrimitives(cfg);this._meshesCfgsBeforeMeshCreation[cfg.id]=cfg;return true;}},{key:"_createMesh",value:function _createMesh(cfg){var mesh=new SceneModelMesh(this,cfg.id,cfg.color,cfg.opacity,cfg.transform,cfg.textureSet);mesh.pickId=this.scene._renderer.getPickID(mesh);var pickId=mesh.pickId;var a=pickId>>24&0xFF;var b=pickId>>16&0xFF;var g=pickId>>8&0xFF;var r=pickId&0xFF;cfg.pickColor=new Uint8Array([r,g,b,a]);// Quantized pick color
18097
+ cfg.solid=cfg.primitive==="solid";mesh.origin=math.vec3(cfg.origin);switch(cfg.type){case DTX:mesh.layer=this._getDTXLayer(cfg);mesh.aabb=cfg.aabb;break;case VBO_BATCHED:mesh.layer=this._getVBOBatchingLayer(cfg);mesh.aabb=cfg.aabb;break;case VBO_INSTANCED:mesh.layer=this._getVBOInstancingLayer(cfg);mesh.aabb=cfg.aabb;break;}if(cfg.transform){cfg.meshMatrix=cfg.transform.worldMatrix;}mesh.portionId=mesh.layer.createPortion(mesh,cfg);return mesh;}},{key:"_getNumPrimitives",value:function _getNumPrimitives(cfg){var countIndices=0;var primitive=cfg.geometry?cfg.geometry.primitive:cfg.primitive;switch(primitive){case"triangles":case"solid":case"surface":switch(cfg.type){case DTX:for(var _i414=0,len=cfg.buckets.length;_i414<len;_i414++){countIndices+=cfg.buckets[_i414].indices.length;}break;case VBO_BATCHED:countIndices+=cfg.indices.length;break;case VBO_INSTANCED:countIndices+=cfg.geometry.indices.length;break;}return Math.round(countIndices/3);case"points":switch(cfg.type){case DTX:for(var _i415=0,_len86=cfg.buckets.length;_i415<_len86;_i415++){countIndices+=cfg.buckets[_i415].positionsCompressed.length;}break;case VBO_BATCHED:countIndices+=cfg.positions?cfg.positions.length:cfg.positionsCompressed.length;break;case VBO_INSTANCED:var geometry=cfg.geometry;countIndices+=geometry.positions?geometry.positions.length:geometry.positionsCompressed.length;break;}return Math.round(countIndices);case"lines":case"line-strip":switch(cfg.type){case DTX:for(var _i416=0,_len87=cfg.buckets.length;_i416<_len87;_i416++){countIndices+=cfg.buckets[_i416].indices.length;}break;case VBO_BATCHED:countIndices+=cfg.indices.length;break;case VBO_INSTANCED:countIndices+=cfg.geometry.indices.length;break;}return Math.round(countIndices/2);}return 0;}},{key:"_getDTXLayer",value:function _getDTXLayer(cfg){var origin=cfg.origin;var primitive=cfg.geometry?cfg.geometry.primitive:cfg.primitive;var layerId=".".concat(primitive,".").concat(Math.round(origin[0]),".").concat(Math.round(origin[1]),".").concat(Math.round(origin[2]));var dtxLayer=this._dtxLayers[layerId];if(dtxLayer){if(!dtxLayer.canCreatePortion(cfg)){dtxLayer.finalize();delete this._dtxLayers[layerId];dtxLayer=null;}else{return dtxLayer;}}switch(primitive){case"triangles":case"solid":case"surface":dtxLayer=new DTXTrianglesLayer(this,{layerIndex:0,origin:origin});// layerIndex is set in #finalize()
18098
18098
  break;case"lines":dtxLayer=new DTXLinesLayer(this,{layerIndex:0,origin:origin});// layerIndex is set in #finalize()
18099
18099
  break;default:return;}this._dtxLayers[layerId]=dtxLayer;this.layerList.push(dtxLayer);return dtxLayer;}},{key:"_getVBOBatchingLayer",value:function _getVBOBatchingLayer(cfg){var model=this;var origin=cfg.origin;var positionsDecodeHash=cfg.positionsDecodeMatrix||cfg.positionsDecodeBoundary?this._createHashStringFromMatrix(cfg.positionsDecodeMatrix||cfg.positionsDecodeBoundary):"-";var textureSetId=cfg.textureSetId||"-";var layerId="".concat(Math.round(origin[0]),".").concat(Math.round(origin[1]),".").concat(Math.round(origin[2]),".").concat(cfg.primitive,".").concat(positionsDecodeHash,".").concat(textureSetId);var vboBatchingLayer=this._vboBatchingLayers[layerId];if(vboBatchingLayer){return vboBatchingLayer;}var textureSet=cfg.textureSet;while(!vboBatchingLayer){switch(cfg.primitive){case"triangles":// console.info(`[SceneModel ${this.id}]: creating TrianglesBatchingLayer`);
18100
18100
  vboBatchingLayer=new VBOBatchingTrianglesLayer({model:model,textureSet:textureSet,layerIndex:0,// This is set in #finalize()
@@ -18155,7 +18155,14 @@ vboInstancingLayer=new VBOInstancingPointsLayer({model:model,textureSet:textureS
18155
18155
  * @param {Boolean} [cfg.selected=false] Indicates if the SceneModelEntity is initially selected. Selected appearance is configured by {@link SceneModel#selectedMaterial}.
18156
18156
  * @param {Boolean} [cfg.edges=false] Indicates if the SceneModelEntity's edges are initially emphasized. Edges appearance is configured by {@link SceneModel#edgeMaterial}.
18157
18157
  * @returns {SceneModelEntity} The new SceneModelEntity.
18158
- */},{key:"createEntity",value:function createEntity(cfg){if(cfg.id===undefined){cfg.id=math.createUUID();}else if(this.scene.components[cfg.id]){this.error("Scene already has a Component with this ID: ".concat(cfg.id," - will assign random ID"));cfg.id=math.createUUID();}if(cfg.meshIds===undefined){this.error("Config missing: meshIds");return;}var flags=0;if(this._visible&&cfg.visible!==false){flags=flags|ENTITY_FLAGS.VISIBLE;}if(this._pickable&&cfg.pickable!==false){flags=flags|ENTITY_FLAGS.PICKABLE;}if(this._culled&&cfg.culled!==false){flags=flags|ENTITY_FLAGS.CULLED;}if(this._clippable&&cfg.clippable!==false){flags=flags|ENTITY_FLAGS.CLIPPABLE;}if(this._collidable&&cfg.collidable!==false){flags=flags|ENTITY_FLAGS.COLLIDABLE;}if(this._edges&&cfg.edges!==false){flags=flags|ENTITY_FLAGS.EDGES;}if(this._xrayed&&cfg.xrayed!==false){flags=flags|ENTITY_FLAGS.XRAYED;}if(this._highlighted&&cfg.highlighted!==false){flags=flags|ENTITY_FLAGS.HIGHLIGHTED;}if(this._selected&&cfg.selected!==false){flags=flags|ENTITY_FLAGS.SELECTED;}cfg.flags=flags;this._createEntity(cfg);}},{key:"_createEntity",value:function _createEntity(cfg){var meshes=[];for(var _i418=0,len=cfg.meshIds.length;_i418<len;_i418++){var meshId=cfg.meshIds[_i418];var _mesh2=this._meshes[meshId];if(!_mesh2){this.error("Mesh with this ID not found: \"".concat(meshId,"\" - ignoring this mesh"));continue;}if(_mesh2.parent){this.error("Mesh with ID \"".concat(meshId,"\" already belongs to object with ID \"").concat(_mesh2.parent.id,"\" - ignoring this mesh"));continue;}meshes.push(_mesh2);}var lodCullable=true;var entity=new SceneModelEntity(this,cfg.isObject,cfg.id,meshes,cfg.flags,lodCullable);// Internally sets SceneModelEntity#parent to this SceneModel
18158
+ */},{key:"createEntity",value:function createEntity(cfg){if(cfg.id===undefined){cfg.id=math.createUUID();}else if(this.scene.components[cfg.id]){this.error("Scene already has a Component with this ID: ".concat(cfg.id," - will assign random ID"));cfg.id=math.createUUID();}if(cfg.meshIds===undefined){this.error("Config missing: meshIds");return;}var flags=0;if(this._visible&&cfg.visible!==false){flags=flags|ENTITY_FLAGS.VISIBLE;}if(this._pickable&&cfg.pickable!==false){flags=flags|ENTITY_FLAGS.PICKABLE;}if(this._culled&&cfg.culled!==false){flags=flags|ENTITY_FLAGS.CULLED;}if(this._clippable&&cfg.clippable!==false){flags=flags|ENTITY_FLAGS.CLIPPABLE;}if(this._collidable&&cfg.collidable!==false){flags=flags|ENTITY_FLAGS.COLLIDABLE;}if(this._edges&&cfg.edges!==false){flags=flags|ENTITY_FLAGS.EDGES;}if(this._xrayed&&cfg.xrayed!==false){flags=flags|ENTITY_FLAGS.XRAYED;}if(this._highlighted&&cfg.highlighted!==false){flags=flags|ENTITY_FLAGS.HIGHLIGHTED;}if(this._selected&&cfg.selected!==false){flags=flags|ENTITY_FLAGS.SELECTED;}cfg.flags=flags;this._createEntity(cfg);}},{key:"_createEntity",value:function _createEntity(cfg){var meshes=[];for(var _i418=0,len=cfg.meshIds.length;_i418<len;_i418++){var meshId=cfg.meshIds[_i418];var _mesh2=this._meshes[meshId];// Trying to get already created mesh
18159
+ if(!_mesh2){// Checks if there is already created mesh for this meshId
18160
+ var meshCfg=this._meshesCfgsBeforeMeshCreation[meshId];// Trying to get already created cfg
18161
+ if(!meshCfg){// Checks if there is already created cfg for this meshId
18162
+ this.error("Mesh with this ID not found: \"".concat(meshId,"\" - ignoring this mesh"));// There is no such cfg
18163
+ continue;}_mesh2=this._createMesh(meshCfg);// There is no such mesh yet, but there is already created cfg, so it creates this mesh
18164
+ this._meshes[cfg.id]=_mesh2;// Now it will also add this mesh to dictionary of created meshes
18165
+ }if(_mesh2.parent){this.error("Mesh with ID \"".concat(meshId,"\" already belongs to object with ID \"").concat(_mesh2.parent.id,"\" - ignoring this mesh"));continue;}meshes.push(_mesh2);}var lodCullable=true;var entity=new SceneModelEntity(this,cfg.isObject,cfg.id,meshes,cfg.flags,lodCullable);// Internally sets SceneModelEntity#parent to this SceneModel
18159
18166
  this._entityList.push(entity);this._entities[cfg.id]=entity;this.numEntities++;}/**
18160
18167
  * Finalizes this SceneModel.
18161
18168
  *