softbox 4.7.0 → 4.9.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/dist/CopyShader-DPSZNOxL.cjs +24 -0
- package/dist/CopyShader-DVL8Bcar.js +41 -0
- package/dist/EffectComposer-BdHnHszK.js +188 -0
- package/dist/EffectComposer-D2IQ0sek.cjs +1 -0
- package/dist/OutputPass-Dy4KNHYF.cjs +72 -0
- package/dist/OutputPass-Tt8WbC_B.js +125 -0
- package/dist/Pass-C1mreNp8.cjs +1 -0
- package/dist/Pass-DOcH4lwV.js +88 -0
- package/dist/RenderPass-B57TYmjs.js +37 -0
- package/dist/RenderPass-BVzyKWsC.cjs +1 -0
- package/dist/ShaderPass-BQRqK8zp.cjs +1 -0
- package/dist/ShaderPass-C2HX8lsT.js +45 -0
- package/dist/{ThreePathTracingService-DbqedkL2.js → ThreePathTracingService-CZdztwad.js} +907 -834
- package/dist/{ThreePathTracingService-CL_k3WTj.cjs → ThreePathTracingService-DnjWVQLR.cjs} +88 -64
- package/dist/UnrealBloomPass-Kx7djcld.cjs +115 -0
- package/dist/UnrealBloomPass-rjyQu37v.js +281 -0
- package/dist/VignetteShader-BG_QwoTp.js +45 -0
- package/dist/VignetteShader-Drpo9YxI.cjs +27 -0
- package/dist/index-BgkyK2Uk.cjs +29 -0
- package/dist/{index-DXbG9xpu.js → index-op1Vhyk7.js} +3731 -3448
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/simple-viewer.cjs +1 -1
- package/dist/simple-viewer.es.js +1 -1
- package/package.json +1 -1
- package/dist/index-BtN2xOzS.cjs +0 -11
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { UnsignedIntType as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import * as _ from "three";
|
|
2
|
+
import { UnsignedIntType as ae, DataTexture as F, NearestFilter as T, IntType as we, FloatType as R, UnsignedByteType as Me, UnsignedShortType as Mt, ByteType as Be, ShortType as At, RGBAFormat as I, RGBAIntegerFormat as Ae, RGIntegerFormat as ft, RedIntegerFormat as Ft, RGFormat as ht, RedFormat as pe, BufferAttribute as O, BufferGeometry as ee, Matrix4 as z, Matrix3 as Ct, Vector3 as P, Vector4 as te, MeshBasicMaterial as Dt, Mesh as Pt, ShaderMaterial as ge, NoBlending as se, WebGLRenderTarget as ie, Vector2 as X, PerspectiveCamera as dt, DataUtils as N, HalfFloatType as E, LinearFilter as D, RepeatWrapping as H, ClampToEdgeWrapping as B, Source as Et, Quaternion as Ot, DataArrayTexture as kt, DoubleSide as Nt, BackSide as zt, FrontSide as Ht, WebGLArrayRenderTarget as Bt, Color as oe, NoToneMapping as Wt, NormalBlending as mt, EquirectangularReflectionMapping as pt, Spherical as Lt, LinearMipMapLinearFilter as Ut, Clock as Gt, Scene as Vt, AdditiveBlending as qt } from "three";
|
|
3
|
+
import { F as Y } from "./Pass-DOcH4lwV.js";
|
|
4
|
+
import { g as $t, a as jt, B as We, I as Yt, C as Xt, O as Qt, S as Kt, b as Zt, L as Jt, c as er, M as tr, T as rr, D as ar, d as ir, P as sr, R as S, e as L, E as U } from "./index-op1Vhyk7.js";
|
|
5
|
+
function or(o) {
|
|
6
|
+
switch (o) {
|
|
6
7
|
case 1:
|
|
7
8
|
return "R";
|
|
8
9
|
case 2:
|
|
@@ -14,22 +15,22 @@ function nr(s) {
|
|
|
14
15
|
}
|
|
15
16
|
throw new Error();
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
switch (
|
|
18
|
+
function nr(o) {
|
|
19
|
+
switch (o) {
|
|
19
20
|
case 1:
|
|
20
|
-
return
|
|
21
|
+
return pe;
|
|
21
22
|
case 2:
|
|
22
|
-
return
|
|
23
|
+
return ht;
|
|
23
24
|
case 3:
|
|
24
25
|
return I;
|
|
25
26
|
case 4:
|
|
26
27
|
return I;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
switch (
|
|
30
|
+
function Le(o) {
|
|
31
|
+
switch (o) {
|
|
31
32
|
case 1:
|
|
32
|
-
return
|
|
33
|
+
return Ft;
|
|
33
34
|
case 2:
|
|
34
35
|
return ft;
|
|
35
36
|
case 3:
|
|
@@ -38,7 +39,7 @@ function Ue(s) {
|
|
|
38
39
|
return Ae;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
class
|
|
42
|
+
class gt extends F {
|
|
42
43
|
constructor() {
|
|
43
44
|
super(), this.minFilter = T, this.magFilter = T, this.generateMipmaps = !1, this.overrideItemSize = null, this._forcedType = null;
|
|
44
45
|
}
|
|
@@ -59,59 +60,59 @@ class xt extends M {
|
|
|
59
60
|
throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");
|
|
60
61
|
e.itemSize = t, e.count = i * r / t;
|
|
61
62
|
}
|
|
62
|
-
const
|
|
63
|
-
let
|
|
64
|
-
if (
|
|
65
|
-
switch (
|
|
63
|
+
const s = e.itemSize, a = e.count, l = e.normalized, u = e.array.constructor, d = u.BYTES_PER_ELEMENT;
|
|
64
|
+
let h = this._forcedType, f = s;
|
|
65
|
+
if (h === null)
|
|
66
|
+
switch (u) {
|
|
66
67
|
case Float32Array:
|
|
67
|
-
|
|
68
|
+
h = R;
|
|
68
69
|
break;
|
|
69
70
|
case Uint8Array:
|
|
70
71
|
case Uint16Array:
|
|
71
72
|
case Uint32Array:
|
|
72
|
-
|
|
73
|
+
h = ae;
|
|
73
74
|
break;
|
|
74
75
|
case Int8Array:
|
|
75
76
|
case Int16Array:
|
|
76
77
|
case Int32Array:
|
|
77
|
-
|
|
78
|
+
h = we;
|
|
78
79
|
break;
|
|
79
80
|
}
|
|
80
|
-
let n, x, m, g, c =
|
|
81
|
-
switch (
|
|
81
|
+
let n, x, m, g, c = or(s);
|
|
82
|
+
switch (h) {
|
|
82
83
|
case R:
|
|
83
|
-
m = 1, x =
|
|
84
|
+
m = 1, x = nr(s), l && d === 1 ? (g = u, c += "8", u === Uint8Array ? n = Me : (n = Be, c += "_SNORM")) : (g = Float32Array, c += "32F", n = R);
|
|
84
85
|
break;
|
|
85
86
|
case we:
|
|
86
|
-
c += d * 8 + "I", m = l ? Math.pow(2,
|
|
87
|
+
c += d * 8 + "I", m = l ? Math.pow(2, u.BYTES_PER_ELEMENT * 8 - 1) : 1, x = Le(s), d === 1 ? (g = Int8Array, n = Be) : d === 2 ? (g = Int16Array, n = At) : (g = Int32Array, n = we);
|
|
87
88
|
break;
|
|
88
|
-
case
|
|
89
|
-
c += d * 8 + "UI", m = l ? Math.pow(2,
|
|
89
|
+
case ae:
|
|
90
|
+
c += d * 8 + "UI", m = l ? Math.pow(2, u.BYTES_PER_ELEMENT * 8 - 1) : 1, x = Le(s), d === 1 ? (g = Uint8Array, n = Me) : d === 2 ? (g = Uint16Array, n = Mt) : (g = Uint32Array, n = ae);
|
|
90
91
|
break;
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
-
const p = Math.ceil(Math.sqrt(a)) || 1, v =
|
|
93
|
+
f === 3 && (x === I || x === Ae) && (f = 4);
|
|
94
|
+
const p = Math.ceil(Math.sqrt(a)) || 1, v = f * p * p, b = new g(v), y = e.normalized;
|
|
94
95
|
e.normalized = !1;
|
|
95
96
|
for (let w = 0; w < a; w++) {
|
|
96
|
-
const
|
|
97
|
-
b[
|
|
97
|
+
const k = f * w;
|
|
98
|
+
b[k] = e.getX(w) / m, s >= 2 && (b[k + 1] = e.getY(w) / m), s >= 3 && (b[k + 2] = e.getZ(w) / m, f === 4 && (b[k + 3] = 1)), s >= 4 && (b[k + 3] = e.getW(w) / m);
|
|
98
99
|
}
|
|
99
100
|
e.normalized = y, this.internalFormat = c, this.format = x, this.type = n, this.image.width = p, this.image.height = p, this.image.data = b, this.needsUpdate = !0, this.dispose(), e.itemSize = r, e.count = i;
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
class
|
|
103
|
+
class vt extends gt {
|
|
103
104
|
constructor() {
|
|
104
|
-
super(), this._forcedType =
|
|
105
|
+
super(), this._forcedType = ae;
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
|
-
class
|
|
108
|
+
class xt extends gt {
|
|
108
109
|
constructor() {
|
|
109
110
|
super(), this._forcedType = R;
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
|
-
class
|
|
113
|
+
class lr {
|
|
113
114
|
constructor() {
|
|
114
|
-
this.index = new
|
|
115
|
+
this.index = new vt(), this.position = new xt(), this.bvhBounds = new F(), this.bvhContents = new F(), this._cachedIndexAttr = null, this.index.overrideItemSize = 3;
|
|
115
116
|
}
|
|
116
117
|
/**
|
|
117
118
|
* Updates the object and associated textures with data from the provided BVH.
|
|
@@ -121,16 +122,16 @@ class cr {
|
|
|
121
122
|
*/
|
|
122
123
|
updateFrom(e) {
|
|
123
124
|
const { geometry: t } = e;
|
|
124
|
-
if (
|
|
125
|
+
if (ur(e, this.bvhBounds, this.bvhContents), this.position.updateFrom(t.attributes.position), e.indirect) {
|
|
125
126
|
const r = e._indirectBuffer;
|
|
126
127
|
if (this._cachedIndexAttr === null || this._cachedIndexAttr.count !== r.length)
|
|
127
128
|
if (t.index)
|
|
128
129
|
this._cachedIndexAttr = t.index.clone();
|
|
129
130
|
else {
|
|
130
|
-
const i =
|
|
131
|
-
this._cachedIndexAttr = new
|
|
131
|
+
const i = $t(jt(t));
|
|
132
|
+
this._cachedIndexAttr = new O(i, 1, !1);
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
+
cr(t, r, this._cachedIndexAttr), this.index.updateFrom(this._cachedIndexAttr);
|
|
134
135
|
} else
|
|
135
136
|
this.index.updateFrom(t.index);
|
|
136
137
|
}
|
|
@@ -144,32 +145,32 @@ class cr {
|
|
|
144
145
|
e && e.dispose(), t && t.dispose(), r && r.dispose(), i && i.dispose();
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
|
-
function
|
|
148
|
-
const r = t.array, i =
|
|
149
|
-
for (let
|
|
150
|
-
const l = 3 *
|
|
148
|
+
function cr(o, e, t) {
|
|
149
|
+
const r = t.array, i = o.index ? o.index.array : null;
|
|
150
|
+
for (let s = 0, a = e.length; s < a; s++) {
|
|
151
|
+
const l = 3 * s, u = 3 * e[s];
|
|
151
152
|
for (let d = 0; d < 3; d++)
|
|
152
|
-
r[l + d] = i ? i[
|
|
153
|
+
r[l + d] = i ? i[u + d] : u + d;
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
-
const r =
|
|
156
|
+
function ur(o, e, t) {
|
|
157
|
+
const r = o._roots;
|
|
157
158
|
if (r.length !== 1)
|
|
158
159
|
throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");
|
|
159
|
-
const i = r[0],
|
|
160
|
-
for (let x = 0; x <
|
|
161
|
-
const m = x *
|
|
160
|
+
const i = r[0], s = new Uint16Array(i), a = new Uint32Array(i), l = new Float32Array(i), u = i.byteLength / We, d = 2 * Math.ceil(Math.sqrt(u / 2)), h = new Float32Array(4 * d * d), f = Math.ceil(Math.sqrt(u)), n = new Uint32Array(2 * f * f);
|
|
161
|
+
for (let x = 0; x < u; x++) {
|
|
162
|
+
const m = x * We / 4, g = m * 2, c = Zt(m);
|
|
162
163
|
for (let p = 0; p < 3; p++)
|
|
163
|
-
|
|
164
|
-
if (
|
|
165
|
-
const p =
|
|
164
|
+
h[8 * x + 0 + p] = l[c + 0 + p], h[8 * x + 4 + p] = l[c + 3 + p];
|
|
165
|
+
if (Yt(g, s)) {
|
|
166
|
+
const p = Xt(g, s), v = Qt(m, a), b = Jt | p;
|
|
166
167
|
n[x * 2 + 0] = b, n[x * 2 + 1] = v;
|
|
167
168
|
} else {
|
|
168
|
-
const p = a[m + 6], v =
|
|
169
|
+
const p = a[m + 6], v = Kt(m, a);
|
|
169
170
|
n[x * 2 + 0] = v, n[x * 2 + 1] = p;
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
|
-
e.image.data =
|
|
173
|
+
e.image.data = h, e.image.width = d, e.image.height = d, e.format = I, e.type = R, e.internalFormat = "RGBA32F", e.minFilter = T, e.magFilter = T, e.generateMipmaps = !1, e.needsUpdate = !0, e.dispose(), t.image.data = n, t.image.width = f, t.image.height = f, t.format = ft, t.type = ae, t.internalFormat = "RG32UI", t.minFilter = T, t.magFilter = T, t.generateMipmaps = !1, t.needsUpdate = !0, t.dispose();
|
|
173
174
|
}
|
|
174
175
|
const fr = (
|
|
175
176
|
/* glsl */
|
|
@@ -256,7 +257,7 @@ void ndcToCameraRay(
|
|
|
256
257
|
|
|
257
258
|
}
|
|
258
259
|
`
|
|
259
|
-
),
|
|
260
|
+
), hr = (
|
|
260
261
|
/* glsl */
|
|
261
262
|
`
|
|
262
263
|
|
|
@@ -463,7 +464,7 @@ bool _bvhIntersectFirstHit(
|
|
|
463
464
|
|
|
464
465
|
}
|
|
465
466
|
`
|
|
466
|
-
),
|
|
467
|
+
), dr = (
|
|
467
468
|
/* glsl */
|
|
468
469
|
`
|
|
469
470
|
struct BVH {
|
|
@@ -477,306 +478,306 @@ struct BVH {
|
|
|
477
478
|
};
|
|
478
479
|
`
|
|
479
480
|
);
|
|
480
|
-
function
|
|
481
|
-
if (
|
|
482
|
-
const r =
|
|
483
|
-
for (let i = 0,
|
|
481
|
+
function bt(o, e, t = 0) {
|
|
482
|
+
if (o.isInterleavedBufferAttribute) {
|
|
483
|
+
const r = o.itemSize;
|
|
484
|
+
for (let i = 0, s = o.count; i < s; i++) {
|
|
484
485
|
const a = i + t;
|
|
485
|
-
e.setX(a,
|
|
486
|
+
e.setX(a, o.getX(i)), r >= 2 && e.setY(a, o.getY(i)), r >= 3 && e.setZ(a, o.getZ(i)), r >= 4 && e.setW(a, o.getW(i));
|
|
486
487
|
}
|
|
487
488
|
} else {
|
|
488
|
-
const r = e.array, i = r.constructor,
|
|
489
|
-
new i(r.buffer,
|
|
489
|
+
const r = e.array, i = r.constructor, s = r.BYTES_PER_ELEMENT * o.itemSize * t;
|
|
490
|
+
new i(r.buffer, s, o.array.length).set(o.array);
|
|
490
491
|
}
|
|
491
492
|
}
|
|
492
|
-
function
|
|
493
|
-
const t =
|
|
494
|
-
return new
|
|
493
|
+
function re(o, e = null) {
|
|
494
|
+
const t = o.array.constructor, r = o.normalized, i = o.itemSize, s = e === null ? o.count : e;
|
|
495
|
+
return new O(new t(i * s), i, r);
|
|
495
496
|
}
|
|
496
|
-
function
|
|
497
|
-
if (!
|
|
497
|
+
function J(o, e) {
|
|
498
|
+
if (!o && !e)
|
|
498
499
|
return !0;
|
|
499
|
-
if (!!
|
|
500
|
+
if (!!o != !!e)
|
|
500
501
|
return !1;
|
|
501
|
-
const t =
|
|
502
|
-
return !(!t || !r || !i || !
|
|
502
|
+
const t = o.count === e.count, r = o.normalized === e.normalized, i = o.array.constructor === e.array.constructor, s = o.itemSize === e.itemSize;
|
|
503
|
+
return !(!t || !r || !i || !s);
|
|
503
504
|
}
|
|
504
|
-
function
|
|
505
|
-
const e =
|
|
506
|
-
if (!
|
|
505
|
+
function mr(o) {
|
|
506
|
+
const e = o[0].index !== null, t = new Set(Object.keys(o[0].attributes));
|
|
507
|
+
if (!o[0].getAttribute("position"))
|
|
507
508
|
throw new Error("StaticGeometryGenerator: position attribute is required.");
|
|
508
|
-
for (let r = 0; r <
|
|
509
|
-
const i =
|
|
510
|
-
let
|
|
509
|
+
for (let r = 0; r < o.length; ++r) {
|
|
510
|
+
const i = o[r];
|
|
511
|
+
let s = 0;
|
|
511
512
|
if (e !== (i.index !== null))
|
|
512
513
|
throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");
|
|
513
514
|
for (const a in i.attributes) {
|
|
514
515
|
if (!t.has(a))
|
|
515
516
|
throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "' + a + '" attribute exists among all geometries, or in none of them.');
|
|
516
|
-
|
|
517
|
+
s++;
|
|
517
518
|
}
|
|
518
|
-
if (
|
|
519
|
+
if (s !== t.size)
|
|
519
520
|
throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.");
|
|
520
521
|
}
|
|
521
522
|
}
|
|
522
|
-
function
|
|
523
|
+
function pr(o) {
|
|
523
524
|
let e = 0;
|
|
524
|
-
for (let t = 0, r =
|
|
525
|
-
e +=
|
|
525
|
+
for (let t = 0, r = o.length; t < r; t++)
|
|
526
|
+
e += o[t].getIndex().count;
|
|
526
527
|
return e;
|
|
527
528
|
}
|
|
528
|
-
function
|
|
529
|
+
function gr(o) {
|
|
529
530
|
let e = 0;
|
|
530
|
-
for (let t = 0, r =
|
|
531
|
-
e +=
|
|
531
|
+
for (let t = 0, r = o.length; t < r; t++)
|
|
532
|
+
e += o[t].getAttribute("position").count;
|
|
532
533
|
return e;
|
|
533
534
|
}
|
|
534
|
-
function
|
|
535
|
-
|
|
536
|
-
const r =
|
|
535
|
+
function vr(o, e, t) {
|
|
536
|
+
o.index && o.index.count !== e && o.setIndex(null);
|
|
537
|
+
const r = o.attributes;
|
|
537
538
|
for (const i in r)
|
|
538
|
-
r[i].count !== t &&
|
|
539
|
+
r[i].count !== t && o.deleteAttribute(i);
|
|
539
540
|
}
|
|
540
|
-
function
|
|
541
|
+
function xr(o, e = {}, t = new ee()) {
|
|
541
542
|
const {
|
|
542
543
|
useGroups: r = !1,
|
|
543
544
|
forceUpdate: i = !1,
|
|
544
|
-
skipAssigningAttributes:
|
|
545
|
+
skipAssigningAttributes: s = [],
|
|
545
546
|
overwriteIndex: a = !0
|
|
546
547
|
} = e;
|
|
547
|
-
|
|
548
|
-
const l =
|
|
549
|
-
if (
|
|
550
|
-
let
|
|
551
|
-
for (let n = 0, x =
|
|
552
|
-
const m =
|
|
548
|
+
mr(o);
|
|
549
|
+
const l = o[0].index !== null, u = l ? pr(o) : -1, d = gr(o);
|
|
550
|
+
if (vr(t, u, d), r) {
|
|
551
|
+
let f = 0;
|
|
552
|
+
for (let n = 0, x = o.length; n < x; n++) {
|
|
553
|
+
const m = o[n];
|
|
553
554
|
let g;
|
|
554
|
-
l ? g = m.getIndex().count : g = m.getAttribute("position").count, t.addGroup(
|
|
555
|
+
l ? g = m.getIndex().count : g = m.getAttribute("position").count, t.addGroup(f, g, n), f += g;
|
|
555
556
|
}
|
|
556
557
|
}
|
|
557
558
|
if (l) {
|
|
558
|
-
let
|
|
559
|
-
if (t.index || (t.setIndex(new
|
|
559
|
+
let f = !1;
|
|
560
|
+
if (t.index || (t.setIndex(new O(new Uint32Array(u), 1, !1)), f = !0), f || a) {
|
|
560
561
|
let n = 0, x = 0;
|
|
561
562
|
const m = t.getIndex();
|
|
562
|
-
for (let g = 0, c =
|
|
563
|
-
const p =
|
|
564
|
-
if (!(!i && !
|
|
563
|
+
for (let g = 0, c = o.length; g < c; g++) {
|
|
564
|
+
const p = o[g], v = p.getIndex();
|
|
565
|
+
if (!(!i && !f && s[g]))
|
|
565
566
|
for (let y = 0; y < v.count; ++y)
|
|
566
567
|
m.setX(n + y, v.getX(y) + x);
|
|
567
568
|
n += v.count, x += p.getAttribute("position").count;
|
|
568
569
|
}
|
|
569
570
|
}
|
|
570
571
|
}
|
|
571
|
-
const
|
|
572
|
-
for (let
|
|
572
|
+
const h = Object.keys(o[0].attributes);
|
|
573
|
+
for (let f = 0, n = h.length; f < n; f++) {
|
|
573
574
|
let x = !1;
|
|
574
|
-
const m = f
|
|
575
|
+
const m = h[f];
|
|
575
576
|
if (!t.getAttribute(m)) {
|
|
576
|
-
const p =
|
|
577
|
-
t.setAttribute(m,
|
|
577
|
+
const p = o[0].getAttribute(m);
|
|
578
|
+
t.setAttribute(m, re(p, d)), x = !0;
|
|
578
579
|
}
|
|
579
580
|
let g = 0;
|
|
580
581
|
const c = t.getAttribute(m);
|
|
581
|
-
for (let p = 0, v =
|
|
582
|
-
const b =
|
|
583
|
-
y ||
|
|
582
|
+
for (let p = 0, v = o.length; p < v; p++) {
|
|
583
|
+
const b = o[p], y = !i && !x && s[p], w = b.getAttribute(m);
|
|
584
|
+
y || bt(w, c, g), g += w.count;
|
|
584
585
|
}
|
|
585
586
|
}
|
|
586
587
|
}
|
|
587
|
-
function
|
|
588
|
-
const r =
|
|
589
|
-
let l =
|
|
588
|
+
function br(o, e, t) {
|
|
589
|
+
const r = o.index, s = o.attributes.position.count, a = r ? r.count : s;
|
|
590
|
+
let l = o.groups;
|
|
590
591
|
l.length === 0 && (l = [{ count: a, start: 0, materialIndex: 0 }]);
|
|
591
|
-
let
|
|
592
|
-
if (!
|
|
593
|
-
let
|
|
594
|
-
t.length <= 255 ?
|
|
595
|
-
}
|
|
596
|
-
const d =
|
|
597
|
-
for (let
|
|
598
|
-
const
|
|
592
|
+
let u = o.getAttribute("materialIndex");
|
|
593
|
+
if (!u || u.count !== s) {
|
|
594
|
+
let h;
|
|
595
|
+
t.length <= 255 ? h = new Uint8Array(s) : h = new Uint16Array(s), u = new O(h, 1, !1), o.deleteAttribute("materialIndex"), o.setAttribute("materialIndex", u);
|
|
596
|
+
}
|
|
597
|
+
const d = u.array;
|
|
598
|
+
for (let h = 0; h < l.length; h++) {
|
|
599
|
+
const f = l[h], n = f.start, x = f.count, m = Math.min(x, a - n), g = Array.isArray(e) ? e[f.materialIndex] : e, c = t.indexOf(g);
|
|
599
600
|
for (let p = 0; p < m; p++) {
|
|
600
601
|
let v = n + p;
|
|
601
602
|
r && (v = r.getX(v)), d[v] = c;
|
|
602
603
|
}
|
|
603
604
|
}
|
|
604
605
|
}
|
|
605
|
-
function
|
|
606
|
-
if (!
|
|
607
|
-
const t =
|
|
606
|
+
function yr(o, e) {
|
|
607
|
+
if (!o.index) {
|
|
608
|
+
const t = o.attributes.position.count, r = new Array(t);
|
|
608
609
|
for (let i = 0; i < t; i++)
|
|
609
610
|
r[i] = i;
|
|
610
|
-
|
|
611
|
+
o.setIndex(r);
|
|
611
612
|
}
|
|
612
|
-
if (!
|
|
613
|
-
const t =
|
|
614
|
-
|
|
613
|
+
if (!o.attributes.normal && e && e.includes("normal") && o.computeVertexNormals(), !o.attributes.uv && e && e.includes("uv")) {
|
|
614
|
+
const t = o.attributes.position.count;
|
|
615
|
+
o.setAttribute("uv", new O(new Float32Array(t * 2), 2, !1));
|
|
615
616
|
}
|
|
616
|
-
if (!
|
|
617
|
-
const t =
|
|
618
|
-
|
|
617
|
+
if (!o.attributes.uv2 && e && e.includes("uv2")) {
|
|
618
|
+
const t = o.attributes.position.count;
|
|
619
|
+
o.setAttribute("uv2", new O(new Float32Array(t * 2), 2, !1));
|
|
619
620
|
}
|
|
620
|
-
if (!
|
|
621
|
-
if (
|
|
622
|
-
|
|
621
|
+
if (!o.attributes.tangent && e && e.includes("tangent"))
|
|
622
|
+
if (o.attributes.uv && o.attributes.normal)
|
|
623
|
+
o.computeTangents();
|
|
623
624
|
else {
|
|
624
|
-
const t =
|
|
625
|
-
|
|
625
|
+
const t = o.attributes.position.count;
|
|
626
|
+
o.setAttribute("tangent", new O(new Float32Array(t * 4), 4, !1));
|
|
626
627
|
}
|
|
627
|
-
if (!
|
|
628
|
-
const t =
|
|
629
|
-
r.fill(1),
|
|
628
|
+
if (!o.attributes.color && e && e.includes("color")) {
|
|
629
|
+
const t = o.attributes.position.count, r = new Float32Array(t * 4);
|
|
630
|
+
r.fill(1), o.setAttribute("color", new O(r, 4));
|
|
630
631
|
}
|
|
631
632
|
}
|
|
632
|
-
function De(
|
|
633
|
+
function De(o) {
|
|
633
634
|
let e = 0;
|
|
634
|
-
if (
|
|
635
|
-
const t = new Uint8Array(
|
|
636
|
-
for (let r = 0; r <
|
|
635
|
+
if (o.byteLength !== 0) {
|
|
636
|
+
const t = new Uint8Array(o);
|
|
637
|
+
for (let r = 0; r < o.byteLength; r++) {
|
|
637
638
|
const i = t[r];
|
|
638
639
|
e = (e << 5) - e + i, e |= 0;
|
|
639
640
|
}
|
|
640
641
|
}
|
|
641
642
|
return e;
|
|
642
643
|
}
|
|
643
|
-
function
|
|
644
|
-
let e =
|
|
645
|
-
const t = Object.values(
|
|
646
|
-
|
|
644
|
+
function Ue(o) {
|
|
645
|
+
let e = o.uuid;
|
|
646
|
+
const t = Object.values(o.attributes);
|
|
647
|
+
o.index && (t.push(o.index), e += `index|${o.index.version}`);
|
|
647
648
|
const r = Object.keys(t).sort();
|
|
648
649
|
for (const i of r) {
|
|
649
|
-
const
|
|
650
|
-
e += `${i}_${
|
|
650
|
+
const s = t[i];
|
|
651
|
+
e += `${i}_${s.version}|`;
|
|
651
652
|
}
|
|
652
653
|
return e;
|
|
653
654
|
}
|
|
654
|
-
function Ge(
|
|
655
|
-
const e =
|
|
655
|
+
function Ge(o) {
|
|
656
|
+
const e = o.skeleton;
|
|
656
657
|
return e ? (e.boneTexture || e.computeBoneTexture(), `${De(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`) : null;
|
|
657
658
|
}
|
|
658
|
-
class
|
|
659
|
+
class Tr {
|
|
659
660
|
constructor(e = null) {
|
|
660
|
-
this.matrixWorld = new
|
|
661
|
+
this.matrixWorld = new z(), this.geometryHash = null, this.skeletonHash = null, this.primitiveCount = -1, e !== null && this.updateFrom(e);
|
|
661
662
|
}
|
|
662
663
|
updateFrom(e) {
|
|
663
664
|
const t = e.geometry, r = (t.index ? t.index.count : t.attributes.position.count) / 3;
|
|
664
|
-
this.matrixWorld.copy(e.matrixWorld), this.geometryHash =
|
|
665
|
+
this.matrixWorld.copy(e.matrixWorld), this.geometryHash = Ue(t), this.primitiveCount = r, this.skeletonHash = Ge(e);
|
|
665
666
|
}
|
|
666
667
|
didChange(e) {
|
|
667
668
|
const t = e.geometry, r = (t.index ? t.index.count : t.attributes.position.count) / 3;
|
|
668
|
-
return !(this.matrixWorld.equals(e.matrixWorld) && this.geometryHash ===
|
|
669
|
+
return !(this.matrixWorld.equals(e.matrixWorld) && this.geometryHash === Ue(t) && this.skeletonHash === Ge(e) && this.primitiveCount === r);
|
|
669
670
|
}
|
|
670
671
|
}
|
|
671
|
-
const
|
|
672
|
-
function
|
|
673
|
-
const r =
|
|
674
|
-
|
|
672
|
+
const G = /* @__PURE__ */ new P(), V = /* @__PURE__ */ new P(), q = /* @__PURE__ */ new P(), Ve = /* @__PURE__ */ new te(), ce = /* @__PURE__ */ new P(), Ie = /* @__PURE__ */ new P(), qe = /* @__PURE__ */ new te(), $e = /* @__PURE__ */ new te(), ue = /* @__PURE__ */ new z(), je = /* @__PURE__ */ new z();
|
|
673
|
+
function Ye(o, e, t) {
|
|
674
|
+
const r = o.skeleton, i = o.geometry, s = r.bones, a = r.boneInverses;
|
|
675
|
+
qe.fromBufferAttribute(i.attributes.skinIndex, e), $e.fromBufferAttribute(i.attributes.skinWeight, e), ue.elements.fill(0);
|
|
675
676
|
for (let l = 0; l < 4; l++) {
|
|
676
|
-
const
|
|
677
|
-
if (
|
|
678
|
-
const d =
|
|
679
|
-
|
|
677
|
+
const u = $e.getComponent(l);
|
|
678
|
+
if (u !== 0) {
|
|
679
|
+
const d = qe.getComponent(l);
|
|
680
|
+
je.multiplyMatrices(s[d].matrixWorld, a[d]), wr(ue, je, u);
|
|
680
681
|
}
|
|
681
682
|
}
|
|
682
|
-
return
|
|
683
|
+
return ue.multiply(o.bindMatrix).premultiply(o.bindMatrixInverse), t.transformDirection(ue), t;
|
|
683
684
|
}
|
|
684
|
-
function Re(
|
|
685
|
-
|
|
686
|
-
for (let
|
|
687
|
-
const l = e[
|
|
688
|
-
l !== 0 && (Ie.fromBufferAttribute(
|
|
685
|
+
function Re(o, e, t, r, i) {
|
|
686
|
+
ce.set(0, 0, 0);
|
|
687
|
+
for (let s = 0, a = o.length; s < a; s++) {
|
|
688
|
+
const l = e[s], u = o[s];
|
|
689
|
+
l !== 0 && (Ie.fromBufferAttribute(u, r), t ? ce.addScaledVector(Ie, l) : ce.addScaledVector(Ie.sub(i), l));
|
|
689
690
|
}
|
|
690
|
-
i.add(
|
|
691
|
+
i.add(ce);
|
|
691
692
|
}
|
|
692
|
-
function
|
|
693
|
-
const r =
|
|
694
|
-
for (let
|
|
695
|
-
r[
|
|
693
|
+
function wr(o, e, t) {
|
|
694
|
+
const r = o.elements, i = e.elements;
|
|
695
|
+
for (let s = 0, a = i.length; s < a; s++)
|
|
696
|
+
r[s] += i[s] * t;
|
|
696
697
|
}
|
|
697
|
-
function
|
|
698
|
-
const { index: e, attributes: t } =
|
|
698
|
+
function Ir(o) {
|
|
699
|
+
const { index: e, attributes: t } = o;
|
|
699
700
|
if (e)
|
|
700
701
|
for (let r = 0, i = e.count; r < i; r += 3) {
|
|
701
|
-
const
|
|
702
|
-
e.setX(r, a), e.setX(r + 2,
|
|
702
|
+
const s = e.getX(r), a = e.getX(r + 2);
|
|
703
|
+
e.setX(r, a), e.setX(r + 2, s);
|
|
703
704
|
}
|
|
704
705
|
else
|
|
705
706
|
for (const r in t) {
|
|
706
|
-
const i = t[r],
|
|
707
|
+
const i = t[r], s = i.itemSize;
|
|
707
708
|
for (let a = 0, l = i.count; a < l; a += 3)
|
|
708
|
-
for (let
|
|
709
|
-
const d = i.getComponent(a,
|
|
710
|
-
i.setComponent(a,
|
|
709
|
+
for (let u = 0; u < s; u++) {
|
|
710
|
+
const d = i.getComponent(a, u), h = i.getComponent(a + 2, u);
|
|
711
|
+
i.setComponent(a, u, h), i.setComponent(a + 2, u, d);
|
|
711
712
|
}
|
|
712
713
|
}
|
|
713
|
-
return
|
|
714
|
+
return o;
|
|
714
715
|
}
|
|
715
|
-
function
|
|
716
|
+
function Rr(o, e = {}, t = new ee()) {
|
|
716
717
|
e = {
|
|
717
718
|
applyWorldTransforms: !0,
|
|
718
719
|
attributes: [],
|
|
719
720
|
...e
|
|
720
721
|
};
|
|
721
|
-
const r =
|
|
722
|
+
const r = o.geometry, i = e.applyWorldTransforms, s = e.attributes.includes("normal"), a = e.attributes.includes("tangent"), l = r.attributes, u = t.attributes;
|
|
722
723
|
for (const v in t.attributes)
|
|
723
724
|
(!e.attributes.includes(v) || !(v in r.attributes)) && t.deleteAttribute(v);
|
|
724
|
-
!t.index && r.index && (t.index = r.index.clone()),
|
|
725
|
-
const d = l.position,
|
|
726
|
-
p.getNormalMatrix(
|
|
725
|
+
!t.index && r.index && (t.index = r.index.clone()), u.position || t.setAttribute("position", re(l.position)), s && !u.normal && l.normal && t.setAttribute("normal", re(l.normal)), a && !u.tangent && l.tangent && t.setAttribute("tangent", re(l.tangent)), J(r.index, t.index), J(l.position, u.position), s && J(l.normal, u.normal), a && J(l.tangent, u.tangent);
|
|
726
|
+
const d = l.position, h = s ? l.normal : null, f = a ? l.tangent : null, n = r.morphAttributes.position, x = r.morphAttributes.normal, m = r.morphAttributes.tangent, g = r.morphTargetsRelative, c = o.morphTargetInfluences, p = new Ct();
|
|
727
|
+
p.getNormalMatrix(o.matrixWorld), r.index && t.index.array.set(r.index.array);
|
|
727
728
|
for (let v = 0, b = l.position.count; v < b; v++)
|
|
728
|
-
|
|
729
|
+
G.fromBufferAttribute(d, v), h && V.fromBufferAttribute(h, v), f && (Ve.fromBufferAttribute(f, v), q.fromBufferAttribute(f, v)), c && (n && Re(n, c, g, v, G), x && Re(x, c, g, v, V), m && Re(m, c, g, v, q)), o.isSkinnedMesh && (o.applyBoneTransform(v, G), h && Ye(o, v, V), f && Ye(o, v, q)), i && G.applyMatrix4(o.matrixWorld), u.position.setXYZ(v, G.x, G.y, G.z), h && (i && V.applyNormalMatrix(p), u.normal.setXYZ(v, V.x, V.y, V.z)), f && (i && q.transformDirection(o.matrixWorld), u.tangent.setXYZW(v, q.x, q.y, q.z, Ve.w));
|
|
729
730
|
for (const v in e.attributes) {
|
|
730
731
|
const b = e.attributes[v];
|
|
731
|
-
b === "position" || b === "tangent" || b === "normal" || !(b in l) || (
|
|
732
|
+
b === "position" || b === "tangent" || b === "normal" || !(b in l) || (u[b] || t.setAttribute(b, re(l[b])), J(l[b], u[b]), bt(l[b], u[b]));
|
|
732
733
|
}
|
|
733
|
-
return
|
|
734
|
+
return o.matrixWorld.determinant() < 0 && Ir(t), t;
|
|
734
735
|
}
|
|
735
|
-
class
|
|
736
|
+
class _r extends ee {
|
|
736
737
|
constructor() {
|
|
737
|
-
super(), this.version = 0, this.hash = null, this._diff = new
|
|
738
|
+
super(), this.version = 0, this.hash = null, this._diff = new Tr();
|
|
738
739
|
}
|
|
739
740
|
// returns whether the passed mesh is compatible with this baked geometry
|
|
740
741
|
// such that it can be updated without resizing attributes
|
|
741
742
|
isCompatible(e, t) {
|
|
742
743
|
const r = e.geometry;
|
|
743
744
|
for (let i = 0; i < t.length; i++) {
|
|
744
|
-
const
|
|
745
|
-
if (a && !
|
|
745
|
+
const s = t[i], a = r.attributes[s], l = this.attributes[s];
|
|
746
|
+
if (a && !J(a, l))
|
|
746
747
|
return !1;
|
|
747
748
|
}
|
|
748
749
|
return !0;
|
|
749
750
|
}
|
|
750
751
|
updateFrom(e, t) {
|
|
751
752
|
const r = this._diff;
|
|
752
|
-
return r.didChange(e) ? (
|
|
753
|
+
return r.didChange(e) ? (Rr(e, t, this), r.updateFrom(e), this.version++, this.hash = `${this.uuid}_${this.version}`, !0) : !1;
|
|
753
754
|
}
|
|
754
755
|
}
|
|
755
|
-
const
|
|
756
|
-
function
|
|
757
|
-
for (let t = 0, r =
|
|
758
|
-
|
|
759
|
-
|
|
756
|
+
const Fe = 0, yt = 1, Tt = 2;
|
|
757
|
+
function Sr(o, e) {
|
|
758
|
+
for (let t = 0, r = o.length; t < r; t++)
|
|
759
|
+
o[t].traverseVisible((s) => {
|
|
760
|
+
s.isMesh && e(s);
|
|
760
761
|
});
|
|
761
762
|
}
|
|
762
|
-
function
|
|
763
|
+
function Mr(o) {
|
|
763
764
|
const e = [];
|
|
764
|
-
for (let t = 0, r =
|
|
765
|
-
const i =
|
|
765
|
+
for (let t = 0, r = o.length; t < r; t++) {
|
|
766
|
+
const i = o[t];
|
|
766
767
|
Array.isArray(i.material) ? e.push(...i.material) : e.push(i.material);
|
|
767
768
|
}
|
|
768
769
|
return e;
|
|
769
770
|
}
|
|
770
|
-
function
|
|
771
|
-
if (
|
|
771
|
+
function Ar(o, e, t) {
|
|
772
|
+
if (o.length === 0) {
|
|
772
773
|
e.setIndex(null);
|
|
773
774
|
const r = e.attributes;
|
|
774
775
|
for (const i in r)
|
|
775
776
|
e.deleteAttribute(i);
|
|
776
777
|
for (const i in t.attributes)
|
|
777
|
-
e.setAttribute(t.attributes[i], new
|
|
778
|
+
e.setAttribute(t.attributes[i], new O(new Float32Array(0), 4, !1));
|
|
778
779
|
} else
|
|
779
|
-
|
|
780
|
+
xr(o, t, e);
|
|
780
781
|
for (const r in e.attributes)
|
|
781
782
|
e.attributes[r].needsUpdate = !0;
|
|
782
783
|
}
|
|
@@ -786,14 +787,14 @@ class Fr {
|
|
|
786
787
|
}
|
|
787
788
|
_getDummyMesh() {
|
|
788
789
|
if (!this._dummyMesh) {
|
|
789
|
-
const e = new
|
|
790
|
-
t.setAttribute("position", new
|
|
790
|
+
const e = new Dt(), t = new ee();
|
|
791
|
+
t.setAttribute("position", new O(new Float32Array(9), 3)), this._dummyMesh = new Pt(t, e);
|
|
791
792
|
}
|
|
792
793
|
return this._dummyMesh;
|
|
793
794
|
}
|
|
794
795
|
_getMeshes() {
|
|
795
796
|
const e = [];
|
|
796
|
-
return
|
|
797
|
+
return Sr(this.objects, (t) => {
|
|
797
798
|
e.push(t);
|
|
798
799
|
}), e.sort((t, r) => t.uuid > r.uuid ? 1 : t.uuid < r.uuid ? -1 : 0), e.length === 0 && e.push(this._getDummyMesh()), e;
|
|
799
800
|
}
|
|
@@ -802,68 +803,68 @@ class Fr {
|
|
|
802
803
|
attributes: this.attributes,
|
|
803
804
|
applyWorldTransforms: this.applyWorldTransforms
|
|
804
805
|
};
|
|
805
|
-
for (let
|
|
806
|
-
const l = t[
|
|
807
|
-
r.delete(
|
|
808
|
-
let d = e.get(
|
|
809
|
-
(!d || !d.isCompatible(l, this.attributes)) && (d && d.dispose(), d = new
|
|
806
|
+
for (let s = 0, a = t.length; s < a; s++) {
|
|
807
|
+
const l = t[s], u = l.uuid;
|
|
808
|
+
r.delete(u);
|
|
809
|
+
let d = e.get(u);
|
|
810
|
+
(!d || !d.isCompatible(l, this.attributes)) && (d && d.dispose(), d = new _r(), e.set(u, d)), d.updateFrom(l, i) && this.generateMissingAttributes && yr(d, this.attributes);
|
|
810
811
|
}
|
|
811
|
-
r.forEach((
|
|
812
|
-
e.delete(
|
|
812
|
+
r.forEach((s) => {
|
|
813
|
+
e.delete(s);
|
|
813
814
|
});
|
|
814
815
|
}
|
|
815
816
|
setObjects(e) {
|
|
816
817
|
Array.isArray(e) ? this.objects = [...e] : this.objects = [e];
|
|
817
818
|
}
|
|
818
|
-
generate(e = new
|
|
819
|
-
const { useGroups: t, overwriteIndex: r, _intermediateGeometry: i, _geometryMergeSets:
|
|
819
|
+
generate(e = new ee()) {
|
|
820
|
+
const { useGroups: t, overwriteIndex: r, _intermediateGeometry: i, _geometryMergeSets: s } = this, a = this._getMeshes(), l = [], u = [], d = s.get(e) || [];
|
|
820
821
|
this._updateIntermediateGeometries();
|
|
821
|
-
let
|
|
822
|
-
a.length !== d.length && (
|
|
822
|
+
let h = !1;
|
|
823
|
+
a.length !== d.length && (h = !0);
|
|
823
824
|
for (let n = 0, x = a.length; n < x; n++) {
|
|
824
825
|
const m = a[n], g = i.get(m.uuid);
|
|
825
|
-
|
|
826
|
+
u.push(g);
|
|
826
827
|
const c = d[n];
|
|
827
|
-
!c || c.uuid !== g.uuid ? (l.push(!1),
|
|
828
|
+
!c || c.uuid !== g.uuid ? (l.push(!1), h = !0) : c.version !== g.version ? l.push(!1) : l.push(!0);
|
|
828
829
|
}
|
|
829
|
-
|
|
830
|
+
Ar(u, e, { useGroups: t, forceUpdate: h, skipAssigningAttributes: l, overwriteIndex: r }), h && e.dispose(), s.set(e, u.map((n) => ({
|
|
830
831
|
version: n.version,
|
|
831
832
|
uuid: n.uuid
|
|
832
833
|
})));
|
|
833
|
-
let
|
|
834
|
-
return
|
|
835
|
-
changeType:
|
|
836
|
-
materials:
|
|
834
|
+
let f = Fe;
|
|
835
|
+
return h ? f = Tt : l.includes(!1) && (f = yt), {
|
|
836
|
+
changeType: f,
|
|
837
|
+
materials: Mr(a),
|
|
837
838
|
geometry: e
|
|
838
839
|
};
|
|
839
840
|
}
|
|
840
841
|
}
|
|
841
|
-
function
|
|
842
|
+
function Cr(o) {
|
|
842
843
|
const e = /* @__PURE__ */ new Set();
|
|
843
|
-
for (let t = 0, r =
|
|
844
|
-
const i =
|
|
845
|
-
for (const
|
|
846
|
-
const a = i[
|
|
844
|
+
for (let t = 0, r = o.length; t < r; t++) {
|
|
845
|
+
const i = o[t];
|
|
846
|
+
for (const s in i) {
|
|
847
|
+
const a = i[s];
|
|
847
848
|
a && a.isTexture && e.add(a);
|
|
848
849
|
}
|
|
849
850
|
}
|
|
850
851
|
return Array.from(e);
|
|
851
852
|
}
|
|
852
|
-
function
|
|
853
|
+
function Dr(o) {
|
|
853
854
|
const e = [], t = /* @__PURE__ */ new Set();
|
|
854
|
-
for (let i = 0,
|
|
855
|
-
|
|
855
|
+
for (let i = 0, s = o.length; i < s; i++)
|
|
856
|
+
o[i].traverse((a) => {
|
|
856
857
|
a.visible && (a.isRectAreaLight || a.isSpotLight || a.isPointLight || a.isDirectionalLight) && (e.push(a), a.iesMap && t.add(a.iesMap));
|
|
857
858
|
});
|
|
858
|
-
const r = Array.from(t).sort((i,
|
|
859
|
+
const r = Array.from(t).sort((i, s) => i.uuid < s.uuid ? 1 : i.uuid > s.uuid ? -1 : 0);
|
|
859
860
|
return { lights: e, iesTextures: r };
|
|
860
861
|
}
|
|
861
|
-
class
|
|
862
|
+
class Pr {
|
|
862
863
|
get initialized() {
|
|
863
864
|
return !!this.bvh;
|
|
864
865
|
}
|
|
865
866
|
constructor(e) {
|
|
866
|
-
this.bvhOptions = {}, this.attributes = ["position", "normal", "tangent", "color", "uv", "uv2"], this.generateBVH = !0, this.bvh = null, this.geometry = new
|
|
867
|
+
this.bvhOptions = {}, this.attributes = ["position", "normal", "tangent", "color", "uv", "uv2"], this.generateBVH = !0, this.bvh = null, this.geometry = new ee(), this.staticGeometryGenerator = new Fr(e), this._bvhWorker = null, this._pendingGenerate = null, this._buildAsync = !1;
|
|
867
868
|
}
|
|
868
869
|
setObjects(e) {
|
|
869
870
|
this.staticGeometryGenerator.setObjects(e);
|
|
@@ -883,82 +884,39 @@ class Er {
|
|
|
883
884
|
}
|
|
884
885
|
}
|
|
885
886
|
generate(e = null) {
|
|
886
|
-
const { staticGeometryGenerator: t, geometry: r, attributes: i } = this,
|
|
887
|
-
t.attributes = i,
|
|
888
|
-
|
|
887
|
+
const { staticGeometryGenerator: t, geometry: r, attributes: i } = this, s = t.objects;
|
|
888
|
+
t.attributes = i, s.forEach((f) => {
|
|
889
|
+
f.traverse((n) => {
|
|
889
890
|
n.isSkinnedMesh && n.skeleton && n.skeleton.update();
|
|
890
891
|
});
|
|
891
892
|
});
|
|
892
|
-
const a = t.generate(r), l = a.materials,
|
|
893
|
-
if (a.changeType !==
|
|
893
|
+
const a = t.generate(r), l = a.materials, u = Cr(l), { lights: d, iesTextures: h } = Dr(s);
|
|
894
|
+
if (a.changeType !== Fe && br(r, l, l), this.generateBVH) {
|
|
894
895
|
if (this.bvh instanceof Promise)
|
|
895
896
|
throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");
|
|
896
|
-
if (a.changeType ===
|
|
897
|
-
const
|
|
898
|
-
strategy:
|
|
897
|
+
if (a.changeType === Tt) {
|
|
898
|
+
const f = {
|
|
899
|
+
strategy: er,
|
|
899
900
|
maxLeafTris: 1,
|
|
900
901
|
indirect: !0,
|
|
901
902
|
onProgress: e,
|
|
902
903
|
...this.bvhOptions
|
|
903
904
|
};
|
|
904
|
-
this._buildAsync ? this.bvh = this._bvhWorker.generate(r,
|
|
905
|
-
} else a.changeType ===
|
|
905
|
+
this._buildAsync ? this.bvh = this._bvhWorker.generate(r, f) : this.bvh = new tr(r, f);
|
|
906
|
+
} else a.changeType === yt && this.bvh.refit();
|
|
906
907
|
}
|
|
907
908
|
return {
|
|
908
|
-
bvhChanged: a.changeType !==
|
|
909
|
+
bvhChanged: a.changeType !== Fe,
|
|
909
910
|
bvh: this.bvh,
|
|
910
911
|
lights: d,
|
|
911
|
-
iesTextures:
|
|
912
|
+
iesTextures: h,
|
|
912
913
|
geometry: r,
|
|
913
914
|
materials: l,
|
|
914
|
-
textures:
|
|
915
|
-
objects:
|
|
915
|
+
textures: u,
|
|
916
|
+
objects: s
|
|
916
917
|
};
|
|
917
918
|
}
|
|
918
919
|
}
|
|
919
|
-
const kr = new kt(-1, 1, 1, -1, 0, 1);
|
|
920
|
-
class Or extends q {
|
|
921
|
-
constructor() {
|
|
922
|
-
super(), this.setAttribute("position", new We([-1, 3, 0, -1, -1, 0, 3, -1, 0], 3)), this.setAttribute("uv", new We([0, 2, 0, 0, 2, 0], 2));
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
const zr = new Or();
|
|
926
|
-
class Z {
|
|
927
|
-
/**
|
|
928
|
-
* Constructs a new full screen quad.
|
|
929
|
-
*
|
|
930
|
-
* @param {?Material} material - The material to render te full screen quad with.
|
|
931
|
-
*/
|
|
932
|
-
constructor(e) {
|
|
933
|
-
this._mesh = new mt(zr, e);
|
|
934
|
-
}
|
|
935
|
-
/**
|
|
936
|
-
* Frees the GPU-related resources allocated by this instance. Call this
|
|
937
|
-
* method whenever the instance is no longer used in your app.
|
|
938
|
-
*/
|
|
939
|
-
dispose() {
|
|
940
|
-
this._mesh.geometry.dispose();
|
|
941
|
-
}
|
|
942
|
-
/**
|
|
943
|
-
* Renders the full screen quad.
|
|
944
|
-
*
|
|
945
|
-
* @param {WebGLRenderer} renderer - The renderer.
|
|
946
|
-
*/
|
|
947
|
-
render(e) {
|
|
948
|
-
e.render(this._mesh, kr);
|
|
949
|
-
}
|
|
950
|
-
/**
|
|
951
|
-
* The quad's material.
|
|
952
|
-
*
|
|
953
|
-
* @type {?Material}
|
|
954
|
-
*/
|
|
955
|
-
get material() {
|
|
956
|
-
return this._mesh.material;
|
|
957
|
-
}
|
|
958
|
-
set material(e) {
|
|
959
|
-
this._mesh.material = e;
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
920
|
class Pe extends ge {
|
|
963
921
|
set needsUpdate(e) {
|
|
964
922
|
super.needsUpdate = !0, this.dispatchEvent({
|
|
@@ -987,10 +945,10 @@ class Pe extends ge {
|
|
|
987
945
|
return !1;
|
|
988
946
|
}
|
|
989
947
|
}
|
|
990
|
-
class
|
|
948
|
+
class Er extends Pe {
|
|
991
949
|
constructor(e) {
|
|
992
950
|
super({
|
|
993
|
-
blending:
|
|
951
|
+
blending: se,
|
|
994
952
|
uniforms: {
|
|
995
953
|
target1: { value: null },
|
|
996
954
|
target2: { value: null },
|
|
@@ -1044,9 +1002,9 @@ class Nr extends Pe {
|
|
|
1044
1002
|
}), this.setValues(e);
|
|
1045
1003
|
}
|
|
1046
1004
|
}
|
|
1047
|
-
function
|
|
1005
|
+
function fe(o = 1) {
|
|
1048
1006
|
let e = "uint";
|
|
1049
|
-
return
|
|
1007
|
+
return o > 1 && (e = "uvec" + o), /* glsl */
|
|
1050
1008
|
`
|
|
1051
1009
|
${e} sobolReverseBits( ${e} x ) {
|
|
1052
1010
|
|
|
@@ -1084,9 +1042,9 @@ function ue(s = 1) {
|
|
|
1084
1042
|
}
|
|
1085
1043
|
`;
|
|
1086
1044
|
}
|
|
1087
|
-
function he(
|
|
1088
|
-
let e = "uint", t = "float", r = "", i = ".r",
|
|
1089
|
-
return
|
|
1045
|
+
function he(o = 1) {
|
|
1046
|
+
let e = "uint", t = "float", r = "", i = ".r", s = "1u";
|
|
1047
|
+
return o > 1 && (e = "uvec" + o, t = "vec" + o, r = o + "", o === 2 ? (i = ".rg", s = "uvec2( 1u, 2u )") : o === 3 ? (i = ".rgb", s = "uvec3( 1u, 2u, 3u )") : (i = "", s = "uvec4( 1u, 2u, 3u, 4u )")), /* glsl */
|
|
1090
1048
|
`
|
|
1091
1049
|
|
|
1092
1050
|
${t} sobol${r}( int effect ) {
|
|
@@ -1099,7 +1057,7 @@ function he(s = 1) {
|
|
|
1099
1057
|
${t} sobol_pt = sobolGetTexturePoint( shuffled_index )${i};
|
|
1100
1058
|
${e} result = ${e}( sobol_pt * 16777216.0 );
|
|
1101
1059
|
|
|
1102
|
-
${e} seed2 = sobolHashCombine( seed, ${
|
|
1060
|
+
${e} seed2 = sobolHashCombine( seed, ${s} );
|
|
1103
1061
|
result = nestedUniformScrambleBase2( result, seed2 );
|
|
1104
1062
|
|
|
1105
1063
|
return SOBOL_FACTOR * ${t}( result >> 8 );
|
|
@@ -1107,7 +1065,7 @@ function he(s = 1) {
|
|
|
1107
1065
|
}
|
|
1108
1066
|
`;
|
|
1109
1067
|
}
|
|
1110
|
-
const
|
|
1068
|
+
const wt = (
|
|
1111
1069
|
/* glsl */
|
|
1112
1070
|
`
|
|
1113
1071
|
|
|
@@ -1115,10 +1073,10 @@ const Rt = (
|
|
|
1115
1073
|
const float SOBOL_FACTOR = 1.0 / 16777216.0;
|
|
1116
1074
|
const uint SOBOL_MAX_POINTS = 256u * 256u;
|
|
1117
1075
|
|
|
1118
|
-
${
|
|
1119
|
-
${
|
|
1120
|
-
${
|
|
1121
|
-
${
|
|
1076
|
+
${fe(1)}
|
|
1077
|
+
${fe(2)}
|
|
1078
|
+
${fe(3)}
|
|
1079
|
+
${fe(4)}
|
|
1122
1080
|
|
|
1123
1081
|
uint sobolHash( uint x ) {
|
|
1124
1082
|
|
|
@@ -1133,7 +1091,7 @@ const Rt = (
|
|
|
1133
1091
|
}
|
|
1134
1092
|
|
|
1135
1093
|
`
|
|
1136
|
-
),
|
|
1094
|
+
), Or = (
|
|
1137
1095
|
/* glsl */
|
|
1138
1096
|
`
|
|
1139
1097
|
|
|
@@ -1214,7 +1172,7 @@ const Rt = (
|
|
|
1214
1172
|
}
|
|
1215
1173
|
|
|
1216
1174
|
`
|
|
1217
|
-
),
|
|
1175
|
+
), kr = (
|
|
1218
1176
|
/* glsl */
|
|
1219
1177
|
`
|
|
1220
1178
|
|
|
@@ -1261,12 +1219,12 @@ const Rt = (
|
|
|
1261
1219
|
|
|
1262
1220
|
`
|
|
1263
1221
|
);
|
|
1264
|
-
class
|
|
1222
|
+
class Nr extends Pe {
|
|
1265
1223
|
constructor() {
|
|
1266
1224
|
super({
|
|
1267
|
-
blending:
|
|
1225
|
+
blending: se,
|
|
1268
1226
|
uniforms: {
|
|
1269
|
-
resolution: { value: new
|
|
1227
|
+
resolution: { value: new X() }
|
|
1270
1228
|
},
|
|
1271
1229
|
vertexShader: (
|
|
1272
1230
|
/* glsl */
|
|
@@ -1285,8 +1243,8 @@ class Wr extends Pe {
|
|
|
1285
1243
|
/* glsl */
|
|
1286
1244
|
`
|
|
1287
1245
|
|
|
1288
|
-
${
|
|
1289
|
-
${
|
|
1246
|
+
${wt}
|
|
1247
|
+
${Or}
|
|
1290
1248
|
|
|
1291
1249
|
varying vec2 vUv;
|
|
1292
1250
|
uniform vec2 resolution;
|
|
@@ -1301,9 +1259,9 @@ class Wr extends Pe {
|
|
|
1301
1259
|
});
|
|
1302
1260
|
}
|
|
1303
1261
|
}
|
|
1304
|
-
class
|
|
1262
|
+
class zr {
|
|
1305
1263
|
generate(e, t = 256) {
|
|
1306
|
-
const r = new
|
|
1264
|
+
const r = new ie(t, t, {
|
|
1307
1265
|
type: R,
|
|
1308
1266
|
format: I,
|
|
1309
1267
|
minFilter: T,
|
|
@@ -1311,11 +1269,11 @@ class Lr {
|
|
|
1311
1269
|
generateMipmaps: !1
|
|
1312
1270
|
}), i = e.getRenderTarget();
|
|
1313
1271
|
e.setRenderTarget(r);
|
|
1314
|
-
const
|
|
1315
|
-
return
|
|
1272
|
+
const s = new Y(new Nr());
|
|
1273
|
+
return s.material.resolution.set(t, t), s.render(e), e.setRenderTarget(i), s.dispose(), r;
|
|
1316
1274
|
}
|
|
1317
1275
|
}
|
|
1318
|
-
class
|
|
1276
|
+
class Hr extends dt {
|
|
1319
1277
|
set bokehSize(e) {
|
|
1320
1278
|
this.fStop = this.getFocalLength() / e;
|
|
1321
1279
|
}
|
|
@@ -1329,132 +1287,132 @@ class Ur extends pt {
|
|
|
1329
1287
|
return super.copy(e, t), this.fStop = e.fStop, this.apertureBlades = e.apertureBlades, this.apertureRotation = e.apertureRotation, this.focusDistance = e.focusDistance, this.anamorphicRatio = e.anamorphicRatio, this;
|
|
1330
1288
|
}
|
|
1331
1289
|
}
|
|
1332
|
-
class
|
|
1290
|
+
class Br {
|
|
1333
1291
|
constructor() {
|
|
1334
1292
|
this.bokehSize = 0, this.apertureBlades = 0, this.apertureRotation = 0, this.focusDistance = 10, this.anamorphicRatio = 1;
|
|
1335
1293
|
}
|
|
1336
1294
|
updateFrom(e) {
|
|
1337
|
-
e instanceof
|
|
1295
|
+
e instanceof Hr ? (this.bokehSize = e.bokehSize, this.apertureBlades = e.apertureBlades, this.apertureRotation = e.apertureRotation, this.focusDistance = e.focusDistance, this.anamorphicRatio = e.anamorphicRatio) : (this.bokehSize = 0, this.apertureRotation = 0, this.apertureBlades = 0, this.focusDistance = 10, this.anamorphicRatio = 1);
|
|
1338
1296
|
}
|
|
1339
1297
|
}
|
|
1340
|
-
function _e(
|
|
1341
|
-
const e = new Uint16Array(
|
|
1342
|
-
for (let t = 0, r =
|
|
1343
|
-
e[t] =
|
|
1298
|
+
function _e(o) {
|
|
1299
|
+
const e = new Uint16Array(o.length);
|
|
1300
|
+
for (let t = 0, r = o.length; t < r; ++t)
|
|
1301
|
+
e[t] = N.toHalfFloat(o[t]);
|
|
1344
1302
|
return e;
|
|
1345
1303
|
}
|
|
1346
|
-
function
|
|
1347
|
-
let i = t,
|
|
1348
|
-
for (; i <
|
|
1349
|
-
const a = i +
|
|
1350
|
-
|
|
1304
|
+
function Xe(o, e, t = 0, r = o.length) {
|
|
1305
|
+
let i = t, s = t + r - 1;
|
|
1306
|
+
for (; i < s; ) {
|
|
1307
|
+
const a = i + s >> 1;
|
|
1308
|
+
o[a] < e ? i = a + 1 : s = a;
|
|
1351
1309
|
}
|
|
1352
1310
|
return i - t;
|
|
1353
1311
|
}
|
|
1354
|
-
function
|
|
1355
|
-
return 0.2126 *
|
|
1312
|
+
function Wr(o, e, t) {
|
|
1313
|
+
return 0.2126 * o + 0.7152 * e + 0.0722 * t;
|
|
1356
1314
|
}
|
|
1357
|
-
function
|
|
1358
|
-
const t =
|
|
1359
|
-
t.source = new
|
|
1360
|
-
const { width: r, height: i, data:
|
|
1361
|
-
let a =
|
|
1315
|
+
function Lr(o, e = E) {
|
|
1316
|
+
const t = o.clone();
|
|
1317
|
+
t.source = new Et({ ...t.image });
|
|
1318
|
+
const { width: r, height: i, data: s } = t.image;
|
|
1319
|
+
let a = s;
|
|
1362
1320
|
if (t.type !== e) {
|
|
1363
|
-
e ===
|
|
1321
|
+
e === E ? a = new Uint16Array(s.length) : a = new Float32Array(s.length);
|
|
1364
1322
|
let l;
|
|
1365
|
-
|
|
1366
|
-
for (let
|
|
1367
|
-
let
|
|
1368
|
-
t.type ===
|
|
1323
|
+
s instanceof Int8Array || s instanceof Int16Array || s instanceof Int32Array ? l = 2 ** (8 * s.BYTES_PER_ELEMENT - 1) - 1 : l = 2 ** (8 * s.BYTES_PER_ELEMENT) - 1;
|
|
1324
|
+
for (let u = 0, d = s.length; u < d; u++) {
|
|
1325
|
+
let h = s[u];
|
|
1326
|
+
t.type === E && (h = N.fromHalfFloat(s[u])), t.type !== R && t.type !== E && (h /= l), e === E && (a[u] = N.toHalfFloat(h));
|
|
1369
1327
|
}
|
|
1370
1328
|
t.image.data = a, t.type = e;
|
|
1371
1329
|
}
|
|
1372
1330
|
if (t.flipY) {
|
|
1373
1331
|
const l = a;
|
|
1374
1332
|
a = a.slice();
|
|
1375
|
-
for (let
|
|
1333
|
+
for (let u = 0; u < i; u++)
|
|
1376
1334
|
for (let d = 0; d < r; d++) {
|
|
1377
|
-
const
|
|
1378
|
-
a[n + 0] = l[
|
|
1335
|
+
const h = i - u - 1, f = 4 * (u * r + d), n = 4 * (h * r + d);
|
|
1336
|
+
a[n + 0] = l[f + 0], a[n + 1] = l[f + 1], a[n + 2] = l[f + 2], a[n + 3] = l[f + 3];
|
|
1379
1337
|
}
|
|
1380
1338
|
t.flipY = !1, t.image.data = a;
|
|
1381
1339
|
}
|
|
1382
1340
|
return t;
|
|
1383
1341
|
}
|
|
1384
|
-
class
|
|
1342
|
+
class Ur {
|
|
1385
1343
|
constructor() {
|
|
1386
|
-
const e = new
|
|
1387
|
-
e.type =
|
|
1388
|
-
const t = new
|
|
1389
|
-
t.type =
|
|
1390
|
-
const r = new
|
|
1391
|
-
r.type =
|
|
1344
|
+
const e = new F(_e(new Float32Array([0, 0, 0, 0])), 1, 1);
|
|
1345
|
+
e.type = E, e.format = I, e.minFilter = D, e.magFilter = D, e.wrapS = H, e.wrapT = H, e.generateMipmaps = !1, e.needsUpdate = !0;
|
|
1346
|
+
const t = new F(_e(new Float32Array([0, 1])), 1, 2);
|
|
1347
|
+
t.type = E, t.format = pe, t.minFilter = D, t.magFilter = D, t.generateMipmaps = !1, t.needsUpdate = !0;
|
|
1348
|
+
const r = new F(_e(new Float32Array([0, 0, 1, 1])), 2, 2);
|
|
1349
|
+
r.type = E, r.format = pe, r.minFilter = D, r.magFilter = D, r.generateMipmaps = !1, r.needsUpdate = !0, this.map = e, this.marginalWeights = t, this.conditionalWeights = r, this.totalSum = 0;
|
|
1392
1350
|
}
|
|
1393
1351
|
dispose() {
|
|
1394
1352
|
this.marginalWeights.dispose(), this.conditionalWeights.dispose(), this.map.dispose();
|
|
1395
1353
|
}
|
|
1396
1354
|
updateFrom(e) {
|
|
1397
|
-
const t =
|
|
1398
|
-
t.wrapS =
|
|
1399
|
-
const { width: r, height: i, data:
|
|
1400
|
-
let
|
|
1355
|
+
const t = Lr(e);
|
|
1356
|
+
t.wrapS = H, t.wrapT = B;
|
|
1357
|
+
const { width: r, height: i, data: s } = t.image, a = new Float32Array(r * i), l = new Float32Array(r * i), u = new Float32Array(i), d = new Float32Array(i);
|
|
1358
|
+
let h = 0, f = 0;
|
|
1401
1359
|
for (let c = 0; c < i; c++) {
|
|
1402
1360
|
let p = 0;
|
|
1403
1361
|
for (let v = 0; v < r; v++) {
|
|
1404
|
-
const b = c * r + v, y =
|
|
1405
|
-
p +=
|
|
1362
|
+
const b = c * r + v, y = N.fromHalfFloat(s[4 * b + 0]), w = N.fromHalfFloat(s[4 * b + 1]), k = N.fromHalfFloat(s[4 * b + 2]), W = Wr(y, w, k);
|
|
1363
|
+
p += W, h += W, a[b] = W, l[b] = p;
|
|
1406
1364
|
}
|
|
1407
1365
|
if (p !== 0)
|
|
1408
1366
|
for (let v = c * r, b = c * r + r; v < b; v++)
|
|
1409
1367
|
a[v] /= p, l[v] /= p;
|
|
1410
|
-
|
|
1368
|
+
f += p, u[c] = p, d[c] = f;
|
|
1411
1369
|
}
|
|
1412
|
-
if (
|
|
1413
|
-
for (let c = 0, p =
|
|
1414
|
-
|
|
1370
|
+
if (f !== 0)
|
|
1371
|
+
for (let c = 0, p = u.length; c < p; c++)
|
|
1372
|
+
u[c] /= f, d[c] /= f;
|
|
1415
1373
|
const n = new Uint16Array(i), x = new Uint16Array(r * i);
|
|
1416
1374
|
for (let c = 0; c < i; c++) {
|
|
1417
|
-
const p = (c + 1) / i, v =
|
|
1418
|
-
n[c] =
|
|
1375
|
+
const p = (c + 1) / i, v = Xe(d, p);
|
|
1376
|
+
n[c] = N.toHalfFloat((v + 0.5) / i);
|
|
1419
1377
|
}
|
|
1420
1378
|
for (let c = 0; c < i; c++)
|
|
1421
1379
|
for (let p = 0; p < r; p++) {
|
|
1422
|
-
const v = c * r + p, b = (p + 1) / r, y =
|
|
1423
|
-
x[v] =
|
|
1380
|
+
const v = c * r + p, b = (p + 1) / r, y = Xe(l, b, c * r, r);
|
|
1381
|
+
x[v] = N.toHalfFloat((y + 0.5) / r);
|
|
1424
1382
|
}
|
|
1425
1383
|
this.dispose();
|
|
1426
1384
|
const { marginalWeights: m, conditionalWeights: g } = this;
|
|
1427
|
-
m.image = { width: i, height: 1, data: n }, m.needsUpdate = !0, g.image = { width: r, height: i, data: x }, g.needsUpdate = !0, this.totalSum =
|
|
1385
|
+
m.image = { width: i, height: 1, data: n }, m.needsUpdate = !0, g.image = { width: r, height: i, data: x }, g.needsUpdate = !0, this.totalSum = h, this.map = t;
|
|
1428
1386
|
}
|
|
1429
1387
|
}
|
|
1430
|
-
const Se = 6,
|
|
1431
|
-
class
|
|
1388
|
+
const Se = 6, Gr = 0, Vr = 1, qr = 2, $r = 3, jr = 4, C = new P(), A = new P(), Qe = new z(), Q = new Ot(), Ke = new P(), K = new P(), Yr = new P(0, 1, 0);
|
|
1389
|
+
class Xr {
|
|
1432
1390
|
constructor() {
|
|
1433
|
-
const e = new
|
|
1434
|
-
e.format = I, e.type = R, e.wrapS =
|
|
1391
|
+
const e = new F(new Float32Array(4), 1, 1);
|
|
1392
|
+
e.format = I, e.type = R, e.wrapS = B, e.wrapT = B, e.generateMipmaps = !1, e.minFilter = T, e.magFilter = T, this.tex = e, this.count = 0;
|
|
1435
1393
|
}
|
|
1436
1394
|
updateFrom(e, t = []) {
|
|
1437
|
-
const r = this.tex, i = Math.max(e.length * Se, 1),
|
|
1438
|
-
r.image.width !==
|
|
1395
|
+
const r = this.tex, i = Math.max(e.length * Se, 1), s = Math.ceil(Math.sqrt(i));
|
|
1396
|
+
r.image.width !== s && (r.dispose(), r.image.data = new Float32Array(s * s * 4), r.image.width = s, r.image.height = s);
|
|
1439
1397
|
const a = r.image.data;
|
|
1440
|
-
for (let
|
|
1441
|
-
const
|
|
1398
|
+
for (let u = 0, d = e.length; u < d; u++) {
|
|
1399
|
+
const h = e[u], f = u * Se * 4;
|
|
1442
1400
|
let n = 0;
|
|
1443
1401
|
for (let m = 0; m < Se * 4; m++)
|
|
1444
|
-
a[
|
|
1445
|
-
|
|
1446
|
-
let x =
|
|
1447
|
-
if (
|
|
1448
|
-
|
|
1449
|
-
else if (
|
|
1450
|
-
const m =
|
|
1451
|
-
|
|
1452
|
-
} else if (
|
|
1453
|
-
const m =
|
|
1454
|
-
a[
|
|
1455
|
-
} else if (
|
|
1456
|
-
const m =
|
|
1457
|
-
|
|
1402
|
+
a[f + m] = 0;
|
|
1403
|
+
h.getWorldPosition(A), a[f + n++] = A.x, a[f + n++] = A.y, a[f + n++] = A.z;
|
|
1404
|
+
let x = Gr;
|
|
1405
|
+
if (h.isRectAreaLight && h.isCircular ? x = Vr : h.isSpotLight ? x = qr : h.isDirectionalLight ? x = $r : h.isPointLight && (x = jr), a[f + n++] = x, a[f + n++] = h.color.r, a[f + n++] = h.color.g, a[f + n++] = h.color.b, a[f + n++] = h.intensity, h.getWorldQuaternion(Q), h.isRectAreaLight)
|
|
1406
|
+
C.set(h.width, 0, 0).applyQuaternion(Q), a[f + n++] = C.x, a[f + n++] = C.y, a[f + n++] = C.z, n++, A.set(0, h.height, 0).applyQuaternion(Q), a[f + n++] = A.x, a[f + n++] = A.y, a[f + n++] = A.z, a[f + n++] = C.cross(A).length() * (h.isCircular ? Math.PI / 4 : 1);
|
|
1407
|
+
else if (h.isSpotLight) {
|
|
1408
|
+
const m = h.radius || 0;
|
|
1409
|
+
Ke.setFromMatrixPosition(h.matrixWorld), K.setFromMatrixPosition(h.target.matrixWorld), Qe.lookAt(Ke, K, Yr), Q.setFromRotationMatrix(Qe), C.set(1, 0, 0).applyQuaternion(Q), a[f + n++] = C.x, a[f + n++] = C.y, a[f + n++] = C.z, n++, A.set(0, 1, 0).applyQuaternion(Q), a[f + n++] = A.x, a[f + n++] = A.y, a[f + n++] = A.z, a[f + n++] = Math.PI * m * m, a[f + n++] = m, a[f + n++] = h.decay, a[f + n++] = h.distance, a[f + n++] = Math.cos(h.angle), a[f + n++] = Math.cos(h.angle * (1 - h.penumbra)), a[f + n++] = h.iesMap ? t.indexOf(h.iesMap) : -1;
|
|
1410
|
+
} else if (h.isPointLight) {
|
|
1411
|
+
const m = C.setFromMatrixPosition(h.matrixWorld);
|
|
1412
|
+
a[f + n++] = m.x, a[f + n++] = m.y, a[f + n++] = m.z, n++, n += 4, n += 1, a[f + n++] = h.decay, a[f + n++] = h.distance;
|
|
1413
|
+
} else if (h.isDirectionalLight) {
|
|
1414
|
+
const m = C.setFromMatrixPosition(h.matrixWorld), g = A.setFromMatrixPosition(h.target.matrixWorld);
|
|
1415
|
+
K.subVectors(m, g).normalize(), a[f + n++] = K.x, a[f + n++] = K.y, a[f + n++] = K.z;
|
|
1458
1416
|
}
|
|
1459
1417
|
}
|
|
1460
1418
|
this.count = e.length;
|
|
@@ -1462,12 +1420,12 @@ class Jr {
|
|
|
1462
1420
|
return this.hash !== l ? (this.hash = l, r.needsUpdate = !0, !0) : !1;
|
|
1463
1421
|
}
|
|
1464
1422
|
}
|
|
1465
|
-
function
|
|
1423
|
+
function Ze(o, e, t, r, i) {
|
|
1466
1424
|
if (e > r)
|
|
1467
1425
|
throw new Error();
|
|
1468
|
-
const
|
|
1426
|
+
const s = o.length / e, a = o.constructor.BYTES_PER_ELEMENT * 8;
|
|
1469
1427
|
let l = 1;
|
|
1470
|
-
switch (
|
|
1428
|
+
switch (o.constructor) {
|
|
1471
1429
|
case Uint8Array:
|
|
1472
1430
|
case Uint16Array:
|
|
1473
1431
|
case Uint32Array:
|
|
@@ -1479,52 +1437,52 @@ function Je(s, e, t, r, i) {
|
|
|
1479
1437
|
l = 2 ** (a - 1) - 1;
|
|
1480
1438
|
break;
|
|
1481
1439
|
}
|
|
1482
|
-
for (let
|
|
1483
|
-
const d = 4 *
|
|
1484
|
-
for (let
|
|
1485
|
-
t[i + d +
|
|
1440
|
+
for (let u = 0; u < s; u++) {
|
|
1441
|
+
const d = 4 * u, h = e * u;
|
|
1442
|
+
for (let f = 0; f < r; f++)
|
|
1443
|
+
t[i + d + f] = e >= f + 1 ? o[h + f] / l : 0;
|
|
1486
1444
|
}
|
|
1487
1445
|
}
|
|
1488
|
-
class
|
|
1446
|
+
class Qr extends kt {
|
|
1489
1447
|
constructor() {
|
|
1490
1448
|
super(), this._textures = [], this.type = R, this.format = I, this.internalFormat = "RGBA32F";
|
|
1491
1449
|
}
|
|
1492
1450
|
updateAttribute(e, t) {
|
|
1493
1451
|
const r = this._textures[e];
|
|
1494
1452
|
r.updateFrom(t);
|
|
1495
|
-
const i = r.image,
|
|
1496
|
-
if (i.width !==
|
|
1453
|
+
const i = r.image, s = this.image;
|
|
1454
|
+
if (i.width !== s.width || i.height !== s.height)
|
|
1497
1455
|
throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");
|
|
1498
|
-
const { width: a, height: l, data:
|
|
1499
|
-
let
|
|
1500
|
-
|
|
1456
|
+
const { width: a, height: l, data: u } = s, h = a * l * 4 * e;
|
|
1457
|
+
let f = t.itemSize;
|
|
1458
|
+
f === 3 && (f = 4), Ze(r.image.data, f, u, 4, h), this.dispose(), this.needsUpdate = !0;
|
|
1501
1459
|
}
|
|
1502
1460
|
setAttributes(e) {
|
|
1503
1461
|
const t = e[0].count, r = e.length;
|
|
1504
|
-
for (let
|
|
1505
|
-
if (e[
|
|
1462
|
+
for (let f = 0, n = r; f < n; f++)
|
|
1463
|
+
if (e[f].count !== t)
|
|
1506
1464
|
throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");
|
|
1507
1465
|
const i = this._textures;
|
|
1508
1466
|
for (; i.length < r; ) {
|
|
1509
|
-
const
|
|
1510
|
-
i.push(
|
|
1467
|
+
const f = new xt();
|
|
1468
|
+
i.push(f);
|
|
1511
1469
|
}
|
|
1512
1470
|
for (; i.length > r; )
|
|
1513
1471
|
i.pop();
|
|
1514
|
-
for (let
|
|
1515
|
-
i[
|
|
1472
|
+
for (let f = 0, n = r; f < n; f++)
|
|
1473
|
+
i[f].updateFrom(e[f]);
|
|
1516
1474
|
const a = i[0].image, l = this.image;
|
|
1517
1475
|
(a.width !== l.width || a.height !== l.height || a.depth !== r) && (l.width = a.width, l.height = a.height, l.depth = r, l.data = new Float32Array(l.width * l.height * l.depth * 4));
|
|
1518
|
-
const { data:
|
|
1519
|
-
for (let
|
|
1520
|
-
const x = i[
|
|
1521
|
-
let c = e[
|
|
1522
|
-
c === 3 && (c = 4),
|
|
1476
|
+
const { data: u, width: d, height: h } = l;
|
|
1477
|
+
for (let f = 0, n = r; f < n; f++) {
|
|
1478
|
+
const x = i[f], g = d * h * 4 * f;
|
|
1479
|
+
let c = e[f].itemSize;
|
|
1480
|
+
c === 3 && (c = 4), Ze(x.image.data, c, u, 4, g);
|
|
1523
1481
|
}
|
|
1524
1482
|
this.dispose(), this.needsUpdate = !0;
|
|
1525
1483
|
}
|
|
1526
1484
|
}
|
|
1527
|
-
class
|
|
1485
|
+
class Kr extends Qr {
|
|
1528
1486
|
updateNormalAttribute(e) {
|
|
1529
1487
|
this.updateAttribute(0, e);
|
|
1530
1488
|
}
|
|
@@ -1541,44 +1499,44 @@ class ta extends ea {
|
|
|
1541
1499
|
this.setAttributes([e, t, r, i]);
|
|
1542
1500
|
}
|
|
1543
1501
|
}
|
|
1544
|
-
function Ee(
|
|
1545
|
-
return
|
|
1502
|
+
function Ee(o, e) {
|
|
1503
|
+
return o.uuid < e.uuid ? 1 : o.uuid > e.uuid ? -1 : 0;
|
|
1546
1504
|
}
|
|
1547
|
-
function
|
|
1548
|
-
return `${
|
|
1505
|
+
function Ce(o) {
|
|
1506
|
+
return `${o.source.uuid}:${o.colorSpace}`;
|
|
1549
1507
|
}
|
|
1550
|
-
function
|
|
1508
|
+
function Zr(o) {
|
|
1551
1509
|
const e = /* @__PURE__ */ new Set(), t = [];
|
|
1552
|
-
for (let r = 0, i =
|
|
1553
|
-
const
|
|
1554
|
-
e.has(a) || (e.add(a), t.push(
|
|
1510
|
+
for (let r = 0, i = o.length; r < i; r++) {
|
|
1511
|
+
const s = o[r], a = Ce(s);
|
|
1512
|
+
e.has(a) || (e.add(a), t.push(s));
|
|
1555
1513
|
}
|
|
1556
1514
|
return t;
|
|
1557
1515
|
}
|
|
1558
|
-
function
|
|
1559
|
-
const e =
|
|
1516
|
+
function Jr(o) {
|
|
1517
|
+
const e = o.map((r) => r.iesMap || null).filter((r) => r), t = new Set(e);
|
|
1560
1518
|
return Array.from(t).sort(Ee);
|
|
1561
1519
|
}
|
|
1562
|
-
function
|
|
1520
|
+
function ea(o) {
|
|
1563
1521
|
const e = /* @__PURE__ */ new Set();
|
|
1564
|
-
for (let r = 0, i =
|
|
1565
|
-
const
|
|
1566
|
-
for (const a in
|
|
1567
|
-
const l =
|
|
1522
|
+
for (let r = 0, i = o.length; r < i; r++) {
|
|
1523
|
+
const s = o[r];
|
|
1524
|
+
for (const a in s) {
|
|
1525
|
+
const l = s[a];
|
|
1568
1526
|
l && l.isTexture && e.add(l);
|
|
1569
1527
|
}
|
|
1570
1528
|
}
|
|
1571
1529
|
const t = Array.from(e);
|
|
1572
|
-
return
|
|
1530
|
+
return Zr(t).sort(Ee);
|
|
1573
1531
|
}
|
|
1574
|
-
function
|
|
1532
|
+
function ta(o) {
|
|
1575
1533
|
const e = [];
|
|
1576
|
-
return
|
|
1534
|
+
return o.traverse((t) => {
|
|
1577
1535
|
t.visible && (t.isRectAreaLight || t.isSpotLight || t.isPointLight || t.isDirectionalLight) && e.push(t);
|
|
1578
1536
|
}), e.sort(Ee);
|
|
1579
1537
|
}
|
|
1580
|
-
const
|
|
1581
|
-
class
|
|
1538
|
+
const It = 45, Je = It * 4;
|
|
1539
|
+
class ra {
|
|
1582
1540
|
constructor() {
|
|
1583
1541
|
this._features = {};
|
|
1584
1542
|
}
|
|
@@ -1592,22 +1550,22 @@ class oa {
|
|
|
1592
1550
|
this._features = {};
|
|
1593
1551
|
}
|
|
1594
1552
|
}
|
|
1595
|
-
class
|
|
1553
|
+
class aa extends F {
|
|
1596
1554
|
constructor() {
|
|
1597
|
-
super(new Float32Array(4), 1, 1), this.format = I, this.type = R, this.wrapS =
|
|
1555
|
+
super(new Float32Array(4), 1, 1), this.format = I, this.type = R, this.wrapS = B, this.wrapT = B, this.minFilter = T, this.magFilter = T, this.generateMipmaps = !1, this.features = new ra();
|
|
1598
1556
|
}
|
|
1599
1557
|
updateFrom(e, t) {
|
|
1600
1558
|
function r(m, g, c = -1) {
|
|
1601
1559
|
if (g in m && m[g]) {
|
|
1602
|
-
const p =
|
|
1603
|
-
return
|
|
1560
|
+
const p = Ce(m[g]);
|
|
1561
|
+
return f[p];
|
|
1604
1562
|
} else
|
|
1605
1563
|
return c;
|
|
1606
1564
|
}
|
|
1607
1565
|
function i(m, g, c) {
|
|
1608
1566
|
return g in m ? m[g] : c;
|
|
1609
1567
|
}
|
|
1610
|
-
function
|
|
1568
|
+
function s(m, g, c, p) {
|
|
1611
1569
|
const v = m[g] && m[g].isTexture ? m[g] : null;
|
|
1612
1570
|
if (v) {
|
|
1613
1571
|
v.matrixAutoUpdate && v.updateMatrix();
|
|
@@ -1618,19 +1576,19 @@ class na extends M {
|
|
|
1618
1576
|
return 8;
|
|
1619
1577
|
}
|
|
1620
1578
|
let a = 0;
|
|
1621
|
-
const l = e.length *
|
|
1579
|
+
const l = e.length * It, u = Math.ceil(Math.sqrt(l)) || 1, { image: d, features: h } = this, f = {};
|
|
1622
1580
|
for (let m = 0, g = t.length; m < g; m++)
|
|
1623
|
-
|
|
1624
|
-
d.width !==
|
|
1581
|
+
f[Ce(t[m])] = m;
|
|
1582
|
+
d.width !== u && (this.dispose(), d.data = new Float32Array(u * u * 4), d.width = u, d.height = u);
|
|
1625
1583
|
const n = d.data;
|
|
1626
|
-
|
|
1584
|
+
h.reset();
|
|
1627
1585
|
for (let m = 0, g = e.length; m < g; m++) {
|
|
1628
1586
|
const c = e[m];
|
|
1629
1587
|
if (c.isFogVolumeMaterial) {
|
|
1630
|
-
|
|
1631
|
-
for (let b = 0; b <
|
|
1588
|
+
h.setUsed("FOG");
|
|
1589
|
+
for (let b = 0; b < Je; b++)
|
|
1632
1590
|
n[a + b] = 0;
|
|
1633
|
-
n[a + 0 + 0] = c.color.r, n[a + 0 + 1] = c.color.g, n[a + 0 + 2] = c.color.b, n[a + 8 + 3] = i(c, "emissiveIntensity", 0), n[a + 12 + 0] = c.emissive.r, n[a + 12 + 1] = c.emissive.g, n[a + 12 + 2] = c.emissive.b, n[a + 52 + 1] = c.density, n[a + 52 + 3] = 0, n[a + 56 + 2] = 4, a +=
|
|
1591
|
+
n[a + 0 + 0] = c.color.r, n[a + 0 + 1] = c.color.g, n[a + 0 + 2] = c.color.b, n[a + 8 + 3] = i(c, "emissiveIntensity", 0), n[a + 12 + 0] = c.emissive.r, n[a + 12 + 1] = c.emissive.g, n[a + 12 + 2] = c.emissive.b, n[a + 52 + 1] = c.density, n[a + 52 + 3] = 0, n[a + 56 + 2] = 4, a += Je;
|
|
1634
1592
|
continue;
|
|
1635
1593
|
}
|
|
1636
1594
|
n[a++] = c.color.r, n[a++] = c.color.g, n[a++] = c.color.b, n[a++] = r(c, "map"), n[a++] = i(c, "metalness", 0), n[a++] = r(c, "metalnessMap"), n[a++] = i(c, "roughness", 0), n[a++] = r(c, "roughnessMap"), n[a++] = i(c, "ior", 1.5), n[a++] = i(c, "transmission", 0), n[a++] = r(c, "transmissionMap"), n[a++] = i(c, "emissiveIntensity", 0), "emissive" in c ? (n[a++] = c.emissive.r, n[a++] = c.emissive.g, n[a++] = c.emissive.b) : (n[a++] = 0, n[a++] = 0, n[a++] = 0), n[a++] = r(c, "emissiveMap"), n[a++] = r(c, "normalMap"), "normalScale" in c ? (n[a++] = c.normalScale.x, n[a++] = c.normalScale.y) : (n[a++] = 1, n[a++] = 1), n[a++] = i(c, "clearcoat", 0), n[a++] = r(c, "clearcoatMap"), n[a++] = i(c, "clearcoatRoughness", 0), n[a++] = r(c, "clearcoatRoughnessMap"), n[a++] = r(c, "clearcoatNormalMap"), "clearcoatNormalScale" in c ? (n[a++] = c.clearcoatNormalScale.x, n[a++] = c.clearcoatNormalScale.y) : (n[a++] = 1, n[a++] = 1), a++, n[a++] = i(c, "sheen", 0), "sheenColor" in c ? (n[a++] = c.sheenColor.r, n[a++] = c.sheenColor.g, n[a++] = c.sheenColor.b) : (n[a++] = 0, n[a++] = 0, n[a++] = 0), n[a++] = r(c, "sheenColorMap"), n[a++] = i(c, "sheenRoughness", 0), n[a++] = r(c, "sheenRoughnessMap"), n[a++] = r(c, "iridescenceMap"), n[a++] = r(c, "iridescenceThicknessMap"), n[a++] = i(c, "iridescence", 0), n[a++] = i(c, "iridescenceIOR", 1.3);
|
|
@@ -1641,66 +1599,66 @@ class na extends M {
|
|
|
1641
1599
|
n[a++] = 0;
|
|
1642
1600
|
else
|
|
1643
1601
|
switch (c.side) {
|
|
1644
|
-
case
|
|
1602
|
+
case Ht:
|
|
1645
1603
|
n[a++] = 1;
|
|
1646
1604
|
break;
|
|
1647
|
-
case
|
|
1605
|
+
case zt:
|
|
1648
1606
|
n[a++] = -1;
|
|
1649
1607
|
break;
|
|
1650
|
-
case
|
|
1608
|
+
case Nt:
|
|
1651
1609
|
n[a++] = 0;
|
|
1652
1610
|
break;
|
|
1653
1611
|
}
|
|
1654
|
-
n[a++] = Number(i(c, "matte", !1)), n[a++] = Number(i(c, "castShadow", !0)), n[a++] = Number(c.vertexColors) | Number(c.flatShading) << 1, n[a++] = Number(c.transparent), a +=
|
|
1612
|
+
n[a++] = Number(i(c, "matte", !1)), n[a++] = Number(i(c, "castShadow", !0)), n[a++] = Number(c.vertexColors) | Number(c.flatShading) << 1, n[a++] = Number(c.transparent), a += s(c, "map", n, a), a += s(c, "metalnessMap", n, a), a += s(c, "roughnessMap", n, a), a += s(c, "transmissionMap", n, a), a += s(c, "emissiveMap", n, a), a += s(c, "normalMap", n, a), a += s(c, "clearcoatMap", n, a), a += s(c, "clearcoatNormalMap", n, a), a += s(c, "clearcoatRoughnessMap", n, a), a += s(c, "sheenColorMap", n, a), a += s(c, "sheenRoughnessMap", n, a), a += s(c, "iridescenceMap", n, a), a += s(c, "iridescenceThicknessMap", n, a), a += s(c, "specularColorMap", n, a), a += s(c, "specularIntensityMap", n, a);
|
|
1655
1613
|
}
|
|
1656
1614
|
const x = De(n.buffer);
|
|
1657
1615
|
return this.hash !== x ? (this.hash = x, this.needsUpdate = !0, !0) : !1;
|
|
1658
1616
|
}
|
|
1659
1617
|
}
|
|
1660
|
-
const
|
|
1661
|
-
function
|
|
1662
|
-
return
|
|
1618
|
+
const et = new oe();
|
|
1619
|
+
function ia(o) {
|
|
1620
|
+
return o ? `${o.uuid}:${o.version}` : null;
|
|
1663
1621
|
}
|
|
1664
|
-
function
|
|
1622
|
+
function sa(o, e) {
|
|
1665
1623
|
for (const t in e)
|
|
1666
|
-
t in
|
|
1624
|
+
t in o && (o[t] = e[t]);
|
|
1667
1625
|
}
|
|
1668
|
-
class
|
|
1626
|
+
class tt extends Bt {
|
|
1669
1627
|
constructor(e, t, r) {
|
|
1670
1628
|
const i = {
|
|
1671
1629
|
format: I,
|
|
1672
1630
|
type: Me,
|
|
1673
|
-
minFilter:
|
|
1674
|
-
magFilter:
|
|
1675
|
-
wrapS:
|
|
1676
|
-
wrapT:
|
|
1631
|
+
minFilter: D,
|
|
1632
|
+
magFilter: D,
|
|
1633
|
+
wrapS: H,
|
|
1634
|
+
wrapT: H,
|
|
1677
1635
|
generateMipmaps: !1,
|
|
1678
1636
|
...r
|
|
1679
1637
|
};
|
|
1680
|
-
super(e, t, 1, i),
|
|
1638
|
+
super(e, t, 1, i), sa(this.texture, i), this.texture.setTextures = (...a) => {
|
|
1681
1639
|
this.setTextures(...a);
|
|
1682
1640
|
}, this.hashes = [null];
|
|
1683
|
-
const
|
|
1684
|
-
this.fsQuad =
|
|
1641
|
+
const s = new Y(new oa());
|
|
1642
|
+
this.fsQuad = s;
|
|
1685
1643
|
}
|
|
1686
1644
|
setTextures(e, t, r = this.width, i = this.height) {
|
|
1687
|
-
const
|
|
1688
|
-
e.getClearColor(
|
|
1689
|
-
const
|
|
1690
|
-
(r !== this.width || i !== this.height || this.depth !==
|
|
1691
|
-
const d = this.fsQuad,
|
|
1692
|
-
let
|
|
1693
|
-
for (let n = 0, x =
|
|
1694
|
-
const m = t[n], g =
|
|
1695
|
-
m && (
|
|
1645
|
+
const s = e.getRenderTarget(), a = e.toneMapping, l = e.getClearAlpha();
|
|
1646
|
+
e.getClearColor(et);
|
|
1647
|
+
const u = t.length || 1;
|
|
1648
|
+
(r !== this.width || i !== this.height || this.depth !== u) && (this.setSize(r, i, u), this.hashes = new Array(u).fill(null)), e.setClearColor(0, 0), e.toneMapping = Wt;
|
|
1649
|
+
const d = this.fsQuad, h = this.hashes;
|
|
1650
|
+
let f = !1;
|
|
1651
|
+
for (let n = 0, x = u; n < x; n++) {
|
|
1652
|
+
const m = t[n], g = ia(m);
|
|
1653
|
+
m && (h[n] !== g || m.isWebGLRenderTarget) && (m.matrixAutoUpdate = !1, m.matrix.identity(), d.material.map = m, e.setRenderTarget(this, n), d.render(e), m.updateMatrix(), m.matrixAutoUpdate = !0, h[n] = g, f = !0);
|
|
1696
1654
|
}
|
|
1697
|
-
return d.material.map = null, e.setClearColor(
|
|
1655
|
+
return d.material.map = null, e.setClearColor(et, l), e.setRenderTarget(s), e.toneMapping = a, f;
|
|
1698
1656
|
}
|
|
1699
1657
|
dispose() {
|
|
1700
1658
|
super.dispose(), this.fsQuad.dispose();
|
|
1701
1659
|
}
|
|
1702
1660
|
}
|
|
1703
|
-
class
|
|
1661
|
+
class oa extends ge {
|
|
1704
1662
|
get map() {
|
|
1705
1663
|
return this.uniforms.map.value;
|
|
1706
1664
|
}
|
|
@@ -1739,60 +1697,60 @@ class ua extends ge {
|
|
|
1739
1697
|
});
|
|
1740
1698
|
}
|
|
1741
1699
|
}
|
|
1742
|
-
function
|
|
1743
|
-
for (let t =
|
|
1744
|
-
const r = Math.floor(e() * (t + 1)), i =
|
|
1745
|
-
|
|
1700
|
+
function na(o, e = Math.random()) {
|
|
1701
|
+
for (let t = o.length - 1; t > 0; t--) {
|
|
1702
|
+
const r = Math.floor(e() * (t + 1)), i = o[t];
|
|
1703
|
+
o[t] = o[r], o[r] = i;
|
|
1746
1704
|
}
|
|
1747
|
-
return
|
|
1705
|
+
return o;
|
|
1748
1706
|
}
|
|
1749
|
-
class
|
|
1707
|
+
class la {
|
|
1750
1708
|
constructor(e, t, r = Math.random) {
|
|
1751
|
-
const i = e ** t,
|
|
1709
|
+
const i = e ** t, s = new Uint16Array(i);
|
|
1752
1710
|
let a = i;
|
|
1753
1711
|
for (let l = 0; l < i; l++)
|
|
1754
|
-
|
|
1712
|
+
s[l] = l;
|
|
1755
1713
|
this.samples = new Float32Array(t), this.strataCount = e, this.reset = function() {
|
|
1756
1714
|
for (let l = 0; l < i; l++)
|
|
1757
|
-
|
|
1715
|
+
s[l] = l;
|
|
1758
1716
|
a = 0;
|
|
1759
1717
|
}, this.reshuffle = function() {
|
|
1760
1718
|
a = 0;
|
|
1761
1719
|
}, this.next = function() {
|
|
1762
1720
|
const { samples: l } = this;
|
|
1763
|
-
a >=
|
|
1764
|
-
let
|
|
1721
|
+
a >= s.length && (na(s, r), this.reshuffle());
|
|
1722
|
+
let u = s[a++];
|
|
1765
1723
|
for (let d = 0; d < t; d++)
|
|
1766
|
-
l[d] = (
|
|
1724
|
+
l[d] = (u % e + r()) / e, u = Math.floor(u / e);
|
|
1767
1725
|
return l;
|
|
1768
1726
|
};
|
|
1769
1727
|
}
|
|
1770
1728
|
}
|
|
1771
|
-
class
|
|
1729
|
+
class ca {
|
|
1772
1730
|
constructor(e, t, r = Math.random) {
|
|
1773
1731
|
let i = 0;
|
|
1774
|
-
for (const
|
|
1775
|
-
i +=
|
|
1776
|
-
const
|
|
1732
|
+
for (const u of t)
|
|
1733
|
+
i += u;
|
|
1734
|
+
const s = new Float32Array(i), a = [];
|
|
1777
1735
|
let l = 0;
|
|
1778
|
-
for (const
|
|
1779
|
-
const d = new
|
|
1780
|
-
d.samples = new Float32Array(
|
|
1736
|
+
for (const u of t) {
|
|
1737
|
+
const d = new la(e, u, r);
|
|
1738
|
+
d.samples = new Float32Array(s.buffer, l, d.samples.length), l += d.samples.length * 4, a.push(d);
|
|
1781
1739
|
}
|
|
1782
|
-
this.samples =
|
|
1783
|
-
for (const
|
|
1784
|
-
|
|
1785
|
-
return
|
|
1740
|
+
this.samples = s, this.strataCount = e, this.next = function() {
|
|
1741
|
+
for (const u of a)
|
|
1742
|
+
u.next();
|
|
1743
|
+
return s;
|
|
1786
1744
|
}, this.reshuffle = function() {
|
|
1787
|
-
for (const
|
|
1788
|
-
|
|
1745
|
+
for (const u of a)
|
|
1746
|
+
u.reshuffle();
|
|
1789
1747
|
}, this.reset = function() {
|
|
1790
|
-
for (const
|
|
1791
|
-
|
|
1748
|
+
for (const u of a)
|
|
1749
|
+
u.reset();
|
|
1792
1750
|
};
|
|
1793
1751
|
}
|
|
1794
1752
|
}
|
|
1795
|
-
class
|
|
1753
|
+
class ua {
|
|
1796
1754
|
constructor(e = 0) {
|
|
1797
1755
|
this.m = 2147483648, this.a = 1103515245, this.c = 12345, this.seed = e;
|
|
1798
1756
|
}
|
|
@@ -1803,15 +1761,15 @@ class ma {
|
|
|
1803
1761
|
return this.nextInt() / (this.m - 1);
|
|
1804
1762
|
}
|
|
1805
1763
|
}
|
|
1806
|
-
class
|
|
1764
|
+
class fa extends F {
|
|
1807
1765
|
constructor(e = 1, t = 1, r = 8) {
|
|
1808
|
-
super(new Float32Array(1), 1, 1, I, R), this.minFilter = T, this.magFilter = T, this.strata = r, this.sampler = null, this.generator = new
|
|
1766
|
+
super(new Float32Array(1), 1, 1, I, R), this.minFilter = T, this.magFilter = T, this.strata = r, this.sampler = null, this.generator = new ua(), this.stableNoise = !1, this.random = () => this.stableNoise ? this.generator.nextFloat() : Math.random(), this.init(e, t, r);
|
|
1809
1767
|
}
|
|
1810
1768
|
init(e = this.image.height, t = this.image.width, r = this.strata) {
|
|
1811
1769
|
const { image: i } = this;
|
|
1812
1770
|
if (i.width === t && i.height === e && this.sampler !== null)
|
|
1813
1771
|
return;
|
|
1814
|
-
const
|
|
1772
|
+
const s = new Array(e * t).fill(4), a = new ca(r, s, this.random);
|
|
1815
1773
|
i.width = t, i.height = e, i.data = a.samples, this.sampler = a, this.dispose(), this.next();
|
|
1816
1774
|
}
|
|
1817
1775
|
next() {
|
|
@@ -1821,51 +1779,51 @@ class pa extends M {
|
|
|
1821
1779
|
this.sampler.reset(), this.generator.seed = 0;
|
|
1822
1780
|
}
|
|
1823
1781
|
}
|
|
1824
|
-
function
|
|
1825
|
-
for (let t =
|
|
1826
|
-
const r = ~~((e() - 1e-6) * t), i =
|
|
1827
|
-
|
|
1782
|
+
function ha(o, e = Math.random) {
|
|
1783
|
+
for (let t = o.length - 1; t > 0; t--) {
|
|
1784
|
+
const r = ~~((e() - 1e-6) * t), i = o[t];
|
|
1785
|
+
o[t] = o[r], o[r] = i;
|
|
1828
1786
|
}
|
|
1829
1787
|
}
|
|
1830
|
-
function
|
|
1831
|
-
|
|
1788
|
+
function da(o, e) {
|
|
1789
|
+
o.fill(0);
|
|
1832
1790
|
for (let t = 0; t < e; t++)
|
|
1833
|
-
|
|
1791
|
+
o[t] = 1;
|
|
1834
1792
|
}
|
|
1835
|
-
class
|
|
1793
|
+
class rt {
|
|
1836
1794
|
constructor(e) {
|
|
1837
1795
|
this.count = 0, this.size = -1, this.sigma = -1, this.radius = -1, this.lookupTable = null, this.score = null, this.binaryPattern = null, this.resize(e), this.setSigma(1.5);
|
|
1838
1796
|
}
|
|
1839
1797
|
findVoid() {
|
|
1840
1798
|
const { score: e, binaryPattern: t } = this;
|
|
1841
1799
|
let r = 1 / 0, i = -1;
|
|
1842
|
-
for (let
|
|
1843
|
-
if (t[
|
|
1800
|
+
for (let s = 0, a = t.length; s < a; s++) {
|
|
1801
|
+
if (t[s] !== 0)
|
|
1844
1802
|
continue;
|
|
1845
|
-
const l = e[
|
|
1846
|
-
l < r && (r = l, i =
|
|
1803
|
+
const l = e[s];
|
|
1804
|
+
l < r && (r = l, i = s);
|
|
1847
1805
|
}
|
|
1848
1806
|
return i;
|
|
1849
1807
|
}
|
|
1850
1808
|
findCluster() {
|
|
1851
1809
|
const { score: e, binaryPattern: t } = this;
|
|
1852
1810
|
let r = -1 / 0, i = -1;
|
|
1853
|
-
for (let
|
|
1854
|
-
if (t[
|
|
1811
|
+
for (let s = 0, a = t.length; s < a; s++) {
|
|
1812
|
+
if (t[s] !== 1)
|
|
1855
1813
|
continue;
|
|
1856
|
-
const l = e[
|
|
1857
|
-
l > r && (r = l, i =
|
|
1814
|
+
const l = e[s];
|
|
1815
|
+
l > r && (r = l, i = s);
|
|
1858
1816
|
}
|
|
1859
1817
|
return i;
|
|
1860
1818
|
}
|
|
1861
1819
|
setSigma(e) {
|
|
1862
1820
|
if (e === this.sigma)
|
|
1863
1821
|
return;
|
|
1864
|
-
const t = ~~(Math.sqrt(20 * e ** 2) + 1), r = 2 * t + 1, i = new Float32Array(r * r),
|
|
1822
|
+
const t = ~~(Math.sqrt(20 * e ** 2) + 1), r = 2 * t + 1, i = new Float32Array(r * r), s = e * e;
|
|
1865
1823
|
for (let a = -t; a <= t; a++)
|
|
1866
1824
|
for (let l = -t; l <= t; l++) {
|
|
1867
|
-
const
|
|
1868
|
-
i[
|
|
1825
|
+
const u = (t + l) * r + a + t, d = a * a + l * l;
|
|
1826
|
+
i[u] = Math.E ** (-d / (2 * s));
|
|
1869
1827
|
}
|
|
1870
1828
|
this.lookupTable = i, this.sigma = e, this.radius = t;
|
|
1871
1829
|
}
|
|
@@ -1875,7 +1833,7 @@ class at {
|
|
|
1875
1833
|
invert() {
|
|
1876
1834
|
const { binaryPattern: e, score: t, size: r } = this;
|
|
1877
1835
|
t.fill(0);
|
|
1878
|
-
for (let i = 0,
|
|
1836
|
+
for (let i = 0, s = e.length; i < s; i++)
|
|
1879
1837
|
if (e[i] === 0) {
|
|
1880
1838
|
const a = ~~(i / r), l = i - a * r;
|
|
1881
1839
|
this.updateScore(l, a, 1), e[i] = 1;
|
|
@@ -1883,16 +1841,16 @@ class at {
|
|
|
1883
1841
|
e[i] = 0;
|
|
1884
1842
|
}
|
|
1885
1843
|
updateScore(e, t, r) {
|
|
1886
|
-
const { size: i, score:
|
|
1844
|
+
const { size: i, score: s, lookupTable: a } = this, l = this.radius, u = 2 * l + 1;
|
|
1887
1845
|
for (let d = -l; d <= l; d++)
|
|
1888
|
-
for (let
|
|
1889
|
-
const
|
|
1846
|
+
for (let h = -l; h <= l; h++) {
|
|
1847
|
+
const f = (l + h) * u + d + l, n = a[f];
|
|
1890
1848
|
let x = e + d;
|
|
1891
1849
|
x = x < 0 ? i + x : x % i;
|
|
1892
|
-
let m = t +
|
|
1850
|
+
let m = t + h;
|
|
1893
1851
|
m = m < 0 ? i + m : m % i;
|
|
1894
1852
|
const g = m * i + x;
|
|
1895
|
-
|
|
1853
|
+
s[g] += r * n;
|
|
1896
1854
|
}
|
|
1897
1855
|
}
|
|
1898
1856
|
addPointIndex(e) {
|
|
@@ -1909,9 +1867,9 @@ class at {
|
|
|
1909
1867
|
this.resize(e.size), this.score.set(e.score), this.binaryPattern.set(e.binaryPattern), this.setSigma(e.sigma), this.count = e.count;
|
|
1910
1868
|
}
|
|
1911
1869
|
}
|
|
1912
|
-
class
|
|
1870
|
+
class ma {
|
|
1913
1871
|
constructor() {
|
|
1914
|
-
this.random = Math.random, this.sigma = 1.5, this.size = 64, this.majorityPointsRatio = 0.1, this.samples = new
|
|
1872
|
+
this.random = Math.random, this.sigma = 1.5, this.size = 64, this.majorityPointsRatio = 0.1, this.samples = new rt(1), this.savedSamples = new rt(1);
|
|
1915
1873
|
}
|
|
1916
1874
|
generate() {
|
|
1917
1875
|
const {
|
|
@@ -1919,76 +1877,76 @@ class xa {
|
|
|
1919
1877
|
savedSamples: t,
|
|
1920
1878
|
sigma: r,
|
|
1921
1879
|
majorityPointsRatio: i,
|
|
1922
|
-
size:
|
|
1880
|
+
size: s
|
|
1923
1881
|
} = this;
|
|
1924
|
-
e.resize(
|
|
1925
|
-
const a = Math.floor(
|
|
1926
|
-
|
|
1927
|
-
for (let
|
|
1928
|
-
l[
|
|
1882
|
+
e.resize(s), e.setSigma(r);
|
|
1883
|
+
const a = Math.floor(s * s * i), l = e.binaryPattern;
|
|
1884
|
+
da(l, a), ha(l, this.random);
|
|
1885
|
+
for (let f = 0, n = l.length; f < n; f++)
|
|
1886
|
+
l[f] === 1 && e.addPointIndex(f);
|
|
1929
1887
|
for (; ; ) {
|
|
1930
|
-
const
|
|
1931
|
-
e.removePointIndex(
|
|
1888
|
+
const f = e.findCluster();
|
|
1889
|
+
e.removePointIndex(f);
|
|
1932
1890
|
const n = e.findVoid();
|
|
1933
|
-
if (
|
|
1934
|
-
e.addPointIndex(
|
|
1891
|
+
if (f === n) {
|
|
1892
|
+
e.addPointIndex(f);
|
|
1935
1893
|
break;
|
|
1936
1894
|
}
|
|
1937
1895
|
e.addPointIndex(n);
|
|
1938
1896
|
}
|
|
1939
|
-
const
|
|
1897
|
+
const u = new Uint32Array(s * s);
|
|
1940
1898
|
t.copy(e);
|
|
1941
1899
|
let d;
|
|
1942
1900
|
for (d = e.count - 1; d >= 0; ) {
|
|
1943
|
-
const
|
|
1944
|
-
e.removePointIndex(
|
|
1901
|
+
const f = e.findCluster();
|
|
1902
|
+
e.removePointIndex(f), u[f] = d, d--;
|
|
1945
1903
|
}
|
|
1946
|
-
const
|
|
1947
|
-
for (d = t.count; d <
|
|
1948
|
-
const
|
|
1949
|
-
t.addPointIndex(
|
|
1904
|
+
const h = s * s;
|
|
1905
|
+
for (d = t.count; d < h / 2; ) {
|
|
1906
|
+
const f = t.findVoid();
|
|
1907
|
+
t.addPointIndex(f), u[f] = d, d++;
|
|
1950
1908
|
}
|
|
1951
|
-
for (t.invert(); d <
|
|
1952
|
-
const
|
|
1953
|
-
t.removePointIndex(
|
|
1909
|
+
for (t.invert(); d < h; ) {
|
|
1910
|
+
const f = t.findCluster();
|
|
1911
|
+
t.removePointIndex(f), u[f] = d, d++;
|
|
1954
1912
|
}
|
|
1955
|
-
return { data:
|
|
1913
|
+
return { data: u, maxValue: h };
|
|
1956
1914
|
}
|
|
1957
1915
|
}
|
|
1958
|
-
function
|
|
1959
|
-
return
|
|
1916
|
+
function pa(o) {
|
|
1917
|
+
return o >= 3 ? 4 : o;
|
|
1960
1918
|
}
|
|
1961
|
-
function
|
|
1962
|
-
switch (
|
|
1919
|
+
function ga(o) {
|
|
1920
|
+
switch (o) {
|
|
1963
1921
|
case 1:
|
|
1964
|
-
return
|
|
1922
|
+
return pe;
|
|
1965
1923
|
case 2:
|
|
1966
|
-
return
|
|
1924
|
+
return ht;
|
|
1967
1925
|
default:
|
|
1968
1926
|
return I;
|
|
1969
1927
|
}
|
|
1970
1928
|
}
|
|
1971
|
-
class
|
|
1929
|
+
class va extends F {
|
|
1972
1930
|
constructor(e = 64, t = 1) {
|
|
1973
1931
|
super(new Float32Array(4), 1, 1, I, R), this.minFilter = T, this.magFilter = T, this.size = e, this.channels = t, this.update();
|
|
1974
1932
|
}
|
|
1975
1933
|
update() {
|
|
1976
|
-
const e = this.channels, t = this.size, r = new
|
|
1934
|
+
const e = this.channels, t = this.size, r = new ma();
|
|
1977
1935
|
r.channels = e, r.size = t;
|
|
1978
|
-
const i =
|
|
1979
|
-
(this.image.width !== t ||
|
|
1936
|
+
const i = pa(e), s = ga(i);
|
|
1937
|
+
(this.image.width !== t || s !== this.format) && (this.image.width = t, this.image.height = t, this.image.data = new Float32Array(t ** 2 * i), this.format = s, this.dispose());
|
|
1980
1938
|
const a = this.image.data;
|
|
1981
|
-
for (let l = 0,
|
|
1982
|
-
const d = r.generate(),
|
|
1983
|
-
for (let n = 0, x =
|
|
1984
|
-
const m =
|
|
1939
|
+
for (let l = 0, u = e; l < u; l++) {
|
|
1940
|
+
const d = r.generate(), h = d.data, f = d.maxValue;
|
|
1941
|
+
for (let n = 0, x = h.length; n < x; n++) {
|
|
1942
|
+
const m = h[n] / f;
|
|
1985
1943
|
a[n * i + l] = m;
|
|
1986
1944
|
}
|
|
1987
1945
|
}
|
|
1988
1946
|
this.needsUpdate = !0;
|
|
1989
1947
|
}
|
|
1990
1948
|
}
|
|
1991
|
-
const
|
|
1949
|
+
const xa = (
|
|
1992
1950
|
/* glsl */
|
|
1993
1951
|
`
|
|
1994
1952
|
|
|
@@ -2003,7 +1961,7 @@ const wa = (
|
|
|
2003
1961
|
};
|
|
2004
1962
|
|
|
2005
1963
|
`
|
|
2006
|
-
),
|
|
1964
|
+
), ba = (
|
|
2007
1965
|
/* glsl */
|
|
2008
1966
|
`
|
|
2009
1967
|
|
|
@@ -2018,7 +1976,7 @@ const wa = (
|
|
|
2018
1976
|
};
|
|
2019
1977
|
|
|
2020
1978
|
`
|
|
2021
|
-
),
|
|
1979
|
+
), ya = (
|
|
2022
1980
|
/* glsl */
|
|
2023
1981
|
`
|
|
2024
1982
|
|
|
@@ -2107,7 +2065,7 @@ const wa = (
|
|
|
2107
2065
|
}
|
|
2108
2066
|
|
|
2109
2067
|
`
|
|
2110
|
-
),
|
|
2068
|
+
), Ta = (
|
|
2111
2069
|
/* glsl */
|
|
2112
2070
|
`
|
|
2113
2071
|
|
|
@@ -2317,7 +2275,7 @@ const wa = (
|
|
|
2317
2275
|
}
|
|
2318
2276
|
|
|
2319
2277
|
`
|
|
2320
|
-
),
|
|
2278
|
+
), wa = (
|
|
2321
2279
|
/* glsl */
|
|
2322
2280
|
`
|
|
2323
2281
|
|
|
@@ -2382,7 +2340,7 @@ const wa = (
|
|
|
2382
2340
|
};
|
|
2383
2341
|
|
|
2384
2342
|
`
|
|
2385
|
-
),
|
|
2343
|
+
), Ia = (
|
|
2386
2344
|
/* glsl */
|
|
2387
2345
|
`
|
|
2388
2346
|
|
|
@@ -2452,7 +2410,7 @@ const wa = (
|
|
|
2452
2410
|
|
|
2453
2411
|
}
|
|
2454
2412
|
`
|
|
2455
|
-
),
|
|
2413
|
+
), Ra = (
|
|
2456
2414
|
/* glsl */
|
|
2457
2415
|
`
|
|
2458
2416
|
|
|
@@ -2670,7 +2628,7 @@ const wa = (
|
|
|
2670
2628
|
}
|
|
2671
2629
|
|
|
2672
2630
|
`
|
|
2673
|
-
),
|
|
2631
|
+
), _a = (
|
|
2674
2632
|
/* glsl */
|
|
2675
2633
|
`
|
|
2676
2634
|
|
|
@@ -2758,7 +2716,7 @@ const wa = (
|
|
|
2758
2716
|
|
|
2759
2717
|
|
|
2760
2718
|
`
|
|
2761
|
-
),
|
|
2719
|
+
), Sa = (
|
|
2762
2720
|
/* glsl */
|
|
2763
2721
|
`
|
|
2764
2722
|
|
|
@@ -2864,7 +2822,7 @@ const wa = (
|
|
|
2864
2822
|
}
|
|
2865
2823
|
|
|
2866
2824
|
`
|
|
2867
|
-
),
|
|
2825
|
+
), Ma = (
|
|
2868
2826
|
/* glsl */
|
|
2869
2827
|
`
|
|
2870
2828
|
|
|
@@ -2947,7 +2905,7 @@ const wa = (
|
|
|
2947
2905
|
}
|
|
2948
2906
|
|
|
2949
2907
|
`
|
|
2950
|
-
),
|
|
2908
|
+
), Aa = (
|
|
2951
2909
|
/* glsl */
|
|
2952
2910
|
`
|
|
2953
2911
|
|
|
@@ -3011,7 +2969,7 @@ const wa = (
|
|
|
3011
2969
|
}
|
|
3012
2970
|
|
|
3013
2971
|
`
|
|
3014
|
-
),
|
|
2972
|
+
), Fa = (
|
|
3015
2973
|
/*glsl */
|
|
3016
2974
|
`
|
|
3017
2975
|
|
|
@@ -3037,7 +2995,7 @@ const wa = (
|
|
|
3037
2995
|
}
|
|
3038
2996
|
|
|
3039
2997
|
`
|
|
3040
|
-
),
|
|
2998
|
+
), Rt = (
|
|
3041
2999
|
/* glsl */
|
|
3042
3000
|
`
|
|
3043
3001
|
|
|
@@ -3155,7 +3113,7 @@ const wa = (
|
|
|
3155
3113
|
|
|
3156
3114
|
}
|
|
3157
3115
|
`
|
|
3158
|
-
),
|
|
3116
|
+
), at = (
|
|
3159
3117
|
/* glsl */
|
|
3160
3118
|
`
|
|
3161
3119
|
|
|
@@ -3214,7 +3172,7 @@ const wa = (
|
|
|
3214
3172
|
|
|
3215
3173
|
}
|
|
3216
3174
|
`
|
|
3217
|
-
),
|
|
3175
|
+
), Ca = (
|
|
3218
3176
|
/* glsl */
|
|
3219
3177
|
`
|
|
3220
3178
|
|
|
@@ -3266,7 +3224,7 @@ const wa = (
|
|
|
3266
3224
|
}
|
|
3267
3225
|
|
|
3268
3226
|
`
|
|
3269
|
-
),
|
|
3227
|
+
), Da = (
|
|
3270
3228
|
/* glsl */
|
|
3271
3229
|
`
|
|
3272
3230
|
|
|
@@ -3707,7 +3665,7 @@ const wa = (
|
|
|
3707
3665
|
}
|
|
3708
3666
|
|
|
3709
3667
|
`
|
|
3710
|
-
),
|
|
3668
|
+
), Pa = (
|
|
3711
3669
|
/* glsl */
|
|
3712
3670
|
`
|
|
3713
3671
|
|
|
@@ -3731,7 +3689,7 @@ const wa = (
|
|
|
3731
3689
|
}
|
|
3732
3690
|
|
|
3733
3691
|
`
|
|
3734
|
-
),
|
|
3692
|
+
), Ea = (
|
|
3735
3693
|
/* glsl */
|
|
3736
3694
|
`
|
|
3737
3695
|
|
|
@@ -3835,7 +3793,7 @@ const wa = (
|
|
|
3835
3793
|
}
|
|
3836
3794
|
|
|
3837
3795
|
`
|
|
3838
|
-
),
|
|
3796
|
+
), Oa = (
|
|
3839
3797
|
/* glsl */
|
|
3840
3798
|
`
|
|
3841
3799
|
|
|
@@ -3972,7 +3930,7 @@ const wa = (
|
|
|
3972
3930
|
}
|
|
3973
3931
|
|
|
3974
3932
|
`
|
|
3975
|
-
),
|
|
3933
|
+
), ka = (
|
|
3976
3934
|
/* glsl */
|
|
3977
3935
|
`
|
|
3978
3936
|
|
|
@@ -4072,7 +4030,7 @@ const wa = (
|
|
|
4072
4030
|
}
|
|
4073
4031
|
|
|
4074
4032
|
`
|
|
4075
|
-
),
|
|
4033
|
+
), Na = (
|
|
4076
4034
|
/* glsl */
|
|
4077
4035
|
`
|
|
4078
4036
|
|
|
@@ -4136,7 +4094,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4136
4094
|
}
|
|
4137
4095
|
|
|
4138
4096
|
`
|
|
4139
|
-
),
|
|
4097
|
+
), za = (
|
|
4140
4098
|
/* glsl */
|
|
4141
4099
|
`
|
|
4142
4100
|
|
|
@@ -4316,7 +4274,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4316
4274
|
}
|
|
4317
4275
|
|
|
4318
4276
|
`
|
|
4319
|
-
),
|
|
4277
|
+
), Ha = (
|
|
4320
4278
|
/* glsl */
|
|
4321
4279
|
`
|
|
4322
4280
|
|
|
@@ -4402,7 +4360,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4402
4360
|
}
|
|
4403
4361
|
|
|
4404
4362
|
`
|
|
4405
|
-
),
|
|
4363
|
+
), Ba = (
|
|
4406
4364
|
/*glsl*/
|
|
4407
4365
|
`
|
|
4408
4366
|
|
|
@@ -4501,7 +4459,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4501
4459
|
}
|
|
4502
4460
|
|
|
4503
4461
|
`
|
|
4504
|
-
),
|
|
4462
|
+
), Wa = (
|
|
4505
4463
|
/* glsl */
|
|
4506
4464
|
`
|
|
4507
4465
|
|
|
@@ -4826,7 +4784,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4826
4784
|
|
|
4827
4785
|
}
|
|
4828
4786
|
`
|
|
4829
|
-
),
|
|
4787
|
+
), La = (
|
|
4830
4788
|
/* glsl */
|
|
4831
4789
|
`
|
|
4832
4790
|
|
|
@@ -4878,7 +4836,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4878
4836
|
}
|
|
4879
4837
|
|
|
4880
4838
|
`
|
|
4881
|
-
),
|
|
4839
|
+
), Ua = (
|
|
4882
4840
|
/* glsl */
|
|
4883
4841
|
`
|
|
4884
4842
|
|
|
@@ -4929,7 +4887,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4929
4887
|
|
|
4930
4888
|
`
|
|
4931
4889
|
);
|
|
4932
|
-
class
|
|
4890
|
+
class Ga extends Pe {
|
|
4933
4891
|
onBeforeRender() {
|
|
4934
4892
|
this.setDefine("FEATURE_DOF", this.physicalCamera.bokehSize === 0 ? 0 : 1), this.setDefine("FEATURE_BACKGROUND_MAP", this.backgroundMap ? 1 : 0), this.setDefine("FEATURE_FOG", this.materials.features.isUsed("FOG") ? 1 : 0);
|
|
4935
4893
|
}
|
|
@@ -4959,42 +4917,42 @@ class ja extends Pe {
|
|
|
4959
4917
|
},
|
|
4960
4918
|
uniforms: {
|
|
4961
4919
|
// path trace uniforms
|
|
4962
|
-
resolution: { value: new
|
|
4920
|
+
resolution: { value: new X() },
|
|
4963
4921
|
opacity: { value: 1 },
|
|
4964
4922
|
bounces: { value: 10 },
|
|
4965
4923
|
transmissiveBounces: { value: 10 },
|
|
4966
4924
|
filterGlossyFactor: { value: 0 },
|
|
4967
4925
|
// camera uniforms
|
|
4968
|
-
physicalCamera: { value: new
|
|
4969
|
-
cameraWorldMatrix: { value: new
|
|
4970
|
-
invProjectionMatrix: { value: new
|
|
4926
|
+
physicalCamera: { value: new Br() },
|
|
4927
|
+
cameraWorldMatrix: { value: new z() },
|
|
4928
|
+
invProjectionMatrix: { value: new z() },
|
|
4971
4929
|
// scene uniforms
|
|
4972
|
-
bvh: { value: new
|
|
4973
|
-
attributesArray: { value: new
|
|
4974
|
-
materialIndexAttribute: { value: new
|
|
4975
|
-
materials: { value: new
|
|
4976
|
-
textures: { value: new
|
|
4930
|
+
bvh: { value: new lr() },
|
|
4931
|
+
attributesArray: { value: new Kr() },
|
|
4932
|
+
materialIndexAttribute: { value: new vt() },
|
|
4933
|
+
materials: { value: new aa() },
|
|
4934
|
+
textures: { value: new tt().texture },
|
|
4977
4935
|
// light uniforms
|
|
4978
|
-
lights: { value: new
|
|
4979
|
-
iesProfiles: { value: new
|
|
4980
|
-
type:
|
|
4981
|
-
wrapS:
|
|
4982
|
-
wrapT:
|
|
4936
|
+
lights: { value: new Xr() },
|
|
4937
|
+
iesProfiles: { value: new tt(360, 180, {
|
|
4938
|
+
type: E,
|
|
4939
|
+
wrapS: B,
|
|
4940
|
+
wrapT: B
|
|
4983
4941
|
}).texture },
|
|
4984
4942
|
environmentIntensity: { value: 1 },
|
|
4985
|
-
environmentRotation: { value: new
|
|
4986
|
-
envMapInfo: { value: new
|
|
4943
|
+
environmentRotation: { value: new z() },
|
|
4944
|
+
envMapInfo: { value: new Ur() },
|
|
4987
4945
|
// background uniforms
|
|
4988
4946
|
backgroundBlur: { value: 0 },
|
|
4989
4947
|
backgroundMap: { value: null },
|
|
4990
4948
|
backgroundAlpha: { value: 1 },
|
|
4991
4949
|
backgroundIntensity: { value: 1 },
|
|
4992
|
-
backgroundRotation: { value: new
|
|
4950
|
+
backgroundRotation: { value: new z() },
|
|
4993
4951
|
// randomness uniforms
|
|
4994
4952
|
seed: { value: 0 },
|
|
4995
4953
|
sobolTexture: { value: null },
|
|
4996
|
-
stratifiedTexture: { value: new
|
|
4997
|
-
stratifiedOffsetTexture: { value: new
|
|
4954
|
+
stratifiedTexture: { value: new fa() },
|
|
4955
|
+
stratifiedOffsetTexture: { value: new va(64, 1) }
|
|
4998
4956
|
},
|
|
4999
4957
|
vertexShader: (
|
|
5000
4958
|
/* glsl */
|
|
@@ -5027,26 +4985,26 @@ class ja extends Pe {
|
|
|
5027
4985
|
|
|
5028
4986
|
// bvh intersection
|
|
5029
4987
|
${fr}
|
|
5030
|
-
${mr}
|
|
5031
4988
|
${dr}
|
|
4989
|
+
${hr}
|
|
5032
4990
|
|
|
5033
4991
|
// uniform structs
|
|
4992
|
+
${xa}
|
|
4993
|
+
${ya}
|
|
4994
|
+
${ba}
|
|
4995
|
+
${Ta}
|
|
5034
4996
|
${wa}
|
|
5035
|
-
${Ra}
|
|
5036
|
-
${Ia}
|
|
5037
|
-
${_a}
|
|
5038
|
-
${Sa}
|
|
5039
4997
|
|
|
5040
4998
|
// random
|
|
5041
4999
|
#if RANDOM_TYPE == 2 // Stratified List
|
|
5042
5000
|
|
|
5043
|
-
${
|
|
5001
|
+
${Ca}
|
|
5044
5002
|
|
|
5045
5003
|
#elif RANDOM_TYPE == 1 // Sobol
|
|
5046
5004
|
|
|
5047
|
-
${
|
|
5048
|
-
${
|
|
5049
|
-
${
|
|
5005
|
+
${at}
|
|
5006
|
+
${wt}
|
|
5007
|
+
${kr}
|
|
5050
5008
|
|
|
5051
5009
|
#define rand(v) sobol(v)
|
|
5052
5010
|
#define rand2(v) sobol2(v)
|
|
@@ -5055,7 +5013,7 @@ class ja extends Pe {
|
|
|
5055
5013
|
|
|
5056
5014
|
#else // PCG
|
|
5057
5015
|
|
|
5058
|
-
${
|
|
5016
|
+
${at}
|
|
5059
5017
|
|
|
5060
5018
|
// Using the sobol functions seems to break the the compiler on MacOS
|
|
5061
5019
|
// - specifically the "sobolReverseBits" function.
|
|
@@ -5071,11 +5029,11 @@ class ja extends Pe {
|
|
|
5071
5029
|
#endif
|
|
5072
5030
|
|
|
5073
5031
|
// common
|
|
5074
|
-
${Ea}
|
|
5075
5032
|
${Fa}
|
|
5076
|
-
${
|
|
5077
|
-
${
|
|
5078
|
-
${
|
|
5033
|
+
${Sa}
|
|
5034
|
+
${Rt}
|
|
5035
|
+
${Ma}
|
|
5036
|
+
${Aa}
|
|
5079
5037
|
|
|
5080
5038
|
// environment
|
|
5081
5039
|
uniform EquirectHdrInfo envMapInfo;
|
|
@@ -5131,16 +5089,16 @@ class ja extends Pe {
|
|
|
5131
5089
|
float lightsDenom;
|
|
5132
5090
|
|
|
5133
5091
|
// sampling
|
|
5134
|
-
${
|
|
5135
|
-
${
|
|
5136
|
-
${
|
|
5092
|
+
${_a}
|
|
5093
|
+
${Ia}
|
|
5094
|
+
${Ra}
|
|
5137
5095
|
|
|
5138
|
-
${Wa}
|
|
5139
5096
|
${Na}
|
|
5140
|
-
${
|
|
5141
|
-
${
|
|
5142
|
-
${za}
|
|
5097
|
+
${Ea}
|
|
5098
|
+
${ka}
|
|
5143
5099
|
${Oa}
|
|
5100
|
+
${Pa}
|
|
5101
|
+
${Da}
|
|
5144
5102
|
|
|
5145
5103
|
float applyFilteredGlossy( float roughness, float accumulatedRoughness ) {
|
|
5146
5104
|
|
|
@@ -5172,12 +5130,12 @@ class ja extends Pe {
|
|
|
5172
5130
|
|
|
5173
5131
|
}
|
|
5174
5132
|
|
|
5175
|
-
${qa}
|
|
5176
|
-
${Ua}
|
|
5177
|
-
${$a}
|
|
5178
5133
|
${La}
|
|
5179
|
-
${
|
|
5180
|
-
${
|
|
5134
|
+
${Ha}
|
|
5135
|
+
${Ua}
|
|
5136
|
+
${za}
|
|
5137
|
+
${Ba}
|
|
5138
|
+
${Wa}
|
|
5181
5139
|
|
|
5182
5140
|
void main() {
|
|
5183
5141
|
|
|
@@ -5474,51 +5432,51 @@ class ja extends Pe {
|
|
|
5474
5432
|
}), this.setValues(e);
|
|
5475
5433
|
}
|
|
5476
5434
|
}
|
|
5477
|
-
function*
|
|
5435
|
+
function* Va() {
|
|
5478
5436
|
const {
|
|
5479
|
-
_renderer:
|
|
5437
|
+
_renderer: o,
|
|
5480
5438
|
_fsQuad: e,
|
|
5481
5439
|
_blendQuad: t,
|
|
5482
5440
|
_primaryTarget: r,
|
|
5483
5441
|
_blendTargets: i,
|
|
5484
|
-
_sobolTarget:
|
|
5442
|
+
_sobolTarget: s,
|
|
5485
5443
|
_subframe: a,
|
|
5486
5444
|
alpha: l,
|
|
5487
|
-
material:
|
|
5488
|
-
} = this, d = new
|
|
5445
|
+
material: u
|
|
5446
|
+
} = this, d = new te(), h = new te(), f = t.material;
|
|
5489
5447
|
let [n, x] = i;
|
|
5490
5448
|
for (; ; ) {
|
|
5491
|
-
l ? (
|
|
5449
|
+
l ? (f.opacity = this._opacityFactor / (this.samples + 1), u.blending = se, u.opacity = 1) : (u.opacity = this._opacityFactor / (this.samples + 1), u.blending = mt);
|
|
5492
5450
|
const [m, g, c, p] = a, v = r.width, b = r.height;
|
|
5493
|
-
|
|
5494
|
-
const y = this.tiles.x || 1, w = this.tiles.y || 1,
|
|
5495
|
-
for (let
|
|
5496
|
-
for (let
|
|
5497
|
-
const
|
|
5498
|
-
|
|
5499
|
-
let ye =
|
|
5451
|
+
u.resolution.set(v * c, b * p), u.sobolTexture = s.texture, u.stratifiedTexture.init(20, u.bounces + u.transmissiveBounces + 5), u.stratifiedTexture.next(), u.seed++;
|
|
5452
|
+
const y = this.tiles.x || 1, w = this.tiles.y || 1, k = y * w, W = Math.ceil(v * c), ve = Math.ceil(b * p), Oe = Math.floor(m * v), ke = Math.floor(g * b), xe = Math.ceil(W / y), be = Math.ceil(ve / w);
|
|
5453
|
+
for (let ne = 0; ne < w; ne++)
|
|
5454
|
+
for (let le = 0; le < y; le++) {
|
|
5455
|
+
const Ne = o.getRenderTarget(), _t = o.autoClear, St = o.getScissorTest();
|
|
5456
|
+
o.getScissor(d), o.getViewport(h);
|
|
5457
|
+
let ye = le, ze = ne;
|
|
5500
5458
|
if (!this.stableTiles) {
|
|
5501
5459
|
const Te = this._currentTile % (y * w);
|
|
5502
|
-
ye = Te % y,
|
|
5460
|
+
ye = Te % y, ze = ~~(Te / y), this._currentTile = Te + 1;
|
|
5503
5461
|
}
|
|
5504
|
-
const He = w -
|
|
5462
|
+
const He = w - ze - 1;
|
|
5505
5463
|
r.scissor.set(
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
Math.min(xe,
|
|
5464
|
+
Oe + ye * xe,
|
|
5465
|
+
ke + He * be,
|
|
5466
|
+
Math.min(xe, W - ye * xe),
|
|
5509
5467
|
Math.min(be, ve - He * be)
|
|
5510
5468
|
), r.viewport.set(
|
|
5511
|
-
ke,
|
|
5512
5469
|
Oe,
|
|
5513
|
-
|
|
5470
|
+
ke,
|
|
5471
|
+
W,
|
|
5514
5472
|
ve
|
|
5515
|
-
),
|
|
5473
|
+
), o.setRenderTarget(r), o.setScissorTest(!0), o.autoClear = !1, e.render(o), o.setViewport(h), o.setScissor(d), o.setScissorTest(St), o.setRenderTarget(Ne), o.autoClear = _t, l && (f.target1 = n.texture, f.target2 = r.texture, o.setRenderTarget(x), t.render(o), o.setRenderTarget(Ne)), this.samples += 1 / k, le === y - 1 && ne === w - 1 && (this.samples = Math.round(this.samples)), yield;
|
|
5516
5474
|
}
|
|
5517
5475
|
[n, x] = [x, n];
|
|
5518
5476
|
}
|
|
5519
5477
|
}
|
|
5520
|
-
const
|
|
5521
|
-
class
|
|
5478
|
+
const it = new oe();
|
|
5479
|
+
class st {
|
|
5522
5480
|
get material() {
|
|
5523
5481
|
return this._fsQuad.material;
|
|
5524
5482
|
}
|
|
@@ -5538,19 +5496,19 @@ class ot {
|
|
|
5538
5496
|
return !!this._compilePromise;
|
|
5539
5497
|
}
|
|
5540
5498
|
constructor(e) {
|
|
5541
|
-
this.camera = null, this.tiles = new
|
|
5499
|
+
this.camera = null, this.tiles = new X(3, 3), this.stableNoise = !1, this.stableTiles = !0, this.samples = 0, this._subframe = new te(0, 0, 1, 1), this._opacityFactor = 1, this._renderer = e, this._alpha = !1, this._fsQuad = new Y(new Ga()), this._blendQuad = new Y(new Er()), this._task = null, this._currentTile = 0, this._compilePromise = null, this._sobolTarget = new zr().generate(e), this._primaryTarget = new ie(1, 1, {
|
|
5542
5500
|
format: I,
|
|
5543
5501
|
type: R,
|
|
5544
5502
|
magFilter: T,
|
|
5545
5503
|
minFilter: T
|
|
5546
5504
|
}), this._blendTargets = [
|
|
5547
|
-
new
|
|
5505
|
+
new ie(1, 1, {
|
|
5548
5506
|
format: I,
|
|
5549
5507
|
type: R,
|
|
5550
5508
|
magFilter: T,
|
|
5551
5509
|
minFilter: T
|
|
5552
5510
|
}),
|
|
5553
|
-
new
|
|
5511
|
+
new ie(1, 1, {
|
|
5554
5512
|
format: I,
|
|
5555
5513
|
type: R,
|
|
5556
5514
|
magFilter: T,
|
|
@@ -5582,15 +5540,15 @@ class ot {
|
|
|
5582
5540
|
this._primaryTarget.dispose(), this._blendTargets[0].dispose(), this._blendTargets[1].dispose(), this._sobolTarget.dispose(), this._fsQuad.dispose(), this._blendQuad.dispose(), this._task = null;
|
|
5583
5541
|
}
|
|
5584
5542
|
reset() {
|
|
5585
|
-
const { _renderer: e, _primaryTarget: t, _blendTargets: r } = this, i = e.getRenderTarget(),
|
|
5586
|
-
e.getClearColor(
|
|
5543
|
+
const { _renderer: e, _primaryTarget: t, _blendTargets: r } = this, i = e.getRenderTarget(), s = e.getClearAlpha();
|
|
5544
|
+
e.getClearColor(it), e.setRenderTarget(t), e.setClearColor(0, 0), e.clearColor(), e.setRenderTarget(r[0]), e.setClearColor(0, 0), e.clearColor(), e.setRenderTarget(r[1]), e.setClearColor(0, 0), e.clearColor(), e.setClearColor(it, s), e.setRenderTarget(i), this.samples = 0, this._task = null, this.material.stratifiedTexture.stableNoise = this.stableNoise, this.stableNoise && (this.material.seed = 0, this.material.stratifiedTexture.reset());
|
|
5587
5545
|
}
|
|
5588
5546
|
update() {
|
|
5589
|
-
this.material.onBeforeRender(), !this.isCompiling && (this._task || (this._task =
|
|
5547
|
+
this.material.onBeforeRender(), !this.isCompiling && (this._task || (this._task = Va.call(this)), this._task.next());
|
|
5590
5548
|
}
|
|
5591
5549
|
}
|
|
5592
|
-
const
|
|
5593
|
-
class
|
|
5550
|
+
const $ = new X(), ot = new X(), de = new Lt(), me = new oe();
|
|
5551
|
+
class qa extends F {
|
|
5594
5552
|
constructor(e = 512, t = 512) {
|
|
5595
5553
|
super(
|
|
5596
5554
|
new Float32Array(e * t * 4),
|
|
@@ -5598,41 +5556,41 @@ class Xa extends M {
|
|
|
5598
5556
|
t,
|
|
5599
5557
|
I,
|
|
5600
5558
|
R,
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5559
|
+
pt,
|
|
5560
|
+
H,
|
|
5561
|
+
B,
|
|
5562
|
+
D,
|
|
5563
|
+
D
|
|
5606
5564
|
), this.generationCallback = null;
|
|
5607
5565
|
}
|
|
5608
5566
|
update() {
|
|
5609
5567
|
this.dispose(), this.needsUpdate = !0;
|
|
5610
5568
|
const { data: e, width: t, height: r } = this.image;
|
|
5611
5569
|
for (let i = 0; i < t; i++)
|
|
5612
|
-
for (let
|
|
5613
|
-
|
|
5614
|
-
const l = 4 * (
|
|
5615
|
-
e[l + 0] =
|
|
5570
|
+
for (let s = 0; s < r; s++) {
|
|
5571
|
+
ot.set(t, r), $.set(i / t, s / r), $.x -= 0.5, $.y = 1 - $.y, de.theta = $.x * 2 * Math.PI, de.phi = $.y * Math.PI, de.radius = 1, this.generationCallback(de, $, ot, me);
|
|
5572
|
+
const l = 4 * (s * t + i);
|
|
5573
|
+
e[l + 0] = me.r, e[l + 1] = me.g, e[l + 2] = me.b, e[l + 3] = 1;
|
|
5616
5574
|
}
|
|
5617
5575
|
}
|
|
5618
5576
|
copy(e) {
|
|
5619
5577
|
return super.copy(e), this.generationCallback = e.generationCallback, this;
|
|
5620
5578
|
}
|
|
5621
5579
|
}
|
|
5622
|
-
const
|
|
5623
|
-
class
|
|
5580
|
+
const nt = new P();
|
|
5581
|
+
class $a extends qa {
|
|
5624
5582
|
constructor(e = 512) {
|
|
5625
|
-
super(e, e), this.topColor = new
|
|
5626
|
-
|
|
5627
|
-
const a =
|
|
5628
|
-
|
|
5583
|
+
super(e, e), this.topColor = new oe().set(16777215), this.bottomColor = new oe().set(0), this.exponent = 2, this.generationCallback = (t, r, i, s) => {
|
|
5584
|
+
nt.setFromSpherical(t);
|
|
5585
|
+
const a = nt.y * 0.5 + 0.5;
|
|
5586
|
+
s.lerpColors(this.bottomColor, this.topColor, a ** this.exponent);
|
|
5629
5587
|
};
|
|
5630
5588
|
}
|
|
5631
5589
|
copy(e) {
|
|
5632
5590
|
return super.copy(e), this.topColor.copy(e.topColor), this.bottomColor.copy(e.bottomColor), this;
|
|
5633
5591
|
}
|
|
5634
5592
|
}
|
|
5635
|
-
class
|
|
5593
|
+
class ja extends ge {
|
|
5636
5594
|
get map() {
|
|
5637
5595
|
return this.uniforms.map.value;
|
|
5638
5596
|
}
|
|
@@ -5719,7 +5677,7 @@ class Ka extends ge {
|
|
|
5719
5677
|
}), this.setValues(e);
|
|
5720
5678
|
}
|
|
5721
5679
|
}
|
|
5722
|
-
class
|
|
5680
|
+
class Ya extends ge {
|
|
5723
5681
|
constructor() {
|
|
5724
5682
|
super({
|
|
5725
5683
|
uniforms: {
|
|
@@ -5749,7 +5707,7 @@ class Za extends ge {
|
|
|
5749
5707
|
#include <common>
|
|
5750
5708
|
#include <cube_uv_reflection_fragment>
|
|
5751
5709
|
|
|
5752
|
-
${
|
|
5710
|
+
${Rt}
|
|
5753
5711
|
|
|
5754
5712
|
void main() {
|
|
5755
5713
|
|
|
@@ -5762,38 +5720,38 @@ class Za extends ge {
|
|
|
5762
5720
|
}), this.depthWrite = !1, this.depthTest = !1;
|
|
5763
5721
|
}
|
|
5764
5722
|
}
|
|
5765
|
-
class
|
|
5723
|
+
class lt {
|
|
5766
5724
|
constructor(e) {
|
|
5767
|
-
this._renderer = e, this._quad = new
|
|
5725
|
+
this._renderer = e, this._quad = new Y(new Ya());
|
|
5768
5726
|
}
|
|
5769
5727
|
generate(e, t = null, r = null) {
|
|
5770
5728
|
if (!e.isCubeTexture)
|
|
5771
5729
|
throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");
|
|
5772
|
-
const i = e.images[0],
|
|
5730
|
+
const i = e.images[0], s = this._renderer, a = this._quad;
|
|
5773
5731
|
t === null && (t = 4 * i.height), r === null && (r = 2 * i.height);
|
|
5774
|
-
const l = new
|
|
5732
|
+
const l = new ie(t, r, {
|
|
5775
5733
|
type: R,
|
|
5776
5734
|
colorSpace: i.colorSpace
|
|
5777
|
-
}),
|
|
5778
|
-
a.material.defines.CUBEUV_MAX_MIP = `${d}.0`, a.material.defines.CUBEUV_TEXEL_WIDTH =
|
|
5779
|
-
const n =
|
|
5780
|
-
|
|
5735
|
+
}), u = i.height, d = Math.log2(u) - 2, h = 1 / u, f = 1 / (3 * Math.max(Math.pow(2, d), 112));
|
|
5736
|
+
a.material.defines.CUBEUV_MAX_MIP = `${d}.0`, a.material.defines.CUBEUV_TEXEL_WIDTH = f, a.material.defines.CUBEUV_TEXEL_HEIGHT = h, a.material.uniforms.envMap.value = e, a.material.uniforms.flipEnvMap.value = e.isRenderTargetTexture ? 1 : -1, a.material.needsUpdate = !0;
|
|
5737
|
+
const n = s.getRenderTarget(), x = s.autoClear;
|
|
5738
|
+
s.autoClear = !0, s.setRenderTarget(l), a.render(s), s.setRenderTarget(n), s.autoClear = x;
|
|
5781
5739
|
const m = new Uint16Array(t * r * 4), g = new Float32Array(t * r * 4);
|
|
5782
|
-
|
|
5740
|
+
s.readRenderTargetPixels(l, 0, 0, t, r, g), l.dispose();
|
|
5783
5741
|
for (let p = 0, v = g.length; p < v; p++)
|
|
5784
|
-
m[p] =
|
|
5785
|
-
const c = new
|
|
5786
|
-
return c.minFilter =
|
|
5742
|
+
m[p] = N.toHalfFloat(g[p]);
|
|
5743
|
+
const c = new F(m, t, r, I, E);
|
|
5744
|
+
return c.minFilter = Ut, c.magFilter = D, c.wrapS = H, c.wrapT = H, c.mapping = pt, c.needsUpdate = !0, c;
|
|
5787
5745
|
}
|
|
5788
5746
|
dispose() {
|
|
5789
5747
|
this._quad.dispose();
|
|
5790
5748
|
}
|
|
5791
5749
|
}
|
|
5792
|
-
function
|
|
5793
|
-
return
|
|
5750
|
+
function Xa(o) {
|
|
5751
|
+
return o.extensions.get("EXT_float_blend");
|
|
5794
5752
|
}
|
|
5795
|
-
const
|
|
5796
|
-
class
|
|
5753
|
+
const Z = new X();
|
|
5754
|
+
class Qa {
|
|
5797
5755
|
get multipleImportanceSampling() {
|
|
5798
5756
|
return !!this._pathTracer.material.defines.FEATURE_MIS;
|
|
5799
5757
|
}
|
|
@@ -5837,17 +5795,17 @@ class ei {
|
|
|
5837
5795
|
return !!this._pathTracer.isCompiling;
|
|
5838
5796
|
}
|
|
5839
5797
|
constructor(e) {
|
|
5840
|
-
this._renderer = e, this._generator = new
|
|
5798
|
+
this._renderer = e, this._generator = new Pr(), this._pathTracer = new st(e), this._queueReset = !1, this._clock = new Gt(), this._compilePromise = null, this._lowResPathTracer = new st(e), this._lowResPathTracer.tiles.set(1, 1), this._quad = new Y(new ja({
|
|
5841
5799
|
map: null,
|
|
5842
5800
|
transparent: !0,
|
|
5843
|
-
blending:
|
|
5801
|
+
blending: se,
|
|
5844
5802
|
premultipliedAlpha: e.getContextAttributes().premultipliedAlpha
|
|
5845
|
-
})), this._materials = null, this._previousEnvironment = null, this._previousBackground = null, this._internalBackground = null, this.renderDelay = 100, this.minSamples = 5, this.fadeDuration = 500, this.enablePathTracing = !0, this.pausePathTracing = !1, this.dynamicLowRes = !1, this.lowResScale = 0.25, this.renderScale = 1, this.synchronizeRenderSize = !0, this.rasterizeScene = !0, this.renderToCanvas = !0, this.textureSize = new
|
|
5803
|
+
})), this._materials = null, this._previousEnvironment = null, this._previousBackground = null, this._internalBackground = null, this.renderDelay = 100, this.minSamples = 5, this.fadeDuration = 500, this.enablePathTracing = !0, this.pausePathTracing = !1, this.dynamicLowRes = !1, this.lowResScale = 0.25, this.renderScale = 1, this.synchronizeRenderSize = !0, this.rasterizeScene = !0, this.renderToCanvas = !0, this.textureSize = new X(1024, 1024), this.rasterizeSceneCallback = (t, r) => {
|
|
5846
5804
|
this._renderer.render(t, r);
|
|
5847
5805
|
}, this.renderToCanvasCallback = (t, r, i) => {
|
|
5848
|
-
const
|
|
5849
|
-
r.autoClear = !1, i.render(r), r.autoClear =
|
|
5850
|
-
}, this.setScene(new
|
|
5806
|
+
const s = r.autoClear;
|
|
5807
|
+
r.autoClear = !1, i.render(r), r.autoClear = s;
|
|
5808
|
+
}, this.setScene(new Vt(), new dt());
|
|
5851
5809
|
}
|
|
5852
5810
|
setBVHWorker(e) {
|
|
5853
5811
|
this._generator.setBVHWorker(e);
|
|
@@ -5856,10 +5814,10 @@ class ei {
|
|
|
5856
5814
|
e.updateMatrixWorld(!0), t.updateMatrixWorld();
|
|
5857
5815
|
const i = this._generator;
|
|
5858
5816
|
if (i.setObjects(e), this._buildAsync)
|
|
5859
|
-
return i.generateAsync(r.onProgress).then((
|
|
5817
|
+
return i.generateAsync(r.onProgress).then((s) => this._updateFromResults(e, t, s));
|
|
5860
5818
|
{
|
|
5861
|
-
const
|
|
5862
|
-
return this._updateFromResults(e, t,
|
|
5819
|
+
const s = i.generate();
|
|
5820
|
+
return this._updateFromResults(e, t, s);
|
|
5863
5821
|
}
|
|
5864
5822
|
}
|
|
5865
5823
|
setSceneAsync(...e) {
|
|
@@ -5875,24 +5833,24 @@ class ei {
|
|
|
5875
5833
|
e.updateMatrixWorld(), this._pathTracer.setCamera(e), this._lowResPathTracer.setCamera(e), this.reset();
|
|
5876
5834
|
}
|
|
5877
5835
|
updateMaterials() {
|
|
5878
|
-
const e = this._pathTracer.material, t = this._renderer, r = this._materials, i = this.textureSize,
|
|
5879
|
-
e.textures.setTextures(t,
|
|
5836
|
+
const e = this._pathTracer.material, t = this._renderer, r = this._materials, i = this.textureSize, s = ea(r);
|
|
5837
|
+
e.textures.setTextures(t, s, i.x, i.y), e.materials.updateFrom(r, s), this.reset();
|
|
5880
5838
|
}
|
|
5881
5839
|
updateLights() {
|
|
5882
|
-
const e = this.scene, t = this._renderer, r = this._pathTracer.material, i =
|
|
5883
|
-
r.lights.updateFrom(i,
|
|
5840
|
+
const e = this.scene, t = this._renderer, r = this._pathTracer.material, i = ta(e), s = Jr(i);
|
|
5841
|
+
r.lights.updateFrom(i, s), r.iesProfiles.setTextures(t, s), this.reset();
|
|
5884
5842
|
}
|
|
5885
5843
|
updateEnvironment() {
|
|
5886
5844
|
const e = this.scene, t = this._pathTracer.material;
|
|
5887
5845
|
if (this._internalBackground && (this._internalBackground.dispose(), this._internalBackground = null), t.backgroundBlur = e.backgroundBlurriness, t.backgroundIntensity = e.backgroundIntensity ?? 1, t.backgroundRotation.makeRotationFromEuler(e.backgroundRotation).invert(), e.background === null)
|
|
5888
5846
|
t.backgroundMap = null, t.backgroundAlpha = 0;
|
|
5889
5847
|
else if (e.background.isColor) {
|
|
5890
|
-
this._colorBackground = this._colorBackground || new
|
|
5848
|
+
this._colorBackground = this._colorBackground || new $a(16);
|
|
5891
5849
|
const r = this._colorBackground;
|
|
5892
5850
|
r.topColor.equals(e.background) || (r.topColor.set(e.background), r.bottomColor.set(e.background), r.update()), t.backgroundMap = r, t.backgroundAlpha = 1;
|
|
5893
5851
|
} else if (e.background.isCubeTexture) {
|
|
5894
5852
|
if (e.background !== this._previousBackground) {
|
|
5895
|
-
const r = new
|
|
5853
|
+
const r = new lt(this._renderer).generate(e.background);
|
|
5896
5854
|
this._internalBackground = r, t.backgroundMap = r, t.backgroundAlpha = 1;
|
|
5897
5855
|
}
|
|
5898
5856
|
} else
|
|
@@ -5900,7 +5858,7 @@ class ei {
|
|
|
5900
5858
|
if (t.environmentIntensity = e.environmentIntensity ?? 1, t.environmentRotation.makeRotationFromEuler(e.environmentRotation).invert(), this._previousEnvironment !== e.environment)
|
|
5901
5859
|
if (e.environment !== null)
|
|
5902
5860
|
if (e.environment.isCubeTexture) {
|
|
5903
|
-
const r = new
|
|
5861
|
+
const r = new lt(this._renderer).generate(e.environment);
|
|
5904
5862
|
t.envMapInfo.updateFrom(r);
|
|
5905
5863
|
} else
|
|
5906
5864
|
t.envMapInfo.updateFrom(e.environment);
|
|
@@ -5911,34 +5869,34 @@ class ei {
|
|
|
5911
5869
|
_updateFromResults(e, t, r) {
|
|
5912
5870
|
const {
|
|
5913
5871
|
materials: i,
|
|
5914
|
-
geometry:
|
|
5872
|
+
geometry: s,
|
|
5915
5873
|
bvh: a,
|
|
5916
5874
|
bvhChanged: l
|
|
5917
5875
|
} = r;
|
|
5918
5876
|
this._materials = i;
|
|
5919
5877
|
const d = this._pathTracer.material;
|
|
5920
5878
|
return l && (d.bvh.updateFrom(a), d.attributesArray.updateFrom(
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
), d.materialIndexAttribute.updateFrom(
|
|
5879
|
+
s.attributes.normal,
|
|
5880
|
+
s.attributes.tangent,
|
|
5881
|
+
s.attributes.uv,
|
|
5882
|
+
s.attributes.color
|
|
5883
|
+
), d.materialIndexAttribute.updateFrom(s.attributes.materialIndex)), this._previousScene = e, this.scene = e, this.camera = t, this.updateCamera(), this.updateMaterials(), this.updateEnvironment(), this.updateLights(), r;
|
|
5926
5884
|
}
|
|
5927
5885
|
renderSample() {
|
|
5928
|
-
const e = this._lowResPathTracer, t = this._pathTracer, r = this._renderer, i = this._clock,
|
|
5929
|
-
this._updateScale(), this._queueReset && (t.reset(), e.reset(), this._queueReset = !1,
|
|
5886
|
+
const e = this._lowResPathTracer, t = this._pathTracer, r = this._renderer, i = this._clock, s = this._quad;
|
|
5887
|
+
this._updateScale(), this._queueReset && (t.reset(), e.reset(), this._queueReset = !1, s.material.opacity = 0, i.start());
|
|
5930
5888
|
const a = i.getDelta() * 1e3, l = i.getElapsedTime() * 1e3;
|
|
5931
|
-
if (!this.pausePathTracing && this.enablePathTracing && this.renderDelay <= l && !this.isCompiling && t.update(), t.alpha = t.material.backgroundAlpha !== 1 || !
|
|
5932
|
-
const
|
|
5933
|
-
if (l >= this.renderDelay && this.samples >= this.minSamples && (this.fadeDuration !== 0 ?
|
|
5889
|
+
if (!this.pausePathTracing && this.enablePathTracing && this.renderDelay <= l && !this.isCompiling && t.update(), t.alpha = t.material.backgroundAlpha !== 1 || !Xa(r), e.alpha = t.alpha, this.renderToCanvas) {
|
|
5890
|
+
const u = this._renderer, d = this.minSamples;
|
|
5891
|
+
if (l >= this.renderDelay && this.samples >= this.minSamples && (this.fadeDuration !== 0 ? s.material.opacity = Math.min(s.material.opacity + a / this.fadeDuration, 1) : s.material.opacity = 1), !this.enablePathTracing || this.samples < d || s.material.opacity < 1) {
|
|
5934
5892
|
if (this.dynamicLowRes && !this.isCompiling) {
|
|
5935
5893
|
e.samples < 1 && (e.material = t.material, e.update());
|
|
5936
|
-
const
|
|
5937
|
-
|
|
5894
|
+
const h = s.material.opacity;
|
|
5895
|
+
s.material.opacity = 1 - s.material.opacity, s.material.map = e.target.texture, s.render(u), s.material.opacity = h;
|
|
5938
5896
|
}
|
|
5939
5897
|
(!this.dynamicLowRes && this.rasterizeScene || this.dynamicLowRes && this.isCompiling) && this.rasterizeSceneCallback(this.scene, this.camera);
|
|
5940
5898
|
}
|
|
5941
|
-
this.enablePathTracing &&
|
|
5899
|
+
this.enablePathTracing && s.material.opacity > 0 && (s.material.opacity < 1 && (s.material.blending = this.dynamicLowRes ? qt : mt), s.material.map = t.target.texture, this.renderToCanvasCallback(t.target, u, s), s.material.blending = se);
|
|
5942
5900
|
}
|
|
5943
5901
|
}
|
|
5944
5902
|
reset() {
|
|
@@ -5949,30 +5907,30 @@ class ei {
|
|
|
5949
5907
|
}
|
|
5950
5908
|
_updateScale() {
|
|
5951
5909
|
if (this.synchronizeRenderSize) {
|
|
5952
|
-
this._renderer.getDrawingBufferSize(
|
|
5953
|
-
const e = Math.floor(this.renderScale *
|
|
5954
|
-
if (this._pathTracer.getSize(
|
|
5910
|
+
this._renderer.getDrawingBufferSize(Z);
|
|
5911
|
+
const e = Math.floor(this.renderScale * Z.x), t = Math.floor(this.renderScale * Z.y);
|
|
5912
|
+
if (this._pathTracer.getSize(Z), Z.x !== e || Z.y !== t) {
|
|
5955
5913
|
const r = this.lowResScale;
|
|
5956
5914
|
this._pathTracer.setSize(e, t), this._lowResPathTracer.setSize(Math.floor(e * r), Math.floor(t * r));
|
|
5957
5915
|
}
|
|
5958
5916
|
}
|
|
5959
5917
|
}
|
|
5960
5918
|
}
|
|
5961
|
-
function
|
|
5962
|
-
return typeof
|
|
5919
|
+
function ct(o) {
|
|
5920
|
+
return typeof o == "object" && o !== null && "getInternalRenderer" in o && typeof o.getInternalRenderer == "function";
|
|
5963
5921
|
}
|
|
5964
|
-
function
|
|
5965
|
-
return
|
|
5922
|
+
function j(o) {
|
|
5923
|
+
return o !== null && typeof o == "object" && "getInternalRenderer" in o && typeof o.getInternalRenderer == "function";
|
|
5966
5924
|
}
|
|
5967
|
-
const
|
|
5925
|
+
const M = class M {
|
|
5968
5926
|
constructor() {
|
|
5969
|
-
this.pathTracer = null, this.enabled = !1, this.renderer = null, this.sampleCount = 0, this.createAttempts = 0, this.maxCreateAttempts = 10, this.sceneInitialized = !1, this.environmentWaitFrames = 0, this.maxEnvironmentWaitFrames = 300, this.disposed = !1, this.convertedEnvTexture = null, this.resumable = !1, this.lastCameraMoveTime = -1 / 0, this.cameraDirty = !1, this.events = new
|
|
5970
|
-
samples:
|
|
5927
|
+
this.pathTracer = null, this.enabled = !1, this.renderer = null, this.sampleCount = 0, this.createAttempts = 0, this.maxCreateAttempts = 10, this.sceneInitialized = !1, this.environmentWaitFrames = 0, this.maxEnvironmentWaitFrames = 300, this.disposed = !1, this.convertedEnvTexture = null, this.resumable = !1, this.lastCameraMoveTime = -1 / 0, this.cameraDirty = !1, this.events = new rr(), this.rasterFadeTarget = null, this.fadeQuad = null, this.fadeToneMapping = null, this.fadeSupported = !0, this.settings = {
|
|
5928
|
+
samples: ar,
|
|
5971
5929
|
bounces: 4,
|
|
5972
5930
|
// Reduce bounces for better performance
|
|
5973
5931
|
transmissiveBounces: 2,
|
|
5974
5932
|
// Reduce transmissive bounces
|
|
5975
|
-
renderScale:
|
|
5933
|
+
renderScale: 1,
|
|
5976
5934
|
// Start with lower resolution for better performance
|
|
5977
5935
|
lowResScale: 0.5,
|
|
5978
5936
|
dynamicLowRes: !0,
|
|
@@ -5980,24 +5938,28 @@ const pe = class pe {
|
|
|
5980
5938
|
};
|
|
5981
5939
|
}
|
|
5982
5940
|
/**
|
|
5983
|
-
* Hand the scene to the path tracer with the
|
|
5984
|
-
* helpers hidden
|
|
5985
|
-
*
|
|
5986
|
-
*
|
|
5987
|
-
*
|
|
5988
|
-
*
|
|
5941
|
+
* Hand the scene to the path tracer with the raster-only contact-shadow
|
|
5942
|
+
* helpers hidden and the tracer-only ground floor shown. The `ShadowMaterial`
|
|
5943
|
+
* catcher (and the baked disc) are raster shadow-map tricks the tracer can't
|
|
5944
|
+
* use — ingesting them double-darkens or floats the contact area — so they're
|
|
5945
|
+
* hidden; the PATH_TRACING_FLOOR_FLAG disc is the mirror image, a real matte
|
|
5946
|
+
* surface kept invisible in the raster view and flipped on only here so the
|
|
5947
|
+
* tracer has something physical to cast a contact shadow onto (otherwise the
|
|
5948
|
+
* model floats in the traced render). The generator only reads currently-
|
|
5949
|
+
* visible nodes, and both sets are restored right after the ingest so the
|
|
5950
|
+
* raster fallback keeps its clean invisible-floor look.
|
|
5989
5951
|
*/
|
|
5990
5952
|
ingestSceneWithoutShadowHelpers(e, t) {
|
|
5991
|
-
var
|
|
5992
|
-
const r = [];
|
|
5993
|
-
e.traverse((
|
|
5994
|
-
var
|
|
5995
|
-
(a =
|
|
5996
|
-
}), r.forEach((
|
|
5953
|
+
var s;
|
|
5954
|
+
const r = [], i = [];
|
|
5955
|
+
e.traverse((a) => {
|
|
5956
|
+
var l, u;
|
|
5957
|
+
(l = a.userData) != null && l[ir] && a.visible ? r.push(a) : (u = a.userData) != null && u[sr] && !a.visible && i.push(a);
|
|
5958
|
+
}), r.forEach((a) => a.visible = !1), i.forEach((a) => a.visible = !0);
|
|
5997
5959
|
try {
|
|
5998
|
-
(
|
|
5960
|
+
(s = this.pathTracer) == null || s.setScene(e, t);
|
|
5999
5961
|
} finally {
|
|
6000
|
-
r.forEach((
|
|
5962
|
+
r.forEach((a) => a.visible = !0), i.forEach((a) => a.visible = !1);
|
|
6001
5963
|
}
|
|
6002
5964
|
}
|
|
6003
5965
|
/**
|
|
@@ -6012,32 +5974,32 @@ const pe = class pe {
|
|
|
6012
5974
|
if (!i)
|
|
6013
5975
|
return null;
|
|
6014
5976
|
i.drawImage(t, 0, 0);
|
|
6015
|
-
const
|
|
6016
|
-
for (let
|
|
6017
|
-
a[
|
|
6018
|
-
const l = new
|
|
5977
|
+
const s = i.getImageData(0, 0, r.width, r.height), a = new Float32Array(s.data.length);
|
|
5978
|
+
for (let u = 0; u < s.data.length; u++)
|
|
5979
|
+
a[u] = s.data[u] / 255;
|
|
5980
|
+
const l = new _.DataTexture(
|
|
6019
5981
|
a,
|
|
6020
5982
|
r.width,
|
|
6021
5983
|
r.height,
|
|
6022
|
-
|
|
6023
|
-
|
|
5984
|
+
_.RGBAFormat,
|
|
5985
|
+
_.FloatType
|
|
6024
5986
|
);
|
|
6025
5987
|
return l.mapping = e.mapping, l.wrapS = e.wrapS, l.wrapT = e.wrapT, l.magFilter = e.magFilter, l.minFilter = e.minFilter, l.anisotropy = e.anisotropy, l.needsUpdate = !0, l;
|
|
6026
5988
|
}
|
|
6027
5989
|
async initialize(e) {
|
|
6028
5990
|
try {
|
|
6029
|
-
return this.renderer = e.renderer, this.enabled = e.enabled, this.isSupported() ?
|
|
6030
|
-
new
|
|
5991
|
+
return this.renderer = e.renderer, this.enabled = e.enabled, this.isSupported() ? S.ok(void 0) : S.err(
|
|
5992
|
+
new L(
|
|
6031
5993
|
"Path tracing is not supported in this environment",
|
|
6032
|
-
|
|
5994
|
+
U.PATH_TRACING_INIT_FAILED,
|
|
6033
5995
|
{ reason: "WebGL2 or required extensions not available" }
|
|
6034
5996
|
)
|
|
6035
5997
|
);
|
|
6036
5998
|
} catch (t) {
|
|
6037
|
-
return
|
|
6038
|
-
new
|
|
5999
|
+
return S.err(
|
|
6000
|
+
new L(
|
|
6039
6001
|
"Failed to initialize path tracing",
|
|
6040
|
-
|
|
6002
|
+
U.PATH_TRACING_INIT_FAILED,
|
|
6041
6003
|
{ originalError: t }
|
|
6042
6004
|
)
|
|
6043
6005
|
);
|
|
@@ -6045,25 +6007,25 @@ const pe = class pe {
|
|
|
6045
6007
|
}
|
|
6046
6008
|
createPathTracer() {
|
|
6047
6009
|
if (this.disposed)
|
|
6048
|
-
return
|
|
6049
|
-
new
|
|
6010
|
+
return S.err(
|
|
6011
|
+
new L(
|
|
6050
6012
|
"Instance is disposed",
|
|
6051
|
-
|
|
6013
|
+
U.INVALID_STATE
|
|
6052
6014
|
)
|
|
6053
6015
|
);
|
|
6054
6016
|
try {
|
|
6055
|
-
const e =
|
|
6056
|
-
return e ? (this.pathTracer = new
|
|
6057
|
-
new
|
|
6017
|
+
const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
|
|
6018
|
+
return e ? (this.pathTracer = new Qa(e), this.pathTracer.tiles && "set" in this.pathTracer.tiles && this.pathTracer.tiles.set(1, 1), this.pathTracer.bounces = this.settings.bounces, this.settings.transmissiveBounces !== void 0 && (this.pathTracer.transmissiveBounces = this.settings.transmissiveBounces), this.pathTracer.renderScale = this.settings.renderScale, this.pathTracer.dynamicLowRes = this.settings.dynamicLowRes, this.pathTracer.lowResScale = this.settings.lowResScale, e.setRenderTarget(null), S.ok(void 0)) : S.err(
|
|
6019
|
+
new L(
|
|
6058
6020
|
"Renderer not ready, will retry",
|
|
6059
|
-
|
|
6021
|
+
U.RENDERER_NOT_INITIALIZED
|
|
6060
6022
|
)
|
|
6061
6023
|
);
|
|
6062
6024
|
} catch (e) {
|
|
6063
|
-
return
|
|
6064
|
-
new
|
|
6025
|
+
return S.err(
|
|
6026
|
+
new L(
|
|
6065
6027
|
"Failed to create path tracer",
|
|
6066
|
-
|
|
6028
|
+
U.PATH_TRACING_INIT_FAILED,
|
|
6067
6029
|
{ originalError: e }
|
|
6068
6030
|
)
|
|
6069
6031
|
);
|
|
@@ -6072,7 +6034,7 @@ const pe = class pe {
|
|
|
6072
6034
|
setEnabled(e) {
|
|
6073
6035
|
if (this.enabled !== e && (this.enabled = e, !e)) {
|
|
6074
6036
|
this.resumable = !1, this.reset(), this.sceneInitialized = !1;
|
|
6075
|
-
const t =
|
|
6037
|
+
const t = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
|
|
6076
6038
|
t && (t.autoClear = !0);
|
|
6077
6039
|
}
|
|
6078
6040
|
}
|
|
@@ -6093,10 +6055,10 @@ const pe = class pe {
|
|
|
6093
6055
|
}
|
|
6094
6056
|
async render(e, t) {
|
|
6095
6057
|
if (this.disposed)
|
|
6096
|
-
return
|
|
6058
|
+
return S.ok(void 0);
|
|
6097
6059
|
const r = this.renderer;
|
|
6098
6060
|
if (!r)
|
|
6099
|
-
return
|
|
6061
|
+
return S.ok(void 0);
|
|
6100
6062
|
if (!this.enabled)
|
|
6101
6063
|
return this.renderWhileDisabled(e, t);
|
|
6102
6064
|
if (!this.pathTracer) {
|
|
@@ -6107,19 +6069,19 @@ const pe = class pe {
|
|
|
6107
6069
|
try {
|
|
6108
6070
|
const i = this.extractThreeObjects(e, t);
|
|
6109
6071
|
if (!i)
|
|
6110
|
-
return
|
|
6111
|
-
new
|
|
6072
|
+
return S.err(
|
|
6073
|
+
new L(
|
|
6112
6074
|
"Could not extract Three.js scene or camera",
|
|
6113
|
-
|
|
6075
|
+
U.INVALID_PARAMETER
|
|
6114
6076
|
)
|
|
6115
6077
|
);
|
|
6116
|
-
const { threeScene:
|
|
6078
|
+
const { threeScene: s, threeCamera: a } = i;
|
|
6117
6079
|
if (!this.sceneInitialized) {
|
|
6118
6080
|
const l = await this.initializeSceneForPathTracing(
|
|
6119
6081
|
r,
|
|
6120
6082
|
e,
|
|
6121
6083
|
t,
|
|
6122
|
-
|
|
6084
|
+
s,
|
|
6123
6085
|
a
|
|
6124
6086
|
);
|
|
6125
6087
|
if (l)
|
|
@@ -6127,10 +6089,10 @@ const pe = class pe {
|
|
|
6127
6089
|
}
|
|
6128
6090
|
return this.sceneInitialized ? this.accumulateSample(r, e, t) : r.render(e, t);
|
|
6129
6091
|
} catch (i) {
|
|
6130
|
-
return
|
|
6131
|
-
new
|
|
6092
|
+
return S.err(
|
|
6093
|
+
new L(
|
|
6132
6094
|
"Failed to render with path tracing",
|
|
6133
|
-
|
|
6095
|
+
U.RENDER_FAILED,
|
|
6134
6096
|
{ originalError: i }
|
|
6135
6097
|
)
|
|
6136
6098
|
);
|
|
@@ -6144,15 +6106,15 @@ const pe = class pe {
|
|
|
6144
6106
|
* while still waiting for the renderer, or after giving up and disabling.
|
|
6145
6107
|
*/
|
|
6146
6108
|
ensurePathTracerCreated(e, t, r) {
|
|
6147
|
-
var
|
|
6109
|
+
var s;
|
|
6148
6110
|
this.createAttempts++;
|
|
6149
6111
|
const i = this.createPathTracer();
|
|
6150
|
-
return i.ok ? (this.createAttempts = 0, null) : (this.createAttempts < this.maxCreateAttempts && ((
|
|
6112
|
+
return i.ok ? (this.createAttempts = 0, null) : (this.createAttempts < this.maxCreateAttempts && ((s = i.error) == null ? void 0 : s.message) === "Renderer not ready, will retry" || (this.disableAfterSelfPause("gave-up"), this.createAttempts = 0), e.render(t, r));
|
|
6151
6113
|
}
|
|
6152
6114
|
/** Unwraps the Three.js scene/camera from their adapters, or null if either fails. */
|
|
6153
6115
|
extractThreeObjects(e, t) {
|
|
6154
6116
|
let r = null, i = null;
|
|
6155
|
-
return
|
|
6117
|
+
return ct(e) && (r = e.getInternalRenderer()), ct(t) && (i = t.getInternalRenderer()), !r || !i ? null : { threeScene: r, threeCamera: i };
|
|
6156
6118
|
}
|
|
6157
6119
|
/**
|
|
6158
6120
|
* First-frame setup: waits for an environment texture, converts an
|
|
@@ -6162,47 +6124,47 @@ const pe = class pe {
|
|
|
6162
6124
|
* Result when render() should return it immediately instead — still
|
|
6163
6125
|
* waiting, or the environment shape isn't one the tracer can use.
|
|
6164
6126
|
*/
|
|
6165
|
-
async initializeSceneForPathTracing(e, t, r, i,
|
|
6127
|
+
async initializeSceneForPathTracing(e, t, r, i, s) {
|
|
6166
6128
|
var a;
|
|
6167
6129
|
try {
|
|
6168
6130
|
const l = i.__originalEnvironmentTexture;
|
|
6169
6131
|
if (!i.environment && !l)
|
|
6170
6132
|
return this.environmentWaitFrames++, this.environmentWaitFrames >= this.maxEnvironmentWaitFrames && (this.disableAfterSelfPause("gave-up"), this.environmentWaitFrames = 0), e.render(t, r);
|
|
6171
6133
|
if (this.environmentWaitFrames = 0, l && l.isCubeTexture) {
|
|
6172
|
-
const
|
|
6134
|
+
const u = i.environment;
|
|
6173
6135
|
i.environment = l;
|
|
6174
6136
|
try {
|
|
6175
|
-
this.ingestSceneWithoutShadowHelpers(i,
|
|
6137
|
+
this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0;
|
|
6176
6138
|
} finally {
|
|
6177
|
-
i.environment =
|
|
6139
|
+
i.environment = u;
|
|
6178
6140
|
}
|
|
6179
|
-
} else if (l && l.mapping ===
|
|
6180
|
-
let
|
|
6141
|
+
} else if (l && l.mapping === _.EquirectangularReflectionMapping) {
|
|
6142
|
+
let u = l;
|
|
6181
6143
|
if (l.image instanceof HTMLImageElement)
|
|
6182
6144
|
if (this.convertedEnvTexture)
|
|
6183
|
-
|
|
6145
|
+
u = this.convertedEnvTexture;
|
|
6184
6146
|
else {
|
|
6185
|
-
const
|
|
6186
|
-
if (!
|
|
6147
|
+
const h = this.convertToDataTexture(l);
|
|
6148
|
+
if (!h)
|
|
6187
6149
|
throw new Error("Failed to convert environment texture to DataTexture");
|
|
6188
|
-
this.convertedEnvTexture =
|
|
6150
|
+
this.convertedEnvTexture = h, u = h;
|
|
6189
6151
|
}
|
|
6190
6152
|
const d = i.environment;
|
|
6191
|
-
i.environment =
|
|
6153
|
+
i.environment = u;
|
|
6192
6154
|
try {
|
|
6193
|
-
const
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
l.needsUpdate = !0,
|
|
6197
|
-
},
|
|
6198
|
-
|
|
6199
|
-
},
|
|
6200
|
-
}), this.ingestSceneWithoutShadowHelpers(i,
|
|
6201
|
-
} catch (
|
|
6202
|
-
throw i.environment = d,
|
|
6155
|
+
const h = l.image;
|
|
6156
|
+
h && !("data" in h && h.data) && h instanceof HTMLImageElement && !h.complete && await new Promise((f) => {
|
|
6157
|
+
h.onload = () => {
|
|
6158
|
+
l.needsUpdate = !0, f();
|
|
6159
|
+
}, h.onerror = () => {
|
|
6160
|
+
f();
|
|
6161
|
+
}, h.complete && f();
|
|
6162
|
+
}), this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0, i.environment = d;
|
|
6163
|
+
} catch (h) {
|
|
6164
|
+
throw i.environment = d, h;
|
|
6203
6165
|
}
|
|
6204
|
-
} else if (((a = i.environment) == null ? void 0 : a.mapping) ===
|
|
6205
|
-
this.ingestSceneWithoutShadowHelpers(i,
|
|
6166
|
+
} else if (((a = i.environment) == null ? void 0 : a.mapping) === _.EquirectangularReflectionMapping)
|
|
6167
|
+
this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0;
|
|
6206
6168
|
else
|
|
6207
6169
|
return this.disableAfterSelfPause("gave-up"), e.render(t, r);
|
|
6208
6170
|
} catch (l) {
|
|
@@ -6216,29 +6178,140 @@ const pe = class pe {
|
|
|
6216
6178
|
* feedback, accumulates a tracer sample, and detects completion.
|
|
6217
6179
|
*/
|
|
6218
6180
|
accumulateSample(e, t, r) {
|
|
6219
|
-
var
|
|
6181
|
+
var s, a;
|
|
6220
6182
|
if (this.sampleCount === 0)
|
|
6221
6183
|
try {
|
|
6222
|
-
(
|
|
6184
|
+
(s = this.pathTracer) == null || s.updateLights();
|
|
6223
6185
|
} catch (l) {
|
|
6224
6186
|
console.warn("Failed to update lights for path tracing:", l);
|
|
6225
6187
|
}
|
|
6226
6188
|
const i = e.render(t, r);
|
|
6227
|
-
|
|
6189
|
+
if (!i.ok)
|
|
6190
|
+
return i;
|
|
6191
|
+
if (performance.now() - this.lastCameraMoveTime < M.CAMERA_SETTLE_MS)
|
|
6192
|
+
return S.ok(void 0);
|
|
6193
|
+
if (this.cameraDirty && (this.cameraDirty = !1, (a = this.pathTracer) == null || a.updateCamera()), this.fadeSupported && this.sampleCount === 0 && this.runFadeStep(() => this.captureRasterFade(e, t, r)), this.accumulateOneSample(), this.sampleCount++, this.fadeSupported && this.sampleCount < M.FADE_SAMPLES) {
|
|
6194
|
+
const l = 1 - this.pathTracedLayerOpacity(this.sampleCount);
|
|
6195
|
+
this.runFadeStep(() => this.renderRasterFade(l));
|
|
6196
|
+
}
|
|
6197
|
+
return this.sampleCount === this.settings.samples ? this.captureCompletedFrame() : S.ok(void 0);
|
|
6198
|
+
}
|
|
6199
|
+
/** Run a cosmetic dissolve step, disabling the dissolve for the rest of the
|
|
6200
|
+
* session if it throws — it must never take the render down with it. */
|
|
6201
|
+
runFadeStep(e) {
|
|
6202
|
+
try {
|
|
6203
|
+
e();
|
|
6204
|
+
} catch (t) {
|
|
6205
|
+
console.warn("Path-tracing startup dissolve unavailable; showing samples directly:", t), this.fadeSupported = !1;
|
|
6206
|
+
}
|
|
6207
|
+
}
|
|
6208
|
+
/** Opacity of the path-traced layer over the raster snapshot as accumulation
|
|
6209
|
+
* progresses: 0 for the opening (noisiest) samples, eased up to a low preview
|
|
6210
|
+
* cap while the image is still grainy — so the tracer's noise never reads
|
|
6211
|
+
* above the cap — then released to fully opaque as it resolves. */
|
|
6212
|
+
pathTracedLayerOpacity(e) {
|
|
6213
|
+
const t = M.FADE_HOLD_SAMPLES, r = M.FADE_SAMPLES, i = M.FADE_PREVIEW_OPACITY, s = t + (r - t) * M.FADE_RELEASE_FRACTION;
|
|
6214
|
+
return e < s ? i * M.smoothstep(t, s, e) : i + (1 - i) * M.smoothstep(s, r, e);
|
|
6215
|
+
}
|
|
6216
|
+
static smoothstep(e, t, r) {
|
|
6217
|
+
const i = Math.min(1, Math.max(0, (r - e) / (t - e)));
|
|
6218
|
+
return i * i * (3 - 2 * i);
|
|
6219
|
+
}
|
|
6220
|
+
/** Render the current raster frame into a linear offscreen target to fade out
|
|
6221
|
+
* over the resolving path-traced image. It is captured pre-tone-mapping
|
|
6222
|
+
* (three only tone-maps when drawing to the canvas, never to a target), so the
|
|
6223
|
+
* fade shader applies the renderer's tone mapping + sRGB itself and the
|
|
6224
|
+
* snapshot matches the frame on screen instead of coming out dark. */
|
|
6225
|
+
captureRasterFade(e, t, r) {
|
|
6226
|
+
const i = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
|
|
6227
|
+
if (!i)
|
|
6228
|
+
return;
|
|
6229
|
+
const s = i.getDrawingBufferSize(new _.Vector2());
|
|
6230
|
+
this.rasterFadeTarget ? (this.rasterFadeTarget.width !== s.x || this.rasterFadeTarget.height !== s.y) && this.rasterFadeTarget.setSize(s.x, s.y) : (this.rasterFadeTarget = new _.WebGLRenderTarget(s.x, s.y, { type: _.HalfFloatType }), this.rasterFadeTarget.texture.colorSpace = _.LinearSRGBColorSpace);
|
|
6231
|
+
const a = i.getRenderTarget();
|
|
6232
|
+
i.setRenderTarget(this.rasterFadeTarget), e.render(t, r), i.setRenderTarget(a);
|
|
6233
|
+
}
|
|
6234
|
+
/** Composite the captured raster over the on-canvas path-traced frame at the
|
|
6235
|
+
* given opacity (1 = pure raster, 0 = fully revealed path tracing). */
|
|
6236
|
+
renderRasterFade(e) {
|
|
6237
|
+
var a, l;
|
|
6238
|
+
const t = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
|
|
6239
|
+
if (!t || !this.rasterFadeTarget)
|
|
6240
|
+
return;
|
|
6241
|
+
(!this.fadeQuad || this.fadeToneMapping !== t.toneMapping) && ((l = (a = this.fadeQuad) == null ? void 0 : a.material) == null || l.dispose(), this.fadeToneMapping = t.toneMapping, this.fadeQuad = new Y(this.createFadeMaterial(t.toneMapping)));
|
|
6242
|
+
const r = this.fadeQuad.material;
|
|
6243
|
+
r.uniforms.tRaster.value = this.rasterFadeTarget.texture, r.uniforms.uOpacity.value = e;
|
|
6244
|
+
const i = t.autoClear, s = t.getRenderTarget();
|
|
6245
|
+
t.setRenderTarget(null), t.autoClear = !1;
|
|
6246
|
+
try {
|
|
6247
|
+
this.fadeQuad.render(t);
|
|
6248
|
+
} finally {
|
|
6249
|
+
t.autoClear = i, t.setRenderTarget(s);
|
|
6250
|
+
}
|
|
6251
|
+
}
|
|
6252
|
+
/** A fade material that tone-maps + sRGB-encodes a linear snapshot exactly the
|
|
6253
|
+
* way the renderer would when drawing to the canvas (mirrors OutputPass), then
|
|
6254
|
+
* applies the fade alpha — so the dissolve's first frame matches the on-screen
|
|
6255
|
+
* raster instead of the darker un-tone-mapped image. */
|
|
6256
|
+
createFadeMaterial(e) {
|
|
6257
|
+
const t = {
|
|
6258
|
+
[_.LinearToneMapping]: "LINEAR_TONE_MAPPING",
|
|
6259
|
+
[_.ReinhardToneMapping]: "REINHARD_TONE_MAPPING",
|
|
6260
|
+
[_.CineonToneMapping]: "CINEON_TONE_MAPPING",
|
|
6261
|
+
[_.ACESFilmicToneMapping]: "ACES_FILMIC_TONE_MAPPING",
|
|
6262
|
+
[_.AgXToneMapping]: "AGX_TONE_MAPPING",
|
|
6263
|
+
[_.NeutralToneMapping]: "NEUTRAL_TONE_MAPPING"
|
|
6264
|
+
}, r = {}, i = t[e];
|
|
6265
|
+
return i && (r[i] = ""), new _.ShaderMaterial({
|
|
6266
|
+
defines: r,
|
|
6267
|
+
uniforms: {
|
|
6268
|
+
tRaster: { value: null },
|
|
6269
|
+
uOpacity: { value: 1 }
|
|
6270
|
+
},
|
|
6271
|
+
vertexShader: `
|
|
6272
|
+
varying vec2 vUv;
|
|
6273
|
+
void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }
|
|
6274
|
+
`,
|
|
6275
|
+
fragmentShader: `
|
|
6276
|
+
uniform sampler2D tRaster;
|
|
6277
|
+
uniform float uOpacity;
|
|
6278
|
+
varying vec2 vUv;
|
|
6279
|
+
void main() {
|
|
6280
|
+
vec3 color = texture2D( tRaster, vUv ).rgb;
|
|
6281
|
+
#ifdef LINEAR_TONE_MAPPING
|
|
6282
|
+
color = LinearToneMapping( color );
|
|
6283
|
+
#elif defined( REINHARD_TONE_MAPPING )
|
|
6284
|
+
color = ReinhardToneMapping( color );
|
|
6285
|
+
#elif defined( CINEON_TONE_MAPPING )
|
|
6286
|
+
color = CineonToneMapping( color );
|
|
6287
|
+
#elif defined( ACES_FILMIC_TONE_MAPPING )
|
|
6288
|
+
color = ACESFilmicToneMapping( color );
|
|
6289
|
+
#elif defined( AGX_TONE_MAPPING )
|
|
6290
|
+
color = AgXToneMapping( color );
|
|
6291
|
+
#elif defined( NEUTRAL_TONE_MAPPING )
|
|
6292
|
+
color = NeutralToneMapping( color );
|
|
6293
|
+
#endif
|
|
6294
|
+
gl_FragColor = vec4( sRGBTransferOETF( vec4( color, 1.0 ) ).rgb, uOpacity );
|
|
6295
|
+
}
|
|
6296
|
+
`,
|
|
6297
|
+
transparent: !0,
|
|
6298
|
+
depthTest: !1,
|
|
6299
|
+
depthWrite: !1
|
|
6300
|
+
});
|
|
6228
6301
|
}
|
|
6229
6302
|
/**
|
|
6230
6303
|
* Render while path tracing is disabled: keep the final accumulated image on
|
|
6231
6304
|
* screen if we just completed, otherwise delegate to the standard renderer.
|
|
6232
6305
|
*/
|
|
6233
6306
|
renderWhileDisabled(e, t) {
|
|
6234
|
-
return this.renderer ? this.sampleCount >= this.settings.samples && this.sampleCount > 0 ? (this.pathTracer &&
|
|
6307
|
+
return this.renderer ? this.sampleCount >= this.settings.samples && this.sampleCount > 0 ? (this.pathTracer && j(this.renderer) && this.renderer.getInternalRenderer().setRenderTarget(null), S.ok(void 0)) : this.renderer.render(e, t) : S.ok(void 0);
|
|
6235
6308
|
}
|
|
6236
6309
|
/**
|
|
6237
6310
|
* Render a single path-tracing sample into the internal buffer, preserving the
|
|
6238
6311
|
* renderer's autoClear/render-target state so the standard view stays visible.
|
|
6239
6312
|
*/
|
|
6240
6313
|
accumulateOneSample() {
|
|
6241
|
-
const e =
|
|
6314
|
+
const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
|
|
6242
6315
|
if (!e)
|
|
6243
6316
|
throw new Error("Three.js renderer not available");
|
|
6244
6317
|
const t = e.autoClear, r = e.getRenderTarget();
|
|
@@ -6252,7 +6325,7 @@ const pe = class pe {
|
|
|
6252
6325
|
* stale frame frozen on screen.
|
|
6253
6326
|
*/
|
|
6254
6327
|
captureCompletedFrame() {
|
|
6255
|
-
const e =
|
|
6328
|
+
const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
|
|
6256
6329
|
if (e && this.pathTracer)
|
|
6257
6330
|
try {
|
|
6258
6331
|
const t = e.autoClear;
|
|
@@ -6262,7 +6335,7 @@ const pe = class pe {
|
|
|
6262
6335
|
} catch (t) {
|
|
6263
6336
|
console.warn("Failed to present path traced result:", t);
|
|
6264
6337
|
}
|
|
6265
|
-
return this.disableAfterSelfPause("completed"),
|
|
6338
|
+
return this.disableAfterSelfPause("completed"), S.ok(void 0);
|
|
6266
6339
|
}
|
|
6267
6340
|
getSampleCount() {
|
|
6268
6341
|
return this.sampleCount;
|
|
@@ -6297,14 +6370,14 @@ const pe = class pe {
|
|
|
6297
6370
|
}
|
|
6298
6371
|
this.pathTracer = null;
|
|
6299
6372
|
}
|
|
6300
|
-
this.convertedEnvTexture && (this.convertedEnvTexture.dispose(), this.convertedEnvTexture = null), this.sampleCount = 0, this.sceneInitialized = !1, this.createAttempts = 0, this.renderer = null;
|
|
6373
|
+
this.convertedEnvTexture && (this.convertedEnvTexture.dispose(), this.convertedEnvTexture = null), this.fadeQuad && (this.fadeQuad.material.dispose(), this.fadeQuad = null), this.fadeToneMapping = null, this.rasterFadeTarget && (this.rasterFadeTarget.dispose(), this.rasterFadeTarget = null), this.sampleCount = 0, this.sceneInitialized = !1, this.createAttempts = 0, this.renderer = null;
|
|
6301
6374
|
}
|
|
6302
6375
|
isSupported() {
|
|
6303
6376
|
return document.createElement("canvas").getContext("webgl2") !== null;
|
|
6304
6377
|
}
|
|
6305
6378
|
};
|
|
6306
|
-
|
|
6307
|
-
let
|
|
6379
|
+
M.CAMERA_SETTLE_MS = 200, M.FADE_SAMPLES = 256, M.FADE_HOLD_SAMPLES = 4, M.FADE_PREVIEW_OPACITY = 0.3, M.FADE_RELEASE_FRACTION = 0.5;
|
|
6380
|
+
let ut = M;
|
|
6308
6381
|
export {
|
|
6309
|
-
|
|
6382
|
+
ut as ThreePathTracingService
|
|
6310
6383
|
};
|