@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.
- package/dist/bundle/index.js +1 -15498
- package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +1 -366
- package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -1448
- package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1292
- package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4374
- package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -465
- package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
- package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -117
- package/dist/cjs/src/analysis/analysis.js +1 -0
- package/dist/cjs/src/analysis/testing.js +1 -0
- package/dist/cjs/src/core/centralPlant.js +1 -0
- package/dist/cjs/src/core/debugLogger.js +1 -0
- package/dist/cjs/src/core/mathUtils.js +1 -0
- package/dist/cjs/src/core/nameUtils.js +1 -0
- package/dist/cjs/src/data/export.js +1 -0
- package/dist/cjs/src/data/import.js +1 -0
- package/dist/cjs/src/data/numerics.js +1 -0
- package/dist/cjs/src/helpers/sceneHelper.js +1 -0
- package/dist/cjs/src/index.js +1 -79
- package/dist/cjs/src/managers/components/animationManager.js +1 -0
- package/dist/cjs/src/managers/components/componentManager.js +1 -0
- package/dist/cjs/src/managers/components/pathfindingManager.js +1 -0
- package/dist/cjs/src/managers/controls/TransformControls.js +1 -0
- package/dist/cjs/src/managers/controls/cameraControlsManager.js +1 -0
- package/dist/cjs/src/managers/controls/dragDropManager.js +1 -0
- package/dist/cjs/src/managers/controls/keyboardControlsManager.js +1 -0
- package/dist/cjs/src/managers/controls/transformControlsManager.js +1 -0
- package/dist/cjs/src/managers/environment/environmentManager.js +1 -0
- package/dist/cjs/src/managers/environment/textureConfig.js +1 -0
- package/dist/cjs/src/managers/scene/sceneExportManager.js +1 -0
- package/dist/cjs/src/managers/scene/sceneInitializationManager.js +1 -0
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1 -0
- package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +1 -0
- package/dist/cjs/src/managers/system/disposalManager.js +1 -0
- package/dist/cjs/src/managers/system/hotReloadManager.js +1 -0
- package/dist/cjs/src/managers/system/performanceMonitor.js +1 -0
- package/dist/cjs/src/rendering/modelPreloader.js +1 -0
- package/dist/cjs/src/rendering/rendering2D.js +1 -0
- package/dist/cjs/src/rendering/rendering3D.js +1 -0
- package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -339
- package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1 -1444
- package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1 -1287
- package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +1 -4370
- package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +1 -461
- package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +1 -0
- package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +1 -113
- package/dist/esm/src/analysis/analysis.js +1 -0
- package/dist/esm/src/analysis/testing.js +1 -0
- package/dist/esm/src/core/centralPlant.js +1 -0
- package/dist/esm/src/core/debugLogger.js +1 -0
- package/dist/esm/src/core/mathUtils.js +1 -0
- package/dist/esm/src/core/nameUtils.js +1 -0
- package/dist/esm/src/data/export.js +1 -0
- package/dist/esm/src/data/import.js +1 -0
- package/dist/esm/src/data/numerics.js +1 -0
- package/dist/esm/src/helpers/sceneHelper.js +1 -0
- package/dist/esm/src/index.js +1 -70
- package/dist/esm/src/managers/components/animationManager.js +1 -0
- package/dist/esm/src/managers/components/componentManager.js +1 -0
- package/dist/esm/src/managers/components/pathfindingManager.js +1 -0
- package/dist/esm/src/managers/controls/TransformControls.js +1 -0
- package/dist/esm/src/managers/controls/cameraControlsManager.js +1 -0
- package/dist/esm/src/managers/controls/dragDropManager.js +1 -0
- package/dist/esm/src/managers/controls/keyboardControlsManager.js +1 -0
- package/dist/esm/src/managers/controls/transformControlsManager.js +1 -0
- package/dist/esm/src/managers/environment/environmentManager.js +1 -0
- package/dist/esm/src/managers/environment/textureConfig.js +1 -0
- package/dist/esm/src/managers/scene/sceneExportManager.js +1 -0
- package/dist/esm/src/managers/scene/sceneInitializationManager.js +1 -0
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +1 -0
- package/dist/esm/src/managers/scene/sceneTooltipsManager.js +1 -0
- package/dist/esm/src/managers/system/disposalManager.js +1 -0
- package/dist/esm/src/managers/system/hotReloadManager.js +1 -0
- package/dist/esm/src/managers/system/performanceMonitor.js +1 -0
- package/dist/esm/src/rendering/modelPreloader.js +1 -0
- package/dist/esm/src/rendering/rendering2D.js +1 -0
- package/dist/esm/src/rendering/rendering3D.js +1 -0
- package/dist/index.d.ts +52 -255
- package/package.json +3 -6
- package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1543
- package/dist/cjs/src/animationManager.js +0 -121
- package/dist/cjs/src/componentManager.js +0 -151
- package/dist/cjs/src/debugLogger.js +0 -176
- package/dist/cjs/src/disposalManager.js +0 -185
- package/dist/cjs/src/environmentManager.js +0 -1308
- package/dist/cjs/src/hotReloadManager.js +0 -252
- package/dist/cjs/src/keyboardControlsManager.js +0 -206
- package/dist/cjs/src/nameUtils.js +0 -106
- package/dist/cjs/src/pathfindingManager.js +0 -503
- package/dist/cjs/src/performanceMonitor.js +0 -718
- package/dist/cjs/src/sceneExportManager.js +0 -292
- package/dist/cjs/src/sceneInitializationManager.js +0 -540
- package/dist/cjs/src/textureConfig.js +0 -624
- package/dist/cjs/src/transformControlsManager.js +0 -851
- package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +0 -1537
- package/dist/esm/src/animationManager.js +0 -112
- package/dist/esm/src/componentManager.js +0 -123
- package/dist/esm/src/debugLogger.js +0 -167
- package/dist/esm/src/disposalManager.js +0 -155
- package/dist/esm/src/environmentManager.js +0 -1282
- package/dist/esm/src/hotReloadManager.js +0 -244
- package/dist/esm/src/keyboardControlsManager.js +0 -196
- package/dist/esm/src/nameUtils.js +0 -99
- package/dist/esm/src/pathfindingManager.js +0 -479
- package/dist/esm/src/performanceMonitor.js +0 -712
- package/dist/esm/src/sceneExportManager.js +0 -286
- package/dist/esm/src/sceneInitializationManager.js +0 -513
- package/dist/esm/src/textureConfig.js +0 -595
- package/dist/esm/src/transformControlsManager.js +0 -827
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var t=require("three");const e={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 n{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(t){return new F(t)}),this.register(function(t){return new z(t)}),this.register(function(t){return new k(t)}),this.register(function(t){return new D(t)}),this.register(function(t){return new G(t)}),this.register(function(t){return new V(t)}),this.register(function(t){return new U(t)}),this.register(function(t){return new B(t)}),this.register(function(t){return new K(t)}),this.register(function(t){return new j(t)}),this.register(function(t){return new P(t)}),this.register(function(t){return new X(t)}),this.register(function(t){return new q(t)}),this.register(function(t){return new J(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 S,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 s=0,i=1,r=2,o=3,a=4,c=5120,h=5121,u=5122,l=5123,f=5124,w=5125,d=5126,y=34962,m=34963,p=9728,A=9729,T=9984,x=9985,g=9986,b=9987,E=33071,M=33648,_=10497,v="KHR_mesh_quantization",O={};O[t.NearestFilter]=p,O[t.NearestMipmapNearestFilter]=T,O[t.NearestMipmapLinearFilter]=g,O[t.LinearFilter]=A,O[t.LinearMipmapNearestFilter]=x,O[t.LinearMipmapLinearFilter]=b,O[t.ClampToEdgeWrapping]=E,O[t.RepeatWrapping]=_,O[t.MirroredRepeatWrapping]=M;const C={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},R=new t.Color;function I(t,e){return t.length===e.length&&t.every(function(t,n){return t===e[n]})}function N(t){return 4*Math.ceil(t/4)}function H(t,e=0){const n=N(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 L(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}class S{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"+t.REVISION}},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),u=Object.keys(a);if(h.length>0&&(r.extensionsUsed=h),u.length>0&&(r.extensionsRequired=u),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=H(t.result),s=new DataView(new ArrayBuffer(8));s.setUint32(0,n.byteLength,!0),s.setUint32(4,5130562,!0);const i=H((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 u=12+a.byteLength+i.byteLength+s.byteLength+n.byteLength;h.setUint32(8,u,!0);const l=new Blob([c,a,i,s,n],{type:"application/octet-stream"}),f=new FileReader;f.readAsArrayBuffer(l),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(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new t.Vector3;for(let t=0,s=e.count;t<s;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const n=this.cache;if(n.attributesNormalized.has(e))return n.attributesNormalized.get(e);const s=e.clone(),i=new t.Vector3;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 n.attributesNormalized.set(e,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(e,n){if(e===n)return e;function s(e){return e.colorSpace===t.SRGBColorSpace?function(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}:function(t){return t}}e instanceof t.CompressedTexture&&(e=await this.decompressTextureAsync(e)),n instanceof t.CompressedTexture&&(n=await this.decompressTextureAsync(n));const i=e?e.image:null,r=n?n.image:null,o=Math.max(i?i.width:0,r?r.width:0),a=Math.max(i?i.height:0,r?r.height:0),c=L();c.width=o,c.height=a;const h=c.getContext("2d",{willReadFrequently:!0});h.fillStyle="#00ffff",h.fillRect(0,0,o,a);const u=h.getImageData(0,0,o,a);if(i){h.drawImage(i,0,0,o,a);const t=s(e),n=h.getImageData(0,0,o,a).data;for(let e=2;e<n.length;e+=4)u.data[e]=256*t(n[e]/256)}if(r){h.drawImage(r,0,0,o,a);const t=s(n),e=h.getImageData(0,0,o,a).data;for(let n=1;n<e.length;n+=4)u.data[n]=256*t(e[n]/256)}h.putImageData(u,0,0);const l=(e||n).clone();return l.source=new t.Source(c),l.colorSpace=t.NoColorSpace,l.channel=(e||n).channel,e&&n&&(e.channel,n.channel),l}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(e,n,s,i,r){const o=this.json;let a;switch(o.bufferViews||(o.bufferViews=[]),n){case c:case h:a=1;break;case u:case l:a=2;break;default:a=4}let m=e.itemSize*a;r===y&&(m=4*Math.ceil(m/4));const p=N(i*m),A=new DataView(new ArrayBuffer(p));let T=0;for(let r=s;r<s+i;r++){for(let s=0;s<e.itemSize;s++){let i;e.itemSize>4?i=e.array[r*e.itemSize+s]:(0===s?i=e.getX(r):1===s?i=e.getY(r):2===s?i=e.getZ(r):3===s&&(i=e.getW(r)),!0===e.normalized&&(i=t.MathUtils.normalize(i,e.array))),n===d?A.setFloat32(T,i,!0):n===f?A.setInt32(T,i,!0):n===w?A.setUint32(T,i,!0):n===u?A.setInt16(T,i,!0):n===l?A.setUint16(T,i,!0):n===c?A.setInt8(T,i):n===h&&A.setUint8(T,i),T+=a}T%m!==0&&(T+=m-T%m)}const x={buffer:this.processBuffer(A.buffer),byteOffset:this.byteOffset,byteLength:p};void 0!==r&&(x.target=r),r===y&&(x.byteStride=m),this.byteOffset+=p,o.bufferViews.push(x);return{id:o.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=H(i.result),r={buffer:e.processBuffer(t),byteOffset:e.byteOffset,byteLength:t.byteLength};e.byteOffset+=t.byteLength,s(n.bufferViews.push(r)-1)}})}processAccessor(e,n,s,i){const r=this.json;let o;if(e.array.constructor===Float32Array)o=d;else if(e.array.constructor===Int32Array)o=f;else if(e.array.constructor===Uint32Array)o=w;else if(e.array.constructor===Int16Array)o=u;else if(e.array.constructor===Uint16Array)o=l;else if(e.array.constructor===Int8Array)o=c;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);o=h}if(void 0===s&&(s=0),void 0!==i&&i!==1/0||(i=e.count),0===i)return null;const a=function(e,n,s){const i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=n;r<n+s;r++)for(let n=0;n<e.itemSize;n++){let s;e.itemSize>4?s=e.array[r*e.itemSize+n]:(0===n?s=e.getX(r):1===n?s=e.getY(r):2===n?s=e.getZ(r):3===n&&(s=e.getW(r)),!0===e.normalized&&(s=t.MathUtils.normalize(s,e.array))),i.min[n]=Math.min(i.min[n],s),i.max[n]=Math.max(i.max[n],s)}return i}(e,s,i);let p;void 0!==n&&(p=e===n.index?m:y);const A=this.processBufferView(e,o,s,i,p),T={bufferView:A.id,byteOffset:A.byteOffset,componentType:o,count:i,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(T.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(T)-1}processImage(e,n,s,i="image/png"){if(null!==e){const n=this,r=n.cache,o=n.json,a=n.options,c=n.pending;r.images.has(e)||r.images.set(e,{});const h=r.images.get(e),u=i+":flipY/"+s.toString();if(void 0!==h[u])return h[u];o.images||(o.images=[]);const l={mimeType:i},f=L();f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);const w=f.getContext("2d",{willReadFrequently:!0});if(!0===s&&(w.translate(0,f.height),w.scale(1,-1)),void 0!==e.data){t.RGBAFormat,e.width>a.maxTextureSize||(e.height,a.maxTextureSize);const n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];w.putImageData(new ImageData(n,e.width,e.height),0,0)}else{if(!("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas))throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");w.drawImage(e,0,0,f.width,f.height)}!0===a.binary?c.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,i).then(t=>n.processBufferViewImage(t)).then(t=>{l.bufferView=t})):l.uri=t.ImageUtils.getDataURL(f,i);const d=o.images.push(l)-1;return h[u]=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:O[t.magFilter],minFilter:O[t.minFilter],wrapS:O[t.wrapS],wrapT:O[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(e){const n=this.options,s=this.cache,i=this.json;if(s.textures.has(e))return s.textures.get(e);i.textures||(i.textures=[]),e instanceof t.CompressedTexture&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));let r=e.userData.mimeType;"image/webp"===r&&(r="image/png");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(o.name=e.name),await this.i(async function(t){t.writeTexture&&await t.writeTexture(e,o)});const a=i.textures.push(o)-1;return s.textures.set(e,a),a}async processMaterialAsync(e){const n=this.cache,s=this.json;if(n.materials.has(e))return n.materials.get(e);if(e.isShaderMaterial)return null;s.materials||(s.materials=[]);const i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&e.isMeshBasicMaterial;const r=e.color.toArray().concat([e.opacity]);if(I(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){const t=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),n={index:await this.processTextureAsync(t),texCoord:t.channel};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){const t={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const t={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){const t={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){const t={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===t.DoubleSide&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),await this.i(async function(t){t.writeMaterialAsync&&await t.writeMaterialAsync(e,i)});const o=s.materials.push(i)-1;return n.materials.set(e,o),o}async processMeshAsync(e){const c=this.cache,h=this.json,u=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)u.push(e.material[t].uuid);else u.push(e.material.uuid);const l=u.join(":");if(c.meshes.has(l))return c.meshes.get(l);const f=e.geometry;let w;w=e.isLineSegments?i:e.isLineLoop?r:e.isLine?o:e.isPoints?s:e.material.wireframe?i:a;const d={},y={},m=[],p=[],A={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},T=f.getAttribute("normal");void 0===T||this.isNormalizedNormalAttribute(T)||f.setAttribute("normal",this.createNormalizedNormalAttribute(T));let x=null;for(let e in f.attributes){if("morph"===e.slice(0,5))continue;const s=f.attributes[e];e=A[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),c.attributes.has(this.getUID(s))){y[e]=c.attributes.get(this.getUID(s));continue}x=null;const i=s.array;"JOINTS_0"!==e||i instanceof Uint16Array||i instanceof Uint8Array?(i instanceof Uint32Array||i instanceof Int32Array)&&!e.startsWith("_")&&(x=n.Utils.toFloat32BufferAttribute(s)):x=new t.BufferAttribute(new Uint16Array(i),s.itemSize,s.normalized);const r=this.processAccessor(x||s,f);null!==r&&(e.startsWith("_")||this.detectMeshQuantization(e,s),y[e]=r,c.attributes.set(this.getUID(s),r))}if(void 0!==T&&f.setAttribute("normal",T),0===Object.keys(y).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const t=[],n=[],s={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)s[e.morphTargetDictionary[t]]=t;for(let i=0;i<e.morphTargetInfluences.length;++i){const r={};let o=!1;for(const t in f.morphAttributes){if("position"!==t&&"normal"!==t){o||(o=!0);continue}const e=f.morphAttributes[t][i],n=t.toUpperCase(),s=f.attributes[t];if(c.attributes.has(this.getUID(e,!0))){r[n]=c.attributes.get(this.getUID(e,!0));continue}const a=e.clone();if(!f.morphTargetsRelative)for(let t=0,n=e.count;t<n;t++)for(let n=0;n<e.itemSize;n++)0===n&&a.setX(t,e.getX(t)-s.getX(t)),1===n&&a.setY(t,e.getY(t)-s.getY(t)),2===n&&a.setZ(t,e.getZ(t)-s.getZ(t)),3===n&&a.setW(t,e.getW(t)-s.getW(t));r[n]=this.processAccessor(a,f),c.attributes.set(this.getUID(s,!0),r[n])}p.push(r),t.push(e.morphTargetInfluences[i]),void 0!==e.morphTargetDictionary&&n.push(s[i])}d.weights=t,n.length>0&&(d.extras={},d.extras.targetNames=n)}const g=Array.isArray(e.material);if(g&&0===f.groups.length)return null;let b=!1;if(g&&null===f.index){const t=[];for(let e=0,n=f.attributes.position.count;e<n;e++)t[e]=e;f.setIndex(t),b=!0}const E=g?e.material:[e.material],M=g?f.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let t=0,e=M.length;t<e;t++){const e={mode:w,attributes:y};if(this.serializeUserData(f,e),p.length>0&&(e.targets=p),null!==f.index){let n=this.getUID(f.index);void 0===M[t].start&&void 0===M[t].count||(n+=":"+M[t].start+":"+M[t].count),c.attributes.has(n)?e.indices=c.attributes.get(n):(e.indices=this.processAccessor(f.index,f,M[t].start,M[t].count),c.attributes.set(n,e.indices)),null===e.indices&&delete e.indices}const n=await this.processMaterialAsync(E[M[t].materialIndex]);null!==n&&(e.material=n),m.push(e)}!0===b&&f.setIndex(null),d.primitives=m,h.meshes||(h.meshes=[]),await this.i(function(t){t.writeMesh&&t.writeMesh(e,d)});const _=h.meshes.push(d)-1;return c.meshes.set(l,_),_}detectMeshQuantization(t,n){if(this.extensionsUsed[v])return;let s;switch(n.array.constructor){case Int8Array:s="byte";break;case Uint8Array:s="unsigned byte";break;case Int16Array:s="short";break;case Uint16Array:s="unsigned short";break;default:return}n.normalized&&(s+=" normalized");const i=t.split("_",1)[0];e[i]&&e[i].includes(s)&&(this.extensionsUsed[v]=!0,this.extensionsRequired[v]=!0)}processCamera(e){const n=this.json;n.cameras||(n.cameras=[]);const s=e.isOrthographicCamera,i={type:s?"orthographic":"perspective"};return s?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:t.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),n.cameras.push(i)-1}processAnimation(e,s){const i=this.json,r=this.nodeMap;i.animations||(i.animations=[]);const o=(e=n.Utils.mergeMorphTargetTracks(e.clone(),s)).tracks,a=[],c=[];for(let e=0;e<o.length;++e){const n=o[e],i=t.PropertyBinding.parseTrackName(n.name);let h=t.PropertyBinding.findNode(s,i.nodeName);const u=C[i.propertyName];if("bones"===i.objectName&&(h=!0===h.isSkinnedMesh?h.skeleton.getBoneByName(i.objectIndex):void 0),!h||!u)continue;const l=1;let f,w=n.values.length/n.times.length;u===C.morphTargetInfluences&&(w/=h.morphTargetInfluences.length),!0===n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(f="CUBICSPLINE",w/=3):f=n.getInterpolation()===t.InterpolateDiscrete?"STEP":"LINEAR",c.push({input:this.processAccessor(new t.BufferAttribute(n.times,l)),output:this.processAccessor(new t.BufferAttribute(n.values,w)),interpolation:f}),a.push({sampler:c.length-1,target:{node:r.get(h),path:u}})}return i.animations.push({name:e.name||"clip_"+i.animations.length,samplers:c,channels:a}),i.animations.length-1}processSkin(e){const n=this.json,s=this.nodeMap,i=n.nodes[s.get(e)],r=e.skeleton;if(void 0===r)return null;const o=e.skeleton.bones[0];if(void 0===o)return null;const a=[],c=new Float32Array(16*r.bones.length),h=new t.Matrix4;for(let t=0;t<r.bones.length;++t)a.push(s.get(r.bones[t])),h.copy(r.boneInverses[t]),h.multiply(e.bindMatrix).toArray(c,16*t);void 0===n.skins&&(n.skins=[]),n.skins.push({inverseBindMatrices:this.processAccessor(new t.BufferAttribute(c,16)),joints:a,skeleton:s.get(o)});return i.skin=n.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();I(e,[0,0,0,1])||(i.rotation=e),I(n,[0,0,0])||(i.translation=n),I(s,[1,1,1])||(i.scale=s)}else t.matrixAutoUpdate&&t.updateMatrix(),!1===I(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.i(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(e){const n=new t.Scene;n.name="AuxScene";for(let t=0;t<e.length;t++)n.children.push(e[t]);await this.processSceneAsync(n)}async processInputAsync(e){const n=this.options;e=e instanceof Array?e:[e],await this.i(function(t){t.beforeParse&&t.beforeParse(e)});const s=[];for(let n=0;n<e.length;n++)e[n]instanceof t.Scene?await this.processSceneAsync(e[n]):s.push(e[n]);s.length>0&&await this.processObjectsAsync(s);for(let t=0;t<this.skins.length;++t)this.processSkin(this.skins[t]);for(let t=0;t<n.animations.length;++t)this.processAnimation(n.animations[t],e[0]);await this.i(function(t){t.afterParse&&t.afterParse(e)})}async i(t){for(let e=0,n=this.plugins.length;e<n;e++)await t(this.plugins[e])}}class F{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 z{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 U{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 B{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 K{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 k{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 D{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 G{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 V{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||1===t.specularIntensity&&t.specularColor.equals(R)&&!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 j{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 P{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 X{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 q{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 J{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(e,n){if(!e.isInstancedMesh)return;const s=this.writer,i=e,r=new Float32Array(3*i.count),o=new Float32Array(4*i.count),a=new Float32Array(3*i.count),c=new t.Matrix4,h=new t.Vector3,u=new t.Quaternion,l=new t.Vector3;for(let t=0;t<i.count;t++)i.getMatrixAt(t,c),c.decompose(h,u,l),h.toArray(r,3*t),u.toArray(o,4*t),l.toArray(a,3*t);const f={TRANSLATION:s.processAccessor(new t.BufferAttribute(r,3)),ROTATION:s.processAccessor(new t.BufferAttribute(o,4)),SCALE:s.processAccessor(new t.BufferAttribute(a,3))};i.instanceColor&&(f.o=s.processAccessor(i.instanceColor)),n.extensions=n.extensions||{},n.extensions[this.name]={attributes:f},s.extensionsUsed[this.name]=!0,s.extensionsRequired[this.name]=!0}}n.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(e,n){const s=[],i={},r=e.tracks;for(let e=0;e<r.length;++e){let o=r[e];const a=t.PropertyBinding.parseTrackName(o.name),c=t.PropertyBinding.findNode(n,a.nodeName);if("morphTargetInfluences"!==a.propertyName||void 0===a.propertyIndex){s.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");o=o.clone(),o.setInterpolation(t.InterpolateLinear)}const h=c.morphTargetInfluences.length,u=c.morphTargetDictionary[a.propertyIndex];if(void 0===u)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let l;if(void 0===i[c.uuid]){l=o.clone();const t=new l.ValueBufferType(h*l.times.length);for(let e=0;e<l.times.length;e++)t[e*h+u]=l.values[e];l.name=(a.nodeName||"")+".morphTargetInfluences",l.values=t,i[c.uuid]=l,s.push(l);continue}const f=o.createInterpolant(new o.ValueBufferType(1));l=i[c.uuid];for(let t=0;t<l.times.length;t++)l.values[t*h+u]=f.evaluate(l.times[t]);for(let t=0;t<o.times.length;t++){const e=this.insertKeyframe(l,o.times[t]);l.values[e*h+u]=o.values[t]}}return e.tracks=s,e},toFloat32BufferAttribute:function(e){const n=new t.BufferAttribute(new Float32Array(e.count*e.itemSize),e.itemSize,!1);if(!e.normalized&&!e.isInterleavedBufferAttribute)return n.array.set(e.array),n;for(let t=0,s=e.count;t<s;t++)for(let s=0;s<e.itemSize;s++)n.setComponent(t,s,e.getComponent(t,s));return n}},exports.GLTFExporter=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"o",{value:!0});var n=require("three");exports.OBJExporter=class{parse(o){let e="",t=0,i=0,l=0;const f=new n.Vector3,r=new n.Color,s=new n.Vector3,c=new n.Vector2,v=[];return o.traverse(function(o){!0===o.isMesh&&function(o){let r=0,u=0,d=0;const p=o.geometry,a=new n.Matrix3,w=p.getAttribute("position"),m=p.getAttribute("normal"),x=p.getAttribute("uv"),L=p.getIndex();if(e+="o "+o.name+"\n",o.material&&o.material.name&&(e+="usemtl "+o.material.name+"\n"),void 0!==w)for(let n=0,t=w.count;n<t;n++,r++)f.fromBufferAttribute(w,n),f.applyMatrix4(o.matrixWorld),e+="v "+f.x+" "+f.y+" "+f.z+"\n";if(void 0!==x)for(let n=0,o=x.count;n<o;n++,d++)c.fromBufferAttribute(x,n),e+="vt "+c.x+" "+c.y+"\n";if(void 0!==m){a.getNormalMatrix(o.matrixWorld);for(let n=0,o=m.count;n<o;n++,u++)s.fromBufferAttribute(m,n),s.applyMatrix3(a).normalize(),e+="vn "+s.x+" "+s.y+" "+s.z+"\n"}if(null!==L)for(let n=0,o=L.count;n<o;n+=3){for(let o=0;o<3;o++){const e=L.getX(n+o)+1;v[o]=t+e+(m||x?"/"+(x?i+e:"")+(m?"/"+(l+e):""):"")}e+="f "+v.join(" ")+"\n"}else for(let n=0,o=w.count;n<o;n+=3){for(let o=0;o<3;o++){const e=n+o+1;v[o]=t+e+(m||x?"/"+(x?i+e:"")+(m?"/"+(l+e):""):"")}e+="f "+v.join(" ")+"\n"}t+=r,i+=d,l+=u}(o),!0===o.isLine&&function(n){let o=0;const i=n.geometry,l=n.type,r=i.getAttribute("position");if(e+="o "+n.name+"\n",void 0!==r)for(let t=0,i=r.count;t<i;t++,o++)f.fromBufferAttribute(r,t),f.applyMatrix4(n.matrixWorld),e+="v "+f.x+" "+f.y+" "+f.z+"\n";if("Line"===l){e+="l ";for(let n=1,o=r.count;n<=o;n++)e+=t+n+" ";e+="\n"}if("LineSegments"===l)for(let n=1,o=n+1,i=r.count;n<i;n+=2,o=n+1)e+="l "+(t+n)+" "+(t+o)+"\n";t+=o}(o),!0===o.isPoints&&function(o){let i=0;const l=o.geometry,s=l.getAttribute("position"),c=l.getAttribute("color");if(e+="o "+o.name+"\n",void 0!==s){for(let t=0,l=s.count;t<l;t++,i++)f.fromBufferAttribute(s,t),f.applyMatrix4(o.matrixWorld),e+="v "+f.x+" "+f.y+" "+f.z,void 0!==c&&(r.fromBufferAttribute(c,t),n.ColorManagement.workingToColorSpace(r,n.SRGBColorSpace),e+=" "+r.r+" "+r.g+" "+r.b),e+="\n";e+="p ";for(let n=1,o=s.count;n<=o;n++)e+=t+n+" ";e+="\n"}t+=i}(o)}),e}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var n=require("three");exports.PLYExporter=class{parse(e,t,o={}){function r(n){e.traverse(function(e){if(!0===e.isMesh||e.isPoints){const t=e,o=t.geometry;!0===o.hasAttribute("position")&&n(t,o)}})}const l=(o=Object.assign({binary:!1,excludeAttributes:[],littleEndian:!1},o)).excludeAttributes;let i=!0,a=!1,u=!1,f=!1,p=0,c=0;e.traverse(function(n){if(!0===n.isMesh){const e=n.geometry,t=e.getAttribute("position"),o=e.getAttribute("normal"),r=e.getAttribute("uv"),l=e.getAttribute("color"),i=e.getIndex();if(void 0===t)return;p+=t.count,c+=i?i.count/3:t.count/3,void 0!==o&&(a=!0),void 0!==r&&(f=!0),void 0!==l&&(u=!0)}else if(n.isPoints){const e=n.geometry,t=e.getAttribute("position"),o=e.getAttribute("normal"),r=e.getAttribute("color");p+=t.count,void 0!==o&&(a=!0),void 0!==r&&(u=!0),i=!1}});const s=new n.Color;if(i=i&&-1===l.indexOf("index"),a=a&&-1===l.indexOf("normal"),u=u&&-1===l.indexOf("color"),f=f&&-1===l.indexOf("uv"),i&&c!==Math.floor(c))return null;let y=`ply\nformat ${o.binary?o.littleEndian?"binary_little_endian":"binary_big_endian":"ascii"} 1.0\nelement vertex ${p}\nproperty float x\nproperty float y\nproperty float z\n`;!0===a&&(y+="property float nx\nproperty float ny\nproperty float nz\n"),!0===f&&(y+="property float s\nproperty float t\n"),!0===u&&(y+="property uchar red\nproperty uchar green\nproperty uchar blue\n"),!0===i&&(y+=`element face ${c}\nproperty list uchar int vertex_index\n`),y+="end_header\n";const d=new n.Vector3,v=new n.Matrix3;let h=null;if(!0===o.binary){const e=(new TextEncoder).encode(y),t=p*(12+(a?12:0)+(u?3:0)+(f?8:0)),l=i?13*c:0,$=new DataView(new ArrayBuffer(e.length+t+l));new Uint8Array($.buffer).set(e,0);let m=e.length,x=e.length+t,b=0;r(function(e,t){const r=t.getAttribute("position"),l=t.getAttribute("normal"),p=t.getAttribute("uv"),c=t.getAttribute("color"),y=t.getIndex();v.getNormalMatrix(e.matrixWorld);for(let t=0,i=r.count;t<i;t++)d.fromBufferAttribute(r,t),d.applyMatrix4(e.matrixWorld),$.setFloat32(m,d.x,o.littleEndian),m+=4,$.setFloat32(m,d.y,o.littleEndian),m+=4,$.setFloat32(m,d.z,o.littleEndian),m+=4,!0===a&&(null!=l?(d.fromBufferAttribute(l,t),d.applyMatrix3(v).normalize(),$.setFloat32(m,d.x,o.littleEndian),m+=4,$.setFloat32(m,d.y,o.littleEndian),m+=4,$.setFloat32(m,d.z,o.littleEndian),m+=4):($.setFloat32(m,0,o.littleEndian),m+=4,$.setFloat32(m,0,o.littleEndian),m+=4,$.setFloat32(m,0,o.littleEndian),m+=4)),!0===f&&(null!=p?($.setFloat32(m,p.getX(t),o.littleEndian),m+=4,$.setFloat32(m,p.getY(t),o.littleEndian),m+=4):($.setFloat32(m,0,o.littleEndian),m+=4,$.setFloat32(m,0,o.littleEndian),m+=4)),!0===u&&(null!=c?(s.fromBufferAttribute(c,t),n.ColorManagement.workingToColorSpace(s,n.SRGBColorSpace),$.setUint8(m,Math.floor(255*s.r)),m+=1,$.setUint8(m,Math.floor(255*s.g)),m+=1,$.setUint8(m,Math.floor(255*s.b)),m+=1):($.setUint8(m,255),m+=1,$.setUint8(m,255),m+=1,$.setUint8(m,255),m+=1));if(!0===i)if(null!==y)for(let n=0,e=y.count;n<e;n+=3)$.setUint8(x,3),x+=1,$.setUint32(x,y.getX(n+0)+b,o.littleEndian),x+=4,$.setUint32(x,y.getX(n+1)+b,o.littleEndian),x+=4,$.setUint32(x,y.getX(n+2)+b,o.littleEndian),x+=4;else for(let n=0,e=r.count;n<e;n+=3)$.setUint8(x,3),x+=1,$.setUint32(x,b+n,o.littleEndian),x+=4,$.setUint32(x,b+n+1,o.littleEndian),x+=4,$.setUint32(x,b+n+2,o.littleEndian),x+=4;b+=r.count}),h=$.buffer}else{let e=0,t="",o="";r(function(r,l){const p=l.getAttribute("position"),y=l.getAttribute("normal"),h=l.getAttribute("uv"),$=l.getAttribute("color"),m=l.getIndex();v.getNormalMatrix(r.matrixWorld);for(let e=0,o=p.count;e<o;e++){d.fromBufferAttribute(p,e),d.applyMatrix4(r.matrixWorld);let o=d.x+" "+d.y+" "+d.z;!0===a&&(null!=y?(d.fromBufferAttribute(y,e),d.applyMatrix3(v).normalize(),o+=" "+d.x+" "+d.y+" "+d.z):o+=" 0 0 0"),!0===f&&(o+=null!=h?" "+h.getX(e)+" "+h.getY(e):" 0 0"),!0===u&&(null!=$?(s.fromBufferAttribute($,e),n.ColorManagement.workingToColorSpace(s,n.SRGBColorSpace),o+=" "+Math.floor(255*s.r)+" "+Math.floor(255*s.g)+" "+Math.floor(255*s.b)):o+=" 255 255 255"),t+=o+"\n"}if(!0===i){if(null!==m)for(let n=0,t=m.count;n<t;n+=3)o+=`3 ${m.getX(n+0)+e}`,o+=` ${m.getX(n+1)+e}`,o+=` ${m.getX(n+2)+e}\n`;else for(let n=0,t=p.count;n<t;n+=3)o+=`3 ${e+n} ${e+n+1} ${e+n+2}\n`;c+=m?m.count/3:p.count/3}e+=p.count}),h=`${y}${t}${i?`${o}\n`:"\n"}`}return"function"==typeof t&&requestAnimationFrame(()=>t(h)),h}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var e=require("three");exports.STLExporter=class{parse(t,n={}){const o=(n=Object.assign({binary:!1},n)).binary,r=[];let l,s=0;t.traverse(function(e){if(e.isMesh){const t=e.geometry,n=t.index,o=t.getAttribute("position");s+=null!==n?n.count/3:o.count/3,r.push({object3d:e,geometry:t})}});let i=80;if(!0===o){const e=new ArrayBuffer(2*s+3*s*4*4+80+4);l=new DataView(e),l.setUint32(i,s,!0),i+=4}else l="",l+="solid exported\n";const c=new e.Vector3,f=new e.Vector3,u=new e.Vector3,a=new e.Vector3,d=new e.Vector3,p=new e.Vector3;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){w(o.getX(e+0),o.getX(e+1),o.getX(e+2),l,t)}else for(let e=0;e<l.count;e+=3){w(e+0,e+1,e+2,l,t)}}return!1===o&&(l+="endsolid exported\n"),l;function w(e,t,n,r,s){c.fromBufferAttribute(r,e),f.fromBufferAttribute(r,t),u.fromBufferAttribute(r,n),!0===s.isSkinnedMesh&&(s.applyBoneTransform(e,c),s.applyBoneTransform(t,f),s.applyBoneTransform(n,u)),c.applyMatrix4(s.matrixWorld),f.applyMatrix4(s.matrixWorld),u.applyMatrix4(s.matrixWorld),function(e,t,n){a.subVectors(n,t),d.subVectors(e,t),a.cross(d).normalize(),p.copy(a).normalize(),!0===o?(l.setFloat32(i,p.x,!0),i+=4,l.setFloat32(i,p.y,!0),i+=4,l.setFloat32(i,p.z,!0),i+=4):(l+="\tfacet normal "+p.x+" "+p.y+" "+p.z+"\n",l+="\t\touter loop\n")}(c,f,u),x(c),x(f),x(u),!0===o?(l.setUint16(i,0,!0),i+=2):(l+="\t\tendloop\n",l+="\tendfacet\n")}function x(e){!0===o?(l.setFloat32(i,e.x,!0),i+=4,l.setFloat32(i,e.y,!0),i+=4,l.setFloat32(i,e.z,!0),i+=4):l+="\t\t\tvertex "+e.x+" "+e.y+" "+e.z+"\n"}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"t",{value:!0});var e=require("three");const t=new WeakMap;class r extends e.Loader{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(t,r,s,n){const o=new e.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,e=>{this.parse(e,r,n)},s,n)}parse(t,r,s=()=>{}){this.decodeDracoFile(t,r,null,null,e.SRGBColorSpace,s).catch(s)}decodeDracoFile(t,r,s,n,o=e.LinearSRGBColorSpace,i=()=>{}){const c={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:o};return this.decodeGeometry(t,c).then(r).catch(i)}decodeGeometry(e,r){const s=JSON.stringify(r);if(t.has(e)){const r=t.get(e);if(r.key===s)return r.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 n;const o=this.workerNextTaskID++,i=e.byteLength,c=this.o(o,i).then(t=>(n=t,new Promise((t,s)=>{n.i[o]={resolve:t,reject:s},n.postMessage({type:"decode",id:o,taskConfig:r,buffer:e},[e])}))).then(e=>this.h(e.geometry));return c.catch(()=>!0).then(()=>{n&&o&&this.u(n,o)}),t.set(e,{key:s,promise:c}),c}h(t){const r=new e.BufferGeometry;t.index&&r.setIndex(new e.BufferAttribute(t.index.array,1));for(let s=0;s<t.attributes.length;s++){const n=t.attributes[s],o=n.name,i=n.array,c=n.itemSize,a=new e.BufferAttribute(i,c);"color"===o&&(this.l(a,n.vertexColorSpace),a.normalized=i instanceof Float32Array==!1),r.setAttribute(o,a)}return r}l(t,r){if(r!==e.SRGBColorSpace)return;const s=new e.Color;for(let r=0,n=t.count;r<n;r++)s.fromBufferAttribute(t,r),e.ColorManagement.colorSpaceToWorking(s,e.SRGBColorSpace),t.setXYZ(r,s.r,s.g,s.b)}p(t,r){const s=new e.FileLoader(this.manager);return s.setPath(this.decoderPath),s.setResponseType(r),s.setWithCredentials(this.withCredentials),new Promise((e,r)=>{s.load(t,e,void 0,r)})}preload(){return this.m(),this}m(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this.p("draco_decoder.js","text")):(t.push(this.p("draco_wasm_wrapper.js","text")),t.push(this.p("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{const r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const n=s.toString(),o=["/* draco decoder */",r,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}o(e,t){return this.m().then(()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e.i={},e.A={},e.D=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const r=t.data;switch(r.type){case"decode":e.i[r.id].resolve(r);break;case"error":e.i[r.id].reject(r)}},this.workerPool.push(e)}else this.workerPool.sort(function(e,t){return e.D>t.D?-1:1});const r=this.workerPool[this.workerPool.length-1];return r.A[e]=t,r.D+=t,r})}u(e,t){e.D-=e.A[t],delete e.i[t],delete e.A[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 s(){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._(a);t.GetAttributeDataArrayForAllPoints(r,o,h,a,u);const l=new n(e.HEAPF32.buffer,u,c).slice();return e.O(u),{name:s,array:l,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,l;if(n.useUniqueIDs)l=o[s],h=t.GetAttributeByUniqueId(c,l);else{if(l=t.GetAttributeId(c,e[o[s]]),-1===l)continue;h=t.GetAttribute(c,l)}const d=r(e,t,c,s,a,h);"color"===s&&(d.vertexColorSpace=n.vertexColorSpace),u.attributes.push(d)}h===e.TRIANGULAR_MESH&&(u.index=function(e,t,r){const s=r.num_faces(),n=3*s,o=4*n,i=e._(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)}})}}}exports.DRACOLoader=r;
|