u-space 0.0.26 → 0.0.28
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/index.cjs +3 -3
- package/dist/index.js +411 -373
- package/dist/plugins/atmosphere/index.cjs +1 -1
- package/dist/plugins/atmosphere/index.js +3255 -129
- package/dist/plugins/atmosphere/threeR185Compat.d.ts +2 -0
- package/dist/plugins/fire/FireEffect.d.ts +90 -0
- package/dist/plugins/fire/index.cjs +1 -0
- package/dist/plugins/fire/index.d.ts +1 -0
- package/dist/plugins/fire/index.js +433 -0
- package/dist/plugins/u-manager/index.cjs +60 -60
- package/dist/plugins/u-manager/index.d.ts +3 -0
- package/dist/plugins/u-manager/index.js +10070 -9660
- package/dist/plugins/u-manager/instances/SemanticInstanceObject.d.ts +37 -0
- package/dist/plugins/u-manager/instances/SemanticModelInstancedLayer.d.ts +33 -0
- package/dist/plugins/u-manager/instances/index.d.ts +2 -0
- package/dist/plugins/u-manager/loaders/SceneInstancedLayer.d.ts +13 -0
- package/dist/plugins/u-manager/loaders/SceneLoader.d.ts +5 -5
- package/dist/plugins/u-manager/loaders/UManagerLoader.d.ts +24 -0
- package/dist/plugins/u-manager/semantics/SemanticLoader.d.ts +2 -2
- package/dist/plugins/u-manager/semantics/SemanticParser.d.ts +3 -3
- package/dist/plugins/u-manager/semantics/index.d.ts +1 -1
- package/dist/plugins/u-manager/semantics/objects/BuildingGroup.d.ts +4 -10
- package/dist/plugins/u-manager/semantics/objects/FacilityInstancedLayer.d.ts +5 -24
- package/dist/plugins/u-manager/semantics/objects/FloorMesh.d.ts +30 -15
- package/dist/plugins/u-manager/semantics/objects/SemanticGroup.d.ts +26 -0
- package/dist/plugins/u-manager/semantics/types.d.ts +1 -0
- package/dist/src/effects/MaterialEffects.d.ts +1 -0
- package/dist/src/tools/AnnotationManager.d.ts +4 -1
- package/dist/src/viewers/RenderPipeline.d.ts +6 -5
- package/docs/api-effects.md +3 -0
- package/docs/api-interactions.md +1 -0
- package/docs/api-managers.md +1 -1
- package/docs/api-plugin-fire.md +174 -0
- package/docs/api-plugin-u-manager.md +249 -57
- package/docs/api-tools.md +1 -1
- package/docs/changelog.md +41 -8
- package/docs/examples-guide.md +39 -13
- package/docs/getting-started.md +1 -1
- package/docs/index.md +1 -0
- package/docs/mcp.md +34 -1
- package/package.json +4 -4
- package/dist/plugins/u-manager/semantics/objects/SemanticSceneGroup.d.ts +0 -31
|
@@ -1,20 +1,3146 @@
|
|
|
1
|
-
import { Matrix4 as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { RendererUtils as K, StructTypeNode as ui, NodeBuilder as li, TextureNode as ci, Texture3DNode as di, TempNode as se, NodeUpdateType as ee, NodeMaterial as Ce, QuadMesh as We, IndirectStorageBufferAttribute as hi, MeshBasicNodeMaterial as mi, Node as pi, StorageTexture as gi, Storage3DTexture as xi, AnalyticLightNode as yi, PointsNodeMaterial as Ti, RenderTarget as wi, Matrix4 as fi, Vector3 as Xt, NoToneMapping as Yt } from "three/webgpu";
|
|
2
|
+
import { Fn as O, positionView as Cs, nodeImmutable as Si, convertToTexture as Lt, vec2 as b, screenCoordinate as Ae, time as vi, vec3 as g, uniform as w, positionLocal as Ci, positionPrevious as Ni, sub as $e, rtt as Mi, add as k, texture as X, ivec2 as Ne, screenUV as Ns, step as Ri, and as bi, If as I, mix as he, textureSize as zi, PI2 as Ei, PI as qe, cos as ne, sin as ie, OnBeforeObjectUpdate as Ai, luminance as Fi, smoothstep as ut, vec4 as v, uv as Me, min as Ms, abs as Vi, mul as te, fract as Li, distance as Di, instancedArray as es, storage as Pi, uvec2 as st, globalId as G, Return as Oe, atomicAdd as Bi, instanceIndex as Ui, mat3 as He, positionGeometry as It, float as A, logarithmicDepthToViewZ as Rs, viewZToPerspectiveDepth as Ii, cameraFar as bs, cameraNear as zs, sqrt as $, max as Re, cameraProjectionMatrix as Oi, cameraProjectionMatrixInverse as ki, cameraWorldMatrix as $i, struct as Y, reference as _e, viewZToLogarithmicDepth as ji, perspectiveDepthToViewZ as Gi, orthographicDepthToViewZ as Wi, log as qi, uint as fe, textureStore as we, acos as Es, workgroupArray as ts, workgroupBarrier as ss, uvec3 as Hi, texture3D as it, mrt as Xe, Loop as Pe, exp as lt, bool as Ve, clamp as Ot, floor as kt, div as $t, normalWorld as _i, positionWorld as Zi, cameraViewMatrix as Ki, nodeProxy as As, pmremTexture as Qi, fwidth as Fs, equirectUV as Ji, dFdx as is, dFdy as rs, instancedBufferAttribute as mt, screenSize as Xi, pow as Vs, log2 as Yi, cdl as er, context as tr, toneMapping as sr, renderOutput as ir } from "three/tsl";
|
|
3
|
+
import { Matrix4 as Dt, DepthTexture as rr, RenderTarget as jt, RGBAFormat as be, HalfFloatType as Ze, LinearFilter as Z, Vector2 as re, AdditiveBlending as Ls, Mesh as Ds, PlaneGeometry as nr, PerspectiveCamera as ar, SRGBColorSpace as or, CanvasTexture as ur, Vector3 as H, FloatType as lr, NoColorSpace as ct, RenderTarget3D as cr, Matrix3 as dr, DirectionalLight as hr, WebGLCubeRenderTarget as mr, CubeCamera as pr, Sprite as gr, InstancedBufferAttribute as pt, Texture as xr, Data3DTexture as yr } from "three";
|
|
4
|
+
import "three/examples/jsm/csm/CSMShadowNode.js";
|
|
5
|
+
import { hash as Gt } from "three/src/nodes/core/NodeUtils.js";
|
|
6
|
+
import { getECIToECEFRotationMatrix as Tr, getSunDirectionECI as wr, getMoonDirectionECI as fr } from "@takram/three-atmosphere";
|
|
7
|
+
import { Geodetic as Ps, Ellipsoid as Bs, radians as rt, isFloatLinearSupported as Sr, reinterpretType as Wt, QuadGeometry as vr, ArrayBufferLoader as Cr } from "@takram/three-geospatial";
|
|
8
|
+
var Nr = "Invariant failed";
|
|
9
|
+
function D(s, e) {
|
|
10
|
+
if (!s)
|
|
11
|
+
throw new Error(Nr);
|
|
12
|
+
}
|
|
13
|
+
let gt;
|
|
14
|
+
function Ke(s, e, t) {
|
|
15
|
+
gt ??= /* @__PURE__ */ new WeakMap();
|
|
16
|
+
let i = gt.get(s);
|
|
17
|
+
return i == null && (i = {}, gt.set(s, i)), i[e] ??= t();
|
|
18
|
+
}
|
|
19
|
+
const Mr = (s) => s != null ? Ke(
|
|
20
|
+
s,
|
|
21
|
+
"projectionMatrix",
|
|
22
|
+
() => _e("projectionMatrix", "mat4", s).setName(
|
|
23
|
+
"projectionMatrix"
|
|
24
|
+
)
|
|
25
|
+
) : Oi, Rr = (s) => s != null ? Ke(
|
|
26
|
+
s,
|
|
27
|
+
"inverseProjectionMatrix",
|
|
28
|
+
() => _e("projectionMatrixInverse", "mat4", s).setName(
|
|
29
|
+
"inverseProjectionMatrix"
|
|
30
|
+
)
|
|
31
|
+
) : ki, br = (s) => s != null ? Ke(
|
|
32
|
+
s,
|
|
33
|
+
"inverseViewMatrix",
|
|
34
|
+
() => _e("matrixWorld", "mat4", s).setName("inverseViewMatrix")
|
|
35
|
+
) : $i, je = (s) => s != null ? Ke(
|
|
36
|
+
s,
|
|
37
|
+
"cameraNear",
|
|
38
|
+
() => _e("near", "float", s).setName("cameraNear")
|
|
39
|
+
) : zs, Ge = (s) => s != null ? Ke(
|
|
40
|
+
s,
|
|
41
|
+
"cameraFar",
|
|
42
|
+
() => _e("far", "float", s).setName("cameraFar")
|
|
43
|
+
) : bs;
|
|
44
|
+
O(() => Cs.z).once()().toVar("viewZ");
|
|
45
|
+
class zr extends ci {
|
|
46
|
+
static get type() {
|
|
47
|
+
return "OutputTextureNode";
|
|
48
|
+
}
|
|
49
|
+
constructor(e, t) {
|
|
50
|
+
super(t), this.owner = e, this.setUpdateMatrix(!1);
|
|
51
|
+
}
|
|
52
|
+
setup(e) {
|
|
53
|
+
return this.owner.build(e), super.setup(e);
|
|
54
|
+
}
|
|
55
|
+
clone() {
|
|
56
|
+
const e = new this.constructor(this.owner, this.value);
|
|
57
|
+
return e.uvNode = this.uvNode, e.levelNode = this.levelNode, e.biasNode = this.biasNode, e.sampler = this.sampler, e.depthNode = this.depthNode, e.compareNode = this.compareNode, e.gradNode = this.gradNode, e.offsetNode = this.offsetNode, e;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const Le = (...s) => new zr(...s);
|
|
61
|
+
let dt = class extends se {
|
|
62
|
+
constructor(e) {
|
|
63
|
+
super("vec4"), this.resolutionScale = 1, this.renderTargets = [], this.updateBeforeType = ee.FRAME, this.inputNode = e;
|
|
64
|
+
}
|
|
65
|
+
static get type() {
|
|
66
|
+
return "FilterNode";
|
|
67
|
+
}
|
|
68
|
+
createRenderTarget(e) {
|
|
69
|
+
const t = new jt(1, 1, {
|
|
70
|
+
depthBuffer: !1,
|
|
71
|
+
type: Ze,
|
|
72
|
+
format: be
|
|
73
|
+
}), i = t.texture;
|
|
74
|
+
i.minFilter = Z, i.magFilter = Z, i.generateMipmaps = !1;
|
|
75
|
+
const r = this.constructor.type;
|
|
76
|
+
return i.name = e != null ? `${r}_${e}` : r, this.renderTargets.push(t), t;
|
|
77
|
+
}
|
|
78
|
+
getTextureNode() {
|
|
79
|
+
return D(
|
|
80
|
+
this.textureNode != null
|
|
81
|
+
), this.textureNode;
|
|
82
|
+
}
|
|
83
|
+
get outputTexture() {
|
|
84
|
+
return this.textureNode?.value ?? null;
|
|
85
|
+
}
|
|
86
|
+
set outputTexture(e) {
|
|
87
|
+
this.textureNode = e != null ? Le(this, e) : void 0;
|
|
88
|
+
}
|
|
89
|
+
setup(e) {
|
|
90
|
+
const { inputNode: t, textureNode: i } = this;
|
|
91
|
+
return D(
|
|
92
|
+
t != null
|
|
93
|
+
), D(
|
|
94
|
+
i != null
|
|
95
|
+
), i.uvNode = t.uvNode, i;
|
|
96
|
+
}
|
|
97
|
+
dispose() {
|
|
98
|
+
for (const e of this.renderTargets)
|
|
99
|
+
e.dispose();
|
|
100
|
+
super.dispose();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const { resetRendererState: Er, restoreRendererState: Ar } = K;
|
|
104
|
+
let Fr = class extends dt {
|
|
105
|
+
constructor(e, t) {
|
|
106
|
+
super(e), this.downsampleRTs = [], this.upsampleRTs = [], this.downsampleMaterial = new Ce(), this.upsampleMaterial = new Ce(), this.mesh = new We(), this.inputTexelSize = w("vec2"), this.downsampleNode = X();
|
|
107
|
+
const i = this.constructor.type.replace(/Node$/, "");
|
|
108
|
+
this.downsampleMaterial.name = `${i}_downsample`, this.upsampleMaterial.name = `${i}_upsample`, this.mesh.name = i;
|
|
109
|
+
for (let r = 0; r < t; ++r)
|
|
110
|
+
this.downsampleRTs[r] = this.createRenderTarget(`downsample${r}`), r < t - 1 && (this.upsampleRTs[r] = this.createRenderTarget(`upsample${r}`));
|
|
111
|
+
this.outputTexture = this.upsampleRTs[0].texture;
|
|
112
|
+
}
|
|
113
|
+
setSize(e, t) {
|
|
114
|
+
const { resolutionScale: i } = this;
|
|
115
|
+
let r = Math.max(Math.round(e * i), 1), n = Math.max(Math.round(t * i), 1);
|
|
116
|
+
const { downsampleRTs: a, upsampleRTs: o } = this;
|
|
117
|
+
for (let u = 0; u < a.length; ++u)
|
|
118
|
+
r = Math.max(Math.round(r / 2), 1), n = Math.max(Math.round(n / 2), 1), a[u].setSize(r, n), u < o.length && o[u].setSize(r, n);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
updateBefore({ renderer: e }) {
|
|
122
|
+
if (e == null)
|
|
123
|
+
return;
|
|
124
|
+
const {
|
|
125
|
+
downsampleRTs: t,
|
|
126
|
+
upsampleRTs: i,
|
|
127
|
+
mesh: r,
|
|
128
|
+
inputNode: n,
|
|
129
|
+
inputTexelSize: a,
|
|
130
|
+
downsampleNode: o
|
|
131
|
+
} = this;
|
|
132
|
+
D(n != null);
|
|
133
|
+
const { width: u, height: l } = n.value;
|
|
134
|
+
this.setSize(u, l);
|
|
135
|
+
const c = n.value;
|
|
136
|
+
this.rendererState = Er(e, this.rendererState), r.material = this.downsampleMaterial;
|
|
137
|
+
for (const d of t) {
|
|
138
|
+
const { width: h, height: m } = n.value;
|
|
139
|
+
a.value.set(1 / h, 1 / m), e.setRenderTarget(d), r.render(e), n.value = d.texture;
|
|
140
|
+
}
|
|
141
|
+
r.material = this.upsampleMaterial;
|
|
142
|
+
for (let d = i.length - 1; d >= 0; --d) {
|
|
143
|
+
const h = i[d], { width: m, height: p } = n.value;
|
|
144
|
+
a.value.set(1 / m, 1 / p), o.value = t[d].texture, e.setRenderTarget(h), r.render(e), n.value = h.texture;
|
|
145
|
+
}
|
|
146
|
+
Ar(e, this.rendererState), n.value = c;
|
|
147
|
+
}
|
|
148
|
+
setup(e) {
|
|
149
|
+
const { inputNode: t } = this;
|
|
150
|
+
D(t != null);
|
|
151
|
+
const { downsampleMaterial: i, upsampleMaterial: r } = this;
|
|
152
|
+
return i.fragmentNode = this.setupDownsampleNode(e), r.fragmentNode = this.setupUpsampleNode(e), i.needsUpdate = !0, r.needsUpdate = !0, super.setup(e);
|
|
153
|
+
}
|
|
154
|
+
dispose() {
|
|
155
|
+
for (const e of this.downsampleRTs)
|
|
156
|
+
e.dispose();
|
|
157
|
+
for (const e of this.upsampleRTs)
|
|
158
|
+
e.dispose();
|
|
159
|
+
this.downsampleMaterial.dispose(), this.upsampleMaterial.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const Vr = (s, e) => {
|
|
163
|
+
const t = Me(), i = v(1, 1, -1, -1).mul(e.xyxy).add(t.xyxy).toVertexStage(), r = v(2, 2, -2, -2).mul(e.xyxy).add(t.xyxy).toVertexStage(), n = i.zy, a = i.xy, o = i.zw, u = i.xw, l = b(t.x, r.y), c = b(r.z, t.y), d = b(r.x, t.y), h = b(t.x, r.w), m = r.zy, p = r.xy, x = r.zw, y = r.xw;
|
|
164
|
+
return k(
|
|
165
|
+
k(
|
|
166
|
+
s.sample(t),
|
|
167
|
+
s.sample(n),
|
|
168
|
+
s.sample(a),
|
|
169
|
+
s.sample(o),
|
|
170
|
+
s.sample(u)
|
|
171
|
+
).mul(1 / 8),
|
|
172
|
+
k(
|
|
173
|
+
s.sample(l),
|
|
174
|
+
s.sample(c),
|
|
175
|
+
s.sample(d),
|
|
176
|
+
s.sample(h)
|
|
177
|
+
).mul(1 / 16),
|
|
178
|
+
k(
|
|
179
|
+
s.sample(m),
|
|
180
|
+
s.sample(p),
|
|
181
|
+
s.sample(x),
|
|
182
|
+
s.sample(y)
|
|
183
|
+
).mul(1 / 32)
|
|
184
|
+
);
|
|
185
|
+
}, { resetRendererState: Lr, restoreRendererState: Dr } = K;
|
|
186
|
+
class Pr extends dt {
|
|
187
|
+
constructor(e) {
|
|
188
|
+
super(e), this.material = new Ce(), this.mesh = new We(this.material), this.inputTexelSize = w("vec2");
|
|
189
|
+
const t = this.constructor.type.replace(/Node$/, "");
|
|
190
|
+
this.material.name = t, this.mesh.name = t, this.renderTarget = this.createRenderTarget(), this.outputTexture = this.renderTarget.texture;
|
|
191
|
+
}
|
|
192
|
+
setSize(e, t) {
|
|
193
|
+
const { resolutionScale: i } = this, r = Math.max(Math.round(e * i), 1), n = Math.max(Math.round(t * i), 1);
|
|
194
|
+
return this.renderTarget.setSize(r, n), this;
|
|
195
|
+
}
|
|
196
|
+
updateBefore({ renderer: e }) {
|
|
197
|
+
if (e == null)
|
|
198
|
+
return;
|
|
199
|
+
const { inputNode: t } = this;
|
|
200
|
+
D(t != null);
|
|
201
|
+
const { width: i, height: r } = t.value;
|
|
202
|
+
this.setSize(i, r), this.inputTexelSize.value.set(1 / i, 1 / r), this.rendererState = Lr(e, this.rendererState), e.setRenderTarget(this.renderTarget), this.mesh.render(e), Dr(e, this.rendererState);
|
|
203
|
+
}
|
|
204
|
+
setup(e) {
|
|
205
|
+
const { inputNode: t } = this;
|
|
206
|
+
D(t != null);
|
|
207
|
+
const { material: i } = this;
|
|
208
|
+
return i.fragmentNode = this.setupOutputNode(e), i.needsUpdate = !0, super.setup(e);
|
|
209
|
+
}
|
|
210
|
+
dispose() {
|
|
211
|
+
this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
let Br = class extends Pr {
|
|
215
|
+
constructor(e) {
|
|
216
|
+
super(e), this.thresholdLevel = w(5), this.thresholdRange = w(1), this.resolutionScale = 0.5;
|
|
217
|
+
}
|
|
218
|
+
static get type() {
|
|
219
|
+
return "DownsampleThresholdNode";
|
|
220
|
+
}
|
|
221
|
+
setupOutputNode() {
|
|
222
|
+
const { inputNode: e, thresholdLevel: t, thresholdRange: i, inputTexelSize: r } = this;
|
|
223
|
+
D(e != null);
|
|
224
|
+
const n = Vr(e, r), a = Fi(n.rgb), o = ut(
|
|
225
|
+
t,
|
|
226
|
+
t.add(i),
|
|
227
|
+
a
|
|
228
|
+
);
|
|
229
|
+
return v(n.rgb, a).mul(o);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const xt = (s) => {
|
|
233
|
+
const e = Ai(s);
|
|
234
|
+
return e.updateBeforeType = ee.FRAME, e;
|
|
235
|
+
};
|
|
236
|
+
function ns(s) {
|
|
237
|
+
if (typeof s == "string")
|
|
238
|
+
return s;
|
|
239
|
+
if (typeof s == "function" && typeof s.name == "string" && s.name.length > 0)
|
|
240
|
+
return s.name;
|
|
241
|
+
if ("layout" in s && s.layout instanceof ui) {
|
|
242
|
+
if (s.layout.name == null)
|
|
243
|
+
throw new Error("Struct name is required.");
|
|
244
|
+
return s.layout.name;
|
|
245
|
+
}
|
|
246
|
+
throw new Error(`Unsupported layout type: ${s}`);
|
|
247
|
+
}
|
|
248
|
+
function R({
|
|
249
|
+
typeOnly: s = !1,
|
|
250
|
+
...e
|
|
251
|
+
}) {
|
|
252
|
+
return s ? (t) => O(t) : (t) => O(t).setLayout({
|
|
253
|
+
...e,
|
|
254
|
+
type: ns(e.type),
|
|
255
|
+
inputs: e.inputs?.map((i) => ({
|
|
256
|
+
...i,
|
|
257
|
+
type: ns(i.type)
|
|
258
|
+
})) ?? []
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function L(s) {
|
|
262
|
+
return O((e, t) => {
|
|
263
|
+
const i = s(...e);
|
|
264
|
+
return typeof i == "function" ? i(t) : i;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
const { resetRendererState: Ur, restoreRendererState: Ir } = K;
|
|
268
|
+
class Or extends dt {
|
|
269
|
+
constructor(e) {
|
|
270
|
+
super(e), this.iterations = 1, this.material = new Ce(), this.mesh = new We(this.material), this.inputTexelSize = w("vec2"), this.direction = w("vec2");
|
|
271
|
+
const t = this.constructor.type.replace(/Node$/, "");
|
|
272
|
+
this.material.name = t, this.mesh.name = t, this.horizontalRT = this.createRenderTarget("horizontal"), this.verticalRT = this.createRenderTarget("vertical"), this.outputTexture = this.verticalRT.texture;
|
|
273
|
+
}
|
|
274
|
+
setSize(e, t) {
|
|
275
|
+
const { resolutionScale: i } = this, r = Math.max(Math.round(e * i), 1), n = Math.max(Math.round(t * i), 1);
|
|
276
|
+
return this.horizontalRT.setSize(r, n), this.verticalRT.setSize(r, n), this;
|
|
277
|
+
}
|
|
278
|
+
updateBefore({ renderer: e }) {
|
|
279
|
+
if (e == null)
|
|
280
|
+
return;
|
|
281
|
+
const { horizontalRT: t, verticalRT: i, mesh: r, inputNode: n, direction: a } = this;
|
|
282
|
+
D(n != null);
|
|
283
|
+
const { width: o, height: u } = n.value;
|
|
284
|
+
this.setSize(o, u), this.inputTexelSize.value.set(1 / o, 1 / u);
|
|
285
|
+
const l = n.value;
|
|
286
|
+
this.rendererState = Ur(e, this.rendererState);
|
|
287
|
+
for (let c = 0; c < this.iterations; ++c)
|
|
288
|
+
a.value.set(1, 0), e.setRenderTarget(t), r.render(e), n.value = t.texture, a.value.set(0, 1), e.setRenderTarget(i), r.render(e), n.value = i.texture;
|
|
289
|
+
Ir(e, this.rendererState), n.value = l;
|
|
290
|
+
}
|
|
291
|
+
setup(e) {
|
|
292
|
+
const { inputNode: t } = this;
|
|
293
|
+
D(t != null);
|
|
294
|
+
const { material: i } = this;
|
|
295
|
+
return i.fragmentNode = this.setupOutputNode(e), i.needsUpdate = !0, super.setup(e);
|
|
296
|
+
}
|
|
297
|
+
dispose() {
|
|
298
|
+
this.horizontalRT.dispose(), this.verticalRT.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function as(s) {
|
|
302
|
+
if (D(s >= 0), s === 0)
|
|
303
|
+
return new Float64Array(0);
|
|
304
|
+
if (s === 1)
|
|
305
|
+
return new Float64Array([1]);
|
|
306
|
+
let e = new Float64Array(s), t = new Float64Array(s), i = t;
|
|
307
|
+
for (let r = 1; r <= s; ++r) {
|
|
308
|
+
for (let n = 0; n < r; ++n)
|
|
309
|
+
t[n] = n === 0 || n === r - 1 ? 1 : e[n - 1] + e[n];
|
|
310
|
+
i = t, t = e, e = i;
|
|
311
|
+
}
|
|
312
|
+
return i;
|
|
313
|
+
}
|
|
314
|
+
function kr(s, e = 2) {
|
|
315
|
+
D(s >= 3);
|
|
316
|
+
const t = s + e * 2, i = e > 0 ? as(t).slice(e, -e) : as(t), r = Math.floor((i.length - 1) / 2), n = i.reduce((d, h) => d + h, 0), a = i.slice(r), o = [...Array(r + 1).keys()], u = new Float64Array(Math.floor(o.length / 2)), l = new Float64Array(u.length);
|
|
317
|
+
u[0] = a[0] / n;
|
|
318
|
+
for (let d = 1, h = 1; d < o.length - 1; d += 2, ++h) {
|
|
319
|
+
const m = o[d], p = o[d + 1], x = a[d], y = a[d + 1], T = x + y, S = (m * x + p * y) / T;
|
|
320
|
+
u[h] = T / n, l[h] = S;
|
|
321
|
+
}
|
|
322
|
+
const c = (u.reduce((d, h) => d + h, 0) - u[0] * 0.5) * 2;
|
|
323
|
+
if (c !== 0) {
|
|
324
|
+
const d = 1 / c;
|
|
325
|
+
for (let h = 0; h < u.length; ++h)
|
|
326
|
+
u[h] *= d;
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
offsets: l,
|
|
330
|
+
weights: u
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
class $r extends Or {
|
|
334
|
+
static get type() {
|
|
335
|
+
return "GaussianBlurNode";
|
|
336
|
+
}
|
|
337
|
+
constructor(e, t = 35) {
|
|
338
|
+
super(e), this.kernelSize = t;
|
|
339
|
+
}
|
|
340
|
+
setupOutputNode(e) {
|
|
341
|
+
const { inputNode: t, inputTexelSize: i, direction: r } = this;
|
|
342
|
+
D(t != null);
|
|
343
|
+
const { offsets: n, weights: a } = kr(this.kernelSize);
|
|
344
|
+
return O(() => {
|
|
345
|
+
const o = Me(), u = r.mul(i).toVertexStage(), l = t.sample(o).mul(a[0]);
|
|
346
|
+
for (let c = 1; c < n.length; ++c) {
|
|
347
|
+
const d = u.mul(n[c]);
|
|
348
|
+
l.addAssign(
|
|
349
|
+
k(
|
|
350
|
+
t.sample(o.add(d)),
|
|
351
|
+
t.sample(o.sub(d))
|
|
352
|
+
).mul(a[c])
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
return l;
|
|
356
|
+
})();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
const jr = (s) => s.dot(b(0.06711056, 583715e-8)).fract().mul(52.9829189).fract(), Gr = /* @__PURE__ */ O(() => {
|
|
360
|
+
const s = b(Ae.xy).add(vi.fract().mul(1337)), e = jr(s);
|
|
361
|
+
return g(e, e.oneMinus(), e).sub(0.5).div(255);
|
|
362
|
+
}).once()();
|
|
363
|
+
class Wr extends se {
|
|
364
|
+
constructor() {
|
|
365
|
+
super("vec3"), this.currentProjectionMatrix = w("mat4"), this.previousProjectionMatrix = w("mat4"), this.currentModelViewMatrix = w("mat4"), this.previousModelViewMatrix = w("mat4"), this.objectModelViewMatrices = /* @__PURE__ */ new WeakMap(), this.updateType = ee.FRAME, this.updateBeforeType = ee.OBJECT, this.updateAfterType = ee.OBJECT;
|
|
366
|
+
}
|
|
367
|
+
static get type() {
|
|
368
|
+
return "HighpVelocityNode";
|
|
369
|
+
}
|
|
370
|
+
setProjectionMatrix(e) {
|
|
371
|
+
return this.projectionMatrix = e, this;
|
|
372
|
+
}
|
|
373
|
+
// Executed once per frame:
|
|
374
|
+
update({ camera: e }) {
|
|
375
|
+
if (e == null)
|
|
376
|
+
return;
|
|
377
|
+
const {
|
|
378
|
+
currentProjectionMatrix: t,
|
|
379
|
+
previousProjectionMatrix: i
|
|
380
|
+
} = this, r = this.projectionMatrix ?? e.projectionMatrix;
|
|
381
|
+
i.value == null ? i.value = new Dt().copy(r) : i.value.copy(t.value), t.value.copy(r);
|
|
382
|
+
}
|
|
383
|
+
// Executed once per object before rendering:
|
|
384
|
+
updateBefore({ object: e, camera: t }) {
|
|
385
|
+
if (e == null || t == null)
|
|
386
|
+
return;
|
|
387
|
+
const {
|
|
388
|
+
currentModelViewMatrix: i,
|
|
389
|
+
previousModelViewMatrix: r,
|
|
390
|
+
objectModelViewMatrices: n
|
|
391
|
+
} = this;
|
|
392
|
+
i.value.multiplyMatrices(
|
|
393
|
+
t.matrixWorldInverse,
|
|
394
|
+
e.matrixWorld
|
|
395
|
+
), r.value = n.get(e) ?? i.value;
|
|
396
|
+
}
|
|
397
|
+
// Executed once per object after rendering:
|
|
398
|
+
updateAfter({ object: e }) {
|
|
399
|
+
if (e == null)
|
|
400
|
+
return;
|
|
401
|
+
const {
|
|
402
|
+
currentModelViewMatrix: t,
|
|
403
|
+
objectModelViewMatrices: i
|
|
404
|
+
} = this;
|
|
405
|
+
let r = i.get(e);
|
|
406
|
+
r == null && (r = new Dt(), i.set(e, r)), r.copy(t.value);
|
|
407
|
+
}
|
|
408
|
+
setup(e) {
|
|
409
|
+
const t = this.currentProjectionMatrix.mul(this.currentModelViewMatrix).mul(Ci).toVertexStage(), i = this.previousProjectionMatrix.mul(this.previousModelViewMatrix).mul(Ni).toVertexStage(), r = t.xyz.div(t.w), n = i.xyz.div(i.w);
|
|
410
|
+
return $e(r, n);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const Pt = /* @__PURE__ */ Si(Wr);
|
|
414
|
+
class qr extends se {
|
|
415
|
+
constructor(e) {
|
|
416
|
+
super("vec3"), this.intensity = w(1e-5), this.inputNode = e;
|
|
417
|
+
}
|
|
418
|
+
static get type() {
|
|
419
|
+
return "LensGhostNode";
|
|
420
|
+
}
|
|
421
|
+
setup(e) {
|
|
422
|
+
const { inputNode: t, intensity: i } = this;
|
|
423
|
+
D(t != null);
|
|
424
|
+
const r = R({
|
|
425
|
+
name: "sampleGhost",
|
|
426
|
+
type: "vec3",
|
|
427
|
+
inputs: [
|
|
428
|
+
{ name: "uv", type: "vec2" },
|
|
429
|
+
{ name: "direction", type: "vec2" },
|
|
430
|
+
{ name: "color", type: "vec3" },
|
|
431
|
+
{ name: "offset", type: "float" }
|
|
432
|
+
]
|
|
433
|
+
})(([o, u, l, c]) => {
|
|
434
|
+
const d = u.mul(c).add(o.oneMinus()).saturate(), h = t.sample(d).rgb.mul(l), m = $e(0.5, d).length().mul(1 / (Math.SQRT2 / 4)).saturate();
|
|
435
|
+
return h.mulAssign(m.oneMinus().pow(3)), h;
|
|
436
|
+
}), n = Me(), a = n.sub(0.5);
|
|
437
|
+
return k(
|
|
438
|
+
r(n, a, g(0.8, 0.8, 1), -5),
|
|
439
|
+
r(n, a, g(1, 0.8, 0.4), -1.5),
|
|
440
|
+
r(n, a, g(0.9, 1, 0.8), -0.4),
|
|
441
|
+
r(n, a, g(1, 0.8, 0.4), -0.2),
|
|
442
|
+
r(n, a, g(0.9, 0.7, 0.7), -0.1),
|
|
443
|
+
r(n, a, g(0.5, 1, 0.4), 0.7),
|
|
444
|
+
r(n, a, g(0.5, 0.5, 0.5), 1),
|
|
445
|
+
r(n, a, g(1, 1, 0.6), 2.5),
|
|
446
|
+
r(n, a, g(0.5, 0.8, 1), 10)
|
|
447
|
+
).mul(i);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
const { resetRendererState: Hr, restoreRendererState: _r } = K;
|
|
451
|
+
function Zr() {
|
|
452
|
+
const s = document.createElement("canvas");
|
|
453
|
+
s.width = 256, s.height = 32;
|
|
454
|
+
const e = s.getContext("2d");
|
|
455
|
+
D(e != null), e.beginPath(), e.moveTo(0, 32 / 2), e.lineTo(256 / 2, 5), e.lineTo(256, 32 / 2), e.lineTo(256 / 2, 27), e.closePath();
|
|
456
|
+
const t = e.createLinearGradient(0, 0, 256, 0);
|
|
457
|
+
return t.addColorStop(0, "#000000"), t.addColorStop(0.5, "#ffffff"), t.addColorStop(1, "#000000"), e.fillStyle = t, e.fill(), new ur(s);
|
|
458
|
+
}
|
|
459
|
+
const os = /* @__PURE__ */ Y({
|
|
460
|
+
color: "vec3",
|
|
461
|
+
luminance: "float",
|
|
462
|
+
position: "vec2",
|
|
463
|
+
scale: "float",
|
|
464
|
+
sin: "float",
|
|
465
|
+
cos: "float"
|
|
466
|
+
});
|
|
467
|
+
class Kr extends dt {
|
|
468
|
+
constructor(e) {
|
|
469
|
+
super(e), this.spikePairCount = 6, this.wireframe = !1, this.intensity = w(1e-5), this.sizeScale = w(new re(1.5, 0.01)), this.luminanceThreshold = w(100), this.indirectBuffer = new hi(
|
|
470
|
+
new Uint32Array([6, 0, 0, 0, 0]),
|
|
471
|
+
1
|
|
472
|
+
), this.instanceBuffer = es(1, os), this.renderTarget = this.createRenderTarget(), this.material = new mi({
|
|
473
|
+
depthTest: !1,
|
|
474
|
+
depthWrite: !1,
|
|
475
|
+
transparent: !0,
|
|
476
|
+
blending: Ls
|
|
477
|
+
}), this.mesh = new Ds(new nr(1, 1), this.material), this.camera = new ar(), this.inputTexelSize = w("vec2"), this.outputTexelSize = w("vec2"), this.geometryRatio = w("vec2"), this.material.name = "LensGlare", this.inputNode = e, this.resolutionScale = 0.5, this.outputTexture = this.renderTarget.texture, this.mesh.geometry.indirect = this.indirectBuffer;
|
|
478
|
+
}
|
|
479
|
+
customCacheKey() {
|
|
480
|
+
return Gt(this.spikePairCount, +this.wireframe);
|
|
481
|
+
}
|
|
482
|
+
setSize(e, t) {
|
|
483
|
+
const { resolutionScale: i } = this, r = Math.max(Math.round(e * i), 1), n = Math.max(Math.round(t * i), 1);
|
|
484
|
+
this.renderTarget.setSize(r, n);
|
|
485
|
+
const a = Math.floor(r / 2), o = Math.floor(n / 2), u = a * o;
|
|
486
|
+
return this.instanceBuffer.bufferCount < u && (this.instanceBuffer.dispose(), this.instanceBuffer = es(u, os), this.setupCompute(a, o), this.setupMaterial()), this;
|
|
487
|
+
}
|
|
488
|
+
updateBefore({ renderer: e }) {
|
|
489
|
+
if (e == null)
|
|
490
|
+
return;
|
|
491
|
+
const { inputNode: t } = this;
|
|
492
|
+
D(t != null);
|
|
493
|
+
const { width: i, height: r } = t.value;
|
|
494
|
+
this.setSize(i, r);
|
|
495
|
+
const { computeNode: n, indirectBuffer: a, renderTarget: o } = this;
|
|
496
|
+
D(n != null), this.inputTexelSize.value.set(1 / i, 1 / r);
|
|
497
|
+
const u = i / r;
|
|
498
|
+
u > 1 ? this.geometryRatio.value.set(1 / u, 1) : this.geometryRatio.value.set(1, u);
|
|
499
|
+
const { width: l, height: c } = o;
|
|
500
|
+
this.outputTexelSize.value.set(1 / l, 1 / c), a.array[1] = 0, a.needsUpdate = !0, e.compute(n), this.rendererState = Hr(e, this.rendererState), e.setRenderTarget(o), e.render(this.mesh, this.camera), _r(e, this.rendererState);
|
|
501
|
+
}
|
|
502
|
+
setupCompute(e, t) {
|
|
503
|
+
const {
|
|
504
|
+
spikePairCount: i,
|
|
505
|
+
inputNode: r,
|
|
506
|
+
indirectBuffer: n,
|
|
507
|
+
instanceBuffer: a,
|
|
508
|
+
outputTexelSize: o
|
|
509
|
+
} = this;
|
|
510
|
+
D(r != null);
|
|
511
|
+
const u = Pi(
|
|
512
|
+
n,
|
|
513
|
+
"uint",
|
|
514
|
+
n.count
|
|
515
|
+
).toAtomic();
|
|
516
|
+
this.computeNode = O(() => {
|
|
517
|
+
const l = st(e, t);
|
|
518
|
+
I(G.xy.greaterThanEqual(l).any(), () => {
|
|
519
|
+
Oe();
|
|
520
|
+
});
|
|
521
|
+
const c = b(G.xy).mul(o).mul(2), d = r.sample(c), h = d.a;
|
|
522
|
+
I(h.greaterThan(0.1), () => {
|
|
523
|
+
const m = Bi(
|
|
524
|
+
u.element(1),
|
|
525
|
+
i
|
|
526
|
+
);
|
|
527
|
+
for (let p = 0; p < i; ++p) {
|
|
528
|
+
const x = a.element(m.add(p));
|
|
529
|
+
x.get("color").assign(d.rgb), x.get("luminance").assign(h), x.get("position").assign(G.xy), x.get("scale").assign(p % 2 === 0 ? 1 : 0.5);
|
|
530
|
+
const y = Math.PI * (3 - Math.sqrt(5)), T = Math.PI / i * p + y;
|
|
531
|
+
x.get("sin").assign(Math.sin(T)), x.get("cos").assign(Math.cos(T));
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
})().compute(
|
|
535
|
+
// @ts-expect-error "count" can be dimensional
|
|
536
|
+
[Math.ceil(e / 8), Math.ceil(t / 8), 1],
|
|
537
|
+
[8, 8, 1]
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
setupMaterial() {
|
|
541
|
+
const {
|
|
542
|
+
inputNode: e,
|
|
543
|
+
spikeNode: t,
|
|
544
|
+
instanceBuffer: i,
|
|
545
|
+
luminanceThreshold: r,
|
|
546
|
+
intensity: n,
|
|
547
|
+
sizeScale: a,
|
|
548
|
+
outputTexelSize: o,
|
|
549
|
+
geometryRatio: u
|
|
550
|
+
} = this;
|
|
551
|
+
D(e != null), D(t != null);
|
|
552
|
+
const l = i.element(Ui);
|
|
553
|
+
this.material.colorNode = this.wireframe ? v(1) : t.mul(l.get("color").mul(n)), this.material.vertexNode = O(() => {
|
|
554
|
+
const c = l.get("sin"), d = l.get("cos"), h = He(d, c, 0, c.negate(), d, 0, 0, 0, 1), m = l.get("position").mul(o).mul(2), p = m.flipY().mul(2).sub(1), x = l.get("luminance").div(r).saturate(), y = b(x, 1).mul(
|
|
555
|
+
l.get("scale"),
|
|
556
|
+
a,
|
|
557
|
+
// Make the spike to shrink at screen borders:
|
|
558
|
+
m.sub(0.5).length().mul(2).oneMinus().mul(0.5).add(0.5)
|
|
559
|
+
), T = h.mul(It.mul(v(y, 1, 1))).mul(u).add(g(p, 0));
|
|
560
|
+
return v(T, 1);
|
|
561
|
+
})(), this.material.wireframe = this.wireframe, this.material.needsUpdate = !0;
|
|
562
|
+
}
|
|
563
|
+
setup(e) {
|
|
564
|
+
if (this.spikeNode == null) {
|
|
565
|
+
const t = Zr();
|
|
566
|
+
t.colorSpace = or, this.spikeNode = X(t);
|
|
567
|
+
}
|
|
568
|
+
return this.setupMaterial(), super.setup(e);
|
|
569
|
+
}
|
|
570
|
+
dispose() {
|
|
571
|
+
this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
const Qr = /* @__PURE__ */ new re();
|
|
575
|
+
class Jr extends se {
|
|
576
|
+
constructor(e) {
|
|
577
|
+
super("vec3"), this.intensity = w(1e-5), this.chromaticAberration = w(5e-3), this.aspectRatio = w(0), this.updateBeforeType = ee.FRAME, this.inputNode = e;
|
|
578
|
+
}
|
|
579
|
+
static get type() {
|
|
580
|
+
return "LensHaloNode";
|
|
581
|
+
}
|
|
582
|
+
updateBefore({ renderer: e }) {
|
|
583
|
+
if (e == null)
|
|
584
|
+
return;
|
|
585
|
+
const { width: t, height: i } = e.getDrawingBufferSize(Qr);
|
|
586
|
+
this.aspectRatio.value = t / i;
|
|
587
|
+
}
|
|
588
|
+
setup(e) {
|
|
589
|
+
const { inputNode: t, intensity: i, chromaticAberration: r, aspectRatio: n } = this;
|
|
590
|
+
D(t != null);
|
|
591
|
+
const a = R({
|
|
592
|
+
name: "cubicRingMask",
|
|
593
|
+
type: "float",
|
|
594
|
+
inputs: [
|
|
595
|
+
{ name: "x", type: "float" },
|
|
596
|
+
{ name: "radius", type: "float" },
|
|
597
|
+
{ name: "thickness", type: "float" }
|
|
598
|
+
]
|
|
599
|
+
})(([l, c, d]) => {
|
|
600
|
+
const h = Ms(Vi(l.sub(c)).div(d), 1);
|
|
601
|
+
return te(h, h, $e(3, h.mul(2))).oneMinus();
|
|
602
|
+
}), o = R({
|
|
603
|
+
name: "sampleHalo",
|
|
604
|
+
type: "vec3",
|
|
605
|
+
inputs: [
|
|
606
|
+
{ name: "uv", type: "vec2" },
|
|
607
|
+
{ name: "radius", type: "float" }
|
|
608
|
+
]
|
|
609
|
+
})(([l, c]) => {
|
|
610
|
+
const d = b(n, 1), h = l.sub(0.5).mul(d).normalize().div(d), m = g(r).mul(g(-1, 0, 1)), p = Li(h.mul(c).add(l.oneMinus())), x = g(
|
|
611
|
+
t.sample(h.mul(m.r).add(p)).r,
|
|
612
|
+
t.sample(h.mul(m.g).add(p)).g,
|
|
613
|
+
t.sample(h.mul(m.b).add(p)).b
|
|
614
|
+
), y = l.sub(b(0.5, 0)).mul(d).add(b(0.5, 0)), T = Di(y, b(0.5)).saturate();
|
|
615
|
+
return x.mulAssign(a(T, 0.45, 0.25)), x;
|
|
616
|
+
}), u = Me();
|
|
617
|
+
return o(u, 0.3).mul(i);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
const J = (s) => s.greaterThanEqual(0).all().and(s.lessThanEqual(1).all()).toFloat();
|
|
621
|
+
let Xr = class extends Fr {
|
|
622
|
+
constructor(e, t = 4) {
|
|
623
|
+
super(e, t), this.blendAmount = w(0.85), this.resolutionScale = 0.5;
|
|
624
|
+
}
|
|
625
|
+
static get type() {
|
|
626
|
+
return "MipmapSurfaceBlurNode";
|
|
627
|
+
}
|
|
628
|
+
setupDownsampleNode(e) {
|
|
629
|
+
const { inputNode: t, inputTexelSize: i } = this;
|
|
630
|
+
return D(t != null), O(() => {
|
|
631
|
+
const r = Me(), n = v(1, 1, -1, -1).mul(i.xyxy).add(r.xyxy).toVertexStage(), a = v(2, 2, -2, -2).mul(i.xyxy).add(r.xyxy).toVertexStage(), o = n.zy, u = n.xy, l = n.zw, c = n.xw, d = a.zy, h = a.xy, m = a.zw, p = a.xw, x = b(r.x, a.y), y = b(a.z, r.y), T = b(a.x, r.y), S = b(r.x, a.w), M = 1 / 4 / 2, C = 1 / 9 / 2, N = t.sample(r).mul(C);
|
|
632
|
+
let f;
|
|
633
|
+
return f = v(
|
|
634
|
+
J(o),
|
|
635
|
+
J(u),
|
|
636
|
+
J(l),
|
|
637
|
+
J(c)
|
|
638
|
+
).mul(M), N.addAssign(
|
|
639
|
+
t.sample(o).mul(f.x),
|
|
640
|
+
t.sample(u).mul(f.y),
|
|
641
|
+
t.sample(l).mul(f.z),
|
|
642
|
+
t.sample(c).mul(f.w)
|
|
643
|
+
), f = v(
|
|
644
|
+
J(d),
|
|
645
|
+
J(h),
|
|
646
|
+
J(m),
|
|
647
|
+
J(p)
|
|
648
|
+
).mul(C), N.addAssign(
|
|
649
|
+
t.sample(d).mul(f.x),
|
|
650
|
+
t.sample(h).mul(f.y),
|
|
651
|
+
t.sample(m).mul(f.z),
|
|
652
|
+
t.sample(p).mul(f.w)
|
|
653
|
+
), f = v(
|
|
654
|
+
J(x),
|
|
655
|
+
J(y),
|
|
656
|
+
J(T),
|
|
657
|
+
J(S)
|
|
658
|
+
).mul(C), N.addAssign(
|
|
659
|
+
t.sample(x).mul(f.x),
|
|
660
|
+
t.sample(y).mul(f.y),
|
|
661
|
+
t.sample(T).mul(f.z),
|
|
662
|
+
t.sample(S).mul(f.w)
|
|
663
|
+
), N;
|
|
664
|
+
})();
|
|
665
|
+
}
|
|
666
|
+
setupUpsampleNode(e) {
|
|
667
|
+
const { inputNode: t, inputTexelSize: i, downsampleNode: r } = this;
|
|
668
|
+
D(t != null);
|
|
669
|
+
const n = Me(), a = v(1, 1, -1, -1).mul(i.xyxy).add(n.xyxy).toVertexStage(), o = b(n.x, a.y), u = b(a.z, n.y), l = b(a.x, n.y), c = b(n.x, a.w), d = a.zy, h = a.xy, m = a.zw, p = a.xw, x = k(
|
|
670
|
+
t.sample(n).mul(1 / 4),
|
|
671
|
+
k(
|
|
672
|
+
t.sample(o),
|
|
673
|
+
t.sample(u),
|
|
674
|
+
t.sample(l),
|
|
675
|
+
t.sample(c)
|
|
676
|
+
).mul(1 / 8),
|
|
677
|
+
k(
|
|
678
|
+
t.sample(d),
|
|
679
|
+
t.sample(h),
|
|
680
|
+
t.sample(m),
|
|
681
|
+
t.sample(p)
|
|
682
|
+
).mul(1 / 16)
|
|
683
|
+
);
|
|
684
|
+
return he(r.sample(n), x, this.blendAmount);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
function qt(s) {
|
|
688
|
+
return (s instanceof li ? s.renderer.backend : "backend" in s ? s.backend : s).isWebGPUBackend === !0;
|
|
689
|
+
}
|
|
690
|
+
class Yr extends se {
|
|
691
|
+
constructor(e) {
|
|
692
|
+
super("vec4"), this.bloomIntensity = w(0.05), this.inputNode = e, this.thresholdNode = new Br(), this.blurNode = new $r(), this.ghostNode = new qr(), this.haloNode = new Jr(), this.bloomNode = new Xr(null, 8), this.glareNode = new Kr(), this.featuresNode = Mi(k(this.ghostNode, this.haloNode)), this.featuresNode.value.name = "LensFlare_features", this.featuresNode.pixelRatio = 0.5, this.blurNode.resolutionScale = 1, this.bloomNode.resolutionScale = 1, this.glareNode.resolutionScale = 1;
|
|
693
|
+
}
|
|
694
|
+
static get type() {
|
|
695
|
+
return "LensFlareNode";
|
|
696
|
+
}
|
|
697
|
+
setup(e) {
|
|
698
|
+
const {
|
|
699
|
+
inputNode: t,
|
|
700
|
+
thresholdNode: i,
|
|
701
|
+
blurNode: r,
|
|
702
|
+
ghostNode: n,
|
|
703
|
+
haloNode: a,
|
|
704
|
+
bloomNode: o,
|
|
705
|
+
featuresNode: u,
|
|
706
|
+
glareNode: l
|
|
707
|
+
} = this;
|
|
708
|
+
D(t != null);
|
|
709
|
+
const c = i.getTextureNode(), d = r.getTextureNode();
|
|
710
|
+
i.inputNode = t, r.inputNode = c, n.inputNode = d, a.inputNode = d, o.inputNode = c, l.inputNode = c;
|
|
711
|
+
const h = o.getTextureNode().mul(this.bloomIntensity), m = l.getTextureNode();
|
|
712
|
+
return O(() => {
|
|
713
|
+
const p = t;
|
|
714
|
+
return p.addAssign(h), qt(e) && p.addAssign(m), p.add(u);
|
|
715
|
+
})();
|
|
716
|
+
}
|
|
717
|
+
dispose() {
|
|
718
|
+
this.thresholdNode.dispose(), this.blurNode.dispose(), this.ghostNode.dispose(), this.haloNode.dispose(), this.bloomNode.dispose(), this.glareNode.dispose(), this.featuresNode.dispose(), super.dispose();
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
const en = (s) => new Yr(s != null ? Lt(s) : null);
|
|
722
|
+
let tn = class extends di {
|
|
723
|
+
static get type() {
|
|
724
|
+
return "OutputTexture3DNode";
|
|
725
|
+
}
|
|
726
|
+
constructor(e, t) {
|
|
727
|
+
super(t), this.owner = e, this.setUpdateMatrix(!1);
|
|
728
|
+
}
|
|
729
|
+
setup(e) {
|
|
730
|
+
return this.owner.build(e), super.setup(e);
|
|
731
|
+
}
|
|
732
|
+
clone() {
|
|
733
|
+
const e = new this.constructor(this.owner, this.value);
|
|
734
|
+
return e.uvNode = this.uvNode, e.levelNode = this.levelNode, e.biasNode = this.biasNode, e.sampler = this.sampler, e.depthNode = this.depthNode, e.compareNode = this.compareNode, e.gradNode = this.gradNode, e.offsetNode = this.offsetNode, e;
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
const yt = (...s) => new tn(...s), sn = /* @__PURE__ */ L(
|
|
738
|
+
(s, e, t, i) => (r) => {
|
|
739
|
+
t ??= je(e), i ??= Ge(e);
|
|
740
|
+
const n = e?.isPerspectiveCamera === !0;
|
|
741
|
+
return r.renderer.logarithmicDepthBuffer ? Rs(s, t, i) : n ? Gi(s, t, i) : Wi(s, t, i);
|
|
742
|
+
}
|
|
743
|
+
), us = (s, e, t) => {
|
|
744
|
+
e ??= zs, t ??= bs;
|
|
745
|
+
const i = Rs(s, e, t);
|
|
746
|
+
return Ii(i, e, t);
|
|
747
|
+
}, Tt = [
|
|
748
|
+
[58.1375, 2.7747, 26.8183],
|
|
749
|
+
[-150.5666, 4.2109, -88.5066],
|
|
750
|
+
[130.5887, -14.0195, 109.0745],
|
|
751
|
+
[-42.3277, 4.8052, -60.1097],
|
|
752
|
+
[4.5974, 2.1856, 12.5925],
|
|
753
|
+
[0.1357, 0.0914, 0.1067]
|
|
754
|
+
], rn = /* @__PURE__ */ R({
|
|
755
|
+
name: "turbo",
|
|
756
|
+
type: "vec3",
|
|
757
|
+
inputs: [{ name: "x", type: "float" }]
|
|
758
|
+
})(([s]) => {
|
|
759
|
+
const e = g(...Tt[0]).toVar();
|
|
760
|
+
for (let t = 1; t < Tt.length; ++t)
|
|
761
|
+
e.assign(g(...Tt[t]).add(s.mul(e)));
|
|
762
|
+
return e;
|
|
763
|
+
});
|
|
764
|
+
L(
|
|
765
|
+
(s, e, t, i) => {
|
|
766
|
+
t ??= je(e), i ??= Ge(e);
|
|
767
|
+
const r = sn(s, e, t, i);
|
|
768
|
+
return rn(ji(r, t, i));
|
|
769
|
+
}
|
|
770
|
+
);
|
|
771
|
+
const nn = /* @__PURE__ */ R({
|
|
772
|
+
name: "equirectToDirectionWorld",
|
|
773
|
+
type: "vec3",
|
|
774
|
+
inputs: [{ name: "uv", type: "vec2" }]
|
|
775
|
+
})(([s]) => {
|
|
776
|
+
const e = $e(0.5, s.x).mul(Ei), t = $e(s.y, 0.5).mul(qe), i = ne(t);
|
|
777
|
+
return g(i.mul(ne(e)), ie(t), i.mul(ie(e)));
|
|
778
|
+
});
|
|
779
|
+
function ls(s, e) {
|
|
780
|
+
let t = 1, i = 0;
|
|
781
|
+
for (; s > 0; )
|
|
782
|
+
t /= e, i += t * (s % e), s = Math.floor(s / e);
|
|
783
|
+
return i;
|
|
784
|
+
}
|
|
785
|
+
const cs = /* @__PURE__ */ Array.from(
|
|
786
|
+
{ length: 16 },
|
|
787
|
+
(s, e) => new re(ls(e + 1, 2), ls(e + 1, 3))
|
|
788
|
+
), { resetRendererState: an, restoreRendererState: on } = K;
|
|
789
|
+
function un(s) {
|
|
790
|
+
return s.isPerspectiveCamera === !0 || s.isOrthographicCamera === !0 || "updateProjectionMatrix" in s && "setViewOffset" in s && "clearViewOffset" in s;
|
|
791
|
+
}
|
|
792
|
+
const ln = /* @__PURE__ */ R({
|
|
793
|
+
name: "clipAABB",
|
|
794
|
+
type: "vec4",
|
|
795
|
+
inputs: [
|
|
796
|
+
{ name: "current", type: "vec4" },
|
|
797
|
+
{ name: "history", type: "vec4" },
|
|
798
|
+
{ name: "minColor", type: "vec4" },
|
|
799
|
+
{ name: "maxColor", type: "vec4" }
|
|
800
|
+
]
|
|
801
|
+
})(([s, e, t, i]) => {
|
|
802
|
+
const r = i.rgb.add(t.rgb).mul(0.5).toConst(), n = i.rgb.sub(t.rgb).mul(0.5).add(1e-7), a = e.sub(v(r, s.a)).toConst(), o = a.xyz.div(n).abs().toConst(), u = Re(o.x, o.y, o.z).toConst();
|
|
803
|
+
return u.greaterThan(1).select(v(r, s.a).add(a.div(u)), e);
|
|
804
|
+
}), ds = [
|
|
805
|
+
[-1, -1],
|
|
806
|
+
[-1, 1],
|
|
807
|
+
[1, -1],
|
|
808
|
+
[1, 1],
|
|
809
|
+
[1, 0],
|
|
810
|
+
[0, -1],
|
|
811
|
+
[0, 1],
|
|
812
|
+
[-1, 0]
|
|
813
|
+
], cn = /* @__PURE__ */ L(
|
|
814
|
+
(s, e, t, i, r) => {
|
|
815
|
+
const n = t.toVar(), a = t.pow2().toVar();
|
|
816
|
+
for (const [h, m] of ds) {
|
|
817
|
+
const p = s.load(e.add(Ne(h, m))).toConst();
|
|
818
|
+
n.addAssign(p), a.addAssign(p.pow2());
|
|
819
|
+
}
|
|
820
|
+
const o = ds.length + 1, u = n.div(o).toConst(), l = $(a.div(o).sub(u.pow2()).max(0)).mul(r).toConst(), c = u.sub(l).toConst(), d = u.add(l).toConst();
|
|
821
|
+
return ln(u.clamp(c, d), i, c, d);
|
|
822
|
+
}
|
|
823
|
+
), dn = [
|
|
824
|
+
[-1, -1],
|
|
825
|
+
[-1, 0],
|
|
826
|
+
[-1, 1],
|
|
827
|
+
[0, -1],
|
|
828
|
+
[0, 0],
|
|
829
|
+
[0, 1],
|
|
830
|
+
[1, -1],
|
|
831
|
+
[1, 0],
|
|
832
|
+
[1, 1]
|
|
833
|
+
], hn = /* @__PURE__ */ Y({
|
|
834
|
+
closestCoord: "ivec2",
|
|
835
|
+
closestDepth: "float"
|
|
836
|
+
}), mn = /* @__PURE__ */ L(
|
|
837
|
+
(s, e) => (t) => {
|
|
838
|
+
const i = Ne(0).toVar(), r = A(1).toVar();
|
|
839
|
+
for (const [n, a] of dn) {
|
|
840
|
+
const o = e.add(Ne(n, a)).toConst();
|
|
841
|
+
let u = s.load(o).r;
|
|
842
|
+
t.renderer.reversedDepthBuffer && (u = u.oneMinus()), u = u.toConst(), I(u.lessThan(r), () => {
|
|
843
|
+
i.assign(o), r.assign(u);
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
return hn(i, r);
|
|
847
|
+
}
|
|
848
|
+
), pn = /* @__PURE__ */ L(
|
|
849
|
+
(s, e) => {
|
|
850
|
+
const t = s.mul(e).fract().abs(), i = Re(t, t.oneMinus());
|
|
851
|
+
return i.x.mul(i.y).oneMinus().div(0.75);
|
|
852
|
+
}
|
|
853
|
+
), hs = /* @__PURE__ */ new re(), gn = /* @__PURE__ */ new rr(1, 1);
|
|
854
|
+
class ms extends se {
|
|
855
|
+
constructor(e, t, i, r) {
|
|
856
|
+
if (super("vec4"), this.temporalAlpha = w(0.05), this.varianceGamma = w(1), this.velocityThreshold = w(0.1), this.depthError = w(1e-3), this.debugShowRejection = !1, this.resolveRT = this.createRenderTarget("resolve"), this.historyRT = this.createRenderTarget("history"), this.resolveMaterial = new Ce(), this.mesh = new We(), this.needsSyncRenderPipeline = !1, this.needsClearHistory = !1, this.resolveNode = X(this.resolveRT.texture), this.historyNode = X(this.historyRT.texture), this.previousDepthNode = X(gn), this.originalProjectionMatrix = new Dt(), this.jitterIndex = 0, this.updateBeforeType = ee.FRAME, this.resolveMaterial.name = "TemporalAntialias_resolve", this.mesh.name = "TemporalAntialias", this.inputNode = e, this.depthNode = t, this.velocityNode = i, !un(r))
|
|
857
|
+
throw new Error("The provided camera is not supported.");
|
|
858
|
+
this.camera = r, this.textureNode = Le(this, this.resolveRT.texture);
|
|
859
|
+
}
|
|
860
|
+
static get type() {
|
|
861
|
+
return "TemporalAntialiasNode";
|
|
862
|
+
}
|
|
863
|
+
customCacheKey() {
|
|
864
|
+
return Gt(this.camera.id, +this.debugShowRejection);
|
|
865
|
+
}
|
|
866
|
+
createRenderTarget(e) {
|
|
867
|
+
const t = new jt(1, 1, {
|
|
868
|
+
depthBuffer: !1,
|
|
869
|
+
type: Ze,
|
|
870
|
+
format: be
|
|
871
|
+
}), i = t.texture;
|
|
872
|
+
i.minFilter = Z, i.magFilter = Z, i.generateMipmaps = !1;
|
|
873
|
+
const r = this.constructor.type;
|
|
874
|
+
return i.name = e != null ? `${r}_${e}` : r, t;
|
|
875
|
+
}
|
|
876
|
+
getTextureNode() {
|
|
877
|
+
return this.textureNode;
|
|
878
|
+
}
|
|
879
|
+
setSize(e, t) {
|
|
880
|
+
const { resolveRT: i, historyRT: r } = this;
|
|
881
|
+
return (e !== r.width || t !== r.height) && (i.setSize(e, t), r.setSize(e, t), this.needsClearHistory = !0), this;
|
|
882
|
+
}
|
|
883
|
+
clearHistory(e) {
|
|
884
|
+
e.setRenderTarget(this.resolveRT), e.clear(), e.setRenderTarget(this.historyRT), e.clear(), this.needsClearHistory = !1;
|
|
885
|
+
}
|
|
886
|
+
setViewOffset(e, t) {
|
|
887
|
+
const { camera: i } = this;
|
|
888
|
+
i.updateProjectionMatrix(), this.originalProjectionMatrix.copy(i.projectionMatrix), Pt.setProjectionMatrix(this.originalProjectionMatrix);
|
|
889
|
+
const r = cs[this.jitterIndex], n = r.x - 0.5, a = r.y - 0.5;
|
|
890
|
+
i.setViewOffset(e, t, n, a, e, t);
|
|
891
|
+
}
|
|
892
|
+
clearViewOffset() {
|
|
893
|
+
this.camera.clearViewOffset(), Pt.setProjectionMatrix(null), this.jitterIndex = (this.jitterIndex + 1) % cs.length;
|
|
894
|
+
}
|
|
895
|
+
copyDepthTexture(e) {
|
|
896
|
+
const t = this.depthNode.value, i = this.previousDepthTexture ??= t.clone();
|
|
897
|
+
(i.image.width !== t.width || i.image.height !== t.height) && (i.image.width = t.width, i.image.height = t.height, i.needsUpdate = !0), e.copyTextureToTexture(t, i), this.previousDepthNode.value = i;
|
|
898
|
+
}
|
|
899
|
+
swapBuffers() {
|
|
900
|
+
const { resolveRT: e, historyRT: t } = this;
|
|
901
|
+
this.resolveRT = t, this.historyRT = e, this.resolveNode.value = t.texture, this.historyNode.value = e.texture, this.textureNode.value = e.texture;
|
|
902
|
+
}
|
|
903
|
+
updateBefore({ renderer: e }) {
|
|
904
|
+
if (e == null)
|
|
905
|
+
return;
|
|
906
|
+
const t = e.getDrawingBufferSize(hs);
|
|
907
|
+
this.setSize(t.x, t.y), this.rendererState = an(e, this.rendererState), this.needsClearHistory && this.clearHistory(e), e.setRenderTarget(this.resolveRT), this.mesh.material = this.resolveMaterial, this.mesh.render(e), on(e, this.rendererState), qt(e) && this.copyDepthTexture(e), this.swapBuffers(), this.needsSyncRenderPipeline && this.clearViewOffset();
|
|
908
|
+
}
|
|
909
|
+
setupResolveNode({ renderer: e }) {
|
|
910
|
+
const t = (i) => {
|
|
911
|
+
const { previousDepthNode: r } = this, n = r.load(Ne(i.mul(r.size()).sub(0.5))).toConst();
|
|
912
|
+
return e.logarithmicDepthBuffer ? us(
|
|
913
|
+
n,
|
|
914
|
+
je(this.camera),
|
|
915
|
+
Ge(this.camera)
|
|
916
|
+
) : e.reversedDepthBuffer ? n.oneMinus() : n;
|
|
917
|
+
};
|
|
918
|
+
return O(() => {
|
|
919
|
+
const i = Ne(Ae), r = Ns, n = mn(this.depthNode, i).toConst(), a = n.get("closestCoord"), o = n.get("closestDepth"), u = this.velocityNode.load(a).xyz.mul(g(0.5, -0.5, 0.5)).toConst(), l = u.xy.length().div(this.velocityThreshold).oneMinus().saturate(), c = r.sub(u.xy).toConst(), d = t(c), h = e.logarithmicDepthBuffer ? us(
|
|
920
|
+
o,
|
|
921
|
+
je(this.camera),
|
|
922
|
+
Ge(this.camera)
|
|
923
|
+
) : o, m = Ri(
|
|
924
|
+
h.add(u.z),
|
|
925
|
+
d.add(this.depthError)
|
|
926
|
+
), p = l.mul(m), x = bi(
|
|
927
|
+
c.greaterThanEqual(0).all(),
|
|
928
|
+
c.lessThanEqual(1).all()
|
|
929
|
+
).toFloat(), y = o.notEqual(1).toFloat(), T = this.inputNode.load(i).toVar();
|
|
930
|
+
return I(x.mul(y).mul(p).greaterThan(0), () => {
|
|
931
|
+
const S = X(this.historyNode, c), M = cn(
|
|
932
|
+
this.inputNode,
|
|
933
|
+
i,
|
|
934
|
+
T,
|
|
935
|
+
S,
|
|
936
|
+
this.varianceGamma
|
|
937
|
+
), C = he(
|
|
938
|
+
this.temporalAlpha,
|
|
939
|
+
0.4,
|
|
940
|
+
pn(u.xy, zi(this.inputNode))
|
|
941
|
+
).saturate();
|
|
942
|
+
T.assign(he(M, T, C));
|
|
943
|
+
}).Else(() => {
|
|
944
|
+
this.debugShowRejection && T.assign(g(1, 0, 0));
|
|
945
|
+
}), T;
|
|
946
|
+
})();
|
|
947
|
+
}
|
|
948
|
+
setup(e) {
|
|
949
|
+
const t = () => {
|
|
950
|
+
const r = e.renderer.getDrawingBufferSize(hs);
|
|
951
|
+
this.setViewOffset(r.width, r.height);
|
|
952
|
+
};
|
|
953
|
+
if (e.context.renderPipeline != null) {
|
|
954
|
+
const { context: r } = e.context.renderPipeline;
|
|
955
|
+
r.onBeforeRenderPipeline = t, this.needsSyncRenderPipeline = !0;
|
|
956
|
+
}
|
|
957
|
+
if (e.context.postProcessing != null) {
|
|
958
|
+
const { context: r } = e.context.postProcessing;
|
|
959
|
+
r.onBeforePostProcessing = t, this.needsSyncRenderPipeline = !0;
|
|
960
|
+
}
|
|
961
|
+
const { resolveMaterial: i } = this;
|
|
962
|
+
return i.fragmentNode = this.setupResolveNode(e), i.needsUpdate = !0, this.textureNode.uvNode = this.inputNode.uvNode, this.textureNode;
|
|
963
|
+
}
|
|
964
|
+
dispose() {
|
|
965
|
+
this.resolveRT.dispose(), this.historyRT.dispose(), this.previousDepthTexture?.dispose(), this.resolveMaterial.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
function xn(...s) {
|
|
969
|
+
if (s.length === 1)
|
|
970
|
+
return (n, a, o, u) => new ms(
|
|
971
|
+
Lt(n),
|
|
972
|
+
a,
|
|
973
|
+
o,
|
|
974
|
+
u
|
|
975
|
+
);
|
|
976
|
+
const [e, t, i, r] = s;
|
|
977
|
+
return new ms(
|
|
978
|
+
Lt(e),
|
|
979
|
+
t,
|
|
980
|
+
i,
|
|
981
|
+
r
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
const yn = "eac103980f20c0956f2d3215833e73514be08462", Tn = `https://media.githubusercontent.com/media/takram-design-engineering/three-geospatial/${yn}/packages/atmosphere/assets/stars.bin`, wn = /* @__PURE__ */ new H();
|
|
985
|
+
function fn(s, e, t, i) {
|
|
986
|
+
const r = t.projectOnSurface(
|
|
987
|
+
s,
|
|
988
|
+
wn
|
|
989
|
+
);
|
|
990
|
+
return r != null ? t.getOsculatingSphereCenter(r, e, i).negate() : i.setScalar(0);
|
|
991
|
+
}
|
|
992
|
+
var Sn = "Invariant failed";
|
|
993
|
+
function de(s, e) {
|
|
994
|
+
if (!s)
|
|
995
|
+
throw new Error(Sn);
|
|
996
|
+
}
|
|
997
|
+
const ps = typeof window < "u" && window.requestIdleCallback != null ? window.requestIdleCallback : function(s, e = {}) {
|
|
998
|
+
const t = e.timeout ?? 1, i = performance.now();
|
|
999
|
+
return setTimeout(() => {
|
|
1000
|
+
s({
|
|
1001
|
+
get didTimeout() {
|
|
1002
|
+
return e.timeout != null ? !1 : performance.now() - i - 1 > t;
|
|
1003
|
+
},
|
|
1004
|
+
timeRemaining() {
|
|
1005
|
+
return Math.max(0, 1 + (performance.now() - i));
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1008
|
+
}, 1);
|
|
1009
|
+
}, U = "float", vn = "float", E = "float", gs = "float", Cn = "float", Us = "float", Nn = "vec3", Se = "vec3", Be = "vec3", Is = "vec3", ge = "vec3", Os = "vec3", nt = /* @__PURE__ */ Y(
|
|
1010
|
+
{
|
|
1011
|
+
width: U,
|
|
1012
|
+
expTerm: E,
|
|
1013
|
+
expScale: gs,
|
|
1014
|
+
linearTerm: gs,
|
|
1015
|
+
constantTerm: E
|
|
1016
|
+
},
|
|
1017
|
+
"DensityProfileLayer"
|
|
1018
|
+
), De = /* @__PURE__ */ Y(
|
|
1019
|
+
{
|
|
1020
|
+
layer0: nt.name,
|
|
1021
|
+
layer1: nt.name
|
|
1022
|
+
},
|
|
1023
|
+
"DensityProfile"
|
|
1024
|
+
), Bt = {
|
|
1025
|
+
worldToUnit: E,
|
|
1026
|
+
solarIrradiance: Be,
|
|
1027
|
+
sunAngularRadius: vn,
|
|
1028
|
+
bottomRadius: U,
|
|
1029
|
+
topRadius: U,
|
|
1030
|
+
rayleighDensity: De.name,
|
|
1031
|
+
rayleighScattering: ge,
|
|
1032
|
+
mieDensity: De.name,
|
|
1033
|
+
mieScattering: ge,
|
|
1034
|
+
mieExtinction: ge,
|
|
1035
|
+
miePhaseFunctionG: E,
|
|
1036
|
+
absorptionDensity: De.name,
|
|
1037
|
+
absorptionExtinction: ge,
|
|
1038
|
+
groundAlbedo: Se,
|
|
1039
|
+
minCosLight: E,
|
|
1040
|
+
sunRadianceToLuminance: Se,
|
|
1041
|
+
skyRadianceToLuminance: Se,
|
|
1042
|
+
luminanceScale: E,
|
|
1043
|
+
transmittanceTextureSize: "uvec2",
|
|
1044
|
+
irradianceTextureSize: "uvec2",
|
|
1045
|
+
multipleScatteringTextureSize: "uvec2",
|
|
1046
|
+
scatteringTextureRadiusSize: "uint",
|
|
1047
|
+
scatteringTextureCosViewSize: "uint",
|
|
1048
|
+
scatteringTextureCosLightSize: "uint",
|
|
1049
|
+
scatteringTextureCosViewLightSize: "uint"
|
|
1050
|
+
}, q = /* @__PURE__ */ Y(
|
|
1051
|
+
Bt,
|
|
1052
|
+
"AtmosphereParameters"
|
|
1053
|
+
);
|
|
1054
|
+
function xs(s, e) {
|
|
1055
|
+
const { width: t, expTerm: i, expScale: r, linearTerm: n, constantTerm: a } = s;
|
|
1056
|
+
return nt({
|
|
1057
|
+
// @ts-expect-error Object-style parameter is supported
|
|
1058
|
+
width: A(t * e),
|
|
1059
|
+
expTerm: A(i),
|
|
1060
|
+
expScale: A(r / e),
|
|
1061
|
+
linearTerm: A(n / e),
|
|
1062
|
+
constantTerm: A(a)
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
function wt(s, e) {
|
|
1066
|
+
return De({
|
|
1067
|
+
// @ts-expect-error Object-style parameter is supported
|
|
1068
|
+
layer0: xs(s.layers[0], e),
|
|
1069
|
+
layer1: xs(s.layers[1], e)
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
const ys = /* @__PURE__ */ Symbol("DESTRUCTIBLE");
|
|
1073
|
+
function j(s) {
|
|
1074
|
+
if (Wt(s), s[ys] === !0)
|
|
1075
|
+
return s;
|
|
1076
|
+
for (const e in Bt)
|
|
1077
|
+
Object.hasOwn(Bt, e) && (s[e] = s.get(e));
|
|
1078
|
+
return s[ys] = !0, s;
|
|
1079
|
+
}
|
|
1080
|
+
class Ht {
|
|
1081
|
+
constructor(e) {
|
|
1082
|
+
this.parameters = e;
|
|
1083
|
+
const {
|
|
1084
|
+
worldToUnit: t,
|
|
1085
|
+
solarIrradiance: i,
|
|
1086
|
+
sunAngularRadius: r,
|
|
1087
|
+
bottomRadius: n,
|
|
1088
|
+
topRadius: a,
|
|
1089
|
+
rayleighDensity: o,
|
|
1090
|
+
rayleighScattering: u,
|
|
1091
|
+
mieDensity: l,
|
|
1092
|
+
mieScattering: c,
|
|
1093
|
+
mieExtinction: d,
|
|
1094
|
+
miePhaseFunctionG: h,
|
|
1095
|
+
absorptionDensity: m,
|
|
1096
|
+
absorptionExtinction: p,
|
|
1097
|
+
groundAlbedo: x,
|
|
1098
|
+
minCosLight: y,
|
|
1099
|
+
sunRadianceToLuminance: T,
|
|
1100
|
+
skyRadianceToLuminance: S,
|
|
1101
|
+
luminanceScale: M,
|
|
1102
|
+
transmittanceTextureSize: C,
|
|
1103
|
+
irradianceTextureSize: N,
|
|
1104
|
+
multipleScatteringTextureSize: f,
|
|
1105
|
+
scatteringTextureRadiusSize: z,
|
|
1106
|
+
scatteringTextureCosViewSize: F,
|
|
1107
|
+
scatteringTextureCosLightSize: P,
|
|
1108
|
+
scatteringTextureCosViewLightSize: V
|
|
1109
|
+
} = e;
|
|
1110
|
+
this.parametersNode = j(
|
|
1111
|
+
q({
|
|
1112
|
+
// @ts-expect-error Object-style parameter is supported
|
|
1113
|
+
worldToUnit: A(t),
|
|
1114
|
+
solarIrradiance: g(i),
|
|
1115
|
+
sunAngularRadius: A(r),
|
|
1116
|
+
bottomRadius: A(n * t),
|
|
1117
|
+
topRadius: A(a * t),
|
|
1118
|
+
rayleighDensity: wt(o, t),
|
|
1119
|
+
rayleighScattering: g(
|
|
1120
|
+
u.x / t,
|
|
1121
|
+
u.y / t,
|
|
1122
|
+
u.z / t
|
|
1123
|
+
),
|
|
1124
|
+
mieDensity: wt(l, t),
|
|
1125
|
+
mieScattering: g(
|
|
1126
|
+
c.x / t,
|
|
1127
|
+
c.y / t,
|
|
1128
|
+
c.z / t
|
|
1129
|
+
),
|
|
1130
|
+
mieExtinction: g(
|
|
1131
|
+
d.x / t,
|
|
1132
|
+
d.y / t,
|
|
1133
|
+
d.z / t
|
|
1134
|
+
),
|
|
1135
|
+
miePhaseFunctionG: A(h),
|
|
1136
|
+
absorptionDensity: wt(m, t),
|
|
1137
|
+
absorptionExtinction: g(
|
|
1138
|
+
p.x / t,
|
|
1139
|
+
p.y / t,
|
|
1140
|
+
p.z / t
|
|
1141
|
+
),
|
|
1142
|
+
groundAlbedo: g(x),
|
|
1143
|
+
minCosLight: A(y),
|
|
1144
|
+
sunRadianceToLuminance: g(T),
|
|
1145
|
+
skyRadianceToLuminance: g(S),
|
|
1146
|
+
luminanceScale: A(M),
|
|
1147
|
+
transmittanceTextureSize: Ne(C),
|
|
1148
|
+
irradianceTextureSize: Ne(N),
|
|
1149
|
+
multipleScatteringTextureSize: st(f),
|
|
1150
|
+
scatteringTextureRadiusSize: fe(z),
|
|
1151
|
+
scatteringTextureCosViewSize: fe(F),
|
|
1152
|
+
scatteringTextureCosLightSize: fe(P),
|
|
1153
|
+
scatteringTextureCosViewLightSize: fe(
|
|
1154
|
+
V
|
|
1155
|
+
)
|
|
1156
|
+
}).toConst("atmosphereParameters")
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
1160
|
+
dispose() {
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
function oe(s) {
|
|
1164
|
+
if (typeof s.context.getAtmosphere != "function")
|
|
1165
|
+
throw new Error("getAtmosphere() was not found in the builder context.");
|
|
1166
|
+
const e = s.context.getAtmosphere();
|
|
1167
|
+
if (!(e instanceof Ht))
|
|
1168
|
+
throw new Error(
|
|
1169
|
+
"getAtmosphere() must return an instanceof AtmosphereContextBase."
|
|
1170
|
+
);
|
|
1171
|
+
return e;
|
|
1172
|
+
}
|
|
1173
|
+
class ks extends Ht {
|
|
1174
|
+
constructor(e, t) {
|
|
1175
|
+
super(e), this.lambdas = w(new H(680, 550, 440)), this.luminanceFromRadiance = w("mat3"), this.textureType = t;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
class $s {
|
|
1179
|
+
setup(e, t) {
|
|
1180
|
+
this.parameters = e, this.textureType = t;
|
|
1181
|
+
}
|
|
1182
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
1183
|
+
dispose() {
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
const ce = /* @__PURE__ */ R({
|
|
1187
|
+
name: "clampCosine",
|
|
1188
|
+
type: E,
|
|
1189
|
+
inputs: [{ name: "cosine", type: E }]
|
|
1190
|
+
})(([s]) => Ot(s, -1, 1)), js = /* @__PURE__ */ R({
|
|
1191
|
+
name: "clampDistance",
|
|
1192
|
+
type: E,
|
|
1193
|
+
inputs: [{ name: "cosine", type: E }]
|
|
1194
|
+
})(([s]) => Re(s, 0)), ht = /* @__PURE__ */ R({
|
|
1195
|
+
name: "clampRadius",
|
|
1196
|
+
type: U,
|
|
1197
|
+
inputs: [
|
|
1198
|
+
{ name: "parameters", type: q },
|
|
1199
|
+
{ name: "radius", type: U }
|
|
1200
|
+
]
|
|
1201
|
+
})(([s, e]) => {
|
|
1202
|
+
const { topRadius: t, bottomRadius: i } = j(s);
|
|
1203
|
+
return Ot(e, i, t);
|
|
1204
|
+
}), ve = /* @__PURE__ */ R({
|
|
1205
|
+
name: "sqrtSafe",
|
|
1206
|
+
type: E,
|
|
1207
|
+
inputs: [{ name: "area", type: Cn }]
|
|
1208
|
+
})(([s]) => $(Re(s, 0))), Ue = /* @__PURE__ */ R({
|
|
1209
|
+
name: "distanceToTopAtmosphereBoundary",
|
|
1210
|
+
type: U,
|
|
1211
|
+
inputs: [
|
|
1212
|
+
{ name: "parameters", type: q },
|
|
1213
|
+
{ name: "radius", type: U },
|
|
1214
|
+
{ name: "cosView", type: E }
|
|
1215
|
+
]
|
|
1216
|
+
})(([s, e, t]) => {
|
|
1217
|
+
const { topRadius: i } = j(s), r = e.pow2().mul(t.pow2().sub(1)).add(i.pow2());
|
|
1218
|
+
return js(e.negate().mul(t).add(ve(r)));
|
|
1219
|
+
}), Mn = /* @__PURE__ */ R({
|
|
1220
|
+
name: "distanceToBottomAtmosphereBoundary",
|
|
1221
|
+
type: U,
|
|
1222
|
+
inputs: [
|
|
1223
|
+
{ name: "parameters", type: q },
|
|
1224
|
+
{ name: "radius", type: U },
|
|
1225
|
+
{ name: "cosView", type: E }
|
|
1226
|
+
]
|
|
1227
|
+
})(([s, e, t]) => {
|
|
1228
|
+
const { bottomRadius: i } = j(s), r = e.pow2().mul(t.pow2().sub(1)).add(i.pow2());
|
|
1229
|
+
return js(e.negate().mul(t).sub(ve(r)));
|
|
1230
|
+
}), Gs = /* @__PURE__ */ R({
|
|
1231
|
+
name: "distanceToNearestAtmosphereBoundary",
|
|
1232
|
+
type: U,
|
|
1233
|
+
inputs: [
|
|
1234
|
+
{ name: "parameters", type: q },
|
|
1235
|
+
{ name: "radius", type: U },
|
|
1236
|
+
{ name: "cosView", type: E },
|
|
1237
|
+
{ name: "intersectsGround", type: "bool" }
|
|
1238
|
+
]
|
|
1239
|
+
})(([s, e, t, i]) => i.select(
|
|
1240
|
+
Mn(s, e, t),
|
|
1241
|
+
Ue(s, e, t)
|
|
1242
|
+
)), Ws = /* @__PURE__ */ R({
|
|
1243
|
+
name: "rayIntersectsGround",
|
|
1244
|
+
type: "bool",
|
|
1245
|
+
inputs: [
|
|
1246
|
+
{ name: "parameters", type: q },
|
|
1247
|
+
{ name: "radius", type: U },
|
|
1248
|
+
{ name: "cosView", type: E }
|
|
1249
|
+
]
|
|
1250
|
+
})(([s, e, t]) => {
|
|
1251
|
+
const { bottomRadius: i } = j(s);
|
|
1252
|
+
return t.lessThan(0).and(
|
|
1253
|
+
e.pow2().mul(t.pow2().sub(1)).add(i.pow2()).greaterThanEqual(0)
|
|
1254
|
+
);
|
|
1255
|
+
}), xe = /* @__PURE__ */ R({
|
|
1256
|
+
name: "getTextureCoordFromUnitRange",
|
|
1257
|
+
type: "float",
|
|
1258
|
+
inputs: [
|
|
1259
|
+
{ name: "unit", type: "float" },
|
|
1260
|
+
{ name: "textureSize", type: "float" }
|
|
1261
|
+
]
|
|
1262
|
+
})(([s, e]) => $t(0.5, e).add(
|
|
1263
|
+
s.mul(e.reciprocal().oneMinus())
|
|
1264
|
+
)), Rn = /* @__PURE__ */ R({
|
|
1265
|
+
name: "getTransmittanceTextureUV",
|
|
1266
|
+
type: "vec2",
|
|
1267
|
+
inputs: [
|
|
1268
|
+
{ name: "parameters", type: q },
|
|
1269
|
+
{ name: "radius", type: U },
|
|
1270
|
+
{ name: "cosView", type: E }
|
|
1271
|
+
]
|
|
1272
|
+
})(([s, e, t]) => {
|
|
1273
|
+
const { topRadius: i, bottomRadius: r, transmittanceTextureSize: n } = j(s), a = $(i.pow2().sub(r.pow2())).toConst(), o = ve(
|
|
1274
|
+
e.pow2().sub(r.pow2())
|
|
1275
|
+
).toConst(), u = Ue(
|
|
1276
|
+
s,
|
|
1277
|
+
e,
|
|
1278
|
+
t
|
|
1279
|
+
), l = i.sub(e).toConst(), c = o.add(a), d = u.remap(l, c), h = o.div(a);
|
|
1280
|
+
return b(
|
|
1281
|
+
xe(d, n.x),
|
|
1282
|
+
xe(h, n.y)
|
|
1283
|
+
);
|
|
1284
|
+
}), Fe = /* @__PURE__ */ L(
|
|
1285
|
+
(s, e, t) => (i) => {
|
|
1286
|
+
const r = oe(i), { parametersNode: n } = r, a = Rn(n, e, t);
|
|
1287
|
+
return s.sample(a).rgb;
|
|
1288
|
+
}
|
|
1289
|
+
), bn = /* @__PURE__ */ L(
|
|
1290
|
+
(s, e, t, i, r) => (n) => {
|
|
1291
|
+
const a = oe(n), { parametersNode: o } = a, u = ht(
|
|
1292
|
+
o,
|
|
1293
|
+
$(
|
|
1294
|
+
i.pow2().add(te(2, e, t, i)).add(e.pow2())
|
|
1295
|
+
)
|
|
1296
|
+
).toConst(), l = ce(
|
|
1297
|
+
e.mul(t).add(i).div(u)
|
|
1298
|
+
).toConst(), c = g(0).toVar();
|
|
1299
|
+
return I(r, () => {
|
|
1300
|
+
c.assign(
|
|
1301
|
+
Fe(
|
|
1302
|
+
s,
|
|
1303
|
+
u,
|
|
1304
|
+
l.negate()
|
|
1305
|
+
).div(
|
|
1306
|
+
Fe(
|
|
1307
|
+
s,
|
|
1308
|
+
e,
|
|
1309
|
+
t.negate()
|
|
1310
|
+
)
|
|
1311
|
+
).min(1)
|
|
1312
|
+
);
|
|
1313
|
+
}).Else(() => {
|
|
1314
|
+
c.assign(
|
|
1315
|
+
Fe(
|
|
1316
|
+
s,
|
|
1317
|
+
e,
|
|
1318
|
+
t
|
|
1319
|
+
).div(
|
|
1320
|
+
Fe(
|
|
1321
|
+
s,
|
|
1322
|
+
u,
|
|
1323
|
+
l
|
|
1324
|
+
)
|
|
1325
|
+
).min(1)
|
|
1326
|
+
);
|
|
1327
|
+
}), c;
|
|
1328
|
+
}
|
|
1329
|
+
), at = /* @__PURE__ */ L(
|
|
1330
|
+
(s, e, t) => (i) => {
|
|
1331
|
+
const r = oe(i), { parametersNode: n } = r, { sunAngularRadius: a, bottomRadius: o } = n, u = o.div(e).toConst(), l = $(Re(u.pow2().oneMinus(), 0)).negate();
|
|
1332
|
+
return Fe(
|
|
1333
|
+
s,
|
|
1334
|
+
e,
|
|
1335
|
+
t
|
|
1336
|
+
).mul(
|
|
1337
|
+
ut(
|
|
1338
|
+
u.negate().mul(a),
|
|
1339
|
+
u.mul(a),
|
|
1340
|
+
t.sub(l)
|
|
1341
|
+
)
|
|
1342
|
+
);
|
|
1343
|
+
}
|
|
1344
|
+
), _t = /* @__PURE__ */ R({
|
|
1345
|
+
name: "rayleighPhaseFunction",
|
|
1346
|
+
type: Us,
|
|
1347
|
+
inputs: [{ name: "cosViewLight", type: E }]
|
|
1348
|
+
})(([s]) => $t(3, te(16, qe)).mul(s.pow2().add(1))), qs = /* @__PURE__ */ R({
|
|
1349
|
+
name: "miePhaseFunction",
|
|
1350
|
+
type: Us,
|
|
1351
|
+
inputs: [
|
|
1352
|
+
{ name: "g", type: E },
|
|
1353
|
+
{ name: "cosViewLight", type: E }
|
|
1354
|
+
]
|
|
1355
|
+
})(([s, e]) => $t(3, qe.mul(8)).mul(s.pow2().oneMinus()).div(s.pow2().add(2)).mul(e.pow2().add(1)).div(s.pow2().sub(s.mul(2).mul(e)).add(1).pow(1.5))), Hs = /* @__PURE__ */ R({
|
|
1356
|
+
name: "getScatteringTextureCoord",
|
|
1357
|
+
type: "vec4",
|
|
1358
|
+
inputs: [
|
|
1359
|
+
{ name: "parameters", type: q },
|
|
1360
|
+
{ name: "radius", type: U },
|
|
1361
|
+
{ name: "cosView", type: E },
|
|
1362
|
+
{ name: "cosLight", type: E },
|
|
1363
|
+
{ name: "cosViewLight", type: E },
|
|
1364
|
+
{ name: "intersectsGround", type: "bool" }
|
|
1365
|
+
]
|
|
1366
|
+
})(([
|
|
1367
|
+
s,
|
|
1368
|
+
e,
|
|
1369
|
+
t,
|
|
1370
|
+
i,
|
|
1371
|
+
r,
|
|
1372
|
+
n
|
|
1373
|
+
]) => {
|
|
1374
|
+
const {
|
|
1375
|
+
topRadius: a,
|
|
1376
|
+
bottomRadius: o,
|
|
1377
|
+
minCosLight: u,
|
|
1378
|
+
scatteringTextureRadiusSize: l,
|
|
1379
|
+
scatteringTextureCosViewSize: c,
|
|
1380
|
+
scatteringTextureCosLightSize: d
|
|
1381
|
+
} = j(s), h = $(a.pow2().sub(o.pow2())).toConst(), m = ve(
|
|
1382
|
+
e.pow2().sub(o.pow2())
|
|
1383
|
+
).toConst(), p = xe(
|
|
1384
|
+
m.div(h),
|
|
1385
|
+
l
|
|
1386
|
+
), x = e.mul(t).toConst(), y = x.pow2().sub(e.pow2()).add(o.pow2()).toConst(), T = A(0).toVar();
|
|
1387
|
+
I(n, () => {
|
|
1388
|
+
const F = x.negate().sub(ve(y)), P = e.sub(o).toConst(), V = m;
|
|
1389
|
+
T.assign(
|
|
1390
|
+
xe(
|
|
1391
|
+
V.equal(P).select(0, F.remap(P, V)),
|
|
1392
|
+
c.div(2)
|
|
1393
|
+
).oneMinus().mul(0.5)
|
|
1394
|
+
);
|
|
1395
|
+
}).Else(() => {
|
|
1396
|
+
const F = x.negate().add(ve(y.add(h.pow2()))), P = a.sub(e).toConst(), V = m.add(h);
|
|
1397
|
+
T.assign(
|
|
1398
|
+
xe(
|
|
1399
|
+
F.remap(P, V),
|
|
1400
|
+
c.div(2)
|
|
1401
|
+
).add(1).mul(0.5)
|
|
1402
|
+
);
|
|
1403
|
+
});
|
|
1404
|
+
const S = a.sub(o).toConst(), M = h, C = Ue(s, o, i).remap(S, M).toConst(), N = Ue(
|
|
1405
|
+
s,
|
|
1406
|
+
o,
|
|
1407
|
+
u
|
|
1408
|
+
).remap(S, M), f = xe(
|
|
1409
|
+
Re(C.div(N).oneMinus(), 0).div(C.add(1)),
|
|
1410
|
+
d
|
|
1411
|
+
), z = r.add(1).mul(0.5);
|
|
1412
|
+
return v(z, f, T, p);
|
|
1413
|
+
}), _s = /* @__PURE__ */ L(
|
|
1414
|
+
(s, e, t, i, r, n) => (a) => {
|
|
1415
|
+
const o = oe(a), { parametersNode: u } = o, { scatteringTextureCosViewLightSize: l } = u, c = Hs(
|
|
1416
|
+
u,
|
|
1417
|
+
e,
|
|
1418
|
+
t,
|
|
1419
|
+
i,
|
|
1420
|
+
r,
|
|
1421
|
+
n
|
|
1422
|
+
).toConst(), d = c.x.mul(l.sub(1)).toConst(), h = kt(d).toConst(), m = d.sub(h).toConst(), p = g(
|
|
1423
|
+
h.add(c.y).div(l),
|
|
1424
|
+
c.z,
|
|
1425
|
+
c.w
|
|
1426
|
+
), x = g(
|
|
1427
|
+
h.add(1).add(c.y).div(l),
|
|
1428
|
+
c.z,
|
|
1429
|
+
c.w
|
|
1430
|
+
);
|
|
1431
|
+
return s.sample(p).mul(m.oneMinus()).add(s.sample(x).mul(m)).rgb;
|
|
1432
|
+
}
|
|
1433
|
+
), zn = /* @__PURE__ */ R({
|
|
1434
|
+
name: "getIrradianceTextureUV",
|
|
1435
|
+
type: "vec2",
|
|
1436
|
+
inputs: [
|
|
1437
|
+
{ name: "parameters", type: q },
|
|
1438
|
+
{ name: "radius", type: U },
|
|
1439
|
+
{ name: "cosLight", type: E }
|
|
1440
|
+
]
|
|
1441
|
+
})(([s, e, t]) => {
|
|
1442
|
+
const { topRadius: i, bottomRadius: r, irradianceTextureSize: n } = j(s), a = e.remap(r, i), o = t.mul(0.5).add(0.5);
|
|
1443
|
+
return b(
|
|
1444
|
+
xe(o, n.x),
|
|
1445
|
+
xe(a, n.y)
|
|
1446
|
+
);
|
|
1447
|
+
}), En = /* @__PURE__ */ L(
|
|
1448
|
+
(s, e, t) => (i) => {
|
|
1449
|
+
const r = oe(i), { parametersNode: n } = r, a = zn(n, e, t);
|
|
1450
|
+
return s.sample(a).rgb;
|
|
1451
|
+
}
|
|
1452
|
+
), Ts = /* @__PURE__ */ R({
|
|
1453
|
+
name: "getLayerDensity",
|
|
1454
|
+
type: E,
|
|
1455
|
+
inputs: [
|
|
1456
|
+
{ name: "layer", type: nt },
|
|
1457
|
+
{ name: "altitude", type: U }
|
|
1458
|
+
]
|
|
1459
|
+
})(([s, e]) => {
|
|
1460
|
+
const t = s.get("expTerm"), i = s.get("expScale"), r = s.get("linearTerm"), n = s.get("constantTerm");
|
|
1461
|
+
return t.mul(lt(i.mul(e))).add(r.mul(e)).add(n).saturate();
|
|
1462
|
+
}), et = /* @__PURE__ */ R({
|
|
1463
|
+
name: "getProfileDensity",
|
|
1464
|
+
type: E,
|
|
1465
|
+
inputs: [
|
|
1466
|
+
{ name: "layer", type: De },
|
|
1467
|
+
{ name: "altitude", type: U }
|
|
1468
|
+
]
|
|
1469
|
+
})(([s, e]) => e.lessThan(s.get("layer0").get("width")).select(
|
|
1470
|
+
Ts(s.get("layer0"), e),
|
|
1471
|
+
Ts(s.get("layer1"), e)
|
|
1472
|
+
)), ye = /* @__PURE__ */ R({
|
|
1473
|
+
name: "getUnitRangeFromTextureCoord",
|
|
1474
|
+
type: "float",
|
|
1475
|
+
inputs: [
|
|
1476
|
+
{ name: "coord", type: "float" },
|
|
1477
|
+
{ name: "textureSize", type: "float" }
|
|
1478
|
+
]
|
|
1479
|
+
})(([s, e]) => {
|
|
1480
|
+
const t = e.reciprocal();
|
|
1481
|
+
return s.sub(t.mul(0.5)).div(t.oneMinus());
|
|
1482
|
+
}), ot = /* @__PURE__ */ Y(
|
|
1483
|
+
{
|
|
1484
|
+
radius: U,
|
|
1485
|
+
cosView: E,
|
|
1486
|
+
cosLight: E,
|
|
1487
|
+
cosViewLight: E,
|
|
1488
|
+
intersectsGround: "bool"
|
|
1489
|
+
},
|
|
1490
|
+
"ScatteringParams"
|
|
1491
|
+
), An = /* @__PURE__ */ R({
|
|
1492
|
+
// BUG: Cannot access vector component inside struct in layout function
|
|
1493
|
+
// https://github.com/mrdoob/three.js/issues/33345
|
|
1494
|
+
typeOnly: !0,
|
|
1495
|
+
name: "getParamsFromScatteringTextureCoord",
|
|
1496
|
+
type: ot,
|
|
1497
|
+
inputs: [
|
|
1498
|
+
{ name: "parameters", type: q },
|
|
1499
|
+
{ name: "coord", type: "vec4" }
|
|
1500
|
+
]
|
|
1501
|
+
})(([s, e]) => {
|
|
1502
|
+
const {
|
|
1503
|
+
bottomRadius: t,
|
|
1504
|
+
topRadius: i,
|
|
1505
|
+
minCosLight: r,
|
|
1506
|
+
scatteringTextureRadiusSize: n,
|
|
1507
|
+
scatteringTextureCosViewSize: a,
|
|
1508
|
+
scatteringTextureCosLightSize: o
|
|
1509
|
+
} = j(s), u = $(i.pow2().sub(t.pow2())).toConst(), l = u.mul(
|
|
1510
|
+
ye(e.w, n)
|
|
1511
|
+
).toConst(), c = $(l.pow2().add(t.pow2())), d = A(0).toVar(), h = Ve().toVar();
|
|
1512
|
+
I(e.z.lessThan(0.5), () => {
|
|
1513
|
+
const N = c.sub(t).toConst(), f = l, z = N.add(
|
|
1514
|
+
f.sub(N).mul(
|
|
1515
|
+
ye(
|
|
1516
|
+
e.z.mul(2).oneMinus(),
|
|
1517
|
+
a.div(2)
|
|
1518
|
+
)
|
|
1519
|
+
)
|
|
1520
|
+
).toConst();
|
|
1521
|
+
d.assign(
|
|
1522
|
+
z.equal(0).select(
|
|
1523
|
+
-1,
|
|
1524
|
+
ce(
|
|
1525
|
+
l.pow2().add(z.pow2()).negate().div(te(2, c, z))
|
|
1526
|
+
)
|
|
1527
|
+
)
|
|
1528
|
+
), h.assign(Ve(!0));
|
|
1529
|
+
}).Else(() => {
|
|
1530
|
+
const N = i.sub(c).toConst(), f = l.add(u), z = N.add(
|
|
1531
|
+
f.sub(N).mul(
|
|
1532
|
+
ye(
|
|
1533
|
+
e.z.mul(2).sub(1),
|
|
1534
|
+
a.div(2)
|
|
1535
|
+
)
|
|
1536
|
+
)
|
|
1537
|
+
).toConst();
|
|
1538
|
+
d.assign(
|
|
1539
|
+
z.equal(0).select(
|
|
1540
|
+
1,
|
|
1541
|
+
ce(
|
|
1542
|
+
u.pow2().sub(l.pow2()).sub(z.pow2()).div(te(2, c, z))
|
|
1543
|
+
)
|
|
1544
|
+
)
|
|
1545
|
+
), h.assign(Ve(!1));
|
|
1546
|
+
});
|
|
1547
|
+
const m = ye(
|
|
1548
|
+
e.y,
|
|
1549
|
+
o
|
|
1550
|
+
).toConst(), p = i.sub(t).toConst(), x = u, y = Ue(
|
|
1551
|
+
s,
|
|
1552
|
+
t,
|
|
1553
|
+
r
|
|
1554
|
+
).remap(p, x).toConst(), T = y.sub(m.mul(y)).div(m.mul(y).add(1)), S = p.add(Ms(T, y).mul(x.sub(p))).toConst(), M = S.equal(0).select(
|
|
1555
|
+
1,
|
|
1556
|
+
ce(
|
|
1557
|
+
u.pow2().sub(S.pow2()).div(te(2, t, S))
|
|
1558
|
+
)
|
|
1559
|
+
), C = ce(e.x.mul(2).sub(1));
|
|
1560
|
+
return ot(
|
|
1561
|
+
c,
|
|
1562
|
+
d,
|
|
1563
|
+
M,
|
|
1564
|
+
C,
|
|
1565
|
+
h
|
|
1566
|
+
);
|
|
1567
|
+
}), Fn = /* @__PURE__ */ R({
|
|
1568
|
+
// BUG: Cannot access vector component inside struct in layout function
|
|
1569
|
+
// https://github.com/mrdoob/three.js/issues/33345
|
|
1570
|
+
typeOnly: !0,
|
|
1571
|
+
name: "getParamsFromScatteringTextureFragCoord",
|
|
1572
|
+
type: ot,
|
|
1573
|
+
inputs: [
|
|
1574
|
+
{ name: "parameters", type: q },
|
|
1575
|
+
{ name: "fragCoord", type: "vec3" }
|
|
1576
|
+
]
|
|
1577
|
+
})(([s, e]) => {
|
|
1578
|
+
const {
|
|
1579
|
+
scatteringTextureRadiusSize: t,
|
|
1580
|
+
scatteringTextureCosViewSize: i,
|
|
1581
|
+
scatteringTextureCosLightSize: r,
|
|
1582
|
+
scatteringTextureCosViewLightSize: n
|
|
1583
|
+
} = j(s), a = kt(
|
|
1584
|
+
e.x.div(r)
|
|
1585
|
+
), o = e.x.mod(r), u = v(
|
|
1586
|
+
n.sub(1),
|
|
1587
|
+
r,
|
|
1588
|
+
i,
|
|
1589
|
+
t
|
|
1590
|
+
), l = v(
|
|
1591
|
+
a,
|
|
1592
|
+
o,
|
|
1593
|
+
e.y,
|
|
1594
|
+
e.z
|
|
1595
|
+
).div(u), c = An(
|
|
1596
|
+
s,
|
|
1597
|
+
l
|
|
1598
|
+
).toConst(), d = c.get("radius"), h = c.get("cosView"), m = c.get("cosLight"), p = c.get("cosViewLight").toVar(), x = c.get("intersectsGround"), y = $(
|
|
1599
|
+
h.pow2().oneMinus().mul(m.pow2().oneMinus())
|
|
1600
|
+
).toConst();
|
|
1601
|
+
return p.assign(
|
|
1602
|
+
Ot(
|
|
1603
|
+
p,
|
|
1604
|
+
h.mul(m).sub(y),
|
|
1605
|
+
h.mul(m).add(y)
|
|
1606
|
+
)
|
|
1607
|
+
), ot(
|
|
1608
|
+
d,
|
|
1609
|
+
h,
|
|
1610
|
+
m,
|
|
1611
|
+
p,
|
|
1612
|
+
x
|
|
1613
|
+
);
|
|
1614
|
+
}), Vn = /* @__PURE__ */ R({
|
|
1615
|
+
name: "getExtrapolatedSingleMieScattering",
|
|
1616
|
+
type: Be,
|
|
1617
|
+
inputs: [
|
|
1618
|
+
{ name: "scattering", type: "vec4" },
|
|
1619
|
+
{ name: "rayleighScattering", type: "vec3" },
|
|
1620
|
+
{ name: "mieScattering", type: "vec3" }
|
|
1621
|
+
]
|
|
1622
|
+
})(([s, e, t]) => {
|
|
1623
|
+
const i = g(0).toVar();
|
|
1624
|
+
return I(s.r.greaterThanEqual(1e-5), () => {
|
|
1625
|
+
i.assign(
|
|
1626
|
+
s.rgb.mul(s.a).div(s.r).mul(e.r.div(t.r)).mul(t.div(e))
|
|
1627
|
+
);
|
|
1628
|
+
}), i;
|
|
1629
|
+
}), Ln = /* @__PURE__ */ Y(
|
|
1630
|
+
{
|
|
1631
|
+
scattering: Be,
|
|
1632
|
+
singleMieScattering: Be
|
|
1633
|
+
},
|
|
1634
|
+
"CombinedScattering"
|
|
1635
|
+
), tt = /* @__PURE__ */ L(
|
|
1636
|
+
(s, e, t, i, r, n, a, o) => (u) => {
|
|
1637
|
+
const l = oe(u), {
|
|
1638
|
+
rayleighScattering: c,
|
|
1639
|
+
mieScattering: d,
|
|
1640
|
+
scatteringTextureCosViewLightSize: h
|
|
1641
|
+
} = j(s), m = Hs(
|
|
1642
|
+
s,
|
|
1643
|
+
i,
|
|
1644
|
+
r,
|
|
1645
|
+
n,
|
|
1646
|
+
a,
|
|
1647
|
+
o
|
|
1648
|
+
).toConst(), p = m.x.mul(h.sub(1)).toConst(), x = kt(p).toConst(), y = p.sub(x).toConst(), T = g(
|
|
1649
|
+
x.add(m.y).div(h),
|
|
1650
|
+
m.z,
|
|
1651
|
+
m.w
|
|
1652
|
+
).toConst(), S = g(
|
|
1653
|
+
x.add(1).add(m.y).div(h),
|
|
1654
|
+
m.z,
|
|
1655
|
+
m.w
|
|
1656
|
+
).toConst(), M = g(0).toVar(), C = g(0).toVar();
|
|
1657
|
+
if (l.parameters.combinedScatteringTextures) {
|
|
1658
|
+
const N = k(
|
|
1659
|
+
e.sample(T).mul(y.oneMinus()),
|
|
1660
|
+
e.sample(S).mul(y)
|
|
1661
|
+
).toConst();
|
|
1662
|
+
M.assign(N.rgb), C.assign(
|
|
1663
|
+
Vn(
|
|
1664
|
+
N,
|
|
1665
|
+
c,
|
|
1666
|
+
d
|
|
1667
|
+
)
|
|
1668
|
+
);
|
|
1669
|
+
} else
|
|
1670
|
+
M.assign(
|
|
1671
|
+
k(
|
|
1672
|
+
e.sample(T).mul(y.oneMinus()),
|
|
1673
|
+
e.sample(S).mul(y)
|
|
1674
|
+
).rgb
|
|
1675
|
+
), C.assign(
|
|
1676
|
+
k(
|
|
1677
|
+
t.sample(T).mul(y.oneMinus()),
|
|
1678
|
+
t.sample(S).mul(y)
|
|
1679
|
+
).rgb
|
|
1680
|
+
);
|
|
1681
|
+
return Ln(M, C);
|
|
1682
|
+
}
|
|
1683
|
+
), Dn = /* @__PURE__ */ Y(
|
|
1684
|
+
{
|
|
1685
|
+
radiance: Is,
|
|
1686
|
+
transmittance: Se
|
|
1687
|
+
},
|
|
1688
|
+
"RadianceTransfer"
|
|
1689
|
+
), Pn = /* @__PURE__ */ R({
|
|
1690
|
+
name: "getSubUVFromTextureUnit",
|
|
1691
|
+
type: "vec2",
|
|
1692
|
+
inputs: [
|
|
1693
|
+
{ name: "unit", type: "vec2" },
|
|
1694
|
+
{ name: "textureSize", type: "vec2" }
|
|
1695
|
+
]
|
|
1696
|
+
})(([s, e]) => s.add(A(0.5).div(e)).mul(e.div(e.add(1)))), Zs = /* @__PURE__ */ R({
|
|
1697
|
+
name: "getTextureUnitFromSubUV",
|
|
1698
|
+
type: "vec2",
|
|
1699
|
+
inputs: [
|
|
1700
|
+
{ name: "subUV", type: "vec2" },
|
|
1701
|
+
{ name: "textureSize", type: "vec2" }
|
|
1702
|
+
]
|
|
1703
|
+
})(([s, e]) => s.sub(A(0.5).div(e)).mul(e.div(e.sub(1)))), ws = /* @__PURE__ */ Y(
|
|
1704
|
+
{
|
|
1705
|
+
rayleighScattering: ge,
|
|
1706
|
+
mieScattering: ge,
|
|
1707
|
+
scattering: ge,
|
|
1708
|
+
extinction: ge
|
|
1709
|
+
},
|
|
1710
|
+
"AtmosphereMedium"
|
|
1711
|
+
), Ks = /* @__PURE__ */ R({
|
|
1712
|
+
name: "sampleAtmosphereMedium",
|
|
1713
|
+
type: ws,
|
|
1714
|
+
inputs: [
|
|
1715
|
+
{ name: "parameters", type: q },
|
|
1716
|
+
{ name: "altitude", type: U }
|
|
1717
|
+
]
|
|
1718
|
+
})(([s, e]) => {
|
|
1719
|
+
const t = j(s), i = et(t.rayleighDensity, e), r = et(t.mieDensity, e), n = et(t.absorptionDensity, e), a = i.mul(t.rayleighScattering), o = a, u = r.mul(t.mieScattering), l = r.mul(t.mieExtinction), c = n.mul(t.absorptionExtinction), d = k(a, u), h = k(o, l, c);
|
|
1720
|
+
return ws(
|
|
1721
|
+
a,
|
|
1722
|
+
u,
|
|
1723
|
+
d,
|
|
1724
|
+
h
|
|
1725
|
+
);
|
|
1726
|
+
}), Bn = /* @__PURE__ */ Y(
|
|
1727
|
+
{
|
|
1728
|
+
multipleScattering: Is,
|
|
1729
|
+
transferFactor: Se
|
|
1730
|
+
},
|
|
1731
|
+
"MultipleScattering"
|
|
1732
|
+
), Qs = /* @__PURE__ */ L(
|
|
1733
|
+
(s, e, t, i, r, n) => {
|
|
1734
|
+
const { solarIrradiance: a, bottomRadius: o, groundAlbedo: u } = j(s), l = Ws(
|
|
1735
|
+
s,
|
|
1736
|
+
t,
|
|
1737
|
+
i
|
|
1738
|
+
).toConst(), c = Gs(
|
|
1739
|
+
s,
|
|
1740
|
+
t,
|
|
1741
|
+
i,
|
|
1742
|
+
l
|
|
1743
|
+
).toConst(), d = g(0).toVar(), h = g(0).toVar(), m = g(1).toVar(), p = A(0).toVar(), x = 20;
|
|
1744
|
+
return Pe({ type: "float", start: 0, end: x }, ({ i: y }) => {
|
|
1745
|
+
const T = c.mul(y.add(0.3)).div(x).toConst(), S = T.sub(p).toConst();
|
|
1746
|
+
p.assign(T);
|
|
1747
|
+
const M = ht(
|
|
1748
|
+
s,
|
|
1749
|
+
$(
|
|
1750
|
+
T.pow2().add(te(2, t, i, T)).add(t.pow2())
|
|
1751
|
+
)
|
|
1752
|
+
).toConst(), C = ce(
|
|
1753
|
+
t.mul(r).add(T.mul(n)).div(M)
|
|
1754
|
+
).toConst(), N = M.sub(o), f = Ks(s, N).toConst(), z = f.get("scattering"), F = f.get("extinction"), P = F.mul(S).toConst(), V = lt(P.negate()).toConst(), _ = at(
|
|
1755
|
+
e,
|
|
1756
|
+
M,
|
|
1757
|
+
C
|
|
1758
|
+
).toConst(), W = z.sub(z.mul(V)).div(F).toConst();
|
|
1759
|
+
h.addAssign(m.mul(W));
|
|
1760
|
+
const Q = _.mul(z.mul(1 / (4 * Math.PI))).toConst(), ue = Q.sub(Q.mul(V)).div(F).toConst();
|
|
1761
|
+
d.addAssign(
|
|
1762
|
+
m.mul(ue)
|
|
1763
|
+
), m.mulAssign(V);
|
|
1764
|
+
}), I(l, () => {
|
|
1765
|
+
const y = ce(
|
|
1766
|
+
t.mul(r).add(c.mul(n)).div(o)
|
|
1767
|
+
).toConst(), T = at(
|
|
1768
|
+
e,
|
|
1769
|
+
o,
|
|
1770
|
+
y
|
|
1771
|
+
).toConst();
|
|
1772
|
+
d.addAssign(
|
|
1773
|
+
a.mul(
|
|
1774
|
+
T,
|
|
1775
|
+
m,
|
|
1776
|
+
y.saturate(),
|
|
1777
|
+
u,
|
|
1778
|
+
1 / Math.PI
|
|
1779
|
+
)
|
|
1780
|
+
);
|
|
1781
|
+
}), Bn(
|
|
1782
|
+
d,
|
|
1783
|
+
h
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1786
|
+
), Un = /* @__PURE__ */ L(
|
|
1787
|
+
(s, e, t, i) => {
|
|
1788
|
+
const { topRadius: r, bottomRadius: n, multipleScatteringTextureSize: a } = j(s), o = Pn(
|
|
1789
|
+
b(
|
|
1790
|
+
i.mul(0.5).add(0.5),
|
|
1791
|
+
t.sub(n).div(r.sub(n))
|
|
1792
|
+
).saturate(),
|
|
1793
|
+
a
|
|
1794
|
+
);
|
|
1795
|
+
return e.sample(o).rgb;
|
|
1796
|
+
}
|
|
1797
|
+
), In = /* @__PURE__ */ Y(
|
|
1798
|
+
{
|
|
1799
|
+
scattering: Be,
|
|
1800
|
+
singleMieScattering: Be,
|
|
1801
|
+
higherOrderScattering: Nn
|
|
1802
|
+
},
|
|
1803
|
+
"Scattering"
|
|
1804
|
+
), Js = /* @__PURE__ */ L(
|
|
1805
|
+
(s, e, t) => (i) => {
|
|
1806
|
+
const r = oe(i), { parametersNode: n } = r, { solarIrradiance: a, bottomRadius: o } = n, u = Fn(
|
|
1807
|
+
n,
|
|
1808
|
+
t
|
|
1809
|
+
).toConst(), l = u.get("radius"), c = u.get("cosView"), d = u.get("cosLight"), h = u.get("cosViewLight"), m = u.get("intersectsGround"), p = Gs(
|
|
1810
|
+
n,
|
|
1811
|
+
l,
|
|
1812
|
+
c,
|
|
1813
|
+
m
|
|
1814
|
+
).toConst(), x = he(
|
|
1815
|
+
14,
|
|
1816
|
+
30,
|
|
1817
|
+
p.mul(1 / 100)
|
|
1818
|
+
).toConst(), y = x.floor().toConst(), T = y.reciprocal().toConst(), S = p.mul(y).div(x).toConst(), M = _t(h).toConst(), C = g(0).toVar(), N = g(0).toVar(), f = g(0).toVar(), z = g(1).toVar();
|
|
1819
|
+
return Pe({ type: "float", start: 0, end: x }, ({ i: F }) => {
|
|
1820
|
+
const P = F.mul(T).toVar(), V = F.add(1).mul(T).toVar();
|
|
1821
|
+
P.mulAssign(P), V.mulAssign(V), P.mulAssign(S), V.assign(
|
|
1822
|
+
V.greaterThan(1).select(p, S.mul(V))
|
|
1823
|
+
);
|
|
1824
|
+
const _ = V.sub(P), W = P.add(_.mul(0.3)), Q = ht(
|
|
1825
|
+
n,
|
|
1826
|
+
$(
|
|
1827
|
+
W.pow2().add(te(2, l, c, W)).add(l.pow2())
|
|
1828
|
+
)
|
|
1829
|
+
).toConst(), ue = ce(
|
|
1830
|
+
l.mul(d).add(W.mul(h)).div(Q)
|
|
1831
|
+
).toConst(), Ie = Q.sub(o), B = Ks(
|
|
1832
|
+
n,
|
|
1833
|
+
Ie
|
|
1834
|
+
).toConst(), Te = B.get("rayleighScattering"), ze = B.get("mieScattering"), me = B.get("scattering"), le = B.get("extinction"), ri = le.mul(_), Je = lt(ri.negate()).toConst(), Zt = at(
|
|
1835
|
+
s,
|
|
1836
|
+
Q,
|
|
1837
|
+
ue
|
|
1838
|
+
).toConst(), Kt = Un(
|
|
1839
|
+
n,
|
|
1840
|
+
e,
|
|
1841
|
+
Q,
|
|
1842
|
+
ue
|
|
1843
|
+
).mul(me).toConst();
|
|
1844
|
+
let Ee = Zt.mul(Te);
|
|
1845
|
+
r.parameters.higherOrderScatteringTexture || (Ee = Ee.add(Kt.div(M))), Ee = a.mul(Ee).toConst();
|
|
1846
|
+
const ni = Ee.sub(Ee.mul(Je)).div(le).toConst();
|
|
1847
|
+
C.addAssign(z.mul(ni));
|
|
1848
|
+
const Qt = a.mul(Zt.mul(ze)).toConst(), ai = Qt.sub(Qt.mul(Je)).div(le).toConst();
|
|
1849
|
+
N.addAssign(z.mul(ai));
|
|
1850
|
+
const Jt = a.mul(Kt), oi = Jt.sub(Jt.mul(Je)).div(le).toConst();
|
|
1851
|
+
f.addAssign(z.mul(oi)), z.mulAssign(Je);
|
|
1852
|
+
}), In(C, N, f);
|
|
1853
|
+
}
|
|
1854
|
+
), ft = /* @__PURE__ */ R({
|
|
1855
|
+
name: "computeOpticalDepthToTopAtmosphereBoundary",
|
|
1856
|
+
type: U,
|
|
1857
|
+
inputs: [
|
|
1858
|
+
{ name: "parameters", type: q },
|
|
1859
|
+
{ name: "profile", type: De },
|
|
1860
|
+
{ name: "radius", type: U },
|
|
1861
|
+
{ name: "cosView", type: E }
|
|
1862
|
+
]
|
|
1863
|
+
})(([s, e, t, i]) => {
|
|
1864
|
+
const { bottomRadius: r } = j(s), n = 500, a = Ue(s, t, i).div(n).toConst(), o = A(0).toVar();
|
|
1865
|
+
return Pe({ start: 0, end: n, condition: "<=" }, ({ i: u }) => {
|
|
1866
|
+
const l = A(u).mul(a).toConst(), c = $(
|
|
1867
|
+
k(l.pow2(), te(2, t, i, l), t.pow2())
|
|
1868
|
+
).toConst(), d = et(e, c.sub(r)), h = b(u).equal(b(0, n)).any().select(0.5, 1);
|
|
1869
|
+
o.addAssign(d.mul(h).mul(a));
|
|
1870
|
+
}), o;
|
|
1871
|
+
}), On = /* @__PURE__ */ R({
|
|
1872
|
+
name: "computeTransmittanceToTopAtmosphereBoundary",
|
|
1873
|
+
type: Se,
|
|
1874
|
+
inputs: [
|
|
1875
|
+
{ name: "parameters", type: q },
|
|
1876
|
+
{ name: "radius", type: U },
|
|
1877
|
+
{ name: "cosView", type: E }
|
|
1878
|
+
]
|
|
1879
|
+
})(([s, e, t]) => {
|
|
1880
|
+
const {
|
|
1881
|
+
rayleighDensity: i,
|
|
1882
|
+
rayleighScattering: r,
|
|
1883
|
+
mieDensity: n,
|
|
1884
|
+
mieExtinction: a,
|
|
1885
|
+
absorptionDensity: o,
|
|
1886
|
+
absorptionExtinction: u
|
|
1887
|
+
} = j(s), l = ft(
|
|
1888
|
+
s,
|
|
1889
|
+
i,
|
|
1890
|
+
e,
|
|
1891
|
+
t
|
|
1892
|
+
), c = ft(
|
|
1893
|
+
s,
|
|
1894
|
+
n,
|
|
1895
|
+
e,
|
|
1896
|
+
t
|
|
1897
|
+
), d = ft(
|
|
1898
|
+
s,
|
|
1899
|
+
o,
|
|
1900
|
+
e,
|
|
1901
|
+
t
|
|
1902
|
+
), h = k(
|
|
1903
|
+
r.mul(l),
|
|
1904
|
+
a.mul(c),
|
|
1905
|
+
u.mul(d)
|
|
1906
|
+
).toConst();
|
|
1907
|
+
return lt(h.negate());
|
|
1908
|
+
}), kn = /* @__PURE__ */ R({
|
|
1909
|
+
// BUG: Cannot access vector component inside struct in layout function
|
|
1910
|
+
// https://github.com/mrdoob/three.js/issues/33345
|
|
1911
|
+
typeOnly: !0,
|
|
1912
|
+
name: "getParamsFromTransmittanceTextureUV",
|
|
1913
|
+
type: "vec2",
|
|
1914
|
+
inputs: [
|
|
1915
|
+
{ name: "parameters", type: q },
|
|
1916
|
+
{ name: "uv", type: "vec2" }
|
|
1917
|
+
]
|
|
1918
|
+
})(([s, e]) => {
|
|
1919
|
+
const { topRadius: t, bottomRadius: i, transmittanceTextureSize: r } = j(s), n = ye(
|
|
1920
|
+
e.x,
|
|
1921
|
+
r.x
|
|
1922
|
+
), a = ye(
|
|
1923
|
+
e.y,
|
|
1924
|
+
r.y
|
|
1925
|
+
), o = $(t.pow2().sub(i.pow2())).toConst(), u = o.mul(a).toConst(), l = $(u.pow2().add(i.pow2())), c = t.sub(l).toConst(), d = u.add(o), h = c.add(n.mul(d.sub(c))).toConst(), m = h.equal(0).select(
|
|
1926
|
+
1,
|
|
1927
|
+
o.pow2().sub(u.pow2()).sub(h.pow2()).div(te(2, l, h))
|
|
1928
|
+
);
|
|
1929
|
+
return b(l, m);
|
|
1930
|
+
}), Xs = /* @__PURE__ */ L(
|
|
1931
|
+
(s) => (e) => {
|
|
1932
|
+
const t = oe(e), { parametersNode: i } = t, { transmittanceTextureSize: r } = i, n = kn(
|
|
1933
|
+
i,
|
|
1934
|
+
s.div(r)
|
|
1935
|
+
).toConst(), a = n.x, o = n.y;
|
|
1936
|
+
return On(
|
|
1937
|
+
i,
|
|
1938
|
+
a,
|
|
1939
|
+
o
|
|
1940
|
+
);
|
|
1941
|
+
}
|
|
1942
|
+
), $n = /* @__PURE__ */ R({
|
|
1943
|
+
// BUG: Cannot access vector component inside struct in layout function
|
|
1944
|
+
// https://github.com/mrdoob/three.js/issues/33345
|
|
1945
|
+
typeOnly: !0,
|
|
1946
|
+
name: "getParamsFromIrradianceTextureUV",
|
|
1947
|
+
type: "vec2",
|
|
1948
|
+
inputs: [
|
|
1949
|
+
{ name: "parameters", type: q },
|
|
1950
|
+
{ name: "uv", type: "vec2" }
|
|
1951
|
+
]
|
|
1952
|
+
})(([s, e]) => {
|
|
1953
|
+
const { topRadius: t, bottomRadius: i, irradianceTextureSize: r } = j(s), n = ye(
|
|
1954
|
+
e.x,
|
|
1955
|
+
r.x
|
|
1956
|
+
), a = ye(e.y, r.y), o = i.add(a.mul(t.sub(i))), u = ce(n.mul(2).sub(1));
|
|
1957
|
+
return b(o, u);
|
|
1958
|
+
}), Ys = /* @__PURE__ */ L(
|
|
1959
|
+
(s, e, t) => (i) => {
|
|
1960
|
+
const r = oe(i), { parametersNode: n } = r, { miePhaseFunctionG: a, irradianceTextureSize: o } = n, u = $n(
|
|
1961
|
+
n,
|
|
1962
|
+
t.div(o)
|
|
1963
|
+
).toConst(), l = u.x, c = u.y, d = 32, h = Math.PI / d, m = Math.PI / d, p = g(0).toVar(), x = g(
|
|
1964
|
+
$(c.pow2().oneMinus()),
|
|
1965
|
+
0,
|
|
1966
|
+
c
|
|
1967
|
+
).toConst();
|
|
1968
|
+
return Pe({ start: 0, end: d / 2, name: "j" }, ({ j: y }) => {
|
|
1969
|
+
const T = A(y).add(0.5).mul(m).toConst();
|
|
1970
|
+
Pe({ start: 0, end: d * 2 }, ({ i: S }) => {
|
|
1971
|
+
const M = A(S).add(0.5).mul(h).toConst(), C = g(
|
|
1972
|
+
ne(M).mul(ie(T)),
|
|
1973
|
+
ie(M).mul(ie(T)),
|
|
1974
|
+
ne(T)
|
|
1975
|
+
).toConst(), N = ie(T).mul(m * h), f = C.dot(x), z = tt(
|
|
1976
|
+
n,
|
|
1977
|
+
s,
|
|
1978
|
+
s,
|
|
1979
|
+
l,
|
|
1980
|
+
C.z,
|
|
1981
|
+
c,
|
|
1982
|
+
f,
|
|
1983
|
+
Ve(!1)
|
|
1984
|
+
);
|
|
1985
|
+
let F = g(0);
|
|
1986
|
+
r.parameters.higherOrderScatteringTexture && (F = _s(
|
|
1987
|
+
e,
|
|
1988
|
+
l,
|
|
1989
|
+
C.z,
|
|
1990
|
+
c,
|
|
1991
|
+
f,
|
|
1992
|
+
Ve(!1)
|
|
1993
|
+
));
|
|
1994
|
+
const P = z.get("scattering"), V = z.get(
|
|
1995
|
+
"singleMieScattering"
|
|
1996
|
+
), _ = _t(f), W = qs(a, f);
|
|
1997
|
+
p.addAssign(
|
|
1998
|
+
P.mul(_).add(V.mul(W)).add(F).mul(C.z, N)
|
|
1999
|
+
);
|
|
2000
|
+
});
|
|
2001
|
+
}), p;
|
|
2002
|
+
}
|
|
2003
|
+
);
|
|
2004
|
+
function St(s) {
|
|
2005
|
+
const e = new jt(1, 1, {
|
|
2006
|
+
depthBuffer: !1,
|
|
2007
|
+
format: be
|
|
2008
|
+
}), t = e.texture;
|
|
2009
|
+
return t.minFilter = Z, t.magFilter = Z, t.colorSpace = ct, t.generateMipmaps = !1, t.name = s, e;
|
|
2010
|
+
}
|
|
2011
|
+
function vt(s) {
|
|
2012
|
+
const e = new cr(1, 1, 1, {
|
|
2013
|
+
depthBuffer: !1,
|
|
2014
|
+
format: be
|
|
2015
|
+
}), t = e.texture;
|
|
2016
|
+
return t.minFilter = Z, t.magFilter = Z, t.colorSpace = ct, t.generateMipmaps = !1, t.name = s, e;
|
|
2017
|
+
}
|
|
2018
|
+
function Ct(s, e, t) {
|
|
2019
|
+
s.texture.type = e, s.setSize(t.x, t.y);
|
|
2020
|
+
}
|
|
2021
|
+
function Nt(s, e, t) {
|
|
2022
|
+
s.texture.type = e, s.setSize(t.x, t.y, t.z), s.texture.isArrayTexture = !1;
|
|
2023
|
+
}
|
|
2024
|
+
class jn extends ks {
|
|
2025
|
+
}
|
|
2026
|
+
class Gn extends $s {
|
|
2027
|
+
constructor() {
|
|
2028
|
+
super(), this.mesh = new We(), this.layer = w(0), this.mesh.name = "AtmosphereLUTTexturesWebGL", this.transmittanceRT = St("transmittance"), this.multipleScatteringRT = St("multipleScattering"), this.scatteringRT = vt("scattering"), this.singleMieScatteringRT = vt("singleMieScattering"), this.higherOrderScatteringRT = vt("higherOrderScattering"), this.irradianceRT = St("irradiance");
|
|
2029
|
+
}
|
|
2030
|
+
get(e) {
|
|
2031
|
+
return this[`${e}RT`].texture;
|
|
2032
|
+
}
|
|
2033
|
+
createContext() {
|
|
2034
|
+
return de(this.parameters != null), de(this.textureType != null), new jn(
|
|
2035
|
+
this.parameters,
|
|
2036
|
+
this.textureType
|
|
2037
|
+
);
|
|
2038
|
+
}
|
|
2039
|
+
renderToRenderTarget(e, t, i) {
|
|
2040
|
+
i != null && t.textures.push(...i.filter((r) => r != null)), e.setRenderTarget(t), this.mesh.render(e), t.textures.length = 1;
|
|
2041
|
+
}
|
|
2042
|
+
renderToRenderTarget3D(e, t, i, r) {
|
|
2043
|
+
r != null && t.textures.push(...r.filter((n) => n != null));
|
|
2044
|
+
for (let n = 0; n < t.depth; ++n)
|
|
2045
|
+
i.value = n, e.setRenderTarget(t, n), this.mesh.render(e);
|
|
2046
|
+
t.textures.length = 1;
|
|
2047
|
+
}
|
|
2048
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2049
|
+
createMaterial(e) {
|
|
2050
|
+
const t = new Ce();
|
|
2051
|
+
return t.fragmentNode = e, t.needsUpdate = !0, t;
|
|
2052
|
+
}
|
|
2053
|
+
computeTransmittance(e, t) {
|
|
2054
|
+
this.transmittanceMaterial?.dispose(), this.transmittanceMaterial = this.createMaterial(
|
|
2055
|
+
// BUG: Context is not merged unless we wrap the node by OutputStructNode.
|
|
2056
|
+
Xe({
|
|
2057
|
+
transmittance: Xs(Ae).context({
|
|
2058
|
+
getAtmosphere: () => t
|
|
2059
|
+
})
|
|
2060
|
+
})
|
|
2061
|
+
), this.mesh.material = this.transmittanceMaterial, this.renderToRenderTarget(e, this.transmittanceRT);
|
|
2062
|
+
}
|
|
2063
|
+
computeMultipleScattering(e, t) {
|
|
2064
|
+
const { parameters: i, parametersNode: r } = t, n = 64, a = L((u) => {
|
|
2065
|
+
const l = A(u), c = l.mul(2 * Math.PI / ((1 + Math.sqrt(5)) / 2)), d = Es(
|
|
2066
|
+
l.add(0.5).mul(2 / n).oneMinus()
|
|
2067
|
+
), h = ne(d), m = ie(d), p = ne(c), x = ie(c);
|
|
2068
|
+
return g(p.mul(m), x.mul(m), h);
|
|
2069
|
+
}), o = O(() => {
|
|
2070
|
+
const u = b(i.multipleScatteringTextureSize), l = Zs(
|
|
2071
|
+
Ae.div(u),
|
|
2072
|
+
u
|
|
2073
|
+
).toConst(), { topRadius: c, bottomRadius: d } = r, h = l.x.mul(2).sub(1).toConst(), m = g(
|
|
2074
|
+
0,
|
|
2075
|
+
$(h.pow2().oneMinus().saturate()),
|
|
2076
|
+
h
|
|
2077
|
+
).toConst(), p = 0, x = d.add(
|
|
2078
|
+
l.y.add(p).saturate().mul(c.sub(d).sub(p))
|
|
2079
|
+
).toConst(), y = g(0).toVar(), T = g(0).toVar();
|
|
2080
|
+
return Pe({ start: 0, end: n }, ({ i: S }) => {
|
|
2081
|
+
const M = a(S).toConst(), C = M.z, N = M.dot(m).toConst(), f = Qs(
|
|
2082
|
+
r,
|
|
2083
|
+
X(this.transmittanceRT.texture),
|
|
2084
|
+
x,
|
|
2085
|
+
C,
|
|
2086
|
+
h,
|
|
2087
|
+
N
|
|
2088
|
+
).context({ getAtmosphere: () => t }).toConst();
|
|
2089
|
+
y.addAssign(
|
|
2090
|
+
f.get("multipleScattering").div(n)
|
|
2091
|
+
), T.addAssign(
|
|
2092
|
+
f.get("transferFactor").div(n)
|
|
2093
|
+
);
|
|
2094
|
+
}), y.mul(
|
|
2095
|
+
T.oneMinus().reciprocal()
|
|
2096
|
+
);
|
|
2097
|
+
});
|
|
2098
|
+
this.multipleScatteringMaterial?.dispose(), this.multipleScatteringMaterial = this.createMaterial(
|
|
2099
|
+
// BUG: Context is not merged unless we wrap the node by
|
|
2100
|
+
// OutputStructNode.
|
|
2101
|
+
Xe({
|
|
2102
|
+
multipleScattering: v(o(), 1)
|
|
2103
|
+
})
|
|
2104
|
+
), this.mesh.material = this.multipleScatteringMaterial, this.renderToRenderTarget(e, this.multipleScatteringRT);
|
|
2105
|
+
}
|
|
2106
|
+
computeScattering(e, t) {
|
|
2107
|
+
const { parameters: i } = t;
|
|
2108
|
+
this.scatteringMaterial?.dispose(), this.scatteringMaterial = this.createMaterial(
|
|
2109
|
+
(() => {
|
|
2110
|
+
const n = Js(
|
|
2111
|
+
X(this.transmittanceRT.texture),
|
|
2112
|
+
X(this.multipleScatteringRT.texture),
|
|
2113
|
+
g(Ae, this.layer.add(0.5))
|
|
2114
|
+
).context({ getAtmosphere: () => t }).toConst(), a = n.get("scattering"), o = n.get("singleMieScattering"), u = n.get("higherOrderScattering"), l = {};
|
|
2115
|
+
return i.combinedScatteringTextures ? l.scattering = v(a, o.r) : (l.scattering = v(a, o.r), l.singleMieScattering = v(o, 1)), i.higherOrderScatteringTexture && (l.higherOrderScattering = v(u, 1)), Xe(l);
|
|
2116
|
+
})()
|
|
2117
|
+
), this.mesh.material = this.scatteringMaterial;
|
|
2118
|
+
const r = [];
|
|
2119
|
+
i.combinedScatteringTextures || r.push(this.singleMieScatteringRT.texture), i.higherOrderScatteringTexture && r.push(this.higherOrderScatteringRT.texture), this.renderToRenderTarget3D(
|
|
2120
|
+
e,
|
|
2121
|
+
this.scatteringRT,
|
|
2122
|
+
this.layer,
|
|
2123
|
+
r
|
|
2124
|
+
);
|
|
2125
|
+
}
|
|
2126
|
+
computeIrradiance(e, t) {
|
|
2127
|
+
this.irradianceMaterial?.dispose(), this.irradianceMaterial = this.createMaterial(
|
|
2128
|
+
// BUG: Context is not merged unless we wrap the node by OutputStructNode.
|
|
2129
|
+
Xe({
|
|
2130
|
+
irradiance: Ys(
|
|
2131
|
+
it(this.scatteringRT.texture),
|
|
2132
|
+
it(this.higherOrderScatteringRT.texture),
|
|
2133
|
+
Ae
|
|
2134
|
+
).context({ getAtmosphere: () => t })
|
|
2135
|
+
})
|
|
2136
|
+
), this.mesh.material = this.irradianceMaterial, this.renderToRenderTarget(e, this.irradianceRT);
|
|
2137
|
+
}
|
|
2138
|
+
setup(e, t) {
|
|
2139
|
+
Ct(
|
|
2140
|
+
this.transmittanceRT,
|
|
2141
|
+
t,
|
|
2142
|
+
e.transmittanceTextureSize
|
|
2143
|
+
), Ct(
|
|
2144
|
+
this.multipleScatteringRT,
|
|
2145
|
+
t,
|
|
2146
|
+
e.multipleScatteringTextureSize
|
|
2147
|
+
), Nt(
|
|
2148
|
+
this.scatteringRT,
|
|
2149
|
+
t,
|
|
2150
|
+
e.scatteringTextureSize
|
|
2151
|
+
), e.combinedScatteringTextures || Nt(
|
|
2152
|
+
this.singleMieScatteringRT,
|
|
2153
|
+
t,
|
|
2154
|
+
e.scatteringTextureSize
|
|
2155
|
+
), e.higherOrderScatteringTexture && Nt(
|
|
2156
|
+
this.higherOrderScatteringRT,
|
|
2157
|
+
t,
|
|
2158
|
+
e.scatteringTextureSize
|
|
2159
|
+
), Ct(
|
|
2160
|
+
this.irradianceRT,
|
|
2161
|
+
t,
|
|
2162
|
+
e.irradianceTextureSize
|
|
2163
|
+
), super.setup(e, t);
|
|
2164
|
+
}
|
|
2165
|
+
dispose() {
|
|
2166
|
+
this.transmittanceRT.dispose(), this.multipleScatteringRT.dispose(), this.scatteringRT.dispose(), this.irradianceRT.dispose(), this.transmittanceMaterial?.dispose(), this.multipleScatteringMaterial?.dispose(), this.scatteringMaterial?.dispose(), this.irradianceMaterial?.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
function Mt(s) {
|
|
2170
|
+
const e = new gi(1, 1);
|
|
2171
|
+
return e.minFilter = Z, e.magFilter = Z, e.colorSpace = ct, e.generateMipmaps = !1, e.name = s, e;
|
|
2172
|
+
}
|
|
2173
|
+
function Rt(s) {
|
|
2174
|
+
const e = new xi(1, 1, 1);
|
|
2175
|
+
return e.minFilter = Z, e.magFilter = Z, e.colorSpace = ct, e.generateMipmaps = !1, e.name = s, e;
|
|
2176
|
+
}
|
|
2177
|
+
function bt(s, e, t) {
|
|
2178
|
+
s.type = e, Wt(s.image), s.image.width = t.x, s.image.height = t.y;
|
|
2179
|
+
}
|
|
2180
|
+
function zt(s, e, t) {
|
|
2181
|
+
s.type = e, Wt(s.image), s.image.width = t.x, s.image.height = t.y, s.image.depth = t.z;
|
|
2182
|
+
}
|
|
2183
|
+
class Wn extends ks {
|
|
2184
|
+
}
|
|
2185
|
+
class qn extends $s {
|
|
2186
|
+
constructor() {
|
|
2187
|
+
super(), this.transmittance = Mt("transmittance"), this.multipleScattering = Mt("multipleScattering"), this.scattering = Rt("scattering"), this.singleMieScattering = Rt("singleMieScattering"), this.higherOrderScattering = Rt("higherOrderScattering"), this.irradiance = Mt("irradiance");
|
|
2188
|
+
}
|
|
2189
|
+
get(e) {
|
|
2190
|
+
return this[e];
|
|
2191
|
+
}
|
|
2192
|
+
createContext() {
|
|
2193
|
+
return de(this.parameters != null), de(this.textureType != null), new Wn(
|
|
2194
|
+
this.parameters,
|
|
2195
|
+
this.textureType
|
|
2196
|
+
);
|
|
2197
|
+
}
|
|
2198
|
+
computeTransmittance(e, t) {
|
|
2199
|
+
const { parameters: i } = t, { x: r, y: n } = i.transmittanceTextureSize;
|
|
2200
|
+
this.transmittanceNode?.dispose(), this.transmittanceNode = O(() => {
|
|
2201
|
+
const a = st(r, n);
|
|
2202
|
+
I(G.xy.greaterThanEqual(a).any(), () => {
|
|
2203
|
+
Oe();
|
|
2204
|
+
});
|
|
2205
|
+
const o = Xs(
|
|
2206
|
+
b(G.xy).add(0.5)
|
|
2207
|
+
);
|
|
2208
|
+
we(this.transmittance, G.xy, o);
|
|
2209
|
+
})().context({ getAtmosphere: () => t }).computeKernel([8, 8, 1]).setName("transmittance"), e.compute(this.transmittanceNode, [
|
|
2210
|
+
Math.ceil(r / 8),
|
|
2211
|
+
Math.ceil(n / 8),
|
|
2212
|
+
1
|
|
2213
|
+
]);
|
|
2214
|
+
}
|
|
2215
|
+
computeMultipleScattering(e, t) {
|
|
2216
|
+
const { parameters: i, parametersNode: r } = t, { x: n, y: a } = i.multipleScatteringTextureSize, o = 64, u = L((l) => {
|
|
2217
|
+
const c = A(l), d = c.mul(2 * Math.PI / ((1 + Math.sqrt(5)) / 2)), h = Es(
|
|
2218
|
+
c.add(0.5).mul(2 / o).oneMinus()
|
|
2219
|
+
), m = ne(h), p = ie(h), x = ne(d), y = ie(d);
|
|
2220
|
+
return g(x.mul(p), y.mul(p), m);
|
|
2221
|
+
});
|
|
2222
|
+
this.multipleScatteringNode?.dispose(), this.multipleScatteringNode = O(() => {
|
|
2223
|
+
const l = ts("vec3", o), c = ts("vec3", o), d = b(n, a).toConst(), h = b(G.xy).add(0.5), m = Zs(h.div(d), d).toConst(), p = G.z, { topRadius: x, bottomRadius: y } = r, T = m.x.mul(2).sub(1).toConst(), S = g(
|
|
2224
|
+
0,
|
|
2225
|
+
$(T.pow2().oneMinus().saturate()),
|
|
2226
|
+
T
|
|
2227
|
+
).toConst(), M = 0, C = y.add(
|
|
2228
|
+
m.y.add(M).saturate().mul(x.sub(y).sub(M))
|
|
2229
|
+
).toConst(), N = u(p).toConst(), f = N.z, z = N.dot(S).toConst(), F = Qs(
|
|
2230
|
+
r,
|
|
2231
|
+
X(this.transmittance),
|
|
2232
|
+
C,
|
|
2233
|
+
f,
|
|
2234
|
+
T,
|
|
2235
|
+
z
|
|
2236
|
+
).toConst();
|
|
2237
|
+
l.element(p).assign(F.get("multipleScattering").div(o)), c.element(p).assign(F.get("transferFactor").div(o)), ss();
|
|
2238
|
+
for (let _ = o >> 1; _ > 0; _ >>>= 1) {
|
|
2239
|
+
const W = fe(_);
|
|
2240
|
+
I(p.lessThan(W), () => {
|
|
2241
|
+
l.element(p).addAssign(l.element(p.add(W))), c.element(p).addAssign(c.element(p.add(W)));
|
|
2242
|
+
}), ss();
|
|
2243
|
+
}
|
|
2244
|
+
I(p.greaterThan(0), () => {
|
|
2245
|
+
Oe();
|
|
2246
|
+
});
|
|
2247
|
+
const P = l.element(fe(0)), V = c.element(fe(0));
|
|
2248
|
+
we(
|
|
2249
|
+
this.multipleScattering,
|
|
2250
|
+
G.xy,
|
|
2251
|
+
// This represents the amount of radiance scattered as if the integral
|
|
2252
|
+
// of scattered radiance over the sphere would be 1.
|
|
2253
|
+
// For a power-series, such integral is analytically:
|
|
2254
|
+
// sum_{n=0}^{n=+inf} = 1 + r + r^2 + r^3 + ... + r^n = 1 / (1 - r)
|
|
2255
|
+
v(P.mul(V.oneMinus().reciprocal()), 1)
|
|
2256
|
+
);
|
|
2257
|
+
})().context({ getAtmosphere: () => t }).computeKernel([1, 1, o]).setName("multipleScattering"), e.compute(this.multipleScatteringNode, [n, a, 1]);
|
|
2258
|
+
}
|
|
2259
|
+
computeScattering(e, t) {
|
|
2260
|
+
const { parameters: i } = t, { x: r, y: n, z: a } = i.scatteringTextureSize;
|
|
2261
|
+
this.scatteringNode?.dispose(), this.scatteringNode = O(() => {
|
|
2262
|
+
const o = Hi(r, n, a);
|
|
2263
|
+
I(G.greaterThanEqual(o).any(), () => {
|
|
2264
|
+
Oe();
|
|
2265
|
+
});
|
|
2266
|
+
const u = Js(
|
|
2267
|
+
X(this.transmittance),
|
|
2268
|
+
X(this.multipleScattering),
|
|
2269
|
+
g(G).add(0.5)
|
|
2270
|
+
).toConst(), l = u.get("scattering"), c = u.get("singleMieScattering");
|
|
2271
|
+
if (i.combinedScatteringTextures ? we(
|
|
2272
|
+
this.scattering,
|
|
2273
|
+
G,
|
|
2274
|
+
v(l, c.r)
|
|
2275
|
+
) : (we(this.scattering, G, v(l, 1)), we(
|
|
2276
|
+
this.singleMieScattering,
|
|
2277
|
+
G,
|
|
2278
|
+
v(c, 1)
|
|
2279
|
+
)), i.higherOrderScatteringTexture) {
|
|
2280
|
+
const d = u.get("higherOrderScattering");
|
|
2281
|
+
we(
|
|
2282
|
+
this.higherOrderScattering,
|
|
2283
|
+
G,
|
|
2284
|
+
v(d, 1)
|
|
2285
|
+
);
|
|
2286
|
+
}
|
|
2287
|
+
})().context({ getAtmosphere: () => t }).computeKernel([4, 4, 4]).setName("scattering"), e.compute(this.scatteringNode, [
|
|
2288
|
+
Math.ceil(r / 4),
|
|
2289
|
+
Math.ceil(n / 4),
|
|
2290
|
+
Math.ceil(a / 4)
|
|
2291
|
+
]);
|
|
2292
|
+
}
|
|
2293
|
+
computeIrradiance(e, t) {
|
|
2294
|
+
const { parameters: i } = t, { x: r, y: n } = i.irradianceTextureSize;
|
|
2295
|
+
this.irradianceNode?.dispose(), this.irradianceNode = O(() => {
|
|
2296
|
+
const a = st(r, n);
|
|
2297
|
+
I(G.xy.greaterThanEqual(a).any(), () => {
|
|
2298
|
+
Oe();
|
|
2299
|
+
});
|
|
2300
|
+
const o = Ys(
|
|
2301
|
+
it(this.scattering),
|
|
2302
|
+
it(this.higherOrderScattering),
|
|
2303
|
+
b(G.xy).add(0.5)
|
|
2304
|
+
);
|
|
2305
|
+
we(this.irradiance, G.xy, o);
|
|
2306
|
+
})().context({ getAtmosphere: () => t }).computeKernel([8, 8, 1]).setName("irradiance"), e.compute(this.irradianceNode, [
|
|
2307
|
+
Math.ceil(r / 8),
|
|
2308
|
+
Math.ceil(n / 8),
|
|
2309
|
+
1
|
|
2310
|
+
]);
|
|
2311
|
+
}
|
|
2312
|
+
setup(e, t) {
|
|
2313
|
+
bt(
|
|
2314
|
+
this.transmittance,
|
|
2315
|
+
t,
|
|
2316
|
+
e.transmittanceTextureSize
|
|
2317
|
+
), bt(
|
|
2318
|
+
this.multipleScattering,
|
|
2319
|
+
t,
|
|
2320
|
+
e.multipleScatteringTextureSize
|
|
2321
|
+
), zt(
|
|
2322
|
+
this.scattering,
|
|
2323
|
+
t,
|
|
2324
|
+
e.scatteringTextureSize
|
|
2325
|
+
), e.combinedScatteringTextures || zt(
|
|
2326
|
+
this.singleMieScattering,
|
|
2327
|
+
t,
|
|
2328
|
+
e.scatteringTextureSize
|
|
2329
|
+
), e.higherOrderScatteringTexture && zt(
|
|
2330
|
+
this.higherOrderScattering,
|
|
2331
|
+
t,
|
|
2332
|
+
e.scatteringTextureSize
|
|
2333
|
+
), bt(
|
|
2334
|
+
this.irradiance,
|
|
2335
|
+
t,
|
|
2336
|
+
e.irradianceTextureSize
|
|
2337
|
+
), super.setup(e, t);
|
|
2338
|
+
}
|
|
2339
|
+
dispose() {
|
|
2340
|
+
this.transmittance.dispose(), this.multipleScattering.dispose(), this.scattering.dispose(), this.singleMieScattering.dispose(), this.higherOrderScattering.dispose(), this.irradiance.dispose(), this.transmittanceNode?.dispose(), this.multipleScatteringNode?.dispose(), this.scatteringNode?.dispose(), this.irradianceNode?.dispose(), super.dispose();
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
class pe {
|
|
2344
|
+
constructor(e = 0, t = 0, i = 0, r = 0, n = 0) {
|
|
2345
|
+
this.width = e, this.expTerm = t, this.expScale = i, this.linearTerm = r, this.constantTerm = n;
|
|
2346
|
+
}
|
|
2347
|
+
copy(e) {
|
|
2348
|
+
return this.width = e.width, this.expTerm = e.expTerm, this.expScale = e.expScale, this.linearTerm = e.linearTerm, this.constantTerm = e.constantTerm, this;
|
|
2349
|
+
}
|
|
2350
|
+
clone() {
|
|
2351
|
+
return new pe().copy(this);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
class ke {
|
|
2355
|
+
constructor(e) {
|
|
2356
|
+
this.layers = e;
|
|
2357
|
+
}
|
|
2358
|
+
copy(e) {
|
|
2359
|
+
return this.layers = [e.layers[0].clone(), e.layers[1].clone()], this;
|
|
2360
|
+
}
|
|
2361
|
+
clone() {
|
|
2362
|
+
return new ke([this.layers[0].clone(), this.layers[1].clone()]);
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
const Hn = /* @__PURE__ */ new H(0.2126, 0.7152, 0.0722);
|
|
2366
|
+
class Qe {
|
|
2367
|
+
constructor() {
|
|
2368
|
+
this.worldToUnit = 1e-3, this.solarIrradiance = new H(1.474, 1.8504, 1.91198), this.sunAngularRadius = 4675e-6, this.bottomRadius = 636e4, this.topRadius = 642e4, this.rayleighDensity = new ke([
|
|
2369
|
+
new pe(),
|
|
2370
|
+
new pe(0, 1, -1 / 8e3)
|
|
2371
|
+
]), this.rayleighScattering = new H(5802e-9, 13558e-9, 331e-7), this.mieDensity = new ke([
|
|
2372
|
+
new pe(),
|
|
2373
|
+
new pe(0, 1, -1 / 1200)
|
|
2374
|
+
]), this.mieScattering = new H().setScalar(3996e-9), this.mieExtinction = new H().setScalar(444e-8), this.miePhaseFunctionG = 0.8, this.absorptionDensity = new ke([
|
|
2375
|
+
new pe(25e3, 0, 0, 1 / 15e3, -2 / 3),
|
|
2376
|
+
new pe(0, 0, 0, -1 / 15e3, 8 / 3)
|
|
2377
|
+
]), this.absorptionExtinction = new H(65e-8, 1881e-9, 85e-9), this.groundAlbedo = new H().setScalar(0.3), this.minCosLight = Math.cos(rt(120)), this.sunRadianceToLuminance = new H(98242.786222, 69954.398112, 66475.012354), this.skyRadianceToLuminance = new H(114974.91644, 71305.954816, 65310.548555), this.luminanceScale = 1 / Hn.dot(this.sunRadianceToLuminance), this.combinedScatteringTextures = !0, this.higherOrderScatteringTexture = !0, this.transmittanceTextureSize = new re(256, 64), this.irradianceTextureSize = new re(64, 16), this.multipleScatteringTextureSize = new re(64, 64), this.scatteringTextureRadiusSize = 32, this.scatteringTextureCosViewSize = 128, this.scatteringTextureCosLightSize = 32, this.scatteringTextureCosViewLightSize = 8, this.scatteringTextureSize = new H(), this.update();
|
|
2378
|
+
}
|
|
2379
|
+
copy(e) {
|
|
2380
|
+
return this.worldToUnit = e.worldToUnit, this.solarIrradiance.copy(e.solarIrradiance), this.sunAngularRadius = e.sunAngularRadius, this.bottomRadius = e.bottomRadius, this.topRadius = e.topRadius, this.rayleighDensity.copy(e.rayleighDensity), this.rayleighScattering.copy(e.rayleighScattering), this.mieDensity.copy(e.mieDensity), this.mieScattering.copy(e.mieScattering), this.mieExtinction.copy(e.mieExtinction), this.miePhaseFunctionG = e.miePhaseFunctionG, this.absorptionDensity.copy(e.absorptionDensity), this.absorptionExtinction.copy(e.absorptionExtinction), this.groundAlbedo.copy(e.groundAlbedo), this.minCosLight = e.minCosLight, this.sunRadianceToLuminance.copy(e.sunRadianceToLuminance), this.skyRadianceToLuminance.copy(e.skyRadianceToLuminance), this.luminanceScale = e.luminanceScale, this.combinedScatteringTextures = e.combinedScatteringTextures, this.transmittanceTextureSize.copy(e.transmittanceTextureSize), this.irradianceTextureSize.copy(e.irradianceTextureSize), this.multipleScatteringTextureSize.copy(e.multipleScatteringTextureSize), this.scatteringTextureRadiusSize = e.scatteringTextureRadiusSize, this.scatteringTextureCosViewSize = e.scatteringTextureCosViewSize, this.scatteringTextureCosLightSize = e.scatteringTextureCosLightSize, this.scatteringTextureCosViewLightSize = e.scatteringTextureCosViewLightSize, this.scatteringTextureSize.copy(e.scatteringTextureSize), this;
|
|
2381
|
+
}
|
|
2382
|
+
update() {
|
|
2383
|
+
return this.scatteringTextureSize.set(
|
|
2384
|
+
this.scatteringTextureCosViewLightSize * this.scatteringTextureCosLightSize,
|
|
2385
|
+
this.scatteringTextureCosViewSize,
|
|
2386
|
+
this.scatteringTextureRadiusSize
|
|
2387
|
+
), this;
|
|
2388
|
+
}
|
|
2389
|
+
clone() {
|
|
2390
|
+
return new Qe().copy(this);
|
|
2391
|
+
}
|
|
2392
|
+
/** @deprecated Use minCosLight */
|
|
2393
|
+
get minCosSun() {
|
|
2394
|
+
return this.minCosLight;
|
|
2395
|
+
}
|
|
2396
|
+
/** @deprecated Use minCosLight */
|
|
2397
|
+
set minCosSun(e) {
|
|
2398
|
+
this.minCosLight = e;
|
|
2399
|
+
}
|
|
2400
|
+
/** @deprecated Use scatteringTextureCosLightSize */
|
|
2401
|
+
get scatteringTextureCosSunSize() {
|
|
2402
|
+
return this.scatteringTextureCosLightSize;
|
|
2403
|
+
}
|
|
2404
|
+
/** @deprecated Use scatteringTextureCosLightSize */
|
|
2405
|
+
set scatteringTextureCosSunSize(e) {
|
|
2406
|
+
this.scatteringTextureCosLightSize = e;
|
|
2407
|
+
}
|
|
2408
|
+
/** @deprecated Use scatteringTextureCosViewLightSize */
|
|
2409
|
+
get scatteringTextureCosViewSunSize() {
|
|
2410
|
+
return this.scatteringTextureCosViewLightSize;
|
|
2411
|
+
}
|
|
2412
|
+
/** @deprecated Use scatteringTextureCosViewLightSize */
|
|
2413
|
+
set scatteringTextureCosViewSunSize(e) {
|
|
2414
|
+
this.scatteringTextureCosViewLightSize = e;
|
|
2415
|
+
}
|
|
2416
|
+
/** @deprecated This option was removed. */
|
|
2417
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2418
|
+
get transmittancePrecisionLog() {
|
|
2419
|
+
return !1;
|
|
2420
|
+
}
|
|
2421
|
+
/** @deprecated This option was removed. */
|
|
2422
|
+
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2423
|
+
set transmittancePrecisionLog(e) {
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
const { resetRendererState: _n, restoreRendererState: Zn } = K;
|
|
2427
|
+
async function Kn(s) {
|
|
2428
|
+
const e = s[Symbol.iterator]();
|
|
2429
|
+
return await new Promise((t, i) => {
|
|
2430
|
+
const r = () => {
|
|
2431
|
+
try {
|
|
2432
|
+
const { value: n, done: a } = e.next();
|
|
2433
|
+
a === !0 ? t(n) : ps(r);
|
|
2434
|
+
} catch (n) {
|
|
2435
|
+
i(n instanceof Error ? n : new Error());
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
ps(r);
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
let Et;
|
|
2442
|
+
function Ye(s, e) {
|
|
2443
|
+
return Et = _n(s, Et), s.setClearColor(0, 0), s.autoClear = !1, e(), Zn(s, Et), !0;
|
|
2444
|
+
}
|
|
2445
|
+
const At = /* @__PURE__ */ new xr(), Ft = /* @__PURE__ */ (() => {
|
|
2446
|
+
const s = new yr(new Uint8Array(4));
|
|
2447
|
+
return s.format = be, s.needsUpdate = !0, s;
|
|
2448
|
+
})(), Qn = { type: "update" };
|
|
2449
|
+
class Jn extends pi {
|
|
2450
|
+
constructor(e = new Qe(), t) {
|
|
2451
|
+
super(null), this.textureNodes = {
|
|
2452
|
+
transmittance: Le(this, At),
|
|
2453
|
+
multipleScattering: Le(this, At),
|
|
2454
|
+
scattering: yt(this, Ft),
|
|
2455
|
+
singleMieScattering: yt(this, Ft),
|
|
2456
|
+
higherOrderScattering: yt(this, Ft),
|
|
2457
|
+
irradiance: Le(this, At)
|
|
2458
|
+
}, this.updating = !1, this.updateBeforeType = ee.FRAME, this.parameters = e, this.textureType = t;
|
|
2459
|
+
}
|
|
2460
|
+
static get type() {
|
|
2461
|
+
return "AtmosphereLUTNode";
|
|
2462
|
+
}
|
|
2463
|
+
getTextureNode(e) {
|
|
2464
|
+
return this.textureNodes[e];
|
|
2465
|
+
}
|
|
2466
|
+
dispatchUpdate() {
|
|
2467
|
+
this.dispatchEvent(
|
|
2468
|
+
// @ts-expect-error Cannot specify the events map
|
|
2469
|
+
Qn
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
*performCompute(e, t) {
|
|
2473
|
+
const { textures: i } = this;
|
|
2474
|
+
de(i != null), yield Ye(e, () => {
|
|
2475
|
+
i.computeTransmittance(e, t), this.dispatchUpdate();
|
|
2476
|
+
}), yield Ye(e, () => {
|
|
2477
|
+
i.computeMultipleScattering(e, t), this.dispatchUpdate();
|
|
2478
|
+
}), yield Ye(e, () => {
|
|
2479
|
+
i.computeScattering(e, t), this.dispatchUpdate();
|
|
2480
|
+
}), yield Ye(e, () => {
|
|
2481
|
+
i.computeIrradiance(e, t), this.dispatchUpdate();
|
|
2482
|
+
});
|
|
2483
|
+
}
|
|
2484
|
+
async updateTextures(e) {
|
|
2485
|
+
de(this.textures != null);
|
|
2486
|
+
const t = this.textures.createContext();
|
|
2487
|
+
this.updating = !0;
|
|
2488
|
+
try {
|
|
2489
|
+
await Kn(this.performCompute(e, t));
|
|
2490
|
+
} finally {
|
|
2491
|
+
this.updating = !1, t.dispose(), this.disposeQueue?.();
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
updateBefore({ renderer: e }) {
|
|
2495
|
+
e == null || this.version === this.currentVersion || (this.currentVersion = this.version, this.updateTextures(e).catch((t) => {
|
|
2496
|
+
throw t instanceof Error ? t : new Error();
|
|
2497
|
+
}));
|
|
2498
|
+
}
|
|
2499
|
+
setup(e) {
|
|
2500
|
+
if (this.textures == null) {
|
|
2501
|
+
this.textures = qt(e) ? new qn() : new Gn();
|
|
2502
|
+
const {
|
|
2503
|
+
transmittance: i,
|
|
2504
|
+
irradiance: r,
|
|
2505
|
+
multipleScattering: n,
|
|
2506
|
+
scattering: a,
|
|
2507
|
+
singleMieScattering: o,
|
|
2508
|
+
higherOrderScattering: u
|
|
2509
|
+
} = this.textureNodes;
|
|
2510
|
+
i.value = this.textures.get("transmittance"), n.value = this.textures.get("multipleScattering"), a.value = this.textures.get("scattering"), o.value = this.textures.get("singleMieScattering"), u.value = this.textures.get("higherOrderScattering"), r.value = this.textures.get("irradiance");
|
|
2511
|
+
}
|
|
2512
|
+
const t = Sr(e.renderer) ? this.textureType ?? lr : Ze;
|
|
2513
|
+
return this.parameters.update(), this.textures.setup(this.parameters, t), super.setup(e);
|
|
2514
|
+
}
|
|
2515
|
+
dispose() {
|
|
2516
|
+
if (this.updating) {
|
|
2517
|
+
this.disposeQueue = () => {
|
|
2518
|
+
this.dispose(), this.disposeQueue = void 0;
|
|
2519
|
+
};
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
this.textures?.dispose(), this.textures = void 0, super.dispose();
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
const Xn = /* @__PURE__ */ new H(), Yn = /* @__PURE__ */ new Ps();
|
|
2526
|
+
class ei extends Ht {
|
|
2527
|
+
constructor(e = new Qe(), t = new Jn(e)) {
|
|
2528
|
+
super(e), this.matrixWorldToECEF = w("mat4").setName("matrixWorldToECEF"), this.matrixECIToECEF = w("mat4").setName("matrixECIToECEF"), this.sunDirectionECEF = w("vec3").setName("sunDirectionECEF"), this.moonDirectionECEF = w("vec3").setName("moonDirectionECEF"), this.matrixMoonFixedToECEF = w("mat4").setName("matrixMoonFixedToECEF"), this.scatteringSampleCount = w(new re(4, 14)), this.matrixECEFToWorld = w("mat4").setName("matrixECEFToWorld").onRenderUpdate((i, { value: r }) => {
|
|
2529
|
+
r.copy(this.matrixWorldToECEF.value).transpose();
|
|
2530
|
+
}), this.cameraPositionECEF = w("vec3").setName("cameraPositionECEF").onRenderUpdate((i, { value: r }) => {
|
|
2531
|
+
const n = this.camera ?? i.camera;
|
|
2532
|
+
n != null && r.setFromMatrixPosition(n.matrixWorld).applyMatrix4(this.matrixWorldToECEF.value);
|
|
2533
|
+
}), this.altitudeCorrectionECEF = w("vec3").setName("altitudeCorrectionECEF").onRenderUpdate((i, { value: r }) => {
|
|
2534
|
+
const n = this.camera ?? i.camera;
|
|
2535
|
+
n != null && fn(
|
|
2536
|
+
r.setFromMatrixPosition(n.matrixWorld).applyMatrix4(this.matrixWorldToECEF.value),
|
|
2537
|
+
this.parameters.bottomRadius,
|
|
2538
|
+
this.ellipsoid,
|
|
2539
|
+
r
|
|
2540
|
+
);
|
|
2541
|
+
}), this.cameraHeight = w(0).setName("cameraHeight").onRenderUpdate((i, r) => {
|
|
2542
|
+
const n = this.camera ?? i.camera;
|
|
2543
|
+
if (n == null)
|
|
2544
|
+
return;
|
|
2545
|
+
const a = Xn.setFromMatrixPosition(n.matrixWorld).applyMatrix4(this.matrixWorldToECEF.value);
|
|
2546
|
+
r.value = Yn.setFromECEF(a).height;
|
|
2547
|
+
}), this.cameraPositionUnit = this.cameraPositionECEF.mul(this.parametersNode.worldToUnit).toConst("cameraPositionUnit"), this.altitudeCorrectionUnit = this.altitudeCorrectionECEF.mul(this.parametersNode.worldToUnit).toConst("altitudeCorrectionUnit"), this.ellipsoid = Bs.WGS84, this.correctAltitude = !0, this.constrainCamera = !0, this.showGround = !0, this.accurateShadowScattering = !0, this.raymarchScattering = !0, this.lutNode = t;
|
|
2548
|
+
}
|
|
2549
|
+
dispose() {
|
|
2550
|
+
this.lutNode.dispose(), super.dispose();
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
function ae(s) {
|
|
2554
|
+
if (typeof s.context.getAtmosphere != "function")
|
|
2555
|
+
throw new Error("getAtmosphere() was not found in the builder context.");
|
|
2556
|
+
const e = s.context.getAtmosphere();
|
|
2557
|
+
if (!(e instanceof ei))
|
|
2558
|
+
throw new Error(
|
|
2559
|
+
"getAtmosphere() must return an instanceof AtmosphereContext."
|
|
2560
|
+
);
|
|
2561
|
+
return e;
|
|
2562
|
+
}
|
|
2563
|
+
O((s) => {
|
|
2564
|
+
const { parametersNode: e } = ae(s), { worldToUnit: t } = e;
|
|
2565
|
+
return Cs.z.mul(t);
|
|
2566
|
+
}).once()().toVar("viewZUnit");
|
|
2567
|
+
const ea = (s, e, t, i, r, n) => {
|
|
2568
|
+
const a = ht(
|
|
2569
|
+
s,
|
|
2570
|
+
$(
|
|
2571
|
+
n.pow2().add(te(2, e, t, n)).add(e.pow2())
|
|
2572
|
+
)
|
|
2573
|
+
).toConst(), o = e.mul(t).add(n).div(a).toConst(), u = e.mul(i).add(n.mul(r)).div(a).toConst();
|
|
2574
|
+
return {
|
|
2575
|
+
radius: a,
|
|
2576
|
+
cosView: o,
|
|
2577
|
+
cosLight: u
|
|
2578
|
+
};
|
|
2579
|
+
}, ta = /* @__PURE__ */ L(
|
|
2580
|
+
(s, e, t, i, r) => {
|
|
2581
|
+
const { lutNode: n, parametersNode: a } = s, o = n.getTextureNode("transmittance"), u = n.getTextureNode("scattering"), l = n.getTextureNode(
|
|
2582
|
+
"singleMieScattering"
|
|
2583
|
+
), { topRadius: c, bottomRadius: d, miePhaseFunctionG: h } = a, m = e.length().toVar();
|
|
2584
|
+
e = e.toVar(), s.constrainCamera && I(m.lessThan(d), () => {
|
|
2585
|
+
m.assign(d), e.assign(e.normalize().mul(m));
|
|
2586
|
+
});
|
|
2587
|
+
const p = e.dot(t).toVar(), x = p.negate().sub(
|
|
2588
|
+
ve(p.pow2().sub(m.pow2()).add(c.pow2()))
|
|
2589
|
+
).toConst();
|
|
2590
|
+
i = i.toVar(), I(x.greaterThan(0), () => {
|
|
2591
|
+
e.assign(e.add(t.mul(x))), m.assign(c), p.addAssign(x), i.y.assign(i.y.sub(x).max(0));
|
|
2592
|
+
});
|
|
2593
|
+
const y = g(0).toVar(), T = g(1).toVar();
|
|
2594
|
+
return I(m.lessThanEqual(c), () => {
|
|
2595
|
+
const S = p.div(m).toConst(), M = e.dot(r).div(m).toConst(), C = t.dot(r).toConst(), N = Ws(
|
|
2596
|
+
a,
|
|
2597
|
+
m,
|
|
2598
|
+
S
|
|
2599
|
+
).toVar();
|
|
2600
|
+
T.assign(
|
|
2601
|
+
N.select(
|
|
2602
|
+
0,
|
|
2603
|
+
Fe(
|
|
2604
|
+
o,
|
|
2605
|
+
m,
|
|
2606
|
+
S
|
|
2607
|
+
)
|
|
2608
|
+
)
|
|
2609
|
+
), s.showGround || N.assign(Ve(!1));
|
|
2610
|
+
const f = g(0).toVar(), z = g(0).toVar(), F = (B) => {
|
|
2611
|
+
const Te = ea(
|
|
2612
|
+
a,
|
|
2613
|
+
m,
|
|
2614
|
+
S,
|
|
2615
|
+
M,
|
|
2616
|
+
C,
|
|
2617
|
+
B
|
|
2618
|
+
), ze = tt(
|
|
2619
|
+
a,
|
|
2620
|
+
u,
|
|
2621
|
+
l,
|
|
2622
|
+
Te.radius,
|
|
2623
|
+
Te.cosView,
|
|
2624
|
+
Te.cosLight,
|
|
2625
|
+
C,
|
|
2626
|
+
N
|
|
2627
|
+
).toConst(), me = bn(
|
|
2628
|
+
o,
|
|
2629
|
+
m,
|
|
2630
|
+
S,
|
|
2631
|
+
B,
|
|
2632
|
+
N
|
|
2633
|
+
);
|
|
2634
|
+
return {
|
|
2635
|
+
S: ze.get("scattering"),
|
|
2636
|
+
M: ze.get("singleMieScattering"),
|
|
2637
|
+
T: me
|
|
2638
|
+
};
|
|
2639
|
+
}, P = i.y.add(i.x).toConst(), V = () => {
|
|
2640
|
+
const B = F(i.x);
|
|
2641
|
+
f.assign(B.T.mul(B.S)), z.assign(B.T.mul(B.M));
|
|
2642
|
+
}, _ = () => {
|
|
2643
|
+
const B = tt(
|
|
2644
|
+
a,
|
|
2645
|
+
u,
|
|
2646
|
+
l,
|
|
2647
|
+
m,
|
|
2648
|
+
S,
|
|
2649
|
+
M,
|
|
2650
|
+
C,
|
|
2651
|
+
N
|
|
2652
|
+
).toConst(), Te = B.get("scattering"), ze = B.get("singleMieScattering"), me = F(i.y), le = F(P);
|
|
2653
|
+
f.assign(Te.sub(me.T.mul(me.S).sub(le.T.mul(le.S)).max(0))), z.assign(ze.sub(me.T.mul(me.M).sub(le.T.mul(le.M)).max(0)));
|
|
2654
|
+
}, W = I(i.x.equal(0), () => {
|
|
2655
|
+
const B = tt(
|
|
2656
|
+
a,
|
|
2657
|
+
u,
|
|
2658
|
+
l,
|
|
2659
|
+
m,
|
|
2660
|
+
S,
|
|
2661
|
+
M,
|
|
2662
|
+
C,
|
|
2663
|
+
N
|
|
2664
|
+
).toConst();
|
|
2665
|
+
f.assign(B.get("scattering")), z.assign(
|
|
2666
|
+
B.get("singleMieScattering")
|
|
2667
|
+
);
|
|
2668
|
+
});
|
|
2669
|
+
s.accurateShadowScattering ? W.Else(_) : W.Else(V);
|
|
2670
|
+
let Q = g(0);
|
|
2671
|
+
if (s.parameters.higherOrderScatteringTexture) {
|
|
2672
|
+
const B = n.getTextureNode(
|
|
2673
|
+
"higherOrderScattering"
|
|
2674
|
+
);
|
|
2675
|
+
Q = _s(
|
|
2676
|
+
B,
|
|
2677
|
+
m,
|
|
2678
|
+
S,
|
|
2679
|
+
M,
|
|
2680
|
+
C,
|
|
2681
|
+
N
|
|
2682
|
+
);
|
|
2683
|
+
}
|
|
2684
|
+
const ue = _t(C), Ie = qs(h, C);
|
|
2685
|
+
y.assign(
|
|
2686
|
+
f.mul(ue).add(z.mul(Ie)).add(Q)
|
|
2687
|
+
);
|
|
2688
|
+
}), Dn(y, T);
|
|
2689
|
+
}
|
|
2690
|
+
), sa = /* @__PURE__ */ L(
|
|
2691
|
+
(s, e, t, i) => {
|
|
2692
|
+
const { lutNode: r } = s, n = r.getTextureNode("irradiance"), a = e.length().toConst(), o = e.dot(i).div(a).toConst();
|
|
2693
|
+
return En(n, a, o).mul(
|
|
2694
|
+
t.dot(e).div(a).add(1).mul(0.5)
|
|
2695
|
+
);
|
|
2696
|
+
}
|
|
2697
|
+
), ia = /* @__PURE__ */ L(
|
|
2698
|
+
() => (s) => {
|
|
2699
|
+
const e = oe(s), { parametersNode: t } = e, {
|
|
2700
|
+
solarIrradiance: i,
|
|
2701
|
+
sunAngularRadius: r,
|
|
2702
|
+
sunRadianceToLuminance: n,
|
|
2703
|
+
luminanceScale: a
|
|
2704
|
+
} = t;
|
|
2705
|
+
return i.div(qe.mul(r.pow2())).mul(n.mul(a));
|
|
2706
|
+
}
|
|
2707
|
+
), ra = /* @__PURE__ */ Y(
|
|
2708
|
+
{
|
|
2709
|
+
luminance: Os,
|
|
2710
|
+
transmittance: Se
|
|
2711
|
+
},
|
|
2712
|
+
"LuminanceTransfer"
|
|
2713
|
+
), fs = /* @__PURE__ */ L(
|
|
2714
|
+
(s, e, t, i) => (r) => {
|
|
2715
|
+
const n = ae(r), { parametersNode: a } = n, { skyRadianceToLuminance: o, luminanceScale: u } = a, l = ta(
|
|
2716
|
+
n,
|
|
2717
|
+
s,
|
|
2718
|
+
e,
|
|
2719
|
+
t,
|
|
2720
|
+
i
|
|
2721
|
+
), c = l.get("radiance").mul(o.mul(u));
|
|
2722
|
+
return ra(
|
|
2723
|
+
c,
|
|
2724
|
+
l.get("transmittance")
|
|
2725
|
+
);
|
|
2726
|
+
}
|
|
2727
|
+
), na = /* @__PURE__ */ L(
|
|
2728
|
+
(s, e, t) => (i) => {
|
|
2729
|
+
const r = ae(i), { parametersNode: n } = r, { skyRadianceToLuminance: a, luminanceScale: o } = n;
|
|
2730
|
+
return sa(
|
|
2731
|
+
r,
|
|
2732
|
+
s,
|
|
2733
|
+
e,
|
|
2734
|
+
t
|
|
2735
|
+
).mul(a.mul(o));
|
|
2736
|
+
}
|
|
2737
|
+
), aa = /* @__PURE__ */ R({
|
|
2738
|
+
name: "getLunarRadiance",
|
|
2739
|
+
type: Os,
|
|
2740
|
+
inputs: [
|
|
2741
|
+
{ name: "parameters", type: q },
|
|
2742
|
+
{ name: "moonAngularRadius", type: "float" }
|
|
2743
|
+
]
|
|
2744
|
+
})(([s, e]) => {
|
|
2745
|
+
const { solarIrradiance: t, sunRadianceToLuminance: i, luminanceScale: r } = j(s);
|
|
2746
|
+
return t.mul(25e-7).div(qe.mul(e.pow2())).mul(i.mul(r));
|
|
2747
|
+
}), oa = /* @__PURE__ */ R({
|
|
2748
|
+
name: "raySphereIntersectionNormal",
|
|
2749
|
+
type: "vec3",
|
|
2750
|
+
inputs: [
|
|
2751
|
+
{ name: "rayDirection", type: "vec3" },
|
|
2752
|
+
{ name: "centerDirection", type: "vec3" },
|
|
2753
|
+
{ name: "angularRadius", type: "float" }
|
|
2754
|
+
]
|
|
2755
|
+
})(([s, e, t]) => {
|
|
2756
|
+
const i = e.dot(s), r = e.sub(s.mul(i)).negate().toConst(), n = $(t.pow2().sub(r.dot(r)).max(0));
|
|
2757
|
+
return r.sub(s.mul(n)).div(t);
|
|
2758
|
+
}), ua = /* @__PURE__ */ R({
|
|
2759
|
+
name: "orenNayarDiffuse",
|
|
2760
|
+
type: "float",
|
|
2761
|
+
inputs: [
|
|
2762
|
+
{ name: "lightDirection", type: "vec3" },
|
|
2763
|
+
{ name: "viewDirection", type: "vec3" },
|
|
2764
|
+
{ name: "normal", type: "vec3" }
|
|
2765
|
+
]
|
|
2766
|
+
})(([s, e, t]) => {
|
|
2767
|
+
const i = t.dot(s).toConst(), r = t.dot(e).toConst(), n = s.dot(e).sub(i.mul(r)).toConst(), a = he(1, Re(i, r).max(0.1), n.smoothstep(0, 0.1)), o = 1 / Math.PI * (1 - 0.5 * (1 / 1.33) + 0.17 * (1 / 1.13)), u = 1 / Math.PI * (0.45 * (1 / 1.09));
|
|
2768
|
+
return i.max(0).mul(n.div(a).mul(u).add(o));
|
|
2769
|
+
});
|
|
2770
|
+
class la extends se {
|
|
2771
|
+
constructor() {
|
|
2772
|
+
super("vec4"), this.angularRadius = w(45e-4), this.intensity = w(1), this.displacementScale = w(65535 * 0.5 / 1727400);
|
|
2773
|
+
}
|
|
2774
|
+
static get type() {
|
|
2775
|
+
return "MoonNode";
|
|
2776
|
+
}
|
|
2777
|
+
setup(e) {
|
|
2778
|
+
const t = ae(e), { rayDirectionECEF: i } = this;
|
|
2779
|
+
if (i == null)
|
|
2780
|
+
return;
|
|
2781
|
+
const {
|
|
2782
|
+
sunDirectionECEF: r,
|
|
2783
|
+
moonDirectionECEF: n,
|
|
2784
|
+
matrixMoonFixedToECEF: a
|
|
2785
|
+
} = t;
|
|
2786
|
+
return O(() => {
|
|
2787
|
+
const o = ne(this.angularRadius).oneMinus().mul(2), u = i.sub(n), l = u.dot(u), c = Fs(l), d = b().toVar(), h = g().toVar(), m = g().toVar();
|
|
2788
|
+
I(l.lessThan(o), () => {
|
|
2789
|
+
h.assign(
|
|
2790
|
+
oa(
|
|
2791
|
+
i,
|
|
2792
|
+
n,
|
|
2793
|
+
this.angularRadius
|
|
2794
|
+
)
|
|
2795
|
+
), m.assign(
|
|
2796
|
+
a.transpose().mul(v(h, 0)).xyz
|
|
2797
|
+
), d.assign(Ji(m.xzy));
|
|
2798
|
+
});
|
|
2799
|
+
const p = is(d).toConst(), x = rs(d).toConst(), y = is(m).toConst(), T = rs(m).toConst(), S = v(0).toVar();
|
|
2800
|
+
return I(l.lessThan(o), () => {
|
|
2801
|
+
if (this.displacementNode != null) {
|
|
2802
|
+
const f = this.displacementNode.sample(d.add(p)).x, z = this.displacementNode.sample(d.sub(p)).x, F = this.displacementNode.sample(d.add(x)).x, P = this.displacementNode.sample(d.sub(x)).x, V = f.sub(z).mul(0.5), _ = F.sub(P).mul(0.5), W = T.cross(m).toConst(), Q = m.cross(y).toConst(), ue = y.dot(W).toConst(), Ie = W.mul(V).add(Q.mul(_)).mul(ue.sign()), B = m.mul(ue.abs()).sub(Ie.mul(this.displacementScale)).normalize();
|
|
2803
|
+
m.assign(
|
|
2804
|
+
he(
|
|
2805
|
+
m,
|
|
2806
|
+
B,
|
|
2807
|
+
// Avoid artifact at the edge:
|
|
2808
|
+
h.dot(i.negate()).smoothstep(0, 0.3)
|
|
2809
|
+
)
|
|
2810
|
+
), h.assign(a.mul(v(m, 0)).xyz);
|
|
2811
|
+
}
|
|
2812
|
+
const M = this.colorNode?.sample(d).xyz ?? 1, C = ua(
|
|
2813
|
+
r,
|
|
2814
|
+
i.negate(),
|
|
2815
|
+
h
|
|
2816
|
+
), N = ut(
|
|
2817
|
+
o,
|
|
2818
|
+
o.sub(c),
|
|
2819
|
+
l
|
|
2820
|
+
);
|
|
2821
|
+
S.assign(
|
|
2822
|
+
v(
|
|
2823
|
+
aa(
|
|
2824
|
+
t.parametersNode,
|
|
2825
|
+
this.angularRadius
|
|
2826
|
+
).mul(this.intensity).mul(M).mul(C),
|
|
2827
|
+
N
|
|
2828
|
+
)
|
|
2829
|
+
);
|
|
2830
|
+
}), S;
|
|
2831
|
+
})();
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
const { resetRendererState: ca, restoreRendererState: da } = K;
|
|
2835
|
+
function ha() {
|
|
2836
|
+
const s = new wi(1, 1, {
|
|
2837
|
+
depthBuffer: !1,
|
|
2838
|
+
type: Ze,
|
|
2839
|
+
format: be
|
|
2840
|
+
}), e = s.texture;
|
|
2841
|
+
return e.minFilter = Z, e.magFilter = Z, e.generateMipmaps = !1, e.name = "Stars", s;
|
|
2842
|
+
}
|
|
2843
|
+
const ma = R({
|
|
2844
|
+
name: "log10",
|
|
2845
|
+
type: "float",
|
|
2846
|
+
inputs: [{ name: "x", type: "float" }]
|
|
2847
|
+
})(([s]) => qi(s).mul(1 / Math.log(10))), pa = /* @__PURE__ */ L(
|
|
2848
|
+
(s, e) => {
|
|
2849
|
+
const t = s.add(ma(e.mul(425e8)).mul(2.5)).toConst();
|
|
2850
|
+
return Vs(10, t.mul(-0.4)).mul(108e3);
|
|
2851
|
+
}
|
|
2852
|
+
), ga = /* @__PURE__ */ new re();
|
|
2853
|
+
class xa extends se {
|
|
2854
|
+
constructor(e = Tn) {
|
|
2855
|
+
super("vec3"), this.pointSize = w(1), this.intensity = w(1e3), this.magnitudeRange = w(new re(-2, 8)), this.material = new Ti(), this.points = new gr(this.material), this.updateBeforeType = ee.FRAME, this.material.name = "Stars", this.data = e, this.renderTarget = ha(), this.textureNode = Le(this, this.renderTarget.texture);
|
|
2856
|
+
}
|
|
2857
|
+
static get type() {
|
|
2858
|
+
return "StarsNode";
|
|
2859
|
+
}
|
|
2860
|
+
getTextureNode() {
|
|
2861
|
+
return this.textureNode;
|
|
2862
|
+
}
|
|
2863
|
+
setSize(e, t) {
|
|
2864
|
+
return this.renderTarget.setSize(e, t), this;
|
|
2865
|
+
}
|
|
2866
|
+
updateBefore(e) {
|
|
2867
|
+
const { renderer: t } = e, i = this.camera ?? e.camera;
|
|
2868
|
+
if (t == null || i == null)
|
|
2869
|
+
return;
|
|
2870
|
+
const r = t.getDrawingBufferSize(ga);
|
|
2871
|
+
this.setSize(r.x, r.y), this.rendererState = ca(t, this.rendererState), this.points.position.copy(i.position), t.setRenderTarget(this.renderTarget), t.render(this.points, i), da(t, this.rendererState);
|
|
2872
|
+
}
|
|
2873
|
+
createBuffers(e) {
|
|
2874
|
+
const t = e.byteLength / 10, i = new Float32Array(t * 3), r = new Float32Array(t), n = new Float32Array(t * 3), a = new Int16Array(e), o = new Uint8Array(e);
|
|
2875
|
+
for (let u = 0, l = 0, c = 0, d = 0; u < t; ++u, l += 3, c += 5, d += 10)
|
|
2876
|
+
i[l + 0] = a[c + 0] / 32767, i[l + 1] = a[c + 1] / 32767, i[l + 2] = a[c + 2] / 32767, r[u] = o[d + 6] / 255, n[l + 0] = o[d + 7] / 255, n[l + 1] = o[d + 8] / 255, n[l + 2] = o[d + 9] / 255;
|
|
2877
|
+
this.positionBuffer = new pt(i, 3), this.magnitudeBuffer = new pt(r, 1), this.colorBuffer = new pt(n, 3), this.points.count = t;
|
|
2878
|
+
}
|
|
2879
|
+
setupMaterial(e) {
|
|
2880
|
+
const t = ae(e), i = t.camera ?? e.camera;
|
|
2881
|
+
if (i == null)
|
|
2882
|
+
return;
|
|
2883
|
+
const { material: r, positionBuffer: n, magnitudeBuffer: a, colorBuffer: o } = this;
|
|
2884
|
+
de(n != null), de(a != null), de(o != null);
|
|
2885
|
+
const u = mt(n, "vec3"), l = mt(a, "float"), c = mt(o, "vec3"), { matrixECIToECEF: d, matrixECEFToWorld: h, parametersNode: m } = t, { luminanceScale: p } = m, x = d.mul(v(u, 0)).xyz, y = h.mul(v(x, 0)).xyz;
|
|
2886
|
+
r.positionNode = y.mul(
|
|
2887
|
+
je(i).add(Ge(i)).mul(0.5)
|
|
2888
|
+
);
|
|
2889
|
+
const T = he(
|
|
2890
|
+
this.magnitudeRange.x,
|
|
2891
|
+
this.magnitudeRange.y,
|
|
2892
|
+
l.x
|
|
2893
|
+
), S = this.pointSize.mul(2).div(Xi.y.mul(Mr(i)[1][1])).pow2(), M = pa(T, S);
|
|
2894
|
+
r.colorNode = M.mul(p).mul(c).mul(this.intensity).toVertexStage(), r.needsUpdate = !0;
|
|
2895
|
+
}
|
|
2896
|
+
setup(e) {
|
|
2897
|
+
typeof this.data == "string" ? this.dataPromise ??= new Cr().loadAsync(this.data).then((r) => {
|
|
2898
|
+
this.createBuffers(r), this.setupMaterial(e);
|
|
2899
|
+
}).catch((r) => {
|
|
2900
|
+
console.error(r);
|
|
2901
|
+
}) : (this.createBuffers(this.data), this.setupMaterial(e));
|
|
2902
|
+
const { material: t } = this;
|
|
2903
|
+
t.sizeNode = this.pointSize, t.sizeAttenuation = !1, t.depthTest = !1, t.depthWrite = !1, t.transparent = !0, t.blending = Ls, t.needsUpdate = !0, this.points.frustumCulled = !1;
|
|
2904
|
+
const i = ae(e);
|
|
2905
|
+
return this.camera = i.camera, this.textureNode.uvNode = Ns, this.textureNode;
|
|
2906
|
+
}
|
|
2907
|
+
dispose() {
|
|
2908
|
+
this.renderTarget.dispose(), this.material.dispose(), super.dispose();
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
class ya extends se {
|
|
2912
|
+
constructor() {
|
|
2913
|
+
super("vec4"), this.angularRadius = w(4675e-6), this.intensity = w(1);
|
|
2914
|
+
}
|
|
2915
|
+
static get type() {
|
|
2916
|
+
return "SunNode";
|
|
2917
|
+
}
|
|
2918
|
+
setup(e) {
|
|
2919
|
+
const t = ae(e), { rayDirectionECEF: i } = this;
|
|
2920
|
+
if (i == null)
|
|
2921
|
+
return;
|
|
2922
|
+
const { sunDirectionECEF: r } = t;
|
|
2923
|
+
return O(() => {
|
|
2924
|
+
const n = ne(this.angularRadius).oneMinus().mul(2), a = i.sub(r), o = a.dot(a), u = Fs(o), l = v(0).toVar();
|
|
2925
|
+
return I(o.lessThan(n), () => {
|
|
2926
|
+
const c = ut(
|
|
2927
|
+
n,
|
|
2928
|
+
n.sub(u),
|
|
2929
|
+
o
|
|
2930
|
+
);
|
|
2931
|
+
l.assign(
|
|
2932
|
+
v(ia().mul(this.intensity), c)
|
|
2933
|
+
);
|
|
2934
|
+
}), l;
|
|
2935
|
+
})();
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
const Ta = (s) => {
|
|
2939
|
+
const e = Rr(s).mul(
|
|
2940
|
+
v(It, 1)
|
|
2941
|
+
).xyz;
|
|
2942
|
+
return br(s).mul(
|
|
2943
|
+
v(e, 0)
|
|
2944
|
+
).xyz;
|
|
2945
|
+
}, Ut = "CAMERA", ti = "EQUIRECTANGULAR";
|
|
2946
|
+
class si extends se {
|
|
2947
|
+
constructor(e, t) {
|
|
2948
|
+
super("vec3"), this.scope = Ut, this.showSun = !0, this.showMoon = !0, this.showStars = !0, this.moonScattering = !1, this.useContextCamera = !0, this.scope = e, this.shadowLengthNode = t, this.sunNode = new ya(), this.moonNode = new la(), this.starsNode = new xa();
|
|
2949
|
+
}
|
|
2950
|
+
static get type() {
|
|
2951
|
+
return "SkyNode";
|
|
2952
|
+
}
|
|
2953
|
+
customCacheKey() {
|
|
2954
|
+
return Gt(
|
|
2955
|
+
+this.showSun,
|
|
2956
|
+
+this.showMoon,
|
|
2957
|
+
+this.showStars,
|
|
2958
|
+
+this.moonScattering,
|
|
2959
|
+
+this.useContextCamera
|
|
2960
|
+
);
|
|
2961
|
+
}
|
|
2962
|
+
setup(e) {
|
|
2963
|
+
const t = ae(e), {
|
|
2964
|
+
matrixWorldToECEF: i,
|
|
2965
|
+
sunDirectionECEF: r,
|
|
2966
|
+
moonDirectionECEF: n,
|
|
2967
|
+
cameraPositionUnit: a,
|
|
2968
|
+
altitudeCorrectionUnit: o
|
|
2969
|
+
} = t;
|
|
2970
|
+
let u;
|
|
2971
|
+
switch (this.scope) {
|
|
2972
|
+
case Ut: {
|
|
2973
|
+
u = Ta(
|
|
2974
|
+
this.useContextCamera ? t.camera : null
|
|
2975
|
+
);
|
|
2976
|
+
break;
|
|
2977
|
+
}
|
|
2978
|
+
case ti:
|
|
2979
|
+
u = nn(Me());
|
|
2980
|
+
break;
|
|
2981
|
+
}
|
|
2982
|
+
if (u != null)
|
|
2983
|
+
return O(() => {
|
|
2984
|
+
const l = i.mul(v(u, 0)).xyz.toVertexStage().normalize().toConst(), c = fs(
|
|
2985
|
+
a.add(o),
|
|
2986
|
+
l,
|
|
2987
|
+
this.shadowLengthNode ?? b(0),
|
|
2988
|
+
r
|
|
2989
|
+
).toConst(), d = c.get("transmittance");
|
|
2990
|
+
let h = c.get("luminance");
|
|
2991
|
+
if (this.moonScattering) {
|
|
2992
|
+
const p = fs(
|
|
2993
|
+
a.add(o),
|
|
2994
|
+
l,
|
|
2995
|
+
this.shadowLengthNode ?? b(0),
|
|
2996
|
+
n
|
|
2997
|
+
);
|
|
2998
|
+
h = h.add(
|
|
2999
|
+
p.get("luminance").mul(25e-7)
|
|
3000
|
+
);
|
|
3001
|
+
}
|
|
3002
|
+
const m = g(0).toVar();
|
|
3003
|
+
if (this.showStars && m.addAssign(this.starsNode), this.showSun) {
|
|
3004
|
+
const { sunNode: p } = this;
|
|
3005
|
+
p.rayDirectionECEF = l, m.assign(he(m, p.rgb, p.a));
|
|
3006
|
+
}
|
|
3007
|
+
if (this.showMoon) {
|
|
3008
|
+
const { moonNode: p } = this;
|
|
3009
|
+
p.rayDirectionECEF = l, m.assign(he(m, p.rgb, p.a));
|
|
3010
|
+
}
|
|
3011
|
+
return m.mul(d).add(h);
|
|
3012
|
+
})();
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
const wa = /* @__PURE__ */ As(si, Ut), fa = /* @__PURE__ */ As(si, ti);
|
|
3016
|
+
class Ss extends hr {
|
|
3017
|
+
constructor(e = 1, t = "sun") {
|
|
3018
|
+
super(), this.type = "AtmosphereLight", this.direct = w(!0), this.indirect = w(!0), this.distance = e, this.body = t;
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
const Sa = /* @__PURE__ */ new dr();
|
|
3022
|
+
class va extends yi {
|
|
3023
|
+
constructor(e) {
|
|
3024
|
+
super(e), this.intensity = w(1), this.directionECEF = w("vec3"), this.updateBeforeType = ee.FRAME;
|
|
3025
|
+
}
|
|
3026
|
+
static get type() {
|
|
3027
|
+
return "AtmosphereLightNode";
|
|
3028
|
+
}
|
|
3029
|
+
updateBefore(e) {
|
|
3030
|
+
const { light: t, atmosphereContext: i } = this;
|
|
3031
|
+
if (t == null || i == null)
|
|
3032
|
+
return;
|
|
3033
|
+
const { matrixECEFToWorld: r } = i;
|
|
3034
|
+
t.position.copy(this.directionECEF.value).applyMatrix3(Sa.setFromMatrix4(r.value)).multiplyScalar(t.distance).add(t.target.position);
|
|
3035
|
+
}
|
|
3036
|
+
update(e) {
|
|
3037
|
+
super.update(e);
|
|
3038
|
+
const { light: t, atmosphereContext: i } = this;
|
|
3039
|
+
if (!(t == null || i == null))
|
|
3040
|
+
switch (t.body) {
|
|
3041
|
+
case "sun":
|
|
3042
|
+
this.intensity.value = t.intensity, this.directionECEF.value.copy(i.sunDirectionECEF.value);
|
|
3043
|
+
break;
|
|
3044
|
+
case "moon":
|
|
3045
|
+
this.intensity.value = t.intensity * 25e-7, this.directionECEF.value.copy(i.moonDirectionECEF.value);
|
|
3046
|
+
break;
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
setup(e) {
|
|
3050
|
+
return this.atmosphereContext = ae(e), super.setup(e);
|
|
3051
|
+
}
|
|
3052
|
+
setupDirect(e) {
|
|
3053
|
+
const { light: t, atmosphereContext: i } = this;
|
|
3054
|
+
if (t == null || i == null)
|
|
3055
|
+
return;
|
|
3056
|
+
const { intensity: r, directionECEF: n } = this, { direct: a, indirect: o } = t, {
|
|
3057
|
+
worldToUnit: u,
|
|
3058
|
+
solarIrradiance: l,
|
|
3059
|
+
sunRadianceToLuminance: c,
|
|
3060
|
+
luminanceScale: d
|
|
3061
|
+
} = i.parametersNode, { matrixWorldToECEF: h, matrixECEFToWorld: m, altitudeCorrectionECEF: p } = i, x = h.mul(v(_i, 0)).xyz;
|
|
3062
|
+
let y = h.mul(v(Zi, 1)).xyz;
|
|
3063
|
+
i.correctAltitude && (y = y.add(p));
|
|
3064
|
+
const T = y.mul(u).toConst(), S = na(
|
|
3065
|
+
T,
|
|
3066
|
+
x,
|
|
3067
|
+
n
|
|
3068
|
+
).mul(o.select(1, 0));
|
|
3069
|
+
e.context.irradiance.addAssign(S.mul(r));
|
|
3070
|
+
const M = m.mul(v(n, 0)).xyz, C = Ki.mul(v(M, 0)).xyz, N = T.length().toConst(), f = T.dot(n).div(N), z = at(
|
|
3071
|
+
i.lutNode.getTextureNode("transmittance"),
|
|
3072
|
+
N,
|
|
3073
|
+
f
|
|
3074
|
+
), F = l.mul(z).mul(c.mul(d)).mul(r).mul(a.select(1, 0));
|
|
3075
|
+
return {
|
|
3076
|
+
lightDirection: C,
|
|
3077
|
+
lightColor: F.mul(this.colorNode)
|
|
3078
|
+
};
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
const { resetRendererState: _a, restoreRendererState: Za } = K, { resetRendererState: Ka, restoreRendererState: Qa } = K, { resetRendererState: Ja, restoreRendererState: Xa } = K, { resetRendererState: Ya, restoreRendererState: eo } = K, { resetRendererState: to, restoreRendererState: so } = K, { resetRendererState: io, restoreRendererState: ro } = K;
|
|
3082
|
+
class Ca extends se {
|
|
3083
|
+
constructor(e = 64) {
|
|
3084
|
+
super("vec3"), this.distanceThreshold = 1e3, this.angularThreshold = rt(0.1), this.material = new Ce(), this.mesh = new Ds(new vr(), this.material), this.updateBeforeType = ee.FRAME, this.material.name = "SkyEnvironment", this.skyNode = wa(), this.skyNode.showSun = !1, this.skyNode.showMoon = !1, this.skyNode.showStars = !1, this.skyNode.useContextCamera = !1, this.renderTarget = new mr(e, {
|
|
3085
|
+
depthBuffer: !1,
|
|
3086
|
+
type: Ze,
|
|
3087
|
+
format: be
|
|
3088
|
+
}), this.cubeCamera = new pr(0.1, 1e3, this.renderTarget);
|
|
3089
|
+
}
|
|
3090
|
+
static get type() {
|
|
3091
|
+
return "SkyEnvironmentNode";
|
|
3092
|
+
}
|
|
3093
|
+
updateBefore({ renderer: e }) {
|
|
3094
|
+
e == null || this.version === this.currentVersion || (this.currentVersion = this.version, this.cubeCamera.update(e, this.mesh));
|
|
3095
|
+
}
|
|
3096
|
+
setup(e) {
|
|
3097
|
+
const t = ae(e), { camera: i } = t;
|
|
3098
|
+
if (i != null) {
|
|
3099
|
+
const o = new H(), u = new H();
|
|
3100
|
+
xt(() => {
|
|
3101
|
+
o.copy(i.position).divideScalar(this.distanceThreshold).round(), u.equals(o) || (u.copy(o), this.needsUpdate = !0);
|
|
3102
|
+
});
|
|
3103
|
+
}
|
|
3104
|
+
const r = t.sunDirectionECEF.value.clone();
|
|
3105
|
+
xt(() => {
|
|
3106
|
+
const { value: o } = t.sunDirectionECEF;
|
|
3107
|
+
r.angleTo(o) > this.angularThreshold && (r.copy(o), this.needsUpdate = !0);
|
|
3108
|
+
});
|
|
3109
|
+
const n = t.moonDirectionECEF.value.clone();
|
|
3110
|
+
xt(() => {
|
|
3111
|
+
const { value: o } = t.moonDirectionECEF;
|
|
3112
|
+
n.angleTo(o) > this.angularThreshold && (n.copy(o), this.needsUpdate = !0);
|
|
3113
|
+
});
|
|
3114
|
+
const a = () => {
|
|
3115
|
+
this.needsUpdate = !0;
|
|
3116
|
+
};
|
|
3117
|
+
return t.lutNode.addEventListener(
|
|
3118
|
+
// @ts-expect-error Cannot specify the events map
|
|
3119
|
+
"update",
|
|
3120
|
+
a
|
|
3121
|
+
), this.removeLUTUpdateListener?.(), this.removeLUTUpdateListener = () => {
|
|
3122
|
+
t.lutNode.removeEventListener(
|
|
3123
|
+
// @ts-expect-error Cannot specify the events map
|
|
3124
|
+
"update",
|
|
3125
|
+
a
|
|
3126
|
+
);
|
|
3127
|
+
}, this.material.vertexNode = v(It.xy, 0, 1), this.material.fragmentNode = this.skyNode, Qi(this.renderTarget.texture);
|
|
3128
|
+
}
|
|
3129
|
+
dispose() {
|
|
3130
|
+
this.removeLUTUpdateListener?.(), this.renderTarget.dispose(), this.skyNode.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
const Na = (...s) => new Ca(...s), Ma = He(
|
|
3134
|
+
g(1.6605, -0.1246, -0.0182),
|
|
3135
|
+
g(-0.5876, 1.1329, -0.1006),
|
|
3136
|
+
g(-0.0728, -83e-4, 1.1187)
|
|
3137
|
+
), Ra = He(
|
|
3138
|
+
g(0.6274, 0.0691, 0.0164),
|
|
3139
|
+
g(0.3293, 0.9195, 0.088),
|
|
3140
|
+
g(0.0433, 0.0113, 0.8956)
|
|
3141
|
+
), ba = L((s) => {
|
|
16
3142
|
const e = s.pow2().toConst(), t = e.pow2().toConst();
|
|
17
|
-
return
|
|
3143
|
+
return k(
|
|
18
3144
|
t.mul(e).mul(15.5),
|
|
19
3145
|
t.mul(s).mul(-40.14),
|
|
20
3146
|
t.mul(31.96),
|
|
@@ -23,15 +3149,15 @@ const q = u(
|
|
|
23
3149
|
s.mul(0.1191),
|
|
24
3150
|
-232e-5
|
|
25
3151
|
);
|
|
26
|
-
}),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
),
|
|
3152
|
+
}), za = He(
|
|
3153
|
+
g(0.856627153315983, 0.137318972929847, 0.11189821299995),
|
|
3154
|
+
g(0.0951212405381588, 0.761241990602591, 0.0767994186031903),
|
|
3155
|
+
g(0.0482516061458583, 0.101439036467562, 0.811302368396859)
|
|
3156
|
+
), Ea = He(
|
|
3157
|
+
g(1.1271005818144368, -0.1413297634984383, -0.14132976349843826),
|
|
3158
|
+
g(-0.11060664309660323, 1.157823702216272, -0.11060664309660294),
|
|
3159
|
+
g(-0.016493938717834573, -0.016493938717834257, 1.2519364065950405)
|
|
3160
|
+
), vs = -12.47393, Aa = 4.026069, Fa = R({
|
|
35
3161
|
name: "agx",
|
|
36
3162
|
type: "vec3",
|
|
37
3163
|
inputs: [
|
|
@@ -39,16 +3165,16 @@ const q = u(
|
|
|
39
3165
|
{ name: "exposure", type: "float" }
|
|
40
3166
|
]
|
|
41
3167
|
})(([s, e]) => {
|
|
42
|
-
const t = s.toVar(),
|
|
43
|
-
return t.mulAssign(
|
|
44
|
-
}),
|
|
3168
|
+
const t = s.toVar(), i = e;
|
|
3169
|
+
return t.mulAssign(i), t.assign(Ra.mul(t)), t.assign(za.mul(t)), t.assign(Yi(t.max(1e-10))), t.assign(t.sub(vs).div(A(Aa).sub(vs))), t.assign(t.saturate()), t.assign(ba(t)), t;
|
|
3170
|
+
}), Va = R({
|
|
45
3171
|
name: "agxEOTF",
|
|
46
3172
|
type: "vec3",
|
|
47
3173
|
inputs: [{ name: "color", type: "vec3" }]
|
|
48
3174
|
})(([s]) => {
|
|
49
3175
|
const e = s.toVar();
|
|
50
|
-
return e.assign(
|
|
51
|
-
}),
|
|
3176
|
+
return e.assign(Ea.mul(e)), e.assign(Vs(e.max(0), A(2.2))), e.assign(Ma.mul(e)), e.assign(e.saturate()), e;
|
|
3177
|
+
}), La = R({
|
|
52
3178
|
name: "agxPunchyToneMapping",
|
|
53
3179
|
type: "vec3",
|
|
54
3180
|
inputs: [
|
|
@@ -56,14 +3182,14 @@ const q = u(
|
|
|
56
3182
|
{ name: "exposure", type: "float" }
|
|
57
3183
|
]
|
|
58
3184
|
})(([s, e]) => {
|
|
59
|
-
const t = s.toVar(),
|
|
60
|
-
return t.assign(
|
|
61
|
-
}),
|
|
62
|
-
function
|
|
3185
|
+
const t = s.toVar(), i = e;
|
|
3186
|
+
return t.assign(Fa(t, i.mul(1.5))), t.assign(er(t, g(1), g(0), g(1.35), A(1.2))), t.assign(Va(t)), t;
|
|
3187
|
+
}), ii = 100;
|
|
3188
|
+
function Vt() {
|
|
63
3189
|
const s = /* @__PURE__ */ new Date();
|
|
64
3190
|
return s.setHours(8, 0, 0, 0), s;
|
|
65
3191
|
}
|
|
66
|
-
const
|
|
3192
|
+
const Da = {
|
|
67
3193
|
longitude: 0,
|
|
68
3194
|
latitude: 0,
|
|
69
3195
|
height: 0,
|
|
@@ -81,7 +3207,7 @@ const te = {
|
|
|
81
3207
|
lensFlare: !0,
|
|
82
3208
|
temporalAntialias: !0,
|
|
83
3209
|
dithering: !0,
|
|
84
|
-
toneMapping:
|
|
3210
|
+
toneMapping: ii,
|
|
85
3211
|
toneMappingExposure: 3,
|
|
86
3212
|
castShadow: !0,
|
|
87
3213
|
shadowMapSize: 4096,
|
|
@@ -93,28 +3219,28 @@ const te = {
|
|
|
93
3219
|
shadowRadius: 1.5,
|
|
94
3220
|
shadowDistance: 3e3
|
|
95
3221
|
};
|
|
96
|
-
class
|
|
3222
|
+
class no {
|
|
97
3223
|
viewer;
|
|
98
3224
|
#r = !1;
|
|
99
3225
|
#e = {
|
|
100
|
-
...
|
|
101
|
-
date:
|
|
3226
|
+
...Da,
|
|
3227
|
+
date: Vt()
|
|
102
3228
|
};
|
|
103
|
-
#
|
|
104
|
-
#i = null;
|
|
105
|
-
#t = null;
|
|
3229
|
+
#h = null;
|
|
106
3230
|
#s = null;
|
|
3231
|
+
#t = null;
|
|
3232
|
+
#i = null;
|
|
107
3233
|
#n = null;
|
|
108
|
-
#h = null;
|
|
109
|
-
#d = null;
|
|
110
|
-
#a = [];
|
|
111
3234
|
#u = null;
|
|
3235
|
+
#l = null;
|
|
3236
|
+
#a = [];
|
|
3237
|
+
#c = null;
|
|
112
3238
|
#g;
|
|
113
|
-
#
|
|
114
|
-
#
|
|
115
|
-
#
|
|
116
|
-
#
|
|
117
|
-
#
|
|
3239
|
+
#m;
|
|
3240
|
+
#x = !1;
|
|
3241
|
+
#d = !1;
|
|
3242
|
+
#y = new fi();
|
|
3243
|
+
#p = new Xt();
|
|
118
3244
|
constructor(e) {
|
|
119
3245
|
this.viewer = e;
|
|
120
3246
|
}
|
|
@@ -122,179 +3248,179 @@ class he {
|
|
|
122
3248
|
return this.#r;
|
|
123
3249
|
}
|
|
124
3250
|
get context() {
|
|
125
|
-
return this.#
|
|
3251
|
+
return this.#s;
|
|
126
3252
|
}
|
|
127
3253
|
get light() {
|
|
128
3254
|
return this.#t;
|
|
129
3255
|
}
|
|
130
3256
|
enable(e = {}) {
|
|
131
|
-
return this.#r ? this.update(e) : (this.#e = this.#
|
|
3257
|
+
return this.#r ? this.update(e) : (this.#e = this.#T(e), this.#h = new Qe(), this.#s = new ei(this.#h), this.#s.camera = this.viewer.camera, this.#w(), this.#F(), this.#V(), this.#L(), this.#D(), this.#P(), this.#U(), this.#O(), this.updateDate(this.#e.date), this.#N(), this.#r = !0, this.viewer.render(), this);
|
|
132
3258
|
}
|
|
133
3259
|
update(e = {}) {
|
|
134
|
-
return this.#e = this.#
|
|
3260
|
+
return this.#e = this.#T(e), this.#s ? (this.#w(), this.#v(), this.#C(), this.#f(), this.#M(), this.#B(), this.updateDate(this.#e.date), this.#N(), this.viewer.render(), this) : this;
|
|
135
3261
|
}
|
|
136
|
-
setLocation(e, t,
|
|
137
|
-
return this.update({ longitude: e, latitude: t, height:
|
|
3262
|
+
setLocation(e, t, i = this.#e.height) {
|
|
3263
|
+
return this.update({ longitude: e, latitude: t, height: i });
|
|
138
3264
|
}
|
|
139
3265
|
setDate(e) {
|
|
140
3266
|
return this.updateDate(e);
|
|
141
3267
|
}
|
|
142
|
-
updateDate(e =
|
|
143
|
-
return this.#e.date = e, this.#
|
|
3268
|
+
updateDate(e = Vt()) {
|
|
3269
|
+
return this.#e.date = e, this.#z(), this.viewer.render(), this;
|
|
144
3270
|
}
|
|
145
3271
|
disable() {
|
|
146
|
-
return this.#r ? (this.#I(), this.#
|
|
3272
|
+
return this.#r ? (this.#I(), this.#k(), this.viewer.renderPipeline.removeOutputEffect(this.#o), this.#R(), this.#o.includesTemporalAntialias = !1, this.viewer.renderPipeline.needsUpdate = !0, this.#b(), this.#t && (this.#t.target.removeFromParent(), this.#t.removeFromParent(), this.#t.dispose(), this.#t = null), this.viewer.scene.backgroundNode = this.#g, this.viewer.scene.environmentNode = this.#m, this.#c && (this.viewer.renderer.contextNode = this.#c, this.#c = null), this.viewer.renderer.highPrecision = this.#x, this.#s?.dispose(), this.#s = null, this.#h = null, this.#i = null, this.#n = null, this.#r = !1, this.viewer.render(), this) : this;
|
|
147
3273
|
}
|
|
148
3274
|
dispose() {
|
|
149
3275
|
return this.disable();
|
|
150
3276
|
}
|
|
151
|
-
#
|
|
3277
|
+
#T(e) {
|
|
152
3278
|
return {
|
|
153
3279
|
...this.#e,
|
|
154
3280
|
...e,
|
|
155
|
-
date: e.date ?? (this.#r ? this.#e.date :
|
|
3281
|
+
date: e.date ?? (this.#r ? this.#e.date : Vt())
|
|
156
3282
|
};
|
|
157
3283
|
}
|
|
158
|
-
#
|
|
159
|
-
if (!this.#
|
|
3284
|
+
#w() {
|
|
3285
|
+
if (!this.#s)
|
|
160
3286
|
return;
|
|
161
|
-
const t = new
|
|
162
|
-
|
|
163
|
-
|
|
3287
|
+
const t = new Ps(
|
|
3288
|
+
rt(this.#e.longitude),
|
|
3289
|
+
rt(this.#e.latitude),
|
|
164
3290
|
this.#e.height
|
|
165
|
-
).toECEF(new
|
|
166
|
-
|
|
3291
|
+
).toECEF(new Xt());
|
|
3292
|
+
Bs.WGS84.getNorthUpEastFrame(t, this.#y), this.#s.camera = this.viewer.camera, this.#s.showGround = this.#e.showGround, this.#s.raymarchScattering = this.#e.raymarchScattering, this.#s.matrixWorldToECEF.value.copy(this.#y);
|
|
167
3293
|
}
|
|
168
|
-
#
|
|
169
|
-
if (!this.#
|
|
3294
|
+
#F() {
|
|
3295
|
+
if (!this.#s)
|
|
170
3296
|
return;
|
|
171
3297
|
const e = this.viewer.renderer;
|
|
172
|
-
this.#
|
|
3298
|
+
this.#c = e.contextNode, this.#x = e.highPrecision, e.highPrecision = !0, e.contextNode = tr({
|
|
173
3299
|
...e.contextNode.value,
|
|
174
|
-
getAtmosphere: () => this.#
|
|
3300
|
+
getAtmosphere: () => this.#s
|
|
175
3301
|
});
|
|
176
3302
|
}
|
|
177
|
-
#
|
|
3303
|
+
#V() {
|
|
178
3304
|
const e = this.viewer.renderer;
|
|
179
|
-
e.library.addLight(
|
|
3305
|
+
e.library.addLight(va, Ss), e.shadowMap.enabled = !0, this.#t = new Ss(), this.#f(), this.viewer.scene.add(this.#t.target), this.#S(), this.viewer.scene.add(this.#t);
|
|
180
3306
|
}
|
|
181
|
-
#
|
|
3307
|
+
#f() {
|
|
182
3308
|
if (!this.#t)
|
|
183
3309
|
return;
|
|
184
3310
|
const {
|
|
185
3311
|
castShadow: e,
|
|
186
3312
|
shadowMapSize: t,
|
|
187
|
-
shadowCameraSize:
|
|
3313
|
+
shadowCameraSize: i,
|
|
188
3314
|
shadowCameraNear: r,
|
|
189
|
-
shadowCameraFar:
|
|
3315
|
+
shadowCameraFar: n,
|
|
190
3316
|
shadowBias: a,
|
|
191
|
-
shadowNormalBias:
|
|
192
|
-
shadowRadius:
|
|
193
|
-
shadowDistance:
|
|
194
|
-
} = this.#e,
|
|
195
|
-
this.#t.castShadow = e, this.#t.distance =
|
|
3317
|
+
shadowNormalBias: o,
|
|
3318
|
+
shadowRadius: u,
|
|
3319
|
+
shadowDistance: l
|
|
3320
|
+
} = this.#e, c = i / 2, d = this.#t.shadow.camera;
|
|
3321
|
+
this.#t.castShadow = e, this.#t.distance = l, this.#t.shadow.mapSize.setScalar(t), this.#t.shadow.bias = a, this.#t.shadow.normalBias = o, this.#t.shadow.radius = u, d.left = -c, d.right = c, d.top = c, d.bottom = -c, d.near = r, d.far = n, d.updateProjectionMatrix(), this.#t.shadow.needsUpdate = !0;
|
|
196
3322
|
}
|
|
197
|
-
#
|
|
3323
|
+
#S() {
|
|
198
3324
|
this.#t && (this.viewer.controls.getTarget(this.#t.target.position), this.#t.target.updateMatrixWorld());
|
|
199
3325
|
}
|
|
200
3326
|
#L() {
|
|
201
|
-
this.#g = this.viewer.scene.backgroundNode, this.#
|
|
3327
|
+
this.#g = this.viewer.scene.backgroundNode, this.#m = this.viewer.scene.environmentNode, this.#i = fa(), this.#C(), this.#v(), this.viewer.scene.backgroundNode = this.#i;
|
|
202
3328
|
}
|
|
203
|
-
#
|
|
204
|
-
this.#
|
|
3329
|
+
#v() {
|
|
3330
|
+
this.#i && (this.#i.showSun = this.#e.showSun, this.#i.showMoon = this.#e.showMoon, this.#i.showStars = this.#e.showStars, this.#i.moonScattering = this.#e.moonScattering);
|
|
205
3331
|
}
|
|
206
|
-
#
|
|
3332
|
+
#C() {
|
|
207
3333
|
if (!this.#e.useSkyEnvironment) {
|
|
208
|
-
this.#n && this.viewer.scene.environmentNode === this.#n && (this.viewer.scene.environmentNode = this.#
|
|
3334
|
+
this.#n && this.viewer.scene.environmentNode === this.#n && (this.viewer.scene.environmentNode = this.#m), this.#n = null;
|
|
209
3335
|
return;
|
|
210
3336
|
}
|
|
211
|
-
this.#n ??=
|
|
3337
|
+
this.#n ??= Na(), this.viewer.scene.environmentNode = this.#n;
|
|
212
3338
|
}
|
|
213
|
-
#
|
|
214
|
-
for (const e of [this.#
|
|
3339
|
+
#N() {
|
|
3340
|
+
for (const e of [this.#i, this.#n])
|
|
215
3341
|
e && (e.needsUpdate = !0);
|
|
216
3342
|
this.viewer.renderPipeline.needsUpdateOutputNode = !0;
|
|
217
3343
|
}
|
|
218
|
-
#
|
|
219
|
-
this.viewer.renderer.library.addToneMapping(
|
|
3344
|
+
#D() {
|
|
3345
|
+
this.viewer.renderer.library.addToneMapping(La, ii);
|
|
220
3346
|
}
|
|
221
|
-
#
|
|
222
|
-
this.#o.includesOutputTransform = !0, this.#
|
|
3347
|
+
#P() {
|
|
3348
|
+
this.#o.includesOutputTransform = !0, this.#M(), this.viewer.renderPipeline.addOutputEffect(this.#o);
|
|
223
3349
|
}
|
|
224
|
-
#
|
|
3350
|
+
#M() {
|
|
225
3351
|
if (this.#o.includesTemporalAntialias = this.#e.temporalAntialias, this.#e.temporalAntialias) {
|
|
226
|
-
this.#
|
|
3352
|
+
this.#d || (this.viewer.renderPipeline.addMRTChannel("atmosphereVelocity", Pt), this.#d = !0);
|
|
227
3353
|
return;
|
|
228
3354
|
}
|
|
229
|
-
this.#
|
|
3355
|
+
this.#R();
|
|
230
3356
|
}
|
|
231
|
-
#
|
|
232
|
-
this.#
|
|
3357
|
+
#R() {
|
|
3358
|
+
this.#d && (this.viewer.renderPipeline.removeMRTChannel("atmosphereVelocity"), this.#d = !1);
|
|
233
3359
|
}
|
|
234
|
-
#
|
|
3360
|
+
#B() {
|
|
235
3361
|
this.#r && (this.viewer.renderPipeline.needsUpdateOutputNode = !0);
|
|
236
3362
|
}
|
|
237
|
-
#
|
|
3363
|
+
#b() {
|
|
238
3364
|
for (const e of this.#a)
|
|
239
3365
|
e.dispose();
|
|
240
|
-
this.#a = [], this.#
|
|
3366
|
+
this.#a = [], this.#u = null, this.#l = null;
|
|
241
3367
|
}
|
|
242
3368
|
#o = (e, t) => {
|
|
243
|
-
const
|
|
244
|
-
this.#
|
|
3369
|
+
const i = e.getTextureNode("depth");
|
|
3370
|
+
this.#b();
|
|
245
3371
|
let r = t;
|
|
246
|
-
if (this.#e.lensFlare && (this.#
|
|
247
|
-
const a =
|
|
3372
|
+
if (this.#e.lensFlare && (this.#u = en(r), this.#a.push(this.#u), r = this.#u), this.#e.toneMapping !== !1 && this.#e.toneMapping !== Yt) {
|
|
3373
|
+
const a = sr(this.#e.toneMapping, this.#e.toneMappingExposure, r);
|
|
248
3374
|
this.#a.push(a), r = a;
|
|
249
3375
|
}
|
|
250
3376
|
if (this.#e.temporalAntialias) {
|
|
251
3377
|
const a = e.getTextureNode("atmosphereVelocity");
|
|
252
|
-
this.#
|
|
3378
|
+
this.#l = xn(
|
|
253
3379
|
r,
|
|
254
|
-
|
|
3380
|
+
i,
|
|
255
3381
|
a,
|
|
256
3382
|
this.viewer.camera
|
|
257
|
-
), this.#a.push(this.#
|
|
3383
|
+
), this.#a.push(this.#l), r = this.#l;
|
|
258
3384
|
}
|
|
259
3385
|
if (this.#e.dithering) {
|
|
260
|
-
const a =
|
|
3386
|
+
const a = k(r, Gr);
|
|
261
3387
|
this.#a.push(a), r = a;
|
|
262
3388
|
}
|
|
263
|
-
const
|
|
264
|
-
return this.#a.push(
|
|
3389
|
+
const n = ir(r, Yt);
|
|
3390
|
+
return this.#a.push(n), n;
|
|
265
3391
|
};
|
|
266
|
-
#
|
|
267
|
-
if (!this.#
|
|
3392
|
+
#z() {
|
|
3393
|
+
if (!this.#s)
|
|
268
3394
|
return;
|
|
269
|
-
this.viewer.camera.updateMatrixWorld(), this.#
|
|
270
|
-
const e = this.#
|
|
271
|
-
|
|
3395
|
+
this.viewer.camera.updateMatrixWorld(), this.#p.setFromMatrixPosition(this.viewer.camera.matrixWorld).applyMatrix4(this.#s.matrixWorldToECEF.value);
|
|
3396
|
+
const e = this.#s.matrixECIToECEF.value;
|
|
3397
|
+
Tr(this.#e.date, e), wr(this.#e.date, this.#s.sunDirectionECEF.value, this.#p).applyMatrix4(
|
|
272
3398
|
e
|
|
273
|
-
),
|
|
3399
|
+
), fr(
|
|
274
3400
|
this.#e.date,
|
|
275
|
-
this.#
|
|
276
|
-
this.#
|
|
3401
|
+
this.#s.moonDirectionECEF.value,
|
|
3402
|
+
this.#p
|
|
277
3403
|
).applyMatrix4(e);
|
|
278
3404
|
}
|
|
279
|
-
#
|
|
280
|
-
this.viewer.addEventListener("cameraChange", this.#
|
|
3405
|
+
#U() {
|
|
3406
|
+
this.viewer.addEventListener("cameraChange", this.#E);
|
|
281
3407
|
}
|
|
282
3408
|
#I() {
|
|
283
|
-
this.viewer.removeEventListener("cameraChange", this.#
|
|
3409
|
+
this.viewer.removeEventListener("cameraChange", this.#E);
|
|
284
3410
|
}
|
|
285
|
-
#
|
|
3411
|
+
#O() {
|
|
286
3412
|
this.viewer.addEventListener("beforeRender", this.#A);
|
|
287
3413
|
}
|
|
288
|
-
#
|
|
3414
|
+
#k() {
|
|
289
3415
|
this.viewer.removeEventListener("beforeRender", this.#A);
|
|
290
3416
|
}
|
|
291
|
-
#
|
|
292
|
-
this.#
|
|
3417
|
+
#E = ({ camera: e }) => {
|
|
3418
|
+
this.#s && (this.#s.camera = e, this.updateDate(this.#e.date));
|
|
293
3419
|
};
|
|
294
3420
|
#A = () => {
|
|
295
|
-
this.#
|
|
3421
|
+
this.#S(), this.#z();
|
|
296
3422
|
};
|
|
297
3423
|
}
|
|
298
3424
|
export {
|
|
299
|
-
|
|
3425
|
+
no as Atmosphere
|
|
300
3426
|
};
|