@luma.gl/gltf 9.1.0-alpha.16 → 9.1.0-alpha.18
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 +56 -27
- package/dist/dist.min.js +5 -5
- package/dist/gltf/create-gltf-model.d.ts.map +1 -1
- package/dist/gltf/create-gltf-model.js +11 -6
- package/dist/gltf/gltf-instantiator.d.ts.map +1 -1
- package/dist/gltf/gltf-instantiator.js +23 -2
- package/dist/index.cjs +50 -27
- package/dist/index.cjs.map +2 -2
- package/dist/pbr/parse-pbr-material.d.ts +4 -3
- package/dist/pbr/parse-pbr-material.d.ts.map +1 -1
- package/dist/pbr/parse-pbr-material.js +40 -40
- package/package.json +5 -5
- package/src/gltf/create-gltf-model.ts +13 -6
- package/src/gltf/gltf-instantiator.ts +25 -2
- package/src/pbr/parse-pbr-material.ts +50 -43
package/dist/dist.dev.js
CHANGED
|
@@ -80,9 +80,9 @@ var __exports__ = (() => {
|
|
|
80
80
|
bindings: {},
|
|
81
81
|
uniforms: {
|
|
82
82
|
// TODO: find better values?
|
|
83
|
-
|
|
83
|
+
camera: [0, 0, 0],
|
|
84
84
|
// Model should override
|
|
85
|
-
|
|
85
|
+
metallicRoughnessValues: [1, 1]
|
|
86
86
|
// Default is 1 and 1
|
|
87
87
|
},
|
|
88
88
|
parameters: {},
|
|
@@ -92,15 +92,15 @@ var __exports__ = (() => {
|
|
|
92
92
|
parsedMaterial.defines.USE_TEX_LOD = 1;
|
|
93
93
|
const { imageBasedLightingEnvironment } = options;
|
|
94
94
|
if (imageBasedLightingEnvironment) {
|
|
95
|
-
parsedMaterial.bindings.
|
|
96
|
-
parsedMaterial.bindings.
|
|
97
|
-
parsedMaterial.bindings.
|
|
98
|
-
parsedMaterial.uniforms.
|
|
95
|
+
parsedMaterial.bindings.pbr_diffuseEnvSampler = imageBasedLightingEnvironment.diffuseEnvSampler.texture;
|
|
96
|
+
parsedMaterial.bindings.pbr_specularEnvSampler = imageBasedLightingEnvironment.specularEnvSampler.texture;
|
|
97
|
+
parsedMaterial.bindings.pbr_BrdfLUT = imageBasedLightingEnvironment.brdfLutTexture.texture;
|
|
98
|
+
parsedMaterial.uniforms.scaleIBLAmbient = [1, 1];
|
|
99
99
|
}
|
|
100
100
|
if (options?.pbrDebug) {
|
|
101
101
|
parsedMaterial.defines.PBR_DEBUG = 1;
|
|
102
|
-
parsedMaterial.uniforms.
|
|
103
|
-
parsedMaterial.uniforms.
|
|
102
|
+
parsedMaterial.uniforms.scaleDiffBaseMR = [0, 0, 0, 0];
|
|
103
|
+
parsedMaterial.uniforms.scaleFGDSpec = [0, 0, 0, 0];
|
|
104
104
|
}
|
|
105
105
|
if (attributes.NORMAL)
|
|
106
106
|
parsedMaterial.defines.HAS_NORMALS = 1;
|
|
@@ -118,41 +118,47 @@ var __exports__ = (() => {
|
|
|
118
118
|
return parsedMaterial;
|
|
119
119
|
}
|
|
120
120
|
function parseMaterial(device, material, parsedMaterial) {
|
|
121
|
-
parsedMaterial.uniforms.
|
|
121
|
+
parsedMaterial.uniforms.unlit = Boolean(material.unlit);
|
|
122
122
|
if (material.pbrMetallicRoughness) {
|
|
123
123
|
parsePbrMetallicRoughness(device, material.pbrMetallicRoughness, parsedMaterial);
|
|
124
124
|
}
|
|
125
125
|
if (material.normalTexture) {
|
|
126
|
-
addTexture(
|
|
126
|
+
addTexture(
|
|
127
|
+
device,
|
|
128
|
+
material.normalTexture,
|
|
129
|
+
"pbr_normalSampler",
|
|
130
|
+
"HAS_NORMALMAP",
|
|
131
|
+
parsedMaterial
|
|
132
|
+
);
|
|
127
133
|
const { scale: scale4 = 1 } = material.normalTexture;
|
|
128
|
-
parsedMaterial.uniforms.
|
|
134
|
+
parsedMaterial.uniforms.normalScale = scale4;
|
|
129
135
|
}
|
|
130
136
|
if (material.occlusionTexture) {
|
|
131
137
|
addTexture(
|
|
132
138
|
device,
|
|
133
139
|
material.occlusionTexture,
|
|
134
|
-
"
|
|
140
|
+
"pbr_occlusionSampler",
|
|
135
141
|
"HAS_OCCLUSIONMAP",
|
|
136
142
|
parsedMaterial
|
|
137
143
|
);
|
|
138
144
|
const { strength = 1 } = material.occlusionTexture;
|
|
139
|
-
parsedMaterial.uniforms.
|
|
145
|
+
parsedMaterial.uniforms.occlusionStrength = strength;
|
|
140
146
|
}
|
|
141
147
|
if (material.emissiveTexture) {
|
|
142
148
|
addTexture(
|
|
143
149
|
device,
|
|
144
150
|
material.emissiveTexture,
|
|
145
|
-
"
|
|
151
|
+
"pbr_emissiveSampler",
|
|
146
152
|
"HAS_EMISSIVEMAP",
|
|
147
153
|
parsedMaterial
|
|
148
154
|
);
|
|
149
|
-
parsedMaterial.uniforms.
|
|
155
|
+
parsedMaterial.uniforms.emissiveFactor = material.emissiveFactor || [0, 0, 0];
|
|
150
156
|
}
|
|
151
157
|
switch (material.alphaMode) {
|
|
152
158
|
case "MASK":
|
|
153
159
|
const { alphaCutoff = 0.5 } = material;
|
|
154
160
|
parsedMaterial.defines.ALPHA_CUTOFF = 1;
|
|
155
|
-
parsedMaterial.uniforms.
|
|
161
|
+
parsedMaterial.uniforms.alphaCutoff = alphaCutoff;
|
|
156
162
|
break;
|
|
157
163
|
case "BLEND":
|
|
158
164
|
import_core.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")();
|
|
@@ -178,23 +184,23 @@ var __exports__ = (() => {
|
|
|
178
184
|
addTexture(
|
|
179
185
|
device,
|
|
180
186
|
pbrMetallicRoughness.baseColorTexture,
|
|
181
|
-
"
|
|
187
|
+
"pbr_baseColorSampler",
|
|
182
188
|
"HAS_BASECOLORMAP",
|
|
183
189
|
parsedMaterial
|
|
184
190
|
);
|
|
185
191
|
}
|
|
186
|
-
parsedMaterial.uniforms.
|
|
192
|
+
parsedMaterial.uniforms.baseColorFactor = pbrMetallicRoughness.baseColorFactor || [1, 1, 1, 1];
|
|
187
193
|
if (pbrMetallicRoughness.metallicRoughnessTexture) {
|
|
188
194
|
addTexture(
|
|
189
195
|
device,
|
|
190
196
|
pbrMetallicRoughness.metallicRoughnessTexture,
|
|
191
|
-
"
|
|
197
|
+
"pbr_metallicRoughnessSampler",
|
|
192
198
|
"HAS_METALROUGHNESSMAP",
|
|
193
199
|
parsedMaterial
|
|
194
200
|
);
|
|
195
201
|
}
|
|
196
202
|
const { metallicFactor = 1, roughnessFactor = 1 } = pbrMetallicRoughness;
|
|
197
|
-
parsedMaterial.uniforms.
|
|
203
|
+
parsedMaterial.uniforms.metallicRoughnessValues = [metallicFactor, roughnessFactor];
|
|
198
204
|
}
|
|
199
205
|
function addTexture(device, gltfTexture, uniformName, define = null, parsedMaterial) {
|
|
200
206
|
const parameters = gltfTexture?.texture?.sampler?.parameters || {};
|
|
@@ -3671,7 +3677,7 @@ layout(0) positions: vec4; // in vec4 POSITION;
|
|
|
3671
3677
|
#endif
|
|
3672
3678
|
|
|
3673
3679
|
pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0);
|
|
3674
|
-
gl_Position =
|
|
3680
|
+
gl_Position = pbrProjection.modelViewProjectionMatrix * positions;
|
|
3675
3681
|
}
|
|
3676
3682
|
`
|
|
3677
3683
|
);
|
|
@@ -3705,14 +3711,19 @@ layout(0) positions: vec4; // in vec4 POSITION;
|
|
|
3705
3711
|
geometry,
|
|
3706
3712
|
topology: geometry.topology,
|
|
3707
3713
|
vertexCount,
|
|
3708
|
-
modules: [import_shadertools.
|
|
3714
|
+
modules: [import_shadertools.pbrMaterial],
|
|
3709
3715
|
...modelOptions,
|
|
3710
|
-
bindings: { ...parsedMaterial.bindings, ...modelOptions.bindings },
|
|
3711
3716
|
defines: { ...parsedMaterial.defines, ...modelOptions.defines },
|
|
3712
|
-
parameters: { ...parameters, ...parsedMaterial.parameters, ...modelOptions.parameters }
|
|
3713
|
-
uniforms: { ...parsedMaterial.uniforms, ...modelOptions.uniforms }
|
|
3717
|
+
parameters: { ...parameters, ...parsedMaterial.parameters, ...modelOptions.parameters }
|
|
3714
3718
|
};
|
|
3715
3719
|
const model = new import_engine2.Model(device, modelProps);
|
|
3720
|
+
const { camera, ...pbrMaterialProps } = {
|
|
3721
|
+
...parsedMaterial.uniforms,
|
|
3722
|
+
...modelOptions.uniforms,
|
|
3723
|
+
...parsedMaterial.bindings,
|
|
3724
|
+
...modelOptions.bindings
|
|
3725
|
+
};
|
|
3726
|
+
model.shaderInputs.setProps({ pbrMaterial: pbrMaterialProps, pbrProjection: { camera } });
|
|
3716
3727
|
return new import_engine2.ModelNode({ managedResources, model });
|
|
3717
3728
|
}
|
|
3718
3729
|
|
|
@@ -3751,8 +3762,8 @@ layout(0) positions: vec4; // in vec4 POSITION;
|
|
|
3751
3762
|
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
3752
3763
|
}
|
|
3753
3764
|
instantiate(gltf) {
|
|
3754
|
-
this.gltf = gltf;
|
|
3755
|
-
const scenes = (gltf.scenes || []).map((scene) => this.createScene(scene));
|
|
3765
|
+
this.gltf = deepCopy(gltf);
|
|
3766
|
+
const scenes = (this.gltf.scenes || []).map((scene) => this.createScene(scene));
|
|
3756
3767
|
return scenes;
|
|
3757
3768
|
}
|
|
3758
3769
|
createAnimator() {
|
|
@@ -3798,6 +3809,8 @@ layout(0) positions: vec4; // in vec4 POSITION;
|
|
|
3798
3809
|
}
|
|
3799
3810
|
gltfNode._node = node;
|
|
3800
3811
|
}
|
|
3812
|
+
const topLevelNode = this.gltf.nodes.find((node) => node.id === gltfNode.id);
|
|
3813
|
+
topLevelNode._node = gltfNode._node;
|
|
3801
3814
|
return gltfNode._node;
|
|
3802
3815
|
}
|
|
3803
3816
|
createMesh(gltfMesh) {
|
|
@@ -3874,6 +3887,22 @@ layout(0) positions: vec4; // in vec4 POSITION;
|
|
|
3874
3887
|
return false;
|
|
3875
3888
|
}
|
|
3876
3889
|
};
|
|
3890
|
+
function deepCopy(object) {
|
|
3891
|
+
if (ArrayBuffer.isView(object) || object instanceof ArrayBuffer) {
|
|
3892
|
+
return object;
|
|
3893
|
+
}
|
|
3894
|
+
if (Array.isArray(object)) {
|
|
3895
|
+
return object.map(deepCopy);
|
|
3896
|
+
}
|
|
3897
|
+
if (object && typeof object === "object") {
|
|
3898
|
+
const result = {};
|
|
3899
|
+
for (const key in object) {
|
|
3900
|
+
result[key] = deepCopy(object[key]);
|
|
3901
|
+
}
|
|
3902
|
+
return result;
|
|
3903
|
+
}
|
|
3904
|
+
return object;
|
|
3905
|
+
}
|
|
3877
3906
|
|
|
3878
3907
|
// src/gltf/create-gltf-objects.ts
|
|
3879
3908
|
function createScenegraphsFromGLTF(device, gltf, options) {
|
package/dist/dist.min.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['luma'] = factory();
|
|
6
6
|
else root['luma'] = factory();})(globalThis, function () {
|
|
7
|
-
var __exports__=(()=>{var Se=Object.create;var it=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var Ot=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),Le=(n,t)=>{for(var e in t)it(n,e,{get:t[e],enumerable:!0})},st=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Oe(t))!Ne.call(n,s)&&s!==e&&it(n,s,{get:()=>t[s],enumerable:!(r=we(t,s))||r.enumerable});return n},ct=(n,t,e)=>(st(n,t,"default"),e&&st(e,t,"default")),B=(n,t,e)=>(e=n!=null?Se(Re(n)):{},st(t||!n||!n.__esModule?it(e,"default",{value:n,enumerable:!0}):e,n)),_e=n=>st(it({},"__esModule",{value:!0}),n);var j=Ot((Wr,jt)=>{jt.exports=globalThis.luma});var at=Ot((Hr,Qt)=>{Qt.exports=globalThis.luma});var ge=Ot((Qi,Me)=>{Me.exports=globalThis.luma});var rt={};Le(rt,{GLTFAnimator:()=>G,createScenegraphsFromGLTF:()=>Ee,loadPBREnvironment:()=>mn,parsePBRMaterial:()=>ot});ct(rt,B(j(),1));var Kt=B(j(),1),z;(function(n){n[n.FUNC_ADD=32774]="FUNC_ADD",n[n.ONE=1]="ONE",n[n.SRC_ALPHA=770]="SRC_ALPHA",n[n.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",n[n.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",n[n.LINEAR=9729]="LINEAR",n[n.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",n[n.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(z||(z={}));function ot(n,t,e,r){let s={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=1;let{imageBasedLightingEnvironment:i}=r;return i&&(s.bindings.u_DiffuseEnvSampler=i.diffuseEnvSampler.texture,s.bindings.u_SpecularEnvSampler=i.specularEnvSampler.texture,s.bindings.u_brdfLUT=i.brdfLutTexture.texture,s.uniforms.u_ScaleIBLAmbient=[1,1]),r?.pbrDebug&&(s.defines.PBR_DEBUG=1,s.uniforms.u_ScaleDiffBaseMR=[0,0,0,0],s.uniforms.u_ScaleFGDSpec=[0,0,0,0]),e.NORMAL&&(s.defines.HAS_NORMALS=1),e.TANGENT&&r?.useTangents&&(s.defines.HAS_TANGENTS=1),e.TEXCOORD_0&&(s.defines.HAS_UV=1),r?.imageBasedLightingEnvironment&&(s.defines.USE_IBL=1),r?.lights&&(s.defines.USE_LIGHTS=1),t&&Ie(n,t,s),s}function Ie(n,t,e){if(e.uniforms.pbr_uUnlit=Boolean(t.unlit),t.pbrMetallicRoughness&&Pe(n,t.pbrMetallicRoughness,e),t.normalTexture){K(n,t.normalTexture,"u_NormalSampler","HAS_NORMALMAP",e);let{scale:r=1}=t.normalTexture;e.uniforms.u_NormalScale=r}if(t.occlusionTexture){K(n,t.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP",e);let{strength:r=1}=t.occlusionTexture;e.uniforms.u_OcclusionStrength=r}switch(t.emissiveTexture&&(K(n,t.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP",e),e.uniforms.u_EmissiveFactor=t.emissiveFactor||[0,0,0]),t.alphaMode){case"MASK":let{alphaCutoff:r=.5}=t;e.defines.ALPHA_CUTOFF=1,e.uniforms.u_AlphaCutoff=r;break;case"BLEND":Kt.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="src-alpha",e.parameters.blendColorDstFactor="one-minus-src-alpha",e.parameters.blendAlphaOperation="add",e.parameters.blendAlphaSrcFactor="one",e.parameters.blendAlphaDstFactor="one-minus-src-alpha",e.glParameters.blend=!0,e.glParameters.blendEquation=z.FUNC_ADD,e.glParameters.blendFunc=[z.SRC_ALPHA,z.ONE_MINUS_SRC_ALPHA,z.ONE,z.ONE_MINUS_SRC_ALPHA];break}}function Pe(n,t,e){t.baseColorTexture&&K(n,t.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP",e),e.uniforms.u_BaseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&K(n,t.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP",e);let{metallicFactor:r=1,roughnessFactor:s=1}=t;e.uniforms.u_MetallicRoughnessValues=[r,s]}function K(n,t,e,r=null,s){let i=t?.texture?.sampler?.parameters||{},c=t.texture.source.image,o,a={};c.compressed?(o=c,a={[z.TEXTURE_MIN_FILTER]:c.data.length>1?z.LINEAR_MIPMAP_NEAREST:z.LINEAR}):o={data:c};let h=n.createTexture({id:t.uniformName||t.id,parameters:{...i,...a},pixelStore:{[z.UNPACK_FLIP_Y_WEBGL]:!1},...o});s.bindings[e]=h,r&&(s.defines[r]=1),s.generatedTextures.push(h)}var zt=B(at(),1);function V(n,t){if(!n)throw new Error(t||"loader assertion failed.")}var b={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},ve=b.self||b.window||b.global||{},ue=b.window||b.self||b.global||{},ke=b.global||b.self||b.window||{},ze=b.document||{};var Rt=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Zt=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),be=Zt&&parseFloat(Zt[1])||0;var qe="",Jt={};function Nt(n){for(let t in Jt)if(n.startsWith(t)){let e=Jt[t];n=n.replace(t,e)}return!n.startsWith("http://")&&!n.startsWith("https://")&&(n=`${qe}${n}`),n}var tn="4.2.1";var Fe=globalThis.loaders?.parseImageNode,Lt=typeof Image<"u",_t=typeof ImageBitmap<"u",Ce=Boolean(Fe),It=Rt?!0:Ce;function nn(n){switch(n){case"auto":return _t||Lt||It;case"imagebitmap":return _t;case"image":return Lt;case"data":return It;default:throw new Error(`@loaders.gl/images: image ${n} not supported in this environment`)}}function en(){if(_t)return"imagebitmap";if(Lt)return"image";if(It)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function rn(n){let t=Be(n);if(!t)throw new Error("Not an image");return t}function Pt(n){return ht(n)}function ht(n){switch(rn(n)){case"data":return n;case"image":case"imagebitmap":let t=document.createElement("canvas"),e=t.getContext("2d");if(!e)throw new Error("getImageData");return t.width=n.width,t.height=n.height,e.drawImage(n,0,0),e.getImageData(0,0,n.width,n.height);default:throw new Error("getImageData")}}function Be(n){return typeof ImageBitmap<"u"&&n instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&n instanceof Image?"image":n&&typeof n=="object"&&n.data&&n.width&&n.height?"data":null}var Ue=/^data:image\/svg\+xml/,Ve=/\.svg((\?|#).*)?$/;function ft(n){return n&&(Ue.test(n)||Ve.test(n))}function sn(n,t){if(ft(t)){let r=new TextDecoder().decode(n);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return vt(n,t)}function vt(n,t){if(ft(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(n)])}async function lt(n,t,e){let r=sn(n,e),s=self.URL||self.webkitURL,i=typeof r!="string"&&s.createObjectURL(r);try{return await De(i||r,t)}finally{i&&s.revokeObjectURL(i)}}async function De(n,t){let e=new Image;return e.src=n,t.image&&t.image.decode&&e.decode?(await e.decode(),e):await new Promise((r,s)=>{try{e.onload=()=>r(e),e.onerror=i=>{let c=i instanceof Error?i.message:"error";s(new Error(c))}}catch(i){s(i)}})}var Ye={},cn=!0;async function on(n,t,e){let r;ft(e)?r=await lt(n,t,e):r=vt(n,e);let s=t&&t.imagebitmap;return await $e(r,s)}async function $e(n,t=null){if((We(t)||!cn)&&(t=null),t)try{return await createImageBitmap(n,t)}catch(e){console.warn(e),cn=!1}return await createImageBitmap(n)}function We(n){for(let t in n||Ye)return!1;return!0}function an(n){return!je(n,"ftyp",4)||!(n[8]&96)?null:Ge(n)}function Ge(n){switch(He(n,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function He(n,t,e){return String.fromCharCode(...n.slice(t,e))}function Xe(n){return[...n].map(t=>t.charCodeAt(0))}function je(n,t,e=0){let r=Xe(t);for(let s=0;s<r.length;++s)if(r[s]!==n[s+e])return!1;return!0}var q=!1,Q=!0;function pt(n){let t=Z(n);return Qe(t)||tr(t)||Ze(t)||Je(t)||Ke(t)}function Ke(n){let t=new Uint8Array(n instanceof DataView?n.buffer:n),e=an(t);return e?{mimeType:e.mimeType,width:0,height:0}:null}function Qe(n){let t=Z(n);return t.byteLength>=24&&t.getUint32(0,q)===2303741511?{mimeType:"image/png",width:t.getUint32(16,q),height:t.getUint32(20,q)}:null}function Ze(n){let t=Z(n);return t.byteLength>=10&&t.getUint32(0,q)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,Q),height:t.getUint16(8,Q)}:null}function Je(n){let t=Z(n);return t.byteLength>=14&&t.getUint16(0,q)===16973&&t.getUint32(2,Q)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,Q),height:t.getUint32(22,Q)}:null}function tr(n){let t=Z(n);if(!(t.byteLength>=3&&t.getUint16(0,q)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=nr(),i=2;for(;i+9<t.byteLength;){let c=t.getUint16(i,q);if(s.has(c))return{mimeType:"image/jpeg",height:t.getUint16(i+5,q),width:t.getUint16(i+7,q)};if(!r.has(c))return null;i+=2,i+=t.getUint16(i,q)}return null}function nr(){let n=new Set([65499,65476,65484,65501,65534]);for(let e=65504;e<65520;++e)n.add(e);return{tableMarkers:n,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Z(n){if(n instanceof DataView)return n;if(ArrayBuffer.isView(n))return new DataView(n.buffer);if(n instanceof ArrayBuffer)return new DataView(n);throw new Error("toDataView")}async function hn(n,t){let{mimeType:e}=pt(n)||{},r=globalThis.loaders?.parseImageNode;return V(r),await r(n,e)}async function fn(n,t,e){t=t||{};let s=(t.image||{}).type||"auto",{url:i}=e||{},c=er(s),o;switch(c){case"imagebitmap":o=await on(n,t,i);break;case"image":o=await lt(n,t,i);break;case"data":o=await hn(n,t);break;default:V(!1)}return s==="data"&&(o=ht(o)),o}function er(n){switch(n){case"auto":case"data":return en();default:return nn(n),n}}var rr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],sr=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],ir={image:{type:"auto",decode:!0}},xt={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:tn,mimeTypes:sr,extensions:rr,parse:fn,tests:[n=>Boolean(pt(new DataView(n)))],options:ir};function mt(n,t,e){let r=typeof n=="function"?n({...t,...e}):n,s=t.baseUrl;return s&&(r=s[s.length-1]==="/"?`${s}${r}`:`${s}/${r}`),Nt(r)}var cr=n=>n&&typeof n=="object";async function ln(n,t,e={}){return await ut(n,t,e)}async function ut(n,t,e){return Array.isArray(n)?await ar(n,t,e):cr(n)?await or(n,t,e):await t(n,e)}async function or(n,t,e){let r=[],s={};for(let i in n){let c=n[i],o=ut(c,t,e).then(a=>{s[i]=a});r.push(o)}return await Promise.all(r),s}async function ar(n,t,e={}){let r=n.map(s=>ut(s,t,e));return await Promise.all(r)}async function pn(n,t,e){return await ln(n,r=>kt(r,t,e))}async function kt(n,t,e){let s=await(await fetch(n,e.fetch)).arrayBuffer();return await t(s,e)}async function J(n,t={}){let e=await hr(n,t);return await pn(e,xt.parse,t)}async function hr(n,t,e={}){let r=t&&t.image&&t.image.mipLevels||0;return r!==0?await fr(n,r,t,e):mt(n,t,e)}async function fr(n,t,e,r){let s=[];if(t==="auto"){let i=mt(n,e,{...r,lod:0}),c=await kt(i,xt.parse,e),{width:o,height:a}=Pt(c);t=lr({width:o,height:a}),s.push(i)}V(t>0);for(let i=s.length;i<t;++i){let c=mt(n,e,{...r,lod:i});s.push(c)}return s}function lr(n){return 1+Math.floor(Math.log2(Math.max(n.width,n.height)))}function mn(n,t){let e=new zt.AsyncTexture(n,{id:"brdfLUT",sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"},data:J(t.brdfLutUrl)}),r=xn(n,{id:"DiffuseEnvSampler",getTextureForFace:i=>J(t.getTexUrl("diffuse",i,0)),sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"}}),s=xn(n,{id:"SpecularEnvSampler",getTextureForFace:i=>{let c=[];for(let o=0;o<=t.specularMipLevels-1;o++)c.push(J(t.getTexUrl("specular",i,o)));return c},sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"}});return{brdfLutTexture:e,diffuseEnvSampler:r,specularEnvSampler:s}}var pr=[0,1,2,3,4,5];function xn(n,{id:t,getTextureForFace:e,sampler:r}){let s={};return pr.forEach(i=>{s[String(i)]=e(i)}),new zt.AsyncTexture(n,{id:t,dimension:"cube",mipmaps:!1,sampler:r,data:s})}var H=B(at(),1);var js=1/Math.PI*180,Ks=1/180*Math.PI,xr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...xr}};var R=globalThis.mathgl.config;function Mn(n,{precision:t=R.precision}={}){return n=mr(n),`${parseFloat(n.toPrecision(t))}`}function Y(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function bt(n,t,e){let r=R.EPSILON;e&&(R.EPSILON=e);try{if(n===t)return!0;if(Y(n)&&Y(t)){if(n.length!==t.length)return!1;for(let s=0;s<n.length;++s)if(!bt(n[s],t[s]))return!1;return!0}return n&&n.equals?n.equals(t):t&&t.equals?t.equals(n):typeof n=="number"&&typeof t=="number"?Math.abs(n-t)<=R.EPSILON*Math.max(1,Math.abs(n),Math.abs(t)):!1}finally{R.EPSILON=r}}function mr(n){return Math.round(n/R.EPSILON)*R.EPSILON}var U=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,e=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+e];return this.check()}toArray(t=[],e=0){for(let r=0;r<this.ELEMENTS;++r)t[e+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Y(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(R)}formatString(t){let e="";for(let r=0;r<this.ELEMENTS;++r)e+=(r>0?", ":"")+Mn(this[r],t);return`${t.printTypes?this.constructor.name:""}[${e}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!bt(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,r){if(r===void 0)return this.lerp(this,t,e);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],c=typeof e=="number"?e:e[s];this[s]=i+r*(c-i)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),e[r]);return this.check()}add(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=e[r];return this.check()}subtract(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=e[r];return this.check()}scale(t){if(typeof t=="number")for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;else for(let e=0;e<this.ELEMENTS&&e<t.length;++e)this[e]*=t[e];return this.check()}multiplyByScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}check(){if(R.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),e);return this.check()}get elements(){return this}};function Mr(n,t){if(n.length!==t)return!1;for(let e=0;e<n.length;++e)if(!Number.isFinite(n[e]))return!1;return!0}function w(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function $(n,t,e=""){if(R.debug&&!Mr(n,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return n}function qt(n,t){if(!n)throw new Error(`math.gl assertion ${t}`)}var Mt=class extends U{get x(){return this[0]}set x(t){this[0]=w(t)}get y(){return this[1]}set y(t){this[1]=w(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let e=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];e+=s*s}return w(e)}dot(t){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*t[r];return w(e)}normalize(){let t=this.magnitude();if(t!==0)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}multiply(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=e[r];return this.check()}divide(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return qt(t>=0&&t<this.ELEMENTS,"index is out of range"),w(this[t])}setComponent(t,e){return qt(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}addVectors(t,e){return this.copy(t).add(e)}subVectors(t,e){return this.copy(t).subtract(e)}multiplyVectors(t,e){return this.copy(t).multiply(e)}addScaledVector(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}};var N=typeof Float32Array<"u"?Float32Array:Array;var oi=Math.PI/180;function gr(){let n=new N(2);return N!=Float32Array&&(n[0]=0,n[1]=0),n}function yn(n,t,e){let r=t[0],s=t[1];return n[0]=e[0]*r+e[4]*s+e[12],n[1]=e[1]*r+e[5]*s+e[13],n}var ai=function(){let n=gr();return function(t,e,r,s,i,c){let o,a;for(e||(e=2),r||(r=0),s?a=Math.min(s*e+r,t.length):a=t.length,o=r;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],i(n,n,c),t[o]=n[0],t[o+1]=n[1];return t}}();function An(n,t,e){let r=t[0],s=t[1],i=e[3]*r+e[7]*s||1;return n[0]=(e[0]*r+e[4]*s)/i,n[1]=(e[1]*r+e[5]*s)/i,n}function Tn(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[3]*r+e[7]*s+e[11]*i||1;return n[0]=(e[0]*r+e[4]*s+e[8]*i)/c,n[1]=(e[1]*r+e[5]*s+e[9]*i)/c,n[2]=(e[2]*r+e[6]*s+e[10]*i)/c,n}function En(n,t,e){let r=t[0],s=t[1];return n[0]=e[0]*r+e[2]*s,n[1]=e[1]*r+e[3]*s,n[2]=t[2],n[3]=t[3],n}function Sn(n,t,e){let r=t[0],s=t[1],i=t[2];return n[0]=e[0]*r+e[3]*s+e[6]*i,n[1]=e[1]*r+e[4]*s+e[7]*i,n[2]=e[2]*r+e[5]*s+e[8]*i,n[3]=t[3],n}function Ft(){let n=new N(3);return N!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function dr(n){let t=n[0],e=n[1],r=n[2];return Math.sqrt(t*t+e*e+r*r)}function Ct(n,t,e){let r=new N(3);return r[0]=n,r[1]=t,r[2]=e,r}function wn(n,t){let e=t[0],r=t[1],s=t[2],i=e*e+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),n[0]=t[0]*i,n[1]=t[1]*i,n[2]=t[2]*i,n}function On(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function gt(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[0],o=e[1],a=e[2];return n[0]=s*a-i*o,n[1]=i*c-r*a,n[2]=r*o-s*c,n}function dt(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[3]*r+e[7]*s+e[11]*i+e[15];return c=c||1,n[0]=(e[0]*r+e[4]*s+e[8]*i+e[12])/c,n[1]=(e[1]*r+e[5]*s+e[9]*i+e[13])/c,n[2]=(e[2]*r+e[6]*s+e[10]*i+e[14])/c,n}function Rn(n,t,e){let r=e[0],s=e[1],i=e[2],c=e[3],o=t[0],a=t[1],h=t[2],f=s*h-i*a,l=i*o-r*h,p=r*a-s*o,x=s*p-i*l,m=i*f-r*p,M=r*l-s*f,g=c*2;return f*=g,l*=g,p*=g,x*=2,m*=2,M*=2,n[0]=o+f+x,n[1]=a+l+m,n[2]=h+p+M,n}var Nn=dr;var li=function(){let n=Ft();return function(t,e,r,s,i,c){let o,a;for(e||(e=3),r||(r=0),s?a=Math.min(s*e+r,t.length):a=t.length,o=r;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],n[2]=t[o+2],i(n,n,c),t[o]=n[0],t[o+1]=n[1],t[o+2]=n[2];return t}}();var yt,W=class extends Mt{static get ZERO(){return yt||(yt=new W(0,0,0,0),Object.freeze(yt)),yt}constructor(t=0,e=0,r=0,s=0){super(-0,-0,-0,-0),Y(t)&&arguments.length===1?this.copy(t):(R.debug&&(w(t),w(e),w(r),w(s)),this[0]=t,this[1]=e,this[2]=r,this[3]=s)}set(t,e,r,s){return this[0]=t,this[1]=e,this[2]=r,this[3]=s,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return R.debug&&(w(t.x),w(t.y),w(t.z),w(t.w)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t.w=this[3],t}get ELEMENTS(){return 4}get z(){return this[2]}set z(t){this[2]=w(t)}get w(){return this[3]}set w(t){this[3]=w(t)}transform(t){return dt(this,this,t),this.check()}transformByMatrix3(t){return Sn(this,this,t),this.check()}transformByMatrix2(t){return En(this,this,t),this.check()}transformByQuaternion(t){return Rn(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var At=class extends U{toString(){let t="[";if(R.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+e]}`}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=` ${this[e]}`}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,r){return this[e*this.RANK+t]=w(r),this}getColumn(t,e=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)e[s]=this[r+s];return e}setColumn(t,e){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=e[s];return this}};function Ln(){let n=new N(9);return N!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function Tr(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function _n(n,t){if(n===t){let e=t[1],r=t[2],s=t[3],i=t[6],c=t[7],o=t[11];n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=e,n[6]=t[9],n[7]=t[13],n[8]=r,n[9]=i,n[11]=t[14],n[12]=s,n[13]=c,n[14]=o}else n[0]=t[0],n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=t[1],n[5]=t[5],n[6]=t[9],n[7]=t[13],n[8]=t[2],n[9]=t[6],n[10]=t[10],n[11]=t[14],n[12]=t[3],n[13]=t[7],n[14]=t[11],n[15]=t[15];return n}function In(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=t[4],o=t[5],a=t[6],h=t[7],f=t[8],l=t[9],p=t[10],x=t[11],m=t[12],M=t[13],g=t[14],E=t[15],O=e*o-r*c,d=e*a-s*c,y=e*h-i*c,A=r*a-s*o,T=r*h-i*o,L=s*h-i*a,_=f*M-l*m,I=f*g-p*m,P=f*E-x*m,v=l*g-p*M,u=l*E-x*M,k=p*E-x*g,S=O*k-d*u+y*v+A*P-T*I+L*_;return S?(S=1/S,n[0]=(o*k-a*u+h*v)*S,n[1]=(s*u-r*k-i*v)*S,n[2]=(M*L-g*T+E*A)*S,n[3]=(p*T-l*L-x*A)*S,n[4]=(a*P-c*k-h*I)*S,n[5]=(e*k-s*P+i*I)*S,n[6]=(g*y-m*L-E*d)*S,n[7]=(f*L-p*y+x*d)*S,n[8]=(c*u-o*P+h*_)*S,n[9]=(r*P-e*u-i*_)*S,n[10]=(m*T-M*y+E*O)*S,n[11]=(l*y-f*T-x*O)*S,n[12]=(o*I-c*v-a*_)*S,n[13]=(e*v-r*I+s*_)*S,n[14]=(M*d-m*A-g*O)*S,n[15]=(f*A-l*d+p*O)*S,n):null}function Pn(n){let t=n[0],e=n[1],r=n[2],s=n[3],i=n[4],c=n[5],o=n[6],a=n[7],h=n[8],f=n[9],l=n[10],p=n[11],x=n[12],m=n[13],M=n[14],g=n[15],E=t*c-e*i,O=t*o-r*i,d=e*o-r*c,y=h*m-f*x,A=h*M-l*x,T=f*M-l*m,L=t*T-e*A+r*y,_=i*T-c*A+o*y,I=h*d-f*O+l*E,P=x*d-m*O+M*E;return a*L-s*_+g*I-p*P}function Bt(n,t,e){let r=t[0],s=t[1],i=t[2],c=t[3],o=t[4],a=t[5],h=t[6],f=t[7],l=t[8],p=t[9],x=t[10],m=t[11],M=t[12],g=t[13],E=t[14],O=t[15],d=e[0],y=e[1],A=e[2],T=e[3];return n[0]=d*r+y*o+A*l+T*M,n[1]=d*s+y*a+A*p+T*g,n[2]=d*i+y*h+A*x+T*E,n[3]=d*c+y*f+A*m+T*O,d=e[4],y=e[5],A=e[6],T=e[7],n[4]=d*r+y*o+A*l+T*M,n[5]=d*s+y*a+A*p+T*g,n[6]=d*i+y*h+A*x+T*E,n[7]=d*c+y*f+A*m+T*O,d=e[8],y=e[9],A=e[10],T=e[11],n[8]=d*r+y*o+A*l+T*M,n[9]=d*s+y*a+A*p+T*g,n[10]=d*i+y*h+A*x+T*E,n[11]=d*c+y*f+A*m+T*O,d=e[12],y=e[13],A=e[14],T=e[15],n[12]=d*r+y*o+A*l+T*M,n[13]=d*s+y*a+A*p+T*g,n[14]=d*i+y*h+A*x+T*E,n[15]=d*c+y*f+A*m+T*O,n}function vn(n,t,e){let r=e[0],s=e[1],i=e[2],c,o,a,h,f,l,p,x,m,M,g,E;return t===n?(n[12]=t[0]*r+t[4]*s+t[8]*i+t[12],n[13]=t[1]*r+t[5]*s+t[9]*i+t[13],n[14]=t[2]*r+t[6]*s+t[10]*i+t[14],n[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(c=t[0],o=t[1],a=t[2],h=t[3],f=t[4],l=t[5],p=t[6],x=t[7],m=t[8],M=t[9],g=t[10],E=t[11],n[0]=c,n[1]=o,n[2]=a,n[3]=h,n[4]=f,n[5]=l,n[6]=p,n[7]=x,n[8]=m,n[9]=M,n[10]=g,n[11]=E,n[12]=c*r+f*s+m*i+t[12],n[13]=o*r+l*s+M*i+t[13],n[14]=a*r+p*s+g*i+t[14],n[15]=h*r+x*s+E*i+t[15]),n}function un(n,t,e){let r=e[0],s=e[1],i=e[2];return n[0]=t[0]*r,n[1]=t[1]*r,n[2]=t[2]*r,n[3]=t[3]*r,n[4]=t[4]*s,n[5]=t[5]*s,n[6]=t[6]*s,n[7]=t[7]*s,n[8]=t[8]*i,n[9]=t[9]*i,n[10]=t[10]*i,n[11]=t[11]*i,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}function kn(n,t,e,r){let s=r[0],i=r[1],c=r[2],o=Math.sqrt(s*s+i*i+c*c),a,h,f,l,p,x,m,M,g,E,O,d,y,A,T,L,_,I,P,v,u,k,S,X;return o<1e-6?null:(o=1/o,s*=o,i*=o,c*=o,h=Math.sin(e),a=Math.cos(e),f=1-a,l=t[0],p=t[1],x=t[2],m=t[3],M=t[4],g=t[5],E=t[6],O=t[7],d=t[8],y=t[9],A=t[10],T=t[11],L=s*s*f+a,_=i*s*f+c*h,I=c*s*f-i*h,P=s*i*f-c*h,v=i*i*f+a,u=c*i*f+s*h,k=s*c*f+i*h,S=i*c*f-s*h,X=c*c*f+a,n[0]=l*L+M*_+d*I,n[1]=p*L+g*_+y*I,n[2]=x*L+E*_+A*I,n[3]=m*L+O*_+T*I,n[4]=l*P+M*v+d*u,n[5]=p*P+g*v+y*u,n[6]=x*P+E*v+A*u,n[7]=m*P+O*v+T*u,n[8]=l*k+M*S+d*X,n[9]=p*k+g*S+y*X,n[10]=x*k+E*S+A*X,n[11]=m*k+O*S+T*X,t!==n&&(n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n)}function zn(n,t,e){let r=Math.sin(e),s=Math.cos(e),i=t[4],c=t[5],o=t[6],a=t[7],h=t[8],f=t[9],l=t[10],p=t[11];return t!==n&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[4]=i*s+h*r,n[5]=c*s+f*r,n[6]=o*s+l*r,n[7]=a*s+p*r,n[8]=h*s-i*r,n[9]=f*s-c*r,n[10]=l*s-o*r,n[11]=p*s-a*r,n}function bn(n,t,e){let r=Math.sin(e),s=Math.cos(e),i=t[0],c=t[1],o=t[2],a=t[3],h=t[8],f=t[9],l=t[10],p=t[11];return t!==n&&(n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*s-h*r,n[1]=c*s-f*r,n[2]=o*s-l*r,n[3]=a*s-p*r,n[8]=i*r+h*s,n[9]=c*r+f*s,n[10]=o*r+l*s,n[11]=a*r+p*s,n}function qn(n,t,e){let r=Math.sin(e),s=Math.cos(e),i=t[0],c=t[1],o=t[2],a=t[3],h=t[4],f=t[5],l=t[6],p=t[7];return t!==n&&(n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*s+h*r,n[1]=c*s+f*r,n[2]=o*s+l*r,n[3]=a*s+p*r,n[4]=h*s-i*r,n[5]=f*s-c*r,n[6]=l*s-o*r,n[7]=p*s-a*r,n}function Fn(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=e+e,o=r+r,a=s+s,h=e*c,f=r*c,l=r*o,p=s*c,x=s*o,m=s*a,M=i*c,g=i*o,E=i*a;return n[0]=1-l-m,n[1]=f+E,n[2]=p-g,n[3]=0,n[4]=f-E,n[5]=1-h-m,n[6]=x+M,n[7]=0,n[8]=p+g,n[9]=x-M,n[10]=1-h-l,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Cn(n,t,e,r,s,i,c){let o=1/(e-t),a=1/(s-r),h=1/(i-c);return n[0]=i*2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*a,n[6]=0,n[7]=0,n[8]=(e+t)*o,n[9]=(s+r)*a,n[10]=(c+i)*h,n[11]=-1,n[12]=0,n[13]=0,n[14]=c*i*2*h,n[15]=0,n}function Er(n,t,e,r,s){let i=1/Math.tan(t/2);if(n[0]=i/e,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,s!=null&&s!==1/0){let c=1/(r-s);n[10]=(s+r)*c,n[14]=2*s*r*c}else n[10]=-1,n[14]=-2*r;return n}var Bn=Er;function Sr(n,t,e,r,s,i,c){let o=1/(t-e),a=1/(r-s),h=1/(i-c);return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*a,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*h,n[11]=0,n[12]=(t+e)*o,n[13]=(s+r)*a,n[14]=(c+i)*h,n[15]=1,n}var Un=Sr;function Vn(n,t,e,r){let s,i,c,o,a,h,f,l,p,x,m=t[0],M=t[1],g=t[2],E=r[0],O=r[1],d=r[2],y=e[0],A=e[1],T=e[2];return Math.abs(m-y)<1e-6&&Math.abs(M-A)<1e-6&&Math.abs(g-T)<1e-6?Tr(n):(l=m-y,p=M-A,x=g-T,s=1/Math.sqrt(l*l+p*p+x*x),l*=s,p*=s,x*=s,i=O*x-d*p,c=d*l-E*x,o=E*p-O*l,s=Math.sqrt(i*i+c*c+o*o),s?(s=1/s,i*=s,c*=s,o*=s):(i=0,c=0,o=0),a=p*o-x*c,h=x*i-l*o,f=l*c-p*i,s=Math.sqrt(a*a+h*h+f*f),s?(s=1/s,a*=s,h*=s,f*=s):(a=0,h=0,f=0),n[0]=i,n[1]=a,n[2]=l,n[3]=0,n[4]=c,n[5]=h,n[6]=p,n[7]=0,n[8]=o,n[9]=f,n[10]=x,n[11]=0,n[12]=-(i*m+c*M+o*g),n[13]=-(a*m+h*M+f*g),n[14]=-(l*m+p*M+x*g),n[15]=1,n)}function wr(){let n=new N(4);return N!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function Dn(n,t,e){return n[0]=t[0]+e[0],n[1]=t[1]+e[1],n[2]=t[2]+e[2],n[3]=t[3]+e[3],n}function Yn(n,t,e){return n[0]=t[0]*e,n[1]=t[1]*e,n[2]=t[2]*e,n[3]=t[3]*e,n}function $n(n){let t=n[0],e=n[1],r=n[2],s=n[3];return Math.sqrt(t*t+e*e+r*r+s*s)}function Wn(n){let t=n[0],e=n[1],r=n[2],s=n[3];return t*t+e*e+r*r+s*s}function Gn(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=e*e+r*r+s*s+i*i;return c>0&&(c=1/Math.sqrt(c)),n[0]=e*c,n[1]=r*c,n[2]=s*c,n[3]=i*c,n}function Hn(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]}function Xn(n,t,e,r){let s=t[0],i=t[1],c=t[2],o=t[3];return n[0]=s+r*(e[0]-s),n[1]=i+r*(e[1]-i),n[2]=c+r*(e[2]-c),n[3]=o+r*(e[3]-o),n}function jn(n,t,e){let r=t[0],s=t[1],i=t[2],c=t[3];return n[0]=e[0]*r+e[4]*s+e[8]*i+e[12]*c,n[1]=e[1]*r+e[5]*s+e[9]*i+e[13]*c,n[2]=e[2]*r+e[6]*s+e[10]*i+e[14]*c,n[3]=e[3]*r+e[7]*s+e[11]*i+e[15]*c,n}function Kn(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[0],o=e[1],a=e[2],h=e[3],f=h*r+o*i-a*s,l=h*s+a*r-c*i,p=h*i+c*s-o*r,x=-c*r-o*s-a*i;return n[0]=f*h+x*-c+l*-a-p*-o,n[1]=l*h+x*-o+p*-c-f*-a,n[2]=p*h+x*-a+f*-o-l*-c,n[3]=t[3],n}var wi=function(){let n=wr();return function(t,e,r,s,i,c){let o,a;for(e||(e=4),r||(r=0),s?a=Math.min(s*e+r,t.length):a=t.length,o=r;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],n[2]=t[o+2],n[3]=t[o+3],i(n,n,c),t[o]=n[0],t[o+1]=n[1],t[o+2]=n[2],t[o+3]=n[3];return t}}();var Dt;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(Dt||(Dt={}));var Rr=45*Math.PI/180,Nr=1,Ut=.1,Vt=500,Lr=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),C=class extends At{static get IDENTITY(){return Ir()}static get ZERO(){return _r()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Dt}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,e,r,s,i,c,o,a,h,f,l,p,x,m,M,g){return this[0]=t,this[1]=e,this[2]=r,this[3]=s,this[4]=i,this[5]=c,this[6]=o,this[7]=a,this[8]=h,this[9]=f,this[10]=l,this[11]=p,this[12]=x,this[13]=m,this[14]=M,this[15]=g,this.check()}setRowMajor(t,e,r,s,i,c,o,a,h,f,l,p,x,m,M,g){return this[0]=t,this[1]=i,this[2]=h,this[3]=x,this[4]=e,this[5]=c,this[6]=f,this[7]=m,this[8]=r,this[9]=o,this[10]=l,this[11]=M,this[12]=s,this[13]=a,this[14]=p,this[15]=g,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(Lr)}fromObject(t){return this.check()}fromQuaternion(t){return Fn(this,t),this.check()}frustum(t){let{left:e,right:r,bottom:s,top:i,near:c=Ut,far:o=Vt}=t;return o===1/0?Pr(this,e,r,s,i,c):Cn(this,e,r,s,i,c,o),this.check()}lookAt(t){let{eye:e,center:r=[0,0,0],up:s=[0,1,0]}=t;return Vn(this,e,r,s),this.check()}ortho(t){let{left:e,right:r,bottom:s,top:i,near:c=Ut,far:o=Vt}=t;return Un(this,e,r,s,i,c,o),this.check()}orthographic(t){let{fovy:e=Rr,aspect:r=Nr,focalDistance:s=1,near:i=Ut,far:c=Vt}=t;Qn(e);let o=e/2,a=s*Math.tan(o),h=a*r;return this.ortho({left:-h,right:h,bottom:-a,top:a,near:i,far:c})}perspective(t){let{fovy:e=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return Qn(e),Bn(this,e,r,s,i),this.check()}determinant(){return Pn(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,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let r=this.getScale(e),s=1/r[0],i=1/r[1],c=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*c,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*c,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let r=this.getScale(e),s=1/r[0],i=1/r[1],c=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*c,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*c,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*c,t}transpose(){return _n(this,this),this.check()}invert(){return In(this,this),this.check()}multiplyLeft(t){return Bt(this,t,this),this.check()}multiplyRight(t){return Bt(this,this,t),this.check()}rotateX(t){return zn(this,this,t),this.check()}rotateY(t){return bn(this,this,t),this.check()}rotateZ(t){return qn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,e){return kn(this,this,t,e),this.check()}scale(t){return un(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return vn(this,this,t),this.check()}transform(t,e){return t.length===4?(e=jn(e||[-0,-0,-0,-0],t,this),$(e,4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){let{length:r}=t,s;switch(r){case 2:s=yn(e||[-0,-0],t,this);break;case 3:s=dt(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $(s,t.length),s}transformAsVector(t,e){let r;switch(t.length){case 2:r=An(e||[-0,-0],t,this);break;case 3:r=Tn(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $(r,t.length),r}transformPoint(t,e){return this.transformAsPoint(t,e)}transformVector(t,e){return this.transformAsPoint(t,e)}transformDirection(t,e){return this.transformAsVector(t,e)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,r){return this.identity().translate([t,e,r])}},Tt,Et;function _r(){return Tt||(Tt=new C([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Tt)),Tt}function Ir(){return Et||(Et=new C,Object.freeze(Et)),Et}function Qn(n){if(n>Math.PI*2)throw Error("expected radians")}function Pr(n,t,e,r,s,i){let c=2*i/(e-t),o=2*i/(s-r),a=(e+t)/(e-t),h=(s+r)/(s-r),f=-1,l=-1,p=-2*i;return n[0]=c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=o,n[6]=0,n[7]=0,n[8]=a,n[9]=h,n[10]=f,n[11]=l,n[12]=0,n[13]=0,n[14]=p,n[15]=0,n}function Zn(){let n=new N(4);return N!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function Jn(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function Yt(n,t,e){e=e*.5;let r=Math.sin(e);return n[0]=r*t[0],n[1]=r*t[1],n[2]=r*t[2],n[3]=Math.cos(e),n}function $t(n,t,e){let r=t[0],s=t[1],i=t[2],c=t[3],o=e[0],a=e[1],h=e[2],f=e[3];return n[0]=r*f+c*o+s*h-i*a,n[1]=s*f+c*a+i*o-r*h,n[2]=i*f+c*h+r*a-s*o,n[3]=c*f-r*o-s*a-i*h,n}function te(n,t,e){e*=.5;let r=t[0],s=t[1],i=t[2],c=t[3],o=Math.sin(e),a=Math.cos(e);return n[0]=r*a+c*o,n[1]=s*a+i*o,n[2]=i*a-s*o,n[3]=c*a-r*o,n}function ne(n,t,e){e*=.5;let r=t[0],s=t[1],i=t[2],c=t[3],o=Math.sin(e),a=Math.cos(e);return n[0]=r*a-i*o,n[1]=s*a+c*o,n[2]=i*a+r*o,n[3]=c*a-s*o,n}function ee(n,t,e){e*=.5;let r=t[0],s=t[1],i=t[2],c=t[3],o=Math.sin(e),a=Math.cos(e);return n[0]=r*a+s*o,n[1]=s*a-r*o,n[2]=i*a+c*o,n[3]=c*a-i*o,n}function re(n,t){let e=t[0],r=t[1],s=t[2];return n[0]=e,n[1]=r,n[2]=s,n[3]=Math.sqrt(Math.abs(1-e*e-r*r-s*s)),n}function nt(n,t,e,r){let s=t[0],i=t[1],c=t[2],o=t[3],a=e[0],h=e[1],f=e[2],l=e[3],p,x,m,M,g;return p=s*a+i*h+c*f+o*l,p<0&&(p=-p,a=-a,h=-h,f=-f,l=-l),1-p>1e-6?(x=Math.acos(p),g=Math.sin(x),m=Math.sin((1-r)*x)/g,M=Math.sin(r*x)/g):(m=1-r,M=r),n[0]=m*s+M*a,n[1]=m*i+M*h,n[2]=m*c+M*f,n[3]=m*o+M*l,n}function se(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=e*e+r*r+s*s+i*i,o=c?1/c:0;return n[0]=-e*o,n[1]=-r*o,n[2]=-s*o,n[3]=i*o,n}function ie(n,t){return n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=t[3],n}function Wt(n,t){let e=t[0]+t[4]+t[8],r;if(e>0)r=Math.sqrt(e+1),n[3]=.5*r,r=.5/r,n[0]=(t[5]-t[7])*r,n[1]=(t[6]-t[2])*r,n[2]=(t[1]-t[3])*r;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,c=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[c*3+c]+1),n[s]=.5*r,r=.5/r,n[3]=(t[i*3+c]-t[c*3+i])*r,n[i]=(t[i*3+s]+t[s*3+i])*r,n[c]=(t[c*3+s]+t[s*3+c])*r}return n}var ce=Dn;var oe=Yn,ae=Hn,he=Xn,fe=$n;var le=Wn;var pe=Gn;var xe=function(){let n=Ft(),t=Ct(1,0,0),e=Ct(0,1,0);return function(r,s,i){let c=On(s,i);return c<-.999999?(gt(n,t,s),Nn(n)<1e-6&>(n,e,s),wn(n,n),Yt(r,n,Math.PI),r):c>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(gt(n,s,i),r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=1+c,pe(r,r))}}(),Fi=function(){let n=Zn(),t=Zn();return function(e,r,s,i,c,o){return nt(n,r,c,o),nt(t,s,i,o),nt(e,n,t,2*o*(1-o)),e}}(),Ci=function(){let n=Ln();return function(t,e,r,s){return n[0]=r[0],n[3]=r[1],n[6]=r[2],n[1]=s[0],n[4]=s[1],n[7]=s[2],n[2]=-e[0],n[5]=-e[1],n[8]=-e[2],pe(t,Wt(t,n))}}();var vr=[0,0,0,1],et=class extends U{constructor(t=0,e=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,e,r,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,e,r,s){return this[0]=t,this[1]=e,this[2]=r,this[3]=s,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return Wt(this,t),this.check()}fromAxisRotation(t,e){return Yt(this,t,e),this.check()}identity(){return Jn(this),this.check()}setAxisAngle(t,e){return this.fromAxisRotation(t,e)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=w(t)}get y(){return this[1]}set y(t){this[1]=w(t)}get z(){return this[2]}set z(t){this[2]=w(t)}get w(){return this[3]}set w(t){this[3]=w(t)}len(){return fe(this)}lengthSquared(){return le(this)}dot(t){return ae(this,t)}rotationTo(t,e){return xe(this,t,e),this.check()}add(t){return ce(this,this,t),this.check()}calculateW(){return re(this,this),this.check()}conjugate(){return ie(this,this),this.check()}invert(){return se(this,this),this.check()}lerp(t,e,r){return r===void 0?this.lerp(this,t,e):(he(this,t,e,r),this.check())}multiplyRight(t){return $t(this,this,t),this.check()}multiplyLeft(t){return $t(this,t,this),this.check()}normalize(){let t=this.len(),e=t>0?1/t:0;return this[0]=this[0]*e,this[1]=this[1]*e,this[2]=this[2]*e,this[3]=this[3]*e,t===0&&(this[3]=1),this.check()}rotateX(t){return te(this,this,t),this.check()}rotateY(t){return ne(this,this,t),this.check()}rotateZ(t){return ee(this,this,t),this.check()}scale(t){return oe(this,this,t),this.check()}slerp(t,e,r){let s,i,c;switch(arguments.length){case 1:({start:s=vr,target:i,ratio:c}=t);break;case 2:s=this,i=t,c=e;break;default:s=t,i=e,c=r}return nt(this,s,i,c),this.check()}transformVector4(t,e=new W){return Kn(e,t,this),$(e,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,e){return this.setAxisAngle(t,e)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var Ht=B(j(),1);var ur={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},kr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Xt=class{name;startTime=0;playing=!0;speed=1;channels=[];constructor(t){Object.assign(this,t)}animate(t){if(!this.playing)return;let r=(t/1e3-this.startTime)*this.speed;this.channels.forEach(({sampler:s,target:i,path:c})=>{Br(r,s,i,c),br(i,i._node)})}},G=class{animations;constructor(t){this.animations=t.animations.map((e,r)=>{let s=e.name||`Animation-${r}`,i=e.samplers.map(({input:o,interpolation:a="LINEAR",output:h})=>({input:me(t.accessors[o]),interpolation:a,output:me(t.accessors[h])})),c=e.channels.map(({sampler:o,target:a})=>({sampler:i[o],target:t.nodes[a.node],path:a.path}));return new Xt({name:s,channels:c})})}animate(t){this.setTime(t)}setTime(t){this.animations.forEach(e=>e.animate(t))}getAnimations(){return this.animations}};function me(n){if(!n._animation){let t=kr[n.componentType],e=ur[n.type],r=e*n.count,{buffer:s,byteOffset:i}=n.bufferView.data,c=new t(s,i+(n.byteOffset||0),r);if(e===1)n._animation=Array.from(c);else{let o=[];for(let a=0;a<c.length;a+=e)o.push(Array.from(c.slice(a,a+e)));n._animation=o}}return n._animation}var zr=new C;function br(n,t){if(t.matrix.identity(),n.translation&&t.matrix.translate(n.translation),n.rotation){let e=zr.fromQuaternion(n.rotation);t.matrix.multiplyRight(e)}n.scale&&t.matrix.scale(n.scale)}var Gt=new et;function qr(n,t,e,r,s){if(t==="rotation"){Gt.slerp({start:e,target:r,ratio:s});for(let i=0;i<Gt.length;i++)n[t][i]=Gt[i]}else for(let i=0;i<e.length;i++)n[t][i]=s*r[i]+(1-s)*e[i]}function Fr(n,t,{p0:e,outTangent0:r,inTangent1:s,p1:i,tDiff:c,ratio:o}){for(let a=0;a<n[t].length;a++){let h=r[a]*c,f=s[a]*c;n[t][a]=(2*Math.pow(o,3)-3*Math.pow(o,2)+1)*e[a]+(Math.pow(o,3)-2*Math.pow(o,2)+o)*h+(-2*Math.pow(o,3)+3*Math.pow(o,2))*i[a]+(Math.pow(o,3)-Math.pow(o,2))*f}}function Cr(n,t,e){for(let r=0;r<e.length;r++)n[t][r]=e[r]}function Br(n,{input:t,interpolation:e,output:r},s,i){let c=t[t.length-1],o=n%c,a=t.findIndex(p=>p>=o),h=Math.max(0,a-1);if(!Array.isArray(s[i]))switch(i){case"translation":s[i]=[0,0,0];break;case"rotation":s[i]=[0,0,0,1];break;case"scale":s[i]=[1,1,1];break;default:Ht.log.warn(`Bad animation path ${i}`)()}let f=t[h],l=t[a];switch(e){case"STEP":Cr(s,i,r[h]);break;case"LINEAR":if(l>f){let p=(o-f)/(l-f);qr(s,i,r[h],r[a],p)}break;case"CUBICSPLINE":if(l>f){let p=(o-f)/(l-f),x=l-f,m=r[3*h+1],M=r[3*h+2],g=r[3*a+0],E=r[3*a+1];Fr(s,i,{p0:m,outTangent0:M,inTangent1:g,p1:E,tDiff:x,ratio:p})}break;default:Ht.log.warn(`Interpolation ${e} not supported`)();break}}var de=B(j(),1),ye=B(ge(),1),St=B(at(),1);var Ur=`
|
|
7
|
+
var __exports__=(()=>{var we=Object.create;var it=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Le=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var Ot=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),_e=(n,t)=>{for(var e in t)it(n,e,{get:t[e],enumerable:!0})},st=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Re(t))!Ne.call(n,s)&&s!==e&&it(n,s,{get:()=>t[s],enumerable:!(r=Oe(t,s))||r.enumerable});return n},ct=(n,t,e)=>(st(n,t,"default"),e&&st(e,t,"default")),C=(n,t,e)=>(e=n!=null?we(Le(n)):{},st(t||!n||!n.__esModule?it(e,"default",{value:n,enumerable:!0}):e,n)),Ie=n=>st(it({},"__esModule",{value:!0}),n);var j=Ot((Gr,Kt)=>{Kt.exports=globalThis.luma});var at=Ot((Xr,Zt)=>{Zt.exports=globalThis.luma});var ge=Ot((Zi,de)=>{de.exports=globalThis.luma});var rt={};_e(rt,{GLTFAnimator:()=>G,createScenegraphsFromGLTF:()=>Se,loadPBREnvironment:()=>Mn,parsePBRMaterial:()=>ot});ct(rt,C(j(),1));var Qt=C(j(),1),z;(function(n){n[n.FUNC_ADD=32774]="FUNC_ADD",n[n.ONE=1]="ONE",n[n.SRC_ALPHA=770]="SRC_ALPHA",n[n.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",n[n.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",n[n.LINEAR=9729]="LINEAR",n[n.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",n[n.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(z||(z={}));function ot(n,t,e,r){let s={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=1;let{imageBasedLightingEnvironment:i}=r;return i&&(s.bindings.pbr_diffuseEnvSampler=i.diffuseEnvSampler.texture,s.bindings.pbr_specularEnvSampler=i.specularEnvSampler.texture,s.bindings.pbr_BrdfLUT=i.brdfLutTexture.texture,s.uniforms.scaleIBLAmbient=[1,1]),r?.pbrDebug&&(s.defines.PBR_DEBUG=1,s.uniforms.scaleDiffBaseMR=[0,0,0,0],s.uniforms.scaleFGDSpec=[0,0,0,0]),e.NORMAL&&(s.defines.HAS_NORMALS=1),e.TANGENT&&r?.useTangents&&(s.defines.HAS_TANGENTS=1),e.TEXCOORD_0&&(s.defines.HAS_UV=1),r?.imageBasedLightingEnvironment&&(s.defines.USE_IBL=1),r?.lights&&(s.defines.USE_LIGHTS=1),t&&Pe(n,t,s),s}function Pe(n,t,e){if(e.uniforms.unlit=Boolean(t.unlit),t.pbrMetallicRoughness&&ve(n,t.pbrMetallicRoughness,e),t.normalTexture){K(n,t.normalTexture,"pbr_normalSampler","HAS_NORMALMAP",e);let{scale:r=1}=t.normalTexture;e.uniforms.normalScale=r}if(t.occlusionTexture){K(n,t.occlusionTexture,"pbr_occlusionSampler","HAS_OCCLUSIONMAP",e);let{strength:r=1}=t.occlusionTexture;e.uniforms.occlusionStrength=r}switch(t.emissiveTexture&&(K(n,t.emissiveTexture,"pbr_emissiveSampler","HAS_EMISSIVEMAP",e),e.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0]),t.alphaMode){case"MASK":let{alphaCutoff:r=.5}=t;e.defines.ALPHA_CUTOFF=1,e.uniforms.alphaCutoff=r;break;case"BLEND":Qt.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),e.parameters.blendColorOperation="add",e.parameters.blendColorSrcFactor="src-alpha",e.parameters.blendColorDstFactor="one-minus-src-alpha",e.parameters.blendAlphaOperation="add",e.parameters.blendAlphaSrcFactor="one",e.parameters.blendAlphaDstFactor="one-minus-src-alpha",e.glParameters.blend=!0,e.glParameters.blendEquation=z.FUNC_ADD,e.glParameters.blendFunc=[z.SRC_ALPHA,z.ONE_MINUS_SRC_ALPHA,z.ONE,z.ONE_MINUS_SRC_ALPHA];break}}function ve(n,t,e){t.baseColorTexture&&K(n,t.baseColorTexture,"pbr_baseColorSampler","HAS_BASECOLORMAP",e),e.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&K(n,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler","HAS_METALROUGHNESSMAP",e);let{metallicFactor:r=1,roughnessFactor:s=1}=t;e.uniforms.metallicRoughnessValues=[r,s]}function K(n,t,e,r=null,s){let i=t?.texture?.sampler?.parameters||{},c=t.texture.source.image,o,a={};c.compressed?(o=c,a={[z.TEXTURE_MIN_FILTER]:c.data.length>1?z.LINEAR_MIPMAP_NEAREST:z.LINEAR}):o={data:c};let f=n.createTexture({id:t.uniformName||t.id,parameters:{...i,...a},pixelStore:{[z.UNPACK_FLIP_Y_WEBGL]:!1},...o});s.bindings[e]=f,r&&(s.defines[r]=1),s.generatedTextures.push(f)}var zt=C(at(),1);function V(n,t){if(!n)throw new Error(t||"loader assertion failed.")}var b={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},ue=b.self||b.window||b.global||{},ke=b.window||b.self||b.global||{},ze=b.global||b.self||b.window||{},be=b.document||{};var Rt=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Jt=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),qe=Jt&&parseFloat(Jt[1])||0;var Fe="",tn={};function Lt(n){for(let t in tn)if(n.startsWith(t)){let e=tn[t];n=n.replace(t,e)}return!n.startsWith("http://")&&!n.startsWith("https://")&&(n=`${Fe}${n}`),n}var nn="4.2.1";var Be=globalThis.loaders?.parseImageNode,Nt=typeof Image<"u",_t=typeof ImageBitmap<"u",Ce=Boolean(Be),It=Rt?!0:Ce;function en(n){switch(n){case"auto":return _t||Nt||It;case"imagebitmap":return _t;case"image":return Nt;case"data":return It;default:throw new Error(`@loaders.gl/images: image ${n} not supported in this environment`)}}function rn(){if(_t)return"imagebitmap";if(Nt)return"image";if(It)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function sn(n){let t=Ue(n);if(!t)throw new Error("Not an image");return t}function Pt(n){return ft(n)}function ft(n){switch(sn(n)){case"data":return n;case"image":case"imagebitmap":let t=document.createElement("canvas"),e=t.getContext("2d");if(!e)throw new Error("getImageData");return t.width=n.width,t.height=n.height,e.drawImage(n,0,0),e.getImageData(0,0,n.width,n.height);default:throw new Error("getImageData")}}function Ue(n){return typeof ImageBitmap<"u"&&n instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&n instanceof Image?"image":n&&typeof n=="object"&&n.data&&n.width&&n.height?"data":null}var Ve=/^data:image\/svg\+xml/,De=/\.svg((\?|#).*)?$/;function ht(n){return n&&(Ve.test(n)||De.test(n))}function cn(n,t){if(ht(t)){let r=new TextDecoder().decode(n);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return vt(n,t)}function vt(n,t){if(ht(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(n)])}async function lt(n,t,e){let r=cn(n,e),s=self.URL||self.webkitURL,i=typeof r!="string"&&s.createObjectURL(r);try{return await Ye(i||r,t)}finally{i&&s.revokeObjectURL(i)}}async function Ye(n,t){let e=new Image;return e.src=n,t.image&&t.image.decode&&e.decode?(await e.decode(),e):await new Promise((r,s)=>{try{e.onload=()=>r(e),e.onerror=i=>{let c=i instanceof Error?i.message:"error";s(new Error(c))}}catch(i){s(i)}})}var $e={},on=!0;async function an(n,t,e){let r;ht(e)?r=await lt(n,t,e):r=vt(n,e);let s=t&&t.imagebitmap;return await We(r,s)}async function We(n,t=null){if((Ge(t)||!on)&&(t=null),t)try{return await createImageBitmap(n,t)}catch(e){console.warn(e),on=!1}return await createImageBitmap(n)}function Ge(n){for(let t in n||$e)return!1;return!0}function fn(n){return!Ke(n,"ftyp",4)||!(n[8]&96)?null:He(n)}function He(n){switch(Xe(n,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Xe(n,t,e){return String.fromCharCode(...n.slice(t,e))}function je(n){return[...n].map(t=>t.charCodeAt(0))}function Ke(n,t,e=0){let r=je(t);for(let s=0;s<r.length;++s)if(r[s]!==n[s+e])return!1;return!0}var q=!1,Q=!0;function pt(n){let t=Z(n);return Ze(t)||nr(t)||Je(t)||tr(t)||Qe(t)}function Qe(n){let t=new Uint8Array(n instanceof DataView?n.buffer:n),e=fn(t);return e?{mimeType:e.mimeType,width:0,height:0}:null}function Ze(n){let t=Z(n);return t.byteLength>=24&&t.getUint32(0,q)===2303741511?{mimeType:"image/png",width:t.getUint32(16,q),height:t.getUint32(20,q)}:null}function Je(n){let t=Z(n);return t.byteLength>=10&&t.getUint32(0,q)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,Q),height:t.getUint16(8,Q)}:null}function tr(n){let t=Z(n);return t.byteLength>=14&&t.getUint16(0,q)===16973&&t.getUint32(2,Q)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,Q),height:t.getUint32(22,Q)}:null}function nr(n){let t=Z(n);if(!(t.byteLength>=3&&t.getUint16(0,q)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=er(),i=2;for(;i+9<t.byteLength;){let c=t.getUint16(i,q);if(s.has(c))return{mimeType:"image/jpeg",height:t.getUint16(i+5,q),width:t.getUint16(i+7,q)};if(!r.has(c))return null;i+=2,i+=t.getUint16(i,q)}return null}function er(){let n=new Set([65499,65476,65484,65501,65534]);for(let e=65504;e<65520;++e)n.add(e);return{tableMarkers:n,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Z(n){if(n instanceof DataView)return n;if(ArrayBuffer.isView(n))return new DataView(n.buffer);if(n instanceof ArrayBuffer)return new DataView(n);throw new Error("toDataView")}async function hn(n,t){let{mimeType:e}=pt(n)||{},r=globalThis.loaders?.parseImageNode;return V(r),await r(n,e)}async function ln(n,t,e){t=t||{};let s=(t.image||{}).type||"auto",{url:i}=e||{},c=rr(s),o;switch(c){case"imagebitmap":o=await an(n,t,i);break;case"image":o=await lt(n,t,i);break;case"data":o=await hn(n,t);break;default:V(!1)}return s==="data"&&(o=ft(o)),o}function rr(n){switch(n){case"auto":case"data":return rn();default:return en(n),n}}var sr=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],ir=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],cr={image:{type:"auto",decode:!0}},xt={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:nn,mimeTypes:ir,extensions:sr,parse:ln,tests:[n=>Boolean(pt(new DataView(n)))],options:cr};function mt(n,t,e){let r=typeof n=="function"?n({...t,...e}):n,s=t.baseUrl;return s&&(r=s[s.length-1]==="/"?`${s}${r}`:`${s}/${r}`),Lt(r)}var or=n=>n&&typeof n=="object";async function pn(n,t,e={}){return await ut(n,t,e)}async function ut(n,t,e){return Array.isArray(n)?await fr(n,t,e):or(n)?await ar(n,t,e):await t(n,e)}async function ar(n,t,e){let r=[],s={};for(let i in n){let c=n[i],o=ut(c,t,e).then(a=>{s[i]=a});r.push(o)}return await Promise.all(r),s}async function fr(n,t,e={}){let r=n.map(s=>ut(s,t,e));return await Promise.all(r)}async function xn(n,t,e){return await pn(n,r=>kt(r,t,e))}async function kt(n,t,e){let s=await(await fetch(n,e.fetch)).arrayBuffer();return await t(s,e)}async function J(n,t={}){let e=await hr(n,t);return await xn(e,xt.parse,t)}async function hr(n,t,e={}){let r=t&&t.image&&t.image.mipLevels||0;return r!==0?await lr(n,r,t,e):mt(n,t,e)}async function lr(n,t,e,r){let s=[];if(t==="auto"){let i=mt(n,e,{...r,lod:0}),c=await kt(i,xt.parse,e),{width:o,height:a}=Pt(c);t=pr({width:o,height:a}),s.push(i)}V(t>0);for(let i=s.length;i<t;++i){let c=mt(n,e,{...r,lod:i});s.push(c)}return s}function pr(n){return 1+Math.floor(Math.log2(Math.max(n.width,n.height)))}function Mn(n,t){let e=new zt.AsyncTexture(n,{id:"brdfLUT",sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"},data:J(t.brdfLutUrl)}),r=mn(n,{id:"DiffuseEnvSampler",getTextureForFace:i=>J(t.getTexUrl("diffuse",i,0)),sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"}}),s=mn(n,{id:"SpecularEnvSampler",getTextureForFace:i=>{let c=[];for(let o=0;o<=t.specularMipLevels-1;o++)c.push(J(t.getTexUrl("specular",i,o)));return c},sampler:{wrapS:"clamp-to-edge",wrapT:"clamp-to-edge",minFilter:"linear",maxFilter:"linear"}});return{brdfLutTexture:e,diffuseEnvSampler:r,specularEnvSampler:s}}var xr=[0,1,2,3,4,5];function mn(n,{id:t,getTextureForFace:e,sampler:r}){let s={};return xr.forEach(i=>{s[String(i)]=e(i)}),new zt.AsyncTexture(n,{id:t,dimension:"cube",mipmaps:!1,sampler:r,data:s})}var H=C(at(),1);var Ks=1/Math.PI*180,Qs=1/180*Math.PI,mr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...mr}};var R=globalThis.mathgl.config;function dn(n,{precision:t=R.precision}={}){return n=Mr(n),`${parseFloat(n.toPrecision(t))}`}function Y(n){return Array.isArray(n)||ArrayBuffer.isView(n)&&!(n instanceof DataView)}function bt(n,t,e){let r=R.EPSILON;e&&(R.EPSILON=e);try{if(n===t)return!0;if(Y(n)&&Y(t)){if(n.length!==t.length)return!1;for(let s=0;s<n.length;++s)if(!bt(n[s],t[s]))return!1;return!0}return n&&n.equals?n.equals(t):t&&t.equals?t.equals(n):typeof n=="number"&&typeof t=="number"?Math.abs(n-t)<=R.EPSILON*Math.max(1,Math.abs(n),Math.abs(t)):!1}finally{R.EPSILON=r}}function Mr(n){return Math.round(n/R.EPSILON)*R.EPSILON}var U=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,e=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+e];return this.check()}toArray(t=[],e=0){for(let r=0;r<this.ELEMENTS;++r)t[e+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Y(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(R)}formatString(t){let e="";for(let r=0;r<this.ELEMENTS;++r)e+=(r>0?", ":"")+dn(this[r],t);return`${t.printTypes?this.constructor.name:""}[${e}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(!bt(this[e],t[e]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,e,r){if(r===void 0)return this.lerp(this,t,e);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],c=typeof e=="number"?e:e[s];this[s]=i+r*(c-i)}return this.check()}min(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}max(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}clamp(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),e[r]);return this.check()}add(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=e[r];return this.check()}subtract(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=e[r];return this.check()}scale(t){if(typeof t=="number")for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;else for(let e=0;e<this.ELEMENTS&&e<t.length;++e)this[e]*=t[e];return this.check()}multiplyByScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}check(){if(R.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let e=0;e<this.ELEMENTS;++e)t=t&&Number.isFinite(this[e]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}addScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),e);return this.check()}get elements(){return this}};function dr(n,t){if(n.length!==t)return!1;for(let e=0;e<n.length;++e)if(!Number.isFinite(n[e]))return!1;return!0}function w(n){if(!Number.isFinite(n))throw new Error(`Invalid number ${JSON.stringify(n)}`);return n}function $(n,t,e=""){if(R.debug&&!dr(n,t))throw new Error(`math.gl: ${e} some fields set to invalid numbers'`);return n}function qt(n,t){if(!n)throw new Error(`math.gl assertion ${t}`)}var Mt=class extends U{get x(){return this[0]}set x(t){this[0]=w(t)}get y(){return this[1]}set y(t){this[1]=w(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let e=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];e+=s*s}return w(e)}dot(t){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*t[r];return w(e)}normalize(){let t=this.magnitude();if(t!==0)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}multiply(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=e[r];return this.check()}divide(...t){for(let e of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return qt(t>=0&&t<this.ELEMENTS,"index is out of range"),w(this[t])}setComponent(t,e){return qt(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}addVectors(t,e){return this.copy(t).add(e)}subVectors(t,e){return this.copy(t).subtract(e)}multiplyVectors(t,e){return this.copy(t).multiply(e)}addScaledVector(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}};var L=typeof Float32Array<"u"?Float32Array:Array;var ai=Math.PI/180;function gr(){let n=new L(2);return L!=Float32Array&&(n[0]=0,n[1]=0),n}function An(n,t,e){let r=t[0],s=t[1];return n[0]=e[0]*r+e[4]*s+e[12],n[1]=e[1]*r+e[5]*s+e[13],n}var fi=function(){let n=gr();return function(t,e,r,s,i,c){let o,a;for(e||(e=2),r||(r=0),s?a=Math.min(s*e+r,t.length):a=t.length,o=r;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],i(n,n,c),t[o]=n[0],t[o+1]=n[1];return t}}();function Tn(n,t,e){let r=t[0],s=t[1],i=e[3]*r+e[7]*s||1;return n[0]=(e[0]*r+e[4]*s)/i,n[1]=(e[1]*r+e[5]*s)/i,n}function En(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[3]*r+e[7]*s+e[11]*i||1;return n[0]=(e[0]*r+e[4]*s+e[8]*i)/c,n[1]=(e[1]*r+e[5]*s+e[9]*i)/c,n[2]=(e[2]*r+e[6]*s+e[10]*i)/c,n}function Sn(n,t,e){let r=t[0],s=t[1];return n[0]=e[0]*r+e[2]*s,n[1]=e[1]*r+e[3]*s,n[2]=t[2],n[3]=t[3],n}function wn(n,t,e){let r=t[0],s=t[1],i=t[2];return n[0]=e[0]*r+e[3]*s+e[6]*i,n[1]=e[1]*r+e[4]*s+e[7]*i,n[2]=e[2]*r+e[5]*s+e[8]*i,n[3]=t[3],n}function Ft(){let n=new L(3);return L!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function yr(n){let t=n[0],e=n[1],r=n[2];return Math.sqrt(t*t+e*e+r*r)}function Bt(n,t,e){let r=new L(3);return r[0]=n,r[1]=t,r[2]=e,r}function On(n,t){let e=t[0],r=t[1],s=t[2],i=e*e+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),n[0]=t[0]*i,n[1]=t[1]*i,n[2]=t[2]*i,n}function Rn(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function dt(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[0],o=e[1],a=e[2];return n[0]=s*a-i*o,n[1]=i*c-r*a,n[2]=r*o-s*c,n}function gt(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[3]*r+e[7]*s+e[11]*i+e[15];return c=c||1,n[0]=(e[0]*r+e[4]*s+e[8]*i+e[12])/c,n[1]=(e[1]*r+e[5]*s+e[9]*i+e[13])/c,n[2]=(e[2]*r+e[6]*s+e[10]*i+e[14])/c,n}function Ln(n,t,e){let r=e[0],s=e[1],i=e[2],c=e[3],o=t[0],a=t[1],f=t[2],h=s*f-i*a,p=i*o-r*f,l=r*a-s*o,x=s*l-i*p,m=i*h-r*l,M=r*p-s*h,d=c*2;return h*=d,p*=d,l*=d,x*=2,m*=2,M*=2,n[0]=o+h+x,n[1]=a+p+m,n[2]=f+l+M,n}var Nn=yr;var pi=function(){let n=Ft();return function(t,e,r,s,i,c){let o,a;for(e||(e=3),r||(r=0),s?a=Math.min(s*e+r,t.length):a=t.length,o=r;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],n[2]=t[o+2],i(n,n,c),t[o]=n[0],t[o+1]=n[1],t[o+2]=n[2];return t}}();var yt,W=class extends Mt{static get ZERO(){return yt||(yt=new W(0,0,0,0),Object.freeze(yt)),yt}constructor(t=0,e=0,r=0,s=0){super(-0,-0,-0,-0),Y(t)&&arguments.length===1?this.copy(t):(R.debug&&(w(t),w(e),w(r),w(s)),this[0]=t,this[1]=e,this[2]=r,this[3]=s)}set(t,e,r,s){return this[0]=t,this[1]=e,this[2]=r,this[3]=s,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return R.debug&&(w(t.x),w(t.y),w(t.z),w(t.w)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t.w=this[3],t}get ELEMENTS(){return 4}get z(){return this[2]}set z(t){this[2]=w(t)}get w(){return this[3]}set w(t){this[3]=w(t)}transform(t){return gt(this,this,t),this.check()}transformByMatrix3(t){return wn(this,this,t),this.check()}transformByMatrix2(t){return Sn(this,this,t),this.check()}transformByQuaternion(t){return Ln(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var At=class extends U{toString(){let t="[";if(R.printRowMajor){t+="row-major:";for(let e=0;e<this.RANK;++e)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+e]}`}else{t+="column-major:";for(let e=0;e<this.ELEMENTS;++e)t+=` ${this[e]}`}return t+="]",t}getElementIndex(t,e){return e*this.RANK+t}getElement(t,e){return this[e*this.RANK+t]}setElement(t,e,r){return this[e*this.RANK+t]=w(r),this}getColumn(t,e=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)e[s]=this[r+s];return e}setColumn(t,e){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=e[s];return this}};function _n(){let n=new L(9);return L!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function Er(n){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function In(n,t){if(n===t){let e=t[1],r=t[2],s=t[3],i=t[6],c=t[7],o=t[11];n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=e,n[6]=t[9],n[7]=t[13],n[8]=r,n[9]=i,n[11]=t[14],n[12]=s,n[13]=c,n[14]=o}else n[0]=t[0],n[1]=t[4],n[2]=t[8],n[3]=t[12],n[4]=t[1],n[5]=t[5],n[6]=t[9],n[7]=t[13],n[8]=t[2],n[9]=t[6],n[10]=t[10],n[11]=t[14],n[12]=t[3],n[13]=t[7],n[14]=t[11],n[15]=t[15];return n}function Pn(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=t[4],o=t[5],a=t[6],f=t[7],h=t[8],p=t[9],l=t[10],x=t[11],m=t[12],M=t[13],d=t[14],E=t[15],O=e*o-r*c,g=e*a-s*c,y=e*f-i*c,A=r*a-s*o,T=r*f-i*o,N=s*f-i*a,_=h*M-p*m,I=h*d-l*m,P=h*E-x*m,v=p*d-l*M,u=p*E-x*M,k=l*E-x*d,S=O*k-g*u+y*v+A*P-T*I+N*_;return S?(S=1/S,n[0]=(o*k-a*u+f*v)*S,n[1]=(s*u-r*k-i*v)*S,n[2]=(M*N-d*T+E*A)*S,n[3]=(l*T-p*N-x*A)*S,n[4]=(a*P-c*k-f*I)*S,n[5]=(e*k-s*P+i*I)*S,n[6]=(d*y-m*N-E*g)*S,n[7]=(h*N-l*y+x*g)*S,n[8]=(c*u-o*P+f*_)*S,n[9]=(r*P-e*u-i*_)*S,n[10]=(m*T-M*y+E*O)*S,n[11]=(p*y-h*T-x*O)*S,n[12]=(o*I-c*v-a*_)*S,n[13]=(e*v-r*I+s*_)*S,n[14]=(M*g-m*A-d*O)*S,n[15]=(h*A-p*g+l*O)*S,n):null}function vn(n){let t=n[0],e=n[1],r=n[2],s=n[3],i=n[4],c=n[5],o=n[6],a=n[7],f=n[8],h=n[9],p=n[10],l=n[11],x=n[12],m=n[13],M=n[14],d=n[15],E=t*c-e*i,O=t*o-r*i,g=e*o-r*c,y=f*m-h*x,A=f*M-p*x,T=h*M-p*m,N=t*T-e*A+r*y,_=i*T-c*A+o*y,I=f*g-h*O+p*E,P=x*g-m*O+M*E;return a*N-s*_+d*I-l*P}function Ct(n,t,e){let r=t[0],s=t[1],i=t[2],c=t[3],o=t[4],a=t[5],f=t[6],h=t[7],p=t[8],l=t[9],x=t[10],m=t[11],M=t[12],d=t[13],E=t[14],O=t[15],g=e[0],y=e[1],A=e[2],T=e[3];return n[0]=g*r+y*o+A*p+T*M,n[1]=g*s+y*a+A*l+T*d,n[2]=g*i+y*f+A*x+T*E,n[3]=g*c+y*h+A*m+T*O,g=e[4],y=e[5],A=e[6],T=e[7],n[4]=g*r+y*o+A*p+T*M,n[5]=g*s+y*a+A*l+T*d,n[6]=g*i+y*f+A*x+T*E,n[7]=g*c+y*h+A*m+T*O,g=e[8],y=e[9],A=e[10],T=e[11],n[8]=g*r+y*o+A*p+T*M,n[9]=g*s+y*a+A*l+T*d,n[10]=g*i+y*f+A*x+T*E,n[11]=g*c+y*h+A*m+T*O,g=e[12],y=e[13],A=e[14],T=e[15],n[12]=g*r+y*o+A*p+T*M,n[13]=g*s+y*a+A*l+T*d,n[14]=g*i+y*f+A*x+T*E,n[15]=g*c+y*h+A*m+T*O,n}function un(n,t,e){let r=e[0],s=e[1],i=e[2],c,o,a,f,h,p,l,x,m,M,d,E;return t===n?(n[12]=t[0]*r+t[4]*s+t[8]*i+t[12],n[13]=t[1]*r+t[5]*s+t[9]*i+t[13],n[14]=t[2]*r+t[6]*s+t[10]*i+t[14],n[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(c=t[0],o=t[1],a=t[2],f=t[3],h=t[4],p=t[5],l=t[6],x=t[7],m=t[8],M=t[9],d=t[10],E=t[11],n[0]=c,n[1]=o,n[2]=a,n[3]=f,n[4]=h,n[5]=p,n[6]=l,n[7]=x,n[8]=m,n[9]=M,n[10]=d,n[11]=E,n[12]=c*r+h*s+m*i+t[12],n[13]=o*r+p*s+M*i+t[13],n[14]=a*r+l*s+d*i+t[14],n[15]=f*r+x*s+E*i+t[15]),n}function kn(n,t,e){let r=e[0],s=e[1],i=e[2];return n[0]=t[0]*r,n[1]=t[1]*r,n[2]=t[2]*r,n[3]=t[3]*r,n[4]=t[4]*s,n[5]=t[5]*s,n[6]=t[6]*s,n[7]=t[7]*s,n[8]=t[8]*i,n[9]=t[9]*i,n[10]=t[10]*i,n[11]=t[11]*i,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}function zn(n,t,e,r){let s=r[0],i=r[1],c=r[2],o=Math.sqrt(s*s+i*i+c*c),a,f,h,p,l,x,m,M,d,E,O,g,y,A,T,N,_,I,P,v,u,k,S,X;return o<1e-6?null:(o=1/o,s*=o,i*=o,c*=o,f=Math.sin(e),a=Math.cos(e),h=1-a,p=t[0],l=t[1],x=t[2],m=t[3],M=t[4],d=t[5],E=t[6],O=t[7],g=t[8],y=t[9],A=t[10],T=t[11],N=s*s*h+a,_=i*s*h+c*f,I=c*s*h-i*f,P=s*i*h-c*f,v=i*i*h+a,u=c*i*h+s*f,k=s*c*h+i*f,S=i*c*h-s*f,X=c*c*h+a,n[0]=p*N+M*_+g*I,n[1]=l*N+d*_+y*I,n[2]=x*N+E*_+A*I,n[3]=m*N+O*_+T*I,n[4]=p*P+M*v+g*u,n[5]=l*P+d*v+y*u,n[6]=x*P+E*v+A*u,n[7]=m*P+O*v+T*u,n[8]=p*k+M*S+g*X,n[9]=l*k+d*S+y*X,n[10]=x*k+E*S+A*X,n[11]=m*k+O*S+T*X,t!==n&&(n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n)}function bn(n,t,e){let r=Math.sin(e),s=Math.cos(e),i=t[4],c=t[5],o=t[6],a=t[7],f=t[8],h=t[9],p=t[10],l=t[11];return t!==n&&(n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[4]=i*s+f*r,n[5]=c*s+h*r,n[6]=o*s+p*r,n[7]=a*s+l*r,n[8]=f*s-i*r,n[9]=h*s-c*r,n[10]=p*s-o*r,n[11]=l*s-a*r,n}function qn(n,t,e){let r=Math.sin(e),s=Math.cos(e),i=t[0],c=t[1],o=t[2],a=t[3],f=t[8],h=t[9],p=t[10],l=t[11];return t!==n&&(n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*s-f*r,n[1]=c*s-h*r,n[2]=o*s-p*r,n[3]=a*s-l*r,n[8]=i*r+f*s,n[9]=c*r+h*s,n[10]=o*r+p*s,n[11]=a*r+l*s,n}function Fn(n,t,e){let r=Math.sin(e),s=Math.cos(e),i=t[0],c=t[1],o=t[2],a=t[3],f=t[4],h=t[5],p=t[6],l=t[7];return t!==n&&(n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15]),n[0]=i*s+f*r,n[1]=c*s+h*r,n[2]=o*s+p*r,n[3]=a*s+l*r,n[4]=f*s-i*r,n[5]=h*s-c*r,n[6]=p*s-o*r,n[7]=l*s-a*r,n}function Bn(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=e+e,o=r+r,a=s+s,f=e*c,h=r*c,p=r*o,l=s*c,x=s*o,m=s*a,M=i*c,d=i*o,E=i*a;return n[0]=1-p-m,n[1]=h+E,n[2]=l-d,n[3]=0,n[4]=h-E,n[5]=1-f-m,n[6]=x+M,n[7]=0,n[8]=l+d,n[9]=x-M,n[10]=1-f-p,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function Cn(n,t,e,r,s,i,c){let o=1/(e-t),a=1/(s-r),f=1/(i-c);return n[0]=i*2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i*2*a,n[6]=0,n[7]=0,n[8]=(e+t)*o,n[9]=(s+r)*a,n[10]=(c+i)*f,n[11]=-1,n[12]=0,n[13]=0,n[14]=c*i*2*f,n[15]=0,n}function Sr(n,t,e,r,s){let i=1/Math.tan(t/2);if(n[0]=i/e,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=i,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[11]=-1,n[12]=0,n[13]=0,n[15]=0,s!=null&&s!==1/0){let c=1/(r-s);n[10]=(s+r)*c,n[14]=2*s*r*c}else n[10]=-1,n[14]=-2*r;return n}var Un=Sr;function wr(n,t,e,r,s,i,c){let o=1/(t-e),a=1/(r-s),f=1/(i-c);return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*a,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*f,n[11]=0,n[12]=(t+e)*o,n[13]=(s+r)*a,n[14]=(c+i)*f,n[15]=1,n}var Vn=wr;function Dn(n,t,e,r){let s,i,c,o,a,f,h,p,l,x,m=t[0],M=t[1],d=t[2],E=r[0],O=r[1],g=r[2],y=e[0],A=e[1],T=e[2];return Math.abs(m-y)<1e-6&&Math.abs(M-A)<1e-6&&Math.abs(d-T)<1e-6?Er(n):(p=m-y,l=M-A,x=d-T,s=1/Math.sqrt(p*p+l*l+x*x),p*=s,l*=s,x*=s,i=O*x-g*l,c=g*p-E*x,o=E*l-O*p,s=Math.sqrt(i*i+c*c+o*o),s?(s=1/s,i*=s,c*=s,o*=s):(i=0,c=0,o=0),a=l*o-x*c,f=x*i-p*o,h=p*c-l*i,s=Math.sqrt(a*a+f*f+h*h),s?(s=1/s,a*=s,f*=s,h*=s):(a=0,f=0,h=0),n[0]=i,n[1]=a,n[2]=p,n[3]=0,n[4]=c,n[5]=f,n[6]=l,n[7]=0,n[8]=o,n[9]=h,n[10]=x,n[11]=0,n[12]=-(i*m+c*M+o*d),n[13]=-(a*m+f*M+h*d),n[14]=-(p*m+l*M+x*d),n[15]=1,n)}function Or(){let n=new L(4);return L!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0,n[3]=0),n}function Yn(n,t,e){return n[0]=t[0]+e[0],n[1]=t[1]+e[1],n[2]=t[2]+e[2],n[3]=t[3]+e[3],n}function $n(n,t,e){return n[0]=t[0]*e,n[1]=t[1]*e,n[2]=t[2]*e,n[3]=t[3]*e,n}function Wn(n){let t=n[0],e=n[1],r=n[2],s=n[3];return Math.sqrt(t*t+e*e+r*r+s*s)}function Gn(n){let t=n[0],e=n[1],r=n[2],s=n[3];return t*t+e*e+r*r+s*s}function Hn(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=e*e+r*r+s*s+i*i;return c>0&&(c=1/Math.sqrt(c)),n[0]=e*c,n[1]=r*c,n[2]=s*c,n[3]=i*c,n}function Xn(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]+n[3]*t[3]}function jn(n,t,e,r){let s=t[0],i=t[1],c=t[2],o=t[3];return n[0]=s+r*(e[0]-s),n[1]=i+r*(e[1]-i),n[2]=c+r*(e[2]-c),n[3]=o+r*(e[3]-o),n}function Kn(n,t,e){let r=t[0],s=t[1],i=t[2],c=t[3];return n[0]=e[0]*r+e[4]*s+e[8]*i+e[12]*c,n[1]=e[1]*r+e[5]*s+e[9]*i+e[13]*c,n[2]=e[2]*r+e[6]*s+e[10]*i+e[14]*c,n[3]=e[3]*r+e[7]*s+e[11]*i+e[15]*c,n}function Qn(n,t,e){let r=t[0],s=t[1],i=t[2],c=e[0],o=e[1],a=e[2],f=e[3],h=f*r+o*i-a*s,p=f*s+a*r-c*i,l=f*i+c*s-o*r,x=-c*r-o*s-a*i;return n[0]=h*f+x*-c+p*-a-l*-o,n[1]=p*f+x*-o+l*-c-h*-a,n[2]=l*f+x*-a+h*-o-p*-c,n[3]=t[3],n}var Oi=function(){let n=Or();return function(t,e,r,s,i,c){let o,a;for(e||(e=4),r||(r=0),s?a=Math.min(s*e+r,t.length):a=t.length,o=r;o<a;o+=e)n[0]=t[o],n[1]=t[o+1],n[2]=t[o+2],n[3]=t[o+3],i(n,n,c),t[o]=n[0],t[o+1]=n[1],t[o+2]=n[2],t[o+3]=n[3];return t}}();var Dt;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL0ROW3=3]="COL0ROW3",n[n.COL1ROW0=4]="COL1ROW0",n[n.COL1ROW1=5]="COL1ROW1",n[n.COL1ROW2=6]="COL1ROW2",n[n.COL1ROW3=7]="COL1ROW3",n[n.COL2ROW0=8]="COL2ROW0",n[n.COL2ROW1=9]="COL2ROW1",n[n.COL2ROW2=10]="COL2ROW2",n[n.COL2ROW3=11]="COL2ROW3",n[n.COL3ROW0=12]="COL3ROW0",n[n.COL3ROW1=13]="COL3ROW1",n[n.COL3ROW2=14]="COL3ROW2",n[n.COL3ROW3=15]="COL3ROW3"})(Dt||(Dt={}));var Lr=45*Math.PI/180,Nr=1,Ut=.1,Vt=500,_r=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),B=class extends At{static get IDENTITY(){return Pr()}static get ZERO(){return Ir()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Dt}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,e,r,s,i,c,o,a,f,h,p,l,x,m,M,d){return this[0]=t,this[1]=e,this[2]=r,this[3]=s,this[4]=i,this[5]=c,this[6]=o,this[7]=a,this[8]=f,this[9]=h,this[10]=p,this[11]=l,this[12]=x,this[13]=m,this[14]=M,this[15]=d,this.check()}setRowMajor(t,e,r,s,i,c,o,a,f,h,p,l,x,m,M,d){return this[0]=t,this[1]=i,this[2]=f,this[3]=x,this[4]=e,this[5]=c,this[6]=h,this[7]=m,this[8]=r,this[9]=o,this[10]=p,this[11]=M,this[12]=s,this[13]=a,this[14]=l,this[15]=d,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(_r)}fromObject(t){return this.check()}fromQuaternion(t){return Bn(this,t),this.check()}frustum(t){let{left:e,right:r,bottom:s,top:i,near:c=Ut,far:o=Vt}=t;return o===1/0?vr(this,e,r,s,i,c):Cn(this,e,r,s,i,c,o),this.check()}lookAt(t){let{eye:e,center:r=[0,0,0],up:s=[0,1,0]}=t;return Dn(this,e,r,s),this.check()}ortho(t){let{left:e,right:r,bottom:s,top:i,near:c=Ut,far:o=Vt}=t;return Vn(this,e,r,s,i,c,o),this.check()}orthographic(t){let{fovy:e=Lr,aspect:r=Nr,focalDistance:s=1,near:i=Ut,far:c=Vt}=t;Zn(e);let o=e/2,a=s*Math.tan(o),f=a*r;return this.ortho({left:-f,right:f,bottom:-a,top:a,near:i,far:c})}perspective(t){let{fovy:e=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return Zn(e),Un(this,e,r,s,i),this.check()}determinant(){return vn(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,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let r=this.getScale(e),s=1/r[0],i=1/r[1],c=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*c,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*c,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,e){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],e=e||[-0,-0,-0];let r=this.getScale(e),s=1/r[0],i=1/r[1],c=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*c,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*c,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*c,t}transpose(){return In(this,this),this.check()}invert(){return Pn(this,this),this.check()}multiplyLeft(t){return Ct(this,t,this),this.check()}multiplyRight(t){return Ct(this,this,t),this.check()}rotateX(t){return bn(this,this,t),this.check()}rotateY(t){return qn(this,this,t),this.check()}rotateZ(t){return Fn(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,e){return zn(this,this,t,e),this.check()}scale(t){return kn(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return un(this,this,t),this.check()}transform(t,e){return t.length===4?(e=Kn(e||[-0,-0,-0,-0],t,this),$(e,4),e):this.transformAsPoint(t,e)}transformAsPoint(t,e){let{length:r}=t,s;switch(r){case 2:s=An(e||[-0,-0],t,this);break;case 3:s=gt(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $(s,t.length),s}transformAsVector(t,e){let r;switch(t.length){case 2:r=Tn(e||[-0,-0],t,this);break;case 3:r=En(e||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return $(r,t.length),r}transformPoint(t,e){return this.transformAsPoint(t,e)}transformVector(t,e){return this.transformAsPoint(t,e)}transformDirection(t,e){return this.transformAsVector(t,e)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,e,r){return this.identity().translate([t,e,r])}},Tt,Et;function Ir(){return Tt||(Tt=new B([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Tt)),Tt}function Pr(){return Et||(Et=new B,Object.freeze(Et)),Et}function Zn(n){if(n>Math.PI*2)throw Error("expected radians")}function vr(n,t,e,r,s,i){let c=2*i/(e-t),o=2*i/(s-r),a=(e+t)/(e-t),f=(s+r)/(s-r),h=-1,p=-1,l=-2*i;return n[0]=c,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=o,n[6]=0,n[7]=0,n[8]=a,n[9]=f,n[10]=h,n[11]=p,n[12]=0,n[13]=0,n[14]=l,n[15]=0,n}function Jn(){let n=new L(4);return L!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function te(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function Yt(n,t,e){e=e*.5;let r=Math.sin(e);return n[0]=r*t[0],n[1]=r*t[1],n[2]=r*t[2],n[3]=Math.cos(e),n}function $t(n,t,e){let r=t[0],s=t[1],i=t[2],c=t[3],o=e[0],a=e[1],f=e[2],h=e[3];return n[0]=r*h+c*o+s*f-i*a,n[1]=s*h+c*a+i*o-r*f,n[2]=i*h+c*f+r*a-s*o,n[3]=c*h-r*o-s*a-i*f,n}function ne(n,t,e){e*=.5;let r=t[0],s=t[1],i=t[2],c=t[3],o=Math.sin(e),a=Math.cos(e);return n[0]=r*a+c*o,n[1]=s*a+i*o,n[2]=i*a-s*o,n[3]=c*a-r*o,n}function ee(n,t,e){e*=.5;let r=t[0],s=t[1],i=t[2],c=t[3],o=Math.sin(e),a=Math.cos(e);return n[0]=r*a-i*o,n[1]=s*a+c*o,n[2]=i*a+r*o,n[3]=c*a-s*o,n}function re(n,t,e){e*=.5;let r=t[0],s=t[1],i=t[2],c=t[3],o=Math.sin(e),a=Math.cos(e);return n[0]=r*a+s*o,n[1]=s*a-r*o,n[2]=i*a+c*o,n[3]=c*a-i*o,n}function se(n,t){let e=t[0],r=t[1],s=t[2];return n[0]=e,n[1]=r,n[2]=s,n[3]=Math.sqrt(Math.abs(1-e*e-r*r-s*s)),n}function nt(n,t,e,r){let s=t[0],i=t[1],c=t[2],o=t[3],a=e[0],f=e[1],h=e[2],p=e[3],l,x,m,M,d;return l=s*a+i*f+c*h+o*p,l<0&&(l=-l,a=-a,f=-f,h=-h,p=-p),1-l>1e-6?(x=Math.acos(l),d=Math.sin(x),m=Math.sin((1-r)*x)/d,M=Math.sin(r*x)/d):(m=1-r,M=r),n[0]=m*s+M*a,n[1]=m*i+M*f,n[2]=m*c+M*h,n[3]=m*o+M*p,n}function ie(n,t){let e=t[0],r=t[1],s=t[2],i=t[3],c=e*e+r*r+s*s+i*i,o=c?1/c:0;return n[0]=-e*o,n[1]=-r*o,n[2]=-s*o,n[3]=i*o,n}function ce(n,t){return n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=t[3],n}function Wt(n,t){let e=t[0]+t[4]+t[8],r;if(e>0)r=Math.sqrt(e+1),n[3]=.5*r,r=.5/r,n[0]=(t[5]-t[7])*r,n[1]=(t[6]-t[2])*r,n[2]=(t[1]-t[3])*r;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,c=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[c*3+c]+1),n[s]=.5*r,r=.5/r,n[3]=(t[i*3+c]-t[c*3+i])*r,n[i]=(t[i*3+s]+t[s*3+i])*r,n[c]=(t[c*3+s]+t[s*3+c])*r}return n}var oe=Yn;var ae=$n,fe=Xn,he=jn,le=Wn;var pe=Gn;var xe=Hn;var me=function(){let n=Ft(),t=Bt(1,0,0),e=Bt(0,1,0);return function(r,s,i){let c=Rn(s,i);return c<-.999999?(dt(n,t,s),Nn(n)<1e-6&&dt(n,e,s),On(n,n),Yt(r,n,Math.PI),r):c>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(dt(n,s,i),r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=1+c,xe(r,r))}}(),Bi=function(){let n=Jn(),t=Jn();return function(e,r,s,i,c,o){return nt(n,r,c,o),nt(t,s,i,o),nt(e,n,t,2*o*(1-o)),e}}(),Ci=function(){let n=_n();return function(t,e,r,s){return n[0]=r[0],n[3]=r[1],n[6]=r[2],n[1]=s[0],n[4]=s[1],n[7]=s[2],n[2]=-e[0],n[5]=-e[1],n[8]=-e[2],xe(t,Wt(t,n))}}();var ur=[0,0,0,1],et=class extends U{constructor(t=0,e=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,e,r,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,e,r,s){return this[0]=t,this[1]=e,this[2]=r,this[3]=s,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return Wt(this,t),this.check()}fromAxisRotation(t,e){return Yt(this,t,e),this.check()}identity(){return te(this),this.check()}setAxisAngle(t,e){return this.fromAxisRotation(t,e)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=w(t)}get y(){return this[1]}set y(t){this[1]=w(t)}get z(){return this[2]}set z(t){this[2]=w(t)}get w(){return this[3]}set w(t){this[3]=w(t)}len(){return le(this)}lengthSquared(){return pe(this)}dot(t){return fe(this,t)}rotationTo(t,e){return me(this,t,e),this.check()}add(t){return oe(this,this,t),this.check()}calculateW(){return se(this,this),this.check()}conjugate(){return ce(this,this),this.check()}invert(){return ie(this,this),this.check()}lerp(t,e,r){return r===void 0?this.lerp(this,t,e):(he(this,t,e,r),this.check())}multiplyRight(t){return $t(this,this,t),this.check()}multiplyLeft(t){return $t(this,t,this),this.check()}normalize(){let t=this.len(),e=t>0?1/t:0;return this[0]=this[0]*e,this[1]=this[1]*e,this[2]=this[2]*e,this[3]=this[3]*e,t===0&&(this[3]=1),this.check()}rotateX(t){return ne(this,this,t),this.check()}rotateY(t){return ee(this,this,t),this.check()}rotateZ(t){return re(this,this,t),this.check()}scale(t){return ae(this,this,t),this.check()}slerp(t,e,r){let s,i,c;switch(arguments.length){case 1:({start:s=ur,target:i,ratio:c}=t);break;case 2:s=this,i=t,c=e;break;default:s=t,i=e,c=r}return nt(this,s,i,c),this.check()}transformVector4(t,e=new W){return Qn(e,t,this),$(e,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,e){return this.setAxisAngle(t,e)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var Ht=C(j(),1);var kr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},zr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Xt=class{name;startTime=0;playing=!0;speed=1;channels=[];constructor(t){Object.assign(this,t)}animate(t){if(!this.playing)return;let r=(t/1e3-this.startTime)*this.speed;this.channels.forEach(({sampler:s,target:i,path:c})=>{Ur(r,s,i,c),qr(i,i._node)})}},G=class{animations;constructor(t){this.animations=t.animations.map((e,r)=>{let s=e.name||`Animation-${r}`,i=e.samplers.map(({input:o,interpolation:a="LINEAR",output:f})=>({input:Me(t.accessors[o]),interpolation:a,output:Me(t.accessors[f])})),c=e.channels.map(({sampler:o,target:a})=>({sampler:i[o],target:t.nodes[a.node],path:a.path}));return new Xt({name:s,channels:c})})}animate(t){this.setTime(t)}setTime(t){this.animations.forEach(e=>e.animate(t))}getAnimations(){return this.animations}};function Me(n){if(!n._animation){let t=zr[n.componentType],e=kr[n.type],r=e*n.count,{buffer:s,byteOffset:i}=n.bufferView.data,c=new t(s,i+(n.byteOffset||0),r);if(e===1)n._animation=Array.from(c);else{let o=[];for(let a=0;a<c.length;a+=e)o.push(Array.from(c.slice(a,a+e)));n._animation=o}}return n._animation}var br=new B;function qr(n,t){if(t.matrix.identity(),n.translation&&t.matrix.translate(n.translation),n.rotation){let e=br.fromQuaternion(n.rotation);t.matrix.multiplyRight(e)}n.scale&&t.matrix.scale(n.scale)}var Gt=new et;function Fr(n,t,e,r,s){if(t==="rotation"){Gt.slerp({start:e,target:r,ratio:s});for(let i=0;i<Gt.length;i++)n[t][i]=Gt[i]}else for(let i=0;i<e.length;i++)n[t][i]=s*r[i]+(1-s)*e[i]}function Br(n,t,{p0:e,outTangent0:r,inTangent1:s,p1:i,tDiff:c,ratio:o}){for(let a=0;a<n[t].length;a++){let f=r[a]*c,h=s[a]*c;n[t][a]=(2*Math.pow(o,3)-3*Math.pow(o,2)+1)*e[a]+(Math.pow(o,3)-2*Math.pow(o,2)+o)*f+(-2*Math.pow(o,3)+3*Math.pow(o,2))*i[a]+(Math.pow(o,3)-Math.pow(o,2))*h}}function Cr(n,t,e){for(let r=0;r<e.length;r++)n[t][r]=e[r]}function Ur(n,{input:t,interpolation:e,output:r},s,i){let c=t[t.length-1],o=n%c,a=t.findIndex(l=>l>=o),f=Math.max(0,a-1);if(!Array.isArray(s[i]))switch(i){case"translation":s[i]=[0,0,0];break;case"rotation":s[i]=[0,0,0,1];break;case"scale":s[i]=[1,1,1];break;default:Ht.log.warn(`Bad animation path ${i}`)()}let h=t[f],p=t[a];switch(e){case"STEP":Cr(s,i,r[f]);break;case"LINEAR":if(p>h){let l=(o-h)/(p-h);Fr(s,i,r[f],r[a],l)}break;case"CUBICSPLINE":if(p>h){let l=(o-h)/(p-h),x=p-h,m=r[3*f+1],M=r[3*f+2],d=r[3*a+0],E=r[3*a+1];Br(s,i,{p0:m,outTangent0:M,inTangent1:d,p1:E,tDiff:x,ratio:l})}break;default:Ht.log.warn(`Interpolation ${e} not supported`)();break}}var ye=C(j(),1),Ae=C(ge(),1),St=C(at(),1);var Vr=`
|
|
8
8
|
layout(0) positions: vec4; // in vec4 POSITION;
|
|
9
9
|
|
|
10
10
|
#ifdef HAS_NORMALS
|
|
@@ -49,7 +49,7 @@ layout(0) positions: vec4; // in vec4 POSITION;
|
|
|
49
49
|
vec3 pos = pbr_vPosition;
|
|
50
50
|
fragmentColor = pbr_filterColor(vec4(1.0));
|
|
51
51
|
}
|
|
52
|
-
`,
|
|
52
|
+
`,Dr=`#version 300 es
|
|
53
53
|
|
|
54
54
|
// in vec4 POSITION;
|
|
55
55
|
in vec4 positions;
|
|
@@ -86,15 +86,15 @@ layout(0) positions: vec4; // in vec4 POSITION;
|
|
|
86
86
|
#endif
|
|
87
87
|
|
|
88
88
|
pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0);
|
|
89
|
-
gl_Position =
|
|
89
|
+
gl_Position = pbrProjection.modelViewProjectionMatrix * positions;
|
|
90
90
|
}
|
|
91
|
-
`,
|
|
91
|
+
`,Yr=`#version 300 es
|
|
92
92
|
out vec4 fragmentColor;
|
|
93
93
|
|
|
94
94
|
void main(void) {
|
|
95
95
|
vec3 pos = pbr_vPosition;
|
|
96
96
|
fragmentColor = pbr_filterColor(vec4(1.0));
|
|
97
97
|
}
|
|
98
|
-
`;function
|
|
98
|
+
`;function Te(n,t){let{id:e,geometry:r,material:s,vertexCount:i,materialOptions:c,modelOptions:o}=t,a=ot(n,s,r.attributes,c);ye.log.info(4,"createGLTFModel defines: ",a.defines)();let f=[],h={depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back"},p={id:e,source:Vr,vs:Dr,fs:Yr,geometry:r,topology:r.topology,vertexCount:i,modules:[Ae.pbrMaterial],...o,defines:{...a.defines,...o.defines},parameters:{...h,...a.parameters,...o.parameters}},l=new St.Model(n,p),{camera:x,...m}={...a.uniforms,...o.uniforms,...a.bindings,...o.bindings};return l.shaderInputs.setProps({pbrMaterial:m,pbrProjection:{camera:x}}),new St.ModelNode({managedResources:f,model:l})}var D;(function(n){n[n.POINTS=0]="POINTS",n[n.LINES=1]="LINES",n[n.LINE_LOOP=2]="LINE_LOOP",n[n.LINE_STRIP=3]="LINE_STRIP",n[n.TRIANGLES=4]="TRIANGLES",n[n.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",n[n.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(D||(D={}));function Ee(n){switch(n){case D.POINTS:return"point-list";case D.LINES:return"line-list";case D.LINE_STRIP:return"line-strip";case D.TRIANGLES:return"triangle-list";case D.TRIANGLE_STRIP:return"triangle-strip";default:throw new Error(String(n))}}var $r={modelOptions:{},pbrDebug:!1,imageBasedLightingEnvironment:null,lights:!0,useTangents:!1},wt=class{device;options;gltf;constructor(t,e={}){this.device=t,this.options={...$r,...e}}instantiate(t){return this.gltf=jt(t),(this.gltf.scenes||[]).map(r=>this.createScene(r))}createAnimator(){return Array.isArray(this.gltf.animations)?new G(this.gltf):null}createScene(t){let r=(t.nodes||[]).map(i=>this.createNode(i));return new H.GroupNode({id:t.name||t.id,children:r})}createNode(t){if(!t._node){let s=(t.children||[]).map(c=>this.createNode(c));t.mesh&&s.push(this.createMesh(t.mesh));let i=new H.GroupNode({id:t.name||t.id,children:s});if(t.matrix)i.setMatrix(t.matrix);else{if(i.matrix.identity(),t.translation&&i.matrix.translate(t.translation),t.rotation){let c=new B().fromQuaternion(t.rotation);i.matrix.multiplyRight(c)}t.scale&&i.matrix.scale(t.scale)}t._node=i}let e=this.gltf.nodes.find(r=>r.id===t.id);return e._node=t._node,t._node}createMesh(t){if(!t._mesh){let r=(t.primitives||[]).map((i,c)=>this.createPrimitive(i,c,t)),s=new H.GroupNode({id:t.name||t.id,children:r});t._mesh=s}return t._mesh}createPrimitive(t,e,r){let s=t.name||`${r.name||r.id}-primitive-${e}`,i=Ee(t.mode||4),c=t.indices?t.indices.count:this.getVertexCount(t.attributes),o=Te(this.device,{id:s,geometry:this.createGeometry(s,t,i),material:t.material,materialOptions:this.options,modelOptions:this.options.modelOptions,vertexCount:c});return o.bounds=[t.attributes.POSITION.min,t.attributes.POSITION.max],o}getVertexCount(t){throw new Error("getVertexCount not implemented")}createGeometry(t,e,r){let s={};for(let[i,c]of Object.entries(e.attributes)){let{components:o,size:a,value:f}=c;s[i]={size:a??o,value:f}}return new H.Geometry({id:t,topology:r,indices:e.indices.value,attributes:s})}createBuffer(t,e){t.bufferView||(t.bufferView={});let{bufferView:r}=t;return r.lumaBuffers||(r.lumaBuffers={}),r.lumaBuffers[e]||(r.lumaBuffers[e]=this.device.createBuffer({id:`from-${r.id}`,data:r.data||t.value})),r.lumaBuffers[e]}createSampler(t){return t}needsPOT(){return!1}};function jt(n){if(ArrayBuffer.isView(n)||n instanceof ArrayBuffer)return n;if(Array.isArray(n))return n.map(jt);if(n&&typeof n=="object"){let t={};for(let e in n)t[e]=jt(n[e]);return t}return n}function Se(n,t,e){let r=new wt(n,e),s=r.instantiate(t),i=r.createAnimator();return{scenes:s,animator:i}}return Ie(rt);})();
|
|
99
99
|
return __exports__;
|
|
100
100
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-gltf-model.d.ts","sourceRoot":"","sources":["../../src/gltf/create-gltf-model.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAgC,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAC,QAAQ,EAAS,SAAS,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAC,uBAAuB,EAAmB,qCAAkC;AAuGpF,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,GAAG,CAAC;IACd,eAAe,EAAE,uBAAuB,CAAC;IACzC,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"create-gltf-model.d.ts","sourceRoot":"","sources":["../../src/gltf/create-gltf-model.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAgC,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAC,QAAQ,EAAS,SAAS,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAC,uBAAuB,EAAmB,qCAAkC;AAuGpF,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,GAAG,CAAC;IACd,eAAe,EAAE,uBAAuB,CAAC;IACzC,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,SAAS,CA8C1F"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
import { log } from '@luma.gl/core';
|
|
5
|
-
import {
|
|
5
|
+
import { pbrMaterial } from '@luma.gl/shadertools';
|
|
6
6
|
import { Model, ModelNode } from '@luma.gl/engine';
|
|
7
7
|
import { parsePBRMaterial } from "../pbr/parse-pbr-material.js";
|
|
8
8
|
const SHADER = /* WGSL */ `
|
|
@@ -91,7 +91,7 @@ const vs = /* glsl */ `\
|
|
|
91
91
|
#endif
|
|
92
92
|
|
|
93
93
|
pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0);
|
|
94
|
-
gl_Position =
|
|
94
|
+
gl_Position = pbrProjection.modelViewProjectionMatrix * positions;
|
|
95
95
|
}
|
|
96
96
|
`;
|
|
97
97
|
const fs = /* glsl */ `\
|
|
@@ -127,13 +127,18 @@ export function createGLTFModel(device, options) {
|
|
|
127
127
|
geometry,
|
|
128
128
|
topology: geometry.topology,
|
|
129
129
|
vertexCount,
|
|
130
|
-
modules: [
|
|
130
|
+
modules: [pbrMaterial],
|
|
131
131
|
...modelOptions,
|
|
132
|
-
bindings: { ...parsedMaterial.bindings, ...modelOptions.bindings },
|
|
133
132
|
defines: { ...parsedMaterial.defines, ...modelOptions.defines },
|
|
134
|
-
parameters: { ...parameters, ...parsedMaterial.parameters, ...modelOptions.parameters }
|
|
135
|
-
uniforms: { ...parsedMaterial.uniforms, ...modelOptions.uniforms }
|
|
133
|
+
parameters: { ...parameters, ...parsedMaterial.parameters, ...modelOptions.parameters }
|
|
136
134
|
};
|
|
137
135
|
const model = new Model(device, modelProps);
|
|
136
|
+
const { camera, ...pbrMaterialProps } = {
|
|
137
|
+
...parsedMaterial.uniforms,
|
|
138
|
+
...modelOptions.uniforms,
|
|
139
|
+
...parsedMaterial.bindings,
|
|
140
|
+
...modelOptions.bindings
|
|
141
|
+
};
|
|
142
|
+
model.shaderInputs.setProps({ pbrMaterial: pbrMaterialProps, pbrProjection: { camera } });
|
|
138
143
|
return new ModelNode({ managedResources, model });
|
|
139
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-instantiator.d.ts","sourceRoot":"","sources":["../../src/gltf/gltf-instantiator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAC,QAAQ,EAAqB,SAAS,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAG9F,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAE7C,OAAO,KAAK,EAAC,cAAc,EAAC,kCAA+B;AAG3D,MAAM,MAAM,uBAAuB,GAAG;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6BAA6B,CAAC,EAAE,cAAc,CAAC;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAUF;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,uBAAuB,CAAC;IACjC,IAAI,EAAE,GAAG,CAAC;gBAEE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;IAKjE,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,SAAS,EAAE;IAMnC,cAAc,IAAI,YAAY;IAQ9B,WAAW,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS;IAUtC,UAAU,CAAC,QAAQ,KAAA;
|
|
1
|
+
{"version":3,"file":"gltf-instantiator.d.ts","sourceRoot":"","sources":["../../src/gltf/gltf-instantiator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChE,OAAO,EAAC,QAAQ,EAAqB,SAAS,EAAE,SAAS,EAAE,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAG9F,OAAO,EAAC,YAAY,EAAC,2BAAwB;AAE7C,OAAO,KAAK,EAAC,cAAc,EAAC,kCAA+B;AAG3D,MAAM,MAAM,uBAAuB,GAAG;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6BAA6B,CAAC,EAAE,cAAc,CAAC;IAC/C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAUF;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,uBAAuB,CAAC;IACjC,IAAI,EAAE,GAAG,CAAC;gBAEE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;IAKjE,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,SAAS,EAAE;IAMnC,cAAc,IAAI,YAAY;IAQ9B,WAAW,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS;IAUtC,UAAU,CAAC,QAAQ,KAAA;IA2CnB,UAAU,CAAC,QAAQ,KAAA,GAAG,SAAS;IAiB/B,eAAe,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,KAAA,GAAG,SAAS;IA0BnE,cAAc,CAAC,UAAU,EAAE,GAAG;IAI9B,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,iBAAiB,GAAG,QAAQ;IAgBrF,YAAY,CAAC,SAAS,KAAA,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAuB9C,aAAa,CAAC,WAAW,KAAA;IAMzB,QAAQ,IAAI,OAAO;CAOpB"}
|
|
@@ -26,8 +26,8 @@ export class GLTFInstantiator {
|
|
|
26
26
|
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
27
27
|
}
|
|
28
28
|
instantiate(gltf) {
|
|
29
|
-
this.gltf = gltf;
|
|
30
|
-
const scenes = (gltf.scenes || []).map(scene => this.createScene(scene));
|
|
29
|
+
this.gltf = deepCopy(gltf);
|
|
30
|
+
const scenes = (this.gltf.scenes || []).map(scene => this.createScene(scene));
|
|
31
31
|
return scenes;
|
|
32
32
|
}
|
|
33
33
|
createAnimator() {
|
|
@@ -75,6 +75,9 @@ export class GLTFInstantiator {
|
|
|
75
75
|
}
|
|
76
76
|
gltfNode._node = node;
|
|
77
77
|
}
|
|
78
|
+
// Copy _node so that gltf-animator can access
|
|
79
|
+
const topLevelNode = this.gltf.nodes.find(node => node.id === gltfNode.id);
|
|
80
|
+
topLevelNode._node = gltfNode._node;
|
|
78
81
|
return gltfNode._node;
|
|
79
82
|
}
|
|
80
83
|
createMesh(gltfMesh) {
|
|
@@ -159,3 +162,21 @@ export class GLTFInstantiator {
|
|
|
159
162
|
return false;
|
|
160
163
|
}
|
|
161
164
|
}
|
|
165
|
+
/** Deeply copies a JS data structure */
|
|
166
|
+
function deepCopy(object) {
|
|
167
|
+
// don't copy binary data
|
|
168
|
+
if (ArrayBuffer.isView(object) || object instanceof ArrayBuffer) {
|
|
169
|
+
return object;
|
|
170
|
+
}
|
|
171
|
+
if (Array.isArray(object)) {
|
|
172
|
+
return object.map(deepCopy);
|
|
173
|
+
}
|
|
174
|
+
if (object && typeof object === 'object') {
|
|
175
|
+
const result = {};
|
|
176
|
+
for (const key in object) {
|
|
177
|
+
result[key] = deepCopy(object[key]);
|
|
178
|
+
}
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
return object;
|
|
182
|
+
}
|