@itwin/core-frontend 4.0.0-dev.22 → 4.0.0-dev.24
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/GeoServices.d.ts +57 -5
- package/lib/cjs/GeoServices.d.ts.map +1 -1
- package/lib/cjs/GeoServices.js +182 -155
- package/lib/cjs/GeoServices.js.map +1 -1
- package/lib/cjs/request/Request.d.ts.map +1 -1
- package/lib/cjs/request/Request.js.map +1 -1
- package/lib/cjs/tile/GltfReader.js +1 -1
- package/lib/cjs/tile/GltfReader.js.map +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/cjs/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -2
- package/lib/cjs/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/lib/esm/GeoServices.d.ts +57 -5
- package/lib/esm/GeoServices.d.ts.map +1 -1
- package/lib/esm/GeoServices.js +180 -154
- package/lib/esm/GeoServices.js.map +1 -1
- package/lib/esm/request/Request.d.ts.map +1 -1
- package/lib/esm/request/Request.js.map +1 -1
- package/lib/esm/tile/GltfReader.js +1 -1
- package/lib/esm/tile/GltfReader.js.map +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.d.ts.map +1 -1
- package/lib/esm/tile/map/ArcGisUtilities.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.d.ts.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js +1 -2
- package/lib/esm/tile/map/ImageryProviders/ArcGISMapLayerImageryProvider.js.map +1 -1
- package/package.json +18 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GltfReader.js","sourceRoot":"","sources":["../../../src/tile/GltfRe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E,IAAW,MAAM,aAAgC,OAAO,MAAA,IAAI,CAAC,KAAK,CAAC,MAAM,mCAAI,SAAS,CAAC,CAAC,CAAC;IACzF,IAAW,UAAU,KAAe,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9D,IAAW,QAAQ,KAAkC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;CAC9E;AAnCD,gDAmCC","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 {\r\n assert, ByteStream, compareBooleans, compareNumbers, compareStrings, Dictionary, JsonUtils, Logger, utf8ToString,\r\n} from \"@itwin/core-bentley\";\r\nimport {\r\n Angle, IndexedPolyface, Matrix3d, Point2d, Point3d, Point4d, Polyface, Range2d, Range3d, Transform, Vector3d,\r\n} from \"@itwin/core-geometry\";\r\nimport {\r\n BatchType, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, FillFlags, GlbHeader, ImageSource, LinePixels, MeshEdge,\r\n MeshEdges, MeshPolyline, MeshPolylineList, OctEncodedNormal, PackedFeatureTable, QParams2d, QParams3d, QPoint2dList,\r\n QPoint3dList, Quantization, RenderMaterial, RenderTexture, TextureMapping, TextureTransparency, TileFormat, TileReadStatus,\r\n} from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"../FrontendLoggerCategory\";\r\nimport { getImageSourceFormatForMimeType, imageBitmapFromImageSource, imageElementFromImageSource, tryImageElementFromUrl } 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 { RealityMeshParams } from \"../render/RealityMeshParams\";\r\nimport { DisplayParams } from \"../render/primitives/DisplayParams\";\r\nimport { Mesh } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { Triangle } from \"../render/primitives/Primitives\";\r\nimport { RenderGraphic } from \"../render/RenderGraphic\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport { RealityTileGeometry, TileContent } from \"./internal\";\r\nimport type { DracoLoader, DracoMesh } from \"@loaders.gl/draco\";\r\nimport { TextureImageSource } from \"../render/RenderTexture\";\r\nimport { CreateRenderMaterialArgs } from \"../render/RenderMaterial\";\r\n\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\n * @internal\r\n */\r\nexport enum 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. @internal */\r\nexport type Gltf1Id = string;\r\n/** The type used to refer to an entry in a GltfDictionary in a glTF 2.0 asset. @internal */\r\nexport type Gltf2Id = number;\r\n/** The type used to refer to an entry in a GltfDictionary. @internal */\r\nexport type 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\nfunction * dictionaryIterator<T extends GltfChildOfRootProperty>(dict: GltfDictionary<T>): Iterable<T> {\r\n if (Array.isArray(dict)) {\r\n for (const elem of dict)\r\n yield elem;\r\n } else {\r\n for (const key of Object.keys(dict)) {\r\n const value = dict[key];\r\n if (undefined !== value)\r\n yield value;\r\n }\r\n }\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\ninterface DracoMeshCompression {\r\n bufferView: GltfId;\r\n // TEXCOORD_0, POSITION, etc\r\n attributes: { [k: string]: number | undefined };\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 extensions?: GltfExtensions & {\r\n /** The [CESIUM_primitive_outline](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/CESIUM_primitive_outline) extension\r\n * describes how to draw outline edges for a triangle mesh.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CESIUM_primitive_outline?: {\r\n /** The Id of the [[GltfBufferViewProps]] supplying the endpoints of each edge as indices into the triangle mesh's vertex array.\r\n * The number of indices must be even; each consecutive pair of indices describes one line segment. No connectivity between\r\n * line segments is implied.\r\n */\r\n indices?: GltfId;\r\n };\r\n /** The [KHR_draco_mesh_compression](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md) extension\r\n * allows glTF to support geometry compressed with Draco geometry compression.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_draco_mesh_compression?: DracoMeshCompression;\r\n };\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 ignored. */\r\n camera?: GltfId;\r\n /** Currently ignored. */\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 ignored. */\r\n jointName?: GltfId;\r\n /** Currently ignored. */\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 ignored. */\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 * @internal\r\n */\r\nexport type 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 */\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 extensions?: GltfExtensions & {\r\n /** The [KHR_binary_glTF](https://github.com/KhronosGroup/glTF/tree/main/extensions/1.0/Khronos/KHR_binary_glTF) allows an image to\r\n * be embedded in a binary chunk appended to the glTF asset's JSON, instead of being referenced by an external URI.\r\n * This is superseded in glTF 2.0 by support for the glb file format specification.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_binary_glTF?: {\r\n /** The Id of the [[GltfBufferViewProps]] that contains the binary image data. */\r\n bufferView?: GltfId;\r\n /** Required - @see [[GltfImage.mimeType]]. */\r\n mimeType?: string;\r\n };\r\n };\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 * For example, if `texCoord` is `2`, an attribute named `TEXCOORD_2` must exist containing the texture coordinates.\r\n * Default: 0.\r\n */\r\n texCoord?: number;\r\n}\r\n\r\n/** Describes a texture and its sampler.\r\n * @internal\r\n */\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\n * @note The implementation currently does not support MirroredRepeat and does not support different wrapping for U and V;\r\n * effectively, unless `wrapS` or `wrapT` is set to ClampToEdge, the sampler will use GltfWrapMode.Repeat.\r\n * @internal\r\n */\r\nexport interface 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. Default: Repeat. */\r\n wrapS?: GltfWrapMode;\r\n /** T (V) wrapping mode. Default: Repeat. */\r\n wrapT?: GltfWrapMode;\r\n}\r\n\r\n/** GL states that can be enabled by a [[GltfTechnique]]. Only those queried by this implementation are enumerated. */\r\nenum GltfTechniqueState {\r\n /** Enables alpha blending. */\r\n Blend = 3042,\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 [[GltfTechniqueState.Blend]] (3042) indicates that blending should be enabled.\r\n */\r\n enable?: GltfTechniqueState[];\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?: GltfTextureInfo;\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_materials_unlit](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_unlit) extension\r\n * indicates that the material should be displayed without lighting. The extension adds no additional properties; it is effectively a boolean flag.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_materials_unlit?: { };\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 * @internal\r\n */\r\nexport interface 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 public readonly version: number;\r\n public readonly glTF: Gltf;\r\n public readonly yAxisUp: boolean;\r\n public readonly binaryData?: Uint8Array;\r\n public readonly baseUrl?: string;\r\n\r\n private constructor(glTF: Gltf, version: number, yAxisUp: boolean, binaryData: Uint8Array | undefined, baseUrl?: string | undefined) {\r\n this.version = version;\r\n this.glTF = glTF;\r\n this.binaryData = binaryData;\r\n this.yAxisUp = yAxisUp;\r\n this.baseUrl = baseUrl;\r\n }\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(source: Uint8Array | Gltf, yAxisUp: boolean = false, baseUrl?: string): GltfReaderProps | undefined {\r\n let version: number;\r\n let json: Gltf;\r\n let binaryData: Uint8Array | undefined;\r\n\r\n if (source instanceof Uint8Array) {\r\n // It may be JSON - check for magic indicating glb.\r\n const buffer = ByteStream.fromUint8Array(source);\r\n if (TileFormat.Gltf !== buffer.readUint32()) {\r\n try {\r\n const utf8Json = utf8ToString(source);\r\n if (!utf8Json)\r\n return undefined;\r\n\r\n json = JSON.parse(utf8Json);\r\n version = 2;\r\n } catch (_) {\r\n return undefined;\r\n }\r\n } else {\r\n buffer.reset();\r\n const header = new GlbHeader(buffer);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n version = header.version;\r\n if (header.binaryChunk)\r\n binaryData = new Uint8Array(source.buffer, source.byteOffset + header.binaryChunk.offset, header.binaryChunk.length);\r\n\r\n try {\r\n const jsonBytes = new Uint8Array(source.buffer, source.byteOffset + header.jsonChunk.offset, header.jsonChunk.length);\r\n const jsonStr = utf8ToString(jsonBytes);\r\n if (undefined === jsonStr)\r\n return undefined;\r\n\r\n json = JSON.parse(jsonStr);\r\n } catch (_) {\r\n return undefined;\r\n }\r\n }\r\n } else {\r\n version = 2; // ###TODO verify against source.asset?.version\r\n json = source;\r\n }\r\n\r\n // asset is required in glTF 2, optional in glTF 1\r\n const asset = JsonUtils.asObject(json.asset);\r\n if (version === 2 && !asset)\r\n return undefined;\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(glTF, version, yAxisUp, binaryData, baseUrl) : undefined;\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?: Uint8Array | 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, isTransparent: boolean): ColorDef {\r\n let color = ColorDef.white;\r\n if (isGltf1Material(material)) {\r\n if (material.values?.color && Array.isArray(material.values.color))\r\n color = colorFromJson(material.values.color);\r\n } else if (material.extensions?.KHR_techniques_webgl?.values?.u_color) {\r\n color = colorFromJson(material.extensions.KHR_techniques_webgl.values.u_color);\r\n } else if (material.pbrMetallicRoughness?.baseColorFactor) {\r\n color = colorFromJson(material.pbrMetallicRoughness.baseColorFactor);\r\n }\r\n\r\n // SPEC: Opaque materials ignore any alpha channel.\r\n if (!isTransparent)\r\n color = color.withTransparency(0);\r\n\r\n return color;\r\n}\r\n\r\nclass TransformStack {\r\n private readonly _stack: Array<Transform | undefined> = [];\r\n\r\n public constructor(transform?: Transform) {\r\n if (transform)\r\n this._stack.push(transform);\r\n }\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/** Arguments to [[GltfReader]] constructor.\r\n * @internal\r\n */\r\nexport interface GltfReaderArgs {\r\n /** Properties of the glTF source. */\r\n props: GltfReaderProps;\r\n /** The iModel with which the graphics are to be associated. */\r\n iModel: IModelConnection;\r\n /** If true, create 2d graphics. */\r\n is2d?: boolean;\r\n /** The render system that will produce the graphics. Defaults to [[IModelApp.renderSystem]]. */\r\n system?: RenderSystem;\r\n /** The type of batch to create. Defaults to [BatchType.Primary]($common).\r\n * @see [[RenderSystem.createBatch]].\r\n */\r\n type?: BatchType;\r\n /** An optional function that, if supplied, is invoked periodically to determine if the process of producing graphics from the glTF should terminate early. */\r\n shouldAbort?: ShouldAbortReadGltf;\r\n /** If true, each vertex in the graphics should belong to exactly one triangle. This is less efficient than sharing vertices between adjoining triangles, but\r\n * sometimes required - for example, for [ViewFlags.wiremesh]($common).\r\n */\r\n deduplicateVertices?: boolean;\r\n /** If true, the graphics produced will always use a [[VertexTable]]; otherwise, where possible a [[RealityMeshParams]] will be used instead.\r\n * Reality meshes are simpler but do not support some features like lighting.\r\n */\r\n vertexTableRequired?: boolean;\r\n}\r\n\r\nfunction * traverseNodes(ids: Iterable<GltfId>, nodes: GltfDictionary<GltfNode>, traversed: Set<GltfId>): Iterable<GltfNode> {\r\n for (const id of ids) {\r\n if (traversed.has(id))\r\n throw new Error(\"Cycle detected while traversing glTF nodes\");\r\n\r\n const node = nodes[id];\r\n if (!node)\r\n continue;\r\n\r\n traversed.add(id);\r\n yield node;\r\n if (node.children)\r\n for (const child of traverseNodes(node.children, nodes, traversed))\r\n yield child;\r\n }\r\n}\r\n\r\ninterface TextureKey {\r\n readonly id: GltfId;\r\n readonly isTransparent: boolean;\r\n}\r\n\r\nfunction compareTextureKeys(lhs: TextureKey, rhs: TextureKey): number {\r\n const cmp = compareBooleans(lhs.isTransparent, rhs.isTransparent);\r\n if (0 !== cmp)\r\n return cmp;\r\n\r\n assert(typeof lhs.id === typeof rhs.id);\r\n if (\"string\" === typeof lhs.id) {\r\n assert(\"string\" === typeof rhs.id);\r\n return compareStrings(lhs.id, rhs.id);\r\n }\r\n\r\n assert(\"number\" === typeof lhs.id && \"number\" === typeof rhs.id);\r\n return compareNumbers(lhs.id, rhs.id);\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 _glTF: Gltf;\r\n protected readonly _version: number;\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 _baseUrl?: string;\r\n protected readonly _type: BatchType;\r\n protected readonly _deduplicateVertices: boolean;\r\n protected readonly _vertexTableRequired: boolean;\r\n private readonly _canceled?: ShouldAbortReadGltf;\r\n protected readonly _sceneNodes: GltfId[];\r\n protected _computedContentRange?: ElementAlignedBox3d;\r\n private readonly _resolvedTextures = new Dictionary<TextureKey, RenderTexture | false>((lhs, rhs) => compareTextureKeys(lhs, rhs));\r\n private readonly _dracoMeshes = new Map<DracoMeshCompression, DracoMesh>();\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 _materials(): GltfDictionary<GltfMaterial> { return this._glTF.materials ?? emptyDict; }\r\n protected get _samplers(): GltfDictionary<GltfSampler> { return this._glTF.samplers ?? emptyDict; }\r\n protected get _textures(): GltfDictionary<GltfTexture> { return this._glTF.textures ?? emptyDict; }\r\n\r\n protected get _images(): GltfDictionary<GltfImage & { resolvedImage?: TextureImageSource }> { return this._glTF.images ?? emptyDict; }\r\n protected get _buffers(): GltfDictionary<GltfBuffer & { resolvedBuffer?: Uint8Array }> { return this._glTF.buffers ?? 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 /** Traverse the nodes specified by their Ids, recursing into their child nodes.\r\n * @param nodeIds The Ids of the nodes to traverse.\r\n * @throws Error if a node appears more than once during traversal\r\n */\r\n public traverseNodes(nodeIds: Iterable<GltfId>): Iterable<GltfNode> {\r\n return traverseNodes(nodeIds, this._nodes, new Set<GltfId>());\r\n }\r\n\r\n /** Traverse the nodes specified by their scene, recursing into their child nodes.\r\n * @throws Error if a node appears more than once during traversal\r\n */\r\n public traverseScene(): Iterable<GltfNode> {\r\n return this.traverseNodes(this._sceneNodes);\r\n }\r\n\r\n private getTileTransform(transformToRoot?: Transform, pseudoRtcBias?: Vector3d): Transform | undefined {\r\n let transform;\r\n\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\r\n return transform;\r\n }\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 const transform = this.getTileTransform(transformToRoot, pseudoRtcBias);\r\n let range = contentRange;\r\n const invTransform = transform?.inverse();\r\n if (invTransform)\r\n range = invTransform.multiplyRange(contentRange);\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 public readGltfAndCreateGeometry(transformToRoot?: Transform, needNormals = false, needParams = false): RealityTileGeometry {\r\n const transformStack = new TransformStack(this.getTileTransform(transformToRoot));\r\n const polyfaces: Polyface[] = [];\r\n for (const nodeKey of this._sceneNodes) {\r\n const node = this._nodes[nodeKey];\r\n if (node)\r\n this.readNodeAndCreatePolyfaces(polyfaces, node, transformStack, needNormals, needParams);\r\n }\r\n\r\n return { polyfaces };\r\n }\r\n\r\n private graphicFromMeshData(gltfMesh: GltfMeshData, instances?: InstancedGraphicParams): RenderGraphic | undefined {\r\n if (!gltfMesh.points || !gltfMesh.pointRange)\r\n return gltfMesh.primitive.getGraphics(this._system, instances);\r\n\r\n const realityMeshPrimitive = (this._vertexTableRequired || instances) ? undefined : RealityMeshParams.fromGltfMesh(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 assert(mesh.points instanceof QPoint3dList);\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(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 meshes = this.readMeshPrimitives(node, featureTable, thisTransform, thisBias);\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], instances);\r\n } else {\r\n const thisList: RenderGraphic[] = [];\r\n for (const mesh of meshes) {\r\n renderGraphic = this.graphicFromMeshData(mesh, 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 private readNodeAndCreatePolyfaces(polyfaces: Polyface[], node: GltfNode, transformStack: TransformStack, needNormals: boolean, needParams: boolean): void {\r\n // IMPORTANT: Do not return without popping this node from the stack.\r\n transformStack.push(node);\r\n const meshes = this.readMeshPrimitives(node);\r\n\r\n for (const mesh of meshes) {\r\n const polyface = this.polyfaceFromGltfMesh(mesh, transformStack.transform, needNormals, needParams);\r\n if (polyface)\r\n polyfaces.push(polyface);\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.readNodeAndCreatePolyfaces(polyfaces, child, transformStack, needNormals, needParams);\r\n }\r\n }\r\n }\r\n\r\n private polyfaceFromGltfMesh(mesh: GltfMeshData, transform: Transform | undefined , needNormals: boolean, needParams: boolean): Polyface | undefined {\r\n if (!mesh.pointQParams || !mesh.points || !mesh.indices)\r\n return undefined;\r\n\r\n const { points, pointQParams, normals, uvs, uvQParams, indices } = mesh;\r\n\r\n const includeNormals = needNormals && undefined !== normals;\r\n const includeParams = needParams && undefined !== uvQParams && undefined !== uvs;\r\n\r\n const polyface = IndexedPolyface.create(includeNormals, includeParams);\r\n for (let i = 0; i < points.length; ) {\r\n const point = pointQParams.unquantize(points[i++], points[i++], points[i++]);\r\n if (transform)\r\n transform.multiplyPoint3d(point, point);\r\n\r\n polyface.addPoint(point);\r\n }\r\n\r\n if (includeNormals && normals)\r\n for (let i = 0; i < normals.length; )\r\n polyface.addNormal(OctEncodedNormal.decodeValue(normals[i++]));\r\n\r\n if (includeParams && uvs && uvQParams)\r\n for (let i = 0; i < uvs.length; )\r\n polyface.addParam(uvQParams.unquantize(uvs[i++], uvs[i++]));\r\n\r\n let j = 0;\r\n for (const index of indices) {\r\n polyface.addPointIndex(index);\r\n if (includeNormals)\r\n polyface.addNormalIndex(index);\r\n\r\n if (includeParams)\r\n polyface.addParamIndex(index);\r\n\r\n if (0 === (++j % 3))\r\n polyface.terminateFacet();\r\n }\r\n\r\n return polyface;\r\n }\r\n\r\n // ###TODO what is the actual type of `json`?\r\n public getBufferView(json: { [k: string]: any }, accessorName: string): GltfBufferView | undefined {\r\n try {\r\n const accessorValue = JsonUtils.asString(json[accessorName]);\r\n const accessor = accessorValue ? this._accessors[accessorValue] : undefined;\r\n if (!accessor)\r\n return undefined;\r\n\r\n const bufferViewAccessorValue = accessor.bufferView;\r\n const bufferView = undefined !== bufferViewAccessorValue ? this._bufferViews[bufferViewAccessorValue] : undefined;\r\n if (!bufferView || undefined === bufferView.buffer)\r\n return undefined;\r\n\r\n const buffer = this._buffers[bufferView.buffer];\r\n const bufferData = buffer?.resolvedBuffer;\r\n if (!bufferData)\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\r\n // If the data is misaligned (Scalable mesh tile publisher) use slice to copy -- else use subarray.\r\n const aligned = 0 === (bufferData.byteOffset + offset) % dataSize;\r\n const bytes = aligned ? bufferData.subarray(offset, offset + length) : bufferData.slice(offset, offset + length);\r\n return new GltfBufferView(bytes, accessor.count, type, accessor, byteStride / dataSize);\r\n } catch (e) {\r\n return undefined;\r\n }\r\n }\r\n\r\n public readBufferData32(json: { [k: string]: any }, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UInt32); }\r\n public readBufferData16(json: { [k: string]: any }, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UnsignedShort); }\r\n public readBufferData8(json: { [k: string]: any }, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UnsignedByte); }\r\n public readBufferDataFloat(json: { [k: string]: any }, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.Float); }\r\n\r\n protected constructor(args: GltfReaderArgs) {\r\n this._glTF = args.props.glTF;\r\n this._version = args.props.version;\r\n this._yAxisUp = args.props.yAxisUp;\r\n this._baseUrl = args.props.baseUrl;\r\n\r\n const rtcCenter = args.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 = args.iModel;\r\n this._is3d = true !== args.is2d;\r\n this._system = args.system ?? IModelApp.renderSystem;\r\n this._type = args.type ?? BatchType.Primary;\r\n this._canceled = args.shouldAbort;\r\n this._deduplicateVertices = args.deduplicateVertices ?? false;\r\n this._vertexTableRequired = args.vertexTableRequired ?? false;\r\n\r\n const binaryData = args.props.binaryData;\r\n if (binaryData) {\r\n const buffer = this._buffers[this._version === 2 ? 0 : \"binary_glTF\"];\r\n if (buffer && undefined === buffer.uri)\r\n buffer.resolvedBuffer = binaryData;\r\n }\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: { [k: string]: 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 extractId(value: any): string | undefined {\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 private extractTextureId(material: GltfMaterial): string | undefined {\r\n if (typeof material !== \"object\")\r\n return undefined;\r\n\r\n // Bimium's shader value...almost certainly obsolete at this point.\r\n if (isGltf1Material(material))\r\n return material.diffuse ?? this.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 this.extractId((ext.values[uniformName] as any)?.index);\r\n }\r\n }\r\n }\r\n\r\n const id = this.extractId(material.pbrMetallicRoughness?.baseColorTexture?.index);\r\n return id ?? this.extractId(material.emissiveTexture?.index);\r\n }\r\n\r\n private extractNormalMapId(material: GltfMaterial): string | undefined {\r\n if (typeof material !== \"object\")\r\n return undefined;\r\n\r\n if (isGltf1Material(material))\r\n return undefined;\r\n\r\n return this.extractId(material.normalTexture?.index);\r\n }\r\n\r\n private isMaterialTransparent(material: GltfMaterial): boolean {\r\n if (isGltf1Material(material)) {\r\n if (this._glTF.techniques && undefined !== material.technique) {\r\n const technique = this._glTF.techniques[material.technique];\r\n if (technique?.states?.enable?.some((state: GltfTechniqueState) => state === GltfTechniqueState.Blend))\r\n return true;\r\n }\r\n\r\n return false;\r\n } else {\r\n // Default: OPAQUE.\r\n // ###TODO support MASK. For now treat as opaque.\r\n return \"BLEND\" === material.alphaMode;\r\n }\r\n }\r\n\r\n protected createDisplayParams(material: GltfMaterial, hasBakedLighting: boolean): DisplayParams | undefined {\r\n const isTransparent = this.isMaterialTransparent(material);\r\n const textureId = this.extractTextureId(material);\r\n const normalMapId = this.extractNormalMapId(material);\r\n const textureMapping = (undefined !== textureId || undefined !== normalMapId) ? this.findTextureMapping(textureId, isTransparent, normalMapId) : undefined;\r\n const color = colorFromMaterial(material, isTransparent);\r\n let renderMaterial: RenderMaterial | undefined;\r\n if (undefined !== textureMapping && undefined !== textureMapping.normalMapParams) {\r\n const args: CreateRenderMaterialArgs = { diffuse: { color }, specular: { color: ColorDef.white }, textureMapping };\r\n renderMaterial = IModelApp.renderSystem.createRenderMaterial(args);\r\n }\r\n return new DisplayParams(DisplayParams.Type.Mesh, color, color, 1, LinePixels.Solid, FillFlags.Always, renderMaterial, undefined, hasBakedLighting, textureMapping);\r\n }\r\n\r\n private readMeshPrimitives(node: GltfNode, featureTable?: FeatureTable, thisTransform?: Transform, thisBias?: Vector3d): GltfMeshData[] {\r\n const meshes: GltfMeshData[] = [];\r\n for (const meshKey of getNodeMeshIds(node)) {\r\n const nodeMesh = this._meshes[meshKey];\r\n if (nodeMesh?.primitives) {\r\n for (const primitive of nodeMesh.primitives) {\r\n const mesh = this.readMeshPrimitive(primitive, featureTable, thisBias);\r\n if (mesh) {\r\n meshes.push(mesh);\r\n if (this._computedContentRange && mesh.pointRange) {\r\n const invTransform = thisTransform?.inverse();\r\n const meshRange = invTransform ? invTransform.multiplyRange(mesh.pointRange) : mesh.pointRange;\r\n this._computedContentRange.extendRange(meshRange);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return meshes;\r\n }\r\n\r\n protected readMeshPrimitive(primitive: GltfMeshPrimitive, featureTable?: FeatureTable, pseudoRtcBias?: Vector3d): GltfMeshData | undefined {\r\n const materialName = JsonUtils.asString(primitive.material);\r\n const material = 0 < materialName.length ? this._materials[materialName] : undefined;\r\n if (!material)\r\n return undefined;\r\n\r\n const hasBakedLighting = undefined === primitive.attributes.NORMAL || undefined !== material.extensions?.KHR_materials_unlit;\r\n const displayParams = material ? this.createDisplayParams(material, hasBakedLighting) : undefined;\r\n if (!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\r\n const isVolumeClassifier = this._isVolumeClassifier;\r\n const meshPrimitive = Mesh.create({\r\n displayParams,\r\n features: featureTable,\r\n type: primitiveType,\r\n range: Range3d.createNull(),\r\n is2d: !this._is3d,\r\n isPlanar: false,\r\n hasBakedLighting,\r\n isVolumeClassifier,\r\n quantizePositions: true,\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 const draco = primitive.extensions?.KHR_draco_mesh_compression;\r\n if (draco)\r\n return this.readDracoMeshPrimitive(mesh.primitive, draco) ? mesh : undefined;\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 let texCoordIndex = 0;\r\n if (!isGltf1Material(material) && undefined !== material.pbrMetallicRoughness?.baseColorTexture?.texCoord)\r\n texCoordIndex = JsonUtils.asInt(material.pbrMetallicRoughness.baseColorTexture.texCoord);\r\n\r\n this.readUVParams(mesh, primitive.attributes, `TEXCOORD_${texCoordIndex}`);\r\n }\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\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 readDracoMeshPrimitive(mesh: Mesh, ext: DracoMeshCompression): boolean {\r\n const draco = this._dracoMeshes.get(ext);\r\n if (!draco || \"triangle-list\" !== draco.topology)\r\n return false;\r\n\r\n const indices = draco.indices?.value;\r\n if (!indices || (indices.length % 3) !== 0)\r\n return false;\r\n\r\n const pos = draco.attributes.POSITION?.value;\r\n if (!pos || (pos.length % 3) !== 0)\r\n return false;\r\n\r\n // ###TODO: I have yet to see a draco-encoded mesh with interleaved attributes. Currently not checking.\r\n const triangle = new Triangle();\r\n for (let i = 0; i < indices.length; i += 3) {\r\n triangle.setIndices(indices[i], indices[i + 1], indices[i + 2]);\r\n mesh.addTriangle(triangle);\r\n }\r\n\r\n let posRange: Range3d;\r\n const bbox = draco.header?.boundingBox;\r\n if (bbox) {\r\n posRange = Range3d.createXYZXYZ(bbox[0][0], bbox[0][1], bbox[0][2], bbox[1][0], bbox[1][1], bbox[1][2]);\r\n } else {\r\n posRange = Range3d.createNull();\r\n for (let i = 0; i < pos.length; i += 3)\r\n posRange.extendXYZ(pos[i], pos[i + 1], pos[i + 2]);\r\n }\r\n\r\n assert(mesh.points instanceof QPoint3dList);\r\n mesh.points.params.setFromRange(posRange);\r\n const pt = Point3d.createZero();\r\n for (let i = 0; i < pos.length; i += 3) {\r\n pt.set(pos[i], pos[i + 1], pos[i + 2]);\r\n mesh.points.add(pt);\r\n }\r\n\r\n const normals = draco.attributes.NORMAL?.value;\r\n if (normals && (normals.length % 3) === 0) {\r\n const vec = Vector3d.createZero();\r\n for (let i = 0; i < normals.length; i += 3) {\r\n vec.set(normals[i], normals[i + 1], normals[i + 2]);\r\n mesh.normals.push(OctEncodedNormal.fromVector(vec));\r\n }\r\n }\r\n\r\n const uvs = draco.attributes.TEXCOORD_0?.value;\r\n if (uvs && (uvs.length & 2) === 0)\r\n for (let i = 0; i < uvs.length; i += 2)\r\n mesh.uvParams.push(new Point2d(uvs[i], uvs[i + 1]));\r\n\r\n const batchIds = draco.attributes._BATCHID?.value;\r\n if (batchIds && mesh.features) {\r\n const featureIndices = [];\r\n for (const batchId of batchIds)\r\n featureIndices.push(batchId);\r\n\r\n mesh.features.setIndices(featureIndices);\r\n }\r\n\r\n return true;\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 else if (indices instanceof Uint8Array && numPoints > 0xff)\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: GltfMeshPrimitive, 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: { [k: string]: 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: { [k: string]: any }): boolean {\r\n if (undefined !== json.indices) {\r\n const data = this.readBufferData16(json, \"indices\") || this.readBufferData32(json, \"indices\");\r\n if (data && (data.buffer instanceof Uint8Array || data.buffer instanceof Uint16Array || data.buffer instanceof Uint32Array)) {\r\n mesh.indices = data.buffer;\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n // Non-indexed geometry. Manufacture triangle indices from points.\r\n const numPoints = mesh.points?.length;\r\n if (undefined === numPoints || 0 !== numPoints % 3)\r\n return false;\r\n\r\n mesh.indices = numPoints < 255 ? new Uint8Array(numPoints) : (numPoints < 0xffff ? new Uint16Array(numPoints) : new Uint32Array(numPoints));\r\n for (let i = 0; i < numPoints; i++)\r\n mesh.indices[i] = i;\r\n\r\n return true;\r\n }\r\n\r\n protected readNormals(mesh: GltfMeshData, json: { [k: string]: 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: { [k: string]: any }, accessorName: string): boolean {\r\n const view = this.getBufferView(json, accessorName);\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 const data = this.readBufferDataFloat(json, accessorName);\r\n if (!data)\r\n return false;\r\n\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: { [k: string]: 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 resolveResources(): Promise<void> {\r\n // Load any external images and buffers.\r\n await this._resolveResources();\r\n\r\n // If any meshes are draco-compressed, dynamically load the decoder module and then decode the meshes.\r\n const dracoMeshes: DracoMeshCompression[] = [];\r\n\r\n for (const node of this.traverseScene()) {\r\n for (const meshId of getNodeMeshIds(node)) {\r\n const mesh = this._meshes[meshId];\r\n if (mesh?.primitives)\r\n for (const primitive of mesh.primitives)\r\n if (primitive.extensions?.KHR_draco_mesh_compression)\r\n dracoMeshes.push(primitive.extensions.KHR_draco_mesh_compression);\r\n }\r\n }\r\n\r\n if (dracoMeshes.length === 0)\r\n return;\r\n\r\n try {\r\n const dracoLoader = (await import(\"@loaders.gl/draco\")).DracoLoader;\r\n await Promise.all(dracoMeshes.map(async (x) => this.decodeDracoMesh(x, dracoLoader)));\r\n } catch (err) {\r\n Logger.logWarning(FrontendLoggerCategory.Render, \"Failed to decode draco-encoded glTF mesh\");\r\n Logger.logException(FrontendLoggerCategory.Render, err);\r\n }\r\n }\r\n\r\n private async _resolveResources(): Promise<void> {\r\n // ###TODO traverse the scene nodes to find resources referenced by them, instead of resolving everything - some resources may not\r\n // be required for the scene.\r\n const promises: Array<Promise<void>> = [];\r\n try {\r\n for (const buffer of dictionaryIterator(this._buffers))\r\n if (!buffer.resolvedBuffer)\r\n promises.push(this.resolveBuffer(buffer));\r\n\r\n await Promise.all(promises);\r\n if (this._isCanceled)\r\n return;\r\n\r\n promises.length = 0;\r\n for (const image of dictionaryIterator(this._images))\r\n if (!image.resolvedImage)\r\n promises.push(this.resolveImage(image));\r\n\r\n await Promise.all(promises);\r\n } catch (_) {\r\n }\r\n }\r\n\r\n private async decodeDracoMesh(ext: DracoMeshCompression, loader: typeof DracoLoader): Promise<void> {\r\n const bv = this._bufferViews[ext.bufferView];\r\n if (!bv || !bv.byteLength)\r\n return;\r\n\r\n let buf = this._buffers[bv.buffer]?.resolvedBuffer;\r\n if (!buf)\r\n return;\r\n\r\n const offset = bv.byteOffset ?? 0;\r\n buf = buf.subarray(offset, offset + bv.byteLength);\r\n const mesh = await loader.parse(buf, { }); // NB: `options` argument declared optional but will produce exception if not supplied.\r\n if (mesh)\r\n this._dracoMeshes.set(ext, mesh);\r\n }\r\n\r\n private resolveUrl(uri: string): string | undefined {\r\n try {\r\n return new URL(uri, this._baseUrl).toString();\r\n } catch (_) {\r\n return undefined;\r\n }\r\n }\r\n\r\n private async resolveBuffer(buffer: GltfBuffer & { resolvedBuffer?: Uint8Array }): Promise<void> {\r\n if (buffer.resolvedBuffer || undefined === buffer.uri)\r\n return;\r\n\r\n try {\r\n const url = this.resolveUrl(buffer.uri);\r\n const response = url ? await fetch(url) : undefined;\r\n if (this._isCanceled)\r\n return;\r\n\r\n const data = await response?.arrayBuffer();\r\n if (this._isCanceled)\r\n return;\r\n\r\n if (data)\r\n buffer.resolvedBuffer = new Uint8Array(data);\r\n } catch (_) {\r\n //\r\n }\r\n }\r\n\r\n private async resolveImage(image: GltfImage & { resolvedImage?: TextureImageSource }): Promise<void> {\r\n if (image.resolvedImage)\r\n return;\r\n\r\n interface BufferViewSource { bufferView?: GltfId, mimeType?: string }\r\n const bvSrc: BufferViewSource | undefined = undefined !== image.bufferView ? image : image.extensions?.KHR_binary_glTF;\r\n if (undefined !== bvSrc?.bufferView) {\r\n const format = undefined !== bvSrc.mimeType ? getImageSourceFormatForMimeType(bvSrc.mimeType) : undefined;\r\n const bufferView = this._bufferViews[bvSrc.bufferView];\r\n if (undefined === format || !bufferView || !bufferView.byteLength || bufferView.byteLength < 0)\r\n return;\r\n\r\n const bufferData = this._buffers[bufferView.buffer]?.resolvedBuffer;\r\n if (!bufferData)\r\n return;\r\n\r\n const offset = bufferView.byteOffset ?? 0;\r\n const bytes = bufferData.subarray(offset, offset + bufferView.byteLength);\r\n try {\r\n const imageSource = new ImageSource(bytes, format);\r\n if (this._system.supportsCreateImageBitmap)\r\n image.resolvedImage = await imageBitmapFromImageSource(imageSource);\r\n else\r\n image.resolvedImage = await imageElementFromImageSource(imageSource);\r\n } catch (_) {\r\n //\r\n }\r\n\r\n return;\r\n }\r\n\r\n const url = undefined !== image.uri ? this.resolveUrl(image.uri) : undefined;\r\n if (undefined !== url)\r\n image.resolvedImage = await tryImageElementFromUrl(url);\r\n }\r\n\r\n /** The glTF spec says that if GltfSampler.wrapS/T are omitted, they default to Repeat.\r\n * However, the reality data service serves tiles that lack any wrapS/T property, and we want those clamped to edge, not repeated.\r\n * (We also don't want to produce mip-maps for them, which is determined indirectly from the wrap mode).\r\n * Allow the default to be optionally overridden.\r\n */\r\n public defaultWrapMode = GltfWrapMode.Repeat;\r\n\r\n /** Exposed strictly for testing. */\r\n public getTextureType(sampler?: GltfSampler): RenderTexture.Type {\r\n // ###TODO: RenderTexture currently does not support different wrapping behavior for U vs V, nor does it support mirrored repeat.\r\n let wrapS = sampler?.wrapS;\r\n let wrapT = sampler?.wrapT;\r\n if (undefined === wrapS && undefined === wrapT)\r\n wrapS = wrapT = this.defaultWrapMode;\r\n\r\n if (GltfWrapMode.ClampToEdge === wrapS || GltfWrapMode.ClampToEdge === wrapT)\r\n return RenderTexture.Type.TileSection;\r\n\r\n return RenderTexture.Type.Normal;\r\n }\r\n\r\n private resolveTexture(textureId: string, isTransparent: boolean): RenderTexture | false {\r\n const texture = this._textures[textureId];\r\n if (!texture || undefined === texture.source)\r\n return false;\r\n\r\n const image = this._images[texture.source]?.resolvedImage;\r\n if (!image)\r\n return false;\r\n\r\n const samplerId = texture.sampler;\r\n const sampler = undefined !== samplerId ? this._samplers[samplerId] : undefined;\r\n const textureType = this.getTextureType(sampler);\r\n const renderTexture = this._system.createTexture({\r\n type: textureType,\r\n image: {\r\n source: image,\r\n transparency: isTransparent ? TextureTransparency.Mixed : TextureTransparency.Opaque,\r\n },\r\n });\r\n\r\n return renderTexture ?? false;\r\n }\r\n\r\n protected findTextureMapping(id: string | undefined, isTransparent: boolean, normalMapId: string | undefined): TextureMapping | undefined {\r\n if (undefined === id && undefined === normalMapId)\r\n return undefined;\r\n\r\n let texture;\r\n if (undefined !== id) {\r\n texture = this._resolvedTextures.get({ id, isTransparent });\r\n if (undefined === texture)\r\n this._resolvedTextures.set({ id, isTransparent }, texture = this.resolveTexture(id, isTransparent));\r\n }\r\n\r\n let normalMap;\r\n if (undefined !== normalMapId) {\r\n normalMap = this._resolvedTextures.get({ id: normalMapId, isTransparent: false });\r\n if (undefined === normalMap)\r\n this._resolvedTextures.set({ id: normalMapId, isTransparent: false }, normalMap = this.resolveTexture(normalMapId, false));\r\n }\r\n\r\n let nMap;\r\n if (normalMap) {\r\n const greenUp = true;\r\n if (texture) {\r\n nMap = {\r\n normalMap,\r\n greenUp,\r\n };\r\n } else {\r\n texture = normalMap;\r\n nMap = { greenUp };\r\n }\r\n }\r\n\r\n if (!texture)\r\n return undefined;\r\n\r\n const textureMapping = new TextureMapping(texture, new TextureMapping.Params());\r\n textureMapping.normalMapParams = nMap;\r\n return textureMapping;\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 /** A representation of the glTF data as one of:\r\n * - The binary data in glb format as a Uint8Array; or\r\n * - A JSON object conforming to the [glTF 2.0 specification](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html); or\r\n * - A Uint8Array containing the utf8-encoded stringified JSON of an object conforming to the [glTF 2.0 specification](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html).\r\n */\r\n gltf: Uint8Array | Object;\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;\r\n /** The base URL for any relative URIs in the glTF. Typically, this is the same as the URL for the glTF asset itself.\r\n * If not supplied, relative URIs cannot be resolved. For glTF assets containing no relative URIs, this is not required.\r\n */\r\n baseUrl?: string;\r\n /** @alpha */\r\n contentRange?: ElementAlignedBox3d;\r\n /** @alpha */\r\n transform?: Transform;\r\n /** @alpha */\r\n hasChildren?: boolean;\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 props = GltfReaderProps.create(args.gltf, true, args.baseUrl); // glTF supports exactly one coordinate system with y axis up.\r\n const reader = props ? new GltfGraphicsReader(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]]. Exported strictly for tests.\r\n * @internal\r\n */\r\nexport class GltfGraphicsReader extends GltfReader {\r\n private readonly _featureTable?: FeatureTable;\r\n private readonly _contentRange?: ElementAlignedBox3d;\r\n private readonly _transform?: Transform;\r\n private readonly _isLeaf: boolean;\r\n public readonly binaryData?: Uint8Array; // strictly for tests\r\n\r\n public constructor(props: GltfReaderProps, args: ReadGltfGraphicsArgs) {\r\n super({\r\n props,\r\n iModel: args.iModel,\r\n vertexTableRequired: true,\r\n });\r\n\r\n this._contentRange = args.contentRange;\r\n this._transform = args.transform;\r\n this._isLeaf = true !== args.hasChildren;\r\n\r\n this.binaryData = props.binaryData;\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 public async read(): Promise<GltfReaderResult> {\r\n await this.resolveResources();\r\n return this.readGltfAndCreateGraphics(this._isLeaf, this._featureTable, this._contentRange, this._transform);\r\n }\r\n\r\n public get nodes(): GltfDictionary<GltfNode> { return this._nodes; }\r\n public get scenes(): GltfDictionary<GltfScene> { return this._glTF.scenes ?? emptyDict; }\r\n public get sceneNodes(): GltfId[] { return this._sceneNodes; }\r\n public get textures(): GltfDictionary<GltfTexture> { return this._textures; }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"GltfReader.js","sourceRoot":"","sources":["../../../src/tile/GltfRe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pE,IAAW,MAAM,aAAgC,OAAO,MAAA,IAAI,CAAC,KAAK,CAAC,MAAM,mCAAI,SAAS,CAAC,CAAC,CAAC;IACzF,IAAW,UAAU,KAAe,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IAC9D,IAAW,QAAQ,KAAkC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;CAC9E;AAnCD,gDAmCC","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 {\r\n assert, ByteStream, compareBooleans, compareNumbers, compareStrings, Dictionary, JsonUtils, Logger, utf8ToString,\r\n} from \"@itwin/core-bentley\";\r\nimport {\r\n Angle, IndexedPolyface, Matrix3d, Point2d, Point3d, Point4d, Polyface, Range2d, Range3d, Transform, Vector3d,\r\n} from \"@itwin/core-geometry\";\r\nimport {\r\n BatchType, ColorDef, ElementAlignedBox3d, Feature, FeatureTable, FillFlags, GlbHeader, ImageSource, LinePixels, MeshEdge,\r\n MeshEdges, MeshPolyline, MeshPolylineList, OctEncodedNormal, PackedFeatureTable, QParams2d, QParams3d, QPoint2dList,\r\n QPoint3dList, Quantization, RenderMaterial, RenderTexture, TextureMapping, TextureTransparency, TileFormat, TileReadStatus,\r\n} from \"@itwin/core-common\";\r\nimport { FrontendLoggerCategory } from \"../FrontendLoggerCategory\";\r\nimport { getImageSourceFormatForMimeType, imageBitmapFromImageSource, imageElementFromImageSource, tryImageElementFromUrl } 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 { RealityMeshParams } from \"../render/RealityMeshParams\";\r\nimport { DisplayParams } from \"../render/primitives/DisplayParams\";\r\nimport { Mesh } from \"../render/primitives/mesh/MeshPrimitives\";\r\nimport { Triangle } from \"../render/primitives/Primitives\";\r\nimport { RenderGraphic } from \"../render/RenderGraphic\";\r\nimport { RenderSystem } from \"../render/RenderSystem\";\r\nimport { RealityTileGeometry, TileContent } from \"./internal\";\r\nimport type { DracoLoader, DracoMesh } from \"@loaders.gl/draco\";\r\nimport { TextureImageSource } from \"../render/RenderTexture\";\r\nimport { CreateRenderMaterialArgs } from \"../render/RenderMaterial\";\r\n\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\n * @internal\r\n */\r\nexport enum 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. @internal */\r\nexport type Gltf1Id = string;\r\n/** The type used to refer to an entry in a GltfDictionary in a glTF 2.0 asset. @internal */\r\nexport type Gltf2Id = number;\r\n/** The type used to refer to an entry in a GltfDictionary. @internal */\r\nexport type 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\nfunction * dictionaryIterator<T extends GltfChildOfRootProperty>(dict: GltfDictionary<T>): Iterable<T> {\r\n if (Array.isArray(dict)) {\r\n for (const elem of dict)\r\n yield elem;\r\n } else {\r\n for (const key of Object.keys(dict)) {\r\n const value = dict[key];\r\n if (undefined !== value)\r\n yield value;\r\n }\r\n }\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\ninterface DracoMeshCompression {\r\n bufferView: GltfId;\r\n // TEXCOORD_0, POSITION, etc\r\n attributes: { [k: string]: number | undefined };\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 extensions?: GltfExtensions & {\r\n /** The [CESIUM_primitive_outline](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Vendor/CESIUM_primitive_outline) extension\r\n * describes how to draw outline edges for a triangle mesh.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CESIUM_primitive_outline?: {\r\n /** The Id of the [[GltfBufferViewProps]] supplying the endpoints of each edge as indices into the triangle mesh's vertex array.\r\n * The number of indices must be even; each consecutive pair of indices describes one line segment. No connectivity between\r\n * line segments is implied.\r\n */\r\n indices?: GltfId;\r\n };\r\n /** The [KHR_draco_mesh_compression](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md) extension\r\n * allows glTF to support geometry compressed with Draco geometry compression.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_draco_mesh_compression?: DracoMeshCompression;\r\n };\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 ignored. */\r\n camera?: GltfId;\r\n /** Currently ignored. */\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 ignored. */\r\n jointName?: GltfId;\r\n /** Currently ignored. */\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 ignored. */\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 * @internal\r\n */\r\nexport type 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 */\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 extensions?: GltfExtensions & {\r\n /** The [KHR_binary_glTF](https://github.com/KhronosGroup/glTF/tree/main/extensions/1.0/Khronos/KHR_binary_glTF) allows an image to\r\n * be embedded in a binary chunk appended to the glTF asset's JSON, instead of being referenced by an external URI.\r\n * This is superseded in glTF 2.0 by support for the glb file format specification.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_binary_glTF?: {\r\n /** The Id of the [[GltfBufferViewProps]] that contains the binary image data. */\r\n bufferView?: GltfId;\r\n /** Required - @see [[GltfImage.mimeType]]. */\r\n mimeType?: string;\r\n };\r\n };\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 * For example, if `texCoord` is `2`, an attribute named `TEXCOORD_2` must exist containing the texture coordinates.\r\n * Default: 0.\r\n */\r\n texCoord?: number;\r\n}\r\n\r\n/** Describes a texture and its sampler.\r\n * @internal\r\n */\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\n * @note The implementation currently does not support MirroredRepeat and does not support different wrapping for U and V;\r\n * effectively, unless `wrapS` or `wrapT` is set to ClampToEdge, the sampler will use GltfWrapMode.Repeat.\r\n * @internal\r\n */\r\nexport interface 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. Default: Repeat. */\r\n wrapS?: GltfWrapMode;\r\n /** T (V) wrapping mode. Default: Repeat. */\r\n wrapT?: GltfWrapMode;\r\n}\r\n\r\n/** GL states that can be enabled by a [[GltfTechnique]]. Only those queried by this implementation are enumerated. */\r\nenum GltfTechniqueState {\r\n /** Enables alpha blending. */\r\n Blend = 3042,\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 [[GltfTechniqueState.Blend]] (3042) indicates that blending should be enabled.\r\n */\r\n enable?: GltfTechniqueState[];\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?: GltfTextureInfo;\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_materials_unlit](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_unlit) extension\r\n * indicates that the material should be displayed without lighting. The extension adds no additional properties; it is effectively a boolean flag.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n KHR_materials_unlit?: { };\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 * @internal\r\n */\r\nexport interface 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 public readonly version: number;\r\n public readonly glTF: Gltf;\r\n public readonly yAxisUp: boolean;\r\n public readonly binaryData?: Uint8Array;\r\n public readonly baseUrl?: string;\r\n\r\n private constructor(glTF: Gltf, version: number, yAxisUp: boolean, binaryData: Uint8Array | undefined, baseUrl?: string | undefined) {\r\n this.version = version;\r\n this.glTF = glTF;\r\n this.binaryData = binaryData;\r\n this.yAxisUp = yAxisUp;\r\n this.baseUrl = baseUrl;\r\n }\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(source: Uint8Array | Gltf, yAxisUp: boolean = false, baseUrl?: string): GltfReaderProps | undefined {\r\n let version: number;\r\n let json: Gltf;\r\n let binaryData: Uint8Array | undefined;\r\n\r\n if (source instanceof Uint8Array) {\r\n // It may be JSON - check for magic indicating glb.\r\n const buffer = ByteStream.fromUint8Array(source);\r\n if (TileFormat.Gltf !== buffer.readUint32()) {\r\n try {\r\n const utf8Json = utf8ToString(source);\r\n if (!utf8Json)\r\n return undefined;\r\n\r\n json = JSON.parse(utf8Json);\r\n version = 2;\r\n } catch (_) {\r\n return undefined;\r\n }\r\n } else {\r\n buffer.reset();\r\n const header = new GlbHeader(buffer);\r\n if (!header.isValid)\r\n return undefined;\r\n\r\n version = header.version;\r\n if (header.binaryChunk)\r\n binaryData = new Uint8Array(source.buffer, source.byteOffset + header.binaryChunk.offset, header.binaryChunk.length);\r\n\r\n try {\r\n const jsonBytes = new Uint8Array(source.buffer, source.byteOffset + header.jsonChunk.offset, header.jsonChunk.length);\r\n const jsonStr = utf8ToString(jsonBytes);\r\n if (undefined === jsonStr)\r\n return undefined;\r\n\r\n json = JSON.parse(jsonStr);\r\n } catch (_) {\r\n return undefined;\r\n }\r\n }\r\n } else {\r\n version = 2; // ###TODO verify against source.asset?.version\r\n json = source;\r\n }\r\n\r\n // asset is required in glTF 2, optional in glTF 1\r\n const asset = JsonUtils.asObject(json.asset);\r\n if (version === 2 && !asset)\r\n return undefined;\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(glTF, version, yAxisUp, binaryData, baseUrl) : undefined;\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?: Uint8Array | 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, isTransparent: boolean): ColorDef {\r\n let color = ColorDef.white;\r\n if (isGltf1Material(material)) {\r\n if (material.values?.color && Array.isArray(material.values.color))\r\n color = colorFromJson(material.values.color);\r\n } else if (material.extensions?.KHR_techniques_webgl?.values?.u_color) {\r\n color = colorFromJson(material.extensions.KHR_techniques_webgl.values.u_color);\r\n } else if (material.pbrMetallicRoughness?.baseColorFactor) {\r\n color = colorFromJson(material.pbrMetallicRoughness.baseColorFactor);\r\n }\r\n\r\n // SPEC: Opaque materials ignore any alpha channel.\r\n if (!isTransparent)\r\n color = color.withTransparency(0);\r\n\r\n return color;\r\n}\r\n\r\nclass TransformStack {\r\n private readonly _stack: Array<Transform | undefined> = [];\r\n\r\n public constructor(transform?: Transform) {\r\n if (transform)\r\n this._stack.push(transform);\r\n }\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/** Arguments to [[GltfReader]] constructor.\r\n * @internal\r\n */\r\nexport interface GltfReaderArgs {\r\n /** Properties of the glTF source. */\r\n props: GltfReaderProps;\r\n /** The iModel with which the graphics are to be associated. */\r\n iModel: IModelConnection;\r\n /** If true, create 2d graphics. */\r\n is2d?: boolean;\r\n /** The render system that will produce the graphics. Defaults to [[IModelApp.renderSystem]]. */\r\n system?: RenderSystem;\r\n /** The type of batch to create. Defaults to [BatchType.Primary]($common).\r\n * @see [[RenderSystem.createBatch]].\r\n */\r\n type?: BatchType;\r\n /** An optional function that, if supplied, is invoked periodically to determine if the process of producing graphics from the glTF should terminate early. */\r\n shouldAbort?: ShouldAbortReadGltf;\r\n /** If true, each vertex in the graphics should belong to exactly one triangle. This is less efficient than sharing vertices between adjoining triangles, but\r\n * sometimes required - for example, for [ViewFlags.wiremesh]($common).\r\n */\r\n deduplicateVertices?: boolean;\r\n /** If true, the graphics produced will always use a [[VertexTable]]; otherwise, where possible a [[RealityMeshParams]] will be used instead.\r\n * Reality meshes are simpler but do not support some features like lighting.\r\n */\r\n vertexTableRequired?: boolean;\r\n}\r\n\r\nfunction * traverseNodes(ids: Iterable<GltfId>, nodes: GltfDictionary<GltfNode>, traversed: Set<GltfId>): Iterable<GltfNode> {\r\n for (const id of ids) {\r\n if (traversed.has(id))\r\n throw new Error(\"Cycle detected while traversing glTF nodes\");\r\n\r\n const node = nodes[id];\r\n if (!node)\r\n continue;\r\n\r\n traversed.add(id);\r\n yield node;\r\n if (node.children)\r\n for (const child of traverseNodes(node.children, nodes, traversed))\r\n yield child;\r\n }\r\n}\r\n\r\ninterface TextureKey {\r\n readonly id: GltfId;\r\n readonly isTransparent: boolean;\r\n}\r\n\r\nfunction compareTextureKeys(lhs: TextureKey, rhs: TextureKey): number {\r\n const cmp = compareBooleans(lhs.isTransparent, rhs.isTransparent);\r\n if (0 !== cmp)\r\n return cmp;\r\n\r\n assert(typeof lhs.id === typeof rhs.id);\r\n if (\"string\" === typeof lhs.id) {\r\n assert(\"string\" === typeof rhs.id);\r\n return compareStrings(lhs.id, rhs.id);\r\n }\r\n\r\n assert(\"number\" === typeof lhs.id && \"number\" === typeof rhs.id);\r\n return compareNumbers(lhs.id, rhs.id);\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 _glTF: Gltf;\r\n protected readonly _version: number;\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 _baseUrl?: string;\r\n protected readonly _type: BatchType;\r\n protected readonly _deduplicateVertices: boolean;\r\n protected readonly _vertexTableRequired: boolean;\r\n private readonly _canceled?: ShouldAbortReadGltf;\r\n protected readonly _sceneNodes: GltfId[];\r\n protected _computedContentRange?: ElementAlignedBox3d;\r\n private readonly _resolvedTextures = new Dictionary<TextureKey, RenderTexture | false>((lhs, rhs) => compareTextureKeys(lhs, rhs));\r\n private readonly _dracoMeshes = new Map<DracoMeshCompression, DracoMesh>();\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 _materials(): GltfDictionary<GltfMaterial> { return this._glTF.materials ?? emptyDict; }\r\n protected get _samplers(): GltfDictionary<GltfSampler> { return this._glTF.samplers ?? emptyDict; }\r\n protected get _textures(): GltfDictionary<GltfTexture> { return this._glTF.textures ?? emptyDict; }\r\n\r\n protected get _images(): GltfDictionary<GltfImage & { resolvedImage?: TextureImageSource }> { return this._glTF.images ?? emptyDict; }\r\n protected get _buffers(): GltfDictionary<GltfBuffer & { resolvedBuffer?: Uint8Array }> { return this._glTF.buffers ?? 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 /** Traverse the nodes specified by their Ids, recursing into their child nodes.\r\n * @param nodeIds The Ids of the nodes to traverse.\r\n * @throws Error if a node appears more than once during traversal\r\n */\r\n public traverseNodes(nodeIds: Iterable<GltfId>): Iterable<GltfNode> {\r\n return traverseNodes(nodeIds, this._nodes, new Set<GltfId>());\r\n }\r\n\r\n /** Traverse the nodes specified by their scene, recursing into their child nodes.\r\n * @throws Error if a node appears more than once during traversal\r\n */\r\n public traverseScene(): Iterable<GltfNode> {\r\n return this.traverseNodes(this._sceneNodes);\r\n }\r\n\r\n private getTileTransform(transformToRoot?: Transform, pseudoRtcBias?: Vector3d): Transform | undefined {\r\n let transform;\r\n\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\r\n return transform;\r\n }\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 const transform = this.getTileTransform(transformToRoot, pseudoRtcBias);\r\n let range = contentRange;\r\n const invTransform = transform?.inverse();\r\n if (invTransform)\r\n range = invTransform.multiplyRange(contentRange);\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 public readGltfAndCreateGeometry(transformToRoot?: Transform, needNormals = false, needParams = false): RealityTileGeometry {\r\n const transformStack = new TransformStack(this.getTileTransform(transformToRoot));\r\n const polyfaces: Polyface[] = [];\r\n for (const nodeKey of this._sceneNodes) {\r\n const node = this._nodes[nodeKey];\r\n if (node)\r\n this.readNodeAndCreatePolyfaces(polyfaces, node, transformStack, needNormals, needParams);\r\n }\r\n\r\n return { polyfaces };\r\n }\r\n\r\n private graphicFromMeshData(gltfMesh: GltfMeshData, instances?: InstancedGraphicParams): RenderGraphic | undefined {\r\n if (!gltfMesh.points || !gltfMesh.pointRange)\r\n return gltfMesh.primitive.getGraphics(this._system, instances);\r\n\r\n const realityMeshPrimitive = (this._vertexTableRequired || instances) ? undefined : RealityMeshParams.fromGltfMesh(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 assert(mesh.points instanceof QPoint3dList);\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(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 meshes = this.readMeshPrimitives(node, featureTable, thisTransform, thisBias);\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], instances);\r\n } else {\r\n const thisList: RenderGraphic[] = [];\r\n for (const mesh of meshes) {\r\n renderGraphic = this.graphicFromMeshData(mesh, 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 private readNodeAndCreatePolyfaces(polyfaces: Polyface[], node: GltfNode, transformStack: TransformStack, needNormals: boolean, needParams: boolean): void {\r\n // IMPORTANT: Do not return without popping this node from the stack.\r\n transformStack.push(node);\r\n const meshes = this.readMeshPrimitives(node);\r\n\r\n for (const mesh of meshes) {\r\n const polyface = this.polyfaceFromGltfMesh(mesh, transformStack.transform, needNormals, needParams);\r\n if (polyface)\r\n polyfaces.push(polyface);\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.readNodeAndCreatePolyfaces(polyfaces, child, transformStack, needNormals, needParams);\r\n }\r\n }\r\n }\r\n\r\n private polyfaceFromGltfMesh(mesh: GltfMeshData, transform: Transform | undefined , needNormals: boolean, needParams: boolean): Polyface | undefined {\r\n if (!mesh.pointQParams || !mesh.points || !mesh.indices)\r\n return undefined;\r\n\r\n const { points, pointQParams, normals, uvs, uvQParams, indices } = mesh;\r\n\r\n const includeNormals = needNormals && undefined !== normals;\r\n const includeParams = needParams && undefined !== uvQParams && undefined !== uvs;\r\n\r\n const polyface = IndexedPolyface.create(includeNormals, includeParams);\r\n for (let i = 0; i < points.length; ) {\r\n const point = pointQParams.unquantize(points[i++], points[i++], points[i++]);\r\n if (transform)\r\n transform.multiplyPoint3d(point, point);\r\n\r\n polyface.addPoint(point);\r\n }\r\n\r\n if (includeNormals && normals)\r\n for (let i = 0; i < normals.length; )\r\n polyface.addNormal(OctEncodedNormal.decodeValue(normals[i++]));\r\n\r\n if (includeParams && uvs && uvQParams)\r\n for (let i = 0; i < uvs.length; )\r\n polyface.addParam(uvQParams.unquantize(uvs[i++], uvs[i++]));\r\n\r\n let j = 0;\r\n for (const index of indices) {\r\n polyface.addPointIndex(index);\r\n if (includeNormals)\r\n polyface.addNormalIndex(index);\r\n\r\n if (includeParams)\r\n polyface.addParamIndex(index);\r\n\r\n if (0 === (++j % 3))\r\n polyface.terminateFacet();\r\n }\r\n\r\n return polyface;\r\n }\r\n\r\n // ###TODO what is the actual type of `json`?\r\n public getBufferView(json: { [k: string]: any }, accessorName: string): GltfBufferView | undefined {\r\n try {\r\n const accessorValue = JsonUtils.asString(json[accessorName]);\r\n const accessor = accessorValue ? this._accessors[accessorValue] : undefined;\r\n if (!accessor)\r\n return undefined;\r\n\r\n const bufferViewAccessorValue = accessor.bufferView;\r\n const bufferView = undefined !== bufferViewAccessorValue ? this._bufferViews[bufferViewAccessorValue] : undefined;\r\n if (!bufferView || undefined === bufferView.buffer)\r\n return undefined;\r\n\r\n const buffer = this._buffers[bufferView.buffer];\r\n const bufferData = buffer?.resolvedBuffer;\r\n if (!bufferData)\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\r\n // If the data is misaligned (Scalable mesh tile publisher) use slice to copy -- else use subarray.\r\n const aligned = 0 === (bufferData.byteOffset + offset) % dataSize;\r\n const bytes = aligned ? bufferData.subarray(offset, offset + length) : bufferData.slice(offset, offset + length);\r\n return new GltfBufferView(bytes, accessor.count, type, accessor, byteStride / dataSize);\r\n } catch (e) {\r\n return undefined;\r\n }\r\n }\r\n\r\n public readBufferData32(json: { [k: string]: any }, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UInt32); }\r\n public readBufferData16(json: { [k: string]: any }, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UnsignedShort); }\r\n public readBufferData8(json: { [k: string]: any }, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.UnsignedByte); }\r\n public readBufferDataFloat(json: { [k: string]: any }, accessorName: string): GltfBufferData | undefined { return this.readBufferData(json, accessorName, GltfDataType.Float); }\r\n\r\n protected constructor(args: GltfReaderArgs) {\r\n this._glTF = args.props.glTF;\r\n this._version = args.props.version;\r\n this._yAxisUp = args.props.yAxisUp;\r\n this._baseUrl = args.props.baseUrl;\r\n\r\n const rtcCenter = args.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 = args.iModel;\r\n this._is3d = true !== args.is2d;\r\n this._system = args.system ?? IModelApp.renderSystem;\r\n this._type = args.type ?? BatchType.Primary;\r\n this._canceled = args.shouldAbort;\r\n this._deduplicateVertices = args.deduplicateVertices ?? false;\r\n this._vertexTableRequired = args.vertexTableRequired ?? false;\r\n\r\n const binaryData = args.props.binaryData;\r\n if (binaryData) {\r\n const buffer = this._buffers[this._version === 2 ? 0 : \"binary_glTF\"];\r\n if (buffer && undefined === buffer.uri)\r\n buffer.resolvedBuffer = binaryData;\r\n }\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: { [k: string]: 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 extractId(value: any): string | undefined {\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 private extractTextureId(material: GltfMaterial): string | undefined {\r\n if (typeof material !== \"object\")\r\n return undefined;\r\n\r\n // Bimium's shader value...almost certainly obsolete at this point.\r\n if (isGltf1Material(material))\r\n return material.diffuse ?? this.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 this.extractId((ext.values[uniformName] as any)?.index);\r\n }\r\n }\r\n }\r\n\r\n const id = this.extractId(material.pbrMetallicRoughness?.baseColorTexture?.index);\r\n return id ?? this.extractId(material.emissiveTexture?.index);\r\n }\r\n\r\n private extractNormalMapId(material: GltfMaterial): string | undefined {\r\n if (typeof material !== \"object\")\r\n return undefined;\r\n\r\n if (isGltf1Material(material))\r\n return undefined;\r\n\r\n return this.extractId(material.normalTexture?.index);\r\n }\r\n\r\n private isMaterialTransparent(material: GltfMaterial): boolean {\r\n if (isGltf1Material(material)) {\r\n if (this._glTF.techniques && undefined !== material.technique) {\r\n const technique = this._glTF.techniques[material.technique];\r\n if (technique?.states?.enable?.some((state: GltfTechniqueState) => state === GltfTechniqueState.Blend))\r\n return true;\r\n }\r\n\r\n return false;\r\n } else {\r\n // Default: OPAQUE.\r\n // ###TODO support MASK. For now treat as opaque.\r\n return \"BLEND\" === material.alphaMode;\r\n }\r\n }\r\n\r\n protected createDisplayParams(material: GltfMaterial, hasBakedLighting: boolean): DisplayParams | undefined {\r\n const isTransparent = this.isMaterialTransparent(material);\r\n const textureId = this.extractTextureId(material);\r\n const normalMapId = this.extractNormalMapId(material);\r\n const textureMapping = (undefined !== textureId || undefined !== normalMapId) ? this.findTextureMapping(textureId, isTransparent, normalMapId) : undefined;\r\n const color = colorFromMaterial(material, isTransparent);\r\n let renderMaterial: RenderMaterial | undefined;\r\n if (undefined !== textureMapping && undefined !== textureMapping.normalMapParams) {\r\n const args: CreateRenderMaterialArgs = { diffuse: { color }, specular: { color: ColorDef.white }, textureMapping };\r\n renderMaterial = IModelApp.renderSystem.createRenderMaterial(args);\r\n }\r\n return new DisplayParams(DisplayParams.Type.Mesh, color, color, 1, LinePixels.Solid, FillFlags.Always, renderMaterial, undefined, hasBakedLighting, textureMapping);\r\n }\r\n\r\n private readMeshPrimitives(node: GltfNode, featureTable?: FeatureTable, thisTransform?: Transform, thisBias?: Vector3d): GltfMeshData[] {\r\n const meshes: GltfMeshData[] = [];\r\n for (const meshKey of getNodeMeshIds(node)) {\r\n const nodeMesh = this._meshes[meshKey];\r\n if (nodeMesh?.primitives) {\r\n for (const primitive of nodeMesh.primitives) {\r\n const mesh = this.readMeshPrimitive(primitive, featureTable, thisBias);\r\n if (mesh) {\r\n meshes.push(mesh);\r\n if (this._computedContentRange && mesh.pointRange) {\r\n const invTransform = thisTransform?.inverse();\r\n const meshRange = invTransform ? invTransform.multiplyRange(mesh.pointRange) : mesh.pointRange;\r\n this._computedContentRange.extendRange(meshRange);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return meshes;\r\n }\r\n\r\n protected readMeshPrimitive(primitive: GltfMeshPrimitive, featureTable?: FeatureTable, pseudoRtcBias?: Vector3d): GltfMeshData | undefined {\r\n const materialName = JsonUtils.asString(primitive.material);\r\n const material = 0 < materialName.length ? this._materials[materialName] : { };\r\n if (!material)\r\n return undefined;\r\n\r\n const hasBakedLighting = undefined === primitive.attributes.NORMAL || undefined !== material.extensions?.KHR_materials_unlit;\r\n const displayParams = material ? this.createDisplayParams(material, hasBakedLighting) : undefined;\r\n if (!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\r\n const isVolumeClassifier = this._isVolumeClassifier;\r\n const meshPrimitive = Mesh.create({\r\n displayParams,\r\n features: featureTable,\r\n type: primitiveType,\r\n range: Range3d.createNull(),\r\n is2d: !this._is3d,\r\n isPlanar: false,\r\n hasBakedLighting,\r\n isVolumeClassifier,\r\n quantizePositions: true,\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 const draco = primitive.extensions?.KHR_draco_mesh_compression;\r\n if (draco)\r\n return this.readDracoMeshPrimitive(mesh.primitive, draco) ? mesh : undefined;\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 let texCoordIndex = 0;\r\n if (!isGltf1Material(material) && undefined !== material.pbrMetallicRoughness?.baseColorTexture?.texCoord)\r\n texCoordIndex = JsonUtils.asInt(material.pbrMetallicRoughness.baseColorTexture.texCoord);\r\n\r\n this.readUVParams(mesh, primitive.attributes, `TEXCOORD_${texCoordIndex}`);\r\n }\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\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 readDracoMeshPrimitive(mesh: Mesh, ext: DracoMeshCompression): boolean {\r\n const draco = this._dracoMeshes.get(ext);\r\n if (!draco || \"triangle-list\" !== draco.topology)\r\n return false;\r\n\r\n const indices = draco.indices?.value;\r\n if (!indices || (indices.length % 3) !== 0)\r\n return false;\r\n\r\n const pos = draco.attributes.POSITION?.value;\r\n if (!pos || (pos.length % 3) !== 0)\r\n return false;\r\n\r\n // ###TODO: I have yet to see a draco-encoded mesh with interleaved attributes. Currently not checking.\r\n const triangle = new Triangle();\r\n for (let i = 0; i < indices.length; i += 3) {\r\n triangle.setIndices(indices[i], indices[i + 1], indices[i + 2]);\r\n mesh.addTriangle(triangle);\r\n }\r\n\r\n let posRange: Range3d;\r\n const bbox = draco.header?.boundingBox;\r\n if (bbox) {\r\n posRange = Range3d.createXYZXYZ(bbox[0][0], bbox[0][1], bbox[0][2], bbox[1][0], bbox[1][1], bbox[1][2]);\r\n } else {\r\n posRange = Range3d.createNull();\r\n for (let i = 0; i < pos.length; i += 3)\r\n posRange.extendXYZ(pos[i], pos[i + 1], pos[i + 2]);\r\n }\r\n\r\n assert(mesh.points instanceof QPoint3dList);\r\n mesh.points.params.setFromRange(posRange);\r\n const pt = Point3d.createZero();\r\n for (let i = 0; i < pos.length; i += 3) {\r\n pt.set(pos[i], pos[i + 1], pos[i + 2]);\r\n mesh.points.add(pt);\r\n }\r\n\r\n const normals = draco.attributes.NORMAL?.value;\r\n if (normals && (normals.length % 3) === 0) {\r\n const vec = Vector3d.createZero();\r\n for (let i = 0; i < normals.length; i += 3) {\r\n vec.set(normals[i], normals[i + 1], normals[i + 2]);\r\n mesh.normals.push(OctEncodedNormal.fromVector(vec));\r\n }\r\n }\r\n\r\n const uvs = draco.attributes.TEXCOORD_0?.value;\r\n if (uvs && (uvs.length & 2) === 0)\r\n for (let i = 0; i < uvs.length; i += 2)\r\n mesh.uvParams.push(new Point2d(uvs[i], uvs[i + 1]));\r\n\r\n const batchIds = draco.attributes._BATCHID?.value;\r\n if (batchIds && mesh.features) {\r\n const featureIndices = [];\r\n for (const batchId of batchIds)\r\n featureIndices.push(batchId);\r\n\r\n mesh.features.setIndices(featureIndices);\r\n }\r\n\r\n return true;\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 else if (indices instanceof Uint8Array && numPoints > 0xff)\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: GltfMeshPrimitive, 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: { [k: string]: 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: { [k: string]: any }): boolean {\r\n if (undefined !== json.indices) {\r\n const data = this.readBufferData16(json, \"indices\") || this.readBufferData32(json, \"indices\");\r\n if (data && (data.buffer instanceof Uint8Array || data.buffer instanceof Uint16Array || data.buffer instanceof Uint32Array)) {\r\n mesh.indices = data.buffer;\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n // Non-indexed geometry. Manufacture triangle indices from points.\r\n const numPoints = mesh.points?.length;\r\n if (undefined === numPoints || 0 !== numPoints % 3)\r\n return false;\r\n\r\n mesh.indices = numPoints < 255 ? new Uint8Array(numPoints) : (numPoints < 0xffff ? new Uint16Array(numPoints) : new Uint32Array(numPoints));\r\n for (let i = 0; i < numPoints; i++)\r\n mesh.indices[i] = i;\r\n\r\n return true;\r\n }\r\n\r\n protected readNormals(mesh: GltfMeshData, json: { [k: string]: 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: { [k: string]: any }, accessorName: string): boolean {\r\n const view = this.getBufferView(json, accessorName);\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 const data = this.readBufferDataFloat(json, accessorName);\r\n if (!data)\r\n return false;\r\n\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: { [k: string]: 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 resolveResources(): Promise<void> {\r\n // Load any external images and buffers.\r\n await this._resolveResources();\r\n\r\n // If any meshes are draco-compressed, dynamically load the decoder module and then decode the meshes.\r\n const dracoMeshes: DracoMeshCompression[] = [];\r\n\r\n for (const node of this.traverseScene()) {\r\n for (const meshId of getNodeMeshIds(node)) {\r\n const mesh = this._meshes[meshId];\r\n if (mesh?.primitives)\r\n for (const primitive of mesh.primitives)\r\n if (primitive.extensions?.KHR_draco_mesh_compression)\r\n dracoMeshes.push(primitive.extensions.KHR_draco_mesh_compression);\r\n }\r\n }\r\n\r\n if (dracoMeshes.length === 0)\r\n return;\r\n\r\n try {\r\n const dracoLoader = (await import(\"@loaders.gl/draco\")).DracoLoader;\r\n await Promise.all(dracoMeshes.map(async (x) => this.decodeDracoMesh(x, dracoLoader)));\r\n } catch (err) {\r\n Logger.logWarning(FrontendLoggerCategory.Render, \"Failed to decode draco-encoded glTF mesh\");\r\n Logger.logException(FrontendLoggerCategory.Render, err);\r\n }\r\n }\r\n\r\n private async _resolveResources(): Promise<void> {\r\n // ###TODO traverse the scene nodes to find resources referenced by them, instead of resolving everything - some resources may not\r\n // be required for the scene.\r\n const promises: Array<Promise<void>> = [];\r\n try {\r\n for (const buffer of dictionaryIterator(this._buffers))\r\n if (!buffer.resolvedBuffer)\r\n promises.push(this.resolveBuffer(buffer));\r\n\r\n await Promise.all(promises);\r\n if (this._isCanceled)\r\n return;\r\n\r\n promises.length = 0;\r\n for (const image of dictionaryIterator(this._images))\r\n if (!image.resolvedImage)\r\n promises.push(this.resolveImage(image));\r\n\r\n await Promise.all(promises);\r\n } catch (_) {\r\n }\r\n }\r\n\r\n private async decodeDracoMesh(ext: DracoMeshCompression, loader: typeof DracoLoader): Promise<void> {\r\n const bv = this._bufferViews[ext.bufferView];\r\n if (!bv || !bv.byteLength)\r\n return;\r\n\r\n let buf = this._buffers[bv.buffer]?.resolvedBuffer;\r\n if (!buf)\r\n return;\r\n\r\n const offset = bv.byteOffset ?? 0;\r\n buf = buf.subarray(offset, offset + bv.byteLength);\r\n const mesh = await loader.parse(buf, { }); // NB: `options` argument declared optional but will produce exception if not supplied.\r\n if (mesh)\r\n this._dracoMeshes.set(ext, mesh);\r\n }\r\n\r\n private resolveUrl(uri: string): string | undefined {\r\n try {\r\n return new URL(uri, this._baseUrl).toString();\r\n } catch (_) {\r\n return undefined;\r\n }\r\n }\r\n\r\n private async resolveBuffer(buffer: GltfBuffer & { resolvedBuffer?: Uint8Array }): Promise<void> {\r\n if (buffer.resolvedBuffer || undefined === buffer.uri)\r\n return;\r\n\r\n try {\r\n const url = this.resolveUrl(buffer.uri);\r\n const response = url ? await fetch(url) : undefined;\r\n if (this._isCanceled)\r\n return;\r\n\r\n const data = await response?.arrayBuffer();\r\n if (this._isCanceled)\r\n return;\r\n\r\n if (data)\r\n buffer.resolvedBuffer = new Uint8Array(data);\r\n } catch (_) {\r\n //\r\n }\r\n }\r\n\r\n private async resolveImage(image: GltfImage & { resolvedImage?: TextureImageSource }): Promise<void> {\r\n if (image.resolvedImage)\r\n return;\r\n\r\n interface BufferViewSource { bufferView?: GltfId, mimeType?: string }\r\n const bvSrc: BufferViewSource | undefined = undefined !== image.bufferView ? image : image.extensions?.KHR_binary_glTF;\r\n if (undefined !== bvSrc?.bufferView) {\r\n const format = undefined !== bvSrc.mimeType ? getImageSourceFormatForMimeType(bvSrc.mimeType) : undefined;\r\n const bufferView = this._bufferViews[bvSrc.bufferView];\r\n if (undefined === format || !bufferView || !bufferView.byteLength || bufferView.byteLength < 0)\r\n return;\r\n\r\n const bufferData = this._buffers[bufferView.buffer]?.resolvedBuffer;\r\n if (!bufferData)\r\n return;\r\n\r\n const offset = bufferView.byteOffset ?? 0;\r\n const bytes = bufferData.subarray(offset, offset + bufferView.byteLength);\r\n try {\r\n const imageSource = new ImageSource(bytes, format);\r\n if (this._system.supportsCreateImageBitmap)\r\n image.resolvedImage = await imageBitmapFromImageSource(imageSource);\r\n else\r\n image.resolvedImage = await imageElementFromImageSource(imageSource);\r\n } catch (_) {\r\n //\r\n }\r\n\r\n return;\r\n }\r\n\r\n const url = undefined !== image.uri ? this.resolveUrl(image.uri) : undefined;\r\n if (undefined !== url)\r\n image.resolvedImage = await tryImageElementFromUrl(url);\r\n }\r\n\r\n /** The glTF spec says that if GltfSampler.wrapS/T are omitted, they default to Repeat.\r\n * However, the reality data service serves tiles that lack any wrapS/T property, and we want those clamped to edge, not repeated.\r\n * (We also don't want to produce mip-maps for them, which is determined indirectly from the wrap mode).\r\n * Allow the default to be optionally overridden.\r\n */\r\n public defaultWrapMode = GltfWrapMode.Repeat;\r\n\r\n /** Exposed strictly for testing. */\r\n public getTextureType(sampler?: GltfSampler): RenderTexture.Type {\r\n // ###TODO: RenderTexture currently does not support different wrapping behavior for U vs V, nor does it support mirrored repeat.\r\n let wrapS = sampler?.wrapS;\r\n let wrapT = sampler?.wrapT;\r\n if (undefined === wrapS && undefined === wrapT)\r\n wrapS = wrapT = this.defaultWrapMode;\r\n\r\n if (GltfWrapMode.ClampToEdge === wrapS || GltfWrapMode.ClampToEdge === wrapT)\r\n return RenderTexture.Type.TileSection;\r\n\r\n return RenderTexture.Type.Normal;\r\n }\r\n\r\n private resolveTexture(textureId: string, isTransparent: boolean): RenderTexture | false {\r\n const texture = this._textures[textureId];\r\n if (!texture || undefined === texture.source)\r\n return false;\r\n\r\n const image = this._images[texture.source]?.resolvedImage;\r\n if (!image)\r\n return false;\r\n\r\n const samplerId = texture.sampler;\r\n const sampler = undefined !== samplerId ? this._samplers[samplerId] : undefined;\r\n const textureType = this.getTextureType(sampler);\r\n const renderTexture = this._system.createTexture({\r\n type: textureType,\r\n image: {\r\n source: image,\r\n transparency: isTransparent ? TextureTransparency.Mixed : TextureTransparency.Opaque,\r\n },\r\n });\r\n\r\n return renderTexture ?? false;\r\n }\r\n\r\n protected findTextureMapping(id: string | undefined, isTransparent: boolean, normalMapId: string | undefined): TextureMapping | undefined {\r\n if (undefined === id && undefined === normalMapId)\r\n return undefined;\r\n\r\n let texture;\r\n if (undefined !== id) {\r\n texture = this._resolvedTextures.get({ id, isTransparent });\r\n if (undefined === texture)\r\n this._resolvedTextures.set({ id, isTransparent }, texture = this.resolveTexture(id, isTransparent));\r\n }\r\n\r\n let normalMap;\r\n if (undefined !== normalMapId) {\r\n normalMap = this._resolvedTextures.get({ id: normalMapId, isTransparent: false });\r\n if (undefined === normalMap)\r\n this._resolvedTextures.set({ id: normalMapId, isTransparent: false }, normalMap = this.resolveTexture(normalMapId, false));\r\n }\r\n\r\n let nMap;\r\n if (normalMap) {\r\n const greenUp = true;\r\n if (texture) {\r\n nMap = {\r\n normalMap,\r\n greenUp,\r\n };\r\n } else {\r\n texture = normalMap;\r\n nMap = { greenUp };\r\n }\r\n }\r\n\r\n if (!texture)\r\n return undefined;\r\n\r\n const textureMapping = new TextureMapping(texture, new TextureMapping.Params());\r\n textureMapping.normalMapParams = nMap;\r\n return textureMapping;\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 /** A representation of the glTF data as one of:\r\n * - The binary data in glb format as a Uint8Array; or\r\n * - A JSON object conforming to the [glTF 2.0 specification](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html); or\r\n * - A Uint8Array containing the utf8-encoded stringified JSON of an object conforming to the [glTF 2.0 specification](https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html).\r\n */\r\n gltf: Uint8Array | Object;\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;\r\n /** The base URL for any relative URIs in the glTF. Typically, this is the same as the URL for the glTF asset itself.\r\n * If not supplied, relative URIs cannot be resolved. For glTF assets containing no relative URIs, this is not required.\r\n */\r\n baseUrl?: string;\r\n /** @alpha */\r\n contentRange?: ElementAlignedBox3d;\r\n /** @alpha */\r\n transform?: Transform;\r\n /** @alpha */\r\n hasChildren?: boolean;\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 props = GltfReaderProps.create(args.gltf, true, args.baseUrl); // glTF supports exactly one coordinate system with y axis up.\r\n const reader = props ? new GltfGraphicsReader(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]]. Exported strictly for tests.\r\n * @internal\r\n */\r\nexport class GltfGraphicsReader extends GltfReader {\r\n private readonly _featureTable?: FeatureTable;\r\n private readonly _contentRange?: ElementAlignedBox3d;\r\n private readonly _transform?: Transform;\r\n private readonly _isLeaf: boolean;\r\n public readonly binaryData?: Uint8Array; // strictly for tests\r\n\r\n public constructor(props: GltfReaderProps, args: ReadGltfGraphicsArgs) {\r\n super({\r\n props,\r\n iModel: args.iModel,\r\n vertexTableRequired: true,\r\n });\r\n\r\n this._contentRange = args.contentRange;\r\n this._transform = args.transform;\r\n this._isLeaf = true !== args.hasChildren;\r\n\r\n this.binaryData = props.binaryData;\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 public async read(): Promise<GltfReaderResult> {\r\n await this.resolveResources();\r\n return this.readGltfAndCreateGraphics(this._isLeaf, this._featureTable, this._contentRange, this._transform);\r\n }\r\n\r\n public get nodes(): GltfDictionary<GltfNode> { return this._nodes; }\r\n public get scenes(): GltfDictionary<GltfScene> { return this._glTF.scenes ?? emptyDict; }\r\n public get sceneNodes(): GltfId[] { return this._sceneNodes; }\r\n public get textures(): GltfDictionary<GltfTexture> { return this._textures; }\r\n}\r\n"]}
|