rayzee 11.7.0 → 11.8.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 +13 -0
- package/dist/{ArchiveImporter-DYcRXeKE.js → ArchiveImporter-_sJm5uaK.js} +1923 -1243
- package/dist/{BidirectionalIntegrator-BvjRpbTP.js → BidirectionalIntegrator-Dzt4Z97x.js} +290 -289
- package/dist/{ColorManagement-oeEk7oSu.js → ColorManagement-30MfpHwQ.js} +1 -1
- package/dist/{EngineIssues-CIZnXHsF.js → EngineIssues-xljoXM0E.js} +18 -8
- package/dist/{NeuralRetouch-ClaMiKYg.js → NeuralRetouch-BKQCsmEs.js} +2 -2
- package/dist/{NeuralSuperRes-WNEXun9s.js → NeuralSuperRes-C4ymq68e.js} +2 -2
- package/dist/{PathTracer-B9wZPPVL.js → PathTracer-C_to_i40.js} +3156 -3098
- package/dist/{PhysicalSky-DcjItqKi.js → PhysicalSky-bMHbm_7H.js} +1 -1
- package/dist/{RayzeeRenderer-p-NeE6E2.js → RayzeeRenderer-B_aB6VTJ.js} +370 -371
- package/dist/SceneMetadata-CSmlJW4c.js +183 -0
- package/dist/{ToneMapGPU-sAs8wdgI.js → ToneMapGPU-4GPwoG_c.js} +13 -6
- package/dist/addons/archives.es.js +1 -1
- package/dist/addons/bidirectional.es.js +1 -1
- package/dist/addons/color.es.js +1 -1
- package/dist/addons/physical-sky.es.js +1 -1
- package/dist/addons/storage.es.js +1 -1
- package/dist/{openStorage-Fe9BoS1_.js → openStorage-B085D9FR.js} +1 -1
- package/dist/rayzee-core.es.js +5 -5
- package/dist/rayzee.es.js +815 -796
- package/dist/rayzee.umd.js +106 -102
- package/dist/{sceneCachePolicy-B9w3BnaP.js → sceneCachePolicy-D_uBSbQF.js} +2 -2
- package/package.json +1 -1
- package/src/EngineIssues.js +20 -6
- package/src/Passes/AIUpscaler.js +4 -0
- package/src/Passes/OIDNDenoiser.js +8 -6
- package/src/PathTracerApp.js +10 -1
- package/src/Processor/ArchiveImporter.js +23 -6
- package/src/Processor/AssetLoader.js +15 -0
- package/src/Processor/LightSerializer.js +6 -2
- package/src/Processor/PBRT/PBRTMaterials.js +2 -1
- package/src/Processor/PBRT/PBRTSceneBuilder.js +1 -1
- package/src/Processor/PlatformImageLoader.js +9 -0
- package/src/Processor/TextureCreator.js +44 -4
- package/src/Processor/ToneMapCPU.js +34 -5
- package/src/Processor/ToneMapGPU.js +15 -9
- package/src/Processor/USD/USDScene.js +981 -17
- package/src/RayzeeRenderer.js +81 -26
- package/src/Stages/AutoExposure.js +21 -8
- package/src/Stages/Compositor.js +39 -1
- package/src/Stages/LocalExposure.js +44 -18
- package/src/Stages/NormalDepth.js +7 -3
- package/src/Stages/PathTracer.js +25 -1
- package/src/Stages/PathTracerStage.js +9 -1
- package/src/TSL/CameraRay.js +12 -1
- package/src/TSL/DebugKernel.js +3 -2
- package/src/TSL/FinalWriteKernel.js +4 -7
- package/src/TSL/GenerateKernel.js +6 -2
- package/src/TSL/LightSplatKernel.js +7 -4
- package/src/TSL/LightsCore.js +6 -2
- package/src/TSL/LightsSampling.js +45 -12
- package/src/TSL/SceneResources.js +11 -0
- package/src/TSL/ShadeKernel.js +1 -2
- package/src/integrators/BidirectionalIntegrator.js +1 -0
- package/src/managers/CameraManager.js +9 -0
- package/src/managers/DenoisingManager.js +1 -0
- package/src/managers/InteractionManager.js +6 -0
- package/src/managers/UniformManager.js +3 -1
- package/dist/SceneMetadata-D2Sh-0e-.js +0 -110
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { dt as e } from "./SolarLimb-bZE6y63S.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Mt as t, Nt as n, Ot as r, bt as i, dt as a, ft as o, i as s, jt as c, kt as l, lt as u, n as d, r as f, ut as p, vt as ee, xt as m } from "./PathTracer-C_to_i40.js";
|
|
3
3
|
import { n as h, t as g } from "./EngineEvents-CLckhYbL.js";
|
|
4
|
-
import { $ as
|
|
4
|
+
import { $ as te, C as ne, G as _, M as re, Q as ie, T as v, W as ae, at as y, d as oe, et as se, f as ce, l as le, nt as b, ot as ue, r as de, rt as fe, tt as pe, u as me, v as he, x as ge } from "./sceneCachePolicy-D_uBSbQF.js";
|
|
5
5
|
import { i as x, r as S } from "./Logger-dDDGj9Av.js";
|
|
6
|
-
import { f as
|
|
7
|
-
import { i as
|
|
8
|
-
import { n as
|
|
9
|
-
import { a as
|
|
10
|
-
import { i as w, r as
|
|
11
|
-
import { n as E, r as
|
|
12
|
-
import { d as
|
|
13
|
-
import { i as O, n as
|
|
14
|
-
import {
|
|
15
|
-
import { t as
|
|
16
|
-
import { LinearSRGBColorSpace as
|
|
17
|
-
import { Fn as
|
|
18
|
-
import { Box3 as
|
|
19
|
-
import { RectAreaLightTexturesLib as
|
|
20
|
-
import { RectAreaLightHelper as
|
|
21
|
-
import { GLTFLoader as
|
|
22
|
-
import { HDRLoader as
|
|
23
|
-
import { createMeshesFromMultiMaterialMesh as
|
|
24
|
-
import { clone as
|
|
6
|
+
import { f as _e, r as ve } from "./BufferLayout-xPRH9jYD.js";
|
|
7
|
+
import { i as ye, n as C, t as be } from "./EngineIssues-xljoXM0E.js";
|
|
8
|
+
import { n as xe, r as Se } from "./shared-BGBcSxBQ.js";
|
|
9
|
+
import { a as Ce } from "./WorkingMatrix-C6y233hT.js";
|
|
10
|
+
import { i as w, r as we, t as T } from "./ActiveColor-YvuQq44O.js";
|
|
11
|
+
import { n as E, r as Te } from "./AssetConfig-DSEntE65.js";
|
|
12
|
+
import { d as Ee, l as De, m as Oe, p as ke, t as Ae, u as D } from "./ViewTransforms-CYN7bq2w.js";
|
|
13
|
+
import { i as O, n as je, r as Me } from "./identity-C1cLD1C0.js";
|
|
14
|
+
import { c as Ne, i as Pe, l as Fe, o as Ie, r as Le, t as Re } from "./SceneMetadata-CSmlJW4c.js";
|
|
15
|
+
import { t as ze } from "./ToneMapGPU-4GPwoG_c.js";
|
|
16
|
+
import { LinearSRGBColorSpace as Be, MeshBasicNodeMaterial as Ve, QuadMesh as He, RectAreaLightNode as Ue, SRGBColorSpace as We, TextureNode as Ge, WebGPURenderer as Ke } from "three/webgpu";
|
|
17
|
+
import { Fn as qe, If as Je, cubeTexture as Ye, dot as Xe, float as k, int as A, mix as j, screenUV as Ze, select as M, storage as Qe, texture as $e, uint as et, uniform as N, uv as P, vec3 as F, vec4 as tt } from "three/tsl";
|
|
18
|
+
import { Box3 as nt, BufferGeometry as rt, CircleGeometry as it, Color as I, DirectionalLight as at, DirectionalLightHelper as ot, EquirectangularReflectionMapping as st, EventDispatcher as L, FloatType as ct, LinearFilter as lt, LinearSRGBColorSpace as ut, LoaderUtils as dt, LoadingManager as ft, MathUtils as R, Mesh as pt, MeshPhysicalMaterial as mt, NoBlending as ht, NoToneMapping as gt, Object3D as z, OrthographicCamera as _t, PerspectiveCamera as vt, PointLight as yt, PointLightHelper as bt, REVISION as xt, RectAreaLight as B, SRGBColorSpace as V, Scene as H, SpotLight as St, SpotLightHelper as Ct, TextureLoader as wt, Vector2 as Tt, Vector3 as U } from "three";
|
|
19
|
+
import { RectAreaLightTexturesLib as Et } from "three/addons/lights/RectAreaLightTexturesLib.js";
|
|
20
|
+
import { RectAreaLightHelper as Dt } from "three/addons/helpers/RectAreaLightHelper.js";
|
|
21
|
+
import { GLTFLoader as Ot } from "three/addons/loaders/GLTFLoader.js";
|
|
22
|
+
import { HDRLoader as kt } from "three/addons/loaders/HDRLoader.js";
|
|
23
|
+
import { createMeshesFromMultiMaterialMesh as At } from "three/addons/utils/SceneUtils.js";
|
|
24
|
+
import { clone as jt } from "three/addons/utils/SkeletonUtils.js";
|
|
25
25
|
//#region src/SceneHelpers.js
|
|
26
|
-
var
|
|
26
|
+
var Mt = class {
|
|
27
27
|
constructor() {
|
|
28
|
-
this.scene = new
|
|
28
|
+
this.scene = new H(), this._helpers = /* @__PURE__ */ new Map(), this.visible = !1;
|
|
29
29
|
}
|
|
30
30
|
add(e) {
|
|
31
31
|
if (this._helpers.has(e.uuid)) return this._helpers.get(e.uuid);
|
|
@@ -63,22 +63,31 @@ var jt = class {
|
|
|
63
63
|
this.clear();
|
|
64
64
|
}
|
|
65
65
|
_createHelper(e) {
|
|
66
|
-
return e.isRectAreaLight ? new
|
|
66
|
+
return e.isRectAreaLight ? new Dt(e) : e.isPointLight ? new bt(e, .5) : e.isSpotLight ? new Ct(e) : e.isDirectionalLight ? new ot(e, .5) : null;
|
|
67
67
|
}
|
|
68
|
-
},
|
|
68
|
+
}, Nt = class extends t {
|
|
69
69
|
constructor(e, t = {}) {
|
|
70
70
|
super("Compositor", {
|
|
71
71
|
...t,
|
|
72
|
-
executionMode:
|
|
73
|
-
}), this.renderer = e, this._lightSources = [...t.displaySources ?? [], "pathtracer:color"], this.saturation = N(t.saturation ?? 1), this._transparentBackground = N(0, "int"), this._pathTracer = t.pathTracer ?? null, this._convergenceOverlay = !1, this._debugMaterial = null, this._debugQuad = null, this._debugTexNode = null, this._debugM2Attr = null, this._debugMaskAttr = null, this._debugExposureComp = N(1), this._sourceTexNode = new
|
|
72
|
+
executionMode: n.ALWAYS
|
|
73
|
+
}), this.renderer = e, this._lightSources = [...t.displaySources ?? [], "pathtracer:color"], this.saturation = N(t.saturation ?? 1), this._transparentBackground = N(0, "int"), this._pathTracer = t.pathTracer ?? null, this._convergenceOverlay = !1, this._debugMaterial = null, this._debugQuad = null, this._debugTexNode = null, this._debugM2Attr = null, this._debugMaskAttr = null, this._debugExposureComp = N(1), this._sourceTexNode = new Ge(), this._displayGain = null, this._backdropExposure = null, this._holdBackdrop = N(0, "int"), this._backdropGain = N(1), this.compositorMaterial = new Ve(), this.compositorMaterial.blending = ht, this._buildColorNode(), this.compositorQuad = new He(this.compositorMaterial);
|
|
74
74
|
}
|
|
75
75
|
_buildColorNode() {
|
|
76
|
-
let t = this._sourceTexNode.sample(P()), n = this._displayGain ?
|
|
77
|
-
this.
|
|
76
|
+
let t = this._sourceTexNode.sample(P()), n = this._displayGain ? this._displayGain(t.xyz, Ze) : null;
|
|
77
|
+
if (this._backdropExposure !== null) {
|
|
78
|
+
let e = n ?? k(1), r = e.add(this._backdropGain.sub(e).mul(t.w.clamp(0, 1).oneMinus()));
|
|
79
|
+
n = M(this._holdBackdrop.greaterThan(A(0)), r, e);
|
|
80
|
+
}
|
|
81
|
+
let r = n ? t.xyz.mul(n) : t.xyz, i = j(F(Xe(r, e)), r, this.saturation), a = M(this._transparentBackground, t.w, 1);
|
|
82
|
+
this.compositorMaterial.colorNode = tt(i, a), this.compositorMaterial.needsUpdate = !0;
|
|
78
83
|
}
|
|
79
84
|
setDisplayGain(e) {
|
|
80
85
|
e !== this._displayGain && (this._displayGain = e, this._buildColorNode());
|
|
81
86
|
}
|
|
87
|
+
setBackdropExposure(e) {
|
|
88
|
+
let t = e === null != (this._backdropExposure === null);
|
|
89
|
+
this._backdropExposure = e, t && this._buildColorNode();
|
|
90
|
+
}
|
|
82
91
|
resolveLightTexture(e) {
|
|
83
92
|
return this.resolveLightSource(e)?.texture ?? null;
|
|
84
93
|
}
|
|
@@ -96,17 +105,17 @@ var jt = class {
|
|
|
96
105
|
let t = this._pathTracer?.getConvergenceDebugSource?.();
|
|
97
106
|
if (!t) return !1;
|
|
98
107
|
if (this._debugMaterial && this._debugM2Attr === t.m2 && this._debugMaskAttr === t.frozenMask) return !0;
|
|
99
|
-
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new
|
|
100
|
-
let n =
|
|
101
|
-
let n =
|
|
102
|
-
return
|
|
103
|
-
let e = j(F(1, .8, .1), F(1, .1, .05),
|
|
104
|
-
|
|
105
|
-
}),
|
|
106
|
-
|
|
107
|
-
}),
|
|
108
|
+
this._debugMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugM2Attr = t.m2, this._debugMaskAttr = t.frozenMask, this._debugTexNode = new Ge();
|
|
109
|
+
let n = qe(() => {
|
|
110
|
+
let n = Xe(this._debugTexNode.sample(P()).toVar().xyz, e).toVar(), r = t.renderWidth, i = t.renderHeight, a = A(P().x.mul(k(r))).min(r.sub(A(1))).max(A(0)), o = et(A(P().y.mul(k(i))).min(i.sub(A(1))).max(A(0)).mul(r).add(a)).toVar(), s = Qe(t.m2, "float").toReadOnly().element(o).toVar(), c = Qe(t.frozenMask, "uint").toReadOnly().element(o).toVar(), l = s.sub(n.mul(n)).max(k(0)).div(k(t.frame).add(1)).sqrt().toVar(), u = t.usePixelFreeze.greaterThan(A(0)), d = M(n.lessThan(k(1)), n.sqrt(), n).toVar(), f = M(u, l.div(n.add(k(1e-4))), l.div(d.add(k(1e-4)))).toVar(), p = M(u, t.pixelFreezeThreshold, t.noiseThreshold).toVar(), ee = f.div(p.max(k(1e-6))).toVar(), m = F(n.div(n.add(k(1))).sqrt().mul(.55)).toVar(), h = m.toVar(), g = k(t.frame).greaterThanEqual(k(t.adaptiveMinSamples));
|
|
111
|
+
return Je(ee.greaterThanEqual(k(1)).or(g.not()), () => {
|
|
112
|
+
let e = j(F(1, .8, .1), F(1, .1, .05), ee.sub(1).div(3).clamp(0, 1));
|
|
113
|
+
h.assign(j(m, e, .85));
|
|
114
|
+
}), Je(c.equal(et(1)).and(u), () => {
|
|
115
|
+
h.assign(j(m, F(.1, .45, 1), .55));
|
|
116
|
+
}), h;
|
|
108
117
|
});
|
|
109
|
-
return this._debugMaterial = new
|
|
118
|
+
return this._debugMaterial = new Ve(), this._debugMaterial.colorNode = tt(n().pow(2.2).mul(this._debugExposureComp), 1), this._debugMaterial.blending = ht, this._debugQuad = new He(this._debugMaterial), !0;
|
|
110
119
|
}
|
|
111
120
|
render(e) {
|
|
112
121
|
if (!this.enabled) return;
|
|
@@ -114,13 +123,19 @@ var jt = class {
|
|
|
114
123
|
let t = e.getTexture("pathtracer:color");
|
|
115
124
|
if (t) {
|
|
116
125
|
this._debugTexNode.value = t;
|
|
117
|
-
let e = this.renderer.toneMapping !==
|
|
126
|
+
let e = this.renderer.toneMapping !== gt;
|
|
118
127
|
this._debugExposureComp.value = e ? 1 / Math.max(this.renderer.toneMappingExposure, 1e-4) : 1, this.renderer.setRenderTarget(null), this._debugQuad.render(this.renderer);
|
|
119
128
|
return;
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
let t = this.resolveLightTexture(e);
|
|
123
|
-
|
|
132
|
+
if (t) {
|
|
133
|
+
if (this._backdropExposure !== null) {
|
|
134
|
+
let t = e.getState("pathtracer:backdrop") === "color";
|
|
135
|
+
this._holdBackdrop.value = +!!t, t && (this._backdropGain.value = a(this._backdropExposure, this.renderer.toneMappingExposure, this.renderer.toneMapping));
|
|
136
|
+
}
|
|
137
|
+
this._sourceTexNode.value = t, this.renderer.setRenderTarget(null), this.compositorQuad.render(this.renderer);
|
|
138
|
+
}
|
|
124
139
|
}
|
|
125
140
|
setConvergenceOverlay(e) {
|
|
126
141
|
this._convergenceOverlay = !!e;
|
|
@@ -134,7 +149,7 @@ var jt = class {
|
|
|
134
149
|
dispose() {
|
|
135
150
|
this._sourceTexNode?.dispose(), this.compositorMaterial?.dispose(), this._debugTexNode?.dispose(), this._debugMaterial?.dispose(), this.compositorQuad = null, this._debugQuad = null, this._debugMaterial = null, this._debugTexNode = null, this._pathTracer = null;
|
|
136
151
|
}
|
|
137
|
-
},
|
|
152
|
+
}, Pt = class {
|
|
138
153
|
constructor() {
|
|
139
154
|
this.textures = /* @__PURE__ */ new Map(), this.renderTargets = /* @__PURE__ */ new Map(), this.uniforms = /* @__PURE__ */ new Map(), this.state = {
|
|
140
155
|
frame: 0,
|
|
@@ -253,7 +268,7 @@ var jt = class {
|
|
|
253
268
|
dispose() {
|
|
254
269
|
this.textures.clear(), this.renderTargets.clear(), this.uniforms.clear(), this._stateChangeCallbacks.clear(), this.state = {};
|
|
255
270
|
}
|
|
256
|
-
},
|
|
271
|
+
}, Ft = class extends L {
|
|
257
272
|
constructor() {
|
|
258
273
|
super(), this._onceCallbacks = /* @__PURE__ */ new Map();
|
|
259
274
|
}
|
|
@@ -291,15 +306,15 @@ var jt = class {
|
|
|
291
306
|
eventNames() {
|
|
292
307
|
return this._listeners ? Object.keys(this._listeners) : [];
|
|
293
308
|
}
|
|
294
|
-
},
|
|
309
|
+
}, It = !1, W = [], Lt = /* @__PURE__ */ new WeakMap();
|
|
295
310
|
function Rt(e) {
|
|
296
|
-
|
|
311
|
+
It = !!e;
|
|
297
312
|
}
|
|
298
313
|
function zt() {
|
|
299
|
-
return
|
|
314
|
+
return W.slice();
|
|
300
315
|
}
|
|
301
316
|
function Bt() {
|
|
302
|
-
|
|
317
|
+
W.length = 0;
|
|
303
318
|
}
|
|
304
319
|
function Vt(e) {
|
|
305
320
|
let t = [];
|
|
@@ -308,7 +323,7 @@ function Vt(e) {
|
|
|
308
323
|
}
|
|
309
324
|
var Ht = (e) => !e || !e.image || !(e.image.width > 0);
|
|
310
325
|
function Ut(e, t, n) {
|
|
311
|
-
if (!
|
|
326
|
+
if (!It) {
|
|
312
327
|
n();
|
|
313
328
|
return;
|
|
314
329
|
}
|
|
@@ -337,7 +352,7 @@ function Wt(e, t) {
|
|
|
337
352
|
if (Ht(t)) return;
|
|
338
353
|
t.isStorageTexture !== !0 && n.push(r);
|
|
339
354
|
}
|
|
340
|
-
t.phase = "done", n.length !== 0 &&
|
|
355
|
+
t.phase = "done", n.length !== 0 && W.push({
|
|
341
356
|
stage: e.name,
|
|
342
357
|
nodes: n,
|
|
343
358
|
unboundAtCompile: t.unboundAtCompile.slice(),
|
|
@@ -357,7 +372,7 @@ var Gt = class {
|
|
|
357
372
|
}));
|
|
358
373
|
}
|
|
359
374
|
constructor(e, t, n, { issues: r = null } = {}) {
|
|
360
|
-
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new
|
|
375
|
+
this.renderer = e, this._issues = r, this._reportedStageFailures = /* @__PURE__ */ new Set(), this.width = t, this.height = n, this.stages = [], this.context = new Pt(), this.eventBus = new Ft(), this.context.setState("width", t), this.context.setState("height", n), this.stats = {
|
|
361
376
|
enabled: !1,
|
|
362
377
|
logSkipped: !1,
|
|
363
378
|
timings: /* @__PURE__ */ new Map(),
|
|
@@ -514,7 +529,7 @@ var Gt = class {
|
|
|
514
529
|
resumeFromPause() {
|
|
515
530
|
this.renderCompleteDispatched = !1, this.lastResetTime = performance.now() - this.timeElapsed * 1e3;
|
|
516
531
|
}
|
|
517
|
-
}, Jt = 864e5,
|
|
532
|
+
}, Jt = 864e5, G = Object.freeze({
|
|
518
533
|
IMMUTABLE: "immutable",
|
|
519
534
|
REVALIDATE: "revalidate",
|
|
520
535
|
NETWORK: "network"
|
|
@@ -522,8 +537,8 @@ var Gt = class {
|
|
|
522
537
|
loaded: e,
|
|
523
538
|
total: t,
|
|
524
539
|
lengthComputable: t > 0 && e <= t
|
|
525
|
-
}),
|
|
526
|
-
function
|
|
540
|
+
}), K = (e, t) => e.headers?.get?.(t) ?? null, Xt = (e) => e.reason ?? new DOMException("aborted", "AbortError");
|
|
541
|
+
function q(e) {
|
|
527
542
|
try {
|
|
528
543
|
let t = new URL(e, globalThis.location?.href ?? "http://localhost/").pathname;
|
|
529
544
|
return decodeURIComponent(t.split("/").pop()) || "download";
|
|
@@ -532,7 +547,7 @@ function K(e) {
|
|
|
532
547
|
}
|
|
533
548
|
}
|
|
534
549
|
async function Zt(e, { onProgress: t, signal: n }) {
|
|
535
|
-
let r = Number(
|
|
550
|
+
let r = Number(K(e, "content-length")) || 0, i = K(e, "content-type") ?? "";
|
|
536
551
|
if (!e.body) return new Blob([await e.arrayBuffer()], { type: i });
|
|
537
552
|
let a = e.body.getReader(), o = [], s = 0;
|
|
538
553
|
for (;;) {
|
|
@@ -546,20 +561,20 @@ async function Zt(e, { onProgress: t, signal: n }) {
|
|
|
546
561
|
var Qt = (e, t, n) => new File([e], t, {
|
|
547
562
|
type: n || e.type,
|
|
548
563
|
lastModified: e.lastModified ?? Date.now()
|
|
549
|
-
}), $t = () => {},
|
|
564
|
+
}), $t = () => {}, J = class {
|
|
550
565
|
constructor(e) {
|
|
551
566
|
this._storage = e, this._revalidating = /* @__PURE__ */ new Set();
|
|
552
567
|
}
|
|
553
568
|
get _area() {
|
|
554
|
-
return this._storage?.area(
|
|
569
|
+
return this._storage?.area(Se.DOWNLOADS) ?? null;
|
|
555
570
|
}
|
|
556
|
-
async fetch(e, { key: t = e, name: n =
|
|
571
|
+
async fetch(e, { key: t = e, name: n = q(e), policy: r = G.REVALIDATE, maxAgeMs: i = Jt, onProgress: a = null, signal: o = null, fetchOptions: s = {} } = {}) {
|
|
557
572
|
let c = this._area;
|
|
558
|
-
if (c && r !==
|
|
573
|
+
if (c && r !== G.NETWORK) {
|
|
559
574
|
let o = await c.open(t);
|
|
560
575
|
if (o) {
|
|
561
576
|
let c = await o.file("data");
|
|
562
|
-
if (c) return r ===
|
|
577
|
+
if (c) return r === G.REVALIDATE && Date.now() - (o.extra.checkedAt ?? 0) >= i && this._revalidate(e, t, n, o.extra, s), a?.(Yt(c.size, c.size)), {
|
|
563
578
|
file: Qt(c, n, o.extra.contentType),
|
|
564
579
|
release: () => o.release(),
|
|
565
580
|
fromCache: !0
|
|
@@ -584,10 +599,10 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
584
599
|
signal: i
|
|
585
600
|
});
|
|
586
601
|
if (!s.ok) throw Error(`HTTP ${s.status} fetching ${e}`);
|
|
587
|
-
let c = Number(
|
|
602
|
+
let c = Number(K(s, "content-length")) || 0, l = {
|
|
588
603
|
url: e,
|
|
589
|
-
contentType:
|
|
590
|
-
lastModified:
|
|
604
|
+
contentType: K(s, "content-type") ?? "",
|
|
605
|
+
lastModified: K(s, "last-modified"),
|
|
591
606
|
contentLength: c || null,
|
|
592
607
|
checkedAt: Date.now()
|
|
593
608
|
}, u = o && s.body ? await this._area.create(t, {
|
|
@@ -636,7 +651,7 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
636
651
|
headers: t
|
|
637
652
|
});
|
|
638
653
|
if (n.body?.cancel().catch(() => {}), n.ok) {
|
|
639
|
-
let e =
|
|
654
|
+
let e = K(n, "last-modified"), t = n.status === 206 ? Number(K(n, "content-range")?.match(/\/(\d+)$/)?.[1]) || null : Number(K(n, "content-length")) || null;
|
|
640
655
|
a = !!(e && r.lastModified && e !== r.lastModified || t && r.contentLength && t !== r.contentLength);
|
|
641
656
|
}
|
|
642
657
|
} catch {}
|
|
@@ -657,10 +672,10 @@ var Qt = (e, t, n) => new File([e], t, {
|
|
|
657
672
|
}
|
|
658
673
|
};
|
|
659
674
|
function en(e, t, n) {
|
|
660
|
-
return new
|
|
675
|
+
return new J(t).fetch(e, n);
|
|
661
676
|
}
|
|
662
677
|
function tn() {
|
|
663
|
-
return new
|
|
678
|
+
return new J(xe(E().cacheNamespace));
|
|
664
679
|
}
|
|
665
680
|
async function nn(e, { downloads: t = tn(), ...n } = {}) {
|
|
666
681
|
if (!t._storage || !/^https?:/i.test(e)) return {
|
|
@@ -900,7 +915,7 @@ var rn = {
|
|
|
900
915
|
},
|
|
901
916
|
maxTextureSize: { reset: !1 },
|
|
902
917
|
areaLightIntensityScale: { reset: !1 }
|
|
903
|
-
},
|
|
918
|
+
}, Y = Object.freeze({
|
|
904
919
|
DEFAULT: "default",
|
|
905
920
|
HOST: "host",
|
|
906
921
|
SCENE_METADATA: "scene-metadata",
|
|
@@ -919,15 +934,15 @@ var rn = {
|
|
|
919
934
|
reset: r
|
|
920
935
|
});
|
|
921
936
|
let i = t === void 0 ? this._defaults[e] : t;
|
|
922
|
-
!this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e,
|
|
937
|
+
!this._values.has(e) && i !== void 0 && (this._values.set(e, i), this._sources.set(e, Y.DEFAULT));
|
|
923
938
|
}
|
|
924
939
|
_buildHandlers({ stages: e, resetCallback: t, reconcileCompletion: n, applyExposure: r, onCameraProjection: i }) {
|
|
925
|
-
let a = new
|
|
926
|
-
a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(
|
|
940
|
+
let a = new Tt(), o = (t, n) => {
|
|
941
|
+
a.set(n?.[0] ?? 0, n?.[1] ?? 0).multiplyScalar(R.DEG2RAD), e.pathTracer?.setUniform(t, a);
|
|
927
942
|
};
|
|
928
943
|
return {
|
|
929
944
|
handleCameraProjection: (t) => {
|
|
930
|
-
e.pathTracer?.setUniform("cameraProjection",
|
|
945
|
+
e.pathTracer?.setUniform("cameraProjection", ae[t] ?? ae.perspective), i?.(t);
|
|
931
946
|
},
|
|
932
947
|
handleDofMode: (t) => e.pathTracer?.setUniform("dofMode", +(t === "look")),
|
|
933
948
|
handlePanoramaLonRange: (e) => o("panoLonRange", e),
|
|
@@ -977,7 +992,7 @@ var rn = {
|
|
|
977
992
|
}
|
|
978
993
|
};
|
|
979
994
|
}
|
|
980
|
-
set(e, t, { reset: n, silent: r, source: i =
|
|
995
|
+
set(e, t, { reset: n, silent: r, source: i = Y.HOST } = {}) {
|
|
981
996
|
let a = this._applyOne(e, t, i);
|
|
982
997
|
a?.route && ((n === void 0 ? a.route.reset ?? !0 : n) && this._resetCallback?.(), r || this.dispatchEvent({
|
|
983
998
|
type: g.SETTING_CHANGED,
|
|
@@ -986,7 +1001,7 @@ var rn = {
|
|
|
986
1001
|
prev: a.prev
|
|
987
1002
|
}));
|
|
988
1003
|
}
|
|
989
|
-
setMany(e, { silent: t, reset: n, source: r =
|
|
1004
|
+
setMany(e, { silent: t, reset: n, source: r = Y.HOST } = {}) {
|
|
990
1005
|
let i = !1;
|
|
991
1006
|
for (let [n, a] of Object.entries(e)) {
|
|
992
1007
|
let e = this._applyOne(n, a, r);
|
|
@@ -1022,7 +1037,7 @@ var rn = {
|
|
|
1022
1037
|
let e = {};
|
|
1023
1038
|
for (let [t, n] of this._values) e[t] = {
|
|
1024
1039
|
value: n,
|
|
1025
|
-
source: this._sources.get(t) ??
|
|
1040
|
+
source: this._sources.get(t) ?? Y.DEFAULT,
|
|
1026
1041
|
routed: this._routes.has(t)
|
|
1027
1042
|
};
|
|
1028
1043
|
return e;
|
|
@@ -1033,7 +1048,7 @@ var rn = {
|
|
|
1033
1048
|
serialize() {
|
|
1034
1049
|
let e = {};
|
|
1035
1050
|
for (let [t, n] of this._values) {
|
|
1036
|
-
if (this._sources.get(t) !==
|
|
1051
|
+
if (this._sources.get(t) !== Y.HOST || !this._routes.has(t)) continue;
|
|
1037
1052
|
let r = m(n);
|
|
1038
1053
|
r !== void 0 && (e[t] = r);
|
|
1039
1054
|
}
|
|
@@ -1041,7 +1056,7 @@ var rn = {
|
|
|
1041
1056
|
}
|
|
1042
1057
|
restore(e) {
|
|
1043
1058
|
let t = {}, n = [];
|
|
1044
|
-
for (let [r,
|
|
1059
|
+
for (let [r, a] of Object.entries(e ?? {})) this._routes.has(r) ? t[r] = i(a) : n.push(r);
|
|
1045
1060
|
return this.setMany(t), n;
|
|
1046
1061
|
}
|
|
1047
1062
|
applyAll() {
|
|
@@ -1054,12 +1069,12 @@ var rn = {
|
|
|
1054
1069
|
e.uniform ? this._pathTracer?.setUniform(e.uniform, t) : e.handler ? this._handlers[e.handler]?.(t, n) : e.apply?.(t, n);
|
|
1055
1070
|
}
|
|
1056
1071
|
_initDefaults(e) {
|
|
1057
|
-
for (let t of Object.keys(rn)) t in e && (this._values.set(t, e[t]), this._sources.set(t,
|
|
1072
|
+
for (let t of Object.keys(rn)) t in e && (this._values.set(t, e[t]), this._sources.set(t, Y.DEFAULT));
|
|
1058
1073
|
}
|
|
1059
1074
|
}, on = class {
|
|
1060
1075
|
constructor({ issues: e = null } = {}) {
|
|
1061
|
-
this._issues = e, this._renderer = null, this._offRegistry =
|
|
1062
|
-
this._renderer &&
|
|
1076
|
+
this._issues = e, this._renderer = null, this._offRegistry = ke(() => {
|
|
1077
|
+
this._renderer && Oe(this._renderer);
|
|
1063
1078
|
});
|
|
1064
1079
|
}
|
|
1065
1080
|
get hasConfig() {
|
|
@@ -1076,11 +1091,11 @@ var rn = {
|
|
|
1076
1091
|
}
|
|
1077
1092
|
attachRenderer(e) {
|
|
1078
1093
|
this._renderer = e;
|
|
1079
|
-
let t =
|
|
1080
|
-
return e.outputColorSpace =
|
|
1094
|
+
let t = Oe(e);
|
|
1095
|
+
return e.outputColorSpace = V, t;
|
|
1081
1096
|
}
|
|
1082
1097
|
listViews() {
|
|
1083
|
-
return
|
|
1098
|
+
return Ee();
|
|
1084
1099
|
}
|
|
1085
1100
|
get activeView() {
|
|
1086
1101
|
return null;
|
|
@@ -1092,7 +1107,7 @@ var rn = {
|
|
|
1092
1107
|
return this._renderer && (this._renderer.toneMapping = e), t;
|
|
1093
1108
|
}
|
|
1094
1109
|
_publishWorkingMatrix() {
|
|
1095
|
-
|
|
1110
|
+
Ce(null, T);
|
|
1096
1111
|
}
|
|
1097
1112
|
loadConfig() {
|
|
1098
1113
|
let e = "colour configs need the OCIO pipeline: renderer.setColorManagement( ColorManagement ), from rayzee/addons/color";
|
|
@@ -1120,83 +1135,16 @@ var rn = {
|
|
|
1120
1135
|
activeView: null,
|
|
1121
1136
|
context: null,
|
|
1122
1137
|
exportSpace: null,
|
|
1123
|
-
views:
|
|
1124
|
-
registryVersion:
|
|
1138
|
+
views: Ee(),
|
|
1139
|
+
registryVersion: De(),
|
|
1125
1140
|
bakeError: e?.error ?? null
|
|
1126
1141
|
};
|
|
1127
1142
|
}
|
|
1128
1143
|
dispose() {
|
|
1129
|
-
this._offRegistry?.(), this._renderer = null, this._issues = null,
|
|
1144
|
+
this._offRegistry?.(), this._renderer = null, this._issues = null, we() === this && (Ce(null), w(null));
|
|
1130
1145
|
}
|
|
1131
|
-
}, sn =
|
|
1132
|
-
[/\.jpe?g(\?|#|$)/i, "image/jpeg"],
|
|
1133
|
-
[/\.webp(\?|#|$)/i, "image/webp"],
|
|
1134
|
-
[/\.avif(\?|#|$)/i, "image/avif"]
|
|
1135
|
-
];
|
|
1146
|
+
}, sn = "KHR_materials_diffuse_transmission";
|
|
1136
1147
|
function cn(e) {
|
|
1137
|
-
return e.mimeType ? e.mimeType : e.uri?.startsWith("data:") ? e.uri.slice(5, e.uri.indexOf(";")) : sn.find(([t]) => t.test(e.uri ?? ""))?.[1] ?? "image/png";
|
|
1138
|
-
}
|
|
1139
|
-
function ln(e) {
|
|
1140
|
-
for (let t = 8; t + 12 <= e.length;) {
|
|
1141
|
-
let n = (e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3]) >>> 0, r = t + 12 + n;
|
|
1142
|
-
if (e[t + 4] === 73 && e[t + 5] === 69 && e[t + 6] === 78 && e[t + 7] === 68) return e.subarray(0, r);
|
|
1143
|
-
t = r;
|
|
1144
|
-
}
|
|
1145
|
-
return e;
|
|
1146
|
-
}
|
|
1147
|
-
function un({ data: e, width: t, height: n }, { shared: r = !1 } = {}) {
|
|
1148
|
-
let i = new Uint8Array(e.buffer, e.byteOffset, t * n * 4), a = i;
|
|
1149
|
-
r && typeof SharedArrayBuffer < "u" && !(i.buffer instanceof SharedArrayBuffer) && (a = new Uint8Array(new SharedArrayBuffer(i.byteLength)), a.set(i));
|
|
1150
|
-
let o = new tt(a, t, n, vt, Ct);
|
|
1151
|
-
return o.needsUpdate = !0, o;
|
|
1152
|
-
}
|
|
1153
|
-
function dn(e, t) {
|
|
1154
|
-
return b().decodeImage(t === "image/png" ? ln(e) : e, t);
|
|
1155
|
-
}
|
|
1156
|
-
async function fn(e) {
|
|
1157
|
-
let t = await fetch(e);
|
|
1158
|
-
if (!t.ok) throw Error(`HTTP ${t.status}`);
|
|
1159
|
-
return new Uint8Array(await t.arrayBuffer());
|
|
1160
|
-
}
|
|
1161
|
-
function pn(e, t) {
|
|
1162
|
-
return t.bufferView === void 0 ? fn(e.options.manager.resolveURL(R.resolveURL(t.uri, e.options.path))) : e.getDependency("bufferView", t.bufferView).then((e) => new Uint8Array(e));
|
|
1163
|
-
}
|
|
1164
|
-
var mn = (e, t) => !!t && t !== e.textureLoader && typeof t.parse == "function";
|
|
1165
|
-
function hn(e, t, n) {
|
|
1166
|
-
if (e.sourceCache[t] !== void 0) return e.sourceCache[t].then((e) => e.clone());
|
|
1167
|
-
let r = pn(e, e.json.images[t]).then((e) => new Promise((t, r) => {
|
|
1168
|
-
n.parse(e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength), t, r);
|
|
1169
|
-
}));
|
|
1170
|
-
return e.sourceCache[t] = r, r;
|
|
1171
|
-
}
|
|
1172
|
-
async function gn(e, t = cn({ uri: e })) {
|
|
1173
|
-
let n = un(await dn(await fn(e), t));
|
|
1174
|
-
return n.flipY = !0, n;
|
|
1175
|
-
}
|
|
1176
|
-
function _n(e, t = null) {
|
|
1177
|
-
return e.loadImageSource = function(e, n) {
|
|
1178
|
-
if (mn(this, n)) return hn(this, e, n);
|
|
1179
|
-
let r = this.json.images[e], i = /* @__PURE__ */ Error("no image decoder in this runtime: configurePlatform( nodePlatform( { decodeImage } ) ) — see \"Running in Node\"");
|
|
1180
|
-
return t?.(r.uri ?? `bufferView ${r.bufferView}`, i), Promise.reject(i);
|
|
1181
|
-
}, { name: "RAYZEE_missing_image_decoder" };
|
|
1182
|
-
}
|
|
1183
|
-
function vn(e, t = null) {
|
|
1184
|
-
return e.loadImageSource = function(e, n) {
|
|
1185
|
-
if (mn(this, n)) return hn(this, e, n);
|
|
1186
|
-
if (this.sourceCache[e] !== void 0) return this.sourceCache[e].then((e) => e.clone());
|
|
1187
|
-
let r = this.json.images[e], i = cn(r), a = r.uri ?? `bufferView ${r.bufferView}`, o = pn(this, r).then((e) => dn(e, i)).then((e) => {
|
|
1188
|
-
let t = un(e, { shared: !0 });
|
|
1189
|
-
return r.extras && typeof r.extras == "object" && Object.assign(t.userData, r.extras), t.userData.mimeType = i, t;
|
|
1190
|
-
}).catch((e) => {
|
|
1191
|
-
throw t?.(a, e), e;
|
|
1192
|
-
});
|
|
1193
|
-
return this.sourceCache[e] = o, o;
|
|
1194
|
-
}, { name: "RAYZEE_platform_images" };
|
|
1195
|
-
}
|
|
1196
|
-
//#endregion
|
|
1197
|
-
//#region src/Processor/GLTFDiffuseTransmission.js
|
|
1198
|
-
var yn = "KHR_materials_diffuse_transmission";
|
|
1199
|
-
function bn(e) {
|
|
1200
1148
|
let t = (t, n, r, i) => {
|
|
1201
1149
|
let a = {};
|
|
1202
1150
|
return e.assignTexture(a, n, r, i).then(() => {
|
|
@@ -1204,7 +1152,7 @@ function bn(e) {
|
|
|
1204
1152
|
});
|
|
1205
1153
|
};
|
|
1206
1154
|
return {
|
|
1207
|
-
name:
|
|
1155
|
+
name: sn,
|
|
1208
1156
|
afterRoot(n) {
|
|
1209
1157
|
let r = e.json.materials ?? [], i = /* @__PURE__ */ new Set(), a = [];
|
|
1210
1158
|
for (let o of n.scenes ?? []) o.traverse((n) => {
|
|
@@ -1212,7 +1160,7 @@ function bn(e) {
|
|
|
1212
1160
|
for (let n of o) {
|
|
1213
1161
|
if (i.has(n)) continue;
|
|
1214
1162
|
i.add(n);
|
|
1215
|
-
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[
|
|
1163
|
+
let o = e.associations.get(n)?.materials, s = o === void 0 ? null : r[o]?.extensions?.[sn];
|
|
1216
1164
|
if (!s) continue;
|
|
1217
1165
|
n.diffuseTransmission = s.diffuseTransmissionFactor ?? 0;
|
|
1218
1166
|
let [c, l, u] = s.diffuseTransmissionColorFactor ?? [
|
|
@@ -1220,7 +1168,7 @@ function bn(e) {
|
|
|
1220
1168
|
1,
|
|
1221
1169
|
1
|
|
1222
1170
|
];
|
|
1223
|
-
n.diffuseTransmissionColor = new I().setRGB(c, l, u,
|
|
1171
|
+
n.diffuseTransmissionColor = new I().setRGB(c, l, u, ut), s.diffuseTransmissionTexture && a.push(t(n, "diffuseTransmissionMap", s.diffuseTransmissionTexture)), s.diffuseTransmissionColorTexture && a.push(t(n, "diffuseTransmissionColorMap", s.diffuseTransmissionColorTexture, V));
|
|
1224
1172
|
}
|
|
1225
1173
|
});
|
|
1226
1174
|
return Promise.all(a);
|
|
@@ -1229,20 +1177,20 @@ function bn(e) {
|
|
|
1229
1177
|
}
|
|
1230
1178
|
//#endregion
|
|
1231
1179
|
//#region src/Processor/GLTFDecoders.js
|
|
1232
|
-
var
|
|
1233
|
-
function
|
|
1180
|
+
var ln = "KHR_draco_mesh_compression", un = "KHR_texture_basisu", dn = ["EXT_meshopt_compression", "KHR_meshopt_compression"], fn = new TextDecoder();
|
|
1181
|
+
function pn(e) {
|
|
1234
1182
|
if (typeof e == "string") return e;
|
|
1235
1183
|
if (!(e instanceof ArrayBuffer)) return JSON.stringify(e?.extensionsUsed ?? []);
|
|
1236
1184
|
let t = new DataView(e);
|
|
1237
|
-
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return
|
|
1185
|
+
if (!(e.byteLength >= 20 && t.getUint32(0, !0) === 1179937895)) return fn.decode(e);
|
|
1238
1186
|
let n = Math.min(t.getUint32(12, !0), e.byteLength - 20);
|
|
1239
|
-
return
|
|
1187
|
+
return fn.decode(new Uint8Array(e, 20, n));
|
|
1240
1188
|
}
|
|
1241
|
-
async function
|
|
1189
|
+
async function mn(e, t, n) {
|
|
1242
1190
|
let { dracoDecoderPath: r, ktx2TranscoderPath: i } = E(), [a, o, s] = await Promise.all([
|
|
1243
|
-
t.includes(
|
|
1244
|
-
t.includes(
|
|
1245
|
-
|
|
1191
|
+
t.includes(ln) && !e.dracoLoader ? import("three/addons/loaders/DRACOLoader.js") : null,
|
|
1192
|
+
t.includes(un) && !e.ktx2Loader ? import("three/addons/loaders/KTX2Loader.js") : null,
|
|
1193
|
+
dn.some((e) => t.includes(e)) && !e.meshoptDecoder ? import("three/addons/libs/meshopt_decoder.module.js") : null
|
|
1246
1194
|
]);
|
|
1247
1195
|
if (a) {
|
|
1248
1196
|
let t = new a.DRACOLoader();
|
|
@@ -1261,15 +1209,15 @@ async function En(e, t, n) {
|
|
|
1261
1209
|
}
|
|
1262
1210
|
s && e.setMeshoptDecoder(s.MeshoptDecoder);
|
|
1263
1211
|
}
|
|
1264
|
-
function
|
|
1212
|
+
function hn(e, t) {
|
|
1265
1213
|
let n = e.parse.bind(e);
|
|
1266
1214
|
return e.parse = (r, i, a, o) => {
|
|
1267
|
-
|
|
1215
|
+
mn(e, pn(r), t).then(() => n(r, i, a, o), (e) => o?.(e));
|
|
1268
1216
|
}, e;
|
|
1269
1217
|
}
|
|
1270
1218
|
//#endregion
|
|
1271
1219
|
//#region src/Processor/AssetLoader.js
|
|
1272
|
-
var
|
|
1220
|
+
var gn = S("assets"), _n = {
|
|
1273
1221
|
glb: {
|
|
1274
1222
|
type: "model",
|
|
1275
1223
|
name: "GLB (GLTF Binary)"
|
|
@@ -1298,45 +1246,52 @@ var On = S("assets"), kn = {
|
|
|
1298
1246
|
type: "image",
|
|
1299
1247
|
name: "WebP"
|
|
1300
1248
|
}
|
|
1301
|
-
},
|
|
1249
|
+
}, X = {
|
|
1302
1250
|
addOn: "rayzee/addons/archives",
|
|
1303
1251
|
install: "assetLoader.setArchiveImporter()"
|
|
1304
|
-
},
|
|
1252
|
+
}, Z = {
|
|
1305
1253
|
addOn: "rayzee/addons/formats",
|
|
1306
1254
|
install: "assetLoader.registerFormat()"
|
|
1307
|
-
},
|
|
1308
|
-
zip:
|
|
1309
|
-
gz:
|
|
1310
|
-
tgz:
|
|
1311
|
-
tar:
|
|
1312
|
-
fbx:
|
|
1313
|
-
obj:
|
|
1314
|
-
stl:
|
|
1315
|
-
ply:
|
|
1316
|
-
dae:
|
|
1317
|
-
"3mf":
|
|
1318
|
-
usd:
|
|
1319
|
-
usda:
|
|
1320
|
-
usdc:
|
|
1321
|
-
usdz:
|
|
1322
|
-
exr:
|
|
1255
|
+
}, vn = {
|
|
1256
|
+
zip: X,
|
|
1257
|
+
gz: X,
|
|
1258
|
+
tgz: X,
|
|
1259
|
+
tar: X,
|
|
1260
|
+
fbx: Z,
|
|
1261
|
+
obj: Z,
|
|
1262
|
+
stl: Z,
|
|
1263
|
+
ply: Z,
|
|
1264
|
+
dae: Z,
|
|
1265
|
+
"3mf": Z,
|
|
1266
|
+
usd: Z,
|
|
1267
|
+
usda: Z,
|
|
1268
|
+
usdc: Z,
|
|
1269
|
+
usdz: Z,
|
|
1270
|
+
exr: Z
|
|
1323
1271
|
};
|
|
1324
|
-
function
|
|
1325
|
-
let t = new
|
|
1272
|
+
function yn(e) {
|
|
1273
|
+
let t = new rt();
|
|
1326
1274
|
for (let n in e.attributes) t.setAttribute(n, e.attributes[n]);
|
|
1327
1275
|
e.index && t.setIndex(e.index);
|
|
1328
1276
|
for (let n of e.groups) t.addGroup(n.start, n.count, n.materialIndex);
|
|
1329
1277
|
return t;
|
|
1330
1278
|
}
|
|
1331
|
-
var
|
|
1332
|
-
|
|
1279
|
+
var bn = {
|
|
1280
|
+
name: "RAYZEE_camera_clip",
|
|
1281
|
+
afterRoot(e) {
|
|
1282
|
+
for (let t of e.scenes) t.traverse((e) => {
|
|
1283
|
+
e.isCamera && e.near > 0 && (e.userData.clipStart = e.near);
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
}, xn = 683;
|
|
1287
|
+
function Sn(e, t, n, r) {
|
|
1333
1288
|
if (!(r.normalize ?? !0)) return Math.PI;
|
|
1334
1289
|
let i = r.shape === "ellipse" || r.shape === "disk" ? Math.PI / 4 : 1, a = e.getWorldScale(new U()), o = Math.PI * i * Math.abs(t * a.x * n * a.y);
|
|
1335
1290
|
return Number.isFinite(o) ? o : Math.PI;
|
|
1336
1291
|
}
|
|
1337
|
-
var
|
|
1292
|
+
var Cn = class e extends L {
|
|
1338
1293
|
constructor(e, t, n, { issues: r = null, areaLightIntensityScale: i = null } = {}) {
|
|
1339
|
-
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new U(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new
|
|
1294
|
+
super(), this.scene = e, this.camera = t, this.controls = n, this.targetModel = null, this.floorPlane = null, this.sceneScale = 1, this.sceneSize = new U(1, 1, 1), this.loaderCache = {}, this.uploadedFileInfo = null, this.animations = [], this.renderer = null, this.sceneMetadata = null, this._loadingManager = new ft(), this._loadCancelled = !1, this._urlAbort = null, this.storage = null, this._downloads = null, this._sourceKey = null, this._appended = !1, this.archives = null, this._archiveLoader = null, this._formats = /* @__PURE__ */ new Map(), this._issues = r, this._areaLightIntensityScale = i ?? (() => _.areaLightIntensityScale), this._loadingManager.onError = (e) => {
|
|
1340
1295
|
this._loadCancelled || this._issues?.record(C.ASSET_UNREACHABLE, `asset "${e}" could not be fetched — anything depending on it renders without it`, { url: e });
|
|
1341
1296
|
};
|
|
1342
1297
|
}
|
|
@@ -1356,7 +1311,7 @@ var Pn = class e extends L {
|
|
|
1356
1311
|
downloads: this.downloads,
|
|
1357
1312
|
key: i,
|
|
1358
1313
|
policy: a,
|
|
1359
|
-
name:
|
|
1314
|
+
name: q(t),
|
|
1360
1315
|
signal: o.signal,
|
|
1361
1316
|
onProgress: this._downloadProgress(n, r)
|
|
1362
1317
|
});
|
|
@@ -1373,7 +1328,7 @@ var Pn = class e extends L {
|
|
|
1373
1328
|
return t ? `${e}::${t}` : null;
|
|
1374
1329
|
}
|
|
1375
1330
|
get downloads() {
|
|
1376
|
-
return this._downloads?._storage !== this.storage && (this._downloads = new
|
|
1331
|
+
return this._downloads?._storage !== this.storage && (this._downloads = new J(this.storage)), this._downloads;
|
|
1377
1332
|
}
|
|
1378
1333
|
_isCancellation(e) {
|
|
1379
1334
|
return this._loadCancelled || e?.name === "AbortError" || e?.code === "LOAD_CANCELLED";
|
|
@@ -1410,7 +1365,7 @@ var Pn = class e extends L {
|
|
|
1410
1365
|
_adoptExternalObject(e) {
|
|
1411
1366
|
let t;
|
|
1412
1367
|
try {
|
|
1413
|
-
t =
|
|
1368
|
+
t = jt(e);
|
|
1414
1369
|
} catch (t) {
|
|
1415
1370
|
throw Error(`Cannot render "${e.name || e.type}": its userData must be JSON-serializable.`, { cause: t });
|
|
1416
1371
|
}
|
|
@@ -1444,10 +1399,10 @@ var Pn = class e extends L {
|
|
|
1444
1399
|
}
|
|
1445
1400
|
getFileFormat(e) {
|
|
1446
1401
|
let t = e.split(".").pop().toLowerCase();
|
|
1447
|
-
return
|
|
1402
|
+
return _n[t] || this._formats.get(t) || this._archiveFormats?.[t] || null;
|
|
1448
1403
|
}
|
|
1449
1404
|
formatError(e) {
|
|
1450
|
-
let t =
|
|
1405
|
+
let t = vn[e.split(".").pop().toLowerCase()];
|
|
1451
1406
|
return /* @__PURE__ */ Error(t ? `${e}: this format is read by ${t.addOn} — install it with ${t.install}` : `Unsupported file format: ${e}`);
|
|
1452
1407
|
}
|
|
1453
1408
|
async inspectArchive(e) {
|
|
@@ -1498,7 +1453,7 @@ var Pn = class e extends L {
|
|
|
1498
1453
|
}
|
|
1499
1454
|
async loadFolder(e, t = {}) {
|
|
1500
1455
|
let n = await this._archiveImporter();
|
|
1501
|
-
if (!n) throw Error(`${e.name}: folders are read by ${
|
|
1456
|
+
if (!n) throw Error(`${e.name}: folders are read by ${X.addOn} — install it with ${X.install}`);
|
|
1502
1457
|
y({
|
|
1503
1458
|
isLoading: !0,
|
|
1504
1459
|
status: `Loading ${e.name}...`,
|
|
@@ -1515,7 +1470,7 @@ var Pn = class e extends L {
|
|
|
1515
1470
|
}
|
|
1516
1471
|
}
|
|
1517
1472
|
async loadAssetFromUrl(t, n = {}) {
|
|
1518
|
-
let { filename: r =
|
|
1473
|
+
let { filename: r = q(t), cacheKey: i = t, cachePolicy: a, ...o } = n;
|
|
1519
1474
|
if (!this.getFileFormat(r)) throw this.formatError(r);
|
|
1520
1475
|
this._loadCancelled = !1;
|
|
1521
1476
|
let s = e._isNetworkUrl(t), c = `Downloading ${r}...`, l = new AbortController();
|
|
@@ -1551,7 +1506,7 @@ var Pn = class e extends L {
|
|
|
1551
1506
|
}
|
|
1552
1507
|
}
|
|
1553
1508
|
async loadModelFromFile(e, t) {
|
|
1554
|
-
let n = this.storage ? this._keyed("file", O(await
|
|
1509
|
+
let n = this.storage ? this._keyed("file", O(await je(e))) : null, r = /\.(usd|usda|usdc)$/i.test(t) ? await this._archiveImporter() : null, i = r ? await r.loadUSDScene({ [t]: e }, t) : await this._loadModelFileByExtension(e, t);
|
|
1555
1510
|
return this._sourceKey = n, i;
|
|
1556
1511
|
}
|
|
1557
1512
|
async _loadModelFileByExtension(e, t) {
|
|
@@ -1598,7 +1553,7 @@ var Pn = class e extends L {
|
|
|
1598
1553
|
};
|
|
1599
1554
|
try {
|
|
1600
1555
|
let r = await this.loadEnvironment(n);
|
|
1601
|
-
return he(r, O(await
|
|
1556
|
+
return he(r, O(await je(e))), this.dispatchEvent({
|
|
1602
1557
|
type: "load",
|
|
1603
1558
|
texture: r,
|
|
1604
1559
|
filename: t
|
|
@@ -1657,21 +1612,21 @@ var Pn = class e extends L {
|
|
|
1657
1612
|
}
|
|
1658
1613
|
async loadEnvironmentByExtension(t, n, { loader: r = null } = {}) {
|
|
1659
1614
|
let i = this._formats.get(n);
|
|
1660
|
-
if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new
|
|
1615
|
+
if (!r && i?.type === "environment" && (r = this.loaderCache[n] ??= await i.createLoader(this._loadingManager)), !r && n === "hdr" && (r = this.loaderCache.hdr ??= new kt(this._loadingManager).setDataType(ct)), !r && vn[n]) throw this.formatError(`environment.${n}`);
|
|
1661
1616
|
let a = e._isNetworkUrl(t), o = "Downloading Environment...", s = await this._viaCache(t, o, a), c = s.cached ? void 0 : this._downloadProgress(o, a), l;
|
|
1662
1617
|
try {
|
|
1663
|
-
r ? l = await r.loadAsync(s.url, c) :
|
|
1618
|
+
r ? l = await r.loadAsync(s.url, c) : ge().decodeImage ? (l = await Le(s.url, `image/${n === "jpg" ? "jpeg" : n}`), l.colorSpace = V) : (this.loaderCache.texture || (this.loaderCache.texture = new wt(this._loadingManager)), l = await this.loaderCache.texture.loadAsync(s.url, c), l.colorSpace = V);
|
|
1664
1619
|
} finally {
|
|
1665
1620
|
s.release();
|
|
1666
1621
|
}
|
|
1667
|
-
return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth &&
|
|
1622
|
+
return this._downloadComplete("Processing Environment...", 62), this.maxEnvironmentWidth && wn(l, this.maxEnvironmentWidth), l.mapping = st, l.minFilter = lt, l.magFilter = lt, l;
|
|
1668
1623
|
}
|
|
1669
1624
|
applyEnvironmentToScene(e) {
|
|
1670
1625
|
this.scene.background = e, this.scene.environment = e;
|
|
1671
1626
|
}
|
|
1672
1627
|
async createGLTFLoader() {
|
|
1673
|
-
let e =
|
|
1674
|
-
return
|
|
1628
|
+
let e = hn(new Ot(this._loadingManager), this.renderer), t = (e, t) => this._reportImageFailure(e, t);
|
|
1629
|
+
return ge().decodeImage ? e.register((e) => Ie(e, t)) : ne() || e.register((e) => Pe(e, t)), e.register((e) => cn(e)), e.register(() => bn), e;
|
|
1675
1630
|
}
|
|
1676
1631
|
_reportImageFailure(e, t) {
|
|
1677
1632
|
try {
|
|
@@ -1706,9 +1661,9 @@ var Pn = class e extends L {
|
|
|
1706
1661
|
canCancel: i,
|
|
1707
1662
|
loadedBytes: 0,
|
|
1708
1663
|
totalBytes: 0
|
|
1709
|
-
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(
|
|
1664
|
+
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
|
|
1710
1665
|
let e = await v(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1711
|
-
return this._downloadComplete(), this._throwDeferred(), this.releaseTargetModel(), this._sourceKey = i ? this._keyed("url", n.cacheKey ?? t) : null, this.targetModel = e.scene, this.animations = e.animations || [], this.sceneMetadata =
|
|
1666
|
+
return this._downloadComplete(), this._throwDeferred(), this.releaseTargetModel(), this._sourceKey = i ? this._keyed("url", n.cacheKey ?? t) : null, this.targetModel = e.scene, this.animations = e.animations || [], this.sceneMetadata = Re(e), await this.onModelLoad(this.targetModel), this.dispatchEvent({
|
|
1712
1667
|
type: "load",
|
|
1713
1668
|
model: e.scene,
|
|
1714
1669
|
filename: t.split("/").pop()
|
|
@@ -1737,7 +1692,7 @@ var Pn = class e extends L {
|
|
|
1737
1692
|
canCancel: i,
|
|
1738
1693
|
loadedBytes: 0,
|
|
1739
1694
|
totalBytes: 0
|
|
1740
|
-
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(
|
|
1695
|
+
}), a = await this._viaCache(t, "Downloading Model...", i, n), a.cached && r.setResourcePath(dt.extractUrlBase(t));
|
|
1741
1696
|
let e = await v(() => r.loadAsync(a.url, a.cached ? void 0 : this._downloadProgress("Downloading Model...", i)));
|
|
1742
1697
|
return this._downloadComplete(), this._throwDeferred(), this._appended = !0, this._processAndParent(e.scene), {
|
|
1743
1698
|
root: e.scene,
|
|
@@ -1755,7 +1710,7 @@ var Pn = class e extends L {
|
|
|
1755
1710
|
return n.name = e.name || t, this._processAndParent(n), { root: n };
|
|
1756
1711
|
}
|
|
1757
1712
|
removeModelRoot(e) {
|
|
1758
|
-
e && (e.userData.__rayzeeExternal ? (
|
|
1713
|
+
e && (e.userData.__rayzeeExternal ? (ie(e), e.parent?.remove(e)) : te(e));
|
|
1759
1714
|
}
|
|
1760
1715
|
async loadGLBFromArrayBuffer(e, t = "model.glb") {
|
|
1761
1716
|
let n = await this.createGLTFLoader();
|
|
@@ -1766,7 +1721,7 @@ var Pn = class e extends L {
|
|
|
1766
1721
|
progress: 5
|
|
1767
1722
|
}), await new Promise((e) => setTimeout(e, 0));
|
|
1768
1723
|
let r = await v(() => n.parseAsync(e, ""));
|
|
1769
|
-
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata =
|
|
1724
|
+
return this._throwDeferred(), this.releaseTargetModel(), this.targetModel = r.scene, this.animations = r.animations || [], this.sceneMetadata = Re(r), y({
|
|
1770
1725
|
isLoading: !0,
|
|
1771
1726
|
status: "Processing Data...",
|
|
1772
1727
|
progress: 10
|
|
@@ -1799,20 +1754,20 @@ var Pn = class e extends L {
|
|
|
1799
1754
|
}), n;
|
|
1800
1755
|
}
|
|
1801
1756
|
async onModelLoad(e) {
|
|
1802
|
-
let t = new
|
|
1757
|
+
let t = new p("onModelLoad");
|
|
1803
1758
|
t.start("Camera extraction");
|
|
1804
1759
|
let n = this.extractCamerasFromModel(e);
|
|
1805
1760
|
t.end("Camera extraction"), t.start("Camera setup");
|
|
1806
|
-
let r = new
|
|
1761
|
+
let r = new nt().setFromObject(e), i = r.getCenter(new U()), a = r.getSize(new U());
|
|
1807
1762
|
this.controls?.target.copy(i);
|
|
1808
|
-
let o = Math.max(a.x, a.y, a.z), s = this.camera.fov * (Math.PI / 180), c = Math.abs(o / Math.sin(s / 2) / 2),
|
|
1809
|
-
if (this.camera.position.copy(
|
|
1763
|
+
let o = Math.max(a.x, a.y, a.z), s = this.camera.fov * (Math.PI / 180), c = Math.abs(o / Math.sin(s / 2) / 2), l = Math.PI / 6, u = new U(Math.cos(l) * c, c / Math.sqrt(2), Math.sin(l) * c);
|
|
1764
|
+
if (this.camera.position.copy(u.add(i)), this.camera.lookAt(i), this.camera.near = o / 100, this.camera.far = o * 100, this.camera.updateProjectionMatrix(), this.controls && (this.controls.maxDistance = c * 10, this.controls.saveState(), this.controls.update()), t.end("Camera setup"), this.floorPlane) {
|
|
1810
1765
|
let e = r.min.y;
|
|
1811
1766
|
this.floorPlane.position.y = e, this.floorPlane.rotation.x = -Math.PI / 2, this.floorPlane.scale.setScalar(o * 5);
|
|
1812
1767
|
}
|
|
1813
1768
|
t.start("Process model objects"), this.processModelObjects(e), t.end("Process model objects"), t.start("Scene add"), this.scene.add(e), t.end("Scene add");
|
|
1814
|
-
let
|
|
1815
|
-
return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e,
|
|
1769
|
+
let d = o;
|
|
1770
|
+
return this.sceneSize.copy(a), t.start("setupPathTracing"), await this.setupPathTracing(e, d), t.end("setupPathTracing"), t.print(), this.dispatchEvent({
|
|
1816
1771
|
type: "modelProcessed",
|
|
1817
1772
|
model: e,
|
|
1818
1773
|
cameras: n,
|
|
@@ -1820,13 +1775,13 @@ var Pn = class e extends L {
|
|
|
1820
1775
|
center: i,
|
|
1821
1776
|
size: a,
|
|
1822
1777
|
maxDim: o,
|
|
1823
|
-
sceneScale:
|
|
1778
|
+
sceneScale: d
|
|
1824
1779
|
}
|
|
1825
1780
|
}), this.dispatchEvent({ type: "SceneRebuild" }), {
|
|
1826
1781
|
center: i,
|
|
1827
1782
|
size: a,
|
|
1828
1783
|
maxDim: o,
|
|
1829
|
-
sceneScale:
|
|
1784
|
+
sceneScale: d
|
|
1830
1785
|
};
|
|
1831
1786
|
}
|
|
1832
1787
|
extractCamerasFromModel(e) {
|
|
@@ -1842,10 +1797,10 @@ var Pn = class e extends L {
|
|
|
1842
1797
|
let t = [], n = [];
|
|
1843
1798
|
e.traverse((e) => {
|
|
1844
1799
|
let r = e.userData;
|
|
1845
|
-
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *=
|
|
1800
|
+
e.isRectAreaLight && !r.__radianceConverted && (e.intensity *= Sn(e, e.width, e.height, r), r.__radianceConverted = !0), (e.isPointLight || e.isSpotLight) && !r.__candelaConverted && (e.intensity *= 4 * Math.PI / xn, r.__candelaConverted = !0), e.isDirectionalLight && !r.__luxConverted && (e.intensity /= xn, r.__luxConverted = !0);
|
|
1846
1801
|
let i = e.name.startsWith("RectAreaLightPlaceholder");
|
|
1847
1802
|
if (i && !(r.name && r.type === "RectAreaLight") && !e.parent?.name?.startsWith("RectAreaLightPlaceholder") && n.push(e.name), i && r.name && r.type === "RectAreaLight") {
|
|
1848
|
-
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity *
|
|
1803
|
+
let t = r.normalize ?? !0, n = r.shape ?? "rectangle", i = r.intensity * Sn(e, r.width, r.height, r), a = new B(new I(...r.color), i * this._areaLightIntensityScale(), r.width, r.height);
|
|
1849
1804
|
a.userData.normalize = t, a.userData.spread = Number.isFinite(r.spread) ? r.spread : Math.PI, a.userData.shape = n, a.userData.__radianceConverted = !0, a.name = r.name, e.add(a);
|
|
1850
1805
|
}
|
|
1851
1806
|
e.isMesh && Array.isArray(e.material) && t.push(e);
|
|
@@ -1856,8 +1811,8 @@ var Pn = class e extends L {
|
|
|
1856
1811
|
let r = e.userData.__rayzeeExternal === !0;
|
|
1857
1812
|
for (let e of t) {
|
|
1858
1813
|
if (!e.parent) continue;
|
|
1859
|
-
console.log("Found multi-material mesh:", e.name), r && (e.geometry =
|
|
1860
|
-
let t =
|
|
1814
|
+
console.log("Found multi-material mesh:", e.name), r && (e.geometry = yn(e.geometry));
|
|
1815
|
+
let t = At(e);
|
|
1861
1816
|
for (let e of t.children) e.geometry.userData.__rayzeeOwned = !0;
|
|
1862
1817
|
e.parent.add(t), e.parent.remove(e);
|
|
1863
1818
|
}
|
|
@@ -1866,7 +1821,7 @@ var Pn = class e extends L {
|
|
|
1866
1821
|
this.sceneScale = t;
|
|
1867
1822
|
}
|
|
1868
1823
|
createFloorPlane() {
|
|
1869
|
-
this.floorPlane = new
|
|
1824
|
+
this.floorPlane = new pt(new it(), new mt({
|
|
1870
1825
|
transparent: !1,
|
|
1871
1826
|
color: 3158064,
|
|
1872
1827
|
roughness: 1,
|
|
@@ -1889,7 +1844,7 @@ var Pn = class e extends L {
|
|
|
1889
1844
|
}
|
|
1890
1845
|
getSupportedFormats(e = null) {
|
|
1891
1846
|
let t = {
|
|
1892
|
-
...
|
|
1847
|
+
..._n,
|
|
1893
1848
|
...this._archiveFormats
|
|
1894
1849
|
};
|
|
1895
1850
|
for (let [e, { type: n, name: r }] of this._formats) t[e] = {
|
|
@@ -1914,7 +1869,7 @@ var Pn = class e extends L {
|
|
|
1914
1869
|
this._listeners = void 0;
|
|
1915
1870
|
}
|
|
1916
1871
|
};
|
|
1917
|
-
function
|
|
1872
|
+
function wn(e, t) {
|
|
1918
1873
|
let { data: n, width: r, height: i } = e.image ?? {};
|
|
1919
1874
|
if (!(n instanceof Float32Array) || r <= t || n.length !== r * i * 4) return;
|
|
1920
1875
|
let a = Math.ceil(r / t), o = Math.ceil(r / a), s = Math.ceil(i / a);
|
|
@@ -1935,17 +1890,17 @@ function Fn(e, t) {
|
|
|
1935
1890
|
data: n.byteOffset === 0 && n.byteLength === n.buffer.byteLength && n.buffer.transfer ? new Float32Array(n.buffer.transfer(c)) : n.slice(0, o * s * 4),
|
|
1936
1891
|
width: o,
|
|
1937
1892
|
height: s
|
|
1938
|
-
}, e.needsUpdate = !0,
|
|
1893
|
+
}, e.needsUpdate = !0, gn.info(`environment ${r}×${i} shrunk to ${o}×${s} (memory spill)`);
|
|
1939
1894
|
}
|
|
1940
1895
|
//#endregion
|
|
1941
1896
|
//#region src/HeadlessCanvas.js
|
|
1942
|
-
var
|
|
1897
|
+
var Tn = {
|
|
1943
1898
|
addEventListener() {},
|
|
1944
1899
|
removeEventListener() {},
|
|
1945
1900
|
dispatchEvent() {
|
|
1946
1901
|
return !0;
|
|
1947
1902
|
}
|
|
1948
|
-
},
|
|
1903
|
+
}, En = class {
|
|
1949
1904
|
constructor(e) {
|
|
1950
1905
|
this.canvas = e, this._configuration = null, this._texture = null;
|
|
1951
1906
|
}
|
|
@@ -1973,12 +1928,12 @@ var In = {
|
|
|
1973
1928
|
return this._texture;
|
|
1974
1929
|
}
|
|
1975
1930
|
};
|
|
1976
|
-
function
|
|
1931
|
+
function Dn(e = 1, t = 1) {
|
|
1977
1932
|
let n = {
|
|
1978
|
-
...
|
|
1933
|
+
...Tn,
|
|
1979
1934
|
defaultView: null
|
|
1980
1935
|
}, r = {
|
|
1981
|
-
...
|
|
1936
|
+
...Tn,
|
|
1982
1937
|
isHeadlessCanvas: !0,
|
|
1983
1938
|
width: e,
|
|
1984
1939
|
height: t,
|
|
@@ -2005,12 +1960,12 @@ function Rn(e = 1, t = 1) {
|
|
|
2005
1960
|
hasPointerCapture: () => !1,
|
|
2006
1961
|
focus() {},
|
|
2007
1962
|
getContext: (e) => e === "webgpu" ? i : null
|
|
2008
|
-
}, i = new
|
|
1963
|
+
}, i = new En(r);
|
|
2009
1964
|
return r;
|
|
2010
1965
|
}
|
|
2011
1966
|
//#endregion
|
|
2012
1967
|
//#region src/managers/ViewCamera.js
|
|
2013
|
-
var
|
|
1968
|
+
var On = class extends vt {
|
|
2014
1969
|
constructor(e, t, n, r) {
|
|
2015
1970
|
super(e, t, n, r), this.orthographic = !1, this.orthoHalfHeight = 1;
|
|
2016
1971
|
}
|
|
@@ -2034,17 +1989,17 @@ var zn = class extends mt {
|
|
|
2034
1989
|
return -this.orthoHalfHeight * this.aspect;
|
|
2035
1990
|
}
|
|
2036
1991
|
updateProjectionMatrix() {
|
|
2037
|
-
this.orthographic ?
|
|
1992
|
+
this.orthographic ? _t.prototype.updateProjectionMatrix.call(this) : super.updateProjectionMatrix();
|
|
2038
1993
|
}
|
|
2039
1994
|
copy(e, t) {
|
|
2040
1995
|
return super.copy(e, t), this.orthographic = e.orthographic === !0, this.orthoHalfHeight = e.orthoHalfHeight ?? this.orthoHalfHeight, this;
|
|
2041
1996
|
}
|
|
2042
|
-
},
|
|
2043
|
-
DirectionalLight:
|
|
2044
|
-
PointLight:
|
|
2045
|
-
SpotLight:
|
|
2046
|
-
RectAreaLight:
|
|
2047
|
-
},
|
|
1997
|
+
}, kn = "__rayzeeUserLight", An = {
|
|
1998
|
+
DirectionalLight: at,
|
|
1999
|
+
PointLight: yt,
|
|
2000
|
+
SpotLight: St,
|
|
2001
|
+
RectAreaLight: B
|
|
2002
|
+
}, jn = class extends L {
|
|
2048
2003
|
constructor(e, t, n, r = {}) {
|
|
2049
2004
|
super(), this.scene = e, this.sceneHelpers = t, this.pathTracer = n, this._onReset = r.onReset || null, this._onLightRemoved = r.onLightRemoved || null;
|
|
2050
2005
|
}
|
|
@@ -2092,14 +2047,14 @@ var zn = class extends mt {
|
|
|
2092
2047
|
}[e];
|
|
2093
2048
|
if (!t) return null;
|
|
2094
2049
|
let n;
|
|
2095
|
-
if (e === "DirectionalLight") n = new
|
|
2096
|
-
else if (e === "PointLight") n = new
|
|
2050
|
+
if (e === "DirectionalLight") n = new at(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2051
|
+
else if (e === "PointLight") n = new yt(t.color, t.intensity), n.position.fromArray(t.position);
|
|
2097
2052
|
else if (e === "SpotLight") {
|
|
2098
|
-
n = new
|
|
2099
|
-
let e = new
|
|
2053
|
+
n = new St(t.color, t.intensity), n.position.fromArray(t.position), n.angle = R.degToRad(t.angle);
|
|
2054
|
+
let e = new z();
|
|
2100
2055
|
this.scene.add(e), n.target = e;
|
|
2101
|
-
} else e === "RectAreaLight" && (n = new
|
|
2102
|
-
n.userData[
|
|
2056
|
+
} else e === "RectAreaLight" && (n = new B(t.color, t.intensity, t.width, t.height), n.position.fromArray(t.position), n.lookAt(0, 0, 0), n.userData.normalize = !0, n.userData.spread = Math.PI, n.userData.shape = "rectangle");
|
|
2057
|
+
n.userData[kn] = !0, n.userData.temperature = 6500, n.userData.useTemperature = !1, n.userData.exposure = 0;
|
|
2103
2058
|
let r = this.scene.getObjectsByProperty("isLight", !0).length;
|
|
2104
2059
|
return n.name = `${e.replace("Light", "")} ${r + 1}`, this.scene.add(n), this.updateLights(), this._syncHelpers(), this._onReset?.(), this._buildDescriptor(n);
|
|
2105
2060
|
}
|
|
@@ -2125,7 +2080,7 @@ var zn = class extends mt {
|
|
|
2125
2080
|
this.pathTracer?.updateLights(), this.sceneHelpers?.visible && this.sceneHelpers.update();
|
|
2126
2081
|
}
|
|
2127
2082
|
transferSceneLights(e, { keepUserLights: t = !1 } = {}) {
|
|
2128
|
-
this._removeAllLights(t ? (e) => !e.userData?.[
|
|
2083
|
+
this._removeAllLights(t ? (e) => !e.userData?.[kn] : void 0);
|
|
2129
2084
|
let n = e.getObjectsByProperty("isLight", !0);
|
|
2130
2085
|
if (!n || n.length === 0) {
|
|
2131
2086
|
this.updateLights();
|
|
@@ -2134,7 +2089,7 @@ var zn = class extends mt {
|
|
|
2134
2089
|
for (let e of n) {
|
|
2135
2090
|
let t = e.clone();
|
|
2136
2091
|
if (e.updateWorldMatrix(!0, !1), e.getWorldPosition(t.position), e.getWorldQuaternion(t.quaternion), e.getWorldScale(t.scale), t.isRectAreaLight && (t.width *= t.scale.x, t.height *= t.scale.y, t.scale.set(1, 1, 1)), (e.isSpotLight || e.isDirectionalLight) && e.target) {
|
|
2137
|
-
let n = new
|
|
2092
|
+
let n = new z();
|
|
2138
2093
|
e.target.updateWorldMatrix(!0, !1), e.target.getWorldPosition(n.position), this.scene.add(n), t.target = n;
|
|
2139
2094
|
}
|
|
2140
2095
|
this.scene.add(t);
|
|
@@ -2179,14 +2134,14 @@ var zn = class extends mt {
|
|
|
2179
2134
|
this.sceneHelpers?.clear(), this._removeAllLights();
|
|
2180
2135
|
let t = [];
|
|
2181
2136
|
for (let n of e ?? []) {
|
|
2182
|
-
let e =
|
|
2137
|
+
let e = An[n.type];
|
|
2183
2138
|
if (!e) continue;
|
|
2184
2139
|
let r = new e();
|
|
2185
2140
|
r.name = n.name ?? "", r.visible = n.visible !== !1, r.color.setRGB(...n.color), r.intensity = n.intensity, r.position.fromArray(n.position), r.quaternion.fromArray(n.quaternion), r.scale.fromArray(n.scale ?? [
|
|
2186
2141
|
1,
|
|
2187
2142
|
1,
|
|
2188
2143
|
1
|
|
2189
|
-
]), r.userData =
|
|
2144
|
+
]), r.userData = i(n.userData) ?? {};
|
|
2190
2145
|
for (let e of [
|
|
2191
2146
|
"angle",
|
|
2192
2147
|
"penumbra",
|
|
@@ -2196,7 +2151,7 @@ var zn = class extends mt {
|
|
|
2196
2151
|
"height"
|
|
2197
2152
|
]) typeof n[e] == "number" && (r[e] = n[e]);
|
|
2198
2153
|
if (n.target) {
|
|
2199
|
-
let e = new
|
|
2154
|
+
let e = new z();
|
|
2200
2155
|
e.position.fromArray(n.target), this.scene.add(e), r.target = e;
|
|
2201
2156
|
}
|
|
2202
2157
|
this.scene.add(r), t.push(r);
|
|
@@ -2236,7 +2191,7 @@ var zn = class extends mt {
|
|
|
2236
2191
|
}
|
|
2237
2192
|
_buildDescriptor(e) {
|
|
2238
2193
|
let t = 0;
|
|
2239
|
-
e.type === "SpotLight" && e.angle !== void 0 ? t =
|
|
2194
|
+
e.type === "SpotLight" && e.angle !== void 0 ? t = R.radToDeg(e.angle) : e.type === "DirectionalLight" && (t = R.radToDeg(e.userData?.angle ?? 0));
|
|
2240
2195
|
let n = {
|
|
2241
2196
|
uuid: e.uuid,
|
|
2242
2197
|
name: e.name,
|
|
@@ -2255,7 +2210,7 @@ var zn = class extends mt {
|
|
|
2255
2210
|
exposure: e.userData?.exposure ?? 0
|
|
2256
2211
|
};
|
|
2257
2212
|
if (e.type === "RectAreaLight") {
|
|
2258
|
-
n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread =
|
|
2213
|
+
n.width = e.width, n.height = e.height, n.normalize = e.userData?.normalize ?? !0, n.spread = R.radToDeg(e.userData?.spread ?? Math.PI);
|
|
2259
2214
|
let t = e.userData?.shape;
|
|
2260
2215
|
n.shape = t === "square" || t === "rectangle" || t === "disk" || t === "ellipse" ? t : t === 1 ? "ellipse" : "rectangle";
|
|
2261
2216
|
let r = e.getWorldDirection(e.position.clone());
|
|
@@ -2271,11 +2226,11 @@ var zn = class extends mt {
|
|
|
2271
2226
|
], n.distance = e.distance ?? 0, n.penumbra = e.penumbra ?? 0, n.decay = e.decay ?? 2) : e.type === "PointLight" && (n.distance = e.distance ?? 0, n.decay = e.decay ?? 2);
|
|
2272
2227
|
return (e.type === "SpotLight" || e.type === "DirectionalLight") && e.userData?.gobo && (n.gobo = e.userData.gobo.name, n.goboIntensity = e.userData.gobo.intensity, n.goboInverted = !!e.userData.gobo.inverted, e.type === "DirectionalLight" && (n.goboScale = e.userData.gobo.scale ?? 5)), e.type === "SpotLight" && e.userData?.ies && (n.ies = e.userData.ies.name, n.iesIntensity = e.userData.ies.intensity ?? 1, n.fixtureLumens = e.userData.ies.fixtureLumens ?? null), n;
|
|
2273
2228
|
}
|
|
2274
|
-
},
|
|
2229
|
+
}, Mn = ({ element: e, pbrtEntry: t } = {}) => ({
|
|
2275
2230
|
...e === void 0 ? {} : { element: e },
|
|
2276
2231
|
...t === void 0 ? {} : { pbrtEntry: t }
|
|
2277
|
-
}), Q = /* @__PURE__ */ new WeakMap(),
|
|
2278
|
-
async function
|
|
2232
|
+
}), Q = /* @__PURE__ */ new WeakMap(), Nn = 3e4, Pn = new Set([...Object.values(g), ...Object.values(h)]), Fn = /* @__PURE__ */ new Set();
|
|
2233
|
+
async function In(e, t) {
|
|
2279
2234
|
if (!t || typeof self < "u") return e.init();
|
|
2280
2235
|
globalThis.self = {
|
|
2281
2236
|
requestAnimationFrame: () => 0,
|
|
@@ -2288,36 +2243,57 @@ async function Kn(e, t) {
|
|
|
2288
2243
|
}
|
|
2289
2244
|
}
|
|
2290
2245
|
var $ = S("engine");
|
|
2291
|
-
function
|
|
2246
|
+
function Ln() {
|
|
2292
2247
|
let e = new Float32Array(16);
|
|
2293
|
-
return new Uint32Array(e.buffer)[3] =
|
|
2248
|
+
return new Uint32Array(e.buffer)[3] = ve.TRIANGLE_LEAF, e;
|
|
2294
2249
|
}
|
|
2295
|
-
function
|
|
2250
|
+
function Rn(e, t) {
|
|
2296
2251
|
e.lost.then((e) => {
|
|
2297
2252
|
t.app && t.app._handleDeviceLost(e);
|
|
2298
2253
|
});
|
|
2299
2254
|
}
|
|
2300
|
-
var
|
|
2301
|
-
|
|
2255
|
+
var zn = [
|
|
2256
|
+
"core-features-and-limits",
|
|
2257
|
+
"depth-clip-control",
|
|
2258
|
+
"depth32float-stencil8",
|
|
2259
|
+
"texture-compression-bc",
|
|
2260
|
+
"texture-compression-bc-sliced-3d",
|
|
2261
|
+
"texture-compression-etc2",
|
|
2262
|
+
"texture-compression-astc",
|
|
2263
|
+
"texture-compression-astc-sliced-3d",
|
|
2264
|
+
"timestamp-query",
|
|
2265
|
+
"indirect-first-instance",
|
|
2266
|
+
"shader-f16",
|
|
2267
|
+
"rg11b10ufloat-renderable",
|
|
2268
|
+
"bgra8unorm-storage",
|
|
2269
|
+
"float32-filterable",
|
|
2270
|
+
"float32-blendable",
|
|
2271
|
+
"clip-distances",
|
|
2272
|
+
"dual-source-blending",
|
|
2273
|
+
"subgroups",
|
|
2274
|
+
"texture-formats-tier1",
|
|
2275
|
+
"texture-formats-tier2"
|
|
2276
|
+
], Bn = /swiftshader|llvmpipe|lavapipe|basic render|microsoft basic|warp/i;
|
|
2277
|
+
function Vn(e) {
|
|
2302
2278
|
let t = e.info ?? {}, n = `${t.vendor ?? ""} ${t.architecture ?? ""} ${t.device ?? ""} ${t.description ?? ""}`;
|
|
2303
2279
|
return {
|
|
2304
2280
|
vendor: t.vendor ?? "",
|
|
2305
2281
|
architecture: t.architecture ?? "",
|
|
2306
2282
|
device: t.device ?? "",
|
|
2307
2283
|
description: t.description ?? "",
|
|
2308
|
-
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 ||
|
|
2284
|
+
isSoftware: t.isFallbackAdapter === !0 || e.isFallbackAdapter === !0 || Bn.test(n)
|
|
2309
2285
|
};
|
|
2310
2286
|
}
|
|
2311
|
-
var
|
|
2287
|
+
var Hn = class extends L {
|
|
2312
2288
|
constructor(e, t = {}) {
|
|
2313
|
-
super(), this._headless = t.headless === !0 || !e, e ??=
|
|
2289
|
+
super(), this._headless = t.headless === !0 || !e, e ??= Dn();
|
|
2314
2290
|
try {
|
|
2315
2291
|
Q.get(e)?.dispose();
|
|
2316
2292
|
} catch (e) {
|
|
2317
2293
|
$.warn("prior canvas owner dispose failed", e);
|
|
2318
2294
|
}
|
|
2319
2295
|
if (Q.set(e, this), this.canvas = e, this._autoResize = !this._headless && t.autoResize !== !1, this._maxSceneBytes = t.maxSceneBytes, this._hostMemoryGB = t.hostMemoryGB, this._storageOption = t.storage, this._storageOpener = null, this._memorySpill = t.memorySpill === !0 || t.memorySpill === !1 ? t.memorySpill : "auto", this._spillPlan = null, this.storage = null, this._storageRelease = null, this._applySceneMetadataEnabled = t.applySceneMetadata !== !1, this._unlitRestore = null, this._applyingSceneMetadata = !1, t.profile !== void 0) throw Error("the `profile` option was removed: the engine has one set of defaults. For the old 'physical' profile set `areaLightIntensityScale: 1` and `dofMode: 'physical'` through `settings`.");
|
|
2320
|
-
this._issues = new
|
|
2296
|
+
this._issues = new ye({
|
|
2321
2297
|
strict: t.strict === !0,
|
|
2322
2298
|
onIssue: (e) => this.dispatchEvent({
|
|
2323
2299
|
type: g.ISSUE,
|
|
@@ -2342,18 +2318,18 @@ var Zn = class extends L {
|
|
|
2342
2318
|
}
|
|
2343
2319
|
async init() {
|
|
2344
2320
|
let e = this._initStorage();
|
|
2345
|
-
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this.camera = this._createCamera(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), await e, this._attachStorage(), this.stages.pathTracer.setTriangleData(new Uint32Array(
|
|
2321
|
+
return await this._initRenderer(), this._applyPendingReservedRenderSize(), this.camera = this._createCamera(), this._initScenes(), this._initAssetPipeline(), this._initPipeline(), await this._initManagers(), this._wireEvents(), await e, this._attachStorage(), this.stages.pathTracer.setTriangleData(new Uint32Array(_e.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Ln()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setupMaterial(), this.isInitialized = !0, $.debug("WebGPU path tracer app initialized"), this;
|
|
2346
2322
|
}
|
|
2347
2323
|
async setStorageOpener(e) {
|
|
2348
2324
|
this._storageOpener = e, !(!this.isInitialized || this.storage || this._disposed) && (await this._initStorage(), this._attachStorage());
|
|
2349
2325
|
}
|
|
2350
2326
|
async _initStorage() {
|
|
2351
|
-
let e = this._storageOption ?? (this._issues.strict && !
|
|
2327
|
+
let e = this._storageOption ?? (this._issues.strict && !Te("storage") ? !1 : E().storage);
|
|
2352
2328
|
if (e !== !1) {
|
|
2353
2329
|
if (e && typeof e == "object") this.storage = e;
|
|
2354
2330
|
else {
|
|
2355
2331
|
if (!this._storageOpener) {
|
|
2356
|
-
(this._storageOption !== void 0 ||
|
|
2332
|
+
(this._storageOption !== void 0 || Te("storage")) && this._issues.warn(C.CAPABILITY_MISSING, "on-disk storage needs rayzee/addons/storage: setStorageOpener( acquireSharedStorage )");
|
|
2357
2333
|
return;
|
|
2358
2334
|
}
|
|
2359
2335
|
let { storage: e, reason: t, release: n } = await this._storageOpener(E().cacheNamespace);
|
|
@@ -2385,7 +2361,7 @@ var Zn = class extends L {
|
|
|
2385
2361
|
});
|
|
2386
2362
|
}
|
|
2387
2363
|
addEventListener(e, t) {
|
|
2388
|
-
!
|
|
2364
|
+
!Pn.has(e) && !Fn.has(e) && (Fn.add(e), $.warn(`no engine event is named "${e}", so this listener will never fire — see EngineEvents`)), super.addEventListener(e, t);
|
|
2389
2365
|
}
|
|
2390
2366
|
animate() {
|
|
2391
2367
|
if (this._headless) throw Error("a headless app has no render loop — drive it with renderFrames() or renderUntilComplete()");
|
|
@@ -2474,26 +2450,27 @@ var Zn = class extends L {
|
|
|
2474
2450
|
t && this.stages.pathTracer?.noteViewChanged(), this._beforeReset(e || t), this.pipeline && (this.pipeline.reset(), e || this.pipeline.eventBus.emit("pipeline:historyReset")), this._afterReset(), this.completion.reset(), this.wake(), this.dispatchEvent({ type: g.RENDER_RESET });
|
|
2475
2451
|
}
|
|
2476
2452
|
dispose() {
|
|
2477
|
-
if (
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
}
|
|
2490
|
-
this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas), this._gpuDevice &&= (this._gpuDevice.onuncapturederror = null, null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), oe(this.renderer), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
2453
|
+
if (this._disposed) return;
|
|
2454
|
+
if (this._disposed = !0, this.dispatchEvent({ type: g.DISPOSE }), this.stopAnimation(), clearTimeout(this._resizeDebounceTimer), this._resizeDebounceTimer = null, clearTimeout(this._respillTimer), this._respillTimer = null, this._removeTrackedListeners(), fe(null), this._storageRelease?.(), this._storageRelease = null, this.storage = null, this._sceneSource = this._sceneSourceInput = null, this._issues.detach(), this.color?.dispose(), this.color = null, this._textureReadback?.dispose(), this._textureReadback = null, this._readbackToneMapper?.dispose(), this._readbackToneMapper = null, this._disposeExtensions(), this.lightManager?.dispose(), this.pipeline?.dispose(), this._sdf?.dispose(), this._sdf = null, this.assetLoader?.dispose(), this.assetLoader = null, this.meshScene) {
|
|
2455
|
+
this.meshScene.environment?.dispose(), this.meshScene.environment = null;
|
|
2456
|
+
for (let e of [...this.meshScene.children]) te(e);
|
|
2457
|
+
this.meshScene.clear(), this.meshScene = null;
|
|
2458
|
+
}
|
|
2459
|
+
this._sceneHelpers?.clear(), this._sceneHelpers = null, this.scene?.clear(), this.scene = null;
|
|
2460
|
+
try {
|
|
2461
|
+
let e = $e().value, t = Ye().value;
|
|
2462
|
+
e?._listeners?.dispose && (e._listeners.dispose.length = 0), t?._listeners?.dispose && (t._listeners.dispose.length = 0);
|
|
2463
|
+
} catch (e) {
|
|
2464
|
+
$.warn("failed to clear TSL texture singleton listeners", e);
|
|
2491
2465
|
}
|
|
2466
|
+
this.canvas && Q.get(this.canvas) === this && Q.delete(this.canvas);
|
|
2467
|
+
let e = this._gpuDevice;
|
|
2468
|
+
e && (e.onuncapturederror = null, this._gpuDevice = null), this._deviceLostHolder &&= (this._deviceLostHolder.app = null, null), Promise.resolve(se(this.renderer)).finally(() => e?.destroy()), this.renderer = null, this.stages = {}, this.isInitialized = !1;
|
|
2492
2469
|
}
|
|
2493
2470
|
unloadScene() {
|
|
2494
2471
|
if (this.isInitialized) {
|
|
2495
2472
|
if (this._loadingInProgress) throw Error("PathTracerApp.unloadScene: cannot unload while a load is in progress");
|
|
2496
|
-
this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(
|
|
2473
|
+
this._disposed || (this._releaseSceneState(), this.assetLoader?.releaseTargetModel(), this._sceneSource = this._sceneSourceInput = null, this.lightManager?.clearLights?.(), this.stages.pathTracer && (this.stages.pathTracer.setTriangleData(new Uint32Array(_e.FLOATS_PER_TRIANGLE), 0), this.stages.pathTracer.setBVHData(Ln()), this.stages.pathTracer.materialData.setMaterialData(new Float32Array(16)), this.stages.pathTracer.setEmissiveTriangleData?.(new Float32Array(), 0, 0), this.stages.pathTracer.setupMaterial()), this._dropDisplay(), this.reset(), this.dispatchEvent({ type: g.SCENE_UNLOADED }));
|
|
2497
2474
|
}
|
|
2498
2475
|
}
|
|
2499
2476
|
async loadModel(e, t = {}) {
|
|
@@ -2538,7 +2515,7 @@ var Zn = class extends L {
|
|
|
2538
2515
|
}
|
|
2539
2516
|
async loadFile(e, t = {}) {
|
|
2540
2517
|
if (t = this._sceneBudgets(t), typeof e == "string") {
|
|
2541
|
-
let n = t.filename ??
|
|
2518
|
+
let n = t.filename ?? q(e), r = this.assetLoader?.getFileFormat(n);
|
|
2542
2519
|
if (!r) throw this.assetLoader.formatError(n);
|
|
2543
2520
|
if (r.type === "environment" || r.type === "image") return this.loadEnvironment(e);
|
|
2544
2521
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadAssetFromUrl(e, {
|
|
@@ -2552,24 +2529,24 @@ var Zn = class extends L {
|
|
|
2552
2529
|
url: e,
|
|
2553
2530
|
filename: n,
|
|
2554
2531
|
cacheKey: t.cacheKey ?? null,
|
|
2555
|
-
...
|
|
2532
|
+
...Mn(t)
|
|
2556
2533
|
});
|
|
2557
2534
|
return;
|
|
2558
2535
|
}
|
|
2559
2536
|
if (Ne(e)) {
|
|
2560
|
-
let n =
|
|
2537
|
+
let n = Fe(e, { isModel: (e) => this.assetLoader?.getFileFormat(e)?.type === "model" });
|
|
2561
2538
|
if (n.files.length === 0) throw Error(`${n.name} holds no files to load`);
|
|
2562
2539
|
await this._loadWithSceneRebuild(() => this.assetLoader.loadFolder(n, t), {
|
|
2563
2540
|
type: g.MODEL_LOADED,
|
|
2564
2541
|
filename: n.name
|
|
2565
2542
|
}, async () => {
|
|
2566
|
-
let e = await
|
|
2543
|
+
let e = await Me(n);
|
|
2567
2544
|
return {
|
|
2568
2545
|
kind: "local-folder",
|
|
2569
2546
|
folder: e,
|
|
2570
2547
|
key: O(e),
|
|
2571
2548
|
...n.flat ? { flat: !0 } : {},
|
|
2572
|
-
...
|
|
2549
|
+
...Mn(t)
|
|
2573
2550
|
};
|
|
2574
2551
|
}), this._sceneSourceInput = n;
|
|
2575
2552
|
return;
|
|
@@ -2577,7 +2554,7 @@ var Zn = class extends L {
|
|
|
2577
2554
|
let n = this.assetLoader?.getFileFormat(e?.name || "");
|
|
2578
2555
|
if (!n) throw this.assetLoader.formatError(e?.name || "");
|
|
2579
2556
|
if (n.type !== "environment" && n.type !== "image") {
|
|
2580
|
-
let n =
|
|
2557
|
+
let n = je(e).catch(() => ({
|
|
2581
2558
|
name: e.name,
|
|
2582
2559
|
size: e.size,
|
|
2583
2560
|
lastModified: e.lastModified ?? 0,
|
|
@@ -2592,7 +2569,7 @@ var Zn = class extends L {
|
|
|
2592
2569
|
kind: "local-file",
|
|
2593
2570
|
file: e,
|
|
2594
2571
|
key: e.sample ? O(e) : null,
|
|
2595
|
-
...
|
|
2572
|
+
...Mn(t)
|
|
2596
2573
|
};
|
|
2597
2574
|
}), this._sceneSourceInput = e;
|
|
2598
2575
|
return;
|
|
@@ -2648,11 +2625,11 @@ var Zn = class extends L {
|
|
|
2648
2625
|
}
|
|
2649
2626
|
async _loadWithSceneRebuild(e, t, n = null) {
|
|
2650
2627
|
if (this._loadingInProgress) throw this._busyError("PathTracerApp");
|
|
2651
|
-
this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ?
|
|
2628
|
+
this._loadingInProgress = !0, this.assetLoader && (this.assetLoader.maxEnvironmentWidth = this._memorySpill === !0 ? le : 0);
|
|
2652
2629
|
try {
|
|
2653
2630
|
await e(), this._sceneSource = typeof n == "function" ? await n() : n, this._sceneSourceInput = null, this._emissiveSamplingUserSet = !1, this._clearAppendedModels(), this._modelReplaced(), this._planSpill(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() }), this._maybeSpill(), this.pipeline?.eventBus.emit("pipeline:lightingChanged"), this._dropDisplay(), this.reset(), this.dispatchEvent(t), this._modelAnnounced();
|
|
2654
2631
|
} catch (e) {
|
|
2655
|
-
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ?
|
|
2632
|
+
throw (!e || e.code !== "LOAD_IN_PROGRESS") && this._discardFailedLoad(), e?.code === "ARCHIVE_NEEDS_ELEMENT" ? b() : e?.code !== "LOAD_IN_PROGRESS" && y({
|
|
2656
2633
|
status: `Error: ${e?.message ?? e}`,
|
|
2657
2634
|
failed: !0,
|
|
2658
2635
|
progress: 100
|
|
@@ -2692,7 +2669,7 @@ var Zn = class extends L {
|
|
|
2692
2669
|
};
|
|
2693
2670
|
n.intensity !== void 0 && (r.environmentIntensity = n.intensity, r.backgroundIntensity = n.intensity), n.rotation !== void 0 && (r.environmentRotation = n.rotation), this.settings.setMany(r, {
|
|
2694
2671
|
reset: !1,
|
|
2695
|
-
source:
|
|
2672
|
+
source: Y.SCENE_METADATA
|
|
2696
2673
|
}), this.scene && (this.scene.background = e), this.dispatchEvent({
|
|
2697
2674
|
type: g.SCENE_METADATA_APPLIED,
|
|
2698
2675
|
metadata: t,
|
|
@@ -2709,7 +2686,7 @@ var Zn = class extends L {
|
|
|
2709
2686
|
source: e[t].source
|
|
2710
2687
|
}])), this.settings.setMany(t, {
|
|
2711
2688
|
reset: !1,
|
|
2712
|
-
source:
|
|
2689
|
+
source: Y.SCENE_METADATA
|
|
2713
2690
|
}), this.dispatchEvent({
|
|
2714
2691
|
type: g.SCENE_METADATA_APPLIED,
|
|
2715
2692
|
metadata: this.sceneMetadata,
|
|
@@ -2721,7 +2698,7 @@ var Zn = class extends L {
|
|
|
2721
2698
|
if (!e) return;
|
|
2722
2699
|
this._unlitRestore = null;
|
|
2723
2700
|
let t = this.settings.getEffective();
|
|
2724
|
-
for (let [n, { value: r, source: i }] of Object.entries(e)) t[n]?.source ===
|
|
2701
|
+
for (let [n, { value: r, source: i }] of Object.entries(e)) t[n]?.source === Y.SCENE_METADATA && this.settings.set(n, r, {
|
|
2725
2702
|
reset: !1,
|
|
2726
2703
|
source: i
|
|
2727
2704
|
});
|
|
@@ -2733,7 +2710,7 @@ var Zn = class extends L {
|
|
|
2733
2710
|
}
|
|
2734
2711
|
async loadSceneData({ pendingEnvironment: e = null, keepUserLights: t = !1 } = {}) {
|
|
2735
2712
|
this._releaseSceneState({ keepSelection: !!this._preserveSelectionOnRebuild }), this._tagPrimarySceneObject();
|
|
2736
|
-
let n = new
|
|
2713
|
+
let n = new p("", {
|
|
2737
2714
|
namespace: "scene",
|
|
2738
2715
|
level: "info"
|
|
2739
2716
|
}), r = () => this.stages.pathTracer.environment.envParams.mode === "hdri" ? this.meshScene.environment : null, i = r(), a = null;
|
|
@@ -2761,7 +2738,7 @@ var Zn = class extends L {
|
|
|
2761
2738
|
let e = (this._sdf?.emissiveTriangleBuilder?.emissiveTriangles?.length ?? this._sdf?.emissiveTriangleCount ?? 0) > 0;
|
|
2762
2739
|
this.settings.set("enableEmissiveTriangleSampling", e, { reset: !1 });
|
|
2763
2740
|
}
|
|
2764
|
-
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()),
|
|
2741
|
+
return n.start("Apply settings"), this.settings.applyAll(), this.stages.compositor.setTransparentBackground(this.settings.get("transparentBackground")), n.end("Apply settings"), n.print(this._sceneSummaryParts()), b(), this._sceneRebuilt(), this.dispatchEvent({ type: g.SCENE_REBUILD }), !0;
|
|
2765
2742
|
}
|
|
2766
2743
|
_sceneSummaryParts() {
|
|
2767
2744
|
let e = this.stages.pathTracer, t = this._sdf?.instanceTable?.setCount ?? 0, n = this._sdf?.geometryExtractor?.maps?.length ?? 0;
|
|
@@ -2847,16 +2824,16 @@ var Zn = class extends L {
|
|
|
2847
2824
|
}
|
|
2848
2825
|
_sceneBudgets(e) {
|
|
2849
2826
|
return this._memorySpill === !1 || !this.storage ? e : {
|
|
2850
|
-
maxTriangles:
|
|
2827
|
+
maxTriangles: oe,
|
|
2851
2828
|
maxPlacements: me,
|
|
2852
2829
|
...e
|
|
2853
2830
|
};
|
|
2854
2831
|
}
|
|
2855
2832
|
_planSpill() {
|
|
2856
2833
|
let e = this._memorySpill !== !1 && !!this.storage && (this.assetLoader?.animations?.length ?? 0) === 0 && (this._memorySpill === !0 || this._sdf.needsSpill(this.meshScene));
|
|
2857
|
-
this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ?
|
|
2834
|
+
this.assetLoader && (this.assetLoader.maxEnvironmentWidth = e ? le : 0);
|
|
2858
2835
|
let t = e ? this.meshScene?.environment : null, n = t?.image;
|
|
2859
|
-
return n &&
|
|
2836
|
+
return n && wn(t, le), t && t.image !== n && (t.dispose(), t.needsUpdate = !0), e && this._memorySpill === "auto" && $.info("scene is past the in-memory line: building it through disk"), this._spillPlan = e, e;
|
|
2860
2837
|
}
|
|
2861
2838
|
_progressiveSpill() {
|
|
2862
2839
|
let e = this._spillPlan ?? this._planSpill();
|
|
@@ -2878,7 +2855,7 @@ var Zn = class extends L {
|
|
|
2878
2855
|
_scheduleRespill() {
|
|
2879
2856
|
this._sdf?.spilling && (clearTimeout(this._respillTimer), this._respillTimer = setTimeout(() => {
|
|
2880
2857
|
this._respillTimer = null, this._sdf?.respill().catch((e) => this._issues.warn(C.STORAGE_WRITE_FAILED, `memory spill failed: ${e.message}`));
|
|
2881
|
-
},
|
|
2858
|
+
}, Nn), this._respillTimer.unref?.());
|
|
2882
2859
|
}
|
|
2883
2860
|
async ensureSceneResident() {
|
|
2884
2861
|
this._sdf?.spilled && await this._sdf.ensureResident(), await this._sdf?.ensureGeometryResident();
|
|
@@ -2913,34 +2890,34 @@ var Zn = class extends L {
|
|
|
2913
2890
|
return this.stages.pathTracer.updateBufferRanges([], this._sdf.takeMoveRanges()), this.reset(!1, { motion: !0 }), this._scheduleRespill(), t;
|
|
2914
2891
|
}
|
|
2915
2892
|
setReservedRenderResolution(e, { allowLower: t = !1 } = {}) {
|
|
2916
|
-
let
|
|
2893
|
+
let n = t ? e : Math.max(e, l);
|
|
2917
2894
|
if (!this.renderer) return this._pendingReservedRenderSize = {
|
|
2918
2895
|
requestedPx: e,
|
|
2919
2896
|
allowLower: t
|
|
2920
|
-
}, Math.max(256, Math.min(r, Math.floor(
|
|
2921
|
-
let
|
|
2922
|
-
if (
|
|
2897
|
+
}, Math.max(256, Math.min(r, Math.floor(n) || 256));
|
|
2898
|
+
let i = this.renderer.backend?.device?.limits?.maxStorageBufferBindingSize || 128 * 1024 * 1024, a = ce(this._hostMemoryGB), o = a.gb >= 8 && i >= 1024 * 1024 * 1024 ? r : 2048, s = c(Math.min(n, o));
|
|
2899
|
+
if (s < Math.floor(e) && this._issues.warn(C.RENDER_RESERVE_CAPPED, `reserved render size ${x.n(e)}px was capped to ${x.n(s)}px by this device's limits — renders above ${x.n(s)}px will be declined` + (a.assumed && a.gb < 8 ? " (host memory unknown, 4 GB assumed: pass hostMemoryGB)" : ""), {
|
|
2923
2900
|
requested: e,
|
|
2924
|
-
applied:
|
|
2925
|
-
deviceMemoryGB:
|
|
2926
|
-
assumed:
|
|
2927
|
-
maxStorageBufferBindingSize:
|
|
2928
|
-
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ??
|
|
2901
|
+
applied: s,
|
|
2902
|
+
deviceMemoryGB: a.gb,
|
|
2903
|
+
assumed: a.assumed,
|
|
2904
|
+
maxStorageBufferBindingSize: i
|
|
2905
|
+
}), (this.stages?.pathTracer?.storageTextures?.writeColor?.image?.width ?? s) !== s) {
|
|
2929
2906
|
let e = this.pauseRendering;
|
|
2930
2907
|
this.pauseRendering = !0;
|
|
2931
2908
|
try {
|
|
2932
2909
|
let e = this.renderer.domElement;
|
|
2933
|
-
(e.width >
|
|
2910
|
+
(e.width > s || e.height > s) && this.renderer.setSize(Math.min(e.width, s), Math.min(e.height, s), !1);
|
|
2934
2911
|
for (let e of Object.values(this.stages)) e?.reallocateReservedStorage?.();
|
|
2935
2912
|
} finally {
|
|
2936
2913
|
this.pauseRendering = e;
|
|
2937
2914
|
}
|
|
2938
2915
|
this.reset(), this.dispatchEvent({
|
|
2939
2916
|
type: g.RESERVED_RENDER_SIZE_CHANGED,
|
|
2940
|
-
size:
|
|
2917
|
+
size: s
|
|
2941
2918
|
});
|
|
2942
2919
|
}
|
|
2943
|
-
return
|
|
2920
|
+
return s;
|
|
2944
2921
|
}
|
|
2945
2922
|
_applyPendingReservedRenderSize() {
|
|
2946
2923
|
let e = this._pendingReservedRenderSize;
|
|
@@ -2953,13 +2930,13 @@ var Zn = class extends L {
|
|
|
2953
2930
|
});
|
|
2954
2931
|
}
|
|
2955
2932
|
getReservedRenderResolution() {
|
|
2956
|
-
return
|
|
2933
|
+
return l;
|
|
2957
2934
|
}
|
|
2958
2935
|
_isRenderSizeSupported(e, t) {
|
|
2959
|
-
return e >
|
|
2936
|
+
return e > l || t > l ? (this._issues.record(C.RENDER_SIZE_DECLINED, `render resolution ${e}×${t} exceeds the ${l}px storage reserve — resize ignored, so output stays at the previous size. Raise it with setReservedRenderResolution( ${Math.max(e, t)} ) before init().`, {
|
|
2960
2937
|
width: e,
|
|
2961
2938
|
height: t,
|
|
2962
|
-
reserve:
|
|
2939
|
+
reserve: l
|
|
2963
2940
|
}), !1) : !0;
|
|
2964
2941
|
}
|
|
2965
2942
|
onResize() {
|
|
@@ -3111,7 +3088,7 @@ var Zn = class extends L {
|
|
|
3111
3088
|
let e = this.stages.pathTracer, t = this.color?.status();
|
|
3112
3089
|
return m({
|
|
3113
3090
|
engine: de,
|
|
3114
|
-
three:
|
|
3091
|
+
three: xt,
|
|
3115
3092
|
adapter: this.adapterInfo ?? null,
|
|
3116
3093
|
mode: {
|
|
3117
3094
|
headless: this._headless,
|
|
@@ -3172,50 +3149,55 @@ var Zn = class extends L {
|
|
|
3172
3149
|
if (e !== "linear" && e !== "srgb" && !this.color?.hasConfig) throw Error(`renderToBuffer: colorSpace must be 'linear' or 'srgb' without a colour config loaded, got "${e}"`);
|
|
3173
3150
|
let r = this.stages?.pathTracer, i = r?.storageTextures?.readTarget;
|
|
3174
3151
|
if (!i) throw Error("renderToBuffer: no render target — call init() and render at least one sample");
|
|
3175
|
-
let { width: a, height:
|
|
3152
|
+
let { width: a, height: c } = r, l = !!this.settings.get("transparentBackground");
|
|
3176
3153
|
if (e === "srgb") {
|
|
3177
|
-
let r = n === "display" ? this._displaySource(i) : null,
|
|
3154
|
+
let r = n === "display" ? this._displaySource(i) : null, u = {
|
|
3178
3155
|
exposure: this.renderer.toneMappingExposure,
|
|
3179
3156
|
toneMapping: this.renderer.toneMapping,
|
|
3180
3157
|
saturation: this.settings.get("saturation") ?? 1,
|
|
3181
|
-
preserveAlpha: t,
|
|
3158
|
+
preserveAlpha: t && l,
|
|
3182
3159
|
gain: this._displayGain()
|
|
3183
|
-
},
|
|
3160
|
+
}, d = await this._toneMapOnGPU(r?.texture ?? null, i, a, c, u), f = !d && u.gain?.cpu ? await u.gain.cpu() : null, p = u.gain?.backdrop ?? 0;
|
|
3184
3161
|
return {
|
|
3185
|
-
data:
|
|
3186
|
-
...
|
|
3187
|
-
pixelGain:
|
|
3188
|
-
fn:
|
|
3162
|
+
data: d ?? o(r ? await this._readTexture(r.texture, a, c) : await s(this.renderer, i, a, c), {
|
|
3163
|
+
...u,
|
|
3164
|
+
pixelGain: f || p ? {
|
|
3165
|
+
fn: f,
|
|
3189
3166
|
width: a,
|
|
3190
|
-
height:
|
|
3191
|
-
|
|
3167
|
+
height: c,
|
|
3168
|
+
backdrop: p
|
|
3169
|
+
} : null
|
|
3192
3170
|
}),
|
|
3193
3171
|
width: a,
|
|
3194
|
-
height:
|
|
3172
|
+
height: c,
|
|
3195
3173
|
colorSpace: e,
|
|
3196
3174
|
source: r?.source ?? "accumulation",
|
|
3197
|
-
toneMappedOn:
|
|
3175
|
+
toneMappedOn: d ? "gpu" : "cpu"
|
|
3198
3176
|
};
|
|
3199
3177
|
}
|
|
3200
|
-
let { data:
|
|
3201
|
-
data: await
|
|
3178
|
+
let { data: u, source: d } = n === "display" ? await this._readDisplaySource(i, a, c) : {
|
|
3179
|
+
data: await s(this.renderer, i, a, c),
|
|
3202
3180
|
source: "accumulation"
|
|
3203
3181
|
};
|
|
3182
|
+
if (!l) {
|
|
3183
|
+
let e = u instanceof Uint16Array ? 15360 : 1;
|
|
3184
|
+
for (let t = 3; t < u.length; t += 4) u[t] = e;
|
|
3185
|
+
}
|
|
3204
3186
|
if (e === "linear") return {
|
|
3205
|
-
data:
|
|
3187
|
+
data: u,
|
|
3206
3188
|
width: a,
|
|
3207
|
-
height:
|
|
3189
|
+
height: c,
|
|
3208
3190
|
colorSpace: e,
|
|
3209
3191
|
workingSpace: this.color?.workingSpace ?? null,
|
|
3210
|
-
source:
|
|
3192
|
+
source: d
|
|
3211
3193
|
};
|
|
3212
|
-
let { rgba:
|
|
3194
|
+
let { rgba: f, colorSpace: p } = this.color.exportPixels(u, e);
|
|
3213
3195
|
return {
|
|
3214
|
-
data:
|
|
3196
|
+
data: f,
|
|
3215
3197
|
width: a,
|
|
3216
|
-
height:
|
|
3217
|
-
colorSpace:
|
|
3218
|
-
source:
|
|
3198
|
+
height: c,
|
|
3199
|
+
colorSpace: p,
|
|
3200
|
+
source: d
|
|
3219
3201
|
};
|
|
3220
3202
|
}
|
|
3221
3203
|
async _toneMapOnGPU(e, t, n, r, i) {
|
|
@@ -3223,9 +3205,9 @@ var Zn = class extends L {
|
|
|
3223
3205
|
if (!a?.device) return this._toneMapFallback("the renderer has no WebGPU device");
|
|
3224
3206
|
try {
|
|
3225
3207
|
let o = e ? this._readbackPass().draw(e, n, r).texture : t.textures[0], s = a.get(o).texture;
|
|
3226
|
-
return s ? (this._readbackToneMapper ??= new
|
|
3208
|
+
return s ? (this._readbackToneMapper ??= new ze(a.device, "rayzee:readback-tonemap", { input: "texture" }), this._readbackToneMapper.ensureSize(n, r), await this._readbackToneMapper.toRGBA8(s, i)) : this._toneMapFallback("the picture has no GPU texture yet");
|
|
3227
3209
|
} catch (e) {
|
|
3228
|
-
if (e instanceof
|
|
3210
|
+
if (e instanceof be) throw e;
|
|
3229
3211
|
return this._toneMapFallback("the GPU pass threw", e);
|
|
3230
3212
|
} finally {
|
|
3231
3213
|
this._readbackToneMapper?.release(), e && this._textureReadback?.release();
|
|
@@ -3363,7 +3345,7 @@ var Zn = class extends L {
|
|
|
3363
3345
|
}
|
|
3364
3346
|
getSceneMinY() {
|
|
3365
3347
|
if (!this.meshScene) return 0;
|
|
3366
|
-
let e = new
|
|
3348
|
+
let e = new nt().setFromObject(this.meshScene);
|
|
3367
3349
|
return Number.isFinite(e.min.y) ? e.min.y : 0;
|
|
3368
3350
|
}
|
|
3369
3351
|
getMaterialProperty(e, t) {
|
|
@@ -3373,7 +3355,7 @@ var Zn = class extends L {
|
|
|
3373
3355
|
return this.stages.pathTracer?.materialData.getMaterialPropertySource(e, t);
|
|
3374
3356
|
}
|
|
3375
3357
|
setMaterialProperty(e, t, n) {
|
|
3376
|
-
if (this._sdf?.spilled &&
|
|
3358
|
+
if (this._sdf?.spilled && ee.has(t)) {
|
|
3377
3359
|
this.ensureSceneResident().then(() => this.setMaterialProperty(e, t, n));
|
|
3378
3360
|
return;
|
|
3379
3361
|
}
|
|
@@ -3436,12 +3418,12 @@ var Zn = class extends L {
|
|
|
3436
3418
|
data: await this._readTexture(r.texture, t, n),
|
|
3437
3419
|
source: r.source
|
|
3438
3420
|
} : {
|
|
3439
|
-
data: await
|
|
3421
|
+
data: await s(this.renderer, e, t, n),
|
|
3440
3422
|
source: "accumulation"
|
|
3441
3423
|
};
|
|
3442
3424
|
}
|
|
3443
3425
|
_readbackPass() {
|
|
3444
|
-
return this._textureReadback ??= new
|
|
3426
|
+
return this._textureReadback ??= new f(this.renderer);
|
|
3445
3427
|
}
|
|
3446
3428
|
_readTexture(e, t, n) {
|
|
3447
3429
|
return this._readbackPass().read(e, t, n);
|
|
@@ -3452,10 +3434,10 @@ var Zn = class extends L {
|
|
|
3452
3434
|
n.__rayzeeOriginalColorSpace === void 0 && (n.__rayzeeOriginalColorSpace = e.colorSpace);
|
|
3453
3435
|
let r = n.__rayzeeOriginalColorSpace;
|
|
3454
3436
|
if (delete n.ocioColorSpace, delete n.__rayzeeColorSpaceChoice, t == null) e.colorSpace = r, delete n.__rayzeeOriginalColorSpace;
|
|
3455
|
-
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ?
|
|
3437
|
+
else if (t === "srgb" || t === "linear") e.colorSpace = t === "srgb" ? We : Be, n.__rayzeeColorSpaceChoice = t;
|
|
3456
3438
|
else {
|
|
3457
3439
|
if (!this.color?.hasConfig) throw Error(`"${t}" needs a colour config loaded`);
|
|
3458
|
-
n.ocioColorSpace = t, e.colorSpace =
|
|
3440
|
+
n.ocioColorSpace = t, e.colorSpace = We;
|
|
3459
3441
|
}
|
|
3460
3442
|
e.needsUpdate = !0, this.stages.pathTracer?.sdfs && await this.rebuildMaterials();
|
|
3461
3443
|
}
|
|
@@ -3485,14 +3467,18 @@ var Zn = class extends L {
|
|
|
3485
3467
|
async rebuildMaterials(e) {
|
|
3486
3468
|
await this.ensureSceneResident();
|
|
3487
3469
|
let t = this.stages.pathTracer;
|
|
3488
|
-
await t?.rebuildMaterials(e || this.meshScene), t?.triangleStorageNode?.withoutUV && this._sdf?.triangles &&
|
|
3470
|
+
await t?.rebuildMaterials(e || this.meshScene), t?.triangleStorageNode?.withoutUV && this._sdf?.triangles && re(e || this.meshScene) && (this._sdf.textureCoordinates = !0, t.setTriangleData(this._sdf.triangles, this._sdf.triangleCount, { textureCoordinates: !0 }), t.setupMaterial()), this.reset();
|
|
3489
3471
|
}
|
|
3490
3472
|
async _initRenderer() {
|
|
3491
|
-
|
|
3492
|
-
let e =
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3473
|
+
fe((e) => this.dispatchEvent(e)), (typeof navigator > "u" || !navigator.gpu) && this._issues.fail(C.WEBGPU_UNAVAILABLE, "WebGPU is not available — outside a browser, install one as navigator.gpu (for Node, the `webgpu` package)");
|
|
3474
|
+
let e = null, t;
|
|
3475
|
+
try {
|
|
3476
|
+
e = await navigator.gpu.requestAdapter({ powerPreference: "high-performance" });
|
|
3477
|
+
} catch (e) {
|
|
3478
|
+
t = e;
|
|
3479
|
+
}
|
|
3480
|
+
e || this._issues.fail(C.ADAPTER_UNAVAILABLE, `no WebGPU adapter${t ? ": " + t.message : ""}`, {}, t), this.adapterInfo = Vn(e), this.adapterInfo.isSoftware && (this._issues.warn(C.ADAPTER_SOFTWARE, `software GPU adapter "${this.adapterInfo.description || this.adapterInfo.vendor}" — renders are correct but orders of magnitude slower than hardware`, { ...this.adapterInfo }), $.warn(`software GPU adapter — check app.adapterInfo.isSoftware. ${this.adapterInfo.description}`));
|
|
3481
|
+
let n = e.limits, r = { maxColorAttachmentBytesPerSample: 128 };
|
|
3496
3482
|
for (let e of [
|
|
3497
3483
|
"maxBufferSize",
|
|
3498
3484
|
"maxStorageBufferBindingSize",
|
|
@@ -3506,26 +3492,39 @@ var Zn = class extends L {
|
|
|
3506
3492
|
"maxComputeWorkgroupSizeY",
|
|
3507
3493
|
"maxComputeWorkgroupSizeZ"
|
|
3508
3494
|
]) {
|
|
3509
|
-
let
|
|
3510
|
-
|
|
3495
|
+
let t = n[e];
|
|
3496
|
+
t !== void 0 && (r[e] = t);
|
|
3511
3497
|
}
|
|
3512
|
-
|
|
3498
|
+
r.maxStorageBuffersPerShaderStage = Math.min(n.maxStorageBuffersPerShaderStage, 10);
|
|
3499
|
+
let i;
|
|
3500
|
+
try {
|
|
3501
|
+
i = await e.requestDevice({
|
|
3502
|
+
requiredFeatures: zn.filter((t) => e.features.has(t)),
|
|
3503
|
+
requiredLimits: r
|
|
3504
|
+
});
|
|
3505
|
+
} catch (e) {
|
|
3506
|
+
this._issues.fail(C.DEVICE_UNAVAILABLE, `WebGPU device request failed: ${e.message}`, { adapter: { ...this.adapterInfo } }, e);
|
|
3507
|
+
}
|
|
3508
|
+
this.renderer = new Ke({
|
|
3513
3509
|
canvas: this.canvas,
|
|
3514
3510
|
alpha: !0,
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3511
|
+
device: i
|
|
3512
|
+
});
|
|
3513
|
+
try {
|
|
3514
|
+
await In(this.renderer, this._headless);
|
|
3515
|
+
} catch (e) {
|
|
3516
|
+
throw i.destroy(), e;
|
|
3517
|
+
}
|
|
3518
|
+
this.renderer.backend?.isWebGPUBackend || (i.destroy(), this._issues.fail(C.WEBGPU_UNAVAILABLE, "three.js fell back to WebGL2, which cannot run the path tracer's compute kernels. Check GPU process flags and driver support.")), this._gpuDevice = i, i.lost && (this._deviceLostHolder = { app: this }, Rn(i, this._deviceLostHolder), i.onuncapturederror = (e) => $.error("WebGPU uncaptured error:", e.error)), Ue.setLTC(Et.init()), this.renderer.outputColorSpace = We, this.renderer.toneMapping = Ae, this.renderer.toneMappingExposure = 1, this.renderer.setPixelRatio(1), this.color.attachRenderer(this.renderer);
|
|
3520
3519
|
}
|
|
3521
3520
|
_initScenes() {
|
|
3522
|
-
this.scene = new
|
|
3521
|
+
this.scene = new H(), this.meshScene = new H(), this._sceneHelpers = new Mt();
|
|
3523
3522
|
}
|
|
3524
3523
|
_initAssetPipeline() {
|
|
3525
|
-
this._sdf = new
|
|
3524
|
+
this._sdf = new u({
|
|
3526
3525
|
issues: this._issues,
|
|
3527
3526
|
...this._maxSceneBytes === void 0 ? {} : { maxSceneBytes: this._maxSceneBytes }
|
|
3528
|
-
}), this.assetLoader = new
|
|
3527
|
+
}), this.assetLoader = new Cn(this.meshScene, this.camera, null, {
|
|
3529
3528
|
issues: this._issues,
|
|
3530
3529
|
areaLightIntensityScale: () => this.settings.get("areaLightIntensityScale")
|
|
3531
3530
|
}), this.assetLoader.setRenderer(this.renderer), this.assetLoader.createFloorPlane();
|
|
@@ -3540,7 +3539,7 @@ var Zn = class extends L {
|
|
|
3540
3539
|
this._displayWidth = n, this._displayHeight = r, this._renderWidth = n, this._renderHeight = r, this.pipeline.setSize(n, r);
|
|
3541
3540
|
}
|
|
3542
3541
|
async _initManagers() {
|
|
3543
|
-
this.lightManager = new
|
|
3542
|
+
this.lightManager = new jn(this.scene, this._sceneHelpers, this.stages.pathTracer, {
|
|
3544
3543
|
onReset: () => this.reset(),
|
|
3545
3544
|
onLightRemoved: (e) => this._lightRemoved(e)
|
|
3546
3545
|
}), this.environmentManager = this.stages.pathTracer.environment, this.environmentManager.issues = this._issues, this.stages.pathTracer.issues = this._issues, this.environmentManager.callbacks.onLightingChanged = () => this.pipeline.eventBus.emit("pipeline:lightingChanged"), this.environmentManager.callbacks.onReset = () => this.reset();
|
|
@@ -3551,7 +3550,7 @@ var Zn = class extends L {
|
|
|
3551
3550
|
if (e.model) this._clearAppendedModels(), await this.loadSceneData({ pendingEnvironment: this._beginSceneMetadataEnvironment() });
|
|
3552
3551
|
else if (e.texture) {
|
|
3553
3552
|
let e = this.meshScene.environment;
|
|
3554
|
-
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e),
|
|
3553
|
+
e && this.stages.pathTracer && await this.stages.pathTracer.environment.setEnvironmentMap(e), b();
|
|
3555
3554
|
}
|
|
3556
3555
|
this.pauseRendering = !1, this.reset();
|
|
3557
3556
|
}
|
|
@@ -3561,10 +3560,10 @@ var Zn = class extends L {
|
|
|
3561
3560
|
}));
|
|
3562
3561
|
}
|
|
3563
3562
|
_createStages() {
|
|
3564
|
-
this.stages.pathTracer = new
|
|
3563
|
+
this.stages.pathTracer = new d(this.renderer, this.scene, this.camera, {
|
|
3565
3564
|
hostMemoryGB: this._hostMemoryGB,
|
|
3566
3565
|
sortMaterials: this.settings.get("wavefrontSortMaterials")
|
|
3567
|
-
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new
|
|
3566
|
+
}), this._extraStages = this._createExtraStages(), this.stages.compositor = new Nt(this.renderer, {
|
|
3568
3567
|
saturation: this.settings.get("saturation") ?? _.saturation,
|
|
3569
3568
|
pathTracer: this.stages.pathTracer,
|
|
3570
3569
|
displaySources: this._displaySources()
|
|
@@ -3580,7 +3579,7 @@ var Zn = class extends L {
|
|
|
3580
3579
|
if (e) for (let n of t) this._addTrackedListener(e, n, (e) => this.dispatchEvent(e));
|
|
3581
3580
|
}
|
|
3582
3581
|
_createCamera() {
|
|
3583
|
-
let e = new
|
|
3582
|
+
let e = new On(60, this.canvas.clientWidth / this.canvas.clientHeight || 1, .01, 1e3);
|
|
3584
3583
|
return e.position.set(0, 0, 5), e;
|
|
3585
3584
|
}
|
|
3586
3585
|
_createExtraStages() {
|
|
@@ -3650,4 +3649,4 @@ var Zn = class extends L {
|
|
|
3650
3649
|
_disposeExtensions() {}
|
|
3651
3650
|
};
|
|
3652
3651
|
//#endregion
|
|
3653
|
-
export {
|
|
3652
|
+
export { Pt as _, an as a, J as c, q as d, tn as f, Rt as g, zt as h, On as i, nn as l, Bt as m, Vn as n, Y as o, Gt as p, jn as r, G as s, Hn as t, en as u };
|