rayzee 9.4.1 → 9.5.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/README.md +226 -25
- package/dist/ActiveColor-YvuQq44O.js +13 -0
- package/dist/ArchiveImporter-xuUJiklP.js +4301 -0
- package/dist/AssetConfig-DSEntE65.js +30 -0
- package/dist/BidirectionalIntegrator-C5PKjJoT.js +934 -0
- package/dist/ColorManagement-CheBCPaW.js +1488 -0
- package/dist/EngineDefaults-DH3bI5t-.js +844 -0
- package/dist/EngineEvents-Ci8dVWCP.js +73 -0
- package/dist/EngineIssues-CIZnXHsF.js +72 -0
- package/dist/FileFormats-sPGJeCRc.js +102 -0
- package/dist/Logger-BnHghprG.js +97 -0
- package/dist/{NeuralRetouch-vkdXXyK2.js → NeuralRetouch-CW11yLZ_.js} +8 -6
- package/dist/{NeuralSuperRes-FVqRJKQV.js → NeuralSuperRes-BekaecYg.js} +55 -120
- package/dist/PathTracer-Ccl9KOuF.js +29729 -0
- package/dist/PhysicalSky-Dv2PMFGW.js +1219 -0
- package/dist/RayzeeRenderer-BQxnzCTD.js +3542 -0
- package/dist/SolarLimb-ken-JbDK.js +721 -0
- package/dist/ToneMapGPU-BHi5JzIq.js +177 -0
- package/dist/ViewTransforms-D0rTLBsX.js +255 -0
- package/dist/WorkingMatrix-C6y233hT.js +27 -0
- package/dist/ZipReader-gDSWr0I5.js +98 -0
- package/dist/addons/archives.es.js +3 -0
- package/dist/addons/bidirectional.es.js +2 -0
- package/dist/addons/color.es.js +3 -0
- package/dist/addons/formats.es.js +2 -0
- package/dist/addons/physical-sky.es.js +2 -0
- package/dist/addons/storage.es.js +3 -0
- package/dist/archiveFormats-BZw7TiDp.js +75 -0
- package/dist/identity-DrQsGT2o.js +39 -0
- package/dist/openStorage-DwcBRUj7.js +820 -0
- package/dist/rayzee-core.es.js +12 -0
- package/dist/rayzee.es.js +2266 -44125
- package/dist/rayzee.umd.js +485 -473
- package/dist/sceneCachePolicy-BmwYOYDu.js +183 -0
- package/dist/shared-BGBcSxBQ.js +17 -0
- package/package.json +23 -2
- package/src/Color/ActiveColor.js +34 -0
- package/src/Color/BasicColor.js +147 -0
- package/src/Color/ColorManagement.js +7 -31
- package/src/EngineDefaults.js +23 -14
- package/src/EngineEvents.js +2 -0
- package/src/EngineIssues.js +1 -0
- package/src/PathTracerApp.js +617 -4016
- package/src/Pipeline/PipelineContext.js +0 -4
- package/src/Platform.js +36 -0
- package/src/Processor/ArchiveCache.js +1 -1
- package/src/Processor/ArchiveImporter.js +1259 -0
- package/src/Processor/AssetLoader.js +322 -1746
- package/src/Processor/AtmosphereModel.js +1 -2
- package/src/Processor/BVHBuilder.js +4 -95
- package/src/Processor/EnvironmentExactTable.js +187 -0
- package/src/Processor/EquirectHDRInfo.js +30 -223
- package/src/Processor/FileFormats.js +116 -0
- package/src/Processor/GLTFDecoders.js +85 -0
- package/src/Processor/GLTFDiffuseTransmission.js +63 -0
- package/src/Processor/GeometryExtractor.js +12 -1
- package/src/Processor/IESParser.js +47 -35
- package/src/Processor/KernelManager.js +35 -2
- package/src/Processor/MaterialPacking.js +8 -7
- package/src/Processor/PBRT/PBRTMaterials.js +129 -41
- package/src/Processor/PBRT/PBRTParser.js +30 -17
- package/src/Processor/PBRT/PBRTSceneBuilder.js +548 -37
- package/src/Processor/PBRT/PBRTTextureBake.js +154 -0
- package/src/Processor/PBRT/PFM.js +59 -0
- package/src/Processor/PackedRayBuffer.js +116 -9
- package/src/Processor/ParallelBVHBuilder.js +3 -6
- package/src/Processor/PhysicalSky.js +5 -4
- package/src/Processor/PlatformImageLoader.js +50 -6
- package/src/Processor/QueueManager.js +12 -3
- package/src/Processor/ReinsertionOptimizer.js +2 -2
- package/src/Processor/SceneProcessor.js +15 -55
- package/src/Processor/ShaderBuilder.js +6 -16
- package/src/Processor/SimpleSky.js +1 -62
- package/src/Processor/SolarLimb.js +3 -0
- package/src/Processor/TextureCreator.js +1 -1
- package/src/Processor/Workers/BVHSubtreeWorker.js +1 -34
- package/src/Processor/Workers/BVHWorker.js +5 -18
- package/src/Processor/Workers/CDFWorker.js +6 -183
- package/src/Processor/archiveFormats.js +7 -0
- package/src/Processor/utils.js +2 -1
- package/src/RayzeeRenderer.js +3902 -0
- package/src/RenderSettings.js +49 -41
- package/src/Stages/ASVGF.js +5 -7
- package/src/Stages/AutoExposure.js +3 -12
- package/src/Stages/Compositor.js +8 -23
- package/src/Stages/NRD.js +9 -2
- package/src/Stages/NormalDepth.js +9 -6
- package/src/Stages/PathTracer.js +254 -38
- package/src/Stages/PathTracerStage.js +11 -16
- package/src/Storage/BLASCache.js +1 -1
- package/src/Storage/CDFCache.js +18 -17
- package/src/Storage/DownloadCache.js +1 -1
- package/src/Storage/SceneGraphCodec.js +46 -3
- package/src/Storage/SpillStore.js +1 -1
- package/src/Storage/StorageManager.js +2 -4
- package/src/Storage/areas.js +4 -0
- package/src/TSL/BVHTraversal.js +62 -24
- package/src/TSL/Bidirectional.js +204 -0
- package/src/TSL/BidirectionalLamps.js +132 -0
- package/src/TSL/Clearcoat.js +15 -6
- package/src/TSL/Common.js +19 -14
- package/src/TSL/ConnectKernel.js +147 -0
- package/src/TSL/Debugger.js +1 -1
- package/src/TSL/Displacement.js +4 -3
- package/src/TSL/EmissiveSampling.js +64 -17
- package/src/TSL/Environment.js +77 -106
- package/src/TSL/EnvironmentCDF.js +85 -39
- package/src/TSL/ExtendKernel.js +8 -3
- package/src/TSL/FinalWriteKernel.js +4 -4
- package/src/TSL/GenerateKernel.js +18 -4
- package/src/TSL/HitFacet.js +35 -5
- package/src/TSL/LightBVHSampling.js +40 -9
- package/src/TSL/LightGenerateKernel.js +293 -0
- package/src/TSL/LightGuide.js +198 -0
- package/src/TSL/LightSplatKernel.js +165 -0
- package/src/TSL/LightsCore.js +13 -38
- package/src/TSL/LightsDirect.js +28 -29
- package/src/TSL/LightsIndirect.js +3 -1
- package/src/TSL/LightsSampling.js +90 -38
- package/src/TSL/MaterialEvaluation.js +113 -31
- package/src/TSL/MaterialProperties.js +44 -17
- package/src/TSL/MaterialTransmission.js +52 -47
- package/src/TSL/MergeKernel.js +218 -0
- package/src/TSL/PathTracerCore.js +65 -29
- package/src/TSL/Random.js +4 -0
- package/src/TSL/SceneResources.js +51 -0
- package/src/TSL/ShadeKernel.js +881 -103
- package/src/TSL/Struct.js +10 -0
- package/src/TSL/Sun.js +1 -1
- package/src/TSL/TextureSampling.js +65 -60
- package/src/addons/archives.js +14 -0
- package/src/addons/bidirectional.js +13 -0
- package/src/addons/color.js +32 -0
- package/src/addons/formats.js +16 -0
- package/src/addons/physicalSky.js +14 -0
- package/src/addons/storage.js +19 -0
- package/src/core.js +35 -0
- package/src/index.js +3 -1
- package/src/integrators/BidirectionalIntegrator.js +832 -0
- package/src/managers/EnvironmentManager.js +94 -91
- package/src/managers/MaterialDataManager.js +42 -0
- package/src/managers/UniformManager.js +0 -1
- package/dist/ToneMapGPU-DKQM1pMd.js +0 -552
- package/dist/rolldown-runtime-CAFD8bLK.js +0 -11
- package/src/Processor/TreeletOptimizer.js +0 -574
|
@@ -0,0 +1,4301 @@
|
|
|
1
|
+
import { n as e } from "./BidirectionalIntegrator-C5PKjJoT.js";
|
|
2
|
+
import { g as t, n, o as r, r as i } from "./sceneCachePolicy-BmwYOYDu.js";
|
|
3
|
+
import "./EngineDefaults-DH3bI5t-.js";
|
|
4
|
+
import { n as a, r as o } from "./EngineIssues-CIZnXHsF.js";
|
|
5
|
+
import { r as s } from "./shared-BGBcSxBQ.js";
|
|
6
|
+
import { a as c, n as l, r as u } from "./identity-DrQsGT2o.js";
|
|
7
|
+
import { n as d, t as f } from "./archiveFormats-BZw7TiDp.js";
|
|
8
|
+
import { n as p, t as m } from "./ZipReader-gDSWr0I5.js";
|
|
9
|
+
import { AnimationClip as h, BooleanKeyframeTrack as g, BufferAttribute as _, BufferGeometry as v, Color as y, DataTexture as b, DirectionalLight as x, DoubleSide as S, EquirectangularReflectionMapping as C, Float32BufferAttribute as w, FloatType as T, FrontSide as E, Group as D, InstancedBufferAttribute as O, InstancedMesh as k, LinearFilter as A, LoadingManager as j, MaterialLoader as M, Matrix4 as N, Mesh as ee, MeshPhysicalMaterial as te, NoColorSpace as ne, NumberKeyframeTrack as re, Object3D as ie, OrthographicCamera as ae, PerspectiveCamera as oe, PointLight as se, Quaternion as ce, QuaternionKeyframeTrack as le, RGBAFormat as P, RepeatWrapping as ue, SRGBColorSpace as F, SphereGeometry as de, SpotLight as fe, Texture as pe, Uint32BufferAttribute as I, Vector3 as L, VectorKeyframeTrack as me } from "three";
|
|
10
|
+
import { HDRLoader as he } from "three/addons/loaders/HDRLoader.js";
|
|
11
|
+
import { Gunzip as ge, strFromU8 as R, zipSync as _e } from "three/addons/libs/fflate.module.js";
|
|
12
|
+
import { EXRLoader as ve } from "three/addons/loaders/EXRLoader.js";
|
|
13
|
+
//#region src/Processor/ArchiveReader.js
|
|
14
|
+
var z = 512, ye = 4 << 20, be = 15e8, xe = new TextDecoder();
|
|
15
|
+
function Se(e) {
|
|
16
|
+
return e.length >= 2 && e[0] === 31 && e[1] === 139;
|
|
17
|
+
}
|
|
18
|
+
function Ce(e) {
|
|
19
|
+
return e.length >= 4 && e[0] === 80 && e[1] === 75 && (e[2] === 3 || e[2] === 5 || e[2] === 7);
|
|
20
|
+
}
|
|
21
|
+
function we(e) {
|
|
22
|
+
return e.length >= 263 && String.fromCharCode(...e.subarray(257, 262)) === "ustar";
|
|
23
|
+
}
|
|
24
|
+
function Te(e) {
|
|
25
|
+
return Se(e) ? "gzip" : Ce(e) ? "zip" : we(e) ? "tar" : null;
|
|
26
|
+
}
|
|
27
|
+
function B(e, t, n) {
|
|
28
|
+
let r = t, i = t + n;
|
|
29
|
+
for (; r < i && e[r] !== 0;) r++;
|
|
30
|
+
return xe.decode(e.subarray(t, r));
|
|
31
|
+
}
|
|
32
|
+
function Ee(e, t, n) {
|
|
33
|
+
if (e[t] & 128) {
|
|
34
|
+
let r = e[t] & 127;
|
|
35
|
+
for (let i = t + 1; i < t + n; i++) r = r * 256 + e[i];
|
|
36
|
+
return r;
|
|
37
|
+
}
|
|
38
|
+
let r = B(e, t, n).trim();
|
|
39
|
+
if (!r) return 0;
|
|
40
|
+
let i = parseInt(r, 8);
|
|
41
|
+
return Number.isFinite(i) ? i : 0;
|
|
42
|
+
}
|
|
43
|
+
function De(e) {
|
|
44
|
+
let t = [];
|
|
45
|
+
for (let n of e.replace(/\\/g, "/").split("/")) n === "" || n === "." || (n === ".." ? t.pop() : t.push(n));
|
|
46
|
+
return t.join("/");
|
|
47
|
+
}
|
|
48
|
+
function Oe(e) {
|
|
49
|
+
let t = xe.decode(e).match(/^\d+ path=(.*)$/m);
|
|
50
|
+
return t ? t[1] : null;
|
|
51
|
+
}
|
|
52
|
+
var ke = (e) => e + (z - e % z) % z, Ae = (e) => e === "L" || e === "x" || e === "X";
|
|
53
|
+
function je(e) {
|
|
54
|
+
let t = B(e, 345, 155), n = B(e, 0, 100);
|
|
55
|
+
return {
|
|
56
|
+
type: String.fromCharCode(e[156] || 48),
|
|
57
|
+
size: Ee(e, 124, 12),
|
|
58
|
+
name: t ? `${t}/${n}` : n
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function Me(e, t) {
|
|
62
|
+
return e === "5" || e === "g" || e === "K" || t.endsWith("/") || e !== "0" && e !== " " ? null : De(t) || null;
|
|
63
|
+
}
|
|
64
|
+
function Ne(e) {
|
|
65
|
+
for (let t = 0; t < z; t++) if (e[t] !== 0) return !1;
|
|
66
|
+
return !0;
|
|
67
|
+
}
|
|
68
|
+
var Pe = class {
|
|
69
|
+
constructor({ filter: e = null, retain: t = null, byteBudget: n = be, onEntry: r = null } = {}) {
|
|
70
|
+
this.filter = e, this.retain = t, this.byteBudget = n, this.onEntry = r, this.entries = Object.create(null), this.listing = [], this.retainedBytes = 0, this.truncated = !1, this.finished = !1, this._header = new Uint8Array(z), this._headerLen = 0, this._state = "header", this._remaining = 0, this._size = 0, this._copied = 0, this._dst = null, this._special = null, this._pendingName = null, this._abs = 0;
|
|
71
|
+
}
|
|
72
|
+
push(e) {
|
|
73
|
+
let t = this._abs;
|
|
74
|
+
this._abs += e.length;
|
|
75
|
+
let n = 0;
|
|
76
|
+
for (; n < e.length && !this.finished;) if (this._state === "header") {
|
|
77
|
+
let r = Math.min(z - this._headerLen, e.length - n);
|
|
78
|
+
this._header.set(e.subarray(n, n + r), this._headerLen), this._headerLen += r, n += r, this._headerLen === z && (this._headerLen = 0, this._bodyStart = t + n, this._readHeader());
|
|
79
|
+
} else {
|
|
80
|
+
let t = Math.min(this._remaining, e.length - n);
|
|
81
|
+
if (this._dst && this._copied < this._size) {
|
|
82
|
+
let r = Math.min(t, this._size - this._copied);
|
|
83
|
+
this._dst.set(e.subarray(n, n + r), this._copied), this._copied += r;
|
|
84
|
+
}
|
|
85
|
+
this._remaining -= t, n += t, this._remaining === 0 && this._endBody();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
end() {
|
|
89
|
+
this.finished = !0;
|
|
90
|
+
}
|
|
91
|
+
result() {
|
|
92
|
+
return {
|
|
93
|
+
entries: this.entries,
|
|
94
|
+
listing: this.listing,
|
|
95
|
+
retainedBytes: this.retainedBytes,
|
|
96
|
+
truncated: this.truncated
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
_readHeader() {
|
|
100
|
+
let e = this._header, t = !0;
|
|
101
|
+
for (let n = 0; n < z; n++) if (e[n] !== 0) {
|
|
102
|
+
t = !1;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (t) {
|
|
106
|
+
this.finished = !0;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
let { type: n, size: r, name: i } = je(e), a = this._pendingName ?? i;
|
|
110
|
+
if (this._pendingName = null, this._size = r, this._copied = 0, this._remaining = ke(r), this._dst = null, this._special = null, this._indexed = !1, this._state = this._remaining > 0 ? "body" : "header", Ae(n)) {
|
|
111
|
+
this._special = n === "L" ? "longname" : "pax", this._dst = new Uint8Array(r);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
let o = Me(n, a);
|
|
115
|
+
o && (this.listing.push({
|
|
116
|
+
path: o,
|
|
117
|
+
size: r
|
|
118
|
+
}), this._indexed = this.filter ? this.filter(o, r) : !0, this._indexed && !(this.retain && !this.retain(o, r)) && (this.retainedBytes + r > this.byteBudget ? this.truncated = !0 : (this._dst = new Uint8Array(r), this.retainedBytes += r)), this._remaining === 0 && this._endBody());
|
|
119
|
+
}
|
|
120
|
+
_endBody() {
|
|
121
|
+
if (this._state = "header", this._special === "longname") {
|
|
122
|
+
this._pendingName = B(this._dst, 0, this._dst.length), this._dst = null;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (this._special === "pax") {
|
|
126
|
+
let e = Oe(this._dst);
|
|
127
|
+
e && (this._pendingName = e), this._dst = null;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
let e = this.listing[this.listing.length - 1];
|
|
131
|
+
this._indexed && e && (e.offset = this._bodyStart, this._indexed = !1), this._dst &&= (this.entries[e.path] = this._dst, this.onEntry?.(e.path, this._dst), null);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
async function Fe(e, t) {
|
|
135
|
+
if (typeof DecompressionStream < "u" && typeof e?.stream == "function") {
|
|
136
|
+
let n = e.stream().pipeThrough(new DecompressionStream("gzip")).getReader();
|
|
137
|
+
for (;;) {
|
|
138
|
+
let { done: e, value: r } = await n.read();
|
|
139
|
+
if (e) break;
|
|
140
|
+
t(r);
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
let n = null, r = new ge((e, r) => {
|
|
145
|
+
e instanceof Error ? n = e : e && e.length && t(e);
|
|
146
|
+
});
|
|
147
|
+
await Ie(e, (e, t) => {
|
|
148
|
+
if (r.push(e, t), n) throw n;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async function Ie(e, t) {
|
|
152
|
+
if (e instanceof Uint8Array) {
|
|
153
|
+
for (let n = 0; n < e.length; n += ye) {
|
|
154
|
+
let r = Math.min(n + ye, e.length);
|
|
155
|
+
t(e.subarray(n, r), r === e.length);
|
|
156
|
+
}
|
|
157
|
+
e.length === 0 && t(e, !0);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
let n = e.size;
|
|
161
|
+
for (let r = 0; r < n; r += ye) {
|
|
162
|
+
let i = Math.min(r + ye, n);
|
|
163
|
+
t(new Uint8Array(await e.slice(r, i).arrayBuffer()), i === n);
|
|
164
|
+
}
|
|
165
|
+
n === 0 && t(new Uint8Array(), !0);
|
|
166
|
+
}
|
|
167
|
+
async function Le(e, t = {}) {
|
|
168
|
+
let { onProgress: n, ...r } = t, i = new Pe(r), a = 0, o = 0;
|
|
169
|
+
return await Fe(e, (e) => {
|
|
170
|
+
i.push(e), a += e.length, n && a >= o && (o = a + (64 << 20), n({
|
|
171
|
+
entries: i.listing.length,
|
|
172
|
+
bytes: a
|
|
173
|
+
}));
|
|
174
|
+
}), i.end(), i.result();
|
|
175
|
+
}
|
|
176
|
+
var Re = 1 << 20;
|
|
177
|
+
async function ze(e, { onProgress: t = null } = {}) {
|
|
178
|
+
let n = e.size, r = [], i = null, a = 0, o = null, s = 0, c = 0, l = async (t, r) => {
|
|
179
|
+
if (i && t >= a && t + r <= a + i.length) return i.subarray(t - a, t - a + r);
|
|
180
|
+
let o = Math.min(n, t + Math.max(r, Re));
|
|
181
|
+
return i = new Uint8Array(await e.slice(t, o).arrayBuffer()), a = t, i.subarray(0, r);
|
|
182
|
+
};
|
|
183
|
+
for (; s + z <= n;) {
|
|
184
|
+
let e = await l(s, z);
|
|
185
|
+
if (Ne(e)) break;
|
|
186
|
+
let { type: n, size: i, name: a } = je(e), u = o ?? a;
|
|
187
|
+
o = null;
|
|
188
|
+
let d = s + z;
|
|
189
|
+
if (Ae(n)) {
|
|
190
|
+
let e = await l(d, i);
|
|
191
|
+
o = n === "L" ? B(e, 0, e.length) : Oe(e);
|
|
192
|
+
} else {
|
|
193
|
+
let e = Me(n, u);
|
|
194
|
+
e && r.push({
|
|
195
|
+
path: e,
|
|
196
|
+
size: i,
|
|
197
|
+
offset: d
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
s = d + ke(i), t && s >= c && (c = s + (256 << 20), t({
|
|
201
|
+
entries: r.length,
|
|
202
|
+
bytes: s
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
return r;
|
|
206
|
+
}
|
|
207
|
+
function Be() {
|
|
208
|
+
let e = new Pe({ retain: () => !1 });
|
|
209
|
+
return {
|
|
210
|
+
push: (t) => e.push(t),
|
|
211
|
+
finish: () => (e.end(), e.listing.filter((e) => e.offset !== void 0))
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
async function Ve(e, t = {}) {
|
|
215
|
+
let { index: n = null, headersOnly: r = !1, onProgress: i = null, ...a } = t, o, s, c, l, u = null;
|
|
216
|
+
if (n || r) {
|
|
217
|
+
u = n?.listing ?? await ze(e, { onProgress: i });
|
|
218
|
+
let { filter: t } = a;
|
|
219
|
+
s = u.map((e) => !t || t(e.path, e.size) ? { ...e } : {
|
|
220
|
+
path: e.path,
|
|
221
|
+
size: e.size
|
|
222
|
+
}), o = Object.create(null), c = 0, l = !1;
|
|
223
|
+
} else {
|
|
224
|
+
let t = new Pe({ ...a });
|
|
225
|
+
await Ie(e, (e) => t.push(e)), t.end(), {entries: o, listing: s, retainedBytes: c, truncated: l} = t.result();
|
|
226
|
+
}
|
|
227
|
+
let d = /* @__PURE__ */ new Map();
|
|
228
|
+
for (let e of s) e.offset !== void 0 && d.set(e.path, e);
|
|
229
|
+
return {
|
|
230
|
+
entries: o,
|
|
231
|
+
listing: s,
|
|
232
|
+
read: async (t) => {
|
|
233
|
+
if (o[t]) return o[t];
|
|
234
|
+
let n = d.get(t);
|
|
235
|
+
return n ? new Uint8Array(await e.slice(n.offset, n.offset + n.size).arrayBuffer()) : null;
|
|
236
|
+
},
|
|
237
|
+
readHead: async (t, n) => {
|
|
238
|
+
if (o[t]) return o[t].subarray(0, n);
|
|
239
|
+
let r = d.get(t);
|
|
240
|
+
return r ? new Uint8Array(await e.slice(r.offset, r.offset + Math.min(r.size, n)).arrayBuffer()) : null;
|
|
241
|
+
},
|
|
242
|
+
retainedBytes: c,
|
|
243
|
+
truncated: l,
|
|
244
|
+
indexed: d.size,
|
|
245
|
+
index: u ? {
|
|
246
|
+
v: 1,
|
|
247
|
+
listing: u
|
|
248
|
+
} : null
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function He(e) {
|
|
252
|
+
let t = (Array.isArray(e) ? e : [e]).filter(Boolean).map((e) => {
|
|
253
|
+
let t = De(e);
|
|
254
|
+
return {
|
|
255
|
+
p: t,
|
|
256
|
+
inside: t + "/"
|
|
257
|
+
};
|
|
258
|
+
});
|
|
259
|
+
return t.length === 0 ? () => !0 : (e) => {
|
|
260
|
+
let n = e.lastIndexOf("/"), r = n < 0 ? "" : e.slice(0, n);
|
|
261
|
+
if (r === "") return !0;
|
|
262
|
+
let i = r.lastIndexOf("/textures"), a = i >= 0 && i === r.length - 9 ? r.slice(0, i) + "/" : null;
|
|
263
|
+
for (let { p: n, inside: i } of t) if (e === n || e.startsWith(i) || i.startsWith(r + "/") || a !== null && i.startsWith(a)) return !0;
|
|
264
|
+
return !1;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function Ue(e) {
|
|
268
|
+
let t = e.filter((e) => e.path.toLowerCase().endsWith(".pbrt")).sort((e, t) => e.path.split("/").length - t.path.split("/").length || e.path.length - t.path.length || (e.path < t.path ? -1 : 1));
|
|
269
|
+
if (!t.length) return {
|
|
270
|
+
root: null,
|
|
271
|
+
elements: []
|
|
272
|
+
};
|
|
273
|
+
let n = t[0].path, r = n.lastIndexOf("/"), i = r < 0 ? "" : n.slice(0, r), a = i ? i + "/" : "", o = /* @__PURE__ */ new Map();
|
|
274
|
+
for (let t of e) {
|
|
275
|
+
if (!t.path.startsWith(a)) continue;
|
|
276
|
+
let e = t.path.slice(a.length), n = e.indexOf("/");
|
|
277
|
+
if (n < 0) continue;
|
|
278
|
+
let r = e.slice(0, n), i = o.get(r);
|
|
279
|
+
i || o.set(r, i = {
|
|
280
|
+
name: r,
|
|
281
|
+
prefix: a + r,
|
|
282
|
+
files: 0,
|
|
283
|
+
bytes: 0,
|
|
284
|
+
scenes: 0
|
|
285
|
+
}), i.files++, i.bytes += t.size, t.path.toLowerCase().endsWith(".pbrt") && i.scenes++;
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
root: i,
|
|
289
|
+
elements: [...o.values()].filter((e) => e.scenes > 0).sort((e, t) => e.bytes - t.bytes)
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/Processor/ArchiveCache.js
|
|
294
|
+
var We = 1, Ge = 3;
|
|
295
|
+
async function Ke(e, t) {
|
|
296
|
+
return `${e}:${u(await l(t))}`;
|
|
297
|
+
}
|
|
298
|
+
async function qe(e, { storage: t, label: n = e.name, onProgress: r = null }) {
|
|
299
|
+
if (!t || typeof DecompressionStream > "u") return null;
|
|
300
|
+
let i = t.area(s.ARCHIVES), o = await Ke("gunzip", e), c = await i.open(o), l = !!c;
|
|
301
|
+
if (!c) {
|
|
302
|
+
let l = await i.create(o, {
|
|
303
|
+
label: n,
|
|
304
|
+
expectedBytes: e.size * Ge
|
|
305
|
+
});
|
|
306
|
+
if (!l) return null;
|
|
307
|
+
let u = Be(), d = new TransformStream({ transform(e, t) {
|
|
308
|
+
u.push(e), t.enqueue(e);
|
|
309
|
+
} });
|
|
310
|
+
try {
|
|
311
|
+
let t = e.stream().pipeThrough(new DecompressionStream("gzip")).pipeThrough(d), n = await l.writeStream("data.tar", t, { onProgress: r });
|
|
312
|
+
await l.writeJSON("index.json", {
|
|
313
|
+
v: We,
|
|
314
|
+
listing: u.finish()
|
|
315
|
+
}), await l.commit({
|
|
316
|
+
compressedBytes: e.size,
|
|
317
|
+
tarBytes: n
|
|
318
|
+
});
|
|
319
|
+
} catch (e) {
|
|
320
|
+
if (await l.abort(), e?.name !== "QuotaExceededError") throw e;
|
|
321
|
+
return t._issue(a.STORAGE_QUOTA_EXCEEDED, `ran out of room unpacking ${n}; reading it in memory instead`, { area: s.ARCHIVES }), null;
|
|
322
|
+
}
|
|
323
|
+
if (c = await i.open(o, { wait: !0 }), !c) return null;
|
|
324
|
+
}
|
|
325
|
+
let u = await c.file("data.tar"), d = await c.json("index.json");
|
|
326
|
+
return !u || d?.v !== We ? (c.release(), null) : {
|
|
327
|
+
file: u,
|
|
328
|
+
index: d,
|
|
329
|
+
release: () => c.release(),
|
|
330
|
+
cached: l
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
async function Je(e, t) {
|
|
334
|
+
if (!t) return null;
|
|
335
|
+
let n = await t.area(s.ARCHIVES).open(await Ke("tarindex", e));
|
|
336
|
+
if (!n) return null;
|
|
337
|
+
try {
|
|
338
|
+
let e = await n.json("index.json");
|
|
339
|
+
return e?.v === We ? e : null;
|
|
340
|
+
} finally {
|
|
341
|
+
n.release();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
async function Ye(e, t, n) {
|
|
345
|
+
if (!t || !n) return !1;
|
|
346
|
+
let r = await t.area(s.ARCHIVES).create(await Ke("tarindex", e), { label: `${e.name} (index)` });
|
|
347
|
+
if (!r) return !1;
|
|
348
|
+
try {
|
|
349
|
+
return await r.writeJSON("index.json", n), await r.commit(), !0;
|
|
350
|
+
} catch {
|
|
351
|
+
return await r.abort(), !1;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
var Xe = ["diffuseTransmissionMap", "diffuseTransmissionColorMap"], Ze = "__rayzeeArchivePath", Qe = "__rayzeeArchiveLoader", $e = 64, et = 32 << 20, tt = 64 << 20, nt = {
|
|
355
|
+
Float32Array,
|
|
356
|
+
Float64Array,
|
|
357
|
+
Int8Array,
|
|
358
|
+
Int16Array,
|
|
359
|
+
Int32Array,
|
|
360
|
+
Uint8Array,
|
|
361
|
+
Uint16Array,
|
|
362
|
+
Uint32Array,
|
|
363
|
+
Uint8ClampedArray
|
|
364
|
+
}, rt = [
|
|
365
|
+
"name",
|
|
366
|
+
"mapping",
|
|
367
|
+
"channel",
|
|
368
|
+
"wrapS",
|
|
369
|
+
"wrapT",
|
|
370
|
+
"magFilter",
|
|
371
|
+
"minFilter",
|
|
372
|
+
"anisotropy",
|
|
373
|
+
"format",
|
|
374
|
+
"type",
|
|
375
|
+
"flipY",
|
|
376
|
+
"generateMipmaps",
|
|
377
|
+
"premultiplyAlpha",
|
|
378
|
+
"unpackAlignment",
|
|
379
|
+
"colorSpace"
|
|
380
|
+
], it = [
|
|
381
|
+
"intensity",
|
|
382
|
+
"distance",
|
|
383
|
+
"decay",
|
|
384
|
+
"angle",
|
|
385
|
+
"penumbra"
|
|
386
|
+
], at = [
|
|
387
|
+
"name",
|
|
388
|
+
"visible",
|
|
389
|
+
"castShadow",
|
|
390
|
+
"receiveShadow",
|
|
391
|
+
"frustumCulled",
|
|
392
|
+
"renderOrder",
|
|
393
|
+
"matrixAutoUpdate"
|
|
394
|
+
], V = class extends Error {
|
|
395
|
+
constructor(e) {
|
|
396
|
+
super(e), this.name = "SceneGraphUnsupported";
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
function ot(e) {
|
|
400
|
+
return e.isInstancedMesh ? "InstancedMesh" : e.isSkinnedMesh || e.isBatchedMesh ? null : e.isMesh ? "Mesh" : e.isPerspectiveCamera ? "PerspectiveCamera" : e.isOrthographicCamera ? "OrthographicCamera" : e.isDirectionalLight ? "DirectionalLight" : e.isPointLight ? "PointLight" : e.isSpotLight ? "SpotLight" : e.isLight || e.isPoints || e.isLine || e.isSprite || e.isLOD ? null : e.isGroup ? "Group" : e.constructor === ie ? "Object3D" : null;
|
|
401
|
+
}
|
|
402
|
+
function st(e, t) {
|
|
403
|
+
try {
|
|
404
|
+
let t = JSON.parse(JSON.stringify(e ?? {}));
|
|
405
|
+
return delete t[Ze], delete t[Qe], t;
|
|
406
|
+
} catch {
|
|
407
|
+
throw new V(`${t}: userData is not plain JSON`);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
var ct = class {
|
|
411
|
+
constructor() {
|
|
412
|
+
this.sections = [], this.length = 0;
|
|
413
|
+
}
|
|
414
|
+
add(e) {
|
|
415
|
+
let t = Math.ceil(this.length / $e) * $e;
|
|
416
|
+
return this.sections.push({
|
|
417
|
+
offset: t,
|
|
418
|
+
array: e
|
|
419
|
+
}), this.length = t + e.byteLength, {
|
|
420
|
+
offset: t,
|
|
421
|
+
byteLength: e.byteLength,
|
|
422
|
+
type: e.constructor.name,
|
|
423
|
+
length: e.length
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
function lt(e, t, n) {
|
|
428
|
+
if (e.isInterleavedBufferAttribute || !ArrayBuffer.isView(e.array)) throw new V(`${n}: interleaved or non-typed attribute`);
|
|
429
|
+
return {
|
|
430
|
+
section: t.add(e.array),
|
|
431
|
+
itemSize: e.itemSize,
|
|
432
|
+
normalized: e.normalized === !0,
|
|
433
|
+
name: e.name ?? ""
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function ut(e, t) {
|
|
437
|
+
let n = `geometry ${e.name || e.uuid}`;
|
|
438
|
+
if (Object.keys(e.morphAttributes ?? {}).length) throw new V(`${n}: morph targets`);
|
|
439
|
+
let r = {};
|
|
440
|
+
for (let [i, a] of Object.entries(e.attributes)) r[i] = lt(a, t, n);
|
|
441
|
+
return {
|
|
442
|
+
uuid: e.uuid,
|
|
443
|
+
name: e.name,
|
|
444
|
+
attributes: r,
|
|
445
|
+
index: e.index ? lt(e.index, t, n) : null,
|
|
446
|
+
groups: e.groups.map((e) => ({ ...e })),
|
|
447
|
+
drawRange: { ...e.drawRange },
|
|
448
|
+
userData: st(e.userData, n)
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function dt(e, t) {
|
|
452
|
+
let n = {
|
|
453
|
+
uuid: e.uuid,
|
|
454
|
+
userData: st(e.userData, `texture ${e.uuid}`)
|
|
455
|
+
};
|
|
456
|
+
for (let t of rt) n[t] = e[t];
|
|
457
|
+
for (let t of [
|
|
458
|
+
"repeat",
|
|
459
|
+
"offset",
|
|
460
|
+
"center"
|
|
461
|
+
]) n[t] = e[t].toArray();
|
|
462
|
+
n.rotation = e.rotation;
|
|
463
|
+
let r = e.userData?.[Ze];
|
|
464
|
+
if (r) n.path = r, n.loader = e.userData.__rayzeeArchiveLoader ?? "image";
|
|
465
|
+
else if (e.isDataTexture && ArrayBuffer.isView(e.image?.data)) n.data = {
|
|
466
|
+
section: t.add(e.image.data),
|
|
467
|
+
width: e.image.width,
|
|
468
|
+
height: e.image.height
|
|
469
|
+
};
|
|
470
|
+
else throw new V(`texture ${e.name || e.uuid}: no archive path and no pixel data to keep`);
|
|
471
|
+
return n;
|
|
472
|
+
}
|
|
473
|
+
function ft(e, t) {
|
|
474
|
+
let n = e.toJSON(t);
|
|
475
|
+
n.exactColors = {};
|
|
476
|
+
for (let [t, r] of Object.entries(e)) r?.isColor && (n.exactColors[t] = [
|
|
477
|
+
r.r,
|
|
478
|
+
r.g,
|
|
479
|
+
r.b
|
|
480
|
+
]);
|
|
481
|
+
e.ior !== void 0 && (n.exactIor = e.ior), e.diffuseTransmission !== void 0 && (n.diffuseTransmission = e.diffuseTransmission);
|
|
482
|
+
for (let t of Xe) e[t]?.isTexture && ((n.engineTextures ??= {})[t] = e[t].uuid);
|
|
483
|
+
return n;
|
|
484
|
+
}
|
|
485
|
+
function pt(e, t) {
|
|
486
|
+
for (let n of Object.values(e)) n?.isTexture && t.set(n.uuid, n);
|
|
487
|
+
}
|
|
488
|
+
function mt(e, { environment: t = null, animations: n = [], stats: r = {} } = {}) {
|
|
489
|
+
let i = new ct(), a = [], o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = (e, t) => {
|
|
490
|
+
let n = ot(e);
|
|
491
|
+
if (!n) throw new V(`${e.type} "${e.name}" cannot be cached`);
|
|
492
|
+
let r = {
|
|
493
|
+
type: n,
|
|
494
|
+
uuid: e.uuid,
|
|
495
|
+
parent: t,
|
|
496
|
+
userData: st(e.userData, `${n} "${e.name}"`)
|
|
497
|
+
};
|
|
498
|
+
for (let t of at) r[t] = e[t];
|
|
499
|
+
if (r.position = e.position.toArray(), r.quaternion = e.quaternion.toArray(), r.scale = e.scale.toArray(), r.layers = e.layers.mask, e.matrixAutoUpdate || (r.matrix = e.matrix.toArray()), e.isMesh) {
|
|
500
|
+
o.set(e.geometry.uuid, e.geometry);
|
|
501
|
+
let t = Array.isArray(e.material) ? e.material : [e.material];
|
|
502
|
+
for (let e of t) s.set(e.uuid, e), pt(e, c);
|
|
503
|
+
r.geometry = e.geometry.uuid, r.material = Array.isArray(e.material) ? t.map((e) => e.uuid) : e.material.uuid;
|
|
504
|
+
}
|
|
505
|
+
if (e.isInstancedMesh && (r.count = e.count, r.instanceMatrix = i.add(e.instanceMatrix.array), r.instanceColor = e.instanceColor ? i.add(e.instanceColor.array) : null), e.isCamera) for (let t of [
|
|
506
|
+
"fov",
|
|
507
|
+
"aspect",
|
|
508
|
+
"near",
|
|
509
|
+
"far",
|
|
510
|
+
"zoom",
|
|
511
|
+
"focus",
|
|
512
|
+
"filmGauge",
|
|
513
|
+
"filmOffset",
|
|
514
|
+
"left",
|
|
515
|
+
"right",
|
|
516
|
+
"top",
|
|
517
|
+
"bottom"
|
|
518
|
+
]) e[t] !== void 0 && (r[t] = e[t]);
|
|
519
|
+
if (e.isLight) {
|
|
520
|
+
r.color = e.color.toArray();
|
|
521
|
+
for (let t of it) e[t] !== void 0 && (r[t] = e[t]);
|
|
522
|
+
e.target && (r.target = e.target.uuid);
|
|
523
|
+
}
|
|
524
|
+
let u = a.push(r) - 1;
|
|
525
|
+
for (let t of e.children) l(t, u);
|
|
526
|
+
};
|
|
527
|
+
l(e, -1), t && c.set(t.uuid, t);
|
|
528
|
+
let u = {
|
|
529
|
+
textures: {},
|
|
530
|
+
images: {}
|
|
531
|
+
};
|
|
532
|
+
for (let e of c.keys()) u.textures[e] = { uuid: e };
|
|
533
|
+
return {
|
|
534
|
+
manifest: {
|
|
535
|
+
v: 2,
|
|
536
|
+
nodes: a,
|
|
537
|
+
geometries: [...o.values()].map((e) => ut(e, i)),
|
|
538
|
+
textures: [...c.values()].map((e) => dt(e, i)),
|
|
539
|
+
materials: [...s.values()].map((e) => ft(e, u)),
|
|
540
|
+
animations: n.map((e) => h.toJSON(e)),
|
|
541
|
+
environment: t ? t.uuid : null,
|
|
542
|
+
stats: r
|
|
543
|
+
},
|
|
544
|
+
sections: i.sections,
|
|
545
|
+
byteLength: i.length
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
async function ht(e, { manifest: t, sections: n }, { release: r = !1 } = {}) {
|
|
549
|
+
for (let t of n) {
|
|
550
|
+
let { offset: n, array: i } = t, a = new Uint8Array(i.buffer, i.byteOffset, i.byteLength);
|
|
551
|
+
for (let t = 0; t < a.length; t += et) await e.write("data.bin", a.subarray(t, Math.min(a.length, t + et)), { at: n + t });
|
|
552
|
+
r && (t.array = null);
|
|
553
|
+
}
|
|
554
|
+
n.length === 0 && await e.write("data.bin", new Uint8Array()), await e.writeJSON("graph.json", t);
|
|
555
|
+
}
|
|
556
|
+
function gt(e) {
|
|
557
|
+
let t = nt[e];
|
|
558
|
+
if (!t) throw Error(`scene graph: unknown array type ${e}`);
|
|
559
|
+
return t;
|
|
560
|
+
}
|
|
561
|
+
async function _t(e, t) {
|
|
562
|
+
let n = /* @__PURE__ */ new Map(), r = [...t].sort((e, t) => e.offset - t.offset), i = null, a = 0;
|
|
563
|
+
for (let t of r) {
|
|
564
|
+
let { offset: r, byteLength: o, type: s } = t, c = gt(s), l = r + o;
|
|
565
|
+
if (o > tt) {
|
|
566
|
+
n.set(r, new c(await e.slice(r, l).arrayBuffer()));
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
(!i || r < a || l > a + i.byteLength) && (a = r, i = await e.slice(r, Math.min(e.size, r + tt)).arrayBuffer()), n.set(r, new c(i.slice(r - a, l - a)));
|
|
570
|
+
}
|
|
571
|
+
return n;
|
|
572
|
+
}
|
|
573
|
+
function vt(e) {
|
|
574
|
+
let t = [];
|
|
575
|
+
for (let n of e.nodes) n.instanceMatrix && t.push(n.instanceMatrix), n.instanceColor && t.push(n.instanceColor);
|
|
576
|
+
for (let n of e.geometries) {
|
|
577
|
+
for (let e of Object.values(n.attributes)) t.push(e.section);
|
|
578
|
+
n.index && t.push(n.index.section);
|
|
579
|
+
}
|
|
580
|
+
for (let n of e.textures) n.data && t.push(n.data.section);
|
|
581
|
+
return t;
|
|
582
|
+
}
|
|
583
|
+
function yt(e, t) {
|
|
584
|
+
let n = new _(e.get(t.section.offset), t.itemSize, t.normalized);
|
|
585
|
+
return n.name = t.name, n;
|
|
586
|
+
}
|
|
587
|
+
function bt(e, t) {
|
|
588
|
+
for (let n of rt) t[n] !== void 0 && (e[n] = t[n]);
|
|
589
|
+
e.repeat.fromArray(t.repeat), e.offset.fromArray(t.offset), e.center.fromArray(t.center), e.rotation = t.rotation, e.uuid = t.uuid, Object.assign(e.userData, t.userData), e.needsUpdate = !0;
|
|
590
|
+
}
|
|
591
|
+
async function xt(e, t, { loadTexture: n }) {
|
|
592
|
+
if (e?.v !== 2) throw Error("scene graph: unknown format");
|
|
593
|
+
let r = await _t(t, vt(e)), i = (e) => r.get(e.offset), a = {};
|
|
594
|
+
for (let t of e.textures) {
|
|
595
|
+
let e;
|
|
596
|
+
if (t.path) {
|
|
597
|
+
if (e = await n(t.path, t.loader), !e) throw Error(`scene graph: "${t.path}" is missing from the archive`);
|
|
598
|
+
e.userData[Ze] = t.path, e.userData[Qe] = t.loader;
|
|
599
|
+
} else e = new b(i(t.data.section), t.data.width, t.data.height);
|
|
600
|
+
bt(e, t), a[t.uuid] = e;
|
|
601
|
+
}
|
|
602
|
+
let o = new M().setTextures(a), s = {};
|
|
603
|
+
for (let t of e.materials) {
|
|
604
|
+
let e = o.parse(t);
|
|
605
|
+
for (let [n, r] of Object.entries(t.exactColors ?? {})) n === "diffuseTransmissionColor" && (e[n] = new y()), e[n]?.setRGB(r[0], r[1], r[2]);
|
|
606
|
+
t.exactIor !== void 0 && (e.ior = t.exactIor), t.diffuseTransmission !== void 0 && (e.diffuseTransmission = t.diffuseTransmission);
|
|
607
|
+
for (let [n, r] of Object.entries(t.engineTextures ?? {})) a[r] && (e[n] = a[r]);
|
|
608
|
+
s[t.uuid] = e;
|
|
609
|
+
}
|
|
610
|
+
let c = {};
|
|
611
|
+
for (let t of e.geometries) {
|
|
612
|
+
let e = new v();
|
|
613
|
+
e.uuid = t.uuid, e.name = t.name;
|
|
614
|
+
for (let [n, i] of Object.entries(t.attributes)) e.setAttribute(n, yt(r, i));
|
|
615
|
+
t.index && e.setIndex(yt(r, t.index));
|
|
616
|
+
for (let n of t.groups) e.addGroup(n.start, n.count, n.materialIndex);
|
|
617
|
+
e.setDrawRange(t.drawRange.start, t.drawRange.count), e.userData = t.userData, c[t.uuid] = e;
|
|
618
|
+
}
|
|
619
|
+
let l = [];
|
|
620
|
+
for (let t of e.nodes) {
|
|
621
|
+
let e = Array.isArray(t.material) ? t.material.map((e) => s[e]) : s[t.material], n;
|
|
622
|
+
switch (t.type) {
|
|
623
|
+
case "InstancedMesh":
|
|
624
|
+
n = new k(c[t.geometry], e, 1), n.instanceMatrix = new O(i(t.instanceMatrix), 16), n.count = t.count, t.instanceColor && (n.instanceColor = new O(i(t.instanceColor), 3));
|
|
625
|
+
break;
|
|
626
|
+
case "Mesh":
|
|
627
|
+
n = new ee(c[t.geometry], e);
|
|
628
|
+
break;
|
|
629
|
+
case "PerspectiveCamera":
|
|
630
|
+
n = new oe();
|
|
631
|
+
break;
|
|
632
|
+
case "OrthographicCamera":
|
|
633
|
+
n = new ae();
|
|
634
|
+
break;
|
|
635
|
+
case "Group":
|
|
636
|
+
n = new D();
|
|
637
|
+
break;
|
|
638
|
+
case "DirectionalLight":
|
|
639
|
+
n = new x();
|
|
640
|
+
break;
|
|
641
|
+
case "PointLight":
|
|
642
|
+
n = new se();
|
|
643
|
+
break;
|
|
644
|
+
case "SpotLight":
|
|
645
|
+
n = new fe();
|
|
646
|
+
break;
|
|
647
|
+
default: n = new ie();
|
|
648
|
+
}
|
|
649
|
+
n.uuid = t.uuid;
|
|
650
|
+
for (let e of at) n[e] = t[e];
|
|
651
|
+
if (n.position.fromArray(t.position), n.quaternion.fromArray(t.quaternion), n.scale.fromArray(t.scale), n.layers.mask = t.layers, n.userData = t.userData, t.matrix && n.matrix.fromArray(t.matrix), n.isCamera) {
|
|
652
|
+
for (let e of [
|
|
653
|
+
"fov",
|
|
654
|
+
"aspect",
|
|
655
|
+
"near",
|
|
656
|
+
"far",
|
|
657
|
+
"zoom",
|
|
658
|
+
"focus",
|
|
659
|
+
"filmGauge",
|
|
660
|
+
"filmOffset",
|
|
661
|
+
"left",
|
|
662
|
+
"right",
|
|
663
|
+
"top",
|
|
664
|
+
"bottom"
|
|
665
|
+
]) t[e] !== void 0 && (n[e] = t[e]);
|
|
666
|
+
n.updateProjectionMatrix();
|
|
667
|
+
}
|
|
668
|
+
if (n.isLight) {
|
|
669
|
+
n.color.fromArray(t.color);
|
|
670
|
+
for (let e of it) t[e] !== void 0 && (n[e] = t[e]);
|
|
671
|
+
}
|
|
672
|
+
l.push(n), t.parent >= 0 && l[t.parent].add(n);
|
|
673
|
+
}
|
|
674
|
+
let u = new Map(l.map((e) => [e.uuid, e]));
|
|
675
|
+
return e.nodes.forEach((e, t) => {
|
|
676
|
+
e.target && u.has(e.target) && (l[t].target = u.get(e.target));
|
|
677
|
+
}), {
|
|
678
|
+
root: l[0],
|
|
679
|
+
environment: e.environment ? a[e.environment] : null,
|
|
680
|
+
animations: e.animations.map((e) => h.parse(e)),
|
|
681
|
+
stats: e.stats
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/Processor/PBRT/buffers.js
|
|
686
|
+
var St = (e) => e.byteOffset === 0 && e.byteLength === e.buffer.byteLength && typeof e.buffer.transfer == "function" && !(typeof SharedArrayBuffer < "u" && e.buffer instanceof SharedArrayBuffer);
|
|
687
|
+
function H(e) {
|
|
688
|
+
e && St(e) && e.buffer.transfer(0);
|
|
689
|
+
}
|
|
690
|
+
function U(e, t) {
|
|
691
|
+
let n = e.constructor;
|
|
692
|
+
if (St(e)) return new n(e.buffer.transfer(t * n.BYTES_PER_ELEMENT));
|
|
693
|
+
let r = new n(t);
|
|
694
|
+
return r.set(t < e.length ? e.subarray(0, t) : e), r;
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region src/Processor/PBRT/PBRTTokenizer.js
|
|
698
|
+
var W = {
|
|
699
|
+
STRING: "string",
|
|
700
|
+
NUMBER: "number",
|
|
701
|
+
WORD: "word",
|
|
702
|
+
LBRACKET: "[",
|
|
703
|
+
RBRACKET: "]"
|
|
704
|
+
}, Ct = 9, wt = 10, Tt = 12, Et = 13, Dt = 32, Ot = 34, kt = 35, At = 43, jt = 45, Mt = 46, Nt = 48, Pt = 57, Ft = 91, It = 93, Lt = 69, Rt = 101, zt = (e) => e === Dt || e === Ct || e === wt || e === Et || e === Tt, G = (e) => e >= Nt && e <= Pt, Bt = 15, Vt = 22, Ht = (() => {
|
|
705
|
+
let e = new Float64Array(Vt + 1);
|
|
706
|
+
for (let t = 0; t < e.length; t++) e[t] = 10 ** t;
|
|
707
|
+
return e;
|
|
708
|
+
})(), Ut = new TextDecoder();
|
|
709
|
+
function K(e, t, n) {
|
|
710
|
+
if (n - t === 0) return "";
|
|
711
|
+
let r = !0;
|
|
712
|
+
for (let i = t; i < n; i++) if (e[i] > 127) {
|
|
713
|
+
r = !1;
|
|
714
|
+
break;
|
|
715
|
+
}
|
|
716
|
+
if (!r) return Ut.decode(e.subarray(t, n));
|
|
717
|
+
let i = "";
|
|
718
|
+
for (let r = t; r < n; r++) i += String.fromCharCode(e[r]);
|
|
719
|
+
return i;
|
|
720
|
+
}
|
|
721
|
+
var Wt = class {
|
|
722
|
+
constructor(e) {
|
|
723
|
+
this.bytes = typeof e == "string" ? new TextEncoder().encode(e) : e, this.i = 0, this.n = this.bytes.length, this._ahead = null;
|
|
724
|
+
}
|
|
725
|
+
peek() {
|
|
726
|
+
return this._ahead === null && (this._ahead = this._scan()), this._ahead;
|
|
727
|
+
}
|
|
728
|
+
next() {
|
|
729
|
+
let e = this.peek();
|
|
730
|
+
return this._ahead = null, e;
|
|
731
|
+
}
|
|
732
|
+
_scan() {
|
|
733
|
+
let e = this.bytes, t = this.i, n = this.n;
|
|
734
|
+
for (;;) {
|
|
735
|
+
for (; t < n && zt(e[t]);) t++;
|
|
736
|
+
if (t < n && e[t] === kt) {
|
|
737
|
+
for (; t < n && e[t] !== wt;) t++;
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
break;
|
|
741
|
+
}
|
|
742
|
+
if (t >= n) return this.i = t, null;
|
|
743
|
+
let r = e[t];
|
|
744
|
+
if (r === Ft) return this.i = t + 1, { type: W.LBRACKET };
|
|
745
|
+
if (r === It) return this.i = t + 1, { type: W.RBRACKET };
|
|
746
|
+
if (r === Ot) {
|
|
747
|
+
let r = ++t;
|
|
748
|
+
for (; t < n && e[t] !== Ot;) t++;
|
|
749
|
+
if (t >= n) throw Error("PBRT tokenizer: unterminated string literal");
|
|
750
|
+
return this.i = t + 1, {
|
|
751
|
+
type: W.STRING,
|
|
752
|
+
value: K(e, r, t)
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
if (G(r) || r === Mt && G(e[t + 1]) || (r === jt || r === At) && (G(e[t + 1]) || e[t + 1] === Mt && G(e[t + 2]))) return this._scanNumber(t);
|
|
756
|
+
let i = t;
|
|
757
|
+
for (; t < n;) {
|
|
758
|
+
let n = e[t];
|
|
759
|
+
if (zt(n) || n === Ot || n === Ft || n === It || n === kt) break;
|
|
760
|
+
t++;
|
|
761
|
+
}
|
|
762
|
+
return this.i = t, {
|
|
763
|
+
type: W.WORD,
|
|
764
|
+
value: K(e, i, t)
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
_scanNumber(e) {
|
|
768
|
+
let t = this.bytes, n = this.n, r = e, i = !1;
|
|
769
|
+
t[r] === jt ? (i = !0, r++) : t[r] === At && r++;
|
|
770
|
+
let a = 0, o = 0, s = 0;
|
|
771
|
+
for (; r < n && G(t[r]);) a = a * 10 + (t[r] - Nt), o++, r++;
|
|
772
|
+
if (r < n && t[r] === Mt) for (r++; r < n && G(t[r]);) a = a * 10 + (t[r] - Nt), o++, s++, r++;
|
|
773
|
+
let c = 0;
|
|
774
|
+
if (r < n && (t[r] === Rt || t[r] === Lt)) {
|
|
775
|
+
let e = r + 1, i = !1;
|
|
776
|
+
if (e < n && (t[e] === jt || t[e] === At) && (i = t[e] === jt, e++), e < n && G(t[e])) {
|
|
777
|
+
let a = 0;
|
|
778
|
+
for (; e < n && G(t[e]);) a = a * 10 + (t[e] - Nt), e++;
|
|
779
|
+
c = i ? -a : a, r = e;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
if (this.i = r, o === 0) throw Error(`PBRT tokenizer: invalid number "${K(t, e, r)}"`);
|
|
783
|
+
let l = c - s;
|
|
784
|
+
if (!(o <= Bt && l >= -Vt && l <= Vt)) {
|
|
785
|
+
let n = Number(K(t, e, r));
|
|
786
|
+
if (Number.isNaN(n)) throw Error(`PBRT tokenizer: invalid number "${K(t, e, r)}"`);
|
|
787
|
+
return {
|
|
788
|
+
type: W.NUMBER,
|
|
789
|
+
value: n
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
let u = l === 0 ? a : l > 0 ? a * Ht[l] : a / Ht[-l];
|
|
793
|
+
return i && (u = -u), {
|
|
794
|
+
type: W.NUMBER,
|
|
795
|
+
value: u
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region src/Processor/PBRT/PBRTMath.js
|
|
801
|
+
function Gt() {
|
|
802
|
+
return [
|
|
803
|
+
1,
|
|
804
|
+
0,
|
|
805
|
+
0,
|
|
806
|
+
0,
|
|
807
|
+
0,
|
|
808
|
+
1,
|
|
809
|
+
0,
|
|
810
|
+
0,
|
|
811
|
+
0,
|
|
812
|
+
0,
|
|
813
|
+
1,
|
|
814
|
+
0,
|
|
815
|
+
0,
|
|
816
|
+
0,
|
|
817
|
+
0,
|
|
818
|
+
1
|
|
819
|
+
];
|
|
820
|
+
}
|
|
821
|
+
function Kt(e) {
|
|
822
|
+
return e[0] * (e[5] * e[10] - e[6] * e[9]) - e[4] * (e[1] * e[10] - e[2] * e[9]) + e[8] * (e[1] * e[6] - e[2] * e[5]);
|
|
823
|
+
}
|
|
824
|
+
function qt(e, t, n, r) {
|
|
825
|
+
for (let i = 0; i < 4; i++) {
|
|
826
|
+
let a = r[i * 4], o = r[i * 4 + 1], s = r[i * 4 + 2], c = r[i * 4 + 3];
|
|
827
|
+
for (let r = 0; r < 4; r++) e[i * 4 + r] = t[n + r] * a + t[n + 4 + r] * o + t[n + 8 + r] * s + t[n + 12 + r] * c;
|
|
828
|
+
}
|
|
829
|
+
return e;
|
|
830
|
+
}
|
|
831
|
+
function q(e, t) {
|
|
832
|
+
let n = e[0], r = e[1], i = e[2], a = e[3], o = e[4], s = e[5], c = e[6], l = e[7], u = e[8], d = e[9], f = e[10], p = e[11], m = e[12], h = e[13], g = e[14], _ = e[15], v = t[0], y = t[1], b = t[2], x = t[3], S = t[4], C = t[5], w = t[6], T = t[7], E = t[8], D = t[9], O = t[10], k = t[11], A = t[12], j = t[13], M = t[14], N = t[15];
|
|
833
|
+
return [
|
|
834
|
+
n * v + o * y + u * b + m * x,
|
|
835
|
+
r * v + s * y + d * b + h * x,
|
|
836
|
+
i * v + c * y + f * b + g * x,
|
|
837
|
+
a * v + l * y + p * b + _ * x,
|
|
838
|
+
n * S + o * C + u * w + m * T,
|
|
839
|
+
r * S + s * C + d * w + h * T,
|
|
840
|
+
i * S + c * C + f * w + g * T,
|
|
841
|
+
a * S + l * C + p * w + _ * T,
|
|
842
|
+
n * E + o * D + u * O + m * k,
|
|
843
|
+
r * E + s * D + d * O + h * k,
|
|
844
|
+
i * E + c * D + f * O + g * k,
|
|
845
|
+
a * E + l * D + p * O + _ * k,
|
|
846
|
+
n * A + o * j + u * M + m * N,
|
|
847
|
+
r * A + s * j + d * M + h * N,
|
|
848
|
+
i * A + c * j + f * M + g * N,
|
|
849
|
+
a * A + l * j + p * M + _ * N
|
|
850
|
+
];
|
|
851
|
+
}
|
|
852
|
+
function Jt(e, t, n) {
|
|
853
|
+
return [
|
|
854
|
+
1,
|
|
855
|
+
0,
|
|
856
|
+
0,
|
|
857
|
+
0,
|
|
858
|
+
0,
|
|
859
|
+
1,
|
|
860
|
+
0,
|
|
861
|
+
0,
|
|
862
|
+
0,
|
|
863
|
+
0,
|
|
864
|
+
1,
|
|
865
|
+
0,
|
|
866
|
+
e,
|
|
867
|
+
t,
|
|
868
|
+
n,
|
|
869
|
+
1
|
|
870
|
+
];
|
|
871
|
+
}
|
|
872
|
+
function Yt(e, t, n) {
|
|
873
|
+
return [
|
|
874
|
+
e,
|
|
875
|
+
0,
|
|
876
|
+
0,
|
|
877
|
+
0,
|
|
878
|
+
0,
|
|
879
|
+
t,
|
|
880
|
+
0,
|
|
881
|
+
0,
|
|
882
|
+
0,
|
|
883
|
+
0,
|
|
884
|
+
n,
|
|
885
|
+
0,
|
|
886
|
+
0,
|
|
887
|
+
0,
|
|
888
|
+
0,
|
|
889
|
+
1
|
|
890
|
+
];
|
|
891
|
+
}
|
|
892
|
+
function Xt(e, t, n, r) {
|
|
893
|
+
let i = Math.hypot(t, n, r) || 1;
|
|
894
|
+
t /= i, n /= i, r /= i;
|
|
895
|
+
let a = e * Math.PI / 180, o = Math.cos(a), s = Math.sin(a), c = 1 - o, l = c * t * t + o, u = c * t * n - s * r, d = c * t * r + s * n, f = c * t * n + s * r, p = c * n * n + o, m = c * n * r - s * t;
|
|
896
|
+
return [
|
|
897
|
+
l,
|
|
898
|
+
f,
|
|
899
|
+
c * t * r - s * n,
|
|
900
|
+
0,
|
|
901
|
+
u,
|
|
902
|
+
p,
|
|
903
|
+
c * n * r + s * t,
|
|
904
|
+
0,
|
|
905
|
+
d,
|
|
906
|
+
m,
|
|
907
|
+
c * r * r + o,
|
|
908
|
+
0,
|
|
909
|
+
0,
|
|
910
|
+
0,
|
|
911
|
+
0,
|
|
912
|
+
1
|
|
913
|
+
];
|
|
914
|
+
}
|
|
915
|
+
function Zt(e, t) {
|
|
916
|
+
return [
|
|
917
|
+
e[0] - t[0],
|
|
918
|
+
e[1] - t[1],
|
|
919
|
+
e[2] - t[2]
|
|
920
|
+
];
|
|
921
|
+
}
|
|
922
|
+
function Qt(e, t) {
|
|
923
|
+
return [
|
|
924
|
+
e[1] * t[2] - e[2] * t[1],
|
|
925
|
+
e[2] * t[0] - e[0] * t[2],
|
|
926
|
+
e[0] * t[1] - e[1] * t[0]
|
|
927
|
+
];
|
|
928
|
+
}
|
|
929
|
+
function $t(e) {
|
|
930
|
+
let t = Math.hypot(e[0], e[1], e[2]) || 1;
|
|
931
|
+
return [
|
|
932
|
+
e[0] / t,
|
|
933
|
+
e[1] / t,
|
|
934
|
+
e[2] / t
|
|
935
|
+
];
|
|
936
|
+
}
|
|
937
|
+
function en(e, t, n) {
|
|
938
|
+
let r = $t(Zt(t, e)), i = $t(Qt($t(n), r)), a = Qt(r, i);
|
|
939
|
+
return [
|
|
940
|
+
i[0],
|
|
941
|
+
i[1],
|
|
942
|
+
i[2],
|
|
943
|
+
0,
|
|
944
|
+
a[0],
|
|
945
|
+
a[1],
|
|
946
|
+
a[2],
|
|
947
|
+
0,
|
|
948
|
+
r[0],
|
|
949
|
+
r[1],
|
|
950
|
+
r[2],
|
|
951
|
+
0,
|
|
952
|
+
e[0],
|
|
953
|
+
e[1],
|
|
954
|
+
e[2],
|
|
955
|
+
1
|
|
956
|
+
];
|
|
957
|
+
}
|
|
958
|
+
function J(e) {
|
|
959
|
+
let t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = e[9], d = e[10], f = e[11], p = e[12], m = e[13], h = e[14], g = e[15], _ = u * h * c - m * d * c + m * s * f - o * h * f - u * s * g + o * d * g, v = p * d * c - l * h * c - p * s * f + a * h * f + l * s * g - a * d * g, y = l * m * c - p * u * c + p * o * f - a * m * f - l * o * g + a * u * g, b = p * u * s - l * m * s - p * o * d + a * m * d + l * o * h - a * u * h, x = t * _ + n * v + r * y + i * b;
|
|
960
|
+
if (x === 0) return Gt();
|
|
961
|
+
let S = 1 / x;
|
|
962
|
+
return [
|
|
963
|
+
_ * S,
|
|
964
|
+
(m * d * i - u * h * i - m * r * f + n * h * f + u * r * g - n * d * g) * S,
|
|
965
|
+
(o * h * i - m * s * i + m * r * c - n * h * c - o * r * g + n * s * g) * S,
|
|
966
|
+
(u * s * i - o * d * i - u * r * c + n * d * c + o * r * f - n * s * f) * S,
|
|
967
|
+
v * S,
|
|
968
|
+
(l * h * i - p * d * i + p * r * f - t * h * f - l * r * g + t * d * g) * S,
|
|
969
|
+
(p * s * i - a * h * i - p * r * c + t * h * c + a * r * g - t * s * g) * S,
|
|
970
|
+
(a * d * i - l * s * i + l * r * c - t * d * c - a * r * f + t * s * f) * S,
|
|
971
|
+
y * S,
|
|
972
|
+
(p * u * i - l * m * i - p * n * f + t * m * f + l * n * g - t * u * g) * S,
|
|
973
|
+
(a * m * i - p * o * i + p * n * c - t * m * c - a * n * g + t * o * g) * S,
|
|
974
|
+
(l * o * i - a * u * i - l * n * c + t * u * c + a * n * f - t * o * f) * S,
|
|
975
|
+
b * S,
|
|
976
|
+
(l * m * r - p * u * r + p * n * d - t * m * d - l * n * h + t * u * h) * S,
|
|
977
|
+
(p * o * r - a * m * r - p * n * s + t * m * s + a * n * h - t * o * h) * S,
|
|
978
|
+
(a * u * r - l * o * r + l * n * s - t * u * s - a * n * d + t * o * d) * S
|
|
979
|
+
];
|
|
980
|
+
}
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/Processor/PBRT/PBRTParser.js
|
|
983
|
+
var tn = 8, nn = 1, rn = 2, Y = 3, an = new Set([
|
|
984
|
+
"Identity",
|
|
985
|
+
"Transform",
|
|
986
|
+
"CoordinateSystem",
|
|
987
|
+
"CoordSysTransform",
|
|
988
|
+
"ActiveTransform",
|
|
989
|
+
"TransformTimes",
|
|
990
|
+
"Camera",
|
|
991
|
+
"Film",
|
|
992
|
+
"WorldBegin",
|
|
993
|
+
"MakeNamedMaterial",
|
|
994
|
+
"Texture",
|
|
995
|
+
"MakeNamedMedium",
|
|
996
|
+
"LightSource",
|
|
997
|
+
"AreaLightSource",
|
|
998
|
+
"ObjectBegin",
|
|
999
|
+
"ObjectEnd",
|
|
1000
|
+
"ObjectInstance"
|
|
1001
|
+
]);
|
|
1002
|
+
function on(e, t) {
|
|
1003
|
+
if (e === t) return !0;
|
|
1004
|
+
for (let n = 0; n < 16; n++) if (e[n] !== t[n]) return !1;
|
|
1005
|
+
return !0;
|
|
1006
|
+
}
|
|
1007
|
+
var sn = {
|
|
1008
|
+
integer: Int32Array,
|
|
1009
|
+
point3: Float32Array,
|
|
1010
|
+
point2: Float32Array,
|
|
1011
|
+
vector3: Float32Array,
|
|
1012
|
+
vector2: Float32Array,
|
|
1013
|
+
vector: Float32Array,
|
|
1014
|
+
normal: Float32Array,
|
|
1015
|
+
rgb: Float32Array
|
|
1016
|
+
}, cn = class {
|
|
1017
|
+
constructor(e = {}) {
|
|
1018
|
+
this.releaseInclude = e.releaseInclude || null, this.resolveInclude = e.resolveInclude || (() => {
|
|
1019
|
+
throw Error("PBRTParser: Include used but no resolveInclude provided");
|
|
1020
|
+
}), this.maxPlacements = e.maxPlacements ?? Infinity, this.instanceIncludes = e.instanceIncludes !== !1, this._includes = /* @__PURE__ */ new Map(), this._stateIds = /* @__PURE__ */ new WeakMap(), this._nextStateId = 1, this._effects = 0, this._movedShapes = !1, this.ir = {
|
|
1021
|
+
film: null,
|
|
1022
|
+
camera: null,
|
|
1023
|
+
namedMaterials: /* @__PURE__ */ new Map(),
|
|
1024
|
+
namedTextures: /* @__PURE__ */ new Map(),
|
|
1025
|
+
shapes: [],
|
|
1026
|
+
lights: [],
|
|
1027
|
+
instances: /* @__PURE__ */ new Map(),
|
|
1028
|
+
instanceCount: 0,
|
|
1029
|
+
skippedInstances: 0,
|
|
1030
|
+
objects: /* @__PURE__ */ new Map(),
|
|
1031
|
+
media: /* @__PURE__ */ new Map(),
|
|
1032
|
+
transformTimes: {
|
|
1033
|
+
start: 0,
|
|
1034
|
+
end: 1
|
|
1035
|
+
},
|
|
1036
|
+
hasMotion: !1,
|
|
1037
|
+
warnings: []
|
|
1038
|
+
}, this.ctm = Gt(), this.ctmEnd = null, this.activeTransform = Y, this._ctmSource = null, this._ctmValue = null, this.state = {
|
|
1039
|
+
material: null,
|
|
1040
|
+
areaLight: null,
|
|
1041
|
+
reverseOrientation: !1,
|
|
1042
|
+
interior: null
|
|
1043
|
+
}, this.attributeStack = [], this.transformStack = [], this.coordSystems = /* @__PURE__ */ new Map(), this.currentObject = null, this.dirStack = [""], this.stream = null, this._warnedUnknown = /* @__PURE__ */ new Set();
|
|
1044
|
+
}
|
|
1045
|
+
async parse(e, t = "") {
|
|
1046
|
+
this.dirStack = [t], await this._run(new Wt(e)), this._movedShapes && (this.ir.shapes = this.ir.shapes.filter(Boolean));
|
|
1047
|
+
for (let e of this.ir.instances.values()) e.matrices = U(e.matrices, e.count * 16), e.matricesEnd &&= U(e.matricesEnd, e.count * 16);
|
|
1048
|
+
return this.ir;
|
|
1049
|
+
}
|
|
1050
|
+
_addInstance(e, t = this.ctm) {
|
|
1051
|
+
if (this.ir.instanceCount >= this.maxPlacements) {
|
|
1052
|
+
this.ir.skippedInstances++;
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
let n = this.ir.instances.get(e);
|
|
1056
|
+
n || this.ir.instances.set(e, n = {
|
|
1057
|
+
name: e,
|
|
1058
|
+
count: 0,
|
|
1059
|
+
matrices: new Float32Array(512),
|
|
1060
|
+
matricesEnd: null
|
|
1061
|
+
});
|
|
1062
|
+
let r = (n.count + 1) * 16;
|
|
1063
|
+
if (r > n.matrices.length) {
|
|
1064
|
+
let e = Math.max(r, n.matrices.length * 2);
|
|
1065
|
+
n.matrices = U(n.matrices, e), n.matricesEnd &&= U(n.matricesEnd, e);
|
|
1066
|
+
}
|
|
1067
|
+
let i = n.count * 16;
|
|
1068
|
+
for (let e = 0; e < 16; e++) n.matrices[i + e] = t[e];
|
|
1069
|
+
let a = this._ctmEndSnapshot();
|
|
1070
|
+
if (a && !n.matricesEnd && (n.matricesEnd = n.matrices.slice()), n.matricesEnd) {
|
|
1071
|
+
let e = a || t;
|
|
1072
|
+
for (let t = 0; t < 16; t++) n.matricesEnd[i + t] = e[t];
|
|
1073
|
+
}
|
|
1074
|
+
n.count++, this.ir.instanceCount++;
|
|
1075
|
+
}
|
|
1076
|
+
_ctmSnapshot() {
|
|
1077
|
+
return this._ctmSource !== this.ctm && (this._ctmSource = this.ctm, this._ctmValue = this.ctm.slice()), this._ctmValue;
|
|
1078
|
+
}
|
|
1079
|
+
_ctmEndSnapshot() {
|
|
1080
|
+
return this.ctmEnd === null || on(this.ctmEnd, this.ctm) ? null : (this.ir.hasMotion = !0, this.ctmEnd.slice());
|
|
1081
|
+
}
|
|
1082
|
+
_concat(e) {
|
|
1083
|
+
if (this.activeTransform === Y && this.ctmEnd === null) {
|
|
1084
|
+
this.ctm = q(this.ctm, e);
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
let t = this.ctmEnd ?? this.ctm;
|
|
1088
|
+
this.ctmEnd = this.activeTransform & rn ? q(t, e) : t, this.activeTransform & nn && (this.ctm = q(this.ctm, e));
|
|
1089
|
+
}
|
|
1090
|
+
_setCTM(e) {
|
|
1091
|
+
if (this.activeTransform === Y) {
|
|
1092
|
+
this.ctm = e, this.ctmEnd = null;
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
let t = this.ctmEnd ?? this.ctm;
|
|
1096
|
+
this.ctmEnd = this.activeTransform & rn ? e : t, this.activeTransform & nn && (this.ctm = e);
|
|
1097
|
+
}
|
|
1098
|
+
_pushGraphicsState() {
|
|
1099
|
+
this.attributeStack.push({
|
|
1100
|
+
ctm: this.ctm,
|
|
1101
|
+
ctmEnd: this.ctmEnd,
|
|
1102
|
+
activeTransform: this.activeTransform,
|
|
1103
|
+
material: this.state.material,
|
|
1104
|
+
areaLight: this.state.areaLight,
|
|
1105
|
+
reverseOrientation: this.state.reverseOrientation,
|
|
1106
|
+
interior: this.state.interior
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
_popGraphicsState() {
|
|
1110
|
+
let e = this.attributeStack.pop();
|
|
1111
|
+
e && (this.ctm = e.ctm, this.ctmEnd = e.ctmEnd, this.activeTransform = e.activeTransform, this.state = {
|
|
1112
|
+
material: e.material,
|
|
1113
|
+
areaLight: e.areaLight,
|
|
1114
|
+
reverseOrientation: e.reverseOrientation,
|
|
1115
|
+
interior: e.interior
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
_peek() {
|
|
1119
|
+
return this.stream.peek();
|
|
1120
|
+
}
|
|
1121
|
+
_next() {
|
|
1122
|
+
return this.stream.next();
|
|
1123
|
+
}
|
|
1124
|
+
_expectNumber(e) {
|
|
1125
|
+
let t = this._next();
|
|
1126
|
+
if (!t || t.type !== W.NUMBER) throw Error(`PBRT parser: expected number for ${e}, got ${t ? t.value : "EOF"}`);
|
|
1127
|
+
return t.value;
|
|
1128
|
+
}
|
|
1129
|
+
_expectString(e) {
|
|
1130
|
+
let t = this._next();
|
|
1131
|
+
if (!t || t.type !== W.STRING) throw Error(`PBRT parser: expected string for ${e}, got ${t ? t.value : "EOF"}`);
|
|
1132
|
+
return t.value;
|
|
1133
|
+
}
|
|
1134
|
+
_readNumbers(e) {
|
|
1135
|
+
let t = [];
|
|
1136
|
+
for (let n = 0; n < e; n++) t.push(this._expectNumber("matrix/transform"));
|
|
1137
|
+
return t;
|
|
1138
|
+
}
|
|
1139
|
+
_readBracketedOrBareNumbers(e) {
|
|
1140
|
+
if (this._peek() && this._peek().type === W.LBRACKET) {
|
|
1141
|
+
this._next();
|
|
1142
|
+
let e = [];
|
|
1143
|
+
for (; this._peek() && this._peek().type !== W.RBRACKET;) e.push(this._expectNumber("transform element"));
|
|
1144
|
+
return this._next(), e;
|
|
1145
|
+
}
|
|
1146
|
+
return this._readNumbers(e);
|
|
1147
|
+
}
|
|
1148
|
+
_parseParams() {
|
|
1149
|
+
let e = {};
|
|
1150
|
+
for (; this._peek() && this._peek().type === W.STRING;) {
|
|
1151
|
+
let t = this._next().value.trim().split(/\s+/), n = t[0], r = t[1] === void 0 ? t[0] : t[1];
|
|
1152
|
+
e[r] = {
|
|
1153
|
+
type: n,
|
|
1154
|
+
value: this._parseParamValue(n)
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
return e;
|
|
1158
|
+
}
|
|
1159
|
+
_parseParamValue(e) {
|
|
1160
|
+
let t = this._peek() && this._peek().type === W.LBRACKET;
|
|
1161
|
+
t && this._next();
|
|
1162
|
+
let n = () => {
|
|
1163
|
+
let e = this._peek();
|
|
1164
|
+
return t ? e && e.type !== W.RBRACKET : !1;
|
|
1165
|
+
};
|
|
1166
|
+
if (!t) return [this._coerceValueToken(this._next())];
|
|
1167
|
+
if (this._peek() && this._peek().type === W.NUMBER) {
|
|
1168
|
+
let t = [];
|
|
1169
|
+
for (; n() && t.length < tn;) {
|
|
1170
|
+
let e = this._next();
|
|
1171
|
+
if (e.type !== W.NUMBER) return this._finishMixedValue(t, t.length, e);
|
|
1172
|
+
t.push(e.value);
|
|
1173
|
+
}
|
|
1174
|
+
if (!n()) return this._next(), t;
|
|
1175
|
+
let r = new (sn[e] || Float64Array)(tn * 4);
|
|
1176
|
+
r.set(t);
|
|
1177
|
+
let i = t.length;
|
|
1178
|
+
for (; n();) {
|
|
1179
|
+
let e = this._next();
|
|
1180
|
+
if (e.type !== W.NUMBER) return this._finishMixedValue(r, i, e);
|
|
1181
|
+
i === r.length && (r = U(r, r.length * 2)), r[i++] = e.value;
|
|
1182
|
+
}
|
|
1183
|
+
return this._next(), i === r.length ? r : U(r, i);
|
|
1184
|
+
}
|
|
1185
|
+
let r = [];
|
|
1186
|
+
for (; n();) r.push(this._coerceValueToken(this._next()));
|
|
1187
|
+
return this._next(), r;
|
|
1188
|
+
}
|
|
1189
|
+
_finishMixedValue(e, t, n) {
|
|
1190
|
+
let r = [];
|
|
1191
|
+
for (let n = 0; n < t; n++) r.push(e[n]);
|
|
1192
|
+
for (r.push(this._coerceValueToken(n)); this._peek() && this._peek().type !== W.RBRACKET;) r.push(this._coerceValueToken(this._next()));
|
|
1193
|
+
return this._next(), r;
|
|
1194
|
+
}
|
|
1195
|
+
_coerceValueToken(e) {
|
|
1196
|
+
if (!e) throw Error("PBRT parser: unexpected EOF in parameter value");
|
|
1197
|
+
if (e.type === W.NUMBER || e.type === W.STRING) return e.value;
|
|
1198
|
+
if (e.type === W.WORD) return e.value === "true" ? !0 : e.value === "false" ? !1 : e.value;
|
|
1199
|
+
throw Error(`PBRT parser: unexpected token in parameter value: ${e.type}`);
|
|
1200
|
+
}
|
|
1201
|
+
async _run(e) {
|
|
1202
|
+
let t = this.stream;
|
|
1203
|
+
this.stream = e;
|
|
1204
|
+
for (let e = this._next(); e !== null; e = this._next()) {
|
|
1205
|
+
if (e.type !== W.WORD) throw Error(`PBRT parser: expected directive, got ${e.type} ${e.value ?? ""}`);
|
|
1206
|
+
an.has(e.value) && this._effects++;
|
|
1207
|
+
let t = this._directive(e.value);
|
|
1208
|
+
t !== void 0 && await t;
|
|
1209
|
+
}
|
|
1210
|
+
this.stream = t;
|
|
1211
|
+
}
|
|
1212
|
+
_directive(e) {
|
|
1213
|
+
switch (e) {
|
|
1214
|
+
case "Identity":
|
|
1215
|
+
this._setCTM(Gt());
|
|
1216
|
+
break;
|
|
1217
|
+
case "Translate": {
|
|
1218
|
+
let [e, t, n] = this._readNumbers(3);
|
|
1219
|
+
this._concat(Jt(e, t, n));
|
|
1220
|
+
break;
|
|
1221
|
+
}
|
|
1222
|
+
case "Scale": {
|
|
1223
|
+
let [e, t, n] = this._readNumbers(3);
|
|
1224
|
+
this._concat(Yt(e, t, n));
|
|
1225
|
+
break;
|
|
1226
|
+
}
|
|
1227
|
+
case "Rotate": {
|
|
1228
|
+
let [e, t, n, r] = this._readNumbers(4);
|
|
1229
|
+
this._concat(Xt(e, t, n, r));
|
|
1230
|
+
break;
|
|
1231
|
+
}
|
|
1232
|
+
case "LookAt": {
|
|
1233
|
+
let e = this._readNumbers(9), t = en([
|
|
1234
|
+
e[0],
|
|
1235
|
+
e[1],
|
|
1236
|
+
e[2]
|
|
1237
|
+
], [
|
|
1238
|
+
e[3],
|
|
1239
|
+
e[4],
|
|
1240
|
+
e[5]
|
|
1241
|
+
], [
|
|
1242
|
+
e[6],
|
|
1243
|
+
e[7],
|
|
1244
|
+
e[8]
|
|
1245
|
+
]);
|
|
1246
|
+
this._concat(J(t));
|
|
1247
|
+
break;
|
|
1248
|
+
}
|
|
1249
|
+
case "Transform":
|
|
1250
|
+
this._setCTM(this._readBracketedOrBareNumbers(16));
|
|
1251
|
+
break;
|
|
1252
|
+
case "ConcatTransform":
|
|
1253
|
+
this._concat(this._readBracketedOrBareNumbers(16));
|
|
1254
|
+
break;
|
|
1255
|
+
case "CoordinateSystem":
|
|
1256
|
+
this.coordSystems.set(this._expectString("CoordinateSystem"), {
|
|
1257
|
+
ctm: this.ctm,
|
|
1258
|
+
ctmEnd: this.ctmEnd
|
|
1259
|
+
});
|
|
1260
|
+
break;
|
|
1261
|
+
case "CoordSysTransform": {
|
|
1262
|
+
let e = this.coordSystems.get(this._expectString("CoordSysTransform"));
|
|
1263
|
+
e && (this.ctm = e.ctm, this.ctmEnd = e.ctmEnd);
|
|
1264
|
+
break;
|
|
1265
|
+
}
|
|
1266
|
+
case "Camera": {
|
|
1267
|
+
let e = this._expectString("Camera type"), t = this._parseParams();
|
|
1268
|
+
this.ir.camera = {
|
|
1269
|
+
type: e,
|
|
1270
|
+
params: t,
|
|
1271
|
+
cameraToWorld: J(this.ctm)
|
|
1272
|
+
};
|
|
1273
|
+
let n = this._ctmEndSnapshot();
|
|
1274
|
+
n && (this.ir.camera.cameraToWorldEnd = J(n));
|
|
1275
|
+
break;
|
|
1276
|
+
}
|
|
1277
|
+
case "Film": {
|
|
1278
|
+
this._expectString("Film type");
|
|
1279
|
+
let e = this._parseParams();
|
|
1280
|
+
this.ir.film = {
|
|
1281
|
+
xresolution: this._num(e.xresolution, 1280),
|
|
1282
|
+
yresolution: this._num(e.yresolution, 720),
|
|
1283
|
+
filename: this._str(e.filename, null)
|
|
1284
|
+
};
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
case "Integrator":
|
|
1288
|
+
case "Sampler":
|
|
1289
|
+
case "PixelFilter":
|
|
1290
|
+
case "Filter":
|
|
1291
|
+
case "Accelerator":
|
|
1292
|
+
case "ColorSpace":
|
|
1293
|
+
case "Option":
|
|
1294
|
+
this._skipTypeAndParams();
|
|
1295
|
+
break;
|
|
1296
|
+
case "WorldBegin":
|
|
1297
|
+
this.ctm = Gt(), this.ctmEnd = null, this.activeTransform = Y, this.state = {
|
|
1298
|
+
material: null,
|
|
1299
|
+
areaLight: null,
|
|
1300
|
+
reverseOrientation: !1,
|
|
1301
|
+
interior: null
|
|
1302
|
+
};
|
|
1303
|
+
break;
|
|
1304
|
+
case "WorldEnd": break;
|
|
1305
|
+
case "AttributeBegin":
|
|
1306
|
+
this._pushGraphicsState();
|
|
1307
|
+
break;
|
|
1308
|
+
case "AttributeEnd":
|
|
1309
|
+
this._popGraphicsState();
|
|
1310
|
+
break;
|
|
1311
|
+
case "TransformBegin":
|
|
1312
|
+
this.transformStack.push({
|
|
1313
|
+
ctm: this.ctm,
|
|
1314
|
+
ctmEnd: this.ctmEnd,
|
|
1315
|
+
activeTransform: this.activeTransform
|
|
1316
|
+
});
|
|
1317
|
+
break;
|
|
1318
|
+
case "TransformEnd": {
|
|
1319
|
+
let e = this.transformStack.pop();
|
|
1320
|
+
e && (this.ctm = e.ctm, this.ctmEnd = e.ctmEnd, this.activeTransform = e.activeTransform);
|
|
1321
|
+
break;
|
|
1322
|
+
}
|
|
1323
|
+
case "ReverseOrientation":
|
|
1324
|
+
this.state.reverseOrientation = !this.state.reverseOrientation;
|
|
1325
|
+
break;
|
|
1326
|
+
case "Attribute":
|
|
1327
|
+
this._expectString("Attribute target"), this._parseParams();
|
|
1328
|
+
break;
|
|
1329
|
+
case "ActiveTransform": {
|
|
1330
|
+
let e = this._next()?.value;
|
|
1331
|
+
e === "StartTime" ? this.activeTransform = nn : e === "EndTime" ? this.activeTransform = rn : e === "All" ? this.activeTransform = Y : this._warn(`ActiveTransform "${e}" not recognised`);
|
|
1332
|
+
break;
|
|
1333
|
+
}
|
|
1334
|
+
case "TransformTimes": {
|
|
1335
|
+
let [e, t] = this._readNumbers(2);
|
|
1336
|
+
this.ir.transformTimes = {
|
|
1337
|
+
start: e,
|
|
1338
|
+
end: t
|
|
1339
|
+
};
|
|
1340
|
+
break;
|
|
1341
|
+
}
|
|
1342
|
+
case "MediumInterface": {
|
|
1343
|
+
let e = this._peek()?.type === W.STRING ? this._next().value : "";
|
|
1344
|
+
this._peek()?.type === W.STRING && this._next(), this.state.interior = e || null;
|
|
1345
|
+
break;
|
|
1346
|
+
}
|
|
1347
|
+
case "MakeNamedMedium": {
|
|
1348
|
+
let e = this._expectString("MakeNamedMedium name");
|
|
1349
|
+
this.ir.media.set(e, this._parseParams());
|
|
1350
|
+
break;
|
|
1351
|
+
}
|
|
1352
|
+
case "Material": {
|
|
1353
|
+
let e = this._expectString("Material type"), t = this._parseParams();
|
|
1354
|
+
this.state.material = {
|
|
1355
|
+
type: e,
|
|
1356
|
+
params: t
|
|
1357
|
+
};
|
|
1358
|
+
break;
|
|
1359
|
+
}
|
|
1360
|
+
case "MakeNamedMaterial": {
|
|
1361
|
+
let e = this._expectString("MakeNamedMaterial name"), t = this._parseParams(), n = this._str(t.type, "diffuse");
|
|
1362
|
+
this.ir.namedMaterials.set(e, {
|
|
1363
|
+
type: n,
|
|
1364
|
+
params: t
|
|
1365
|
+
});
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
case "NamedMaterial": {
|
|
1369
|
+
let e = this._expectString("NamedMaterial name"), t = this.ir.namedMaterials.get(e);
|
|
1370
|
+
this.state.material = t || {
|
|
1371
|
+
type: "diffuse",
|
|
1372
|
+
params: {},
|
|
1373
|
+
_missingRef: e
|
|
1374
|
+
}, t || this._warn(`NamedMaterial "${e}" referenced before definition`);
|
|
1375
|
+
break;
|
|
1376
|
+
}
|
|
1377
|
+
case "Texture": {
|
|
1378
|
+
let e = this._expectString("Texture name"), t = this._expectString("Texture data type"), n = this._expectString("Texture class"), r = this._parseParams();
|
|
1379
|
+
this.ir.namedTextures.set(e, {
|
|
1380
|
+
dataType: t,
|
|
1381
|
+
class: n,
|
|
1382
|
+
params: r
|
|
1383
|
+
});
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
case "AreaLightSource": {
|
|
1387
|
+
let e = this._expectString("AreaLightSource type"), t = this._parseParams();
|
|
1388
|
+
this.state.areaLight = {
|
|
1389
|
+
type: e,
|
|
1390
|
+
params: t
|
|
1391
|
+
};
|
|
1392
|
+
break;
|
|
1393
|
+
}
|
|
1394
|
+
case "LightSource": {
|
|
1395
|
+
let e = this._expectString("LightSource type"), t = this._parseParams();
|
|
1396
|
+
this.ctmEnd !== null && !on(this.ctmEnd, this.ctm) && this._warnOnce("animated-light", "animated LightSource transforms are not supported — using the start transform"), this.ir.lights.push({
|
|
1397
|
+
type: e,
|
|
1398
|
+
params: t,
|
|
1399
|
+
ctm: this._ctmSnapshot()
|
|
1400
|
+
});
|
|
1401
|
+
break;
|
|
1402
|
+
}
|
|
1403
|
+
case "Shape": {
|
|
1404
|
+
let e = this._expectString("Shape type"), t = this._parseParams(), n = t.alpha;
|
|
1405
|
+
if (n?.type === "float" && n.value[0] <= 0) break;
|
|
1406
|
+
n && !(n.type === "float" && n.value[0] >= 1) && this._warnOnce("alpha", "shape \"alpha\" between 0 and 1, or as a texture, is not supported — drawn opaque");
|
|
1407
|
+
let r = {
|
|
1408
|
+
type: e,
|
|
1409
|
+
params: t,
|
|
1410
|
+
ctm: this._ctmSnapshot(),
|
|
1411
|
+
material: this.state.material,
|
|
1412
|
+
areaLight: this.state.areaLight,
|
|
1413
|
+
reverseOrientation: this.state.reverseOrientation,
|
|
1414
|
+
interior: this.state.interior
|
|
1415
|
+
}, i = this.currentObject === null ? this._ctmEndSnapshot() : null;
|
|
1416
|
+
i ? r.ctmEnd = i : this.currentObject !== null && this.ctmEnd !== null && !on(this.ctmEnd, this.ctm) && this._warnOnce("animated-template", "animated transforms inside ObjectBegin are not supported — using the start transform"), this._emitShape(r);
|
|
1417
|
+
break;
|
|
1418
|
+
}
|
|
1419
|
+
case "ObjectBegin": {
|
|
1420
|
+
let e = this._expectString("ObjectBegin name");
|
|
1421
|
+
this._pushGraphicsState(), this.currentObject = e, this.ir.objects.has(e) || this.ir.objects.set(e, []);
|
|
1422
|
+
break;
|
|
1423
|
+
}
|
|
1424
|
+
case "ObjectEnd":
|
|
1425
|
+
this.currentObject = null, this._popGraphicsState();
|
|
1426
|
+
break;
|
|
1427
|
+
case "ObjectInstance": {
|
|
1428
|
+
let e = this._expectString("ObjectInstance name");
|
|
1429
|
+
this._addInstance(e);
|
|
1430
|
+
break;
|
|
1431
|
+
}
|
|
1432
|
+
case "Include":
|
|
1433
|
+
case "Import": {
|
|
1434
|
+
let t = this._expectString(e);
|
|
1435
|
+
return this._include(t);
|
|
1436
|
+
}
|
|
1437
|
+
default:
|
|
1438
|
+
this._warnUnknown(e), this._parseParams();
|
|
1439
|
+
break;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
_emitShape(e) {
|
|
1443
|
+
this.currentObject === null ? this.ir.shapes.push(e) : this.ir.objects.get(this.currentObject).push(e);
|
|
1444
|
+
}
|
|
1445
|
+
async _include(e) {
|
|
1446
|
+
let t = this.dirStack[this.dirStack.length - 1], n = this._includeKey(e, t);
|
|
1447
|
+
if (n !== null && this._placeRepeat(n, e)) return;
|
|
1448
|
+
let r = await this.resolveInclude(e, t);
|
|
1449
|
+
if (r == null) {
|
|
1450
|
+
this._warn(`Include target not found: ${e}`);
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
let i = n === null ? null : this._includeState(), a = e.includes("/") ? e.slice(0, e.lastIndexOf("/")) : "";
|
|
1454
|
+
this.dirStack.push(a);
|
|
1455
|
+
try {
|
|
1456
|
+
await this._run(new Wt(r));
|
|
1457
|
+
} finally {
|
|
1458
|
+
this.dirStack.pop(), this.releaseInclude?.(e, t, r);
|
|
1459
|
+
}
|
|
1460
|
+
i && this._sameIncludeState(i) && !this._includes.has(n) && this._includes.set(n, {
|
|
1461
|
+
start: i.shapes,
|
|
1462
|
+
end: this.ir.shapes.length,
|
|
1463
|
+
ctm: i.ctm.slice(),
|
|
1464
|
+
template: null
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
_includeKey(e, t) {
|
|
1468
|
+
return !this.instanceIncludes || this.currentObject !== null || this.ctmEnd !== null || this.activeTransform !== Y || this.state.areaLight ? null : `${t}\0${e}\0${this._stateId(this.state.material)}\0${this.state.reverseOrientation}\0${this.state.interior}`;
|
|
1469
|
+
}
|
|
1470
|
+
_stateId(e) {
|
|
1471
|
+
if (!e) return 0;
|
|
1472
|
+
let t = this._stateIds.get(e);
|
|
1473
|
+
return t === void 0 && this._stateIds.set(e, t = this._nextStateId++), t;
|
|
1474
|
+
}
|
|
1475
|
+
_includeState() {
|
|
1476
|
+
return {
|
|
1477
|
+
shapes: this.ir.shapes.length,
|
|
1478
|
+
effects: this._effects,
|
|
1479
|
+
ctm: this.ctm,
|
|
1480
|
+
attributes: this.attributeStack.length,
|
|
1481
|
+
transforms: this.transformStack.length,
|
|
1482
|
+
material: this.state.material,
|
|
1483
|
+
reverseOrientation: this.state.reverseOrientation,
|
|
1484
|
+
interior: this.state.interior
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
_sameIncludeState(e) {
|
|
1488
|
+
return this._effects === e.effects && this.ctmEnd === null && this.activeTransform === Y && on(this.ctm, e.ctm) && this.attributeStack.length === e.attributes && this.transformStack.length === e.transforms && this.state.material === e.material && this.state.areaLight === null && this.state.reverseOrientation === e.reverseOrientation && this.state.interior === e.interior;
|
|
1489
|
+
}
|
|
1490
|
+
_placeRepeat(e, t) {
|
|
1491
|
+
let n = this._includes.get(e);
|
|
1492
|
+
if (!n) return !1;
|
|
1493
|
+
if (n.template === null) {
|
|
1494
|
+
let { start: r, end: i } = n;
|
|
1495
|
+
if (i === r || this.ir.instanceCount + 2 > this.maxPlacements) return !1;
|
|
1496
|
+
for (let t = r; t < i; t++) if (!this.ir.shapes[t]) return this._includes.delete(e), !1;
|
|
1497
|
+
let a = `${t}#${this.ir.objects.size}`, o = J(n.ctm), s = [], c = null, l = null;
|
|
1498
|
+
for (let e = r; e < i; e++) {
|
|
1499
|
+
let t = this.ir.shapes[e];
|
|
1500
|
+
t.ctm !== c && (l = q(o, c = t.ctm)), t.relativeCTM = l, s.push(t), this.ir.shapes[e] = null;
|
|
1501
|
+
}
|
|
1502
|
+
this.ir.objects.set(a, s), this._addInstance(a, n.ctm), n.template = a, this._movedShapes = !0;
|
|
1503
|
+
}
|
|
1504
|
+
return this._addInstance(n.template), !0;
|
|
1505
|
+
}
|
|
1506
|
+
_skipTypeAndParams() {
|
|
1507
|
+
this._peek() && this._peek().type === W.STRING && this._next(), this._parseParams();
|
|
1508
|
+
}
|
|
1509
|
+
_skipNamedAndParams() {
|
|
1510
|
+
this._peek() && this._peek().type === W.STRING && this._next(), this._parseParams();
|
|
1511
|
+
}
|
|
1512
|
+
_num(e, t) {
|
|
1513
|
+
return e && e.value.length ? e.value[0] : t;
|
|
1514
|
+
}
|
|
1515
|
+
_str(e, t) {
|
|
1516
|
+
return e && e.value.length ? e.value[0] : t;
|
|
1517
|
+
}
|
|
1518
|
+
_warn(e) {
|
|
1519
|
+
this.ir.warnings.push(e);
|
|
1520
|
+
}
|
|
1521
|
+
_warnOnce(e, t) {
|
|
1522
|
+
this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(t));
|
|
1523
|
+
}
|
|
1524
|
+
_warnUnknown(e) {
|
|
1525
|
+
this._warnedUnknown.has(e) || (this._warnedUnknown.add(e), this._warn(`Unsupported directive ignored: ${e}`));
|
|
1526
|
+
}
|
|
1527
|
+
}, ln = {
|
|
1528
|
+
au: [
|
|
1529
|
+
1,
|
|
1530
|
+
.78,
|
|
1531
|
+
.34
|
|
1532
|
+
],
|
|
1533
|
+
gold: [
|
|
1534
|
+
1,
|
|
1535
|
+
.78,
|
|
1536
|
+
.34
|
|
1537
|
+
],
|
|
1538
|
+
cu: [
|
|
1539
|
+
.95,
|
|
1540
|
+
.64,
|
|
1541
|
+
.54
|
|
1542
|
+
],
|
|
1543
|
+
copper: [
|
|
1544
|
+
.95,
|
|
1545
|
+
.64,
|
|
1546
|
+
.54
|
|
1547
|
+
],
|
|
1548
|
+
ag: [
|
|
1549
|
+
.97,
|
|
1550
|
+
.96,
|
|
1551
|
+
.91
|
|
1552
|
+
],
|
|
1553
|
+
silver: [
|
|
1554
|
+
.97,
|
|
1555
|
+
.96,
|
|
1556
|
+
.91
|
|
1557
|
+
],
|
|
1558
|
+
al: [
|
|
1559
|
+
.91,
|
|
1560
|
+
.92,
|
|
1561
|
+
.92
|
|
1562
|
+
],
|
|
1563
|
+
aluminium: [
|
|
1564
|
+
.91,
|
|
1565
|
+
.92,
|
|
1566
|
+
.92
|
|
1567
|
+
],
|
|
1568
|
+
aluminum: [
|
|
1569
|
+
.91,
|
|
1570
|
+
.92,
|
|
1571
|
+
.92
|
|
1572
|
+
],
|
|
1573
|
+
mgo: [
|
|
1574
|
+
.9,
|
|
1575
|
+
.9,
|
|
1576
|
+
.9
|
|
1577
|
+
],
|
|
1578
|
+
tio2: [
|
|
1579
|
+
.9,
|
|
1580
|
+
.9,
|
|
1581
|
+
.9
|
|
1582
|
+
]
|
|
1583
|
+
}, un = [
|
|
1584
|
+
.92,
|
|
1585
|
+
.92,
|
|
1586
|
+
.92
|
|
1587
|
+
];
|
|
1588
|
+
function dn(e) {
|
|
1589
|
+
let t = Math.max(1e3, Math.min(4e4, e)) / 100, n, r, i;
|
|
1590
|
+
t <= 66 ? (n = 255, r = 99.47 * Math.log(t) - 161.12) : (n = 329.7 * (t - 60) ** -.1332, r = 288.12 * (t - 60) ** -.0755), i = t >= 66 ? 255 : t <= 19 ? 0 : 138.52 * Math.log(t - 10) - 305.04;
|
|
1591
|
+
let a = (e) => Math.max(0, Math.min(255, e)) / 255;
|
|
1592
|
+
return [
|
|
1593
|
+
a(n) ** 2.2,
|
|
1594
|
+
a(r) ** 2.2,
|
|
1595
|
+
a(i) ** 2.2
|
|
1596
|
+
];
|
|
1597
|
+
}
|
|
1598
|
+
function X(e, t, n) {
|
|
1599
|
+
let r = e[t];
|
|
1600
|
+
return r && typeof r.value[0] == "number" ? r.value[0] : n;
|
|
1601
|
+
}
|
|
1602
|
+
function Z(e, t, n) {
|
|
1603
|
+
let r = e[t];
|
|
1604
|
+
return r && typeof r.value[0] == "string" ? r.value[0] : n;
|
|
1605
|
+
}
|
|
1606
|
+
function fn(e, t, n) {
|
|
1607
|
+
let r = e[t]?.value?.[0];
|
|
1608
|
+
return r === void 0 ? n : r === !0 || r === "true";
|
|
1609
|
+
}
|
|
1610
|
+
async function Q(e, t, n, r = null) {
|
|
1611
|
+
let i = e[t];
|
|
1612
|
+
if (!i) return {
|
|
1613
|
+
rgb: r,
|
|
1614
|
+
texture: null
|
|
1615
|
+
};
|
|
1616
|
+
if (i.type === "texture") {
|
|
1617
|
+
let e = i.value[0], t = await n.resolveNamedTexture(e);
|
|
1618
|
+
return t && t.texture ? {
|
|
1619
|
+
rgb: t.constant ?? null,
|
|
1620
|
+
texture: t.texture
|
|
1621
|
+
} : t && t.constant ? {
|
|
1622
|
+
rgb: t.constant,
|
|
1623
|
+
texture: null
|
|
1624
|
+
} : (n.warn(`texture "${e}" could not be resolved`), {
|
|
1625
|
+
rgb: r,
|
|
1626
|
+
texture: null
|
|
1627
|
+
});
|
|
1628
|
+
}
|
|
1629
|
+
if (i.type === "rgb" || i.type === "color") return {
|
|
1630
|
+
rgb: [
|
|
1631
|
+
i.value[0],
|
|
1632
|
+
i.value[1],
|
|
1633
|
+
i.value[2]
|
|
1634
|
+
],
|
|
1635
|
+
texture: null
|
|
1636
|
+
};
|
|
1637
|
+
if (i.type === "float") {
|
|
1638
|
+
let e = i.value[0];
|
|
1639
|
+
return {
|
|
1640
|
+
rgb: [
|
|
1641
|
+
e,
|
|
1642
|
+
e,
|
|
1643
|
+
e
|
|
1644
|
+
],
|
|
1645
|
+
texture: null
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
if (i.type === "blackbody") return {
|
|
1649
|
+
rgb: dn(i.value[0]),
|
|
1650
|
+
texture: null
|
|
1651
|
+
};
|
|
1652
|
+
if (i.type === "spectrum") {
|
|
1653
|
+
if (typeof i.value[0] == "string") {
|
|
1654
|
+
let e = pn(i.value[0]);
|
|
1655
|
+
return e && ln[e] ? {
|
|
1656
|
+
rgb: ln[e].slice(),
|
|
1657
|
+
texture: null
|
|
1658
|
+
} : (n.warn(`named spectrum "${i.value[0]}" approximated to gray`), {
|
|
1659
|
+
rgb: [
|
|
1660
|
+
.5,
|
|
1661
|
+
.5,
|
|
1662
|
+
.5
|
|
1663
|
+
],
|
|
1664
|
+
texture: null
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
let e = 0, t = 0;
|
|
1668
|
+
for (let n = 1; n < i.value.length; n += 2) e += i.value[n], t++;
|
|
1669
|
+
let r = t ? e / t : .5;
|
|
1670
|
+
return {
|
|
1671
|
+
rgb: [
|
|
1672
|
+
r,
|
|
1673
|
+
r,
|
|
1674
|
+
r
|
|
1675
|
+
],
|
|
1676
|
+
texture: null
|
|
1677
|
+
};
|
|
1678
|
+
}
|
|
1679
|
+
return {
|
|
1680
|
+
rgb: r,
|
|
1681
|
+
texture: null
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
function pn(e) {
|
|
1685
|
+
let t = e.toLowerCase().match(/metal-([a-z]+)/);
|
|
1686
|
+
if (t) return t[1];
|
|
1687
|
+
for (let t of Object.keys(ln)) if (e.toLowerCase().includes(t)) return t;
|
|
1688
|
+
return null;
|
|
1689
|
+
}
|
|
1690
|
+
async function mn(e, t, n) {
|
|
1691
|
+
let r = e[t];
|
|
1692
|
+
return r ? typeof r.value[0] == "number" ? r.value[0] : r.type === "texture" ? await n.floatTextureMean?.(r.value[0]) ?? null : null : null;
|
|
1693
|
+
}
|
|
1694
|
+
async function hn(e, t, n, r = "") {
|
|
1695
|
+
let i = e.remaproughness?.value?.[0], a = (e) => i === !1 || i === "false" ? e : Math.sqrt(Math.max(e, 0)), o = null, s = await mn(e, `${r}roughness`, n);
|
|
1696
|
+
if (s !== null) o = a(s);
|
|
1697
|
+
else {
|
|
1698
|
+
let t = await mn(e, `${r}uroughness`, n), i = await mn(e, `${r}vroughness`, n);
|
|
1699
|
+
t !== null && (o = i === null ? a(t) : (a(t) + a(i)) / 2);
|
|
1700
|
+
}
|
|
1701
|
+
return o === null ? t : Math.sqrt(Math.max(o, 0));
|
|
1702
|
+
}
|
|
1703
|
+
async function gn(e, t, n, r, i, a) {
|
|
1704
|
+
let o = await Q(t, "reflectance", n, null), s = t[`${r}eta`], c = t[`${r}k`], l = s && s.type === "spectrum" && typeof s.value[0] == "string";
|
|
1705
|
+
if (o.rgb || o.texture) i(o);
|
|
1706
|
+
else if (s && c && !l) {
|
|
1707
|
+
let e = (await Q(t, `${r}eta`, n, [
|
|
1708
|
+
.2,
|
|
1709
|
+
.92,
|
|
1710
|
+
1.1
|
|
1711
|
+
])).rgb, i = (await Q(t, `${r}k`, n, [
|
|
1712
|
+
3.9,
|
|
1713
|
+
2.45,
|
|
1714
|
+
2.14
|
|
1715
|
+
])).rgb, o = (e, t) => ((e - 1) ** 2 + t ** 2) / ((e + 1) ** 2 + t ** 2);
|
|
1716
|
+
a([
|
|
1717
|
+
o(e[0], i[0]),
|
|
1718
|
+
o(e[1], i[1]),
|
|
1719
|
+
o(e[2], i[2])
|
|
1720
|
+
]);
|
|
1721
|
+
} else a(s ? (await Q(t, `${r}eta`, n, un)).rgb || un : ln.cu);
|
|
1722
|
+
e.metalness = 1;
|
|
1723
|
+
}
|
|
1724
|
+
async function _n(e, t) {
|
|
1725
|
+
let n = e?.type || "diffuse", r = e?.params || {}, i = new te({
|
|
1726
|
+
side: S,
|
|
1727
|
+
roughness: 1,
|
|
1728
|
+
metalness: 0
|
|
1729
|
+
}), a = (e) => {
|
|
1730
|
+
e && i.color.setRGB(e[0], e[1], e[2]);
|
|
1731
|
+
}, o = (e) => {
|
|
1732
|
+
a(e.rgb), e.texture && (i.map = e.texture, e.rgb || i.color.setRGB(1, 1, 1));
|
|
1733
|
+
};
|
|
1734
|
+
switch (n) {
|
|
1735
|
+
case "diffuse":
|
|
1736
|
+
o(await Q(r, "reflectance", t, [
|
|
1737
|
+
.5,
|
|
1738
|
+
.5,
|
|
1739
|
+
.5
|
|
1740
|
+
])), i.roughness = 1, i.metalness = 0, i.specularIntensity = 0;
|
|
1741
|
+
break;
|
|
1742
|
+
case "conductor":
|
|
1743
|
+
case "metal":
|
|
1744
|
+
await gn(i, r, t, "", o, a), i.roughness = await hn(r, .1, t);
|
|
1745
|
+
break;
|
|
1746
|
+
case "coatedconductor":
|
|
1747
|
+
await gn(i, r, t, "conductor.", o, a), i.roughness = await hn(r, 0, t, "conductor."), i.clearcoat = 1, i.clearcoatRoughness = await hn(r, 0, t, "interface.");
|
|
1748
|
+
break;
|
|
1749
|
+
case "dielectric":
|
|
1750
|
+
case "thindielectric":
|
|
1751
|
+
i.transmission = 1, i.metalness = 0, i.color.setRGB(1, 1, 1), i.ior = X(r, "eta", 1.5), i.roughness = await hn(r, 0, t), i.thickness = n === "thindielectric" ? 0 : X(r, "thickness", 0);
|
|
1752
|
+
break;
|
|
1753
|
+
case "coateddiffuse":
|
|
1754
|
+
o(await Q(r, "reflectance", t, [
|
|
1755
|
+
.5,
|
|
1756
|
+
.5,
|
|
1757
|
+
.5
|
|
1758
|
+
])), i.roughness = .6, i.metalness = 0, i.clearcoat = 1, i.clearcoatRoughness = await hn(r, 0, t);
|
|
1759
|
+
break;
|
|
1760
|
+
case "diffusetransmission": {
|
|
1761
|
+
let e = X(r, "scale", 1), n = (t) => Math.min(1, Math.max(0, e * t)), a = await Q(r, "transmittance", t, [
|
|
1762
|
+
.25,
|
|
1763
|
+
.25,
|
|
1764
|
+
.25
|
|
1765
|
+
]), s = a.rgb ? a.rgb.map(n) : [
|
|
1766
|
+
.5,
|
|
1767
|
+
.5,
|
|
1768
|
+
.5
|
|
1769
|
+
], c = Math.min(.99, Math.max(...s)), l = await Q(r, "reflectance", t, [
|
|
1770
|
+
.25,
|
|
1771
|
+
.25,
|
|
1772
|
+
.25
|
|
1773
|
+
]), u = (e) => Math.min(1, n(e) / (1 - c));
|
|
1774
|
+
o({
|
|
1775
|
+
texture: l.texture,
|
|
1776
|
+
rgb: l.rgb ? l.rgb.map(u) : l.texture ? [
|
|
1777
|
+
1,
|
|
1778
|
+
1,
|
|
1779
|
+
1
|
|
1780
|
+
].map(u) : null
|
|
1781
|
+
}), a.texture && t.warn("diffusetransmission: a textured \"transmittance\" is not supported — using 0.5"), i.diffuseTransmission = c, i.diffuseTransmissionColor = new y().setRGB(...s.map((e) => c > 0 ? Math.min(1, e / c) : 1)), i.roughness = 1, i.metalness = 0, i.specularIntensity = 0;
|
|
1782
|
+
break;
|
|
1783
|
+
}
|
|
1784
|
+
case "interface":
|
|
1785
|
+
case "none":
|
|
1786
|
+
case "":
|
|
1787
|
+
i.transmission = 1, i.ior = 1, i.roughness = 0, i.color.setRGB(1, 1, 1);
|
|
1788
|
+
break;
|
|
1789
|
+
case "mix": {
|
|
1790
|
+
let e = r.materials?.value || [], n = Math.max(0, Math.min(1, X(r, "amount", .5))), a = e[0] ? t.namedMaterials?.get(e[0]) : null, o = e[1] ? t.namedMaterials?.get(e[1]) : null;
|
|
1791
|
+
if (a && o) {
|
|
1792
|
+
let [e, s] = await Promise.all([_n(a, t), _n(o, t)]), c = r.amount, l = c?.type === "texture" ? await t.bakeMaterialMix?.(e, s, c.value[0]) : null;
|
|
1793
|
+
l && (n = l.mean);
|
|
1794
|
+
let u = (e, t) => e * (1 - n) + t * n;
|
|
1795
|
+
i.color.lerpColors(e.color, s.color, n), i.roughness = u(e.roughness, s.roughness), i.metalness = u(e.metalness, s.metalness), i.ior = u(e.ior ?? 1.5, s.ior ?? 1.5), i.transmission = u(e.transmission ?? 0, s.transmission ?? 0), i.thickness = u(e.thickness ?? 0, s.thickness ?? 0), i.clearcoat = u(e.clearcoat ?? 0, s.clearcoat ?? 0), i.clearcoatRoughness = u(e.clearcoatRoughness ?? 0, s.clearcoatRoughness ?? 0), i.emissive.lerpColors(e.emissive, s.emissive, n);
|
|
1796
|
+
let d = e.diffuseTransmission ?? 0, f = s.diffuseTransmission ?? 0;
|
|
1797
|
+
(d > 0 || f > 0) && (i.diffuseTransmission = u(d, f), i.diffuseTransmissionColor = new y().lerpColors(e.diffuseTransmissionColor ?? new y(1, 1, 1), s.diffuseTransmissionColor ?? new y(1, 1, 1), n)), i.emissiveIntensity = u(e.emissiveIntensity ?? 0, s.emissiveIntensity ?? 0), i.map = (n < .5 ? e.map : s.map) || null, i.normalMap = (n < .5 ? e.normalMap : s.normalMap) || null, l?.texture && (i.map = l.texture, i.color.setRGB(1, 1, 1));
|
|
1798
|
+
break;
|
|
1799
|
+
}
|
|
1800
|
+
t.warn(`material "mix" — could not resolve inner materials [${e.join(", ")}], falling back to diffuse`), i.color.set(new y(.6, .6, .6));
|
|
1801
|
+
break;
|
|
1802
|
+
}
|
|
1803
|
+
case "subsurface":
|
|
1804
|
+
case "hair":
|
|
1805
|
+
case "measured":
|
|
1806
|
+
t.warn(`material "${n}" not supported — using diffuse approximation`), a((await Q(r, "reflectance", t, [
|
|
1807
|
+
.5,
|
|
1808
|
+
.5,
|
|
1809
|
+
.5
|
|
1810
|
+
])).rgb), i.roughness = 1;
|
|
1811
|
+
break;
|
|
1812
|
+
default:
|
|
1813
|
+
t.warn(`unknown material "${n}" — using neutral diffuse`), i.color.set(new y(.6, .6, .6));
|
|
1814
|
+
break;
|
|
1815
|
+
}
|
|
1816
|
+
let s = Z(r, "normalmap", null);
|
|
1817
|
+
return s && t.resolveNormalMap && (i.normalMap = await t.resolveNormalMap(s)), i.roughness = Math.max(0, Math.min(1, i.roughness)), i;
|
|
1818
|
+
}
|
|
1819
|
+
//#endregion
|
|
1820
|
+
//#region src/Processor/PBRT/PBRTTextureBake.js
|
|
1821
|
+
var vn = 4096, yn = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, bn = (e) => e <= .0031308 ? e * 12.92 : 1.055 * e ** (1 / 2.4) - .055;
|
|
1822
|
+
function xn(e, { channels: t, decode: n = null, scale: r = 1, invert: i = !1, mapping: a = null }) {
|
|
1823
|
+
let { width: o, height: s } = e, c = e.channels ?? 4, l = new Float32Array(o * s * t), u = e.topDown !== !1;
|
|
1824
|
+
for (let a = 0; a < s; a++) {
|
|
1825
|
+
let d = u ? a : s - 1 - a;
|
|
1826
|
+
for (let s = 0; s < o; s++) {
|
|
1827
|
+
let u = (d * o + s) * c, f = (a * o + s) * t;
|
|
1828
|
+
for (let a = 0; a < t; a++) {
|
|
1829
|
+
let t = e.data[u + Math.min(a, c - 1)], o = r * (n ? n(t / 255) : t);
|
|
1830
|
+
l[f + a] = i ? Math.max(0, 1 - o) : o;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
return {
|
|
1835
|
+
width: o,
|
|
1836
|
+
height: s,
|
|
1837
|
+
channels: t,
|
|
1838
|
+
data: l,
|
|
1839
|
+
su: 1,
|
|
1840
|
+
sv: 1,
|
|
1841
|
+
du: 0,
|
|
1842
|
+
dv: 0,
|
|
1843
|
+
...a
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
function Sn(e) {
|
|
1847
|
+
let t = 0;
|
|
1848
|
+
for (let n = 0; n < e.data.length; n++) t += e.data[n];
|
|
1849
|
+
return e.data.length ? t / e.data.length : 0;
|
|
1850
|
+
}
|
|
1851
|
+
function Cn(e, t, n, r) {
|
|
1852
|
+
let { width: i, height: a, channels: o, data: s } = e, c = t * i - .5, l = (1 - n) * a - .5, u = Math.floor(c), d = Math.floor(l), f = c - u, p = l - d, m = (e, t) => (e % t + t) % t, h = m(u, i), g = m(u + 1, i), _ = m(d, a), v = m(d + 1, a);
|
|
1853
|
+
for (let e = 0; e < 3; e++) {
|
|
1854
|
+
let t = Math.min(e, o - 1), n = s[(_ * i + h) * o + t] * (1 - f) + s[(_ * i + g) * o + t] * f, a = s[(v * i + h) * o + t] * (1 - f) + s[(v * i + g) * o + t] * f;
|
|
1855
|
+
r[e] = n * (1 - p) + a * p;
|
|
1856
|
+
}
|
|
1857
|
+
return r;
|
|
1858
|
+
}
|
|
1859
|
+
function wn(e, t) {
|
|
1860
|
+
let n = null;
|
|
1861
|
+
for (let t of e) t.layer && (!n || t.layer.width * t.layer.height > n.width * n.height) && (n = t.layer);
|
|
1862
|
+
if (!n) return null;
|
|
1863
|
+
let r = Math.min(n.width, vn), i = Math.min(n.height, vn), a = new Uint8Array(r * i * 4), o = e.map(() => [
|
|
1864
|
+
0,
|
|
1865
|
+
0,
|
|
1866
|
+
0
|
|
1867
|
+
]);
|
|
1868
|
+
for (let s = 0; s < i; s++) {
|
|
1869
|
+
let c = (s + .5) / i, l = (c - n.dv) / n.sv;
|
|
1870
|
+
for (let i = 0; i < r; i++) {
|
|
1871
|
+
let u = (i + .5) / r, d = (u - n.du) / n.su;
|
|
1872
|
+
for (let t = 0; t < e.length; t++) {
|
|
1873
|
+
let r = e[t], i = o[t];
|
|
1874
|
+
if (r.layer) {
|
|
1875
|
+
let e = r.layer;
|
|
1876
|
+
if (Cn(e, e === n ? u : e.su * d + e.du, e === n ? c : e.sv * l + e.dv, i), r.tint) for (let e = 0; e < 3; e++) i[e] *= r.tint[e];
|
|
1877
|
+
} else i[0] = r.rgb[0], i[1] = r.rgb[1], i[2] = r.rgb[2];
|
|
1878
|
+
if (r.clamp) for (let e = 0; e < 3; e++) i[e] = Math.min(1, Math.max(0, i[e]));
|
|
1879
|
+
}
|
|
1880
|
+
let f = t(o), p = (s * r + i) * 4;
|
|
1881
|
+
for (let e = 0; e < 3; e++) a[p + e] = Math.round(255 * bn(Math.min(1, Math.max(0, f[e]))));
|
|
1882
|
+
a[p + 3] = 255;
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
return {
|
|
1886
|
+
data: a,
|
|
1887
|
+
width: r,
|
|
1888
|
+
height: i,
|
|
1889
|
+
mapping: {
|
|
1890
|
+
su: n.su,
|
|
1891
|
+
sv: n.sv,
|
|
1892
|
+
du: n.du,
|
|
1893
|
+
dv: n.dv
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
}
|
|
1897
|
+
var Tn = ([e, t, n]) => {
|
|
1898
|
+
let r = n[0];
|
|
1899
|
+
return [
|
|
1900
|
+
e[0] + (t[0] - e[0]) * r,
|
|
1901
|
+
e[1] + (t[1] - e[1]) * r,
|
|
1902
|
+
e[2] + (t[2] - e[2]) * r
|
|
1903
|
+
];
|
|
1904
|
+
};
|
|
1905
|
+
//#endregion
|
|
1906
|
+
//#region src/Processor/PBRT/LoopSubdivision.js
|
|
1907
|
+
function En(e) {
|
|
1908
|
+
return e === 3 ? 3 / 16 : 3 / (8 * e);
|
|
1909
|
+
}
|
|
1910
|
+
function Dn(e) {
|
|
1911
|
+
return 1 / (e + 3 / (8 * En(e)));
|
|
1912
|
+
}
|
|
1913
|
+
function On(e, t) {
|
|
1914
|
+
let n = /* @__PURE__ */ new Map(), r = [], i = [], a = [], o = [], s = [], c = t.length / 3;
|
|
1915
|
+
for (let l = 0; l < c; l++) for (let c = 0; c < 3; c++) {
|
|
1916
|
+
let u = t[l * 3 + c], d = t[l * 3 + (c + 1) % 3], f = t[l * 3 + (c + 2) % 3], p = u < d ? u : d, m = u < d ? d : u, h = p * e + m, g = n.get(h);
|
|
1917
|
+
g === void 0 ? (n.set(h, r.length), r.push(p), i.push(m), a.push(f), o.push(-1), s.push(1)) : (o[g] < 0 && (o[g] = f), s[g]++);
|
|
1918
|
+
}
|
|
1919
|
+
let l = Array.from({ length: e }, () => []), u = Array.from({ length: e }, () => []);
|
|
1920
|
+
for (let e = 0; e < r.length; e++) {
|
|
1921
|
+
let t = r[e], n = i[e];
|
|
1922
|
+
l[t].push(n), l[n].push(t), s[e] === 1 && (u[t].push(n), u[n].push(t));
|
|
1923
|
+
}
|
|
1924
|
+
return {
|
|
1925
|
+
edgeIndex: n,
|
|
1926
|
+
edgeV0: r,
|
|
1927
|
+
edgeV1: i,
|
|
1928
|
+
edgeOpp0: a,
|
|
1929
|
+
edgeOpp1: o,
|
|
1930
|
+
edgeFaces: s,
|
|
1931
|
+
ring: l,
|
|
1932
|
+
boundaryRing: u
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
function kn(e, t, n, r, i) {
|
|
1936
|
+
let a = new Float64Array(e.length);
|
|
1937
|
+
for (let o = 0; o < n; o++) {
|
|
1938
|
+
let n = o * 3, s = t.boundaryRing[o];
|
|
1939
|
+
if (s.length === 2) {
|
|
1940
|
+
let t = s[0] * 3, r = s[1] * 3, o = 1 - 2 * i;
|
|
1941
|
+
for (let s = 0; s < 3; s++) a[n + s] = o * e[n + s] + i * (e[t + s] + e[r + s]);
|
|
1942
|
+
continue;
|
|
1943
|
+
}
|
|
1944
|
+
let c = t.ring[o], l = c.length;
|
|
1945
|
+
if (l === 0 || s.length > 0) {
|
|
1946
|
+
for (let t = 0; t < 3; t++) a[n + t] = e[n + t];
|
|
1947
|
+
continue;
|
|
1948
|
+
}
|
|
1949
|
+
let u = r(l), d = 0, f = 0, p = 0;
|
|
1950
|
+
for (let t = 0; t < l; t++) {
|
|
1951
|
+
let n = c[t] * 3;
|
|
1952
|
+
d += e[n], f += e[n + 1], p += e[n + 2];
|
|
1953
|
+
}
|
|
1954
|
+
let m = 1 - l * u;
|
|
1955
|
+
a[n] = m * e[n] + u * d, a[n + 1] = m * e[n + 1] + u * f, a[n + 2] = m * e[n + 2] + u * p;
|
|
1956
|
+
}
|
|
1957
|
+
return a;
|
|
1958
|
+
}
|
|
1959
|
+
function An(e, t) {
|
|
1960
|
+
let n = e.length / 3, r = On(n, t), i = r.edgeV0.length, a = kn(e, r, n, En, 1 / 8), o = new Float64Array((n + i) * 3);
|
|
1961
|
+
o.set(a);
|
|
1962
|
+
for (let t = 0; t < i; t++) {
|
|
1963
|
+
let i = r.edgeV0[t] * 3, a = r.edgeV1[t] * 3, s = (n + t) * 3, c = r.edgeOpp1[t];
|
|
1964
|
+
if (c < 0) for (let t = 0; t < 3; t++) o[s + t] = .5 * (e[i + t] + e[a + t]);
|
|
1965
|
+
else {
|
|
1966
|
+
let n = r.edgeOpp0[t] * 3, l = c * 3;
|
|
1967
|
+
for (let t = 0; t < 3; t++) o[s + t] = .375 * (e[i + t] + e[a + t]) + .125 * (e[n + t] + e[l + t]);
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
let s = t.length / 3, c = new Int32Array(s * 12), l = (e, t) => n + r.edgeIndex.get((e < t ? e : t) * n + (e < t ? t : e));
|
|
1971
|
+
for (let e = 0; e < s; e++) {
|
|
1972
|
+
let n = t[e * 3], r = t[e * 3 + 1], i = t[e * 3 + 2], a = l(n, r), o = l(r, i), s = l(i, n), u = e * 12;
|
|
1973
|
+
c[u] = n, c[u + 1] = a, c[u + 2] = s, c[u + 3] = a, c[u + 4] = r, c[u + 5] = o, c[u + 6] = s, c[u + 7] = o, c[u + 8] = i, c[u + 9] = a, c[u + 10] = o, c[u + 11] = s;
|
|
1974
|
+
}
|
|
1975
|
+
return {
|
|
1976
|
+
positions: o,
|
|
1977
|
+
indices: c
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
function jn(e, t, n, r = 2e6) {
|
|
1981
|
+
let i = Float64Array.from(e), a = Int32Array.from(t), o = 0;
|
|
1982
|
+
for (let e = 0; e < n && !(a.length / 3 * 4 > r); e++) {
|
|
1983
|
+
let e = An(i, a);
|
|
1984
|
+
i = e.positions, a = e.indices, o++;
|
|
1985
|
+
}
|
|
1986
|
+
let s = i.length / 3, c = kn(i, On(s, a), s, Dn, 1 / 5);
|
|
1987
|
+
return {
|
|
1988
|
+
positions: Float32Array.from(c),
|
|
1989
|
+
indices: Uint32Array.from(a),
|
|
1990
|
+
levels: o
|
|
1991
|
+
};
|
|
1992
|
+
}
|
|
1993
|
+
//#endregion
|
|
1994
|
+
//#region src/Processor/PBRT/EqualAreaOctahedral.js
|
|
1995
|
+
function Mn(e, t, n) {
|
|
1996
|
+
let r = Math.abs(e), i = Math.abs(t), a = Math.sqrt(Math.max(0, 1 - Math.abs(n))), o = Math.max(r, i), s = o === 0 ? 0 : Math.min(r, i) / o, c = 2 / Math.PI * Math.atan(s);
|
|
1997
|
+
r < i && (c = 1 - c);
|
|
1998
|
+
let l = c * a, u = a - l;
|
|
1999
|
+
if (n < 0) {
|
|
2000
|
+
let e = u;
|
|
2001
|
+
u = 1 - l, l = 1 - e;
|
|
2002
|
+
}
|
|
2003
|
+
return e < 0 && (u = -u), t < 0 && (l = -l), [.5 * (u + 1), .5 * (l + 1)];
|
|
2004
|
+
}
|
|
2005
|
+
var Nn = (() => {
|
|
2006
|
+
let e = new Float32Array(256);
|
|
2007
|
+
for (let t = 0; t < 256; t++) {
|
|
2008
|
+
let n = t / 255;
|
|
2009
|
+
e[t] = n <= .04045 ? n / 12.92 : ((n + .055) / 1.055) ** 2.4;
|
|
2010
|
+
}
|
|
2011
|
+
return e;
|
|
2012
|
+
})();
|
|
2013
|
+
function Pn(e, t, n, r, i, a, o, s) {
|
|
2014
|
+
let c = Math.min(Math.max(i * t - .5, 0), t - 1), l = Math.min(Math.max(a * n - .5, 0), n - 1), u = Math.floor(c), d = Math.floor(l), f = Math.min(u + 1, t - 1), p = Math.min(d + 1, n - 1), m = c - u, h = l - d, g = (d * t + u) * r, _ = (d * t + f) * r, v = (p * t + u) * r, y = (p * t + f) * r;
|
|
2015
|
+
for (let t = 0; t < 3; t++) {
|
|
2016
|
+
let n = s ? s[e[g + t]] : e[g + t], r = s ? s[e[_ + t]] : e[_ + t], i = s ? s[e[v + t]] : e[v + t], a = s ? s[e[y + t]] : e[y + t], c = n * (1 - m) + r * m, l = i * (1 - m) + a * m;
|
|
2017
|
+
o[t] = c * (1 - h) + l * h;
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
function Fn(e, t, n = 1, r = 0) {
|
|
2021
|
+
let i = r || Math.min(e.width, 4096), a = Math.max(1, i >> 1), o = new Float32Array(i * a * 4), s = t ? J(t) : null, c = e.srgb ? Nn : null, l = [
|
|
2022
|
+
0,
|
|
2023
|
+
0,
|
|
2024
|
+
0
|
|
2025
|
+
];
|
|
2026
|
+
for (let t = 0; t < a; t++) {
|
|
2027
|
+
let r = (1 - (t + .5) / a) * Math.PI, u = Math.sin(r), d = Math.cos(r);
|
|
2028
|
+
for (let r = 0; r < i; r++) {
|
|
2029
|
+
let a = ((r + .5) / i - .5) * 2 * Math.PI, f = u * Math.cos(a), p = d, m = u * Math.sin(a);
|
|
2030
|
+
if (s) {
|
|
2031
|
+
let e = s, t = e[0] * f + e[4] * p + e[8] * m, n = e[1] * f + e[5] * p + e[9] * m, r = e[2] * f + e[6] * p + e[10] * m, i = Math.hypot(t, n, r) || 1;
|
|
2032
|
+
f = t / i, p = n / i, m = r / i;
|
|
2033
|
+
}
|
|
2034
|
+
let [h, g] = Mn(f, p, m);
|
|
2035
|
+
Pn(e.data, e.width, e.height, e.channels, h, e.bottomUp ? 1 - g : g, l, c);
|
|
2036
|
+
let _ = (t * i + r) * 4;
|
|
2037
|
+
o[_] = l[0] * n, o[_ + 1] = l[1] * n, o[_ + 2] = l[2] * n, o[_ + 3] = 1;
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
return {
|
|
2041
|
+
data: o,
|
|
2042
|
+
width: i,
|
|
2043
|
+
height: a
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
//#endregion
|
|
2047
|
+
//#region src/Processor/PBRT/PBRTCurves.js
|
|
2048
|
+
var In = 2;
|
|
2049
|
+
function Ln(e, t) {
|
|
2050
|
+
let n = e * e, r = n * e;
|
|
2051
|
+
t[0] = (1 - 3 * e + 3 * n - r) / 6, t[1] = (4 - 6 * n + 3 * r) / 6, t[2] = (1 + 3 * e + 3 * n - 3 * r) / 6, t[3] = r / 6;
|
|
2052
|
+
}
|
|
2053
|
+
function Rn(e, t) {
|
|
2054
|
+
let n = 1 - e;
|
|
2055
|
+
t[0] = n * n * n, t[1] = 3 * n * n * e, t[2] = 3 * n * e * e, t[3] = e * e * e;
|
|
2056
|
+
}
|
|
2057
|
+
function zn(e) {
|
|
2058
|
+
let t = Math.hypot(e[0], e[1], e[2]);
|
|
2059
|
+
return t > 0 && (e[0] /= t, e[1] /= t, e[2] /= t), e;
|
|
2060
|
+
}
|
|
2061
|
+
function Bn(e, t, n) {
|
|
2062
|
+
return n[0] = e[1] * t[2] - e[2] * t[1], n[1] = e[2] * t[0] - e[0] * t[2], n[2] = e[0] * t[1] - e[1] * t[0], n;
|
|
2063
|
+
}
|
|
2064
|
+
function Vn(e, t) {
|
|
2065
|
+
let n = e.length / 3;
|
|
2066
|
+
return t === "bspline" ? n - 3 : Math.max(1, (n - 1) / 3);
|
|
2067
|
+
}
|
|
2068
|
+
function Hn(e, t, n, r, i, a, o) {
|
|
2069
|
+
let s = Math.floor(r);
|
|
2070
|
+
s >= n && (s = n - 1);
|
|
2071
|
+
let c = r - s;
|
|
2072
|
+
t === "bspline" ? Ln(c, i) : Rn(c, i);
|
|
2073
|
+
let l = t === "bspline" ? s : s * 3, u = 0, d = 0, f = 0;
|
|
2074
|
+
for (let t = 0; t < 4; t++) {
|
|
2075
|
+
let n = (l + t) * 3;
|
|
2076
|
+
u += i[t] * e[n], d += i[t] * e[n + 1], f += i[t] * e[n + 2];
|
|
2077
|
+
}
|
|
2078
|
+
a[o] = u, a[o + 1] = d, a[o + 2] = f;
|
|
2079
|
+
}
|
|
2080
|
+
function Un(e, t, n) {
|
|
2081
|
+
let r = Vn(e, t);
|
|
2082
|
+
if (r < 1) return null;
|
|
2083
|
+
let i = Math.max(1, Math.round(n * r)), a = new Float64Array((i + 1) * 3), o = [
|
|
2084
|
+
0,
|
|
2085
|
+
0,
|
|
2086
|
+
0,
|
|
2087
|
+
0
|
|
2088
|
+
];
|
|
2089
|
+
for (let n = 0; n <= i; n++) Hn(e, t, r, n / i * r, o, a, n * 3);
|
|
2090
|
+
return {
|
|
2091
|
+
points: a,
|
|
2092
|
+
count: i + 1,
|
|
2093
|
+
spans: r
|
|
2094
|
+
};
|
|
2095
|
+
}
|
|
2096
|
+
function Wn(e, t, n, r, i) {
|
|
2097
|
+
let a = e[t * 3], o = e[t * 3 + 1], s = e[t * 3 + 2], c = n[r * 3], l = n[r * 3 + 1], u = n[r * 3 + 2], d = n[i * 3] - c, f = n[i * 3 + 1] - l, p = n[i * 3 + 2] - u, m = d * d + f * f + p * p, h = m > 0 ? ((a - c) * d + (o - l) * f + (s - u) * p) / m : 0;
|
|
2098
|
+
return h = h < 0 ? 0 : h > 1 ? 1 : h, Math.hypot(a - c - h * d, o - l - h * f, s - u - h * p);
|
|
2099
|
+
}
|
|
2100
|
+
function Gn(e, t, n, r, i, a) {
|
|
2101
|
+
let { points: o, count: s, spans: c } = n;
|
|
2102
|
+
if (s < 3) return null;
|
|
2103
|
+
let l = new Float64Array((s - 1) * 3), u = [
|
|
2104
|
+
0,
|
|
2105
|
+
0,
|
|
2106
|
+
0,
|
|
2107
|
+
0
|
|
2108
|
+
], d = s - 1;
|
|
2109
|
+
for (let n = 0; n < d; n++) Hn(e, t, c, (n + .5) / d * c, u, l, n * 3);
|
|
2110
|
+
let f = 0;
|
|
2111
|
+
for (let e = 0; e < d; e++) f = Math.max(f, Wn(l, e, o, e, e + 1));
|
|
2112
|
+
let p = (e) => Math.max(f, r * .5 * (i + (a - i) * (e / d))), m = (e, t) => {
|
|
2113
|
+
for (let n = e + 1; n < t; n++) if (Wn(o, n, o, e, t) > p(n)) return !1;
|
|
2114
|
+
for (let n = e; n < t; n++) if (Wn(l, n, o, e, t) > p(n + .5)) return !1;
|
|
2115
|
+
return !0;
|
|
2116
|
+
}, h = new Int32Array(s), g = 0;
|
|
2117
|
+
h[g++] = 0;
|
|
2118
|
+
for (let e = 0; e < d;) {
|
|
2119
|
+
let t = e + 1;
|
|
2120
|
+
for (; t < d && m(e, t + 1);) t++;
|
|
2121
|
+
h[g++] = t, e = t;
|
|
2122
|
+
}
|
|
2123
|
+
return g === s ? null : h.subarray(0, g);
|
|
2124
|
+
}
|
|
2125
|
+
function Kn(e) {
|
|
2126
|
+
let { P: t, basis: n = "bezier", width0: r = 1, width1: i = 1, N: a = null } = e, o = Math.max(1, Math.round(e.steps ?? In)), s = Math.max(1, Math.round(e.sides ?? 1));
|
|
2127
|
+
if (!t || t.length < 12) return null;
|
|
2128
|
+
let c = Un(t, n, o);
|
|
2129
|
+
if (!c) return null;
|
|
2130
|
+
let { points: l, count: u } = c, d = e.tolerance > 0 ? Gn(t, n, c, e.tolerance, r, i) : null, f = d ? d.length : u, p = s >= 3 ? s : s * 2, m = new Float32Array(f * p * 3), h = [
|
|
2131
|
+
0,
|
|
2132
|
+
0,
|
|
2133
|
+
0
|
|
2134
|
+
], g = [
|
|
2135
|
+
0,
|
|
2136
|
+
0,
|
|
2137
|
+
0
|
|
2138
|
+
], _ = [
|
|
2139
|
+
0,
|
|
2140
|
+
0,
|
|
2141
|
+
0
|
|
2142
|
+
], v = [
|
|
2143
|
+
0,
|
|
2144
|
+
0,
|
|
2145
|
+
0
|
|
2146
|
+
], y = !1, b = 0;
|
|
2147
|
+
for (let e = 0; e < u; e++) {
|
|
2148
|
+
let t = Math.max(0, e - 1), n = Math.min(u - 1, e + 1);
|
|
2149
|
+
if (h[0] = l[n * 3] - l[t * 3], h[1] = l[n * 3 + 1] - l[t * 3 + 1], h[2] = l[n * 3 + 2] - l[t * 3 + 2], zn(h), y) {
|
|
2150
|
+
let e = g[0] * h[0] + g[1] * h[1] + g[2] * h[2];
|
|
2151
|
+
g[0] -= e * h[0], g[1] -= e * h[1], g[2] -= e * h[2], Math.hypot(g[0], g[1], g[2]) < 1e-9 && Bn(h, [
|
|
2152
|
+
0,
|
|
2153
|
+
1,
|
|
2154
|
+
0
|
|
2155
|
+
], g), zn(g);
|
|
2156
|
+
} else {
|
|
2157
|
+
if (a && a.length >= 3) g[0] = a[0], g[1] = a[1], g[2] = a[2], Bn(h, g, v), g[0] = v[0], g[1] = v[1], g[2] = v[2];
|
|
2158
|
+
else {
|
|
2159
|
+
let e = Math.abs(h[0]), t = Math.abs(h[1]), n = Math.abs(h[2]);
|
|
2160
|
+
Bn(h, e < t && e < n ? [
|
|
2161
|
+
1,
|
|
2162
|
+
0,
|
|
2163
|
+
0
|
|
2164
|
+
] : t < n ? [
|
|
2165
|
+
0,
|
|
2166
|
+
1,
|
|
2167
|
+
0
|
|
2168
|
+
] : [
|
|
2169
|
+
0,
|
|
2170
|
+
0,
|
|
2171
|
+
1
|
|
2172
|
+
], g);
|
|
2173
|
+
}
|
|
2174
|
+
Math.hypot(g[0], g[1], g[2]) < 1e-9 && Bn(h, [
|
|
2175
|
+
0,
|
|
2176
|
+
1,
|
|
2177
|
+
0
|
|
2178
|
+
], g), zn(g), y = !0;
|
|
2179
|
+
}
|
|
2180
|
+
if (d && d[b] !== e) continue;
|
|
2181
|
+
Bn(h, g, _), zn(_);
|
|
2182
|
+
let o = e / (u - 1 || 1), c = (r + (i - r) * o) * .5, f = l[e * 3], x = l[e * 3 + 1], S = l[e * 3 + 2];
|
|
2183
|
+
for (let e = 0; e < p; e++) {
|
|
2184
|
+
let t, n, r;
|
|
2185
|
+
if (s >= 3) {
|
|
2186
|
+
let i = e / s * Math.PI * 2, a = Math.cos(i), o = Math.sin(i);
|
|
2187
|
+
t = g[0] * a + _[0] * o, n = g[1] * a + _[1] * o, r = g[2] * a + _[2] * o;
|
|
2188
|
+
} else {
|
|
2189
|
+
let i = e < 2 ? g : _, a = e % 2 == 0 ? -1 : 1;
|
|
2190
|
+
t = i[0] * a, n = i[1] * a, r = i[2] * a;
|
|
2191
|
+
}
|
|
2192
|
+
let i = (b * p + e) * 3;
|
|
2193
|
+
m[i] = f + t * c, m[i + 1] = x + n * c, m[i + 2] = S + r * c;
|
|
2194
|
+
}
|
|
2195
|
+
b++;
|
|
2196
|
+
}
|
|
2197
|
+
let x = s, S = new Uint32Array((f - 1) * x * 6), C = 0;
|
|
2198
|
+
for (let e = 0; e < f - 1; e++) for (let t = 0; t < x; t++) {
|
|
2199
|
+
let n = s >= 3 ? t : t * 2, r = s >= 3 ? (t + 1) % s : t * 2 + 1, i = e * p + n, a = e * p + r, o = (e + 1) * p + r, c = (e + 1) * p + n;
|
|
2200
|
+
S[C++] = i, S[C++] = a, S[C++] = o, S[C++] = i, S[C++] = o, S[C++] = c;
|
|
2201
|
+
}
|
|
2202
|
+
return {
|
|
2203
|
+
positions: m,
|
|
2204
|
+
indices: C === S.length ? S : U(S, C)
|
|
2205
|
+
};
|
|
2206
|
+
}
|
|
2207
|
+
//#endregion
|
|
2208
|
+
//#region src/Processor/PBRT/PBRTSceneBuilder.js
|
|
2209
|
+
var qn = new Set([
|
|
2210
|
+
"distant",
|
|
2211
|
+
"point",
|
|
2212
|
+
"spot"
|
|
2213
|
+
]);
|
|
2214
|
+
async function Jn(e, t, n) {
|
|
2215
|
+
let r = e[t];
|
|
2216
|
+
if (r?.type === "spectrum" && typeof r.value[0] == "string" && r.value[0].startsWith("stdillum")) return [
|
|
2217
|
+
1,
|
|
2218
|
+
1,
|
|
2219
|
+
1
|
|
2220
|
+
];
|
|
2221
|
+
let i = (await Q(e, t, n, [
|
|
2222
|
+
1,
|
|
2223
|
+
1,
|
|
2224
|
+
1
|
|
2225
|
+
])).rgb || [
|
|
2226
|
+
1,
|
|
2227
|
+
1,
|
|
2228
|
+
1
|
|
2229
|
+
];
|
|
2230
|
+
if (!r || r.type === "rgb" || r.type === "color" || r.type === "float") return i;
|
|
2231
|
+
let a = .2126 * i[0] + .7152 * i[1] + .0722 * i[2];
|
|
2232
|
+
return a > 0 ? i.map((e) => e / a) : i;
|
|
2233
|
+
}
|
|
2234
|
+
var $ = [
|
|
2235
|
+
1,
|
|
2236
|
+
0,
|
|
2237
|
+
0,
|
|
2238
|
+
0,
|
|
2239
|
+
0,
|
|
2240
|
+
1,
|
|
2241
|
+
0,
|
|
2242
|
+
0,
|
|
2243
|
+
0,
|
|
2244
|
+
0,
|
|
2245
|
+
-1,
|
|
2246
|
+
0,
|
|
2247
|
+
0,
|
|
2248
|
+
0,
|
|
2249
|
+
0,
|
|
2250
|
+
1
|
|
2251
|
+
], Yn = 4096;
|
|
2252
|
+
function Xn(e) {
|
|
2253
|
+
return e instanceof Uint32Array ? new I(e, 1) : ArrayBuffer.isView(e) && e.BYTES_PER_ELEMENT === 4 ? new I(new Uint32Array(e.buffer, e.byteOffset, e.length), 1) : new I(Uint32Array.from(e), 1);
|
|
2254
|
+
}
|
|
2255
|
+
function Zn(e, t) {
|
|
2256
|
+
if (t <= e.length) return e;
|
|
2257
|
+
let n = e.length || 1;
|
|
2258
|
+
for (; n < t;) n *= 2;
|
|
2259
|
+
return U(e, n);
|
|
2260
|
+
}
|
|
2261
|
+
function Qn(e) {
|
|
2262
|
+
return e instanceof Float32Array ? e : Float32Array.from(e);
|
|
2263
|
+
}
|
|
2264
|
+
var $n = 1e3, er = 45e6, tr = 6e6, nr = 256, rr = 4096, ir = 5e5, ar = 2, or = {
|
|
2265
|
+
flat: 1,
|
|
2266
|
+
ribbon: 1,
|
|
2267
|
+
cylinder: 2
|
|
2268
|
+
}, sr = .05;
|
|
2269
|
+
function cr(e, t) {
|
|
2270
|
+
if (e.count !== t.count) return !1;
|
|
2271
|
+
for (let n = 0, r = e.count * 16; n < r; n++) if (e.matrices[n] !== t.matrices[n]) return !1;
|
|
2272
|
+
return !0;
|
|
2273
|
+
}
|
|
2274
|
+
function lr(e, t) {
|
|
2275
|
+
let n = Math.min(e.width, Yn), r = null;
|
|
2276
|
+
if (typeof OffscreenCanvas < "u") r = new OffscreenCanvas(n, n);
|
|
2277
|
+
else if (typeof document < "u") r = document.createElement("canvas"), r.width = r.height = n;
|
|
2278
|
+
else return null;
|
|
2279
|
+
try {
|
|
2280
|
+
let i = r.getContext("2d", { willReadFrequently: !0 });
|
|
2281
|
+
if (!i) return null;
|
|
2282
|
+
i.drawImage(e, 0, 0, n, n);
|
|
2283
|
+
let { data: a } = i.getImageData(0, 0, n, n);
|
|
2284
|
+
return {
|
|
2285
|
+
data: a,
|
|
2286
|
+
width: n,
|
|
2287
|
+
height: n,
|
|
2288
|
+
channels: 4,
|
|
2289
|
+
bottomUp: !1,
|
|
2290
|
+
srgb: t
|
|
2291
|
+
};
|
|
2292
|
+
} catch {
|
|
2293
|
+
return null;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
function ur(e) {
|
|
2297
|
+
let t = e?.image;
|
|
2298
|
+
if (!t) return null;
|
|
2299
|
+
if (ArrayBuffer.isView(t.data)) return {
|
|
2300
|
+
data: t.data,
|
|
2301
|
+
width: t.width,
|
|
2302
|
+
height: t.height,
|
|
2303
|
+
channels: 4,
|
|
2304
|
+
topDown: e.flipY === !0,
|
|
2305
|
+
float: !(t.data instanceof Uint8Array || t.data instanceof Uint8ClampedArray)
|
|
2306
|
+
};
|
|
2307
|
+
let { width: n, height: r } = t;
|
|
2308
|
+
if (!n || !r) return null;
|
|
2309
|
+
let i = null;
|
|
2310
|
+
if (typeof OffscreenCanvas < "u") i = new OffscreenCanvas(n, r);
|
|
2311
|
+
else if (typeof document < "u") i = document.createElement("canvas"), i.width = n, i.height = r;
|
|
2312
|
+
else return null;
|
|
2313
|
+
try {
|
|
2314
|
+
let e = i.getContext("2d", { willReadFrequently: !0 });
|
|
2315
|
+
return e ? (e.drawImage(t, 0, 0), {
|
|
2316
|
+
data: e.getImageData(0, 0, n, r).data,
|
|
2317
|
+
width: n,
|
|
2318
|
+
height: r,
|
|
2319
|
+
channels: 4,
|
|
2320
|
+
topDown: !0,
|
|
2321
|
+
float: !1
|
|
2322
|
+
}) : null;
|
|
2323
|
+
} catch {
|
|
2324
|
+
return null;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
function dr(e) {
|
|
2328
|
+
let t = Z(e, "encoding", "sRGB");
|
|
2329
|
+
if (t === "linear") return (e) => e;
|
|
2330
|
+
let n = /^gamma\s+([\d.]+)$/.exec(t);
|
|
2331
|
+
return n ? (e) => e ** Number(n[1]) : yn;
|
|
2332
|
+
}
|
|
2333
|
+
function fr(e) {
|
|
2334
|
+
return {
|
|
2335
|
+
su: X(e, "uscale", 1),
|
|
2336
|
+
sv: X(e, "vscale", 1),
|
|
2337
|
+
du: X(e, "udelta", 0),
|
|
2338
|
+
dv: X(e, "vdelta", 0)
|
|
2339
|
+
};
|
|
2340
|
+
}
|
|
2341
|
+
function pr(e, { su: t, sv: n, du: r, dv: i }) {
|
|
2342
|
+
e.repeat.set(t, n), e.offset.set(r, i);
|
|
2343
|
+
}
|
|
2344
|
+
function mr(e, { srgb: t }) {
|
|
2345
|
+
let n = e?.image?.data;
|
|
2346
|
+
if (!ArrayBuffer.isView(n) || n instanceof Uint8Array || n instanceof Uint8ClampedArray) return e;
|
|
2347
|
+
let { width: r, height: i } = e.image, a = new Uint8Array(r * i * 4), o = n.length / (r * i);
|
|
2348
|
+
for (let e = 0; e < r * i; e++) for (let r = 0; r < 4; r++) {
|
|
2349
|
+
let i = r < o ? Math.min(1, Math.max(0, n[e * o + r])) : 1;
|
|
2350
|
+
a[e * 4 + r] = Math.round(255 * (t && r < 3 ? bn(i) : i));
|
|
2351
|
+
}
|
|
2352
|
+
let s = new b(a, r, i, P);
|
|
2353
|
+
return s.flipY = e.flipY, s.colorSpace = t ? F : ne, s.wrapS = s.wrapT = ue, s.needsUpdate = !0, s;
|
|
2354
|
+
}
|
|
2355
|
+
function hr({ data: e, width: t, height: n, mapping: r }) {
|
|
2356
|
+
let i = new b(e, t, n, P);
|
|
2357
|
+
return i.colorSpace = F, i.wrapS = i.wrapT = ue, pr(i, r), i.needsUpdate = !0, i;
|
|
2358
|
+
}
|
|
2359
|
+
function gr(e) {
|
|
2360
|
+
let t = [e], n = e, r = [
|
|
2361
|
+
(e) => e.replace(/-renamed-\d+$/, ""),
|
|
2362
|
+
(e) => e.replace(/\d+$/, ""),
|
|
2363
|
+
(e) => e.replace(/_Color$/i, ""),
|
|
2364
|
+
(e) => e.replace(/\d+$/, "")
|
|
2365
|
+
];
|
|
2366
|
+
for (let e of r) {
|
|
2367
|
+
let r = e(n);
|
|
2368
|
+
r !== n && r && t.push(n = r);
|
|
2369
|
+
}
|
|
2370
|
+
return t;
|
|
2371
|
+
}
|
|
2372
|
+
var _r = class {
|
|
2373
|
+
constructor(e = {}) {
|
|
2374
|
+
this.maxTriangles = e.maxTriangles ?? er, this.maxPlacements = e.maxPlacements ?? tr, this.mergeShapesAbove = e.mergeShapesAbove ?? nr, this.curveSteps = e.curveSteps ?? ar, this.curveSides = e.curveSides ?? null, this.curveTolerance = e.curveTolerance ?? sr, this.resolvePLY = e.resolvePLY || (async () => null), this.resolveImage = e.resolveImage || (async () => null), this.resolveEnvironment = e.resolveEnvironment || e.resolveImage || (async () => null), this.convertHandedness = e.convertHandedness === !0, this.warnings = [], this.report = [], this._materialCache = /* @__PURE__ */ new Map(), this._textureCache = /* @__PURE__ */ new Map(), this._geometryCache = /* @__PURE__ */ new Map(), this._materialBySignature = /* @__PURE__ */ new Map(), this._noUVMaterials = /* @__PURE__ */ new Map(), this._plyCache = /* @__PURE__ */ new Map(), this._imageCache = /* @__PURE__ */ new Map(), this._termCache = /* @__PURE__ */ new Map(), this._mediumMaterials = /* @__PURE__ */ new Map();
|
|
2375
|
+
}
|
|
2376
|
+
warn(e) {
|
|
2377
|
+
this.warnings.push(e);
|
|
2378
|
+
}
|
|
2379
|
+
async build(e) {
|
|
2380
|
+
this.ir = e, this._keepShapes = /* @__PURE__ */ new Set();
|
|
2381
|
+
for (let { name: t } of e.animatedInstances ?? []) for (let n of e.objects.get(t) ?? []) this._keepShapes.add(n);
|
|
2382
|
+
this._plyUsers = /* @__PURE__ */ new Map(), this._plyHeld = /* @__PURE__ */ new Set();
|
|
2383
|
+
for (let t of e.shapes) if (t?.type === "plymesh") {
|
|
2384
|
+
let e = Z(t.params, "filename", null);
|
|
2385
|
+
this._plyUsers.set(e, (this._plyUsers.get(e) ?? 0) + 1);
|
|
2386
|
+
}
|
|
2387
|
+
for (let t of e.objects.values()) for (let e of t) e.type === "plymesh" && this._plyHeld.add(Z(e.params, "filename", null));
|
|
2388
|
+
this._recoveredColors = 0, this.reportedMeshes = 0, this.triangleCount = 0, this.placementCount = 0, this.skippedForBudget = 0, this._countedGeometries = /* @__PURE__ */ new WeakSet();
|
|
2389
|
+
let t = new D();
|
|
2390
|
+
t.name = "PBRTScene", this._batches = e.shapes.length >= this.mergeShapesAbove ? /* @__PURE__ */ new Map() : null, this._mergedBatches = 0, this.mergedShapes = 0, this.droppedNoTemplate = 0, this._animated = [];
|
|
2391
|
+
for (let n = 0; n < e.shapes.length; n++) {
|
|
2392
|
+
if (this._overBudget()) {
|
|
2393
|
+
this.skippedForBudget += e.shapes.length - n;
|
|
2394
|
+
break;
|
|
2395
|
+
}
|
|
2396
|
+
let r = e.shapes[n], [i, a] = await Promise.all([this._batches ? this._createGeometry(r) : this._buildGeometry(r), this._getMaterial(r)]);
|
|
2397
|
+
if (!i) continue;
|
|
2398
|
+
if (this._batches && !r.motion && i.getAttribute("position").count <= rr) {
|
|
2399
|
+
this._mergeShape(r, i, a, t), e.shapes[n] = null;
|
|
2400
|
+
continue;
|
|
2401
|
+
}
|
|
2402
|
+
r.type === "plymesh" && this._plyHeld.add(Z(r.params, "filename", null));
|
|
2403
|
+
let o = this._meshFromGeometry(r, i, a, r.ctm, `shape_${n}`);
|
|
2404
|
+
o && (t.add(o), r.motion && this._animate(o, r.motion));
|
|
2405
|
+
}
|
|
2406
|
+
if (this._batches) {
|
|
2407
|
+
for (let e of this._batches.values()) this._flushBatch(e[0], t), this._flushBatch(e[1], t);
|
|
2408
|
+
this._batches = null;
|
|
2409
|
+
}
|
|
2410
|
+
await this._buildInstances(e, t), await this._buildAnimatedPlacements(e, t), this.skippedForBudget > 0 && this.warn(`stopped at ${this.triangleCount.toLocaleString()} stored triangles (budget ${this.maxTriangles.toLocaleString()}) and ${this.placementCount.toLocaleString()} placements (budget ${this.maxPlacements.toLocaleString()}); ${this.skippedForBudget.toLocaleString()} placement(s) skipped`);
|
|
2411
|
+
let n = null;
|
|
2412
|
+
e.camera && (n = this._buildCamera(e.camera, e.film), n && t.add(n));
|
|
2413
|
+
let r = e.animation ? this._buildClip(e, n) : [], i = await this._buildEnvironment(e.lights);
|
|
2414
|
+
return await this._buildLamps(e.lights, t), this._reportUnsupportedLights(e.lights), this._recoveredColors > 0 && this.warn(`${this._recoveredColors} unreadable texture(s) fell back to the like-named material's colour`), {
|
|
2415
|
+
group: t,
|
|
2416
|
+
camera: n,
|
|
2417
|
+
environment: i,
|
|
2418
|
+
animations: r,
|
|
2419
|
+
report: this.report,
|
|
2420
|
+
meshCount: this.reportedMeshes,
|
|
2421
|
+
triangleCount: this.triangleCount,
|
|
2422
|
+
placementCount: this.placementCount,
|
|
2423
|
+
mergedShapes: this.mergedShapes,
|
|
2424
|
+
droppedNoTemplate: this.droppedNoTemplate,
|
|
2425
|
+
skippedForBudget: this.skippedForBudget,
|
|
2426
|
+
warnings: this.warnings.concat(e.warnings || [])
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
_overBudget() {
|
|
2430
|
+
return this.triangleCount >= this.maxTriangles || this.placementCount >= this.maxPlacements;
|
|
2431
|
+
}
|
|
2432
|
+
_accountGeometry(e) {
|
|
2433
|
+
let t = e.index ? e.index.count / 3 : e.getAttribute("position").count / 3;
|
|
2434
|
+
return this._countedGeometries.has(e) || (this._countedGeometries.add(e), this.triangleCount += t), t;
|
|
2435
|
+
}
|
|
2436
|
+
async _buildInstances(e, t) {
|
|
2437
|
+
let n = 0;
|
|
2438
|
+
e.skippedInstances > 0 && (this.skippedForBudget += e.skippedInstances);
|
|
2439
|
+
let r = new Float64Array(16), i = new N(), a = (e, a, o, s, c, l, u) => {
|
|
2440
|
+
let d = Math.max(0, this.maxPlacements - this.placementCount), f = Math.min(e.count, d);
|
|
2441
|
+
if (f < e.count && (this.skippedForBudget += e.count - f), f === 0) return;
|
|
2442
|
+
let p = new k(a, o, f);
|
|
2443
|
+
p.name = `instance_${n++}`, p.frustumCulled = !1;
|
|
2444
|
+
for (let t = 0; t < f; t++) {
|
|
2445
|
+
if (s) qt(r, e.matrices, t * 16, s);
|
|
2446
|
+
else for (let n = 0; n < 16; n++) r[n] = e.matrices[t * 16 + n];
|
|
2447
|
+
p.setMatrixAt(t, i.fromArray(this.convertHandedness ? q($, r) : r));
|
|
2448
|
+
}
|
|
2449
|
+
p.instanceMatrix.needsUpdate = !0, t.add(p), this.placementCount += f, this.reportedMeshes += f, this.report.length < $n && this.report.push({
|
|
2450
|
+
mesh: `${p.name} ×${f}`,
|
|
2451
|
+
shape: c,
|
|
2452
|
+
material: l,
|
|
2453
|
+
color: "#" + o.color.getHexString(),
|
|
2454
|
+
map: o.map ? "yes" : "-",
|
|
2455
|
+
uv: a.getAttribute("uv") ? "yes" : "NO",
|
|
2456
|
+
normals: a.getAttribute("normal") ? "yes" : "NO",
|
|
2457
|
+
emissive: o.emissiveIntensity > 0 ? `#${o.emissive.getHexString()}×${o.emissiveIntensity}` : "-",
|
|
2458
|
+
size: "instanced",
|
|
2459
|
+
tris: u
|
|
2460
|
+
});
|
|
2461
|
+
}, o = (e, t) => {
|
|
2462
|
+
t && t.triangles > 0 && a(e, this._batchGeometry(t), t.material, null, "merged", "-", t.triangles);
|
|
2463
|
+
};
|
|
2464
|
+
for (let { name: t, list: n, template: r } of this._samePlacementGroups(e)) {
|
|
2465
|
+
if (!r) {
|
|
2466
|
+
this.droppedNoTemplate += n.count, this.warn(`ObjectInstance "${t}" has no template — ${n.count.toLocaleString()} placement(s) dropped`);
|
|
2467
|
+
continue;
|
|
2468
|
+
}
|
|
2469
|
+
let e = 0;
|
|
2470
|
+
for (let t of r) t.type !== "plymesh" && e++;
|
|
2471
|
+
let i = e >= 2 ? /* @__PURE__ */ new Map() : null;
|
|
2472
|
+
for (let e of r) {
|
|
2473
|
+
if (this._overBudget()) {
|
|
2474
|
+
this.skippedForBudget += n.count;
|
|
2475
|
+
continue;
|
|
2476
|
+
}
|
|
2477
|
+
let [r, s] = await Promise.all([this._buildGeometry(e), this._getMaterial(e)]);
|
|
2478
|
+
if (!r) continue;
|
|
2479
|
+
if (i && e.type !== "plymesh" && r.getAttribute("position").count <= rr) {
|
|
2480
|
+
this._geometryCache.delete(e);
|
|
2481
|
+
let t = this._appendToBatch(i, e, r, s, e.relativeCTM || e.ctm);
|
|
2482
|
+
this._releaseMerged(e, r), o(n, t);
|
|
2483
|
+
continue;
|
|
2484
|
+
}
|
|
2485
|
+
let c = this._accountGeometry(r);
|
|
2486
|
+
a(n, r, this._materialForGeometry(e, r, s, `instances_${t}`), e.relativeCTM || e.ctm, e.type, e.material?.type || "diffuse", c);
|
|
2487
|
+
}
|
|
2488
|
+
if (i) for (let e of i.values()) o(n, e[0]), o(n, e[1]);
|
|
2489
|
+
H(n.matrices), H(n.matricesEnd);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2492
|
+
_samePlacementGroups(e) {
|
|
2493
|
+
let t = [], n = /* @__PURE__ */ new Map();
|
|
2494
|
+
for (let [r, i] of e.instances) {
|
|
2495
|
+
let a = e.objects.get(r);
|
|
2496
|
+
if (!a || i.matricesEnd) {
|
|
2497
|
+
t.push({
|
|
2498
|
+
name: r,
|
|
2499
|
+
list: i,
|
|
2500
|
+
template: a
|
|
2501
|
+
});
|
|
2502
|
+
continue;
|
|
2503
|
+
}
|
|
2504
|
+
let o = `${i.count}:${Array.prototype.join.call(i.matrices.subarray(0, 16), ",")}`, s = n.get(o);
|
|
2505
|
+
s || n.set(o, s = []);
|
|
2506
|
+
let c = s.find((e) => cr(e.list, i));
|
|
2507
|
+
if (c) {
|
|
2508
|
+
c.template === e.objects.get(c.name) && (c.template = c.template.slice());
|
|
2509
|
+
for (let e of a) c.template.push(e);
|
|
2510
|
+
H(i.matrices);
|
|
2511
|
+
continue;
|
|
2512
|
+
}
|
|
2513
|
+
let l = {
|
|
2514
|
+
name: r,
|
|
2515
|
+
list: i,
|
|
2516
|
+
template: a
|
|
2517
|
+
};
|
|
2518
|
+
s.push(l), t.push(l);
|
|
2519
|
+
}
|
|
2520
|
+
return t;
|
|
2521
|
+
}
|
|
2522
|
+
async _buildAnimatedPlacements(e, t) {
|
|
2523
|
+
let n = e.animatedInstances ?? [];
|
|
2524
|
+
for (let r = 0; r < n.length; r++) {
|
|
2525
|
+
let { name: i, motion: a } = n[r], o = e.objects.get(i);
|
|
2526
|
+
if (!o) {
|
|
2527
|
+
this.droppedNoTemplate++;
|
|
2528
|
+
continue;
|
|
2529
|
+
}
|
|
2530
|
+
if (this._overBudget()) {
|
|
2531
|
+
this.skippedForBudget += n.length - r;
|
|
2532
|
+
break;
|
|
2533
|
+
}
|
|
2534
|
+
let s = new D();
|
|
2535
|
+
s.name = `placement_${r}`;
|
|
2536
|
+
let c = Array.from(a.matrices.subarray(0, 16));
|
|
2537
|
+
new N().fromArray(this.convertHandedness ? q($, c) : c).decompose(s.position, s.quaternion, s.scale);
|
|
2538
|
+
for (let e = 0; e < o.length; e++) {
|
|
2539
|
+
let t = o[e], [n, r] = await Promise.all([this._buildGeometry(t), this._getMaterial(t)]);
|
|
2540
|
+
if (!n) continue;
|
|
2541
|
+
let i = this._meshFromGeometry(t, n, r, t.relativeCTM || t.ctm, `${s.name}_${e}`, !0);
|
|
2542
|
+
i && s.add(i);
|
|
2543
|
+
}
|
|
2544
|
+
s.children.length !== 0 && (t.add(s), this._animate(s, a));
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
_animate(e, t) {
|
|
2548
|
+
t.visible && (e.visible = t.visible[0] === 1), this._animated.push({
|
|
2549
|
+
node: e,
|
|
2550
|
+
motion: t
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
_buildClip(e, t) {
|
|
2554
|
+
let n = [];
|
|
2555
|
+
for (let { node: e, motion: t } of this._animated) if (this._transformTracks(n, e.name, t, (e, t) => {
|
|
2556
|
+
let n = Array.from(e.subarray(t, t + 16));
|
|
2557
|
+
return this.convertHandedness ? q($, n) : n;
|
|
2558
|
+
}), t.visible) {
|
|
2559
|
+
let r = t.times, i = r.map((e, t) => t === 0 ? 0 : (r[t - 1] + e) / 2);
|
|
2560
|
+
n.push(new g(`${e.name}.visible`, i, Array.from(t.visible, (e) => e === 1)));
|
|
2561
|
+
}
|
|
2562
|
+
let r = e.camera?.motion;
|
|
2563
|
+
if (t && r) {
|
|
2564
|
+
let e = new oe();
|
|
2565
|
+
if (this._transformTracks(n, t.name, r, (t, n) => (this._poseCamera(e, t.subarray(n, n + 16)), e.updateMatrix(), e.matrix.elements)), r.fov && t.isPerspectiveCamera) {
|
|
2566
|
+
let e = Array.from(r.fov, (e) => this._verticalFov({ fov: {
|
|
2567
|
+
type: "float",
|
|
2568
|
+
value: [e]
|
|
2569
|
+
} }, t.aspect));
|
|
2570
|
+
n.push(new re(`${t.name}.fov`, r.times.slice(), e));
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
for (let e of n) e.optimize();
|
|
2574
|
+
return n.length === 0 ? [] : [new h(e.animation.name, e.animation.duration, n)];
|
|
2575
|
+
}
|
|
2576
|
+
_transformTracks(e, t, n, r) {
|
|
2577
|
+
let i = n.times.length, a = new Float32Array(i * 3), o = new Float32Array(i * 4), s = new Float32Array(i * 3), c = new N(), l = new L(), u = new ce(), d = new L();
|
|
2578
|
+
for (let e = 0; e < i; e++) c.fromArray(r(n.matrices, e * 16)).decompose(l, u, d), e > 0 && u.x * o[e * 4 - 4] + u.y * o[e * 4 - 3] + u.z * o[e * 4 - 2] + u.w * o[e * 4 - 1] < 0 && u.set(-u.x, -u.y, -u.z, -u.w), l.toArray(a, e * 3), u.toArray(o, e * 4), d.toArray(s, e * 3);
|
|
2579
|
+
let f = (e, t) => {
|
|
2580
|
+
for (let n = t; n < e.length; n++) if (e[n] !== e[n % t]) return !0;
|
|
2581
|
+
return !1;
|
|
2582
|
+
};
|
|
2583
|
+
f(a, 3) && e.push(new me(`${t}.position`, n.times.slice(), a)), f(o, 4) && e.push(new le(`${t}.quaternion`, n.times.slice(), o)), f(s, 3) && e.push(new me(`${t}.scale`, n.times.slice(), s));
|
|
2584
|
+
}
|
|
2585
|
+
async _buildShapeMesh(e, t, n) {
|
|
2586
|
+
let [r, i] = await Promise.all([this._buildGeometry(e), this._getMaterial(e)]);
|
|
2587
|
+
return r ? this._meshFromGeometry(e, r, i, t, n) : null;
|
|
2588
|
+
}
|
|
2589
|
+
_meshFromGeometry(e, t, n, r, i, a = !1) {
|
|
2590
|
+
let o = !!t.getAttribute("uv"), s = this._materialForGeometry(e, t, n, i), c = new ee(t, s);
|
|
2591
|
+
c.name = i;
|
|
2592
|
+
let l = this.convertHandedness && !a ? q($, r) : r;
|
|
2593
|
+
new N().fromArray(l).decompose(c.position, c.quaternion, c.scale), c.updateMatrix(), t.boundingBox || t.computeBoundingBox();
|
|
2594
|
+
let u = t.boundingBox ? t.boundingBox.clone().applyMatrix4(c.matrix).getSize(new L()) : new L(), d = this._accountGeometry(t);
|
|
2595
|
+
return this.placementCount++, this.reportedMeshes++, this.report.length < $n && this.report.push({
|
|
2596
|
+
mesh: i,
|
|
2597
|
+
shape: e.type,
|
|
2598
|
+
material: e.material?.type || "diffuse",
|
|
2599
|
+
color: "#" + s.color.getHexString(),
|
|
2600
|
+
map: s.map ? "yes" : "-",
|
|
2601
|
+
uv: o ? "yes" : "NO",
|
|
2602
|
+
normals: t.getAttribute("normal") ? "yes" : "NO",
|
|
2603
|
+
emissive: s.emissiveIntensity > 0 ? `#${s.emissive.getHexString()}×${s.emissiveIntensity}` : "-",
|
|
2604
|
+
size: `${u.x.toFixed(2)}×${u.y.toFixed(2)}×${u.z.toFixed(2)}`,
|
|
2605
|
+
tris: d
|
|
2606
|
+
}), c;
|
|
2607
|
+
}
|
|
2608
|
+
_materialForGeometry(e, t, n, r) {
|
|
2609
|
+
if (!n.map || t.getAttribute("uv")) return n;
|
|
2610
|
+
let i = this._noUVMaterials.get(n);
|
|
2611
|
+
return i || (this.warn(`${r} (${e.type}, "${e.material?.type || "diffuse"}") has a texture map but no UVs — dropping map, using base color`), i = n.clone(), i.map = null, this._noUVMaterials.set(n, i)), i;
|
|
2612
|
+
}
|
|
2613
|
+
_mergeShape(e, t, n, r) {
|
|
2614
|
+
this.reportedMeshes++;
|
|
2615
|
+
let i = this.convertHandedness ? q($, e.ctm) : e.ctm, a = this._appendToBatch(this._batches, e, t, n, i);
|
|
2616
|
+
this._releaseMerged(e, t), a && this._flushBatch(a, r);
|
|
2617
|
+
}
|
|
2618
|
+
_releaseMerged(e, t) {
|
|
2619
|
+
if (!this._keepShapes?.has(e) && !(e.type === "plymesh" && !this._lastPlyUse(Z(e.params, "filename", null)))) {
|
|
2620
|
+
for (let e in t.attributes) H(t.attributes[e].array);
|
|
2621
|
+
H(t.index?.array);
|
|
2622
|
+
for (let t in e.params) ArrayBuffer.isView(e.params[t]?.value) && H(e.params[t].value);
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
_lastPlyUse(e) {
|
|
2626
|
+
let t = (this._plyUsers.get(e) ?? 1) - 1;
|
|
2627
|
+
return this._plyUsers.set(e, t), t > 0 || this._plyHeld.has(e) ? !1 : (this._plyCache.delete(e), !0);
|
|
2628
|
+
}
|
|
2629
|
+
_appendToBatch(e, t, n, r, i) {
|
|
2630
|
+
let a = this._materialForGeometry(t, n, r, "merged shape"), o = n.getAttribute("position"), s = n.getAttribute("normal"), c = n.getAttribute("uv"), l = n.index, u = o.count;
|
|
2631
|
+
this.triangleCount += (l ? l.count : u) / 3, this.mergedShapes++;
|
|
2632
|
+
let d = e.get(a);
|
|
2633
|
+
d || e.set(a, d = [null, null]);
|
|
2634
|
+
let f = +!!c, p = d[f];
|
|
2635
|
+
p || (d[f] = p = {
|
|
2636
|
+
material: a,
|
|
2637
|
+
positions: new Float32Array(3072),
|
|
2638
|
+
normals: new Float32Array(3072),
|
|
2639
|
+
uvs: c ? new Float32Array(2048) : null,
|
|
2640
|
+
indices: new Uint32Array(3072),
|
|
2641
|
+
vertexCount: 0,
|
|
2642
|
+
indexCount: 0,
|
|
2643
|
+
triangles: 0
|
|
2644
|
+
});
|
|
2645
|
+
let m = i, h = J(m), g = p.vertexCount;
|
|
2646
|
+
p.positions = Zn(p.positions, (g + u) * 3), p.normals = Zn(p.normals, (g + u) * 3), c && (p.uvs = Zn(p.uvs, (g + u) * 2));
|
|
2647
|
+
let _ = o.array, v = p.positions, y = s ? s.array : null, b = p.normals;
|
|
2648
|
+
for (let e = 0; e < u; e++) {
|
|
2649
|
+
let t = e * 3, n = (g + e) * 3, r = _[t], i = _[t + 1], a = _[t + 2];
|
|
2650
|
+
if (v[n] = m[0] * r + m[4] * i + m[8] * a + m[12], v[n + 1] = m[1] * r + m[5] * i + m[9] * a + m[13], v[n + 2] = m[2] * r + m[6] * i + m[10] * a + m[14], !y) continue;
|
|
2651
|
+
let o = y[t], s = y[t + 1], c = y[t + 2], l = h[0] * o + h[1] * s + h[2] * c, u = h[4] * o + h[5] * s + h[6] * c, d = h[8] * o + h[9] * s + h[10] * c, f = Math.hypot(l, u, d);
|
|
2652
|
+
f > 0 && (l /= f, u /= f, d /= f), b[n] = l, b[n + 1] = u, b[n + 2] = d;
|
|
2653
|
+
}
|
|
2654
|
+
c && p.uvs.set(c.array.subarray(0, u * 2), g * 2);
|
|
2655
|
+
let x = l ? l.count : u;
|
|
2656
|
+
p.indices = Zn(p.indices, p.indexCount + x);
|
|
2657
|
+
let S = p.indices, C = l ? l.array : null;
|
|
2658
|
+
for (let e = 0; e < x; e++) S[p.indexCount + e] = g + (C ? C[e] : e);
|
|
2659
|
+
return p.vertexCount += u, p.indexCount += x, p.triangles += x / 3, p.triangles >= ir ? (d[f] = null, p) : null;
|
|
2660
|
+
}
|
|
2661
|
+
_batchGeometry(e) {
|
|
2662
|
+
let t = new v();
|
|
2663
|
+
return t.setAttribute("position", new w(U(e.positions, e.vertexCount * 3), 3)), t.setAttribute("normal", new w(U(e.normals, e.vertexCount * 3), 3)), e.uvs && t.setAttribute("uv", new w(U(e.uvs, e.vertexCount * 2), 2)), t.setIndex(new I(U(e.indices, e.indexCount), 1)), e.positions = e.normals = e.uvs = e.indices = null, t;
|
|
2664
|
+
}
|
|
2665
|
+
_flushBatch(e, t) {
|
|
2666
|
+
if (!e || e.triangles === 0) return;
|
|
2667
|
+
let n = new ee(this._batchGeometry(e), e.material);
|
|
2668
|
+
n.name = `merged_${this._mergedBatches++}`, n.frustumCulled = !1, t.add(n), this.placementCount++, this.report.length < $n && this.report.push({
|
|
2669
|
+
mesh: n.name,
|
|
2670
|
+
shape: "merged",
|
|
2671
|
+
material: "-",
|
|
2672
|
+
color: "#" + e.material.color.getHexString(),
|
|
2673
|
+
map: e.material.map ? "yes" : "-",
|
|
2674
|
+
uv: e.uvs ? "yes" : "NO",
|
|
2675
|
+
normals: "yes",
|
|
2676
|
+
emissive: e.material.emissiveIntensity > 0 ? `#${e.material.emissive.getHexString()}×${e.material.emissiveIntensity}` : "-",
|
|
2677
|
+
size: "merged",
|
|
2678
|
+
tris: e.triangles
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
_buildGeometry(e) {
|
|
2682
|
+
let t = this._geometryCache.get(e);
|
|
2683
|
+
return t || this._geometryCache.set(e, t = this._createGeometry(e)), t;
|
|
2684
|
+
}
|
|
2685
|
+
async _createGeometry(e) {
|
|
2686
|
+
let t = await this._shapeGeometry(e);
|
|
2687
|
+
return t && e.areaLight && !fn(e.areaLight.params, "twosided", !1) ? this._facingEmission(e, t) : t;
|
|
2688
|
+
}
|
|
2689
|
+
_facingEmission(e, t) {
|
|
2690
|
+
let n = t.userData.pbrtNormals ? t.getAttribute("normal") : null;
|
|
2691
|
+
if (!n && !e.reverseOrientation) return t;
|
|
2692
|
+
let r = t.getAttribute("position").array, i = n?.array, a = t.index?.array ?? null, o = a ? a.length : t.getAttribute("position").count, s = new Uint32Array(o), c = 0;
|
|
2693
|
+
for (let t = 0; t + 2 < o; t += 3) {
|
|
2694
|
+
let n = a ? a[t] : t, o = a ? a[t + 1] : t + 1, l = a ? a[t + 2] : t + 2, u = e.reverseOrientation;
|
|
2695
|
+
if (i) {
|
|
2696
|
+
let e = r[o * 3] - r[n * 3], t = r[o * 3 + 1] - r[n * 3 + 1], a = r[o * 3 + 2] - r[n * 3 + 2], s = r[l * 3] - r[n * 3], c = r[l * 3 + 1] - r[n * 3 + 1], d = r[l * 3 + 2] - r[n * 3 + 2], f = i[n * 3] + i[o * 3] + i[l * 3], p = i[n * 3 + 1] + i[o * 3 + 1] + i[l * 3 + 1], m = i[n * 3 + 2] + i[o * 3 + 2] + i[l * 3 + 2];
|
|
2697
|
+
u = (t * d - a * c) * f + (a * s - e * d) * p + (e * c - t * s) * m < 0;
|
|
2698
|
+
}
|
|
2699
|
+
s[t] = n, s[t + 1] = u ? l : o, s[t + 2] = u ? o : l, u && c++;
|
|
2700
|
+
}
|
|
2701
|
+
if (c === 0) return t;
|
|
2702
|
+
let l = new v();
|
|
2703
|
+
for (let e in t.attributes) l.setAttribute(e, t.getAttribute(e));
|
|
2704
|
+
return l.setIndex(new I(s, 1)), l;
|
|
2705
|
+
}
|
|
2706
|
+
_shapeGeometry(e) {
|
|
2707
|
+
switch (e.type) {
|
|
2708
|
+
case "trianglemesh": return this._triangleMesh(e.params);
|
|
2709
|
+
case "bilinearmesh": return this._bilinearMesh(e.params);
|
|
2710
|
+
case "loopsubdiv": return this._loopSubdiv(e.params);
|
|
2711
|
+
case "curve": return this._curve(e.params);
|
|
2712
|
+
case "plymesh": return this._plyMesh(e.params);
|
|
2713
|
+
case "sphere": return this._sphere(e.params);
|
|
2714
|
+
case "disk": return this._disk(e.params);
|
|
2715
|
+
default: return this.warn(`shape "${e.type}" not supported — skipped`), null;
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
_triangleMesh(e) {
|
|
2719
|
+
let t = e.P?.value;
|
|
2720
|
+
if (!t || t.length < 9) return this.warn("trianglemesh missing P"), null;
|
|
2721
|
+
let n = new v();
|
|
2722
|
+
n.setAttribute("position", new w(Qn(t), 3));
|
|
2723
|
+
let r = e.N?.value;
|
|
2724
|
+
r && r.length === t.length && (n.setAttribute("normal", new w(Qn(r), 3)), n.userData.pbrtNormals = !0);
|
|
2725
|
+
let i = (e.uv || e.st)?.value;
|
|
2726
|
+
i && i.length === t.length / 3 * 2 && n.setAttribute("uv", new w(Qn(i), 2));
|
|
2727
|
+
let a = e.indices?.value;
|
|
2728
|
+
return a && a.length && n.setIndex(Xn(a)), r || n.computeVertexNormals(), n;
|
|
2729
|
+
}
|
|
2730
|
+
_curve(e) {
|
|
2731
|
+
let t = e.P?.value;
|
|
2732
|
+
if (!t || t.length < 12) return this.warn("curve needs at least 4 control points"), null;
|
|
2733
|
+
let n = Math.round(X(e, "degree", 3));
|
|
2734
|
+
if (n !== 3) return this.warn(`curve degree ${n} not supported — only cubic`), null;
|
|
2735
|
+
let r = Z(e, "type", "flat"), i = X(e, "width", 1), a = Kn({
|
|
2736
|
+
P: t,
|
|
2737
|
+
basis: Z(e, "basis", "bezier"),
|
|
2738
|
+
width0: X(e, "width0", i),
|
|
2739
|
+
width1: X(e, "width1", i),
|
|
2740
|
+
N: e.N?.value || null,
|
|
2741
|
+
steps: this.curveSteps,
|
|
2742
|
+
sides: this.curveSides ?? or[r] ?? 1,
|
|
2743
|
+
tolerance: this.curveTolerance
|
|
2744
|
+
});
|
|
2745
|
+
if (!a) return this.warn("curve could not be tessellated"), null;
|
|
2746
|
+
let o = new v();
|
|
2747
|
+
return o.setAttribute("position", new w(a.positions, 3)), o.setIndex(new I(a.indices, 1)), o.computeVertexNormals(), o;
|
|
2748
|
+
}
|
|
2749
|
+
_loopSubdiv(e) {
|
|
2750
|
+
let t = e.P?.value, n = e.indices?.value;
|
|
2751
|
+
if (!t || t.length < 9 || !n || n.length < 3) return this.warn("loopsubdiv missing P/indices"), null;
|
|
2752
|
+
let r = Math.max(0, Math.min(6, Math.round(X(e, "levels", 3)))), { positions: i, indices: a, levels: o } = jn(t, n, r);
|
|
2753
|
+
o < r && this.warn(`loopsubdiv refined ${o}/${r} levels — the control mesh is too dense for the triangle budget`);
|
|
2754
|
+
let s = new v();
|
|
2755
|
+
return s.setAttribute("position", new w(i, 3)), s.setIndex(new I(a, 1)), s.computeVertexNormals(), s;
|
|
2756
|
+
}
|
|
2757
|
+
_bilinearMesh(e) {
|
|
2758
|
+
let t = e.P?.value, n = e.indices?.value;
|
|
2759
|
+
if (!t || !n) return this.warn("bilinearmesh missing P/indices"), null;
|
|
2760
|
+
let r = [];
|
|
2761
|
+
for (let e = 0; e + 3 < n.length; e += 4) {
|
|
2762
|
+
let [t, i, a, o] = [
|
|
2763
|
+
n[e],
|
|
2764
|
+
n[e + 1],
|
|
2765
|
+
n[e + 2],
|
|
2766
|
+
n[e + 3]
|
|
2767
|
+
];
|
|
2768
|
+
r.push(t, i, a, t, a, o);
|
|
2769
|
+
}
|
|
2770
|
+
let i = new v();
|
|
2771
|
+
return i.setAttribute("position", new w(Float32Array.from(t), 3)), i.setIndex(r), i.computeVertexNormals(), i;
|
|
2772
|
+
}
|
|
2773
|
+
_plyMesh(e) {
|
|
2774
|
+
let t = Z(e, "filename", null);
|
|
2775
|
+
if (!t) return this.warn("plymesh missing filename"), null;
|
|
2776
|
+
let n = this._plyCache.get(t);
|
|
2777
|
+
return n || this._plyCache.set(t, n = this._decodePly(t)), n;
|
|
2778
|
+
}
|
|
2779
|
+
async _decodePly(e) {
|
|
2780
|
+
try {
|
|
2781
|
+
let t = await this.resolvePLY(e);
|
|
2782
|
+
return t ? (t.getAttribute("normal") ? t.userData.pbrtNormals = !0 : t.computeVertexNormals(), t) : (this.warn(`plymesh file not found: ${e}`), null);
|
|
2783
|
+
} catch (t) {
|
|
2784
|
+
return this.warn(`failed to load plymesh ${e}: ${t.message}`), null;
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
_sphere(e) {
|
|
2788
|
+
return new de(X(e, "radius", 1), 48, 32);
|
|
2789
|
+
}
|
|
2790
|
+
_disk(e) {
|
|
2791
|
+
let t = X(e, "radius", 1), n = X(e, "innerradius", 0), r = X(e, "height", 0), i = [], a = [];
|
|
2792
|
+
for (let e = 0; e < 48; e++) {
|
|
2793
|
+
let o = e / 48 * Math.PI * 2, s = (e + 1) / 48 * Math.PI * 2, c = i.length / 3;
|
|
2794
|
+
i.push(Math.cos(o) * n, Math.sin(o) * n, r), i.push(Math.cos(o) * t, Math.sin(o) * t, r), i.push(Math.cos(s) * t, Math.sin(s) * t, r), i.push(Math.cos(s) * n, Math.sin(s) * n, r), a.push(c, c + 1, c + 2, c, c + 2, c + 3);
|
|
2795
|
+
}
|
|
2796
|
+
let o = new v();
|
|
2797
|
+
return o.setAttribute("position", new w(Float32Array.from(i), 3)), o.setIndex(a), o.computeVertexNormals(), o;
|
|
2798
|
+
}
|
|
2799
|
+
async _getMaterial(e) {
|
|
2800
|
+
let t = await this._surfaceMaterial(e);
|
|
2801
|
+
return e.interior ? this._inMedium(t, e.interior) : t;
|
|
2802
|
+
}
|
|
2803
|
+
async _surfaceMaterial(e) {
|
|
2804
|
+
let t = this._materialCache.get(e.material);
|
|
2805
|
+
if (t || (t = /* @__PURE__ */ new Map(), this._materialCache.set(e.material, t)), t.has(e.areaLight)) return t.get(e.areaLight);
|
|
2806
|
+
let n = this._materialContext(), r = await _n(e.material, n);
|
|
2807
|
+
e.areaLight && await this._applyAreaLight(r, e.areaLight, n);
|
|
2808
|
+
let i = this._dedupeMaterial(r);
|
|
2809
|
+
return t.set(e.areaLight, i), i;
|
|
2810
|
+
}
|
|
2811
|
+
_materialContext() {
|
|
2812
|
+
return this._ctx ??= {
|
|
2813
|
+
resolveNamedTexture: (e) => this._resolveNamedTexture(e),
|
|
2814
|
+
namedMaterials: this.ir.namedMaterials,
|
|
2815
|
+
warn: (e) => this.warn(e),
|
|
2816
|
+
floatTextureMean: async (e) => {
|
|
2817
|
+
let t = await this._bakeTerm(e, 1);
|
|
2818
|
+
return t ? t.layer ? Sn(t.layer) : t.rgb[0] : null;
|
|
2819
|
+
},
|
|
2820
|
+
bakeMaterialMix: (e, t, n) => this._bakeMaterialMix(e, t, n),
|
|
2821
|
+
resolveNormalMap: async (e) => {
|
|
2822
|
+
let t = await this._image(e);
|
|
2823
|
+
if (!t) return null;
|
|
2824
|
+
let n = mr(t, { srgb: !1 }), r = n === t ? t.clone() : n;
|
|
2825
|
+
return r.colorSpace = ne, r;
|
|
2826
|
+
}
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
async _inMedium(e, t) {
|
|
2830
|
+
if (!(e.transmission > 0)) return e;
|
|
2831
|
+
let n = this._mediumMaterials.get(e);
|
|
2832
|
+
return n || this._mediumMaterials.set(e, n = /* @__PURE__ */ new Map()), n.has(t) || n.set(t, this._attenuated(e, t)), n.get(t);
|
|
2833
|
+
}
|
|
2834
|
+
async _attenuated(e, t) {
|
|
2835
|
+
let n = this.ir.media?.get(t), r = n && Z(n, "type", "");
|
|
2836
|
+
if (r !== "homogeneous") return this.warn(n ? `medium "${t}" (${r}) is not supported — "${t}" glass left clear` : `medium "${t}" not defined`), e;
|
|
2837
|
+
n.preset && this.warn(`medium preset "${Z(n, "preset", "")}" is not supported — using sigma_a / sigma_s`);
|
|
2838
|
+
let i = this._materialContext(), a = (await Q(n, "sigma_a", i, [
|
|
2839
|
+
1,
|
|
2840
|
+
1,
|
|
2841
|
+
1
|
|
2842
|
+
])).rgb, o = (await Q(n, "sigma_s", i, [
|
|
2843
|
+
1,
|
|
2844
|
+
1,
|
|
2845
|
+
1
|
|
2846
|
+
])).rgb, s = X(n, "scale", 1), c = [
|
|
2847
|
+
0,
|
|
2848
|
+
1,
|
|
2849
|
+
2
|
|
2850
|
+
].map((e) => (a[e] + o[e]) * s), l = Math.max(...c);
|
|
2851
|
+
if (!(l > 0)) return e;
|
|
2852
|
+
let u = e.clone();
|
|
2853
|
+
return u.attenuationDistance = 1 / l, u.attenuationColor.setRGB(...c.map((e) => Math.exp(-e / l))), this._dedupeMaterial(u);
|
|
2854
|
+
}
|
|
2855
|
+
_dedupeMaterial(e) {
|
|
2856
|
+
let t = e.color, n = e.emissive, r = `${t.r},${t.g},${t.b}|${n.r},${n.g},${n.b}|${e.emissiveIntensity}|${e.map ? e.map.uuid : "-"}|${e.roughness}|${e.metalness}|${e.transmission}|${e.ior}|${e.thickness}|${e.clearcoat}|${e.clearcoatRoughness}|${e.opacity}|${e.side}|${e.normalMap ? e.normalMap.uuid : "-"}|${e.attenuationDistance}|${e.attenuationColor.toArray()}|${e.specularIntensity}|${e.diffuseTransmission ?? 0}|${e.diffuseTransmissionColor?.toArray() ?? "-"}`;
|
|
2857
|
+
return this._materialBySignature.get(r) || (this._materialBySignature.set(r, e), e);
|
|
2858
|
+
}
|
|
2859
|
+
async _applyAreaLight(e, t, n) {
|
|
2860
|
+
let r = await Jn(t.params, "L", n), i = X(t.params, "scale", 1);
|
|
2861
|
+
e.emissive.setRGB(r[0], r[1], r[2]), e.emissiveIntensity = i, e.side = fn(t.params, "twosided", !1) ? S : E;
|
|
2862
|
+
}
|
|
2863
|
+
async _resolveNamedTexture(e) {
|
|
2864
|
+
if (this._textureCache.has(e)) return this._textureCache.get(e);
|
|
2865
|
+
let t = this.ir.namedTextures.get(e), n = null;
|
|
2866
|
+
if (!t) this.warn(`named texture "${e}" not defined`);
|
|
2867
|
+
else if (t.class === "imagemap") n = await this._imageMapTexture(e, t);
|
|
2868
|
+
else if (t.class === "mix") n = await this._mixTexture(e, t);
|
|
2869
|
+
else if (t.class === "constant") {
|
|
2870
|
+
let e = t.params.value;
|
|
2871
|
+
e && e.type === "rgb" ? n = { constant: [
|
|
2872
|
+
e.value[0],
|
|
2873
|
+
e.value[1],
|
|
2874
|
+
e.value[2]
|
|
2875
|
+
] } : e && (n = { constant: [
|
|
2876
|
+
e.value[0],
|
|
2877
|
+
e.value[0],
|
|
2878
|
+
e.value[0]
|
|
2879
|
+
] });
|
|
2880
|
+
} else if (t.class === "scale") n = await this._resolveScaleTexture(e, t);
|
|
2881
|
+
else {
|
|
2882
|
+
let r = this._colorFromLikeNamedMaterial(e);
|
|
2883
|
+
r ? (n = { constant: r.rgb }, this._recoveredColors++) : this.warn(`texture class "${t.class}" not supported (texture "${e}")`);
|
|
2884
|
+
}
|
|
2885
|
+
return this._textureCache.set(e, n), n;
|
|
2886
|
+
}
|
|
2887
|
+
_image(e) {
|
|
2888
|
+
let t = this._imageCache.get(e);
|
|
2889
|
+
return t || (t = Promise.resolve().then(() => this.resolveImage(e)).catch((t) => (this.warn(`failed to load image ${e}: ${t.message}`), null)), this._imageCache.set(e, t)), t;
|
|
2890
|
+
}
|
|
2891
|
+
async _imageMapTexture(e, t) {
|
|
2892
|
+
let n = Z(t.params, "filename", null);
|
|
2893
|
+
if (!n) return null;
|
|
2894
|
+
let r = await this._image(n);
|
|
2895
|
+
if (!r) return this.warn(`image not found for texture "${e}": ${n}`), null;
|
|
2896
|
+
let i = Z(t.params, "mapping", "uv");
|
|
2897
|
+
i !== "uv" && this.warn(`texture "${e}": "${i}" mapping is not supported — using the mesh's uv`);
|
|
2898
|
+
let a = X(t.params, "scale", 1);
|
|
2899
|
+
if (a > 1 || fn(t.params, "invert", !1)) {
|
|
2900
|
+
let t = await this._bakeTerm(e, 3), n = t?.layer && wn([{
|
|
2901
|
+
...t,
|
|
2902
|
+
clamp: !0
|
|
2903
|
+
}], ([e]) => e);
|
|
2904
|
+
if (n) return { texture: hr(n) };
|
|
2905
|
+
this.warn(`texture "${e}": its scale or invert could not be baked here — ignored`);
|
|
2906
|
+
}
|
|
2907
|
+
let o = mr(r, { srgb: !0 }), s = o === r ? r.clone() : o;
|
|
2908
|
+
return pr(s, fr(t.params)), s.needsUpdate = !0, a < 1 ? {
|
|
2909
|
+
texture: s,
|
|
2910
|
+
constant: [
|
|
2911
|
+
a,
|
|
2912
|
+
a,
|
|
2913
|
+
a
|
|
2914
|
+
]
|
|
2915
|
+
} : { texture: s };
|
|
2916
|
+
}
|
|
2917
|
+
async _mixTexture(e, t) {
|
|
2918
|
+
let [n, r, i] = await Promise.all([
|
|
2919
|
+
this._paramTerm(t.params, "tex1", 3, [
|
|
2920
|
+
0,
|
|
2921
|
+
0,
|
|
2922
|
+
0
|
|
2923
|
+
]),
|
|
2924
|
+
this._paramTerm(t.params, "tex2", 3, [
|
|
2925
|
+
1,
|
|
2926
|
+
1,
|
|
2927
|
+
1
|
|
2928
|
+
]),
|
|
2929
|
+
this._paramTerm(t.params, "amount", 1, [
|
|
2930
|
+
.5,
|
|
2931
|
+
.5,
|
|
2932
|
+
.5
|
|
2933
|
+
])
|
|
2934
|
+
]);
|
|
2935
|
+
if (!n || !r || !i) return this.warn(`texture "${e}": a "mix" input could not be read here`), null;
|
|
2936
|
+
let a = (e) => e.map((e) => Math.min(1, Math.max(0, e))), o = wn([
|
|
2937
|
+
{
|
|
2938
|
+
...n,
|
|
2939
|
+
clamp: !0
|
|
2940
|
+
},
|
|
2941
|
+
{
|
|
2942
|
+
...r,
|
|
2943
|
+
clamp: !0
|
|
2944
|
+
},
|
|
2945
|
+
i
|
|
2946
|
+
], Tn);
|
|
2947
|
+
return o ? { texture: hr(o) } : { constant: Tn([
|
|
2948
|
+
a(n.rgb),
|
|
2949
|
+
a(r.rgb),
|
|
2950
|
+
i.rgb
|
|
2951
|
+
]) };
|
|
2952
|
+
}
|
|
2953
|
+
async _paramTerm(e, t, n, r) {
|
|
2954
|
+
let i = e[t];
|
|
2955
|
+
if (!i) return { rgb: r };
|
|
2956
|
+
if (i.type === "texture") return this._bakeTerm(i.value[0], n);
|
|
2957
|
+
let a = (await Q(e, t, this._materialContext(), r)).rgb;
|
|
2958
|
+
return a ? { rgb: a } : null;
|
|
2959
|
+
}
|
|
2960
|
+
_bakeTerm(e, t) {
|
|
2961
|
+
let n = `${e}\0${t}`, r = this._termCache.get(n);
|
|
2962
|
+
return r || this._termCache.set(n, r = this._createBakeTerm(e, t)), r;
|
|
2963
|
+
}
|
|
2964
|
+
async _createBakeTerm(e, t) {
|
|
2965
|
+
let n = this.ir.namedTextures.get(e);
|
|
2966
|
+
if (n?.class === "imagemap") {
|
|
2967
|
+
if (Z(n.params, "mapping", "uv") !== "uv") return null;
|
|
2968
|
+
let e = Z(n.params, "filename", null), r = ur(e && await this._image(e));
|
|
2969
|
+
return r ? { layer: xn(r, {
|
|
2970
|
+
channels: t,
|
|
2971
|
+
decode: r.float ? null : dr(n.params),
|
|
2972
|
+
scale: X(n.params, "scale", 1),
|
|
2973
|
+
invert: fn(n.params, "invert", !1),
|
|
2974
|
+
mapping: fr(n.params)
|
|
2975
|
+
}) } : null;
|
|
2976
|
+
}
|
|
2977
|
+
let r = await this._resolveNamedTexture(e);
|
|
2978
|
+
if (!r) return null;
|
|
2979
|
+
if (!r.texture) return r.constant ? { rgb: r.constant } : null;
|
|
2980
|
+
let i = this._textureLayer(r.texture, t);
|
|
2981
|
+
return i ? {
|
|
2982
|
+
layer: i,
|
|
2983
|
+
tint: r.constant ?? null
|
|
2984
|
+
} : null;
|
|
2985
|
+
}
|
|
2986
|
+
_textureLayer(e, t) {
|
|
2987
|
+
let n = ur(e);
|
|
2988
|
+
if (!n) return null;
|
|
2989
|
+
let r = !n.float && e.colorSpace === F;
|
|
2990
|
+
return xn(n, {
|
|
2991
|
+
channels: t,
|
|
2992
|
+
decode: n.float ? null : r ? yn : (e) => e,
|
|
2993
|
+
mapping: {
|
|
2994
|
+
su: e.repeat.x,
|
|
2995
|
+
sv: e.repeat.y,
|
|
2996
|
+
du: e.offset.x,
|
|
2997
|
+
dv: e.offset.y
|
|
2998
|
+
}
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
async _bakeMaterialMix(e, t, n) {
|
|
3002
|
+
let r = await this._bakeTerm(n, 1);
|
|
3003
|
+
if (!r) return null;
|
|
3004
|
+
if (!r.layer) return {
|
|
3005
|
+
mean: r.rgb[0],
|
|
3006
|
+
texture: null
|
|
3007
|
+
};
|
|
3008
|
+
let i = Sn(r.layer), a = (e) => {
|
|
3009
|
+
if (!e.map) return {
|
|
3010
|
+
rgb: e.color.toArray(),
|
|
3011
|
+
clamp: !0
|
|
3012
|
+
};
|
|
3013
|
+
let t = this._textureLayer(e.map, 3);
|
|
3014
|
+
return t && {
|
|
3015
|
+
layer: t,
|
|
3016
|
+
tint: e.color.toArray(),
|
|
3017
|
+
clamp: !0
|
|
3018
|
+
};
|
|
3019
|
+
}, o = a(e), s = a(t);
|
|
3020
|
+
if (!o || !s) return {
|
|
3021
|
+
mean: i,
|
|
3022
|
+
texture: null
|
|
3023
|
+
};
|
|
3024
|
+
let c = wn([
|
|
3025
|
+
o,
|
|
3026
|
+
s,
|
|
3027
|
+
r
|
|
3028
|
+
], Tn);
|
|
3029
|
+
return {
|
|
3030
|
+
mean: i,
|
|
3031
|
+
texture: c ? hr(c) : null
|
|
3032
|
+
};
|
|
3033
|
+
}
|
|
3034
|
+
_colorFromLikeNamedMaterial(e) {
|
|
3035
|
+
for (let t of gr(e)) {
|
|
3036
|
+
let e = (this.ir?.namedMaterials?.get(t))?.params?.reflectance;
|
|
3037
|
+
if (e && (e.type === "rgb" || e.type === "color")) return {
|
|
3038
|
+
name: t,
|
|
3039
|
+
rgb: [
|
|
3040
|
+
e.value[0],
|
|
3041
|
+
e.value[1],
|
|
3042
|
+
e.value[2]
|
|
3043
|
+
]
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
return null;
|
|
3047
|
+
}
|
|
3048
|
+
async _resolveScaleTexture(e, t) {
|
|
3049
|
+
if (t.params.scale?.type === "texture") {
|
|
3050
|
+
let [n, r] = await Promise.all([this._paramTerm(t.params, "tex", 3, [
|
|
3051
|
+
1,
|
|
3052
|
+
1,
|
|
3053
|
+
1
|
|
3054
|
+
]), this._paramTerm(t.params, "scale", 1, [
|
|
3055
|
+
1,
|
|
3056
|
+
1,
|
|
3057
|
+
1
|
|
3058
|
+
])]), i = ([e, t]) => [
|
|
3059
|
+
e[0] * t[0],
|
|
3060
|
+
e[1] * t[0],
|
|
3061
|
+
e[2] * t[0]
|
|
3062
|
+
];
|
|
3063
|
+
if (n && r) {
|
|
3064
|
+
let e = wn([{
|
|
3065
|
+
...n,
|
|
3066
|
+
clamp: !0
|
|
3067
|
+
}, r], i);
|
|
3068
|
+
return e ? { texture: hr(e) } : { constant: i([n.rgb, r.rgb]) };
|
|
3069
|
+
}
|
|
3070
|
+
this.warn(`texture "${e}": its "scale" texture could not be read here — ignored`);
|
|
3071
|
+
}
|
|
3072
|
+
let n = t.params.tex, r = null;
|
|
3073
|
+
if (n?.type === "texture" && typeof n.value[0] == "string") r = await this._resolveNamedTexture(n.value[0]);
|
|
3074
|
+
else if (n?.type === "rgb" || n?.type === "color") r = { constant: [
|
|
3075
|
+
n.value[0],
|
|
3076
|
+
n.value[1],
|
|
3077
|
+
n.value[2]
|
|
3078
|
+
] };
|
|
3079
|
+
else if (n?.type === "float") {
|
|
3080
|
+
let e = n.value[0];
|
|
3081
|
+
r = { constant: [
|
|
3082
|
+
e,
|
|
3083
|
+
e,
|
|
3084
|
+
e
|
|
3085
|
+
] };
|
|
3086
|
+
}
|
|
3087
|
+
let i = t.params.scale, a = [
|
|
3088
|
+
1,
|
|
3089
|
+
1,
|
|
3090
|
+
1
|
|
3091
|
+
];
|
|
3092
|
+
if (i?.type === "rgb" || i?.type === "color") a = [
|
|
3093
|
+
i.value[0],
|
|
3094
|
+
i.value[1],
|
|
3095
|
+
i.value[2]
|
|
3096
|
+
];
|
|
3097
|
+
else if (i?.type === "float") {
|
|
3098
|
+
let e = i.value[0];
|
|
3099
|
+
a = [
|
|
3100
|
+
e,
|
|
3101
|
+
e,
|
|
3102
|
+
e
|
|
3103
|
+
];
|
|
3104
|
+
}
|
|
3105
|
+
if (r?.texture) {
|
|
3106
|
+
let e = r.constant || [
|
|
3107
|
+
1,
|
|
3108
|
+
1,
|
|
3109
|
+
1
|
|
3110
|
+
];
|
|
3111
|
+
return {
|
|
3112
|
+
texture: r.texture,
|
|
3113
|
+
constant: [
|
|
3114
|
+
e[0] * a[0],
|
|
3115
|
+
e[1] * a[1],
|
|
3116
|
+
e[2] * a[2]
|
|
3117
|
+
]
|
|
3118
|
+
};
|
|
3119
|
+
}
|
|
3120
|
+
let o = r?.constant || [
|
|
3121
|
+
1,
|
|
3122
|
+
1,
|
|
3123
|
+
1
|
|
3124
|
+
];
|
|
3125
|
+
return { constant: [
|
|
3126
|
+
o[0] * a[0],
|
|
3127
|
+
o[1] * a[1],
|
|
3128
|
+
o[2] * a[2]
|
|
3129
|
+
] };
|
|
3130
|
+
}
|
|
3131
|
+
_buildCamera(e, t) {
|
|
3132
|
+
let n = t && t.yresolution ? t.xresolution / t.yresolution : 16 / 9, r;
|
|
3133
|
+
if (e.type === "orthographic") {
|
|
3134
|
+
let t = e.params?.screenwindow?.value, i = t?.length === 4 ? (t[3] - t[2]) / 2 : Math.max(1, 1 / n);
|
|
3135
|
+
r = new ae(-i * n, i * n, i, -i, .01, 1e4);
|
|
3136
|
+
} else r = new oe(this._verticalFov(e.params, n), n, .01, 1e4);
|
|
3137
|
+
return r.name = "PBRT Camera", this._poseCamera(r, e.cameraToWorld), r.updateMatrixWorld(!0), r;
|
|
3138
|
+
}
|
|
3139
|
+
_poseCamera(e, t) {
|
|
3140
|
+
let n = t, r = new L(n[12], n[13], n[14]), i = new L(n[8], n[9], n[10]), a = new L(n[4], n[5], n[6]);
|
|
3141
|
+
this.convertHandedness && (r.z *= -1, i.z *= -1, a.z *= -1), e.up.copy(a.normalize()), e.position.copy(r), e.scale.set(1, 1, 1), e.lookAt(r.clone().add(i)), Kt(t) > 0 !== this.convertHandedness && (e.scale.x = -1);
|
|
3142
|
+
}
|
|
3143
|
+
_verticalFov(e, t) {
|
|
3144
|
+
let n = X(e, "fov", 90);
|
|
3145
|
+
if (t >= 1) return n;
|
|
3146
|
+
let r = n * Math.PI / 180;
|
|
3147
|
+
return 2 * Math.atan(Math.tan(r / 2) / t) * 180 / Math.PI;
|
|
3148
|
+
}
|
|
3149
|
+
_equirectFromInfiniteLight(e, t, n, r) {
|
|
3150
|
+
let i = e.image;
|
|
3151
|
+
if (!i?.width || i.width !== i.height) return i?.width !== i?.height && this.warn(`infinite-light image "${r}" is ${i?.width}x${i?.height}, not square — read as equirectangular, but pbrt would read it as equal-area octahedral`), null;
|
|
3152
|
+
let a = null;
|
|
3153
|
+
if (i.data) {
|
|
3154
|
+
let e = i.data.length / (i.width * i.height);
|
|
3155
|
+
if (!Number.isInteger(e) || e < 3) return null;
|
|
3156
|
+
a = {
|
|
3157
|
+
data: i.data,
|
|
3158
|
+
width: i.width,
|
|
3159
|
+
height: i.height,
|
|
3160
|
+
channels: e,
|
|
3161
|
+
bottomUp: !0
|
|
3162
|
+
};
|
|
3163
|
+
} else if (a = lr(i, e.colorSpace === F), !a) return this.warn(`infinite-light image "${r}" could not be read back for octahedral conversion`), null;
|
|
3164
|
+
let { data: o, width: s, height: c } = Fn(a, t.ctm, n), l = new b(o, s, c, P, T);
|
|
3165
|
+
return l.mapping = C, l.minFilter = A, l.magFilter = A, l.needsUpdate = !0, l;
|
|
3166
|
+
}
|
|
3167
|
+
async _buildEnvironment(e) {
|
|
3168
|
+
let t = e.find((e) => e.type === "infinite");
|
|
3169
|
+
if (!t) return null;
|
|
3170
|
+
let n = X(t.params, "scale", 1), r = Z(t.params, "filename", null);
|
|
3171
|
+
if (r) try {
|
|
3172
|
+
let e = await this.resolveEnvironment(r);
|
|
3173
|
+
if (e) {
|
|
3174
|
+
let i = this._equirectFromInfiniteLight(e, t, n, r);
|
|
3175
|
+
return i ? { texture: i } : (e.mapping = C, { texture: e });
|
|
3176
|
+
}
|
|
3177
|
+
this.warn(`infinite-light image not found: ${r}`);
|
|
3178
|
+
} catch (e) {
|
|
3179
|
+
this.warn(`failed to load infinite-light image ${r}: ${e.message}`);
|
|
3180
|
+
}
|
|
3181
|
+
let i = (await Jn(t.params, "L", {
|
|
3182
|
+
resolveNamedTexture: async () => null,
|
|
3183
|
+
warn: (e) => this.warn(e)
|
|
3184
|
+
})).map((e) => e * n), a = new Float32Array(8);
|
|
3185
|
+
for (let e = 0; e < 2; e++) a[e * 4 + 0] = i[0], a[e * 4 + 1] = i[1], a[e * 4 + 2] = i[2], a[e * 4 + 3] = 1;
|
|
3186
|
+
let o = new b(a, 2, 1, P, T);
|
|
3187
|
+
return o.mapping = C, o.minFilter = A, o.magFilter = A, o.needsUpdate = !0, { texture: o };
|
|
3188
|
+
}
|
|
3189
|
+
async _buildLamps(e, t) {
|
|
3190
|
+
let n = {
|
|
3191
|
+
resolveNamedTexture: async () => null,
|
|
3192
|
+
warn: (e) => this.warn(e)
|
|
3193
|
+
};
|
|
3194
|
+
for (let r of e) {
|
|
3195
|
+
if (!qn.has(r.type)) continue;
|
|
3196
|
+
let e = new N().fromArray(this.convertHandedness ? q($, r.ctm) : r.ctm), i = (t, n) => {
|
|
3197
|
+
let i = r.params[t]?.value;
|
|
3198
|
+
return new L().fromArray(i?.length >= 3 ? i : n).applyMatrix4(e);
|
|
3199
|
+
}, a = await Jn(r.params, r.type === "distant" ? "L" : "I", n), o = X(r.params, "scale", 1), s = i("from", [
|
|
3200
|
+
0,
|
|
3201
|
+
0,
|
|
3202
|
+
0
|
|
3203
|
+
]), c = i("to", [
|
|
3204
|
+
0,
|
|
3205
|
+
0,
|
|
3206
|
+
1
|
|
3207
|
+
]), l;
|
|
3208
|
+
if (r.type === "distant") {
|
|
3209
|
+
let e = X(r.params, "illuminance", -1);
|
|
3210
|
+
e > 0 && (o *= e), l = new x(), l.userData.__luxConverted = !0;
|
|
3211
|
+
} else if (r.type === "point") {
|
|
3212
|
+
let e = X(r.params, "power", -1);
|
|
3213
|
+
o *= e > 0 ? e : 4 * Math.PI, l = new se(), l.userData.__candelaConverted = !0;
|
|
3214
|
+
} else {
|
|
3215
|
+
let e = Math.min(Math.max(X(r.params, "coneangle", 30), 0), 90) * Math.PI / 180, t = Math.min(Math.max(X(r.params, "conedeltaangle", 5) * Math.PI / 180, 0), e), n = Math.cos(e), i = Math.cos(e - t), a = X(r.params, "power", -1);
|
|
3216
|
+
a > 0 && (o *= a / (2 * Math.PI * (1 - i + (i - n) / 2))), o *= 4 * Math.PI, l = new fe(), l.angle = e, l.penumbra = n < 1 ? Math.min((i - n) / (1 - n), 1) : 0, l.userData.__candelaConverted = !0;
|
|
3217
|
+
}
|
|
3218
|
+
let u = Math.max(a[0], a[1], a[2]);
|
|
3219
|
+
!(u > 0) || !(o > 0) || (l.color.setRGB(a[0] / u, a[1] / u, a[2] / u), l.intensity = u * o, l.name = `pbrt ${r.type}`, l.position.copy(s), l.decay = 2, l.distance = 0, l.target && (l.target.position.subVectors(c, s), l.add(l.target)), t.add(l));
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
_reportUnsupportedLights(e) {
|
|
3223
|
+
for (let t of e) t.type !== "infinite" && !qn.has(t.type) && this.warn(`light "${t.type}" not supported (only infinite, distant, point and spot lights and emissive area lights are mapped)`);
|
|
3224
|
+
}
|
|
3225
|
+
}, vr = 1e3, yr = 2048, br = 1e5;
|
|
3226
|
+
function xr(e) {
|
|
3227
|
+
let t = e[0], n = (e) => {
|
|
3228
|
+
let t = e.lastIndexOf("/"), n = /^(.*?)(\d+)\.pbrt$/i.exec(e.slice(t + 1));
|
|
3229
|
+
return n ? {
|
|
3230
|
+
group: e.slice(0, t + 1) + "\0" + n[1].toLowerCase(),
|
|
3231
|
+
number: parseInt(n[2], 10)
|
|
3232
|
+
} : null;
|
|
3233
|
+
}, r = t ? n(t) : null;
|
|
3234
|
+
if (!r) return null;
|
|
3235
|
+
let i = /* @__PURE__ */ new Map();
|
|
3236
|
+
for (let t of e) {
|
|
3237
|
+
let e = n(t);
|
|
3238
|
+
e && e.group === r.group && !i.has(e.number) && i.set(e.number, t);
|
|
3239
|
+
}
|
|
3240
|
+
return i.size < 2 ? null : [...i].sort((e, t) => e[0] - t[0]).slice(0, vr).map(([e, t]) => ({
|
|
3241
|
+
path: t,
|
|
3242
|
+
number: e
|
|
3243
|
+
}));
|
|
3244
|
+
}
|
|
3245
|
+
function Sr(e) {
|
|
3246
|
+
let t = e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint32Array ? new Uint32Array(e.buffer, e.byteOffset, e.length) : null;
|
|
3247
|
+
t ||= new Uint32Array(Float32Array.from(e).buffer);
|
|
3248
|
+
let n = 2166136261;
|
|
3249
|
+
for (let e = 0; e < t.length; e++) n = Math.imul(n ^ t[e], 16777619), n ^= n >>> 15;
|
|
3250
|
+
return (n >>> 0).toString(36) + ":" + e.length;
|
|
3251
|
+
}
|
|
3252
|
+
function Cr(e) {
|
|
3253
|
+
let t = "";
|
|
3254
|
+
for (let n of Object.keys(e).sort()) {
|
|
3255
|
+
let { type: r, value: i } = e[n], a = ArrayBuffer.isView(i) || i.length > 16 && typeof i[0] == "number";
|
|
3256
|
+
t += `${r} ${n}=${a ? "#" + Sr(i) : i.join(",")};`;
|
|
3257
|
+
}
|
|
3258
|
+
return t;
|
|
3259
|
+
}
|
|
3260
|
+
var wr = class {
|
|
3261
|
+
constructor(e) {
|
|
3262
|
+
this.materialNames = /* @__PURE__ */ new Map();
|
|
3263
|
+
for (let [t, n] of e.namedMaterials) this.materialNames.set(n, t);
|
|
3264
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
3265
|
+
}
|
|
3266
|
+
of(e) {
|
|
3267
|
+
return `${e.type}|${+!!e.reverseOrientation}|${Cr(e.params)}|${this._material(e.material)}|${this._light(e.areaLight)}`;
|
|
3268
|
+
}
|
|
3269
|
+
_material(e) {
|
|
3270
|
+
if (!e) return "-";
|
|
3271
|
+
let t = this.cache.get(e);
|
|
3272
|
+
if (t === void 0) {
|
|
3273
|
+
let n = this.materialNames.get(e) ?? e._missingRef;
|
|
3274
|
+
t = n === void 0 ? "I:" + e.type + ":" + Cr(e.params) : "N:" + n, this.cache.set(e, t);
|
|
3275
|
+
}
|
|
3276
|
+
return t;
|
|
3277
|
+
}
|
|
3278
|
+
_light(e) {
|
|
3279
|
+
if (!e) return "-";
|
|
3280
|
+
let t = this.cache.get(e);
|
|
3281
|
+
return t === void 0 && this.cache.set(e, t = "L:" + e.type + ":" + Cr(e.params)), t;
|
|
3282
|
+
}
|
|
3283
|
+
};
|
|
3284
|
+
function Tr(e, t) {
|
|
3285
|
+
let n = new Int32Array(t.length).fill(-1), r = 0;
|
|
3286
|
+
for (; r < e.length && r < t.length && e[r] === t[r];) n[r] = r, r++;
|
|
3287
|
+
let i = e.length, a = t.length;
|
|
3288
|
+
for (; i > r && a > r && e[i - 1] === t[a - 1];) n[--a] = --i;
|
|
3289
|
+
return r < i && r < a && !Er(e, r, i, t, r, a, n) && Or(e, r, i, t, r, a, n), n;
|
|
3290
|
+
}
|
|
3291
|
+
function Er(e, t, n, r, i, a, o) {
|
|
3292
|
+
let s = n - t, c = a - i, l = Math.min(s + c, yr), u = l + 1, d = new Int32Array(2 * l + 3), f = [];
|
|
3293
|
+
for (let n = 0; n <= l; n++) {
|
|
3294
|
+
for (let a = -n; a <= n; a += 2) {
|
|
3295
|
+
let l = a === -n || a !== n && d[u + a - 1] < d[u + a + 1] ? d[u + a + 1] : d[u + a - 1] + 1, p = l - a;
|
|
3296
|
+
for (; l < s && p < c && e[t + l] === r[i + p];) l++, p++;
|
|
3297
|
+
if (d[u + a] = l, l >= s && p >= c) return f.push(d.slice(u - n, u + n + 1)), Dr(f, s, c, t, i, o), !0;
|
|
3298
|
+
}
|
|
3299
|
+
f.push(d.slice(u - n, u + n + 1));
|
|
3300
|
+
}
|
|
3301
|
+
return !1;
|
|
3302
|
+
}
|
|
3303
|
+
function Dr(e, t, n, r, i, a) {
|
|
3304
|
+
let o = t, s = n;
|
|
3305
|
+
for (let t = e.length - 1; t > 0; t--) {
|
|
3306
|
+
let n = e[t - 1], c = (e) => n[e + t - 1], l = o - s, u = l === -t || l !== t && c(l - 1) < c(l + 1) ? l + 1 : l - 1, d = c(u), f = d - u;
|
|
3307
|
+
for (; o > d && s > f;) a[i + --s] = r + --o;
|
|
3308
|
+
o = d, s = f;
|
|
3309
|
+
}
|
|
3310
|
+
for (; o > 0 && s > 0;) a[i + --s] = r + --o;
|
|
3311
|
+
}
|
|
3312
|
+
function Or(e, t, n, r, i, a, o) {
|
|
3313
|
+
let s = /* @__PURE__ */ new Map();
|
|
3314
|
+
for (let r = t; r < n; r++) {
|
|
3315
|
+
let t = s.get(e[r]);
|
|
3316
|
+
t ? t.push(r) : s.set(e[r], [r]);
|
|
3317
|
+
}
|
|
3318
|
+
let c = /* @__PURE__ */ new Map();
|
|
3319
|
+
for (let e = i; e < a; e++) {
|
|
3320
|
+
let t = s.get(r[e]);
|
|
3321
|
+
if (!t) continue;
|
|
3322
|
+
let n = c.get(r[e]) ?? 0;
|
|
3323
|
+
n < t.length && (o[e] = t[n], c.set(r[e], n + 1));
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
function kr(e, t, n, r) {
|
|
3327
|
+
for (let i = 0; i < 16; i++) if (e[t + i] !== n[r + i]) return !1;
|
|
3328
|
+
return !0;
|
|
3329
|
+
}
|
|
3330
|
+
function Ar(e, t, n) {
|
|
3331
|
+
let r = e.length, i = new Float32Array(16 * r), a = null, o = -1;
|
|
3332
|
+
for (let e = 0; e < r; e++) if (t(e)) {
|
|
3333
|
+
if (i.set(n(e), e * 16), o < 0) for (let t = 0; t < e; t++) i.copyWithin(t * 16, e * 16, e * 16 + 16);
|
|
3334
|
+
o = e;
|
|
3335
|
+
} else a ??= new Uint8Array(r).fill(1), a[e] = 0, o >= 0 && i.copyWithin(e * 16, o * 16, o * 16 + 16);
|
|
3336
|
+
return {
|
|
3337
|
+
times: e,
|
|
3338
|
+
matrices: i,
|
|
3339
|
+
visible: a
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
function jr(e) {
|
|
3343
|
+
if (e.visible) return !1;
|
|
3344
|
+
let t = e.matrices;
|
|
3345
|
+
for (let e = 16; e < t.length; e += 16) if (!kr(t, 0, t, e)) return !1;
|
|
3346
|
+
return !0;
|
|
3347
|
+
}
|
|
3348
|
+
var Mr = class {
|
|
3349
|
+
constructor(e, t) {
|
|
3350
|
+
this.times = Float32Array.from(e), this.name = t, this.base = null, this.frame = -1, this.keyIds = /* @__PURE__ */ new Map(), this.tracks = [], this.prev = null, this.placements = /* @__PURE__ */ new Map(), this.templates = /* @__PURE__ */ new Map(), this.cameras = [], this.warnings = /* @__PURE__ */ new Set();
|
|
3351
|
+
}
|
|
3352
|
+
addFrame(e) {
|
|
3353
|
+
let t = ++this.frame;
|
|
3354
|
+
t === 0 ? this.base = e : this._adoptDefinitions(e);
|
|
3355
|
+
for (let t of e.warnings) this.warnings.add(t);
|
|
3356
|
+
let n = new wr(e), r = new Int32Array(e.shapes.length);
|
|
3357
|
+
for (let t = 0; t < r.length; t++) {
|
|
3358
|
+
let i = n.of(e.shapes[t]), a = this.keyIds.get(i);
|
|
3359
|
+
a === void 0 && this.keyIds.set(i, a = this.keyIds.size), r[t] = a;
|
|
3360
|
+
}
|
|
3361
|
+
let i = this.prev ? Tr(this.prev.keys, r) : null, a = Array(r.length);
|
|
3362
|
+
for (let o = 0; o < r.length; o++) {
|
|
3363
|
+
let r = e.shapes[o], s = i && i[o] >= 0 ? this.prev.tracks[i[o]] : null;
|
|
3364
|
+
s ? (s.last = t, s.ctms ? s.ctms.push(r.ctm) : r.ctm !== s.shape.ctm && !kr(r.ctm, 0, s.shape.ctm, 0) && (s.ctms = Array(t - s.first).fill(s.shape.ctm), s.ctms.push(r.ctm))) : (s = {
|
|
3365
|
+
shape: r,
|
|
3366
|
+
first: t,
|
|
3367
|
+
last: t,
|
|
3368
|
+
ctms: null
|
|
3369
|
+
}, t > 0 && this._adoptMaterial(r, n.materialNames), this.tracks.push(s)), a[o] = s;
|
|
3370
|
+
}
|
|
3371
|
+
this.prev = {
|
|
3372
|
+
keys: r,
|
|
3373
|
+
tracks: a
|
|
3374
|
+
}, this._addPlacements(e, t, this._resolveTemplates(e, t, n)), this.cameras.push(e.camera ? {
|
|
3375
|
+
cameraToWorld: e.camera.cameraToWorld,
|
|
3376
|
+
fov: e.camera.params?.fov?.value?.[0]
|
|
3377
|
+
} : null);
|
|
3378
|
+
}
|
|
3379
|
+
_adoptDefinitions(e) {
|
|
3380
|
+
for (let [t, n] of e.namedMaterials) this.base.namedMaterials.has(t) || this.base.namedMaterials.set(t, n);
|
|
3381
|
+
for (let [t, n] of e.namedTextures) this.base.namedTextures.has(t) || this.base.namedTextures.set(t, n);
|
|
3382
|
+
}
|
|
3383
|
+
_resolveTemplates(e, t, n) {
|
|
3384
|
+
let r = /* @__PURE__ */ new Map();
|
|
3385
|
+
for (let [i, a] of e.objects) {
|
|
3386
|
+
let e = "";
|
|
3387
|
+
for (let t of a) e += n.of(t) + "@" + Array.prototype.join.call(t.relativeCTM || t.ctm, ",") + ";";
|
|
3388
|
+
let o = i + "\0" + e, s = this.templates.get(o);
|
|
3389
|
+
if (s === void 0 && (s = t === 0 || !this.base.objects.has(i) ? i : `${i} @${t}`, this.templates.set(o, s), t > 0)) {
|
|
3390
|
+
for (let e of a) this._adoptMaterial(e, n.materialNames);
|
|
3391
|
+
this.base.objects.set(s, a);
|
|
3392
|
+
}
|
|
3393
|
+
r.set(i, s);
|
|
3394
|
+
}
|
|
3395
|
+
return r;
|
|
3396
|
+
}
|
|
3397
|
+
_adoptMaterial(e, t) {
|
|
3398
|
+
let n = e.material && t.get(e.material);
|
|
3399
|
+
n !== void 0 && (e.material = this.base.namedMaterials.get(n) ?? e.material);
|
|
3400
|
+
}
|
|
3401
|
+
_addPlacements(e, t, n) {
|
|
3402
|
+
for (let [r, i] of e.instances) {
|
|
3403
|
+
let e = n.get(r) ?? r, a = this.placements.get(e);
|
|
3404
|
+
if (a || this.placements.set(e, a = {
|
|
3405
|
+
counts: new Int32Array(this.times.length),
|
|
3406
|
+
diffs: /* @__PURE__ */ new Map()
|
|
3407
|
+
}), a.counts[t] = i.count, t === 0) continue;
|
|
3408
|
+
let o = this.base.instances.get(e), s = o?.count ?? 0;
|
|
3409
|
+
for (let e = 0; e < i.count; e++) {
|
|
3410
|
+
let n = e * 16;
|
|
3411
|
+
if (e < s && kr(i.matrices, n, o.matrices, n)) continue;
|
|
3412
|
+
let r = a.diffs.get(e);
|
|
3413
|
+
r || a.diffs.set(e, r = /* @__PURE__ */ new Map()), r.set(t, i.matrices.slice(n, n + 16));
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
finish() {
|
|
3418
|
+
let e = this.base, t = this.times, n = this.frame + 1;
|
|
3419
|
+
e.shapes = this.tracks.map((e) => {
|
|
3420
|
+
let { shape: r, first: i, last: a, ctms: o } = e;
|
|
3421
|
+
return (i > 0 || a < n - 1 || o) && (r.motion = Ar(t, (e) => e >= i && e <= a, (e) => o ? o[e - i] : r.ctm)), r;
|
|
3422
|
+
}), e.warnings = [...this.warnings], e.animatedInstances = this._finishPlacements(e, t, n);
|
|
3423
|
+
let r = this.cameras;
|
|
3424
|
+
if (r[0] && r.every(Boolean)) {
|
|
3425
|
+
let n = Ar(t, () => !0, (e) => r[e].cameraToWorld), i = r.map((e) => e.fov ?? r[0].fov), a = i.some((e) => e !== i[0]);
|
|
3426
|
+
(!jr(n) || a) && (e.camera.motion = {
|
|
3427
|
+
...n,
|
|
3428
|
+
fov: a ? Float32Array.from(i) : null
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
return e.animation = {
|
|
3432
|
+
name: this.name,
|
|
3433
|
+
duration: t[n - 1],
|
|
3434
|
+
frames: n
|
|
3435
|
+
}, e;
|
|
3436
|
+
}
|
|
3437
|
+
_finishPlacements(e, t, n) {
|
|
3438
|
+
let r = [], i = 0;
|
|
3439
|
+
for (let [a, { counts: o, diffs: s }] of this.placements) {
|
|
3440
|
+
let c = e.instances.get(a), l = c?.count ?? 0, u = Math.max(...o.subarray(0, n)), d = [];
|
|
3441
|
+
for (let e = 0; e < u; e++) {
|
|
3442
|
+
let u = s.get(e), f = !!u;
|
|
3443
|
+
for (let t = 0; t < n && !f; t++) f = e >= o[t];
|
|
3444
|
+
if (f && r.length < br) {
|
|
3445
|
+
let n = Ar(t, (t) => e < o[t], (t) => u?.get(t) ?? c.matrices.subarray(e * 16, e * 16 + 16));
|
|
3446
|
+
r.push({
|
|
3447
|
+
name: a,
|
|
3448
|
+
motion: n
|
|
3449
|
+
});
|
|
3450
|
+
} else f && i++, e < l && d.push(e);
|
|
3451
|
+
}
|
|
3452
|
+
if (c && d.length !== l) {
|
|
3453
|
+
let t = new Float32Array(d.length * 16);
|
|
3454
|
+
d.forEach((e, n) => t.set(c.matrices.subarray(e * 16, e * 16 + 16), n * 16)), e.instanceCount -= l - d.length, c.matrices = t, c.matricesEnd = null, c.count = d.length;
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
return i > 0 && e.warnings.push(`${i.toLocaleString()} moving placement(s) past ${br.toLocaleString()} left static`), r;
|
|
3458
|
+
}
|
|
3459
|
+
};
|
|
3460
|
+
function Nr(e) {
|
|
3461
|
+
if (!e.hasMotion) return e;
|
|
3462
|
+
let { start: t, end: n } = e.transformTimes, r = n - t;
|
|
3463
|
+
if (!(r > 0)) return e;
|
|
3464
|
+
let i = Float32Array.of(0, r), a = (e, t, n, r) => {
|
|
3465
|
+
let a = new Float32Array(32);
|
|
3466
|
+
for (let i = 0; i < 16; i++) a[i] = e[t + i], a[16 + i] = n[r + i];
|
|
3467
|
+
return {
|
|
3468
|
+
times: i,
|
|
3469
|
+
matrices: a,
|
|
3470
|
+
visible: null
|
|
3471
|
+
};
|
|
3472
|
+
};
|
|
3473
|
+
for (let t of e.shapes) t.ctmEnd && (t.motion = a(t.ctm, 0, t.ctmEnd, 0));
|
|
3474
|
+
e.animatedInstances = [];
|
|
3475
|
+
for (let t of e.instances.values()) {
|
|
3476
|
+
if (!t.matricesEnd) continue;
|
|
3477
|
+
let n = [];
|
|
3478
|
+
for (let r = 0; r < t.count; r++) {
|
|
3479
|
+
let i = r * 16;
|
|
3480
|
+
kr(t.matrices, i, t.matricesEnd, i) || e.animatedInstances.length >= br ? n.push(r) : e.animatedInstances.push({
|
|
3481
|
+
name: t.name,
|
|
3482
|
+
motion: a(t.matrices, i, t.matricesEnd, i)
|
|
3483
|
+
});
|
|
3484
|
+
}
|
|
3485
|
+
if (n.length !== t.count) {
|
|
3486
|
+
let r = new Float32Array(n.length * 16);
|
|
3487
|
+
n.forEach((e, n) => r.set(t.matrices.subarray(e * 16, e * 16 + 16), n * 16)), e.instanceCount -= t.count - n.length, t.matrices = r, t.count = n.length;
|
|
3488
|
+
}
|
|
3489
|
+
t.matricesEnd = null;
|
|
3490
|
+
}
|
|
3491
|
+
return e.camera?.cameraToWorldEnd && (e.camera.motion = {
|
|
3492
|
+
...a(e.camera.cameraToWorld, 0, e.camera.cameraToWorldEnd, 0),
|
|
3493
|
+
fov: null
|
|
3494
|
+
}), e.animation = {
|
|
3495
|
+
name: "Shutter motion",
|
|
3496
|
+
duration: r,
|
|
3497
|
+
frames: 2
|
|
3498
|
+
}, e;
|
|
3499
|
+
}
|
|
3500
|
+
//#endregion
|
|
3501
|
+
//#region src/Processor/PBRT/index.js
|
|
3502
|
+
var Pr = 2e6, Fr = new TextDecoder();
|
|
3503
|
+
function Ir(e) {
|
|
3504
|
+
let t = e.replace(/\\/g, "/").split("/"), n = [];
|
|
3505
|
+
for (let e of t) e === "" || e === "." || (e === ".." ? n.pop() : n.push(e));
|
|
3506
|
+
return n.join("/");
|
|
3507
|
+
}
|
|
3508
|
+
function Lr(e, t) {
|
|
3509
|
+
return !e || t.startsWith("/") ? Ir(t) : Ir(`${e}/${t}`);
|
|
3510
|
+
}
|
|
3511
|
+
var Rr = class {
|
|
3512
|
+
constructor(e, t = null) {
|
|
3513
|
+
this.entries = e, this.source = t, this.records = [], this.byPath = /* @__PURE__ */ new Map(), this.byBase = /* @__PURE__ */ new Map();
|
|
3514
|
+
let n = (e, t, n) => {
|
|
3515
|
+
let r = Ir(e).toLowerCase();
|
|
3516
|
+
if (this.byPath.has(r)) return;
|
|
3517
|
+
let i = {
|
|
3518
|
+
key: e,
|
|
3519
|
+
norm: r,
|
|
3520
|
+
bytes: t,
|
|
3521
|
+
lazy: n
|
|
3522
|
+
};
|
|
3523
|
+
this.records.push(i), this.byPath.set(r, i);
|
|
3524
|
+
let a = r.split("/").pop(), o = this.byBase.get(a);
|
|
3525
|
+
o ? o.push(i) : this.byBase.set(a, [i]);
|
|
3526
|
+
};
|
|
3527
|
+
for (let t in e) n(t, e[t], !1);
|
|
3528
|
+
for (let e of t?.listing ?? []) e.offset !== void 0 && n(e.path, null, !0);
|
|
3529
|
+
}
|
|
3530
|
+
async read(e) {
|
|
3531
|
+
return e ? e.bytes ? e.bytes : !e.lazy || !this.source ? null : this.source.read(e.key) : null;
|
|
3532
|
+
}
|
|
3533
|
+
async readHead(e, t) {
|
|
3534
|
+
return e ? e.bytes ? e.bytes.subarray(0, t) : !e.lazy || !this.source ? null : this.source.readHead ? this.source.readHead(e.key, t) : this.source.read(e.key) : null;
|
|
3535
|
+
}
|
|
3536
|
+
async readPath(e, t = null) {
|
|
3537
|
+
let n = t !== null && this.findRecord(Lr(t, e)) || this.findRecord(e);
|
|
3538
|
+
return this.read(n);
|
|
3539
|
+
}
|
|
3540
|
+
release(e) {
|
|
3541
|
+
e.bytes = null, delete this.entries[e.key];
|
|
3542
|
+
}
|
|
3543
|
+
releasePath(e, t = null, n = null) {
|
|
3544
|
+
let r = t !== null && this.findRecord(Lr(t, e)) || this.findRecord(e);
|
|
3545
|
+
r?.lazy && (this.release(r), H(n));
|
|
3546
|
+
}
|
|
3547
|
+
releaseScenes() {
|
|
3548
|
+
for (let e of this.records) e.norm.endsWith(".pbrt") && this.release(e);
|
|
3549
|
+
}
|
|
3550
|
+
findRecord(e) {
|
|
3551
|
+
let t = Ir(e).toLowerCase();
|
|
3552
|
+
if (this.byPath.has(t)) return this.byPath.get(t);
|
|
3553
|
+
let n = this.byBase.get(t.split("/").pop());
|
|
3554
|
+
return n ? n.find((e) => e.norm.endsWith("/" + t)) || (n.length === 1 ? n[0] : null) : null;
|
|
3555
|
+
}
|
|
3556
|
+
find(e) {
|
|
3557
|
+
return this.findRecord(e)?.bytes ?? null;
|
|
3558
|
+
}
|
|
3559
|
+
};
|
|
3560
|
+
function zr(e, t, n = 0) {
|
|
3561
|
+
let r = t[0], i = e.length - t.length;
|
|
3562
|
+
outer: for (let a = n; a <= i; a++) if (e[a] === r) {
|
|
3563
|
+
for (let n = 1; n < t.length; n++) if (e[a + n] !== t[n]) continue outer;
|
|
3564
|
+
return a;
|
|
3565
|
+
}
|
|
3566
|
+
return -1;
|
|
3567
|
+
}
|
|
3568
|
+
var Br = (e) => Uint8Array.from(e, (e) => e.charCodeAt(0)), Vr = 4 * 1024 * 1024, Hr = Br("WorldBegin"), Ur = [Br("Include"), Br("Import")];
|
|
3569
|
+
function Wr(e, t) {
|
|
3570
|
+
for (let n = t - 1; n >= 0; n--) {
|
|
3571
|
+
let t = e[n];
|
|
3572
|
+
if (t === 10) return !0;
|
|
3573
|
+
if (t !== 32 && t !== 9) return !1;
|
|
3574
|
+
}
|
|
3575
|
+
return !0;
|
|
3576
|
+
}
|
|
3577
|
+
function Gr(e) {
|
|
3578
|
+
for (let t = zr(e, Hr); t >= 0; t = zr(e, Hr, t + 1)) if (Wr(e, t)) return !0;
|
|
3579
|
+
return !1;
|
|
3580
|
+
}
|
|
3581
|
+
function Kr(e, t) {
|
|
3582
|
+
for (let n of Ur) for (let r = zr(e, n); r >= 0; r = zr(e, n, r + 1)) {
|
|
3583
|
+
if (!Wr(e, r)) continue;
|
|
3584
|
+
let i = r + n.length;
|
|
3585
|
+
for (; i < e.length && (e[i] === 32 || e[i] === 9);) i++;
|
|
3586
|
+
if (e[i] !== 34) continue;
|
|
3587
|
+
let a = ++i;
|
|
3588
|
+
for (; i < e.length && e[i] !== 34 && e[i] !== 10;) i++;
|
|
3589
|
+
if (e[i] !== 34) continue;
|
|
3590
|
+
let o = Fr.decode(e.subarray(a, i));
|
|
3591
|
+
t.add(Ir(o).toLowerCase().split("/").pop());
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
function qr(e) {
|
|
3595
|
+
let t = Object.keys(e).filter((e) => e.toLowerCase().endsWith(".pbrt"));
|
|
3596
|
+
if (t.length <= 1) return t;
|
|
3597
|
+
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Map();
|
|
3598
|
+
for (let i of t) {
|
|
3599
|
+
let t = e[i];
|
|
3600
|
+
r.set(i, Gr(t)), Kr(t, n);
|
|
3601
|
+
}
|
|
3602
|
+
return Jr(t, r, n);
|
|
3603
|
+
}
|
|
3604
|
+
function Jr(e, t, n) {
|
|
3605
|
+
let r = (e, t) => {
|
|
3606
|
+
let n = e.filter(t);
|
|
3607
|
+
return n.length ? n : e;
|
|
3608
|
+
}, i = r(e, (e) => t.get(e));
|
|
3609
|
+
return i = r(i, (e) => !n.has(e.toLowerCase().split("/").pop())), i = r(i, (e) => /(^|\/)(scene|main)\.pbrt$/i.test(e)), i.sort((e, t) => {
|
|
3610
|
+
let n = e.split("/").length, r = t.split("/").length;
|
|
3611
|
+
return n === r ? e.length === t.length ? e < t ? -1 : +(e > t) : e.length - t.length : n - r;
|
|
3612
|
+
});
|
|
3613
|
+
}
|
|
3614
|
+
function Yr(e) {
|
|
3615
|
+
return qr(e)[0] || null;
|
|
3616
|
+
}
|
|
3617
|
+
async function Xr(e) {
|
|
3618
|
+
let t = e.records.filter((e) => e.norm.endsWith(".pbrt"));
|
|
3619
|
+
if (t.length === 0) return [];
|
|
3620
|
+
if (t.length === 1) return [t[0].key];
|
|
3621
|
+
let n = async (n) => {
|
|
3622
|
+
let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map(), a = !1;
|
|
3623
|
+
for (let o of t) {
|
|
3624
|
+
let t = await n(o);
|
|
3625
|
+
t && (i.set(o.key, Gr(t)), Kr(t, r), t.length >= Vr && (a = !0), o.lazy && (e.release(o), H(t)));
|
|
3626
|
+
}
|
|
3627
|
+
return {
|
|
3628
|
+
included: r,
|
|
3629
|
+
worlds: i,
|
|
3630
|
+
cut: a
|
|
3631
|
+
};
|
|
3632
|
+
}, r = await n((t) => e.readHead(t, Vr)), { included: i, worlds: a } = [...r.worlds.values()].filter(Boolean).length === 1 || !r.cut ? r : await n((t) => e.read(t));
|
|
3633
|
+
return Jr(t.map((e) => e.key), a, i);
|
|
3634
|
+
}
|
|
3635
|
+
async function Zr(e) {
|
|
3636
|
+
let { vfs: t, source: n, plyParser: r, imageFromBytes: i, envFromBytes: a, convertHandedness: o } = e, s = new Rr(t, n), c = [], l = await Xr(s);
|
|
3637
|
+
if (l.length === 0) throw Error("PBRT loader: no .pbrt file found in archive");
|
|
3638
|
+
let u = e.entryPath && l.includes(e.entryPath) ? e.entryPath : null;
|
|
3639
|
+
e.entryPath && !u && c.push(`PBRT entry "${e.entryPath}" is not a scene in this archive — auto-detecting instead`);
|
|
3640
|
+
let d = u || l[0], f = async (t) => {
|
|
3641
|
+
let n = await s.readPath(t);
|
|
3642
|
+
if (!n) throw Error(`PBRT loader: entry "${t}" not readable`);
|
|
3643
|
+
let r = await new cn({
|
|
3644
|
+
resolveInclude: (e, t) => s.readPath(e, t),
|
|
3645
|
+
releaseInclude: (e, t, n) => s.releasePath(e, t, n),
|
|
3646
|
+
maxPlacements: e.maxPlacements,
|
|
3647
|
+
instanceIncludes: e.instanceIncludes
|
|
3648
|
+
}).parse(n, t.includes("/") ? t.slice(0, t.lastIndexOf("/")) : "");
|
|
3649
|
+
return s.releasePath(t, null, n), r;
|
|
3650
|
+
}, p = performance.now(), m = !u && e.animation !== !1 ? xr(l) : null, h;
|
|
3651
|
+
if (m) {
|
|
3652
|
+
let e = await f(m[0].path);
|
|
3653
|
+
if (e.shapes.length + e.instanceCount > Pr) c.push(`${m.length} animation frames found, but the scene is too large to parse once per frame — loaded "${m[0].path}" only`), m = null, h = Nr(e);
|
|
3654
|
+
else {
|
|
3655
|
+
let t = new Mr(m.map((e) => (e.number - m[0].number) / 30), Qr(m));
|
|
3656
|
+
t.addFrame(e);
|
|
3657
|
+
for (let e = 1; e < m.length; e++) t.addFrame(await f(m[e].path));
|
|
3658
|
+
h = t.finish();
|
|
3659
|
+
}
|
|
3660
|
+
} else h = Nr(await f(d));
|
|
3661
|
+
let g = performance.now() - p;
|
|
3662
|
+
s.releaseScenes();
|
|
3663
|
+
let _ = (e) => e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), v = /* @__PURE__ */ new Map(), y = async (e) => {
|
|
3664
|
+
let t = await s.read(e);
|
|
3665
|
+
return t ? (s.release(e), r(_(t))) : null;
|
|
3666
|
+
}, b = new _r({
|
|
3667
|
+
convertHandedness: o,
|
|
3668
|
+
maxTriangles: e.maxTriangles,
|
|
3669
|
+
maxPlacements: e.maxPlacements,
|
|
3670
|
+
mergeShapesAbove: e.mergeShapesAbove,
|
|
3671
|
+
curveSteps: e.curveSteps,
|
|
3672
|
+
curveSides: e.curveSides,
|
|
3673
|
+
curveTolerance: e.curveTolerance,
|
|
3674
|
+
resolvePLY: async (e) => {
|
|
3675
|
+
let t = s.findRecord(e);
|
|
3676
|
+
return t ? (v.has(t.norm) || v.set(t.norm, await y(t)), v.get(t.norm)) : null;
|
|
3677
|
+
},
|
|
3678
|
+
resolveImage: async (e) => {
|
|
3679
|
+
let t = await s.readPath(e);
|
|
3680
|
+
return t ? i(t, e) : null;
|
|
3681
|
+
},
|
|
3682
|
+
resolveEnvironment: async (e) => {
|
|
3683
|
+
let t = await s.readPath(e);
|
|
3684
|
+
return t ? (a || i)(t, e) : null;
|
|
3685
|
+
}
|
|
3686
|
+
}), x = performance.now(), S = await b.build(h);
|
|
3687
|
+
return {
|
|
3688
|
+
...S,
|
|
3689
|
+
entryPath: m ? m[0].path : d,
|
|
3690
|
+
frames: m ? m.map((e) => e.path) : null,
|
|
3691
|
+
candidates: l,
|
|
3692
|
+
warnings: [...c, ...S.warnings ?? []],
|
|
3693
|
+
parseMs: g,
|
|
3694
|
+
buildMs: performance.now() - x
|
|
3695
|
+
};
|
|
3696
|
+
}
|
|
3697
|
+
function Qr(e) {
|
|
3698
|
+
let t = e[0].path.split("/");
|
|
3699
|
+
return `${t.length > 1 ? t[t.length - 2] : t[0].replace(/\d+\.pbrt$/i, "") || "frames"} · frames ${e[0].number}–${e[e.length - 1].number}`;
|
|
3700
|
+
}
|
|
3701
|
+
//#endregion
|
|
3702
|
+
//#region src/Processor/PBRT/PFM.js
|
|
3703
|
+
function $r(e) {
|
|
3704
|
+
let t = 0, n = () => {
|
|
3705
|
+
for (; t < e.length && e[t] <= 32;) t++;
|
|
3706
|
+
let n = t;
|
|
3707
|
+
for (; t < e.length && e[t] > 32;) t++;
|
|
3708
|
+
return String.fromCharCode(...e.subarray(n, t));
|
|
3709
|
+
}, r = n();
|
|
3710
|
+
if (r !== "PF" && r !== "Pf") throw Error("not a PFM image");
|
|
3711
|
+
let i = parseInt(n(), 10), a = parseInt(n(), 10), o = parseFloat(n());
|
|
3712
|
+
t++;
|
|
3713
|
+
let s = r === "PF" ? 3 : 1, c = i * a;
|
|
3714
|
+
if (!(i > 0 && a > 0) || !Number.isFinite(o) || o === 0) throw Error("bad PFM header");
|
|
3715
|
+
if (e.length - t < c * s * 4) throw Error("PFM image is truncated");
|
|
3716
|
+
let l = new DataView(e.buffer, e.byteOffset + t, c * s * 4), u = o < 0, d = Math.abs(o), f = new Float32Array(c * 4);
|
|
3717
|
+
for (let e = 0; e < c; e++) {
|
|
3718
|
+
for (let t = 0; t < 3; t++) f[e * 4 + t] = l.getFloat32((e * s + (s === 3 ? t : 0)) * 4, u) * d;
|
|
3719
|
+
f[e * 4 + 3] = 1;
|
|
3720
|
+
}
|
|
3721
|
+
return {
|
|
3722
|
+
data: f,
|
|
3723
|
+
width: i,
|
|
3724
|
+
height: a
|
|
3725
|
+
};
|
|
3726
|
+
}
|
|
3727
|
+
function ei(e) {
|
|
3728
|
+
let { data: t, width: n, height: r } = $r(e), i = new b(t, n, r, P, T);
|
|
3729
|
+
return i.minFilter = A, i.magFilter = A, i.needsUpdate = !0, i;
|
|
3730
|
+
}
|
|
3731
|
+
//#endregion
|
|
3732
|
+
//#region src/Processor/ArchiveImporter.js
|
|
3733
|
+
var ti = /* @__PURE__ */ e({
|
|
3734
|
+
ARCHIVE_ELEMENT_PROMPT_BYTES: () => ai,
|
|
3735
|
+
ArchiveImporter: () => oi
|
|
3736
|
+
}), ni = /\.(usd|usda|usdc)$/i, ri = /\.(png|jpg|jpeg|avif)$/i, ii = 3e4, ai = 4e9, oi = class e {
|
|
3737
|
+
static FORMATS = f;
|
|
3738
|
+
constructor(e) {
|
|
3739
|
+
this.loader = e, this._pendingGraph = null, this.lastPBRTStats = null;
|
|
3740
|
+
}
|
|
3741
|
+
release() {
|
|
3742
|
+
this._pendingGraph = null;
|
|
3743
|
+
}
|
|
3744
|
+
async _readHead(e, t = 512) {
|
|
3745
|
+
return e instanceof Uint8Array ? e.subarray(0, t) : typeof e.slice == "function" && typeof e.arrayBuffer == "function" ? new Uint8Array(await e.slice(0, t).arrayBuffer()) : new Uint8Array((await this.loader.readFileAsArrayBuffer(e)).slice(0, t));
|
|
3746
|
+
}
|
|
3747
|
+
async inspectArchive(e) {
|
|
3748
|
+
let n = Te(await this._readHead(e)), r = (e) => t({
|
|
3749
|
+
isLoading: !0,
|
|
3750
|
+
status: `Scanning archive… ${(e.bytes / 1e9).toFixed(1)} GB`,
|
|
3751
|
+
progress: 4
|
|
3752
|
+
}), i;
|
|
3753
|
+
if (n === "gzip") {
|
|
3754
|
+
let t = await this._unpackGzip(e, e.name);
|
|
3755
|
+
t ? (i = t.index.listing, t.release()) : {listing: i} = await Le(e, {
|
|
3756
|
+
filter: () => !1,
|
|
3757
|
+
onProgress: r
|
|
3758
|
+
});
|
|
3759
|
+
} else i = n === "tar" ? (await Je(e, this.loader.storage))?.listing ?? await ze(e, { onProgress: r }) : (await p(e)).map((e) => ({
|
|
3760
|
+
path: e.name,
|
|
3761
|
+
size: e.size
|
|
3762
|
+
}));
|
|
3763
|
+
let { root: a, elements: o } = Ue(i);
|
|
3764
|
+
return {
|
|
3765
|
+
kind: n ?? "zip",
|
|
3766
|
+
root: a,
|
|
3767
|
+
elements: o,
|
|
3768
|
+
entryCount: i.length,
|
|
3769
|
+
totalBytes: i.reduce((e, t) => e + t.size, 0)
|
|
3770
|
+
};
|
|
3771
|
+
}
|
|
3772
|
+
async _unpackGzip(e, n) {
|
|
3773
|
+
try {
|
|
3774
|
+
return await qe(e, {
|
|
3775
|
+
storage: this.loader.storage,
|
|
3776
|
+
label: n,
|
|
3777
|
+
onProgress: (e) => t({
|
|
3778
|
+
isLoading: !0,
|
|
3779
|
+
status: `Unpacking archive… ${(e / 1e9).toFixed(1)} GB`,
|
|
3780
|
+
progress: 4
|
|
3781
|
+
})
|
|
3782
|
+
});
|
|
3783
|
+
} catch (e) {
|
|
3784
|
+
return console.warn(`Unpacking "${n}" to storage failed, reading it in memory: ${e.message}`), null;
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
async loadArchiveFromFile(e, t, { pbrtEntry: n = null, element: r = null, byteBudget: i, promptBytes: a, ...o } = {}) {
|
|
3788
|
+
try {
|
|
3789
|
+
let s = Te(await this._readHead(e)), c = this.loader.storage ? u(await l(e)) : null, d = {
|
|
3790
|
+
element: r,
|
|
3791
|
+
promptBytes: a,
|
|
3792
|
+
pbrtEntry: n,
|
|
3793
|
+
pbrt: o,
|
|
3794
|
+
archiveId: c
|
|
3795
|
+
};
|
|
3796
|
+
if (s === "tar") return await this._loadSeekable(e, t, d);
|
|
3797
|
+
if (s === "gzip") {
|
|
3798
|
+
let a = await this._unpackGzip(e, t);
|
|
3799
|
+
if (a) try {
|
|
3800
|
+
return await this._loadSeekable(a.file, t, {
|
|
3801
|
+
...d,
|
|
3802
|
+
index: a.index
|
|
3803
|
+
});
|
|
3804
|
+
} finally {
|
|
3805
|
+
a.release();
|
|
3806
|
+
}
|
|
3807
|
+
let l = await this._readStreamedArchive(e, t, s, r, i);
|
|
3808
|
+
if (Yr(l)) return await this.loadPBRTFromZip(l, t, n, o);
|
|
3809
|
+
let u = await this._loadNonPBRTArchive(l, t);
|
|
3810
|
+
return this.loader._sourceKey = this.loader._keyed("archive", c), u;
|
|
3811
|
+
}
|
|
3812
|
+
return await this._loadSeekable(e, t, {
|
|
3813
|
+
...d,
|
|
3814
|
+
zip: !0
|
|
3815
|
+
});
|
|
3816
|
+
} catch (e) {
|
|
3817
|
+
throw e?.code !== "ARCHIVE_NEEDS_ELEMENT" && console.error("Error loading archive:", e), e;
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
async _loadNonPBRTArchive(e, t) {
|
|
3821
|
+
return await this.processObjMtlPairsInZip(e, t) || await this.findAndLoadModelFromZip(e, t);
|
|
3822
|
+
}
|
|
3823
|
+
async _loadSeekable(e, t, { element: n, promptBytes: r, pbrtEntry: i, pbrt: a, index: o = null, zip: s = !1, archiveId: c = null }) {
|
|
3824
|
+
let l = await this._openSeekableArchive(e, t, n, r, {
|
|
3825
|
+
index: o,
|
|
3826
|
+
zip: s
|
|
3827
|
+
});
|
|
3828
|
+
if (l.archiveId = c, l.elements = (Array.isArray(n) ? n : [n]).filter(Boolean), l.listing.some((e) => e.path.toLowerCase().endsWith(".pbrt"))) return await this.loadPBRTFromZip({}, t, i, a, l);
|
|
3829
|
+
for (let e of l.listing) e.offset !== void 0 && (l.entries[e.path] ??= await l.read(e.path));
|
|
3830
|
+
let u = await this._loadNonPBRTArchive(l.entries, t);
|
|
3831
|
+
return this.loader._sourceKey = this.loader._keyed("archive", c), u;
|
|
3832
|
+
}
|
|
3833
|
+
async _loadStoredGraph(e, n, { imageFromBytes: r, envFromBytes: i }) {
|
|
3834
|
+
let o = this.loader.storage?.area(s.SCENES), c = o ? await o.open(e) : null;
|
|
3835
|
+
if (!c) return null;
|
|
3836
|
+
let l = performance.now(), u = null;
|
|
3837
|
+
try {
|
|
3838
|
+
t({
|
|
3839
|
+
isLoading: !0,
|
|
3840
|
+
status: "Opening the stored scene...",
|
|
3841
|
+
progress: 6
|
|
3842
|
+
});
|
|
3843
|
+
let e = await c.json("graph.json"), a = await c.file("data.bin"), o = new Rr({}, n), s = await xt(e, a, { loadTexture: async (e, t) => {
|
|
3844
|
+
let n = await o.readPath(e);
|
|
3845
|
+
return n ? t === "environment" ? i(n, e) : r(n, e) : null;
|
|
3846
|
+
} });
|
|
3847
|
+
return {
|
|
3848
|
+
...s.stats,
|
|
3849
|
+
group: s.root,
|
|
3850
|
+
environment: s.environment ? { texture: s.environment } : null,
|
|
3851
|
+
animations: s.animations,
|
|
3852
|
+
report: null,
|
|
3853
|
+
parseMs: 0,
|
|
3854
|
+
buildMs: performance.now() - l,
|
|
3855
|
+
fromStorage: !0
|
|
3856
|
+
};
|
|
3857
|
+
} catch (e) {
|
|
3858
|
+
return u = e, null;
|
|
3859
|
+
} finally {
|
|
3860
|
+
c.release(), u && (console.warn(`The stored scene could not be used, parsing the archive instead: ${u.message}`), this.loader._issues?.warn(a.STORAGE_ENTRY_CORRUPT, `stored scene unusable: ${u.message}`, { key: e }), o.remove(e).catch(() => {}));
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
_storeGraph(e, t, r) {
|
|
3864
|
+
let i = this.loader.storage?.area(s.SCENES);
|
|
3865
|
+
if (!i) return;
|
|
3866
|
+
let a;
|
|
3867
|
+
try {
|
|
3868
|
+
a = mt(t.group, {
|
|
3869
|
+
environment: t.environment?.texture ?? null,
|
|
3870
|
+
animations: t.animations ?? [],
|
|
3871
|
+
stats: {
|
|
3872
|
+
meshCount: t.meshCount,
|
|
3873
|
+
entryPath: t.entryPath,
|
|
3874
|
+
candidates: t.candidates,
|
|
3875
|
+
frames: t.frames,
|
|
3876
|
+
warnings: t.warnings,
|
|
3877
|
+
triangleCount: t.triangleCount,
|
|
3878
|
+
placementCount: t.placementCount,
|
|
3879
|
+
mergedShapes: t.mergedShapes,
|
|
3880
|
+
skippedForBudget: t.skippedForBudget,
|
|
3881
|
+
droppedNoTemplate: t.droppedNoTemplate
|
|
3882
|
+
}
|
|
3883
|
+
});
|
|
3884
|
+
} catch (e) {
|
|
3885
|
+
e instanceof V ? console.info(`Scene not stored for next time: ${e.message}`) : console.warn("Scene not stored for next time:", e);
|
|
3886
|
+
return;
|
|
3887
|
+
}
|
|
3888
|
+
let o = {
|
|
3889
|
+
key: e,
|
|
3890
|
+
encoded: a,
|
|
3891
|
+
label: r,
|
|
3892
|
+
parseMs: (t.parseMs ?? 0) + (t.buildMs ?? 0),
|
|
3893
|
+
triangles: t.triangleCount ?? null
|
|
3894
|
+
};
|
|
3895
|
+
n(o.parseMs, a.byteLength) ? this._writeGraph(i, o) : this._pendingGraph = o;
|
|
3896
|
+
}
|
|
3897
|
+
flushPendingGraph(e) {
|
|
3898
|
+
let t = this._pendingGraph;
|
|
3899
|
+
this._pendingGraph = null;
|
|
3900
|
+
let r = this.loader.storage?.area(s.SCENES);
|
|
3901
|
+
!t || !r || !n(t.parseMs + e, t.encoded.byteLength) || this._writeGraph(r, t);
|
|
3902
|
+
}
|
|
3903
|
+
_writeGraph(e, t) {
|
|
3904
|
+
(async () => {
|
|
3905
|
+
let n = await e.create(t.key, {
|
|
3906
|
+
label: `${t.label} (scene)`,
|
|
3907
|
+
expectedBytes: t.encoded.byteLength
|
|
3908
|
+
});
|
|
3909
|
+
if (n) try {
|
|
3910
|
+
await ht(n, t.encoded, { release: !0 }), await n.commit({ triangles: t.triangles });
|
|
3911
|
+
} catch (e) {
|
|
3912
|
+
await n.abort(), console.warn("Storing the scene failed:", e);
|
|
3913
|
+
}
|
|
3914
|
+
})().catch((e) => console.warn("Storing the scene failed:", e));
|
|
3915
|
+
}
|
|
3916
|
+
async _openSeekableArchive(e, n, r, i, { index: a = null, zip: o = !1 } = {}) {
|
|
3917
|
+
let s = Array.isArray(r) ? r.filter(Boolean) : r ? [r] : [], c = s.length ? He(s) : null, l;
|
|
3918
|
+
if (o) l = await m(e, { filter: c });
|
|
3919
|
+
else {
|
|
3920
|
+
let n = a ?? await Je(e, this.loader.storage);
|
|
3921
|
+
l = await Ve(e, {
|
|
3922
|
+
index: n,
|
|
3923
|
+
headersOnly: !0,
|
|
3924
|
+
filter: c,
|
|
3925
|
+
onProgress: (e) => t({
|
|
3926
|
+
isLoading: !0,
|
|
3927
|
+
status: `Indexing archive… ${(e.bytes / 1e9).toFixed(1)} GB`,
|
|
3928
|
+
progress: 4
|
|
3929
|
+
})
|
|
3930
|
+
}), n || Ye(e, this.loader.storage, l.index).catch(() => {});
|
|
3931
|
+
}
|
|
3932
|
+
let u = l.listing.reduce((e, t) => e + t.size, 0);
|
|
3933
|
+
return s.length === 0 && this._requireElementChoice(n, l.listing, u, i), console.info(`Archive "${n}": indexed ${l.indexed} entries, ${(u / 1e9).toFixed(1)} GB, none resident` + (s.length ? `, ${s.length} part${s.length > 1 ? "s" : ""} selected.` : ".")), l;
|
|
3934
|
+
}
|
|
3935
|
+
_requireElementChoice(e, t, n, r = ai) {
|
|
3936
|
+
if (n < r) return;
|
|
3937
|
+
let { root: i, elements: s } = Ue(t);
|
|
3938
|
+
if (s.length < 2) return;
|
|
3939
|
+
let c = /* @__PURE__ */ Error(`"${e}" holds ${(n / 1e9).toFixed(1)} GB across ${s.length} parts. Choose which to load — loading all of them at once may exhaust memory.`);
|
|
3940
|
+
throw c.code = "ARCHIVE_NEEDS_ELEMENT", c.root = i, c.elements = s, c.totalBytes = n, this.loader._issues?.record(a.ASSET_ARCHIVE_TOO_LARGE, `archive holds ${(n / 1e9).toFixed(1)} GB across ${s.length} parts; choose which to load`, {
|
|
3941
|
+
root: i,
|
|
3942
|
+
elements: s.map((e) => e.prefix),
|
|
3943
|
+
totalBytes: n
|
|
3944
|
+
}, o.WARNING), c;
|
|
3945
|
+
}
|
|
3946
|
+
async _readStreamedArchive(e, n, r, i, s) {
|
|
3947
|
+
let c = Array.isArray(i) ? i.filter(Boolean) : i ? [i] : [], { entries: l, listing: u, retainedBytes: d, truncated: f } = await Le(e, {
|
|
3948
|
+
filter: c.length ? He(c) : null,
|
|
3949
|
+
...s === void 0 ? {} : { byteBudget: s },
|
|
3950
|
+
onProgress: (e) => t({
|
|
3951
|
+
isLoading: !0,
|
|
3952
|
+
status: `Reading archive… ${(e.bytes / 1e9).toFixed(1)} GB`,
|
|
3953
|
+
progress: 4
|
|
3954
|
+
})
|
|
3955
|
+
});
|
|
3956
|
+
if (f && c.length === 0) {
|
|
3957
|
+
let { root: e, elements: t } = Ue(u), r = u.reduce((e, t) => e + t.size, 0), i = /* @__PURE__ */ Error(`"${n}" unpacks to ${(r / 1e9).toFixed(1)} GB, past the load budget. Load one of its ${t.length} parts instead.`);
|
|
3958
|
+
throw i.code = "ARCHIVE_NEEDS_ELEMENT", i.root = e, i.elements = t, i.totalBytes = r, this.loader._issues?.record(a.ASSET_ARCHIVE_TOO_LARGE, `archive unpacks to ${(r / 1e9).toFixed(1)} GB; choose one of ${t.length} parts`, {
|
|
3959
|
+
root: e,
|
|
3960
|
+
elements: t.map((e) => e.prefix),
|
|
3961
|
+
totalBytes: r
|
|
3962
|
+
}, o.WARNING), i;
|
|
3963
|
+
}
|
|
3964
|
+
if (f) {
|
|
3965
|
+
let e = He(c), t = u.filter((t) => e(t.path, t.size) && !l[t.path]).length;
|
|
3966
|
+
this.loader._issues?.record(a.ASSET_ARCHIVE_TOO_LARGE, `${t} files of the chosen parts were left out: they did not fit the ${((s ?? 15e8) / 1e9).toFixed(1)} GB in-memory read budget`, {
|
|
3967
|
+
elements: c,
|
|
3968
|
+
missing: t,
|
|
3969
|
+
retainedBytes: d
|
|
3970
|
+
}, o.WARNING);
|
|
3971
|
+
}
|
|
3972
|
+
return c.length && console.info(`Archive "${n}": loaded ${c.map((e) => `"${e}"`).join(", ")} — ${Object.keys(l).length} of ${u.length} files, ${(d / 1048576).toFixed(1)} MB.`), l;
|
|
3973
|
+
}
|
|
3974
|
+
async loadPBRTFromZip(e, n, s = null, l = {}, u = null) {
|
|
3975
|
+
if (t({
|
|
3976
|
+
isLoading: !0,
|
|
3977
|
+
status: "Parsing PBRT scene...",
|
|
3978
|
+
progress: 5
|
|
3979
|
+
}), !this.loader.loaderCache.ply) {
|
|
3980
|
+
let { PLYLoader: e } = await import("three/examples/jsm/loaders/PLYLoader.js");
|
|
3981
|
+
this.loader.loaderCache.ply = new e();
|
|
3982
|
+
}
|
|
3983
|
+
let d = (e) => this.loader.loaderCache.ply.parse(e), f = async (e, t) => {
|
|
3984
|
+
let n = await this._pbrtTextureFromBytes(e, t);
|
|
3985
|
+
return n && (n.userData[Ze] = t), n;
|
|
3986
|
+
}, p = async (e, t) => {
|
|
3987
|
+
let n = t.split(".").pop().toLowerCase(), i = new Blob([e]), a = n === "pfm" ? null : URL.createObjectURL(i);
|
|
3988
|
+
try {
|
|
3989
|
+
let o = a ? await this.loader.loadEnvironmentByExtension(a, n, { loader: n === "exr" ? this._exrLoader() : null }) : ei(e);
|
|
3990
|
+
return o.mapping = C, r(o, `bytes:${await c(i)}`), o.userData[Ze] = t, o.userData[Qe] = "environment", o;
|
|
3991
|
+
} finally {
|
|
3992
|
+
a && URL.revokeObjectURL(a);
|
|
3993
|
+
}
|
|
3994
|
+
}, m = performance.now(), h = {
|
|
3995
|
+
animation: l.animation,
|
|
3996
|
+
maxTriangles: l.maxTriangles,
|
|
3997
|
+
maxPlacements: l.maxPlacements,
|
|
3998
|
+
mergeShapesAbove: l.mergeShapesAbove,
|
|
3999
|
+
curveSteps: l.curveSteps,
|
|
4000
|
+
curveSides: l.curveSides,
|
|
4001
|
+
curveTolerance: l.curveTolerance,
|
|
4002
|
+
instanceIncludes: l.instanceIncludes
|
|
4003
|
+
}, g = u?.archiveId ? this.loader._keyed(`pbrt:2.8:${i}`, `${u.archiveId}|${s ?? ""}|${[...u.elements ?? []].sort().join(",")}|${JSON.stringify(h)}`) : null, _ = g ? await this._loadStoredGraph(g, u, {
|
|
4004
|
+
imageFromBytes: f,
|
|
4005
|
+
envFromBytes: p
|
|
4006
|
+
}) : null, v = _ ?? await Zr({
|
|
4007
|
+
vfs: e,
|
|
4008
|
+
source: u,
|
|
4009
|
+
entryPath: s,
|
|
4010
|
+
plyParser: d,
|
|
4011
|
+
imageFromBytes: f,
|
|
4012
|
+
envFromBytes: p,
|
|
4013
|
+
...h
|
|
4014
|
+
}), { group: y, environment: b, animations: x, report: S, warnings: w, meshCount: T, entryPath: E, candidates: D, frames: O, parseMs: k, buildMs: A, triangleCount: j, placementCount: M, mergedShapes: N, skippedForBudget: ee, droppedNoTemplate: te } = v;
|
|
4015
|
+
_ && console.info(`PBRT scene "${E}" opened from storage in ${(A / 1e3).toFixed(1)} s, skipping the parse`), this.lastPBRTStats = {
|
|
4016
|
+
parseMs: k,
|
|
4017
|
+
buildMs: A,
|
|
4018
|
+
loaderMs: performance.now() - m,
|
|
4019
|
+
triangleCount: j,
|
|
4020
|
+
placementCount: M,
|
|
4021
|
+
mergedShapes: N,
|
|
4022
|
+
skippedForBudget: ee,
|
|
4023
|
+
droppedNoTemplate: te,
|
|
4024
|
+
meshCount: T,
|
|
4025
|
+
frames: O?.length ?? 1
|
|
4026
|
+
};
|
|
4027
|
+
let ne = new Set(O ?? [E]), re = D.filter((e) => !ne.has(e));
|
|
4028
|
+
if (re.length > 0 && (console.warn(`PBRT archive holds ${D.length} scenes; loaded "${E}". Others: ${re.join(", ")}`), this.loader._issues?.record(a.ASSET_AMBIGUOUS_ENTRY, `archive holds ${D.length} pbrt scenes; loaded "${E}"`, {
|
|
4029
|
+
loaded: E,
|
|
4030
|
+
alternatives: re
|
|
4031
|
+
}, o.WARNING)), S && S.length && typeof console.table == "function") {
|
|
4032
|
+
let e = S.length < T ? ` (first ${S.length} of ${T})` : "";
|
|
4033
|
+
console.groupCollapsed(`PBRT loader: ${T} mesh(es) from "${E}"${e}`), console.table(S), console.groupEnd();
|
|
4034
|
+
}
|
|
4035
|
+
return w && w.length && (console.warn(`PBRT loader: ${w.length} warning(s) parsing "${E}"`), w.forEach((e) => console.warn(" •", e))), b?.texture && (b.texture.generateMipmaps = !0, this.loader.applyEnvironmentToScene(b.texture)), y.name = E || n, this.loader.releaseTargetModel(), this.loader._sourceKey = g, g && !_ && this._storeGraph(g, v, n), this.loader.targetModel = y, this.loader.animations = x ?? [], this.loader.sceneMetadata = { environment: b?.texture ? {
|
|
4036
|
+
rotation: 0,
|
|
4037
|
+
intensity: 1
|
|
4038
|
+
} : { enabled: !1 } }, t({
|
|
4039
|
+
isLoading: !0,
|
|
4040
|
+
status: "Processing PBRT geometry...",
|
|
4041
|
+
progress: 10
|
|
4042
|
+
}), await this.loader.onModelLoad(this.loader.targetModel), this.loader.dispatchEvent({
|
|
4043
|
+
type: "load",
|
|
4044
|
+
model: y,
|
|
4045
|
+
filename: `${E} (from ZIP)`
|
|
4046
|
+
}), y;
|
|
4047
|
+
}
|
|
4048
|
+
_exrLoader() {
|
|
4049
|
+
return this.loader.loaderCache.exr ??= new ve().setDataType(T);
|
|
4050
|
+
}
|
|
4051
|
+
async _pbrtTextureFromBytes(e, t) {
|
|
4052
|
+
let n = t.split(".").pop().toLowerCase(), r;
|
|
4053
|
+
if (n === "exr" || n === "hdr") {
|
|
4054
|
+
let t = n === "hdr" ? this.loader.loaderCache.hdr || (this.loader.loaderCache.hdr = new he().setDataType(T)) : this._exrLoader();
|
|
4055
|
+
r = await this._loadViaObjectURL(t, e);
|
|
4056
|
+
} else if (n === "pfm") r = ei(e);
|
|
4057
|
+
else if (n === "tga") {
|
|
4058
|
+
if (!this.loader.loaderCache.tga) {
|
|
4059
|
+
let { TGALoader: e } = await import("three/examples/jsm/loaders/TGALoader.js");
|
|
4060
|
+
this.loader.loaderCache.tga = new e();
|
|
4061
|
+
}
|
|
4062
|
+
r = await this._loadViaObjectURL(this.loader.loaderCache.tga, e), r.colorSpace = F;
|
|
4063
|
+
} else r = new pe(await createImageBitmap(new Blob([e]))), r.colorSpace = F;
|
|
4064
|
+
return r.wrapS = r.wrapT = ue, r.needsUpdate = !0, r;
|
|
4065
|
+
}
|
|
4066
|
+
async _loadViaObjectURL(e, t) {
|
|
4067
|
+
let n = URL.createObjectURL(new Blob([t]));
|
|
4068
|
+
try {
|
|
4069
|
+
return await e.loadAsync(n);
|
|
4070
|
+
} finally {
|
|
4071
|
+
URL.revokeObjectURL(n);
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
async processObjMtlPairsInZip(e, t) {
|
|
4075
|
+
let n = [], r = [];
|
|
4076
|
+
for (let t in e) {
|
|
4077
|
+
let i = t.toLowerCase();
|
|
4078
|
+
i.endsWith(".obj") ? n.push({
|
|
4079
|
+
path: t,
|
|
4080
|
+
content: e[t]
|
|
4081
|
+
}) : i.endsWith(".mtl") && r.push({
|
|
4082
|
+
path: t,
|
|
4083
|
+
content: e[t]
|
|
4084
|
+
});
|
|
4085
|
+
}
|
|
4086
|
+
if (n.length > 0 && r.length > 0) {
|
|
4087
|
+
console.log(`Found ${n.length} OBJ files and ${r.length} MTL files in ZIP`);
|
|
4088
|
+
let i = this.findMatchingObjMtlPairs(n, r);
|
|
4089
|
+
if (i.length > 0) return console.log(`Found ${i.length} matching OBJ+MTL pairs`), await this.loadOBJMTLPairFromZip(i[0].obj, i[0].mtl, e, t);
|
|
4090
|
+
if (i.length === 0) return console.log("No matching pairs by name, using first OBJ and MTL files"), await this.loadOBJMTLPairFromZip(n[0], r[0], e, t);
|
|
4091
|
+
}
|
|
4092
|
+
return null;
|
|
4093
|
+
}
|
|
4094
|
+
findMatchingObjMtlPairs(e, t) {
|
|
4095
|
+
let n = [];
|
|
4096
|
+
for (let r of e) {
|
|
4097
|
+
let e = r.path.split("/").pop().replace(/\.obj$/i, "").toLowerCase();
|
|
4098
|
+
for (let i of t) {
|
|
4099
|
+
let t = i.path.split("/").pop().replace(/\.mtl$/i, "").toLowerCase();
|
|
4100
|
+
if (e === t || e.includes(t) || t.includes(e)) {
|
|
4101
|
+
n.push({
|
|
4102
|
+
obj: r,
|
|
4103
|
+
mtl: i
|
|
4104
|
+
});
|
|
4105
|
+
break;
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
return n;
|
|
4110
|
+
}
|
|
4111
|
+
async findAndLoadModelFromZip(e) {
|
|
4112
|
+
for (let t of [
|
|
4113
|
+
"scene.gltf",
|
|
4114
|
+
"scene.glb",
|
|
4115
|
+
"model.gltf",
|
|
4116
|
+
"model.glb",
|
|
4117
|
+
"main.gltf",
|
|
4118
|
+
"main.glb",
|
|
4119
|
+
"asset.gltf",
|
|
4120
|
+
"asset.glb"
|
|
4121
|
+
]) if (e[t]) {
|
|
4122
|
+
console.log(`Found main model file: ${t}`);
|
|
4123
|
+
let n = t.split(".").pop().toLowerCase();
|
|
4124
|
+
return await this.loadModelFromZipEntry(e[t], t, n, e);
|
|
4125
|
+
}
|
|
4126
|
+
for (let t in e) {
|
|
4127
|
+
let n = t.split(".").pop().toLowerCase();
|
|
4128
|
+
if (n === "obj" || this.loader.getFileFormat(t)?.type === "model") return ni.test(t) ? await this.loadUSDHierarchyFromZip(e) : (console.log(`Loading model file from ZIP: ${t}`), await this.loadModelFromZipEntry(e[t], t, n, e));
|
|
4129
|
+
}
|
|
4130
|
+
throw Error("No supported model files found in the ZIP archive");
|
|
4131
|
+
}
|
|
4132
|
+
async loadUSDHierarchyFromZip(t) {
|
|
4133
|
+
let n = Object.keys(t).filter((e) => ni.test(e));
|
|
4134
|
+
if (n.length === 0) throw Error("No USD layers found in the ZIP archive");
|
|
4135
|
+
let r = e._pickUSDRootLayer(n);
|
|
4136
|
+
console.log(`Loading USD scene from ZIP: ${r} (${n.length} layers)`);
|
|
4137
|
+
let i = { [r]: [t[r], { level: 0 }] };
|
|
4138
|
+
for (let e of Object.keys(t)) e !== r && (ni.test(e) || ri.test(e)) && (i[e] = [t[e], { level: 0 }]);
|
|
4139
|
+
return await this.loader._loadModelFileByExtension(new File([_e(i)], r), r);
|
|
4140
|
+
}
|
|
4141
|
+
static _pickUSDRootLayer(e) {
|
|
4142
|
+
let t = (e) => e.split("/").length, n = Math.min(...e.map(t)), r = e.filter((e) => t(e) === n);
|
|
4143
|
+
return r.find((e) => {
|
|
4144
|
+
let t = e.split("/");
|
|
4145
|
+
return t.length > 1 && t[t.length - 1].replace(ni, "") === t[t.length - 2];
|
|
4146
|
+
}) || r[0];
|
|
4147
|
+
}
|
|
4148
|
+
async loadModelFromZipEntry(e, n, r, i) {
|
|
4149
|
+
try {
|
|
4150
|
+
t({
|
|
4151
|
+
isLoading: !0,
|
|
4152
|
+
status: `Processing ${r.toUpperCase()} from ZIP...`,
|
|
4153
|
+
progress: 5
|
|
4154
|
+
});
|
|
4155
|
+
let a = new Blob([e.buffer], { type: "application/octet-stream" }), o = URL.createObjectURL(a), s;
|
|
4156
|
+
switch (r) {
|
|
4157
|
+
case "glb":
|
|
4158
|
+
case "gltf":
|
|
4159
|
+
s = await this.handleGltfFromZip(r, e, n, i);
|
|
4160
|
+
break;
|
|
4161
|
+
case "obj":
|
|
4162
|
+
s = await this.handleObjFromZip(e, n, i);
|
|
4163
|
+
break;
|
|
4164
|
+
default: s = await this.loader._loadModelFileByExtension(new File([e], n), n);
|
|
4165
|
+
}
|
|
4166
|
+
return URL.revokeObjectURL(o), this.loader.dispatchEvent({
|
|
4167
|
+
type: "load",
|
|
4168
|
+
model: this.loader.targetModel,
|
|
4169
|
+
filename: `${n} (from ZIP)`
|
|
4170
|
+
}), s;
|
|
4171
|
+
} catch (e) {
|
|
4172
|
+
throw console.error(`Error loading ${r} from ZIP:`, e), this.loader.dispatchEvent({
|
|
4173
|
+
type: "error",
|
|
4174
|
+
message: e.message,
|
|
4175
|
+
filename: n
|
|
4176
|
+
}), e;
|
|
4177
|
+
}
|
|
4178
|
+
}
|
|
4179
|
+
async handleGltfFromZip(e, t, n, r) {
|
|
4180
|
+
if (e === "gltf") {
|
|
4181
|
+
let e = R(t), i = new j(), a = n.split("/").slice(0, -1).join("/");
|
|
4182
|
+
i.setURLModifier((e) => this.resolveZipResource(e, a, r));
|
|
4183
|
+
let o = await this.loader.createGLTFLoader();
|
|
4184
|
+
o.manager = i;
|
|
4185
|
+
try {
|
|
4186
|
+
return await new Promise((t, n) => {
|
|
4187
|
+
o.parse(e, "", (e) => {
|
|
4188
|
+
try {
|
|
4189
|
+
this.loader._throwDeferred();
|
|
4190
|
+
} catch (e) {
|
|
4191
|
+
n(e);
|
|
4192
|
+
return;
|
|
4193
|
+
}
|
|
4194
|
+
this.loader.releaseTargetModel(), this.loader.targetModel = e.scene, this.loader.sceneMetadata = d(e), this.loader.onModelLoad(this.loader.targetModel).then(() => t(e));
|
|
4195
|
+
}, (e) => n(e));
|
|
4196
|
+
});
|
|
4197
|
+
} finally {
|
|
4198
|
+
this.loader._disposeGLTFLoader(o);
|
|
4199
|
+
}
|
|
4200
|
+
} else return await this.loader.loadGLBFromArrayBuffer(t.buffer, n);
|
|
4201
|
+
}
|
|
4202
|
+
async handleObjFromZip(e, t, n) {
|
|
4203
|
+
let r = R(e), i = r.match(/mtllib\s+([^\s]+)/), a = null;
|
|
4204
|
+
i && i[1] && (a = await this.loadMtlFromZip(i[1], t, n));
|
|
4205
|
+
let { OBJLoader: o } = await import("three/examples/jsm/loaders/OBJLoader.js"), s = new o();
|
|
4206
|
+
a && s.setMaterials(a);
|
|
4207
|
+
let c = s.parse(r);
|
|
4208
|
+
return c.name = t, this.loader.releaseTargetModel(), this.loader.targetModel = c, await this.loader.onModelLoad(this.loader.targetModel), c;
|
|
4209
|
+
}
|
|
4210
|
+
async preloadMtlTextures(e) {
|
|
4211
|
+
let t = [], n = e.loadTexture.bind(e);
|
|
4212
|
+
if (e.loadTexture = (e, r, i, a, o) => {
|
|
4213
|
+
let s;
|
|
4214
|
+
return t.push(new Promise((e) => s = e)), n(e, r, (e) => {
|
|
4215
|
+
s(), i?.(e);
|
|
4216
|
+
}, a, (e) => {
|
|
4217
|
+
s(), o?.(e);
|
|
4218
|
+
});
|
|
4219
|
+
}, e.preload(), t.length === 0) return e;
|
|
4220
|
+
let r, i = await Promise.race([Promise.all(t).then(() => !0), new Promise((e) => r = setTimeout(() => e(!1), ii))]);
|
|
4221
|
+
return clearTimeout(r), i || this.loader._issues?.record(a.TEXTURE_BUILD_FAILED, `MTL textures did not decode within ${ii}ms; affected materials render untextured`, { pending: t.length }), e;
|
|
4222
|
+
}
|
|
4223
|
+
async loadMtlFromZip(e, t, n) {
|
|
4224
|
+
let r = t.split("/").slice(0, -1).join("/"), i = [
|
|
4225
|
+
e,
|
|
4226
|
+
`${r}/${e}`,
|
|
4227
|
+
e.split("/").pop()
|
|
4228
|
+
];
|
|
4229
|
+
for (let e of i) if (n[e]) {
|
|
4230
|
+
let { MTLLoader: t } = await import("three/examples/jsm/loaders/MTLLoader.js"), i = R(n[e]), a = new j();
|
|
4231
|
+
a.setURLModifier((e) => this.resolveZipResource(e, r, n));
|
|
4232
|
+
let o = new t(a).parse(i, r);
|
|
4233
|
+
return await this.preloadMtlTextures(o), o;
|
|
4234
|
+
}
|
|
4235
|
+
return null;
|
|
4236
|
+
}
|
|
4237
|
+
resolveZipResource(e, t, n) {
|
|
4238
|
+
let r = e.replace(/^\.\/|^\//, ""), i = [
|
|
4239
|
+
r,
|
|
4240
|
+
`${t}/${r}`,
|
|
4241
|
+
r.split("/").pop()
|
|
4242
|
+
];
|
|
4243
|
+
for (let e of i) if (n[e]) {
|
|
4244
|
+
let t = new Blob([n[e].buffer], { type: "application/octet-stream" });
|
|
4245
|
+
return URL.createObjectURL(t);
|
|
4246
|
+
}
|
|
4247
|
+
return console.warn(`Resource not found in ZIP: ${e}`), e;
|
|
4248
|
+
}
|
|
4249
|
+
async loadOBJMTLPairFromZip(e, t, n, r) {
|
|
4250
|
+
let { MTLLoader: i } = await import("three/examples/jsm/loaders/MTLLoader.js"), { OBJLoader: a } = await import("three/examples/jsm/loaders/OBJLoader.js"), o = [], s = new j(), c = e.path.split("/").slice(0, -1).join("/"), l = t.path.split("/").slice(0, -1).join("/");
|
|
4251
|
+
s.setURLModifier((e) => this.resolveTextureInZip(e, c, l, t, n, o));
|
|
4252
|
+
let u = this.prepareFixedMtlContent(t), d = new i(s).parse(u, l);
|
|
4253
|
+
await this.preloadMtlTextures(d);
|
|
4254
|
+
let f = new a(s);
|
|
4255
|
+
f.setMaterials(d);
|
|
4256
|
+
let p = R(e.content), m = f.parse(p);
|
|
4257
|
+
return this.loader.releaseTargetModel(), this.loader.targetModel = m, await this.loader.onModelLoad(this.loader.targetModel), o.forEach((e) => URL.revokeObjectURL(e)), this.loader.dispatchEvent({
|
|
4258
|
+
type: "load",
|
|
4259
|
+
model: m,
|
|
4260
|
+
filename: `${e.path} (from ${r})`
|
|
4261
|
+
}), m;
|
|
4262
|
+
}
|
|
4263
|
+
prepareFixedMtlContent(e) {
|
|
4264
|
+
return R(e.content).replace(RegExp(`${e.path.split("/").pop()}\\s+`, "g"), " ").replace(/([a-zA-Z_]+)([\\/])/g, "$1 $2");
|
|
4265
|
+
}
|
|
4266
|
+
resolveTextureInZip(e, t, n, r, i, a) {
|
|
4267
|
+
let o = e.split("?")[0].split("#")[0].replace(/^\.\/|^\//, ""), s = r.path.split("/").pop();
|
|
4268
|
+
o.startsWith(s) && (o = o.substring(s.length).replace(/^\.\/|^\/|^\./, ""));
|
|
4269
|
+
let c = [
|
|
4270
|
+
o,
|
|
4271
|
+
`${t}/${o}`,
|
|
4272
|
+
`${n}/${o}`,
|
|
4273
|
+
`textures/${o}`,
|
|
4274
|
+
`texture/${o}`,
|
|
4275
|
+
`materials/${o}`,
|
|
4276
|
+
o.split("/").pop()
|
|
4277
|
+
];
|
|
4278
|
+
for (let e of c) if (i[e]) {
|
|
4279
|
+
let t = new Blob([i[e].buffer], { type: "application/octet-stream" }), n = URL.createObjectURL(t);
|
|
4280
|
+
return a.push(n), n;
|
|
4281
|
+
}
|
|
4282
|
+
return this.findTextureWithFuzzyMatch(o, i, a) || e;
|
|
4283
|
+
}
|
|
4284
|
+
findTextureWithFuzzyMatch(e, t, n) {
|
|
4285
|
+
let r = e.split("/").pop();
|
|
4286
|
+
for (let e in t) if (e.endsWith(r)) {
|
|
4287
|
+
let r = new Blob([t[e].buffer], { type: "application/octet-stream" }), i = URL.createObjectURL(r);
|
|
4288
|
+
return n.push(i), i;
|
|
4289
|
+
}
|
|
4290
|
+
if (r && r.length > 5) for (let e in t) {
|
|
4291
|
+
let i = e.split("/").pop();
|
|
4292
|
+
if (i.includes(r) || r.includes(i)) {
|
|
4293
|
+
let r = new Blob([t[e].buffer], { type: "application/octet-stream" }), i = URL.createObjectURL(r);
|
|
4294
|
+
return n.push(i), i;
|
|
4295
|
+
}
|
|
4296
|
+
}
|
|
4297
|
+
return null;
|
|
4298
|
+
}
|
|
4299
|
+
};
|
|
4300
|
+
//#endregion
|
|
4301
|
+
export { oi as n, ti as r, ai as t };
|