@2112-lab/central-plant 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/bundle/index.js +1 -15498
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -366
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -1448
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1292
  5. package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
  6. package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
  7. package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
  8. package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
  9. package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
  10. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4374
  11. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -465
  12. package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
  13. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -117
  14. package/dist/cjs/src/analysis/analysis.js +1 -0
  15. package/dist/cjs/src/analysis/testing.js +1 -0
  16. package/dist/cjs/src/core/centralPlant.js +1 -0
  17. package/dist/cjs/src/core/debugLogger.js +1 -0
  18. package/dist/cjs/src/core/mathUtils.js +1 -0
  19. package/dist/cjs/src/core/nameUtils.js +1 -0
  20. package/dist/cjs/src/data/export.js +1 -0
  21. package/dist/cjs/src/data/import.js +1 -0
  22. package/dist/cjs/src/data/numerics.js +1 -0
  23. package/dist/cjs/src/helpers/sceneHelper.js +1 -0
  24. package/dist/cjs/src/index.js +1 -79
  25. package/dist/cjs/src/managers/components/animationManager.js +1 -0
  26. package/dist/cjs/src/managers/components/componentManager.js +1 -0
  27. package/dist/cjs/src/managers/components/pathfindingManager.js +1 -0
  28. package/dist/cjs/src/managers/controls/TransformControls.js +1 -0
  29. package/dist/cjs/src/managers/controls/cameraControlsManager.js +1 -0
  30. package/dist/cjs/src/managers/controls/dragDropManager.js +1 -0
  31. package/dist/cjs/src/managers/controls/keyboardControlsManager.js +1 -0
  32. package/dist/cjs/src/managers/controls/transformControlsManager.js +1 -0
  33. package/dist/cjs/src/managers/environment/environmentManager.js +1 -0
  34. package/dist/cjs/src/managers/environment/textureConfig.js +1 -0
  35. package/dist/cjs/src/managers/scene/sceneExportManager.js +1 -0
  36. package/dist/cjs/src/managers/scene/sceneInitializationManager.js +1 -0
  37. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1 -0
  38. package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +1 -0
  39. package/dist/cjs/src/managers/system/disposalManager.js +1 -0
  40. package/dist/cjs/src/managers/system/hotReloadManager.js +1 -0
  41. package/dist/cjs/src/managers/system/performanceMonitor.js +1 -0
  42. package/dist/cjs/src/rendering/modelPreloader.js +1 -0
  43. package/dist/cjs/src/rendering/rendering2D.js +1 -0
  44. package/dist/cjs/src/rendering/rendering3D.js +1 -0
  45. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -339
  46. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -1444
  47. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1287
  48. package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
  49. package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
  50. package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
  51. package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
  52. package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
  53. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4370
  54. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -461
  55. package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
  56. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -113
  57. package/dist/esm/src/analysis/analysis.js +1 -0
  58. package/dist/esm/src/analysis/testing.js +1 -0
  59. package/dist/esm/src/core/centralPlant.js +1 -0
  60. package/dist/esm/src/core/debugLogger.js +1 -0
  61. package/dist/esm/src/core/mathUtils.js +1 -0
  62. package/dist/esm/src/core/nameUtils.js +1 -0
  63. package/dist/esm/src/data/export.js +1 -0
  64. package/dist/esm/src/data/import.js +1 -0
  65. package/dist/esm/src/data/numerics.js +1 -0
  66. package/dist/esm/src/helpers/sceneHelper.js +1 -0
  67. package/dist/esm/src/index.js +1 -70
  68. package/dist/esm/src/managers/components/animationManager.js +1 -0
  69. package/dist/esm/src/managers/components/componentManager.js +1 -0
  70. package/dist/esm/src/managers/components/pathfindingManager.js +1 -0
  71. package/dist/esm/src/managers/controls/TransformControls.js +1 -0
  72. package/dist/esm/src/managers/controls/cameraControlsManager.js +1 -0
  73. package/dist/esm/src/managers/controls/dragDropManager.js +1 -0
  74. package/dist/esm/src/managers/controls/keyboardControlsManager.js +1 -0
  75. package/dist/esm/src/managers/controls/transformControlsManager.js +1 -0
  76. package/dist/esm/src/managers/environment/environmentManager.js +1 -0
  77. package/dist/esm/src/managers/environment/textureConfig.js +1 -0
  78. package/dist/esm/src/managers/scene/sceneExportManager.js +1 -0
  79. package/dist/esm/src/managers/scene/sceneInitializationManager.js +1 -0
  80. package/dist/esm/src/managers/scene/sceneOperationsManager.js +1 -0
  81. package/dist/esm/src/managers/scene/sceneTooltipsManager.js +1 -0
  82. package/dist/esm/src/managers/system/disposalManager.js +1 -0
  83. package/dist/esm/src/managers/system/hotReloadManager.js +1 -0
  84. package/dist/esm/src/managers/system/performanceMonitor.js +1 -0
  85. package/dist/esm/src/rendering/modelPreloader.js +1 -0
  86. package/dist/esm/src/rendering/rendering2D.js +1 -0
  87. package/dist/esm/src/rendering/rendering3D.js +1 -0
  88. package/dist/index.d.ts +52 -255
  89. package/package.json +3 -6
  90. package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1543
  91. package/dist/cjs/src/animationManager.js +0 -121
  92. package/dist/cjs/src/componentManager.js +0 -151
  93. package/dist/cjs/src/debugLogger.js +0 -176
  94. package/dist/cjs/src/disposalManager.js +0 -185
  95. package/dist/cjs/src/environmentManager.js +0 -1308
  96. package/dist/cjs/src/hotReloadManager.js +0 -252
  97. package/dist/cjs/src/keyboardControlsManager.js +0 -206
  98. package/dist/cjs/src/nameUtils.js +0 -106
  99. package/dist/cjs/src/pathfindingManager.js +0 -503
  100. package/dist/cjs/src/performanceMonitor.js +0 -718
  101. package/dist/cjs/src/sceneExportManager.js +0 -292
  102. package/dist/cjs/src/sceneInitializationManager.js +0 -540
  103. package/dist/cjs/src/textureConfig.js +0 -624
  104. package/dist/cjs/src/transformControlsManager.js +0 -851
  105. package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1537
  106. package/dist/esm/src/animationManager.js +0 -112
  107. package/dist/esm/src/componentManager.js +0 -123
  108. package/dist/esm/src/debugLogger.js +0 -167
  109. package/dist/esm/src/disposalManager.js +0 -155
  110. package/dist/esm/src/environmentManager.js +0 -1282
  111. package/dist/esm/src/hotReloadManager.js +0 -244
  112. package/dist/esm/src/keyboardControlsManager.js +0 -196
  113. package/dist/esm/src/nameUtils.js +0 -99
  114. package/dist/esm/src/pathfindingManager.js +0 -479
  115. package/dist/esm/src/performanceMonitor.js +0 -712
  116. package/dist/esm/src/sceneExportManager.js +0 -286
  117. package/dist/esm/src/sceneInitializationManager.js +0 -513
  118. package/dist/esm/src/textureConfig.js +0 -595
  119. package/dist/esm/src/transformControlsManager.js +0 -827
