@luma.gl/engine 9.0.0-alpha.40 → 9.0.0-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +4 -1
- package/dist/index.cjs +4 -1
- package/dist/model/model.d.ts.map +1 -1
- package/dist/model/model.js +4 -1
- package/dist/model/model.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +5 -5
- package/src/model/.model.ts.swp +0 -0
- package/src/model/model.ts +4 -1
package/dist/dist.dev.js
CHANGED
|
@@ -5648,7 +5648,10 @@ ${stage === "fragment" ? FRAGMENT_SHADER_PROLOGUE : ""}
|
|
|
5648
5648
|
*/
|
|
5649
5649
|
setShaderModuleProps(props) {
|
|
5650
5650
|
const uniforms = this._getModuleUniforms(props);
|
|
5651
|
-
const keys = Object.keys(uniforms).filter((k) =>
|
|
5651
|
+
const keys = Object.keys(uniforms).filter((k) => {
|
|
5652
|
+
const uniform = uniforms[k];
|
|
5653
|
+
return !Array.isArray(uniform) && typeof uniform !== "number" && typeof uniform !== "boolean";
|
|
5654
|
+
});
|
|
5652
5655
|
const bindings = {};
|
|
5653
5656
|
for (const k of keys) {
|
|
5654
5657
|
bindings[k] = uniforms[k];
|
package/dist/index.cjs
CHANGED
|
@@ -995,7 +995,10 @@ var _Model = class {
|
|
|
995
995
|
*/
|
|
996
996
|
setShaderModuleProps(props) {
|
|
997
997
|
const uniforms = this._getModuleUniforms(props);
|
|
998
|
-
const keys = Object.keys(uniforms).filter((k) =>
|
|
998
|
+
const keys = Object.keys(uniforms).filter((k) => {
|
|
999
|
+
const uniform = uniforms[k];
|
|
1000
|
+
return !Array.isArray(uniform) && typeof uniform !== "number" && typeof uniform !== "boolean";
|
|
1001
|
+
});
|
|
999
1002
|
const bindings = {};
|
|
1000
1003
|
for (const k of keys) {
|
|
1001
1004
|
bindings[k] = uniforms[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceR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C;;;OAGG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAI7C;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAmBtD;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAItD;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIpD;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI;IAKzD;;;OAGG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIhD;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAgCpD;;;;;;;OAOG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,IAAI;IAWnE,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI7C,eAAe,IAAI,cAAc;CAqBlC"}
|
package/dist/model/model.js
CHANGED
|
@@ -155,7 +155,10 @@ export class Model {
|
|
|
155
155
|
}
|
|
156
156
|
setShaderModuleProps(props) {
|
|
157
157
|
const uniforms = this._getModuleUniforms(props);
|
|
158
|
-
const keys = Object.keys(uniforms).filter(k =>
|
|
158
|
+
const keys = Object.keys(uniforms).filter(k => {
|
|
159
|
+
const uniform = uniforms[k];
|
|
160
|
+
return !Array.isArray(uniform) && typeof uniform !== 'number' && typeof uniform !== 'boolean';
|
|
161
|
+
});
|
|
159
162
|
const bindings = {};
|
|
160
163
|
for (const k of keys) {
|
|
161
164
|
bindings[k] = uniforms[k];
|
package/dist/model/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","names":["RenderPipeline","log","uid","deepEqual","getAttributeInfosFromLayouts","ShaderAssembler","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indexBuffer","bufferAttributes","constantAttributes","bindings","uniforms","pipeline","vertexArray","_pipelineNeedsUpdate","_attributeInfos","_gpuGeometry","_getModuleUniforms","defaultProps","Object","assign","platformInfo","type","info","shaderLanguage","shadingLanguages","gpu","features","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","createVertexArray","renderPipeline","_setGeometryAttributes","setVertexCount","setInstanceCount","indices","Error","setIndexBuffer","attributes","setAttributes","setConstantAttributes","setBindings","setUniforms","moduleSettings","updateModuleSettings","seal","destroy","release","draw","renderPass","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","setShaderModuleProps","keys","filter","k","name","includes","buffers","warn","bufferName","buffer","entries","_bufferLayout$attribu","find","layout","attributeNames","map","attribute","set","attributeName","attributeInfo","setBuffer","location","value","setConstant","reason","createRenderPipeline","createShader","stage","source","shaderLayout","handle","undefined","defines","modules","getDefaultShaderAssembler","layouts1","layouts2","layouts","index","findIndex","attribute2","push"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n TypedArray,\n RenderPipelineProps,\n RenderPipelineParameters,\n BufferLayout,\n VertexArray,\n AttributeInfo\n} from '@luma.gl/core';\nimport type {Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';\nimport {Device, Buffer, RenderPipeline, RenderPass, log, uid, deepEqual} from '@luma.gl/core';\nimport {getAttributeInfosFromLayouts} from '@luma.gl/core';\nimport type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';\nimport {ShaderAssembler} from '@luma.gl/shadertools';\nimport type {Geometry} from '../geometry/geometry';\nimport {GPUGeometry, makeGPUGeometry} from '../geometry/gpu-geometry';\nimport {PipelineFactory} from '../lib/pipeline-factory';\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string shaders\n vs: {glsl?: string; wgsl?: string} | string | null;\n fs: {glsl?: string; wgsl?: string} | string | null;\n /** shadertool shader modules (added to shader code) */\n modules?: ShaderModule[];\n /** Shadertool module defines (configures shader code)*/\n defines?: Record<string, string | number | boolean>;\n // TODO - injections, hooks etc?\n\n /** pipeline factory to use to create render pipelines. Defaults to default factory for the device */\n pipelineFactory?: PipelineFactory;\n /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */\n shaderAssembler?: ShaderAssembler;\n\n /** Parameters that are built into the pipeline */\n parameters?: RenderPipelineParameters;\n\n /** Geometry */\n geometry?: GPUGeometry | Geometry | null;\n\n /** Vertex count */\n vertexCount?: number;\n /** instance count */\n instanceCount?: number;\n\n indexBuffer?: Buffer | null;\n /** @note this is really a map of buffers, not a map of attributes */\n attributes?: Record<string, Buffer>;\n /** */\n constantAttributes?: Record<string, TypedArray>;\n\n /** Mapped uniforms for shadertool modules */\n moduleSettings?: Record<string, Record<string, any>>;\n};\n\n/**\n * v9 Model API\n * A model\n * - automatically reuses pipelines (programs) when possible\n * - automatically rebuilds pipelines if necessary to accommodate changed settings\n * shadertools integration\n * - accepts modules and performs shader transpilation\n */\nexport class Model {\n static defaultProps: Required<ModelProps> = {\n ...RenderPipeline.defaultProps,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n defines: {},\n modules: [],\n moduleSettings: {},\n geometry: null,\n indexBuffer: null,\n attributes: {},\n constantAttributes: {},\n\n pipelineFactory: undefined!,\n shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()\n };\n\n readonly device: Device;\n readonly id: string;\n readonly vs: string;\n readonly fs: string;\n readonly pipelineFactory: PipelineFactory;\n userData: {[key: string]: any} = {};\n\n // Fixed properties (change can trigger pipeline rebuild)\n\n /** The render pipeline GPU parameters, depth testing etc */\n parameters: RenderPipelineParameters;\n\n /** The primitive topology */\n topology: PrimitiveTopology;\n /** Buffer layout */\n bufferLayout: BufferLayout[];\n\n // Dynamic properties\n\n /** Vertex count */\n vertexCount: number;\n /** instance count */\n instanceCount: number = 0;\n\n /** Index buffer */\n indexBuffer: Buffer | null = null;\n /** Buffer-valued attributes */\n bufferAttributes: Record<string, Buffer> = {};\n /** Constant-valued attributes */\n constantAttributes: Record<string, TypedArray> = {};\n /** Bindings (textures, samplers, uniform buffers) */\n bindings: Record<string, Binding> = {};\n /** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/\n uniforms: Record<string, UniformValue> = {};\n\n /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\n\n /**\n * VertexArray\n * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!\n * @todo - allow application to define multiple vertex arrays?\n * */\n vertexArray: VertexArray;\n\n _pipelineNeedsUpdate: string | false = 'newly created';\n _attributeInfos: Record<string, AttributeInfo> = {};\n _gpuGeometry: GPUGeometry | null = null;\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n private props: Required<ModelProps>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...Model.defaultProps, ...props};\n props = this.props;\n this.id = props.id || uid('model');\n this.device = device;\n\n Object.assign(this.userData, props.userData);\n\n /** Create a shadertools platform info from the Device */\n const platformInfo: PlatformInfo = {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguages[0],\n gpu: device.info.gpu,\n features: device.features\n };\n\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders(\n platformInfo,\n this.props\n );\n this.vs = vs;\n this.fs = fs;\n this._getModuleUniforms = getUniforms;\n\n this.vertexCount = this.props.vertexCount;\n this.instanceCount = this.props.instanceCount;\n\n this.topology = this.props.topology;\n this.bufferLayout = this.props.bufferLayout;\n this.parameters = this.props.parameters;\n\n // Geometry, if provided, sets topology and vertex cound\n if (props.geometry) {\n this._gpuGeometry = this.setGeometry(props.geometry);\n }\n\n this.pipelineFactory =\n props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);\n\n // Create the pipeline\n // @note order is important\n this.pipeline = this._updatePipeline();\n\n this.vertexArray = device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Now we can apply geometry attributes\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n\n // Apply any dynamic settings that will not trigger pipeline change\n if (props.vertexCount) {\n this.setVertexCount(props.vertexCount);\n }\n if (props.instanceCount) {\n this.setInstanceCount(props.instanceCount);\n }\n // @ts-expect-error\n if (props.indices) {\n throw new Error('Model.props.indices removed. Use props.indexBuffer')\n }\n if (props.indexBuffer) {\n this.setIndexBuffer(props.indexBuffer);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.constantAttributes) {\n this.setConstantAttributes(props.constantAttributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n this.updateModuleSettings(props.moduleSettings);\n }\n\n this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms\n\n // Catch any access to non-standard props\n Object.seal(this);\n }\n\n destroy(): void {\n this.pipelineFactory.release(this.pipeline);\n }\n\n // Draw call\n\n draw(renderPass: RenderPass): void {\n // Check if the pipeline is invalidated\n // TODO - this is likely the worst place to do this from performance perspective. Perhaps add a predraw()?\n this.pipeline = this._updatePipeline();\n\n // Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw\n // Any caching needs to be done inside the pipeline functions\n this.pipeline.setBindings(this.bindings);\n this.pipeline.setUniforms(this.uniforms);\n\n this.pipeline.draw({\n renderPass,\n vertexArray: this.vertexArray,\n vertexCount: this.vertexCount,\n instanceCount: this.instanceCount\n });\n }\n\n // Update fixed fields (can trigger pipeline rebuild)\n\n /**\n * Updates the optional geometry\n * Geometry, set topology and bufferLayout\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);\n if (this.vertexArray) {\n this._setGeometryAttributes(gpuGeometry);\n }\n return gpuGeometry;\n }\n\n /**\n * Updates the optional geometry attributes\n * Geometry, sets several attributes, indexBuffer, and also vertex count\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n _setGeometryAttributes(gpuGeometry: GPUGeometry): void {\n // TODO - delete previous geometry?\n this.vertexCount = gpuGeometry.vertexCount;\n this.setAttributes(gpuGeometry.attributes);\n this.setIndexBuffer(gpuGeometry.indices);\n }\n\n /**\n * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setTopology(topology: PrimitiveTopology): void {\n if (topology !== this.topology) {\n this.topology = topology;\n this._setPipelineNeedsUpdate('topology');\n }\n }\n\n /**\n * Updates the buffer layout.\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setBufferLayout(bufferLayout: BufferLayout[]): void {\n this.bufferLayout = this._gpuGeometry\n ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout)\n : bufferLayout;\n this._setPipelineNeedsUpdate('bufferLayout');\n\n // Recreate the pipeline\n this.pipeline = this._updatePipeline();\n \n // vertex array needs to be updated if we update buffer layout,\n // but not if we update parameters\n this.vertexArray = this.device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Reapply geometry attributes to the new vertex array\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n }\n\n /**\n * Set GPU parameters.\n * @note Can trigger a pipeline rebuild / pipeline cache fetch.\n * @param parameters\n */\n setParameters(parameters: RenderPipelineParameters) {\n if (!deepEqual(parameters, this.parameters, 2)) {\n this.parameters = parameters;\n this._setPipelineNeedsUpdate('parameters');\n }\n }\n\n // Update dynamic fields\n\n /**\n * Updates the vertex count (used in draw calls)\n * @note Any attributes with stepMode=vertex need to be at least this big\n */\n setVertexCount(vertexCount: number): void {\n this.vertexCount = vertexCount;\n }\n\n /**\n * Updates the instance count (used in draw calls)\n * @note Any attributes with stepMode=instance need to be at least this big\n */\n setInstanceCount(instanceCount: number): void {\n this.instanceCount = instanceCount;\n }\n\n /**\n * Updates shader module settings (which results in uniforms being set)\n */\n setShaderModuleProps(props: Record<string, any>): void {\n const uniforms = this._getModuleUniforms(props);\n\n // Extract textures & framebuffers set by the modules\n // TODO better way to extract bindings\n const keys = Object.keys(uniforms).filter(k => uniforms[k].constructor.name.includes('WEBGL'));\n const bindings: Record<string, Binding> = {};\n for (const k of keys) {\n bindings[k] = uniforms[k];\n delete uniforms[k];\n }\n\n Object.assign(this.uniforms, uniforms);\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * @deprecated Updates shader module settings (which results in uniforms being set)\n */\n updateModuleSettings(props: Record<string, any>): void {\n this.setShaderModuleProps(props);\n }\n\n /**\n * Sets bindings (textures, samplers, uniform buffers)\n */\n setBindings(bindings: Record<string, Binding>): void {\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * Sets individual uniforms\n * @deprecated WebGL only, use uniform buffers for portability\n * @param uniforms\n * @returns self for chaining\n */\n setUniforms(uniforms: Record<string, UniformValue>): void {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * Sets the index buffer\n * @todo - how to unset it if we change geometry?\n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n this.vertexArray.setIndexBuffer(indexBuffer);\n }\n\n /**\n * Sets attributes (buffers)\n * @note Overrides any attributes previously set with the same name\n */\n setAttributes(buffers: Record<string, Buffer>): void {\n if (buffers.indices) {\n log.warn(\n `Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`\n );\n }\n for (const [bufferName, buffer] of Object.entries(buffers)) {\n const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);\n if (!bufferLayout) {\n continue; // eslint-disable-line no-continue\n }\n\n // For an interleaved attribute we may need to set multiple attributes\n const attributeNames = bufferLayout.attributes\n ? bufferLayout.attributes?.map(layout => layout.attribute)\n : [bufferLayout.name];\n let set = false;\n for (const attributeName of attributeNames) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setBuffer(attributeInfo.location, buffer);\n set = true;\n }\n }\n if (!set) {\n log.warn(\n `Model(${this.id}): Ignoring buffer \"${buffer.id}\" for unknown attribute \"${bufferName}\"`\n )();\n }\n }\n }\n\n /**\n * Sets constant attributes\n * @note Overrides any attributes previously set with the same name\n * Constant attributes are only supported in WebGL, not in WebGPU\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @param constantAttributes\n */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n for (const [attributeName, value] of Object.entries(attributes)) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setConstant(attributeInfo.location, value);\n } else {\n log.warn(`Model \"${this.id}: Ignoring constant supplied for unknown attribute \"${attributeName}\"`)();\n }\n }\n }\n\n _setPipelineNeedsUpdate(reason: string): void {\n this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;\n }\n\n _updatePipeline(): RenderPipeline {\n if (this._pipelineNeedsUpdate) {\n if (this.pipeline) {\n log.log(1, `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`)();\n }\n this._pipelineNeedsUpdate = false;\n this.pipeline = this.device.createRenderPipeline({\n ...this.props,\n bufferLayout: this.bufferLayout,\n topology: this.topology,\n parameters: this.parameters,\n vs: this.device.createShader({id: '{$this.id}-vertex', stage: 'vertex', source: this.vs}),\n fs: this.fs ? this.device.createShader({id: '{$this.id}-fragment', stage: 'fragment', source: this.fs}) : null\n });\n this._attributeInfos = getAttributeInfosFromLayouts(\n this.pipeline.shaderLayout,\n this.bufferLayout\n );\n }\n return this.pipeline;\n }\n}\n\n/** TODO - move to core, document add tests */\nfunction mergeBufferLayouts(layouts1: BufferLayout[], layouts2: BufferLayout[]): BufferLayout[] {\n const layouts = [...layouts1];\n for (const attribute of layouts2) {\n const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);\n if (index < 0) {\n layouts.push(attribute);\n } else {\n layouts[index] = attribute;\n }\n }\n return layouts;\n}\n"],"mappings":"AAYA,SAAwBA,cAAc,EAAcC,GAAG,EAAEC,GAAG,EAAEC,SAAS,QAAO,eAAe;AAC7F,SAAQC,4BAA4B,QAAO,eAAe;AAE1D,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAEhCC,eAAe;AAAA,SAC5BC,eAAe;AA8CvB,OAAO,MAAMC,KAAK,CAAC;EAuEjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,KAnDtCD,MAAM;IAAA,KACNE,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,eAAe;IAAA,KACxBC,QAAQ,GAAyB,CAAC,CAAC;IAAA,KAKnCC,UAAU;IAAA,KAGVC,QAAQ;IAAA,KAERC,YAAY;IAAA,KAKZC,WAAW;IAAA,KAEXC,aAAa,GAAW,CAAC;IAAA,KAGzBC,WAAW,GAAkB,IAAI;IAAA,KAEjCC,gBAAgB,GAA2B,CAAC,CAAC;IAAA,KAE7CC,kBAAkB,GAA+B,CAAC,CAAC;IAAA,KAEnDC,QAAQ,GAA4B,CAAC,CAAC;IAAA,KAEtCC,QAAQ,GAAiC,CAAC,CAAC;IAAA,KAG3CC,QAAQ;IAAA,KAORC,WAAW;IAAA,KAEXC,oBAAoB,GAAmB,eAAe;IAAA,KACtDC,eAAe,GAAkC,CAAC,CAAC;IAAA,KACnDC,YAAY,GAAuB,IAAI;IAAA,KAC/BC,kBAAkB;IAAA,KAClBrB,KAAK;IAGX,IAAI,CAACA,KAAK,G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outs","ShaderAssembler","makeGPUGeometry","PipelineFactory","Model","constructor","device","props","id","vs","fs","pipelineFactory","userData","parameters","topology","bufferLayout","vertexCount","instanceCount","indexBuffer","bufferAttributes","constantAttributes","bindings","uniforms","pipeline","vertexArray","_pipelineNeedsUpdate","_attributeInfos","_gpuGeometry","_getModuleUniforms","defaultProps","Object","assign","platformInfo","type","info","shaderLanguage","shadingLanguages","gpu","features","getUniforms","shaderAssembler","assembleShaders","geometry","setGeometry","getDefaultPipelineFactory","_updatePipeline","createVertexArray","renderPipeline","_setGeometryAttributes","setVertexCount","setInstanceCount","indices","Error","setIndexBuffer","attributes","setAttributes","setConstantAttributes","setBindings","setUniforms","moduleSettings","updateModuleSettings","seal","destroy","release","draw","renderPass","gpuGeometry","setTopology","mergeBufferLayouts","_setPipelineNeedsUpdate","setBufferLayout","setParameters","setShaderModuleProps","keys","filter","k","uniform","Array","isArray","buffers","warn","bufferName","buffer","entries","_bufferLayout$attribu","find","layout","name","attributeNames","map","attribute","set","attributeName","attributeInfo","setBuffer","location","value","setConstant","reason","createRenderPipeline","createShader","stage","source","shaderLayout","handle","undefined","defines","modules","getDefaultShaderAssembler","layouts1","layouts2","layouts","index","findIndex","attribute2","push"],"sources":["../../src/model/model.ts"],"sourcesContent":["// luma.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {\n TypedArray,\n RenderPipelineProps,\n RenderPipelineParameters,\n BufferLayout,\n VertexArray,\n AttributeInfo\n} from '@luma.gl/core';\nimport type {Binding, UniformValue, PrimitiveTopology} from '@luma.gl/core';\nimport {Device, Buffer, RenderPipeline, RenderPass, log, uid, deepEqual} from '@luma.gl/core';\nimport {getAttributeInfosFromLayouts} from '@luma.gl/core';\nimport type {ShaderModule, PlatformInfo} from '@luma.gl/shadertools';\nimport {ShaderAssembler} from '@luma.gl/shadertools';\nimport type {Geometry} from '../geometry/geometry';\nimport {GPUGeometry, makeGPUGeometry} from '../geometry/gpu-geometry';\nimport {PipelineFactory} from '../lib/pipeline-factory';\n\nexport type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {\n // Model also accepts a string shaders\n vs: {glsl?: string; wgsl?: string} | string | null;\n fs: {glsl?: string; wgsl?: string} | string | null;\n /** shadertool shader modules (added to shader code) */\n modules?: ShaderModule[];\n /** Shadertool module defines (configures shader code)*/\n defines?: Record<string, string | number | boolean>;\n // TODO - injections, hooks etc?\n\n /** pipeline factory to use to create render pipelines. Defaults to default factory for the device */\n pipelineFactory?: PipelineFactory;\n /** Shader assembler. Defaults to the ShaderAssembler.getShaderAssembler() */\n shaderAssembler?: ShaderAssembler;\n\n /** Parameters that are built into the pipeline */\n parameters?: RenderPipelineParameters;\n\n /** Geometry */\n geometry?: GPUGeometry | Geometry | null;\n\n /** Vertex count */\n vertexCount?: number;\n /** instance count */\n instanceCount?: number;\n\n indexBuffer?: Buffer | null;\n /** @note this is really a map of buffers, not a map of attributes */\n attributes?: Record<string, Buffer>;\n /** */\n constantAttributes?: Record<string, TypedArray>;\n\n /** Mapped uniforms for shadertool modules */\n moduleSettings?: Record<string, Record<string, any>>;\n};\n\n/**\n * v9 Model API\n * A model\n * - automatically reuses pipelines (programs) when possible\n * - automatically rebuilds pipelines if necessary to accommodate changed settings\n * shadertools integration\n * - accepts modules and performs shader transpilation\n */\nexport class Model {\n static defaultProps: Required<ModelProps> = {\n ...RenderPipeline.defaultProps,\n vs: null,\n fs: null,\n id: 'unnamed',\n handle: undefined,\n userData: {},\n defines: {},\n modules: [],\n moduleSettings: {},\n geometry: null,\n indexBuffer: null,\n attributes: {},\n constantAttributes: {},\n\n pipelineFactory: undefined!,\n shaderAssembler: ShaderAssembler.getDefaultShaderAssembler()\n };\n\n readonly device: Device;\n readonly id: string;\n readonly vs: string;\n readonly fs: string;\n readonly pipelineFactory: PipelineFactory;\n userData: {[key: string]: any} = {};\n\n // Fixed properties (change can trigger pipeline rebuild)\n\n /** The render pipeline GPU parameters, depth testing etc */\n parameters: RenderPipelineParameters;\n\n /** The primitive topology */\n topology: PrimitiveTopology;\n /** Buffer layout */\n bufferLayout: BufferLayout[];\n\n // Dynamic properties\n\n /** Vertex count */\n vertexCount: number;\n /** instance count */\n instanceCount: number = 0;\n\n /** Index buffer */\n indexBuffer: Buffer | null = null;\n /** Buffer-valued attributes */\n bufferAttributes: Record<string, Buffer> = {};\n /** Constant-valued attributes */\n constantAttributes: Record<string, TypedArray> = {};\n /** Bindings (textures, samplers, uniform buffers) */\n bindings: Record<string, Binding> = {};\n /** Sets uniforms @deprecated Use uniform buffers and setBindings() for portability*/\n uniforms: Record<string, UniformValue> = {};\n\n /** The underlying GPU \"program\". @note May be recreated if parameters change */\n pipeline: RenderPipeline;\n\n /**\n * VertexArray\n * @note not implemented: if bufferLayout is updated, vertex array has to be rebuilt!\n * @todo - allow application to define multiple vertex arrays?\n * */\n vertexArray: VertexArray;\n\n _pipelineNeedsUpdate: string | false = 'newly created';\n _attributeInfos: Record<string, AttributeInfo> = {};\n _gpuGeometry: GPUGeometry | null = null;\n private _getModuleUniforms: (props?: Record<string, Record<string, any>>) => Record<string, any>;\n private props: Required<ModelProps>;\n\n constructor(device: Device, props: ModelProps) {\n this.props = {...Model.defaultProps, ...props};\n props = this.props;\n this.id = props.id || uid('model');\n this.device = device;\n\n Object.assign(this.userData, props.userData);\n\n /** Create a shadertools platform info from the Device */\n const platformInfo: PlatformInfo = {\n type: device.info.type,\n shaderLanguage: device.info.shadingLanguages[0],\n gpu: device.info.gpu,\n features: device.features\n };\n\n const {vs, fs, getUniforms} = this.props.shaderAssembler.assembleShaders(\n platformInfo,\n this.props\n );\n this.vs = vs;\n this.fs = fs;\n this._getModuleUniforms = getUniforms;\n\n this.vertexCount = this.props.vertexCount;\n this.instanceCount = this.props.instanceCount;\n\n this.topology = this.props.topology;\n this.bufferLayout = this.props.bufferLayout;\n this.parameters = this.props.parameters;\n\n // Geometry, if provided, sets topology and vertex cound\n if (props.geometry) {\n this._gpuGeometry = this.setGeometry(props.geometry);\n }\n\n this.pipelineFactory =\n props.pipelineFactory || PipelineFactory.getDefaultPipelineFactory(this.device);\n\n // Create the pipeline\n // @note order is important\n this.pipeline = this._updatePipeline();\n\n this.vertexArray = device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Now we can apply geometry attributes\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n\n // Apply any dynamic settings that will not trigger pipeline change\n if (props.vertexCount) {\n this.setVertexCount(props.vertexCount);\n }\n if (props.instanceCount) {\n this.setInstanceCount(props.instanceCount);\n }\n // @ts-expect-error\n if (props.indices) {\n throw new Error('Model.props.indices removed. Use props.indexBuffer')\n }\n if (props.indexBuffer) {\n this.setIndexBuffer(props.indexBuffer);\n }\n if (props.attributes) {\n this.setAttributes(props.attributes);\n }\n if (props.constantAttributes) {\n this.setConstantAttributes(props.constantAttributes);\n }\n if (props.bindings) {\n this.setBindings(props.bindings);\n }\n if (props.uniforms) {\n this.setUniforms(props.uniforms);\n }\n if (props.moduleSettings) {\n this.updateModuleSettings(props.moduleSettings);\n }\n\n this.setUniforms(this._getModuleUniforms()); // Get all default module uniforms\n\n // Catch any access to non-standard props\n Object.seal(this);\n }\n\n destroy(): void {\n this.pipelineFactory.release(this.pipeline);\n }\n\n // Draw call\n\n draw(renderPass: RenderPass): void {\n // Check if the pipeline is invalidated\n // TODO - this is likely the worst place to do this from performance perspective. Perhaps add a predraw()?\n this.pipeline = this._updatePipeline();\n\n // Set pipeline state, we may be sharing a pipeline so we need to set all state on every draw\n // Any caching needs to be done inside the pipeline functions\n this.pipeline.setBindings(this.bindings);\n this.pipeline.setUniforms(this.uniforms);\n\n this.pipeline.draw({\n renderPass,\n vertexArray: this.vertexArray,\n vertexCount: this.vertexCount,\n instanceCount: this.instanceCount\n });\n }\n\n // Update fixed fields (can trigger pipeline rebuild)\n\n /**\n * Updates the optional geometry\n * Geometry, set topology and bufferLayout\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setGeometry(geometry: GPUGeometry | Geometry): GPUGeometry {\n const gpuGeometry = geometry && makeGPUGeometry(this.device, geometry);\n this.setTopology(gpuGeometry.topology || 'triangle-list');\n this.bufferLayout = mergeBufferLayouts(this.bufferLayout, gpuGeometry.bufferLayout);\n if (this.vertexArray) {\n this._setGeometryAttributes(gpuGeometry);\n }\n return gpuGeometry;\n }\n\n /**\n * Updates the optional geometry attributes\n * Geometry, sets several attributes, indexBuffer, and also vertex count\n * @note Can trigger a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n _setGeometryAttributes(gpuGeometry: GPUGeometry): void {\n // TODO - delete previous geometry?\n this.vertexCount = gpuGeometry.vertexCount;\n this.setAttributes(gpuGeometry.attributes);\n this.setIndexBuffer(gpuGeometry.indices);\n }\n\n /**\n * Updates the primitive topology ('triangle-list', 'triangle-strip' etc).\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setTopology(topology: PrimitiveTopology): void {\n if (topology !== this.topology) {\n this.topology = topology;\n this._setPipelineNeedsUpdate('topology');\n }\n }\n\n /**\n * Updates the buffer layout.\n * @note Triggers a pipeline rebuild / pipeline cache fetch on WebGPU\n */\n setBufferLayout(bufferLayout: BufferLayout[]): void {\n this.bufferLayout = this._gpuGeometry\n ? mergeBufferLayouts(bufferLayout, this._gpuGeometry.bufferLayout)\n : bufferLayout;\n this._setPipelineNeedsUpdate('bufferLayout');\n\n // Recreate the pipeline\n this.pipeline = this._updatePipeline();\n \n // vertex array needs to be updated if we update buffer layout,\n // but not if we update parameters\n this.vertexArray = this.device.createVertexArray({\n renderPipeline: this.pipeline\n });\n\n // Reapply geometry attributes to the new vertex array\n if (this._gpuGeometry) {\n this._setGeometryAttributes(this._gpuGeometry);\n }\n }\n\n /**\n * Set GPU parameters.\n * @note Can trigger a pipeline rebuild / pipeline cache fetch.\n * @param parameters\n */\n setParameters(parameters: RenderPipelineParameters) {\n if (!deepEqual(parameters, this.parameters, 2)) {\n this.parameters = parameters;\n this._setPipelineNeedsUpdate('parameters');\n }\n }\n\n // Update dynamic fields\n\n /**\n * Updates the vertex count (used in draw calls)\n * @note Any attributes with stepMode=vertex need to be at least this big\n */\n setVertexCount(vertexCount: number): void {\n this.vertexCount = vertexCount;\n }\n\n /**\n * Updates the instance count (used in draw calls)\n * @note Any attributes with stepMode=instance need to be at least this big\n */\n setInstanceCount(instanceCount: number): void {\n this.instanceCount = instanceCount;\n }\n\n /**\n * Updates shader module settings (which results in uniforms being set)\n */\n setShaderModuleProps(props: Record<string, any>): void {\n const uniforms = this._getModuleUniforms(props);\n\n // Extract textures & framebuffers set by the modules\n // TODO better way to extract bindings\n const keys = Object.keys(uniforms).filter(k => {\n const uniform = uniforms[k];\n return !Array.isArray(uniform) && (typeof uniform !== 'number') && (typeof uniform !== 'boolean');\n });\n const bindings: Record<string, Binding> = {};\n for (const k of keys) {\n bindings[k] = uniforms[k];\n delete uniforms[k];\n }\n\n Object.assign(this.uniforms, uniforms);\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * @deprecated Updates shader module settings (which results in uniforms being set)\n */\n updateModuleSettings(props: Record<string, any>): void {\n this.setShaderModuleProps(props);\n }\n\n /**\n * Sets bindings (textures, samplers, uniform buffers)\n */\n setBindings(bindings: Record<string, Binding>): void {\n Object.assign(this.bindings, bindings);\n }\n\n /**\n * Sets individual uniforms\n * @deprecated WebGL only, use uniform buffers for portability\n * @param uniforms\n * @returns self for chaining\n */\n setUniforms(uniforms: Record<string, UniformValue>): void {\n this.pipeline.setUniforms(uniforms);\n Object.assign(this.uniforms, uniforms);\n }\n\n /**\n * Sets the index buffer\n * @todo - how to unset it if we change geometry?\n */\n setIndexBuffer(indexBuffer: Buffer | null): void {\n this.vertexArray.setIndexBuffer(indexBuffer);\n }\n\n /**\n * Sets attributes (buffers)\n * @note Overrides any attributes previously set with the same name\n */\n setAttributes(buffers: Record<string, Buffer>): void {\n if (buffers.indices) {\n log.warn(\n `Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`\n );\n }\n for (const [bufferName, buffer] of Object.entries(buffers)) {\n const bufferLayout = this.bufferLayout.find(layout => layout.name === bufferName);\n if (!bufferLayout) {\n continue; // eslint-disable-line no-continue\n }\n\n // For an interleaved attribute we may need to set multiple attributes\n const attributeNames = bufferLayout.attributes\n ? bufferLayout.attributes?.map(layout => layout.attribute)\n : [bufferLayout.name];\n let set = false;\n for (const attributeName of attributeNames) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setBuffer(attributeInfo.location, buffer);\n set = true;\n }\n }\n if (!set) {\n log.warn(\n `Model(${this.id}): Ignoring buffer \"${buffer.id}\" for unknown attribute \"${bufferName}\"`\n )();\n }\n }\n }\n\n /**\n * Sets constant attributes\n * @note Overrides any attributes previously set with the same name\n * Constant attributes are only supported in WebGL, not in WebGPU\n * Any attribute that is disabled in the current vertex array object\n * is read from the context's global constant value for that attribute location.\n * @param constantAttributes\n */\n setConstantAttributes(attributes: Record<string, TypedArray>): void {\n for (const [attributeName, value] of Object.entries(attributes)) {\n const attributeInfo = this._attributeInfos[attributeName];\n if (attributeInfo) {\n this.vertexArray.setConstant(attributeInfo.location, value);\n } else {\n log.warn(`Model \"${this.id}: Ignoring constant supplied for unknown attribute \"${attributeName}\"`)();\n }\n }\n }\n\n _setPipelineNeedsUpdate(reason: string): void {\n this._pipelineNeedsUpdate = this._pipelineNeedsUpdate || reason;\n }\n\n _updatePipeline(): RenderPipeline {\n if (this._pipelineNeedsUpdate) {\n if (this.pipeline) {\n log.log(1, `Model ${this.id}: Recreating pipeline because \"${this._pipelineNeedsUpdate}\".`)();\n }\n this._pipelineNeedsUpdate = false;\n this.pipeline = this.device.createRenderPipeline({\n ...this.props,\n bufferLayout: this.bufferLayout,\n topology: this.topology,\n parameters: this.parameters,\n vs: this.device.createShader({id: '{$this.id}-vertex', stage: 'vertex', source: this.vs}),\n fs: this.fs ? this.device.createShader({id: '{$this.id}-fragment', stage: 'fragment', source: this.fs}) : null\n });\n this._attributeInfos = getAttributeInfosFromLayouts(\n this.pipeline.shaderLayout,\n this.bufferLayout\n );\n }\n return this.pipeline;\n }\n}\n\n/** TODO - move to core, document add tests */\nfunction mergeBufferLayouts(layouts1: BufferLayout[], layouts2: BufferLayout[]): BufferLayout[] {\n const layouts = [...layouts1];\n for (const attribute of layouts2) {\n const index = layouts.findIndex(attribute2 => attribute2.name === attribute.name);\n if (index < 0) {\n layouts.push(attribute);\n } else {\n layouts[index] = attribute;\n }\n }\n return layouts;\n}\n"],"mappings":"AAYA,SAAwBA,cAAc,EAAcC,GAAG,EAAEC,GAAG,EAAEC,SAAS,QAAO,eAAe;AAC7F,SAAQC,4BAA4B,QAAO,eAAe;AAE1D,SAAQC,eAAe,QAAO,sBAAsB;AAAC,SAEhCC,eAAe;AAAA,SAC5BC,eAAe;AA8CvB,OAAO,MAAMC,KAAK,CAAC;EAuEjBC,WAAWA,CAACC,MAAc,EAAEC,KAAiB,EAAE;IAAA,KAnDtCD,MAAM;IAAA,KACNE,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,EAAE;IAAA,KACFC,eAAe;IAAA,KACxBC,QAAQ,GAAyB,CAAC,CAAC;IAAA,KAKnCC,UAAU;IAAA,KAGVC,QAAQ;IAAA,KAERC,YAAY;IAAA,KAKZC,WAAW;IAAA,KAEXC,aAAa,GAAW,CAAC;IAAA,KAGzBC,WAAW,GAAkB,IAAI;IAAA,KAEjCC,gBAAgB,GAA2B,CAAC,CAAC;IAAA,KAE7CC,kBAAkB,GAA+B,CAAC,CAAC;IAAA,KAEnDC,QAAQ,GAA4B,CAAC,CAAC;IAAA,KAEtCC,QAAQ,GAAiC,CAAC,CAAC;IAAA,KAG3CC,QAAQ;IAAA,KAORC,WAAW;IAAA,KAEXC,oBAAoB,GAAmB,eAAe;IAAA,KACtDC,eAAe,GAAkC,CAAC,CAAC;IAAA,KACnDC,YAAY,GAAuB,IAAI;IAAA,KAC/BC,kBAAkB;IAAA,KAClBrB,KAAK;IAGX,IAAI,CAACA,KAAK,GAAG;MAA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qB,OAAO;AAChB"}
|
package/dist.min.js
CHANGED
|
@@ -224,7 +224,7 @@ precision highp float;
|
|
|
224
224
|
`),t++;var i=e[n];(i||Number.isFinite(i))&&(r+="#define ".concat(n.toUpperCase()," ").concat(e[n],`
|
|
225
225
|
`))}return t===0&&(r+=`
|
|
226
226
|
`),r}function fi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function ui(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?fi(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fi(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function hi(e,t){if(!t.vs)throw new Error("no vertex shader");var r=li(e,t.vs),n;return t.fs&&(n=li(e,t.fs)),ui(ui({},t),{},{vs:r,fs:n})}function li(e,t){if(typeof t=="string")return t;switch(e.type){case"webgpu":if(t!=null&&t.wgsl)return t.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(t!=null&&t.glsl)return t.glsl;throw new Error("WebGL does not support WGSL shaders")}}function pi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function di(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pi(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pi(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var we=function(){function e(){T(this,e),this._hookFunctions=[],this._defaultModules=[]}e.getDefaultShaderAssembler=function(){return e.defaultShaderAssembler=e.defaultShaderAssembler||new e,e.defaultShaderAssembler};var t=e.prototype;return t.addDefaultModule=function(n){this._defaultModules.find(function(i){return i.name===(typeof n=="string"?n:n.name)})||this._defaultModules.push(n)},t.removeDefaultModule=function(n){var i=typeof n=="string"?n:n.name;this._defaultModules=this._defaultModules.filter(function(o){return o.name!==i})},t.addShaderHook=function(n,i){i&&(n=Object.assign(i,{hook:n})),this._hookFunctions.push(n)},t.assembleShaders=function(n,i){var o=this._getModuleList(i.modules),s=this._hookFunctions,c=hi(n,i),a=ci(n,di(di({},c),{},{modules:o,hookFunctions:s}));return a},t._getModuleList=function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],i=new Array(this._defaultModules.length+n.length),o={},s=0,c=0,a=this._defaultModules.length;c<a;++c){var f=this._defaultModules[c],u=f.name;i[s++]=f,o[u]=!0}for(var l=0,h=n.length;l<h;++l){var v=n[l],m=v.name;o[m]||(i[s++]=v,o[m]=!0)}return i.length=s,i},A(e)}();we.defaultShaderAssembler=void 0;var jh=1/Math.PI*180,Fh=1/180*Math.PI,Ks={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Ks}};var et=globalThis.mathgl.config;function mi(e,{precision:t=et.precision}={}){return e=Ys(e),"".concat(parseFloat(e.toPrecision(t)))}function Vt(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function dr(e,t,r){let n=et.EPSILON;r&&(et.EPSILON=r);try{if(e===t)return!0;if(Vt(e)&&Vt(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(!dr(e[i],t[i]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=et.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{et.EPSILON=n}}function Ys(e){return Math.round(e/et.EPSILON)*et.EPSILON}function Xs(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}var Ht=class extends Xs(Array){clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+r];return this.check()}toArray(t=[],r=0){for(let n=0;n<this.ELEMENTS;++n)t[r+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Vt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(et)}formatString(t){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+mi(this[n],t);return"".concat(t.printTypes?this.constructor.name:"","[").concat(r,"]")}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!dr(this[r],t[r]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==t[r])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,r,n){if(n===void 0)return this.lerp(this,t,r);for(let i=0;i<this.ELEMENTS;++i){let o=t[i],s=typeof r=="number"?r:r[i];this[i]=o+n*(s-o)}return this.check()}min(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(t[r],this[r]);return this.check()}max(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(t[r],this[r]);return this.check()}clamp(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),r[n]);return this.check()}add(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(t){if(typeof t=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;else for(let r=0;r<this.ELEMENTS&&r<t.length;++r)this[r]*=t[r];return this.check()}multiplyByScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}check(){if(et.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let t=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)t=t&&Number.isFinite(this[r]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=t;return this.check()}addScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t),r);return this.check()}get elements(){return this}};function $s(e,t){if(e.length!==t)return!1;for(let r=0;r<e.length;++r)if(!Number.isFinite(e[r]))return!1;return!0}function it(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(JSON.stringify(e)));return e}function Ee(e,t,r=""){if(et.debug&&!$s(e,t))throw new Error("math.gl: ".concat(r," some fields set to invalid numbers'"));return e}function mr(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}var Me=class extends Ht{get x(){return this[0]}set x(t){this[0]=it(t)}get y(){return this[1]}set y(t){this[1]=it(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*this[r];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let r=0;for(let n=0;n<this.ELEMENTS;++n){let i=this[n]-t[n];r+=i*i}return it(r)}dot(t){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*t[n];return it(r)}normalize(){let t=this.magnitude();if(t!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t;return this.check()}multiply(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return mr(t>=0&&t<this.ELEMENTS,"index is out of range"),it(this[t])}setComponent(t,r){return mr(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=r,this.check()}addVectors(t,r){return this.copy(t).add(r)}subVectors(t,r){return this.copy(t).subtract(r)}multiplyVectors(t,r){return this.copy(t).multiply(r)}addScaledVector(t,r){return this.add(new this.constructor(t).multiplyScalar(r))}};var _t=typeof Float32Array<"u"?Float32Array:Array;var Yh=Math.PI/180;function Zs(){let e=new _t(2);return _t!=Float32Array&&(e[0]=0,e[1]=0),e}function yi(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e}var Xh=function(){let e=Zs();return function(t,r,n,i,o,s){let c,a;for(r||(r=2),n||(n=0),i?a=Math.min(i*r+n,t.length):a=t.length,c=n;c<a;c+=r)e[0]=t[c],e[1]=t[c+1],o(e,e,s),t[c]=e[0],t[c+1]=e[1];return t}}();function _i(e,t,r){let n=t[0],i=t[1],o=r[3]*n+r[7]*i||1;return e[0]=(r[0]*n+r[4]*i)/o,e[1]=(r[1]*n+r[5]*i)/o,e}function Se(e,t,r){let n=t[0],i=t[1],o=t[2],s=r[3]*n+r[7]*i+r[11]*o||1;return e[0]=(r[0]*n+r[4]*i+r[8]*o)/s,e[1]=(r[1]*n+r[5]*i+r[9]*o)/s,e[2]=(r[2]*n+r[6]*i+r[10]*o)/s,e}function xi(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e[2]=t[2],e}function Js(){let e=new _t(3);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Qs(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function bi(e,t,r){let n=t[0],i=t[1],o=t[2],s=r[0],c=r[1],a=r[2];return e[0]=i*a-o*c,e[1]=o*s-n*a,e[2]=n*c-i*s,e}function Pe(e,t,r){let n=t[0],i=t[1],o=t[2],s=r[3]*n+r[7]*i+r[11]*o+r[15];return s=s||1,e[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/s,e[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/s,e[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/s,e}function Oi(e,t,r){let n=t[0],i=t[1],o=t[2];return e[0]=n*r[0]+i*r[3]+o*r[6],e[1]=n*r[1]+i*r[4]+o*r[7],e[2]=n*r[2]+i*r[5]+o*r[8],e}function wi(e,t,r){let n=r[0],i=r[1],o=r[2],s=r[3],c=t[0],a=t[1],f=t[2],u=i*f-o*a,l=o*c-n*f,h=n*a-i*c,v=i*h-o*l,m=o*u-n*h,y=n*l-i*u,b=s*2;return u*=b,l*=b,h*=b,v*=2,m*=2,y*=2,e[0]=c+u+v,e[1]=a+l+m,e[2]=f+h+y,e}function Ei(e,t,r,n){let i=[],o=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],o[0]=i[0],o[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),o[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Mi(e,t,r,n){let i=[],o=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],o[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),o[1]=i[1],o[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Si(e,t,r,n){let i=[],o=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],o[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),o[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),o[2]=i[2],e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Pi(e,t){let r=e[0],n=e[1],i=e[2],o=t[0],s=t[1],c=t[2],a=Math.sqrt((r*r+n*n+i*i)*(o*o+s*s+c*c)),f=a&&Qs(e,t)/a;return Math.acos(Math.min(Math.max(f,-1),1))}var Jh=function(){let e=Js();return function(t,r,n,i,o,s){let c,a;for(r||(r=3),n||(n=0),i?a=Math.min(i*r+n,t.length):a=t.length,c=n;c<a;c+=r)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],o(e,e,s),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var vr=[0,0,0],Ae,ot=class extends Me{static get ZERO(){return Ae||(Ae=new ot(0,0,0),Object.freeze(Ae)),Ae}constructor(t=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&Vt(t)?this.copy(t):(et.debug&&(it(t),it(r),it(n)),this[0]=t,this[1]=r,this[2]=n)}set(t,r,n){return this[0]=t,this[1]=r,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return et.debug&&(it(t.x),it(t.y),it(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=it(t)}angle(t){return Pi(this,t)}cross(t){return bi(this,this,t),this.check()}rotateX({radians:t,origin:r=vr}){return Ei(this,this,r,t),this.check()}rotateY({radians:t,origin:r=vr}){return Mi(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=vr}){return Si(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Pe(this,this,t),this.check()}transformAsVector(t){return Se(this,this,t),this.check()}transformByMatrix3(t){return Oi(this,this,t),this.check()}transformByMatrix2(t){return xi(this,this,t),this.check()}transformByQuaternion(t){return wi(this,this,t),this.check()}};var Te=class extends Ht{toString(){let t="[";if(et.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)t+=" ".concat(this[n*this.RANK+r])}else{t+="column-major:";for(let r=0;r<this.ELEMENTS;++r)t+=" ".concat(this[r])}return t+="]",t}getElementIndex(t,r){return r*this.RANK+t}getElement(t,r){return this[r*this.RANK+t]}setElement(t,r,n){return this[r*this.RANK+t]=it(n),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)r[i]=this[n+i];return r}setColumn(t,r){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)this[n+i]=r[i];return this}};function ta(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ai(e,t){if(e===t){let r=t[1],n=t[2],i=t[3],o=t[6],s=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=o,e[11]=t[14],e[12]=i,e[13]=s,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function Ti(e,t){let r=t[0],n=t[1],i=t[2],o=t[3],s=t[4],c=t[5],a=t[6],f=t[7],u=t[8],l=t[9],h=t[10],v=t[11],m=t[12],y=t[13],b=t[14],O=t[15],R=r*c-n*s,x=r*a-i*s,S=r*f-o*s,w=n*a-i*c,M=n*f-o*c,j=i*f-o*a,N=u*y-l*m,U=u*b-h*m,C=u*O-v*m,g=l*b-h*y,p=l*O-v*y,d=h*O-v*b,_=R*d-x*p+S*g+w*C-M*U+j*N;return _?(_=1/_,e[0]=(c*d-a*p+f*g)*_,e[1]=(i*p-n*d-o*g)*_,e[2]=(y*j-b*M+O*w)*_,e[3]=(h*M-l*j-v*w)*_,e[4]=(a*C-s*d-f*U)*_,e[5]=(r*d-i*C+o*U)*_,e[6]=(b*S-m*j-O*x)*_,e[7]=(u*j-h*S+v*x)*_,e[8]=(s*p-c*C+f*N)*_,e[9]=(n*C-r*p-o*N)*_,e[10]=(m*M-y*S+O*R)*_,e[11]=(l*S-u*M-v*R)*_,e[12]=(c*U-s*g-a*N)*_,e[13]=(r*g-n*U+i*N)*_,e[14]=(y*x-m*w-b*R)*_,e[15]=(u*w-l*x+h*R)*_,e):null}function Ri(e){let t=e[0],r=e[1],n=e[2],i=e[3],o=e[4],s=e[5],c=e[6],a=e[7],f=e[8],u=e[9],l=e[10],h=e[11],v=e[12],m=e[13],y=e[14],b=e[15],O=t*s-r*o,R=t*c-n*o,x=r*c-n*s,S=f*m-u*v,w=f*y-l*v,M=u*y-l*m,j=t*M-r*w+n*S,N=o*M-s*w+c*S,U=f*x-u*R+l*O,C=v*x-m*R+y*O;return a*j-i*N+b*U-h*C}function yr(e,t,r){let n=t[0],i=t[1],o=t[2],s=t[3],c=t[4],a=t[5],f=t[6],u=t[7],l=t[8],h=t[9],v=t[10],m=t[11],y=t[12],b=t[13],O=t[14],R=t[15],x=r[0],S=r[1],w=r[2],M=r[3];return e[0]=x*n+S*c+w*l+M*y,e[1]=x*i+S*a+w*h+M*b,e[2]=x*o+S*f+w*v+M*O,e[3]=x*s+S*u+w*m+M*R,x=r[4],S=r[5],w=r[6],M=r[7],e[4]=x*n+S*c+w*l+M*y,e[5]=x*i+S*a+w*h+M*b,e[6]=x*o+S*f+w*v+M*O,e[7]=x*s+S*u+w*m+M*R,x=r[8],S=r[9],w=r[10],M=r[11],e[8]=x*n+S*c+w*l+M*y,e[9]=x*i+S*a+w*h+M*b,e[10]=x*o+S*f+w*v+M*O,e[11]=x*s+S*u+w*m+M*R,x=r[12],S=r[13],w=r[14],M=r[15],e[12]=x*n+S*c+w*l+M*y,e[13]=x*i+S*a+w*h+M*b,e[14]=x*o+S*f+w*v+M*O,e[15]=x*s+S*u+w*m+M*R,e}function Ci(e,t,r){let n=r[0],i=r[1],o=r[2],s,c,a,f,u,l,h,v,m,y,b,O;return t===e?(e[12]=t[0]*n+t[4]*i+t[8]*o+t[12],e[13]=t[1]*n+t[5]*i+t[9]*o+t[13],e[14]=t[2]*n+t[6]*i+t[10]*o+t[14],e[15]=t[3]*n+t[7]*i+t[11]*o+t[15]):(s=t[0],c=t[1],a=t[2],f=t[3],u=t[4],l=t[5],h=t[6],v=t[7],m=t[8],y=t[9],b=t[10],O=t[11],e[0]=s,e[1]=c,e[2]=a,e[3]=f,e[4]=u,e[5]=l,e[6]=h,e[7]=v,e[8]=m,e[9]=y,e[10]=b,e[11]=O,e[12]=s*n+u*i+m*o+t[12],e[13]=c*n+l*i+y*o+t[13],e[14]=a*n+h*i+b*o+t[14],e[15]=f*n+v*i+O*o+t[15]),e}function Li(e,t,r){let n=r[0],i=r[1],o=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Di(e,t,r,n){let i=n[0],o=n[1],s=n[2],c=Math.sqrt(i*i+o*o+s*s),a,f,u,l,h,v,m,y,b,O,R,x,S,w,M,j,N,U,C,g,p,d,_,E;return c<1e-6?null:(c=1/c,i*=c,o*=c,s*=c,f=Math.sin(r),a=Math.cos(r),u=1-a,l=t[0],h=t[1],v=t[2],m=t[3],y=t[4],b=t[5],O=t[6],R=t[7],x=t[8],S=t[9],w=t[10],M=t[11],j=i*i*u+a,N=o*i*u+s*f,U=s*i*u-o*f,C=i*o*u-s*f,g=o*o*u+a,p=s*o*u+i*f,d=i*s*u+o*f,_=o*s*u-i*f,E=s*s*u+a,e[0]=l*j+y*N+x*U,e[1]=h*j+b*N+S*U,e[2]=v*j+O*N+w*U,e[3]=m*j+R*N+M*U,e[4]=l*C+y*g+x*p,e[5]=h*C+b*g+S*p,e[6]=v*C+O*g+w*p,e[7]=m*C+R*g+M*p,e[8]=l*d+y*_+x*E,e[9]=h*d+b*_+S*E,e[10]=v*d+O*_+w*E,e[11]=m*d+R*_+M*E,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Ii(e,t,r){let n=Math.sin(r),i=Math.cos(r),o=t[4],s=t[5],c=t[6],a=t[7],f=t[8],u=t[9],l=t[10],h=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*i+f*n,e[5]=s*i+u*n,e[6]=c*i+l*n,e[7]=a*i+h*n,e[8]=f*i-o*n,e[9]=u*i-s*n,e[10]=l*i-c*n,e[11]=h*i-a*n,e}function Ni(e,t,r){let n=Math.sin(r),i=Math.cos(r),o=t[0],s=t[1],c=t[2],a=t[3],f=t[8],u=t[9],l=t[10],h=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i-f*n,e[1]=s*i-u*n,e[2]=c*i-l*n,e[3]=a*i-h*n,e[8]=o*n+f*i,e[9]=s*n+u*i,e[10]=c*n+l*i,e[11]=a*n+h*i,e}function ji(e,t,r){let n=Math.sin(r),i=Math.cos(r),o=t[0],s=t[1],c=t[2],a=t[3],f=t[4],u=t[5],l=t[6],h=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i+f*n,e[1]=s*i+u*n,e[2]=c*i+l*n,e[3]=a*i+h*n,e[4]=f*i-o*n,e[5]=u*i-s*n,e[6]=l*i-c*n,e[7]=h*i-a*n,e}function Fi(e,t){let r=t[0],n=t[1],i=t[2],o=t[3],s=r+r,c=n+n,a=i+i,f=r*s,u=n*s,l=n*c,h=i*s,v=i*c,m=i*a,y=o*s,b=o*c,O=o*a;return e[0]=1-l-m,e[1]=u+O,e[2]=h-b,e[3]=0,e[4]=u-O,e[5]=1-f-m,e[6]=v+y,e[7]=0,e[8]=h+b,e[9]=v-y,e[10]=1-f-l,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ui(e,t,r,n,i,o,s){let c=1/(r-t),a=1/(i-n),f=1/(o-s);return e[0]=o*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o*2*a,e[6]=0,e[7]=0,e[8]=(r+t)*c,e[9]=(i+n)*a,e[10]=(s+o)*f,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*f,e[15]=0,e}function ea(e,t,r,n,i){let o=1/Math.tan(t/2);if(e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){let s=1/(n-i);e[10]=(i+n)*s,e[14]=2*i*n*s}else e[10]=-1,e[14]=-2*n;return e}var Gi=ea;function ra(e,t,r,n,i,o,s){let c=1/(t-r),a=1/(n-i),f=1/(o-s);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*f,e[11]=0,e[12]=(t+r)*c,e[13]=(i+n)*a,e[14]=(s+o)*f,e[15]=1,e}var zi=ra;function Bi(e,t,r,n){let i,o,s,c,a,f,u,l,h,v,m=t[0],y=t[1],b=t[2],O=n[0],R=n[1],x=n[2],S=r[0],w=r[1],M=r[2];return Math.abs(m-S)<1e-6&&Math.abs(y-w)<1e-6&&Math.abs(b-M)<1e-6?ta(e):(l=m-S,h=y-w,v=b-M,i=1/Math.sqrt(l*l+h*h+v*v),l*=i,h*=i,v*=i,o=R*v-x*h,s=x*l-O*v,c=O*h-R*l,i=Math.sqrt(o*o+s*s+c*c),i?(i=1/i,o*=i,s*=i,c*=i):(o=0,s=0,c=0),a=h*c-v*s,f=v*o-l*c,u=l*s-h*o,i=Math.sqrt(a*a+f*f+u*u),i?(i=1/i,a*=i,f*=i,u*=i):(a=0,f=0,u=0),e[0]=o,e[1]=a,e[2]=l,e[3]=0,e[4]=s,e[5]=f,e[6]=h,e[7]=0,e[8]=c,e[9]=u,e[10]=v,e[11]=0,e[12]=-(o*m+s*y+c*b),e[13]=-(a*m+f*y+u*b),e[14]=-(l*m+h*y+v*b),e[15]=1,e)}function na(){let e=new _t(4);return _t!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function ki(e,t,r){let n=t[0],i=t[1],o=t[2],s=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*o+r[12]*s,e[1]=r[1]*n+r[5]*i+r[9]*o+r[13]*s,e[2]=r[2]*n+r[6]*i+r[10]*o+r[14]*s,e[3]=r[3]*n+r[7]*i+r[11]*o+r[15]*s,e}var lp=function(){let e=na();return function(t,r,n,i,o,s){let c,a;for(r||(r=4),n||(n=0),i?a=Math.min(i*r+n,t.length):a=t.length,c=n;c<a;c+=r)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],o(e,e,s),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();var br;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(br||(br={}));var ia=45*Math.PI/180,oa=1,_r=.1,xr=500,sa=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),mt=class extends Te{static get IDENTITY(){return ca()}static get ZERO(){return aa()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return br}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,r,n,i,o,s,c,a,f,u,l,h,v,m,y,b){return this[0]=t,this[1]=r,this[2]=n,this[3]=i,this[4]=o,this[5]=s,this[6]=c,this[7]=a,this[8]=f,this[9]=u,this[10]=l,this[11]=h,this[12]=v,this[13]=m,this[14]=y,this[15]=b,this.check()}setRowMajor(t,r,n,i,o,s,c,a,f,u,l,h,v,m,y,b){return this[0]=t,this[1]=o,this[2]=f,this[3]=v,this[4]=r,this[5]=s,this[6]=u,this[7]=m,this[8]=n,this[9]=c,this[10]=l,this[11]=y,this[12]=i,this[13]=a,this[14]=h,this[15]=b,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(sa)}fromObject(t){return this.check()}fromQuaternion(t){return Fi(this,t),this.check()}frustum(t){let{left:r,right:n,bottom:i,top:o,near:s=_r,far:c=xr}=t;return c===1/0?fa(this,r,n,i,o,s):Ui(this,r,n,i,o,s,c),this.check()}lookAt(t){let{eye:r,center:n=[0,0,0],up:i=[0,1,0]}=t;return Bi(this,r,n,i),this.check()}ortho(t){let{left:r,right:n,bottom:i,top:o,near:s=_r,far:c=xr}=t;return zi(this,r,n,i,o,s,c),this.check()}orthographic(t){let{fovy:r=ia,aspect:n=oa,focalDistance:i=1,near:o=_r,far:s=xr}=t;Vi(r);let c=r/2,a=i*Math.tan(c),f=a*n;return this.ortho({left:-f,right:f,bottom:-a,top:a,near:o,far:s})}perspective(t){let{fovy:r=45*Math.PI/180,aspect:n=1,near:i=.1,far:o=500}=t;return Vi(r),Gi(this,r,n,i,o),this.check()}determinant(){return Ri(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],o=1/n[1],s=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*o,t[2]=this[2]*s,t[3]=0,t[4]=this[4]*i,t[5]=this[5]*o,t[6]=this[6]*s,t[7]=0,t[8]=this[8]*i,t[9]=this[9]*o,t[10]=this[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],o=1/n[1],s=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*o,t[2]=this[2]*s,t[3]=this[4]*i,t[4]=this[5]*o,t[5]=this[6]*s,t[6]=this[8]*i,t[7]=this[9]*o,t[8]=this[10]*s,t}transpose(){return Ai(this,this),this.check()}invert(){return Ti(this,this),this.check()}multiplyLeft(t){return yr(this,t,this),this.check()}multiplyRight(t){return yr(this,this,t),this.check()}rotateX(t){return Ii(this,this,t),this.check()}rotateY(t){return Ni(this,this,t),this.check()}rotateZ(t){return ji(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return Di(this,this,t,r),this.check()}scale(t){return Li(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Ci(this,this,t),this.check()}transform(t,r){return t.length===4?(r=ki(r||[-0,-0,-0,-0],t,this),Ee(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:n}=t,i;switch(n){case 2:i=yi(r||[-0,-0],t,this);break;case 3:i=Pe(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Ee(i,t.length),i}transformAsVector(t,r){let n;switch(t.length){case 2:n=_i(r||[-0,-0],t,this);break;case 3:n=Se(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Ee(n,t.length),n}transformPoint(t,r){return this.transformAsPoint(t,r)}transformVector(t,r){return this.transformAsPoint(t,r)}transformDirection(t,r){return this.transformAsVector(t,r)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,n){return this.identity().translate([t,r,n])}},Re,Ce;function aa(){return Re||(Re=new mt([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Re)),Re}function ca(){return Ce||(Ce=new mt,Object.freeze(Ce)),Ce}function Vi(e){if(e>Math.PI*2)throw Error("expected radians")}function fa(e,t,r,n,i,o){let s=2*o/(r-t),c=2*o/(i-n),a=(r+t)/(r-t),f=(i+n)/(i-n),u=-1,l=-1,h=-2*o;return e[0]=s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=a,e[9]=f,e[10]=u,e[11]=l,e[12]=0,e[13]=0,e[14]=h,e[15]=0,e}var Hi=function(){function e(r){T(this,e),this.id=void 0,this.userData={},this.topology=void 0,this.bufferLayout=[],this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.id=r.id||H("geometry"),this.topology=r.topology,this.indices=r.indices||null,this.attributes=r.attributes,this.vertexCount=r.vertexCount,this.bufferLayout=r.bufferLayout||[],this.indices&&rt(this.indices.usage===X.INDEX)}var t=e.prototype;return t.destroy=function(){var n;this.indices.destroy(),this.attributes.positions.destroy(),this.attributes.normals.destroy(),this.attributes.texCoords.destroy(),(n=this.attributes.colors)===null||n===void 0||n.destroy()},t.getVertexCount=function(){return this.vertexCount},t.getAttributes=function(){return this.attributes},t.getIndexes=function(){return this.indices},t._calculateVertexCount=function(n){var i=n.byteLength/12;return i},A(e)}();function qi(e,t){if(t instanceof Hi)return t;var r=ua(e,t),n=la(e,t),i=n.attributes,o=n.bufferLayout;return new Hi({topology:t.topology||"triangle-list",bufferLayout:o,vertexCount:t.vertexCount,indices:r,attributes:i})}function ua(e,t){if(t.indices){var r=t.indices.value;return e.createBuffer({usage:X.INDEX,data:r})}}function la(e,t){for(var r=[],n={},i=0,o=Object.entries(t.attributes);i<o.length;i++){var s=B(o[i],2),c=s[0],a=s[1],f=c;switch(c){case"POSITION":f="positions";break;case"NORMAL":f="normals";break;case"TEXCOORD_0":f="texCoords";break}n[f]=e.createBuffer({data:a.value,id:"".concat(c,"-buffer")}),r.push({name:f,format:"float32x".concat(a.size)})}var u=t._calculateVertexCount(t.attributes,t.indices);return{attributes:n,bufferLayout:r,vertexCount:u}}function Wi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function xt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Wi(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Wi(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var se=function(){e.getDefaultPipelineFactory=function(n){return n._lumaData.defaultPipelineFactory=n._lumaData.defaultPipelineFactory||new e(n),n._lumaData.defaultPipelineFactory};function e(r){T(this,e),this.device=void 0,this._hashCounter=0,this._hashes={},this._useCounts={},this._pipelineCache={},this.device=r}var t=e.prototype;return t.createRenderPipeline=function(n){var i=xt(xt({},e.defaultProps),n),o=this._hashRenderPipeline(xt({},i));if(!this._pipelineCache[o]){var s=this.device.createRenderPipeline(xt(xt({},i),{},{vs:this.device.createShader({stage:"vertex",source:i.vs}),fs:i.fs?this.device.createShader({stage:"fragment",source:i.fs}):null}));s.hash=o,this._pipelineCache[o]=s,this._useCounts[o]=0}return this._useCounts[o]++,this._pipelineCache[o]},t.release=function(n){var i=n.hash;this._useCounts[i]--,this._useCounts[i]===0&&(this._pipelineCache[i].destroy(),delete this._pipelineCache[i],delete this._useCounts[i])},t._createRenderPipeline=function(n){if(!n.fs)throw new Error("fs");var i=this.device.createRenderPipeline(xt(xt({},n),{},{vs:this.device.createShader({stage:"vertex",source:n.vs}),fs:n.fs?this.device.createShader({stage:"fragment",source:n.fs}):null}));return i},t._hashRenderPipeline=function(n){var i=this._getHash(n.vs),o=n.fs?this._getHash(n.fs):0,s="-";switch(this.device.info.type){case"webgpu":var c=this._getHash(JSON.stringify(n.parameters)),a=this._getHash(JSON.stringify(n.bufferLayout));return"".concat(i,"/").concat(o,"V").concat(s,"T").concat(n.topology,"P").concat(c,"BL").concat(a,"}");default:return"".concat(i,"/").concat(o,"V").concat(s)}},t._getHash=function(n){return this._hashes[n]===void 0&&(this._hashes[n]=this._hashCounter++),this._hashes[n]},A(e)}();se.defaultProps=xt(xt({},Bt.defaultProps),{},{vs:void 0,fs:void 0});function Or(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=ha(e))||t&&e&&typeof e.length=="number"){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(f){throw f},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
227
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return o=f.done,f},e:function(f){s=!0,c=f},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(s)throw c}}}}function ha(e,t){if(e){if(typeof e=="string")return Ki(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ki(e,t)}}function Ki(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Yi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Wt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Yi(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yi(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var ae=function(){function e(r,n){T(this,e),this.device=void 0,this.id=void 0,this.vs=void 0,this.fs=void 0,this.pipelineFactory=void 0,this.userData={},this.parameters=void 0,this.topology=void 0,this.bufferLayout=void 0,this.vertexCount=void 0,this.instanceCount=0,this.indexBuffer=null,this.bufferAttributes={},this.constantAttributes={},this.bindings={},this.uniforms={},this.pipeline=void 0,this.vertexArray=void 0,this._pipelineNeedsUpdate="newly created",this._attributeInfos={},this._gpuGeometry=null,this._getModuleUniforms=void 0,this.props=void 0,this.props=Wt(Wt({},e.defaultProps),n),n=this.props,this.id=n.id||H("model"),this.device=r,Object.assign(this.userData,n.userData);var i={type:r.info.type,shaderLanguage:r.info.shadingLanguages[0],gpu:r.info.gpu,features:r.features},o=this.props.shaderAssembler.assembleShaders(i,this.props),s=o.vs,c=o.fs,a=o.getUniforms;if(this.vs=s,this.fs=c,this._getModuleUniforms=a,this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,n.geometry&&(this._gpuGeometry=this.setGeometry(n.geometry)),this.pipelineFactory=n.pipelineFactory||se.getDefaultPipelineFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=r.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),n.vertexCount&&this.setVertexCount(n.vertexCount),n.instanceCount&&this.setInstanceCount(n.instanceCount),n.indices)throw new Error("Model.props.indices removed. Use props.indexBuffer");n.indexBuffer&&this.setIndexBuffer(n.indexBuffer),n.attributes&&this.setAttributes(n.attributes),n.constantAttributes&&this.setConstantAttributes(n.constantAttributes),n.bindings&&this.setBindings(n.bindings),n.uniforms&&this.setUniforms(n.uniforms),n.moduleSettings&&this.updateModuleSettings(n.moduleSettings),this.setUniforms(this._getModuleUniforms()),Object.seal(this)}var t=e.prototype;return t.destroy=function(){this.pipelineFactory.release(this.pipeline)},t.draw=function(n){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),this.pipeline.setUniforms(this.uniforms),this.pipeline.draw({renderPass:n,vertexArray:this.vertexArray,vertexCount:this.vertexCount,instanceCount:this.instanceCount})},t.setGeometry=function(n){var i=n&&qi(this.device,n);return this.setTopology(i.topology||"triangle-list"),this.bufferLayout=Xi(this.bufferLayout,i.bufferLayout),this.vertexArray&&this._setGeometryAttributes(i),i},t._setGeometryAttributes=function(n){this.vertexCount=n.vertexCount,this.setAttributes(n.attributes),this.setIndexBuffer(n.indices)},t.setTopology=function(n){n!==this.topology&&(this.topology=n,this._setPipelineNeedsUpdate("topology"))},t.setBufferLayout=function(n){this.bufferLayout=this._gpuGeometry?Xi(n,this._gpuGeometry.bufferLayout):n,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)},t.setParameters=function(n){re(n,this.parameters,2)||(this.parameters=n,this._setPipelineNeedsUpdate("parameters"))},t.setVertexCount=function(n){this.vertexCount=n},t.setInstanceCount=function(n){this.instanceCount=n},t.setShaderModuleProps=function(n){var i=this._getModuleUniforms(n),o=Object.keys(i).filter(function(u){return i[u].constructor.name.includes("WEBGL")}),s={},c=Or(o),a;try{for(c.s();!(a=c.n()).done;){var f=a.value;s[f]=i[f],delete i[f]}}catch(u){c.e(u)}finally{c.f()}Object.assign(this.uniforms,i),Object.assign(this.bindings,s)},t.updateModuleSettings=function(n){this.setShaderModuleProps(n)},t.setBindings=function(n){Object.assign(this.bindings,n)},t.setUniforms=function(n){this.pipeline.setUniforms(n),Object.assign(this.uniforms,n)},t.setIndexBuffer=function(n){this.vertexArray.setIndexBuffer(n)},t.setAttributes=function(n){var i=this;n.indices&&K.warn("Model:".concat(this.id," setAttributes() - indexBuffer should be set using setIndexBuffer()"));for(var o=function(){var u,l=B(c[s],2),h=l[0],v=l[1],m=i.bufferLayout.find(function(w){return w.name===h});if(!m)return"continue";var y=m.attributes?(u=m.attributes)===null||u===void 0?void 0:u.map(function(w){return w.attribute}):[m.name],b=!1,O=Or(y),R;try{for(O.s();!(R=O.n()).done;){var x=R.value,S=i._attributeInfos[x];S&&(i.vertexArray.setBuffer(S.location,v),b=!0)}}catch(w){O.e(w)}finally{O.f()}b||K.warn("Model(".concat(i.id,'): Ignoring buffer "').concat(v.id,'" for unknown attribute "').concat(h,'"'))()},s=0,c=Object.entries(n);s<c.length;s++)var a=o()},t.setConstantAttributes=function(n){for(var i=0,o=Object.entries(n);i<o.length;i++){var s=B(o[i],2),c=s[0],a=s[1],f=this._attributeInfos[c];f?this.vertexArray.setConstant(f.location,a):K.warn('Model "'.concat(this.id,': Ignoring constant supplied for unknown attribute "').concat(c,'"'))()}},t._setPipelineNeedsUpdate=function(n){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||n},t._updatePipeline=function(){return this._pipelineNeedsUpdate&&(this.pipeline&&K.log(1,"Model ".concat(this.id,': Recreating pipeline because "').concat(this._pipelineNeedsUpdate,'".'))(),this._pipelineNeedsUpdate=!1,this.pipeline=this.device.createRenderPipeline(Wt(Wt({},this.props),{},{bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:this.device.createShader({id:"{$this.id}-vertex",stage:"vertex",source:this.vs}),fs:this.fs?this.device.createShader({id:"{$this.id}-fragment",stage:"fragment",source:this.fs}):null})),this._attributeInfos=Qe(this.pipeline.shaderLayout,this.bufferLayout)),this.pipeline},A(e)}();ae.defaultProps=Wt(Wt({},Bt.defaultProps),{},{vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:{},geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},pipelineFactory:void 0,shaderAssembler:we.getDefaultShaderAssembler()});function Xi(e,t){var r=ne(e),n=Or(t),i;try{var o=function(){var c=i.value,a=r.findIndex(function(f){return f.name===c.name});a<0?r.push(c):r[a]=c};for(n.s();!(i=n.n()).done;)o()}catch(s){n.e(s)}finally{n.f()}return r}function $i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Zi(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?$i(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$i(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var Ji=function(){e.isSupported=function(n){return!1};function e(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};T(this,e),this.device=void 0,this.gl=void 0,this.elementCount=0,this.elementIDBuffer=null}var t=e.prototype;return t.destroy=function(){},t.delete=function(){this.destroy()},t.run=function(n){var i=n||{},o=i.clearRenderTarget,s=o===void 0?!0:o,c=this._updateDrawOptions(n);s&&c.framebuffer},t.swap=function(){},t.getBuffer=function(n){return null},t.getData=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}},t.getFramebuffer=function(){return null},t.update=function(n){},t._updateModelProps=function(n){var i=Zi({},n);return i},t._buildResourceTransforms=function(n){},t._updateDrawOptions=function(n){var i=Zi({},n);return i},A(e)}();var Qi=function(){function e(r){T(this,e),this.device=void 0,this.shaderModule=void 0,this.useUniformBuffers=void 0,this.uniformBufferLayout=void 0,this.uniformBuffer=null,this.uniforms={},this.modifiedUniforms={},this.modified=!0,this.needsRedraw="initialized",this.device=r.device,this.shaderModule=r.shaderModule,this.useUniformBuffers=this.device.info.type!=="webgl";for(var n={},i=0,o=Object.entries(r.shaderModule.uniforms);i<o.length;i++){var s=B(o[i],2),c=s[0],a=s[1].format;n[c]=a}this.uniformBufferLayout=new tr(n),this.useUniformBuffers&&(this.uniformBuffer=this.device.createBuffer({usage:X.UNIFORM,byteLength:this.uniformBufferLayout.byteLength}))}var t=e.prototype;return t.setUniforms=function(n){for(var i=0,o=Object.entries(n);i<o.length;i++){var s=B(o[i],2),c=s[0],a=s[1];this._setUniform(c,a),this.setNeedsRedraw(c)}},t.setNeedsRedraw=function(n){this.needsRedraw=this.needsRedraw||n},t.getUniformBuffer=function(){if(this.needsRedraw){var n=this.getModifiedUniforms(),i=this.uniformBufferLayout.getData(n);this.uniformBuffer.write(i)}return this.uniformBuffer},t.getUniforms=function(n){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms[n]||{}},t.getModifiedUniforms=function(){var n=this.modifiedUniforms;return this.modifiedUniforms={},this.needsRedraw=!1,n},t._setUniform=function(n,i){pa(this.uniforms[n],i)||(this.uniforms[n]=i,this.modifiedUniforms[n]=!0,this.modified=!0)},A(e)}();function pa(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:16;if(e!==t)return!1;var n=Gt(e);if(!n)return!1;var i=Gt(t);if(i&&n.length===i.length){for(var o=0;o<n.length;++o)if(i[o]!==n[o])return!1}return!0}function to(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function da(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?to(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):to(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var st=function(){function e(r){T(this,e),this.id=void 0,this.topology=void 0,this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.userData={};var n=r.attributes,i=n===void 0?{}:n,o=r.indices,s=o===void 0?null:o,c=r.vertexCount,a=c===void 0?null:c;this.id=r.id||H("geometry"),this.topology=r.topology,s&&(this.indices=ArrayBuffer.isView(s)?{value:s,size:1}:s),this.attributes={};for(var f=0,u=Object.entries(i);f<u.length;f++){var l=B(u[f],2),h=l[0],v=l[1],m=ArrayBuffer.isView(v)?{value:v}:v;rt(ArrayBuffer.isView(m.value),"".concat(this._print(h),": must be typed array or object with value as typed array")),(h==="POSITION"||h==="positions")&&!m.size&&(m.size=3),h==="indices"?(rt(!this.indices),this.indices=m):this.attributes[h]=m}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=a||this._calculateVertexCount(this.attributes,this.indices)}var t=e.prototype;return t.getVertexCount=function(){return this.vertexCount},t.getAttributes=function(){return this.indices?da({indices:this.indices},this.attributes):this.attributes},t._print=function(n){return"Geometry ".concat(this.id," attribute ").concat(n)},t._setAttributes=function(n,i){return this},t._calculateVertexCount=function(n,i){if(i)return i.value.length;for(var o=1/0,s=0,c=Object.values(n);s<c.length;s++){var a=c[s],f=a.value,u=a.size,l=a.constant;!l&&f&&u>=1&&(o=Math.min(o,f.length/u))}return rt(Number.isFinite(o)),o},A(e)}();var eo;function ro(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function no(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ro(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ro(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ma(e){var t=ga();return function(){var n=F(e),i;if(t){var o=F(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return W(this,i)}}function ga(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var va=mn(eo||(eo=$([`attribute vec2 aClipSpacePosition;
|
|
227
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){r=r.call(e)},n:function(){var f=r.next();return o=f.done,f},e:function(f){s=!0,c=f},f:function(){try{!o&&r.return!=null&&r.return()}finally{if(s)throw c}}}}function ha(e,t){if(e){if(typeof e=="string")return Ki(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ki(e,t)}}function Ki(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Yi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Wt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Yi(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yi(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var ae=function(){function e(r,n){T(this,e),this.device=void 0,this.id=void 0,this.vs=void 0,this.fs=void 0,this.pipelineFactory=void 0,this.userData={},this.parameters=void 0,this.topology=void 0,this.bufferLayout=void 0,this.vertexCount=void 0,this.instanceCount=0,this.indexBuffer=null,this.bufferAttributes={},this.constantAttributes={},this.bindings={},this.uniforms={},this.pipeline=void 0,this.vertexArray=void 0,this._pipelineNeedsUpdate="newly created",this._attributeInfos={},this._gpuGeometry=null,this._getModuleUniforms=void 0,this.props=void 0,this.props=Wt(Wt({},e.defaultProps),n),n=this.props,this.id=n.id||H("model"),this.device=r,Object.assign(this.userData,n.userData);var i={type:r.info.type,shaderLanguage:r.info.shadingLanguages[0],gpu:r.info.gpu,features:r.features},o=this.props.shaderAssembler.assembleShaders(i,this.props),s=o.vs,c=o.fs,a=o.getUniforms;if(this.vs=s,this.fs=c,this._getModuleUniforms=a,this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,n.geometry&&(this._gpuGeometry=this.setGeometry(n.geometry)),this.pipelineFactory=n.pipelineFactory||se.getDefaultPipelineFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=r.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),n.vertexCount&&this.setVertexCount(n.vertexCount),n.instanceCount&&this.setInstanceCount(n.instanceCount),n.indices)throw new Error("Model.props.indices removed. Use props.indexBuffer");n.indexBuffer&&this.setIndexBuffer(n.indexBuffer),n.attributes&&this.setAttributes(n.attributes),n.constantAttributes&&this.setConstantAttributes(n.constantAttributes),n.bindings&&this.setBindings(n.bindings),n.uniforms&&this.setUniforms(n.uniforms),n.moduleSettings&&this.updateModuleSettings(n.moduleSettings),this.setUniforms(this._getModuleUniforms()),Object.seal(this)}var t=e.prototype;return t.destroy=function(){this.pipelineFactory.release(this.pipeline)},t.draw=function(n){this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings),this.pipeline.setUniforms(this.uniforms),this.pipeline.draw({renderPass:n,vertexArray:this.vertexArray,vertexCount:this.vertexCount,instanceCount:this.instanceCount})},t.setGeometry=function(n){var i=n&&qi(this.device,n);return this.setTopology(i.topology||"triangle-list"),this.bufferLayout=Xi(this.bufferLayout,i.bufferLayout),this.vertexArray&&this._setGeometryAttributes(i),i},t._setGeometryAttributes=function(n){this.vertexCount=n.vertexCount,this.setAttributes(n.attributes),this.setIndexBuffer(n.indices)},t.setTopology=function(n){n!==this.topology&&(this.topology=n,this._setPipelineNeedsUpdate("topology"))},t.setBufferLayout=function(n){this.bufferLayout=this._gpuGeometry?Xi(n,this._gpuGeometry.bufferLayout):n,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)},t.setParameters=function(n){re(n,this.parameters,2)||(this.parameters=n,this._setPipelineNeedsUpdate("parameters"))},t.setVertexCount=function(n){this.vertexCount=n},t.setInstanceCount=function(n){this.instanceCount=n},t.setShaderModuleProps=function(n){var i=this._getModuleUniforms(n),o=Object.keys(i).filter(function(u){var l=i[u];return!Array.isArray(l)&&typeof l!="number"&&typeof l!="boolean"}),s={},c=Or(o),a;try{for(c.s();!(a=c.n()).done;){var f=a.value;s[f]=i[f],delete i[f]}}catch(u){c.e(u)}finally{c.f()}Object.assign(this.uniforms,i),Object.assign(this.bindings,s)},t.updateModuleSettings=function(n){this.setShaderModuleProps(n)},t.setBindings=function(n){Object.assign(this.bindings,n)},t.setUniforms=function(n){this.pipeline.setUniforms(n),Object.assign(this.uniforms,n)},t.setIndexBuffer=function(n){this.vertexArray.setIndexBuffer(n)},t.setAttributes=function(n){var i=this;n.indices&&K.warn("Model:".concat(this.id," setAttributes() - indexBuffer should be set using setIndexBuffer()"));for(var o=function(){var u,l=B(c[s],2),h=l[0],v=l[1],m=i.bufferLayout.find(function(w){return w.name===h});if(!m)return"continue";var y=m.attributes?(u=m.attributes)===null||u===void 0?void 0:u.map(function(w){return w.attribute}):[m.name],b=!1,O=Or(y),R;try{for(O.s();!(R=O.n()).done;){var x=R.value,S=i._attributeInfos[x];S&&(i.vertexArray.setBuffer(S.location,v),b=!0)}}catch(w){O.e(w)}finally{O.f()}b||K.warn("Model(".concat(i.id,'): Ignoring buffer "').concat(v.id,'" for unknown attribute "').concat(h,'"'))()},s=0,c=Object.entries(n);s<c.length;s++)var a=o()},t.setConstantAttributes=function(n){for(var i=0,o=Object.entries(n);i<o.length;i++){var s=B(o[i],2),c=s[0],a=s[1],f=this._attributeInfos[c];f?this.vertexArray.setConstant(f.location,a):K.warn('Model "'.concat(this.id,': Ignoring constant supplied for unknown attribute "').concat(c,'"'))()}},t._setPipelineNeedsUpdate=function(n){this._pipelineNeedsUpdate=this._pipelineNeedsUpdate||n},t._updatePipeline=function(){return this._pipelineNeedsUpdate&&(this.pipeline&&K.log(1,"Model ".concat(this.id,': Recreating pipeline because "').concat(this._pipelineNeedsUpdate,'".'))(),this._pipelineNeedsUpdate=!1,this.pipeline=this.device.createRenderPipeline(Wt(Wt({},this.props),{},{bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:this.device.createShader({id:"{$this.id}-vertex",stage:"vertex",source:this.vs}),fs:this.fs?this.device.createShader({id:"{$this.id}-fragment",stage:"fragment",source:this.fs}):null})),this._attributeInfos=Qe(this.pipeline.shaderLayout,this.bufferLayout)),this.pipeline},A(e)}();ae.defaultProps=Wt(Wt({},Bt.defaultProps),{},{vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:{},geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},pipelineFactory:void 0,shaderAssembler:we.getDefaultShaderAssembler()});function Xi(e,t){var r=ne(e),n=Or(t),i;try{var o=function(){var c=i.value,a=r.findIndex(function(f){return f.name===c.name});a<0?r.push(c):r[a]=c};for(n.s();!(i=n.n()).done;)o()}catch(s){n.e(s)}finally{n.f()}return r}function $i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function Zi(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?$i(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$i(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var Ji=function(){e.isSupported=function(n){return!1};function e(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};T(this,e),this.device=void 0,this.gl=void 0,this.elementCount=0,this.elementIDBuffer=null}var t=e.prototype;return t.destroy=function(){},t.delete=function(){this.destroy()},t.run=function(n){var i=n||{},o=i.clearRenderTarget,s=o===void 0?!0:o,c=this._updateDrawOptions(n);s&&c.framebuffer},t.swap=function(){},t.getBuffer=function(n){return null},t.getData=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}},t.getFramebuffer=function(){return null},t.update=function(n){},t._updateModelProps=function(n){var i=Zi({},n);return i},t._buildResourceTransforms=function(n){},t._updateDrawOptions=function(n){var i=Zi({},n);return i},A(e)}();var Qi=function(){function e(r){T(this,e),this.device=void 0,this.shaderModule=void 0,this.useUniformBuffers=void 0,this.uniformBufferLayout=void 0,this.uniformBuffer=null,this.uniforms={},this.modifiedUniforms={},this.modified=!0,this.needsRedraw="initialized",this.device=r.device,this.shaderModule=r.shaderModule,this.useUniformBuffers=this.device.info.type!=="webgl";for(var n={},i=0,o=Object.entries(r.shaderModule.uniforms);i<o.length;i++){var s=B(o[i],2),c=s[0],a=s[1].format;n[c]=a}this.uniformBufferLayout=new tr(n),this.useUniformBuffers&&(this.uniformBuffer=this.device.createBuffer({usage:X.UNIFORM,byteLength:this.uniformBufferLayout.byteLength}))}var t=e.prototype;return t.setUniforms=function(n){for(var i=0,o=Object.entries(n);i<o.length;i++){var s=B(o[i],2),c=s[0],a=s[1];this._setUniform(c,a),this.setNeedsRedraw(c)}},t.setNeedsRedraw=function(n){this.needsRedraw=this.needsRedraw||n},t.getUniformBuffer=function(){if(this.needsRedraw){var n=this.getModifiedUniforms(),i=this.uniformBufferLayout.getData(n);this.uniformBuffer.write(i)}return this.uniformBuffer},t.getUniforms=function(n){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms[n]||{}},t.getModifiedUniforms=function(){var n=this.modifiedUniforms;return this.modifiedUniforms={},this.needsRedraw=!1,n},t._setUniform=function(n,i){pa(this.uniforms[n],i)||(this.uniforms[n]=i,this.modifiedUniforms[n]=!0,this.modified=!0)},A(e)}();function pa(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:16;if(e!==t)return!1;var n=Gt(e);if(!n)return!1;var i=Gt(t);if(i&&n.length===i.length){for(var o=0;o<n.length;++o)if(i[o]!==n[o])return!1}return!0}function to(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function da(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?to(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):to(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var st=function(){function e(r){T(this,e),this.id=void 0,this.topology=void 0,this.vertexCount=void 0,this.indices=void 0,this.attributes=void 0,this.userData={};var n=r.attributes,i=n===void 0?{}:n,o=r.indices,s=o===void 0?null:o,c=r.vertexCount,a=c===void 0?null:c;this.id=r.id||H("geometry"),this.topology=r.topology,s&&(this.indices=ArrayBuffer.isView(s)?{value:s,size:1}:s),this.attributes={};for(var f=0,u=Object.entries(i);f<u.length;f++){var l=B(u[f],2),h=l[0],v=l[1],m=ArrayBuffer.isView(v)?{value:v}:v;rt(ArrayBuffer.isView(m.value),"".concat(this._print(h),": must be typed array or object with value as typed array")),(h==="POSITION"||h==="positions")&&!m.size&&(m.size=3),h==="indices"?(rt(!this.indices),this.indices=m):this.attributes[h]=m}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=a||this._calculateVertexCount(this.attributes,this.indices)}var t=e.prototype;return t.getVertexCount=function(){return this.vertexCount},t.getAttributes=function(){return this.indices?da({indices:this.indices},this.attributes):this.attributes},t._print=function(n){return"Geometry ".concat(this.id," attribute ").concat(n)},t._setAttributes=function(n,i){return this},t._calculateVertexCount=function(n,i){if(i)return i.value.length;for(var o=1/0,s=0,c=Object.values(n);s<c.length;s++){var a=c[s],f=a.value,u=a.size,l=a.constant;!l&&f&&u>=1&&(o=Math.min(o,f.length/u))}return rt(Number.isFinite(o)),o},A(e)}();var eo;function ro(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function no(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ro(Object(r),!0).forEach(function(n){L(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ro(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ma(e){var t=ga();return function(){var n=F(e),i;if(t){var o=F(this).constructor;i=Reflect.construct(n,arguments,o)}else i=n.apply(this,arguments);return W(this,i)}}function ga(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var va=mn(eo||(eo=$([`attribute vec2 aClipSpacePosition;
|
|
228
228
|
attribute vec2 aTexCoord;
|
|
229
229
|
attribute vec2 aCoordinate;
|
|
230
230
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/engine",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.41",
|
|
4
4
|
"description": "WebGL2 Components for High Performance Rendering and Computation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
44
|
-
"@luma.gl/core": "9.0.0-alpha.
|
|
45
|
-
"@luma.gl/shadertools": "9.0.0-alpha.
|
|
43
|
+
"@luma.gl/constants": "9.0.0-alpha.41",
|
|
44
|
+
"@luma.gl/core": "9.0.0-alpha.41",
|
|
45
|
+
"@luma.gl/shadertools": "9.0.0-alpha.41",
|
|
46
46
|
"@math.gl/core": "^4.0.0",
|
|
47
47
|
"@probe.gl/log": "^4.0.2",
|
|
48
48
|
"@probe.gl/stats": "^4.0.2"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "e8a5f47c6890d0b1883979c09114676b8fa90cc6"
|
|
51
51
|
}
|
|
Binary file
|
package/src/model/model.ts
CHANGED
|
@@ -348,7 +348,10 @@ export class Model {
|
|
|
348
348
|
|
|
349
349
|
// Extract textures & framebuffers set by the modules
|
|
350
350
|
// TODO better way to extract bindings
|
|
351
|
-
const keys = Object.keys(uniforms).filter(k =>
|
|
351
|
+
const keys = Object.keys(uniforms).filter(k => {
|
|
352
|
+
const uniform = uniforms[k];
|
|
353
|
+
return !Array.isArray(uniform) && (typeof uniform !== 'number') && (typeof uniform !== 'boolean');
|
|
354
|
+
});
|
|
352
355
|
const bindings: Record<string, Binding> = {};
|
|
353
356
|
for (const k of keys) {
|
|
354
357
|
bindings[k] = uniforms[k];
|