three-rwx-loader
Version:
three.js RWX (AW) loader
2 lines (1 loc) • 36.3 kB
JavaScript
import{FileLoader as e,Loader as t,Mesh as r,Vector2 as a,Vector3 as i,Matrix4 as s,Vector4 as n,MathUtils as l,MeshPhongMaterial as u,MeshBasicMaterial as o,BufferGeometry as c,Quaternion as h,Plane as f,TextureLoader as m,NearestFilter as p,LinearMipmapNearestFilter as g,RepeatWrapping as x,ClampToEdgeWrapping as d,MirroredRepeatWrapping as M,LinearSRGBColorSpace as R,SRGBColorSpace as w,FrontSide as T,DoubleSide as y,Group as F,BufferAttribute as B,EdgesGeometry as k,LineSegments as V,LineBasicMaterial as I}from"three";import{Earcut as b}from"three/src/extras/Earcut.js";import{SweepContext as A}from"poly2tri";const C={FACET:1,VERTEX:2},v={POINTCLOUD:1,WIREFRAME:2,SOLID:3},E={LIT:1,FORESHORTEN:2,FILTER:3},W={NONE:0,NULL:1,DOUBLE:2},S={WRAP:0,MIRROR:1,CLAMP:2},G=100,$=200,D=.2,X=[.69,0,0],L=/^https?:\/\/.*$/i,U=/^(.*)(\.[^\\]+)$/i,N=/^\.(tiff|png|webp|gif)$/i,P="rwx-first-clump",H="rwx-scale-group";function z(e,t,r,a=R,i=x,s=!0){return new Promise((n=>{r.load(e,(e=>{e.image.height!==e.image.width&&e.image.height%e.image.width==0&&(t.userData.rwx.maskAnimation={yTiles:e.image.height/e.image.width,yHeight:e.image.width/e.image.height,step:0},e.offset.y=1-t.userData.rwx.maskAnimation.yHeight,e.repeat.set(1,t.userData.rwx.maskAnimation.yHeight)),e.wrapS=i,e.wrapT=i,e.colorSpace=a,s||(e.minFilter=g,e.magFilter=p),t.alphaMap=e,t.needsUpdate=!0,n(e)}))}))}function O(t,r,a,i=".jpg",s=null,n=".zip",l=null,u=null,o=null,c=[],h=w,f=x,d=.2,M=!0,T=!0){let y=new m,F=null;const B=L.exec(a),k=U.exec(a);if(B){if(!T)return void console.error(`Full URLs not allowed for texture and mask paths, skipping ${a}`);F=a}else k&&(i=""),F=r+"/"+a+i;if(k&&N.test(k[2])&&(t.alphaTest=d,t.transparent=!0),c.push(new Promise(((e,r)=>{y.load(F,(r=>{r.wrapS=f,r.wrapT=f,r.colorSpace=h,t.map=r,t.needsUpdate=!0,M||(r.minFilter=g,r.magFilter=p),r.image.height!==r.image.width&&r.image.height%r.image.width==0&&(t.userData.rwx.animation={yTiles:r.image.height/r.image.width,yHeight:r.image.width/r.image.height,step:0},r.offset.y=1-t.userData.rwx.animation.yHeight,r.repeat.set(1,t.userData.rwx.animation.yHeight)),e(r)}),null,(e=>{r(e)}))}))),null!=s){t.alphaTest=d,t.transparent=!0;const a=L.exec(s),i=U.exec(s);i&&(n=i[2]);let l=i?i[1]:s;if(a){if(!T)return void console.error(`Full URLs not allowed for texture and mask paths, skipping ${s}`);l=l.slice(l.lastIndexOf("/")+1)}if(".zip"==n.toLowerCase()&&null!=o){const i=a?s:r+"/"+l+n;c.push(new Promise(((r,a)=>{const s=new e;s.setResponseType("arraybuffer"),s.load(i,(e=>{const s=o.unzipSync(new Uint8Array(e));let n=null;for(const e of Object.keys(s))if(e.toLowerCase()==l.toLowerCase()+".bmp"){n=e;break}n||a(new Error(`No .bmp file candidate found within '${i}'`));const u=s[n];let c="data:image/bmp;base64,";let h="";for(let e=0;e<u.length;e+=4056)h=h.concat(String.fromCharCode.apply(null,new Uint16Array(u.slice(e,e+4056))));c=c.concat(btoa(h)),z(c,t,y,R,f,M).then((e=>{r(e)})).catch((e=>{a(e)}))}),null,(e=>{a(e)}))})))}else if(".zip"!=n){const e=a?s:r+"/"+l+n;c.push(z(e,t,y,R,f,M))}}if(null!=u){const e=L.exec(u)?u:r+"/"+u+i;c.push(new Promise(((r,a)=>{y.load(e,(e=>{e.wrapS=f,e.wrapT=f,t.normalMap=e,t.needsUpdate=!0,r(e)}),null,a)})))}if(null!=l){const e=L.exec(l)?l:r+"/"+l+i;c.push(new Promise(((r,a)=>{y.load(e,(e=>{e.wrapS=f,e.wrapT=f,t.specularMap=e,t.needsUpdate=!0,r(e)}),null,a)})))}}function _(e,t,r=".jpg",a=".zip",i=null,s=!1,n=w,l=.2,c=!0){let h={name:e.getMatSignature()};e.materialmode==W.NULL?h.side=T:e.materialmode==W.DOUBLE?h.side=y:e.materialmode==W.NONE&&(h.visible=!1),e.opacity<1&&(h.transparent=!0),e.geometrysampling<v.SOLID?h.wireframe=!0:h.wireframe=!1;const f=e.texturemodes.includes(E.FILTER);let m=d;e.textureaddressmode==S.WRAP?m=x:e.textureaddressmode==S.MIRROR&&(m=M);const p=e.texturemodes.includes(E.LIT)?e.surface:X;if(!s){e.lightsampling==C.FACET?h.flatShading=!0:e.lightsampling==C.VERTEX&&(h.flatShading=!1);const t=Math.trunc(.1*p[2]*255);h.specular=(t<<16)+(t<<8)+t;const r=Math.trunc(p[1]);h.emissive=(r<<16)+(r<<8)+r,h.shininess=30}h.opacity=e.opacity;let g=s?new o(h):new u(h);g.userData.rwx={material:e.clone()};let R=[];g.userData.collision=e.collision,g.userData.ratio=e.ratio;const F=Math.max(...p);return null==e.texture?(g.color.set(e.getColorHexValue()),g.color.multiplyScalar(F)):(g.color.set(e.tint?e.getColorHexValue():16777215),g.color.multiplyScalar(F),O(g,t,e.texture,r,e.mask,a,e.specular,e.normal,i,R,n,m,l,f,c)),g.needsUpdate=!0,{threeMat:g,loadingPromises:R}}function q(e){e.currentBufferFaceCount>0&&Z(e),e.currentBufferGeometry=new c,e.currentBufferVertices=[],e.currentBufferUVs=[],e.currentBufferFaces=[],e.currentBufferFaceCount=0,e.currentBufferGroupFirstFaceID=0,e.previousMaterialID=null}function j(e){if(e.currentBufferFaceCount>0&&Z(e),e.currentBufferFaces.length>0){e.currentBufferGeometry.setAttribute("position",new B(new Float32Array(e.currentBufferVertices),3)),e.currentBufferGeometry.setAttribute("uv",new B(new Float32Array(e.currentBufferUVs),2)),e.currentBufferGeometry.setIndex(e.currentBufferFaces),e.currentBufferGeometry.uvsNeedUpdate=!0,e.currentBufferGeometry.computeVertexNormals(),e.loadingPromises=e.loadingPromises.concat(e.materialTracker.getCommitedMaterialList().map((e=>e.loadingPromises)));const t=new r(e.currentBufferGeometry,e.materialTracker.getCommitedMaterialList().map((e=>e.threeMat)));t.userData.taggedMaterials=e.taggedMaterials,e.currentGroup.add(t),me(e),ge(e),e.taggedMaterials={}}}function Z(e){e.currentBufferFaceCount&&e.currentBufferGeometry.addGroup(e.currentBufferGroupFirstFaceID,3*e.currentBufferFaceCount,e.previousMaterialID),e.materialTracker.commitMaterials(),e.previousMaterialID=e.materialTracker.getCurrentMaterialID(),e.currentBufferGroupFirstFaceID=e.currentBufferGroupFirstFaceID+3*e.currentBufferFaceCount,e.currentBufferFaceCount=0}function Q(e,t,r,a){e.materialTracker.getCurrentMaterialID()!==e.previousMaterialID&&Z(e),e.currentBufferFaceCount++,e.currentBufferFaces.push(t,r,a)}function Y(e,t,r,a,s){if(e.materialTracker.getCurrentMaterialID()!==e.previousMaterialID&&Z(e),e.materialTracker.currentRWXMaterial.geometrysampling==v.WIREFRAME){const i=new c;i.setAttribute("position",new B(new Float32Array([e.currentBufferVertices[3*t],e.currentBufferVertices[3*t+1],e.currentBufferVertices[3*t+2],e.currentBufferVertices[3*r],e.currentBufferVertices[3*r+1],e.currentBufferVertices[3*r+2],e.currentBufferVertices[3*a],e.currentBufferVertices[3*a+1],e.currentBufferVertices[3*a+2],e.currentBufferVertices[3*t],e.currentBufferVertices[3*t+1],e.currentBufferVertices[3*t+2],e.currentBufferVertices[3*a],e.currentBufferVertices[3*a+1],e.currentBufferVertices[3*a+2],e.currentBufferVertices[3*s],e.currentBufferVertices[3*s+1],e.currentBufferVertices[3*s+2]]),3)),i.computeVertexNormals();const n=new V(new k(i),new I({color:e.materialTracker.currentRWXMaterial.getColorHexValue()}));e.currentGroup.add(n)}else{const n=new i(e.currentBufferVertices[3*t],e.currentBufferVertices[3*t+1],e.currentBufferVertices[3*t+2]),l=new i(e.currentBufferVertices[3*r],e.currentBufferVertices[3*r+1],e.currentBufferVertices[3*r+2]),u=new i(e.currentBufferVertices[3*a],e.currentBufferVertices[3*a+1],e.currentBufferVertices[3*a+2]),o=new i(e.currentBufferVertices[3*s],e.currentBufferVertices[3*s+1],e.currentBufferVertices[3*s+2]),h=n.distanceToSquared(u)>l.distanceToSquared(o);e.currentBufferFaceCount+=2;const f=h?[t,r,a,t,a,s]:[t,r,s,r,a,s];if(e.correctInvalidNormals&&function(e,t){if(e.currentBufferFaces.length>0){const r=new c,a=[];if(a.push(...e.currentBufferFaces,...t),r.setAttribute("position",new B(new Float32Array(e.currentBufferVertices),3)),r.setIndex(a),r.computeVertexNormals(),r.computeVertexNormals(),r.hasAttribute("normal")){const e=r.getAttribute("normal").array,a=new i;for(let r=0;r<e.length;r+=3)if(t.includes(r/3)&&(a.set(e[r],e[r+1],e[r+2]),0==a.lengthSq()))return!0}}return!1}(e,f)&&e.materialTracker.currentRWXMaterial!=C.FACET){const i=[];for(const n of[t,r,a,s])i.push(e.currentBufferVertices.length/3),e.currentBufferVertices.push(e.currentBufferVertices[3*n],e.currentBufferVertices[3*n+1],e.currentBufferVertices[3*n+2]),e.currentBufferUVs.push(e.currentBufferUVs[2*n],e.currentBufferUVs[2*n+1]);h?e.currentBufferFaces.push(i[0],i[1],i[2],i[0],i[2],i[3]):e.currentBufferFaces.push(i[0],i[1],i[3],i[1],i[2],i[3]),e.currentBufferGeometry.computeVertexNormals()}else e.currentBufferFaces.push(...f)}}function J(e,t){const r=e.materialTracker.currentRWXMaterial.lightsampling;e.materialTracker.currentRWXMaterial.lightsampling=C.FACET,e.materialTracker.getCurrentMaterialID()!==e.previousMaterialID&&Z(e);const a=function(e,t,r,a,n=!1,l=!1){const u=new i;let o=new s;const c=new f,m=new h,p=new i,g=new i,x=new i(1,0,0),d=new i(0,0,1);let M=new i;const R=[];u.setScalar(0);let w=r.length;for(let t=0;t<w;t++)u.add(new i(e[3*r[t]],e[3*r[t]+1],e[3*r[t]+2])),R.push(r[t]);u.multiplyScalar(1/w);let T=new i(0,0,0);for(let t=0;t<w;t++){const a=new i(e[3*r[t]],e[3*r[t]+1],e[3*r[t]+2]);let s=new i(e[3*r[(t+1)%w]],e[3*r[(t+1)%w]+1],e[3*r[(t+1)%w]+2]);T.x+=(a.y-s.y)*(a.z+s.z),T.y+=(a.z-s.z)*(a.x+s.x),T.z+=(a.x-s.x)*(a.y+s.y)}T.normalize();const y=new i(e[3*r[0]],e[3*r[0]+1],e[3*r[0]+2]);c.setFromNormalAndCoplanarPoint(T,y);let F=c.normal;m.setFromUnitVectors(d,F),g.copy(x).applyQuaternion(m),p.crossVectors(g,F),p.normalize(),o.makeBasis(g,p,F),o.setPosition(u);let B=[],k=[];for(let t=0;t<w;t++){const a=new i(e[3*r[t]],e[3*r[t]+1],e[3*r[t]+2]);M.subVectors(a,u),n||B.push({x:M.dot(g),y:M.dot(p),id:R[t]}),k.push(M.dot(g),M.dot(p))}let V=[];if(!n)try{const e=new A(B);e.triangulate();const t=e.getTriangles();for(const e of t)V.push(e.getPoint(0).id,e.getPoint(1).id,e.getPoint(2).id);return V}catch(e){l&&console.warn("Could not use poly2tri here for "+a+" (falling back to Earcut): "+e)}return V=b.triangulate(k,null,2).map((e=>R[e])),V}(e.currentBufferVertices,e.currentBufferUVs,t,e.objectName,e.forceEarcut,e.verboseWarning);for(let t=0;t<a.length;t+=3){const r=a[t],i=a[t+1],s=a[t+2];e.currentBufferFaceCount++,e.currentBufferFaces.push(r,i,s)}e.materialTracker.currentRWXMaterial.lightsampling=r}function K(e,t,r,a=null){if(r<3)throw new Error("Need at least 3 sides to make a vertex circle");let s=[],n=[],l=new i;const u=2*Math.PI/r,o=new i(0,1,0);l.add(new i(t,0,0));for(let t=0;t<r;t++)s.push(l.x,l.y+e,l.z),l.applyAxisAngle(o,u),null===a?n.push((Math.cos(u*t)+1)/2,(Math.sin(u*t)+1)/2):n.push(1/r*t,a);return[s,n]}function ee(e,t,a,i){let s=new c,n=e.materialTracker.getCurrentMaterial().threeMat;void 0===n.flatShading||n.flatShading||(n=n.clone(),n.flatShading=!0);const l=[-t/2,a/2,-i/2,t/2,a/2,-i/2,t/2,a/2,i/2,-t/2,a/2,i/2,-t/2,-a/2,-i/2,t/2,-a/2,-i/2,t/2,-a/2,i/2,-t/2,-a/2,i/2];s.setAttribute("position",new B(new Float32Array(l),3)),s.setAttribute("uv",new B(new Float32Array([0,0,1,0,1,1,0,1,1,1,0,1,0,0,1,0]),2)),s.setIndex([0,3,1,1,3,2,0,4,3,3,4,7,3,6,2,3,7,6,6,7,5,5,7,4,1,5,0,0,5,4,2,5,1,6,5,2]),s.addGroup(0,36,0),s.uvsNeedUpdate=!0,s.computeVertexNormals();let u=new r(s,[n]);u.userData.taggedMaterials={},u.applyMatrix4(e.currentTransform),e.currentGroup.add(u)}function te(e,t,a,i){if(i<3)return;let s=new c,[n,l]=K(0,a,i);n.push(0,t,0),l.push(.5,.5),s.setAttribute("position",new B(new Float32Array(n),3)),s.setAttribute("uv",new B(new Float32Array(l),2));let u=[];for(let e=0;e<i;e++)u.push(i,e,(e+1)%i);s.setIndex(u),s.addGroup(0,3*i,0),s.uvsNeedUpdate=!0,s.computeVertexNormals();let o=new r(s,[e.materialTracker.getCurrentMaterial().threeMat]);o.userData.taggedMaterials={},o.applyMatrix4(e.currentTransform),e.currentGroup.add(o)}function re(e,t,a,i,s){if(s<3)return;let[n,l]=K(0,a,s,1);const u=K(t,i,s,0);n.push(...u[0]),l.push(...u[1]);let o=new c;o.setAttribute("position",new B(new Float32Array(n),3)),o.setAttribute("uv",new B(new Float32Array(l),2));const h=s;let f=[];for(let e=0;e<s;e++)f.push(h+e,e,(e+1)%s),f.push(h+e,(e+1)%s,h+(e+1)%s);o.setIndex(f),o.addGroup(0,6*s,0),o.uvsNeedUpdate=!0,o.computeVertexNormals();let m=new r(o,[e.materialTracker.getCurrentMaterial().threeMat]);m.userData.taggedMaterials={},m.applyMatrix4(e.currentTransform),e.currentGroup.add(m)}function ae(e,t,a,i){if(i<3)return;let s=new c,[n,l]=K(t,a,i);s.setAttribute("position",new B(new Float32Array(n),3)),s.setAttribute("uv",new B(new Float32Array(l),2));let u=[];for(let e=1;e<i;e++)u.push(0,e,(e+1)%i);s.setIndex(u),s.addGroup(0,3*i,0),s.uvsNeedUpdate=!0,s.computeVertexNormals();let o=new r(s,[e.materialTracker.getCurrentMaterial().threeMat]);o.applyMatrix4(e.currentTransform),o.userData.taggedMaterials={},e.currentGroup.add(o)}function ie(e,t,a){if(a<2)return;const i=4*a,s=a,n=Math.PI/(2*s);let[l,u]=K(0,t,i,1),o=0,h=0,f=[];for(let e=1;e<s;e++){h=o+i;const r=Math.sin(n*e),a=K(r*t,Math.cos(n*e)*t,i,r);l.push(...a[0]),u.push(...a[1]);for(let e=0;e<i;e++)f.push(h+e,o+e,o+(e+1)%i,h+e,o+(e+1)%i,h+(e+1)%i);o=h}l.push(0,t,0),u.push(.5,0);const m=l.length/3-1;for(let e=0;e<i;e++)f.push(m,o+e,o+(e+1)%i);let p=new c;p.setAttribute("position",new B(new Float32Array(l),3)),p.setAttribute("uv",new B(new Float32Array(u),2)),p.setIndex(f),p.addGroup(0,p.getIndex().count,0),p.uvsNeedUpdate=!0,p.computeVertexNormals();let g=new r(p,[e.materialTracker.getCurrentMaterial().threeMat]);g.userData.taggedMaterials={},g.applyMatrix4(e.currentTransform),e.currentGroup.add(g)}function se(e,t,a){if(a<2)return;const i=4*a,s=a,n=Math.PI/(2*s),l=[0,-t,0],u=[.5,0];let o=1-s;const h=Math.sin(n*o);let f=K(h*t,Math.cos(n*o)*t,i,h);l.push(...f[0]),u.push(...f[1]);let m=0,p=1;const g=[];for(let e=0;e<i;e++)g.push(m,p+(e+1)%i,p+e);for(m=p,o++;o<s;o++){p=m+i;const e=Math.sin(n*o);f=K(e*t,Math.cos(n*o)*t,i,e),l.push(...f[0]),u.push(...f[1]);for(let e=0;e<i;e++)g.push(p+e,m+e,m+(e+1)%i,p+e,m+(e+1)%i,p+(e+1)%i);m=p}l.push(0,t,0),u.push(.5,0),p+=i;for(let e=0;e<i;e++)g.push(p,m+e,m+(e+1)%i);let x=new c;x.setAttribute("position",new B(new Float32Array(l),3)),x.setAttribute("uv",new B(new Float32Array(u),2)),x.setIndex(g),x.addGroup(0,x.getIndex().count,0),x.uvsNeedUpdate=!0,x.computeVertexNormals();let d=new r(x,[e.materialTracker.getCurrentMaterial().threeMat]);d.userData.taggedMaterials={},d.applyMatrix4(e.currentTransform),e.currentGroup.add(d)}function ne(e){let t=new F;t.userData.rwx={},t.applyMatrix4(e.currentTransform),e.currentGroup.add(t),e.currentGroup=t,e.currentTransform=new s}function le(e){e.currentTransform=e.currentGroup.matrix.clone(),e.currentGroup=e.currentGroup.parent}function ue(e){e.materialStack.push(e.materialTracker.currentRWXMaterial),e.materialTracker.currentRWXMaterial=e.materialTracker.currentRWXMaterial.clone(),e.materialTracker.clearCurrentMaterialList(e.materialTracker.currentRWXMaterial)}function oe(e){e.materialTracker.currentRWXMaterial=e.materialStack.pop(),e.materialTracker.clearCurrentMaterialList(e.materialTracker.currentRWXMaterial)}function ce(e){e.transformSaves.push(e.currentTransform.clone())}function he(e){e.transformSaves.length>0?e.currentTransform=e.transformSaves.pop():e.currentTransform=new s}function fe(e,t){e.materialTracker.currentRWXMaterial.tag=t,void 0===e.taggedMaterials[t.toString()]&&(e.taggedMaterials[t.toString()]=[]),e.taggedMaterials[t.toString()].includes(e.materialTracker.getCurrentMaterialID())||e.taggedMaterials[t.toString()].push(e.materialTracker.getCurrentMaterialID())}function me(e){e.materialTracker.currentRWXMaterial.tag=0}function pe(e,t,r,s,n=null){const l=new i(e.currentBufferVertices[3*t],e.currentBufferVertices[3*t+1],e.currentBufferVertices[3*t+2]),u=new i(e.currentBufferVertices[3*r],e.currentBufferVertices[3*r+1],e.currentBufferVertices[3*r+2]),o=new i(e.currentBufferVertices[3*s],e.currentBufferVertices[3*s+1],e.currentBufferVertices[3*s+2]),c=new a(e.currentBufferUVs[2*t],e.currentBufferUVs[2*t+1]),h=new a(e.currentBufferUVs[2*r],e.currentBufferUVs[2*r+1]),f=new a(e.currentBufferUVs[2*s],e.currentBufferUVs[2*s+1]),m=Math.max(c.x,h.x,f.x),p=Math.max(c.y,h.y,f.y),g=Math.min(c.x,h.x,f.x),x=(m+g)/2,d=1/(m-g),M=1/(p-Math.min(c.y,h.y,f.y));let R=1,w=1,T=o,y=f,F=[l,u],B=[c,h],k=l.distanceToSquared(u);const V=l.distanceToSquared(o),I=u.distanceToSquared(o);V>k&&(k=V,T=u,F=[l,o],y=h,B=[c,f]),I>k&&(k=I,T=l,F=[u,o],y=c,B=[h,f]),y.x<x&&(B[0].x>x?(R=T.distanceTo(F[0]),w=T.distanceTo(F[1])):(R=T.distanceTo(F[1]),w=T.distanceTo(F[0]))),y.x>x&&(B[0].x<x?(R=T.distanceTo(F[0]),w=T.distanceTo(F[1])):(R=T.distanceTo(F[1]),w=T.distanceTo(F[0])));const b=R*d/(w*M);e.materialTracker.currentRWXMaterial.ratio=b,null===n?null===e.triangleRatioHint?e.triangleRatioHint=b:e.materialTracker.currentRWXMaterial.ratio=e.triangleRatioHint:null===e.quadRatioHint?e.quadRatioHint=b:e.materialTracker.currentRWXMaterial.ratio=e.quadRatioHint}function ge(e){e.materialTracker.currentRWXMaterial.ratio=1}function xe(e,t,a=e.matrix){e.children.forEach((e=>{let i=new s;if(i.copy(a),i.multiply(e.matrix),e instanceof r&&t.meshFilter(e)){let r=[];const a=e.geometry.getIndex().array;if("function"==typeof e.material[Symbol.iterator]){e.geometry.groups.forEach((e=>{r.push({start:e.start+t.indices.length,count:e.count,materialIndex:e.materialIndex+t.materials.length})}));const a=e.userData.taggedMaterials;if(void 0!==a)for(const[e,r]of Object.entries(a))void 0===t.taggedMaterials[e]&&(t.taggedMaterials[e]=[]),r.forEach((r=>{t.taggedMaterials[e].push(r+t.materials.length)}));t.materials.push(...e.material)}else r.push({start:t.indices.length,count:a.length,materialIndex:t.materials.length}),t.materials.push(e.material);const s=e.geometry.getAttribute("position").array,l=t.positions.length/3;let u=0;for(let e=s.length/3;u<e;u++){let e=new n(s[3*u],s[3*u+1],s[3*u+2]);e.applyMatrix4(i),t.positions.push(e.x),t.positions.push(e.y),t.positions.push(e.z)}if(void 0===e.geometry.getAttribute("uv")){const e=new Array(2*u).fill(0);t.uvs.push(...e)}else t.uvs.push(...e.geometry.getAttribute("uv").array);t.indices.push(...a.map((e=>e+l))),r.forEach((e=>{t.bufferGeometry.addGroup(e.start,e.count,e.materialIndex)}))}else e instanceof F&&xe(e,t,i)}))}function de(e,t=()=>!0){let a={bufferGeometry:new c,positions:[],uvs:[],indices:[],materials:[],taggedMaterials:{},meshFilter:t};xe(e,a),a.bufferGeometry.setAttribute("position",new B(new Float32Array(a.positions),3)),a.bufferGeometry.setAttribute("uv",new B(new Float32Array(a.uvs),2)),a.bufferGeometry.setIndex(a.indices),a.bufferGeometry.uvsNeedUpdate=!0,a.bufferGeometry.computeVertexNormals();let i=new r(a.bufferGeometry,a.materials);return i.userData.rwx=e.userData.rwx,i.userData.taggedMaterials=a.taggedMaterials,i}class Me{constructor(){this.color=[0,0,0],this.surface=X.slice(0,3),this.opacity=1,this.lightsampling=C.FACET,this.geometrysampling=v.SOLID,this.texturemodes=[E.LIT,E.FORESHORTEN,E.FILTER],this.materialmode=W.NULL,this.texture=null,this.tint=!1,this.mask=null,this.normalMap=null,this.specularMap=null,this.textureaddressmode=S.WRAP,this.collision=!0,this.tag=0,this.ratio=1}clone(){let e=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return e.color=[...this.color],e.surface=[...this.surface],e.texturemodes=[...this.texturemodes],e}getColorHexValue(){return(Math.trunc(255*this.color[0])<<16)+(Math.trunc(255*this.color[1])<<8)+Math.trunc(255*this.color[2])}getMatSignature(){const e=this.color[0].toFixed(3)+this.color[1].toFixed(3)+this.color[2].toFixed(3),t=this.surface[0].toFixed(3)+this.surface[1].toFixed(3)+this.surface[2].toFixed(3),r=this.opacity.toFixed(3),a=this.lightsampling.toString(),i=this.geometrysampling.toString();let s="";this.texturemodes.forEach((e=>{s+=e.toString()}));const n=this.materialmode.toString(),l=null===this.texture?"":this.texture,u=null===this.mask?"":this.mask,o=null===this.normalMap?"":this.normalMap,c=null===this.specularMap?"":this.specularMap,h=this.textureaddressmode.toString(),f=this.collision.toString(),m=this.tag.toString(),p=this.ratio.toFixed(2);return`${e}_${t}_${r}_${a}_${i}_${s}_${n}_${l}_${this.tint}_${u}_${c}_${o}_${h}_${f}_${m}_${p}`}}class Re{constructor(e,t=".jpg",r=".zip",a=null,i=!1,s=w,n=.2,l=!1){this.threeMaterialMap=new Map,this.folder=e,this.textureExtension=t,this.maskExtension=r,this.fflate=a,this.useBasicMaterial=i,this.textureColorSpace=s,this.alphaTest=n,this.allowURLs=l}addRWXMaterial(e,t=null){const r=t||e.getMatSignature(),a=_(e,this.folder,this.textureExtension,this.maskExtension,this.fflate,this.useBasicMaterial,this.textureColorSpace,this.alphaTest,this.allowURLs);a.signature=r,this.threeMaterialMap.set(r,a)}hasThreeMaterialPack(e){return this.threeMaterialMap.has(e)}getThreeMaterialPack(e){return this.threeMaterialMap.get(e)}removeThreeMaterialPack(e){this.threeMaterialMap.delete(e)}clear(){this.threeMaterialMap.clear()}texturesNextFrame(){for(const e of this.threeMaterialMap){const t=e[1].threeMat.userData.rwx.animation,r=e[1].threeMat.userData.rwx.maskAnimation;void 0!==t&&(t.step=(t.step+1)%t.yTiles,e[1].threeMat.map.offset.y=1-t.yHeight-t.step*t.yHeight,e[1].threeMat.needsUpdate=!0),void 0!==r&&(r.step=(r.step+1)%r.yTiles,e[1].threeMat.alphaMap.offset.y=1-r.yHeight-r.step*r.yHeight,e[1].threeMat.needsUpdate=!0)}}}class we{constructor(e){this.manager=e,this.currentRWXMaterial=new Me,this.currentMaterialID=null,this.currentMaterialList=[],this.signatureMap=new Map,this.commitedMaterialsAmount=0,this.currentMaterialSignature=""}getCurrentMaterialID(){const e=this.currentRWXMaterial.getMatSignature();return this.signatureMap.has(e)?(this.currentMaterialSignature=e,this.signatureMap.get(e)):(this.manager.hasThreeMaterialPack(e)||this.manager.addRWXMaterial(this.currentRWXMaterial,e),this.currentMaterialSignature!=e&&(this.currentMaterialSignature=e,null===this.currentMaterialID?this.currentMaterialID=0:this.currentMaterialID++,this.signatureMap.set(e,this.currentMaterialID),this.currentMaterialList.push(this.manager.getThreeMaterialPack(e))),this.currentMaterialID)}getCurrentMaterial(){return this.currentMaterialList[this.getCurrentMaterialID()]}getCurrentMaterialList(){return this.currentMaterialList}clearCurrentMaterialList(e=new Me){this.currentMaterialID=null,this.currentMaterialList=[],this.signatureMap.clear(),this.currentMaterialSignature="",this.currentRWXMaterial=e,this.commitedMaterialsAmount=0}commitMaterials(){this.commitedMaterialsAmount=this.currentMaterialList.length}getCommitedMaterialList(){return this.currentMaterialList.slice(0,this.commitedMaterialsAmount)}}export default class extends t{constructor(e){super(e),this.integerRegex=/([-+]?[0-9]+)/g,this.floatRegex=/([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][-+][0-9]+)?)/g,this.nonCommentRegex=/^(.*)#(?!\!)/g,this.clumpbeginRegex=/^ *(clumpbegin).*$/i,this.clumpendRegex=/^ *(clumpend).*$/i,this.transformbeginRegex=/^ *(transformbegin).*$/i,this.transformendRegex=/^ *(transformend).*$/i,this.protobeginRegex=/^ *(protobegin) +([A-Za-z0-9_\-\.]+).*$/i,this.protoinstanceRegex=/^ *(protoinstance) +([A-Za-z0-9_\-\.]+).*$/i,this.protoendRegex=/^ *(protoend).*$/i,this.vertexRegex=/^ *(vertex|vertexext)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){3}) *(uv(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){2}))?.*$/i,this.polygonRegex=/^ *(polygon|polygonext)( +[0-9]+)(( +[0-9]+)+)( +tag +([0-9]+))?.*$/i,this.quadRegex=/^ *(quad|quadext)(( +([0-9]+)){4})( +tag +([0-9]+))?.*$/i,this.triangleRegex=/^ *(triangle|triangleext)(( +([0-9]+)){3})( +tag +([0-9]+))?.*$/i,this.textureRegex=/^ *texture +(?<texture>[A-Za-z0-9_\-\/:.]+)(?: +(?<rest>.*))?$/i,this.colorRegex=/^ *(color)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){3}).*$/i,this.opacityRegex=/^ *(opacity)( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?).*$/i,this.identityRegex=/^ *(identity) *$/i,this.transformRegex=/^ *(transform)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){16}).*$/i,this.translateRegex=/^ *(translate)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){3}).*$/i,this.scaleRegex=/^ *(scale)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){3}).*$/i,this.rotateRegex=/^ *(rotate)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){4})$/i,this.surfaceRegex=/^ *(surface)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){3}).*$/i,this.ambientRegex=/^ *(ambient)( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?).*$/i,this.diffuseRegex=/^ *(diffuse)( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?).*$/i,this.specularRegex=/^ *(specular)( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?).*$/i,this.materialModeRegex=/^ *((add)?materialmode(s)?) +([A-Za-z0-9_\-]+).*$/i,this.collisionRegex=/^ *(collision) +(on|off).*$/i,this.lightsamplingRegex=/^ *(lightsampling) +(facet|vertex).*$/i,this.geometrysamplingRegex=/^ *(geometrysampling) +(pointcloud|wireframe|solid).*$/i,this.texturemodesRegex=/^ *(texturemode(s)?)(( +null)|( +lit| +foreshorten| +filter)+).*$/i,this.addtexturemodeRegex=/^ *(addtexturemode)( +lit| +foreshorten| +filter).*$/i,this.removetexturemodeRegex=/^ *(removetexturemode)( +lit| +foreshorten| +filter).*$/i,this.textureaddressmodeRegex=/^ *(#\!)? *(textureaddressmode) +(wrap|mirror|clamp).*$/i,this.axisalignmentRegex=/^ *(axisalignment) +(none|zorientx|zorienty|xyz).*$/i,this.blockRegex=/^ *(block)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){3}).*$/i,this.coneRegex=/^ *(cone)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){2}( +[-+]?[0-9]+)).*$/i,this.cylinderRegex=/^ *(cylinder)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){3}( +[-+]?[0-9]+)).*$/i,this.discRegex=/^ *(disc)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?){2}( +[-+]?[0-9]+)).*$/i,this.hemisphereRegex=/^ *(hemisphere)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?)( +[-+]?[0-9]+)).*$/i,this.sphereRegex=/^ *(sphere)(( +[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)(e[-+][0-9]+)?)( +[-+]?[0-9]+)).*$/i,this.tagRegex=/^ *(tag)( +[-+]?[0-9]+).*$/i,this.fflate=null,this.textureExtension=".jpg",this.maskExtension=".zip",this.waitFullLoad=!1,this.flatten=!1,this.useBasicMaterial=!1,this.rwxMaterialManager=null,this.textureColorSpace=w,this.enableTextures=!0,this.forceEarcut=!1,this.verboseWarning=!1,this.alphaTest=D,this.forceTextureFiltering=!0,this.correctInvalidNormals=!1,this.allowURLs=!1}setFflate(e){return this.fflate=e,this}setTextureExtension(e){return this.textureExtension=e,this}setMaskExtension(e){return this.maskExtension=e,this}setWaitFullLoad(e){return this.waitFullLoad=e,this}setFlatten(e){return this.flatten=e,this}setUseBasicMaterial(e){return this.useBasicMaterial=e,this}setRWXMaterialManager(e){return this.rwxMaterialManager=e,this}setTextureColorSpace(e){return this.textureColorSpace=e,this}setEnableTextures(e){return this.enableTextures=e,this}setForceEarcut(e){return this.forceEarcut=e,this}setVerboseWarning(e){return this.verboseWarning=e,this}setAlphaTest(e){return this.alphaTest=e,this}setForceTextureFiltering(e){return this.forceTextureFiltering=e,this}setCorrectInvalidNormals(e){return this.correctInvalidNormals=e,this}setAllowURLs(e){return this.allowURLs=e,this}load(t,r,a,i){let s=this,n=this.path,l=this.resourcePath,u=new e(this.manager);u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(n+"/"+t,(function(e){try{s.parse(t,e,l,(function(e){r(e)}))}catch(e){i?i(e):console.error(e),s.manager.itemError(t)}}),a,i)}parse(e,t,r,a){let i={rootGroup:null,currentGroup:null,transformSaves:[],materialStack:[],currentTransform:new s,currentBufferGeometry:null,currentBufferVertices:[],currentBufferUVs:[],currentBufferFaces:[],currentBufferFaceCount:0,currentBufferGroupFirstFaceID:0,previousMaterialID:null,rwxClumpStack:[],rwxPrototypes:new Map,loadingPromises:[],materialTracker:null!==this.rwxMaterialManager?new we(this.rwxMaterialManager):new we(new Re(r,this.textureExtension,this.maskExtension,this.fflate,this.useBasicMaterial,this.textureColorSpace,this.alphaTest,this.allowURLs)),taggedMaterials:{},quadRatioHint:null,triangleRatioHint:null,forceEarcut:this.forceEarcut,verboseWarning:this.verboseWarning,objectName:this.path+"/"+e,correctInvalidNormals:this.correctInvalidNormals},u=null,o=null,c=!1;const h=t.split(/[\n\r]+/g);i.rootGroup=new F,i.rootGroup.userData.rwx={axisAlignment:"none"};const f=new F;f.scale.set(10,10,10),f.updateMatrix(),i.rootGroup.add(f),f.name=H,i.currentGroup=f,i.materialStack.push(i.materialTracker.currentMaterial);for(let e=0,t=h.length;e<t;e++){let t=h[e],r=this.nonCommentRegex.exec(t);if(null!=r&&(t=r[1]),t=t.trim().replace(/\t/g," "),r=this.clumpbeginRegex.exec(t),null==r)if(r=this.clumpendRegex.exec(t),null==r)if(r=this.transformbeginRegex.exec(t),null==r)if(r=this.transformendRegex.exec(t),null==r)if(r=this.protobeginRegex.exec(t),null==r)if(r=this.protoendRegex.exec(t),null==r)if(r=this.protoinstanceRegex.exec(t),null==r)if(r=this.textureRegex.exec(t),this.enableTextures&&null!=r){const e=r.groups.texture?.toLowerCase();i.materialTracker.currentRWXMaterial.texture="null"===e?null:e,i.materialTracker.currentRWXMaterial.mask=null,i.materialTracker.currentRWXMaterial.normalMap=null,i.materialTracker.currentRWXMaterial.specularMap=null;const t=r.groups.rest||"",a=/\b(mask|normal|specular)\s+([A-Za-z0-9_\-\/:.]+)/gi;let s;for(;null!==(s=a.exec(t));){const e=s[1].toLowerCase(),t=s[2];i.materialTracker.currentRWXMaterial[e]=t}}else if(r=this.triangleRegex.exec(t),null==r)if(i.triangleRatioHint=null,r=this.quadRegex.exec(t),null==r)if(i.quadRatioHint=null,r=this.polygonRegex.exec(t),null==r)if(r=this.vertexRegex.exec(t),null==r)if(r=this.colorRegex.exec(t),null==r)if(r=this.opacityRegex.exec(t),null==r)if(r=this.identityRegex.exec(t),null!=r&&i.currentTransform.identity(),r=this.transformRegex.exec(t),null==r)if(r=this.translateRegex.exec(t),null==r)if(r=this.rotateRegex.exec(t),null==r)if(r=this.scaleRegex.exec(t),null==r)if(r=this.surfaceRegex.exec(t),null==r)if(r=this.ambientRegex.exec(t),null==r)if(r=this.diffuseRegex.exec(t),null==r)if(r=this.specularRegex.exec(t),null==r)if(r=this.materialModeRegex.exec(t),null==r)if(r=this.collisionRegex.exec(t),null==r)if(r=this.lightsamplingRegex.exec(t),null==r)if(r=this.geometrysamplingRegex.exec(t),null==r){if(r=this.texturemodesRegex.exec(t),null==r)if(r=this.addtexturemodeRegex.exec(t),null==r)if(r=this.removetexturemodeRegex.exec(t),null==r)if(r=this.textureaddressmodeRegex.exec(t),null==r)if(r=this.axisalignmentRegex.exec(t),null==r)if(r=this.blockRegex.exec(t),null==r)if(r=this.coneRegex.exec(t),null==r)if(r=this.cylinderRegex.exec(t),null==r)if(r=this.discRegex.exec(t),null==r)if(r=this.hemisphereRegex.exec(t),null==r)if(r=this.sphereRegex.exec(t),null==r)r=this.tagRegex.exec(t),null==r||(i.currentGroup.userData.rwx.tag=parseInt(r[2]));else{let e=[];r[2].match(this.floatRegex).forEach(((t,r)=>{e.push(1==r?parseInt(t):parseFloat(t))})),se(i,e[0],e[1])}else{let e=[];r[2].match(this.floatRegex).forEach(((t,r)=>{e.push(1==r?parseInt(t):parseFloat(t))})),ie(i,e[0],e[1])}else{let e=[];r[2].match(this.floatRegex).forEach(((t,r)=>{e.push(2==r?parseInt(t):parseFloat(t))})),ae(i,e[0],e[1],e[2])}else{let e=[];r[2].match(this.floatRegex).forEach(((t,r)=>{e.push(3==r?parseInt(t):parseFloat(t))})),re(i,e[0],e[1],e[2],e[3])}else{let e=[];r[2].match(this.floatRegex).forEach(((t,r)=>{e.push(2==r?parseInt(t):parseFloat(t))})),te(i,e[0],e[1],e[2])}else{let e=[];r[2].match(this.floatRegex).forEach((t=>{e.push(parseFloat(t))})),ee(i,e[0],e[1],e[2])}else i.rootGroup.userData.rwx.axisAlignment=r[2].toLowerCase();else{const e=r[3].toUpperCase();i.materialTracker.currentRWXMaterial.textureaddressmode=S[e]}else{const e=r[2].trim().toUpperCase();if(this.forceTextureFiltering&&E[e]===E.FILTER)continue;const t=i.materialTracker.currentRWXMaterial.texturemodes.indexOf(E[e]);t>=0&&(i.materialTracker.currentRWXMaterial.texturemodes.splice(t,1),i.materialTracker.currentRWXMaterial.texturemodes.sort())}else{const e=r[2].trim().toUpperCase();i.materialTracker.currentRWXMaterial.texturemodes.includes(E[e])||(i.materialTracker.currentRWXMaterial.texturemodes.push(E[e]),i.materialTracker.currentRWXMaterial.texturemodes.sort())}else if(i.materialTracker.currentRWXMaterial.texturemodes=[],!r[4]){const e=r[3].split(" ").filter((e=>""!==e)).map((e=>e.toUpperCase()));for(const t of e)i.materialTracker.currentRWXMaterial.texturemodes.includes(E[t])||i.materialTracker.currentRWXMaterial.texturemodes.push(E[t]);this.forceTextureFiltering&&!i.materialTracker.currentRWXMaterial.texturemodes.includes(E.FILTER)&&i.materialTracker.currentRWXMaterial.texturemodes.push(E.FILTER),i.materialTracker.currentRWXMaterial.texturemodes.sort()}}else{const e=r[2].toUpperCase();i.materialTracker.currentRWXMaterial.geometrysampling=v[e]}else{const e=r[2].toUpperCase();i.materialTracker.currentRWXMaterial.lightsampling=C[e]}else{const e=r[2].toLowerCase();"on"==e?i.materialTracker.currentRWXMaterial.collision=!0:"off"==e&&(i.materialTracker.currentRWXMaterial.collision=!1)}else{const e=r[4].toUpperCase();i.materialTracker.currentRWXMaterial.materialmode=W[e]}else i.materialTracker.currentRWXMaterial.surface[2]=parseFloat(r[2]);else i.materialTracker.currentRWXMaterial.surface[1]=parseFloat(r[2]);else i.materialTracker.currentRWXMaterial.surface[0]=parseFloat(r[2]);else{let e=[];r[2].match(this.floatRegex).forEach((t=>{e.push(parseFloat(t))})),i.materialTracker.currentRWXMaterial.surface=e}else{let e=[];r[2].match(this.floatRegex).forEach((t=>{e.push(parseFloat(t))}));let t=new s;3==e.length&&(t.makeScale(e[0],e[1],e[2]),i.currentTransform.multiply(t))}else{let e=[];if(r[2].match(this.floatRegex).forEach((t=>{e.push(parseFloat(t))})),4==e.length){let t=new s;e[0]&&(t.makeRotationX(l.degToRad(e[0]*e[3])),i.currentTransform.multiply(t)),e[1]&&(t.makeRotationY(l.degToRad(e[1]*e[3])),i.currentTransform.multiply(t)),e[2]&&(t.makeRotationZ(l.degToRad(e[2]*e[3])),i.currentTransform.multiply(t))}}else{let e=[];r[2].match(this.floatRegex).forEach((t=>{e.push(parseFloat(t))}));let t=new s;3==e.length&&(t.makeTranslation(e[0],e[1],e[2]),i.currentTransform.multiply(t))}else{let e=[];r[2].match(this.floatRegex).forEach((t=>{e.push(parseFloat(t))})),16==e.length&&(0==e[15]&&(e[15]=1),i.currentTransform.fromArray(e))}else i.materialTracker.currentRWXMaterial.opacity=parseFloat(r[2]);else{let e=[];r[2].match(this.floatRegex).forEach((t=>{e.push(parseFloat(t))})),3==e.length&&(i.materialTracker.currentRWXMaterial.color=e)}else{let e=[];r[2].match(this.floatRegex).forEach((t=>{e.push(parseFloat(t))}));let t=new n(e[0],e[1],e[2]);if(t.applyMatrix4(i.currentTransform),i.currentBufferVertices.push(t.x,t.y,t.z),void 0!==r[7]){let e=[];r[7].match(this.floatRegex).forEach((t=>{e.push(parseFloat(t))})),i.currentBufferUVs.push(e[0],1-e[1])}else i.currentBufferUVs.push(0,0)}else{const e=parseInt(r[2].match(this.integerRegex)[0]);let t=[];const a=r[3].match(this.integerRegex);for(let r=0;r<e;r++){const e=a[r];t.unshift(parseInt(e)-1)}const s=r.slice(-1)[0];void 0!==s&&fe(i,parseInt(s)),J(i,t),void 0!==s&&me(i)}else{let e=[];r[2].match(this.integerRegex).forEach((t=>{e.push(parseInt(t)-1)}));const t=r.slice(-1)[0];void 0!==t?(100==t?pe(i,e[0],e[1],e[2],e[3]):i.quadRatioHint=null,fe(i,parseInt(t))):i.quadRatioHint=null,Y(i,e[0],e[1],e[2],e[3]),void 0!==t&&(me(i),ge(i))}else{let e=[];r[2].match(this.integerRegex).forEach((t=>{e.push(parseInt(t)-1)}));const t=r.slice(-1)[0];void 0!==t?(100==t?pe(i,e[0],e[1],e[2]):i.triangleRatioHint=null,fe(i,parseInt(t))):i.triangleRatioHint=null,Q(i,e[0],e[1],e[2]),void 0!==t&&(me(i),ge(i))}else{const e=r[2],t=i.rwxPrototypes.get(e).clone();t.applyMatrix4(i.currentTransform),i.currentGroup.add(t)}else j(i),i.currentGroup=o,i.currentTransform=u,oe(i),q(i);else{let e=r[2];o=i.currentGroup,u=i.currentTransform,ue(i);const t=new F;t.userData.rwx={},i.rwxPrototypes.set(e,t),i.currentTransform=new s,q(i),i.currentGroup=t}else he(i);else ce(i);else j(i),oe(i),le(i),q(i);else j(i),q(i),ne(i),ue(i),c||(i.currentGroup.name=P,c=!0)}i.materialTracker.clearCurrentMaterialList(),this.waitFullLoad?Promise.all(i.loadingPromises).then((()=>{a(this.flatten?de(i.rootGroup):i.rootGroup)})):a(this.flatten?de(i.rootGroup):i.rootGroup)}}export{Me as RWXMaterial,Re as RWXMaterialManager,we as RWXMaterialTracker,_ as makeThreeMaterial,z as makeMaskPromise,O as applyTextureToMat,C as LightSampling,v as GeometrySampling,E as TextureMode,W as MaterialMode,S as TextureAddressMode,G as signTag,$ as pictureTag,de as flattenGroup,D as defaultAlphaTest,P as firstClumpName,H as scaleGroupName};