@itwin/core-frontend 3.0.0-dev.154 → 3.0.0-dev.159
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/render/GraphicBuilder.d.ts +1 -1
- package/lib/cjs/render/GraphicBuilder.js.map +1 -1
- package/lib/cjs/tile/B3dmReader.d.ts +1 -0
- package/lib/cjs/tile/B3dmReader.d.ts.map +1 -1
- package/lib/cjs/tile/B3dmReader.js +3 -2
- package/lib/cjs/tile/B3dmReader.js.map +1 -1
- package/lib/cjs/tile/GltfReader.d.ts +438 -32
- package/lib/cjs/tile/GltfReader.d.ts.map +1 -1
- package/lib/cjs/tile/GltfReader.js +409 -166
- package/lib/cjs/tile/GltfReader.js.map +1 -1
- package/lib/cjs/tile/I3dmReader.d.ts +1 -0
- package/lib/cjs/tile/I3dmReader.d.ts.map +1 -1
- package/lib/cjs/tile/I3dmReader.js +2 -1
- package/lib/cjs/tile/I3dmReader.js.map +1 -1
- package/lib/cjs/tile/ImdlReader.d.ts +334 -10
- package/lib/cjs/tile/ImdlReader.d.ts.map +1 -1
- package/lib/cjs/tile/ImdlReader.js +84 -44
- package/lib/cjs/tile/ImdlReader.js.map +1 -1
- package/lib/cjs/tile/map/CesiumTerrainProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/CesiumTerrainProvider.js +16 -5
- package/lib/cjs/tile/map/CesiumTerrainProvider.js.map +1 -1
- package/lib/cjs/tile/map/MapTileTree.d.ts +1 -1
- package/lib/cjs/tile/map/MapTileTree.d.ts.map +1 -1
- package/lib/cjs/tile/map/MapTileTree.js +12 -13
- package/lib/cjs/tile/map/MapTileTree.js.map +1 -1
- package/lib/cjs/tools/ToolAdmin.d.ts.map +1 -1
- package/lib/cjs/tools/ToolAdmin.js +17 -7
- package/lib/cjs/tools/ToolAdmin.js.map +1 -1
- package/lib/esm/render/GraphicBuilder.d.ts +1 -1
- package/lib/esm/render/GraphicBuilder.js.map +1 -1
- package/lib/esm/tile/B3dmReader.d.ts +1 -0
- package/lib/esm/tile/B3dmReader.d.ts.map +1 -1
- package/lib/esm/tile/B3dmReader.js +4 -3
- package/lib/esm/tile/B3dmReader.js.map +1 -1
- package/lib/esm/tile/GltfReader.d.ts +438 -32
- package/lib/esm/tile/GltfReader.d.ts.map +1 -1
- package/lib/esm/tile/GltfReader.js +384 -143
- package/lib/esm/tile/GltfReader.js.map +1 -1
- package/lib/esm/tile/I3dmReader.d.ts +1 -0
- package/lib/esm/tile/I3dmReader.d.ts.map +1 -1
- package/lib/esm/tile/I3dmReader.js +2 -1
- package/lib/esm/tile/I3dmReader.js.map +1 -1
- package/lib/esm/tile/ImdlReader.d.ts +334 -10
- package/lib/esm/tile/ImdlReader.d.ts.map +1 -1
- package/lib/esm/tile/ImdlReader.js +86 -46
- package/lib/esm/tile/ImdlReader.js.map +1 -1
- package/lib/esm/tile/map/CesiumTerrainProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/CesiumTerrainProvider.js +16 -5
- package/lib/esm/tile/map/CesiumTerrainProvider.js.map +1 -1
- package/lib/esm/tile/map/MapTileTree.d.ts +1 -1
- package/lib/esm/tile/map/MapTileTree.d.ts.map +1 -1
- package/lib/esm/tile/map/MapTileTree.js +12 -13
- package/lib/esm/tile/map/MapTileTree.js.map +1 -1
- package/lib/esm/tools/ToolAdmin.d.ts.map +1 -1
- package/lib/esm/tools/ToolAdmin.js +17 -7
- package/lib/esm/tools/ToolAdmin.js.map +1 -1
- package/lib/public/locales/en/iModelJs.json +3 -1
- package/package.json +22 -22
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GltfReader.js","sourceRoot":"","sources":["../../../src/tile/GltfReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAA0B,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,OA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C,CAAC,SAAS,CAAC;QACnG,OAAO,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,OAAO,EAAE,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACtG,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 { assert, ByteStream, Id64String, JsonUtils, utf8ToString } from \"@itwin/core-bentley\";\r\nimport { Angle, Matrix3d, Point2d, Point3d, Range2d, Range3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport {\r\n BatchType, ColorDef, ElementAlignedBox3d, FeatureTable, FillFlags, GltfBufferData, GltfBufferView, GltfDataType, GltfHeader, GltfMeshMode,\r\n ImageSource, ImageSourceFormat, LinePixels, MeshEdge, MeshEdges, MeshPolyline, MeshPolylineList, OctEncodedNormal, PackedFeatureTable, QParams2d, QParams3d, QPoint2dList, QPoint3dList,\r\n Quantization,\r\n RenderTexture, TextureMapping, TileReadStatus,\r\n} from \"@itwin/core-common\";\r\nimport { getImageSourceFormatForMimeType, imageElementFromImageSource } from \"../ImageUtil\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { GraphicBranch } from \"../render/GraphicBranch\";\r\nimport { InstancedGraphicParams } from \"../render/InstancedGraphicParams\";\r\nimport { DisplayParams } from \"../render/primitives/DisplayParams\";\r\nimport { Mesh, MeshGraphicArgs } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { RealityMeshPrimitive } from \"../render/primitives/mesh/RealityMeshPrimitive\";\r\nimport { RenderGraphic } from \"../render/RenderGraphic\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport { TextureTransparency } from \"../render/RenderTexture\";\r\nimport { TileContent } from \"./internal\";\r\n\r\n// eslint-disable-next-line prefer-const\r\nlet forceLUT = false;\r\n/* eslint-disable no-restricted-syntax */\r\n\r\n/* -----------------------------------\r\n * To restore the use of web workers to decode jpeg, locate and uncomment the three sections by searching for \"webworker\".\r\n import { WorkerOperation, WebWorkerManager } from \"../WebWorkerManager\";\r\n ------------------------------------ */\r\n\r\n/** The result of [[GltfReader.read]].\r\n * @internal\r\n */\r\nexport interface GltfReaderResult extends TileContent {\r\n readStatus: TileReadStatus;\r\n}\r\n\r\n/** Data required for creating a [[GltfReader]] capable of deserializing [glTF](https://www.khronos.org/gltf/).\r\n * @internal\r\n */\r\nexport class GltfReaderProps {\r\n private constructor(public readonly buffer: ByteStream,\r\n public readonly binaryData: Uint8Array,\r\n public readonly accessors: any,\r\n public readonly bufferViews: any,\r\n public readonly scene: any,\r\n public readonly nodes: any,\r\n public readonly meshes: any,\r\n public readonly materials: any,\r\n public readonly extensions: any,\r\n public readonly samplers: any,\r\n public readonly techniques: any,\r\n public readonly yAxisUp: boolean) { }\r\n\r\n /** Attempt to construct a new GltfReaderProps from the binary data beginning at the supplied stream's current read position. */\r\n public static create(buffer: ByteStream, yAxisUp: boolean = false): GltfReaderProps | undefined {\r\n const header = new GltfHeader(buffer);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n const binaryData = new Uint8Array(buffer.arrayBuffer, header.binaryPosition);\r\n buffer.curPos = header.scenePosition;\r\n const sceneStrData = buffer.nextBytes(header.sceneStrLength);\r\n const sceneStr = utf8ToString(sceneStrData);\r\n if (undefined === sceneStr)\r\n return undefined;\r\n\r\n try {\r\n const sceneValue = JSON.parse(sceneStr);\r\n const nodes = JsonUtils.asObject(sceneValue.nodes);\r\n const meshes = JsonUtils.asObject(sceneValue.meshes);\r\n const materialValues = JsonUtils.asObject(sceneValue.materials);\r\n const accessors = JsonUtils.asObject(sceneValue.accessors);\r\n const bufferViews = JsonUtils.asObject(sceneValue.bufferViews);\r\n const extensions = JsonUtils.asObject(sceneValue.extensions);\r\n const samplers = JsonUtils.asObject(sceneValue.samplers);\r\n const techniques = JsonUtils.asObject(sceneValue.techniques);\r\n\r\n if (undefined === meshes)\r\n return undefined;\r\n\r\n return new GltfReaderProps(buffer, binaryData, accessors, bufferViews, sceneValue, nodes, meshes, materialValues, extensions, samplers, techniques, yAxisUp);\r\n } catch (e) {\r\n return undefined;\r\n }\r\n }\r\n}\r\n\r\n/** The GltfMeshData contains the raw GLTF mesh data. If the data is suitable to create a [[RealityMesh]] directly, basically in the quantized format produced by\r\n * ContextCapture, then a RealityMesh is created directly from this data. Otherwise, the mesh primitive is populated from the raw data and a MeshPrimitive\r\n * is generated. The MeshPrimitve path is much less efficient but should be rarely used.\r\n *\r\n * @internal\r\n */\r\nexport class GltfMeshData {\r\n public primitive: Mesh; // Populated with vertex and indices only if the mesh cannot be represented as [[RealityMesh]]\r\n public pointQParams?: QParams3d;\r\n public points?: Uint16Array;\r\n public pointRange?: Range3d;\r\n public normals?: Uint16Array;\r\n public uvQParams?: QParams2d;\r\n public uvs?: Uint16Array;\r\n public uvRange?: Range2d;\r\n public indices?: Uint16Array | Uint32Array;\r\n\r\n public constructor(props: Mesh) {\r\n this.primitive = props;\r\n }\r\n}\r\n\r\n/** A function that returns true if deserialization of the data supplied by the reader should abort.\r\n * @internal\r\n */\r\nexport type ShouldAbortReadGltf = (reader: GltfReader) => boolean;\r\n\r\n/* -----------------------------------\r\n This is part of the webworker option.\r\n\r\n // input is Uint8Array, the result is an ImageBitMap.\r\n class ImageDecodeWorkerOperation extends WorkerOperation {\r\n constructor(imageBytes: ArrayBuffer, imageMimeType: string) {\r\n super(\"imageBytesToImageBitmap\", [imageBytes, imageMimeType], [imageBytes]);\r\n }\r\n }\r\n-------------------------------------- */\r\n\r\n/** Deserializes [glTF](https://www.khronos.org/gltf/).\r\n * @internal\r\n */\r\nexport abstract class GltfReader {\r\n protected readonly _buffer: ByteStream;\r\n protected readonly _scene: any;\r\n protected readonly _accessors: any;\r\n protected readonly _bufferViews: any;\r\n protected readonly _meshes: any;\r\n protected readonly _nodes: any;\r\n protected readonly _batchData: any;\r\n protected readonly _materialValues: any;\r\n protected readonly _textures: any;\r\n protected readonly _renderMaterials: any; // Materials that may be deserialized and created directly\r\n protected readonly _namedTextures: any; // Textures that may be deserialized and created directly\r\n protected readonly _images: any;\r\n protected readonly _samplers: any;\r\n protected readonly _techniques: any;\r\n protected readonly _extensions: any;\r\n protected readonly _binaryData: Uint8Array;\r\n protected readonly _iModel: IModelConnection;\r\n protected readonly _is3d: boolean;\r\n protected readonly _modelId: Id64String;\r\n protected readonly _system: RenderSystem;\r\n protected readonly _returnToCenter: number[] | undefined;\r\n protected readonly _yAxisUp: boolean;\r\n protected readonly _type: BatchType;\r\n protected readonly _deduplicateVertices: boolean;\r\n private readonly _canceled?: ShouldAbortReadGltf;\r\n\r\n /* -----------------------------------\r\n private static _webWorkerManager: WebWorkerManager;\r\n\r\n private static get webWorkerManager() {\r\n if (!GltfReader._webWorkerManager) {\r\n GltfReader._webWorkerManager = new WebWorkerManager(\"v\" + BUILD_SEMVER + \"/frontend-webworker.js\", 4);\r\n }\r\n return GltfReader._webWorkerManager;\r\n }\r\n ------------------------------------- */\r\n\r\n /** Asynchronously deserialize the tile data and return the result. */\r\n public abstract read(): Promise<GltfReaderResult>;\r\n\r\n protected get _isCanceled(): boolean { return undefined !== this._canceled && this._canceled(this); }\r\n protected get _isVolumeClassifier(): boolean { return BatchType.VolumeClassifier === this._type; }\r\n\r\n protected readGltfAndCreateGraphics(isLeaf: boolean, featureTable: FeatureTable, contentRange: ElementAlignedBox3d, transformToRoot?: Transform, pseudoRtcBias?: Vector3d, instances?: InstancedGraphicParams): GltfReaderResult {\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf };\r\n\r\n if (this._returnToCenter !== undefined || this._nodes[0]?.matrix !== undefined || (pseudoRtcBias !== undefined && pseudoRtcBias.magnitude() < 1.0E5))\r\n pseudoRtcBias = undefined;\r\n\r\n const childNodes = new Set<string>();\r\n for (const key of Object.keys(this._nodes)) {\r\n const node = this._nodes[key];\r\n if (node.children)\r\n for (const child of node.children)\r\n childNodes.add(child.toString());\r\n }\r\n\r\n const renderGraphicList: RenderGraphic[] = [];\r\n let readStatus: TileReadStatus = TileReadStatus.InvalidTileData;\r\n for (const nodeKey of Object.keys(this._nodes))\r\n if (!childNodes.has(nodeKey))\r\n if (TileReadStatus.Success !== (readStatus = this.readNodeAndCreateGraphics(renderGraphicList, this._nodes[nodeKey], featureTable, undefined, instances, pseudoRtcBias)))\r\n return { readStatus, isLeaf };\r\n\r\n if (0 === renderGraphicList.length)\r\n return { readStatus: TileReadStatus.InvalidTileData, isLeaf };\r\n\r\n let renderGraphic: RenderGraphic | undefined;\r\n if (1 === renderGraphicList.length)\r\n renderGraphic = renderGraphicList[0];\r\n else\r\n renderGraphic = this._system.createGraphicList(renderGraphicList);\r\n\r\n let transform;\r\n let range = contentRange;\r\n if (undefined !== this._returnToCenter || undefined !== pseudoRtcBias || this._yAxisUp || undefined !== transformToRoot) {\r\n if (undefined !== this._returnToCenter)\r\n transform = Transform.createTranslationXYZ(this._returnToCenter[0], this._returnToCenter[1], this._returnToCenter[2]);\r\n else if (undefined !== pseudoRtcBias)\r\n transform = Transform.createTranslationXYZ(pseudoRtcBias.x, pseudoRtcBias.y, pseudoRtcBias.z);\r\n else\r\n transform = Transform.createIdentity();\r\n\r\n if (this._yAxisUp)\r\n transform = transform.multiplyTransformMatrix3d(Matrix3d.createRotationAroundVector(Vector3d.create(1.0, 0.0, 0.0), Angle.createRadians(Angle.piOver2Radians)) as Matrix3d);\r\n if (undefined !== transformToRoot)\r\n transform = transformToRoot.multiplyTransformTransform(transform);\r\n\r\n range = transform.inverse()!.multiplyRange(contentRange);\r\n }\r\n renderGraphic = this._system.createBatch(renderGraphic, PackedFeatureTable.pack(featureTable), range);\r\n if (transform) {\r\n const branch = new GraphicBranch(true);\r\n branch.add(renderGraphic);\r\n renderGraphic = this._system.createBranch(branch, transform);\r\n }\r\n\r\n return {\r\n readStatus,\r\n isLeaf,\r\n contentRange,\r\n graphic: renderGraphic,\r\n };\r\n }\r\n\r\n private graphicFromMeshData(gltfMesh: GltfMeshData, meshGraphicArgs: MeshGraphicArgs, instances?: InstancedGraphicParams) {\r\n if (!gltfMesh.points || !gltfMesh.pointRange) {\r\n assert(false);\r\n return;\r\n }\r\n const realityMeshPrimitive = (forceLUT || instances) ? undefined : RealityMeshPrimitive.createFromGltfMesh(gltfMesh);\r\n if (realityMeshPrimitive) {\r\n const realityMesh = this._system.createRealityMesh(realityMeshPrimitive);\r\n if (realityMesh)\r\n return realityMesh;\r\n }\r\n const mesh = gltfMesh.primitive;\r\n const pointCount = gltfMesh.points.length / 3;\r\n mesh.points.fromTypedArray(gltfMesh.pointRange, gltfMesh.points);\r\n if (mesh.triangles && gltfMesh.indices)\r\n mesh.triangles.addFromTypedArray(gltfMesh.indices);\r\n\r\n if (gltfMesh.uvs && gltfMesh.uvRange && gltfMesh.uvQParams) {\r\n /** This is ugly and inefficient... unnecessary if Mesh stored uvs as QPoint2dList */\r\n for (let i = 0, j = 0; i < pointCount; i++)\r\n mesh.uvParams.push(gltfMesh.uvQParams.unquantize(gltfMesh.uvs[j++], gltfMesh.uvs[j++]));\r\n }\r\n if (gltfMesh.normals)\r\n for (const normal of gltfMesh.normals)\r\n mesh.normals.push(new OctEncodedNormal(normal));\r\n\r\n return mesh.getGraphics(meshGraphicArgs, this._system, instances);\r\n }\r\n\r\n private readNodeAndCreateGraphics(renderGraphicList: RenderGraphic[], node: any, featureTable: FeatureTable, parentTransform: Transform | undefined, instances?: InstancedGraphicParams, pseudoRtcBias?: Vector3d): TileReadStatus {\r\n if (undefined === node)\r\n return TileReadStatus.InvalidTileData;\r\n\r\n let thisTransform = parentTransform;\r\n let thisBias;\r\n if (Array.isArray(node.matrix)) {\r\n const jTrans = node.matrix;\r\n const nodeTransform = Transform.createOriginAndMatrix(Point3d.create(jTrans[12], jTrans[13], jTrans[14]), Matrix3d.createRowValues(jTrans[0], jTrans[4], jTrans[8], jTrans[1], jTrans[5], jTrans[9], jTrans[2], jTrans[6], jTrans[10]));\r\n thisTransform = thisTransform ? thisTransform.multiplyTransformTransform(nodeTransform) : nodeTransform;\r\n }\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 if (undefined !== pseudoRtcBias) {\r\n thisBias = (undefined === thisTransform) ? pseudoRtcBias : thisTransform.matrix.multiplyInverse(pseudoRtcBias);\r\n }\r\n const meshKey = node.meshes ? node.meshes : node.mesh;\r\n if (undefined !== meshKey) {\r\n const nodeMesh = this._meshes[meshKey];\r\n if (nodeMesh) {\r\n const meshGraphicArgs = new MeshGraphicArgs();\r\n const meshes = [];\r\n for (const primitive of nodeMesh.primitives) {\r\n const geometry = this.readMeshPrimitive(primitive, featureTable, thisBias);\r\n if (undefined !== geometry)\r\n meshes.push(geometry);\r\n }\r\n\r\n let renderGraphic: RenderGraphic | undefined;\r\n if (0 !== meshes.length) {\r\n if (1 === meshes.length) {\r\n renderGraphic = this.graphicFromMeshData(meshes[0], meshGraphicArgs, instances);\r\n } else {\r\n const thisList: RenderGraphic[] = [];\r\n for (const mesh of meshes) {\r\n renderGraphic = this.graphicFromMeshData(mesh, meshGraphicArgs, instances);\r\n if (undefined !== renderGraphic)\r\n thisList.push(renderGraphic);\r\n }\r\n if (0 !== thisList.length)\r\n renderGraphic = this._system.createGraphicList(thisList);\r\n }\r\n if (renderGraphic) {\r\n if (thisTransform && !thisTransform.isIdentity) {\r\n const branch = new GraphicBranch(true);\r\n branch.add(renderGraphic);\r\n renderGraphic = this._system.createBranch(branch, thisTransform);\r\n }\r\n renderGraphicList.push(renderGraphic);\r\n }\r\n }\r\n }\r\n }\r\n if (node.children) {\r\n for (const child of node.children)\r\n this.readNodeAndCreateGraphics(renderGraphicList, this._nodes[child], featureTable, thisTransform, instances);\r\n }\r\n return TileReadStatus.Success;\r\n }\r\n\r\n public getBufferView(json: any, accessorName: string): GltfBufferView | undefined {\r\n try {\r\n const accessorValue = JsonUtils.asString(json[accessorName]);\r\n const accessor = 0 < accessorValue.length ? JsonUtils.asObject(this._accessors[accessorValue]) : undefined;\r\n const bufferViewAccessorValue = undefined !== accessor ? JsonUtils.asString(accessor.bufferView) : \"\";\r\n const bufferView = 0 < bufferViewAccessorValue.length ? JsonUtils.asObject(this._bufferViews[bufferViewAccessorValue]) : undefined;\r\n\r\n if (undefined === accessor)\r\n return undefined;\r\n\r\n const type = accessor.componentType as GltfDataType;\r\n let dataSize = 0;\r\n switch (type) {\r\n case GltfDataType.UnsignedByte:\r\n dataSize = 1;\r\n break;\r\n case GltfDataType.UnsignedShort:\r\n dataSize = 2;\r\n break;\r\n case GltfDataType.UInt32:\r\n case GltfDataType.Float:\r\n dataSize = 4;\r\n break;\r\n default:\r\n return undefined;\r\n }\r\n let componentCount = 1;\r\n switch (accessor.type) {\r\n case \"VEC3\":\r\n componentCount = 3;\r\n break;\r\n case \"VEC2\":\r\n componentCount = 2;\r\n break;\r\n }\r\n\r\n const byteStride = bufferView.byteStride ? bufferView.byteStride : componentCount * dataSize;\r\n const offset = ((bufferView && bufferView.byteOffset) ? bufferView.byteOffset : 0) + (accessor.byteOffset ? accessor.byteOffset : 0);\r\n const length = byteStride * accessor.count;\r\n // If the data is misaligned (Scalable mesh tile publisher) use slice to copy -- else use subarray.\r\n // assert(0 === offset % dataSize);\r\n const bytes = (0 === (this._binaryData.byteOffset + offset) % dataSize) ? this._binaryData.subarray(offset, offset + length) : this._binaryData.slice(offset, offset + length);\r\n return new GltfBufferView(bytes, accessor.count as number, type, accessor, byteStride / dataSize);\r\n } catch (e) {\r\n return undefined;\r\n }\r\n }\r\n\r\n public readBufferData32(json: any, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UInt32); }\r\n public readBufferData16(json: any, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UnsignedShort); }\r\n public readBufferData8(json: any, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UnsignedByte); }\r\n public readBufferDataFloat(json: any, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.Float); }\r\n\r\n protected constructor(props: GltfReaderProps, iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem, type: BatchType = BatchType.Primary, isCanceled?: ShouldAbortReadGltf, deduplicateVertices=false) {\r\n this._buffer = props.buffer;\r\n this._scene = props.scene;\r\n this._binaryData = props.binaryData;\r\n this._accessors = props.accessors;\r\n this._bufferViews = props.bufferViews;\r\n this._meshes = props.meshes;\r\n this._nodes = props.nodes;\r\n this._materialValues = props.materials;\r\n this._samplers = props.samplers;\r\n this._techniques = props.techniques;\r\n this._extensions = props.extensions;\r\n this._yAxisUp = props.yAxisUp;\r\n this._returnToCenter = this.extractReturnToCenter(props.extensions);\r\n this._textures = props.scene.textures;\r\n this._images = props.scene.images;\r\n\r\n this._renderMaterials = props.scene.renderMaterials;\r\n this._namedTextures = props.scene.namedTextures;\r\n\r\n this._iModel = iModel;\r\n this._modelId = modelId;\r\n this._is3d = is3d;\r\n this._system = system;\r\n this._type = type;\r\n this._canceled = isCanceled;\r\n this._deduplicateVertices = deduplicateVertices;\r\n }\r\n\r\n protected readBufferData(json: any, accessorName: string, type: GltfDataType): GltfBufferData | undefined {\r\n const view = this.getBufferView(json, accessorName);\r\n return undefined !== view ? view.toBufferData(type) : undefined;\r\n }\r\n\r\n protected readFeatureIndices(_json: any): number[] | undefined { return undefined; }\r\n\r\n private colorFromJson(values: number[]): ColorDef { return ColorDef.from(values[0] * 255, values[1] * 255, values[2] * 255, (1.0 - values[3]) * 255); }\r\n\r\n private colorFromMaterial(materialJson: any): ColorDef {\r\n if (materialJson) {\r\n if (materialJson.values && Array.isArray(materialJson.values.color))\r\n return this.colorFromJson(materialJson.values.color);\r\n else if (materialJson.pbrMetallicRoughness && Array.isArray(materialJson.pbrMetallicRoughness.baseColorFactor))\r\n return this.colorFromJson(materialJson.pbrMetallicRoughness.baseColorFactor);\r\n else if (materialJson.extensions && materialJson.extensions.KHR_techniques_webgl && materialJson.extensions.KHR_techniques_webgl.values && materialJson.extensions.KHR_techniques_webgl.values.u_color)\r\n return this.colorFromJson(materialJson.extensions.KHR_techniques_webgl.values.u_color);\r\n }\r\n\r\n return ColorDef.white;\r\n }\r\n\r\n private extractTextureId(materialJson: any): string | undefined {\r\n if (typeof materialJson !== \"object\")\r\n return undefined;\r\n\r\n const extractId = (value: any) => {\r\n switch (typeof value) {\r\n case \"string\":\r\n return value;\r\n case \"number\":\r\n return value.toString();\r\n default:\r\n return undefined;\r\n }\r\n };\r\n\r\n // Bimium's shader value...almost certainly obsolete at this point.\r\n let id = extractId(materialJson.values?.tex);\r\n if (undefined !== id)\r\n return id;\r\n\r\n // KHR_techniques_webgl extension\r\n const techniques = this._extensions?.KHR_techniques_webgl?.techniques;\r\n const ext = Array.isArray(techniques) ? materialJson.extensions?.KHR_techniques_webgl : undefined;\r\n if (undefined !== ext && typeof ext.values === \"object\") {\r\n const uniforms = typeof ext.technique === \"number\" ? techniques[ext.technique].uniforms : undefined;\r\n if (typeof uniforms === \"object\") {\r\n for (const uniformName of Object.keys(uniforms)) {\r\n const uniform = uniforms[uniformName];\r\n if (typeof uniform === \"object\" && uniform.type === GltfDataType.Sampler2d)\r\n return extractId(ext.values[uniformName]?.index);\r\n }\r\n }\r\n }\r\n\r\n id = extractId(materialJson.diffuseTexture?.index);\r\n id = id ?? extractId(materialJson.emissiveTexture?.index);\r\n return id ?? extractId(materialJson.pbrMetallicRoughness?.baseColorTexture?.index);\r\n }\r\n\r\n protected createDisplayParams(materialJson: any, hasBakedLighting: boolean): DisplayParams | undefined {\r\n const textureId = this.extractTextureId(materialJson);\r\n const textureMapping = undefined !== textureId ? this.findTextureMapping(textureId) : undefined;\r\n const color = this.colorFromMaterial(materialJson);\r\n return new DisplayParams(DisplayParams.Type.Mesh, color, color, 1, LinePixels.Solid, FillFlags.Always, undefined, undefined, hasBakedLighting, textureMapping);\r\n }\r\n protected extractReturnToCenter(extensions: any): number[] | undefined {\r\n if (extensions === undefined) { return undefined; }\r\n const cesiumRtc = JsonUtils.asObject(extensions.CESIUM_RTC);\r\n if (cesiumRtc === undefined) return undefined;\r\n const rtc = JsonUtils.asArray(cesiumRtc.center);\r\n return (rtc[0] === 0.0 && rtc[1] === 0.0 && rtc[2] === 0.0) ? undefined : rtc;\r\n }\r\n\r\n protected readMeshPrimitive(primitive: any, featureTable?: FeatureTable, pseudoRtcBias?: Vector3d): GltfMeshData | undefined {\r\n const materialName = JsonUtils.asString(primitive.material);\r\n const hasBakedLighting = undefined === primitive.attributes.NORMAL;\r\n const materialValue = 0 < materialName.length ? JsonUtils.asObject(this._materialValues[materialName]) : undefined;\r\n const displayParams = this.createDisplayParams(materialValue, hasBakedLighting);\r\n if (undefined === displayParams)\r\n return undefined;\r\n\r\n let primitiveType: number = -1;\r\n const meshMode = JsonUtils.asInt(primitive.mode, GltfMeshMode.Triangles);\r\n switch (meshMode) {\r\n case GltfMeshMode.Lines:\r\n primitiveType = Mesh.PrimitiveType.Polyline;\r\n break;\r\n\r\n case GltfMeshMode.Points:\r\n primitiveType = Mesh.PrimitiveType.Point;\r\n break;\r\n\r\n case GltfMeshMode.Triangles:\r\n primitiveType = Mesh.PrimitiveType.Mesh;\r\n break;\r\n\r\n default:\r\n assert(false);\r\n return undefined;\r\n }\r\n const isPlanar = JsonUtils.asBool(primitive.isPlanar);\r\n\r\n const isVolumeClassifier = this._isVolumeClassifier;\r\n const meshPrimitive = Mesh.create({\r\n displayParams,\r\n features: undefined !== featureTable ? new Mesh.Features(featureTable) : undefined,\r\n type: primitiveType,\r\n range: Range3d.createNull(),\r\n is2d: !this._is3d,\r\n isPlanar,\r\n hasBakedLighting,\r\n isVolumeClassifier,\r\n });\r\n const mesh = new GltfMeshData(meshPrimitive);\r\n\r\n // We don't have real colormap - just load material color. This will be used if non-Bentley\r\n // tile or fit the color table is uniform. For a non-Bentley, non-Uniform, we'll set the\r\n // uv parameters to pick the colors out of the color map texture.\r\n meshPrimitive.colorMap.insert(displayParams.fillColor.tbgr); // White...\r\n\r\n const colorIndices = this.readBufferData16(primitive.attributes, \"_COLORINDEX\");\r\n if (undefined !== colorIndices) {\r\n let texStep;\r\n if (materialValue.values !== undefined && Array.isArray(materialValue.values.texStep))\r\n texStep = materialValue.values.texStep;\r\n else if (materialValue.extensions && materialValue.extensions.KHR_techniques_webgl && materialValue.extensions.KHR_techniques_webgl.values && Array.isArray(materialValue.extensions.KHR_techniques_webgl.values.u_texStep))\r\n texStep = materialValue.extensions.KHR_techniques_webgl.values.u_texStep;\r\n\r\n if (texStep) {\r\n const uvParams = [];\r\n for (let i = 0; i < colorIndices.count; i++)\r\n uvParams.push(new Point2d(texStep[1] + texStep[0] * colorIndices.buffer[i], .5));\r\n\r\n const paramList = QPoint2dList.fromPoints(uvParams);\r\n mesh.uvs = paramList.toTypedArray();\r\n mesh.uvQParams = paramList.params;\r\n }\r\n }\r\n\r\n if (primitive.extensions?.KHR_draco_mesh_compression) {\r\n return undefined; // Defer Draco decompression until web workers implementation.\r\n /*\r\n const dracoExtension = primitive.extensions.KHR_draco_mesh_compression;\r\n const bufferView = this._bufferViews[dracoExtension.bufferView];\r\n if (undefined === bufferView) return undefined;\r\n const bufferData = this._binaryData.subarray(bufferView.byteOffset, bufferView.byteOffset + bufferView.byteLength);\r\n\r\n return DracoDecoder.readDracoMesh(mesh, primitive, bufferData, dracoExtension.attributes); */\r\n }\r\n\r\n this.readBatchTable(mesh.primitive, primitive);\r\n\r\n if (!this.readVertices(mesh, primitive, pseudoRtcBias))\r\n return undefined;\r\n\r\n switch (primitiveType) {\r\n case Mesh.PrimitiveType.Mesh: {\r\n if (!this.readMeshIndices(mesh, primitive))\r\n return undefined;\r\n\r\n if (!displayParams.ignoreLighting && !this.readNormals(mesh, primitive.attributes, \"NORMAL\"))\r\n return undefined;\r\n\r\n if (!mesh.uvs)\r\n this.readUVParams(mesh, primitive.attributes, \"TEXCOORD_0\");\r\n\r\n if (this._deduplicateVertices && !this.deduplicateVertices(mesh))\r\n return undefined;\r\n\r\n break;\r\n }\r\n\r\n case Mesh.PrimitiveType.Polyline:\r\n case Mesh.PrimitiveType.Point: {\r\n if (undefined !== mesh.primitive.polylines && !this.readPolylines(mesh.primitive.polylines, primitive, \"indices\", Mesh.PrimitiveType.Point === primitiveType))\r\n return undefined;\r\n break;\r\n }\r\n default: {\r\n assert(false, \"unhandled primitive type\");\r\n return undefined;\r\n }\r\n }\r\n if (displayParams.textureMapping && !mesh.uvs)\r\n return undefined;\r\n\r\n if (primitive.extensions?.CESIUM_primitive_outline) {\r\n const data = this.readBufferData32(primitive.extensions.CESIUM_primitive_outline, \"indices\");\r\n if (data !== undefined) {\r\n assert(0 === data.count % 2);\r\n mesh.primitive.edges = new MeshEdges();\r\n for (let i = 0; i < data.count;)\r\n mesh.primitive.edges.visible.push(new MeshEdge(data.buffer[i++], data.buffer[i++]));\r\n }\r\n }\r\n\r\n return mesh;\r\n }\r\n\r\n private deduplicateVertices(mesh: GltfMeshData): boolean {\r\n if (!mesh.points || !mesh.indices)\r\n return false;\r\n\r\n const numPoints = mesh.indices.length;\r\n assert(0 === numPoints % 3);\r\n\r\n const indices = mesh.indices;\r\n if (indices instanceof Uint16Array && numPoints > 0xffff)\r\n mesh.indices = new Uint32Array(numPoints);\r\n\r\n const points = new Uint16Array(3 * numPoints);\r\n const normals = mesh.normals ? new Uint16Array(numPoints) : undefined;\r\n const uvs = mesh.uvs ? new Uint16Array(2 * numPoints) : undefined;\r\n\r\n for (let i = 0; i < numPoints; i++) {\r\n const index = indices[i];\r\n mesh.indices[i] = i;\r\n\r\n points[i * 3 + 0] = mesh.points[index * 3 + 0];\r\n points[i * 3 + 1] = mesh.points[index * 3 + 1];\r\n points[i * 3 + 2] = mesh.points[index * 3 + 2];\r\n\r\n if (normals)\r\n normals[i] = mesh.normals![index];\r\n\r\n if (uvs) {\r\n uvs[i * 2 + 0] = mesh.uvs![index * 2 + 0];\r\n uvs[i * 2 + 1] = mesh.uvs![index * 2 + 1];\r\n }\r\n }\r\n\r\n mesh.points = points;\r\n mesh.normals = normals;\r\n mesh.uvs = uvs;\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n *\r\n * @param positions quantized points\r\n * @param primitive input json\r\n * @param pseudoRtcBias a bias applied to each point - 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. This is essentially an ad hoc RTC applied at read time.\r\n */\r\n private readVertices(mesh: GltfMeshData, primitive: any, pseudoRtcBias?: Vector3d): boolean {\r\n const view = this.getBufferView(primitive.attributes, \"POSITION\");\r\n if (undefined === view)\r\n return false;\r\n\r\n if (GltfDataType.Float === view.type) {\r\n const buffer = view.toBufferData(GltfDataType.Float);\r\n if (undefined === buffer)\r\n return false;\r\n\r\n const strideSkip = view.stride - 3;\r\n mesh.pointRange = Range3d.createNull();\r\n for (let i = 0; i < buffer.buffer.length; i += strideSkip)\r\n mesh.pointRange.extendXYZ(buffer.buffer[i++], buffer.buffer[i++], buffer.buffer[i++]);\r\n\r\n const positions = new QPoint3dList(QParams3d.fromRange(mesh.pointRange));\r\n const scratchPoint = new Point3d();\r\n for (let i = 0, j = 0; i < buffer.count; i++, j += strideSkip) {\r\n scratchPoint.set(buffer.buffer[j++], buffer.buffer[j++], buffer.buffer[j++]);\r\n if (undefined !== pseudoRtcBias)\r\n scratchPoint.subtractInPlace(pseudoRtcBias);\r\n\r\n positions.add(scratchPoint);\r\n }\r\n mesh.pointQParams = positions.params;\r\n mesh.points = positions.toTypedArray();\r\n } else {\r\n if (GltfDataType.UnsignedShort !== view.type)\r\n return false;\r\n\r\n const extensions = JsonUtils.asObject(view.accessor.extensions);\r\n const quantized = undefined !== extensions ? JsonUtils.asObject(extensions.WEB3D_quantized_attributes) : undefined;\r\n if (undefined === quantized)\r\n return false;\r\n\r\n const rangeMin = JsonUtils.asArray(quantized.decodedMin);\r\n const rangeMax = JsonUtils.asArray(quantized.decodedMax);\r\n if (undefined === rangeMin || undefined === rangeMax)\r\n return false;\r\n\r\n const buffer = view.toBufferData(GltfDataType.UnsignedShort);\r\n if (undefined === buffer || !(buffer.buffer instanceof Uint16Array))\r\n return false;\r\n\r\n assert(buffer.buffer instanceof Uint16Array);\r\n mesh.pointRange = Range3d.createXYZXYZ(rangeMin[0], rangeMin[1], rangeMin[2], rangeMax[0], rangeMax[1], rangeMax[2]);\r\n if (undefined !== pseudoRtcBias) {\r\n mesh.pointRange.low.subtractInPlace(pseudoRtcBias);\r\n mesh.pointRange.high.subtractInPlace(pseudoRtcBias);\r\n }\r\n mesh.pointQParams = QParams3d.fromRange(mesh.pointRange);\r\n if (3 === view.stride) {\r\n mesh.points = buffer.buffer;\r\n } else {\r\n mesh.points = new Uint16Array(3 * view.count);\r\n for (let i = 0, j = 0; i < view.count; i++) {\r\n const index = i * view.stride;\r\n mesh.points[j++] = buffer.buffer[index];\r\n mesh.points[j++] = buffer.buffer[index + 1];\r\n mesh.points[j++] = buffer.buffer[index + 2];\r\n }\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n protected readIndices(json: any, accessorName: string): number[] | undefined {\r\n const data = this.readBufferData32(json, accessorName);\r\n if (undefined === data)\r\n return undefined;\r\n\r\n const indices = [];\r\n for (let i = 0; i < data.count; i++)\r\n indices.push(data.buffer[i]);\r\n\r\n return indices;\r\n }\r\n\r\n protected readBatchTable(_mesh: Mesh, _json: any) {\r\n }\r\n\r\n protected readMeshIndices(mesh: GltfMeshData, json: any): boolean {\r\n const data = this.readBufferData16(json, \"indices\") || this.readBufferData32(json, \"indices\");\r\n if (undefined === data || (!(data.buffer instanceof (Uint16Array)) && !(data.buffer instanceof (Uint32Array))))\r\n return false;\r\n\r\n mesh.indices = data.buffer;\r\n\r\n return true;\r\n }\r\n\r\n protected readNormals(mesh: GltfMeshData, json: any, accessorName: string): boolean {\r\n const view = this.getBufferView(json, accessorName);\r\n if (undefined === view)\r\n return false;\r\n\r\n switch (view.type) {\r\n case GltfDataType.Float: {\r\n const data = view.toBufferData(GltfDataType.Float);\r\n if (undefined === data)\r\n return false;\r\n\r\n mesh.normals = new Uint16Array(data.count);\r\n const scratchNormal = new Vector3d();\r\n const strideSkip = view.stride - 3;\r\n for (let i = 0, j = 0; i < data.count; i++, j += strideSkip) {\r\n scratchNormal.set(data.buffer[j++], data.buffer[j++], data.buffer[j++]);\r\n mesh.normals[i] = OctEncodedNormal.encode(scratchNormal);\r\n }\r\n return true;\r\n }\r\n\r\n case GltfDataType.UnsignedByte: {\r\n const data = view.toBufferData(GltfDataType.UnsignedByte);\r\n if (undefined === data)\r\n return false;\r\n\r\n // ###TODO: we shouldn't have to allocate OctEncodedNormal objects...just use uint16s / numbers...\r\n mesh.normals = new Uint16Array(data.count);\r\n for (let i = 0; i < data.count; i++) {\r\n // ###TODO? not clear why ray writes these as pairs of uint8...\r\n const index = i * view.stride;\r\n const normal = data.buffer[index] | (data.buffer[index + 1] << 8);\r\n mesh.normals[i] = normal;\r\n }\r\n return true;\r\n }\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n private readUVParams(mesh: GltfMeshData, json: any, accessorName: string): boolean {\r\n const view = this.getBufferView(json, accessorName);\r\n let data: any;\r\n\r\n if (view === undefined)\r\n return false;\r\n\r\n switch (view.type) {\r\n case GltfDataType.Float: {\r\n data = this.readBufferDataFloat(json, accessorName);\r\n mesh.uvRange = Range2d.createNull();\r\n\r\n for (let i = 0; i < data.count; i++) {\r\n const index = view.stride * i; // 2 float per param...\r\n mesh.uvRange.extendXY(data.buffer[index], data.buffer[index + 1]);\r\n }\r\n mesh.uvQParams = QParams2d.fromRange(mesh.uvRange);\r\n mesh.uvs = new Uint16Array(data.count * 2);\r\n for (let i = 0, j = 0; i < data.count; i++) {\r\n const index = view.stride * i; // 2 float per param...\r\n mesh.uvs[j++] = Quantization.quantize(data.buffer[index], mesh.uvQParams.origin.x, mesh.uvQParams.scale.x);\r\n mesh.uvs[j++] = Quantization.quantize(data.buffer[index + 1], mesh.uvQParams.origin.y, mesh.uvQParams.scale.y);\r\n }\r\n return true;\r\n }\r\n\r\n case GltfDataType.UnsignedShort: {\r\n const extensions = JsonUtils.asObject(view.accessor.extensions);\r\n const quantized = undefined !== extensions ? JsonUtils.asObject(extensions.WEB3D_quantized_attributes) : undefined;\r\n if (undefined === quantized)\r\n return false;\r\n\r\n const rangeMin = JsonUtils.asArray(quantized.decodedMin);\r\n const rangeMax = JsonUtils.asArray(quantized.decodedMax);\r\n if (undefined === rangeMin || undefined === rangeMax)\r\n return false;\r\n\r\n const qData = view.toBufferData(GltfDataType.UnsignedShort);\r\n if (undefined === qData || !(qData.buffer instanceof Uint16Array))\r\n return false;\r\n\r\n mesh.uvRange = Range2d.createXYXY(rangeMin[0], rangeMin[1], rangeMax[0], rangeMax[1]);\r\n mesh.uvQParams = QParams2d.fromRange(mesh.uvRange);\r\n if (2 === view.stride) {\r\n mesh.uvs = qData.buffer;\r\n } else {\r\n mesh.uvs = new Uint16Array(2 * view.count);\r\n for (let i = 0, j = 0; i < view.count; i++) {\r\n const index = i * view.stride;\r\n mesh.uvs[j++] = qData.buffer[index];\r\n mesh.uvs[j++] = qData.buffer[index + 1];\r\n }\r\n }\r\n return true;\r\n }\r\n default:\r\n assert(false);\r\n return false;\r\n\r\n }\r\n\r\n return true;\r\n }\r\n\r\n protected readPolylines(polylines: MeshPolylineList, json: any, accessorName: string, disjoint: boolean): boolean {\r\n const data = this.readBufferData32(json, accessorName);\r\n if (undefined === data)\r\n return false;\r\n\r\n const indices = new Array<number>();\r\n if (disjoint) {\r\n for (let i = 0; i < data.count;)\r\n indices.push(data.buffer[i++]);\r\n } else {\r\n for (let i = 0; i < data.count;) {\r\n const index0 = data.buffer[i++];\r\n const index1 = data.buffer[i++];\r\n if (0 === indices.length || index0 !== indices[indices.length - 1]) {\r\n if (indices.length !== 0) {\r\n polylines.push(new MeshPolyline(indices));\r\n indices.length = 0;\r\n }\r\n indices.push(index0);\r\n }\r\n indices.push(index1);\r\n }\r\n }\r\n if (indices.length !== 0)\r\n polylines.push(new MeshPolyline(indices));\r\n\r\n return true;\r\n }\r\n\r\n protected async loadTextures(): Promise<void> {\r\n if (undefined === this._textures)\r\n return;\r\n\r\n const transparentTextures: Set<string> = new Set<string>();\r\n for (const name of Object.keys(this._materialValues)) {\r\n const materialValue = this._materialValues[name];\r\n let technique;\r\n if (undefined !== materialValue.values &&\r\n undefined !== materialValue.values.tex &&\r\n undefined !== materialValue.technique &&\r\n undefined !== (technique = this._techniques[materialValue.technique]) &&\r\n undefined !== technique.states &&\r\n Array.isArray(technique.states.enable)) {\r\n for (const enable of technique.states.enable)\r\n if (enable === 3042)\r\n transparentTextures.add(materialValue.values.tex);\r\n }\r\n }\r\n\r\n const promises = new Array<Promise<void>>();\r\n for (const name of Object.keys(this._textures))\r\n promises.push(this.loadTexture(name, transparentTextures.has(name)));\r\n\r\n if (promises.length > 0)\r\n await Promise.all(promises);\r\n }\r\n\r\n protected async loadTextureImage(imageJson: any, samplerJson: any, isTransparent: boolean): Promise<RenderTexture | undefined> {\r\n try {\r\n const binaryImageJson = (imageJson.extensions && imageJson.extensions.KHR_binary_glTF) ? JsonUtils.asObject(imageJson.extensions.KHR_binary_glTF) : imageJson;\r\n const bufferView = this._bufferViews[binaryImageJson.bufferView];\r\n const mimeType = JsonUtils.asString(binaryImageJson.mimeType);\r\n const format = getImageSourceFormatForMimeType(mimeType);\r\n if (undefined === format)\r\n return undefined;\r\n\r\n let textureType = RenderTexture.Type.Normal;\r\n if (undefined !== samplerJson &&\r\n (undefined !== samplerJson.wrapS || undefined !== samplerJson.wrapT))\r\n textureType = RenderTexture.Type.TileSection;\r\n\r\n const offset = bufferView.byteOffset;\r\n\r\n /* -----------------------------------\r\n const jpegArray = this._binaryData.slice(offset, offset + bufferView.byteLength);\r\n const jpegArrayBuffer = jpegArray.buffer;\r\n const workerOp = new ImageDecodeWorkerOperation(jpegArrayBuffer, mimeType);\r\n try {\r\n const imageBitmap = await GltfReader.webWorkerManager.queueOperation(workerOp)\r\n return this._isCanceled ? undefined : this._system.createTextureFromImage(imageBitmap, isTransparent && ImageSourceFormat.Png === format, this._iModel, textureParams))\r\n } catch {\r\n return undefined;\r\n }\r\n ------------------------------------- */\r\n\r\n const bytes = this._binaryData.subarray(offset, offset + bufferView.byteLength);\r\n const imageSource = new ImageSource(bytes, format);\r\n try {\r\n const image = await imageElementFromImageSource(imageSource);\r\n if (this._isCanceled)\r\n return undefined;\r\n\r\n return this._system.createTexture({\r\n type: textureType,\r\n image: {\r\n source: image,\r\n transparency: isTransparent && ImageSourceFormat.Png === format ? TextureTransparency.Translucent : TextureTransparency.Opaque,\r\n },\r\n });\r\n } catch {\r\n return undefined;\r\n }\r\n } catch (e) {\r\n return undefined;\r\n }\r\n }\r\n\r\n protected async loadTexture(textureId: string, isTransparent: boolean): Promise<void> {\r\n const textureJson = JsonUtils.asObject(this._textures[textureId]);\r\n if (undefined === textureJson)\r\n return;\r\n\r\n const texture = await this.loadTextureImage(this._images[textureJson.source], undefined === this._samplers ? undefined : this._samplers[textureJson.sampler], isTransparent);\r\n textureJson.renderTexture = texture;\r\n }\r\n\r\n protected findTextureMapping(textureId: string): TextureMapping | undefined {\r\n const textureJson = JsonUtils.asObject(this._textures[textureId]);\r\n const texture = undefined !== textureJson ? textureJson.renderTexture as RenderTexture : undefined;\r\n return undefined !== texture ? new TextureMapping(texture, new TextureMapping.Params()) : undefined;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"GltfReader.js","sourceRoot":"","sources":["../../../src/tile/GltfReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,E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,CAAC;IAEnB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC;AAED,uCAAuC;AACvC,MAAM,MAAO,SAAQ,UAAU;IAG7B,YAAmB,KAAsB,EAAE,IAA0B;;QACnE,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;QAEzD,MAAM,UAAU,GAAG,MAAA,IAAI,CAAC,eAAe,0CAAE,EAAE,CAAC;QAC5C,IAAI,UAAU,EAAE;YACd,IAAI,CAAC,aAAa,GAAG,IAAI,YAAY,CAAC,CAAC,EAAE,MAAA,MAAA,IAAI,CAAC,eAAe,0CAAE,OAAO,mCAAI,UAAU,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;YACzG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;SACpD;IAEH,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,yBAAyB,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAC7E,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 { assert, ByteStream, Id64String, JsonUtils, utf8ToString } from \"@itwin/core-bentley\";\r\nimport { Angle, Matrix3d, Point2d, Point3d, Point4d, Range2d, Range3d, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport {\r\n BatchType, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, FillFlags, GltfHeader, ImageSource, ImageSourceFormat, LinePixels, MeshEdge,\r\n MeshEdges, MeshPolyline, MeshPolylineList, OctEncodedNormal, PackedFeatureTable, QParams2d, QParams3d, QPoint2dList,\r\n QPoint3dList, Quantization, RenderTexture, TextureMapping, TileReadStatus,\r\n} from \"@itwin/core-common\";\r\nimport { getImageSourceFormatForMimeType, imageElementFromImageSource } from \"../ImageUtil\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { IModelApp } from \"../IModelApp\";\r\nimport { GraphicBranch } from \"../render/GraphicBranch\";\r\nimport { PickableGraphicOptions } from \"../render/GraphicBuilder\";\r\nimport { InstancedGraphicParams } from \"../render/InstancedGraphicParams\";\r\nimport { DisplayParams } from \"../render/primitives/DisplayParams\";\r\nimport { Mesh, MeshGraphicArgs } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { RealityMeshPrimitive } from \"../render/primitives/mesh/RealityMeshPrimitive\";\r\nimport { RenderGraphic } from \"../render/RenderGraphic\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport { TextureTransparency } from \"../render/RenderTexture\";\r\nimport { TileContent } from \"./internal\";\r\n\r\n// eslint-disable-next-line prefer-const\r\nlet forceLUT = false;\r\n/* eslint-disable no-restricted-syntax */\r\n\r\n/** Enumerates the types of [[GltfMeshPrimitive]] topologies. */\r\nenum GltfMeshMode {\r\n Points = 0,\r\n Lines = 1,\r\n LineStrip = 3,\r\n Triangles = 4,\r\n /** Not currently supported. */\r\n TriangleStrip = 5,\r\n /** Not currently supported. */\r\n TriangleFan = 6,\r\n}\r\n\r\n/** Enumerates the basic data types supported by accessors, material values, technique uniforms, etc.\r\n * @internal\r\n */\r\nexport enum GltfDataType {\r\n SignedByte = 0x1400,\r\n UnsignedByte = 0x1401,\r\n SignedShort = 5122,\r\n UnsignedShort = 5123,\r\n UInt32 = 5125,\r\n Float = 5126,\r\n Rgb = 6407,\r\n Rgba = 6408,\r\n IntVec2 = 0x8b53,\r\n IntVec3 = 0x8b54,\r\n FloatVec2 = 35664,\r\n FloatVec3 = 35665,\r\n FloatVec4 = 35666,\r\n FloatMat3 = 35675,\r\n FloatMat4 = 35676,\r\n Sampler2d = 35678,\r\n}\r\n\r\n/** @internal */\r\nenum GltfMagFilter {\r\n Nearest = 9728,\r\n Linear = 9729,\r\n}\r\n\r\n/** @internal */\r\nenum GltfMinFilter {\r\n Nearest = GltfMagFilter.Nearest,\r\n Linear = GltfMagFilter.Linear,\r\n NearestMipMapNearest = 9984,\r\n LinearMipMapNearest = 9985,\r\n NearestMipMapLinear = 9986,\r\n LinearMipMapLinear = 9987,\r\n}\r\n\r\n/** Describes how texture coordinates outside of the range [0..1] are handled. */\r\nenum GltfWrapMode {\r\n ClampToEdge = 33071,\r\n MirroredRepeat = 33648,\r\n Repeat = 10497,\r\n}\r\n\r\n/** Describes the intended target of a [[GltfBufferViewProps]]. */\r\nenum GltfBufferTarget {\r\n ArrayBuffer = 34962,\r\n ElementArrayBuffer = 24963,\r\n}\r\n\r\n/** The type used to refer to an entry in a [[GltfDictionary]] in a glTF 1.0 asset. */\r\ntype Gltf1Id = string;\r\n/** The type used to refer to an entry in a [[GltfDictionary]] in a glTF 2.0 asset. */\r\ntype Gltf2Id = number;\r\n/** The type used to refer to an entry in a [[GltfDictionary]]. */\r\ntype GltfId = Gltf1Id | Gltf2Id;\r\n\r\n/** A collection of resources of some type defined at the top-level of a [[Gltf]] asset.\r\n * In glTF 1.0, these are defined as objects; each resource is referenced and accessed by its string key.\r\n * In glTF 2.0, these are defined as arrays; each resource is referenced and accessed by its integer array index.\r\n */\r\ninterface GltfDictionary<T extends GltfChildOfRootProperty> {\r\n [key: GltfId]: T | undefined;\r\n}\r\n\r\n/** Optional extensions applied to a [[GltfProperty]] to enable behavior not defined in the core specification. */\r\ninterface GltfExtensions {\r\n [key: string]: unknown | undefined;\r\n}\r\n\r\n/** The base interface provided by most objects in a glTF asset, permitting additional data to be associated with the object. */\r\ninterface GltfProperty {\r\n extensions?: GltfExtensions;\r\n extras?: any;\r\n}\r\n\r\n/** The base interface provided by top-level properties of a [[Gltf]] asset. */\r\ninterface GltfChildOfRootProperty extends GltfProperty {\r\n /** Optional name, strictly for human consumption. */\r\n name?: string;\r\n}\r\n\r\n/** A unit of geometry belonging to a [[GltfMesh]]. */\r\ninterface GltfMeshPrimitive extends GltfProperty {\r\n /** Maps the name of each mesh attribute semantic to the Id of the [[GltfAccessor]] providing the attribute's data. */\r\n attributes: { [k: string]: GltfId | undefined };\r\n /** The Id of the [[GltfAccessor]] providing the vertex indices. */\r\n indices?: GltfId;\r\n /** The Id of the [[GltfMaterial]] to apply to the primitive when rendering. */\r\n material?: GltfId;\r\n /** The primitive topology type. */\r\n mode?: GltfMeshMode;\r\n /** Morph targets - currently unsupported. */\r\n targets?: { [k: string]: GltfId | undefined };\r\n}\r\n\r\n/** A collection of [[GltfMeshPrimitive]]s to be rendered. Each mesh is referenced by a node. Multiple nodes can refer to the same mesh.\r\n * The node's transform is applied when rendering the mesh.\r\n */\r\ninterface GltfMesh extends GltfChildOfRootProperty {\r\n /** The collection of primitives to be rendered. */\r\n primitives?: GltfMeshPrimitive[];\r\n /** For morph targets - currently unsupported. */\r\n weights?: number[];\r\n}\r\n\r\n/** Properties common to [[Gltf1Node]] and [[Gltf2Node]]. */\r\ninterface GltfNodeBaseProps {\r\n /** The Ids of the child nodes. @see [[GltfNode]]. */\r\n children?: GltfId[];\r\n /** Currently unsupported. */\r\n camera?: GltfId;\r\n /** Currently unsupported. */\r\n skin?: GltfId;\r\n /** A 4x4 column-major transformation matrix. Mutually exclusive with [[rotation]], [[scale]], and [[translation]]. */\r\n matrix?: number[];\r\n /** Unit quaternion as [x, y, z, w], where w is the scalar. */\r\n rotation?: number[];\r\n /** Non-uniform scale as [x, y, z]. */\r\n scale?: number[];\r\n /** Translation as [x, y, z]. */\r\n translation?: number[];\r\n}\r\n\r\n/** glTF 1.0 representation of a [[GltfNode]]. Unlike a [[Gltf2Node]], a Gltf1Node may refer to any number of [[GltfMesh]]es. */\r\ninterface Gltf1Node extends GltfChildOfRootProperty, GltfNodeBaseProps {\r\n /** The Ids of the [[GltfMesh]]es to be rendered by this node.\r\n * @note The spec defines this as an array of strings, but the original implementation of [[GltfReader]] was written to treat it as a string instead.\r\n * In case this was because of non-spec-compliant glTF that placed a string here instead of an array, either is permitted.\r\n */\r\n meshes?: GltfId[] | string;\r\n mesh?: never;\r\n /** Currently unsupported. */\r\n jointName?: GltfId;\r\n /** Currently unsupported. */\r\n skeletons?: GltfId[];\r\n}\r\n\r\n/** glTF 2.0 representation of a [[GltfNode]]. Unlike a [[Gltf1Node]], a Gltf2Node may refer to at most one [[GltfMesh]]. */\r\ninterface Gltf2Node extends GltfChildOfRootProperty, GltfNodeBaseProps {\r\n /** The Id of the [[GltfMesh]] to be rendered by this node. */\r\n mesh?: GltfId;\r\n meshes?: never;\r\n /** Morph targets - currently unsupported. */\r\n weights?: number[];\r\n}\r\n\r\n/** Describes a node in a [[GltfScene]]. Each node may be associated with zero, one (glTF 2.0), or any number of (glTF 1.0) [[GltfMesh]]es.\r\n * Each node may define a transform. Each node may have any number of child nodes. A child node's transform is multiplied by its parent node's transform.\r\n * Some nodes may be associated with other types of data like cameras, skins, lights, etc - these types of data are currently unsupported.\r\n * Rendering a node means rendering its meshes and the meshes of all of its descendants, with transforms applied.\r\n */\r\ntype GltfNode = Gltf1Node | Gltf2Node;\r\n\r\nfunction getNodeMeshIds(node: GltfNode): GltfId[] {\r\n if (undefined !== node.meshes)\r\n return typeof node.meshes === \"string\" ? [node.meshes] : node.meshes;\r\n else if (undefined !== node.mesh)\r\n return [node.mesh];\r\n\r\n return [];\r\n}\r\n\r\n/** Describes a scene graph that composes any number of [[GltfNode]]s to produce a rendering of the [[Gltf]] asset.\r\n * An asset may define any number of scenes; the default scene is specified by [[Gltf.scene]].\r\n */\r\ninterface GltfScene extends GltfChildOfRootProperty {\r\n /** The Ids of the nodes comprising the scene graph. */\r\n nodes?: GltfId[];\r\n}\r\n\r\n/** Provides metadata about a [[Gltf]] asset. */\r\ninterface GltfAsset extends GltfProperty {\r\n /** A copyright message suitable for display to credit the content creator. */\r\n copyright?: string;\r\n /** The name of the tool that generated the asset. */\r\n generator?: string;\r\n /** The glTF version targeted by the asset, in the form \"major.minor\" where \"major\" and \"minor\" are integers. */\r\n version: string;\r\n /** The minimum glTF version required to properly load this asset, in the same form as [[version]].\r\n * This minimum version must be no greater than [[version]].\r\n */\r\n minVersion?: string;\r\n}\r\n\r\n/** Describes an image such as one used for a [[GltfTexture]]. The image may be referenced by a [[uri]] or a [[bufferView]]. */\r\ninterface GltfImage extends GltfChildOfRootProperty {\r\n /** URI from which the image data can be obtained, either as a base-64-encoded data URI or an external resource.\r\n * Mutually exclusive with [[bufferView]].\r\n * Currently unsupported.\r\n */\r\n uri?: string;\r\n /** The image's media type. This property is required if [[bufferView]] is defined. */\r\n mimeType?: \"image/jpeg\" | \"image/png\";\r\n /** The Id of the [[GltfBufferViewProps]] containing the image data. Mutually exclusive with [[uri]]. */\r\n bufferView?: GltfId;\r\n}\r\n\r\n/** Describes a reference to a [[GltfTexture]]. */\r\ninterface GltfTextureInfo extends GltfProperty {\r\n /** The Id of the [[GltfTexture]]. */\r\n index: GltfId;\r\n /** The set index of the texture's TEXCOORD attribute used for texture coordinate mapping. */\r\n texCoord?: number;\r\n}\r\n\r\n/** Describes a texture and its sampler. */\r\ninterface GltfTexture extends GltfChildOfRootProperty {\r\n /** The Id of the [[GltfSampler]] used by this texture.\r\n * If undefined, a sampler with repeat wrapping and auto filtering should be used by default.\r\n */\r\n sampler?: GltfId;\r\n /** The Id of the [[GltfImage]] used by this texture.\r\n * If undefined, an extension or other mechanism should supply an alternate image source - otherwise, the behavior is undefined.\r\n */\r\n source?: GltfId;\r\n}\r\n\r\n/** Describes the filtering and wrapping behavior to be applied to a [[GltfTexture]]. */\r\ninterface GltfSampler extends GltfChildOfRootProperty {\r\n /** Magnification filter. */\r\n magFilter?: GltfMagFilter;\r\n /** Minification filter. */\r\n minFilter?: GltfMinFilter;\r\n /** S (U) wrapping mode. */\r\n wrapS?: GltfWrapMode;\r\n /** T (V) wrapping mode. */\r\n wrapT?: GltfWrapMode;\r\n}\r\n\r\n/** For glTF 1.0 only, describes shader programs and shader state associated with a [[Gltf1Material]], used to render meshes associated with the material.\r\n * This implementation uses it strictly to identify techniques that require alpha blending.\r\n */\r\ninterface GltfTechnique extends GltfChildOfRootProperty {\r\n /** GL render states to be applied by the technique. */\r\n states?: {\r\n /** An array of integers corresponding to boolean GL states that should be enabled using GL's `enable` function.\r\n * For example, the value `3042` indicates that blending should be enabled.\r\n */\r\n enable?: number[];\r\n };\r\n}\r\n\r\ninterface Gltf1Material extends GltfChildOfRootProperty {\r\n diffuse?: string;\r\n emission?: number[];\r\n shininess?: number;\r\n specular?: number[];\r\n technique?: GltfId;\r\n values?: {\r\n texStep?: number[];\r\n color?: number[];\r\n tex?: number | string;\r\n };\r\n}\r\n\r\ninterface GltfMaterialPbrMetallicRoughness extends GltfProperty {\r\n baseColorFactor?: number[];\r\n baseColorTexture?: GltfTextureInfo;\r\n metallicFactor?: number;\r\n metallicRoughnessTexture?: GltfTextureInfo;\r\n}\r\n\r\ninterface Gltf2Material extends GltfChildOfRootProperty {\r\n pbrMetallicRoughness?: GltfMaterialPbrMetallicRoughness;\r\n normalTexture?: unknown;\r\n occlusionTexture?: unknown;\r\n emissiveTexture?: GltfTextureInfo;\r\n emissiveFactor?: number[];\r\n alphaMode?: \"OPAQUE\" | \"MASK\" | \"BLEND\";\r\n alphaCutoff?: number;\r\n doubleSided?: boolean;\r\n extensions?: GltfExtensions & {\r\n /** The [KHR_techniques_webgl extension](https://github.com/KhronosGroup/glTF/blob/c1c12bd100e88ff468ccef1cb88cfbec56a69af2/extensions/2.0/Khronos/KHR_techniques_webgl/README.md)\r\n * allows \"techniques\" to be associated with [[GltfMaterial]]s. Techniques can supply custom shader programs to render geometry; this was a core feature of glTF 1.0 (see [[GltfTechnique]]).\r\n * Here, it is only used to extract uniform values.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_techniques_webgl?: {\r\n technique?: number;\r\n // An object containing uniform values. Each property name corresponds to a uniform in the material's technique and must conform to that uniform's type and count properties.\r\n // A handful of uniforms referenced in this implementation by name are defined below.\r\n values?: {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n u_texStep?: number[];\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n u_color?: number[];\r\n // Diffuse texture.\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n u_diffuse?: { index: number, texCoord: number };\r\n [k: string]: unknown | undefined;\r\n };\r\n };\r\n };\r\n}\r\n\r\ntype GltfMaterial = Gltf1Material | Gltf2Material;\r\n\r\nfunction isGltf1Material(material: GltfMaterial): material is Gltf1Material {\r\n const mat1 = material as Gltf1Material;\r\n return undefined !== mat1.technique || undefined !== mat1.values;\r\n}\r\n\r\ninterface GltfBuffer extends GltfChildOfRootProperty {\r\n uri?: string;\r\n byteLength?: number;\r\n}\r\n\r\ninterface GltfBufferViewProps extends GltfChildOfRootProperty {\r\n buffer: GltfId;\r\n byteLength?: number;\r\n byteOffset?: number;\r\n byteStride?: number;\r\n target?: GltfBufferTarget;\r\n}\r\n\r\ninterface GltfAccessor extends GltfChildOfRootProperty {\r\n bufferView?: GltfId;\r\n byteOffset?: number;\r\n componentType?: GltfDataType.SignedByte | GltfDataType.UnsignedByte | GltfDataType.SignedShort | GltfDataType.UnsignedShort | GltfDataType.UInt32 | GltfDataType.Float;\r\n normalized?: boolean;\r\n count: number;\r\n type: \"SCALAR\" | \"VEC2\" | \"VEC3\" | \"VEC4\" | \"MAT2\" | \"MAT3\" | \"MAT4\";\r\n max?: number[];\r\n min?: number[];\r\n sparse?: unknown; // ###TODO sparse accessors\r\n}\r\n\r\n/** Describes the top-level structure of a glTF asset.\r\n * This interface, along with all of the related Gltf* types defined in this file, is primarily based upon the [official glTF 2.0 specification](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html).\r\n * However, it can also represent a [glTF 1.0](https://github.com/KhronosGroup/glTF/tree/main/specification/1.0#reference-node) asset.\r\n * Some types are combined. For example, the top-level dictionaries in glTF 1.0 are objects, while in glTF 2.0 they are arrays; the GltfDictionary interface supports accessing\r\n * items using either strings or numeric indexes represented by [[GltfId]].\r\n * For types that differ significantly between the two specs, Gltf1* and Gltf2* versions are defined (e.g., GltfMaterial is a union of Gltf1Material and Gltf2Material).\r\n * These interfaces also accommodate some deviations from both specs that are known to exist in the wild.\r\n * Most aspects of the specifications that are not implemented here are omitted (e.g., skinning, animations).\r\n */\r\ninterface Gltf extends GltfProperty {\r\n /** Metadata about the glTF asset.\r\n * @note This property is required in glTF 2.0, but optional in 1.0.\r\n */\r\n asset?: GltfAsset;\r\n /** The Id of the default [[GltfScene]] in [[scenes]]. */\r\n scene?: GltfId;\r\n extensions?: GltfExtensions & {\r\n /** The [CESIUM_RTC extension](https://github.com/KhronosGroup/glTF/blob/main/extensions/1.0/Vendor/CESIUM_RTC/README.md) defines a centroid\r\n * relative to which all coordinates in the asset are defined, to reduce floating-point precision errors for large coordinates.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CESIUM_RTC?: {\r\n center?: number[];\r\n };\r\n /** The [KHR_techniques_webgl extension](https://github.com/KhronosGroup/glTF/blob/c1c12bd100e88ff468ccef1cb88cfbec56a69af2/extensions/2.0/Khronos/KHR_techniques_webgl/README.md)\r\n * allows \"techniques\" to be associated with [[GltfMaterial]]s. Techniques can supply custom shader programs to render geometry; this was a core feature of glTF 1.0 (see [[GltfTechnique]]).\r\n * Here, it is only used to extract uniform values.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_techniques_webgl?: {\r\n techniques?: Array<{\r\n uniforms?: {\r\n [key: string]: { type: GltfDataType, value?: any } | undefined;\r\n };\r\n }>;\r\n };\r\n };\r\n /** Names of glTF extensions used in the asset. */\r\n extensionsUsed?: string[];\r\n /** Names of glTF extensions required to properly load the asset. */\r\n extensionsRequired?: string[];\r\n accessors?: GltfDictionary<GltfAccessor>;\r\n /** Not currently supported. */\r\n animations?: GltfDictionary<any>;\r\n buffers?: GltfDictionary<GltfBuffer>;\r\n bufferViews?: GltfDictionary<GltfBufferViewProps>;\r\n /** Not currently used. */\r\n cameras?: GltfDictionary<any>;\r\n images?: GltfDictionary<GltfImage>;\r\n materials?: GltfDictionary<GltfMaterial>;\r\n meshes?: GltfDictionary<GltfMesh>;\r\n nodes?: GltfDictionary<GltfNode>;\r\n samplers?: GltfDictionary<GltfSampler>;\r\n scenes?: GltfDictionary<GltfScene>;\r\n /** Not currently supported. */\r\n skins?: GltfDictionary<any>;\r\n textures?: GltfDictionary<GltfTexture>;\r\n /** For glTF 1.0 only, techniques associated with [[Gltf1Material]]s. */\r\n techniques?: GltfDictionary<GltfTechnique>;\r\n}\r\n\r\n/** @internal */\r\nexport type GltfDataBuffer = Uint8Array | Uint16Array | Uint32Array | Float32Array;\r\n\r\n/**\r\n * A chunk of binary data exposed as a typed array.\r\n * The count member indicates how many elements exist. This may be less than this.buffer.length due to padding added to the\r\n * binary stream to ensure correct alignment.\r\n * @internal\r\n */\r\nexport class GltfBufferData {\r\n public readonly buffer: GltfDataBuffer;\r\n public readonly count: number;\r\n\r\n public constructor(buffer: GltfDataBuffer, count: number) {\r\n this.buffer = buffer;\r\n this.count = count;\r\n }\r\n\r\n /**\r\n * Create a GltfBufferData of the desired type. The actual type may differ from the desired type - for example, small 32-bit integers\r\n * may be represented as 8-bit or 16-bit integers instead.\r\n * If the actual data type is not convertible to the desired type, this function returns undefined.\r\n */\r\n public static create(bytes: Uint8Array, actualType: GltfDataType, expectedType: GltfDataType, count: number): GltfBufferData | undefined {\r\n if (expectedType !== actualType) {\r\n // Some data is stored in smaller data types to save space if no values exceed the maximum of the smaller type.\r\n switch (expectedType) {\r\n case GltfDataType.Float:\r\n case GltfDataType.UnsignedByte:\r\n return undefined;\r\n case GltfDataType.UnsignedShort:\r\n if (GltfDataType.UnsignedByte !== actualType)\r\n return undefined;\r\n break;\r\n case GltfDataType.UInt32:\r\n if (GltfDataType.UnsignedByte !== actualType && GltfDataType.UnsignedShort !== actualType)\r\n return undefined;\r\n break;\r\n }\r\n }\r\n\r\n const data = this.createDataBuffer(bytes, actualType);\r\n return undefined !== data ? new GltfBufferData(data, count) : undefined;\r\n }\r\n\r\n private static createDataBuffer(bytes: Uint8Array, actualType: GltfDataType): GltfDataBuffer | undefined {\r\n // NB: Endianness of typed array data is determined by the 'platform byte order'. Actual data is always little-endian.\r\n // We are assuming little-endian platform. If we find a big-endian platform, we'll need to use a DataView instead.\r\n switch (actualType) {\r\n case GltfDataType.UnsignedByte:\r\n return bytes;\r\n case GltfDataType.UnsignedShort:\r\n return new Uint16Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 2);\r\n case GltfDataType.UInt32:\r\n return new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);\r\n case GltfDataType.Float:\r\n return new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);\r\n default:\r\n return undefined;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A view of a chunk of glTF binary data containing an array of elements of a specific data type.\r\n * The count member indicates how many elements exist; this may be smaller than this.data.length.\r\n * The count member may also indicate the number of elements of a type containing more than one value of the\r\n * underlying type. For example, a buffer of 4 32-bit floating point 'vec2' elements will have a count of 4,\r\n * but its data member will contain 8 32-bit floating point values (2 per vec2).\r\n * The accessor member may contain additional JSON data specific to a particular buffer.\r\n * @internal\r\n */\r\nclass GltfBufferView {\r\n public readonly data: Uint8Array;\r\n public readonly count: number;\r\n public readonly type: GltfDataType;\r\n public readonly accessor: GltfAccessor;\r\n public readonly stride: number;\r\n\r\n public get byteLength(): number { return this.data.length; }\r\n\r\n public constructor(data: Uint8Array, count: number, type: GltfDataType, accessor: GltfAccessor, stride: number) {\r\n this.data = data;\r\n this.count = count;\r\n this.type = type;\r\n this.accessor = accessor;\r\n this.stride = stride;\r\n }\r\n\r\n public toBufferData(desiredType: GltfDataType): GltfBufferData | undefined {\r\n return GltfBufferData.create(this.data, this.type, desiredType, this.count);\r\n }\r\n}\r\n\r\n/* -----------------------------------\r\n * To restore the use of web workers to decode jpeg, locate and uncomment the three sections by searching for \"webworker\".\r\n import { WorkerOperation, WebWorkerManager } from \"../WebWorkerManager\";\r\n ------------------------------------ */\r\n\r\n/** The result of [[GltfReader.read]].\r\n * @internal\r\n */\r\nexport interface GltfReaderResult extends TileContent {\r\n readStatus: TileReadStatus;\r\n}\r\n\r\n/** Data required for creating a [[GltfReader]] capable of deserializing [glTF](https://www.khronos.org/gltf/).\r\n * @internal\r\n */\r\nexport class GltfReaderProps {\r\n private constructor(\r\n public readonly buffer: ByteStream,\r\n public readonly binaryData: Uint8Array,\r\n public readonly glTF: Gltf,\r\n public readonly yAxisUp: boolean) { }\r\n\r\n /** Attempt to construct a new GltfReaderProps from the binary data beginning at the supplied stream's current read position. */\r\n public static create(buffer: ByteStream, yAxisUp: boolean = false): GltfReaderProps | undefined {\r\n const header = new GltfHeader(buffer);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n const binaryData = new Uint8Array(buffer.arrayBuffer, header.binaryPosition);\r\n buffer.curPos = header.scenePosition;\r\n const jsonStrData = buffer.nextBytes(header.sceneStrLength);\r\n const jsonStr = utf8ToString(jsonStrData);\r\n if (undefined === jsonStr)\r\n return undefined;\r\n\r\n try {\r\n const json: Gltf = JSON.parse(jsonStr);\r\n const asset = JsonUtils.asObject(json.asset);\r\n if (header.version === 2 && !asset)\r\n return undefined; // asset is required in glTF 2.0\r\n\r\n const glTF: Gltf = {\r\n asset,\r\n scene: JsonUtils.asString(json.scene),\r\n extensions: JsonUtils.asObject(json.extensions),\r\n extensionsUsed: JsonUtils.asArray(json.extensionsUsed),\r\n extensionsRequired: JsonUtils.asArray(json.extensionsRequired),\r\n accessors: JsonUtils.asObject(json.accessors),\r\n buffers: JsonUtils.asObject(json.buffers),\r\n bufferViews: JsonUtils.asObject(json.bufferViews),\r\n images: JsonUtils.asObject(json.images),\r\n materials: JsonUtils.asObject(json.materials),\r\n meshes: JsonUtils.asObject(json.meshes),\r\n nodes: JsonUtils.asObject(json.nodes),\r\n samplers: JsonUtils.asObject(json.samplers),\r\n scenes: JsonUtils.asObject(json.scenes),\r\n textures: JsonUtils.asObject(json.textures),\r\n techniques: JsonUtils.asObject(json.techniques),\r\n };\r\n\r\n return glTF.meshes ? new GltfReaderProps(buffer, binaryData, glTF, yAxisUp) : undefined;\r\n } catch (e) {\r\n return undefined;\r\n }\r\n }\r\n}\r\n\r\n/** The GltfMeshData contains the raw GLTF mesh data. If the data is suitable to create a [[RealityMesh]] directly, basically in the quantized format produced by\r\n * ContextCapture, then a RealityMesh is created directly from this data. Otherwise, the mesh primitive is populated from the raw data and a MeshPrimitive\r\n * is generated. The MeshPrimitve path is much less efficient but should be rarely used.\r\n *\r\n * @internal\r\n */\r\nexport class GltfMeshData {\r\n public primitive: Mesh; // Populated with vertex and indices only if the mesh cannot be represented as [[RealityMesh]]\r\n public pointQParams?: QParams3d;\r\n public points?: Uint16Array;\r\n public pointRange?: Range3d;\r\n public normals?: Uint16Array;\r\n public uvQParams?: QParams2d;\r\n public uvs?: Uint16Array;\r\n public uvRange?: Range2d;\r\n public indices?: Uint16Array | Uint32Array;\r\n\r\n public constructor(props: Mesh) {\r\n this.primitive = props;\r\n }\r\n}\r\n\r\n/** A function that returns true if deserialization of the data supplied by the reader should abort.\r\n * @internal\r\n */\r\nexport type ShouldAbortReadGltf = (reader: GltfReader) => boolean;\r\n\r\n/* -----------------------------------\r\n This is part of the webworker option.\r\n\r\n // input is Uint8Array, the result is an ImageBitMap.\r\n class ImageDecodeWorkerOperation extends WorkerOperation {\r\n constructor(imageBytes: ArrayBuffer, imageMimeType: string) {\r\n super(\"imageBytesToImageBitmap\", [imageBytes, imageMimeType], [imageBytes]);\r\n }\r\n }\r\n-------------------------------------- */\r\n\r\nconst emptyDict = { };\r\n\r\nfunction colorFromJson(values: number[]): ColorDef {\r\n return ColorDef.from(values[0] * 255, values[1] * 255, values[2] * 255, (1.0 - values[3]) * 255);\r\n}\r\n\r\nfunction colorFromMaterial(material: GltfMaterial | undefined): ColorDef {\r\n if (material) {\r\n if (isGltf1Material(material)) {\r\n if (material.values?.color && Array.isArray(material.values.color))\r\n return colorFromJson(material.values.color);\r\n } else if (material.extensions?.KHR_techniques_webgl?.values?.u_color) {\r\n return colorFromJson(material.extensions.KHR_techniques_webgl.values.u_color);\r\n } else if (material.pbrMetallicRoughness?.baseColorFactor) {\r\n return colorFromJson(material.pbrMetallicRoughness.baseColorFactor);\r\n }\r\n }\r\n\r\n return ColorDef.white;\r\n}\r\n\r\nclass TransformStack {\r\n private readonly _stack: Array<Transform | undefined> = [];\r\n\r\n public get transform(): Transform | undefined {\r\n return this._stack.length > 0 ? this._stack[this._stack.length - 1] : undefined;\r\n }\r\n\r\n public get isEmpty(): boolean {\r\n return 0 === this._stack.length;\r\n }\r\n\r\n public push(node: GltfNode): void {\r\n let nodeTransform;\r\n if (node.matrix) {\r\n const origin = Point3d.create(node.matrix[12], node.matrix[13], node.matrix[14]);\r\n const matrix = Matrix3d.createRowValues(\r\n node.matrix[0], node.matrix[4], node.matrix[8],\r\n node.matrix[1], node.matrix[5], node.matrix[9],\r\n node.matrix[2], node.matrix[6], node.matrix[10],\r\n );\r\n\r\n nodeTransform = Transform.createOriginAndMatrix(origin, matrix);\r\n } else if (node.rotation || node.scale || node.translation) {\r\n // SPEC: To compose the local transformation matrix, TRS properties MUST be converted to matrices and postmultiplied in the T * R * S order;\r\n // first the scale is applied to the vertices, then the rotation, and then the translation.\r\n const scale = Transform.createRefs(undefined, node.scale ? Matrix3d.createScale(node.scale[0], node.scale[1], node.scale[2]) : Matrix3d.identity);\r\n const rot = Transform.createRefs(undefined, node.rotation ? Matrix3d.createFromQuaternion(Point4d.create(node.rotation[0], node.rotation[1], node.rotation[2], node.rotation[3])) : Matrix3d.identity);\r\n rot.matrix.transposeInPlace(); // See comment on Matrix3d.createFromQuaternion\r\n const trans = Transform.createTranslation(node.translation ? new Point3d(node.translation[0], node.translation[1], node.translation[2]) : Point3d.createZero());\r\n\r\n nodeTransform = scale.multiplyTransformTransform(rot);\r\n trans.multiplyTransformTransform(nodeTransform, nodeTransform);\r\n }\r\n\r\n const top = this.transform;\r\n if (!top)\r\n this._stack.push(nodeTransform);\r\n else\r\n this._stack.push(nodeTransform ? top.multiplyTransformTransform(nodeTransform) : top);\r\n }\r\n\r\n public pop(): void {\r\n assert(this._stack.length > 0);\r\n this._stack.pop();\r\n }\r\n}\r\n\r\n/** Deserializes [glTF](https://www.khronos.org/gltf/).\r\n * @internal\r\n */\r\nexport abstract class GltfReader {\r\n protected readonly _buffer: ByteStream;\r\n protected readonly _binaryData: Uint8Array;\r\n protected readonly _glTF: Gltf;\r\n protected readonly _iModel: IModelConnection;\r\n protected readonly _is3d: boolean;\r\n protected readonly _system: RenderSystem;\r\n protected readonly _returnToCenter?: Point3d;\r\n protected readonly _yAxisUp: boolean;\r\n protected readonly _type: BatchType;\r\n protected readonly _deduplicateVertices: boolean;\r\n private readonly _canceled?: ShouldAbortReadGltf;\r\n protected readonly _sceneNodes: GltfId[];\r\n protected _computedContentRange?: ElementAlignedBox3d;\r\n\r\n protected get _nodes(): GltfDictionary<GltfNode> { return this._glTF.nodes ?? emptyDict; }\r\n protected get _meshes(): GltfDictionary<GltfMesh> { return this._glTF.meshes ?? emptyDict; }\r\n protected get _accessors(): GltfDictionary<GltfAccessor> { return this._glTF.accessors ?? emptyDict; }\r\n protected get _bufferViews(): GltfDictionary<GltfBufferViewProps> { return this._glTF.bufferViews ?? emptyDict; }\r\n protected get _materialValues(): GltfDictionary<GltfMaterial> { return this._glTF.materials ?? emptyDict; }\r\n\r\n /* -----------------------------------\r\n private static _webWorkerManager: WebWorkerManager;\r\n\r\n private static get webWorkerManager() {\r\n if (!GltfReader._webWorkerManager) {\r\n GltfReader._webWorkerManager = new WebWorkerManager(\"v\" + BUILD_SEMVER + \"/frontend-webworker.js\", 4);\r\n }\r\n return GltfReader._webWorkerManager;\r\n }\r\n ------------------------------------- */\r\n\r\n /** Asynchronously deserialize the tile data and return the result. */\r\n public abstract read(): Promise<GltfReaderResult>;\r\n\r\n protected get _isCanceled(): boolean { return undefined !== this._canceled && this._canceled(this); }\r\n protected get _isVolumeClassifier(): boolean { return BatchType.VolumeClassifier === this._type; }\r\n\r\n protected readGltfAndCreateGraphics(isLeaf: boolean, featureTable: FeatureTable | undefined, contentRange: ElementAlignedBox3d | undefined, transformToRoot?: Transform, pseudoRtcBias?: Vector3d, instances?: InstancedGraphicParams): GltfReaderResult {\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf };\r\n\r\n // If contentRange was not supplied, we will compute it as we read the meshes.\r\n if (!contentRange)\r\n this._computedContentRange = contentRange = Range3d.createNull();\r\n else\r\n this._computedContentRange = undefined;\r\n\r\n // ###TODO this looks like a hack? Why does it assume the first node's transform is special, or that the transform will be specified as a matrix instead of translation+rot+scale?\r\n if (this._returnToCenter || this._nodes[0]?.matrix || (pseudoRtcBias && pseudoRtcBias.magnitude() < 1.0E5))\r\n pseudoRtcBias = undefined;\r\n\r\n const transformStack = new TransformStack();\r\n const renderGraphicList: RenderGraphic[] = [];\r\n let readStatus: TileReadStatus = TileReadStatus.InvalidTileData;\r\n for (const nodeKey of this._sceneNodes) {\r\n assert(transformStack.isEmpty);\r\n const node = this._nodes[nodeKey];\r\n if (node && TileReadStatus.Success !== (readStatus = this.readNodeAndCreateGraphics(renderGraphicList, node, featureTable, transformStack, instances, pseudoRtcBias)))\r\n return { readStatus, isLeaf };\r\n }\r\n\r\n if (0 === renderGraphicList.length)\r\n return { readStatus: TileReadStatus.InvalidTileData, isLeaf };\r\n\r\n let renderGraphic: RenderGraphic | undefined;\r\n if (1 === renderGraphicList.length)\r\n renderGraphic = renderGraphicList[0];\r\n else\r\n renderGraphic = this._system.createGraphicList(renderGraphicList);\r\n\r\n let transform;\r\n let range = contentRange;\r\n if (this._returnToCenter || pseudoRtcBias || this._yAxisUp || transformToRoot) {\r\n if (this._returnToCenter)\r\n transform = Transform.createTranslation(this._returnToCenter.clone());\r\n else if (pseudoRtcBias)\r\n transform = Transform.createTranslationXYZ(pseudoRtcBias.x, pseudoRtcBias.y, pseudoRtcBias.z);\r\n else\r\n transform = Transform.createIdentity();\r\n\r\n if (this._yAxisUp)\r\n transform = transform.multiplyTransformMatrix3d(Matrix3d.createRotationAroundVector(Vector3d.create(1.0, 0.0, 0.0), Angle.createRadians(Angle.piOver2Radians)) as Matrix3d);\r\n\r\n if (transformToRoot)\r\n transform = transformToRoot.multiplyTransformTransform(transform);\r\n\r\n range = transform.inverse()!.multiplyRange(contentRange);\r\n }\r\n\r\n if (featureTable)\r\n renderGraphic = this._system.createBatch(renderGraphic, PackedFeatureTable.pack(featureTable), range);\r\n\r\n if (transform) {\r\n const branch = new GraphicBranch(true);\r\n branch.add(renderGraphic);\r\n renderGraphic = this._system.createBranch(branch, transform);\r\n }\r\n\r\n return {\r\n readStatus,\r\n isLeaf,\r\n contentRange,\r\n graphic: renderGraphic,\r\n };\r\n }\r\n\r\n private graphicFromMeshData(gltfMesh: GltfMeshData, meshGraphicArgs: MeshGraphicArgs, instances?: InstancedGraphicParams) {\r\n if (!gltfMesh.points || !gltfMesh.pointRange)\r\n return;\r\n\r\n const realityMeshPrimitive = (forceLUT || instances) ? undefined : RealityMeshPrimitive.createFromGltfMesh(gltfMesh);\r\n if (realityMeshPrimitive) {\r\n const realityMesh = this._system.createRealityMesh(realityMeshPrimitive);\r\n if (realityMesh)\r\n return realityMesh;\r\n }\r\n\r\n const mesh = gltfMesh.primitive;\r\n const pointCount = gltfMesh.points.length / 3;\r\n mesh.points.fromTypedArray(gltfMesh.pointRange, gltfMesh.points);\r\n if (mesh.triangles && gltfMesh.indices)\r\n mesh.triangles.addFromTypedArray(gltfMesh.indices);\r\n\r\n if (gltfMesh.uvs && gltfMesh.uvRange && gltfMesh.uvQParams) {\r\n /** This is ugly and inefficient... unnecessary if Mesh stored uvs as QPoint2dList */\r\n for (let i = 0, j = 0; i < pointCount; i++)\r\n mesh.uvParams.push(gltfMesh.uvQParams.unquantize(gltfMesh.uvs[j++], gltfMesh.uvs[j++]));\r\n }\r\n\r\n if (gltfMesh.normals)\r\n for (const normal of gltfMesh.normals)\r\n mesh.normals.push(new OctEncodedNormal(normal));\r\n\r\n return mesh.getGraphics(meshGraphicArgs, this._system, instances);\r\n }\r\n\r\n private readNodeAndCreateGraphics(renderGraphicList: RenderGraphic[], node: GltfNode, featureTable: FeatureTable | undefined, transformStack: TransformStack, instances?: InstancedGraphicParams, pseudoRtcBias?: Vector3d): TileReadStatus {\r\n if (undefined === node)\r\n return TileReadStatus.InvalidTileData;\r\n\r\n // IMPORTANT: Do not return without popping this node from the stack.\r\n transformStack.push(node);\r\n const thisTransform = transformStack.transform;\r\n\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 let thisBias;\r\n if (undefined !== pseudoRtcBias)\r\n thisBias = (undefined === thisTransform) ? pseudoRtcBias : thisTransform.matrix.multiplyInverse(pseudoRtcBias);\r\n\r\n for (const meshKey of getNodeMeshIds(node)) {\r\n const nodeMesh = this._meshes[meshKey];\r\n if (nodeMesh?.primitives) {\r\n const meshGraphicArgs = new MeshGraphicArgs();\r\n const meshes = [];\r\n for (const primitive of nodeMesh.primitives) {\r\n const geometry = this.readMeshPrimitive(primitive, featureTable, thisBias);\r\n if (geometry) {\r\n meshes.push(geometry);\r\n if (this._computedContentRange && geometry.pointRange) {\r\n const invTransform = thisTransform?.inverse();\r\n const meshRange = invTransform ? invTransform.multiplyRange(geometry.pointRange) : geometry.pointRange;\r\n this._computedContentRange.extendRange(meshRange);\r\n }\r\n }\r\n }\r\n\r\n let renderGraphic: RenderGraphic | undefined;\r\n if (0 !== meshes.length) {\r\n if (1 === meshes.length) {\r\n renderGraphic = this.graphicFromMeshData(meshes[0], meshGraphicArgs, instances);\r\n } else {\r\n const thisList: RenderGraphic[] = [];\r\n for (const mesh of meshes) {\r\n renderGraphic = this.graphicFromMeshData(mesh, meshGraphicArgs, instances);\r\n if (undefined !== renderGraphic)\r\n thisList.push(renderGraphic);\r\n }\r\n\r\n if (0 !== thisList.length)\r\n renderGraphic = this._system.createGraphicList(thisList);\r\n }\r\n\r\n if (renderGraphic) {\r\n if (thisTransform && !thisTransform.isIdentity) {\r\n const branch = new GraphicBranch(true);\r\n branch.add(renderGraphic);\r\n renderGraphic = this._system.createBranch(branch, thisTransform);\r\n }\r\n\r\n renderGraphicList.push(renderGraphic);\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (node.children) {\r\n for (const childId of node.children) {\r\n const child = this._nodes[childId];\r\n if (child)\r\n this.readNodeAndCreateGraphics(renderGraphicList, child, featureTable, transformStack, instances);\r\n }\r\n }\r\n\r\n transformStack.pop();\r\n return TileReadStatus.Success;\r\n }\r\n\r\n // ###TODO what is the actual type of `json`?\r\n public getBufferView(json: any, accessorName: string): GltfBufferView | undefined {\r\n try {\r\n const accessorValue = JsonUtils.asString(json[accessorName]);\r\n const accessor = 0 < accessorValue.length ? JsonUtils.asObject(this._accessors[accessorValue]) : undefined;\r\n const bufferViewAccessorValue = undefined !== accessor ? JsonUtils.asString(accessor.bufferView) : \"\";\r\n const bufferView = 0 < bufferViewAccessorValue.length ? JsonUtils.asObject(this._bufferViews[bufferViewAccessorValue]) : undefined;\r\n\r\n if (undefined === accessor)\r\n return undefined;\r\n\r\n const type = accessor.componentType as GltfDataType;\r\n let dataSize = 0;\r\n switch (type) {\r\n case GltfDataType.UnsignedByte:\r\n dataSize = 1;\r\n break;\r\n case GltfDataType.UnsignedShort:\r\n dataSize = 2;\r\n break;\r\n case GltfDataType.UInt32:\r\n case GltfDataType.Float:\r\n dataSize = 4;\r\n break;\r\n default:\r\n return undefined;\r\n }\r\n let componentCount = 1;\r\n switch (accessor.type) {\r\n case \"VEC3\":\r\n componentCount = 3;\r\n break;\r\n case \"VEC2\":\r\n componentCount = 2;\r\n break;\r\n }\r\n\r\n const byteStride = bufferView.byteStride ? bufferView.byteStride : componentCount * dataSize;\r\n const offset = ((bufferView && bufferView.byteOffset) ? bufferView.byteOffset : 0) + (accessor.byteOffset ? accessor.byteOffset : 0);\r\n const length = byteStride * accessor.count;\r\n // If the data is misaligned (Scalable mesh tile publisher) use slice to copy -- else use subarray.\r\n // assert(0 === offset % dataSize);\r\n const bytes = (0 === (this._binaryData.byteOffset + offset) % dataSize) ? this._binaryData.subarray(offset, offset + length) : this._binaryData.slice(offset, offset + length);\r\n return new GltfBufferView(bytes, accessor.count as number, type, accessor, byteStride / dataSize);\r\n } catch (e) {\r\n return undefined;\r\n }\r\n }\r\n\r\n public readBufferData32(json: any, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UInt32); }\r\n public readBufferData16(json: any, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UnsignedShort); }\r\n public readBufferData8(json: any, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UnsignedByte); }\r\n public readBufferDataFloat(json: any, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.Float); }\r\n\r\n protected constructor(props: GltfReaderProps, iModel: IModelConnection, is3d: boolean, system: RenderSystem, type: BatchType = BatchType.Primary, isCanceled?: ShouldAbortReadGltf, deduplicateVertices=false) {\r\n this._buffer = props.buffer;\r\n this._binaryData = props.binaryData;\r\n this._glTF = props.glTF;\r\n this._yAxisUp = props.yAxisUp;\r\n\r\n const rtcCenter = props.glTF.extensions?.CESIUM_RTC?.center;\r\n if (rtcCenter && 3 === rtcCenter.length)\r\n if (0 !== rtcCenter[0] || 0 !== rtcCenter[1] || 0 !== rtcCenter[2])\r\n this._returnToCenter = Point3d.fromJSON(rtcCenter);\r\n\r\n this._iModel = iModel;\r\n this._is3d = is3d;\r\n this._system = system;\r\n this._type = type;\r\n this._canceled = isCanceled;\r\n this._deduplicateVertices = deduplicateVertices;\r\n\r\n // The original implementation of GltfReader would process and produce graphics for every node in glTF.nodes.\r\n // What it's *supposed* to do is process the nodes in glTF.scenes[glTF.scene].nodes\r\n // Some nodes may not be referenced by the configured scene, or only indirectly via GltfNode.children.\r\n // Perhaps some faulty tiles existed that didn't define their scenes properly?\r\n let sceneNodes;\r\n if (this._glTF.scenes && undefined !== this._glTF.scene)\r\n sceneNodes = this._glTF.scenes[this._glTF.scene]?.nodes;\r\n\r\n if (!sceneNodes)\r\n sceneNodes = Object.keys(this._nodes);\r\n\r\n this._sceneNodes = sceneNodes;\r\n }\r\n\r\n protected readBufferData(json: any, accessorName: string, type: GltfDataType): GltfBufferData | undefined {\r\n const view = this.getBufferView(json, accessorName);\r\n return undefined !== view ? view.toBufferData(type) : undefined;\r\n }\r\n\r\n protected readFeatureIndices(_json: any): number[] | undefined { return undefined; }\r\n\r\n private extractTextureId(material: GltfMaterial): string | undefined {\r\n if (typeof material !== \"object\")\r\n return undefined;\r\n\r\n const extractId = (value: any) => {\r\n switch (typeof value) {\r\n case \"string\":\r\n return value;\r\n case \"number\":\r\n return value.toString();\r\n default:\r\n return undefined;\r\n }\r\n };\r\n\r\n // Bimium's shader value...almost certainly obsolete at this point.\r\n if (isGltf1Material(material))\r\n return material.diffuse ?? extractId(material.values?.tex);\r\n\r\n // KHR_techniques_webgl extension\r\n const techniques = this._glTF.extensions?.KHR_techniques_webgl?.techniques;\r\n const ext = Array.isArray(techniques) ? material.extensions?.KHR_techniques_webgl : undefined;\r\n if (techniques && undefined !== ext && typeof(ext.values) === \"object\") {\r\n const uniforms = typeof ext.technique === \"number\" ? techniques[ext.technique].uniforms : undefined;\r\n if (typeof uniforms === \"object\") {\r\n for (const uniformName of Object.keys(uniforms)) {\r\n const uniform = uniforms[uniformName];\r\n if (typeof uniform === \"object\" && uniform.type === GltfDataType.Sampler2d)\r\n return extractId((ext.values[uniformName] as any)?.index);\r\n }\r\n }\r\n }\r\n\r\n const id = extractId(material.emissiveTexture?.index);\r\n return id ?? extractId(material.pbrMetallicRoughness?.baseColorTexture?.index);\r\n }\r\n\r\n protected createDisplayParams(materialJson: any, hasBakedLighting: boolean): DisplayParams | undefined {\r\n const textureId = this.extractTextureId(materialJson);\r\n const textureMapping = undefined !== textureId ? this.findTextureMapping(textureId) : undefined;\r\n const color = colorFromMaterial(materialJson);\r\n return new DisplayParams(DisplayParams.Type.Mesh, color, color, 1, LinePixels.Solid, FillFlags.Always, undefined, undefined, hasBakedLighting, textureMapping);\r\n }\r\n\r\n protected readMeshPrimitive(primitive: any, featureTable?: FeatureTable, pseudoRtcBias?: Vector3d): GltfMeshData | undefined {\r\n const materialName = JsonUtils.asString(primitive.material);\r\n const hasBakedLighting = undefined === primitive.attributes.NORMAL;\r\n const material = 0 < materialName.length ? this._materialValues[materialName] : undefined;\r\n const displayParams = this.createDisplayParams(material, hasBakedLighting);\r\n if (undefined === displayParams)\r\n return undefined;\r\n\r\n let primitiveType: number = -1;\r\n const meshMode = JsonUtils.asInt(primitive.mode, GltfMeshMode.Triangles);\r\n switch (meshMode) {\r\n case GltfMeshMode.Lines:\r\n primitiveType = Mesh.PrimitiveType.Polyline;\r\n break;\r\n\r\n case GltfMeshMode.Points:\r\n primitiveType = Mesh.PrimitiveType.Point;\r\n break;\r\n\r\n case GltfMeshMode.Triangles:\r\n primitiveType = Mesh.PrimitiveType.Mesh;\r\n break;\r\n\r\n default:\r\n assert(false);\r\n return undefined;\r\n }\r\n const isPlanar = JsonUtils.asBool(primitive.isPlanar);\r\n\r\n const isVolumeClassifier = this._isVolumeClassifier;\r\n const meshPrimitive = Mesh.create({\r\n displayParams,\r\n features: undefined !== featureTable ? new Mesh.Features(featureTable) : undefined,\r\n type: primitiveType,\r\n range: Range3d.createNull(),\r\n is2d: !this._is3d,\r\n isPlanar,\r\n hasBakedLighting,\r\n isVolumeClassifier,\r\n });\r\n\r\n const mesh = new GltfMeshData(meshPrimitive);\r\n\r\n // We don't have real colormap - just load material color. This will be used if non-Bentley\r\n // tile or fit the color table is uniform. For a non-Bentley, non-Uniform, we'll set the\r\n // uv parameters to pick the colors out of the color map texture.\r\n meshPrimitive.colorMap.insert(displayParams.fillColor.tbgr); // White...\r\n\r\n const colorIndices = this.readBufferData16(primitive.attributes, \"_COLORINDEX\");\r\n if (undefined !== colorIndices && material) {\r\n let texStep;\r\n if (isGltf1Material(material))\r\n texStep = material.values?.texStep;\r\n else\r\n texStep = material.extensions?.KHR_techniques_webgl?.values?.u_texStep;\r\n\r\n if (texStep) {\r\n const uvParams = [];\r\n for (let i = 0; i < colorIndices.count; i++)\r\n uvParams.push(new Point2d(texStep[1] + texStep[0] * colorIndices.buffer[i], .5));\r\n\r\n const paramList = QPoint2dList.fromPoints(uvParams);\r\n mesh.uvs = paramList.toTypedArray();\r\n mesh.uvQParams = paramList.params;\r\n }\r\n }\r\n\r\n if (primitive.extensions?.KHR_draco_mesh_compression) {\r\n return undefined; // Defer Draco decompression until web workers implementation.\r\n /*\r\n const dracoExtension = primitive.extensions.KHR_draco_mesh_compression;\r\n const bufferView = this._bufferViews[dracoExtension.bufferView];\r\n if (undefined === bufferView) return undefined;\r\n const bufferData = this._binaryData.subarray(bufferView.byteOffset, bufferView.byteOffset + bufferView.byteLength);\r\n\r\n return DracoDecoder.readDracoMesh(mesh, primitive, bufferData, dracoExtension.attributes); */\r\n }\r\n\r\n this.readBatchTable(mesh.primitive, primitive);\r\n\r\n if (!this.readVertices(mesh, primitive, pseudoRtcBias))\r\n return undefined;\r\n\r\n switch (primitiveType) {\r\n case Mesh.PrimitiveType.Mesh: {\r\n if (!this.readMeshIndices(mesh, primitive))\r\n return undefined;\r\n\r\n if (!displayParams.ignoreLighting && !this.readNormals(mesh, primitive.attributes, \"NORMAL\"))\r\n return undefined;\r\n\r\n if (!mesh.uvs)\r\n this.readUVParams(mesh, primitive.attributes, \"TEXCOORD_0\");\r\n\r\n if (this._deduplicateVertices && !this.deduplicateVertices(mesh))\r\n return undefined;\r\n\r\n break;\r\n }\r\n\r\n case Mesh.PrimitiveType.Polyline:\r\n case Mesh.PrimitiveType.Point: {\r\n if (undefined !== mesh.primitive.polylines && !this.readPolylines(mesh.primitive.polylines, primitive, \"indices\", Mesh.PrimitiveType.Point === primitiveType))\r\n return undefined;\r\n break;\r\n }\r\n default: {\r\n assert(false, \"unhandled primitive type\");\r\n return undefined;\r\n }\r\n }\r\n if (displayParams.textureMapping && !mesh.uvs)\r\n return undefined;\r\n\r\n if (primitive.extensions?.CESIUM_primitive_outline) {\r\n const data = this.readBufferData32(primitive.extensions.CESIUM_primitive_outline, \"indices\");\r\n if (data !== undefined) {\r\n assert(0 === data.count % 2);\r\n mesh.primitive.edges = new MeshEdges();\r\n for (let i = 0; i < data.count;)\r\n mesh.primitive.edges.visible.push(new MeshEdge(data.buffer[i++], data.buffer[i++]));\r\n }\r\n }\r\n\r\n return mesh;\r\n }\r\n\r\n private deduplicateVertices(mesh: GltfMeshData): boolean {\r\n if (!mesh.points || !mesh.indices)\r\n return false;\r\n\r\n const numPoints = mesh.indices.length;\r\n assert(0 === numPoints % 3);\r\n\r\n const indices = mesh.indices;\r\n if (indices instanceof Uint16Array && numPoints > 0xffff)\r\n mesh.indices = new Uint32Array(numPoints);\r\n\r\n const points = new Uint16Array(3 * numPoints);\r\n const normals = mesh.normals ? new Uint16Array(numPoints) : undefined;\r\n const uvs = mesh.uvs ? new Uint16Array(2 * numPoints) : undefined;\r\n\r\n for (let i = 0; i < numPoints; i++) {\r\n const index = indices[i];\r\n mesh.indices[i] = i;\r\n\r\n points[i * 3 + 0] = mesh.points[index * 3 + 0];\r\n points[i * 3 + 1] = mesh.points[index * 3 + 1];\r\n points[i * 3 + 2] = mesh.points[index * 3 + 2];\r\n\r\n if (normals)\r\n normals[i] = mesh.normals![index];\r\n\r\n if (uvs) {\r\n uvs[i * 2 + 0] = mesh.uvs![index * 2 + 0];\r\n uvs[i * 2 + 1] = mesh.uvs![index * 2 + 1];\r\n }\r\n }\r\n\r\n mesh.points = points;\r\n mesh.normals = normals;\r\n mesh.uvs = uvs;\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n *\r\n * @param positions quantized points\r\n * @param primitive input json\r\n * @param pseudoRtcBias a bias applied to each point - 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. This is essentially an ad hoc RTC applied at read time.\r\n */\r\n private readVertices(mesh: GltfMeshData, primitive: any, pseudoRtcBias?: Vector3d): boolean {\r\n const view = this.getBufferView(primitive.attributes, \"POSITION\");\r\n if (undefined === view)\r\n return false;\r\n\r\n if (GltfDataType.Float === view.type) {\r\n const buffer = view.toBufferData(GltfDataType.Float);\r\n if (undefined === buffer)\r\n return false;\r\n\r\n const strideSkip = view.stride - 3;\r\n mesh.pointRange = Range3d.createNull();\r\n for (let i = 0; i < buffer.buffer.length; i += strideSkip)\r\n mesh.pointRange.extendXYZ(buffer.buffer[i++], buffer.buffer[i++], buffer.buffer[i++]);\r\n\r\n const positions = new QPoint3dList(QParams3d.fromRange(mesh.pointRange));\r\n const scratchPoint = new Point3d();\r\n for (let i = 0, j = 0; i < buffer.count; i++, j += strideSkip) {\r\n scratchPoint.set(buffer.buffer[j++], buffer.buffer[j++], buffer.buffer[j++]);\r\n if (undefined !== pseudoRtcBias)\r\n scratchPoint.subtractInPlace(pseudoRtcBias);\r\n\r\n positions.add(scratchPoint);\r\n }\r\n mesh.pointQParams = positions.params;\r\n mesh.points = positions.toTypedArray();\r\n } else {\r\n if (GltfDataType.UnsignedShort !== view.type)\r\n return false;\r\n\r\n const extensions = JsonUtils.asObject(view.accessor.extensions);\r\n const quantized = undefined !== extensions ? JsonUtils.asObject(extensions.WEB3D_quantized_attributes) : undefined;\r\n if (undefined === quantized)\r\n return false;\r\n\r\n const rangeMin = JsonUtils.asArray(quantized.decodedMin);\r\n const rangeMax = JsonUtils.asArray(quantized.decodedMax);\r\n if (undefined === rangeMin || undefined === rangeMax)\r\n return false;\r\n\r\n const buffer = view.toBufferData(GltfDataType.UnsignedShort);\r\n if (undefined === buffer || !(buffer.buffer instanceof Uint16Array))\r\n return false;\r\n\r\n assert(buffer.buffer instanceof Uint16Array);\r\n mesh.pointRange = Range3d.createXYZXYZ(rangeMin[0], rangeMin[1], rangeMin[2], rangeMax[0], rangeMax[1], rangeMax[2]);\r\n if (undefined !== pseudoRtcBias) {\r\n mesh.pointRange.low.subtractInPlace(pseudoRtcBias);\r\n mesh.pointRange.high.subtractInPlace(pseudoRtcBias);\r\n }\r\n mesh.pointQParams = QParams3d.fromRange(mesh.pointRange);\r\n if (3 === view.stride) {\r\n mesh.points = buffer.buffer;\r\n } else {\r\n mesh.points = new Uint16Array(3 * view.count);\r\n for (let i = 0, j = 0; i < view.count; i++) {\r\n const index = i * view.stride;\r\n mesh.points[j++] = buffer.buffer[index];\r\n mesh.points[j++] = buffer.buffer[index + 1];\r\n mesh.points[j++] = buffer.buffer[index + 2];\r\n }\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n protected readIndices(json: any, accessorName: string): number[] | undefined {\r\n const data = this.readBufferData32(json, accessorName);\r\n if (undefined === data)\r\n return undefined;\r\n\r\n const indices = [];\r\n for (let i = 0; i < data.count; i++)\r\n indices.push(data.buffer[i]);\r\n\r\n return indices;\r\n }\r\n\r\n protected readBatchTable(_mesh: Mesh, _json: any) {\r\n }\r\n\r\n protected readMeshIndices(mesh: GltfMeshData, json: any): boolean {\r\n const data = this.readBufferData16(json, \"indices\") || this.readBufferData32(json, \"indices\");\r\n if (undefined === data || (!(data.buffer instanceof (Uint16Array)) && !(data.buffer instanceof (Uint32Array))))\r\n return false;\r\n\r\n mesh.indices = data.buffer;\r\n\r\n return true;\r\n }\r\n\r\n protected readNormals(mesh: GltfMeshData, json: any, accessorName: string): boolean {\r\n const view = this.getBufferView(json, accessorName);\r\n if (undefined === view)\r\n return false;\r\n\r\n switch (view.type) {\r\n case GltfDataType.Float: {\r\n const data = view.toBufferData(GltfDataType.Float);\r\n if (undefined === data)\r\n return false;\r\n\r\n mesh.normals = new Uint16Array(data.count);\r\n const scratchNormal = new Vector3d();\r\n const strideSkip = view.stride - 3;\r\n for (let i = 0, j = 0; i < data.count; i++, j += strideSkip) {\r\n scratchNormal.set(data.buffer[j++], data.buffer[j++], data.buffer[j++]);\r\n mesh.normals[i] = OctEncodedNormal.encode(scratchNormal);\r\n }\r\n return true;\r\n }\r\n\r\n case GltfDataType.UnsignedByte: {\r\n const data = view.toBufferData(GltfDataType.UnsignedByte);\r\n if (undefined === data)\r\n return false;\r\n\r\n // ###TODO: we shouldn't have to allocate OctEncodedNormal objects...just use uint16s / numbers...\r\n mesh.normals = new Uint16Array(data.count);\r\n for (let i = 0; i < data.count; i++) {\r\n // ###TODO? not clear why ray writes these as pairs of uint8...\r\n const index = i * view.stride;\r\n const normal = data.buffer[index] | (data.buffer[index + 1] << 8);\r\n mesh.normals[i] = normal;\r\n }\r\n return true;\r\n }\r\n default:\r\n return false;\r\n }\r\n }\r\n\r\n private readUVParams(mesh: GltfMeshData, json: any, accessorName: string): boolean {\r\n const view = this.getBufferView(json, accessorName);\r\n let data: any;\r\n\r\n if (view === undefined)\r\n return false;\r\n\r\n switch (view.type) {\r\n case GltfDataType.Float: {\r\n data = this.readBufferDataFloat(json, accessorName);\r\n mesh.uvRange = Range2d.createNull();\r\n\r\n for (let i = 0; i < data.count; i++) {\r\n const index = view.stride * i; // 2 float per param...\r\n mesh.uvRange.extendXY(data.buffer[index], data.buffer[index + 1]);\r\n }\r\n mesh.uvQParams = QParams2d.fromRange(mesh.uvRange);\r\n mesh.uvs = new Uint16Array(data.count * 2);\r\n for (let i = 0, j = 0; i < data.count; i++) {\r\n const index = view.stride * i; // 2 float per param...\r\n mesh.uvs[j++] = Quantization.quantize(data.buffer[index], mesh.uvQParams.origin.x, mesh.uvQParams.scale.x);\r\n mesh.uvs[j++] = Quantization.quantize(data.buffer[index + 1], mesh.uvQParams.origin.y, mesh.uvQParams.scale.y);\r\n }\r\n return true;\r\n }\r\n\r\n case GltfDataType.UnsignedShort: {\r\n const extensions = JsonUtils.asObject(view.accessor.extensions);\r\n const quantized = undefined !== extensions ? JsonUtils.asObject(extensions.WEB3D_quantized_attributes) : undefined;\r\n if (undefined === quantized)\r\n return false;\r\n\r\n const rangeMin = JsonUtils.asArray(quantized.decodedMin);\r\n const rangeMax = JsonUtils.asArray(quantized.decodedMax);\r\n if (undefined === rangeMin || undefined === rangeMax)\r\n return false;\r\n\r\n const qData = view.toBufferData(GltfDataType.UnsignedShort);\r\n if (undefined === qData || !(qData.buffer instanceof Uint16Array))\r\n return false;\r\n\r\n mesh.uvRange = Range2d.createXYXY(rangeMin[0], rangeMin[1], rangeMax[0], rangeMax[1]);\r\n mesh.uvQParams = QParams2d.fromRange(mesh.uvRange);\r\n if (2 === view.stride) {\r\n mesh.uvs = qData.buffer;\r\n } else {\r\n mesh.uvs = new Uint16Array(2 * view.count);\r\n for (let i = 0, j = 0; i < view.count; i++) {\r\n const index = i * view.stride;\r\n mesh.uvs[j++] = qData.buffer[index];\r\n mesh.uvs[j++] = qData.buffer[index + 1];\r\n }\r\n }\r\n return true;\r\n }\r\n default:\r\n assert(false);\r\n return false;\r\n\r\n }\r\n\r\n return true;\r\n }\r\n\r\n protected readPolylines(polylines: MeshPolylineList, json: any, accessorName: string, disjoint: boolean): boolean {\r\n const data = this.readBufferData32(json, accessorName);\r\n if (undefined === data)\r\n return false;\r\n\r\n const indices = new Array<number>();\r\n if (disjoint) {\r\n for (let i = 0; i < data.count;)\r\n indices.push(data.buffer[i++]);\r\n } else {\r\n for (let i = 0; i < data.count;) {\r\n const index0 = data.buffer[i++];\r\n const index1 = data.buffer[i++];\r\n if (0 === indices.length || index0 !== indices[indices.length - 1]) {\r\n if (indices.length !== 0) {\r\n polylines.push(new MeshPolyline(indices));\r\n indices.length = 0;\r\n }\r\n indices.push(index0);\r\n }\r\n indices.push(index1);\r\n }\r\n }\r\n if (indices.length !== 0)\r\n polylines.push(new MeshPolyline(indices));\r\n\r\n return true;\r\n }\r\n\r\n protected async loadTextures(): Promise<void> {\r\n if (undefined === this._glTF.textures)\r\n return;\r\n\r\n const transparentTextures: Set<string> = new Set<string>();\r\n if (this._glTF.techniques) {\r\n for (const name of Object.keys(this._materialValues)) {\r\n const material = this._materialValues[name];\r\n if (material && isGltf1Material(material) && undefined !== material.technique && undefined !== material.values?.tex) {\r\n const technique = this._glTF.techniques[material.technique];\r\n if (technique?.states?.enable) {\r\n for (const enable of technique.states.enable) {\r\n if (3042 === enable) { // 3042 = BLEND\r\n transparentTextures.add(material.values.tex.toString());\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n const promises = new Array<Promise<void>>();\r\n for (const name of Object.keys(this._glTF.textures))\r\n promises.push(this.loadTexture(name, transparentTextures.has(name)));\r\n\r\n if (promises.length > 0)\r\n await Promise.all(promises);\r\n }\r\n\r\n protected async loadTextureImage(imageJson: any, samplerJson: any, isTransparent: boolean): Promise<RenderTexture | undefined> {\r\n try {\r\n const binaryImageJson = (imageJson.extensions && imageJson.extensions.KHR_binary_glTF) ? JsonUtils.asObject(imageJson.extensions.KHR_binary_glTF) : imageJson;\r\n const bufferView = this._bufferViews[binaryImageJson.bufferView];\r\n if (!bufferView?.byteOffset || !bufferView?.byteLength)\r\n return undefined;\r\n\r\n const mimeType = JsonUtils.asString(binaryImageJson.mimeType);\r\n const format = getImageSourceFormatForMimeType(mimeType);\r\n if (undefined === format)\r\n return undefined;\r\n\r\n let textureType = RenderTexture.Type.Normal;\r\n if (undefined !== samplerJson &&\r\n (undefined !== samplerJson.wrapS || undefined !== samplerJson.wrapT))\r\n textureType = RenderTexture.Type.TileSection;\r\n\r\n const offset = bufferView.byteOffset;\r\n\r\n /* -----------------------------------\r\n const jpegArray = this._binaryData.slice(offset, offset + bufferView.byteLength);\r\n const jpegArrayBuffer = jpegArray.buffer;\r\n const workerOp = new ImageDecodeWorkerOperation(jpegArrayBuffer, mimeType);\r\n try {\r\n const imageBitmap = await GltfReader.webWorkerManager.queueOperation(workerOp)\r\n return this._isCanceled ? undefined : this._system.createTextureFromImage(imageBitmap, isTransparent && ImageSourceFormat.Png === format, this._iModel, textureParams))\r\n } catch {\r\n return undefined;\r\n }\r\n ------------------------------------- */\r\n\r\n const bytes = this._binaryData.subarray(offset, offset + bufferView.byteLength);\r\n const imageSource = new ImageSource(bytes, format);\r\n try {\r\n const image = await imageElementFromImageSource(imageSource);\r\n if (this._isCanceled)\r\n return undefined;\r\n\r\n return this._system.createTexture({\r\n type: textureType,\r\n image: {\r\n source: image,\r\n transparency: isTransparent && ImageSourceFormat.Png === format ? TextureTransparency.Translucent : TextureTransparency.Opaque,\r\n },\r\n });\r\n } catch {\r\n return undefined;\r\n }\r\n } catch (e) {\r\n return undefined;\r\n }\r\n }\r\n\r\n protected async loadTexture(textureId: string, isTransparent: boolean): Promise<void> {\r\n if (!this._glTF.textures || !this._glTF.images)\r\n return;\r\n\r\n const textureJson = JsonUtils.asObject(this._glTF.textures[textureId]);\r\n if (undefined === textureJson)\r\n return;\r\n\r\n const texture = await this.loadTextureImage(this._glTF.images[textureJson.source], this._glTF.samplers ? this._glTF.samplers[textureJson.sampler] : undefined, isTransparent);\r\n textureJson.renderTexture = texture;\r\n }\r\n\r\n protected findTextureMapping(textureId: string): TextureMapping | undefined {\r\n const textureJson = this._glTF.textures ? JsonUtils.asObject(this._glTF.textures[textureId]) : undefined;\r\n const texture = undefined !== textureJson ? textureJson.renderTexture as RenderTexture : undefined;\r\n return undefined !== texture ? new TextureMapping(texture, new TextureMapping.Params()) : undefined;\r\n }\r\n}\r\n\r\n/** Arguments supplied to [[readGltfGraphics]] to produce a [[RenderGraphic]] from a [glTF](https://www.khronos.org/gltf/) asset.\r\n * @public\r\n */\r\nexport interface ReadGltfGraphicsArgs {\r\n /** The binary data describing the glTF asset. */\r\n gltf: Uint8Array;\r\n /** The iModel with which the graphics will be associated - typically obtained from the [[Viewport]] into which they will be drawn. */\r\n iModel: IModelConnection;\r\n /** Options for making the graphic [pickable]($docs/learning/frontend/ViewDecorations#pickable-view-graphic-decorations).\r\n * Only the [[PickableGraphicOptions.id]] property is required to make the graphics pickable. If a `modelId` is also supplied and differs from the `id`,\r\n * the graphics will also be selectable.\r\n */\r\n pickableOptions?: PickableGraphicOptions & { modelId?: Id64String };\r\n}\r\n\r\n/** Produce a [[RenderGraphic]] from a [glTF](https://www.khronos.org/gltf/) asset suitable for use in [view decorations]($docs/learning/frontend/ViewDecorations).\r\n * @returns a graphic produced from the glTF asset's default scene, or `undefined` if a graphic could not be produced from the asset.\r\n * @note Support for the full [glTF 2.0 specification](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html) is currently a work in progress.\r\n * If a particular glTF asset fails to load and/or display properly, please\r\n * [submit an issue](https://github.com/iTwin/itwinjs-core/issues).\r\n * @see [Example decorator]($docs/learning/frontend/ViewDecorations#gltf-decorations) for an example of a decorator that reads and displays a glTF asset.\r\n * @public\r\n */\r\nexport async function readGltfGraphics(args: ReadGltfGraphicsArgs): Promise<RenderGraphic | undefined> {\r\n const stream = new ByteStream(args.gltf.buffer);\r\n const props = GltfReaderProps.create(stream, true); // glTF supports exactly one coordinate system with y axis up.\r\n const reader = props ? new Reader(props, args) : undefined;\r\n if (!reader)\r\n return undefined;\r\n\r\n const result = await reader.read();\r\n return result.graphic;\r\n}\r\n\r\n/** Implements [[readGltfGraphics]]. */\r\nclass Reader extends GltfReader {\r\n private readonly _featureTable?: FeatureTable;\r\n\r\n public constructor(props: GltfReaderProps, args: ReadGltfGraphicsArgs) {\r\n super(props, args.iModel, false, IModelApp.renderSystem);\r\n\r\n const pickableId = args.pickableOptions?.id;\r\n if (pickableId) {\r\n this._featureTable = new FeatureTable(1, args.pickableOptions?.modelId ?? pickableId, BatchType.Primary);\r\n this._featureTable.insert(new Feature(pickableId));\r\n }\r\n\r\n }\r\n\r\n public async read(): Promise<GltfReaderResult> {\r\n await this.loadTextures();\r\n return this.readGltfAndCreateGraphics(true, this._featureTable, undefined);\r\n }\r\n}\r\n"]}
|
|
@@ -20,6 +20,7 @@ export declare class I3dmReader extends GltfReader {
|
|
|
20
20
|
private _idMap?;
|
|
21
21
|
private _instanceCount;
|
|
22
22
|
private _featureTable?;
|
|
23
|
+
private readonly _modelId;
|
|
23
24
|
static create(stream: ByteStream, iModel: IModelConnection, modelId: Id64String, is3d: boolean, range: ElementAlignedBox3d, system: RenderSystem, yAxisUp: boolean, isLeaf: boolean, isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices?: boolean): I3dmReader | undefined;
|
|
24
25
|
private constructor();
|
|
25
26
|
read(): Promise<GltfReaderResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I3dmReader.d.ts","sourceRoot":"","sources":["../../../src/tile/I3dmReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAA2B,MAAM,qBAAqB,CAAC;AAEtF,OAAO,EAAa,mBAAmB,EAAqD,MAAM,oBAAoB,CAAC;AACvH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAmB,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AA8BlH;;;GAGG;AACH,qBAAa,UAAW,SAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"I3dmReader.d.ts","sourceRoot":"","sources":["../../../src/tile/I3dmReader.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,UAA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|
|
38
38
|
export class I3dmReader extends GltfReader {
|
|
39
39
|
constructor(_featureBinary, _featureJson, _batchTableJson, props, iModel, modelId, is3d, system, _range, _isLeaf, isCanceled, _idMap, deduplicateVertices = false) {
|
|
40
|
-
super(props, iModel,
|
|
40
|
+
super(props, iModel, is3d, system, BatchType.Primary, isCanceled, deduplicateVertices);
|
|
41
41
|
this._featureBinary = _featureBinary;
|
|
42
42
|
this._featureJson = _featureJson;
|
|
43
43
|
this._batchTableJson = _batchTableJson;
|
|
@@ -45,6 +45,7 @@ export class I3dmReader extends GltfReader {
|
|
|
45
45
|
this._isLeaf = _isLeaf;
|
|
46
46
|
this._idMap = _idMap;
|
|
47
47
|
this._instanceCount = 0;
|
|
48
|
+
this._modelId = modelId;
|
|
48
49
|
}
|
|
49
50
|
static create(stream, iModel, modelId, is3d, range, system, yAxisUp, isLeaf, isCanceled, idMap, deduplicateVertices = false) {
|
|
50
51
|
const header = new I3dmHeader(stream);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I3dmReader.js","sourceRoot":"","sources":["../../../src/tile/I3dmReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAA0B,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAuB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKvH,OAAO,EAAoB,UAAU,EAAE,eAAe,EAAyC,MAAM,YAAY,CAAC;AAElH,SAAS,YAAY,CAAC,UAAwB,EAAE,KAAa,EAAE,QAAkB,EAAE,MAAe;IAChG,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;IACrB,IAAI,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC;IAEzB,MAAM,cA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AAC,CAAC;gBAC9C,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;aAChD;SACF;QACD,MAAM,kBAAkB,GAAG,SAAS,CAAC;QAErC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;IAChF,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\nimport { ByteStream, Id64String, JsonUtils, utf8ToString } from \"@itwin/core-bentley\";\r\nimport { AxisOrder, Matrix3d, Point3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { BatchType, ElementAlignedBox3d, Feature, FeatureTable, I3dmHeader, TileReadStatus } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { InstancedGraphicParams } from \"../render/InstancedGraphicParams\";\r\nimport { Mesh } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport { BatchedTileIdMap, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf } from \"./internal\";\r\n\r\nfunction setTransform(transforms: Float32Array, index: number, rotation: Matrix3d, origin: Point3d): void {\r\n const i = index * 12;\r\n let rot = rotation.coffs;\r\n\r\n const ignoreRotation = false;\r\n if (ignoreRotation)\r\n rot = new Float64Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);\r\n\r\n const ignoreOrigin = false;\r\n if (ignoreOrigin)\r\n origin.x = origin.y = origin.z = 0;\r\n\r\n transforms[i + 0] = rot[0];\r\n transforms[i + 1] = rot[1];\r\n transforms[i + 2] = rot[2];\r\n transforms[i + 3] = origin.x;\r\n\r\n transforms[i + 4] = rot[3];\r\n transforms[i + 5] = rot[4];\r\n transforms[i + 6] = rot[5];\r\n transforms[i + 7] = origin.y;\r\n\r\n transforms[i + 8] = rot[6];\r\n transforms[i + 9] = rot[7];\r\n transforms[i + 10] = rot[8];\r\n transforms[i + 11] = origin.z;\r\n}\r\n\r\n/**\r\n * Deserializes a tile in [i3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Instanced3DModel) format.\r\n * @internal\r\n */\r\nexport class I3dmReader extends GltfReader {\r\n private _instanceCount = 0;\r\n private _featureTable?: FeatureTable;\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, isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices=false): I3dmReader | undefined {\r\n const header = new I3dmHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n const props = GltfReaderProps.create(stream, yAxisUp);\r\n if (undefined === props)\r\n return undefined;\r\n\r\n stream.curPos = header.featureTableJsonPosition;\r\n const featureStr = utf8ToString(stream.nextBytes(header.featureTableJsonLength));\r\n if (undefined === featureStr)\r\n return undefined;\r\n\r\n const featureBinary = new Uint8Array(stream.arrayBuffer, header.featureTableJsonPosition + header.featureTableJsonLength, header.featureTableBinaryLength);\r\n return new I3dmReader(featureBinary, JSON.parse(featureStr), header.batchTableJson, props, iModel, modelId, is3d, system,\r\n range, isLeaf, isCanceled, idMap, deduplicateVertices);\r\n }\r\n\r\n private constructor(private _featureBinary: Uint8Array, private _featureJson: any, private _batchTableJson: any, props: GltfReaderProps,\r\n iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem, private _range: ElementAlignedBox3d,\r\n private _isLeaf: boolean, isCanceled?: ShouldAbortReadGltf, private _idMap?: BatchedTileIdMap, deduplicateVertices=false) {\r\n super(props, iModel, modelId, is3d, system, BatchType.Primary, isCanceled, deduplicateVertices);\r\n }\r\n\r\n public async read(): Promise<GltfReaderResult> {\r\n this._instanceCount = JsonUtils.asInt(this._featureJson.INSTANCES_LENGTH, 0);\r\n\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n this._featureTable = new FeatureTable(undefined === this._batchTableJson ? this._instanceCount : 1, this._modelId, this._type);\r\n if (this._idMap !== undefined && this._batchTableJson !== undefined) {\r\n for (let i = 0; i < this._instanceCount; 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._featureTable.insert(new Feature(this._idMap.getBatchId(feature)));\r\n }\r\n } else {\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n const feature = new Feature(this._modelId);\r\n this._featureTable.insert(feature);\r\n }\r\n\r\n await this.loadTextures();\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf: this._isLeaf };\r\n\r\n const instances = this.readInstances();\r\n if (undefined === instances)\r\n return { readStatus: TileReadStatus.InvalidTileData, isLeaf: this._isLeaf };\r\n\r\n return this.readGltfAndCreateGraphics(this._isLeaf, this._featureTable, this._range, undefined, undefined, instances);\r\n }\r\n\r\n protected readFeatures(_features: Mesh.Features, _json: any): boolean {\r\n return false;\r\n }\r\n\r\n private readInstances(): InstancedGraphicParams | undefined {\r\n const count = JsonUtils.asInt(this._featureJson.INSTANCES_LENGTH, 0);\r\n if (count <= 0)\r\n return undefined;\r\n\r\n const json = this._featureJson;\r\n const binary = this._featureBinary;\r\n\r\n const batchIds = json.BATCH_ID ? new Int32Array(binary.buffer, binary.byteOffset + json.BATCH_ID.byteOffset, count) : undefined;\r\n const positions = json.POSITION ? new Float32Array(binary.buffer, binary.byteOffset + json.POSITION.byteOffset, count * 3) : undefined;\r\n const upNormals = json.NORMAL_UP ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_UP.byteOffset, count * 3) : undefined;\r\n const rightNormals = json.NORMAL_RIGHT ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_RIGHT.byteOffset, count * 3) : undefined;\r\n const scales = json.SCALE ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE.byteOffset, count) : undefined;\r\n const nonUniformScales = json.SCALE_NON_UNIFORM ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE_NON_UNIFORM.byteOffset, count * 3) : undefined;\r\n\r\n const matrix = Matrix3d.createIdentity();\r\n const position = Point3d.createZero();\r\n const upNormal = Vector3d.create(0, 0, 1);\r\n const rightNormal = Vector3d.create(1, 0, 0);\r\n const scale = Vector3d.create(1, 1, 1);\r\n\r\n const transformCenter = this._range.center;\r\n const transforms = new Float32Array(12 * count);\r\n for (let i = 0; i < count; i++) {\r\n const index = i * 3;\r\n if (positions)\r\n position.set(positions[index] - transformCenter.x, positions[index + 1] - transformCenter.y, positions[index + 2] - transformCenter.z);\r\n\r\n if (upNormals || rightNormals) {\r\n if (upNormals)\r\n upNormal.set(upNormals[index], upNormals[index + 1], upNormals[index + 2]);\r\n\r\n if (rightNormals)\r\n rightNormal.set(rightNormals[index], rightNormals[index + 1], rightNormals[index + 2]);\r\n\r\n if (scales)\r\n scale.x = scale.y = scale.z = scales[i];\r\n\r\n if (nonUniformScales) {\r\n scale.x *= nonUniformScales[index + 0];\r\n scale.y *= nonUniformScales[index + 1];\r\n scale.z *= nonUniformScales[index + 2];\r\n }\r\n\r\n Matrix3d.createRigidFromColumns(rightNormal, upNormal, AxisOrder.XYZ, matrix);\r\n if (scales || nonUniformScales)\r\n matrix.scaleColumnsInPlace(scale.x, scale.y, scale.z);\r\n\r\n setTransform(transforms, i, matrix, position);\r\n }\r\n }\r\n\r\n let featureIds;\r\n if (undefined !== batchIds) {\r\n featureIds = new Uint8Array(3 * batchIds.length);\r\n for (let i = 0, j = 0; i < batchIds.length; i++) {\r\n const batchId = batchIds[i];\r\n featureIds[j++] = batchId & 0x000000ff;\r\n featureIds[j++] = (batchId & 0x0000ff00) >> 8;\r\n featureIds[j++] = (batchId & 0x00ff0000) >> 16;\r\n }\r\n }\r\n const symbologyOverrides = undefined;\r\n\r\n return { count, transforms, symbologyOverrides, featureIds, transformCenter };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"I3dmReader.js","sourceRoot":"","sources":["../../../src/tile/I3dmReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAA0B,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAuB,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKvH,OAAO,EAAoB,UAAU,EAAE,eAAe,EAAyC,MAAM,YAAY,CAAC;AAElH,SAAS,YAAY,CAAC,UAAwB,EAAE,KAAa,EAAE,QAAkB,EAAE,MAAe;IAChG,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;IACrB,IAAI,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC;IAEzB,MAAM,cAAc,GAAG,KAAK,CAAC;IAC7B,IAAI,cAAc;QAChB,GAAG,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEtD,MAAM,YAAY,GAAG,KAAK,CAAC;IAC3B,IAAI,YAAY;QACd,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IAErC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3B,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;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AAQ,EAAE,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;gBAC9E,IAAI,MAAM,IAAI,gBAAgB;oBAC5B,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;gBAExD,YAAY,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;aAC/C;SACF;QAED,IAAI,UAAU,CAAC;QACf,IAAI,SAAS,KAAK,QAAQ,EAAE;YAC1B,UAAU,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;YACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC/C,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAC5B,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,GAAG,UAAU,CAAC;gBACvC,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;gBAC9C,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;aAChD;SACF;QACD,MAAM,kBAAkB,GAAG,SAAS,CAAC;QAErC,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;IAChF,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\nimport { ByteStream, Id64String, JsonUtils, utf8ToString } from \"@itwin/core-bentley\";\r\nimport { AxisOrder, Matrix3d, Point3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { BatchType, ElementAlignedBox3d, Feature, FeatureTable, I3dmHeader, TileReadStatus } from \"@itwin/core-common\";\r\nimport { IModelConnection } from \"../IModelConnection\";\r\nimport { InstancedGraphicParams } from \"../render/InstancedGraphicParams\";\r\nimport { Mesh } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport { BatchedTileIdMap, GltfReader, GltfReaderProps, GltfReaderResult, ShouldAbortReadGltf } from \"./internal\";\r\n\r\nfunction setTransform(transforms: Float32Array, index: number, rotation: Matrix3d, origin: Point3d): void {\r\n const i = index * 12;\r\n let rot = rotation.coffs;\r\n\r\n const ignoreRotation = false;\r\n if (ignoreRotation)\r\n rot = new Float64Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);\r\n\r\n const ignoreOrigin = false;\r\n if (ignoreOrigin)\r\n origin.x = origin.y = origin.z = 0;\r\n\r\n transforms[i + 0] = rot[0];\r\n transforms[i + 1] = rot[1];\r\n transforms[i + 2] = rot[2];\r\n transforms[i + 3] = origin.x;\r\n\r\n transforms[i + 4] = rot[3];\r\n transforms[i + 5] = rot[4];\r\n transforms[i + 6] = rot[5];\r\n transforms[i + 7] = origin.y;\r\n\r\n transforms[i + 8] = rot[6];\r\n transforms[i + 9] = rot[7];\r\n transforms[i + 10] = rot[8];\r\n transforms[i + 11] = origin.z;\r\n}\r\n\r\n/**\r\n * Deserializes a tile in [i3dm](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification/TileFormats/Instanced3DModel) format.\r\n * @internal\r\n */\r\nexport class I3dmReader extends GltfReader {\r\n private _instanceCount = 0;\r\n private _featureTable?: FeatureTable;\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, isCanceled?: ShouldAbortReadGltf, idMap?: BatchedTileIdMap, deduplicateVertices=false): I3dmReader | undefined {\r\n const header = new I3dmHeader(stream);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n const props = GltfReaderProps.create(stream, yAxisUp);\r\n if (undefined === props)\r\n return undefined;\r\n\r\n stream.curPos = header.featureTableJsonPosition;\r\n const featureStr = utf8ToString(stream.nextBytes(header.featureTableJsonLength));\r\n if (undefined === featureStr)\r\n return undefined;\r\n\r\n const featureBinary = new Uint8Array(stream.arrayBuffer, header.featureTableJsonPosition + header.featureTableJsonLength, header.featureTableBinaryLength);\r\n return new I3dmReader(featureBinary, JSON.parse(featureStr), header.batchTableJson, props, iModel, modelId, is3d, system,\r\n range, isLeaf, isCanceled, idMap, deduplicateVertices);\r\n }\r\n\r\n private constructor(private _featureBinary: Uint8Array, private _featureJson: any, private _batchTableJson: any, props: GltfReaderProps,\r\n iModel: IModelConnection, modelId: Id64String, is3d: boolean, system: RenderSystem, private _range: ElementAlignedBox3d,\r\n private _isLeaf: boolean, isCanceled?: ShouldAbortReadGltf, private _idMap?: BatchedTileIdMap, deduplicateVertices=false) {\r\n super(props, iModel, is3d, system, BatchType.Primary, isCanceled, deduplicateVertices);\r\n this._modelId = modelId;\r\n }\r\n\r\n public async read(): Promise<GltfReaderResult> {\r\n this._instanceCount = JsonUtils.asInt(this._featureJson.INSTANCES_LENGTH, 0);\r\n\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n this._featureTable = new FeatureTable(undefined === this._batchTableJson ? this._instanceCount : 1, this._modelId, this._type);\r\n if (this._idMap !== undefined && this._batchTableJson !== undefined) {\r\n for (let i = 0; i < this._instanceCount; 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._featureTable.insert(new Feature(this._idMap.getBatchId(feature)));\r\n }\r\n } else {\r\n // NB: For reality models with no batch table, we want the model ID in the feature table\r\n const feature = new Feature(this._modelId);\r\n this._featureTable.insert(feature);\r\n }\r\n\r\n await this.loadTextures();\r\n if (this._isCanceled)\r\n return { readStatus: TileReadStatus.Canceled, isLeaf: this._isLeaf };\r\n\r\n const instances = this.readInstances();\r\n if (undefined === instances)\r\n return { readStatus: TileReadStatus.InvalidTileData, isLeaf: this._isLeaf };\r\n\r\n return this.readGltfAndCreateGraphics(this._isLeaf, this._featureTable, this._range, undefined, undefined, instances);\r\n }\r\n\r\n protected readFeatures(_features: Mesh.Features, _json: any): boolean {\r\n return false;\r\n }\r\n\r\n private readInstances(): InstancedGraphicParams | undefined {\r\n const count = JsonUtils.asInt(this._featureJson.INSTANCES_LENGTH, 0);\r\n if (count <= 0)\r\n return undefined;\r\n\r\n const json = this._featureJson;\r\n const binary = this._featureBinary;\r\n\r\n const batchIds = json.BATCH_ID ? new Int32Array(binary.buffer, binary.byteOffset + json.BATCH_ID.byteOffset, count) : undefined;\r\n const positions = json.POSITION ? new Float32Array(binary.buffer, binary.byteOffset + json.POSITION.byteOffset, count * 3) : undefined;\r\n const upNormals = json.NORMAL_UP ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_UP.byteOffset, count * 3) : undefined;\r\n const rightNormals = json.NORMAL_RIGHT ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_RIGHT.byteOffset, count * 3) : undefined;\r\n const scales = json.SCALE ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE.byteOffset, count) : undefined;\r\n const nonUniformScales = json.SCALE_NON_UNIFORM ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE_NON_UNIFORM.byteOffset, count * 3) : undefined;\r\n\r\n const matrix = Matrix3d.createIdentity();\r\n const position = Point3d.createZero();\r\n const upNormal = Vector3d.create(0, 0, 1);\r\n const rightNormal = Vector3d.create(1, 0, 0);\r\n const scale = Vector3d.create(1, 1, 1);\r\n\r\n const transformCenter = this._range.center;\r\n const transforms = new Float32Array(12 * count);\r\n for (let i = 0; i < count; i++) {\r\n const index = i * 3;\r\n if (positions)\r\n position.set(positions[index] - transformCenter.x, positions[index + 1] - transformCenter.y, positions[index + 2] - transformCenter.z);\r\n\r\n if (upNormals || rightNormals) {\r\n if (upNormals)\r\n upNormal.set(upNormals[index], upNormals[index + 1], upNormals[index + 2]);\r\n\r\n if (rightNormals)\r\n rightNormal.set(rightNormals[index], rightNormals[index + 1], rightNormals[index + 2]);\r\n\r\n if (scales)\r\n scale.x = scale.y = scale.z = scales[i];\r\n\r\n if (nonUniformScales) {\r\n scale.x *= nonUniformScales[index + 0];\r\n scale.y *= nonUniformScales[index + 1];\r\n scale.z *= nonUniformScales[index + 2];\r\n }\r\n\r\n Matrix3d.createRigidFromColumns(rightNormal, upNormal, AxisOrder.XYZ, matrix);\r\n if (scales || nonUniformScales)\r\n matrix.scaleColumnsInPlace(scale.x, scale.y, scale.z);\r\n\r\n setTransform(transforms, i, matrix, position);\r\n }\r\n }\r\n\r\n let featureIds;\r\n if (undefined !== batchIds) {\r\n featureIds = new Uint8Array(3 * batchIds.length);\r\n for (let i = 0, j = 0; i < batchIds.length; i++) {\r\n const batchId = batchIds[i];\r\n featureIds[j++] = batchId & 0x000000ff;\r\n featureIds[j++] = (batchId & 0x0000ff00) >> 8;\r\n featureIds[j++] = (batchId & 0x00ff0000) >> 16;\r\n }\r\n }\r\n const symbologyOverrides = undefined;\r\n\r\n return { count, transforms, symbologyOverrides, featureIds, transformCenter };\r\n }\r\n}\r\n"]}
|