@itwin/core-frontend 5.5.0-dev.5 → 5.5.0-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/internal/tile/B3dmReader.d.ts +3 -3
- package/lib/cjs/internal/tile/B3dmReader.d.ts.map +1 -1
- package/lib/cjs/internal/tile/B3dmReader.js.map +1 -1
- package/lib/esm/internal/tile/B3dmReader.d.ts +3 -3
- package/lib/esm/internal/tile/B3dmReader.d.ts.map +1 -1
- package/lib/esm/internal/tile/B3dmReader.js.map +1 -1
- package/package.json +20 -20
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* @module Tiles
|
|
3
3
|
*/
|
|
4
4
|
import { ByteStream, Id64String } from "@itwin/core-bentley";
|
|
5
|
-
import { Point3d, Transform } from "@itwin/core-geometry";
|
|
5
|
+
import { Point3d, Transform, Vector3d } from "@itwin/core-geometry";
|
|
6
6
|
import { ElementAlignedBox3d } from "@itwin/core-common";
|
|
7
7
|
import { IModelConnection } from "../../IModelConnection";
|
|
8
8
|
import { Mesh } from "../../common/internal/render/MeshPrimitives";
|
|
9
9
|
import { RenderSystem } from "../../render/RenderSystem";
|
|
10
10
|
import { GltfMeshPrimitive } from "../../common/gltf/GltfSchema";
|
|
11
|
-
import { BatchedTileIdMap, GltfReader, GltfReaderResult, ShouldAbortReadGltf } from "../../tile/internal";
|
|
11
|
+
import { BatchedTileIdMap, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf } from "../../tile/internal";
|
|
12
12
|
import { LayerTileData } from "../render/webgl/MapLayerParams";
|
|
13
13
|
/**
|
|
14
14
|
* Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.
|
|
@@ -24,7 +24,7 @@ export declare class B3dmReader extends GltfReader {
|
|
|
24
24
|
private _colors?;
|
|
25
25
|
private readonly _modelId;
|
|
26
26
|
static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d, system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, tileCenter: Point3d, transformToRoot?: Transform, isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices?: boolean, tileData?: LayerTileData): B3dmReader | undefined;
|
|
27
|
-
|
|
27
|
+
constructor(props: GltfReaderProps, iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem, _range: ElementAlignedBox3d, _isLeaf: boolean, _batchTableLength: number, _transformToRoot?: Transform | undefined, _batchTableJson?: any, shouldAbort?: ShouldAbortReadGltf, _idMap?: BatchedTileIdMap, _pseudoRtcBias?: Vector3d | undefined, deduplicateVertices?: boolean, tileData?: LayerTileData);
|
|
28
28
|
read(): Promise<GltfReaderResult>;
|
|
29
29
|
protected readBatchTable(mesh: Mesh, json: GltfMeshPrimitive): void;
|
|
30
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"B3dmReader.d.ts","sourceRoot":"","sources":["../../../../src/internal/tile/B3dmReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAiB,UAAU,EAAa,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"B3dmReader.d.ts","sourceRoot":"","sources":["../../../../src/internal/tile/B3dmReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAiB,UAAU,EAAa,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAwB,mBAAmB,EAAyC,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,6CAA6C,CAAC;AACnE,OAAO,EAAE,YAAY,EA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,CAAC;wBACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;wBACjD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;wBAChD,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;wBAClD,IAAI,UAAU;4BACZ,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;oBACrC,CAAC;oBACD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAEpC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,qBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA/JD,gCA+JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { ByteStream, expectDefined, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport { Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { B3dmHeader, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, TileReadStatus } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { Mesh } from \"../../common/internal/render/MeshPrimitives\";\r\nimport { RenderSystem } from \"../../render/RenderSystem\";\r\nimport { GltfDataType, GltfMeshPrimitive } from \"../../common/gltf/GltfSchema\";\r\nimport {\r\n BatchedTileIdMap, GltfBufferData, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf,\r\n} from \"../../tile/internal\";\r\nimport { LayerTileData } from \"../render/webgl/MapLayerParams\";\r\n\r\n\r\n/**\r\n * Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.\r\n */\r\nexport class B3dmReader extends GltfReader {\r\n private _batchIdRemap = new Map<number, number>();\r\n private _colors?: Array<number>;\r\n private readonly _modelId: Id64String;\r\n\r\n public static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d,\r\n system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, tileCenter: Point3d, transformToRoot?: Transform,\r\n isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices=false, tileData?: LayerTileData): B3dmReader | undefined {\r\n const header = new B3dmHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n let returnToCenterTransform, pseudoRtcBias;\r\n if (header.featureTableJson && Array.isArray(header.featureTableJson.RTC_CENTER)) {\r\n returnToCenterTransform = Transform.createTranslationXYZ(header.featureTableJson.RTC_CENTER[0], header.featureTableJson.RTC_CENTER[1], header.featureTableJson.RTC_CENTER[2]);\r\n } else {\r\n /**\r\n * This is a workaround for tiles generated by\r\n * context capture which have a large offset from the tileset origin that exceeds the\r\n * capacity of 32 bit integers. It is essentially an ad hoc RTC applied at read time only if the tile is far from the\r\n * origin and there is no RTC supplied either with the B3DM of the GLTF.\r\n * as the vertices are supplied in a quantized format, applying the RTC bias to\r\n * quantization origin will make these tiles work correctly.\r\n */\r\n pseudoRtcBias = Vector3d.create(tileCenter.x, tileCenter.y, tileCenter.z);\r\n }\r\n\r\n if (undefined !== returnToCenterTransform)\r\n transformToRoot = transformToRoot ? transformToRoot.multiplyTransformTransform(returnToCenterTransform) : returnToCenterTransform;\r\n\r\n const props = GltfReaderProps.create(stream.nextBytes(header.length - stream.curPos), yAxisUp);\r\n const batchTableLength = header.featureTableJson ? JsonUtils.asInt(header.featureTableJson.BATCH_LENGTH, 0) : 0;\r\n\r\n return undefined !== props ? new B3dmReader(props, iModel, modelId, is3d, system, range, isLeaf, batchTableLength,\r\n transformToRoot, header.batchTableJson, isCanceled, idMap, pseudoRtcBias, deduplicateVertices, tileData) : undefined;\r\n }\r\n\r\n private constructor(props: GltfReaderProps, iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem,\r\n private _range: ElementAlignedBox3d, private _isLeaf: boolean, private _batchTableLength: number, private _transformToRoot?: Transform, private _batchTableJson?: any\r\n , shouldAbort?: ShouldAbortReadGltf, _idMap?: BatchedTileIdMap, private _pseudoRtcBias?: Vector3d, deduplicateVertices=false, tileData?: LayerTileData) {\r\n super({\r\n props, iModel, system, shouldAbort, deduplicateVertices,\r\n is2d: !is3d, idMap: _idMap, tileData\r\n });\r\n this._modelId = modelId;\r\n }\r\n\r\n public async read(): Promise<GltfReaderResult> {\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n const featureTable: FeatureTable = new FeatureTable(this._batchTableLength ? this._batchTableLength : 1, this._modelId, this._type);\r\n if (this._batchTableLength > 0 && this._idMap !== undefined && this._batchTableJson !== undefined) {\r\n if (this._batchTableJson.extensions && this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"]) {\r\n const hierarchy = this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"];\r\n const { classIds, classes, parentIds, parentCounts, instancesLength } = hierarchy;\r\n if (classes !== undefined && classIds !== undefined && instancesLength !== 0) {\r\n const classCounts = new Array<number>(classes.length);\r\n classCounts.fill(0);\r\n const classIndexes = new Uint16Array(instancesLength);\r\n for (let i = 0; i < instancesLength; ++i) {\r\n const classId = classIds[i];\r\n classIndexes[i] = classCounts[classId]++;\r\n }\r\n\r\n let parentMap: [][] | undefined;\r\n if (parentIds) {\r\n parentMap = new Array<[]>();\r\n for (let i = 0, parentIndex = 0; i < instancesLength; i++) {\r\n const parentCount = parentCounts === undefined ? 1 : parentCounts[i];\r\n parentMap[i] = parentIds.slice(parentIndex, parentIndex += parentCount);\r\n }\r\n }\r\n\r\n const getProperties = (instance: any, instanceIndex: number) => {\r\n const classId = classIds[instanceIndex];\r\n const instanceClass = classes[classId];\r\n const instances = instanceClass.instances;\r\n const indexInClass = classIndexes[instanceIndex];\r\n for (const key in instances) { // eslint-disable-line guard-for-in\r\n const value = instances[key][indexInClass];\r\n if (value !== undefined && value !== null)\r\n instance[key] = value;\r\n }\r\n if (parentIds !== undefined) {\r\n const thisParents = expectDefined(parentMap)[instanceIndex];\r\n for (const parentId of thisParents) {\r\n if (parentId !== instanceIndex)\r\n getProperties(instance, parentId);\r\n }\r\n }\r\n };\r\n for (let batchId = 0; batchId < instancesLength; batchId++) {\r\n const instance: any = {};\r\n getProperties(instance, batchId);\r\n this._batchIdRemap.set(batchId, featureTable.insert(new Feature(this._idMap.getBatchId(instance))));\r\n const cesiumColor = instance[\"cesium#color\"];\r\n if (undefined !== cesiumColor) {\r\n if (!this._colors) {\r\n this._colors = new Array<number>(instancesLength);\r\n this._colors.fill(ColorDef.white.tbgr);\r\n }\r\n this._colors[batchId] = ColorDef.create(cesiumColor).tbgr;\r\n }\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < this._batchTableLength; i++) {\r\n const feature: any = {};\r\n for (const key in this._batchTableJson) // eslint-disable-line guard-for-in\r\n feature[key] = this._batchTableJson[key][i];\r\n\r\n this._batchIdRemap.set(i, featureTable.insert(new Feature(this._idMap.getBatchId(feature))));\r\n }\r\n }\r\n }\r\n\r\n if (featureTable.isEmpty) {\r\n this._batchIdRemap.set(0, 0);\r\n const feature = new Feature(this._modelId);\r\n featureTable.insert(feature);\r\n }\r\n\r\n await this.resolveResources();\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf: this._isLeaf };\r\n\r\n return this.readGltfAndCreateGraphics(this._isLeaf, featureTable, this._range, this._transformToRoot, this._pseudoRtcBias, undefined);\r\n }\r\n\r\n protected override readBatchTable(mesh: Mesh, json: GltfMeshPrimitive) {\r\n if (mesh.features !== undefined) {\r\n if (this._batchTableLength > 0 && undefined !== this._batchTableJson && undefined !== json.attributes) {\r\n const view = this.getBufferView(json.attributes, \"_BATCHID\");\r\n let batchIds: undefined | GltfBufferData;\r\n if (undefined !== view && (undefined !== (batchIds = view.toBufferData(GltfDataType.UInt32)) || undefined !== (batchIds = view.toBufferData(GltfDataType.Float)))) {\r\n const indices = [];\r\n const { colors, colorMap } = mesh;\r\n let colorRemap: Uint32Array | undefined;\r\n if (this._colors && this._colors.length === this._batchTableLength) {\r\n colorRemap = new Uint32Array(this._batchTableLength);\r\n\r\n for (let i = 0; i < this._batchTableLength; i++)\r\n colorRemap[i] = colorMap.insert(this._colors[i]);\r\n }\r\n\r\n for (let i = 0; i < batchIds.count; i++) {\r\n const batchId = batchIds.buffer[i * view.stride];\r\n const remapId = this._batchIdRemap.get(batchId);\r\n indices.push(remapId === undefined ? 0 : remapId);\r\n if (colorRemap)\r\n colors.push(colorRemap[batchId]);\r\n }\r\n mesh.features.setIndices(indices);\r\n\r\n }\r\n } else {\r\n mesh.features.add(new Feature(this._modelId), 1);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"B3dmReader.js","sourceRoot":"","sources":["../../../../src/internal/tile/B3dmReader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuF;AACvF,wDAAoE;AACpE,oDAAsH;AAItH,6DAA+E;AAC/E,kDAE6B;AAI7B;;GAEG;AACH,MAAa,UAAW,SAAQ,qBAAU;IAsC9B;IAAqC;IAA0B;IAAmC;IAAsC;IACxE;IAtClE,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,OAAO,CAAiB;IACf,QAAQ,CAAa;IAE/B,MAAM,CAAC,MAAM,CAAC,MAAkB,EAAE,MAAwB,EAAE,OAAmB,EAAE,IAAa,EAAE,KAA0B,EAC/H,MAAoB,EAAE,OAA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AAC,MAAM,KAAK,IAAI,CAAC,iBAAiB,EAAE,CAAC;wBACnE,UAAU,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;wBAErD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC,EAAE;4BAC7C,UAAU,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;oBACrD,CAAC;oBAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;wBACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;wBACjD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;wBAChD,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;wBAClD,IAAI,UAAU;4BACZ,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;oBACrC,CAAC;oBACD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAEpC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,qBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA/JD,gCA+JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { ByteStream, expectDefined, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport { Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { B3dmHeader, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, TileReadStatus } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { Mesh } from \"../../common/internal/render/MeshPrimitives\";\r\nimport { RenderSystem } from \"../../render/RenderSystem\";\r\nimport { GltfDataType, GltfMeshPrimitive } from \"../../common/gltf/GltfSchema\";\r\nimport {\r\n BatchedTileIdMap, GltfBufferData, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf,\r\n} from \"../../tile/internal\";\r\nimport { LayerTileData } from \"../render/webgl/MapLayerParams\";\r\n\r\n\r\n/**\r\n * Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.\r\n */\r\nexport class B3dmReader extends GltfReader {\r\n private _batchIdRemap = new Map<number, number>();\r\n private _colors?: Array<number>;\r\n private readonly _modelId: Id64String;\r\n\r\n public static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d,\r\n system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, tileCenter: Point3d, transformToRoot?: Transform,\r\n isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices=false, tileData?: LayerTileData): B3dmReader | undefined {\r\n const header = new B3dmHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n let returnToCenterTransform, pseudoRtcBias;\r\n if (header.featureTableJson && Array.isArray(header.featureTableJson.RTC_CENTER)) {\r\n returnToCenterTransform = Transform.createTranslationXYZ(header.featureTableJson.RTC_CENTER[0], header.featureTableJson.RTC_CENTER[1], header.featureTableJson.RTC_CENTER[2]);\r\n } else {\r\n /**\r\n * This is a workaround for tiles generated by\r\n * context capture which have a large offset from the tileset origin that exceeds the\r\n * capacity of 32 bit integers. It is essentially an ad hoc RTC applied at read time only if the tile is far from the\r\n * origin and there is no RTC supplied either with the B3DM of the GLTF.\r\n * as the vertices are supplied in a quantized format, applying the RTC bias to\r\n * quantization origin will make these tiles work correctly.\r\n */\r\n pseudoRtcBias = Vector3d.create(tileCenter.x, tileCenter.y, tileCenter.z);\r\n }\r\n\r\n if (undefined !== returnToCenterTransform)\r\n transformToRoot = transformToRoot ? transformToRoot.multiplyTransformTransform(returnToCenterTransform) : returnToCenterTransform;\r\n\r\n const props = GltfReaderProps.create(stream.nextBytes(header.length - stream.curPos), yAxisUp);\r\n const batchTableLength = header.featureTableJson ? JsonUtils.asInt(header.featureTableJson.BATCH_LENGTH, 0) : 0;\r\n\r\n return undefined !== props ? new B3dmReader(props, iModel, modelId, is3d, system, range, isLeaf, batchTableLength,\r\n transformToRoot, header.batchTableJson, isCanceled, idMap, pseudoRtcBias, deduplicateVertices, tileData) : undefined;\r\n }\r\n\r\n public constructor(props: GltfReaderProps, iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem,\r\n private _range: ElementAlignedBox3d, private _isLeaf: boolean, private _batchTableLength: number, private _transformToRoot?: Transform, private _batchTableJson?: any\r\n , shouldAbort?: ShouldAbortReadGltf, _idMap?: BatchedTileIdMap, private _pseudoRtcBias?: Vector3d, deduplicateVertices=false, tileData?: LayerTileData) {\r\n super({\r\n props, iModel, system, shouldAbort, deduplicateVertices,\r\n is2d: !is3d, idMap: _idMap, tileData\r\n });\r\n this._modelId = modelId;\r\n }\r\n\r\n public async read(): Promise<GltfReaderResult> {\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n const featureTable: FeatureTable = new FeatureTable(this._batchTableLength ? this._batchTableLength : 1, this._modelId, this._type);\r\n if (this._batchTableLength > 0 && this._idMap !== undefined && this._batchTableJson !== undefined) {\r\n if (this._batchTableJson.extensions && this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"]) {\r\n const hierarchy = this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"];\r\n const { classIds, classes, parentIds, parentCounts, instancesLength } = hierarchy;\r\n if (classes !== undefined && classIds !== undefined && instancesLength !== 0) {\r\n const classCounts = new Array<number>(classes.length);\r\n classCounts.fill(0);\r\n const classIndexes = new Uint16Array(instancesLength);\r\n for (let i = 0; i < instancesLength; ++i) {\r\n const classId = classIds[i];\r\n classIndexes[i] = classCounts[classId]++;\r\n }\r\n\r\n let parentMap: [][] | undefined;\r\n if (parentIds) {\r\n parentMap = new Array<[]>();\r\n for (let i = 0, parentIndex = 0; i < instancesLength; i++) {\r\n const parentCount = parentCounts === undefined ? 1 : parentCounts[i];\r\n parentMap[i] = parentIds.slice(parentIndex, parentIndex += parentCount);\r\n }\r\n }\r\n\r\n const getProperties = (instance: any, instanceIndex: number) => {\r\n const classId = classIds[instanceIndex];\r\n const instanceClass = classes[classId];\r\n const instances = instanceClass.instances;\r\n const indexInClass = classIndexes[instanceIndex];\r\n for (const key in instances) { // eslint-disable-line guard-for-in\r\n const value = instances[key][indexInClass];\r\n if (value !== undefined && value !== null)\r\n instance[key] = value;\r\n }\r\n if (parentIds !== undefined) {\r\n const thisParents = expectDefined(parentMap)[instanceIndex];\r\n for (const parentId of thisParents) {\r\n if (parentId !== instanceIndex)\r\n getProperties(instance, parentId);\r\n }\r\n }\r\n };\r\n for (let batchId = 0; batchId < instancesLength; batchId++) {\r\n const instance: any = {};\r\n getProperties(instance, batchId);\r\n this._batchIdRemap.set(batchId, featureTable.insert(new Feature(this._idMap.getBatchId(instance))));\r\n const cesiumColor = instance[\"cesium#color\"];\r\n if (undefined !== cesiumColor) {\r\n if (!this._colors) {\r\n this._colors = new Array<number>(instancesLength);\r\n this._colors.fill(ColorDef.white.tbgr);\r\n }\r\n this._colors[batchId] = ColorDef.create(cesiumColor).tbgr;\r\n }\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < this._batchTableLength; i++) {\r\n const feature: any = {};\r\n for (const key in this._batchTableJson) // eslint-disable-line guard-for-in\r\n feature[key] = this._batchTableJson[key][i];\r\n\r\n this._batchIdRemap.set(i, featureTable.insert(new Feature(this._idMap.getBatchId(feature))));\r\n }\r\n }\r\n }\r\n\r\n if (featureTable.isEmpty) {\r\n this._batchIdRemap.set(0, 0);\r\n const feature = new Feature(this._modelId);\r\n featureTable.insert(feature);\r\n }\r\n\r\n await this.resolveResources();\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf: this._isLeaf };\r\n\r\n return this.readGltfAndCreateGraphics(this._isLeaf, featureTable, this._range, this._transformToRoot, this._pseudoRtcBias, undefined);\r\n }\r\n\r\n protected override readBatchTable(mesh: Mesh, json: GltfMeshPrimitive) {\r\n if (mesh.features !== undefined) {\r\n if (this._batchTableLength > 0 && undefined !== this._batchTableJson && undefined !== json.attributes) {\r\n const view = this.getBufferView(json.attributes, \"_BATCHID\");\r\n let batchIds: undefined | GltfBufferData;\r\n if (undefined !== view && (undefined !== (batchIds = view.toBufferData(GltfDataType.UInt32)) || undefined !== (batchIds = view.toBufferData(GltfDataType.Float)))) {\r\n const indices = [];\r\n const { colors, colorMap } = mesh;\r\n let colorRemap: Uint32Array | undefined;\r\n if (this._colors && this._colors.length === this._batchTableLength) {\r\n colorRemap = new Uint32Array(this._batchTableLength);\r\n\r\n for (let i = 0; i < this._batchTableLength; i++)\r\n colorRemap[i] = colorMap.insert(this._colors[i]);\r\n }\r\n\r\n for (let i = 0; i < batchIds.count; i++) {\r\n const batchId = batchIds.buffer[i * view.stride];\r\n const remapId = this._batchIdRemap.get(batchId);\r\n indices.push(remapId === undefined ? 0 : remapId);\r\n if (colorRemap)\r\n colors.push(colorRemap[batchId]);\r\n }\r\n mesh.features.setIndices(indices);\r\n\r\n }\r\n } else {\r\n mesh.features.add(new Feature(this._modelId), 1);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* @module Tiles
|
|
3
3
|
*/
|
|
4
4
|
import { ByteStream, Id64String } from "@itwin/core-bentley";
|
|
5
|
-
import { Point3d, Transform } from "@itwin/core-geometry";
|
|
5
|
+
import { Point3d, Transform, Vector3d } from "@itwin/core-geometry";
|
|
6
6
|
import { ElementAlignedBox3d } from "@itwin/core-common";
|
|
7
7
|
import { IModelConnection } from "../../IModelConnection";
|
|
8
8
|
import { Mesh } from "../../common/internal/render/MeshPrimitives";
|
|
9
9
|
import { RenderSystem } from "../../render/RenderSystem";
|
|
10
10
|
import { GltfMeshPrimitive } from "../../common/gltf/GltfSchema";
|
|
11
|
-
import { BatchedTileIdMap, GltfReader, GltfReaderResult, ShouldAbortReadGltf } from "../../tile/internal";
|
|
11
|
+
import { BatchedTileIdMap, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf } from "../../tile/internal";
|
|
12
12
|
import { LayerTileData } from "../render/webgl/MapLayerParams";
|
|
13
13
|
/**
|
|
14
14
|
* Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.
|
|
@@ -24,7 +24,7 @@ export declare class B3dmReader extends GltfReader {
|
|
|
24
24
|
private _colors?;
|
|
25
25
|
private readonly _modelId;
|
|
26
26
|
static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d, system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, tileCenter: Point3d, transformToRoot?: Transform, isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices?: boolean, tileData?: LayerTileData): B3dmReader | undefined;
|
|
27
|
-
|
|
27
|
+
constructor(props: GltfReaderProps, iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem, _range: ElementAlignedBox3d, _isLeaf: boolean, _batchTableLength: number, _transformToRoot?: Transform | undefined, _batchTableJson?: any, shouldAbort?: ShouldAbortReadGltf, _idMap?: BatchedTileIdMap, _pseudoRtcBias?: Vector3d | undefined, deduplicateVertices?: boolean, tileData?: LayerTileData);
|
|
28
28
|
read(): Promise<GltfReaderResult>;
|
|
29
29
|
protected readBatchTable(mesh: Mesh, json: GltfMeshPrimitive): void;
|
|
30
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"B3dmReader.d.ts","sourceRoot":"","sources":["../../../../src/internal/tile/B3dmReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAiB,UAAU,EAAa,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"B3dmReader.d.ts","sourceRoot":"","sources":["../../../../src/internal/tile/B3dmReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAiB,UAAU,EAAa,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAwB,mBAAmB,EAAyC,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,6CAA6C,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAgB,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAAkB,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EACrG,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;IAsCtC,OAAO,CAAC,MAAM;IAAuB,OAAO,CAAC,OAAO;IAAW,OAAO,CAAC,iBAAiB;IAAU,OAAO,CAAC,gBAAgB,CAAC;IAAa,OAAO,CAAC,eAAe,CAAC;I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AAC;wBAChD,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;wBAClD,IAAI,UAAU;4BACZ,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;oBACrC,CAAC;oBACD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAEpC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { ByteStream, expectDefined, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport { Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { B3dmHeader, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, TileReadStatus } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { Mesh } from \"../../common/internal/render/MeshPrimitives\";\r\nimport { RenderSystem } from \"../../render/RenderSystem\";\r\nimport { GltfDataType, GltfMeshPrimitive } from \"../../common/gltf/GltfSchema\";\r\nimport {\r\n BatchedTileIdMap, GltfBufferData, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf,\r\n} from \"../../tile/internal\";\r\nimport { LayerTileData } from \"../render/webgl/MapLayerParams\";\r\n\r\n\r\n/**\r\n * Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.\r\n */\r\nexport class B3dmReader extends GltfReader {\r\n private _batchIdRemap = new Map<number, number>();\r\n private _colors?: Array<number>;\r\n private readonly _modelId: Id64String;\r\n\r\n public static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d,\r\n system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, tileCenter: Point3d, transformToRoot?: Transform,\r\n isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices=false, tileData?: LayerTileData): B3dmReader | undefined {\r\n const header = new B3dmHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n let returnToCenterTransform, pseudoRtcBias;\r\n if (header.featureTableJson && Array.isArray(header.featureTableJson.RTC_CENTER)) {\r\n returnToCenterTransform = Transform.createTranslationXYZ(header.featureTableJson.RTC_CENTER[0], header.featureTableJson.RTC_CENTER[1], header.featureTableJson.RTC_CENTER[2]);\r\n } else {\r\n /**\r\n * This is a workaround for tiles generated by\r\n * context capture which have a large offset from the tileset origin that exceeds the\r\n * capacity of 32 bit integers. It is essentially an ad hoc RTC applied at read time only if the tile is far from the\r\n * origin and there is no RTC supplied either with the B3DM of the GLTF.\r\n * as the vertices are supplied in a quantized format, applying the RTC bias to\r\n * quantization origin will make these tiles work correctly.\r\n */\r\n pseudoRtcBias = Vector3d.create(tileCenter.x, tileCenter.y, tileCenter.z);\r\n }\r\n\r\n if (undefined !== returnToCenterTransform)\r\n transformToRoot = transformToRoot ? transformToRoot.multiplyTransformTransform(returnToCenterTransform) : returnToCenterTransform;\r\n\r\n const props = GltfReaderProps.create(stream.nextBytes(header.length - stream.curPos), yAxisUp);\r\n const batchTableLength = header.featureTableJson ? JsonUtils.asInt(header.featureTableJson.BATCH_LENGTH, 0) : 0;\r\n\r\n return undefined !== props ? new B3dmReader(props, iModel, modelId, is3d, system, range, isLeaf, batchTableLength,\r\n transformToRoot, header.batchTableJson, isCanceled, idMap, pseudoRtcBias, deduplicateVertices, tileData) : undefined;\r\n }\r\n\r\n private constructor(props: GltfReaderProps, iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem,\r\n private _range: ElementAlignedBox3d, private _isLeaf: boolean, private _batchTableLength: number, private _transformToRoot?: Transform, private _batchTableJson?: any\r\n , shouldAbort?: ShouldAbortReadGltf, _idMap?: BatchedTileIdMap, private _pseudoRtcBias?: Vector3d, deduplicateVertices=false, tileData?: LayerTileData) {\r\n super({\r\n props, iModel, system, shouldAbort, deduplicateVertices,\r\n is2d: !is3d, idMap: _idMap, tileData\r\n });\r\n this._modelId = modelId;\r\n }\r\n\r\n public async read(): Promise<GltfReaderResult> {\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n const featureTable: FeatureTable = new FeatureTable(this._batchTableLength ? this._batchTableLength : 1, this._modelId, this._type);\r\n if (this._batchTableLength > 0 && this._idMap !== undefined && this._batchTableJson !== undefined) {\r\n if (this._batchTableJson.extensions && this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"]) {\r\n const hierarchy = this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"];\r\n const { classIds, classes, parentIds, parentCounts, instancesLength } = hierarchy;\r\n if (classes !== undefined && classIds !== undefined && instancesLength !== 0) {\r\n const classCounts = new Array<number>(classes.length);\r\n classCounts.fill(0);\r\n const classIndexes = new Uint16Array(instancesLength);\r\n for (let i = 0; i < instancesLength; ++i) {\r\n const classId = classIds[i];\r\n classIndexes[i] = classCounts[classId]++;\r\n }\r\n\r\n let parentMap: [][] | undefined;\r\n if (parentIds) {\r\n parentMap = new Array<[]>();\r\n for (let i = 0, parentIndex = 0; i < instancesLength; i++) {\r\n const parentCount = parentCounts === undefined ? 1 : parentCounts[i];\r\n parentMap[i] = parentIds.slice(parentIndex, parentIndex += parentCount);\r\n }\r\n }\r\n\r\n const getProperties = (instance: any, instanceIndex: number) => {\r\n const classId = classIds[instanceIndex];\r\n const instanceClass = classes[classId];\r\n const instances = instanceClass.instances;\r\n const indexInClass = classIndexes[instanceIndex];\r\n for (const key in instances) { // eslint-disable-line guard-for-in\r\n const value = instances[key][indexInClass];\r\n if (value !== undefined && value !== null)\r\n instance[key] = value;\r\n }\r\n if (parentIds !== undefined) {\r\n const thisParents = expectDefined(parentMap)[instanceIndex];\r\n for (const parentId of thisParents) {\r\n if (parentId !== instanceIndex)\r\n getProperties(instance, parentId);\r\n }\r\n }\r\n };\r\n for (let batchId = 0; batchId < instancesLength; batchId++) {\r\n const instance: any = {};\r\n getProperties(instance, batchId);\r\n this._batchIdRemap.set(batchId, featureTable.insert(new Feature(this._idMap.getBatchId(instance))));\r\n const cesiumColor = instance[\"cesium#color\"];\r\n if (undefined !== cesiumColor) {\r\n if (!this._colors) {\r\n this._colors = new Array<number>(instancesLength);\r\n this._colors.fill(ColorDef.white.tbgr);\r\n }\r\n this._colors[batchId] = ColorDef.create(cesiumColor).tbgr;\r\n }\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < this._batchTableLength; i++) {\r\n const feature: any = {};\r\n for (const key in this._batchTableJson) // eslint-disable-line guard-for-in\r\n feature[key] = this._batchTableJson[key][i];\r\n\r\n this._batchIdRemap.set(i, featureTable.insert(new Feature(this._idMap.getBatchId(feature))));\r\n }\r\n }\r\n }\r\n\r\n if (featureTable.isEmpty) {\r\n this._batchIdRemap.set(0, 0);\r\n const feature = new Feature(this._modelId);\r\n featureTable.insert(feature);\r\n }\r\n\r\n await this.resolveResources();\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf: this._isLeaf };\r\n\r\n return this.readGltfAndCreateGraphics(this._isLeaf, featureTable, this._range, this._transformToRoot, this._pseudoRtcBias, undefined);\r\n }\r\n\r\n protected override readBatchTable(mesh: Mesh, json: GltfMeshPrimitive) {\r\n if (mesh.features !== undefined) {\r\n if (this._batchTableLength > 0 && undefined !== this._batchTableJson && undefined !== json.attributes) {\r\n const view = this.getBufferView(json.attributes, \"_BATCHID\");\r\n let batchIds: undefined | GltfBufferData;\r\n if (undefined !== view && (undefined !== (batchIds = view.toBufferData(GltfDataType.UInt32)) || undefined !== (batchIds = view.toBufferData(GltfDataType.Float)))) {\r\n const indices = [];\r\n const { colors, colorMap } = mesh;\r\n let colorRemap: Uint32Array | undefined;\r\n if (this._colors && this._colors.length === this._batchTableLength) {\r\n colorRemap = new Uint32Array(this._batchTableLength);\r\n\r\n for (let i = 0; i < this._batchTableLength; i++)\r\n colorRemap[i] = colorMap.insert(this._colors[i]);\r\n }\r\n\r\n for (let i = 0; i < batchIds.count; i++) {\r\n const batchId = batchIds.buffer[i * view.stride];\r\n const remapId = this._batchIdRemap.get(batchId);\r\n indices.push(remapId === undefined ? 0 : remapId);\r\n if (colorRemap)\r\n colors.push(colorRemap[batchId]);\r\n }\r\n mesh.features.setIndices(indices);\r\n\r\n }\r\n } else {\r\n mesh.features.add(new Feature(this._modelId), 1);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"B3dmReader.js","sourceRoot":"","sources":["../../../../src/internal/tile/B3dmReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAc,aAAa,EAAc,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAW,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAuB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAItH,OAAO,EAAE,YAAY,EAAqB,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAC6B,UAAU,EAAE,eAAe,GAC9D,MAAM,qBAAqB,CAAC;AAI7B;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAsC9B;IAAqC;IAA0B;IAAmC;IAAsC;IACxE;IAtClE,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,OAAO,CAAiB;IACf,QAAQ,CAAa;IAE/B,MAAM,CAAC,MAAM,CAAC,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C;oBACxC,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,iBAAiB,EAAE,CAAC;wBACnE,UAAU,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;wBAErD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC,EAAE;4BAC7C,UAAU,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;oBACrD,CAAC;oBAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;wBACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;wBACjD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;wBAChD,OAAO,CAAC,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;wBAClD,IAAI,UAAU;4BACZ,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;oBACrC,CAAC;oBACD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAEpC,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Tiles\r\n */\r\n\r\nimport { ByteStream, expectDefined, Id64String, JsonUtils } from \"@itwin/core-bentley\";\r\nimport { Point3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { B3dmHeader, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, TileReadStatus } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { Mesh } from \"../../common/internal/render/MeshPrimitives\";\r\nimport { RenderSystem } from \"../../render/RenderSystem\";\r\nimport { GltfDataType, GltfMeshPrimitive } from \"../../common/gltf/GltfSchema\";\r\nimport {\r\n BatchedTileIdMap, GltfBufferData, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf,\r\n} from \"../../tile/internal\";\r\nimport { LayerTileData } from \"../render/webgl/MapLayerParams\";\r\n\r\n\r\n/**\r\n * Deserializes a tile in [b3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Batched3DModel) format.\r\n */\r\nexport class B3dmReader extends GltfReader {\r\n private _batchIdRemap = new Map<number, number>();\r\n private _colors?: Array<number>;\r\n private readonly _modelId: Id64String;\r\n\r\n public static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d,\r\n system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, tileCenter: Point3d, transformToRoot?: Transform,\r\n isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices=false, tileData?: LayerTileData): B3dmReader | undefined {\r\n const header = new B3dmHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n let returnToCenterTransform, pseudoRtcBias;\r\n if (header.featureTableJson && Array.isArray(header.featureTableJson.RTC_CENTER)) {\r\n returnToCenterTransform = Transform.createTranslationXYZ(header.featureTableJson.RTC_CENTER[0], header.featureTableJson.RTC_CENTER[1], header.featureTableJson.RTC_CENTER[2]);\r\n } else {\r\n /**\r\n * This is a workaround for tiles generated by\r\n * context capture which have a large offset from the tileset origin that exceeds the\r\n * capacity of 32 bit integers. It is essentially an ad hoc RTC applied at read time only if the tile is far from the\r\n * origin and there is no RTC supplied either with the B3DM of the GLTF.\r\n * as the vertices are supplied in a quantized format, applying the RTC bias to\r\n * quantization origin will make these tiles work correctly.\r\n */\r\n pseudoRtcBias = Vector3d.create(tileCenter.x, tileCenter.y, tileCenter.z);\r\n }\r\n\r\n if (undefined !== returnToCenterTransform)\r\n transformToRoot = transformToRoot ? transformToRoot.multiplyTransformTransform(returnToCenterTransform) : returnToCenterTransform;\r\n\r\n const props = GltfReaderProps.create(stream.nextBytes(header.length - stream.curPos), yAxisUp);\r\n const batchTableLength = header.featureTableJson ? JsonUtils.asInt(header.featureTableJson.BATCH_LENGTH, 0) : 0;\r\n\r\n return undefined !== props ? new B3dmReader(props, iModel, modelId, is3d, system, range, isLeaf, batchTableLength,\r\n transformToRoot, header.batchTableJson, isCanceled, idMap, pseudoRtcBias, deduplicateVertices, tileData) : undefined;\r\n }\r\n\r\n public constructor(props: GltfReaderProps, iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem,\r\n private _range: ElementAlignedBox3d, private _isLeaf: boolean, private _batchTableLength: number, private _transformToRoot?: Transform, private _batchTableJson?: any\r\n , shouldAbort?: ShouldAbortReadGltf, _idMap?: BatchedTileIdMap, private _pseudoRtcBias?: Vector3d, deduplicateVertices=false, tileData?: LayerTileData) {\r\n super({\r\n props, iModel, system, shouldAbort, deduplicateVertices,\r\n is2d: !is3d, idMap: _idMap, tileData\r\n });\r\n this._modelId = modelId;\r\n }\r\n\r\n public async read(): Promise<GltfReaderResult> {\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n const featureTable: FeatureTable = new FeatureTable(this._batchTableLength ? this._batchTableLength : 1, this._modelId, this._type);\r\n if (this._batchTableLength > 0 && this._idMap !== undefined && this._batchTableJson !== undefined) {\r\n if (this._batchTableJson.extensions && this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"]) {\r\n const hierarchy = this._batchTableJson.extensions[\"3DTILES_batch_table_hierarchy\"];\r\n const { classIds, classes, parentIds, parentCounts, instancesLength } = hierarchy;\r\n if (classes !== undefined && classIds !== undefined && instancesLength !== 0) {\r\n const classCounts = new Array<number>(classes.length);\r\n classCounts.fill(0);\r\n const classIndexes = new Uint16Array(instancesLength);\r\n for (let i = 0; i < instancesLength; ++i) {\r\n const classId = classIds[i];\r\n classIndexes[i] = classCounts[classId]++;\r\n }\r\n\r\n let parentMap: [][] | undefined;\r\n if (parentIds) {\r\n parentMap = new Array<[]>();\r\n for (let i = 0, parentIndex = 0; i < instancesLength; i++) {\r\n const parentCount = parentCounts === undefined ? 1 : parentCounts[i];\r\n parentMap[i] = parentIds.slice(parentIndex, parentIndex += parentCount);\r\n }\r\n }\r\n\r\n const getProperties = (instance: any, instanceIndex: number) => {\r\n const classId = classIds[instanceIndex];\r\n const instanceClass = classes[classId];\r\n const instances = instanceClass.instances;\r\n const indexInClass = classIndexes[instanceIndex];\r\n for (const key in instances) { // eslint-disable-line guard-for-in\r\n const value = instances[key][indexInClass];\r\n if (value !== undefined && value !== null)\r\n instance[key] = value;\r\n }\r\n if (parentIds !== undefined) {\r\n const thisParents = expectDefined(parentMap)[instanceIndex];\r\n for (const parentId of thisParents) {\r\n if (parentId !== instanceIndex)\r\n getProperties(instance, parentId);\r\n }\r\n }\r\n };\r\n for (let batchId = 0; batchId < instancesLength; batchId++) {\r\n const instance: any = {};\r\n getProperties(instance, batchId);\r\n this._batchIdRemap.set(batchId, featureTable.insert(new Feature(this._idMap.getBatchId(instance))));\r\n const cesiumColor = instance[\"cesium#color\"];\r\n if (undefined !== cesiumColor) {\r\n if (!this._colors) {\r\n this._colors = new Array<number>(instancesLength);\r\n this._colors.fill(ColorDef.white.tbgr);\r\n }\r\n this._colors[batchId] = ColorDef.create(cesiumColor).tbgr;\r\n }\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < this._batchTableLength; i++) {\r\n const feature: any = {};\r\n for (const key in this._batchTableJson) // eslint-disable-line guard-for-in\r\n feature[key] = this._batchTableJson[key][i];\r\n\r\n this._batchIdRemap.set(i, featureTable.insert(new Feature(this._idMap.getBatchId(feature))));\r\n }\r\n }\r\n }\r\n\r\n if (featureTable.isEmpty) {\r\n this._batchIdRemap.set(0, 0);\r\n const feature = new Feature(this._modelId);\r\n featureTable.insert(feature);\r\n }\r\n\r\n await this.resolveResources();\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf: this._isLeaf };\r\n\r\n return this.readGltfAndCreateGraphics(this._isLeaf, featureTable, this._range, this._transformToRoot, this._pseudoRtcBias, undefined);\r\n }\r\n\r\n protected override readBatchTable(mesh: Mesh, json: GltfMeshPrimitive) {\r\n if (mesh.features !== undefined) {\r\n if (this._batchTableLength > 0 && undefined !== this._batchTableJson && undefined !== json.attributes) {\r\n const view = this.getBufferView(json.attributes, \"_BATCHID\");\r\n let batchIds: undefined | GltfBufferData;\r\n if (undefined !== view && (undefined !== (batchIds = view.toBufferData(GltfDataType.UInt32)) || undefined !== (batchIds = view.toBufferData(GltfDataType.Float)))) {\r\n const indices = [];\r\n const { colors, colorMap } = mesh;\r\n let colorRemap: Uint32Array | undefined;\r\n if (this._colors && this._colors.length === this._batchTableLength) {\r\n colorRemap = new Uint32Array(this._batchTableLength);\r\n\r\n for (let i = 0; i < this._batchTableLength; i++)\r\n colorRemap[i] = colorMap.insert(this._colors[i]);\r\n }\r\n\r\n for (let i = 0; i < batchIds.count; i++) {\r\n const batchId = batchIds.buffer[i * view.stride];\r\n const remapId = this._batchIdRemap.get(batchId);\r\n indices.push(remapId === undefined ? 0 : remapId);\r\n if (colorRemap)\r\n colors.push(colorRemap[batchId]);\r\n }\r\n mesh.features.setIndices(indices);\r\n\r\n }\r\n } else {\r\n mesh.features.add(new Feature(this._modelId), 1);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-frontend",
|
|
3
|
-
"version": "5.5.0-dev.
|
|
3
|
+
"version": "5.5.0-dev.6",
|
|
4
4
|
"description": "iTwin.js frontend components",
|
|
5
5
|
"main": "lib/cjs/core-frontend.js",
|
|
6
6
|
"module": "lib/esm/core-frontend.js",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"url": "http://www.bentley.com"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@itwin/
|
|
27
|
-
"@itwin/
|
|
28
|
-
"@itwin/core-common": "5.5.0-dev.
|
|
29
|
-
"@itwin/core-
|
|
30
|
-
"@itwin/
|
|
31
|
-
"@itwin/
|
|
32
|
-
"@itwin/
|
|
33
|
-
"@itwin/
|
|
26
|
+
"@itwin/core-bentley": "5.5.0-dev.6",
|
|
27
|
+
"@itwin/ecschema-metadata": "5.5.0-dev.6",
|
|
28
|
+
"@itwin/core-common": "5.5.0-dev.6",
|
|
29
|
+
"@itwin/core-orbitgt": "5.5.0-dev.6",
|
|
30
|
+
"@itwin/appui-abstract": "5.5.0-dev.6",
|
|
31
|
+
"@itwin/ecschema-rpcinterface-common": "5.5.0-dev.6",
|
|
32
|
+
"@itwin/core-geometry": "5.5.0-dev.6",
|
|
33
|
+
"@itwin/core-quantity": "5.5.0-dev.6"
|
|
34
34
|
},
|
|
35
35
|
"//devDependencies": [
|
|
36
36
|
"NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install",
|
|
@@ -57,15 +57,15 @@
|
|
|
57
57
|
"vite-multiple-assets": "^1.3.1",
|
|
58
58
|
"vite-plugin-static-copy": "2.2.0",
|
|
59
59
|
"webpack": "^5.97.1",
|
|
60
|
-
"@itwin/appui-abstract": "5.5.0-dev.
|
|
61
|
-
"@itwin/core-
|
|
62
|
-
"@itwin/core-
|
|
63
|
-
"@itwin/build-tools": "5.5.0-dev.
|
|
64
|
-
"@itwin/core-geometry": "5.5.0-dev.
|
|
65
|
-
"@itwin/core-orbitgt": "5.5.0-dev.
|
|
66
|
-
"@itwin/
|
|
67
|
-
"@itwin/ecschema-rpcinterface-common": "5.5.0-dev.
|
|
68
|
-
"@itwin/
|
|
60
|
+
"@itwin/appui-abstract": "5.5.0-dev.6",
|
|
61
|
+
"@itwin/core-common": "5.5.0-dev.6",
|
|
62
|
+
"@itwin/core-bentley": "5.5.0-dev.6",
|
|
63
|
+
"@itwin/build-tools": "5.5.0-dev.6",
|
|
64
|
+
"@itwin/core-geometry": "5.5.0-dev.6",
|
|
65
|
+
"@itwin/core-orbitgt": "5.5.0-dev.6",
|
|
66
|
+
"@itwin/core-quantity": "5.5.0-dev.6",
|
|
67
|
+
"@itwin/ecschema-rpcinterface-common": "5.5.0-dev.6",
|
|
68
|
+
"@itwin/ecschema-metadata": "5.5.0-dev.6"
|
|
69
69
|
},
|
|
70
70
|
"//dependencies": [
|
|
71
71
|
"NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"@loaders.gl/draco": "^4.3.4",
|
|
77
77
|
"fuse.js": "^3.3.0",
|
|
78
78
|
"wms-capabilities": "0.4.0",
|
|
79
|
-
"@itwin/core-i18n": "5.5.0-dev.
|
|
80
|
-
"@itwin/webgl-compatibility": "5.5.0-dev.
|
|
79
|
+
"@itwin/core-i18n": "5.5.0-dev.6",
|
|
80
|
+
"@itwin/webgl-compatibility": "5.5.0-dev.6"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers && npm run -s copy:draco",
|