@shopware-ag/dive 2.0.1-beta.9 → 2.0.1
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/README.md +7 -9
- package/build/chunks/AssetCache-BvUcYEFC.mjs +79 -0
- package/build/chunks/AssetCache-CSbNftve.cjs +1 -0
- package/build/chunks/{AssetExporter-Ds2dAfxL.cjs → AssetExporter-DsbC2rqv.cjs} +18 -18
- package/build/chunks/{AssetExporter-CcSkkmZL.mjs → AssetExporter-brT7ogoM.mjs} +3 -4
- package/build/chunks/{AssetLoader-DjHz5xWK.mjs → AssetLoader-B07cARjB.mjs} +32 -26
- package/build/chunks/AssetLoader-CJNVpiKM.cjs +4 -0
- package/build/chunks/FileTypes-DQE3hqoS.cjs +30 -0
- package/build/chunks/{FileTypes-Cu4s3c_0.mjs → FileTypes-rkWpMg2n.mjs} +155 -205
- package/build/chunks/OrbitController-BQ6SV1O_.mjs +1159 -0
- package/build/chunks/OrbitController-CpFQ3A1H.cjs +1 -0
- package/build/chunks/PerspectiveCamera-BByyG5R4.cjs +1 -0
- package/build/chunks/PerspectiveCamera-PMJPzAn3.mjs +34 -0
- package/build/chunks/{SelectTool-w7sF1obN.mjs → SelectTool-7pU-VXgr.mjs} +4 -4
- package/build/chunks/SelectTool-BSlKpYbt.cjs +1 -0
- package/build/chunks/VisibilityLayerMask-BI7jPKdx.cjs +1 -0
- package/build/chunks/VisibilityLayerMask-CXgt1fJc.mjs +8 -0
- package/build/chunks/package-CX-oVoMh.mjs +39 -0
- package/build/chunks/package-CubHy4zo.cjs +1 -0
- package/build/chunks/parse-error-DfOPyLWM.mjs +14 -0
- package/build/chunks/parse-error-Dy_EE4rL.cjs +1 -0
- package/build/dive.cjs +1 -1
- package/build/dive.mjs +293 -223
- package/build/plugins/ar/index.cjs +1 -1
- package/build/plugins/ar/index.mjs +2 -2
- package/build/plugins/assetcache/index.cjs +1 -1
- package/build/plugins/assetcache/index.mjs +1 -1
- package/build/plugins/assetexporter/index.cjs +1 -1
- package/build/plugins/assetexporter/index.mjs +1 -1
- package/build/plugins/assetloader/index.cjs +1 -1
- package/build/plugins/assetloader/index.mjs +1 -1
- package/build/plugins/mediacreator/index.cjs +1 -1
- package/build/plugins/mediacreator/index.mjs +13 -13
- package/build/plugins/orbitcontroller/index.cjs +1 -1
- package/build/plugins/orbitcontroller/index.mjs +1 -1
- package/build/plugins/orientationdisplay/index.cjs +1 -0
- package/build/plugins/orientationdisplay/index.d.ts +2 -0
- package/build/plugins/orientationdisplay/index.mjs +5 -0
- package/build/plugins/state/index.cjs +6 -6
- package/build/plugins/state/index.mjs +728 -728
- package/build/plugins/toolbox/index.cjs +1 -1
- package/build/plugins/toolbox/index.mjs +12 -12
- package/build/src/components/boundingbox/BoundingBox.d.ts +136 -0
- package/build/src/components/light/AmbientLight.d.ts +3 -1
- package/build/src/components/light/SceneLight.d.ts +3 -1
- package/build/src/core/Dive.d.ts +1 -1
- package/build/src/helpers/deepClone/deepClone.d.ts +34 -0
- package/build/src/helpers/index.d.ts +5 -4
- package/build/src/plugins/ar/src/webxr/raycaster/WebXRRaycaster.d.ts +2 -2
- package/build/src/plugins/ar/src/webxr/touchscreencontrols/WebXRTouchscreenControls.d.ts +2 -2
- package/build/src/plugins/assetcache/src/cache/AssetCache.d.ts +5 -4
- package/build/src/plugins/assetcache/src/chunk/Chunk.d.ts +4 -7
- package/build/src/plugins/assetloader/src/loader/AssetLoader.d.ts +7 -0
- package/build/src/plugins/mediacreator/index.d.ts +1 -0
- package/build/src/plugins/mediacreator/src/MediaCreator.d.ts +2 -2
- package/build/src/plugins/mediacreator/types/MediaGenerationById.d.ts +5 -0
- package/build/src/plugins/mediacreator/types/MediaGenerationByPosition.d.ts +7 -0
- package/build/src/plugins/mediacreator/types/MediaGenerationResolution.d.ts +4 -0
- package/build/src/plugins/mediacreator/types/index.d.ts +3 -0
- package/build/src/plugins/orbitcontroller/src/OrbitController.d.ts +17 -2
- package/build/src/plugins/orientationdisplay/index.d.ts +2 -0
- package/build/src/plugins/{axiscamera/src/AxisCamera.d.ts → orientationdisplay/src/OrientationDisplay.d.ts} +5 -5
- package/build/src/plugins/orientationdisplay/src/axes/Axes.d.ts +6 -0
- package/build/src/plugins/state/src/actions/action.d.ts +4 -4
- package/build/src/plugins/state/src/actions/media/generatemedia.d.ts +2 -18
- package/build/src/plugins/state/src/actions/toolbox/setgizmovisible.d.ts +2 -2
- package/build/src/plugins/state/types/index.d.ts +2 -0
- package/build/src/plugins/toolbox/index.d.ts +1 -0
- package/build/src/plugins/toolbox/src/Toolbox.d.ts +2 -2
- package/build/src/plugins/toolbox/src/transform/TransformTool.d.ts +1 -1
- package/build/src/plugins/toolbox/types/ToolType.d.ts +1 -0
- package/build/src/plugins/toolbox/types/index.d.ts +1 -0
- package/package.json +7 -9
- package/build/chunks/AssetCache-CWeKL4PT.cjs +0 -1
- package/build/chunks/AssetCache-Y5G3mQU1.mjs +0 -84
- package/build/chunks/AssetLoader-CMKzMJ1u.cjs +0 -4
- package/build/chunks/FileTypes-CKOjpHjz.cjs +0 -30
- package/build/chunks/OrbitController-D-WNei2f.mjs +0 -940
- package/build/chunks/OrbitController-rMX8EHvJ.cjs +0 -1
- package/build/chunks/PerspectiveCamera-CONx93im.cjs +0 -1
- package/build/chunks/PerspectiveCamera-DUiWJJIj.mjs +0 -38
- package/build/chunks/SelectTool-BD6Ccy_2.cjs +0 -1
- package/build/chunks/file-type-error-BsK7IJt7.cjs +0 -1
- package/build/chunks/file-type-error-aWHfMumr.mjs +0 -8
- package/build/chunks/package-DXbIn_zz.mjs +0 -39
- package/build/chunks/package-DaKgG9tF.cjs +0 -1
- package/build/chunks/parse-error-IryNa_oq.mjs +0 -8
- package/build/chunks/parse-error-m5cNt1UV.cjs +0 -1
- package/build/plugins/axiscamera/index.cjs +0 -1
- package/build/plugins/axiscamera/index.d.ts +0 -2
- package/build/plugins/axiscamera/index.mjs +0 -4
- package/build/src/plugins/axiscamera/index.d.ts +0 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
- [Getting Started](#getting-started)
|
|
26
26
|
- [Basic Setup](#basic-setup)
|
|
27
27
|
- [Quick View](#quick-view)
|
|
28
|
-
- [
|
|
28
|
+
- [Plugins](#plugins)
|
|
29
29
|
- [Documentation](#documentation)
|
|
30
30
|
|
|
31
31
|
## About
|
|
@@ -80,13 +80,12 @@ const myCanvasWrapper = document.createElement('div');
|
|
|
80
80
|
myCanvasWrapper.appendChild(dive.canvas);
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
##
|
|
83
|
+
## Plugins
|
|
84
84
|
|
|
85
|
-
DIVE comes with several built-in
|
|
86
|
-
independent and can be accessed directly from the modules directory:
|
|
85
|
+
DIVE comes with several built-in plugins that provide specific functionality. They are self-contained and can be imported as a subpath export from the package:
|
|
87
86
|
|
|
88
87
|
```ts
|
|
89
|
-
import { ARSystem } from '@shopware-ag/dive/
|
|
88
|
+
import { ARSystem } from '@shopware-ag/dive/ar';
|
|
90
89
|
|
|
91
90
|
// Initialize AR with options
|
|
92
91
|
const arSystem = new ARSystem();
|
|
@@ -96,16 +95,15 @@ await arSystem.launch('path/to/model.glb', {
|
|
|
96
95
|
});
|
|
97
96
|
```
|
|
98
97
|
|
|
99
|
-
For detailed information about the
|
|
100
|
-
[
|
|
98
|
+
For detailed information about the plugin system, see
|
|
99
|
+
[Plugin System Documentation](docs/plugin-system.md).
|
|
101
100
|
|
|
102
101
|
## Documentation
|
|
103
102
|
|
|
104
103
|
For detailed documentation, please refer to the following sections:
|
|
105
104
|
|
|
106
|
-
- [
|
|
105
|
+
- [Plugin System](docs/plugin-system.md) - Detailed plugin system architecture and usage
|
|
107
106
|
- [Shopware Integration](docs/shopware-integration.md) - Integration with Shopware projects
|
|
108
107
|
- [Testing and Quality Assurance](docs/testing.md) - Testing guidelines and best practices
|
|
109
108
|
- [Local Development](docs/local-development.md) - Local development setup and workflow
|
|
110
|
-
- [Module Reference](docs/module-reference.md) - Complete list of available modules
|
|
111
109
|
- [Actions Reference](docs/actions-reference.md) - Complete list of available actions
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var c = (s, e, t) => e in s ? h(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var r = (s, e, t) => c(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import "./FileTypes-rkWpMg2n.mjs";
|
|
5
|
+
import "three";
|
|
6
|
+
import { N as o, F as _ } from "./network-error-BONfHWQq.mjs";
|
|
7
|
+
class n {
|
|
8
|
+
constructor(e) {
|
|
9
|
+
r(this, "_promise");
|
|
10
|
+
r(this, "_resolve");
|
|
11
|
+
r(this, "_arrayBuffer", null);
|
|
12
|
+
// metadata
|
|
13
|
+
r(this, "_size", 0);
|
|
14
|
+
r(this, "_createdAt");
|
|
15
|
+
r(this, "_updatedAt");
|
|
16
|
+
this._uri = e, this._promise = new Promise((t) => {
|
|
17
|
+
this._resolve = t;
|
|
18
|
+
}), this._createdAt = /* @__PURE__ */ new Date(), this._updatedAt = /* @__PURE__ */ new Date();
|
|
19
|
+
}
|
|
20
|
+
get promise() {
|
|
21
|
+
return this._promise;
|
|
22
|
+
}
|
|
23
|
+
get size() {
|
|
24
|
+
return this._size;
|
|
25
|
+
}
|
|
26
|
+
get createdAt() {
|
|
27
|
+
return this._createdAt;
|
|
28
|
+
}
|
|
29
|
+
get updatedAt() {
|
|
30
|
+
return this._updatedAt;
|
|
31
|
+
}
|
|
32
|
+
get arrayBuffer() {
|
|
33
|
+
return this._arrayBuffer;
|
|
34
|
+
}
|
|
35
|
+
async load() {
|
|
36
|
+
const e = await fetch(this._uri);
|
|
37
|
+
if (!e.ok)
|
|
38
|
+
throw new o(this._uri);
|
|
39
|
+
try {
|
|
40
|
+
this._arrayBuffer = await e.arrayBuffer(), this._size += this._arrayBuffer.byteLength, this._updatedAt = /* @__PURE__ */ new Date();
|
|
41
|
+
} catch {
|
|
42
|
+
throw new _(this._uri);
|
|
43
|
+
}
|
|
44
|
+
return this._resolve(this._arrayBuffer), this._arrayBuffer;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
class u {
|
|
48
|
+
constructor() {
|
|
49
|
+
r(this, "_cache", /* @__PURE__ */ new Map());
|
|
50
|
+
}
|
|
51
|
+
get() {
|
|
52
|
+
return this._cache;
|
|
53
|
+
}
|
|
54
|
+
create(e) {
|
|
55
|
+
const t = new n(e);
|
|
56
|
+
return this._cache.set(e, t), t;
|
|
57
|
+
}
|
|
58
|
+
write(e, t) {
|
|
59
|
+
this._cache.set(e, t);
|
|
60
|
+
}
|
|
61
|
+
read(e) {
|
|
62
|
+
return this._cache.get(e) ?? null;
|
|
63
|
+
}
|
|
64
|
+
delete(...e) {
|
|
65
|
+
e.forEach((t) => {
|
|
66
|
+
this._cache.delete(t);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
clear() {
|
|
70
|
+
this._cache.clear();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const a = Symbol.for("@shopware-ag/dive/assetcache"), i = globalThis;
|
|
74
|
+
i[a] || (i[a] = new u());
|
|
75
|
+
const w = i[a];
|
|
76
|
+
export {
|
|
77
|
+
w as A,
|
|
78
|
+
n as C
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var u=(s,e,t)=>e in s?n(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var r=(s,e,t)=>u(s,typeof e!="symbol"?e+"":e,t);require("./FileTypes-DQE3hqoS.cjs");require("three");const h=require("./network-error-CdDXil5g.cjs");class c{constructor(e){r(this,"_promise");r(this,"_resolve");r(this,"_arrayBuffer",null);r(this,"_size",0);r(this,"_createdAt");r(this,"_updatedAt");this._uri=e,this._promise=new Promise(t=>{this._resolve=t}),this._createdAt=new Date,this._updatedAt=new Date}get promise(){return this._promise}get size(){return this._size}get createdAt(){return this._createdAt}get updatedAt(){return this._updatedAt}get arrayBuffer(){return this._arrayBuffer}async load(){const e=await fetch(this._uri);if(!e.ok)throw new h.NetworkError(this._uri);try{this._arrayBuffer=await e.arrayBuffer(),this._size+=this._arrayBuffer.byteLength,this._updatedAt=new Date}catch{throw new h.FileContentError(this._uri)}return this._resolve(this._arrayBuffer),this._arrayBuffer}}class o{constructor(){r(this,"_cache",new Map)}get(){return this._cache}create(e){const t=new c(e);return this._cache.set(e,t),t}write(e,t){this._cache.set(e,t)}read(e){return this._cache.get(e)??null}delete(...e){e.forEach(t=>{this._cache.delete(t)})}clear(){this._cache.clear()}}const a=Symbol.for("@shopware-ag/dive/assetcache"),i=globalThis;i[a]||(i[a]=new o);const _=i[a];exports.AssetCache=_;exports.Chunk=c;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ue=Object.defineProperty;var le=(n,e,s)=>e in n?ue(n,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[e]=s;var H=(n,e,s)=>le(n,typeof e!="symbol"?e+"":e,s);const d=require("three"),K=require("./fflate.module-DHdJvhNh.cjs"),
|
|
1
|
+
"use strict";var ue=Object.defineProperty;var le=(n,e,s)=>e in n?ue(n,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[e]=s;var H=(n,e,s)=>le(n,typeof e!="symbol"?e+"":e,s);const d=require("three"),K=require("./fflate.module-DHdJvhNh.cjs"),L=require("./parse-error-Dy_EE4rL.cjs");let O,V,C,D;function k(n,e=1/0,s=null){V||(V=new d.PlaneGeometry(2,2,1,1)),C||(C=new d.ShaderMaterial({uniforms:{blitTexture:new d.Uniform(n)},vertexShader:`
|
|
2
2
|
varying vec2 vUv;
|
|
3
3
|
void main(){
|
|
4
4
|
vUv = uv;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
#else
|
|
16
16
|
gl_FragColor = texture2D( blitTexture, vUv);
|
|
17
17
|
#endif
|
|
18
|
-
}`})),C.uniforms.blitTexture.value=n,C.defines.IS_SRGB=n.colorSpace==d.SRGBColorSpace,C.needsUpdate=!0,D||(D=new d.Mesh(V,C),D.frustumCulled=!1);const t=new d.PerspectiveCamera,r=new d.Scene;r.add(D),s===null&&(s=O=new d.WebGLRenderer({antialias:!1}));const i=Math.min(n.image.width,e),o=Math.min(n.image.height,e);s.setSize(i,o),s.clear(),s.render(r,t);const a=document.createElement("canvas"),c=a.getContext("2d");a.width=i,a.height=o,c.drawImage(s.domElement,0,0,i,o);const u=new d.CanvasTexture(a);return u.minFilter=n.minFilter,u.magFilter=n.magFilter,u.wrapS=n.wrapS,u.wrapT=n.wrapT,u.name=n.name,O&&(O.forceContextLoss(),O.dispose(),O=null),u}const Z={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 X{constructor(){this.pluginCallbacks=[],this.register(function(e){return new we(e)}),this.register(function(e){return new Ee(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new Re(e)}),this.register(function(e){return new Se(e)}),this.register(function(e){return new _e(e)}),this.register(function(e){return new be(e)}),this.register(function(e){return new Ae(e)}),this.register(function(e){return new Ne(e)}),this.register(function(e){return new Le(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Ce(e)}),this.register(function(e){return new Ue(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,s,t,r){const i=new ye,o=[];for(let a=0,c=this.pluginCallbacks.length;a<c;a++)o.push(this.pluginCallbacks[a](i));i.setPlugins(o),i.write(e,s,r).catch(t)}parseAsync(e,s){const t=this;return new Promise(function(r,i){t.parse(e,r,i,s)})}}const M={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Y="KHR_mesh_quantization",S={};S[d.NearestFilter]=M.NEAREST;S[d.NearestMipmapNearestFilter]=M.NEAREST_MIPMAP_NEAREST;S[d.NearestMipmapLinearFilter]=M.NEAREST_MIPMAP_LINEAR;S[d.LinearFilter]=M.LINEAR;S[d.LinearMipmapNearestFilter]=M.LINEAR_MIPMAP_NEAREST;S[d.LinearMipmapLinearFilter]=M.LINEAR_MIPMAP_LINEAR;S[d.ClampToEdgeWrapping]=M.CLAMP_TO_EDGE;S[d.RepeatWrapping]=M.REPEAT;S[d.MirroredRepeatWrapping]=M.MIRRORED_REPEAT;const J={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},pe=new d.Color,Q=12,he=1179937895,de=2,ee=8,xe=1313821514,ge=5130562;function P(n,e){return n.length===e.length&&n.every(function(s,t){return s===e[t]})}function me(n){return new TextEncoder().encode(n).buffer}function Te(n){return P(n.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Me(n,e,s){const t={min:new Array(n.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(n.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r<e+s;r++)for(let i=0;i<n.itemSize;i++){let o;n.itemSize>4?o=n.array[r*n.itemSize+i]:(i===0?o=n.getX(r):i===1?o=n.getY(r):i===2?o=n.getZ(r):i===3&&(o=n.getW(r)),n.normalized===!0&&(o=d.MathUtils.normalize(o,n.array))),t.min[i]=Math.min(t.min[i],o),t.max[i]=Math.max(t.max[i],o)}return t}function ie(n){return Math.ceil(n/4)*4}function j(n,e=0){const s=ie(n.byteLength);if(s!==n.byteLength){const t=new Uint8Array(s);if(t.set(new Uint8Array(n)),e!==0)for(let r=n.byteLength;r<s;r++)t[r]=e;return t.buffer}return n}function te(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function se(n,e){if(n.toBlob!==void 0)return new Promise(t=>n.toBlob(t,e));let s;return e==="image/jpeg"?s=.92:e==="image/webp"&&(s=.8),n.convertToBlob({type:e,quality:s})}class ye{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"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,s,t={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},t),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const r=this,i=r.buffers,o=r.json;t=r.options;const a=r.extensionsUsed,c=r.extensionsRequired,u=new Blob(i,{type:"application/octet-stream"}),p=Object.keys(a),l=Object.keys(c);if(p.length>0&&(o.extensionsUsed=p),l.length>0&&(o.extensionsRequired=l),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=u.size),t.binary===!0){const g=new FileReader;g.readAsArrayBuffer(u),g.onloadend=function(){const f=j(g.result),h=new DataView(new ArrayBuffer(ee));h.setUint32(0,f.byteLength,!0),h.setUint32(4,ge,!0);const x=j(me(JSON.stringify(o)),32),m=new DataView(new ArrayBuffer(ee));m.setUint32(0,x.byteLength,!0),m.setUint32(4,xe,!0);const w=new ArrayBuffer(Q),_=new DataView(w);_.setUint32(0,he,!0),_.setUint32(4,de,!0);const B=Q+m.byteLength+x.byteLength+h.byteLength+f.byteLength;_.setUint32(8,B,!0);const T=new Blob([w,m,x,h,f],{type:"application/octet-stream"}),y=new FileReader;y.readAsArrayBuffer(T),y.onloadend=function(){s(y.result)}}}else if(o.buffers&&o.buffers.length>0){const g=new FileReader;g.readAsDataURL(u),g.onloadend=function(){const f=g.result;o.buffers[0].uri=f,s(o)}}else s(o)}serializeUserData(e,s){if(Object.keys(e.userData).length===0)return;const t=this.options,r=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(e.userData));if(t.includeCustomExtensions&&i.gltfExtensions){s.extensions===void 0&&(s.extensions={});for(const o in i.gltfExtensions)s.extensions[o]=i.gltfExtensions[o],r[o]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(s.extras=i)}catch(i){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+i.message)}}getUID(e,s=!1){if(this.uids.has(e)===!1){const r=new Map;r.set(!0,this.uid++),r.set(!1,this.uid++),this.uids.set(e,r)}return this.uids.get(e).get(s)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new d.Vector3;for(let r=0,i=e.count;r<i;r++)if(Math.abs(t.fromBufferAttribute(e,r).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const s=this.cache;if(s.attributesNormalized.has(e))return s.attributesNormalized.get(e);const t=e.clone(),r=new d.Vector3;for(let i=0,o=t.count;i<o;i++)r.fromBufferAttribute(t,i),r.x===0&&r.y===0&&r.z===0?r.setX(1):r.normalize(),t.setXYZ(i,r.x,r.y,r.z);return s.attributesNormalized.set(e,t),t}applyTextureTransform(e,s){let t=!1;const r={};(s.offset.x!==0||s.offset.y!==0)&&(r.offset=s.offset.toArray(),t=!0),s.rotation!==0&&(r.rotation=s.rotation,t=!0),(s.repeat.x!==1||s.repeat.y!==1)&&(r.scale=s.repeat.toArray(),t=!0),t&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,s){if(e===s)return e;function t(f){return f.colorSpace===d.SRGBColorSpace?function(x){return x<.04045?x*.0773993808:Math.pow(x*.9478672986+.0521327014,2.4)}:function(x){return x}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof d.CompressedTexture&&(e=k(e)),s instanceof d.CompressedTexture&&(s=k(s));const r=e?e.image:null,i=s?s.image:null,o=Math.max(r?r.width:0,i?i.width:0),a=Math.max(r?r.height:0,i?i.height:0),c=te();c.width=o,c.height=a;const u=c.getContext("2d");u.fillStyle="#00ffff",u.fillRect(0,0,o,a);const p=u.getImageData(0,0,o,a);if(r){u.drawImage(r,0,0,o,a);const f=t(e),h=u.getImageData(0,0,o,a).data;for(let x=2;x<h.length;x+=4)p.data[x]=f(h[x]/256)*256}if(i){u.drawImage(i,0,0,o,a);const f=t(s),h=u.getImageData(0,0,o,a).data;for(let x=1;x<h.length;x+=4)p.data[x]=f(h[x]/256)*256}u.putImageData(p,0,0);const g=(e||s).clone();return g.source=new d.Source(c),g.colorSpace=d.NoColorSpace,g.channel=(e||s).channel,e&&s&&e.channel!==s.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),g}processBuffer(e){const s=this.json,t=this.buffers;return s.buffers||(s.buffers=[{byteLength:0}]),t.push(e),0}processBufferView(e,s,t,r,i){const o=this.json;o.bufferViews||(o.bufferViews=[]);let a;switch(s){case M.BYTE:case M.UNSIGNED_BYTE:a=1;break;case M.SHORT:case M.UNSIGNED_SHORT:a=2;break;default:a=4}let c=e.itemSize*a;i===M.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);const u=ie(r*c),p=new DataView(new ArrayBuffer(u));let l=0;for(let h=t;h<t+r;h++){for(let x=0;x<e.itemSize;x++){let m;e.itemSize>4?m=e.array[h*e.itemSize+x]:(x===0?m=e.getX(h):x===1?m=e.getY(h):x===2?m=e.getZ(h):x===3&&(m=e.getW(h)),e.normalized===!0&&(m=d.MathUtils.normalize(m,e.array))),s===M.FLOAT?p.setFloat32(l,m,!0):s===M.INT?p.setInt32(l,m,!0):s===M.UNSIGNED_INT?p.setUint32(l,m,!0):s===M.SHORT?p.setInt16(l,m,!0):s===M.UNSIGNED_SHORT?p.setUint16(l,m,!0):s===M.BYTE?p.setInt8(l,m):s===M.UNSIGNED_BYTE&&p.setUint8(l,m),l+=a}l%c!==0&&(l+=c-l%c)}const g={buffer:this.processBuffer(p.buffer),byteOffset:this.byteOffset,byteLength:u};return i!==void 0&&(g.target=i),i===M.ARRAY_BUFFER&&(g.byteStride=c),this.byteOffset+=u,o.bufferViews.push(g),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const s=this,t=s.json;return t.bufferViews||(t.bufferViews=[]),new Promise(function(r){const i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){const o=j(i.result),a={buffer:s.processBuffer(o),byteOffset:s.byteOffset,byteLength:o.byteLength};s.byteOffset+=o.byteLength,r(t.bufferViews.push(a)-1)}})}processAccessor(e,s,t,r){const i=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let a;if(e.array.constructor===Float32Array)a=M.FLOAT;else if(e.array.constructor===Int32Array)a=M.INT;else if(e.array.constructor===Uint32Array)a=M.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=M.SHORT;else if(e.array.constructor===Uint16Array)a=M.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=M.BYTE;else if(e.array.constructor===Uint8Array)a=M.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(t===void 0&&(t=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;const c=Me(e,t,r);let u;s!==void 0&&(u=e===s.index?M.ELEMENT_ARRAY_BUFFER:M.ARRAY_BUFFER);const p=this.processBufferView(e,a,t,r,u),l={bufferView:p.id,byteOffset:p.byteOffset,componentType:a,count:r,max:c.max,min:c.min,type:o[e.itemSize]};return e.normalized===!0&&(l.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(l)-1}processImage(e,s,t,r="image/png"){if(e!==null){const i=this,o=i.cache,a=i.json,c=i.options,u=i.pending;o.images.has(e)||o.images.set(e,{});const p=o.images.get(e),l=r+":flipY/"+t.toString();if(p[l]!==void 0)return p[l];a.images||(a.images=[]);const g={mimeType:r},f=te();f.width=Math.min(e.width,c.maxTextureSize),f.height=Math.min(e.height,c.maxTextureSize);const h=f.getContext("2d");if(t===!0&&(h.translate(0,f.height),h.scale(1,-1)),e.data!==void 0){s!==d.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",s),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const m=new Uint8ClampedArray(e.height*e.width*4);for(let w=0;w<m.length;w+=4)m[w+0]=e.data[w+0],m[w+1]=e.data[w+1],m[w+2]=e.data[w+2],m[w+3]=e.data[w+3];h.putImageData(new ImageData(m,e.width,e.height),0,0)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)h.drawImage(e,0,0,f.width,f.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");c.binary===!0?u.push(se(f,r).then(m=>i.processBufferViewImage(m)).then(m=>{g.bufferView=m})):f.toDataURL!==void 0?g.uri=f.toDataURL(r):u.push(se(f,r).then(m=>new FileReader().readAsDataURL(m)).then(m=>{g.uri=m}));const x=a.images.push(g)-1;return p[l]=x,x}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const s=this.json;s.samplers||(s.samplers=[]);const t={magFilter:S[e.magFilter],minFilter:S[e.minFilter],wrapS:S[e.wrapS],wrapT:S[e.wrapT]};return s.samplers.push(t)-1}processTexture(e){const t=this.options,r=this.cache,i=this.json;if(r.textures.has(e))return r.textures.get(e);i.textures||(i.textures=[]),e instanceof d.CompressedTexture&&(e=k(e,t.maxTextureSize));let o=e.userData.mimeType;o==="image/webp"&&(o="image/png");const a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,o)};e.name&&(a.name=e.name),this._invokeAll(function(u){u.writeTexture&&u.writeTexture(e,a)});const c=i.textures.push(a)-1;return r.textures.set(e,c),c}processMaterial(e){const s=this.cache,t=this.json;if(s.materials.has(e))return s.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;t.materials||(t.materials=[]);const r={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const i=e.color.toArray().concat([e.opacity]);if(P(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),c={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(c,a),r.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){const a={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(a,e.map),r.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive;if(Math.max(a.r,a.g,a.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const u={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(u,e.emissiveMap),r.emissiveTexture=u}}if(e.normalMap){const a={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),r.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),r.occlusionTexture=a}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===d.DoubleSide&&(r.doubleSided=!0),e.name!==""&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,r)});const o=t.materials.push(r)-1;return s.materials.set(e,o),o}processMesh(e){const s=this.cache,t=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let T=0,y=e.material.length;T<y;T++)r.push(e.material[T].uuid);else r.push(e.material.uuid);const i=r.join(":");if(s.meshes.has(i))return s.meshes.get(i);const o=e.geometry;let a;e.isLineSegments?a=M.LINES:e.isLineLoop?a=M.LINE_LOOP:e.isLine?a=M.LINE_STRIP:e.isPoints?a=M.POINTS:a=e.material.wireframe?M.LINES:M.TRIANGLES;const c={},u={},p=[],l=[],g={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=o.getAttribute("normal");f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let h=null;for(let T in o.attributes){if(T.slice(0,5)==="morph")continue;const y=o.attributes[T];if(T=g[T]||T.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(T)||(T="_"+T),s.attributes.has(this.getUID(y))){u[T]=s.attributes.get(this.getUID(y));continue}h=null;const A=y.array;T==="JOINTS_0"&&!(A instanceof Uint16Array)&&!(A instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),h=new d.BufferAttribute(new Uint16Array(A),y.itemSize,y.normalized));const R=this.processAccessor(h||y,o);R!==null&&(T.startsWith("_")||this.detectMeshQuantization(T,y),u[T]=R,s.attributes.set(this.getUID(y),R))}if(f!==void 0&&o.setAttribute("normal",f),Object.keys(u).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const T=[],y=[],b={};if(e.morphTargetDictionary!==void 0)for(const A in e.morphTargetDictionary)b[e.morphTargetDictionary[A]]=A;for(let A=0;A<e.morphTargetInfluences.length;++A){const R={};let q=!1;for(const U in o.morphAttributes){if(U!=="position"&&U!=="normal"){q||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),q=!0);continue}const N=o.morphAttributes[U][A],z=U.toUpperCase(),F=o.attributes[U];if(s.attributes.has(this.getUID(N,!0))){R[z]=s.attributes.get(this.getUID(N,!0));continue}const $=N.clone();if(!o.morphTargetsRelative)for(let I=0,ce=N.count;I<ce;I++)for(let v=0;v<N.itemSize;v++)v===0&&$.setX(I,N.getX(I)-F.getX(I)),v===1&&$.setY(I,N.getY(I)-F.getY(I)),v===2&&$.setZ(I,N.getZ(I)-F.getZ(I)),v===3&&$.setW(I,N.getW(I)-F.getW(I));R[z]=this.processAccessor($,o),s.attributes.set(this.getUID(F,!0),R[z])}l.push(R),T.push(e.morphTargetInfluences[A]),e.morphTargetDictionary!==void 0&&y.push(b[A])}c.weights=T,y.length>0&&(c.extras={},c.extras.targetNames=y)}const x=Array.isArray(e.material);if(x&&o.groups.length===0)return null;let m=!1;if(x&&o.index===null){const T=[];for(let y=0,b=o.attributes.position.count;y<b;y++)T[y]=y;o.setIndex(T),m=!0}const w=x?e.material:[e.material],_=x?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let T=0,y=_.length;T<y;T++){const b={mode:a,attributes:u};if(this.serializeUserData(o,b),l.length>0&&(b.targets=l),o.index!==null){let R=this.getUID(o.index);(_[T].start!==void 0||_[T].count!==void 0)&&(R+=":"+_[T].start+":"+_[T].count),s.attributes.has(R)?b.indices=s.attributes.get(R):(b.indices=this.processAccessor(o.index,o,_[T].start,_[T].count),s.attributes.set(R,b.indices)),b.indices===null&&delete b.indices}const A=this.processMaterial(w[_[T].materialIndex]);A!==null&&(b.material=A),p.push(b)}m===!0&&o.setIndex(null),c.primitives=p,t.meshes||(t.meshes=[]),this._invokeAll(function(T){T.writeMesh&&T.writeMesh(e,c)});const B=t.meshes.push(c)-1;return s.meshes.set(i,B),B}detectMeshQuantization(e,s){if(this.extensionsUsed[Y])return;let t;switch(s.array.constructor){case Int8Array:t="byte";break;case Uint8Array:t="unsigned byte";break;case Int16Array:t="short";break;case Uint16Array:t="unsigned short";break;default:return}s.normalized&&(t+=" normalized");const r=e.split("_",1)[0];Z[r]&&Z[r].includes(t)&&(this.extensionsUsed[Y]=!0,this.extensionsRequired[Y]=!0)}processCamera(e){const s=this.json;s.cameras||(s.cameras=[]);const t=e.isOrthographicCamera,r={type:t?"orthographic":"perspective"};return t?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:d.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(r.name=e.type),s.cameras.push(r)-1}processAnimation(e,s){const t=this.json,r=this.nodeMap;t.animations||(t.animations=[]),e=X.Utils.mergeMorphTargetTracks(e.clone(),s);const i=e.tracks,o=[],a=[];for(let c=0;c<i.length;++c){const u=i[c],p=d.PropertyBinding.parseTrackName(u.name);let l=d.PropertyBinding.findNode(s,p.nodeName);const g=J[p.propertyName];if(p.objectName==="bones"&&(l.isSkinnedMesh===!0?l=l.skeleton.getBoneByName(p.objectIndex):l=void 0),!l||!g)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',u.name),null;const f=1;let h=u.values.length/u.times.length;g===J.morphTargetInfluences&&(h/=l.morphTargetInfluences.length);let x;u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(x="CUBICSPLINE",h/=3):u.getInterpolation()===d.InterpolateDiscrete?x="STEP":x="LINEAR",a.push({input:this.processAccessor(new d.BufferAttribute(u.times,f)),output:this.processAccessor(new d.BufferAttribute(u.values,h)),interpolation:x}),o.push({sampler:a.length-1,target:{node:r.get(l),path:g}})}return t.animations.push({name:e.name||"clip_"+t.animations.length,samplers:a,channels:o}),t.animations.length-1}processSkin(e){const s=this.json,t=this.nodeMap,r=s.nodes[t.get(e)],i=e.skeleton;if(i===void 0)return null;const o=e.skeleton.bones[0];if(o===void 0)return null;const a=[],c=new Float32Array(i.bones.length*16),u=new d.Matrix4;for(let l=0;l<i.bones.length;++l)a.push(t.get(i.bones[l])),u.copy(i.boneInverses[l]),u.multiply(e.bindMatrix).toArray(c,l*16);return s.skins===void 0&&(s.skins=[]),s.skins.push({inverseBindMatrices:this.processAccessor(new d.BufferAttribute(c,16)),joints:a,skeleton:t.get(o)}),r.skin=s.skins.length-1}processNode(e){const s=this.json,t=this.options,r=this.nodeMap;s.nodes||(s.nodes=[]);const i={};if(t.trs){const a=e.quaternion.toArray(),c=e.position.toArray(),u=e.scale.toArray();P(a,[0,0,0,1])||(i.rotation=a),P(c,[0,0,0])||(i.translation=c),P(u,[1,1,1])||(i.scale=u)}else e.matrixAutoUpdate&&e.updateMatrix(),Te(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==""&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){const a=this.processMesh(e);a!==null&&(i.mesh=a)}else e.isCamera&&(i.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const a=[];for(let c=0,u=e.children.length;c<u;c++){const p=e.children[c];if(p.visible||t.onlyVisible===!1){const l=this.processNode(p);l!==null&&a.push(l)}}a.length>0&&(i.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,i)});const o=s.nodes.push(i)-1;return r.set(e,o),o}processScene(e){const s=this.json,t=this.options;s.scenes||(s.scenes=[],s.scene=0);const r={};e.name!==""&&(r.name=e.name),s.scenes.push(r);const i=[];for(let o=0,a=e.children.length;o<a;o++){const c=e.children[o];if(c.visible||t.onlyVisible===!1){const u=this.processNode(c);u!==null&&i.push(u)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(e){const s=new d.Scene;s.name="AuxScene";for(let t=0;t<e.length;t++)s.children.push(e[t]);this.processScene(s)}processInput(e){const s=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(r){r.beforeParse&&r.beforeParse(e)});const t=[];for(let r=0;r<e.length;r++)e[r]instanceof d.Scene?this.processScene(e[r]):t.push(e[r]);t.length>0&&this.processObjects(t);for(let r=0;r<this.skins.length;++r)this.processSkin(this.skins[r]);for(let r=0;r<s.animations.length;++r)this.processAnimation(s.animations[r],e[0]);this._invokeAll(function(r){r.afterParse&&r.afterParse(e)})}_invokeAll(e){for(let s=0,t=this.plugins.length;s<t;s++)e(this.plugins[s])}}class we{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,s){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const t=this.writer,r=t.json,i=t.extensionsUsed,o={};e.name&&(o.name=e.name),o.color=e.color.toArray(),o.intensity=e.intensity,e.isDirectionalLight?o.type="directional":e.isPointLight?(o.type="point",e.distance>0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);const a=r.extensions[this.name].lights;a.push(o),s.extensions=s.extensions||{},s.extensions[this.name]={light:a.length-1}}}class Ee{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,s){if(!e.isMeshBasicMaterial)return;const r=this.writer.extensionsUsed;s.extensions=s.extensions||{},s.extensions[this.name]={},r[this.name]=!0,s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=.9}}class be{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const t=this.writer,r=t.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){const o={index:t.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};t.applyTextureTransform(o,e.clearcoatMap),i.clearcoatTexture=o}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const o={index:t.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};t.applyTextureTransform(o,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){const o={index:t.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};t.applyTextureTransform(o,e.clearcoatNormalMap),i.clearcoatNormalTexture=o}s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Ae{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const t=this.writer,r=t.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){const o={index:t.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};t.applyTextureTransform(o,e.iridescenceMap),i.iridescenceTexture=o}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const o={index:t.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};t.applyTextureTransform(o,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=o}s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Ie{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const t=this.writer,r=t.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){const o={index:t.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};t.applyTextureTransform(o,e.transmissionMap),i.transmissionTexture=o}s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Re{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const t=this.writer,r=t.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){const o={index:t.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};t.applyTextureTransform(o,e.thicknessMap),i.thicknessTexture=o}i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Se{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const r=this.writer.extensionsUsed,i={};i.ior=e.ior,s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class _e{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(pe)&&!e.specularIntensityMap&&!e.specularColorMap)return;const t=this.writer,r=t.extensionsUsed,i={};if(e.specularIntensityMap){const o={index:t.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};t.applyTextureTransform(o,e.specularIntensityMap),i.specularTexture=o}if(e.specularColorMap){const o={index:t.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};t.applyTextureTransform(o,e.specularColorMap),i.specularColorTexture=o}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Ne{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const t=this.writer,r=t.extensionsUsed,i={};if(e.sheenRoughnessMap){const o={index:t.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};t.applyTextureTransform(o,e.sheenRoughnessMap),i.sheenRoughnessTexture=o}if(e.sheenColorMap){const o={index:t.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};t.applyTextureTransform(o,e.sheenColorMap),i.sheenColorTexture=o}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Le{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const t=this.writer,r=t.extensionsUsed,i={};if(e.anisotropyMap){const o={index:t.processTexture(e.anisotropyMap)};t.applyTextureTransform(o,e.anisotropyMap),i.anisotropyTexture=o}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class ve{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,s){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const r=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Ce{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,s){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const t=this.writer,r=t.extensionsUsed,i={};if(e.bumpMap){const o={index:t.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};t.applyTextureTransform(o,e.bumpMap),i.bumpTexture=o}i.bumpFactor=e.bumpScale,s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Ue{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,s){if(!e.isInstancedMesh)return;const t=this.writer,r=e,i=new Float32Array(r.count*3),o=new Float32Array(r.count*4),a=new Float32Array(r.count*3),c=new d.Matrix4,u=new d.Vector3,p=new d.Quaternion,l=new d.Vector3;for(let f=0;f<r.count;f++)r.getMatrixAt(f,c),c.decompose(u,p,l),u.toArray(i,f*3),p.toArray(o,f*4),l.toArray(a,f*3);const g={TRANSLATION:t.processAccessor(new d.BufferAttribute(i,3)),ROTATION:t.processAccessor(new d.BufferAttribute(o,4)),SCALE:t.processAccessor(new d.BufferAttribute(a,3))};r.instanceColor&&(g._COLOR_0=t.processAccessor(r.instanceColor)),s.extensions=s.extensions||{},s.extensions[this.name]={attributes:g},t.extensionsUsed[this.name]=!0,t.extensionsRequired[this.name]=!0}}X.Utils={insertKeyframe:function(n,e){const t=n.getValueSize(),r=new n.TimeBufferType(n.times.length+1),i=new n.ValueBufferType(n.values.length+t),o=n.createInterpolant(new n.ValueBufferType(t));let a;if(n.times.length===0){r[0]=e;for(let c=0;c<t;c++)i[c]=0;a=0}else if(e<n.times[0]){if(Math.abs(n.times[0]-e)<.001)return 0;r[0]=e,r.set(n.times,1),i.set(o.evaluate(e),0),i.set(n.values,t),a=0}else if(e>n.times[n.times.length-1]){if(Math.abs(n.times[n.times.length-1]-e)<.001)return n.times.length-1;r[r.length-1]=e,r.set(n.times,0),i.set(n.values,0),i.set(o.evaluate(e),n.values.length),a=r.length-1}else for(let c=0;c<n.times.length;c++){if(Math.abs(n.times[c]-e)<.001)return c;if(n.times[c]<e&&n.times[c+1]>e){r.set(n.times.slice(0,c+1),0),r[c+1]=e,r.set(n.times.slice(c+1),c+2),i.set(n.values.slice(0,(c+1)*t),0),i.set(o.evaluate(e),(c+1)*t),i.set(n.values.slice((c+1)*t),(c+2)*t),a=c+1;break}}return n.times=r,n.values=i,a},mergeMorphTargetTracks:function(n,e){const s=[],t={},r=n.tracks;for(let i=0;i<r.length;++i){let o=r[i];const a=d.PropertyBinding.parseTrackName(o.name),c=d.PropertyBinding.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){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.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(d.InterpolateLinear)}const u=c.morphTargetInfluences.length,p=c.morphTargetDictionary[a.propertyIndex];if(p===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let l;if(t[c.uuid]===void 0){l=o.clone();const f=new l.ValueBufferType(u*l.times.length);for(let h=0;h<l.times.length;h++)f[h*u+p]=l.values[h];l.name=(a.nodeName||"")+".morphTargetInfluences",l.values=f,t[c.uuid]=l,s.push(l);continue}const g=o.createInterpolant(new o.ValueBufferType(1));l=t[c.uuid];for(let f=0;f<l.times.length;f++)l.values[f*u+p]=g.evaluate(l.times[f]);for(let f=0;f<o.times.length;f++){const h=this.insertKeyframe(l,o.times[f]);l.values[h*u+p]=o.values[f]}}return n.tracks=s,n}};class Fe{async parse(e,s={}){s=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1,maxTextureSize:1024},s);const t={},r="model.usda";t[r]=null;let i=oe();i+=Oe(s);const o={},a={};e.traverseVisible(u=>{if(u.isMesh){const p=u.geometry,l=u.material;if(l.isMeshStandardMaterial){const g="geometries/Geometry_"+p.id+".usda";if(!(g in t)){const f=Ge(p);t[g]=Be(f)}l.uuid in o||(o[l.uuid]=l),i+=De(u,p,l)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",u)}else u.isCamera&&(i+=Xe(u))}),i+=Pe(),i+=je(o,a,s.quickLookCompatible),t[r]=K.strToU8(i),i=null;for(const u in a){let p=a[u];p.isCompressedTexture===!0&&(p=k(p));const l=$e(p.image,p.flipY,s.maxTextureSize),g=await new Promise(f=>l.toBlob(f,"image/png",1));t[`textures/Texture_${u}.png`]=new Uint8Array(await g.arrayBuffer())}let c=0;for(const u in t){const p=t[u],l=34+u.length;c+=l;const g=c&63;if(g!==4){const f=64-g,h=new Uint8Array(f);t[u]=[p,{extra:{12345:h}}]}c=p.length}return K.zipSync(t,{level:0})}}function $e(n,e,s){if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&n instanceof ImageBitmap){const t=s/Math.max(n.width,n.height),r=document.createElement("canvas");r.width=n.width*Math.min(1,t),r.height=n.height*Math.min(1,t);const i=r.getContext("2d");return e===!0&&(i.translate(0,r.height),i.scale(1,-1)),i.drawImage(n,0,0,r.width,r.height),r}else throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const E=7;function oe(){return`#usda 1.0
|
|
18
|
+
}`})),C.uniforms.blitTexture.value=n,C.defines.IS_SRGB=n.colorSpace==d.SRGBColorSpace,C.needsUpdate=!0,D||(D=new d.Mesh(V,C),D.frustumCulled=!1);const t=new d.PerspectiveCamera,r=new d.Scene;r.add(D),s===null&&(s=O=new d.WebGLRenderer({antialias:!1}));const i=Math.min(n.image.width,e),o=Math.min(n.image.height,e);s.setSize(i,o),s.clear(),s.render(r,t);const a=document.createElement("canvas"),c=a.getContext("2d");a.width=i,a.height=o,c.drawImage(s.domElement,0,0,i,o);const u=new d.CanvasTexture(a);return u.minFilter=n.minFilter,u.magFilter=n.magFilter,u.wrapS=n.wrapS,u.wrapT=n.wrapT,u.name=n.name,O&&(O.forceContextLoss(),O.dispose(),O=null),u}const Z={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 X{constructor(){this.pluginCallbacks=[],this.register(function(e){return new ye(e)}),this.register(function(e){return new we(e)}),this.register(function(e){return new Ae(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new Re(e)}),this.register(function(e){return new Se(e)}),this.register(function(e){return new Ee(e)}),this.register(function(e){return new be(e)}),this.register(function(e){return new _e(e)}),this.register(function(e){return new Ne(e)}),this.register(function(e){return new Le(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Ce(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,s,t,r){const i=new Me,o=[];for(let a=0,c=this.pluginCallbacks.length;a<c;a++)o.push(this.pluginCallbacks[a](i));i.setPlugins(o),i.write(e,s,r).catch(t)}parseAsync(e,s){const t=this;return new Promise(function(r,i){t.parse(e,r,i,s)})}}const M={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Y="KHR_mesh_quantization",S={};S[d.NearestFilter]=M.NEAREST;S[d.NearestMipmapNearestFilter]=M.NEAREST_MIPMAP_NEAREST;S[d.NearestMipmapLinearFilter]=M.NEAREST_MIPMAP_LINEAR;S[d.LinearFilter]=M.LINEAR;S[d.LinearMipmapNearestFilter]=M.LINEAR_MIPMAP_NEAREST;S[d.LinearMipmapLinearFilter]=M.LINEAR_MIPMAP_LINEAR;S[d.ClampToEdgeWrapping]=M.CLAMP_TO_EDGE;S[d.RepeatWrapping]=M.REPEAT;S[d.MirroredRepeatWrapping]=M.MIRRORED_REPEAT;const J={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},fe=new d.Color,Q=12,pe=1179937895,he=2,ee=8,de=1313821514,xe=5130562;function P(n,e){return n.length===e.length&&n.every(function(s,t){return s===e[t]})}function ge(n){return new TextEncoder().encode(n).buffer}function me(n){return P(n.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Te(n,e,s){const t={min:new Array(n.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(n.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r<e+s;r++)for(let i=0;i<n.itemSize;i++){let o;n.itemSize>4?o=n.array[r*n.itemSize+i]:(i===0?o=n.getX(r):i===1?o=n.getY(r):i===2?o=n.getZ(r):i===3&&(o=n.getW(r)),n.normalized===!0&&(o=d.MathUtils.normalize(o,n.array))),t.min[i]=Math.min(t.min[i],o),t.max[i]=Math.max(t.max[i],o)}return t}function ie(n){return Math.ceil(n/4)*4}function j(n,e=0){const s=ie(n.byteLength);if(s!==n.byteLength){const t=new Uint8Array(s);if(t.set(new Uint8Array(n)),e!==0)for(let r=n.byteLength;r<s;r++)t[r]=e;return t.buffer}return n}function te(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function se(n,e){if(n.toBlob!==void 0)return new Promise(t=>n.toBlob(t,e));let s;return e==="image/jpeg"?s=.92:e==="image/webp"&&(s=.8),n.convertToBlob({type:e,quality:s})}class Me{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"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,s,t={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},t),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const r=this,i=r.buffers,o=r.json;t=r.options;const a=r.extensionsUsed,c=r.extensionsRequired,u=new Blob(i,{type:"application/octet-stream"}),p=Object.keys(a),l=Object.keys(c);if(p.length>0&&(o.extensionsUsed=p),l.length>0&&(o.extensionsRequired=l),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=u.size),t.binary===!0){const g=new FileReader;g.readAsArrayBuffer(u),g.onloadend=function(){const f=j(g.result),h=new DataView(new ArrayBuffer(ee));h.setUint32(0,f.byteLength,!0),h.setUint32(4,xe,!0);const x=j(ge(JSON.stringify(o)),32),m=new DataView(new ArrayBuffer(ee));m.setUint32(0,x.byteLength,!0),m.setUint32(4,de,!0);const w=new ArrayBuffer(Q),_=new DataView(w);_.setUint32(0,pe,!0),_.setUint32(4,he,!0);const B=Q+m.byteLength+x.byteLength+h.byteLength+f.byteLength;_.setUint32(8,B,!0);const T=new Blob([w,m,x,h,f],{type:"application/octet-stream"}),y=new FileReader;y.readAsArrayBuffer(T),y.onloadend=function(){s(y.result)}}}else if(o.buffers&&o.buffers.length>0){const g=new FileReader;g.readAsDataURL(u),g.onloadend=function(){const f=g.result;o.buffers[0].uri=f,s(o)}}else s(o)}serializeUserData(e,s){if(Object.keys(e.userData).length===0)return;const t=this.options,r=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(e.userData));if(t.includeCustomExtensions&&i.gltfExtensions){s.extensions===void 0&&(s.extensions={});for(const o in i.gltfExtensions)s.extensions[o]=i.gltfExtensions[o],r[o]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(s.extras=i)}catch(i){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+i.message)}}getUID(e,s=!1){if(this.uids.has(e)===!1){const r=new Map;r.set(!0,this.uid++),r.set(!1,this.uid++),this.uids.set(e,r)}return this.uids.get(e).get(s)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new d.Vector3;for(let r=0,i=e.count;r<i;r++)if(Math.abs(t.fromBufferAttribute(e,r).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const s=this.cache;if(s.attributesNormalized.has(e))return s.attributesNormalized.get(e);const t=e.clone(),r=new d.Vector3;for(let i=0,o=t.count;i<o;i++)r.fromBufferAttribute(t,i),r.x===0&&r.y===0&&r.z===0?r.setX(1):r.normalize(),t.setXYZ(i,r.x,r.y,r.z);return s.attributesNormalized.set(e,t),t}applyTextureTransform(e,s){let t=!1;const r={};(s.offset.x!==0||s.offset.y!==0)&&(r.offset=s.offset.toArray(),t=!0),s.rotation!==0&&(r.rotation=s.rotation,t=!0),(s.repeat.x!==1||s.repeat.y!==1)&&(r.scale=s.repeat.toArray(),t=!0),t&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,s){if(e===s)return e;function t(f){return f.colorSpace===d.SRGBColorSpace?function(x){return x<.04045?x*.0773993808:Math.pow(x*.9478672986+.0521327014,2.4)}:function(x){return x}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof d.CompressedTexture&&(e=k(e)),s instanceof d.CompressedTexture&&(s=k(s));const r=e?e.image:null,i=s?s.image:null,o=Math.max(r?r.width:0,i?i.width:0),a=Math.max(r?r.height:0,i?i.height:0),c=te();c.width=o,c.height=a;const u=c.getContext("2d");u.fillStyle="#00ffff",u.fillRect(0,0,o,a);const p=u.getImageData(0,0,o,a);if(r){u.drawImage(r,0,0,o,a);const f=t(e),h=u.getImageData(0,0,o,a).data;for(let x=2;x<h.length;x+=4)p.data[x]=f(h[x]/256)*256}if(i){u.drawImage(i,0,0,o,a);const f=t(s),h=u.getImageData(0,0,o,a).data;for(let x=1;x<h.length;x+=4)p.data[x]=f(h[x]/256)*256}u.putImageData(p,0,0);const g=(e||s).clone();return g.source=new d.Source(c),g.colorSpace=d.NoColorSpace,g.channel=(e||s).channel,e&&s&&e.channel!==s.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),g}processBuffer(e){const s=this.json,t=this.buffers;return s.buffers||(s.buffers=[{byteLength:0}]),t.push(e),0}processBufferView(e,s,t,r,i){const o=this.json;o.bufferViews||(o.bufferViews=[]);let a;switch(s){case M.BYTE:case M.UNSIGNED_BYTE:a=1;break;case M.SHORT:case M.UNSIGNED_SHORT:a=2;break;default:a=4}let c=e.itemSize*a;i===M.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);const u=ie(r*c),p=new DataView(new ArrayBuffer(u));let l=0;for(let h=t;h<t+r;h++){for(let x=0;x<e.itemSize;x++){let m;e.itemSize>4?m=e.array[h*e.itemSize+x]:(x===0?m=e.getX(h):x===1?m=e.getY(h):x===2?m=e.getZ(h):x===3&&(m=e.getW(h)),e.normalized===!0&&(m=d.MathUtils.normalize(m,e.array))),s===M.FLOAT?p.setFloat32(l,m,!0):s===M.INT?p.setInt32(l,m,!0):s===M.UNSIGNED_INT?p.setUint32(l,m,!0):s===M.SHORT?p.setInt16(l,m,!0):s===M.UNSIGNED_SHORT?p.setUint16(l,m,!0):s===M.BYTE?p.setInt8(l,m):s===M.UNSIGNED_BYTE&&p.setUint8(l,m),l+=a}l%c!==0&&(l+=c-l%c)}const g={buffer:this.processBuffer(p.buffer),byteOffset:this.byteOffset,byteLength:u};return i!==void 0&&(g.target=i),i===M.ARRAY_BUFFER&&(g.byteStride=c),this.byteOffset+=u,o.bufferViews.push(g),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const s=this,t=s.json;return t.bufferViews||(t.bufferViews=[]),new Promise(function(r){const i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){const o=j(i.result),a={buffer:s.processBuffer(o),byteOffset:s.byteOffset,byteLength:o.byteLength};s.byteOffset+=o.byteLength,r(t.bufferViews.push(a)-1)}})}processAccessor(e,s,t,r){const i=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let a;if(e.array.constructor===Float32Array)a=M.FLOAT;else if(e.array.constructor===Int32Array)a=M.INT;else if(e.array.constructor===Uint32Array)a=M.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=M.SHORT;else if(e.array.constructor===Uint16Array)a=M.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=M.BYTE;else if(e.array.constructor===Uint8Array)a=M.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(t===void 0&&(t=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;const c=Te(e,t,r);let u;s!==void 0&&(u=e===s.index?M.ELEMENT_ARRAY_BUFFER:M.ARRAY_BUFFER);const p=this.processBufferView(e,a,t,r,u),l={bufferView:p.id,byteOffset:p.byteOffset,componentType:a,count:r,max:c.max,min:c.min,type:o[e.itemSize]};return e.normalized===!0&&(l.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(l)-1}processImage(e,s,t,r="image/png"){if(e!==null){const i=this,o=i.cache,a=i.json,c=i.options,u=i.pending;o.images.has(e)||o.images.set(e,{});const p=o.images.get(e),l=r+":flipY/"+t.toString();if(p[l]!==void 0)return p[l];a.images||(a.images=[]);const g={mimeType:r},f=te();f.width=Math.min(e.width,c.maxTextureSize),f.height=Math.min(e.height,c.maxTextureSize);const h=f.getContext("2d");if(t===!0&&(h.translate(0,f.height),h.scale(1,-1)),e.data!==void 0){s!==d.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",s),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const m=new Uint8ClampedArray(e.height*e.width*4);for(let w=0;w<m.length;w+=4)m[w+0]=e.data[w+0],m[w+1]=e.data[w+1],m[w+2]=e.data[w+2],m[w+3]=e.data[w+3];h.putImageData(new ImageData(m,e.width,e.height),0,0)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)h.drawImage(e,0,0,f.width,f.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");c.binary===!0?u.push(se(f,r).then(m=>i.processBufferViewImage(m)).then(m=>{g.bufferView=m})):f.toDataURL!==void 0?g.uri=f.toDataURL(r):u.push(se(f,r).then(m=>new FileReader().readAsDataURL(m)).then(m=>{g.uri=m}));const x=a.images.push(g)-1;return p[l]=x,x}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const s=this.json;s.samplers||(s.samplers=[]);const t={magFilter:S[e.magFilter],minFilter:S[e.minFilter],wrapS:S[e.wrapS],wrapT:S[e.wrapT]};return s.samplers.push(t)-1}processTexture(e){const t=this.options,r=this.cache,i=this.json;if(r.textures.has(e))return r.textures.get(e);i.textures||(i.textures=[]),e instanceof d.CompressedTexture&&(e=k(e,t.maxTextureSize));let o=e.userData.mimeType;o==="image/webp"&&(o="image/png");const a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,o)};e.name&&(a.name=e.name),this._invokeAll(function(u){u.writeTexture&&u.writeTexture(e,a)});const c=i.textures.push(a)-1;return r.textures.set(e,c),c}processMaterial(e){const s=this.cache,t=this.json;if(s.materials.has(e))return s.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;t.materials||(t.materials=[]);const r={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const i=e.color.toArray().concat([e.opacity]);if(P(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),c={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(c,a),r.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){const a={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(a,e.map),r.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive;if(Math.max(a.r,a.g,a.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const u={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(u,e.emissiveMap),r.emissiveTexture=u}}if(e.normalMap){const a={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),r.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),r.occlusionTexture=a}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===d.DoubleSide&&(r.doubleSided=!0),e.name!==""&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,r)});const o=t.materials.push(r)-1;return s.materials.set(e,o),o}processMesh(e){const s=this.cache,t=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let T=0,y=e.material.length;T<y;T++)r.push(e.material[T].uuid);else r.push(e.material.uuid);const i=r.join(":");if(s.meshes.has(i))return s.meshes.get(i);const o=e.geometry;let a;e.isLineSegments?a=M.LINES:e.isLineLoop?a=M.LINE_LOOP:e.isLine?a=M.LINE_STRIP:e.isPoints?a=M.POINTS:a=e.material.wireframe?M.LINES:M.TRIANGLES;const c={},u={},p=[],l=[],g={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=o.getAttribute("normal");f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let h=null;for(let T in o.attributes){if(T.slice(0,5)==="morph")continue;const y=o.attributes[T];if(T=g[T]||T.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(T)||(T="_"+T),s.attributes.has(this.getUID(y))){u[T]=s.attributes.get(this.getUID(y));continue}h=null;const A=y.array;T==="JOINTS_0"&&!(A instanceof Uint16Array)&&!(A instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),h=new d.BufferAttribute(new Uint16Array(A),y.itemSize,y.normalized));const R=this.processAccessor(h||y,o);R!==null&&(T.startsWith("_")||this.detectMeshQuantization(T,y),u[T]=R,s.attributes.set(this.getUID(y),R))}if(f!==void 0&&o.setAttribute("normal",f),Object.keys(u).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const T=[],y=[],b={};if(e.morphTargetDictionary!==void 0)for(const A in e.morphTargetDictionary)b[e.morphTargetDictionary[A]]=A;for(let A=0;A<e.morphTargetInfluences.length;++A){const R={};let q=!1;for(const U in o.morphAttributes){if(U!=="position"&&U!=="normal"){q||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),q=!0);continue}const N=o.morphAttributes[U][A],z=U.toUpperCase(),F=o.attributes[U];if(s.attributes.has(this.getUID(N,!0))){R[z]=s.attributes.get(this.getUID(N,!0));continue}const $=N.clone();if(!o.morphTargetsRelative)for(let I=0,ce=N.count;I<ce;I++)for(let v=0;v<N.itemSize;v++)v===0&&$.setX(I,N.getX(I)-F.getX(I)),v===1&&$.setY(I,N.getY(I)-F.getY(I)),v===2&&$.setZ(I,N.getZ(I)-F.getZ(I)),v===3&&$.setW(I,N.getW(I)-F.getW(I));R[z]=this.processAccessor($,o),s.attributes.set(this.getUID(F,!0),R[z])}l.push(R),T.push(e.morphTargetInfluences[A]),e.morphTargetDictionary!==void 0&&y.push(b[A])}c.weights=T,y.length>0&&(c.extras={},c.extras.targetNames=y)}const x=Array.isArray(e.material);if(x&&o.groups.length===0)return null;let m=!1;if(x&&o.index===null){const T=[];for(let y=0,b=o.attributes.position.count;y<b;y++)T[y]=y;o.setIndex(T),m=!0}const w=x?e.material:[e.material],_=x?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let T=0,y=_.length;T<y;T++){const b={mode:a,attributes:u};if(this.serializeUserData(o,b),l.length>0&&(b.targets=l),o.index!==null){let R=this.getUID(o.index);(_[T].start!==void 0||_[T].count!==void 0)&&(R+=":"+_[T].start+":"+_[T].count),s.attributes.has(R)?b.indices=s.attributes.get(R):(b.indices=this.processAccessor(o.index,o,_[T].start,_[T].count),s.attributes.set(R,b.indices)),b.indices===null&&delete b.indices}const A=this.processMaterial(w[_[T].materialIndex]);A!==null&&(b.material=A),p.push(b)}m===!0&&o.setIndex(null),c.primitives=p,t.meshes||(t.meshes=[]),this._invokeAll(function(T){T.writeMesh&&T.writeMesh(e,c)});const B=t.meshes.push(c)-1;return s.meshes.set(i,B),B}detectMeshQuantization(e,s){if(this.extensionsUsed[Y])return;let t;switch(s.array.constructor){case Int8Array:t="byte";break;case Uint8Array:t="unsigned byte";break;case Int16Array:t="short";break;case Uint16Array:t="unsigned short";break;default:return}s.normalized&&(t+=" normalized");const r=e.split("_",1)[0];Z[r]&&Z[r].includes(t)&&(this.extensionsUsed[Y]=!0,this.extensionsRequired[Y]=!0)}processCamera(e){const s=this.json;s.cameras||(s.cameras=[]);const t=e.isOrthographicCamera,r={type:t?"orthographic":"perspective"};return t?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:d.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(r.name=e.type),s.cameras.push(r)-1}processAnimation(e,s){const t=this.json,r=this.nodeMap;t.animations||(t.animations=[]),e=X.Utils.mergeMorphTargetTracks(e.clone(),s);const i=e.tracks,o=[],a=[];for(let c=0;c<i.length;++c){const u=i[c],p=d.PropertyBinding.parseTrackName(u.name);let l=d.PropertyBinding.findNode(s,p.nodeName);const g=J[p.propertyName];if(p.objectName==="bones"&&(l.isSkinnedMesh===!0?l=l.skeleton.getBoneByName(p.objectIndex):l=void 0),!l||!g)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',u.name),null;const f=1;let h=u.values.length/u.times.length;g===J.morphTargetInfluences&&(h/=l.morphTargetInfluences.length);let x;u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(x="CUBICSPLINE",h/=3):u.getInterpolation()===d.InterpolateDiscrete?x="STEP":x="LINEAR",a.push({input:this.processAccessor(new d.BufferAttribute(u.times,f)),output:this.processAccessor(new d.BufferAttribute(u.values,h)),interpolation:x}),o.push({sampler:a.length-1,target:{node:r.get(l),path:g}})}return t.animations.push({name:e.name||"clip_"+t.animations.length,samplers:a,channels:o}),t.animations.length-1}processSkin(e){const s=this.json,t=this.nodeMap,r=s.nodes[t.get(e)],i=e.skeleton;if(i===void 0)return null;const o=e.skeleton.bones[0];if(o===void 0)return null;const a=[],c=new Float32Array(i.bones.length*16),u=new d.Matrix4;for(let l=0;l<i.bones.length;++l)a.push(t.get(i.bones[l])),u.copy(i.boneInverses[l]),u.multiply(e.bindMatrix).toArray(c,l*16);return s.skins===void 0&&(s.skins=[]),s.skins.push({inverseBindMatrices:this.processAccessor(new d.BufferAttribute(c,16)),joints:a,skeleton:t.get(o)}),r.skin=s.skins.length-1}processNode(e){const s=this.json,t=this.options,r=this.nodeMap;s.nodes||(s.nodes=[]);const i={};if(t.trs){const a=e.quaternion.toArray(),c=e.position.toArray(),u=e.scale.toArray();P(a,[0,0,0,1])||(i.rotation=a),P(c,[0,0,0])||(i.translation=c),P(u,[1,1,1])||(i.scale=u)}else e.matrixAutoUpdate&&e.updateMatrix(),me(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==""&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){const a=this.processMesh(e);a!==null&&(i.mesh=a)}else e.isCamera&&(i.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const a=[];for(let c=0,u=e.children.length;c<u;c++){const p=e.children[c];if(p.visible||t.onlyVisible===!1){const l=this.processNode(p);l!==null&&a.push(l)}}a.length>0&&(i.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,i)});const o=s.nodes.push(i)-1;return r.set(e,o),o}processScene(e){const s=this.json,t=this.options;s.scenes||(s.scenes=[],s.scene=0);const r={};e.name!==""&&(r.name=e.name),s.scenes.push(r);const i=[];for(let o=0,a=e.children.length;o<a;o++){const c=e.children[o];if(c.visible||t.onlyVisible===!1){const u=this.processNode(c);u!==null&&i.push(u)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(e){const s=new d.Scene;s.name="AuxScene";for(let t=0;t<e.length;t++)s.children.push(e[t]);this.processScene(s)}processInput(e){const s=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(r){r.beforeParse&&r.beforeParse(e)});const t=[];for(let r=0;r<e.length;r++)e[r]instanceof d.Scene?this.processScene(e[r]):t.push(e[r]);t.length>0&&this.processObjects(t);for(let r=0;r<this.skins.length;++r)this.processSkin(this.skins[r]);for(let r=0;r<s.animations.length;++r)this.processAnimation(s.animations[r],e[0]);this._invokeAll(function(r){r.afterParse&&r.afterParse(e)})}_invokeAll(e){for(let s=0,t=this.plugins.length;s<t;s++)e(this.plugins[s])}}class ye{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,s){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const t=this.writer,r=t.json,i=t.extensionsUsed,o={};e.name&&(o.name=e.name),o.color=e.color.toArray(),o.intensity=e.intensity,e.isDirectionalLight?o.type="directional":e.isPointLight?(o.type="point",e.distance>0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);const a=r.extensions[this.name].lights;a.push(o),s.extensions=s.extensions||{},s.extensions[this.name]={light:a.length-1}}}class we{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,s){if(!e.isMeshBasicMaterial)return;const r=this.writer.extensionsUsed;s.extensions=s.extensions||{},s.extensions[this.name]={},r[this.name]=!0,s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=.9}}class Ee{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const t=this.writer,r=t.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){const o={index:t.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};t.applyTextureTransform(o,e.clearcoatMap),i.clearcoatTexture=o}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const o={index:t.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};t.applyTextureTransform(o,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){const o={index:t.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};t.applyTextureTransform(o,e.clearcoatNormalMap),i.clearcoatNormalTexture=o}s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class be{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const t=this.writer,r=t.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){const o={index:t.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};t.applyTextureTransform(o,e.iridescenceMap),i.iridescenceTexture=o}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const o={index:t.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};t.applyTextureTransform(o,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=o}s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Ae{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const t=this.writer,r=t.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){const o={index:t.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};t.applyTextureTransform(o,e.transmissionMap),i.transmissionTexture=o}s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Ie{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const t=this.writer,r=t.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){const o={index:t.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};t.applyTextureTransform(o,e.thicknessMap),i.thicknessTexture=o}i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Re{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const r=this.writer.extensionsUsed,i={};i.ior=e.ior,s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Se{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(fe)&&!e.specularIntensityMap&&!e.specularColorMap)return;const t=this.writer,r=t.extensionsUsed,i={};if(e.specularIntensityMap){const o={index:t.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};t.applyTextureTransform(o,e.specularIntensityMap),i.specularTexture=o}if(e.specularColorMap){const o={index:t.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};t.applyTextureTransform(o,e.specularColorMap),i.specularColorTexture=o}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class _e{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const t=this.writer,r=t.extensionsUsed,i={};if(e.sheenRoughnessMap){const o={index:t.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};t.applyTextureTransform(o,e.sheenRoughnessMap),i.sheenRoughnessTexture=o}if(e.sheenColorMap){const o={index:t.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};t.applyTextureTransform(o,e.sheenColorMap),i.sheenColorTexture=o}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Ne{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,s){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const t=this.writer,r=t.extensionsUsed,i={};if(e.anisotropyMap){const o={index:t.processTexture(e.anisotropyMap)};t.applyTextureTransform(o,e.anisotropyMap),i.anisotropyTexture=o}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Le{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,s){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const r=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class ve{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,s){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const t=this.writer,r=t.extensionsUsed,i={};if(e.bumpMap){const o={index:t.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};t.applyTextureTransform(o,e.bumpMap),i.bumpTexture=o}i.bumpFactor=e.bumpScale,s.extensions=s.extensions||{},s.extensions[this.name]=i,r[this.name]=!0}}class Ce{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,s){if(!e.isInstancedMesh)return;const t=this.writer,r=e,i=new Float32Array(r.count*3),o=new Float32Array(r.count*4),a=new Float32Array(r.count*3),c=new d.Matrix4,u=new d.Vector3,p=new d.Quaternion,l=new d.Vector3;for(let f=0;f<r.count;f++)r.getMatrixAt(f,c),c.decompose(u,p,l),u.toArray(i,f*3),p.toArray(o,f*4),l.toArray(a,f*3);const g={TRANSLATION:t.processAccessor(new d.BufferAttribute(i,3)),ROTATION:t.processAccessor(new d.BufferAttribute(o,4)),SCALE:t.processAccessor(new d.BufferAttribute(a,3))};r.instanceColor&&(g._COLOR_0=t.processAccessor(r.instanceColor)),s.extensions=s.extensions||{},s.extensions[this.name]={attributes:g},t.extensionsUsed[this.name]=!0,t.extensionsRequired[this.name]=!0}}X.Utils={insertKeyframe:function(n,e){const t=n.getValueSize(),r=new n.TimeBufferType(n.times.length+1),i=new n.ValueBufferType(n.values.length+t),o=n.createInterpolant(new n.ValueBufferType(t));let a;if(n.times.length===0){r[0]=e;for(let c=0;c<t;c++)i[c]=0;a=0}else if(e<n.times[0]){if(Math.abs(n.times[0]-e)<.001)return 0;r[0]=e,r.set(n.times,1),i.set(o.evaluate(e),0),i.set(n.values,t),a=0}else if(e>n.times[n.times.length-1]){if(Math.abs(n.times[n.times.length-1]-e)<.001)return n.times.length-1;r[r.length-1]=e,r.set(n.times,0),i.set(n.values,0),i.set(o.evaluate(e),n.values.length),a=r.length-1}else for(let c=0;c<n.times.length;c++){if(Math.abs(n.times[c]-e)<.001)return c;if(n.times[c]<e&&n.times[c+1]>e){r.set(n.times.slice(0,c+1),0),r[c+1]=e,r.set(n.times.slice(c+1),c+2),i.set(n.values.slice(0,(c+1)*t),0),i.set(o.evaluate(e),(c+1)*t),i.set(n.values.slice((c+1)*t),(c+2)*t),a=c+1;break}}return n.times=r,n.values=i,a},mergeMorphTargetTracks:function(n,e){const s=[],t={},r=n.tracks;for(let i=0;i<r.length;++i){let o=r[i];const a=d.PropertyBinding.parseTrackName(o.name),c=d.PropertyBinding.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){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.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(d.InterpolateLinear)}const u=c.morphTargetInfluences.length,p=c.morphTargetDictionary[a.propertyIndex];if(p===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let l;if(t[c.uuid]===void 0){l=o.clone();const f=new l.ValueBufferType(u*l.times.length);for(let h=0;h<l.times.length;h++)f[h*u+p]=l.values[h];l.name=(a.nodeName||"")+".morphTargetInfluences",l.values=f,t[c.uuid]=l,s.push(l);continue}const g=o.createInterpolant(new o.ValueBufferType(1));l=t[c.uuid];for(let f=0;f<l.times.length;f++)l.values[f*u+p]=g.evaluate(l.times[f]);for(let f=0;f<o.times.length;f++){const h=this.insertKeyframe(l,o.times[f]);l.values[h*u+p]=o.values[f]}}return n.tracks=s,n}};class Ue{async parse(e,s={}){s=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1,maxTextureSize:1024},s);const t={},r="model.usda";t[r]=null;let i=oe();i+=$e(s);const o={},a={};e.traverseVisible(u=>{if(u.isMesh){const p=u.geometry,l=u.material;if(l.isMeshStandardMaterial){const g="geometries/Geometry_"+p.id+".usda";if(!(g in t)){const f=De(p);t[g]=Pe(f)}l.uuid in o||(o[l.uuid]=l),i+=Be(u,p,l)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",u)}else u.isCamera&&(i+=We(u))}),i+=Oe(),i+=Ye(o,a,s.quickLookCompatible),t[r]=K.strToU8(i),i=null;for(const u in a){let p=a[u];p.isCompressedTexture===!0&&(p=k(p));const l=Fe(p.image,p.flipY,s.maxTextureSize),g=await new Promise(f=>l.toBlob(f,"image/png",1));t[`textures/Texture_${u}.png`]=new Uint8Array(await g.arrayBuffer())}let c=0;for(const u in t){const p=t[u],l=34+u.length;c+=l;const g=c&63;if(g!==4){const f=64-g,h=new Uint8Array(f);t[u]=[p,{extra:{12345:h}}]}c=p.length}return K.zipSync(t,{level:0})}}function Fe(n,e,s){if(typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&n instanceof ImageBitmap){const t=s/Math.max(n.width,n.height),r=document.createElement("canvas");r.width=n.width*Math.min(1,t),r.height=n.height*Math.min(1,t);const i=r.getContext("2d");return e===!0&&(i.translate(0,r.height),i.scale(1,-1)),i.drawImage(n,0,0,r.width,r.height),r}else throw new Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}const E=7;function oe(){return`#usda 1.0
|
|
19
19
|
(
|
|
20
20
|
customLayerData = {
|
|
21
21
|
string creator = "Three.js USDZExporter"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
upAxis = "Y"
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
`}function
|
|
28
|
+
`}function $e(n){return`def Xform "Root"
|
|
29
29
|
{
|
|
30
30
|
def Scope "Scenes" (
|
|
31
31
|
kind = "sceneLibrary"
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
token preliminary:anchoring:type = "${n.ar.anchoring.type}"
|
|
43
43
|
token preliminary:planeAnchoring:alignment = "${n.ar.planeAnchoring.alignment}"
|
|
44
44
|
|
|
45
|
-
`}function
|
|
45
|
+
`}function Oe(){return`
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
`}function
|
|
50
|
+
`}function Pe(n){let e=oe();return e+=n,K.strToU8(e)}function Be(n,e,s){const t="Object_"+n.id,r=ae(n.matrixWorld);return n.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",n),`def Xform "${t}" (
|
|
51
51
|
prepend references = @./geometries/Geometry_${e.id}.usda@</Geometry>
|
|
52
52
|
prepend apiSchemas = ["MaterialBindingAPI"]
|
|
53
53
|
)
|
|
@@ -58,35 +58,35 @@
|
|
|
58
58
|
rel material:binding = </Materials/Material_${s.id}>
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
`}function ae(n){const e=n.elements;return`( ${G(e,0)}, ${G(e,4)}, ${G(e,8)}, ${G(e,12)} )`}function G(n,e){return`(${n[e+0]}, ${n[e+1]}, ${n[e+2]}, ${n[e+3]})`}function
|
|
61
|
+
`}function ae(n){const e=n.elements;return`( ${G(e,0)}, ${G(e,4)}, ${G(e,8)}, ${G(e,12)} )`}function G(n,e){return`(${n[e+0]}, ${n[e+1]}, ${n[e+2]}, ${n[e+3]})`}function De(n){return`
|
|
62
62
|
def "Geometry"
|
|
63
63
|
{
|
|
64
|
-
${
|
|
64
|
+
${Ge(n)}
|
|
65
65
|
}
|
|
66
|
-
`}function
|
|
66
|
+
`}function Ge(n){const e="Geometry",s=n.attributes,t=s.position.count;return`
|
|
67
67
|
def Mesh "${e}"
|
|
68
68
|
{
|
|
69
|
-
int[] faceVertexCounts = [${
|
|
70
|
-
int[] faceVertexIndices = [${
|
|
69
|
+
int[] faceVertexCounts = [${ke(n)}]
|
|
70
|
+
int[] faceVertexIndices = [${ze(n)}]
|
|
71
71
|
normal3f[] normals = [${W(s.normal,t)}] (
|
|
72
72
|
interpolation = "vertex"
|
|
73
73
|
)
|
|
74
74
|
point3f[] points = [${W(s.position,t)}]
|
|
75
|
-
${
|
|
75
|
+
${Ve(s)}
|
|
76
76
|
uniform token subdivisionScheme = "none"
|
|
77
77
|
}
|
|
78
|
-
`}function
|
|
79
|
-
texCoord2f[] primvars:st${r} = [${
|
|
78
|
+
`}function ke(n){const e=n.index!==null?n.index.count:n.attributes.position.count;return Array(e/3).fill(3).join(", ")}function ze(n){const e=n.index,s=[];if(e!==null)for(let t=0;t<e.count;t++)s.push(e.getX(t));else{const t=n.attributes.position.count;for(let r=0;r<t;r++)s.push(r)}return s.join(", ")}function W(n,e){if(n===void 0)return console.warn("USDZExporter: Normals missing."),Array(e).fill("(0, 0, 0)").join(", ");const s=[];for(let t=0;t<n.count;t++){const r=n.getX(t),i=n.getY(t),o=n.getZ(t);s.push(`(${r.toPrecision(E)}, ${i.toPrecision(E)}, ${o.toPrecision(E)})`)}return s.join(", ")}function He(n){const e=[];for(let s=0;s<n.count;s++){const t=n.getX(s),r=n.getY(s);e.push(`(${t.toPrecision(E)}, ${1-r.toPrecision(E)})`)}return e.join(", ")}function Ve(n){let e="";for(let t=0;t<4;t++){const r=t>0?t:"",i=n["uv"+r];i!==void 0&&(e+=`
|
|
79
|
+
texCoord2f[] primvars:st${r} = [${He(i)}] (
|
|
80
80
|
interpolation = "vertex"
|
|
81
81
|
)`)}const s=n.color;if(s!==void 0){const t=s.count;e+=`
|
|
82
82
|
color3f[] primvars:displayColor = [${W(s,t)}] (
|
|
83
83
|
interpolation = "vertex"
|
|
84
|
-
)`}return e}function
|
|
84
|
+
)`}return e}function Ye(n,e,s=!1){const t=[];for(const r in n){const i=n[r];t.push(je(i,e,s))}return`def "Materials"
|
|
85
85
|
{
|
|
86
86
|
${t.join("")}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
`}function
|
|
89
|
+
`}function je(n,e,s=!1){const t=" ",r=[],i=[];function o(a,c,u){const p=a.source.id+"_"+a.flipY;e[p]=a;const l=a.channel>0?"st"+a.channel:"st",g={1e3:"repeat",1001:"clamp",1002:"mirror"},f=a.repeat.clone(),h=a.offset.clone(),x=a.rotation,m=Math.sin(x),w=Math.cos(x);return h.y=1-h.y-f.y,s?(h.x=h.x/f.x,h.y=h.y/f.y,h.x+=m/f.x,h.y+=w-1):(h.x+=m*f.x,h.y+=(1-w)*f.y),`
|
|
90
90
|
def Shader "PrimvarReader_${c}"
|
|
91
91
|
{
|
|
92
92
|
uniform token info:id = "UsdPrimvarReader_float2"
|
|
@@ -110,7 +110,7 @@ ${t.join("")}
|
|
|
110
110
|
uniform token info:id = "UsdUVTexture"
|
|
111
111
|
asset inputs:file = @textures/Texture_${p}.png@
|
|
112
112
|
float2 inputs:st.connect = </Materials/Material_${n.id}/Transform2d_${c}.outputs:result>
|
|
113
|
-
${u!==void 0?"float4 inputs:scale = "+
|
|
113
|
+
${u!==void 0?"float4 inputs:scale = "+Ke(u):""}
|
|
114
114
|
token inputs:sourceColorSpace = "${a.colorSpace===d.NoColorSpace?"raw":"sRGB"}"
|
|
115
115
|
token inputs:wrapS = "${g[a.wrapS]}"
|
|
116
116
|
token inputs:wrapT = "${g[a.wrapT]}"
|
|
@@ -137,7 +137,7 @@ ${i.join(`
|
|
|
137
137
|
`)}
|
|
138
138
|
|
|
139
139
|
}
|
|
140
|
-
`}function ne(n){return`(${n.r}, ${n.g}, ${n.b})`}function
|
|
140
|
+
`}function ne(n){return`(${n.r}, ${n.g}, ${n.b})`}function Ke(n){return`(${n.r}, ${n.g}, ${n.b}, 1.0)`}function re(n){return`(${n.x}, ${n.y})`}function We(n){const e=n.name?n.name:"Camera_"+n.id,s=ae(n.matrixWorld);return n.matrixWorld.determinant()<0&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",n),n.isOrthographicCamera?`def Camera "${e}"
|
|
141
141
|
{
|
|
142
142
|
matrix4d xformOp:transform = ${s}
|
|
143
143
|
uniform token[] xformOpOrder = ["xformOp:transform"]
|
|
@@ -161,4 +161,4 @@ ${i.join(`
|
|
|
161
161
|
float verticalAperture = ${n.getFilmHeight().toPrecision(E)}
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
`}class
|
|
164
|
+
`}class Xe{constructor(){H(this,"_gltfExporter");H(this,"_usdzExporter");this._gltfExporter=new X,this._usdzExporter=new Ue}async export(e,s,t){switch(s){case"glb":return this._exportGlb(e,t);case"gltf":return this._exportGltf(e,t);case"usdz":return this._exportUsdz(e,t);default:throw new L.FileTypeError(`Unsupported file type: ${s}`,s)}}async _exportGlb(e,s){try{const t=await this._gltfExporter.parseAsync(e,{...s,binary:!0});if(t instanceof ArrayBuffer)return t;throw new L.ParseError("Failed to export GLB: expected ArrayBuffer")}catch(t){throw t instanceof L.ParseError?t:new L.ParseError("Failed to export GLB",t)}}async _exportGltf(e,s){try{const t=await this._gltfExporter.parseAsync(e,{...s,binary:!1}),r=JSON.stringify(t);return new TextEncoder().encode(r).buffer}catch(t){throw t instanceof L.ParseError?t:new L.ParseError("Failed to export GLTF",t)}}async _exportUsdz(e,s){try{return(await this._usdzExporter.parse(e,s)).buffer}catch(t){throw t instanceof L.ParseError?t:new L.ParseError("Failed to export USDZ",t)}}}exports.AssetExporter=Xe;
|
|
@@ -3,8 +3,7 @@ var Me = (n, e, s) => e in n ? Te(n, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var Y = (n, e, s) => Me(n, typeof e != "symbol" ? e + "" : e, s);
|
|
4
4
|
import { PlaneGeometry as ye, ShaderMaterial as we, Uniform as Ee, SRGBColorSpace as ue, Mesh as Ae, PerspectiveCamera as be, Scene as Z, WebGLRenderer as Ie, CanvasTexture as Re, Color as _e, Matrix4 as le, Vector3 as B, Quaternion as Se, BufferAttribute as L, CompressedTexture as j, Source as Ne, NoColorSpace as fe, MathUtils as q, RGBAFormat as Le, DoubleSide as pe, PropertyBinding as H, InterpolateDiscrete as ve, NearestFilter as Ce, NearestMipmapNearestFilter as Ue, NearestMipmapLinearFilter as Fe, LinearFilter as $e, LinearMipmapNearestFilter as Oe, LinearMipmapLinearFilter as Pe, ClampToEdgeWrapping as De, RepeatWrapping as Ge, MirroredRepeatWrapping as ke, InterpolateLinear as ze } from "three";
|
|
5
5
|
import { s as he, z as Be } from "./fflate.module-xyO_T3Zm.mjs";
|
|
6
|
-
import { F as He } from "./
|
|
7
|
-
import { P as N } from "./parse-error-IryNa_oq.mjs";
|
|
6
|
+
import { F as He, P as N } from "./parse-error-DfOPyLWM.mjs";
|
|
8
7
|
let O, K, C, G;
|
|
9
8
|
function z(n, e = 1 / 0, s = null) {
|
|
10
9
|
K || (K = new ye(2, 2, 1, 1)), C || (C = new we({
|
|
@@ -1567,7 +1566,7 @@ function _t(n) {
|
|
|
1567
1566
|
|
|
1568
1567
|
`;
|
|
1569
1568
|
}
|
|
1570
|
-
class
|
|
1569
|
+
class Ct {
|
|
1571
1570
|
constructor() {
|
|
1572
1571
|
Y(this, "_gltfExporter");
|
|
1573
1572
|
Y(this, "_usdzExporter");
|
|
@@ -1618,5 +1617,5 @@ class Ut {
|
|
|
1618
1617
|
}
|
|
1619
1618
|
}
|
|
1620
1619
|
export {
|
|
1621
|
-
|
|
1620
|
+
Ct as A
|
|
1622
1621
|
};
|
|
@@ -3,11 +3,10 @@ var Be = (d, e, t) => e in d ? ve(d, e, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var v = (d, e, t) => Be(d, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { TrianglesDrawMode as je, TriangleFanDrawMode as re, TriangleStripDrawMode as be, Loader as ae, LoaderUtils as X, FileLoader as K, MeshPhysicalMaterial as O, Vector2 as q, Color as U, LinearSRGBColorSpace as D, SRGBColorSpace as N, SpotLight as Ke, PointLight as Ve, DirectionalLight as We, Matrix4 as Y, Vector3 as B, Quaternion as Le, InstancedMesh as Xe, InstancedBufferAttribute as ze, Object3D as ce, TextureLoader as Me, ImageBitmapLoader as qe, BufferAttribute as P, InterleavedBuffer as Ye, InterleavedBufferAttribute as Je, LinearMipmapLinearFilter as Ie, NearestMipmapLinearFilter as Qe, LinearMipmapNearestFilter as Ze, NearestMipmapNearestFilter as $e, LinearFilter as Ce, NearestFilter as et, RepeatWrapping as J, MirroredRepeatWrapping as Ne, ClampToEdgeWrapping as De, PointsMaterial as tt, Material as Z, LineBasicMaterial as nt, MeshStandardMaterial as Oe, DoubleSide as st, MeshBasicMaterial as W, PropertyBinding as rt, BufferGeometry as ue, SkinnedMesh as ot, Mesh as Pe, LineSegments as it, Line as at, LineLoop as ct, Points as ut, Group as z, PerspectiveCamera as lt, MathUtils as ft, OrthographicCamera as dt, Skeleton as ht, AnimationClip as pt, Bone as mt, InterpolateDiscrete as gt, InterpolateLinear as ke, Texture as de, VectorKeyframeTrack as he, NumberKeyframeTrack as pe, QuaternionKeyframeTrack as me, ColorManagement as ge, FrontSide as At, Interpolant as Tt, Box3 as yt, Sphere as xt, NoColorSpace as H } from "three";
|
|
5
5
|
import { u as Rt, a as Ae } from "./fflate.module-xyO_T3Zm.mjs";
|
|
6
|
-
import { S as _t } from "./FileTypes-
|
|
6
|
+
import { S as _t } from "./FileTypes-rkWpMg2n.mjs";
|
|
7
7
|
import { g as wt, i as Et } from "./isFileTypeSupported-BSpswPHU.mjs";
|
|
8
|
-
import { F as Te } from "./
|
|
9
|
-
import {
|
|
10
|
-
import { A as xe } from "./AssetCache-Y5G3mQU1.mjs";
|
|
8
|
+
import { F as Te, P as ye } from "./parse-error-DfOPyLWM.mjs";
|
|
9
|
+
import { A as xe } from "./AssetCache-BvUcYEFC.mjs";
|
|
11
10
|
function Re(d, e) {
|
|
12
11
|
if (e === je)
|
|
13
12
|
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), d;
|
|
@@ -2287,7 +2286,7 @@ class fn extends cn {
|
|
|
2287
2286
|
), this.decoderPending;
|
|
2288
2287
|
}
|
|
2289
2288
|
}
|
|
2290
|
-
class
|
|
2289
|
+
class yn {
|
|
2291
2290
|
constructor() {
|
|
2292
2291
|
v(this, "_gltfLoader");
|
|
2293
2292
|
v(this, "_usdzLoader");
|
|
@@ -2305,31 +2304,38 @@ class xn {
|
|
|
2305
2304
|
);
|
|
2306
2305
|
const o = xe.read(e);
|
|
2307
2306
|
if (o)
|
|
2308
|
-
return o.
|
|
2309
|
-
const
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2307
|
+
return o.arrayBuffer ? this._parse(o.arrayBuffer, t) : o.promise.then((n) => this._parse(n, t));
|
|
2308
|
+
const r = await xe.create(e).load();
|
|
2309
|
+
return this._parse(r, t);
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2312
|
+
* parse function for the chunk
|
|
2313
|
+
* @param arrayBuffer - the array buffer to parse, will be provided within the chunk
|
|
2314
|
+
* @param type - the file type of the array buffer
|
|
2315
|
+
* @returns the parsed object, will be stored within the chunk
|
|
2316
|
+
*/
|
|
2317
|
+
async _parse(e, t) {
|
|
2318
|
+
try {
|
|
2319
|
+
switch (t) {
|
|
2320
|
+
case "glb":
|
|
2321
|
+
case "gltf":
|
|
2322
|
+
return (await this._gltfLoader.parseAsync(
|
|
2323
|
+
e,
|
|
2324
|
+
""
|
|
2325
|
+
)).scene;
|
|
2326
|
+
case "usdz":
|
|
2327
|
+
return await this._usdzLoader.parse(e);
|
|
2326
2328
|
}
|
|
2327
|
-
}
|
|
2328
|
-
|
|
2329
|
+
} catch (o) {
|
|
2330
|
+
throw o instanceof Error ? new ye(
|
|
2331
|
+
`Failed to parse ${t} file: ${o.message}`,
|
|
2332
|
+
o
|
|
2333
|
+
) : new ye(`Failed to parse ${t} file`);
|
|
2334
|
+
}
|
|
2329
2335
|
}
|
|
2330
2336
|
}
|
|
2331
2337
|
export {
|
|
2332
|
-
|
|
2338
|
+
yn as A,
|
|
2333
2339
|
fn as D,
|
|
2334
2340
|
ln as a
|
|
2335
2341
|
};
|