stack3js 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +141 -2
- package/THIRD-PARTY-LICENSES.md +100 -0
- package/bin/stack3.mjs +4237 -0
- package/examples/future-tank.stack3.json +1 -0
- package/examples/traffic-cone-4view.png +0 -0
- package/package.json +25 -4
- package/viewer/dist/THIRD-PARTY-LICENSES.md +174 -0
- package/viewer/dist/assets/GLTFExporter--hziUXc8.js +1 -0
- package/viewer/dist/assets/ant-mech-angled-leg-4view-BO2qt1_k.png +0 -0
- package/viewer/dist/assets/ant-mech-body-4view-D9xVPpbc.png +0 -0
- package/viewer/dist/assets/ant-mech-center-leg-4view-BcphjF_G.png +0 -0
- package/viewer/dist/assets/compare-B6DWTZS9.css +1 -0
- package/viewer/dist/assets/compare-DJ8rV3Rn.js +6 -0
- package/viewer/dist/assets/compare.worker-DK2lJl0n.js +21 -0
- package/viewer/dist/assets/concrete-barrier-4view-7PsO3Ftq.png +0 -0
- package/viewer/dist/assets/emscripten-module-uFzwHH0Y.wasm +0 -0
- package/viewer/dist/assets/emscripten-module.browser-BcR5qphc.js +1 -0
- package/viewer/dist/assets/ffi-Boa1QuFa.js +1 -0
- package/viewer/dist/assets/fillet-rover-body-4-view-Chk8Mx4R.png +0 -0
- package/viewer/dist/assets/fillet-rover-wheel-4-view-B-F8flOC.png +0 -0
- package/viewer/dist/assets/hull-4view-BPPqJYUz.png +0 -0
- package/viewer/dist/assets/hull-base-color-4view-DrQmdT3h.png +0 -0
- package/viewer/dist/assets/hull-clay-4view-3Cu-4Hvr.png +0 -0
- package/viewer/dist/assets/hull-depth-4view-DCOdT5ev.png +0 -0
- package/viewer/dist/assets/hull-normal-4view-CvLaFITy.png +0 -0
- package/viewer/dist/assets/inspection-robot-body-4-view-CLMaHFYm.png +0 -0
- package/viewer/dist/assets/inspection-robot-wheel-4-view-27wRsxcs.png +0 -0
- package/viewer/dist/assets/plastic-barrier-4view-DQkTBW_i.png +0 -0
- package/viewer/dist/assets/presets-DwdZVYhs.js +1 -0
- package/viewer/dist/assets/preview-cache-DRF_H5pq.js +58 -0
- package/viewer/dist/assets/project-BzR9Ensg.css +1 -0
- package/viewer/dist/assets/project-D8tR6U-_.js +17 -0
- package/viewer/dist/assets/reconstruct.worker-Cf8iZwT3.js +21 -0
- package/viewer/dist/assets/script-engine-CLj7QMLe.js +6 -0
- package/viewer/dist/assets/style-CMUT8CmM.css +1 -0
- package/viewer/dist/assets/style-CWGgpweN.js +3947 -0
- package/viewer/dist/assets/tank-hull-4view-B4sMMkP5.png +0 -0
- package/viewer/dist/assets/tank-track-4view-DAIiMTy3.png +0 -0
- package/viewer/dist/assets/tank-turret-4view-Cx0FuNFu.png +0 -0
- package/viewer/dist/assets/traffic-cone-4view-DG-TkITx.png +0 -0
- package/viewer/dist/assets/viewer-CyGodHLY.js +2 -0
- package/viewer/dist/assets/wet-floor-sign-4view-CWJDyeTX.png +0 -0
- package/viewer/dist/compare.html +47 -0
- package/viewer/dist/examples/traffic-cone-4view.png +0 -0
- package/viewer/dist/index.html +147 -0
- package/viewer/dist/playground/index.html +3342 -0
- package/viewer/dist/project.html +83 -0
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stack3js",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "Build 3D meshes and sprite stacks from orthographic atlases.",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ev3rlit/stack3.js.git"
|
|
10
|
+
},
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=22.12"
|
|
13
|
+
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"stack3": "./bin/stack3.mjs"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"vite": "7.3.8",
|
|
19
|
+
"pngjs": "7.0.0"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin",
|
|
23
|
+
"examples",
|
|
24
|
+
"viewer/dist",
|
|
25
|
+
"THIRD-PARTY-LICENSES.md"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Licenses
|
|
2
|
+
|
|
3
|
+
The app bundles dependencies which contain the following licenses:
|
|
4
|
+
|
|
5
|
+
## @jitl/quickjs-ffi-types - 0.32.0 (MIT)
|
|
6
|
+
|
|
7
|
+
The MIT License
|
|
8
|
+
|
|
9
|
+
quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
## @jitl/quickjs-wasmfile-release-sync - 0.32.0 (MIT)
|
|
30
|
+
|
|
31
|
+
quickjs-emscripten:
|
|
32
|
+
The MIT License
|
|
33
|
+
|
|
34
|
+
quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
|
|
35
|
+
|
|
36
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
37
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
38
|
+
in the Software without restriction, including without limitation the rights
|
|
39
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
40
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
41
|
+
furnished to do so, subject to the following conditions:
|
|
42
|
+
|
|
43
|
+
The above copyright notice and this permission notice shall be included in all
|
|
44
|
+
copies or substantial portions of the Software.
|
|
45
|
+
|
|
46
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
47
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
48
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
49
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
50
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
51
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
52
|
+
SOFTWARE.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
quickjs:
|
|
56
|
+
QuickJS Javascript Engine
|
|
57
|
+
|
|
58
|
+
Copyright (c) 2017-2021 Fabrice Bellard
|
|
59
|
+
Copyright (c) 2017-2021 Charlie Gordon
|
|
60
|
+
|
|
61
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
62
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
63
|
+
in the Software without restriction, including without limitation the rights
|
|
64
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
65
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
66
|
+
furnished to do so, subject to the following conditions:
|
|
67
|
+
|
|
68
|
+
The above copyright notice and this permission notice shall be included in
|
|
69
|
+
all copies or substantial portions of the Software.
|
|
70
|
+
|
|
71
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
72
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
73
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
74
|
+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
75
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
76
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
77
|
+
THE SOFTWARE.
|
|
78
|
+
|
|
79
|
+
## fflate - 0.8.3 (MIT)
|
|
80
|
+
|
|
81
|
+
MIT License
|
|
82
|
+
|
|
83
|
+
Copyright (c) 2026 Arjun Barrett
|
|
84
|
+
|
|
85
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
86
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
87
|
+
in the Software without restriction, including without limitation the rights
|
|
88
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
89
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
90
|
+
furnished to do so, subject to the following conditions:
|
|
91
|
+
|
|
92
|
+
The above copyright notice and this permission notice shall be included in all
|
|
93
|
+
copies or substantial portions of the Software.
|
|
94
|
+
|
|
95
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
96
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
97
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
98
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
99
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
100
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
101
|
+
SOFTWARE.
|
|
102
|
+
|
|
103
|
+
## quickjs-emscripten-core - 0.32.0 (MIT)
|
|
104
|
+
|
|
105
|
+
The MIT License
|
|
106
|
+
|
|
107
|
+
quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
|
|
108
|
+
|
|
109
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
110
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
111
|
+
in the Software without restriction, including without limitation the rights
|
|
112
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
113
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
114
|
+
furnished to do so, subject to the following conditions:
|
|
115
|
+
|
|
116
|
+
The above copyright notice and this permission notice shall be included in all
|
|
117
|
+
copies or substantial portions of the Software.
|
|
118
|
+
|
|
119
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
120
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
121
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
122
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
123
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
124
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
125
|
+
SOFTWARE.
|
|
126
|
+
|
|
127
|
+
## simplify-js - 1.2.4 (BSD-2-Clause)
|
|
128
|
+
|
|
129
|
+
Copyright (c) 2017, Vladimir Agafonkin
|
|
130
|
+
All rights reserved.
|
|
131
|
+
|
|
132
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
|
133
|
+
permitted provided that the following conditions are met:
|
|
134
|
+
|
|
135
|
+
1. Redistributions of source code must retain the above copyright notice, this list of
|
|
136
|
+
conditions and the following disclaimer.
|
|
137
|
+
|
|
138
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
139
|
+
of conditions and the following disclaimer in the documentation and/or other materials
|
|
140
|
+
provided with the distribution.
|
|
141
|
+
|
|
142
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
143
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
144
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
145
|
+
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
146
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
147
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
148
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
|
149
|
+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
150
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
151
|
+
|
|
152
|
+
## three - 0.181.2 (MIT)
|
|
153
|
+
|
|
154
|
+
The MIT License
|
|
155
|
+
|
|
156
|
+
Copyright © 2010-2025 three.js authors
|
|
157
|
+
|
|
158
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
159
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
160
|
+
in the Software without restriction, including without limitation the rights
|
|
161
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
162
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
163
|
+
furnished to do so, subject to the following conditions:
|
|
164
|
+
|
|
165
|
+
The above copyright notice and this permission notice shall be included in
|
|
166
|
+
all copies or substantial portions of the Software.
|
|
167
|
+
|
|
168
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
169
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
170
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
171
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
172
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
173
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
174
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as $,M as J,V as v,Q as ee,B as S,R as se,a as D,S as te,N as ne,b as k,c as ie,I as re,D as oe,P as z,d as ae,e as Y,f as ce,g as ue,h as le,i as fe,L as he,j as pe,k as de,l as xe,m as ye,n as ge,o as Te}from"./style-CWGgpweN.js";const j={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 H{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new Le(e)}),this.register(function(e){return new _e(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Ce(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new Fe(e)}),this.register(function(e){return new De(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new He(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}setTextureUtils(e){return this.textureUtils=e,this}parse(e,s,n,t){const i=new Se,r=[];for(let o=0,c=this.pluginCallbacks.length;o<c;o++)r.push(this.pluginCallbacks[o](i));i.setPlugins(r),i.setTextureUtils(this.textureUtils),i.writeAsync(e,s,t).catch(n)}parseAsync(e,s){const n=this;return new Promise(function(t,i){n.parse(e,t,i,s)})}}const g={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},G="KHR_mesh_quantization",R={};R[ue]=g.NEAREST;R[le]=g.NEAREST_MIPMAP_NEAREST;R[fe]=g.NEAREST_MIPMAP_LINEAR;R[he]=g.LINEAR;R[pe]=g.LINEAR_MIPMAP_NEAREST;R[de]=g.LINEAR_MIPMAP_LINEAR;R[xe]=g.CLAMP_TO_EDGE;R[ye]=g.REPEAT;R[ge]=g.MIRRORED_REPEAT;const K={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},we=new $,q=12,me=1179937895,Me=2,W=8,Ae=1313821514,Ee=5130562;function F(a,e){return a.length===e.length&&a.every(function(s,n){return s===e[n]})}function Ie(a){return new TextEncoder().encode(a).buffer}function Re(a){return F(a.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ne(a,e,s){const n={min:new Array(a.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(a.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let t=e;t<e+s;t++)for(let i=0;i<a.itemSize;i++){let r;a.itemSize>4?r=a.array[t*a.itemSize+i]:(i===0?r=a.getX(t):i===1?r=a.getY(t):i===2?r=a.getZ(t):i===3&&(r=a.getW(t)),a.normalized===!0&&(r=k.normalize(r,a.array))),n.min[i]=Math.min(n.min[i],r),n.max[i]=Math.max(n.max[i],r)}return n}function Z(a){return Math.ceil(a/4)*4}function P(a,e=0){const s=Z(a.byteLength);if(s!==a.byteLength){const n=new Uint8Array(s);if(n.set(new Uint8Array(a)),e!==0)for(let t=a.byteLength;t<s;t++)n[t]=e;return n.buffer}return a}function X(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function be(a,e){if(typeof OffscreenCanvas<"u"&&a instanceof OffscreenCanvas){let s;return e==="image/jpeg"?s=.92:e==="image/webp"&&(s=.8),a.convertToBlob({type:e,quality:s})}else return new Promise(s=>a.toBlob(s,e))}class Se{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+se}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,s,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);const t=this,i=t.buffers,r=t.json;n=t.options;const o=t.extensionsUsed,c=t.extensionsRequired,l=new Blob(i,{type:"application/octet-stream"}),h=Object.keys(o),u=Object.keys(c);if(h.length>0&&(r.extensionsUsed=h),u.length>0&&(r.extensionsRequired=u),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=l.size),n.binary===!0){const T=new FileReader;T.readAsArrayBuffer(l),T.onloadend=function(){const f=P(T.result),d=new DataView(new ArrayBuffer(W));d.setUint32(0,f.byteLength,!0),d.setUint32(4,Ee,!0);const x=P(Ie(JSON.stringify(r)),32),y=new DataView(new ArrayBuffer(W));y.setUint32(0,x.byteLength,!0),y.setUint32(4,Ae,!0);const M=new ArrayBuffer(q),N=new DataView(M);N.setUint32(0,me,!0),N.setUint32(4,Me,!0);const O=q+y.byteLength+x.byteLength+d.byteLength+f.byteLength;N.setUint32(8,O,!0);const p=new Blob([M,y,x,d,f],{type:"application/octet-stream"}),w=new FileReader;w.readAsArrayBuffer(p),w.onloadend=function(){s(w.result)}}}else if(r.buffers&&r.buffers.length>0){const T=new FileReader;T.readAsDataURL(l),T.onloadend=function(){const f=T.result;r.buffers[0].uri=f,s(r)}}else s(r)}serializeUserData(e,s){if(Object.keys(e.userData).length===0)return;const n=this.options,t=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){s.extensions===void 0&&(s.extensions={});for(const r in i.gltfExtensions)s.extensions[r]=i.gltfExtensions[r],t[r]=!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 t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(s)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new v;for(let t=0,i=e.count;t<i;t++)if(Math.abs(n.fromBufferAttribute(e,t).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 n=e.clone(),t=new v;for(let i=0,r=n.count;i<r;i++)t.fromBufferAttribute(n,i),t.x===0&&t.y===0&&t.z===0?t.setX(1):t.normalize(),n.setXYZ(i,t.x,t.y,t.z);return s.attributesNormalized.set(e,n),n}applyTextureTransform(e,s){let n=!1;const t={};(s.offset.x!==0||s.offset.y!==0)&&(t.offset=s.offset.toArray(),n=!0),s.rotation!==0&&(t.rotation=s.rotation,n=!0),(s.repeat.x!==1||s.repeat.y!==1)&&(t.scale=s.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=t,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,s){if(e===s)return e;function n(f){return f.colorSpace===ce?function(x){return x<.04045?x*.0773993808:Math.pow(x*.9478672986+.0521327014,2.4)}:function(x){return x}}e instanceof D&&(e=await this.decompressTextureAsync(e)),s instanceof D&&(s=await this.decompressTextureAsync(s));const t=e?e.image:null,i=s?s.image:null,r=Math.max(t?t.width:0,i?i.width:0),o=Math.max(t?t.height:0,i?i.height:0),c=X();c.width=r,c.height=o;const l=c.getContext("2d",{willReadFrequently:!0});l.fillStyle="#00ffff",l.fillRect(0,0,r,o);const h=l.getImageData(0,0,r,o);if(t){l.drawImage(t,0,0,r,o);const f=n(e),d=l.getImageData(0,0,r,o).data;for(let x=2;x<d.length;x+=4)h.data[x]=f(d[x]/256)*256}if(i){l.drawImage(i,0,0,r,o);const f=n(s),d=l.getImageData(0,0,r,o).data;for(let x=1;x<d.length;x+=4)h.data[x]=f(d[x]/256)*256}l.putImageData(h,0,0);const T=(e||s).clone();return T.source=new te(c),T.colorSpace=ne,T.channel=(e||s).channel,e&&s&&e.channel!==s.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),T}async decompressTextureAsync(e,s=1/0){if(this.textureUtils===null)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(e,s)}processBuffer(e){const s=this.json,n=this.buffers;return s.buffers||(s.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,s,n,t,i){const r=this.json;r.bufferViews||(r.bufferViews=[]);let o;switch(s){case g.BYTE:case g.UNSIGNED_BYTE:o=1;break;case g.SHORT:case g.UNSIGNED_SHORT:o=2;break;default:o=4}let c=e.itemSize*o;i===g.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);const l=Z(t*c),h=new DataView(new ArrayBuffer(l));let u=0;for(let d=n;d<n+t;d++){for(let x=0;x<e.itemSize;x++){let y;e.itemSize>4?y=e.array[d*e.itemSize+x]:(x===0?y=e.getX(d):x===1?y=e.getY(d):x===2?y=e.getZ(d):x===3&&(y=e.getW(d)),e.normalized===!0&&(y=k.normalize(y,e.array))),s===g.FLOAT?h.setFloat32(u,y,!0):s===g.INT?h.setInt32(u,y,!0):s===g.UNSIGNED_INT?h.setUint32(u,y,!0):s===g.SHORT?h.setInt16(u,y,!0):s===g.UNSIGNED_SHORT?h.setUint16(u,y,!0):s===g.BYTE?h.setInt8(u,y):s===g.UNSIGNED_BYTE&&h.setUint8(u,y),u+=o}u%c!==0&&(u+=c-u%c)}const T={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:l};return i!==void 0&&(T.target=i),i===g.ARRAY_BUFFER&&(T.byteStride=c),this.byteOffset+=l,r.bufferViews.push(T),{id:r.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const s=this,n=s.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(t){const i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){const r=P(i.result),o={buffer:s.processBuffer(r),byteOffset:s.byteOffset,byteLength:r.byteLength};s.byteOffset+=r.byteLength,t(n.bufferViews.push(o)-1)}})}processAccessor(e,s,n,t){const i=this.json,r={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let o;if(e.array.constructor===Float32Array)o=g.FLOAT;else if(e.array.constructor===Int32Array)o=g.INT;else if(e.array.constructor===Uint32Array)o=g.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=g.SHORT;else if(e.array.constructor===Uint16Array)o=g.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=g.BYTE;else if(e.array.constructor===Uint8Array)o=g.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(t===void 0||t===1/0)&&(t=e.count),t===0)return null;const c=Ne(e,n,t);let l;s!==void 0&&(l=e===s.index?g.ELEMENT_ARRAY_BUFFER:g.ARRAY_BUFFER);const h=this.processBufferView(e,o,n,t,l),u={bufferView:h.id,byteOffset:h.byteOffset,componentType:o,count:t,max:c.max,min:c.min,type:r[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(u)-1}processImage(e,s,n,t="image/png"){if(e!==null){const i=this,r=i.cache,o=i.json,c=i.options,l=i.pending;r.images.has(e)||r.images.set(e,{});const h=r.images.get(e),u=t+":flipY/"+n.toString();if(h[u]!==void 0)return h[u];o.images||(o.images=[]);const T={mimeType:t},f=X();f.width=Math.min(e.width,c.maxTextureSize),f.height=Math.min(e.height,c.maxTextureSize);const d=f.getContext("2d",{willReadFrequently:!0});if(n===!0&&(d.translate(0,f.height),d.scale(1,-1)),e.data!==void 0){s!==ie&&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 y=new Uint8ClampedArray(e.height*e.width*4);for(let M=0;M<y.length;M+=4)y[M+0]=e.data[M+0],y[M+1]=e.data[M+1],y[M+2]=e.data[M+2],y[M+3]=e.data[M+3];d.putImageData(new ImageData(y,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)d.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?l.push(be(f,t).then(y=>i.processBufferViewImage(y)).then(y=>{T.bufferView=y})):T.uri=re.getDataURL(f,t);const x=o.images.push(T)-1;return h[u]=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 n={magFilter:R[e.magFilter],minFilter:R[e.minFilter],wrapS:R[e.wrapS],wrapT:R[e.wrapT]};return s.samplers.push(n)-1}async processTextureAsync(e){const n=this.options,t=this.cache,i=this.json;if(t.textures.has(e))return t.textures.get(e);i.textures||(i.textures=[]),e instanceof D&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));let r=e.userData.mimeType;r==="image/webp"&&(r="image/png");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(o.name=e.name),await this._invokeAllAsync(async function(l){l.writeTexture&&await l.writeTexture(e,o)});const c=i.textures.push(o)-1;return t.textures.set(e,c),c}async processMaterialAsync(e){const s=this.cache,n=this.json;if(s.materials.has(e))return s.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const t={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(F(i,[1,1,1,1])||(t.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(t.pbrMetallicRoughness.metallicFactor=e.metalness,t.pbrMetallicRoughness.roughnessFactor=e.roughness):(t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){const o=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),c={index:await this.processTextureAsync(o),texCoord:o.channel};this.applyTextureTransform(c,o),t.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){const o={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(o,e.map),t.pbrMetallicRoughness.baseColorTexture=o}if(e.emissive){const o=e.emissive;if(Math.max(o.r,o.g,o.b)>0&&(t.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const l={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(l,e.emissiveMap),t.emissiveTexture=l}}if(e.normalMap){const o={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),t.normalTexture=o}if(e.aoMap){const o={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(o.strength=e.aoMapIntensity),this.applyTextureTransform(o,e.aoMap),t.occlusionTexture=o}e.transparent?t.alphaMode="BLEND":e.alphaTest>0&&(t.alphaMode="MASK",t.alphaCutoff=e.alphaTest),e.side===oe&&(t.doubleSided=!0),e.name!==""&&(t.name=e.name),this.serializeUserData(e,t),await this._invokeAllAsync(async function(o){o.writeMaterialAsync&&await o.writeMaterialAsync(e,t)});const r=n.materials.push(t)-1;return s.materials.set(e,r),r}async processMeshAsync(e){const s=this.cache,n=this.json,t=[e.geometry.uuid];if(Array.isArray(e.material))for(let p=0,w=e.material.length;p<w;p++)t.push(e.material[p].uuid);else t.push(e.material.uuid);const i=t.join(":");if(s.meshes.has(i))return s.meshes.get(i);const r=e.geometry;let o;e.isLineSegments?o=g.LINES:e.isLineLoop?o=g.LINE_LOOP:e.isLine?o=g.LINE_STRIP:e.isPoints?o=g.POINTS:o=e.material.wireframe?g.LINES:g.TRIANGLES;const c={},l={},h=[],u=[],T={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=r.getAttribute("normal");f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),r.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let d=null;for(let p in r.attributes){if(p.slice(0,5)==="morph")continue;const w=r.attributes[p];if(p=T[p]||p.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(p)||(p="_"+p),s.attributes.has(this.getUID(w))){l[p]=s.attributes.get(this.getUID(w));continue}d=null;const m=w.array;p==="JOINTS_0"&&!(m instanceof Uint16Array)&&!(m instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),d=new S(new Uint16Array(m),w.itemSize,w.normalized)):(m instanceof Uint32Array||m instanceof Int32Array)&&!p.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${p}" converted to type FLOAT.`),d=H.Utils.toFloat32BufferAttribute(w));const I=this.processAccessor(d||w,r);I!==null&&(p.startsWith("_")||this.detectMeshQuantization(p,w),l[p]=I,s.attributes.set(this.getUID(w),I))}if(f!==void 0&&r.setAttribute("normal",f),Object.keys(l).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const p=[],w=[],A={};if(e.morphTargetDictionary!==void 0)for(const m in e.morphTargetDictionary)A[e.morphTargetDictionary[m]]=m;for(let m=0;m<e.morphTargetInfluences.length;++m){const I={};let V=!1;for(const _ in r.morphAttributes){if(_!=="position"&&_!=="normal"){V||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),V=!0);continue}const b=r.morphAttributes[_][m],B=_.toUpperCase(),C=r.attributes[_];if(s.attributes.has(this.getUID(b,!0))){I[B]=s.attributes.get(this.getUID(b,!0));continue}const U=b.clone();if(!r.morphTargetsRelative)for(let E=0,Q=b.count;E<Q;E++)for(let L=0;L<b.itemSize;L++)L===0&&U.setX(E,b.getX(E)-C.getX(E)),L===1&&U.setY(E,b.getY(E)-C.getY(E)),L===2&&U.setZ(E,b.getZ(E)-C.getZ(E)),L===3&&U.setW(E,b.getW(E)-C.getW(E));I[B]=this.processAccessor(U,r),s.attributes.set(this.getUID(C,!0),I[B])}u.push(I),p.push(e.morphTargetInfluences[m]),e.morphTargetDictionary!==void 0&&w.push(A[m])}c.weights=p,w.length>0&&(c.extras={},c.extras.targetNames=w)}const x=Array.isArray(e.material);if(x&&r.groups.length===0)return null;let y=!1;if(x&&r.index===null){const p=[];for(let w=0,A=r.attributes.position.count;w<A;w++)p[w]=w;r.setIndex(p),y=!0}const M=x?e.material:[e.material],N=x?r.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let p=0,w=N.length;p<w;p++){const A={mode:o,attributes:l};if(this.serializeUserData(r,A),u.length>0&&(A.targets=u),r.index!==null){let I=this.getUID(r.index);(N[p].start!==void 0||N[p].count!==void 0)&&(I+=":"+N[p].start+":"+N[p].count),s.attributes.has(I)?A.indices=s.attributes.get(I):(A.indices=this.processAccessor(r.index,r,N[p].start,N[p].count),s.attributes.set(I,A.indices)),A.indices===null&&delete A.indices}const m=await this.processMaterialAsync(M[N[p].materialIndex]);m!==null&&(A.material=m),h.push(A)}y===!0&&r.setIndex(null),c.primitives=h,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(p){p.writeMesh&&p.writeMesh(e,c)});const O=n.meshes.push(c)-1;return s.meshes.set(i,O),O}detectMeshQuantization(e,s){if(this.extensionsUsed[G])return;let n;switch(s.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}s.normalized&&(n+=" normalized");const t=e.split("_",1)[0];j[t]&&j[t].includes(n)&&(this.extensionsUsed[G]=!0,this.extensionsRequired[G]=!0)}processCamera(e){const s=this.json;s.cameras||(s.cameras=[]);const n=e.isOrthographicCamera,t={type:n?"orthographic":"perspective"};return n?t.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:t.perspective={aspectRatio:e.aspect,yfov:k.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(t.name=e.type),s.cameras.push(t)-1}processAnimation(e,s){const n=this.json,t=this.nodeMap;n.animations||(n.animations=[]),e=H.Utils.mergeMorphTargetTracks(e.clone(),s);const i=e.tracks,r=[],o=[];for(let l=0;l<i.length;++l){const h=i[l],u=z.parseTrackName(h.name);let T=z.findNode(s,u.nodeName);const f=K[u.propertyName];if(u.objectName==="bones"&&(T.isSkinnedMesh===!0?T=T.skeleton.getBoneByName(u.objectIndex):T=void 0),!T||!f){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',h.name);continue}const d=1;let x=h.values.length/h.times.length;f===K.morphTargetInfluences&&(x/=T.morphTargetInfluences.length);let y;h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(y="CUBICSPLINE",x/=3):h.getInterpolation()===ae?y="STEP":y="LINEAR",o.push({input:this.processAccessor(new S(h.times,d)),output:this.processAccessor(new S(h.values,x)),interpolation:y}),r.push({sampler:o.length-1,target:{node:t.get(T),path:f}})}const c={name:e.name||"clip_"+n.animations.length,samplers:o,channels:r};return this.serializeUserData(e,c),n.animations.push(c),n.animations.length-1}processSkin(e){const s=this.json,n=this.nodeMap,t=s.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;const r=e.skeleton.bones[0];if(r===void 0)return null;const o=[],c=new Float32Array(i.bones.length*16),l=new J;for(let u=0;u<i.bones.length;++u)o.push(n.get(i.bones[u])),l.copy(i.boneInverses[u]),l.multiply(e.bindMatrix).toArray(c,u*16);return s.skins===void 0&&(s.skins=[]),s.skins.push({inverseBindMatrices:this.processAccessor(new S(c,16)),joints:o,skeleton:n.get(r)}),t.skin=s.skins.length-1}async processNodeAsync(e){const s=this.json,n=this.options,t=this.nodeMap;s.nodes||(s.nodes=[]);const i={};if(n.trs){const o=e.quaternion.toArray(),c=e.position.toArray(),l=e.scale.toArray();F(o,[0,0,0,1])||(i.rotation=o),F(c,[0,0,0])||(i.translation=c),F(l,[1,1,1])||(i.scale=l)}else e.matrixAutoUpdate&&e.updateMatrix(),Re(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 o=await this.processMeshAsync(e);o!==null&&(i.mesh=o)}else e.isCamera&&(i.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const r=s.nodes.push(i)-1;if(t.set(e,r),e.children.length>0){const o=[];for(let c=0,l=e.children.length;c<l;c++){const h=e.children[c];if(h.visible||n.onlyVisible===!1){const u=await this.processNodeAsync(h);u!==null&&o.push(u)}}o.length>0&&(i.children=o)}return await this._invokeAllAsync(function(o){o.writeNode&&o.writeNode(e,i)}),r}async processSceneAsync(e){const s=this.json,n=this.options;s.scenes||(s.scenes=[],s.scene=0);const t={};e.name!==""&&(t.name=e.name),s.scenes.push(t);const i=[];for(let r=0,o=e.children.length;r<o;r++){const c=e.children[r];if(c.visible||n.onlyVisible===!1){const l=await this.processNodeAsync(c);l!==null&&i.push(l)}}i.length>0&&(t.nodes=i),this.serializeUserData(e,t)}async processObjectsAsync(e){const s=new Y;s.name="AuxScene";for(let n=0;n<e.length;n++)s.children.push(e[n]);await this.processSceneAsync(s)}async processInputAsync(e){const s=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(t){t.beforeParse&&t.beforeParse(e)});const n=[];for(let t=0;t<e.length;t++)e[t]instanceof Y?await this.processSceneAsync(e[t]):n.push(e[t]);n.length>0&&await this.processObjectsAsync(n);for(let t=0;t<this.skins.length;++t)this.processSkin(this.skins[t]);for(let t=0;t<s.animations.length;++t)this.processAnimation(s.animations[t],e[0]);await this._invokeAllAsync(function(t){t.afterParse&&t.afterParse(e)})}async _invokeAllAsync(e){for(let s=0,n=this.plugins.length;s<n;s++)await e(this.plugins[s])}}class Le{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 n=this.writer,t=n.json,i=n.extensionsUsed,r={};e.name&&(r.name=e.name),r.color=e.color.toArray(),r.intensity=e.intensity,e.isDirectionalLight?r.type="directional":e.isPointLight?(r.type="point",e.distance>0&&(r.range=e.distance)):e.isSpotLight&&(r.type="spot",e.distance>0&&(r.range=e.distance),r.spot={},r.spot.innerConeAngle=(1-e.penumbra)*e.angle,r.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]||(t.extensions=t.extensions||{},t.extensions[this.name]={lights:[]},i[this.name]=!0);const o=t.extensions[this.name].lights;o.push(r),s.extensions=s.extensions||{},s.extensions[this.name]={light:o.length-1}}}class _e{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,s){if(!e.isMeshBasicMaterial)return;const t=this.writer.extensionsUsed;s.extensions=s.extensions||{},s.extensions[this.name]={},t[this.name]=!0,s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=.9}}class Ce{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,t=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){const r={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(r,e.clearcoatMap),i.clearcoatTexture=r}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const r={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(r,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=r}if(e.clearcoatNormalMap){const r={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(r.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(r,e.clearcoatNormalMap),i.clearcoatNormalTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Ue{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;const t=this.writer.extensionsUsed,i={};i.dispersion=e.dispersion,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Fe{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,t=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){const r={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(r,e.iridescenceMap),i.iridescenceTexture=r}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const r={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(r,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Oe{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,t=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){const r={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(r,e.transmissionMap),i.transmissionTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class ve{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,t=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){const r={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(r,e.thicknessMap),i.thicknessTexture=r}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class ze{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const t=this.writer.extensionsUsed,i={};i.ior=e.ior,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Be{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(we)&&!e.specularIntensityMap&&!e.specularColorMap)return;const n=this.writer,t=n.extensionsUsed,i={};if(e.specularIntensityMap){const r={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(r,e.specularIntensityMap),i.specularTexture=r}if(e.specularColorMap){const r={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(r,e.specularColorMap),i.specularColorTexture=r}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class De{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,t=n.extensionsUsed,i={};if(e.sheenRoughnessMap){const r={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(r,e.sheenRoughnessMap),i.sheenRoughnessTexture=r}if(e.sheenColorMap){const r={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(r,e.sheenColorMap),i.sheenColorTexture=r}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Ge{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,t=n.extensionsUsed,i={};if(e.anisotropyMap){const r={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(r,e.anisotropyMap),i.anisotropyTexture=r}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class Pe{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const t=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class ke{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const n=this.writer,t=n.extensionsUsed,i={};if(e.bumpMap){const r={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(r,e.bumpMap),i.bumpTexture=r}i.bumpFactor=e.bumpScale,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}}class He{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,s){if(!e.isInstancedMesh)return;const n=this.writer,t=e,i=new Float32Array(t.count*3),r=new Float32Array(t.count*4),o=new Float32Array(t.count*3),c=new J,l=new v,h=new ee,u=new v;for(let f=0;f<t.count;f++)t.getMatrixAt(f,c),c.decompose(l,h,u),l.toArray(i,f*3),h.toArray(r,f*4),u.toArray(o,f*3);const T={TRANSLATION:n.processAccessor(new S(i,3)),ROTATION:n.processAccessor(new S(r,4)),SCALE:n.processAccessor(new S(o,3))};t.instanceColor&&(T._COLOR_0=n.processAccessor(t.instanceColor)),s.extensions=s.extensions||{},s.extensions[this.name]={attributes:T},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}}H.Utils={insertKeyframe:function(a,e){const n=a.getValueSize(),t=new a.TimeBufferType(a.times.length+1),i=new a.ValueBufferType(a.values.length+n),r=a.createInterpolant(new a.ValueBufferType(n));let o;if(a.times.length===0){t[0]=e;for(let c=0;c<n;c++)i[c]=0;o=0}else if(e<a.times[0]){if(Math.abs(a.times[0]-e)<.001)return 0;t[0]=e,t.set(a.times,1),i.set(r.evaluate(e),0),i.set(a.values,n),o=0}else if(e>a.times[a.times.length-1]){if(Math.abs(a.times[a.times.length-1]-e)<.001)return a.times.length-1;t[t.length-1]=e,t.set(a.times,0),i.set(a.values,0),i.set(r.evaluate(e),a.values.length),o=t.length-1}else for(let c=0;c<a.times.length;c++){if(Math.abs(a.times[c]-e)<.001)return c;if(a.times[c]<e&&a.times[c+1]>e){t.set(a.times.slice(0,c+1),0),t[c+1]=e,t.set(a.times.slice(c+1),c+2),i.set(a.values.slice(0,(c+1)*n),0),i.set(r.evaluate(e),(c+1)*n),i.set(a.values.slice((c+1)*n),(c+2)*n),o=c+1;break}}return a.times=t,a.values=i,o},mergeMorphTargetTracks:function(a,e){const s=[],n={},t=a.tracks;for(let i=0;i<t.length;++i){let r=t[i];const o=z.parseTrackName(r.name),c=z.findNode(e,o.nodeName);if(o.propertyName!=="morphTargetInfluences"||o.propertyIndex===void 0){s.push(r);continue}if(r.createInterpolant!==r.InterpolantFactoryMethodDiscrete&&r.createInterpolant!==r.InterpolantFactoryMethodLinear){if(r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),r=r.clone(),r.setInterpolation(Te)}const l=c.morphTargetInfluences.length,h=c.morphTargetDictionary[o.propertyIndex];if(h===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(n[c.uuid]===void 0){u=r.clone();const f=new u.ValueBufferType(l*u.times.length);for(let d=0;d<u.times.length;d++)f[d*l+h]=u.values[d];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=f,n[c.uuid]=u,s.push(u);continue}const T=r.createInterpolant(new r.ValueBufferType(1));u=n[c.uuid];for(let f=0;f<u.times.length;f++)u.values[f*l+h]=T.evaluate(u.times[f]);for(let f=0;f<r.times.length;f++){const d=this.insertKeyframe(u,r.times[f]);u.values[d*l+h]=r.values[f]}}return a.tracks=s,a},toFloat32BufferAttribute:function(a){const e=new S(new Float32Array(a.count*a.itemSize),a.itemSize,!1);if(!a.normalized&&!a.isInterleavedBufferAttribute)return e.array.set(a.array),e;for(let s=0,n=a.count;s<n;s++)for(let t=0;t<a.itemSize;t++)e.setComponent(s,t,a.getComponent(s,t));return e}};export{H as GLTFExporter};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.comparison{display:block}.compare-controls{display:flex;flex-wrap:wrap;align-items:end;gap:10px 16px;margin-bottom:14px}.compare-controls>div{min-width:105px}.compare-controls>div:has(input[type=file]){width:190px}.compare-controls>div:has(input[type=range]){flex:0 1 105px}.compare-controls input[type=range]{min-height:36px}.compare-actions{display:flex;gap:6px}.compare-results{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.compare-results section{min-width:0;overflow:hidden;background:var(--surface);border:1px solid var(--border);border-radius:7px}.compare-results h2,.compare-results p{padding:9px 11px;margin:0}.compare-results p{color:var(--muted);font-size:13px}.compare-results figure{min-width:0;margin:0}.model{display:block;width:100%;height:auto;aspect-ratio:4 / 3;background:#121923}.compare-results figcaption{padding:7px 10px;overflow-wrap:anywhere;font-size:12px}.compare-results small{display:block;margin-top:3px;color:var(--muted);font-variant-numeric:tabular-nums}#comparison-status{display:block;margin-bottom:12px}#comparison-status[data-error=true]{color:#ffbfa6}#comparison-warnings{color:#f3c778;margin-bottom:12px}#comparison-warnings:empty{display:none}@media(min-width:825px){.compare-controls{position:sticky;top:0;z-index:1;padding-bottom:8px;background:#151b22}}@media(max-width:910px){.compare-results{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:570px){.compare-results{grid-template-columns:1fr}}.depth-fit>strong{display:block;padding:12px 11px 0;font-size:26px;font-variant-numeric:tabular-nums}.depth-fit table{width:calc(100% - 22px);margin:7px 11px;border-collapse:collapse;font-size:13px}.depth-fit th,.depth-fit td{border-bottom:1px solid var(--border);padding:6px 4px;text-align:right;font-variant-numeric:tabular-nums}.depth-fit th:first-child,.depth-fit td:first-child{text-align:left}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{G as ae,b as P,q as oe,V as y,W as he,O as we,e as fe,C as be,r as $,s as ye,A as Me,M as ne,g as ve,L as re,p as xe,t as Le,u as Ze}from"./style-CWGgpweN.js";import{m as Se,i as We,c as De}from"./presets-DwdZVYhs.js";const A=e=>document.getElementById(e),se=A("comparison-status"),Q=A("atlas"),w=A("part"),X=A("yaw"),V=A("pitch"),z=A("zoom"),K=A("layers"),F=A("spacing"),M=A("explode"),Y=A("clay"),Be=document.querySelector(".compare-results"),le=new URLSearchParams(location.search),E=le.get("session"),O=E&&/^[a-f0-9-]{36}$/.test(E)?"./__stack3_project/"+E:void 0;let L,v=0,N,ge,k,J=[],Ie,U=1;const _=new y;let Ce=[],T=0;const ee="top,left,front,rear",W={layers:80,resolution:144},q=Se.tank,ce="Future Tank · hull material passes",S={source:new URL(""+new URL("hull-4view-BPPqJYUz.png",import.meta.url).href,import.meta.url),clay:new URL(""+new URL("hull-clay-4view-3Cu-4Hvr.png",import.meta.url).href,import.meta.url),depth:new URL(""+new URL("hull-depth-4view-DCOdT5ev.png",import.meta.url).href,import.meta.url),baseColor:new URL(""+new URL("hull-base-color-4view-DrQmdT3h.png",import.meta.url).href,import.meta.url),normal:new URL(""+new URL("hull-normal-4view-CvLaFITy.png",import.meta.url).href,import.meta.url),calibration:new URL("data:application/json;base64,ewogICJzb3VyY2VBdGxhcyI6ICJodWxsLTR2aWV3LnBuZyIsCiAgImdlb21ldHJ5IjogInN0YWNrMyByZWd1bGFyaXplZCB2aXN1YWwgaHVsbCBmcm9tIHRoZSBSR0IgYXRsYXMgc2lsaG91ZXR0ZXMsIHdpdGggdGhlIHR1cm50YWJsZSBhbmQgbGFyZ2UgaGF0Y2ggcmVsaWVmIGd1aWRlZCBieSB2aXNpYmxlIHNvdXJjZSBnZW9tZXRyeSIsCiAgImRpbWVuc2lvbnMiOiBbCiAgICAxODc0LAogICAgNjkyCiAgXSwKICAibGF5b3V0IjogWwogICAgInRvcCIsCiAgICAibGVmdCIsCiAgICAiZnJvbnQiLAogICAgInJlYXIiCiAgXSwKICAicGl4ZWxzUGVyVW5pdCI6IDIwMCwKICAiZ3JvdW5kWSI6IDQ0MCwKICAiY2xheSI6IHsKICAgICJmaWxlIjogImh1bGwtY2xheS00dmlldy5wbmciLAogICAgImJhY2tncm91bmQiOiAidHJhbnNwYXJlbnQiCiAgfSwKICAiZGVwdGgiOiB7CiAgICAiZmlsZSI6ICJodWxsLWRlcHRoLTR2aWV3LnBuZyIsCiAgICAiZW5jb2RpbmciOiAiMTYtYml0IHVuc2lnbmVkIGdyYXlzY2FsZSwgbGluZWFyIGludmVyc2UgY2FtZXJhIGRpc3RhbmNlIiwKICAgICJiYWNrZ3JvdW5kIjogMCwKICAgICJ2YWxpZFJhbmdlIjogWwogICAgICAxLAogICAgICA2NTUzNQogICAgXSwKICAgICJkZWNvZGUiOiAiZGlzdGFuY2UgPSBuZWFyICsgKGZhciAtIG5lYXIpICogKDY1NTM1IC0gdmFsdWUpIC8gNjU1MzQiLAogICAgInVuaXRzIjogInN0YWNrMyBzY2VuZSB1bml0cyIsCiAgICAicGl4ZWxDZW50ZXJPZmZzZXQiOiAwLjUKICB9LAogICJ2aWV3cyI6IHsKICAgICJ0b3AiOiB7CiAgICAgICJyZWN0IjogWwogICAgICAgIDAsCiAgICAgICAgMCwKICAgICAgICAzOTYsCiAgICAgICAgNjkyCiAgICAgIF0sCiAgICAgICJhbmNob3IiOiBbCiAgICAgICAgMTk5LAogICAgICAgIDM0NgogICAgICBdLAogICAgICAib3JpZ2luIjogWwogICAgICAgIDAsCiAgICAgICAgMS4wNCwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJyaWdodCI6IFsKICAgICAgICAtMSwKICAgICAgICAwLAogICAgICAgIDAKICAgICAgXSwKICAgICAgInVwIjogWwogICAgICAgIDAsCiAgICAgICAgMCwKICAgICAgICAxCiAgICAgIF0sCiAgICAgICJmb3J3YXJkIjogWwogICAgICAgIDAsCiAgICAgICAgLTEsCiAgICAgICAgMAogICAgICBdLAogICAgICAibmVhciI6IDAsCiAgICAgICJmYXIiOiAxLjE0CiAgICB9LAogICAgImxlZnQiOiB7CiAgICAgICJyZWN0IjogWwogICAgICAgIDM5NiwKICAgICAgICAwLAogICAgICAgIDY4OCwKICAgICAgICA2OTIKICAgICAgXSwKICAgICAgImFuY2hvciI6IFsKICAgICAgICA3NDAsCiAgICAgICAgNDQwCiAgICAgIF0sCiAgICAgICJvcmlnaW4iOiBbCiAgICAgICAgLTAuOTQ1LAogICAgICAgIDAsCiAgICAgICAgMAogICAgICBdLAogICAgICAicmlnaHQiOiBbCiAgICAgICAgMCwKICAgICAgICAwLAogICAgICAgIDEKICAgICAgXSwKICAgICAgInVwIjogWwogICAgICAgIDAsCiAgICAgICAgMSwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJmb3J3YXJkIjogWwogICAgICAgIDEsCiAgICAgICAgMCwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJuZWFyIjogMCwKICAgICAgImZhciI6IDEuODkKICAgIH0sCiAgICAiZnJvbnQiOiB7CiAgICAgICJyZWN0IjogWwogICAgICAgIDEwODQsCiAgICAgICAgMCwKICAgICAgICAzOTQsCiAgICAgICAgNjkyCiAgICAgIF0sCiAgICAgICJhbmNob3IiOiBbCiAgICAgICAgMTI4MSwKICAgICAgICA0NDAKICAgICAgXSwKICAgICAgIm9yaWdpbiI6IFsKICAgICAgICAwLAogICAgICAgIDAsCiAgICAgICAgLTEuNjgwMDAwMDAwMDAwMDAwMgogICAgICBdLAogICAgICAicmlnaHQiOiBbCiAgICAgICAgLTEsCiAgICAgICAgMCwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJ1cCI6IFsKICAgICAgICAwLAogICAgICAgIDEsCiAgICAgICAgMAogICAgICBdLAogICAgICAiZm9yd2FyZCI6IFsKICAgICAgICAwLAogICAgICAgIDAsCiAgICAgICAgMQogICAgICBdLAogICAgICAibmVhciI6IDAsCiAgICAgICJmYXIiOiAzLjM2MDAwMDAwMDAwMDAwMDMKICAgIH0sCiAgICAicmVhciI6IHsKICAgICAgInJlY3QiOiBbCiAgICAgICAgMTQ3OCwKICAgICAgICAwLAogICAgICAgIDM5NiwKICAgICAgICA2OTIKICAgICAgXSwKICAgICAgImFuY2hvciI6IFsKICAgICAgICAxNjc1LAogICAgICAgIDQ0MAogICAgICBdLAogICAgICAib3JpZ2luIjogWwogICAgICAgIDAsCiAgICAgICAgMCwKICAgICAgICAxLjY4MDAwMDAwMDAwMDAwMDIKICAgICAgXSwKICAgICAgInJpZ2h0IjogWwogICAgICAgIDEsCiAgICAgICAgMCwKICAgICAgICAwCiAgICAgIF0sCiAgICAgICJ1cCI6IFsKICAgICAgICAwLAogICAgICAgIDEsCiAgICAgICAgMAogICAgICBdLAogICAgICAiZm9yd2FyZCI6IFsKICAgICAgICAwLAogICAgICAgIDAsCiAgICAgICAgLTEKICAgICAgXSwKICAgICAgIm5lYXIiOiAwLAogICAgICAiZmFyIjogMy4zNjAwMDAwMDAwMDAwMDAzCiAgICB9CiAgfSwKICAiYmFzZUNvbG9yIjogewogICAgImZpbGUiOiAiaHVsbC1iYXNlLWNvbG9yLTR2aWV3LnBuZyIsCiAgICAiZW5jb2RpbmciOiAiUkdCQTggc1JHQiIsCiAgICAic291cmNlIjogImdlbmVyYXRlZCBtYXRlcmlhbCBwYXNzIHJlZ2lzdGVyZWQgcGVyIHZpZXcgdG8gdGhlIENsYXkgc2lsaG91ZXR0ZXMiCiAgfSwKICAibm9ybWFsIjogewogICAgImZpbGUiOiAiaHVsbC1ub3JtYWwtNHZpZXcucG5nIiwKICAgICJlbmNvZGluZyI6ICJSR0JBOCBsaW5lYXIgZGF0YSIsCiAgICAic3BhY2UiOiAidmlldyIsCiAgICAiYXhlcyI6IHsKICAgICAgInJlZCI6ICIrWCBpbWFnZSByaWdodCIsCiAgICAgICJncmVlbiI6ICIrWSBpbWFnZSB1cCIsCiAgICAgICJibHVlIjogIitaIHRvd2FyZCB0aGUgY2FtZXJhIgogICAgfSwKICAgICJkZWNvZGUiOiAibm9ybWFsID0gbm9ybWFsaXplKDIgKiBSR0IgLyAyNTUgLSAxKSIsCiAgICAiYmFja2dyb3VuZCI6ICJhbHBoYSAwIgogIH0sCiAgInNpemUiOiBbCiAgICAxLjY5LAogICAgMy4xNiwKICAgIDAuOTQKICBdCn0K",import.meta.url)},Ae=["Armored tank · full (assembled)",...q.map(e=>"Armored tank · "+e.name.toLowerCase()),ce],D=["Voxel surface","Marching Cubes","Finer grid","RGB · nearest","RGB · linear","RGB + ID","RGB + ID + depth"];function Z(e,s=!1){se.value=e,se.dataset.error=String(s)}function Ke(){const e=new he({antialias:!0}),s=Math.min(devicePixelRatio,2),t=new we(-1,1,1,-1,.01,50),a=new fe;a.background=new be("#121923");const n=new $({color:"#b4bac3",roughness:.85}),o=new ye("#fff2e5",2.6);o.position.set(3,6,-4),a.add(o,new Me("#b6c9e4",1.5));let r=0,i=0;return{gray:n,draw(g,l,C){const c=Math.round(l.clientWidth*s),d=Math.round(l.clientHeight*s);if(!c||!d)return;const b=c/d,I=U/Math.min(1,b)/Number(z.value);t.left=-I*b,t.right=I*b,t.top=I,t.bottom=-I;const p=P.degToRad(Number(X.value)),u=P.degToRad(Number(V.value)),m=Math.max(8,U*4);t.far=m+U*3,t.position.set(Math.sin(p)*Math.cos(u)*m,Math.sin(u)*m,-Math.cos(p)*Math.cos(u)*m).add(_),t.lookAt(_),t.updateProjectionMatrix(),(c!==r||d!==i)&&(e.setSize(c,d,!1),r=c,i=d),(l.width!==c||l.height!==d)&&(l.width=c,l.height=d),a.add(g),e.render(a,t),C.drawImage(e.domElement,0,0),a.remove(g)}}}function Ne(e,s){const t=new $({map:e.map,roughness:.82});if(e.dispose(),!s)return t;const a=new Le(s.data,s.width,s.height);return a.minFilter=a.magFilter=re,a.needsUpdate=!0,t.normalMap=a,t.normalMapType=Ze,t.onBeforeCompile=n=>{n.fragmentShader=n.fragmentShader.replace("#include <normal_fragment_maps>",`
|
|
2
|
+
vec3 geometricNormal = normal;
|
|
3
|
+
#include <normal_fragment_maps>
|
|
4
|
+
float coverage = texture2D(normalMap, vNormalMapUv).a;
|
|
5
|
+
normal = normalize(mix(geometricNormal, normal, coverage));
|
|
6
|
+
`)},t}function je(e,s,t){const a=s.getContext("2d",{alpha:!1});if(!a)throw new Error("Could not create a thumbnail surface.");const n=We(e.parts.map(I=>I.asset),e.parts),o=e.parts.flatMap(I=>I.mounts),r=e.parts.flatMap(I=>I.mounts.map(()=>I.normalMap)),i=De(n),g=e.nearest?ve:re,l=[],C=[];for(const[I,{asset:p}]of n.entries()){const u=i.children[I],m=o[I].matrix;if(m&&(u.matrix.fromArray(m),u.matrixAutoUpdate=!1,u.matrixWorldNeedsUpdate=!0),p.target==="stack"){C.push({object:u,asset:p});continue}const h=u,f=h.material,x=e.lit?Ne(f,r[I]):f;x.map&&(x.map.minFilter=x.map.magFilter=g,x.map.needsUpdate=!0);const te=!e.geometryOnly&&p.frontAccents,G=te?xe(te):void 0;G&&(G.material.alphaTest=.4,h.add(G)),l.push({mesh:h,textured:x,accent:G})}const c=i.children.map(I=>(I.matrixAutoUpdate&&I.updateMatrix(),I.matrixAutoUpdate=!1,I.matrix.clone()));let d=1,b=0;return{surface:s,isStack:C.length>0,draw(){const I=M.valueAsNumber/100;if(I!==b){for(const[m,h]of i.children.entries()){const f=Ce[m];h.matrix.copy(c[m]),h.matrix.elements[12]+=f.x*I,h.matrix.elements[13]+=f.y*I,h.matrix.elements[14]+=f.z*I,h.matrixWorldNeedsUpdate=!0}b=I}const p=F.valueAsNumber;if(C.length&&p!==d){for(const{object:m,asset:h}of C)for(const[f,x]of m.children.entries())x.position.y=((f+.5)*h.spacing-h.pivot[2])*p;d=p}const u=e.geometryOnly||Y.getAttribute("aria-pressed")==="true";for(const{mesh:m,textured:h,accent:f}of l)m.material=u?t.gray:h,f&&(f.visible=!u);t.draw(i,s,a)},dispose(){for(const{object:I}of C){const p=I.children;p[0]?.geometry.dispose();for(const u of p){const m=u.material;m.map?.dispose(),m.dispose()}}for(const{mesh:I,textured:p,accent:u}of l){if(I.geometry.dispose(),p.map?.dispose(),p instanceof $&&p.normalMap?.dispose(),p.dispose(),!u)continue;u.geometry.dispose();const m=u.material;m.map?.dispose(),m.dispose()}}}}function Fe(e){const s=r=>e.map(i=>({name:i.name,mounts:i.mounts,asset:typeof r=="number"?i.meshes[r]:i[r],grid:r==="voxel"||r==="marching"?i.coarseGrid:i.fullGrid})),t=s(0),a=e.every(r=>r.fullGrid.every((i,g)=>i===r.coarseGrid[g])),n=[{title:"RGB only",detail:"Visual hull and RGB projection",parts:t},{title:"RGB + ID",detail:"Keeps accent colors on visible source-facing surfaces",parts:s(1)},{title:"RGB + ID + depth",detail:"Rebuilds the surface with smoother depth transitions",parts:s(2)}],o=[{title:"Sprite Stack",detail:"Spacing changes the distance between these horizontal slices.",parts:s("stack")},{title:D[0],detail:"Exposed faces of the occupied cells.",parts:s("voxel"),geometryOnly:!0},{title:D[1],detail:"Interpolated surface from the same occupied cells.",parts:s("marching"),geometryOnly:!0},{title:D[2],detail:a?"Only one occupied grid was available at these settings.":"Marching Cubes rebuilt with the full sampling grid.",parts:t,geometryOnly:!0},{title:D[3],detail:"Projects the atlas onto that mesh, using the closest texel.",parts:t,nearest:!0},{title:D[4],detail:"Blends nearby texels on the same textured mesh.",parts:t},n[1],n[2]];if(e.some(r=>r.mapped)){const r=e.map(l=>({name:l.name,mounts:l.mounts,asset:l.mapped?.mesh??l.meshes[0],grid:l.mapped?.grid??l.fullGrid})),i=r.map((l,C)=>({...l,normalMap:e[C].mapped?.normalMap})),g=r.map((l,C)=>({...l,asset:e[C].mapped?.silhouetteMesh??l.asset}));o.unshift({title:"Clay Silhouette Only",detail:"Uses the same calibrated Clay views, grid, and lighting.",parts:g,geometryOnly:!0},{title:"Clay + Depth Map",detail:"Uses the 16-bit depth pass to carve the registered Clay silhouettes.",parts:r,geometryOnly:!0},{title:"Depth + Base Color",detail:"Projects the generated color pass onto the depth-carved mesh.",parts:r,lit:!0},{title:"Depth + Base Color + Normal",detail:"Uses the view-space normal pass for per-pixel lighting on the same mesh.",parts:i,lit:!0})}return o}function Oe(e,s){const t=document.createElement("figure"),a=document.createElement("canvas");a.className="model",a.setAttribute("role","img"),a.setAttribute("aria-label",e.title),t.append(a);const n=document.createElement("figcaption"),o=document.createElement("small"),r=e.parts.map(({name:l,grid:C})=>(l?l+" ":"")+C.join(" × ")).join(" · "),i=e.parts.reduce((l,{asset:C,mounts:c})=>l+(C.target==="stack"?C.layers:C.indices.length/3)*c.length,0),g=e.parts[0].asset.target==="stack"?" slices":" triangles";o.textContent=r+" cells · "+i.toLocaleString()+g,n.append(o),t.append(n),s.append(t),J.push(je(e,a,Ie)),ue.observe(a)}function Je(e){const s=document.createElement("section");s.className="depth-fit";const t=document.createElement("h2");t.textContent="Depth Fit",s.append(t);const a=c=>c===null?"—":c.toFixed(3),n=document.createElement("strong");n.textContent=a(e.baselineMae)+" → "+a(e.carvedMae)+" units",s.append(n);const o=document.createElement("p"),r=e.baselineMae&&e.carvedMae!==null?100*(e.carvedMae/e.baselineMae-1):null;o.textContent="Mean absolute distance error against the supplied depth map"+(r===null?".":" · "+(r>0?"+":"−")+Math.abs(r).toFixed(1)+"%"),s.append(o);const i=document.createElement("table");i.setAttribute("aria-label","Mean absolute depth error by camera");const g=i.createTHead().insertRow();for(const c of["View","Clay only","+ Depth"]){const d=document.createElement("th");d.scope="col",d.textContent=c,g.append(d)}const l=i.createTBody();for(const c of e.byView){const d=l.insertRow();for(const b of[c.view.toUpperCase(),a(c.baselineMae),a(c.carvedMae)])d.insertCell().textContent=b}s.append(i);const C=document.createElement("p");return C.textContent=e.sharedPixels.toLocaleString()+" shared visible pixels · "+(100*e.sharedPixels/Math.max(1,e.referencePixels)).toFixed(1)+"% of reference",s.append(C),s}function Re(e){for(const n of J)ue.unobserve(n.surface),n.dispose();J=[];const s=Fe(e.parts),t=e.parts.find(n=>n.mapped)?.mapped?.fit,a=document.createDocumentFragment();for(const n of s){const o=document.createElement("section"),r=document.createElement("h2"),i=document.createElement("p");r.textContent=n.title,i.textContent=n.detail,o.append(r),Oe(n,o),o.append(i),a.append(o),t&&n.title==="Clay + Depth Map"&&a.append(Je(t))}Be.replaceChildren(a),R()}function R(){T||(T=requestAnimationFrame(()=>{T=0,A("yaw-value").textContent=X.value+"°",A("pitch-value").textContent=V.value+"°",A("zoom-value").textContent=z.value+"×",A("explode-value").textContent=M.value+"%",J.forEach(e=>e.draw())}))}function me(){return window.clearTimeout(ge),N?.terminate(),N=void 0,++v}function de(e,s,t){const a=new Worker(new URL(""+new URL("compare.worker-DK2lJl0n.js",import.meta.url).href,import.meta.url),{type:"module"});N=a,a.onerror=()=>{a.terminate(),t===v&&(N=void 0,Z("The comparison worker could not start.",!0))},a.onmessage=({data:n})=>{if(a.terminate(),t===v){if(N=void 0,"error"in n){Z(n.error,!0);return}try{Ee(n,s)}catch(o){Z(o instanceof Error?o.message:String(o),!0)}}},a.postMessage(e)}function B(e,s){const t=me();k=void 0,K.disabled=!0,F.disabled=!0,M.disabled=!0,Z("Building comparison from "+s+"…"),A("comparison-warnings").replaceChildren(),e().then(a=>{if(t!==v)return;k={job:a,name:s};const n="parts"in a?a.parts.map(r=>r.settings):[a.settings],o=n[0].layers??W.layers;K.value=String(o),A("layers-value").textContent=n.every(r=>(r.layers??W.layers)===o)?String(o):"Per part",K.disabled=!1,de(a,s,t)}).catch(a=>{t===v&&Z(String(a),!0)})}function Ge(e){return e.flatMap(s=>{const{size:[t,a,n],pivot:o}=s.meshes[0],r=new oe(new y(-t/2,-o[2],-a/2),new y(t/2,n-o[2],a/2));return s.mounts.map(({position:[i,g,l],scale:C=1,matrix:c})=>{const d=c?new ne().fromArray(c):new ne().makeScale(C,C,C).setPosition(i,l,-g);return r.clone().applyMatrix4(d)})})}function Ye(e,s){const t=e.map(i=>i.getSize(new y)),a=t.reduce((i,g,l)=>g.x*g.z>t[i].x*t[i].z?l:i,0),n=e[a].getCenter(new y),o=t[a],r=Math.max(s.x,s.y,s.z)*.12;return e.map((i,g)=>{if(g===a)return new y;const l=i.getCenter(new y).sub(n),C=l.y>o.y*.18;l.y=0;const c=Math.hypot(l.x/o.x,l.z/o.z);return c>.16?l.normalize().multiplyScalar(r):l.set(0,0,0),(C||c<=.16)&&(l.y=r),l})}function Ee(e,s){Ie??=Ke();const t=Ge(e.parts),a=t.reduce((r,i)=>r.union(i),new oe),n=a.getSize(new y);U=n.length()*.53,a.getCenter(_),Ce=Ye(t,n),M.disabled=t.length<2,M.disabled&&(M.value=M.defaultValue),A("comparison-warnings").replaceChildren(...e.warnings.map(r=>{const i=document.createElement("li");return i.textContent=r,i})),Re(e),F.disabled=!1;const o=e.parts.length>1?" "+e.parts.length+" atlases reconstructed separately.":"";Z(s+" · Comparison ready."+o+" Camera settings are shared.")}function pe(){const e=L?.nodes.filter(n=>n.atlasId)??[],s=document.createElement("optgroup");s.label="Built-in atlases",s.append(...Ae.map((n,o)=>new Option(n,"sample:"+o)));const t=document.createElement("optgroup");t.label=L?.name??"Project",t.append(...e.map(n=>new Option(n.name,n.id))),e.length>1&&t.append(new Option("Project · full (assembled)","project:assembly"));const a=e.length?[t,s]:[s];w.replaceChildren(...a)}function Ue(e){const s=new ae,t=new Map(e.map(n=>{const o=new ae;return o.position.set(...n.position),o.rotation.set(...n.rotation.map(P.degToRad)),o.scale.set(...n.scale),o.visible=n.visible,[n.id,o]}));for(const n of e)((n.parentId?t.get(n.parentId):void 0)??s).add(t.get(n.id));s.updateMatrixWorld(!0);const a=new Set;return s.traverseVisible(n=>a.add(n)),e.flatMap(n=>{const o=t.get(n.id);return n.atlasId&&a.has(o)?[{node:n,matrix:o.matrixWorld.toArray()}]:[]})}async function ie(e){const s=O+"/atlas/"+encodeURIComponent(e.id),t=await fetch(s);if(!t.ok)throw new Error("Could not load the project atlas.");return{file:await t.blob(),layout:e.layout}}async function ke(){async function e(i){const g=await fetch(i);if(!g.ok)throw new Error("Could not load the hull material passes.");return g}const[s,t,a,n,o,r]=await Promise.all([e(S.source).then(i=>i.blob()),e(S.clay).then(i=>i.blob()),e(S.depth).then(i=>i.blob()),e(S.baseColor).then(i=>i.blob()),e(S.normal).then(i=>i.blob()),e(S.calibration).then(i=>i.json())]);return{file:s,layout:ee,settings:{...W,size:r.size},maps:{clay:t,depth:a,baseColor:n,normal:o,calibration:r}}}function j(){if(w.value.startsWith("sample:")){const t=Number(w.value.slice(7)),a=Ae[t];if(!a)return;if(a===ce){B(ke,a);return}B(async()=>{async function n(r){const i=await fetch(r);if(!i.ok)throw new Error("Could not load the built-in atlas.");return{file:await i.blob(),layout:ee}}if(t===0)return{parts:await Promise.all(q.map(async({name:i,url:g,size:l,mounts:C})=>({...await n(g),name:i,mounts:C,settings:{...W,size:l,height:l?.[2]}})))};const o=q[t-1].url;return{...await n(o),settings:W}},a);return}if(w.value==="project:assembly"&&L&&O){const t=L;B(async()=>{const a=Ue(t.nodes);if(!a.length)throw new Error("No visible atlas parts in the project.");const n=new Map;return{parts:await Promise.all(a.map(async({node:r,matrix:i})=>{const g=t.atlases.find(l=>l.id===r.atlasId);if(!g)throw new Error("Missing atlas for "+r.name);return n.has(g.id)||n.set(g.id,ie(g)),{...await n.get(g.id),name:r.name,mounts:[{name:r.name,position:[0,0,0],matrix:i}],settings:r.settings}}))}},t.name+" · full (assembled)");return}const e=L?.nodes.find(t=>t.id===w.value),s=L?.atlases.find(t=>t.id===e?.atlasId);!O||!e||!s||B(async()=>({...await ie(s),settings:e.settings}),e.name)}Q.addEventListener("change",()=>{const e=Q.files?.[0];e&&(w.selectedIndex=-1,B(async()=>({file:e,layout:ee,settings:W}),e.name))});w.addEventListener("change",()=>{Q.value="",j()});K.addEventListener("input",()=>{if(!k)return;const{job:e,name:s}=k,t=K.valueAsNumber,a=me();A("layers-value").textContent=String(t),Z("Rebuilding "+s+" at "+t+" layers…");const n="parts"in e?{parts:e.parts.map(o=>({...o,settings:{...o.settings,layers:t}}))}:{...e,settings:{...e.settings,layers:t}};ge=window.setTimeout(()=>de(n,s,a),85)});F.addEventListener("input",()=>{A("spacing-value").textContent=F.valueAsNumber.toFixed(2)+"×",J.find(e=>e.isStack)?.draw()});for(const e of[X,V,z,M])e.addEventListener("input",R);Y.addEventListener("click",()=>{Y.setAttribute("aria-pressed",String(Y.getAttribute("aria-pressed")!=="true")),R()});A("reset").addEventListener("click",()=>{for(const e of[X,V,z])e.value=e.defaultValue;R()});const ue=new ResizeObserver(R);pe();const H=le.get("sample");H!==null&&[...w.options].some(e=>e.value==="sample:"+H)&&(w.value="sample:"+H,j());if(O){const e=A("back");e.href="./project.html?session="+E+"&playground=1",e.textContent="Playground",fetch(O+"/state").then(async s=>{if(!s.ok)throw new Error("Could not read the project.");L=await s.json();const t=w.value;pe(),v?w.value=t:([...w.options].some(a=>a.value==="project:assembly")&&(w.value="project:assembly"),j())}).catch(()=>{v||j()})}else v||j();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
(function(){"use strict";const At=["top","left","front","rear","right","bottom"];function Gt(n){const t=[137,80,78,71,13,10,26,10];if(n.length<33||t.some((c,l)=>n[l]!==c)||String.fromCharCode(...n.subarray(12,16))!=="IHDR")throw new Error("Expected a PNG image.");const e=new DataView(n.buffer,n.byteOffset,n.byteLength),r=e.getUint32(16),i=e.getUint32(20);if(!r||!i||r>8192||i>8192||r*i>16e6)throw new Error("PNG dimensions exceed the 8192 px or 16 MP input limit.");return{width:r,height:i}}function bt(n){const t=n.split(",").map(e=>e.trim());if(t.some(e=>!At.includes(e)))throw new Error("Use directions top, left, front, rear, right, and bottom.");if(t.length!==4&&t.length!==6||new Set(t).size!==t.length||At.slice(0,t.length).some(e=>!t.includes(e)))throw new Error("A layout needs the four required directions or all six, with no duplicates.");return t}function Kt(n,t){const{width:e,height:r}=n,i=new Uint8Array(n.data),c=e*r;for(let s=3;s<i.length;s+=4)if(i[s]<128)return{width:e,height:r,data:i};const l=new Uint8Array(c),a=new Uint32Array(c);let o=0,f=0;function A(s){if(l[s])return;l[s]=1;const h=s*4;Math.min(i[h],i[h+1],i[h+2])>=t&&(a[f++]=s)}for(let s=0;s<e;s++)A(s),A((r-1)*e+s);for(let s=1;s<r-1;s++)A(s*e),A(s*e+e-1);for(;o<f;){const s=a[o++];i[s*4+3]=0;const h=s%e;h&&A(s-1),h+1<e&&A(s+1),s>=e&&A(s-e),s+e<c&&A(s+e)}return{width:e,height:r,data:i}}function Jt(n,t){const{left:e,top:r,width:i,height:c}=t,l=new Uint8Array(i*c*4);for(let a=0;a<c;a++){const o=((r+a)*n.width+e)*4;l.set(n.data.subarray(o,o+i*4),a*i*4)}return{width:i,height:c,data:l}}function Yt(n,t){const{left:e,top:r,width:i,height:c}=t;let l=e+i,a=-1,o=r+c,f=-1;for(let A=r;A<r+c;A++)for(let s=e;s<e+i;s++)n.data[(A*n.width+s)*4+3]<128||(l=Math.min(l,s),a=Math.max(a,s),o=Math.min(o,A),f=Math.max(f,A));return a<0?null:{left:l,top:o,width:a-l+1,height:f-o+1}}function Pt(n){const t=[];let e=-1;for(let r=0;r<=n.length;r++)n[r]?e<0&&(e=r):e>=0&&(t.push([e,r]),e=-1);return t}function St(n,t,e){const r=new Uint8Array(n.width);for(let i=t;i<e;i++)for(let c=0;c<n.width;c++)n.data[(i*n.width+c)*4+3]>=128&&(r[c]=1);return Pt(r)}function on(n,t){bt(t.join(","));let e=St(n,0,n.height).map(([r,i])=>({left:r,top:0,width:i-r,height:n.height}));if(e.length!==t.length){const r=new Uint8Array(n.height);for(let i=0;i<n.height;i++)for(let c=0;c<n.width;c++)if(n.data[(i*n.width+c)*4+3]>=128){r[i]=1;break}e=Pt(r).flatMap(([i,c])=>St(n,i,c).map(([l,a])=>({left:l,top:i,width:a-l,height:c-i})))}if(e.length!==t.length)throw new Error(`Expected ${t.length} separated views, found ${e.length}. Use clear gutters or individual PNGs.`);return e.map(r=>Yt(n,r))}function sn(n,t,e=238){const r=Kt(n,e);return Object.fromEntries(on(r,t).map((i,c)=>{const l=Jt(r,i),a=l.width+2,o=l.height+2,f=new Uint8Array(a*o*4);for(let A=0;A<l.height;A++)f.set(l.data.subarray(A*l.width*4,(A+1)*l.width*4),((A+1)*a+1)*4);return[t[c],{width:a,height:o,data:f}]}))}function Nt(n,t=238){bt(Object.keys(n).join(","));const e=Object.entries(n);return Object.fromEntries(e.map(([r,i])=>{const c=Kt(i,t),l=Yt(c,{left:0,top:0,width:c.width,height:c.height});if(!l)throw new Error(`The ${r} view has an empty silhouette.`);return[r,Jt(c,l)]}))}function an(n){const{top:t,left:e,front:r,rear:i}=n,c=e.width/e.height*t.width/t.height,l=r.width/r.height,a=[];return Math.abs(c/l-1)>.2&&a.push("Top, left, and front proportions differ by more than 20%. Check alignment."),Math.abs(i.width/i.height/l-1)>.2&&a.push("Front and rear proportions differ by more than 20%."),{views:Object.entries(n).map(([f,A])=>({direction:f,width:A.width,height:A.height})),warnings:a}}var Ut={exports:{}},Tt;function cn(){return Tt||(Tt=1,(function(n){(function(){function t(a,o){var f=a.x-o.x,A=a.y-o.y;return f*f+A*A}function e(a,o,f){var A=o.x,s=o.y,h=f.x-A,C=f.y-s;if(h!==0||C!==0){var u=((a.x-A)*h+(a.y-s)*C)/(h*h+C*C);u>1?(A=f.x,s=f.y):u>0&&(A+=h*u,s+=C*u)}return h=a.x-A,C=a.y-s,h*h+C*C}function r(a,o){for(var f=a[0],A=[f],s,h=1,C=a.length;h<C;h++)s=a[h],t(s,f)>o&&(A.push(s),f=s);return f!==s&&A.push(s),A}function i(a,o,f,A,s){for(var h=A,C,u=o+1;u<f;u++){var p=e(a[u],a[o],a[f]);p>h&&(C=u,h=p)}h>A&&(C-o>1&&i(a,o,C,A,s),s.push(a[C]),f-C>1&&i(a,C,f,A,s))}function c(a,o){var f=a.length-1,A=[a[0]];return i(a,0,f,o,A),A.push(a[f]),A}function l(a,o,f){if(a.length<=2)return a;var A=o!==void 0?o*o:1;return a=f?a:r(a,A),a=c(a,A),a}n.exports=l,n.exports.default=l})()})(Ut)),Ut.exports}cn();function An(n){const{width:t,height:e}=n,r=n.data.slice(),i=new Int32Array(t*e);let c=0,l=0;for(let o=0;o<i.length;o++)r[o*4+3]>=128&&(i[l++]=o);function a(o,f){r[f*4+3]>=128||(r.set(r.subarray(o*4,o*4+3),f*4),r[f*4+3]=255,i[l++]=f)}for(;c<l;){const o=i[c++],f=o%t;f&&a(o,o-1),f+1<t&&a(o,o+1),o>=t&&a(o,o-t),o+t<i.length&&a(o,o+t)}return{width:t,height:e,data:r}}const zt={top:[2,!0],bottom:[2,!1],left:[0,!1],right:[0,!0],front:[1,!0],rear:[1,!1]},fn=[0,1,2];function hn(n,t){const e=n[t],r=n[t+1],i=n[t+2];return n[t+3]<128?0:e>145&&e-i>70&&r-i>20&&e-r>22?1:r>95&&i>105&&Math.min(r,i)-e>46&&i-r>-20?2:0}function ln(n){const t={},e={},r=new Map,i=new Map;for(const[c,l]of Object.entries(n)){let a=function(g,B){!s[B]||h[B]>=0||(h[B]=h[g]+1,u.set(u.subarray(g*4,g*4+3),B*4),C[w++]=B)};const{width:o,height:f,data:A}=l,s=new Uint8Array(o*f),h=new Int32Array(s.length).fill(-1),C=new Int32Array(s.length),u=new Uint8Array(A),p=[0,0,0];for(let g=0;g<s.length;g++){const B=s[g]=hn(A,g*4);B&&p[B]++}const d=s.slice();for(let g=0;g<d.length;g++){const B=d[g];if(!B)continue;const m=g%o,Q=Math.floor(g/o);for(let M=-3;M<=3;M++)for(let U=-3;U<=3;U++){if(U*U+M*M>9||m+U<0||m+U>=o||Q+M<0||Q+M>=f)continue;const I=g+M*o+U,x=I*4;if(s[I]||A[x+3]<128)continue;const E=A[x],b=A[x+1],v=A[x+2];(B===1?E-v>12&&b-v>5&&E>=b-8:Math.min(b,v)-E>12)&&(s[I]=B)}}let w=0;for(let g=0;g<s.length;g++)s[g]||A[g*4+3]<128||(h[g]=0,C[w++]=g);for(let g=0;g<w;g++){const B=C[g],m=B%o;m>0&&a(B,B-1),m+1<o&&a(B,B+1),B>=o&&a(B,B-o),B+o<s.length&&a(B,B+o)}for(const g of[1,2]){const B=p[g]/(o*f)*(c==="front"?1.35:1);B<=(i.get(g)??0)||(i.set(g,B),r.set(g,c))}e[c]=s,t[c]={width:o,height:f,data:u}}return{clean:t,masks:e,owner:r}}function wn(n,t,e){const r={};for(const a of e){const[o,f]=zt[a],A=fn.filter(p=>p!==o),s=t[A[0]],h=t[A[1]],C=new Int16Array(s*h).fill(-1),u=[0,0,0];for(let p=0;p<h;p++)for(let d=0;d<s;d++){u[A[0]]=d,u[A[1]]=p;for(let w=0;w<t[o];w++)if(u[o]=f?t[o]-1-w:w,!!n[(u[2]*t[1]+u[1])*t[0]+u[0]]){C[p*s+d]=u[o]+Number(f);break}}r[a]={axis:o,axes:A,width:s,height:h,values:C}}function i(a,o){return[Math.max(0,Math.min(a.width-1,Math.floor(o[a.axes[0]]))),Math.max(0,Math.min(a.height-1,Math.floor(o[a.axes[1]])))]}function c(a,o){const f=r[a];if(!f)return-1;const[A,s]=i(f,o);return f.values[s*f.width+A]}function l(a,o,f=1.5){const A=c(a,o);return A>=0&&Math.abs(A-o[zt[a][0]])<=f}return{visible:l,firstHit:c}}function gn(n,t,e,r,i,c){const{width:l,height:a,data:o}=n,f=new Uint8Array(t.length),A=new Uint8Array(t.length),s=new Uint8Array(o.length),h=[],C=[],u=[],p=[];for(let w=0;w<t.length;w++){if(t[w]!==1||A[w])continue;const g=[w],B=new Map;let m=l,Q=0,M=a,U=0;A[w]=1;for(const x of g){const E=x%l,b=Math.floor(x/l);m=Math.min(m,E),Q=Math.max(Q,E),M=Math.min(M,b),U=Math.max(U,b);const v=B.get(b)??[E,E];B.set(b,[Math.min(v[0],E),Math.max(v[1],E)]);for(const F of[E>0?x-1:-1,E+1<l?x+1:-1,x-l,x+l])t[F]!==1||A[F]||(A[F]=1,g.push(F))}if(g.length<5||Q-m>l/4||U-M>a/4)continue;const I=new Map;for(const[x,[E,b]]of B){let v=-1;for(let F=E;F<=b;F++){const H=[(F+.5)/l*e[0],0,(1-(x+.5)/a)*e[2]];v=Math.max(v,c("front",H))}v>=0&&I.set(x,v)}if(!(I.size<2)){for(const x of g)I.has(Math.floor(x/l))&&(f[x]=1,s.set(o.subarray(x*4,x*4+4),x*4));for(const[x,E]of I){const[b,v]=B.get(x),F=b/l,H=(v+1)/l,G=x/a,D=(x+1)/a,L=(F-.5)*r[0],Y=(H-.5)*r[0],P=(1-G)*r[2]-i[2],S=(1-D)*r[2]-i[2],T=(.5-(E+.65)/e[1])*r[1],R=h.length/3;h.push(L,P,T,Y,P,T,Y,S,T,L,S,T),C.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1),u.push(R,R+1,R+2,R,R+2,R+3),p.push(F,G,H,G,H,D,F,D)}}}return{mesh:u.length?{target:"mesh",size:r,pivot:i,texture:{width:l,height:a,data:s},positions:Float32Array.from(h),normals:Float32Array.from(C),indices:Uint32Array.from(u),uvs:Float32Array.from(p)}:void 0,marked:f}}const Ot=Int8Array.from(atob("/////////////////////wAIA/////////////////8AAQn/////////////////AQgDCQgB/////////////wECCv////////////////8ACAMBAgr/////////////CQIKAAIJ/////////////wIIAwIKCAoJCP////////8DCwL/////////////////AAsCCAsA/////////////wEJAAIDC/////////////8BCwIBCQsJCAv/////////AwoBCwoD/////////////wAKAQAICggLCv////////8DCQADCwkLCgn/////////CQgKCggL/////////////wQHCP////////////////8EAwAHAwT/////////////AAEJCAQH/////////////wQBCQQHAQcDAf////////8BAgoIBAf/////////////AwQHAwAEAQIK/////////wkCCgkAAggEB/////////8CCgkCCQcCBwMHCQT/////CAQHAwsC/////////////wsEBwsCBAIABP////////8JAAEIBAcCAwv/////////BAcLCQQLCQsCCQIB/////wMKAQMLCgcIBP////////8BCwoBBAsBAAQHCwT/////BAcICQALCQsKCwAD/////wQHCwQLCQkLCv////////8JBQT/////////////////CQUEAAgD/////////////wAFBAEFAP////////////8IBQQIAwUDAQX/////////AQIKCQUE/////////////wMACAECCgQJBf////////8FAgoFBAIEAAL/////////AgoFAwIFAwUEAwQI/////wkFBAIDC/////////////8ACwIACAsECQX/////////AAUEAAEFAgML/////////wIBBQIFCAIICwQIBf////8KAwsKAQMJBQT/////////BAkFAAgBCAoBCAsK/////wUEAAUACwULCgsAA/////8FBAgFCAoKCAv/////////CQcIBQcJ/////////////wkDAAkFAwUHA/////////8ABwgAAQcBBQf/////////AQUDAwUH/////////////wkHCAkFBwoBAv////////8KAQIJBQAFAwAFBwP/////CAACCAIFCAUHCgUC/////wIKBQIFAwMFB/////////8HCQUHCAkDCwL/////////CQUHCQcCCQIAAgcL/////wIDCwABCAEHCAEFB/////8LAgELAQcHAQX/////////CQUICAUHCgEDCgML/////wUHAAUACQcLAAEACgsKAP8LCgALAAMKBQAIAAcFBwD/CwoFBwsF/////////////woGBf////////////////8ACAMFCgb/////////////CQABBQoG/////////////wEIAwEJCAUKBv////////8BBgUCBgH/////////////AQYFAQIGAwAI/////////wkGBQkABgACBv////////8FCQgFCAIFAgYDAgj/////AgMLCgYF/////////////wsACAsCAAoGBf////////8AAQkCAwsFCgb/////////BQoGAQkCCQsCCQgL/////wYDCwYFAwUBA/////////8ACAsACwUABQEFCwb/////AwsGAAMGAAYFAAUJ/////wYFCQYJCwsJCP////////8FCgYEBwj/////////////BAMABAcDBgUK/////////wEJAAUKBggEB/////////8KBgUBCQcBBwMHCQT/////BgECBgUBBAcI/////////wECBQUCBgMABAMEB/////8IBAcJAAUABgUAAgb/////BwMJBwkEAwIJBQkGAgYJ/wMLAgcIBAoGBf////////8FCgYEBwIEAgACBwv/////AAEJBAcIAgMLBQoG/////wkCAQkLAgkECwcLBAUKBv8IBAcDCwUDBQEFCwb/////BQELBQsGAQALBwsEAAQL/wAFCQAGBQADBgsGAwgEB/8GBQkGCQsEBwkHCwn/////CgQJBgQK/////////////wQKBgQJCgAIA/////////8KAAEKBgAGBAD/////////CAMBCAEGCAYEBgEK/////wEECQECBAIGBP////////8DAAgBAgkCBAkCBgT/////AAIEBAIG/////////////wgDAggCBAQCBv////////8KBAkKBgQLAgP/////////AAgCAggLBAkKBAoG/////wMLAgABBgAGBAYBCv////8GBAEGAQoECAECAQsICwH/CQYECQMGCQEDCwYD/////wgLAQgBAAsGAQkBBAYEAf8DCwYDBgAABgT/////////BgQICwYI/////////////wcKBgcICggJCv////////8ABwMACgcACQoGBwr/////CgYHAQoHAQcIAQgA/////woGBwoHAQEHA/////////8BAgYBBggBCAkIBgf/////AgYJAgkBBgcJAAkDBwMJ/wcIAAcABgYAAv////////8HAwIGBwL/////////////AgMLCgYICggJCAYH/////wIABwIHCwAJBwYHCgkKB/8BCAABBwgBCgcGBwoCAwv/CwIBCwEHCgYBBgcB/////wgJBggGBwkBBgsGAwEDBv8ACQELBgf/////////////BwgABwAGAwsACwYA/////wcLBv////////////////8HBgv/////////////////AwAICwcG/////////////wABCQsHBv////////////8IAQkIAwELBwb/////////CgECBgsH/////////////wECCgMACAYLB/////////8CCQACCgkGCwf/////////BgsHAgoDCggDCgkI/////wcCAwYCB/////////////8HAAgHBgAGAgD/////////AgcGAgMHAAEJ/////////wEGAgEIBgEJCAgHBv////8KBwYKAQcBAwf/////////CgcGAQcKAQgHAQAI/////wADBwAHCgAKCQYKB/////8HBgoHCggICgn/////////BggECwgG/////////////wMGCwMABgAEBv////////8IBgsIBAYJAAH/////////CQQGCQYDCQMBCwMG/////wYIBAYLCAIKAf////////8BAgoDAAsABgsABAb/////BAsIBAYLAAIJAgoJ/////woJAwoDAgkEAwsDBgQGA/8IAgMIBAIEBgL/////////AAQCBAYC/////////////wEJAAIDBAIEBgQDCP////8BCQQBBAICBAb/////////CAEDCAYBCAQGBgoB/////woBAAoABgYABP////////8EBgMEAwgGCgMAAwkKCQP/CgkEBgoE/////////////wQJBQcGC/////////////8ACAMECQULBwb/////////BQABBQQABwYL/////////wsHBggDBAMFBAMBBf////8JBQQKAQIHBgv/////////BgsHAQIKAAgDBAkF/////wcGCwUECgQCCgQAAv////8DBAgDBQQDAgUKBQILBwb/BwIDBwYCBQQJ/////////wkFBAAIBgAGAgYIB/////8DBgIDBwYBBQAFBAD/////BgIIBggHAgEIBAgFAQUI/wkFBAoBBgEHBgEDB/////8BBgoBBwYBAAcIBwAJBQT/BAAKBAoFAAMKBgoHAwcK/wcGCgcKCAUECgQICv////8GCQUGCwkLCAn/////////AwYLAAYDAAUGAAkF/////wALCAAFCwABBQUGC/////8GCwMGAwUFAwH/////////AQIKCQULCQsICwUG/////wALAwAGCwAJBgUGCQECCv8LCAULBQYIAAUKBQIAAgX/BgsDBgMFAgoDCgUD/////wUICQUCCAUGAgMIAv////8JBQYJBgAABgL/////////AQUIAQgABQYIAwgCBgII/wEFBgIBBv////////////8BAwYBBgoDCAYFBgkICQb/CgEACgAGCQUABQYA/////wADCAUGCv////////////8KBQb/////////////////CwUKBwUL/////////////wsFCgsHBQgDAP////////8FCwcFCgsBCQD/////////CgcFCgsHCQgBCAMB/////wsBAgsHAQcFAf////////8ACAMBAgcBBwUHAgv/////CQcFCQIHCQACAgsH/////wcFAgcCCwUJAgMCCAkIAv8CBQoCAwUDBwX/////////CAIACAUCCAcFCgIF/////wkAAQUKAwUDBwMKAv////8JCAIJAgEIBwIKAgUHBQL/AQMFAwcF/////////////wAIBwAHAQEHBf////////8JAAMJAwUFAwf/////////CQgHBQkH/////////////wUIBAUKCAoLCP////////8FAAQFCwAFCgsLAwD/////AAEJCAQKCAoLCgQF/////woLBAoEBQsDBAkEAQMBBP8CBQECCAUCCwgEBQj/////AAQLAAsDBAULAgsBBQEL/wACBQAFCQILBQQFCAsIBf8JBAUCCwP/////////////AgUKAwUCAwQFAwgE/////wUKAgUCBAQCAP////////8DCgIDBQoDCAUEBQgAAQn/BQoCBQIEAQkCCQQC/////wgEBQgFAwMFAf////////8ABAUBAAX/////////////CAQFCAUDCQAFAAMF/////wkEBf////////////////8ECwcECQsJCgv/////////AAgDBAkHCQsHCQoL/////wEKCwELBAEEAAcEC/////8DAQQDBAgBCgQHBAsKCwT/BAsHCQsECQILCQEC/////wkHBAkLBwkBCwILAQAIA/8LBwQLBAICBAD/////////CwcECwQCCAMEAwIE/////wIJCgIHCQIDBwcECf////8JCgcJBwQKAgcIBwACAAf/AwcKAwoCBwQKAQoABAAK/wEKAggHBP////////////8ECQEEAQcHAQP/////////BAkBBAEHAAgBCAcB/////wQAAwcEA/////////////8ECAf/////////////////CQoICgsI/////////////wMACQMJCwsJCv////////8AAQoACggICgv/////////AwEKCwMK/////////////wECCwELCQkLCP////////8DAAkDCQsBAgkCCwn/////AAILCAAL/////////////wMCC/////////////////8CAwgCCAoKCAn/////////CQoCAAkC/////////////wIDCAIICgABCAEKCP////8BCgL/////////////////AQMICQEI/////////////wAJAf////////////////8AAwj//////////////////////////////////////w=="),n=>n.charCodeAt(0)),jt=[[0,0,0],[1,0,0],[1,1,0],[0,1,0],[0,0,1],[1,0,1],[1,1,1],[0,1,1]],un=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]];function dn(n,t,e){const r=Math.min(e[2]*(t[2]-2)*.042,Math.max(e[0],e[1])*1.65),i=[1,t[0],t[0]*t[1]];let c=Float32Array.from(n),l=new Float32Array(c.length);for(let a=0;a<t.length;a++){const o=Math.max(.6,Math.min(5,r/e[a])),f=Math.ceil(o*2.5),A=Array.from({length:f+1},(p,d)=>Math.exp(-d*d/(2*o*o))),s=A[0]+2*A.slice(1).reduce((p,d)=>p+d,0),h=i[a],C=t[a],u=h*C;for(let p=0;p<c.length;p+=u)for(let d=0;d<h;d++)for(let w=0;w<C;w++){const g=p+d+w*h;let B=A[0]*c[g];for(let m=1;m<=f;m++)w>=m&&(B+=A[m]*c[g-m*h]),w+m<C&&(B+=A[m]*c[g+m*h]);l[g]=B/s}[c,l]=[l,c]}return c}function Ft(n,t,e,r,i){const c=t+2,l=e+2,a=r+2,o=c*l,f=o*a,A=new Uint8Array(f);for(let B=0;B<r;B++)for(let m=0;m<e;m++){const Q=(B*e+m)*t;A.set(n.subarray(Q,Q+t),(B+1)*o+(m+1)*c+1)}const s=i?dn(A,[c,l,a],[i[0]/t,i[1]/e,i[2]/r]):new Float32Array(f);for(let B=0;B<a;B++)for(let m=0;m<l;m++)for(let Q=0;Q<c;Q++){const M=B*o+m*c+Q,U=(Q>0?A[M-1]:0)+(Q+1<c?A[M+1]:0)+(m>0?A[M-c]:0)+(m+1<l?A[M+c]:0)+(B>0?A[M-o]:0)+(B+1<a?A[M+o]:0),I=A[M]*.64+U*.06;s[M]=i?s[M]*.92+I*.08:I}const h=[0,1,c+1,c,o,o+1,o+c+1,o+c],C=new Int32Array(f*3).fill(-1),u=[],p=[],d=[];function w(B,m){return(s[B-m]??0)-(s[B+m]??0)}function g(B,m,Q,M,U){const[I,x]=un[U],E=jt[I],b=jt[x],v=M+h[I],F=M+h[x],H=E[0]!==b[0]?0:E[1]!==b[1]?1:2,G=Math.min(v,F)*3+H;if(C[G]>=0)return C[G];const D=u.length/3,L=(.5-s[v])/(s[F]-s[v]);return u.push(B-.5+E[0]+(b[0]-E[0])*L,m-.5+E[1]+(b[1]-E[1])*L,Q-.5+E[2]+(b[2]-E[2])*L),p.push(...[1,c,o].map(Y=>w(v,Y)*(1-L)+w(F,Y)*L)),C[G]=D,D}for(let B=0;B<a-1;B++)for(let m=0;m<l-1;m++)for(let Q=0;Q<c-1;Q++){const M=B*o+m*c+Q;let U=0;for(let I=0;I<8;I++)s[M+h[I]]<.5&&(U|=1<<I);if(!(U===0||U===255))for(let I=U*16;Ot[I]>=0;I++)d.push(g(Q,m,B,M,Ot[I]))}return{positions:u,gradients:p,indices:d}}function Cn(n,t,e,r){const i=[t,e,r],c=[1,t,t*e],l=[],a=[],o=[],f=[[0,0],[1,0],[1,1],[0,1]];for(let A=0;A<r;A++)for(let s=0;s<e;s++)for(let h=0;h<t;h++){const C=(A*e+s)*t+h;if(!n[C])continue;const u=[h,s,A];for(let p=0;p<3;p++){const d=(p+1)%3,w=(p+2)%3;for(const g of[-1,1]){const B=u[p]+g;if(B>=0&&B<i[p]&&n[C+g*c[p]])continue;const m=[0,0,0];m[p]=g;const Q=l.length/3;for(const[E,b]of f){const v=[...u];v[p]+=+(g>0),v[d]+=E,v[w]+=b,l.push(...v),a.push(...m)}const M=Q,U=Q+1,I=Q+2,x=Q+3;g>0?o.push(M,U,I,M,I,x):o.push(M,I,U,M,x,I)}}}return{positions:l,gradients:a,indices:o}}const wt=(n,t,e)=>Math.min(e,Math.max(t,n));function mt(n,t,e,r){switch(n){case"top":return[t,e];case"bottom":return[t,1-e];case"left":return[1-e,1-r];case"right":return[e,1-r];case"front":return[t,1-r];case"rear":return[1-t,1-r]}}function Qt(n,t,e){return(wt(Math.floor(e*n.height),0,n.height-1)*n.width+wt(Math.floor(t*n.width),0,n.width-1))*4}function Rt(n,t,e){if(n.width===t&&n.height===e)return n;const r=new Uint8Array(t*e*4);for(let i=0;i<e;i++)for(let c=0;c<t;c++){const l=Qt(n,(c+.5)/t,(i+.5)/e),a=(i*t+c)*4;for(let o=0;o<4;o++)r[a+o]=n.data[l+o]}return{width:t,height:e,data:r}}function Mt(n,t,e,r){const i=[Math.max(0,r),Math.max(0,-t),Math.max(0,e),Math.max(0,-e),Math.max(0,t),Math.max(0,-r)];return n.right||(i[1]=Math.abs(t)),n.bottom||(i[0]=Math.abs(r)),[...At].filter(c=>n[c]).sort((c,l)=>i[At.indexOf(l)]-i[At.indexOf(c)])}function Bn(n,t){const e=n.top,r=n.front,i=n.left,c=t.layers??48,l=t.resolution??96,a=t.height??1;if(!Number.isInteger(c)||c<8||c>128)throw new Error("Layers must be an integer from 8 to 128.");if(!Number.isInteger(l)||l<16||l>192)throw new Error("Resolution must be an integer from 16 to 192.");if(!Number.isFinite(a)||a<=0)throw new Error("Height must be positive.");if(t.pivot&&t.pivot!=="center"&&t.pivot!=="ground")throw new Error("Pivot must be ground or center.");const o=i.width/i.height*a,[f,A,s]=t.size??[(r.width/r.height*a+o*e.width/e.height)/2,o,a];if(![f,A,s].every(d=>Number.isFinite(d)&&d>0))throw new Error("Part dimensions must be positive.");const h=Math.max(2,Math.round(f/Math.max(f,A)*l)),C=Math.max(2,Math.round(A/Math.max(f,A)*l)),u=[f,A,s],p=[0,0,t.pivot==="center"?s/2:0];return{width:h,depth:C,layers:c,size:u,pivot:p}}function Vt(n,t,e){const{width:r,depth:i,layers:c,size:l,pivot:a}=Bn(n,t);if(r*i*c>3e6)throw new Error("The grid is too large. Reduce layers or XY resolution.");const o={};for(const u of At){const p=n[u];if(!p)continue;const d=u!=="top"&&u!=="bottom";o[u]=Rt(p,u==="left"||u==="right"?i:r,d?c:i)}const f=Object.entries(o),A=(u,p,d,w,g)=>p.data[Qt(p,...mt(u,d,w,g))+3]>=128,s=new Uint8Array(r*i*c);let h=0;const C=t.profile==="round"||t.profile==="round-base";for(let u=0;u<c;u++)for(let p=0;p<i;p++)for(let d=0;d<r;d++){const w=(d+.5)/r,g=(p+.5)/i,B=(u+.5)/c;(n.right?f.every(([Q,M])=>A(Q,M,w,g,B)):A("top",o.top,w,g,B)&&A("left",o.left,w,g,B)&&(A("front",o.front,w,g,B)||A("rear",o.rear,w,g,B)))&&(s[(u*i+p)*r+d]=1,h++)}if(C){const u=r*i;for(let p=0;p<c;p++){if(t.profile==="round-base"&&(p+.5)/c<.03)continue;let d=r,w=-1,g=i,B=-1;const m=p*u;for(let Q=0;Q<i;Q++)for(let M=0;M<r;M++)s[m+Q*r+M]&&(d=Math.min(d,M),w=Math.max(w,M),g=Math.min(g,Q),B=Math.max(B,Q));if(!(w<d))for(let Q=g;Q<=B;Q++)for(let M=d;M<=w;M++){if(((2*M-d-w)/(w-d+1))**2+((2*Q-g-B)/(B-g+1))**2<=1)continue;const U=m+Q*r+M;h-=s[U],s[U]=0}}}if(!h){if(e)return e;throw new Error("The aligned views have no common volume.")}return{width:r,depth:i,layers:c,size:l,pivot:a,volume:s,aligned:o}}function pn(n,t={},e=!1){const r=new Map,i=new Map(r);let c=0,l=0;for(const[o,f]of[[n,r],[t,i]])for(const A of At){const s=o[A];if(!s)continue;const h=Math.min(1,512/Math.max(s.width,s.height)),C=Rt(s,Math.max(1,Math.round(s.width*h)),Math.max(1,Math.round(s.height*h)));f.set(A,{image:e?An(C):C,left:c+1}),c+=C.width+2,l=Math.max(l,C.height+2)}const a=new Uint8Array(c*l*4).fill(255);for(const{image:o,left:f}of[...r.values(),...i.values()])for(let A=-1;A<=o.height;A++)for(let s=-1;s<=o.width;s++){const h=(wt(A,0,o.height-1)*o.width+wt(s,0,o.width-1))*4,C=((A+1)*c+f+s)*4;for(let u=0;u<3;u++)a[C+u]=o.data[h+3]>=128?o.data[h+u]:137}return{tiles:r,accents:i,texture:{width:c,height:l,data:a}}}function Xt(n,t,e="rgb"){const{width:r,depth:i,layers:c,size:l,pivot:a,volume:o}=n,f=Ft(o,r,i,c,e==="depth"?l:void 0);if(!f.indices.length&&e==="depth")return Xt(n,t,"id");const A=new Int16Array(r*i).fill(-1),s=new Int16Array(r*i).fill(c),h=r*i;for(let E=0;E<c;E++)for(let b=0;b<h;b++)o[E*h+b]&&(A[b]=E,s[b]=Math.min(s[b],E));function C(E,b,v,F){const H=wt(Math.floor(b*r),0,r-1),G=wt(Math.floor(v*i),0,i-1),D=E[G*r+H];if(Math.abs(D+.5-F*c)>2)return!1;let L=0;for(const[Y,P]of[[2,0],[-2,0],[0,2],[0,-2]]){const S=H+Y,T=G+P;if(!(S<0||S>=r||T<0||T>=i)){if(Math.abs(E[T*r+S]-D)>(t.bottom?2:1))return!1;L++}}return L>=(t.bottom?2:3)}const u=e==="rgb"?void 0:ln(t),p={};for(const E of u?.owner.values()??[])p[E]=t[E];const d=u?wn(o,[r,i,c],At):void 0,w=u?.owner.get(1)==="front"&&d&&t.front&&u.masks.front?gn(t.front,u.masks.front,[r,i,c],l,a,d.firstHit):void 0,{texture:g,tiles:B,accents:m}=pn(u?.clean??t,p),Q=[],M=[],U=[],I=[],x=new Map;for(let E=0;E<f.indices.length;E+=3){const b=f.indices.slice(E,E+3),v=[0,1,2].map(O=>b.reduce((z,V)=>z+f.gradients[V*3+O],0)),F=[0,1,2].map(O=>b.reduce((z,V)=>z+f.positions[V*3+O],0)),H=[F[0]/(3*r),F[1]/(3*i),F[2]/(3*c)];let G=Mt(t,v[0],v[1],v[2]);const D=v[2]<0&&t.bottom?"bottom":"top",L=v[2]<0?s:A,Y=e==="depth"&&d&&Math.abs(v[2])*c/l[2]>1.55*Math.max(Math.abs(v[0])*r/l[0],Math.abs(v[1])*i/l[1])&&d.visible(D,F.map(O=>O/3),3);if(!Y&&!C(L,H[0],H[1],H[2])){const O=v[0],z=v[1];G=Math.hypot(O,z)>.1?Mt(t,O,z,0):Mt(t,H[0]-.5,H[1]-.5,0),G=[...G.filter(V=>V!=="top"&&V!=="bottom"),D]}const P=O=>{const z=t[O];return z.data[Qt(z,...mt(O,...H))+3]>=128};let S=Y&&P(D)?D:G.find(P)??G[0],T=!1;if(u&&d){const O=F.map(y=>y/3),z=e==="depth"?3:1.5,V=Mt(t,v[0],v[1],v[2]),W=[Math.max(0,v[2]),Math.max(0,-v[0]),Math.max(0,v[1]),Math.max(0,-v[1]),Math.max(0,v[0]),Math.max(0,-v[2])],ht=Math.max(...W);for(const y of V){if(!p[y]||W[At.indexOf(y)]<=ht*.45||!d.visible(y,O,z))continue;const k=p[y],K=Qt(k,...mt(y,...H))/4,j=u.masks[y][K];if(!(u.owner.get(j)!==y||y==="front"&&w?.marked[K])){S=y,T=!0;break}}}const{image:R,left:it}=(T?m:B).get(S);for(const O of b){const z=O*12+At.indexOf(S)+(T?6:0);let V=x.get(z);if(V===void 0){V=Q.length/3,x.set(z,V);const W=O*3,ht=f.positions[W]/r,y=f.positions[W+1]/i,k=f.positions[W+2]/c;Q.push((ht-.5)*l[0],k*l[2]-a[2],(.5-y)*l[1]);const K=f.gradients[W]*r/l[0],j=f.gradients[W+1]*i/l[1],J=f.gradients[W+2]*c/l[2],q=Math.hypot(K,j,J)||1;M.push(K/q,J/q,-j/q);const[$,_]=mt(S,ht,y,k);I.push((it+.5+wt($,0,1)*(R.width-1))/g.width,(1.5+wt(_,0,1)*(R.height-1))/g.height)}U.push(V)}}return{target:"mesh",size:l,pivot:a,texture:g,positions:Float32Array.from(Q),normals:Float32Array.from(M),indices:Uint32Array.from(U),uvs:Float32Array.from(I),...w?.mesh&&{frontAccents:w.mesh}}}function mn(n,t){const{width:e,depth:r,layers:i,size:c,pivot:l,volume:a}=n,o=Math.min(i,Math.max(1,Math.floor(4096/e))),f=e*o,A=r*Math.ceil(i/o),s=new Uint8Array(f*A*4),h=(d,w,g)=>+(d>=0&&d<e&&w>=0&&w<r&&g>=0&&g<i&&a[(g*r+w)*e+d]>0),C=new Int16Array(e*r).fill(-1);for(let d=0;d<i;d++)for(let w=0;w<C.length;w++)a[d*C.length+w]&&(C[w]=d);const u=Array.from({length:27},(d,w)=>Mt(t,w%3-1,Math.floor(w/3)%3-1,Math.floor(w/9)-1)),p=(d,w,g)=>d<0||d>=e||w<0||w>=r||Math.abs(C[w*e+d]-g)<=1;for(let d=0;d<i;d++)for(let w=0;w<r;w++)for(let g=0;g<e;g++){if(!h(g,w,d))continue;const B=h(g-1,w,d)-h(g+1,w,d),m=h(g,w-1,d)-h(g,w+1,d),Q=h(g,w,d-1)-h(g,w,d+1),M=B+1+(m+1)*3+(Q+1)*9,U=((Math.floor(d/o)*r+w)*f+d%o*e+g)*4,I=C[w*e+g],x=d===I&&p(g-2,w,d)&&p(g+2,w,d)&&p(g,w-2,d)&&p(g,w+2,d),E=u[M],b=x||Q<0&&t.bottom?E:u[M-Q*9];let v=0,F=0,H=0,G=0;for(const D of b){if(!x&&D==="top")continue;const L=t[D],Y=Qt(L,...mt(D,(g+.5)/e,(w+.5)/r,(d+.5)/i));if(L.data[Y+3]<128)continue;const P=L.data[Y],S=L.data[Y+1],T=L.data[Y+2];if(v&&Math.max(Math.abs(P-F/v),Math.abs(S-H/v),Math.abs(T-G/v))>66)continue;const R=D==="front"||D==="rear"?.1+Math.abs(m):D==="left"||D==="right"?.1+Math.abs(B):.1+Math.abs(Q);F+=P*R,H+=S*R,G+=T*R,v+=R}v&&(s[U]=Math.round(F/v),s[U+1]=Math.round(H/v),s[U+2]=Math.round(G/v),s[U+3]=255)}return{target:"stack",size:c,pivot:l,width:e,depth:r,layers:i,columns:o,spacing:c[2]/i,texture:{width:f,height:A,data:s}}}function Qn(n,t){return["rgb","id","depth"].map(e=>Xt(t,n,e))}function qt(n,t){const{size:e,pivot:r,width:i,depth:c,layers:l}=n,a=new Float32Array(t.positions.length),o=new Float32Array(a.length);for(let f=0;f<a.length;f+=3){a[f]=(t.positions[f]/i-.5)*e[0],a[f+1]=t.positions[f+2]/l*e[2]-r[2],a[f+2]=(.5-t.positions[f+1]/c)*e[1];const A=t.gradients[f]*i/e[0],s=t.gradients[f+2]*l/e[2],h=-t.gradients[f+1]*c/e[1],C=Math.hypot(A,s,h)||1;o.set([A/C,s/C,h/C],f)}return{target:"mesh",size:e,pivot:r,positions:a,normals:o,indices:Uint32Array.from(t.indices),uvs:new Float32Array(a.length/3*2),texture:{width:1,height:1,data:Uint8Array.of(255,255,255,255)}}}function Mn(n,t={}){const e=Nt(n,t.threshold),r=Vt(e,t),i=Vt(e,{...t,size:r.size,resolution:Math.max(16,Math.min(48,Math.floor((t.resolution??96)/2))),layers:Math.max(8,Math.min(32,Math.floor(r.layers/2)))},r),{volume:c,width:l,depth:a,layers:o}=i,f=qt(i,Cn(c,l,a,o)),A=qt(i,Ft(c,l,a,o)),s=h=>[h.width,h.depth,h.layers];return{voxel:f,marching:A,meshes:Qn(e,r),stack:mn(r,r.aligned),coarseGrid:s(i),fullGrid:s(r)}}var ot=Uint8Array,Bt=Uint16Array,vn=Int32Array,_t=new ot([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),$t=new ot([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),yn=new ot([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Wt=function(n,t){for(var e=new Bt(31),r=0;r<31;++r)e[r]=t+=1<<n[r-1];for(var i=new vn(e[30]),r=1;r<30;++r)for(var c=e[r];c<e[r+1];++c)i[c]=c-e[r]<<5|r;return{b:e,r:i}},Zt=Wt(_t,2),tn=Zt.b,xn=Zt.r;tn[28]=258,xn[258]=28;for(var En=Wt($t,0),In=En.b,kt=new Bt(32768),N=0;N<32768;++N){var gt=(N&43690)>>1|(N&21845)<<1;gt=(gt&52428)>>2|(gt&13107)<<2,gt=(gt&61680)>>4|(gt&3855)<<4,kt[N]=((gt&65280)>>8|(gt&255)<<8)>>1}for(var vt=(function(n,t,e){for(var r=n.length,i=0,c=new Bt(t);i<r;++i)n[i]&&++c[n[i]-1];var l=new Bt(t);for(i=1;i<t;++i)l[i]=l[i-1]+c[i-1]<<1;var a;if(e){a=new Bt(1<<t);var o=15-t;for(i=0;i<r;++i)if(n[i])for(var f=i<<4|n[i],A=t-n[i],s=l[n[i]-1]++<<A,h=s|(1<<A)-1;s<=h;++s)a[kt[s]>>o]=f}else for(a=new Bt(r),i=0;i<r;++i)n[i]&&(a[i]=kt[l[n[i]-1]++]>>15-n[i]);return a}),yt=new ot(288),N=0;N<144;++N)yt[N]=8;for(var N=144;N<256;++N)yt[N]=9;for(var N=256;N<280;++N)yt[N]=7;for(var N=280;N<288;++N)yt[N]=8;for(var nn=new ot(32),N=0;N<32;++N)nn[N]=5;var bn=vt(yt,9,1),Un=vt(nn,5,1),Dt=function(n){for(var t=n[0],e=1;e<n.length;++e)n[e]>t&&(t=n[e]);return t},st=function(n,t,e){var r=t/8|0;return(n[r]|n[r+1]<<8)>>(t&7)&e},Lt=function(n,t){var e=t/8|0;return(n[e]|n[e+1]<<8|n[e+2]<<16)>>(t&7)},Fn=function(n){return(n+7)/8|0},kn=function(n,t,e){return(e==null||e>n.length)&&(e=n.length),new ot(n.subarray(t,e))},Dn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],at=function(n,t,e){var r=new Error(t||Dn[n]);if(r.code=n,Error.captureStackTrace&&Error.captureStackTrace(r,at),!e)throw r;return r},Ln=function(n,t,e,r){var i=n.length,c=r?r.length:0;if(!i||t.f&&!t.l)return e||new ot(0);var l=!e,a=l||t.i!=2,o=t.i;l&&(e=new ot(i*3));var f=function(K){var j=e.length;if(K>j){var J=new ot(Math.max(j*2,K));J.set(e),e=J}},A=t.f||0,s=t.p||0,h=t.b||0,C=t.l,u=t.d,p=t.m,d=t.n,w=i*8;do{if(!C){A=st(n,s,1);var g=st(n,s+1,3);if(s+=3,g)if(g==1)C=bn,u=Un,p=9,d=5;else if(g==2){var M=st(n,s,31)+257,U=st(n,s+10,15)+4,I=M+st(n,s+5,31)+1;s+=14;for(var x=new ot(I),E=new ot(19),b=0;b<U;++b)E[yn[b]]=st(n,s+b*3,7);s+=U*3;for(var v=Dt(E),F=(1<<v)-1,H=vt(E,v,1),b=0;b<I;){var G=H[st(n,s,F)];s+=G&15;var B=G>>4;if(B<16)x[b++]=B;else{var D=0,L=0;for(B==16?(L=3+st(n,s,3),s+=2,D=x[b-1]):B==17?(L=3+st(n,s,7),s+=3):B==18&&(L=11+st(n,s,127),s+=7);L--;)x[b++]=D}}var Y=x.subarray(0,M),P=x.subarray(M);p=Dt(Y),d=Dt(P),C=vt(Y,p,1),u=vt(P,d,1)}else at(1);else{var B=Fn(s)+4,m=n[B-4]|n[B-3]<<8,Q=B+m;if(Q>i){o&&at(0);break}a&&f(h+m),e.set(n.subarray(B,Q),h),t.b=h+=m,t.p=s=Q*8,t.f=A;continue}if(s>w){o&&at(0);break}}a&&f(h+131072);for(var S=(1<<p)-1,T=(1<<d)-1,R=s;;R=s){var D=C[Lt(n,s)&S],it=D>>4;if(s+=D&15,s>w){o&&at(0);break}if(D||at(2),it<256)e[h++]=it;else if(it==256){R=s,C=null;break}else{var O=it-254;if(it>264){var b=it-257,z=_t[b];O=st(n,s,(1<<z)-1)+tn[b],s+=z}var V=u[Lt(n,s)&T],W=V>>4;V||at(3),s+=V&15;var P=In[W];if(W>3){var z=$t[W];P+=Lt(n,s)&(1<<z)-1,s+=z}if(s>w){o&&at(0);break}a&&f(h+131072);var ht=h+O;if(h<P){var y=c-P,k=Math.min(P,ht);for(y+h<0&&at(3);h<k;++h)e[h]=r[y+h]}for(;h<ht;++h)e[h]=e[h-P]}}t.l=C,t.p=R,t.b=h,t.f=A,C&&(A=1,t.m=p,t.d=u,t.n=d)}while(!A);return h!=e.length&&l?kn(e,0,h):e.subarray(0,h)},Hn=new ot(0),Gn=function(n,t){return((n[0]&15)!=8||n[0]>>4>7||(n[0]<<8|n[1])%31)&&at(6,"invalid zlib data"),(n[1]>>5&1)==+!t&&at(6,"invalid zlib data: "+(n[1]&32?"need":"unexpected")+" dictionary"),(n[1]>>3&4)+2};function Kn(n,t){return Ln(n.subarray(Gn(n,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var Jn=typeof TextDecoder<"u"&&new TextDecoder,Yn=0;try{Jn.decode(Hn,{stream:!0}),Yn=1}catch{}new TextEncoder,Uint32Array.from({length:256},(n,t)=>{let e=t;for(let r=0;r<8;r++)e=e>>>1^(e&1?3988292384:0);return e});function Pn(n){return`function update({ dt, keys, fields, state, rotation }) {
|
|
2
|
+
const tracks = ${JSON.stringify(n)};
|
|
3
|
+
const held = (...codes) => codes.some(code => keys.includes(code));
|
|
4
|
+
const throttle = Number(held('KeyW', 'ArrowUp')) - Number(held('KeyS', 'ArrowDown'));
|
|
5
|
+
const direction = Number(held('KeyA', 'ArrowLeft')) - Number(held('KeyD', 'ArrowRight'));
|
|
6
|
+
const target = throttle * (throttle < 0 ? fields.reverseSpeed : fields.forwardSpeed);
|
|
7
|
+
const oldSpeed = state.speed ?? 0;
|
|
8
|
+
const speed = oldSpeed + (target - oldSpeed) * (1 - Math.exp(-fields.response * dt));
|
|
9
|
+
const distance = (oldSpeed + speed) * .5 * dt;
|
|
10
|
+
const turn = direction * fields.turnRate * dt;
|
|
11
|
+
const radians = Math.PI / 180;
|
|
12
|
+
const previous = state.yaw ?? 0;
|
|
13
|
+
const heading = (rotation[1] + previous + turn * .5) * radians;
|
|
14
|
+
const yaw = (previous + turn) % 360;
|
|
15
|
+
const x = (state.x ?? 0) - Math.sin(heading) * distance;
|
|
16
|
+
const z = (state.z ?? 0) - Math.cos(heading) * distance;
|
|
17
|
+
const travel = tracks.map((track, i) => (state.travel?.[i] ?? 0) + distance + turn * radians * track[1]);
|
|
18
|
+
return { translation: [x, 0, z], rotation: [0, yaw, 0],
|
|
19
|
+
childTrackTravel: Object.fromEntries(tracks.map((track, i) => [track[0], travel[i]])),
|
|
20
|
+
state: { speed, yaw, x, z, travel } };
|
|
21
|
+
}`}Pn([]);const Sn=(n,t,e="number")=>({type:e,minimum:n,maximum:t}),Ct=(...n)=>({...Sn(...n),type:"array"});Ct(-1e4,1e4),Ct(-360,360),Ct(.01,100),Ct(-100,100),Ct(-720,720),Ct(-100,100),Ct(-360,360);function Nn(n){const{width:t,height:e}=Gt(n);if(n[24]!==16||n[25]!==0||n[26]||n[27]||n[28])throw new Error("Depth maps must be non-interlaced 16-bit grayscale PNGs.");const r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=[];let c=0;for(let u=8;u+12<=n.length;){const p=r.getUint32(u),d=r.getUint32(u+4),w=u+12+p;if(w>n.length)throw new Error("Truncated depth PNG.");if(d===1229209940&&(i.push(n.subarray(u+8,u+8+p)),c+=p),d===1229278788)break;u=w}if(!c)throw new Error("Depth PNG is missing image data.");const l=new Uint8Array(c);let a=0;for(const u of i)l.set(u,a),a+=u.length;const o=t*2,f=(o+1)*e,A=Kn(l,{out:new Uint8Array(f+1)});if(A.length!==f)throw new Error("Invalid depth PNG scanline length.");const s=new Uint16Array(t*e);let h=new Uint8Array(o),C=new Uint8Array(o);for(let u=0;u<e;u++){const p=u*(o+1),d=A[p];if(d>4)throw new Error("Invalid depth PNG filter.");for(let w=0;w<o;w++){const g=w>=2?h[w-2]:0,B=C[w],m=w>=2?C[w-2]:0;let Q=0;switch(d){case 1:Q=g;break;case 2:Q=B;break;case 3:Q=g+B>>1;break;case 4:{const M=g+B-m,U=Math.abs(M-g),I=Math.abs(M-B),x=Math.abs(M-m);Q=U<=I&&U<=x?g:I<=x?B:m;break}}h[w]=A[p+1+w]+Q}for(let w=0;w<t;w++)s[u*t+w]=h[w*2]*256+h[w*2+1];[h,C]=[C,h]}return{width:t,height:e,data:s}}function en(n,t,e){return t+(e-t)*(65535-n)/65534}function rn(n,t,e){const[r,i,c,l]=t.rect,a=new Float32Array(n.positions.length),o=n.positions,f=(C,u)=>o[C]*u[0]+o[C+1]*u[1]+o[C+2]*u[2],A=t.origin.reduce((C,u,p)=>C+u*t.forward[p],0);for(let C=0;C<o.length;C+=3)a[C]=t.anchor[0]-r+f(C,t.right)*e,a[C+1]=t.anchor[1]-i-f(C,t.up)*e,a[C+2]=f(C,t.forward)-A;const s=new Float32Array(c*l).fill(1/0),h=n.indices;for(let C=0;C<h.length;C+=3){const u=h[C]*3,p=h[C+1]*3,d=h[C+2]*3,w=a[u],g=a[u+1],B=a[p],m=a[p+1],Q=a[d],M=a[d+1],U=(B-w)*(M-g)-(m-g)*(Q-w);if(Math.abs(U)<1e-8)continue;const I=Math.max(0,Math.ceil(Math.min(w,B,Q)-.5)),x=Math.min(c-1,Math.floor(Math.max(w,B,Q)-.5)),E=Math.max(0,Math.ceil(Math.min(g,m,M)-.5)),b=Math.min(l-1,Math.floor(Math.max(g,m,M)-.5));for(let v=E;v<=b;v++)for(let F=I;F<=x;F++){const H=F+.5,G=v+.5,D=((B-H)*(M-G)-(m-G)*(Q-H))/U,L=((Q-H)*(g-G)-(M-G)*(w-H))/U,Y=1-D-L;if(Math.min(D,L,Y)<-1e-6)continue;const P=D*a[u+2]+L*a[p+2]+Y*a[d+2],S=v*c+F;P>=t.near&&P<=t.far&&P<s[S]&&(s[S]=P)}}return s}function Tn(n,t,e,r){let i=0,c=0,l=0,a=0;const o=Object.entries(r.views).map(([f,A])=>{const s=rn(n,A,r.pixelsPerUnit),h=rn(t,A,r.pixelsPerUnit),[C,u,p,d]=A.rect;let w=0,g=0,B=0,m=0;for(let Q=0;Q<d;Q++)for(let M=0;M<p;M++){const U=e.data[(Q+u)*e.width+M+C];if(!U)continue;w++;const I=Q*p+M;if(!Number.isFinite(s[I])||!Number.isFinite(h[I]))continue;const x=en(U,A.near,A.far);B+=Math.abs(s[I]-x),m+=Math.abs(h[I]-x),g++}return l+=B,a+=m,i+=w,c+=g,{view:f,sharedPixels:g,referencePixels:w,baselineMae:g?B/g:null,carvedMae:g?m/g:null}});return{referencePixels:i,sharedPixels:c,byView:o,baselineMae:c?l/c:null,carvedMae:c?a/c:null}}const zn=["top","left","front","rear"],ut=(n,t,e,r)=>n*r[0]+t*r[1]+e*r[2],Ht=n=>Math.max(0,Math.min(255,Math.round(127.5*(1+n))));function On({calibration:n,depth:t,clay:e,baseColor:r,normal:i},c={}){const{size:l,pixelsPerUnit:a,views:o}=n,[f,A]=n.dimensions;if(![t,e,r,i].every(y=>y.width===f&&y.height===A)||!l.every(y=>Number.isFinite(y)&&y>0)||!Number.isFinite(a)||a<=0)throw new Error("Material passes must match the calibrated atlas dimensions.");const[s,h,C]=l,u=c.resolution??144,p=c.layers??80;if(!Number.isInteger(u)||u<16||u>192||!Number.isInteger(p)||p<8||p>128)throw new Error("Invalid resolution or layer count for registered depth.");const d=Math.max(2,Math.round(s/Math.max(s,h)*u)),w=Math.max(2,Math.round(h/Math.max(s,h)*u));if(d*w*p>3e6)throw new Error("The calibrated grid is too large. Reduce layers or resolution.");const g=Math.max(s/d,h/w,C/p)*.75+1/a,B=[0,0,c.pivot==="center"?C/2:0],m=zn.map(y=>o[y]),Q=m.map(y=>ut(...y.origin,y.forward)),M=m.length,U=[...m,o.left],I=f+o.left.rect[2]+1,x=new Uint8Array(I*A*4),E=new Uint8Array(x.length);for(let y=0;y<x.length;y+=4)x.set([146,149,154,255],y);function b(y,k,K,j){const J=y.anchor[0]+ut(k,K,j,y.right)*a,q=y.anchor[1]-ut(k,K,j,y.up)*a,[$,_,X,nt]=y.rect;return J<$||J>=$+X||q<_||q>=_+nt?-1:Math.floor(q)*f+Math.floor(J)}function v(y,k){return en(t.data[k],y.near,y.far)}function F(y,k){const[K,j,J,q]=y.rect;for(let $=j;$<j+q;$++)for(let _=K;_<K+J;_++){const X=($*f+_)*4;if(r.data[X+3]<128)continue;const nt=($*I+(k?f+_-K:_))*4;if(x.set(r.data.subarray(X,X+4),nt),i.data[X+3]<128)continue;const lt=i.data[X]/127.5-1,Z=i.data[X+1]/127.5-1,et=i.data[X+2]/127.5-1,tt=y.right.map((ct,dt)=>lt*ct+Z*y.up[dt]-et*y.forward[dt]),rt=Math.hypot(...tt)||1;E.set([Ht(tt[0]*(k?-1:1)/rt),Ht(tt[1]/rt),Ht(tt[2]/rt),255],nt)}}for(const y of m)F(y,!1);F(o.left,!0);const H=new Uint8Array(d*w*p),G=new Uint8Array(H.length);for(let y=0;y<p;y++)for(let k=0;k<w;k++)for(let K=0;K<d;K++){const j=((K+.5)/d-.5)*s,J=(y+.5)/p*C,q=(.5-(k+.5)/w)*h;let $=!0,_=!0;for(const[X,nt]of m.entries()){const lt=b(nt,j,J,q);if(lt<0||e.data[lt*4+3]<128){$=!1;break}const Z=ut(j,J,q,nt.forward)-Q[X];(!t.data[lt]||Z+g<v(nt,lt))&&(_=!1)}if($){const X=(y*w+k)*d+K;G[X]=1,_&&(H[X]=1)}}function D(y){const k=Ft(y,d,w,p);if(!k.indices.length)throw new Error("The calibrated views have no common surface.");const K=new Float32Array(k.positions.length),j=new Float32Array(k.positions.length);for(let J=0;J<K.length;J+=3){K.set([(k.positions[J]/d-.5)*s,k.positions[J+2]/p*C,(.5-k.positions[J+1]/w)*h],J);const q=k.gradients[J]*d/s,$=k.gradients[J+2]*p/C,_=-k.gradients[J+1]*w/h,X=Math.hypot(q,$,_)||1;j.set([q/X,$/X,_/X],J)}return{positions:K,normals:j,indices:k.indices}}const L=D(G),Y=D(H),P=Tn(L,Y,t,n),{positions:S,normals:T}=Y,R=new Map,it=[],O=[],z=[],V=[];for(let y=0;y<Y.indices.length;y+=3){const k=Y.indices.slice(y,y+3),K=(Z,et)=>(Z[k[0]*3+et]+Z[k[1]*3+et]+Z[k[2]*3+et])/3,j=K(S,0),J=K(S,1),q=K(S,2),$=K(T,0),_=K(T,1),X=K(T,2);let nt=-1,lt=0;for(const[Z,et]of U.entries()){const tt=Z===M?-1:1,rt=-ut($*tt,_,X,et.forward);if(rt<=.04)continue;const ct=b(et,j*tt,J,q);if(ct<0||!t.data[ct])continue;const dt=v(et,ct),Et=ut(j*tt,J,q,et.forward)-Q[tt===-1?1:Z],ft=Math.abs(Et-dt)/g;if(ft>3.5)continue;const pt=rt/(1+ft*ft);pt>lt&&(nt=Z,lt=pt)}for(const Z of k){const et=Z*(U.length+1)+nt+1;let tt=R.get(et);if(tt===void 0){tt=it.length/3,R.set(et,tt);const rt=Z*3,ct=S[rt],dt=S[rt+1],Et=S[rt+2];it.push(ct,dt-B[2],Et),O.push(T[rt],T[rt+1],T[rt+2]);const ft=U[nt];if(!ft)z.push((I-.5)/I,.5/A);else{const pt=nt===M,jn=ft.anchor[0]+a*ut(pt?-ct:ct,dt,Et,ft.right),Rn=ft.anchor[1]-a*ut(pt?-ct:ct,dt,Et,ft.up);z.push((jn+(pt?f-ft.rect[0]:0))/I,Rn/A)}}V.push(tt)}}const W={target:"mesh",size:l,pivot:B,positions:Float32Array.from(it),normals:Float32Array.from(O),uvs:Float32Array.from(z),indices:Uint32Array.from(V),texture:{width:I,height:A,data:x}},ht={target:"mesh",size:l,pivot:B,positions:L.positions.map((y,k)=>k%3===1?y-B[2]:y),normals:L.normals,indices:Uint32Array.from(L.indices),uvs:new Float32Array(L.positions.length/3*2),texture:{width:1,height:1,data:Uint8Array.of(255,255,255,255)}};return{mesh:W,silhouetteMesh:ht,fit:P,normalMap:{width:I,height:A,data:E},grid:[d,w,p]}}async function It(n,t=!1){Gt(new Uint8Array(await n.slice(0,33).arrayBuffer()));const e=await createImageBitmap(n,{colorSpaceConversion:t?"none":"default"});try{const r=new OffscreenCanvas(e.width,e.height),i=r.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("Could not decode the PNG.");i.drawImage(e,0,0);const c=i.getImageData(0,0,r.width,r.height);return{width:r.width,height:r.height,data:new Uint8Array(c.data.buffer)}}finally{e.close()}}function xt(n){return[n.positions,n.normals,n.indices,n.uvs,n.texture.data].map(t=>t.buffer)}self.onmessage=async({data:n})=>{try{const t=o=>({...o,name:"",mounts:[{name:"",position:[0,0,0]}]}),e="parts"in n?n.parts:[t(n)],r=[];async function i({file:o,layout:f,settings:A,name:s,mounts:h,maps:C}){const u=sn(await It(o),bt(f),A.threshold),p=Mn(u,A),d=an(Nt(u,A.threshold));r.push(...d.warnings.map(g=>s?s+" · "+g:g));let w;if(C){const[g,B,m,Q]=await Promise.all([It(C.clay),C.depth.arrayBuffer(),It(C.baseColor),It(C.normal,!0)]);w=On({calibration:C.calibration,clay:g,depth:Nn(new Uint8Array(B)),baseColor:m,normal:Q},A)}return{...p,name:s,mounts:h,mapped:w}}const c=[];for(const o of e)c.push(await i(o));const a=c.flatMap(o=>[o.voxel,o.marching,...o.meshes]).flatMap(o=>o.frontAccents?[...xt(o),...xt(o.frontAccents)]:xt(o));for(const o of c)a.push(o.stack.texture.data.buffer),o.mapped&&a.push(...xt(o.mapped.mesh),...xt(o.mapped.silhouetteMesh),o.mapped.normalMap.data.buffer);self.postMessage({parts:c,warnings:r},a)}catch(t){self.postMessage({error:t instanceof Error?t.message:String(t)})}}})();
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function ge(ae={}){var M,r=ae,ie=!!globalThis.window,B=!!globalThis.WorkerGlobalScope;function h(e){e={log:e||function(){}};for(const n of h.Pa)n(e);return r.quickJSEmscriptenExtensions=e}h.Pa=[],r.quickjsEmscriptenInit=h,h.Pa.push(e=>{e.getWasmMemory=function(){return T}});var x="./this.program",oe=import.meta.url,P="",H,I;if(ie||B){try{P=new URL(".",oe).href}catch{}B&&(I=e=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)}),H=async e=>{if(e=await fetch(e,{credentials:"same-origin"}),e.ok)return e.arrayBuffer();throw Error(e.status+" : "+e.url)}}var k=console.log.bind(console),g=console.error.bind(console),p,R=!1,F,z,C,W,y,_,m,$=!1;function j(){var e=T.buffer;r.HEAP8=W=new Int8Array(e),new Int16Array(e),r.HEAPU8=y=new Uint8Array(e),new Uint16Array(e),_=new Int32Array(e),m=new Uint32Array(e),new Float32Array(e),new Float64Array(e),new BigInt64Array(e),new BigUint64Array(e)}function N(e){throw r.onAbort?.(e),e="Aborted("+e+")",g(e),R=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),C?.(e),e}var G;async function ue(e){if(!p)try{var n=await H(e);return new Uint8Array(n)}catch{}if(e==G&&p)e=new Uint8Array(p);else if(I)e=I(e);else throw"both async and sync fetching of the wasm failed";return e}async function se(e,n){try{var t=await ue(e);return await WebAssembly.instantiate(t,n)}catch(a){g(`failed to asynchronously prepare wasm: ${a}`),N(a)}}async function le(e){var n=G;if(!p)try{var t=fetch(n,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(t,e)}catch(a){g(`wasm streaming compile failed: ${a}`),g("falling back to ArrayBuffer instantiation")}return se(n,e)}class Y{name="ExitStatus";constructor(n){this.message=`Program terminated with exit(${n})`,this.status=n}}var q=e=>{for(;0<e.length;)e.shift()(r)},J=[],V=[],fe=()=>{var e=r.preRun.shift();V.push(e)},A=!0,T,K=new TextDecoder,X=(e,n,t,a)=>{if(t=n+t,a)return t;for(;e[n]&&!(n>=t);)++n;return n},S=(e,n,t)=>e?K.decode(y.subarray(e,X(y,e,n,t))):"",d=0,_e=[0,31,60,91,121,152,182,213,244,274,305,335],ce=[0,31,59,90,120,151,181,212,243,273,304,334],v={},Z=e=>{if(!(e instanceof Y||e=="unwind"))throw e},b=e=>{throw F=e,A||0<d||(r.onExit?.(e),R=!0),new Y(e)},me=e=>{if(!R)try{e()}catch(n){Z(n)}finally{if(!(A||0<d))try{F=e=F,b(e)}catch(n){Z(n)}}},w=(e,n,t)=>{var a=y;if(!(0<t))return 0;var i=n;t=n+t-1;for(var o=0;o<e.length;++o){var u=e.codePointAt(o);if(127>=u){if(n>=t)break;a[n++]=u}else if(2047>=u){if(n+1>=t)break;a[n++]=192|u>>6,a[n++]=128|u&63}else if(65535>=u){if(n+2>=t)break;a[n++]=224|u>>12,a[n++]=128|u>>6&63,a[n++]=128|u&63}else{if(n+3>=t)break;a[n++]=240|u>>18,a[n++]=128|u>>12&63,a[n++]=128|u>>6&63,a[n++]=128|u&63,o++}}return a[n]=0,n-i},D={},ee=()=>{if(!U){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:x||"./this.program"},n;for(n in D)D[n]===void 0?delete e[n]:e[n]=D[n];var t=[];for(n in e)t.push(`${n}=${e[n]}`);U=t}return U},U,L=e=>{for(var n=0,t=0;t<e.length;++t){var a=e.charCodeAt(t);127>=a?n++:2047>=a?n+=2:55296<=a&&57343>=a?(n+=4,++t):n+=3}return n},Se=[null,[],[]],Te=(e,n,t,a)=>{var i={string:s=>{var l=0;if(s!=null&&s!==0){l=L(s)+1;var c=O(l);w(s,c,l),l=c}return l},array:s=>{var l=O(s.length);return W.set(s,l),l}};e=r["_"+e];var o=[],u=0;if(a)for(var f=0;f<a.length;f++){var Q=i[t[f]];Q?(u===0&&(u=ne()),o[f]=Q(a[f])):o[f]=a[f]}return t=e(...o),t=(function(s){return u!==0&&re(u),n==="string"?S(s):n==="boolean"?!!s:s})(t)};if(r.wasmMemory?T=r.wasmMemory:T=new WebAssembly.Memory({initial:(r.INITIAL_MEMORY||16777216)/65536,maximum:32768}),j(),r.noExitRuntime&&(A=r.noExitRuntime),r.print&&(k=r.print),r.printErr&&(g=r.printErr),r.wasmBinary&&(p=r.wasmBinary),r.thisProgram&&(x=r.thisProgram),r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);0<r.preInit.length;)r.preInit.shift()();r.cwrap=(e,n,t,a)=>{var i=!t||t.every(o=>o==="number"||o==="boolean");return n!=="string"&&i&&!a?r["_"+e]:(...o)=>Te(e,n,t,o)},r.UTF8ToString=S,r.stringToUTF8=(e,n,t)=>w(e,n,t),r.lengthBytesUTF8=L;var te,re,O,ne,we={b:(e,n,t,a)=>N(`Assertion failed: ${S(e)}, at: `+[n?S(n):"unknown filename",t,a?S(a):"unknown function"]),q:()=>N(""),l:()=>{A=!1,d=0},m:function(e,n){e=-9007199254740992>e||9007199254740992<e?NaN:Number(e),e=new Date(1e3*e),_[n>>2]=e.getSeconds(),_[n+4>>2]=e.getMinutes(),_[n+8>>2]=e.getHours(),_[n+12>>2]=e.getDate(),_[n+16>>2]=e.getMonth(),_[n+20>>2]=e.getFullYear()-1900,_[n+24>>2]=e.getDay();var t=e.getFullYear();_[n+28>>2]=(t%4!==0||t%100===0&&t%400!==0?ce:_e)[e.getMonth()]+e.getDate()-1|0,_[n+36>>2]=-(60*e.getTimezoneOffset()),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var a=new Date(e.getFullYear(),0,1).getTimezoneOffset();_[n+32>>2]=(t!=a&&e.getTimezoneOffset()==Math.min(a,t))|0},j:(e,n)=>{if(v[e]&&(clearTimeout(v[e].id),delete v[e]),!n)return 0;var t=setTimeout(()=>{delete v[e],me(()=>te(e,performance.now()))},n);return v[e]={id:t,Qa:n},0},n:(e,n,t,a)=>{var i=new Date().getFullYear(),o=new Date(i,0,1).getTimezoneOffset();i=new Date(i,6,1).getTimezoneOffset(),m[e>>2]=60*Math.max(o,i),_[n>>2]=+(o!=i),n=u=>{var f=Math.abs(u);return`UTC${0<=u?"-":"+"}${String(Math.floor(f/60)).padStart(2,"0")}${String(f%60).padStart(2,"0")}`},e=n(o),n=n(i),i<o?(w(e,t,17),w(n,a,17)):(w(e,a,17),w(n,t,17))},p:()=>Date.now(),k:e=>{var n=y.length;if(e>>>=0,2147483648<e)return!1;for(var t=1;4>=t;t*=2){var a=n*(1+.2/t);a=Math.min(a,e+100663296);e:{a=(Math.min(2147483648,65536*Math.ceil(Math.max(e,a)/65536))-T.buffer.byteLength+65535)/65536|0;try{T.grow(a),j();var i=1;break e}catch{}i=void 0}if(i)return!0}return!1},e:(e,n)=>{var t=0,a=0,i;for(i of ee()){var o=n+t;m[e+a>>2]=o,t+=w(i,o,1/0)+1,a+=4}return 0},f:(e,n)=>{var t=ee();m[e>>2]=t.length,e=0;for(var a of t)e+=L(a)+1;return m[n>>2]=e,0},d:()=>52,o:function(){return 70},c:(e,n,t,a)=>{for(var i=0,o=0;o<t;o++){var u=m[n>>2],f=m[n+4>>2];n+=8;for(var Q=0;Q<f;Q++){var s=e,l=y[u+Q],c=Se[s];l===0||l===10?(s=s===1?k:g,l=X(c,0),l=K.decode(c.buffer?c.subarray(0,l):new Uint8Array(c.slice(0,l))),s(l),c.length=0):c.push(l)}i+=f}return m[a>>2]=i,0},a:T,r:b,s:function(e,n,t,a,i){return r.callbacks.callFunction(void 0,e,n,t,a,i)},i:function(e){return r.callbacks.shouldInterrupt(void 0,e)},h:function(e,n,t){return t=S(t),r.callbacks.loadModuleSource(void 0,e,n,t)},g:function(e,n,t,a){return t=S(t),a=S(a),r.callbacks.normalizeModule(void 0,e,n,t,a)},t:function(e,n){r.callbacks.freeHostRef(void 0,e,n)}},E;return E=await(async function(){function e(t){return t=E=t.exports,r._malloc=t.v,r._QTS_Throw=t.w,r._QTS_NewError=t.x,r._QTS_RuntimeSetMemoryLimit=t.y,r._QTS_RuntimeComputeMemoryUsage=t.z,r._QTS_RuntimeDumpMemoryUsage=t.A,r._QTS_RecoverableLeakCheck=t.B,r._QTS_BuildIsSanitizeLeak=t.C,r._QTS_RuntimeSetMaxStackSize=t.D,r._QTS_GetUndefined=t.E,r._QTS_GetNull=t.F,r._QTS_GetFalse=t.G,r._QTS_GetTrue=t.H,r._QTS_NewHostRef=t.I,r._QTS_GetHostRefId=t.J,r._QTS_NewRuntime=t.K,r._QTS_FreeRuntime=t.L,r._free=t.M,r._QTS_NewContext=t.N,r._QTS_FreeContext=t.O,r._QTS_FreeValuePointer=t.P,r._QTS_FreeValuePointerRuntime=t.Q,r._QTS_FreeVoidPointer=t.R,r._QTS_FreeCString=t.S,r._QTS_DupValuePointer=t.T,r._QTS_NewObject=t.U,r._QTS_NewObjectProto=t.V,r._QTS_NewArray=t.W,r._QTS_NewArrayBuffer=t.X,r._QTS_NewFloat64=t.Y,r._QTS_GetFloat64=t.Z,r._QTS_NewString=t._,r._QTS_GetString=t.$,r._QTS_GetArrayBuffer=t.aa,r._QTS_GetArrayBufferLength=t.ba,r._QTS_NewSymbol=t.ca,r._QTS_GetSymbolDescriptionOrKey=t.da,r._QTS_IsGlobalSymbol=t.ea,r._QTS_IsJobPending=t.fa,r._QTS_ExecutePendingJob=t.ga,r._QTS_GetProp=t.ha,r._QTS_GetPropNumber=t.ia,r._QTS_SetProp=t.ja,r._QTS_DefineProp=t.ka,r._QTS_GetOwnPropertyNames=t.la,r._QTS_Call=t.ma,r._QTS_ResolveException=t.na,r._QTS_Dump=t.oa,r._QTS_Eval=t.pa,r._QTS_GetModuleNamespace=t.qa,r._QTS_Typeof=t.ra,r._QTS_GetLength=t.sa,r._QTS_IsEqual=t.ta,r._QTS_GetGlobalObject=t.ua,r._QTS_NewPromiseCapability=t.va,r._QTS_PromiseState=t.wa,r._QTS_PromiseResult=t.xa,r._QTS_TestStringArg=t.ya,r._QTS_GetDebugLogEnabled=t.za,r._QTS_SetDebugLogEnabled=t.Aa,r._QTS_BuildIsDebug=t.Ba,r._QTS_BuildIsAsyncify=t.Ca,r._QTS_NewFunction=t.Da,r._QTS_ArgvGetJSValueConstPointer=t.Ea,r._QTS_RuntimeEnableInterruptHandler=t.Fa,r._QTS_RuntimeDisableInterruptHandler=t.Ga,r._QTS_RuntimeEnableModuleLoader=t.Ha,r._QTS_RuntimeDisableModuleLoader=t.Ia,r._QTS_bjson_encode=t.Ja,r._QTS_bjson_decode=t.Ka,te=t.La,re=t.Ma,O=t.Na,ne=t.Oa,E}var n={a:we};return r.instantiateWasm?new Promise(t=>{r.instantiateWasm(n,(a,i)=>{t(e(a))})}):(G??=r.locateFile?r.locateFile?r.locateFile("emscripten-module.wasm",P):P+"emscripten-module.wasm":new URL(""+new URL("emscripten-module-uFzwHH0Y.wasm",import.meta.url).href,import.meta.url).href,e((await le(n)).instance))})(),(function(){function e(){if(r.calledRun=!0,!R){if($=!0,E.u(),z?.(r),r.onRuntimeInitialized?.(),r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;){var n=r.postRun.shift();J.push(n)}q(J)}}if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)fe();q(V),r.setStatus?(r.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>r.setStatus(""),1),e()},1)):e()})(),$?M=r:M=new Promise((e,n)=>{z=e,C=n}),M}export{ge as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=class{constructor(e){this.module=e,this.DEBUG=!1,this.QTS_Throw=this.module.cwrap("QTS_Throw","number",["number","number"]),this.QTS_NewError=this.module.cwrap("QTS_NewError","number",["number"]),this.QTS_RuntimeSetMemoryLimit=this.module.cwrap("QTS_RuntimeSetMemoryLimit",null,["number","number"]),this.QTS_RuntimeComputeMemoryUsage=this.module.cwrap("QTS_RuntimeComputeMemoryUsage","number",["number","number"]),this.QTS_RuntimeDumpMemoryUsage=this.module.cwrap("QTS_RuntimeDumpMemoryUsage","number",["number"]),this.QTS_RecoverableLeakCheck=this.module.cwrap("QTS_RecoverableLeakCheck","number",[]),this.QTS_BuildIsSanitizeLeak=this.module.cwrap("QTS_BuildIsSanitizeLeak","number",[]),this.QTS_RuntimeSetMaxStackSize=this.module.cwrap("QTS_RuntimeSetMaxStackSize",null,["number","number"]),this.QTS_GetUndefined=this.module.cwrap("QTS_GetUndefined","number",[]),this.QTS_GetNull=this.module.cwrap("QTS_GetNull","number",[]),this.QTS_GetFalse=this.module.cwrap("QTS_GetFalse","number",[]),this.QTS_GetTrue=this.module.cwrap("QTS_GetTrue","number",[]),this.QTS_NewHostRef=this.module.cwrap("QTS_NewHostRef","number",["number","number"]),this.QTS_GetHostRefId=this.module.cwrap("QTS_GetHostRefId","number",["number"]),this.QTS_NewRuntime=this.module.cwrap("QTS_NewRuntime","number",[]),this.QTS_FreeRuntime=this.module.cwrap("QTS_FreeRuntime",null,["number"]),this.QTS_NewContext=this.module.cwrap("QTS_NewContext","number",["number","number"]),this.QTS_FreeContext=this.module.cwrap("QTS_FreeContext",null,["number"]),this.QTS_FreeValuePointer=this.module.cwrap("QTS_FreeValuePointer",null,["number","number"]),this.QTS_FreeValuePointerRuntime=this.module.cwrap("QTS_FreeValuePointerRuntime",null,["number","number"]),this.QTS_FreeVoidPointer=this.module.cwrap("QTS_FreeVoidPointer",null,["number","number"]),this.QTS_FreeCString=this.module.cwrap("QTS_FreeCString",null,["number","number"]),this.QTS_DupValuePointer=this.module.cwrap("QTS_DupValuePointer","number",["number","number"]),this.QTS_NewObject=this.module.cwrap("QTS_NewObject","number",["number"]),this.QTS_NewObjectProto=this.module.cwrap("QTS_NewObjectProto","number",["number","number"]),this.QTS_NewArray=this.module.cwrap("QTS_NewArray","number",["number"]),this.QTS_NewArrayBuffer=this.module.cwrap("QTS_NewArrayBuffer","number",["number","number","number"]),this.QTS_NewFloat64=this.module.cwrap("QTS_NewFloat64","number",["number","number"]),this.QTS_GetFloat64=this.module.cwrap("QTS_GetFloat64","number",["number","number"]),this.QTS_NewString=this.module.cwrap("QTS_NewString","number",["number","number"]),this.QTS_GetString=this.module.cwrap("QTS_GetString","number",["number","number"]),this.QTS_GetArrayBuffer=this.module.cwrap("QTS_GetArrayBuffer","number",["number","number"]),this.QTS_GetArrayBufferLength=this.module.cwrap("QTS_GetArrayBufferLength","number",["number","number"]),this.QTS_NewSymbol=this.module.cwrap("QTS_NewSymbol","number",["number","number","number"]),this.QTS_GetSymbolDescriptionOrKey=this.module.cwrap("QTS_GetSymbolDescriptionOrKey","number",["number","number"]),this.QTS_IsGlobalSymbol=this.module.cwrap("QTS_IsGlobalSymbol","number",["number","number"]),this.QTS_IsJobPending=this.module.cwrap("QTS_IsJobPending","number",["number"]),this.QTS_ExecutePendingJob=this.module.cwrap("QTS_ExecutePendingJob","number",["number","number","number"]),this.QTS_GetProp=this.module.cwrap("QTS_GetProp","number",["number","number","number"]),this.QTS_GetPropNumber=this.module.cwrap("QTS_GetPropNumber","number",["number","number","number"]),this.QTS_SetProp=this.module.cwrap("QTS_SetProp",null,["number","number","number","number"]),this.QTS_DefineProp=this.module.cwrap("QTS_DefineProp",null,["number","number","number","number","number","number","boolean","boolean","boolean"]),this.QTS_GetOwnPropertyNames=this.module.cwrap("QTS_GetOwnPropertyNames","number",["number","number","number","number","number"]),this.QTS_Call=this.module.cwrap("QTS_Call","number",["number","number","number","number","number"]),this.QTS_ResolveException=this.module.cwrap("QTS_ResolveException","number",["number","number"]),this.QTS_Dump=this.module.cwrap("QTS_Dump","number",["number","number"]),this.QTS_Eval=this.module.cwrap("QTS_Eval","number",["number","number","number","string","number","number"]),this.QTS_GetModuleNamespace=this.module.cwrap("QTS_GetModuleNamespace","number",["number","number"]),this.QTS_Typeof=this.module.cwrap("QTS_Typeof","number",["number","number"]),this.QTS_GetLength=this.module.cwrap("QTS_GetLength","number",["number","number","number"]),this.QTS_IsEqual=this.module.cwrap("QTS_IsEqual","number",["number","number","number","number"]),this.QTS_GetGlobalObject=this.module.cwrap("QTS_GetGlobalObject","number",["number"]),this.QTS_NewPromiseCapability=this.module.cwrap("QTS_NewPromiseCapability","number",["number","number"]),this.QTS_PromiseState=this.module.cwrap("QTS_PromiseState","number",["number","number"]),this.QTS_PromiseResult=this.module.cwrap("QTS_PromiseResult","number",["number","number"]),this.QTS_TestStringArg=this.module.cwrap("QTS_TestStringArg",null,["string"]),this.QTS_GetDebugLogEnabled=this.module.cwrap("QTS_GetDebugLogEnabled","number",["number"]),this.QTS_SetDebugLogEnabled=this.module.cwrap("QTS_SetDebugLogEnabled",null,["number","number"]),this.QTS_BuildIsDebug=this.module.cwrap("QTS_BuildIsDebug","number",[]),this.QTS_BuildIsAsyncify=this.module.cwrap("QTS_BuildIsAsyncify","number",[]),this.QTS_NewFunction=this.module.cwrap("QTS_NewFunction","number",["number","string","number","boolean","number"]),this.QTS_ArgvGetJSValueConstPointer=this.module.cwrap("QTS_ArgvGetJSValueConstPointer","number",["number","number"]),this.QTS_RuntimeEnableInterruptHandler=this.module.cwrap("QTS_RuntimeEnableInterruptHandler",null,["number"]),this.QTS_RuntimeDisableInterruptHandler=this.module.cwrap("QTS_RuntimeDisableInterruptHandler",null,["number"]),this.QTS_RuntimeEnableModuleLoader=this.module.cwrap("QTS_RuntimeEnableModuleLoader",null,["number","number"]),this.QTS_RuntimeDisableModuleLoader=this.module.cwrap("QTS_RuntimeDisableModuleLoader",null,["number"]),this.QTS_bjson_encode=this.module.cwrap("QTS_bjson_encode","number",["number","number"]),this.QTS_bjson_decode=this.module.cwrap("QTS_bjson_decode","number",["number","number"])}};export{r as QuickJSFFI};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G,p as H}from"./style-CWGgpweN.js";function Q(e,n){return n.flatMap((c,i)=>c.mounts.map(w=>({...w,asset:e[i]})))}function S(e){const n=new G;for(const{asset:c,name:i,position:[w,s,f],scale:m=1,mirrorX:p,mirrorY:h}of e){const u=H(c);u.name=i,u.position.set(w,f,-s),u.scale.set(p?-m:m,m,h?-m:m),n.add(u)}return n}function V(e){if(e.length===0||e.some(({asset:r})=>r.target!=="stack"))throw new Error("A stack assembly needs reconstructed stack parts.");const n=e,c=n.map(({asset:r,position:[t,y,T],scale:R=1})=>{const[U,L,v]=r.size.map(l=>l*R),M=T-r.pivot[2]*R;return{min:[t-U/2,y-L/2,M],max:[t+U/2,y+L/2,M+v]}}),i=[0,1,2].map(r=>Math.min(...c.map(({min:t})=>t[r]))),s=[0,1,2].map(r=>Math.max(...c.map(({max:t})=>t[r]))).map((r,t)=>r-i[t]),f=Math.min(192/Math.max(s[0],s[1]),Math.max(...n.map(({asset:r,scale:t=1})=>Math.max(r.width/r.size[0],r.depth/r.size[1])/t))),m=Math.max(1,Math.round(s[0]*f)),p=Math.max(1,Math.round(s[1]*f)),h=Math.min(...n.map(({asset:r,scale:t=1})=>r.spacing*t)),u=Math.max(1,Math.min(128,Math.floor(3e6/(m*p)),Math.ceil(s[2]/h))),g=[s[0]/m,s[1]/p,s[2]/u],d=Math.min(u,Math.floor(4096/m)),B=m*d,A=p*Math.ceil(u/d),C=new Uint8Array(4*B*A);for(const[r,{asset:t,mirrorX:y,mirrorY:T}]of n.entries()){const{min:R,max:U}=c[r],L=R.map((l,o)=>Math.ceil((l-i[o])/g[o]-.5)),v=U.map((l,o)=>Math.ceil((l-i[o])/g[o]-.5)),M=(l,o,k)=>Math.max(0,Math.min(k-1,Math.floor((i[o]+(l+.5)*g[o]-R[o])*k/(U[o]-R[o]))));for(let l=L[2];l<v[2];l++)for(let o=L[1];o<v[1];o++){const k=M(l,2,t.layers),X=M(o,1,t.depth),P=(Math.floor(k/t.columns)*t.depth+(T?t.depth-1-X:X))*t.texture.width,j=(Math.floor(l/d)*p+o)*B;for(let b=L[0];b<v[0];b++){const F=M(b,0,t.width),D=4*(P+k%t.columns*t.width+(y?t.width-1-F:F));if(t.texture.data[D+3]<128)continue;const q=4*(j+l%d*m+b);for(let x=0;x<4;x++)C[q+x]=t.texture.data[D+x]}}}return{target:"stack",width:m,depth:p,layers:u,columns:d,spacing:g[2],size:s,pivot:[0,0,-i[2]],texture:{width:B,height:A,data:C}}}const z={cone:new URL(""+new URL("traffic-cone-4view-DG-TkITx.png",import.meta.url).href,import.meta.url),rover:new URL(""+new URL("fillet-rover-body-4-view-Chk8Mx4R.png",import.meta.url).href,import.meta.url),inspection:new URL(""+new URL("inspection-robot-body-4-view-CLMaHFYm.png",import.meta.url).href,import.meta.url),ant:new URL(""+new URL("ant-mech-body-4view-D9xVPpbc.png",import.meta.url).href,import.meta.url),tank:new URL(""+new URL("tank-hull-4view-B4sMMkP5.png",import.meta.url).href,import.meta.url),sign:new URL(""+new URL("wet-floor-sign-4view-CWJDyeTX.png",import.meta.url).href,import.meta.url),barrier:new URL(""+new URL("plastic-barrier-4view-DQkTBW_i.png",import.meta.url).href,import.meta.url),concrete:new URL(""+new URL("concrete-barrier-4view-7PsO3Ftq.png",import.meta.url).href,import.meta.url)},K={draft:{layers:24,resolution:72},balanced:{layers:48,resolution:96},detail:{layers:90,resolution:144}},W=new URL(""+new URL("fillet-rover-wheel-4-view-B-F8flOC.png",import.meta.url).href,import.meta.url),Y=new URL(""+new URL("inspection-robot-wheel-4-view-27wRsxcs.png",import.meta.url).href,import.meta.url),I=new URL(""+new URL("ant-mech-center-leg-4view-BcphjF_G.png",import.meta.url).href,import.meta.url),_=new URL(""+new URL("ant-mech-angled-leg-4view-BO2qt1_k.png",import.meta.url).href,import.meta.url),E=new URL(""+new URL("tank-turret-4view-Cx0FuNFu.png",import.meta.url).href,import.meta.url),J=new URL(""+new URL("tank-track-4view-DAIiMTy3.png",import.meta.url).href,import.meta.url),a=(e,n,c,i)=>[e/i,n/i,c/i];function O(e,n,c,i,w,s,f,m){const p=c[2];return[{name:"Body",url:e,size:a(...c,p),mounts:[{name:"Body",position:a(0,0,w,p)}]},{name:"Wheel",url:n,size:a(...i,p),mounts:[-1,1].flatMap(h=>[s,f].map((u,g)=>({name:(h<0?"Left ":"Right ")+(g?"rear wheel":"front wheel"),position:a(h*m,u,0,p),mirrorX:h<0})))}]}const Z={rover:O(z.rover,W,[80,188,90],[20,44,44],13,48.5,-56.5,36.5),inspection:O(z.inspection,Y,[92,194,150],[30,74,74],14,45,-63,46.5),ant:[{name:"Body",url:z.ant,size:a(50,114,56,56),mounts:[{name:"Body",position:a(0,0,26,56)}]},{name:"Center leg",url:I,size:a(23,17,41,56),mounts:[-1,1].map(e=>({name:e<0?"Left center leg":"Right center leg",position:a(e*27,0,0,56),mirrorX:e<0}))},{name:"Angled leg",url:_,size:a(23,30,41,56),mounts:[-1,1].flatMap(e=>[-1,1].map(n=>({name:(e<0?"Left ":"Right ")+(n<0?"rear leg":"front leg"),position:a(e*27,n*42,0,56),mirrorX:e<0,mirrorY:n<0})))}],tank:[{name:"Hull",url:z.tank,size:a(86,166,49,49),mounts:[{name:"Hull",position:a(0,0,13,49)}]},{name:"Turret",url:E,size:a(60,120,33,49),mounts:[{name:"Turret",position:a(0,15,60,49)}]},{name:"Track",url:J,size:a(23,163,34,49),mounts:[-1,1].map(e=>({name:e<0?"Left track":"Right track",position:a(e*45,0,0,49),mirrorX:e<0}))}]};export{V as b,S as c,Q as i,Z as m,K as q,z as s};
|