softbox 4.8.0 → 4.10.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/{ThreePathTracingService-BgK90Qzi.cjs → ThreePathTracingService-BqI6Nw-K.cjs} +50 -26
- package/dist/{ThreePathTracingService-yfJv1Gh-.js → ThreePathTracingService-Dj2JP7gs.js} +811 -696
- package/dist/index-DC_xAbSh.cjs +29 -0
- package/dist/{index-C4Vga5nj.js → index-DOb7Peb_.js} +2773 -2658
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/simple-viewer.cjs +1 -1
- package/dist/simple-viewer.es.js +1 -1
- package/package.json +1 -1
- package/dist/index-CPZ7CXqQ.cjs +0 -29
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { UnsignedIntType as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
function
|
|
6
|
-
switch (
|
|
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-DOb7Peb_.js";
|
|
5
|
+
function or(o) {
|
|
6
|
+
switch (o) {
|
|
7
7
|
case 1:
|
|
8
8
|
return "R";
|
|
9
9
|
case 2:
|
|
@@ -15,10 +15,10 @@ function sr(s) {
|
|
|
15
15
|
}
|
|
16
16
|
throw new Error();
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
switch (
|
|
18
|
+
function nr(o) {
|
|
19
|
+
switch (o) {
|
|
20
20
|
case 1:
|
|
21
|
-
return
|
|
21
|
+
return pe;
|
|
22
22
|
case 2:
|
|
23
23
|
return ht;
|
|
24
24
|
case 3:
|
|
@@ -27,10 +27,10 @@ function or(s) {
|
|
|
27
27
|
return I;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
function Le(
|
|
31
|
-
switch (
|
|
30
|
+
function Le(o) {
|
|
31
|
+
switch (o) {
|
|
32
32
|
case 1:
|
|
33
|
-
return
|
|
33
|
+
return Ft;
|
|
34
34
|
case 2:
|
|
35
35
|
return ft;
|
|
36
36
|
case 3:
|
|
@@ -39,7 +39,7 @@ function Le(s) {
|
|
|
39
39
|
return Ae;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
class gt extends
|
|
42
|
+
class gt extends F {
|
|
43
43
|
constructor() {
|
|
44
44
|
super(), this.minFilter = T, this.magFilter = T, this.generateMipmaps = !1, this.overrideItemSize = null, this._forcedType = null;
|
|
45
45
|
}
|
|
@@ -60,17 +60,17 @@ class gt extends M {
|
|
|
60
60
|
throw new Error("VertexAttributeTexture: overrideItemSize must divide evenly into buffer length.");
|
|
61
61
|
e.itemSize = t, e.count = i * r / t;
|
|
62
62
|
}
|
|
63
|
-
const
|
|
64
|
-
let h = this._forcedType,
|
|
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
65
|
if (h === null)
|
|
66
|
-
switch (
|
|
66
|
+
switch (u) {
|
|
67
67
|
case Float32Array:
|
|
68
68
|
h = R;
|
|
69
69
|
break;
|
|
70
70
|
case Uint8Array:
|
|
71
71
|
case Uint16Array:
|
|
72
72
|
case Uint32Array:
|
|
73
|
-
h =
|
|
73
|
+
h = ae;
|
|
74
74
|
break;
|
|
75
75
|
case Int8Array:
|
|
76
76
|
case Int16Array:
|
|
@@ -78,31 +78,31 @@ class gt extends M {
|
|
|
78
78
|
h = we;
|
|
79
79
|
break;
|
|
80
80
|
}
|
|
81
|
-
let n, x, m, g, c =
|
|
81
|
+
let n, x, m, g, c = or(s);
|
|
82
82
|
switch (h) {
|
|
83
83
|
case R:
|
|
84
|
-
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);
|
|
85
85
|
break;
|
|
86
86
|
case we:
|
|
87
|
-
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);
|
|
88
88
|
break;
|
|
89
|
-
case
|
|
90
|
-
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);
|
|
91
91
|
break;
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
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;
|
|
95
95
|
e.normalized = !1;
|
|
96
96
|
for (let w = 0; w < a; w++) {
|
|
97
|
-
const
|
|
98
|
-
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);
|
|
99
99
|
}
|
|
100
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;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
class vt extends gt {
|
|
104
104
|
constructor() {
|
|
105
|
-
super(), this._forcedType =
|
|
105
|
+
super(), this._forcedType = ae;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
class xt extends gt {
|
|
@@ -110,9 +110,9 @@ class xt extends gt {
|
|
|
110
110
|
super(), this._forcedType = R;
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
class
|
|
113
|
+
class lr {
|
|
114
114
|
constructor() {
|
|
115
|
-
this.index = new vt(), this.position = new xt(), this.bvhBounds = 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;
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
118
|
* Updates the object and associated textures with data from the provided BVH.
|
|
@@ -122,16 +122,16 @@ class nr {
|
|
|
122
122
|
*/
|
|
123
123
|
updateFrom(e) {
|
|
124
124
|
const { geometry: t } = e;
|
|
125
|
-
if (
|
|
125
|
+
if (ur(e, this.bvhBounds, this.bvhContents), this.position.updateFrom(t.attributes.position), e.indirect) {
|
|
126
126
|
const r = e._indirectBuffer;
|
|
127
127
|
if (this._cachedIndexAttr === null || this._cachedIndexAttr.count !== r.length)
|
|
128
128
|
if (t.index)
|
|
129
129
|
this._cachedIndexAttr = t.index.clone();
|
|
130
130
|
else {
|
|
131
131
|
const i = $t(jt(t));
|
|
132
|
-
this._cachedIndexAttr = new
|
|
132
|
+
this._cachedIndexAttr = new O(i, 1, !1);
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
cr(t, r, this._cachedIndexAttr), this.index.updateFrom(this._cachedIndexAttr);
|
|
135
135
|
} else
|
|
136
136
|
this.index.updateFrom(t.index);
|
|
137
137
|
}
|
|
@@ -145,34 +145,34 @@ class nr {
|
|
|
145
145
|
e && e.dispose(), t && t.dispose(), r && r.dispose(), i && i.dispose();
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
const r = t.array, i =
|
|
150
|
-
for (let
|
|
151
|
-
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];
|
|
152
152
|
for (let d = 0; d < 3; d++)
|
|
153
|
-
r[l + d] = i ? i[
|
|
153
|
+
r[l + d] = i ? i[u + d] : u + d;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
function
|
|
157
|
-
const r =
|
|
156
|
+
function ur(o, e, t) {
|
|
157
|
+
const r = o._roots;
|
|
158
158
|
if (r.length !== 1)
|
|
159
159
|
throw new Error("MeshBVHUniformStruct: Multi-root BVHs not supported.");
|
|
160
|
-
const i = r[0],
|
|
161
|
-
for (let x = 0; 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
162
|
const m = x * We / 4, g = m * 2, c = Zt(m);
|
|
163
163
|
for (let p = 0; p < 3; p++)
|
|
164
164
|
h[8 * x + 0 + p] = l[c + 0 + p], h[8 * x + 4 + p] = l[c + 3 + p];
|
|
165
|
-
if (Yt(g,
|
|
166
|
-
const p = Xt(g,
|
|
165
|
+
if (Yt(g, s)) {
|
|
166
|
+
const p = Xt(g, s), v = Qt(m, a), b = Jt | p;
|
|
167
167
|
n[x * 2 + 0] = b, n[x * 2 + 1] = v;
|
|
168
168
|
} else {
|
|
169
169
|
const p = a[m + 6], v = Kt(m, a);
|
|
170
170
|
n[x * 2 + 0] = v, n[x * 2 + 1] = p;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
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 =
|
|
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();
|
|
174
174
|
}
|
|
175
|
-
const
|
|
175
|
+
const fr = (
|
|
176
176
|
/* glsl */
|
|
177
177
|
`
|
|
178
178
|
|
|
@@ -257,7 +257,7 @@ void ndcToCameraRay(
|
|
|
257
257
|
|
|
258
258
|
}
|
|
259
259
|
`
|
|
260
|
-
),
|
|
260
|
+
), hr = (
|
|
261
261
|
/* glsl */
|
|
262
262
|
`
|
|
263
263
|
|
|
@@ -464,7 +464,7 @@ bool _bvhIntersectFirstHit(
|
|
|
464
464
|
|
|
465
465
|
}
|
|
466
466
|
`
|
|
467
|
-
),
|
|
467
|
+
), dr = (
|
|
468
468
|
/* glsl */
|
|
469
469
|
`
|
|
470
470
|
struct BVH {
|
|
@@ -478,317 +478,317 @@ struct BVH {
|
|
|
478
478
|
};
|
|
479
479
|
`
|
|
480
480
|
);
|
|
481
|
-
function bt(
|
|
482
|
-
if (
|
|
483
|
-
const r =
|
|
484
|
-
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++) {
|
|
485
485
|
const a = i + t;
|
|
486
|
-
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));
|
|
487
487
|
}
|
|
488
488
|
} else {
|
|
489
|
-
const r = e.array, i = r.constructor,
|
|
490
|
-
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);
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
|
-
function
|
|
494
|
-
const t =
|
|
495
|
-
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);
|
|
496
496
|
}
|
|
497
|
-
function
|
|
498
|
-
if (!
|
|
497
|
+
function J(o, e) {
|
|
498
|
+
if (!o && !e)
|
|
499
499
|
return !0;
|
|
500
|
-
if (!!
|
|
500
|
+
if (!!o != !!e)
|
|
501
501
|
return !1;
|
|
502
|
-
const t =
|
|
503
|
-
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);
|
|
504
504
|
}
|
|
505
|
-
function
|
|
506
|
-
const e =
|
|
507
|
-
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"))
|
|
508
508
|
throw new Error("StaticGeometryGenerator: position attribute is required.");
|
|
509
|
-
for (let r = 0; r <
|
|
510
|
-
const i =
|
|
511
|
-
let
|
|
509
|
+
for (let r = 0; r < o.length; ++r) {
|
|
510
|
+
const i = o[r];
|
|
511
|
+
let s = 0;
|
|
512
512
|
if (e !== (i.index !== null))
|
|
513
513
|
throw new Error("StaticGeometryGenerator: All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.");
|
|
514
514
|
for (const a in i.attributes) {
|
|
515
515
|
if (!t.has(a))
|
|
516
516
|
throw new Error('StaticGeometryGenerator: All geometries must have compatible attributes; make sure "' + a + '" attribute exists among all geometries, or in none of them.');
|
|
517
|
-
|
|
517
|
+
s++;
|
|
518
518
|
}
|
|
519
|
-
if (
|
|
519
|
+
if (s !== t.size)
|
|
520
520
|
throw new Error("StaticGeometryGenerator: All geometries must have the same number of attributes.");
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function pr(o) {
|
|
524
524
|
let e = 0;
|
|
525
|
-
for (let t = 0, r =
|
|
526
|
-
e +=
|
|
525
|
+
for (let t = 0, r = o.length; t < r; t++)
|
|
526
|
+
e += o[t].getIndex().count;
|
|
527
527
|
return e;
|
|
528
528
|
}
|
|
529
|
-
function
|
|
529
|
+
function gr(o) {
|
|
530
530
|
let e = 0;
|
|
531
|
-
for (let t = 0, r =
|
|
532
|
-
e +=
|
|
531
|
+
for (let t = 0, r = o.length; t < r; t++)
|
|
532
|
+
e += o[t].getAttribute("position").count;
|
|
533
533
|
return e;
|
|
534
534
|
}
|
|
535
|
-
function
|
|
536
|
-
|
|
537
|
-
const r =
|
|
535
|
+
function vr(o, e, t) {
|
|
536
|
+
o.index && o.index.count !== e && o.setIndex(null);
|
|
537
|
+
const r = o.attributes;
|
|
538
538
|
for (const i in r)
|
|
539
|
-
r[i].count !== t &&
|
|
539
|
+
r[i].count !== t && o.deleteAttribute(i);
|
|
540
540
|
}
|
|
541
|
-
function
|
|
541
|
+
function xr(o, e = {}, t = new ee()) {
|
|
542
542
|
const {
|
|
543
543
|
useGroups: r = !1,
|
|
544
544
|
forceUpdate: i = !1,
|
|
545
|
-
skipAssigningAttributes:
|
|
545
|
+
skipAssigningAttributes: s = [],
|
|
546
546
|
overwriteIndex: a = !0
|
|
547
547
|
} = e;
|
|
548
|
-
|
|
549
|
-
const l =
|
|
550
|
-
if (
|
|
551
|
-
let
|
|
552
|
-
for (let n = 0, x =
|
|
553
|
-
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];
|
|
554
554
|
let g;
|
|
555
|
-
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;
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
558
|
if (l) {
|
|
559
|
-
let
|
|
560
|
-
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) {
|
|
561
561
|
let n = 0, x = 0;
|
|
562
562
|
const m = t.getIndex();
|
|
563
|
-
for (let g = 0, c =
|
|
564
|
-
const p =
|
|
565
|
-
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]))
|
|
566
566
|
for (let y = 0; y < v.count; ++y)
|
|
567
567
|
m.setX(n + y, v.getX(y) + x);
|
|
568
568
|
n += v.count, x += p.getAttribute("position").count;
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
-
const h = Object.keys(
|
|
573
|
-
for (let
|
|
572
|
+
const h = Object.keys(o[0].attributes);
|
|
573
|
+
for (let f = 0, n = h.length; f < n; f++) {
|
|
574
574
|
let x = !1;
|
|
575
|
-
const m = h[
|
|
575
|
+
const m = h[f];
|
|
576
576
|
if (!t.getAttribute(m)) {
|
|
577
|
-
const p =
|
|
578
|
-
t.setAttribute(m,
|
|
577
|
+
const p = o[0].getAttribute(m);
|
|
578
|
+
t.setAttribute(m, re(p, d)), x = !0;
|
|
579
579
|
}
|
|
580
580
|
let g = 0;
|
|
581
581
|
const c = t.getAttribute(m);
|
|
582
|
-
for (let p = 0, v =
|
|
583
|
-
const b =
|
|
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
584
|
y || bt(w, c, g), g += w.count;
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
|
-
function
|
|
589
|
-
const r =
|
|
590
|
-
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;
|
|
591
591
|
l.length === 0 && (l = [{ count: a, start: 0, materialIndex: 0 }]);
|
|
592
|
-
let
|
|
593
|
-
if (!
|
|
592
|
+
let u = o.getAttribute("materialIndex");
|
|
593
|
+
if (!u || u.count !== s) {
|
|
594
594
|
let h;
|
|
595
|
-
t.length <= 255 ? h = new Uint8Array(
|
|
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
596
|
}
|
|
597
|
-
const d =
|
|
597
|
+
const d = u.array;
|
|
598
598
|
for (let h = 0; h < l.length; h++) {
|
|
599
|
-
const
|
|
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);
|
|
600
600
|
for (let p = 0; p < m; p++) {
|
|
601
601
|
let v = n + p;
|
|
602
602
|
r && (v = r.getX(v)), d[v] = c;
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
}
|
|
606
|
-
function
|
|
607
|
-
if (!
|
|
608
|
-
const t =
|
|
606
|
+
function yr(o, e) {
|
|
607
|
+
if (!o.index) {
|
|
608
|
+
const t = o.attributes.position.count, r = new Array(t);
|
|
609
609
|
for (let i = 0; i < t; i++)
|
|
610
610
|
r[i] = i;
|
|
611
|
-
|
|
611
|
+
o.setIndex(r);
|
|
612
612
|
}
|
|
613
|
-
if (!
|
|
614
|
-
const t =
|
|
615
|
-
|
|
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));
|
|
616
616
|
}
|
|
617
|
-
if (!
|
|
618
|
-
const t =
|
|
619
|
-
|
|
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));
|
|
620
620
|
}
|
|
621
|
-
if (!
|
|
622
|
-
if (
|
|
623
|
-
|
|
621
|
+
if (!o.attributes.tangent && e && e.includes("tangent"))
|
|
622
|
+
if (o.attributes.uv && o.attributes.normal)
|
|
623
|
+
o.computeTangents();
|
|
624
624
|
else {
|
|
625
|
-
const t =
|
|
626
|
-
|
|
625
|
+
const t = o.attributes.position.count;
|
|
626
|
+
o.setAttribute("tangent", new O(new Float32Array(t * 4), 4, !1));
|
|
627
627
|
}
|
|
628
|
-
if (!
|
|
629
|
-
const t =
|
|
630
|
-
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));
|
|
631
631
|
}
|
|
632
632
|
}
|
|
633
|
-
function De(
|
|
633
|
+
function De(o) {
|
|
634
634
|
let e = 0;
|
|
635
|
-
if (
|
|
636
|
-
const t = new Uint8Array(
|
|
637
|
-
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++) {
|
|
638
638
|
const i = t[r];
|
|
639
639
|
e = (e << 5) - e + i, e |= 0;
|
|
640
640
|
}
|
|
641
641
|
}
|
|
642
642
|
return e;
|
|
643
643
|
}
|
|
644
|
-
function Ue(
|
|
645
|
-
let e =
|
|
646
|
-
const t = Object.values(
|
|
647
|
-
|
|
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}`);
|
|
648
648
|
const r = Object.keys(t).sort();
|
|
649
649
|
for (const i of r) {
|
|
650
|
-
const
|
|
651
|
-
e += `${i}_${
|
|
650
|
+
const s = t[i];
|
|
651
|
+
e += `${i}_${s.version}|`;
|
|
652
652
|
}
|
|
653
653
|
return e;
|
|
654
654
|
}
|
|
655
|
-
function
|
|
656
|
-
const e =
|
|
655
|
+
function Ge(o) {
|
|
656
|
+
const e = o.skeleton;
|
|
657
657
|
return e ? (e.boneTexture || e.computeBoneTexture(), `${De(e.boneTexture.image.data.buffer)}_${e.boneTexture.uuid}`) : null;
|
|
658
658
|
}
|
|
659
|
-
class
|
|
659
|
+
class Tr {
|
|
660
660
|
constructor(e = null) {
|
|
661
|
-
this.matrixWorld = new
|
|
661
|
+
this.matrixWorld = new z(), this.geometryHash = null, this.skeletonHash = null, this.primitiveCount = -1, e !== null && this.updateFrom(e);
|
|
662
662
|
}
|
|
663
663
|
updateFrom(e) {
|
|
664
664
|
const t = e.geometry, r = (t.index ? t.index.count : t.attributes.position.count) / 3;
|
|
665
|
-
this.matrixWorld.copy(e.matrixWorld), this.geometryHash = Ue(t), this.primitiveCount = r, this.skeletonHash =
|
|
665
|
+
this.matrixWorld.copy(e.matrixWorld), this.geometryHash = Ue(t), this.primitiveCount = r, this.skeletonHash = Ge(e);
|
|
666
666
|
}
|
|
667
667
|
didChange(e) {
|
|
668
668
|
const t = e.geometry, r = (t.index ? t.index.count : t.attributes.position.count) / 3;
|
|
669
|
-
return !(this.matrixWorld.equals(e.matrixWorld) && this.geometryHash === Ue(t) && this.skeletonHash ===
|
|
669
|
+
return !(this.matrixWorld.equals(e.matrixWorld) && this.geometryHash === Ue(t) && this.skeletonHash === Ge(e) && this.primitiveCount === r);
|
|
670
670
|
}
|
|
671
671
|
}
|
|
672
|
-
const
|
|
673
|
-
function Ye(
|
|
674
|
-
const r =
|
|
675
|
-
qe.fromBufferAttribute(i.attributes.skinIndex, e), $e.fromBufferAttribute(i.attributes.skinWeight, e),
|
|
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);
|
|
676
676
|
for (let l = 0; l < 4; l++) {
|
|
677
|
-
const
|
|
678
|
-
if (
|
|
677
|
+
const u = $e.getComponent(l);
|
|
678
|
+
if (u !== 0) {
|
|
679
679
|
const d = qe.getComponent(l);
|
|
680
|
-
je.multiplyMatrices(
|
|
680
|
+
je.multiplyMatrices(s[d].matrixWorld, a[d]), wr(ue, je, u);
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
|
-
return
|
|
683
|
+
return ue.multiply(o.bindMatrix).premultiply(o.bindMatrixInverse), t.transformDirection(ue), t;
|
|
684
684
|
}
|
|
685
|
-
function Re(
|
|
686
|
-
|
|
687
|
-
for (let
|
|
688
|
-
const l = e[
|
|
689
|
-
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));
|
|
690
690
|
}
|
|
691
|
-
i.add(
|
|
691
|
+
i.add(ce);
|
|
692
692
|
}
|
|
693
|
-
function
|
|
694
|
-
const r =
|
|
695
|
-
for (let
|
|
696
|
-
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;
|
|
697
697
|
}
|
|
698
|
-
function
|
|
699
|
-
const { index: e, attributes: t } =
|
|
698
|
+
function Ir(o) {
|
|
699
|
+
const { index: e, attributes: t } = o;
|
|
700
700
|
if (e)
|
|
701
701
|
for (let r = 0, i = e.count; r < i; r += 3) {
|
|
702
|
-
const
|
|
703
|
-
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);
|
|
704
704
|
}
|
|
705
705
|
else
|
|
706
706
|
for (const r in t) {
|
|
707
|
-
const i = t[r],
|
|
707
|
+
const i = t[r], s = i.itemSize;
|
|
708
708
|
for (let a = 0, l = i.count; a < l; a += 3)
|
|
709
|
-
for (let
|
|
710
|
-
const d = i.getComponent(a,
|
|
711
|
-
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);
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
|
-
return
|
|
714
|
+
return o;
|
|
715
715
|
}
|
|
716
|
-
function
|
|
716
|
+
function Rr(o, e = {}, t = new ee()) {
|
|
717
717
|
e = {
|
|
718
718
|
applyWorldTransforms: !0,
|
|
719
719
|
attributes: [],
|
|
720
720
|
...e
|
|
721
721
|
};
|
|
722
|
-
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;
|
|
723
723
|
for (const v in t.attributes)
|
|
724
724
|
(!e.attributes.includes(v) || !(v in r.attributes)) && t.deleteAttribute(v);
|
|
725
|
-
!t.index && r.index && (t.index = r.index.clone()),
|
|
726
|
-
const d = l.position, h =
|
|
727
|
-
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);
|
|
728
728
|
for (let v = 0, b = l.position.count; v < b; v++)
|
|
729
|
-
|
|
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));
|
|
730
730
|
for (const v in e.attributes) {
|
|
731
731
|
const b = e.attributes[v];
|
|
732
|
-
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]));
|
|
733
733
|
}
|
|
734
|
-
return
|
|
734
|
+
return o.matrixWorld.determinant() < 0 && Ir(t), t;
|
|
735
735
|
}
|
|
736
|
-
class
|
|
736
|
+
class _r extends ee {
|
|
737
737
|
constructor() {
|
|
738
|
-
super(), this.version = 0, this.hash = null, this._diff = new
|
|
738
|
+
super(), this.version = 0, this.hash = null, this._diff = new Tr();
|
|
739
739
|
}
|
|
740
740
|
// returns whether the passed mesh is compatible with this baked geometry
|
|
741
741
|
// such that it can be updated without resizing attributes
|
|
742
742
|
isCompatible(e, t) {
|
|
743
743
|
const r = e.geometry;
|
|
744
744
|
for (let i = 0; i < t.length; i++) {
|
|
745
|
-
const
|
|
746
|
-
if (a && !
|
|
745
|
+
const s = t[i], a = r.attributes[s], l = this.attributes[s];
|
|
746
|
+
if (a && !J(a, l))
|
|
747
747
|
return !1;
|
|
748
748
|
}
|
|
749
749
|
return !0;
|
|
750
750
|
}
|
|
751
751
|
updateFrom(e, t) {
|
|
752
752
|
const r = this._diff;
|
|
753
|
-
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;
|
|
754
754
|
}
|
|
755
755
|
}
|
|
756
|
-
const
|
|
757
|
-
function Sr(
|
|
758
|
-
for (let t = 0, r =
|
|
759
|
-
|
|
760
|
-
|
|
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);
|
|
761
761
|
});
|
|
762
762
|
}
|
|
763
|
-
function
|
|
763
|
+
function Mr(o) {
|
|
764
764
|
const e = [];
|
|
765
|
-
for (let t = 0, r =
|
|
766
|
-
const i =
|
|
765
|
+
for (let t = 0, r = o.length; t < r; t++) {
|
|
766
|
+
const i = o[t];
|
|
767
767
|
Array.isArray(i.material) ? e.push(...i.material) : e.push(i.material);
|
|
768
768
|
}
|
|
769
769
|
return e;
|
|
770
770
|
}
|
|
771
|
-
function
|
|
772
|
-
if (
|
|
771
|
+
function Ar(o, e, t) {
|
|
772
|
+
if (o.length === 0) {
|
|
773
773
|
e.setIndex(null);
|
|
774
774
|
const r = e.attributes;
|
|
775
775
|
for (const i in r)
|
|
776
776
|
e.deleteAttribute(i);
|
|
777
777
|
for (const i in t.attributes)
|
|
778
|
-
e.setAttribute(t.attributes[i], new
|
|
778
|
+
e.setAttribute(t.attributes[i], new O(new Float32Array(0), 4, !1));
|
|
779
779
|
} else
|
|
780
|
-
|
|
780
|
+
xr(o, t, e);
|
|
781
781
|
for (const r in e.attributes)
|
|
782
782
|
e.attributes[r].needsUpdate = !0;
|
|
783
783
|
}
|
|
784
|
-
class
|
|
784
|
+
class Fr {
|
|
785
785
|
constructor(e) {
|
|
786
786
|
this.objects = null, this.useGroups = !0, this.applyWorldTransforms = !0, this.generateMissingAttributes = !0, this.overwriteIndex = !0, this.attributes = ["position", "normal", "color", "tangent", "uv", "uv2"], this._intermediateGeometry = /* @__PURE__ */ new Map(), this._geometryMergeSets = /* @__PURE__ */ new WeakMap(), this._mergeOrder = [], this._dummyMesh = null, this.setObjects(e || []);
|
|
787
787
|
}
|
|
788
788
|
_getDummyMesh() {
|
|
789
789
|
if (!this._dummyMesh) {
|
|
790
|
-
const e = new Dt(), t = new
|
|
791
|
-
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);
|
|
792
792
|
}
|
|
793
793
|
return this._dummyMesh;
|
|
794
794
|
}
|
|
@@ -803,68 +803,68 @@ class Ar {
|
|
|
803
803
|
attributes: this.attributes,
|
|
804
804
|
applyWorldTransforms: this.applyWorldTransforms
|
|
805
805
|
};
|
|
806
|
-
for (let
|
|
807
|
-
const l = t[
|
|
808
|
-
r.delete(
|
|
809
|
-
let d = e.get(
|
|
810
|
-
(!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);
|
|
811
811
|
}
|
|
812
|
-
r.forEach((
|
|
813
|
-
e.delete(
|
|
812
|
+
r.forEach((s) => {
|
|
813
|
+
e.delete(s);
|
|
814
814
|
});
|
|
815
815
|
}
|
|
816
816
|
setObjects(e) {
|
|
817
817
|
Array.isArray(e) ? this.objects = [...e] : this.objects = [e];
|
|
818
818
|
}
|
|
819
|
-
generate(e = new
|
|
820
|
-
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) || [];
|
|
821
821
|
this._updateIntermediateGeometries();
|
|
822
822
|
let h = !1;
|
|
823
823
|
a.length !== d.length && (h = !0);
|
|
824
824
|
for (let n = 0, x = a.length; n < x; n++) {
|
|
825
825
|
const m = a[n], g = i.get(m.uuid);
|
|
826
|
-
|
|
826
|
+
u.push(g);
|
|
827
827
|
const c = d[n];
|
|
828
828
|
!c || c.uuid !== g.uuid ? (l.push(!1), h = !0) : c.version !== g.version ? l.push(!1) : l.push(!0);
|
|
829
829
|
}
|
|
830
|
-
|
|
830
|
+
Ar(u, e, { useGroups: t, forceUpdate: h, skipAssigningAttributes: l, overwriteIndex: r }), h && e.dispose(), s.set(e, u.map((n) => ({
|
|
831
831
|
version: n.version,
|
|
832
832
|
uuid: n.uuid
|
|
833
833
|
})));
|
|
834
|
-
let
|
|
835
|
-
return h ?
|
|
836
|
-
changeType:
|
|
837
|
-
materials:
|
|
834
|
+
let f = Fe;
|
|
835
|
+
return h ? f = Tt : l.includes(!1) && (f = yt), {
|
|
836
|
+
changeType: f,
|
|
837
|
+
materials: Mr(a),
|
|
838
838
|
geometry: e
|
|
839
839
|
};
|
|
840
840
|
}
|
|
841
841
|
}
|
|
842
|
-
function Cr(
|
|
842
|
+
function Cr(o) {
|
|
843
843
|
const e = /* @__PURE__ */ new Set();
|
|
844
|
-
for (let t = 0, r =
|
|
845
|
-
const i =
|
|
846
|
-
for (const
|
|
847
|
-
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];
|
|
848
848
|
a && a.isTexture && e.add(a);
|
|
849
849
|
}
|
|
850
850
|
}
|
|
851
851
|
return Array.from(e);
|
|
852
852
|
}
|
|
853
|
-
function
|
|
853
|
+
function Dr(o) {
|
|
854
854
|
const e = [], t = /* @__PURE__ */ new Set();
|
|
855
|
-
for (let i = 0,
|
|
856
|
-
|
|
855
|
+
for (let i = 0, s = o.length; i < s; i++)
|
|
856
|
+
o[i].traverse((a) => {
|
|
857
857
|
a.visible && (a.isRectAreaLight || a.isSpotLight || a.isPointLight || a.isDirectionalLight) && (e.push(a), a.iesMap && t.add(a.iesMap));
|
|
858
858
|
});
|
|
859
|
-
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);
|
|
860
860
|
return { lights: e, iesTextures: r };
|
|
861
861
|
}
|
|
862
|
-
class
|
|
862
|
+
class Pr {
|
|
863
863
|
get initialized() {
|
|
864
864
|
return !!this.bvh;
|
|
865
865
|
}
|
|
866
866
|
constructor(e) {
|
|
867
|
-
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;
|
|
868
868
|
}
|
|
869
869
|
setObjects(e) {
|
|
870
870
|
this.staticGeometryGenerator.setObjects(e);
|
|
@@ -884,36 +884,36 @@ class Dr {
|
|
|
884
884
|
}
|
|
885
885
|
}
|
|
886
886
|
generate(e = null) {
|
|
887
|
-
const { staticGeometryGenerator: t, geometry: r, attributes: i } = this,
|
|
888
|
-
t.attributes = i,
|
|
889
|
-
|
|
887
|
+
const { staticGeometryGenerator: t, geometry: r, attributes: i } = this, s = t.objects;
|
|
888
|
+
t.attributes = i, s.forEach((f) => {
|
|
889
|
+
f.traverse((n) => {
|
|
890
890
|
n.isSkinnedMesh && n.skeleton && n.skeleton.update();
|
|
891
891
|
});
|
|
892
892
|
});
|
|
893
|
-
const a = t.generate(r), l = a.materials,
|
|
894
|
-
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) {
|
|
895
895
|
if (this.bvh instanceof Promise)
|
|
896
896
|
throw new Error("PathTracingSceneGenerator: BVH is already building asynchronously.");
|
|
897
897
|
if (a.changeType === Tt) {
|
|
898
|
-
const
|
|
898
|
+
const f = {
|
|
899
899
|
strategy: er,
|
|
900
900
|
maxLeafTris: 1,
|
|
901
901
|
indirect: !0,
|
|
902
902
|
onProgress: e,
|
|
903
903
|
...this.bvhOptions
|
|
904
904
|
};
|
|
905
|
-
this._buildAsync ? this.bvh = this._bvhWorker.generate(r,
|
|
905
|
+
this._buildAsync ? this.bvh = this._bvhWorker.generate(r, f) : this.bvh = new tr(r, f);
|
|
906
906
|
} else a.changeType === yt && this.bvh.refit();
|
|
907
907
|
}
|
|
908
908
|
return {
|
|
909
|
-
bvhChanged: a.changeType !==
|
|
909
|
+
bvhChanged: a.changeType !== Fe,
|
|
910
910
|
bvh: this.bvh,
|
|
911
911
|
lights: d,
|
|
912
912
|
iesTextures: h,
|
|
913
913
|
geometry: r,
|
|
914
914
|
materials: l,
|
|
915
|
-
textures:
|
|
916
|
-
objects:
|
|
915
|
+
textures: u,
|
|
916
|
+
objects: s
|
|
917
917
|
};
|
|
918
918
|
}
|
|
919
919
|
}
|
|
@@ -945,10 +945,10 @@ class Pe extends ge {
|
|
|
945
945
|
return !1;
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
|
-
class
|
|
948
|
+
class Er extends Pe {
|
|
949
949
|
constructor(e) {
|
|
950
950
|
super({
|
|
951
|
-
blending:
|
|
951
|
+
blending: se,
|
|
952
952
|
uniforms: {
|
|
953
953
|
target1: { value: null },
|
|
954
954
|
target2: { value: null },
|
|
@@ -1002,9 +1002,9 @@ class Pr extends Pe {
|
|
|
1002
1002
|
}), this.setValues(e);
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
1005
|
-
function
|
|
1005
|
+
function fe(o = 1) {
|
|
1006
1006
|
let e = "uint";
|
|
1007
|
-
return
|
|
1007
|
+
return o > 1 && (e = "uvec" + o), /* glsl */
|
|
1008
1008
|
`
|
|
1009
1009
|
${e} sobolReverseBits( ${e} x ) {
|
|
1010
1010
|
|
|
@@ -1042,9 +1042,9 @@ function ue(s = 1) {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
`;
|
|
1044
1044
|
}
|
|
1045
|
-
function
|
|
1046
|
-
let e = "uint", t = "float", r = "", i = ".r",
|
|
1047
|
-
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 */
|
|
1048
1048
|
`
|
|
1049
1049
|
|
|
1050
1050
|
${t} sobol${r}( int effect ) {
|
|
@@ -1057,7 +1057,7 @@ function fe(s = 1) {
|
|
|
1057
1057
|
${t} sobol_pt = sobolGetTexturePoint( shuffled_index )${i};
|
|
1058
1058
|
${e} result = ${e}( sobol_pt * 16777216.0 );
|
|
1059
1059
|
|
|
1060
|
-
${e} seed2 = sobolHashCombine( seed, ${
|
|
1060
|
+
${e} seed2 = sobolHashCombine( seed, ${s} );
|
|
1061
1061
|
result = nestedUniformScrambleBase2( result, seed2 );
|
|
1062
1062
|
|
|
1063
1063
|
return SOBOL_FACTOR * ${t}( result >> 8 );
|
|
@@ -1073,10 +1073,10 @@ const wt = (
|
|
|
1073
1073
|
const float SOBOL_FACTOR = 1.0 / 16777216.0;
|
|
1074
1074
|
const uint SOBOL_MAX_POINTS = 256u * 256u;
|
|
1075
1075
|
|
|
1076
|
-
${
|
|
1077
|
-
${
|
|
1078
|
-
${
|
|
1079
|
-
${
|
|
1076
|
+
${fe(1)}
|
|
1077
|
+
${fe(2)}
|
|
1078
|
+
${fe(3)}
|
|
1079
|
+
${fe(4)}
|
|
1080
1080
|
|
|
1081
1081
|
uint sobolHash( uint x ) {
|
|
1082
1082
|
|
|
@@ -1091,7 +1091,7 @@ const wt = (
|
|
|
1091
1091
|
}
|
|
1092
1092
|
|
|
1093
1093
|
`
|
|
1094
|
-
),
|
|
1094
|
+
), Or = (
|
|
1095
1095
|
/* glsl */
|
|
1096
1096
|
`
|
|
1097
1097
|
|
|
@@ -1212,19 +1212,19 @@ const wt = (
|
|
|
1212
1212
|
|
|
1213
1213
|
}
|
|
1214
1214
|
|
|
1215
|
-
${
|
|
1216
|
-
${
|
|
1217
|
-
${
|
|
1218
|
-
${
|
|
1215
|
+
${he(1)}
|
|
1216
|
+
${he(2)}
|
|
1217
|
+
${he(3)}
|
|
1218
|
+
${he(4)}
|
|
1219
1219
|
|
|
1220
1220
|
`
|
|
1221
1221
|
);
|
|
1222
|
-
class
|
|
1222
|
+
class Nr extends Pe {
|
|
1223
1223
|
constructor() {
|
|
1224
1224
|
super({
|
|
1225
|
-
blending:
|
|
1225
|
+
blending: se,
|
|
1226
1226
|
uniforms: {
|
|
1227
|
-
resolution: { value: new
|
|
1227
|
+
resolution: { value: new X() }
|
|
1228
1228
|
},
|
|
1229
1229
|
vertexShader: (
|
|
1230
1230
|
/* glsl */
|
|
@@ -1244,7 +1244,7 @@ class Or extends Pe {
|
|
|
1244
1244
|
`
|
|
1245
1245
|
|
|
1246
1246
|
${wt}
|
|
1247
|
-
${
|
|
1247
|
+
${Or}
|
|
1248
1248
|
|
|
1249
1249
|
varying vec2 vUv;
|
|
1250
1250
|
uniform vec2 resolution;
|
|
@@ -1261,7 +1261,7 @@ class Or extends Pe {
|
|
|
1261
1261
|
}
|
|
1262
1262
|
class zr {
|
|
1263
1263
|
generate(e, t = 256) {
|
|
1264
|
-
const r = new
|
|
1264
|
+
const r = new ie(t, t, {
|
|
1265
1265
|
type: R,
|
|
1266
1266
|
format: I,
|
|
1267
1267
|
minFilter: T,
|
|
@@ -1269,11 +1269,11 @@ class zr {
|
|
|
1269
1269
|
generateMipmaps: !1
|
|
1270
1270
|
}), i = e.getRenderTarget();
|
|
1271
1271
|
e.setRenderTarget(r);
|
|
1272
|
-
const
|
|
1273
|
-
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;
|
|
1274
1274
|
}
|
|
1275
1275
|
}
|
|
1276
|
-
class
|
|
1276
|
+
class Hr extends dt {
|
|
1277
1277
|
set bokehSize(e) {
|
|
1278
1278
|
this.fStop = this.getFocalLength() / e;
|
|
1279
1279
|
}
|
|
@@ -1287,132 +1287,132 @@ class Nr extends dt {
|
|
|
1287
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;
|
|
1288
1288
|
}
|
|
1289
1289
|
}
|
|
1290
|
-
class
|
|
1290
|
+
class Br {
|
|
1291
1291
|
constructor() {
|
|
1292
1292
|
this.bokehSize = 0, this.apertureBlades = 0, this.apertureRotation = 0, this.focusDistance = 10, this.anamorphicRatio = 1;
|
|
1293
1293
|
}
|
|
1294
1294
|
updateFrom(e) {
|
|
1295
|
-
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);
|
|
1296
1296
|
}
|
|
1297
1297
|
}
|
|
1298
|
-
function
|
|
1299
|
-
const e = new Uint16Array(
|
|
1300
|
-
for (let t = 0, r =
|
|
1301
|
-
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]);
|
|
1302
1302
|
return e;
|
|
1303
1303
|
}
|
|
1304
|
-
function Xe(
|
|
1305
|
-
let i = t,
|
|
1306
|
-
for (; i <
|
|
1307
|
-
const a = i +
|
|
1308
|
-
|
|
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;
|
|
1309
1309
|
}
|
|
1310
1310
|
return i - t;
|
|
1311
1311
|
}
|
|
1312
|
-
function
|
|
1313
|
-
return 0.2126 *
|
|
1312
|
+
function Wr(o, e, t) {
|
|
1313
|
+
return 0.2126 * o + 0.7152 * e + 0.0722 * t;
|
|
1314
1314
|
}
|
|
1315
|
-
function
|
|
1316
|
-
const t =
|
|
1315
|
+
function Lr(o, e = E) {
|
|
1316
|
+
const t = o.clone();
|
|
1317
1317
|
t.source = new Et({ ...t.image });
|
|
1318
|
-
const { width: r, height: i, data:
|
|
1319
|
-
let a =
|
|
1318
|
+
const { width: r, height: i, data: s } = t.image;
|
|
1319
|
+
let a = s;
|
|
1320
1320
|
if (t.type !== e) {
|
|
1321
|
-
e ===
|
|
1321
|
+
e === E ? a = new Uint16Array(s.length) : a = new Float32Array(s.length);
|
|
1322
1322
|
let l;
|
|
1323
|
-
|
|
1324
|
-
for (let
|
|
1325
|
-
let h =
|
|
1326
|
-
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));
|
|
1327
1327
|
}
|
|
1328
1328
|
t.image.data = a, t.type = e;
|
|
1329
1329
|
}
|
|
1330
1330
|
if (t.flipY) {
|
|
1331
1331
|
const l = a;
|
|
1332
1332
|
a = a.slice();
|
|
1333
|
-
for (let
|
|
1333
|
+
for (let u = 0; u < i; u++)
|
|
1334
1334
|
for (let d = 0; d < r; d++) {
|
|
1335
|
-
const h = i -
|
|
1336
|
-
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];
|
|
1337
1337
|
}
|
|
1338
1338
|
t.flipY = !1, t.image.data = a;
|
|
1339
1339
|
}
|
|
1340
1340
|
return t;
|
|
1341
1341
|
}
|
|
1342
|
-
class
|
|
1342
|
+
class Ur {
|
|
1343
1343
|
constructor() {
|
|
1344
|
-
const e = new
|
|
1345
|
-
e.type =
|
|
1346
|
-
const t = new
|
|
1347
|
-
t.type =
|
|
1348
|
-
const r = new
|
|
1349
|
-
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;
|
|
1350
1350
|
}
|
|
1351
1351
|
dispose() {
|
|
1352
1352
|
this.marginalWeights.dispose(), this.conditionalWeights.dispose(), this.map.dispose();
|
|
1353
1353
|
}
|
|
1354
1354
|
updateFrom(e) {
|
|
1355
|
-
const t =
|
|
1356
|
-
t.wrapS =
|
|
1357
|
-
const { width: r, height: i, data:
|
|
1358
|
-
let h = 0,
|
|
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;
|
|
1359
1359
|
for (let c = 0; c < i; c++) {
|
|
1360
1360
|
let p = 0;
|
|
1361
1361
|
for (let v = 0; v < r; v++) {
|
|
1362
|
-
const b = c * r + v, y =
|
|
1363
|
-
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;
|
|
1364
1364
|
}
|
|
1365
1365
|
if (p !== 0)
|
|
1366
1366
|
for (let v = c * r, b = c * r + r; v < b; v++)
|
|
1367
1367
|
a[v] /= p, l[v] /= p;
|
|
1368
|
-
|
|
1368
|
+
f += p, u[c] = p, d[c] = f;
|
|
1369
1369
|
}
|
|
1370
|
-
if (
|
|
1371
|
-
for (let c = 0, p =
|
|
1372
|
-
|
|
1370
|
+
if (f !== 0)
|
|
1371
|
+
for (let c = 0, p = u.length; c < p; c++)
|
|
1372
|
+
u[c] /= f, d[c] /= f;
|
|
1373
1373
|
const n = new Uint16Array(i), x = new Uint16Array(r * i);
|
|
1374
1374
|
for (let c = 0; c < i; c++) {
|
|
1375
1375
|
const p = (c + 1) / i, v = Xe(d, p);
|
|
1376
|
-
n[c] =
|
|
1376
|
+
n[c] = N.toHalfFloat((v + 0.5) / i);
|
|
1377
1377
|
}
|
|
1378
1378
|
for (let c = 0; c < i; c++)
|
|
1379
1379
|
for (let p = 0; p < r; p++) {
|
|
1380
1380
|
const v = c * r + p, b = (p + 1) / r, y = Xe(l, b, c * r, r);
|
|
1381
|
-
x[v] =
|
|
1381
|
+
x[v] = N.toHalfFloat((y + 0.5) / r);
|
|
1382
1382
|
}
|
|
1383
1383
|
this.dispose();
|
|
1384
1384
|
const { marginalWeights: m, conditionalWeights: g } = this;
|
|
1385
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;
|
|
1386
1386
|
}
|
|
1387
1387
|
}
|
|
1388
|
-
const
|
|
1389
|
-
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 {
|
|
1390
1390
|
constructor() {
|
|
1391
|
-
const e = new
|
|
1392
|
-
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;
|
|
1393
1393
|
}
|
|
1394
1394
|
updateFrom(e, t = []) {
|
|
1395
|
-
const r = this.tex, i = Math.max(e.length *
|
|
1396
|
-
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);
|
|
1397
1397
|
const a = r.image.data;
|
|
1398
|
-
for (let
|
|
1399
|
-
const h = e[
|
|
1398
|
+
for (let u = 0, d = e.length; u < d; u++) {
|
|
1399
|
+
const h = e[u], f = u * Se * 4;
|
|
1400
1400
|
let n = 0;
|
|
1401
|
-
for (let m = 0; m <
|
|
1402
|
-
a[
|
|
1403
|
-
h.getWorldPosition(
|
|
1404
|
-
let x =
|
|
1405
|
-
if (h.isRectAreaLight && h.isCircular ? x = Vr : h.isSpotLight ? x =
|
|
1406
|
-
|
|
1401
|
+
for (let m = 0; m < Se * 4; m++)
|
|
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
1407
|
else if (h.isSpotLight) {
|
|
1408
1408
|
const m = h.radius || 0;
|
|
1409
|
-
Ke.setFromMatrixPosition(h.matrixWorld),
|
|
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
1410
|
} else if (h.isPointLight) {
|
|
1411
|
-
const m =
|
|
1412
|
-
a[
|
|
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
1413
|
} else if (h.isDirectionalLight) {
|
|
1414
|
-
const m =
|
|
1415
|
-
|
|
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;
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
1418
|
this.count = e.length;
|
|
@@ -1420,12 +1420,12 @@ class Yr {
|
|
|
1420
1420
|
return this.hash !== l ? (this.hash = l, r.needsUpdate = !0, !0) : !1;
|
|
1421
1421
|
}
|
|
1422
1422
|
}
|
|
1423
|
-
function Ze(
|
|
1423
|
+
function Ze(o, e, t, r, i) {
|
|
1424
1424
|
if (e > r)
|
|
1425
1425
|
throw new Error();
|
|
1426
|
-
const
|
|
1426
|
+
const s = o.length / e, a = o.constructor.BYTES_PER_ELEMENT * 8;
|
|
1427
1427
|
let l = 1;
|
|
1428
|
-
switch (
|
|
1428
|
+
switch (o.constructor) {
|
|
1429
1429
|
case Uint8Array:
|
|
1430
1430
|
case Uint16Array:
|
|
1431
1431
|
case Uint32Array:
|
|
@@ -1437,52 +1437,52 @@ function Ze(s, e, t, r, i) {
|
|
|
1437
1437
|
l = 2 ** (a - 1) - 1;
|
|
1438
1438
|
break;
|
|
1439
1439
|
}
|
|
1440
|
-
for (let
|
|
1441
|
-
const d = 4 *
|
|
1442
|
-
for (let
|
|
1443
|
-
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;
|
|
1444
1444
|
}
|
|
1445
1445
|
}
|
|
1446
|
-
class
|
|
1446
|
+
class Qr extends kt {
|
|
1447
1447
|
constructor() {
|
|
1448
1448
|
super(), this._textures = [], this.type = R, this.format = I, this.internalFormat = "RGBA32F";
|
|
1449
1449
|
}
|
|
1450
1450
|
updateAttribute(e, t) {
|
|
1451
1451
|
const r = this._textures[e];
|
|
1452
1452
|
r.updateFrom(t);
|
|
1453
|
-
const i = r.image,
|
|
1454
|
-
if (i.width !==
|
|
1453
|
+
const i = r.image, s = this.image;
|
|
1454
|
+
if (i.width !== s.width || i.height !== s.height)
|
|
1455
1455
|
throw new Error("FloatAttributeTextureArray: Attribute must be the same dimensions when updating single layer.");
|
|
1456
|
-
const { width: a, height: l, data:
|
|
1457
|
-
let
|
|
1458
|
-
|
|
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;
|
|
1459
1459
|
}
|
|
1460
1460
|
setAttributes(e) {
|
|
1461
1461
|
const t = e[0].count, r = e.length;
|
|
1462
|
-
for (let
|
|
1463
|
-
if (e[
|
|
1462
|
+
for (let f = 0, n = r; f < n; f++)
|
|
1463
|
+
if (e[f].count !== t)
|
|
1464
1464
|
throw new Error("FloatAttributeTextureArray: All attributes must have the same item count.");
|
|
1465
1465
|
const i = this._textures;
|
|
1466
1466
|
for (; i.length < r; ) {
|
|
1467
|
-
const
|
|
1468
|
-
i.push(
|
|
1467
|
+
const f = new xt();
|
|
1468
|
+
i.push(f);
|
|
1469
1469
|
}
|
|
1470
1470
|
for (; i.length > r; )
|
|
1471
1471
|
i.pop();
|
|
1472
|
-
for (let
|
|
1473
|
-
i[
|
|
1472
|
+
for (let f = 0, n = r; f < n; f++)
|
|
1473
|
+
i[f].updateFrom(e[f]);
|
|
1474
1474
|
const a = i[0].image, l = this.image;
|
|
1475
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));
|
|
1476
|
-
const { data:
|
|
1477
|
-
for (let
|
|
1478
|
-
const x = i[
|
|
1479
|
-
let c = e[
|
|
1480
|
-
c === 3 && (c = 4), Ze(x.image.data, c,
|
|
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);
|
|
1481
1481
|
}
|
|
1482
1482
|
this.dispose(), this.needsUpdate = !0;
|
|
1483
1483
|
}
|
|
1484
1484
|
}
|
|
1485
|
-
class
|
|
1485
|
+
class Kr extends Qr {
|
|
1486
1486
|
updateNormalAttribute(e) {
|
|
1487
1487
|
this.updateAttribute(0, e);
|
|
1488
1488
|
}
|
|
@@ -1499,44 +1499,44 @@ class Qr extends Xr {
|
|
|
1499
1499
|
this.setAttributes([e, t, r, i]);
|
|
1500
1500
|
}
|
|
1501
1501
|
}
|
|
1502
|
-
function Ee(
|
|
1503
|
-
return
|
|
1502
|
+
function Ee(o, e) {
|
|
1503
|
+
return o.uuid < e.uuid ? 1 : o.uuid > e.uuid ? -1 : 0;
|
|
1504
1504
|
}
|
|
1505
|
-
function
|
|
1506
|
-
return `${
|
|
1505
|
+
function Ce(o) {
|
|
1506
|
+
return `${o.source.uuid}:${o.colorSpace}`;
|
|
1507
1507
|
}
|
|
1508
|
-
function
|
|
1508
|
+
function Zr(o) {
|
|
1509
1509
|
const e = /* @__PURE__ */ new Set(), t = [];
|
|
1510
|
-
for (let r = 0, i =
|
|
1511
|
-
const
|
|
1512
|
-
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));
|
|
1513
1513
|
}
|
|
1514
1514
|
return t;
|
|
1515
1515
|
}
|
|
1516
|
-
function
|
|
1517
|
-
const e =
|
|
1516
|
+
function Jr(o) {
|
|
1517
|
+
const e = o.map((r) => r.iesMap || null).filter((r) => r), t = new Set(e);
|
|
1518
1518
|
return Array.from(t).sort(Ee);
|
|
1519
1519
|
}
|
|
1520
|
-
function
|
|
1520
|
+
function ea(o) {
|
|
1521
1521
|
const e = /* @__PURE__ */ new Set();
|
|
1522
|
-
for (let r = 0, i =
|
|
1523
|
-
const
|
|
1524
|
-
for (const a in
|
|
1525
|
-
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];
|
|
1526
1526
|
l && l.isTexture && e.add(l);
|
|
1527
1527
|
}
|
|
1528
1528
|
}
|
|
1529
1529
|
const t = Array.from(e);
|
|
1530
|
-
return
|
|
1530
|
+
return Zr(t).sort(Ee);
|
|
1531
1531
|
}
|
|
1532
|
-
function
|
|
1532
|
+
function ta(o) {
|
|
1533
1533
|
const e = [];
|
|
1534
|
-
return
|
|
1534
|
+
return o.traverse((t) => {
|
|
1535
1535
|
t.visible && (t.isRectAreaLight || t.isSpotLight || t.isPointLight || t.isDirectionalLight) && e.push(t);
|
|
1536
1536
|
}), e.sort(Ee);
|
|
1537
1537
|
}
|
|
1538
1538
|
const It = 45, Je = It * 4;
|
|
1539
|
-
class
|
|
1539
|
+
class ra {
|
|
1540
1540
|
constructor() {
|
|
1541
1541
|
this._features = {};
|
|
1542
1542
|
}
|
|
@@ -1550,22 +1550,22 @@ class ta {
|
|
|
1550
1550
|
this._features = {};
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
1553
|
-
class
|
|
1553
|
+
class aa extends F {
|
|
1554
1554
|
constructor() {
|
|
1555
|
-
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();
|
|
1556
1556
|
}
|
|
1557
1557
|
updateFrom(e, t) {
|
|
1558
1558
|
function r(m, g, c = -1) {
|
|
1559
1559
|
if (g in m && m[g]) {
|
|
1560
|
-
const p =
|
|
1561
|
-
return
|
|
1560
|
+
const p = Ce(m[g]);
|
|
1561
|
+
return f[p];
|
|
1562
1562
|
} else
|
|
1563
1563
|
return c;
|
|
1564
1564
|
}
|
|
1565
1565
|
function i(m, g, c) {
|
|
1566
1566
|
return g in m ? m[g] : c;
|
|
1567
1567
|
}
|
|
1568
|
-
function
|
|
1568
|
+
function s(m, g, c, p) {
|
|
1569
1569
|
const v = m[g] && m[g].isTexture ? m[g] : null;
|
|
1570
1570
|
if (v) {
|
|
1571
1571
|
v.matrixAutoUpdate && v.updateMatrix();
|
|
@@ -1576,10 +1576,10 @@ class ra extends M {
|
|
|
1576
1576
|
return 8;
|
|
1577
1577
|
}
|
|
1578
1578
|
let a = 0;
|
|
1579
|
-
const l = e.length * It,
|
|
1579
|
+
const l = e.length * It, u = Math.ceil(Math.sqrt(l)) || 1, { image: d, features: h } = this, f = {};
|
|
1580
1580
|
for (let m = 0, g = t.length; m < g; m++)
|
|
1581
|
-
|
|
1582
|
-
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);
|
|
1583
1583
|
const n = d.data;
|
|
1584
1584
|
h.reset();
|
|
1585
1585
|
for (let m = 0, g = e.length; m < g; m++) {
|
|
@@ -1602,63 +1602,63 @@ class ra extends M {
|
|
|
1602
1602
|
case Ht:
|
|
1603
1603
|
n[a++] = 1;
|
|
1604
1604
|
break;
|
|
1605
|
-
case
|
|
1605
|
+
case zt:
|
|
1606
1606
|
n[a++] = -1;
|
|
1607
1607
|
break;
|
|
1608
|
-
case
|
|
1608
|
+
case Nt:
|
|
1609
1609
|
n[a++] = 0;
|
|
1610
1610
|
break;
|
|
1611
1611
|
}
|
|
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 +=
|
|
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);
|
|
1613
1613
|
}
|
|
1614
1614
|
const x = De(n.buffer);
|
|
1615
1615
|
return this.hash !== x ? (this.hash = x, this.needsUpdate = !0, !0) : !1;
|
|
1616
1616
|
}
|
|
1617
1617
|
}
|
|
1618
|
-
const et = new
|
|
1619
|
-
function
|
|
1620
|
-
return
|
|
1618
|
+
const et = new oe();
|
|
1619
|
+
function ia(o) {
|
|
1620
|
+
return o ? `${o.uuid}:${o.version}` : null;
|
|
1621
1621
|
}
|
|
1622
|
-
function
|
|
1622
|
+
function sa(o, e) {
|
|
1623
1623
|
for (const t in e)
|
|
1624
|
-
t in
|
|
1624
|
+
t in o && (o[t] = e[t]);
|
|
1625
1625
|
}
|
|
1626
1626
|
class tt extends Bt {
|
|
1627
1627
|
constructor(e, t, r) {
|
|
1628
1628
|
const i = {
|
|
1629
1629
|
format: I,
|
|
1630
1630
|
type: Me,
|
|
1631
|
-
minFilter:
|
|
1632
|
-
magFilter:
|
|
1633
|
-
wrapS:
|
|
1634
|
-
wrapT:
|
|
1631
|
+
minFilter: D,
|
|
1632
|
+
magFilter: D,
|
|
1633
|
+
wrapS: H,
|
|
1634
|
+
wrapT: H,
|
|
1635
1635
|
generateMipmaps: !1,
|
|
1636
1636
|
...r
|
|
1637
1637
|
};
|
|
1638
|
-
super(e, t, 1, i),
|
|
1638
|
+
super(e, t, 1, i), sa(this.texture, i), this.texture.setTextures = (...a) => {
|
|
1639
1639
|
this.setTextures(...a);
|
|
1640
1640
|
}, this.hashes = [null];
|
|
1641
|
-
const
|
|
1642
|
-
this.fsQuad =
|
|
1641
|
+
const s = new Y(new oa());
|
|
1642
|
+
this.fsQuad = s;
|
|
1643
1643
|
}
|
|
1644
1644
|
setTextures(e, t, r = this.width, i = this.height) {
|
|
1645
|
-
const
|
|
1645
|
+
const s = e.getRenderTarget(), a = e.toneMapping, l = e.getClearAlpha();
|
|
1646
1646
|
e.getClearColor(et);
|
|
1647
|
-
const
|
|
1648
|
-
(r !== this.width || i !== this.height || this.depth !==
|
|
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
1649
|
const d = this.fsQuad, h = this.hashes;
|
|
1650
|
-
let
|
|
1651
|
-
for (let n = 0, x =
|
|
1652
|
-
const m = t[n], g =
|
|
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,
|
|
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);
|
|
1654
1654
|
}
|
|
1655
|
-
return d.material.map = null, e.setClearColor(et, l), e.setRenderTarget(
|
|
1655
|
+
return d.material.map = null, e.setClearColor(et, l), e.setRenderTarget(s), e.toneMapping = a, f;
|
|
1656
1656
|
}
|
|
1657
1657
|
dispose() {
|
|
1658
1658
|
super.dispose(), this.fsQuad.dispose();
|
|
1659
1659
|
}
|
|
1660
1660
|
}
|
|
1661
|
-
class
|
|
1661
|
+
class oa extends ge {
|
|
1662
1662
|
get map() {
|
|
1663
1663
|
return this.uniforms.map.value;
|
|
1664
1664
|
}
|
|
@@ -1697,60 +1697,60 @@ class sa extends ge {
|
|
|
1697
1697
|
});
|
|
1698
1698
|
}
|
|
1699
1699
|
}
|
|
1700
|
-
function
|
|
1701
|
-
for (let t =
|
|
1702
|
-
const r = Math.floor(e() * (t + 1)), i =
|
|
1703
|
-
|
|
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;
|
|
1704
1704
|
}
|
|
1705
|
-
return
|
|
1705
|
+
return o;
|
|
1706
1706
|
}
|
|
1707
|
-
class
|
|
1707
|
+
class la {
|
|
1708
1708
|
constructor(e, t, r = Math.random) {
|
|
1709
|
-
const i = e ** t,
|
|
1709
|
+
const i = e ** t, s = new Uint16Array(i);
|
|
1710
1710
|
let a = i;
|
|
1711
1711
|
for (let l = 0; l < i; l++)
|
|
1712
|
-
|
|
1712
|
+
s[l] = l;
|
|
1713
1713
|
this.samples = new Float32Array(t), this.strataCount = e, this.reset = function() {
|
|
1714
1714
|
for (let l = 0; l < i; l++)
|
|
1715
|
-
|
|
1715
|
+
s[l] = l;
|
|
1716
1716
|
a = 0;
|
|
1717
1717
|
}, this.reshuffle = function() {
|
|
1718
1718
|
a = 0;
|
|
1719
1719
|
}, this.next = function() {
|
|
1720
1720
|
const { samples: l } = this;
|
|
1721
|
-
a >=
|
|
1722
|
-
let
|
|
1721
|
+
a >= s.length && (na(s, r), this.reshuffle());
|
|
1722
|
+
let u = s[a++];
|
|
1723
1723
|
for (let d = 0; d < t; d++)
|
|
1724
|
-
l[d] = (
|
|
1724
|
+
l[d] = (u % e + r()) / e, u = Math.floor(u / e);
|
|
1725
1725
|
return l;
|
|
1726
1726
|
};
|
|
1727
1727
|
}
|
|
1728
1728
|
}
|
|
1729
|
-
class
|
|
1729
|
+
class ca {
|
|
1730
1730
|
constructor(e, t, r = Math.random) {
|
|
1731
1731
|
let i = 0;
|
|
1732
|
-
for (const
|
|
1733
|
-
i +=
|
|
1734
|
-
const
|
|
1732
|
+
for (const u of t)
|
|
1733
|
+
i += u;
|
|
1734
|
+
const s = new Float32Array(i), a = [];
|
|
1735
1735
|
let l = 0;
|
|
1736
|
-
for (const
|
|
1737
|
-
const d = new
|
|
1738
|
-
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);
|
|
1739
1739
|
}
|
|
1740
|
-
this.samples =
|
|
1741
|
-
for (const
|
|
1742
|
-
|
|
1743
|
-
return
|
|
1740
|
+
this.samples = s, this.strataCount = e, this.next = function() {
|
|
1741
|
+
for (const u of a)
|
|
1742
|
+
u.next();
|
|
1743
|
+
return s;
|
|
1744
1744
|
}, this.reshuffle = function() {
|
|
1745
|
-
for (const
|
|
1746
|
-
|
|
1745
|
+
for (const u of a)
|
|
1746
|
+
u.reshuffle();
|
|
1747
1747
|
}, this.reset = function() {
|
|
1748
|
-
for (const
|
|
1749
|
-
|
|
1748
|
+
for (const u of a)
|
|
1749
|
+
u.reset();
|
|
1750
1750
|
};
|
|
1751
1751
|
}
|
|
1752
1752
|
}
|
|
1753
|
-
class
|
|
1753
|
+
class ua {
|
|
1754
1754
|
constructor(e = 0) {
|
|
1755
1755
|
this.m = 2147483648, this.a = 1103515245, this.c = 12345, this.seed = e;
|
|
1756
1756
|
}
|
|
@@ -1761,15 +1761,15 @@ class ca {
|
|
|
1761
1761
|
return this.nextInt() / (this.m - 1);
|
|
1762
1762
|
}
|
|
1763
1763
|
}
|
|
1764
|
-
class
|
|
1764
|
+
class fa extends F {
|
|
1765
1765
|
constructor(e = 1, t = 1, r = 8) {
|
|
1766
|
-
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);
|
|
1767
1767
|
}
|
|
1768
1768
|
init(e = this.image.height, t = this.image.width, r = this.strata) {
|
|
1769
1769
|
const { image: i } = this;
|
|
1770
1770
|
if (i.width === t && i.height === e && this.sampler !== null)
|
|
1771
1771
|
return;
|
|
1772
|
-
const
|
|
1772
|
+
const s = new Array(e * t).fill(4), a = new ca(r, s, this.random);
|
|
1773
1773
|
i.width = t, i.height = e, i.data = a.samples, this.sampler = a, this.dispose(), this.next();
|
|
1774
1774
|
}
|
|
1775
1775
|
next() {
|
|
@@ -1779,16 +1779,16 @@ class ua extends M {
|
|
|
1779
1779
|
this.sampler.reset(), this.generator.seed = 0;
|
|
1780
1780
|
}
|
|
1781
1781
|
}
|
|
1782
|
-
function
|
|
1783
|
-
for (let t =
|
|
1784
|
-
const r = ~~((e() - 1e-6) * t), i =
|
|
1785
|
-
|
|
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;
|
|
1786
1786
|
}
|
|
1787
1787
|
}
|
|
1788
|
-
function
|
|
1789
|
-
|
|
1788
|
+
function da(o, e) {
|
|
1789
|
+
o.fill(0);
|
|
1790
1790
|
for (let t = 0; t < e; t++)
|
|
1791
|
-
|
|
1791
|
+
o[t] = 1;
|
|
1792
1792
|
}
|
|
1793
1793
|
class rt {
|
|
1794
1794
|
constructor(e) {
|
|
@@ -1797,33 +1797,33 @@ class rt {
|
|
|
1797
1797
|
findVoid() {
|
|
1798
1798
|
const { score: e, binaryPattern: t } = this;
|
|
1799
1799
|
let r = 1 / 0, i = -1;
|
|
1800
|
-
for (let
|
|
1801
|
-
if (t[
|
|
1800
|
+
for (let s = 0, a = t.length; s < a; s++) {
|
|
1801
|
+
if (t[s] !== 0)
|
|
1802
1802
|
continue;
|
|
1803
|
-
const l = e[
|
|
1804
|
-
l < r && (r = l, i =
|
|
1803
|
+
const l = e[s];
|
|
1804
|
+
l < r && (r = l, i = s);
|
|
1805
1805
|
}
|
|
1806
1806
|
return i;
|
|
1807
1807
|
}
|
|
1808
1808
|
findCluster() {
|
|
1809
1809
|
const { score: e, binaryPattern: t } = this;
|
|
1810
1810
|
let r = -1 / 0, i = -1;
|
|
1811
|
-
for (let
|
|
1812
|
-
if (t[
|
|
1811
|
+
for (let s = 0, a = t.length; s < a; s++) {
|
|
1812
|
+
if (t[s] !== 1)
|
|
1813
1813
|
continue;
|
|
1814
|
-
const l = e[
|
|
1815
|
-
l > r && (r = l, i =
|
|
1814
|
+
const l = e[s];
|
|
1815
|
+
l > r && (r = l, i = s);
|
|
1816
1816
|
}
|
|
1817
1817
|
return i;
|
|
1818
1818
|
}
|
|
1819
1819
|
setSigma(e) {
|
|
1820
1820
|
if (e === this.sigma)
|
|
1821
1821
|
return;
|
|
1822
|
-
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;
|
|
1823
1823
|
for (let a = -t; a <= t; a++)
|
|
1824
1824
|
for (let l = -t; l <= t; l++) {
|
|
1825
|
-
const
|
|
1826
|
-
i[
|
|
1825
|
+
const u = (t + l) * r + a + t, d = a * a + l * l;
|
|
1826
|
+
i[u] = Math.E ** (-d / (2 * s));
|
|
1827
1827
|
}
|
|
1828
1828
|
this.lookupTable = i, this.sigma = e, this.radius = t;
|
|
1829
1829
|
}
|
|
@@ -1833,7 +1833,7 @@ class rt {
|
|
|
1833
1833
|
invert() {
|
|
1834
1834
|
const { binaryPattern: e, score: t, size: r } = this;
|
|
1835
1835
|
t.fill(0);
|
|
1836
|
-
for (let i = 0,
|
|
1836
|
+
for (let i = 0, s = e.length; i < s; i++)
|
|
1837
1837
|
if (e[i] === 0) {
|
|
1838
1838
|
const a = ~~(i / r), l = i - a * r;
|
|
1839
1839
|
this.updateScore(l, a, 1), e[i] = 1;
|
|
@@ -1841,16 +1841,16 @@ class rt {
|
|
|
1841
1841
|
e[i] = 0;
|
|
1842
1842
|
}
|
|
1843
1843
|
updateScore(e, t, r) {
|
|
1844
|
-
const { size: i, score:
|
|
1844
|
+
const { size: i, score: s, lookupTable: a } = this, l = this.radius, u = 2 * l + 1;
|
|
1845
1845
|
for (let d = -l; d <= l; d++)
|
|
1846
1846
|
for (let h = -l; h <= l; h++) {
|
|
1847
|
-
const
|
|
1847
|
+
const f = (l + h) * u + d + l, n = a[f];
|
|
1848
1848
|
let x = e + d;
|
|
1849
1849
|
x = x < 0 ? i + x : x % i;
|
|
1850
1850
|
let m = t + h;
|
|
1851
1851
|
m = m < 0 ? i + m : m % i;
|
|
1852
1852
|
const g = m * i + x;
|
|
1853
|
-
|
|
1853
|
+
s[g] += r * n;
|
|
1854
1854
|
}
|
|
1855
1855
|
}
|
|
1856
1856
|
addPointIndex(e) {
|
|
@@ -1867,7 +1867,7 @@ class rt {
|
|
|
1867
1867
|
this.resize(e.size), this.score.set(e.score), this.binaryPattern.set(e.binaryPattern), this.setSigma(e.sigma), this.count = e.count;
|
|
1868
1868
|
}
|
|
1869
1869
|
}
|
|
1870
|
-
class
|
|
1870
|
+
class ma {
|
|
1871
1871
|
constructor() {
|
|
1872
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);
|
|
1873
1873
|
}
|
|
@@ -1877,76 +1877,76 @@ class da {
|
|
|
1877
1877
|
savedSamples: t,
|
|
1878
1878
|
sigma: r,
|
|
1879
1879
|
majorityPointsRatio: i,
|
|
1880
|
-
size:
|
|
1880
|
+
size: s
|
|
1881
1881
|
} = this;
|
|
1882
|
-
e.resize(
|
|
1883
|
-
const a = Math.floor(
|
|
1884
|
-
|
|
1885
|
-
for (let
|
|
1886
|
-
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);
|
|
1887
1887
|
for (; ; ) {
|
|
1888
|
-
const
|
|
1889
|
-
e.removePointIndex(
|
|
1888
|
+
const f = e.findCluster();
|
|
1889
|
+
e.removePointIndex(f);
|
|
1890
1890
|
const n = e.findVoid();
|
|
1891
|
-
if (
|
|
1892
|
-
e.addPointIndex(
|
|
1891
|
+
if (f === n) {
|
|
1892
|
+
e.addPointIndex(f);
|
|
1893
1893
|
break;
|
|
1894
1894
|
}
|
|
1895
1895
|
e.addPointIndex(n);
|
|
1896
1896
|
}
|
|
1897
|
-
const
|
|
1897
|
+
const u = new Uint32Array(s * s);
|
|
1898
1898
|
t.copy(e);
|
|
1899
1899
|
let d;
|
|
1900
1900
|
for (d = e.count - 1; d >= 0; ) {
|
|
1901
|
-
const
|
|
1902
|
-
e.removePointIndex(
|
|
1901
|
+
const f = e.findCluster();
|
|
1902
|
+
e.removePointIndex(f), u[f] = d, d--;
|
|
1903
1903
|
}
|
|
1904
|
-
const h =
|
|
1904
|
+
const h = s * s;
|
|
1905
1905
|
for (d = t.count; d < h / 2; ) {
|
|
1906
|
-
const
|
|
1907
|
-
t.addPointIndex(
|
|
1906
|
+
const f = t.findVoid();
|
|
1907
|
+
t.addPointIndex(f), u[f] = d, d++;
|
|
1908
1908
|
}
|
|
1909
1909
|
for (t.invert(); d < h; ) {
|
|
1910
|
-
const
|
|
1911
|
-
t.removePointIndex(
|
|
1910
|
+
const f = t.findCluster();
|
|
1911
|
+
t.removePointIndex(f), u[f] = d, d++;
|
|
1912
1912
|
}
|
|
1913
|
-
return { data:
|
|
1913
|
+
return { data: u, maxValue: h };
|
|
1914
1914
|
}
|
|
1915
1915
|
}
|
|
1916
|
-
function
|
|
1917
|
-
return
|
|
1916
|
+
function pa(o) {
|
|
1917
|
+
return o >= 3 ? 4 : o;
|
|
1918
1918
|
}
|
|
1919
|
-
function
|
|
1920
|
-
switch (
|
|
1919
|
+
function ga(o) {
|
|
1920
|
+
switch (o) {
|
|
1921
1921
|
case 1:
|
|
1922
|
-
return
|
|
1922
|
+
return pe;
|
|
1923
1923
|
case 2:
|
|
1924
1924
|
return ht;
|
|
1925
1925
|
default:
|
|
1926
1926
|
return I;
|
|
1927
1927
|
}
|
|
1928
1928
|
}
|
|
1929
|
-
class
|
|
1929
|
+
class va extends F {
|
|
1930
1930
|
constructor(e = 64, t = 1) {
|
|
1931
1931
|
super(new Float32Array(4), 1, 1, I, R), this.minFilter = T, this.magFilter = T, this.size = e, this.channels = t, this.update();
|
|
1932
1932
|
}
|
|
1933
1933
|
update() {
|
|
1934
|
-
const e = this.channels, t = this.size, r = new
|
|
1934
|
+
const e = this.channels, t = this.size, r = new ma();
|
|
1935
1935
|
r.channels = e, r.size = t;
|
|
1936
|
-
const i =
|
|
1937
|
-
(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());
|
|
1938
1938
|
const a = this.image.data;
|
|
1939
|
-
for (let l = 0,
|
|
1940
|
-
const d = r.generate(), h = d.data,
|
|
1939
|
+
for (let l = 0, u = e; l < u; l++) {
|
|
1940
|
+
const d = r.generate(), h = d.data, f = d.maxValue;
|
|
1941
1941
|
for (let n = 0, x = h.length; n < x; n++) {
|
|
1942
|
-
const m = h[n] /
|
|
1942
|
+
const m = h[n] / f;
|
|
1943
1943
|
a[n * i + l] = m;
|
|
1944
1944
|
}
|
|
1945
1945
|
}
|
|
1946
1946
|
this.needsUpdate = !0;
|
|
1947
1947
|
}
|
|
1948
1948
|
}
|
|
1949
|
-
const
|
|
1949
|
+
const xa = (
|
|
1950
1950
|
/* glsl */
|
|
1951
1951
|
`
|
|
1952
1952
|
|
|
@@ -1961,7 +1961,7 @@ const va = (
|
|
|
1961
1961
|
};
|
|
1962
1962
|
|
|
1963
1963
|
`
|
|
1964
|
-
),
|
|
1964
|
+
), ba = (
|
|
1965
1965
|
/* glsl */
|
|
1966
1966
|
`
|
|
1967
1967
|
|
|
@@ -1976,7 +1976,7 @@ const va = (
|
|
|
1976
1976
|
};
|
|
1977
1977
|
|
|
1978
1978
|
`
|
|
1979
|
-
),
|
|
1979
|
+
), ya = (
|
|
1980
1980
|
/* glsl */
|
|
1981
1981
|
`
|
|
1982
1982
|
|
|
@@ -2065,7 +2065,7 @@ const va = (
|
|
|
2065
2065
|
}
|
|
2066
2066
|
|
|
2067
2067
|
`
|
|
2068
|
-
),
|
|
2068
|
+
), Ta = (
|
|
2069
2069
|
/* glsl */
|
|
2070
2070
|
`
|
|
2071
2071
|
|
|
@@ -2275,7 +2275,7 @@ const va = (
|
|
|
2275
2275
|
}
|
|
2276
2276
|
|
|
2277
2277
|
`
|
|
2278
|
-
),
|
|
2278
|
+
), wa = (
|
|
2279
2279
|
/* glsl */
|
|
2280
2280
|
`
|
|
2281
2281
|
|
|
@@ -2340,7 +2340,7 @@ const va = (
|
|
|
2340
2340
|
};
|
|
2341
2341
|
|
|
2342
2342
|
`
|
|
2343
|
-
),
|
|
2343
|
+
), Ia = (
|
|
2344
2344
|
/* glsl */
|
|
2345
2345
|
`
|
|
2346
2346
|
|
|
@@ -2410,7 +2410,7 @@ const va = (
|
|
|
2410
2410
|
|
|
2411
2411
|
}
|
|
2412
2412
|
`
|
|
2413
|
-
),
|
|
2413
|
+
), Ra = (
|
|
2414
2414
|
/* glsl */
|
|
2415
2415
|
`
|
|
2416
2416
|
|
|
@@ -2628,7 +2628,7 @@ const va = (
|
|
|
2628
2628
|
}
|
|
2629
2629
|
|
|
2630
2630
|
`
|
|
2631
|
-
),
|
|
2631
|
+
), _a = (
|
|
2632
2632
|
/* glsl */
|
|
2633
2633
|
`
|
|
2634
2634
|
|
|
@@ -2822,7 +2822,7 @@ const va = (
|
|
|
2822
2822
|
}
|
|
2823
2823
|
|
|
2824
2824
|
`
|
|
2825
|
-
),
|
|
2825
|
+
), Ma = (
|
|
2826
2826
|
/* glsl */
|
|
2827
2827
|
`
|
|
2828
2828
|
|
|
@@ -2905,7 +2905,7 @@ const va = (
|
|
|
2905
2905
|
}
|
|
2906
2906
|
|
|
2907
2907
|
`
|
|
2908
|
-
),
|
|
2908
|
+
), Aa = (
|
|
2909
2909
|
/* glsl */
|
|
2910
2910
|
`
|
|
2911
2911
|
|
|
@@ -2969,7 +2969,7 @@ const va = (
|
|
|
2969
2969
|
}
|
|
2970
2970
|
|
|
2971
2971
|
`
|
|
2972
|
-
),
|
|
2972
|
+
), Fa = (
|
|
2973
2973
|
/*glsl */
|
|
2974
2974
|
`
|
|
2975
2975
|
|
|
@@ -3224,7 +3224,7 @@ const va = (
|
|
|
3224
3224
|
}
|
|
3225
3225
|
|
|
3226
3226
|
`
|
|
3227
|
-
),
|
|
3227
|
+
), Da = (
|
|
3228
3228
|
/* glsl */
|
|
3229
3229
|
`
|
|
3230
3230
|
|
|
@@ -3665,7 +3665,7 @@ const va = (
|
|
|
3665
3665
|
}
|
|
3666
3666
|
|
|
3667
3667
|
`
|
|
3668
|
-
),
|
|
3668
|
+
), Pa = (
|
|
3669
3669
|
/* glsl */
|
|
3670
3670
|
`
|
|
3671
3671
|
|
|
@@ -3689,7 +3689,7 @@ const va = (
|
|
|
3689
3689
|
}
|
|
3690
3690
|
|
|
3691
3691
|
`
|
|
3692
|
-
),
|
|
3692
|
+
), Ea = (
|
|
3693
3693
|
/* glsl */
|
|
3694
3694
|
`
|
|
3695
3695
|
|
|
@@ -3793,7 +3793,7 @@ const va = (
|
|
|
3793
3793
|
}
|
|
3794
3794
|
|
|
3795
3795
|
`
|
|
3796
|
-
),
|
|
3796
|
+
), Oa = (
|
|
3797
3797
|
/* glsl */
|
|
3798
3798
|
`
|
|
3799
3799
|
|
|
@@ -4030,7 +4030,7 @@ const va = (
|
|
|
4030
4030
|
}
|
|
4031
4031
|
|
|
4032
4032
|
`
|
|
4033
|
-
),
|
|
4033
|
+
), Na = (
|
|
4034
4034
|
/* glsl */
|
|
4035
4035
|
`
|
|
4036
4036
|
|
|
@@ -4274,7 +4274,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4274
4274
|
}
|
|
4275
4275
|
|
|
4276
4276
|
`
|
|
4277
|
-
),
|
|
4277
|
+
), Ha = (
|
|
4278
4278
|
/* glsl */
|
|
4279
4279
|
`
|
|
4280
4280
|
|
|
@@ -4360,7 +4360,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4360
4360
|
}
|
|
4361
4361
|
|
|
4362
4362
|
`
|
|
4363
|
-
),
|
|
4363
|
+
), Ba = (
|
|
4364
4364
|
/*glsl*/
|
|
4365
4365
|
`
|
|
4366
4366
|
|
|
@@ -4459,7 +4459,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4459
4459
|
}
|
|
4460
4460
|
|
|
4461
4461
|
`
|
|
4462
|
-
),
|
|
4462
|
+
), Wa = (
|
|
4463
4463
|
/* glsl */
|
|
4464
4464
|
`
|
|
4465
4465
|
|
|
@@ -4784,7 +4784,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4784
4784
|
|
|
4785
4785
|
}
|
|
4786
4786
|
`
|
|
4787
|
-
),
|
|
4787
|
+
), La = (
|
|
4788
4788
|
/* glsl */
|
|
4789
4789
|
`
|
|
4790
4790
|
|
|
@@ -4836,7 +4836,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4836
4836
|
}
|
|
4837
4837
|
|
|
4838
4838
|
`
|
|
4839
|
-
),
|
|
4839
|
+
), Ua = (
|
|
4840
4840
|
/* glsl */
|
|
4841
4841
|
`
|
|
4842
4842
|
|
|
@@ -4887,7 +4887,7 @@ bool bvhIntersectFogVolumeHit(
|
|
|
4887
4887
|
|
|
4888
4888
|
`
|
|
4889
4889
|
);
|
|
4890
|
-
class
|
|
4890
|
+
class Ga extends Pe {
|
|
4891
4891
|
onBeforeRender() {
|
|
4892
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);
|
|
4893
4893
|
}
|
|
@@ -4917,42 +4917,42 @@ class Ua extends Pe {
|
|
|
4917
4917
|
},
|
|
4918
4918
|
uniforms: {
|
|
4919
4919
|
// path trace uniforms
|
|
4920
|
-
resolution: { value: new
|
|
4920
|
+
resolution: { value: new X() },
|
|
4921
4921
|
opacity: { value: 1 },
|
|
4922
4922
|
bounces: { value: 10 },
|
|
4923
4923
|
transmissiveBounces: { value: 10 },
|
|
4924
4924
|
filterGlossyFactor: { value: 0 },
|
|
4925
4925
|
// camera uniforms
|
|
4926
|
-
physicalCamera: { value: new
|
|
4927
|
-
cameraWorldMatrix: { value: new
|
|
4928
|
-
invProjectionMatrix: { value: new
|
|
4926
|
+
physicalCamera: { value: new Br() },
|
|
4927
|
+
cameraWorldMatrix: { value: new z() },
|
|
4928
|
+
invProjectionMatrix: { value: new z() },
|
|
4929
4929
|
// scene uniforms
|
|
4930
|
-
bvh: { value: new
|
|
4931
|
-
attributesArray: { value: new
|
|
4930
|
+
bvh: { value: new lr() },
|
|
4931
|
+
attributesArray: { value: new Kr() },
|
|
4932
4932
|
materialIndexAttribute: { value: new vt() },
|
|
4933
|
-
materials: { value: new
|
|
4933
|
+
materials: { value: new aa() },
|
|
4934
4934
|
textures: { value: new tt().texture },
|
|
4935
4935
|
// light uniforms
|
|
4936
|
-
lights: { value: new
|
|
4936
|
+
lights: { value: new Xr() },
|
|
4937
4937
|
iesProfiles: { value: new tt(360, 180, {
|
|
4938
|
-
type:
|
|
4939
|
-
wrapS:
|
|
4940
|
-
wrapT:
|
|
4938
|
+
type: E,
|
|
4939
|
+
wrapS: B,
|
|
4940
|
+
wrapT: B
|
|
4941
4941
|
}).texture },
|
|
4942
4942
|
environmentIntensity: { value: 1 },
|
|
4943
|
-
environmentRotation: { value: new
|
|
4944
|
-
envMapInfo: { value: new
|
|
4943
|
+
environmentRotation: { value: new z() },
|
|
4944
|
+
envMapInfo: { value: new Ur() },
|
|
4945
4945
|
// background uniforms
|
|
4946
4946
|
backgroundBlur: { value: 0 },
|
|
4947
4947
|
backgroundMap: { value: null },
|
|
4948
4948
|
backgroundAlpha: { value: 1 },
|
|
4949
4949
|
backgroundIntensity: { value: 1 },
|
|
4950
|
-
backgroundRotation: { value: new
|
|
4950
|
+
backgroundRotation: { value: new z() },
|
|
4951
4951
|
// randomness uniforms
|
|
4952
4952
|
seed: { value: 0 },
|
|
4953
4953
|
sobolTexture: { value: null },
|
|
4954
|
-
stratifiedTexture: { value: new
|
|
4955
|
-
stratifiedOffsetTexture: { value: new
|
|
4954
|
+
stratifiedTexture: { value: new fa() },
|
|
4955
|
+
stratifiedOffsetTexture: { value: new va(64, 1) }
|
|
4956
4956
|
},
|
|
4957
4957
|
vertexShader: (
|
|
4958
4958
|
/* glsl */
|
|
@@ -4984,16 +4984,16 @@ class Ua extends Pe {
|
|
|
4984
4984
|
#include <common>
|
|
4985
4985
|
|
|
4986
4986
|
// bvh intersection
|
|
4987
|
-
${ur}
|
|
4988
|
-
${hr}
|
|
4989
4987
|
${fr}
|
|
4988
|
+
${dr}
|
|
4989
|
+
${hr}
|
|
4990
4990
|
|
|
4991
4991
|
// uniform structs
|
|
4992
|
-
${va}
|
|
4993
|
-
${ba}
|
|
4994
4992
|
${xa}
|
|
4995
4993
|
${ya}
|
|
4994
|
+
${ba}
|
|
4996
4995
|
${Ta}
|
|
4996
|
+
${wa}
|
|
4997
4997
|
|
|
4998
4998
|
// random
|
|
4999
4999
|
#if RANDOM_TYPE == 2 // Stratified List
|
|
@@ -5029,11 +5029,11 @@ class Ua extends Pe {
|
|
|
5029
5029
|
#endif
|
|
5030
5030
|
|
|
5031
5031
|
// common
|
|
5032
|
-
${
|
|
5032
|
+
${Fa}
|
|
5033
5033
|
${Sa}
|
|
5034
5034
|
${Rt}
|
|
5035
|
-
${_a}
|
|
5036
5035
|
${Ma}
|
|
5036
|
+
${Aa}
|
|
5037
5037
|
|
|
5038
5038
|
// environment
|
|
5039
5039
|
uniform EquirectHdrInfo envMapInfo;
|
|
@@ -5089,16 +5089,16 @@ class Ua extends Pe {
|
|
|
5089
5089
|
float lightsDenom;
|
|
5090
5090
|
|
|
5091
5091
|
// sampling
|
|
5092
|
-
${
|
|
5093
|
-
${wa}
|
|
5092
|
+
${_a}
|
|
5094
5093
|
${Ia}
|
|
5094
|
+
${Ra}
|
|
5095
5095
|
|
|
5096
|
+
${Na}
|
|
5097
|
+
${Ea}
|
|
5098
|
+
${ka}
|
|
5096
5099
|
${Oa}
|
|
5097
5100
|
${Pa}
|
|
5098
|
-
${ka}
|
|
5099
|
-
${Ea}
|
|
5100
5101
|
${Da}
|
|
5101
|
-
${Fa}
|
|
5102
5102
|
|
|
5103
5103
|
float applyFilteredGlossy( float roughness, float accumulatedRoughness ) {
|
|
5104
5104
|
|
|
@@ -5130,12 +5130,12 @@ class Ua extends Pe {
|
|
|
5130
5130
|
|
|
5131
5131
|
}
|
|
5132
5132
|
|
|
5133
|
-
${Wa}
|
|
5134
|
-
${Na}
|
|
5135
5133
|
${La}
|
|
5136
|
-
${za}
|
|
5137
5134
|
${Ha}
|
|
5135
|
+
${Ua}
|
|
5136
|
+
${za}
|
|
5138
5137
|
${Ba}
|
|
5138
|
+
${Wa}
|
|
5139
5139
|
|
|
5140
5140
|
void main() {
|
|
5141
5141
|
|
|
@@ -5434,48 +5434,48 @@ class Ua extends Pe {
|
|
|
5434
5434
|
}
|
|
5435
5435
|
function* Va() {
|
|
5436
5436
|
const {
|
|
5437
|
-
_renderer:
|
|
5437
|
+
_renderer: o,
|
|
5438
5438
|
_fsQuad: e,
|
|
5439
5439
|
_blendQuad: t,
|
|
5440
5440
|
_primaryTarget: r,
|
|
5441
5441
|
_blendTargets: i,
|
|
5442
|
-
_sobolTarget:
|
|
5442
|
+
_sobolTarget: s,
|
|
5443
5443
|
_subframe: a,
|
|
5444
5444
|
alpha: l,
|
|
5445
|
-
material:
|
|
5446
|
-
} = this, d = new
|
|
5445
|
+
material: u
|
|
5446
|
+
} = this, d = new te(), h = new te(), f = t.material;
|
|
5447
5447
|
let [n, x] = i;
|
|
5448
5448
|
for (; ; ) {
|
|
5449
|
-
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);
|
|
5450
5450
|
const [m, g, c, p] = a, v = r.width, b = r.height;
|
|
5451
|
-
|
|
5452
|
-
const y = this.tiles.x || 1, w = this.tiles.y || 1,
|
|
5453
|
-
for (let
|
|
5454
|
-
for (let
|
|
5455
|
-
const
|
|
5456
|
-
|
|
5457
|
-
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;
|
|
5458
5458
|
if (!this.stableTiles) {
|
|
5459
5459
|
const Te = this._currentTile % (y * w);
|
|
5460
|
-
ye = Te % y,
|
|
5460
|
+
ye = Te % y, ze = ~~(Te / y), this._currentTile = Te + 1;
|
|
5461
5461
|
}
|
|
5462
|
-
const He = w -
|
|
5462
|
+
const He = w - ze - 1;
|
|
5463
5463
|
r.scissor.set(
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
Math.min(xe,
|
|
5464
|
+
Oe + ye * xe,
|
|
5465
|
+
ke + He * be,
|
|
5466
|
+
Math.min(xe, W - ye * xe),
|
|
5467
5467
|
Math.min(be, ve - He * be)
|
|
5468
5468
|
), r.viewport.set(
|
|
5469
|
-
ke,
|
|
5470
5469
|
Oe,
|
|
5471
|
-
|
|
5470
|
+
ke,
|
|
5471
|
+
W,
|
|
5472
5472
|
ve
|
|
5473
|
-
),
|
|
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;
|
|
5474
5474
|
}
|
|
5475
5475
|
[n, x] = [x, n];
|
|
5476
5476
|
}
|
|
5477
5477
|
}
|
|
5478
|
-
const it = new
|
|
5478
|
+
const it = new oe();
|
|
5479
5479
|
class st {
|
|
5480
5480
|
get material() {
|
|
5481
5481
|
return this._fsQuad.material;
|
|
@@ -5496,19 +5496,19 @@ class st {
|
|
|
5496
5496
|
return !!this._compilePromise;
|
|
5497
5497
|
}
|
|
5498
5498
|
constructor(e) {
|
|
5499
|
-
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, {
|
|
5500
5500
|
format: I,
|
|
5501
5501
|
type: R,
|
|
5502
5502
|
magFilter: T,
|
|
5503
5503
|
minFilter: T
|
|
5504
5504
|
}), this._blendTargets = [
|
|
5505
|
-
new
|
|
5505
|
+
new ie(1, 1, {
|
|
5506
5506
|
format: I,
|
|
5507
5507
|
type: R,
|
|
5508
5508
|
magFilter: T,
|
|
5509
5509
|
minFilter: T
|
|
5510
5510
|
}),
|
|
5511
|
-
new
|
|
5511
|
+
new ie(1, 1, {
|
|
5512
5512
|
format: I,
|
|
5513
5513
|
type: R,
|
|
5514
5514
|
magFilter: T,
|
|
@@ -5540,15 +5540,15 @@ class st {
|
|
|
5540
5540
|
this._primaryTarget.dispose(), this._blendTargets[0].dispose(), this._blendTargets[1].dispose(), this._sobolTarget.dispose(), this._fsQuad.dispose(), this._blendQuad.dispose(), this._task = null;
|
|
5541
5541
|
}
|
|
5542
5542
|
reset() {
|
|
5543
|
-
const { _renderer: e, _primaryTarget: t, _blendTargets: r } = this, i = e.getRenderTarget(),
|
|
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,
|
|
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());
|
|
5545
5545
|
}
|
|
5546
5546
|
update() {
|
|
5547
5547
|
this.material.onBeforeRender(), !this.isCompiling && (this._task || (this._task = Va.call(this)), this._task.next());
|
|
5548
5548
|
}
|
|
5549
5549
|
}
|
|
5550
|
-
const
|
|
5551
|
-
class
|
|
5550
|
+
const $ = new X(), ot = new X(), de = new Lt(), me = new oe();
|
|
5551
|
+
class qa extends F {
|
|
5552
5552
|
constructor(e = 512, t = 512) {
|
|
5553
5553
|
super(
|
|
5554
5554
|
new Float32Array(e * t * 4),
|
|
@@ -5557,40 +5557,40 @@ class Ga extends M {
|
|
|
5557
5557
|
I,
|
|
5558
5558
|
R,
|
|
5559
5559
|
pt,
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5560
|
+
H,
|
|
5561
|
+
B,
|
|
5562
|
+
D,
|
|
5563
|
+
D
|
|
5564
5564
|
), this.generationCallback = null;
|
|
5565
5565
|
}
|
|
5566
5566
|
update() {
|
|
5567
5567
|
this.dispose(), this.needsUpdate = !0;
|
|
5568
5568
|
const { data: e, width: t, height: r } = this.image;
|
|
5569
5569
|
for (let i = 0; i < t; i++)
|
|
5570
|
-
for (let
|
|
5571
|
-
ot.set(t, r),
|
|
5572
|
-
const l = 4 * (
|
|
5573
|
-
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;
|
|
5574
5574
|
}
|
|
5575
5575
|
}
|
|
5576
5576
|
copy(e) {
|
|
5577
5577
|
return super.copy(e), this.generationCallback = e.generationCallback, this;
|
|
5578
5578
|
}
|
|
5579
5579
|
}
|
|
5580
|
-
const nt = new
|
|
5581
|
-
class
|
|
5580
|
+
const nt = new P();
|
|
5581
|
+
class $a extends qa {
|
|
5582
5582
|
constructor(e = 512) {
|
|
5583
|
-
super(e, e), this.topColor = new
|
|
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
5584
|
nt.setFromSpherical(t);
|
|
5585
5585
|
const a = nt.y * 0.5 + 0.5;
|
|
5586
|
-
|
|
5586
|
+
s.lerpColors(this.bottomColor, this.topColor, a ** this.exponent);
|
|
5587
5587
|
};
|
|
5588
5588
|
}
|
|
5589
5589
|
copy(e) {
|
|
5590
5590
|
return super.copy(e), this.topColor.copy(e.topColor), this.bottomColor.copy(e.bottomColor), this;
|
|
5591
5591
|
}
|
|
5592
5592
|
}
|
|
5593
|
-
class
|
|
5593
|
+
class ja extends ge {
|
|
5594
5594
|
get map() {
|
|
5595
5595
|
return this.uniforms.map.value;
|
|
5596
5596
|
}
|
|
@@ -5677,7 +5677,7 @@ class $a extends ge {
|
|
|
5677
5677
|
}), this.setValues(e);
|
|
5678
5678
|
}
|
|
5679
5679
|
}
|
|
5680
|
-
class
|
|
5680
|
+
class Ya extends ge {
|
|
5681
5681
|
constructor() {
|
|
5682
5682
|
super({
|
|
5683
5683
|
uniforms: {
|
|
@@ -5722,36 +5722,36 @@ class ja extends ge {
|
|
|
5722
5722
|
}
|
|
5723
5723
|
class lt {
|
|
5724
5724
|
constructor(e) {
|
|
5725
|
-
this._renderer = e, this._quad = new
|
|
5725
|
+
this._renderer = e, this._quad = new Y(new Ya());
|
|
5726
5726
|
}
|
|
5727
5727
|
generate(e, t = null, r = null) {
|
|
5728
5728
|
if (!e.isCubeTexture)
|
|
5729
5729
|
throw new Error("CubeToEquirectMaterial: Source can only be cube textures.");
|
|
5730
|
-
const i = e.images[0],
|
|
5730
|
+
const i = e.images[0], s = this._renderer, a = this._quad;
|
|
5731
5731
|
t === null && (t = 4 * i.height), r === null && (r = 2 * i.height);
|
|
5732
|
-
const l = new
|
|
5732
|
+
const l = new ie(t, r, {
|
|
5733
5733
|
type: R,
|
|
5734
5734
|
colorSpace: i.colorSpace
|
|
5735
|
-
}),
|
|
5736
|
-
a.material.defines.CUBEUV_MAX_MIP = `${d}.0`, a.material.defines.CUBEUV_TEXEL_WIDTH =
|
|
5737
|
-
const n =
|
|
5738
|
-
|
|
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;
|
|
5739
5739
|
const m = new Uint16Array(t * r * 4), g = new Float32Array(t * r * 4);
|
|
5740
|
-
|
|
5740
|
+
s.readRenderTargetPixels(l, 0, 0, t, r, g), l.dispose();
|
|
5741
5741
|
for (let p = 0, v = g.length; p < v; p++)
|
|
5742
|
-
m[p] =
|
|
5743
|
-
const c = new
|
|
5744
|
-
return c.minFilter = Ut, c.magFilter =
|
|
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;
|
|
5745
5745
|
}
|
|
5746
5746
|
dispose() {
|
|
5747
5747
|
this._quad.dispose();
|
|
5748
5748
|
}
|
|
5749
5749
|
}
|
|
5750
|
-
function
|
|
5751
|
-
return
|
|
5750
|
+
function Xa(o) {
|
|
5751
|
+
return o.extensions.get("EXT_float_blend");
|
|
5752
5752
|
}
|
|
5753
|
-
const
|
|
5754
|
-
class
|
|
5753
|
+
const Z = new X();
|
|
5754
|
+
class Qa {
|
|
5755
5755
|
get multipleImportanceSampling() {
|
|
5756
5756
|
return !!this._pathTracer.material.defines.FEATURE_MIS;
|
|
5757
5757
|
}
|
|
@@ -5795,17 +5795,17 @@ class Xa {
|
|
|
5795
5795
|
return !!this._pathTracer.isCompiling;
|
|
5796
5796
|
}
|
|
5797
5797
|
constructor(e) {
|
|
5798
|
-
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({
|
|
5799
5799
|
map: null,
|
|
5800
5800
|
transparent: !0,
|
|
5801
|
-
blending:
|
|
5801
|
+
blending: se,
|
|
5802
5802
|
premultipliedAlpha: e.getContextAttributes().premultipliedAlpha
|
|
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
|
|
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) => {
|
|
5804
5804
|
this._renderer.render(t, r);
|
|
5805
5805
|
}, this.renderToCanvasCallback = (t, r, i) => {
|
|
5806
|
-
const
|
|
5807
|
-
r.autoClear = !1, i.render(r), r.autoClear =
|
|
5808
|
-
}, 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());
|
|
5809
5809
|
}
|
|
5810
5810
|
setBVHWorker(e) {
|
|
5811
5811
|
this._generator.setBVHWorker(e);
|
|
@@ -5814,10 +5814,10 @@ class Xa {
|
|
|
5814
5814
|
e.updateMatrixWorld(!0), t.updateMatrixWorld();
|
|
5815
5815
|
const i = this._generator;
|
|
5816
5816
|
if (i.setObjects(e), this._buildAsync)
|
|
5817
|
-
return i.generateAsync(r.onProgress).then((
|
|
5817
|
+
return i.generateAsync(r.onProgress).then((s) => this._updateFromResults(e, t, s));
|
|
5818
5818
|
{
|
|
5819
|
-
const
|
|
5820
|
-
return this._updateFromResults(e, t,
|
|
5819
|
+
const s = i.generate();
|
|
5820
|
+
return this._updateFromResults(e, t, s);
|
|
5821
5821
|
}
|
|
5822
5822
|
}
|
|
5823
5823
|
setSceneAsync(...e) {
|
|
@@ -5833,19 +5833,19 @@ class Xa {
|
|
|
5833
5833
|
e.updateMatrixWorld(), this._pathTracer.setCamera(e), this._lowResPathTracer.setCamera(e), this.reset();
|
|
5834
5834
|
}
|
|
5835
5835
|
updateMaterials() {
|
|
5836
|
-
const e = this._pathTracer.material, t = this._renderer, r = this._materials, i = this.textureSize,
|
|
5837
|
-
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();
|
|
5838
5838
|
}
|
|
5839
5839
|
updateLights() {
|
|
5840
|
-
const e = this.scene, t = this._renderer, r = this._pathTracer.material, i =
|
|
5841
|
-
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();
|
|
5842
5842
|
}
|
|
5843
5843
|
updateEnvironment() {
|
|
5844
5844
|
const e = this.scene, t = this._pathTracer.material;
|
|
5845
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)
|
|
5846
5846
|
t.backgroundMap = null, t.backgroundAlpha = 0;
|
|
5847
5847
|
else if (e.background.isColor) {
|
|
5848
|
-
this._colorBackground = this._colorBackground || new
|
|
5848
|
+
this._colorBackground = this._colorBackground || new $a(16);
|
|
5849
5849
|
const r = this._colorBackground;
|
|
5850
5850
|
r.topColor.equals(e.background) || (r.topColor.set(e.background), r.bottomColor.set(e.background), r.update()), t.backgroundMap = r, t.backgroundAlpha = 1;
|
|
5851
5851
|
} else if (e.background.isCubeTexture) {
|
|
@@ -5869,34 +5869,34 @@ class Xa {
|
|
|
5869
5869
|
_updateFromResults(e, t, r) {
|
|
5870
5870
|
const {
|
|
5871
5871
|
materials: i,
|
|
5872
|
-
geometry:
|
|
5872
|
+
geometry: s,
|
|
5873
5873
|
bvh: a,
|
|
5874
5874
|
bvhChanged: l
|
|
5875
5875
|
} = r;
|
|
5876
5876
|
this._materials = i;
|
|
5877
5877
|
const d = this._pathTracer.material;
|
|
5878
5878
|
return l && (d.bvh.updateFrom(a), d.attributesArray.updateFrom(
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
), 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;
|
|
5884
5884
|
}
|
|
5885
5885
|
renderSample() {
|
|
5886
|
-
const e = this._lowResPathTracer, t = this._pathTracer, r = this._renderer, i = this._clock,
|
|
5887
|
-
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());
|
|
5888
5888
|
const a = i.getDelta() * 1e3, l = i.getElapsedTime() * 1e3;
|
|
5889
|
-
if (!this.pausePathTracing && this.enablePathTracing && this.renderDelay <= l && !this.isCompiling && t.update(), t.alpha = t.material.backgroundAlpha !== 1 || !
|
|
5890
|
-
const
|
|
5891
|
-
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) {
|
|
5892
5892
|
if (this.dynamicLowRes && !this.isCompiling) {
|
|
5893
5893
|
e.samples < 1 && (e.material = t.material, e.update());
|
|
5894
|
-
const h =
|
|
5895
|
-
|
|
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;
|
|
5896
5896
|
}
|
|
5897
5897
|
(!this.dynamicLowRes && this.rasterizeScene || this.dynamicLowRes && this.isCompiling) && this.rasterizeSceneCallback(this.scene, this.camera);
|
|
5898
5898
|
}
|
|
5899
|
-
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);
|
|
5900
5900
|
}
|
|
5901
5901
|
}
|
|
5902
5902
|
reset() {
|
|
@@ -5907,30 +5907,30 @@ class Xa {
|
|
|
5907
5907
|
}
|
|
5908
5908
|
_updateScale() {
|
|
5909
5909
|
if (this.synchronizeRenderSize) {
|
|
5910
|
-
this._renderer.getDrawingBufferSize(
|
|
5911
|
-
const e = Math.floor(this.renderScale *
|
|
5912
|
-
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) {
|
|
5913
5913
|
const r = this.lowResScale;
|
|
5914
5914
|
this._pathTracer.setSize(e, t), this._lowResPathTracer.setSize(Math.floor(e * r), Math.floor(t * r));
|
|
5915
5915
|
}
|
|
5916
5916
|
}
|
|
5917
5917
|
}
|
|
5918
5918
|
}
|
|
5919
|
-
function ct(
|
|
5920
|
-
return typeof
|
|
5919
|
+
function ct(o) {
|
|
5920
|
+
return typeof o == "object" && o !== null && "getInternalRenderer" in o && typeof o.getInternalRenderer == "function";
|
|
5921
5921
|
}
|
|
5922
|
-
function
|
|
5923
|
-
return
|
|
5922
|
+
function j(o) {
|
|
5923
|
+
return o !== null && typeof o == "object" && "getInternalRenderer" in o && typeof o.getInternalRenderer == "function";
|
|
5924
5924
|
}
|
|
5925
|
-
const
|
|
5925
|
+
const M = class M {
|
|
5926
5926
|
constructor() {
|
|
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.settings = {
|
|
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
5928
|
samples: ar,
|
|
5929
5929
|
bounces: 4,
|
|
5930
5930
|
// Reduce bounces for better performance
|
|
5931
5931
|
transmissiveBounces: 2,
|
|
5932
5932
|
// Reduce transmissive bounces
|
|
5933
|
-
renderScale:
|
|
5933
|
+
renderScale: 1,
|
|
5934
5934
|
// Start with lower resolution for better performance
|
|
5935
5935
|
lowResScale: 0.5,
|
|
5936
5936
|
dynamicLowRes: !0,
|
|
@@ -5938,24 +5938,28 @@ const pe = class pe {
|
|
|
5938
5938
|
};
|
|
5939
5939
|
}
|
|
5940
5940
|
/**
|
|
5941
|
-
* Hand the scene to the path tracer with the
|
|
5942
|
-
* helpers hidden
|
|
5943
|
-
*
|
|
5944
|
-
*
|
|
5945
|
-
*
|
|
5946
|
-
*
|
|
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.
|
|
5947
5951
|
*/
|
|
5948
5952
|
ingestSceneWithoutShadowHelpers(e, t) {
|
|
5949
|
-
var
|
|
5950
|
-
const r = [];
|
|
5951
|
-
e.traverse((
|
|
5952
|
-
var
|
|
5953
|
-
(
|
|
5954
|
-
}), 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);
|
|
5955
5959
|
try {
|
|
5956
|
-
(
|
|
5960
|
+
(s = this.pathTracer) == null || s.setScene(e, t);
|
|
5957
5961
|
} finally {
|
|
5958
|
-
r.forEach((
|
|
5962
|
+
r.forEach((a) => a.visible = !0), i.forEach((a) => a.visible = !1);
|
|
5959
5963
|
}
|
|
5960
5964
|
}
|
|
5961
5965
|
/**
|
|
@@ -5970,32 +5974,32 @@ const pe = class pe {
|
|
|
5970
5974
|
if (!i)
|
|
5971
5975
|
return null;
|
|
5972
5976
|
i.drawImage(t, 0, 0);
|
|
5973
|
-
const
|
|
5974
|
-
for (let
|
|
5975
|
-
a[
|
|
5976
|
-
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(
|
|
5977
5981
|
a,
|
|
5978
5982
|
r.width,
|
|
5979
5983
|
r.height,
|
|
5980
|
-
|
|
5981
|
-
|
|
5984
|
+
_.RGBAFormat,
|
|
5985
|
+
_.FloatType
|
|
5982
5986
|
);
|
|
5983
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;
|
|
5984
5988
|
}
|
|
5985
5989
|
async initialize(e) {
|
|
5986
5990
|
try {
|
|
5987
5991
|
return this.renderer = e.renderer, this.enabled = e.enabled, this.isSupported() ? S.ok(void 0) : S.err(
|
|
5988
|
-
new
|
|
5992
|
+
new L(
|
|
5989
5993
|
"Path tracing is not supported in this environment",
|
|
5990
|
-
|
|
5994
|
+
U.PATH_TRACING_INIT_FAILED,
|
|
5991
5995
|
{ reason: "WebGL2 or required extensions not available" }
|
|
5992
5996
|
)
|
|
5993
5997
|
);
|
|
5994
5998
|
} catch (t) {
|
|
5995
5999
|
return S.err(
|
|
5996
|
-
new
|
|
6000
|
+
new L(
|
|
5997
6001
|
"Failed to initialize path tracing",
|
|
5998
|
-
|
|
6002
|
+
U.PATH_TRACING_INIT_FAILED,
|
|
5999
6003
|
{ originalError: t }
|
|
6000
6004
|
)
|
|
6001
6005
|
);
|
|
@@ -6004,24 +6008,24 @@ const pe = class pe {
|
|
|
6004
6008
|
createPathTracer() {
|
|
6005
6009
|
if (this.disposed)
|
|
6006
6010
|
return S.err(
|
|
6007
|
-
new
|
|
6011
|
+
new L(
|
|
6008
6012
|
"Instance is disposed",
|
|
6009
|
-
|
|
6013
|
+
U.INVALID_STATE
|
|
6010
6014
|
)
|
|
6011
6015
|
);
|
|
6012
6016
|
try {
|
|
6013
|
-
const e =
|
|
6014
|
-
return e ? (this.pathTracer = new
|
|
6015
|
-
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(
|
|
6016
6020
|
"Renderer not ready, will retry",
|
|
6017
|
-
|
|
6021
|
+
U.RENDERER_NOT_INITIALIZED
|
|
6018
6022
|
)
|
|
6019
6023
|
);
|
|
6020
6024
|
} catch (e) {
|
|
6021
6025
|
return S.err(
|
|
6022
|
-
new
|
|
6026
|
+
new L(
|
|
6023
6027
|
"Failed to create path tracer",
|
|
6024
|
-
|
|
6028
|
+
U.PATH_TRACING_INIT_FAILED,
|
|
6025
6029
|
{ originalError: e }
|
|
6026
6030
|
)
|
|
6027
6031
|
);
|
|
@@ -6030,7 +6034,7 @@ const pe = class pe {
|
|
|
6030
6034
|
setEnabled(e) {
|
|
6031
6035
|
if (this.enabled !== e && (this.enabled = e, !e)) {
|
|
6032
6036
|
this.resumable = !1, this.reset(), this.sceneInitialized = !1;
|
|
6033
|
-
const t =
|
|
6037
|
+
const t = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
|
|
6034
6038
|
t && (t.autoClear = !0);
|
|
6035
6039
|
}
|
|
6036
6040
|
}
|
|
@@ -6066,18 +6070,18 @@ const pe = class pe {
|
|
|
6066
6070
|
const i = this.extractThreeObjects(e, t);
|
|
6067
6071
|
if (!i)
|
|
6068
6072
|
return S.err(
|
|
6069
|
-
new
|
|
6073
|
+
new L(
|
|
6070
6074
|
"Could not extract Three.js scene or camera",
|
|
6071
|
-
|
|
6075
|
+
U.INVALID_PARAMETER
|
|
6072
6076
|
)
|
|
6073
6077
|
);
|
|
6074
|
-
const { threeScene:
|
|
6078
|
+
const { threeScene: s, threeCamera: a } = i;
|
|
6075
6079
|
if (!this.sceneInitialized) {
|
|
6076
6080
|
const l = await this.initializeSceneForPathTracing(
|
|
6077
6081
|
r,
|
|
6078
6082
|
e,
|
|
6079
6083
|
t,
|
|
6080
|
-
|
|
6084
|
+
s,
|
|
6081
6085
|
a
|
|
6082
6086
|
);
|
|
6083
6087
|
if (l)
|
|
@@ -6086,9 +6090,9 @@ const pe = class pe {
|
|
|
6086
6090
|
return this.sceneInitialized ? this.accumulateSample(r, e, t) : r.render(e, t);
|
|
6087
6091
|
} catch (i) {
|
|
6088
6092
|
return S.err(
|
|
6089
|
-
new
|
|
6093
|
+
new L(
|
|
6090
6094
|
"Failed to render with path tracing",
|
|
6091
|
-
|
|
6095
|
+
U.RENDER_FAILED,
|
|
6092
6096
|
{ originalError: i }
|
|
6093
6097
|
)
|
|
6094
6098
|
);
|
|
@@ -6102,10 +6106,10 @@ const pe = class pe {
|
|
|
6102
6106
|
* while still waiting for the renderer, or after giving up and disabling.
|
|
6103
6107
|
*/
|
|
6104
6108
|
ensurePathTracerCreated(e, t, r) {
|
|
6105
|
-
var
|
|
6109
|
+
var s;
|
|
6106
6110
|
this.createAttempts++;
|
|
6107
6111
|
const i = this.createPathTracer();
|
|
6108
|
-
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));
|
|
6109
6113
|
}
|
|
6110
6114
|
/** Unwraps the Three.js scene/camera from their adapters, or null if either fails. */
|
|
6111
6115
|
extractThreeObjects(e, t) {
|
|
@@ -6120,47 +6124,47 @@ const pe = class pe {
|
|
|
6120
6124
|
* Result when render() should return it immediately instead — still
|
|
6121
6125
|
* waiting, or the environment shape isn't one the tracer can use.
|
|
6122
6126
|
*/
|
|
6123
|
-
async initializeSceneForPathTracing(e, t, r, i,
|
|
6127
|
+
async initializeSceneForPathTracing(e, t, r, i, s) {
|
|
6124
6128
|
var a;
|
|
6125
6129
|
try {
|
|
6126
6130
|
const l = i.__originalEnvironmentTexture;
|
|
6127
6131
|
if (!i.environment && !l)
|
|
6128
6132
|
return this.environmentWaitFrames++, this.environmentWaitFrames >= this.maxEnvironmentWaitFrames && (this.disableAfterSelfPause("gave-up"), this.environmentWaitFrames = 0), e.render(t, r);
|
|
6129
6133
|
if (this.environmentWaitFrames = 0, l && l.isCubeTexture) {
|
|
6130
|
-
const
|
|
6134
|
+
const u = i.environment;
|
|
6131
6135
|
i.environment = l;
|
|
6132
6136
|
try {
|
|
6133
|
-
this.ingestSceneWithoutShadowHelpers(i,
|
|
6137
|
+
this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0;
|
|
6134
6138
|
} finally {
|
|
6135
|
-
i.environment =
|
|
6139
|
+
i.environment = u;
|
|
6136
6140
|
}
|
|
6137
|
-
} else if (l && l.mapping ===
|
|
6138
|
-
let
|
|
6141
|
+
} else if (l && l.mapping === _.EquirectangularReflectionMapping) {
|
|
6142
|
+
let u = l;
|
|
6139
6143
|
if (l.image instanceof HTMLImageElement)
|
|
6140
6144
|
if (this.convertedEnvTexture)
|
|
6141
|
-
|
|
6145
|
+
u = this.convertedEnvTexture;
|
|
6142
6146
|
else {
|
|
6143
6147
|
const h = this.convertToDataTexture(l);
|
|
6144
6148
|
if (!h)
|
|
6145
6149
|
throw new Error("Failed to convert environment texture to DataTexture");
|
|
6146
|
-
this.convertedEnvTexture = h,
|
|
6150
|
+
this.convertedEnvTexture = h, u = h;
|
|
6147
6151
|
}
|
|
6148
6152
|
const d = i.environment;
|
|
6149
|
-
i.environment =
|
|
6153
|
+
i.environment = u;
|
|
6150
6154
|
try {
|
|
6151
6155
|
const h = l.image;
|
|
6152
|
-
h && !("data" in h && h.data) && h instanceof HTMLImageElement && !h.complete && await new Promise((
|
|
6156
|
+
h && !("data" in h && h.data) && h instanceof HTMLImageElement && !h.complete && await new Promise((f) => {
|
|
6153
6157
|
h.onload = () => {
|
|
6154
|
-
l.needsUpdate = !0,
|
|
6158
|
+
l.needsUpdate = !0, f();
|
|
6155
6159
|
}, h.onerror = () => {
|
|
6156
|
-
|
|
6157
|
-
}, h.complete &&
|
|
6158
|
-
}), this.ingestSceneWithoutShadowHelpers(i,
|
|
6160
|
+
f();
|
|
6161
|
+
}, h.complete && f();
|
|
6162
|
+
}), this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0, i.environment = d;
|
|
6159
6163
|
} catch (h) {
|
|
6160
6164
|
throw i.environment = d, h;
|
|
6161
6165
|
}
|
|
6162
|
-
} else if (((a = i.environment) == null ? void 0 : a.mapping) ===
|
|
6163
|
-
this.ingestSceneWithoutShadowHelpers(i,
|
|
6166
|
+
} else if (((a = i.environment) == null ? void 0 : a.mapping) === _.EquirectangularReflectionMapping)
|
|
6167
|
+
this.ingestSceneWithoutShadowHelpers(i, s), this.sceneInitialized = !0;
|
|
6164
6168
|
else
|
|
6165
6169
|
return this.disableAfterSelfPause("gave-up"), e.render(t, r);
|
|
6166
6170
|
} catch (l) {
|
|
@@ -6174,29 +6178,140 @@ const pe = class pe {
|
|
|
6174
6178
|
* feedback, accumulates a tracer sample, and detects completion.
|
|
6175
6179
|
*/
|
|
6176
6180
|
accumulateSample(e, t, r) {
|
|
6177
|
-
var
|
|
6181
|
+
var s, a;
|
|
6178
6182
|
if (this.sampleCount === 0)
|
|
6179
6183
|
try {
|
|
6180
|
-
(
|
|
6184
|
+
(s = this.pathTracer) == null || s.updateLights();
|
|
6181
6185
|
} catch (l) {
|
|
6182
6186
|
console.warn("Failed to update lights for path tracing:", l);
|
|
6183
6187
|
}
|
|
6184
6188
|
const i = e.render(t, r);
|
|
6185
|
-
|
|
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
|
+
});
|
|
6186
6301
|
}
|
|
6187
6302
|
/**
|
|
6188
6303
|
* Render while path tracing is disabled: keep the final accumulated image on
|
|
6189
6304
|
* screen if we just completed, otherwise delegate to the standard renderer.
|
|
6190
6305
|
*/
|
|
6191
6306
|
renderWhileDisabled(e, t) {
|
|
6192
|
-
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);
|
|
6193
6308
|
}
|
|
6194
6309
|
/**
|
|
6195
6310
|
* Render a single path-tracing sample into the internal buffer, preserving the
|
|
6196
6311
|
* renderer's autoClear/render-target state so the standard view stays visible.
|
|
6197
6312
|
*/
|
|
6198
6313
|
accumulateOneSample() {
|
|
6199
|
-
const e =
|
|
6314
|
+
const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
|
|
6200
6315
|
if (!e)
|
|
6201
6316
|
throw new Error("Three.js renderer not available");
|
|
6202
6317
|
const t = e.autoClear, r = e.getRenderTarget();
|
|
@@ -6210,7 +6325,7 @@ const pe = class pe {
|
|
|
6210
6325
|
* stale frame frozen on screen.
|
|
6211
6326
|
*/
|
|
6212
6327
|
captureCompletedFrame() {
|
|
6213
|
-
const e =
|
|
6328
|
+
const e = j(this.renderer) ? this.renderer.getInternalRenderer() : null;
|
|
6214
6329
|
if (e && this.pathTracer)
|
|
6215
6330
|
try {
|
|
6216
6331
|
const t = e.autoClear;
|
|
@@ -6255,14 +6370,14 @@ const pe = class pe {
|
|
|
6255
6370
|
}
|
|
6256
6371
|
this.pathTracer = null;
|
|
6257
6372
|
}
|
|
6258
|
-
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;
|
|
6259
6374
|
}
|
|
6260
6375
|
isSupported() {
|
|
6261
6376
|
return document.createElement("canvas").getContext("webgl2") !== null;
|
|
6262
6377
|
}
|
|
6263
6378
|
};
|
|
6264
|
-
|
|
6265
|
-
let ut =
|
|
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;
|
|
6266
6381
|
export {
|
|
6267
6382
|
ut as ThreePathTracingService
|
|
6268
6383
|
};
|