(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['deck'] = factory(); else root['deck'] = factory();})(globalThis, function () { "use strict"; var __exports__ = (() => { var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name12 in all) __defProp(target, name12, { get: all[name12], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // external-global-plugin:@deck.gl/core var require_core = __commonJS({ "external-global-plugin:@deck.gl/core"(exports, module) { module.exports = globalThis.deck; } }); // external-global-plugin:@luma.gl/core var require_core2 = __commonJS({ "external-global-plugin:@luma.gl/core"(exports, module) { module.exports = globalThis.luma; } }); // external-global-plugin:@luma.gl/engine var require_engine = __commonJS({ "external-global-plugin:@luma.gl/engine"(exports, module) { module.exports = globalThis.luma; } }); // bundle.ts var bundle_exports = {}; __export(bundle_exports, { ScenegraphLayer: () => ScenegraphLayer, SimpleMeshLayer: () => SimpleMeshLayer }); // ../core/bundle/peer-dependency.ts var peer_dependency_exports = {}; var import_core = __toESM(require_core(), 1); __reExport(peer_dependency_exports, __toESM(require_core(), 1)); if (!import_core.Layer) { throw new Error("@deck.gl/core is not found"); } // bundle.ts __reExport(bundle_exports, peer_dependency_exports); // src/simple-mesh-layer/simple-mesh-layer.ts var import_core3 = __toESM(require_core(), 1); var import_core4 = __toESM(require_core2(), 1); var import_engine = __toESM(require_engine(), 1); // src/utils/matrix.ts var import_core2 = __toESM(require_core(), 1); var RADIAN_PER_DEGREE = Math.PI / 180; var modelMatrix = new Float32Array(16); var valueArray = new Float32Array(12); function calculateTransformMatrix(targetMatrix, orientation, scale5) { const pitch = orientation[0] * RADIAN_PER_DEGREE; const yaw = orientation[1] * RADIAN_PER_DEGREE; const roll = orientation[2] * RADIAN_PER_DEGREE; const sr = Math.sin(roll); const sp = Math.sin(pitch); const sw = Math.sin(yaw); const cr = Math.cos(roll); const cp = Math.cos(pitch); const cw = Math.cos(yaw); const scx = scale5[0]; const scy = scale5[1]; const scz = scale5[2]; targetMatrix[0] = scx * cw * cp; targetMatrix[1] = scx * sw * cp; targetMatrix[2] = scx * -sp; targetMatrix[3] = scy * (-sw * cr + cw * sp * sr); targetMatrix[4] = scy * (cw * cr + sw * sp * sr); targetMatrix[5] = scy * cp * sr; targetMatrix[6] = scz * (sw * sr + cw * sp * cr); targetMatrix[7] = scz * (-cw * sr + sw * sp * cr); targetMatrix[8] = scz * cp * cr; } function getExtendedMat3FromMat4(mat4) { mat4[0] = mat4[0]; mat4[1] = mat4[1]; mat4[2] = mat4[2]; mat4[3] = mat4[4]; mat4[4] = mat4[5]; mat4[5] = mat4[6]; mat4[6] = mat4[8]; mat4[7] = mat4[9]; mat4[8] = mat4[10]; mat4[9] = mat4[12]; mat4[10] = mat4[13]; mat4[11] = mat4[14]; return mat4.subarray(0, 12); } var MATRIX_ATTRIBUTES = { size: 12, accessor: ["getOrientation", "getScale", "getTranslation", "getTransformMatrix"], shaderAttributes: { instanceModelMatrixCol0: { size: 3, elementOffset: 0 }, instanceModelMatrixCol1: { size: 3, elementOffset: 3 }, instanceModelMatrixCol2: { size: 3, elementOffset: 6 }, instanceTranslation: { size: 3, elementOffset: 9 } }, update(attribute, { startRow, endRow }) { const { data, getOrientation, getScale, getTranslation, getTransformMatrix } = this.props; const arrayMatrix = Array.isArray(getTransformMatrix); const constantMatrix = arrayMatrix && getTransformMatrix.length === 16; const constantScale = Array.isArray(getScale); const constantOrientation = Array.isArray(getOrientation); const constantTranslation = Array.isArray(getTranslation); const hasMatrix = constantMatrix || !arrayMatrix && Boolean(getTransformMatrix(data[0])); if (hasMatrix) { attribute.constant = constantMatrix; } else { attribute.constant = constantOrientation && constantScale && constantTranslation; } const instanceModelMatrixData = attribute.value; if (attribute.constant) { let matrix; if (hasMatrix) { modelMatrix.set(getTransformMatrix); matrix = getExtendedMat3FromMat4(modelMatrix); } else { matrix = valueArray; const orientation = getOrientation; const scale5 = getScale; calculateTransformMatrix(matrix, orientation, scale5); matrix.set(getTranslation, 9); } attribute.value = new Float32Array(matrix); } else { let i2 = startRow * attribute.size; const { iterable, objectInfo } = (0, import_core2.createIterable)(data, startRow, endRow); for (const object of iterable) { objectInfo.index++; let matrix; if (hasMatrix) { modelMatrix.set( constantMatrix ? getTransformMatrix : getTransformMatrix(object, objectInfo) ); matrix = getExtendedMat3FromMat4(modelMatrix); } else { matrix = valueArray; const orientation = constantOrientation ? getOrientation : getOrientation(object, objectInfo); const scale5 = constantScale ? getScale : getScale(object, objectInfo); calculateTransformMatrix(matrix, orientation, scale5); matrix.set(constantTranslation ? getTranslation : getTranslation(object, objectInfo), 9); } instanceModelMatrixData[i2++] = matrix[0]; instanceModelMatrixData[i2++] = matrix[1]; instanceModelMatrixData[i2++] = matrix[2]; instanceModelMatrixData[i2++] = matrix[3]; instanceModelMatrixData[i2++] = matrix[4]; instanceModelMatrixData[i2++] = matrix[5]; instanceModelMatrixData[i2++] = matrix[6]; instanceModelMatrixData[i2++] = matrix[7]; instanceModelMatrixData[i2++] = matrix[8]; instanceModelMatrixData[i2++] = matrix[9]; instanceModelMatrixData[i2++] = matrix[10]; instanceModelMatrixData[i2++] = matrix[11]; } } } }; function shouldComposeModelMatrix(viewport, coordinateSystem) { return coordinateSystem === import_core2.COORDINATE_SYSTEM.CARTESIAN || coordinateSystem === import_core2.COORDINATE_SYSTEM.METER_OFFSETS || coordinateSystem === import_core2.COORDINATE_SYSTEM.DEFAULT && !viewport.isGeospatial; } // src/simple-mesh-layer/simple-mesh-layer-vertex.glsl.ts var simple_mesh_layer_vertex_glsl_default = `#version 300 es #define SHADER_NAME simple-mesh-layer-vs // Scale the model uniform float sizeScale; uniform bool composeModelMatrix; // Primitive attributes in vec3 positions; in vec3 normals; in vec3 colors; in vec2 texCoords; // Instance attributes in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; in vec3 instanceTranslation; // Outputs to fragment shader out vec2 vTexCoord; out vec3 cameraPosition; out vec3 normals_commonspace; out vec4 position_commonspace; out vec4 vColor; void main(void) { geometry.worldPosition = instancePositions; geometry.uv = texCoords; geometry.pickingColor = instancePickingColors; vTexCoord = texCoords; cameraPosition = project_uCameraPosition; vColor = vec4(colors * instanceColors.rgb, instanceColors.a); mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vec3 pos = (instanceModelMatrix * positions) * sizeScale + instanceTranslation; if (composeModelMatrix) { DECKGL_FILTER_SIZE(pos, geometry); // using instancePositions as world coordinates // when using globe mode, this branch does not re-orient the model to align with the surface of the earth // call project_normal before setting position to avoid rotation normals_commonspace = project_normal(instanceModelMatrix * normals); geometry.worldPosition += pos; gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace); geometry.position = position_commonspace; } else { pos = project_size(pos); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace); geometry.position = position_commonspace; normals_commonspace = project_normal(instanceModelMatrix * normals); } geometry.normal = normals_commonspace; DECKGL_FILTER_GL_POSITION(gl_Position, geometry); DECKGL_FILTER_COLOR(vColor, geometry); } `; // src/simple-mesh-layer/simple-mesh-layer-fragment.glsl.ts var simple_mesh_layer_fragment_glsl_default = `#version 300 es #define SHADER_NAME simple-mesh-layer-fs precision highp float; uniform bool hasTexture; uniform sampler2D sampler; uniform bool flatShading; uniform float opacity; in vec2 vTexCoord; in vec3 cameraPosition; in vec3 normals_commonspace; in vec4 position_commonspace; in vec4 vColor; out vec4 fragColor; void main(void) { geometry.uv = vTexCoord; vec3 normal; if (flatShading) { normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); } else { normal = normals_commonspace; } vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor; DECKGL_FILTER_COLOR(color, geometry); vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal); fragColor = vec4(lightColor, color.a * opacity); } `; // ../../node_modules/@loaders.gl/schema/dist/lib/table/simple-table/data-type.js function getDataTypeFromTypedArray(array) { switch (array.constructor) { case Int8Array: return "int8"; case Uint8Array: case Uint8ClampedArray: return "uint8"; case Int16Array: return "int16"; case Uint16Array: return "uint16"; case Int32Array: return "int32"; case Uint32Array: return "uint32"; case Float32Array: return "float32"; case Float64Array: return "float64"; default: return "null"; } } // ../../node_modules/@loaders.gl/schema/dist/lib/mesh/mesh-utils.js function getMeshBoundingBox(attributes) { let minX = Infinity; let minY = Infinity; let minZ = Infinity; let maxX = -Infinity; let maxY = -Infinity; let maxZ = -Infinity; const positions = attributes.POSITION ? attributes.POSITION.value : []; const len2 = positions && positions.length; for (let i2 = 0; i2 < len2; i2 += 3) { const x = positions[i2]; const y = positions[i2 + 1]; const z = positions[i2 + 2]; minX = x < minX ? x : minX; minY = y < minY ? y : minY; minZ = z < minZ ? z : minZ; maxX = x > maxX ? x : maxX; maxY = y > maxY ? y : maxY; maxZ = z > maxZ ? z : maxZ; } return [ [minX, minY, minZ], [maxX, maxY, maxZ] ]; } // ../../node_modules/@loaders.gl/schema/dist/lib/mesh/deduce-mesh-schema.js function deduceMeshField(name12, attribute, optionalMetadata) { const type = getDataTypeFromTypedArray(attribute.value); const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute); return { name: name12, type: { type: "fixed-size-list", listSize: attribute.size, children: [{ name: "value", type }] }, nullable: false, metadata }; } function makeMeshAttributeMetadata(attribute) { const result = {}; if ("byteOffset" in attribute) { result.byteOffset = attribute.byteOffset.toString(10); } if ("byteStride" in attribute) { result.byteStride = attribute.byteStride.toString(10); } if ("normalized" in attribute) { result.normalized = attribute.normalized.toString(); } return result; } // src/simple-mesh-layer/simple-mesh-layer.ts function normalizeGeometryAttributes(attributes) { const positionAttribute = attributes.positions || attributes.POSITION; import_core3.log.assert(positionAttribute, 'no "postions" or "POSITION" attribute in mesh'); const vertexCount = positionAttribute.value.length / positionAttribute.size; let colorAttribute = attributes.COLOR_0 || attributes.colors; if (!colorAttribute) { colorAttribute = { size: 3, value: new Float32Array(vertexCount * 3).fill(1) }; } let normalAttribute = attributes.NORMAL || attributes.normals; if (!normalAttribute) { normalAttribute = { size: 3, value: new Float32Array(vertexCount * 3).fill(0) }; } let texCoordAttribute = attributes.TEXCOORD_0 || attributes.texCoords; if (!texCoordAttribute) { texCoordAttribute = { size: 2, value: new Float32Array(vertexCount * 2).fill(0) }; } return { positions: positionAttribute, colors: colorAttribute, normals: normalAttribute, texCoords: texCoordAttribute }; } function getGeometry(data) { if (data instanceof import_engine.Geometry) { data.attributes = normalizeGeometryAttributes(data.attributes); return data; } else if (data.attributes) { return new import_engine.Geometry({ ...data, topology: "triangle-list", attributes: normalizeGeometryAttributes(data.attributes) }); } else { return new import_engine.Geometry({ topology: "triangle-list", attributes: normalizeGeometryAttributes(data) }); } } var DEFAULT_COLOR = [0, 0, 0, 255]; var defaultProps = { mesh: { type: "object", value: null, async: true }, texture: { type: "image", value: null, async: true }, sizeScale: { type: "number", value: 1, min: 0 }, _instanced: true, wireframe: false, material: true, getPosition: { type: "accessor", value: (x) => x.position }, getColor: { type: "accessor", value: DEFAULT_COLOR }, getOrientation: { type: "accessor", value: [0, 0, 0] }, getScale: { type: "accessor", value: [1, 1, 1] }, getTranslation: { type: "accessor", value: [0, 0, 0] }, getTransformMatrix: { type: "accessor", value: [] }, textureParameters: { type: "object", ignore: true, value: null } }; var SimpleMeshLayer = class extends import_core3.Layer { getShaders() { return super.getShaders({ vs: simple_mesh_layer_vertex_glsl_default, fs: simple_mesh_layer_fragment_glsl_default, modules: [import_core3.project32, import_core3.phongLighting, import_core3.picking] }); } getBounds() { if (this.props._instanced) { return super.getBounds(); } let result = this.state.positionBounds; if (result) { return result; } const { mesh } = this.props; if (!mesh) { return null; } result = mesh.header?.boundingBox; if (!result) { const { attributes } = getGeometry(mesh); attributes.POSITION = attributes.POSITION || attributes.positions; result = getMeshBoundingBox(attributes); } this.state.positionBounds = result; return result; } initializeState() { const attributeManager = this.getAttributeManager(); attributeManager.addInstanced({ instancePositions: { transition: true, type: "float64", fp64: this.use64bitPositions(), size: 3, accessor: "getPosition" }, instanceColors: { type: "unorm8", transition: true, size: this.props.colorFormat.length, accessor: "getColor", defaultValue: [0, 0, 0, 255] }, instanceModelMatrix: MATRIX_ATTRIBUTES }); this.setState({ emptyTexture: this.context.device.createTexture({ data: new Uint8Array(4), width: 1, height: 1 }) }); } updateState(params) { super.updateState(params); const { props, oldProps, changeFlags } = params; if (props.mesh !== oldProps.mesh || changeFlags.extensionsChanged) { this.state.positionBounds = null; this.state.model?.destroy(); if (props.mesh) { this.state.model = this.getModel(props.mesh); const attributes = props.mesh.attributes || props.mesh; this.setState({ hasNormals: Boolean(attributes.NORMAL || attributes.normals) }); } this.getAttributeManager().invalidateAll(); } if (props.texture !== oldProps.texture && props.texture instanceof import_core4.Texture) { this.setTexture(props.texture); } if (this.state.model) { this.state.model.setTopology(this.props.wireframe ? "line-strip" : "triangle-list"); } } finalizeState(context) { super.finalizeState(context); this.state.emptyTexture.delete(); } draw({ uniforms }) { const { model } = this.state; if (!model) { return; } const { viewport, renderPass } = this.context; const { sizeScale, coordinateSystem, _instanced } = this.props; model.setUniforms(uniforms); model.setUniforms({ sizeScale, composeModelMatrix: !_instanced || shouldComposeModelMatrix(viewport, coordinateSystem), flatShading: !this.state.hasNormals }); model.draw(renderPass); } get isLoaded() { return Boolean(this.state?.model && super.isLoaded); } getModel(mesh) { const model = new import_engine.Model(this.context.device, { ...this.getShaders(), id: this.props.id, bufferLayout: this.getAttributeManager().getBufferLayouts(), geometry: getGeometry(mesh), isInstanced: true }); const { texture } = this.props; const { emptyTexture } = this.state; model.setBindings({ sampler: texture || emptyTexture }); model.setUniforms({ hasTexture: Boolean(texture) }); return model; } setTexture(texture) { const { emptyTexture, model } = this.state; if (model) { model.setBindings({ sampler: texture || emptyTexture }); model.setUniforms({ hasTexture: Boolean(texture) }); } } }; SimpleMeshLayer.defaultProps = defaultProps; SimpleMeshLayer.layerName = "SimpleMeshLayer"; // src/scenegraph-layer/scenegraph-layer.ts var import_core11 = __toESM(require_core(), 1); // ../../node_modules/@math.gl/core/dist/lib/common.js var RADIANS_TO_DEGREES = 1 / Math.PI * 180; var DEGREES_TO_RADIANS = 1 / 180 * Math.PI; var DEFAULT_CONFIG = { EPSILON: 1e-12, debug: false, precision: 4, printTypes: false, printDegrees: false, printRowMajor: true, _cartographicRadians: false }; globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } }; var config = globalThis.mathgl.config; function formatValue(value, { precision = config.precision } = {}) { value = round(value); return `${parseFloat(value.toPrecision(precision))}`; } function isArray(value) { return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView); } function equals(a2, b, epsilon) { const oldEpsilon = config.EPSILON; if (epsilon) { config.EPSILON = epsilon; } try { if (a2 === b) { return true; } if (isArray(a2) && isArray(b)) { if (a2.length !== b.length) { return false; } for (let i2 = 0; i2 < a2.length; ++i2) { if (!equals(a2[i2], b[i2])) { return false; } } return true; } if (a2 && a2.equals) { return a2.equals(b); } if (b && b.equals) { return b.equals(a2); } if (typeof a2 === "number" && typeof b === "number") { return Math.abs(a2 - b) <= config.EPSILON * Math.max(1, Math.abs(a2), Math.abs(b)); } return false; } finally { config.EPSILON = oldEpsilon; } } function round(value) { return Math.round(value / config.EPSILON) * config.EPSILON; } // ../../node_modules/@math.gl/core/dist/classes/base/math-array.js var MathArray = class extends Array { clone() { return new this.constructor().copy(this); } fromArray(array, offset = 0) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] = array[i2 + offset]; } return this.check(); } toArray(targetArray = [], offset = 0) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { targetArray[offset + i2] = this[i2]; } return targetArray; } toObject(targetObject) { return targetObject; } from(arrayOrObject) { return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject); } to(arrayOrObject) { if (arrayOrObject === this) { return this; } return isArray(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject); } toTarget(target) { return target ? this.to(target) : this; } toFloat32Array() { return new Float32Array(this); } toString() { return this.formatString(config); } formatString(opts) { let string = ""; for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { string += (i2 > 0 ? ", " : "") + formatValue(this[i2], opts); } return `${opts.printTypes ? this.constructor.name : ""}[${string}]`; } equals(array) { if (!array || this.length !== array.length) { return false; } for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { if (!equals(this[i2], array[i2])) { return false; } } return true; } exactEquals(array) { if (!array || this.length !== array.length) { return false; } for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { if (this[i2] !== array[i2]) { return false; } } return true; } negate() { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] = -this[i2]; } return this.check(); } lerp(a2, b, t2) { if (t2 === void 0) { return this.lerp(this, a2, b); } for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { const ai = a2[i2]; const endValue = typeof b === "number" ? b : b[i2]; this[i2] = ai + t2 * (endValue - ai); } return this.check(); } min(vector) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] = Math.min(vector[i2], this[i2]); } return this.check(); } max(vector) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] = Math.max(vector[i2], this[i2]); } return this.check(); } clamp(minVector, maxVector) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] = Math.min(Math.max(this[i2], minVector[i2]), maxVector[i2]); } return this.check(); } add(...vectors) { for (const vector of vectors) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] += vector[i2]; } } return this.check(); } subtract(...vectors) { for (const vector of vectors) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] -= vector[i2]; } } return this.check(); } scale(scale5) { if (typeof scale5 === "number") { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] *= scale5; } } else { for (let i2 = 0; i2 < this.ELEMENTS && i2 < scale5.length; ++i2) { this[i2] *= scale5[i2]; } } return this.check(); } multiplyByScalar(scalar) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] *= scalar; } return this.check(); } check() { if (config.debug && !this.validate()) { throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`); } return this; } validate() { let valid = this.length === this.ELEMENTS; for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { valid = valid && Number.isFinite(this[i2]); } return valid; } sub(a2) { return this.subtract(a2); } setScalar(a2) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] = a2; } return this.check(); } addScalar(a2) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] += a2; } return this.check(); } subScalar(a2) { return this.addScalar(-a2); } multiplyScalar(scalar) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] *= scalar; } return this.check(); } divideScalar(a2) { return this.multiplyByScalar(1 / a2); } clampScalar(min, max) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] = Math.min(Math.max(this[i2], min), max); } return this.check(); } get elements() { return this; } }; // ../../node_modules/@math.gl/core/dist/lib/validators.js function validateVector(v, length4) { if (v.length !== length4) { return false; } for (let i2 = 0; i2 < v.length; ++i2) { if (!Number.isFinite(v[i2])) { return false; } } return true; } function checkNumber(value) { if (!Number.isFinite(value)) { throw new Error(`Invalid number ${JSON.stringify(value)}`); } return value; } function checkVector(v, length4, callerName = "") { if (config.debug && !validateVector(v, length4)) { throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`); } return v; } // ../../node_modules/@math.gl/core/dist/lib/assert.js function assert(condition, message) { if (!condition) { throw new Error(`math.gl assertion ${message}`); } } // ../../node_modules/@math.gl/core/dist/classes/base/vector.js var Vector = class extends MathArray { get x() { return this[0]; } set x(value) { this[0] = checkNumber(value); } get y() { return this[1]; } set y(value) { this[1] = checkNumber(value); } len() { return Math.sqrt(this.lengthSquared()); } magnitude() { return this.len(); } lengthSquared() { let length4 = 0; for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { length4 += this[i2] * this[i2]; } return length4; } magnitudeSquared() { return this.lengthSquared(); } distance(mathArray) { return Math.sqrt(this.distanceSquared(mathArray)); } distanceSquared(mathArray) { let length4 = 0; for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { const dist = this[i2] - mathArray[i2]; length4 += dist * dist; } return checkNumber(length4); } dot(mathArray) { let product = 0; for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { product += this[i2] * mathArray[i2]; } return checkNumber(product); } normalize() { const length4 = this.magnitude(); if (length4 !== 0) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] /= length4; } } return this.check(); } multiply(...vectors) { for (const vector of vectors) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] *= vector[i2]; } } return this.check(); } divide(...vectors) { for (const vector of vectors) { for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { this[i2] /= vector[i2]; } } return this.check(); } lengthSq() { return this.lengthSquared(); } distanceTo(vector) { return this.distance(vector); } distanceToSquared(vector) { return this.distanceSquared(vector); } getComponent(i2) { assert(i2 >= 0 && i2 < this.ELEMENTS, "index is out of range"); return checkNumber(this[i2]); } setComponent(i2, value) { assert(i2 >= 0 && i2 < this.ELEMENTS, "index is out of range"); this[i2] = value; return this.check(); } addVectors(a2, b) { return this.copy(a2).add(b); } subVectors(a2, b) { return this.copy(a2).subtract(b); } multiplyVectors(a2, b) { return this.copy(a2).multiply(b); } addScaledVector(a2, b) { return this.add(new this.constructor(a2).multiplyScalar(b)); } }; // ../../node_modules/@math.gl/core/dist/gl-matrix/common.js var EPSILON = 1e-6; var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array; var degree = Math.PI / 180; // ../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js function create() { const out = new ARRAY_TYPE(2); if (ARRAY_TYPE != Float32Array) { out[0] = 0; out[1] = 0; } return out; } function transformMat3(out, a2, m) { const x = a2[0]; const y = a2[1]; out[0] = m[0] * x + m[3] * y + m[6]; out[1] = m[1] * x + m[4] * y + m[7]; return out; } function transformMat4(out, a2, m) { const x = a2[0]; const y = a2[1]; out[0] = m[0] * x + m[4] * y + m[12]; out[1] = m[1] * x + m[5] * y + m[13]; return out; } var forEach = function() { const vec = create(); return function(a2, stride, offset, count, fn, arg) { let i2; let l2; if (!stride) { stride = 2; } if (!offset) { offset = 0; } if (count) { l2 = Math.min(count * stride + offset, a2.length); } else { l2 = a2.length; } for (i2 = offset; i2 < l2; i2 += stride) { vec[0] = a2[i2]; vec[1] = a2[i2 + 1]; fn(vec, vec, arg); a2[i2] = vec[0]; a2[i2 + 1] = vec[1]; } return a2; }; }(); // ../../node_modules/@math.gl/core/dist/lib/gl-matrix-extras.js function vec2_transformMat4AsVector(out, a2, m) { const x = a2[0]; const y = a2[1]; const w = m[3] * x + m[7] * y || 1; out[0] = (m[0] * x + m[4] * y) / w; out[1] = (m[1] * x + m[5] * y) / w; return out; } function vec3_transformMat4AsVector(out, a2, m) { const x = a2[0]; const y = a2[1]; const z = a2[2]; const w = m[3] * x + m[7] * y + m[11] * z || 1; out[0] = (m[0] * x + m[4] * y + m[8] * z) / w; out[1] = (m[1] * x + m[5] * y + m[9] * z) / w; out[2] = (m[2] * x + m[6] * y + m[10] * z) / w; return out; } function vec3_transformMat2(out, a2, m) { const x = a2[0]; const y = a2[1]; out[0] = m[0] * x + m[2] * y; out[1] = m[1] * x + m[3] * y; out[2] = a2[2]; return out; } function vec4_transformMat2(out, a2, m) { const x = a2[0]; const y = a2[1]; out[0] = m[0] * x + m[2] * y; out[1] = m[1] * x + m[3] * y; out[2] = a2[2]; out[3] = a2[3]; return out; } function vec4_transformMat3(out, a2, m) { const x = a2[0]; const y = a2[1]; const z = a2[2]; out[0] = m[0] * x + m[3] * y + m[6] * z; out[1] = m[1] * x + m[4] * y + m[7] * z; out[2] = m[2] * x + m[5] * y + m[8] * z; out[3] = a2[3]; return out; } // ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js function create2() { const out = new ARRAY_TYPE(3); if (ARRAY_TYPE != Float32Array) { out[0] = 0; out[1] = 0; out[2] = 0; } return out; } function length(a2) { const x = a2[0]; const y = a2[1]; const z = a2[2]; return Math.sqrt(x * x + y * y + z * z); } function fromValues(x, y, z) { const out = new ARRAY_TYPE(3); out[0] = x; out[1] = y; out[2] = z; return out; } function normalize(out, a2) { const x = a2[0]; const y = a2[1]; const z = a2[2]; let len2 = x * x + y * y + z * z; if (len2 > 0) { len2 = 1 / Math.sqrt(len2); } out[0] = a2[0] * len2; out[1] = a2[1] * len2; out[2] = a2[2] * len2; return out; } function dot(a2, b) { return a2[0] * b[0] + a2[1] * b[1] + a2[2] * b[2]; } function cross(out, a2, b) { const ax = a2[0]; const ay = a2[1]; const az = a2[2]; const bx = b[0]; const by = b[1]; const bz = b[2]; out[0] = ay * bz - az * by; out[1] = az * bx - ax * bz; out[2] = ax * by - ay * bx; return out; } function transformMat42(out, a2, m) { const x = a2[0]; const y = a2[1]; const z = a2[2]; let w = m[3] * x + m[7] * y + m[11] * z + m[15]; w = w || 1; out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w; out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w; out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w; return out; } function transformMat32(out, a2, m) { const x = a2[0]; const y = a2[1]; const z = a2[2]; out[0] = x * m[0] + y * m[3] + z * m[6]; out[1] = x * m[1] + y * m[4] + z * m[7]; out[2] = x * m[2] + y * m[5] + z * m[8]; return out; } function transformQuat(out, a2, q) { const qx = q[0]; const qy = q[1]; const qz = q[2]; const qw = q[3]; const x = a2[0]; const y = a2[1]; const z = a2[2]; let uvx = qy * z - qz * y; let uvy = qz * x - qx * z; let uvz = qx * y - qy * x; let uuvx = qy * uvz - qz * uvy; let uuvy = qz * uvx - qx * uvz; let uuvz = qx * uvy - qy * uvx; const w2 = qw * 2; uvx *= w2; uvy *= w2; uvz *= w2; uuvx *= 2; uuvy *= 2; uuvz *= 2; out[0] = x + uvx + uuvx; out[1] = y + uvy + uuvy; out[2] = z + uvz + uuvz; return out; } function rotateX(out, a2, b, rad) { const p2 = []; const r2 = []; p2[0] = a2[0] - b[0]; p2[1] = a2[1] - b[1]; p2[2] = a2[2] - b[2]; r2[0] = p2[0]; r2[1] = p2[1] * Math.cos(rad) - p2[2] * Math.sin(rad); r2[2] = p2[1] * Math.sin(rad) + p2[2] * Math.cos(rad); out[0] = r2[0] + b[0]; out[1] = r2[1] + b[1]; out[2] = r2[2] + b[2]; return out; } function rotateY(out, a2, b, rad) { const p2 = []; const r2 = []; p2[0] = a2[0] - b[0]; p2[1] = a2[1] - b[1]; p2[2] = a2[2] - b[2]; r2[0] = p2[2] * Math.sin(rad) + p2[0] * Math.cos(rad); r2[1] = p2[1]; r2[2] = p2[2] * Math.cos(rad) - p2[0] * Math.sin(rad); out[0] = r2[0] + b[0]; out[1] = r2[1] + b[1]; out[2] = r2[2] + b[2]; return out; } function rotateZ(out, a2, b, rad) { const p2 = []; const r2 = []; p2[0] = a2[0] - b[0]; p2[1] = a2[1] - b[1]; p2[2] = a2[2] - b[2]; r2[0] = p2[0] * Math.cos(rad) - p2[1] * Math.sin(rad); r2[1] = p2[0] * Math.sin(rad) + p2[1] * Math.cos(rad); r2[2] = p2[2]; out[0] = r2[0] + b[0]; out[1] = r2[1] + b[1]; out[2] = r2[2] + b[2]; return out; } function angle(a2, b) { const ax = a2[0]; const ay = a2[1]; const az = a2[2]; const bx = b[0]; const by = b[1]; const bz = b[2]; const mag = Math.sqrt((ax * ax + ay * ay + az * az) * (bx * bx + by * by + bz * bz)); const cosine = mag && dot(a2, b) / mag; return Math.acos(Math.min(Math.max(cosine, -1), 1)); } var len = length; var forEach2 = function() { const vec = create2(); return function(a2, stride, offset, count, fn, arg) { let i2; let l2; if (!stride) { stride = 3; } if (!offset) { offset = 0; } if (count) { l2 = Math.min(count * stride + offset, a2.length); } else { l2 = a2.length; } for (i2 = offset; i2 < l2; i2 += stride) { vec[0] = a2[i2]; vec[1] = a2[i2 + 1]; vec[2] = a2[i2 + 2]; fn(vec, vec, arg); a2[i2] = vec[0]; a2[i2 + 1] = vec[1]; a2[i2 + 2] = vec[2]; } return a2; }; }(); // ../../node_modules/@math.gl/core/dist/classes/vector3.js var ORIGIN = [0, 0, 0]; var ZERO; var Vector3 = class extends Vector { static get ZERO() { if (!ZERO) { ZERO = new Vector3(0, 0, 0); Object.freeze(ZERO); } return ZERO; } constructor(x = 0, y = 0, z = 0) { super(-0, -0, -0); if (arguments.length === 1 && isArray(x)) { this.copy(x); } else { if (config.debug) { checkNumber(x); checkNumber(y); checkNumber(z); } this[0] = x; this[1] = y; this[2] = z; } } set(x, y, z) { this[0] = x; this[1] = y; this[2] = z; return this.check(); } copy(array) { this[0] = array[0]; this[1] = array[1]; this[2] = array[2]; return this.check(); } fromObject(object) { if (config.debug) { checkNumber(object.x); checkNumber(object.y); checkNumber(object.z); } this[0] = object.x; this[1] = object.y; this[2] = object.z; return this.check(); } toObject(object) { object.x = this[0]; object.y = this[1]; object.z = this[2]; return object; } get ELEMENTS() { return 3; } get z() { return this[2]; } set z(value) { this[2] = checkNumber(value); } angle(vector) { return angle(this, vector); } cross(vector) { cross(this, this, vector); return this.check(); } rotateX({ radians, origin = ORIGIN }) { rotateX(this, this, origin, radians); return this.check(); } rotateY({ radians, origin = ORIGIN }) { rotateY(this, this, origin, radians); return this.check(); } rotateZ({ radians, origin = ORIGIN }) { rotateZ(this, this, origin, radians); return this.check(); } transform(matrix4) { return this.transformAsPoint(matrix4); } transformAsPoint(matrix4) { transformMat42(this, this, matrix4); return this.check(); } transformAsVector(matrix4) { vec3_transformMat4AsVector(this, this, matrix4); return this.check(); } transformByMatrix3(matrix3) { transformMat32(this, this, matrix3); return this.check(); } transformByMatrix2(matrix2) { vec3_transformMat2(this, this, matrix2); return this.check(); } transformByQuaternion(quaternion2) { transformQuat(this, this, quaternion2); return this.check(); } }; // ../../node_modules/@math.gl/core/dist/classes/vector4.js var ZERO2; var Vector4 = class extends Vector { static get ZERO() { if (!ZERO2) { ZERO2 = new Vector4(0, 0, 0, 0); Object.freeze(ZERO2); } return ZERO2; } constructor(x = 0, y = 0, z = 0, w = 0) { super(-0, -0, -0, -0); if (isArray(x) && arguments.length === 1) { this.copy(x); } else { if (config.debug) { checkNumber(x); checkNumber(y); checkNumber(z); checkNumber(w); } this[0] = x; this[1] = y; this[2] = z; this[3] = w; } } set(x, y, z, w) { this[0] = x; this[1] = y; this[2] = z; this[3] = w; return this.check(); } copy(array) { this[0] = array[0]; this[1] = array[1]; this[2] = array[2]; this[3] = array[3]; return this.check(); } fromObject(object) { if (config.debug) { checkNumber(object.x); checkNumber(object.y); checkNumber(object.z); checkNumber(object.w); } this[0] = object.x; this[1] = object.y; this[2] = object.z; this[3] = object.w; return this; } toObject(object) { object.x = this[0]; object.y = this[1]; object.z = this[2]; object.w = this[3]; return object; } get ELEMENTS() { return 4; } get z() { return this[2]; } set z(value) { this[2] = checkNumber(value); } get w() { return this[3]; } set w(value) { this[3] = checkNumber(value); } transform(matrix4) { transformMat42(this, this, matrix4); return this.check(); } transformByMatrix3(matrix3) { vec4_transformMat3(this, this, matrix3); return this.check(); } transformByMatrix2(matrix2) { vec4_transformMat2(this, this, matrix2); return this.check(); } transformByQuaternion(quaternion2) { transformQuat(this, this, quaternion2); return this.check(); } applyMatrix4(m) { m.transform(this, this); return this; } }; // ../../node_modules/@math.gl/core/dist/classes/base/matrix.js var Matrix = class extends MathArray { toString() { let string = "["; if (config.printRowMajor) { string += "row-major:"; for (let row = 0; row < this.RANK; ++row) { for (let col = 0; col < this.RANK; ++col) { string += ` ${this[col * this.RANK + row]}`; } } } else { string += "column-major:"; for (let i2 = 0; i2 < this.ELEMENTS; ++i2) { string += ` ${this[i2]}`; } } string += "]"; return string; } getElementIndex(row, col) { return col * this.RANK + row; } getElement(row, col) { return this[col * this.RANK + row]; } setElement(row, col, value) { this[col * this.RANK + row] = checkNumber(value); return this; } getColumn(columnIndex, result = new Array(this.RANK).fill(-0)) { const firstIndex = columnIndex * this.RANK; for (let i2 = 0; i2 < this.RANK; ++i2) { result[i2] = this[firstIndex + i2]; } return result; } setColumn(columnIndex, columnVector) { const firstIndex = columnIndex * this.RANK; for (let i2 = 0; i2 < this.RANK; ++i2) { this[firstIndex + i2] = columnVector[i2]; } return this; } }; // ../../node_modules/@math.gl/core/dist/gl-matrix/mat3.js function create3() { const out = new ARRAY_TYPE(9); if (ARRAY_TYPE != Float32Array) { out[1] = 0; out[2] = 0; out[3] = 0; out[5] = 0; out[6] = 0; out[7] = 0; } out[0] = 1; out[4] = 1; out[8] = 1; return out; } function transpose(out, a2) { if (out === a2) { const a01 = a2[1]; const a02 = a2[2]; const a12 = a2[5]; out[1] = a2[3]; out[2] = a2[6]; out[3] = a01; out[5] = a2[7]; out[6] = a02; out[7] = a12; } else { out[0] = a2[0]; out[1] = a2[3]; out[2] = a2[6]; out[3] = a2[1]; out[4] = a2[4]; out[5] = a2[7]; out[6] = a2[2]; out[7] = a2[5]; out[8] = a2[8]; } return out; } function invert(out, a2) { const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a10 = a2[3]; const a11 = a2[4]; const a12 = a2[5]; const a20 = a2[6]; const a21 = a2[7]; const a22 = a2[8]; const b01 = a22 * a11 - a12 * a21; const b11 = -a22 * a10 + a12 * a20; const b21 = a21 * a10 - a11 * a20; let det = a00 * b01 + a01 * b11 + a02 * b21; if (!det) { return null; } det = 1 / det; out[0] = b01 * det; out[1] = (-a22 * a01 + a02 * a21) * det; out[2] = (a12 * a01 - a02 * a11) * det; out[3] = b11 * det; out[4] = (a22 * a00 - a02 * a20) * det; out[5] = (-a12 * a00 + a02 * a10) * det; out[6] = b21 * det; out[7] = (-a21 * a00 + a01 * a20) * det; out[8] = (a11 * a00 - a01 * a10) * det; return out; } function determinant(a2) { const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a10 = a2[3]; const a11 = a2[4]; const a12 = a2[5]; const a20 = a2[6]; const a21 = a2[7]; const a22 = a2[8]; return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20); } function multiply(out, a2, b) { const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a10 = a2[3]; const a11 = a2[4]; const a12 = a2[5]; const a20 = a2[6]; const a21 = a2[7]; const a22 = a2[8]; const b00 = b[0]; const b01 = b[1]; const b02 = b[2]; const b10 = b[3]; const b11 = b[4]; const b12 = b[5]; const b20 = b[6]; const b21 = b[7]; const b22 = b[8]; out[0] = b00 * a00 + b01 * a10 + b02 * a20; out[1] = b00 * a01 + b01 * a11 + b02 * a21; out[2] = b00 * a02 + b01 * a12 + b02 * a22; out[3] = b10 * a00 + b11 * a10 + b12 * a20; out[4] = b10 * a01 + b11 * a11 + b12 * a21; out[5] = b10 * a02 + b11 * a12 + b12 * a22; out[6] = b20 * a00 + b21 * a10 + b22 * a20; out[7] = b20 * a01 + b21 * a11 + b22 * a21; out[8] = b20 * a02 + b21 * a12 + b22 * a22; return out; } function translate(out, a2, v) { const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a10 = a2[3]; const a11 = a2[4]; const a12 = a2[5]; const a20 = a2[6]; const a21 = a2[7]; const a22 = a2[8]; const x = v[0]; const y = v[1]; out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a10; out[4] = a11; out[5] = a12; out[6] = x * a00 + y * a10 + a20; out[7] = x * a01 + y * a11 + a21; out[8] = x * a02 + y * a12 + a22; return out; } function rotate(out, a2, rad) { const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a10 = a2[3]; const a11 = a2[4]; const a12 = a2[5]; const a20 = a2[6]; const a21 = a2[7]; const a22 = a2[8]; const s2 = Math.sin(rad); const c = Math.cos(rad); out[0] = c * a00 + s2 * a10; out[1] = c * a01 + s2 * a11; out[2] = c * a02 + s2 * a12; out[3] = c * a10 - s2 * a00; out[4] = c * a11 - s2 * a01; out[5] = c * a12 - s2 * a02; out[6] = a20; out[7] = a21; out[8] = a22; return out; } function scale(out, a2, v) { const x = v[0]; const y = v[1]; out[0] = x * a2[0]; out[1] = x * a2[1]; out[2] = x * a2[2]; out[3] = y * a2[3]; out[4] = y * a2[4]; out[5] = y * a2[5]; out[6] = a2[6]; out[7] = a2[7]; out[8] = a2[8]; return out; } function fromQuat(out, q) { const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3]; const x2 = x + x; const y2 = y + y; const z2 = z + z; const xx = x * x2; const yx = y * x2; const yy = y * y2; const zx = z * x2; const zy = z * y2; const zz = z * z2; const wx = w * x2; const wy = w * y2; const wz = w * z2; out[0] = 1 - yy - zz; out[3] = yx - wz; out[6] = zx + wy; out[1] = yx + wz; out[4] = 1 - xx - zz; out[7] = zy - wx; out[2] = zx - wy; out[5] = zy + wx; out[8] = 1 - xx - yy; return out; } // ../../node_modules/@math.gl/core/dist/classes/matrix3.js var INDICES; (function(INDICES3) { INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0"; INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1"; INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2"; INDICES3[INDICES3["COL1ROW0"] = 3] = "COL1ROW0"; INDICES3[INDICES3["COL1ROW1"] = 4] = "COL1ROW1"; INDICES3[INDICES3["COL1ROW2"] = 5] = "COL1ROW2"; INDICES3[INDICES3["COL2ROW0"] = 6] = "COL2ROW0"; INDICES3[INDICES3["COL2ROW1"] = 7] = "COL2ROW1"; INDICES3[INDICES3["COL2ROW2"] = 8] = "COL2ROW2"; })(INDICES || (INDICES = {})); var IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 1, 0, 0, 0, 1]); var Matrix3 = class extends Matrix { static get IDENTITY() { return getIdentityMatrix(); } static get ZERO() { return getZeroMatrix(); } get ELEMENTS() { return 9; } get RANK() { return 3; } get INDICES() { return INDICES; } constructor(array, ...args) { super(-0, -0, -0, -0, -0, -0, -0, -0, -0); if (arguments.length === 1 && Array.isArray(array)) { this.copy(array); } else if (args.length > 0) { this.copy([array, ...args]); } else { this.identity(); } } copy(array) { this[0] = array[0]; this[1] = array[1]; this[2] = array[2]; this[3] = array[3]; this[4] = array[4]; this[5] = array[5]; this[6] = array[6]; this[7] = array[7]; this[8] = array[8]; return this.check(); } identity() { return this.copy(IDENTITY_MATRIX); } fromObject(object) { return this.check(); } fromQuaternion(q) { fromQuat(this, q); return this.check(); } set(m00, m10, m20, m01, m11, m21, m02, m12, m22) { this[0] = m00; this[1] = m10; this[2] = m20; this[3] = m01; this[4] = m11; this[5] = m21; this[6] = m02; this[7] = m12; this[8] = m22; return this.check(); } setRowMajor(m00, m01, m02, m10, m11, m12, m20, m21, m22) { this[0] = m00; this[1] = m10; this[2] = m20; this[3] = m01; this[4] = m11; this[5] = m21; this[6] = m02; this[7] = m12; this[8] = m22; return this.check(); } determinant() { return determinant(this); } transpose() { transpose(this, this); return this.check(); } invert() { invert(this, this); return this.check(); } multiplyLeft(a2) { multiply(this, a2, this); return this.check(); } multiplyRight(a2) { multiply(this, this, a2); return this.check(); } rotate(radians) { rotate(this, this, radians); return this.check(); } scale(factor) { if (Array.isArray(factor)) { scale(this, this, factor); } else { scale(this, this, [factor, factor]); } return this.check(); } translate(vec) { translate(this, this, vec); return this.check(); } transform(vector, result) { let out; switch (vector.length) { case 2: out = transformMat3(result || [-0, -0], vector, this); break; case 3: out = transformMat32(result || [-0, -0, -0], vector, this); break; case 4: out = vec4_transformMat3(result || [-0, -0, -0, -0], vector, this); break; default: throw new Error("Illegal vector"); } checkVector(out, vector.length); return out; } transformVector(vector, result) { return this.transform(vector, result); } transformVector2(vector, result) { return this.transform(vector, result); } transformVector3(vector, result) { return this.transform(vector, result); } }; var ZERO_MATRIX3; var IDENTITY_MATRIX3 = null; function getZeroMatrix() { if (!ZERO_MATRIX3) { ZERO_MATRIX3 = new Matrix3([0, 0, 0, 0, 0, 0, 0, 0, 0]); Object.freeze(ZERO_MATRIX3); } return ZERO_MATRIX3; } function getIdentityMatrix() { if (!IDENTITY_MATRIX3) { IDENTITY_MATRIX3 = new Matrix3(); Object.freeze(IDENTITY_MATRIX3); } return IDENTITY_MATRIX3; } // ../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js function identity(out) { out[0] = 1; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 0; out[5] = 1; out[6] = 0; out[7] = 0; out[8] = 0; out[9] = 0; out[10] = 1; out[11] = 0; out[12] = 0; out[13] = 0; out[14] = 0; out[15] = 1; return out; } function transpose2(out, a2) { if (out === a2) { const a01 = a2[1]; const a02 = a2[2]; const a03 = a2[3]; const a12 = a2[6]; const a13 = a2[7]; const a23 = a2[11]; out[1] = a2[4]; out[2] = a2[8]; out[3] = a2[12]; out[4] = a01; out[6] = a2[9]; out[7] = a2[13]; out[8] = a02; out[9] = a12; out[11] = a2[14]; out[12] = a03; out[13] = a13; out[14] = a23; } else { out[0] = a2[0]; out[1] = a2[4]; out[2] = a2[8]; out[3] = a2[12]; out[4] = a2[1]; out[5] = a2[5]; out[6] = a2[9]; out[7] = a2[13]; out[8] = a2[2]; out[9] = a2[6]; out[10] = a2[10]; out[11] = a2[14]; out[12] = a2[3]; out[13] = a2[7]; out[14] = a2[11]; out[15] = a2[15]; } return out; } function invert2(out, a2) { const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a03 = a2[3]; const a10 = a2[4]; const a11 = a2[5]; const a12 = a2[6]; const a13 = a2[7]; const a20 = a2[8]; const a21 = a2[9]; const a22 = a2[10]; const a23 = a2[11]; const a30 = a2[12]; const a31 = a2[13]; const a32 = a2[14]; const a33 = a2[15]; const b00 = a00 * a11 - a01 * a10; const b01 = a00 * a12 - a02 * a10; const b02 = a00 * a13 - a03 * a10; const b03 = a01 * a12 - a02 * a11; const b04 = a01 * a13 - a03 * a11; const b05 = a02 * a13 - a03 * a12; const b06 = a20 * a31 - a21 * a30; const b07 = a20 * a32 - a22 * a30; const b08 = a20 * a33 - a23 * a30; const b09 = a21 * a32 - a22 * a31; const b10 = a21 * a33 - a23 * a31; const b11 = a22 * a33 - a23 * a32; let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06; if (!det) { return null; } det = 1 / det; out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det; out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det; out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det; out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det; out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det; out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det; out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det; out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det; out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det; out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det; out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det; out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det; out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det; out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det; out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det; out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det; return out; } function determinant2(a2) { const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a03 = a2[3]; const a10 = a2[4]; const a11 = a2[5]; const a12 = a2[6]; const a13 = a2[7]; const a20 = a2[8]; const a21 = a2[9]; const a22 = a2[10]; const a23 = a2[11]; const a30 = a2[12]; const a31 = a2[13]; const a32 = a2[14]; const a33 = a2[15]; const b0 = a00 * a11 - a01 * a10; const b1 = a00 * a12 - a02 * a10; const b2 = a01 * a12 - a02 * a11; const b3 = a20 * a31 - a21 * a30; const b4 = a20 * a32 - a22 * a30; const b5 = a21 * a32 - a22 * a31; const b6 = a00 * b5 - a01 * b4 + a02 * b3; const b7 = a10 * b5 - a11 * b4 + a12 * b3; const b8 = a20 * b2 - a21 * b1 + a22 * b0; const b9 = a30 * b2 - a31 * b1 + a32 * b0; return a13 * b6 - a03 * b7 + a33 * b8 - a23 * b9; } function multiply2(out, a2, b) { const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a03 = a2[3]; const a10 = a2[4]; const a11 = a2[5]; const a12 = a2[6]; const a13 = a2[7]; const a20 = a2[8]; const a21 = a2[9]; const a22 = a2[10]; const a23 = a2[11]; const a30 = a2[12]; const a31 = a2[13]; const a32 = a2[14]; const a33 = a2[15]; let b0 = b[0]; let b1 = b[1]; let b2 = b[2]; let b3 = b[3]; out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30; out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31; out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32; out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33; return out; } function translate2(out, a2, v) { const x = v[0]; const y = v[1]; const z = v[2]; let a00; let a01; let a02; let a03; let a10; let a11; let a12; let a13; let a20; let a21; let a22; let a23; if (a2 === out) { out[12] = a2[0] * x + a2[4] * y + a2[8] * z + a2[12]; out[13] = a2[1] * x + a2[5] * y + a2[9] * z + a2[13]; out[14] = a2[2] * x + a2[6] * y + a2[10] * z + a2[14]; out[15] = a2[3] * x + a2[7] * y + a2[11] * z + a2[15]; } else { a00 = a2[0]; a01 = a2[1]; a02 = a2[2]; a03 = a2[3]; a10 = a2[4]; a11 = a2[5]; a12 = a2[6]; a13 = a2[7]; a20 = a2[8]; a21 = a2[9]; a22 = a2[10]; a23 = a2[11]; out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03; out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13; out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23; out[12] = a00 * x + a10 * y + a20 * z + a2[12]; out[13] = a01 * x + a11 * y + a21 * z + a2[13]; out[14] = a02 * x + a12 * y + a22 * z + a2[14]; out[15] = a03 * x + a13 * y + a23 * z + a2[15]; } return out; } function scale2(out, a2, v) { const x = v[0]; const y = v[1]; const z = v[2]; out[0] = a2[0] * x; out[1] = a2[1] * x; out[2] = a2[2] * x; out[3] = a2[3] * x; out[4] = a2[4] * y; out[5] = a2[5] * y; out[6] = a2[6] * y; out[7] = a2[7] * y; out[8] = a2[8] * z; out[9] = a2[9] * z; out[10] = a2[10] * z; out[11] = a2[11] * z; out[12] = a2[12]; out[13] = a2[13]; out[14] = a2[14]; out[15] = a2[15]; return out; } function rotate2(out, a2, rad, axis) { let x = axis[0]; let y = axis[1]; let z = axis[2]; let len2 = Math.sqrt(x * x + y * y + z * z); let c; let s2; let t2; let a00; let a01; let a02; let a03; let a10; let a11; let a12; let a13; let a20; let a21; let a22; let a23; let b00; let b01; let b02; let b10; let b11; let b12; let b20; let b21; let b22; if (len2 < EPSILON) { return null; } len2 = 1 / len2; x *= len2; y *= len2; z *= len2; s2 = Math.sin(rad); c = Math.cos(rad); t2 = 1 - c; a00 = a2[0]; a01 = a2[1]; a02 = a2[2]; a03 = a2[3]; a10 = a2[4]; a11 = a2[5]; a12 = a2[6]; a13 = a2[7]; a20 = a2[8]; a21 = a2[9]; a22 = a2[10]; a23 = a2[11]; b00 = x * x * t2 + c; b01 = y * x * t2 + z * s2; b02 = z * x * t2 - y * s2; b10 = x * y * t2 - z * s2; b11 = y * y * t2 + c; b12 = z * y * t2 + x * s2; b20 = x * z * t2 + y * s2; b21 = y * z * t2 - x * s2; b22 = z * z * t2 + c; out[0] = a00 * b00 + a10 * b01 + a20 * b02; out[1] = a01 * b00 + a11 * b01 + a21 * b02; out[2] = a02 * b00 + a12 * b01 + a22 * b02; out[3] = a03 * b00 + a13 * b01 + a23 * b02; out[4] = a00 * b10 + a10 * b11 + a20 * b12; out[5] = a01 * b10 + a11 * b11 + a21 * b12; out[6] = a02 * b10 + a12 * b11 + a22 * b12; out[7] = a03 * b10 + a13 * b11 + a23 * b12; out[8] = a00 * b20 + a10 * b21 + a20 * b22; out[9] = a01 * b20 + a11 * b21 + a21 * b22; out[10] = a02 * b20 + a12 * b21 + a22 * b22; out[11] = a03 * b20 + a13 * b21 + a23 * b22; if (a2 !== out) { out[12] = a2[12]; out[13] = a2[13]; out[14] = a2[14]; out[15] = a2[15]; } return out; } function rotateX2(out, a2, rad) { const s2 = Math.sin(rad); const c = Math.cos(rad); const a10 = a2[4]; const a11 = a2[5]; const a12 = a2[6]; const a13 = a2[7]; const a20 = a2[8]; const a21 = a2[9]; const a22 = a2[10]; const a23 = a2[11]; if (a2 !== out) { out[0] = a2[0]; out[1] = a2[1]; out[2] = a2[2]; out[3] = a2[3]; out[12] = a2[12]; out[13] = a2[13]; out[14] = a2[14]; out[15] = a2[15]; } out[4] = a10 * c + a20 * s2; out[5] = a11 * c + a21 * s2; out[6] = a12 * c + a22 * s2; out[7] = a13 * c + a23 * s2; out[8] = a20 * c - a10 * s2; out[9] = a21 * c - a11 * s2; out[10] = a22 * c - a12 * s2; out[11] = a23 * c - a13 * s2; return out; } function rotateY2(out, a2, rad) { const s2 = Math.sin(rad); const c = Math.cos(rad); const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a03 = a2[3]; const a20 = a2[8]; const a21 = a2[9]; const a22 = a2[10]; const a23 = a2[11]; if (a2 !== out) { out[4] = a2[4]; out[5] = a2[5]; out[6] = a2[6]; out[7] = a2[7]; out[12] = a2[12]; out[13] = a2[13]; out[14] = a2[14]; out[15] = a2[15]; } out[0] = a00 * c - a20 * s2; out[1] = a01 * c - a21 * s2; out[2] = a02 * c - a22 * s2; out[3] = a03 * c - a23 * s2; out[8] = a00 * s2 + a20 * c; out[9] = a01 * s2 + a21 * c; out[10] = a02 * s2 + a22 * c; out[11] = a03 * s2 + a23 * c; return out; } function rotateZ2(out, a2, rad) { const s2 = Math.sin(rad); const c = Math.cos(rad); const a00 = a2[0]; const a01 = a2[1]; const a02 = a2[2]; const a03 = a2[3]; const a10 = a2[4]; const a11 = a2[5]; const a12 = a2[6]; const a13 = a2[7]; if (a2 !== out) { out[8] = a2[8]; out[9] = a2[9]; out[10] = a2[10]; out[11] = a2[11]; out[12] = a2[12]; out[13] = a2[13]; out[14] = a2[14]; out[15] = a2[15]; } out[0] = a00 * c + a10 * s2; out[1] = a01 * c + a11 * s2; out[2] = a02 * c + a12 * s2; out[3] = a03 * c + a13 * s2; out[4] = a10 * c - a00 * s2; out[5] = a11 * c - a01 * s2; out[6] = a12 * c - a02 * s2; out[7] = a13 * c - a03 * s2; return out; } function fromQuat2(out, q) { const x = q[0]; const y = q[1]; const z = q[2]; const w = q[3]; const x2 = x + x; const y2 = y + y; const z2 = z + z; const xx = x * x2; const yx = y * x2; const yy = y * y2; const zx = z * x2; const zy = z * y2; const zz = z * z2; const wx = w * x2; const wy = w * y2; const wz = w * z2; out[0] = 1 - yy - zz; out[1] = yx + wz; out[2] = zx - wy; out[3] = 0; out[4] = yx - wz; out[5] = 1 - xx - zz; out[6] = zy + wx; out[7] = 0; out[8] = zx + wy; out[9] = zy - wx; out[10] = 1 - xx - yy; out[11] = 0; out[12] = 0; out[13] = 0; out[14] = 0; out[15] = 1; return out; } function frustum(out, left, right, bottom, top, near, far) { const rl = 1 / (right - left); const tb = 1 / (top - bottom); const nf = 1 / (near - far); out[0] = near * 2 * rl; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 0; out[5] = near * 2 * tb; out[6] = 0; out[7] = 0; out[8] = (right + left) * rl; out[9] = (top + bottom) * tb; out[10] = (far + near) * nf; out[11] = -1; out[12] = 0; out[13] = 0; out[14] = far * near * 2 * nf; out[15] = 0; return out; } function perspectiveNO(out, fovy, aspect, near, far) { const f2 = 1 / Math.tan(fovy / 2); out[0] = f2 / aspect; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 0; out[5] = f2; out[6] = 0; out[7] = 0; out[8] = 0; out[9] = 0; out[11] = -1; out[12] = 0; out[13] = 0; out[15] = 0; if (far != null && far !== Infinity) { const nf = 1 / (near - far); out[10] = (far + near) * nf; out[14] = 2 * far * near * nf; } else { out[10] = -1; out[14] = -2 * near; } return out; } var perspective = perspectiveNO; function orthoNO(out, left, right, bottom, top, near, far) { const lr = 1 / (left - right); const bt = 1 / (bottom - top); const nf = 1 / (near - far); out[0] = -2 * lr; out[1] = 0; out[2] = 0; out[3] = 0; out[4] = 0; out[5] = -2 * bt; out[6] = 0; out[7] = 0; out[8] = 0; out[9] = 0; out[10] = 2 * nf; out[11] = 0; out[12] = (left + right) * lr; out[13] = (top + bottom) * bt; out[14] = (far + near) * nf; out[15] = 1; return out; } var ortho = orthoNO; function lookAt(out, eye, center, up) { let len2; let x0; let x1; let x2; let y0; let y1; let y2; let z0; let z1; let z2; const eyex = eye[0]; const eyey = eye[1]; const eyez = eye[2]; const upx = up[0]; const upy = up[1]; const upz = up[2]; const centerx = center[0]; const centery = center[1]; const centerz = center[2]; if (Math.abs(eyex - centerx) < EPSILON && Math.abs(eyey - centery) < EPSILON && Math.abs(eyez - centerz) < EPSILON) { return identity(out); } z0 = eyex - centerx; z1 = eyey - centery; z2 = eyez - centerz; len2 = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2); z0 *= len2; z1 *= len2; z2 *= len2; x0 = upy * z2 - upz * z1; x1 = upz * z0 - upx * z2; x2 = upx * z1 - upy * z0; len2 = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2); if (!len2) { x0 = 0; x1 = 0; x2 = 0; } else { len2 = 1 / len2; x0 *= len2; x1 *= len2; x2 *= len2; } y0 = z1 * x2 - z2 * x1; y1 = z2 * x0 - z0 * x2; y2 = z0 * x1 - z1 * x0; len2 = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2); if (!len2) { y0 = 0; y1 = 0; y2 = 0; } else { len2 = 1 / len2; y0 *= len2; y1 *= len2; y2 *= len2; } out[0] = x0; out[1] = y0; out[2] = z0; out[3] = 0; out[4] = x1; out[5] = y1; out[6] = z1; out[7] = 0; out[8] = x2; out[9] = y2; out[10] = z2; out[11] = 0; out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez); out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez); out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez); out[15] = 1; return out; } // ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js function create4() { const out = new ARRAY_TYPE(4); if (ARRAY_TYPE != Float32Array) { out[0] = 0; out[1] = 0; out[2] = 0; out[3] = 0; } return out; } function add(out, a2, b) { out[0] = a2[0] + b[0]; out[1] = a2[1] + b[1]; out[2] = a2[2] + b[2]; out[3] = a2[3] + b[3]; return out; } function scale3(out, a2, b) { out[0] = a2[0] * b; out[1] = a2[1] * b; out[2] = a2[2] * b; out[3] = a2[3] * b; return out; } function length2(a2) { const x = a2[0]; const y = a2[1]; const z = a2[2]; const w = a2[3]; return Math.sqrt(x * x + y * y + z * z + w * w); } function squaredLength(a2) { const x = a2[0]; const y = a2[1]; const z = a2[2]; const w = a2[3]; return x * x + y * y + z * z + w * w; } function normalize2(out, a2) { const x = a2[0]; const y = a2[1]; const z = a2[2]; const w = a2[3]; let len2 = x * x + y * y + z * z + w * w; if (len2 > 0) { len2 = 1 / Math.sqrt(len2); } out[0] = x * len2; out[1] = y * len2; out[2] = z * len2; out[3] = w * len2; return out; } function dot2(a2, b) { return a2[0] * b[0] + a2[1] * b[1] + a2[2] * b[2] + a2[3] * b[3]; } function lerp(out, a2, b, t2) { const ax = a2[0]; const ay = a2[1]; const az = a2[2]; const aw = a2[3]; out[0] = ax + t2 * (b[0] - ax); out[1] = ay + t2 * (b[1] - ay); out[2] = az + t2 * (b[2] - az); out[3] = aw + t2 * (b[3] - aw); return out; } function transformMat43(out, a2, m) { const x = a2[0]; const y = a2[1]; const z = a2[2]; const w = a2[3]; out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w; out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w; out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w; out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w; return out; } function transformQuat2(out, a2, q) { const x = a2[0]; const y = a2[1]; const z = a2[2]; const qx = q[0]; const qy = q[1]; const qz = q[2]; const qw = q[3]; const ix = qw * x + qy * z - qz * y; const iy = qw * y + qz * x - qx * z; const iz = qw * z + qx * y - qy * x; const iw = -qx * x - qy * y - qz * z; out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy; out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz; out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx; out[3] = a2[3]; return out; } var forEach3 = function() { const vec = create4(); return function(a2, stride, offset, count, fn, arg) { let i2; let l2; if (!stride) { stride = 4; } if (!offset) { offset = 0; } if (count) { l2 = Math.min(count * stride + offset, a2.length); } else { l2 = a2.length; } for (i2 = offset; i2 < l2; i2 += stride) { vec[0] = a2[i2]; vec[1] = a2[i2 + 1]; vec[2] = a2[i2 + 2]; vec[3] = a2[i2 + 3]; fn(vec, vec, arg); a2[i2] = vec[0]; a2[i2 + 1] = vec[1]; a2[i2 + 2] = vec[2]; a2[i2 + 3] = vec[3]; } return a2; }; }(); // ../../node_modules/@math.gl/core/dist/classes/matrix4.js var INDICES2; (function(INDICES3) { INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0"; INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1"; INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2"; INDICES3[INDICES3["COL0ROW3"] = 3] = "COL0ROW3"; INDICES3[INDICES3["COL1ROW0"] = 4] = "COL1ROW0"; INDICES3[INDICES3["COL1ROW1"] = 5] = "COL1ROW1"; INDICES3[INDICES3["COL1ROW2"] = 6] = "COL1ROW2"; INDICES3[INDICES3["COL1ROW3"] = 7] = "COL1ROW3"; INDICES3[INDICES3["COL2ROW0"] = 8] = "COL2ROW0"; INDICES3[INDICES3["COL2ROW1"] = 9] = "COL2ROW1"; INDICES3[INDICES3["COL2ROW2"] = 10] = "COL2ROW2"; INDICES3[INDICES3["COL2ROW3"] = 11] = "COL2ROW3"; INDICES3[INDICES3["COL3ROW0"] = 12] = "COL3ROW0"; INDICES3[INDICES3["COL3ROW1"] = 13] = "COL3ROW1"; INDICES3[INDICES3["COL3ROW2"] = 14] = "COL3ROW2"; INDICES3[INDICES3["COL3ROW3"] = 15] = "COL3ROW3"; })(INDICES2 || (INDICES2 = {})); var DEFAULT_FOVY = 45 * Math.PI / 180; var DEFAULT_ASPECT = 1; var DEFAULT_NEAR = 0.1; var DEFAULT_FAR = 500; var IDENTITY_MATRIX2 = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); var Matrix4 = class extends Matrix { static get IDENTITY() { return getIdentityMatrix2(); } static get ZERO() { return getZeroMatrix2(); } get ELEMENTS() { return 16; } get RANK() { return 4; } get INDICES() { return INDICES2; } constructor(array) { super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0); if (arguments.length === 1 && Array.isArray(array)) { this.copy(array); } else { this.identity(); } } copy(array) { this[0] = array[0]; this[1] = array[1]; this[2] = array[2]; this[3] = array[3]; this[4] = array[4]; this[5] = array[5]; this[6] = array[6]; this[7] = array[7]; this[8] = array[8]; this[9] = array[9]; this[10] = array[10]; this[11] = array[11]; this[12] = array[12]; this[13] = array[13]; this[14] = array[14]; this[15] = array[15]; return this.check(); } set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) { this[0] = m00; this[1] = m10; this[2] = m20; this[3] = m30; this[4] = m01; this[5] = m11; this[6] = m21; this[7] = m31; this[8] = m02; this[9] = m12; this[10] = m22; this[11] = m32; this[12] = m03; this[13] = m13; this[14] = m23; this[15] = m33; return this.check(); } setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) { this[0] = m00; this[1] = m10; this[2] = m20; this[3] = m30; this[4] = m01; this[5] = m11; this[6] = m21; this[7] = m31; this[8] = m02; this[9] = m12; this[10] = m22; this[11] = m32; this[12] = m03; this[13] = m13; this[14] = m23; this[15] = m33; return this.check(); } toRowMajor(result) { result[0] = this[0]; result[1] = this[4]; result[2] = this[8]; result[3] = this[12]; result[4] = this[1]; result[5] = this[5]; result[6] = this[9]; result[7] = this[13]; result[8] = this[2]; result[9] = this[6]; result[10] = this[10]; result[11] = this[14]; result[12] = this[3]; result[13] = this[7]; result[14] = this[11]; result[15] = this[15]; return result; } identity() { return this.copy(IDENTITY_MATRIX2); } fromObject(object) { return this.check(); } fromQuaternion(quaternion2) { fromQuat2(this, quaternion2); return this.check(); } frustum(view) { const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view; if (far === Infinity) { computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near); } else { frustum(this, left, right, bottom, top, near, far); } return this.check(); } lookAt(view) { const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view; lookAt(this, eye, center, up); return this.check(); } ortho(view) { const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view; ortho(this, left, right, bottom, top, near, far); return this.check(); } orthographic(view) { const { fovy = DEFAULT_FOVY, aspect = DEFAULT_ASPECT, focalDistance = 1, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view; checkRadians(fovy); const halfY = fovy / 2; const top = focalDistance * Math.tan(halfY); const right = top * aspect; return this.ortho({ left: -right, right, bottom: -top, top, near, far }); } perspective(view) { const { fovy = 45 * Math.PI / 180, aspect = 1, near = 0.1, far = 500 } = view; checkRadians(fovy); perspective(this, fovy, aspect, near, far); return this.check(); } determinant() { return determinant2(this); } getScale(result = [-0, -0, -0]) { result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]); result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]); result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]); return result; } getTranslation(result = [-0, -0, -0]) { result[0] = this[12]; result[1] = this[13]; result[2] = this[14]; return result; } getRotation(result, scaleResult) { result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0]; scaleResult = scaleResult || [-0, -0, -0]; const scale5 = this.getScale(scaleResult); const inverseScale0 = 1 / scale5[0]; const inverseScale1 = 1 / scale5[1]; const inverseScale2 = 1 / scale5[2]; result[0] = this[0] * inverseScale0; result[1] = this[1] * inverseScale1; result[2] = this[2] * inverseScale2; result[3] = 0; result[4] = this[4] * inverseScale0; result[5] = this[5] * inverseScale1; result[6] = this[6] * inverseScale2; result[7] = 0; result[8] = this[8] * inverseScale0; result[9] = this[9] * inverseScale1; result[10] = this[10] * inverseScale2; result[11] = 0; result[12] = 0; result[13] = 0; result[14] = 0; result[15] = 1; return result; } getRotationMatrix3(result, scaleResult) { result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0]; scaleResult = scaleResult || [-0, -0, -0]; const scale5 = this.getScale(scaleResult); const inverseScale0 = 1 / scale5[0]; const inverseScale1 = 1 / scale5[1]; const inverseScale2 = 1 / scale5[2]; result[0] = this[0] * inverseScale0; result[1] = this[1] * inverseScale1; result[2] = this[2] * inverseScale2; result[3] = this[4] * inverseScale0; result[4] = this[5] * inverseScale1; result[5] = this[6] * inverseScale2; result[6] = this[8] * inverseScale0; result[7] = this[9] * inverseScale1; result[8] = this[10] * inverseScale2; return result; } transpose() { transpose2(this, this); return this.check(); } invert() { invert2(this, this); return this.check(); } multiplyLeft(a2) { multiply2(this, a2, this); return this.check(); } multiplyRight(a2) { multiply2(this, this, a2); return this.check(); } rotateX(radians) { rotateX2(this, this, radians); return this.check(); } rotateY(radians) { rotateY2(this, this, radians); return this.check(); } rotateZ(radians) { rotateZ2(this, this, radians); return this.check(); } rotateXYZ(angleXYZ) { return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]); } rotateAxis(radians, axis) { rotate2(this, this, radians, axis); return this.check(); } scale(factor) { scale2(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]); return this.check(); } translate(vector) { translate2(this, this, vector); return this.check(); } transform(vector, result) { if (vector.length === 4) { result = transformMat43(result || [-0, -0, -0, -0], vector, this); checkVector(result, 4); return result; } return this.transformAsPoint(vector, result); } transformAsPoint(vector, result) { const { length: length4 } = vector; let out; switch (length4) { case 2: out = transformMat4(result || [-0, -0], vector, this); break; case 3: out = transformMat42(result || [-0, -0, -0], vector, this); break; default: throw new Error("Illegal vector"); } checkVector(out, vector.length); return out; } transformAsVector(vector, result) { let out; switch (vector.length) { case 2: out = vec2_transformMat4AsVector(result || [-0, -0], vector, this); break; case 3: out = vec3_transformMat4AsVector(result || [-0, -0, -0], vector, this); break; default: throw new Error("Illegal vector"); } checkVector(out, vector.length); return out; } transformPoint(vector, result) { return this.transformAsPoint(vector, result); } transformVector(vector, result) { return this.transformAsPoint(vector, result); } transformDirection(vector, result) { return this.transformAsVector(vector, result); } makeRotationX(radians) { return this.identity().rotateX(radians); } makeTranslation(x, y, z) { return this.identity().translate([x, y, z]); } }; var ZERO3; var IDENTITY; function getZeroMatrix2() { if (!ZERO3) { ZERO3 = new Matrix4([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); Object.freeze(ZERO3); } return ZERO3; } function getIdentityMatrix2() { if (!IDENTITY) { IDENTITY = new Matrix4(); Object.freeze(IDENTITY); } return IDENTITY; } function checkRadians(possiblyDegrees) { if (possiblyDegrees > Math.PI * 2) { throw Error("expected radians"); } } function computeInfinitePerspectiveOffCenter(result, left, right, bottom, top, near) { const column0Row0 = 2 * near / (right - left); const column1Row1 = 2 * near / (top - bottom); const column2Row0 = (right + left) / (right - left); const column2Row1 = (top + bottom) / (top - bottom); const column2Row2 = -1; const column2Row3 = -1; const column3Row2 = -2 * near; result[0] = column0Row0; result[1] = 0; result[2] = 0; result[3] = 0; result[4] = 0; result[5] = column1Row1; result[6] = 0; result[7] = 0; result[8] = column2Row0; result[9] = column2Row1; result[10] = column2Row2; result[11] = column2Row3; result[12] = 0; result[13] = 0; result[14] = column3Row2; result[15] = 0; return result; } // ../../node_modules/@math.gl/core/dist/gl-matrix/quat.js function create5() { const out = new ARRAY_TYPE(4); if (ARRAY_TYPE != Float32Array) { out[0] = 0; out[1] = 0; out[2] = 0; } out[3] = 1; return out; } function identity2(out) { out[0] = 0; out[1] = 0; out[2] = 0; out[3] = 1; return out; } function setAxisAngle(out, axis, rad) { rad = rad * 0.5; const s2 = Math.sin(rad); out[0] = s2 * axis[0]; out[1] = s2 * axis[1]; out[2] = s2 * axis[2]; out[3] = Math.cos(rad); return out; } function multiply3(out, a2, b) { const ax = a2[0]; const ay = a2[1]; const az = a2[2]; const aw = a2[3]; const bx = b[0]; const by = b[1]; const bz = b[2]; const bw = b[3]; out[0] = ax * bw + aw * bx + ay * bz - az * by; out[1] = ay * bw + aw * by + az * bx - ax * bz; out[2] = az * bw + aw * bz + ax * by - ay * bx; out[3] = aw * bw - ax * bx - ay * by - az * bz; return out; } function rotateX3(out, a2, rad) { rad *= 0.5; const ax = a2[0]; const ay = a2[1]; const az = a2[2]; const aw = a2[3]; const bx = Math.sin(rad); const bw = Math.cos(rad); out[0] = ax * bw + aw * bx; out[1] = ay * bw + az * bx; out[2] = az * bw - ay * bx; out[3] = aw * bw - ax * bx; return out; } function rotateY3(out, a2, rad) { rad *= 0.5; const ax = a2[0]; const ay = a2[1]; const az = a2[2]; const aw = a2[3]; const by = Math.sin(rad); const bw = Math.cos(rad); out[0] = ax * bw - az * by; out[1] = ay * bw + aw * by; out[2] = az * bw + ax * by; out[3] = aw * bw - ay * by; return out; } function rotateZ3(out, a2, rad) { rad *= 0.5; const ax = a2[0]; const ay = a2[1]; const az = a2[2]; const aw = a2[3]; const bz = Math.sin(rad); const bw = Math.cos(rad); out[0] = ax * bw + ay * bz; out[1] = ay * bw - ax * bz; out[2] = az * bw + aw * bz; out[3] = aw * bw - az * bz; return out; } function calculateW(out, a2) { const x = a2[0]; const y = a2[1]; const z = a2[2]; out[0] = x; out[1] = y; out[2] = z; out[3] = Math.sqrt(Math.abs(1 - x * x - y * y - z * z)); return out; } function slerp(out, a2, b, t2) { const ax = a2[0]; const ay = a2[1]; const az = a2[2]; const aw = a2[3]; let bx = b[0]; let by = b[1]; let bz = b[2]; let bw = b[3]; let cosom; let omega; let scale0; let scale1; let sinom; cosom = ax * bx + ay * by + az * bz + aw * bw; if (cosom < 0) { cosom = -cosom; bx = -bx; by = -by; bz = -bz; bw = -bw; } if (1 - cosom > EPSILON) { omega = Math.acos(cosom); sinom = Math.sin(omega); scale0 = Math.sin((1 - t2) * omega) / sinom; scale1 = Math.sin(t2 * omega) / sinom; } else { scale0 = 1 - t2; scale1 = t2; } out[0] = scale0 * ax + scale1 * bx; out[1] = scale0 * ay + scale1 * by; out[2] = scale0 * az + scale1 * bz; out[3] = scale0 * aw + scale1 * bw; return out; } function invert3(out, a2) { const a0 = a2[0]; const a1 = a2[1]; const a22 = a2[2]; const a3 = a2[3]; const dot4 = a0 * a0 + a1 * a1 + a22 * a22 + a3 * a3; const invDot = dot4 ? 1 / dot4 : 0; out[0] = -a0 * invDot; out[1] = -a1 * invDot; out[2] = -a22 * invDot; out[3] = a3 * invDot; return out; } function conjugate(out, a2) { out[0] = -a2[0]; out[1] = -a2[1]; out[2] = -a2[2]; out[3] = a2[3]; return out; } function fromMat3(out, m) { const fTrace = m[0] + m[4] + m[8]; let fRoot; if (fTrace > 0) { fRoot = Math.sqrt(fTrace + 1); out[3] = 0.5 * fRoot; fRoot = 0.5 / fRoot; out[0] = (m[5] - m[7]) * fRoot; out[1] = (m[6] - m[2]) * fRoot; out[2] = (m[1] - m[3]) * fRoot; } else { let i2 = 0; if (m[4] > m[0]) i2 = 1; if (m[8] > m[i2 * 3 + i2]) i2 = 2; const j = (i2 + 1) % 3; const k = (i2 + 2) % 3; fRoot = Math.sqrt(m[i2 * 3 + i2] - m[j * 3 + j] - m[k * 3 + k] + 1); out[i2] = 0.5 * fRoot; fRoot = 0.5 / fRoot; out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot; out[j] = (m[j * 3 + i2] + m[i2 * 3 + j]) * fRoot; out[k] = (m[k * 3 + i2] + m[i2 * 3 + k]) * fRoot; } return out; } var add2 = add; var scale4 = scale3; var dot3 = dot2; var lerp2 = lerp; var length3 = length2; var squaredLength2 = squaredLength; var normalize3 = normalize2; var rotationTo = function() { const tmpvec3 = create2(); const xUnitVec3 = fromValues(1, 0, 0); const yUnitVec3 = fromValues(0, 1, 0); return function(out, a2, b) { const dot4 = dot(a2, b); if (dot4 < -0.999999) { cross(tmpvec3, xUnitVec3, a2); if (len(tmpvec3) < 1e-6) cross(tmpvec3, yUnitVec3, a2); normalize(tmpvec3, tmpvec3); setAxisAngle(out, tmpvec3, Math.PI); return out; } else if (dot4 > 0.999999) { out[0] = 0; out[1] = 0; out[2] = 0; out[3] = 1; return out; } cross(tmpvec3, a2, b); out[0] = tmpvec3[0]; out[1] = tmpvec3[1]; out[2] = tmpvec3[2]; out[3] = 1 + dot4; return normalize3(out, out); }; }(); var sqlerp = function() { const temp1 = create5(); const temp2 = create5(); return function(out, a2, b, c, d, t2) { slerp(temp1, a2, d, t2); slerp(temp2, b, c, t2); slerp(out, temp1, temp2, 2 * t2 * (1 - t2)); return out; }; }(); var setAxes = function() { const matr = create3(); return function(out, view, right, up) { matr[0] = right[0]; matr[3] = right[1]; matr[6] = right[2]; matr[1] = up[0]; matr[4] = up[1]; matr[7] = up[2]; matr[2] = -view[0]; matr[5] = -view[1]; matr[8] = -view[2]; return normalize3(out, fromMat3(out, matr)); }; }(); // ../../node_modules/@math.gl/core/dist/classes/quaternion.js var IDENTITY_QUATERNION = [0, 0, 0, 1]; var Quaternion = class extends MathArray { constructor(x = 0, y = 0, z = 0, w = 1) { super(-0, -0, -0, -0); if (Array.isArray(x) && arguments.length === 1) { this.copy(x); } else { this.set(x, y, z, w); } } copy(array) { this[0] = array[0]; this[1] = array[1]; this[2] = array[2]; this[3] = array[3]; return this.check(); } set(x, y, z, w) { this[0] = x; this[1] = y; this[2] = z; this[3] = w; return this.check(); } fromObject(object) { this[0] = object.x; this[1] = object.y; this[2] = object.z; this[3] = object.w; return this.check(); } fromMatrix3(m) { fromMat3(this, m); return this.check(); } fromAxisRotation(axis, rad) { setAxisAngle(this, axis, rad); return this.check(); } identity() { identity2(this); return this.check(); } setAxisAngle(axis, rad) { return this.fromAxisRotation(axis, rad); } get ELEMENTS() { return 4; } get x() { return this[0]; } set x(value) { this[0] = checkNumber(value); } get y() { return this[1]; } set y(value) { this[1] = checkNumber(value); } get z() { return this[2]; } set z(value) { this[2] = checkNumber(value); } get w() { return this[3]; } set w(value) { this[3] = checkNumber(value); } len() { return length3(this); } lengthSquared() { return squaredLength2(this); } dot(a2) { return dot3(this, a2); } rotationTo(vectorA, vectorB) { rotationTo(this, vectorA, vectorB); return this.check(); } add(a2) { add2(this, this, a2); return this.check(); } calculateW() { calculateW(this, this); return this.check(); } conjugate() { conjugate(this, this); return this.check(); } invert() { invert3(this, this); return this.check(); } lerp(a2, b, t2) { if (t2 === void 0) { return this.lerp(this, a2, b); } lerp2(this, a2, b, t2); return this.check(); } multiplyRight(a2) { multiply3(this, this, a2); return this.check(); } multiplyLeft(a2) { multiply3(this, a2, this); return this.check(); } normalize() { const length4 = this.len(); const l2 = length4 > 0 ? 1 / length4 : 0; this[0] = this[0] * l2; this[1] = this[1] * l2; this[2] = this[2] * l2; this[3] = this[3] * l2; if (length4 === 0) { this[3] = 1; } return this.check(); } rotateX(rad) { rotateX3(this, this, rad); return this.check(); } rotateY(rad) { rotateY3(this, this, rad); return this.check(); } rotateZ(rad) { rotateZ3(this, this, rad); return this.check(); } scale(b) { scale4(this, this, b); return this.check(); } slerp(arg0, arg1, arg2) { let start; let target; let ratio; switch (arguments.length) { case 1: ({ start = IDENTITY_QUATERNION, target, ratio } = arg0); break; case 2: start = this; target = arg0; ratio = arg1; break; default: start = arg0; target = arg1; ratio = arg2; } slerp(this, start, target, ratio); return this.check(); } transformVector4(vector, result = new Vector4()) { transformQuat2(result, vector, this); return checkVector(result, 4); } lengthSq() { return this.lengthSquared(); } setFromAxisAngle(axis, rad) { return this.setAxisAngle(axis, rad); } premultiply(a2) { return this.multiplyLeft(a2); } multiply(a2) { return this.multiplyRight(a2); } }; // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/lights/lights-glsl.js var lightingShader = `#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) struct AmbientLight { vec3 color; }; struct PointLight { vec3 color; vec3 position; vec3 attenuation; }; struct DirectionalLight { vec3 color; vec3 direction; }; uniform AmbientLight lighting_uAmbientLight; uniform PointLight lighting_uPointLight[MAX_LIGHTS]; uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS]; uniform int lighting_uPointLightCount; uniform int lighting_uDirectionalLightCount; uniform bool lighting_uEnabled; float getPointLightAttenuation(PointLight pointLight, float distance) { return pointLight.attenuation.x + pointLight.attenuation.y * distance + pointLight.attenuation.z * distance * distance; } #endif `; // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/lights/lights.js var INITIAL_MODULE_OPTIONS = { lightSources: {} }; function convertColor(colorDef = {}) { const { color = [0, 0, 0], intensity = 1 } = colorDef; return color.map((component) => component * intensity / 255); } function getLightSourceUniforms({ ambientLight, pointLights = [], directionalLights = [] }) { const lightSourceUniforms = {}; if (ambientLight) { lightSourceUniforms["lighting_uAmbientLight.color"] = convertColor(ambientLight); } else { lightSourceUniforms["lighting_uAmbientLight.color"] = [0, 0, 0]; } pointLights.forEach((pointLight, index) => { lightSourceUniforms[`lighting_uPointLight[${index}].color`] = convertColor(pointLight); lightSourceUniforms[`lighting_uPointLight[${index}].position`] = pointLight.position; lightSourceUniforms[`lighting_uPointLight[${index}].attenuation`] = pointLight.attenuation || [ 1, 0, 0 ]; }); lightSourceUniforms.lighting_uPointLightCount = pointLights.length; directionalLights.forEach((directionalLight, index) => { lightSourceUniforms[`lighting_uDirectionalLight[${index}].color`] = convertColor(directionalLight); lightSourceUniforms[`lighting_uDirectionalLight[${index}].direction`] = directionalLight.direction; }); lightSourceUniforms.lighting_uDirectionalLightCount = directionalLights.length; return lightSourceUniforms; } function getUniforms(opts = INITIAL_MODULE_OPTIONS) { if ("lightSources" in opts) { const { ambientLight, pointLights, directionalLights } = opts.lightSources || {}; const hasLights = ambientLight || pointLights && pointLights.length > 0 || directionalLights && directionalLights.length > 0; if (!hasLights) { return { lighting_uEnabled: false }; } return Object.assign({}, getLightSourceUniforms({ ambientLight, pointLights, directionalLights }), { lighting_uEnabled: true }); } if ("lights" in opts) { const lightSources = { pointLights: [], directionalLights: [] }; for (const light of opts.lights || []) { switch (light.type) { case "ambient": lightSources.ambientLight = light; break; case "directional": lightSources.directionalLights?.push(light); break; case "point": lightSources.pointLights?.push(light); break; default: } } return getUniforms({ lightSources }); } return {}; } var lights = { name: "lights", vs: lightingShader, fs: lightingShader, getUniforms, defines: { MAX_LIGHTS: 3 } }; // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js var vs = `uniform mat4 u_MVPMatrix; uniform mat4 u_ModelMatrix; uniform mat4 u_NormalMatrix; out vec3 pbr_vPosition; out vec2 pbr_vUV; #ifdef HAS_NORMALS # ifdef HAS_TANGENTS out mat3 pbr_vTBN; # else out vec3 pbr_vNormal; # endif #endif void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv) { vec4 pos = u_ModelMatrix * position; pbr_vPosition = vec3(pos.xyz) / pos.w; #ifdef HAS_NORMALS #ifdef HAS_TANGENTS vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0))); vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0))); vec3 bitangentW = cross(normalW, tangentW) * tangent.w; pbr_vTBN = mat3(tangentW, bitangentW, normalW); #else pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0))); #endif #endif #ifdef HAS_UV pbr_vUV = uv; #else pbr_vUV = vec2(0.,0.); #endif } `; // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js var fs = `precision highp float; uniform bool pbr_uUnlit; #ifdef USE_IBL uniform samplerCube u_DiffuseEnvSampler; uniform samplerCube u_SpecularEnvSampler; uniform sampler2D u_brdfLUT; uniform vec2 u_ScaleIBLAmbient; #endif #ifdef HAS_BASECOLORMAP uniform sampler2D u_BaseColorSampler; #endif #ifdef HAS_NORMALMAP uniform sampler2D u_NormalSampler; uniform float u_NormalScale; #endif #ifdef HAS_EMISSIVEMAP uniform sampler2D u_EmissiveSampler; uniform vec3 u_EmissiveFactor; #endif #ifdef HAS_METALROUGHNESSMAP uniform sampler2D u_MetallicRoughnessSampler; #endif #ifdef HAS_OCCLUSIONMAP uniform sampler2D u_OcclusionSampler; uniform float u_OcclusionStrength; #endif #ifdef ALPHA_CUTOFF uniform float u_AlphaCutoff; #endif uniform vec2 u_MetallicRoughnessValues; uniform vec4 u_BaseColorFactor; uniform vec3 u_Camera; #ifdef PBR_DEBUG uniform vec4 u_ScaleDiffBaseMR; uniform vec4 u_ScaleFGDSpec; #endif in vec3 pbr_vPosition; in vec2 pbr_vUV; #ifdef HAS_NORMALS #ifdef HAS_TANGENTS in mat3 pbr_vTBN; #else in vec3 pbr_vNormal; #endif #endif struct PBRInfo { float NdotL; float NdotV; float NdotH; float LdotH; float VdotH; float perceptualRoughness; float metalness; vec3 reflectance0; vec3 reflectance90; float alphaRoughness; vec3 diffuseColor; vec3 specularColor; vec3 n; vec3 v; }; const float M_PI = 3.141592653589793; const float c_MinRoughness = 0.04; vec4 SRGBtoLINEAR(vec4 srgbIn) { #ifdef MANUAL_SRGB #ifdef SRGB_FAST_APPROXIMATION vec3 linOut = pow(srgbIn.xyz,vec3(2.2)); #else vec3 bLess = step(vec3(0.04045),srgbIn.xyz); vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); #endif return vec4(linOut,srgbIn.w);; #else return srgbIn; #endif } vec3 getNormal() { #ifndef HAS_TANGENTS vec3 pos_dx = dFdx(pbr_vPosition); vec3 pos_dy = dFdy(pbr_vPosition); vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0)); vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0)); vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t); #ifdef HAS_NORMALS vec3 ng = normalize(pbr_vNormal); #else vec3 ng = cross(pos_dx, pos_dy); #endif t = normalize(t - ng * dot(ng, t)); vec3 b = normalize(cross(ng, t)); mat3 tbn = mat3(t, b, ng); #else mat3 tbn = pbr_vTBN; #endif #ifdef HAS_NORMALMAP vec3 n = texture(u_NormalSampler, pbr_vUV).rgb; n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0))); #else vec3 n = normalize(tbn[2].xyz); #endif return n; } #ifdef USE_IBL vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection) { float mipCount = 9.0; float lod = (pbrInputs.perceptualRoughness * mipCount); vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT, vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb; vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb; #ifdef USE_TEX_LOD vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb; #else vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb; #endif vec3 diffuse = diffuseLight * pbrInputs.diffuseColor; vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y); diffuse *= u_ScaleIBLAmbient.x; specular *= u_ScaleIBLAmbient.y; return diffuse + specular; } #endif vec3 diffuse(PBRInfo pbrInputs) { return pbrInputs.diffuseColor / M_PI; } vec3 specularReflection(PBRInfo pbrInputs) { return pbrInputs.reflectance0 + (pbrInputs.reflectance90 - pbrInputs.reflectance0) * pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0); } float geometricOcclusion(PBRInfo pbrInputs) { float NdotL = pbrInputs.NdotL; float NdotV = pbrInputs.NdotV; float r = pbrInputs.alphaRoughness; float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL))); float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV))); return attenuationL * attenuationV; } float microfacetDistribution(PBRInfo pbrInputs) { float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness; float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0; return roughnessSq / (M_PI * f * f); } void PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) { pbrInputs.NdotL = 1.0; pbrInputs.NdotH = 0.0; pbrInputs.LdotH = 0.0; pbrInputs.VdotH = 1.0; } void PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) { vec3 n = pbrInputs.n; vec3 v = pbrInputs.v; vec3 l = normalize(lightDirection); vec3 h = normalize(l+v); pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0); pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0); pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0); pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0); } void PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) { vec3 light_direction = normalize(pointLight.position - pbr_vPosition); PBRInfo_setDirectionalLight(pbrInputs, light_direction); } vec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) { vec3 F = specularReflection(pbrInputs); float G = geometricOcclusion(pbrInputs); float D = microfacetDistribution(pbrInputs); vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs); vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV); return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib); } vec4 pbr_filterColor(vec4 colorUnused) { #ifdef HAS_BASECOLORMAP vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor; #else vec4 baseColor = u_BaseColorFactor; #endif #ifdef ALPHA_CUTOFF if (baseColor.a < u_AlphaCutoff) { discard; } #endif vec3 color = vec3(0, 0, 0); if(pbr_uUnlit){ color.rgb = baseColor.rgb; } else{ float perceptualRoughness = u_MetallicRoughnessValues.y; float metallic = u_MetallicRoughnessValues.x; #ifdef HAS_METALROUGHNESSMAP vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV); perceptualRoughness = mrSample.g * perceptualRoughness; metallic = mrSample.b * metallic; #endif perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0); metallic = clamp(metallic, 0.0, 1.0); float alphaRoughness = perceptualRoughness * perceptualRoughness; vec3 f0 = vec3(0.04); vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0); diffuseColor *= 1.0 - metallic; vec3 specularColor = mix(f0, baseColor.rgb, metallic); float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b); float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0); vec3 specularEnvironmentR0 = specularColor.rgb; vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90; vec3 n = getNormal(); vec3 v = normalize(u_Camera - pbr_vPosition); float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0); vec3 reflection = -normalize(reflect(v, n)); PBRInfo pbrInputs = PBRInfo( 0.0, NdotV, 0.0, 0.0, 0.0, perceptualRoughness, metallic, specularEnvironmentR0, specularEnvironmentR90, alphaRoughness, diffuseColor, specularColor, n, v ); #ifdef USE_LIGHTS PBRInfo_setAmbientLight(pbrInputs); color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color); for(int i = 0; i < lighting_uDirectionalLightCount; i++) { if (i < lighting_uDirectionalLightCount) { PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction); color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color); } } for(int i = 0; i < lighting_uPointLightCount; i++) { if (i < lighting_uPointLightCount) { PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]); float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition)); color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation); } } #endif #ifdef USE_IBL color += getIBLContribution(pbrInputs, n, reflection); #endif #ifdef HAS_OCCLUSIONMAP float ao = texture(u_OcclusionSampler, pbr_vUV).r; color = mix(color, color * ao, u_OcclusionStrength); #endif #ifdef HAS_EMISSIVEMAP vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor; color += emissive; #endif #ifdef PBR_DEBUG color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y); color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z); color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w); #endif } return vec4(pow(color,vec3(1.0/2.2)), baseColor.a); } `; // ../../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/pbr/pbr.js var pbr = { name: "pbr", vs, fs, defines: { LIGHTING_FRAGMENT: 1 }, dependencies: [lights] }; // src/scenegraph-layer/scenegraph-layer.ts var import_engine4 = __toESM(require_engine(), 1); // ../../node_modules/@luma.gl/gltf/dist/pbr/parse-pbr-material.js var import_core5 = __toESM(require_core2(), 1); var GLEnum; (function(GLEnum3) { GLEnum3[GLEnum3["FUNC_ADD"] = 32774] = "FUNC_ADD"; GLEnum3[GLEnum3["ONE"] = 1] = "ONE"; GLEnum3[GLEnum3["SRC_ALPHA"] = 770] = "SRC_ALPHA"; GLEnum3[GLEnum3["ONE_MINUS_SRC_ALPHA"] = 771] = "ONE_MINUS_SRC_ALPHA"; GLEnum3[GLEnum3["TEXTURE_MIN_FILTER"] = 10241] = "TEXTURE_MIN_FILTER"; GLEnum3[GLEnum3["LINEAR"] = 9729] = "LINEAR"; GLEnum3[GLEnum3["LINEAR_MIPMAP_NEAREST"] = 9985] = "LINEAR_MIPMAP_NEAREST"; GLEnum3[GLEnum3["UNPACK_FLIP_Y_WEBGL"] = 37440] = "UNPACK_FLIP_Y_WEBGL"; })(GLEnum || (GLEnum = {})); function parsePBRMaterial(device, material, attributes, options) { const parsedMaterial = { defines: { MANUAL_SRGB: 1, SRGB_FAST_APPROXIMATION: 1 }, bindings: {}, uniforms: { u_Camera: [0, 0, 0], u_MetallicRoughnessValues: [1, 1] }, parameters: {}, glParameters: {}, generatedTextures: [] }; parsedMaterial.defines.USE_TEX_LOD = 1; const { imageBasedLightingEnvironment } = options; if (imageBasedLightingEnvironment) { parsedMaterial.bindings.u_DiffuseEnvSampler = imageBasedLightingEnvironment.diffuseEnvSampler; parsedMaterial.bindings.u_SpecularEnvSampler = imageBasedLightingEnvironment.specularEnvSampler; parsedMaterial.bindings.u_brdfLUT = imageBasedLightingEnvironment.brdfLutTexture; parsedMaterial.uniforms.u_ScaleIBLAmbient = [1, 1]; } if (options?.pbrDebug) { parsedMaterial.defines.PBR_DEBUG = 1; parsedMaterial.uniforms.u_ScaleDiffBaseMR = [0, 0, 0, 0]; parsedMaterial.uniforms.u_ScaleFGDSpec = [0, 0, 0, 0]; } if (attributes.NORMAL) parsedMaterial.defines.HAS_NORMALS = 1; if (attributes.TANGENT && options?.useTangents) parsedMaterial.defines.HAS_TANGENTS = 1; if (attributes.TEXCOORD_0) parsedMaterial.defines.HAS_UV = 1; if (options?.imageBasedLightingEnvironment) parsedMaterial.defines.USE_IBL = 1; if (options?.lights) parsedMaterial.defines.USE_LIGHTS = 1; if (material) { parseMaterial(device, material, parsedMaterial); } return parsedMaterial; } function parseMaterial(device, material, parsedMaterial) { parsedMaterial.uniforms.pbr_uUnlit = Boolean(material.unlit); if (material.pbrMetallicRoughness) { parsePbrMetallicRoughness(device, material.pbrMetallicRoughness, parsedMaterial); } if (material.normalTexture) { addTexture(device, material.normalTexture, "u_NormalSampler", "HAS_NORMALMAP", parsedMaterial); const { scale: scale5 = 1 } = material.normalTexture; parsedMaterial.uniforms.u_NormalScale = scale5; } if (material.occlusionTexture) { addTexture(device, material.occlusionTexture, "u_OcclusionSampler", "HAS_OCCLUSIONMAP", parsedMaterial); const { strength = 1 } = material.occlusionTexture; parsedMaterial.uniforms.u_OcclusionStrength = strength; } if (material.emissiveTexture) { addTexture(device, material.emissiveTexture, "u_EmissiveSampler", "HAS_EMISSIVEMAP", parsedMaterial); parsedMaterial.uniforms.u_EmissiveFactor = material.emissiveFactor || [0, 0, 0]; } switch (material.alphaMode) { case "MASK": const { alphaCutoff = 0.5 } = material; parsedMaterial.defines.ALPHA_CUTOFF = 1; parsedMaterial.uniforms.u_AlphaCutoff = alphaCutoff; break; case "BLEND": import_core5.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(); parsedMaterial.parameters.blendColorOperation = "add"; parsedMaterial.parameters.blendColorSrcFactor = "src-alpha"; parsedMaterial.parameters.blendColorDstFactor = "one-minus-src-alpha"; parsedMaterial.parameters.blendAlphaOperation = "add"; parsedMaterial.parameters.blendAlphaSrcFactor = "one"; parsedMaterial.parameters.blendAlphaDstFactor = "one-minus-src-alpha"; parsedMaterial.glParameters.blend = true; parsedMaterial.glParameters.blendEquation = GLEnum.FUNC_ADD; parsedMaterial.glParameters.blendFunc = [ GLEnum.SRC_ALPHA, GLEnum.ONE_MINUS_SRC_ALPHA, GLEnum.ONE, GLEnum.ONE_MINUS_SRC_ALPHA ]; break; } } function parsePbrMetallicRoughness(device, pbrMetallicRoughness, parsedMaterial) { if (pbrMetallicRoughness.baseColorTexture) { addTexture(device, pbrMetallicRoughness.baseColorTexture, "u_BaseColorSampler", "HAS_BASECOLORMAP", parsedMaterial); } parsedMaterial.uniforms.u_BaseColorFactor = pbrMetallicRoughness.baseColorFactor || [1, 1, 1, 1]; if (pbrMetallicRoughness.metallicRoughnessTexture) { addTexture(device, pbrMetallicRoughness.metallicRoughnessTexture, "u_MetallicRoughnessSampler", "HAS_METALROUGHNESSMAP", parsedMaterial); } const { metallicFactor = 1, roughnessFactor = 1 } = pbrMetallicRoughness; parsedMaterial.uniforms.u_MetallicRoughnessValues = [metallicFactor, roughnessFactor]; } function addTexture(device, gltfTexture, uniformName, define = null, parsedMaterial) { const parameters = gltfTexture?.texture?.sampler?.parameters || {}; const image = gltfTexture.texture.source.image; let textureOptions; let specialTextureParameters = {}; if (image.compressed) { textureOptions = image; specialTextureParameters = { [GLEnum.TEXTURE_MIN_FILTER]: image.data.length > 1 ? GLEnum.LINEAR_MIPMAP_NEAREST : GLEnum.LINEAR }; } else { textureOptions = { data: image }; } const texture = device.createTexture({ id: gltfTexture.uniformName || gltfTexture.id, parameters: { ...parameters, ...specialTextureParameters }, pixelStore: { [GLEnum.UNPACK_FLIP_Y_WEBGL]: false }, ...textureOptions }); parsedMaterial.bindings[uniformName] = texture; if (define) parsedMaterial.defines[define] = 1; parsedMaterial.generatedTextures.push(texture); } // ../../node_modules/@loaders.gl/textures/dist/lib/utils/version.js var VERSION = true ? "4.2.0-beta.2" : "latest"; // ../../node_modules/@loaders.gl/loader-utils/dist/loader-types.js async function parseFromContext(data, loaders, options, context) { return context._parse(data, loaders, options, context); } // ../../node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/assert.js function assert2(condition, message) { if (!condition) { throw new Error(message || "loader assertion failed."); } } // ../../node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/globals.js var globals = { self: typeof self !== "undefined" && self, window: typeof window !== "undefined" && window, global: typeof global !== "undefined" && global, document: typeof document !== "undefined" && document }; var self_ = globals.self || globals.window || globals.global || {}; var window_ = globals.window || globals.self || globals.global || {}; var global_ = globals.global || globals.self || globals.window || {}; var document_ = globals.document || {}; var isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser); var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version); var nodeVersion = matches && parseFloat(matches[1]) || 0; // ../../node_modules/@loaders.gl/loader-utils/dist/lib/module-utils/js-module-utils.js function registerJSModules(modules) { globalThis.loaders ||= {}; globalThis.loaders.modules ||= {}; Object.assign(globalThis.loaders.modules, modules); } function getJSModuleOrNull(name12) { const module = globalThis.loaders?.modules?.[name12]; return module || null; } // ../../node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js function getVersion() { if (!globalThis._loadersgl_?.version) { globalThis._loadersgl_ = globalThis._loadersgl_ || {}; if (false) { console.warn("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."); globalThis._loadersgl_.version = NPM_TAG; } else { globalThis._loadersgl_.version = "4.2.0-beta.2"; } } return globalThis._loadersgl_.version; } var VERSION2 = getVersion(); // ../../node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js function assert3(condition, message) { if (!condition) { throw new Error(message || "loaders.gl assertion failed."); } } // ../../node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/globals.js var globals2 = { self: typeof self !== "undefined" && self, window: typeof window !== "undefined" && window, global: typeof global !== "undefined" && global, document: typeof document !== "undefined" && document }; var self_2 = globals2.self || globals2.window || globals2.global || {}; var window_2 = globals2.window || globals2.self || globals2.global || {}; var global_2 = globals2.global || globals2.self || globals2.window || {}; var document_2 = globals2.document || {}; var isBrowser2 = typeof process !== "object" || String(process) !== "[object process]" || process.browser; var isWorker = typeof importScripts === "function"; var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined"; var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version); var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0; // ../../node_modules/@loaders.gl/worker-utils/dist/lib/library-utils/library-utils.js var loadLibraryPromises = {}; async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) { if (moduleName) { libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName); } loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl); return await loadLibraryPromises[libraryUrl]; } function getLibraryUrl(library, moduleName, options = {}, libraryName = null) { if (!options.useLocalLibraries && library.startsWith("http")) { return library; } libraryName = libraryName || library; const modules = options.modules || {}; if (modules[libraryName]) { return modules[libraryName]; } if (!isBrowser2) { return `modules/${moduleName}/dist/libs/${libraryName}`; } if (options.CDN) { assert3(options.CDN.startsWith("http")); return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`; } if (isWorker) { return `../src/libs/${libraryName}`; } return `modules/${moduleName}/src/libs/${libraryName}`; } async function loadLibraryFromFile(libraryUrl) { if (libraryUrl.endsWith("wasm")) { return await loadAsArrayBuffer(libraryUrl); } if (!isBrowser2) { try { const { requireFromFile } = globalThis.loaders || {}; return await requireFromFile?.(libraryUrl); } catch (error) { console.error(error); return null; } } if (isWorker) { return importScripts(libraryUrl); } const scriptSource = await loadAsText(libraryUrl); return loadLibraryFromString(scriptSource, libraryUrl); } function loadLibraryFromString(scriptSource, id) { if (!isBrowser2) { const { requireFromString } = globalThis.loaders || {}; return requireFromString?.(scriptSource, id); } if (isWorker) { eval.call(globalThis, scriptSource); return null; } const script = document.createElement("script"); script.id = id; try { script.appendChild(document.createTextNode(scriptSource)); } catch (e) { script.text = scriptSource; } document.body.appendChild(script); return null; } async function loadAsArrayBuffer(url) { const { readFileAsArrayBuffer } = globalThis.loaders || {}; if (isBrowser2 || !readFileAsArrayBuffer || url.startsWith("http")) { const response = await fetch(url); return await response.arrayBuffer(); } return await readFileAsArrayBuffer(url); } async function loadAsText(url) { const { readFileAsText } = globalThis.loaders || {}; if (isBrowser2 || !readFileAsText || url.startsWith("http")) { const response = await fetch(url); return await response.text(); } return await readFileAsText(url); } // ../../node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/get-first-characters.js function getFirstCharacters(data, length4 = 5) { if (typeof data === "string") { return data.slice(0, length4); } else if (ArrayBuffer.isView(data)) { return getMagicString(data.buffer, data.byteOffset, length4); } else if (data instanceof ArrayBuffer) { const byteOffset = 0; return getMagicString(data, byteOffset, length4); } return ""; } function getMagicString(arrayBuffer, byteOffset, length4) { if (arrayBuffer.byteLength <= byteOffset + length4) { return ""; } const dataView = new DataView(arrayBuffer); let magic = ""; for (let i2 = 0; i2 < length4; i2++) { magic += String.fromCharCode(dataView.getUint8(byteOffset + i2)); } return magic; } // ../../node_modules/@loaders.gl/loader-utils/dist/lib/parser-utils/parse-json.js function parseJSON(string) { try { return JSON.parse(string); } catch (_) { throw new Error(`Failed to parse JSON from data starting with "${getFirstCharacters(string)}"`); } } // ../../node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/array-buffer-utils.js function sliceArrayBuffer(arrayBuffer, byteOffset, byteLength) { const subArray = byteLength !== void 0 ? new Uint8Array(arrayBuffer).subarray(byteOffset, byteOffset + byteLength) : new Uint8Array(arrayBuffer).subarray(byteOffset); const arrayCopy = new Uint8Array(subArray); return arrayCopy.buffer; } // ../../node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/memory-copy-utils.js function padToNBytes(byteLength, padding) { assert2(byteLength >= 0); assert2(padding > 0); return byteLength + (padding - 1) & ~(padding - 1); } function copyToArray(source, target, targetOffset) { let sourceArray; if (source instanceof ArrayBuffer) { sourceArray = new Uint8Array(source); } else { const srcByteOffset = source.byteOffset; const srcByteLength = source.byteLength; sourceArray = new Uint8Array(source.buffer || source.arrayBuffer, srcByteOffset, srcByteLength); } target.set(sourceArray, targetOffset); return targetOffset + padToNBytes(sourceArray.byteLength, 4); } // ../../node_modules/@loaders.gl/textures/dist/lib/parsers/basis-module-loader.js var BASIS_EXTERNAL_LIBRARIES = { TRANSCODER: "basis_transcoder.js", TRANSCODER_WASM: "basis_transcoder.wasm", ENCODER: "basis_encoder.js", ENCODER_WASM: "basis_encoder.wasm" }; var loadBasisTranscoderPromise; async function loadBasisTranscoderModule(options) { registerJSModules(options.modules); const basis = getJSModuleOrNull("basis"); if (basis) { return basis; } loadBasisTranscoderPromise ||= loadBasisTranscoder(options); return await loadBasisTranscoderPromise; } async function loadBasisTranscoder(options) { let BASIS = null; let wasmBinary = null; [BASIS, wasmBinary] = await Promise.all([ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options), await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options) ]); BASIS = BASIS || globalThis.BASIS; return await initializeBasisTranscoderModule(BASIS, wasmBinary); } function initializeBasisTranscoderModule(BasisModule, wasmBinary) { const options = {}; if (wasmBinary) { options.wasmBinary = wasmBinary; } return new Promise((resolve) => { BasisModule(options).then((module) => { const { BasisFile, initializeBasis } = module; initializeBasis(); resolve({ BasisFile }); }); }); } var loadBasisEncoderPromise; async function loadBasisEncoderModule(options) { const modules = options.modules || {}; if (modules.basisEncoder) { return modules.basisEncoder; } loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options); return await loadBasisEncoderPromise; } async function loadBasisEncoder(options) { let BASIS_ENCODER = null; let wasmBinary = null; [BASIS_ENCODER, wasmBinary] = await Promise.all([ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options), await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options) ]); BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS; return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary); } function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) { const options = {}; if (wasmBinary) { options.wasmBinary = wasmBinary; } return new Promise((resolve) => { BasisEncoderModule(options).then((module) => { const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module; initializeBasis(); resolve({ BasisFile, KTX2File, BasisEncoder }); }); }); } // ../../node_modules/@loaders.gl/textures/dist/lib/gl-extensions.js var GL_EXTENSIONS_CONSTANTS = { COMPRESSED_RGB_S3TC_DXT1_EXT: 33776, COMPRESSED_RGBA_S3TC_DXT1_EXT: 33777, COMPRESSED_RGBA_S3TC_DXT3_EXT: 33778, COMPRESSED_RGBA_S3TC_DXT5_EXT: 33779, COMPRESSED_R11_EAC: 37488, COMPRESSED_SIGNED_R11_EAC: 37489, COMPRESSED_RG11_EAC: 37490, COMPRESSED_SIGNED_RG11_EAC: 37491, COMPRESSED_RGB8_ETC2: 37492, COMPRESSED_RGBA8_ETC2_EAC: 37493, COMPRESSED_SRGB8_ETC2: 37494, COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 37495, COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37496, COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 37497, COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 35840, COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 35842, COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 35841, COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 35843, COMPRESSED_RGB_ETC1_WEBGL: 36196, COMPRESSED_RGB_ATC_WEBGL: 35986, COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 35987, COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 34798, COMPRESSED_RGBA_ASTC_4X4_KHR: 37808, COMPRESSED_RGBA_ASTC_5X4_KHR: 37809, COMPRESSED_RGBA_ASTC_5X5_KHR: 37810, COMPRESSED_RGBA_ASTC_6X5_KHR: 37811, COMPRESSED_RGBA_ASTC_6X6_KHR: 37812, COMPRESSED_RGBA_ASTC_8X5_KHR: 37813, COMPRESSED_RGBA_ASTC_8X6_KHR: 37814, COMPRESSED_RGBA_ASTC_8X8_KHR: 37815, COMPRESSED_RGBA_ASTC_10X5_KHR: 37816, COMPRESSED_RGBA_ASTC_10X6_KHR: 37817, COMPRESSED_RGBA_ASTC_10X8_KHR: 37818, COMPRESSED_RGBA_ASTC_10X10_KHR: 37819, COMPRESSED_RGBA_ASTC_12X10_KHR: 37820, COMPRESSED_RGBA_ASTC_12X12_KHR: 37821, COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 37840, COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 37841, COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 37842, COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 37843, COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 37844, COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 37845, COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 37846, COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 37847, COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 37848, COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 37849, COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 37850, COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 37851, COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 37852, COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 37853, COMPRESSED_RED_RGTC1_EXT: 36283, COMPRESSED_SIGNED_RED_RGTC1_EXT: 36284, COMPRESSED_RED_GREEN_RGTC2_EXT: 36285, COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 36286, COMPRESSED_SRGB_S3TC_DXT1_EXT: 35916, COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 35917, COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 35918, COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 35919 }; // ../../node_modules/@loaders.gl/textures/dist/lib/utils/texture-formats.js var BROWSER_PREFIXES = ["", "WEBKIT_", "MOZ_"]; var WEBGL_EXTENSIONS = { WEBGL_compressed_texture_s3tc: "dxt", WEBGL_compressed_texture_s3tc_srgb: "dxt-srgb", WEBGL_compressed_texture_etc1: "etc1", WEBGL_compressed_texture_etc: "etc2", WEBGL_compressed_texture_pvrtc: "pvrtc", WEBGL_compressed_texture_atc: "atc", WEBGL_compressed_texture_astc: "astc", EXT_texture_compression_rgtc: "rgtc" }; var formats = null; function getSupportedGPUTextureFormats(gl) { if (!formats) { gl = gl || getWebGLContext() || void 0; formats = /* @__PURE__ */ new Set(); for (const prefix of BROWSER_PREFIXES) { for (const extension in WEBGL_EXTENSIONS) { if (gl && gl.getExtension(`${prefix}${extension}`)) { const gpuTextureFormat = WEBGL_EXTENSIONS[extension]; formats.add(gpuTextureFormat); } } } } return formats; } function getWebGLContext() { try { const canvas = document.createElement("canvas"); return canvas.getContext("webgl"); } catch (error) { return null; } } // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js var t = new Uint8Array([0]); var n; var i; var s; var a; var r; var o; var l; var f; !function(t2) { t2[t2.NONE = 0] = "NONE", t2[t2.BASISLZ = 1] = "BASISLZ", t2[t2.ZSTD = 2] = "ZSTD", t2[t2.ZLIB = 3] = "ZLIB"; }(n || (n = {})), function(t2) { t2[t2.BASICFORMAT = 0] = "BASICFORMAT"; }(i || (i = {})), function(t2) { t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.ETC1S = 163] = "ETC1S", t2[t2.UASTC = 166] = "UASTC"; }(s || (s = {})), function(t2) { t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.SRGB = 1] = "SRGB"; }(a || (a = {})), function(t2) { t2[t2.UNSPECIFIED = 0] = "UNSPECIFIED", t2[t2.LINEAR = 1] = "LINEAR", t2[t2.SRGB = 2] = "SRGB", t2[t2.ITU = 3] = "ITU", t2[t2.NTSC = 4] = "NTSC", t2[t2.SLOG = 5] = "SLOG", t2[t2.SLOG2 = 6] = "SLOG2"; }(r || (r = {})), function(t2) { t2[t2.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t2[t2.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED"; }(o || (o = {})), function(t2) { t2[t2.RGB = 0] = "RGB", t2[t2.RRR = 3] = "RRR", t2[t2.GGG = 4] = "GGG", t2[t2.AAA = 15] = "AAA"; }(l || (l = {})), function(t2) { t2[t2.RGB = 0] = "RGB", t2[t2.RGBA = 3] = "RGBA", t2[t2.RRR = 4] = "RRR", t2[t2.RRRG = 5] = "RRRG"; }(f || (f = {})); // ../../node_modules/@loaders.gl/textures/dist/lib/parsers/parse-ktx.js var KTX2_ID = [ 171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10 ]; function isKTX(data) { const id = new Uint8Array(data); const notKTX = id.byteLength < KTX2_ID.length || id[0] !== KTX2_ID[0] || id[1] !== KTX2_ID[1] || id[2] !== KTX2_ID[2] || id[3] !== KTX2_ID[3] || id[4] !== KTX2_ID[4] || id[5] !== KTX2_ID[5] || id[6] !== KTX2_ID[6] || id[7] !== KTX2_ID[7] || id[8] !== KTX2_ID[8] || id[9] !== KTX2_ID[9] || id[10] !== KTX2_ID[10] || id[11] !== KTX2_ID[11]; return !notKTX; } // ../../node_modules/@loaders.gl/textures/dist/lib/parsers/parse-basis.js var OutputFormat = { etc1: { basisFormat: 0, compressed: true, format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL }, etc2: { basisFormat: 1, compressed: true }, bc1: { basisFormat: 2, compressed: true, format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT }, bc3: { basisFormat: 3, compressed: true, format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT }, bc4: { basisFormat: 4, compressed: true }, bc5: { basisFormat: 5, compressed: true }, "bc7-m6-opaque-only": { basisFormat: 6, compressed: true }, "bc7-m5": { basisFormat: 7, compressed: true }, "pvrtc1-4-rgb": { basisFormat: 8, compressed: true, format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG }, "pvrtc1-4-rgba": { basisFormat: 9, compressed: true, format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG }, "astc-4x4": { basisFormat: 10, compressed: true, format: GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR }, "atc-rgb": { basisFormat: 11, compressed: true }, "atc-rgba-interpolated-alpha": { basisFormat: 12, compressed: true }, rgba32: { basisFormat: 13, compressed: false }, rgb565: { basisFormat: 14, compressed: false }, bgr565: { basisFormat: 15, compressed: false }, rgba4444: { basisFormat: 16, compressed: false } }; async function parseBasis(data, options) { if (options.basis.containerFormat === "auto") { if (isKTX(data)) { const fileConstructors = await loadBasisEncoderModule(options); return parseKTX2File(fileConstructors.KTX2File, data, options); } const { BasisFile } = await loadBasisTranscoderModule(options); return parseBasisFile(BasisFile, data, options); } switch (options.basis.module) { case "encoder": const fileConstructors = await loadBasisEncoderModule(options); switch (options.basis.containerFormat) { case "ktx2": return parseKTX2File(fileConstructors.KTX2File, data, options); case "basis": default: return parseBasisFile(fileConstructors.BasisFile, data, options); } case "transcoder": default: const { BasisFile } = await loadBasisTranscoderModule(options); return parseBasisFile(BasisFile, data, options); } } function parseBasisFile(BasisFile, data, options) { const basisFile = new BasisFile(new Uint8Array(data)); try { if (!basisFile.startTranscoding()) { throw new Error("Failed to start basis transcoding"); } const imageCount = basisFile.getNumImages(); const images = []; for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) { const levelsCount = basisFile.getNumLevels(imageIndex); const levels = []; for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) { levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options)); } images.push(levels); } return images; } finally { basisFile.close(); basisFile.delete(); } } function transcodeImage(basisFile, imageIndex, levelIndex, options) { const width = basisFile.getImageWidth(imageIndex, levelIndex); const height = basisFile.getImageHeight(imageIndex, levelIndex); const hasAlpha = basisFile.getHasAlpha(); const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha); const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat); const decodedData = new Uint8Array(decodedSize); if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) { throw new Error("failed to start Basis transcoding"); } return { width, height, data: decodedData, compressed, format, hasAlpha }; } function parseKTX2File(KTX2File, data, options) { const ktx2File = new KTX2File(new Uint8Array(data)); try { if (!ktx2File.startTranscoding()) { throw new Error("failed to start KTX2 transcoding"); } const levelsCount = ktx2File.getLevels(); const levels = []; for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) { levels.push(transcodeKTX2Image(ktx2File, levelIndex, options)); break; } return [levels]; } finally { ktx2File.close(); ktx2File.delete(); } } function transcodeKTX2Image(ktx2File, levelIndex, options) { const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0); const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag); const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0, 0, basisFormat); const decodedData = new Uint8Array(decodedSize); if (!ktx2File.transcodeImage(decodedData, levelIndex, 0, 0, basisFormat, 0, -1, -1)) { throw new Error("Failed to transcode KTX2 image"); } return { width, height, data: decodedData, compressed, levelSize: decodedSize, hasAlpha: alphaFlag, format }; } function getBasisOptions(options, hasAlpha) { let format = options && options.basis && options.basis.format; if (format === "auto") { format = selectSupportedBasisFormat(); } if (typeof format === "object") { format = hasAlpha ? format.alpha : format.noAlpha; } format = format.toLowerCase(); return OutputFormat[format]; } function selectSupportedBasisFormat() { const supportedFormats = getSupportedGPUTextureFormats(); if (supportedFormats.has("astc")) { return "astc-4x4"; } else if (supportedFormats.has("dxt")) { return { alpha: "bc3", noAlpha: "bc1" }; } else if (supportedFormats.has("pvrtc")) { return { alpha: "pvrtc1-4-rgba", noAlpha: "pvrtc1-4-rgb" }; } else if (supportedFormats.has("etc1")) { return "etc1"; } else if (supportedFormats.has("etc2")) { return "etc2"; } return "rgb565"; } // ../../node_modules/@loaders.gl/textures/dist/basis-loader.js var BasisWorkerLoader = { dataType: null, batchType: null, name: "Basis", id: "basis", module: "textures", version: VERSION, worker: true, extensions: ["basis", "ktx2"], mimeTypes: ["application/octet-stream", "image/ktx2"], tests: ["sB"], binary: true, options: { basis: { format: "auto", libraryPath: "libs/", containerFormat: "auto", module: "transcoder" } } }; var BasisLoader = { ...BasisWorkerLoader, parse: parseBasis }; // ../../node_modules/@loaders.gl/images/dist/lib/utils/version.js var VERSION3 = true ? "4.2.0-beta.2" : "latest"; // ../../node_modules/@loaders.gl/images/dist/lib/category-api/image-type.js var parseImageNode = globalThis.loaders?.parseImageNode; var IMAGE_SUPPORTED = typeof Image !== "undefined"; var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined"; var NODE_IMAGE_SUPPORTED = Boolean(parseImageNode); var DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED; function isImageTypeSupported(type) { switch (type) { case "auto": return IMAGE_BITMAP_SUPPORTED || IMAGE_SUPPORTED || DATA_SUPPORTED; case "imagebitmap": return IMAGE_BITMAP_SUPPORTED; case "image": return IMAGE_SUPPORTED; case "data": return DATA_SUPPORTED; default: throw new Error(`@loaders.gl/images: image ${type} not supported in this environment`); } } function getDefaultImageType() { if (IMAGE_BITMAP_SUPPORTED) { return "imagebitmap"; } if (IMAGE_SUPPORTED) { return "image"; } if (DATA_SUPPORTED) { return "data"; } throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js"); } // ../../node_modules/@loaders.gl/images/dist/lib/category-api/parsed-image-api.js function getImageType(image) { const format = getImageTypeOrNull(image); if (!format) { throw new Error("Not an image"); } return format; } function getImageData(image) { switch (getImageType(image)) { case "data": return image; case "image": case "imagebitmap": const canvas = document.createElement("canvas"); const context = canvas.getContext("2d"); if (!context) { throw new Error("getImageData"); } canvas.width = image.width; canvas.height = image.height; context.drawImage(image, 0, 0); return context.getImageData(0, 0, image.width, image.height); default: throw new Error("getImageData"); } } function getImageTypeOrNull(image) { if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) { return "imagebitmap"; } if (typeof Image !== "undefined" && image instanceof Image) { return "image"; } if (image && typeof image === "object" && image.data && image.width && image.height) { return "data"; } return null; } // ../../node_modules/@loaders.gl/images/dist/lib/parsers/svg-utils.js var SVG_DATA_URL_PATTERN = /^data:image\/svg\+xml/; var SVG_URL_PATTERN = /\.svg((\?|#).*)?$/; function isSVG(url) { return url && (SVG_DATA_URL_PATTERN.test(url) || SVG_URL_PATTERN.test(url)); } function getBlobOrSVGDataUrl(arrayBuffer, url) { if (isSVG(url)) { const textDecoder = new TextDecoder(); let xmlText = textDecoder.decode(arrayBuffer); try { if (typeof unescape === "function" && typeof encodeURIComponent === "function") { xmlText = unescape(encodeURIComponent(xmlText)); } } catch (error) { throw new Error(error.message); } const src = `data:image/svg+xml;base64,${btoa(xmlText)}`; return src; } return getBlob(arrayBuffer, url); } function getBlob(arrayBuffer, url) { if (isSVG(url)) { throw new Error("SVG cannot be parsed directly to imagebitmap"); } return new Blob([new Uint8Array(arrayBuffer)]); } // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image.js async function parseToImage(arrayBuffer, options, url) { const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url); const URL = self.URL || self.webkitURL; const objectUrl = typeof blobOrDataUrl !== "string" && URL.createObjectURL(blobOrDataUrl); try { return await loadToImage(objectUrl || blobOrDataUrl, options); } finally { if (objectUrl) { URL.revokeObjectURL(objectUrl); } } } async function loadToImage(url, options) { const image = new Image(); image.src = url; if (options.image && options.image.decode && image.decode) { await image.decode(); return image; } return await new Promise((resolve, reject) => { try { image.onload = () => resolve(image); image.onerror = (error) => { const message = error instanceof Error ? error.message : "error"; reject(new Error(message)); }; } catch (error) { reject(error); } }); } // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image-bitmap.js var EMPTY_OBJECT = {}; var imagebitmapOptionsSupported = true; async function parseToImageBitmap(arrayBuffer, options, url) { let blob; if (isSVG(url)) { const image = await parseToImage(arrayBuffer, options, url); blob = image; } else { blob = getBlob(arrayBuffer, url); } const imagebitmapOptions = options && options.imagebitmap; return await safeCreateImageBitmap(blob, imagebitmapOptions); } async function safeCreateImageBitmap(blob, imagebitmapOptions = null) { if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) { imagebitmapOptions = null; } if (imagebitmapOptions) { try { return await createImageBitmap(blob, imagebitmapOptions); } catch (error) { console.warn(error); imagebitmapOptionsSupported = false; } } return await createImageBitmap(blob); } function isEmptyObject(object) { for (const key in object || EMPTY_OBJECT) { return false; } return true; } // ../../node_modules/@loaders.gl/images/dist/lib/category-api/parse-isobmff-binary.js function getISOBMFFMediaType(buffer) { if (!checkString(buffer, "ftyp", 4)) { return null; } if ((buffer[8] & 96) === 0) { return null; } return decodeMajorBrand(buffer); } function decodeMajorBrand(buffer) { const brandMajor = getUTF8String(buffer, 8, 12).replace("\0", " ").trim(); switch (brandMajor) { case "avif": case "avis": return { extension: "avif", mimeType: "image/avif" }; default: return null; } } function getUTF8String(array, start, end) { return String.fromCharCode(...array.slice(start, end)); } function stringToBytes(string) { return [...string].map((character) => character.charCodeAt(0)); } function checkString(buffer, header, offset = 0) { const headerBytes = stringToBytes(header); for (let i2 = 0; i2 < headerBytes.length; ++i2) { if (headerBytes[i2] !== buffer[i2 + offset]) { return false; } } return true; } // ../../node_modules/@loaders.gl/images/dist/lib/category-api/binary-image-api.js var BIG_ENDIAN = false; var LITTLE_ENDIAN = true; function getBinaryImageMetadata(binaryData) { const dataView = toDataView(binaryData); return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView) || getISOBMFFMetadata(dataView); } function getISOBMFFMetadata(binaryData) { const buffer = new Uint8Array(binaryData instanceof DataView ? binaryData.buffer : binaryData); const mediaType = getISOBMFFMediaType(buffer); if (!mediaType) { return null; } return { mimeType: mediaType.mimeType, width: 0, height: 0 }; } function getPngMetadata(binaryData) { const dataView = toDataView(binaryData); const isPng = dataView.byteLength >= 24 && dataView.getUint32(0, BIG_ENDIAN) === 2303741511; if (!isPng) { return null; } return { mimeType: "image/png", width: dataView.getUint32(16, BIG_ENDIAN), height: dataView.getUint32(20, BIG_ENDIAN) }; } function getGifMetadata(binaryData) { const dataView = toDataView(binaryData); const isGif = dataView.byteLength >= 10 && dataView.getUint32(0, BIG_ENDIAN) === 1195984440; if (!isGif) { return null; } return { mimeType: "image/gif", width: dataView.getUint16(6, LITTLE_ENDIAN), height: dataView.getUint16(8, LITTLE_ENDIAN) }; } function getBmpMetadata(binaryData) { const dataView = toDataView(binaryData); const isBmp = dataView.byteLength >= 14 && dataView.getUint16(0, BIG_ENDIAN) === 16973 && dataView.getUint32(2, LITTLE_ENDIAN) === dataView.byteLength; if (!isBmp) { return null; } return { mimeType: "image/bmp", width: dataView.getUint32(18, LITTLE_ENDIAN), height: dataView.getUint32(22, LITTLE_ENDIAN) }; } function getJpegMetadata(binaryData) { const dataView = toDataView(binaryData); const isJpeg = dataView.byteLength >= 3 && dataView.getUint16(0, BIG_ENDIAN) === 65496 && dataView.getUint8(2) === 255; if (!isJpeg) { return null; } const { tableMarkers, sofMarkers } = getJpegMarkers(); let i2 = 2; while (i2 + 9 < dataView.byteLength) { const marker = dataView.getUint16(i2, BIG_ENDIAN); if (sofMarkers.has(marker)) { return { mimeType: "image/jpeg", height: dataView.getUint16(i2 + 5, BIG_ENDIAN), width: dataView.getUint16(i2 + 7, BIG_ENDIAN) }; } if (!tableMarkers.has(marker)) { return null; } i2 += 2; i2 += dataView.getUint16(i2, BIG_ENDIAN); } return null; } function getJpegMarkers() { const tableMarkers = /* @__PURE__ */ new Set([65499, 65476, 65484, 65501, 65534]); for (let i2 = 65504; i2 < 65520; ++i2) { tableMarkers.add(i2); } const sofMarkers = /* @__PURE__ */ new Set([ 65472, 65473, 65474, 65475, 65477, 65478, 65479, 65481, 65482, 65483, 65485, 65486, 65487, 65502 ]); return { tableMarkers, sofMarkers }; } function toDataView(data) { if (data instanceof DataView) { return data; } if (ArrayBuffer.isView(data)) { return new DataView(data.buffer); } if (data instanceof ArrayBuffer) { return new DataView(data); } throw new Error("toDataView"); } // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-node-image.js async function parseToNodeImage(arrayBuffer, options) { const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {}; const parseImageNode2 = globalThis.loaders?.parseImageNode; assert2(parseImageNode2); return await parseImageNode2(arrayBuffer, mimeType); } // ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-image.js async function parseImage(arrayBuffer, options, context) { options = options || {}; const imageOptions = options.image || {}; const imageType = imageOptions.type || "auto"; const { url } = context || {}; const loadType = getLoadableImageType(imageType); let image; switch (loadType) { case "imagebitmap": image = await parseToImageBitmap(arrayBuffer, options, url); break; case "image": image = await parseToImage(arrayBuffer, options, url); break; case "data": image = await parseToNodeImage(arrayBuffer, options); break; default: assert2(false); } if (imageType === "data") { image = getImageData(image); } return image; } function getLoadableImageType(type) { switch (type) { case "auto": case "data": return getDefaultImageType(); default: isImageTypeSupported(type); return type; } } // ../../node_modules/@loaders.gl/images/dist/image-loader.js var EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"]; var MIME_TYPES = [ "image/png", "image/jpeg", "image/gif", "image/webp", "image/avif", "image/bmp", "image/vnd.microsoft.icon", "image/svg+xml" ]; var DEFAULT_IMAGE_LOADER_OPTIONS = { image: { type: "auto", decode: true } }; var ImageLoader = { dataType: null, batchType: null, id: "image", module: "images", name: "Images", version: VERSION3, mimeTypes: MIME_TYPES, extensions: EXTENSIONS, parse: parseImage, tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))], options: DEFAULT_IMAGE_LOADER_OPTIONS }; // ../../node_modules/@loaders.gl/images/dist/lib/category-api/image-format.js var mimeTypeSupportedSync = {}; function isImageFormatSupported(mimeType) { if (mimeTypeSupportedSync[mimeType] === void 0) { const supported = isBrowser ? checkBrowserImageFormatSupport(mimeType) : checkNodeImageFormatSupport(mimeType); mimeTypeSupportedSync[mimeType] = supported; } return mimeTypeSupportedSync[mimeType]; } function checkNodeImageFormatSupport(mimeType) { const NODE_FORMAT_SUPPORT = ["image/png", "image/jpeg", "image/gif"]; const imageFormatsNode = globalThis.loaders?.imageFormatsNode || NODE_FORMAT_SUPPORT; const parseImageNode2 = globalThis.loaders?.parseImageNode; return Boolean(parseImageNode2) && imageFormatsNode.includes(mimeType); } function checkBrowserImageFormatSupport(mimeType) { switch (mimeType) { case "image/avif": case "image/webp": return testBrowserImageFormatSupport(mimeType); default: return true; } } function testBrowserImageFormatSupport(mimeType) { try { const element = document.createElement("canvas"); const dataURL = element.toDataURL(mimeType); return dataURL.indexOf(`data:${mimeType}`) === 0; } catch { return false; } } // ../../node_modules/@luma.gl/gltf/dist/gltf/gltf-instantiator.js var import_engine3 = __toESM(require_engine(), 1); // ../../node_modules/@luma.gl/gltf/dist/gltf/gltf-animator.js var import_core6 = __toESM(require_core2(), 1); var ATTRIBUTE_TYPE_TO_COMPONENTS = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16 }; var ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = { 5120: Int8Array, 5121: Uint8Array, 5122: Int16Array, 5123: Uint16Array, 5125: Uint32Array, 5126: Float32Array }; var GLTFAnimation = class { name; startTime = 0; playing = true; speed = 1; channels = []; constructor(props) { Object.assign(this, props); } animate(timeMs) { if (!this.playing) { return; } const absTime = timeMs / 1e3; const time = (absTime - this.startTime) * this.speed; this.channels.forEach(({ sampler, target, path }) => { interpolate(time, sampler, target, path); applyTranslationRotationScale(target, target._node); }); } }; var GLTFAnimator = class { animations; constructor(gltf) { this.animations = gltf.animations.map((animation, index) => { const name12 = animation.name || `Animation-${index}`; const samplers = animation.samplers.map(({ input, interpolation = "LINEAR", output }) => ({ input: accessorToJsArray(gltf.accessors[input]), interpolation, output: accessorToJsArray(gltf.accessors[output]) })); const channels = animation.channels.map(({ sampler, target }) => ({ sampler: samplers[sampler], target: gltf.nodes[target.node], path: target.path })); return new GLTFAnimation({ name: name12, channels }); }); } animate(time) { this.setTime(time); } setTime(time) { this.animations.forEach((animation) => animation.animate(time)); } getAnimations() { return this.animations; } }; function accessorToJsArray(accessor) { if (!accessor._animation) { const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY[accessor.componentType]; const components = ATTRIBUTE_TYPE_TO_COMPONENTS[accessor.type]; const length4 = components * accessor.count; const { buffer, byteOffset } = accessor.bufferView.data; const array = new ArrayType(buffer, byteOffset + (accessor.byteOffset || 0), length4); if (components === 1) { accessor._animation = Array.from(array); } else { const slicedArray = []; for (let i2 = 0; i2 < array.length; i2 += components) { slicedArray.push(Array.from(array.slice(i2, i2 + components))); } accessor._animation = slicedArray; } } return accessor._animation; } var helperMatrix = new Matrix4(); function applyTranslationRotationScale(gltfNode, node) { node.matrix.identity(); if (gltfNode.translation) { node.matrix.translate(gltfNode.translation); } if (gltfNode.rotation) { const rotationMatrix = helperMatrix.fromQuaternion(gltfNode.rotation); node.matrix.multiplyRight(rotationMatrix); } if (gltfNode.scale) { node.matrix.scale(gltfNode.scale); } } var quaternion = new Quaternion(); function linearInterpolate(target, path, start, stop, ratio) { if (path === "rotation") { quaternion.slerp({ start, target: stop, ratio }); for (let i2 = 0; i2 < quaternion.length; i2++) { target[path][i2] = quaternion[i2]; } } else { for (let i2 = 0; i2 < start.length; i2++) { target[path][i2] = ratio * stop[i2] + (1 - ratio) * start[i2]; } } } function cubicsplineInterpolate(target, path, { p0, outTangent0, inTangent1, p1, tDiff, ratio: t2 }) { for (let i2 = 0; i2 < target[path].length; i2++) { const m0 = outTangent0[i2] * tDiff; const m1 = inTangent1[i2] * tDiff; target[path][i2] = (2 * Math.pow(t2, 3) - 3 * Math.pow(t2, 2) + 1) * p0[i2] + (Math.pow(t2, 3) - 2 * Math.pow(t2, 2) + t2) * m0 + (-2 * Math.pow(t2, 3) + 3 * Math.pow(t2, 2)) * p1[i2] + (Math.pow(t2, 3) - Math.pow(t2, 2)) * m1; } } function stepInterpolate(target, path, value) { for (let i2 = 0; i2 < value.length; i2++) { target[path][i2] = value[i2]; } } function interpolate(time, { input, interpolation, output }, target, path) { const maxTime = input[input.length - 1]; const animationTime = time % maxTime; const nextIndex = input.findIndex((t2) => t2 >= animationTime); const previousIndex = Math.max(0, nextIndex - 1); if (!Array.isArray(target[path])) { switch (path) { case "translation": target[path] = [0, 0, 0]; break; case "rotation": target[path] = [0, 0, 0, 1]; break; case "scale": target[path] = [1, 1, 1]; break; default: import_core6.log.warn(`Bad animation path ${path}`)(); } } (0, import_core6.assert)(target[path].length === output[previousIndex].length); const previousTime = input[previousIndex]; const nextTime = input[nextIndex]; switch (interpolation) { case "STEP": stepInterpolate(target, path, output[previousIndex]); break; case "LINEAR": if (nextTime > previousTime) { const ratio = (animationTime - previousTime) / (nextTime - previousTime); linearInterpolate(target, path, output[previousIndex], output[nextIndex], ratio); } break; case "CUBICSPLINE": if (nextTime > previousTime) { const ratio = (animationTime - previousTime) / (nextTime - previousTime); const tDiff = nextTime - previousTime; const p0 = output[3 * previousIndex + 1]; const outTangent0 = output[3 * previousIndex + 2]; const inTangent1 = output[3 * nextIndex + 0]; const p1 = output[3 * nextIndex + 1]; cubicsplineInterpolate(target, path, { p0, outTangent0, inTangent1, p1, tDiff, ratio }); } break; default: import_core6.log.warn(`Interpolation ${interpolation} not supported`)(); break; } } // ../../node_modules/@luma.gl/gltf/dist/gltf/create-gltf-model.js var import_core8 = __toESM(require_core2(), 1); var import_engine2 = __toESM(require_engine(), 1); var vs2 = ` #pragma vscode_glsllint_stage: vert #if (__VERSION__ < 300) #define _attr attribute #else #define _attr in #endif // _attr vec4 POSITION; _attr vec4 positions; #ifdef HAS_NORMALS // _attr vec4 NORMAL; _attr vec4 normals; #endif #ifdef HAS_TANGENTS _attr vec4 TANGENT; #endif #ifdef HAS_UV // _attr vec2 TEXCOORD_0; _attr vec2 texCoords; #endif void main(void) { vec4 _NORMAL = vec4(0.); vec4 _TANGENT = vec4(0.); vec2 _TEXCOORD_0 = vec2(0.); #ifdef HAS_NORMALS _NORMAL = normals; #endif #ifdef HAS_TANGENTS _TANGENT = TANGENT; #endif #ifdef HAS_UV _TEXCOORD_0 = texCoords; #endif pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0); gl_Position = u_MVPMatrix * positions; } `; var fs2 = ` #pragma vscode_glsllint_stage: frag #if (__VERSION__ < 300) #define fragmentColor gl_FragColor #else out vec4 fragmentColor; #endif void main(void) { vec3 pos = pbr_vPosition; fragmentColor = pbr_filterColor(vec4(1.0)); } `; function createGLTFModel(device, options) { const { id, geometry, material, vertexCount, materialOptions, modelOptions } = options; const parsedMaterial = parsePBRMaterial(device, material, geometry.attributes, materialOptions); import_core8.log.info(4, "createGLTFModel defines: ", parsedMaterial.defines)(); const managedResources = []; const parameters = { depthWriteEnabled: true, depthCompare: "less", depthFormat: "depth24plus", cullMode: "back" }; const modelProps = { id, geometry, topology: geometry.topology, vertexCount, modules: [pbr], vs: addVersionToShader(device, vs2), fs: addVersionToShader(device, fs2), ...modelOptions, bindings: { ...parsedMaterial.bindings, ...modelOptions.bindings }, defines: { ...parsedMaterial.defines, ...modelOptions.defines }, parameters: { ...parameters, ...parsedMaterial.parameters, ...modelOptions.parameters }, uniforms: { ...parsedMaterial.uniforms, ...modelOptions.uniforms } }; const model = new import_engine2.Model(device, modelProps); return new import_engine2.ModelNode({ managedResources, model }); } function addVersionToShader(device, source) { return `#version 300 es ${source}`; } // ../../node_modules/@luma.gl/gltf/dist/gltf/gltf-instantiator.js var DEFAULT_OPTIONS = { modelOptions: {}, pbrDebug: false, imageBasedLightingEnvironment: null, lights: true, useTangents: false }; var GLTFInstantiator = class { device; options; gltf; constructor(device, options = {}) { this.device = device; this.options = { ...DEFAULT_OPTIONS, ...options }; } instantiate(gltf) { this.gltf = gltf; const scenes = (gltf.scenes || []).map((scene) => this.createScene(scene)); return scenes; } createAnimator() { if (Array.isArray(this.gltf.animations)) { return new GLTFAnimator(this.gltf); } return null; } createScene(gltfScene) { const gltfNodes = gltfScene.nodes || []; const nodes = gltfNodes.map((node) => this.createNode(node)); const scene = new import_engine3.GroupNode({ id: gltfScene.name || gltfScene.id, children: nodes }); return scene; } createNode(gltfNode) { if (!gltfNode._node) { const gltfChildren = gltfNode.children || []; const children = gltfChildren.map((child) => this.createNode(child)); if (gltfNode.mesh) { children.push(this.createMesh(gltfNode.mesh)); } const node = new import_engine3.GroupNode({ id: gltfNode.name || gltfNode.id, children }); if (gltfNode.matrix) { node.setMatrix(gltfNode.matrix); } else { node.matrix.identity(); if (gltfNode.translation) { node.matrix.translate(gltfNode.translation); } if (gltfNode.rotation) { const rotationMatrix = new Matrix4().fromQuaternion(gltfNode.rotation); node.matrix.multiplyRight(rotationMatrix); } if (gltfNode.scale) { node.matrix.scale(gltfNode.scale); } } gltfNode._node = node; } return gltfNode._node; } createMesh(gltfMesh) { if (!gltfMesh._mesh) { const gltfPrimitives = gltfMesh.primitives || []; const primitives = gltfPrimitives.map((gltfPrimitive, i2) => this.createPrimitive(gltfPrimitive, i2, gltfMesh)); const mesh = new import_engine3.GroupNode({ id: gltfMesh.name || gltfMesh.id, children: primitives }); gltfMesh._mesh = mesh; } return gltfMesh._mesh; } createPrimitive(gltfPrimitive, i2, gltfMesh) { const id = gltfPrimitive.name || `${gltfMesh.name || gltfMesh.id}-primitive-${i2}`; const topology = convertGLDrawModeToTopology(gltfPrimitive.mode || 4); const vertexCount = gltfPrimitive.indices ? gltfPrimitive.indices.count : this.getVertexCount(gltfPrimitive.attributes); const modelNode = createGLTFModel(this.device, { id, geometry: this.createGeometry(id, gltfPrimitive, topology), material: gltfPrimitive.material, materialOptions: this.options, modelOptions: this.options.modelOptions, vertexCount }); modelNode.bounds = [ gltfPrimitive.attributes.POSITION.min, gltfPrimitive.attributes.POSITION.max ]; return modelNode; } getVertexCount(attributes) { throw new Error("getVertexCount not implemented"); } createGeometry(id, gltfPrimitive, topology) { const attributes = {}; for (const [attributeName, attribute] of Object.entries(gltfPrimitive.attributes)) { const { components, size, value } = attribute; attributes[attributeName] = { size: size ?? components, value }; } return new import_engine3.Geometry({ id, topology, indices: gltfPrimitive.indices.value, attributes }); } createBuffer(attribute, usage) { if (!attribute.bufferView) { attribute.bufferView = {}; } const { bufferView } = attribute; if (!bufferView.lumaBuffers) { bufferView.lumaBuffers = {}; } if (!bufferView.lumaBuffers[usage]) { bufferView.lumaBuffers[usage] = this.device.createBuffer({ id: `from-${bufferView.id}`, data: bufferView.data || attribute.value }); } return bufferView.lumaBuffers[usage]; } createSampler(gltfSampler) { return gltfSampler; } needsPOT() { return false; } }; var GLEnum2; (function(GLEnum3) { GLEnum3[GLEnum3["POINTS"] = 0] = "POINTS"; GLEnum3[GLEnum3["LINES"] = 1] = "LINES"; GLEnum3[GLEnum3["LINE_LOOP"] = 2] = "LINE_LOOP"; GLEnum3[GLEnum3["LINE_STRIP"] = 3] = "LINE_STRIP"; GLEnum3[GLEnum3["TRIANGLES"] = 4] = "TRIANGLES"; GLEnum3[GLEnum3["TRIANGLE_STRIP"] = 5] = "TRIANGLE_STRIP"; GLEnum3[GLEnum3["TRIANGLE_FAN"] = 6] = "TRIANGLE_FAN"; })(GLEnum2 || (GLEnum2 = {})); function convertGLDrawModeToTopology(drawMode) { switch (drawMode) { case GLEnum2.POINTS: return "point-list"; case GLEnum2.LINES: return "line-list"; case GLEnum2.LINE_STRIP: return "line-strip"; case GLEnum2.LINE_LOOP: return "line-loop-webgl"; case GLEnum2.TRIANGLES: return "triangle-list"; case GLEnum2.TRIANGLE_STRIP: return "triangle-strip"; case GLEnum2.TRIANGLE_FAN: return "triangle-fan-webgl"; default: throw new Error(drawMode); } } // ../../node_modules/@luma.gl/gltf/dist/gltf/create-gltf-objects.js function createScenegraphsFromGLTF(device, gltf, options) { const instantiator = new GLTFInstantiator(device, options); const scenes = instantiator.instantiate(gltf); const animator = instantiator.createAnimator(); return { scenes, animator }; } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_mesh_features.js var EXT_mesh_features_exports = {}; __export(EXT_mesh_features_exports, { decode: () => decode, name: () => name }); // ../../node_modules/@loaders.gl/gltf/dist/lib/utils/assert.js function assert5(condition, message) { if (!condition) { throw new Error(message || "assert failed: gltf"); } } // ../../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/gltf-constants.js var COMPONENTS = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16 }; var BYTES = { 5120: 1, 5121: 1, 5122: 2, 5123: 2, 5125: 4, 5126: 4 }; // ../../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/gltf-utils.js var TYPES = ["SCALAR", "VEC2", "VEC3", "VEC4"]; var ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT = [ [Int8Array, 5120], [Uint8Array, 5121], [Int16Array, 5122], [Uint16Array, 5123], [Uint32Array, 5125], [Float32Array, 5126], [Float64Array, 5130] ]; var ARRAY_TO_COMPONENT_TYPE = new Map(ARRAY_CONSTRUCTOR_TO_WEBGL_CONSTANT); var ATTRIBUTE_TYPE_TO_COMPONENTS2 = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16 }; var ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = { 5120: 1, 5121: 1, 5122: 2, 5123: 2, 5125: 4, 5126: 4 }; var ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2 = { 5120: Int8Array, 5121: Uint8Array, 5122: Int16Array, 5123: Uint16Array, 5125: Uint32Array, 5126: Float32Array }; function getAccessorTypeFromSize(size) { const type = TYPES[size - 1]; return type || TYPES[0]; } function getComponentTypeFromArray(typedArray) { const componentType = ARRAY_TO_COMPONENT_TYPE.get(typedArray.constructor); if (!componentType) { throw new Error("Illegal typed array"); } return componentType; } function getAccessorArrayTypeAndLength(accessor, bufferView) { const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY2[accessor.componentType]; const components = ATTRIBUTE_TYPE_TO_COMPONENTS2[accessor.type]; const bytesPerComponent = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE[accessor.componentType]; const length4 = accessor.count * components; const byteLength = accessor.count * components * bytesPerComponent; assert5(byteLength >= 0 && byteLength <= bufferView.byteLength); const componentByteSize = BYTES[accessor.componentType]; const numberOfComponentsInElement = COMPONENTS[accessor.type]; return { ArrayType, length: length4, byteLength, componentByteSize, numberOfComponentsInElement }; } // ../../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/get-typed-array.js function getTypedArrayForBufferView(json, buffers, bufferViewIndex) { const bufferView = json.bufferViews[bufferViewIndex]; assert5(bufferView); const bufferIndex = bufferView.buffer; const binChunk = buffers[bufferIndex]; assert5(binChunk); const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset; return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength); } function getTypedArrayForAccessor(json, buffers, accessor) { const gltfAccessor = typeof accessor === "number" ? json.accessors?.[accessor] : accessor; if (!gltfAccessor) { throw new Error(`No gltf accessor ${JSON.stringify(accessor)}`); } const bufferView = json.bufferViews?.[gltfAccessor.bufferView || 0]; if (!bufferView) { throw new Error(`No gltf buffer view for accessor ${bufferView}`); } const { arrayBuffer, byteOffset: bufferByteOffset } = buffers[bufferView.buffer]; const byteOffset = (bufferByteOffset || 0) + (gltfAccessor.byteOffset || 0) + (bufferView.byteOffset || 0); const { ArrayType, length: length4, componentByteSize, numberOfComponentsInElement } = getAccessorArrayTypeAndLength(gltfAccessor, bufferView); const elementByteSize = componentByteSize * numberOfComponentsInElement; const elementAddressScale = bufferView.byteStride || elementByteSize; if (typeof bufferView.byteStride === "undefined" || bufferView.byteStride === elementByteSize) { const result2 = new ArrayType(arrayBuffer, byteOffset, length4); return result2; } const result = new ArrayType(length4); for (let i2 = 0; i2 < gltfAccessor.count; i2++) { const values = new ArrayType(arrayBuffer, byteOffset + i2 * elementAddressScale, numberOfComponentsInElement); result.set(values, i2 * numberOfComponentsInElement); } return result; } // ../../node_modules/@loaders.gl/gltf/dist/lib/api/gltf-scenegraph.js function makeDefaultGLTFJson() { return { asset: { version: "2.0", generator: "loaders.gl" }, buffers: [], extensions: {}, extensionsRequired: [], extensionsUsed: [] }; } var GLTFScenegraph = class { gltf; sourceBuffers; byteLength; constructor(gltf) { this.gltf = { json: gltf?.json || makeDefaultGLTFJson(), buffers: gltf?.buffers || [], images: gltf?.images || [] }; this.sourceBuffers = []; this.byteLength = 0; if (this.gltf.buffers && this.gltf.buffers[0]) { this.byteLength = this.gltf.buffers[0].byteLength; this.sourceBuffers = [this.gltf.buffers[0]]; } } get json() { return this.gltf.json; } getApplicationData(key) { const data = this.json[key]; return data; } getExtraData(key) { const extras = this.json.extras || {}; return extras[key]; } hasExtension(extensionName) { const isUsedExtension = this.getUsedExtensions().find((name12) => name12 === extensionName); const isRequiredExtension = this.getRequiredExtensions().find((name12) => name12 === extensionName); return typeof isUsedExtension === "string" || typeof isRequiredExtension === "string"; } getExtension(extensionName) { const isExtension = this.getUsedExtensions().find((name12) => name12 === extensionName); const extensions = this.json.extensions || {}; return isExtension ? extensions[extensionName] : null; } getRequiredExtension(extensionName) { const isRequired = this.getRequiredExtensions().find((name12) => name12 === extensionName); return isRequired ? this.getExtension(extensionName) : null; } getRequiredExtensions() { return this.json.extensionsRequired || []; } getUsedExtensions() { return this.json.extensionsUsed || []; } getRemovedExtensions() { return this.json.extensionsRemoved || []; } getObjectExtension(object, extensionName) { const extensions = object.extensions || {}; return extensions[extensionName]; } getScene(index) { return this.getObject("scenes", index); } getNode(index) { return this.getObject("nodes", index); } getSkin(index) { return this.getObject("skins", index); } getMesh(index) { return this.getObject("meshes", index); } getMaterial(index) { return this.getObject("materials", index); } getAccessor(index) { return this.getObject("accessors", index); } getTexture(index) { return this.getObject("textures", index); } getSampler(index) { return this.getObject("samplers", index); } getImage(index) { return this.getObject("images", index); } getBufferView(index) { return this.getObject("bufferViews", index); } getBuffer(index) { return this.getObject("buffers", index); } getObject(array, index) { if (typeof index === "object") { return index; } const object = this.json[array] && this.json[array][index]; if (!object) { throw new Error(`glTF file error: Could not find ${array}[${index}]`); } return object; } getTypedArrayForBufferView(bufferView) { bufferView = this.getBufferView(bufferView); const bufferIndex = bufferView.buffer; const binChunk = this.gltf.buffers[bufferIndex]; assert5(binChunk); const byteOffset = (bufferView.byteOffset || 0) + binChunk.byteOffset; return new Uint8Array(binChunk.arrayBuffer, byteOffset, bufferView.byteLength); } getTypedArrayForAccessor(accessor) { const gltfAccessor = this.getAccessor(accessor); return getTypedArrayForAccessor(this.gltf.json, this.gltf.buffers, gltfAccessor); } getTypedArrayForImageData(image) { image = this.getAccessor(image); const bufferView = this.getBufferView(image.bufferView); const buffer = this.getBuffer(bufferView.buffer); const arrayBuffer = buffer.data; const byteOffset = bufferView.byteOffset || 0; return new Uint8Array(arrayBuffer, byteOffset, bufferView.byteLength); } addApplicationData(key, data) { this.json[key] = data; return this; } addExtraData(key, data) { this.json.extras = this.json.extras || {}; this.json.extras[key] = data; return this; } addObjectExtension(object, extensionName, data) { object.extensions = object.extensions || {}; object.extensions[extensionName] = data; this.registerUsedExtension(extensionName); return this; } setObjectExtension(object, extensionName, data) { const extensions = object.extensions || {}; extensions[extensionName] = data; } removeObjectExtension(object, extensionName) { const extensions = object?.extensions || {}; if (extensions[extensionName]) { this.json.extensionsRemoved = this.json.extensionsRemoved || []; const extensionsRemoved = this.json.extensionsRemoved; if (!extensionsRemoved.includes(extensionName)) { extensionsRemoved.push(extensionName); } } delete extensions[extensionName]; } addExtension(extensionName, extensionData = {}) { assert5(extensionData); this.json.extensions = this.json.extensions || {}; this.json.extensions[extensionName] = extensionData; this.registerUsedExtension(extensionName); return extensionData; } addRequiredExtension(extensionName, extensionData = {}) { assert5(extensionData); this.addExtension(extensionName, extensionData); this.registerRequiredExtension(extensionName); return extensionData; } registerUsedExtension(extensionName) { this.json.extensionsUsed = this.json.extensionsUsed || []; if (!this.json.extensionsUsed.find((ext) => ext === extensionName)) { this.json.extensionsUsed.push(extensionName); } } registerRequiredExtension(extensionName) { this.registerUsedExtension(extensionName); this.json.extensionsRequired = this.json.extensionsRequired || []; if (!this.json.extensionsRequired.find((ext) => ext === extensionName)) { this.json.extensionsRequired.push(extensionName); } } removeExtension(extensionName) { if (this.json.extensions?.[extensionName]) { this.json.extensionsRemoved = this.json.extensionsRemoved || []; const extensionsRemoved = this.json.extensionsRemoved; if (!extensionsRemoved.includes(extensionName)) { extensionsRemoved.push(extensionName); } } if (this.json.extensions) { delete this.json.extensions[extensionName]; } if (this.json.extensionsRequired) { this._removeStringFromArray(this.json.extensionsRequired, extensionName); } if (this.json.extensionsUsed) { this._removeStringFromArray(this.json.extensionsUsed, extensionName); } } setDefaultScene(sceneIndex) { this.json.scene = sceneIndex; } addScene(scene) { const { nodeIndices } = scene; this.json.scenes = this.json.scenes || []; this.json.scenes.push({ nodes: nodeIndices }); return this.json.scenes.length - 1; } addNode(node) { const { meshIndex, matrix } = node; this.json.nodes = this.json.nodes || []; const nodeData = { mesh: meshIndex }; if (matrix) { nodeData.matrix = matrix; } this.json.nodes.push(nodeData); return this.json.nodes.length - 1; } addMesh(mesh) { const { attributes, indices, material, mode = 4 } = mesh; const accessors = this._addAttributes(attributes); const glTFMesh = { primitives: [ { attributes: accessors, mode } ] }; if (indices) { const indicesAccessor = this._addIndices(indices); glTFMesh.primitives[0].indices = indicesAccessor; } if (Number.isFinite(material)) { glTFMesh.primitives[0].material = material; } this.json.meshes = this.json.meshes || []; this.json.meshes.push(glTFMesh); return this.json.meshes.length - 1; } addPointCloud(attributes) { const accessorIndices = this._addAttributes(attributes); const glTFMesh = { primitives: [ { attributes: accessorIndices, mode: 0 } ] }; this.json.meshes = this.json.meshes || []; this.json.meshes.push(glTFMesh); return this.json.meshes.length - 1; } addImage(imageData, mimeTypeOpt) { const metadata = getBinaryImageMetadata(imageData); const mimeType = mimeTypeOpt || metadata?.mimeType; const bufferViewIndex = this.addBufferView(imageData); const glTFImage = { bufferView: bufferViewIndex, mimeType }; this.json.images = this.json.images || []; this.json.images.push(glTFImage); return this.json.images.length - 1; } addBufferView(buffer, bufferIndex = 0, byteOffset = this.byteLength) { const byteLength = buffer.byteLength; assert5(Number.isFinite(byteLength)); this.sourceBuffers = this.sourceBuffers || []; this.sourceBuffers.push(buffer); const glTFBufferView = { buffer: bufferIndex, byteOffset, byteLength }; this.byteLength += padToNBytes(byteLength, 4); this.json.bufferViews = this.json.bufferViews || []; this.json.bufferViews.push(glTFBufferView); return this.json.bufferViews.length - 1; } addAccessor(bufferViewIndex, accessor) { const glTFAccessor = { bufferView: bufferViewIndex, type: getAccessorTypeFromSize(accessor.size), componentType: accessor.componentType, count: accessor.count, max: accessor.max, min: accessor.min }; this.json.accessors = this.json.accessors || []; this.json.accessors.push(glTFAccessor); return this.json.accessors.length - 1; } addBinaryBuffer(sourceBuffer, accessor = { size: 3 }) { const bufferViewIndex = this.addBufferView(sourceBuffer); let minMax = { min: accessor.min, max: accessor.max }; if (!minMax.min || !minMax.max) { minMax = this._getAccessorMinMax(sourceBuffer, accessor.size); } const accessorDefaults = { size: accessor.size, componentType: getComponentTypeFromArray(sourceBuffer), count: Math.round(sourceBuffer.length / accessor.size), min: minMax.min, max: minMax.max }; return this.addAccessor(bufferViewIndex, Object.assign(accessorDefaults, accessor)); } addTexture(texture) { const { imageIndex } = texture; const glTFTexture = { source: imageIndex }; this.json.textures = this.json.textures || []; this.json.textures.push(glTFTexture); return this.json.textures.length - 1; } addMaterial(pbrMaterialInfo) { this.json.materials = this.json.materials || []; this.json.materials.push(pbrMaterialInfo); return this.json.materials.length - 1; } createBinaryChunk() { this.gltf.buffers = []; const totalByteLength = this.byteLength; const arrayBuffer = new ArrayBuffer(totalByteLength); const targetArray = new Uint8Array(arrayBuffer); let dstByteOffset = 0; for (const sourceBuffer of this.sourceBuffers || []) { dstByteOffset = copyToArray(sourceBuffer, targetArray, dstByteOffset); } if (this.json?.buffers?.[0]) { this.json.buffers[0].byteLength = totalByteLength; } else { this.json.buffers = [{ byteLength: totalByteLength }]; } this.gltf.binary = arrayBuffer; this.sourceBuffers = [arrayBuffer]; } _removeStringFromArray(array, string) { let found = true; while (found) { const index = array.indexOf(string); if (index > -1) { array.splice(index, 1); } else { found = false; } } } _addAttributes(attributes = {}) { const result = {}; for (const attributeKey in attributes) { const attributeData = attributes[attributeKey]; const attrName = this._getGltfAttributeName(attributeKey); const accessor = this.addBinaryBuffer(attributeData.value, attributeData); result[attrName] = accessor; } return result; } _addIndices(indices) { return this.addBinaryBuffer(indices, { size: 1 }); } _getGltfAttributeName(attributeName) { switch (attributeName.toLowerCase()) { case "position": case "positions": case "vertices": return "POSITION"; case "normal": case "normals": return "NORMAL"; case "color": case "colors": return "COLOR_0"; case "texcoord": case "texcoords": return "TEXCOORD_0"; default: return attributeName; } } _getAccessorMinMax(buffer, size) { const result = { min: null, max: null }; if (buffer.length < size) { return result; } result.min = []; result.max = []; const initValues = buffer.subarray(0, size); for (const value of initValues) { result.min.push(value); result.max.push(value); } for (let index = size; index < buffer.length; index += size) { for (let componentIndex = 0; componentIndex < size; componentIndex++) { result.min[0 + componentIndex] = Math.min( result.min[0 + componentIndex], buffer[index + componentIndex] ); result.max[0 + componentIndex] = Math.max( result.max[0 + componentIndex], buffer[index + componentIndex] ); } } return result; } }; // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/utils/3d-tiles-utils.js function emod(n2) { return (n2 % 1 + 1) % 1; } var ATTRIBUTE_TYPE_TO_COMPONENTS3 = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16, BOOLEAN: 1, STRING: 1, ENUM: 1 }; var ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY3 = { INT8: Int8Array, UINT8: Uint8Array, INT16: Int16Array, UINT16: Uint16Array, INT32: Int32Array, UINT32: Uint32Array, INT64: BigInt64Array, UINT64: BigUint64Array, FLOAT32: Float32Array, FLOAT64: Float64Array }; var ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2 = { INT8: 1, UINT8: 1, INT16: 2, UINT16: 2, INT32: 4, UINT32: 4, INT64: 8, UINT64: 8, FLOAT32: 4, FLOAT64: 8 }; function getArrayElementByteSize(attributeType, componentType) { return ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType] * ATTRIBUTE_TYPE_TO_COMPONENTS3[attributeType]; } function getOffsetsForProperty(scenegraph, bufferViewIndex, offsetType, numberOfElements) { if (offsetType !== "UINT8" && offsetType !== "UINT16" && offsetType !== "UINT32" && offsetType !== "UINT64") { return null; } const arrayOffsetsBytes = scenegraph.getTypedArrayForBufferView(bufferViewIndex); const arrayOffsets = convertRawBufferToMetadataArray( arrayOffsetsBytes, "SCALAR", offsetType, numberOfElements + 1 ); if (arrayOffsets instanceof BigInt64Array || arrayOffsets instanceof BigUint64Array) { return null; } return arrayOffsets; } function convertRawBufferToMetadataArray(data, attributeType, componentType, elementCount = 1) { const numberOfComponents = ATTRIBUTE_TYPE_TO_COMPONENTS3[attributeType]; const ArrayType = ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY3[componentType]; const size = ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE2[componentType]; const length4 = elementCount * numberOfComponents; const byteLength = length4 * size; let buffer = data.buffer; let offset = data.byteOffset; if (offset % size !== 0) { const bufferArray = new Uint8Array(buffer); buffer = bufferArray.slice(offset, offset + byteLength).buffer; offset = 0; } return new ArrayType(buffer, offset, length4); } function getPrimitiveTextureData(scenegraph, textureInfo, primitive) { const texCoordAccessorKey = `TEXCOORD_${textureInfo.texCoord || 0}`; const texCoordAccessorIndex = primitive.attributes[texCoordAccessorKey]; const textureCoordinates = scenegraph.getTypedArrayForAccessor(texCoordAccessorIndex); const json = scenegraph.gltf.json; const textureIndex = textureInfo.index; const imageIndex = json.textures?.[textureIndex]?.source; if (typeof imageIndex !== "undefined") { const mimeType = json.images?.[imageIndex]?.mimeType; const parsedImage = scenegraph.gltf.images?.[imageIndex]; if (parsedImage && typeof parsedImage.width !== "undefined") { const textureData = []; for (let index = 0; index < textureCoordinates.length; index += 2) { const value = getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, textureInfo.channels); textureData.push(value); } return textureData; } } return []; } function primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTable, primitive) { if (!propertyData?.length) { return; } const featureIndices = []; for (const texelData of propertyData) { let index = featureTable.findIndex((item) => item === texelData); if (index === -1) { index = featureTable.push(texelData) - 1; } featureIndices.push(index); } const typedArray = new Uint32Array(featureIndices); const bufferIndex = scenegraph.gltf.buffers.push({ arrayBuffer: typedArray.buffer, byteOffset: typedArray.byteOffset, byteLength: typedArray.byteLength }) - 1; const bufferViewIndex = scenegraph.addBufferView(typedArray, bufferIndex, 0); const accessorIndex = scenegraph.addAccessor(bufferViewIndex, { size: 1, componentType: getComponentTypeFromArray(typedArray), count: typedArray.length }); primitive.attributes[attributeName] = accessorIndex; } function getImageValueByCoordinates(parsedImage, mimeType, textureCoordinates, index, channels = [0]) { const CHANNELS_MAP = { r: { offset: 0, shift: 0 }, g: { offset: 1, shift: 8 }, b: { offset: 2, shift: 16 }, a: { offset: 3, shift: 24 } }; const u = textureCoordinates[index]; const v = textureCoordinates[index + 1]; let components = 1; if (mimeType && (mimeType.indexOf("image/jpeg") !== -1 || mimeType.indexOf("image/png") !== -1)) components = 4; const offset = coordinatesToOffset(u, v, parsedImage, components); let value = 0; for (const c of channels) { const map = typeof c === "number" ? Object.values(CHANNELS_MAP)[c] : CHANNELS_MAP[c]; const imageOffset = offset + map.offset; const imageData = getImageData(parsedImage); if (imageData.data.length <= imageOffset) { throw new Error(`${imageData.data.length} <= ${imageOffset}`); } const imageValue = imageData.data[imageOffset]; value |= imageValue << map.shift; } return value; } function coordinatesToOffset(u, v, parsedImage, componentsCount = 1) { const w = parsedImage.width; const iX = emod(u) * (w - 1); const indX = Math.round(iX); const h = parsedImage.height; const iY = emod(v) * (h - 1); const indY = Math.round(iY); const components = parsedImage.components ? parsedImage.components : componentsCount; const offset = (indY * w + indX) * components; return offset; } function parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, valueSize) { const attributeValueArray = []; for (let index = 0; index < numberOfElements; index++) { const arrayOffset = arrayOffsets[index]; const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index]; if (arrayByteSize + arrayOffset > valuesDataBytesLength) { break; } const typedArrayOffset = arrayOffset / valueSize; const elementCount = arrayByteSize / valueSize; attributeValueArray.push(valuesData.slice(typedArrayOffset, typedArrayOffset + elementCount)); } return attributeValueArray; } function parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount) { const attributeValueArray = []; for (let index = 0; index < numberOfElements; index++) { const elementOffset = index * arrayCount; attributeValueArray.push(valuesData.slice(elementOffset, elementOffset + arrayCount)); } return attributeValueArray; } function getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets) { if (arrayOffsets) { throw new Error("Not implemented - arrayOffsets for strings is specified"); } if (stringOffsets) { const stringsArray = []; const textDecoder = new TextDecoder("utf8"); let stringOffset = 0; for (let index = 0; index < numberOfElements; index++) { const stringByteSize = stringOffsets[index + 1] - stringOffsets[index]; if (stringByteSize + stringOffset <= valuesDataBytes.length) { const stringData = valuesDataBytes.subarray(stringOffset, stringByteSize + stringOffset); const stringAttribute = textDecoder.decode(stringData); stringsArray.push(stringAttribute); stringOffset += stringByteSize; } } return stringsArray; } return []; } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_mesh_features.js var EXT_MESH_FEATURES_NAME = "EXT_mesh_features"; var name = EXT_MESH_FEATURES_NAME; async function decode(gltfData, options) { const scenegraph = new GLTFScenegraph(gltfData); decodeExtMeshFeatures(scenegraph, options); } function decodeExtMeshFeatures(scenegraph, options) { const json = scenegraph.gltf.json; if (!json.meshes) { return; } for (const mesh of json.meshes) { for (const primitive of mesh.primitives) { processMeshPrimitiveFeatures(scenegraph, primitive, options); } } } function processMeshPrimitiveFeatures(scenegraph, primitive, options) { if (!options?.gltf?.loadBuffers) { return; } const extension = primitive.extensions?.[EXT_MESH_FEATURES_NAME]; const featureIds = extension?.featureIds; if (!featureIds) { return; } for (const featureId of featureIds) { let featureIdData; if (typeof featureId.attribute !== "undefined") { const accessorKey = `_FEATURE_ID_${featureId.attribute}`; const accessorIndex = primitive.attributes[accessorKey]; featureIdData = scenegraph.getTypedArrayForAccessor(accessorIndex); } else if (typeof featureId.texture !== "undefined" && options?.gltf?.loadImages) { featureIdData = getPrimitiveTextureData(scenegraph, featureId.texture, primitive); } else { featureIdData = []; } featureId.data = featureIdData; } } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_structural_metadata.js var EXT_structural_metadata_exports = {}; __export(EXT_structural_metadata_exports, { decode: () => decode2, name: () => name2 }); var EXT_STRUCTURAL_METADATA_NAME = "EXT_structural_metadata"; var name2 = EXT_STRUCTURAL_METADATA_NAME; async function decode2(gltfData, options) { const scenegraph = new GLTFScenegraph(gltfData); decodeExtStructuralMetadata(scenegraph, options); } function decodeExtStructuralMetadata(scenegraph, options) { if (!options.gltf?.loadBuffers) { return; } const extension = scenegraph.getExtension(EXT_STRUCTURAL_METADATA_NAME); if (!extension) { return; } if (options.gltf?.loadImages) { decodePropertyTextures(scenegraph, extension); } decodePropertyTables(scenegraph, extension); } function decodePropertyTextures(scenegraph, extension) { const propertyTextures = extension.propertyTextures; const json = scenegraph.gltf.json; if (propertyTextures && json.meshes) { for (const mesh of json.meshes) { for (const primitive of mesh.primitives) { processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension); } } } } function decodePropertyTables(scenegraph, extension) { const schema = extension.schema; if (!schema) { return; } const schemaClasses = schema.classes; const propertyTables = extension.propertyTables; if (schemaClasses && propertyTables) { for (const schemaName in schemaClasses) { const propertyTable = findPropertyTableByClass(propertyTables, schemaName); if (propertyTable) { processPropertyTable(scenegraph, schema, propertyTable); } } } } function findPropertyTableByClass(propertyTables, schemaClassName) { for (const propertyTable of propertyTables) { if (propertyTable.class === schemaClassName) { return propertyTable; } } return null; } function processPrimitivePropertyTextures(scenegraph, propertyTextures, primitive, extension) { if (!propertyTextures) { return; } const primitiveExtension = primitive.extensions?.[EXT_STRUCTURAL_METADATA_NAME]; const primitivePropertyTextureIndices = primitiveExtension?.propertyTextures; if (!primitivePropertyTextureIndices) { return; } for (const primitivePropertyTextureIndex of primitivePropertyTextureIndices) { const propertyTexture = propertyTextures[primitivePropertyTextureIndex]; processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension); } } function processPrimitivePropertyTexture(scenegraph, propertyTexture, primitive, extension) { if (!propertyTexture.properties) { return; } if (!extension.dataAttributeNames) { extension.dataAttributeNames = []; } const className = propertyTexture.class; for (const propertyName in propertyTexture.properties) { const attributeName = `${className}_${propertyName}`; const textureInfoTopLevel = propertyTexture.properties?.[propertyName]; if (!textureInfoTopLevel) { continue; } if (!textureInfoTopLevel.data) { textureInfoTopLevel.data = []; } const featureTextureTable = textureInfoTopLevel.data; const propertyData = getPrimitiveTextureData(scenegraph, textureInfoTopLevel, primitive); if (propertyData === null) { continue; } primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTextureTable, primitive); textureInfoTopLevel.data = featureTextureTable; extension.dataAttributeNames.push(attributeName); } } function processPropertyTable(scenegraph, schema, propertyTable) { const schemaClass = schema.classes?.[propertyTable.class]; if (!schemaClass) { throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`); } const numberOfElements = propertyTable.count; for (const propertyName in schemaClass.properties) { const classProperty = schemaClass.properties[propertyName]; const propertyTableProperty = propertyTable.properties?.[propertyName]; if (propertyTableProperty) { const data = getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty); propertyTableProperty.data = data; } } } function getPropertyDataFromBinarySource(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty) { let data = []; const valuesBufferView = propertyTableProperty.values; const valuesDataBytes = scenegraph.getTypedArrayForBufferView(valuesBufferView); const arrayOffsets = getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements); const stringOffsets = getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements); switch (classProperty.type) { case "SCALAR": case "VEC2": case "VEC3": case "VEC4": case "MAT2": case "MAT3": case "MAT4": { data = getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets); break; } case "BOOLEAN": { throw new Error(`Not implemented - classProperty.type=${classProperty.type}`); } case "STRING": { data = getPropertyDataString(numberOfElements, valuesDataBytes, arrayOffsets, stringOffsets); break; } case "ENUM": { data = getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets); break; } default: throw new Error(`Unknown classProperty type ${classProperty.type}`); } return data; } function getArrayOffsetsForProperty(scenegraph, classProperty, propertyTableProperty, numberOfElements) { if (classProperty.array && typeof classProperty.count === "undefined" && typeof propertyTableProperty.arrayOffsets !== "undefined") { return getOffsetsForProperty(scenegraph, propertyTableProperty.arrayOffsets, propertyTableProperty.arrayOffsetType || "UINT32", numberOfElements); } return null; } function getStringOffsetsForProperty(scenegraph, propertyTableProperty, numberOfElements) { if (typeof propertyTableProperty.stringOffsets !== "undefined") { return getOffsetsForProperty(scenegraph, propertyTableProperty.stringOffsets, propertyTableProperty.stringOffsetType || "UINT32", numberOfElements); } return null; } function getPropertyDataNumeric(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) { const isArray2 = classProperty.array; const arrayCount = classProperty.count; const elementSize = getArrayElementByteSize(classProperty.type, classProperty.componentType); const elementCount = valuesDataBytes.byteLength / elementSize; let valuesData; if (classProperty.componentType) { valuesData = convertRawBufferToMetadataArray( valuesDataBytes, classProperty.type, classProperty.componentType, elementCount ); } else { valuesData = valuesDataBytes; } if (isArray2) { if (arrayOffsets) { return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize); } if (arrayCount) { return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount); } return []; } return valuesData; } function getPropertyDataENUM(schema, classProperty, numberOfElements, valuesDataBytes, arrayOffsets) { const enumType = classProperty.enumType; if (!enumType) { throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM"); } const enumEntry = schema.enums?.[enumType]; if (!enumEntry) { throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${enumType}`); } const enumValueType = enumEntry.valueType || "UINT16"; const elementSize = getArrayElementByteSize(classProperty.type, enumValueType); const elementCount = valuesDataBytes.byteLength / elementSize; let valuesData = convertRawBufferToMetadataArray(valuesDataBytes, classProperty.type, enumValueType, elementCount); if (!valuesData) { valuesData = valuesDataBytes; } if (classProperty.array) { if (arrayOffsets) { return parseVariableLengthArrayENUM({ valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength: valuesDataBytes.length, elementSize, enumEntry }); } const arrayCount = classProperty.count; if (arrayCount) { return parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry); } return []; } return getEnumsArray(valuesData, 0, numberOfElements, enumEntry); } function parseVariableLengthArrayENUM(params) { const { valuesData, numberOfElements, arrayOffsets, valuesDataBytesLength, elementSize, enumEntry } = params; const attributeValueArray = []; for (let index = 0; index < numberOfElements; index++) { const arrayOffset = arrayOffsets[index]; const arrayByteSize = arrayOffsets[index + 1] - arrayOffsets[index]; if (arrayByteSize + arrayOffset > valuesDataBytesLength) { break; } const typedArrayOffset = arrayOffset / elementSize; const elementCount = arrayByteSize / elementSize; const array = getEnumsArray(valuesData, typedArrayOffset, elementCount, enumEntry); attributeValueArray.push(array); } return attributeValueArray; } function parseFixedLengthArrayENUM(valuesData, numberOfElements, arrayCount, enumEntry) { const attributeValueArray = []; for (let index = 0; index < numberOfElements; index++) { const elementOffset = arrayCount * index; const array = getEnumsArray(valuesData, elementOffset, arrayCount, enumEntry); attributeValueArray.push(array); } return attributeValueArray; } function getEnumsArray(valuesData, offset, count, enumEntry) { const array = []; for (let i2 = 0; i2 < count; i2++) { if (valuesData instanceof BigInt64Array || valuesData instanceof BigUint64Array) { array.push(""); } else { const value = valuesData[offset + i2]; const enumObject = getEnumByValue(enumEntry, value); if (enumObject) { array.push(enumObject.name); } else { array.push(""); } } } return array; } function getEnumByValue(enumEntry, value) { for (const enumValue of enumEntry.values) { if (enumValue.value === value) { return enumValue; } } return null; } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/EXT_feature_metadata.js var EXT_feature_metadata_exports = {}; __export(EXT_feature_metadata_exports, { decode: () => decode3, name: () => name3 }); var EXT_FEATURE_METADATA_NAME = "EXT_feature_metadata"; var name3 = EXT_FEATURE_METADATA_NAME; async function decode3(gltfData, options) { const scenegraph = new GLTFScenegraph(gltfData); decodeExtFeatureMetadata(scenegraph, options); } function decodeExtFeatureMetadata(scenegraph, options) { if (!options.gltf?.loadBuffers) { return; } const extension = scenegraph.getExtension(EXT_FEATURE_METADATA_NAME); if (!extension) { return; } if (options.gltf?.loadImages) { decodePropertyTextures2(scenegraph, extension); } decodePropertyTables2(scenegraph, extension); } function decodePropertyTextures2(scenegraph, extension) { const schema = extension.schema; if (!schema) { return; } const schemaClasses = schema.classes; const { featureTextures } = extension; if (schemaClasses && featureTextures) { for (const schemaName in schemaClasses) { const schemaClass = schemaClasses[schemaName]; const featureTexture = findFeatureTextureByClass(featureTextures, schemaName); if (featureTexture) { handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass); } } } } function decodePropertyTables2(scenegraph, extension) { const schema = extension.schema; if (!schema) { return; } const schemaClasses = schema.classes; const propertyTables = extension.featureTables; if (schemaClasses && propertyTables) { for (const schemaName in schemaClasses) { const propertyTable = findPropertyTableByClass2(propertyTables, schemaName); if (propertyTable) { processPropertyTable2(scenegraph, schema, propertyTable); } } } } function findPropertyTableByClass2(propertyTables, schemaClassName) { for (const propertyTableName in propertyTables) { const propertyTable = propertyTables[propertyTableName]; if (propertyTable.class === schemaClassName) { return propertyTable; } } return null; } function findFeatureTextureByClass(featureTextures, schemaClassName) { for (const featureTexturesName in featureTextures) { const featureTable = featureTextures[featureTexturesName]; if (featureTable.class === schemaClassName) { return featureTable; } } return null; } function processPropertyTable2(scenegraph, schema, propertyTable) { if (!propertyTable.class) { return; } const schemaClass = schema.classes?.[propertyTable.class]; if (!schemaClass) { throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${propertyTable.class}`); } const numberOfElements = propertyTable.count; for (const propertyName in schemaClass.properties) { const classProperty = schemaClass.properties[propertyName]; const propertyTableProperty = propertyTable.properties?.[propertyName]; if (propertyTableProperty) { const data = getPropertyDataFromBinarySource2(scenegraph, schema, classProperty, numberOfElements, propertyTableProperty); propertyTableProperty.data = data; } } } function handleFeatureTextureProperties(scenegraph, featureTexture, schemaClass) { const attributeName = featureTexture.class; for (const propertyName in schemaClass.properties) { const featureTextureProperty = featureTexture?.properties?.[propertyName]; if (featureTextureProperty) { const data = getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName); featureTextureProperty.data = data; } } } function getPropertyDataFromBinarySource2(scenegraph, schema, classProperty, numberOfFeatures, featureTableProperty) { let data = []; const bufferView = featureTableProperty.bufferView; const dataArray = scenegraph.getTypedArrayForBufferView(bufferView); const arrayOffsets = getArrayOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures); const stringOffsets = getStringOffsetsForProperty2(scenegraph, classProperty, featureTableProperty, numberOfFeatures); if (classProperty.type === "STRING" || classProperty.componentType === "STRING") { data = getPropertyDataString(numberOfFeatures, dataArray, arrayOffsets, stringOffsets); } else if (isNumericProperty(classProperty)) { data = getPropertyDataNumeric2(classProperty, numberOfFeatures, dataArray, arrayOffsets); } return data; } function getArrayOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) { if (classProperty.type === "ARRAY" && typeof classProperty.componentCount === "undefined" && typeof propertyTableProperty.arrayOffsetBufferView !== "undefined") { return getOffsetsForProperty( scenegraph, propertyTableProperty.arrayOffsetBufferView, propertyTableProperty.offsetType || "UINT32", numberOfElements ); } return null; } function getStringOffsetsForProperty2(scenegraph, classProperty, propertyTableProperty, numberOfElements) { if (typeof propertyTableProperty.stringOffsetBufferView !== "undefined") { return getOffsetsForProperty( scenegraph, propertyTableProperty.stringOffsetBufferView, propertyTableProperty.offsetType || "UINT32", numberOfElements ); } return null; } function isNumericProperty(schemaProperty) { const types = [ "UINT8", "INT16", "UINT16", "INT32", "UINT32", "INT64", "UINT64", "FLOAT32", "FLOAT64" ]; return types.includes(schemaProperty.type) || typeof schemaProperty.componentType !== "undefined" && types.includes(schemaProperty.componentType); } function getPropertyDataNumeric2(classProperty, numberOfElements, valuesDataBytes, arrayOffsets) { const isArray2 = classProperty.type === "ARRAY"; const arrayCount = classProperty.componentCount; const attributeType = "SCALAR"; const componentType = classProperty.componentType || classProperty.type; const elementSize = getArrayElementByteSize(attributeType, componentType); const elementCount = valuesDataBytes.byteLength / elementSize; const valuesData = convertRawBufferToMetadataArray(valuesDataBytes, attributeType, componentType, elementCount); if (isArray2) { if (arrayOffsets) { return parseVariableLengthArrayNumeric(valuesData, numberOfElements, arrayOffsets, valuesDataBytes.length, elementSize); } if (arrayCount) { return parseFixedLengthArrayNumeric(valuesData, numberOfElements, arrayCount); } return []; } return valuesData; } function getPropertyDataFromTexture(scenegraph, featureTextureProperty, attributeName) { const json = scenegraph.gltf.json; if (!json.meshes) { return []; } const featureTextureTable = []; for (const mesh of json.meshes) { for (const primitive of mesh.primitives) { processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive); } } return featureTextureTable; } function processPrimitiveTextures(scenegraph, attributeName, featureTextureProperty, featureTextureTable, primitive) { const textureInfoTopLevel = { channels: featureTextureProperty.channels, ...featureTextureProperty.texture }; const propertyData = getPrimitiveTextureData(scenegraph, textureInfoTopLevel, primitive); if (!propertyData) { return; } primitivePropertyDataToAttributes(scenegraph, attributeName, propertyData, featureTextureTable, primitive); } // ../../node_modules/@loaders.gl/gltf/dist/lib/utils/version.js var VERSION4 = true ? "4.2.0-beta.2" : "latest"; // ../../node_modules/@loaders.gl/gltf/dist/lib/parsers/parse-glb.js var LITTLE_ENDIAN2 = true; var MAGIC_glTF = 1735152710; var GLB_FILE_HEADER_SIZE = 12; var GLB_CHUNK_HEADER_SIZE = 8; var GLB_CHUNK_TYPE_JSON = 1313821514; var GLB_CHUNK_TYPE_BIN = 5130562; var GLB_V1_CONTENT_FORMAT_JSON = 0; var GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED = 0; var GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED = 1; function getMagicString2(dataView, byteOffset = 0) { return `${String.fromCharCode(dataView.getUint8(byteOffset + 0))}${String.fromCharCode(dataView.getUint8(byteOffset + 1))}${String.fromCharCode(dataView.getUint8(byteOffset + 2))}${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`; } function isGLB(arrayBuffer, byteOffset = 0, options = {}) { const dataView = new DataView(arrayBuffer); const { magic = MAGIC_glTF } = options; const magic1 = dataView.getUint32(byteOffset, false); return magic1 === magic || magic1 === MAGIC_glTF; } function parseGLBSync(glb, arrayBuffer, byteOffset = 0, options = {}) { const dataView = new DataView(arrayBuffer); const type = getMagicString2(dataView, byteOffset + 0); const version = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2); const byteLength = dataView.getUint32(byteOffset + 8, LITTLE_ENDIAN2); Object.assign(glb, { header: { byteOffset, byteLength, hasBinChunk: false }, type, version, json: {}, binChunks: [] }); byteOffset += GLB_FILE_HEADER_SIZE; switch (glb.version) { case 1: return parseGLBV1(glb, dataView, byteOffset); case 2: return parseGLBV2(glb, dataView, byteOffset, options = {}); default: throw new Error(`Invalid GLB version ${glb.version}. Only supports version 1 and 2.`); } } function parseGLBV1(glb, dataView, byteOffset) { assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE); const contentLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2); const contentFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2); byteOffset += GLB_CHUNK_HEADER_SIZE; assert2(contentFormat === GLB_V1_CONTENT_FORMAT_JSON); parseJSONChunk(glb, dataView, byteOffset, contentLength); byteOffset += contentLength; byteOffset += parseBINChunk(glb, dataView, byteOffset, glb.header.byteLength); return byteOffset; } function parseGLBV2(glb, dataView, byteOffset, options) { assert2(glb.header.byteLength > GLB_FILE_HEADER_SIZE + GLB_CHUNK_HEADER_SIZE); parseGLBChunksSync(glb, dataView, byteOffset, options); return byteOffset + glb.header.byteLength; } function parseGLBChunksSync(glb, dataView, byteOffset, options) { while (byteOffset + 8 <= glb.header.byteLength) { const chunkLength = dataView.getUint32(byteOffset + 0, LITTLE_ENDIAN2); const chunkFormat = dataView.getUint32(byteOffset + 4, LITTLE_ENDIAN2); byteOffset += GLB_CHUNK_HEADER_SIZE; switch (chunkFormat) { case GLB_CHUNK_TYPE_JSON: parseJSONChunk(glb, dataView, byteOffset, chunkLength); break; case GLB_CHUNK_TYPE_BIN: parseBINChunk(glb, dataView, byteOffset, chunkLength); break; case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED: if (!options.strict) { parseJSONChunk(glb, dataView, byteOffset, chunkLength); } break; case GLB_CHUNK_TYPE_BIX_XVIZ_DEPRECATED: if (!options.strict) { parseBINChunk(glb, dataView, byteOffset, chunkLength); } break; default: break; } byteOffset += padToNBytes(chunkLength, 4); } return byteOffset; } function parseJSONChunk(glb, dataView, byteOffset, chunkLength) { const jsonChunk = new Uint8Array(dataView.buffer, byteOffset, chunkLength); const textDecoder = new TextDecoder("utf8"); const jsonText = textDecoder.decode(jsonChunk); glb.json = JSON.parse(jsonText); return padToNBytes(chunkLength, 4); } function parseBINChunk(glb, dataView, byteOffset, chunkLength) { glb.header.hasBinChunk = true; glb.binChunks.push({ byteOffset, byteLength: chunkLength, arrayBuffer: dataView.buffer }); return padToNBytes(chunkLength, 4); } // ../../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/resolve-url.js function resolveUrl(url, options) { const absolute = url.startsWith("data:") || url.startsWith("http:") || url.startsWith("https:"); if (absolute) { return url; } const baseUrl = options.baseUri || options.uri; if (!baseUrl) { throw new Error(`'baseUri' must be provided to resolve relative url ${url}`); } return baseUrl.substr(0, baseUrl.lastIndexOf("/") + 1) + url; } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_meshopt_compression.js var EXT_meshopt_compression_exports = {}; __export(EXT_meshopt_compression_exports, { decode: () => decode5, name: () => name4 }); // ../../node_modules/@loaders.gl/gltf/dist/meshopt/meshopt-decoder.js var wasm_base = "B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGX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AEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB"; var detector = new Uint8Array([ 0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 3, 2, 0, 0, 5, 3, 1, 0, 1, 12, 1, 0, 10, 22, 2, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11, 7, 0, 65, 0, 253, 15, 26, 11 ]); var wasmpack = new Uint8Array([ 32, 0, 65, 253, 3, 1, 2, 34, 4, 106, 6, 5, 11, 8, 7, 20, 13, 33, 12, 16, 128, 9, 116, 64, 19, 113, 127, 15, 10, 21, 22, 14, 255, 66, 24, 54, 136, 107, 18, 23, 192, 26, 114, 118, 132, 17, 77, 101, 130, 144, 27, 87, 131, 44, 45, 74, 156, 154, 70, 167 ]); var FILTERS = { 0: "", 1: "meshopt_decodeFilterOct", 2: "meshopt_decodeFilterQuat", 3: "meshopt_decodeFilterExp", NONE: "", OCTAHEDRAL: "meshopt_decodeFilterOct", QUATERNION: "meshopt_decodeFilterQuat", EXPONENTIAL: "meshopt_decodeFilterExp" }; var DECODERS = { 0: "meshopt_decodeVertexBuffer", 1: "meshopt_decodeIndexBuffer", 2: "meshopt_decodeIndexSequence", ATTRIBUTES: "meshopt_decodeVertexBuffer", TRIANGLES: "meshopt_decodeIndexBuffer", INDICES: "meshopt_decodeIndexSequence" }; async function meshoptDecodeGltfBuffer(target, count, size, source, mode, filter = "NONE") { const instance = await loadWasmInstance(); decode4(instance, instance.exports[DECODERS[mode]], target, count, size, source, instance.exports[FILTERS[filter || "NONE"]]); } var wasmPromise; async function loadWasmInstance() { if (!wasmPromise) { wasmPromise = loadWasmModule(); } return wasmPromise; } async function loadWasmModule() { let wasm = wasm_base; if (WebAssembly.validate(detector)) { wasm = wasm_simd; console.log("Warning: meshopt_decoder is using experimental SIMD support"); } const result = await WebAssembly.instantiate(unpack(wasm), {}); await result.instance.exports.__wasm_call_ctors(); return result.instance; } function unpack(data) { const result = new Uint8Array(data.length); for (let i2 = 0; i2 < data.length; ++i2) { const ch = data.charCodeAt(i2); result[i2] = ch > 96 ? ch - 71 : ch > 64 ? ch - 65 : ch > 47 ? ch + 4 : ch > 46 ? 63 : 62; } let write = 0; for (let i2 = 0; i2 < data.length; ++i2) { result[write++] = result[i2] < 60 ? wasmpack[result[i2]] : (result[i2] - 60) * 64 + result[++i2]; } return result.buffer.slice(0, write); } function decode4(instance, fun, target, count, size, source, filter) { const sbrk = instance.exports.sbrk; const count4 = count + 3 & ~3; const tp = sbrk(count4 * size); const sp = sbrk(source.length); const heap = new Uint8Array(instance.exports.memory.buffer); heap.set(source, sp); const res = fun(tp, count, size, sp, source.length); if (res === 0 && filter) { filter(tp, count4, size); } target.set(heap.subarray(tp, tp + count * size)); sbrk(tp - sbrk(0)); if (res !== 0) { throw new Error(`Malformed buffer data: ${res}`); } } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_meshopt_compression.js var EXT_MESHOPT_COMPRESSION = "EXT_meshopt_compression"; var name4 = EXT_MESHOPT_COMPRESSION; async function decode5(gltfData, options) { const scenegraph = new GLTFScenegraph(gltfData); if (!options?.gltf?.decompressMeshes || !options.gltf?.loadBuffers) { return; } const promises = []; for (const bufferViewIndex of gltfData.json.bufferViews || []) { promises.push(decodeMeshoptBufferView(scenegraph, bufferViewIndex)); } await Promise.all(promises); scenegraph.removeExtension(EXT_MESHOPT_COMPRESSION); } async function decodeMeshoptBufferView(scenegraph, bufferView) { const meshoptExtension = scenegraph.getObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION); if (meshoptExtension) { const { byteOffset = 0, byteLength = 0, byteStride, count, mode, filter = "NONE", buffer: bufferIndex } = meshoptExtension; const buffer = scenegraph.gltf.buffers[bufferIndex]; const source = new Uint8Array(buffer.arrayBuffer, buffer.byteOffset + byteOffset, byteLength); const result = new Uint8Array(scenegraph.gltf.buffers[bufferView.buffer].arrayBuffer, bufferView.byteOffset, bufferView.byteLength); await meshoptDecodeGltfBuffer(result, count, byteStride, source, mode, filter); scenegraph.removeObjectExtension(bufferView, EXT_MESHOPT_COMPRESSION); } } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_texture_webp.js var EXT_texture_webp_exports = {}; __export(EXT_texture_webp_exports, { name: () => name5, preprocess: () => preprocess }); var EXT_TEXTURE_WEBP = "EXT_texture_webp"; var name5 = EXT_TEXTURE_WEBP; function preprocess(gltfData, options) { const scenegraph = new GLTFScenegraph(gltfData); if (!isImageFormatSupported("image/webp")) { if (scenegraph.getRequiredExtensions().includes(EXT_TEXTURE_WEBP)) { throw new Error(`gltf: Required extension ${EXT_TEXTURE_WEBP} not supported by browser`); } return; } const { json } = scenegraph; for (const texture of json.textures || []) { const extension = scenegraph.getObjectExtension(texture, EXT_TEXTURE_WEBP); if (extension) { texture.source = extension.source; } scenegraph.removeObjectExtension(texture, EXT_TEXTURE_WEBP); } scenegraph.removeExtension(EXT_TEXTURE_WEBP); } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_texture_basisu.js var KHR_texture_basisu_exports = {}; __export(KHR_texture_basisu_exports, { name: () => name6, preprocess: () => preprocess2 }); var KHR_TEXTURE_BASISU = "KHR_texture_basisu"; var name6 = KHR_TEXTURE_BASISU; function preprocess2(gltfData, options) { const scene = new GLTFScenegraph(gltfData); const { json } = scene; for (const texture of json.textures || []) { const extension = scene.getObjectExtension(texture, KHR_TEXTURE_BASISU); if (extension) { texture.source = extension.source; scene.removeObjectExtension(texture, KHR_TEXTURE_BASISU); } } scene.removeExtension(KHR_TEXTURE_BASISU); } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_draco_mesh_compression.js var KHR_draco_mesh_compression_exports = {}; __export(KHR_draco_mesh_compression_exports, { decode: () => decode6, encode: () => encode, name: () => name7, preprocess: () => preprocess3 }); // ../../node_modules/@loaders.gl/draco/dist/lib/utils/version.js var VERSION5 = true ? "4.2.0-beta.2" : "latest"; // ../../node_modules/@loaders.gl/draco/dist/draco-loader.js var DracoLoader = { dataType: null, batchType: null, name: "Draco", id: "draco", module: "draco", version: VERSION5, worker: true, extensions: ["drc"], mimeTypes: ["application/octet-stream"], binary: true, tests: ["DRACO"], options: { draco: { decoderType: typeof WebAssembly === "object" ? "wasm" : "js", libraryPath: "libs/", extraAttributes: {}, attributeNameEntry: void 0 } } }; // ../../node_modules/@loaders.gl/draco/dist/lib/utils/get-draco-schema.js function getDracoSchema(attributes, loaderData, indices) { const metadata = makeMetadata(loaderData.metadata); const fields = []; const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes); for (const attributeName in attributes) { const attribute = attributes[attributeName]; const field = getArrowFieldFromAttribute(attributeName, attribute, namedLoaderDataAttributes[attributeName]); fields.push(field); } if (indices) { const indicesField = getArrowFieldFromAttribute("indices", indices); fields.push(indicesField); } return { fields, metadata }; } function transformAttributesLoaderData(loaderData) { const result = {}; for (const key in loaderData) { const dracoAttribute = loaderData[key]; result[dracoAttribute.name || "undefined"] = dracoAttribute; } return result; } function getArrowFieldFromAttribute(attributeName, attribute, loaderData) { const metadataMap = loaderData ? makeMetadata(loaderData.metadata) : void 0; const field = deduceMeshField(attributeName, attribute, metadataMap); return field; } function makeMetadata(metadata) { Object.entries(metadata); const serializedMetadata = {}; for (const key in metadata) { serializedMetadata[`${key}.string`] = JSON.stringify(metadata[key]); } return serializedMetadata; } // ../../node_modules/@loaders.gl/draco/dist/lib/draco-parser.js var DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP = { POSITION: "POSITION", NORMAL: "NORMAL", COLOR: "COLOR_0", TEX_COORD: "TEXCOORD_0" }; var DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP = { 1: Int8Array, 2: Uint8Array, 3: Int16Array, 4: Uint16Array, 5: Int32Array, 6: Uint32Array, 9: Float32Array }; var INDEX_ITEM_SIZE = 4; var DracoParser = class { draco; decoder; metadataQuerier; constructor(draco) { this.draco = draco; this.decoder = new this.draco.Decoder(); this.metadataQuerier = new this.draco.MetadataQuerier(); } destroy() { this.draco.destroy(this.decoder); this.draco.destroy(this.metadataQuerier); } parseSync(arrayBuffer, options = {}) { const buffer = new this.draco.DecoderBuffer(); buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength); this._disableAttributeTransforms(options); const geometry_type = this.decoder.GetEncodedGeometryType(buffer); const dracoGeometry = geometry_type === this.draco.TRIANGULAR_MESH ? new this.draco.Mesh() : new this.draco.PointCloud(); try { let dracoStatus; switch (geometry_type) { case this.draco.TRIANGULAR_MESH: dracoStatus = this.decoder.DecodeBufferToMesh(buffer, dracoGeometry); break; case this.draco.POINT_CLOUD: dracoStatus = this.decoder.DecodeBufferToPointCloud(buffer, dracoGeometry); break; default: throw new Error("DRACO: Unknown geometry type."); } if (!dracoStatus.ok() || !dracoGeometry.ptr) { const message = `DRACO decompression failed: ${dracoStatus.error_msg()}`; throw new Error(message); } const loaderData = this._getDracoLoaderData(dracoGeometry, geometry_type, options); const geometry = this._getMeshData(dracoGeometry, loaderData, options); const boundingBox = getMeshBoundingBox(geometry.attributes); const schema = getDracoSchema(geometry.attributes, loaderData, geometry.indices); const data = { loader: "draco", loaderData, header: { vertexCount: dracoGeometry.num_points(), boundingBox }, ...geometry, schema }; return data; } finally { this.draco.destroy(buffer); if (dracoGeometry) { this.draco.destroy(dracoGeometry); } } } _getDracoLoaderData(dracoGeometry, geometry_type, options) { const metadata = this._getTopLevelMetadata(dracoGeometry); const attributes = this._getDracoAttributes(dracoGeometry, options); return { geometry_type, num_attributes: dracoGeometry.num_attributes(), num_points: dracoGeometry.num_points(), num_faces: dracoGeometry instanceof this.draco.Mesh ? dracoGeometry.num_faces() : 0, metadata, attributes }; } _getDracoAttributes(dracoGeometry, options) { const dracoAttributes = {}; for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) { const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId); const metadata = this._getAttributeMetadata(dracoGeometry, attributeId); dracoAttributes[dracoAttribute.unique_id()] = { unique_id: dracoAttribute.unique_id(), attribute_type: dracoAttribute.attribute_type(), data_type: dracoAttribute.data_type(), num_components: dracoAttribute.num_components(), byte_offset: dracoAttribute.byte_offset(), byte_stride: dracoAttribute.byte_stride(), normalized: dracoAttribute.normalized(), attribute_index: attributeId, metadata }; const quantization = this._getQuantizationTransform(dracoAttribute, options); if (quantization) { dracoAttributes[dracoAttribute.unique_id()].quantization_transform = quantization; } const octahedron = this._getOctahedronTransform(dracoAttribute, options); if (octahedron) { dracoAttributes[dracoAttribute.unique_id()].octahedron_transform = octahedron; } } return dracoAttributes; } _getMeshData(dracoGeometry, loaderData, options) { const attributes = this._getMeshAttributes(loaderData, dracoGeometry, options); const positionAttribute = attributes.POSITION; if (!positionAttribute) { throw new Error("DRACO: No position attribute found."); } if (dracoGeometry instanceof this.draco.Mesh) { switch (options.topology) { case "triangle-strip": return { topology: "triangle-strip", mode: 4, attributes, indices: { value: this._getTriangleStripIndices(dracoGeometry), size: 1 } }; case "triangle-list": default: return { topology: "triangle-list", mode: 5, attributes, indices: { value: this._getTriangleListIndices(dracoGeometry), size: 1 } }; } } return { topology: "point-list", mode: 0, attributes }; } _getMeshAttributes(loaderData, dracoGeometry, options) { const attributes = {}; for (const loaderAttribute of Object.values(loaderData.attributes)) { const attributeName = this._deduceAttributeName(loaderAttribute, options); loaderAttribute.name = attributeName; const values = this._getAttributeValues(dracoGeometry, loaderAttribute); if (values) { const { value, size } = values; attributes[attributeName] = { value, size, byteOffset: loaderAttribute.byte_offset, byteStride: loaderAttribute.byte_stride, normalized: loaderAttribute.normalized }; } } return attributes; } _getTriangleListIndices(dracoGeometry) { const numFaces = dracoGeometry.num_faces(); const numIndices = numFaces * 3; const byteLength = numIndices * INDEX_ITEM_SIZE; const ptr = this.draco._malloc(byteLength); try { this.decoder.GetTrianglesUInt32Array(dracoGeometry, byteLength, ptr); return new Uint32Array(this.draco.HEAPF32.buffer, ptr, numIndices).slice(); } finally { this.draco._free(ptr); } } _getTriangleStripIndices(dracoGeometry) { const dracoArray = new this.draco.DracoInt32Array(); try { this.decoder.GetTriangleStripsFromMesh(dracoGeometry, dracoArray); return getUint32Array(dracoArray); } finally { this.draco.destroy(dracoArray); } } _getAttributeValues(dracoGeometry, attribute) { const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type]; if (!TypedArrayCtor) { console.warn(`DRACO: Unsupported attribute type ${attribute.data_type}`); return null; } const numComponents = attribute.num_components; const numPoints = dracoGeometry.num_points(); const numValues = numPoints * numComponents; const byteLength = numValues * TypedArrayCtor.BYTES_PER_ELEMENT; const dataType = getDracoDataType(this.draco, TypedArrayCtor); let value; const ptr = this.draco._malloc(byteLength); try { const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attribute.attribute_index); this.decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, dracoAttribute, dataType, byteLength, ptr); value = new TypedArrayCtor(this.draco.HEAPF32.buffer, ptr, numValues).slice(); } finally { this.draco._free(ptr); } return { value, size: numComponents }; } _deduceAttributeName(attribute, options) { const uniqueId = attribute.unique_id; for (const [attributeName, attributeUniqueId] of Object.entries(options.extraAttributes || {})) { if (attributeUniqueId === uniqueId) { return attributeName; } } const thisAttributeType = attribute.attribute_type; for (const dracoAttributeConstant in DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP) { const attributeType = this.draco[dracoAttributeConstant]; if (attributeType === thisAttributeType) { return DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP[dracoAttributeConstant]; } } const entryName = options.attributeNameEntry || "name"; if (attribute.metadata[entryName]) { return attribute.metadata[entryName].string; } return `CUSTOM_ATTRIBUTE_${uniqueId}`; } _getTopLevelMetadata(dracoGeometry) { const dracoMetadata = this.decoder.GetMetadata(dracoGeometry); return this._getDracoMetadata(dracoMetadata); } _getAttributeMetadata(dracoGeometry, attributeId) { const dracoMetadata = this.decoder.GetAttributeMetadata(dracoGeometry, attributeId); return this._getDracoMetadata(dracoMetadata); } _getDracoMetadata(dracoMetadata) { if (!dracoMetadata || !dracoMetadata.ptr) { return {}; } const result = {}; const numEntries = this.metadataQuerier.NumEntries(dracoMetadata); for (let entryIndex = 0; entryIndex < numEntries; entryIndex++) { const entryName = this.metadataQuerier.GetEntryName(dracoMetadata, entryIndex); result[entryName] = this._getDracoMetadataField(dracoMetadata, entryName); } return result; } _getDracoMetadataField(dracoMetadata, entryName) { const dracoArray = new this.draco.DracoInt32Array(); try { this.metadataQuerier.GetIntEntryArray(dracoMetadata, entryName, dracoArray); const intArray = getInt32Array(dracoArray); return { int: this.metadataQuerier.GetIntEntry(dracoMetadata, entryName), string: this.metadataQuerier.GetStringEntry(dracoMetadata, entryName), double: this.metadataQuerier.GetDoubleEntry(dracoMetadata, entryName), intArray }; } finally { this.draco.destroy(dracoArray); } } _disableAttributeTransforms(options) { const { quantizedAttributes = [], octahedronAttributes = [] } = options; const skipAttributes = [...quantizedAttributes, ...octahedronAttributes]; for (const dracoAttributeName of skipAttributes) { this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]); } } _getQuantizationTransform(dracoAttribute, options) { const { quantizedAttributes = [] } = options; const attribute_type = dracoAttribute.attribute_type(); const skip = quantizedAttributes.map((type) => this.decoder[type]).includes(attribute_type); if (skip) { const transform = new this.draco.AttributeQuantizationTransform(); try { if (transform.InitFromAttribute(dracoAttribute)) { return { quantization_bits: transform.quantization_bits(), range: transform.range(), min_values: new Float32Array([1, 2, 3]).map((i2) => transform.min_value(i2)) }; } } finally { this.draco.destroy(transform); } } return null; } _getOctahedronTransform(dracoAttribute, options) { const { octahedronAttributes = [] } = options; const attribute_type = dracoAttribute.attribute_type(); const octahedron = octahedronAttributes.map((type) => this.decoder[type]).includes(attribute_type); if (octahedron) { const transform = new this.draco.AttributeQuantizationTransform(); try { if (transform.InitFromAttribute(dracoAttribute)) { return { quantization_bits: transform.quantization_bits() }; } } finally { this.draco.destroy(transform); } } return null; } }; function getDracoDataType(draco, attributeType) { switch (attributeType) { case Float32Array: return draco.DT_FLOAT32; case Int8Array: return draco.DT_INT8; case Int16Array: return draco.DT_INT16; case Int32Array: return draco.DT_INT32; case Uint8Array: return draco.DT_UINT8; case Uint16Array: return draco.DT_UINT16; case Uint32Array: return draco.DT_UINT32; default: return draco.DT_INVALID; } } function getInt32Array(dracoArray) { const numValues = dracoArray.size(); const intArray = new Int32Array(numValues); for (let i2 = 0; i2 < numValues; i2++) { intArray[i2] = dracoArray.GetValue(i2); } return intArray; } function getUint32Array(dracoArray) { const numValues = dracoArray.size(); const intArray = new Int32Array(numValues); for (let i2 = 0; i2 < numValues; i2++) { intArray[i2] = dracoArray.GetValue(i2); } return intArray; } // ../../node_modules/@loaders.gl/draco/dist/lib/draco-module-loader.js var DRACO_DECODER_VERSION = "1.5.6"; var DRACO_ENCODER_VERSION = "1.4.1"; var STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`; var DRACO_EXTERNAL_LIBRARIES = { DECODER: "draco_wasm_wrapper.js", DECODER_WASM: "draco_decoder.wasm", FALLBACK_DECODER: "draco_decoder.js", ENCODER: "draco_encoder.js" }; var DRACO_EXTERNAL_LIBRARY_URLS = { [DRACO_EXTERNAL_LIBRARIES.DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER}`, [DRACO_EXTERNAL_LIBRARIES.DECODER_WASM]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER_WASM}`, [DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER}`, [DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}` }; var loadDecoderPromise; async function loadDracoDecoderModule(options) { const modules = options.modules || {}; if (modules.draco3d) { loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => { return { draco }; }); } else { loadDecoderPromise ||= loadDracoDecoder(options); } return await loadDecoderPromise; } async function loadDracoDecoder(options) { let DracoDecoderModule; let wasmBinary; switch (options.draco && options.draco.decoderType) { case "js": DracoDecoderModule = await loadLibrary(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER], "draco", options, DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER); break; case "wasm": default: [DracoDecoderModule, wasmBinary] = await Promise.all([ await loadLibrary(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER], "draco", options, DRACO_EXTERNAL_LIBRARIES.DECODER), await loadLibrary(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM], "draco", options, DRACO_EXTERNAL_LIBRARIES.DECODER_WASM) ]); } DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule; return await initializeDracoDecoder(DracoDecoderModule, wasmBinary); } function initializeDracoDecoder(DracoDecoderModule, wasmBinary) { const options = {}; if (wasmBinary) { options.wasmBinary = wasmBinary; } return new Promise((resolve) => { DracoDecoderModule({ ...options, onModuleLoaded: (draco) => resolve({ draco }) }); }); } // ../../node_modules/@loaders.gl/draco/dist/index.js var DracoLoader2 = { ...DracoLoader, parse }; async function parse(arrayBuffer, options) { const { draco } = await loadDracoDecoderModule(options); const dracoParser = new DracoParser(draco); try { return dracoParser.parseSync(arrayBuffer, options?.draco); } finally { dracoParser.destroy(); } } // ../../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/gltf-attribute-utils.js function getGLTFAccessors(attributes) { const accessors = {}; for (const name12 in attributes) { const attribute = attributes[name12]; if (name12 !== "indices") { const glTFAccessor = getGLTFAccessor(attribute); accessors[name12] = glTFAccessor; } } return accessors; } function getGLTFAccessor(attribute) { const { buffer, size, count } = getAccessorData(attribute); const glTFAccessor = { value: buffer, size, byteOffset: 0, count, type: getAccessorTypeFromSize(size), componentType: getComponentTypeFromArray(buffer) }; return glTFAccessor; } function getAccessorData(attribute) { let buffer = attribute; let size = 1; let count = 0; if (attribute && attribute.value) { buffer = attribute.value; size = attribute.size || 1; } if (buffer) { if (!ArrayBuffer.isView(buffer)) { buffer = toTypedArray(buffer, Float32Array); } count = buffer.length / size; } return { buffer, size, count }; } function toTypedArray(array, ArrayType, convertTypedArrays = false) { if (!array) { return null; } if (Array.isArray(array)) { return new ArrayType(array); } if (convertTypedArrays && !(array instanceof ArrayType)) { return new ArrayType(array); } return array; } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_draco_mesh_compression.js var KHR_DRACO_MESH_COMPRESSION = "KHR_draco_mesh_compression"; var name7 = KHR_DRACO_MESH_COMPRESSION; function preprocess3(gltfData, options, context) { const scenegraph = new GLTFScenegraph(gltfData); for (const primitive of makeMeshPrimitiveIterator(scenegraph)) { if (scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION)) { } } } async function decode6(gltfData, options, context) { if (!options?.gltf?.decompressMeshes) { return; } const scenegraph = new GLTFScenegraph(gltfData); const promises = []; for (const primitive of makeMeshPrimitiveIterator(scenegraph)) { if (scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION)) { promises.push(decompressPrimitive(scenegraph, primitive, options, context)); } } await Promise.all(promises); scenegraph.removeExtension(KHR_DRACO_MESH_COMPRESSION); } function encode(gltfData, options = {}) { const scenegraph = new GLTFScenegraph(gltfData); for (const mesh of scenegraph.json.meshes || []) { compressMesh(mesh, options); scenegraph.addRequiredExtension(KHR_DRACO_MESH_COMPRESSION); } } async function decompressPrimitive(scenegraph, primitive, options, context) { const dracoExtension = scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION); if (!dracoExtension) { return; } const buffer = scenegraph.getTypedArrayForBufferView(dracoExtension.bufferView); const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset); const dracoOptions = { ...options }; delete dracoOptions["3d-tiles"]; const decodedData = await parseFromContext(bufferCopy, DracoLoader2, dracoOptions, context); const decodedAttributes = getGLTFAccessors(decodedData.attributes); for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) { if (attributeName in primitive.attributes) { const accessorIndex = primitive.attributes[attributeName]; const accessor = scenegraph.getAccessor(accessorIndex); if (accessor?.min && accessor?.max) { decodedAttribute.min = accessor.min; decodedAttribute.max = accessor.max; } } } primitive.attributes = decodedAttributes; if (decodedData.indices) { primitive.indices = getGLTFAccessor(decodedData.indices); } scenegraph.removeObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION); checkPrimitive(primitive); } function compressMesh(attributes, indices, mode = 4, options, context) { if (!options.DracoWriter) { throw new Error("options.gltf.DracoWriter not provided"); } const compressedData = options.DracoWriter.encodeSync({ attributes }); const decodedData = context?.parseSync?.({ attributes }); const fauxAccessors = options._addFauxAttributes(decodedData.attributes); const bufferViewIndex = options.addBufferView(compressedData); const glTFMesh = { primitives: [ { attributes: fauxAccessors, mode, extensions: { [KHR_DRACO_MESH_COMPRESSION]: { bufferView: bufferViewIndex, attributes: fauxAccessors } } } ] }; return glTFMesh; } function checkPrimitive(primitive) { if (!primitive.attributes && Object.keys(primitive.attributes).length > 0) { throw new Error("glTF: Empty primitive detected: Draco decompression failure?"); } } function* makeMeshPrimitiveIterator(scenegraph) { for (const mesh of scenegraph.json.meshes || []) { for (const primitive of mesh.primitives) { yield primitive; } } } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_texture_transform.js var KHR_texture_transform_exports = {}; __export(KHR_texture_transform_exports, { decode: () => decode7, name: () => name8 }); var KHR_TEXTURE_TRANSFORM = "KHR_texture_transform"; var name8 = KHR_TEXTURE_TRANSFORM; var scratchVector = new Vector3(); var scratchRotationMatrix = new Matrix3(); var scratchScaleMatrix = new Matrix3(); async function decode7(gltfData, options) { const gltfScenegraph = new GLTFScenegraph(gltfData); const hasExtension = gltfScenegraph.hasExtension(KHR_TEXTURE_TRANSFORM); if (!hasExtension || !options.gltf?.loadBuffers) { return; } const materials = gltfData.json.materials || []; for (let i2 = 0; i2 < materials.length; i2++) { transformTexCoords(i2, gltfData); } } function transformTexCoords(materialIndex, gltfData) { const material = gltfData.json.materials?.[materialIndex]; const materialTextures = [ material?.pbrMetallicRoughness?.baseColorTexture, material?.emissiveTexture, material?.normalTexture, material?.occlusionTexture, material?.pbrMetallicRoughness?.metallicRoughnessTexture ]; const processedTexCoords = []; for (const textureInfo of materialTextures) { if (textureInfo && textureInfo?.extensions?.[KHR_TEXTURE_TRANSFORM]) { transformPrimitives(gltfData, materialIndex, textureInfo, processedTexCoords); } } } function transformPrimitives(gltfData, materialIndex, texture, processedTexCoords) { const transformParameters = getTransformParameters(texture, processedTexCoords); if (!transformParameters) { return; } const meshes = gltfData.json.meshes || []; for (const mesh of meshes) { for (const primitive of mesh.primitives) { const material = primitive.material; if (Number.isFinite(material) && materialIndex === material) { transformPrimitive(gltfData, primitive, transformParameters); } } } } function getTransformParameters(texture, processedTexCoords) { const textureInfo = texture.extensions?.[KHR_TEXTURE_TRANSFORM]; const { texCoord: originalTexCoord = 0 } = texture; const { texCoord = originalTexCoord } = textureInfo; const isProcessed = processedTexCoords.findIndex(([original, newTexCoord]) => original === originalTexCoord && newTexCoord === texCoord) !== -1; if (!isProcessed) { const matrix = makeTransformationMatrix(textureInfo); if (originalTexCoord !== texCoord) { texture.texCoord = texCoord; } processedTexCoords.push([originalTexCoord, texCoord]); return { originalTexCoord, texCoord, matrix }; } return null; } function transformPrimitive(gltfData, primitive, transformParameters) { const { originalTexCoord, texCoord, matrix } = transformParameters; const texCoordAccessor = primitive.attributes[`TEXCOORD_${originalTexCoord}`]; if (Number.isFinite(texCoordAccessor)) { const accessor = gltfData.json.accessors?.[texCoordAccessor]; if (accessor && accessor.bufferView) { const bufferView = gltfData.json.bufferViews?.[accessor.bufferView]; if (bufferView) { const { arrayBuffer, byteOffset: bufferByteOffset } = gltfData.buffers[bufferView.buffer]; const byteOffset = (bufferByteOffset || 0) + (accessor.byteOffset || 0) + (bufferView.byteOffset || 0); const { ArrayType, length: length4 } = getAccessorArrayTypeAndLength(accessor, bufferView); const bytes = BYTES[accessor.componentType]; const components = COMPONENTS[accessor.type]; const elementAddressScale = bufferView.byteStride || bytes * components; const result = new Float32Array(length4); for (let i2 = 0; i2 < accessor.count; i2++) { const uv = new ArrayType(arrayBuffer, byteOffset + i2 * elementAddressScale, 2); scratchVector.set(uv[0], uv[1], 1); scratchVector.transformByMatrix3(matrix); result.set([scratchVector[0], scratchVector[1]], i2 * components); } if (originalTexCoord === texCoord) { updateGltf(accessor, bufferView, gltfData.buffers, result); } else { createAttribute(texCoord, accessor, primitive, gltfData, result); } } } } } function updateGltf(accessor, bufferView, buffers, newTexCoordArray) { accessor.componentType = 5126; buffers.push({ arrayBuffer: newTexCoordArray.buffer, byteOffset: 0, byteLength: newTexCoordArray.buffer.byteLength }); bufferView.buffer = buffers.length - 1; bufferView.byteLength = newTexCoordArray.buffer.byteLength; bufferView.byteOffset = 0; delete bufferView.byteStride; } function createAttribute(newTexCoord, originalAccessor, primitive, gltfData, newTexCoordArray) { gltfData.buffers.push({ arrayBuffer: newTexCoordArray.buffer, byteOffset: 0, byteLength: newTexCoordArray.buffer.byteLength }); const bufferViews = gltfData.json.bufferViews; if (!bufferViews) { return; } bufferViews.push({ buffer: gltfData.buffers.length - 1, byteLength: newTexCoordArray.buffer.byteLength, byteOffset: 0 }); const accessors = gltfData.json.accessors; if (!accessors) { return; } accessors.push({ bufferView: bufferViews?.length - 1, byteOffset: 0, componentType: 5126, count: originalAccessor.count, type: "VEC2" }); primitive.attributes[`TEXCOORD_${newTexCoord}`] = accessors.length - 1; } function makeTransformationMatrix(extensionData) { const { offset = [0, 0], rotation = 0, scale: scale5 = [1, 1] } = extensionData; const translationMatrix = new Matrix3().set(1, 0, 0, 0, 1, 0, offset[0], offset[1], 1); const rotationMatrix = scratchRotationMatrix.set(Math.cos(rotation), Math.sin(rotation), 0, -Math.sin(rotation), Math.cos(rotation), 0, 0, 0, 1); const scaleMatrix = scratchScaleMatrix.set(scale5[0], 0, 0, 0, scale5[1], 0, 0, 0, 1); return translationMatrix.multiplyRight(rotationMatrix).multiplyRight(scaleMatrix); } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/KHR_lights_punctual.js var KHR_lights_punctual_exports = {}; __export(KHR_lights_punctual_exports, { decode: () => decode8, encode: () => encode2, name: () => name9 }); var KHR_LIGHTS_PUNCTUAL = "KHR_lights_punctual"; var name9 = KHR_LIGHTS_PUNCTUAL; async function decode8(gltfData) { const gltfScenegraph = new GLTFScenegraph(gltfData); const { json } = gltfScenegraph; const extension = gltfScenegraph.getExtension(KHR_LIGHTS_PUNCTUAL); if (extension) { gltfScenegraph.json.lights = extension.lights; gltfScenegraph.removeExtension(KHR_LIGHTS_PUNCTUAL); } for (const node of json.nodes || []) { const nodeExtension = gltfScenegraph.getObjectExtension(node, KHR_LIGHTS_PUNCTUAL); if (nodeExtension) { node.light = nodeExtension.light; } gltfScenegraph.removeObjectExtension(node, KHR_LIGHTS_PUNCTUAL); } } async function encode2(gltfData) { const gltfScenegraph = new GLTFScenegraph(gltfData); const { json } = gltfScenegraph; if (json.lights) { const extension = gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL); assert5(!extension.lights); extension.lights = json.lights; delete json.lights; } if (gltfScenegraph.json.lights) { for (const light of gltfScenegraph.json.lights) { const node = light.node; gltfScenegraph.addObjectExtension(node, KHR_LIGHTS_PUNCTUAL, light); } delete gltfScenegraph.json.lights; } } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/KHR_materials_unlit.js var KHR_materials_unlit_exports = {}; __export(KHR_materials_unlit_exports, { decode: () => decode9, encode: () => encode3, name: () => name10 }); var KHR_MATERIALS_UNLIT = "KHR_materials_unlit"; var name10 = KHR_MATERIALS_UNLIT; async function decode9(gltfData) { const gltfScenegraph = new GLTFScenegraph(gltfData); const { json } = gltfScenegraph; for (const material of json.materials || []) { const extension = material.extensions && material.extensions.KHR_materials_unlit; if (extension) { material.unlit = true; } gltfScenegraph.removeObjectExtension(material, KHR_MATERIALS_UNLIT); } gltfScenegraph.removeExtension(KHR_MATERIALS_UNLIT); } function encode3(gltfData) { const gltfScenegraph = new GLTFScenegraph(gltfData); const { json } = gltfScenegraph; if (gltfScenegraph.materials) { for (const material of json.materials || []) { if (material.unlit) { delete material.unlit; gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT, {}); gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT); } } } } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/KHR_techniques_webgl.js var KHR_techniques_webgl_exports = {}; __export(KHR_techniques_webgl_exports, { decode: () => decode10, encode: () => encode4, name: () => name11 }); var KHR_TECHNIQUES_WEBGL = "KHR_techniques_webgl"; var name11 = KHR_TECHNIQUES_WEBGL; async function decode10(gltfData) { const gltfScenegraph = new GLTFScenegraph(gltfData); const { json } = gltfScenegraph; const extension = gltfScenegraph.getExtension(KHR_TECHNIQUES_WEBGL); if (extension) { const techniques = resolveTechniques(extension, gltfScenegraph); for (const material of json.materials || []) { const materialExtension = gltfScenegraph.getObjectExtension(material, KHR_TECHNIQUES_WEBGL); if (materialExtension) { material.technique = Object.assign( {}, materialExtension, techniques[materialExtension.technique] ); material.technique.values = resolveValues(material.technique, gltfScenegraph); } gltfScenegraph.removeObjectExtension(material, KHR_TECHNIQUES_WEBGL); } gltfScenegraph.removeExtension(KHR_TECHNIQUES_WEBGL); } } async function encode4(gltfData, options) { } function resolveTechniques(techniquesExtension, gltfScenegraph) { const { programs = [], shaders = [], techniques = [] } = techniquesExtension; const textDecoder = new TextDecoder(); shaders.forEach((shader) => { if (Number.isFinite(shader.bufferView)) { shader.code = textDecoder.decode(gltfScenegraph.getTypedArrayForBufferView(shader.bufferView)); } else { throw new Error("KHR_techniques_webgl: no shader code"); } }); programs.forEach((program) => { program.fragmentShader = shaders[program.fragmentShader]; program.vertexShader = shaders[program.vertexShader]; }); techniques.forEach((technique) => { technique.program = programs[technique.program]; }); return techniques; } function resolveValues(technique, gltfScenegraph) { const values = Object.assign({}, technique.values); Object.keys(technique.uniforms || {}).forEach((uniform) => { if (technique.uniforms[uniform].value && !(uniform in values)) { values[uniform] = technique.uniforms[uniform].value; } }); Object.keys(values).forEach((uniform) => { if (typeof values[uniform] === "object" && values[uniform].index !== void 0) { values[uniform].texture = gltfScenegraph.getTexture(values[uniform].index); } }); return values; } // ../../node_modules/@loaders.gl/gltf/dist/lib/api/gltf-extensions.js var EXTENSIONS2 = [ EXT_structural_metadata_exports, EXT_mesh_features_exports, EXT_meshopt_compression_exports, EXT_texture_webp_exports, KHR_texture_basisu_exports, KHR_draco_mesh_compression_exports, KHR_lights_punctual_exports, KHR_materials_unlit_exports, KHR_techniques_webgl_exports, KHR_texture_transform_exports, EXT_feature_metadata_exports ]; function preprocessExtensions(gltf, options = {}, context) { const extensions = EXTENSIONS2.filter((extension) => useExtension(extension.name, options)); for (const extension of extensions) { extension.preprocess?.(gltf, options, context); } } async function decodeExtensions(gltf, options = {}, context) { const extensions = EXTENSIONS2.filter((extension) => useExtension(extension.name, options)); for (const extension of extensions) { await extension.decode?.(gltf, options, context); } } function useExtension(extensionName, options) { const excludes = options?.gltf?.excludeExtensions || {}; const exclude = extensionName in excludes && !excludes[extensionName]; return !exclude; } // ../../node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_binary_gltf.js var KHR_BINARY_GLTF = "KHR_binary_glTF"; function preprocess4(gltfData) { const gltfScenegraph = new GLTFScenegraph(gltfData); const { json } = gltfScenegraph; for (const image of json.images || []) { const extension = gltfScenegraph.getObjectExtension(image, KHR_BINARY_GLTF); if (extension) { Object.assign(image, extension); } gltfScenegraph.removeObjectExtension(image, KHR_BINARY_GLTF); } if (json.buffers && json.buffers[0]) { delete json.buffers[0].uri; } gltfScenegraph.removeExtension(KHR_BINARY_GLTF); } // ../../node_modules/@loaders.gl/gltf/dist/lib/api/normalize-gltf-v1.js var GLTF_ARRAYS = { accessors: "accessor", animations: "animation", buffers: "buffer", bufferViews: "bufferView", images: "image", materials: "material", meshes: "mesh", nodes: "node", samplers: "sampler", scenes: "scene", skins: "skin", textures: "texture" }; var GLTF_KEYS = { accessor: "accessors", animations: "animation", buffer: "buffers", bufferView: "bufferViews", image: "images", material: "materials", mesh: "meshes", node: "nodes", sampler: "samplers", scene: "scenes", skin: "skins", texture: "textures" }; var GLTFV1Normalizer = class { idToIndexMap = { animations: {}, accessors: {}, buffers: {}, bufferViews: {}, images: {}, materials: {}, meshes: {}, nodes: {}, samplers: {}, scenes: {}, skins: {}, textures: {} }; json; normalize(gltf, options) { this.json = gltf.json; const json = gltf.json; switch (json.asset && json.asset.version) { case "2.0": return; case void 0: case "1.0": break; default: console.warn(`glTF: Unknown version ${json.asset.version}`); return; } if (!options.normalize) { throw new Error("glTF v1 is not supported."); } console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."); this._addAsset(json); this._convertTopLevelObjectsToArrays(json); preprocess4(gltf); this._convertObjectIdsToArrayIndices(json); this._updateObjects(json); this._updateMaterial(json); } _addAsset(json) { json.asset = json.asset || {}; json.asset.version = "2.0"; json.asset.generator = json.asset.generator || "Normalized to glTF 2.0 by loaders.gl"; } _convertTopLevelObjectsToArrays(json) { for (const arrayName in GLTF_ARRAYS) { this._convertTopLevelObjectToArray(json, arrayName); } } _convertTopLevelObjectToArray(json, mapName) { const objectMap = json[mapName]; if (!objectMap || Array.isArray(objectMap)) { return; } json[mapName] = []; for (const id in objectMap) { const object = objectMap[id]; object.id = object.id || id; const index = json[mapName].length; json[mapName].push(object); this.idToIndexMap[mapName][id] = index; } } _convertObjectIdsToArrayIndices(json) { for (const arrayName in GLTF_ARRAYS) { this._convertIdsToIndices(json, arrayName); } if ("scene" in json) { json.scene = this._convertIdToIndex(json.scene, "scene"); } for (const texture of json.textures) { this._convertTextureIds(texture); } for (const mesh of json.meshes) { this._convertMeshIds(mesh); } for (const node of json.nodes) { this._convertNodeIds(node); } for (const node of json.scenes) { this._convertSceneIds(node); } } _convertTextureIds(texture) { if (texture.source) { texture.source = this._convertIdToIndex(texture.source, "image"); } } _convertMeshIds(mesh) { for (const primitive of mesh.primitives) { const { attributes, indices, material } = primitive; for (const attributeName in attributes) { attributes[attributeName] = this._convertIdToIndex(attributes[attributeName], "accessor"); } if (indices) { primitive.indices = this._convertIdToIndex(indices, "accessor"); } if (material) { primitive.material = this._convertIdToIndex(material, "material"); } } } _convertNodeIds(node) { if (node.children) { node.children = node.children.map((child) => this._convertIdToIndex(child, "node")); } if (node.meshes) { node.meshes = node.meshes.map((mesh) => this._convertIdToIndex(mesh, "mesh")); } } _convertSceneIds(scene) { if (scene.nodes) { scene.nodes = scene.nodes.map((node) => this._convertIdToIndex(node, "node")); } } _convertIdsToIndices(json, topLevelArrayName) { if (!json[topLevelArrayName]) { console.warn(`gltf v1: json doesn't contain attribute ${topLevelArrayName}`); json[topLevelArrayName] = []; } for (const object of json[topLevelArrayName]) { for (const key in object) { const id = object[key]; const index = this._convertIdToIndex(id, key); object[key] = index; } } } _convertIdToIndex(id, key) { const arrayName = GLTF_KEYS[key]; if (arrayName in this.idToIndexMap) { const index = this.idToIndexMap[arrayName][id]; if (!Number.isFinite(index)) { throw new Error(`gltf v1: failed to resolve ${key} with id ${id}`); } return index; } return id; } _updateObjects(json) { for (const buffer of this.json.buffers) { delete buffer.type; } } _updateMaterial(json) { for (const material of json.materials) { material.pbrMetallicRoughness = { baseColorFactor: [1, 1, 1, 1], metallicFactor: 1, roughnessFactor: 1 }; const textureId = material.values?.tex || material.values?.texture2d_0 || material.values?.diffuseTex; const textureIndex = json.textures.findIndex((texture) => texture.id === textureId); if (textureIndex !== -1) { material.pbrMetallicRoughness.baseColorTexture = { index: textureIndex }; } } } }; function normalizeGLTFV1(gltf, options = {}) { return new GLTFV1Normalizer().normalize(gltf, options); } // ../../node_modules/@loaders.gl/gltf/dist/lib/parsers/parse-gltf.js async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, context) { parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options); normalizeGLTFV1(gltf, { normalize: options?.gltf?.normalize }); preprocessExtensions(gltf, options, context); if (options?.gltf?.loadBuffers && gltf.json.buffers) { await loadBuffers(gltf, options, context); } if (options?.gltf?.loadImages) { await loadImages(gltf, options, context); } await decodeExtensions(gltf, options, context); return gltf; } function parseGLTFContainerSync(gltf, data, byteOffset, options) { if (options.uri) { gltf.baseUri = options.uri; } if (data instanceof ArrayBuffer && !isGLB(data, byteOffset, options)) { const textDecoder = new TextDecoder(); data = textDecoder.decode(data); } if (typeof data === "string") { gltf.json = parseJSON(data); } else if (data instanceof ArrayBuffer) { const glb = {}; byteOffset = parseGLBSync(glb, data, byteOffset, options.glb); assert5(glb.type === "glTF", `Invalid GLB magic string ${glb.type}`); gltf._glb = glb; gltf.json = glb.json; } else { assert5(false, "GLTF: must be ArrayBuffer or string"); } const buffers = gltf.json.buffers || []; gltf.buffers = new Array(buffers.length).fill(null); if (gltf._glb && gltf._glb.header.hasBinChunk) { const { binChunks } = gltf._glb; gltf.buffers[0] = { arrayBuffer: binChunks[0].arrayBuffer, byteOffset: binChunks[0].byteOffset, byteLength: binChunks[0].byteLength }; } const images = gltf.json.images || []; gltf.images = new Array(images.length).fill({}); } async function loadBuffers(gltf, options, context) { const buffers = gltf.json.buffers || []; for (let i2 = 0; i2 < buffers.length; ++i2) { const buffer = buffers[i2]; if (buffer.uri) { const { fetch: fetch2 } = context; assert5(fetch2); const uri = resolveUrl(buffer.uri, options); const response = await context?.fetch?.(uri); const arrayBuffer = await response?.arrayBuffer?.(); gltf.buffers[i2] = { arrayBuffer, byteOffset: 0, byteLength: arrayBuffer.byteLength }; delete buffer.uri; } else if (gltf.buffers[i2] === null) { gltf.buffers[i2] = { arrayBuffer: new ArrayBuffer(buffer.byteLength), byteOffset: 0, byteLength: buffer.byteLength }; } } } async function loadImages(gltf, options, context) { const imageIndices = getReferencesImageIndices(gltf); const images = gltf.json.images || []; const promises = []; for (const imageIndex of imageIndices) { promises.push(loadImage(gltf, images[imageIndex], imageIndex, options, context)); } return await Promise.all(promises); } function getReferencesImageIndices(gltf) { const imageIndices = /* @__PURE__ */ new Set(); const textures = gltf.json.textures || []; for (const texture of textures) { if (texture.source !== void 0) { imageIndices.add(texture.source); } } return Array.from(imageIndices).sort(); } async function loadImage(gltf, image, index, options, context) { let arrayBuffer; if (image.uri && !image.hasOwnProperty("bufferView")) { const uri = resolveUrl(image.uri, options); const { fetch: fetch2 } = context; const response = await fetch2(uri); arrayBuffer = await response.arrayBuffer(); image.bufferView = { data: arrayBuffer }; } if (Number.isFinite(image.bufferView)) { const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView); arrayBuffer = sliceArrayBuffer(array.buffer, array.byteOffset, array.byteLength); } assert5(arrayBuffer, "glTF image has no data"); let parsedImage = await parseFromContext(arrayBuffer, [ImageLoader, BasisLoader], { ...options, mimeType: image.mimeType, basis: options.basis || { format: selectSupportedBasisFormat() } }, context); if (parsedImage && parsedImage[0]) { parsedImage = { compressed: true, mipmaps: false, width: parsedImage[0].width, height: parsedImage[0].height, data: parsedImage[0] }; } gltf.images = gltf.images || []; gltf.images[index] = parsedImage; } // ../../node_modules/@loaders.gl/gltf/dist/gltf-loader.js var GLTFLoader = { dataType: null, batchType: null, name: "glTF", id: "gltf", module: "gltf", version: VERSION4, extensions: ["gltf", "glb"], mimeTypes: ["model/gltf+json", "model/gltf-binary"], text: true, binary: true, tests: ["glTF"], parse: parse2, options: { gltf: { normalize: true, loadBuffers: true, loadImages: true, decompressMeshes: true }, log: console } }; async function parse2(arrayBuffer, options = {}, context) { options = { ...GLTFLoader.options, ...options }; options.gltf = { ...GLTFLoader.options.gltf, ...options.gltf }; const { byteOffset = 0 } = options; const gltf = {}; return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context); } // ../../node_modules/@loaders.gl/gltf/dist/lib/api/post-process-gltf.js var COMPONENTS2 = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16 }; var BYTES2 = { 5120: 1, 5121: 1, 5122: 2, 5123: 2, 5125: 4, 5126: 4 }; var GL_SAMPLER = { TEXTURE_MAG_FILTER: 10240, TEXTURE_MIN_FILTER: 10241, TEXTURE_WRAP_S: 10242, TEXTURE_WRAP_T: 10243, REPEAT: 10497, LINEAR: 9729, NEAREST_MIPMAP_LINEAR: 9986 }; var SAMPLER_PARAMETER_GLTF_TO_GL = { magFilter: GL_SAMPLER.TEXTURE_MAG_FILTER, minFilter: GL_SAMPLER.TEXTURE_MIN_FILTER, wrapS: GL_SAMPLER.TEXTURE_WRAP_S, wrapT: GL_SAMPLER.TEXTURE_WRAP_T }; var DEFAULT_SAMPLER_PARAMETERS = { [GL_SAMPLER.TEXTURE_MAG_FILTER]: GL_SAMPLER.LINEAR, [GL_SAMPLER.TEXTURE_MIN_FILTER]: GL_SAMPLER.NEAREST_MIPMAP_LINEAR, [GL_SAMPLER.TEXTURE_WRAP_S]: GL_SAMPLER.REPEAT, [GL_SAMPLER.TEXTURE_WRAP_T]: GL_SAMPLER.REPEAT }; function makeDefaultSampler() { return { id: "default-sampler", parameters: DEFAULT_SAMPLER_PARAMETERS }; } function getBytesFromComponentType(componentType) { return BYTES2[componentType]; } function getSizeFromAccessorType(type) { return COMPONENTS2[type]; } var GLTFPostProcessor = class { baseUri = ""; jsonUnprocessed; json; buffers = []; images = []; postProcess(gltf, options = {}) { const { json, buffers = [], images = [] } = gltf; const { baseUri = "" } = gltf; assert5(json); this.baseUri = baseUri; this.buffers = buffers; this.images = images; this.jsonUnprocessed = json; this.json = this._resolveTree(gltf.json, options); return this.json; } _resolveTree(gltf, options = {}) { const json = { ...gltf }; this.json = json; if (gltf.bufferViews) { json.bufferViews = gltf.bufferViews.map((bufView, i2) => this._resolveBufferView(bufView, i2)); } if (gltf.images) { json.images = gltf.images.map((image, i2) => this._resolveImage(image, i2)); } if (gltf.samplers) { json.samplers = gltf.samplers.map((sampler, i2) => this._resolveSampler(sampler, i2)); } if (gltf.textures) { json.textures = gltf.textures.map((texture, i2) => this._resolveTexture(texture, i2)); } if (gltf.accessors) { json.accessors = gltf.accessors.map((accessor, i2) => this._resolveAccessor(accessor, i2)); } if (gltf.materials) { json.materials = gltf.materials.map((material, i2) => this._resolveMaterial(material, i2)); } if (gltf.meshes) { json.meshes = gltf.meshes.map((mesh, i2) => this._resolveMesh(mesh, i2)); } if (gltf.nodes) { json.nodes = gltf.nodes.map((node, i2) => this._resolveNode(node, i2)); json.nodes = json.nodes.map((node, i2) => this._resolveNodeChildren(node)); } if (gltf.skins) { json.skins = gltf.skins.map((skin, i2) => this._resolveSkin(skin, i2)); } if (gltf.scenes) { json.scenes = gltf.scenes.map((scene, i2) => this._resolveScene(scene, i2)); } if (typeof this.json.scene === "number" && json.scenes) { json.scene = json.scenes[this.json.scene]; } return json; } getScene(index) { return this._get(this.json.scenes, index); } getNode(index) { return this._get(this.json.nodes, index); } getSkin(index) { return this._get(this.json.skins, index); } getMesh(index) { return this._get(this.json.meshes, index); } getMaterial(index) { return this._get(this.json.materials, index); } getAccessor(index) { return this._get(this.json.accessors, index); } getCamera(index) { return this._get(this.json.cameras, index); } getTexture(index) { return this._get(this.json.textures, index); } getSampler(index) { return this._get(this.json.samplers, index); } getImage(index) { return this._get(this.json.images, index); } getBufferView(index) { return this._get(this.json.bufferViews, index); } getBuffer(index) { return this._get(this.json.buffers, index); } _get(array, index) { if (typeof index === "object") { return index; } const object = array && array[index]; if (!object) { console.warn(`glTF file error: Could not find ${array}[${index}]`); } return object; } _resolveScene(scene, index) { return { ...scene, id: scene.id || `scene-${index}`, nodes: (scene.nodes || []).map((node) => this.getNode(node)) }; } _resolveNode(gltfNode, index) { const node = { ...gltfNode, id: gltfNode?.id || `node-${index}` }; if (gltfNode.mesh !== void 0) { node.mesh = this.getMesh(gltfNode.mesh); } if (gltfNode.camera !== void 0) { node.camera = this.getCamera(gltfNode.camera); } if (gltfNode.skin !== void 0) { node.skin = this.getSkin(gltfNode.skin); } if (gltfNode.meshes !== void 0 && gltfNode.meshes.length) { node.mesh = gltfNode.meshes.reduce((accum, meshIndex) => { const mesh = this.getMesh(meshIndex); accum.id = mesh.id; accum.primitives = accum.primitives.concat(mesh.primitives); return accum; }, { primitives: [] }); } return node; } _resolveNodeChildren(node) { if (node.children) { node.children = node.children.map((child) => this.getNode(child)); } return node; } _resolveSkin(gltfSkin, index) { const inverseBindMatrices = typeof gltfSkin.inverseBindMatrices === "number" ? this.getAccessor(gltfSkin.inverseBindMatrices) : void 0; return { ...gltfSkin, id: gltfSkin.id || `skin-${index}`, inverseBindMatrices }; } _resolveMesh(gltfMesh, index) { const mesh = { ...gltfMesh, id: gltfMesh.id || `mesh-${index}`, primitives: [] }; if (gltfMesh.primitives) { mesh.primitives = gltfMesh.primitives.map((gltfPrimitive) => { const primitive = { ...gltfPrimitive, attributes: {}, indices: void 0, material: void 0 }; const attributes = gltfPrimitive.attributes; for (const attribute in attributes) { primitive.attributes[attribute] = this.getAccessor(attributes[attribute]); } if (gltfPrimitive.indices !== void 0) { primitive.indices = this.getAccessor(gltfPrimitive.indices); } if (gltfPrimitive.material !== void 0) { primitive.material = this.getMaterial(gltfPrimitive.material); } return primitive; }); } return mesh; } _resolveMaterial(gltfMaterial, index) { const material = { ...gltfMaterial, id: gltfMaterial.id || `material-${index}` }; if (material.normalTexture) { material.normalTexture = { ...material.normalTexture }; material.normalTexture.texture = this.getTexture(material.normalTexture.index); } if (material.occlusionTexture) { material.occlusionTexture = { ...material.occlusionTexture }; material.occlusionTexture.texture = this.getTexture(material.occlusionTexture.index); } if (material.emissiveTexture) { material.emissiveTexture = { ...material.emissiveTexture }; material.emissiveTexture.texture = this.getTexture(material.emissiveTexture.index); } if (!material.emissiveFactor) { material.emissiveFactor = material.emissiveTexture ? [1, 1, 1] : [0, 0, 0]; } if (material.pbrMetallicRoughness) { material.pbrMetallicRoughness = { ...material.pbrMetallicRoughness }; const mr = material.pbrMetallicRoughness; if (mr.baseColorTexture) { mr.baseColorTexture = { ...mr.baseColorTexture }; mr.baseColorTexture.texture = this.getTexture(mr.baseColorTexture.index); } if (mr.metallicRoughnessTexture) { mr.metallicRoughnessTexture = { ...mr.metallicRoughnessTexture }; mr.metallicRoughnessTexture.texture = this.getTexture(mr.metallicRoughnessTexture.index); } } return material; } _resolveAccessor(gltfAccessor, index) { const bytesPerComponent = getBytesFromComponentType(gltfAccessor.componentType); const components = getSizeFromAccessorType(gltfAccessor.type); const bytesPerElement = bytesPerComponent * components; const accessor = { ...gltfAccessor, id: gltfAccessor.id || `accessor-${index}`, bytesPerComponent, components, bytesPerElement, value: void 0, bufferView: void 0, sparse: void 0 }; if (gltfAccessor.bufferView !== void 0) { accessor.bufferView = this.getBufferView(gltfAccessor.bufferView); } if (accessor.bufferView) { const buffer = accessor.bufferView.buffer; const { ArrayType, byteLength } = getAccessorArrayTypeAndLength(accessor, accessor.bufferView); const byteOffset = (accessor.bufferView.byteOffset || 0) + (accessor.byteOffset || 0) + buffer.byteOffset; let cutBuffer = buffer.arrayBuffer.slice(byteOffset, byteOffset + byteLength); if (accessor.bufferView.byteStride) { cutBuffer = this._getValueFromInterleavedBuffer(buffer, byteOffset, accessor.bufferView.byteStride, accessor.bytesPerElement, accessor.count); } accessor.value = new ArrayType(cutBuffer); } return accessor; } _getValueFromInterleavedBuffer(buffer, byteOffset, byteStride, bytesPerElement, count) { const result = new Uint8Array(count * bytesPerElement); for (let i2 = 0; i2 < count; i2++) { const elementOffset = byteOffset + i2 * byteStride; result.set(new Uint8Array(buffer.arrayBuffer.slice(elementOffset, elementOffset + bytesPerElement)), i2 * bytesPerElement); } return result.buffer; } _resolveTexture(gltfTexture, index) { return { ...gltfTexture, id: gltfTexture.id || `texture-${index}`, sampler: typeof gltfTexture.sampler === "number" ? this.getSampler(gltfTexture.sampler) : makeDefaultSampler(), source: typeof gltfTexture.source === "number" ? this.getImage(gltfTexture.source) : void 0 }; } _resolveSampler(gltfSampler, index) { const sampler = { id: gltfSampler.id || `sampler-${index}`, ...gltfSampler, parameters: {} }; for (const key in sampler) { const glEnum = this._enumSamplerParameter(key); if (glEnum !== void 0) { sampler.parameters[glEnum] = sampler[key]; } } return sampler; } _enumSamplerParameter(key) { return SAMPLER_PARAMETER_GLTF_TO_GL[key]; } _resolveImage(gltfImage, index) { const image = { ...gltfImage, id: gltfImage.id || `image-${index}`, image: null, bufferView: gltfImage.bufferView !== void 0 ? this.getBufferView(gltfImage.bufferView) : void 0 }; const preloadedImage = this.images[index]; if (preloadedImage) { image.image = preloadedImage; } return image; } _resolveBufferView(gltfBufferView, index) { const bufferIndex = gltfBufferView.buffer; const arrayBuffer = this.buffers[bufferIndex].arrayBuffer; let byteOffset = this.buffers[bufferIndex].byteOffset || 0; if (gltfBufferView.byteOffset) { byteOffset += gltfBufferView.byteOffset; } const bufferView = { id: `bufferView-${index}`, ...gltfBufferView, buffer: this.buffers[bufferIndex], data: new Uint8Array(arrayBuffer, byteOffset, gltfBufferView.byteLength) }; return bufferView; } _resolveCamera(gltfCamera, index) { const camera = { ...gltfCamera, id: gltfCamera.id || `camera-${index}` }; if (camera.perspective) { } if (camera.orthographic) { } return camera; } }; function postProcessGLTF(gltf, options) { return new GLTFPostProcessor().postProcess(gltf, options); } // src/scenegraph-layer/gltf-utils.ts async function waitForGLTFAssets(gltfObjects) { const remaining = []; gltfObjects.scenes.forEach((scene) => { scene.traverse((modelNode) => { Object.values(modelNode.model.uniforms).forEach((uniform) => { if (uniform.loaded === false) { remaining.push(uniform); } }); }); }); return await waitWhileCondition(() => remaining.some((uniform) => !uniform.loaded)); } async function waitWhileCondition(condition) { while (condition()) { await new Promise((resolve) => requestAnimationFrame(resolve)); } } // src/scenegraph-layer/scenegraph-layer-vertex.glsl.ts var scenegraph_layer_vertex_glsl_default = `#version 300 es #define SHADER_NAME scenegraph-layer-vertex-shader // Instance attributes in vec3 instancePositions; in vec3 instancePositions64Low; in vec4 instanceColors; in vec3 instancePickingColors; in vec3 instanceModelMatrixCol0; in vec3 instanceModelMatrixCol1; in vec3 instanceModelMatrixCol2; in vec3 instanceTranslation; // Scale the model uniform float sizeScale; uniform float sizeMinPixels; uniform float sizeMaxPixels; uniform mat4 sceneModelMatrix; uniform bool composeModelMatrix; // Primitive attributes in vec3 positions; #ifdef HAS_UV in vec2 texCoords; #endif #ifdef MODULE_PBR #ifdef HAS_NORMALS in vec3 normals; #endif #endif // Varying out vec4 vColor; // MODULE_PBR contains all the varying definitions needed #ifndef MODULE_PBR #ifdef HAS_UV out vec2 vTEXCOORD_0; #endif #endif // Main void main(void) { #if defined(HAS_UV) && !defined(MODULE_PBR) vTEXCOORD_0 = texCoords; geometry.uv = texCoords; #endif geometry.worldPosition = instancePositions; geometry.pickingColor = instancePickingColors; mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2); vec3 normal = vec3(0.0, 0.0, 1.0); #ifdef MODULE_PBR #ifdef HAS_NORMALS normal = instanceModelMatrix * (sceneModelMatrix * vec4(normals, 0.0)).xyz; #endif #endif float originalSize = project_size_to_pixel(sizeScale); float clampedSize = clamp(originalSize, sizeMinPixels, sizeMaxPixels); vec3 pos = (instanceModelMatrix * (sceneModelMatrix * vec4(positions, 1.0)).xyz) * sizeScale * (clampedSize / originalSize) + instanceTranslation; if(composeModelMatrix) { DECKGL_FILTER_SIZE(pos, geometry); // using instancePositions as world coordinates // when using globe mode, this branch does not re-orient the model to align with the surface of the earth // call project_normal before setting position to avoid rotation geometry.normal = project_normal(normal); geometry.worldPosition += pos; gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position); } else { pos = project_size(pos); DECKGL_FILTER_SIZE(pos, geometry); gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position); geometry.normal = project_normal(normal); } DECKGL_FILTER_GL_POSITION(gl_Position, geometry); #ifdef MODULE_PBR // set PBR data pbr_vPosition = geometry.position.xyz; #ifdef HAS_NORMALS pbr_vNormal = geometry.normal; #endif #ifdef HAS_UV pbr_vUV = texCoords; #else pbr_vUV = vec2(0., 0.); #endif geometry.uv = pbr_vUV; #endif vColor = instanceColors; DECKGL_FILTER_COLOR(vColor, geometry); } `; // src/scenegraph-layer/scenegraph-layer-fragment.glsl.ts var scenegraph_layer_fragment_glsl_default = `#version 300 es #define SHADER_NAME scenegraph-layer-fragment-shader // Uniforms uniform float opacity; // Varying in vec4 vColor; out vec4 fragColor; // MODULE_PBR contains all the varying definitions needed #ifndef MODULE_PBR #if defined(HAS_UV) && defined(HAS_BASECOLORMAP) in vec2 vTEXCOORD_0; uniform sampler2D u_BaseColorSampler; #endif #endif void main(void) { #ifdef MODULE_PBR fragColor = vColor * pbr_filterColor(vec4(0)); geometry.uv = pbr_vUV; #else #if defined(HAS_UV) && defined(HAS_BASECOLORMAP) fragColor = vColor * texture(u_BaseColorSampler, vTEXCOORD_0); geometry.uv = vTEXCOORD_0; #else fragColor = vColor; #endif #endif fragColor.a *= opacity; DECKGL_FILTER_COLOR(fragColor, geometry); } `; // src/scenegraph-layer/scenegraph-layer.ts var DEFAULT_COLOR2 = [255, 255, 255, 255]; var defaultProps2 = { scenegraph: { type: "object", value: null, async: true }, getScene: (gltf) => { if (gltf && gltf.scenes) { return typeof gltf.scene === "object" ? gltf.scene : gltf.scenes[gltf.scene || 0]; } return gltf; }, getAnimator: (scenegraph) => scenegraph && scenegraph.animator, _animations: null, sizeScale: { type: "number", value: 1, min: 0 }, sizeMinPixels: { type: "number", min: 0, value: 0 }, sizeMaxPixels: { type: "number", min: 0, value: Number.MAX_SAFE_INTEGER }, getPosition: { type: "accessor", value: (x) => x.position }, getColor: { type: "accessor", value: DEFAULT_COLOR2 }, _lighting: "flat", _imageBasedLightingEnvironment: void 0, getOrientation: { type: "accessor", value: [0, 0, 0] }, getScale: { type: "accessor", value: [1, 1, 1] }, getTranslation: { type: "accessor", value: [0, 0, 0] }, getTransformMatrix: { type: "accessor", value: [] }, loaders: [GLTFLoader] }; var ScenegraphLayer = class extends import_core11.Layer { getShaders() { const modules = [import_core11.project32, import_core11.picking]; if (this.props._lighting === "pbr") { modules.push(pbr); } return super.getShaders({ vs: scenegraph_layer_vertex_glsl_default, fs: scenegraph_layer_fragment_glsl_default, modules }); } initializeState() { const attributeManager = this.getAttributeManager(); attributeManager.addInstanced({ instancePositions: { size: 3, type: "float64", fp64: this.use64bitPositions(), accessor: "getPosition", transition: true }, instanceColors: { type: "unorm8", size: this.props.colorFormat.length, accessor: "getColor", defaultValue: DEFAULT_COLOR2, transition: true }, instanceModelMatrix: MATRIX_ATTRIBUTES }); } updateState(params) { super.updateState(params); const { props, oldProps } = params; if (props.scenegraph !== oldProps.scenegraph) { this._updateScenegraph(); } else if (props._animations !== oldProps._animations) { this._applyAnimationsProp(this.state.animator, props._animations); } } finalizeState(context) { super.finalizeState(context); this.state.scenegraph?.destroy(); } get isLoaded() { return Boolean(this.state?.scenegraph && super.isLoaded); } _updateScenegraph() { const props = this.props; const { device } = this.context; let scenegraphData = null; if (props.scenegraph instanceof import_engine4.ScenegraphNode) { scenegraphData = { scenes: [props.scenegraph] }; } else if (props.scenegraph && typeof props.scenegraph === "object") { const gltf = props.scenegraph; const processedGLTF = gltf.json ? postProcessGLTF(gltf) : gltf; const gltfObjects = createScenegraphsFromGLTF(device, processedGLTF, this._getModelOptions()); scenegraphData = { gltf: processedGLTF, ...gltfObjects }; waitForGLTFAssets(gltfObjects).then(() => { this.setNeedsRedraw(); }).catch((ex) => { this.raiseError(ex, "loading glTF"); }); } const options = { layer: this, device: this.context.device }; const scenegraph = props.getScene(scenegraphData, options); const animator = props.getAnimator(scenegraphData, options); if (scenegraph instanceof import_engine4.GroupNode) { this.state.scenegraph?.destroy(); this._applyAnimationsProp(animator, props._animations); const models = []; scenegraph.traverse((node) => { if (node instanceof import_engine4.ModelNode) { models.push(node.model); } }); this.setState({ scenegraph, animator, models }); this.getAttributeManager().invalidateAll(); } else if (scenegraph !== null) { import_core11.log.warn("invalid scenegraph:", scenegraph)(); } } _applyAnimationsProp(animator, animationsProp) { if (!animator || !animationsProp) { return; } const animations = animator.getAnimations(); Object.keys(animationsProp).sort().forEach((key) => { const value = animationsProp[key]; if (key === "*") { animations.forEach((animation) => { Object.assign(animation, value); }); } else if (Number.isFinite(Number(key))) { const number = Number(key); if (number >= 0 && number < animations.length) { Object.assign(animations[number], value); } else { import_core11.log.warn(`animation ${key} not found`)(); } } else { const findResult = animations.find(({ name: name12 }) => name12 === key); if (findResult) { Object.assign(findResult, value); } else { import_core11.log.warn(`animation ${key} not found`)(); } } }); } _getModelOptions() { const { _imageBasedLightingEnvironment } = this.props; let env; if (_imageBasedLightingEnvironment) { if (typeof _imageBasedLightingEnvironment === "function") { env = _imageBasedLightingEnvironment({ gl: this.context.gl, layer: this }); } else { env = _imageBasedLightingEnvironment; } } return { imageBasedLightingEnvironment: env, modelOptions: { id: this.props.id, isInstanced: true, bufferLayout: this.getAttributeManager().getBufferLayouts(), ...this.getShaders() }, useTangents: false }; } draw({ context }) { if (!this.state.scenegraph) return; if (this.props._animations && this.state.animator) { this.state.animator.animate(context.timeline.getTime()); this.setNeedsRedraw(); } const { viewport, renderPass } = this.context; const { sizeScale, sizeMinPixels, sizeMaxPixels, opacity, coordinateSystem } = this.props; const numInstances = this.getNumInstances(); this.state.scenegraph.traverse((node, { worldMatrix }) => { if (node instanceof import_engine4.ModelNode) { const { model } = node; model.setInstanceCount(numInstances); model.setUniforms({ sizeScale, opacity, sizeMinPixels, sizeMaxPixels, composeModelMatrix: shouldComposeModelMatrix(viewport, coordinateSystem), sceneModelMatrix: worldMatrix, u_Camera: model.uniforms.project_uCameraPosition }); model.draw(renderPass); } }); } }; ScenegraphLayer.defaultProps = defaultProps2; ScenegraphLayer.layerName = "ScenegraphLayer"; return __toCommonJS(bundle_exports); })(); return __exports__; });