gltf-parser-plugin 1.1.7 → 1.1.9
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/build/gltf-parser-plugin.module.js +1591 -435
- package/build/gltf-parser-plugin.module.js.map +1 -1
- package/build/index.d.ts +233 -45
- package/package.json +9 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-parser-plugin.module.js","names":["b","Y","E","Oe","Xn","Yn","K","ei","$n","ts","un","Qn","Kn","Jn","Zn","Se","Wt","hn"],"sources":["../src/mesh-helper/FeatureIdUniforms.ts","../src/mesh-helper/idmap.ts","../src/mesh-helper/intersection.ts","../src/mesh-helper/mesh.ts","../src/MeshCollector.ts","../src/utils/build-textures.ts","../src/utils/build-materials.ts","../src/utils/build-mesh-primitives.ts","../src/utils/worker-pool.ts","../src/utils/spatial-query.ts","../node_modules/.pnpm/3d-tiles-renderer@0.4.22_three@0.183.2/node_modules/3d-tiles-renderer/build/constants-Cj07Qhs1.js","../node_modules/.pnpm/three@0.183.2/node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/.pnpm/3d-tiles-renderer@0.4.22_three@0.183.2/node_modules/3d-tiles-renderer/build/WMSCapabilitiesLoader-DngSzqI4.js","../src/GLTFWorkerLoader.ts","../src/plugin/PartColorHelper.ts","../src/plugin/PartBlinkHelper.ts","../src/plugin/PartFrameHelper.ts","../src/plugin/InteractionFilter.ts","../src/db/tile-cache.ts","../src/GLTFParserPlugin.ts"],"sourcesContent":["import type { GLTFParserPlugin } from \"../GLTFParserPlugin\";\r\nimport { Mesh } from \"three\";\r\n\r\nexport class FeatureIdUniforms {\r\n mesh: Mesh;\r\n plugin: GLTFParserPlugin;\r\n\r\n constructor(mesh: Mesh, plugin: GLTFParserPlugin) {\r\n this.mesh = mesh;\r\n this.plugin = plugin;\r\n }\r\n\r\n get value() {\r\n const idMap = this.mesh.userData.idMap;\r\n\r\n if (!idMap) {\r\n return new Array(this.plugin.getFeatureIdCount()).fill(-1);\r\n }\r\n\r\n const result = new Array(this.plugin.getFeatureIdCount()).fill(-1);\r\n for (let i = 0; i < this.plugin.oids.length; i++) {\r\n const oid = this.plugin.oids[i];\r\n const featureId = idMap[oid];\r\n result[i] = featureId !== undefined ? featureId : -1;\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n","import { Object3D } from \"three\";\r\n\r\nconst FEATURE_INDEX = 0;\r\n\r\n/**\r\n * Build mapping relationship from OID to FeatureId\r\n * @param scene Scene object\r\n */\r\nfunction buildOidToFeatureIdMap(scene: Object3D): void {\r\n scene.traverse((meshObject: Object3D) => {\r\n const { meshFeatures, structuralMetadata } = meshObject.userData;\r\n\r\n if (meshFeatures && structuralMetadata) {\r\n const { geometry, featureIds } = meshFeatures;\r\n const featureIdConfig = featureIds[FEATURE_INDEX];\r\n const featureAttribute = geometry.getAttribute(\r\n `_feature_id_${featureIdConfig.attribute}`\r\n );\r\n\r\n const processedFeatureIds = new Set<number>();\r\n const oidToFeatureIdMap: Record<number, number> = {};\r\n\r\n for (\r\n let vertexIndex = 0;\r\n vertexIndex < featureAttribute.count;\r\n vertexIndex++\r\n ) {\r\n const currentFeatureId = featureAttribute.getX(vertexIndex);\r\n\r\n if (processedFeatureIds.has(currentFeatureId)) {\r\n continue;\r\n }\r\n\r\n const featureData = structuralMetadata.getPropertyTableData(\r\n featureIdConfig.propertyTable,\r\n currentFeatureId\r\n );\r\n\r\n oidToFeatureIdMap[featureData._oid] = currentFeatureId;\r\n processedFeatureIds.add(currentFeatureId);\r\n }\r\n\r\n processedFeatureIds.clear();\r\n meshObject.userData.idMap = oidToFeatureIdMap;\r\n }\r\n });\r\n}\r\n\r\nexport { buildOidToFeatureIdMap };\r\n","import { Intersection, Mesh, Triangle, Vector3 } from \"three\";\r\n\r\n/**\r\n * Hit object feature information interface\r\n */\r\nexport interface FeatureInfo {\r\n oid?: number;\r\n featureId?: number;\r\n features?: number[];\r\n propertyData?: object;\r\n isValid: boolean;\r\n error?: string;\r\n}\r\n\r\n/**\r\n * General function for extracting OID and feature information from raycaster hit objects\r\n * @param hit - hit object returned by raycaster.intersectObject\r\n * @returns FeatureInfo object containing OID and other feature information\r\n */\r\nexport function queryFeatureFromIntersection(hit: Intersection): FeatureInfo {\r\n const result: FeatureInfo = {\r\n isValid: false,\r\n };\r\n\r\n try {\r\n if (!hit || !hit.object) {\r\n result.error = \"Invalid hit object\";\r\n return result;\r\n }\r\n\r\n const { object, face, point, faceIndex } = hit;\r\n const { meshFeatures, structuralMetadata } = object.userData;\r\n\r\n if (!(object instanceof Mesh)) {\r\n result.error = \"Hit object is not a Mesh\";\r\n return result;\r\n }\r\n\r\n if (!meshFeatures || !structuralMetadata) {\r\n result.error = \"No mesh features or structural metadata found\";\r\n return result;\r\n }\r\n\r\n const barycoord = new Vector3();\r\n if (face && point) {\r\n const triangle = new Triangle();\r\n triangle.setFromAttributeAndIndices(\r\n object.geometry.attributes.position,\r\n face.a,\r\n face.b,\r\n face.c\r\n );\r\n triangle.a.applyMatrix4(object.matrixWorld);\r\n triangle.b.applyMatrix4(object.matrixWorld);\r\n triangle.c.applyMatrix4(object.matrixWorld);\r\n triangle.getBarycoord(point, barycoord);\r\n } else {\r\n barycoord.set(0, 0, 0);\r\n }\r\n\r\n const features = meshFeatures.getFeatures(faceIndex, barycoord);\r\n if (!features || features.length === 0) {\r\n result.error = \"No features found at hit location\";\r\n return result;\r\n }\r\n\r\n result.features = features;\r\n\r\n const { featureIds } = meshFeatures;\r\n if (!featureIds || featureIds.length === 0) {\r\n result.error = \"Feature IDs not available\";\r\n return result;\r\n }\r\n\r\n const featureId = featureIds[0];\r\n const fid = features[0];\r\n result.featureId = fid;\r\n\r\n const propertyData = structuralMetadata.getPropertyTableData(\r\n featureId.propertyTable,\r\n fid\r\n );\r\n\r\n result.propertyData = propertyData;\r\n\r\n if (propertyData && propertyData._oid !== undefined) {\r\n result.oid = propertyData._oid;\r\n result.isValid = true;\r\n } else {\r\n result.error = \"OID not found in property data\";\r\n }\r\n\r\n return result;\r\n } catch (error) {\r\n result.error = `Error extracting OID: ${\r\n error instanceof Error ? error.message : String(error)\r\n }`;\r\n return result;\r\n }\r\n}\r\n","import { BufferAttribute, BufferGeometry, Mesh, Object3D } from \"three\";\n\nimport { TilesRenderer } from \"3d-tiles-renderer\";\n\n/**\n * 预建featureId到顶点索引的映射表,提高查询性能\n */\nfunction buildFeatureIdIndexMap(\n featureIdAttr: BufferAttribute\n): Map<number, Set<number>> {\n const featureIdMap = new Map<number, Set<number>>();\n\n for (let i = 0; i < featureIdAttr.count; i++) {\n const featureId = featureIdAttr.getX(i);\n\n if (!featureIdMap.has(featureId)) {\n featureIdMap.set(featureId, new Set<number>());\n }\n featureIdMap.get(featureId)!.add(i);\n }\n\n return featureIdMap;\n}\n\n/**\n * Create a geometry for a specified feature ID\n */\nfunction createGeometryForFeatureId(\n originalGeometry: BufferGeometry,\n featureIdMap: Map<number, Set<number>>,\n targetFeatureId: number\n): BufferGeometry | null {\n const newGeometry = new BufferGeometry();\n\n const targetVertexIndices = featureIdMap.get(targetFeatureId);\n\n if (!targetVertexIndices || targetVertexIndices.size === 0) {\n return null;\n }\n\n const attributes = originalGeometry.attributes;\n for (const attributeName in attributes) {\n newGeometry.setAttribute(attributeName, attributes[attributeName]);\n }\n\n if (originalGeometry.index) {\n const originalIndex = originalGeometry.index.array;\n const newIndices: number[] = [];\n\n for (let i = 0; i < originalIndex.length; i += 3) {\n const a = originalIndex[i];\n const b = originalIndex[i + 1];\n const c = originalIndex[i + 2];\n\n if (\n targetVertexIndices.has(a) &&\n targetVertexIndices.has(b) &&\n targetVertexIndices.has(c)\n ) {\n newIndices.push(a, b, c);\n }\n }\n\n if (newIndices.length > 0) {\n newGeometry.setIndex(newIndices);\n }\n }\n\n return newGeometry;\n}\n\n/**\n * Function to split mesh by feature ID\n */\nfunction splitMeshByOid(originalMesh: Mesh, oid: number): Mesh[] {\n const { meshFeatures, structuralMetadata } = originalMesh.userData;\n const { geometry, featureIds } = meshFeatures;\n\n const featureId = featureIds[0];\n const featureIdAttr = geometry.getAttribute(\n `_feature_id_${featureId.attribute}`\n );\n\n if (!featureIdAttr) {\n console.warn(\"No feature ID attribute found\");\n return [];\n }\n\n const featureIdMap = buildFeatureIdIndexMap(featureIdAttr);\n\n const currentBatchMeshes: Mesh[] = [];\n\n for (const [fid] of featureIdMap) {\n try {\n let _oid = null;\n let propertyData = null;\n\n if (structuralMetadata) {\n try {\n propertyData = structuralMetadata.getPropertyTableData(\n featureId.propertyTable,\n fid\n );\n _oid = (propertyData as any)?._oid;\n\n if (_oid === oid) {\n const newGeometry = createGeometryForFeatureId(\n geometry,\n featureIdMap,\n fid\n );\n\n if (newGeometry && newGeometry.attributes.position.count > 0) {\n const newMaterial = (originalMesh.material as any).clone();\n\n const newMesh = new Mesh(newGeometry, newMaterial);\n newMesh.parent = originalMesh.parent;\n newMesh.position.copy(originalMesh.position);\n newMesh.rotation.copy(originalMesh.rotation);\n newMesh.scale.copy(originalMesh.scale);\n newMesh.matrixWorld.copy(originalMesh.matrixWorld);\n\n newMesh.userData = {\n ...originalMesh.userData,\n featureId: fid,\n oid: oid,\n originalMesh: originalMesh,\n propertyData: propertyData,\n isSplit: true,\n };\n\n newMesh.name = `feature_${fid}_${oid || \"\"}`;\n currentBatchMeshes.push(newMesh);\n }\n }\n } catch (e) {\n console.warn(`Failed to get property data for feature ${fid}:`, e);\n }\n }\n } catch (error) {\n console.warn(`Error creating mesh for feature ${fid}:`, error);\n }\n }\n\n return currentBatchMeshes;\n}\n\n/**\n * 根据OID获取包含该OID的瓦片mesh\n */\nexport function getTileMeshesByOid(tiles: TilesRenderer, oid: number): Mesh[] {\n const tileMeshes: Mesh[] = [];\n\n tiles.group.traverse((child: Object3D) => {\n const mesh = child as Mesh;\n\n if (\n mesh.userData.meshFeatures &&\n mesh.userData.structuralMetadata &&\n !mesh.userData.isSplit\n ) {\n if (checkMeshContainsOid(mesh, oid)) {\n tileMeshes.push(mesh);\n }\n }\n });\n\n return tileMeshes;\n}\n\nfunction checkMeshContainsOid(mesh: Mesh, oid: number): boolean {\n const idMap = mesh.userData.idMap;\n\n if (!idMap) {\n return false;\n }\n\n return idMap[oid] !== undefined;\n}\n\n/**\n * 获取分割后的mesh\n */\nexport function getSplitMeshesFromTile(tileMesh: Mesh, oid: number): Mesh[] {\n let meshes: Mesh[] = [];\n\n try {\n const splitMeshes = splitMeshByOid(tileMesh, oid);\n meshes = [...meshes, ...splitMeshes];\n } catch (error) {\n console.warn(`拆分mesh失败:`, error);\n }\n\n return meshes;\n}\n","import { EventDispatcher, Mesh } from \"three\";\r\n\r\nexport interface MeshHelperHost {\r\n _registerCollector(collector: MeshCollector): void;\r\n _unregisterCollector(collector: MeshCollector): void;\r\n _getMeshesByOidInternal(oid: number): Mesh[];\r\n}\r\n\r\nexport interface MeshChangeEvent {\r\n type: \"mesh-change\";\r\n meshes: Mesh[];\r\n}\r\n\r\nexport type MeshCollectorEventMap = {\r\n \"mesh-change\": MeshChangeEvent;\r\n};\r\n\r\n/**\r\n * MeshCollector - 用于监听和收集特定 oid 对应的 mesh\r\n * 随着瓦片变化,会自动更新 meshes 并触发 mesh-change 事件\r\n */\r\nexport class MeshCollector extends EventDispatcher<MeshCollectorEventMap> {\r\n private oid: number;\r\n private plugin: MeshHelperHost;\r\n private _meshes: Mesh[] = [];\r\n private _disposed: boolean = false;\r\n\r\n constructor(oid: number, plugin: MeshHelperHost) {\r\n super();\r\n this.oid = oid;\r\n this.plugin = plugin;\r\n\r\n plugin._registerCollector(this);\r\n\r\n this._updateMeshes();\r\n }\r\n\r\n get meshes(): Mesh[] {\r\n return this._meshes;\r\n }\r\n\r\n _updateMeshes(): void {\r\n if (this._disposed) return;\r\n\r\n const newMeshes = this.plugin._getMeshesByOidInternal(this.oid);\r\n\r\n const hasChanged =\r\n newMeshes.length !== this._meshes.length ||\r\n newMeshes.some((mesh: Mesh, i: number) => mesh !== this._meshes[i]);\r\n\r\n if (hasChanged) {\r\n this._meshes = newMeshes;\r\n this.dispatchEvent({ type: \"mesh-change\", meshes: this._meshes });\r\n }\r\n }\r\n\r\n getOid(): number {\r\n return this.oid;\r\n }\r\n\r\n dispose(): void {\r\n if (this._disposed) return;\r\n this._disposed = true;\r\n this.plugin._unregisterCollector(this);\r\n this._meshes = [];\r\n }\r\n}\r\n","import {\n DataTexture,\n RGBAFormat,\n SRGBColorSpace,\n Texture,\n UnsignedByteType,\n} from \"three\";\nimport type { GLTFWorkerData } from \"../types\";\n\nexport interface TextureBuildResult {\n textureMap: Map<number, Texture>;\n textureArray: (Texture | null)[];\n}\n\n/**\n * Build textures from GLTF data\n */\nexport function buildTextures(data: GLTFWorkerData): TextureBuildResult {\n const textureMap = new Map<number, Texture>();\n const textureArray: (Texture | null)[] = [];\n\n if (!data.textures) {\n return { textureMap, textureArray };\n }\n\n for (const [index, textureData] of data.textures.entries()) {\n if (textureData.image && textureData.image.array) {\n const imageData = textureData.image;\n const tex = new DataTexture(\n imageData.array,\n imageData.width,\n imageData.height,\n RGBAFormat,\n UnsignedByteType,\n );\n tex.flipY = false;\n tex.colorSpace = SRGBColorSpace;\n tex.needsUpdate = true;\n textureMap.set(index, tex);\n textureArray[index] = tex;\n continue;\n }\n\n // Default empty texture\n const texture = new Texture();\n texture.flipY = false;\n textureMap.set(index, texture);\n textureArray[index] = texture;\n }\n\n return { textureMap, textureArray };\n}\n","import {\r\n DoubleSide,\r\n FrontSide,\r\n Material,\r\n MeshStandardMaterial,\r\n Texture,\r\n} from \"three\";\r\nimport type { GLTFWorkerData, MaterialBuilder } from \"../types\";\r\n\r\n/**\r\n * Build materials from GLTF data\r\n */\r\nexport function buildMaterials(\r\n data: GLTFWorkerData,\r\n textureMap: Map<number, Texture>,\r\n customMaterialBuilder?: MaterialBuilder,\r\n): Map<number, Material> {\r\n const materialMap = new Map<number, Material>();\r\n\r\n if (!data.materials) {\r\n return materialMap;\r\n }\r\n\r\n const materialBuilder = customMaterialBuilder || defaultMaterialBuilder;\r\n\r\n for (const [index, matData] of data.materials.entries()) {\r\n const material = materialBuilder(matData, textureMap);\r\n\r\n materialMap.set(index, material);\r\n }\r\n\r\n return materialMap;\r\n}\r\n\r\nfunction defaultMaterialBuilder(\r\n matData: any,\r\n textureMap: Map<number, Texture>,\r\n): Material {\r\n const material = new MeshStandardMaterial();\r\n\r\n // PBR material properties\r\n if (matData.pbrMetallicRoughness) {\r\n const pbr = matData.pbrMetallicRoughness;\r\n\r\n // Base color\r\n if (pbr.baseColorFactor) {\r\n material.color.setRGB(\r\n pbr.baseColorFactor[0],\r\n pbr.baseColorFactor[1],\r\n pbr.baseColorFactor[2],\r\n );\r\n if (pbr.baseColorFactor[3] !== undefined) {\r\n material.opacity = pbr.baseColorFactor[3];\r\n if (material.opacity < 1) material.transparent = true;\r\n }\r\n }\r\n\r\n // Base color texture\r\n if (pbr.baseColorTexture && pbr.baseColorTexture.index !== undefined) {\r\n const tex = textureMap.get(pbr.baseColorTexture.index);\r\n if (tex) {\r\n material.map = tex;\r\n }\r\n }\r\n\r\n // Metalness and roughness\r\n material.metalness =\r\n pbr.metallicFactor !== undefined ? pbr.metallicFactor : 1.0;\r\n material.roughness =\r\n pbr.roughnessFactor !== undefined ? pbr.roughnessFactor : 1.0;\r\n\r\n // Metallic roughness texture\r\n if (\r\n pbr.metallicRoughnessTexture &&\r\n pbr.metallicRoughnessTexture.index !== undefined\r\n ) {\r\n const tex = textureMap.get(pbr.metallicRoughnessTexture.index);\r\n if (tex) {\r\n material.metalnessMap = material.roughnessMap = tex;\r\n }\r\n }\r\n }\r\n\r\n // Normal map\r\n if (matData.normalTexture && matData.normalTexture.index !== undefined) {\r\n const tex = textureMap.get(matData.normalTexture.index);\r\n if (tex) {\r\n material.normalMap = tex;\r\n if (matData.normalTexture.scale !== undefined) {\r\n material.normalScale.set(\r\n matData.normalTexture.scale,\r\n matData.normalTexture.scale,\r\n );\r\n }\r\n }\r\n }\r\n\r\n // Occlusion map\r\n if (\r\n matData.occlusionTexture &&\r\n matData.occlusionTexture.index !== undefined\r\n ) {\r\n const tex = textureMap.get(matData.occlusionTexture.index);\r\n if (tex) {\r\n material.aoMap = tex;\r\n }\r\n }\r\n\r\n // Emissive\r\n if (matData.emissiveTexture && matData.emissiveTexture.index !== undefined) {\r\n const tex = textureMap.get(matData.emissiveTexture.index);\r\n if (tex) {\r\n material.emissiveMap = tex;\r\n }\r\n }\r\n if (matData.emissiveFactor) {\r\n material.emissive.setRGB(\r\n matData.emissiveFactor[0],\r\n matData.emissiveFactor[1],\r\n matData.emissiveFactor[2],\r\n );\r\n }\r\n\r\n // Double sided rendering\r\n material.side = matData.doubleSided ? DoubleSide : FrontSide;\r\n\r\n // Alpha mode\r\n if (matData.alphaMode === \"BLEND\") {\r\n material.transparent = true;\r\n } else if (matData.alphaMode === \"MASK\") {\r\n material.alphaTest =\r\n matData.alphaCutoff !== undefined ? matData.alphaCutoff : 0.5;\r\n }\r\n\r\n return material;\r\n}\r\n","import { BufferAttribute, BufferGeometry, Material, MeshStandardMaterial } from \"three\";\r\nimport type { GLTFWorkerData, PrimitiveExtensions } from \"../types\";\r\n\r\nexport interface PrimitiveData {\r\n geometry: BufferGeometry;\r\n material: Material;\r\n primitiveIndex: number;\r\n extensions?: PrimitiveExtensions;\r\n}\r\n\r\n/**\r\n * Build Mesh Primitives from GLTF data\r\n */\r\nexport function buildMeshPrimitives(\r\n data: GLTFWorkerData,\r\n materialMap: Map<number, Material>,\r\n defaultMaterial: Material,\r\n): Map<number, PrimitiveData[]> {\r\n const meshMap = new Map<number, PrimitiveData[]>();\r\n\r\n if (!data.meshes) {\r\n return meshMap;\r\n }\r\n\r\n for (const meshIndex in data.meshes) {\r\n const meshData = data.meshes[meshIndex];\r\n const primitiveDataList: PrimitiveData[] = [];\r\n const primitives = meshData.primitives;\r\n\r\n for (\r\n let primitiveIndex = 0;\r\n primitiveIndex < primitives.length;\r\n primitiveIndex++\r\n ) {\r\n const primitive = primitives[primitiveIndex];\r\n const geometry = new BufferGeometry();\r\n\r\n // Handle vertex attributes\r\n if (primitive.attributes) {\r\n // Position\r\n const posData = primitive.attributes.POSITION;\r\n if (posData && posData.array) {\r\n geometry.setAttribute(\r\n \"position\",\r\n new BufferAttribute(posData.array, posData.itemSize || 3),\r\n );\r\n }\r\n\r\n // Normal\r\n const normalData = primitive.attributes.NORMAL;\r\n if (normalData && normalData.array) {\r\n geometry.setAttribute(\r\n \"normal\",\r\n new BufferAttribute(normalData.array, normalData.itemSize || 3),\r\n );\r\n }\r\n\r\n // UV coordinates\r\n const uvData = primitive.attributes.TEXCOORD_0;\r\n if (uvData && uvData.array) {\r\n geometry.setAttribute(\r\n \"uv\",\r\n new BufferAttribute(uvData.array, uvData.itemSize || 2),\r\n );\r\n }\r\n\r\n // Vertex color\r\n const colorData = primitive.attributes.COLOR_0;\r\n if (colorData && colorData.array) {\r\n geometry.setAttribute(\r\n \"color\",\r\n new BufferAttribute(colorData.array, colorData.itemSize || 3),\r\n );\r\n }\r\n\r\n // Tangent\r\n const tangentData = primitive.attributes.TANGENT;\r\n if (tangentData && tangentData.array) {\r\n geometry.setAttribute(\r\n \"tangent\",\r\n new BufferAttribute(tangentData.array, tangentData.itemSize || 4),\r\n );\r\n }\r\n\r\n // Feature ID attribute (for EXT_mesh_features)\r\n for (const attrName in primitive.attributes) {\r\n if (attrName.startsWith(\"_FEATURE_ID_\")) {\r\n const featureIdData = primitive.attributes[attrName];\r\n if (featureIdData && featureIdData.array) {\r\n const normalizedName = attrName\r\n .toLowerCase()\r\n .replace(\"_feature_id_\", \"_feature_id_\");\r\n geometry.setAttribute(\r\n normalizedName,\r\n new BufferAttribute(\r\n featureIdData.array,\r\n featureIdData.itemSize || 1,\r\n ),\r\n );\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Indices\r\n const indexData = primitive.indices;\r\n if (indexData && indexData.array) {\r\n geometry.setIndex(new BufferAttribute(indexData.array, 1));\r\n }\r\n\r\n // Get material\r\n const material =\r\n primitive.material !== undefined\r\n ? materialMap.get(primitive.material) || defaultMaterial\r\n : defaultMaterial;\r\n\r\n if (!geometry.hasAttribute(\"normal\") && material instanceof MeshStandardMaterial) {\r\n material.flatShading = true;\r\n }\r\n\r\n primitiveDataList.push({\r\n geometry,\r\n material,\r\n primitiveIndex,\r\n extensions: primitive.extensions,\r\n });\r\n }\r\n\r\n meshMap.set(Number(meshIndex), primitiveDataList);\r\n }\r\n\r\n return meshMap;\r\n}\r\n","// Import inline Worker (Vite will compile and bundle the worker code into a base64 data URL)\r\nimport GLTFWorkerClass from \"../worker/index?worker&inline\";\r\n\r\n// Worker pool management\r\nlet workerPool: Worker[] = [];\r\nlet maxWorkers = 1;\r\nlet currentWorkerIndex = 0;\r\n\r\n// ---- Global schema cache (shared across all workers) ----\r\n\r\nconst schemaCache = new Map<string, Promise<any>>();\r\n\r\n/**\r\n * Clear the global schema cache.\r\n */\r\nexport function clearSchemaCache(): void {\r\n schemaCache.clear();\r\n}\r\n\r\n/**\r\n * Attach a schema request handler to a Worker.\r\n * When the worker sends a { type: \"fetchSchema\" } message,\r\n * the main thread fetches (with deduplication via cache) and replies with the result.\r\n */\r\nfunction setupSchemaHandler(worker: Worker): void {\r\n worker.addEventListener(\"message\", (event: MessageEvent) => {\r\n const { type, schemaRequestId, url } = event.data;\r\n if (type !== \"fetchSchema\") return;\r\n\r\n let promise = schemaCache.get(url);\r\n if (!promise) {\r\n promise = fetch(url)\r\n .then((res) => {\r\n if (!res.ok) {\r\n throw new Error(\r\n `Failed to fetch schema: ${res.status} ${res.statusText}`,\r\n );\r\n }\r\n return res.json();\r\n })\r\n .catch((err) => {\r\n // Remove from cache on failure so it can be retried next time\r\n schemaCache.delete(url);\r\n throw err;\r\n });\r\n schemaCache.set(url, promise);\r\n }\r\n\r\n promise\r\n .then((data) => {\r\n worker.postMessage({ type: \"schemaResponse\", schemaRequestId, data });\r\n })\r\n .catch((err) => {\r\n worker.postMessage({\r\n type: \"schemaResponse\",\r\n schemaRequestId,\r\n error: err.message || String(err),\r\n });\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Set the maximum number of Workers (must be called before initialization)\r\n */\r\nexport function setMaxWorkers(count: number): void {\r\n maxWorkers = Math.max(1, Math.min(count, navigator.hardwareConcurrency || 4));\r\n}\r\n\r\n/**\r\n * Create a single Worker and wait for it to be ready\r\n */\r\nfunction createWorker(): Worker {\r\n const worker = new GLTFWorkerClass();\r\n setupSchemaHandler(worker);\r\n return worker;\r\n}\r\n\r\n/**\r\n * Initialize the Worker pool\r\n */\r\nfunction initWorkerPool() {\r\n if (workerPool.length === 0) {\r\n // Create all Workers\r\n for (let i = 0; i < maxWorkers; i++) {\r\n workerPool.push(createWorker());\r\n }\r\n }\r\n}\r\n\r\nexport function getWorkers(): Worker[] {\r\n initWorkerPool();\r\n return workerPool;\r\n}\r\n\r\n/**\r\n * Acquire a Worker (wait if none are available)\r\n */\r\nexport function acquireWorker() {\r\n initWorkerPool();\r\n\r\n const worker = workerPool[currentWorkerIndex];\r\n currentWorkerIndex = (currentWorkerIndex + 1) % workerPool.length;\r\n return worker;\r\n}\r\n","import { Box3, Vector2 } from \"three\";\nimport type { Vector3 } from \"three\";\nimport type { StructureNode } from \"../plugin-types\";\n\n/**\n * 射线法判断点是否在多边形内\n */\nexport function pointInPolygon(\n px: number,\n py: number,\n polygon: Vector2[],\n): boolean {\n let inside = false;\n const n = polygon.length;\n for (let i = 0, j = n - 1; i < n; j = i++) {\n const xi = polygon[i].x,\n yi = polygon[i].y;\n const xj = polygon[j].x,\n yj = polygon[j].y;\n if (yi > py !== yj > py && px < ((xj - xi) * (py - yi)) / (yj - yi) + xi) {\n inside = !inside;\n }\n }\n return inside;\n}\n\n/**\n * 判断两线段是否相交\n */\nexport function segmentsIntersect(\n ax1: number,\n ay1: number,\n ax2: number,\n ay2: number,\n bx1: number,\n by1: number,\n bx2: number,\n by2: number,\n): boolean {\n const cross = (\n ox: number,\n oy: number,\n ax: number,\n ay: number,\n bx: number,\n by: number,\n ) => (ax - ox) * (by - oy) - (ay - oy) * (bx - ox);\n\n const d1 = cross(bx1, by1, bx2, by2, ax1, ay1);\n const d2 = cross(bx1, by1, bx2, by2, ax2, ay2);\n const d3 = cross(ax1, ay1, ax2, ay2, bx1, by1);\n const d4 = cross(ax1, ay1, ax2, ay2, bx2, by2);\n\n if (\n ((d1 > 0 && d2 < 0) || (d1 < 0 && d2 > 0)) &&\n ((d3 > 0 && d4 < 0) || (d3 < 0 && d4 > 0))\n ) {\n return true;\n }\n\n const onSeg = (\n px: number,\n py: number,\n qx: number,\n qy: number,\n rx: number,\n ry: number,\n ) =>\n Math.min(px, qx) <= rx &&\n rx <= Math.max(px, qx) &&\n Math.min(py, qy) <= ry &&\n ry <= Math.max(py, qy);\n\n if (d1 === 0 && onSeg(bx1, by1, bx2, by2, ax1, ay1)) return true;\n if (d2 === 0 && onSeg(bx1, by1, bx2, by2, ax2, ay2)) return true;\n if (d3 === 0 && onSeg(ax1, ay1, ax2, ay2, bx1, by1)) return true;\n if (d4 === 0 && onSeg(ax1, ay1, ax2, ay2, bx2, by2)) return true;\n\n return false;\n}\n\n/**\n * 判断多边形与矩形是否相交或包含\n */\nexport function polygonIntersectsRect(\n polygon: Vector2[],\n minX: number,\n minY: number,\n maxX: number,\n maxY: number,\n): boolean {\n const n = polygon.length;\n\n for (let i = 0; i < n; i++) {\n const p = polygon[i];\n if (p.x >= minX && p.x <= maxX && p.y >= minY && p.y <= maxY) {\n return true;\n }\n }\n\n if (\n pointInPolygon(minX, minY, polygon) ||\n pointInPolygon(maxX, minY, polygon) ||\n pointInPolygon(maxX, maxY, polygon) ||\n pointInPolygon(minX, maxY, polygon)\n ) {\n return true;\n }\n\n const rx = [minX, maxX, maxX, minX];\n const ry = [minY, minY, maxY, maxY];\n\n for (let i = 0; i < n; i++) {\n const a = polygon[i];\n const b = polygon[(i + 1) % n];\n for (let j = 0; j < 4; j++) {\n const k = (j + 1) % 4;\n if (segmentsIntersect(a.x, a.y, b.x, b.y, rx[j], ry[j], rx[k], ry[k])) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n/**\n * 从 OID 节点映射中按 Box3 范围筛选构件\n */\nexport function selectByBoxFromOidMap(\n oidNodeMap: Map<number, StructureNode>,\n box: Box3,\n): number[] {\n const result: number[] = [];\n const nodeBox = new Box3();\n\n for (const [oid, node] of oidNodeMap) {\n if (!node.bbox || node.bbox.length < 6) continue;\n nodeBox.min.set(node.bbox[0], node.bbox[1], node.bbox[2]);\n nodeBox.max.set(node.bbox[3], node.bbox[4], node.bbox[5]);\n if (box.intersectsBox(nodeBox)) {\n result.push(oid);\n }\n }\n\n return result;\n}\n\n/**\n * 从 OID 节点映射中按多边形(平面投影)范围筛选构件\n */\nexport function selectByPolygonFromOidMap(\n oidNodeMap: Map<number, StructureNode>,\n polygon: Vector3[],\n axis: \"xy\" | \"xz\" | \"yz\" = \"xz\",\n): number[] {\n const result: number[] = [];\n const polygon2D: Vector2[] = polygon.map((p) => {\n switch (axis) {\n case \"xy\":\n return new Vector2(p.x, p.y);\n case \"yz\":\n return new Vector2(p.y, p.z);\n case \"xz\":\n default:\n return new Vector2(p.x, p.z);\n }\n });\n\n for (const [oid, node] of oidNodeMap) {\n if (!node.bbox || node.bbox.length < 6) continue;\n\n let minU: number, minV: number, maxU: number, maxV: number;\n switch (axis) {\n case \"xy\":\n minU = node.bbox[0];\n minV = node.bbox[1];\n maxU = node.bbox[3];\n maxV = node.bbox[4];\n break;\n case \"xz\":\n minU = node.bbox[0];\n minV = node.bbox[2];\n maxU = node.bbox[3];\n maxV = node.bbox[5];\n break;\n case \"yz\":\n minU = node.bbox[1];\n minV = node.bbox[2];\n maxU = node.bbox[4];\n maxV = node.bbox[5];\n break;\n }\n\n if (polygonIntersectsRect(polygon2D, minU, minV, maxU, maxV)) {\n result.push(oid);\n }\n }\n\n return result;\n}\n","class z {\n get unloadPriorityCallback() {\n return this._unloadPriorityCallback;\n }\n set unloadPriorityCallback(t) {\n t.length === 1 ? (console.warn('LRUCache: \"unloadPriorityCallback\" function has been changed to take two arguments.'), this._unloadPriorityCallback = (a, e) => {\n const s = t(a), o = t(e);\n return s < o ? -1 : s > o ? 1 : 0;\n }) : this._unloadPriorityCallback = t;\n }\n constructor() {\n this.minSize = 6e3, this.maxSize = 8e3, this.minBytesSize = 0.3 * 1073741824, this.maxBytesSize = 0.4 * 1073741824, this.unloadPercent = 0.05, this.autoMarkUnused = !0, this.itemSet = /* @__PURE__ */ new Map(), this.itemList = [], this.usedSet = /* @__PURE__ */ new Set(), this.callbacks = /* @__PURE__ */ new Map(), this.unloadingHandle = -1, this.cachedBytes = 0, this.bytesMap = /* @__PURE__ */ new Map(), this.loadedSet = /* @__PURE__ */ new Set(), this._unloadPriorityCallback = null;\n const t = this.itemSet;\n this.defaultPriorityCallback = (a) => t.get(a);\n }\n // Returns whether or not the cache has reached the maximum size\n isFull() {\n return this.itemSet.size >= this.maxSize || this.cachedBytes >= this.maxBytesSize;\n }\n getMemoryUsage(t) {\n return this.bytesMap.get(t) || 0;\n }\n setMemoryUsage(t, a) {\n const { bytesMap: e, itemSet: s } = this;\n s.has(t) && (this.cachedBytes -= e.get(t) || 0, e.set(t, a), this.cachedBytes += a);\n }\n add(t, a) {\n const e = this.itemSet;\n if (e.has(t) || this.isFull())\n return !1;\n const s = this.usedSet, o = this.itemList, i = this.callbacks;\n return o.push(t), s.add(t), e.set(t, Date.now()), i.set(t, a), !0;\n }\n has(t) {\n return this.itemSet.has(t);\n }\n remove(t) {\n const a = this.usedSet, e = this.itemSet, s = this.itemList, o = this.bytesMap, i = this.callbacks, c = this.loadedSet;\n if (e.has(t)) {\n this.cachedBytes -= o.get(t) || 0, o.delete(t), i.get(t)(t);\n const d = s.indexOf(t);\n return s.splice(d, 1), a.delete(t), e.delete(t), i.delete(t), c.delete(t), !0;\n }\n return !1;\n }\n // Marks whether tiles in the cache have been completely loaded or not. Tiles that have not been completely\n // loaded are subject to being disposed early if the cache is full above its max size limits, even if they\n // are marked as used.\n setLoaded(t, a) {\n const { itemSet: e, loadedSet: s } = this;\n e.has(t) && (a === !0 ? s.add(t) : s.delete(t));\n }\n markUsed(t) {\n const a = this.itemSet, e = this.usedSet;\n a.has(t) && !e.has(t) && (a.set(t, Date.now()), e.add(t));\n }\n markUnused(t) {\n this.usedSet.delete(t);\n }\n markAllUnused() {\n this.usedSet.clear();\n }\n isUsed(t) {\n return this.usedSet.has(t);\n }\n // TODO: this should be renamed because it's not necessarily unloading all unused content\n // Maybe call it \"cleanup\" or \"unloadToMinSize\"\n unloadUnusedContent() {\n const {\n unloadPercent: t,\n minSize: a,\n maxSize: e,\n itemList: s,\n itemSet: o,\n usedSet: i,\n loadedSet: c,\n callbacks: d,\n bytesMap: u,\n minBytesSize: h,\n maxBytesSize: y\n } = this, b = s.length - i.size, B = s.length - c.size, S = Math.max(Math.min(s.length - a, b), 0), k = this.cachedBytes - h, M = this.unloadPriorityCallback || this.defaultPriorityCallback;\n let f = !1;\n const P = S > 0 && b > 0 || B && s.length > e;\n if (b && this.cachedBytes > h || B && this.cachedBytes > y || P) {\n s.sort((n, r) => {\n const U = i.has(n), L = i.has(r);\n if (U === L) {\n const x = c.has(n), v = c.has(r);\n return x === v ? -M(n, r) : x ? 1 : -1;\n } else\n return U ? 1 : -1;\n });\n const A = Math.max(a * t, S * t), p = Math.ceil(Math.min(A, b, S)), E = Math.max(t * k, t * h), w = Math.min(E, k);\n let l = 0, m = 0;\n for (; this.cachedBytes - m > y || s.length - l > e; ) {\n const n = s[l], r = u.get(n) || 0;\n if (i.has(n) && c.has(n) || this.cachedBytes - m - r < y && s.length - l <= e)\n break;\n m += r, l++;\n }\n for (; m < w || l < p; ) {\n const n = s[l], r = u.get(n) || 0;\n if (i.has(n) || this.cachedBytes - m - r < h && l >= p)\n break;\n m += r, l++;\n }\n s.splice(0, l).forEach((n) => {\n this.cachedBytes -= u.get(n) || 0, d.get(n)(n), u.delete(n), o.delete(n), d.delete(n), c.delete(n), i.delete(n);\n }), f = l < S || m < k && l < b, f = f && l > 0;\n }\n f && (this.unloadingHandle = requestAnimationFrame(() => this.scheduleUnload()));\n }\n scheduleUnload() {\n cancelAnimationFrame(this.unloadingHandle), this.scheduled || (this.scheduled = !0, queueMicrotask(() => {\n this.scheduled = !1, this.unloadUnusedContent();\n }));\n }\n}\nclass C extends Error {\n constructor() {\n super(\"PriorityQueue: Item removed\"), this.name = \"PriorityQueueItemRemovedError\";\n }\n}\nclass G {\n // returns whether tasks are queued or actively running\n get running() {\n return this.items.length !== 0 || this.currJobs !== 0;\n }\n constructor() {\n this.maxJobs = 6, this.items = [], this.callbacks = /* @__PURE__ */ new Map(), this.currJobs = 0, this.scheduled = !1, this.autoUpdate = !0, this.priorityCallback = null, this.schedulingCallback = (t) => {\n requestAnimationFrame(t);\n }, this._runjobs = () => {\n this.scheduled = !1, this.tryRunJobs();\n };\n }\n sort() {\n const t = this.priorityCallback, a = this.items;\n t !== null && a.sort(t);\n }\n has(t) {\n return this.callbacks.has(t);\n }\n add(t, a) {\n const e = {\n callback: a,\n reject: null,\n resolve: null,\n promise: null\n };\n return e.promise = new Promise((s, o) => {\n const i = this.items, c = this.callbacks;\n e.resolve = s, e.reject = o, i.unshift(t), c.set(t, e), this.autoUpdate && this.scheduleJobRun();\n }), e.promise;\n }\n remove(t) {\n const a = this.items, e = this.callbacks, s = a.indexOf(t);\n if (s !== -1) {\n const o = e.get(t);\n o.promise.catch((i) => {\n if (!(i instanceof C))\n throw i;\n }), o.reject(new C()), a.splice(s, 1), e.delete(t);\n }\n }\n removeByFilter(t) {\n const { items: a } = this;\n for (let e = 0; e < a.length; e++) {\n const s = a[e];\n t(s) && (this.remove(s), e--);\n }\n }\n tryRunJobs() {\n this.sort();\n const t = this.items, a = this.callbacks, e = this.maxJobs;\n let s = 0;\n const o = () => {\n this.currJobs--, this.autoUpdate && this.scheduleJobRun();\n };\n for (; e > this.currJobs && t.length > 0 && s < e; ) {\n this.currJobs++, s++;\n const i = t.pop(), { callback: c, resolve: d, reject: u } = a.get(i);\n a.delete(i);\n let h;\n try {\n h = c(i);\n } catch (y) {\n u(y), o();\n }\n h instanceof Promise ? h.then(d).catch(u).finally(o) : (d(h), o());\n }\n }\n scheduleJobRun() {\n this.scheduled || (this.schedulingCallback(this._runjobs), this.scheduled = !0);\n }\n}\nconst J = -1, I = 0, R = 1, _ = 2, D = 3, F = 4, N = 6378137, j = 1 / 298.257223563, Q = 6356752314245179e-9;\nexport {\n J as F,\n F as L,\n D as P,\n R as Q,\n I as U,\n j as W,\n _ as a,\n z as b,\n G as c,\n C as d,\n Q as e,\n N as f\n};\n//# sourceMappingURL=constants-Cj07Qhs1.js.map\n","import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebGLRenderer}.\n *\n * @augments Mesh\n * @three_import import { FullScreenQuad } from 'three/addons/postprocessing/Pass.js';\n */\nclass FullScreenQuad {\n\n\t/**\n\t * Constructs a new full screen quad.\n\t *\n\t * @param {?Material} material - The material to render te full screen quad with.\n\t */\n\tconstructor( material ) {\n\n\t\tthis._mesh = new Mesh( _geometry, material );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the instance is no longer used in your app.\n\t */\n\tdispose() {\n\n\t\tthis._mesh.geometry.dispose();\n\n\t}\n\n\t/**\n\t * Renders the full screen quad.\n\t *\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t */\n\trender( renderer ) {\n\n\t\trenderer.render( this._mesh, _camera );\n\n\t}\n\n\t/**\n\t * The quad's material.\n\t *\n\t * @type {?Material}\n\t */\n\tget material() {\n\n\t\treturn this._mesh.material;\n\n\t}\n\n\tset material( value ) {\n\n\t\tthis._mesh.material = value;\n\n\t}\n\n}\n\nexport { Pass, FullScreenQuad };\n","import { Q as Fn, b as kn, C as Gn, G as zn } from \"./QuantizedMeshLoaderBase-Bbby1xf8.js\";\nimport { PlaneGeometry as Js, Mesh as Be, MeshBasicMaterial as Se, Vector2 as Y, MathUtils as b, Vector3 as E, Sphere as de, Texture as Hn, SRGBColorSpace as qt, TextureUtils as qn, DefaultLoadingManager as Wn, BufferGeometry as st, MeshStandardMaterial as Ks, BufferAttribute as J, DataTexture as Wt, RGFormat as en, UnsignedByteType as tn, LinearMipMapLinearFilter as jn, LinearFilter as sn, Triangle as jt, Vector4 as Oe, Matrix4 as K, Matrix3 as Yn, Matrix2 as Xn, WebGLRenderer as $n, WebGLRenderTarget as ts, ShaderMaterial as Qn, OneFactor as Zn, ZeroFactor as Jn, CustomBlending as Kn, Box2 as ei, FileLoader as ti, Quaternion as nn, BatchedMesh as si, Source as ni, Box3 as ct, REVISION as ii, WebGLArrayRenderTarget as ss, Raycaster as ri, DoubleSide as rn, CanvasTexture as Yt, Color as on, Ray as oi, LineSegments as an, LineBasicMaterial as ai, EdgesGeometry as li, BoxGeometry as ln, Group as ke, Box3Helper as ci, PointsMaterial as ui } from \"three\";\nimport { a as cn, c as hi, W as di, g as pi, O as fi, b as mi } from \"./MemoryUtils-BD0AS93P.js\";\nimport { GLTFLoader as gi } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { FullScreenQuad as un } from \"three/examples/jsm/postprocessing/Pass.js\";\nimport { b as yi, c as xi, d as Ti, f as hn } from \"./constants-Cj07Qhs1.js\";\nimport { c as bi, L as dn } from \"./LoaderBase-2yhE3Jur.js\";\nconst fe = /* @__PURE__ */ new Y(), ye = Symbol(\"TILE_X\"), xe = Symbol(\"TILE_Y\"), ae = Symbol(\"TILE_LEVEL\");\nclass pn {\n get tiling() {\n return this.imageSource.tiling;\n }\n constructor(e = {}) {\n const {\n pixelSize: t = null,\n center: s = !1,\n useRecommendedSettings: n = !0,\n imageSource: i = null\n } = e;\n this.priority = -10, this.tiles = null, this.imageSource = i, this.pixelSize = t, this.center = s, this.useRecommendedSettings = n, t !== null && console.warn('ImageFormatPlugin: \"pixelSize\" has been deprecated in favor of scaling the tiles root.');\n }\n // Plugin functions\n init(e) {\n this.useRecommendedSettings && (e.errorTarget = 1), this.tiles = e, this.imageSource.fetchOptions = e.fetchOptions, this.imageSource.fetchData = (t, s) => (e.invokeAllPlugins((n) => t = n.preprocessURL ? n.preprocessURL(t, null) : t), e.invokeOnePlugin((n) => n !== this && n.fetchData && n.fetchData(t, s)));\n }\n async loadRootTileset() {\n const { tiles: e, imageSource: t } = this;\n return t.url = t.url || e.rootURL, e.invokeAllPlugins((s) => t.url = s.preprocessURL ? s.preprocessURL(t.url, null) : t.url), await t.init(), e.rootURL = t.url, this.getTileset(t.url);\n }\n async parseToMesh(e, t, s, n, i) {\n if (i.aborted)\n return null;\n const { imageSource: r } = this, o = t[ye], l = t[xe], c = t[ae], u = await r.processBufferToTexture(e);\n if (i.aborted)\n return u.dispose(), u.image.close(), null;\n r.setData(o, l, c, u);\n let h = 1, d = 1, m = 0, f = 0, p = 0;\n const g = t.boundingVolume.box;\n g && ([m, f, p] = g, h = g[3], d = g[7]);\n const y = new Js(2 * h, 2 * d), x = new Be(y, new Se({ map: u, transparent: !0 }));\n x.position.set(m, f, p);\n const T = r.tiling.getTileContentUVBounds(o, l, c), { uv: M } = y.attributes;\n for (let _ = 0; _ < M.count; _++)\n fe.fromBufferAttribute(M, _), fe.x = b.mapLinear(fe.x, 0, 1, T[0], T[2]), fe.y = b.mapLinear(fe.y, 0, 1, T[1], T[3]), M.setXY(_, fe.x, fe.y);\n return x;\n }\n preprocessNode(e) {\n const { tiling: t } = this, s = t.maxLevel;\n e[ae] < s && e.parent !== null && this.expandChildren(e);\n }\n disposeTile(e) {\n const t = e[ye], s = e[xe], n = e[ae], { imageSource: i } = this;\n i.has(t, s, n) && i.release(t, s, n);\n }\n // Local functions\n getTileset(e) {\n const { tiling: t, tiles: s } = this, n = t.minLevel, { tileCountX: i, tileCountY: r } = t.getLevel(n), o = [];\n for (let c = 0; c < i; c++)\n for (let u = 0; u < r; u++) {\n const h = this.createChild(c, u, n);\n h !== null && o.push(h);\n }\n const l = {\n asset: {\n version: \"1.1\"\n },\n geometricError: 1e5,\n root: {\n refine: \"REPLACE\",\n geometricError: 1e5,\n boundingVolume: this.createBoundingVolume(0, 0, -1),\n children: o,\n [ae]: -1,\n [ye]: 0,\n [xe]: 0\n }\n };\n return s.preprocessTileset(l, e), l;\n }\n getUrl(e, t, s) {\n return this.imageSource.getUrl(e, t, s);\n }\n createBoundingVolume(e, t, s) {\n const { center: n, pixelSize: i, tiling: r } = this, { pixelWidth: o, pixelHeight: l } = r.getLevel(r.maxLevel), [c, u, h, d] = s === -1 ? r.getContentBounds(!0) : r.getTileBounds(e, t, s, !0);\n let m = (h - c) / 2, f = (d - u) / 2, p = c + m, g = u + f;\n return n && (p -= 0.5, g -= 0.5), i ? (p *= o * i, m *= o * i, g *= l * i, f *= l * i) : (p *= r.aspectRatio, m *= r.aspectRatio), {\n box: [\n // center\n p,\n g,\n 0,\n // x, y, z half vectors\n m,\n 0,\n 0,\n 0,\n f,\n 0,\n 0,\n 0,\n 0\n ]\n };\n }\n createChild(e, t, s) {\n const { pixelSize: n, tiling: i } = this;\n if (!i.getTileExists(e, t, s))\n return null;\n const { pixelWidth: r, pixelHeight: o } = i.getLevel(s);\n let l = Math.max(i.aspectRatio / r, 1 / o);\n if (n) {\n const c = i.getLevel(i.maxLevel);\n l *= n * Math.max(c.pixelWidth, c.pixelHeight);\n }\n return {\n refine: \"REPLACE\",\n geometricError: l,\n boundingVolume: this.createBoundingVolume(e, t, s),\n content: {\n uri: this.getUrl(e, t, s)\n },\n children: [],\n // save the tile params so we can expand later\n [ye]: e,\n [xe]: t,\n [ae]: s\n };\n }\n expandChildren(e) {\n const t = e[ae], s = e[ye], n = e[xe], { tileSplitX: i, tileSplitY: r } = this.tiling.getLevel(t);\n for (let o = 0; o < i; o++)\n for (let l = 0; l < r; l++) {\n const c = this.createChild(i * s + o, r * n + l, t + 1);\n c && e.children.push(c);\n }\n }\n}\nconst ft = /* @__PURE__ */ new E(), Ge = /* @__PURE__ */ new E();\nfunction _i(a, e, t) {\n const n = t + 1e-5;\n let i = e + 1e-5;\n Math.abs(i) > Math.PI / 2 && (i = i - 1e-5), a.getCartographicToPosition(e, t, 0, ft), a.getCartographicToPosition(i, t, 0, Ge);\n const r = ft.distanceTo(Ge) / 1e-5;\n return a.getCartographicToPosition(e, n, 0, Ge), [ft.distanceTo(Ge) / 1e-5, r];\n}\nconst Si = 30, Mi = 15, mt = /* @__PURE__ */ new E(), ns = /* @__PURE__ */ new E(), ie = /* @__PURE__ */ new Y(), gt = /* @__PURE__ */ new de();\nclass ut extends pn {\n get projection() {\n return this.tiling.projection;\n }\n constructor(e = {}) {\n const {\n shape: t = \"planar\",\n endCaps: s = !0,\n ...n\n } = e;\n super(n), this.shape = t, this.endCaps = s;\n }\n // override the parse to mesh logic to support a region mesh\n async parseToMesh(e, t, ...s) {\n const n = await super.parseToMesh(e, t, ...s), { shape: i, projection: r, tiles: o, tiling: l } = this;\n if (i === \"ellipsoid\") {\n const c = o.ellipsoid, u = t[ae], h = t[ye], d = t[xe], [m, f, p, g] = t.boundingVolume.region, y = Math.ceil((g - f) * b.RAD2DEG * 0.25), x = Math.ceil((p - m) * b.RAD2DEG * 0.25), S = Math.max(Mi, y), T = Math.max(Si, x), M = new Js(1, 1, T, S), [_, C, v, P] = l.getTileBounds(h, d, u, !0, !0), R = l.getTileContentUVBounds(h, d, u), { position: V, normal: k, uv: W } = M.attributes, $ = V.count;\n t.engineData.boundingVolume.getSphere(gt);\n for (let H = 0; H < $; H++) {\n mt.fromBufferAttribute(V, H), ie.fromBufferAttribute(W, H);\n const I = r.convertNormalizedToLongitude(b.mapLinear(ie.x, 0, 1, _, v));\n let A = r.convertNormalizedToLatitude(b.mapLinear(ie.y, 0, 1, C, P));\n if (r.isMercator && this.endCaps && (P === 1 && ie.y === 1 && (A = Math.PI / 2), C === 0 && ie.y === 0 && (A = -Math.PI / 2)), r.isMercator && ie.y !== 0 && ie.y !== 1) {\n const L = r.convertNormalizedToLatitude(1), N = 1 / S, Q = b.mapLinear(ie.y - N, 0, 1, f, g), F = b.mapLinear(ie.y + N, 0, 1, f, g);\n A > L && Q < L && (A = L), A < -L && F > -L && (A = -L);\n }\n c.getCartographicToPosition(A, I, 0, mt).sub(gt.center), c.getCartographicToNormal(A, I, ns);\n const D = b.mapLinear(r.convertLongitudeToNormalized(I), _, v, R[0], R[2]), O = b.mapLinear(r.convertLatitudeToNormalized(A), C, P, R[1], R[3]);\n W.setXY(H, D, O), V.setXYZ(H, ...mt), k.setXYZ(H, ...ns);\n }\n n.geometry = M, n.position.copy(gt.center);\n }\n return n;\n }\n createBoundingVolume(e, t, s) {\n if (this.shape === \"ellipsoid\") {\n const { tiling: n, endCaps: i } = this, r = s === -1, o = r ? n.getContentBounds(!0) : n.getTileBounds(e, t, s, !0, !0), l = r ? n.getContentBounds() : n.getTileBounds(e, t, s, !1, !0);\n return i && (o[3] === 1 && (l[3] = Math.PI / 2), o[1] === 0 && (l[1] = -Math.PI / 2)), {\n region: [...l, -1, 1]\n };\n } else\n return super.createBoundingVolume(e, t, s);\n }\n createChild(...e) {\n const t = super.createChild(...e), { shape: s, projection: n, tiling: i } = this;\n if (t && s === \"ellipsoid\") {\n const r = t[ae], o = t[ye], l = t[xe];\n if (r === -1)\n return t.geometricError = 1e50, parent;\n const [c, u, h, d] = i.getTileBounds(o, l, r, !0), { tilePixelWidth: m, tilePixelHeight: f } = i.getLevel(r), p = (h - c) / m, g = (d - u) / f, [\n /* west */\n ,\n y,\n x,\n S\n ] = i.getTileBounds(o, l, r), T = y > 0 != S > 0 ? 0 : Math.min(Math.abs(y), Math.abs(S)), M = n.convertLatitudeToNormalized(T), _ = n.getLongitudeDerivativeAtNormalized(c), C = n.getLatitudeDerivativeAtNormalized(M), [v, P] = _i(this.tiles.ellipsoid, T, x), R = Math.max(p * _ * v, g * C * P);\n t.geometricError = R;\n }\n return t;\n }\n}\nclass re {\n get isMercator() {\n return this.scheme === \"EPSG:3857\";\n }\n constructor(e = \"EPSG:4326\") {\n this.scheme = e, this.tileCountX = 1, this.tileCountY = 1, this.setScheme(e);\n }\n setScheme(e) {\n switch (this.scheme = e, e) {\n // equirect\n case \"CRS:84\":\n case \"EPSG:4326\":\n this.tileCountX = 2, this.tileCountY = 1;\n break;\n // mercator\n case \"EPSG:3857\":\n this.tileCountX = 1, this.tileCountY = 1;\n break;\n case \"none\":\n this.tileCountX = 1, this.tileCountY = 1;\n break;\n default:\n throw new Error(`ProjectionScheme: Unknown projection scheme \"${e}\"`);\n }\n }\n convertNormalizedToLatitude(e) {\n if (this.scheme === \"none\")\n return e;\n if (this.isMercator) {\n const t = b.mapLinear(e, 0, 1, -1, 1);\n return 2 * Math.atan(Math.exp(t * Math.PI)) - Math.PI / 2;\n } else\n return b.mapLinear(e, 0, 1, -Math.PI / 2, Math.PI / 2);\n }\n convertNormalizedToLongitude(e) {\n return this.scheme === \"none\" ? e : b.mapLinear(e, 0, 1, -Math.PI, Math.PI);\n }\n convertLatitudeToNormalized(e) {\n if (this.scheme === \"none\")\n return e;\n if (this.isMercator) {\n const t = Math.log(Math.tan(Math.PI / 4 + e / 2));\n return 1 / 2 + 1 * t / (2 * Math.PI);\n } else\n return b.mapLinear(e, -Math.PI / 2, Math.PI / 2, 0, 1);\n }\n convertLongitudeToNormalized(e) {\n return this.scheme === \"none\" ? e : (e + Math.PI) / (2 * Math.PI);\n }\n getLongitudeDerivativeAtNormalized(e) {\n return this.scheme === \"none\" ? 1 : 2 * Math.PI;\n }\n getLatitudeDerivativeAtNormalized(e) {\n if (this.scheme === \"none\")\n return 1;\n {\n let s = e - 1e-5;\n return s < 0 && (s = e + 1e-5), this.isMercator ? Math.abs(this.convertNormalizedToLatitude(e) - this.convertNormalizedToLatitude(s)) / 1e-5 : Math.PI;\n }\n }\n getBounds() {\n return this.scheme === \"none\" ? [0, 0, 1, 1] : [\n this.convertNormalizedToLongitude(0),\n this.convertNormalizedToLatitude(0),\n this.convertNormalizedToLongitude(1),\n this.convertNormalizedToLatitude(1)\n ];\n }\n toNormalizedPoint(e, t) {\n const s = [e, t];\n return s[0] = this.convertLongitudeToNormalized(s[0]), s[1] = this.convertLatitudeToNormalized(s[1]), s;\n }\n toNormalizedRange(e) {\n return [\n ...this.toNormalizedPoint(e[0], e[1]),\n ...this.toNormalizedPoint(e[2], e[3])\n ];\n }\n toCartographicPoint(e, t) {\n const s = [e, t];\n return s[0] = this.convertNormalizedToLongitude(s[0]), s[1] = this.convertNormalizedToLatitude(s[1]), s;\n }\n toCartographicRange(e) {\n return [\n ...this.toCartographicPoint(e[0], e[1]),\n ...this.toCartographicPoint(e[2], e[3])\n ];\n }\n clampToBounds(e, t = !1) {\n const s = [...e];\n let n;\n t ? n = [0, 0, 1, 1] : n = this.getBounds();\n const [i, r, o, l] = n;\n return s[0] = b.clamp(s[0], i, o), s[1] = b.clamp(s[1], r, l), s[2] = b.clamp(s[2], i, o), s[3] = b.clamp(s[3], r, l), s;\n }\n}\nfunction Ae(...a) {\n return a.join(\"_\");\n}\nclass fn {\n constructor() {\n this.cache = {}, this.count = 0, this.cachedBytes = 0, this.active = 0;\n }\n // overridable\n fetchItem() {\n }\n disposeItem() {\n }\n getMemoryUsage(e) {\n return 0;\n }\n // sets the data in the cache explicitly without need to load\n setData(...e) {\n const { cache: t } = this, s = e.pop(), n = Ae(...e);\n if (n in t)\n throw new Error(`DataCache: \"${n}\" is already present.`);\n return this.cache[n] = {\n abortController: new AbortController(),\n result: s,\n count: 1,\n bytes: this.getMemoryUsage(s)\n }, this.count++, this.cachedBytes += this.cache[n].bytes, s;\n }\n // fetches the associated data if it doesn't exist and increments the lock counter\n lock(...e) {\n const { cache: t } = this, s = Ae(...e);\n if (s in t)\n t[s].count++;\n else {\n const n = new AbortController(), i = {\n abortController: n,\n result: null,\n count: 1,\n bytes: 0,\n args: e\n };\n this.active++, i.result = this.fetchItem(e, n.signal), i.result instanceof Promise ? i.result.then((r) => (i.result = r, i.bytes = this.getMemoryUsage(r), this.cachedBytes += i.bytes, r)).finally(() => {\n this.active--;\n }).catch((r) => {\n }) : (this.active--, i.bytes = this.getMemoryUsage(i.result), this.cachedBytes += i.bytes), this.cache[s] = i, this.count++;\n }\n return t[s].result;\n }\n // decrements the lock counter for the item and deletes the item if it has reached zero\n release(...e) {\n const t = Ae(...e);\n this.releaseViaFullKey(t);\n }\n // get the loaded item\n get(...e) {\n const { cache: t } = this, s = Ae(...e);\n return s in t && t[s].count > 0 ? t[s].result : null;\n }\n has(...e) {\n const { cache: t } = this;\n return Ae(...e) in t;\n }\n forEachItem(e) {\n const { cache: t } = this;\n for (const s in t) {\n const n = t[s];\n n.result instanceof Promise || e(n.result, n.args);\n }\n }\n // dispose all items\n dispose() {\n const { cache: e } = this;\n for (const t in e) {\n const { abortController: s } = e[t];\n s.abort(), this.releaseViaFullKey(t, !0);\n }\n this.cache = {};\n }\n // releases an item with an optional force flag\n releaseViaFullKey(e, t = !1) {\n const { cache: s } = this;\n if (e in s && s[e].count > 0) {\n const n = s[e];\n if (n.count--, n.count === 0 || t) {\n const i = () => {\n if (s[e] !== n)\n return;\n const { result: r, abortController: o } = n;\n o.abort(), r instanceof Promise ? r.then((l) => {\n this.disposeItem(l), this.count--, this.cachedBytes -= n.bytes;\n }).catch(() => {\n }) : (this.disposeItem(r), this.count--, this.cachedBytes -= n.bytes), delete s[e];\n };\n t ? i() : queueMicrotask(() => {\n n.count === 0 && i();\n });\n }\n return !0;\n }\n throw new Error(\"DataCache: Attempting to release key that does not exist\");\n }\n}\nfunction is(a, e) {\n const [t, s, n, i] = a, [r, o, l, c] = e;\n return !(t >= l || n <= r || s >= c || i <= o);\n}\nclass mn {\n get levelCount() {\n return this._levels.length;\n }\n get maxLevel() {\n return this.levelCount - 1;\n }\n get minLevel() {\n const e = this._levels;\n for (let t = 0; t < e.length; t++)\n if (e[t] !== null)\n return t;\n return -1;\n }\n // prioritize user-set bounds over projection bounds if present\n get contentBounds() {\n return this._contentBounds ?? this.projection.getBounds();\n }\n get aspectRatio() {\n const { pixelWidth: e, pixelHeight: t } = this.getLevel(this.maxLevel);\n return e / t;\n }\n constructor() {\n this.flipY = !1, this.pixelOverlap = 0, this._contentBounds = null, this.projection = new re(\"none\"), this._levels = [];\n }\n // build the zoom levels\n setLevel(e, t = {}) {\n const s = this._levels;\n for (; s.length < e; )\n s.push(null);\n const {\n tileSplitX: n = 2,\n tileSplitY: i = 2\n } = t, {\n tilePixelWidth: r = 256,\n tilePixelHeight: o = 256,\n tileCountX: l = n ** e,\n tileCountY: c = i ** e,\n tileBounds: u = null\n } = t, {\n pixelWidth: h = r * l,\n pixelHeight: d = o * c\n } = t;\n s[e] = {\n // The pixel resolution of each tile.\n tilePixelWidth: r,\n tilePixelHeight: o,\n // The total pixel resolution of the final image at this level. These numbers\n // may not be a round multiple of the tile width.\n pixelWidth: h,\n pixelHeight: d,\n // Or the total number of tiles that can be loaded at this level.\n tileCountX: l,\n tileCountY: c,\n // The number of tiles that the tiles at this layer split in to\n tileSplitX: n,\n tileSplitY: i,\n // The bounds covered by the extent of the tiles at this loaded. The actual content covered by the overall tileset\n // may be a subset of this range (eg there may be unused space).\n tileBounds: u\n };\n }\n generateLevels(e, t, s, n = {}) {\n const {\n minLevel: i = 0,\n tilePixelWidth: r = 256,\n tilePixelHeight: o = 256\n } = n, l = e - 1, {\n pixelWidth: c = r * t * 2 ** l,\n pixelHeight: u = o * s * 2 ** l\n } = n;\n for (let h = i; h < e; h++) {\n const d = e - h - 1, m = Math.ceil(c * 2 ** -d), f = Math.ceil(u * 2 ** -d), p = Math.ceil(m / r), g = Math.ceil(f / o);\n this.setLevel(h, {\n tilePixelWidth: r,\n tilePixelHeight: o,\n pixelWidth: m,\n pixelHeight: f,\n tileCountX: p,\n tileCountY: g\n });\n }\n }\n getLevel(e) {\n return this._levels[e];\n }\n // bounds representing the contentful region of the image\n setContentBounds(e, t, s, n) {\n this._contentBounds = [e, t, s, n];\n }\n setProjection(e) {\n this.projection = e;\n }\n // query functions\n getTileAtPoint(e, t, s, n = !1) {\n const { flipY: i } = this, { tileCountX: r, tileCountY: o, tileBounds: l } = this.getLevel(s), c = 1 / r, u = 1 / o;\n if (n || ([e, t] = this.toNormalizedPoint(e, t)), l) {\n const m = this.toNormalizedRange(l);\n e = b.mapLinear(e, m[0], m[2], 0, 1), t = b.mapLinear(t, m[1], m[3], 0, 1);\n }\n const h = Math.floor(e / c);\n let d = Math.floor(t / u);\n return i && (d = o - 1 - d), [h, d];\n }\n getTilesInRange(e, t, s, n, i, r = !1) {\n const o = [e, t, s, n], l = this.getContentBounds(r);\n let c = this.getLevel(i).tileBounds;\n if (!is(o, l))\n return [0, 0, -1, -1];\n if (c && (r && (c = this.toNormalizedRange(c)), !is(o, l)))\n return [0, 0, -1, -1];\n const [u, h, d, m] = this.clampToContentBounds(o, r), f = this.getTileAtPoint(u, h, i, r), p = this.getTileAtPoint(d, m, i, r);\n this.flipY && ([f[1], p[1]] = [p[1], f[1]]);\n const { tileCountX: g, tileCountY: y } = this.getLevel(i), [x, S] = f, [T, M] = p;\n return T < 0 || M < 0 || x >= g || S >= y ? [0, 0, -1, -1] : [\n b.clamp(x, 0, g - 1),\n b.clamp(S, 0, y - 1),\n b.clamp(T, 0, g - 1),\n b.clamp(M, 0, y - 1)\n ];\n }\n getTileExists(e, t, s) {\n const [n, i, r, o] = this.contentBounds, [l, c, u, h] = this.getTileBounds(e, t, s);\n return !(l >= u || c >= h) && l <= r && c <= o && u >= n && h >= i;\n }\n getContentBounds(e = !1) {\n const { projection: t } = this, s = [...this.contentBounds];\n return e && (s[0] = t.convertLongitudeToNormalized(s[0]), s[1] = t.convertLatitudeToNormalized(s[1]), s[2] = t.convertLongitudeToNormalized(s[2]), s[3] = t.convertLatitudeToNormalized(s[3])), s;\n }\n // returns the UV range associated with the content in the given tile\n getTileContentUVBounds(e, t, s) {\n const [n, i, r, o] = this.getTileBounds(e, t, s, !0, !0), [l, c, u, h] = this.getTileBounds(e, t, s, !0, !1);\n return [\n b.mapLinear(n, l, u, 0, 1),\n b.mapLinear(i, c, h, 0, 1),\n b.mapLinear(r, l, u, 0, 1),\n b.mapLinear(o, c, h, 0, 1)\n ];\n }\n getTileBounds(e, t, s, n = !1, i = !0) {\n const { flipY: r, pixelOverlap: o, projection: l } = this, { tilePixelWidth: c, tilePixelHeight: u, pixelWidth: h, pixelHeight: d, tileBounds: m } = this.getLevel(s);\n let f = c * e - o, p = u * t - o, g = f + c + o * 2, y = p + u + o * 2;\n if (f = Math.max(f, 0), p = Math.max(p, 0), g = Math.min(g, h), y = Math.min(y, d), f = f / h, g = g / h, p = p / d, y = y / d, r) {\n const S = (y - p) / 2, M = 1 - (p + y) / 2;\n p = M - S, y = M + S;\n }\n let x = [f, p, g, y];\n if (m) {\n const S = this.toNormalizedRange(m);\n x[0] = b.mapLinear(x[0], 0, 1, S[0], S[2]), x[2] = b.mapLinear(x[2], 0, 1, S[0], S[2]), x[1] = b.mapLinear(x[1], 0, 1, S[1], S[3]), x[3] = b.mapLinear(x[3], 0, 1, S[1], S[3]);\n }\n return i && (x = this.clampToBounds(x, !0)), n || (x[0] = l.convertNormalizedToLongitude(x[0]), x[1] = l.convertNormalizedToLatitude(x[1]), x[2] = l.convertNormalizedToLongitude(x[2]), x[3] = l.convertNormalizedToLatitude(x[3])), x;\n }\n toNormalizedPoint(e, t) {\n return this.projection.toNormalizedPoint(e, t);\n }\n toNormalizedRange(e) {\n return this.projection.toNormalizedRange(e);\n }\n toCartographicPoint(e, t) {\n return this.projection.toCartographicPoint(e, t);\n }\n toCartographicRange(e) {\n return this.projection.toCartographicRange(e);\n }\n clampToContentBounds(e, t = !1) {\n const s = [...e], [n, i, r, o] = this.getContentBounds(t);\n return s[0] = b.clamp(s[0], n, r), s[1] = b.clamp(s[1], i, o), s[2] = b.clamp(s[2], n, r), s[3] = b.clamp(s[3], i, o), s;\n }\n clampToBounds(e, t = !1) {\n return this.projection.clampToBounds(e, t);\n }\n}\nclass Ue extends fn {\n constructor(e = {}) {\n super();\n const {\n fetchOptions: t = {}\n } = e;\n this.tiling = new mn(), this.fetchOptions = t, this.fetchData = (...s) => fetch(...s);\n }\n // async function for initializing the tiled image set\n init() {\n }\n // helper for processing the buffer into a texture\n async processBufferToTexture(e) {\n const t = new Blob([e]), s = await createImageBitmap(t, {\n premultiplyAlpha: \"none\",\n colorSpaceConversion: \"none\",\n imageOrientation: \"flipY\"\n }), n = new Hn(s);\n return n.generateMipmaps = !1, n.colorSpace = qt, n.needsUpdate = !0, n;\n }\n getMemoryUsage(e) {\n const { format: t, type: s, image: n, generateMipmaps: i } = e, { width: r, height: o } = n, l = qn.getByteLength(r, o, t, s);\n return i ? l * 4 / 3 : l;\n }\n // fetch the item with the given key fields\n fetchItem(e, t) {\n const s = {\n ...this.fetchOptions,\n signal: t\n }, n = this.getUrl(...e);\n return this.fetchData(n, s).then((i) => i.arrayBuffer()).then((i) => this.processBufferToTexture(i));\n }\n // dispose of the item that was fetched\n disposeItem(e) {\n e.dispose(), e.image instanceof ImageBitmap && e.image.close();\n }\n getUrl(...e) {\n }\n}\nclass Ne extends Ue {\n constructor(e = {}) {\n const {\n levels: t = 20,\n tileDimension: s = 256,\n projection: n = \"EPSG:3857\",\n url: i = null,\n ...r\n } = e;\n super(r), this.tileDimension = s, this.levels = t, this.projection = n, this.url = i;\n }\n getUrl(e, t, s) {\n return this.url.replace(/{\\s*z\\s*}/gi, s).replace(/{\\s*x\\s*}/gi, e).replace(/{\\s*(y|reverseY|-\\s*y)\\s*}/gi, t);\n }\n init() {\n const { tiling: e, tileDimension: t, levels: s, url: n, projection: i } = this;\n return e.flipY = !/{\\s*reverseY|-\\s*y\\s*}/g.test(n), e.setProjection(new re(i)), e.setContentBounds(...e.projection.getBounds()), Array.isArray(s) ? s.forEach((r, o) => {\n r !== null && e.setLevel(o, {\n tilePixelWidth: t,\n tilePixelHeight: t,\n ...r\n });\n }) : e.generateLevels(s, e.projection.tileCountX, e.projection.tileCountY, {\n tilePixelWidth: t,\n tilePixelHeight: t\n }), this.url = n, Promise.resolve();\n }\n}\nclass Xt extends Ue {\n constructor(e = {}) {\n const {\n url: t = null,\n ...s\n } = e;\n super(s), this.tileSets = null, this.extension = null, this.url = t;\n }\n getUrl(e, t, s) {\n const { url: n, extension: i, tileSets: r, tiling: o } = this;\n return new URL(`${parseInt(r[s - o.minLevel].href)}/${e}/${t}.${i}`, n).toString();\n }\n init() {\n const { url: e } = this;\n return this.fetchData(new URL(\"tilemapresource.xml\", e), this.fetchOptions).then((t) => t.text()).then((t) => {\n const { tiling: s } = this, n = new DOMParser().parseFromString(t, \"text/xml\"), i = n.querySelector(\"BoundingBox\"), r = n.querySelector(\"TileFormat\"), l = [...n.querySelector(\"TileSets\").querySelectorAll(\"TileSet\")].map((y) => ({\n href: parseInt(y.getAttribute(\"href\")),\n unitsPerPixel: parseFloat(y.getAttribute(\"units-per-pixel\")),\n order: parseInt(y.getAttribute(\"order\"))\n })).sort((y, x) => y.order - x.order), c = parseFloat(i.getAttribute(\"minx\")) * b.DEG2RAD, u = parseFloat(i.getAttribute(\"maxx\")) * b.DEG2RAD, h = parseFloat(i.getAttribute(\"miny\")) * b.DEG2RAD, d = parseFloat(i.getAttribute(\"maxy\")) * b.DEG2RAD, m = parseInt(r.getAttribute(\"width\")), f = parseInt(r.getAttribute(\"height\")), p = r.getAttribute(\"extension\"), g = n.querySelector(\"SRS\").textContent;\n this.extension = p, this.url = e, this.tileSets = l, s.setProjection(new re(g)), s.setContentBounds(c, h, u, d), l.forEach(({ order: y }) => {\n s.setLevel(y, {\n tileCountX: s.projection.tileCountX * 2 ** y,\n tilePixelWidth: m,\n tilePixelHeight: f\n });\n });\n });\n }\n}\nfunction Ci(a) {\n return /(:84|:crs84)$/i.test(a);\n}\nclass gn extends Ue {\n constructor(e = {}) {\n const {\n capabilities: t = null,\n layer: s = null,\n tileMatrixSet: n = null,\n style: i = null,\n url: r = null,\n dimensions: o = {},\n ...l\n } = e;\n super(l), this.capabilities = t, this.layer = s, this.tileMatrixSet = n, this.style = i, this.dimensions = o, this.url = r;\n }\n getUrl(e, t, s) {\n return this.url.replace(/{\\s*TileMatrix\\s*}/gi, s).replace(/{\\s*TileCol\\s*}/gi, e).replace(/{\\s*TileRow\\s*}/gi, t);\n }\n init() {\n const { tiling: e, dimensions: t, capabilities: s } = this;\n let { layer: n, tileMatrixSet: i, style: r, url: o } = this;\n n ? typeof n == \"string\" && (n = s.layers.find((u) => u.identifier === n)) : n = s.layers[0], i ? typeof i == \"string\" && (i = n.tileMatrixSets.find((u) => u.identifier === i)) : i = n.tileMatrixSets[0], r || (r = n.styles.find((u) => u.isDefault).identifier), o || (o = n.resourceUrls[0].template);\n const l = i.supportedCRS, c = l.includes(\"4326\") || Ci(l) ? \"EPSG:4326\" : \"EPSG:3857\";\n e.flipY = !0, e.setProjection(new re(c)), n.boundingBox !== null ? e.setContentBounds(...n.boundingBox.bounds) : e.setContentBounds(...e.projection.getBounds()), i.tileMatrices.forEach((u, h) => {\n const { tileWidth: d, tileHeight: m, matrixWidth: f, matrixHeight: p } = u;\n e.setLevel(h, {\n tilePixelWidth: d,\n tilePixelHeight: m,\n tileCountX: f || e.projection.tileCountX * 2 ** h,\n tileCountY: p || e.projection.tileCountY * 2 ** h,\n tileBounds: u.bounds\n });\n }), o = o.replace(/{\\s*TileMatrixSet\\s*}/g, i.identifier).replace(/{\\s*Style\\s*}/g, r);\n for (const u in t)\n o = o.replace(new RegExp(`{\\\\s*${u}\\\\s*}`), t[u]);\n return n.dimensions.forEach((u) => {\n o = o.replace(new RegExp(`{\\\\s*${u.identifier}\\\\s*}`), u.defaultValue);\n }), this.url = o, Promise.resolve();\n }\n}\nclass yn extends Ue {\n // TODO: layer and styles can be arrays, comma separated lists\n constructor(e = {}) {\n const {\n url: t = null,\n layer: s = null,\n styles: n = null,\n contentBoundingBox: i = null,\n version: r = \"1.3.0\",\n crs: o = \"EPSG:4326\",\n format: l = \"image/png\",\n transparent: c = !1,\n levels: u = 18,\n tileDimension: h = 256,\n ...d\n } = e;\n super(d), this.url = t, this.layer = s, this.crs = o, this.format = l, this.tileDimension = h, this.styles = n, this.version = r, this.levels = u, this.transparent = c, this.contentBoundingBox = i;\n }\n init() {\n const { tiling: e, levels: t, tileDimension: s, contentBoundingBox: n } = this;\n return e.setProjection(new re(this.crs)), e.flipY = !0, e.generateLevels(t, e.projection.tileCountX, e.projection.tileCountY, {\n tilePixelWidth: s,\n tilePixelHeight: s\n }), n !== null ? e.setContentBounds(...n) : e.setContentBounds(...e.projection.getBounds()), Promise.resolve();\n }\n // TODO: handle this in ProjectionScheme or TilingScheme? Or Loader?\n normalizedToMercatorX(e) {\n return b.mapLinear(e, 0, 1, -20037508342789244e-9, 20037508342789244e-9);\n }\n normalizedToMercatorY(e) {\n return b.mapLinear(e, 0, 1, -20037508342789244e-9, 20037508342789244e-9);\n }\n getUrl(e, t, s) {\n const {\n tiling: n,\n layer: i,\n crs: r,\n format: o,\n tileDimension: l,\n styles: c,\n version: u,\n transparent: h\n } = this, d = u === \"1.1.1\" ? \"SRS\" : \"CRS\";\n let m;\n if (r === \"EPSG:3857\") {\n const p = n.getTileBounds(e, t, s, !0, !1), g = this.normalizedToMercatorX(p[0]), y = this.normalizedToMercatorY(p[1]), x = this.normalizedToMercatorX(p[2]), S = this.normalizedToMercatorY(p[3]);\n m = [g, y, x, S];\n } else {\n const [p, g, y, x] = n.getTileBounds(e, t, s, !1, !1).map((S) => S * b.RAD2DEG);\n r === \"EPSG:4326\" ? u === \"1.1.1\" ? m = [p, g, y, x] : m = [g, p, x, y] : m = [p, g, y, x];\n }\n const f = new URLSearchParams({\n SERVICE: \"WMS\",\n REQUEST: \"GetMap\",\n VERSION: u,\n LAYERS: i,\n [d]: r,\n BBOX: m.join(\",\"),\n WIDTH: l,\n HEIGHT: l,\n FORMAT: o,\n TRANSPARENT: h ? \"TRUE\" : \"FALSE\"\n });\n return c != null && f.set(\"STYLES\", c), new URL(\"?\" + f.toString(), this.url).toString();\n }\n}\nclass to extends ut {\n constructor(e = {}) {\n const {\n levels: t,\n tileDimension: s,\n projection: n,\n url: i,\n ...r\n } = e;\n super(r), this.name = \"XYZ_TILES_PLUGIN\", this.imageSource = new Ne({ url: i, levels: t, tileDimension: s, projection: n });\n }\n}\nclass Ai extends ut {\n constructor(e = {}) {\n const { url: t, ...s } = e;\n super(s), this.name = \"TMS_TILES_PLUGIN\", this.imageSource = new Xt({ url: t });\n }\n}\nclass so extends ut {\n constructor(e = {}) {\n const {\n capabilities: t,\n layer: s,\n tileMatrixSet: n,\n style: i,\n dimensions: r,\n ...o\n } = e;\n super(o), this.name = \"WTMS_TILES_PLUGIN\", this.imageSource = new gn({\n capabilities: t,\n layer: s,\n tileMatrixSet: n,\n style: i,\n dimensions: r\n });\n }\n}\nclass no extends ut {\n constructor(e = {}) {\n const {\n url: t,\n layer: s,\n crs: n,\n format: i,\n tileDimension: r,\n styles: o,\n version: l,\n ...c\n } = e;\n super(c), this.name = \"WMS_TILES_PLUGIN\", this.imageSource = new yn({\n url: t,\n layer: s,\n crs: n,\n format: i,\n tileDimension: r,\n styles: o,\n version: l\n });\n }\n}\nconst rs = /* @__PURE__ */ new E(), ze = /* @__PURE__ */ new jt(), U = /* @__PURE__ */ new E(), oe = /* @__PURE__ */ new E();\nclass Ii extends Fn {\n constructor(e = Wn) {\n super(), this.manager = e, this.ellipsoid = new cn(), this.skirtLength = 1e3, this.smoothSkirtNormals = !0, this.generateNormals = !0, this.solid = !1, this.minLat = -Math.PI / 2, this.maxLat = Math.PI / 2, this.minLon = -Math.PI, this.maxLon = Math.PI;\n }\n parse(e) {\n const {\n ellipsoid: t,\n solid: s,\n skirtLength: n,\n smoothSkirtNormals: i,\n generateNormals: r,\n minLat: o,\n maxLat: l,\n minLon: c,\n maxLon: u\n } = this, {\n header: h,\n indices: d,\n vertexData: m,\n edgeIndices: f,\n extensions: p\n } = super.parse(e), g = new st(), y = new Ks(), x = new Be(g, y);\n x.position.set(...h.center);\n const S = \"octvertexnormals\" in p, T = S || r, M = m.u.length, _ = [], C = [], v = [], P = [];\n let R = 0, V = 0;\n for (let I = 0; I < M; I++)\n W(I, U), $(U.x, U.y, U.z, oe), C.push(U.x, U.y), _.push(...oe);\n for (let I = 0, A = d.length; I < A; I++)\n v.push(d[I]);\n if (T)\n if (S) {\n const I = p.octvertexnormals.normals;\n for (let A = 0, D = I.length; A < D; A++)\n P.push(I[A]);\n } else {\n const I = new st(), A = d.length > 21845 ? new Uint32Array(d) : new Uint16Array(d);\n I.setIndex(new J(A, 1, !1)), I.setAttribute(\"position\", new J(new Float32Array(_), 3, !1)), I.computeVertexNormals();\n const O = I.getAttribute(\"normal\").array;\n p.octvertexnormals = { normals: O };\n for (let L = 0, N = O.length; L < N; L++)\n P.push(O[L]);\n }\n if (g.addGroup(R, d.length, V), R += d.length, V++, s) {\n const I = _.length / 3;\n for (let A = 0; A < M; A++)\n W(A, U), $(U.x, U.y, U.z, oe, -n), C.push(U.x, U.y), _.push(...oe);\n for (let A = d.length - 1; A >= 0; A--)\n v.push(d[A] + I);\n if (T) {\n const A = p.octvertexnormals.normals;\n for (let D = 0, O = A.length; D < O; D++)\n P.push(-A[D]);\n }\n g.addGroup(R, d.length, V), R += d.length, V++;\n }\n if (n > 0) {\n const {\n westIndices: I,\n eastIndices: A,\n southIndices: D,\n northIndices: O\n } = f;\n let L;\n const N = H(I);\n L = _.length / 3, C.push(...N.uv), _.push(...N.positions);\n for (let B = 0, Z = N.indices.length; B < Z; B++)\n v.push(N.indices[B] + L);\n const Q = H(A);\n L = _.length / 3, C.push(...Q.uv), _.push(...Q.positions);\n for (let B = 0, Z = Q.indices.length; B < Z; B++)\n v.push(Q.indices[B] + L);\n const F = H(D);\n L = _.length / 3, C.push(...F.uv), _.push(...F.positions);\n for (let B = 0, Z = F.indices.length; B < Z; B++)\n v.push(F.indices[B] + L);\n const G = H(O);\n L = _.length / 3, C.push(...G.uv), _.push(...G.positions);\n for (let B = 0, Z = G.indices.length; B < Z; B++)\n v.push(G.indices[B] + L);\n T && (P.push(...N.normals), P.push(...Q.normals), P.push(...F.normals), P.push(...G.normals)), g.addGroup(R, d.length, V), R += d.length, V++;\n }\n for (let I = 0, A = _.length; I < A; I += 3)\n _[I + 0] -= h.center[0], _[I + 1] -= h.center[1], _[I + 2] -= h.center[2];\n const k = _.length / 3 > 65535 ? new Uint32Array(v) : new Uint16Array(v);\n if (g.setIndex(new J(k, 1, !1)), g.setAttribute(\"position\", new J(new Float32Array(_), 3, !1)), g.setAttribute(\"uv\", new J(new Float32Array(C), 2, !1)), T && g.setAttribute(\"normal\", new J(new Float32Array(P), 3, !1)), \"watermask\" in p) {\n const { mask: I, size: A } = p.watermask, D = new Uint8Array(2 * A * A);\n for (let L = 0, N = I.length; L < N; L++) {\n const Q = I[L] === 255 ? 0 : 255;\n D[2 * L + 0] = Q, D[2 * L + 1] = Q;\n }\n const O = new Wt(D, A, A, en, tn);\n O.flipY = !0, O.minFilter = jn, O.magFilter = sn, O.needsUpdate = !0, y.roughnessMap = O;\n }\n return x.userData.minHeight = h.minHeight, x.userData.maxHeight = h.maxHeight, \"metadata\" in p && (x.userData.metadata = p.metadata.json), x;\n function W(I, A) {\n return A.x = m.u[I], A.y = m.v[I], A.z = m.height[I], A;\n }\n function $(I, A, D, O, L = 0) {\n const N = b.lerp(h.minHeight, h.maxHeight, D), Q = b.lerp(c, u, I), F = b.lerp(o, l, A);\n return t.getCartographicToPosition(F, Q, N + L, O), O;\n }\n function H(I) {\n const A = [], D = [], O = [], L = [], N = [];\n for (let G = 0, B = I.length; G < B; G++)\n W(I[G], U), A.push(U.x, U.y), O.push(U.x, U.y), $(U.x, U.y, U.z, oe), D.push(...oe), $(U.x, U.y, U.z, oe, -n), L.push(...oe);\n const Q = I.length - 1;\n for (let G = 0; G < Q; G++) {\n const B = G, Z = G + 1, pe = G + I.length, dt = G + I.length + 1;\n N.push(B, pe, Z), N.push(Z, pe, dt);\n }\n let F = null;\n if (T) {\n const G = (D.length + L.length) / 3;\n if (i) {\n F = new Array(G * 3);\n const B = p.octvertexnormals.normals, Z = F.length / 2;\n for (let pe = 0, dt = G / 2; pe < dt; pe++) {\n const pt = I[pe], Te = 3 * pe, Jt = B[3 * pt + 0], Kt = B[3 * pt + 1], es = B[3 * pt + 2];\n F[Te + 0] = Jt, F[Te + 1] = Kt, F[Te + 2] = es, F[Z + Te + 0] = Jt, F[Z + Te + 1] = Kt, F[Z + Te + 2] = es;\n }\n } else {\n F = [], ze.a.fromArray(D, 0), ze.b.fromArray(L, 0), ze.c.fromArray(D, 3), ze.getNormal(rs);\n for (let B = 0; B < G; B++)\n F.push(...rs);\n }\n }\n return {\n uv: [...A, ...O],\n positions: [...D, ...L],\n indices: N,\n normals: F\n };\n }\n }\n}\nconst z = 0, ce = [\"a\", \"b\", \"c\"], w = /* @__PURE__ */ new Oe(), os = /* @__PURE__ */ new Oe(), as = /* @__PURE__ */ new Oe(), ls = /* @__PURE__ */ new Oe();\nclass xn {\n constructor() {\n this.attributeList = null, this.splitOperations = [], this.trianglePool = new vi();\n }\n forEachSplitPermutation(e) {\n const { splitOperations: t } = this, s = (n = 0) => {\n if (n >= t.length) {\n e();\n return;\n }\n t[n].keepPositive = !0, s(n + 1), t[n].keepPositive = !1, s(n + 1);\n };\n s();\n }\n // Takes an operation that returns a value for the given vertex passed to the callback. Triangles\n // are clipped along edges where the interpolated value is equal to 0. The polygons on the positive\n // side of the operation are kept if \"keepPositive\" is true.\n // callback( geometry, i0, i1, i2, barycoord );\n addSplitOperation(e, t = !0) {\n this.splitOperations.push({\n callback: e,\n keepPositive: t\n });\n }\n // Removes all split operations\n clearSplitOperations() {\n this.splitOperations.length = 0;\n }\n // clips an object hierarchy\n clipObject(e) {\n const t = e.clone(), s = [];\n return t.traverse((n) => {\n n.isMesh && (n.geometry = this.clip(n).geometry, (n.geometry.index ? n.geometry.index.count / 3 : n.attributes.position.count / 3) === 0 && s.push(n));\n }), s.forEach((n) => {\n n.removeFromParent();\n }), t;\n }\n // Returns a new mesh that has been clipped by the split operations. Range indicates the range of\n // elements to include when clipping.\n clip(e, t = null) {\n const s = this.getClippedData(e, t);\n return this.constructMesh(s.attributes, s.index, e);\n }\n // Appends the clip operation data to the given \"target\" object so multiple ranges can be appended.\n // The \"target\" object is returned with an \"index\" field, \"vertexIsClipped\" field, and series of arrays\n // in \"attributes\".\n // attributes - set of attribute arrays\n // index - triangle indices referencing vertices in attributes\n // vertexIsClipped - array indicating whether a vertex is on a clipped edge\n getClippedData(e, t = null, s = {}) {\n const { trianglePool: n, splitOperations: i, attributeList: r } = this, o = e.geometry, l = o.attributes.position, c = o.index;\n let u = 0;\n const h = {};\n s.index = s.index || [], s.vertexIsClipped = s.vertexIsClipped || [], s.attributes = s.attributes || {};\n for (const p in o.attributes) {\n if (r !== null) {\n if (r instanceof Function && !r(p))\n continue;\n if (Array.isArray(r) && !r.includes(p))\n continue;\n }\n s.attributes[p] = [];\n }\n let d = 0, m = c ? c.count : l.count;\n t !== null && (d = t.start, m = t.count);\n for (let p = d, g = d + m; p < g; p += 3) {\n let y = p + 0, x = p + 1, S = p + 2;\n c && (y = c.getX(y), x = c.getX(x), S = c.getX(S));\n const T = n.get();\n T.initFromIndices(y, x, S);\n let M = [T];\n for (let _ = 0; _ < i.length; _++) {\n const { keepPositive: C, callback: v } = i[_], P = [];\n for (let R = 0; R < M.length; R++) {\n const V = M[R], { indices: k, barycoord: W } = V;\n V.clipValues.a = v(o, k.a, k.b, k.c, W.a, e.matrixWorld), V.clipValues.b = v(o, k.a, k.b, k.c, W.b, e.matrixWorld), V.clipValues.c = v(o, k.a, k.b, k.c, W.c, e.matrixWorld), this.splitTriangle(V, !C, P);\n }\n M = P;\n }\n for (let _ = 0, C = M.length; _ < C; _++) {\n const v = M[_];\n f(v, o);\n }\n n.reset();\n }\n return s;\n function f(p, g) {\n for (let y = 0; y < 3; y++) {\n const x = p.getVertexHash(y, g);\n x in h || (h[x] = u, u++, p.getVertexData(y, g, s.attributes), s.vertexIsClipped.push(p.clipValues[ce[y]] === z));\n const S = h[x];\n s.index.push(S);\n }\n }\n }\n // Takes the set of resultant data and constructs a mesh\n constructMesh(e, t, s) {\n const n = s.geometry, i = new st(), r = e.position.length / 3 > 65535 ? new Uint32Array(t) : new Uint16Array(t);\n i.setIndex(new J(r, 1, !1));\n for (const l in e) {\n const c = n.getAttribute(l), u = new c.array.constructor(e[l]), h = new J(u, c.itemSize, c.normalized);\n h.gpuType = c.gpuType, i.setAttribute(l, h);\n }\n const o = new Be(i, s.material.clone());\n return o.position.copy(s.position), o.quaternion.copy(s.quaternion), o.scale.copy(s.scale), o;\n }\n // Splits the given triangle\n splitTriangle(e, t, s) {\n const { trianglePool: n } = this, i = [], r = [], o = [];\n for (let l = 0; l < 3; l++) {\n const c = ce[l], u = ce[(l + 1) % 3], h = e.clipValues[c], d = e.clipValues[u];\n (h < z != d < z || h === z) && (i.push(l), r.push([c, u]), h === d ? o.push(0) : o.push(b.mapLinear(z, h, d, 0, 1)));\n }\n if (i.length !== 2)\n Math.min(\n e.clipValues.a,\n e.clipValues.b,\n e.clipValues.c\n ) < z === t && s.push(e);\n else if (i.length === 2) {\n const l = n.get().initFromTriangle(e), c = n.get().initFromTriangle(e), u = n.get().initFromTriangle(e);\n (i[0] + 1) % 3 === i[1] ? (l.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), l.copyVertex(e, r[0][1], \"b\"), l.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"c\"), l.clipValues.a = z, l.clipValues.c = z, c.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), c.copyVertex(e, r[1][1], \"b\"), c.copyVertex(e, r[0][0], \"c\"), c.clipValues.a = z, u.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), u.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"b\"), u.copyVertex(e, r[1][1], \"c\"), u.clipValues.a = z, u.clipValues.b = z) : (l.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), l.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"b\"), l.copyVertex(e, r[0][0], \"c\"), l.clipValues.a = z, l.clipValues.b = z, c.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), c.copyVertex(e, r[0][1], \"b\"), c.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"c\"), c.clipValues.a = z, c.clipValues.c = z, u.copyVertex(e, r[0][1], \"a\"), u.copyVertex(e, r[1][0], \"b\"), u.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"c\"), u.clipValues.c = z);\n let d, m;\n d = Math.min(l.clipValues.a, l.clipValues.b, l.clipValues.c), m = d < z, m === t && s.push(l), d = Math.min(c.clipValues.a, c.clipValues.b, c.clipValues.c), m = d < z, m === t && s.push(c), d = Math.min(u.clipValues.a, u.clipValues.b, u.clipValues.c), m = d < z, m === t && s.push(u);\n }\n }\n}\nclass vi {\n constructor() {\n this.pool = [], this.index = 0;\n }\n get() {\n if (this.index >= this.pool.length) {\n const t = new Li();\n this.pool.push(t);\n }\n const e = this.pool[this.index];\n return this.index++, e;\n }\n reset() {\n this.index = 0;\n }\n}\nclass Li {\n constructor() {\n this.indices = {\n a: -1,\n b: -1,\n c: -1\n }, this.clipValues = {\n a: -1,\n b: -1,\n c: -1\n }, this.barycoord = new jt();\n }\n // returns a hash for the given [0, 2] index based on attributes of the referenced geometry\n getVertexHash(e, t) {\n const { barycoord: s, indices: n } = this, i = ce[e], r = s[i];\n if (r.x === 1)\n return n[ce[0]];\n if (r.y === 1)\n return n[ce[1]];\n if (r.z === 1)\n return n[ce[2]];\n {\n const { attributes: o } = t;\n let l = \"\";\n for (const c in o) {\n const u = o[c];\n switch (cs(u, n.a, n.b, n.c, r, w), (c === \"normal\" || c === \"tangent\" || c === \"bitangent\") && w.normalize(), u.itemSize) {\n case 4:\n l += we(w.x, w.y, w.z, w.w);\n break;\n case 3:\n l += we(w.x, w.y, w.z);\n break;\n case 2:\n l += we(w.x, w.y);\n break;\n case 1:\n l += we(w.x);\n break;\n }\n l += \"|\";\n }\n return l;\n }\n }\n // Accumulate the vertex data in the given attribute arrays\n getVertexData(e, t, s) {\n const { barycoord: n, indices: i } = this, r = ce[e], o = n[r], { attributes: l } = t;\n for (const c in l) {\n if (!s[c])\n continue;\n const u = l[c], h = s[c];\n switch (cs(u, i.a, i.b, i.c, o, w), (c === \"normal\" || c === \"tangent\" || c === \"bitangent\") && w.normalize(), u.itemSize) {\n case 4:\n h.push(w.x, w.y, w.z, w.w);\n break;\n case 3:\n h.push(w.x, w.y, w.z);\n break;\n case 2:\n h.push(w.x, w.y);\n break;\n case 1:\n h.push(w.x);\n break;\n }\n }\n }\n // Copy the indices from a target triangle\n initFromTriangle(e) {\n return this.initFromIndices(\n e.indices.a,\n e.indices.b,\n e.indices.c\n );\n }\n // Set the indices for the given\n initFromIndices(e, t, s) {\n return this.indices.a = e, this.indices.b = t, this.indices.c = s, this.clipValues.a = -1, this.clipValues.b = -1, this.clipValues.c = -1, this.barycoord.a.set(1, 0, 0), this.barycoord.b.set(0, 1, 0), this.barycoord.c.set(0, 0, 1), this;\n }\n // Lerp the given vertex along to the provided edge of the provided triangle\n lerpVertexFromEdge(e, t, s, n, i) {\n this.clipValues[i] = b.lerp(e.clipValues[t], e.clipValues[s], n), this.barycoord[i].lerpVectors(e.barycoord[t], e.barycoord[s], n);\n }\n // Copy a vertex from the provided triangle\n copyVertex(e, t, s) {\n this.clipValues[s] = e.clipValues[t], this.barycoord[s].copy(e.barycoord[t]);\n }\n}\nfunction cs(a, e, t, s, n, i) {\n switch (os.fromBufferAttribute(a, e), as.fromBufferAttribute(a, t), ls.fromBufferAttribute(a, s), i.set(0, 0, 0, 0).addScaledVector(os, n.x).addScaledVector(as, n.y).addScaledVector(ls, n.z), a.itemSize) {\n case 3:\n w.w = 0;\n break;\n case 2:\n w.w = 0, w.z = 0;\n break;\n case 1:\n w.w = 0, w.z = 0, w.y = 0;\n break;\n }\n return i;\n}\nfunction we(...a) {\n let s = \"\";\n for (let n = 0, i = a.length; n < i; n++)\n s += ~~(a[n] * 1e5 + 0.5), n !== i - 1 && (s += \"_\");\n return s;\n}\nconst us = {}, Ei = /* @__PURE__ */ new E(), yt = /* @__PURE__ */ new E(), xt = /* @__PURE__ */ new E(), wi = /* @__PURE__ */ new E(), Pi = /* @__PURE__ */ new E(), X = /* @__PURE__ */ new E(), be = /* @__PURE__ */ new E(), j = /* @__PURE__ */ new Y(), le = /* @__PURE__ */ new Y(), hs = /* @__PURE__ */ new Y();\nclass Ri extends xn {\n constructor() {\n super(), this.ellipsoid = new cn(), this.skirtLength = 1e3, this.smoothSkirtNormals = !0, this.solid = !1, this.minLat = -Math.PI / 2, this.maxLat = Math.PI / 2, this.minLon = -Math.PI, this.maxLon = Math.PI, this.attributeList = [\"position\", \"normal\", \"uv\"];\n }\n clipToQuadrant(e, t, s) {\n const { solid: n, skirtLength: i, ellipsoid: r, smoothSkirtNormals: o } = this;\n this.clearSplitOperations(), this.addSplitOperation(ds(\"x\"), !t), this.addSplitOperation(ds(\"y\"), !s);\n let l, c;\n const u = e.geometry.groups[0], h = this.getClippedData(e, u);\n if (this.adjustVertices(h, e.position, 0), n) {\n l = {\n index: h.index.slice().reverse(),\n attributes: {}\n };\n for (const M in h.attributes)\n l.attributes[M] = h.attributes[M].slice();\n const T = l.attributes.normal;\n if (T)\n for (let M = 0; M < T.length; M += 3)\n T[M + 0] *= -1, T[M + 1] *= -1, T[M + 2] *= -1;\n this.adjustVertices(l, e.position, -i);\n }\n if (i > 0) {\n c = {\n index: [],\n attributes: {\n position: [],\n normal: [],\n uv: []\n }\n };\n let T = 0;\n const M = {}, _ = (k, W, $) => {\n const H = we(...k, ...$, ...W);\n H in M || (M[H] = T, T++, c.attributes.position.push(...k), c.attributes.normal.push(...$), c.attributes.uv.push(...W)), c.index.push(M[H]);\n }, C = h.index, v = h.attributes.uv, P = h.attributes.position, R = h.attributes.normal, V = h.index.length / 3;\n for (let k = 0; k < V; k++) {\n const W = 3 * k;\n for (let $ = 0; $ < 3; $++) {\n const H = ($ + 1) % 3, I = C[W + $], A = C[W + H];\n if (j.fromArray(v, I * 2), le.fromArray(v, A * 2), j.x === le.x && (j.x === 0 || j.x === 0.5 || j.x === 1) || j.y === le.y && (j.y === 0 || j.y === 0.5 || j.y === 1)) {\n yt.fromArray(P, I * 3), xt.fromArray(P, A * 3);\n const D = yt, O = xt, L = wi.copy(yt), N = Pi.copy(xt);\n X.copy(L).add(e.position), r.getPositionToNormal(X, X), L.addScaledVector(X, -i), X.copy(N).add(e.position), r.getPositionToNormal(X, X), N.addScaledVector(X, -i), o && R ? (X.fromArray(R, I * 3), be.fromArray(R, A * 3)) : (X.subVectors(D, O), be.subVectors(D, L).cross(X).normalize(), X.copy(be)), _(O, le, be), _(D, j, X), _(L, j, X), _(O, le, be), _(L, j, X), _(N, le, be);\n }\n }\n }\n }\n const d = h.index.length, m = h;\n if (l) {\n const { index: T, attributes: M } = l, _ = m.attributes.position.length / 3;\n for (let C = 0, v = T.length; C < v; C++)\n m.index.push(T[C] + _);\n for (const C in h.attributes)\n m.attributes[C].push(...M[C]);\n }\n if (c) {\n const { index: T, attributes: M } = c, _ = m.attributes.position.length / 3;\n for (let C = 0, v = T.length; C < v; C++)\n m.index.push(T[C] + _);\n for (const C in h.attributes)\n m.attributes[C].push(...M[C]);\n }\n const f = t ? 0 : -0.5, p = s ? 0 : -0.5, g = m.attributes.uv;\n for (let T = 0, M = g.length; T < M; T += 2)\n g[T] = (g[T] + f) * 2, g[T + 1] = (g[T + 1] + p) * 2;\n const y = this.constructMesh(m.attributes, m.index, e);\n y.userData.minHeight = e.userData.minHeight, y.userData.maxHeight = e.userData.maxHeight;\n let x = 0, S = 0;\n return y.geometry.addGroup(S, d, x), S += d, x++, l && (y.geometry.addGroup(S, l.index.length, x), S += l.index.length, x++), c && (y.geometry.addGroup(S, c.index.length, x), S += c.index.length, x++), y;\n }\n adjustVertices(e, t, s) {\n const { ellipsoid: n, minLat: i, maxLat: r, minLon: o, maxLon: l } = this, { attributes: c, vertexIsClipped: u } = e, h = c.position, d = c.uv, m = h.length / 3;\n for (let f = 0; f < m; f++) {\n const p = j.fromArray(d, f * 2);\n u && u[f] && (Math.abs(p.x - 0.5) < 1e-10 && (p.x = 0.5), Math.abs(p.y - 0.5) < 1e-10 && (p.y = 0.5), j.toArray(d, f * 2));\n const g = b.lerp(i, r, p.y), y = b.lerp(o, l, p.x), x = Ei.fromArray(h, f * 3).add(t);\n n.getPositionToCartographic(x, us), n.getCartographicToPosition(g, y, us.height + s, x), x.sub(t), x.toArray(h, f * 3);\n }\n }\n}\nfunction ds(a) {\n return (e, t, s, n, i) => {\n const r = e.attributes.uv;\n return j.fromBufferAttribute(r, t), le.fromBufferAttribute(r, s), hs.fromBufferAttribute(r, n), j[a] * i.x + le[a] * i.y + hs[a] * i.z - 0.5;\n };\n}\nconst ps = Symbol(\"TILE_X\"), fs = Symbol(\"TILE_Y\"), Pe = Symbol(\"TILE_LEVEL\"), me = Symbol(\"TILE_AVAILABLE\"), He = 1e4, ms = /* @__PURE__ */ new E();\nfunction Di(a, e, t, s) {\n if (a && e < a.length) {\n const n = a[e];\n for (let i = 0, r = n.length; i < r; i++) {\n const { startX: o, startY: l, endX: c, endY: u } = n[i];\n if (t >= o && t <= c && s >= l && s <= u)\n return !0;\n }\n }\n return !1;\n}\nfunction Tn(a) {\n const { available: e = null, maxzoom: t = null } = a;\n return t === null ? e.length - 1 : t;\n}\nfunction Bi(a) {\n const { metadataAvailability: e = -1 } = a;\n return e;\n}\nfunction Tt(a, e) {\n const t = a[Pe], s = Bi(e), n = Tn(e);\n return t < n && s !== -1 && t % s === 0;\n}\nfunction Oi(a, e, t, s, n) {\n return n.tiles[0].replace(/{\\s*z\\s*}/g, t).replace(/{\\s*x\\s*}/g, a).replace(/{\\s*y\\s*}/g, e).replace(/{\\s*version\\s*}/g, s);\n}\nclass Ui {\n constructor(e = {}) {\n const {\n useRecommendedSettings: t = !0,\n skirtLength: s = null,\n smoothSkirtNormals: n = !0,\n generateNormals: i = !0,\n solid: r = !1\n } = e;\n this.name = \"QUANTIZED_MESH_PLUGIN\", this.priority = -1e3, this.tiles = null, this.layer = null, this.useRecommendedSettings = t, this.skirtLength = s, this.smoothSkirtNormals = n, this.solid = r, this.generateNormals = i, this.attribution = null, this.tiling = new mn(), this.projection = new re();\n }\n // Plugin function\n init(e) {\n e.fetchOptions.headers = e.fetchOptions.headers || {}, e.fetchOptions.headers.Accept = \"application/vnd.quantized-mesh,application/octet-stream;q=0.9\", this.useRecommendedSettings && (e.errorTarget = 2), this.tiles = e;\n }\n loadRootTileset() {\n const { tiles: e } = this;\n let t = new URL(\"layer.json\", new URL(e.rootURL, location.href));\n return e.invokeAllPlugins((s) => t = s.preprocessURL ? s.preprocessURL(t, null) : t), e.invokeOnePlugin((s) => s.fetchData && s.fetchData(t, this.tiles.fetchOptions)).then((s) => s.json()).then((s) => {\n this.layer = s;\n const {\n projection: n = \"EPSG:4326\",\n extensions: i = [],\n attribution: r = \"\",\n available: o = null\n } = s, {\n tiling: l,\n tiles: c,\n projection: u\n } = this;\n r && (this.attribution = {\n value: r,\n type: \"string\",\n collapsible: !0\n }), i.length > 0 && (c.fetchOptions.headers.Accept += `;extensions=${i.join(\"-\")}`), u.setScheme(n);\n const { tileCountX: h, tileCountY: d } = u;\n l.setProjection(u), l.generateLevels(Tn(s) + 1, h, d);\n const m = [];\n for (let g = 0; g < h; g++) {\n const y = this.createChild(0, g, 0, o);\n y && m.push(y);\n }\n const f = {\n asset: {\n version: \"1.1\"\n },\n geometricError: 1 / 0,\n root: {\n refine: \"REPLACE\",\n geometricError: 1 / 0,\n boundingVolume: {\n region: [...this.tiling.getContentBounds(), -He, He]\n },\n children: m,\n [me]: o,\n [Pe]: -1\n }\n };\n let p = c.rootURL;\n return c.invokeAllPlugins((g) => p = g.preprocessURL ? g.preprocessURL(p, null) : p), c.preprocessTileset(f, p), f;\n });\n }\n parseToMesh(e, t, s, n) {\n const {\n skirtLength: i,\n solid: r,\n smoothSkirtNormals: o,\n generateNormals: l,\n tiles: c\n } = this, u = c.ellipsoid;\n let h;\n if (s === \"quantized_tile_split\") {\n const p = new URL(n).searchParams, g = p.get(\"left\") === \"true\", y = p.get(\"bottom\") === \"true\", x = new Ri();\n x.ellipsoid.copy(u), x.solid = r, x.smoothSkirtNormals = o, x.skirtLength = i === null ? t.geometricError : i;\n const [S, T, M, _] = t.parent.boundingVolume.region;\n x.minLat = T, x.maxLat = _, x.minLon = S, x.maxLon = M, h = x.clipToQuadrant(t.parent.engineData.scene, g, y);\n } else if (s === \"terrain\") {\n const p = new Ii(c.manager);\n p.ellipsoid.copy(u), p.solid = r, p.smoothSkirtNormals = o, p.generateNormals = l, p.skirtLength = i === null ? t.geometricError : i;\n const [g, y, x, S] = t.boundingVolume.region;\n p.minLat = y, p.maxLat = S, p.minLon = g, p.maxLon = x, h = p.parse(e);\n } else\n return;\n const { minHeight: d, maxHeight: m, metadata: f } = h.userData;\n return t.boundingVolume.region[4] = d, t.boundingVolume.region[5] = m, t.engineData.boundingVolume.setRegionData(u, ...t.boundingVolume.region), f && (\"geometricerror\" in f && (t.geometricError = f.geometricerror), Tt(t, this.layer) && \"available\" in f && t.children.length === 0 && (t[me] = [\n ...new Array(t[Pe] + 1).fill(null),\n ...f.available\n ])), t.engineData.scene = h, this.expandChildren(t), h;\n }\n getAttributions(e) {\n this.attribution && e.push(this.attribution);\n }\n // Local functions\n createChild(e, t, s, n) {\n const { tiles: i, layer: r, tiling: o, projection: l } = this, c = i.ellipsoid, u = n === null && e === 0 || Di(n, e, t, s), h = Oi(t, s, e, 1, r), d = [...o.getTileBounds(t, s, e), -He, He], [\n /* west */\n ,\n m,\n /* east */\n ,\n f,\n /* minHeight */\n ,\n p\n ] = d, g = m > 0 != f > 0 ? 0 : Math.min(Math.abs(m), Math.abs(f));\n c.getCartographicToPosition(g, 0, p, ms), ms.z = 0;\n const y = l.tileCountX, T = Math.max(...c.radius) * 2 * Math.PI * 0.25 / (65 * y) / 2 ** e, M = {\n [me]: null,\n [Pe]: e,\n [ps]: t,\n [fs]: s,\n refine: \"REPLACE\",\n geometricError: T,\n boundingVolume: { region: d },\n content: u ? { uri: h } : null,\n children: []\n };\n return Tt(M, r) || (M[me] = n), M;\n }\n expandChildren(e) {\n const t = e[Pe], s = e[ps], n = e[fs], i = e[me];\n if (t >= this.tiling.maxLevel)\n return;\n let r = !1;\n for (let o = 0; o < 2; o++)\n for (let l = 0; l < 2; l++) {\n const c = this.createChild(t + 1, 2 * s + o, 2 * n + l, i);\n c.content !== null ? (e.children.push(c), r = !0) : (c.content = { uri: `tile.quantized_tile_split?bottom=${l === 0}&left=${o === 0}` }, c.internal = { isVirtual: !0 }, e.internal.virtualChildCount++, e.children.push(c));\n }\n r || (e.children.length -= e.internal.virtualChildCount, e.internal.virtualChildCount = 0);\n }\n fetchData(e, t) {\n if (/quantized_tile_split/.test(e))\n return new ArrayBuffer();\n }\n disposeTile(e) {\n const { tiles: t, layer: s } = this;\n if (Tt(e, s) && (e[me] = null), me in e) {\n const { virtualChildCount: n } = e.internal, i = e.children.length, r = i - n;\n for (let o = r; o < i; o++)\n t.processNodeQueue.remove(e.children[o]);\n e.children.length -= n, e.internal.virtualChildCount = 0;\n }\n }\n}\nlet io = class extends kn {\n constructor(e = {}) {\n super({\n assetTypeHandler: (t, s, n) => {\n t === \"TERRAIN\" && s.getPluginByName(\"QUANTIZED_MESH_PLUGIN\") === null ? (console.warn(\n 'CesiumIonAuthPlugin: CesiumIonAuthPlugin plugin auto-registration has been deprecated. Please implement a custom \"assetTypeHandler\" for \"TERRAIN\" using \"QuantizedMeshPlugin\", instead.'\n ), s.registerPlugin(new Ui({\n useRecommendedSettings: this.useRecommendedSettings\n }))) : t === \"IMAGERY\" && s.getPluginByName(\"TMS_TILES_PLUGIN\") === null ? (console.warn(\n 'CesiumIonAuthPlugin: CesiumIonAuthPlugin plugin auto-registration has been deprecated. Please implement a custom \"assetTypeHandler\" for \"IMAGERY\" using \"TMSTilesPlugin\", instead.'\n ), s.registerPlugin(new Ai({\n useRecommendedSettings: this.useRecommendedSettings,\n shape: \"ellipsoid\"\n }))) : console.warn(`CesiumIonAuthPlugin: Cesium Ion asset type \"${t}\" unhandled.`);\n },\n ...e\n }), e.__suppress_warning__ && console.warn(\n 'CesiumIonAuthPlugin: Plugin has been moved to \"3d-tiles-renderer/core/plugins\".'\n );\n }\n};\nconst bt = /* @__PURE__ */ new K();\nclass oo {\n constructor() {\n this.name = \"UPDATE_ON_CHANGE_PLUGIN\", this.tiles = null, this.needsUpdate = !1, this.cameraMatrices = /* @__PURE__ */ new Map();\n }\n init(e) {\n this.tiles = e, this._needsUpdateCallback = () => {\n this.needsUpdate = !0;\n }, this._onCameraAdd = ({ camera: t }) => {\n this.needsUpdate = !0, this.cameraMatrices.set(t, new K());\n }, this._onCameraDelete = ({ camera: t }) => {\n this.needsUpdate = !0, this.cameraMatrices.delete(t);\n }, e.addEventListener(\"needs-update\", this._needsUpdateCallback), e.addEventListener(\"add-camera\", this._onCameraAdd), e.addEventListener(\"delete-camera\", this._onCameraDelete), e.addEventListener(\"camera-resolution-change\", this._needsUpdateCallback), e.cameras.forEach((t) => {\n this._onCameraAdd({ camera: t });\n });\n }\n doTilesNeedUpdate() {\n const e = this.tiles;\n let t = !1;\n this.cameraMatrices.forEach((n, i) => {\n bt.copy(e.group.matrixWorld).premultiply(i.matrixWorldInverse).premultiply(i.projectionMatrixInverse), t = t || !bt.equals(n), n.copy(bt);\n });\n const s = this.needsUpdate;\n return this.needsUpdate = !1, s || t;\n }\n preprocessNode() {\n this.needsUpdate = !0;\n }\n dispose() {\n const e = this.tiles;\n e.removeEventListener(\"camera-resolution-change\", this._needsUpdateCallback), e.removeEventListener(\"needs-update\", this._needsUpdateCallback), e.removeEventListener(\"add-camera\", this._onCameraAdd), e.removeEventListener(\"delete-camera\", this._onCameraDelete);\n }\n}\nconst gs = /* @__PURE__ */ new E();\nfunction Ie(a, e) {\n if (a.isInterleavedBufferAttribute || a.array instanceof e)\n return a;\n const s = e === Int8Array || e === Int16Array || e === Int32Array ? -1 : 0, n = new e(a.count * a.itemSize), i = new J(n, a.itemSize, !0), r = a.itemSize, o = a.count;\n for (let l = 0; l < o; l++)\n for (let c = 0; c < r; c++) {\n const u = b.clamp(a.getComponent(l, c), s, 1);\n i.setComponent(l, c, u);\n }\n return i;\n}\nfunction Ni(a, e = Int16Array) {\n const t = a.geometry, s = t.attributes, n = s.position;\n if (n.isInterleavedBufferAttribute || n.array instanceof e)\n return n;\n const i = new e(n.count * n.itemSize), r = new J(i, n.itemSize, !1), o = n.itemSize, l = n.count;\n t.computeBoundingBox();\n const c = t.boundingBox, { min: u, max: h } = c, d = 2 ** (8 * e.BYTES_PER_ELEMENT - 1) - 1, m = -d;\n for (let f = 0; f < l; f++)\n for (let p = 0; p < o; p++) {\n const g = p === 0 ? \"x\" : p === 1 ? \"y\" : \"z\", y = u[g], x = h[g], S = b.mapLinear(\n n.getComponent(f, p),\n y,\n x,\n m,\n d\n );\n r.setComponent(f, p, S);\n }\n c.getCenter(gs).multiply(a.scale).applyQuaternion(a.quaternion), a.position.add(gs), a.scale.x *= 0.5 * (h.x - u.x) / d, a.scale.y *= 0.5 * (h.y - u.y) / d, a.scale.z *= 0.5 * (h.z - u.z) / d, s.position = r, a.geometry.boundingBox = null, a.geometry.boundingSphere = null, a.updateMatrixWorld();\n}\nclass ao {\n constructor(e) {\n this._options = {\n // whether to generate normals if they don't already exist.\n generateNormals: !1,\n // whether to disable use of mipmaps since they are typically not necessary\n // with something like 3d tiles.\n disableMipmaps: !0,\n // whether to compress certain attributes\n compressIndex: !0,\n compressNormals: !1,\n compressUvs: !1,\n compressPosition: !1,\n // the TypedArray type to use when compressing the attributes\n uvType: Int8Array,\n normalType: Int8Array,\n positionType: Int16Array,\n ...e\n }, this.name = \"TILES_COMPRESSION_PLUGIN\", this.priority = -100;\n }\n processTileModel(e, t) {\n const {\n generateNormals: s,\n disableMipmaps: n,\n compressIndex: i,\n compressUvs: r,\n compressNormals: o,\n compressPosition: l,\n uvType: c,\n normalType: u,\n positionType: h\n } = this._options;\n e.traverse((d) => {\n if (d.material && n) {\n const m = d.material;\n for (const f in m) {\n const p = m[f];\n p && p.isTexture && p.generateMipmaps && (p.generateMipmaps = !1, p.minFilter = sn);\n }\n }\n if (d.geometry) {\n const m = d.geometry, f = m.attributes;\n if (r) {\n const { uv: p, uv1: g, uv2: y, uv3: x } = f;\n p && (f.uv = Ie(p, c)), g && (f.uv1 = Ie(g, c)), y && (f.uv2 = Ie(y, c)), x && (f.uv3 = Ie(x, c));\n }\n if (s && !f.normals && m.computeVertexNormals(), o && f.normals && (f.normals = Ie(f.normals, u)), l && Ni(d, h), i && m.index) {\n const p = f.position.count, g = m.index, y = p > 65535 ? Uint32Array : p > 255 ? Uint16Array : Uint8Array;\n if (!(g.array instanceof y)) {\n const x = new y(m.index.count);\n x.set(g.array);\n const S = new J(x, 1);\n m.setIndex(S);\n }\n }\n }\n });\n }\n}\nfunction q(a, e, t) {\n return a && e in a ? a[e] : t;\n}\nfunction bn(a) {\n return a !== \"BOOLEAN\" && a !== \"STRING\" && a !== \"ENUM\";\n}\nfunction Vi(a) {\n return /^FLOAT/.test(a);\n}\nfunction Ve(a) {\n return /^VEC/.test(a);\n}\nfunction Fe(a) {\n return /^MAT/.test(a);\n}\nfunction _n(a, e, t, s = null) {\n return Fe(t) || Ve(t) ? s.fromArray(a, e) : a[e];\n}\nfunction Vt(a) {\n const { type: e, componentType: t } = a;\n switch (e) {\n case \"SCALAR\":\n return t === \"INT64\" ? 0n : 0;\n case \"VEC2\":\n return new Y();\n case \"VEC3\":\n return new E();\n case \"VEC4\":\n return new Oe();\n case \"MAT2\":\n return new Xn();\n case \"MAT3\":\n return new Yn();\n case \"MAT4\":\n return new K();\n case \"BOOLEAN\":\n return !1;\n case \"STRING\":\n return \"\";\n // the final value for enums is a string but are represented as integers\n // during intermediate steps\n case \"ENUM\":\n return 0;\n }\n}\nfunction ys(a, e) {\n if (e == null)\n return !1;\n switch (a) {\n case \"SCALAR\":\n return typeof e == \"number\" || typeof e == \"bigint\";\n case \"VEC2\":\n return e.isVector2;\n case \"VEC3\":\n return e.isVector3;\n case \"VEC4\":\n return e.isVector4;\n case \"MAT2\":\n return e.isMatrix2;\n case \"MAT3\":\n return e.isMatrix3;\n case \"MAT4\":\n return e.isMatrix4;\n case \"BOOLEAN\":\n return typeof e == \"boolean\";\n case \"STRING\":\n return typeof e == \"string\";\n case \"ENUM\":\n return typeof e == \"number\" || typeof e == \"bigint\";\n }\n throw new Error(\"ClassProperty: invalid type.\");\n}\nfunction De(a, e = null) {\n switch (a) {\n case \"INT8\":\n return Int8Array;\n case \"INT16\":\n return Int16Array;\n case \"INT32\":\n return Int32Array;\n case \"INT64\":\n return BigInt64Array;\n case \"UINT8\":\n return Uint8Array;\n case \"UINT16\":\n return Uint16Array;\n case \"UINT32\":\n return Uint32Array;\n case \"UINT64\":\n return BigUint64Array;\n case \"FLOAT32\":\n return Float32Array;\n case \"FLOAT64\":\n return Float64Array;\n }\n switch (e) {\n case \"BOOLEAN\":\n return Uint8Array;\n case \"STRING\":\n return Uint8Array;\n }\n throw new Error(\"ClassProperty: invalid type.\");\n}\nfunction Fi(a, e = null) {\n if (a.array) {\n e = e && Array.isArray(e) ? e : [], e.length = a.count;\n for (let s = 0, n = e.length; s < n; s++)\n e[s] = nt(a, e[s]);\n } else\n e = nt(a, e);\n return e;\n}\nfunction nt(a, e = null) {\n const t = a.default, s = a.type;\n if (e = e || Vt(a), t === null) {\n switch (s) {\n case \"SCALAR\":\n return 0;\n case \"VEC2\":\n return e.set(0, 0);\n case \"VEC3\":\n return e.set(0, 0, 0);\n case \"VEC4\":\n return e.set(0, 0, 0, 0);\n case \"MAT2\":\n return e.identity();\n case \"MAT3\":\n return e.identity();\n case \"MAT4\":\n return e.identity();\n case \"BOOLEAN\":\n return !1;\n case \"STRING\":\n return \"\";\n case \"ENUM\":\n return \"\";\n }\n throw new Error(\"ClassProperty: invalid type.\");\n } else if (Fe(s))\n e.fromArray(t);\n else if (Ve(s))\n e.fromArray(t);\n else\n return t;\n}\nfunction ki(a, e) {\n if (a.noData === null)\n return e;\n const t = a.noData, s = a.type;\n if (Array.isArray(e))\n for (let r = 0, o = e.length; r < o; r++)\n e[r] = n(e[r]);\n else\n e = n(e);\n return e;\n function n(r) {\n return i(r) && (r = nt(a, r)), r;\n }\n function i(r) {\n if (Fe(s)) {\n const o = r.elements;\n for (let l = 0, c = t.length; l < c; l++)\n if (t[l] !== o[l])\n return !1;\n return !0;\n } else if (Ve(s)) {\n for (let o = 0, l = t.length; o < l; o++)\n if (t[o] !== r.getComponent(o))\n return !1;\n return !0;\n } else\n return t === r;\n }\n}\nfunction Gi(a, e) {\n switch (a) {\n case \"INT8\":\n return Math.max(e / 127, -1);\n case \"INT16\":\n return Math.max(e, 32767, -1);\n case \"INT32\":\n return Math.max(e / 2147483647, -1);\n case \"INT64\":\n return Math.max(Number(e) / 9223372036854776e3, -1);\n // eslint-disable-line no-loss-of-precision\n case \"UINT8\":\n return e / 255;\n case \"UINT16\":\n return e / 65535;\n case \"UINT32\":\n return e / 4294967295;\n case \"UINT64\":\n return Number(e) / 18446744073709552e3;\n }\n}\nfunction zi(a, e) {\n const {\n type: t,\n componentType: s,\n scale: n,\n offset: i,\n normalized: r\n } = a;\n if (Array.isArray(e))\n for (let h = 0, d = e.length; h < d; h++)\n e[h] = o(e[h]);\n else\n e = o(e);\n return e;\n function o(h) {\n return Fe(t) ? h = c(h) : Ve(t) ? h = l(h) : h = u(h), h;\n }\n function l(h) {\n return h.x = u(h.x), h.y = u(h.y), \"z\" in h && (h.z = u(h.z)), \"w\" in h && (h.w = u(h.w)), h;\n }\n function c(h) {\n const d = h.elements;\n for (let m = 0, f = d.length; m < f; m++)\n d[m] = u(d[m]);\n return h;\n }\n function u(h) {\n return r && (h = Gi(s, h)), (r || Vi(s)) && (h = h * n + i), h;\n }\n}\nfunction $t(a, e, t = null) {\n if (a.array) {\n Array.isArray(e) || (e = new Array(a.count || 0)), e.length = t !== null ? t : a.count;\n for (let s = 0, n = e.length; s < n; s++)\n ys(a.type, e[s]) || (e[s] = Vt(a));\n } else\n ys(a.type, e) || (e = Vt(a));\n return e;\n}\nfunction it(a, e) {\n for (const t in e)\n t in a || delete e[t];\n for (const t in a) {\n const s = a[t];\n e[t] = $t(s, e[t]);\n }\n}\nfunction Hi(a) {\n switch (a) {\n case \"ENUM\":\n return 1;\n case \"SCALAR\":\n return 1;\n case \"VEC2\":\n return 2;\n case \"VEC3\":\n return 3;\n case \"VEC4\":\n return 4;\n case \"MAT2\":\n return 4;\n case \"MAT3\":\n return 9;\n case \"MAT4\":\n return 16;\n // unused\n case \"BOOLEAN\":\n return -1;\n case \"STRING\":\n return -1;\n default:\n return -1;\n }\n}\nclass ht {\n constructor(e, t, s = null) {\n this.name = t.name || null, this.description = t.description || null, this.type = t.type, this.componentType = t.componentType || null, this.enumType = t.enumType || null, this.array = t.array || !1, this.count = t.count || 0, this.normalized = t.normalized || !1, this.offset = t.offset || 0, this.scale = q(t, \"scale\", 1), this.max = q(t, \"max\", 1 / 0), this.min = q(t, \"min\", -1 / 0), this.required = t.required || !1, this.noData = q(t, \"noData\", null), this.default = q(t, \"default\", null), this.semantic = q(t, \"semantic\", null), this.enumSet = null, this.accessorProperty = s, s && (this.offset = q(s, \"offset\", this.offset), this.scale = q(s, \"scale\", this.scale), this.max = q(s, \"max\", this.max), this.min = q(s, \"min\", this.min)), t.type === \"ENUM\" && (this.enumSet = e[this.enumType], this.componentType === null && (this.componentType = q(this.enumSet, \"valueType\", \"UINT16\")));\n }\n // shape the given target to match the data type of the property\n // enums are set to their integer value\n shapeToProperty(e, t = null) {\n return $t(this, e, t);\n }\n // resolve the given object to the default value for the property for a single element\n // enums are set to a default string\n resolveDefaultElement(e) {\n return nt(this, e);\n }\n // resolve the target to the default value for the property for every element if it's an array\n // enums are set to a default string\n resolveDefault(e) {\n return Fi(this, e);\n }\n // converts any instances of no data to the default value\n resolveNoData(e) {\n return ki(this, e);\n }\n // converts enums integers in the given target to strings\n resolveEnumsToStrings(e) {\n const t = this.enumSet;\n if (this.type === \"ENUM\")\n if (Array.isArray(e))\n for (let n = 0, i = e.length; n < i; n++)\n e[n] = s(e[n]);\n else\n e = s(e);\n return e;\n function s(n) {\n const i = t.values.find((r) => r.value === n);\n return i === null ? \"\" : i.name;\n }\n }\n // apply scales\n adjustValueScaleOffset(e) {\n return bn(this.type) ? zi(this, e) : e;\n }\n}\nclass Qt {\n constructor(e, t = {}, s = {}, n = null) {\n this.definition = e, this.class = t[e.class], this.className = e.class, this.enums = s, this.data = n, this.name = \"name\" in e ? e.name : null, this.properties = null;\n }\n getPropertyNames() {\n return Object.keys(this.class.properties);\n }\n includesData(e) {\n return !!this.definition.properties[e];\n }\n dispose() {\n }\n _initProperties(e = ht) {\n const t = {};\n for (const s in this.class.properties)\n t[s] = new e(this.enums, this.class.properties[s], this.definition.properties[s]);\n this.properties = t;\n }\n}\nclass qi extends ht {\n constructor(e, t, s = null) {\n super(e, t, s), this.attribute = (s == null ? void 0 : s.attribute) ?? null;\n }\n}\nclass Wi extends Qt {\n constructor(...e) {\n super(...e), this.isPropertyAttributeAccessor = !0, this._initProperties(qi);\n }\n getData(e, t, s = {}) {\n const n = this.properties;\n it(n, s);\n for (const i in n)\n s[i] = this.getPropertyValue(i, e, t, s[i]);\n return s;\n }\n getPropertyValue(e, t, s, n = null) {\n if (t >= this.count)\n throw new Error(\"PropertyAttributeAccessor: Requested index is outside the range of the buffer.\");\n const i = this.properties[e], r = i.type;\n if (i) {\n if (!this.definition.properties[e])\n return i.resolveDefault(n);\n } else throw new Error(\"PropertyAttributeAccessor: Requested class property does not exist.\");\n n = i.shapeToProperty(n);\n const o = s.getAttribute(i.attribute.toLowerCase());\n if (Fe(r)) {\n const l = n.elements;\n for (let c = 0, u = l.length; c < u; c < u)\n l[c] = o.getComponent(t, c);\n } else if (Ve(r))\n n.fromBufferAttribute(o, t);\n else if (r === \"SCALAR\" || r === \"ENUM\")\n n = o.getX(t);\n else\n throw new Error(\"StructuredMetadata.PropertyAttributeAccessor: BOOLEAN and STRING types are not supported by property attributes.\");\n return n = i.adjustValueScaleOffset(n), n = i.resolveEnumsToStrings(n), n = i.resolveNoData(n), n;\n }\n}\nclass ji extends ht {\n constructor(e, t, s = null) {\n super(e, t, s), this.values = (s == null ? void 0 : s.values) ?? null, this.valueLength = Hi(this.type), this.arrayOffsets = q(s, \"arrayOffsets\", null), this.stringOffsets = q(s, \"stringOffsets\", null), this.arrayOffsetType = q(s, \"arrayOffsetType\", \"UINT32\"), this.stringOffsetType = q(s, \"stringOffsetType\", \"UINT32\");\n }\n // returns the necessary array length based on the array offsets if present\n getArrayLengthFromId(e, t) {\n let s = this.count;\n if (this.arrayOffsets !== null) {\n const { arrayOffsets: n, arrayOffsetType: i } = this, r = De(i), o = new r(e[n]);\n s = o[t + 1] - o[t];\n }\n return s;\n }\n // returns the index offset into the data buffer for the given id based on the\n // the array offsets if present\n getIndexOffsetFromId(e, t) {\n let s = t;\n if (this.arrayOffsets) {\n const { arrayOffsets: n, arrayOffsetType: i } = this, r = De(i);\n s = new r(e[n])[s];\n } else this.array && (s *= this.count);\n return s;\n }\n}\nclass Yi extends Qt {\n constructor(...e) {\n super(...e), this.isPropertyTableAccessor = !0, this.count = this.definition.count, this._initProperties(ji);\n }\n getData(e, t = {}) {\n const s = this.properties;\n it(s, t);\n for (const n in s)\n t[n] = this.getPropertyValue(n, e, t[n]);\n return t;\n }\n // reads an individual element\n _readValueAtIndex(e, t, s, n = null) {\n const i = this.properties[e], { componentType: r, type: o } = i, l = this.data, c = l[i.values], u = De(r, o), h = new u(c), d = i.getIndexOffsetFromId(l, t);\n if (bn(o) || o === \"ENUM\")\n return _n(h, (d + s) * i.valueLength, o, n);\n if (o === \"STRING\") {\n let m = d + s, f = 0;\n if (i.stringOffsets !== null) {\n const { stringOffsets: g, stringOffsetType: y } = i, x = De(y), S = new x(l[g]);\n f = S[m + 1] - S[m], m = S[m];\n }\n const p = new Uint8Array(h.buffer, m, f);\n n = new TextDecoder().decode(p);\n } else if (o === \"BOOLEAN\") {\n const m = d + s, f = Math.floor(m / 8), p = m % 8;\n n = (h[f] >> p & 1) === 1;\n }\n return n;\n }\n // Reads the data for the given table index\n getPropertyValue(e, t, s = null) {\n if (t >= this.count)\n throw new Error(\"PropertyTableAccessor: Requested index is outside the range of the table.\");\n const n = this.properties[e];\n if (n) {\n if (!this.definition.properties[e])\n return n.resolveDefault(s);\n } else throw new Error(\"PropertyTableAccessor: Requested property does not exist.\");\n const i = n.array, r = this.data, o = n.getArrayLengthFromId(r, t);\n if (s = n.shapeToProperty(s, o), i)\n for (let l = 0, c = s.length; l < c; l++)\n s[l] = this._readValueAtIndex(e, t, l, s[l]);\n else\n s = this._readValueAtIndex(e, t, 0, s);\n return s = n.adjustValueScaleOffset(s), s = n.resolveEnumsToStrings(s), s = n.resolveNoData(s), s;\n }\n}\nconst ve = /* @__PURE__ */ new ei();\nclass xs {\n constructor() {\n this._renderer = new $n(), this._target = new ts(1, 1), this._texTarget = new ts(), this._quad = new un(new Qn({\n blending: Kn,\n blendDst: Jn,\n blendSrc: Zn,\n uniforms: {\n map: { value: null },\n pixel: { value: new Y() }\n },\n vertexShader: (\n /* glsl */\n `\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}\n\t\t\t`\n ),\n fragmentShader: (\n /* glsl */\n `\n\t\t\t\tuniform sampler2D map;\n\t\t\t\tuniform ivec2 pixel;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_FragColor = texelFetch( map, pixel, 0 );\n\n\t\t\t\t}\n\t\t\t`\n )\n }));\n }\n // increases the width of the target render target to support more data\n increaseSizeTo(e) {\n this._target.setSize(Math.max(this._target.width, e), 1);\n }\n // read data from the rendered texture asynchronously\n readDataAsync(e) {\n const { _renderer: t, _target: s } = this;\n return t.readRenderTargetPixelsAsync(s, 0, 0, e.length / 4, 1, e);\n }\n // read data from the rendered texture\n readData(e) {\n const { _renderer: t, _target: s } = this;\n t.readRenderTargetPixels(s, 0, 0, e.length / 4, 1, e);\n }\n // render a single pixel from the source at the destination point on the render target\n // takes the texture, pixel to read from, and pixel to render in to\n renderPixelToTarget(e, t, s) {\n const { _renderer: n, _target: i } = this;\n ve.min.copy(t), ve.max.copy(t), ve.max.x += 1, ve.max.y += 1, n.initRenderTarget(i), n.copyTextureToTexture(e, i.texture, ve, s, 0);\n }\n}\nconst he = /* @__PURE__ */ new class {\n constructor() {\n let a = null;\n Object.getOwnPropertyNames(xs.prototype).forEach((e) => {\n e !== \"constructor\" && (this[e] = (...t) => (a = a || new xs(), a[e](...t)));\n });\n }\n}(), Ts = /* @__PURE__ */ new Y(), bs = /* @__PURE__ */ new Y(), _s = /* @__PURE__ */ new Y();\nfunction Xi(a, e) {\n return e === 0 ? a.getAttribute(\"uv\") : a.getAttribute(`uv${e}`);\n}\nfunction Sn(a, e, t = new Array(3)) {\n let s = 3 * e, n = 3 * e + 1, i = 3 * e + 2;\n return a.index && (s = a.index.getX(s), n = a.index.getX(n), i = a.index.getX(i)), t[0] = s, t[1] = n, t[2] = i, t;\n}\nfunction Mn(a, e, t, s, n) {\n const [i, r, o] = s, l = Xi(a, e);\n Ts.fromBufferAttribute(l, i), bs.fromBufferAttribute(l, r), _s.fromBufferAttribute(l, o), n.set(0, 0, 0).addScaledVector(Ts, t.x).addScaledVector(bs, t.y).addScaledVector(_s, t.z);\n}\nfunction Cn(a, e, t, s) {\n const n = a.x - Math.floor(a.x), i = a.y - Math.floor(a.y), r = Math.floor(n * e % e), o = Math.floor(i * t % t);\n return s.set(r, o), s;\n}\nconst Ss = /* @__PURE__ */ new Y(), Ms = /* @__PURE__ */ new Y(), Cs = /* @__PURE__ */ new Y();\nclass $i extends ht {\n constructor(e, t, s = null) {\n super(e, t, s), this.channels = q(s, \"channels\", [0]), this.index = q(s, \"index\", null), this.texCoord = q(s, \"texCoord\", null), this.valueLength = parseInt(this.type.replace(/[^0-9]/g, \"\")) || 1;\n }\n // takes the buffer to read from and the value index to read\n readDataFromBuffer(e, t, s = null) {\n const n = this.type;\n if (n === \"BOOLEAN\" || n === \"STRING\")\n throw new Error(\"PropertyTextureAccessor: BOOLEAN and STRING types not supported.\");\n return _n(e, t * this.valueLength, n, s);\n }\n}\nclass Qi extends Qt {\n constructor(...e) {\n super(...e), this.isPropertyTextureAccessor = !0, this._asyncRead = !1, this._initProperties($i);\n }\n // Reads the full set of property data\n getData(e, t, s, n = {}) {\n const i = this.properties;\n it(i, n);\n const r = Object.keys(i), o = r.map((l) => n[l]);\n return this.getPropertyValuesAtTexel(r, e, t, s, o), r.forEach((l, c) => n[l] = o[c]), n;\n }\n // Reads the full set of property data asynchronously\n async getDataAsync(e, t, s, n = {}) {\n const i = this.properties;\n it(i, n);\n const r = Object.keys(i), o = r.map((l) => n[l]);\n return await this.getPropertyValuesAtTexelAsync(r, e, t, s, o), r.forEach((l, c) => n[l] = o[c]), n;\n }\n // Reads values asynchronously\n getPropertyValuesAtTexelAsync(...e) {\n this._asyncRead = !0;\n const t = this.getPropertyValuesAtTexel(...e);\n return this._asyncRead = !1, t;\n }\n // Reads values from the textures synchronously\n getPropertyValuesAtTexel(e, t, s, n, i = []) {\n for (; i.length < e.length; ) i.push(null);\n i.length = e.length, he.increaseSizeTo(i.length);\n const r = this.data, o = this.definition.properties, l = this.properties, c = Sn(n, t);\n for (let d = 0, m = e.length; d < m; d++) {\n const f = e[d];\n if (!o[f])\n continue;\n const p = l[f], g = r[p.index];\n Mn(n, p.texCoord, s, c, Ss), Cn(Ss, g.image.width, g.image.height, Ms), Cs.set(d, 0), he.renderPixelToTarget(g, Ms, Cs);\n }\n const u = new Uint8Array(e.length * 4);\n if (this._asyncRead)\n return he.readDataAsync(u).then(() => (h.call(this), i));\n return he.readData(u), h.call(this), i;\n function h() {\n for (let d = 0, m = e.length; d < m; d++) {\n const f = e[d], p = l[f], g = p.type;\n if (i[d] = $t(p, i[d]), p) {\n if (!o[f]) {\n i[d] = p.resolveDefault(i);\n continue;\n }\n } else throw new Error(\"PropertyTextureAccessor: Requested property does not exist.\");\n const y = p.valueLength * (p.count || 1), x = p.channels.map((_) => u[4 * d + _]), S = p.componentType, T = De(S, g), M = new T(y);\n if (new Uint8Array(M.buffer).set(x), p.array) {\n const _ = i[d];\n for (let C = 0, v = _.length; C < v; C++)\n _[C] = p.readDataFromBuffer(M, C, _[C]);\n } else\n i[d] = p.readDataFromBuffer(M, 0, i[d]);\n i[d] = p.adjustValueScaleOffset(i[d]), i[d] = p.resolveEnumsToStrings(i[d]), i[d] = p.resolveNoData(i[d]);\n }\n }\n }\n // dispose all of the texture data used\n dispose() {\n this.data.forEach((e) => {\n e && (e.dispose(), e.image instanceof ImageBitmap && e.image.close());\n });\n }\n}\nclass As {\n constructor(e, t, s, n = null, i = null) {\n const {\n schema: r,\n propertyTables: o = [],\n propertyTextures: l = [],\n propertyAttributes: c = []\n } = e, { enums: u, classes: h } = r, d = o.map((p) => new Yi(p, h, u, s));\n let m = [], f = [];\n n && (n.propertyTextures && (m = n.propertyTextures.map((p) => new Qi(l[p], h, u, t))), n.propertyAttributes && (f = n.propertyAttributes.map((p) => new Wi(c[p], h, u)))), this.schema = r, this.tableAccessors = d, this.textureAccessors = m, this.attributeAccessors = f, this.object = i, this.textures = t, this.nodeMetadata = n;\n }\n // Property Tables\n getPropertyTableData(e, t, s = null) {\n if (!Array.isArray(e) || !Array.isArray(t))\n s = s || {}, s = this.tableAccessors[e].getData(t, s);\n else {\n s = s || [];\n const n = Math.min(e.length, t.length);\n s.length = n;\n for (let i = 0; i < n; i++) {\n const r = this.tableAccessors[e[i]];\n s[i] = r.getData(t[i], s[i]);\n }\n }\n return s;\n }\n getPropertyTableInfo(e = null) {\n if (e === null && (e = this.tableAccessors.map((t, s) => s)), Array.isArray(e))\n return e.map((t) => {\n const s = this.tableAccessors[t];\n return {\n name: s.name,\n className: s.definition.class\n };\n });\n {\n const t = this.tableAccessors[e];\n return {\n name: t.name,\n className: t.definition.class\n };\n }\n }\n // Property Textures\n getPropertyTextureData(e, t, s = []) {\n const n = this.textureAccessors;\n s.length = n.length;\n for (let i = 0; i < n.length; i++) {\n const r = n[i];\n s[i] = r.getData(e, t, this.object.geometry, s[i]);\n }\n return s;\n }\n async getPropertyTextureDataAsync(e, t, s = []) {\n const n = this.textureAccessors;\n s.length = n.length;\n const i = [];\n for (let r = 0; r < n.length; r++) {\n const l = n[r].getDataAsync(e, t, this.object.geometry, s[r]).then((c) => {\n s[r] = c;\n });\n i.push(l);\n }\n return await Promise.all(i), s;\n }\n getPropertyTextureInfo() {\n return this.textureAccessors;\n }\n // Property Attributes\n getPropertyAttributeData(e, t = []) {\n const s = this.attributeAccessors;\n t.length = s.length;\n for (let n = 0; n < s.length; n++) {\n const i = s[n];\n t[n] = i.getData(e, this.object.geometry, t[n]);\n }\n return t;\n }\n getPropertyAttributeInfo() {\n return this.attributeAccessors.map((e) => ({\n name: e.name,\n className: e.definition.class\n }));\n }\n dispose() {\n this.textureAccessors.forEach((e) => e.dispose()), this.tableAccessors.forEach((e) => e.dispose()), this.attributeAccessors.forEach((e) => e.dispose());\n }\n}\nconst Le = \"EXT_structural_metadata\";\nfunction Zi(a, e = []) {\n var n;\n const t = ((n = a.json.textures) == null ? void 0 : n.length) || 0, s = new Array(t).fill(null);\n return e.forEach(({ properties: i }) => {\n for (const r in i) {\n const { index: o } = i[r];\n s[o] === null && (s[o] = a.loadTexture(o));\n }\n }), Promise.all(s);\n}\nfunction Ji(a, e = []) {\n var n;\n const t = ((n = a.json.bufferViews) == null ? void 0 : n.length) || 0, s = new Array(t).fill(null);\n return e.forEach(({ properties: i }) => {\n for (const r in i) {\n const { values: o, arrayOffsets: l, stringOffsets: c } = i[r];\n s[o] === null && (s[o] = a.loadBufferView(o)), s[l] === null && (s[l] = a.loadBufferView(l)), s[c] === null && (s[c] = a.loadBufferView(c));\n }\n }), Promise.all(s);\n}\nclass Ki {\n constructor(e) {\n this.parser = e, this.name = Le;\n }\n async afterRoot({ scene: e, parser: t }) {\n const s = t.json.extensionsUsed;\n if (!s || !s.includes(Le))\n return;\n let n = null, i = t.json.extensions[Le];\n if (i.schemaUri) {\n const { manager: c, path: u, requestHeader: h, crossOrigin: d } = t.options, m = new URL(i.schemaUri, u).toString(), f = new ti(c);\n f.setCrossOrigin(d), f.setResponseType(\"json\"), f.setRequestHeader(h), n = f.loadAsync(m).then((p) => {\n i = { ...i, schema: p };\n });\n }\n const [r, o] = await Promise.all([\n Zi(t, i.propertyTextures),\n Ji(t, i.propertyTables),\n n\n ]), l = new As(i, r, o);\n e.userData.structuralMetadata = l, e.traverse((c) => {\n var u;\n if (t.associations.has(c)) {\n const { meshes: h, primitives: d } = t.associations.get(c), m = (u = t.json.meshes[h]) == null ? void 0 : u.primitives[d];\n if (m && m.extensions && m.extensions[Le]) {\n const f = m.extensions[Le];\n c.userData.structuralMetadata = new As(i, r, o, f, c);\n } else\n c.userData.structuralMetadata = l;\n }\n });\n }\n}\nconst Is = /* @__PURE__ */ new Y(), vs = /* @__PURE__ */ new Y(), Ls = /* @__PURE__ */ new Y();\nfunction er(a) {\n return a.x > a.y && a.x > a.z ? 0 : a.y > a.z ? 1 : 2;\n}\nclass tr {\n constructor(e, t, s) {\n this.geometry = e, this.textures = t, this.data = s, this._asyncRead = !1, this.featureIds = s.featureIds.map((n) => {\n const { texture: i, ...r } = n, o = {\n label: null,\n propertyTable: null,\n nullFeatureId: null,\n ...r\n };\n return i && (o.texture = {\n texCoord: 0,\n channels: [0],\n ...i\n }), o;\n });\n }\n // returns list of textures\n getTextures() {\n return this.textures;\n }\n // returns a set of info for each feature\n getFeatureInfo() {\n return this.featureIds;\n }\n // performs texture data read back asynchronously\n getFeaturesAsync(...e) {\n this._asyncRead = !0;\n const t = this.getFeatures(...e);\n return this._asyncRead = !1, t;\n }\n // returns all features for the given point on the given triangle\n getFeatures(e, t) {\n const { geometry: s, textures: n, featureIds: i } = this, r = new Array(i.length).fill(null), o = i.length;\n he.increaseSizeTo(o);\n const l = Sn(s, e), c = l[er(t)];\n for (let d = 0, m = i.length; d < m; d++) {\n const f = i[d], p = \"nullFeatureId\" in f ? f.nullFeatureId : null;\n if (\"texture\" in f) {\n const g = n[f.texture.index];\n Mn(s, f.texture.texCoord, t, l, Is), Cn(Is, g.image.width, g.image.height, vs), Ls.set(d, 0), he.renderPixelToTarget(n[f.texture.index], vs, Ls);\n } else if (\"attribute\" in f) {\n const y = s.getAttribute(`_feature_id_${f.attribute}`).getX(c);\n y !== p && (r[d] = y);\n } else {\n const g = c;\n g !== p && (r[d] = g);\n }\n }\n const u = new Uint8Array(o * 4);\n if (this._asyncRead)\n return he.readDataAsync(u).then(() => (h(), r));\n return he.readData(u), h(), r;\n function h() {\n const d = new Uint32Array(1);\n for (let m = 0, f = i.length; m < f; m++) {\n const p = i[m], g = \"nullFeatureId\" in p ? p.nullFeatureId : null;\n if (\"texture\" in p) {\n const { channels: y } = p.texture, x = y.map((T) => u[4 * m + T]);\n new Uint8Array(d.buffer).set(x);\n const S = d[0];\n S !== g && (r[m] = S);\n }\n }\n }\n }\n // dispose all of the texture data used\n dispose() {\n this.textures.forEach((e) => {\n e && (e.dispose(), e.image instanceof ImageBitmap && e.image.close());\n });\n }\n}\nconst rt = \"EXT_mesh_features\";\nfunction Es(a, e, t) {\n a.traverse((s) => {\n var n;\n if (e.associations.has(s)) {\n const { meshes: i, primitives: r } = e.associations.get(s), o = (n = e.json.meshes[i]) == null ? void 0 : n.primitives[r];\n o && o.extensions && o.extensions[rt] && t(s, o.extensions[rt]);\n }\n });\n}\nclass sr {\n constructor(e) {\n this.parser = e, this.name = rt;\n }\n async afterRoot({ scene: e, parser: t }) {\n var o;\n const s = t.json.extensionsUsed;\n if (!s || !s.includes(rt))\n return;\n const n = ((o = t.json.textures) == null ? void 0 : o.length) || 0, i = new Array(n).fill(null);\n Es(e, t, (l, { featureIds: c }) => {\n c.forEach((u) => {\n if (u.texture && i[u.texture.index] === null) {\n const h = u.texture.index;\n i[h] = t.loadTexture(h);\n }\n });\n });\n const r = await Promise.all(i);\n Es(e, t, (l, c) => {\n l.userData.meshFeatures = new tr(l.geometry, r, c);\n });\n }\n}\nclass nr {\n constructor() {\n this.name = \"CESIUM_RTC\";\n }\n afterRoot(e) {\n if (e.parser.json.extensions && e.parser.json.extensions.CESIUM_RTC) {\n const { center: t } = e.parser.json.extensions.CESIUM_RTC;\n t && (e.scene.position.x += t[0], e.scene.position.y += t[1], e.scene.position.z += t[2]);\n }\n }\n}\nclass lo {\n constructor(e) {\n e = {\n metadata: !0,\n rtc: !0,\n plugins: [],\n dracoLoader: null,\n ktxLoader: null,\n meshoptDecoder: null,\n autoDispose: !0,\n ...e\n }, this.tiles = null, this.metadata = e.metadata, this.rtc = e.rtc, this.plugins = e.plugins, this.dracoLoader = e.dracoLoader, this.ktxLoader = e.ktxLoader, this.meshoptDecoder = e.meshoptDecoder, this._gltfRegex = /\\.(gltf|glb)$/g, this._dracoRegex = /\\.drc$/g, this._loader = null;\n }\n init(e) {\n const t = new gi(e.manager);\n this.dracoLoader && (t.setDRACOLoader(this.dracoLoader), e.manager.addHandler(this._dracoRegex, this.dracoLoader)), this.ktxLoader && t.setKTX2Loader(this.ktxLoader), this.meshoptDecoder && t.setMeshoptDecoder(this.meshoptDecoder), this.rtc && t.register(() => new nr()), this.metadata && (t.register(() => new Ki()), t.register(() => new sr())), this.plugins.forEach((s) => t.register(s)), e.manager.addHandler(this._gltfRegex, t), this.tiles = e, this._loader = t;\n }\n dispose() {\n this.tiles.manager.removeHandler(this._gltfRegex), this.tiles.manager.removeHandler(this._dracoRegex), this.autoDispose && (this.ktxLoader.dispose(), this.dracoLoader.dispose());\n }\n}\nconst qe = /* @__PURE__ */ new de();\nclass co {\n constructor(e) {\n e = {\n up: \"+z\",\n recenter: !0,\n lat: null,\n lon: null,\n height: 0,\n azimuth: 0,\n elevation: 0,\n roll: 0,\n ...e\n }, this.tiles = null, this.up = e.up.toLowerCase().replace(/\\s+/, \"\"), this.lat = e.lat, this.lon = e.lon, this.height = e.height, this.azimuth = e.azimuth, this.elevation = e.elevation, this.roll = e.roll, this.recenter = e.recenter, this._callback = null;\n }\n init(e) {\n this.tiles = e, this._callback = () => {\n const { up: t, lat: s, lon: n, height: i, azimuth: r, elevation: o, roll: l, recenter: c } = this;\n if (s !== null && n !== null)\n this.transformLatLonHeightToOrigin(s, n, i, r, o, l);\n else {\n const { ellipsoid: u } = e, h = Math.min(...u.radius);\n if (e.getBoundingSphere(qe), qe.center.length() > h * 0.5) {\n const d = {};\n u.getPositionToCartographic(qe.center, d), this.transformLatLonHeightToOrigin(d.lat, d.lon, d.height);\n } else {\n const d = e.group;\n switch (d.rotation.set(0, 0, 0), t) {\n case \"x\":\n case \"+x\":\n d.rotation.z = Math.PI / 2;\n break;\n case \"-x\":\n d.rotation.z = -Math.PI / 2;\n break;\n case \"y\":\n case \"+y\":\n break;\n case \"-y\":\n d.rotation.z = Math.PI;\n break;\n case \"z\":\n case \"+z\":\n d.rotation.x = -Math.PI / 2;\n break;\n case \"-z\":\n d.rotation.x = Math.PI / 2;\n break;\n }\n e.group.position.copy(qe.center).applyEuler(d.rotation).multiplyScalar(-1);\n }\n }\n c || e.group.position.setScalar(0), e.removeEventListener(\"load-root-tileset\", this._callback);\n }, e.addEventListener(\"load-root-tileset\", this._callback), e.root && this._callback();\n }\n transformLatLonHeightToOrigin(e, t, s = 0, n = 0, i = 0, r = 0) {\n const { group: o, ellipsoid: l } = this.tiles;\n l.getObjectFrame(e, t, s, n, i, r, o.matrix, hi), o.matrix.invert().decompose(o.position, o.quaternion, o.scale), o.updateMatrixWorld();\n }\n dispose() {\n const { group: e } = this.tiles;\n e.position.setScalar(0), e.quaternion.identity(), e.scale.set(1, 1, 1), this.tiles.removeEventListener(\"load-root-tileset\", this._callback);\n }\n}\nclass uo {\n set delay(e) {\n this.deferCallbacks.delay = e;\n }\n get delay() {\n return this.deferCallbacks.delay;\n }\n set bytesTarget(e) {\n this.lruCache.minBytesSize = e;\n }\n get bytesTarget() {\n return this.lruCache.minBytesSize;\n }\n get estimatedGpuBytes() {\n return this.lruCache.cachedBytes;\n }\n constructor(e = {}) {\n const {\n delay: t = 0,\n bytesTarget: s = 0\n } = e;\n this.name = \"UNLOAD_TILES_PLUGIN\", this.tiles = null, this.lruCache = new yi(), this.deferCallbacks = new ir(), this.delay = t, this.bytesTarget = s;\n }\n init(e) {\n this.tiles = e;\n const { lruCache: t, deferCallbacks: s } = this, n = (i) => {\n const r = i.engineData.scene;\n e.visibleTiles.has(i) || e.invokeOnePlugin((l) => l.unloadTileFromGPU && l.unloadTileFromGPU(r, i));\n };\n this._onUpdateBefore = () => {\n t.unloadPriorityCallback = e.lruCache.unloadPriorityCallback, t.minSize = 1 / 0, t.maxSize = 1 / 0, t.maxBytesSize = 1 / 0, t.unloadPercent = 1, t.autoMarkUnused = !1;\n }, this._onVisibilityChangeCallback = ({ tile: i, scene: r, visible: o }) => {\n o ? (t.add(i, n), t.setMemoryUsage(i, e.calculateBytesUsed(i, r) || 1), e.markTileUsed(i), s.cancel(i)) : s.run(i);\n }, this._onDisposeModel = ({ tile: i }) => {\n t.remove(i), s.cancel(i);\n }, s.callback = (i) => {\n t.markUnused(i), t.scheduleUnload();\n }, e.forEachLoadedModel((i, r) => {\n const o = e.visibleTiles.has(r);\n this._onVisibilityChangeCallback({ tile: r, visible: o });\n }), e.addEventListener(\"tile-visibility-change\", this._onVisibilityChangeCallback), e.addEventListener(\"update-before\", this._onUpdateBefore), e.addEventListener(\"dispose-model\", this._onDisposeModel);\n }\n unloadTileFromGPU(e, t) {\n e && e.traverse((s) => {\n if (s.material) {\n const n = s.material;\n n.dispose();\n for (const i in n) {\n const r = n[i];\n r && r.isTexture && r.dispose();\n }\n }\n s.geometry && s.geometry.dispose();\n });\n }\n dispose() {\n const { lruCache: e, tiles: t, deferCallbacks: s } = this;\n t.removeEventListener(\"tile-visibility-change\", this._onVisibilityChangeCallback), t.removeEventListener(\"update-before\", this._onUpdateBefore), t.removeEventListener(\"dispose-model\", this._onDisposeModel), s.cancelAll(), e.minBytesSize = 0, e.minSize = 0, e.maxSize = 0, e.markAllUnused(), e.scheduleUnload();\n }\n}\nclass ir {\n constructor(e = () => {\n }) {\n this.map = /* @__PURE__ */ new Map(), this.callback = e, this.delay = 0;\n }\n run(e) {\n const { map: t, delay: s } = this;\n if (t.has(e))\n throw new Error(\"DeferCallbackManager: Callback already initialized.\");\n s === 0 ? this.callback(e) : t.set(e, setTimeout(() => {\n this.callback(e), t.delete(e);\n }, s));\n }\n cancel(e) {\n const { map: t } = this;\n t.has(e) && (clearTimeout(t.get(e)), t.delete(e));\n }\n cancelAll() {\n this.map.forEach((e, t) => {\n this.cancel(t);\n });\n }\n}\nconst { clamp: _t } = b;\nclass rr {\n constructor() {\n this.duration = 250, this.fadeCount = 0, this._lastTick = -1, this._fadeState = /* @__PURE__ */ new Map(), this.onFadeComplete = null, this.onFadeStart = null, this.onFadeSetComplete = null, this.onFadeSetStart = null;\n }\n // delete the object from the fade, reset the material data\n deleteObject(e) {\n e && this.completeFade(e);\n }\n // Ensure we're storing a fade timer for the provided object\n // Returns whether a new state had to be added\n guaranteeState(e) {\n const t = this._fadeState;\n if (t.has(e))\n return !1;\n const s = {\n fadeInTarget: 0,\n fadeOutTarget: 0,\n fadeIn: 0,\n fadeOut: 0\n };\n return t.set(e, s), !0;\n }\n // Force the fade to complete in the direction it is already trending\n completeFade(e) {\n const t = this._fadeState;\n if (!t.has(e))\n return;\n const s = t.get(e).fadeOutTarget === 0;\n t.delete(e), this.fadeCount--, this.onFadeComplete && this.onFadeComplete(e, s), this.fadeCount === 0 && this.onFadeSetComplete && this.onFadeSetComplete();\n }\n completeAllFades() {\n this._fadeState.forEach((e, t) => {\n this.completeFade(t);\n });\n }\n forEachObject(e) {\n this._fadeState.forEach((t, s) => {\n e(s, t);\n });\n }\n // Fade the object in\n fadeIn(e) {\n const t = this.guaranteeState(e), s = this._fadeState.get(e);\n s.fadeInTarget = 1, s.fadeOutTarget = 0, s.fadeOut = 0, t && (this.fadeCount++, this.fadeCount === 1 && this.onFadeSetStart && this.onFadeSetStart(), this.onFadeStart && this.onFadeStart(e));\n }\n // Fade the object out\n fadeOut(e) {\n const t = this.guaranteeState(e), s = this._fadeState.get(e);\n s.fadeOutTarget = 1, t && (s.fadeInTarget = 1, s.fadeIn = 1, this.fadeCount++, this.fadeCount === 1 && this.onFadeSetStart && this.onFadeSetStart(), this.onFadeStart && this.onFadeStart(e));\n }\n isFading(e) {\n return this._fadeState.has(e);\n }\n isFadingOut(e) {\n const t = this._fadeState.get(e);\n return t && t.fadeOutTarget === 1;\n }\n // Tick the fade timer for each actively fading object\n update() {\n const e = window.performance.now();\n this._lastTick === -1 && (this._lastTick = e);\n const t = _t((e - this._lastTick) / this.duration, 0, 1);\n this._lastTick = e, this._fadeState.forEach((n, i) => {\n const {\n fadeOutTarget: r,\n fadeInTarget: o\n } = n;\n let {\n fadeOut: l,\n fadeIn: c\n } = n;\n const u = Math.sign(o - c);\n c = _t(c + u * t, 0, 1);\n const h = Math.sign(r - l);\n l = _t(l + h * t, 0, 1), n.fadeIn = c, n.fadeOut = l, ((l === 1 || l === 0) && (c === 1 || c === 0) || l >= c) && this.completeFade(i);\n });\n }\n}\nconst St = Symbol(\"FADE_PARAMS\");\nfunction An(a, e) {\n if (a[St])\n return a[St];\n const t = {\n fadeIn: { value: 0 },\n fadeOut: { value: 0 },\n fadeTexture: { value: null }\n };\n return a[St] = t, a.defines = {\n ...a.defines || {},\n FEATURE_FADE: 0\n }, a.onBeforeCompile = (s) => {\n e && e(s), s.uniforms = {\n ...s.uniforms,\n ...t\n }, s.vertexShader = s.vertexShader.replace(\n /void\\s+main\\(\\)\\s+{/,\n (n) => (\n /* glsl */\n `\n\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\tvarying float vBatchId;\n\n\t\t\t\t\t#endif\n\n\t\t\t\t\t${n}\n\n\t\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\t\t// add 0.5 to the value to avoid floating error that may cause flickering\n\t\t\t\t\t\tvBatchId = getIndirectIndex( gl_DrawID ) + 0.5;\n\n\t\t\t\t\t\t#endif\n\t\t\t\t`\n )\n ), s.fragmentShader = s.fragmentShader.replace(/void main\\(/, (n) => (\n /* glsl */\n `\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t// adapted from https://www.shadertoy.com/view/Mlt3z8\n\t\t\t\tfloat bayerDither2x2( vec2 v ) {\n\n\t\t\t\t\treturn mod( 3.0 * v.y + 2.0 * v.x, 4.0 );\n\n\t\t\t\t}\n\n\t\t\t\tfloat bayerDither4x4( vec2 v ) {\n\n\t\t\t\t\tvec2 P1 = mod( v, 2.0 );\n\t\t\t\t\tvec2 P2 = floor( 0.5 * mod( v, 4.0 ) );\n\t\t\t\t\treturn 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 );\n\n\t\t\t\t}\n\n\t\t\t\t// the USE_BATCHING define is not available in fragment shaders\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t// functions for reading the fade state of a given batch id\n\t\t\t\tuniform sampler2D fadeTexture;\n\t\t\t\tvarying float vBatchId;\n\t\t\t\tvec2 getFadeValues( const in float i ) {\n\n\t\t\t\t\tint size = textureSize( fadeTexture, 0 ).x;\n\t\t\t\t\tint j = int( i );\n\t\t\t\t\tint x = j % size;\n\t\t\t\t\tint y = j / size;\n\t\t\t\t\treturn texelFetch( fadeTexture, ivec2( x, y ), 0 ).rg;\n\n\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\tuniform float fadeIn;\n\t\t\t\tuniform float fadeOut;\n\n\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t\t${n}\n\t\t\t`\n )).replace(/#include <dithering_fragment>/, (n) => (\n /* glsl */\n `\n\n\t\t\t\t${n}\n\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\tvec2 fadeValues = getFadeValues( vBatchId );\n\t\t\t\tfloat fadeIn = fadeValues.r;\n\t\t\t\tfloat fadeOut = fadeValues.g;\n\n\t\t\t\t#endif\n\n\t\t\t\tfloat bayerValue = bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) );\n\t\t\t\tfloat bayerBins = 16.0;\n\t\t\t\tfloat dither = ( 0.5 + bayerValue ) / bayerBins;\n\t\t\t\tif ( dither >= fadeIn ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\tif ( dither < fadeOut ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t`\n ));\n }, t;\n}\nclass or {\n constructor() {\n this._fadeParams = /* @__PURE__ */ new WeakMap(), this.fading = 0;\n }\n // Set the fade parameters for the given scene\n setFade(e, t, s) {\n if (!e)\n return;\n const n = this._fadeParams;\n e.traverse((i) => {\n const r = i.material;\n if (r && n.has(r)) {\n const o = n.get(r);\n o.fadeIn.value = t, o.fadeOut.value = s;\n const u = +(!(t === 0 || t === 1) || !(s === 0 || s === 1));\n r.defines.FEATURE_FADE !== u && (this.fading += u === 1 ? 1 : -1, r.defines.FEATURE_FADE = u, r.needsUpdate = !0);\n }\n });\n }\n // initialize materials in the object\n prepareScene(e) {\n e.traverse((t) => {\n t.material && this.prepareMaterial(t.material);\n });\n }\n // delete the object from the fade, reset the material data\n deleteScene(e) {\n if (!e)\n return;\n this.setFade(e, 1, 0);\n const t = this._fadeParams;\n e.traverse((s) => {\n const n = s.material;\n n && t.delete(n);\n });\n }\n // initialize the material\n prepareMaterial(e) {\n const t = this._fadeParams;\n t.has(e) || t.set(e, An(e, e.onBeforeCompile));\n }\n}\nclass ar {\n constructor(e, t = new Se()) {\n this.other = e, this.material = t, this.visible = !0, this.parent = null, this._instanceInfo = [], this._visibilityChanged = !0;\n const s = new Proxy(this, {\n get(n, i) {\n if (i in n)\n return n[i];\n {\n const r = e[i];\n return r instanceof Function ? (...o) => (n.syncInstances(), r.call(s, ...o)) : e[i];\n }\n },\n set(n, i, r) {\n return i in n ? n[i] = r : e[i] = r, !0;\n },\n deleteProperty(n, i) {\n return i in n ? delete n[i] : delete e[i];\n }\n // ownKeys() {},\n // has(target, key) {},\n // defineProperty(target, key, descriptor) {},\n // getOwnPropertyDescriptor(target, key) {},\n });\n return s;\n }\n syncInstances() {\n const e = this._instanceInfo, t = this.other._instanceInfo;\n for (; t.length > e.length; ) {\n const s = e.length;\n e.push(new Proxy({ visible: !1 }, {\n get(n, i) {\n return i in n ? n[i] : t[s][i];\n },\n set(n, i, r) {\n return i in n ? n[i] = r : t[s][i] = r, !0;\n }\n }));\n }\n }\n}\nclass lr extends ar {\n constructor(...e) {\n super(...e);\n const t = this.material, s = An(t, t.onBeforeCompile);\n t.defines.FEATURE_FADE = 1, t.defines.USE_BATCHING_FRAG = 1, t.needsUpdate = !0, this.fadeTexture = null, this._fadeParams = s;\n }\n // Set the fade state\n setFadeAt(e, t, s) {\n this._initFadeTexture(), this.fadeTexture.setValueAt(e, t * 255, s * 255);\n }\n // initialize the texture and resize it if needed\n _initFadeTexture() {\n let e = Math.sqrt(this._maxInstanceCount);\n e = Math.ceil(e);\n const t = e * e * 2, s = this.fadeTexture;\n if (!s || s.image.data.length !== t) {\n const n = new Uint8Array(t), i = new cr(n, e, e, en, tn);\n if (s) {\n s.dispose();\n const r = s.image.data, o = this.fadeTexture.image.data, l = Math.min(r.length, o.length);\n o.set(new r.constructor(r.buffer, 0, l));\n }\n this.fadeTexture = i, this._fadeParams.fadeTexture.value = i, i.needsUpdate = !0;\n }\n }\n // dispose the fade texture. Super cannot be used here due to proxy\n dispose() {\n this.fadeTexture && this.fadeTexture.dispose();\n }\n}\nclass cr extends Wt {\n setValueAt(e, ...t) {\n const { data: s, width: n, height: i } = this.image, r = Math.floor(s.length / (n * i));\n let o = !1;\n for (let l = 0; l < r; l++) {\n const c = e * r + l, u = s[c], h = t[l] || 0;\n u !== h && (s[c] = h, o = !0);\n }\n o && (this.needsUpdate = !0);\n }\n}\nconst ws = Symbol(\"HAS_POPPED_IN\"), Ps = /* @__PURE__ */ new E(), Rs = /* @__PURE__ */ new E(), Ds = /* @__PURE__ */ new nn(), Bs = /* @__PURE__ */ new nn(), Os = /* @__PURE__ */ new E();\nfunction ur() {\n const a = this._fadeManager, e = this.tiles;\n this._fadingBefore = a.fadeCount, this._displayActiveTiles = e.displayActiveTiles, e.displayActiveTiles = !0;\n}\nfunction hr() {\n const a = this._fadeManager, e = this._fadeMaterialManager, t = this._displayActiveTiles, s = this._fadingBefore, n = this._prevCameraTransforms, { tiles: i, maximumFadeOutTiles: r, batchedMesh: o } = this, { cameras: l } = i;\n i.displayActiveTiles = t, a.update();\n const c = a.fadeCount;\n if (s !== 0 && c !== 0 && (i.dispatchEvent({ type: \"fade-change\" }), i.dispatchEvent({ type: \"needs-render\" })), t || i.visibleTiles.forEach((u) => {\n const h = u.engineData.scene;\n h && (h.visible = u.traversal.inFrustum), this.forEachBatchIds(u, (d, m, f) => {\n m.setVisibleAt(d, u.traversal.inFrustum), f.batchedMesh.setVisibleAt(d, u.traversal.inFrustum);\n });\n }), r < this._fadingOutCount) {\n let u = !0;\n l.forEach((h) => {\n if (!n.has(h))\n return;\n const d = h.matrixWorld, m = n.get(h);\n d.decompose(Rs, Bs, Os), m.decompose(Ps, Ds, Os);\n const f = Bs.angleTo(Ds), p = Rs.distanceTo(Ps);\n u = u && (f > 0.25 || p > 0.1);\n }), u && a.completeAllFades();\n }\n if (l.forEach((u) => {\n n.get(u).copy(u.matrixWorld);\n }), a.forEachObject((u, { fadeIn: h, fadeOut: d }) => {\n const m = u.engineData.scene, f = a.isFadingOut(u);\n i.markTileUsed(u), m && (e.setFade(m, h, d), f && (m.visible = !0)), this.forEachBatchIds(u, (p, g, y) => {\n g.setFadeAt(p, h, d), g.setVisibleAt(p, !0), y.batchedMesh.setVisibleAt(p, !1);\n });\n }), o) {\n const u = i.getPluginByName(\"BATCHED_TILES_PLUGIN\").batchedMesh.material;\n o.material.map = u.map;\n }\n}\nclass ho {\n get fadeDuration() {\n return this._fadeManager.duration;\n }\n set fadeDuration(e) {\n this._fadeManager.duration = Number(e);\n }\n get fadingTiles() {\n return this._fadeManager.fadeCount;\n }\n constructor(e) {\n e = {\n maximumFadeOutTiles: 50,\n fadeRootTiles: !1,\n fadeDuration: 250,\n ...e\n }, this.name = \"FADE_TILES_PLUGIN\", this.priority = -2, this.tiles = null, this.batchedMesh = null, this._quickFadeTiles = /* @__PURE__ */ new Set(), this._fadeManager = new rr(), this._fadeMaterialManager = new or(), this._prevCameraTransforms = null, this._fadingOutCount = 0, this.maximumFadeOutTiles = e.maximumFadeOutTiles, this.fadeRootTiles = e.fadeRootTiles, this.fadeDuration = e.fadeDuration;\n }\n init(e) {\n this._onLoadModel = ({ scene: n }) => {\n this._fadeMaterialManager.prepareScene(n);\n }, this._onDisposeModel = ({ tile: n, scene: i }) => {\n this.tiles.visibleTiles.has(n) && this._quickFadeTiles.add(n.parent), this._fadeManager.deleteObject(n), this._fadeMaterialManager.deleteScene(i);\n }, this._onAddCamera = ({ camera: n }) => {\n this._prevCameraTransforms.set(n, new K());\n }, this._onDeleteCamera = ({ camera: n }) => {\n this._prevCameraTransforms.delete(n);\n }, this._onTileVisibilityChange = ({ tile: n, visible: i }) => {\n const r = n.engineData.scene;\n r && (r.visible = !0), this.forEachBatchIds(n, (o, l, c) => {\n l.setFadeAt(o, 0, 0), l.setVisibleAt(o, !1), c.batchedMesh.setVisibleAt(o, !1);\n });\n }, this._onUpdateBefore = () => {\n ur.call(this);\n }, this._onUpdateAfter = () => {\n hr.call(this);\n }, e.addEventListener(\"load-model\", this._onLoadModel), e.addEventListener(\"dispose-model\", this._onDisposeModel), e.addEventListener(\"add-camera\", this._onAddCamera), e.addEventListener(\"delete-camera\", this._onDeleteCamera), e.addEventListener(\"update-before\", this._onUpdateBefore), e.addEventListener(\"update-after\", this._onUpdateAfter), e.addEventListener(\"tile-visibility-change\", this._onTileVisibilityChange);\n const t = this._fadeManager;\n t.onFadeSetStart = () => {\n e.dispatchEvent({ type: \"fade-start\" }), e.dispatchEvent({ type: \"needs-render\" });\n }, t.onFadeSetComplete = () => {\n e.dispatchEvent({ type: \"fade-end\" }), e.dispatchEvent({ type: \"needs-render\" });\n }, t.onFadeComplete = (n, i) => {\n this._fadeMaterialManager.setFade(n.engineData.scene, 0, 0), this.forEachBatchIds(n, (r, o, l) => {\n o.setFadeAt(r, 0, 0), o.setVisibleAt(r, !1), l.batchedMesh.setVisibleAt(r, i);\n }), i || (e.invokeOnePlugin((r) => r !== this && r.setTileVisible && r.setTileVisible(n, !1)), this._fadingOutCount--);\n };\n const s = /* @__PURE__ */ new Map();\n e.cameras.forEach((n) => {\n s.set(n, new K());\n }), e.forEachLoadedModel((n, i) => {\n this._onLoadModel({ scene: n });\n }), this.tiles = e, this._fadeManager = t, this._prevCameraTransforms = s;\n }\n // initializes the batched mesh if it needs to be, dispose if it it's no longer needed\n initBatchedMesh() {\n var t;\n const e = (t = this.tiles.getPluginByName(\"BATCHED_TILES_PLUGIN\")) == null ? void 0 : t.batchedMesh;\n if (e) {\n if (this.batchedMesh === null) {\n this._onBatchedMeshDispose = () => {\n this.batchedMesh.dispose(), this.batchedMesh.removeFromParent(), this.batchedMesh = null, e.removeEventListener(\"dispose\", this._onBatchedMeshDispose);\n };\n const s = e.material.clone();\n s.onBeforeCompile = e.material.onBeforeCompile, this.batchedMesh = new lr(e, s), this.tiles.group.add(this.batchedMesh);\n }\n } else\n this.batchedMesh !== null && (this._onBatchedMeshDispose(), this._onBatchedMeshDispose = null);\n }\n // callback for fading to prevent tiles from being removed until the fade effect has completed\n setTileVisible(e, t) {\n const s = this._fadeManager, n = s.isFading(e);\n if (s.isFadingOut(e) && this._fadingOutCount--, t ? e.internal.depthFromRenderedParent === 1 ? ((e[ws] || this.fadeRootTiles) && this._fadeManager.fadeIn(e), e[ws] = !0) : this._fadeManager.fadeIn(e) : (this._fadingOutCount++, s.fadeOut(e)), this._quickFadeTiles.has(e) && (this._fadeManager.completeFade(e), this._quickFadeTiles.delete(e)), n)\n return !0;\n const i = this._fadeManager.isFading(e);\n return !!(!t && i);\n }\n dispose() {\n const e = this.tiles;\n this._fadeManager.completeAllFades(), this.batchedMesh !== null && this._onBatchedMeshDispose(), e.removeEventListener(\"load-model\", this._onLoadModel), e.removeEventListener(\"dispose-model\", this._onDisposeModel), e.removeEventListener(\"add-camera\", this._onAddCamera), e.removeEventListener(\"delete-camera\", this._onDeleteCamera), e.removeEventListener(\"update-before\", this._onUpdateBefore), e.removeEventListener(\"update-after\", this._onUpdateAfter), e.removeEventListener(\"tile-visibility-change\", this._onTileVisibilityChange), e.forEachLoadedModel((t, s) => {\n this._fadeManager.deleteObject(s), t && (t.visible = !0);\n });\n }\n // helper for iterating over the batch ids for a given tile\n forEachBatchIds(e, t) {\n if (this.initBatchedMesh(), this.batchedMesh) {\n const s = this.tiles.getPluginByName(\"BATCHED_TILES_PLUGIN\"), n = s.getTileBatchIds(e);\n n && n.forEach((i) => {\n t(i, this.batchedMesh, s);\n });\n }\n }\n}\nconst Mt = /* @__PURE__ */ new K(), Us = /* @__PURE__ */ new E(), Ns = /* @__PURE__ */ new E();\nclass dr extends si {\n constructor(...e) {\n super(...e), this.resetDistance = 1e4, this._matricesTextureHandle = null, this._lastCameraPos = new K(), this._forceUpdate = !0, this._matrices = [];\n }\n setMatrixAt(e, t) {\n super.setMatrixAt(e, t), this._forceUpdate = !0;\n const s = this._matrices;\n for (; s.length <= e; )\n s.push(new K());\n s[e].copy(t);\n }\n setInstanceCount(...e) {\n super.setInstanceCount(...e);\n const t = this._matrices;\n for (; t.length > this.instanceCount; )\n t.pop();\n }\n onBeforeRender(e, t, s, n, i, r) {\n super.onBeforeRender(e, t, s, n, i, r), Us.setFromMatrixPosition(s.matrixWorld), Ns.setFromMatrixPosition(this._lastCameraPos);\n const o = this._matricesTexture;\n let l = this._modelViewMatricesTexture;\n if ((!l || l.image.width !== o.image.width || l.image.height !== o.image.height) && (l && l.dispose(), l = o.clone(), l.source = new ni({\n ...l.image,\n data: l.image.data.slice()\n }), this._modelViewMatricesTexture = l), this._forceUpdate || Us.distanceTo(Ns) > this.resetDistance) {\n const c = this._matrices, u = l.image.data;\n for (let h = 0; h < this.maxInstanceCount; h++) {\n const d = c[h];\n d ? Mt.copy(d) : Mt.identity(), Mt.premultiply(this.matrixWorld).premultiply(s.matrixWorldInverse).toArray(u, h * 16);\n }\n l.needsUpdate = !0, this._lastCameraPos.copy(s.matrixWorld), this._forceUpdate = !1;\n }\n this._matricesTextureHandle = this._matricesTexture, this._matricesTexture = this._modelViewMatricesTexture, this.matrixWorld.copy(this._lastCameraPos);\n }\n onAfterRender() {\n this.updateMatrixWorld(), this._matricesTexture = this._matricesTextureHandle, this._matricesTextureHandle = null;\n }\n onAfterShadow(e, t, s, n, i, r) {\n this.onAfterRender(e, null, n, i, r);\n }\n dispose() {\n super.dispose(), this._modelViewMatricesTexture && this._modelViewMatricesTexture.dispose();\n }\n}\nconst ee = /* @__PURE__ */ new Be(), We = [];\nclass pr extends dr {\n constructor(...e) {\n super(...e), this.expandPercent = 0.25, this.maxInstanceExpansionSize = 1 / 0, this._freeGeometryIds = [];\n }\n // Finds a free id that can fit the geometry with the requested ranges. Returns -1 if it could not be found.\n findFreeId(e, t, s) {\n const n = !!this.geometry.index, i = Math.max(n ? e.index.count : -1, s), r = Math.max(e.attributes.position.count, t);\n let o = -1, l = 1 / 0;\n const c = this._freeGeometryIds;\n if (c.forEach((u, h) => {\n const d = this.getGeometryRangeAt(u), { reservedIndexCount: m, reservedVertexCount: f } = d;\n if (m >= i && f >= r) {\n const p = i - m + (r - f);\n p < l && (o = h, l = p);\n }\n }), o !== -1) {\n const u = c[o];\n return c.splice(o, 1), u;\n } else\n return -1;\n }\n // Overrides addGeometry to find an option geometry slot, expand, or optimized if needed\n addGeometry(e, t, s) {\n const n = !!this.geometry.index;\n s = Math.max(n ? e.index.count : -1, s), t = Math.max(e.attributes.position.count, t);\n const { expandPercent: i, _freeGeometryIds: r } = this;\n let o = this.findFreeId(e, t, s);\n if (o !== -1)\n this.setGeometryAt(o, e);\n else {\n const l = () => {\n const h = this.unusedVertexCount < t, d = this.unusedIndexCount < s;\n return h || d;\n }, c = e.index, u = e.attributes.position;\n if (t = Math.max(t, u.count), s = Math.max(s, c ? c.count : 0), l() && (r.forEach((h) => this.deleteGeometry(h)), r.length = 0, this.optimize(), l())) {\n const h = this.geometry.index, d = this.geometry.attributes.position;\n let m, f;\n if (h) {\n const p = Math.ceil(i * h.count);\n m = Math.max(p, s, c.count) + h.count;\n } else\n m = Math.max(this.unusedIndexCount, s);\n if (d) {\n const p = Math.ceil(i * d.count);\n f = Math.max(p, t, u.count) + d.count;\n } else\n f = Math.max(this.unusedVertexCount, t);\n this.setGeometrySize(f, m);\n }\n o = super.addGeometry(e, t, s);\n }\n return o;\n }\n // add an instance and automatically expand the number of instances if necessary\n addInstance(e) {\n if (this.maxInstanceCount === this.instanceCount) {\n const t = Math.ceil(this.maxInstanceCount * (1 + this.expandPercent));\n this.setInstanceCount(Math.min(t, this.maxInstanceExpansionSize));\n }\n return super.addInstance(e);\n }\n // delete an instance, keeping note that the geometry id is now unused\n deleteInstance(e) {\n const t = this.getGeometryIdAt(e);\n return t !== -1 && this._freeGeometryIds.push(t), super.deleteInstance(e);\n }\n // add a function for raycasting per tile\n raycastInstance(e, t, s) {\n const n = this.geometry, i = this.getGeometryIdAt(e);\n ee.material = this.material, ee.geometry.index = n.index, ee.geometry.attributes = n.attributes;\n const r = this.getGeometryRangeAt(i);\n ee.geometry.setDrawRange(r.start, r.count), ee.geometry.boundingBox === null && (ee.geometry.boundingBox = new ct()), ee.geometry.boundingSphere === null && (ee.geometry.boundingSphere = new de()), this.getMatrixAt(e, ee.matrixWorld).premultiply(this.matrixWorld), this.getBoundingBoxAt(i, ee.geometry.boundingBox), this.getBoundingSphereAt(i, ee.geometry.boundingSphere), ee.raycast(t, We);\n for (let o = 0, l = We.length; o < l; o++) {\n const c = We[o];\n c.object = this, c.batchId = e, s.push(c);\n }\n We.length = 0;\n }\n}\nfunction fr(a) {\n return a.r === 1 && a.g === 1 && a.b === 1;\n}\nfunction mr(a) {\n a.needsUpdate = !0, a.onBeforeCompile = (e) => {\n e.vertexShader = e.vertexShader.replace(\n \"#include <common>\",\n /* glsl */\n `\n\t\t\t\t#include <common>\n\t\t\t\tvarying float texture_index;\n\t\t\t\t`\n ).replace(\n \"#include <uv_vertex>\",\n /* glsl */\n `\n\t\t\t\t#include <uv_vertex>\n\t\t\t\ttexture_index = getIndirectIndex( gl_DrawID );\n\t\t\t\t`\n ), e.fragmentShader = e.fragmentShader.replace(\n \"#include <map_pars_fragment>\",\n /* glsl */\n `\n\t\t\t\t#ifdef USE_MAP\n\t\t\t\tprecision highp sampler2DArray;\n\t\t\t\tuniform sampler2DArray map;\n\t\t\t\tvarying float texture_index;\n\t\t\t\t#endif\n\t\t\t\t`\n ).replace(\n \"#include <map_fragment>\",\n /* glsl */\n `\n\t\t\t\t#ifdef USE_MAP\n\t\t\t\t\tdiffuseColor *= texture( map, vec3( vMapUv, texture_index ) );\n\t\t\t\t#endif\n\t\t\t\t`\n );\n };\n}\nconst Ct = new un(new Se()), Ft = new Wt(new Uint8Array([255, 255, 255, 255]), 1, 1);\nFt.needsUpdate = !0;\nclass po {\n constructor(e = {}) {\n if (parseInt(ii) < 170)\n throw new Error(\"BatchedTilesPlugin: Three.js revision 170 or higher required.\");\n e = {\n instanceCount: 500,\n vertexCount: 750,\n indexCount: 2e3,\n expandPercent: 0.25,\n maxInstanceCount: 1 / 0,\n discardOriginalContent: !0,\n textureSize: null,\n material: null,\n renderer: null,\n ...e\n }, this.name = \"BATCHED_TILES_PLUGIN\", this.priority = -1;\n const t = e.renderer.getContext();\n this.instanceCount = e.instanceCount, this.vertexCount = e.vertexCount, this.indexCount = e.indexCount, this.material = e.material ? e.material.clone() : null, this.expandPercent = e.expandPercent, this.maxInstanceCount = Math.min(e.maxInstanceCount, t.getParameter(t.MAX_3D_TEXTURE_SIZE)), this.renderer = e.renderer, this.discardOriginalContent = e.discardOriginalContent, this.textureSize = e.textureSize, this.batchedMesh = null, this.arrayTarget = null, this.tiles = null, this._onLoadModel = null, this._onDisposeModel = null, this._onVisibilityChange = null, this._tileToInstanceId = /* @__PURE__ */ new Map();\n }\n init(e) {\n this._onDisposeModel = ({ scene: t, tile: s }) => {\n this.removeSceneFromBatchedMesh(t, s);\n }, e.addEventListener(\"dispose-model\", this._onDisposeModel), this.tiles = e;\n }\n initTextureArray(e) {\n if (this.arrayTarget !== null || e.material.map === null)\n return;\n const { instanceCount: t, renderer: s, textureSize: n, batchedMesh: i } = this, r = e.material.map, o = {\n colorSpace: r.colorSpace,\n wrapS: r.wrapS,\n wrapT: r.wrapT,\n wrapR: r.wrapS,\n // TODO: Generating mipmaps for the volume every time a new texture is added is extremely slow\n // generateMipmaps: map.generateMipmaps,\n // minFilter: map.minFilter,\n magFilter: r.magFilter\n }, l = new ss(n || r.image.width, n || r.image.height, t);\n Object.assign(l.texture, o), s.initRenderTarget(l), i.material.map = l.texture, this.arrayTarget = l, this._tileToInstanceId.forEach((c) => {\n c.forEach((u) => {\n this.assignTextureToLayer(Ft, u);\n });\n });\n }\n // init the batched mesh if it's not ready\n initBatchedMesh(e) {\n if (this.batchedMesh !== null)\n return;\n const { instanceCount: t, vertexCount: s, indexCount: n, tiles: i } = this, r = this.material ? this.material : new e.material.constructor(), o = new pr(t, t * s, t * n, r);\n o.name = \"BatchTilesPlugin\", o.frustumCulled = !1, i.group.add(o), o.updateMatrixWorld(), mr(o.material), this.batchedMesh = o;\n }\n setTileVisible(e, t) {\n const s = e.engineData.scene;\n if (t && this.addSceneToBatchedMesh(s, e), this._tileToInstanceId.has(e)) {\n this._tileToInstanceId.get(e).forEach((r) => {\n this.batchedMesh.setVisibleAt(r, t);\n });\n const i = this.tiles;\n return t ? i.visibleTiles.add(e) : i.visibleTiles.delete(e), i.dispatchEvent({\n type: \"tile-visibility-change\",\n scene: s,\n tile: e,\n visible: t\n }), !0;\n }\n return !1;\n }\n unloadTileFromGPU(e, t) {\n return !this.discardOriginalContent && this._tileToInstanceId.has(t) ? (this.removeSceneFromBatchedMesh(e, t), !0) : !1;\n }\n // render the given into the given layer\n assignTextureToLayer(e, t) {\n if (!this.arrayTarget)\n return;\n this.expandArrayTargetIfNeeded();\n const { renderer: s } = this, n = s.getRenderTarget();\n s.setRenderTarget(this.arrayTarget, t), Ct.material.map = e, Ct.render(s), s.setRenderTarget(n), Ct.material.map = null, e.dispose();\n }\n // check if the array texture target needs to be expanded\n expandArrayTargetIfNeeded() {\n const { batchedMesh: e, arrayTarget: t, renderer: s } = this, n = Math.min(e.maxInstanceCount, this.maxInstanceCount);\n if (n > t.depth) {\n const i = {\n colorSpace: t.texture.colorSpace,\n wrapS: t.texture.wrapS,\n wrapT: t.texture.wrapT,\n generateMipmaps: t.texture.generateMipmaps,\n minFilter: t.texture.minFilter,\n magFilter: t.texture.magFilter\n }, r = new ss(t.width, t.height, n);\n Object.assign(r.texture, i), s.initRenderTarget(r), s.copyTextureToTexture(t.texture, r.texture), t.dispose(), e.material.map = r.texture, this.arrayTarget = r;\n }\n }\n removeSceneFromBatchedMesh(e, t) {\n if (this._tileToInstanceId.has(t)) {\n const s = this._tileToInstanceId.get(t);\n this._tileToInstanceId.delete(t), s.forEach((n) => {\n this.batchedMesh.deleteInstance(n);\n });\n }\n }\n addSceneToBatchedMesh(e, t) {\n if (this._tileToInstanceId.has(t))\n return;\n const s = [];\n e.traverse((r) => {\n r.isMesh && s.push(r);\n });\n let n = !0;\n s.forEach((r) => {\n if (this.batchedMesh && n) {\n const o = r.geometry.attributes, l = this.batchedMesh.geometry.attributes;\n for (const c in l)\n if (!(c in o)) {\n n = !1;\n return;\n }\n }\n });\n const i = !this.batchedMesh || this.batchedMesh.instanceCount + s.length <= this.maxInstanceCount;\n if (n && i) {\n e.updateMatrixWorld();\n const r = [];\n this._tileToInstanceId.set(t, r), s.forEach((o) => {\n this.initBatchedMesh(o), this.initTextureArray(o);\n const { geometry: l, material: c } = o, { batchedMesh: u, expandPercent: h } = this;\n u.expandPercent = h;\n const d = u.addGeometry(l, this.vertexCount, this.indexCount), m = u.addInstance(d);\n r.push(m), u.setMatrixAt(m, o.matrixWorld), u.setVisibleAt(m, !1), fr(c.color) || (c.color.setHSL(Math.random(), 0.5, 0.5), u.setColorAt(m, c.color));\n const f = c.map;\n f ? this.assignTextureToLayer(f, m) : this.assignTextureToLayer(Ft, m);\n }), this.discardOriginalContent && (t.engineData.textures.forEach((o) => {\n o.image instanceof ImageBitmap && o.image.close();\n }), t.engineData.scene = null, t.engineData.materials = [], t.engineData.geometries = [], t.engineData.textures = []);\n }\n }\n // Override raycasting per tile to defer to the batched mesh\n raycastTile(e, t, s, n) {\n return this._tileToInstanceId.has(e) ? (this._tileToInstanceId.get(e).forEach((r) => {\n this.batchedMesh.raycastInstance(r, s, n);\n }), !0) : !1;\n }\n dispose() {\n const { arrayTarget: e, tiles: t, batchedMesh: s } = this;\n e && e.dispose(), s && (s.material.dispose(), s.geometry.dispose(), s.dispose(), s.removeFromParent()), t.removeEventListener(\"dispose-model\", this._onDisposeModel);\n }\n getTileBatchIds(e) {\n return this._tileToInstanceId.get(e);\n }\n}\nconst At = /* @__PURE__ */ new de(), je = /* @__PURE__ */ new E(), Ee = /* @__PURE__ */ new K(), Vs = /* @__PURE__ */ new K(), It = /* @__PURE__ */ new ri(), gr = /* @__PURE__ */ new Se({ side: rn }), Fs = /* @__PURE__ */ new ct(), vt = 1e5;\nfunction ks(a, e) {\n return a.isBufferGeometry ? (a.boundingSphere === null && a.computeBoundingSphere(), e.copy(a.boundingSphere)) : (Fs.setFromObject(a), Fs.getBoundingSphere(e), e);\n}\nclass fo {\n constructor() {\n this.name = \"TILE_FLATTENING_PLUGIN\", this.priority = -100, this.tiles = null, this.shapes = /* @__PURE__ */ new Map(), this.positionsMap = /* @__PURE__ */ new Map(), this.positionsUpdated = /* @__PURE__ */ new Set(), this.needsUpdate = !1;\n }\n init(e) {\n this.tiles = e, this.needsUpdate = !0, this._updateBeforeCallback = () => {\n this.needsUpdate && (this._updateTiles(), this.needsUpdate = !1);\n }, this._disposeModelCallback = ({ tile: t }) => {\n this.positionsMap.delete(t), this.positionsUpdated.delete(t);\n }, e.addEventListener(\"update-before\", this._updateBeforeCallback), e.addEventListener(\"dispose-model\", this._disposeModelCallback);\n }\n // update tile flattening state if it has not been made visible, yet\n setTileActive(e, t) {\n t && !this.positionsUpdated.has(e) && this._updateTile(e);\n }\n _updateTile(e) {\n const { positionsUpdated: t, positionsMap: s, shapes: n, tiles: i } = this;\n t.add(e);\n const r = e.engineData.scene;\n if (s.has(e)) {\n const o = s.get(e);\n r.traverse((l) => {\n if (l.geometry) {\n const c = o.get(l.geometry);\n c && (l.geometry.attributes.position.array.set(c), l.geometry.attributes.position.needsUpdate = !0);\n }\n });\n } else {\n const o = /* @__PURE__ */ new Map();\n s.set(e, o), r.traverse((l) => {\n l.geometry && o.set(l.geometry, l.geometry.attributes.position.array.slice());\n });\n }\n r.updateMatrixWorld(!0), r.traverse((o) => {\n const { geometry: l } = o;\n l && (Ee.copy(o.matrixWorld), r.parent !== null && Ee.premultiply(i.group.matrixWorldInverse), Vs.copy(Ee).invert(), ks(l, At).applyMatrix4(Ee), n.forEach(({\n shape: c,\n direction: u,\n sphere: h,\n thresholdMode: d,\n threshold: m,\n flattenRange: f\n }) => {\n je.subVectors(At.center, h.center), je.addScaledVector(u, -u.dot(je));\n const p = (At.radius + h.radius) ** 2;\n if (je.lengthSq() > p)\n return;\n const { position: g } = l.attributes, { ray: y } = It;\n y.direction.copy(u).multiplyScalar(-1);\n for (let x = 0, S = g.count; x < S; x++) {\n y.origin.fromBufferAttribute(g, x).applyMatrix4(Ee).addScaledVector(u, vt), It.far = vt;\n const T = It.intersectObject(c)[0];\n if (T) {\n let M = (vt - T.distance) / m;\n const _ = M >= 1;\n (!_ || _ && d === \"flatten\") && (M = Math.min(M, 1), T.point.addScaledVector(y.direction, b.mapLinear(M, 0, 1, -f, 0)), T.point.applyMatrix4(Vs), g.setXYZ(x, ...T.point));\n }\n }\n }));\n }), this.tiles.dispatchEvent({ type: \"needs-render\" });\n }\n _updateTiles() {\n this.positionsUpdated.clear(), this.tiles.activeTiles.forEach((e) => this._updateTile(e));\n }\n // API for updating and shapes to flatten the vertices\n hasShape(e) {\n return this.shapes.has(e);\n }\n addShape(e, t = new E(0, 0, -1), s = {}) {\n if (this.hasShape(e))\n throw new Error(\"TileFlatteningPlugin: Shape is already used.\");\n typeof s == \"number\" && (console.warn('TileFlatteningPlugin: \"addShape\" function signature has changed. Please use an options object, instead.'), s = {\n threshold: s\n }), this.needsUpdate = !0;\n const n = e.clone();\n n.updateMatrixWorld(!0), n.traverse((r) => {\n r.material && (r.material = gr);\n });\n const i = ks(n, new de());\n this.shapes.set(e, {\n shape: n,\n direction: t.clone(),\n sphere: i,\n // \"flatten\": Flattens the vertices above the shape\n // \"none\": leaves the vertices above the shape as they are\n thresholdMode: \"none\",\n // only flatten within this range above the object\n threshold: 1 / 0,\n // the range to flatten vertices in to. 0 is completely flat\n // while 0.1 means a 10cm range.\n flattenRange: 0,\n ...s\n });\n }\n updateShape(e) {\n if (!this.hasShape(e))\n throw new Error(\"TileFlatteningPlugin: Shape is not present.\");\n const { direction: t, threshold: s, thresholdMode: n, flattenRange: i } = this.shapes.get(e);\n this.deleteShape(e), this.addShape(e, t, {\n threshold: s,\n thresholdMode: n,\n flattenRange: i\n });\n }\n deleteShape(e) {\n return this.needsUpdate = !0, this.shapes.delete(e);\n }\n clearShapes() {\n this.shapes.size !== 0 && (this.needsUpdate = !0, this.shapes.clear());\n }\n // reset the vertex positions and remove the update callback\n dispose() {\n this.tiles.removeEventListener(\"before-update\", this._updateBeforeCallback), this.tiles.removeEventListener(\"dispose-model\", this._disposeModelCallback), this.positionsMap.forEach((e) => {\n e.forEach((t, s) => {\n const { position: n } = s.attributes;\n n.array.set(t), n.needsUpdate = !0;\n });\n });\n }\n}\nclass yr extends Ne {\n constructor(e = {}) {\n const {\n subdomains: t = [\"t0\"],\n ...s\n } = e;\n super(s), this.subdomains = t, this.subDomainIndex = 0;\n }\n getUrl(e, t, s) {\n return this.url.replace(/{\\s*subdomain\\s*}/gi, this._getSubdomain()).replace(/{\\s*quadkey\\s*}/gi, this._tileToQuadKey(e, t, s));\n }\n _tileToQuadKey(e, t, s) {\n let n = \"\";\n for (let i = s; i > 0; i--) {\n let r = 0;\n const o = 1 << i - 1;\n (e & o) !== 0 && (r += 1), (t & o) !== 0 && (r += 2), n += r.toString();\n }\n return n;\n }\n _getSubdomain() {\n return this.subDomainIndex = (this.subDomainIndex + 1) % this.subdomains.length, this.subdomains[this.subDomainIndex];\n }\n}\nfunction Lt(a, e, t, s) {\n let [n, i, r, o] = a;\n i += 1e-8, n += 1e-8, o -= 1e-8, r -= 1e-8;\n const l = Math.max(Math.min(e, t.maxLevel), t.minLevel), [c, u, h, d] = t.getTilesInRange(n, i, r, o, l, !0);\n for (let m = c; m <= h; m++)\n for (let f = u; f <= d; f++)\n s(m, f, l);\n}\nfunction xr(a, e, t) {\n const s = new E(), n = {}, i = [], r = a.getAttribute(\"position\");\n a.computeBoundingBox(), a.boundingBox.getCenter(s).applyMatrix4(e), t.getPositionToCartographic(s, n);\n const o = n.lat, l = n.lon;\n let c = 1 / 0, u = 1 / 0, h = 1 / 0, d = -1 / 0, m = -1 / 0, f = -1 / 0;\n for (let y = 0; y < r.count; y++)\n s.fromBufferAttribute(r, y).applyMatrix4(e), t.getPositionToCartographic(s, n), Math.abs(Math.abs(n.lat) - Math.PI / 2) < 1e-5 && (n.lon = l), Math.abs(l - n.lon) > Math.PI && (n.lon += Math.sign(l - n.lon) * Math.PI * 2), Math.abs(o - n.lat) > Math.PI && (n.lat += Math.sign(o - n.lat) * Math.PI * 2), i.push(n.lon, n.lat, n.height), c = Math.min(c, n.lat), d = Math.max(d, n.lat), u = Math.min(u, n.lon), m = Math.max(m, n.lon), h = Math.min(h, n.height), f = Math.max(f, n.height);\n const p = [u, c, m, d], g = [...p, h, f];\n return {\n uv: i,\n range: p,\n region: g\n };\n}\nfunction Gs(a, e, t = null, s = null) {\n let n = 1 / 0, i = 1 / 0, r = 1 / 0, o = -1 / 0, l = -1 / 0, c = -1 / 0;\n const u = [], h = new K();\n a.forEach((m) => {\n h.copy(m.matrixWorld), t && h.premultiply(t);\n const { uv: f, region: p } = xr(m.geometry, h, e);\n u.push(f), n = Math.min(n, p[1]), o = Math.max(o, p[3]), i = Math.min(i, p[0]), l = Math.max(l, p[2]), r = Math.min(r, p[4]), c = Math.max(c, p[5]);\n });\n let d = [i, n, l, o];\n if (s !== null) {\n d = s.clampToBounds([i, n, l, o]);\n const [m, f, p, g] = s.toNormalizedRange(d);\n u.forEach((y) => {\n for (let x = 0, S = y.length; x < S; x += 3) {\n const T = y[x + 0], M = y[x + 1], _ = y[x + 2], [C, v] = s.toNormalizedPoint(T, M);\n y[x + 0] = b.mapLinear(C, m, p, 0, 1), y[x + 1] = b.mapLinear(v, f, g, 0, 1), y[x + 2] = b.mapLinear(_, r, c, 0, 1);\n }\n });\n }\n return {\n uvs: u,\n range: d,\n region: [i, n, l, o, r, c]\n };\n}\nfunction Tr(a, e) {\n const t = new E(), s = [], n = a.getAttribute(\"position\");\n let i = 1 / 0, r = 1 / 0, o = 1 / 0, l = -1 / 0, c = -1 / 0, u = -1 / 0;\n for (let d = 0; d < n.count; d++)\n t.fromBufferAttribute(n, d).applyMatrix4(e), s.push(t.x, t.y, t.z), i = Math.min(i, t.x), l = Math.max(l, t.x), r = Math.min(r, t.y), c = Math.max(c, t.y), o = Math.min(o, t.z), u = Math.max(u, t.z);\n return {\n uv: s,\n range: [i, r, l, c],\n heightRange: [o, u]\n };\n}\nfunction br(a, e) {\n let t = 1 / 0, s = 1 / 0, n = 1 / 0, i = -1 / 0, r = -1 / 0, o = -1 / 0;\n const l = [], c = new K();\n return a.forEach((u) => {\n c.copy(u.matrixWorld), e && c.premultiply(e);\n const { uv: h, range: d, heightRange: m } = Tr(u.geometry, c);\n l.push(h), t = Math.min(t, d[0]), i = Math.max(i, d[2]), s = Math.min(s, d[1]), r = Math.max(r, d[3]), n = Math.min(n, m[0]), o = Math.max(o, m[1]);\n }), l.forEach((u) => {\n for (let h = 0, d = u.length; h < d; h += 3) {\n const m = u[h + 0], f = u[h + 1];\n u[h + 0] = b.mapLinear(m, t, i, 0, 1), u[h + 1] = b.mapLinear(f, s, r, 0, 1);\n }\n }), {\n uvs: l,\n range: [t, s, i, r],\n heightRange: [n, o]\n };\n}\nconst Et = Symbol(\"OVERLAY_PARAMS\");\nfunction _r(a, e) {\n if (a[Et])\n return a[Et];\n const t = {\n layerMaps: { value: [] },\n layerInfo: { value: [] }\n };\n return a[Et] = t, a.defines = {\n ...a.defines || {},\n LAYER_COUNT: 0\n }, a.onBeforeCompile = (s) => {\n e && e(s), s.uniforms = {\n ...s.uniforms,\n ...t\n }, s.vertexShader = s.vertexShader.replace(/void main\\(\\s*\\)\\s*{/, (n) => (\n /* glsl */\n `\n\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\tfor ( int i = 0; i < 10; i ++ ) {\n\n\t\t\t\t\t\t#if UNROLLED_LOOP_INDEX < LAYER_COUNT\n\n\t\t\t\t\t\t\tattribute vec3 layer_uv_UNROLLED_LOOP_INDEX;\n\t\t\t\t\t\t\tvarying vec3 v_layer_uv_UNROLLED_LOOP_INDEX;\n\n\t\t\t\t\t\t#endif\n\n\n\t\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t${n}\n\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\tfor ( int i = 0; i < 10; i ++ ) {\n\n\t\t\t\t\t\t#if UNROLLED_LOOP_INDEX < LAYER_COUNT\n\n\t\t\t\t\t\t\tv_layer_uv_UNROLLED_LOOP_INDEX = layer_uv_UNROLLED_LOOP_INDEX;\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t`\n )), s.fragmentShader = s.fragmentShader.replace(/void main\\(/, (n) => (\n /* glsl */\n `\n\n\t\t\t\t#if LAYER_COUNT != 0\n\t\t\t\t\tstruct LayerInfo {\n\t\t\t\t\t\tvec3 color;\n\t\t\t\t\t\tfloat opacity;\n\n\t\t\t\t\t\tint alphaMask;\n\t\t\t\t\t\tint alphaInvert;\n\t\t\t\t\t};\n\n\t\t\t\t\tuniform sampler2D layerMaps[ LAYER_COUNT ];\n\t\t\t\t\tuniform LayerInfo layerInfo[ LAYER_COUNT ];\n\t\t\t\t#endif\n\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\tfor ( int i = 0; i < 10; i ++ ) {\n\n\t\t\t\t\t\t#if UNROLLED_LOOP_INDEX < LAYER_COUNT\n\n\t\t\t\t\t\t\tvarying vec3 v_layer_uv_UNROLLED_LOOP_INDEX;\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t${n}\n\n\t\t\t`\n )).replace(/#include <color_fragment>/, (n) => (\n /* glsl */\n `\n\n\t\t\t\t${n}\n\n\t\t\t\t#if LAYER_COUNT != 0\n\t\t\t\t{\n\t\t\t\t\tvec4 tint;\n\t\t\t\t\tvec3 layerUV;\n\t\t\t\t\tfloat layerOpacity;\n\t\t\t\t\tfloat wOpacity;\n\t\t\t\t\tfloat wDelta;\n\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < 10; i ++ ) {\n\n\t\t\t\t\t\t\t#if UNROLLED_LOOP_INDEX < LAYER_COUNT\n\n\t\t\t\t\t\t\t\tlayerUV = v_layer_uv_UNROLLED_LOOP_INDEX;\n\t\t\t\t\t\t\t\ttint = texture( layerMaps[ i ], layerUV.xy );\n\n\t\t\t\t\t\t\t\t// discard texture outside 0, 1 on w - offset the stepped value by an epsilon to avoid cases\n\t\t\t\t\t\t\t\t// where wDelta is near 0 (eg a flat surface) at the w boundary, resulting in artifacts on some\n\t\t\t\t\t\t\t\t// hardware.\n\t\t\t\t\t\t\t\twDelta = max( fwidth( layerUV.z ), 1e-7 );\n\t\t\t\t\t\t\t\twOpacity =\n\t\t\t\t\t\t\t\t\tsmoothstep( - wDelta, 0.0, layerUV.z ) *\n\t\t\t\t\t\t\t\t\tsmoothstep( 1.0 + wDelta, 1.0, layerUV.z );\n\n\t\t\t\t\t\t\t\t// apply tint & opacity\n\t\t\t\t\t\t\t\ttint.rgb *= layerInfo[ i ].color;\n\t\t\t\t\t\t\t\ttint.rgba *= layerInfo[ i ].opacity * wOpacity;\n\n\t\t\t\t\t\t\t\t// invert the alpha\n\t\t\t\t\t\t\t\tif ( layerInfo[ i ].alphaInvert > 0 ) {\n\n\t\t\t\t\t\t\t\t\ttint.a = 1.0 - tint.a;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// apply the alpha across all existing layers if alpha mask is true\n\t\t\t\t\t\t\t\tif ( layerInfo[ i ].alphaMask > 0 ) {\n\n\t\t\t\t\t\t\t\t\tdiffuseColor.a *= tint.a;\n\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\ttint.rgb *= tint.a;\n\t\t\t\t\t\t\t\t\tdiffuseColor = tint + diffuseColor * ( 1.0 - tint.a );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t#endif\n\n\t\t\t\t\t\t}\n\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t`\n ));\n }, t;\n}\nclass In {\n constructor() {\n this.canvas = null, this.context = null, this.range = [0, 0, 1, 1];\n }\n // set the target render texture and the range that represents the full span\n setTarget(e, t) {\n this.canvas = e.image, this.context = e.image.getContext(\"2d\"), this.range = [...t];\n }\n // draw the given texture at the given span with the provided projection\n draw(e, t) {\n const { canvas: s, range: n, context: i } = this, { width: r, height: o } = s, { image: l } = e, c = Math.round(b.mapLinear(t[0], n[0], n[2], 0, r)), u = Math.round(b.mapLinear(t[1], n[1], n[3], 0, o)), h = Math.round(b.mapLinear(t[2], n[0], n[2], 0, r)), d = Math.round(b.mapLinear(t[3], n[1], n[3], 0, o)), m = h - c, f = d - u;\n l instanceof ImageBitmap ? (i.save(), i.translate(c, o - u), i.scale(1, -1), i.drawImage(l, 0, 0, m, f), i.restore()) : i.drawImage(l, c, o - u, m, -f);\n }\n // clear the set target\n clear() {\n const { context: e, canvas: t } = this;\n e.clearRect(0, 0, t.width, t.height);\n }\n}\nclass vn extends fn {\n hasContent(...e) {\n return !0;\n }\n}\nclass Sr extends vn {\n constructor(e) {\n super(), this.tiledImageSource = e, this.tileComposer = new In(), this.resolution = 256;\n }\n hasContent(e, t, s, n, i) {\n const r = this.tiledImageSource.tiling;\n let o = 0;\n return Lt([e, t, s, n], i, r, () => {\n o++;\n }), o !== 0;\n }\n async fetchItem([e, t, s, n, i], r) {\n const o = [e, t, s, n], l = this.tiledImageSource, c = this.tileComposer, u = l.tiling, h = document.createElement(\"canvas\");\n h.width = this.resolution, h.height = this.resolution;\n const d = new Yt(h);\n return d.colorSpace = qt, d.generateMipmaps = !1, d.tokens = [...o, i], await this._markImages(o, i, !1), c.setTarget(d, o), c.clear(16777215, 0), Lt(o, i, u, (m, f, p) => {\n const g = u.getTileBounds(m, f, p, !0, !1), y = l.get(m, f, p);\n c.draw(y, g);\n }), d;\n }\n disposeItem(e) {\n e.dispose();\n const [t, s, n, i, r] = e.tokens;\n this._markImages([t, s, n, i], r, !0);\n }\n dispose() {\n super.dispose(), this.tiledImageSource.dispose();\n }\n _markImages(e, t, s = !1) {\n const n = this.tiledImageSource, i = n.tiling, r = [];\n Lt(e, t, i, (l, c, u) => {\n s ? n.release(l, c, u) : r.push(n.lock(l, c, u));\n });\n const o = r.filter((l) => l instanceof Promise);\n return o.length !== 0 ? Promise.all(o) : null;\n }\n}\nconst wt = /* @__PURE__ */ new E(), Ye = /* @__PURE__ */ new E();\nfunction Mr(a, e, t) {\n a.getCartographicToPosition(e, t, 0, wt), a.getCartographicToPosition(e + 0.01, t, 0, Ye);\n const n = wt.distanceTo(Ye);\n return a.getCartographicToPosition(e, t + 0.01, 0, Ye), wt.distanceTo(Ye) / n;\n}\nclass Cr extends vn {\n constructor({\n geojson: e = null,\n url: t = null,\n // URL or GeoJson object can be provided\n resolution: s = 256,\n pointRadius: n = 6,\n strokeStyle: i = \"white\",\n strokeWidth: r = 2,\n fillStyle: o = \"rgba( 255, 255, 255, 0.5 )\",\n ...l\n } = {}) {\n super(l), this.geojson = e, this.url = t, this.resolution = s, this.pointRadius = n, this.strokeStyle = i, this.strokeWidth = r, this.fillStyle = o, this.features = null, this.featureBounds = /* @__PURE__ */ new Map(), this.contentBounds = null, this.projection = new re(), this.fetchData = (...c) => fetch(...c);\n }\n async init() {\n const { geojson: e, url: t } = this;\n if (!e && t) {\n const s = await this.fetchData(t);\n this.geojson = await s.json();\n }\n this._updateCache(!0);\n }\n hasContent(e, t, s, n) {\n const i = [e, t, s, n].map((r) => r * Math.RAD2DEG);\n return this._boundsIntersectBounds(i, this.contentBounds);\n }\n // main fetch per region -> returns CanvasTexture\n async fetchItem(e, t) {\n const s = document.createElement(\"canvas\"), n = new Yt(s);\n return n.colorSpace = qt, n.generateMipmaps = !1, this._drawToCanvas(s, e), n.needsUpdate = !0, n;\n }\n disposeItem(e) {\n e.dispose();\n }\n redraw() {\n this._updateCache(!0), this.forEachItem((e, t) => {\n this._drawToCanvas(e.image, t), e.needsUpdate = !0;\n });\n }\n _updateCache(e = !1) {\n const { geojson: t, featureBounds: s } = this;\n if (!t || this.features && !e)\n return;\n s.clear();\n let n = 1 / 0, i = 1 / 0, r = -1 / 0, o = -1 / 0;\n this.features = this._featuresFromGeoJSON(t), this.features.forEach((l) => {\n const c = this._getFeatureBounds(l);\n s.set(l, c);\n const [u, h, d, m] = c;\n n = Math.min(n, u), i = Math.min(i, h), r = Math.max(r, d), o = Math.max(o, m);\n }), this.contentBounds = [n, i, r, o];\n }\n _drawToCanvas(e, t) {\n this._updateCache();\n const [s, n, i, r] = t, { projection: o, resolution: l, features: c } = this;\n e.width = l, e.height = l;\n const u = o.convertNormalizedToLongitude(s), h = o.convertNormalizedToLatitude(n), d = o.convertNormalizedToLongitude(i), m = o.convertNormalizedToLatitude(r), f = [\n u * b.RAD2DEG,\n h * b.RAD2DEG,\n d * b.RAD2DEG,\n m * b.RAD2DEG\n ], p = e.getContext(\"2d\");\n for (let g = 0; g < c.length; g++) {\n const y = c[g];\n this._featureIntersectsTile(y, f) && this._drawFeatureOnCanvas(p, y, f, e.width, e.height);\n }\n }\n // bounding box quick test in projected units\n _featureIntersectsTile(e, t) {\n const s = this.featureBounds.get(e);\n return s ? this._boundsIntersectBounds(s, t) : !1;\n }\n _boundsIntersectBounds(e, t) {\n const [s, n, i, r] = e, [o, l, c, u] = t;\n return !(i < o || s > c || r < l || n > u);\n }\n _getFeatureBounds(e) {\n const { geometry: t } = e;\n if (!t)\n return null;\n const { type: s, coordinates: n } = t;\n let i = 1 / 0, r = 1 / 0, o = -1 / 0, l = -1 / 0;\n const c = (u, h) => {\n i = Math.min(i, u), o = Math.max(o, u), r = Math.min(r, h), l = Math.max(l, h);\n };\n return s === \"Point\" ? c(n[0], n[1]) : s === \"MultiPoint\" || s === \"LineString\" ? n.forEach((u) => c(u[0], u[1])) : s === \"MultiLineString\" || s === \"Polygon\" ? n.forEach((u) => u.forEach((h) => c(h[0], h[1]))) : s === \"MultiPolygon\" && n.forEach(\n (u) => u.forEach((h) => h.forEach((d) => c(d[0], d[1])))\n ), [i, r, o, l];\n }\n // Normalize top-level geojson into an array of Feature objects\n _featuresFromGeoJSON(e) {\n const t = e.type, s = /* @__PURE__ */ new Set([\"Point\", \"MultiPoint\", \"LineString\", \"MultiLineString\", \"Polygon\", \"MultiPolygon\"]);\n return t === \"FeatureCollection\" ? e.features : t === \"Feature\" ? [e] : t === \"GeometryCollection\" ? e.geometries.map((n) => ({ type: \"Feature\", geometry: n, properties: {} })) : s.has(t) ? [{ type: \"Feature\", geometry: e, properties: {} }] : [];\n }\n // draw feature on canvas ( assumes intersects already )\n _drawFeatureOnCanvas(e, t, s, n, i) {\n const { geometry: r = null, properties: o = {} } = t;\n if (!r)\n return;\n const [l, c, u, h] = s, d = o.strokeStyle || this.strokeStyle, m = o.fillStyle || this.fillStyle, f = o.pointRadius || this.pointRadius, p = o.strokeWidth || this.strokeWidth;\n e.save(), e.strokeStyle = d, e.fillStyle = m, e.lineWidth = p;\n const g = new Array(2), y = (T, M, _ = g) => {\n const C = b.mapLinear(T, l, u, 0, n), v = i - b.mapLinear(M, c, h, 0, i);\n return _[0] = Math.round(C), _[1] = Math.round(v), _;\n }, x = (T, M) => {\n const _ = M * b.DEG2RAD, C = T * b.DEG2RAD, v = (h - c) / i;\n return (u - l) / n / v * Mr(di, _, C);\n }, S = r.type;\n if (S === \"Point\") {\n const [T, M] = r.coordinates, [_, C] = y(T, M), v = x(T, M);\n e.beginPath(), e.ellipse(_, C, f / v, f, 0, 0, Math.PI * 2), e.fill(), e.stroke();\n } else S === \"MultiPoint\" ? r.coordinates.forEach(([T, M]) => {\n const [_, C] = y(T, M), v = x(T, M);\n e.beginPath(), e.ellipse(_, C, f / v, f, 0, 0, Math.PI * 2), e.fill(), e.stroke();\n }) : S === \"LineString\" ? (e.beginPath(), r.coordinates.forEach(([T, M], _) => {\n const [C, v] = y(T, M);\n _ === 0 ? e.moveTo(C, v) : e.lineTo(C, v);\n }), e.stroke()) : S === \"MultiLineString\" ? (e.beginPath(), r.coordinates.forEach((T) => {\n T.forEach(([M, _], C) => {\n const [v, P] = y(M, _);\n C === 0 ? e.moveTo(v, P) : e.lineTo(v, P);\n });\n }), e.stroke()) : S === \"Polygon\" ? (e.beginPath(), r.coordinates.forEach((T, M) => {\n T.forEach(([_, C], v) => {\n const [P, R] = y(_, C);\n v === 0 ? e.moveTo(P, R) : e.lineTo(P, R);\n }), e.closePath();\n }), e.fill(\"evenodd\"), e.stroke()) : S === \"MultiPolygon\" && r.coordinates.forEach((T) => {\n e.beginPath(), T.forEach((M, _) => {\n M.forEach(([C, v], P) => {\n const [R, V] = y(C, v);\n P === 0 ? e.moveTo(R, V) : e.lineTo(R, V);\n }), e.closePath();\n }), e.fill(\"evenodd\"), e.stroke();\n });\n e.restore();\n }\n}\nconst _e = /* @__PURE__ */ new K(), Xe = /* @__PURE__ */ new E(), Pt = /* @__PURE__ */ new E(), Rt = /* @__PURE__ */ new E(), se = /* @__PURE__ */ new E(), Ar = /* @__PURE__ */ new ct(), zs = Symbol(\"SPLIT_TILE_DATA\"), $e = Symbol(\"SPLIT_HASH\"), Qe = Symbol(\"ORIGINAL_REFINE\");\nclass mo {\n get enableTileSplitting() {\n return this._enableTileSplitting;\n }\n set enableTileSplitting(e) {\n this._enableTileSplitting !== e && (this._enableTileSplitting = e, this._markNeedsUpdate());\n }\n constructor(e = {}) {\n const {\n overlays: t = [],\n resolution: s = 256,\n enableTileSplitting: n = !0\n } = e;\n this.name = \"IMAGE_OVERLAY_PLUGIN\", this.priority = -15, this.resolution = s, this._enableTileSplitting = n, this.overlays = [], this.needsUpdate = !1, this.tiles = null, this.tileComposer = null, this.tileControllers = /* @__PURE__ */ new Map(), this.overlayInfo = /* @__PURE__ */ new Map(), this.meshParams = /* @__PURE__ */ new WeakMap(), this.pendingTiles = /* @__PURE__ */ new Map(), this.processedTiles = /* @__PURE__ */ new Set(), this.processQueue = null, this._onUpdateAfter = null, this._onTileDownloadStart = null, this._virtualChildResetId = 0, this._bytesUsed = /* @__PURE__ */ new WeakMap(), t.forEach((i) => {\n this.addOverlay(i);\n });\n }\n // plugin functions\n init(e) {\n const t = new In(), s = new xi();\n s.maxJobs = 10, s.priorityCallback = (n, i) => {\n const r = n.tile, o = i.tile, l = e.visibleTiles.has(r), c = e.visibleTiles.has(o);\n return l !== c ? l ? 1 : -1 : e.downloadQueue.priorityCallback(r, o);\n }, this.tiles = e, this.tileComposer = t, this.processQueue = s, e.forEachLoadedModel((n, i) => {\n this._processTileModel(n, i, !0);\n }), this._onUpdateAfter = async () => {\n let n = !1;\n if (this.overlayInfo.forEach((i, r) => {\n if (!!r.frame != !!i.frame || r.frame && i.frame && !i.frame.equals(r.frame)) {\n const o = i.order;\n this.deleteOverlay(r), this.addOverlay(r, o), n = !0;\n }\n }), n) {\n const i = s.maxJobs;\n let r = 0;\n s.items.forEach((o) => {\n e.visibleTiles.has(o.tile) && r++;\n }), s.maxJobs = r + s.currJobs, s.tryRunJobs(), s.maxJobs = i, this.needsUpdate = !0;\n }\n if (this.needsUpdate) {\n this.needsUpdate = !1;\n const { overlays: i, overlayInfo: r } = this;\n i.sort((o, l) => r.get(o).order - r.get(l).order), this.processedTiles.forEach((o) => {\n this._updateLayers(o);\n }), this.resetVirtualChildren(!this.enableTileSplitting), e.recalculateBytesUsed(), e.dispatchEvent({ type: \"needs-rerender\" });\n }\n }, this._onTileDownloadStart = ({ tile: n, url: i }) => {\n !/\\.json$/i.test(i) && !/\\.subtree/i.test(i) && (this.processedTiles.add(n), this._initTileOverlayInfo(n));\n }, e.addEventListener(\"update-after\", this._onUpdateAfter), e.addEventListener(\"tile-download-start\", this._onTileDownloadStart), this.overlays.forEach((n) => {\n this._initOverlay(n);\n });\n }\n _removeVirtualChildren(e) {\n if (!(Qe in e))\n return;\n const { tiles: t } = this, { virtualChildCount: s } = e.internal, n = e.children.length, i = n - s;\n for (let r = i; r < n; r++) {\n const o = e.children[r];\n t.processNodeQueue.remove(o), t.lruCache.remove(o), o.parent = null;\n }\n e.children.length -= s, e.internal.virtualChildCount = 0, e.refine = e[Qe], delete e[Qe], delete e[$e];\n }\n disposeTile(e) {\n const { overlayInfo: t, tileControllers: s, processQueue: n, pendingTiles: i, processedTiles: r } = this;\n r.delete(e), this._removeVirtualChildren(e), s.has(e) && (s.get(e).abort(), s.delete(e), i.delete(e)), t.forEach((({ tileInfo: o }, l) => {\n if (o.has(e)) {\n const { meshInfo: c, range: u } = o.get(e);\n u !== null && l.releaseTexture(u, e), o.delete(e), c.clear();\n }\n })), n.removeByFilter((o) => o.tile === e);\n }\n calculateBytesUsed(e) {\n const { overlayInfo: t } = this, s = this._bytesUsed;\n let n = null;\n return t.forEach(({ tileInfo: i }, r) => {\n if (i.has(e)) {\n const { target: o } = i.get(e);\n n = n || 0, n += pi(o);\n }\n }), n !== null ? (s.set(e, n), n) : s.has(e) ? s.get(e) : 0;\n }\n processTileModel(e, t) {\n return this._processTileModel(e, t);\n }\n async _processTileModel(e, t, s = !1) {\n const { tileControllers: n, processedTiles: i, pendingTiles: r } = this;\n n.set(t, new AbortController()), s || r.set(t, e), i.add(t), this._wrapMaterials(e), this._initTileOverlayInfo(t), await this._initTileSceneOverlayInfo(e, t), this.expandVirtualChildren(e, t), this._updateLayers(t), r.delete(t);\n }\n dispose() {\n const { tiles: e } = this;\n [...this.overlays].forEach((s) => {\n this.deleteOverlay(s);\n }), this.processedTiles.forEach((s) => {\n this._updateLayers(s), this.disposeTile(s);\n }), e.removeEventListener(\"update-after\", this._onUpdateAfter), this.resetVirtualChildren(!0);\n }\n getAttributions(e) {\n this.overlays.forEach((t) => {\n t.opacity > 0 && t.getAttributions(e);\n });\n }\n parseToMesh(e, t, s, n) {\n if (s === \"image_overlay_tile_split\")\n return t[zs];\n }\n async resetVirtualChildren(e = !1) {\n this._virtualChildResetId++;\n const t = this._virtualChildResetId;\n if (await Promise.all(this.overlays.map((i) => i.whenReady())), t !== this._virtualChildResetId)\n return;\n const { tiles: s } = this, n = [];\n this.processedTiles.forEach((i) => {\n $e in i && n.push(i);\n }), n.sort((i, r) => r.internal.depth - i.internal.depth), n.forEach((i) => {\n const r = i.engineData.scene.clone();\n r.updateMatrixWorld(), (e || i[$e] !== this._getSplitVectors(r, i).hash) && this._removeVirtualChildren(i);\n }), e || s.forEachLoadedModel((i, r) => {\n this.expandVirtualChildren(i, r);\n });\n }\n _getSplitVectors(e, t, s = Pt) {\n const { tiles: n, overlayInfo: i } = this, r = new ct();\n r.setFromObject(e), r.getCenter(s);\n const o = [], l = [];\n i.forEach(({ tileInfo: u }, h) => {\n const d = u.get(t);\n if (d && d.target && h.shouldSplit(d.range, t)) {\n h.frame ? se.set(0, 0, 1).transformDirection(h.frame) : (n.ellipsoid.getPositionToNormal(s, se), se.length() < 1e-6 && se.set(1, 0, 0));\n const m = `${se.x.toFixed(3)},${se.y.toFixed(3)},${se.z.toFixed(3)}_`;\n l.includes(m) || l.push(m);\n const f = Xe.set(0, 0, 1);\n Math.abs(se.dot(f)) > 1 - 1e-4 && f.set(1, 0, 0);\n const p = new E().crossVectors(se, f).normalize(), g = new E().crossVectors(se, p).normalize();\n o.push(p, g);\n }\n });\n const c = [];\n for (; o.length !== 0; ) {\n const u = o.pop().clone(), h = u.clone();\n for (let d = 0; d < o.length; d++) {\n const m = o[d], f = u.dot(m);\n Math.abs(f) > Math.cos(Math.PI / 8) && (h.addScaledVector(m, Math.sign(f)), u.copy(h).normalize(), o.splice(d, 1), d--);\n }\n c.push(h.normalize());\n }\n return { directions: c, hash: l.join(\"\") };\n }\n async expandVirtualChildren(e, t) {\n const { refine: s } = t, n = s === \"REPLACE\" && t.children.length === 0 || s === \"ADD\", i = t.internal.virtualChildCount !== 0;\n if (this.enableTileSplitting === !1 || !n || i)\n return;\n const r = e.clone();\n r.updateMatrixWorld();\n const { directions: o, hash: l } = this._getSplitVectors(r, t, Pt);\n if (o.length === 0)\n return;\n t[$e] = l;\n const c = new xn();\n c.attributeList = (h) => !/^layer_uv_\\d+/.test(h), o.map((h) => {\n c.addSplitOperation((d, m, f, p, g, y) => (jt.getInterpolatedAttribute(d.attributes.position, m, f, p, g, Xe), Xe.applyMatrix4(y).sub(Pt).dot(h)));\n });\n const u = [];\n c.forEachSplitPermutation(() => {\n const h = c.clipObject(r);\n h.matrix.premultiply(t.engineData.transformInverse).decompose(h.position, h.quaternion, h.scale);\n const d = [];\n if (h.traverse((f) => {\n if (f.isMesh) {\n const p = f.material.clone();\n f.material = p;\n for (const g in p) {\n const y = p[g];\n if (y && y.isTexture && y.source.data instanceof ImageBitmap) {\n const x = document.createElement(\"canvas\");\n x.width = y.image.width, x.height = y.image.height;\n const S = x.getContext(\"2d\");\n S.scale(1, -1), S.drawImage(y.source.data, 0, 0, x.width, -x.height);\n const T = new Yt(x);\n T.mapping = y.mapping, T.wrapS = y.wrapS, T.wrapT = y.wrapT, T.minFilter = y.minFilter, T.magFilter = y.magFilter, T.format = y.format, T.type = y.type, T.anisotropy = y.anisotropy, T.colorSpace = y.colorSpace, T.generateMipmaps = y.generateMipmaps, p[g] = T;\n }\n }\n d.push(f);\n }\n }), d.length === 0)\n return;\n const m = {};\n if (t.boundingVolume.region && (m.region = Gs(d, this.tiles.ellipsoid).region), t.boundingVolume.box || t.boundingVolume.sphere) {\n Ar.setFromObject(h, !0).getCenter(Rt);\n let f = 0;\n h.traverse((p) => {\n const g = p.geometry;\n if (g) {\n const y = g.attributes.position;\n for (let x = 0, S = y.count; x < S; x++) {\n const T = Xe.fromBufferAttribute(y, x).applyMatrix4(p.matrixWorld).distanceToSquared(Rt);\n f = Math.max(f, T);\n }\n }\n }), m.sphere = [...Rt, Math.sqrt(f)];\n }\n u.push({\n internal: { isVirtual: !0 },\n refine: \"REPLACE\",\n geometricError: t.geometricError * 0.5,\n boundingVolume: m,\n content: { uri: \"./child.image_overlay_tile_split\" },\n children: [],\n [zs]: h\n });\n }), t[Qe] = t.refine, t.refine = \"REPLACE\", t.children.push(...u), t.internal.virtualChildCount += u.length;\n }\n fetchData(e, t) {\n if (/image_overlay_tile_split/.test(e))\n return new ArrayBuffer();\n }\n // public\n addOverlay(e, t = null) {\n const { tiles: s, overlays: n, overlayInfo: i } = this;\n t === null && (t = n.reduce((o, l) => Math.max(o, l.order + 1), 0));\n const r = new AbortController();\n n.push(e), i.set(e, {\n order: t,\n uniforms: {},\n tileInfo: /* @__PURE__ */ new Map(),\n controller: r,\n frame: e.frame ? e.frame.clone() : null\n }), s !== null && this._initOverlay(e);\n }\n setOverlayOrder(e, t) {\n this.overlays.indexOf(e) !== -1 && (this.overlayInfo.get(e).order = t, this._markNeedsUpdate());\n }\n deleteOverlay(e) {\n const { overlays: t, overlayInfo: s, processQueue: n, processedTiles: i } = this, r = t.indexOf(e);\n if (r !== -1) {\n const { tileInfo: o, controller: l } = s.get(e);\n i.forEach((c) => {\n if (!o.has(c))\n return;\n const {\n meshInfo: u,\n range: h\n } = o.get(c);\n h !== null && e.releaseTexture(h, c), o.delete(c), u.clear();\n }), o.clear(), s.delete(e), l.abort(), n.removeByFilter((c) => c.overlay === e), t.splice(r, 1), i.forEach((c) => {\n this._updateLayers(c);\n }), this._markNeedsUpdate();\n }\n }\n // initialize the overlay to use the right fetch options, load all data for existing tiles\n _initOverlay(e) {\n const { tiles: t } = this;\n e.isInitialized || (e.init(), e.whenReady().then(() => {\n e.setResolution(this.resolution);\n const i = e.fetch.bind(e);\n e.fetch = (...r) => t.downloadQueue.add({ priority: -performance.now() }, () => i(...r));\n }));\n const s = [], n = async (i, r) => {\n this._initTileOverlayInfo(r, e);\n const o = this._initTileSceneOverlayInfo(i, r, e);\n s.push(o), await o, this._updateLayers(r);\n };\n t.forEachLoadedModel((i, r) => {\n n(i, r);\n }), this.pendingTiles.forEach((i, r) => {\n n(i, r);\n }), Promise.all(s).then(() => {\n this._markNeedsUpdate();\n });\n }\n // wrap all materials in the given scene wit the overlay material shader\n _wrapMaterials(e) {\n e.traverse((t) => {\n if (t.material) {\n const s = _r(t.material, t.material.onBeforeCompile);\n this.meshParams.set(t, s);\n }\n });\n }\n // Initialize per-tile overlay information. This function triggers an async function but\n // does not need to be awaited for use since it's just locking textures which are awaited later.\n _initTileOverlayInfo(e, t = this.overlays) {\n if (Array.isArray(t)) {\n t.forEach((i) => this._initTileOverlayInfo(e, i));\n return;\n }\n const { overlayInfo: s } = this;\n if (s.get(t).tileInfo.has(e))\n return;\n const n = {\n range: null,\n target: null,\n meshInfo: /* @__PURE__ */ new Map()\n };\n if (s.get(t).tileInfo.set(e, n), t.isReady && !t.isPlanarProjection) {\n if (e.boundingVolume.region) {\n const [i, r, o, l] = e.boundingVolume.region, c = t.projection.toNormalizedRange([i, r, o, l]);\n n.range = c, t.lockTexture(c, e);\n }\n }\n }\n // initialize the scene meshes\n async _initTileSceneOverlayInfo(e, t, s = this.overlays) {\n if (Array.isArray(s))\n return Promise.all(s.map((T) => this._initTileSceneOverlayInfo(e, t, T)));\n const { tiles: n, overlayInfo: i, tileControllers: r, processQueue: o } = this, { ellipsoid: l } = n, { controller: c, tileInfo: u } = i.get(s), h = r.get(t);\n if (s.isReady || await s.whenReady(), c.signal.aborted || h.signal.aborted)\n return;\n const d = [];\n e.updateMatrixWorld(), e.traverse((T) => {\n T.isMesh && d.push(T);\n });\n const { aspectRatio: m, projection: f } = s, p = u.get(t);\n let g, y, x;\n if (s.isPlanarProjection) {\n _e.makeScale(1 / m, 1, 1).multiply(s.frame), e.parent !== null && _e.multiply(n.group.matrixWorldInverse);\n let T;\n ({ range: g, uvs: y, heightRange: T } = br(d, _e)), x = !(T[0] > 1 || T[1] < 0);\n } else\n _e.identity(), e.parent !== null && _e.copy(n.group.matrixWorldInverse), { range: g, uvs: y } = Gs(d, l, _e, f), g = f.toNormalizedRange(g), x = !0;\n p.range === null ? (p.range = g, s.lockTexture(g, t)) : g = p.range;\n let S = null;\n x && s.hasContent(g, t) && (S = await o.add({ tile: t, overlay: s }, async () => {\n if (c.signal.aborted || h.signal.aborted)\n return null;\n const T = await s.getTexture(g, t);\n return c.signal.aborted || h.signal.aborted ? null : T;\n }).catch((T) => {\n if (!(T instanceof Ti))\n throw T;\n })), p.target = S, d.forEach((T, M) => {\n const _ = new Float32Array(y[M]), C = new J(_, 3);\n p.meshInfo.set(T, { attribute: C });\n });\n }\n _updateLayers(e) {\n const { overlayInfo: t, overlays: s, tileControllers: n, meshParams: i } = this, r = n.get(e);\n if (this.tiles.recalculateBytesUsed(e), !(!r || r.signal.aborted)) {\n if (s.length === 0) {\n const o = e.engineData && e.engineData.scene;\n o && o.traverse((l) => {\n if (l.material && i.has(l)) {\n const c = i.get(l);\n c.layerMaps.length = 0, c.layerInfo.length = 0, l.material.defines.LAYER_COUNT = 0, l.material.needsUpdate = !0;\n }\n });\n return;\n }\n s.forEach((o, l) => {\n const { tileInfo: c } = t.get(o), { meshInfo: u, target: h } = c.get(e);\n u.forEach(({ attribute: d }, m) => {\n const { geometry: f, material: p } = m, g = i.get(m), y = `layer_uv_${l}`;\n f.getAttribute(y) !== d && (f.setAttribute(y, d), f.dispose()), g.layerMaps.length = s.length, g.layerInfo.length = s.length, g.layerMaps.value[l] = h !== null ? h : null, g.layerInfo.value[l] = o, p.defines[`LAYER_${l}_EXISTS`] = +(h !== null), p.defines[`LAYER_${l}_ALPHA_INVERT`] = Number(o.alphaInvert), p.defines[`LAYER_${l}_ALPHA_MASK`] = Number(o.alphaMask), p.defines.LAYER_COUNT = s.length, p.needsUpdate = !0;\n });\n });\n }\n }\n _markNeedsUpdate() {\n this.needsUpdate === !1 && (this.needsUpdate = !0, this.tiles !== null && this.tiles.dispatchEvent({ type: \"needs-update\" }));\n }\n}\nclass Ln {\n get isPlanarProjection() {\n return !!this.frame;\n }\n constructor(e = {}) {\n const {\n opacity: t = 1,\n color: s = 16777215,\n frame: n = null,\n preprocessURL: i = null,\n alphaMask: r = !1,\n alphaInvert: o = !1\n } = e;\n this.preprocessURL = i, this.opacity = t, this.color = new on(s), this.frame = n !== null ? n.clone() : null, this.alphaMask = r, this.alphaInvert = o, this._whenReady = null, this.isReady = !1, this.isInitialized = !1;\n }\n init() {\n this.isInitialized = !0, this._whenReady = this._init().then(() => this.isReady = !0);\n }\n whenReady() {\n return this._whenReady;\n }\n // overrideable\n _init() {\n }\n fetch(e, t = {}) {\n return this.preprocessURL && (e = this.preprocessURL(e)), fetch(e, t);\n }\n getAttributions(e) {\n }\n hasContent(e, t) {\n return !1;\n }\n async getTexture(e, t) {\n return null;\n }\n async lockTexture(e, t) {\n return null;\n }\n releaseTexture(e, t) {\n }\n setResolution(e) {\n }\n shouldSplit(e, t) {\n return !1;\n }\n}\nclass Ce extends Ln {\n get tiling() {\n return this.imageSource.tiling;\n }\n get projection() {\n return this.tiling.projection;\n }\n get aspectRatio() {\n return this.tiling && this.isReady ? this.tiling.aspectRatio : 1;\n }\n get fetchOptions() {\n return this.imageSource.fetchOptions;\n }\n set fetchOptions(e) {\n this.imageSource.fetchOptions = e;\n }\n constructor(e = {}) {\n const { imageSource: t = null, ...s } = e;\n super(s), this.imageSource = t, this.regionImageSource = null;\n }\n _init() {\n return this._initImageSource().then(() => {\n this.imageSource.fetchData = (...e) => this.fetch(...e), this.regionImageSource = new Sr(this.imageSource);\n });\n }\n _initImageSource() {\n return this.imageSource.init();\n }\n // Texture acquisition API implementations\n calculateLevel(e, t) {\n if (this.isPlanarProjection) {\n const [s, n, i, r] = e, o = i - s, l = r - n;\n let c = 0;\n const u = this.regionImageSource.resolution, h = this.tiling.maxLevel;\n for (; c < h; c++) {\n const d = u / o, m = u / l, { pixelWidth: f, pixelHeight: p } = this.tiling.getLevel(c);\n if (f >= d || p >= m)\n break;\n }\n return c;\n } else\n return t.internal.depthFromRenderedParent - 1;\n }\n hasContent(e, t) {\n return this.regionImageSource.hasContent(...e, this.calculateLevel(e, t));\n }\n getTexture(e, t) {\n return this.regionImageSource.get(...e, this.calculateLevel(e, t));\n }\n lockTexture(e, t) {\n return this.regionImageSource.lock(...e, this.calculateLevel(e, t));\n }\n releaseTexture(e, t) {\n this.regionImageSource.release(...e, this.calculateLevel(e, t));\n }\n setResolution(e) {\n this.regionImageSource.resolution = e;\n }\n shouldSplit(e, t) {\n return this.tiling.maxLevel > this.calculateLevel(e, t);\n }\n}\nclass go extends Ce {\n constructor(e = {}) {\n super(e), this.imageSource = new Ne(e);\n }\n}\nclass yo extends Ln {\n get projection() {\n return this.imageSource.projection;\n }\n get aspectRatio() {\n return 2;\n }\n get pointRadius() {\n return this.imageSource.pointRadius;\n }\n set pointRadius(e) {\n this.imageSource.pointRadius = e;\n }\n get strokeStyle() {\n return this.imageSource.strokeStyle;\n }\n set strokeStyle(e) {\n this.imageSource.strokeStyle = e;\n }\n get strokeWidth() {\n return this.imageSource.strokeWidth;\n }\n set strokeWidth(e) {\n this.imageSource.strokeWidth = e;\n }\n get fillStyle() {\n return this.imageSource.fillStyle;\n }\n set fillStyle(e) {\n this.imageSource.fillStyle = e;\n }\n get geojson() {\n return this.imageSource.geojson;\n }\n set geojson(e) {\n this.imageSource.geojson = e;\n }\n constructor(e = {}) {\n super(e), this.imageSource = new Cr(e);\n }\n _init() {\n return this.imageSource.init();\n }\n hasContent(e) {\n return this.imageSource.hasContent(...e);\n }\n getTexture(e) {\n return this.imageSource.get(...e);\n }\n lockTexture(e) {\n return this.imageSource.lock(...e);\n }\n releaseTexture(e) {\n this.imageSource.release(...e);\n }\n setResolution(e) {\n this.imageSource.resolution = e;\n }\n shouldSplit(e, t) {\n return !0;\n }\n redraw() {\n this.imageSource.redraw();\n }\n}\nclass xo extends Ce {\n constructor(e = {}) {\n super(e), this.imageSource = new yn(e);\n }\n}\nclass To extends Ce {\n constructor(e = {}) {\n super(e), this.imageSource = new gn(e);\n }\n}\nclass bo extends Ce {\n constructor(e = {}) {\n super(e), this.imageSource = new Xt(e);\n }\n}\nclass _o extends Ce {\n constructor(e = {}) {\n super(e);\n const { apiToken: t, autoRefreshToken: s, assetId: n } = e;\n this.options = e, this.assetId = n, this.auth = new Gn({ apiToken: t, autoRefreshToken: s }), this.auth.authURL = `https://api.cesium.com/v1/assets/${n}/endpoint`, this._attributions = [], this.externalType = !1;\n }\n _initImageSource() {\n return this.auth.refreshToken().then(async (e) => {\n if (this._attributions = e.attributions.map((t) => ({\n value: t.html,\n type: \"html\",\n collapsible: t.collapsible\n })), e.type !== \"IMAGERY\")\n throw new Error(\"CesiumIonOverlay: Only IMAGERY is supported as overlay type.\");\n switch (this.externalType = !!e.externalType, e.externalType) {\n case \"GOOGLE_2D_MAPS\": {\n const { url: t, session: s, key: n, tileWidth: i } = e.options, r = `${t}/v1/2dtiles/{z}/{x}/{y}?session=${s}&key=${n}`;\n this.imageSource = new Ne({\n ...this.options,\n url: r,\n tileDimension: i,\n // Google maps tiles have a fixed depth of 22\n // https://developers.google.com/maps/documentation/tile/2d-tiles-overview\n levels: 22\n });\n break;\n }\n case \"BING\": {\n const { url: t, mapStyle: s, key: n } = e.options, i = `${t}/REST/v1/Imagery/Metadata/${s}?incl=ImageryProviders&key=${n}&uriScheme=https`, o = (await fetch(i).then((l) => l.json())).resourceSets[0].resources[0];\n this.imageSource = new yr({\n ...this.options,\n url: o.imageUrl,\n subdomains: o.imageUrlSubdomains,\n tileDimension: o.tileWidth,\n levels: o.zoomMax\n });\n break;\n }\n default:\n this.imageSource = new Xt({\n ...this.options,\n url: e.url\n });\n }\n return this.imageSource.fetchData = (...t) => this.fetch(...t), this.imageSource.init();\n });\n }\n fetch(...e) {\n return this.externalType ? super.fetch(...e) : this.auth.fetch(...e);\n }\n getAttributions(e) {\n e.push(...this._attributions);\n }\n}\nclass So extends Ce {\n constructor(e = {}) {\n super(e);\n const { apiToken: t, sessionOptions: s, autoRefreshToken: n, logoUrl: i } = e;\n this.logoUrl = i, this.auth = new zn({ apiToken: t, sessionOptions: s, autoRefreshToken: n }), this.imageSource = new Ne(), this.imageSource.fetchData = (...r) => this.fetch(...r), this._logoAttribution = {\n value: \"\",\n type: \"image\",\n collapsible: !1\n };\n }\n _initImageSource() {\n return this.auth.refreshToken().then((e) => (this.imageSource.tileDimension = e.tileWidth, this.imageSource.url = \"https://tile.googleapis.com/v1/2dtiles/{z}/{x}/{y}\", this.imageSource.init()));\n }\n fetch(...e) {\n return this.auth.fetch(...e);\n }\n getAttributions(e) {\n this.logoUrl && (this._logoAttribution.value = this.logoUrl, e.push(this._logoAttribution));\n }\n}\nclass Mo {\n constructor() {\n this.name = \"LOAD_REGION_PLUGIN\", this.regions = [], this.tiles = null;\n }\n init(e) {\n this.tiles = e;\n }\n addRegion(e) {\n this.regions.indexOf(e) === -1 && this.regions.push(e);\n }\n removeRegion(e) {\n const t = this.regions.indexOf(e);\n t !== -1 && this.regions.splice(t, 1);\n }\n hasRegion(e) {\n return this.regions.indexOf(e) !== -1;\n }\n clearRegions() {\n this.regions = [];\n }\n // Calculates shape intersections and associated error values to use. If \"mask\" shapes are present then\n // tiles are only loaded if they are within those shapes.\n calculateTileViewError(e, t) {\n const s = e.engineData.boundingVolume, { regions: n, tiles: i } = this;\n let r = !1, o = null, l = 0, c = 1 / 0;\n for (const u of n) {\n const h = u.intersectsTile(s, e, i);\n r = r || h, h && (l = Math.max(u.calculateError(e, i), l), c = Math.min(u.calculateDistance(s, e, i), c)), u.mask && (o = o || h);\n }\n return t.inView = r && o !== !1, t.error = l, t.distance = c, t.inView || o !== null;\n }\n dispose() {\n this.regions = [];\n }\n}\nclass Zt {\n constructor(e = {}) {\n typeof e == \"number\" && (console.warn(\"LoadRegionPlugin: Region constructor has been changed to take options as an object.\"), e = { errorTarget: e });\n const {\n errorTarget: t = 10,\n mask: s = !1\n } = e;\n this.errorTarget = t, this.mask = s;\n }\n intersectsTile(e, t, s) {\n return !1;\n }\n calculateDistance(e, t, s) {\n return 1 / 0;\n }\n calculateError(e, t) {\n return e.geometricError - this.errorTarget + t.errorTarget;\n }\n}\nclass Co extends Zt {\n constructor(e = {}) {\n typeof e == \"number\" && (console.warn(\"SphereRegion: Region constructor has been changed to take options as an object.\"), e = {\n errorTarget: arguments[0],\n sphere: arguments[1]\n });\n const { sphere: t = new de() } = e;\n super(e), this.sphere = t.clone();\n }\n intersectsTile(e) {\n return e.intersectsSphere(this.sphere);\n }\n}\nclass Ao extends Zt {\n constructor(e = {}) {\n typeof e == \"number\" && (console.warn(\"RayRegion: Region constructor has been changed to take options as an object.\"), e = {\n errorTarget: arguments[0],\n ray: arguments[1]\n });\n const { ray: t = new oi() } = e;\n super(e), this.ray = t.clone();\n }\n intersectsTile(e) {\n return e.intersectsRay(this.ray);\n }\n}\nclass Io extends Zt {\n constructor(e = {}) {\n typeof e == \"number\" && (console.warn(\"RayRegion: Region constructor has been changed to take options as an object.\"), e = {\n errorTarget: arguments[0],\n obb: arguments[1]\n });\n const { obb: t = new fi() } = e;\n super(e), this.obb = t.clone(), this.obb.update();\n }\n intersectsTile(e) {\n return e.intersectsOBB(this.obb);\n }\n}\nconst te = /* @__PURE__ */ new E(), Hs = [\"x\", \"y\", \"z\"];\nclass Ir extends an {\n constructor(e, t = 16776960, s = 40) {\n const n = new st(), i = [];\n for (let r = 0; r < 3; r++) {\n const o = Hs[r], l = Hs[(r + 1) % 3];\n te.set(0, 0, 0);\n for (let c = 0; c < s; c++) {\n let u;\n u = 2 * Math.PI * c / (s - 1), te[o] = Math.sin(u), te[l] = Math.cos(u), i.push(te.x, te.y, te.z), u = 2 * Math.PI * (c + 1) / (s - 1), te[o] = Math.sin(u), te[l] = Math.cos(u), i.push(te.x, te.y, te.z);\n }\n }\n n.setAttribute(\"position\", new J(new Float32Array(i), 3)), n.computeBoundingSphere(), super(n, new ai({ color: t, toneMapped: !1 })), this.sphere = e, this.type = \"SphereHelper\";\n }\n updateMatrixWorld(e) {\n const t = this.sphere;\n this.position.copy(t.center), this.scale.setScalar(t.radius), super.updateMatrixWorld(e);\n }\n}\nconst Dt = /* @__PURE__ */ new E(), Ze = /* @__PURE__ */ new E(), ne = /* @__PURE__ */ new E();\nfunction vr(a, { computeNormals: e = !1 } = {}) {\n const {\n latStart: t = -Math.PI / 2,\n latEnd: s = Math.PI / 2,\n lonStart: n = 0,\n lonEnd: i = 2 * Math.PI,\n heightStart: r = 0,\n heightEnd: o = 0\n } = a, l = new ln(1, 1, 1, 32, 32), { normal: c, position: u } = l.attributes, h = u.clone();\n for (let d = 0, m = u.count; d < m; d++) {\n ne.fromBufferAttribute(u, d);\n const f = b.mapLinear(ne.x, -0.5, 0.5, t, s), p = b.mapLinear(ne.y, -0.5, 0.5, n, i);\n let g = r;\n a.getCartographicToNormal(f, p, Dt), ne.z < 0 && (g = o), a.getCartographicToPosition(f, p, g, ne), u.setXYZ(d, ...ne);\n }\n e && l.computeVertexNormals();\n for (let d = 0, m = h.count; d < m; d++) {\n ne.fromBufferAttribute(h, d);\n const f = b.mapLinear(ne.x, -0.5, 0.5, t, s), p = b.mapLinear(ne.y, -0.5, 0.5, n, i);\n Dt.fromBufferAttribute(c, d), a.getCartographicToNormal(f, p, Ze), Math.abs(Dt.dot(Ze)) > 0.1 && (ne.z > 0 && Ze.multiplyScalar(-1), c.setXYZ(d, ...Ze));\n }\n return l;\n}\nclass Lr extends an {\n constructor(e = new mi(), t = 16776960) {\n super(), this.ellipsoidRegion = e, this.material.color.set(t), this.update();\n }\n update() {\n const e = vr(this.ellipsoidRegion);\n this.geometry.dispose(), this.geometry = new li(e, 80);\n }\n dispose() {\n this.geometry.dispose(), this.material.dispose();\n }\n}\nconst qs = Symbol(\"ORIGINAL_MATERIAL\"), Bt = Symbol(\"HAS_RANDOM_COLOR\"), Ot = Symbol(\"HAS_RANDOM_NODE_COLOR\"), Ut = Symbol(\"LOAD_TIME\"), ge = Symbol(\"PARENT_BOUND_REF_COUNT\"), Ws = /* @__PURE__ */ new de(), Je = () => {\n}, Nt = {};\nfunction Ke(a) {\n if (!Nt[a]) {\n const e = Math.random(), t = 0.5 + Math.random() * 0.5, s = 0.375 + Math.random() * 0.25;\n Nt[a] = new on().setHSL(e, t, s);\n }\n return Nt[a];\n}\nconst Re = 0, En = 1, wn = 2, Pn = 3, Rn = 4, Dn = 5, Bn = 6, et = 7, tt = 8, On = 9, kt = 10, Er = Object.freeze({\n NONE: Re,\n SCREEN_ERROR: En,\n GEOMETRIC_ERROR: wn,\n DISTANCE: Pn,\n DEPTH: Rn,\n RELATIVE_DEPTH: Dn,\n IS_LEAF: Bn,\n RANDOM_COLOR: et,\n RANDOM_NODE_COLOR: tt,\n CUSTOM_COLOR: On,\n LOAD_ORDER: kt\n});\nclass vo {\n static get ColorModes() {\n return Er;\n }\n get unlit() {\n return this._unlit;\n }\n set unlit(e) {\n e !== this._unlit && (this._unlit = e, this.materialsNeedUpdate = !0);\n }\n get colorMode() {\n return this._colorMode;\n }\n set colorMode(e) {\n e !== this._colorMode && (this._colorMode = e, this.materialsNeedUpdate = !0);\n }\n get enabled() {\n return this._enabled;\n }\n set enabled(e) {\n e !== this._enabled && this.tiles !== null && (this._enabled = e, e ? this.init(this.tiles) : this.dispose());\n }\n get displayParentBounds() {\n return this._displayParentBounds;\n }\n set displayParentBounds(e) {\n this._displayParentBounds !== e && (this._displayParentBounds = e, e ? this.tiles.traverse((t) => {\n t.traversal.visible && this._onTileVisibilityChange(t, !0);\n }) : this.tiles.traverse((t) => {\n t[ge] = null, this._onTileVisibilityChange(t, t.traversal.visible);\n }));\n }\n constructor(e) {\n e = {\n displayParentBounds: !1,\n displayBoxBounds: !1,\n displaySphereBounds: !1,\n displayRegionBounds: !1,\n colorMode: Re,\n maxDebugDepth: -1,\n maxDebugDistance: -1,\n maxDebugError: -1,\n customColorCallback: null,\n unlit: !1,\n enabled: !0,\n ...e\n }, this.name = \"DEBUG_TILES_PLUGIN\", this.tiles = null, this._colorMode = null, this._unlit = null, this.materialsNeedUpdate = !1, this.extremeDebugDepth = -1, this.extremeDebugError = -1, this.boxGroup = null, this.sphereGroup = null, this.regionGroup = null, this._enabled = e.enabled, this._displayParentBounds = e.displayParentBounds, this.displayBoxBounds = e.displayBoxBounds, this.displaySphereBounds = e.displaySphereBounds, this.displayRegionBounds = e.displayRegionBounds, this.colorMode = e.colorMode, this.maxDebugDepth = e.maxDebugDepth, this.maxDebugDistance = e.maxDebugDistance, this.maxDebugError = e.maxDebugError, this.customColorCallback = e.customColorCallback, this.unlit = e.unlit, this.getDebugColor = (t, s) => {\n s.setRGB(t, t, t);\n };\n }\n // initialize the groups for displaying helpers, register events, and initialize existing tiles\n init(e) {\n if (this.tiles = e, !this.enabled)\n return;\n const t = e.group;\n this.boxGroup = new ke(), this.boxGroup.name = \"DebugTilesRenderer.boxGroup\", t.add(this.boxGroup), this.boxGroup.updateMatrixWorld(), this.sphereGroup = new ke(), this.sphereGroup.name = \"DebugTilesRenderer.sphereGroup\", t.add(this.sphereGroup), this.sphereGroup.updateMatrixWorld(), this.regionGroup = new ke(), this.regionGroup.name = \"DebugTilesRenderer.regionGroup\", t.add(this.regionGroup), this.regionGroup.updateMatrixWorld(), this._onLoadTilesetCB = () => {\n this._initExtremes();\n }, this._onLoadModelCB = ({ scene: s, tile: n }) => {\n this._onLoadModel(s, n);\n }, this._onDisposeModelCB = ({ tile: s }) => {\n this._onDisposeModel(s);\n }, this._onUpdateAfterCB = () => {\n this.update();\n }, this._onTileVisibilityChangeCB = ({ scene: s, tile: n, visible: i }) => {\n this._onTileVisibilityChange(n, i);\n }, e.addEventListener(\"load-tileset\", this._onLoadTilesetCB), e.addEventListener(\"load-model\", this._onLoadModelCB), e.addEventListener(\"dispose-model\", this._onDisposeModelCB), e.addEventListener(\"update-after\", this._onUpdateAfterCB), e.addEventListener(\"tile-visibility-change\", this._onTileVisibilityChangeCB), this._initExtremes(), e.traverse((s) => {\n s.engineData.scene && this._onLoadModel(s.engineData.scene, s);\n }), e.visibleTiles.forEach((s) => {\n this._onTileVisibilityChange(s, !0);\n });\n }\n getTileFromObject3D(e) {\n let t = null;\n return this.tiles.activeTiles.forEach((n) => {\n if (t)\n return !0;\n const i = n.engineData.scene;\n i && i.traverse((r) => {\n r === e && (t = n);\n });\n }), t;\n }\n _initExtremes() {\n if (!(this.tiles && this.tiles.root))\n return;\n let e = -1, t = -1;\n this.tiles.traverse(null, (s, n, i) => {\n e = Math.max(e, i), t = Math.max(t, s.geometricError);\n }, !1), this.extremeDebugDepth = e, this.extremeDebugError = t;\n }\n update() {\n const { tiles: e, colorMode: t } = this;\n if (!e.root)\n return;\n this.materialsNeedUpdate && (e.forEachLoadedModel((c) => {\n this._updateMaterial(c);\n }), this.materialsNeedUpdate = !1), this.boxGroup.visible = this.displayBoxBounds, this.sphereGroup.visible = this.displaySphereBounds, this.regionGroup.visible = this.displayRegionBounds;\n let s = -1;\n this.maxDebugDepth === -1 ? s = this.extremeDebugDepth : s = this.maxDebugDepth;\n let n = -1;\n this.maxDebugError === -1 ? n = this.extremeDebugError : n = this.maxDebugError;\n let i = -1;\n this.maxDebugDistance === -1 ? (e.getBoundingSphere(Ws), i = Ws.radius) : i = this.maxDebugDistance;\n const { errorTarget: r, visibleTiles: o } = e;\n let l;\n t === kt && (l = Array.from(o).sort((c, u) => c[Ut] - u[Ut])), o.forEach((c) => {\n const u = c.engineData.scene;\n let h, d, m;\n t === et && (h = Math.random(), d = 0.5 + Math.random() * 0.5, m = 0.375 + Math.random() * 0.25), u.traverse((f) => {\n if (t === tt && (h = Math.random(), d = 0.5 + Math.random() * 0.5, m = 0.375 + Math.random() * 0.25), f.material)\n switch (t !== et && delete f.material[Bt], t !== tt && delete f.material[Ot], t) {\n case Rn: {\n const p = c.internal.depth / s;\n this.getDebugColor(p, f.material.color);\n break;\n }\n case Dn: {\n const p = c.internal.depthFromRenderedParent / s;\n this.getDebugColor(p, f.material.color);\n break;\n }\n case En: {\n const p = c.traversal.error / r;\n p > 1 ? f.material.color.setRGB(1, 0, 0) : this.getDebugColor(p, f.material.color);\n break;\n }\n case wn: {\n const p = Math.min(c.geometricError / n, 1);\n this.getDebugColor(p, f.material.color);\n break;\n }\n case Pn: {\n const p = Math.min(c.traversal.distanceFromCamera / i, 1);\n this.getDebugColor(p, f.material.color);\n break;\n }\n case Bn: {\n !c.children || c.children.length === 0 ? this.getDebugColor(1, f.material.color) : this.getDebugColor(0, f.material.color);\n break;\n }\n case tt: {\n f.material[Ot] || (f.material.color.setHSL(h, d, m), f.material[Ot] = !0);\n break;\n }\n case et: {\n f.material[Bt] || (f.material.color.setHSL(h, d, m), f.material[Bt] = !0);\n break;\n }\n case On: {\n this.customColorCallback ? this.customColorCallback(c, f) : console.warn(\"DebugTilesRenderer: customColorCallback not defined\");\n break;\n }\n case kt: {\n const p = l.indexOf(c);\n this.getDebugColor(p / (l.length - 1), f.material.color);\n break;\n }\n }\n });\n });\n }\n _onTileVisibilityChange(e, t) {\n this.displayParentBounds ? bi(e, (s) => {\n s[ge] == null && (s[ge] = 0), t ? s[ge]++ : s[ge] > 0 && s[ge]--;\n const n = s === e && t || this.displayParentBounds && s[ge] > 0;\n this._updateBoundHelper(s, n);\n }) : this._updateBoundHelper(e, t);\n }\n _createBoundHelper(e) {\n const t = this.tiles, s = e.engineData, { sphere: n, obb: i, region: r } = s.boundingVolume;\n if (i) {\n const o = new ke();\n o.name = \"DebugTilesRenderer.boxHelperGroup\", o.matrix.copy(i.transform), o.matrixAutoUpdate = !1, s.boxHelperGroup = o;\n const l = new ci(i.box, Ke(e.internal.depth));\n l.raycast = Je, o.add(l);\n const c = new Be(new ln(), new Se({\n color: Ke(e.internal.depth),\n transparent: !0,\n depthWrite: !1,\n opacity: 0.05,\n side: rn\n }));\n i.box.getSize(c.scale), c.raycast = Je, o.add(c), t.visibleTiles.has(e) && this.displayBoxBounds && (this.boxGroup.add(o), o.updateMatrixWorld(!0));\n }\n if (n) {\n const o = new Ir(n, Ke(e.internal.depth));\n o.raycast = Je, s.sphereHelper = o, t.visibleTiles.has(e) && this.displaySphereBounds && (this.sphereGroup.add(o), o.updateMatrixWorld(!0));\n }\n if (r) {\n const o = new Lr(r, Ke(e.internal.depth));\n o.raycast = Je;\n const l = new de();\n r.getBoundingSphere(l), o.position.copy(l.center), l.center.multiplyScalar(-1), o.geometry.translate(...l.center), s.regionHelper = o, t.visibleTiles.has(e) && this.displayRegionBounds && (this.regionGroup.add(o), o.updateMatrixWorld(!0));\n }\n }\n _updateHelperMaterials(e, t) {\n t.traverse((s) => {\n const { material: n } = s;\n if (!n)\n return;\n e.traversal.visible || !this.displayParentBounds ? n.opacity = s.isMesh ? 0.05 : 1 : n.opacity = s.isMesh ? 0.01 : 0.2;\n const i = n.transparent;\n n.transparent = n.opacity < 1, n.transparent !== i && (n.needsUpdate = !0);\n });\n }\n _updateBoundHelper(e, t) {\n const s = e.engineData;\n if (!s)\n return;\n const n = this.sphereGroup, i = this.boxGroup, r = this.regionGroup;\n t && s.boxHelperGroup == null && s.sphereHelper == null && s.regionHelper == null && this._createBoundHelper(e);\n const o = s.boxHelperGroup, l = s.sphereHelper, c = s.regionHelper;\n t ? (o && (i.add(o), o.updateMatrixWorld(!0), this._updateHelperMaterials(e, o)), l && (n.add(l), l.updateMatrixWorld(!0), this._updateHelperMaterials(e, l)), c && (r.add(c), c.updateMatrixWorld(!0), this._updateHelperMaterials(e, c))) : (o && i.remove(o), l && n.remove(l), c && r.remove(c));\n }\n _updateMaterial(e) {\n const { colorMode: t, unlit: s } = this;\n e.traverse((n) => {\n if (!n.material)\n return;\n const i = n.material, r = n[qs];\n if (i !== r && i.dispose(), t !== Re || s) {\n if (n.isPoints) {\n const o = new ui();\n o.size = r.size, o.sizeAttenuation = r.sizeAttenuation, n.material = o;\n } else s ? n.material = new Se() : (n.material = new Ks(), n.material.flatShading = !0);\n t === Re && (n.material.map = r.map, n.material.color.set(r.color));\n } else\n n.material = r;\n });\n }\n _onLoadModel(e, t) {\n t[Ut] = performance.now(), e.traverse((s) => {\n const n = s.material;\n n && (s[qs] = n);\n }), this._updateMaterial(e);\n }\n _onDisposeModel(e) {\n const t = e.engineData;\n t != null && t.boxHelperGroup && (t.boxHelperGroup.children[0].geometry.dispose(), delete t.boxHelperGroup), t != null && t.sphereHelper && (t.sphereHelper.geometry.dispose(), delete t.sphereHelper), t != null && t.regionHelper && (t.regionHelper.geometry.dispose(), delete t.regionHelper);\n }\n dispose() {\n var t, s, n;\n const e = this.tiles;\n e.removeEventListener(\"load-tileset\", this._onLoadTilesetCB), e.removeEventListener(\"load-model\", this._onLoadModelCB), e.removeEventListener(\"dispose-model\", this._onDisposeModelCB), e.removeEventListener(\"update-after\", this._onUpdateAfterCB), e.removeEventListener(\"tile-visibility-change\", this._onTileVisibilityChangeCB), this.colorMode = Re, this.unlit = !1, e.forEachLoadedModel((i) => {\n this._updateMaterial(i);\n }), e.traverse((i) => {\n this._onDisposeModel(i);\n }, null, !1), (t = this.boxGroup) == null || t.removeFromParent(), (s = this.sphereGroup) == null || s.removeFromParent(), (n = this.regionGroup) == null || n.removeFromParent();\n }\n}\nclass wr extends Ue {\n constructor(e = {}) {\n const { url: t = null, ...s } = e;\n super(s), this.url = t, this.format = null, this.stem = null;\n }\n getUrl(e, t, s) {\n return `${this.stem}_files/${s}/${e}_${t}.${this.format}`;\n }\n init() {\n const { url: e } = this;\n return this.fetchData(e, this.fetchOptions).then((t) => t.text()).then((t) => {\n const s = new DOMParser().parseFromString(t, \"text/xml\");\n if (s.querySelector(\"DisplayRects\") || s.querySelector(\"Collection\"))\n throw new Error(\"DeepZoomImagesPlugin: DisplayRect and Collection DZI files not supported.\");\n const n = s.querySelector(\"Image\"), i = n.querySelector(\"Size\"), r = parseInt(i.getAttribute(\"Width\")), o = parseInt(i.getAttribute(\"Height\")), l = parseInt(n.getAttribute(\"TileSize\")), c = parseInt(n.getAttribute(\"Overlap\")), u = n.getAttribute(\"Format\");\n this.format = u, this.stem = e.split(/\\.[^.]+$/g)[0];\n const { tiling: h } = this, d = Math.ceil(Math.log2(Math.max(r, o))) + 1;\n h.flipY = !0, h.pixelOverlap = c, h.generateLevels(d, 1, 1, {\n tilePixelWidth: l,\n tilePixelHeight: l,\n pixelWidth: r,\n pixelHeight: o\n });\n });\n }\n}\nclass Lo extends pn {\n constructor(e = {}) {\n const { url: t, ...s } = e;\n super(s), this.name = \"DZI_TILES_PLUGIN\", this.imageSource = new wr({ url: t });\n }\n}\nconst ot = hn * Math.PI * 2, js = /* @__PURE__ */ new re(\"EPSG:3857\");\nfunction Pr(a) {\n return /:4326$/i.test(a);\n}\nfunction Un(a) {\n return /:3857$/i.test(a);\n}\nfunction Gt(a) {\n return a.trim().split(/\\s+/).map((e) => parseFloat(e));\n}\nfunction zt(a, e) {\n Pr(e) && ([a[1], a[0]] = [a[0], a[1]]);\n}\nfunction at(a, e) {\n if (Un(e))\n return a[0] = js.convertNormalizedToLongitude(0.5 + a[0] / ot), a[1] = js.convertNormalizedToLatitude(0.5 + a[1] / ot), a[0] *= b.RAD2DEG, a[1] *= b.RAD2DEG, a;\n}\nfunction lt(a) {\n a[0] *= b.DEG2RAD, a[1] *= b.DEG2RAD;\n}\nclass Eo extends dn {\n parse(e) {\n const t = new TextDecoder(\"utf-8\").decode(new Uint8Array(e)), s = new DOMParser().parseFromString(t, \"text/xml\"), n = s.querySelector(\"Contents\"), i = ue(n, \"TileMatrixSet\").map((l) => Nr(l)), r = ue(n, \"Layer\").map((l) => Dr(l)), o = Rr(s.querySelector(\"ServiceIdentification\"));\n return r.forEach((l) => {\n l.tileMatrixSets = l.tileMatrixSetLinks.map((c) => i.find((u) => u.identifier === c));\n }), {\n serviceIdentification: o,\n tileMatrixSets: i,\n layers: r\n };\n }\n}\nfunction Rr(a) {\n var i;\n const e = a.querySelector(\"Title\").textContent, t = ((i = a.querySelector(\"Abstract\")) == null ? void 0 : i.textContent) || \"\", s = a.querySelector(\"ServiceType\").textContent, n = a.querySelector(\"ServiceTypeVersion\").textContent;\n return {\n title: e,\n abstract: t,\n serviceType: s,\n serviceTypeVersion: n\n };\n}\nfunction Dr(a) {\n const e = a.querySelector(\"Title\").textContent, t = a.querySelector(\"Identifier\").textContent, s = a.querySelector(\"Format\").textContent, n = ue(a, \"ResourceURL\").map((c) => Br(c)), i = ue(a, \"TileMatrixSetLink\").map((c) => ue(c, \"TileMatrixSet\")[0].textContent), r = ue(a, \"Style\").map((c) => Ur(c)), o = ue(a, \"Dimension\").map((c) => Or(c));\n let l = Ys(a.querySelector(\"WGS84BoundingBox\"));\n return l || (l = Ys(a.querySelector(\"BoundingBox\"))), {\n title: e,\n identifier: t,\n format: s,\n dimensions: o,\n tileMatrixSetLinks: i,\n styles: r,\n boundingBox: l,\n resourceUrls: n\n };\n}\nfunction Br(a) {\n const e = a.getAttribute(\"template\"), t = a.getAttribute(\"format\"), s = a.getAttribute(\"resourceType\");\n return {\n template: e,\n format: t,\n resourceType: s\n };\n}\nfunction Or(a) {\n var r, o;\n const e = a.querySelector(\"Identifier\").textContent, t = ((r = a.querySelector(\"UOM\")) == null ? void 0 : r.textContent) || \"\", s = a.querySelector(\"Default\").textContent, n = ((o = a.querySelector(\"Current\")) == null ? void 0 : o.textContent) === \"true\", i = ue(a, \"Value\").map((l) => l.textContent);\n return {\n identifier: e,\n uom: t,\n defaultValue: s,\n current: n,\n values: i\n };\n}\nfunction Ys(a) {\n if (!a)\n return null;\n const e = a.nodeName.endsWith(\"WGS84BoundingBox\") ? \"urn:ogc:def:crs:CRS::84\" : a.getAttribute(\"crs\"), t = Gt(a.querySelector(\"LowerCorner\").textContent), s = Gt(a.querySelector(\"UpperCorner\").textContent);\n return zt(t, e), zt(s, e), at(t, e), at(s, e), lt(t), lt(s), {\n crs: e,\n lowerCorner: t,\n upperCorner: s,\n bounds: [...t, ...s]\n };\n}\nfunction Ur(a) {\n var n;\n const e = ((n = a.querySelector(\"Title\")) == null ? void 0 : n.textContent) || null, t = a.querySelector(\"Identifier\").textContent, s = a.getAttribute(\"isDefault\") === \"true\";\n return {\n title: e,\n identifier: t,\n isDefault: s\n };\n}\nfunction Nr(a) {\n var r, o;\n const e = a.querySelector(\"SupportedCRS\").textContent, t = ((r = a.querySelector(\"Title\")) == null ? void 0 : r.textContent) || \"\", s = a.querySelector(\"Identifier\").textContent, n = ((o = a.querySelector(\"Abstract\")) == null ? void 0 : o.textContent) || \"\", i = [];\n return a.querySelectorAll(\"TileMatrix\").forEach((l, c) => {\n const u = Vr(l), h = 28e-5 * u.scaleDenominator, d = u.tileWidth * u.matrixWidth * h, m = u.tileHeight * u.matrixHeight * h;\n let f;\n zt(u.topLeftCorner, e), Un(e) ? f = [\n u.topLeftCorner[0] + d,\n u.topLeftCorner[1] - m\n ] : f = [\n u.topLeftCorner[0] + 360 * d / ot,\n u.topLeftCorner[1] - 360 * m / ot\n ], at(f, e), at(u.topLeftCorner, e), lt(f), lt(u.topLeftCorner), u.bounds = [...u.topLeftCorner, ...f], [u.bounds[1], u.bounds[3]] = [u.bounds[3], u.bounds[1]], i.push(u);\n }), {\n title: t,\n identifier: s,\n abstract: n,\n supportedCRS: e,\n tileMatrices: i\n };\n}\nfunction Vr(a) {\n const e = a.querySelector(\"Identifier\").textContent, t = parseFloat(a.querySelector(\"TileWidth\").textContent), s = parseFloat(a.querySelector(\"TileHeight\").textContent), n = parseFloat(a.querySelector(\"MatrixWidth\").textContent), i = parseFloat(a.querySelector(\"MatrixHeight\").textContent), r = parseFloat(a.querySelector(\"ScaleDenominator\").textContent), o = Gt(a.querySelector(\"TopLeftCorner\").textContent);\n return {\n identifier: e,\n tileWidth: t,\n tileHeight: s,\n matrixWidth: n,\n matrixHeight: i,\n scaleDenominator: r,\n topLeftCorner: o,\n bounds: null\n };\n}\nfunction ue(a, e) {\n return [...a.children].filter((t) => t.tagName === e);\n}\nconst Xs = hn * Math.PI * 2, $s = /* @__PURE__ */ new re(\"EPSG:3857\");\nfunction Fr(a) {\n return /:4326$/i.test(a);\n}\nfunction kr(a) {\n return /:3857$/i.test(a);\n}\nfunction Qs(a, e) {\n return kr(e) && (a[0] = $s.convertNormalizedToLongitude(0.5 + a[0] / (Math.PI * 2 * Xs)), a[1] = $s.convertNormalizedToLatitude(0.5 + a[1] / (Math.PI * 2 * Xs)), a[0] *= b.RAD2DEG, a[1] *= b.RAD2DEG), a;\n}\nfunction Zs(a, e, t) {\n const [s, n] = t.split(\".\").map((r) => parseInt(r)), i = s === 1 && n < 3 || s < 1;\n Fr(e) && i && ([a[0], a[1]] = [a[1], a[0]]);\n}\nfunction Me(a) {\n a[0] *= b.DEG2RAD, a[1] *= b.DEG2RAD;\n}\nfunction Gr(a, e) {\n if (!a)\n return null;\n const t = a.getAttribute(\"CRS\") || a.getAttribute(\"crs\") || a.getAttribute(\"SRS\") || \"\", s = parseFloat(a.getAttribute(\"minx\")), n = parseFloat(a.getAttribute(\"miny\")), i = parseFloat(a.getAttribute(\"maxx\")), r = parseFloat(a.getAttribute(\"maxy\")), o = [s, n], l = [i, r];\n return Zs(o, t, e), Zs(l, t, e), Qs(o, t), Qs(l, t), Me(o), Me(l), { crs: t, bounds: [...o, ...l] };\n}\nfunction zr(a) {\n const e = parseFloat(a.querySelector(\"westBoundLongitude\").textContent), t = parseFloat(a.querySelector(\"eastBoundLongitude\").textContent), s = parseFloat(a.querySelector(\"southBoundLatitude\").textContent), n = parseFloat(a.querySelector(\"northBoundLatitude\").textContent), i = [e, s], r = [t, n];\n return Me(i), Me(r), [...i, ...r];\n}\nfunction Hr(a) {\n const e = parseFloat(a.getAttribute(\"minx\").textContent), t = parseFloat(a.getAttribute(\"maxx\").textContent), s = parseFloat(a.getAttribute(\"miny\").textContent), n = parseFloat(a.getAttribute(\"maxy\").textContent), i = [e, s], r = [t, n];\n return Me(i), Me(r), [...i, ...r];\n}\nfunction qr(a) {\n const e = a.querySelector(\"Name\").textContent, t = a.querySelector(\"Title\").textContent, s = [...a.querySelectorAll(\"LegendURL\")].map((n) => {\n const i = parseInt(n.getAttribute(\"width\")), r = parseInt(n.getAttribute(\"height\")), o = n.querySelector(\"Format\").textContent, l = n.querySelector(\"OnlineResource\"), c = Ht(l);\n return {\n width: i,\n height: r,\n format: o,\n url: c\n };\n });\n return {\n name: e,\n title: t,\n legends: s\n };\n}\nfunction Nn(a, e, t = {}) {\n var p, g, y;\n let {\n styles: s = [],\n crs: n = [],\n contentBoundingBox: i = null,\n queryable: r = !1,\n opaque: o = !1\n } = t;\n const l = ((p = a.querySelector(\":scope > Name\")) == null ? void 0 : p.textContent) || null, c = ((g = a.querySelector(\":scope > Title\")) == null ? void 0 : g.textContent) || \"\", u = ((y = a.querySelector(\":scope > Abstract\")) == null ? void 0 : y.textContent) || \"\", h = [...a.querySelectorAll(\":scope > Keyword\")].map((x) => x.textContent), m = [...a.querySelectorAll(\":scope > BoundingBox\")].map((x) => Gr(x, e));\n n = [\n ...n,\n ...Array.from(a.querySelectorAll(\"CRS\")).map((x) => x.textContent)\n ], s = [\n ...s,\n ...Array.from(a.querySelectorAll(\":scope > Style\")).map((x) => qr(x))\n ], a.hasAttribute(\"queryable\") && (r = a.getAttribute(\"queryable\") === \"1\"), a.hasAttribute(\"opaque\") && (o = a.getAttribute(\"opaque\") === \"1\"), a.querySelector(\"EX_GeographicBoundingBox\") ? i = zr(a.querySelector(\"EX_GeographicBoundingBox\")) : a.querySelector(\"LatLonBoundingBox\") && (i = Hr(a.querySelector(\"LatLonBoundingBox\")));\n const f = Array.from(a.querySelectorAll(\":scope > Layer\")).map((x) => Nn(x, e, {\n // add\n styles: s,\n crs: n,\n // replace\n contentBoundingBox: i,\n queryable: r,\n opaque: o\n }));\n return {\n name: l,\n title: c,\n abstract: u,\n queryable: r,\n opaque: o,\n keywords: h,\n crs: n,\n boundingBoxes: m,\n contentBoundingBox: i,\n styles: s,\n subLayers: f\n };\n}\nfunction Wr(a) {\n var e, t, s;\n return {\n name: ((e = a.querySelector(\"Name\")) == null ? void 0 : e.textContent) || \"\",\n title: ((t = a.querySelector(\"Title\")) == null ? void 0 : t.textContent) || \"\",\n abstract: ((s = a.querySelector(\"Abstract\")) == null ? void 0 : s.textContent) || \"\",\n keywords: Array.from(a.querySelectorAll(\"Keyword\")).map((n) => n.textContent),\n maxWidth: parseFloat(a.querySelector(\"MaxWidth\")) || null,\n maxHeight: parseFloat(a.querySelector(\"MaxHeight\")) || null,\n layerLimit: parseFloat(a.querySelector(\"LayerLimit\")) || null\n };\n}\nfunction Ht(a) {\n return a ? (a.getAttribute(\"xlink:href\") || a.getAttributeNS(\"http://www.w3.org/1999/xlink\", \"href\") || \"\").trim() : \"\";\n}\nfunction jr(a) {\n const e = Array.from(a.querySelectorAll(\"Format\")).map((s) => s.textContent.trim()), t = Array.from(a.querySelectorAll(\"DCPType\")).map((s) => {\n const n = s.querySelector(\"HTTP\"), i = n.querySelector(\"Get OnlineResource\") || n.querySelector(\"Get > OnlineResource\") || n.querySelector(\"Get\"), r = n.querySelector(\"Post OnlineResource\") || n.querySelector(\"Post > OnlineResource\") || n.querySelector(\"Post\"), o = Ht(i), l = Ht(r);\n return { type: \"HTTP\", get: o, post: l };\n });\n return { formats: e, dcp: t, href: t[0].get };\n}\nfunction Yr(a) {\n const e = {};\n return Array.from(a.querySelectorAll(\":scope > *\")).forEach((t) => {\n const s = t.localName;\n e[s] = jr(t);\n }), e;\n}\nfunction Vn(a, e = []) {\n return a.forEach((t) => {\n t.name !== null && e.push(t), Vn(t.subLayers, e);\n }), e;\n}\nclass wo extends dn {\n parse(e) {\n const t = new TextDecoder(\"utf-8\").decode(new Uint8Array(e)), s = new DOMParser().parseFromString(t, \"text/xml\"), i = (s.querySelector(\"WMS_Capabilities\") || s.querySelector(\"WMT_MS_Capabilities\")).getAttribute(\"version\"), r = s.querySelector(\"Capability\"), o = Wr(s.querySelector(\":scope > Service\")), l = Yr(r.querySelector(\":scope > Request\")), c = Array.from(r.querySelectorAll(\":scope > Layer\")).map((h) => Nn(h, i)), u = Vn(c);\n return { version: i, service: o, layers: u, request: l };\n }\n}\nexport {\n Zt as B,\n io as C,\n vo as D,\n nr as G,\n mo as I,\n Mo as L,\n tr as M,\n Io as O,\n Ui as Q,\n Ao as R,\n Co as S,\n bo as T,\n uo as U,\n wo as W,\n go as X,\n po as a,\n _o as b,\n Lo as c,\n lo as d,\n sr as e,\n Ki as f,\n yo as g,\n So as h,\n co as i,\n As as j,\n Ai as k,\n ao as l,\n fo as m,\n ho as n,\n oo as o,\n xo as p,\n no as q,\n Eo as r,\n To as s,\n so as t,\n to as u\n};\n//# sourceMappingURL=WMSCapabilitiesLoader-DngSzqI4.js.map\n","import {\r\n Group,\r\n InstancedMesh,\r\n LoadingManager,\r\n Matrix4,\r\n Mesh,\r\n MeshStandardMaterial,\r\n Quaternion,\r\n Scene,\r\n Texture,\r\n Vector3,\r\n Loader,\r\n} from \"three\";\r\nimport {\r\n acquireWorker,\r\n buildTextures,\r\n buildMaterials,\r\n buildMeshPrimitives,\r\n type PrimitiveData,\r\n getWorkers,\r\n} from \"./utils\";\r\nimport type { GLTFNodeData, GLTFWorkerData, MaterialBuilder } from \"./types\";\r\nimport { StructuralMetadata, MeshFeatures } from \"3d-tiles-renderer/plugins\";\r\n\r\n// 隔离接收oid数组\r\n\r\n// Extension names\r\nconst EXT_STRUCTURAL_METADATA = \"EXT_structural_metadata\";\r\nconst EXT_MESH_FEATURES = \"EXT_mesh_features\";\r\n\r\n/**\r\n * GLTFWorkerLoader configuration options\r\n */\r\nexport interface GLTFWorkerLoaderOptions {\r\n /** Whether to enable metadata support (EXT_mesh_features, EXT_structural_metadata) */\r\n metadata?: boolean;\r\n /** Custom material builder function */\r\n materialBuilder?: MaterialBuilder;\r\n}\r\n\r\nlet uuid = 0;\r\n\r\n/**\r\n * Custom Loader using Worker for GLTF parsing\r\n */\r\nexport class GLTFWorkerLoader extends Loader {\r\n private _metadata: boolean = true;\r\n private _materialBuilder?: MaterialBuilder;\r\n private _loaderId = uuid++;\r\n private _callbacks = new Map<\r\n number,\r\n { resolve: (data: any) => void; reject: (err: Error) => void }\r\n >();\r\n private _nextRequestId = 1;\r\n\r\n constructor(manager?: LoadingManager, options?: GLTFWorkerLoaderOptions) {\r\n super(manager);\r\n this._metadata = options?.metadata ?? true;\r\n this._materialBuilder = options?.materialBuilder;\r\n\r\n this.addListeners();\r\n }\r\n\r\n addListeners() {\r\n const workers = getWorkers();\r\n workers.forEach((worker) => {\r\n worker.addEventListener(\"message\", this._onMessage);\r\n });\r\n }\r\n\r\n removeListeners() {\r\n const workers = getWorkers();\r\n workers.forEach((worker) => {\r\n worker.removeEventListener(\"message\", this._onMessage);\r\n });\r\n }\r\n\r\n /**\r\n * Asynchronously parse GLTF buffer\r\n */\r\n async parseAsync(buffer: ArrayBuffer, path: string): Promise<any> {\r\n // Acquire available Worker\r\n const worker = acquireWorker();\r\n\r\n // Parse using worker\r\n const data = await this.parseWithWorker(worker, buffer, path);\r\n\r\n // Build Three.js scene\r\n const scene = this.buildSceneFromGLTFData(data);\r\n\r\n // Return format identical to GLTFLoader\r\n return {\r\n scene: scene,\r\n scenes: [scene],\r\n animations: [],\r\n cameras: [],\r\n asset: {\r\n generator: \"GLTFWorkerLoader\",\r\n version: \"2.0\",\r\n },\r\n parser: null as any,\r\n userData: {},\r\n };\r\n }\r\n\r\n /**\r\n * Parse GLTF data using Worker\r\n */\r\n private parseWithWorker(\r\n worker: Worker,\r\n buffer: ArrayBuffer,\r\n workingPath: string,\r\n ): Promise<GLTFWorkerData> {\r\n return new Promise((resolve, reject) => {\r\n const requestId = this._nextRequestId++;\r\n this._callbacks.set(requestId, { resolve, reject });\r\n\r\n // Send buffer and working path to worker\r\n worker.postMessage(\r\n {\r\n method: \"parseTile\",\r\n buffer: buffer,\r\n root: workingPath,\r\n loaderId: this._loaderId,\r\n requestId,\r\n fetchOptions: {\r\n referrer: window.location.href,\r\n referrerPolicy: \"origin\",\r\n },\r\n },\r\n [buffer],\r\n );\r\n });\r\n }\r\n\r\n private _onMessage = (event: MessageEvent) => {\r\n const { type, data, error, loaderId, requestId } = event.data;\r\n\r\n // loaderId here is our requestId\r\n if (loaderId !== this._loaderId) return;\r\n const callback = this._callbacks.get(requestId);\r\n if (!callback) return;\r\n\r\n this._callbacks.delete(requestId);\r\n\r\n if (type === \"success\") {\r\n callback.resolve(data);\r\n } else if (type === \"error\") {\r\n callback.reject(new Error(error));\r\n }\r\n };\r\n\r\n /**\r\n * Convert GLTF data returned by Worker to Three.js Scene\r\n */\r\n private buildSceneFromGLTFData(data: GLTFWorkerData): Scene {\r\n const scene = new Scene();\r\n\r\n // Build textures\r\n const { textureMap, textureArray } = buildTextures(data);\r\n\r\n // Build materials\r\n const materialMap = buildMaterials(data, textureMap, this._materialBuilder);\r\n\r\n // Create default material\r\n const defaultMaterial = new MeshStandardMaterial({ color: 0xcccccc });\r\n\r\n // Build mesh primitives\r\n const meshMap = buildMeshPrimitives(data, materialMap, defaultMaterial);\r\n\r\n // Parse node\r\n const parseNodeData = (nodeData: GLTFNodeData): Group => {\r\n const node = new Group();\r\n\r\n const primitiveDataList = meshMap.get(nodeData.mesh);\r\n if (primitiveDataList) {\r\n if (nodeData.instanceData) {\r\n // EXT_mesh_gpu_instancing: create InstancedMesh per primitive\r\n const { count, TRANSLATION, ROTATION, SCALE } = nodeData.instanceData;\r\n\r\n for (const {\r\n geometry,\r\n material,\r\n primitiveIndex,\r\n } of primitiveDataList) {\r\n const instancedMesh = new InstancedMesh(geometry, material, count);\r\n\r\n const tmpMatrix = new Matrix4();\r\n const tmpPos = new Vector3();\r\n const tmpQuat = new Quaternion();\r\n const tmpScale = new Vector3(1, 1, 1);\r\n\r\n for (let i = 0; i < count; i++) {\r\n if (TRANSLATION) {\r\n tmpPos.set(\r\n TRANSLATION[i * 3],\r\n TRANSLATION[i * 3 + 1],\r\n TRANSLATION[i * 3 + 2],\r\n );\r\n } else {\r\n tmpPos.set(0, 0, 0);\r\n }\r\n\r\n if (ROTATION) {\r\n tmpQuat.set(\r\n ROTATION[i * 4],\r\n ROTATION[i * 4 + 1],\r\n ROTATION[i * 4 + 2],\r\n ROTATION[i * 4 + 3],\r\n );\r\n } else {\r\n tmpQuat.identity();\r\n }\r\n\r\n if (SCALE) {\r\n tmpScale.set(SCALE[i * 3], SCALE[i * 3 + 1], SCALE[i * 3 + 2]);\r\n } else {\r\n tmpScale.set(1, 1, 1);\r\n }\r\n\r\n tmpMatrix.compose(tmpPos, tmpQuat, tmpScale);\r\n instancedMesh.setMatrixAt(i, tmpMatrix);\r\n }\r\n\r\n instancedMesh.instanceMatrix.needsUpdate = true;\r\n instancedMesh.userData._gltfMeshIndex = nodeData.mesh;\r\n instancedMesh.userData._gltfPrimitiveIndex = primitiveIndex;\r\n node.add(instancedMesh);\r\n }\r\n } else {\r\n for (const {\r\n geometry,\r\n material,\r\n primitiveIndex,\r\n } of primitiveDataList) {\r\n const mesh = new Mesh(geometry, material);\r\n mesh.userData._gltfMeshIndex = nodeData.mesh;\r\n mesh.userData._gltfPrimitiveIndex = primitiveIndex;\r\n node.add(mesh);\r\n }\r\n }\r\n }\r\n\r\n // Set node name\r\n if (nodeData.name) {\r\n node.name = nodeData.name;\r\n }\r\n\r\n // Apply transformation\r\n if (nodeData.matrix) {\r\n const m = new Matrix4();\r\n m.fromArray(nodeData.matrix);\r\n node.applyMatrix4(m);\r\n } else {\r\n if (nodeData.translation) {\r\n node.position.set(\r\n nodeData.translation[0],\r\n nodeData.translation[1],\r\n nodeData.translation[2],\r\n );\r\n }\r\n if (nodeData.rotation) {\r\n node.quaternion.set(\r\n nodeData.rotation[0],\r\n nodeData.rotation[1],\r\n nodeData.rotation[2],\r\n nodeData.rotation[3],\r\n );\r\n }\r\n if (nodeData.scale) {\r\n node.scale.set(\r\n nodeData.scale[0],\r\n nodeData.scale[1],\r\n nodeData.scale[2],\r\n );\r\n }\r\n }\r\n\r\n // Recursively process child nodes\r\n if (nodeData.children && Array.isArray(nodeData.children)) {\r\n for (const child of nodeData.children) {\r\n const childNode = parseNodeData(child);\r\n node.add(childNode);\r\n }\r\n }\r\n\r\n return node;\r\n };\r\n\r\n // Add scene nodes\r\n const sceneData = data.scenes[0];\r\n for (const nodeData of sceneData.nodes) {\r\n const node = parseNodeData(nodeData);\r\n scene.add(node);\r\n }\r\n\r\n // Process metadata (if enabled)\r\n if (this._metadata) {\r\n this.processMetadata(scene, data, textureArray, meshMap);\r\n }\r\n\r\n return scene;\r\n }\r\n\r\n /**\r\n * Process and attach metadata to scene and mesh objects\r\n */\r\n private processMetadata(\r\n scene: Scene,\r\n data: GLTFWorkerData,\r\n textures: (Texture | null)[],\r\n meshMap: Map<number, PrimitiveData[]>,\r\n ): void {\r\n const extensionsUsed = data.json?.extensionsUsed || [];\r\n const hasStructuralMetadata = extensionsUsed.includes(\r\n EXT_STRUCTURAL_METADATA,\r\n );\r\n const hasMeshFeatures = extensionsUsed.includes(EXT_MESH_FEATURES);\r\n\r\n if (!hasStructuralMetadata && !hasMeshFeatures) {\r\n return;\r\n }\r\n\r\n // Process EXT_structural_metadata\r\n let rootMetadata: any = null;\r\n if (hasStructuralMetadata && data.structuralMetadata) {\r\n const rootExtension = data.json?.extensions?.[EXT_STRUCTURAL_METADATA];\r\n if (rootExtension) {\r\n const definition = {\r\n schema: data.structuralMetadata.schema,\r\n propertyTables: data.structuralMetadata.propertyTables || [],\r\n propertyTextures: rootExtension.propertyTextures || [],\r\n propertyAttributes: rootExtension.propertyAttributes || [],\r\n };\r\n\r\n const buffers = data.structuralMetadata.buffers || [];\r\n rootMetadata = new StructuralMetadata(definition, textures, buffers);\r\n scene.userData.structuralMetadata = rootMetadata;\r\n }\r\n }\r\n\r\n // Traverse all meshes in the scene, process mesh-level metadata\r\n scene.traverse((child) => {\r\n if (!(child instanceof Mesh)) return;\r\n\r\n const meshIndex = child.userData._gltfMeshIndex as number | undefined;\r\n const primitiveIndex = child.userData._gltfPrimitiveIndex as\r\n | number\r\n | undefined;\r\n if (meshIndex === undefined || primitiveIndex === undefined) return;\r\n\r\n const primitiveDataList = meshMap.get(meshIndex);\r\n if (!primitiveDataList) return;\r\n\r\n const primitiveData = primitiveDataList.find(\r\n (p) => p.primitiveIndex === primitiveIndex,\r\n );\r\n if (!primitiveData) return;\r\n\r\n const extensions = primitiveData.extensions;\r\n\r\n // Process EXT_structural_metadata (primitive level)\r\n if (hasStructuralMetadata && rootMetadata) {\r\n const primMetadataExt = extensions?.[EXT_STRUCTURAL_METADATA];\r\n if (primMetadataExt) {\r\n const rootExtension =\r\n data.json?.extensions?.[EXT_STRUCTURAL_METADATA];\r\n if (rootExtension) {\r\n const definition = {\r\n schema: data.structuralMetadata!.schema,\r\n propertyTables: data.structuralMetadata!.propertyTables || [],\r\n propertyTextures: rootExtension.propertyTextures || [],\r\n propertyAttributes: rootExtension.propertyAttributes || [],\r\n };\r\n const buffers = data.structuralMetadata!.buffers || [];\r\n\r\n child.userData.structuralMetadata = new StructuralMetadata(\r\n definition,\r\n textures,\r\n buffers,\r\n primMetadataExt,\r\n child,\r\n );\r\n }\r\n } else {\r\n child.userData.structuralMetadata = rootMetadata;\r\n }\r\n }\r\n\r\n // Process EXT_mesh_features\r\n if (hasMeshFeatures) {\r\n const meshFeaturesExt = extensions?.[EXT_MESH_FEATURES];\r\n if (meshFeaturesExt) {\r\n child.userData.meshFeatures = new MeshFeatures(\r\n child.geometry,\r\n textures,\r\n meshFeaturesExt,\r\n );\r\n }\r\n }\r\n });\r\n }\r\n}\r\n","import type { MeshCollector } from \"../MeshCollector\";\nimport {\n Color,\n Material,\n Mesh,\n MeshStandardMaterial,\n Object3D,\n} from \"three\";\n\nexport type ColorInput = number | string | Color;\n\n/** 内部使用:插件需提供的接口 */\ninterface PartColorHelperContext {\n hidePartsByOids(oids: number[]): void;\n showPartsByOids(oids: number[]): void;\n getMeshCollectorByOid(oid: number): MeshCollector;\n getScene(): Object3D | null;\n}\n\nfunction ensureColor(color: ColorInput): Color {\n if (color instanceof Color) return color;\n return new Color(color);\n}\n\nfunction getMaterials(mesh: Mesh): Material[] {\n const mat = mesh.material;\n if (!mat) return [];\n return Array.isArray(mat) ? mat : [mat];\n}\n\n/** 根据颜色创建材质,相同颜色复用同一材质 */\nfunction getMaterialForColor(color: Color): MeshStandardMaterial {\n const key = color.getHex();\n if (!materialCache.has(key)) {\n materialCache.set(key, new MeshStandardMaterial({\n color: color.clone(),\n roughness: 0.5,\n metalness: 0.1,\n }));\n }\n return materialCache.get(key)!;\n}\n\nconst materialCache = new Map<number, MeshStandardMaterial>();\n\n/**\n * 构件着色/透明度辅助器,参考 example 逻辑:hidePartsByOids -> 修改材质 -> scene.add -> mesh-change 监听\n * 由 GLTFParserPlugin 内部使用,scene 通过 tiles.group 获取\n */\nexport class PartColorHelper {\n private coloredOids = new Set<number>();\n private materialByOid = new Map<number, MeshStandardMaterial>();\n private originalMaterialByMesh = new Map<string, Material>();\n private opacityModifiedOids = new Set<number>();\n private opacityByOid = new Map<number, number>();\n private originalOpacityByMaterial = new Map<Material, number>();\n private meshChangeHandlers = new Map<number, () => void>();\n\n constructor(private context: PartColorHelperContext) {}\n\n private getAllModifiedOids(): number[] {\n return Array.from(new Set([...this.coloredOids, ...this.opacityModifiedOids]));\n }\n\n private applyToMeshes(oid: number): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const collector = this.context.getMeshCollectorByOid(oid);\n\n const colorMaterial = this.materialByOid.get(oid);\n const opacity = this.opacityByOid.get(oid);\n\n collector.meshes.forEach((mesh) => {\n if (!mesh.parent) scene.add(mesh);\n\n if (colorMaterial) {\n mesh.material = colorMaterial;\n }\n\n if (opacity !== undefined) {\n for (const mat of getMaterials(mesh)) {\n if (!this.originalOpacityByMaterial.has(mat)) {\n this.originalOpacityByMaterial.set(mat, mat.opacity);\n }\n mat.opacity = opacity;\n mat.transparent = opacity < 1;\n }\n }\n });\n }\n\n /**\n * 根据 oid 数组设置构件颜色\n * 隐藏原 mesh,将 split mesh 替换材质后加入场景\n */\n setPartColorByOids(oids: number[], color: ColorInput): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const threeColor = ensureColor(color);\n const material = getMaterialForColor(threeColor);\n\n for (const oid of oids) {\n this.coloredOids.add(oid);\n this.materialByOid.set(oid, material);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n if (!this.originalMaterialByMesh.has(mesh.uuid)) {\n this.originalMaterialByMesh.set(mesh.uuid, mesh.material as Material);\n }\n mesh.material = material;\n scene.add(mesh);\n });\n\n if (!this.meshChangeHandlers.has(oid)) {\n const handler = () => this.applyToMeshes(oid);\n this.meshChangeHandlers.set(oid, handler);\n collector.addEventListener(\"mesh-change\", handler);\n }\n }\n\n this.context.hidePartsByOids(this.getAllModifiedOids());\n }\n\n /**\n * 恢复指定构件的颜色\n * 若该 oid 已无颜色且无透明度修改,则从场景移除 split mesh 并 unhide 原 mesh\n */\n restorePartColorByOids(oids: number[]): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n for (const oid of oids) {\n this.coloredOids.delete(oid);\n this.materialByOid.delete(oid);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n const opacity = this.opacityByOid.get(oid);\n\n collector.meshes.forEach((mesh) => {\n const originalMat = this.originalMaterialByMesh.get(mesh.uuid);\n if (originalMat) {\n mesh.material = originalMat;\n this.originalMaterialByMesh.delete(mesh.uuid);\n if (opacity !== undefined) {\n for (const mat of getMaterials(mesh)) {\n if (!this.originalOpacityByMaterial.has(mat)) {\n this.originalOpacityByMaterial.set(mat, mat.opacity);\n }\n mat.opacity = opacity;\n mat.transparent = opacity < 1;\n }\n }\n }\n if (\n !this.coloredOids.has(oid) &&\n !this.opacityModifiedOids.has(oid) &&\n mesh.parent === scene\n ) {\n scene.remove(mesh);\n }\n });\n\n if (!this.coloredOids.has(oid) && !this.opacityModifiedOids.has(oid)) {\n const handler = this.meshChangeHandlers.get(oid);\n if (handler) {\n this.meshChangeHandlers.delete(oid);\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n }\n\n this.context.showPartsByOids(oids);\n }\n\n /**\n * 根据 oid 数组设置构件透明度\n * 隐藏原 mesh,将 split mesh 修改材质透明度后加入场景\n * @param oids 构件 OID 数组\n * @param opacity 透明度,0-1,0 完全透明,1 完全不透明\n */\n setPartOpacityByOids(oids: number[], opacity: number): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const clampedOpacity = Math.max(0, Math.min(1, opacity));\n\n for (const oid of oids) {\n this.opacityModifiedOids.add(oid);\n this.opacityByOid.set(oid, clampedOpacity);\n\n const colorMat = this.materialByOid.get(oid);\n if (colorMat && colorMat.opacity !== clampedOpacity) {\n const clone = colorMat.clone();\n clone.opacity = clampedOpacity;\n clone.transparent = clampedOpacity < 1;\n this.materialByOid.set(oid, clone);\n this.originalOpacityByMaterial.set(clone, 1);\n }\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n scene.add(mesh);\n const mat = colorMat\n ? (this.materialByOid.get(oid) as Material)\n : (mesh.material as Material);\n if (!this.originalOpacityByMaterial.has(mat)) {\n this.originalOpacityByMaterial.set(mat, mat.opacity);\n }\n mat.opacity = clampedOpacity;\n mat.transparent = clampedOpacity < 1;\n if (colorMat) mesh.material = mat;\n });\n\n if (!this.meshChangeHandlers.has(oid)) {\n const handler = () => this.applyToMeshes(oid);\n this.meshChangeHandlers.set(oid, handler);\n collector.addEventListener(\"mesh-change\", handler);\n }\n }\n\n this.context.hidePartsByOids(this.getAllModifiedOids());\n }\n\n /**\n * 恢复指定构件的透明度\n * 若该 oid 已无颜色且无透明度修改,则从场景移除 split mesh 并 unhide 原 mesh\n */\n restorePartOpacityByOids(oids: number[]): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n for (const oid of oids) {\n this.opacityModifiedOids.delete(oid);\n this.opacityByOid.delete(oid);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n for (const mat of getMaterials(mesh)) {\n const original = this.originalOpacityByMaterial.get(mat);\n if (original !== undefined) {\n mat.opacity = original;\n mat.transparent = original < 1;\n this.originalOpacityByMaterial.delete(mat);\n }\n }\n if (\n !this.coloredOids.has(oid) &&\n !this.opacityModifiedOids.has(oid) &&\n mesh.parent === scene\n ) {\n scene.remove(mesh);\n }\n });\n\n if (!this.coloredOids.has(oid) && !this.opacityModifiedOids.has(oid)) {\n const handler = this.meshChangeHandlers.get(oid);\n if (handler) {\n this.meshChangeHandlers.delete(oid);\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n }\n\n this.context.showPartsByOids(oids);\n }\n}\n","import type { MeshCollector } from \"../MeshCollector\";\nimport { Color, Material, MeshStandardMaterial, Object3D } from \"three\";\n\nimport type { ColorInput } from \"./PartColorHelper\";\n\n/** 内部使用:插件需提供的接口 */\ninterface PartBlinkHelperContext {\n hidePartsByOids(oids: number[]): void;\n showPartsByOids(oids: number[]): void;\n getMeshCollectorByOid(oid: number): MeshCollector;\n getScene(): Object3D | null;\n}\n\nfunction ensureColor(color: ColorInput): Color {\n if (color instanceof Color) return color;\n return new Color(color);\n}\n\n/**\n * 构件闪烁强调辅助器\n * 通过 hidePartsByOids + split mesh + emissive 动画实现闪烁效果\n */\nexport class PartBlinkHelper {\n private blinkOids = new Set<number>();\n private originalMaterialByMesh = new Map<string, Material>();\n private meshChangeHandlers = new Map<number, () => void>();\n\n private blinkMaterial: MeshStandardMaterial;\n private blinkColor: Color;\n private cycleMs: number;\n private flashTime = 0;\n private rafId: number | null = null;\n private lastTime = 0;\n\n constructor(private context: PartBlinkHelperContext) {\n this.blinkColor = new Color(0xffaa00);\n this.blinkMaterial = new MeshStandardMaterial({\n color: this.blinkColor.clone(),\n emissive: this.blinkColor.clone(),\n emissiveIntensity: 0.5,\n transparent: true,\n opacity: 0.9,\n });\n this.cycleMs = 1000;\n }\n\n private applyBlinkToMeshes(oid: number): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n if (!mesh.parent) scene.add(mesh);\n if (!this.originalMaterialByMesh.has(mesh.uuid)) {\n this.originalMaterialByMesh.set(mesh.uuid, mesh.material as Material);\n }\n mesh.material = this.blinkMaterial;\n });\n }\n\n private startAnimation(): void {\n if (this.rafId !== null) return;\n this.lastTime = performance.now();\n\n const tick = () => {\n this.rafId = requestAnimationFrame(tick);\n const now = performance.now();\n const delta = (now - this.lastTime) / this.cycleMs;\n this.lastTime = now;\n this.flashTime += delta * Math.PI * 2;\n const intensity = 0.3 + Math.sin(this.flashTime) * 0.3;\n this.blinkMaterial.emissiveIntensity = intensity;\n };\n tick();\n }\n\n private stopAnimation(): void {\n if (this.rafId !== null) {\n cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n }\n\n /**\n * 设置需要闪烁的构件\n * @param oids 构件 OID 数组\n */\n setBlinkPartsByOids(oids: number[]): void {\n this.clearAllBlinkParts();\n\n const scene = this.context.getScene();\n if (!scene) return;\n\n for (const oid of oids) {\n this.blinkOids.add(oid);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n if (!this.originalMaterialByMesh.has(mesh.uuid)) {\n this.originalMaterialByMesh.set(mesh.uuid, mesh.material as Material);\n }\n mesh.material = this.blinkMaterial;\n scene.add(mesh);\n });\n\n const handler = () => this.applyBlinkToMeshes(oid);\n this.meshChangeHandlers.set(oid, handler);\n collector.addEventListener(\"mesh-change\", handler);\n }\n\n this.context.hidePartsByOids(Array.from(this.blinkOids));\n if (this.blinkOids.size > 0) this.startAnimation();\n }\n\n /**\n * 设置闪烁颜色\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setBlinkColor(color: ColorInput): void {\n const c = ensureColor(color);\n this.blinkColor.copy(c);\n this.blinkMaterial.color.copy(c);\n this.blinkMaterial.emissive.copy(c);\n }\n\n /**\n * 设置闪烁周期时间(毫秒)\n * @param ms 一个完整闪烁周期(暗->亮->暗)的时长,默认 1000\n */\n setBlinkIntervalTime(ms: number): void {\n this.cycleMs = Math.max(100, ms);\n }\n\n /**\n * 清除所有闪烁构件\n */\n clearAllBlinkParts(): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n this.stopAnimation();\n\n const oidsToUnhide = Array.from(this.blinkOids);\n\n for (const oid of oidsToUnhide) {\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n const original = this.originalMaterialByMesh.get(mesh.uuid);\n if (original) {\n mesh.material = original;\n this.originalMaterialByMesh.delete(mesh.uuid);\n }\n if (mesh.parent === scene) scene.remove(mesh);\n });\n\n const handler = this.meshChangeHandlers.get(oid);\n if (handler) {\n this.meshChangeHandlers.delete(oid);\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n\n this.blinkOids.clear();\n this.context.showPartsByOids(oidsToUnhide);\n }\n\n dispose(): void {\n this.clearAllBlinkParts();\n }\n}\n","import type { MeshCollector } from \"../MeshCollector\";\nimport type { ColorInput } from \"./PartColorHelper\";\nimport {\n Color,\n DoubleSide,\n EdgesGeometry,\n LineSegments,\n Material,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n} from \"three\";\n\nfunction ensureColor(color: ColorInput): Color {\n if (color instanceof Color) return color;\n return new Color(color);\n}\n\n/** 内部使用:插件需提供的接口 */\ninterface PartFrameHelperContext {\n hidePartsByOids(oids: number[]): void;\n showPartsByOids(oids: number[]): void;\n getMeshCollectorByOid(oid: number): MeshCollector;\n getScene(): Object3D | null;\n}\n\ninterface FrameOidData {\n meshes: Mesh[];\n lines: LineSegments[];\n}\n\n/**\n * 构件线框显示辅助器\n * 通过 hidePartsByOids + split mesh + 填充材质 + EdgesGeometry 实现线框效果\n */\nconst DEFAULT_FRAME_COLOR = 0x00d4aa;\n\nexport class PartFrameHelper {\n private frameOids = new Set<number>();\n private originalMaterialByMesh = new Map<string, Material>();\n private frameDataByOid = new Map<number, FrameOidData>();\n private meshChangeHandlers = new Map<number, () => void>();\n\n private fillColorByOid = new Map<number, number>();\n private edgeColorByOid = new Map<number, number>();\n private fillMaterialCache = new Map<number, MeshBasicMaterial>();\n private edgeMaterialCache = new Map<number, MeshBasicMaterial>();\n private edgeThreshold: number;\n\n constructor(private context: PartFrameHelperContext) {\n this.edgeThreshold = 15;\n }\n\n private getFillMaterial(hex: number): MeshBasicMaterial {\n if (!this.fillMaterialCache.has(hex)) {\n this.fillMaterialCache.set(\n hex,\n new MeshBasicMaterial({\n color: hex,\n transparent: true,\n opacity: 0.3,\n side: DoubleSide,\n depthWrite: false,\n })\n );\n }\n return this.fillMaterialCache.get(hex)!;\n }\n\n private getEdgeMaterial(hex: number): MeshBasicMaterial {\n if (!this.edgeMaterialCache.has(hex)) {\n this.edgeMaterialCache.set(\n hex,\n new MeshBasicMaterial({\n color: hex,\n transparent: true,\n opacity: 0.8,\n })\n );\n }\n return this.edgeMaterialCache.get(hex)!;\n }\n\n private createWireframeForMeshes(\n meshes: Mesh[],\n scene: Object3D,\n oid: number\n ): FrameOidData {\n const fillHex = this.fillColorByOid.get(oid) ?? DEFAULT_FRAME_COLOR;\n const edgeHex = this.edgeColorByOid.get(oid) ?? DEFAULT_FRAME_COLOR;\n const fillMaterial = this.getFillMaterial(fillHex);\n const edgeMaterial = this.getEdgeMaterial(edgeHex);\n\n const frameMeshes: Mesh[] = [];\n const lines: LineSegments[] = [];\n\n for (const mesh of meshes) {\n if (!this.originalMaterialByMesh.has(mesh.uuid)) {\n this.originalMaterialByMesh.set(mesh.uuid, mesh.material as Material);\n }\n mesh.material = fillMaterial;\n scene.add(mesh);\n frameMeshes.push(mesh);\n\n const edges = new EdgesGeometry(mesh.geometry, this.edgeThreshold);\n const line = new LineSegments(edges, edgeMaterial);\n line.matrix.copy(mesh.matrixWorld);\n line.matrixAutoUpdate = false;\n scene.add(line);\n lines.push(line);\n }\n\n return { meshes: frameMeshes, lines };\n }\n\n private removeFrameData(data: FrameOidData, scene: Object3D): void {\n for (const mesh of data.meshes) {\n const original = this.originalMaterialByMesh.get(mesh.uuid);\n if (original) {\n mesh.material = original;\n this.originalMaterialByMesh.delete(mesh.uuid);\n }\n if (mesh.parent === scene) scene.remove(mesh);\n }\n for (const line of data.lines) {\n if (line.parent === scene) scene.remove(line);\n line.geometry.dispose();\n }\n }\n\n private applyFrameToOid(oid: number): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const collector = this.context.getMeshCollectorByOid(oid);\n const oldData = this.frameDataByOid.get(oid);\n if (oldData) this.removeFrameData(oldData, scene);\n\n const newData = this.createWireframeForMeshes(collector.meshes, scene, oid);\n this.frameDataByOid.set(oid, newData);\n }\n\n /**\n * 设置需要线框显示的构件\n * @param oids 构件 OID 数组\n */\n setFramePartsByOids(oids: number[]): void {\n this.clearAllFrameParts();\n\n const scene = this.context.getScene();\n if (!scene) return;\n\n for (const oid of oids) {\n this.frameOids.add(oid);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n const data = this.createWireframeForMeshes(collector.meshes, scene, oid);\n this.frameDataByOid.set(oid, data);\n\n const handler = () => this.applyFrameToOid(oid);\n this.meshChangeHandlers.set(oid, handler);\n collector.addEventListener(\"mesh-change\", handler);\n }\n\n this.context.hidePartsByOids(Array.from(this.frameOids));\n }\n\n /**\n * 清除所有线框显示构件\n */\n clearAllFrameParts(): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const oidsToUnhide = Array.from(this.frameOids);\n\n for (const oid of oidsToUnhide) {\n const data = this.frameDataByOid.get(oid);\n if (data) {\n this.removeFrameData(data, scene);\n this.frameDataByOid.delete(oid);\n }\n\n const handler = this.meshChangeHandlers.get(oid);\n if (handler) {\n this.meshChangeHandlers.delete(oid);\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n\n this.frameOids.clear();\n this.fillColorByOid.clear();\n this.edgeColorByOid.clear();\n this.context.showPartsByOids(oidsToUnhide);\n }\n\n /**\n * 设置指定构件的线框填充颜色\n * @param oids 构件 OID 数组\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setFrameFillColor(oids: number[], color: ColorInput): void {\n const hex = ensureColor(color).getHex();\n for (const oid of oids) {\n if (!this.frameOids.has(oid)) continue;\n this.fillColorByOid.set(oid, hex);\n this.applyFrameToOid(oid);\n }\n }\n\n /**\n * 设置指定构件的线框边框颜色\n * @param oids 构件 OID 数组\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setFrameEdgeColor(oids: number[], color: ColorInput): void {\n const hex = ensureColor(color).getHex();\n for (const oid of oids) {\n if (!this.frameOids.has(oid)) continue;\n this.edgeColorByOid.set(oid, hex);\n this.applyFrameToOid(oid);\n }\n }\n\n dispose(): void {\n this.clearAllFrameParts();\n this.fillMaterialCache.forEach((m) => m.dispose());\n this.fillMaterialCache.clear();\n this.edgeMaterialCache.forEach((m) => m.dispose());\n this.edgeMaterialCache.clear();\n }\n}\n","import { Mesh } from \"three\";\nimport type { MeshCollector } from \"../MeshCollector\";\n\nexport interface InteractionFilterContext {\n getCollectorCache(): Map<number, MeshCollector>;\n}\n\n/**\n * 冻结与隔离逻辑:管理构件的交互过滤及 getMeshCollectorByOid 获取的 mesh 在场景中的显隐\n */\nexport class InteractionFilter {\n private frozenOids = new Set<number>();\n private isolatedOids = new Set<number>();\n private trackedMeshes = new Map<number, Set<Mesh>>();\n private meshListeners = new Map<\n Mesh,\n { onAdded: () => void; onRemoved: () => void }\n >();\n private isPluginRemoving = false;\n\n constructor(private context: InteractionFilterContext) {}\n\n isOidBlocked(oid: number): boolean {\n if (this.frozenOids.has(oid)) return true;\n if (this.isolatedOids.size > 0 && !this.isolatedOids.has(oid)) return true;\n return false;\n }\n\n private trackMesh(mesh: Mesh, oid: number): void {\n if (this.meshListeners.has(mesh)) return;\n\n const onAdded = () => {\n if (this.isPluginRemoving) return;\n mesh.userData._detachedParent = null;\n if (this.isOidBlocked(oid) && mesh.parent) {\n const parent = mesh.parent;\n this.isPluginRemoving = true;\n mesh.userData._detachedParent = parent;\n parent.remove(mesh);\n this.isPluginRemoving = false;\n }\n };\n\n const onRemoved = () => {\n if (this.isPluginRemoving) return;\n mesh.userData._detachedParent = null;\n };\n\n mesh.addEventListener(\"added\", onAdded);\n mesh.addEventListener(\"removed\", onRemoved);\n this.meshListeners.set(mesh, { onAdded, onRemoved });\n }\n\n private untrackMesh(mesh: Mesh): void {\n const listeners = this.meshListeners.get(mesh);\n if (listeners) {\n mesh.removeEventListener(\"added\", listeners.onAdded);\n mesh.removeEventListener(\"removed\", listeners.onRemoved);\n this.meshListeners.delete(mesh);\n }\n mesh.userData._detachedParent = null;\n }\n\n onCollectorMeshChange(oid: number, newMeshes: Mesh[]): void {\n const tracked = this.trackedMeshes.get(oid);\n const newSet = new Set(newMeshes);\n\n if (tracked) {\n for (const mesh of tracked) {\n if (!newSet.has(mesh)) {\n this.untrackMesh(mesh);\n tracked.delete(mesh);\n }\n }\n }\n\n const trackSet = tracked || new Set<Mesh>();\n for (const mesh of newMeshes) {\n if (!trackSet.has(mesh)) {\n this.trackMesh(mesh, oid);\n trackSet.add(mesh);\n }\n }\n this.trackedMeshes.set(oid, trackSet);\n }\n\n private syncCollectorMeshes(): void {\n this.isPluginRemoving = true;\n\n for (const [oid, collector] of this.context.getCollectorCache()) {\n const blocked = this.isOidBlocked(oid);\n\n for (const mesh of collector.meshes) {\n if (!this.meshListeners.has(mesh)) continue;\n\n if (blocked) {\n if (mesh.parent && !mesh.userData._detachedParent) {\n const parent = mesh.parent;\n mesh.userData._detachedParent = parent;\n parent.remove(mesh);\n }\n } else {\n const storedParent = mesh.userData._detachedParent;\n if (storedParent && !mesh.parent) {\n storedParent.add(mesh);\n mesh.userData._detachedParent = null;\n }\n }\n }\n }\n\n this.isPluginRemoving = false;\n }\n\n onUnregisterCollector(oid: number): void {\n const tracked = this.trackedMeshes.get(oid);\n if (tracked) {\n for (const mesh of tracked) {\n this.untrackMesh(mesh);\n }\n this.trackedMeshes.delete(oid);\n }\n }\n\n freezeByOids(oids: number[]): void {\n for (const oid of oids) {\n this.frozenOids.add(oid);\n }\n this.syncCollectorMeshes();\n }\n\n freezeByOid(oid: number): void {\n this.frozenOids.add(oid);\n this.syncCollectorMeshes();\n }\n\n unfreezeByOids(oids: number[]): void {\n for (const oid of oids) {\n this.frozenOids.delete(oid);\n }\n this.syncCollectorMeshes();\n }\n\n unfreezeByOid(oid: number): void {\n this.frozenOids.delete(oid);\n this.syncCollectorMeshes();\n }\n\n unfreeze(): void {\n this.frozenOids.clear();\n this.syncCollectorMeshes();\n }\n\n getFrozenOids(): number[] {\n return Array.from(this.frozenOids);\n }\n\n isolateByOids(oids: number[]): void {\n for (const oid of oids) {\n this.isolatedOids.add(oid);\n }\n this.syncCollectorMeshes();\n }\n\n isolateByOid(oid: number): void {\n this.isolatedOids.add(oid);\n this.syncCollectorMeshes();\n }\n\n unisolateByOids(oids: number[]): void {\n for (const oid of oids) {\n this.isolatedOids.delete(oid);\n }\n this.syncCollectorMeshes();\n }\n\n unisolateByOid(oid: number): void {\n this.isolatedOids.delete(oid);\n this.syncCollectorMeshes();\n }\n\n unisolate(): void {\n this.isolatedOids.clear();\n this.syncCollectorMeshes();\n }\n\n getIsolatedOids(): number[] {\n return Array.from(this.isolatedOids);\n }\n\n dispose(): void {\n for (const [, meshSet] of this.trackedMeshes) {\n for (const mesh of meshSet) {\n this.untrackMesh(mesh);\n }\n }\n this.trackedMeshes.clear();\n this.meshListeners.clear();\n this.frozenOids.clear();\n this.isolatedOids.clear();\n }\n}\n","// IndexedDB constants\nconst DB_NAME = \"GLTFParserPluginTilesCache\";\nconst DB_VERSION = 1;\nconst STORE_NAME = \"tiles\";\n\n/**\n * IndexedDB Cache Manager Class\n */\nexport class TileCacheDB {\n private dbPromise: Promise<IDBDatabase> | null = null;\n\n /**\n * Open/Get database connection\n */\n private openDB(): Promise<IDBDatabase> {\n if (this.dbPromise) {\n return this.dbPromise;\n }\n\n this.dbPromise = new Promise((resolve, reject) => {\n const request = indexedDB.open(DB_NAME, DB_VERSION);\n\n request.onerror = () => {\n reject(request.error);\n };\n\n request.onsuccess = () => {\n resolve(request.result);\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n if (!db.objectStoreNames.contains(STORE_NAME)) {\n db.createObjectStore(STORE_NAME, { keyPath: \"url\" });\n }\n };\n });\n\n return this.dbPromise;\n }\n\n /**\n * Get data from cache\n * @param url Cache key (processedUrl)\n */\n async get(url: string): Promise<ArrayBuffer | null> {\n try {\n const db = await this.openDB();\n return new Promise((resolve, reject) => {\n const transaction = db.transaction(STORE_NAME, \"readonly\");\n const store = transaction.objectStore(STORE_NAME);\n const request = store.get(url);\n\n request.onerror = () => {\n reject(request.error);\n };\n\n request.onsuccess = () => {\n const result = request.result;\n resolve(result ? result.data : null);\n };\n });\n } catch (error) {\n return null;\n }\n }\n\n /**\n * Store data to cache\n * @param url Cache key (processedUrl)\n * @param data Data to cache\n */\n async set(url: string, data: ArrayBuffer): Promise<void> {\n const db = await this.openDB();\n return new Promise((resolve, reject) => {\n const transaction = db.transaction(STORE_NAME, \"readwrite\");\n const store = transaction.objectStore(STORE_NAME);\n const request = store.put({\n url,\n data,\n timestamp: Date.now(),\n });\n\n request.onerror = () => {\n reject(request.error);\n };\n\n request.onsuccess = () => {\n resolve();\n };\n });\n }\n\n /**\n * Clear cache\n */\n async clear(): Promise<void> {\n const db = await this.openDB();\n return new Promise((resolve, reject) => {\n const transaction = db.transaction(STORE_NAME, \"readwrite\");\n const store = transaction.objectStore(STORE_NAME);\n const request = store.clear();\n\n request.onerror = () => reject(request.error);\n request.onsuccess = () => resolve();\n });\n }\n}\n\n// Global cache instance\nexport const tileCache = new TileCacheDB();\n","import {\r\n Box3,\r\n DoubleSide,\r\n Intersection,\r\n Material,\r\n Mesh,\r\n Object3D,\r\n WebGLRenderer,\r\n} from \"three\";\r\nimport type { Vector3 } from \"three\";\r\nimport {\r\n FeatureIdUniforms,\r\n FeatureInfo,\r\n buildOidToFeatureIdMap,\r\n getSplitMeshesFromTile,\r\n getTileMeshesByOid,\r\n queryFeatureFromIntersection,\r\n} from \"./mesh-helper\";\r\n\r\nimport { MeshCollector, type MeshHelperHost } from \"./MeshCollector\";\r\nimport { GLTFWorkerLoader } from \"./GLTFWorkerLoader\";\r\nimport {\r\n PartColorHelper,\r\n type ColorInput,\r\n} from \"./plugin/PartColorHelper\";\r\nimport { PartBlinkHelper } from \"./plugin/PartBlinkHelper\";\r\nimport { PartFrameHelper } from \"./plugin/PartFrameHelper\";\r\nimport { InteractionFilter } from \"./plugin/InteractionFilter\";\r\nimport { setMaxWorkers } from \"./utils\";\r\nimport {\r\n selectByBoxFromOidMap,\r\n selectByPolygonFromOidMap,\r\n} from \"./utils/spatial-query\";\r\nimport { tileCache } from \"./db\";\r\nimport { TilesRenderer } from \"3d-tiles-renderer\";\r\n\r\nimport type {\r\n GLTFParserPluginOptions,\r\n ModelInfo,\r\n StructureData,\r\n StructureNode,\r\n} from \"./plugin-types\";\r\n\r\nexport type {\r\n GLTFParserPluginOptions,\r\n ModelInfo,\r\n StructureData,\r\n StructureNode,\r\n};\r\n\r\ninterface TileWithCache {\r\n cached?: {\r\n scene: Object3D;\r\n };\r\n}\r\n\r\nexport class GLTFParserPlugin implements MeshHelperHost {\r\n name = \"GLTFParserPlugin\";\r\n\r\n private tiles: (TilesRenderer & Record<string, any>) | null = null;\r\n private _loader: GLTFWorkerLoader | null = null;\r\n private readonly _gltfRegex = /\\.(gltf|glb)$/g;\r\n private readonly _options: GLTFParserPluginOptions;\r\n\r\n // --- Structure data properties ---\r\n private _structureData: StructureData | null = null;\r\n private _oidNodeMap: Map<number, StructureNode> = new Map();\r\n private _structurePromise: Promise<StructureData | null> | null = null;\r\n\r\n // --- Model info properties ---\r\n private _modelInfo: ModelInfo | null = null;\r\n private _modelInfoPromise: Promise<ModelInfo | null> | null = null;\r\n\r\n private _interactionFilter: InteractionFilter;\r\n private _partColorHelper: PartColorHelper | null = null;\r\n private _partBlinkHelper: PartBlinkHelper | null = null;\r\n private _partFrameHelper: PartFrameHelper | null = null;\r\n\r\n // --- Mesh helper properties ---\r\n oids: number[] = [];\r\n private renderer: WebGLRenderer | null = null;\r\n private splitMeshCache: Map<string, Mesh[]> = new Map();\r\n private maxUniformVectors: number = 1024;\r\n private featureIdCount: number = 32;\r\n private collectors: Set<MeshCollector> = new Set();\r\n private collectorCache: Map<number, MeshCollector> = new Map();\r\n\r\n /**\r\n * Create a GLTFParserPlugin instance\r\n * @param options configuration options\r\n */\r\n constructor(options?: GLTFParserPluginOptions) {\r\n this._options = {\r\n metadata: true,\r\n maxWorkers: navigator.hardwareConcurrency || 4,\r\n useIndexedDB: false,\r\n ...options,\r\n };\r\n\r\n if (options?.renderer) {\r\n this.renderer = options.renderer;\r\n }\r\n\r\n this._interactionFilter = new InteractionFilter({\r\n getCollectorCache: () => this.collectorCache,\r\n });\r\n\r\n setMaxWorkers(this._options.maxWorkers!);\r\n }\r\n\r\n /**\r\n * Plugin initialization, called by TilesRenderer\r\n */\r\n init(tiles: TilesRenderer) {\r\n this.tiles = tiles;\r\n\r\n this._partColorHelper = new PartColorHelper({\r\n hidePartsByOids: (oids) => this.hidePartsByOids(oids),\r\n showPartsByOids: (oids) => this.showPartsByOids(oids),\r\n getMeshCollectorByOid: (oid) => this.getMeshCollectorByOid(oid),\r\n getScene: () => this.tiles?.group ?? null,\r\n });\r\n\r\n this._partBlinkHelper = new PartBlinkHelper({\r\n hidePartsByOids: (oids) => this.hidePartsByOids(oids),\r\n showPartsByOids: (oids) => this.showPartsByOids(oids),\r\n getMeshCollectorByOid: (oid) => this.getMeshCollectorByOid(oid),\r\n getScene: () => this.tiles?.group ?? null,\r\n });\r\n\r\n this._partFrameHelper = new PartFrameHelper({\r\n hidePartsByOids: (oids) => this.hidePartsByOids(oids),\r\n showPartsByOids: (oids) => this.showPartsByOids(oids),\r\n getMeshCollectorByOid: (oid) => this.getMeshCollectorByOid(oid),\r\n getScene: () => this.tiles?.group ?? null,\r\n });\r\n\r\n // --- GLTF loader setup ---\r\n this._loader = new GLTFWorkerLoader(tiles.manager, {\r\n metadata: this._options.metadata,\r\n materialBuilder: this._options.materialBuilder,\r\n });\r\n tiles.manager.addHandler(this._gltfRegex, this._loader);\r\n\r\n // --- Mesh helper setup ---\r\n if (this.renderer) {\r\n this._updateWebGLLimits();\r\n }\r\n\r\n tiles.addEventListener(\"load-model\", this._onLoadModelCB);\r\n tiles.addEventListener(\"tiles-load-end\", this._onTilesLoadEndCB);\r\n\r\n tiles.traverse((tile: any) => {\r\n const tileWithCache = tile as TileWithCache;\r\n if (tileWithCache.cached?.scene) {\r\n this._onLoadModel(tileWithCache.cached.scene);\r\n }\r\n return true;\r\n }, null);\r\n }\r\n\r\n // =============================================\r\n // GLTF Parser Methods\r\n // =============================================\r\n\r\n /**\r\n * Fetch tile data with IndexedDB caching support\r\n */\r\n async fetchData(\r\n url: string,\r\n options?: RequestInit,\r\n ): Promise<Response | ArrayBuffer | object> {\r\n const isJson = url.toLowerCase().endsWith(\".json\");\r\n if (!this._options.useIndexedDB || isJson) {\r\n return this.tiles!.fetchData(url, options);\r\n }\r\n\r\n try {\r\n const cachedData = await tileCache.get(url);\r\n\r\n if (cachedData) {\r\n return cachedData;\r\n }\r\n\r\n const response = await this.tiles!.fetchData(url, options);\r\n\r\n if (!response.ok) {\r\n return response;\r\n }\r\n\r\n const arrayBuffer = await response.arrayBuffer();\r\n\r\n tileCache.set(url, arrayBuffer).catch((err: unknown) => {\r\n console.warn(\"[GLTFParserPlugin] Failed to cache data:\", err);\r\n });\r\n\r\n return arrayBuffer;\r\n } catch (error) {\r\n return this.tiles!.fetchData(url, options);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all cached tile data from IndexedDB\r\n */\r\n async clearCache(): Promise<void> {\r\n await tileCache.clear();\r\n console.info(\"[GLTFParserPlugin] Cache cleared\");\r\n }\r\n\r\n async parseTile(\r\n buffer: ArrayBuffer,\r\n tile: any,\r\n extension: any,\r\n uri: string,\r\n abortSignal: AbortSignal,\r\n ) {\r\n if (this._options.beforeParseTile) {\r\n buffer = await this._options.beforeParseTile(\r\n buffer,\r\n tile,\r\n extension,\r\n uri,\r\n abortSignal,\r\n );\r\n }\r\n return this.tiles!.parseTile(buffer, tile, extension, uri, abortSignal);\r\n }\r\n\r\n // =============================================\r\n // Structure Data Methods\r\n // =============================================\r\n\r\n private _getStructureUrl(): string | null {\r\n const rootURL = this.tiles?.rootURL as string | undefined;\r\n if (!rootURL) return null;\r\n return rootURL.replace(/[^/]+$/, \"structure.json\");\r\n }\r\n\r\n private _buildOidNodeMap(\r\n node: StructureNode,\r\n map: Map<number, StructureNode>,\r\n ): void {\r\n if (node.id !== undefined) {\r\n map.set(node.id, node);\r\n }\r\n if (node.children) {\r\n for (const child of node.children) {\r\n this._buildOidNodeMap(child, map);\r\n }\r\n }\r\n }\r\n\r\n private async _fetchStructureData(): Promise<StructureData | null> {\r\n const url = this._getStructureUrl();\r\n if (!url) {\r\n console.warn(\r\n \"[GLTFParserPlugin] Cannot derive structure.json URL: tiles not initialized\",\r\n );\r\n return null;\r\n }\r\n\r\n try {\r\n const response = await fetch(url);\r\n if (!response.ok) {\r\n console.warn(\r\n `[GLTFParserPlugin] Failed to fetch structure.json: ${response.status}`,\r\n );\r\n return null;\r\n }\r\n const data: StructureData = await response.json();\r\n this._structureData = data;\r\n\r\n this._oidNodeMap.clear();\r\n if (data.trees) {\r\n for (const tree of data.trees) {\r\n this._buildOidNodeMap(tree, this._oidNodeMap);\r\n }\r\n }\r\n\r\n return data;\r\n } catch (error) {\r\n console.error(\"[GLTFParserPlugin] Error loading structure.json:\", error);\r\n return null;\r\n }\r\n }\r\n\r\n private async _ensureStructureLoaded(): Promise<StructureData | null> {\r\n if (this._structureData) return this._structureData;\r\n if (!this._structurePromise) {\r\n this._structurePromise = this._fetchStructureData();\r\n }\r\n return this._structurePromise;\r\n }\r\n\r\n /**\r\n * 根据 oid 获取 structure.json 中对应的节点树数据\r\n * 包含 bbox、children、name 等完整结构信息\r\n * 首次调用时会自动从 tileset URL 推导并请求 structure.json\r\n */\r\n async getNodeTreeByOid(oid: number): Promise<StructureNode | null> {\r\n await this._ensureStructureLoaded();\r\n return this._oidNodeMap.get(oid) ?? null;\r\n }\r\n\r\n /**\r\n * 根据 oid 数组批量获取 structure.json 中对应的节点树数据\r\n */\r\n async getNodeTreeByOids(oids: number[]): Promise<Map<number, StructureNode>> {\r\n await this._ensureStructureLoaded();\r\n const result = new Map<number, StructureNode>();\r\n for (const oid of oids) {\r\n const node = this._oidNodeMap.get(oid);\r\n if (node) {\r\n result.set(oid, node);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n /**\r\n * 获取完整的 structure.json 数据\r\n * 首次调用时会自动请求\r\n */\r\n async getStructureData(): Promise<StructureData | null> {\r\n return this._ensureStructureLoaded();\r\n }\r\n\r\n /**\r\n * 选择包围盒范围内的构件(包含相交和包含两种情况)\r\n * @param box 查询用的 Box3 范围,坐标系与 structure.json 中 bbox 一致\r\n * @returns 范围内所有构件的 oid 数组\r\n */\r\n async selectByBox(box: Box3): Promise<number[]> {\r\n await this._ensureStructureLoaded();\r\n return selectByBoxFromOidMap(this._oidNodeMap, box);\r\n }\r\n\r\n /**\r\n * 选择多边形(平面投影)范围内的构件(包含相交和包含两种情况)\r\n * @param polygon 多边形顶点数组(Vector3),按顺序连接构成闭合多边形\r\n * @param axis 投影平面,决定使用 bbox 的哪两个轴做 2D 判定\r\n * - 'xz'(默认):俯视图,取 bbox 的 x/z 坐标\r\n * - 'xy':正视图,取 bbox 的 x/y 坐标\r\n * - 'yz':侧视图,取 bbox 的 y/z 坐标\r\n * @returns 范围内所有构件的 oid 数组\r\n */\r\n async selectByPolygon(\r\n polygon: Vector3[],\r\n axis: \"xy\" | \"xz\" | \"yz\" = \"xz\",\r\n ): Promise<number[]> {\r\n await this._ensureStructureLoaded();\r\n return selectByPolygonFromOidMap(this._oidNodeMap, polygon, axis);\r\n }\r\n\r\n // =============================================\r\n // Model Info Methods\r\n // =============================================\r\n\r\n private _getModelInfoUrl(): string | null {\r\n const rootURL = this.tiles?.rootURL as string | undefined;\r\n if (!rootURL) return null;\r\n return rootURL.replace(/[^/]+$/, \"modelInfo.json\");\r\n }\r\n\r\n private async _fetchModelInfo(): Promise<ModelInfo | null> {\r\n const url = this._getModelInfoUrl();\r\n if (!url) {\r\n console.warn(\r\n \"[GLTFParserPlugin] Cannot derive modelInfo.json URL: tiles not initialized\",\r\n );\r\n return null;\r\n }\r\n\r\n try {\r\n const response = await fetch(url);\r\n if (!response.ok) {\r\n console.warn(\r\n `[GLTFParserPlugin] Failed to fetch modelInfo.json: ${response.status}`,\r\n );\r\n return null;\r\n }\r\n const data: ModelInfo = await response.json();\r\n this._modelInfo = data;\r\n return data;\r\n } catch (error) {\r\n console.error(\"[GLTFParserPlugin] Error loading modelInfo.json:\", error);\r\n return null;\r\n }\r\n }\r\n\r\n private async _ensureModelInfoLoaded(): Promise<ModelInfo | null> {\r\n if (this._modelInfo) return this._modelInfo;\r\n if (!this._modelInfoPromise) {\r\n this._modelInfoPromise = this._fetchModelInfo();\r\n }\r\n return this._modelInfoPromise;\r\n }\r\n\r\n /**\r\n * 获取 modelInfo.json 数据\r\n * 包含模型的基本信息:动画支持、材质数量、顶点数、三角形数等\r\n * 首次调用时会自动从 tileset URL 推导并请求 modelInfo.json\r\n */\r\n async getModelInfo(): Promise<ModelInfo | null> {\r\n return this._ensureModelInfoLoaded();\r\n }\r\n\r\n // =============================================\r\n // Mesh Helper Methods (from MaptalksTilerPlugin)\r\n // =============================================\r\n\r\n /**\r\n * Load model callback\r\n */\r\n private _onLoadModelCB = ({ scene }: { scene: Object3D }) => {\r\n this._onLoadModel(scene);\r\n };\r\n\r\n /**\r\n * Tiles load end callback\r\n */\r\n private _onTilesLoadEndCB = () => {\r\n this._notifyCollectors();\r\n };\r\n\r\n private _onLoadModel(scene: Object3D) {\r\n this.splitMeshCache.clear();\r\n\r\n buildOidToFeatureIdMap(scene);\r\n scene.traverse((c) => {\r\n if ((c as Mesh).material) {\r\n this._setupMaterial(c as Mesh);\r\n }\r\n });\r\n }\r\n\r\n private _notifyCollectors(): void {\r\n for (const collector of this.collectors) {\r\n collector._updateMeshes();\r\n }\r\n }\r\n\r\n _registerCollector(collector: MeshCollector): void {\r\n this.collectors.add(collector);\r\n }\r\n\r\n _unregisterCollector(collector: MeshCollector): void {\r\n const oid = collector.getOid();\r\n this.collectors.delete(collector);\r\n this.collectorCache.delete(oid);\r\n this._interactionFilter.onUnregisterCollector(oid);\r\n }\r\n\r\n private _updateWebGLLimits() {\r\n const gl = this.renderer!.getContext();\r\n const maxVectors = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS);\r\n this.maxUniformVectors = maxVectors;\r\n }\r\n\r\n /**\r\n * Dynamically calculate FEATURE_ID_COUNT based on WebGL limits and current oid count\r\n */\r\n private _calculateFeatureIdCount(): number {\r\n const maxUniformVectors = this.maxUniformVectors;\r\n const currentOidCount = this.oids.length;\r\n\r\n if (currentOidCount > maxUniformVectors) {\r\n throw new Error(\r\n `The number of OIDs to hide (${currentOidCount}) exceeds the WebGL MAX_FRAGMENT_UNIFORM_VECTORS limit (${maxUniformVectors}).`,\r\n );\r\n }\r\n\r\n const minFeatureIdCount = 32;\r\n\r\n if (currentOidCount <= minFeatureIdCount) {\r\n return minFeatureIdCount;\r\n }\r\n\r\n const powerOf2 = Math.ceil(Math.log2(currentOidCount));\r\n return Math.pow(2, powerOf2);\r\n }\r\n\r\n /**\r\n * Set up shader modification for hiding specific features\r\n */\r\n private _setupMaterial(mesh: Mesh) {\r\n const material = mesh.material as Material;\r\n\r\n if (material.userData._meshHelperSetup) {\r\n return;\r\n }\r\n material.userData._meshHelperSetup = true;\r\n\r\n material.side = DoubleSide;\r\n\r\n const previousOnBeforeCompile = material.onBeforeCompile;\r\n\r\n if (!material.defines) {\r\n material.defines = {};\r\n }\r\n\r\n material.userData._materialFeatureIdCount = this.featureIdCount;\r\n\r\n Object.defineProperty(material.defines, \"FEATURE_ID_COUNT\", {\r\n get: () => {\r\n if (material.userData._materialFeatureIdCount !== this.featureIdCount) {\r\n material.userData._materialFeatureIdCount = this.featureIdCount;\r\n material.needsUpdate = true;\r\n }\r\n return material.userData._materialFeatureIdCount;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n });\r\n\r\n material.onBeforeCompile = (shader, renderer) => {\r\n previousOnBeforeCompile?.call(material, shader, renderer);\r\n\r\n if (shader.vertexShader.includes(\"varying float vFeatureId;\")) {\r\n return;\r\n }\r\n\r\n shader.uniforms.hiddenFeatureIds = new FeatureIdUniforms(mesh, this);\r\n\r\n shader.vertexShader = shader.vertexShader.replace(\r\n \"#include <common>\",\r\n `#include <common>\r\n attribute float _feature_id_0;\r\n varying float vFeatureId;`,\r\n );\r\n\r\n shader.vertexShader = shader.vertexShader.replace(\r\n \"#include <begin_vertex>\",\r\n `#include <begin_vertex>\r\n vFeatureId = _feature_id_0;`,\r\n );\r\n\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n \"#include <common>\",\r\n `#include <common>\r\n uniform float hiddenFeatureIds[FEATURE_ID_COUNT];\r\n varying float vFeatureId;\r\n \r\n bool shouldHideFeature(float featureId) {\r\n for(int i = 0; i < FEATURE_ID_COUNT; i++) {\r\n if(abs(hiddenFeatureIds[i] - featureId) < 0.001) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }`,\r\n );\r\n\r\n shader.fragmentShader = shader.fragmentShader.replace(\r\n \"void main() {\",\r\n `void main() {\r\n if(shouldHideFeature(vFeatureId)) {\r\n discard;\r\n }`,\r\n );\r\n };\r\n }\r\n\r\n /**\r\n * Query feature information from intersection\r\n * Respects freeze and isolate filters\r\n */\r\n queryFeatureFromIntersection(hit: Intersection): FeatureInfo {\r\n const result = queryFeatureFromIntersection(hit);\r\n\r\n if (result.isValid && result.oid !== undefined) {\r\n if (this._interactionFilter.isOidBlocked(result.oid)) {\r\n return {\r\n isValid: false,\r\n error: this._interactionFilter.getFrozenOids().includes(result.oid)\r\n ? \"Component is frozen\"\r\n : \"Component is not in isolated set\",\r\n };\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n // =============================================\r\n // Interaction Filter Methods (delegated)\r\n // =============================================\r\n\r\n freezeByOids(oids: number[]): void {\r\n this._interactionFilter.freezeByOids(oids);\r\n }\r\n\r\n freezeByOid(oid: number): void {\r\n this._interactionFilter.freezeByOid(oid);\r\n }\r\n\r\n unfreezeByOids(oids: number[]): void {\r\n this._interactionFilter.unfreezeByOids(oids);\r\n }\r\n\r\n unfreezeByOid(oid: number): void {\r\n this._interactionFilter.unfreezeByOid(oid);\r\n }\r\n\r\n unfreeze(): void {\r\n this._interactionFilter.unfreeze();\r\n }\r\n\r\n getFrozenOids(): number[] {\r\n return this._interactionFilter.getFrozenOids();\r\n }\r\n\r\n isolateByOids(oids: number[]): void {\r\n this._interactionFilter.isolateByOids(oids);\r\n }\r\n\r\n isolateByOid(oid: number): void {\r\n this._interactionFilter.isolateByOid(oid);\r\n }\r\n\r\n unisolateByOids(oids: number[]): void {\r\n this._interactionFilter.unisolateByOids(oids);\r\n }\r\n\r\n unisolateByOid(oid: number): void {\r\n this._interactionFilter.unisolateByOid(oid);\r\n }\r\n\r\n unisolate(): void {\r\n this._interactionFilter.unisolate();\r\n }\r\n\r\n getIsolatedOids(): number[] {\r\n return this._interactionFilter.getIsolatedOids();\r\n }\r\n\r\n /**\r\n * 内部方法:根据 oid 获取 mesh 数组\r\n */\r\n _getMeshesByOidInternal(oid: number): Mesh[] {\r\n const tileMeshes = getTileMeshesByOid(this.tiles!, oid);\r\n\r\n const allSplitMeshes: Mesh[] = [];\r\n\r\n for (const tileMesh of tileMeshes) {\r\n const cacheKey = `${oid}_${tileMesh.uuid}`;\r\n\r\n let splitMeshes = this.splitMeshCache.get(cacheKey);\r\n\r\n if (!splitMeshes) {\r\n splitMeshes = getSplitMeshesFromTile(tileMesh, oid);\r\n this.splitMeshCache.set(cacheKey, splitMeshes);\r\n }\r\n allSplitMeshes.push(...splitMeshes);\r\n }\r\n\r\n return allSplitMeshes;\r\n }\r\n\r\n /**\r\n * 根据 oid 获取 MeshCollector\r\n * MeshCollector 会监听瓦片变化,自动更新 meshes 并触发 mesh-change 事件\r\n * 内部缓存:相同 oid 多次调用会返回同一个 collector 实例\r\n */\r\n getMeshCollectorByOid(oid: number): MeshCollector {\r\n const existing = this.collectorCache.get(oid);\r\n if (existing) {\r\n return existing;\r\n }\r\n const collector = new MeshCollector(oid, this);\r\n this.collectorCache.set(oid, collector);\r\n\r\n this._interactionFilter.onCollectorMeshChange(oid, collector.meshes);\r\n\r\n collector.addEventListener(\"mesh-change\", (event) => {\r\n this._interactionFilter.onCollectorMeshChange(oid, event.meshes);\r\n });\r\n\r\n return collector;\r\n }\r\n\r\n /**\r\n * Hide the corresponding part of the original mesh according to the OID array\r\n */\r\n hidePartsByOids(oids: number[]): void {\r\n this.oids = oids;\r\n this.featureIdCount = this._calculateFeatureIdCount();\r\n }\r\n\r\n /**\r\n * Restore the display of the corresponding mesh according to the OID array\r\n */\r\n showPartsByOids(oids: number[]): void {\r\n const oidSet = new Set(oids);\r\n const newOids = this.oids.filter((existingOid) => !oidSet.has(existingOid));\r\n this.oids = newOids;\r\n this.featureIdCount = this._calculateFeatureIdCount();\r\n }\r\n\r\n /**\r\n * 根据 oid 数组设置构件颜色\r\n * 隐藏原 mesh,将 split mesh 替换材质后加入场景(使用 tiles.group)\r\n * @param oids 构件 OID 数组\r\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\r\n */\r\n setPartColorByOids(oids: number[], color: ColorInput): void {\r\n this._partColorHelper?.setPartColorByOids(oids, color);\r\n }\r\n\r\n /**\r\n * 恢复指定构件的颜色\r\n * 从场景移除 split mesh,恢复原 mesh 显示\r\n * @param oids 构件 OID 数组\r\n */\r\n restorePartColorByOids(oids: number[]): void {\r\n this._partColorHelper?.restorePartColorByOids(oids);\r\n }\r\n\r\n /**\r\n * 根据 oid 数组设置构件透明度\r\n * @param oids 构件 OID 数组\r\n * @param opacity 透明度,0-1,0 完全透明,1 完全不透明\r\n */\r\n setPartOpacityByOids(oids: number[], opacity: number): void {\r\n this._partColorHelper?.setPartOpacityByOids(oids, opacity);\r\n }\r\n\r\n /**\r\n * 恢复指定构件的透明度\r\n * @param oids 构件 OID 数组\r\n */\r\n restorePartOpacityByOids(oids: number[]): void {\r\n this._partColorHelper?.restorePartOpacityByOids(oids);\r\n }\r\n\r\n /**\r\n * 设置需要闪烁的构件\r\n * @param oids 构件 OID 数组\r\n */\r\n setBlinkPartsByOids(oids: number[]): void {\r\n this._partBlinkHelper?.setBlinkPartsByOids(oids);\r\n }\r\n\r\n /**\r\n * 设置闪烁颜色\r\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\r\n */\r\n setBlinkColor(color: ColorInput): void {\r\n this._partBlinkHelper?.setBlinkColor(color);\r\n }\r\n\r\n /**\r\n * 设置闪烁周期时间(毫秒)\r\n * @param ms 一个完整闪烁周期(暗->亮->暗)的时长,默认 1000\r\n */\r\n setBlinkIntervalTime(ms: number): void {\r\n this._partBlinkHelper?.setBlinkIntervalTime(ms);\r\n }\r\n\r\n /**\r\n * 清除所有闪烁构件\r\n */\r\n clearAllBlinkParts(): void {\r\n this._partBlinkHelper?.clearAllBlinkParts();\r\n }\r\n\r\n /**\r\n * 设置需要线框显示的构件\r\n * @param oids 构件 OID 数组\r\n */\r\n setFramePartsByOids(oids: number[]): void {\r\n this._partFrameHelper?.setFramePartsByOids(oids);\r\n }\r\n\r\n /**\r\n * 清除所有线框显示构件\r\n */\r\n clearAllFrameParts(): void {\r\n this._partFrameHelper?.clearAllFrameParts();\r\n }\r\n\r\n /**\r\n * 设置指定构件的线框填充颜色\r\n * @param oids 构件 OID 数组\r\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\r\n */\r\n setFrameFillColor(oids: number[], color: ColorInput): void {\r\n this._partFrameHelper?.setFrameFillColor(oids, color);\r\n }\r\n\r\n /**\r\n * 设置指定构件的线框边框颜色\r\n * @param oids 构件 OID 数组\r\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\r\n */\r\n setFrameEdgeColor(oids: number[], color: ColorInput): void {\r\n this._partFrameHelper?.setFrameEdgeColor(oids, color);\r\n }\r\n\r\n /**\r\n * Restore the original materials of the mesh\r\n */\r\n showAllParts(): void {\r\n this.oids = [];\r\n this.featureIdCount = this._calculateFeatureIdCount();\r\n }\r\n\r\n /**\r\n * Get the current feature ID count\r\n */\r\n getFeatureIdCount(): number {\r\n return this.featureIdCount;\r\n }\r\n\r\n /**\r\n * Plugin disposal\r\n */\r\n dispose() {\r\n if (this.tiles) {\r\n this.tiles.manager.removeHandler(this._gltfRegex);\r\n this.tiles.removeEventListener(\"load-model\", this._onLoadModelCB);\r\n this.tiles.removeEventListener(\"tiles-load-end\", this._onTilesLoadEndCB);\r\n }\r\n\r\n if (this._loader) {\r\n this._loader.removeListeners();\r\n }\r\n\r\n for (const collector of this.collectors) {\r\n collector.dispose();\r\n }\r\n this.collectors.clear();\r\n this.collectorCache.clear();\r\n\r\n this.splitMeshCache.clear();\r\n\r\n this._structureData = null;\r\n this._oidNodeMap.clear();\r\n this._structurePromise = null;\r\n\r\n // Clear model info data\r\n this._modelInfo = null;\r\n this._modelInfoPromise = null;\r\n\r\n this._interactionFilter.dispose();\r\n this._partColorHelper = null;\r\n this._partBlinkHelper?.dispose();\r\n this._partBlinkHelper = null;\r\n this._partFrameHelper?.dispose();\r\n this._partFrameHelper = null;\r\n\r\n this._loader = null;\r\n this.tiles = null;\r\n }\r\n}\r\n"],"x_google_ignoreList":[10,11,12],"mappings":";;AAGA,IAAa,oBAAb,MAA+B;CAC7B;CACA;CAEA,YAAY,MAAY,QAA0B;AAChD,O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MAAK,QAAQ,iBAAiB;AAGhC,OAAK,MAAM,aAAa,KAAK,WAC3B,WAAU,SAAS;AAErB,OAAK,WAAW,OAAO;AACvB,OAAK,eAAe,OAAO;AAE3B,OAAK,eAAe,OAAO;AAE3B,OAAK,iBAAiB;AACtB,OAAK,YAAY,OAAO;AACxB,OAAK,oBAAoB;AAGzB,OAAK,aAAa;AAClB,OAAK,oBAAoB;AAEzB,OAAK,mBAAmB,SAAS;AACjC,OAAK,mBAAmB;AACxB,OAAK,kBAAkB,SAAS;AAChC,OAAK,mBAAmB;AACxB,OAAK,kBAAkB,SAAS;AAChC,OAAK,mBAAmB;AAExB,OAAK,UAAU;AACf,OAAK,QAAQ"}
|
|
1
|
+
{"version":3,"file":"gltf-parser-plugin.module.js","names":["_","X","L","ke","ei","Kn","K","oi","ti","ns","mn","si","ri","ii","ni","_e","Xt","gn"],"sources":["../src/mesh-helper/index-visibility.ts","../src/mesh-helper/idmap.ts","../src/mesh-helper/intersection.ts","../src/mesh-helper/mesh.ts","../src/MeshCollector.ts","../src/plugin/style-condition-eval.ts","../src/utils/build-textures.ts","../src/utils/build-materials.ts","../src/utils/build-mesh-primitives.ts","../src/utils/worker-pool.ts","../src/utils/spatial-query.ts","../src/utils/color-input.ts","../node_modules/.pnpm/fflate@0.8.2/node_modules/fflate/esm/browser.js","../src/utils/tileset-structure-uri.ts","../node_modules/.pnpm/3d-tiles-renderer@0.4.23_three@0.183.2/node_modules/3d-tiles-renderer/build/constants-D7SEibTb.js","../node_modules/.pnpm/three@0.183.2/node_modules/three/examples/jsm/postprocessing/Pass.js","../node_modules/.pnpm/3d-tiles-renderer@0.4.23_three@0.183.2/node_modules/3d-tiles-renderer/build/WMSCapabilitiesLoader-X7r6Cf4e.js","../src/GLTFWorkerLoader.ts","../src/plugin/PartColorHelper.ts","../src/plugin/PartBlinkHelper.ts","../src/plugin/PartFrameHelper.ts","../src/plugin/style-appearance-shared.ts","../src/plugin/StyleHelper.ts","../src/plugin/PartHighlightHelper.ts","../src/plugin/InteractionFilter.ts","../src/db/tile-cache.ts","../src/GLTFParserPlugin.ts"],"sourcesContent":["import {\n BufferAttribute,\n BufferGeometry,\n Mesh,\n Object3D,\n} from \"three\";\n\n/** 从 mesh 的 idMap 和 hiddenOids 构建需要隐藏的 feature ID 集合 */\nfunction getHiddenFeatureIds(\n mesh: Mesh,\n hiddenOids: Set<number>\n): Set<number> {\n const idMap = mesh.userData?.idMap as Record<number, number> | undefined;\n if (!idMap) return new Set();\n\n const hidden = new Set<number>();\n for (const oid of hiddenOids) {\n const fid = idMap[oid];\n if (fid !== undefined) hidden.add(fid);\n }\n return hidden;\n}\n\n/** 对单个 mesh 应用可见性过滤(通过修改 index 排除隐藏的三角形) */\nexport function applyVisibilityToMesh(\n mesh: Mesh,\n hiddenOids: Set<number>\n): void {\n const { meshFeatures } = mesh.userData;\n if (!meshFeatures) return;\n\n const geometry = mesh.geometry as BufferGeometry;\n const index = geometry.index;\n const featureIdAttr = geometry.getAttribute(\"_feature_id_0\");\n\n if (!index || !featureIdAttr) return;\n\n const hiddenFeatureIds = getHiddenFeatureIds(mesh, hiddenOids);\n if (hiddenFeatureIds.size === 0) {\n restoreMeshIndex(mesh);\n return;\n }\n\n if (!(mesh.userData as any)._originalIndex) {\n (mesh.userData as any)._originalIndex = index.array.slice(0);\n }\n const originalArray = (mesh.userData as any)._originalIndex as\n | Uint16Array\n | Uint32Array;\n\n const isUint32 = originalArray instanceof Uint32Array;\n const filtered = isUint32\n ? new Uint32Array(originalArray.length)\n : new Uint16Array(originalArray.length);\n\n let writeOffset = 0;\n for (let i = 0; i < originalArray.length; i += 3) {\n const a = originalArray[i];\n const fid = featureIdAttr.getX(a);\n if (hiddenFeatureIds.has(fid)) continue;\n\n filtered[writeOffset++] = originalArray[i];\n filtered[writeOffset++] = originalArray[i + 1];\n filtered[writeOffset++] = originalArray[i + 2];\n }\n\n const filteredArray = filtered.subarray(0, writeOffset);\n geometry.setIndex(new BufferAttribute(filteredArray, 1));\n geometry.index!.needsUpdate = true;\n}\n\n/** 恢复 mesh 的原始 index */\nexport function restoreMeshIndex(mesh: Mesh): void {\n const original = (mesh.userData as any)?._originalIndex;\n if (!original) return;\n\n const geometry = mesh.geometry as BufferGeometry;\n if (!geometry?.index) return;\n\n geometry.setIndex(new BufferAttribute(original, 1));\n geometry.index!.needsUpdate = true;\n}\n\n/** 遍历 scene 中所有 tile mesh,应用可见性过滤 */\nexport function applyVisibilityToScene(\n scene: Object3D,\n hiddenOids: Set<number>\n): void {\n const oidSet = hiddenOids;\n if (oidSet.size === 0) {\n scene.traverse((obj) => {\n const mesh = obj as Mesh;\n if (mesh.userData?.meshFeatures && !mesh.userData?.isSplit) {\n restoreMeshIndex(mesh);\n }\n });\n return;\n }\n\n scene.traverse((obj) => {\n const mesh = obj as Mesh;\n if (\n mesh.userData?.meshFeatures &&\n mesh.userData?.structuralMetadata &&\n !mesh.userData?.isSplit\n ) {\n applyVisibilityToMesh(mesh, oidSet);\n }\n });\n}\n","import { Object3D } from \"three\";\r\n\r\nconst FEATURE_INDEX = 0;\r\n\r\n/**\r\n * Build mapping relationship from OID to FeatureId\r\n * @param scene Scene object\r\n */\r\nfunction buildOidToFeatureIdMap(scene: Object3D): void {\r\n scene.traverse((meshObject: Object3D) => {\r\n const { meshFeatures, structuralMetadata } = meshObject.userData;\r\n\r\n if (meshFeatures && structuralMetadata) {\r\n const { geometry, featureIds } = meshFeatures;\r\n const featureIdConfig = featureIds[FEATURE_INDEX];\r\n const featureAttribute = geometry.getAttribute(\r\n `_feature_id_${featureIdConfig.attribute}`\r\n );\r\n\r\n const processedFeatureIds = new Set<number>();\r\n const oidToFeatureIdMap: Record<number, number> = {};\r\n\r\n for (\r\n let vertexIndex = 0;\r\n vertexIndex < featureAttribute.count;\r\n vertexIndex++\r\n ) {\r\n const currentFeatureId = featureAttribute.getX(vertexIndex);\r\n\r\n if (processedFeatureIds.has(currentFeatureId)) {\r\n continue;\r\n }\r\n\r\n const featureData = structuralMetadata.getPropertyTableData(\r\n featureIdConfig.propertyTable,\r\n currentFeatureId\r\n );\r\n\r\n oidToFeatureIdMap[featureData._oid] = currentFeatureId;\r\n processedFeatureIds.add(currentFeatureId);\r\n }\r\n\r\n processedFeatureIds.clear();\r\n meshObject.userData.idMap = oidToFeatureIdMap;\r\n }\r\n });\r\n}\r\n\r\nexport { buildOidToFeatureIdMap };\r\n","import { Intersection, Mesh, Triangle, Vector3 } from \"three\";\r\n\r\n/**\r\n * Hit object feature information interface\r\n */\r\nexport interface FeatureInfo {\r\n oid?: number;\r\n featureId?: number;\r\n features?: number[];\r\n propertyData?: object;\r\n isValid: boolean;\r\n error?: string;\r\n}\r\n\r\n/**\r\n * General function for extracting OID and feature information from raycaster hit objects\r\n * @param hit - hit object returned by raycaster.intersectObject\r\n * @returns FeatureInfo object containing OID and other feature information\r\n */\r\nexport function queryFeatureFromIntersection(hit: Intersection): FeatureInfo {\r\n const result: FeatureInfo = {\r\n isValid: false,\r\n };\r\n\r\n try {\r\n if (!hit || !hit.object) {\r\n result.error = \"Invalid hit object\";\r\n return result;\r\n }\r\n\r\n const { object, face, point, faceIndex } = hit;\r\n const { meshFeatures, structuralMetadata } = object.userData;\r\n\r\n if (!(object instanceof Mesh)) {\r\n result.error = \"Hit object is not a Mesh\";\r\n return result;\r\n }\r\n\r\n if (!meshFeatures || !structuralMetadata) {\r\n result.error = \"No mesh features or structural metadata found\";\r\n return result;\r\n }\r\n\r\n const barycoord = new Vector3();\r\n if (face && point) {\r\n const triangle = new Triangle();\r\n triangle.setFromAttributeAndIndices(\r\n object.geometry.attributes.position,\r\n face.a,\r\n face.b,\r\n face.c\r\n );\r\n triangle.a.applyMatrix4(object.matrixWorld);\r\n triangle.b.applyMatrix4(object.matrixWorld);\r\n triangle.c.applyMatrix4(object.matrixWorld);\r\n triangle.getBarycoord(point, barycoord);\r\n } else {\r\n barycoord.set(0, 0, 0);\r\n }\r\n\r\n const features = meshFeatures.getFeatures(faceIndex, barycoord);\r\n if (!features || features.length === 0) {\r\n result.error = \"No features found at hit location\";\r\n return result;\r\n }\r\n\r\n result.features = features;\r\n\r\n const { featureIds } = meshFeatures;\r\n if (!featureIds || featureIds.length === 0) {\r\n result.error = \"Feature IDs not available\";\r\n return result;\r\n }\r\n\r\n const featureId = featureIds[0];\r\n const fid = features[0];\r\n result.featureId = fid;\r\n\r\n const propertyData = structuralMetadata.getPropertyTableData(\r\n featureId.propertyTable,\r\n fid\r\n );\r\n\r\n result.propertyData = propertyData;\r\n\r\n if (propertyData && propertyData._oid !== undefined) {\r\n result.oid = propertyData._oid;\r\n result.isValid = true;\r\n } else {\r\n result.error = \"OID not found in property data\";\r\n }\r\n\r\n return result;\r\n } catch (error) {\r\n result.error = `Error extracting OID: ${\r\n error instanceof Error ? error.message : String(error)\r\n }`;\r\n return result;\r\n }\r\n}\r\n","import {\n BufferAttribute,\n BufferGeometry,\n Material,\n Mesh,\n Object3D,\n} from \"three\";\n\nimport { TilesRenderer } from \"3d-tiles-renderer\";\n\n/**\n * 合并多个 feature 的三角形为单一 BufferGeometry(共享顶点属性,index 为并集)\n */\nfunction createGeometryForFeatureIdSet(\n originalGeometry: BufferGeometry,\n featureIdAttr: BufferAttribute,\n targetFids: Set<number>,\n): BufferGeometry | null {\n if (targetFids.size === 0 || !originalGeometry.index) {\n return null;\n }\n\n const newGeometry = new BufferGeometry();\n const attributes = originalGeometry.attributes;\n for (const attributeName in attributes) {\n newGeometry.setAttribute(attributeName, attributes[attributeName]);\n }\n\n const originalIndex = originalGeometry.index.array;\n const newIndices: number[] = [];\n\n for (let i = 0; i < originalIndex.length; i += 3) {\n const a = originalIndex[i];\n const b = originalIndex[i + 1];\n const c = originalIndex[i + 2];\n const fa = featureIdAttr.getX(a);\n if (\n fa === featureIdAttr.getX(b) &&\n fa === featureIdAttr.getX(c) &&\n targetFids.has(fa)\n ) {\n newIndices.push(a, b, c);\n }\n }\n\n if (newIndices.length === 0) {\n return null;\n }\n\n newGeometry.setIndex(newIndices);\n return newGeometry;\n}\n\n/**\n * 将同一瓦片 mesh 内、属于给定 OID 集合的所有 feature 合并为 **单个** Mesh(每瓦片最多一个)\n */\nexport function splitMeshByOidsMerged(\n originalMesh: Mesh,\n oidSet: ReadonlySet<number>,\n): Mesh | null {\n if (oidSet.size === 0) return null;\n\n const idMap = originalMesh.userData?.idMap as\n | Record<number, number>\n | undefined;\n if (!idMap) return null;\n\n const { meshFeatures, structuralMetadata } = originalMesh.userData;\n const { geometry, featureIds } = meshFeatures;\n const featureId = featureIds[0];\n const featureIdAttr = geometry.getAttribute(\n `_feature_id_${featureId.attribute}`,\n );\n\n if (!featureIdAttr) {\n console.warn(\"No feature ID attribute found\");\n return null;\n }\n\n const targetFids = new Set<number>();\n const oidsOnMesh: number[] = [];\n for (const oid of oidSet) {\n const fid = idMap[oid];\n if (fid !== undefined) {\n targetFids.add(fid);\n oidsOnMesh.push(oid);\n }\n }\n\n if (targetFids.size === 0) return null;\n\n const newGeometry = createGeometryForFeatureIdSet(\n geometry,\n featureIdAttr,\n targetFids,\n );\n\n if (!newGeometry || newGeometry.attributes.position.count === 0) {\n return null;\n }\n\n const newMaterial = (originalMesh.material as Material).clone();\n const newMesh = new Mesh(newGeometry, newMaterial);\n newMesh.parent = originalMesh.parent;\n newMesh.position.copy(originalMesh.position);\n newMesh.rotation.copy(originalMesh.rotation);\n newMesh.scale.copy(originalMesh.scale);\n newMesh.matrixWorld.copy(originalMesh.matrixWorld);\n\n oidsOnMesh.sort((a, b) => a - b);\n const primaryOid = oidsOnMesh[0]!;\n\n let propertyData: unknown = null;\n if (structuralMetadata && idMap[primaryOid] !== undefined) {\n try {\n propertyData = structuralMetadata.getPropertyTableData(\n featureId.propertyTable,\n idMap[primaryOid]!,\n );\n } catch {\n // ignore\n }\n }\n\n newMesh.userData = {\n ...originalMesh.userData,\n featureId: idMap[primaryOid],\n oid: primaryOid,\n collectorOids: oidsOnMesh,\n originalMesh: originalMesh,\n propertyData,\n isSplit: true,\n isMergedSplit: true,\n };\n\n newMesh.name = `merged_features_${oidsOnMesh.length}_${primaryOid}`;\n return newMesh;\n}\n\n/** 瓦片内原始 feature mesh(非 split 子网格) */\nfunction isFeatureSourceMesh(mesh: Mesh): boolean {\n const u = mesh.userData;\n return Boolean(u?.meshFeatures && u?.structuralMetadata && !u?.isSplit);\n}\n\n/**\n * 从瓦片中获取所有 OID\n */\nexport function getAllOidsFromTiles(tiles: TilesRenderer): number[] {\n const oidSet = new Set<number>();\n\n tiles.group.traverse((child: Object3D) => {\n const mesh = child as Mesh;\n if (!isFeatureSourceMesh(mesh)) return;\n const idMap = mesh.userData.idMap as Record<number, number> | undefined;\n if (!idMap) return;\n for (const oid of Object.keys(idMap).map(Number)) {\n oidSet.add(oid);\n }\n });\n\n return Array.from(oidSet);\n}\n\n/**\n * 根据 OID 获取属性数据(从瓦片 structuralMetadata)\n */\nexport function getPropertyDataByOid(\n tiles: TilesRenderer,\n oid: number\n): Record<string, unknown> | null {\n let result: Record<string, unknown> | null = null;\n\n tiles.group.traverse((child: Object3D) => {\n if (result) return;\n\n const mesh = child as Mesh;\n if (!isFeatureSourceMesh(mesh)) return;\n const idMap = mesh.userData.idMap as Record<number, number> | undefined;\n if (!idMap || idMap[oid] === undefined) return;\n\n const { meshFeatures, structuralMetadata } = mesh.userData;\n const featureId = meshFeatures.featureIds[0];\n const fid = idMap[oid];\n\n try {\n const data = structuralMetadata.getPropertyTableData(\n featureId.propertyTable,\n fid\n );\n result = data as Record<string, unknown>;\n } catch {\n // ignore\n }\n });\n\n return result;\n}\n\n/**\n * 单次遍历场景构建 OID → 属性表数据。\n * 批量样式/筛选时使用,避免对每个 OID 重复 traverse(O(n×场景节点))。\n */\nexport function getPropertyDataMapFromTiles(\n tiles: TilesRenderer,\n): Map<number, Record<string, unknown> | null> {\n const map = new Map<number, Record<string, unknown> | null>();\n\n tiles.group.traverse((child: Object3D) => {\n const mesh = child as Mesh;\n if (!isFeatureSourceMesh(mesh)) return;\n const idMap = mesh.userData.idMap as Record<number, number> | undefined;\n if (!idMap) return;\n\n const { meshFeatures, structuralMetadata } = mesh.userData;\n const featureId = meshFeatures.featureIds[0];\n const propertyTable = featureId.propertyTable;\n\n for (const oid of Object.keys(idMap).map(Number)) {\n if (map.has(oid)) continue;\n\n const fid = idMap[oid];\n if (fid === undefined) continue;\n\n try {\n const data = structuralMetadata.getPropertyTableData(\n propertyTable,\n fid,\n );\n map.set(oid, data as Record<string, unknown>);\n } catch {\n map.set(oid, null);\n }\n }\n });\n\n return map;\n}\n\n/**\n * 根据OID获取包含该OID的瓦片mesh\n */\nexport function getTileMeshesByOid(tiles: TilesRenderer, oid: number): Mesh[] {\n const tileMeshes: Mesh[] = [];\n\n tiles.group.traverse((child: Object3D) => {\n const mesh = child as Mesh;\n if (isFeatureSourceMesh(mesh) && checkMeshContainsOid(mesh, oid)) {\n tileMeshes.push(mesh);\n }\n });\n\n return tileMeshes;\n}\n\nfunction checkMeshContainsOid(mesh: Mesh, oid: number): boolean {\n const idMap = mesh.userData.idMap;\n\n if (!idMap) {\n return false;\n }\n\n return idMap[oid] !== undefined;\n}\n","import { EventDispatcher, Mesh } from \"three\";\r\n\r\n/** 收集器查询:OID 范围 + 可选属性条件(语义同 setStyle 的 show / conditions 中的表达式字符串) */\r\nexport interface MeshCollectorQuery {\r\n /**\r\n * 限定在这些 OID 内收集;不传或空数组时,若提供 condition 则从全场景 OID 中筛选\r\n */\r\n oids?: readonly number[];\r\n /**\r\n * 属性表达式,如 `type === \"wall\"`,与 setStyle 里 `show` 或 `conditions[i][0]`(为 string 时)相同\r\n */\r\n condition?: string;\r\n}\r\n\r\nexport interface MeshHelperHost {\r\n _registerCollector(collector: MeshCollector): void;\r\n _unregisterCollector(collector: MeshCollector): void;\r\n _getMeshesForCollectorQueryInternal(params: {\r\n oids: readonly number[];\r\n condition?: string;\r\n }): Mesh[];\r\n}\r\n\r\nexport interface MeshChangeEvent {\r\n type: \"mesh-change\";\r\n meshes: Mesh[];\r\n}\r\n\r\nexport type MeshCollectorEventMap = {\r\n \"mesh-change\": MeshChangeEvent;\r\n};\r\n\r\n/** 去重并排序 OID */\r\nexport function normalizeMeshCollectorOids(oids: readonly number[]): number[] {\r\n return [...new Set(oids)].sort((a, b) => a - b);\r\n}\r\n\r\n/**\r\n * 与 MeshCollector.getCacheKey()、插件 collectorCache 键一致\r\n */\r\nexport function meshCollectorQueryCacheKey(query: MeshCollectorQuery): string {\r\n const oidsNorm = normalizeMeshCollectorOids(query.oids ?? []);\r\n const oidPart = oidsNorm.length > 0 ? oidsNorm.join(\",\") : \"*\";\r\n const condRaw = query.condition?.trim() ?? \"\";\r\n const condPart = condRaw === \"\" ? \"_\" : encodeURIComponent(condRaw);\r\n return `${oidPart}@@${condPart}`;\r\n}\r\n\r\n/** @deprecated 请使用 meshCollectorQueryCacheKey({ oids }) */\r\nexport function meshCollectorGroupKey(oids: readonly number[]): string {\r\n return meshCollectorQueryCacheKey({ oids });\r\n}\r\n\r\n/**\r\n * MeshCollector - 按查询条件监听并收集 split mesh\r\n */\r\nexport class MeshCollector extends EventDispatcher<MeshCollectorEventMap> {\r\n private readonly queryOids: number[];\r\n private readonly condition: string | undefined;\r\n private readonly cacheKey: string;\r\n private plugin: MeshHelperHost;\r\n private _meshes: Mesh[] = [];\r\n private _disposed: boolean = false;\r\n\r\n constructor(query: MeshCollectorQuery, plugin: MeshHelperHost) {\r\n super();\r\n const oids = normalizeMeshCollectorOids(query.oids ?? []);\r\n const condition = query.condition?.trim() || undefined;\r\n if (oids.length === 0 && !condition) {\r\n throw new Error(\r\n \"MeshCollector requires at least one OID in oids and/or a non-empty condition\",\r\n );\r\n }\r\n this.queryOids = oids;\r\n this.condition = condition;\r\n this.cacheKey = meshCollectorQueryCacheKey({ oids, condition });\r\n this.plugin = plugin;\r\n\r\n plugin._registerCollector(this);\r\n\r\n this._updateMeshes();\r\n }\r\n\r\n getCacheKey(): string {\r\n return this.cacheKey;\r\n }\r\n\r\n /** 查询里显式传入的 OID(规范化后);仅用 condition 筛选时可能为空数组 */\r\n getOids(): readonly number[] {\r\n return this.queryOids;\r\n }\r\n\r\n /** 有显式 OID 时返回第一个;否则无意义(可能为 undefined) */\r\n getOid(): number | undefined {\r\n return this.queryOids[0];\r\n }\r\n\r\n get meshes(): Mesh[] {\r\n return this._meshes;\r\n }\r\n\r\n /** 与 setStyle 一致的条件表达式(若有) */\r\n getCondition(): string | undefined {\r\n return this.condition;\r\n }\r\n\r\n _updateMeshes(): void {\r\n if (this._disposed) return;\r\n\r\n const newMeshes = this.plugin._getMeshesForCollectorQueryInternal({\r\n oids: this.queryOids,\r\n condition: this.condition,\r\n });\r\n\r\n const hasChanged =\r\n newMeshes.length !== this._meshes.length ||\r\n newMeshes.some((mesh: Mesh, i: number) => mesh !== this._meshes[i]);\r\n\r\n if (hasChanged) {\r\n this._meshes = newMeshes;\r\n this.dispatchEvent({ type: \"mesh-change\", meshes: this._meshes });\r\n }\r\n }\r\n\r\n dispose(): void {\r\n if (this._disposed) return;\r\n this._disposed = true;\r\n this.plugin._unregisterCollector(this);\r\n this._meshes = [];\r\n }\r\n}\r\n","/**\n * 与 StyleHelper 中 `show`、`conditions` 条件项的表达式求值一致\n * 在 propertyData 的键作为变量名的上下文中执行 `Boolean(expr)`\n *\n * 实现:对每个表达式字符串只编译一次 `new Function('data', 'with(d){...}')`,\n * 避免按「表达式 × 属性键集合」重复编译,也避免每次求值排序/拼接 cacheKey。\n */\n\nconst compiledCache = new Map<string, (data: Record<string, unknown>) => boolean>();\nconst MAX_CACHE_ENTRIES = 512;\n\nfunction getCompiled(\n expr: string,\n): ((data: Record<string, unknown>) => boolean) | null {\n let fn = compiledCache.get(expr);\n if (fn) return fn;\n\n try {\n // 非 strict 函数才允许 with;形参 data 为属性表,表达式内可直接写属性名\n fn = new Function(\n \"data\",\n `var d = data != null && typeof data === \"object\" ? data : {};\nwith (d) { return Boolean(${expr}); }`,\n ) as (data: Record<string, unknown>) => boolean;\n } catch {\n return null;\n }\n\n if (compiledCache.size >= MAX_CACHE_ENTRIES) {\n const first = compiledCache.keys().next().value;\n if (first !== undefined) compiledCache.delete(first);\n }\n compiledCache.set(expr, fn);\n return fn;\n}\n\n/**\n * 清空表达式编译缓存(热更新或单测可调用)\n */\nexport function clearStyleConditionCache(): void {\n compiledCache.clear();\n}\n\nexport function evaluateStyleCondition(\n expr: string | boolean,\n propertyData: Record<string, unknown> | null,\n): boolean {\n if (expr === true) return true;\n if (expr === false) return false;\n if (typeof expr !== \"string\" || !expr.trim()) return true;\n\n const trimmed = expr.trim();\n const fn = getCompiled(trimmed);\n if (!fn) return false;\n\n try {\n return fn(propertyData ?? {});\n } catch {\n return false;\n }\n}\n","import {\n DataTexture,\n RGBAFormat,\n SRGBColorSpace,\n Texture,\n UnsignedByteType,\n} from \"three\";\nimport type { GLTFWorkerData } from \"../types\";\n\nexport interface TextureBuildResult {\n textureMap: Map<number, Texture>;\n textureArray: (Texture | null)[];\n}\n\n/**\n * Build textures from GLTF data\n */\nexport function buildTextures(data: GLTFWorkerData): TextureBuildResult {\n const textureMap = new Map<number, Texture>();\n const textureArray: (Texture | null)[] = [];\n\n if (!data.textures) {\n return { textureMap, textureArray };\n }\n\n for (const [index, textureData] of data.textures.entries()) {\n if (textureData.image && textureData.image.array) {\n const imageData = textureData.image;\n const tex = new DataTexture(\n imageData.array,\n imageData.width,\n imageData.height,\n RGBAFormat,\n UnsignedByteType,\n );\n tex.flipY = false;\n tex.colorSpace = SRGBColorSpace;\n tex.needsUpdate = true;\n textureMap.set(index, tex);\n textureArray[index] = tex;\n continue;\n }\n\n // Default empty texture\n const texture = new Texture();\n texture.flipY = false;\n textureMap.set(index, texture);\n textureArray[index] = texture;\n }\n\n return { textureMap, textureArray };\n}\n","import {\r\n DoubleSide,\r\n FrontSide,\r\n Material,\r\n MeshStandardMaterial,\r\n Texture,\r\n} from \"three\";\r\nimport type { GLTFWorkerData, MaterialBuilder } from \"../types\";\r\n\r\n/**\r\n * Build materials from GLTF data\r\n */\r\nexport function buildMaterials(\r\n data: GLTFWorkerData,\r\n textureMap: Map<number, Texture>,\r\n customMaterialBuilder?: MaterialBuilder,\r\n): Map<number, Material> {\r\n const materialMap = new Map<number, Material>();\r\n\r\n if (!data.materials) {\r\n return materialMap;\r\n }\r\n\r\n const materialBuilder = customMaterialBuilder || defaultMaterialBuilder;\r\n\r\n for (const [index, matData] of data.materials.entries()) {\r\n const material = materialBuilder(matData, textureMap);\r\n\r\n materialMap.set(index, material);\r\n }\r\n\r\n return materialMap;\r\n}\r\n\r\nfunction defaultMaterialBuilder(\r\n matData: any,\r\n textureMap: Map<number, Texture>,\r\n): Material {\r\n const material = new MeshStandardMaterial();\r\n\r\n // PBR material properties\r\n if (matData.pbrMetallicRoughness) {\r\n const pbr = matData.pbrMetallicRoughness;\r\n\r\n // Base color\r\n if (pbr.baseColorFactor) {\r\n material.color.setRGB(\r\n pbr.baseColorFactor[0],\r\n pbr.baseColorFactor[1],\r\n pbr.baseColorFactor[2],\r\n );\r\n if (pbr.baseColorFactor[3] !== undefined) {\r\n material.opacity = pbr.baseColorFactor[3];\r\n if (material.opacity < 1) material.transparent = true;\r\n }\r\n }\r\n\r\n // Base color texture\r\n if (pbr.baseColorTexture && pbr.baseColorTexture.index !== undefined) {\r\n const tex = textureMap.get(pbr.baseColorTexture.index);\r\n if (tex) {\r\n material.map = tex;\r\n }\r\n }\r\n\r\n // Metalness and roughness\r\n material.metalness =\r\n pbr.metallicFactor !== undefined ? pbr.metallicFactor : 1.0;\r\n material.roughness =\r\n pbr.roughnessFactor !== undefined ? pbr.roughnessFactor : 1.0;\r\n\r\n // Metallic roughness texture\r\n if (\r\n pbr.metallicRoughnessTexture &&\r\n pbr.metallicRoughnessTexture.index !== undefined\r\n ) {\r\n const tex = textureMap.get(pbr.metallicRoughnessTexture.index);\r\n if (tex) {\r\n material.metalnessMap = material.roughnessMap = tex;\r\n }\r\n }\r\n }\r\n\r\n // Normal map\r\n if (matData.normalTexture && matData.normalTexture.index !== undefined) {\r\n const tex = textureMap.get(matData.normalTexture.index);\r\n if (tex) {\r\n material.normalMap = tex;\r\n if (matData.normalTexture.scale !== undefined) {\r\n material.normalScale.set(\r\n matData.normalTexture.scale,\r\n matData.normalTexture.scale,\r\n );\r\n }\r\n }\r\n }\r\n\r\n // Occlusion map\r\n if (\r\n matData.occlusionTexture &&\r\n matData.occlusionTexture.index !== undefined\r\n ) {\r\n const tex = textureMap.get(matData.occlusionTexture.index);\r\n if (tex) {\r\n material.aoMap = tex;\r\n }\r\n }\r\n\r\n // Emissive\r\n if (matData.emissiveTexture && matData.emissiveTexture.index !== undefined) {\r\n const tex = textureMap.get(matData.emissiveTexture.index);\r\n if (tex) {\r\n material.emissiveMap = tex;\r\n }\r\n }\r\n if (matData.emissiveFactor) {\r\n material.emissive.setRGB(\r\n matData.emissiveFactor[0],\r\n matData.emissiveFactor[1],\r\n matData.emissiveFactor[2],\r\n );\r\n }\r\n\r\n // Double sided rendering\r\n material.side = matData.doubleSided ? DoubleSide : FrontSide;\r\n\r\n // Alpha mode\r\n if (matData.alphaMode === \"BLEND\") {\r\n material.transparent = true;\r\n } else if (matData.alphaMode === \"MASK\") {\r\n material.alphaTest =\r\n matData.alphaCutoff !== undefined ? matData.alphaCutoff : 0.5;\r\n }\r\n\r\n return material;\r\n}\r\n","import { BufferAttribute, BufferGeometry, Material, MeshStandardMaterial } from \"three\";\r\nimport type { GLTFWorkerData, PrimitiveExtensions } from \"../types\";\r\n\r\nexport interface PrimitiveData {\r\n geometry: BufferGeometry;\r\n material: Material;\r\n primitiveIndex: number;\r\n extensions?: PrimitiveExtensions;\r\n}\r\n\r\n/**\r\n * Build Mesh Primitives from GLTF data\r\n */\r\nexport function buildMeshPrimitives(\r\n data: GLTFWorkerData,\r\n materialMap: Map<number, Material>,\r\n defaultMaterial: Material,\r\n): Map<number, PrimitiveData[]> {\r\n const meshMap = new Map<number, PrimitiveData[]>();\r\n\r\n if (!data.meshes) {\r\n return meshMap;\r\n }\r\n\r\n for (const meshIndex in data.meshes) {\r\n const meshData = data.meshes[meshIndex];\r\n const primitiveDataList: PrimitiveData[] = [];\r\n const primitives = meshData.primitives;\r\n\r\n for (\r\n let primitiveIndex = 0;\r\n primitiveIndex < primitives.length;\r\n primitiveIndex++\r\n ) {\r\n const primitive = primitives[primitiveIndex];\r\n const geometry = new BufferGeometry();\r\n\r\n // Handle vertex attributes\r\n if (primitive.attributes) {\r\n // Position\r\n const posData = primitive.attributes.POSITION;\r\n if (posData && posData.array) {\r\n geometry.setAttribute(\r\n \"position\",\r\n new BufferAttribute(posData.array, posData.itemSize || 3),\r\n );\r\n }\r\n\r\n // Normal\r\n const normalData = primitive.attributes.NORMAL;\r\n if (normalData && normalData.array) {\r\n geometry.setAttribute(\r\n \"normal\",\r\n new BufferAttribute(normalData.array, normalData.itemSize || 3),\r\n );\r\n }\r\n\r\n // UV coordinates\r\n const uvData = primitive.attributes.TEXCOORD_0;\r\n if (uvData && uvData.array) {\r\n geometry.setAttribute(\r\n \"uv\",\r\n new BufferAttribute(uvData.array, uvData.itemSize || 2),\r\n );\r\n }\r\n\r\n // Vertex color\r\n const colorData = primitive.attributes.COLOR_0;\r\n if (colorData && colorData.array) {\r\n geometry.setAttribute(\r\n \"color\",\r\n new BufferAttribute(colorData.array, colorData.itemSize || 3),\r\n );\r\n }\r\n\r\n // Tangent\r\n const tangentData = primitive.attributes.TANGENT;\r\n if (tangentData && tangentData.array) {\r\n geometry.setAttribute(\r\n \"tangent\",\r\n new BufferAttribute(tangentData.array, tangentData.itemSize || 4),\r\n );\r\n }\r\n\r\n // Feature ID attribute (for EXT_mesh_features)\r\n for (const attrName in primitive.attributes) {\r\n if (attrName.startsWith(\"_FEATURE_ID_\")) {\r\n const featureIdData = primitive.attributes[attrName];\r\n if (featureIdData && featureIdData.array) {\r\n const normalizedName = attrName\r\n .toLowerCase()\r\n .replace(\"_feature_id_\", \"_feature_id_\");\r\n geometry.setAttribute(\r\n normalizedName,\r\n new BufferAttribute(\r\n featureIdData.array,\r\n featureIdData.itemSize || 1,\r\n ),\r\n );\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Indices\r\n const indexData = primitive.indices;\r\n if (indexData && indexData.array) {\r\n geometry.setIndex(new BufferAttribute(indexData.array, 1));\r\n }\r\n\r\n // Get material\r\n const material =\r\n primitive.material !== undefined\r\n ? materialMap.get(primitive.material) || defaultMaterial\r\n : defaultMaterial;\r\n\r\n if (!geometry.hasAttribute(\"normal\") && material instanceof MeshStandardMaterial) {\r\n material.flatShading = true;\r\n }\r\n\r\n primitiveDataList.push({\r\n geometry,\r\n material,\r\n primitiveIndex,\r\n extensions: primitive.extensions,\r\n });\r\n }\r\n\r\n meshMap.set(Number(meshIndex), primitiveDataList);\r\n }\r\n\r\n return meshMap;\r\n}\r\n","// Import inline Worker (Vite will compile and bundle the worker code into a base64 data URL)\r\nimport GLTFWorkerClass from \"../worker/index?worker&inline\";\r\n\r\n// Worker pool management\r\nlet workerPool: Worker[] = [];\r\nlet maxWorkers = 1;\r\nlet currentWorkerIndex = 0;\r\n\r\n// ---- Global schema cache (shared across all workers) ----\r\n\r\nconst schemaCache = new Map<string, Promise<any>>();\r\n\r\n/**\r\n * Clear the global schema cache.\r\n */\r\nexport function clearSchemaCache(): void {\r\n schemaCache.clear();\r\n}\r\n\r\n/**\r\n * Attach a schema request handler to a Worker.\r\n * When the worker sends a { type: \"fetchSchema\" } message,\r\n * the main thread fetches (with deduplication via cache) and replies with the result.\r\n */\r\nfunction setupSchemaHandler(worker: Worker): void {\r\n worker.addEventListener(\"message\", (event: MessageEvent) => {\r\n const { type, schemaRequestId, url } = event.data;\r\n if (type !== \"fetchSchema\") return;\r\n\r\n let promise = schemaCache.get(url);\r\n if (!promise) {\r\n promise = fetch(url)\r\n .then((res) => {\r\n if (!res.ok) {\r\n throw new Error(\r\n `Failed to fetch schema: ${res.status} ${res.statusText}`,\r\n );\r\n }\r\n return res.json();\r\n })\r\n .catch((err) => {\r\n // Remove from cache on failure so it can be retried next time\r\n schemaCache.delete(url);\r\n throw err;\r\n });\r\n schemaCache.set(url, promise);\r\n }\r\n\r\n promise\r\n .then((data) => {\r\n worker.postMessage({ type: \"schemaResponse\", schemaRequestId, data });\r\n })\r\n .catch((err) => {\r\n worker.postMessage({\r\n type: \"schemaResponse\",\r\n schemaRequestId,\r\n error: err.message || String(err),\r\n });\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Set the maximum number of Workers (must be called before initialization)\r\n */\r\nexport function setMaxWorkers(count: number): void {\r\n maxWorkers = Math.max(1, Math.min(count, navigator.hardwareConcurrency || 4));\r\n}\r\n\r\n/**\r\n * Create a single Worker and wait for it to be ready\r\n */\r\nfunction createWorker(): Worker {\r\n const worker = new GLTFWorkerClass();\r\n setupSchemaHandler(worker);\r\n return worker;\r\n}\r\n\r\n/**\r\n * Initialize the Worker pool\r\n */\r\nfunction initWorkerPool() {\r\n if (workerPool.length === 0) {\r\n // Create all Workers\r\n for (let i = 0; i < maxWorkers; i++) {\r\n workerPool.push(createWorker());\r\n }\r\n }\r\n}\r\n\r\nexport function getWorkers(): Worker[] {\r\n initWorkerPool();\r\n return workerPool;\r\n}\r\n\r\n/**\r\n * Acquire a Worker (wait if none are available)\r\n */\r\nexport function acquireWorker() {\r\n initWorkerPool();\r\n\r\n const worker = workerPool[currentWorkerIndex];\r\n currentWorkerIndex = (currentWorkerIndex + 1) % workerPool.length;\r\n return worker;\r\n}\r\n","import { Box3, Vector2 } from \"three\";\nimport type { Vector3 } from \"three\";\nimport type { StructureNode } from \"../plugin-types\";\n\n/**\n * 射线法判断点是否在多边形内\n */\nexport function pointInPolygon(\n px: number,\n py: number,\n polygon: Vector2[],\n): boolean {\n let inside = false;\n const n = polygon.length;\n for (let i = 0, j = n - 1; i < n; j = i++) {\n const xi = polygon[i].x,\n yi = polygon[i].y;\n const xj = polygon[j].x,\n yj = polygon[j].y;\n if (yi > py !== yj > py && px < ((xj - xi) * (py - yi)) / (yj - yi) + xi) {\n inside = !inside;\n }\n }\n return inside;\n}\n\n/**\n * 判断两线段是否相交\n */\nexport function segmentsIntersect(\n ax1: number,\n ay1: number,\n ax2: number,\n ay2: number,\n bx1: number,\n by1: number,\n bx2: number,\n by2: number,\n): boolean {\n const cross = (\n ox: number,\n oy: number,\n ax: number,\n ay: number,\n bx: number,\n by: number,\n ) => (ax - ox) * (by - oy) - (ay - oy) * (bx - ox);\n\n const d1 = cross(bx1, by1, bx2, by2, ax1, ay1);\n const d2 = cross(bx1, by1, bx2, by2, ax2, ay2);\n const d3 = cross(ax1, ay1, ax2, ay2, bx1, by1);\n const d4 = cross(ax1, ay1, ax2, ay2, bx2, by2);\n\n if (\n ((d1 > 0 && d2 < 0) || (d1 < 0 && d2 > 0)) &&\n ((d3 > 0 && d4 < 0) || (d3 < 0 && d4 > 0))\n ) {\n return true;\n }\n\n const onSeg = (\n px: number,\n py: number,\n qx: number,\n qy: number,\n rx: number,\n ry: number,\n ) =>\n Math.min(px, qx) <= rx &&\n rx <= Math.max(px, qx) &&\n Math.min(py, qy) <= ry &&\n ry <= Math.max(py, qy);\n\n if (d1 === 0 && onSeg(bx1, by1, bx2, by2, ax1, ay1)) return true;\n if (d2 === 0 && onSeg(bx1, by1, bx2, by2, ax2, ay2)) return true;\n if (d3 === 0 && onSeg(ax1, ay1, ax2, ay2, bx1, by1)) return true;\n if (d4 === 0 && onSeg(ax1, ay1, ax2, ay2, bx2, by2)) return true;\n\n return false;\n}\n\n/**\n * 判断多边形与矩形是否相交或包含\n */\nexport function polygonIntersectsRect(\n polygon: Vector2[],\n minX: number,\n minY: number,\n maxX: number,\n maxY: number,\n): boolean {\n const n = polygon.length;\n\n for (let i = 0; i < n; i++) {\n const p = polygon[i];\n if (p.x >= minX && p.x <= maxX && p.y >= minY && p.y <= maxY) {\n return true;\n }\n }\n\n if (\n pointInPolygon(minX, minY, polygon) ||\n pointInPolygon(maxX, minY, polygon) ||\n pointInPolygon(maxX, maxY, polygon) ||\n pointInPolygon(minX, maxY, polygon)\n ) {\n return true;\n }\n\n const rx = [minX, maxX, maxX, minX];\n const ry = [minY, minY, maxY, maxY];\n\n for (let i = 0; i < n; i++) {\n const a = polygon[i];\n const b = polygon[(i + 1) % n];\n for (let j = 0; j < 4; j++) {\n const k = (j + 1) % 4;\n if (segmentsIntersect(a.x, a.y, b.x, b.y, rx[j], ry[j], rx[k], ry[k])) {\n return true;\n }\n }\n }\n\n return false;\n}\n\n/**\n * 将 structure 中的 bbox 数组转为 Box3。\n * 约定与 `selectByBox` 一致:`[minX, minY, minZ, maxX, maxY, maxZ]`,至少 6 个数。\n */\nexport function bboxArrayToBox3(bbox: number[] | undefined): Box3 | null {\n if (!bbox || bbox.length < 6) return null;\n const box = new Box3();\n box.min.set(bbox[0], bbox[1], bbox[2]);\n box.max.set(bbox[3], bbox[4], bbox[5]);\n return box;\n}\n\n/**\n * 从 OID 节点映射中按 Box3 范围筛选构件\n */\nexport function selectByBoxFromOidMap(\n oidNodeMap: Map<number, StructureNode>,\n box: Box3,\n): number[] {\n const result: number[] = [];\n\n for (const [oid, node] of oidNodeMap) {\n const nodeBox = bboxArrayToBox3(node.bbox);\n if (!nodeBox) continue;\n if (box.intersectsBox(nodeBox)) {\n result.push(oid);\n }\n }\n\n return result;\n}\n\n/**\n * 从 OID 节点映射中按多边形(平面投影)范围筛选构件\n */\nexport function selectByPolygonFromOidMap(\n oidNodeMap: Map<number, StructureNode>,\n polygon: Vector3[],\n axis: \"xy\" | \"xz\" | \"yz\" = \"xz\",\n): number[] {\n const result: number[] = [];\n const polygon2D: Vector2[] = polygon.map((p) => {\n switch (axis) {\n case \"xy\":\n return new Vector2(p.x, p.y);\n case \"yz\":\n return new Vector2(p.y, p.z);\n case \"xz\":\n default:\n return new Vector2(p.x, p.z);\n }\n });\n\n for (const [oid, node] of oidNodeMap) {\n if (!node.bbox || node.bbox.length < 6) continue;\n\n let minU: number, minV: number, maxU: number, maxV: number;\n switch (axis) {\n case \"xy\":\n minU = node.bbox[0];\n minV = node.bbox[1];\n maxU = node.bbox[3];\n maxV = node.bbox[4];\n break;\n case \"xz\":\n minU = node.bbox[0];\n minV = node.bbox[2];\n maxU = node.bbox[3];\n maxV = node.bbox[5];\n break;\n case \"yz\":\n minU = node.bbox[1];\n minV = node.bbox[2];\n maxU = node.bbox[4];\n maxV = node.bbox[5];\n break;\n }\n\n if (polygonIntersectsRect(polygon2D, minU, minV, maxU, maxV)) {\n result.push(oid);\n }\n }\n\n return result;\n}\n","import { Color } from \"three\";\n\n/** 可解析为 THREE.Color 的输入 */\nexport type ColorInput = number | string | Color;\n\nexport function toColor(value: ColorInput): Color {\n return value instanceof Color ? value : new Color(value);\n}\n","// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Some of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var w = new Worker(ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([\n c + ';addEventListener(\"error\",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'\n ], { type: 'text/javascript' }))));\n w.onmessage = function (e) {\n var d = e.data, ed = d.$e$;\n if (ed) {\n var err = new Error(ed[0]);\n err['code'] = ed[1];\n err.stack = ed[2];\n cb(err, null);\n }\n else\n cb(null, d);\n };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;\n// fixed length extra bits\nvar fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\nvar fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new i32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return { b: b, r: r };\n};\nvar _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b.b, revfd = _b.r;\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i) {\n if (cd[i])\n ++l[cd[i] - 1];\n }\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 1; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i) {\n if (cd[i]) {\n co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);\n }\n }\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p + 7) / 8) | 0; };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n return new u8(v.subarray(s, e));\n};\n/**\n * Codes for errors generated within this library\n */\nexport var FlateErrorCode = {\n UnexpectedEOF: 0,\n InvalidBlockType: 1,\n InvalidLengthLiteral: 2,\n InvalidDistance: 3,\n StreamFinished: 4,\n NoStreamHandler: 5,\n InvalidHeader: 6,\n NoCallback: 7,\n InvalidUTF8: 8,\n ExtraFieldTooLong: 9,\n InvalidDate: 10,\n FilenameTooLong: 11,\n StreamFinishing: 12,\n InvalidZipData: 13,\n UnknownCompressionMethod: 14\n};\n// error codes\nvar ec = [\n 'unexpected EOF',\n 'invalid block type',\n 'invalid length/literal',\n 'invalid distance',\n 'stream finished',\n 'no stream handler',\n ,\n 'no callback',\n 'invalid UTF-8 data',\n 'extra field too long',\n 'date not in range 1980-2099',\n 'filename too long',\n 'stream finishing',\n 'invalid zip data'\n // determined by unknown compression method\n];\n;\nvar err = function (ind, msg, nt) {\n var e = new Error(msg || ec[ind]);\n e.code = ind;\n if (Error.captureStackTrace)\n Error.captureStackTrace(e, err);\n if (!nt)\n throw e;\n return e;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, st, buf, dict) {\n // source length dict length\n var sl = dat.length, dl = dict ? dict.length : 0;\n if (!sl || st.f && !st.l)\n return buf || new u8(0);\n var noBuf = !buf;\n // have to estimate size\n var resize = noBuf || st.i != 2;\n // no state\n var noSt = st.i;\n // Assumes roughly 33% compression ratio average\n if (noBuf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n err(0);\n break;\n }\n // ensure size\n if (resize)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8, st.f = final;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n err(1);\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17\n if (resize)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var lpos = pos;\n for (;; lpos = pos) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >> 4;\n pos += c & 15;\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (!c)\n err(2);\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lpos = pos, lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;\n if (!d)\n err(3);\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & (1 << b) - 1, pos += b;\n }\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (resize)\n cbuf(bt + 131072);\n var end = bt + add;\n if (bt < dt) {\n var shift = dl - dt, dend = Math.min(dt, end);\n if (shift + bt < 0)\n err(3);\n for (; bt < dend; ++bt)\n buf[bt] = dict[shift + bt];\n }\n for (; bt < end; ++bt)\n buf[bt] = buf[bt - dt];\n }\n }\n st.l = lm, st.p = lpos, st.b = bt, st.f = final;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n // don't reallocate for streams or user buffers\n return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) | 0;\n d[o] |= v;\n d[o + 1] |= v >> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) | 0;\n d[o] |= v;\n d[o + 1] |= v >> 8;\n d[o + 2] |= v >> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return { t: et, l: 0 };\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return { t: v, l: 1 };\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return { t: new u8(tr), l: mbt };\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return { c: cl.subarray(0, cli), n: s };\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a.t, mlb = _a.l;\n var _b = hTree(df, 15), ddt = _b.t, mdb = _b.l;\n var _c = lc(dlt), lclt = _c.c, nlc = _c.n;\n var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n ++lcfreq[lclt[i] & 31];\n for (var i = 0; i < lcdt.length; ++i)\n ++lcfreq[lcdt[i] & 31];\n var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];\n if (bs >= 0 && flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >> 5) & 127), p += clct[i] >> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n var sym = syms[i];\n if (sym > 255) {\n var len = (sym >> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (sym >> 23) & 31), p += fleb[len];\n var dst = sym & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (sym >> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[sym]), p += ll[sym];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, st) {\n var s = st.z || dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var lst = st.l;\n var pos = (st.r || 0) & 7;\n if (lvl) {\n if (pos)\n w[0] = st.r >> 3;\n var opt = deo[lvl - 1];\n var n = opt >> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new i32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx blkpos\n var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;\n for (; i + 2 < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768 previous index mod\n var imod = i & 32767, pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && (rem > 423 || !lst)) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = i - dif + j & 32767;\n var pti = prev[ti];\n var cd = ti - pti & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += imod - pimod & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one int32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n for (i = Math.max(i, wi); i < s; ++i) {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n if (!lst) {\n st.r = (pos & 7) | w[(pos / 8) | 0] << 3;\n // shft(pos) now 1 less if pos & 7 != 0\n pos -= 7;\n st.h = head, st.p = prev, st.i = i, st.w = wi;\n }\n }\n else {\n for (var i = st.w || 0; i < s + lst; i += 65535) {\n // end\n var e = i + 65535;\n if (e >= s) {\n // write final block\n w[(pos / 8) | 0] = lst;\n e = s;\n }\n pos = wfblk(w, pos + 1, dat.subarray(i, e));\n }\n st.i = s;\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new Int32Array(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && -306674912) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = -1;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return ~c; }\n };\n};\n// Adler32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length | 0;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 2655, l);\n for (; i < e; ++i)\n m += n += d[i];\n n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);\n }\n a = n, b = m;\n },\n d: function () {\n a %= 65521, b %= 65521;\n return (a & 255) << 24 | (a & 0xFF00) << 8 | (b & 255) << 8 | (b >> 8);\n }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n if (!st) {\n st = { l: 1 };\n if (opt.dictionary) {\n var dict = opt.dictionary.subarray(-32768);\n var newDat = new u8(dict.length + dat.length);\n newDat.set(dict);\n newDat.set(dat, dict.length);\n dat = newDat;\n st.w = dict.length;\n }\n }\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? (st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20) : (12 + opt.mem), pre, post, st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/\\s+/g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return fnStr;\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k].buffer) {\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n fnStr = wcln(fns[i], fnStr, td_1);\n ch[id] = { c: wcln(fns[m], fnStr, td_1), e: td_1 };\n }\n var td = mrg({}, ch[id].e);\n return wk(ch[id].c + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, i32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, ec, hMap, max, bits, bits16, shft, slc, err, inflt, inflateSync, pbf, gopt]; };\nvar bDflt = function () { return [u8, u16, i32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zls]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get opts\nvar gopt = function (o) { return o && {\n out: o.size && new u8(o.size),\n dictionary: o.dictionary\n}; };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n w.postMessage([dat, opts], opts.consume ? [dat.buffer] : []);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) {\n if (ev.data.length) {\n strm.push(ev.data[0], ev.data[1]);\n postMessage([ev.data[0].length]);\n }\n else\n strm.flush();\n };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id, flush, ext) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else if (!Array.isArray(dat))\n ext(dat);\n else if (dat.length == 1) {\n strm.queuedSize -= dat[0];\n if (strm.ondrain)\n strm.ondrain(dat[0]);\n }\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.queuedSize = 0;\n strm.push = function (d, f) {\n if (!strm.ondata)\n err(5);\n if (t)\n strm.ondata(err(4, 0, 1), null, !!f);\n strm.queuedSize += d.length;\n w.postMessage([d, t = f], [d.buffer]);\n };\n strm.terminate = function () { w.terminate(); };\n if (flush) {\n strm.flush = function () { w.postMessage([]); };\n }\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };\nvar b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n err(6, 'invalid gzip data');\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += (d[10] | d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + (o.filename ? o.filename.length + 1 : 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (o.dictionary && 32);\n c[1] |= 31 - ((c[0] << 8) | c[1]) % 31;\n if (o.dictionary) {\n var h = adler();\n h.p(o.dictionary);\n wbytes(c, 2, h.d());\n }\n};\n// zlib start\nvar zls = function (d, dict) {\n if ((d[0] & 15) != 8 || (d[0] >> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n err(6, 'invalid zlib data');\n if ((d[1] >> 5 & 1) == +!dict)\n err(6, 'invalid zlib data: ' + (d[1] & 32 ? 'need' : 'unexpected') + ' dictionary');\n return (d[1] >> 3 & 4) + 2;\n};\nfunction StrmOpt(opts, cb) {\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n this.s = { l: 0, i: 32768, w: 32768, z: 32768 };\n // Buffer length must always be 0 mod 32768 for index calculations to be correct when modifying head and prev\n // 98304 = 32768 (lookback) + 65536 (common chunk size)\n this.b = new u8(98304);\n if (this.o.dictionary) {\n var dict = this.o.dictionary.subarray(-32768);\n this.b.set(dict, 32768 - dict.length);\n this.s.i = 32768 - dict.length;\n }\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, this.s), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (this.s.l)\n err(4);\n var endLen = chunk.length + this.s.z;\n if (endLen > this.b.length) {\n if (endLen > 2 * this.b.length - 32768) {\n var newBuf = new u8(endLen & -32768);\n newBuf.set(this.b.subarray(0, this.s.z));\n this.b = newBuf;\n }\n var split = this.b.length - this.s.z;\n this.b.set(chunk.subarray(0, split), this.s.z);\n this.s.z = this.b.length;\n this.p(this.b, false);\n this.b.set(this.b.subarray(-32768));\n this.b.set(chunk.subarray(split), 32768);\n this.s.z = chunk.length - split + 32768;\n this.s.i = 32766, this.s.w = 32768;\n }\n else {\n this.b.set(chunk, this.s.z);\n this.s.z += chunk.length;\n }\n this.s.l = final & 1;\n if (this.s.z > this.s.w + 8191 || final) {\n this.p(this.b, final || false);\n this.s.w = this.s.i, this.s.i -= 2;\n }\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * deflated output for small inputs.\n */\n Deflate.prototype.flush = function () {\n if (!this.ondata)\n err(5);\n if (this.s.l)\n err(4);\n this.p(this.b, false);\n this.s.w = this.s.i, this.s.i -= 2;\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6, 1);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n return dopt(data, opts || {}, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n function Inflate(opts, cb) {\n // no StrmOpt here to avoid adding to workerizer\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n var dict = opts && opts.dictionary && opts.dictionary.subarray(-32768);\n this.s = { i: 0, b: dict ? dict.length : 0 };\n this.o = new u8(32768);\n this.p = new u8(0);\n if (dict)\n this.o.set(dict);\n }\n Inflate.prototype.e = function (c) {\n if (!this.ondata)\n err(5);\n if (this.d)\n err(4);\n if (!this.p.length)\n this.p = c;\n else if (c.length) {\n var n = new u8(this.p.length + c.length);\n n.set(this.p), n.set(c, this.p.length), this.p = n;\n }\n };\n Inflate.prototype.c = function (final) {\n this.s.i = +(this.d = final || false);\n var bts = this.s.b;\n var dt = inflt(this.p, this.s, this.o);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) | 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n function AsyncInflate(opts, cb) {\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Inflate(ev.data);\n onmessage = astrm(strm);\n }, 7, 0);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gopt(ev.data[1]))); }, 1, cb);\n}\n/**\n * Expands DEFLATE data with no wrapper\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function inflateSync(data, opts) {\n return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n this.c.p(chunk);\n this.l += chunk.length;\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, this.s);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * GZIPped output for small inputs.\n */\n Gzip.prototype.flush = function () {\n Deflate.prototype.flush.call(this);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8, 1);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (!opts)\n opts = {};\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming single or multi-member GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n function Gunzip(opts, cb) {\n this.v = 1;\n this.r = 0;\n Inflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n this.r += chunk.length;\n if (this.v) {\n var p = this.p.subarray(this.v - 1);\n var s = p.length > 3 ? gzs(p) : 4;\n if (s > p.length) {\n if (!final)\n return;\n }\n else if (this.v > 1 && this.onmember) {\n this.onmember(this.r - p.length);\n }\n this.p = p.subarray(s), this.v = 0;\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n // process concatenated GZIP\n if (this.s.f && !this.s.l && !final) {\n this.v = shft(this.s.p) + 9;\n this.s = { i: 0 };\n this.o = new u8(0);\n this.push(new u8(0), final);\n }\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming single or multi-member GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n function AsyncGunzip(opts, cb) {\n var _this = this;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Gunzip(ev.data);\n strm.onmember = function (offset) { return postMessage(offset); };\n onmessage = astrm(strm);\n }, 9, 0, function (offset) { return _this.onmember && _this.onmember(offset); });\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0], ev.data[1])); }, 3, cb);\n}\n/**\n * Expands GZIP data\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function gunzipSync(data, opts) {\n var st = gzs(data);\n if (st + 8 > data.length)\n err(6, 'invalid gzip data');\n return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary);\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n this.c.p(chunk);\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n var raw = dopt(c, this.o, this.v && (this.o.dictionary ? 6 : 2), f && 4, this.s);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * zlibbed output for small inputs.\n */\n Zlib.prototype.flush = function () {\n Deflate.prototype.flush.call(this);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10, 1);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (!opts)\n opts = {};\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, opts.dictionary ? 6 : 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n function Unzlib(opts, cb) {\n Inflate.call(this, opts, cb);\n this.v = opts && opts.dictionary ? 2 : 1;\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 6 && !final)\n return;\n this.p = this.p.subarray(zls(this.p, this.v - 1)), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n err(6, 'invalid zlib data');\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n function AsyncUnzlib(opts, cb) {\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Unzlib(ev.data);\n onmessage = astrm(strm);\n }, 11, 0);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gopt(ev.data[1]))); }, 5, cb);\n}\n/**\n * Expands Zlib data\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function unzlibSync(data, opts) {\n return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n function Decompress(opts, cb) {\n this.o = StrmOpt.call(this, opts, cb) || {};\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n }\n // init substream\n // overriden by AsyncDecompress\n Decompress.prototype.i = function () {\n var _this = this;\n this.s.ondata = function (dat, final) {\n _this.ondata(dat, final);\n };\n };\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(this.o)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(this.o)\n : new this.Z(this.o);\n this.i();\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n function AsyncDecompress(opts, cb) {\n Decompress.call(this, opts, cb);\n this.queuedSize = 0;\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n }\n AsyncDecompress.prototype.i = function () {\n var _this = this;\n this.s.ondata = function (err, dat, final) {\n _this.ondata(err, dat, final);\n };\n this.s.ondrain = function (size) {\n _this.queuedSize -= size;\n if (_this.ondrain)\n _this.ondrain(size);\n };\n };\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n this.queuedSize += chunk.length;\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, opts) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, opts)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, opts)\n : unzlibSync(data, opts);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k, op = o;\n if (Array.isArray(val))\n op = mrg(o, val[1]), val = val[0];\n if (val instanceof u8)\n t[n] = [val, op];\n else {\n t[n += '/'] = [new u8(0), op];\n fltn(val, n, t, o);\n }\n }\n};\n// text encoder\nvar te = typeof TextEncoder != 'undefined' && /*#__PURE__*/ new TextEncoder();\n// text decoder\nvar td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();\n// text decoder stream\nvar tds = 0;\ntry {\n td.decode(et, { stream: true });\n tds = 1;\n}\ncatch (e) { }\n// decode UTF8\nvar dutf8 = function (d) {\n for (var r = '', i = 0;;) {\n var c = d[i++];\n var eb = (c > 127) + (c > 223) + (c > 239);\n if (i + eb > d.length)\n return { s: r, r: slc(d, i - 1) };\n if (!eb)\n r += String.fromCharCode(c);\n else if (eb == 3) {\n c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n else if (eb & 1)\n r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));\n else\n r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));\n }\n};\n/**\n * Streaming UTF-8 decoding\n */\nvar DecodeUTF8 = /*#__PURE__*/ (function () {\n /**\n * Creates a UTF-8 decoding stream\n * @param cb The callback to call whenever data is decoded\n */\n function DecodeUTF8(cb) {\n this.ondata = cb;\n if (tds)\n this.t = new TextDecoder();\n else\n this.p = et;\n }\n /**\n * Pushes a chunk to be decoded from UTF-8 binary\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n DecodeUTF8.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n final = !!final;\n if (this.t) {\n this.ondata(this.t.decode(chunk, { stream: true }), final);\n if (final) {\n if (this.t.decode().length)\n err(8);\n this.t = null;\n }\n return;\n }\n if (!this.p)\n err(4);\n var dat = new u8(this.p.length + chunk.length);\n dat.set(this.p);\n dat.set(chunk, this.p.length);\n var _a = dutf8(dat), s = _a.s, r = _a.r;\n if (final) {\n if (r.length)\n err(8);\n this.p = null;\n }\n else\n this.p = r;\n this.ondata(s, final);\n };\n return DecodeUTF8;\n}());\nexport { DecodeUTF8 };\n/**\n * Streaming UTF-8 encoding\n */\nvar EncodeUTF8 = /*#__PURE__*/ (function () {\n /**\n * Creates a UTF-8 decoding stream\n * @param cb The callback to call whenever data is encoded\n */\n function EncodeUTF8(cb) {\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be encoded to UTF-8\n * @param chunk The string data to push\n * @param final Whether this is the last chunk\n */\n EncodeUTF8.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (this.d)\n err(4);\n this.ondata(strToU8(chunk), this.d = final || false);\n };\n return EncodeUTF8;\n}());\nexport { EncodeUTF8 };\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n if (latin1) {\n var ar_1 = new u8(str.length);\n for (var i = 0; i < str.length; ++i)\n ar_1[i] = str.charCodeAt(i);\n return ar_1;\n }\n if (te)\n return te.encode(str);\n var l = str.length;\n var ar = new u8(str.length + (str.length >> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >> 18)), w(128 | ((c >> 12) & 63)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >> 12)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n if (latin1) {\n var r = '';\n for (var i = 0; i < dat.length; i += 16384)\n r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));\n return r;\n }\n else if (td) {\n return td.decode(dat);\n }\n else {\n var _a = dutf8(dat), s = _a.s, r = _a.r;\n if (r.length)\n err(8);\n return s;\n }\n}\n;\n// deflate bit flag\nvar dbf = function (l) { return l == 1 ? 3 : l < 6 ? 2 : l == 9 ? 1 : 0; };\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);\n var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];\n};\n// read zip64 extra field\nvar z64e = function (d, b) {\n for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))\n ;\n return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];\n};\n// extra field length\nvar exfl = function (ex) {\n var le = 0;\n if (ex) {\n for (var k in ex) {\n var l = ex[k].length;\n if (l > 65535)\n err(9);\n le += l + 4;\n }\n }\n return le;\n};\n// write zip header\nvar wzh = function (d, b, f, fn, u, c, ce, co) {\n var fl = fn.length, ex = f.extra, col = co && co.length;\n var exl = exfl(ex);\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b++] = 20, d[b++] = f.os;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (f.flag << 1) | (c < 0 && 8), d[b++] = u && 8;\n d[b++] = f.compression & 255, d[b++] = f.compression >> 8;\n var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n err(10);\n wbytes(d, b, (y << 25) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >> 1)), b += 4;\n if (c != -1) {\n wbytes(d, b, f.crc);\n wbytes(d, b + 4, c < 0 ? -c - 2 : c);\n wbytes(d, b + 8, f.size);\n }\n wbytes(d, b + 12, fl);\n wbytes(d, b + 14, exl), b += 16;\n if (ce != null) {\n wbytes(d, b, col);\n wbytes(d, b + 6, f.attrs);\n wbytes(d, b + 10, ce), b += 14;\n }\n d.set(fn, b);\n b += fl;\n if (exl) {\n for (var k in ex) {\n var exf = ex[k], l = exf.length;\n wbytes(d, b, +k);\n wbytes(d, b + 2, l);\n d.set(exf, b + 4), b += 4 + l;\n }\n }\n if (col)\n d.set(co, b), b += col;\n return b;\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\n/**\n * A pass-through stream to keep data uncompressed in a ZIP archive.\n */\nvar ZipPassThrough = /*#__PURE__*/ (function () {\n /**\n * Creates a pass-through stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n */\n function ZipPassThrough(filename) {\n this.filename = filename;\n this.c = crc();\n this.size = 0;\n this.compression = 0;\n }\n /**\n * Processes a chunk and pushes to the output stream. You can override this\n * method in a subclass for custom behavior, but by default this passes\n * the data through. You must call this.ondata(err, chunk, final) at some\n * point in this method.\n * @param chunk The chunk to process\n * @param final Whether this is the last chunk\n */\n ZipPassThrough.prototype.process = function (chunk, final) {\n this.ondata(null, chunk, final);\n };\n /**\n * Pushes a chunk to be added. If you are subclassing this with a custom\n * compression algorithm, note that you must push data from the source\n * file only, pre-compression.\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n ZipPassThrough.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n this.c.p(chunk);\n this.size += chunk.length;\n if (final)\n this.crc = this.c.d();\n this.process(chunk, final || false);\n };\n return ZipPassThrough;\n}());\nexport { ZipPassThrough };\n// I don't extend because TypeScript extension adds 1kB of runtime bloat\n/**\n * Streaming DEFLATE compression for ZIP archives. Prefer using AsyncZipDeflate\n * for better performance\n */\nvar ZipDeflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n * @param opts The compression options\n */\n function ZipDeflate(filename, opts) {\n var _this = this;\n if (!opts)\n opts = {};\n ZipPassThrough.call(this, filename);\n this.d = new Deflate(opts, function (dat, final) {\n _this.ondata(null, dat, final);\n });\n this.compression = 8;\n this.flag = dbf(opts.level);\n }\n ZipDeflate.prototype.process = function (chunk, final) {\n try {\n this.d.push(chunk, final);\n }\n catch (e) {\n this.ondata(e, null, final);\n }\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n ZipDeflate.prototype.push = function (chunk, final) {\n ZipPassThrough.prototype.push.call(this, chunk, final);\n };\n return ZipDeflate;\n}());\nexport { ZipDeflate };\n/**\n * Asynchronous streaming DEFLATE compression for ZIP archives\n */\nvar AsyncZipDeflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous DEFLATE stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n * @param opts The compression options\n */\n function AsyncZipDeflate(filename, opts) {\n var _this = this;\n if (!opts)\n opts = {};\n ZipPassThrough.call(this, filename);\n this.d = new AsyncDeflate(opts, function (err, dat, final) {\n _this.ondata(err, dat, final);\n });\n this.compression = 8;\n this.flag = dbf(opts.level);\n this.terminate = this.d.terminate;\n }\n AsyncZipDeflate.prototype.process = function (chunk, final) {\n this.d.push(chunk, final);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncZipDeflate.prototype.push = function (chunk, final) {\n ZipPassThrough.prototype.push.call(this, chunk, final);\n };\n return AsyncZipDeflate;\n}());\nexport { AsyncZipDeflate };\n// TODO: Better tree shaking\n/**\n * A zippable archive to which files can incrementally be added\n */\nvar Zip = /*#__PURE__*/ (function () {\n /**\n * Creates an empty ZIP archive to which files can be added\n * @param cb The callback to call whenever data for the generated ZIP archive\n * is available\n */\n function Zip(cb) {\n this.ondata = cb;\n this.u = [];\n this.d = 1;\n }\n /**\n * Adds a file to the ZIP archive\n * @param file The file stream to add\n */\n Zip.prototype.add = function (file) {\n var _this = this;\n if (!this.ondata)\n err(5);\n // finishing or finished\n if (this.d & 2)\n this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, false);\n else {\n var f = strToU8(file.filename), fl_1 = f.length;\n var com = file.comment, o = com && strToU8(com);\n var u = fl_1 != file.filename.length || (o && (com.length != o.length));\n var hl_1 = fl_1 + exfl(file.extra) + 30;\n if (fl_1 > 65535)\n this.ondata(err(11, 0, 1), null, false);\n var header = new u8(hl_1);\n wzh(header, 0, file, f, u, -1);\n var chks_1 = [header];\n var pAll_1 = function () {\n for (var _i = 0, chks_2 = chks_1; _i < chks_2.length; _i++) {\n var chk = chks_2[_i];\n _this.ondata(null, chk, false);\n }\n chks_1 = [];\n };\n var tr_1 = this.d;\n this.d = 0;\n var ind_1 = this.u.length;\n var uf_1 = mrg(file, {\n f: f,\n u: u,\n o: o,\n t: function () {\n if (file.terminate)\n file.terminate();\n },\n r: function () {\n pAll_1();\n if (tr_1) {\n var nxt = _this.u[ind_1 + 1];\n if (nxt)\n nxt.r();\n else\n _this.d = 1;\n }\n tr_1 = 1;\n }\n });\n var cl_1 = 0;\n file.ondata = function (err, dat, final) {\n if (err) {\n _this.ondata(err, dat, final);\n _this.terminate();\n }\n else {\n cl_1 += dat.length;\n chks_1.push(dat);\n if (final) {\n var dd = new u8(16);\n wbytes(dd, 0, 0x8074B50);\n wbytes(dd, 4, file.crc);\n wbytes(dd, 8, cl_1);\n wbytes(dd, 12, file.size);\n chks_1.push(dd);\n uf_1.c = cl_1, uf_1.b = hl_1 + cl_1 + 16, uf_1.crc = file.crc, uf_1.size = file.size;\n if (tr_1)\n uf_1.r();\n tr_1 = 1;\n }\n else if (tr_1)\n pAll_1();\n }\n };\n this.u.push(uf_1);\n }\n };\n /**\n * Ends the process of adding files and prepares to emit the final chunks.\n * This *must* be called after adding all desired files for the resulting\n * ZIP file to work properly.\n */\n Zip.prototype.end = function () {\n var _this = this;\n if (this.d & 2) {\n this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, true);\n return;\n }\n if (this.d)\n this.e();\n else\n this.u.push({\n r: function () {\n if (!(_this.d & 1))\n return;\n _this.u.splice(-1, 1);\n _this.e();\n },\n t: function () { }\n });\n this.d = 3;\n };\n Zip.prototype.e = function () {\n var bt = 0, l = 0, tl = 0;\n for (var _i = 0, _a = this.u; _i < _a.length; _i++) {\n var f = _a[_i];\n tl += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0);\n }\n var out = new u8(tl + 22);\n for (var _b = 0, _c = this.u; _b < _c.length; _b++) {\n var f = _c[_b];\n wzh(out, bt, f, f.f, f.u, -f.c - 2, l, f.o);\n bt += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0), l += f.b;\n }\n wzf(out, bt, this.u.length, tl, l);\n this.ondata(null, out, true);\n this.d = 2;\n };\n /**\n * A method to terminate any internal workers used by the stream. Subsequent\n * calls to add() will fail.\n */\n Zip.prototype.terminate = function () {\n for (var _i = 0, _a = this.u; _i < _a.length; _i++) {\n var f = _a[_i];\n f.t();\n }\n this.d = 2;\n };\n return Zip;\n}());\nexport { Zip };\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbd = function (a, b) {\n mt(function () { cb(a, b); });\n };\n mt(function () { cbd = cb; });\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n var l = f.c.length;\n wzh(out, tot, f, f.f, f.u, l);\n var badd = 30 + f.f.length + exfl(f.extra);\n var loc = tot + badd;\n out.set(f.c, loc);\n wzh(out, o, f, f.f, f.u, l, tot, f.m), o += 16 + badd + (f.m ? f.m.length : 0), tot = loc + l;\n }\n catch (e) {\n return cbd(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cbd(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), size = file.length;\n c.p(file);\n var f = strToU8(fn), s = f.length;\n var com = p.comment, m = com && strToU8(com), ms = m && m.length;\n var exl = exfl(p.extra);\n var compression = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cbd(e, null);\n }\n else {\n var l = d.length;\n files[i] = mrg(p, {\n size: size,\n crc: c.d(),\n c: d,\n f: f,\n m: m,\n u: s != fn.length || (m && (com.length != ms)),\n compression: compression\n });\n o += 30 + s + exl + l;\n tot += 76 + 2 * (s + exl) + (ms || 0) + l;\n if (!--lft)\n cbf();\n }\n };\n if (s > 65535)\n cbl(err(11, 0, 1), null);\n if (!compression)\n cbl(null, file);\n else if (size < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (!opts)\n opts = {};\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var compression = p.level == 0 ? 0 : 8;\n var f = strToU8(fn), s = f.length;\n var com = p.comment, m = com && strToU8(com), ms = m && m.length;\n var exl = exfl(p.extra);\n if (s > 65535)\n err(11);\n var d = compression ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push(mrg(p, {\n size: file.length,\n crc: c.d(),\n c: d,\n f: f,\n m: m,\n u: s != fn.length || (m && (com.length != ms)),\n o: o,\n compression: compression\n }));\n o += 30 + s + exl + l;\n tot += 76 + 2 * (s + exl) + (ms || 0) + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f, f.f, f.u, f.c.length);\n var badd = 30 + f.f.length + exfl(f.extra);\n out.set(f.c, f.o + badd);\n wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Streaming pass-through decompression for ZIP archives\n */\nvar UnzipPassThrough = /*#__PURE__*/ (function () {\n function UnzipPassThrough() {\n }\n UnzipPassThrough.prototype.push = function (data, final) {\n this.ondata(null, data, final);\n };\n UnzipPassThrough.compression = 0;\n return UnzipPassThrough;\n}());\nexport { UnzipPassThrough };\n/**\n * Streaming DEFLATE decompression for ZIP archives. Prefer AsyncZipInflate for\n * better performance.\n */\nvar UnzipInflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE decompression that can be used in ZIP archives\n */\n function UnzipInflate() {\n var _this = this;\n this.i = new Inflate(function (dat, final) {\n _this.ondata(null, dat, final);\n });\n }\n UnzipInflate.prototype.push = function (data, final) {\n try {\n this.i.push(data, final);\n }\n catch (e) {\n this.ondata(e, null, final);\n }\n };\n UnzipInflate.compression = 8;\n return UnzipInflate;\n}());\nexport { UnzipInflate };\n/**\n * Asynchronous streaming DEFLATE decompression for ZIP archives\n */\nvar AsyncUnzipInflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE decompression that can be used in ZIP archives\n */\n function AsyncUnzipInflate(_, sz) {\n var _this = this;\n if (sz < 320000) {\n this.i = new Inflate(function (dat, final) {\n _this.ondata(null, dat, final);\n });\n }\n else {\n this.i = new AsyncInflate(function (err, dat, final) {\n _this.ondata(err, dat, final);\n });\n this.terminate = this.i.terminate;\n }\n }\n AsyncUnzipInflate.prototype.push = function (data, final) {\n if (this.i.terminate)\n data = slc(data, 0);\n this.i.push(data, final);\n };\n AsyncUnzipInflate.compression = 8;\n return AsyncUnzipInflate;\n}());\nexport { AsyncUnzipInflate };\n/**\n * A ZIP archive decompression stream that emits files as they are discovered\n */\nvar Unzip = /*#__PURE__*/ (function () {\n /**\n * Creates a ZIP decompression stream\n * @param cb The callback to call whenever a file in the ZIP archive is found\n */\n function Unzip(cb) {\n this.onfile = cb;\n this.k = [];\n this.o = {\n 0: UnzipPassThrough\n };\n this.p = et;\n }\n /**\n * Pushes a chunk to be unzipped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzip.prototype.push = function (chunk, final) {\n var _this = this;\n if (!this.onfile)\n err(5);\n if (!this.p)\n err(4);\n if (this.c > 0) {\n var len = Math.min(this.c, chunk.length);\n var toAdd = chunk.subarray(0, len);\n this.c -= len;\n if (this.d)\n this.d.push(toAdd, !this.c);\n else\n this.k[0].push(toAdd);\n chunk = chunk.subarray(len);\n if (chunk.length)\n return this.push(chunk, final);\n }\n else {\n var f = 0, i = 0, is = void 0, buf = void 0;\n if (!this.p.length)\n buf = chunk;\n else if (!chunk.length)\n buf = this.p;\n else {\n buf = new u8(this.p.length + chunk.length);\n buf.set(this.p), buf.set(chunk, this.p.length);\n }\n var l = buf.length, oc = this.c, add = oc && this.d;\n var _loop_2 = function () {\n var _a;\n var sig = b4(buf, i);\n if (sig == 0x4034B50) {\n f = 1, is = i;\n this_1.d = null;\n this_1.c = 0;\n var bf = b2(buf, i + 6), cmp_1 = b2(buf, i + 8), u = bf & 2048, dd = bf & 8, fnl = b2(buf, i + 26), es = b2(buf, i + 28);\n if (l > i + 30 + fnl + es) {\n var chks_3 = [];\n this_1.k.unshift(chks_3);\n f = 2;\n var sc_1 = b4(buf, i + 18), su_1 = b4(buf, i + 22);\n var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);\n if (sc_1 == 4294967295) {\n _a = dd ? [-2] : z64e(buf, i), sc_1 = _a[0], su_1 = _a[1];\n }\n else if (dd)\n sc_1 = -1;\n i += es;\n this_1.c = sc_1;\n var d_1;\n var file_1 = {\n name: fn_1,\n compression: cmp_1,\n start: function () {\n if (!file_1.ondata)\n err(5);\n if (!sc_1)\n file_1.ondata(null, et, true);\n else {\n var ctr = _this.o[cmp_1];\n if (!ctr)\n file_1.ondata(err(14, 'unknown compression type ' + cmp_1, 1), null, false);\n d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);\n d_1.ondata = function (err, dat, final) { file_1.ondata(err, dat, final); };\n for (var _i = 0, chks_4 = chks_3; _i < chks_4.length; _i++) {\n var dat = chks_4[_i];\n d_1.push(dat, false);\n }\n if (_this.k[0] == chks_3 && _this.c)\n _this.d = d_1;\n else\n d_1.push(et, true);\n }\n },\n terminate: function () {\n if (d_1 && d_1.terminate)\n d_1.terminate();\n }\n };\n if (sc_1 >= 0)\n file_1.size = sc_1, file_1.originalSize = su_1;\n this_1.onfile(file_1);\n }\n return \"break\";\n }\n else if (oc) {\n if (sig == 0x8074B50) {\n is = i += 12 + (oc == -2 && 8), f = 3, this_1.c = 0;\n return \"break\";\n }\n else if (sig == 0x2014B50) {\n is = i -= 4, f = 3, this_1.c = 0;\n return \"break\";\n }\n }\n };\n var this_1 = this;\n for (; i < l - 4; ++i) {\n var state_1 = _loop_2();\n if (state_1 === \"break\")\n break;\n }\n this.p = et;\n if (oc < 0) {\n var dat = f ? buf.subarray(0, is - 12 - (oc == -2 && 8) - (b4(buf, is - 16) == 0x8074B50 && 4)) : buf.subarray(0, i);\n if (add)\n add.push(dat, !!f);\n else\n this.k[+(f == 2)].push(dat);\n }\n if (f & 2)\n return this.push(buf.subarray(i), final);\n this.p = buf.subarray(i);\n }\n if (final) {\n if (this.c)\n err(13);\n this.p = null;\n }\n };\n /**\n * Registers a decoder with the stream, allowing for files compressed with\n * the compression type provided to be expanded correctly\n * @param decoder The decoder constructor\n */\n Unzip.prototype.register = function (decoder) {\n this.o[decoder.compression] = decoder;\n };\n return Unzip;\n}());\nexport { Unzip };\nvar mt = typeof queueMicrotask == 'function' ? queueMicrotask : typeof setTimeout == 'function' ? setTimeout : function (fn) { fn(); };\nexport function unzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var cbd = function (a, b) {\n mt(function () { cb(a, b); });\n };\n mt(function () { cbd = cb; });\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cbd(err(13, 0, 1), null);\n return tAll;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (lft) {\n var c = lft;\n var o = b4(data, e + 16);\n var z = o == 4294967295 || c == 65535;\n if (z) {\n var ze = b4(data, e - 12);\n z = b4(data, ze) == 0x6064B50;\n if (z) {\n c = lft = b4(data, ze + 32);\n o = b4(data, ze + 48);\n }\n }\n var fltr = opts && opts.filter;\n var _loop_3 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cbd(e, null);\n }\n else {\n if (d)\n files[fn] = d;\n if (!--lft)\n cbd(null, files);\n }\n };\n if (!fltr || fltr({\n name: fn,\n size: sc,\n originalSize: su,\n compression: c_1\n })) {\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n // Synchronously decompress under 512KB, or barely-compressed data\n if (su < 524288 || sc > 0.8 * su) {\n try {\n cbl(null, inflateSync(infl, { out: new u8(su) }));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl(err(14, 'unknown compression type ' + c_1, 1), null);\n }\n else\n cbl(null, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_3(i);\n }\n }\n else\n cbd(null, {});\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @param opts The ZIP extraction options\n * @returns The decompressed files\n */\nexport function unzipSync(data, opts) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n err(13);\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = o == 4294967295 || c == 65535;\n if (z) {\n var ze = b4(data, e - 12);\n z = b4(data, ze) == 0x6064B50;\n if (z) {\n c = b4(data, ze + 32);\n o = b4(data, ze + 48);\n }\n }\n var fltr = opts && opts.filter;\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!fltr || fltr({\n name: fn,\n size: sc,\n originalSize: su,\n compression: c_2\n })) {\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });\n else\n err(14, 'unknown compression type ' + c_2);\n }\n }\n return files;\n}\n","import { gunzipSync } from \"fflate\";\nimport type { Tileset } from \"3d-tiles-renderer/core\";\nimport type { StructureData } from \"../plugin-types\";\n\n/** 兼容:少数 tileset 在根级挂 structureUri */\nexport type TilesetWithStructureUri = Tileset & {\n structureUri?: string;\n};\n\n/** 从 tileset 取内嵌 structure 的 data URI(优先 MapTalks:`asset.extras.maptalks.structureUri`) */\nexport function getStructureDataUriFromTileset(\n root: Tileset | null,\n): string | null {\n if (!root) return null;\n\n const extras = (root.asset as { extras?: Record<string, unknown> } | undefined)\n ?.extras;\n const maptalks = extras?.maptalks;\n if (maptalks && typeof maptalks === \"object\") {\n const uri = (maptalks as { structureUri?: unknown }).structureUri;\n if (typeof uri === \"string\" && uri.trim()) {\n return uri.trim();\n }\n }\n\n const legacy = (root as TilesetWithStructureUri).structureUri;\n if (typeof legacy === \"string\" && legacy.trim()) {\n return legacy.trim();\n }\n\n return null;\n}\n\nfunction base64ToUint8Array(b64: string): Uint8Array {\n const clean = b64.replace(/\\s/g, \"\");\n if (typeof globalThis.atob === \"function\") {\n const bin = globalThis.atob(clean);\n const out = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) {\n out[i] = bin.charCodeAt(i);\n }\n return out;\n }\n if (typeof Buffer !== \"undefined\") {\n return new Uint8Array(Buffer.from(clean, \"base64\"));\n }\n throw new Error(\"[tileset-structure-uri] No base64 decoder available\");\n}\n\n/**\n * 同步解析 `data:application/x-gzip;base64,...`:base64 → 二进制 → gunzip → UTF-8 文本。\n */\nexport function decodeGzipBase64DataUriSync(dataUri: string): string {\n const comma = dataUri.indexOf(\",\");\n if (comma < 0) {\n throw new Error(\"[tileset-structure-uri] Invalid data URI: missing comma\");\n }\n const header = dataUri.slice(0, comma).toLowerCase();\n if (!header.includes(\"base64\")) {\n throw new Error(\n \"[tileset-structure-uri] Expected base64 data URI (e.g. data:application/x-gzip;base64,...)\",\n );\n }\n const payload = dataUri.slice(comma + 1);\n const compressed = base64ToUint8Array(payload);\n const raw = gunzipSync(compressed);\n return new TextDecoder(\"utf-8\").decode(raw);\n}\n\n/**\n * 从已加载的根 tileset 读取内嵌 structure(`asset.extras.maptalks.structureUri`,\n * 若无则回退根级 `structureUri`),同步解码并解析。\n * - 无有效 URI 或解析失败时返回 `null`(不抛错)。\n */\nexport function parseEmbeddedStructureDataFromTilesSync(\n tiles: { rootTileset: Tileset | null },\n): StructureData | null {\n const uri = getStructureDataUriFromTileset(tiles.rootTileset);\n if (!uri) {\n return null;\n }\n try {\n const text = decodeGzipBase64DataUriSync(uri);\n const data = JSON.parse(text) as StructureData;\n return data;\n } catch (e) {\n console.warn(\"[GLTFParserPlugin] Failed to decode tileset structureUri:\", e);\n return null;\n }\n}\n","class z {\n /**\n * Comparator used to determine eviction order. Items that sort last are evicted first.\n * Defaults to `null` (eviction order is by last-used time).\n * @type {UnloadPriorityCallback|null}\n */\n get unloadPriorityCallback() {\n return this._unloadPriorityCallback;\n }\n set unloadPriorityCallback(t) {\n t.length === 1 ? (console.warn('LRUCache: \"unloadPriorityCallback\" function has been changed to take two arguments.'), this._unloadPriorityCallback = (a, e) => {\n const s = t(a), o = t(e);\n return s < o ? -1 : s > o ? 1 : 0;\n }) : this._unloadPriorityCallback = t;\n }\n constructor() {\n this.minSize = 6e3, this.maxSize = 8e3, this.minBytesSize = 0.3 * 1073741824, this.maxBytesSize = 0.4 * 1073741824, this.unloadPercent = 0.05, this.autoMarkUnused = !0, this.itemSet = /* @__PURE__ */ new Map(), this.itemList = [], this.usedSet = /* @__PURE__ */ new Set(), this.callbacks = /* @__PURE__ */ new Map(), this.unloadingHandle = -1, this.cachedBytes = 0, this.bytesMap = /* @__PURE__ */ new Map(), this.loadedSet = /* @__PURE__ */ new Set(), this._unloadPriorityCallback = null;\n const t = this.itemSet;\n this.defaultPriorityCallback = (a) => t.get(a);\n }\n /**\n * Returns whether the cache has reached its maximum item count or byte size.\n * @returns {boolean}\n */\n isFull() {\n return this.itemSet.size >= this.maxSize || this.cachedBytes >= this.maxBytesSize;\n }\n /**\n * Returns the byte size registered for the given item, or 0 if not tracked.\n * @param {any} item\n * @returns {number}\n */\n getMemoryUsage(t) {\n return this.bytesMap.get(t) || 0;\n }\n /**\n * Sets the byte size for the given item, updating the total `cachedBytes` count.\n * @param {any} item\n * @param {number} bytes\n */\n setMemoryUsage(t, a) {\n const { bytesMap: e, itemSet: s } = this;\n s.has(t) && (this.cachedBytes -= e.get(t) || 0, e.set(t, a), this.cachedBytes += a);\n }\n /**\n * Adds an item to the cache. Returns false if the item already exists or the cache is full.\n * @param {any} item\n * @param {RemoveCallback} removeCb - Called with the item when it is evicted\n * @returns {boolean}\n */\n add(t, a) {\n const e = this.itemSet;\n if (e.has(t) || this.isFull())\n return !1;\n const s = this.usedSet, o = this.itemList, i = this.callbacks;\n return o.push(t), s.add(t), e.set(t, Date.now()), i.set(t, a), !0;\n }\n /**\n * Returns whether the given item is in the cache.\n * @param {any} item\n * @returns {boolean}\n */\n has(t) {\n return this.itemSet.has(t);\n }\n /**\n * Removes an item from the cache immediately, invoking its removal callback.\n * Returns false if the item was not in the cache.\n * @param {any} item\n * @returns {boolean}\n */\n remove(t) {\n const a = this.usedSet, e = this.itemSet, s = this.itemList, o = this.bytesMap, i = this.callbacks, c = this.loadedSet;\n if (e.has(t)) {\n this.cachedBytes -= o.get(t) || 0, o.delete(t), i.get(t)(t);\n const d = s.indexOf(t);\n return s.splice(d, 1), a.delete(t), e.delete(t), i.delete(t), c.delete(t), !0;\n }\n return !1;\n }\n /**\n * Marks whether an item has finished loading. Unloaded items may be evicted early\n * when the cache is over its max size limits, even if they are marked as used.\n * @param {any} item\n * @param {boolean} value\n */\n setLoaded(t, a) {\n const { itemSet: e, loadedSet: s } = this;\n e.has(t) && (a === !0 ? s.add(t) : s.delete(t));\n }\n /**\n * Marks an item as used in the current frame, preventing it from being evicted.\n * @param {any} item\n */\n markUsed(t) {\n const a = this.itemSet, e = this.usedSet;\n a.has(t) && !e.has(t) && (a.set(t, Date.now()), e.add(t));\n }\n /**\n * Marks an item as unused, making it eligible for eviction.\n * @param {any} item\n */\n markUnused(t) {\n this.usedSet.delete(t);\n }\n /**\n * Marks all items in the cache as unused.\n */\n markAllUnused() {\n this.usedSet.clear();\n }\n /**\n * Returns whether the given item is currently marked as used.\n * @param {any} item\n * @returns {boolean}\n */\n isUsed(t) {\n return this.usedSet.has(t);\n }\n /**\n * Evicts unused items until the cache is within its min size and byte limits.\n * Items are sorted by `unloadPriorityCallback` before eviction.\n */\n // TODO: this should be renamed because it's not necessarily unloading all unused content\n // Maybe call it \"cleanup\" or \"unloadToMinSize\"\n unloadUnusedContent() {\n const {\n unloadPercent: t,\n minSize: a,\n maxSize: e,\n itemList: s,\n itemSet: o,\n usedSet: i,\n loadedSet: c,\n callbacks: d,\n bytesMap: u,\n minBytesSize: h,\n maxBytesSize: y\n } = this, b = s.length - i.size, B = s.length - c.size, S = Math.max(Math.min(s.length - a, b), 0), k = this.cachedBytes - h, M = this.unloadPriorityCallback || this.defaultPriorityCallback;\n let f = !1;\n const P = S > 0 && b > 0 || B && s.length > e;\n if (b && this.cachedBytes > h || B && this.cachedBytes > y || P) {\n s.sort((n, r) => {\n const U = i.has(n), L = i.has(r);\n if (U === L) {\n const x = c.has(n), v = c.has(r);\n return x === v ? -M(n, r) : x ? 1 : -1;\n } else\n return U ? 1 : -1;\n });\n const A = Math.max(a * t, S * t), p = Math.ceil(Math.min(A, b, S)), E = Math.max(t * k, t * h), w = Math.min(E, k);\n let l = 0, m = 0;\n for (; this.cachedBytes - m > y || s.length - l > e; ) {\n const n = s[l], r = u.get(n) || 0;\n if (i.has(n) && c.has(n) || this.cachedBytes - m - r < y && s.length - l <= e)\n break;\n m += r, l++;\n }\n for (; m < w || l < p; ) {\n const n = s[l], r = u.get(n) || 0;\n if (i.has(n) || this.cachedBytes - m - r < h && l >= p)\n break;\n m += r, l++;\n }\n s.splice(0, l).forEach((n) => {\n this.cachedBytes -= u.get(n) || 0, d.get(n)(n), u.delete(n), o.delete(n), d.delete(n), c.delete(n), i.delete(n);\n }), f = l < S || m < k && l < b, f = f && l > 0;\n }\n f && (this.unloadingHandle = requestAnimationFrame(() => this.scheduleUnload()));\n }\n /**\n * Schedules `unloadUnusedContent` to run asynchronously via microtask.\n */\n scheduleUnload() {\n cancelAnimationFrame(this.unloadingHandle), this.scheduled || (this.scheduled = !0, queueMicrotask(() => {\n this.scheduled = !1, this.unloadUnusedContent();\n }));\n }\n}\nclass C extends Error {\n constructor() {\n super(\"PriorityQueue: Item removed\"), this.name = \"PriorityQueueItemRemovedError\";\n }\n}\nclass G {\n // returns whether tasks are queued or actively running\n get running() {\n return this.items.length !== 0 || this.currJobs !== 0;\n }\n constructor() {\n this.maxJobs = 6, this.items = [], this.callbacks = /* @__PURE__ */ new Map(), this.currJobs = 0, this.scheduled = !1, this.autoUpdate = !0, this.priorityCallback = null, this.schedulingCallback = (t) => {\n requestAnimationFrame(t);\n }, this._runjobs = () => {\n this.scheduled = !1, this.tryRunJobs();\n };\n }\n /**\n * Sorts the pending item list using `priorityCallback`, if set.\n */\n sort() {\n const t = this.priorityCallback, a = this.items;\n t !== null && a.sort(t);\n }\n /**\n * Returns whether the given item is currently queued.\n * @param {any} item\n * @returns {boolean}\n */\n has(t) {\n return this.callbacks.has(t);\n }\n /**\n * Adds an item to the queue and returns a Promise that resolves when the item's\n * callback completes, or rejects if the item is removed before running.\n * @param {any} item\n * @param {ItemCallback} callback - Invoked with `item` when it is dequeued; may return a Promise\n * @returns {Promise<any>}\n */\n add(t, a) {\n const e = {\n callback: a,\n reject: null,\n resolve: null,\n promise: null\n };\n return e.promise = new Promise((s, o) => {\n const i = this.items, c = this.callbacks;\n e.resolve = s, e.reject = o, i.unshift(t), c.set(t, e), this.autoUpdate && this.scheduleJobRun();\n }), e.promise;\n }\n /**\n * Removes an item from the queue, rejecting its promise with `PriorityQueueItemRemovedError`.\n * @param {any} item\n */\n remove(t) {\n const a = this.items, e = this.callbacks, s = a.indexOf(t);\n if (s !== -1) {\n const o = e.get(t);\n o.promise.catch((i) => {\n if (!(i instanceof C))\n throw i;\n }), o.reject(new C()), a.splice(s, 1), e.delete(t);\n }\n }\n /**\n * Removes all queued items for which `filter` returns true.\n * @param {FilterCallback} filter - Called with each item; return true to remove\n */\n removeByFilter(t) {\n const { items: a } = this;\n for (let e = 0; e < a.length; e++) {\n const s = a[e];\n t(s) && (this.remove(s), e--);\n }\n }\n /**\n * Immediately attempts to dequeue and run pending jobs up to `maxJobs` concurrency.\n */\n tryRunJobs() {\n this.sort();\n const t = this.items, a = this.callbacks, e = this.maxJobs;\n let s = 0;\n const o = () => {\n this.currJobs--, this.autoUpdate && this.scheduleJobRun();\n };\n for (; e > this.currJobs && t.length > 0 && s < e; ) {\n this.currJobs++, s++;\n const i = t.pop(), { callback: c, resolve: d, reject: u } = a.get(i);\n a.delete(i);\n let h;\n try {\n h = c(i);\n } catch (y) {\n u(y), o();\n }\n h instanceof Promise ? h.then(d).catch(u).finally(o) : (d(h), o());\n }\n }\n /**\n * Schedules a deferred call to `tryRunJobs` via `schedulingCallback`.\n */\n scheduleJobRun() {\n this.scheduled || (this.schedulingCallback(this._runjobs), this.scheduled = !0);\n }\n}\nconst J = -1, I = 0, R = 1, _ = 2, D = 3, F = 4, N = 6378137, j = 1 / 298.257223563, Q = 6356752314245179e-9;\nexport {\n J as F,\n F as L,\n D as P,\n R as Q,\n I as U,\n j as W,\n _ as a,\n z as b,\n G as c,\n C as d,\n Q as e,\n N as f\n};\n//# sourceMappingURL=constants-D7SEibTb.js.map\n","import {\n\tBufferGeometry,\n\tFloat32BufferAttribute,\n\tOrthographicCamera,\n\tMesh\n} from 'three';\n\n/**\n * Abstract base class for all post processing passes.\n *\n * This module is only relevant for post processing with {@link WebGLRenderer}.\n *\n * @abstract\n * @three_import import { Pass } from 'three/addons/postprocessing/Pass.js';\n */\nclass Pass {\n\n\t/**\n\t * Constructs a new pass.\n\t */\n\tconstructor() {\n\n\t\t/**\n\t\t * This flag can be used for type testing.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @readonly\n\t\t * @default true\n\t\t */\n\t\tthis.isPass = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass is processed by the composer.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.enabled = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass indicates to swap read and write buffer after rendering.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.needsSwap = true;\n\n\t\t/**\n\t\t * If set to `true`, the pass clears its buffer before rendering\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.clear = false;\n\n\t\t/**\n\t\t * If set to `true`, the result of the pass is rendered to screen. The last pass in the composers\n\t\t * pass chain gets automatically rendered to screen, no matter how this property is configured.\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.renderToScreen = false;\n\n\t}\n\n\t/**\n\t * Sets the size of the pass.\n\t *\n\t * @abstract\n\t * @param {number} width - The width to set.\n\t * @param {number} height - The height to set.\n\t */\n\tsetSize( /* width, height */ ) {}\n\n\t/**\n\t * This method holds the render logic of a pass. It must be implemented in all derived classes.\n\t *\n\t * @abstract\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t * @param {WebGLRenderTarget} writeBuffer - The write buffer. This buffer is intended as the rendering\n\t * destination for the pass.\n\t * @param {WebGLRenderTarget} readBuffer - The read buffer. The pass can access the result from the\n\t * previous pass from this buffer.\n\t * @param {number} deltaTime - The delta time in seconds.\n\t * @param {boolean} maskActive - Whether masking is active or not.\n\t */\n\trender( /* renderer, writeBuffer, readBuffer, deltaTime, maskActive */ ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the pass is no longer used in your app.\n\t *\n\t * @abstract\n\t */\n\tdispose() {}\n\n}\n\n// Helper for passes that need to fill the viewport with a single quad.\n\nconst _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\n// https://github.com/mrdoob/three.js/pull/21358\n\nclass FullscreenTriangleGeometry extends BufferGeometry {\n\n\tconstructor() {\n\n\t\tsuper();\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( [ - 1, 3, 0, - 1, - 1, 0, 3, - 1, 0 ], 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( [ 0, 2, 0, 0, 2, 0 ], 2 ) );\n\n\t}\n\n}\n\nconst _geometry = new FullscreenTriangleGeometry();\n\n\n/**\n * This module is a helper for passes which need to render a full\n * screen effect which is quite common in context of post processing.\n *\n * The intended usage is to reuse a single full screen quad for rendering\n * subsequent passes by just reassigning the `material` reference.\n *\n * This module can only be used with {@link WebGLRenderer}.\n *\n * @augments Mesh\n * @three_import import { FullScreenQuad } from 'three/addons/postprocessing/Pass.js';\n */\nclass FullScreenQuad {\n\n\t/**\n\t * Constructs a new full screen quad.\n\t *\n\t * @param {?Material} material - The material to render te full screen quad with.\n\t */\n\tconstructor( material ) {\n\n\t\tthis._mesh = new Mesh( _geometry, material );\n\n\t}\n\n\t/**\n\t * Frees the GPU-related resources allocated by this instance. Call this\n\t * method whenever the instance is no longer used in your app.\n\t */\n\tdispose() {\n\n\t\tthis._mesh.geometry.dispose();\n\n\t}\n\n\t/**\n\t * Renders the full screen quad.\n\t *\n\t * @param {WebGLRenderer} renderer - The renderer.\n\t */\n\trender( renderer ) {\n\n\t\trenderer.render( this._mesh, _camera );\n\n\t}\n\n\t/**\n\t * The quad's material.\n\t *\n\t * @type {?Material}\n\t */\n\tget material() {\n\n\t\treturn this._mesh.material;\n\n\t}\n\n\tset material( value ) {\n\n\t\tthis._mesh.material = value;\n\n\t}\n\n}\n\nexport { Pass, FullScreenQuad };\n","import { Q as Wn, b as jn, C as Xn, G as Yn } from \"./QuantizedMeshLoaderBase-Cn33qyYc.js\";\nimport { PlaneGeometry as nn, Mesh as Se, MeshBasicMaterial as _e, Vector2 as X, MathUtils as _, Vector3 as L, Sphere as pe, Texture as $n, SRGBColorSpace as jt, TextureUtils as Qn, DefaultLoadingManager as Zn, BufferGeometry as Ve, MeshStandardMaterial as rn, BufferAttribute as $, DataTexture as Xt, RGFormat as on, UnsignedByteType as an, LinearMipMapLinearFilter as Jn, LinearFilter as ln, Triangle as Yt, Vector4 as ke, Matrix4 as K, Matrix3 as Kn, Matrix2 as ei, WebGLRenderer as ti, WebGLRenderTarget as ns, ShaderMaterial as si, OneFactor as ni, ZeroFactor as ii, CustomBlending as ri, Box2 as oi, FileLoader as ai, Quaternion as cn, BatchedMesh as li, Source as ci, Box3 as pt, REVISION as ui, WebGLArrayRenderTarget as is, Raycaster as hi, DoubleSide as rt, CanvasTexture as $t, Color as un, Ray as di, LineSegments as hn, LineBasicMaterial as pi, EdgesGeometry as fi, BoxGeometry as dn, Group as We, Box3Helper as mi, SphereGeometry as gi, PointsMaterial as yi } from \"three\";\nimport { a as pn, c as xi, W as Ti, g as bi, O as _i, b as fn } from \"./MemoryUtils-C4SM4ZNH.js\";\nimport { GLTFLoader as Si } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { FullScreenQuad as mn } from \"three/examples/jsm/postprocessing/Pass.js\";\nimport { b as Mi, c as Ci, d as Ai, f as gn } from \"./constants-D7SEibTb.js\";\nimport { c as Ii, L as yn } from \"./LoaderBase-ATuDWTDB.js\";\nconst me = /* @__PURE__ */ new X(), Te = Symbol(\"TILE_X\"), be = Symbol(\"TILE_Y\"), le = Symbol(\"TILE_LEVEL\");\nclass xn {\n get tiling() {\n return this.imageSource.tiling;\n }\n constructor(e = {}) {\n const {\n pixelSize: t = null,\n center: s = !1,\n useRecommendedSettings: n = !0,\n imageSource: i = null\n } = e;\n this.priority = -10, this.tiles = null, this.imageSource = i, this.pixelSize = t, this.center = s, this.useRecommendedSettings = n, t !== null && console.warn('ImageFormatPlugin: \"pixelSize\" has been deprecated in favor of scaling the tiles root.');\n }\n // Plugin functions\n init(e) {\n this.useRecommendedSettings && (e.errorTarget = 1), this.tiles = e, this.imageSource.fetchOptions = e.fetchOptions, this.imageSource.fetchData = (t, s) => (e.invokeAllPlugins((n) => t = n.preprocessURL ? n.preprocessURL(t, null) : t), e.invokeOnePlugin((n) => n !== this && n.fetchData && n.fetchData(t, s)));\n }\n async loadRootTileset() {\n const { tiles: e, imageSource: t } = this;\n return t.url = t.url || e.rootURL, e.invokeAllPlugins((s) => t.url = s.preprocessURL ? s.preprocessURL(t.url, null) : t.url), await t.init(), e.rootURL = t.url, this.getTileset(t.url);\n }\n async parseToMesh(e, t, s, n, i) {\n if (i.aborted)\n return null;\n const { imageSource: r } = this, o = t[Te], l = t[be], c = t[le], u = await r.processBufferToTexture(e);\n if (i.aborted)\n return u.dispose(), u.image.close(), null;\n r.setData(o, l, c, u);\n let h = 1, d = 1, m = 0, f = 0, p = 0;\n const g = t.boundingVolume.box;\n g && ([m, f, p] = g, h = g[3], d = g[7]);\n const y = new nn(2 * h, 2 * d), x = new Se(y, new _e({ map: u, transparent: !0 }));\n x.position.set(m, f, p);\n const T = r.tiling.getTileContentUVBounds(o, l, c), { uv: M } = y.attributes;\n for (let S = 0; S < M.count; S++)\n me.fromBufferAttribute(M, S), me.x = _.mapLinear(me.x, 0, 1, T[0], T[2]), me.y = _.mapLinear(me.y, 0, 1, T[1], T[3]), M.setXY(S, me.x, me.y);\n return x;\n }\n preprocessNode(e) {\n const { tiling: t } = this, s = t.maxLevel;\n e[le] < s && e.parent !== null && this.expandChildren(e);\n }\n disposeTile(e) {\n const t = e[Te], s = e[be], n = e[le], { imageSource: i } = this;\n i.has(t, s, n) && i.release(t, s, n);\n }\n // Local functions\n getTileset(e) {\n const { tiling: t, tiles: s } = this, n = t.minLevel, { tileCountX: i, tileCountY: r } = t.getLevel(n), o = [];\n for (let c = 0; c < i; c++)\n for (let u = 0; u < r; u++) {\n const h = this.createChild(c, u, n);\n h !== null && o.push(h);\n }\n const l = {\n asset: {\n version: \"1.1\"\n },\n geometricError: 1e5,\n root: {\n refine: \"REPLACE\",\n geometricError: 1e5,\n boundingVolume: this.createBoundingVolume(0, 0, -1),\n children: o,\n [le]: -1,\n [Te]: 0,\n [be]: 0\n }\n };\n return s.preprocessTileset(l, e), l;\n }\n getUrl(e, t, s) {\n return this.imageSource.getUrl(e, t, s);\n }\n createBoundingVolume(e, t, s) {\n const { center: n, pixelSize: i, tiling: r } = this, { pixelWidth: o, pixelHeight: l } = r.getLevel(r.maxLevel), [c, u, h, d] = s === -1 ? r.getContentBounds(!0) : r.getTileBounds(e, t, s, !0);\n let m = (h - c) / 2, f = (d - u) / 2, p = c + m, g = u + f;\n return n && (p -= 0.5, g -= 0.5), i ? (p *= o * i, m *= o * i, g *= l * i, f *= l * i) : (p *= r.aspectRatio, m *= r.aspectRatio), {\n box: [\n // center\n p,\n g,\n 0,\n // x, y, z half vectors\n m,\n 0,\n 0,\n 0,\n f,\n 0,\n 0,\n 0,\n 0\n ]\n };\n }\n createChild(e, t, s) {\n const { pixelSize: n, tiling: i } = this;\n if (!i.getTileExists(e, t, s))\n return null;\n const { pixelWidth: r, pixelHeight: o } = i.getLevel(s);\n let l = Math.max(i.aspectRatio / r, 1 / o);\n if (n) {\n const c = i.getLevel(i.maxLevel);\n l *= n * Math.max(c.pixelWidth, c.pixelHeight);\n }\n return {\n refine: \"REPLACE\",\n geometricError: l,\n boundingVolume: this.createBoundingVolume(e, t, s),\n content: {\n uri: this.getUrl(e, t, s)\n },\n children: [],\n // save the tile params so we can expand later\n [Te]: e,\n [be]: t,\n [le]: s\n };\n }\n expandChildren(e) {\n const t = e[le], s = e[Te], n = e[be], { tileSplitX: i, tileSplitY: r } = this.tiling.getLevel(t);\n for (let o = 0; o < i; o++)\n for (let l = 0; l < r; l++) {\n const c = this.createChild(i * s + o, r * n + l, t + 1);\n c && e.children.push(c);\n }\n }\n}\nconst xt = /* @__PURE__ */ new L(), je = /* @__PURE__ */ new L();\nfunction vi(a, e, t) {\n const n = t + 1e-5;\n let i = e + 1e-5;\n Math.abs(i) > Math.PI / 2 && (i = i - 1e-5), a.getCartographicToPosition(e, t, 0, xt), a.getCartographicToPosition(i, t, 0, je);\n const r = xt.distanceTo(je) / 1e-5;\n return a.getCartographicToPosition(e, n, 0, je), [xt.distanceTo(je) / 1e-5, r];\n}\nconst Li = 30, Ei = 15, Tt = /* @__PURE__ */ new L(), rs = /* @__PURE__ */ new L(), ie = /* @__PURE__ */ new X(), bt = /* @__PURE__ */ new pe();\nclass ft extends xn {\n get projection() {\n return this.tiling.projection;\n }\n constructor(e = {}) {\n const {\n shape: t = \"planar\",\n endCaps: s = !0,\n ...n\n } = e;\n super(n), this.shape = t, this.endCaps = s;\n }\n // override the parse to mesh logic to support a region mesh\n async parseToMesh(e, t, ...s) {\n const n = await super.parseToMesh(e, t, ...s), { shape: i, projection: r, tiles: o, tiling: l } = this;\n if (i === \"ellipsoid\") {\n const c = o.ellipsoid, u = t[le], h = t[Te], d = t[be], [m, f, p, g] = t.boundingVolume.region, y = Math.ceil((g - f) * _.RAD2DEG * 0.25), x = Math.ceil((p - m) * _.RAD2DEG * 0.25), b = Math.max(Ei, y), T = Math.max(Li, x), M = new nn(1, 1, T, b), [S, C, v, P] = l.getTileBounds(h, d, u, !0, !0), R = l.getTileContentUVBounds(h, d, u), { position: V, normal: k, uv: W } = M.attributes, Q = V.count;\n t.engineData.boundingVolume.getSphere(bt);\n for (let H = 0; H < Q; H++) {\n Tt.fromBufferAttribute(V, H), ie.fromBufferAttribute(W, H);\n const I = r.convertNormalizedToLongitude(_.mapLinear(ie.x, 0, 1, S, v));\n let A = r.convertNormalizedToLatitude(_.mapLinear(ie.y, 0, 1, C, P));\n if (r.isMercator && this.endCaps && (P === 1 && ie.y === 1 && (A = Math.PI / 2), C === 0 && ie.y === 0 && (A = -Math.PI / 2)), r.isMercator && ie.y !== 0 && ie.y !== 1) {\n const E = r.convertNormalizedToLatitude(1), N = 1 / b, Z = _.mapLinear(ie.y - N, 0, 1, f, g), F = _.mapLinear(ie.y + N, 0, 1, f, g);\n A > E && Z < E && (A = E), A < -E && F > -E && (A = -E);\n }\n c.getCartographicToPosition(A, I, 0, Tt).sub(bt.center), c.getCartographicToNormal(A, I, rs);\n const D = _.mapLinear(r.convertLongitudeToNormalized(I), S, v, R[0], R[2]), O = _.mapLinear(r.convertLatitudeToNormalized(A), C, P, R[1], R[3]);\n W.setXY(H, D, O), V.setXYZ(H, ...Tt), k.setXYZ(H, ...rs);\n }\n n.geometry = M, n.position.copy(bt.center);\n }\n return n;\n }\n createBoundingVolume(e, t, s) {\n if (this.shape === \"ellipsoid\") {\n const { tiling: n, endCaps: i } = this, r = s === -1, o = r ? n.getContentBounds(!0) : n.getTileBounds(e, t, s, !0, !0), l = r ? n.getContentBounds() : n.getTileBounds(e, t, s, !1, !0);\n return i && (o[3] === 1 && (l[3] = Math.PI / 2), o[1] === 0 && (l[1] = -Math.PI / 2)), {\n region: [...l, -1, 1]\n };\n } else\n return super.createBoundingVolume(e, t, s);\n }\n createChild(...e) {\n const t = super.createChild(...e), { shape: s, projection: n, tiling: i } = this;\n if (t && s === \"ellipsoid\") {\n const r = t[le], o = t[Te], l = t[be];\n if (r === -1)\n return t.geometricError = 1e50, parent;\n const [c, u, h, d] = i.getTileBounds(o, l, r, !0), { tilePixelWidth: m, tilePixelHeight: f } = i.getLevel(r), p = (h - c) / m, g = (d - u) / f, [\n /* west */\n ,\n y,\n x,\n b\n ] = i.getTileBounds(o, l, r), T = y > 0 != b > 0 ? 0 : Math.min(Math.abs(y), Math.abs(b)), M = n.convertLatitudeToNormalized(T), S = n.getLongitudeDerivativeAtNormalized(c), C = n.getLatitudeDerivativeAtNormalized(M), [v, P] = vi(this.tiles.ellipsoid, T, x), R = Math.max(p * S * v, g * C * P);\n t.geometricError = R;\n }\n return t;\n }\n}\nclass re {\n get isMercator() {\n return this.scheme === \"EPSG:3857\";\n }\n constructor(e = \"EPSG:4326\") {\n this.scheme = e, this.tileCountX = 1, this.tileCountY = 1, this.setScheme(e);\n }\n setScheme(e) {\n switch (this.scheme = e, e) {\n // equirect\n case \"CRS:84\":\n case \"EPSG:4326\":\n this.tileCountX = 2, this.tileCountY = 1;\n break;\n // mercator\n case \"EPSG:3857\":\n this.tileCountX = 1, this.tileCountY = 1;\n break;\n case \"none\":\n this.tileCountX = 1, this.tileCountY = 1;\n break;\n default:\n throw new Error(`ProjectionScheme: Unknown projection scheme \"${e}\"`);\n }\n }\n convertNormalizedToLatitude(e) {\n if (this.scheme === \"none\")\n return e;\n if (this.isMercator) {\n const t = _.mapLinear(e, 0, 1, -1, 1);\n return 2 * Math.atan(Math.exp(t * Math.PI)) - Math.PI / 2;\n } else\n return _.mapLinear(e, 0, 1, -Math.PI / 2, Math.PI / 2);\n }\n convertNormalizedToLongitude(e) {\n return this.scheme === \"none\" ? e : _.mapLinear(e, 0, 1, -Math.PI, Math.PI);\n }\n convertLatitudeToNormalized(e) {\n if (this.scheme === \"none\")\n return e;\n if (this.isMercator) {\n const t = Math.log(Math.tan(Math.PI / 4 + e / 2));\n return 1 / 2 + 1 * t / (2 * Math.PI);\n } else\n return _.mapLinear(e, -Math.PI / 2, Math.PI / 2, 0, 1);\n }\n convertLongitudeToNormalized(e) {\n return this.scheme === \"none\" ? e : (e + Math.PI) / (2 * Math.PI);\n }\n getLongitudeDerivativeAtNormalized(e) {\n return this.scheme === \"none\" ? 1 : 2 * Math.PI;\n }\n getLatitudeDerivativeAtNormalized(e) {\n if (this.scheme === \"none\")\n return 1;\n {\n let s = e - 1e-5;\n return s < 0 && (s = e + 1e-5), this.isMercator ? Math.abs(this.convertNormalizedToLatitude(e) - this.convertNormalizedToLatitude(s)) / 1e-5 : Math.PI;\n }\n }\n getBounds() {\n return this.scheme === \"none\" ? [0, 0, 1, 1] : [\n this.convertNormalizedToLongitude(0),\n this.convertNormalizedToLatitude(0),\n this.convertNormalizedToLongitude(1),\n this.convertNormalizedToLatitude(1)\n ];\n }\n toNormalizedPoint(e, t) {\n const s = [e, t];\n return s[0] = this.convertLongitudeToNormalized(s[0]), s[1] = this.convertLatitudeToNormalized(s[1]), s;\n }\n toNormalizedRange(e) {\n return [\n ...this.toNormalizedPoint(e[0], e[1]),\n ...this.toNormalizedPoint(e[2], e[3])\n ];\n }\n toCartographicPoint(e, t) {\n const s = [e, t];\n return s[0] = this.convertNormalizedToLongitude(s[0]), s[1] = this.convertNormalizedToLatitude(s[1]), s;\n }\n toCartographicRange(e) {\n return [\n ...this.toCartographicPoint(e[0], e[1]),\n ...this.toCartographicPoint(e[2], e[3])\n ];\n }\n clampToBounds(e, t = !1) {\n const s = [...e];\n let n;\n t ? n = [0, 0, 1, 1] : n = this.getBounds();\n const [i, r, o, l] = n;\n return s[0] = _.clamp(s[0], i, o), s[1] = _.clamp(s[1], r, l), s[2] = _.clamp(s[2], i, o), s[3] = _.clamp(s[3], r, l), s;\n }\n}\nfunction Ee(...a) {\n return a.join(\"_\");\n}\nclass Tn {\n constructor() {\n this.cache = {}, this.count = 0, this.cachedBytes = 0, this.active = 0;\n }\n // overridable\n fetchItem() {\n }\n disposeItem() {\n }\n getMemoryUsage(e) {\n return 0;\n }\n // sets the data in the cache explicitly without need to load\n setData(...e) {\n const { cache: t } = this, s = e.pop(), n = Ee(...e);\n if (n in t)\n throw new Error(`DataCache: \"${n}\" is already present.`);\n return this.cache[n] = {\n abortController: new AbortController(),\n result: s,\n count: 1,\n bytes: this.getMemoryUsage(s)\n }, this.count++, this.cachedBytes += this.cache[n].bytes, s;\n }\n // fetches the associated data if it doesn't exist and increments the lock counter\n lock(...e) {\n const { cache: t } = this, s = Ee(...e);\n if (s in t)\n t[s].count++;\n else {\n const n = new AbortController(), i = {\n abortController: n,\n result: null,\n count: 1,\n bytes: 0,\n args: e\n };\n this.active++, i.result = this.fetchItem(e, n.signal), i.result instanceof Promise ? i.result.then((r) => (i.result = r, i.bytes = this.getMemoryUsage(r), this.cachedBytes += i.bytes, r)).finally(() => {\n this.active--;\n }).catch((r) => {\n }) : (this.active--, i.bytes = this.getMemoryUsage(i.result), this.cachedBytes += i.bytes), this.cache[s] = i, this.count++;\n }\n return t[s].result;\n }\n // decrements the lock counter for the item and deletes the item if it has reached zero\n release(...e) {\n const t = Ee(...e);\n this.releaseViaFullKey(t);\n }\n // get the loaded item\n get(...e) {\n const { cache: t } = this, s = Ee(...e);\n return s in t && t[s].count > 0 ? t[s].result : null;\n }\n has(...e) {\n const { cache: t } = this;\n return Ee(...e) in t;\n }\n forEachItem(e) {\n const { cache: t } = this;\n for (const s in t) {\n const n = t[s];\n n.result instanceof Promise || e(n.result, n.args);\n }\n }\n // dispose all items\n dispose() {\n const { cache: e } = this;\n for (const t in e) {\n const { abortController: s } = e[t];\n s.abort(), this.releaseViaFullKey(t, !0);\n }\n this.cache = {};\n }\n // releases an item with an optional force flag\n releaseViaFullKey(e, t = !1) {\n const { cache: s } = this;\n if (e in s && s[e].count > 0) {\n const n = s[e];\n if (n.count--, n.count === 0 || t) {\n const i = () => {\n if (s[e] !== n)\n return;\n const { result: r, abortController: o } = n;\n o.abort(), r instanceof Promise ? r.then((l) => {\n this.disposeItem(l), this.count--, this.cachedBytes -= n.bytes;\n }).catch(() => {\n }) : (this.disposeItem(r), this.count--, this.cachedBytes -= n.bytes), delete s[e];\n };\n t ? i() : queueMicrotask(() => {\n n.count === 0 && i();\n });\n }\n return !0;\n }\n throw new Error(\"DataCache: Attempting to release key that does not exist\");\n }\n}\nfunction os(a, e) {\n const [t, s, n, i] = a, [r, o, l, c] = e;\n return !(t >= l || n <= r || s >= c || i <= o);\n}\nclass bn {\n get levelCount() {\n return this._levels.length;\n }\n get maxLevel() {\n return this.levelCount - 1;\n }\n get minLevel() {\n const e = this._levels;\n for (let t = 0; t < e.length; t++)\n if (e[t] !== null)\n return t;\n return -1;\n }\n // prioritize user-set bounds over projection bounds if present\n get contentBounds() {\n return this._contentBounds ?? this.projection.getBounds();\n }\n get aspectRatio() {\n const { pixelWidth: e, pixelHeight: t } = this.getLevel(this.maxLevel);\n return e / t;\n }\n constructor() {\n this.flipY = !1, this.pixelOverlap = 0, this._contentBounds = null, this.projection = new re(\"none\"), this._levels = [];\n }\n // build the zoom levels\n setLevel(e, t = {}) {\n const s = this._levels;\n for (; s.length < e; )\n s.push(null);\n const {\n tileSplitX: n = 2,\n tileSplitY: i = 2\n } = t, {\n tilePixelWidth: r = 256,\n tilePixelHeight: o = 256,\n tileCountX: l = n ** e,\n tileCountY: c = i ** e,\n tileBounds: u = null\n } = t, {\n pixelWidth: h = r * l,\n pixelHeight: d = o * c\n } = t;\n s[e] = {\n // The pixel resolution of each tile.\n tilePixelWidth: r,\n tilePixelHeight: o,\n // The total pixel resolution of the final image at this level. These numbers\n // may not be a round multiple of the tile width.\n pixelWidth: h,\n pixelHeight: d,\n // Or the total number of tiles that can be loaded at this level.\n tileCountX: l,\n tileCountY: c,\n // The number of tiles that the tiles at this layer split in to\n tileSplitX: n,\n tileSplitY: i,\n // The bounds covered by the extent of the tiles at this loaded. The actual content covered by the overall tileset\n // may be a subset of this range (eg there may be unused space).\n tileBounds: u\n };\n }\n generateLevels(e, t, s, n = {}) {\n const {\n minLevel: i = 0,\n tilePixelWidth: r = 256,\n tilePixelHeight: o = 256\n } = n, l = e - 1, {\n pixelWidth: c = r * t * 2 ** l,\n pixelHeight: u = o * s * 2 ** l\n } = n;\n for (let h = i; h < e; h++) {\n const d = e - h - 1, m = Math.ceil(c * 2 ** -d), f = Math.ceil(u * 2 ** -d), p = Math.ceil(m / r), g = Math.ceil(f / o);\n this.setLevel(h, {\n tilePixelWidth: r,\n tilePixelHeight: o,\n pixelWidth: m,\n pixelHeight: f,\n tileCountX: p,\n tileCountY: g\n });\n }\n }\n getLevel(e) {\n return this._levels[e];\n }\n // bounds representing the contentful region of the image\n setContentBounds(e, t, s, n) {\n this._contentBounds = [e, t, s, n];\n }\n setProjection(e) {\n this.projection = e;\n }\n // query functions\n getTileAtPoint(e, t, s, n = !1) {\n const { flipY: i } = this, { tileCountX: r, tileCountY: o, tileBounds: l } = this.getLevel(s), c = 1 / r, u = 1 / o;\n if (n || ([e, t] = this.toNormalizedPoint(e, t)), l) {\n const m = this.toNormalizedRange(l);\n e = _.mapLinear(e, m[0], m[2], 0, 1), t = _.mapLinear(t, m[1], m[3], 0, 1);\n }\n const h = Math.floor(e / c);\n let d = Math.floor(t / u);\n return i && (d = o - 1 - d), [h, d];\n }\n getTilesInRange(e, t, s, n, i, r = !1) {\n const o = [e, t, s, n], l = this.getContentBounds(r);\n let c = this.getLevel(i).tileBounds;\n if (!os(o, l))\n return [0, 0, -1, -1];\n if (c && (r && (c = this.toNormalizedRange(c)), !os(o, l)))\n return [0, 0, -1, -1];\n const [u, h, d, m] = this.clampToContentBounds(o, r), f = this.getTileAtPoint(u, h, i, r), p = this.getTileAtPoint(d, m, i, r);\n this.flipY && ([f[1], p[1]] = [p[1], f[1]]);\n const { tileCountX: g, tileCountY: y } = this.getLevel(i), [x, b] = f, [T, M] = p;\n return T < 0 || M < 0 || x >= g || b >= y ? [0, 0, -1, -1] : [\n _.clamp(x, 0, g - 1),\n _.clamp(b, 0, y - 1),\n _.clamp(T, 0, g - 1),\n _.clamp(M, 0, y - 1)\n ];\n }\n getTileExists(e, t, s) {\n const [n, i, r, o] = this.contentBounds, [l, c, u, h] = this.getTileBounds(e, t, s);\n return !(l >= u || c >= h) && l <= r && c <= o && u >= n && h >= i;\n }\n getContentBounds(e = !1) {\n const { projection: t } = this, s = [...this.contentBounds];\n return e && (s[0] = t.convertLongitudeToNormalized(s[0]), s[1] = t.convertLatitudeToNormalized(s[1]), s[2] = t.convertLongitudeToNormalized(s[2]), s[3] = t.convertLatitudeToNormalized(s[3])), s;\n }\n // returns the UV range associated with the content in the given tile\n getTileContentUVBounds(e, t, s) {\n const [n, i, r, o] = this.getTileBounds(e, t, s, !0, !0), [l, c, u, h] = this.getTileBounds(e, t, s, !0, !1);\n return [\n _.mapLinear(n, l, u, 0, 1),\n _.mapLinear(i, c, h, 0, 1),\n _.mapLinear(r, l, u, 0, 1),\n _.mapLinear(o, c, h, 0, 1)\n ];\n }\n getTileBounds(e, t, s, n = !1, i = !0) {\n const { flipY: r, pixelOverlap: o, projection: l } = this, { tilePixelWidth: c, tilePixelHeight: u, pixelWidth: h, pixelHeight: d, tileBounds: m } = this.getLevel(s);\n let f = c * e - o, p = u * t - o, g = f + c + o * 2, y = p + u + o * 2;\n if (f = Math.max(f, 0), p = Math.max(p, 0), g = Math.min(g, h), y = Math.min(y, d), f = f / h, g = g / h, p = p / d, y = y / d, r) {\n const b = (y - p) / 2, M = 1 - (p + y) / 2;\n p = M - b, y = M + b;\n }\n let x = [f, p, g, y];\n if (m) {\n const b = this.toNormalizedRange(m);\n x[0] = _.mapLinear(x[0], 0, 1, b[0], b[2]), x[2] = _.mapLinear(x[2], 0, 1, b[0], b[2]), x[1] = _.mapLinear(x[1], 0, 1, b[1], b[3]), x[3] = _.mapLinear(x[3], 0, 1, b[1], b[3]);\n }\n return i && (x = this.clampToBounds(x, !0)), n || (x[0] = l.convertNormalizedToLongitude(x[0]), x[1] = l.convertNormalizedToLatitude(x[1]), x[2] = l.convertNormalizedToLongitude(x[2]), x[3] = l.convertNormalizedToLatitude(x[3])), x;\n }\n toNormalizedPoint(e, t) {\n return this.projection.toNormalizedPoint(e, t);\n }\n toNormalizedRange(e) {\n return this.projection.toNormalizedRange(e);\n }\n toCartographicPoint(e, t) {\n return this.projection.toCartographicPoint(e, t);\n }\n toCartographicRange(e) {\n return this.projection.toCartographicRange(e);\n }\n clampToContentBounds(e, t = !1) {\n const s = [...e], [n, i, r, o] = this.getContentBounds(t);\n return s[0] = _.clamp(s[0], n, r), s[1] = _.clamp(s[1], i, o), s[2] = _.clamp(s[2], n, r), s[3] = _.clamp(s[3], i, o), s;\n }\n clampToBounds(e, t = !1) {\n return this.projection.clampToBounds(e, t);\n }\n}\nclass Ge extends Tn {\n constructor(e = {}) {\n super();\n const {\n fetchOptions: t = {}\n } = e;\n this.tiling = new bn(), this.fetchOptions = t, this.fetchData = (...s) => fetch(...s);\n }\n // async function for initializing the tiled image set\n init() {\n }\n // helper for processing the buffer into a texture\n async processBufferToTexture(e) {\n const t = new Blob([e]), s = await createImageBitmap(t, {\n premultiplyAlpha: \"none\",\n colorSpaceConversion: \"none\",\n imageOrientation: \"flipY\"\n }), n = new $n(s);\n return n.generateMipmaps = !1, n.colorSpace = jt, n.needsUpdate = !0, n;\n }\n getMemoryUsage(e) {\n const { format: t, type: s, image: n, generateMipmaps: i } = e, { width: r, height: o } = n, l = Qn.getByteLength(r, o, t, s);\n return i ? l * 4 / 3 : l;\n }\n // fetch the item with the given key fields\n fetchItem(e, t) {\n const s = {\n ...this.fetchOptions,\n signal: t\n }, n = this.getUrl(...e);\n return this.fetchData(n, s).then((i) => i.arrayBuffer()).then((i) => this.processBufferToTexture(i));\n }\n // dispose of the item that was fetched\n disposeItem(e) {\n e.dispose(), e.image instanceof ImageBitmap && e.image.close();\n }\n getUrl(...e) {\n }\n}\nclass ze extends Ge {\n constructor(e = {}) {\n const {\n levels: t = 20,\n tileDimension: s = 256,\n projection: n = \"EPSG:3857\",\n url: i = null,\n ...r\n } = e;\n super(r), this.tileDimension = s, this.levels = t, this.projection = n, this.url = i;\n }\n getUrl(e, t, s) {\n return this.url.replace(/{\\s*z\\s*}/gi, s).replace(/{\\s*x\\s*}/gi, e).replace(/{\\s*(y|reverseY|-\\s*y)\\s*}/gi, t);\n }\n init() {\n const { tiling: e, tileDimension: t, levels: s, url: n, projection: i } = this;\n return e.flipY = !/{\\s*reverseY|-\\s*y\\s*}/g.test(n), e.setProjection(new re(i)), e.setContentBounds(...e.projection.getBounds()), Array.isArray(s) ? s.forEach((r, o) => {\n r !== null && e.setLevel(o, {\n tilePixelWidth: t,\n tilePixelHeight: t,\n ...r\n });\n }) : e.generateLevels(s, e.projection.tileCountX, e.projection.tileCountY, {\n tilePixelWidth: t,\n tilePixelHeight: t\n }), this.url = n, Promise.resolve();\n }\n}\nclass Qt extends Ge {\n constructor(e = {}) {\n const {\n url: t = null,\n ...s\n } = e;\n super(s), this.tileSets = null, this.extension = null, this.url = t;\n }\n getUrl(e, t, s) {\n const { url: n, extension: i, tileSets: r, tiling: o } = this;\n return new URL(`${parseInt(r[s - o.minLevel].href)}/${e}/${t}.${i}`, n).toString();\n }\n init() {\n const { url: e } = this;\n return this.fetchData(new URL(\"tilemapresource.xml\", e), this.fetchOptions).then((t) => t.text()).then((t) => {\n const { tiling: s } = this, n = new DOMParser().parseFromString(t, \"text/xml\"), i = n.querySelector(\"BoundingBox\"), r = n.querySelector(\"TileFormat\"), l = [...n.querySelector(\"TileSets\").querySelectorAll(\"TileSet\")].map((y) => ({\n href: parseInt(y.getAttribute(\"href\")),\n unitsPerPixel: parseFloat(y.getAttribute(\"units-per-pixel\")),\n order: parseInt(y.getAttribute(\"order\"))\n })).sort((y, x) => y.order - x.order), c = parseFloat(i.getAttribute(\"minx\")) * _.DEG2RAD, u = parseFloat(i.getAttribute(\"maxx\")) * _.DEG2RAD, h = parseFloat(i.getAttribute(\"miny\")) * _.DEG2RAD, d = parseFloat(i.getAttribute(\"maxy\")) * _.DEG2RAD, m = parseInt(r.getAttribute(\"width\")), f = parseInt(r.getAttribute(\"height\")), p = r.getAttribute(\"extension\"), g = n.querySelector(\"SRS\").textContent;\n this.extension = p, this.url = e, this.tileSets = l, s.setProjection(new re(g)), s.setContentBounds(c, h, u, d), l.forEach(({ order: y }) => {\n s.setLevel(y, {\n tileCountX: s.projection.tileCountX * 2 ** y,\n tilePixelWidth: m,\n tilePixelHeight: f\n });\n });\n });\n }\n}\nfunction wi(a) {\n return /(:84|:crs84)$/i.test(a);\n}\nclass _n extends Ge {\n /**\n * Creates a new WMTSImageSource instance.\n *\n * @param {Object} [options={}] - Configuration options\n * @param {Object} [options.capabilities=null] - Parsed WMTS capabilities object from WMTSCapabilitiesLoader\n * @param {string|Object} [options.layer=null] - Layer identifier string or layer object. If null, uses first available layer.\n * @param {string|Object} [options.tileMatrixSet=null] - TileMatrixSet identifier or object. If null, uses first available.\n * @param {string} [options.style=null] - Style identifier. If null, uses the default style.\n * @param {string} [options.url=null] - Custom URL template. If null, extracted from capabilities.\n * @param {Object} [options.dimensions={}] - Dimension values (e.g., { Time: '2023-01-01' })\n */\n constructor(e = {}) {\n const {\n capabilities: t = null,\n layer: s = null,\n tileMatrixSet: n = null,\n style: i = null,\n url: r = null,\n dimensions: o = {},\n ...l\n } = e;\n super(l), this.capabilities = t, this.layer = s, this.tileMatrixSet = n, this.style = i, this.dimensions = o, this.url = r;\n }\n /**\n * Generates the URL for a specific tile.\n *\n * @param {number} x - Tile column index\n * @param {number} y - Tile row index\n * @param {number} level - Zoom level (TileMatrix)\n * @returns {string} The complete URL for the requested tile\n */\n getUrl(e, t, s) {\n return this.url.replace(/{\\s*TileMatrix\\s*}/gi, s).replace(/{\\s*TileCol\\s*}/gi, e).replace(/{\\s*TileRow\\s*}/gi, t);\n }\n /**\n * Initializes the image source by parsing capabilities and setting up the tiling scheme.\n *\n * This method:\n * - Resolves layer, tileMatrixSet, and style from capabilities\n * - Determines the projection (EPSG:4326 or EPSG:3857)\n * - Configures the tiling scheme with proper bounds and tile sizes\n * - Constructs the final URL template\n *\n * @returns {Promise<void>} Resolves when initialization is complete\n */\n init() {\n const { tiling: e, dimensions: t, capabilities: s } = this;\n let { layer: n, tileMatrixSet: i, style: r, url: o } = this;\n n ? typeof n == \"string\" && (n = s.layers.find((u) => u.identifier === n)) : n = s.layers[0], i ? typeof i == \"string\" && (i = n.tileMatrixSets.find((u) => u.identifier === i)) : i = n.tileMatrixSets[0], r || (r = n.styles.find((u) => u.isDefault).identifier), o || (o = n.resourceUrls[0].template);\n const l = i.supportedCRS, c = l.includes(\"4326\") || wi(l) ? \"EPSG:4326\" : \"EPSG:3857\";\n e.flipY = !0, e.setProjection(new re(c)), n.boundingBox !== null ? e.setContentBounds(...n.boundingBox.bounds) : e.setContentBounds(...e.projection.getBounds()), i.tileMatrices.forEach((u, h) => {\n const { tileWidth: d, tileHeight: m, matrixWidth: f, matrixHeight: p } = u;\n e.setLevel(h, {\n tilePixelWidth: d,\n tilePixelHeight: m,\n tileCountX: f || e.projection.tileCountX * 2 ** h,\n tileCountY: p || e.projection.tileCountY * 2 ** h,\n tileBounds: u.bounds\n });\n }), o = o.replace(/{\\s*TileMatrixSet\\s*}/g, i.identifier).replace(/{\\s*Style\\s*}/g, r);\n for (const u in t)\n o = o.replace(new RegExp(`{\\\\s*${u}\\\\s*}`), t[u]);\n return n.dimensions.forEach((u) => {\n o = o.replace(new RegExp(`{\\\\s*${u.identifier}\\\\s*}`), u.defaultValue);\n }), this.url = o, Promise.resolve();\n }\n}\nclass Sn extends Ge {\n // TODO: layer and styles can be arrays, comma separated lists\n constructor(e = {}) {\n const {\n url: t = null,\n layer: s = null,\n styles: n = null,\n contentBoundingBox: i = null,\n version: r = \"1.3.0\",\n crs: o = \"EPSG:4326\",\n format: l = \"image/png\",\n transparent: c = !1,\n levels: u = 18,\n tileDimension: h = 256,\n ...d\n } = e;\n super(d), this.url = t, this.layer = s, this.crs = o, this.format = l, this.tileDimension = h, this.styles = n, this.version = r, this.levels = u, this.transparent = c, this.contentBoundingBox = i;\n }\n init() {\n const { tiling: e, levels: t, tileDimension: s, contentBoundingBox: n } = this;\n return e.setProjection(new re(this.crs)), e.flipY = !0, e.generateLevels(t, e.projection.tileCountX, e.projection.tileCountY, {\n tilePixelWidth: s,\n tilePixelHeight: s\n }), n !== null ? e.setContentBounds(...n) : e.setContentBounds(...e.projection.getBounds()), Promise.resolve();\n }\n // TODO: handle this in ProjectionScheme or TilingScheme? Or Loader?\n normalizedToMercatorX(e) {\n return _.mapLinear(e, 0, 1, -20037508342789244e-9, 20037508342789244e-9);\n }\n normalizedToMercatorY(e) {\n return _.mapLinear(e, 0, 1, -20037508342789244e-9, 20037508342789244e-9);\n }\n getUrl(e, t, s) {\n const {\n tiling: n,\n layer: i,\n crs: r,\n format: o,\n tileDimension: l,\n styles: c,\n version: u,\n transparent: h\n } = this, d = u === \"1.1.1\" ? \"SRS\" : \"CRS\";\n let m;\n if (r === \"EPSG:3857\") {\n const p = n.getTileBounds(e, t, s, !0, !1), g = this.normalizedToMercatorX(p[0]), y = this.normalizedToMercatorY(p[1]), x = this.normalizedToMercatorX(p[2]), b = this.normalizedToMercatorY(p[3]);\n m = [g, y, x, b];\n } else {\n const [p, g, y, x] = n.getTileBounds(e, t, s, !1, !1).map((b) => b * _.RAD2DEG);\n r === \"EPSG:4326\" ? u === \"1.1.1\" ? m = [p, g, y, x] : m = [g, p, x, y] : m = [p, g, y, x];\n }\n const f = new URLSearchParams({\n SERVICE: \"WMS\",\n REQUEST: \"GetMap\",\n VERSION: u,\n LAYERS: i,\n [d]: r,\n BBOX: m.join(\",\"),\n WIDTH: l,\n HEIGHT: l,\n FORMAT: o,\n TRANSPARENT: h ? \"TRUE\" : \"FALSE\"\n });\n return c != null && f.set(\"STYLES\", c), new URL(\"?\" + f.toString(), this.url).toString();\n }\n}\nclass lo extends ft {\n constructor(e = {}) {\n const {\n levels: t,\n tileDimension: s,\n projection: n,\n url: i,\n ...r\n } = e;\n super(r), this.name = \"XYZ_TILES_PLUGIN\", this.imageSource = new ze({ url: i, levels: t, tileDimension: s, projection: n });\n }\n}\nclass Pi extends ft {\n constructor(e = {}) {\n const { url: t, ...s } = e;\n super(s), this.name = \"TMS_TILES_PLUGIN\", this.imageSource = new Qt({ url: t });\n }\n}\nclass co extends ft {\n constructor(e = {}) {\n const {\n capabilities: t,\n layer: s,\n tileMatrixSet: n,\n style: i,\n dimensions: r,\n ...o\n } = e;\n super(o), this.name = \"WTMS_TILES_PLUGIN\", this.imageSource = new _n({\n capabilities: t,\n layer: s,\n tileMatrixSet: n,\n style: i,\n dimensions: r\n });\n }\n}\nclass uo extends ft {\n constructor(e = {}) {\n const {\n url: t,\n layer: s,\n crs: n,\n format: i,\n tileDimension: r,\n styles: o,\n version: l,\n ...c\n } = e;\n super(c), this.name = \"WMS_TILES_PLUGIN\", this.imageSource = new Sn({\n url: t,\n layer: s,\n crs: n,\n format: i,\n tileDimension: r,\n styles: o,\n version: l\n });\n }\n}\nconst as = /* @__PURE__ */ new L(), Xe = /* @__PURE__ */ new Yt(), U = /* @__PURE__ */ new L(), oe = /* @__PURE__ */ new L();\nclass Ri extends Wn {\n constructor(e = Zn) {\n super(), this.manager = e, this.ellipsoid = new pn(), this.skirtLength = 1e3, this.smoothSkirtNormals = !0, this.generateNormals = !0, this.solid = !1, this.minLat = -Math.PI / 2, this.maxLat = Math.PI / 2, this.minLon = -Math.PI, this.maxLon = Math.PI;\n }\n parse(e) {\n const {\n ellipsoid: t,\n solid: s,\n skirtLength: n,\n smoothSkirtNormals: i,\n generateNormals: r,\n minLat: o,\n maxLat: l,\n minLon: c,\n maxLon: u\n } = this, {\n header: h,\n indices: d,\n vertexData: m,\n edgeIndices: f,\n extensions: p\n } = super.parse(e), g = new Ve(), y = new rn(), x = new Se(g, y);\n x.position.set(...h.center);\n const b = \"octvertexnormals\" in p, T = b || r, M = m.u.length, S = [], C = [], v = [], P = [];\n let R = 0, V = 0;\n for (let I = 0; I < M; I++)\n W(I, U), Q(U.x, U.y, U.z, oe), C.push(U.x, U.y), S.push(...oe);\n for (let I = 0, A = d.length; I < A; I++)\n v.push(d[I]);\n if (T)\n if (b) {\n const I = p.octvertexnormals.normals;\n for (let A = 0, D = I.length; A < D; A++)\n P.push(I[A]);\n } else {\n const I = new Ve(), A = d.length > 21845 ? new Uint32Array(d) : new Uint16Array(d);\n I.setIndex(new $(A, 1, !1)), I.setAttribute(\"position\", new $(new Float32Array(S), 3, !1)), I.computeVertexNormals();\n const O = I.getAttribute(\"normal\").array;\n p.octvertexnormals = { normals: O };\n for (let E = 0, N = O.length; E < N; E++)\n P.push(O[E]);\n }\n if (g.addGroup(R, d.length, V), R += d.length, V++, s) {\n const I = S.length / 3;\n for (let A = 0; A < M; A++)\n W(A, U), Q(U.x, U.y, U.z, oe, -n), C.push(U.x, U.y), S.push(...oe);\n for (let A = d.length - 1; A >= 0; A--)\n v.push(d[A] + I);\n if (T) {\n const A = p.octvertexnormals.normals;\n for (let D = 0, O = A.length; D < O; D++)\n P.push(-A[D]);\n }\n g.addGroup(R, d.length, V), R += d.length, V++;\n }\n if (n > 0) {\n const {\n westIndices: I,\n eastIndices: A,\n southIndices: D,\n northIndices: O\n } = f;\n let E;\n const N = H(I);\n E = S.length / 3, C.push(...N.uv), S.push(...N.positions);\n for (let B = 0, J = N.indices.length; B < J; B++)\n v.push(N.indices[B] + E);\n const Z = H(A);\n E = S.length / 3, C.push(...Z.uv), S.push(...Z.positions);\n for (let B = 0, J = Z.indices.length; B < J; B++)\n v.push(Z.indices[B] + E);\n const F = H(D);\n E = S.length / 3, C.push(...F.uv), S.push(...F.positions);\n for (let B = 0, J = F.indices.length; B < J; B++)\n v.push(F.indices[B] + E);\n const G = H(O);\n E = S.length / 3, C.push(...G.uv), S.push(...G.positions);\n for (let B = 0, J = G.indices.length; B < J; B++)\n v.push(G.indices[B] + E);\n T && (P.push(...N.normals), P.push(...Z.normals), P.push(...F.normals), P.push(...G.normals)), g.addGroup(R, d.length, V), R += d.length, V++;\n }\n for (let I = 0, A = S.length; I < A; I += 3)\n S[I + 0] -= h.center[0], S[I + 1] -= h.center[1], S[I + 2] -= h.center[2];\n const k = S.length / 3 > 65535 ? new Uint32Array(v) : new Uint16Array(v);\n if (g.setIndex(new $(k, 1, !1)), g.setAttribute(\"position\", new $(new Float32Array(S), 3, !1)), g.setAttribute(\"uv\", new $(new Float32Array(C), 2, !1)), T && g.setAttribute(\"normal\", new $(new Float32Array(P), 3, !1)), \"watermask\" in p) {\n const { mask: I, size: A } = p.watermask, D = new Uint8Array(2 * A * A);\n for (let E = 0, N = I.length; E < N; E++) {\n const Z = I[E] === 255 ? 0 : 255;\n D[2 * E + 0] = Z, D[2 * E + 1] = Z;\n }\n const O = new Xt(D, A, A, on, an);\n O.flipY = !0, O.minFilter = Jn, O.magFilter = ln, O.needsUpdate = !0, y.roughnessMap = O;\n }\n return x.userData.minHeight = h.minHeight, x.userData.maxHeight = h.maxHeight, \"metadata\" in p && (x.userData.metadata = p.metadata.json), x;\n function W(I, A) {\n return A.x = m.u[I], A.y = m.v[I], A.z = m.height[I], A;\n }\n function Q(I, A, D, O, E = 0) {\n const N = _.lerp(h.minHeight, h.maxHeight, D), Z = _.lerp(c, u, I), F = _.lerp(o, l, A);\n return t.getCartographicToPosition(F, Z, N + E, O), O;\n }\n function H(I) {\n const A = [], D = [], O = [], E = [], N = [];\n for (let G = 0, B = I.length; G < B; G++)\n W(I[G], U), A.push(U.x, U.y), O.push(U.x, U.y), Q(U.x, U.y, U.z, oe), D.push(...oe), Q(U.x, U.y, U.z, oe, -n), E.push(...oe);\n const Z = I.length - 1;\n for (let G = 0; G < Z; G++) {\n const B = G, J = G + 1, fe = G + I.length, gt = G + I.length + 1;\n N.push(B, fe, J), N.push(J, fe, gt);\n }\n let F = null;\n if (T) {\n const G = (D.length + E.length) / 3;\n if (i) {\n F = new Array(G * 3);\n const B = p.octvertexnormals.normals, J = F.length / 2;\n for (let fe = 0, gt = G / 2; fe < gt; fe++) {\n const yt = I[fe], Me = 3 * fe, es = B[3 * yt + 0], ts = B[3 * yt + 1], ss = B[3 * yt + 2];\n F[Me + 0] = es, F[Me + 1] = ts, F[Me + 2] = ss, F[J + Me + 0] = es, F[J + Me + 1] = ts, F[J + Me + 2] = ss;\n }\n } else {\n F = [], Xe.a.fromArray(D, 0), Xe.b.fromArray(E, 0), Xe.c.fromArray(D, 3), Xe.getNormal(as);\n for (let B = 0; B < G; B++)\n F.push(...as);\n }\n }\n return {\n uv: [...A, ...O],\n positions: [...D, ...E],\n indices: N,\n normals: F\n };\n }\n }\n}\nconst z = 0, ue = [\"a\", \"b\", \"c\"], w = /* @__PURE__ */ new ke(), ls = /* @__PURE__ */ new ke(), cs = /* @__PURE__ */ new ke(), us = /* @__PURE__ */ new ke();\nclass Mn {\n constructor() {\n this.attributeList = null, this.splitOperations = [], this.trianglePool = new Di();\n }\n forEachSplitPermutation(e) {\n const { splitOperations: t } = this, s = (n = 0) => {\n if (n >= t.length) {\n e();\n return;\n }\n t[n].keepPositive = !0, s(n + 1), t[n].keepPositive = !1, s(n + 1);\n };\n s();\n }\n // Takes an operation that returns a value for the given vertex passed to the callback. Triangles\n // are clipped along edges where the interpolated value is equal to 0. The polygons on the positive\n // side of the operation are kept if \"keepPositive\" is true.\n // callback( geometry, i0, i1, i2, barycoord );\n addSplitOperation(e, t = !0) {\n this.splitOperations.push({\n callback: e,\n keepPositive: t\n });\n }\n // Removes all split operations\n clearSplitOperations() {\n this.splitOperations.length = 0;\n }\n // clips an object hierarchy\n clipObject(e) {\n const t = e.clone(), s = [];\n return t.traverse((n) => {\n n.isMesh && (n.geometry = this.clip(n).geometry, (n.geometry.index ? n.geometry.index.count / 3 : n.attributes.position.count / 3) === 0 && s.push(n));\n }), s.forEach((n) => {\n n.removeFromParent();\n }), t;\n }\n // Returns a new mesh that has been clipped by the split operations. Range indicates the range of\n // elements to include when clipping.\n clip(e, t = null) {\n const s = this.getClippedData(e, t);\n return this.constructMesh(s.attributes, s.index, e);\n }\n // Appends the clip operation data to the given \"target\" object so multiple ranges can be appended.\n // The \"target\" object is returned with an \"index\" field, \"vertexIsClipped\" field, and series of arrays\n // in \"attributes\".\n // attributes - set of attribute arrays\n // index - triangle indices referencing vertices in attributes\n // vertexIsClipped - array indicating whether a vertex is on a clipped edge\n getClippedData(e, t = null, s = {}) {\n const { trianglePool: n, splitOperations: i, attributeList: r } = this, o = e.geometry, l = o.attributes.position, c = o.index;\n let u = 0;\n const h = {};\n s.index = s.index || [], s.vertexIsClipped = s.vertexIsClipped || [], s.attributes = s.attributes || {};\n for (const p in o.attributes) {\n if (r !== null) {\n if (r instanceof Function && !r(p))\n continue;\n if (Array.isArray(r) && !r.includes(p))\n continue;\n }\n s.attributes[p] = [];\n }\n let d = 0, m = c ? c.count : l.count;\n t !== null && (d = t.start, m = t.count);\n for (let p = d, g = d + m; p < g; p += 3) {\n let y = p + 0, x = p + 1, b = p + 2;\n c && (y = c.getX(y), x = c.getX(x), b = c.getX(b));\n const T = n.get();\n T.initFromIndices(y, x, b);\n let M = [T];\n for (let S = 0; S < i.length; S++) {\n const { keepPositive: C, callback: v } = i[S], P = [];\n for (let R = 0; R < M.length; R++) {\n const V = M[R], { indices: k, barycoord: W } = V;\n V.clipValues.a = v(o, k.a, k.b, k.c, W.a, e.matrixWorld), V.clipValues.b = v(o, k.a, k.b, k.c, W.b, e.matrixWorld), V.clipValues.c = v(o, k.a, k.b, k.c, W.c, e.matrixWorld), this.splitTriangle(V, !C, P);\n }\n M = P;\n }\n for (let S = 0, C = M.length; S < C; S++) {\n const v = M[S];\n f(v, o);\n }\n n.reset();\n }\n return s;\n function f(p, g) {\n for (let y = 0; y < 3; y++) {\n const x = p.getVertexHash(y, g);\n x in h || (h[x] = u, u++, p.getVertexData(y, g, s.attributes), s.vertexIsClipped.push(p.clipValues[ue[y]] === z));\n const b = h[x];\n s.index.push(b);\n }\n }\n }\n // Takes the set of resultant data and constructs a mesh\n constructMesh(e, t, s) {\n const n = s.geometry, i = new Ve(), r = e.position.length / 3 > 65535 ? new Uint32Array(t) : new Uint16Array(t);\n i.setIndex(new $(r, 1, !1));\n for (const l in e) {\n const c = n.getAttribute(l), u = new c.array.constructor(e[l]), h = new $(u, c.itemSize, c.normalized);\n h.gpuType = c.gpuType, i.setAttribute(l, h);\n }\n const o = new Se(i, s.material.clone());\n return o.position.copy(s.position), o.quaternion.copy(s.quaternion), o.scale.copy(s.scale), o;\n }\n // Splits the given triangle\n splitTriangle(e, t, s) {\n const { trianglePool: n } = this, i = [], r = [], o = [];\n for (let l = 0; l < 3; l++) {\n const c = ue[l], u = ue[(l + 1) % 3], h = e.clipValues[c], d = e.clipValues[u];\n (h < z != d < z || h === z) && (i.push(l), r.push([c, u]), h === d ? o.push(0) : o.push(_.mapLinear(z, h, d, 0, 1)));\n }\n if (i.length !== 2)\n Math.min(\n e.clipValues.a,\n e.clipValues.b,\n e.clipValues.c\n ) < z === t && s.push(e);\n else if (i.length === 2) {\n const l = n.get().initFromTriangle(e), c = n.get().initFromTriangle(e), u = n.get().initFromTriangle(e);\n (i[0] + 1) % 3 === i[1] ? (l.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), l.copyVertex(e, r[0][1], \"b\"), l.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"c\"), l.clipValues.a = z, l.clipValues.c = z, c.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), c.copyVertex(e, r[1][1], \"b\"), c.copyVertex(e, r[0][0], \"c\"), c.clipValues.a = z, u.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), u.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"b\"), u.copyVertex(e, r[1][1], \"c\"), u.clipValues.a = z, u.clipValues.b = z) : (l.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), l.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"b\"), l.copyVertex(e, r[0][0], \"c\"), l.clipValues.a = z, l.clipValues.b = z, c.lerpVertexFromEdge(e, r[0][0], r[0][1], o[0], \"a\"), c.copyVertex(e, r[0][1], \"b\"), c.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"c\"), c.clipValues.a = z, c.clipValues.c = z, u.copyVertex(e, r[0][1], \"a\"), u.copyVertex(e, r[1][0], \"b\"), u.lerpVertexFromEdge(e, r[1][0], r[1][1], o[1], \"c\"), u.clipValues.c = z);\n let d, m;\n d = Math.min(l.clipValues.a, l.clipValues.b, l.clipValues.c), m = d < z, m === t && s.push(l), d = Math.min(c.clipValues.a, c.clipValues.b, c.clipValues.c), m = d < z, m === t && s.push(c), d = Math.min(u.clipValues.a, u.clipValues.b, u.clipValues.c), m = d < z, m === t && s.push(u);\n }\n }\n}\nclass Di {\n constructor() {\n this.pool = [], this.index = 0;\n }\n get() {\n if (this.index >= this.pool.length) {\n const t = new Bi();\n this.pool.push(t);\n }\n const e = this.pool[this.index];\n return this.index++, e;\n }\n reset() {\n this.index = 0;\n }\n}\nclass Bi {\n constructor() {\n this.indices = {\n a: -1,\n b: -1,\n c: -1\n }, this.clipValues = {\n a: -1,\n b: -1,\n c: -1\n }, this.barycoord = new Yt();\n }\n // returns a hash for the given [0, 2] index based on attributes of the referenced geometry\n getVertexHash(e, t) {\n const { barycoord: s, indices: n } = this, i = ue[e], r = s[i];\n if (r.x === 1)\n return n[ue[0]];\n if (r.y === 1)\n return n[ue[1]];\n if (r.z === 1)\n return n[ue[2]];\n {\n const { attributes: o } = t;\n let l = \"\";\n for (const c in o) {\n const u = o[c];\n switch (hs(u, n.a, n.b, n.c, r, w), (c === \"normal\" || c === \"tangent\" || c === \"bitangent\") && w.normalize(), u.itemSize) {\n case 4:\n l += Be(w.x, w.y, w.z, w.w);\n break;\n case 3:\n l += Be(w.x, w.y, w.z);\n break;\n case 2:\n l += Be(w.x, w.y);\n break;\n case 1:\n l += Be(w.x);\n break;\n }\n l += \"|\";\n }\n return l;\n }\n }\n // Accumulate the vertex data in the given attribute arrays\n getVertexData(e, t, s) {\n const { barycoord: n, indices: i } = this, r = ue[e], o = n[r], { attributes: l } = t;\n for (const c in l) {\n if (!s[c])\n continue;\n const u = l[c], h = s[c];\n switch (hs(u, i.a, i.b, i.c, o, w), (c === \"normal\" || c === \"tangent\" || c === \"bitangent\") && w.normalize(), u.itemSize) {\n case 4:\n h.push(w.x, w.y, w.z, w.w);\n break;\n case 3:\n h.push(w.x, w.y, w.z);\n break;\n case 2:\n h.push(w.x, w.y);\n break;\n case 1:\n h.push(w.x);\n break;\n }\n }\n }\n // Copy the indices from a target triangle\n initFromTriangle(e) {\n return this.initFromIndices(\n e.indices.a,\n e.indices.b,\n e.indices.c\n );\n }\n // Set the indices for the given\n initFromIndices(e, t, s) {\n return this.indices.a = e, this.indices.b = t, this.indices.c = s, this.clipValues.a = -1, this.clipValues.b = -1, this.clipValues.c = -1, this.barycoord.a.set(1, 0, 0), this.barycoord.b.set(0, 1, 0), this.barycoord.c.set(0, 0, 1), this;\n }\n // Lerp the given vertex along to the provided edge of the provided triangle\n lerpVertexFromEdge(e, t, s, n, i) {\n this.clipValues[i] = _.lerp(e.clipValues[t], e.clipValues[s], n), this.barycoord[i].lerpVectors(e.barycoord[t], e.barycoord[s], n);\n }\n // Copy a vertex from the provided triangle\n copyVertex(e, t, s) {\n this.clipValues[s] = e.clipValues[t], this.barycoord[s].copy(e.barycoord[t]);\n }\n}\nfunction hs(a, e, t, s, n, i) {\n switch (ls.fromBufferAttribute(a, e), cs.fromBufferAttribute(a, t), us.fromBufferAttribute(a, s), i.set(0, 0, 0, 0).addScaledVector(ls, n.x).addScaledVector(cs, n.y).addScaledVector(us, n.z), a.itemSize) {\n case 3:\n w.w = 0;\n break;\n case 2:\n w.w = 0, w.z = 0;\n break;\n case 1:\n w.w = 0, w.z = 0, w.y = 0;\n break;\n }\n return i;\n}\nfunction Be(...a) {\n let s = \"\";\n for (let n = 0, i = a.length; n < i; n++)\n s += ~~(a[n] * 1e5 + 0.5), n !== i - 1 && (s += \"_\");\n return s;\n}\nconst ds = {}, Oi = /* @__PURE__ */ new L(), _t = /* @__PURE__ */ new L(), St = /* @__PURE__ */ new L(), Ui = /* @__PURE__ */ new L(), Ni = /* @__PURE__ */ new L(), Y = /* @__PURE__ */ new L(), Ce = /* @__PURE__ */ new L(), j = /* @__PURE__ */ new X(), ce = /* @__PURE__ */ new X(), ps = /* @__PURE__ */ new X();\nclass Vi extends Mn {\n constructor() {\n super(), this.ellipsoid = new pn(), this.skirtLength = 1e3, this.smoothSkirtNormals = !0, this.solid = !1, this.minLat = -Math.PI / 2, this.maxLat = Math.PI / 2, this.minLon = -Math.PI, this.maxLon = Math.PI, this.attributeList = [\"position\", \"normal\", \"uv\"];\n }\n clipToQuadrant(e, t, s) {\n const { solid: n, skirtLength: i, ellipsoid: r, smoothSkirtNormals: o } = this;\n this.clearSplitOperations(), this.addSplitOperation(fs(\"x\"), !t), this.addSplitOperation(fs(\"y\"), !s);\n let l, c;\n const u = e.geometry.groups[0], h = this.getClippedData(e, u);\n if (this.adjustVertices(h, e.position, 0), n) {\n l = {\n index: h.index.slice().reverse(),\n attributes: {}\n };\n for (const M in h.attributes)\n l.attributes[M] = h.attributes[M].slice();\n const T = l.attributes.normal;\n if (T)\n for (let M = 0; M < T.length; M += 3)\n T[M + 0] *= -1, T[M + 1] *= -1, T[M + 2] *= -1;\n this.adjustVertices(l, e.position, -i);\n }\n if (i > 0) {\n c = {\n index: [],\n attributes: {\n position: [],\n normal: [],\n uv: []\n }\n };\n let T = 0;\n const M = {}, S = (k, W, Q) => {\n const H = Be(...k, ...Q, ...W);\n H in M || (M[H] = T, T++, c.attributes.position.push(...k), c.attributes.normal.push(...Q), c.attributes.uv.push(...W)), c.index.push(M[H]);\n }, C = h.index, v = h.attributes.uv, P = h.attributes.position, R = h.attributes.normal, V = h.index.length / 3;\n for (let k = 0; k < V; k++) {\n const W = 3 * k;\n for (let Q = 0; Q < 3; Q++) {\n const H = (Q + 1) % 3, I = C[W + Q], A = C[W + H];\n if (j.fromArray(v, I * 2), ce.fromArray(v, A * 2), j.x === ce.x && (j.x === 0 || j.x === 0.5 || j.x === 1) || j.y === ce.y && (j.y === 0 || j.y === 0.5 || j.y === 1)) {\n _t.fromArray(P, I * 3), St.fromArray(P, A * 3);\n const D = _t, O = St, E = Ui.copy(_t), N = Ni.copy(St);\n Y.copy(E).add(e.position), r.getPositionToNormal(Y, Y), E.addScaledVector(Y, -i), Y.copy(N).add(e.position), r.getPositionToNormal(Y, Y), N.addScaledVector(Y, -i), o && R ? (Y.fromArray(R, I * 3), Ce.fromArray(R, A * 3)) : (Y.subVectors(D, O), Ce.subVectors(D, E).cross(Y).normalize(), Y.copy(Ce)), S(O, ce, Ce), S(D, j, Y), S(E, j, Y), S(O, ce, Ce), S(E, j, Y), S(N, ce, Ce);\n }\n }\n }\n }\n const d = h.index.length, m = h;\n if (l) {\n const { index: T, attributes: M } = l, S = m.attributes.position.length / 3;\n for (let C = 0, v = T.length; C < v; C++)\n m.index.push(T[C] + S);\n for (const C in h.attributes)\n m.attributes[C].push(...M[C]);\n }\n if (c) {\n const { index: T, attributes: M } = c, S = m.attributes.position.length / 3;\n for (let C = 0, v = T.length; C < v; C++)\n m.index.push(T[C] + S);\n for (const C in h.attributes)\n m.attributes[C].push(...M[C]);\n }\n const f = t ? 0 : -0.5, p = s ? 0 : -0.5, g = m.attributes.uv;\n for (let T = 0, M = g.length; T < M; T += 2)\n g[T] = (g[T] + f) * 2, g[T + 1] = (g[T + 1] + p) * 2;\n const y = this.constructMesh(m.attributes, m.index, e);\n y.userData.minHeight = e.userData.minHeight, y.userData.maxHeight = e.userData.maxHeight;\n let x = 0, b = 0;\n return y.geometry.addGroup(b, d, x), b += d, x++, l && (y.geometry.addGroup(b, l.index.length, x), b += l.index.length, x++), c && (y.geometry.addGroup(b, c.index.length, x), b += c.index.length, x++), y;\n }\n adjustVertices(e, t, s) {\n const { ellipsoid: n, minLat: i, maxLat: r, minLon: o, maxLon: l } = this, { attributes: c, vertexIsClipped: u } = e, h = c.position, d = c.uv, m = h.length / 3;\n for (let f = 0; f < m; f++) {\n const p = j.fromArray(d, f * 2);\n u && u[f] && (Math.abs(p.x - 0.5) < 1e-10 && (p.x = 0.5), Math.abs(p.y - 0.5) < 1e-10 && (p.y = 0.5), j.toArray(d, f * 2));\n const g = _.lerp(i, r, p.y), y = _.lerp(o, l, p.x), x = Oi.fromArray(h, f * 3).add(t);\n n.getPositionToCartographic(x, ds), n.getCartographicToPosition(g, y, ds.height + s, x), x.sub(t), x.toArray(h, f * 3);\n }\n }\n}\nfunction fs(a) {\n return (e, t, s, n, i) => {\n const r = e.attributes.uv;\n return j.fromBufferAttribute(r, t), ce.fromBufferAttribute(r, s), ps.fromBufferAttribute(r, n), j[a] * i.x + ce[a] * i.y + ps[a] * i.z - 0.5;\n };\n}\nconst ms = Symbol(\"TILE_X\"), gs = Symbol(\"TILE_Y\"), Oe = Symbol(\"TILE_LEVEL\"), ge = Symbol(\"TILE_AVAILABLE\"), Mt = Symbol(\"TILE_SPLIT_SOURCE_SCENE\"), Ye = 1e4, ys = /* @__PURE__ */ new L();\nfunction Fi(a, e, t, s) {\n if (a && e < a.length) {\n const n = a[e];\n for (let i = 0, r = n.length; i < r; i++) {\n const { startX: o, startY: l, endX: c, endY: u } = n[i];\n if (t >= o && t <= c && s >= l && s <= u)\n return !0;\n }\n }\n return !1;\n}\nfunction Cn(a) {\n const { available: e = null, maxzoom: t = null } = a;\n return t === null ? e.length - 1 : t;\n}\nfunction ki(a) {\n const { metadataAvailability: e = -1 } = a;\n return e;\n}\nfunction Ct(a, e) {\n const t = a[Oe], s = ki(e), n = Cn(e);\n return t < n && s !== -1 && t % s === 0;\n}\nfunction Gi(a, e, t, s, n) {\n return n.tiles[0].replace(/{\\s*z\\s*}/g, t).replace(/{\\s*x\\s*}/g, a).replace(/{\\s*y\\s*}/g, e).replace(/{\\s*version\\s*}/g, s);\n}\nclass zi {\n constructor(e = {}) {\n const {\n useRecommendedSettings: t = !0,\n skirtLength: s = null,\n smoothSkirtNormals: n = !0,\n generateNormals: i = !0,\n solid: r = !1\n } = e;\n this.name = \"QUANTIZED_MESH_PLUGIN\", this.priority = -1e3, this.tiles = null, this.layer = null, this.useRecommendedSettings = t, this.skirtLength = s, this.smoothSkirtNormals = n, this.solid = r, this.generateNormals = i, this.attribution = null, this.tiling = new bn(), this.projection = new re();\n }\n // Plugin function\n init(e) {\n e.fetchOptions.headers = e.fetchOptions.headers || {}, e.fetchOptions.headers.Accept = \"application/vnd.quantized-mesh,application/octet-stream;q=0.9\", this.useRecommendedSettings && (e.errorTarget = 2), this.tiles = e;\n }\n loadRootTileset() {\n const { tiles: e } = this;\n let t = new URL(\"layer.json\", new URL(e.rootURL, location.href));\n return e.invokeAllPlugins((s) => t = s.preprocessURL ? s.preprocessURL(t, null) : t), e.invokeOnePlugin((s) => s.fetchData && s.fetchData(t, this.tiles.fetchOptions)).then((s) => s.json()).then((s) => {\n this.layer = s;\n const {\n projection: n = \"EPSG:4326\",\n extensions: i = [],\n attribution: r = \"\",\n available: o = null\n } = s, {\n tiling: l,\n tiles: c,\n projection: u\n } = this;\n r && (this.attribution = {\n value: r,\n type: \"string\",\n collapsible: !0\n }), i.length > 0 && (c.fetchOptions.headers.Accept += `;extensions=${i.join(\"-\")}`), u.setScheme(n);\n const { tileCountX: h, tileCountY: d } = u;\n l.setProjection(u), l.generateLevels(Cn(s) + 1, h, d);\n const m = [];\n for (let g = 0; g < h; g++) {\n const y = this.createChild(0, g, 0, o);\n y && m.push(y);\n }\n const f = {\n asset: {\n version: \"1.1\"\n },\n geometricError: 1 / 0,\n root: {\n refine: \"REPLACE\",\n geometricError: 1 / 0,\n boundingVolume: {\n region: [...this.tiling.getContentBounds(), -Ye, Ye]\n },\n children: m,\n [ge]: o,\n [Oe]: -1\n }\n };\n let p = c.rootURL;\n return c.invokeAllPlugins((g) => p = g.preprocessURL ? g.preprocessURL(p, null) : p), c.preprocessTileset(f, p), f;\n });\n }\n parseToMesh(e, t, s, n) {\n const {\n skirtLength: i,\n solid: r,\n smoothSkirtNormals: o,\n generateNormals: l,\n tiles: c\n } = this, u = c.ellipsoid;\n let h;\n if (s === \"quantized_tile_split\") {\n const p = new URL(n).searchParams, g = p.get(\"left\") === \"true\", y = p.get(\"bottom\") === \"true\", x = new Vi();\n x.ellipsoid.copy(u), x.solid = r, x.smoothSkirtNormals = o, x.skirtLength = i === null ? t.geometricError : i;\n const [b, T, M, S] = t.parent.boundingVolume.region;\n x.minLat = T, x.maxLat = S, x.minLon = b, x.maxLon = M;\n const C = t.parent.engineData.scene || t.parent[Mt];\n h = x.clipToQuadrant(C, g, y);\n } else if (s === \"terrain\") {\n const p = new Ri(c.manager);\n p.ellipsoid.copy(u), p.solid = r, p.smoothSkirtNormals = o, p.generateNormals = l, p.skirtLength = i === null ? t.geometricError : i;\n const [g, y, x, b] = t.boundingVolume.region;\n p.minLat = y, p.maxLat = b, p.minLon = g, p.maxLon = x, h = p.parse(e);\n } else\n return;\n const { minHeight: d, maxHeight: m, metadata: f } = h.userData;\n return t.boundingVolume.region[4] = d, t.boundingVolume.region[5] = m, t.engineData.boundingVolume.setRegionData(u, ...t.boundingVolume.region), f && (\"geometricerror\" in f && (t.geometricError = f.geometricerror), Ct(t, this.layer) && \"available\" in f && t.children.length === 0 && (t[ge] = [\n ...new Array(t[Oe] + 1).fill(null),\n ...f.available\n ])), t[Mt] = h, this.expandChildren(t), h;\n }\n getAttributions(e) {\n this.attribution && e.push(this.attribution);\n }\n // Local functions\n createChild(e, t, s, n) {\n const { tiles: i, layer: r, tiling: o, projection: l } = this, c = i.ellipsoid, u = n === null && e === 0 || Fi(n, e, t, s), h = Gi(t, s, e, 1, r), d = [...o.getTileBounds(t, s, e), -Ye, Ye], [\n /* west */\n ,\n m,\n /* east */\n ,\n f,\n /* minHeight */\n ,\n p\n ] = d, g = m > 0 != f > 0 ? 0 : Math.min(Math.abs(m), Math.abs(f));\n c.getCartographicToPosition(g, 0, p, ys), ys.z = 0;\n const y = l.tileCountX, T = Math.max(...c.radius) * 2 * Math.PI * 0.25 / (65 * y) / 2 ** e, M = {\n [ge]: null,\n [Oe]: e,\n [ms]: t,\n [gs]: s,\n refine: \"REPLACE\",\n geometricError: T,\n boundingVolume: { region: d },\n content: u ? { uri: h } : null,\n children: []\n };\n return Ct(M, r) || (M[ge] = n), M;\n }\n expandChildren(e) {\n const t = e[Oe], s = e[ms], n = e[gs], i = e[ge];\n if (t >= this.tiling.maxLevel)\n return;\n let r = !1;\n for (let o = 0; o < 2; o++)\n for (let l = 0; l < 2; l++) {\n const c = this.createChild(t + 1, 2 * s + o, 2 * n + l, i);\n c.content !== null ? (e.children.push(c), r = !0) : (c.content = { uri: `tile.quantized_tile_split?bottom=${l === 0}&left=${o === 0}` }, c.internal = { isVirtual: !0 }, e.internal.virtualChildCount++, e.children.push(c));\n }\n r || (e.children.length -= e.internal.virtualChildCount, e.internal.virtualChildCount = 0);\n }\n fetchData(e, t) {\n if (/quantized_tile_split/.test(e))\n return new ArrayBuffer();\n }\n disposeTile(e) {\n const { tiles: t, layer: s } = this;\n if (delete e[Mt], Ct(e, s) && (e[ge] = null), ge in e) {\n const { virtualChildCount: n } = e.internal, i = e.children.length, r = i - n;\n for (let o = r; o < i; o++)\n t.processNodeQueue.remove(e.children[o]);\n e.children.length = 0, e.internal.virtualChildCount = 0;\n }\n }\n}\nlet ho = class extends jn {\n constructor(e = {}) {\n super({\n assetTypeHandler: (t, s, n) => {\n t === \"TERRAIN\" && s.getPluginByName(\"QUANTIZED_MESH_PLUGIN\") === null ? (console.warn(\n 'CesiumIonAuthPlugin: CesiumIonAuthPlugin plugin auto-registration has been deprecated. Please implement a custom \"assetTypeHandler\" for \"TERRAIN\" using \"QuantizedMeshPlugin\", instead.'\n ), s.registerPlugin(new zi({\n useRecommendedSettings: this.useRecommendedSettings\n }))) : t === \"IMAGERY\" && s.getPluginByName(\"TMS_TILES_PLUGIN\") === null ? (console.warn(\n 'CesiumIonAuthPlugin: CesiumIonAuthPlugin plugin auto-registration has been deprecated. Please implement a custom \"assetTypeHandler\" for \"IMAGERY\" using \"TMSTilesPlugin\", instead.'\n ), s.registerPlugin(new Pi({\n useRecommendedSettings: this.useRecommendedSettings,\n shape: \"ellipsoid\"\n }))) : console.warn(`CesiumIonAuthPlugin: Cesium Ion asset type \"${t}\" unhandled.`);\n },\n ...e\n }), e.__suppress_warning__ && console.warn(\n 'CesiumIonAuthPlugin: Plugin has been moved to \"3d-tiles-renderer/core/plugins\".'\n );\n }\n};\nconst At = /* @__PURE__ */ new K();\nclass fo {\n constructor() {\n this.name = \"UPDATE_ON_CHANGE_PLUGIN\", this.tiles = null, this.needsUpdate = !1, this.cameraMatrices = /* @__PURE__ */ new Map();\n }\n init(e) {\n this.tiles = e, this._needsUpdateCallback = () => {\n this.needsUpdate = !0;\n }, this._onCameraAdd = ({ camera: t }) => {\n this.needsUpdate = !0, this.cameraMatrices.set(t, new K());\n }, this._onCameraDelete = ({ camera: t }) => {\n this.needsUpdate = !0, this.cameraMatrices.delete(t);\n }, e.addEventListener(\"needs-update\", this._needsUpdateCallback), e.addEventListener(\"add-camera\", this._onCameraAdd), e.addEventListener(\"delete-camera\", this._onCameraDelete), e.addEventListener(\"camera-resolution-change\", this._needsUpdateCallback), e.cameras.forEach((t) => {\n this._onCameraAdd({ camera: t });\n });\n }\n doTilesNeedUpdate() {\n const e = this.tiles;\n let t = !1;\n this.cameraMatrices.forEach((n, i) => {\n At.copy(e.group.matrixWorld).premultiply(i.matrixWorldInverse).premultiply(i.projectionMatrixInverse), t = t || !At.equals(n), n.copy(At);\n });\n const s = this.needsUpdate;\n return this.needsUpdate = !1, s || t;\n }\n preprocessNode() {\n this.needsUpdate = !0;\n }\n dispose() {\n const e = this.tiles;\n e.removeEventListener(\"camera-resolution-change\", this._needsUpdateCallback), e.removeEventListener(\"needs-update\", this._needsUpdateCallback), e.removeEventListener(\"add-camera\", this._onCameraAdd), e.removeEventListener(\"delete-camera\", this._onCameraDelete);\n }\n}\nconst xs = /* @__PURE__ */ new L();\nfunction we(a, e) {\n if (a.isInterleavedBufferAttribute || a.array instanceof e)\n return a;\n const s = e === Int8Array || e === Int16Array || e === Int32Array ? -1 : 0, n = new e(a.count * a.itemSize), i = new $(n, a.itemSize, !0), r = a.itemSize, o = a.count;\n for (let l = 0; l < o; l++)\n for (let c = 0; c < r; c++) {\n const u = _.clamp(a.getComponent(l, c), s, 1);\n i.setComponent(l, c, u);\n }\n return i;\n}\nfunction Hi(a, e = Int16Array) {\n const t = a.geometry, s = t.attributes, n = s.position;\n if (n.isInterleavedBufferAttribute || n.array instanceof e)\n return n;\n const i = new e(n.count * n.itemSize), r = new $(i, n.itemSize, !1), o = n.itemSize, l = n.count;\n t.computeBoundingBox();\n const c = t.boundingBox, { min: u, max: h } = c, d = 2 ** (8 * e.BYTES_PER_ELEMENT - 1) - 1, m = -d;\n for (let f = 0; f < l; f++)\n for (let p = 0; p < o; p++) {\n const g = p === 0 ? \"x\" : p === 1 ? \"y\" : \"z\", y = u[g], x = h[g], b = _.mapLinear(\n n.getComponent(f, p),\n y,\n x,\n m,\n d\n );\n r.setComponent(f, p, b);\n }\n c.getCenter(xs).multiply(a.scale).applyQuaternion(a.quaternion), a.position.add(xs), a.scale.x *= 0.5 * (h.x - u.x) / d, a.scale.y *= 0.5 * (h.y - u.y) / d, a.scale.z *= 0.5 * (h.z - u.z) / d, s.position = r, a.geometry.boundingBox = null, a.geometry.boundingSphere = null, a.updateMatrixWorld();\n}\nclass mo {\n constructor(e) {\n this._options = {\n // whether to generate normals if they don't already exist.\n generateNormals: !1,\n // whether to disable use of mipmaps since they are typically not necessary\n // with something like 3d tiles.\n disableMipmaps: !0,\n // whether to compress certain attributes\n compressIndex: !0,\n compressNormals: !1,\n compressUvs: !1,\n compressPosition: !1,\n // the TypedArray type to use when compressing the attributes\n uvType: Int8Array,\n normalType: Int8Array,\n positionType: Int16Array,\n ...e\n }, this.name = \"TILES_COMPRESSION_PLUGIN\", this.priority = -100;\n }\n processTileModel(e, t) {\n const {\n generateNormals: s,\n disableMipmaps: n,\n compressIndex: i,\n compressUvs: r,\n compressNormals: o,\n compressPosition: l,\n uvType: c,\n normalType: u,\n positionType: h\n } = this._options;\n e.traverse((d) => {\n if (d.material && n) {\n const m = d.material;\n for (const f in m) {\n const p = m[f];\n p && p.isTexture && p.generateMipmaps && (p.generateMipmaps = !1, p.minFilter = ln);\n }\n }\n if (d.geometry) {\n const m = d.geometry, f = m.attributes;\n if (r) {\n const { uv: p, uv1: g, uv2: y, uv3: x } = f;\n p && (f.uv = we(p, c)), g && (f.uv1 = we(g, c)), y && (f.uv2 = we(y, c)), x && (f.uv3 = we(x, c));\n }\n if (s && !f.normals && m.computeVertexNormals(), o && f.normals && (f.normals = we(f.normals, u)), l && Hi(d, h), i && m.index) {\n const p = f.position.count, g = m.index, y = p > 65535 ? Uint32Array : p > 255 ? Uint16Array : Uint8Array;\n if (!(g.array instanceof y)) {\n const x = new y(m.index.count);\n x.set(g.array);\n const b = new $(x, 1);\n m.setIndex(b);\n }\n }\n }\n });\n }\n}\nfunction q(a, e, t) {\n return a && e in a ? a[e] : t;\n}\nfunction An(a) {\n return a !== \"BOOLEAN\" && a !== \"STRING\" && a !== \"ENUM\";\n}\nfunction qi(a) {\n return /^FLOAT/.test(a);\n}\nfunction He(a) {\n return /^VEC/.test(a);\n}\nfunction qe(a) {\n return /^MAT/.test(a);\n}\nfunction In(a, e, t, s = null) {\n return qe(t) || He(t) ? s.fromArray(a, e) : a[e];\n}\nfunction Gt(a) {\n const { type: e, componentType: t } = a;\n switch (e) {\n case \"SCALAR\":\n return t === \"INT64\" ? 0n : 0;\n case \"VEC2\":\n return new X();\n case \"VEC3\":\n return new L();\n case \"VEC4\":\n return new ke();\n case \"MAT2\":\n return new ei();\n case \"MAT3\":\n return new Kn();\n case \"MAT4\":\n return new K();\n case \"BOOLEAN\":\n return !1;\n case \"STRING\":\n return \"\";\n // the final value for enums is a string but are represented as integers\n // during intermediate steps\n case \"ENUM\":\n return 0;\n }\n}\nfunction Ts(a, e) {\n if (e == null)\n return !1;\n switch (a) {\n case \"SCALAR\":\n return typeof e == \"number\" || typeof e == \"bigint\";\n case \"VEC2\":\n return e.isVector2;\n case \"VEC3\":\n return e.isVector3;\n case \"VEC4\":\n return e.isVector4;\n case \"MAT2\":\n return e.isMatrix2;\n case \"MAT3\":\n return e.isMatrix3;\n case \"MAT4\":\n return e.isMatrix4;\n case \"BOOLEAN\":\n return typeof e == \"boolean\";\n case \"STRING\":\n return typeof e == \"string\";\n case \"ENUM\":\n return typeof e == \"number\" || typeof e == \"bigint\";\n }\n throw new Error(\"ClassProperty: invalid type.\");\n}\nfunction Fe(a, e = null) {\n switch (a) {\n case \"INT8\":\n return Int8Array;\n case \"INT16\":\n return Int16Array;\n case \"INT32\":\n return Int32Array;\n case \"INT64\":\n return BigInt64Array;\n case \"UINT8\":\n return Uint8Array;\n case \"UINT16\":\n return Uint16Array;\n case \"UINT32\":\n return Uint32Array;\n case \"UINT64\":\n return BigUint64Array;\n case \"FLOAT32\":\n return Float32Array;\n case \"FLOAT64\":\n return Float64Array;\n }\n switch (e) {\n case \"BOOLEAN\":\n return Uint8Array;\n case \"STRING\":\n return Uint8Array;\n }\n throw new Error(\"ClassProperty: invalid type.\");\n}\nfunction Wi(a, e = null) {\n if (a.array) {\n e = e && Array.isArray(e) ? e : [], e.length = a.count;\n for (let s = 0, n = e.length; s < n; s++)\n e[s] = at(a, e[s]);\n } else\n e = at(a, e);\n return e;\n}\nfunction at(a, e = null) {\n const t = a.default, s = a.type;\n if (e = e || Gt(a), t === null) {\n switch (s) {\n case \"SCALAR\":\n return 0;\n case \"VEC2\":\n return e.set(0, 0);\n case \"VEC3\":\n return e.set(0, 0, 0);\n case \"VEC4\":\n return e.set(0, 0, 0, 0);\n case \"MAT2\":\n return e.identity();\n case \"MAT3\":\n return e.identity();\n case \"MAT4\":\n return e.identity();\n case \"BOOLEAN\":\n return !1;\n case \"STRING\":\n return \"\";\n case \"ENUM\":\n return \"\";\n }\n throw new Error(\"ClassProperty: invalid type.\");\n } else if (qe(s))\n e.fromArray(t);\n else if (He(s))\n e.fromArray(t);\n else\n return t;\n}\nfunction ji(a, e) {\n if (a.noData === null)\n return e;\n const t = a.noData, s = a.type;\n if (Array.isArray(e))\n for (let r = 0, o = e.length; r < o; r++)\n e[r] = n(e[r]);\n else\n e = n(e);\n return e;\n function n(r) {\n return i(r) && (r = at(a, r)), r;\n }\n function i(r) {\n if (qe(s)) {\n const o = r.elements;\n for (let l = 0, c = t.length; l < c; l++)\n if (t[l] !== o[l])\n return !1;\n return !0;\n } else if (He(s)) {\n for (let o = 0, l = t.length; o < l; o++)\n if (t[o] !== r.getComponent(o))\n return !1;\n return !0;\n } else\n return t === r;\n }\n}\nfunction Xi(a, e) {\n switch (a) {\n case \"INT8\":\n return Math.max(e / 127, -1);\n case \"INT16\":\n return Math.max(e, 32767, -1);\n case \"INT32\":\n return Math.max(e / 2147483647, -1);\n case \"INT64\":\n return Math.max(Number(e) / 9223372036854776e3, -1);\n // eslint-disable-line no-loss-of-precision\n case \"UINT8\":\n return e / 255;\n case \"UINT16\":\n return e / 65535;\n case \"UINT32\":\n return e / 4294967295;\n case \"UINT64\":\n return Number(e) / 18446744073709552e3;\n }\n}\nfunction Yi(a, e) {\n const {\n type: t,\n componentType: s,\n scale: n,\n offset: i,\n normalized: r\n } = a;\n if (Array.isArray(e))\n for (let h = 0, d = e.length; h < d; h++)\n e[h] = o(e[h]);\n else\n e = o(e);\n return e;\n function o(h) {\n return qe(t) ? h = c(h) : He(t) ? h = l(h) : h = u(h), h;\n }\n function l(h) {\n return h.x = u(h.x), h.y = u(h.y), \"z\" in h && (h.z = u(h.z)), \"w\" in h && (h.w = u(h.w)), h;\n }\n function c(h) {\n const d = h.elements;\n for (let m = 0, f = d.length; m < f; m++)\n d[m] = u(d[m]);\n return h;\n }\n function u(h) {\n return r && (h = Xi(s, h)), (r || qi(s)) && (h = h * n + i), h;\n }\n}\nfunction Zt(a, e, t = null) {\n if (a.array) {\n Array.isArray(e) || (e = new Array(a.count || 0)), e.length = t !== null ? t : a.count;\n for (let s = 0, n = e.length; s < n; s++)\n Ts(a.type, e[s]) || (e[s] = Gt(a));\n } else\n Ts(a.type, e) || (e = Gt(a));\n return e;\n}\nfunction lt(a, e) {\n for (const t in e)\n t in a || delete e[t];\n for (const t in a) {\n const s = a[t];\n e[t] = Zt(s, e[t]);\n }\n}\nfunction $i(a) {\n switch (a) {\n case \"ENUM\":\n return 1;\n case \"SCALAR\":\n return 1;\n case \"VEC2\":\n return 2;\n case \"VEC3\":\n return 3;\n case \"VEC4\":\n return 4;\n case \"MAT2\":\n return 4;\n case \"MAT3\":\n return 9;\n case \"MAT4\":\n return 16;\n // unused\n case \"BOOLEAN\":\n return -1;\n case \"STRING\":\n return -1;\n default:\n return -1;\n }\n}\nclass mt {\n constructor(e, t, s = null) {\n this.name = t.name || null, this.description = t.description || null, this.type = t.type, this.componentType = t.componentType || null, this.enumType = t.enumType || null, this.array = t.array || !1, this.count = t.count || 0, this.normalized = t.normalized || !1, this.offset = t.offset || 0, this.scale = q(t, \"scale\", 1), this.max = q(t, \"max\", 1 / 0), this.min = q(t, \"min\", -1 / 0), this.required = t.required || !1, this.noData = q(t, \"noData\", null), this.default = q(t, \"default\", null), this.semantic = q(t, \"semantic\", null), this.enumSet = null, this.accessorProperty = s, s && (this.offset = q(s, \"offset\", this.offset), this.scale = q(s, \"scale\", this.scale), this.max = q(s, \"max\", this.max), this.min = q(s, \"min\", this.min)), t.type === \"ENUM\" && (this.enumSet = e[this.enumType], this.componentType === null && (this.componentType = q(this.enumSet, \"valueType\", \"UINT16\")));\n }\n // shape the given target to match the data type of the property\n // enums are set to their integer value\n shapeToProperty(e, t = null) {\n return Zt(this, e, t);\n }\n // resolve the given object to the default value for the property for a single element\n // enums are set to a default string\n resolveDefaultElement(e) {\n return at(this, e);\n }\n // resolve the target to the default value for the property for every element if it's an array\n // enums are set to a default string\n resolveDefault(e) {\n return Wi(this, e);\n }\n // converts any instances of no data to the default value\n resolveNoData(e) {\n return ji(this, e);\n }\n // converts enums integers in the given target to strings\n resolveEnumsToStrings(e) {\n const t = this.enumSet;\n if (this.type === \"ENUM\")\n if (Array.isArray(e))\n for (let n = 0, i = e.length; n < i; n++)\n e[n] = s(e[n]);\n else\n e = s(e);\n return e;\n function s(n) {\n const i = t.values.find((r) => r.value === n);\n return i === null ? \"\" : i.name;\n }\n }\n // apply scales\n adjustValueScaleOffset(e) {\n return An(this.type) ? Yi(this, e) : e;\n }\n}\nclass Jt {\n constructor(e, t = {}, s = {}, n = null) {\n this.definition = e, this.class = t[e.class], this.className = e.class, this.enums = s, this.data = n, this.name = \"name\" in e ? e.name : null, this.properties = null;\n }\n getPropertyNames() {\n return Object.keys(this.class.properties);\n }\n includesData(e) {\n return !!this.definition.properties[e];\n }\n dispose() {\n }\n _initProperties(e = mt) {\n const t = {};\n for (const s in this.class.properties)\n t[s] = new e(this.enums, this.class.properties[s], this.definition.properties[s]);\n this.properties = t;\n }\n}\nclass Qi extends mt {\n constructor(e, t, s = null) {\n super(e, t, s), this.attribute = (s == null ? void 0 : s.attribute) ?? null;\n }\n}\nclass Zi extends Jt {\n constructor(...e) {\n super(...e), this.isPropertyAttributeAccessor = !0, this._initProperties(Qi);\n }\n getData(e, t, s = {}) {\n const n = this.properties;\n lt(n, s);\n for (const i in n)\n s[i] = this.getPropertyValue(i, e, t, s[i]);\n return s;\n }\n getPropertyValue(e, t, s, n = null) {\n if (t >= this.count)\n throw new Error(\"PropertyAttributeAccessor: Requested index is outside the range of the buffer.\");\n const i = this.properties[e], r = i.type;\n if (i) {\n if (!this.definition.properties[e])\n return i.resolveDefault(n);\n } else throw new Error(\"PropertyAttributeAccessor: Requested class property does not exist.\");\n n = i.shapeToProperty(n);\n const o = s.getAttribute(i.attribute.toLowerCase());\n if (qe(r)) {\n const l = n.elements;\n for (let c = 0, u = l.length; c < u; c < u)\n l[c] = o.getComponent(t, c);\n } else if (He(r))\n n.fromBufferAttribute(o, t);\n else if (r === \"SCALAR\" || r === \"ENUM\")\n n = o.getX(t);\n else\n throw new Error(\"StructuredMetadata.PropertyAttributeAccessor: BOOLEAN and STRING types are not supported by property attributes.\");\n return n = i.adjustValueScaleOffset(n), n = i.resolveEnumsToStrings(n), n = i.resolveNoData(n), n;\n }\n}\nclass Ji extends mt {\n constructor(e, t, s = null) {\n super(e, t, s), this.values = (s == null ? void 0 : s.values) ?? null, this.valueLength = $i(this.type), this.arrayOffsets = q(s, \"arrayOffsets\", null), this.stringOffsets = q(s, \"stringOffsets\", null), this.arrayOffsetType = q(s, \"arrayOffsetType\", \"UINT32\"), this.stringOffsetType = q(s, \"stringOffsetType\", \"UINT32\");\n }\n // returns the necessary array length based on the array offsets if present\n getArrayLengthFromId(e, t) {\n let s = this.count;\n if (this.arrayOffsets !== null) {\n const { arrayOffsets: n, arrayOffsetType: i } = this, r = Fe(i), o = new r(e[n]);\n s = o[t + 1] - o[t];\n }\n return s;\n }\n // returns the index offset into the data buffer for the given id based on the\n // the array offsets if present\n getIndexOffsetFromId(e, t) {\n let s = t;\n if (this.arrayOffsets) {\n const { arrayOffsets: n, arrayOffsetType: i } = this, r = Fe(i);\n s = new r(e[n])[s];\n } else this.array && (s *= this.count);\n return s;\n }\n}\nclass Ki extends Jt {\n constructor(...e) {\n super(...e), this.isPropertyTableAccessor = !0, this.count = this.definition.count, this._initProperties(Ji);\n }\n getData(e, t = {}) {\n const s = this.properties;\n lt(s, t);\n for (const n in s)\n t[n] = this.getPropertyValue(n, e, t[n]);\n return t;\n }\n // reads an individual element\n _readValueAtIndex(e, t, s, n = null) {\n const i = this.properties[e], { componentType: r, type: o } = i, l = this.data, c = l[i.values], u = Fe(r, o), h = new u(c), d = i.getIndexOffsetFromId(l, t);\n if (An(o) || o === \"ENUM\")\n return In(h, (d + s) * i.valueLength, o, n);\n if (o === \"STRING\") {\n let m = d + s, f = 0;\n if (i.stringOffsets !== null) {\n const { stringOffsets: g, stringOffsetType: y } = i, x = Fe(y), b = new x(l[g]);\n f = b[m + 1] - b[m], m = b[m];\n }\n const p = new Uint8Array(h.buffer, m, f);\n n = new TextDecoder().decode(p);\n } else if (o === \"BOOLEAN\") {\n const m = d + s, f = Math.floor(m / 8), p = m % 8;\n n = (h[f] >> p & 1) === 1;\n }\n return n;\n }\n // Reads the data for the given table index\n getPropertyValue(e, t, s = null) {\n if (t >= this.count)\n throw new Error(\"PropertyTableAccessor: Requested index is outside the range of the table.\");\n const n = this.properties[e];\n if (n) {\n if (!this.definition.properties[e])\n return n.resolveDefault(s);\n } else throw new Error(\"PropertyTableAccessor: Requested property does not exist.\");\n const i = n.array, r = this.data, o = n.getArrayLengthFromId(r, t);\n if (s = n.shapeToProperty(s, o), i)\n for (let l = 0, c = s.length; l < c; l++)\n s[l] = this._readValueAtIndex(e, t, l, s[l]);\n else\n s = this._readValueAtIndex(e, t, 0, s);\n return s = n.adjustValueScaleOffset(s), s = n.resolveEnumsToStrings(s), s = n.resolveNoData(s), s;\n }\n}\nconst Pe = /* @__PURE__ */ new oi();\nclass bs {\n constructor() {\n this._renderer = new ti(), this._target = new ns(1, 1), this._texTarget = new ns(), this._quad = new mn(new si({\n blending: ri,\n blendDst: ii,\n blendSrc: ni,\n uniforms: {\n map: { value: null },\n pixel: { value: new X() }\n },\n vertexShader: (\n /* glsl */\n `\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}\n\t\t\t`\n ),\n fragmentShader: (\n /* glsl */\n `\n\t\t\t\tuniform sampler2D map;\n\t\t\t\tuniform ivec2 pixel;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_FragColor = texelFetch( map, pixel, 0 );\n\n\t\t\t\t}\n\t\t\t`\n )\n }));\n }\n // increases the width of the target render target to support more data\n increaseSizeTo(e) {\n this._target.setSize(Math.max(this._target.width, e), 1);\n }\n // read data from the rendered texture asynchronously\n readDataAsync(e) {\n const { _renderer: t, _target: s } = this;\n return t.readRenderTargetPixelsAsync(s, 0, 0, e.length / 4, 1, e);\n }\n // read data from the rendered texture\n readData(e) {\n const { _renderer: t, _target: s } = this;\n t.readRenderTargetPixels(s, 0, 0, e.length / 4, 1, e);\n }\n // render a single pixel from the source at the destination point on the render target\n // takes the texture, pixel to read from, and pixel to render in to\n renderPixelToTarget(e, t, s) {\n const { _renderer: n, _target: i } = this;\n Pe.min.copy(t), Pe.max.copy(t), Pe.max.x += 1, Pe.max.y += 1, n.initRenderTarget(i), n.copyTextureToTexture(e, i.texture, Pe, s, 0);\n }\n}\nconst de = /* @__PURE__ */ new class {\n constructor() {\n let a = null;\n Object.getOwnPropertyNames(bs.prototype).forEach((e) => {\n e !== \"constructor\" && (this[e] = (...t) => (a = a || new bs(), a[e](...t)));\n });\n }\n}(), _s = /* @__PURE__ */ new X(), Ss = /* @__PURE__ */ new X(), Ms = /* @__PURE__ */ new X();\nfunction er(a, e) {\n return e === 0 ? a.getAttribute(\"uv\") : a.getAttribute(`uv${e}`);\n}\nfunction vn(a, e, t = new Array(3)) {\n let s = 3 * e, n = 3 * e + 1, i = 3 * e + 2;\n return a.index && (s = a.index.getX(s), n = a.index.getX(n), i = a.index.getX(i)), t[0] = s, t[1] = n, t[2] = i, t;\n}\nfunction Ln(a, e, t, s, n) {\n const [i, r, o] = s, l = er(a, e);\n _s.fromBufferAttribute(l, i), Ss.fromBufferAttribute(l, r), Ms.fromBufferAttribute(l, o), n.set(0, 0, 0).addScaledVector(_s, t.x).addScaledVector(Ss, t.y).addScaledVector(Ms, t.z);\n}\nfunction En(a, e, t, s) {\n const n = a.x - Math.floor(a.x), i = a.y - Math.floor(a.y), r = Math.floor(n * e % e), o = Math.floor(i * t % t);\n return s.set(r, o), s;\n}\nconst Cs = /* @__PURE__ */ new X(), As = /* @__PURE__ */ new X(), Is = /* @__PURE__ */ new X();\nclass tr extends mt {\n constructor(e, t, s = null) {\n super(e, t, s), this.channels = q(s, \"channels\", [0]), this.index = q(s, \"index\", null), this.texCoord = q(s, \"texCoord\", null), this.valueLength = parseInt(this.type.replace(/[^0-9]/g, \"\")) || 1;\n }\n // takes the buffer to read from and the value index to read\n readDataFromBuffer(e, t, s = null) {\n const n = this.type;\n if (n === \"BOOLEAN\" || n === \"STRING\")\n throw new Error(\"PropertyTextureAccessor: BOOLEAN and STRING types not supported.\");\n return In(e, t * this.valueLength, n, s);\n }\n}\nclass sr extends Jt {\n constructor(...e) {\n super(...e), this.isPropertyTextureAccessor = !0, this._asyncRead = !1, this._initProperties(tr);\n }\n // Reads the full set of property data\n getData(e, t, s, n = {}) {\n const i = this.properties;\n lt(i, n);\n const r = Object.keys(i), o = r.map((l) => n[l]);\n return this.getPropertyValuesAtTexel(r, e, t, s, o), r.forEach((l, c) => n[l] = o[c]), n;\n }\n // Reads the full set of property data asynchronously\n async getDataAsync(e, t, s, n = {}) {\n const i = this.properties;\n lt(i, n);\n const r = Object.keys(i), o = r.map((l) => n[l]);\n return await this.getPropertyValuesAtTexelAsync(r, e, t, s, o), r.forEach((l, c) => n[l] = o[c]), n;\n }\n // Reads values asynchronously\n getPropertyValuesAtTexelAsync(...e) {\n this._asyncRead = !0;\n const t = this.getPropertyValuesAtTexel(...e);\n return this._asyncRead = !1, t;\n }\n // Reads values from the textures synchronously\n getPropertyValuesAtTexel(e, t, s, n, i = []) {\n for (; i.length < e.length; ) i.push(null);\n i.length = e.length, de.increaseSizeTo(i.length);\n const r = this.data, o = this.definition.properties, l = this.properties, c = vn(n, t);\n for (let d = 0, m = e.length; d < m; d++) {\n const f = e[d];\n if (!o[f])\n continue;\n const p = l[f], g = r[p.index];\n Ln(n, p.texCoord, s, c, Cs), En(Cs, g.image.width, g.image.height, As), Is.set(d, 0), de.renderPixelToTarget(g, As, Is);\n }\n const u = new Uint8Array(e.length * 4);\n if (this._asyncRead)\n return de.readDataAsync(u).then(() => (h.call(this), i));\n return de.readData(u), h.call(this), i;\n function h() {\n for (let d = 0, m = e.length; d < m; d++) {\n const f = e[d], p = l[f], g = p.type;\n if (i[d] = Zt(p, i[d]), p) {\n if (!o[f]) {\n i[d] = p.resolveDefault(i);\n continue;\n }\n } else throw new Error(\"PropertyTextureAccessor: Requested property does not exist.\");\n const y = p.valueLength * (p.count || 1), x = p.channels.map((S) => u[4 * d + S]), b = p.componentType, T = Fe(b, g), M = new T(y);\n if (new Uint8Array(M.buffer).set(x), p.array) {\n const S = i[d];\n for (let C = 0, v = S.length; C < v; C++)\n S[C] = p.readDataFromBuffer(M, C, S[C]);\n } else\n i[d] = p.readDataFromBuffer(M, 0, i[d]);\n i[d] = p.adjustValueScaleOffset(i[d]), i[d] = p.resolveEnumsToStrings(i[d]), i[d] = p.resolveNoData(i[d]);\n }\n }\n }\n // dispose all of the texture data used\n dispose() {\n this.data.forEach((e) => {\n e && (e.dispose(), e.image instanceof ImageBitmap && e.image.close());\n });\n }\n}\nclass vs {\n constructor(e, t, s, n = null, i = null) {\n const {\n schema: r,\n propertyTables: o = [],\n propertyTextures: l = [],\n propertyAttributes: c = []\n } = e, { enums: u, classes: h } = r, d = o.map((p) => new Ki(p, h, u, s));\n let m = [], f = [];\n n && (n.propertyTextures && (m = n.propertyTextures.map((p) => new sr(l[p], h, u, t))), n.propertyAttributes && (f = n.propertyAttributes.map((p) => new Zi(c[p], h, u)))), this.schema = r, this.tableAccessors = d, this.textureAccessors = m, this.attributeAccessors = f, this.object = i, this.textures = t, this.nodeMetadata = n;\n }\n // Property Tables\n /**\n * Returns data from one or more property tables. Pass a single table index and row ID to\n * get one object, or parallel arrays of table indices and row IDs to get an array of\n * results. Each returned object conforms to the structure class referenced in the schema.\n * @param {number|Array<number>} tableIndices Table index or array of table indices.\n * @param {number|Array<number>} ids Row ID or array of row IDs.\n * @param {Object|Array|null} [target=null] Optional target object or array to write into.\n * @returns {Object|Array}\n */\n getPropertyTableData(e, t, s = null) {\n if (!Array.isArray(e) || !Array.isArray(t))\n s = s || {}, s = this.tableAccessors[e].getData(t, s);\n else {\n s = s || [];\n const n = Math.min(e.length, t.length);\n s.length = n;\n for (let i = 0; i < n; i++) {\n const r = this.tableAccessors[e[i]];\n s[i] = r.getData(t[i], s[i]);\n }\n }\n return s;\n }\n /**\n * Returns name and class information for one or more property tables. Defaults to all\n * tables when `tableIndices` is `null`.\n * @param {Array<number>|null} [tableIndices=null]\n * @returns {Array<{name: string, className: string}>|{name: string, className: string}}\n */\n getPropertyTableInfo(e = null) {\n if (e === null && (e = this.tableAccessors.map((t, s) => s)), Array.isArray(e))\n return e.map((t) => {\n const s = this.tableAccessors[t];\n return {\n name: s.name,\n className: s.definition.class\n };\n });\n {\n const t = this.tableAccessors[e];\n return {\n name: t.name,\n className: t.definition.class\n };\n }\n }\n // Property Textures\n /**\n * Returns data from property textures at the given point on the mesh. Takes the triangle\n * index and barycentric coordinate from a raycast result. See `MeshFeatures.getFeatures`\n * for how to obtain these values.\n * @param {number} triangle Triangle index from a raycast hit.\n * @param {Vector3} barycoord Barycentric coordinate of the hit point.\n * @param {Array} [target=[]] Optional target array to write into.\n * @returns {Array}\n */\n getPropertyTextureData(e, t, s = []) {\n const n = this.textureAccessors;\n s.length = n.length;\n for (let i = 0; i < n.length; i++) {\n const r = n[i];\n s[i] = r.getData(e, t, this.object.geometry, s[i]);\n }\n return s;\n }\n /**\n * Returns the same data as `getPropertyTextureData` but performs texture reads\n * asynchronously.\n * @param {number} triangle Triangle index from a raycast hit.\n * @param {Vector3} barycoord Barycentric coordinate of the hit point.\n * @param {Array} [target=[]] Optional target array to write into.\n * @returns {Promise<Array>}\n */\n async getPropertyTextureDataAsync(e, t, s = []) {\n const n = this.textureAccessors;\n s.length = n.length;\n const i = [];\n for (let r = 0; r < n.length; r++) {\n const l = n[r].getDataAsync(e, t, this.object.geometry, s[r]).then((c) => {\n s[r] = c;\n });\n i.push(l);\n }\n return await Promise.all(i), s;\n }\n /**\n * Returns information about the property texture accessors, including their class names\n * and per-property channel/texcoord mappings.\n * @returns {Array<{name: string, className: string, properties: Object}>}\n */\n getPropertyTextureInfo() {\n return this.textureAccessors;\n }\n // Property Attributes\n /**\n * Returns data stored as property attributes for the given vertex index.\n * @param {number} attributeIndex Vertex index.\n * @param {Array} [target=[]] Optional target array to write into.\n * @returns {Array}\n */\n getPropertyAttributeData(e, t = []) {\n const s = this.attributeAccessors;\n t.length = s.length;\n for (let n = 0; n < s.length; n++) {\n const i = s[n];\n t[n] = i.getData(e, this.object.geometry, t[n]);\n }\n return t;\n }\n /**\n * Returns name and class information for all property attribute accessors.\n * @returns {Array<{name: string, className: string}>}\n */\n getPropertyAttributeInfo() {\n return this.attributeAccessors.map((e) => ({\n name: e.name,\n className: e.definition.class\n }));\n }\n /**\n * Disposes all texture, table, and attribute accessors.\n */\n dispose() {\n this.textureAccessors.forEach((e) => e.dispose()), this.tableAccessors.forEach((e) => e.dispose()), this.attributeAccessors.forEach((e) => e.dispose());\n }\n}\nconst Re = \"EXT_structural_metadata\";\nfunction nr(a, e = []) {\n var n;\n const t = ((n = a.json.textures) == null ? void 0 : n.length) || 0, s = new Array(t).fill(null);\n return e.forEach(({ properties: i }) => {\n for (const r in i) {\n const { index: o } = i[r];\n s[o] === null && (s[o] = a.loadTexture(o));\n }\n }), Promise.all(s);\n}\nfunction ir(a, e = []) {\n var n;\n const t = ((n = a.json.bufferViews) == null ? void 0 : n.length) || 0, s = new Array(t).fill(null);\n return e.forEach(({ properties: i }) => {\n for (const r in i) {\n const { values: o, arrayOffsets: l, stringOffsets: c } = i[r];\n s[o] === null && (s[o] = a.loadBufferView(o)), s[l] === null && (s[l] = a.loadBufferView(l)), s[c] === null && (s[c] = a.loadBufferView(c));\n }\n }), Promise.all(s);\n}\nclass rr {\n constructor(e) {\n this.parser = e, this.name = Re;\n }\n async afterRoot({ scene: e, parser: t }) {\n const s = t.json.extensionsUsed;\n if (!s || !s.includes(Re))\n return;\n let n = null, i = t.json.extensions[Re];\n if (i.schemaUri) {\n const { manager: c, path: u, requestHeader: h, crossOrigin: d } = t.options, m = new URL(i.schemaUri, u).toString(), f = new ai(c);\n f.setCrossOrigin(d), f.setResponseType(\"json\"), f.setRequestHeader(h), n = f.loadAsync(m).then((p) => {\n i = { ...i, schema: p };\n });\n }\n const [r, o] = await Promise.all([\n nr(t, i.propertyTextures),\n ir(t, i.propertyTables),\n n\n ]), l = new vs(i, r, o);\n e.userData.structuralMetadata = l, e.traverse((c) => {\n var u;\n if (t.associations.has(c)) {\n const { meshes: h, primitives: d } = t.associations.get(c), m = (u = t.json.meshes[h]) == null ? void 0 : u.primitives[d];\n if (m && m.extensions && m.extensions[Re]) {\n const f = m.extensions[Re];\n c.userData.structuralMetadata = new vs(i, r, o, f, c);\n } else\n c.userData.structuralMetadata = l;\n }\n });\n }\n}\nconst Ls = /* @__PURE__ */ new X(), Es = /* @__PURE__ */ new X(), ws = /* @__PURE__ */ new X();\nfunction or(a) {\n return a.x > a.y && a.x > a.z ? 0 : a.y > a.z ? 1 : 2;\n}\nclass ar {\n constructor(e, t, s) {\n this.geometry = e, this.textures = t, this.data = s, this._asyncRead = !1, this.featureIds = s.featureIds.map((n) => {\n const { texture: i, ...r } = n, o = {\n label: null,\n propertyTable: null,\n nullFeatureId: null,\n ...r\n };\n return i && (o.texture = {\n texCoord: 0,\n channels: [0],\n ...i\n }), o;\n });\n }\n /**\n * Returns an indexed list of all textures used by features in the extension.\n * @returns {Array<Texture>}\n */\n getTextures() {\n return this.textures;\n }\n /**\n * Returns the feature ID info for each feature set defined on this primitive.\n * @returns {Array<FeatureInfo>}\n */\n getFeatureInfo() {\n return this.featureIds;\n }\n /**\n * Performs the same function as `getFeatures` but reads texture data asynchronously.\n * @param {number} triangle Triangle index from a raycast hit.\n * @param {Vector3} barycoord Barycentric coordinate of the hit point.\n * @returns {Promise<Array<number|null>>}\n */\n getFeaturesAsync(...e) {\n this._asyncRead = !0;\n const t = this.getFeatures(...e);\n return this._asyncRead = !1, t;\n }\n /**\n * Returns the list of feature IDs at the given point on the mesh. Takes the triangle\n * index from a raycast result and a barycentric coordinate. Results are indexed in the\n * same order as the feature info returned by `getFeatureInfo()`.\n * @param {number} triangle Triangle index from a raycast hit.\n * @param {Vector3} barycoord Barycentric coordinate of the hit point.\n * @returns {Array<number|null>}\n */\n getFeatures(e, t) {\n const { geometry: s, textures: n, featureIds: i } = this, r = new Array(i.length).fill(null), o = i.length;\n de.increaseSizeTo(o);\n const l = vn(s, e), c = l[or(t)];\n for (let d = 0, m = i.length; d < m; d++) {\n const f = i[d], p = \"nullFeatureId\" in f ? f.nullFeatureId : null;\n if (\"texture\" in f) {\n const g = n[f.texture.index];\n Ln(s, f.texture.texCoord, t, l, Ls), En(Ls, g.image.width, g.image.height, Es), ws.set(d, 0), de.renderPixelToTarget(n[f.texture.index], Es, ws);\n } else if (\"attribute\" in f) {\n const y = s.getAttribute(`_feature_id_${f.attribute}`).getX(c);\n y !== p && (r[d] = y);\n } else {\n const g = c;\n g !== p && (r[d] = g);\n }\n }\n const u = new Uint8Array(o * 4);\n if (this._asyncRead)\n return de.readDataAsync(u).then(() => (h(), r));\n return de.readData(u), h(), r;\n function h() {\n const d = new Uint32Array(1);\n for (let m = 0, f = i.length; m < f; m++) {\n const p = i[m], g = \"nullFeatureId\" in p ? p.nullFeatureId : null;\n if (\"texture\" in p) {\n const { channels: y } = p.texture, x = y.map((T) => u[4 * m + T]);\n new Uint8Array(d.buffer).set(x);\n const b = d[0];\n b !== g && (r[m] = b);\n }\n }\n }\n }\n /**\n * Disposes all textures used by this instance.\n */\n dispose() {\n this.textures.forEach((e) => {\n e && (e.dispose(), e.image instanceof ImageBitmap && e.image.close());\n });\n }\n}\nconst ct = \"EXT_mesh_features\";\nfunction Ps(a, e, t) {\n a.traverse((s) => {\n var n;\n if (e.associations.has(s)) {\n const { meshes: i, primitives: r } = e.associations.get(s), o = (n = e.json.meshes[i]) == null ? void 0 : n.primitives[r];\n o && o.extensions && o.extensions[ct] && t(s, o.extensions[ct]);\n }\n });\n}\nclass lr {\n constructor(e) {\n this.parser = e, this.name = ct;\n }\n async afterRoot({ scene: e, parser: t }) {\n var o;\n const s = t.json.extensionsUsed;\n if (!s || !s.includes(ct))\n return;\n const n = ((o = t.json.textures) == null ? void 0 : o.length) || 0, i = new Array(n).fill(null);\n Ps(e, t, (l, { featureIds: c }) => {\n c.forEach((u) => {\n if (u.texture && i[u.texture.index] === null) {\n const h = u.texture.index;\n i[h] = t.loadTexture(h);\n }\n });\n });\n const r = await Promise.all(i);\n Ps(e, t, (l, c) => {\n l.userData.meshFeatures = new ar(l.geometry, r, c);\n });\n }\n}\nclass cr {\n constructor() {\n this.name = \"CESIUM_RTC\";\n }\n afterRoot(e) {\n if (e.parser.json.extensions && e.parser.json.extensions.CESIUM_RTC) {\n const { center: t } = e.parser.json.extensions.CESIUM_RTC;\n t && (e.scene.position.x += t[0], e.scene.position.y += t[1], e.scene.position.z += t[2]);\n }\n }\n}\nclass go {\n constructor(e) {\n e = {\n metadata: !0,\n rtc: !0,\n plugins: [],\n dracoLoader: null,\n ktxLoader: null,\n meshoptDecoder: null,\n autoDispose: !0,\n ...e\n }, this.tiles = null, this.metadata = e.metadata, this.rtc = e.rtc, this.plugins = e.plugins, this.dracoLoader = e.dracoLoader, this.ktxLoader = e.ktxLoader, this.meshoptDecoder = e.meshoptDecoder, this._gltfRegex = /\\.(gltf|glb)$/g, this._dracoRegex = /\\.drc$/g, this._loader = null;\n }\n init(e) {\n const t = new Si(e.manager);\n this.dracoLoader && (t.setDRACOLoader(this.dracoLoader), e.manager.addHandler(this._dracoRegex, this.dracoLoader)), this.ktxLoader && t.setKTX2Loader(this.ktxLoader), this.meshoptDecoder && t.setMeshoptDecoder(this.meshoptDecoder), this.rtc && t.register(() => new cr()), this.metadata && (t.register(() => new rr()), t.register(() => new lr())), this.plugins.forEach((s) => t.register(s)), e.manager.addHandler(this._gltfRegex, t), this.tiles = e, this._loader = t;\n }\n dispose() {\n this.tiles.manager.removeHandler(this._gltfRegex), this.tiles.manager.removeHandler(this._dracoRegex), this.autoDispose && (this.ktxLoader.dispose(), this.dracoLoader.dispose());\n }\n}\nconst $e = /* @__PURE__ */ new pe();\nclass yo {\n constructor(e) {\n e = {\n up: \"+z\",\n recenter: !0,\n lat: null,\n lon: null,\n height: 0,\n azimuth: 0,\n elevation: 0,\n roll: 0,\n ...e\n }, this.tiles = null, this.up = e.up.toLowerCase().replace(/\\s+/, \"\"), this.lat = e.lat, this.lon = e.lon, this.height = e.height, this.azimuth = e.azimuth, this.elevation = e.elevation, this.roll = e.roll, this.recenter = e.recenter, this._callback = null;\n }\n init(e) {\n this.tiles = e, this._callback = () => {\n const { up: t, lat: s, lon: n, height: i, azimuth: r, elevation: o, roll: l, recenter: c } = this;\n if (s !== null && n !== null)\n this.transformLatLonHeightToOrigin(s, n, i, r, o, l);\n else {\n const { ellipsoid: u } = e, h = Math.min(...u.radius);\n if (e.getBoundingSphere($e), $e.center.length() > h * 0.5) {\n const d = {};\n u.getPositionToCartographic($e.center, d), this.transformLatLonHeightToOrigin(d.lat, d.lon, d.height);\n } else {\n const d = e.group;\n switch (d.rotation.set(0, 0, 0), t) {\n case \"x\":\n case \"+x\":\n d.rotation.z = Math.PI / 2;\n break;\n case \"-x\":\n d.rotation.z = -Math.PI / 2;\n break;\n case \"y\":\n case \"+y\":\n break;\n case \"-y\":\n d.rotation.z = Math.PI;\n break;\n case \"z\":\n case \"+z\":\n d.rotation.x = -Math.PI / 2;\n break;\n case \"-z\":\n d.rotation.x = Math.PI / 2;\n break;\n }\n e.group.position.copy($e.center).applyEuler(d.rotation).multiplyScalar(-1);\n }\n }\n c || e.group.position.setScalar(0), e.removeEventListener(\"load-root-tileset\", this._callback);\n }, e.addEventListener(\"load-root-tileset\", this._callback), e.root && this._callback();\n }\n /**\n * Centers the tileset such that the given coordinates are positioned at the origin\n * with X facing west and Z facing north.\n * @param {number} lat Latitude in radians.\n * @param {number} lon Longitude in radians.\n * @param {number} [height=0] Height in metres above the ellipsoid surface.\n * @param {number} [azimuth=0] Azimuth rotation in radians.\n * @param {number} [elevation=0] Elevation rotation in radians.\n * @param {number} [roll=0] Roll rotation in radians.\n */\n transformLatLonHeightToOrigin(e, t, s = 0, n = 0, i = 0, r = 0) {\n const { group: o, ellipsoid: l } = this.tiles;\n l.getObjectFrame(e, t, s, n, i, r, o.matrix, xi), o.matrix.invert().decompose(o.position, o.quaternion, o.scale), o.updateMatrixWorld();\n }\n dispose() {\n const { group: e } = this.tiles;\n e.position.setScalar(0), e.quaternion.identity(), e.scale.set(1, 1, 1), this.tiles.removeEventListener(\"load-root-tileset\", this._callback);\n }\n}\nclass xo {\n set delay(e) {\n this.deferCallbacks.delay = e;\n }\n get delay() {\n return this.deferCallbacks.delay;\n }\n set bytesTarget(e) {\n this.lruCache.minBytesSize = e;\n }\n get bytesTarget() {\n return this.lruCache.minBytesSize;\n }\n /**\n * The number of bytes currently uploaded to the GPU for rendering. Compare to\n * `lruCache.cachedBytes` which reports all downloaded bytes including those not\n * yet on the GPU.\n * @type {number}\n */\n get estimatedGpuBytes() {\n return this.lruCache.cachedBytes;\n }\n constructor(e = {}) {\n const {\n delay: t = 0,\n bytesTarget: s = 0\n } = e;\n this.name = \"UNLOAD_TILES_PLUGIN\", this.tiles = null, this.lruCache = new Mi(), this.deferCallbacks = new ur(), this.delay = t, this.bytesTarget = s;\n }\n init(e) {\n this.tiles = e;\n const { lruCache: t, deferCallbacks: s } = this, n = (i) => {\n const r = i.engineData.scene;\n e.visibleTiles.has(i) || e.invokeOnePlugin((l) => l.unloadTileFromGPU && l.unloadTileFromGPU(r, i));\n };\n this._onUpdateBefore = () => {\n t.unloadPriorityCallback = e.lruCache.unloadPriorityCallback, t.minSize = 1 / 0, t.maxSize = 1 / 0, t.maxBytesSize = 1 / 0, t.unloadPercent = 1, t.autoMarkUnused = !1;\n }, this._onVisibilityChangeCallback = ({ tile: i, scene: r, visible: o }) => {\n o ? (t.add(i, n), t.setMemoryUsage(i, e.calculateBytesUsed(i, r) || 1), e.markTileUsed(i), s.cancel(i)) : s.run(i);\n }, this._onDisposeModel = ({ tile: i }) => {\n t.remove(i), s.cancel(i);\n }, s.callback = (i) => {\n t.markUnused(i), t.scheduleUnload();\n }, e.forEachLoadedModel((i, r) => {\n const o = e.visibleTiles.has(r);\n this._onVisibilityChangeCallback({ tile: r, visible: o });\n }), e.addEventListener(\"tile-visibility-change\", this._onVisibilityChangeCallback), e.addEventListener(\"update-before\", this._onUpdateBefore), e.addEventListener(\"dispose-model\", this._onDisposeModel);\n }\n unloadTileFromGPU(e, t) {\n e && e.traverse((s) => {\n if (s.material) {\n const n = s.material;\n n.dispose();\n for (const i in n) {\n const r = n[i];\n r && r.isTexture && r.dispose();\n }\n }\n s.geometry && s.geometry.dispose();\n });\n }\n dispose() {\n const { lruCache: e, tiles: t, deferCallbacks: s } = this;\n t.removeEventListener(\"tile-visibility-change\", this._onVisibilityChangeCallback), t.removeEventListener(\"update-before\", this._onUpdateBefore), t.removeEventListener(\"dispose-model\", this._onDisposeModel), s.cancelAll(), e.minBytesSize = 0, e.minSize = 0, e.maxSize = 0, e.markAllUnused(), e.scheduleUnload();\n }\n}\nclass ur {\n constructor(e = () => {\n }) {\n this.map = /* @__PURE__ */ new Map(), this.callback = e, this.delay = 0;\n }\n run(e) {\n const { map: t, delay: s } = this;\n if (t.has(e))\n throw new Error(\"DeferCallbackManager: Callback already initialized.\");\n s === 0 ? this.callback(e) : t.set(e, setTimeout(() => {\n this.callback(e), t.delete(e);\n }, s));\n }\n cancel(e) {\n const { map: t } = this;\n t.has(e) && (clearTimeout(t.get(e)), t.delete(e));\n }\n cancelAll() {\n this.map.forEach((e, t) => {\n this.cancel(t);\n });\n }\n}\nconst { clamp: It } = _;\nclass hr {\n constructor() {\n this.duration = 250, this.fadeCount = 0, this._lastTick = -1, this._fadeState = /* @__PURE__ */ new Map(), this.onFadeComplete = null, this.onFadeStart = null, this.onFadeSetComplete = null, this.onFadeSetStart = null;\n }\n // delete the object from the fade, reset the material data\n deleteObject(e) {\n e && this.completeFade(e);\n }\n // Ensure we're storing a fade timer for the provided object\n // Returns whether a new state had to be added\n guaranteeState(e) {\n const t = this._fadeState;\n if (t.has(e))\n return !1;\n const s = {\n fadeInTarget: 0,\n fadeOutTarget: 0,\n fadeIn: 0,\n fadeOut: 0\n };\n return t.set(e, s), !0;\n }\n // Force the fade to complete in the direction it is already trending\n completeFade(e) {\n const t = this._fadeState;\n if (!t.has(e))\n return;\n const s = t.get(e).fadeOutTarget === 0;\n t.delete(e), this.fadeCount--, this.onFadeComplete && this.onFadeComplete(e, s), this.fadeCount === 0 && this.onFadeSetComplete && this.onFadeSetComplete();\n }\n completeAllFades() {\n this._fadeState.forEach((e, t) => {\n this.completeFade(t);\n });\n }\n forEachObject(e) {\n this._fadeState.forEach((t, s) => {\n e(s, t);\n });\n }\n // Fade the object in\n fadeIn(e) {\n const t = this.guaranteeState(e), s = this._fadeState.get(e);\n s.fadeInTarget = 1, s.fadeOutTarget = 0, s.fadeOut = 0, t && (this.fadeCount++, this.fadeCount === 1 && this.onFadeSetStart && this.onFadeSetStart(), this.onFadeStart && this.onFadeStart(e));\n }\n // Fade the object out\n fadeOut(e) {\n const t = this.guaranteeState(e), s = this._fadeState.get(e);\n s.fadeOutTarget = 1, t && (s.fadeInTarget = 1, s.fadeIn = 1, this.fadeCount++, this.fadeCount === 1 && this.onFadeSetStart && this.onFadeSetStart(), this.onFadeStart && this.onFadeStart(e));\n }\n isFading(e) {\n return this._fadeState.has(e);\n }\n isFadingOut(e) {\n const t = this._fadeState.get(e);\n return t && t.fadeOutTarget === 1;\n }\n // Tick the fade timer for each actively fading object\n update() {\n const e = window.performance.now();\n this._lastTick === -1 && (this._lastTick = e);\n const t = It((e - this._lastTick) / this.duration, 0, 1);\n this._lastTick = e, this._fadeState.forEach((n, i) => {\n const {\n fadeOutTarget: r,\n fadeInTarget: o\n } = n;\n let {\n fadeOut: l,\n fadeIn: c\n } = n;\n const u = Math.sign(o - c);\n c = It(c + u * t, 0, 1);\n const h = Math.sign(r - l);\n l = It(l + h * t, 0, 1), n.fadeIn = c, n.fadeOut = l, ((l === 1 || l === 0) && (c === 1 || c === 0) || l >= c) && this.completeFade(i);\n });\n }\n}\nconst vt = Symbol(\"FADE_PARAMS\");\nfunction wn(a, e) {\n if (a[vt])\n return a[vt];\n const t = {\n fadeIn: { value: 0 },\n fadeOut: { value: 0 },\n fadeTexture: { value: null }\n };\n return a[vt] = t, a.defines = {\n ...a.defines || {},\n FEATURE_FADE: 0\n }, a.onBeforeCompile = (s) => {\n e && e(s), s.uniforms = {\n ...s.uniforms,\n ...t\n }, s.vertexShader = s.vertexShader.replace(\n /void\\s+main\\(\\)\\s+{/,\n (n) => (\n /* glsl */\n `\n\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\tvarying float vBatchId;\n\n\t\t\t\t\t#endif\n\n\t\t\t\t\t${n}\n\n\t\t\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t\t\t// add 0.5 to the value to avoid floating error that may cause flickering\n\t\t\t\t\t\tvBatchId = getIndirectIndex( gl_DrawID ) + 0.5;\n\n\t\t\t\t\t\t#endif\n\t\t\t\t`\n )\n ), s.fragmentShader = s.fragmentShader.replace(/void main\\(/, (n) => (\n /* glsl */\n `\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t// adapted from https://www.shadertoy.com/view/Mlt3z8\n\t\t\t\tfloat bayerDither2x2( vec2 v ) {\n\n\t\t\t\t\treturn mod( 3.0 * v.y + 2.0 * v.x, 4.0 );\n\n\t\t\t\t}\n\n\t\t\t\tfloat bayerDither4x4( vec2 v ) {\n\n\t\t\t\t\tvec2 P1 = mod( v, 2.0 );\n\t\t\t\t\tvec2 P2 = floor( 0.5 * mod( v, 4.0 ) );\n\t\t\t\t\treturn 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 );\n\n\t\t\t\t}\n\n\t\t\t\t// the USE_BATCHING define is not available in fragment shaders\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\t// functions for reading the fade state of a given batch id\n\t\t\t\tuniform sampler2D fadeTexture;\n\t\t\t\tvarying float vBatchId;\n\t\t\t\tvec2 getFadeValues( const in float i ) {\n\n\t\t\t\t\tint size = textureSize( fadeTexture, 0 ).x;\n\t\t\t\t\tint j = int( i );\n\t\t\t\t\tint x = j % size;\n\t\t\t\t\tint y = j / size;\n\t\t\t\t\treturn texelFetch( fadeTexture, ivec2( x, y ), 0 ).rg;\n\n\t\t\t\t}\n\n\t\t\t\t#else\n\n\t\t\t\tuniform float fadeIn;\n\t\t\t\tuniform float fadeOut;\n\n\t\t\t\t#endif\n\n\t\t\t\t#endif\n\n\t\t\t\t${n}\n\t\t\t`\n )).replace(/#include <dithering_fragment>/, (n) => (\n /* glsl */\n `\n\n\t\t\t\t${n}\n\n\t\t\t\t#if FEATURE_FADE\n\n\t\t\t\t#ifdef USE_BATCHING_FRAG\n\n\t\t\t\tvec2 fadeValues = getFadeValues( vBatchId );\n\t\t\t\tfloat fadeIn = fadeValues.r;\n\t\t\t\tfloat fadeOut = fadeValues.g;\n\n\t\t\t\t#endif\n\n\t\t\t\tfloat bayerValue = bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) );\n\t\t\t\tfloat bayerBins = 16.0;\n\t\t\t\tfloat dither = ( 0.5 + bayerValue ) / bayerBins;\n\t\t\t\tif ( dither >= fadeIn ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\tif ( dither < fadeOut ) {\n\n\t\t\t\t\tdiscard;\n\n\t\t\t\t}\n\n\t\t\t\t#endif\n\n\t\t\t`\n ));\n }, t;\n}\nclass dr {\n constructor() {\n this._fadeParams = /* @__PURE__ */ new WeakMap(), this.fading = 0;\n }\n // Set the fade parameters for the given scene\n setFade(e, t, s) {\n if (!e)\n return;\n const n = this._fadeParams;\n e.traverse((i) => {\n const r = i.material;\n if (r && n.has(r)) {\n const o = n.get(r);\n o.fadeIn.value = t, o.fadeOut.value = s;\n const u = +(!(t === 0 || t === 1) || !(s === 0 || s === 1));\n r.defines.FEATURE_FADE !== u && (this.fading += u === 1 ? 1 : -1, r.defines.FEATURE_FADE = u, r.needsUpdate = !0);\n }\n });\n }\n // initialize materials in the object\n prepareScene(e) {\n e.traverse((t) => {\n t.material && this.prepareMaterial(t.material);\n });\n }\n // delete the object from the fade, reset the material data\n deleteScene(e) {\n if (!e)\n return;\n this.setFade(e, 1, 0);\n const t = this._fadeParams;\n e.traverse((s) => {\n const n = s.material;\n n && t.delete(n);\n });\n }\n // initialize the material\n prepareMaterial(e) {\n const t = this._fadeParams;\n t.has(e) || t.set(e, wn(e, e.onBeforeCompile));\n }\n}\nclass pr {\n constructor(e, t = new _e()) {\n this.other = e, this.material = t, this.visible = !0, this.parent = null, this._instanceInfo = [], this._visibilityChanged = !0;\n const s = new Proxy(this, {\n get(n, i) {\n if (i in n)\n return n[i];\n {\n const r = e[i];\n return r instanceof Function ? (...o) => (n.syncInstances(), r.call(s, ...o)) : e[i];\n }\n },\n set(n, i, r) {\n return i in n ? n[i] = r : e[i] = r, !0;\n },\n deleteProperty(n, i) {\n return i in n ? delete n[i] : delete e[i];\n }\n // ownKeys() {},\n // has(target, key) {},\n // defineProperty(target, key, descriptor) {},\n // getOwnPropertyDescriptor(target, key) {},\n });\n return s;\n }\n syncInstances() {\n const e = this._instanceInfo, t = this.other._instanceInfo;\n for (; t.length > e.length; ) {\n const s = e.length;\n e.push(new Proxy({ visible: !1 }, {\n get(n, i) {\n return i in n ? n[i] : t[s][i];\n },\n set(n, i, r) {\n return i in n ? n[i] = r : t[s][i] = r, !0;\n }\n }));\n }\n }\n}\nclass fr extends pr {\n constructor(...e) {\n super(...e);\n const t = this.material, s = wn(t, t.onBeforeCompile);\n t.defines.FEATURE_FADE = 1, t.defines.USE_BATCHING_FRAG = 1, t.needsUpdate = !0, this.fadeTexture = null, this._fadeParams = s;\n }\n // Set the fade state\n setFadeAt(e, t, s) {\n this._initFadeTexture(), this.fadeTexture.setValueAt(e, t * 255, s * 255);\n }\n // initialize the texture and resize it if needed\n _initFadeTexture() {\n let e = Math.sqrt(this._maxInstanceCount);\n e = Math.ceil(e);\n const t = e * e * 2, s = this.fadeTexture;\n if (!s || s.image.data.length !== t) {\n const n = new Uint8Array(t), i = new mr(n, e, e, on, an);\n if (s) {\n s.dispose();\n const r = s.image.data, o = this.fadeTexture.image.data, l = Math.min(r.length, o.length);\n o.set(new r.constructor(r.buffer, 0, l));\n }\n this.fadeTexture = i, this._fadeParams.fadeTexture.value = i, i.needsUpdate = !0;\n }\n }\n // dispose the fade texture. Super cannot be used here due to proxy\n dispose() {\n this.fadeTexture && this.fadeTexture.dispose();\n }\n}\nclass mr extends Xt {\n setValueAt(e, ...t) {\n const { data: s, width: n, height: i } = this.image, r = Math.floor(s.length / (n * i));\n let o = !1;\n for (let l = 0; l < r; l++) {\n const c = e * r + l, u = s[c], h = t[l] || 0;\n u !== h && (s[c] = h, o = !0);\n }\n o && (this.needsUpdate = !0);\n }\n}\nconst Rs = Symbol(\"HAS_POPPED_IN\"), Ds = /* @__PURE__ */ new L(), Bs = /* @__PURE__ */ new L(), Os = /* @__PURE__ */ new cn(), Us = /* @__PURE__ */ new cn(), Ns = /* @__PURE__ */ new L();\nfunction gr() {\n const a = this._fadeManager, e = this.tiles;\n this._fadingBefore = a.fadeCount, this._displayActiveTiles = e.displayActiveTiles, e.displayActiveTiles = !0;\n}\nfunction yr() {\n const a = this._fadeManager, e = this._fadeMaterialManager, t = this._displayActiveTiles, s = this._fadingBefore, n = this._prevCameraTransforms, { tiles: i, maximumFadeOutTiles: r, batchedMesh: o } = this, { cameras: l } = i;\n i.displayActiveTiles = t, a.update();\n const c = a.fadeCount;\n if (s !== 0 && c !== 0 && (i.dispatchEvent({ type: \"fade-change\" }), i.dispatchEvent({ type: \"needs-render\" })), t || i.visibleTiles.forEach((u) => {\n const h = u.engineData.scene;\n h && (h.visible = u.traversal.inFrustum), this.forEachBatchIds(u, (d, m, f) => {\n m.setVisibleAt(d, u.traversal.inFrustum), f.batchedMesh.setVisibleAt(d, u.traversal.inFrustum);\n });\n }), r < this._fadingOutCount) {\n let u = !0;\n l.forEach((h) => {\n if (!n.has(h))\n return;\n const d = h.matrixWorld, m = n.get(h);\n d.decompose(Bs, Us, Ns), m.decompose(Ds, Os, Ns);\n const f = Us.angleTo(Os), p = Bs.distanceTo(Ds);\n u = u && (f > 0.25 || p > 0.1);\n }), u && a.completeAllFades();\n }\n if (l.forEach((u) => {\n n.get(u).copy(u.matrixWorld);\n }), a.forEachObject((u, { fadeIn: h, fadeOut: d }) => {\n const m = u.engineData.scene, f = a.isFadingOut(u);\n i.markTileUsed(u), m && (e.setFade(m, h, d), f && (m.visible = !0)), this.forEachBatchIds(u, (p, g, y) => {\n g.setFadeAt(p, h, d), g.setVisibleAt(p, !0), y.batchedMesh.setVisibleAt(p, !1);\n });\n }), o) {\n const u = i.getPluginByName(\"BATCHED_TILES_PLUGIN\").batchedMesh.material;\n o.material.map = u.map;\n }\n}\nclass To {\n get fadeDuration() {\n return this._fadeManager.duration;\n }\n set fadeDuration(e) {\n this._fadeManager.duration = Number(e);\n }\n get fadingTiles() {\n return this._fadeManager.fadeCount;\n }\n constructor(e) {\n e = {\n maximumFadeOutTiles: 50,\n fadeRootTiles: !1,\n fadeDuration: 250,\n ...e\n }, this.name = \"FADE_TILES_PLUGIN\", this.priority = -2, this.tiles = null, this.batchedMesh = null, this._quickFadeTiles = /* @__PURE__ */ new Set(), this._fadeManager = new hr(), this._fadeMaterialManager = new dr(), this._prevCameraTransforms = null, this._fadingOutCount = 0, this.maximumFadeOutTiles = e.maximumFadeOutTiles, this.fadeRootTiles = e.fadeRootTiles, this.fadeDuration = e.fadeDuration;\n }\n init(e) {\n this._onLoadModel = ({ scene: n }) => {\n this._fadeMaterialManager.prepareScene(n);\n }, this._onDisposeModel = ({ tile: n, scene: i }) => {\n this.tiles.visibleTiles.has(n) && this._quickFadeTiles.add(n.parent), this._fadeManager.deleteObject(n), this._fadeMaterialManager.deleteScene(i);\n }, this._onAddCamera = ({ camera: n }) => {\n this._prevCameraTransforms.set(n, new K());\n }, this._onDeleteCamera = ({ camera: n }) => {\n this._prevCameraTransforms.delete(n);\n }, this._onTileVisibilityChange = ({ tile: n, visible: i }) => {\n const r = n.engineData.scene;\n r && (r.visible = !0), this.forEachBatchIds(n, (o, l, c) => {\n l.setFadeAt(o, 0, 0), l.setVisibleAt(o, !1), c.batchedMesh.setVisibleAt(o, !1);\n });\n }, this._onUpdateBefore = () => {\n gr.call(this);\n }, this._onUpdateAfter = () => {\n yr.call(this);\n }, e.addEventListener(\"load-model\", this._onLoadModel), e.addEventListener(\"dispose-model\", this._onDisposeModel), e.addEventListener(\"add-camera\", this._onAddCamera), e.addEventListener(\"delete-camera\", this._onDeleteCamera), e.addEventListener(\"update-before\", this._onUpdateBefore), e.addEventListener(\"update-after\", this._onUpdateAfter), e.addEventListener(\"tile-visibility-change\", this._onTileVisibilityChange);\n const t = this._fadeManager;\n t.onFadeSetStart = () => {\n e.dispatchEvent({ type: \"fade-start\" }), e.dispatchEvent({ type: \"needs-render\" });\n }, t.onFadeSetComplete = () => {\n e.dispatchEvent({ type: \"fade-end\" }), e.dispatchEvent({ type: \"needs-render\" });\n }, t.onFadeComplete = (n, i) => {\n this._fadeMaterialManager.setFade(n.engineData.scene, 0, 0), this.forEachBatchIds(n, (r, o, l) => {\n o.setFadeAt(r, 0, 0), o.setVisibleAt(r, !1), l.batchedMesh.setVisibleAt(r, i);\n }), i || (e.invokeOnePlugin((r) => r !== this && r.setTileVisible && r.setTileVisible(n, !1)), this._fadingOutCount--);\n };\n const s = /* @__PURE__ */ new Map();\n e.cameras.forEach((n) => {\n s.set(n, new K());\n }), e.forEachLoadedModel((n, i) => {\n this._onLoadModel({ scene: n });\n }), this.tiles = e, this._fadeManager = t, this._prevCameraTransforms = s;\n }\n // initializes the batched mesh if it needs to be, dispose if it it's no longer needed\n initBatchedMesh() {\n var t;\n const e = (t = this.tiles.getPluginByName(\"BATCHED_TILES_PLUGIN\")) == null ? void 0 : t.batchedMesh;\n if (e) {\n if (this.batchedMesh === null) {\n this._onBatchedMeshDispose = () => {\n this.batchedMesh.dispose(), this.batchedMesh.removeFromParent(), this.batchedMesh = null, e.removeEventListener(\"dispose\", this._onBatchedMeshDispose);\n };\n const s = e.material.clone();\n s.onBeforeCompile = e.material.onBeforeCompile, this.batchedMesh = new fr(e, s), this.tiles.group.add(this.batchedMesh);\n }\n } else\n this.batchedMesh !== null && (this._onBatchedMeshDispose(), this._onBatchedMeshDispose = null);\n }\n // callback for fading to prevent tiles from being removed until the fade effect has completed\n setTileVisible(e, t) {\n const s = this._fadeManager, n = s.isFading(e);\n if (s.isFadingOut(e) && this._fadingOutCount--, t ? e.internal.depthFromRenderedParent === 1 ? ((e[Rs] || this.fadeRootTiles) && this._fadeManager.fadeIn(e), e[Rs] = !0) : this._fadeManager.fadeIn(e) : (this._fadingOutCount++, s.fadeOut(e)), this._quickFadeTiles.has(e) && (this._fadeManager.completeFade(e), this._quickFadeTiles.delete(e)), n)\n return !0;\n const i = this._fadeManager.isFading(e);\n return !!(!t && i);\n }\n dispose() {\n const e = this.tiles;\n this._fadeManager.completeAllFades(), this.batchedMesh !== null && this._onBatchedMeshDispose(), e.removeEventListener(\"load-model\", this._onLoadModel), e.removeEventListener(\"dispose-model\", this._onDisposeModel), e.removeEventListener(\"add-camera\", this._onAddCamera), e.removeEventListener(\"delete-camera\", this._onDeleteCamera), e.removeEventListener(\"update-before\", this._onUpdateBefore), e.removeEventListener(\"update-after\", this._onUpdateAfter), e.removeEventListener(\"tile-visibility-change\", this._onTileVisibilityChange), e.forEachLoadedModel((t, s) => {\n this._fadeManager.deleteObject(s), t && (t.visible = !0);\n });\n }\n // helper for iterating over the batch ids for a given tile\n forEachBatchIds(e, t) {\n if (this.initBatchedMesh(), this.batchedMesh) {\n const s = this.tiles.getPluginByName(\"BATCHED_TILES_PLUGIN\"), n = s.getTileBatchIds(e);\n n && n.forEach((i) => {\n t(i, this.batchedMesh, s);\n });\n }\n }\n}\nconst Lt = /* @__PURE__ */ new K(), Vs = /* @__PURE__ */ new L(), Fs = /* @__PURE__ */ new L();\nclass xr extends li {\n constructor(...e) {\n super(...e), this.resetDistance = 1e4, this._matricesTextureHandle = null, this._lastCameraPos = new K(), this._forceUpdate = !0, this._matrices = [];\n }\n setMatrixAt(e, t) {\n super.setMatrixAt(e, t), this._forceUpdate = !0;\n const s = this._matrices;\n for (; s.length <= e; )\n s.push(new K());\n s[e].copy(t);\n }\n setInstanceCount(...e) {\n super.setInstanceCount(...e);\n const t = this._matrices;\n for (; t.length > this.instanceCount; )\n t.pop();\n }\n onBeforeRender(e, t, s, n, i, r) {\n super.onBeforeRender(e, t, s, n, i, r), Vs.setFromMatrixPosition(s.matrixWorld), Fs.setFromMatrixPosition(this._lastCameraPos);\n const o = this._matricesTexture;\n let l = this._modelViewMatricesTexture;\n if ((!l || l.image.width !== o.image.width || l.image.height !== o.image.height) && (l && l.dispose(), l = o.clone(), l.source = new ci({\n ...l.image,\n data: l.image.data.slice()\n }), this._modelViewMatricesTexture = l), this._forceUpdate || Vs.distanceTo(Fs) > this.resetDistance) {\n const c = this._matrices, u = l.image.data;\n for (let h = 0; h < this.maxInstanceCount; h++) {\n const d = c[h];\n d ? Lt.copy(d) : Lt.identity(), Lt.premultiply(this.matrixWorld).premultiply(s.matrixWorldInverse).toArray(u, h * 16);\n }\n l.needsUpdate = !0, this._lastCameraPos.copy(s.matrixWorld), this._forceUpdate = !1;\n }\n this._matricesTextureHandle = this._matricesTexture, this._matricesTexture = this._modelViewMatricesTexture, this.matrixWorld.copy(this._lastCameraPos);\n }\n onAfterRender() {\n this.updateMatrixWorld(), this._matricesTexture = this._matricesTextureHandle, this._matricesTextureHandle = null;\n }\n onAfterShadow(e, t, s, n, i, r) {\n this.onAfterRender(e, null, n, i, r);\n }\n dispose() {\n super.dispose(), this._modelViewMatricesTexture && this._modelViewMatricesTexture.dispose();\n }\n}\nconst ee = /* @__PURE__ */ new Se(), Qe = [];\nclass Tr extends xr {\n constructor(...e) {\n super(...e), this.expandPercent = 0.25, this.maxInstanceExpansionSize = 1 / 0, this._freeGeometryIds = [];\n }\n // Finds a free id that can fit the geometry with the requested ranges. Returns -1 if it could not be found.\n findFreeId(e, t, s) {\n const n = !!this.geometry.index, i = Math.max(n ? e.index.count : -1, s), r = Math.max(e.attributes.position.count, t);\n let o = -1, l = 1 / 0;\n const c = this._freeGeometryIds;\n if (c.forEach((u, h) => {\n const d = this.getGeometryRangeAt(u), { reservedIndexCount: m, reservedVertexCount: f } = d;\n if (m >= i && f >= r) {\n const p = i - m + (r - f);\n p < l && (o = h, l = p);\n }\n }), o !== -1) {\n const u = c[o];\n return c.splice(o, 1), u;\n } else\n return -1;\n }\n // Overrides addGeometry to find an option geometry slot, expand, or optimized if needed\n addGeometry(e, t, s) {\n const n = !!this.geometry.index;\n s = Math.max(n ? e.index.count : -1, s), t = Math.max(e.attributes.position.count, t);\n const { expandPercent: i, _freeGeometryIds: r } = this;\n let o = this.findFreeId(e, t, s);\n if (o !== -1)\n this.setGeometryAt(o, e);\n else {\n const l = () => {\n const h = this.unusedVertexCount < t, d = this.unusedIndexCount < s;\n return h || d;\n }, c = e.index, u = e.attributes.position;\n if (t = Math.max(t, u.count), s = Math.max(s, c ? c.count : 0), l() && (r.forEach((h) => this.deleteGeometry(h)), r.length = 0, this.optimize(), l())) {\n const h = this.geometry.index, d = this.geometry.attributes.position;\n let m, f;\n if (h) {\n const p = Math.ceil(i * h.count);\n m = Math.max(p, s, c.count) + h.count;\n } else\n m = Math.max(this.unusedIndexCount, s);\n if (d) {\n const p = Math.ceil(i * d.count);\n f = Math.max(p, t, u.count) + d.count;\n } else\n f = Math.max(this.unusedVertexCount, t);\n this.setGeometrySize(f, m);\n }\n o = super.addGeometry(e, t, s);\n }\n return o;\n }\n // add an instance and automatically expand the number of instances if necessary\n addInstance(e) {\n if (this.maxInstanceCount === this.instanceCount) {\n const t = Math.ceil(this.maxInstanceCount * (1 + this.expandPercent));\n this.setInstanceCount(Math.min(t, this.maxInstanceExpansionSize));\n }\n return super.addInstance(e);\n }\n // delete an instance, keeping note that the geometry id is now unused\n deleteInstance(e) {\n const t = this.getGeometryIdAt(e);\n return t !== -1 && this._freeGeometryIds.push(t), super.deleteInstance(e);\n }\n // add a function for raycasting per tile\n raycastInstance(e, t, s) {\n const n = this.geometry, i = this.getGeometryIdAt(e);\n ee.material = this.material, ee.geometry.index = n.index, ee.geometry.attributes = n.attributes;\n const r = this.getGeometryRangeAt(i);\n ee.geometry.setDrawRange(r.start, r.count), ee.geometry.boundingBox === null && (ee.geometry.boundingBox = new pt()), ee.geometry.boundingSphere === null && (ee.geometry.boundingSphere = new pe()), this.getMatrixAt(e, ee.matrixWorld).premultiply(this.matrixWorld), this.getBoundingBoxAt(i, ee.geometry.boundingBox), this.getBoundingSphereAt(i, ee.geometry.boundingSphere), ee.raycast(t, Qe);\n for (let o = 0, l = Qe.length; o < l; o++) {\n const c = Qe[o];\n c.object = this, c.batchId = e, s.push(c);\n }\n Qe.length = 0;\n }\n}\nfunction br(a) {\n return a.r === 1 && a.g === 1 && a.b === 1;\n}\nfunction _r(a) {\n a.needsUpdate = !0, a.onBeforeCompile = (e) => {\n e.vertexShader = e.vertexShader.replace(\n \"#include <common>\",\n /* glsl */\n `\n\t\t\t\t#include <common>\n\t\t\t\tvarying float texture_index;\n\t\t\t\t`\n ).replace(\n \"#include <uv_vertex>\",\n /* glsl */\n `\n\t\t\t\t#include <uv_vertex>\n\t\t\t\ttexture_index = getIndirectIndex( gl_DrawID );\n\t\t\t\t`\n ), e.fragmentShader = e.fragmentShader.replace(\n \"#include <map_pars_fragment>\",\n /* glsl */\n `\n\t\t\t\t#ifdef USE_MAP\n\t\t\t\tprecision highp sampler2DArray;\n\t\t\t\tuniform sampler2DArray map;\n\t\t\t\tvarying float texture_index;\n\t\t\t\t#endif\n\t\t\t\t`\n ).replace(\n \"#include <map_fragment>\",\n /* glsl */\n `\n\t\t\t\t#ifdef USE_MAP\n\t\t\t\t\tdiffuseColor *= texture( map, vec3( vMapUv, texture_index ) );\n\t\t\t\t#endif\n\t\t\t\t`\n );\n };\n}\nconst Et = new mn(new _e()), zt = new Xt(new Uint8Array([255, 255, 255, 255]), 1, 1);\nzt.needsUpdate = !0;\nclass bo {\n constructor(e = {}) {\n if (parseInt(ui) < 170)\n throw new Error(\"BatchedTilesPlugin: Three.js revision 170 or higher required.\");\n e = {\n instanceCount: 500,\n vertexCount: 750,\n indexCount: 2e3,\n expandPercent: 0.25,\n maxInstanceCount: 1 / 0,\n discardOriginalContent: !0,\n textureSize: null,\n material: null,\n renderer: null,\n ...e\n }, this.name = \"BATCHED_TILES_PLUGIN\", this.priority = -1;\n const t = e.renderer.getContext();\n this.instanceCount = e.instanceCount, this.vertexCount = e.vertexCount, this.indexCount = e.indexCount, this.material = e.material ? e.material.clone() : null, this.expandPercent = e.expandPercent, this.maxInstanceCount = Math.min(e.maxInstanceCount, t.getParameter(t.MAX_3D_TEXTURE_SIZE)), this.renderer = e.renderer, this.discardOriginalContent = e.discardOriginalContent, this.textureSize = e.textureSize, this.batchedMesh = null, this.arrayTarget = null, this.tiles = null, this._tileToInstanceId = /* @__PURE__ */ new Map();\n }\n init(e) {\n this.tiles = e;\n }\n initTextureArray(e) {\n if (this.arrayTarget !== null || e.material.map === null)\n return;\n const { instanceCount: t, renderer: s, textureSize: n, batchedMesh: i } = this, r = e.material.map, o = {\n colorSpace: r.colorSpace,\n wrapS: r.wrapS,\n wrapT: r.wrapT,\n wrapR: r.wrapS,\n // TODO: Generating mipmaps for the volume every time a new texture is added is extremely slow\n // generateMipmaps: map.generateMipmaps,\n // minFilter: map.minFilter,\n magFilter: r.magFilter\n }, l = new is(n || r.image.width, n || r.image.height, t);\n Object.assign(l.texture, o), s.initRenderTarget(l), i.material.map = l.texture, this.arrayTarget = l, this._tileToInstanceId.forEach((c) => {\n c.forEach((u) => {\n this.assignTextureToLayer(zt, u);\n });\n });\n }\n // init the batched mesh if it's not ready\n initBatchedMesh(e) {\n if (this.batchedMesh !== null)\n return;\n const { instanceCount: t, vertexCount: s, indexCount: n, tiles: i } = this, r = this.material ? this.material : new e.material.constructor(), o = new Tr(t, t * s, t * n, r);\n o.name = \"BatchTilesPlugin\", o.frustumCulled = !1, i.group.add(o), o.updateMatrixWorld(), _r(o.material), this.batchedMesh = o;\n }\n setTileVisible(e, t) {\n const s = e.engineData.scene;\n if (t && this.addSceneToBatchedMesh(s, e), this._tileToInstanceId.has(e)) {\n this._tileToInstanceId.get(e).forEach((r) => {\n this.batchedMesh.setVisibleAt(r, t);\n });\n const i = this.tiles;\n return t ? i.visibleTiles.add(e) : i.visibleTiles.delete(e), i.dispatchEvent({\n type: \"tile-visibility-change\",\n scene: s,\n tile: e,\n visible: t\n }), !0;\n }\n return !1;\n }\n disposeTile(e) {\n this.removeSceneFromBatchedMesh(e);\n }\n unloadTileFromGPU(e, t) {\n return !this.discardOriginalContent && this._tileToInstanceId.has(t) ? (this.removeSceneFromBatchedMesh(t), !0) : !1;\n }\n // render the given into the given layer\n assignTextureToLayer(e, t) {\n if (!this.arrayTarget)\n return;\n this.expandArrayTargetIfNeeded();\n const { renderer: s } = this, n = s.getRenderTarget();\n s.setRenderTarget(this.arrayTarget, t), Et.material.map = e, Et.render(s), s.setRenderTarget(n), Et.material.map = null, e.dispose();\n }\n // check if the array texture target needs to be expanded\n expandArrayTargetIfNeeded() {\n const { batchedMesh: e, arrayTarget: t, renderer: s } = this, n = Math.min(e.maxInstanceCount, this.maxInstanceCount);\n if (n > t.depth) {\n const i = {\n colorSpace: t.texture.colorSpace,\n wrapS: t.texture.wrapS,\n wrapT: t.texture.wrapT,\n generateMipmaps: t.texture.generateMipmaps,\n minFilter: t.texture.minFilter,\n magFilter: t.texture.magFilter\n }, r = new is(t.width, t.height, n);\n Object.assign(r.texture, i), s.initRenderTarget(r), s.copyTextureToTexture(t.texture, r.texture), t.dispose(), e.material.map = r.texture, this.arrayTarget = r;\n }\n }\n removeSceneFromBatchedMesh(e) {\n if (this._tileToInstanceId.has(e)) {\n const t = this._tileToInstanceId.get(e);\n this._tileToInstanceId.delete(e), t.forEach((s) => {\n this.batchedMesh.deleteInstance(s);\n });\n }\n }\n addSceneToBatchedMesh(e, t) {\n if (this._tileToInstanceId.has(t))\n return;\n const s = [];\n e.traverse((r) => {\n r.isMesh && s.push(r);\n });\n let n = !0;\n s.forEach((r) => {\n if (this.batchedMesh && n) {\n const o = r.geometry.attributes, l = this.batchedMesh.geometry.attributes;\n for (const c in l)\n if (!(c in o)) {\n n = !1;\n return;\n }\n }\n });\n const i = !this.batchedMesh || this.batchedMesh.instanceCount + s.length <= this.maxInstanceCount;\n if (n && i) {\n e.updateMatrixWorld();\n const r = [];\n this._tileToInstanceId.set(t, r), s.forEach((o) => {\n this.initBatchedMesh(o), this.initTextureArray(o);\n const { geometry: l, material: c } = o, { batchedMesh: u, expandPercent: h } = this;\n u.expandPercent = h;\n const d = u.addGeometry(l, this.vertexCount, this.indexCount), m = u.addInstance(d);\n r.push(m), u.setMatrixAt(m, o.matrixWorld), u.setVisibleAt(m, !1), br(c.color) || (c.color.setHSL(Math.random(), 0.5, 0.5), u.setColorAt(m, c.color));\n const f = c.map;\n f ? this.assignTextureToLayer(f, m) : this.assignTextureToLayer(zt, m);\n }), this.discardOriginalContent && (t.engineData.textures.forEach((o) => {\n o.image instanceof ImageBitmap && o.image.close();\n }), t.engineData.scene = null, t.engineData.materials = [], t.engineData.geometries = [], t.engineData.textures = []);\n }\n }\n // Override raycasting per tile to defer to the batched mesh\n raycastTile(e, t, s, n) {\n return this._tileToInstanceId.has(e) ? (this._tileToInstanceId.get(e).forEach((r) => {\n this.batchedMesh.raycastInstance(r, s, n);\n }), !0) : !1;\n }\n dispose() {\n const { arrayTarget: e, batchedMesh: t } = this;\n e && e.dispose(), t && (t.material.dispose(), t.geometry.dispose(), t.dispose(), t.removeFromParent());\n }\n getTileBatchIds(e) {\n return this._tileToInstanceId.get(e);\n }\n}\nconst wt = /* @__PURE__ */ new pe(), Ze = /* @__PURE__ */ new L(), De = /* @__PURE__ */ new K(), ks = /* @__PURE__ */ new K(), Pt = /* @__PURE__ */ new hi(), Sr = /* @__PURE__ */ new _e({ side: rt }), Gs = /* @__PURE__ */ new pt(), Rt = 1e5;\nfunction zs(a, e) {\n return a.isBufferGeometry ? (a.boundingSphere === null && a.computeBoundingSphere(), e.copy(a.boundingSphere)) : (Gs.setFromObject(a), Gs.getBoundingSphere(e), e);\n}\nclass _o {\n constructor() {\n this.name = \"TILE_FLATTENING_PLUGIN\", this.priority = -100, this.tiles = null, this.shapes = /* @__PURE__ */ new Map(), this.positionsMap = /* @__PURE__ */ new Map(), this.positionsUpdated = /* @__PURE__ */ new Set(), this.needsUpdate = !1;\n }\n init(e) {\n this.tiles = e, this.needsUpdate = !0, this._updateBeforeCallback = () => {\n this.needsUpdate && (this._updateTiles(), this.needsUpdate = !1);\n }, this._disposeModelCallback = ({ tile: t }) => {\n this.positionsMap.delete(t), this.positionsUpdated.delete(t);\n }, e.addEventListener(\"update-before\", this._updateBeforeCallback), e.addEventListener(\"dispose-model\", this._disposeModelCallback);\n }\n // update tile flattening state if it has not been made visible, yet\n setTileActive(e, t) {\n t && !this.positionsUpdated.has(e) && this._updateTile(e);\n }\n _updateTile(e) {\n const { positionsUpdated: t, positionsMap: s, shapes: n, tiles: i } = this;\n t.add(e);\n const r = e.engineData.scene;\n if (s.has(e)) {\n const o = s.get(e);\n r.traverse((l) => {\n if (l.geometry) {\n const c = o.get(l.geometry);\n c && (l.geometry.attributes.position.array.set(c), l.geometry.attributes.position.needsUpdate = !0);\n }\n });\n } else {\n const o = /* @__PURE__ */ new Map();\n s.set(e, o), r.traverse((l) => {\n l.geometry && o.set(l.geometry, l.geometry.attributes.position.array.slice());\n });\n }\n r.updateMatrixWorld(!0), r.traverse((o) => {\n const { geometry: l } = o;\n l && (De.copy(o.matrixWorld), r.parent !== null && De.premultiply(i.group.matrixWorldInverse), ks.copy(De).invert(), zs(l, wt).applyMatrix4(De), n.forEach(({\n shape: c,\n direction: u,\n sphere: h,\n thresholdMode: d,\n threshold: m,\n flattenRange: f\n }) => {\n Ze.subVectors(wt.center, h.center), Ze.addScaledVector(u, -u.dot(Ze));\n const p = (wt.radius + h.radius) ** 2;\n if (Ze.lengthSq() > p)\n return;\n const { position: g } = l.attributes, { ray: y } = Pt;\n y.direction.copy(u).multiplyScalar(-1);\n for (let x = 0, b = g.count; x < b; x++) {\n y.origin.fromBufferAttribute(g, x).applyMatrix4(De).addScaledVector(u, Rt), Pt.far = Rt;\n const T = Pt.intersectObject(c)[0];\n if (T) {\n let M = (Rt - T.distance) / m;\n const S = M >= 1;\n (!S || S && d === \"flatten\") && (M = Math.min(M, 1), T.point.addScaledVector(y.direction, _.mapLinear(M, 0, 1, -f, 0)), T.point.applyMatrix4(ks), g.setXYZ(x, ...T.point));\n }\n }\n }));\n }), this.tiles.dispatchEvent({ type: \"needs-render\" });\n }\n _updateTiles() {\n this.positionsUpdated.clear(), this.tiles.activeTiles.forEach((e) => this._updateTile(e));\n }\n /**\n * Returns whether the given object has already been added as a shape.\n * @param {Object3D} mesh\n * @returns {boolean}\n */\n hasShape(e) {\n return this.shapes.has(e);\n }\n /**\n * Adds the given mesh as a flattening shape. All coordinates must be in the tileset's local\n * frame. Throws if the shape has already been added.\n * @param {Object3D} mesh The shape mesh to flatten tile vertices onto.\n * @param {Vector3} [direction] Direction to cast rays when flattening (default downward along -Z).\n * @param {Object} [options]\n * @param {number} [options.threshold=Infinity] Maximum distance from the shape surface within which vertices are flattened. `Infinity` always flattens; `0` never flattens.\n */\n addShape(e, t = new L(0, 0, -1), s = {}) {\n if (this.hasShape(e))\n throw new Error(\"TileFlatteningPlugin: Shape is already used.\");\n typeof s == \"number\" && (console.warn('TileFlatteningPlugin: \"addShape\" function signature has changed. Please use an options object, instead.'), s = {\n threshold: s\n }), this.needsUpdate = !0;\n const n = e.clone();\n n.updateMatrixWorld(!0), n.traverse((r) => {\n r.material && (r.material = Sr);\n });\n const i = zs(n, new pe());\n this.shapes.set(e, {\n shape: n,\n direction: t.clone(),\n sphere: i,\n // \"flatten\": Flattens the vertices above the shape\n // \"none\": leaves the vertices above the shape as they are\n thresholdMode: \"none\",\n // only flatten within this range above the object\n threshold: 1 / 0,\n // the range to flatten vertices in to. 0 is completely flat\n // while 0.1 means a 10cm range.\n flattenRange: 0,\n ...s\n });\n }\n /**\n * Notifies the plugin that a shape's geometry or transform has changed and tile\n * flattening needs to be regenerated.\n * @param {Object3D} mesh\n */\n updateShape(e) {\n if (!this.hasShape(e))\n throw new Error(\"TileFlatteningPlugin: Shape is not present.\");\n const { direction: t, threshold: s, thresholdMode: n, flattenRange: i } = this.shapes.get(e);\n this.deleteShape(e), this.addShape(e, t, {\n threshold: s,\n thresholdMode: n,\n flattenRange: i\n });\n }\n /**\n * Removes the given shape and triggers tile regeneration.\n * @param {Object3D} mesh\n * @returns {boolean} `true` if the shape was found and removed.\n */\n deleteShape(e) {\n return this.needsUpdate = !0, this.shapes.delete(e);\n }\n /**\n * Removes all shapes and resets flattened tiles to their original positions.\n */\n clearShapes() {\n this.shapes.size !== 0 && (this.needsUpdate = !0, this.shapes.clear());\n }\n // reset the vertex positions and remove the update callback\n dispose() {\n this.tiles.removeEventListener(\"before-update\", this._updateBeforeCallback), this.tiles.removeEventListener(\"dispose-model\", this._disposeModelCallback), this.positionsMap.forEach((e) => {\n e.forEach((t, s) => {\n const { position: n } = s.attributes;\n n.array.set(t), n.needsUpdate = !0;\n });\n });\n }\n}\nclass Mr extends ze {\n constructor(e = {}) {\n const {\n subdomains: t = [\"t0\"],\n ...s\n } = e;\n super(s), this.subdomains = t, this.subDomainIndex = 0;\n }\n getUrl(e, t, s) {\n return this.url.replace(/{\\s*subdomain\\s*}/gi, this._getSubdomain()).replace(/{\\s*quadkey\\s*}/gi, this._tileToQuadKey(e, t, s));\n }\n _tileToQuadKey(e, t, s) {\n let n = \"\";\n for (let i = s; i > 0; i--) {\n let r = 0;\n const o = 1 << i - 1;\n (e & o) !== 0 && (r += 1), (t & o) !== 0 && (r += 2), n += r.toString();\n }\n return n;\n }\n _getSubdomain() {\n return this.subDomainIndex = (this.subDomainIndex + 1) % this.subdomains.length, this.subdomains[this.subDomainIndex];\n }\n}\nfunction Dt(a, e, t, s) {\n let [n, i, r, o] = a;\n i += 1e-8, n += 1e-8, o -= 1e-8, r -= 1e-8;\n const l = Math.max(Math.min(e, t.maxLevel), t.minLevel), [c, u, h, d] = t.getTilesInRange(n, i, r, o, l, !0);\n for (let m = c; m <= h; m++)\n for (let f = u; f <= d; f++)\n s(m, f, l);\n}\nfunction Cr(a, e, t) {\n const s = new L(), n = {}, i = [], r = a.getAttribute(\"position\");\n a.computeBoundingBox(), a.boundingBox.getCenter(s).applyMatrix4(e), t.getPositionToCartographic(s, n);\n const o = n.lat, l = n.lon;\n let c = 1 / 0, u = 1 / 0, h = 1 / 0, d = -1 / 0, m = -1 / 0, f = -1 / 0;\n for (let y = 0; y < r.count; y++)\n s.fromBufferAttribute(r, y).applyMatrix4(e), t.getPositionToCartographic(s, n), Math.abs(Math.abs(n.lat) - Math.PI / 2) < 1e-5 && (n.lon = l), Math.abs(l - n.lon) > Math.PI && (n.lon += Math.sign(l - n.lon) * Math.PI * 2), Math.abs(o - n.lat) > Math.PI && (n.lat += Math.sign(o - n.lat) * Math.PI * 2), i.push(n.lon, n.lat, n.height), c = Math.min(c, n.lat), d = Math.max(d, n.lat), u = Math.min(u, n.lon), m = Math.max(m, n.lon), h = Math.min(h, n.height), f = Math.max(f, n.height);\n const p = [u, c, m, d], g = [...p, h, f];\n return {\n uv: i,\n range: p,\n region: g\n };\n}\nfunction Hs(a, e, t = null, s = null) {\n let n = 1 / 0, i = 1 / 0, r = 1 / 0, o = -1 / 0, l = -1 / 0, c = -1 / 0;\n const u = [], h = new K();\n a.forEach((m) => {\n h.copy(m.matrixWorld), t && h.premultiply(t);\n const { uv: f, region: p } = Cr(m.geometry, h, e);\n u.push(f), n = Math.min(n, p[1]), o = Math.max(o, p[3]), i = Math.min(i, p[0]), l = Math.max(l, p[2]), r = Math.min(r, p[4]), c = Math.max(c, p[5]);\n });\n let d = [i, n, l, o];\n if (s !== null) {\n d = s.clampToBounds([i, n, l, o]);\n const [m, f, p, g] = s.toNormalizedRange(d);\n u.forEach((y) => {\n for (let x = 0, b = y.length; x < b; x += 3) {\n const T = y[x + 0], M = y[x + 1], S = y[x + 2], [C, v] = s.toNormalizedPoint(T, M);\n y[x + 0] = _.mapLinear(C, m, p, 0, 1), y[x + 1] = _.mapLinear(v, f, g, 0, 1), y[x + 2] = _.mapLinear(S, r, c, 0, 1);\n }\n });\n }\n return {\n uvs: u,\n range: d,\n region: [i, n, l, o, r, c]\n };\n}\nfunction Ar(a, e) {\n const t = new L(), s = [], n = a.getAttribute(\"position\");\n let i = 1 / 0, r = 1 / 0, o = 1 / 0, l = -1 / 0, c = -1 / 0, u = -1 / 0;\n for (let d = 0; d < n.count; d++)\n t.fromBufferAttribute(n, d).applyMatrix4(e), s.push(t.x, t.y, t.z), i = Math.min(i, t.x), l = Math.max(l, t.x), r = Math.min(r, t.y), c = Math.max(c, t.y), o = Math.min(o, t.z), u = Math.max(u, t.z);\n return {\n uv: s,\n range: [i, r, l, c],\n heightRange: [o, u]\n };\n}\nfunction Ir(a, e) {\n let t = 1 / 0, s = 1 / 0, n = 1 / 0, i = -1 / 0, r = -1 / 0, o = -1 / 0;\n const l = [], c = new K();\n return a.forEach((u) => {\n c.copy(u.matrixWorld), e && c.premultiply(e);\n const { uv: h, range: d, heightRange: m } = Ar(u.geometry, c);\n l.push(h), t = Math.min(t, d[0]), i = Math.max(i, d[2]), s = Math.min(s, d[1]), r = Math.max(r, d[3]), n = Math.min(n, m[0]), o = Math.max(o, m[1]);\n }), l.forEach((u) => {\n for (let h = 0, d = u.length; h < d; h += 3) {\n const m = u[h + 0], f = u[h + 1];\n u[h + 0] = _.mapLinear(m, t, i, 0, 1), u[h + 1] = _.mapLinear(f, s, r, 0, 1);\n }\n }), {\n uvs: l,\n range: [t, s, i, r],\n heightRange: [n, o]\n };\n}\nconst Bt = Symbol(\"OVERLAY_PARAMS\");\nfunction vr(a, e) {\n if (a[Bt])\n return a[Bt];\n const t = {\n layerMaps: { value: [] },\n layerInfo: { value: [] }\n };\n return a[Bt] = t, a.defines = {\n ...a.defines || {},\n LAYER_COUNT: 0\n }, a.onBeforeCompile = (s) => {\n e && e(s), s.uniforms = {\n ...s.uniforms,\n ...t\n }, s.vertexShader = s.vertexShader.replace(/void main\\(\\s*\\)\\s*{/, (n) => (\n /* glsl */\n `\n\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\tfor ( int i = 0; i < 10; i ++ ) {\n\n\t\t\t\t\t\t#if UNROLLED_LOOP_INDEX < LAYER_COUNT\n\n\t\t\t\t\t\t\tattribute vec3 layer_uv_UNROLLED_LOOP_INDEX;\n\t\t\t\t\t\t\tvarying vec3 v_layer_uv_UNROLLED_LOOP_INDEX;\n\n\t\t\t\t\t\t#endif\n\n\n\t\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t${n}\n\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\tfor ( int i = 0; i < 10; i ++ ) {\n\n\t\t\t\t\t\t#if UNROLLED_LOOP_INDEX < LAYER_COUNT\n\n\t\t\t\t\t\t\tv_layer_uv_UNROLLED_LOOP_INDEX = layer_uv_UNROLLED_LOOP_INDEX;\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t`\n )), s.fragmentShader = s.fragmentShader.replace(/void main\\(/, (n) => (\n /* glsl */\n `\n\n\t\t\t\t#if LAYER_COUNT != 0\n\t\t\t\t\tstruct LayerInfo {\n\t\t\t\t\t\tvec3 color;\n\t\t\t\t\t\tfloat opacity;\n\n\t\t\t\t\t\tint alphaMask;\n\t\t\t\t\t\tint alphaInvert;\n\t\t\t\t\t};\n\n\t\t\t\t\tuniform sampler2D layerMaps[ LAYER_COUNT ];\n\t\t\t\t\tuniform LayerInfo layerInfo[ LAYER_COUNT ];\n\t\t\t\t#endif\n\n\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\tfor ( int i = 0; i < 10; i ++ ) {\n\n\t\t\t\t\t\t#if UNROLLED_LOOP_INDEX < LAYER_COUNT\n\n\t\t\t\t\t\t\tvarying vec3 v_layer_uv_UNROLLED_LOOP_INDEX;\n\n\t\t\t\t\t\t#endif\n\n\t\t\t\t\t}\n\t\t\t\t#pragma unroll_loop_end\n\n\t\t\t\t${n}\n\n\t\t\t`\n )).replace(/#include <color_fragment>/, (n) => (\n /* glsl */\n `\n\n\t\t\t\t${n}\n\n\t\t\t\t#if LAYER_COUNT != 0\n\t\t\t\t{\n\t\t\t\t\tvec4 tint;\n\t\t\t\t\tvec3 layerUV;\n\t\t\t\t\tfloat layerOpacity;\n\t\t\t\t\tfloat wOpacity;\n\t\t\t\t\tfloat wDelta;\n\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < 10; i ++ ) {\n\n\t\t\t\t\t\t\t#if UNROLLED_LOOP_INDEX < LAYER_COUNT\n\n\t\t\t\t\t\t\t\tlayerUV = v_layer_uv_UNROLLED_LOOP_INDEX;\n\t\t\t\t\t\t\t\ttint = texture( layerMaps[ i ], layerUV.xy );\n\n\t\t\t\t\t\t\t\t// discard texture outside 0, 1 on w - offset the stepped value by an epsilon to avoid cases\n\t\t\t\t\t\t\t\t// where wDelta is near 0 (eg a flat surface) at the w boundary, resulting in artifacts on some\n\t\t\t\t\t\t\t\t// hardware.\n\t\t\t\t\t\t\t\twDelta = max( fwidth( layerUV.z ), 1e-7 );\n\t\t\t\t\t\t\t\twOpacity =\n\t\t\t\t\t\t\t\t\tsmoothstep( - wDelta, 0.0, layerUV.z ) *\n\t\t\t\t\t\t\t\t\tsmoothstep( 1.0 + wDelta, 1.0, layerUV.z );\n\n\t\t\t\t\t\t\t\t// apply tint & opacity\n\t\t\t\t\t\t\t\ttint.rgb *= layerInfo[ i ].color;\n\t\t\t\t\t\t\t\ttint.rgba *= layerInfo[ i ].opacity * wOpacity;\n\n\t\t\t\t\t\t\t\t// invert the alpha\n\t\t\t\t\t\t\t\tif ( layerInfo[ i ].alphaInvert > 0 ) {\n\n\t\t\t\t\t\t\t\t\ttint.a = 1.0 - tint.a;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t// apply the alpha across all existing layers if alpha mask is true\n\t\t\t\t\t\t\t\tif ( layerInfo[ i ].alphaMask > 0 ) {\n\n\t\t\t\t\t\t\t\t\tdiffuseColor.a *= tint.a;\n\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\ttint.rgb *= tint.a;\n\t\t\t\t\t\t\t\t\tdiffuseColor = tint + diffuseColor * ( 1.0 - tint.a );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t#endif\n\n\t\t\t\t\t\t}\n\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t}\n\t\t\t\t#endif\n\t\t\t`\n ));\n }, t;\n}\nclass Pn {\n constructor() {\n this.canvas = null, this.context = null, this.range = [0, 0, 1, 1];\n }\n // set the target render texture and the range that represents the full span\n setTarget(e, t) {\n this.canvas = e.image, this.context = e.image.getContext(\"2d\"), this.range = [...t];\n }\n // draw the given texture at the given span with the provided projection\n draw(e, t) {\n const { canvas: s, range: n, context: i } = this, { width: r, height: o } = s, { image: l } = e, c = Math.round(_.mapLinear(t[0], n[0], n[2], 0, r)), u = Math.round(_.mapLinear(t[1], n[1], n[3], 0, o)), h = Math.round(_.mapLinear(t[2], n[0], n[2], 0, r)), d = Math.round(_.mapLinear(t[3], n[1], n[3], 0, o)), m = h - c, f = d - u;\n l instanceof ImageBitmap ? (i.save(), i.translate(c, o - u), i.scale(1, -1), i.drawImage(l, 0, 0, m, f), i.restore()) : i.drawImage(l, c, o - u, m, -f);\n }\n // clear the set target\n clear() {\n const { context: e, canvas: t } = this;\n e.clearRect(0, 0, t.width, t.height);\n }\n}\nclass Rn extends Tn {\n hasContent(...e) {\n return !0;\n }\n}\nclass Lr extends Rn {\n constructor(e) {\n super(), this.tiledImageSource = e, this.tileComposer = new Pn(), this.resolution = 256;\n }\n hasContent(e, t, s, n, i) {\n const r = this.tiledImageSource.tiling;\n let o = 0;\n return Dt([e, t, s, n], i, r, () => {\n o++;\n }), o !== 0;\n }\n async fetchItem([e, t, s, n, i], r) {\n const o = [e, t, s, n], l = this.tiledImageSource, c = this.tileComposer, u = l.tiling, h = document.createElement(\"canvas\");\n h.width = this.resolution, h.height = this.resolution;\n const d = new $t(h);\n return d.colorSpace = jt, d.generateMipmaps = !1, d.tokens = [...o, i], await this._markImages(o, i, !1), c.setTarget(d, o), c.clear(16777215, 0), Dt(o, i, u, (m, f, p) => {\n const g = u.getTileBounds(m, f, p, !0, !1), y = l.get(m, f, p);\n c.draw(y, g);\n }), d;\n }\n disposeItem(e) {\n e.dispose();\n const [t, s, n, i, r] = e.tokens;\n this._markImages([t, s, n, i], r, !0);\n }\n dispose() {\n super.dispose(), this.tiledImageSource.dispose();\n }\n _markImages(e, t, s = !1) {\n const n = this.tiledImageSource, i = n.tiling, r = [];\n Dt(e, t, i, (l, c, u) => {\n s ? n.release(l, c, u) : r.push(n.lock(l, c, u));\n });\n const o = r.filter((l) => l instanceof Promise);\n return o.length !== 0 ? Promise.all(o) : null;\n }\n}\nconst Ot = /* @__PURE__ */ new L(), Je = /* @__PURE__ */ new L();\nfunction Er(a, e, t) {\n a.getCartographicToPosition(e, t, 0, Ot), a.getCartographicToPosition(e + 0.01, t, 0, Je);\n const n = Ot.distanceTo(Je);\n return a.getCartographicToPosition(e, t + 0.01, 0, Je), Ot.distanceTo(Je) / n;\n}\nclass wr extends Rn {\n constructor({\n geojson: e = null,\n url: t = null,\n // URL or GeoJson object can be provided\n resolution: s = 256,\n pointRadius: n = 6,\n strokeStyle: i = \"white\",\n strokeWidth: r = 2,\n fillStyle: o = \"rgba( 255, 255, 255, 0.5 )\",\n ...l\n } = {}) {\n super(l), this.geojson = e, this.url = t, this.resolution = s, this.pointRadius = n, this.strokeStyle = i, this.strokeWidth = r, this.fillStyle = o, this.features = null, this.featureBounds = /* @__PURE__ */ new Map(), this.contentBounds = null, this.projection = new re(), this.fetchData = (...c) => fetch(...c);\n }\n async init() {\n const { geojson: e, url: t } = this;\n if (!e && t) {\n const s = await this.fetchData(t);\n this.geojson = await s.json();\n }\n this._updateCache(!0);\n }\n hasContent(e, t, s, n) {\n const i = [e, t, s, n].map((r) => r * Math.RAD2DEG);\n return this._boundsIntersectBounds(i, this.contentBounds);\n }\n // main fetch per region -> returns CanvasTexture\n async fetchItem(e, t) {\n const s = document.createElement(\"canvas\"), n = new $t(s);\n return n.colorSpace = jt, n.generateMipmaps = !1, this._drawToCanvas(s, e), n.needsUpdate = !0, n;\n }\n disposeItem(e) {\n e.dispose();\n }\n redraw() {\n this._updateCache(!0), this.forEachItem((e, t) => {\n this._drawToCanvas(e.image, t), e.needsUpdate = !0;\n });\n }\n _updateCache(e = !1) {\n const { geojson: t, featureBounds: s } = this;\n if (!t || this.features && !e)\n return;\n s.clear();\n let n = 1 / 0, i = 1 / 0, r = -1 / 0, o = -1 / 0;\n this.features = this._featuresFromGeoJSON(t), this.features.forEach((l) => {\n const c = this._getFeatureBounds(l);\n s.set(l, c);\n const [u, h, d, m] = c;\n n = Math.min(n, u), i = Math.min(i, h), r = Math.max(r, d), o = Math.max(o, m);\n }), this.contentBounds = [n, i, r, o];\n }\n _drawToCanvas(e, t) {\n this._updateCache();\n const [s, n, i, r] = t, { projection: o, resolution: l, features: c } = this;\n e.width = l, e.height = l;\n const u = o.convertNormalizedToLongitude(s), h = o.convertNormalizedToLatitude(n), d = o.convertNormalizedToLongitude(i), m = o.convertNormalizedToLatitude(r), f = [\n u * _.RAD2DEG,\n h * _.RAD2DEG,\n d * _.RAD2DEG,\n m * _.RAD2DEG\n ], p = e.getContext(\"2d\");\n for (let g = 0; g < c.length; g++) {\n const y = c[g];\n this._featureIntersectsTile(y, f) && this._drawFeatureOnCanvas(p, y, f, e.width, e.height);\n }\n }\n // bounding box quick test in projected units\n _featureIntersectsTile(e, t) {\n const s = this.featureBounds.get(e);\n return s ? this._boundsIntersectBounds(s, t) : !1;\n }\n _boundsIntersectBounds(e, t) {\n const [s, n, i, r] = e, [o, l, c, u] = t;\n return !(i < o || s > c || r < l || n > u);\n }\n _getFeatureBounds(e) {\n const { geometry: t } = e;\n if (!t)\n return null;\n const { type: s, coordinates: n } = t;\n let i = 1 / 0, r = 1 / 0, o = -1 / 0, l = -1 / 0;\n const c = (u, h) => {\n i = Math.min(i, u), o = Math.max(o, u), r = Math.min(r, h), l = Math.max(l, h);\n };\n return s === \"Point\" ? c(n[0], n[1]) : s === \"MultiPoint\" || s === \"LineString\" ? n.forEach((u) => c(u[0], u[1])) : s === \"MultiLineString\" || s === \"Polygon\" ? n.forEach((u) => u.forEach((h) => c(h[0], h[1]))) : s === \"MultiPolygon\" && n.forEach(\n (u) => u.forEach((h) => h.forEach((d) => c(d[0], d[1])))\n ), [i, r, o, l];\n }\n // Normalize top-level geojson into an array of Feature objects\n _featuresFromGeoJSON(e) {\n const t = e.type, s = /* @__PURE__ */ new Set([\"Point\", \"MultiPoint\", \"LineString\", \"MultiLineString\", \"Polygon\", \"MultiPolygon\"]);\n return t === \"FeatureCollection\" ? e.features : t === \"Feature\" ? [e] : t === \"GeometryCollection\" ? e.geometries.map((n) => ({ type: \"Feature\", geometry: n, properties: {} })) : s.has(t) ? [{ type: \"Feature\", geometry: e, properties: {} }] : [];\n }\n // draw feature on canvas ( assumes intersects already )\n _drawFeatureOnCanvas(e, t, s, n, i) {\n const { geometry: r = null, properties: o = {} } = t;\n if (!r)\n return;\n const [l, c, u, h] = s, d = o.strokeStyle || this.strokeStyle, m = o.fillStyle || this.fillStyle, f = o.pointRadius || this.pointRadius, p = o.strokeWidth || this.strokeWidth;\n e.save(), e.strokeStyle = d, e.fillStyle = m, e.lineWidth = p;\n const g = new Array(2), y = (T, M, S = g) => {\n const C = _.mapLinear(T, l, u, 0, n), v = i - _.mapLinear(M, c, h, 0, i);\n return S[0] = Math.round(C), S[1] = Math.round(v), S;\n }, x = (T, M) => {\n const S = M * _.DEG2RAD, C = T * _.DEG2RAD, v = (h - c) / i;\n return (u - l) / n / v * Er(Ti, S, C);\n }, b = r.type;\n if (b === \"Point\") {\n const [T, M] = r.coordinates, [S, C] = y(T, M), v = x(T, M);\n e.beginPath(), e.ellipse(S, C, f / v, f, 0, 0, Math.PI * 2), e.fill(), e.stroke();\n } else b === \"MultiPoint\" ? r.coordinates.forEach(([T, M]) => {\n const [S, C] = y(T, M), v = x(T, M);\n e.beginPath(), e.ellipse(S, C, f / v, f, 0, 0, Math.PI * 2), e.fill(), e.stroke();\n }) : b === \"LineString\" ? (e.beginPath(), r.coordinates.forEach(([T, M], S) => {\n const [C, v] = y(T, M);\n S === 0 ? e.moveTo(C, v) : e.lineTo(C, v);\n }), e.stroke()) : b === \"MultiLineString\" ? (e.beginPath(), r.coordinates.forEach((T) => {\n T.forEach(([M, S], C) => {\n const [v, P] = y(M, S);\n C === 0 ? e.moveTo(v, P) : e.lineTo(v, P);\n });\n }), e.stroke()) : b === \"Polygon\" ? (e.beginPath(), r.coordinates.forEach((T, M) => {\n T.forEach(([S, C], v) => {\n const [P, R] = y(S, C);\n v === 0 ? e.moveTo(P, R) : e.lineTo(P, R);\n }), e.closePath();\n }), e.fill(\"evenodd\"), e.stroke()) : b === \"MultiPolygon\" && r.coordinates.forEach((T) => {\n e.beginPath(), T.forEach((M, S) => {\n M.forEach(([C, v], P) => {\n const [R, V] = y(C, v);\n P === 0 ? e.moveTo(R, V) : e.lineTo(R, V);\n }), e.closePath();\n }), e.fill(\"evenodd\"), e.stroke();\n });\n e.restore();\n }\n}\nconst Ae = /* @__PURE__ */ new K(), Ke = /* @__PURE__ */ new L(), Ut = /* @__PURE__ */ new L(), Nt = /* @__PURE__ */ new L(), se = /* @__PURE__ */ new L(), Pr = /* @__PURE__ */ new pt(), qs = Symbol(\"SPLIT_TILE_DATA\"), et = Symbol(\"SPLIT_HASH\"), tt = Symbol(\"ORIGINAL_REFINE\");\nclass So {\n get enableTileSplitting() {\n return this._enableTileSplitting;\n }\n set enableTileSplitting(e) {\n this._enableTileSplitting !== e && (this._enableTileSplitting = e, this._markNeedsUpdate());\n }\n constructor(e = {}) {\n const {\n overlays: t = [],\n resolution: s = 256,\n enableTileSplitting: n = !0\n } = e;\n this.name = \"IMAGE_OVERLAY_PLUGIN\", this.priority = -15, this.resolution = s, this._enableTileSplitting = n, this.overlays = [], this.needsUpdate = !1, this.tiles = null, this.tileComposer = null, this.tileControllers = /* @__PURE__ */ new Map(), this.overlayInfo = /* @__PURE__ */ new Map(), this.meshParams = /* @__PURE__ */ new WeakMap(), this.pendingTiles = /* @__PURE__ */ new Map(), this.processedTiles = /* @__PURE__ */ new Set(), this.processQueue = null, this._onUpdateAfter = null, this._onTileDownloadStart = null, this._virtualChildResetId = 0, this._bytesUsed = /* @__PURE__ */ new WeakMap(), t.forEach((i) => {\n this.addOverlay(i);\n });\n }\n // plugin functions\n init(e) {\n const t = new Pn(), s = new Ci();\n s.maxJobs = 10, s.priorityCallback = (n, i) => {\n const r = n.tile, o = i.tile, l = e.visibleTiles.has(r), c = e.visibleTiles.has(o);\n return l !== c ? l ? 1 : -1 : e.downloadQueue.priorityCallback(r, o);\n }, this.tiles = e, this.tileComposer = t, this.processQueue = s, e.forEachLoadedModel((n, i) => {\n this._processTileModel(n, i, !0);\n }), this._onUpdateAfter = async () => {\n let n = !1;\n if (this.overlayInfo.forEach((i, r) => {\n if (!!r.frame != !!i.frame || r.frame && i.frame && !i.frame.equals(r.frame)) {\n const o = i.order;\n this.deleteOverlay(r), this.addOverlay(r, o), n = !0;\n }\n }), n) {\n const i = s.maxJobs;\n let r = 0;\n s.items.forEach((o) => {\n e.visibleTiles.has(o.tile) && r++;\n }), s.maxJobs = r + s.currJobs, s.tryRunJobs(), s.maxJobs = i, this.needsUpdate = !0;\n }\n if (this.needsUpdate) {\n this.needsUpdate = !1;\n const { overlays: i, overlayInfo: r } = this;\n i.sort((o, l) => r.get(o).order - r.get(l).order), this.processedTiles.forEach((o) => {\n this._updateLayers(o);\n }), this.resetVirtualChildren(!this.enableTileSplitting), e.recalculateBytesUsed(), e.dispatchEvent({ type: \"needs-rerender\" });\n }\n }, this._onTileDownloadStart = ({ tile: n, url: i }) => {\n !/\\.json$/i.test(i) && !/\\.subtree/i.test(i) && (this.processedTiles.add(n), this._initTileOverlayInfo(n));\n }, e.addEventListener(\"update-after\", this._onUpdateAfter), e.addEventListener(\"tile-download-start\", this._onTileDownloadStart), this.overlays.forEach((n) => {\n this._initOverlay(n);\n });\n }\n _removeVirtualChildren(e) {\n if (!(tt in e))\n return;\n const { tiles: t } = this, { virtualChildCount: s } = e.internal, n = e.children.length, i = n - s;\n for (let r = i; r < n; r++) {\n const o = e.children[r];\n t.processNodeQueue.remove(o), t.lruCache.remove(o), o.parent = null;\n }\n e.children.length -= s, e.internal.virtualChildCount = 0, e.refine = e[tt], delete e[tt], delete e[et];\n }\n disposeTile(e) {\n const { overlayInfo: t, tileControllers: s, processQueue: n, pendingTiles: i, processedTiles: r } = this;\n r.delete(e), this._removeVirtualChildren(e), s.has(e) && (s.get(e).abort(), s.delete(e), i.delete(e)), t.forEach((({ tileInfo: o }, l) => {\n if (o.has(e)) {\n const { meshInfo: c, range: u } = o.get(e);\n u !== null && l.releaseTexture(u, e), o.delete(e), c.clear();\n }\n })), n.removeByFilter((o) => o.tile === e);\n }\n calculateBytesUsed(e) {\n const { overlayInfo: t } = this, s = this._bytesUsed;\n let n = null;\n return t.forEach(({ tileInfo: i }, r) => {\n if (i.has(e)) {\n const { target: o } = i.get(e);\n n = n || 0, n += bi(o);\n }\n }), n !== null ? (s.set(e, n), n) : s.has(e) ? s.get(e) : 0;\n }\n processTileModel(e, t) {\n return this._processTileModel(e, t);\n }\n async _processTileModel(e, t, s = !1) {\n const { tileControllers: n, processedTiles: i, pendingTiles: r } = this;\n n.set(t, new AbortController()), s || r.set(t, e), i.add(t), this._wrapMaterials(e), this._initTileOverlayInfo(t), await this._initTileSceneOverlayInfo(e, t), this.expandVirtualChildren(e, t), this._updateLayers(t), r.delete(t);\n }\n dispose() {\n const { tiles: e } = this;\n [...this.overlays].forEach((s) => {\n this.deleteOverlay(s);\n }), this.processedTiles.forEach((s) => {\n this._updateLayers(s), this.disposeTile(s);\n }), e.removeEventListener(\"update-after\", this._onUpdateAfter), this.resetVirtualChildren(!0);\n }\n getAttributions(e) {\n this.overlays.forEach((t) => {\n t.opacity > 0 && t.getAttributions(e);\n });\n }\n parseToMesh(e, t, s, n) {\n if (s === \"image_overlay_tile_split\")\n return t[qs];\n }\n async resetVirtualChildren(e = !1) {\n this._virtualChildResetId++;\n const t = this._virtualChildResetId;\n if (await Promise.all(this.overlays.map((i) => i.whenReady())), t !== this._virtualChildResetId)\n return;\n const { tiles: s } = this, n = [];\n this.processedTiles.forEach((i) => {\n et in i && n.push(i);\n }), n.sort((i, r) => r.internal.depth - i.internal.depth), n.forEach((i) => {\n const r = i.engineData.scene.clone();\n r.updateMatrixWorld(), (e || i[et] !== this._getSplitVectors(r, i).hash) && this._removeVirtualChildren(i);\n }), e || s.forEachLoadedModel((i, r) => {\n this.expandVirtualChildren(i, r);\n });\n }\n _getSplitVectors(e, t, s = Ut) {\n const { tiles: n, overlayInfo: i } = this, r = new pt();\n r.setFromObject(e), r.getCenter(s);\n const o = [], l = [];\n i.forEach(({ tileInfo: u }, h) => {\n const d = u.get(t);\n if (d && d.target && h.shouldSplit(d.range, t)) {\n h.frame ? se.set(0, 0, 1).transformDirection(h.frame) : (n.ellipsoid.getPositionToNormal(s, se), se.length() < 1e-6 && se.set(1, 0, 0));\n const m = `${se.x.toFixed(3)},${se.y.toFixed(3)},${se.z.toFixed(3)}_`;\n l.includes(m) || l.push(m);\n const f = Ke.set(0, 0, 1);\n Math.abs(se.dot(f)) > 1 - 1e-4 && f.set(1, 0, 0);\n const p = new L().crossVectors(se, f).normalize(), g = new L().crossVectors(se, p).normalize();\n o.push(p, g);\n }\n });\n const c = [];\n for (; o.length !== 0; ) {\n const u = o.pop().clone(), h = u.clone();\n for (let d = 0; d < o.length; d++) {\n const m = o[d], f = u.dot(m);\n Math.abs(f) > Math.cos(Math.PI / 8) && (h.addScaledVector(m, Math.sign(f)), u.copy(h).normalize(), o.splice(d, 1), d--);\n }\n c.push(h.normalize());\n }\n return { directions: c, hash: l.join(\"\") };\n }\n async expandVirtualChildren(e, t) {\n const { refine: s } = t, n = s === \"REPLACE\" && t.children.length === 0 || s === \"ADD\", i = t.internal.virtualChildCount !== 0;\n if (this.enableTileSplitting === !1 || !n || i)\n return;\n const r = e.clone();\n r.updateMatrixWorld();\n const { directions: o, hash: l } = this._getSplitVectors(r, t, Ut);\n if (o.length === 0)\n return;\n t[et] = l;\n const c = new Mn();\n c.attributeList = (h) => !/^layer_uv_\\d+/.test(h), o.map((h) => {\n c.addSplitOperation((d, m, f, p, g, y) => (Yt.getInterpolatedAttribute(d.attributes.position, m, f, p, g, Ke), Ke.applyMatrix4(y).sub(Ut).dot(h)));\n });\n const u = [];\n c.forEachSplitPermutation(() => {\n const h = c.clipObject(r);\n h.matrix.premultiply(t.engineData.transformInverse).decompose(h.position, h.quaternion, h.scale);\n const d = [];\n if (h.traverse((f) => {\n if (f.isMesh) {\n const p = f.material.clone();\n f.material = p;\n for (const g in p) {\n const y = p[g];\n if (y && y.isTexture && y.source.data instanceof ImageBitmap) {\n const x = document.createElement(\"canvas\");\n x.width = y.image.width, x.height = y.image.height;\n const b = x.getContext(\"2d\");\n b.scale(1, -1), b.drawImage(y.source.data, 0, 0, x.width, -x.height);\n const T = new $t(x);\n T.mapping = y.mapping, T.wrapS = y.wrapS, T.wrapT = y.wrapT, T.minFilter = y.minFilter, T.magFilter = y.magFilter, T.format = y.format, T.type = y.type, T.anisotropy = y.anisotropy, T.colorSpace = y.colorSpace, T.generateMipmaps = y.generateMipmaps, p[g] = T;\n }\n }\n d.push(f);\n }\n }), d.length === 0)\n return;\n const m = {};\n if (t.boundingVolume.region && (m.region = Hs(d, this.tiles.ellipsoid).region), t.boundingVolume.box || t.boundingVolume.sphere) {\n Pr.setFromObject(h, !0).getCenter(Nt);\n let f = 0;\n h.traverse((p) => {\n const g = p.geometry;\n if (g) {\n const y = g.attributes.position;\n for (let x = 0, b = y.count; x < b; x++) {\n const T = Ke.fromBufferAttribute(y, x).applyMatrix4(p.matrixWorld).distanceToSquared(Nt);\n f = Math.max(f, T);\n }\n }\n }), m.sphere = [...Nt, Math.sqrt(f)];\n }\n u.push({\n internal: { isVirtual: !0 },\n refine: \"REPLACE\",\n geometricError: t.geometricError * 0.5,\n boundingVolume: m,\n content: { uri: \"./child.image_overlay_tile_split\" },\n children: [],\n [qs]: h\n });\n }), t[tt] = t.refine, t.refine = \"REPLACE\", t.children.push(...u), t.internal.virtualChildCount += u.length;\n }\n fetchData(e, t) {\n if (/image_overlay_tile_split/.test(e))\n return new ArrayBuffer();\n }\n /**\n * Adds an image overlay source to the plugin. The `order` parameter controls the draw\n * order among overlays; lower values are drawn first. If omitted, the overlay is appended\n * after all existing overlays.\n * @param {Object} overlay An image source object (e.g. `XYZImageSource`, `WMTSImageSource`).\n * @param {number|null} [order=null] Draw order for this overlay.\n */\n addOverlay(e, t = null) {\n const { tiles: s, overlays: n, overlayInfo: i } = this;\n t === null && (t = n.reduce((o, l) => Math.max(o, l.order + 1), 0));\n const r = new AbortController();\n n.push(e), i.set(e, {\n order: t,\n uniforms: {},\n tileInfo: /* @__PURE__ */ new Map(),\n controller: r,\n frame: e.frame ? e.frame.clone() : null\n }), s !== null && this._initOverlay(e);\n }\n /**\n * Updates the draw order for the given overlay.\n * @param {Object} overlay The overlay to reorder.\n * @param {number} order New draw order value.\n */\n setOverlayOrder(e, t) {\n this.overlays.indexOf(e) !== -1 && (this.overlayInfo.get(e).order = t, this._markNeedsUpdate());\n }\n /**\n * Removes the given overlay from the plugin.\n * @param {Object} overlay The overlay to remove.\n */\n deleteOverlay(e) {\n const { overlays: t, overlayInfo: s, processQueue: n, processedTiles: i } = this, r = t.indexOf(e);\n if (r !== -1) {\n const { tileInfo: o, controller: l } = s.get(e);\n i.forEach((c) => {\n if (!o.has(c))\n return;\n const {\n meshInfo: u,\n range: h\n } = o.get(c);\n h !== null && e.releaseTexture(h, c), o.delete(c), u.clear();\n }), o.clear(), s.delete(e), l.abort(), n.removeByFilter((c) => c.overlay === e), t.splice(r, 1), i.forEach((c) => {\n this._updateLayers(c);\n }), this._markNeedsUpdate();\n }\n }\n // initialize the overlay to use the right fetch options, load all data for existing tiles\n _initOverlay(e) {\n const { tiles: t } = this;\n e.isInitialized || (e.init(), e.whenReady().then(() => {\n e.setResolution(this.resolution);\n const i = e.fetch.bind(e);\n e.fetch = (...r) => t.downloadQueue.add({ priority: -performance.now() }, () => i(...r));\n }));\n const s = [], n = async (i, r) => {\n this._initTileOverlayInfo(r, e);\n const o = this._initTileSceneOverlayInfo(i, r, e);\n s.push(o), await o, this._updateLayers(r);\n };\n t.forEachLoadedModel((i, r) => {\n n(i, r);\n }), this.pendingTiles.forEach((i, r) => {\n n(i, r);\n }), Promise.all(s).then(() => {\n this._markNeedsUpdate();\n });\n }\n // wrap all materials in the given scene wit the overlay material shader\n _wrapMaterials(e) {\n e.traverse((t) => {\n if (t.material) {\n const s = vr(t.material, t.material.onBeforeCompile);\n this.meshParams.set(t, s);\n }\n });\n }\n // Initialize per-tile overlay information. This function triggers an async function but\n // does not need to be awaited for use since it's just locking textures which are awaited later.\n _initTileOverlayInfo(e, t = this.overlays) {\n if (Array.isArray(t)) {\n t.forEach((i) => this._initTileOverlayInfo(e, i));\n return;\n }\n const { overlayInfo: s } = this;\n if (s.get(t).tileInfo.has(e))\n return;\n const n = {\n range: null,\n target: null,\n meshInfo: /* @__PURE__ */ new Map()\n };\n if (s.get(t).tileInfo.set(e, n), t.isReady && !t.isPlanarProjection) {\n if (e.boundingVolume.region) {\n const [i, r, o, l] = e.boundingVolume.region, c = t.projection.toNormalizedRange([i, r, o, l]);\n n.range = c, t.lockTexture(c, e);\n }\n }\n }\n // initialize the scene meshes\n async _initTileSceneOverlayInfo(e, t, s = this.overlays) {\n if (Array.isArray(s))\n return Promise.all(s.map((T) => this._initTileSceneOverlayInfo(e, t, T)));\n const { tiles: n, overlayInfo: i, tileControllers: r, processQueue: o } = this, { ellipsoid: l } = n, { controller: c, tileInfo: u } = i.get(s), h = r.get(t);\n if (s.isReady || await s.whenReady(), c.signal.aborted || h.signal.aborted)\n return;\n const d = [];\n e.updateMatrixWorld(), e.traverse((T) => {\n T.isMesh && d.push(T);\n });\n const { aspectRatio: m, projection: f } = s, p = u.get(t);\n let g, y, x;\n if (s.isPlanarProjection) {\n Ae.makeScale(1 / m, 1, 1).multiply(s.frame), e.parent !== null && Ae.multiply(n.group.matrixWorldInverse);\n let T;\n ({ range: g, uvs: y, heightRange: T } = Ir(d, Ae)), x = !(T[0] > 1 || T[1] < 0);\n } else\n Ae.identity(), e.parent !== null && Ae.copy(n.group.matrixWorldInverse), { range: g, uvs: y } = Hs(d, l, Ae, f), g = f.toNormalizedRange(g), x = !0;\n p.range === null ? (p.range = g, s.lockTexture(g, t)) : g = p.range;\n let b = null;\n x && s.hasContent(g, t) && (b = await o.add({ tile: t, overlay: s }, async () => {\n if (c.signal.aborted || h.signal.aborted)\n return null;\n const T = await s.getTexture(g, t);\n return c.signal.aborted || h.signal.aborted ? null : T;\n }).catch((T) => {\n if (!(T instanceof Ai))\n throw T;\n })), p.target = b, d.forEach((T, M) => {\n const S = new Float32Array(y[M]), C = new $(S, 3);\n p.meshInfo.set(T, { attribute: C });\n });\n }\n _updateLayers(e) {\n const { overlayInfo: t, overlays: s, tileControllers: n, meshParams: i } = this, r = n.get(e);\n if (this.tiles.recalculateBytesUsed(e), !(!r || r.signal.aborted)) {\n if (s.length === 0) {\n const o = e.engineData && e.engineData.scene;\n o && o.traverse((l) => {\n if (l.material && i.has(l)) {\n const c = i.get(l);\n c.layerMaps.length = 0, c.layerInfo.length = 0, l.material.defines.LAYER_COUNT = 0, l.material.needsUpdate = !0;\n }\n });\n return;\n }\n s.forEach((o, l) => {\n const { tileInfo: c } = t.get(o), { meshInfo: u, target: h } = c.get(e);\n u.forEach(({ attribute: d }, m) => {\n const { geometry: f, material: p } = m, g = i.get(m), y = `layer_uv_${l}`;\n f.getAttribute(y) !== d && (f.setAttribute(y, d), f.dispose()), g.layerMaps.length = s.length, g.layerInfo.length = s.length, g.layerMaps.value[l] = h !== null ? h : null, g.layerInfo.value[l] = o, p.defines[`LAYER_${l}_EXISTS`] = +(h !== null), p.defines[`LAYER_${l}_ALPHA_INVERT`] = Number(o.alphaInvert), p.defines[`LAYER_${l}_ALPHA_MASK`] = Number(o.alphaMask), p.defines.LAYER_COUNT = s.length, p.needsUpdate = !0;\n });\n });\n }\n }\n _markNeedsUpdate() {\n this.needsUpdate === !1 && (this.needsUpdate = !0, this.tiles !== null && this.tiles.dispatchEvent({ type: \"needs-update\" }));\n }\n}\nclass Dn {\n get isPlanarProjection() {\n return !!this.frame;\n }\n constructor(e = {}) {\n const {\n opacity: t = 1,\n color: s = 16777215,\n frame: n = null,\n preprocessURL: i = null,\n alphaMask: r = !1,\n alphaInvert: o = !1\n } = e;\n this.preprocessURL = i, this.opacity = t, this.color = new un(s), this.frame = n !== null ? n.clone() : null, this.alphaMask = r, this.alphaInvert = o, this._whenReady = null, this.isReady = !1, this.isInitialized = !1;\n }\n init() {\n this.isInitialized = !0, this._whenReady = this._init().then(() => this.isReady = !0);\n }\n whenReady() {\n return this._whenReady;\n }\n // overrideable\n _init() {\n }\n fetch(e, t = {}) {\n return this.preprocessURL && (e = this.preprocessURL(e)), fetch(e, t);\n }\n getAttributions(e) {\n }\n hasContent(e, t) {\n return !1;\n }\n async getTexture(e, t) {\n return null;\n }\n async lockTexture(e, t) {\n return null;\n }\n releaseTexture(e, t) {\n }\n setResolution(e) {\n }\n shouldSplit(e, t) {\n return !1;\n }\n}\nclass Le extends Dn {\n get tiling() {\n return this.imageSource.tiling;\n }\n get projection() {\n return this.tiling.projection;\n }\n get aspectRatio() {\n return this.tiling && this.isReady ? this.tiling.aspectRatio : 1;\n }\n get fetchOptions() {\n return this.imageSource.fetchOptions;\n }\n set fetchOptions(e) {\n this.imageSource.fetchOptions = e;\n }\n constructor(e = {}) {\n const { imageSource: t = null, ...s } = e;\n super(s), this.imageSource = t, this.regionImageSource = null;\n }\n _init() {\n return this._initImageSource().then(() => {\n this.imageSource.fetchData = (...e) => this.fetch(...e), this.regionImageSource = new Lr(this.imageSource);\n });\n }\n _initImageSource() {\n return this.imageSource.init();\n }\n // Texture acquisition API implementations\n calculateLevel(e, t) {\n if (this.isPlanarProjection) {\n const [s, n, i, r] = e, o = i - s, l = r - n;\n let c = 0;\n const u = this.regionImageSource.resolution, h = this.tiling.maxLevel;\n for (; c < h; c++) {\n const d = u / o, m = u / l, { pixelWidth: f, pixelHeight: p } = this.tiling.getLevel(c);\n if (f >= d || p >= m)\n break;\n }\n return c;\n } else\n return t.internal.depthFromRenderedParent - 1;\n }\n hasContent(e, t) {\n return this.regionImageSource.hasContent(...e, this.calculateLevel(e, t));\n }\n getTexture(e, t) {\n return this.regionImageSource.get(...e, this.calculateLevel(e, t));\n }\n lockTexture(e, t) {\n return this.regionImageSource.lock(...e, this.calculateLevel(e, t));\n }\n releaseTexture(e, t) {\n this.regionImageSource.release(...e, this.calculateLevel(e, t));\n }\n setResolution(e) {\n this.regionImageSource.resolution = e;\n }\n shouldSplit(e, t) {\n return this.tiling.maxLevel > this.calculateLevel(e, t);\n }\n}\nclass Mo extends Le {\n constructor(e = {}) {\n super(e), this.imageSource = new ze(e);\n }\n}\nclass Co extends Dn {\n get projection() {\n return this.imageSource.projection;\n }\n get aspectRatio() {\n return 2;\n }\n get pointRadius() {\n return this.imageSource.pointRadius;\n }\n set pointRadius(e) {\n this.imageSource.pointRadius = e;\n }\n get strokeStyle() {\n return this.imageSource.strokeStyle;\n }\n set strokeStyle(e) {\n this.imageSource.strokeStyle = e;\n }\n get strokeWidth() {\n return this.imageSource.strokeWidth;\n }\n set strokeWidth(e) {\n this.imageSource.strokeWidth = e;\n }\n get fillStyle() {\n return this.imageSource.fillStyle;\n }\n set fillStyle(e) {\n this.imageSource.fillStyle = e;\n }\n get geojson() {\n return this.imageSource.geojson;\n }\n set geojson(e) {\n this.imageSource.geojson = e;\n }\n constructor(e = {}) {\n super(e), this.imageSource = new wr(e);\n }\n _init() {\n return this.imageSource.init();\n }\n hasContent(e) {\n return this.imageSource.hasContent(...e);\n }\n getTexture(e) {\n return this.imageSource.get(...e);\n }\n lockTexture(e) {\n return this.imageSource.lock(...e);\n }\n releaseTexture(e) {\n this.imageSource.release(...e);\n }\n setResolution(e) {\n this.imageSource.resolution = e;\n }\n shouldSplit(e, t) {\n return !0;\n }\n redraw() {\n this.imageSource.redraw();\n }\n}\nclass Ao extends Le {\n constructor(e = {}) {\n super(e), this.imageSource = new Sn(e);\n }\n}\nclass Io extends Le {\n constructor(e = {}) {\n super(e), this.imageSource = new _n(e);\n }\n}\nclass vo extends Le {\n constructor(e = {}) {\n super(e), this.imageSource = new Qt(e);\n }\n}\nclass Lo extends Le {\n constructor(e = {}) {\n super(e);\n const { apiToken: t, autoRefreshToken: s, assetId: n } = e;\n this.options = e, this.assetId = n, this.auth = new Xn({ apiToken: t, autoRefreshToken: s }), this.auth.authURL = `https://api.cesium.com/v1/assets/${n}/endpoint`, this._attributions = [], this.externalType = !1;\n }\n _initImageSource() {\n return this.auth.refreshToken().then(async (e) => {\n if (this._attributions = e.attributions.map((t) => ({\n value: t.html,\n type: \"html\",\n collapsible: t.collapsible\n })), e.type !== \"IMAGERY\")\n throw new Error(\"CesiumIonOverlay: Only IMAGERY is supported as overlay type.\");\n switch (this.externalType = !!e.externalType, e.externalType) {\n case \"GOOGLE_2D_MAPS\": {\n const { url: t, session: s, key: n, tileWidth: i } = e.options, r = `${t}/v1/2dtiles/{z}/{x}/{y}?session=${s}&key=${n}`;\n this.imageSource = new ze({\n ...this.options,\n url: r,\n tileDimension: i,\n // Google maps tiles have a fixed depth of 22\n // https://developers.google.com/maps/documentation/tile/2d-tiles-overview\n levels: 22\n });\n break;\n }\n case \"BING\": {\n const { url: t, mapStyle: s, key: n } = e.options, i = `${t}/REST/v1/Imagery/Metadata/${s}?incl=ImageryProviders&key=${n}&uriScheme=https`, o = (await fetch(i).then((l) => l.json())).resourceSets[0].resources[0];\n this.imageSource = new Mr({\n ...this.options,\n url: o.imageUrl,\n subdomains: o.imageUrlSubdomains,\n tileDimension: o.tileWidth,\n levels: o.zoomMax\n });\n break;\n }\n default:\n this.imageSource = new Qt({\n ...this.options,\n url: e.url\n });\n }\n return this.imageSource.fetchData = (...t) => this.fetch(...t), this.imageSource.init();\n });\n }\n fetch(...e) {\n return this.externalType ? super.fetch(...e) : this.auth.fetch(...e);\n }\n getAttributions(e) {\n e.push(...this._attributions);\n }\n}\nclass Eo extends Le {\n constructor(e = {}) {\n super(e);\n const { apiToken: t, sessionOptions: s, autoRefreshToken: n, logoUrl: i } = e;\n this.logoUrl = i, this.auth = new Yn({ apiToken: t, sessionOptions: s, autoRefreshToken: n }), this.imageSource = new ze(), this.imageSource.fetchData = (...r) => this.fetch(...r), this._logoAttribution = {\n value: \"\",\n type: \"image\",\n collapsible: !1\n };\n }\n _initImageSource() {\n return this.auth.refreshToken().then((e) => (this.imageSource.tileDimension = e.tileWidth, this.imageSource.url = \"https://tile.googleapis.com/v1/2dtiles/{z}/{x}/{y}\", this.imageSource.init()));\n }\n fetch(...e) {\n return this.auth.fetch(...e);\n }\n getAttributions(e) {\n this.logoUrl && (this._logoAttribution.value = this.logoUrl, e.push(this._logoAttribution));\n }\n}\nclass wo {\n constructor() {\n this.name = \"LOAD_REGION_PLUGIN\", this.regions = [], this.tiles = null;\n }\n init(e) {\n this.tiles = e;\n }\n addRegion(e) {\n this.regions.indexOf(e) === -1 && this.regions.push(e);\n }\n removeRegion(e) {\n const t = this.regions.indexOf(e);\n t !== -1 && this.regions.splice(t, 1);\n }\n hasRegion(e) {\n return this.regions.indexOf(e) !== -1;\n }\n clearRegions() {\n this.regions = [];\n }\n // Calculates shape intersections and associated error values to use. If \"mask\" shapes are present then\n // tiles are only loaded if they are within those shapes.\n calculateTileViewError(e, t) {\n const s = e.engineData.boundingVolume, { regions: n, tiles: i } = this;\n let r = !1, o = null, l = 0, c = 1 / 0;\n for (const u of n) {\n const h = u.intersectsTile(s, e, i);\n r = r || h, h && (l = Math.max(u.calculateError(e, i), l), c = Math.min(u.calculateDistance(s, e, i), c)), u.mask && (o = o || h);\n }\n return t.inView = r && o !== !1, t.error = l, t.distance = c, t.inView || o !== null;\n }\n dispose() {\n this.regions = [];\n }\n}\nclass Kt {\n constructor(e = {}) {\n typeof e == \"number\" && (console.warn(\"LoadRegionPlugin: Region constructor has been changed to take options as an object.\"), e = { errorTarget: e });\n const {\n errorTarget: t = 10,\n mask: s = !1\n } = e;\n this.errorTarget = t, this.mask = s;\n }\n intersectsTile(e, t, s) {\n return !1;\n }\n calculateDistance(e, t, s) {\n return 1 / 0;\n }\n calculateError(e, t) {\n return e.geometricError - this.errorTarget + t.errorTarget;\n }\n}\nclass Po extends Kt {\n constructor(e = {}) {\n typeof e == \"number\" && (console.warn(\"SphereRegion: Region constructor has been changed to take options as an object.\"), e = {\n errorTarget: arguments[0],\n sphere: arguments[1]\n });\n const { sphere: t = new pe() } = e;\n super(e), this.sphere = t.clone();\n }\n intersectsTile(e) {\n return e.intersectsSphere(this.sphere);\n }\n}\nclass Ro extends Kt {\n constructor(e = {}) {\n typeof e == \"number\" && (console.warn(\"RayRegion: Region constructor has been changed to take options as an object.\"), e = {\n errorTarget: arguments[0],\n ray: arguments[1]\n });\n const { ray: t = new di() } = e;\n super(e), this.ray = t.clone();\n }\n intersectsTile(e) {\n return e.intersectsRay(this.ray);\n }\n}\nclass Do extends Kt {\n constructor(e = {}) {\n typeof e == \"number\" && (console.warn(\"RayRegion: Region constructor has been changed to take options as an object.\"), e = {\n errorTarget: arguments[0],\n obb: arguments[1]\n });\n const { obb: t = new _i() } = e;\n super(e), this.obb = t.clone(), this.obb.update();\n }\n intersectsTile(e) {\n return e.intersectsOBB(this.obb);\n }\n}\nconst te = /* @__PURE__ */ new L(), Ws = [\"x\", \"y\", \"z\"];\nclass Rr extends hn {\n constructor(e, t = 16776960, s = 40) {\n const n = new Ve(), i = [];\n for (let r = 0; r < 3; r++) {\n const o = Ws[r], l = Ws[(r + 1) % 3];\n te.set(0, 0, 0);\n for (let c = 0; c < s; c++) {\n let u;\n u = 2 * Math.PI * c / (s - 1), te[o] = Math.sin(u), te[l] = Math.cos(u), i.push(te.x, te.y, te.z), u = 2 * Math.PI * (c + 1) / (s - 1), te[o] = Math.sin(u), te[l] = Math.cos(u), i.push(te.x, te.y, te.z);\n }\n }\n n.setAttribute(\"position\", new $(new Float32Array(i), 3)), n.computeBoundingSphere(), super(n, new pi({ color: t, toneMapped: !1 })), this.sphere = e, this.type = \"SphereHelper\";\n }\n updateMatrixWorld(e) {\n const t = this.sphere;\n this.position.copy(t.center), this.scale.setScalar(t.radius), super.updateMatrixWorld(e);\n }\n}\nconst Vt = /* @__PURE__ */ new L(), st = /* @__PURE__ */ new L(), ne = /* @__PURE__ */ new L(), js = /* @__PURE__ */ new L(), Xs = /* @__PURE__ */ new L();\nfunction Dr(a) {\n a = a.toNonIndexed();\n const { groups: e } = a, { position: t, normal: s } = a.attributes, n = [], i = [];\n for (const o of e) {\n const { start: l, count: c } = o;\n for (let u = l, h = l + c; u < h; u++)\n js.fromBufferAttribute(t, u), Xs.fromBufferAttribute(s, u), i.push(...js), n.push(...Xs);\n }\n const r = new Ve();\n return r.setAttribute(\"position\", new $(new Float32Array(i), 3)), r.setAttribute(\"normal\", new $(new Float32Array(n), 3)), r;\n}\nfunction Bn(a, { computeNormals: e = !1 } = {}) {\n const {\n latStart: t = -Math.PI / 2,\n latEnd: s = Math.PI / 2,\n lonStart: n = 0,\n lonEnd: i = 2 * Math.PI,\n heightStart: r = 0,\n heightEnd: o = 0\n } = a, l = new dn(1, 1, 1, 32, 32), { normal: c, position: u } = l.attributes, h = u.clone();\n for (let d = 0, m = u.count; d < m; d++) {\n ne.fromBufferAttribute(u, d);\n const f = _.mapLinear(ne.x, -0.5, 0.5, t, s), p = _.mapLinear(ne.y, -0.5, 0.5, n, i);\n let g = r;\n a.getCartographicToNormal(f, p, Vt), ne.z < 0 && (g = o), a.getCartographicToPosition(f, p, g, ne), u.setXYZ(d, ...ne);\n }\n e && l.computeVertexNormals();\n for (let d = 0, m = h.count; d < m; d++) {\n ne.fromBufferAttribute(h, d);\n const f = _.mapLinear(ne.x, -0.5, 0.5, t, s), p = _.mapLinear(ne.y, -0.5, 0.5, n, i);\n Vt.fromBufferAttribute(c, d), a.getCartographicToNormal(f, p, st), Math.abs(Vt.dot(st)) > 0.1 && (ne.z > 0 && st.multiplyScalar(-1), c.setXYZ(d, ...st));\n }\n return l;\n}\nclass Br extends hn {\n constructor(e = new fn(), t = 16776960) {\n super(), this.ellipsoidRegion = e, this.material.color.set(t), this.update();\n }\n update() {\n const e = Bn(this.ellipsoidRegion);\n this.geometry.dispose(), this.geometry = new fi(e, 80);\n }\n dispose() {\n this.geometry.dispose(), this.material.dispose();\n }\n}\nclass Or extends Se {\n constructor(e = new fn(), t = 16776960) {\n super(), this.ellipsoidRegion = e, this.material.color.set(t), this.update();\n }\n update() {\n this.geometry.dispose();\n const e = Bn(this.ellipsoidRegion, { computeNormals: !0 }), { lonStart: t, lonEnd: s } = this;\n s - t >= 2 * Math.PI ? (e.groups.splice(2, 2), this.geometry = Dr(e)) : this.geometry = e;\n }\n dispose() {\n this.geometry.dispose(), this.material.dispose();\n }\n}\nconst Ys = Symbol(\"ORIGINAL_MATERIAL\"), nt = Symbol(\"HAS_RANDOM_COLOR\"), it = Symbol(\"HAS_RANDOM_NODE_COLOR\"), Ft = Symbol(\"LOAD_TIME\"), ye = Symbol(\"PARENT_BOUND_REF_COUNT\"), $s = /* @__PURE__ */ new pe(), Ie = () => {\n}, kt = {};\nfunction xe(a) {\n if (!kt[a]) {\n const e = Math.random(), t = 0.5 + Math.random() * 0.5, s = 0.375 + Math.random() * 0.25;\n kt[a] = new un().setHSL(e, t, s);\n }\n return kt[a];\n}\nconst ae = 0, On = 1, Un = 2, Nn = 3, Vn = 4, Fn = 5, kn = 6, Ue = 7, Ne = 8, Gn = 9, ot = 10, Qs = 11, Ur = Object.freeze({\n NONE: ae,\n SCREEN_ERROR: On,\n GEOMETRIC_ERROR: Un,\n DISTANCE: Nn,\n DEPTH: Vn,\n RELATIVE_DEPTH: Fn,\n IS_LEAF: kn,\n RANDOM_COLOR: Ue,\n RANDOM_NODE_COLOR: Ne,\n CUSTOM_COLOR: Gn,\n LOAD_ORDER: ot\n});\nclass Bo {\n static get ColorModes() {\n return Ur;\n }\n get unlit() {\n return this._unlit;\n }\n set unlit(e) {\n e !== this._unlit && (this._unlit = e, this.materialsNeedUpdate = !0);\n }\n get colorMode() {\n return this._colorMode;\n }\n set colorMode(e) {\n e !== this._colorMode && (this._colorMode = e, this.materialsNeedUpdate = !0);\n }\n get boundsColorMode() {\n return this._boundsColorMode;\n }\n set boundsColorMode(e) {\n e !== this._boundsColorMode && (this._boundsColorMode = e, this.materialsNeedUpdate = !0);\n }\n get enabled() {\n return this._enabled;\n }\n set enabled(e) {\n e !== this._enabled && this.tiles !== null && (this._enabled = e, e ? this.init(this.tiles) : this.dispose());\n }\n get displayParentBounds() {\n return this._displayParentBounds;\n }\n set displayParentBounds(e) {\n this._displayParentBounds !== e && (this._displayParentBounds = e, e ? this.tiles.traverse((t) => {\n t.traversal.visible && this._onTileVisibilityChange(t, !0);\n }) : this.tiles.traverse((t) => {\n t[ye] = null, this._onTileVisibilityChange(t, t.traversal.visible);\n }));\n }\n constructor(e) {\n e = {\n displayParentBounds: !1,\n displayBoxBounds: !1,\n displaySphereBounds: !1,\n displayRegionBounds: !1,\n colorMode: ae,\n boundsColorMode: ae,\n maxDebugDepth: -1,\n maxDebugDistance: -1,\n maxDebugError: -1,\n customColorCallback: null,\n unlit: !1,\n enabled: !0,\n ...e\n }, this.name = \"DEBUG_TILES_PLUGIN\", this.tiles = null, this._colorMode = null, this._boundsColorMode = null, this._unlit = null, this.materialsNeedUpdate = !1, this.extremeDebugDepth = -1, this.extremeDebugError = -1, this.boxGroup = null, this.sphereGroup = null, this.regionGroup = null, this._enabled = e.enabled, this._displayParentBounds = e.displayParentBounds, this.displayBoxBounds = e.displayBoxBounds, this.displaySphereBounds = e.displaySphereBounds, this.displayRegionBounds = e.displayRegionBounds, this.colorMode = e.colorMode, this.boundsColorMode = e.boundsColorMode, this.maxDebugDepth = e.maxDebugDepth, this.maxDebugDistance = e.maxDebugDistance, this.maxDebugError = e.maxDebugError, this.customColorCallback = e.customColorCallback, this.unlit = e.unlit, this.getDebugColor = (t, s) => {\n s.setRGB(t, t, t);\n };\n }\n // initialize the groups for displaying helpers, register events, and initialize existing tiles\n init(e) {\n if (this.tiles = e, !this.enabled)\n return;\n const t = e.group;\n this.boxGroup = new We(), this.boxGroup.name = \"DebugTilesRenderer.boxGroup\", t.add(this.boxGroup), this.boxGroup.updateMatrixWorld(), this.sphereGroup = new We(), this.sphereGroup.name = \"DebugTilesRenderer.sphereGroup\", t.add(this.sphereGroup), this.sphereGroup.updateMatrixWorld(), this.regionGroup = new We(), this.regionGroup.name = \"DebugTilesRenderer.regionGroup\", t.add(this.regionGroup), this.regionGroup.updateMatrixWorld(), this._onLoadTilesetCB = () => {\n this._initExtremes();\n }, this._onLoadModelCB = ({ scene: s, tile: n }) => {\n this._onLoadModel(s, n);\n }, this._onDisposeModelCB = ({ tile: s }) => {\n this._onDisposeModel(s);\n }, this._onUpdateAfterCB = () => {\n this.update();\n }, this._onTileVisibilityChangeCB = ({ scene: s, tile: n, visible: i }) => {\n this._onTileVisibilityChange(n, i);\n }, e.addEventListener(\"load-tileset\", this._onLoadTilesetCB), e.addEventListener(\"load-model\", this._onLoadModelCB), e.addEventListener(\"dispose-model\", this._onDisposeModelCB), e.addEventListener(\"update-after\", this._onUpdateAfterCB), e.addEventListener(\"tile-visibility-change\", this._onTileVisibilityChangeCB), this._initExtremes(), e.traverse((s) => {\n s.engineData.scene && this._onLoadModel(s.engineData.scene, s);\n }), e.visibleTiles.forEach((s) => {\n this._onTileVisibilityChange(s, !0);\n });\n }\n getTileFromObject3D(e) {\n let t = null;\n return this.tiles.activeTiles.forEach((n) => {\n if (t)\n return;\n const i = n.engineData.scene;\n i && i.traverse((r) => {\n r === e && (t = n);\n });\n }), t;\n }\n _initExtremes() {\n if (!(this.tiles && this.tiles.root))\n return;\n let e = -1, t = -1;\n this.tiles.traverse(null, (s, n, i) => {\n e = Math.max(e, i), t = Math.max(t, s.geometricError);\n }, !1), this.extremeDebugDepth = e, this.extremeDebugError = t;\n }\n /**\n * Applies the current plugin field values to all visible tile geometry. Call this\n * after modifying properties such as `colorMode`, `displayBoxBounds`, or\n * `displayParentBounds` when `TilesRenderer.update` is not being called every frame\n * so changes can be reflected.\n */\n update() {\n const { tiles: e, colorMode: t, boundsColorMode: s } = this;\n if (!e.root)\n return;\n this.materialsNeedUpdate && (e.forEachLoadedModel((m) => {\n this._updateMaterial(m);\n }), this.materialsNeedUpdate = !1), this.boxGroup.visible = this.displayBoxBounds, this.sphereGroup.visible = this.displaySphereBounds, this.regionGroup.visible = this.displayRegionBounds;\n let n = -1;\n this.maxDebugDepth === -1 ? n = this.extremeDebugDepth : n = this.maxDebugDepth;\n let i = -1;\n this.maxDebugError === -1 ? i = this.extremeDebugError : i = this.maxDebugError;\n let r = -1;\n this.maxDebugDistance === -1 ? (e.getBoundingSphere($s), r = $s.radius) : r = this.maxDebugDistance;\n const { errorTarget: o, visibleTiles: l } = e;\n let c;\n (t === ot || s === ot) && (c = Array.from(l).sort((m, f) => m[Ft] - f[Ft]));\n const u = (m, f, p, g, y, x) => {\n switch (m !== Ue && delete p.material[nt], m !== Ne && delete p.material[it], m) {\n case Vn: {\n const b = f.internal.depth / n;\n this.getDebugColor(b, p.material.color);\n break;\n }\n case Fn: {\n const b = f.internal.depthFromRenderedParent / n;\n this.getDebugColor(b, p.material.color);\n break;\n }\n case On: {\n const b = f.traversal.error / o;\n b > 1 ? p.material.color.setRGB(1, 0, 0) : this.getDebugColor(b, p.material.color);\n break;\n }\n case Un: {\n const b = Math.min(f.geometricError / i, 1);\n this.getDebugColor(b, p.material.color);\n break;\n }\n case Nn: {\n const b = Math.min(f.traversal.distanceFromCamera / r, 1);\n this.getDebugColor(b, p.material.color);\n break;\n }\n case kn: {\n !f.children || f.children.length === 0 ? this.getDebugColor(1, p.material.color) : this.getDebugColor(0, p.material.color);\n break;\n }\n case Ne: {\n p.material[it] || (p.material.color.setHSL(g, y, x), p.material[it] = !0);\n break;\n }\n case Ue: {\n p.material[nt] || (p.material.color.setHSL(g, y, x), p.material[nt] = !0);\n break;\n }\n case Gn: {\n this.customColorCallback ? this.customColorCallback(f, p) : console.warn(\"DebugTilesRenderer: customColorCallback not defined\");\n break;\n }\n case ot: {\n const b = c.indexOf(f);\n this.getDebugColor(b / (c.length - 1), p.material.color);\n break;\n }\n case Qs: {\n p.material.color.copy(xe(f.internal.depth)), delete p.material[nt], delete p.material[it];\n break;\n }\n }\n };\n l.forEach((m) => {\n const f = m.engineData.scene;\n let p, g, y;\n t === Ue && (p = Math.random(), g = 0.5 + Math.random() * 0.5, y = 0.375 + Math.random() * 0.25), f.traverse((x) => {\n t === Ne && (p = Math.random(), g = 0.5 + Math.random() * 0.5, y = 0.375 + Math.random() * 0.25), x.material && u(t, m, x, p, g, y);\n });\n });\n const h = s === ae ? Qs : s, d = [this.boxGroup, this.sphereGroup, this.regionGroup];\n for (const m of d)\n for (const f of m.children) {\n const p = f.userData.tile;\n let g, y, x;\n h === Ue && (g = Math.random(), y = 0.5 + Math.random() * 0.5, x = 0.375 + Math.random() * 0.25), f.traverse((b) => {\n h === Ne && (g = Math.random(), y = 0.5 + Math.random() * 0.5, x = 0.375 + Math.random() * 0.25), b.material && u(h, p, b, g, y, x);\n });\n }\n }\n _onTileVisibilityChange(e, t) {\n this.displayParentBounds ? Ii(e, (s) => {\n s[ye] == null && (s[ye] = 0), t ? s[ye]++ : s[ye] > 0 && s[ye]--;\n const n = s === e && t || this.displayParentBounds && s[ye] > 0;\n this._updateBoundHelper(s, n);\n }) : this._updateBoundHelper(e, t);\n }\n _createBoundHelper(e) {\n const t = this.tiles, s = e.engineData, { sphere: n, obb: i, region: r } = s.boundingVolume;\n if (i) {\n const o = new We();\n o.name = \"DebugTilesRenderer.boxHelperGroup\", o.matrix.copy(i.transform), o.matrixAutoUpdate = !1, o.userData.tile = e, s.boxHelperGroup = o;\n const l = new mi(i.box, xe(e.internal.depth));\n l.raycast = Ie, o.add(l);\n const c = new Se(new dn(), new _e({\n color: xe(e.internal.depth),\n transparent: !0,\n depthWrite: !1,\n opacity: 0.05,\n side: rt\n }));\n i.box.getSize(c.scale), c.raycast = Ie, o.add(c), t.visibleTiles.has(e) && this.displayBoxBounds && (this.boxGroup.add(o), o.updateMatrixWorld(!0));\n }\n if (n) {\n const o = new Rr(n, xe(e.internal.depth));\n o.raycast = Ie, o.userData.tile = e;\n const l = new Se(new gi(1), new _e({\n color: xe(e.internal.depth),\n transparent: !0,\n depthWrite: !1,\n opacity: 0.05,\n side: rt\n }));\n l.raycast = Ie, o.add(l), s.sphereHelper = o, t.visibleTiles.has(e) && this.displaySphereBounds && (this.sphereGroup.add(o), o.updateMatrixWorld(!0));\n }\n if (r) {\n const o = new Br(r, xe(e.internal.depth));\n o.raycast = Ie, o.userData.tile = e;\n const l = new Or(r, xe(e.internal.depth));\n l.material.transparent = !0, l.material.depthWrite = !1, l.material.opacity = 0.05, l.material.side = rt, l.raycast = Ie, o.add(l);\n const c = new pe();\n r.getBoundingSphere(c), o.position.copy(c.center), c.center.multiplyScalar(-1), o.geometry.translate(...c.center), l.geometry.translate(...c.center), s.regionHelper = o, t.visibleTiles.has(e) && this.displayRegionBounds && (this.regionGroup.add(o), o.updateMatrixWorld(!0));\n }\n }\n _updateHelperMaterials(e, t) {\n t.traverse((s) => {\n const { material: n } = s;\n if (!n)\n return;\n e.traversal.visible || !this.displayParentBounds ? n.opacity = s.isMesh ? 0.05 : 1 : n.opacity = s.isMesh ? 0.01 : 0.2;\n const i = n.transparent;\n n.transparent = n.opacity < 1, n.transparent !== i && (n.needsUpdate = !0);\n });\n }\n _updateBoundHelper(e, t) {\n const s = e.engineData;\n if (!s)\n return;\n const n = this.sphereGroup, i = this.boxGroup, r = this.regionGroup;\n t && s.boxHelperGroup == null && s.sphereHelper == null && s.regionHelper == null && this._createBoundHelper(e);\n const o = s.boxHelperGroup, l = s.sphereHelper, c = s.regionHelper;\n t ? (o && (i.add(o), o.updateMatrixWorld(!0), this._updateHelperMaterials(e, o)), l && (n.add(l), l.updateMatrixWorld(!0), this._updateHelperMaterials(e, l)), c && (r.add(c), c.updateMatrixWorld(!0), this._updateHelperMaterials(e, c))) : (o && i.remove(o), l && n.remove(l), c && r.remove(c));\n }\n _updateMaterial(e) {\n const { colorMode: t, unlit: s } = this;\n e.traverse((n) => {\n if (!n.material)\n return;\n const i = n.material, r = n[Ys];\n if (i !== r && i.dispose(), t !== ae || s) {\n if (n.isPoints) {\n const o = new yi();\n o.size = r.size, o.sizeAttenuation = r.sizeAttenuation, n.material = o;\n } else s ? n.material = new _e() : (n.material = new rn(), n.material.flatShading = !0);\n t === ae && (n.material.map = r.map, n.material.color.set(r.color));\n } else\n n.material = r;\n });\n }\n _onLoadModel(e, t) {\n t[Ft] = performance.now(), e.traverse((s) => {\n const n = s.material;\n n && (s[Ys] = n);\n }), this._updateMaterial(e);\n }\n _onDisposeModel(e) {\n const t = e.engineData;\n t != null && t.boxHelperGroup && (t.boxHelperGroup.traverse((s) => {\n s.geometry && (s.geometry.dispose(), s.material.dispose());\n }), delete t.boxHelperGroup), t != null && t.sphereHelper && (t.sphereHelper.traverse((s) => {\n s.geometry && (s.geometry.dispose(), s.material.dispose());\n }), delete t.sphereHelper), t != null && t.regionHelper && (t.regionHelper.traverse((s) => {\n s.geometry && (s.geometry.dispose(), s.material.dispose());\n }), delete t.regionHelper);\n }\n dispose() {\n var t, s, n;\n const e = this.tiles;\n e.removeEventListener(\"load-tileset\", this._onLoadTilesetCB), e.removeEventListener(\"load-model\", this._onLoadModelCB), e.removeEventListener(\"dispose-model\", this._onDisposeModelCB), e.removeEventListener(\"update-after\", this._onUpdateAfterCB), e.removeEventListener(\"tile-visibility-change\", this._onTileVisibilityChangeCB), this.colorMode = ae, this.boundsColorMode = ae, this.unlit = !1, e.forEachLoadedModel((i) => {\n this._updateMaterial(i);\n }), e.traverse((i) => {\n this._onDisposeModel(i);\n }, null, !1), (t = this.boxGroup) == null || t.removeFromParent(), (s = this.sphereGroup) == null || s.removeFromParent(), (n = this.regionGroup) == null || n.removeFromParent();\n }\n}\nclass Nr extends Ge {\n constructor(e = {}) {\n const { url: t = null, ...s } = e;\n super(s), this.url = t, this.format = null, this.stem = null;\n }\n getUrl(e, t, s) {\n return `${this.stem}_files/${s}/${e}_${t}.${this.format}`;\n }\n init() {\n const { url: e } = this;\n return this.fetchData(e, this.fetchOptions).then((t) => t.text()).then((t) => {\n const s = new DOMParser().parseFromString(t, \"text/xml\");\n if (s.querySelector(\"DisplayRects\") || s.querySelector(\"Collection\"))\n throw new Error(\"DeepZoomImagesPlugin: DisplayRect and Collection DZI files not supported.\");\n const n = s.querySelector(\"Image\"), i = n.querySelector(\"Size\"), r = parseInt(i.getAttribute(\"Width\")), o = parseInt(i.getAttribute(\"Height\")), l = parseInt(n.getAttribute(\"TileSize\")), c = parseInt(n.getAttribute(\"Overlap\")), u = n.getAttribute(\"Format\");\n this.format = u, this.stem = e.split(/\\.[^.]+$/g)[0];\n const { tiling: h } = this, d = Math.ceil(Math.log2(Math.max(r, o))) + 1;\n h.flipY = !0, h.pixelOverlap = c, h.generateLevels(d, 1, 1, {\n tilePixelWidth: l,\n tilePixelHeight: l,\n pixelWidth: r,\n pixelHeight: o\n });\n });\n }\n}\nclass Oo extends xn {\n constructor(e = {}) {\n const { url: t, ...s } = e;\n super(s), this.name = \"DZI_TILES_PLUGIN\", this.imageSource = new Nr({ url: t });\n }\n}\nconst ut = gn * Math.PI * 2, Zs = /* @__PURE__ */ new re(\"EPSG:3857\");\nfunction Vr(a) {\n return /:4326$/i.test(a);\n}\nfunction zn(a) {\n return /:3857$/i.test(a);\n}\nfunction Ht(a) {\n return a.trim().split(/\\s+/).map((e) => parseFloat(e));\n}\nfunction qt(a, e) {\n Vr(e) && ([a[1], a[0]] = [a[0], a[1]]);\n}\nfunction ht(a, e) {\n if (zn(e))\n return a[0] = Zs.convertNormalizedToLongitude(0.5 + a[0] / ut), a[1] = Zs.convertNormalizedToLatitude(0.5 + a[1] / ut), a[0] *= _.RAD2DEG, a[1] *= _.RAD2DEG, a;\n}\nfunction dt(a) {\n a[0] *= _.DEG2RAD, a[1] *= _.DEG2RAD;\n}\nclass Uo extends yn {\n parse(e) {\n const t = new TextDecoder(\"utf-8\").decode(new Uint8Array(e)), s = new DOMParser().parseFromString(t, \"text/xml\"), n = s.querySelector(\"Contents\"), i = he(n, \"TileMatrixSet\").map((l) => qr(l)), r = he(n, \"Layer\").map((l) => kr(l)), o = Fr(s.querySelector(\"ServiceIdentification\"));\n return r.forEach((l) => {\n l.tileMatrixSets = l.tileMatrixSetLinks.map((c) => i.find((u) => u.identifier === c));\n }), {\n serviceIdentification: o,\n tileMatrixSets: i,\n layers: r\n };\n }\n}\nfunction Fr(a) {\n var i;\n const e = a.querySelector(\"Title\").textContent, t = ((i = a.querySelector(\"Abstract\")) == null ? void 0 : i.textContent) || \"\", s = a.querySelector(\"ServiceType\").textContent, n = a.querySelector(\"ServiceTypeVersion\").textContent;\n return {\n title: e,\n abstract: t,\n serviceType: s,\n serviceTypeVersion: n\n };\n}\nfunction kr(a) {\n const e = a.querySelector(\"Title\").textContent, t = a.querySelector(\"Identifier\").textContent, s = a.querySelector(\"Format\").textContent, n = he(a, \"ResourceURL\").map((c) => Gr(c)), i = he(a, \"TileMatrixSetLink\").map((c) => he(c, \"TileMatrixSet\")[0].textContent), r = he(a, \"Style\").map((c) => Hr(c)), o = he(a, \"Dimension\").map((c) => zr(c));\n let l = Js(a.querySelector(\"WGS84BoundingBox\"));\n return l || (l = Js(a.querySelector(\"BoundingBox\"))), {\n title: e,\n identifier: t,\n format: s,\n dimensions: o,\n tileMatrixSetLinks: i,\n styles: r,\n boundingBox: l,\n resourceUrls: n\n };\n}\nfunction Gr(a) {\n const e = a.getAttribute(\"template\"), t = a.getAttribute(\"format\"), s = a.getAttribute(\"resourceType\");\n return {\n template: e,\n format: t,\n resourceType: s\n };\n}\nfunction zr(a) {\n var r, o;\n const e = a.querySelector(\"Identifier\").textContent, t = ((r = a.querySelector(\"UOM\")) == null ? void 0 : r.textContent) || \"\", s = a.querySelector(\"Default\").textContent, n = ((o = a.querySelector(\"Current\")) == null ? void 0 : o.textContent) === \"true\", i = he(a, \"Value\").map((l) => l.textContent);\n return {\n identifier: e,\n uom: t,\n defaultValue: s,\n current: n,\n values: i\n };\n}\nfunction Js(a) {\n if (!a)\n return null;\n const e = a.nodeName.endsWith(\"WGS84BoundingBox\") ? \"urn:ogc:def:crs:CRS::84\" : a.getAttribute(\"crs\"), t = Ht(a.querySelector(\"LowerCorner\").textContent), s = Ht(a.querySelector(\"UpperCorner\").textContent);\n return qt(t, e), qt(s, e), ht(t, e), ht(s, e), dt(t), dt(s), {\n crs: e,\n lowerCorner: t,\n upperCorner: s,\n bounds: [...t, ...s]\n };\n}\nfunction Hr(a) {\n var n;\n const e = ((n = a.querySelector(\"Title\")) == null ? void 0 : n.textContent) || null, t = a.querySelector(\"Identifier\").textContent, s = a.getAttribute(\"isDefault\") === \"true\";\n return {\n title: e,\n identifier: t,\n isDefault: s\n };\n}\nfunction qr(a) {\n var r, o;\n const e = a.querySelector(\"SupportedCRS\").textContent, t = ((r = a.querySelector(\"Title\")) == null ? void 0 : r.textContent) || \"\", s = a.querySelector(\"Identifier\").textContent, n = ((o = a.querySelector(\"Abstract\")) == null ? void 0 : o.textContent) || \"\", i = [];\n return a.querySelectorAll(\"TileMatrix\").forEach((l, c) => {\n const u = Wr(l), h = 28e-5 * u.scaleDenominator, d = u.tileWidth * u.matrixWidth * h, m = u.tileHeight * u.matrixHeight * h;\n let f;\n qt(u.topLeftCorner, e), zn(e) ? f = [\n u.topLeftCorner[0] + d,\n u.topLeftCorner[1] - m\n ] : f = [\n u.topLeftCorner[0] + 360 * d / ut,\n u.topLeftCorner[1] - 360 * m / ut\n ], ht(f, e), ht(u.topLeftCorner, e), dt(f), dt(u.topLeftCorner), u.bounds = [...u.topLeftCorner, ...f], [u.bounds[1], u.bounds[3]] = [u.bounds[3], u.bounds[1]], i.push(u);\n }), {\n title: t,\n identifier: s,\n abstract: n,\n supportedCRS: e,\n tileMatrices: i\n };\n}\nfunction Wr(a) {\n const e = a.querySelector(\"Identifier\").textContent, t = parseFloat(a.querySelector(\"TileWidth\").textContent), s = parseFloat(a.querySelector(\"TileHeight\").textContent), n = parseFloat(a.querySelector(\"MatrixWidth\").textContent), i = parseFloat(a.querySelector(\"MatrixHeight\").textContent), r = parseFloat(a.querySelector(\"ScaleDenominator\").textContent), o = Ht(a.querySelector(\"TopLeftCorner\").textContent);\n return {\n identifier: e,\n tileWidth: t,\n tileHeight: s,\n matrixWidth: n,\n matrixHeight: i,\n scaleDenominator: r,\n topLeftCorner: o,\n bounds: null\n };\n}\nfunction he(a, e) {\n return [...a.children].filter((t) => t.tagName === e);\n}\nconst Ks = gn * Math.PI * 2, en = /* @__PURE__ */ new re(\"EPSG:3857\");\nfunction jr(a) {\n return /:4326$/i.test(a);\n}\nfunction Xr(a) {\n return /:3857$/i.test(a);\n}\nfunction tn(a, e) {\n return Xr(e) && (a[0] = en.convertNormalizedToLongitude(0.5 + a[0] / (Math.PI * 2 * Ks)), a[1] = en.convertNormalizedToLatitude(0.5 + a[1] / (Math.PI * 2 * Ks)), a[0] *= _.RAD2DEG, a[1] *= _.RAD2DEG), a;\n}\nfunction sn(a, e, t) {\n const [s, n] = t.split(\".\").map((r) => parseInt(r)), i = s === 1 && n < 3 || s < 1;\n jr(e) && i && ([a[0], a[1]] = [a[1], a[0]]);\n}\nfunction ve(a) {\n a[0] *= _.DEG2RAD, a[1] *= _.DEG2RAD;\n}\nfunction Yr(a, e) {\n if (!a)\n return null;\n const t = a.getAttribute(\"CRS\") || a.getAttribute(\"crs\") || a.getAttribute(\"SRS\") || \"\", s = parseFloat(a.getAttribute(\"minx\")), n = parseFloat(a.getAttribute(\"miny\")), i = parseFloat(a.getAttribute(\"maxx\")), r = parseFloat(a.getAttribute(\"maxy\")), o = [s, n], l = [i, r];\n return sn(o, t, e), sn(l, t, e), tn(o, t), tn(l, t), ve(o), ve(l), { crs: t, bounds: [...o, ...l] };\n}\nfunction $r(a) {\n const e = parseFloat(a.querySelector(\"westBoundLongitude\").textContent), t = parseFloat(a.querySelector(\"eastBoundLongitude\").textContent), s = parseFloat(a.querySelector(\"southBoundLatitude\").textContent), n = parseFloat(a.querySelector(\"northBoundLatitude\").textContent), i = [e, s], r = [t, n];\n return ve(i), ve(r), [...i, ...r];\n}\nfunction Qr(a) {\n const e = parseFloat(a.getAttribute(\"minx\").textContent), t = parseFloat(a.getAttribute(\"maxx\").textContent), s = parseFloat(a.getAttribute(\"miny\").textContent), n = parseFloat(a.getAttribute(\"maxy\").textContent), i = [e, s], r = [t, n];\n return ve(i), ve(r), [...i, ...r];\n}\nfunction Zr(a) {\n const e = a.querySelector(\"Name\").textContent, t = a.querySelector(\"Title\").textContent, s = [...a.querySelectorAll(\"LegendURL\")].map((n) => {\n const i = parseInt(n.getAttribute(\"width\")), r = parseInt(n.getAttribute(\"height\")), o = n.querySelector(\"Format\").textContent, l = n.querySelector(\"OnlineResource\"), c = Wt(l);\n return {\n width: i,\n height: r,\n format: o,\n url: c\n };\n });\n return {\n name: e,\n title: t,\n legends: s\n };\n}\nfunction Hn(a, e, t = {}) {\n var p, g, y;\n let {\n styles: s = [],\n crs: n = [],\n contentBoundingBox: i = null,\n queryable: r = !1,\n opaque: o = !1\n } = t;\n const l = ((p = a.querySelector(\":scope > Name\")) == null ? void 0 : p.textContent) || null, c = ((g = a.querySelector(\":scope > Title\")) == null ? void 0 : g.textContent) || \"\", u = ((y = a.querySelector(\":scope > Abstract\")) == null ? void 0 : y.textContent) || \"\", h = [...a.querySelectorAll(\":scope > Keyword\")].map((x) => x.textContent), m = [...a.querySelectorAll(\":scope > BoundingBox\")].map((x) => Yr(x, e));\n n = [\n ...n,\n ...Array.from(a.querySelectorAll(\"CRS\")).map((x) => x.textContent)\n ], s = [\n ...s,\n ...Array.from(a.querySelectorAll(\":scope > Style\")).map((x) => Zr(x))\n ], a.hasAttribute(\"queryable\") && (r = a.getAttribute(\"queryable\") === \"1\"), a.hasAttribute(\"opaque\") && (o = a.getAttribute(\"opaque\") === \"1\"), a.querySelector(\"EX_GeographicBoundingBox\") ? i = $r(a.querySelector(\"EX_GeographicBoundingBox\")) : a.querySelector(\"LatLonBoundingBox\") && (i = Qr(a.querySelector(\"LatLonBoundingBox\")));\n const f = Array.from(a.querySelectorAll(\":scope > Layer\")).map((x) => Hn(x, e, {\n // add\n styles: s,\n crs: n,\n // replace\n contentBoundingBox: i,\n queryable: r,\n opaque: o\n }));\n return {\n name: l,\n title: c,\n abstract: u,\n queryable: r,\n opaque: o,\n keywords: h,\n crs: n,\n boundingBoxes: m,\n contentBoundingBox: i,\n styles: s,\n subLayers: f\n };\n}\nfunction Jr(a) {\n var e, t, s;\n return {\n name: ((e = a.querySelector(\"Name\")) == null ? void 0 : e.textContent) || \"\",\n title: ((t = a.querySelector(\"Title\")) == null ? void 0 : t.textContent) || \"\",\n abstract: ((s = a.querySelector(\"Abstract\")) == null ? void 0 : s.textContent) || \"\",\n keywords: Array.from(a.querySelectorAll(\"Keyword\")).map((n) => n.textContent),\n maxWidth: parseFloat(a.querySelector(\"MaxWidth\")) || null,\n maxHeight: parseFloat(a.querySelector(\"MaxHeight\")) || null,\n layerLimit: parseFloat(a.querySelector(\"LayerLimit\")) || null\n };\n}\nfunction Wt(a) {\n return a ? (a.getAttribute(\"xlink:href\") || a.getAttributeNS(\"http://www.w3.org/1999/xlink\", \"href\") || \"\").trim() : \"\";\n}\nfunction Kr(a) {\n const e = Array.from(a.querySelectorAll(\"Format\")).map((s) => s.textContent.trim()), t = Array.from(a.querySelectorAll(\"DCPType\")).map((s) => {\n const n = s.querySelector(\"HTTP\"), i = n.querySelector(\"Get OnlineResource\") || n.querySelector(\"Get > OnlineResource\") || n.querySelector(\"Get\"), r = n.querySelector(\"Post OnlineResource\") || n.querySelector(\"Post > OnlineResource\") || n.querySelector(\"Post\"), o = Wt(i), l = Wt(r);\n return { type: \"HTTP\", get: o, post: l };\n });\n return { formats: e, dcp: t, href: t[0].get };\n}\nfunction eo(a) {\n const e = {};\n return Array.from(a.querySelectorAll(\":scope > *\")).forEach((t) => {\n const s = t.localName;\n e[s] = Kr(t);\n }), e;\n}\nfunction qn(a, e = []) {\n return a.forEach((t) => {\n t.name !== null && e.push(t), qn(t.subLayers, e);\n }), e;\n}\nclass No extends yn {\n parse(e) {\n const t = new TextDecoder(\"utf-8\").decode(new Uint8Array(e)), s = new DOMParser().parseFromString(t, \"text/xml\"), i = (s.querySelector(\"WMS_Capabilities\") || s.querySelector(\"WMT_MS_Capabilities\")).getAttribute(\"version\"), r = s.querySelector(\"Capability\"), o = Jr(s.querySelector(\":scope > Service\")), l = eo(r.querySelector(\":scope > Request\")), c = Array.from(r.querySelectorAll(\":scope > Layer\")).map((h) => Hn(h, i)), u = qn(c);\n return { version: i, service: o, layers: u, request: l };\n }\n}\nexport {\n Kt as B,\n ho as C,\n Bo as D,\n cr as G,\n So as I,\n wo as L,\n ar as M,\n Do as O,\n zi as Q,\n Ro as R,\n Po as S,\n vo as T,\n xo as U,\n No as W,\n Mo as X,\n bo as a,\n Lo as b,\n Oo as c,\n go as d,\n lr as e,\n rr as f,\n Co as g,\n Eo as h,\n yo as i,\n vs as j,\n Pi as k,\n mo as l,\n _o as m,\n To as n,\n fo as o,\n Ao as p,\n uo as q,\n Uo as r,\n Io as s,\n co as t,\n lo as u\n};\n//# sourceMappingURL=WMSCapabilitiesLoader-X7r6Cf4e.js.map\n","import {\r\n Group,\r\n InstancedMesh,\r\n LoadingManager,\r\n Matrix4,\r\n Mesh,\r\n MeshStandardMaterial,\r\n Quaternion,\r\n Scene,\r\n Texture,\r\n Vector3,\r\n Loader,\r\n} from \"three\";\r\nimport {\r\n acquireWorker,\r\n buildTextures,\r\n buildMaterials,\r\n buildMeshPrimitives,\r\n type PrimitiveData,\r\n getWorkers,\r\n} from \"./utils\";\r\nimport type { GLTFNodeData, GLTFWorkerData, MaterialBuilder } from \"./types\";\r\nimport { StructuralMetadata, MeshFeatures } from \"3d-tiles-renderer/plugins\";\r\n\r\n// 隔离接收oid数组\r\n\r\n// Extension names\r\nconst EXT_STRUCTURAL_METADATA = \"EXT_structural_metadata\";\r\nconst EXT_MESH_FEATURES = \"EXT_mesh_features\";\r\n\r\n/**\r\n * GLTFWorkerLoader configuration options\r\n */\r\nexport interface GLTFWorkerLoaderOptions {\r\n /** Whether to enable metadata support (EXT_mesh_features, EXT_structural_metadata) */\r\n metadata?: boolean;\r\n /** Custom material builder function */\r\n materialBuilder?: MaterialBuilder;\r\n}\r\n\r\nlet uuid = 0;\r\n\r\n/**\r\n * Custom Loader using Worker for GLTF parsing\r\n */\r\nexport class GLTFWorkerLoader extends Loader {\r\n private _metadata: boolean = true;\r\n private _materialBuilder?: MaterialBuilder;\r\n private _loaderId = uuid++;\r\n private _callbacks = new Map<\r\n number,\r\n { resolve: (data: any) => void; reject: (err: Error) => void }\r\n >();\r\n private _nextRequestId = 1;\r\n\r\n constructor(manager?: LoadingManager, options?: GLTFWorkerLoaderOptions) {\r\n super(manager);\r\n this._metadata = options?.metadata ?? true;\r\n this._materialBuilder = options?.materialBuilder;\r\n\r\n this.addListeners();\r\n }\r\n\r\n addListeners() {\r\n const workers = getWorkers();\r\n workers.forEach((worker) => {\r\n worker.addEventListener(\"message\", this._onMessage);\r\n });\r\n }\r\n\r\n removeListeners() {\r\n const workers = getWorkers();\r\n workers.forEach((worker) => {\r\n worker.removeEventListener(\"message\", this._onMessage);\r\n });\r\n }\r\n\r\n /**\r\n * Asynchronously parse GLTF buffer\r\n */\r\n async parseAsync(buffer: ArrayBuffer, path: string): Promise<any> {\r\n // Acquire available Worker\r\n const worker = acquireWorker();\r\n\r\n // Parse using worker\r\n const data = await this.parseWithWorker(worker, buffer, path);\r\n\r\n // Build Three.js scene\r\n const scene = this.buildSceneFromGLTFData(data);\r\n\r\n // Return format identical to GLTFLoader\r\n return {\r\n scene: scene,\r\n scenes: [scene],\r\n animations: [],\r\n cameras: [],\r\n asset: {\r\n generator: \"GLTFWorkerLoader\",\r\n version: \"2.0\",\r\n },\r\n parser: null as any,\r\n userData: {},\r\n };\r\n }\r\n\r\n /**\r\n * Parse GLTF data using Worker\r\n */\r\n private parseWithWorker(\r\n worker: Worker,\r\n buffer: ArrayBuffer,\r\n workingPath: string,\r\n ): Promise<GLTFWorkerData> {\r\n return new Promise((resolve, reject) => {\r\n const requestId = this._nextRequestId++;\r\n this._callbacks.set(requestId, { resolve, reject });\r\n\r\n // Send buffer and working path to worker\r\n worker.postMessage(\r\n {\r\n method: \"parseTile\",\r\n buffer: buffer,\r\n root: workingPath,\r\n loaderId: this._loaderId,\r\n requestId,\r\n fetchOptions: {\r\n referrer: window.location.href,\r\n referrerPolicy: \"origin\",\r\n },\r\n },\r\n [buffer],\r\n );\r\n });\r\n }\r\n\r\n private _onMessage = (event: MessageEvent) => {\r\n const { type, data, error, loaderId, requestId } = event.data;\r\n\r\n // loaderId here is our requestId\r\n if (loaderId !== this._loaderId) return;\r\n const callback = this._callbacks.get(requestId);\r\n if (!callback) return;\r\n\r\n this._callbacks.delete(requestId);\r\n\r\n if (type === \"success\") {\r\n callback.resolve(data);\r\n } else if (type === \"error\") {\r\n callback.reject(new Error(error));\r\n }\r\n };\r\n\r\n /**\r\n * Convert GLTF data returned by Worker to Three.js Scene\r\n */\r\n private buildSceneFromGLTFData(data: GLTFWorkerData): Scene {\r\n const scene = new Scene();\r\n\r\n // Build textures\r\n const { textureMap, textureArray } = buildTextures(data);\r\n\r\n // Build materials\r\n const materialMap = buildMaterials(data, textureMap, this._materialBuilder);\r\n\r\n // Create default material\r\n const defaultMaterial = new MeshStandardMaterial({ color: 0xcccccc });\r\n\r\n // Build mesh primitives\r\n const meshMap = buildMeshPrimitives(data, materialMap, defaultMaterial);\r\n\r\n // Parse node\r\n const parseNodeData = (nodeData: GLTFNodeData): Group => {\r\n const node = new Group();\r\n\r\n const primitiveDataList = meshMap.get(nodeData.mesh);\r\n if (primitiveDataList) {\r\n if (nodeData.instanceData) {\r\n // EXT_mesh_gpu_instancing: create InstancedMesh per primitive\r\n const { count, TRANSLATION, ROTATION, SCALE } = nodeData.instanceData;\r\n\r\n for (const {\r\n geometry,\r\n material,\r\n primitiveIndex,\r\n } of primitiveDataList) {\r\n const instancedMesh = new InstancedMesh(geometry, material, count);\r\n\r\n const tmpMatrix = new Matrix4();\r\n const tmpPos = new Vector3();\r\n const tmpQuat = new Quaternion();\r\n const tmpScale = new Vector3(1, 1, 1);\r\n\r\n for (let i = 0; i < count; i++) {\r\n if (TRANSLATION) {\r\n tmpPos.set(\r\n TRANSLATION[i * 3],\r\n TRANSLATION[i * 3 + 1],\r\n TRANSLATION[i * 3 + 2],\r\n );\r\n } else {\r\n tmpPos.set(0, 0, 0);\r\n }\r\n\r\n if (ROTATION) {\r\n tmpQuat.set(\r\n ROTATION[i * 4],\r\n ROTATION[i * 4 + 1],\r\n ROTATION[i * 4 + 2],\r\n ROTATION[i * 4 + 3],\r\n );\r\n } else {\r\n tmpQuat.identity();\r\n }\r\n\r\n if (SCALE) {\r\n tmpScale.set(SCALE[i * 3], SCALE[i * 3 + 1], SCALE[i * 3 + 2]);\r\n } else {\r\n tmpScale.set(1, 1, 1);\r\n }\r\n\r\n tmpMatrix.compose(tmpPos, tmpQuat, tmpScale);\r\n instancedMesh.setMatrixAt(i, tmpMatrix);\r\n }\r\n\r\n instancedMesh.instanceMatrix.needsUpdate = true;\r\n instancedMesh.userData._gltfMeshIndex = nodeData.mesh;\r\n instancedMesh.userData._gltfPrimitiveIndex = primitiveIndex;\r\n node.add(instancedMesh);\r\n }\r\n } else {\r\n for (const {\r\n geometry,\r\n material,\r\n primitiveIndex,\r\n } of primitiveDataList) {\r\n const mesh = new Mesh(geometry, material);\r\n mesh.userData._gltfMeshIndex = nodeData.mesh;\r\n mesh.userData._gltfPrimitiveIndex = primitiveIndex;\r\n node.add(mesh);\r\n }\r\n }\r\n }\r\n\r\n // Set node name\r\n if (nodeData.name) {\r\n node.name = nodeData.name;\r\n }\r\n\r\n // Apply transformation\r\n if (nodeData.matrix) {\r\n const m = new Matrix4();\r\n m.fromArray(nodeData.matrix);\r\n node.applyMatrix4(m);\r\n } else {\r\n if (nodeData.translation) {\r\n node.position.set(\r\n nodeData.translation[0],\r\n nodeData.translation[1],\r\n nodeData.translation[2],\r\n );\r\n }\r\n if (nodeData.rotation) {\r\n node.quaternion.set(\r\n nodeData.rotation[0],\r\n nodeData.rotation[1],\r\n nodeData.rotation[2],\r\n nodeData.rotation[3],\r\n );\r\n }\r\n if (nodeData.scale) {\r\n node.scale.set(\r\n nodeData.scale[0],\r\n nodeData.scale[1],\r\n nodeData.scale[2],\r\n );\r\n }\r\n }\r\n\r\n // Recursively process child nodes\r\n if (nodeData.children && Array.isArray(nodeData.children)) {\r\n for (const child of nodeData.children) {\r\n const childNode = parseNodeData(child);\r\n node.add(childNode);\r\n }\r\n }\r\n\r\n return node;\r\n };\r\n\r\n // Add scene nodes\r\n const sceneData = data.scenes[0];\r\n for (const nodeData of sceneData.nodes) {\r\n const node = parseNodeData(nodeData);\r\n scene.add(node);\r\n }\r\n\r\n // Process metadata (if enabled)\r\n if (this._metadata) {\r\n this.processMetadata(scene, data, textureArray, meshMap);\r\n }\r\n\r\n return scene;\r\n }\r\n\r\n /**\r\n * Process and attach metadata to scene and mesh objects\r\n */\r\n private processMetadata(\r\n scene: Scene,\r\n data: GLTFWorkerData,\r\n textures: (Texture | null)[],\r\n meshMap: Map<number, PrimitiveData[]>,\r\n ): void {\r\n const extensionsUsed = data.json?.extensionsUsed || [];\r\n const hasStructuralMetadata = extensionsUsed.includes(\r\n EXT_STRUCTURAL_METADATA,\r\n );\r\n const hasMeshFeatures = extensionsUsed.includes(EXT_MESH_FEATURES);\r\n\r\n if (!hasStructuralMetadata && !hasMeshFeatures) {\r\n return;\r\n }\r\n\r\n // Process EXT_structural_metadata\r\n let rootMetadata: any = null;\r\n if (hasStructuralMetadata && data.structuralMetadata) {\r\n const rootExtension = data.json?.extensions?.[EXT_STRUCTURAL_METADATA];\r\n if (rootExtension) {\r\n const definition = {\r\n schema: data.structuralMetadata.schema,\r\n propertyTables: data.structuralMetadata.propertyTables || [],\r\n propertyTextures: rootExtension.propertyTextures || [],\r\n propertyAttributes: rootExtension.propertyAttributes || [],\r\n };\r\n\r\n const buffers = data.structuralMetadata.buffers || [];\r\n rootMetadata = new StructuralMetadata(definition, textures, buffers);\r\n scene.userData.structuralMetadata = rootMetadata;\r\n }\r\n }\r\n\r\n // Traverse all meshes in the scene, process mesh-level metadata\r\n scene.traverse((child) => {\r\n if (!(child instanceof Mesh)) return;\r\n\r\n const meshIndex = child.userData._gltfMeshIndex as number | undefined;\r\n const primitiveIndex = child.userData._gltfPrimitiveIndex as\r\n | number\r\n | undefined;\r\n if (meshIndex === undefined || primitiveIndex === undefined) return;\r\n\r\n const primitiveDataList = meshMap.get(meshIndex);\r\n if (!primitiveDataList) return;\r\n\r\n const primitiveData = primitiveDataList.find(\r\n (p) => p.primitiveIndex === primitiveIndex,\r\n );\r\n if (!primitiveData) return;\r\n\r\n const extensions = primitiveData.extensions;\r\n\r\n // Process EXT_structural_metadata (primitive level)\r\n if (hasStructuralMetadata && rootMetadata) {\r\n const primMetadataExt = extensions?.[EXT_STRUCTURAL_METADATA];\r\n if (primMetadataExt) {\r\n const rootExtension =\r\n data.json?.extensions?.[EXT_STRUCTURAL_METADATA];\r\n if (rootExtension) {\r\n const definition = {\r\n schema: data.structuralMetadata!.schema,\r\n propertyTables: data.structuralMetadata!.propertyTables || [],\r\n propertyTextures: rootExtension.propertyTextures || [],\r\n propertyAttributes: rootExtension.propertyAttributes || [],\r\n };\r\n const buffers = data.structuralMetadata!.buffers || [];\r\n\r\n child.userData.structuralMetadata = new StructuralMetadata(\r\n definition,\r\n textures,\r\n buffers,\r\n primMetadataExt,\r\n child,\r\n );\r\n }\r\n } else {\r\n child.userData.structuralMetadata = rootMetadata;\r\n }\r\n }\r\n\r\n // Process EXT_mesh_features\r\n if (hasMeshFeatures) {\r\n const meshFeaturesExt = extensions?.[EXT_MESH_FEATURES];\r\n if (meshFeaturesExt) {\r\n child.userData.meshFeatures = new MeshFeatures(\r\n child.geometry,\r\n textures,\r\n meshFeaturesExt,\r\n );\r\n }\r\n }\r\n });\r\n }\r\n}\r\n","import type { PartEffectHost } from \"./part-effect-host\";\nimport type { ColorInput } from \"../utils/color-input\";\nimport { toColor } from \"../utils/color-input\";\nimport { Color, Material, Mesh, MeshStandardMaterial } from \"three\";\n\nexport type { ColorInput } from \"../utils/color-input\";\n\nfunction getMaterials(mesh: Mesh): Material[] {\n const mat = mesh.material;\n if (!mat) return [];\n return Array.isArray(mat) ? mat : [mat];\n}\n\n/** 根据颜色创建材质,相同颜色复用同一材质 */\nfunction getMaterialForColor(color: Color): MeshStandardMaterial {\n const key = color.getHex();\n if (!materialCache.has(key)) {\n materialCache.set(key, new MeshStandardMaterial({\n color: color.clone(),\n roughness: 0.5,\n metalness: 0.1,\n }));\n }\n return materialCache.get(key)!;\n}\n\nconst materialCache = new Map<number, MeshStandardMaterial>();\n\n/**\n * 构件着色/透明度辅助器,参考 example 逻辑:hidePartsByOids -> 修改材质 -> scene.add -> mesh-change 监听\n * 由 GLTFParserPlugin 内部使用,scene 通过 tiles.group 获取\n */\nexport class PartColorHelper {\n private coloredOids = new Set<number>();\n private materialByOid = new Map<number, MeshStandardMaterial>();\n private originalMaterialByMesh = new Map<string, Material>();\n private opacityModifiedOids = new Set<number>();\n private opacityByOid = new Map<number, number>();\n private originalOpacityByMaterial = new Map<Material, number>();\n private meshChangeHandlers = new Map<number, () => void>();\n\n constructor(private context: PartEffectHost) {}\n\n private getAllModifiedOids(): number[] {\n return Array.from(new Set([...this.coloredOids, ...this.opacityModifiedOids]));\n }\n\n private applyToMeshes(oid: number): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const collector = this.context.getMeshCollectorByOid(oid);\n\n const colorMaterial = this.materialByOid.get(oid);\n const opacity = this.opacityByOid.get(oid);\n\n collector.meshes.forEach((mesh) => {\n if (!mesh.parent) scene.add(mesh);\n\n if (colorMaterial) {\n mesh.material = colorMaterial;\n }\n\n if (opacity !== undefined) {\n for (const mat of getMaterials(mesh)) {\n if (!this.originalOpacityByMaterial.has(mat)) {\n this.originalOpacityByMaterial.set(mat, mat.opacity);\n }\n mat.opacity = opacity;\n mat.transparent = opacity < 1;\n }\n }\n });\n }\n\n /**\n * 根据 oid 数组设置构件颜色\n * 隐藏原 mesh,将 split mesh 替换材质后加入场景\n */\n setPartColorByOids(oids: number[], color: ColorInput): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const threeColor = toColor(color);\n const material = getMaterialForColor(threeColor);\n\n for (const oid of oids) {\n this.coloredOids.add(oid);\n this.materialByOid.set(oid, material);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n if (!this.originalMaterialByMesh.has(mesh.uuid)) {\n this.originalMaterialByMesh.set(mesh.uuid, mesh.material as Material);\n }\n mesh.material = material;\n scene.add(mesh);\n });\n\n if (!this.meshChangeHandlers.has(oid)) {\n const handler = () => this.applyToMeshes(oid);\n this.meshChangeHandlers.set(oid, handler);\n collector.addEventListener(\"mesh-change\", handler);\n }\n }\n\n this.context.hidePartsByOids(this.getAllModifiedOids());\n }\n\n /**\n * 恢复指定构件的颜色\n * 若该 oid 已无颜色且无透明度修改,则从场景移除 split mesh 并 unhide 原 mesh\n */\n restorePartColorByOids(oids: number[]): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n for (const oid of oids) {\n this.coloredOids.delete(oid);\n this.materialByOid.delete(oid);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n const opacity = this.opacityByOid.get(oid);\n\n collector.meshes.forEach((mesh) => {\n const originalMat = this.originalMaterialByMesh.get(mesh.uuid);\n if (originalMat) {\n mesh.material = originalMat;\n this.originalMaterialByMesh.delete(mesh.uuid);\n if (opacity !== undefined) {\n for (const mat of getMaterials(mesh)) {\n if (!this.originalOpacityByMaterial.has(mat)) {\n this.originalOpacityByMaterial.set(mat, mat.opacity);\n }\n mat.opacity = opacity;\n mat.transparent = opacity < 1;\n }\n }\n }\n if (\n !this.coloredOids.has(oid) &&\n !this.opacityModifiedOids.has(oid) &&\n mesh.parent === scene\n ) {\n scene.remove(mesh);\n }\n });\n\n if (!this.coloredOids.has(oid) && !this.opacityModifiedOids.has(oid)) {\n const handler = this.meshChangeHandlers.get(oid);\n if (handler) {\n this.meshChangeHandlers.delete(oid);\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n }\n\n this.context.showPartsByOids(oids);\n }\n\n /**\n * 根据 oid 数组设置构件透明度\n * 隐藏原 mesh,将 split mesh 修改材质透明度后加入场景\n * @param oids 构件 OID 数组\n * @param opacity 透明度,0-1,0 完全透明,1 完全不透明\n */\n setPartOpacityByOids(oids: number[], opacity: number): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const clampedOpacity = Math.max(0, Math.min(1, opacity));\n\n for (const oid of oids) {\n this.opacityModifiedOids.add(oid);\n this.opacityByOid.set(oid, clampedOpacity);\n\n const colorMat = this.materialByOid.get(oid);\n if (colorMat && colorMat.opacity !== clampedOpacity) {\n const clone = colorMat.clone();\n clone.opacity = clampedOpacity;\n clone.transparent = clampedOpacity < 1;\n this.materialByOid.set(oid, clone);\n this.originalOpacityByMaterial.set(clone, 1);\n }\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n scene.add(mesh);\n const mat = colorMat\n ? (this.materialByOid.get(oid) as Material)\n : (mesh.material as Material);\n if (!this.originalOpacityByMaterial.has(mat)) {\n this.originalOpacityByMaterial.set(mat, mat.opacity);\n }\n mat.opacity = clampedOpacity;\n mat.transparent = clampedOpacity < 1;\n if (colorMat) mesh.material = mat;\n });\n\n if (!this.meshChangeHandlers.has(oid)) {\n const handler = () => this.applyToMeshes(oid);\n this.meshChangeHandlers.set(oid, handler);\n collector.addEventListener(\"mesh-change\", handler);\n }\n }\n\n this.context.hidePartsByOids(this.getAllModifiedOids());\n }\n\n /**\n * 恢复指定构件的透明度\n * 若该 oid 已无颜色且无透明度修改,则从场景移除 split mesh 并 unhide 原 mesh\n */\n restorePartOpacityByOids(oids: number[]): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n for (const oid of oids) {\n this.opacityModifiedOids.delete(oid);\n this.opacityByOid.delete(oid);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n for (const mat of getMaterials(mesh)) {\n const original = this.originalOpacityByMaterial.get(mat);\n if (original !== undefined) {\n mat.opacity = original;\n mat.transparent = original < 1;\n this.originalOpacityByMaterial.delete(mat);\n }\n }\n if (\n !this.coloredOids.has(oid) &&\n !this.opacityModifiedOids.has(oid) &&\n mesh.parent === scene\n ) {\n scene.remove(mesh);\n }\n });\n\n if (!this.coloredOids.has(oid) && !this.opacityModifiedOids.has(oid)) {\n const handler = this.meshChangeHandlers.get(oid);\n if (handler) {\n this.meshChangeHandlers.delete(oid);\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n }\n\n this.context.showPartsByOids(oids);\n }\n}\n","import type { PartEffectHost } from \"./part-effect-host\";\nimport type { ColorInput } from \"../utils/color-input\";\nimport { toColor } from \"../utils/color-input\";\nimport { Color, Material, MeshStandardMaterial } from \"three\";\n\n/**\n * 构件闪烁强调辅助器\n * 通过 hidePartsByOids + split mesh + emissive 动画实现闪烁效果\n */\nexport class PartBlinkHelper {\n private blinkOids = new Set<number>();\n private originalMaterialByMesh = new Map<string, Material>();\n private meshChangeHandlers = new Map<number, () => void>();\n\n private blinkMaterial: MeshStandardMaterial;\n private blinkColor: Color;\n private cycleMs: number;\n private flashTime = 0;\n private rafId: number | null = null;\n private lastTime = 0;\n\n constructor(private context: PartEffectHost) {\n this.blinkColor = new Color(0xffaa00);\n this.blinkMaterial = new MeshStandardMaterial({\n color: this.blinkColor.clone(),\n emissive: this.blinkColor.clone(),\n emissiveIntensity: 0.5,\n transparent: true,\n opacity: 0.9,\n });\n this.cycleMs = 1000;\n }\n\n private applyBlinkToMeshes(oid: number): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n if (!mesh.parent) scene.add(mesh);\n if (!this.originalMaterialByMesh.has(mesh.uuid)) {\n this.originalMaterialByMesh.set(mesh.uuid, mesh.material as Material);\n }\n mesh.material = this.blinkMaterial;\n });\n }\n\n private startAnimation(): void {\n if (this.rafId !== null) return;\n this.lastTime = performance.now();\n\n const tick = () => {\n this.rafId = requestAnimationFrame(tick);\n const now = performance.now();\n const delta = (now - this.lastTime) / this.cycleMs;\n this.lastTime = now;\n this.flashTime += delta * Math.PI * 2;\n const intensity = 0.3 + Math.sin(this.flashTime) * 0.3;\n this.blinkMaterial.emissiveIntensity = intensity;\n };\n tick();\n }\n\n private stopAnimation(): void {\n if (this.rafId !== null) {\n cancelAnimationFrame(this.rafId);\n this.rafId = null;\n }\n }\n\n /**\n * 设置需要闪烁的构件\n * @param oids 构件 OID 数组\n */\n setBlinkPartsByOids(oids: number[]): void {\n this.clearAllBlinkParts();\n\n const scene = this.context.getScene();\n if (!scene) return;\n\n for (const oid of oids) {\n this.blinkOids.add(oid);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n if (!this.originalMaterialByMesh.has(mesh.uuid)) {\n this.originalMaterialByMesh.set(mesh.uuid, mesh.material as Material);\n }\n mesh.material = this.blinkMaterial;\n scene.add(mesh);\n });\n\n const handler = () => this.applyBlinkToMeshes(oid);\n this.meshChangeHandlers.set(oid, handler);\n collector.addEventListener(\"mesh-change\", handler);\n }\n\n this.context.hidePartsByOids(Array.from(this.blinkOids));\n if (this.blinkOids.size > 0) this.startAnimation();\n }\n\n /**\n * 设置闪烁颜色\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setBlinkColor(color: ColorInput): void {\n const c = toColor(color);\n this.blinkColor.copy(c);\n this.blinkMaterial.color.copy(c);\n this.blinkMaterial.emissive.copy(c);\n }\n\n /**\n * 设置闪烁周期时间(毫秒)\n * @param ms 一个完整闪烁周期(暗->亮->暗)的时长,默认 1000\n */\n setBlinkIntervalTime(ms: number): void {\n this.cycleMs = Math.max(100, ms);\n }\n\n /**\n * 清除所有闪烁构件\n */\n clearAllBlinkParts(): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n this.stopAnimation();\n\n const oidsToUnhide = Array.from(this.blinkOids);\n\n for (const oid of oidsToUnhide) {\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.meshes.forEach((mesh) => {\n const original = this.originalMaterialByMesh.get(mesh.uuid);\n if (original) {\n mesh.material = original;\n this.originalMaterialByMesh.delete(mesh.uuid);\n }\n if (mesh.parent === scene) scene.remove(mesh);\n });\n\n const handler = this.meshChangeHandlers.get(oid);\n if (handler) {\n this.meshChangeHandlers.delete(oid);\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n\n this.blinkOids.clear();\n this.context.showPartsByOids(oidsToUnhide);\n }\n\n dispose(): void {\n this.clearAllBlinkParts();\n }\n}\n","import type { PartEffectHost } from \"./part-effect-host\";\nimport type { ColorInput } from \"../utils/color-input\";\nimport { toColor } from \"../utils/color-input\";\nimport {\n DoubleSide,\n EdgesGeometry,\n LineSegments,\n Material,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n} from \"three\";\n\ninterface FrameOidData {\n meshes: Mesh[];\n lines: LineSegments[];\n}\n\n/**\n * 构件线框显示辅助器\n * 通过 hidePartsByOids + split mesh + 填充材质 + EdgesGeometry 实现线框效果\n */\nconst DEFAULT_FRAME_COLOR = 0x00d4aa;\n\nexport class PartFrameHelper {\n private frameOids = new Set<number>();\n private originalMaterialByMesh = new Map<string, Material>();\n private frameDataByOid = new Map<number, FrameOidData>();\n private meshChangeHandlers = new Map<number, () => void>();\n\n private fillColorByOid = new Map<number, number>();\n private edgeColorByOid = new Map<number, number>();\n private fillMaterialCache = new Map<number, MeshBasicMaterial>();\n private edgeMaterialCache = new Map<number, MeshBasicMaterial>();\n private edgeThreshold: number;\n\n constructor(private context: PartEffectHost) {\n this.edgeThreshold = 15;\n }\n\n private getFillMaterial(hex: number): MeshBasicMaterial {\n if (!this.fillMaterialCache.has(hex)) {\n this.fillMaterialCache.set(\n hex,\n new MeshBasicMaterial({\n color: hex,\n transparent: true,\n opacity: 0.3,\n side: DoubleSide,\n depthWrite: false,\n })\n );\n }\n return this.fillMaterialCache.get(hex)!;\n }\n\n private getEdgeMaterial(hex: number): MeshBasicMaterial {\n if (!this.edgeMaterialCache.has(hex)) {\n this.edgeMaterialCache.set(\n hex,\n new MeshBasicMaterial({\n color: hex,\n transparent: true,\n opacity: 0.8,\n })\n );\n }\n return this.edgeMaterialCache.get(hex)!;\n }\n\n private createWireframeForMeshes(\n meshes: Mesh[],\n scene: Object3D,\n oid: number\n ): FrameOidData {\n const fillHex = this.fillColorByOid.get(oid) ?? DEFAULT_FRAME_COLOR;\n const edgeHex = this.edgeColorByOid.get(oid) ?? DEFAULT_FRAME_COLOR;\n const fillMaterial = this.getFillMaterial(fillHex);\n const edgeMaterial = this.getEdgeMaterial(edgeHex);\n\n const frameMeshes: Mesh[] = [];\n const lines: LineSegments[] = [];\n\n for (const mesh of meshes) {\n if (!this.originalMaterialByMesh.has(mesh.uuid)) {\n this.originalMaterialByMesh.set(mesh.uuid, mesh.material as Material);\n }\n mesh.material = fillMaterial;\n scene.add(mesh);\n frameMeshes.push(mesh);\n\n const edges = new EdgesGeometry(mesh.geometry, this.edgeThreshold);\n const line = new LineSegments(edges, edgeMaterial);\n line.matrix.copy(mesh.matrixWorld);\n line.matrixAutoUpdate = false;\n scene.add(line);\n lines.push(line);\n }\n\n return { meshes: frameMeshes, lines };\n }\n\n private removeFrameData(data: FrameOidData, scene: Object3D): void {\n for (const mesh of data.meshes) {\n const original = this.originalMaterialByMesh.get(mesh.uuid);\n if (original) {\n mesh.material = original;\n this.originalMaterialByMesh.delete(mesh.uuid);\n }\n if (mesh.parent === scene) scene.remove(mesh);\n }\n for (const line of data.lines) {\n if (line.parent === scene) scene.remove(line);\n line.geometry.dispose();\n }\n }\n\n private applyFrameToOid(oid: number): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const collector = this.context.getMeshCollectorByOid(oid);\n const oldData = this.frameDataByOid.get(oid);\n if (oldData) this.removeFrameData(oldData, scene);\n\n const newData = this.createWireframeForMeshes(collector.meshes, scene, oid);\n this.frameDataByOid.set(oid, newData);\n }\n\n /**\n * 设置需要线框显示的构件\n * @param oids 构件 OID 数组\n */\n setFramePartsByOids(oids: number[]): void {\n this.clearAllFrameParts();\n\n const scene = this.context.getScene();\n if (!scene) return;\n\n for (const oid of oids) {\n this.frameOids.add(oid);\n\n const collector = this.context.getMeshCollectorByOid(oid);\n const data = this.createWireframeForMeshes(collector.meshes, scene, oid);\n this.frameDataByOid.set(oid, data);\n\n const handler = () => this.applyFrameToOid(oid);\n this.meshChangeHandlers.set(oid, handler);\n collector.addEventListener(\"mesh-change\", handler);\n }\n\n this.context.hidePartsByOids(Array.from(this.frameOids));\n }\n\n /**\n * 清除所有线框显示构件\n */\n clearAllFrameParts(): void {\n const scene = this.context.getScene();\n if (!scene) return;\n\n const oidsToUnhide = Array.from(this.frameOids);\n\n for (const oid of oidsToUnhide) {\n const data = this.frameDataByOid.get(oid);\n if (data) {\n this.removeFrameData(data, scene);\n this.frameDataByOid.delete(oid);\n }\n\n const handler = this.meshChangeHandlers.get(oid);\n if (handler) {\n this.meshChangeHandlers.delete(oid);\n const collector = this.context.getMeshCollectorByOid(oid);\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n\n this.frameOids.clear();\n this.fillColorByOid.clear();\n this.edgeColorByOid.clear();\n this.context.showPartsByOids(oidsToUnhide);\n }\n\n /**\n * 设置指定构件的线框填充颜色\n * @param oids 构件 OID 数组\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setFrameFillColor(oids: number[], color: ColorInput): void {\n const hex = toColor(color).getHex();\n for (const oid of oids) {\n if (!this.frameOids.has(oid)) continue;\n this.fillColorByOid.set(oid, hex);\n this.applyFrameToOid(oid);\n }\n }\n\n /**\n * 设置指定构件的线框边框颜色\n * @param oids 构件 OID 数组\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setFrameEdgeColor(oids: number[], color: ColorInput): void {\n const hex = toColor(color).getHex();\n for (const oid of oids) {\n if (!this.frameOids.has(oid)) continue;\n this.edgeColorByOid.set(oid, hex);\n this.applyFrameToOid(oid);\n }\n }\n\n dispose(): void {\n this.clearAllFrameParts();\n this.fillMaterialCache.forEach((m) => m.dispose());\n this.fillMaterialCache.clear();\n this.edgeMaterialCache.forEach((m) => m.dispose());\n this.edgeMaterialCache.clear();\n }\n}\n","import {\n Euler,\n type EulerOrder,\n Material,\n Matrix4,\n Mesh,\n Object3D,\n Vector3,\n} from \"three\";\nimport { evaluateStyleCondition } from \"./style-condition-eval\";\nimport type {\n StyleAppearance,\n StyleCondition,\n StyleEulerInput,\n StyleVec3Input,\n} from \"./style-appearance-types\";\n\nexport type StoredTransform = {\n position: Vector3;\n scale: Vector3;\n rotation: Euler;\n};\n\nexport interface MeshAppearanceMaps {\n originalMaterialByMesh: Map<string, Material>;\n originalTransformByMesh: Map<string, StoredTransform>;\n}\n\nexport function vec3Key(v: StyleVec3Input | undefined): string {\n if (v === undefined) return \"\";\n if (Array.isArray(v)) {\n return `${v[0] ?? 0},${v[1] ?? 0},${v[2] ?? 0}`;\n }\n const p = v as Vector3;\n return `${p.x},${p.y},${p.z}`;\n}\n\nexport function eulerKey(r: StyleEulerInput | undefined): string {\n if (r === undefined) return \"\";\n if (Array.isArray(r)) {\n const order: EulerOrder =\n r.length >= 4 && typeof r[3] === \"string\" ? (r[3] as EulerOrder) : \"XYZ\";\n return `${r[0] ?? 0},${r[1] ?? 0},${r[2] ?? 0},${order}`;\n }\n const e = r as Euler;\n return `${e.x},${e.y},${e.z},${e.order}`;\n}\n\nexport function applyVec3(target: Vector3, input: StyleVec3Input): void {\n if (Array.isArray(input)) {\n target.set(input[0] ?? 0, input[1] ?? 0, input[2] ?? 0);\n } else {\n target.copy(input as Vector3);\n }\n}\n\nexport function applyEuler(target: Euler, input: StyleEulerInput): void {\n if (Array.isArray(input)) {\n if (input.length >= 4 && typeof input[3] === \"string\") {\n target.set(\n input[0] ?? 0,\n input[1] ?? 0,\n input[2] ?? 0,\n input[3] as EulerOrder,\n );\n } else {\n target.set(input[0] ?? 0, input[1] ?? 0, input[2] ?? 0, \"XYZ\");\n }\n } else {\n target.copy(input as Euler);\n }\n}\n\nexport function appearanceGroupKey(a: StyleAppearance): string {\n const m = a.material.uuid;\n const t = vec3Key(a.translation);\n const s = vec3Key(a.scale);\n const r = eulerKey(a.rotation);\n const o = vec3Key(a.origin);\n return `${m}|${t}|${s}|${r}|${o}`;\n}\n\nexport function buildPivotStyleMatrix(\n pivot: Vector3,\n sx: number,\n sy: number,\n sz: number,\n euler: Euler,\n): Matrix4 {\n const m = new Matrix4().makeTranslation(-pivot.x, -pivot.y, -pivot.z);\n m.premultiply(new Matrix4().makeScale(sx, sy, sz));\n m.premultiply(new Matrix4().makeRotationFromEuler(euler));\n m.premultiply(new Matrix4().makeTranslation(pivot.x, pivot.y, pivot.z));\n return m;\n}\n\nexport function resolveConditionsAppearance<T>(\n conditions: [string | boolean, T][] | undefined,\n propertyData: Record<string, unknown> | null,\n): T | null {\n if (!conditions?.length) return null;\n for (const [cond, value] of conditions) {\n if (evaluateStyleCondition(cond, propertyData)) {\n return value;\n }\n }\n return null;\n}\n\nexport function resolveStyleAppearance(\n conditions: StyleCondition[] | undefined,\n propertyData: Record<string, unknown> | null,\n): StyleAppearance | null {\n return resolveConditionsAppearance(conditions, propertyData);\n}\n\n/** 与 setStyle 相同的 OID 分组逻辑(show + conditions → 外观分组 + 被 show 隐藏的 OID) */\nexport function buildAppearanceGroupsFromPropertyMap(\n propertyByOid: Map<number, Record<string, unknown> | null>,\n config: { show?: string; conditions: StyleCondition[] },\n): {\n hiddenOidsList: number[];\n groups: Map<string, { appearance: StyleAppearance; oids: number[] }>;\n} {\n const hiddenOidsList: number[] = [];\n const groups = new Map<\n string,\n { appearance: StyleAppearance; oids: number[] }\n >();\n const conditions = config.conditions ?? [];\n\n for (const [oid, propertyData] of propertyByOid) {\n if (propertyData == null) continue;\n if (config.show) {\n if (!evaluateStyleCondition(config.show, propertyData)) {\n hiddenOidsList.push(oid);\n continue;\n }\n }\n\n const appearance = resolveStyleAppearance(conditions, propertyData);\n if (!appearance) continue;\n\n const gkey = appearanceGroupKey(appearance);\n let g = groups.get(gkey);\n if (!g) {\n g = { appearance, oids: [] };\n groups.set(gkey, g);\n }\n g.oids.push(oid);\n }\n\n return { hiddenOidsList, groups };\n}\n\nexport function restoreMeshAppearanceMaps(\n mesh: Mesh,\n maps: MeshAppearanceMaps,\n): void {\n const original = maps.originalMaterialByMesh.get(mesh.uuid);\n if (original) {\n mesh.material = original;\n maps.originalMaterialByMesh.delete(mesh.uuid);\n }\n const origT = maps.originalTransformByMesh.get(mesh.uuid);\n if (origT) {\n mesh.position.copy(origT.position);\n mesh.scale.copy(origT.scale);\n mesh.rotation.copy(origT.rotation);\n maps.originalTransformByMesh.delete(mesh.uuid);\n }\n}\n\n/**\n * 将 StyleAppearance 应用到 mesh(与 StyleHelper.applyAppearanceToCollector 一致)\n */\nexport function applyStyleAppearanceToMesh(\n mesh: Mesh,\n appearance: StyleAppearance,\n scene: Object3D,\n maps: MeshAppearanceMaps,\n): void {\n if (!maps.originalMaterialByMesh.has(mesh.uuid)) {\n maps.originalMaterialByMesh.set(mesh.uuid, mesh.material as Material);\n }\n mesh.material = appearance.material;\n\n const needTransform =\n appearance.translation !== undefined ||\n appearance.scale !== undefined ||\n appearance.rotation !== undefined;\n\n if (needTransform) {\n if (!maps.originalTransformByMesh.has(mesh.uuid)) {\n maps.originalTransformByMesh.set(mesh.uuid, {\n position: mesh.position.clone(),\n scale: mesh.scale.clone(),\n rotation: mesh.rotation.clone(),\n });\n }\n const bt = maps.originalTransformByMesh.get(mesh.uuid)!;\n mesh.position.copy(bt.position);\n mesh.scale.copy(bt.scale);\n mesh.rotation.copy(bt.rotation);\n\n const hasScaleOrRotation =\n appearance.scale !== undefined || appearance.rotation !== undefined;\n\n if (hasScaleOrRotation) {\n const pivot = new Vector3();\n if (appearance.origin !== undefined) {\n applyVec3(pivot, appearance.origin);\n } else {\n pivot.set(0, 0, 0);\n }\n\n let sx = 1;\n let sy = 1;\n let sz = 1;\n if (appearance.scale !== undefined) {\n if (Array.isArray(appearance.scale)) {\n sx = appearance.scale[0] ?? 1;\n sy = appearance.scale[1] ?? 1;\n sz = appearance.scale[2] ?? 1;\n } else {\n const sc = appearance.scale as Vector3;\n sx = sc.x;\n sy = sc.y;\n sz = sc.z;\n }\n }\n\n const euler = new Euler();\n if (appearance.rotation !== undefined) {\n applyEuler(euler, appearance.rotation);\n } else {\n euler.set(0, 0, 0);\n }\n\n const styleM = buildPivotStyleMatrix(pivot, sx, sy, sz, euler);\n mesh.updateMatrix();\n mesh.matrix.multiply(styleM);\n mesh.matrix.decompose(mesh.position, mesh.quaternion, mesh.scale);\n }\n\n if (appearance.translation !== undefined) {\n applyVec3(mesh.position, appearance.translation);\n }\n }\n\n mesh.updateMatrixWorld();\n scene.add(mesh);\n}\n","import {\n normalizeMeshCollectorOids,\n type MeshCollector,\n type MeshCollectorQuery,\n} from \"../MeshCollector\";\nimport type { TilesRenderer } from \"3d-tiles-renderer\";\nimport { getPropertyDataMapFromTiles } from \"../mesh-helper/mesh\";\nimport { Object3D } from \"three\";\nimport type { Material } from \"three\";\nimport type { StyleConfig } from \"./style-appearance-types\";\nimport {\n applyStyleAppearanceToMesh,\n buildAppearanceGroupsFromPropertyMap,\n type MeshAppearanceMaps,\n type StoredTransform,\n} from \"./style-appearance-shared\";\n\nexport type {\n StyleAppearance,\n StyleConfig,\n StyleCondition,\n StyleEulerInput,\n StyleVec3Input,\n} from \"./style-appearance-types\";\n\n/** 内部使用:插件需提供的接口 */\ninterface StyleHelperContext {\n getTiles(): TilesRenderer | null;\n hidePartsByOids(oids: number[]): void;\n showPartsByOids(oids: number[]): void;\n getMeshCollectorByCondition(query: MeshCollectorQuery): MeshCollector;\n getScene(): Object3D | null;\n}\n\n/**\n * 构件样式辅助器\n * 通过 show 表达式控制可见性,通过 conditions 应用条件材质与可选位姿\n */\nexport class StyleHelper {\n /** 当前样式配置;在插件上可通过 `plugin.style` 读写(与 `setStyle` 等价) */\n style: StyleConfig | null = null;\n private styledOids = new Set<number>();\n private hiddenOids = new Set<number>();\n private originalMaterialByMesh = new Map<string, Material>();\n private originalTransformByMesh = new Map<string, StoredTransform>();\n /** 按材质分组后的收集器,key 与 collector.getCacheKey() 一致 */\n private meshChangeHandlers = new Map<string, () => void>();\n /** 当前样式占用的收集器(用于 clearStyle / 下次 applyStyle 前卸载监听) */\n private styleCollectors: MeshCollector[] = [];\n\n constructor(private context: StyleHelperContext) {}\n\n /**\n * 设置样式\n * @param style 样式配置,传 null 或空对象清除样式\n */\n setStyle(style: StyleConfig | null): void {\n this.clearStyle();\n this.style = style;\n\n if (\n !style ||\n (!style.show && (!style.conditions || style.conditions.length === 0))\n ) {\n return;\n }\n\n this.applyStyle();\n }\n\n /**\n * 清除样式,恢复默认显示\n */\n clearStyle(): void {\n const styledOidsList = Array.from(this.styledOids);\n const hiddenOidsList = Array.from(this.hiddenOids);\n\n for (const collector of this.styleCollectors) {\n collector.meshes.forEach((mesh) => {\n const original = this.originalMaterialByMesh.get(mesh.uuid);\n if (original) {\n mesh.material = original;\n this.originalMaterialByMesh.delete(mesh.uuid);\n }\n const origT = this.originalTransformByMesh.get(mesh.uuid);\n if (origT) {\n mesh.position.copy(origT.position);\n mesh.scale.copy(origT.scale);\n mesh.rotation.copy(origT.rotation);\n this.originalTransformByMesh.delete(mesh.uuid);\n }\n mesh.removeFromParent();\n });\n\n const handler = this.meshChangeHandlers.get(collector.getCacheKey());\n if (handler) {\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n this.meshChangeHandlers.clear();\n this.styleCollectors = [];\n\n this.style = null;\n this.styledOids.clear();\n this.hiddenOids.clear();\n this.context.showPartsByOids([...styledOidsList, ...hiddenOidsList]);\n }\n\n private applyStyle(): void {\n const style = this.style;\n if (!style) return;\n\n const scene = this.context.getScene();\n if (!scene) return;\n\n const tiles = this.context.getTiles();\n if (!tiles) return;\n\n const propertyByOid = getPropertyDataMapFromTiles(tiles);\n\n for (const collector of this.styleCollectors) {\n const h = this.meshChangeHandlers.get(collector.getCacheKey());\n if (h) collector.removeEventListener(\"mesh-change\", h);\n }\n this.styleCollectors = [];\n this.meshChangeHandlers.clear();\n\n const { hiddenOidsList, groups } = buildAppearanceGroupsFromPropertyMap(\n propertyByOid,\n { show: style.show, conditions: style.conditions ?? [] },\n );\n\n for (const { oids } of groups.values()) {\n for (const oid of oids) {\n this.styledOids.add(oid);\n }\n }\n\n this.hiddenOids = new Set(hiddenOidsList);\n const oidsToHide = [...hiddenOidsList];\n for (const { oids } of groups.values()) {\n oidsToHide.push(...oids);\n }\n\n const maps: MeshAppearanceMaps = {\n originalMaterialByMesh: this.originalMaterialByMesh,\n originalTransformByMesh: this.originalTransformByMesh,\n };\n\n for (const { appearance, oids } of groups.values()) {\n const sortedOids = normalizeMeshCollectorOids(oids);\n const collector = this.context.getMeshCollectorByCondition({\n oids: sortedOids,\n });\n this.styleCollectors.push(collector);\n\n const cacheKey = collector.getCacheKey();\n const handler = () => {\n const s = this.context.getScene();\n if (!s) return;\n collector.meshes.forEach((mesh) => {\n applyStyleAppearanceToMesh(mesh, appearance, s, maps);\n });\n };\n this.meshChangeHandlers.set(cacheKey, handler);\n collector.addEventListener(\"mesh-change\", handler);\n handler();\n }\n\n this.context.hidePartsByOids(oidsToHide);\n }\n\n /**\n * 瓦片加载完成后重新应用样式(由插件调用)\n */\n onTilesLoadEnd(): void {\n if (this.style) {\n this.applyStyle();\n }\n }\n\n dispose(): void {\n this.clearStyle();\n }\n}\n","import {\n normalizeMeshCollectorOids,\n type MeshCollector,\n} from \"../MeshCollector\";\nimport { getPropertyDataMapFromTiles } from \"../mesh-helper/mesh\";\nimport { evaluateStyleCondition } from \"./style-condition-eval\";\nimport type { PartEffectHost } from \"./part-effect-host\";\nimport type { ColorInput } from \"../utils/color-input\";\nimport { toColor } from \"../utils/color-input\";\nimport { Color, Material, MeshStandardMaterial } from \"three\";\nimport type {\n StyleAppearance,\n StyleEulerInput,\n StyleVec3Input,\n} from \"./style-appearance-types\";\nimport {\n appearanceGroupKey,\n applyStyleAppearanceToMesh,\n resolveConditionsAppearance,\n restoreMeshAppearanceMaps,\n type MeshAppearanceMaps,\n type StoredTransform,\n} from \"./style-appearance-shared\";\n\n/** 高亮材质:Three.js Material 或 { color, opacity } */\nexport type HighlightMaterial = Material | { color?: ColorInput; opacity?: number };\n\n/** 条件命中后的外观:材质可为简写,位姿与 setStyle 一致 */\nexport interface HighlightAppearance {\n material: HighlightMaterial;\n translation?: StyleVec3Input;\n scale?: StyleVec3Input;\n rotation?: StyleEulerInput;\n origin?: StyleVec3Input;\n}\n\nexport type HighlightCondition = [string | boolean, HighlightAppearance];\n\n/** 高亮配置:语义与 setStyle 一致,并多一个 name 用于命名分组 */\nexport interface HighlightOptions {\n /** 高亮组名称,用于 cancelHighlight(name) 取消 */\n name: string;\n /** 可见性表达式,仅满足条件的构件参与高亮,如 'foo === bar' */\n show?: string;\n /** 条件外观数组,第一个满足条件的应用对应外观;[true, appearance] 为默认 */\n conditions?: HighlightCondition[];\n /** 若指定,仅在这些 OID 与属性数据的交集中应用(与 conditions 组合) */\n oids?: number[];\n}\n\nconst highlightMaterialCache = new Map<string, MeshStandardMaterial>();\n\nfunction getMaterialForHighlight(\n style: { color?: ColorInput; opacity?: number },\n): MeshStandardMaterial {\n const color = style.color != null ? toColor(style.color) : new Color(0xffff00);\n const opacity =\n style.opacity != null ? Math.max(0, Math.min(1, style.opacity)) : 1;\n const key = `${color.getHex()}_${opacity}`;\n\n if (!highlightMaterialCache.has(key)) {\n const mat = new MeshStandardMaterial({\n color: color.clone(),\n roughness: 0.5,\n metalness: 0.1,\n opacity,\n transparent: opacity < 1,\n });\n highlightMaterialCache.set(key, mat);\n }\n return highlightMaterialCache.get(key)!;\n}\n\nfunction toMaterial(value: HighlightMaterial): Material {\n if (value instanceof Material) return value;\n return getMaterialForHighlight(value);\n}\n\nfunction toStyleAppearance(ha: HighlightAppearance): StyleAppearance {\n return {\n material: toMaterial(ha.material),\n translation: ha.translation,\n scale: ha.scale,\n rotation: ha.rotation,\n origin: ha.origin,\n };\n}\n\ninterface HighlightGroupConfig {\n show?: string;\n conditions?: HighlightCondition[];\n oids?: number[];\n}\n\n/**\n * 构件高亮辅助器\n * 与 setStyle 相同的 show / conditions / 位姿语义,多组命名高亮;底层通过 hidePartsByOids + split mesh 实现\n */\nexport class PartHighlightHelper {\n private highlightGroups = new Map<string, HighlightGroupConfig>();\n\n private originalMaterialByMesh = new Map<string, Material>();\n private originalTransformByMesh = new Map<string, StoredTransform>();\n private meshChangeHandlers = new Map<string, () => void>();\n private highlightCollectors: MeshCollector[] = [];\n /** 上次 hidePartsByOids 传入的 OID 列表,用于重新应用前 showParts */\n private lastHiddenOids: number[] = [];\n\n constructor(private context: PartEffectHost) {}\n\n private getMaps(): MeshAppearanceMaps {\n return {\n originalMaterialByMesh: this.originalMaterialByMesh,\n originalTransformByMesh: this.originalTransformByMesh,\n };\n }\n\n /**\n * 合并多组命名高亮:按 Map 插入顺序,后写入的组覆盖同一 OID 的外观\n */\n private mergeAppearanceByOid(\n propertyByOid: Map<number, Record<string, unknown> | null>,\n ): Map<number, StyleAppearance> {\n const appearanceByOid = new Map<number, StyleAppearance>();\n for (const [, hl] of this.highlightGroups) {\n const conditions = (hl.conditions ?? []).map(\n ([c, h]): [string | boolean, StyleAppearance] => [\n c,\n toStyleAppearance(h),\n ],\n );\n for (const [oid, propertyData] of propertyByOid) {\n if (propertyData == null) continue;\n if (hl.oids && !hl.oids.includes(oid)) continue;\n if (hl.show && !evaluateStyleCondition(hl.show, propertyData)) continue;\n const app = resolveConditionsAppearance(conditions, propertyData);\n if (!app) continue;\n appearanceByOid.set(oid, app);\n }\n }\n return appearanceByOid;\n }\n\n /** 各组 show 失败需隐藏的 OID(与 setStyle 一致:show 不满足则隐藏原片) */\n private collectUnionShowHide(\n propertyByOid: Map<number, Record<string, unknown> | null>,\n ): Set<number> {\n const unionHide = new Set<number>();\n for (const [, hl] of this.highlightGroups) {\n for (const [oid, propertyData] of propertyByOid) {\n if (propertyData == null) continue;\n if (hl.oids && !hl.oids.includes(oid)) continue;\n if (hl.show && !evaluateStyleCondition(hl.show, propertyData)) {\n unionHide.add(oid);\n }\n }\n }\n return unionHide;\n }\n\n private clearCollectorsAndRestoreMeshes(): void {\n const maps = this.getMaps();\n for (const collector of this.highlightCollectors) {\n collector.meshes.forEach((mesh) => {\n restoreMeshAppearanceMaps(mesh, maps);\n mesh.removeFromParent();\n });\n const handler = this.meshChangeHandlers.get(collector.getCacheKey());\n if (handler) {\n collector.removeEventListener(\"mesh-change\", handler);\n }\n }\n this.meshChangeHandlers.clear();\n this.highlightCollectors = [];\n }\n\n private reapplyAll(): void {\n this.clearCollectorsAndRestoreMeshes();\n\n if (this.lastHiddenOids.length > 0) {\n this.context.showPartsByOids(this.lastHiddenOids);\n }\n\n if (this.highlightGroups.size === 0) {\n this.lastHiddenOids = [];\n return;\n }\n\n const tiles = this.context.getTiles();\n const scene = this.context.getScene();\n if (!tiles || !scene) return;\n\n const propertyByOid = getPropertyDataMapFromTiles(tiles);\n const appearanceByOid = this.mergeAppearanceByOid(propertyByOid);\n const unionHide = this.collectUnionShowHide(propertyByOid);\n\n const oidsToHide = [\n ...new Set([...appearanceByOid.keys(), ...unionHide]),\n ];\n this.lastHiddenOids = oidsToHide;\n\n const groups = new Map<\n string,\n { appearance: StyleAppearance; oids: number[] }\n >();\n for (const [oid, app] of appearanceByOid) {\n const gkey = appearanceGroupKey(app);\n let g = groups.get(gkey);\n if (!g) {\n g = { appearance: app, oids: [] };\n groups.set(gkey, g);\n }\n g.oids.push(oid);\n }\n\n const maps = this.getMaps();\n\n for (const { appearance, oids } of groups.values()) {\n const sortedOids = normalizeMeshCollectorOids(oids);\n const collector = this.context.getMeshCollectorByCondition({\n oids: sortedOids,\n });\n this.highlightCollectors.push(collector);\n\n const cacheKey = collector.getCacheKey();\n const handler = () => {\n const s = this.context.getScene();\n if (!s) return;\n collector.meshes.forEach((mesh) => {\n applyStyleAppearanceToMesh(mesh, appearance, s, maps);\n });\n };\n this.meshChangeHandlers.set(cacheKey, handler);\n collector.addEventListener(\"mesh-change\", handler);\n handler();\n }\n\n this.context.hidePartsByOids(oidsToHide);\n }\n\n /**\n * 高亮指定构件(语义与 setStyle 一致,多 name 参数)\n */\n highlight(options: HighlightOptions): void {\n const { name, show, conditions, oids } = options;\n if (!show && (!conditions || conditions.length === 0)) {\n this.cancelHighlight(name);\n return;\n }\n\n this.highlightGroups.set(name, { show, conditions, oids });\n this.reapplyAll();\n }\n\n /**\n * 取消指定名称的高亮\n */\n cancelHighlight(name: string): void {\n if (!this.highlightGroups.has(name)) return;\n this.highlightGroups.delete(name);\n this.reapplyAll();\n }\n\n /**\n * 取消所有高亮\n */\n cancelAllHighlight(): void {\n this.highlightGroups.clear();\n this.reapplyAll();\n }\n\n /**\n * 瓦片加载完成后重新应用高亮(由插件调用)\n */\n onTilesLoadEnd(): void {\n if (this.highlightGroups.size === 0) return;\n this.reapplyAll();\n }\n\n dispose(): void {\n this.cancelAllHighlight();\n }\n}\n","import { Mesh } from \"three\";\nimport type { MeshCollector } from \"../MeshCollector\";\n\nexport interface InteractionFilterContext {\n getCollectorCache(): Map<string, MeshCollector>;\n}\n\n/**\n * 冻结与隔离逻辑:管理构件的交互过滤及 MeshCollector 获取的 mesh 在场景中的显隐\n * split mesh 使用 userData.oid(单 feature)或 userData.collectorOids(合并 mesh):任一相关 OID 被冻结/隔离规则命中则整 mesh 脱离场景\n */\nexport class InteractionFilter {\n private frozenOids = new Set<number>();\n private isolatedOids = new Set<number>();\n /** 按 collector 分组键追踪 mesh */\n private trackedMeshes = new Map<string, Set<Mesh>>();\n private meshListeners = new Map<\n Mesh,\n { onAdded: () => void; onRemoved: () => void }\n >();\n private isPluginRemoving = false;\n\n constructor(private context: InteractionFilterContext) {}\n\n isOidBlocked(oid: number): boolean {\n if (this.frozenOids.has(oid)) return true;\n if (this.isolatedOids.size > 0 && !this.isolatedOids.has(oid)) return true;\n return false;\n }\n\n /** 合并 split:任一 collector OID 被 block 则整 mesh 视为应隐藏 */\n private isMeshInteractionBlocked(mesh: Mesh): boolean {\n const coids = mesh.userData?.collectorOids as number[] | undefined;\n if (coids && coids.length > 0) {\n return coids.some((oid) => this.isOidBlocked(oid));\n }\n const oid = mesh.userData?.oid as number | undefined;\n return oid !== undefined && this.isOidBlocked(oid);\n }\n\n private trackMesh(mesh: Mesh): void {\n if (this.meshListeners.has(mesh)) return;\n\n const onAdded = () => {\n if (this.isPluginRemoving) return;\n mesh.userData._detachedParent = null;\n if (this.isMeshInteractionBlocked(mesh) && mesh.parent) {\n const parent = mesh.parent;\n this.isPluginRemoving = true;\n mesh.userData._detachedParent = parent;\n parent.remove(mesh);\n this.isPluginRemoving = false;\n }\n };\n\n const onRemoved = () => {\n if (this.isPluginRemoving) return;\n mesh.userData._detachedParent = null;\n };\n\n mesh.addEventListener(\"added\", onAdded);\n mesh.addEventListener(\"removed\", onRemoved);\n this.meshListeners.set(mesh, { onAdded, onRemoved });\n }\n\n private untrackMesh(mesh: Mesh): void {\n const listeners = this.meshListeners.get(mesh);\n if (listeners) {\n mesh.removeEventListener(\"added\", listeners.onAdded);\n mesh.removeEventListener(\"removed\", listeners.onRemoved);\n this.meshListeners.delete(mesh);\n }\n mesh.userData._detachedParent = null;\n }\n\n onCollectorMeshChange(groupKey: string, newMeshes: Mesh[]): void {\n const tracked = this.trackedMeshes.get(groupKey);\n const newSet = new Set(newMeshes);\n\n if (tracked) {\n for (const mesh of tracked) {\n if (!newSet.has(mesh)) {\n this.untrackMesh(mesh);\n tracked.delete(mesh);\n }\n }\n }\n\n const trackSet = tracked || new Set<Mesh>();\n for (const mesh of newMeshes) {\n if (!trackSet.has(mesh)) {\n this.trackMesh(mesh);\n trackSet.add(mesh);\n }\n }\n this.trackedMeshes.set(groupKey, trackSet);\n }\n\n private syncCollectorMeshes(): void {\n this.isPluginRemoving = true;\n\n for (const [, collector] of this.context.getCollectorCache()) {\n for (const mesh of collector.meshes) {\n if (!this.meshListeners.has(mesh)) continue;\n\n const blocked = this.isMeshInteractionBlocked(mesh);\n\n if (blocked) {\n if (mesh.parent && !mesh.userData._detachedParent) {\n const parent = mesh.parent;\n mesh.userData._detachedParent = parent;\n parent.remove(mesh);\n }\n } else {\n const storedParent = mesh.userData._detachedParent;\n if (storedParent && !mesh.parent) {\n storedParent.add(mesh);\n mesh.userData._detachedParent = null;\n }\n }\n }\n }\n\n this.isPluginRemoving = false;\n }\n\n onUnregisterCollector(groupKey: string): void {\n const tracked = this.trackedMeshes.get(groupKey);\n if (tracked) {\n for (const mesh of tracked) {\n this.untrackMesh(mesh);\n }\n this.trackedMeshes.delete(groupKey);\n }\n }\n\n freezeByOids(oids: number[]): void {\n for (const oid of oids) {\n this.frozenOids.add(oid);\n }\n this.syncCollectorMeshes();\n }\n\n freezeByOid(oid: number): void {\n this.freezeByOids([oid]);\n }\n\n unfreezeByOids(oids: number[]): void {\n for (const oid of oids) {\n this.frozenOids.delete(oid);\n }\n this.syncCollectorMeshes();\n }\n\n unfreezeByOid(oid: number): void {\n this.unfreezeByOids([oid]);\n }\n\n unfreeze(): void {\n this.frozenOids.clear();\n this.syncCollectorMeshes();\n }\n\n getFrozenOids(): number[] {\n return Array.from(this.frozenOids);\n }\n\n isolateByOids(oids: number[]): void {\n for (const oid of oids) {\n this.isolatedOids.add(oid);\n }\n this.syncCollectorMeshes();\n }\n\n isolateByOid(oid: number): void {\n this.isolatedOids.add(oid);\n this.syncCollectorMeshes();\n }\n\n unisolateByOids(oids: number[]): void {\n for (const oid of oids) {\n this.isolatedOids.delete(oid);\n }\n this.syncCollectorMeshes();\n }\n\n unisolateByOid(oid: number): void {\n this.unisolateByOids([oid]);\n }\n\n unisolate(): void {\n this.isolatedOids.clear();\n this.syncCollectorMeshes();\n }\n\n getIsolatedOids(): number[] {\n return Array.from(this.isolatedOids);\n }\n\n dispose(): void {\n for (const [, meshSet] of this.trackedMeshes) {\n for (const mesh of meshSet) {\n this.untrackMesh(mesh);\n }\n }\n this.trackedMeshes.clear();\n this.meshListeners.clear();\n this.frozenOids.clear();\n this.isolatedOids.clear();\n }\n}\n","// IndexedDB constants\nconst DB_NAME = \"GLTFParserPluginTilesCache\";\nconst DB_VERSION = 1;\nconst STORE_NAME = \"tiles\";\n\n/**\n * IndexedDB Cache Manager Class\n */\nexport class TileCacheDB {\n private dbPromise: Promise<IDBDatabase> | null = null;\n\n /**\n * Open/Get database connection\n */\n private openDB(): Promise<IDBDatabase> {\n if (this.dbPromise) {\n return this.dbPromise;\n }\n\n this.dbPromise = new Promise((resolve, reject) => {\n const request = indexedDB.open(DB_NAME, DB_VERSION);\n\n request.onerror = () => {\n reject(request.error);\n };\n\n request.onsuccess = () => {\n resolve(request.result);\n };\n\n request.onupgradeneeded = (event) => {\n const db = (event.target as IDBOpenDBRequest).result;\n if (!db.objectStoreNames.contains(STORE_NAME)) {\n db.createObjectStore(STORE_NAME, { keyPath: \"url\" });\n }\n };\n });\n\n return this.dbPromise;\n }\n\n /**\n * Get data from cache\n * @param url Cache key (processedUrl)\n */\n async get(url: string): Promise<ArrayBuffer | null> {\n try {\n const db = await this.openDB();\n return new Promise((resolve, reject) => {\n const transaction = db.transaction(STORE_NAME, \"readonly\");\n const store = transaction.objectStore(STORE_NAME);\n const request = store.get(url);\n\n request.onerror = () => {\n reject(request.error);\n };\n\n request.onsuccess = () => {\n const result = request.result;\n resolve(result ? result.data : null);\n };\n });\n } catch (error) {\n return null;\n }\n }\n\n /**\n * Store data to cache\n * @param url Cache key (processedUrl)\n * @param data Data to cache\n */\n async set(url: string, data: ArrayBuffer): Promise<void> {\n const db = await this.openDB();\n return new Promise((resolve, reject) => {\n const transaction = db.transaction(STORE_NAME, \"readwrite\");\n const store = transaction.objectStore(STORE_NAME);\n const request = store.put({\n url,\n data,\n timestamp: Date.now(),\n });\n\n request.onerror = () => {\n reject(request.error);\n };\n\n request.onsuccess = () => {\n resolve();\n };\n });\n }\n\n /**\n * Clear cache\n */\n async clear(): Promise<void> {\n const db = await this.openDB();\n return new Promise((resolve, reject) => {\n const transaction = db.transaction(STORE_NAME, \"readwrite\");\n const store = transaction.objectStore(STORE_NAME);\n const request = store.clear();\n\n request.onerror = () => reject(request.error);\n request.onsuccess = () => resolve();\n });\n }\n}\n\n// Global cache instance\nexport const tileCache = new TileCacheDB();\n","import {\n Box3,\n DoubleSide,\n Intersection,\n Material,\n Mesh,\n Object3D,\n Vector3,\n WebGLRenderer,\n} from \"three\";\nimport {\n FeatureInfo,\n applyVisibilityToScene,\n buildOidToFeatureIdMap,\n getAllOidsFromTiles,\n getPropertyDataByOid,\n getTileMeshesByOid,\n queryFeatureFromIntersection,\n splitMeshByOidsMerged,\n} from \"./mesh-helper\";\n\nimport {\n MeshCollector,\n meshCollectorQueryCacheKey,\n normalizeMeshCollectorOids,\n type MeshCollectorQuery,\n type MeshHelperHost,\n} from \"./MeshCollector\";\nimport { evaluateStyleCondition } from \"./plugin/style-condition-eval\";\nimport { GLTFWorkerLoader } from \"./GLTFWorkerLoader\";\nimport type { PartEffectHost } from \"./plugin/part-effect-host\";\nimport { PartColorHelper } from \"./plugin/PartColorHelper\";\nimport type { ColorInput } from \"./utils/color-input\";\nimport { PartBlinkHelper } from \"./plugin/PartBlinkHelper\";\nimport { PartFrameHelper } from \"./plugin/PartFrameHelper\";\nimport {\n StyleHelper,\n type StyleConfig,\n} from \"./plugin/StyleHelper\";\nimport {\n PartHighlightHelper,\n type HighlightOptions,\n} from \"./plugin/PartHighlightHelper\";\nimport { InteractionFilter } from \"./plugin/InteractionFilter\";\nimport { setMaxWorkers } from \"./utils\";\nimport {\n bboxArrayToBox3,\n selectByBoxFromOidMap,\n selectByPolygonFromOidMap,\n} from \"./utils/spatial-query\";\nimport { tileCache } from \"./db\";\nimport { parseEmbeddedStructureDataFromTilesSync } from \"./utils/tileset-structure-uri\";\nimport { TilesRenderer } from \"3d-tiles-renderer\";\n\nimport type {\n GLTFParserPluginOptions,\n ModelInfo,\n StructureData,\n StructureNode,\n} from \"./plugin-types\";\n\nexport type {\n GLTFParserPluginOptions,\n ModelInfo,\n StructureData,\n StructureNode,\n};\n\ninterface TileWithCache {\n engineData?: {\n scene: Object3D;\n };\n}\n\nexport class GLTFParserPlugin implements MeshHelperHost {\n name = \"GLTFParserPlugin\";\n\n private tiles: (TilesRenderer & Record<string, any>) | null = null;\n private _loader: GLTFWorkerLoader | null = null;\n private readonly _gltfRegex = /\\.(gltf|glb)$/g;\n private readonly _options: GLTFParserPluginOptions;\n\n // --- Structure data(tileset.asset.extras.maptalks.structureUri 等,同步解压,不请求 structure.json)---\n private _structureData: StructureData | null = null;\n private _oidNodeMap: Map<number, StructureNode> = new Map();\n /** rootTileset 已存在且已尝试过内嵌解析后仍为 null,则不再重复 gunzip */\n private _structureEmbedResolved = false;\n\n // --- Model info properties ---\n private _modelInfo: ModelInfo | null = null;\n private _modelInfoPromise: Promise<ModelInfo | null> | null = null;\n\n private _interactionFilter: InteractionFilter;\n private _partColorHelper: PartColorHelper | null = null;\n private _partBlinkHelper: PartBlinkHelper | null = null;\n private _partFrameHelper: PartFrameHelper | null = null;\n private _styleHelper: StyleHelper | null = null;\n private _partHighlightHelper: PartHighlightHelper | null = null;\n\n // --- Mesh helper properties ---\n oids: number[] = [];\n /** WebGLRenderer 实例,用于 mesh helper 等扩展 */\n get renderer(): WebGLRenderer | null {\n return this._renderer;\n }\n private _renderer: WebGLRenderer | null = null;\n private splitMeshCache: Map<string, Mesh[]> = new Map();\n private collectors: Set<MeshCollector> = new Set();\n private collectorCache: Map<string, MeshCollector> = new Map();\n\n /**\n * Create a GLTFParserPlugin instance\n * @param options configuration options\n */\n constructor(options?: GLTFParserPluginOptions) {\n this._options = {\n metadata: true,\n maxWorkers: navigator.hardwareConcurrency || 4,\n useIndexedDB: false,\n ...options,\n };\n\n if (options?.renderer) {\n this._renderer = options.renderer;\n }\n\n this._interactionFilter = new InteractionFilter({\n getCollectorCache: () => this.collectorCache,\n });\n\n setMaxWorkers(this._options.maxWorkers!);\n }\n\n /**\n * Plugin initialization, called by TilesRenderer\n */\n init(tiles: TilesRenderer) {\n this.tiles = tiles;\n\n const partFx = this._createPartEffectHost();\n this._partColorHelper = new PartColorHelper(partFx);\n this._partBlinkHelper = new PartBlinkHelper(partFx);\n this._partFrameHelper = new PartFrameHelper(partFx);\n this._styleHelper = new StyleHelper({\n getTiles: () => this.tiles,\n hidePartsByOids: partFx.hidePartsByOids,\n showPartsByOids: partFx.showPartsByOids,\n getMeshCollectorByCondition: partFx.getMeshCollectorByCondition,\n getScene: partFx.getScene,\n });\n this._partHighlightHelper = new PartHighlightHelper(partFx);\n\n // --- GLTF loader setup ---\n this._loader = new GLTFWorkerLoader(tiles.manager, {\n metadata: this._options.metadata,\n materialBuilder: this._options.materialBuilder,\n });\n tiles.manager.addHandler(this._gltfRegex, this._loader);\n\n tiles.addEventListener(\"load-model\", this._onLoadModelCB);\n tiles.addEventListener(\"tiles-load-end\", this._onTilesLoadEndCB);\n tiles.addEventListener(\"load-root-tileset\", this._onLoadRootTilesetCB);\n this._syncStructureFromTileset();\n\n tiles.traverse((tile: any) => {\n const tileWithCache = tile as TileWithCache;\n if (tileWithCache.engineData?.scene) {\n this._onLoadModel(tileWithCache.engineData.scene);\n }\n return true;\n }, null);\n }\n\n private _createPartEffectHost(): PartEffectHost {\n return {\n getTiles: () => this.tiles ?? null,\n hidePartsByOids: (oids) => this.hidePartsByOids(oids),\n showPartsByOids: (oids) => this.showPartsByOids(oids),\n getMeshCollectorByOid: (oid) => this.getMeshCollectorByOid(oid),\n getMeshCollectorByCondition: (q) => this.getMeshCollectorByCondition(q),\n getScene: () => this.tiles?.group ?? null,\n };\n }\n\n // =============================================\n // GLTF Parser Methods\n // =============================================\n\n /**\n * Fetch tile data with IndexedDB caching support\n */\n async fetchData(\n url: string,\n options?: RequestInit,\n ): Promise<Response | ArrayBuffer | object> {\n const isJson = url.toLowerCase().endsWith(\".json\");\n if (!this._options.useIndexedDB || isJson) {\n return this.tiles!.fetchData(url, options);\n }\n\n try {\n const cachedData = await tileCache.get(url);\n\n if (cachedData) {\n return cachedData;\n }\n\n const response = await this.tiles!.fetchData(url, options);\n\n if (!response.ok) {\n return response;\n }\n\n const arrayBuffer = await response.arrayBuffer();\n\n tileCache.set(url, arrayBuffer).catch((err: unknown) => {\n console.warn(\"[GLTFParserPlugin] Failed to cache data:\", err);\n });\n\n return arrayBuffer;\n } catch (error) {\n return this.tiles!.fetchData(url, options);\n }\n }\n\n /**\n * Clear all cached tile data from IndexedDB\n */\n async clearCache(): Promise<void> {\n await tileCache.clear();\n console.info(\"[GLTFParserPlugin] Cache cleared\");\n }\n\n async parseTile(\n buffer: ArrayBuffer,\n tile: any,\n extension: any,\n uri: string,\n abortSignal: AbortSignal,\n ) {\n if (this._options.beforeParseTile) {\n buffer = await this._options.beforeParseTile(\n buffer,\n tile,\n extension,\n uri,\n abortSignal,\n );\n }\n return this.tiles!.parseTile(buffer, tile, extension, uri, abortSignal);\n }\n\n // =============================================\n // Structure Data Methods\n // =============================================\n\n /** 与 tileset 同目录的侧车 JSON,如 structure.json / modelInfo.json */\n private _sidecarJsonUrl(fileName: string): string | null {\n const rootURL = this.tiles?.rootURL as string | undefined;\n if (!rootURL) return null;\n return rootURL.replace(/[^/]+$/, fileName);\n }\n\n private _buildOidNodeMap(\n node: StructureNode,\n map: Map<number, StructureNode>,\n ): void {\n if (node.id !== undefined) {\n map.set(node.id, node);\n }\n if (node.children) {\n for (const child of node.children) {\n this._buildOidNodeMap(child, map);\n }\n }\n }\n\n /** 仅根 tileset 变化时重解析 structureUri(子 tileset 的 load-tileset 不会触发) */\n private _onLoadRootTilesetCB = (): void => {\n this._structureData = null;\n this._oidNodeMap.clear();\n this._structureEmbedResolved = false;\n this._syncStructureFromTileset();\n };\n\n /**\n * 从已加载根 tileset 的内嵌 structure(优先 asset.extras.maptalks.structureUri)同步解压并建索引。\n * rootTileset 尚未就绪时返回 null,可稍后再次调用;已成功或已判定无内嵌数据后见 _structureEmbedResolved。\n */\n private _syncStructureFromTileset(): StructureData | null {\n if (this._structureData) {\n return this._structureData;\n }\n if (this._structureEmbedResolved) {\n return null;\n }\n if (!this.tiles?.rootTileset) {\n return null;\n }\n\n const embedded = parseEmbeddedStructureDataFromTilesSync(this.tiles);\n this._structureEmbedResolved = true;\n\n if (!embedded) {\n return null;\n }\n\n this._structureData = embedded;\n this._oidNodeMap.clear();\n if (embedded.trees) {\n for (const tree of embedded.trees) {\n this._buildOidNodeMap(tree, this._oidNodeMap);\n }\n }\n return embedded;\n }\n\n /**\n * 根据 oid 获取结构树节点(数据来自 tileset 内嵌 structureUri 同步解压)\n */\n getNodeTreeByOid(oid: number): StructureNode | null {\n this._syncStructureFromTileset();\n return this._oidNodeMap.get(oid) ?? null;\n }\n\n /**\n * 根据 oid 数组批量获取结构树节点\n */\n getNodeTreeByOids(oids: number[]): Map<number, StructureNode> {\n this._syncStructureFromTileset();\n const result = new Map<number, StructureNode>();\n for (const oid of oids) {\n const node = this._oidNodeMap.get(oid);\n if (node) {\n result.set(oid, node);\n }\n }\n return result;\n }\n\n /**\n * 根据 oid 从结构数据取轴对齐包围盒(`bbox` 为 `[minX,minY,minZ,maxX,maxY,maxZ]`,与 `selectByBox` 一致)\n * @returns 无对应节点或缺少有效 bbox 时返回 `null`\n */\n getBoundingBoxByOid(oid: number): Box3 | null {\n this._syncStructureFromTileset();\n const node = this._oidNodeMap.get(oid);\n return bboxArrayToBox3(node?.bbox);\n }\n\n /**\n * 计算给定 OID 集合的几何中心(世界坐标系与结构 bbox / 瓦片 mesh 一致)。\n * 优先合并结构树中的轴对齐 bbox;若无有效 bbox 则合并对应 split mesh 的世界包围盒。\n */\n getCenterByOids(oids: readonly number[]): Vector3 | null {\n if (!this.tiles || oids.length === 0) return null;\n const unique = [...new Set(oids)];\n if (unique.length === 0) return null;\n return this._getCenterFromOidList(unique);\n }\n\n /**\n * 按属性条件筛选构件(语义同 `setStyle` 的 `show` / conditions 中的表达式字符串),\n * 返回筛选结果的整体中心点;合并方式同 {@link getCenterByOids}。\n */\n getCenterByCondition(condition: string): Vector3 | null {\n if (!this.tiles) return null;\n const cond = condition.trim();\n if (!cond) return null;\n\n const targetOids: number[] = [];\n for (const oid of getAllOidsFromTiles(this.tiles)) {\n const data = getPropertyDataByOid(this.tiles, oid);\n if (evaluateStyleCondition(cond, data)) {\n targetOids.push(oid);\n }\n }\n if (targetOids.length === 0) return null;\n return this._getCenterFromOidList(targetOids);\n }\n\n /**\n * 完整结构数据(与内嵌 structure JSON 一致)\n */\n getStructureData(): StructureData | null {\n return this._syncStructureFromTileset();\n }\n\n /**\n * 选择包围盒范围内的构件(坐标系与结构 bbox 一致)\n */\n selectByBox(box: Box3): number[] {\n this._syncStructureFromTileset();\n return selectByBoxFromOidMap(this._oidNodeMap, box);\n }\n\n /**\n * 选择多边形(平面投影)范围内的构件\n */\n selectByPolygon(\n polygon: Vector3[],\n axis: \"xy\" | \"xz\" | \"yz\" = \"xz\",\n ): number[] {\n this._syncStructureFromTileset();\n return selectByPolygonFromOidMap(this._oidNodeMap, polygon, axis);\n }\n\n // =============================================\n // Model Info Methods\n // =============================================\n\n private async _fetchModelInfo(): Promise<ModelInfo | null> {\n const url = this._sidecarJsonUrl(\"modelInfo.json\");\n if (!url) {\n console.warn(\n \"[GLTFParserPlugin] Cannot derive modelInfo.json URL: tiles not initialized\",\n );\n return null;\n }\n\n try {\n const response = await fetch(url);\n if (!response.ok) {\n console.warn(\n `[GLTFParserPlugin] Failed to fetch modelInfo.json: ${response.status}`,\n );\n return null;\n }\n const data: ModelInfo = await response.json();\n this._modelInfo = data;\n return data;\n } catch (error) {\n console.error(\"[GLTFParserPlugin] Error loading modelInfo.json:\", error);\n return null;\n }\n }\n\n private async _ensureModelInfoLoaded(): Promise<ModelInfo | null> {\n if (this._modelInfo) return this._modelInfo;\n if (!this._modelInfoPromise) {\n this._modelInfoPromise = this._fetchModelInfo();\n }\n return this._modelInfoPromise;\n }\n\n /**\n * 获取 modelInfo.json 数据\n * 包含模型的基本信息:动画支持、材质数量、顶点数、三角形数等\n * 首次调用时会自动从 tileset URL 推导并请求 modelInfo.json\n */\n async getModelInfo(): Promise<ModelInfo | null> {\n return this._ensureModelInfoLoaded();\n }\n\n // =============================================\n // Mesh Helper Methods (from MaptalksTilerPlugin)\n // =============================================\n\n /**\n * Load model callback\n */\n private _onLoadModelCB = ({ scene }: { scene: Object3D }) => {\n this._onLoadModel(scene);\n };\n\n /**\n * Tiles load end callback\n */\n private _onTilesLoadEndCB = () => {\n this._notifyCollectors();\n };\n\n private _onLoadModel(scene: Object3D) {\n this.splitMeshCache.clear();\n\n buildOidToFeatureIdMap(scene);\n scene.traverse((c) => {\n if ((c as Mesh).material) {\n this._setupMaterial(c as Mesh);\n }\n });\n applyVisibilityToScene(scene, new Set(this.oids));\n }\n\n private _notifyCollectors(): void {\n for (const collector of this.collectors) {\n collector._updateMeshes();\n }\n this._styleHelper?.onTilesLoadEnd();\n }\n\n _registerCollector(collector: MeshCollector): void {\n this.collectors.add(collector);\n }\n\n _unregisterCollector(collector: MeshCollector): void {\n const key = collector.getCacheKey();\n this.collectors.delete(collector);\n this.collectorCache.delete(key);\n this._interactionFilter.onUnregisterCollector(key);\n }\n\n /**\n * 遍历所有已加载瓦片,应用可见性过滤\n */\n private _applyVisibilityToAllTiles(): void {\n if (!this.tiles) return;\n const hiddenSet = new Set(this.oids);\n this.tiles.traverse((tile: any) => {\n const tileWithCache = tile as TileWithCache;\n if (tileWithCache.engineData?.scene) {\n applyVisibilityToScene(tileWithCache.engineData.scene, hiddenSet);\n }\n return true;\n }, null);\n }\n\n /**\n * 设置材质(DoubleSide 等基础配置)\n */\n private _setupMaterial(mesh: Mesh) {\n const material = mesh.material as Material;\n\n if (material.userData._meshHelperSetup) {\n return;\n }\n material.userData._meshHelperSetup = true;\n\n material.side = DoubleSide;\n }\n\n /**\n * Query feature information from intersection\n * Respects freeze and isolate filters\n */\n queryFeatureFromIntersection(hit: Intersection): FeatureInfo {\n const result = queryFeatureFromIntersection(hit);\n\n if (result.isValid && result.oid !== undefined) {\n if (this._interactionFilter.isOidBlocked(result.oid)) {\n return {\n isValid: false,\n error: this._interactionFilter.getFrozenOids().includes(result.oid)\n ? \"Component is frozen\"\n : \"Component is not in isolated set\",\n };\n }\n }\n\n return result;\n }\n\n // =============================================\n // Interaction Filter Methods (delegated)\n // =============================================\n\n freezeByOids(oids: number[]): void {\n this._interactionFilter.freezeByOids(oids);\n }\n\n freezeByOid(oid: number): void {\n this._interactionFilter.freezeByOid(oid);\n }\n\n unfreezeByOids(oids: number[]): void {\n this._interactionFilter.unfreezeByOids(oids);\n }\n\n unfreezeByOid(oid: number): void {\n this._interactionFilter.unfreezeByOid(oid);\n }\n\n unfreeze(): void {\n this._interactionFilter.unfreeze();\n }\n\n getFrozenOids(): number[] {\n return this._interactionFilter.getFrozenOids();\n }\n\n isolateByOids(oids: number[]): void {\n this._interactionFilter.isolateByOids(oids);\n }\n\n isolateByOid(oid: number): void {\n this._interactionFilter.isolateByOid(oid);\n }\n\n unisolateByOids(oids: number[]): void {\n this._interactionFilter.unisolateByOids(oids);\n }\n\n unisolateByOid(oid: number): void {\n this._interactionFilter.unisolateByOid(oid);\n }\n\n unisolate(): void {\n this._interactionFilter.unisolate();\n }\n\n getIsolatedOids(): number[] {\n return this._interactionFilter.getIsolatedOids();\n }\n\n /**\n * 合并 OID 列表对应的结构 bbox;若无可用 bbox 则使用 split mesh 世界包围盒并求中心。\n */\n private _getCenterFromOidList(oids: readonly number[]): Vector3 | null {\n this._syncStructureFromTileset();\n\n const union = new Box3();\n let hasStructureBox = false;\n for (const oid of oids) {\n const b = this.getBoundingBoxByOid(oid);\n if (b && !b.isEmpty()) {\n if (!hasStructureBox) {\n union.copy(b);\n hasStructureBox = true;\n } else {\n union.union(b);\n }\n }\n }\n if (hasStructureBox && !union.isEmpty()) {\n return union.getCenter(new Vector3());\n }\n\n const meshes = this._getMeshesByOidsInternal(oids);\n if (meshes.length === 0) return null;\n\n const meshBox = new Box3();\n for (const mesh of meshes) {\n mesh.updateMatrixWorld(true);\n meshBox.expandByObject(mesh);\n }\n if (meshBox.isEmpty()) return null;\n return meshBox.getCenter(new Vector3());\n }\n\n /**\n * 按 OID 集合:每个瓦片 mesh 只生成 **一个** 合并后的 split mesh(同一组 oid / condition 一条几何)\n */\n private _getMergedSplitMeshesForOidSet(oidSet: Set<number>): Mesh[] {\n if (!this.tiles || oidSet.size === 0) return [];\n\n const sortedKey = [...oidSet].sort((a, b) => a - b).join(\",\");\n const result: Mesh[] = [];\n const candidateTiles = new Set<Mesh>();\n\n for (const oid of oidSet) {\n for (const tm of getTileMeshesByOid(this.tiles, oid)) {\n candidateTiles.add(tm);\n }\n }\n\n for (const tileMesh of candidateTiles) {\n const cacheKey = `merged|${tileMesh.uuid}|${sortedKey}`;\n let cached = this.splitMeshCache.get(cacheKey);\n if (!cached) {\n const m = splitMeshByOidsMerged(tileMesh, oidSet);\n cached = m ? [m] : [];\n this.splitMeshCache.set(cacheKey, cached);\n }\n result.push(...cached);\n }\n return result;\n }\n\n /**\n * 内部方法:根据单个 oid 获取 split mesh(每瓦片合并为一条)\n */\n _getMeshesByOidInternal(oid: number): Mesh[] {\n return this._getMergedSplitMeshesForOidSet(new Set([oid]));\n }\n\n /**\n * 内部方法:根据多个 oid 获取合并 split mesh(每瓦片一条,而非每 oid 一条)\n */\n _getMeshesByOidsInternal(oids: readonly number[]): Mesh[] {\n return this._getMergedSplitMeshesForOidSet(new Set(oids));\n }\n\n /**\n * 按查询收集 mesh:可只传 oids、只传 condition(全场景 OID 上筛选)、或两者组合\n * condition 与 setStyle 的 show / conditions 中字符串表达式语义一致\n */\n _getMeshesForCollectorQueryInternal(params: {\n oids: readonly number[];\n condition?: string;\n }): Mesh[] {\n if (!this.tiles) return [];\n\n const cond = params.condition?.trim();\n let targetOids: number[];\n\n if (!cond) {\n if (params.oids.length === 0) return [];\n targetOids = [...new Set(params.oids)].sort((a, b) => a - b);\n } else {\n const candidate =\n params.oids.length === 0\n ? getAllOidsFromTiles(this.tiles)\n : [...new Set(params.oids)];\n targetOids = [];\n for (const oid of candidate) {\n const data = getPropertyDataByOid(this.tiles, oid);\n if (evaluateStyleCondition(cond, data)) {\n targetOids.push(oid);\n }\n }\n targetOids.sort((a, b) => a - b);\n }\n\n return this._getMeshesByOidsInternal(targetOids);\n }\n\n /**\n * 根据查询获取 MeshCollector(oids + 可选 condition,缓存键相同则复用实例)\n */\n getMeshCollectorByCondition(query: MeshCollectorQuery): MeshCollector {\n const oids = query.oids ?? [];\n const hasOids = normalizeMeshCollectorOids(oids).length > 0;\n const hasCond = Boolean(query.condition?.trim());\n if (!hasOids && !hasCond) {\n throw new Error(\n \"getMeshCollectorByCondition requires non-empty oids and/or a condition string\",\n );\n }\n\n const key = meshCollectorQueryCacheKey(query);\n const existing = this.collectorCache.get(key);\n if (existing) {\n return existing;\n }\n const collector = new MeshCollector(query, this);\n this.collectorCache.set(key, collector);\n\n this._interactionFilter.onCollectorMeshChange(key, collector.meshes);\n\n collector.addEventListener(\"mesh-change\", (event) => {\n this._interactionFilter.onCollectorMeshChange(key, event.meshes);\n });\n\n return collector;\n }\n\n /**\n * 根据单个 oid 获取 MeshCollector(等价于 getMeshCollectorByCondition({ oids: [oid] }))\n */\n getMeshCollectorByOid(oid: number): MeshCollector {\n return this.getMeshCollectorByCondition({ oids: [oid] });\n }\n\n /**\n * Hide the corresponding part of the original mesh according to the OID array\n */\n hidePartsByOids(oids: number[]): void {\n this.oids = oids;\n this._applyVisibilityToAllTiles();\n }\n\n /**\n * Restore the display of the corresponding mesh according to the OID array\n */\n showPartsByOids(oids: number[]): void {\n const oidSet = new Set(oids);\n this.oids = this.oids.filter((existingOid) => !oidSet.has(existingOid));\n this._applyVisibilityToAllTiles();\n }\n\n /**\n * 根据 oid 数组设置构件颜色\n * 隐藏原 mesh,将 split mesh 替换材质后加入场景(使用 tiles.group)\n * @param oids 构件 OID 数组\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setPartColorByOids(oids: number[], color: ColorInput): void {\n this._partColorHelper?.setPartColorByOids(oids, color);\n }\n\n /**\n * 恢复指定构件的颜色\n * 从场景移除 split mesh,恢复原 mesh 显示\n * @param oids 构件 OID 数组\n */\n restorePartColorByOids(oids: number[]): void {\n this._partColorHelper?.restorePartColorByOids(oids);\n }\n\n /**\n * 根据 oid 数组设置构件透明度\n * @param oids 构件 OID 数组\n * @param opacity 透明度,0-1,0 完全透明,1 完全不透明\n */\n setPartOpacityByOids(oids: number[], opacity: number): void {\n this._partColorHelper?.setPartOpacityByOids(oids, opacity);\n }\n\n /**\n * 恢复指定构件的透明度\n * @param oids 构件 OID 数组\n */\n restorePartOpacityByOids(oids: number[]): void {\n this._partColorHelper?.restorePartOpacityByOids(oids);\n }\n\n /**\n * 设置需要闪烁的构件\n * @param oids 构件 OID 数组\n */\n setBlinkPartsByOids(oids: number[]): void {\n this._partBlinkHelper?.setBlinkPartsByOids(oids);\n }\n\n /**\n * 设置闪烁颜色\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setBlinkColor(color: ColorInput): void {\n this._partBlinkHelper?.setBlinkColor(color);\n }\n\n /**\n * 设置闪烁周期时间(毫秒)\n * @param ms 一个完整闪烁周期(暗->亮->暗)的时长,默认 1000\n */\n setBlinkIntervalTime(ms: number): void {\n this._partBlinkHelper?.setBlinkIntervalTime(ms);\n }\n\n /**\n * 清除所有闪烁构件\n */\n clearAllBlinkParts(): void {\n this._partBlinkHelper?.clearAllBlinkParts();\n }\n\n /**\n * 设置需要线框显示的构件\n * @param oids 构件 OID 数组\n */\n setFramePartsByOids(oids: number[]): void {\n this._partFrameHelper?.setFramePartsByOids(oids);\n }\n\n /**\n * 清除所有线框显示构件\n */\n clearAllFrameParts(): void {\n this._partFrameHelper?.clearAllFrameParts();\n }\n\n /**\n * 设置指定构件的线框填充颜色\n * @param oids 构件 OID 数组\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setFrameFillColor(oids: number[], color: ColorInput): void {\n this._partFrameHelper?.setFrameFillColor(oids, color);\n }\n\n /**\n * 设置指定构件的线框边框颜色\n * @param oids 构件 OID 数组\n * @param color 颜色值,支持 hex 数字、颜色字符串(如 \"#ff0000\")、THREE.Color 对象\n */\n setFrameEdgeColor(oids: number[], color: ColorInput): void {\n this._partFrameHelper?.setFrameEdgeColor(oids, color);\n }\n\n /**\n * 设置构件样式(条件可见性 + 条件材质)\n * @param style 样式配置,传 null 清除样式\n */\n setStyle(style: StyleConfig | null): void {\n this._styleHelper?.setStyle(style);\n }\n\n /**\n * 当前样式配置。赋值与 `setStyle(...)` 等价,例如 `plugin.style = { show, conditions }`。\n */\n get style(): StyleConfig | null {\n return this._styleHelper?.style ?? null;\n }\n\n set style(style: StyleConfig | null) {\n this.setStyle(style);\n }\n\n /**\n * 清除构件样式\n */\n clearStyle(): void {\n this._styleHelper?.clearStyle();\n }\n\n /**\n * 高亮指定构件(语义与 setStyle 一致:show、conditions、可选 oids,另需 name 标识分组)\n * @param options 高亮配置\n */\n highlight(options: HighlightOptions): void {\n this._partHighlightHelper?.highlight(options);\n }\n\n /**\n * 取消指定名称的高亮\n * @param name 高亮组名称\n */\n cancelHighlight(name: string): void {\n this._partHighlightHelper?.cancelHighlight(name);\n }\n\n /**\n * 取消所有高亮\n */\n cancelAllHighlight(): void {\n this._partHighlightHelper?.cancelAllHighlight();\n }\n\n /**\n * Restore the original materials of the mesh\n */\n showAllParts(): void {\n this.oids = [];\n this._applyVisibilityToAllTiles();\n }\n\n /**\n * 获取当前隐藏的 OID 数量(兼容旧 API)\n */\n getFeatureIdCount(): number {\n return this.oids.length;\n }\n\n /**\n * Plugin disposal\n */\n dispose() {\n if (this.tiles) {\n this.tiles.manager.removeHandler(this._gltfRegex);\n this.tiles.removeEventListener(\"load-model\", this._onLoadModelCB);\n this.tiles.removeEventListener(\"tiles-load-end\", this._onTilesLoadEndCB);\n this.tiles.removeEventListener(\"load-root-tileset\", this._onLoadRootTilesetCB);\n }\n\n if (this._loader) {\n this._loader.removeListeners();\n }\n\n for (const collector of this.collectors) {\n collector.dispose();\n }\n this.collectors.clear();\n this.collectorCache.clear();\n\n this.splitMeshCache.clear();\n\n this._structureData = null;\n this._oidNodeMap.clear();\n this._structureEmbedResolved = false;\n\n // Clear model info data\n this._modelInfo = null;\n this._modelInfoPromise = null;\n\n this._interactionFilter.dispose();\n this._partColorHelper = null;\n this._partBlinkHelper?.dispose();\n this._partBlinkHelper = null;\n this._partFrameHelper?.dispose();\n this._partFrameHelper = null;\n this._styleHelper?.dispose();\n this._styleHelper = null;\n this._partHighlightHelper?.dispose();\n this._partHighlightHelper = null;\n\n this._loader = null;\n this.tiles = null;\n }\n}\n"],"x_google_ignoreList":[12,14,15,16],"mappings":";;;AAQA,SAAS,oBACP,MACA,YACa;CACb,MAAM,QAAQ,KAAK,UAAU;AAC7B,KAAI,CAAC,MAAO,wBAAO,IAAI,KAAK;CAE5B,MAAM,yBAAS,IAAI,KAAa;AAChC,MAAK,MAAM,OAAO,YAAY;EAC5B,MAAM,MAAM,MAAM;AAClB,MAAI,QAAQ,KAAA,EAAW,QAAO,IAAI,IAAI;;AAExC,QAAO;;;AAIT,SAAgB,sBACd,MACA,YACM;CACN,MAAM,EAAE,iBAAiB,KAAK;AAC9B,KAAI,CAAC,aAAc;CAEnB,MAAM,WAAW,KAAK;CACtB,MAAM,QAAQ,SAAS;CACvB,MAAM,gBAAgB,SAAS,aAAa,gBAAgB;AAE5D,KAAI,CAAC,SAAS,CAAC,cAAe;CAE9B,MAAM,mBAAmB,oBAAoB,MAAM,WAAW;AAC9D,KAAI,iBAAiB,SAAS,GA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