1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/color.vertex-BE763cha.js","assets/fileTools.pure-O3hflNMy.js","assets/clipPlaneVertex-B5KC89fQ.js","assets/vertexColorMixing-7o77qkoJ.js","assets/color.fragment-DrcP9H-Y.js","assets/clipPlaneFragment-DpbE3SOa.js","assets/fogFragment-CnqgmQRM.js","assets/color.vertex-Bz11lMd9.js","assets/tier3-babylon-z6xMXPxH.js","assets/index-DY6XcbtQ.js","assets/index-DK3k_-YE.css","assets/smartArray-B7wVGkJ5.js","assets/tools.pure-PAKPbutq.js","assets/thinEngine-DI9LWTqR.js","assets/helperFunctions-D7-zXdUR.js","assets/color.fragment-BGIR8YbO.js"])))=>i.map(i=>d[i]); 2import{M as it,V as F,aB as St,ae as bt,Q as Nt,f as tt,C as fs,h as ot,am as gs,g as yt,a as Ft,E as Ht,c as pt,x as Oe,L as ct,q as $t,aC as et,aD as Jt}from"./fileTools.pure-O3hflNMy.js";import{a6 as O,ae as Z,af as De,h as xs,M as Ut,ag as ms,ah as ps}from"./tier3-babylon-z6xMXPxH.js";import{V as Q}from"./smartArray-B7wVGkJ5.js";import{a as _s}from"./scene.pure--hyippSf.js";import{_ as Ct}from"./index-DY6XcbtQ.js";import{S as ys}from"./shaderMaterial.pure-BD7SHfvy.js";import{T as vs}from"./tools.pure-PAKPbutq.js";import"./thinEngine-DI9LWTqR.js";import"./helperFunctions-D7-zXdUR.js";import"./deviceInputEvents-BYmA4r4v.js";import"./perfCounter-BXP6OJRQ.js";import"./texture.pure-Df8EqGL8.js";import"./baseTexture.pure-BeMB4zCM.js";import"./math.size-F3xmSqZc.js";import"./effectFallbacks-DqrlKF7n.js";import"./vertexPullingHelper.functions-C384XxIb.js";var te;(function(i){i[i.CW=0]="CW",i[i.CCW=1]="CCW"})(te||(te={}));class ft{constructor(t){this._radians=t,this._radians<0&&(this._radians+=2*Math.PI)}degrees(){return this._radians*180/Math.PI}radians(){return this._radians}static BetweenTwoPoints(t,e){const s=e.subtract(t),n=Math.atan2(s.y,s.x);return new ft(n)}static BetweenTwoVectors(t,e){let s=t.lengthSquared()*e.lengthSquared();if(s===0)return new ft(Math.PI/2);s=Math.sqrt(s);let n=t.dot(e)/s;n=fs(n,-1,1);const a=Math.acos(n);return new ft(a)}static FromRadians(t){return new ft(t)}static FromDegrees(t){return new ft(t*Math.PI/180)}}class bs{constructor(t,e,s){this.startPoint=t,this.midPoint=e,this.endPoint=s;const n=Math.pow(e.x,2)+Math.pow(e.y,2),a=(Math.pow(t.x,2)+Math.pow(t.y,2)-n)/2,r=(n-Math.pow(s.x,2)-Math.pow(s.y,2))/2,o=(t.x-e.x)*(e.y-s.y)-(e.x-s.x)*(t.y-e.y);this.centerPoint=new tt((a*(e.y-s.y)-r*(t.y-e.y))/o,((t.x-e.x)*r-(e.x-s.x)*a)/o),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=ft.BetweenTwoPoints(this.centerPoint,this.startPoint);const l=this.startAngle.degrees();let u=ft.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),d=ft.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();u-l>180&&(u-=360),u-l<-180&&(u+=360),d-u>180&&(d-=360),d-u<-180&&(d+=360),this.orientation=u-l<0?0:1,this.angle=ft.FromDegrees(this.orientation===0?l-d:d-l)}}class Rt{constructor(t,e){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new tt(t,e))}addLineTo(t,e){if(this.closed)return this;const s=new tt(t,e),n=this._points[this._points.length-1];return this._points.push(s),this._length+=s.subtract(n).length(),this}addArcTo(t,e,s,n,a=36){if(this.closed)return this;const r=this._points[this._points.length-1],o=new tt(t,e),l=new tt(s,n),u=new bs(r,o,l);let d=u.angle.radians()/a;u.orientation===0&&(d*=-1);let h=u.startAngle.radians()+d;for(let c=0;c<a;c++){const x=Math.cos(h)*u.radius+u.centerPoint.x,g=Math.sin(h)*u.radius+u.centerPoint.y;this.addLineTo(x,g),h+=d}return this}addQuadraticCurveTo(t,e,s,n,a=36){if(this.closed)return this;const r=(l,u,d,h)=>(1-l)*(1-l)*u+2*l*(1-l)*d+l*l*h,o=this._points[this._points.length-1];for(let l=0;l<=a;l++){const u=l/a,d=r(u,o.x,t,s),h=r(u,o.y,e,n);this.addLineTo(d,h)}return this}addBezierCurveTo(t,e,s,n,a,r,o=36){if(this.closed)return this;const l=(d,h,c,x,g)=>(1-d)*(1-d)*(1-d)*h+3*d*(1-d)*(1-d)*c+3*d*d*(1-d)*x+d*d*d*g,u=this._points[this._points.length-1];for(let d=0;d<=o;d++){const h=d/o,c=l(h,u.x,t,s,a),x=l(h,u.y,e,n,r);this.addLineTo(c,x)}return this}isPointInside(t){let e=!1;const s=this._points.length;for(let n=s-1,a=0;a<s;n=a++){let r=this._points[n],o=this._points[a],l=o.x-r.x,u=o.y-r.y;if(Math.abs(u)>Number.EPSILON){if(u<0&&(r=this._points[a],l=-l,o=this._points[n],u=-u),t.y<r.y||t.y>o.y)continue;if(t.y===r.y&&t.x===r.x)return!0;
2{const d=u*(t.x-r.x)-l*(t.y-r.y);if(d===0)return!0;if(d<0)continue;e=!e}}else{if(t.y!==r.y)continue;if(o.x<=t.x&&t.x<=r.x||r.x<=t.x&&t.x<=o.x)return!0}}return e}close(){return this.closed=!0,this}length(){let t=this._length;if(this.closed){const e=this._points[this._points.length-1],s=this._points[0];t+=s.subtract(e).length()}return t}area(){const t=this._points.length;let e=0;for(let s=t-1,n=0;n<t;s=n++)e+=this._points[s].x*this._points[n].y-this._points[n].x*this._points[s].y;return e*.5}getPoints(){return this._points}getPointAtLengthPosition(t){if(t<0||t>1)return tt.Zero();const e=t*this.length();let s=0;for(let n=0;n<this._points.length;n++){const a=(n+1)%this._points.length,r=this._points[n],l=this._points[a].subtract(r),u=l.length()+s;if(e>=s&&e<=u){const d=l.normalize(),h=e-s;return new tt(r.x+d.x*h,r.y+d.y*h)}s=u}return tt.Zero()}static StartingAt(t,e){return new Rt(t,e)}}class It{constructor(t,e=null,s,n=!1){this.path=t,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array,this._pointAtData={id:0,point:F.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:it.Identity()};for(let a=0;a<t.length;a++)this._curve[a]=t[a].clone();this._raw=s||!1,this._alignTangentsWithPath=n,this._compute(e,n)}getCurve(){return this._curve}getPoints(){return this._curve}length(){return this._distances[this._distances.length-1]}getTangents(){return this._tangents}getNormals(){return this._normals}getBinormals(){return this._binormals}getDistances(){return this._distances}getPointAt(t){return this._updatePointAtData(t).point}getTangentAt(t,e=!1){return this._updatePointAtData(t,e),e?F.TransformCoordinates(F.Forward(),this._pointAtData.interpolationMatrix):this._tangents[this._pointAtData.previousPointArrayIndex]}getNormalAt(t,e=!1){return this._updatePointAtData(t,e),e?F.TransformCoordinates(F.Right(),this._pointAtData.interpolationMatrix):this._normals[this._pointAtData.previousPointArrayIndex]}getBinormalAt(t,e=!1){return this._updatePointAtData(t,e),e?F.TransformCoordinates(F.UpReadOnly,this._pointAtData.interpolationMatrix):this._binormals[this._pointAtData.previousPointArrayIndex]}getDistanceAt(t){return this.length()*t}getPreviousPointIndexAt(t){return this._updatePointAtData(t),this._pointAtData.previousPointArrayIndex}getSubPositionAt(t){return this._updatePointAtData(t),this._pointAtData.subPosition}getClosestPositionTo(t){let e=Number.MAX_VALUE,s=0;for(let n=0;n<this._curve.length-1;n++){const a=this._curve[n+0],r=this._curve[n+1].subtract(a).normalize(),o=this._distances[n+1]-this._distances[n+0],l=Math.min(Math.max(F.Dot(r,t.subtract(a).normalize()),0)*F.Distance(a,t)/o,1),u=F.Distance(a.add(r.scale(l*o)),t);u<e&&(e=u,s=(this._distances[n+0]+o*l)/this.length())}return s}slice(t=0,e=1){if(t<0&&(t=1-t*-1%1),e<0&&(e=1-e*-1%1),t>e){const u=t;t=e,e=u}const s=this.getCurve(),n=this.getPointAt(t);let a=this.getPreviousPointIndexAt(t);const r=this.getPointAt(e),o=this.getPreviousPointIndexAt(e)+1,l=[];return t!==0&&(a++,l.push(n)),l.push(...s.slice(a,o)),(e!==1||t===1)&&l.push(r),new It(l,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)}update(t,e=null,s=!1){for(let n=0;n<t.length;n++)this._curve[n].x=t[n].x,this._curve[n].y=t[n].y,this._curve[n].z=t[n].z;return this._compute(e,s),this}_compute(t,e=!1){const s=this._curve.length;if(s<2)return;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[s-1]=this._curve[s-1].subtract(this._curve[s-2]),this._raw||this._tangents[s-1].normalize();const n=this._tangents[0],a=this._normalVector(n,t);this._normals[0]=a,this._raw||this._normals[0].normalize(),this._binormals[0]=F.Cross(n,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;let r,o,l,u,d;for(let h=1;h<s;h++)r=this._getLastNonNullVector(h),h<s-1&&(o=this._getFirstNonNullVector(h),this._tangents[h]=e?o:r.add(o),this._tangents[h].normalize()),this._distances[h]=this._distances[h-1]+this._curve[h].subtract(this._curve[h-1]).length(),l=this._tangents[h],d=this._binormals[h-1],this._normals[h]=F.Cross(d,l),this._raw||(this._normals[h].length()===0?(u=this._normals[h-1],this._normals[h]=u.clone()):this._normals[h].normalize()),this._binormals[h]=F.Cross(l,this._normals[h]),this._raw||this._binormals[h].normalize();this._pointAtData.id=NaN}_getFirstNonNullVector(t){let e=1,s=this._curve[t+e].subtract(this._curve[t]);for(;s.length()===0&&t+e+1<this._curve.length;)e++,s=this._curve[t+e].subtract(this._curve[t]);return s}_getLastNonNullVector(t){let e=1,s=this._curve[t].subtract(this._curve[t-e]);for(;s.length()===0&&t>e+1;)e++,s=this._curve[t].subtract(this._curve[t-e]);return s}_normalVector(t,e){let s,n=t.length();if(n===0&&(n=1),e==null){let a;St(Math.abs(t.y)/n,1,bt)?St(Math.abs(t.x)/n,1,bt)?St(Math.abs(t.z)/n,1,bt)?a=F.Zero():a=new F(0,0,1):a=new F(1,0,0):a=new F(0,-1,0),s=F.Cross(t,a)}else s=F.Cross(t,e),F.CrossToRef(s,t,s);return s.normalize(),s}_updatePointAtData(t,e=!1){if(this._pointAtData.id===t)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=t;const s=this.getPoints();if(t<=0)return this._setPointAtData(0,0,s[0],0,e);if(t>=1)return this._setPointAtData(1,1,s[s.length-1],s.length-1,e);let n=s[0],a,r=0;const o=t*this.length();for(let l=1;l<s.length;l++){a=s[l];const u=F.Distance(n,a);if(r+=u,r===o)return this._setPointAtData(t,1,a,l,e);if(r>
2o){const h=(r-o)/u,c=n.subtract(a),x=a.add(c.scaleInPlace(h));return this._setPointAtData(t,1-h,x,l-1,e)}n=a}return this._pointAtData}_setPointAtData(t,e,s,n,a){return this._pointAtData.point=s,this._pointAtData.position=t,this._pointAtData.subPosition=e,this._pointAtData.previousPointArrayIndex=n,this._pointAtData.interpolateReady=a,a&&this._updateInterpolationMatrix(),this._pointAtData}_updateInterpolationMatrix(){this._pointAtData.interpolationMatrix=it.Identity();const t=this._pointAtData.previousPointArrayIndex;if(t!==this._tangents.length-1){const e=t+1,s=this._tangents[t].clone(),n=this._normals[t].clone(),a=this._binormals[t].clone(),r=this._tangents[e].clone(),o=this._normals[e].clone(),l=this._binormals[e].clone(),u=Nt.RotationQuaternionFromAxis(n,a,s),d=Nt.RotationQuaternionFromAxis(o,l,r);Nt.Slerp(u,d,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}}}function we(i){let t=i.pathArray;const e=i.closeArray||!1,s=i.closePath||!1,n=i.invertUV||!1,a=Math.floor(t[0].length/2);let r=i.offset||a;r=r>a?a:Math.floor(r);const o=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE,l=i.uvs,u=i.colors,d=[],h=[],c=[],x=[],g=[],_=[],p=[],v=[];let I;const C=[],A=[];let f,y,m;if(t.length<2){const X=[],q=[];for(y=0;y<t[0].length-r;y++)X.push(t[0][y]),q.push(t[0][y+r]);t=[X,q]}let P=0;const T=s?1:0,R=e?1:0;let L,S;I=t[0].length;let H,z;for(f=0;f<t.length+R;f++){for(p[f]=0,g[f]=[0],L=f===t.length?t[0]:t[f],S=L.length,I=I<S?I:S,m=0;m<S;)d.push(L[m].x,L[m].y,L[m].z),m>0&&(H=L[m].subtract(L[m-1]).length(),z=H+p[f],g[f].push(z),p[f]=z),m++;s&&(m--,d.push(L[0].x,L[0].y,L[0].z),H=L[m].subtract(L[0]).length(),z=H+p[f],g[f].push(z),p[f]=z),C[f]=S+T,A[f]=P,P+=S+T}let W,N,U,G;for(y=0;y<I+T;y++)for(v[y]=0,_[y]=[0],f=0;f<t.length-1+R;f++)W=t[f],N=f===t.length-1?t[0]:t[f+1],y===I?(U=W[0],G=N[0]):(U=W[y],G=N[y]),H=G.subtract(U).length(),z=H+v[y],_[y].push(z),v[y]=z;let B,M;if(l)for(f=0;f<l.length;f++)x.push(l[f].x,l[f].y);else for(f=0;f<t.length+R;f++)for(y=0;y<I+T;y++)B=p[f]!=0?g[f][y]/p[f]:0,M=v[y]!=0?_[y][f]/v[y]:0,n?x.push(M,B):x.push(B,M);f=0;let b=0,D=C[f]-1,w=C[f+1]-1,V=D<w?D:w,Y=A[1]-A[0];const E=C.length-1;for(;b<=V&&f<E;)h.push(b,b+Y,b+1),h.push(b+Y+1,b+1,b+Y),b+=1,b===V&&(f++,Y=A[f+1]-A[f],D=C[f]-1,w=C[f+1]-1,b=A[f],V=D<w?D+b:w+b);if(Z.ComputeNormals(d,h,c),s){let X,q;for(f=0;f<t.length;f++){X=A[f]*3,f+1<t.length?q=(A[f+1]-1)*3:q=c.length-3,c[X]=(c[X]+c[q])*.5,c[X+1]=(c[X+1]+c[q+1])*.5,c[X+2]=(c[X+2]+c[q+2])*.5;const st=Math.sqrt(c[X]*c[X]+c[X+1]*c[X+1]+c[X+2]*c[X+2]);c[X]/=st,c[X+1]/=st,c[X+2]/=st,c[q]=c[X],c[q+1]=c[X+1],c[q+2]=c[X+2]}}if(e){let X=A[0]*3,q=A[t.length]*3;for(y=0;y<I+T;y++){c[X]=(c[X]+c[q])*.5,c[X+1]=(c[X+1]+c[q+1])*.5,c[X+2]=(c[X+2]+c[q+2])*.5;const st=Math.sqrt(c[X]*c[X]+c[X+1]*c[X+1]+c[X+2]*c[X+2]);c[X]/=st,c[X+1]/=st,c[X+2]/=st,c[q]=c[X],c[q+1]=c[X+1],c[q+2]=c[X+2],X+=3,q+=3}}Z._ComputeSides(o,d,h,c,x,i.frontUVs,i.backUVs);let k=null;if(u){k=new Float32Array(u.length*4);for(let X=0;X<u.length;X++)k[X*4]=u[X].r,k[X*4+1]=u[X].g,k[X*4+2]=u[X].b,k[X*4+3]=u[X].a}const j=new Z,nt=new Float32Array(d),at=new Float32Array(c),$=new Float32Array(x);return j.indices=h,j.positions=nt,j.normals=at,j.uvs=$,k&&j.set(k,Q.ColorKind),s&&(j._idx=A),j}function vt(i,t,e=null){const s=t.pathArray,n=t.closeArray,a=t.closePath,r=O._GetDefaultSideOrientation(t.sideOrientation),o=t.instance,l=t.updatable;if(o){const u=ot.Vector3[0].setAll(Number.MAX_VALUE),d=ot.Vector3[1].setAll(-Number.MAX_VALUE),h=x=>{let g=s[0].length;const _=o;let p=0;const v=_._originalBuilderSideOrientation===O.DOUBLESIDE?2:1;for(let I=1;I<=v;++I)for(let C=0;C<s.length;++C){const A=s[C],f=A.length;g=g<f?g:f;for(let y=0;y<g;++y){const m=A[y];x[p]=m.x,x[p+1]=m.y,x[p+2]=m.z,u.minimizeInPlaceFromFloats(m.x,m.y,m.z),d.maximizeInPlaceFromFloats(m.x,m.y,m.z),p+=3}if(_._creationDataStorage&&_._creationDataStorage.closePath){const y=A[0];x[p]=y.x,x[p+1]=y.y,x[p+2]=y.z,p+=3}}},c=o.getVerticesData(Q.PositionKind);if(h(c),o.hasBoundingInfo?o.getBoundingInfo().reConstruct(u,d,o._worldMatrix):o.buildBoundingInfo(u,d,o._worldMatrix),o.updateVerticesData(Q.PositionKind,c,!1,!1),t.colors){const x=o.getVerticesData(Q.ColorKind);for(let g=0,_=0;g<t.colors.length;g++,_+=4){const p=t.colors[g];x[_]=p.r,x[_+1]=p.g,x[_+2]=p.b,x[_+3]=p.a}o.updateVerticesData(Q.ColorKind,x,!1,!1)}if(t.uvs){const x=o.getVerticesData(Q.UVKind);for(let g=0;g<t.uvs.length;g++)x[g*2]=t.uvs[g].x,x[g*2+1]=t.uvs[g].y;o.updateVerticesData(Q.UVKind,x,!1,!1)}if(!o.areNormalsFrozen||o.isFacetDataEnabled){const x=o.getIndices(),g=o.getVerticesData(Q.NormalKind),_=o.isFacetDataEnabled?o.getFacetDataParameters():null;if(Z.ComputeNormals(c,x,g,_),o._creationDataStorage&&o._creationDataStorage.closePath){let p,v;for(let I=0;I<s.length;
2I++)p=o._creationDataStorage.idx[I]*3,I+1<s.length?v=(o._creationDataStorage.idx[I+1]-1)*3:v=g.length-3,g[p]=(g[p]+g[v])*.5,g[p+1]=(g[p+1]+g[v+1])*.5,g[p+2]=(g[p+2]+g[v+2])*.5,g[v]=g[p],g[v+1]=g[p+1],g[v+2]=g[p+2]}o.areNormalsFrozen||o.updateVerticesData(Q.NormalKind,g,!1,!1)}return o}else{const u=new O(i,e);u._originalBuilderSideOrientation=r,u._creationDataStorage=new De;const d=we(t);return a&&(u._creationDataStorage.idx=d._idx),u._creationDataStorage.closePath=a,u._creationDataStorage.closeArray=n,d.applyToMesh(u,l),u}}let ee=!1;function As(){ee||(ee=!0,Z.CreateRibbon=we,O.CreateRibbon=(i,t,e=!1,s,n,a,r=!1,o,l)=>vt(i,{pathArray:t,closeArray:e,closePath:s,offset:n,updatable:r,sideOrientation:o,instance:l},a))}function Ie(i){const t=[],e=[],s=[],n=[],a=i.radius||.5,r=i.tessellation||64,o=i.arc&&(i.arc<=0||i.arc>1)?1:i.arc||1,l=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE;t.push(0,0,0),n.push(.5,.5);const u=Math.PI*2*o,d=o===1?u/r:u/(r-1);let h=0;for(let g=0;g<r;g++){const _=Math.cos(h),p=Math.sin(h),v=(_+1)/2,I=(1-p)/2;t.push(a*_,a*p,0),n.push(v,I),h+=d}o===1&&(t.push(t[3],t[4],t[5]),n.push(n[2],n[3]));const c=t.length/3;for(let g=1;g<c-1;g++)e.push(g+1,0,g);Z.ComputeNormals(t,e,s),Z._ComputeSides(l,t,e,s,n,i.frontUVs,i.backUVs);const x=new Z;return x.indices=e,x.positions=t,x.normals=s,x.uvs=n,x}function Te(i,t={},e=null){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,Ie(t).applyToMesh(s,t.updatable),s}let se=!1;function Os(){se||(se=!0,Z.CreateDisc=Ie,O.CreateDisc=(i,t,e,s=null,n,a)=>Te(i,{radius:t,tessellation:e,sideOrientation:a,updatable:n},s))}class Bt extends O{constructor(t,e){super(t,e),this.generateOctree=!1}getClassName(){return"GroundMesh"}get subdivisions(){return Math.min(this._subdivisionsX,this._subdivisionsY)}get subdivisionsX(){return this._subdivisionsX}get subdivisionsY(){return this._subdivisionsY}optimize(t,e=32){this._subdivisionsX=t,this._subdivisionsY=t,this.subdivide(t);const s=this;gs(s.createOrUpdateSubmeshesOctree)&&s.createOrUpdateSubmeshesOctree(e)}getHeightAtCoordinates(t,e){const s=this.getWorldMatrix(),n=ot.Matrix[5];s.invertToRef(n);const a=ot.Vector3[8];if(F.TransformCoordinatesFromFloatsToRef(t,0,e,n,a),t=a.x,e=a.z,t<this._minX||t>=this._maxX||e<=this._minZ||e>this._maxZ)return this.position.y;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());const r=this._getFacetAt(t,e),o=-(r.x*t+r.z*e+r.w)/r.y;return F.TransformCoordinatesFromFloatsToRef(0,o,0,s,a),a.y}getNormalAtCoordinates(t,e){const s=new F(0,1,0);return this.getNormalAtCoordinatesToRef(t,e,s),s}getNormalAtCoordinatesToRef(t,e,s){const n=this.getWorldMatrix(),a=ot.Matrix[5];n.invertToRef(a);const r=ot.Vector3[8];if(F.TransformCoordinatesFromFloatsToRef(t,0,e,a,r),t=r.x,e=r.z,t<this._minX||t>this._maxX||e<this._minZ||e>this._maxZ)return this;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());const o=this._getFacetAt(t,e);return F.TransformNormalFromFloatsToRef(o.x,o.y,o.z,n,s),this}updateCoordinateHeights(){return(!this._heightQuads||this._heightQuads.length==0)&&this._initHeightQuads(),this._computeHeightQuads(),this}_getFacetAt(t,e){const s=Math.floor((t+this._maxX)*this._subdivisionsX/this._width),n=Math.floor(-(e+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),a=this._heightQuads[n*this._subdivisionsX+s];let r;return e<a.slope.x*t+a.slope.y?r=a.facet1:r=a.facet2,r}_initHeightQuads(){const t=this._subdivisionsX,e=this._subdivisionsY;this._heightQuads=[];for(let s=0;s<e;s++)for(let n=0;n<t;n++){const a={slope:tt.Zero(),facet1:new yt(0,0,0,0),facet2:new yt(0,0,0,0)};this._heightQuads[s*t+n]=a}return this}_computeHeightQuads(){const t=this.getVerticesData(Q.PositionKind);if(!t)return this;const e=ot.Vector3[3],s=ot.Vector3[2],n=ot.Vector3[1],a=ot.Vector3[0],r=ot.Vector3[4],o=ot.Vector3[5],l=ot.Vector3[6],u=ot.Vector3[7],d=ot.Vector3[8];let h,c,x,g,_,p,v;const I=this._subdivisionsX,C=this._subdivisionsY;for(let A=0;A<C;A++)for(let f=0;f<I;f++){h=f*3,c=A*(I+1)*3,x=(A+1)*(I+1)*3,e.x=t[c+h],e.y=t[c+h+1],e.z=t[c+h+2],s.x=t[c+h+3],s.y=t[c+h+4],s.z=t[c+h+5],n.x=t[x+h],n.y=t[x+h+1],n.z=t[x+h+2],a.x=t[x+h+3],a.y=t[x+h+4],a.z=t[x+h+5],g=(a.z-e.z)/(a.x-e.x),_=e.z-g*e.x,s.subtractToRef(e,r),n.subtractToRef(e,o),a.subtractToRef(e,l),F.CrossToRef(l,o,u),F.CrossToRef(r,l,d),u.normalize(),d.normalize(),p=-(u.x*e.x+u.y*e.y+u.z*e.z),v=-(d.x*s.x+d.y*s.y+d.z*s.z);const y=this._heightQuads[A*I+f];y.slope.copyFromFloats(g,_),y.facet1.copyFromFloats(u.x,u.y,u.z,p),y.facet2.copyFromFloats(d.x,d.y,d.z,v)}return this}serialize(t){super.serialize(t),t.subdivisionsX=this._subdivisionsX,t.subdivisionsY=this._subdivisionsY,t.minX=this._minX,t.maxX=this._maxX,t.minZ=this._minZ,t.maxZ=this._maxZ,t.width=this._width,t.height=this._height}static Parse(t,e){const s=new Bt(t.name,e);return s._subdivisionsX=t.subdivisionsX||1,s._subdivisionsY=t.subdivisionsY||1,s._minX=t.minX,s._maxX=t.maxX,s._minZ=t.minZ,s._maxZ=t.maxZ,s._width=t.width,s._height=t.height,s}}function Ce(i){const t=[],e=[],s=[],n=[];let a,r;const o=i.width||i.size||1,l=i.height||i.size||1,u=(i.subdivisionsX||i.subdivisions||1)|0,d=(i.subdivisionsY||i.subdivisions||1)|0;for(a=0;a<=d;a++)for(r=0;r<=u;r++){const c=new F(r*o/u-o/2,0,(d-a)*l/d-l/2),x=new F(0,1,0);e.push(c.x,c.y,c.z),s.push(x.x,x.y,x.z),n.push(r/u,1-a/d)}for(a=0;a<d;a++)for(r=0;r<u;r++)t.push(r+1+(a+1)*(u+1)),t.push(r+1+a*(u+1)),t.push(r+a*(u+1)),t.push(r+(a+1)*(u+1)),t.push(r+1+(a+1)*(u+1)),t.push(r+a*(u+1));const h=new Z;return h.indices=t,h.positions=e,h.normals=s,h.uvs=n,h}function Pe(i){const t=i.xmin!==void 0&&i.xmin!==null?i.xmin:-1,e=i.zmin!==void 0&&i.zmin!==null?i.zmin:-1,s=i.xmax!==void 0&&i.xmax!==null?i.xmax:1,n=i.zmax!==void 0&&i.zmax!==null?i.zmax:1,a=i.subdivisions||{w:1,h:1},r=i.precision||{w:1,h:1},o=[],l=[],u=[],d=[];let h,c,x,g;a.h=a.h<1?1:a.h,a.w=a.w<1?1:a.w,r.w=r.w<1?1:r.w,r.h=r.h<1?1:r.h;const _={w:(s-t)/a.w,h:(n-e)/a.h};function p(I,C,A,f){const y=l.length/3,m=r.w+1;for(h=0;h<r.h;h++)for(c=0;c<r.w;c++){const R=[y+c+h*m,y+(c+1)+h*m,y+(c+1)+(h+1)*m,y+c+(h+1)*m];o.push(R[1]),o.push(R[2]),o.push(R[3]),o.push(R[0]),o.push(R[1]),o.push(R[3])}const P=F.Zero(),T=new F(0,1,0);for(h=0;h<=r.h;
vendor: 4,357 bytes, line 2
2h++)for(P.z=h*(f-C)/r.h+C,c=0;c<=r.w;c++)P.x=c*(A-I)/r.w+I,P.y=0,l.push(P.x,P.y,P.z),u.push(T.x,T.y,T.z),d.push(c/r.w,h/r.h)}for(x=0;x<a.h;x++)for(g=0;g<a.w;g++)p(t+g*_.w,e+x*_.h,t+(g+1)*_.w,e+(x+1)*_.h);const v=new Z;return v.indices=o,v.positions=l,v.normals=u,v.uvs=d,v}function Fe(i){const t=[],e=[],s=[],n=[];let a,r;const o=i.colorFilter||new Ft(.3,.59,.11),l=i.alphaFilter||0;let u=!1;if(i.minHeight>i.maxHeight){u=!0;const h=i.maxHeight;i.maxHeight=i.minHeight,i.minHeight=h}for(a=0;a<=i.subdivisions;a++)for(r=0;r<=i.subdivisions;r++){const h=new F(r*i.width/i.subdivisions-i.width/2,0,(i.subdivisions-a)*i.height/i.subdivisions-i.height/2),c=(h.x+i.width/2)/i.width*(i.bufferWidth-1)|0,x=(1-(h.z+i.height/2)/i.height)*(i.bufferHeight-1)|0,g=(c+x*i.bufferWidth)*4;let _=i.buffer[g]/255,p=i.buffer[g+1]/255,v=i.buffer[g+2]/255;const I=i.buffer[g+3]/255;u&&(_=1-_,p=1-p,v=1-v);const C=_*o.r+p*o.g+v*o.b;I>=l?h.y=i.minHeight+(i.maxHeight-i.minHeight)*C:h.y=i.minHeight-bt,i.heightBuffer&&(i.heightBuffer[a*(i.subdivisions+1)+r]=h.y),e.push(h.x,h.y,h.z),s.push(0,0,0),n.push(r/i.subdivisions,1-a/i.subdivisions)}for(a=0;a<i.subdivisions;a++)for(r=0;r<i.subdivisions;r++){const h=r+1+(a+1)*(i.subdivisions+1),c=r+1+a*(i.subdivisions+1),x=r+a*(i.subdivisions+1),g=r+(a+1)*(i.subdivisions+1),_=e[h*3+1]>=i.minHeight,p=e[c*3+1]>=i.minHeight,v=e[x*3+1]>=i.minHeight;_&&p&&v&&(t.push(h),t.push(c),t.push(x)),e[g*3+1]>=i.minHeight&&_&&v&&(t.push(g),t.push(h),t.push(x))}Z.ComputeNormals(e,t,s);const d=new Z;return d.indices=t,d.positions=e,d.normals=s,d.uvs=n,d}function Ve(i,t={},e){const s=new Bt(i,e);return s._setReady(!1),s._subdivisionsX=t.subdivisionsX||t.subdivisions||1,s._subdivisionsY=t.subdivisionsY||t.subdivisions||1,s._width=t.width||1,s._height=t.height||1,s._maxX=s._width/2,s._maxZ=s._height/2,s._minX=-s._maxX,s._minZ=-s._maxZ,Ce(t).applyToMesh(s,t.updatable),s._setReady(!0),s}function Re(i,t,e=null){const s=new O(i,e);return Pe(t).applyToMesh(s,t.updatable),s}function Be(i,t,e={},s=null){const n=e.width||10,a=e.height||10,r=e.subdivisions||1,o=e.minHeight||0,l=e.maxHeight||1,u=e.colorFilter||new Ft(.3,.59,.11),d=e.alphaFilter||0,h=e.updatable,c=e.onReady;s=s||Ht.LastCreatedScene;const x=new Bt(i,s);x._subdivisionsX=r,x._subdivisionsY=r,x._width=n,x._height=a,x._maxX=x._width/2,x._maxZ=x._height/2,x._minX=-x._maxX,x._minZ=-x._maxZ,x._setReady(!1);let g;e.passHeightBufferInCallback&&(g=new Float32Array((r+1)*(r+1)));const _=(p,v,I)=>{Fe({width:n,height:a,subdivisions:r,minHeight:o,maxHeight:l,colorFilter:u,buffer:p,bufferWidth:v,bufferHeight:I,alphaFilter:d,heightBuffer:g}).applyToMesh(x,h),c&&c(x,g),x._setReady(!0)};if(typeof t=="string"){s.addPendingData(x);const p=I=>{const C=I.width,A=I.height;if(s.isDisposed){s.removePendingData(x);return}const f=s?.getEngine().resizeImageBitmap(I,C,A);_(f,C,A),s.removePendingData(x)},v=(I,C)=>{s.removePendingData(x),e.onError&&e.onError(I,C)};vs.LoadImage(t,p,v,s.offlineProvider)}else _(t.data,t.width,t.height);return x}let ne=!1;function Ds(){ne||(ne=!0,Z.CreateGround=Ce,Z.CreateTiledGround=Pe,Z.CreateGroundFromHeightMap=Fe,O.CreateGround=(i,t,e,s,n,a)=>Ve(i,{width:t,height:e,subdivisions:s,updatable:a},n),O.CreateTiledGround=(i,t,e,s,n,a,r,o,l)=>Re(i,{xmin:t,zmin:e,xmax:s,zmax:n,subdivisions:a,precision:r,updatable:l},o),O.CreateGroundFromHeightMap=(i,t,e,s,n,a,r,o,l,u,d)=>Be(i,t,{width:e,height:s,subdivisions:n,minHeight:a,maxHeight:r,updatable:l,onReady:u,alphaFilter:d},o))}function Me(i){let e=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23];const s=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],n=[],a=i.width||i.size||1,r=i.height||i.size||1,o=i.depth||i.size||1,l=i.wrap||!1;let u=i.topBaseAt===void 0?1:i.topBaseAt,d=i.bottomBaseAt===void 0?0:i.bottomBaseAt;u=(u+4)%4,d=(d+4)%4;const h=[2,0,3,1],c=[2,0,1,3];let x=h[u],g=c[d],_=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(l){e=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],_=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];
2let m=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],P=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]];const T=[17,18,19,16],R=[22,23,20,21];for(;x>0;)m.unshift(m.pop()),T.unshift(T.pop()),x--;for(;g>0;)P.unshift(P.pop()),R.unshift(R.pop()),g--;m=m.flat(),P=P.flat(),_=_.concat(m).concat(P),e.push(T[0],T[2],T[3],T[0],T[1],T[2]),e.push(R[0],R[2],R[3],R[0],R[1],R[2])}const p=[a/2,r/2,o/2],v=_.reduce((m,P,T)=>m.concat(P*p[T%3]),[]),I=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE,C=i.faceUV||new Array(6),A=i.faceColors,f=[];for(let m=0;m<6;m++)C[m]===void 0&&(C[m]=new yt(0,0,1,1)),A&&A[m]===void 0&&(A[m]=new pt(1,1,1,1));for(let m=0;m<6;m++)if(n.push(C[m].z,C[m].w),n.push(C[m].x,C[m].w),n.push(C[m].x,C[m].y),n.push(C[m].z,C[m].y),A)for(let P=0;P<4;P++)f.push(A[m].r,A[m].g,A[m].b,A[m].a);Z._ComputeSides(I,v,e,s,n,i.frontUVs,i.backUVs);const y=new Z;if(y.indices=e,y.positions=v,y.normals=s,y.uvs=n,A){const m=I===Z.DOUBLESIDE?f.concat(f):f;y.colors=m}return y}function ze(i,t={},e=null){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,Me(t).applyToMesh(s,t.updatable),s}let ie=!1;function ws(){ie||(ie=!0,Z.CreateBox=Me,O.CreateBox=(i,t,e=null,s,n)=>ze(i,{size:t,sideOrientation:n,updatable:s},e))}function wt(i){const t=i.pattern||O.NO_FLIP,e=i.tileWidth||i.tileSize||1,s=i.tileHeight||i.tileSize||1,n=i.alignHorizontal||0,a=i.alignVertical||0,r=i.width||i.size||1,o=Math.floor(r/e);let l=r-o*e;const u=i.height||i.size||1,d=Math.floor(u/s);let h=u-d*s;const c=e*o/2,x=s*d/2;let g=0,_=0,p=0,v=0,I=0,C=0;if(l>0||h>0){switch(p=-c,v=-x,I=c,C=x,n){case O.CENTER:l/=2,p-=l,I+=l;break;case O.LEFT:I+=l,g=-l/2;break;case O.RIGHT:p-=l,g=l/2;break}switch(a){case O.CENTER:h/=2,v-=h,C+=h;break;case O.BOTTOM:C+=h,_=-h/2;break;case O.TOP:v-=h,_=h/2;break}}const A=[],f=[],y=[];y[0]=[0,0,1,0,1,1,0,1],y[1]=[0,0,1,0,1,1,0,1],(t===O.ROTATE_TILE||t===O.ROTATE_ROW)&&(y[1]=[1,1,0,1,0,0,1,0]),(t===O.FLIP_TILE||t===O.FLIP_ROW)&&(y[1]=[1,0,0,0,0,1,1,1]),(t===O.FLIP_N_ROTATE_TILE||t===O.FLIP_N_ROTATE_ROW)&&(y[1]=[0,1,1,1,1,0,0,0]);let m=[];const P=[],T=[];let R=0;for(let z=0;z<d;z++)for(let W=0;W<o;W++)A.push(-c+W*e+g,-x+z*s+_,0),A.push(-c+(W+1)*e+g,-x+z*s+_,0),A.push(-c+(W+1)*e+g,-x+(z+1)*s+_,0),A.push(-c+W*e+g,-x+(z+1)*s+_,0),T.push(R,R+1,R+3,R+1,R+2,R+3),t===O.FLIP_TILE||t===O.ROTATE_TILE||t===O.FLIP_N_ROTATE_TILE?m=m.concat(y[(W%2+z%2)%2]):t===O.FLIP_ROW||t===O.ROTATE_ROW||t===O.FLIP_N_ROTATE_ROW?m=m.concat(y[z%2]):m=m.concat(y[0]),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),f.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1),R+=4;if(l>0||h>0){const z=h>0&&(a===O.CENTER||a===O.TOP),W=h>0&&(a===O.CENTER||a===O.BOTTOM),N=l>0&&(n===O.CENTER||n===O.RIGHT),U=l>0&&(n===O.CENTER||n===O.LEFT);let G,B,M,b,D;if(z&&N&&(A.push(p+g,v+_,0),A.push(-c+g,v+_,0),A.push(-c+g,v+h+_,0),A.push(p+g,v+h+_,0),T.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,B=1-l/e,M=1-h/s,b=1,D=1,G=[B,M,b,M,b,D,B,D],t===O.ROTATE_ROW&&(G=[1-B,1-M,1-b,1-M,1-b,1-D,1-B,1-D]),t===O.FLIP_ROW&&(G=[1-B,M,1-b,M,1-b,D,1-B,D]),t===O.FLIP_N_ROTATE_ROW&&(G=[B,1-M,b,1-M,b,1-D,B,1-D]),m=m.concat(G),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),f.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),z&&U&&(A.push(c+g,v+_,0),A.push(I+g,v+_,0),A.push(I+g,v+h+_,0),A.push(c+g,v+h+_,0),T.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,B=0,M=1-h/s,b=l/e,D=1,G=[B,M,b,M,b,D,B,D],(t===O.ROTATE_ROW||t===O.ROTATE_TILE&&o%2===0)&&(G=[1-B,1-M,1-b,1-M,1-b,1-D,1-B,1-D]),(t===O.FLIP_ROW||t===O.FLIP_TILE&&o%2===0)&&(G=[1-B,M,1-b,M,1-b,D,1-B,D]),(t===O.FLIP_N_ROTATE_ROW||t===O.FLIP_N_ROTATE_TILE&&o%2===0)&&(G=[B,1-M,b,1-M,b,1-D,B,1-D]),m=m.concat(G),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),f.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),W&&N&&(A.push(p+g,x+_,0),A.push(-c+g,x+_,0),A.push(-c+g,C+_,0),A.push(p+g,C+_,0),T.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,B=1-l/e,M=0,b=1,D=h/s,G=[B,M,b,M,b,D,B,D],(t===O.ROTATE_ROW&&d%2===1||t===O.ROTATE_TILE&&d%1===0)&&(G=[1-B,1-M,1-b,1-M,1-b,1-D,1-B,1-D]),(t===O.FLIP_ROW&&d%2===1||t===O.FLIP_TILE&&d%2===0)&&(G=[1-B,M,1-b,M,1-b,D,1-B,D]),(t===O.FLIP_N_ROTATE_ROW&&d%2===1||t===O.FLIP_N_ROTATE_TILE&&d%2===0)&&(G=[B,1-M,b,1-M,b,1-D,B,1-D]),m=m.concat(G),P.pu
2sh(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),f.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),W&&U&&(A.push(c+g,x+_,0),A.push(I+g,x+_,0),A.push(I+g,C+_,0),A.push(c+g,C+_,0),T.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,B=0,M=0,b=l/e,D=h/s,G=[B,M,b,M,b,D,B,D],(t===O.ROTATE_ROW&&d%2===1||t===O.ROTATE_TILE&&(d+o)%2===1)&&(G=[1-B,1-M,1-b,1-M,1-b,1-D,1-B,1-D]),(t===O.FLIP_ROW&&d%2===1||t===O.FLIP_TILE&&(d+o)%2===1)&&(G=[1-B,M,1-b,M,1-b,D,1-B,D]),(t===O.FLIP_N_ROTATE_ROW&&d%2===1||t===O.FLIP_N_ROTATE_TILE&&(d+o)%2===1)&&(G=[B,1-M,b,1-M,b,1-D,B,1-D]),m=m.concat(G),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),f.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),z){const w=[];B=0,M=1-h/s,b=1,D=1,w[0]=[B,M,b,M,b,D,B,D],w[1]=[B,M,b,M,b,D,B,D],(t===O.ROTATE_TILE||t===O.ROTATE_ROW)&&(w[1]=[1-B,1-M,1-b,1-M,1-b,1-D,1-B,1-D]),(t===O.FLIP_TILE||t===O.FLIP_ROW)&&(w[1]=[1-B,M,1-b,M,1-b,D,1-B,D]),(t===O.FLIP_N_ROTATE_TILE||t===O.FLIP_N_ROTATE_ROW)&&(w[1]=[B,1-M,b,1-M,b,1-D,B,1-D]);for(let V=0;V<o;V++)A.push(-c+V*e+g,v+_,0),A.push(-c+(V+1)*e+g,v+_,0),A.push(-c+(V+1)*e+g,v+h+_,0),A.push(-c+V*e+g,v+h+_,0),T.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,t===O.FLIP_TILE||t===O.ROTATE_TILE||t===O.FLIP_N_ROTATE_TILE?m=m.concat(w[(V+1)%2]):t===O.FLIP_ROW||t===O.ROTATE_ROW||t===O.FLIP_N_ROTATE_ROW?m=m.concat(w[1]):m=m.concat(w[0]),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),f.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(W){const w=[];B=0,M=0,b=1,D=h/s,w[0]=[B,M,b,M,b,D,B,D],w[1]=[B,M,b,M,b,D,B,D],(t===O.ROTATE_TILE||t===O.ROTATE_ROW)&&(w[1]=[1-B,1-M,1-b,1-M,1-b,1-D,1-B,1-D]),(t===O.FLIP_TILE||t===O.FLIP_ROW)&&(w[1]=[1-B,M,1-b,M,1-b,D,1-B,D]),(t===O.FLIP_N_ROTATE_TILE||t===O.FLIP_N_ROTATE_ROW)&&(w[1]=[B,1-M,b,1-M,b,1-D,B,1-D]);for(let V=0;V<o;V++)A.push(-c+V*e+g,C-h+_,0),A.push(-c+(V+1)*e+g,C-h+_,0),A.push(-c+(V+1)*e+g,C+_,0),A.push(-c+V*e+g,C+_,0),T.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,t===O.FLIP_TILE||t===O.ROTATE_TILE||t===O.FLIP_N_ROTATE_TILE?m=m.concat(w[(V+d)%2]):t===O.FLIP_ROW||t===O.ROTATE_ROW||t===O.FLIP_N_ROTATE_ROW?m=m.concat(w[d%2]):m=m.concat(w[0]),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),f.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(N){const w=[];B=1-l/e,M=0,b=1,D=1,w[0]=[B,M,b,M,b,D,B,D],w[1]=[B,M,b,M,b,D,B,D],(t===O.ROTATE_TILE||t===O.ROTATE_ROW)&&(w[1]=[1-B,1-M,1-b,1-M,1-b,1-D,1-B,1-D]),(t===O.FLIP_TILE||t===O.FLIP_ROW)&&(w[1]=[1-B,M,1-b,M,1-b,D,1-B,D]),(t===O.FLIP_N_ROTATE_TILE||t===O.FLIP_N_ROTATE_ROW)&&(w[1]=[B,1-M,b,1-M,b,1-D,B,1-D]);for(let V=0;V<d;V++)A.push(p+g,-x+V*s+_,0),A.push(p+l+g,-x+V*s+_,0),A.push(p+l+g,-x+(V+1)*s+_,0),A.push(p+g,-x+(V+1)*s+_,0),T.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,t===O.FLIP_TILE||t===O.ROTATE_TILE||t===O.FLIP_N_ROTATE_TILE?m=m.concat(w[(V+1)%2]):t===O.FLIP_ROW||t===O.ROTATE_ROW||t===O.FLIP_N_ROTATE_ROW?m=m.concat(w[V%2]):m=m.concat(w[0]),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),f.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(U){const w=[];B=0,M=0,b=l/s,D=1,w[0]=[B,M,b,M,b,D,B,D],w[1]=[B,M,b,M,b,D,B,D],(t===O.ROTATE_TILE||t===O.ROTATE_ROW)&&(w[1]=[1-B,1-M,1-b,1-M,1-b,1-D,1-B,1-D]),(t===O.FLIP_TILE||t===O.FLIP_ROW)&&(w[1]=[1-B,M,1-b,M,1-b,D,1-B,D]),(t===O.FLIP_N_ROTATE_TILE||t===O.FLIP_N_ROTATE_ROW)&&(w[1]=[B,1-M,b,1-M,b,1-D,B,1-D]);for(let V=0;V<d;V++)A.push(I-l+g,-x+V*s+_,0),A.push(I+g,-x+V*s+_,0),A.push(I+g,-x+(V+1)*s+_,0),A.push(I-l+g,-x+(V+1)*s+_,0),T.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,t===O.FLIP_TILE||t===O.ROTATE_TILE||t===O.FLIP_N_ROTATE_TILE?m=m.concat(w[(V+o)%2]):t===O.FLIP_ROW||t===O.ROTATE_ROW||t===O.FLIP_N_ROTATE_ROW?m=m.concat(w[V%2]):m=m.concat(w[0]),P.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),f.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}}const L=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE;Z._ComputeSides(L,A,T,f,m,i.frontUVs,i.backUVs);const S=new Z;S.indices=T,S.positions=A,S.normals=f,S.uvs=m;const H=L===Z.DOUBLESIDE?P.concat(P):P;return S.colors=H,S}function Is(i,t,e=null){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,wt(t).applyToMesh(s,t.updatable),s}let ae=!1;function Le(){ae||(ae=!0,Z.CreateTiledPlane=wt)}const Pt=1,Wt=-1;function Ee(i){const e=i.faceUV||new Array(6),s=i.faceColors,n=i.pattern||O.NO_FLIP,a=i.width||i.size||1,r=i.height||i.size||1,o=i.depth||i.size||1,l=i.tileWidth||i.tileSize||1,u=i.tileHeight||i.tileSize||1,d=i.alignHorizontal||0,h=i.alignVertical||0,c=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE;for(let z=0;z<6;z++)e[z]===void 0&&(e[z]=new yt(0,0,1,1)),s&&s[z]===void 0&&(s[z]=new pt(1,1,1,1));const x=a/2,g=r/2,_=o/2,p=[];for(let z=0;z<2;z++)p[z]=wt({pattern:n,tileWidth:l,tileHeight:u,width:a,height:r,alignVertical:h,alignHorizontal:d,sideOrientation:c});for(let z=2;z<4;z++)p[z]=wt({pattern:n,tileWidth:l,tileHeight:u,width:o,height:r,alignVertical:h,alignHorizontal:d,sideOrientation:c});let v=h;h===O.BOTTOM?v=O.TOP:h===O.TOP&&(v=O.BOTTOM);for(let z=4;z<6;z++)p[z]=wt({pattern:n,tileWidth:l,tileHeight:u,width:a,height:o,alignVertical:v,alignHorizontal:d,sideOrientation:c});const I=[],C=[];let A=[],f=[];const y=[],m=[],P=[],T=[];let R,L=0;for(let z=0;z<6;z++){const W=p[z].positions.length;m[z]=[],P[z]=[];for(let N=0;N<W/3;N++)m[z].push(new F(p[z].positions[3*N],p[z].positions[3*N+1],p[z].positions[3*N+2])),P[z].push(new F(p[z].normals[3*N],p[z].normals[3*N+1],p[z].normals[3*N+2]));R=p[z].uvs.length,T[z]=[];for(let N=0;N<R;N+=2)T[z][N]=e[z].x+(e[z].z-e[z].x)*p[z].uvs[N],T[z][N+1]=e[z].y+(e[z].w-e[z].y)*p[z].uvs[N+1];if(A=A.concat(T[z]),f=f.concat(p[z].indices.map(N=>N+L)),L+=m[z].length,s){const N=s[z];for(let U=0;U<m[z].length;U++)y.push(N.r,N.g,N.b,N.a)}}const S=[{m:it.RotationY(Math.PI),t:new F(0,0,_),op:Pt},{m:it.Identity(),t:new F(0,0,_),op:Wt},{m:it.RotationY(-Math.PI/2),t:new F(x,0,0),op:Pt},{m:it.RotationY(Math.PI/2),t:new F(x,0,0),op:Wt},{m:it.RotationX(Math.PI/2),t:new F(0,g,0),op:Pt},{m:it.RotationX(-Math.PI/2),t:new F(0,g,0),op:Wt}];for(let z=0;z<6;z++){const{m:W,t:N,op:U}=S[z];for(const G of m[z]){const B=F.TransformCoordinates(G,W),M=U===Pt?B.add(N):B.subtract(N);I.push(M.x,M.y,M.z)}for(const G of P[z]){const B=F.TransformNormal(G,W);C.push(B.x,B.y,B.z)}}const H=new Z;
2if(H.indices=f,H.positions=I,H.normals=C,H.uvs=A,s){const z=c===Z.DOUBLESIDE?y.concat(y):y;H.colors=z}return H}function Ts(i,t,e=null){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,Ee(t).applyToMesh(s,t.updatable),s}let re=!1;function Cs(){re||(re=!0,Le(),Z.CreateTiledBox=Ee)}function Se(i){const t=(i.segments||32)|0,e=i.diameterX||i.diameter||1,s=i.diameterY||i.diameter||1,n=i.diameterZ||i.diameter||1,a=i.arc&&(i.arc<=0||i.arc>1)?1:i.arc||1,r=i.slice&&i.slice<=0?1:i.slice||1,o=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE,l=!!i.dedupTopBottomIndices,u=new F(e/2,s/2,n/2),d=2+t,h=2*d,c=[],x=[],g=[],_=[];for(let v=0;v<=d;v++){const I=v/d,C=I*Math.PI*r;for(let A=0;A<=h;A++){const f=A/h,y=f*Math.PI*2*a,m=it.RotationZ(-C),P=it.RotationY(y),T=F.TransformCoordinates(F.Up(),m),R=F.TransformCoordinates(T,P),L=R.multiply(u),S=R.divide(u).normalize();x.push(L.x,L.y,L.z),g.push(S.x,S.y,S.z),_.push(f,I)}if(v>0){const A=x.length/3;for(let f=A-2*(h+1);f+h+2<A;f++)l?(v>1&&(c.push(f),c.push(f+1),c.push(f+h+1)),(v<d||r<1)&&(c.push(f+h+1),c.push(f+1),c.push(f+h+2))):(c.push(f),c.push(f+1),c.push(f+h+1),c.push(f+h+1),c.push(f+1),c.push(f+h+2))}}Z._ComputeSides(o,x,c,g,_,i.frontUVs,i.backUVs);const p=new Z;return p.indices=c,p.positions=x,p.normals=g,p.uvs=_,p}function Ne(i,t={},e=null){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,Se(t).applyToMesh(s,t.updatable),s}let oe=!1;function Ps(){oe||(oe=!0,Z.CreateSphere=Se,O.CreateSphere=(i,t,e,s,n,a)=>Ne(i,{segments:t,diameterX:e,diameterY:e,diameterZ:e,sideOrientation:a,updatable:n},s))}function Ue(i){const t=i.height||2;let e=i.diameterTop===0?0:i.diameterTop||i.diameter||1,s=i.diameterBottom===0?0:i.diameterBottom||i.diameter||1;e=e||1e-5,s=s||1e-5;const n=(i.tessellation||24)|0,a=(i.subdivisions||1)|0,r=!!i.hasRings,o=!!i.enclose,l=i.cap===0?0:i.cap||O.CAP_ALL,u=i.arc&&(i.arc<=0||i.arc>1)?1:i.arc||1,d=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE,h=i.faceUV||new Array(3),c=i.faceColors,x=u!==1&&o?2:0,g=r?a:1,_=2+(1+x)*g;let p;for(p=0;p<_;p++)c&&c[p]===void 0&&(c[p]=new pt(1,1,1,1));for(p=0;p<_;p++)h&&h[p]===void 0&&(h[p]=new yt(0,0,1,1));const v=[],I=[],C=[],A=[],f=[],y=Math.PI*2*u/n;let m,P,T;const R=(s-e)/2/t,L=F.Zero(),S=F.Zero(),H=F.Zero(),z=F.Zero(),W=F.Zero(),N=xs.Y;let U,G,B,M,b=1,D=0,w;for(U=0;U<=a;U++)for(P=U/a,T=(P*(e-s)+s)/2,M=r&&U!==0&&U!==a?2:1,B=0;B<M;B++){for(r&&(b+=B),o&&(b+=2*B),G=0;G<=n;G++)m=G*y,L.x=Math.cos(-m)*T,L.y=-t/2+P*t,L.z=Math.sin(-m)*T,e===0&&U===a?(S.x=C[C.length-(n+1)*3],S.y=C[C.length-(n+1)*3+1],S.z=C[C.length-(n+1)*3+2]):(S.x=L.x,S.z=L.z,S.y=Math.sqrt(S.x*S.x+S.z*S.z)*R,S.normalize()),G===0&&(H.copyFrom(L),z.copyFrom(S)),I.push(L.x,L.y,L.z),C.push(S.x,S.y,S.z),r?w=D!==b?h[b].y:h[b].w:w=h[b].y+(h[b].w-h[b].y)*P,A.push(h[b].x+(h[b].z-h[b].x)*G/n,w),c&&f.push(c[b].r,c[b].g,c[b].b,c[b].a);u!==1&&o&&(I.push(L.x,L.y,L.z),I.push(0,L.y,0),I.push(0,L.y,0),I.push(H.x,H.y,H.z),F.CrossToRef(N,S,W),W.normalize(),C.push(W.x,W.y,W.z,W.x,W.y,W.z),F.CrossToRef(z,N,W),W.normalize(),C.push(W.x,W.y,W.z,W.x,W.y,W.z),r?w=D!==b?h[b+1].y:h[b+1].w:w=h[b+1].y+(h[b+1].w-h[b+1].y)*P,A.push(h[b+1].x,w),A.push(h[b+1].z,w),r?w=D!==b?h[b+2].y:h[b+2].w:w=h[b+2].y+(h[b+2].w-h[b+2].y)*P,A.push(h[b+2].x,w),A.push(h[b+2].z,w),c&&(f.push(c[b+1].r,c[b+1].g,c[b+1].b,c[b+1].a),f.push(c[b+1].r,c[b+1].g,c[b+1].b,c[b+1].a),f.push(c[b+2].r,c[b+2].g,c[b+2].b,c[b+2].a),f.push(c[b+2].r,c[b+2].g,c[b+2].b,c[b+2].a))),D!==b&&(D=b)}const V=u!==1&&o?n+4:n;for(U=0,b=0;b<a;b++){let k=0,j=0,nt=0,at=0;for(G=0;G<n;G++)k=U*(V+1)+G,j=(U+1)*(V+1)+G,nt=U*(V+1)+(G+1),at=(U+1)*(V+1)+(G+1),v.push(k,j,nt),v.push(at,nt,j);u!==1&&o&&(v.push(k+2,j+2,nt+2),v.push(at+2,nt+2,j+2),v.push(k+4,j+4,nt+4),v.push(at+4,nt+4,j+4)),U=r?U+2:U+1}const Y=k=>{const j=k?e/2:s/2;if(j===0)return;let nt,at,$;const X=k?h[_-1]:h[0];let q=null;c&&(q=k?c[_-1]:c[0]);const st=I.length/3,K=k?t/2:-t/2,rt=new F(0,K,0);I.push(rt.x,rt.y,rt.z),C.push(0,k?1:-1,0);const gt=X.y+(X.w-X.y)*.5;A.push(X.x+(X.z-X.x)*.5,gt),q&&f.push(q.r,q.g,q.b,q.a);const lt=new tt(.5,.5);for($=0;$<=n;$++){nt=Math.PI*2*$*u/n;const ht=Math.cos(-nt),mt=Math.sin(-nt);at=new F(ht*j,K,mt*j);const dt=new tt(ht*lt.x+.5,mt*lt.y+.5);I.push(at.x,at.y,at.z),C.push(0,k?1:-1,0);const At=X.y+(X.w-X.y)*dt.y;A.push(X.x+(X.z-X.x)*dt.x,At),q&&f.push(q.r,q.g,q.b,q.a)}for($=0;$<n;$++)k?(v.push(st),v.push(st+($+2)),v.push(st+($+1))):(v.push(st),v.push(st+($+1)),v.push(st+($+2)))};(l===O.CAP_START||l===O.CAP_ALL)&&Y(!1),(l===O.CAP_END||l===O.CAP_ALL)&&Y(!0),Z._ComputeSides(d,I,v,C,A,i.frontUVs,i.backUVs);const E=new Z;return E.indices=v,E.positions=I,E.normals=C,E.uvs=A,c&&(E.colors=f),E}function We(i,t={},e){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,Ue(t).applyToMesh(s,t.updatable),s}let ce=!1;function Fs(){ce||(ce=!0,Z.CreateCylinder=Ue,O.CreateCylinder=(i,t,e,s,n,a,r,o,l)=>((r===void 0||!(r instanceof _s))&&(r!==void 0&&(l=o||O.DEFAULTSIDE,o=r),r=a,a=1),We(i,{height:t,diameterTop:e,diameterBottom:s,tessellation:n,subdivisions:a,sideOrientation:l,updatable:o},r)))}function Ze(i){const t=[],e=[],s=[],n=[],a=i.diameter||1,r=i.thickness||.5,o=(i.tessellation||16)|0,l=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE,u=o+1;for(let h=0;h<=o;h++){const c=h/o,x=h*Math.PI*2/o-Math.PI/2,g=it.Translation(a/2,0,0).multiply(it.RotationY(x));for(let _=0;_<=o;_++){const p=1-_/o,v=_*Math.PI*2/o+Math.PI,I=Math.cos(v),C=Math.sin(v);let A=new F(I,C,0),f=A.scale(r/2);const y=new tt(c,p);f=F.TransformCoordinates(f,g),A=F.TransformNormal(A,g),e.push(f.x,f.y,f.z),s.push(A.x,A.y,A.z),n.push(y.x,y.y);const m=(h+1)%u,P=(_+1)%u;
2t.push(h*u+_),t.push(h*u+P),t.push(m*u+_),t.push(h*u+P),t.push(m*u+P),t.push(m*u+_)}}Z._ComputeSides(l,e,t,s,n,i.frontUVs,i.backUVs);const d=new Z;return d.indices=t,d.positions=e,d.normals=s,d.uvs=n,d}function Xe(i,t={},e){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,Ze(t).applyToMesh(s,t.updatable),s}let le=!1;function Vs(){le||(le=!0,Z.CreateTorus=Ze,O.CreateTorus=(i,t,e,s,n,a,r)=>Xe(i,{diameter:t,thickness:e,tessellation:s,sideOrientation:r,updatable:a},n))}function He(i){const t=[],e=[],s=[],n=[],a=i.radius||2,r=i.tube||.5,o=i.radialSegments||32,l=i.tubularSegments||32,u=i.p||2,d=i.q||3,h=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE,c=p=>{const v=Math.cos(p),I=Math.sin(p),C=d/u*p,A=Math.cos(C),f=a*(2+A)*.5*v,y=a*(2+A)*I*.5,m=a*Math.sin(C)*.5;return new F(f,y,m)};let x,g;for(x=0;x<=o;x++){const v=x%o/o*2*u*Math.PI,I=c(v),C=c(v+.01),A=C.subtract(I);let f=C.add(I);const y=F.Cross(A,f);for(f=F.Cross(y,A),y.normalize(),f.normalize(),g=0;g<l;g++){const P=g%l/l*2*Math.PI,T=-r*Math.cos(P),R=r*Math.sin(P);e.push(I.x+T*f.x+R*y.x),e.push(I.y+T*f.y+R*y.y),e.push(I.z+T*f.z+R*y.z),n.push(x/o),n.push(g/l)}}for(x=0;x<o;x++)for(g=0;g<l;g++){const p=(g+1)%l,v=x*l+g,I=(x+1)*l+g,C=(x+1)*l+p,A=x*l+p;t.push(A),t.push(I),t.push(v),t.push(A),t.push(C),t.push(I)}Z.ComputeNormals(e,t,s),Z._ComputeSides(h,e,t,s,n,i.frontUVs,i.backUVs);const _=new Z;return _.indices=t,_.positions=e,_.normals=s,_.uvs=n,_}function Ge(i,t={},e){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,He(t).applyToMesh(s,t.updatable),s}let he=!1;function Rs(){he||(he=!0,Z.CreateTorusKnot=He,O.CreateTorusKnot=(i,t,e,s,n,a,r,o,l,u)=>Ge(i,{radius:t,tube:e,radialSegments:s,tubularSegments:n,p:a,q:r,sideOrientation:u,updatable:l},o))}var ue,de;class xt extends O{_isShaderMaterial(t){return t?t.getClassName()==="ShaderMaterial":!1}constructor(t,e=null,s=null,n=null,a,r,o,l){super(t,e,s,n,a),this.useVertexColor=r,this.useVertexAlpha=o,this.color=new Ft(1,1,1),this.alpha=1,this._shaderLanguage=0,this._ownsMaterial=!1,n&&(this.color=n.color.clone(),this.alpha=n.alpha,this.useVertexColor=n.useVertexColor,this.useVertexAlpha=n.useVertexAlpha),this.intersectionThreshold=.1;const u=[],d={attributes:[Q.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:u,useClipPlane:null,shaderLanguage:0};if(this.useVertexAlpha?d.defines.push("#define VERTEXALPHA"):d.needAlphaBlending=!1,this.useVertexColor?(d.defines.push("#define VERTEXCOLOR"),d.attributes.push(Q.ColorKind)):(d.uniforms.push("color"),this._color4=new pt),l)this.material=l;else{this.getScene().getEngine().isWebGPU&&!xt.ForceGLSL&&(this._shaderLanguage=1),d.shaderLanguage=this._shaderLanguage,d.extraInitializationsAsync=async()=>{this._shaderLanguage===1?await Promise.all([Ct(()=>import("./color.vertex-BE763cha.js"),__vite__mapDeps([0,1,2,3])),Ct(()=>import("./color.fragment-DrcP9H-Y.js"),__vite__mapDeps([4,1,5,6]))]):await Promise.all([Ct(()=>import("./color.vertex-Bz11lMd9.js"),__vite__mapDeps([7,1,8,9,10,11,12,13,14])),Ct(()=>import("./color.fragment-BGIR8YbO.js"),__vite__mapDeps([15,1,8,9,10,11,12,13,14]))])};const c=new ys("colorShader",this.getScene(),"color",d,!1);c.doNotSerialize=!0,this._ownsMaterial=!0,this._setInternalMaterial(c)}}getClassName(){return"LinesMesh"}get material(){return this._internalAbstractMeshDataInfo._material}set material(t){const e=this.material;if(e===t)return;const s=e&&this._ownsMaterial;this._ownsMaterial=!1,this._setInternalMaterial(t),s&&e?.dispose()}_setInternalMaterial(t){this._setMaterial(t),this.material&&(this.material.fillMode=Ut.LineListDrawMode,this.material.disableLighting=!0)}get checkCollisions(){return!1}set checkCollisions(t){}_bind(t,e){if(!this._geometry)return this;const s=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(!this._userInstancedBuffersStorage||this.hasThinInstances?this._geometry._bind(e,s):this._geometry._bind(e,s,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects),!this.useVertexColor&&this._isShaderMaterial(this.material)){const{r:n,g:a,b:r}=this.color;this._color4.set(n,a,r,this.alpha),this.material.setColor4("color",this._color4)}return this}_draw(t,e,s){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;const n=this.getScene().getEngine();return this._unIndexed?n.drawArraysType(Ut.LineListDrawMode,t.verticesStart,t.verticesCount,s):n.drawElementsType(Ut.LineListDrawMode,t.indexStart,t.indexCount,s),this}dispose(t,e=!1,s){s||(this._ownsMaterial?this.material?.dispose(!1,!1,!0):e&&this.material?.dispose(!1,!1,!0)),super.dispose(t)}clone(t,e=null,s){if(e&&e._addToSceneRootNodes===void 0){const n=e;
2return n.source=this,new xt(t,this.getScene(),n.parent,n.source,n.doNotCloneChildren)}return new xt(t,this.getScene(),e,this,s)}createInstance(t){const e=new Ye(t,this);if(this.instancedBuffers){e.instancedBuffers={};for(const s in this.instancedBuffers)e.instancedBuffers[s]=this.instancedBuffers[s]}return e}serialize(t){super.serialize(t),t.color=this.color.asArray(),t.alpha=this.alpha}static Parse(t,e){const s=new xt(t.name,e);return s.color=Ft.FromArray(t.color),s.alpha=t.alpha,s}}xt.ForceGLSL=!1;class Ye extends ms{constructor(t,e){super(t,e),this.intersectionThreshold=e.intersectionThreshold}getClassName(){return"InstancedLinesMesh"}}(ue=xt.prototype).enableEdgesRendering??(ue.enableEdgesRendering=Oe("LinesMesh","enableEdgesRendering"));(de=Ye.prototype).enableEdgesRendering??(de.enableEdgesRendering=Oe("InstancedLinesMesh","enableEdgesRendering"));function ke(i){const t=[],e=[],s=i.lines,n=i.colors,a=[];let r=0;for(let l=0;l<s.length;l++){const u=s[l];for(let d=0;d<u.length;d++){const{x:h,y:c,z:x}=u[d];if(e.push(h,c,x),n){const g=n[l],{r:_,g:p,b:v,a:I}=g[d];a.push(_,p,v,I)}d>0&&(t.push(r-1),t.push(r)),r++}}const o=new Z;return o.indices=t,o.positions=e,n&&(o.colors=a),o}function Ke(i){const t=i.dashSize||3,e=i.gapSize||1,s=i.dashNb||200,n=i.points,a=[],r=[],o=F.Zero();let l=0,u,d,h=0,c;for(c=0;c<n.length-1;c++)n[c+1].subtractToRef(n[c],o),l+=o.length();const x=l/s,g=t*x/(t+e);for(c=0;c<n.length-1;c++){n[c+1].subtractToRef(n[c],o),u=Math.floor(o.length()/x),o.normalize();for(let p=0;p<u;p++)d=x*p,a.push(n[c].x+d*o.x,n[c].y+d*o.y,n[c].z+d*o.z),a.push(n[c].x+(d+g)*o.x,n[c].y+(d+g)*o.y,n[c].z+(d+g)*o.z),r.push(h,h+1),h+=2}const _=new Z;return _.positions=a,_.indices=r,_}function qe(i,t,e=null){const s=t.instance,n=t.lines,a=t.colors;if(s){const u=s.getVerticesData(Q.PositionKind);let d,h;a&&(d=s.getVerticesData(Q.ColorKind));let c=0,x=0;for(let g=0;g<n.length;g++){const _=n[g];for(let p=0;p<_.length;p++)u[c]=_[p].x,u[c+1]=_[p].y,u[c+2]=_[p].z,a&&d&&(h=a[g],d[x]=h[p].r,d[x+1]=h[p].g,d[x+2]=h[p].b,d[x+3]=h[p].a,x+=4),c+=3}return s.updateVerticesData(Q.PositionKind,u,!1,!1),a&&d&&s.updateVerticesData(Q.ColorKind,d,!1,!1),s.refreshBoundingInfo(),s}const r=!!a,o=new xt(i,e,null,void 0,void 0,r,t.useVertexAlpha,t.material);return ke(t).applyToMesh(o,t.updatable),o}function Qe(i,t,e=null){const s=t.colors?[t.colors]:null;return qe(i,{lines:[t.points],updatable:t.updatable,instance:t.instance,colors:s,useVertexAlpha:t.useVertexAlpha,material:t.material},e)}function je(i,t,e=null){const s=t.points,n=t.instance,a=t.gapSize||1,r=t.dashSize||3;if(n){const u=d=>{const h=F.Zero(),c=d.length/6;let x=0,g,_,p=0,v,I;for(v=0;v<s.length-1;v++)s[v+1].subtractToRef(s[v],h),x+=h.length();const C=x/c,A=n._creationDataStorage.dashSize,f=n._creationDataStorage.gapSize,y=A*C/(A+f);for(v=0;v<s.length-1;v++)for(s[v+1].subtractToRef(s[v],h),g=Math.floor(h.length()/C),h.normalize(),I=0;I<g&&p<d.length;)_=C*I,d[p]=s[v].x+_*h.x,d[p+1]=s[v].y+_*h.y,d[p+2]=s[v].z+_*h.z,d[p+3]=s[v].x+(_+y)*h.x,d[p+4]=s[v].y+(_+y)*h.y,d[p+5]=s[v].z+(_+y)*h.z,p+=6,I++;for(;p<d.length;)d[p]=s[v].x,d[p+1]=s[v].y,d[p+2]=s[v].z,p+=3};return(t.dashNb||t.dashSize||t.gapSize||t.useVertexAlpha||t.material)&&ct.Warn("You have used an option other than points with the instance option. Please be aware that these other options will be ignored."),n.updateMeshPositions(u,!1),n}const o=new xt(i,e,null,void 0,void 0,void 0,t.useVertexAlpha,t.material);return Ke(t).applyToMesh(o,t.updatable),o._creationDataStorage=new De,o._creationDataStorage.dashSize=r,o._creationDataStorage.gapSize=a,o}let fe=!1;function Bs(){fe||(fe=!0,Z.CreateLineSystem=ke,Z.CreateDashedLines=Ke,O.CreateLines=(i,t,e=null,s=!1,n=null)=>Qe(i,{points:t,updatable:s,instance:n},e),O.CreateDashedLines=(i,t,e,s,n,a=null,r,o)=>je(i,{points:t,dashSize:e,gapSize:s,dashNb:n,updatable:r,instance:o},a))}class Ms extends tt{constructor(t,e){super(t.x,t.y),this.index=e}}class Zt{constructor(){this.elements=[]}add(t){const e=[];for(const s of t){const n=new Ms(s,this.elements.length);e.push(n),this.elements.push(n)}return e}computeBounds(){const t=new tt(this.elements[0].x,this.elements[0].y),e=new tt(this.elements[0].x,this.elements[0].y);for(const s of this.elements)s.x<t.x?t.x=s.x:s.x>e.x&&(e.x=s.x),s.y<t.y?t.y=s.y:s.y>
2e.y&&(e.y=s.y);return{min:t,max:e,width:e.x-t.x,height:e.y-t.y}}}class zs{_addToepoint(t){for(const e of t)this._epoints.push(e.x,e.y)}constructor(t,e,s,n=earcut){this._points=new Zt,this._outlinepoints=new Zt,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=n,this._name=t,this._scene=s||Ht.LastCreatedScene;let a;e instanceof Rt?a=e.getPoints():a=e,this._addToepoint(a),this._points.add(a),this._outlinepoints.add(a),typeof this.bjsEarcut>"u"&&ct.Warn("Earcut was not found, the polygon will not be built.")}addHole(t){this._points.add(t);const e=new Zt;return e.add(t),this._holes.push(e),this._eholes.push(this._epoints.length/2),this._addToepoint(t),this}build(t=!1,e=0,s=2){const n=new O(this._name,this._scene),a=this.buildVertexData(e,s);return n.setVerticesData(Q.PositionKind,a.positions,t),n.setVerticesData(Q.NormalKind,a.normals,t),n.setVerticesData(Q.UVKind,a.uvs,t),n.setIndices(a.indices),n}buildVertexData(t=0,e=2){const s=new Z,n=[],a=[],r=[],o=this._points.computeBounds();for(const d of this._points.elements)n.push(0,1,0),a.push(d.x,0,d.y),r.push((d.x-o.min.x)/o.width,(d.y-o.min.y)/o.height);const l=[],u=this.bjsEarcut(this._epoints,this._eholes,2);for(let d=0;d<u.length;d++)l.push(u[d]);if(t>0){const d=a.length/3;for(const c of this._points.elements)n.push(0,-1,0),a.push(c.x,-t,c.y),r.push(1-(c.x-o.min.x)/o.width,1-(c.y-o.min.y)/o.height);const h=l.length;for(let c=0;c<h;c+=3){const x=l[c+0],g=l[c+1],_=l[c+2];l.push(_+d),l.push(g+d),l.push(x+d)}this._addSide(a,n,r,l,o,this._outlinepoints,t,!1,e);for(const c of this._holes)this._addSide(a,n,r,l,o,c,t,!0,e)}return s.indices=l,s.positions=a,s.normals=n,s.uvs=r,s}_addSide(t,e,s,n,a,r,o,l,u){let d=t.length/3,h=0;for(let c=0;c<r.elements.length;c++){const x=r.elements[c],g=r.elements[(c+1)%r.elements.length];t.push(x.x,0,x.y),t.push(x.x,-o,x.y),t.push(g.x,0,g.y),t.push(g.x,-o,g.y);const _=r.elements[(c+r.elements.length-1)%r.elements.length],p=r.elements[(c+2)%r.elements.length];let v=new F(-(g.y-x.y),0,g.x-x.x),I=new F(-(x.y-_.y),0,x.x-_.x),C=new F(-(p.y-g.y),0,p.x-g.x);l||(v=v.scale(-1),I=I.scale(-1),C=C.scale(-1));const A=v.normalizeToNew();let f=I.normalizeToNew(),y;const m=F.Dot(f,A);m>u?m<bt-1?f=new F(x.x,0,x.y).subtract(new F(g.x,0,g.y)).normalize():f=I.add(v).normalize():f=A;const P=F.Dot(C,v);P>u?P<bt-1?y=new F(g.x,0,g.y).subtract(new F(x.x,0,x.y)).normalize():y=C.add(v).normalize():y=A,s.push(h/a.width,0),s.push(h/a.width,1),h+=v.length(),s.push(h/a.width,0),s.push(h/a.width,1),e.push(f.x,f.y,f.z),e.push(f.x,f.y,f.z),e.push(y.x,y.y,y.z),e.push(y.x,y.y,y.z),l?(n.push(d),n.push(d+2),n.push(d+1),n.push(d+1),n.push(d+2),n.push(d+3)):(n.push(d),n.push(d+1),n.push(d+2),n.push(d+1),n.push(d+3),n.push(d+2)),d+=4}}}function $e(i,t,e,s,n,a,r){const o=e||new Array(3),l=s,u=[],d=r||!1;for(let T=0;T<3;T++)o[T]===void 0&&(o[T]=new yt(0,0,1,1)),l&&l[T]===void 0&&(l[T]=new pt(1,1,1,1));const h=i.getVerticesData(Q.PositionKind),c=i.getVerticesData(Q.NormalKind),x=i.getVerticesData(Q.UVKind),g=i.getIndices(),_=h.length/9;let p,v,I,C,A=0;const f=[0];if(d)for(let T=_;T<h.length/3;T+=4)v=h[3*(T+2)]-h[3*T],I=h[3*(T+2)+2]-h[3*T+2],C=Math.sqrt(v*v+I*I),A+=C,f.push(A);let y,m=0;for(let T=0;T<c.length;T+=3)Math.abs(c[T+1])<.001&&(m=1),Math.abs(c[T+1]-1)<.001&&(m=0),Math.abs(c[T+1]+1)<.001&&(m=2),y=T/3,m===1?(p=y-_,p%4<1.5?d?x[2*y]=o[m].x+(o[m].z-o[m].x)*f[Math.floor(p/4)]/A:x[2*y]=o[m].x:d?x[2*y]=o[m].x+(o[m].z-o[m].x)*f[Math.floor(p/4)+1]/A:x[2*y]=o[m].z,p%2===0?x[2*y+1]=o[m].w:x[2*y+1]=o[m].y):(x[2*y]=(1-x[2*y])*o[m].x+x[2*y]*o[m].z,x[2*y+1]=(1-x[2*y+1])*o[m].y+x[2*y+1]*o[m].w),l&&u.push(l[m].r,l[m].g,l[m].b,l[m].a);Z._ComputeSides(t,h,g,c,x,n,a);const P=new Z;if(P.indices=g,P.positions=h,P.normals=c,P.uvs=x,l){const T=t===Z.DOUBLESIDE?u.concat(u):u;P.colors=T}return P}function Gt(i,t,e=null,s=earcut){t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation);const n=t.shape,a=t.holes||[],r=t.depth||0,o=t.smoothingThreshold||2,l=[];let u;for(let g=0;g<n.length;g++)l[g]=new tt(n[g].x,n[g].z);l[0].equalsWithEpsilon(l[l.length-1],1e-8)&&l.pop();const h=new zs(i,l,e||Ht.LastCreatedScene,s);for(let g=0;g<a.length;g++){u=[];for(let _=0;_<a[g].length;_++)u.push(new tt(a[g][_].x,a[g][_].z));h.addHole(u)}const c=h.build(!1,r,o);return c._originalBuilderSideOrientation=t.sideOrientation,$e(c,t.sideOrientation,t.faceUV,t.faceColors,t.frontUVs,t.backUVs,t.wrap).applyToMesh(c,t.updatable),c}function Yt(i,t,e=null,s=earcut){return Gt(i,t,e,s)}let ge=!1;function Ls(){ge||(ge=!0,Z.CreatePolygon=$e,O.CreatePolygon=(i,t,e,s,n,a,r=earcut)=>Gt(i,{shape:t,holes:s,updatable:n,sideOrientation:a},e,r),O.ExtrudePolygon=(i,t,e,s,n,a,r,o=earcut)=>Yt(i,{shape:t,holes:n,depth:e,updatable:a,sideOrientation:r},s,o))}function Je(i,t,e=null){const s=t.path,n=t.shape,a=t.scale||1,r=t.rotation||0,o=t.cap===0?0:t.cap||O.NO_CAP,l=t.updatable,u=O._GetDefaultSideOrientation(t.sideOrientation),d=t.instance||null,h=t.invertUV||!1,c=t.closeShape||!1,x=t.closePath||!1,g=t.capFunction||null;return es(i,n,s,a,r,null,null,x,c,o,!1,e,!!l,u,d,h,t.frontUVs||null,t.backUVs||null,t.firstNormal||null,!!t.adjustFrame,g)}function ts(i,t,e=null){const s=t.path,n=t.shape,a=F.Zero(),r=(I,C)=>
2{const A=t.scaleFunction?.(I,C)??1;return a.copyFromFloats(A,A,A)},o=t.rotationFunction||(()=>0),l=t.closePath||t.ribbonCloseArray||!1,u=t.closeShape||t.ribbonClosePath||!1,d=t.cap===0?0:t.cap||O.NO_CAP,h=t.updatable,c=t.firstNormal||null,x=t.adjustFrame||!1,g=O._GetDefaultSideOrientation(t.sideOrientation),_=t.instance,p=t.invertUV||!1,v=t.capFunction||null;return es(i,n,s,null,null,t.scaleVectorFunction??r,o,l,u,d,!0,e,!!h,g,_||null,p,t.frontUVs||null,t.backUVs||null,c,x,v||null)}function es(i,t,e,s,n,a,r,o,l,u,d,h,c,x,g,_,p,v,I,C,A){const f=(L,S,H,z,W,N,U,G,B,M,b)=>{const D=H.getTangents(),w=H.getNormals(),V=H.getBinormals(),Y=H.getDistances();if(b){for(let K=0;K<D.length;K++)if(D[K].x==0&&D[K].y==0&&D[K].z==0&&D[K].copyFrom(D[K-1]),w[K].x==0&&w[K].y==0&&w[K].z==0&&w[K].copyFrom(w[K-1]),V[K].x==0&&V[K].y==0&&V[K].z==0&&V[K].copyFrom(V[K-1]),K>0){let rt=D[K-1];F.Dot(rt,D[K])<0&&D[K].scaleInPlace(-1),rt=w[K-1],F.Dot(rt,w[K])<0&&w[K].scaleInPlace(-1),rt=V[K-1],F.Dot(rt,V[K])<0&&V[K].scaleInPlace(-1)}}let E=0;const k=()=>W!==null?W:F.OneReadOnly,nt=M&&G?G:()=>N!==null?N:0,at=M&&U?U:k;let $=B===O.NO_CAP||B===O.CAP_END?0:2;const X=ot.Matrix[0];for(let K=0;K<S.length;K++){const rt=[],gt=nt(K,Y[K]),lt=at(K,Y[K]);it.RotationAxisToRef(D[K],E,X);for(let ht=0;ht<L.length;ht++){const mt=D[K].scale(L[ht].z).add(w[K].scale(L[ht].x)).add(V[K].scale(L[ht].y)),dt=F.Zero();F.TransformCoordinatesToRef(mt,X,dt),dt.multiplyInPlace(lt).addInPlace(S[K]),rt[ht]=dt}z[$]=rt,E+=gt,$++}const st=A||(K=>{const rt=Array(),gt=F.Zero();let lt;for(lt=0;lt<K.length;lt++)gt.addInPlace(K[lt]);for(gt.scaleInPlace(1/K.length),lt=0;lt<K.length;lt++)rt.push(gt);return rt});switch(B){case O.NO_CAP:break;case O.CAP_START:z[0]=st(z[2]),z[1]=z[2];break;case O.CAP_END:z[$]=z[$-1],z[$+1]=st(z[$-1]);break;case O.CAP_ALL:z[0]=st(z[2]),z[1]=z[2],z[$]=z[$-1],z[$+1]=st(z[$-1]);break}return z},y=s!==null?new F(s,s,s):null;let m;if(g){const L=g._creationDataStorage;return I?L.path3D.update(e,I):L.path3D.update(e),m=f(t,e,L.path3D,L.pathArray,y,n,a,r,L.cap,d,C),g=vt("",{pathArray:m,closeArray:!1,closePath:!1,offset:0,updatable:!1,sideOrientation:0,instance:g},h||void 0),g}const P=I?new It(e,I):new It(e),T=new Array;u=u<0||u>3?0:u,m=f(t,e,P,T,y,n,a,r,u,d,C);const R=vt(i,{pathArray:m,closeArray:o,closePath:l,updatable:c,sideOrientation:x,invertUV:_,frontUVs:p||void 0,backUVs:v||void 0},h);return R._creationDataStorage.pathArray=m,R._creationDataStorage.path3D=P,R._creationDataStorage.cap=u,R}let xe=!1;function Es(){xe||(xe=!0,O.ExtrudeShape=(i,t,e,s,n,a,r=null,o,l,u)=>{const d={shape:t,path:e,scale:s,rotation:n,cap:a===0?0:a||O.NO_CAP,sideOrientation:l,instance:u,updatable:o};return Je(i,d,r)},O.ExtrudeShapeCustom=(i,t,e,s,n,a,r,o,l,u,d,h)=>{const c={shape:t,path:e,scaleFunction:s,rotationFunction:n,ribbonCloseArray:a,ribbonClosePath:r,cap:o===0?0:o||O.NO_CAP,sideOrientation:d,instance:h,updatable:u};return ts(i,c,l)})}function ss(i,t,e=null){const s=t.arc?t.arc<=0||t.arc>1?1:t.arc:1,n=t.closed===void 0?!0:t.closed,a=t.shape,r=t.radius||1,o=t.tessellation||64,l=t.clip||0,u=t.updatable,d=O._GetDefaultSideOrientation(t.sideOrientation),h=t.cap||O.NO_CAP,c=Math.PI*2,x=[],g=t.invertUV||!1;let _,p;const v=c/o*s;let I,C;for(_=0;_<=o-l;_++){for(C=[],(h==O.CAP_START||h==O.CAP_ALL)&&(C.push(new F(0,a[0].y,0)),C.push(new F(Math.cos(_*v)*a[0].x*r,a[0].y,Math.sin(_*v)*a[0].x*r))),p=0;p<a.length;p++)I=new F(Math.cos(_*v)*a[p].x*r,a[p].y,Math.sin(_*v)*a[p].x*r),C.push(I);(h==O.CAP_END||h==O.CAP_ALL)&&(C.push(new F(Math.cos(_*v)*a[a.length-1].x*r,a[a.length-1].y,Math.sin(_*v)*a[a.length-1].x*r)),C.push(new F(0,a[a.length-1].y,0))),x.push(C)}return vt(i,{pathArray:x,closeArray:n,sideOrientation:d,updatable:u,invertUV:g,frontUVs:t.frontUVs,backUVs:t.backUVs},e)}let me=!1;function Ss(){me||(me=!0,O.CreateLathe=(i,t,e,s,n,a,r)=>ss(i,{shape:t,radius:e,tessellation:s,sideOrientation:r,updatable:a},n))}function ns(i){const t=[],e=[],s=[],n=[],a=i.width!==void 0?i.width:i.size!==void 0?i.size:1,r=i.height!==void 0?i.height:i.size!==void 0?i.size:1,o=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE,l=a/2,u=r/2;e.push(-l,-u,0),s.push(0,0,-1),n.push(0,0),e.push(l,-u,0),s.push(0,0,-1),n.push(1,0),e.push(l,u,0),s.push(0,0,-1),n.push(1,1),e.push(-l,u,0),s.push(0,0,-1),n.push(0,1),t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),Z._
2ComputeSides(o,e,t,s,n,i.frontUVs,i.backUVs);const d=new Z;return d.indices=t,d.positions=e,d.normals=s,d.uvs=n,d}function is(i,t={},e=null){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,ns(t).applyToMesh(s,t.updatable),t.sourcePlane&&(s.translate(t.sourcePlane.normal,-t.sourcePlane.d),s.setDirection(t.sourcePlane.normal.scale(-1))),s}let pe=!1;function Ns(){pe||(pe=!0,Z.CreatePlane=ns,O.CreatePlane=(i,t,e,s,n)=>is(i,{size:t,width:t,height:t,sideOrientation:n,updatable:s},e))}function as(i,t,e=null){const s=t.path;let n=t.instance,a=1;t.radius!==void 0?a=t.radius:n&&(a=n._creationDataStorage.radius);const r=t.tessellation||64,o=t.radiusFunction||null;let l=t.cap||O.NO_CAP;const u=t.invertUV||!1,d=t.updatable,h=O._GetDefaultSideOrientation(t.sideOrientation);t.arc=t.arc&&(t.arc<=0||t.arc>1)?1:t.arc||1;const c=(v,I,C,A,f,y,m,P)=>{const T=I.getTangents(),R=I.getNormals(),L=I.getDistances(),H=Math.PI*2/f*P,W=y||(()=>A);let N,U,G,B;const M=ot.Matrix[0];let b=m===O.NO_CAP||m===O.CAP_END?0:2;for(let w=0;w<v.length;w++){U=W(w,L[w]),N=Array(),G=R[w];for(let V=0;V<f;V++)it.RotationAxisToRef(T[w],H*V,M),B=N[V]?N[V]:F.Zero(),F.TransformCoordinatesToRef(G,M,B),B.scaleInPlace(U).addInPlace(v[w]),N[V]=B;C[b]=N,b++}const D=(w,V)=>{const Y=Array();for(let E=0;E<w;E++)Y.push(v[V]);return Y};switch(m){case O.NO_CAP:break;case O.CAP_START:C[0]=D(f,0),C[1]=C[2].slice(0);break;case O.CAP_END:C[b]=C[b-1].slice(0),C[b+1]=D(f,v.length-1);break;case O.CAP_ALL:C[0]=D(f,0),C[1]=C[2].slice(0),C[b]=C[b-1].slice(0),C[b+1]=D(f,v.length-1);break}return C};let x,g;if(n){const v=n._creationDataStorage,I=t.arc||v.arc;return x=v.path3D.update(s),g=c(s,x,v.pathArray,a,v.tessellation,o,v.cap,I),n=vt("",{pathArray:g,instance:n}),v.path3D=x,v.pathArray=g,v.arc=I,v.radius=a,n}x=new It(s);const _=new Array;l=l<0||l>3?0:l,g=c(s,x,_,a,r,o,l,t.arc);const p=vt(i,{pathArray:g,closePath:!0,closeArray:!1,updatable:d,sideOrientation:h,invertUV:u,frontUVs:t.frontUVs,backUVs:t.backUVs},e);return p._creationDataStorage.pathArray=g,p._creationDataStorage.path3D=x,p._creationDataStorage.tessellation=r,p._creationDataStorage.cap=l,p._creationDataStorage.arc=t.arc,p._creationDataStorage.radius=a,p}let _e=!1;function Us(){_e||(_e=!0,O.CreateTube=(i,t,e,s,n,a,r,o,l,u)=>as(i,{path:t,radius:e,tessellation:s,radiusFunction:n,arc:1,cap:a,updatable:o,sideOrientation:l,instance:u},r))}function rs(i){const t=[];t[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},t[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},t[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},t[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},t[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,
20,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},t[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},t[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},t[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},t[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},t[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},t[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},t[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},t[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},t[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},t[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};const e=i.type&&(i.type<0||i.type>=t.length)?0:i.type||0,s=i.size,n=i.sizeX||s||1,a=i.sizeY||s||1,r=i.sizeZ||s||1,o=i.custom||t[e],l=o.face.length,u=i.faceUV||new Array(l),d=i.faceColors,h=i.flat===void 0?!0:i.flat,c=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE,x=[],g=[],_=[],p=[],v=[];let I=0,C=0;const A=[];let f,y,m,P,T,R,L,S;if(h)for(y=0;y<l;y++)d&&d[y]===void 0&&(d[y]=new pt(1,1,1,1)),u&&u[y]===void 0&&(u[y]=new yt(0,0,1,1));if(h)for(y=0;y<l;y++){const z=o.face[y].length;for(T=2*Math.PI/z,R=.5*Math.tan(T/2),L=.5,f=0;f<z;f++)x.push(o.vertex[o.face[y][f]][0]*n,o.vertex[o.face[y][f]][1]*a,o.vertex[o.face[y][f]][2]*r),A.push(I),I++,m=u[y].x+(u[y].z-u[y].x)*(.5+R),P=u[y].y+(u[y].w-u[y].y)*(L-.5),p.push(m,P),S=R*Math.cos(T)-L*Math.sin(T),L=R*Math.sin(T)+L*Math.cos(T),R=S,d&&v.push(d[y].r,d[y].g,d[y].b,d[y].a);for(f=0;f<z-2;f++)g.push(A[0+C],A[f+2+C],A[f+1+C]);C+=z}else{for(f=0;f<o.vertex.length;f++)x.push(o.vertex[f][0]*n,o.vertex[f][1]*a,o.vertex[f][2]*r),p.push(0,0);for(y=0;y<l;y++)for(f=0;f<o.face[y].length-2;f++)g.push(o.face[y][0],o.face[y][f+2],o.face[y][f+1])}
2Z.ComputeNormals(x,g,_),Z._ComputeSides(c,x,g,_,p,i.frontUVs,i.backUVs);const H=new Z;return H.positions=x,H.indices=g,H.normals=_,H.uvs=p,d&&h&&(H.colors=v),H}function kt(i,t={},e=null){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,rs(t).applyToMesh(s,t.updatable),s}let ye=!1;function Ws(){ye||(ye=!0,Z.CreatePolyhedron=rs,O.CreatePolyhedron=(i,t,e)=>kt(i,t,e))}function os(i){const t=i.sideOrientation||Z.DEFAULTSIDE,e=i.radius||1,s=i.flat===void 0?!0:i.flat,n=(i.subdivisions||4)|0,a=i.radiusX||e,r=i.radiusY||e,o=i.radiusZ||e,l=(1+Math.sqrt(5))/2,u=[-1,l,-0,1,l,0,-1,-l,0,1,-l,0,0,-1,-l,0,1,-l,0,-1,l,0,1,l,l,0,1,l,0,-1,-l,0,1,-l,0,-1],d=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],h=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],c=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],x=138/1024,g=239/1024,_=60/1024,p=26/1024,v=-40/1024,I=20/1024,C=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],A=[],f=[],y=[],m=[];let P=0;const T=new Array(3),R=new Array(3);let L;for(L=0;L<3;L++)T[L]=F.Zero(),R[L]=tt.Zero();for(let H=0;H<20;H++){for(L=0;L<3;L++){const W=d[3*H+L];T[L].copyFromFloats(u[3*h[W]],u[3*h[W]+1],u[3*h[W]+2]),T[L].normalize(),R[L].copyFromFloats(c[2*W]*x+_+C[H]*v,c[2*W+1]*g+p+C[H]*I)}const z=(W,N,U,G)=>{const B=F.Lerp(T[0],T[2],N/n),M=F.Lerp(T[1],T[2],N/n),b=n===N?T[2]:F.Lerp(B,M,W/(n-N));b.normalize();let D;if(s){const E=F.Lerp(T[0],T[2],G/n),k=F.Lerp(T[1],T[2],G/n);D=F.Lerp(E,k,U/(n-G))}else D=new F(b.x,b.y,b.z);D.x/=a,D.y/=r,D.z/=o,D.normalize();const w=tt.Lerp(R[0],R[2],N/n),V=tt.Lerp(R[1],R[2],N/n),Y=n===N?R[2]:tt.Lerp(w,V,W/(n-N));f.push(b.x*a,b.y*r,b.z*o),y.push(D.x,D.y,D.z),m.push(Y.x,Y.y),A.push(P),P++};for(let W=0;W<n;W++)for(let N=0;N+W<n;N++)z(N,W,N+1/3,W+1/3),z(N+1,W,N+1/3,W+1/3),z(N,W+1,N+1/3,W+1/3),N+W+1<n&&(z(N+1,W,N+2/3,W+2/3),z(N+1,W+1,N+2/3,W+2/3),z(N,W+1,N+2/3,W+2/3))}Z._ComputeSides(t,f,A,y,m,i.frontUVs,i.backUVs);const S=new Z;return S.indices=A,S.positions=f,S.normals=y,S.uvs=m,S}function cs(i,t={},e=null){const s=new O(i,e);return t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),s._originalBuilderSideOrientation=t.sideOrientation,os(t).applyToMesh(s,t.updatable),s}let ve=!1;function Zs(){ve||(ve=!0,Z.CreateIcoSphere=os,O.CreateIcoSphere=(i,t,e)=>cs(i,t,e))}const Xs=new F(1,0,0),Hs=new F(-1,0,0),Gs=new F(0,1,0),Ys=new F(0,-1,0),ks=new F(0,0,1),Ks=new F(0,0,-1);class Vt{constructor(t=F.Zero(),e=F.Up(),s=tt.Zero(),n=0,a=0,r=null,o=null,l=null,u=null){this.position=t,this.normal=e,this.uv=s,this.vertexIdx=n,this.vertexIdxForBones=a,this.localPositionOverride=r,this.localNormalOverride=o,this.matrixIndicesOverride=l,this.matrixWeightsOverride=u}clone(){return new Vt(this.position.clone(),this.normal.clone(),this.uv.clone(),this.vertexIdx,this.vertexIdxForBones,this.localPositionOverride?.slice(),this.localNormalOverride?.slice(),this.matrixIndicesOverride?.slice(),this.matrixWeightsOverride?.slice())}}function ls(i,t,e){const s=!!t.skeleton,n=!!t.morphTargetManager?.numTargets,a=e.localMode||s,r=t.getIndices(),o=s||n?t.getPositionData(!0,!0):t.getVerticesData(Q.PositionKind),l=s||n?t.getNormalsData(!0,!0):t.getVerticesData(Q.NormalKind),u=a?s?t.getVerticesData(Q.PositionKind):o:null,d=a?s?t.getVerticesData(Q.NormalKind):l:null,h=t.getVerticesData(Q.UVKind),c=s?t.getVerticesData(Q.MatricesIndicesKind):null,x=s?t.getVerticesData(Q.MatricesWeightsKind):null,g=s?t.getVerticesData(Q.MatricesIndicesExtraKind):null,_=s?t.getVerticesData(Q.MatricesWeightsExtraKind):null,p=e.position||F.Zero();let v=e.normal||F.Up();const I=e.size||F.One(),C=e.angle||0;if(!v){const U=new F(0,0,1),G=t.getScene().activeCamera,B=F.TransformCoordinates(U,G.getWorldMatrix());v=G.globalPosition.subtract(B)}const A=-Math.atan2(v.z,v.x)-Math.PI/2,f=Math.sqrt(v.x*v.x+v.z*v.z),y=Math.atan2(v.y,f),m=new Z;m.indices=[],m.positions=[],m.normals=[],m.uvs=[],m.matricesIndices=s?[]:null,m.matricesWeights=s?[]:null,m.matricesIndicesExtra=g?[]:null,m.matricesWeightsExtra=_?[]:null;let P=0;const T=(U,G)=>{const B=new Vt;if(!r||!o||!l)return B;const M=r[U];if(B.vertexIdx=M*3,B.vertexIdxForBones=M*4,B.position=new F(o[M*3],o[M*3+1],o[M*3+2]),F.TransformCoordinatesToRef(B.position,G,B.position),B.normal=new F(l[M*3],l[M*3+1],l[M*3+2]),F.TransformNormalToRef(
2B.normal,G,B.normal),e.captureUVS&&h){const b=h[M*2+1];B.uv=new tt(h[M*2],b)}return B},R=[0,0,0,0],L=(U,G)=>{if(U.length===0)return U;const B=.5*Math.abs(F.Dot(I,G)),M=(w,V,Y,E)=>{for(let k=0;k<E;++k)if(w[Y+k]===V)return Y+k;return-1},b=(w,V)=>{const Y=F.GetClipFactor(w.position,V.position,G,B);let E=R,k=R;if(c&&x){const Ot=w.matrixIndicesOverride?0:w.vertexIdxForBones,Lt=w.matrixIndicesOverride??c,qt=w.matrixWeightsOverride??x,Et=V.matrixIndicesOverride?0:V.vertexIdxForBones,Qt=V.matrixIndicesOverride??c,jt=V.matrixWeightsOverride??x;E=[0,0,0,0],k=[0,0,0,0];let _t=0;for(let ut=0;ut<4;++ut)if(qt[Ot+ut]>0){const Dt=M(Qt,Lt[Ot+ut],Et,4);E[_t]=Lt[Ot+ut],k[_t]=$t(qt[Ot+ut],Dt>=0?jt[Dt]:0,Y),_t++}for(let ut=0;ut<4&&_t<4;++ut){const Dt=Qt[Et+ut];M(Lt,Dt,Ot,4)===-1&&(E[_t]=Dt,k[_t]=$t(0,jt[Et+ut],Y),_t++)}const Tt=k[0]+k[1]+k[2]+k[3];k[0]/=Tt,k[1]/=Tt,k[2]/=Tt,k[3]/=Tt}const j=w.localPositionOverride?w.localPositionOverride[0]:u?.[w.vertexIdx]??0,nt=w.localPositionOverride?w.localPositionOverride[1]:u?.[w.vertexIdx+1]??0,at=w.localPositionOverride?w.localPositionOverride[2]:u?.[w.vertexIdx+2]??0,$=V.localPositionOverride?V.localPositionOverride[0]:u?.[V.vertexIdx]??0,X=V.localPositionOverride?V.localPositionOverride[1]:u?.[V.vertexIdx+1]??0,q=V.localPositionOverride?V.localPositionOverride[2]:u?.[V.vertexIdx+2]??0,st=w.localNormalOverride?w.localNormalOverride[0]:d?.[w.vertexIdx]??0,K=w.localNormalOverride?w.localNormalOverride[1]:d?.[w.vertexIdx+1]??0,rt=w.localNormalOverride?w.localNormalOverride[2]:d?.[w.vertexIdx+2]??0,gt=V.localNormalOverride?V.localNormalOverride[0]:d?.[V.vertexIdx]??0,lt=V.localNormalOverride?V.localNormalOverride[1]:d?.[V.vertexIdx+1]??0,ht=V.localNormalOverride?V.localNormalOverride[2]:d?.[V.vertexIdx+2]??0,mt=st+(gt-st)*Y,dt=K+(lt-K)*Y,At=rt+(ht-rt)*Y,zt=Math.sqrt(mt*mt+dt*dt+At*At);return new Vt(F.Lerp(w.position,V.position,Y),F.Lerp(w.normal,V.normal,Y).normalize(),tt.Lerp(w.uv,V.uv,Y),-1,-1,u?[j+($-j)*Y,nt+(X-nt)*Y,at+(q-at)*Y]:null,d?[mt/zt,dt/zt,At/zt]:null,E,k)};let D=null;U.length>3&&(D=[]);for(let w=0;w<U.length;w+=3){let V=null,Y=null,E=null,k=null;const j=F.Dot(U[w].position,G)-B,nt=F.Dot(U[w+1].position,G)-B,at=F.Dot(U[w+2].position,G)-B,$=j>0,X=nt>0,q=at>0;switch(($?1:0)+(X?1:0)+(q?1:0)){case 0:U.length>3?(D.push(U[w]),D.push(U[w+1]),D.push(U[w+2])):D=U;break;case 1:if(D=D??new Array,$&&(V=U[w+1],Y=U[w+2],E=b(U[w],V),k=b(U[w],Y)),X){V=U[w],Y=U[w+2],E=b(U[w+1],V),k=b(U[w+1],Y),D.push(E),D.push(Y.clone()),D.push(V.clone()),D.push(Y.clone()),D.push(E.clone()),D.push(k);break}q&&(V=U[w],Y=U[w+1],E=b(U[w+2],V),k=b(U[w+2],Y)),V&&Y&&E&&k&&(D.push(V.clone()),D.push(Y.clone()),D.push(E),D.push(k),D.push(E.clone()),D.push(Y.clone()));break;case 2:D=D??new Array,$||(V=U[w].clone(),Y=b(V,U[w+1]),E=b(V,U[w+2]),D.push(V),D.push(Y),D.push(E)),X||(V=U[w+1].clone(),Y=b(V,U[w+2]),E=b(V,U[w]),D.push(V),D.push(Y),D.push(E)),q||(V=U[w+2].clone(),Y=b(V,U[w]),E=b(V,U[w+1]),D.push(V),D.push(Y),D.push(E));break}}return D},S=t instanceof O?t:null,H=S?._thinInstanceDataStorage.matrixData,z=S?.thinInstanceCount||1,W=ot.Matrix[0];W.copyFrom(it.IdentityReadOnly);for(let U=0;U<z;++U){if(S?.hasThinInstances&&H){const w=U*16;W.setRowFromFloats(0,H[w+0],H[w+1],H[w+2],H[w+3]),W.setRowFromFloats(1,H[w+4],H[w+5],H[w+6],H[w+7]),W.setRowFromFloats(2,H[w+8],H[w+9],H[w+10],H[w+11]),W.setRowFromFloats(3,H[w+12],H[w+13],H[w+14],H[w+15])}const G=it.RotationYawPitchRoll(A,y,C).multiply(it.Translation(p.x,p.y,p.z)),B=it.Invert(G),M=t.getWorldMatrix(),b=W.multiply(M).multiply(B),D=new Array(3);for(let w=0;w<r.length;w+=3){let V=D;if(V[0]=T(w,b),V[1]=T(w+1,b),V[2]=T(w+2,b),!(e.cullBackFaces&&-V[0].normal.z<=0&&-V[1].normal.z<=0&&-V[2].normal.z<=0)&&(V=L(V,Xs),!!V&&(V=L(V,Hs),!!V&&(V=L(V,Gs),!!V&&(V=L(V,Ys),!!V&&(V=L(V,ks),!!V&&(V=L(V,Ks),!!V)))))))for(let Y=0;Y<V.length;Y++){const E=V[Y];if(m.indices.push(P),a?(E.localPositionOverride?(m.positions[P*3]=E.localPositionOverride[0],m.positions[P*3+1]=E.localPositionOverride[1],m.positions[P*3+2]=E.localPositionOverride[2]):u&&(m.positions[P*3]=u[E.vertexIdx],m.positions[P*3+1]=u[E.vertexIdx+1],m.positions[P*3+2]=u[E.vertexIdx+2]),E.localNormalOverride?(m.normals[P*3]=E.localNormalOverride[0],m.normals[P*3+1]=E.localNormalOverride[1],m.normals[P*3+2]=E.localNormalOverride[2]):d&&(m.normals[P*3]=d[E.vertexIdx],m.normals[P*3+1]=d[E.vertexIdx+1],m.normals[P*3+2]=d[E.vertexIdx+2])):(E.position.toArray(m.positions,P*3),E.normal.toArray(m.n
2ormals,P*3)),m.matricesIndices&&m.matricesWeights&&(E.matrixIndicesOverride?(m.matricesIndices[P*4]=E.matrixIndicesOverride[0],m.matricesIndices[P*4+1]=E.matrixIndicesOverride[1],m.matricesIndices[P*4+2]=E.matrixIndicesOverride[2],m.matricesIndices[P*4+3]=E.matrixIndicesOverride[3]):(c&&(m.matricesIndices[P*4]=c[E.vertexIdxForBones],m.matricesIndices[P*4+1]=c[E.vertexIdxForBones+1],m.matricesIndices[P*4+2]=c[E.vertexIdxForBones+2],m.matricesIndices[P*4+3]=c[E.vertexIdxForBones+3]),g&&m.matricesIndicesExtra&&(m.matricesIndicesExtra[P*4]=g[E.vertexIdxForBones],m.matricesIndicesExtra[P*4+1]=g[E.vertexIdxForBones+1],m.matricesIndicesExtra[P*4+2]=g[E.vertexIdxForBones+2],m.matricesIndicesExtra[P*4+3]=g[E.vertexIdxForBones+3])),E.matrixWeightsOverride?(m.matricesWeights[P*4]=E.matrixWeightsOverride[0],m.matricesWeights[P*4+1]=E.matrixWeightsOverride[1],m.matricesWeights[P*4+2]=E.matrixWeightsOverride[2],m.matricesWeights[P*4+3]=E.matrixWeightsOverride[3]):(x&&(m.matricesWeights[P*4]=x[E.vertexIdxForBones],m.matricesWeights[P*4+1]=x[E.vertexIdxForBones+1],m.matricesWeights[P*4+2]=x[E.vertexIdxForBones+2],m.matricesWeights[P*4+3]=x[E.vertexIdxForBones+3]),_&&m.matricesWeightsExtra&&(m.matricesWeightsExtra[P*4]=_[E.vertexIdxForBones],m.matricesWeightsExtra[P*4+1]=_[E.vertexIdxForBones+1],m.matricesWeightsExtra[P*4+2]=_[E.vertexIdxForBones+2],m.matricesWeightsExtra[P*4+3]=_[E.vertexIdxForBones+3]))),e.captureUVS)E.uv.toArray(m.uvs,P*2);else{m.uvs.push(.5+E.position.x/I.x);const k=.5+E.position.y/I.y;m.uvs.push(k)}P++}}}m.indices.length===0&&(m.indices=null),m.positions.length===0&&(m.positions=null),m.normals.length===0&&(m.normals=null),m.uvs.length===0&&(m.uvs=null),m.matricesIndices?.length===0&&(m.matricesIndices=null),m.matricesWeights?.length===0&&(m.matricesWeights=null),m.matricesIndicesExtra?.length===0&&(m.matricesIndicesExtra=null),m.matricesWeightsExtra?.length===0&&(m.matricesWeightsExtra=null);const N=new O(i,t.getScene());return m.applyToMesh(N),a?(N.skeleton=t.skeleton,N.parent=t):(N.position=p.clone(),N.rotation=new F(y,A,C)),N.computeWorldMatrix(!0),N.refreshBoundingInfo(!0,!0),N}let be=!1;function qs(){be||(be=!0,O.CreateDecal=(i,t,e,s,n,a)=>ls(i,t,{position:e,normal:s,size:n,angle:a}))}function hs(i={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){const t=Math.max(i.subdivisions?i.subdivisions:2,1)|0,e=Math.max(i.tessellation?i.tessellation:16,3)|0,s=Math.max(i.height?i.height:1,0),n=Math.max(i.radius?i.radius:.25,0),a=Math.max(i.capSubdivisions?i.capSubdivisions:6,1)|0,r=e,o=t,l=Math.max(i.radiusTop?i.radiusTop:n,0),u=Math.max(i.radiusBottom?i.radiusBottom:n,0),d=s-(l+u),h=0,c=2*Math.PI,x=Math.max(i.topCapSubdivisions?i.topCapSubdivisions:a,1),g=Math.max(i.bottomCapSubdivisions?i.bottomCapSubdivisions:a,1),_=Math.acos((u-l)/s);let p=[];const v=[],I=[],C=[];let A=0;const f=[],y=d*.5,m=Math.PI*.5;let P,T;const R=F.Zero(),L=F.Zero(),S=Math.cos(_),H=Math.sin(_),z=new tt(l*H,y+l*S).subtract(new tt(u*H,-y+u*S)).length(),W=l*_+z+u*(m-_);let N=0;for(T=0;T<=x;T++){const M=[],b=m-_*(T/x);N+=l*_/x;const D=Math.cos(b),w=Math.sin(b),V=D*l;for(P=0;P<=r;P++){const Y=P/r,E=Y*c+h,k=Math.sin(E),j=Math.cos(E);L.x=V*k,L.y=y+w*l,L.z=V*j,v.push(L.x,L.y,L.z),R.set(D*k,w,D*j),I.push(R.x,R.y,R.z),C.push(Y,1-N/W),M.push(A),A++}f.push(M)}const U=s-l-u+S*l-S*u,G=H*(u-l)/U;for(T=1;T<=o;T++){const M=[];N+=z/o;const b=H*(T*(u-l)/o+l);for(P=0;P<=r;P++){const D=P/r,w=D*c+h,V=Math.sin(w),Y=Math.cos(w);L.x=b*V,L.y=y+S*l-T*U/o,L.z=b*Y,v.push(L.x,L.y,L.z),R.set(V,G,Y).normalize(),I.push(R.x,R.y,R.z),C.push(D,1-N/W),M.push(A),A++}f.push(M)}for(T=1;T<=g;T++){const M=[],b=m-_-(Math.PI-_)*(T/g);N+=u*_/g;const D=Math.cos(b),w=Math.sin(b),V=D*u;for(P=0;P<=r;P++){const Y=P/r,E=Y*c+h,k=Math.sin(E),j=Math.cos(E);L.x=V*k,L.y=-y+w*u,L.z=V*j,v.push(L.x,L.y,L.z),R.set(D*k,w,D*j),I.push(R.x,R.y,R.z),C.push(Y,1-N/W),M.push(A),A++}f.push(M)}for(P=0;P<r;P++)for(T=0;T<x+o+g;T++){const M=f[T][P],b=f[T+1][P],D=f[T+1][P+1],w=f[T][P+1];p.push(M),p.push(b),p.push(w),p.push(b),p.push(D),p.push(w)}
2if(p=p.reverse(),i.orientation&&!i.orientation.equals(F.Up())){const M=new it;i.orientation.clone().scale(Math.PI*.5).cross(F.Up()).toQuaternion().toRotationMatrix(M);const b=F.Zero();for(let D=0;D<v.length;D+=3)b.set(v[D],v[D+1],v[D+2]),F.TransformCoordinatesToRef(b.clone(),M,b),v[D]=b.x,v[D+1]=b.y,v[D+2]=b.z}const B=new Z;return B.positions=v,B.normals=I,B.uvs=C,B.indices=p,B}function us(i,t={orientation:F.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6,updatable:!1},e=null){const s=new O(i,e);return hs(t).applyToMesh(s,t.updatable),s}let Ae=!1;function Qs(){Ae||(Ae=!0,O.CreateCapsule=(i,t,e)=>us(i,t,e),Z.CreateCapsule=hs)}class J{constructor(t=0,e=0){this.x=t,this.y=e,t!==Math.floor(t)&&(t=Math.floor(t),ct.Warn("x is not an integer, floor(x) used")),e!==Math.floor(e)&&(e=Math.floor(e),ct.Warn("y is not an integer, floor(y) used"))}clone(){return new J(this.x,this.y)}rotate60About(t){const e=this.x;return this.x=t.x+t.y-this.y,this.y=e+this.y-t.x,this}rotateNeg60About(t){const e=this.x;return this.x=e+this.y-t.y,this.y=t.x+t.y-e,this}rotate120(t,e){t!==Math.floor(t)&&(t=Math.floor(t),ct.Warn("m not an integer only floor(m) used")),e!==Math.floor(e)&&(e=Math.floor(e),ct.Warn("n not an integer only floor(n) used"));const s=this.x;return this.x=t-s-this.y,this.y=e+s,this}rotateNeg120(t,e){t!==Math.floor(t)&&(t=Math.floor(t),ct.Warn("m is not an integer, floor(m) used")),e!==Math.floor(e)&&(e=Math.floor(e),ct.Warn("n is not an integer, floor(n) used"));const s=this.x;return this.x=this.y-e,this.y=t+e-s-this.y,this}toCartesianOrigin(t,e){const s=F.Zero();return s.x=t.x+2*this.x*e+this.y*e,s.y=t.y+Math.sqrt(3)*this.y*e,s}static Zero(){return new J(0,0)}}class ds{constructor(){this.cartesian=[],this.vertices=[],this.max=[],this.min=[],this.closestTo=[],this.innerFacets=[],this.isoVecsABOB=[],this.isoVecsOBOA=[],this.isoVecsBAOA=[],this.vertexTypes=[],this.IDATA=new Xt("icosahedron","Regular",[[0,et,-1],[-et,1,0],[-1,0,-et],[1,0,-et],[et,1,0],[0,et,1],[-1,0,et],[-et,-1,0],[0,-et,-1],[et,-1,0],[1,0,et],[0,-et,1]],[[0,2,1],[0,3,2],[0,4,3],[0,5,4],[0,1,5],[7,6,1],[8,7,2],[9,8,3],[10,9,4],[6,10,5],[2,7,1],[3,8,2],[4,9,3],[5,10,4],[1,6,5],[11,6,7],[11,7,8],[11,8,9],[11,9,10],[11,10,6]])}setIndices(){let t=12;const e={},s=this.m,n=this.n;let a=s;n!==0&&(a=Jt(s,n));const r=s/a,o=n/a;let l,u,d,h,c;const x=J.Zero(),g=new J(s,n),_=new J(-n,s+n),p=J.Zero(),v=J.Zero(),I=J.Zero();let C=[],A,f,y,m;const P=[],T=this.vertByDist,R=(L,S,H,z)=>{A=L+"|"+H,f=S+"|"+z,A in e||f in e?A in e&&!(f in e)?e[f]=e[A]:f in e&&!(A in e)&&(e[A]=e[f]):(e[A]=t,e[f]=t,t++),T[H][0]>2?P[e[A]]=[-T[H][0],T[H][1],e[A]]:P[e[A]]=[C[T[H][0]],T[H][1],e[A]]};this.IDATA.edgematch=[[1,"B"],[2,"B"],[3,"B"],[4,"B"],[0,"B"],[10,"O",14,"A"],[11,"O",10,"A"],[12,"O",11,"A"],[13,"O",12,"A"],[14,"O",13,"A"],[0,"O"],[1,"O"],[2,"O"],[3,"O"],[4,"O"],[19,"B",5,"A"],[15,"B",6,"A"],[16,"B",7,"A"],[17,"B",8,"A"],[18,"B",9,"A"]];for(let L=0;L<20;L++){if(C=this.IDATA.face[L],d=C[2],h=C[1],c=C[0],y=x.x+"|"+x.y,A=L+"|"+y,A in e||(e[A]=d,P[d]=[C[T[y][0]],T[y][1]]),y=g.x+"|"+g.y,A=L+"|"+y,A in e||(e[A]=h,P[h]=[C[T[y][0]],T[y][1]]),y=_.x+"|"+_.y,A=L+"|"+y,A in e||(e[A]=c,P[c]=[C[T[y][0]],T[y][1]]),l=this.IDATA.edgematch[L][0],u=this.IDATA.edgematch[L][1],u==="B")for(let S=1;S<a;S++)v.x=s-S*(r+o),v.y=n+S*r,I.x=-S*o,I.y=S*(r+o),y=v.x+"|"+v.y,m=I.x+"|"+I.y,R(L,l,y,m);if(u==="O")for(let S=1;S<a;S++)I.x=-S*o,I.y=S*(r+o),p.x=S*r,p.y=S*o,y=I.x+"|"+I.y,m=p.x+"|"+p.y,R(L,l,y,m);if(l=this.IDATA.edgematch[L][2],u=this.IDATA.edgematch[L][3],u&&u==="A")for(let S=1;S<a;S++)p.x=S*r,p.y=S*o,v.x=s-(a-S)*(r+o),v.y=n+(a-S)*r,y=p.x+"|"+p.y,m=v.x+"|"+v.y,R(L,l,y,m);for(let S=0;S<this.vertices.length;S++)y=this.vertices[S].x+"|"+this.vertices[S].y,A=L+"|"+y,A in e||(e[A]=t++,T[y][0]>2?P[e[A]]=[-T[y][0],T[y][1],e[A]]:P[e[A]]=[C[T[y][0]],T[y][1],e[A]])}this.closestTo=P,this.vecToidx=e}calcCoeffs(){const t=this.m,e=this.n,s=Math.sqrt(3)/3,n=t*t+e*e+t*e;this.coau=(t+e)/n,this.cobu=-e/n,this.coav=-s*(t-e)/n,this.cobv=s*(2*t+e)/n}createInnerFacets(){const t=this.m,e=this.n;for(let s=0;s<e+t+1;s++)for(let n=this.min[s];n<this.max[s]+1;n++)n<this.max[s]&&n<this.max[s+1]+1&&this.innerFacets.push(["|"+n+"|"+s,"|"+n+"|"+(s+1),"|"+(n+1)+"|"+s]),s>0&&n<this.max[s-1]&&n+1<this.max[s]+1&&this.innerFacets.push(["|"+n+"|"+s,"|"+(n+1)+"|"+s,"|"+(n+1)+"|"+(s-1)])}edgeVecsABOB(){const t=this.m,e=this.n,s=new J(-e,t+e);for(let n=1;n<t+e;n++){const a=new J(this.min[n],n),r=new J(this.min[n-1],n-1),o=new J(this.min[n+1],n+1),l=a.clone(),u=r.clone(),d=o.clone();l.rotate60About(s),u.rotate60About(s),d.rotate60About(s);const h=new J(this.max[l.y],l.y),c=new J(this.max[l.y-1],l.y-1),x=new J(this.max[l.y-1]-1,l.y-1);(l.x!==h.x||l.y!==h.y)&&(l.x!==c.x?(this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([a,c,x]),this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([a,x,h])):l.y===d.y?(this.vertexTypes.push([1,1,0]),this.isoVecsABOB.push([a,r,c]),this.vertexTypes.push([1,0,1]),this.isoVecsABOB.push([a,c,o])):(this.vertexTypes.push([1,1,0]),this.isoVecsABOB.push([a,r,c]),this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([a,c,h])))}}mapABOBtoOBOA(){const t=new J(0,0);for(let e=0;e<this.isoVecsABOB.length;e++){const s=[];for(let n=0;n<3;n++)t.x=this.isoVecsABOB[e][n].x,t.y=this.isoVecsABOB[e][n].y,this.vertexTypes[e][n]===0&&t.rotateNeg120(this.m,this.n),s.push(t.clone());this.isoVecsOBOA.push(s)}}mapABOBtoBAOA(){const t=new J(0,0);for(let e=0;e<this.isoVecsABOB.length;e++){const s=[];for(let n=0;n<3;n++)t.x=this.isoVecsABOB[e][n].x,t.y=this.isoVecsABOB[e][n].y,this.vertexTypes[e][n]===1&&t.rotate120(this.m,this.n),s.push(t.clone());this.isoVecsBAOA.push(s)}}MapToFace(t,e){const s=this.IDATA.face[t],n=s[2],a=s[1],r=s[0],o=F.FromArray(this.IDATA.vertex[n]),l=F.FromArray(this.IDATA.vertex[a]),u=F.FromArray(this.IDATA.vertex[r]),d=l.subtract(o),h=u.subtract(o),c=d.scale(this.coau).add(h.scale(this.cobu)),x=d.scale(this.coav).add(h.scale(this.cobv));let g,_;for(let p=0;p<this.cartesian.length;p++)_=c.scale(this.cartesian[p].x).add(x.scale(this.cartesian[p].y)).add(o),_.x,_.y,_.z,g=t+"|"+this.vertices[p].x+"|"+this.vertices[p].y,e.vertex[this.vecToidx[g]]=[_.x,_.y,_.z]}build(t,e){const s=[],n=J.Zero(),a=new J(t,e),r=new J(-e,t+e);s.push(n,a,r);for(let f=e;f<t+1;f++)for(let y=0;y<t+1-f;y++)s.push(new J(y,f));if(e>0){const f=Jt(t,e),y=t/f,m=e/f;
2for(let T=1;T<f;T++)s.push(new J(T*y,T*m)),s.push(new J(-T*m,T*(y+m))),s.push(new J(t-T*(y+m),e+T*y));const P=t/e;for(let T=1;T<e;T++)for(let R=0;R<T*P;R++)s.push(new J(R,T)),s.push(new J(R,T).rotate120(t,e)),s.push(new J(R,T).rotateNeg120(t,e))}s.sort((f,y)=>f.x-y.x),s.sort((f,y)=>f.y-y.y);const o=new Array(t+e+1),l=new Array(t+e+1);for(let f=0;f<o.length;f++)o[f]=1/0,l[f]=-1/0;let u,d;const h=s.length;for(let f=0;f<h;f++)d=s[f].x,u=s[f].y,o[u]=Math.min(d,o[u]),l[u]=Math.max(d,l[u]);const c=(f,y)=>{const m=f.clone();return y==="A"&&m.rotateNeg120(t,e),y==="B"&&m.rotate120(t,e),m.x<0?m.y:m.x+m.y},x=[],g=[],_=[],p=[],v={},I=[];let C=-1,A=-1;for(let f=0;f<h;f++)x[f]=s[f].toCartesianOrigin(new J(0,0),.5),g[f]=c(s[f],"O"),_[f]=c(s[f],"A"),p[f]=c(s[f],"B"),g[f]===_[f]&&_[f]===p[f]?(C=3,A=g[f]):g[f]===_[f]?(C=4,A=g[f]):_[f]===p[f]?(C=5,A=_[f]):p[f]===g[f]&&(C=6,A=g[f]),g[f]<_[f]&&g[f]<p[f]&&(C=2,A=g[f]),_[f]<g[f]&&_[f]<p[f]&&(C=1,A=_[f]),p[f]<_[f]&&p[f]<g[f]&&(C=0,A=p[f]),I.push([C,A,s[f].x,s[f].y]);I.sort((f,y)=>f[2]-y[2]),I.sort((f,y)=>f[3]-y[3]),I.sort((f,y)=>f[1]-y[1]),I.sort((f,y)=>f[0]-y[0]);for(let f=0;f<I.length;f++)v[I[f][2]+"|"+I[f][3]]=[I[f][0],I[f][1],f];return this.m=t,this.n=e,this.vertices=s,this.vertByDist=v,this.cartesian=x,this.min=o,this.max=l,this}}class Xt{constructor(t,e,s,n){this.name=t,this.category=e,this.vertex=s,this.face=n}}class Mt extends Xt{innerToData(t,e){for(let s=0;s<e.innerFacets.length;s++)this.face.push(e.innerFacets[s].map(n=>e.vecToidx[t+n]))}mapABOBtoDATA(t,e){const s=e.IDATA.edgematch[t][0];for(let n=0;n<e.isoVecsABOB.length;n++){const a=[];for(let r=0;r<3;r++)e.vertexTypes[n][r]===0?a.push(t+"|"+e.isoVecsABOB[n][r].x+"|"+e.isoVecsABOB[n][r].y):a.push(s+"|"+e.isoVecsABOB[n][r].x+"|"+e.isoVecsABOB[n][r].y);this.face.push([e.vecToidx[a[0]],e.vecToidx[a[1]],e.vecToidx[a[2]]])}}mapOBOAtoDATA(t,e){const s=e.IDATA.edgematch[t][0];for(let n=0;n<e.isoVecsOBOA.length;n++){const a=[];for(let r=0;r<3;r++)e.vertexTypes[n][r]===1?a.push(t+"|"+e.isoVecsOBOA[n][r].x+"|"+e.isoVecsOBOA[n][r].y):a.push(s+"|"+e.isoVecsOBOA[n][r].x+"|"+e.isoVecsOBOA[n][r].y);this.face.push([e.vecToidx[a[0]],e.vecToidx[a[1]],e.vecToidx[a[2]]])}}mapBAOAtoDATA(t,e){const s=e.IDATA.edgematch[t][2];for(let n=0;n<e.isoVecsBAOA.length;n++){const a=[];for(let r=0;r<3;r++)e.vertexTypes[n][r]===1?a.push(t+"|"+e.isoVecsBAOA[n][r].x+"|"+e.isoVecsBAOA[n][r].y):a.push(s+"|"+e.isoVecsBAOA[n][r].x+"|"+e.isoVecsBAOA[n][r].y);this.face.push([e.vecToidx[a[0]],e.vecToidx[a[1]],e.vecToidx[a[2]]])}}orderData(t){const e=[];for(let r=0;r<13;r++)e[r]=[];const s=t.closestTo;for(let r=0;r<s.length;r++)s[r][0]>-1?s[r][1]>0&&e[s[r][0]].push([r,s[r][1]]):e[12].push([r,s[r][0]]);const n=[];for(let r=0;r<12;r++)n[r]=r;let a=12;for(let r=0;r<12;r++){e[r].sort((o,l)=>o[1]-l[1]);for(let o=0;o<e[r].length;o++)n[e[r][o][0]]=a++}for(let r=0;r<e[12].length;r++)n[e[12][r][0]]=a++;for(let r=0;r<this.vertex.length;r++)this.vertex[r].push(n[r]);this.vertex.sort((r,o)=>r[3]-o[3]);for(let r=0;r<this.vertex.length;r++)this.vertex[r].pop();for(let r=0;r<this.face.length;r++)for(let o=0;o<this.face[r].length;o++)this.face[r][o]=n[this.face[r][o]];this.sharedNodes=e[12].length,this.poleNodes=this.vertex.length-this.sharedNodes}setOrder(t,e){const s=[],n=[];let a=e.pop();n.push(a);let r=this.face[a].indexOf(t);r=(r+2)%3;let o=this.face[a][r];s.push(o);let l=0;for(;e.length>0;)a=e[l],this.face[a].indexOf(o)>-1?(r=(this.face[a].indexOf(o)+1)%3,o=this.face[a][r],s.push(o),n.push(a),e.splice(l,1),l=0):l++;return this.adjacentFaces.push(s),n}toGoldbergPolyhedronData(){const t=new Xt("GeoDual","Goldberg",[],[]);t.name="GD dual";const e=this.vertex.length,s=new Array(e);for(let u=0;u<e;u++)s[u]=[];for(let u=0;u<this.face.length;u++)for(let d=0;d<3;d++)s[this.face[u][d]].push(u);let n,a,r,o,l;this.adjacentFaces=[];for(let u=0;u<s.length;u++){t.face[u]=this.setOrder(u,s[u].concat([]));for(const d of s[u]){n=0,a=0,r=0,o=this.face[d];for(let h=0;h<3;h++)l=this.vertex[o[h]],n+=l[0],a+=l[1],r+=l[2];t.vertex[d]=[n/3,a/3,r/3]}}return t}static BuildGeodesicData(t){const e=new Mt("Geodesic-m-n","Geodesic",[[0,et,-1],[-et,1,0],[-1,0,-et],[1,0,-et],[et,1,0],[0,et,1],[
2-1,0,et],[-et,-1,0],[0,-et,-1],[et,-1,0],[1,0,et],[0,-et,1]],[]);t.setIndices(),t.calcCoeffs(),t.createInnerFacets(),t.edgeVecsABOB(),t.mapABOBtoOBOA(),t.mapABOBtoBAOA();for(let n=0;n<t.IDATA.face.length;n++)t.MapToFace(n,e),e.innerToData(n,t),t.IDATA.edgematch[n][1]==="B"&&e.mapABOBtoDATA(n,t),t.IDATA.edgematch[n][1]==="O"&&e.mapOBOAtoDATA(n,t),t.IDATA.edgematch[n][3]==="A"&&e.mapBAOAtoDATA(n,t);e.orderData(t);const s=1;return e.vertex=e.vertex.map(function(n){const a=n[0],r=n[1],o=n[2],l=Math.sqrt(a*a+r*r+o*o);return n[0]*=s/l,n[1]*=s/l,n[2]*=s/l,n}),e}}function js(i,t,e=null){let s=t.m||1;s!==Math.floor(s)&&(s=Math.floor(s),ct.Warn("m not an integer only floor(m) used"));let n=t.n||0;if(n!==Math.floor(n)&&(n=Math.floor(n),ct.Warn("n not an integer only floor(n) used")),n>s){const u=n;n=s,s=u,ct.Warn("n > m therefore m and n swapped")}const a=new ds;a.build(s,n);const o={custom:Mt.BuildGeodesicData(a),size:t.size,sizeX:t.sizeX,sizeY:t.sizeY,sizeZ:t.sizeZ,faceUV:t.faceUV,faceColors:t.faceColors,flat:t.flat,updatable:t.updatable,sideOrientation:t.sideOrientation,frontUVs:t.frontUVs,backUVs:t.backUVs};return kt(i,o,e)}class Kt extends O{constructor(){super(...arguments),this.goldbergData={faceColors:[],faceCenters:[],faceZaxis:[],faceXaxis:[],faceYaxis:[],nbSharedFaces:0,nbUnsharedFaces:0,nbFaces:0,nbFacesAtPole:0,adjacentFaces:[]}}relatedGoldbergFace(t,e){return e===void 0?(t>this.goldbergData.nbUnsharedFaces-1&&(ct.Warn("Maximum number of unshared faces used"),t=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+t):(t>11&&(ct.Warn("Last pole used"),t=11),e>this.goldbergData.nbFacesAtPole-1&&(ct.Warn("Maximum number of faces at a pole used"),e=this.goldbergData.nbFacesAtPole-1),12+t*this.goldbergData.nbFacesAtPole+e)}_changeGoldbergFaceColors(t){for(let s=0;s<t.length;s++){const n=t[s][0],a=t[s][1],r=t[s][2];for(let o=n;o<a+1;o++)this.goldbergData.faceColors[o]=r}const e=[];for(let s=0;s<12;s++)for(let n=0;n<5;n++)e.push(this.goldbergData.faceColors[s].r,this.goldbergData.faceColors[s].g,this.goldbergData.faceColors[s].b,this.goldbergData.faceColors[s].a);for(let s=12;s<this.goldbergData.faceColors.length;s++)for(let n=0;n<6;n++)e.push(this.goldbergData.faceColors[s].r,this.goldbergData.faceColors[s].g,this.goldbergData.faceColors[s].b,this.goldbergData.faceColors[s].a);return e}setGoldbergFaceColors(t){const e=this._changeGoldbergFaceColors(t);this.setVerticesData(Q.ColorKind,e)}updateGoldbergFaceColors(t){const e=this._changeGoldbergFaceColors(t);this.updateVerticesData(Q.ColorKind,e)}_changeGoldbergFaceUVs(t){const e=this.getVerticesData(Q.UVKind);for(let s=0;s<t.length;s++){const n=t[s][0],a=t[s][1],r=t[s][2],o=t[s][3],l=t[s][4],u=[],d=[];let h,c;for(let x=0;x<5;x++)h=r.x+o*Math.cos(l+x*Math.PI/2.5),c=r.y+o*Math.sin(l+x*Math.PI/2.5),h<0&&(h=0),h>1&&(h=1),u.push(h,c);for(let x=0;x<6;x++)h=r.x+o*Math.cos(l+x*Math.PI/3),c=r.y+o*Math.sin(l+x*Math.PI/3),h<0&&(h=0),h>1&&(h=1),d.push(h,c);for(let x=n;x<Math.min(12,a+1);x++)for(let g=0;g<5;g++)e[10*x+2*g]=u[2*g],e[10*x+2*g+1]=u[2*g+1];for(let x=Math.max(12,n);x<a+1;x++)for(let g=0;g<6;g++)e[12*x-24+2*g]=d[2*g],e[12*x-23+2*g]=d[2*g+1]}return e}setGoldbergFaceUVs(t){const e=this._changeGoldbergFaceUVs(t);this.setVerticesData(Q.UVKind,e)}updateGoldbergFaceUVs(t){const e=this._changeGoldbergFaceUVs(t);this.updateVerticesData(Q.UVKind,e)}placeOnGoldbergFaceAt(t,e,s){const n=F.RotationFromAxis(this.goldbergData.faceXaxis[e],this.goldbergData.faceYaxis[e],this.goldbergData.faceZaxis[e]);t.rotation=n,t.position=this.goldbergData.faceCenters[e].add(this.goldbergData.faceXaxis[e].scale(s.x)).add(this.goldbergData.faceYaxis[e].scale(s.y)).add(this.goldbergData.faceZaxis[e].scale(s.z))}serialize(t){super.serialize(t),t.type="GoldbergMesh";const e={};if(e.adjacentFaces=this.goldbergData.adjacentFaces,e.nbSharedFaces=this.goldbergData.nbSharedFaces,e.nbUnsharedFaces=this.goldbergData.nbUnsharedFaces,e.nbFaces=this.goldbergData.nbFaces,e.nbFacesAtPole=this.goldbergData.nbFacesAtPole,this.goldbergData.faceColors){e.faceColors=[];for(const s of this.goldbergData.faceColors)e.faceColors.push(s.asArray())}if(this.goldbergData.faceCenters){e.faceCenters=[];for(const s of this.goldbergData.faceCenters)e.faceCenters.push(s.asArray())}if(this.goldbergData.faceZaxis){e.faceZaxis=[];for(const s of this.goldbergData.faceZaxis)e.faceZaxis.push(s.asArray())}if(this.goldbergData.faceYaxis){e.faceYaxis=[];for(const s of this.goldbergData.faceYaxis)e.faceYaxis.push(s.asArray())}if(this.goldbergData.faceXaxis){e.faceXaxis=[];for(const s of this.goldbergData.faceXaxis)e.faceXaxis.push(s.asArray())}t.goldbergData=e}static Parse(t,e){const s=t.goldbergData;s.faceColors=s.faceColors.map(a=>pt.FromArray(a)),s.faceCenters=s.faceCenters.map(a=>F.FromArray(a)),s.faceZaxis=s.faceZaxis.map(a=>F.FromArray(a)),s.faceXaxis=s.faceXaxis.map(a=>F.FromArray(a)),s.faceYaxis=s.faceYaxis.map(a=>F.FromArray(a));const n=new Kt(t.name,e);return n.goldbergData=s,n}}function $s(i,t){const e=i.size,s=i.sizeX||e||1,n=i.sizeY||e||1,a=i.sizeZ||e||1,r
2=i.sideOrientation===0?0:i.sideOrientation||Z.DEFAULTSIDE,o=[],l=[],u=[],d=[];let h=1/0,c=-1/0,x=1/0,g=-1/0;for(let v=0;v<t.vertex.length;v++)h=Math.min(h,t.vertex[v][0]*s),c=Math.max(c,t.vertex[v][0]*s),x=Math.min(x,t.vertex[v][1]*n),g=Math.max(g,t.vertex[v][1]*n);let _=0;for(let v=0;v<t.face.length;v++){const I=t.face[v],C=F.FromArray(t.vertex[I[0]]),A=F.FromArray(t.vertex[I[2]]),f=F.FromArray(t.vertex[I[1]]),y=A.subtract(C),m=f.subtract(C),P=F.Cross(m,y).normalize();for(let T=0;T<I.length;T++){u.push(P.x,P.y,P.z);const R=t.vertex[I[T]];o.push(R[0]*s,R[1]*n,R[2]*a);const L=(R[1]*n-x)/(g-x);d.push((R[0]*s-h)/(c-h),L)}for(let T=0;T<I.length-2;T++)l.push(_,_+T+2,_+T+1);_+=I.length}Z._ComputeSides(r,o,l,u,d);const p=new Z;return p.positions=o,p.indices=l,p.normals=u,p.uvs=d,p}function Js(i,t,e=null){const s=t.size,n=t.sizeX||s||1,a=t.sizeY||s||1,r=t.sizeZ||s||1;let o=t.m||1;o!==Math.floor(o)&&(o=Math.floor(o),ct.Warn("m not an integer only floor(m) used"));let l=t.n||0;if(l!==Math.floor(l)&&(l=Math.floor(l),ct.Warn("n not an integer only floor(n) used")),l>o){const g=l;l=o,o=g,ct.Warn("n > m therefore m and n swapped")}const u=new ds;u.build(o,l);const d=Mt.BuildGeodesicData(u),h=d.toGoldbergPolyhedronData(),c=new Kt(i,e);t.sideOrientation=O._GetDefaultSideOrientation(t.sideOrientation),c._originalBuilderSideOrientation=t.sideOrientation,$s(t,h).applyToMesh(c,t.updatable),c.goldbergData.nbSharedFaces=d.sharedNodes,c.goldbergData.nbUnsharedFaces=d.poleNodes,c.goldbergData.adjacentFaces=d.adjacentFaces,c.goldbergData.nbFaces=c.goldbergData.nbSharedFaces+c.goldbergData.nbUnsharedFaces,c.goldbergData.nbFacesAtPole=(c.goldbergData.nbUnsharedFaces-12)/12;for(let g=0;g<d.vertex.length;g++)c.goldbergData.faceCenters.push(F.FromArray(d.vertex[g])),c.goldbergData.faceCenters[g].x*=n,c.goldbergData.faceCenters[g].y*=a,c.goldbergData.faceCenters[g].z*=r,c.goldbergData.faceColors.push(new pt(1,1,1,1));for(let g=0;g<h.face.length;g++){const _=h.face[g],p=F.FromArray(h.vertex[_[0]]),v=F.FromArray(h.vertex[_[2]]),I=F.FromArray(h.vertex[_[1]]),C=v.subtract(p),A=I.subtract(p),f=F.Cross(A,C).normalize(),y=F.Cross(A,f).normalize();c.goldbergData.faceXaxis.push(A.normalize()),c.goldbergData.faceYaxis.push(f),c.goldbergData.faceZaxis.push(y)}return c}class tn{constructor(t){this._paths=[],this._tempPaths=[],this._holes=[],this._resolution=t}moveTo(t,e){this._currentPath=new Rt(t,e),this._tempPaths.push(this._currentPath)}lineTo(t,e){this._currentPath.addLineTo(t,e)}quadraticCurveTo(t,e,s,n){this._currentPath.addQuadraticCurveTo(t,e,s,n,this._resolution)}bezierCurveTo(t,e,s,n,a,r){this._currentPath.addBezierCurveTo(t,e,s,n,a,r,this._resolution)}extractHoles(){for(const t of this._tempPaths)t.area()>0?this._holes.push(t):this._paths.push(t);if(!this._paths.length&&this._holes.length){const t=this._holes;this._holes=this._paths,this._paths=t}this._tempPaths.length=0}get paths(){return this._paths}get holes(){return this._holes}}function en(i,t,e,s,n,a){const r=a.glyphs[i]||a.glyphs["?"];if(!r)return null;const o=new tn(n);if(r.o){const l=r.o.split(" ");for(let u=0,d=l.length;u<d;)switch(l[u++]){case"m":{const c=parseInt(l[u++])*t+e,x=parseInt(l[u++])*t+s;o.moveTo(c,x);break}case"l":{const c=parseInt(l[u++])*t+e,x=parseInt(l[u++])*t+s;o.lineTo(c,x);break}case"q":{const c=parseInt(l[u++])*t+e,x=parseInt(l[u++])*t+s,g=parseInt(l[u++])*t+e,_=parseInt(l[u++])*t+s;o.quadraticCurveTo(g,_,c,x);break}case"b":{const c=parseInt(l[u++])*t+e,x=parseInt(l[u++])*t+s,g=parseInt(l[u++])*t+e,_=parseInt(l[u++])*t+s,p=parseInt(l[u++])*t+e,v=parseInt(l[u++])*t+s;o.bezierCurveTo(g,_,p,v,c,x);break}}}return o.extractHoles(),{offsetX:r.ha*t,shapePath:o}}function sn(i,t,e,s){const n=Array.from(i),a=t/s.resolution,r=(s.boundingBox.yMax-s.boundingBox.yMin+s.underlineThickness)*a,o=[];let l=0,u=0;for(let d=0;d<n.length;d++){const h=n[d];if(h===` 3`)l=0,u-=r;else{const c=en(h,a,l,u,e,s);c&&(l+=c.offsetX,o.push(c.shapePath))}}return o}function nn(i,t,e,s={size:50,resolution:8,depth:1},n=null,a=earcut){const r=sn(t,s.size||50,s.resolution||8,e),o=[];let l=0;for(const d of r){if(!d.paths.length)continue;const h=d.holes.slice();for(const c of d.paths){const x=[],g=[],_=c.getPoints();for(const I of _)g.push(new F(I.x,0,I.y));const p=h.slice();for(const I of p){const C=I.getPoints();let A=!1;for(const y of C)if(c.isPointInside(y)){A=!0;break}if(!A)continue;const f=[];for(const y of C)f.push(new F(y.x,0,y.y));x.push(f),h.splice(h.indexOf(I),1)}if(!x.length&&h.length)for(const I of h){const C=I.getPoints(),A=[];
3for(const f of C)A.push(new F(f.x,0,f.y));x.push(A)}const v=Yt(i,{shape:g,holes:x.length?x:void 0,depth:s.depth||1,faceUV:s.faceUV||s.perLetterFaceUV?.(l),faceColors:s.faceColors||s.perLetterFaceColors?.(l),sideOrientation:O._GetDefaultSideOrientation(s.sideOrientation||O.DOUBLESIDE)},n,a);o.push(v),l++}}const u=O.MergeMeshes(o,!0,!0);if(u){const d=u.getBoundingInfo().boundingBox;u.position.x+=-(d.minimumWorld.x+d.maximumWorld.x)/2,u.position.y+=-(d.minimumWorld.y+d.maximumWorld.y)/2,u.position.z+=-(d.minimumWorld.z+d.maximumWorld.z)/2+d.extendSize.z,u.name=i;const h=new ps("pivot",n);h.rotation.x=-Math.PI/2,u.parent=h,u.bakeCurrentTransformIntoVertices(),u.parent=null,h.dispose()}return u}const bn={CreateBox:ze,CreateTiledBox:Ts,CreateSphere:Ne,CreateDisc:Te,CreateIcoSphere:cs,CreateRibbon:vt,CreateCylinder:We,CreateTorus:Xe,CreateTorusKnot:Ge,CreateLineSystem:qe,CreateLines:Qe,CreateDashedLines:je,ExtrudeShape:Je,ExtrudeShapeCustom:ts,CreateLathe:ss,CreateTiledPlane:Is,CreatePlane:is,CreateGround:Ve,CreateTiledGround:Re,CreateGroundFromHeightMap:Be,CreatePolygon:Gt,ExtrudePolygon:Yt,CreateTube:as,CreatePolyhedron:kt,CreateGeodesic:js,CreateGoldberg:Js,CreateDecal:ls,CreateCapsule:us,CreateText:nn};As();Os();ws();Cs();Ps();Fs();Vs();Rs();Bs();Ls();Es();Ss();Ns();Le();Ds();Us();Ws();Zs();qs();Qs();export{bn as MeshBuilder};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.