@@ -0,0 +1 @@
1
+ import{Color as t,REVISION as e,Vector3 as n,CompressedTexture as s,Source as i,NoColorSpace as r,MathUtils as o,RGBAFormat as a,ImageUtils as c,DoubleSide as h,BufferAttribute as l,PropertyBinding as u,InterpolateDiscrete as f,Matrix4 as w,Scene as d,Quaternion as y,InterpolateLinear as m,NearestFilter as p,NearestMipmapNearestFilter as A,NearestMipmapLinearFilter as T,LinearFilter as x,LinearMipmapNearestFilter as g,LinearMipmapLinearFilter as b,ClampToEdgeWrapping as E,RepeatWrapping as M,MirroredRepeatWrapping as _,SRGBColorSpace as v}from"three";const C={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class O{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(t){return new at(t)}),this.register(function(t){return new ct(t)}),this.register(function(t){return new ft(t)}),this.register(function(t){return new wt(t)}),this.register(function(t){return new dt(t)}),this.register(function(t){return new yt(t)}),this.register(function(t){return new ht(t)}),this.register(function(t){return new lt(t)}),this.register(function(t){return new ut(t)}),this.register(function(t){return new mt(t)}),this.register(function(t){return new pt(t)}),this.register(function(t){return new At(t)}),this.register(function(t){return new Tt(t)}),this.register(function(t){return new xt(t)})}register(t){return-1===this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.push(t),this}unregister(t){return-1!==this.pluginCallbacks.indexOf(t)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}setTextureUtils(t){return this.textureUtils=t,this}parse(t,e,n,s){const i=new ot,r=[];for(let t=0,e=this.pluginCallbacks.length;t<e;t++)r.push(this.pluginCallbacks[t](i));i.setPlugins(r),i.setTextureUtils(this.textureUtils),i.writeAsync(t,e,s).catch(n)}parseAsync(t,e){const n=this;return new Promise(function(s,i){n.parse(t,s,i,e)})}}const R=0,I=1,N=2,H=3,L=4,S=5120,F=5121,z=5122,U=5123,B=5124,K=5125,k=5126,D=34962,G=34963,V=9728,P=9729,j=9984,X=9985,J=9986,q=9987,W=33071,Q=33648,Y=10497,$="KHR_mesh_quantization",Z={};Z[p]=V,Z[A]=j,Z[T]=J,Z[x]=P,Z[g]=X,Z[b]=q,Z[E]=W,Z[M]=Y,Z[_]=Q;const tt={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},et=new t;function nt(t,e){return t.length===e.length&&t.every(function(t,n){return t===e[n]})}function st(t){return 4*Math.ceil(t/4)}function it(t,e=0){const n=st(t.byteLength);if(n!==t.byteLength){const s=new Uint8Array(n);if(s.set(new Uint8Array(t)),0!==e)for(let i=t.byteLength;i<n;i++)s[i]=e;return s.buffer}return t}function rt(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}class ot{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+e}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(t){this.plugins=t}setTextureUtils(t){this.textureUtils=t}async writeAsync(t,e,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(t),await Promise.all(this.pending);const s=this,i=s.buffers,r=s.json;n=s.options;const o=s.extensionsUsed,a=s.extensionsRequired,c=new Blob(i,{type:"application/octet-stream"}),h=Object.keys(o),l=Object.keys(a);if(h.length>0&&(r.extensionsUsed=h),l.length>0&&(r.extensionsRequired=l),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=c.size),!0===n.binary){const t=new FileReader;t.readAsArrayBuffer(c),t.onloadend=function(){const n=it(t.result),s=new DataView(new ArrayBuffer(8));s.setUint32(0,n.byteLength,!0),s.setUint32(4,5130562,!0);const i=it((o=JSON.stringify(r),(new TextEncoder).encode(o).buffer),32);var o;const a=new DataView(new ArrayBuffer(8));a.setUint32(0,i.byteLength,!0),a.setUint32(4,1313821514,!0);const c=new ArrayBuffer(12),h=new DataView(c);h.setUint32(0,1179937895,!0),h.setUint32(4,2,!0);const l=12+a.byteLength+i.byteLength+s.byteLength+n.byteLength;h.setUint32(8,l,!0);const u=new Blob([c,a,i,s,n],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(u),f.onloadend=function(){e(f.result)}}}else if(r.buffers&&r.buffers.length>0){const t=new FileReader;t.readAsDataURL(c),t.onloadend=function(){const n=t.result;r.buffers[0].uri=n,e(r)}}else e(r)}serializeUserData(t,e){if(0===Object.keys(t.userData).length)return;const n=this.options,s=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&i.gltfExtensions){void 0===e.extensions&&(e.extensions={});for(const t in i.gltfExtensions)e.extensions[t]=i.gltfExtensions[t],s[t]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(e.extras=i)}catch(t){}}getUID(t,e=!1){if(!1===this.uids.has(t)){const e=new Map;e.set(!0,this.uid++),e.set(!1,this.uid++),this.uids.set(t,e)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;const e=new n;for(let n=0,s=t.count;n<s;n++)if(Math.abs(e.fromBufferAttribute(t,n).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(t){const e=this.cache;if(e.attributesNormalized.has(t))return e.attributesNormalized.get(t);const s=t.clone(),i=new n;for(let t=0,e=s.count;t<e;t++)i.fromBufferAttribute(s,t),0===i.x&&0===i.y&&0===i.z?i.setX(1):i.normalize(),s.setXYZ(t,i.x,i.y,i.z);return e.attributesNormalized.set(t,s),s}applyTextureTransform(t,e){let n=!1;const s={};0===e.offset.x&&0===e.offset.y||(s.offset=e.offset.toArray(),n=!0),0!==e.rotation&&(s.rotation=e.rotation,n=!0),1===e.repeat.x&&1===e.repeat.y||(s.scale=e.repeat.toArray(),n=!0),n&&(t.extensions=t.extensions||{},t.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(t,e){if(t===e)return t;function n(t){return t.colorSpace===v?function(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}:function(t){return t}}t instanceof s&&(t=await this.decompressTextureAsync(t)),e instanceof s&&(e=await this.decompressTextureAsync(e));const o=t?t.image:null,a=e?e.image:null,c=Math.max(o?o.width:0,a?a.width:0),h=Math.max(o?o.height:0,a?a.height:0),l=rt();l.width=c,l.height=h;const u=l.getContext("2d",{willReadFrequently:!0});u.fillStyle="#00ffff",u.fillRect(0,0,c,h);const f=u.getImageData(0,0,c,h);if(o){u.drawImage(o,0,0,c,h);const e=n(t),s=u.getImageData(0,0,c,h).data;for(let t=2;t<s.length;t+=4)f.data[t]=256*e(s[t]/256)}if(a){u.drawImage(a,0,0,c,h);const t=n(e),s=u.getImageData(0,0,c,h).data;for(let e=1;e<s.length;e+=4)f.data[e]=256*t(s[e]/256)}u.putImageData(f,0,0);const w=(t||e).clone();return w.source=new i(l),w.colorSpace=r,w.channel=(t||e).channel,t&&e&&(t.channel,e.channel),w}async decompressTextureAsync(t,e=1/0){if(null===this.textureUtils)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(t,e)}processBuffer(t){const e=this.json,n=this.buffers;return e.buffers||(e.buffers=[{byteLength:0}]),n.push(t),0}processBufferView(t,e,n,s,i){const r=this.json;let a;switch(r.bufferViews||(r.bufferViews=[]),e){case S:case F:a=1;break;case z:case U:a=2;break;default:a=4}let c=t.itemSize*a;i===D&&(c=4*Math.ceil(c/4));const h=st(s*c),l=new DataView(new ArrayBuffer(h));let u=0;for(let i=n;i<n+s;i++){for(let n=0;n<t.itemSize;n++){let s;t.itemSize>4?s=t.array[i*t.itemSize+n]:(0===n?s=t.getX(i):1===n?s=t.getY(i):2===n?s=t.getZ(i):3===n&&(s=t.getW(i)),!0===t.normalized&&(s=o.normalize(s,t.array))),e===k?l.setFloat32(u,s,!0):e===B?l.setInt32(u,s,!0):e===K?l.setUint32(u,s,!0):e===z?l.setInt16(u,s,!0):e===U?l.setUint16(u,s,!0):e===S?l.setInt8(u,s):e===F&&l.setUint8(u,s),u+=a}u%c!==0&&(u+=c-u%c)}const f={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:h};void 0!==i&&(f.target=i),i===D&&(f.byteStride=c),this.byteOffset+=h,r.bufferViews.push(f);return{id:r.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){const e=this,n=e.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(s){const i=new FileReader;i.readAsArrayBuffer(t),i.onloadend=function(){const t=it(i.result),r={buffer:e.processBuffer(t),byteOffset:e.byteOffset,byteLength:t.byteLength};e.byteOffset+=t.byteLength,s(n.bufferViews.push(r)-1)}})}processAccessor(t,e,n,s){const i=this.json;let r;if(t.array.constructor===Float32Array)r=k;else if(t.array.constructor===Int32Array)r=B;else if(t.array.constructor===Uint32Array)r=K;else if(t.array.constructor===Int16Array)r=z;else if(t.array.constructor===Uint16Array)r=U;else if(t.array.constructor===Int8Array)r=S;else{if(t.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+t.array.constructor.name);r=F}if(void 0===n&&(n=0),void 0!==s&&s!==1/0||(s=t.count),0===s)return null;const a=function(t,e,n){const s={min:new Array(t.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(t.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=e;i<e+n;i++)for(let e=0;e<t.itemSize;e++){let n;t.itemSize>4?n=t.array[i*t.itemSize+e]:(0===e?n=t.getX(i):1===e?n=t.getY(i):2===e?n=t.getZ(i):3===e&&(n=t.getW(i)),!0===t.normalized&&(n=o.normalize(n,t.array))),s.min[e]=Math.min(s.min[e],n),s.max[e]=Math.max(s.max[e],n)}return s}(t,n,s);let c;void 0!==e&&(c=t===e.index?G:D);const h=this.processBufferView(t,r,n,s,c),l={bufferView:h.id,byteOffset:h.byteOffset,componentType:r,count:s,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[t.itemSize]};return!0===t.normalized&&(l.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(l)-1}processImage(t,e,n,s="image/png"){if(null!==t){const e=this,i=e.cache,r=e.json,o=e.options,a=e.pending;i.images.has(t)||i.images.set(t,{});const h=i.images.get(t),l=s+":flipY/"+n.toString();if(void 0!==h[l])return h[l];r.images||(r.images=[]);const u={mimeType:s},f=rt();f.width=Math.min(t.width,o.maxTextureSize),f.height=Math.min(t.height,o.maxTextureSize);const w=f.getContext("2d",{willReadFrequently:!0});if(!0===n&&(w.translate(0,f.height),w.scale(1,-1)),void 0!==t.data){t.width>o.maxTextureSize||(t.height,o.maxTextureSize);const e=new Uint8ClampedArray(t.height*t.width*4);for(let n=0;n<e.length;n+=4)e[n+0]=t.data[n+0],e[n+1]=t.data[n+1],e[n+2]=t.data[n+2],e[n+3]=t.data[n+3];w.putImageData(new ImageData(e,t.width,t.height),0,0)}else{if(!("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas))throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");w.drawImage(t,0,0,f.width,f.height)}!0===o.binary?a.push(function(t,e){if(void 0!==t.toBlob)return new Promise(n=>t.toBlob(n,e));let n;return"image/jpeg"===e?n=.92:"image/webp"===e&&(n=.8),t.convertToBlob({type:e,quality:n})}(f,s).then(t=>e.processBufferViewImage(t)).then(t=>{u.bufferView=t})):u.uri=c.getDataURL(f,s);const d=r.images.push(u)-1;return h[l]=d,d}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){const e=this.json;e.samplers||(e.samplers=[]);const n={magFilter:Z[t.magFilter],minFilter:Z[t.minFilter],wrapS:Z[t.wrapS],wrapT:Z[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(t){const e=this.options,n=this.cache,i=this.json;if(n.textures.has(t))return n.textures.get(t);i.textures||(i.textures=[]),t instanceof s&&(t=await this.decompressTextureAsync(t,e.maxTextureSize));let r=t.userData.mimeType;"image/webp"===r&&(r="image/png");const o={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY,r)};t.name&&(o.name=t.name),await this.t(async function(e){e.writeTexture&&await e.writeTexture(t,o)});const a=i.textures.push(o)-1;return n.textures.set(t,a),a}async processMaterialAsync(t){const e=this.cache,n=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return null;n.materials||(n.materials=[]);const s={pbrMetallicRoughness:{}};!0!==t.isMeshStandardMaterial&&t.isMeshBasicMaterial;const i=t.color.toArray().concat([t.opacity]);if(nt(i,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=i),t.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=t.metalness,s.pbrMetallicRoughness.roughnessFactor=t.roughness):(s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=1),t.metalnessMap||t.roughnessMap){const e=await this.buildMetalRoughTextureAsync(t.metalnessMap,t.roughnessMap),n={index:await this.processTextureAsync(e),texCoord:e.channel};this.applyTextureTransform(n,e),s.pbrMetallicRoughness.metallicRoughnessTexture=n}if(t.map){const e={index:await this.processTextureAsync(t.map),texCoord:t.map.channel};this.applyTextureTransform(e,t.map),s.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){const e=t.emissive;if(Math.max(e.r,e.g,e.b)>0&&(s.emissiveFactor=t.emissive.toArray()),t.emissiveMap){const e={index:await this.processTextureAsync(t.emissiveMap),texCoord:t.emissiveMap.channel};this.applyTextureTransform(e,t.emissiveMap),s.emissiveTexture=e}}if(t.normalMap){const e={index:await this.processTextureAsync(t.normalMap),texCoord:t.normalMap.channel};t.normalScale&&1!==t.normalScale.x&&(e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),s.normalTexture=e}if(t.aoMap){const e={index:await this.processTextureAsync(t.aoMap),texCoord:t.aoMap.channel};1!==t.aoMapIntensity&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),s.occlusionTexture=e}t.transparent?s.alphaMode="BLEND":t.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=t.alphaTest),t.side===h&&(s.doubleSided=!0),""!==t.name&&(s.name=t.name),this.serializeUserData(t,s),await this.t(async function(e){e.writeMaterialAsync&&await e.writeMaterialAsync(t,s)});const r=n.materials.push(s)-1;return e.materials.set(t,r),r}async processMeshAsync(t){const e=this.cache,n=this.json,s=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,n=t.material.length;e<n;e++)s.push(t.material[e].uuid);else s.push(t.material.uuid);const i=s.join(":");if(e.meshes.has(i))return e.meshes.get(i);const r=t.geometry;let o;o=t.isLineSegments?I:t.isLineLoop?N:t.isLine?H:t.isPoints?R:t.material.wireframe?I:L;const a={},c={},h=[],u=[],f={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},w=r.getAttribute("normal");void 0===w||this.isNormalizedNormalAttribute(w)||r.setAttribute("normal",this.createNormalizedNormalAttribute(w));let d=null;for(let t in r.attributes){if("morph"===t.slice(0,5))continue;const n=r.attributes[t];t=f[t]||t.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(t)||(t="_"+t),e.attributes.has(this.getUID(n))){c[t]=e.attributes.get(this.getUID(n));continue}d=null;const s=n.array;"JOINTS_0"!==t||s instanceof Uint16Array||s instanceof Uint8Array?(s instanceof Uint32Array||s instanceof Int32Array)&&!t.startsWith("_")&&(d=O.Utils.toFloat32BufferAttribute(n)):d=new l(new Uint16Array(s),n.itemSize,n.normalized);const i=this.processAccessor(d||n,r);null!==i&&(t.startsWith("_")||this.detectMeshQuantization(t,n),c[t]=i,e.attributes.set(this.getUID(n),i))}if(void 0!==w&&r.setAttribute("normal",w),0===Object.keys(c).length)return null;if(void 0!==t.morphTargetInfluences&&t.morphTargetInfluences.length>0){const n=[],s=[],i={};if(void 0!==t.morphTargetDictionary)for(const e in t.morphTargetDictionary)i[t.morphTargetDictionary[e]]=e;for(let o=0;o<t.morphTargetInfluences.length;++o){const a={};let c=!1;for(const t in r.morphAttributes){if("position"!==t&&"normal"!==t){c||(c=!0);continue}const n=r.morphAttributes[t][o],s=t.toUpperCase(),i=r.attributes[t];if(e.attributes.has(this.getUID(n,!0))){a[s]=e.attributes.get(this.getUID(n,!0));continue}const h=n.clone();if(!r.morphTargetsRelative)for(let t=0,e=n.count;t<e;t++)for(let e=0;e<n.itemSize;e++)0===e&&h.setX(t,n.getX(t)-i.getX(t)),1===e&&h.setY(t,n.getY(t)-i.getY(t)),2===e&&h.setZ(t,n.getZ(t)-i.getZ(t)),3===e&&h.setW(t,n.getW(t)-i.getW(t));a[s]=this.processAccessor(h,r),e.attributes.set(this.getUID(i,!0),a[s])}u.push(a),n.push(t.morphTargetInfluences[o]),void 0!==t.morphTargetDictionary&&s.push(i[o])}a.weights=n,s.length>0&&(a.extras={},a.extras.targetNames=s)}const y=Array.isArray(t.material);if(y&&0===r.groups.length)return null;let m=!1;if(y&&null===r.index){const t=[];for(let e=0,n=r.attributes.position.count;e<n;e++)t[e]=e;r.setIndex(t),m=!0}const p=y?t.material:[t.material],A=y?r.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let t=0,n=A.length;t<n;t++){const n={mode:o,attributes:c};if(this.serializeUserData(r,n),u.length>0&&(n.targets=u),null!==r.index){let s=this.getUID(r.index);void 0===A[t].start&&void 0===A[t].count||(s+=":"+A[t].start+":"+A[t].count),e.attributes.has(s)?n.indices=e.attributes.get(s):(n.indices=this.processAccessor(r.index,r,A[t].start,A[t].count),e.attributes.set(s,n.indices)),null===n.indices&&delete n.indices}const s=await this.processMaterialAsync(p[A[t].materialIndex]);null!==s&&(n.material=s),h.push(n)}!0===m&&r.setIndex(null),a.primitives=h,n.meshes||(n.meshes=[]),await this.t(function(e){e.writeMesh&&e.writeMesh(t,a)});const T=n.meshes.push(a)-1;return e.meshes.set(i,T),T}detectMeshQuantization(t,e){if(this.extensionsUsed[$])return;let n;switch(e.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}e.normalized&&(n+=" normalized");const s=t.split("_",1)[0];C[s]&&C[s].includes(n)&&(this.extensionsUsed[$]=!0,this.extensionsRequired[$]=!0)}processCamera(t){const e=this.json;e.cameras||(e.cameras=[]);const n=t.isOrthographicCamera,s={type:n?"orthographic":"perspective"};return n?s.orthographic={xmag:2*t.right,ymag:2*t.top,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:s.perspective={aspectRatio:t.aspect,yfov:o.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},""!==t.name&&(s.name=t.type),e.cameras.push(s)-1}processAnimation(t,e){const n=this.json,s=this.nodeMap;n.animations||(n.animations=[]);const i=(t=O.Utils.mergeMorphTargetTracks(t.clone(),e)).tracks,r=[],o=[];for(let t=0;t<i.length;++t){const n=i[t],a=u.parseTrackName(n.name);let c=u.findNode(e,a.nodeName);const h=tt[a.propertyName];if("bones"===a.objectName&&(c=!0===c.isSkinnedMesh?c.skeleton.getBoneByName(a.objectIndex):void 0),!c||!h)continue;const w=1;let d,y=n.values.length/n.times.length;h===tt.morphTargetInfluences&&(y/=c.morphTargetInfluences.length),!0===n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(d="CUBICSPLINE",y/=3):d=n.getInterpolation()===f?"STEP":"LINEAR",o.push({input:this.processAccessor(new l(n.times,w)),output:this.processAccessor(new l(n.values,y)),interpolation:d}),r.push({sampler:o.length-1,target:{node:s.get(c),path:h}})}return n.animations.push({name:t.name||"clip_"+n.animations.length,samplers:o,channels:r}),n.animations.length-1}processSkin(t){const e=this.json,n=this.nodeMap,s=e.nodes[n.get(t)],i=t.skeleton;if(void 0===i)return null;const r=t.skeleton.bones[0];if(void 0===r)return null;const o=[],a=new Float32Array(16*i.bones.length),c=new w;for(let e=0;e<i.bones.length;++e)o.push(n.get(i.bones[e])),c.copy(i.boneInverses[e]),c.multiply(t.bindMatrix).toArray(a,16*e);void 0===e.skins&&(e.skins=[]),e.skins.push({inverseBindMatrices:this.processAccessor(new l(a,16)),joints:o,skeleton:n.get(r)});return s.skin=e.skins.length-1}async processNodeAsync(t){const e=this.json,n=this.options,s=this.nodeMap;e.nodes||(e.nodes=[]);const i={};if(n.trs){const e=t.quaternion.toArray(),n=t.position.toArray(),s=t.scale.toArray();nt(e,[0,0,0,1])||(i.rotation=e),nt(n,[0,0,0])||(i.translation=n),nt(s,[1,1,1])||(i.scale=s)}else t.matrixAutoUpdate&&t.updateMatrix(),!1===nt(t.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(i.matrix=t.matrix.elements);if(""!==t.name&&(i.name=String(t.name)),this.serializeUserData(t,i),t.isMesh||t.isLine||t.isPoints){const e=await this.processMeshAsync(t);null!==e&&(i.mesh=e)}else t.isCamera&&(i.camera=this.processCamera(t));t.isSkinnedMesh&&this.skins.push(t);const r=e.nodes.push(i)-1;if(s.set(t,r),t.children.length>0){const e=[];for(let s=0,i=t.children.length;s<i;s++){const i=t.children[s];if(i.visible||!1===n.onlyVisible){const t=await this.processNodeAsync(i);null!==t&&e.push(t)}}e.length>0&&(i.children=e)}return await this.t(function(e){e.writeNode&&e.writeNode(t,i)}),r}async processSceneAsync(t){const e=this.json,n=this.options;e.scenes||(e.scenes=[],e.scene=0);const s={};""!==t.name&&(s.name=t.name),e.scenes.push(s);const i=[];for(let e=0,s=t.children.length;e<s;e++){const s=t.children[e];if(s.visible||!1===n.onlyVisible){const t=await this.processNodeAsync(s);null!==t&&i.push(t)}}i.length>0&&(s.nodes=i),this.serializeUserData(t,s)}async processObjectsAsync(t){const e=new d;e.name="AuxScene";for(let n=0;n<t.length;n++)e.children.push(t[n]);await this.processSceneAsync(e)}async processInputAsync(t){const e=this.options;t=t instanceof Array?t:[t],await this.t(function(e){e.beforeParse&&e.beforeParse(t)});const n=[];for(let e=0;e<t.length;e++)t[e]instanceof d?await this.processSceneAsync(t[e]):n.push(t[e]);n.length>0&&await this.processObjectsAsync(n);for(let t=0;t<this.skins.length;++t)this.processSkin(this.skins[t]);for(let n=0;n<e.animations.length;++n)this.processAnimation(e.animations[n],t[0]);await this.t(function(e){e.afterParse&&e.afterParse(t)})}async t(t){for(let e=0,n=this.plugins.length;e<n;e++)await t(this.plugins[e])}}class at{constructor(t){this.writer=t,this.name="KHR_lights_punctual"}writeNode(t,e){if(!t.isLight)return;if(!t.isDirectionalLight&&!t.isPointLight&&!t.isSpotLight)return;const n=this.writer,s=n.json,i=n.extensionsUsed,r={};t.name&&(r.name=t.name),r.color=t.color.toArray(),r.intensity=t.intensity,t.isDirectionalLight?r.type="directional":t.isPointLight?(r.type="point",t.distance>0&&(r.range=t.distance)):t.isSpotLight&&(r.type="spot",t.distance>0&&(r.range=t.distance),r.spot={},r.spot.innerConeAngle=(1-t.penumbra)*t.angle,r.spot.outerConeAngle=t.angle),void 0!==t.decay&&t.decay,t.target&&(t.target.parent!==t||0!==t.target.position.x||0!==t.target.position.y||t.target.position.z),i[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},i[this.name]=!0);const o=s.extensions[this.name].lights;o.push(r),e.extensions=e.extensions||{},e.extensions[this.name]={light:o.length-1}}}class ct{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}async writeMaterialAsync(t,e){if(!t.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},n[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}}class ht{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.clearcoat)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.clearcoatFactor=t.clearcoat,t.clearcoatMap){const e={index:await n.processTextureAsync(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(e,t.clearcoatMap),i.clearcoatTexture=e}if(i.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){const e={index:await n.processTextureAsync(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(e,t.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=e}if(t.clearcoatNormalMap){const e={index:await n.processTextureAsync(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};1!==t.clearcoatNormalScale.x&&(e.scale=t.clearcoatNormalScale.x),n.applyTextureTransform(e,t.clearcoatNormalMap),i.clearcoatNormalTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class lt{constructor(t){this.writer=t,this.name="KHR_materials_dispersion"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.dispersion)return;const n=this.writer.extensionsUsed,s={};s.dispersion=t.dispersion,e.extensions=e.extensions||{},e.extensions[this.name]=s,n[this.name]=!0}}class ut{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.iridescence)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.iridescenceFactor=t.iridescence,t.iridescenceMap){const e={index:await n.processTextureAsync(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(e,t.iridescenceMap),i.iridescenceTexture=e}if(i.iridescenceIor=t.iridescenceIOR,i.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){const e={index:await n.processTextureAsync(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(e,t.iridescenceThicknessMap),i.iridescenceThicknessTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class ft{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.transmissionFactor=t.transmission,t.transmissionMap){const e={index:await n.processTextureAsync(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(e,t.transmissionMap),i.transmissionTexture=e}e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class wt{constructor(t){this.writer=t,this.name="KHR_materials_volume"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0===t.transmission)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.thicknessFactor=t.thickness,t.thicknessMap){const e={index:await n.processTextureAsync(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(e,t.thicknessMap),i.thicknessTexture=e}t.attenuationDistance!==1/0&&(i.attenuationDistance=t.attenuationDistance),i.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class dt{constructor(t){this.writer=t,this.name="KHR_materials_ior"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1.5===t.ior)return;const n=this.writer.extensionsUsed,s={};s.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=s,n[this.name]=!0}}class yt{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1===t.specularIntensity&&t.specularColor.equals(et)&&!t.specularIntensityMap&&!t.specularColorMap)return;const n=this.writer,s=n.extensionsUsed,i={};if(t.specularIntensityMap){const e={index:await n.processTextureAsync(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(e,t.specularIntensityMap),i.specularTexture=e}if(t.specularColorMap){const e={index:await n.processTextureAsync(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(e,t.specularColorMap),i.specularColorTexture=e}i.specularFactor=t.specularIntensity,i.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class mt{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.sheen)return;const n=this.writer,s=n.extensionsUsed,i={};if(t.sheenRoughnessMap){const e={index:await n.processTextureAsync(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(e,t.sheenRoughnessMap),i.sheenRoughnessTexture=e}if(t.sheenColorMap){const e={index:await n.processTextureAsync(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(e,t.sheenColorMap),i.sheenColorTexture=e}i.sheenRoughnessFactor=t.sheenRoughness,i.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class pt{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||0==t.anisotropy)return;const n=this.writer,s=n.extensionsUsed,i={};if(t.anisotropyMap){const e={index:await n.processTextureAsync(t.anisotropyMap)};n.applyTextureTransform(e,t.anisotropyMap),i.anisotropyTexture=e}i.anisotropyStrength=t.anisotropy,i.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class At{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.emissiveIntensity)return;const n=this.writer.extensionsUsed,s={};s.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=s,n[this.name]=!0}}class Tt{constructor(t){this.writer=t,this.name="EXT_materials_bump"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||1===t.bumpScale&&!t.bumpMap)return;const n=this.writer,s=n.extensionsUsed,i={};if(t.bumpMap){const e={index:await n.processTextureAsync(t.bumpMap),texCoord:t.bumpMap.channel};n.applyTextureTransform(e,t.bumpMap),i.bumpTexture=e}i.bumpFactor=t.bumpScale,e.extensions=e.extensions||{},e.extensions[this.name]=i,s[this.name]=!0}}class xt{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(t,e){if(!t.isInstancedMesh)return;const s=this.writer,i=t,r=new Float32Array(3*i.count),o=new Float32Array(4*i.count),a=new Float32Array(3*i.count),c=new w,h=new n,u=new y,f=new n;for(let t=0;t<i.count;t++)i.getMatrixAt(t,c),c.decompose(h,u,f),h.toArray(r,3*t),u.toArray(o,4*t),f.toArray(a,3*t);const d={TRANSLATION:s.processAccessor(new l(r,3)),ROTATION:s.processAccessor(new l(o,4)),SCALE:s.processAccessor(new l(a,3))};i.instanceColor&&(d.i=s.processAccessor(i.instanceColor)),e.extensions=e.extensions||{},e.extensions[this.name]={attributes:d},s.extensionsUsed[this.name]=!0,s.extensionsRequired[this.name]=!0}}O.Utils={insertKeyframe:function(t,e){const n=.001,s=t.getValueSize(),i=new t.TimeBufferType(t.times.length+1),r=new t.ValueBufferType(t.values.length+s),o=t.createInterpolant(new t.ValueBufferType(s));let a;if(0===t.times.length){i[0]=e;for(let t=0;t<s;t++)r[t]=0;a=0}else if(e<t.times[0]){if(Math.abs(t.times[0]-e)<n)return 0;i[0]=e,i.set(t.times,1),r.set(o.evaluate(e),0),r.set(t.values,s),a=0}else if(e>t.times[t.times.length-1]){if(Math.abs(t.times[t.times.length-1]-e)<n)return t.times.length-1;i[i.length-1]=e,i.set(t.times,0),r.set(t.values,0),r.set(o.evaluate(e),t.values.length),a=i.length-1}else for(let c=0;c<t.times.length;c++){if(Math.abs(t.times[c]-e)<n)return c;if(t.times[c]<e&&t.times[c+1]>e){i.set(t.times.slice(0,c+1),0),i[c+1]=e,i.set(t.times.slice(c+1),c+2),r.set(t.values.slice(0,(c+1)*s),0),r.set(o.evaluate(e),(c+1)*s),r.set(t.values.slice((c+1)*s),(c+2)*s),a=c+1;break}}return t.times=i,t.values=r,a},mergeMorphTargetTracks:function(t,e){const n=[],s={},i=t.tracks;for(let t=0;t<i.length;++t){let r=i[t];const o=u.parseTrackName(r.name),a=u.findNode(e,o.nodeName);if("morphTargetInfluences"!==o.propertyName||void 0===o.propertyIndex){n.push(r);continue}if(r.createInterpolant!==r.InterpolantFactoryMethodDiscrete&&r.createInterpolant!==r.InterpolantFactoryMethodLinear){if(r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");r=r.clone(),r.setInterpolation(m)}const c=a.morphTargetInfluences.length,h=a.morphTargetDictionary[o.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let l;if(void 0===s[a.uuid]){l=r.clone();const t=new l.ValueBufferType(c*l.times.length);for(let e=0;e<l.times.length;e++)t[e*c+h]=l.values[e];l.name=(o.nodeName||"")+".morphTargetInfluences",l.values=t,s[a.uuid]=l,n.push(l);continue}const f=r.createInterpolant(new r.ValueBufferType(1));l=s[a.uuid];for(let t=0;t<l.times.length;t++)l.values[t*c+h]=f.evaluate(l.times[t]);for(let t=0;t<r.times.length;t++){const e=this.insertKeyframe(l,r.times[t]);l.values[e*c+h]=r.values[t]}}return t.tracks=n,t},toFloat32BufferAttribute:function(t){const e=new l(new Float32Array(t.count*t.itemSize),t.itemSize,!1);if(!t.normalized&&!t.isInterleavedBufferAttribute)return e.array.set(t.array),e;for(let n=0,s=t.count;n<s;n++)for(let s=0;s<t.itemSize;s++)e.setComponent(n,s,t.getComponent(n,s));return e}};export{O as GLTFExporter};
@@ -0,0 +1 @@
1
+ import{Vector3 as n,Color as o,Vector2 as t,Matrix3 as e,ColorManagement as f,SRGBColorSpace as i}from"three";class l{parse(l){let r="",s=0,c=0,v=0;const u=new n,p=new o,d=new n,m=new t,w=[];return l.traverse(function(n){!0===n.isMesh&&function(n){let o=0,t=0,f=0;const i=n.geometry,l=new e,p=i.getAttribute("position"),a=i.getAttribute("normal"),L=i.getAttribute("uv"),g=i.getIndex();if(r+="o "+n.name+"\n",n.material&&n.material.name&&(r+="usemtl "+n.material.name+"\n"),void 0!==p)for(let t=0,e=p.count;t<e;t++,o++)u.fromBufferAttribute(p,t),u.applyMatrix4(n.matrixWorld),r+="v "+u.x+" "+u.y+" "+u.z+"\n";if(void 0!==L)for(let n=0,o=L.count;n<o;n++,f++)m.fromBufferAttribute(L,n),r+="vt "+m.x+" "+m.y+"\n";if(void 0!==a){l.getNormalMatrix(n.matrixWorld);for(let n=0,o=a.count;n<o;n++,t++)d.fromBufferAttribute(a,n),d.applyMatrix3(l).normalize(),r+="vn "+d.x+" "+d.y+" "+d.z+"\n"}if(null!==g)for(let n=0,o=g.count;n<o;n+=3){for(let o=0;o<3;o++){const t=g.getX(n+o)+1;w[o]=s+t+(a||L?"/"+(L?c+t:"")+(a?"/"+(v+t):""):"")}r+="f "+w.join(" ")+"\n"}else for(let n=0,o=p.count;n<o;n+=3){for(let o=0;o<3;o++){const t=n+o+1;w[o]=s+t+(a||L?"/"+(L?c+t:"")+(a?"/"+(v+t):""):"")}r+="f "+w.join(" ")+"\n"}s+=o,c+=f,v+=t}(n),!0===n.isLine&&function(n){let o=0;const t=n.geometry,e=n.type,f=t.getAttribute("position");if(r+="o "+n.name+"\n",void 0!==f)for(let t=0,e=f.count;t<e;t++,o++)u.fromBufferAttribute(f,t),u.applyMatrix4(n.matrixWorld),r+="v "+u.x+" "+u.y+" "+u.z+"\n";if("Line"===e){r+="l ";for(let n=1,o=f.count;n<=o;n++)r+=s+n+" ";r+="\n"}if("LineSegments"===e)for(let n=1,o=n+1,t=f.count;n<t;n+=2,o=n+1)r+="l "+(s+n)+" "+(s+o)+"\n";s+=o}(n),!0===n.isPoints&&function(n){let o=0;const t=n.geometry,e=t.getAttribute("position"),l=t.getAttribute("color");if(r+="o "+n.name+"\n",void 0!==e){for(let t=0,s=e.count;t<s;t++,o++)u.fromBufferAttribute(e,t),u.applyMatrix4(n.matrixWorld),r+="v "+u.x+" "+u.y+" "+u.z,void 0!==l&&(p.fromBufferAttribute(l,t),f.workingToColorSpace(p,i),r+=" "+p.r+" "+p.g+" "+p.b),r+="\n";r+="p ";for(let n=1,o=e.count;n<=o;n++)r+=s+n+" ";r+="\n"}s+=o}(n)}),r}}export{l as OBJExporter};
@@ -0,0 +1 @@
1
+ import{Color as n,Vector3 as t,Matrix3 as e,ColorManagement as o,SRGBColorSpace as r}from"three";class l{parse(l,i,a={}){function f(n){l.traverse(function(t){if(!0===t.isMesh||t.isPoints){const e=t,o=e.geometry;!0===o.hasAttribute("position")&&n(e,o)}})}const p=(a=Object.assign({binary:!1,excludeAttributes:[],littleEndian:!1},a)).excludeAttributes;let u=!0,c=!1,s=!1,y=!1,d=0,h=0;l.traverse(function(n){if(!0===n.isMesh){const t=n.geometry,e=t.getAttribute("position"),o=t.getAttribute("normal"),r=t.getAttribute("uv"),l=t.getAttribute("color"),i=t.getIndex();if(void 0===e)return;d+=e.count,h+=i?i.count/3:e.count/3,void 0!==o&&(c=!0),void 0!==r&&(y=!0),void 0!==l&&(s=!0)}else if(n.isPoints){const t=n.geometry,e=t.getAttribute("position"),o=t.getAttribute("normal"),r=t.getAttribute("color");d+=e.count,void 0!==o&&(c=!0),void 0!==r&&(s=!0),u=!1}});const $=new n;if(u=u&&-1===p.indexOf("index"),c=c&&-1===p.indexOf("normal"),s=s&&-1===p.indexOf("color"),y=y&&-1===p.indexOf("uv"),u&&h!==Math.floor(h))return null;let m=`ply\nformat ${a.binary?a.littleEndian?"binary_little_endian":"binary_big_endian":"ascii"} 1.0\nelement vertex ${d}\nproperty float x\nproperty float y\nproperty float z\n`;!0===c&&(m+="property float nx\nproperty float ny\nproperty float nz\n"),!0===y&&(m+="property float s\nproperty float t\n"),!0===s&&(m+="property uchar red\nproperty uchar green\nproperty uchar blue\n"),!0===u&&(m+=`element face ${h}\nproperty list uchar int vertex_index\n`),m+="end_header\n";const v=new t,x=new e;let w=null;if(!0===a.binary){const n=(new TextEncoder).encode(m),t=d*(12+(c?12:0)+(s?3:0)+(y?8:0)),e=u?13*h:0,l=new DataView(new ArrayBuffer(n.length+t+e));new Uint8Array(l.buffer).set(n,0);let i=n.length,p=n.length+t,b=0;f(function(n,t){const e=t.getAttribute("position"),f=t.getAttribute("normal"),d=t.getAttribute("uv"),h=t.getAttribute("color"),m=t.getIndex();x.getNormalMatrix(n.matrixWorld);for(let t=0,p=e.count;t<p;t++)v.fromBufferAttribute(e,t),v.applyMatrix4(n.matrixWorld),l.setFloat32(i,v.x,a.littleEndian),i+=4,l.setFloat32(i,v.y,a.littleEndian),i+=4,l.setFloat32(i,v.z,a.littleEndian),i+=4,!0===c&&(null!=f?(v.fromBufferAttribute(f,t),v.applyMatrix3(x).normalize(),l.setFloat32(i,v.x,a.littleEndian),i+=4,l.setFloat32(i,v.y,a.littleEndian),i+=4,l.setFloat32(i,v.z,a.littleEndian),i+=4):(l.setFloat32(i,0,a.littleEndian),i+=4,l.setFloat32(i,0,a.littleEndian),i+=4,l.setFloat32(i,0,a.littleEndian),i+=4)),!0===y&&(null!=d?(l.setFloat32(i,d.getX(t),a.littleEndian),i+=4,l.setFloat32(i,d.getY(t),a.littleEndian),i+=4):(l.setFloat32(i,0,a.littleEndian),i+=4,l.setFloat32(i,0,a.littleEndian),i+=4)),!0===s&&(null!=h?($.fromBufferAttribute(h,t),o.workingToColorSpace($,r),l.setUint8(i,Math.floor(255*$.r)),i+=1,l.setUint8(i,Math.floor(255*$.g)),i+=1,l.setUint8(i,Math.floor(255*$.b)),i+=1):(l.setUint8(i,255),i+=1,l.setUint8(i,255),i+=1,l.setUint8(i,255),i+=1));if(!0===u)if(null!==m)for(let n=0,t=m.count;n<t;n+=3)l.setUint8(p,3),p+=1,l.setUint32(p,m.getX(n+0)+b,a.littleEndian),p+=4,l.setUint32(p,m.getX(n+1)+b,a.littleEndian),p+=4,l.setUint32(p,m.getX(n+2)+b,a.littleEndian),p+=4;else for(let n=0,t=e.count;n<t;n+=3)l.setUint8(p,3),p+=1,l.setUint32(p,b+n,a.littleEndian),p+=4,l.setUint32(p,b+n+1,a.littleEndian),p+=4,l.setUint32(p,b+n+2,a.littleEndian),p+=4;b+=e.count}),w=l.buffer}else{let n=0,t="",e="";f(function(l,i){const a=i.getAttribute("position"),f=i.getAttribute("normal"),p=i.getAttribute("uv"),d=i.getAttribute("color"),m=i.getIndex();x.getNormalMatrix(l.matrixWorld);for(let n=0,e=a.count;n<e;n++){v.fromBufferAttribute(a,n),v.applyMatrix4(l.matrixWorld);let e=v.x+" "+v.y+" "+v.z;!0===c&&(null!=f?(v.fromBufferAttribute(f,n),v.applyMatrix3(x).normalize(),e+=" "+v.x+" "+v.y+" "+v.z):e+=" 0 0 0"),!0===y&&(e+=null!=p?" "+p.getX(n)+" "+p.getY(n):" 0 0"),!0===s&&(null!=d?($.fromBufferAttribute(d,n),o.workingToColorSpace($,r),e+=" "+Math.floor(255*$.r)+" "+Math.floor(255*$.g)+" "+Math.floor(255*$.b)):e+=" 255 255 255"),t+=e+"\n"}if(!0===u){if(null!==m)for(let t=0,o=m.count;t<o;t+=3)e+=`3 ${m.getX(t+0)+n}`,e+=` ${m.getX(t+1)+n}`,e+=` ${m.getX(t+2)+n}\n`;else for(let t=0,o=a.count;t<o;t+=3)e+=`3 ${n+t} ${n+t+1} ${n+t+2}\n`;h+=m?m.count/3:a.count/3}n+=a.count}),w=`${m}${t}${u?`${e}\n`:"\n"}`}return"function"==typeof i&&requestAnimationFrame(()=>i(w)),w}}export{l as PLYExporter};
@@ -0,0 +1 @@
1
+ import{Vector3 as e}from"three";class t{parse(t,n={}){const o=(n=Object.assign({binary:!1},n)).binary,r=[];let l,i=0;t.traverse(function(e){if(e.isMesh){const t=e.geometry,n=t.index,o=t.getAttribute("position");i+=null!==n?n.count/3:o.count/3,r.push({object3d:e,geometry:t})}});let f=80;if(!0===o){const e=new ArrayBuffer(2*i+3*i*4*4+80+4);l=new DataView(e),l.setUint32(f,i,!0),f+=4}else l="",l+="solid exported\n";const c=new e,s=new e,a=new e,p=new e,u=new e,w=new e;for(let e=0,t=r.length;e<t;e++){const t=r[e].object3d,n=r[e].geometry,o=n.index,l=n.getAttribute("position");if(null!==o)for(let e=0;e<o.count;e+=3){d(o.getX(e+0),o.getX(e+1),o.getX(e+2),l,t)}else for(let e=0;e<l.count;e+=3){d(e+0,e+1,e+2,l,t)}}return!1===o&&(l+="endsolid exported\n"),l;function d(e,t,n,r,i){c.fromBufferAttribute(r,e),s.fromBufferAttribute(r,t),a.fromBufferAttribute(r,n),!0===i.isSkinnedMesh&&(i.applyBoneTransform(e,c),i.applyBoneTransform(t,s),i.applyBoneTransform(n,a)),c.applyMatrix4(i.matrixWorld),s.applyMatrix4(i.matrixWorld),a.applyMatrix4(i.matrixWorld),function(e,t,n){p.subVectors(n,t),u.subVectors(e,t),p.cross(u).normalize(),w.copy(p).normalize(),!0===o?(l.setFloat32(f,w.x,!0),f+=4,l.setFloat32(f,w.y,!0),f+=4,l.setFloat32(f,w.z,!0),f+=4):(l+="\tfacet normal "+w.x+" "+w.y+" "+w.z+"\n",l+="\t\touter loop\n")}(c,s,a),m(c),m(s),m(a),!0===o?(l.setUint16(f,0,!0),f+=2):(l+="\t\tendloop\n",l+="\tendfacet\n")}function m(e){!0===o?(l.setFloat32(f,e.x,!0),f+=4,l.setFloat32(f,e.y,!0),f+=4,l.setFloat32(f,e.z,!0),f+=4):l+="\t\t\tvertex "+e.x+" "+e.y+" "+e.z+"\n"}}}export{t as STLExporter};
@@ -0,0 +1 @@
1
+ import{Loader as e,FileLoader as t,SRGBColorSpace as r,LinearSRGBColorSpace as s,BufferGeometry as n,BufferAttribute as o,Color as i,ColorManagement as c}from"three";const a=new WeakMap;class h extends e{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,r,s,n){const o=new t(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,e=>{this.parse(e,r,n)},s,n)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,r,s).catch(s)}decodeDracoFile(e,t,r,n,o=s,i=()=>{}){const c={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r,vertexColorSpace:o};return this.decodeGeometry(e,c).then(t).catch(i)}decodeGeometry(e,t){const r=JSON.stringify(t);if(a.has(e)){const t=a.get(e);if(t.key===r)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const n=this.workerNextTaskID++,o=e.byteLength,i=this.t(n,o).then(r=>(s=r,new Promise((r,o)=>{s.o[n]={resolve:r,reject:o},s.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(e=>this.i(e.geometry));return i.catch(()=>!0).then(()=>{s&&n&&this.h(s,n)}),a.set(e,{key:r,promise:i}),i}i(e){const t=new n;e.index&&t.setIndex(new o(e.index.array,1));for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r],n=s.name,i=s.array,c=s.itemSize,a=new o(i,c);"color"===n&&(this.u(a,s.vertexColorSpace),a.normalized=i instanceof Float32Array==!1),t.setAttribute(n,a)}return t}u(e,t){if(t!==r)return;const s=new i;for(let t=0,n=e.count;t<n;t++)s.fromBufferAttribute(e,t),c.colorSpaceToWorking(s,r),e.setXYZ(t,s.r,s.g,s.b)}l(e,r){const s=new t(this.manager);return s.setPath(this.decoderPath),s.setResponseType(r),s.setWithCredentials(this.withCredentials),new Promise((t,r)=>{s.load(e,t,void 0,r)})}preload(){return this.p(),this}p(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this.l("draco_decoder.js","text")):(t.push(this.l("draco_wasm_wrapper.js","text")),t.push(this.l("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{const r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const s=u.toString(),n=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}t(e,t){return this.p().then(()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e.o={},e.m={},e.A=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const r=t.data;switch(r.type){case"decode":e.o[r.id].resolve(r);break;case"error":e.o[r.id].reject(r)}},this.workerPool.push(e)}else this.workerPool.sort(function(e,t){return e.A>t.A?-1:1});const r=this.workerPool[this.workerPool.length-1];return r.m[e]=t,r.A+=t,r})}h(e,t){e.A-=e.m[t],delete e.o[t],delete e.m[t]}debug(){}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function u(){let e,t;function r(e,t,r,s,n,o){const i=o.num_components(),c=r.num_points()*i,a=c*n.BYTES_PER_ELEMENT,h=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,n),u=e.D(a);t.GetAttributeDataArrayForAllPoints(r,o,h,a,u);const d=new n(e.HEAPF32.buffer,u,c).slice();return e.O(u),{name:s,array:d,itemSize:i}}onmessage=function(s){const n=s.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise(function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)});break;case"decode":const s=n.buffer,o=n.taskConfig;t.then(e=>{const t=e.draco,i=new t.Decoder;try{const e=function(e,t,s,n){const o=n.attributeIDs,i=n.attributeTypes;let c,a;const h=t.GetEncodedGeometryType(s);if(h===e.TRIANGULAR_MESH)c=new e.Mesh,a=t.DecodeArrayToMesh(s,s.byteLength,c);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");c=new e.PointCloud,a=t.DecodeArrayToPointCloud(s,s.byteLength,c)}if(!a.ok()||0===c.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+a.error_msg());const u={index:null,attributes:[]};for(const s in o){const a=self[i[s]];let h,d;if(n.useUniqueIDs)d=o[s],h=t.GetAttributeByUniqueId(c,d);else{if(d=t.GetAttributeId(c,e[o[s]]),-1===d)continue;h=t.GetAttribute(c,d)}const l=r(e,t,c,s,a,h);"color"===s&&(l.vertexColorSpace=n.vertexColorSpace),u.attributes.push(l)}h===e.TRIANGULAR_MESH&&(u.index=function(e,t,r){const s=r.num_faces(),n=3*s,o=4*n,i=e.D(o);t.GetTrianglesUInt32Array(r,o,i);const c=new Uint32Array(e.HEAPF32.buffer,i,n).slice();return e.O(i),{array:c,itemSize:1}}(e,t,c));return e.destroy(c),u}(t,i,new Int8Array(s),o),c=e.attributes.map(e=>e.array.buffer);e.index&&c.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},c)}catch(e){self.postMessage({type:"error",id:n.id,error:e.message})}finally{t.destroy(i)}})}}}export{h as DRACOLoader};