@deck.gl/mesh-layers
Version:
deck.gl layers that loads 3D meshes or scene graphs
266 lines (238 loc) • 279 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if (typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if (typeof define === 'function' && define.amd) define([], factory);
else if (typeof exports === 'object') exports['deck'] = factory();
else root['deck'] = factory();})(globalThis, function () {
"use strict";var __exports__=(()=>{var Hi=Object.create;var ut=Object.defineProperty;var Vi=Object.getOwnPropertyDescriptor;var Ji=Object.getOwnPropertyNames;var ki=Object.getPrototypeOf,Ki=Object.prototype.hasOwnProperty;var Qt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),k=(t,e)=>{for(var r in e)ut(t,r,{get:e[r],enumerable:!0})},pt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ji(e))!Ki.call(t,o)&&o!==r&&ut(t,o,{get:()=>e[o],enumerable:!(n=Vi(e,o))||n.enumerable});return t},se=(t,e,r)=>(pt(t,e,"default"),r&&pt(r,e,"default")),L=(t,e,r)=>(r=t!=null?Hi(ki(t)):{},pt(e||!t||!t.__esModule?ut(r,"default",{value:t,enumerable:!0}):r,t)),ji=t=>pt(ut({},"__esModule",{value:!0}),t);var Me=Qt((bu,Mn)=>{Mn.exports=globalThis.deck});var ie=Qt((xu,Tn)=>{Tn.exports=globalThis.luma});var Ce=Qt((Mu,En)=>{En.exports=globalThis.luma});var ft={};k(ft,{ScenegraphLayer:()=>Gi,SimpleMeshLayer:()=>Dn});var W={},Cn=L(Me(),1);se(W,L(Me(),1));if(!Cn.Layer)throw new Error("@deck.gl/core is not found");se(ft,W);var q=L(Me(),1),Nn=L(ie(),1),Te=L(Ce(),1);var _n=L(Me(),1),Wt=Math.PI/180,mt=new Float32Array(16),Rn=new Float32Array(12);function yn(t,e,r){let n=e[0]*Wt,o=e[1]*Wt,s=e[2]*Wt,i=Math.sin(s),a=Math.sin(n),c=Math.sin(o),l=Math.cos(s),f=Math.cos(n),p=Math.cos(o),u=r[0],m=r[1],h=r[2];t[0]=u*p*f,t[1]=u*c*f,t[2]=u*-a,t[3]=m*(-c*l+p*a*i),t[4]=m*(p*l+c*a*i),t[5]=m*f*i,t[6]=h*(c*i+p*a*l),t[7]=h*(-p*i+c*a*l),t[8]=h*f*l}function Sn(t){return t[0]=t[0],t[1]=t[1],t[2]=t[2],t[3]=t[4],t[4]=t[5],t[5]=t[6],t[6]=t[8],t[7]=t[9],t[8]=t[10],t[9]=t[12],t[10]=t[13],t[11]=t[14],t.subarray(0,12)}var ht={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(t,{startRow:e,endRow:r}){let{data:n,getOrientation:o,getScale:s,getTranslation:i,getTransformMatrix:a}=this.props,c=Array.isArray(a),l=c&&a.length===16,f=Array.isArray(s),p=Array.isArray(o),u=Array.isArray(i),m=l||!c&&Boolean(a(n[0]));m?t.constant=l:t.constant=p&&f&&u;let h=t.value;if(t.constant){let d;m?(mt.set(a),d=Sn(mt)):(d=Rn,yn(d,o,s),d.set(i,9)),t.value=new Float32Array(d)}else{let d=e*t.size,{iterable:A,objectInfo:b}=(0,_n.createIterable)(n,e,r);for(let M of A){b.index++;let g;if(m)mt.set(l?a:a(M,b)),g=Sn(mt);else{g=Rn;let B=p?o:o(M,b),x=f?s:s(M,b);yn(g,B,x),g.set(u?i:i(M,b),9)}h[d++]=g[0],h[d++]=g[1],h[d++]=g[2],h[d++]=g[3],h[d++]=g[4],h[d++]=g[5],h[d++]=g[6],h[d++]=g[7],h[d++]=g[8],h[d++]=g[9],h[d++]=g[10],h[d++]=g[11]}}}};function dt(t,e){return e==="cartesian"||e==="meter-offsets"||e==="default"&&!t.isGeospatial}var In=`layout(std140) uniform simpleMeshUniforms {
float sizeScale;
bool composeModelMatrix;
bool hasTexture;
bool flatShading;
} simpleMesh;
`,vn={name:"simpleMesh",vs:In,fs:In,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}};var Fn=`#version 300 es
#define SHADER_NAME simple-mesh-layer-vs
in vec3 positions;
in vec3 normals;
in vec3 colors;
in vec2 texCoords;
in vec3 instancePositions;
in vec3 instancePositions64Low;
in vec4 instanceColors;
in vec3 instancePickingColors;
in vec3 instanceModelMatrixCol0;
in vec3 instanceModelMatrixCol1;
in vec3 instanceModelMatrixCol2;
in vec3 instanceTranslation;
out vec2 vTexCoord;
out vec3 cameraPosition;
out vec3 normals_commonspace;
out vec4 position_commonspace;
out vec4 vColor;
void main(void) {
geometry.worldPosition = instancePositions;
geometry.uv = texCoords;
geometry.pickingColor = instancePickingColors;
vTexCoord = texCoords;
cameraPosition = project.cameraPosition;
vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale + instanceTranslation;
if (simpleMesh.composeModelMatrix) {
DECKGL_FILTER_SIZE(pos, geometry);
normals_commonspace = project_normal(instanceModelMatrix * normals);
geometry.worldPosition += pos;
gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace);
geometry.position = position_commonspace;
}
else {
pos = project_size(pos);
DECKGL_FILTER_SIZE(pos, geometry);
gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace);
geometry.position = position_commonspace;
normals_commonspace = project_normal(instanceModelMatrix * normals);
}
geometry.normal = normals_commonspace;
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
DECKGL_FILTER_COLOR(vColor, geometry);
}
`;var Ln=`#version 300 es
#define SHADER_NAME simple-mesh-layer-fs
precision highp float;
uniform sampler2D sampler;
in vec2 vTexCoord;
in vec3 cameraPosition;
in vec3 normals_commonspace;
in vec4 position_commonspace;
in vec4 vColor;
out vec4 fragColor;
void main(void) {
geometry.uv = vTexCoord;
vec3 normal;
if (simpleMesh.flatShading) {
normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
} else {
normal = normals_commonspace;
}
vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;
DECKGL_FILTER_COLOR(color, geometry);
vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
fragColor = vec4(lightColor, color.a * layer.opacity);
}
`;function qt(t){let e=1/0,r=1/0,n=1/0,o=-1/0,s=-1/0,i=-1/0,a=t.POSITION?t.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let f=a[l],p=a[l+1],u=a[l+2];e=f<e?f:e,r=p<r?p:r,n=u<n?u:n,o=f>o?f:o,s=p>s?p:s,i=u>i?u:i}return[[e,r,n],[o,s,i]]}function Zt(t){let e=t.positions||t.POSITION;q.log.assert(e,'no "postions" or "POSITION" attribute in mesh');let r=e.value.length/e.size,n=t.COLOR_0||t.colors;n||(n={size:3,value:new Float32Array(r*3).fill(1)});let o=t.NORMAL||t.normals;o||(o={size:3,value:new Float32Array(r*3).fill(0)});let s=t.TEXCOORD_0||t.texCoords;return s||(s={size:2,value:new Float32Array(r*2).fill(0)}),{positions:e,colors:n,normals:o,texCoords:s}}function On(t){return t instanceof Te.Geometry?(t.attributes=Zt(t.attributes),t):t.attributes?new Te.Geometry({...t,topology:"triangle-list",attributes:Zt(t.attributes)}):new Te.Geometry({topology:"triangle-list",attributes:Zt(t)})}var zi=[0,0,0,255],Xi={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:zi},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}},Ve=class extends q.Layer{getShaders(){return super.getShaders({vs:Fn,fs:Ln,modules:[q.project32,q.phongMaterial,q.picking,vn]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;let{mesh:r}=this.props;if(!r)return null;if(e=r.header?.boundingBox,!e){let{attributes:n}=On(r);n.POSITION=n.POSITION||n.positions,e=qt(n)}return this.state.positionBounds=e,e}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:ht}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);let{props:r,oldProps:n,changeFlags:o}=e;if(r.mesh!==n.mesh||o.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),r.mesh){this.state.model=this.getModel(r.mesh);let s=r.mesh.attributes||r.mesh;this.setState({hasNormals:Boolean(s.NORMAL||s.normals)})}this.getAttributeManager().invalidateAll()}r.texture!==n.texture&&r.texture instanceof Nn.Texture&&this.setTexture(r.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){let{model:r}=this.state;if(!r)return;let{viewport:n,renderPass:o}=this.context,{sizeScale:s,coordinateSystem:i,_instanced:a}=this.props,c={sizeScale:s,composeModelMatrix:!a||dt(n,i),flatShading:!this.state.hasNormals};r.shaderInputs.setProps({simpleMesh:c}),r.draw(o)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){let r=new Te.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:On(e),isInstanced:!0}),{texture:n}=this.props,{emptyTexture:o}=this.state,s={sampler:n||o,hasTexture:Boolean(n)};return r.shaderInputs.setProps({simpleMesh:s}),r}setTexture(e){let{emptyTexture:r,model:n}=this.state;if(n){let o={sampler:e||r,hasTexture:Boolean(e)};n.shaderInputs.setProps({simpleMesh:o})}}};Ve.defaultProps=Xi;Ve.layerName="SimpleMeshLayer";var Dn=Ve;var re=L(Me(),1);var Uu=1/Math.PI*180,Pu=1/180*Math.PI,Yi={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Yi}};var _=globalThis.mathgl.config;function Un(t,{precision:e=_.precision}={}){return t=Qi(t),`${parseFloat(t.toPrecision(e))}`}function ae(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function $t(t,e,r){let n=_.EPSILON;r&&(_.EPSILON=r);try{if(t===e)return!0;if(ae(t)&&ae(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!$t(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=_.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{_.EPSILON=n}}function Qi(t){return Math.round(t/_.EPSILON)*_.EPSILON}var ce=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:ae(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(_)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Un(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!$t(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let s=e[o],i=typeof r=="number"?r:r[o];this[o]=s+n*(i-s)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(_.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),r);return this.check()}get elements(){return this}};function Wi(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function T(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function le(t,e,r=""){if(_.debug&&!Wi(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function er(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var Ee=class extends ce{get x(){return this[0]}set x(e){this[0]=T(e)}get y(){return this[1]}set y(e){this[1]=T(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let n=0;n<this.ELEMENTS;++n){let o=this[n]-e[n];r+=o*o}return T(r)}dot(e){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*e[n];return T(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return er(e>=0&&e<this.ELEMENTS,"index is out of range"),T(this[e])}setComponent(e,r){return er(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var D=typeof Float32Array<"u"?Float32Array:Array;var Yu=Math.PI/180;function qi(){let t=new D(2);return D!=Float32Array&&(t[0]=0,t[1]=0),t}function Gn(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[3]*o+r[6],t[1]=r[1]*n+r[4]*o+r[7],t}function Hn(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[4]*o+r[12],t[1]=r[1]*n+r[5]*o+r[13],t}var Qu=function(){let t=qi();return function(e,r,n,o,s,i){let a,c;for(r||(r=2),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],s(t,t,i),e[a]=t[0],e[a+1]=t[1];return e}}();function Vn(t,e,r){let n=e[0],o=e[1],s=r[3]*n+r[7]*o||1;return t[0]=(r[0]*n+r[4]*o)/s,t[1]=(r[1]*n+r[5]*o)/s,t}function At(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s||1;return t[0]=(r[0]*n+r[4]*o+r[8]*s)/i,t[1]=(r[1]*n+r[5]*o+r[9]*s)/i,t[2]=(r[2]*n+r[6]*o+r[10]*s)/i,t}function Jn(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t[2]=e[2],t}function kn(t,e,r){let n=e[0],o=e[1];return t[0]=r[0]*n+r[2]*o,t[1]=r[1]*n+r[3]*o,t[2]=e[2],t[3]=e[3],t}function gt(t,e,r){let n=e[0],o=e[1],s=e[2];return t[0]=r[0]*n+r[3]*o+r[6]*s,t[1]=r[1]*n+r[4]*o+r[7]*s,t[2]=r[2]*n+r[5]*o+r[8]*s,t[3]=e[3],t}function tr(){let t=new D(3);return D!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Zi(t){let e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function rr(t,e,r){let n=new D(3);return n[0]=t,n[1]=e,n[2]=r,n}function Kn(t,e){let r=e[0],n=e[1],o=e[2],s=r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function nr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Re(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2];return t[0]=o*c-s*a,t[1]=s*i-n*c,t[2]=n*a-o*i,t}function ye(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[3]*n+r[7]*o+r[11]*s+r[15];return i=i||1,t[0]=(r[0]*n+r[4]*o+r[8]*s+r[12])/i,t[1]=(r[1]*n+r[5]*o+r[9]*s+r[13])/i,t[2]=(r[2]*n+r[6]*o+r[10]*s+r[14])/i,t}function bt(t,e,r){let n=e[0],o=e[1],s=e[2];return t[0]=n*r[0]+o*r[3]+s*r[6],t[1]=n*r[1]+o*r[4]+s*r[7],t[2]=n*r[2]+o*r[5]+s*r[8],t}function Bt(t,e,r){let n=r[0],o=r[1],s=r[2],i=r[3],a=e[0],c=e[1],l=e[2],f=o*l-s*c,p=s*a-n*l,u=n*c-o*a,m=o*u-s*p,h=s*f-n*u,d=n*p-o*f,A=i*2;return f*=A,p*=A,u*=A,m*=2,h*=2,d*=2,t[0]=a+f+m,t[1]=c+p+h,t[2]=l+u+d,t}function jn(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0],s[1]=o[1]*Math.cos(n)-o[2]*Math.sin(n),s[2]=o[1]*Math.sin(n)+o[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function zn(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[2]*Math.sin(n)+o[0]*Math.cos(n),s[1]=o[1],s[2]=o[2]*Math.cos(n)-o[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function Xn(t,e,r,n){let o=[],s=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],s[0]=o[0]*Math.cos(n)-o[1]*Math.sin(n),s[1]=o[0]*Math.sin(n)+o[1]*Math.cos(n),s[2]=o[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t}function Yn(t,e){let r=t[0],n=t[1],o=t[2],s=e[0],i=e[1],a=e[2],c=Math.sqrt((r*r+n*n+o*o)*(s*s+i*i+a*a)),l=c&&nr(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}var Qn=Zi;var Zu=function(){let t=tr();return function(e,r,n,o,s,i){let a,c;for(r||(r=3),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var or=[0,0,0],xt,Ae=class extends Ee{static get ZERO(){return xt||(xt=new Ae(0,0,0),Object.freeze(xt)),xt}constructor(e=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&ae(e)?this.copy(e):(_.debug&&(T(e),T(r),T(n)),this[0]=e,this[1]=r,this[2]=n)}set(e,r,n){return this[0]=e,this[1]=r,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return _.debug&&(T(e.x),T(e.y),T(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=T(e)}angle(e){return Yn(this,e)}cross(e){return Re(this,this,e),this.check()}rotateX({radians:e,origin:r=or}){return jn(this,this,r,e),this.check()}rotateY({radians:e,origin:r=or}){return zn(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=or}){return Xn(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return ye(this,this,e),this.check()}transformAsVector(e){return At(this,this,e),this.check()}transformByMatrix3(e){return bt(this,this,e),this.check()}transformByMatrix2(e){return Jn(this,this,e),this.check()}transformByQuaternion(e){return Bt(this,this,e),this.check()}};var Mt,Se=class extends Ee{static get ZERO(){return Mt||(Mt=new Se(0,0,0,0),Object.freeze(Mt)),Mt}constructor(e=0,r=0,n=0,o=0){super(-0,-0,-0,-0),ae(e)&&arguments.length===1?this.copy(e):(_.debug&&(T(e),T(r),T(n),T(o)),this[0]=e,this[1]=r,this[2]=n,this[3]=o)}set(e,r,n,o){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return _.debug&&(T(e.x),T(e.y),T(e.z),T(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=T(e)}get w(){return this[3]}set w(e){this[3]=T(e)}transform(e){return ye(this,this,e),this.check()}transformByMatrix3(e){return gt(this,this,e),this.check()}transformByMatrix2(e){return kn(this,this,e),this.check()}transformByQuaternion(e){return Bt(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}};var _e=class extends ce{toString(){let e="[";if(_.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=T(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[n+o];return r}setColumn(e,r){let n=e*this.RANK;for(let o=0;o<this.RANK;++o)this[n+o]=r[o];return this}};function Wn(){let t=new D(9);return D!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function qn(t,e){if(t===e){let r=e[1],n=e[2],o=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=o}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function Zn(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],p=f*i-a*l,u=-f*s+a*c,m=l*s-i*c,h=r*p+n*u+o*m;return h?(h=1/h,t[0]=p*h,t[1]=(-f*n+o*l)*h,t[2]=(a*n-o*i)*h,t[3]=u*h,t[4]=(f*r-o*c)*h,t[5]=(-a*r+o*s)*h,t[6]=m*h,t[7]=(-l*r+n*c)*h,t[8]=(i*r-n*s)*h,t):null}function $n(t){let e=t[0],r=t[1],n=t[2],o=t[3],s=t[4],i=t[5],a=t[6],c=t[7],l=t[8];return e*(l*s-i*c)+r*(-l*o+i*a)+n*(c*o-s*a)}function sr(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],p=e[8],u=r[0],m=r[1],h=r[2],d=r[3],A=r[4],b=r[5],M=r[6],g=r[7],B=r[8];return t[0]=u*n+m*i+h*l,t[1]=u*o+m*a+h*f,t[2]=u*s+m*c+h*p,t[3]=d*n+A*i+b*l,t[4]=d*o+A*a+b*f,t[5]=d*s+A*c+b*p,t[6]=M*n+g*i+B*l,t[7]=M*o+g*a+B*f,t[8]=M*s+g*c+B*p,t}function eo(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],p=e[8],u=r[0],m=r[1];return t[0]=n,t[1]=o,t[2]=s,t[3]=i,t[4]=a,t[5]=c,t[6]=u*n+m*i+l,t[7]=u*o+m*a+f,t[8]=u*s+m*c+p,t}function to(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],p=e[8],u=Math.sin(r),m=Math.cos(r);return t[0]=m*n+u*i,t[1]=m*o+u*a,t[2]=m*s+u*c,t[3]=m*i-u*n,t[4]=m*a-u*o,t[5]=m*c-u*s,t[6]=l,t[7]=f,t[8]=p,t}function ir(t,e,r){let n=r[0],o=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=o*e[3],t[4]=o*e[4],t[5]=o*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function ro(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r+r,a=n+n,c=o+o,l=r*i,f=n*i,p=n*a,u=o*i,m=o*a,h=o*c,d=s*i,A=s*a,b=s*c;return t[0]=1-p-h,t[3]=f-b,t[6]=u+A,t[1]=f+b,t[4]=1-l-h,t[7]=m-d,t[2]=u-A,t[5]=m+d,t[8]=1-l-p,t}var ar;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(ar||(ar={}));var ta=Object.freeze([1,0,0,0,1,0,0,0,1]),U=class extends _e{static get IDENTITY(){return na()}static get ZERO(){return ra()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return ar}constructor(e,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):r.length>0?this.copy([e,...r]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(ta)}fromObject(e){return this.check()}fromQuaternion(e){return ro(this,e),this.check()}set(e,r,n,o,s,i,a,c,l){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=s,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,n,o,s,i,a,c,l){return this[0]=e,this[1]=o,this[2]=a,this[3]=r,this[4]=s,this[5]=c,this[6]=n,this[7]=i,this[8]=l,this.check()}determinant(){return $n(this)}transpose(){return qn(this,this),this.check()}invert(){return Zn(this,this),this.check()}multiplyLeft(e){return sr(this,e,this),this.check()}multiplyRight(e){return sr(this,this,e),this.check()}rotate(e){return to(this,this,e),this.check()}scale(e){return Array.isArray(e)?ir(this,this,e):ir(this,this,[e,e]),this.check()}translate(e){return eo(this,this,e),this.check()}transform(e,r){let n;switch(e.length){case 2:n=Gn(r||[-0,-0],e,this);break;case 3:n=bt(r||[-0,-0,-0],e,this);break;case 4:n=gt(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return le(n,e.length),n}transformVector(e,r){return this.transform(e,r)}transformVector2(e,r){return this.transform(e,r)}transformVector3(e,r){return this.transform(e,r)}},Ct,Tt=null;function ra(){return Ct||(Ct=new U([0,0,0,0,0,0,0,0,0]),Object.freeze(Ct)),Ct}function na(){return Tt||(Tt=new U,Object.freeze(Tt)),Tt}function oa(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function no(t,e){if(t===e){let r=e[1],n=e[2],o=e[3],s=e[6],i=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=s,t[11]=e[14],t[12]=o,t[13]=i,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function oo(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=e[4],a=e[5],c=e[6],l=e[7],f=e[8],p=e[9],u=e[10],m=e[11],h=e[12],d=e[13],A=e[14],b=e[15],M=r*a-n*i,g=r*c-o*i,B=r*l-s*i,x=n*c-o*a,C=n*l-s*a,P=o*l-s*c,w=f*d-p*h,G=f*A-u*h,H=f*b-m*h,X=p*A-u*d,Y=p*b-m*d,Q=u*b-m*A,y=M*Q-g*Y+B*X+x*H-C*G+P*w;return y?(y=1/y,t[0]=(a*Q-c*Y+l*X)*y,t[1]=(o*Y-n*Q-s*X)*y,t[2]=(d*P-A*C+b*x)*y,t[3]=(u*C-p*P-m*x)*y,t[4]=(c*H-i*Q-l*G)*y,t[5]=(r*Q-o*H+s*G)*y,t[6]=(A*B-h*P-b*g)*y,t[7]=(f*P-u*B+m*g)*y,t[8]=(i*Y-a*H+l*w)*y,t[9]=(n*H-r*Y-s*w)*y,t[10]=(h*C-d*B+b*M)*y,t[11]=(p*B-f*C-m*M)*y,t[12]=(a*G-i*X-c*w)*y,t[13]=(r*X-n*G+o*w)*y,t[14]=(d*g-h*x-A*M)*y,t[15]=(f*x-p*g+u*M)*y,t):null}function so(t){let e=t[0],r=t[1],n=t[2],o=t[3],s=t[4],i=t[5],a=t[6],c=t[7],l=t[8],f=t[9],p=t[10],u=t[11],m=t[12],h=t[13],d=t[14],A=t[15],b=e*i-r*s,M=e*a-n*s,g=r*a-n*i,B=l*h-f*m,x=l*d-p*m,C=f*d-p*h,P=e*C-r*x+n*B,w=s*C-i*x+a*B,G=l*g-f*M+p*b,H=m*g-h*M+d*b;return c*P-o*w+A*G-u*H}function cr(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=e[4],c=e[5],l=e[6],f=e[7],p=e[8],u=e[9],m=e[10],h=e[11],d=e[12],A=e[13],b=e[14],M=e[15],g=r[0],B=r[1],x=r[2],C=r[3];return t[0]=g*n+B*a+x*p+C*d,t[1]=g*o+B*c+x*u+C*A,t[2]=g*s+B*l+x*m+C*b,t[3]=g*i+B*f+x*h+C*M,g=r[4],B=r[5],x=r[6],C=r[7],t[4]=g*n+B*a+x*p+C*d,t[5]=g*o+B*c+x*u+C*A,t[6]=g*s+B*l+x*m+C*b,t[7]=g*i+B*f+x*h+C*M,g=r[8],B=r[9],x=r[10],C=r[11],t[8]=g*n+B*a+x*p+C*d,t[9]=g*o+B*c+x*u+C*A,t[10]=g*s+B*l+x*m+C*b,t[11]=g*i+B*f+x*h+C*M,g=r[12],B=r[13],x=r[14],C=r[15],t[12]=g*n+B*a+x*p+C*d,t[13]=g*o+B*c+x*u+C*A,t[14]=g*s+B*l+x*m+C*b,t[15]=g*i+B*f+x*h+C*M,t}function io(t,e,r){let n=r[0],o=r[1],s=r[2],i,a,c,l,f,p,u,m,h,d,A,b;return e===t?(t[12]=e[0]*n+e[4]*o+e[8]*s+e[12],t[13]=e[1]*n+e[5]*o+e[9]*s+e[13],t[14]=e[2]*n+e[6]*o+e[10]*s+e[14],t[15]=e[3]*n+e[7]*o+e[11]*s+e[15]):(i=e[0],a=e[1],c=e[2],l=e[3],f=e[4],p=e[5],u=e[6],m=e[7],h=e[8],d=e[9],A=e[10],b=e[11],t[0]=i,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=p,t[6]=u,t[7]=m,t[8]=h,t[9]=d,t[10]=A,t[11]=b,t[12]=i*n+f*o+h*s+e[12],t[13]=a*n+p*o+d*s+e[13],t[14]=c*n+u*o+A*s+e[14],t[15]=l*n+m*o+b*s+e[15]),t}function ao(t,e,r){let n=r[0],o=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function co(t,e,r,n){let o=n[0],s=n[1],i=n[2],a=Math.sqrt(o*o+s*s+i*i),c,l,f,p,u,m,h,d,A,b,M,g,B,x,C,P,w,G,H,X,Y,Q,y,He;return a<1e-6?null:(a=1/a,o*=a,s*=a,i*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,p=e[0],u=e[1],m=e[2],h=e[3],d=e[4],A=e[5],b=e[6],M=e[7],g=e[8],B=e[9],x=e[10],C=e[11],P=o*o*f+c,w=s*o*f+i*l,G=i*o*f-s*l,H=o*s*f-i*l,X=s*s*f+c,Y=i*s*f+o*l,Q=o*i*f+s*l,y=s*i*f-o*l,He=i*i*f+c,t[0]=p*P+d*w+g*G,t[1]=u*P+A*w+B*G,t[2]=m*P+b*w+x*G,t[3]=h*P+M*w+C*G,t[4]=p*H+d*X+g*Y,t[5]=u*H+A*X+B*Y,t[6]=m*H+b*X+x*Y,t[7]=h*H+M*X+C*Y,t[8]=p*Q+d*y+g*He,t[9]=u*Q+A*y+B*He,t[10]=m*Q+b*y+x*He,t[11]=h*Q+M*y+C*He,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function lo(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[4],i=e[5],a=e[6],c=e[7],l=e[8],f=e[9],p=e[10],u=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=s*o+l*n,t[5]=i*o+f*n,t[6]=a*o+p*n,t[7]=c*o+u*n,t[8]=l*o-s*n,t[9]=f*o-i*n,t[10]=p*o-a*n,t[11]=u*o-c*n,t}function fo(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[0],i=e[1],a=e[2],c=e[3],l=e[8],f=e[9],p=e[10],u=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o-l*n,t[1]=i*o-f*n,t[2]=a*o-p*n,t[3]=c*o-u*n,t[8]=s*n+l*o,t[9]=i*n+f*o,t[10]=a*n+p*o,t[11]=c*n+u*o,t}function po(t,e,r){let n=Math.sin(r),o=Math.cos(r),s=e[0],i=e[1],a=e[2],c=e[3],l=e[4],f=e[5],p=e[6],u=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=s*o+l*n,t[1]=i*o+f*n,t[2]=a*o+p*n,t[3]=c*o+u*n,t[4]=l*o-s*n,t[5]=f*o-i*n,t[6]=p*o-a*n,t[7]=u*o-c*n,t}function uo(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r+r,a=n+n,c=o+o,l=r*i,f=n*i,p=n*a,u=o*i,m=o*a,h=o*c,d=s*i,A=s*a,b=s*c;return t[0]=1-p-h,t[1]=f+b,t[2]=u-A,t[3]=0,t[4]=f-b,t[5]=1-l-h,t[6]=m+d,t[7]=0,t[8]=u+A,t[9]=m-d,t[10]=1-l-p,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function mo(t,e,r,n,o,s,i){let a=1/(r-e),c=1/(o-n),l=1/(s-i);return t[0]=s*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+n)*c,t[10]=(i+s)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=i*s*2*l,t[15]=0,t}function sa(t,e,r,n,o){let s=1/Math.tan(e/2);if(t[0]=s/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let i=1/(n-o);t[10]=(o+n)*i,t[14]=2*o*n*i}else t[10]=-1,t[14]=-2*n;return t}var ho=sa;function ia(t,e,r,n,o,s,i){let a=1/(e-r),c=1/(n-o),l=1/(s-i);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+n)*c,t[14]=(i+s)*l,t[15]=1,t}var Ao=ia;function go(t,e,r,n){let o,s,i,a,c,l,f,p,u,m,h=e[0],d=e[1],A=e[2],b=n[0],M=n[1],g=n[2],B=r[0],x=r[1],C=r[2];return Math.abs(h-B)<1e-6&&Math.abs(d-x)<1e-6&&Math.abs(A-C)<1e-6?oa(t):(p=h-B,u=d-x,m=A-C,o=1/Math.sqrt(p*p+u*u+m*m),p*=o,u*=o,m*=o,s=M*m-g*u,i=g*p-b*m,a=b*u-M*p,o=Math.sqrt(s*s+i*i+a*a),o?(o=1/o,s*=o,i*=o,a*=o):(s=0,i=0,a=0),c=u*a-m*i,l=m*s-p*a,f=p*i-u*s,o=Math.sqrt(c*c+l*l+f*f),o?(o=1/o,c*=o,l*=o,f*=o):(c=0,l=0,f=0),t[0]=s,t[1]=c,t[2]=p,t[3]=0,t[4]=i,t[5]=l,t[6]=u,t[7]=0,t[8]=a,t[9]=f,t[10]=m,t[11]=0,t[12]=-(s*h+i*d+a*A),t[13]=-(c*h+l*d+f*A),t[14]=-(p*h+u*d+m*A),t[15]=1,t)}function aa(){let t=new D(4);return D!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function bo(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function Bo(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function xo(t){let e=t[0],r=t[1],n=t[2],o=t[3];return Math.sqrt(e*e+r*r+n*n+o*o)}function Mo(t){let e=t[0],r=t[1],n=t[2],o=t[3];return e*e+r*r+n*n+o*o}function Co(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=r*i,t[1]=n*i,t[2]=o*i,t[3]=s*i,t}function To(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Eo(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3];return t[0]=o+n*(r[0]-o),t[1]=s+n*(r[1]-s),t[2]=i+n*(r[2]-i),t[3]=a+n*(r[3]-a),t}function Ro(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3];return t[0]=r[0]*n+r[4]*o+r[8]*s+r[12]*i,t[1]=r[1]*n+r[5]*o+r[9]*s+r[13]*i,t[2]=r[2]*n+r[6]*o+r[10]*s+r[14]*i,t[3]=r[3]*n+r[7]*o+r[11]*s+r[15]*i,t}function yo(t,e,r){let n=e[0],o=e[1],s=e[2],i=r[0],a=r[1],c=r[2],l=r[3],f=l*n+a*s-c*o,p=l*o+c*n-i*s,u=l*s+i*o-a*n,m=-i*n-a*o-c*s;return t[0]=f*l+m*-i+p*-c-u*-a,t[1]=p*l+m*-a+u*-i-f*-c,t[2]=u*l+m*-c+f*-a-p*-i,t[3]=e[3],t}var Tm=function(){let t=aa();return function(e,r,n,o,s,i){let a,c;for(r||(r=4),n||(n=0),o?c=Math.min(o*r+n,e.length):c=e.length,a=n;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],s(t,t,i),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var pr;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(pr||(pr={}));var la=45*Math.PI/180,fa=1,lr=.1,fr=500,pa=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),V=class extends _e{static get IDENTITY(){return ma()}static get ZERO(){return ua()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return pr}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,o,s,i,a,c,l,f,p,u,m,h,d,A){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this[4]=s,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=p,this[11]=u,this[12]=m,this[13]=h,this[14]=d,this[15]=A,this.check()}setRowMajor(e,r,n,o,s,i,a,c,l,f,p,u,m,h,d,A){return this[0]=e,this[1]=s,this[2]=l,this[3]=m,this[4]=r,this[5]=i,this[6]=f,this[7]=h,this[8]=n,this[9]=a,this[10]=p,this[11]=d,this[12]=o,this[13]=c,this[14]=u,this[15]=A,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(pa)}fromObject(e){return this.check()}fromQuaternion(e){return uo(this,e),this.check()}frustum(e){let{left:r,right:n,bottom:o,top:s,near:i=lr,far:a=fr}=e;return a===1/0?ha(this,r,n,o,s,i):mo(this,r,n,o,s,i,a),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:o=[0,1,0]}=e;return go(this,r,n,o),this.check()}ortho(e){let{left:r,right:n,bottom:o,top:s,near:i=lr,far:a=fr}=e;return Ao(this,r,n,o,s,i,a),this.check()}orthographic(e){let{fovy:r=la,aspect:n=fa,focalDistance:o=1,near:s=lr,far:i=fr}=e;So(r);let a=r/2,c=o*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:i})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:o=.1,far:s=500}=e;return So(r),ho(this,r,n,o,s),this.check()}determinant(){return so(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],s=1/n[1],i=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*s,e[2]=this[2]*i,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*s,e[6]=this[6]*i,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*s,e[10]=this[10]*i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),o=1/n[0],s=1/n[1],i=1/n[2];return e[0]=this[0]*o,e[1]=this[1]*s,e[2]=this[2]*i,e[3]=this[4]*o,e[4]=this[5]*s,e[5]=this[6]*i,e[6]=this[8]*o,e[7]=this[9]*s,e[8]=this[10]*i,e}transpose(){return no(this,this),this.check()}invert(){return oo(this,this),this.check()}multiplyLeft(e){return cr(this,e,this),this.check()}multiplyRight(e){return cr(this,this,e),this.check()}rotateX(e){return lo(this,this,e),this.check()}rotateY(e){return fo(this,this,e),this.check()}rotateZ(e){return po(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return co(this,this,e,r),this.check()}scale(e){return ao(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return io(this,this,e),this.check()}transform(e,r){return e.length===4?(r=Ro(r||[-0,-0,-0,-0],e,this),le(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,o;switch(n){case 2:o=Hn(r||[-0,-0],e,this);break;case 3:o=ye(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return le(o,e.length),o}transformAsVector(e,r){let n;switch(e.length){case 2:n=Vn(r||[-0,-0],e,this);break;case 3:n=At(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return le(n,e.length),n}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},Et,Rt;function ua(){return Et||(Et=new V([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Et)),Et}function ma(){return Rt||(Rt=new V,Object.freeze(Rt)),Rt}function So(t){if(t>Math.PI*2)throw Error("expected radians")}function ha(t,e,r,n,o,s){let i=2*s/(r-e),a=2*s/(o-n),c=(r+e)/(r-e),l=(o+n)/(o-n),f=-1,p=-1,u=-2*s;return t[0]=i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=p,t[12]=0,t[13]=0,t[14]=u,t[15]=0,t}function _o(){let t=new D(4);return D!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Io(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function ur(t,e,r){r=r*.5;let n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function mr(t,e,r){let n=e[0],o=e[1],s=e[2],i=e[3],a=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+i*a+o*l-s*c,t[1]=o*f+i*c+s*a-n*l,t[2]=s*f+i*l+n*c-o*a,t[3]=i*f-n*a-o*c-s*l,t}function vo(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=o*c+s*a,t[2]=s*c-o*a,t[3]=i*c-n*a,t}function Fo(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-s*a,t[1]=o*c+i*a,t[2]=s*c+n*a,t[3]=i*c-o*a,t}function Lo(t,e,r){r*=.5;let n=e[0],o=e[1],s=e[2],i=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+o*a,t[1]=o*c-n*a,t[2]=s*c+i*a,t[3]=i*c-s*a,t}function Oo(t,e){let r=e[0],n=e[1],o=e[2];return t[0]=r,t[1]=n,t[2]=o,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-o*o)),t}function ke(t,e,r,n){let o=e[0],s=e[1],i=e[2],a=e[3],c=r[0],l=r[1],f=r[2],p=r[3],u,m,h,d,A;return u=o*c+s*l+i*f+a*p,u<0&&(u=-u,c=-c,l=-l,f=-f,p=-p),1-u>1e-6?(m=Math.acos(u),A=Math.sin(m),h=Math.sin((1-n)*m)/A,d=Math.sin(n*m)/A):(h=1-n,d=n),t[0]=h*o+d*c,t[1]=h*s+d*l,t[2]=h*i+d*f,t[3]=h*a+d*p,t}function No(t,e){let r=e[0],n=e[1],o=e[2],s=e[3],i=r*r+n*n+o*o+s*s,a=i?1/i:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-o*a,t[3]=s*a,t}function Do(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function hr(t,e){let r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{let o=0;e[4]>e[0]&&(o=1),e[8]>e[o*3+o]&&(o=2);let s=(o+1)%3,i=(o+2)%3;n=Math.sqrt(e[o*3+o]-e[s*3+s]-e[i*3+i]+1),t[o]=.5*n,n=.5/n,t[3]=(e[s*3+i]-e[i*3+s])*n,t[s]=(e[s*3+o]+e[o*3+s])*n,t[i]=(e[i*3+o]+e[o*3+i])*n}return t}var Uo=bo;var Po=Bo,wo=To,Go=Eo,Ho=xo;var Vo=Mo;var Jo=Co;var ko=function(){let t=tr(),e=rr(1,0,0),r=rr(0,1,0);return function(n,o,s){let i=nr(o,s);return i<-.999999?(Re(t,e,o),Qn(t)<1e-6&&Re(t,r,o),Kn(t,t),ur(n,t,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Re(t,o,s),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+i,Jo(n,n))}}(),Pm=function(){let t=_o(),e=_o();return function(r,n,o,s,i,a){return ke(t,n,i,a),ke(e,o,s,a),ke(r,t,e,2*a*(1-a)),r}}(),wm=function(){let t=Wn();return function(e,r,n,o){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=o[0],t[4]=o[1],t[7]=o[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],Jo(e,hr(e,t))}}();var da=[0,0,0,1],Ke=class extends ce{constructor(e=0,r=0,n=0,o=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,n,o)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,n,o){return this[0]=e,this[1]=r,this[2]=n,this[3]=o,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return hr(this,e),this.check()}fromAxisRotation(e,r){return ur(this,e,r),this.check()}identity(){return Io(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=T(e)}get y(){return this[1]}set y(e){this[1]=T(e)}get z(){return this[2]}set z(e){this[2]=T(e)}get w(){return this[3]}set w(e){this[3]=T(e)}len(){return Ho(this)}lengthSquared(){return Vo(this)}dot(e){return wo(this,e)}rotationTo(e,r){return ko(this,e,r),this.check()}add(e){return Uo(this,this,e),this.check()}calculateW(){return Oo(this,this),this.check()}conjugate(){return Do(this,this),this.check()}invert(){return No(this,this),this.check()}lerp(e,r,n){return n===void 0?this.lerp(this,e,r):(Go(this,e,r,n),this.check())}multiplyRight(e){return mr(this,this,e),this.check()}multiplyLeft(e){return mr(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return vo(this,this,e),this.check()}rotateY(e){return Fo(this,this,e),this.check()}rotateZ(e){return Lo(this,this,e),this.check()}scale(e){return Po(this,this,e),this.check()}slerp(e,r,n){let o,s,i;switch(arguments.length){case 1:({start:o=da,target:s,ratio:i}=e);break;case 2:o=this,s=e,i=r;break;default:o=e,s=r,i=n}return ke(this,o,s,i),this.check()}transformVector4(e,r=new Se){return yo(r,e,this),le(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};function dr(t,e=!0){return t??e}function je(t=[0,0,0],e=!0){return e?t.map(r=>r/255):[...t]}var ze=20,Aa=`
struct skinUniforms {
jointMatrix: array<mat4x4<f32>, ${ze}>,
};
@group(0) @binding(auto) var<uniform> skin: skinUniforms;
fn getSkinMatrix(weights: vec4f, joints: vec4u) -> mat4x4<f32> {
return (weights.x * skin.jointMatrix[joints.x])
+ (weights.y * skin.jointMatrix[joints.y])
+ (weights.z * skin.jointMatrix[joints.z])
+ (weights.w * skin.jointMatrix[joints.w]);
}
`,ga=`
layout(std140) uniform skinUniforms {
mat4 jointMatrix[SKIN_MAX_JOINTS];
} skin;
mat4 getSkinMatrix(vec4 weights, uvec4 joints) {
return (weights.x * skin.jointMatrix[joints.x])
+ (weights.y * skin.jointMatrix[joints.y])
+ (weights.z * skin.jointMatrix[joints.z])
+ (weights.w * skin.jointMatrix[joints.w]);
}
`,ba="",Ar={props:{},uniforms:{},name:"skin",bindingLayout:[{name:"skin",group:0}],dependencies:[],source:Aa,vs:ga,fs:ba,defines:{SKIN_MAX_JOINTS:ze},getUniforms:(t={},e)=>{let{scenegraphsFromGLTF:r}=t;if(!r?.gltf?.skins?.[0])return{jointMatrix:[]};let{inverseBindMatrices:n,joints:o,skeleton:s}=r.gltf.skins[0],i=[],a=n.value.length/16;for(let p=0;p<a;p++){let u=n.value.subarray(p*16,p*16+16);i.push(new V(Array.from(u)))}let c=r.gltfNodeIndexToNodeMap.get(s),l={};c.preorderTraversal((p,{worldMatrix:u})=>{l[p.id]=u});let f=new Float32Array(ze*16);for(let p=0;p<ze;++p){let u=o[p];if(u===void 0)break;let m=l[r.gltfNodeIndexToNodeMap.get(u).id],h=i[p],d=new V().copy(m).multiplyRight(h),A=p*16;for(let b=0;b<16;b++)f[A+b]=d[b]}return{jointMatrix:f}},uniformTypes:{jointMatrix:["mat4x4<f32>",ze]}};var jo=L(ie(),1);var gr=`precision highp int;
// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
struct AmbientLight {
vec3 color;
};
struct PointLight {
vec3 color;
vec3 position;
vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential
};
struct SpotLight {
vec3 color;
vec3 position;
vec3 direction;
vec3 attenuation;
vec2 coneCos;
};
struct DirectionalLight {
vec3 color;
vec3 direction;
};
struct UniformLight {
vec3 color;
vec3 position;
vec3 direction;
vec3 attenuation;
vec2 coneCos;
};
layout(std140) uniform lightingUniforms {
int enabled;
int directionalLightCount;
int pointLightCount;
int spotLightCount;
vec3 ambientColor;
UniformLight lights[5];
} lighting;
PointLight lighting_getPointLight(int index) {
UniformLight light = lighting.lights[index];
return PointLight(light.color, light.position, light.attenuation);
}
SpotLight lighting_getSpotLight(int index) {
UniformLight light = lighting.lights[lighting.pointLightCount + index];
return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
}
DirectionalLight lighting_getDirectionalLight(int index) {
UniformLight light =
lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
return DirectionalLight(light.color, light.direction);
}
float getPointLightAttenuation(PointLight pointLight, float distance) {
return pointLight.attenuation.x
+ pointLight.attenuation.y * distance
+ pointLight.attenuation.z * distance * distance;
}
float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
vec3 light_direction = normalize(positionWorldspace - spotLight.position);
float coneFactor = smoothstep(
spotLight.coneCos.y,
spotLight.coneCos.x,
dot(normalize(spotLight.direction), light_direction)
);
float distanceAttenuation = getPointLightAttenuation(
PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
distance(spotLight.position, positionWorldspace)
);
return distanceAttenuation / max(coneFactor, 0.0001);
}
// #endif
`;var Ko=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
const MAX_LIGHTS: i32 = 5;
struct AmbientLight {
color: vec3<f32>,
};
struct PointLight {
color: vec3<f32>,
position: vec3<f32>,
attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
};
struct SpotLight {
color: vec3<f32>,
position: vec3<f32>,
direction: vec3<f32>,
attenuation: vec3<f32>,
coneCos: vec2<f32>,
};
struct DirectionalLight {
color: vec3<f32>,
direction: vec3<f32>,
};
struct UniformLight {
color: vec3<f32>,
position: vec3<f32>,
direction: vec3<f32>,
attenuation: vec3<f32>,
coneCos: vec2<f32>,
};
struct lightingUniforms {
enabled: i32,
directionalLightCount: i32,
pointLightCount: i32,
spotLightCount: i32,
ambientColor: vec3<f32>,
lights: array<UniformLight, 5>,
};
@group(2) @binding(auto) var<uniform> lighting : lightingUniforms;
fn lighting_getPointLight(index: i32) -> PointLight {
let light = lighting.lights[index];
return PointLight(light.color, light.position, light.attenuation);
}
fn lighting_getSpotLight(index: i32) -> SpotLight {
let light = lighting.lights[lighting.pointLightCount + index];
return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos);
}
fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index];
return DirectionalLight(light.color, light.direction);
}
fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
return pointLight.attenuation.x
+ pointLight.attenuation.y * distance
+ pointLight.attenuation.z * distance * distance;
}
fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 {
let lightDirection = normalize(positionWorldspace - spotLight.position);
let coneFactor = smoothstep(
spotLight.coneCos.y,
spotLight.coneCos.x,
dot(normalize(spotLight.direction), lightDirection)
);
let distanceAttenuation = getPointLightAttenuation(
PointLight(spotLight.color, spotLight.position, spotLight.attenuation),
distance(spotLight.position, positionWorldspace)
);
return distanceAttenuation / max(coneFactor, 0.0001);
}
`;var ge=5,Ba={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},zo={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[Ba,ge]},defaultUniforms:St(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:Ko,vs:gr,fs:gr,getUniforms:xa};function xa(t,e={}){if(t=t&&{...t},!t)return St();t.lights&&(t={...t,...Ca(t.lights),lights:void 0});let{useByteColors:r,ambientLight:n,pointLights:o,spotLights:s,directionalLights:i}=t||{};if(!(n||o&&o.length>0||s&&s.length>0||i&&i.length>0))return{...St(),enabled:0};let c={...St(),...Ma({useByteColors:r,ambientLight:n,pointLights:o,spotLights:s,directionalLights:i})};return t.enabled!==void 0&&(c.enabled=t.enabled?1:0),c}function Ma({useByteColors:t,ambientLight:e,pointLights:r=[],spotLights:n=[],directionalLights:o=[]}){let s=Xo(),i=0,a=0,c=0,l=0;for(let f of r){if(i>=ge)break;s[i]={...s[i],color:yt(f,t),position:f.position,attenuation:f.attenuation||[1,0,0]},i++,a++}for(let f of n){if(i>=ge)break;s[i]={...s[i],color:yt(f,t),position:f.position,direction:f.direction,attenuation:f.attenuation||[1,0,0],coneCos:Ea(f)},i++,c++}for(let f of o){if(i>=ge)break;s[i]={...s[i],color:yt(f,t),direction:f.direction},i++,l++}return r.length+n.length+o.length>ge&&jo.log.warn(`MAX_LIGHTS exceeded, truncating to ${ge}`)(),{ambientColor:yt(e,t),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:s}}function Ca(t){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let r of t||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;case"spot":e.spotLights?.push(r);break;default:}return e}function yt(t={},e){let{color:r=[0,0,0],