babylonjs-addons 9.22.2 → 9.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2533 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __generator = (this && this.__generator) || function (thisArg, body) {
18
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
19
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
20
+ function verb(n) { return function (v) { return step([n, v]); }; }
21
+ function step(op) {
22
+ if (f) throw new TypeError("Generator is already executing.");
23
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
24
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
25
+ if (y = 0, t) op = [op[0] & 2, t.value];
26
+ switch (op[0]) {
27
+ case 0: case 1: t = op; break;
28
+ case 4: _.label++; return { value: op[1], done: false };
29
+ case 5: _.label++; y = op[1]; op = [0]; continue;
30
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
31
+ default:
32
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
33
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
34
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
35
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
36
+ if (t[2]) _.ops.pop();
37
+ _.trys.pop(); continue;
38
+ }
39
+ op = body.call(thisArg, _);
40
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
41
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
42
+ }
43
+ };
44
+ var __values = (this && this.__values) || function(o) {
45
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
46
+ if (m) return m.call(o);
47
+ if (o && typeof o.length === "number") return {
48
+ next: function () {
49
+ if (o && i >= o.length) o = void 0;
50
+ return { value: o && o[i++], done: !o };
51
+ }
52
+ };
53
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
54
+ };
55
+ var __read = (this && this.__read) || function (o, n) {
56
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
57
+ if (!m) return o;
58
+ var i = m.call(o), r, ar = [], e;
59
+ try {
60
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
61
+ }
62
+ catch (error) { e = { error: error }; }
63
+ finally {
64
+ try {
65
+ if (r && !r.done && (m = i["return"])) m.call(i);
66
+ }
67
+ finally { if (e) throw e.error; }
68
+ }
69
+ return ar;
70
+ };
71
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
72
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
73
+ if (ar || !(i in from)) {
74
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
75
+ ar[i] = from[i];
76
+ }
77
+ }
78
+ return to.concat(ar || Array.prototype.slice.call(from));
79
+ };
80
+ !function (e, t) { "object" == typeof exports && "undefined" != typeof module ? t(exports, require("babylonjs")) : "function" == typeof define && define.amd ? define(["exports", "babylonjs"], t) : t((e = "undefined" != typeof globalThis ? globalThis : e || self).ADDONS = e.ADDONS || {}, e.BABYLON); }(this, function (e, t) {
81
+ "use strict";
82
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _f, e_6, _g, e_7, _h, e_8, _j, e_9, _k, e_10, _l, e_11, _m, e_12, _o, e_13, _p, e_14, _q, e_15, _r, e_16, _s, e_17, _u, e_18, _v;
83
+ function i(e, t, i, n) { return new (i || (i = Promise))(function (r, a) { function s(e) { try {
84
+ l(n.next(e));
85
+ }
86
+ catch (e) {
87
+ a(e);
88
+ } } function o(e) { try {
89
+ l(n.throw(e));
90
+ }
91
+ catch (e) {
92
+ a(e);
93
+ } } function l(e) { var t; e.done ? r(e.value) : (t = e.value, t instanceof i ? t : new i(function (e) { e(t); })).then(s, o); } l((n = n.apply(e, t || [])).next()); }); }
94
+ Object.create, Object.create, "function" == typeof SuppressedError && SuppressedError, t.MaterialDefines;
95
+ var n = "originOffsetKm", r = "inverseViewportSize", a = [{ name: n, size: 3, type: "vec3" }, { name: "_atmoPbrPadding1", size: 1, type: "float" }, { name: r, size: 2, type: "vec2" }], s = { x: 0, y: 0, z: 0 }, o = ["atmosphereFunctions", "atmosphereUboDeclaration", "atmosphereFragmentDeclaration"], l = ["atmosphereFunctions", "atmosphereUboDeclaration"], c = { loaded: !1, loadPromise: null, nextRetryTime: 0 }, d = { loaded: !1, loadPromise: null, nextRetryTime: 0 };
96
+ function h(e) { return 1 === e ? d : c; }
97
+ function u(e) {
98
+ var e_19, _a;
99
+ var i = t.ShaderStore.GetIncludesShadersStore(e), n = 1 === e ? l : o;
100
+ try {
101
+ for (var n_1 = __values(n), n_1_1 = n_1.next(); !n_1_1.done; n_1_1 = n_1.next()) {
102
+ var e_20 = n_1_1.value;
103
+ if (void 0 === i[e_20])
104
+ return !1;
105
+ }
106
+ }
107
+ catch (e_19_1) { e_19 = { error: e_19_1 }; }
108
+ finally {
109
+ try {
110
+ if (n_1_1 && !n_1_1.done && (_a = n_1.return)) _a.call(n_1);
111
+ }
112
+ finally { if (e_19) throw e_19.error; }
113
+ }
114
+ return !0;
115
+ }
116
+ function m(e) { return i(this, void 0, void 0, function () { var t, e_21; return __generator(this, function (_a) {
117
+ switch (_a.label) {
118
+ case 0:
119
+ t = h(e);
120
+ if (!(t.loaded || u(e))) return [3 /*break*/, 1];
121
+ t.loaded = !0;
122
+ return [3 /*break*/, 5];
123
+ case 1:
124
+ t.loadPromise || (t.loadPromise = function (e) { return i(this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
125
+ switch (_b.label) {
126
+ case 0:
127
+ if (!(1 === e)) return [3 /*break*/, 2];
128
+ return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return vt; }), Promise.resolve().then(function () { return Tt; })])];
129
+ case 1:
130
+ _a = _b.sent();
131
+ return [3 /*break*/, 4];
132
+ case 2: return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return Rt; }), Promise.resolve().then(function () { return It; }), Promise.resolve().then(function () { return Dt; })])];
133
+ case 3:
134
+ _a = _b.sent();
135
+ _b.label = 4;
136
+ case 4:
137
+ _a;
138
+ return [2 /*return*/];
139
+ }
140
+ }); }); }(e));
141
+ _a.label = 2;
142
+ case 2:
143
+ _a.trys.push([2, 4, , 5]);
144
+ return [4 /*yield*/, t.loadPromise];
145
+ case 3:
146
+ _a.sent(), t.loaded = !0;
147
+ return [3 /*break*/, 5];
148
+ case 4:
149
+ e_21 = _a.sent();
150
+ throw t.loadPromise = null, e_21;
151
+ case 5: return [2 /*return*/];
152
+ }
153
+ }); }); }
154
+ var p = /** @class */ (function (_super) {
155
+ __extends(p, _super);
156
+ function p(e, t, i) {
157
+ if (i === void 0) { i = !1; }
158
+ var _this = this;
159
+ _this = _super.call(this, e, "AtmospherePBRMaterialPlugin", 600, { USE_CUSTOM_REFLECTION: !1, CUSTOM_FRAGMENT_BEFORE_FOG: i, USE_AERIAL_PERSPECTIVE_LUT: i && t.isAerialPerspectiveLutEnabled, APPLY_AERIAL_PERSPECTIVE_INTENSITY: i && 1 !== t.aerialPerspectiveIntensity, APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS: i && 0 !== t.aerialPerspectiveRadianceBias, SAMPLE_TRANSMITTANCE_LUT: !0, EXCLUDE_RAY_MARCHING_FUNCTIONS: !0 }, !1, !0, !0) || this, _this._atmosphere = t, _this._isAerialPerspectiveEnabled = i, _this.doNotSerialize = !0, _this._pluginManager._addPlugin(_this), _this._ensureShaderIncludesLoaded();
160
+ return _this;
161
+ }
162
+ p.prototype.isCompatible = function () { return !0; };
163
+ p.prototype.getUniformBuffersNames = function (e) { var t = this._atmosphere.uniformBuffer; if (t.useUbo) {
164
+ var i_1 = 1 === this._material.shaderLanguage ? "atmosphere" : t.name;
165
+ e.push(i_1);
166
+ } };
167
+ p.prototype.getUniforms = function () { return e = this._atmosphere, { ubo: a, fragment: "uniform vec2 ".concat(r, ";\nuniform vec3 ").concat(n, ";\n"), externalUniforms: e.uniformBuffer.getUniformNames() }; var e; };
168
+ p.prototype.isReadyForSubMesh = function () { var e; if (!this._ensureShaderIncludesLoaded())
169
+ return !1; var t = this._atmosphere; if (!(null === (e = t.transmittanceLut) || void 0 === e ? void 0 : e.hasLutData) || t.diffuseSkyIrradianceLut && !t.diffuseSkyIrradianceLut.hasLutData)
170
+ return !1; if (this._isAerialPerspectiveEnabled && t.isAerialPerspectiveLutEnabled) {
171
+ var e_22 = t.aerialPerspectiveLutRenderTarget;
172
+ if (!(null == e_22 ? void 0 : e_22.isReady()))
173
+ return !1;
174
+ } return !0; };
175
+ p.prototype._ensureShaderIncludesLoaded = function () { var e = this._material.shaderLanguage, t = h(e); return t.loaded || u(e) ? (t.loaded = !0, !0) : (!t.loadPromise && Date.now() >= t.nextRetryTime && this._tryLoadShaderIncludesAsync(e, t), !1); };
176
+ p.prototype._tryLoadShaderIncludesAsync = function (e, n) { return i(this, void 0, void 0, function () { var e_23; return __generator(this, function (_a) {
177
+ switch (_a.label) {
178
+ case 0:
179
+ _a.trys.push([0, 2, , 3]);
180
+ return [4 /*yield*/, m(e)];
181
+ case 1:
182
+ _a.sent();
183
+ return [3 /*break*/, 3];
184
+ case 2:
185
+ e_23 = _a.sent();
186
+ t.Logger.Error("AtmospherePBRMaterialPlugin: Failed to load atmosphere shader includes; the atmosphere material will not render until they load. Retrying in 5s. ".concat(e_23)), n.nextRetryTime = Date.now() + 5e3;
187
+ return [3 /*break*/, 3];
188
+ case 3: return [2 /*return*/];
189
+ }
190
+ }); }); };
191
+ p.PreloadShaderIncludesAsync = function () { return i(this, arguments, void 0, function (e) {
192
+ if (e === void 0) { e = 0; }
193
+ return __generator(this, function (_a) {
194
+ switch (_a.label) {
195
+ case 0: return [4 /*yield*/, m(e)];
196
+ case 1:
197
+ _a.sent();
198
+ return [2 /*return*/];
199
+ }
200
+ });
201
+ }); };
202
+ p.prototype.getActiveTextures = function (e) { var t, i; var n = this._atmosphere; if (this._isAerialPerspectiveEnabled && n.isAerialPerspectiveLutEnabled) {
203
+ var t_1 = n.aerialPerspectiveLutRenderTarget;
204
+ t_1 && e.push(t_1);
205
+ } var r = null !== (i = null === (t = n.transmittanceLut) || void 0 === t ? void 0 : t.renderTarget) && void 0 !== i ? i : null; r && e.push(r); };
206
+ p.prototype.bindForSubMesh = function (e) { var i, a; var o = this._atmosphere, l = o.scene, c = l.getEngine(), d = e.currentEffect; d && this._atmosphere.bindUniformBufferToEffect(d), e.updateVector3(n, l.floatingOriginMode ? t.Vector3ScaleToRef(l.floatingOriginOffset, .001, s) : t.Vector3FromFloatsToRef(0, o.physicalProperties.planetRadius, 0, s)); var h = c.getRenderWidth(), u = c.getRenderHeight(); if (e.updateFloat2(r, 1 / h, 1 / u), this._isAerialPerspectiveEnabled && o.isAerialPerspectiveLutEnabled) {
207
+ var t_2 = o.aerialPerspectiveLutRenderTarget;
208
+ e.setTexture("aerialPerspectiveLut", t_2);
209
+ } var m = null !== (a = null === (i = o.transmittanceLut) || void 0 === i ? void 0 : i.renderTarget) && void 0 !== a ? a : null; e.setTexture("transmittanceLut", m); };
210
+ p.prototype.prepareDefines = function (e) { var t = e.USE_CUSTOM_REFLECTION, i = e.USE_AERIAL_PERSPECTIVE_LUT, n = e.APPLY_AERIAL_PERSPECTIVE_INTENSITY, r = e.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS; e.USE_CUSTOM_REFLECTION = null !== this._atmosphere.diffuseSkyIrradianceLut && !!e.USEIRRADIANCEMAP, e.USE_AERIAL_PERSPECTIVE_LUT = this._isAerialPerspectiveEnabled && this._atmosphere.isAerialPerspectiveLutEnabled, e.APPLY_AERIAL_PERSPECTIVE_INTENSITY = this._isAerialPerspectiveEnabled && 1 !== this._atmosphere.aerialPerspectiveIntensity, e.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS = this._isAerialPerspectiveEnabled && 0 !== this._atmosphere.aerialPerspectiveRadianceBias, t === e.USE_CUSTOM_REFLECTION && i === e.USE_AERIAL_PERSPECTIVE_LUT && n === e.APPLY_AERIAL_PERSPECTIVE_INTENSITY && r === e.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS || e.markAllAsDirty(); };
211
+ p.prototype.getSamplers = function (e) { e.push("transmittanceLut"), this._isAerialPerspectiveEnabled && this._atmosphere.isAerialPerspectiveLutEnabled && e.push("aerialPerspectiveLut"); };
212
+ p.prototype.getCustomCode = function (e, t) { if ("fragment" !== e)
213
+ return null; var i = this._atmosphere.scene.getEngine().supportsUniformBuffers ? "-light0.vLightData.xyz" : "-vLightData0.xyz", a = 1 === t || this._atmosphere.uniformBuffer.useUbo ? "#include<atmosphereUboDeclaration>" : "#include<atmosphereFragmentDeclaration>"; return 0 === t ? { CUSTOM_FRAGMENT_DEFINITIONS: this._isAerialPerspectiveEnabled && this._atmosphere.isAerialPerspectiveLutEnabled ? "uniform sampler2D transmittanceLut;\r\nprecision highp sampler2DArray;\r\nuniform sampler2DArray aerialPerspectiveLut;\r\n".concat(a, "\r\n#include<atmosphereFunctions>") : "uniform sampler2D transmittanceLut;\r\n".concat(a, "\r\n#include<atmosphereFunctions>"), CUSTOM_LIGHT0_COLOR: "\n {\n vec3 positionGlobal = 0.001 * vPositionW + ".concat(n, ";\n float positionRadius = length(positionGlobal);\n vec3 geocentricNormal = positionGlobal / positionRadius;\n vec3 directionToLight = ").concat(i, ";\n float cosAngleLightToZenith = dot(directionToLight, geocentricNormal);\n diffuse0 = lightIntensity * sampleTransmittanceLut(transmittanceLut, positionRadius, cosAngleLightToZenith);\n }\n"), CUSTOM_REFLECTION: "\n {\n vec3 positionGlobal = 0.001 * vPositionW + ".concat(n, ";\n float positionRadius = length(positionGlobal);\n vec3 geocentricNormal = positionGlobal / positionRadius;\n\n vec3 directionToLight = ").concat(i, ";\n float cosAngleLightToZenith = dot(directionToLight, geocentricNormal);\n\n vec2 uv = vec2(0.5 + 0.5 * cosAngleLightToZenith, (positionRadius - planetRadius) / atmosphereThickness);\n float irradianceScaleT = 0.5 * dot(normalW, geocentricNormal) + 0.5;\n float irradianceScale = ((-0.6652 * irradianceScaleT) + 1.5927) * irradianceScaleT + 0.1023;\n vec3 environmentIrradiance = lightIntensity * sampleReflection(irradianceSampler, uv).rgb;\n\n // Add a contribution here to estimate indirect lighting.\n const float r = 0.2;\n float indirect = getLuminanceUnclamped(environmentIrradiance) / max(0.00001, 1. - r);\n environmentIrradiance *= irradianceScale;\n environmentIrradiance += indirect;\n\n environmentIrradiance += additionalDiffuseSkyIrradiance;\n\n const float diffuseBrdf = 1. / PI;\n environmentIrradiance *= diffuseBrdf * diffuseSkyIrradianceIntensity;\n\n reflectionOut.environmentIrradiance = environmentIrradiance;\n reflectionOut.environmentRadiance.rgb = reflectionOut.environmentIrradiance;\n }\n"), CUSTOM_FRAGMENT_BEFORE_FOG: "\n #if USE_AERIAL_PERSPECTIVE_LUT\n {\n float distanceFromCameraKm = 0.001 * distance(vEyePosition.xyz, vPositionW);\n vec4 aerialPerspective = vec4(0.);\n if (sampleAerialPerspectiveLut(\n gl_FragCoord.xy * ".concat(r, ",\n true,\n distanceFromCameraKm,\n NumAerialPerspectiveLutLayers,\n AerialPerspectiveLutKMPerSlice,\n AerialPerspectiveLutRangeKM,\n aerialPerspective)) {\n finalColor = aerialPerspective + (1. - aerialPerspective.a) * finalColor;\n }\n }\n #endif\n") } : { CUSTOM_FRAGMENT_DEFINITIONS: this._isAerialPerspectiveEnabled && this._atmosphere.isAerialPerspectiveLutEnabled ? "var transmittanceLutSampler: sampler;\r\nvar transmittanceLut: texture_2d<f32>;\r\nvar aerialPerspectiveLutSampler: sampler;\r\nvar aerialPerspectiveLut: texture_2d_array<f32>;\r\n".concat(a, "\r\n#include<atmosphereFunctions>") : "var transmittanceLutSampler: sampler;\r\nvar transmittanceLut: texture_2d<f32>;\r\n".concat(a, "\r\n#include<atmosphereFunctions>"), CUSTOM_LIGHT0_COLOR: "\n {\n var positionGlobal = 0.001 * fragmentInputs.vPositionW + uniforms.".concat(n, ";\n var positionRadius = length(positionGlobal);\n var geocentricNormal = positionGlobal / positionRadius;\n var directionToLight = ").concat(i, ";\n var cosAngleLightToZenith = dot(directionToLight, geocentricNormal);\n diffuse0 = atmosphere.lightIntensity * sampleTransmittanceLut(transmittanceLut, positionRadius, cosAngleLightToZenith);\n }\n"), CUSTOM_REFLECTION: "\n {\n var positionGlobal = 0.001 * fragmentInputs.vPositionW + uniforms.".concat(n, ";\n var positionRadius = length(positionGlobal);\n var geocentricNormal = positionGlobal / positionRadius;\n\n var directionToLight = ").concat(i, ";\n var cosAngleLightToZenith = dot(directionToLight, geocentricNormal);\n\n var uv = vec2f(0.5 + 0.5 * cosAngleLightToZenith, (positionRadius - atmosphere.planetRadius) / atmosphere.atmosphereThickness);\n var irradianceScaleT = 0.5 * dot(normalW, geocentricNormal) + 0.5;\n var irradianceScale = ((-0.6652 * irradianceScaleT) + 1.5927) * irradianceScaleT + 0.1023;\n var environmentIrradiance = atmosphere.lightIntensity * textureSample(irradianceSampler, irradianceSamplerSampler, uv).rgb;\n\n // Add a contribution here to estimate indirect lighting.\n const r = 0.2;\n var indirect = getLuminanceUnclamped(environmentIrradiance) / max(0.00001, 1.0 - r);\n environmentIrradiance *= irradianceScale;\n environmentIrradiance += indirect;\n\n environmentIrradiance += atmosphere.additionalDiffuseSkyIrradiance;\n\n const diffuseBrdf = 1.0 / PI;\n environmentIrradiance *= diffuseBrdf * atmosphere.diffuseSkyIrradianceIntensity;\n\n reflectionOut.environmentIrradiance = environmentIrradiance;\n reflectionOut.environmentRadiance = vec4f(reflectionOut.environmentIrradiance, reflectionOut.environmentRadiance.a);\n }\n"), CUSTOM_FRAGMENT_BEFORE_FOG: "\n #if USE_AERIAL_PERSPECTIVE_LUT\n {\n var distanceFromCameraKm = 0.001 * distance(scene.vEyePosition.xyz, fragmentInputs.vPositionW);\n var aerialPerspective = vec4f(0.);\n if (sampleAerialPerspectiveLut(\n fragmentInputs.position.xy * uniforms.".concat(r, ",\n true,\n distanceFromCameraKm,\n NumAerialPerspectiveLutLayers,\n AerialPerspectiveLutKMPerSlice,\n AerialPerspectiveLutRangeKM,\n &aerialPerspective)) {\n finalColor = aerialPerspective + (1. - aerialPerspective.a) * finalColor;\n }\n }\n #endif\n") }; };
214
+ return p;
215
+ }(t.MaterialPluginBase));
216
+ var f = new t.Ray(t.Vector3.Zero(), t.Vector3.Zero());
217
+ var g = /** @class */ (function () {
218
+ function g() {
219
+ this._inverseViewProjectionMatrixWithoutTranslation = t.Matrix.Identity(), this._directionToLightRelativeToCameraGeocentricNormal = t.Vector3.Up(), this._cosAngleLightToZenith = 0, this._cameraRadius = 0, this._clampedCameraRadius = 0, this._cameraHeight = 0, this._clampedCameraHeight = 0, this._cameraPositionGlobal = new t.Vector3, this._clampedCameraPositionGlobal = new t.Vector3, this._cosCameraHorizonAngleFromZenith = 0, this._sinCameraAtmosphereHorizonAngleFromNadir = 0, this._cameraGeocentricNormal = t.Vector3.Up(), this._cameraForward = t.Vector3.Down(), this._cameraNearPlane = 0, this._cameraPosition = new t.Vector3, this._viewport = new t.Vector4, this._lastViewMatrix = t.Matrix.Identity(), this._lastProjectionMatrix = t.Matrix.Identity(), this._inverseViewMatrixWithoutTranslation = t.Matrix.Identity(), this._inverseProjectionMatrix = t.Matrix.Identity();
220
+ }
221
+ Object.defineProperty(g.prototype, "inverseViewProjectionMatrixWithoutTranslation", {
222
+ get: function () { return this._inverseViewProjectionMatrixWithoutTranslation; },
223
+ enumerable: false,
224
+ configurable: true
225
+ });
226
+ Object.defineProperty(g.prototype, "directionToLightRelativeToCameraGeocentricNormal", {
227
+ get: function () { return this._directionToLightRelativeToCameraGeocentricNormal; },
228
+ enumerable: false,
229
+ configurable: true
230
+ });
231
+ Object.defineProperty(g.prototype, "cosAngleLightToZenith", {
232
+ get: function () { return this._cosAngleLightToZenith; },
233
+ enumerable: false,
234
+ configurable: true
235
+ });
236
+ Object.defineProperty(g.prototype, "cameraRadius", {
237
+ get: function () { return this._cameraRadius; },
238
+ enumerable: false,
239
+ configurable: true
240
+ });
241
+ Object.defineProperty(g.prototype, "clampedCameraRadius", {
242
+ get: function () { return this._clampedCameraRadius; },
243
+ enumerable: false,
244
+ configurable: true
245
+ });
246
+ Object.defineProperty(g.prototype, "cameraHeight", {
247
+ get: function () { return this._cameraHeight; },
248
+ enumerable: false,
249
+ configurable: true
250
+ });
251
+ Object.defineProperty(g.prototype, "clampedCameraHeight", {
252
+ get: function () { return this._clampedCameraHeight; },
253
+ enumerable: false,
254
+ configurable: true
255
+ });
256
+ Object.defineProperty(g.prototype, "cameraPositionGlobal", {
257
+ get: function () { return this._cameraPositionGlobal; },
258
+ enumerable: false,
259
+ configurable: true
260
+ });
261
+ Object.defineProperty(g.prototype, "clampedCameraPositionGlobal", {
262
+ get: function () { return this._clampedCameraPositionGlobal; },
263
+ enumerable: false,
264
+ configurable: true
265
+ });
266
+ Object.defineProperty(g.prototype, "cosCameraHorizonAngleFromZenith", {
267
+ get: function () { return this._cosCameraHorizonAngleFromZenith; },
268
+ enumerable: false,
269
+ configurable: true
270
+ });
271
+ Object.defineProperty(g.prototype, "sinCameraAtmosphereHorizonAngleFromNadir", {
272
+ get: function () { return this._sinCameraAtmosphereHorizonAngleFromNadir; },
273
+ enumerable: false,
274
+ configurable: true
275
+ });
276
+ Object.defineProperty(g.prototype, "cameraGeocentricNormal", {
277
+ get: function () { return this._cameraGeocentricNormal; },
278
+ enumerable: false,
279
+ configurable: true
280
+ });
281
+ Object.defineProperty(g.prototype, "cameraForward", {
282
+ get: function () { return this._cameraForward; },
283
+ enumerable: false,
284
+ configurable: true
285
+ });
286
+ Object.defineProperty(g.prototype, "cameraNearPlane", {
287
+ get: function () { return this._cameraNearPlane; },
288
+ enumerable: false,
289
+ configurable: true
290
+ });
291
+ Object.defineProperty(g.prototype, "cameraPosition", {
292
+ get: function () { return this._cameraPosition; },
293
+ enumerable: false,
294
+ configurable: true
295
+ });
296
+ Object.defineProperty(g.prototype, "viewport", {
297
+ get: function () { return this._viewport; },
298
+ enumerable: false,
299
+ configurable: true
300
+ });
301
+ g.prototype.update = function (e, i, n, r, a, s) { this._cameraNearPlane = e.minZ, this._cameraForward.copyFrom(e.getForwardRayToRef(f, 1).direction); var o = e.getScene(), l = o.getEngine(); this._viewport.copyFromFloats(0, 0, l.getRenderWidth(), l.getRenderHeight()); var c = e.getViewMatrix(), d = e.getProjectionMatrix(), h = this._lastViewMatrix, u = this._lastProjectionMatrix; h.equals(c) && u.equals(d) || (h.copyFrom(c), h.setTranslation(t.Vector3.ZeroReadOnly), h.invertToRef(this._inverseViewMatrixWithoutTranslation), u.copyFrom(d), u.invertToRef(this._inverseProjectionMatrix), this._inverseProjectionMatrix.multiplyToRef(this._inverseViewMatrixWithoutTranslation, this._inverseViewProjectionMatrixWithoutTranslation)); var m = this._cameraPosition.copyFrom(e.globalPosition).scaleToRef(.001, this._cameraPositionGlobal); o.floatingOriginMode ? (m.normalizeToRef(this._cameraGeocentricNormal), this._cameraGeocentricNormal.scaleAndAddToRef(s, m)) : (m.y += i + s, m.normalizeToRef(this._cameraGeocentricNormal)), this._cameraRadius = m.length(), this._cameraHeight = this._cameraRadius - i, this._clampedCameraRadius = this._cameraRadius, this._clampedCameraRadius < n ? (this._clampedCameraRadius = n, this._cameraGeocentricNormal.scaleToRef(n, this._clampedCameraPositionGlobal)) : this._clampedCameraPositionGlobal.copyFrom(m), this._cosCameraHorizonAngleFromZenith = v(i, this._clampedCameraRadius), this._sinCameraAtmosphereHorizonAngleFromNadir = Math.min(1, r / this._clampedCameraRadius), this._clampedCameraHeight = this._clampedCameraRadius - i; {
302
+ this._cosAngleLightToZenith = t.Vector3Dot(a, this._cameraGeocentricNormal);
303
+ var e_24 = Math.sqrt(Math.max(0, 1 - this._cosAngleLightToZenith * this._cosAngleLightToZenith));
304
+ this._directionToLightRelativeToCameraGeocentricNormal.copyFromFloats(e_24, this._cosAngleLightToZenith, 0), this._directionToLightRelativeToCameraGeocentricNormal.normalize();
305
+ } };
306
+ return g;
307
+ }());
308
+ var v = function (e, t) { var i = Math.min(1, e / t); return -Math.sqrt(1 - i * i); }, S = new t.Vector3(.005802, .013558, .0331), _ = new t.Vector3(.003996, .003996, .003996), y = new t.Vector3(444e-6, 444e-6, 444e-6), T = new t.Vector3(65e-5, .001881, 85e-6);
309
+ var A = /** @class */ (function () {
310
+ function A(e) {
311
+ var i, n, r, a, s, o, l, c, d, h, u;
312
+ this.onChangedObservable = new t.Observable, this._peakRayleighScattering = new t.Vector3, this._peakMieScattering = new t.Vector3, this._peakMieAbsorption = new t.Vector3, this._peakOzoneAbsorption = new t.Vector3, this._planetRadiusWithOffset = 0, this._planetRadiusSquared = 0, this._atmosphereRadius = 0, this._atmosphereRadiusSquared = 0, this._horizonDistanceToAtmosphereEdge = 0, this._horizonDistanceToAtmosphereEdgeSquared = 0, this._rayleighScattering = new t.Vector3, this._mieScattering = new t.Vector3, this._mieAbsorption = new t.Vector3, this._mieExtinction = new t.Vector3, this._ozoneAbsorption = new t.Vector3, this._planetRadius = null !== (i = null == e ? void 0 : e.planetRadius) && void 0 !== i ? i : 6360, this._planetRadiusOffset = null !== (n = null == e ? void 0 : e.planetRadiusOffset) && void 0 !== n ? n : .01, this._atmosphereThickness = null !== (r = null == e ? void 0 : e.atmosphereThickness) && void 0 !== r ? r : 100, this._rayleighScatteringScale = null !== (a = null == e ? void 0 : e.rayleighScatteringScale) && void 0 !== a ? a : 1, this._peakRayleighScattering.copyFrom(null !== (s = null == e ? void 0 : e.peakRayleighScattering) && void 0 !== s ? s : S), this._mieScatteringScale = null !== (o = null == e ? void 0 : e.mieScatteringScale) && void 0 !== o ? o : 1, this._peakMieScattering.copyFrom(null !== (l = null == e ? void 0 : e.peakMieScattering) && void 0 !== l ? l : _), this._mieAbsorptionScale = null !== (c = null == e ? void 0 : e.mieAbsorptionScale) && void 0 !== c ? c : 1, this._peakMieAbsorption.copyFrom(null !== (d = null == e ? void 0 : e.peakMieAbsorption) && void 0 !== d ? d : y), this._ozoneAbsorptionScale = null !== (h = null == e ? void 0 : e.ozoneAbsorptionScale) && void 0 !== h ? h : 1, this._peakOzoneAbsorption.copyFrom(null !== (u = null == e ? void 0 : e.peakOzoneAbsorption) && void 0 !== u ? u : T), this._recomputeDimensionalParameters(), this._recomputeRayleighScattering(), this._recomputeMieScattering(), this._recomputeMieAbsorption(), this._recomputeOzoneAbsorption();
313
+ }
314
+ Object.defineProperty(A.prototype, "planetRadius", {
315
+ get: function () { return this._planetRadius; },
316
+ set: function (e) { this._planetRadius !== e && (this._planetRadius = e, this._recomputeDimensionalParameters(), this.onChangedObservable.notifyObservers(this)); },
317
+ enumerable: false,
318
+ configurable: true
319
+ });
320
+ Object.defineProperty(A.prototype, "planetRadiusSquared", {
321
+ get: function () { return this._planetRadiusSquared; },
322
+ enumerable: false,
323
+ configurable: true
324
+ });
325
+ Object.defineProperty(A.prototype, "planetRadiusOffset", {
326
+ get: function () { return this._planetRadiusOffset; },
327
+ set: function (e) { this._planetRadiusOffset !== e && (this._planetRadiusOffset = e, this._recomputeDimensionalParameters(), this.onChangedObservable.notifyObservers(this)); },
328
+ enumerable: false,
329
+ configurable: true
330
+ });
331
+ Object.defineProperty(A.prototype, "planetRadiusWithOffset", {
332
+ get: function () { return this._planetRadiusWithOffset; },
333
+ enumerable: false,
334
+ configurable: true
335
+ });
336
+ Object.defineProperty(A.prototype, "atmosphereThickness", {
337
+ get: function () { return this._atmosphereThickness; },
338
+ set: function (e) { this._atmosphereThickness !== e && (this._atmosphereThickness = e, this._recomputeDimensionalParameters(), this.onChangedObservable.notifyObservers(this)); },
339
+ enumerable: false,
340
+ configurable: true
341
+ });
342
+ Object.defineProperty(A.prototype, "atmosphereRadius", {
343
+ get: function () { return this._atmosphereRadius; },
344
+ enumerable: false,
345
+ configurable: true
346
+ });
347
+ Object.defineProperty(A.prototype, "atmosphereRadiusSquared", {
348
+ get: function () { return this._atmosphereRadiusSquared; },
349
+ enumerable: false,
350
+ configurable: true
351
+ });
352
+ Object.defineProperty(A.prototype, "horizonDistanceToAtmosphereEdge", {
353
+ get: function () { return this._horizonDistanceToAtmosphereEdge; },
354
+ enumerable: false,
355
+ configurable: true
356
+ });
357
+ Object.defineProperty(A.prototype, "horizonDistanceToAtmosphereEdgeSquared", {
358
+ get: function () { return this._horizonDistanceToAtmosphereEdgeSquared; },
359
+ enumerable: false,
360
+ configurable: true
361
+ });
362
+ Object.defineProperty(A.prototype, "rayleighScatteringScale", {
363
+ get: function () { return this._rayleighScatteringScale; },
364
+ set: function (e) { this._rayleighScatteringScale !== e && (this._rayleighScatteringScale = e, this._recomputeRayleighScattering(), this.onChangedObservable.notifyObservers(this)); },
365
+ enumerable: false,
366
+ configurable: true
367
+ });
368
+ Object.defineProperty(A.prototype, "peakRayleighScattering", {
369
+ get: function () { return this._peakRayleighScattering; },
370
+ set: function (e) { this._peakRayleighScattering.equals(e) || (this._peakRayleighScattering.copyFrom(e), this._recomputeRayleighScattering(), this.onChangedObservable.notifyObservers(this)); },
371
+ enumerable: false,
372
+ configurable: true
373
+ });
374
+ Object.defineProperty(A.prototype, "rayleighScattering", {
375
+ get: function () { return this._rayleighScattering; },
376
+ enumerable: false,
377
+ configurable: true
378
+ });
379
+ Object.defineProperty(A.prototype, "mieScatteringScale", {
380
+ get: function () { return this._mieScatteringScale; },
381
+ set: function (e) { this._mieScatteringScale !== e && (this._mieScatteringScale = e, this._recomputeMieScattering(), this.onChangedObservable.notifyObservers(this)); },
382
+ enumerable: false,
383
+ configurable: true
384
+ });
385
+ Object.defineProperty(A.prototype, "peakMieScattering", {
386
+ get: function () { return this._peakMieScattering; },
387
+ set: function (e) { this._peakMieScattering.equals(e) || (this._peakMieScattering.copyFrom(e), this._recomputeMieScattering(), this.onChangedObservable.notifyObservers(this)); },
388
+ enumerable: false,
389
+ configurable: true
390
+ });
391
+ Object.defineProperty(A.prototype, "mieScattering", {
392
+ get: function () { return this._mieScattering; },
393
+ enumerable: false,
394
+ configurable: true
395
+ });
396
+ Object.defineProperty(A.prototype, "mieAbsorptionScale", {
397
+ get: function () { return this._mieAbsorptionScale; },
398
+ set: function (e) { this._mieAbsorptionScale !== e && (this._mieAbsorptionScale = e, this._recomputeMieAbsorption(), this.onChangedObservable.notifyObservers(this)); },
399
+ enumerable: false,
400
+ configurable: true
401
+ });
402
+ Object.defineProperty(A.prototype, "peakMieAbsorption", {
403
+ get: function () { return this._peakMieAbsorption; },
404
+ set: function (e) { this._peakMieAbsorption.equals(e) || (this._peakMieAbsorption.copyFrom(e), this._recomputeMieAbsorption(), this.onChangedObservable.notifyObservers(this)); },
405
+ enumerable: false,
406
+ configurable: true
407
+ });
408
+ Object.defineProperty(A.prototype, "mieAbsorption", {
409
+ get: function () { return this._mieAbsorption; },
410
+ enumerable: false,
411
+ configurable: true
412
+ });
413
+ Object.defineProperty(A.prototype, "mieExtinction", {
414
+ get: function () { return this._mieExtinction; },
415
+ enumerable: false,
416
+ configurable: true
417
+ });
418
+ Object.defineProperty(A.prototype, "ozoneAbsorptionScale", {
419
+ get: function () { return this._ozoneAbsorptionScale; },
420
+ set: function (e) { this._ozoneAbsorptionScale !== e && (this._ozoneAbsorptionScale = e, this._recomputeOzoneAbsorption(), this.onChangedObservable.notifyObservers(this)); },
421
+ enumerable: false,
422
+ configurable: true
423
+ });
424
+ Object.defineProperty(A.prototype, "peakOzoneAbsorption", {
425
+ get: function () { return this._peakOzoneAbsorption; },
426
+ set: function (e) { this._peakOzoneAbsorption.equals(e) || (this._peakOzoneAbsorption.copyFrom(e), this._recomputeOzoneAbsorption(), this.onChangedObservable.notifyObservers(this)); },
427
+ enumerable: false,
428
+ configurable: true
429
+ });
430
+ Object.defineProperty(A.prototype, "ozoneAbsorption", {
431
+ get: function () { return this._ozoneAbsorption; },
432
+ enumerable: false,
433
+ configurable: true
434
+ });
435
+ A.prototype._recomputeDimensionalParameters = function () { this._planetRadiusWithOffset = this._planetRadius + this._planetRadiusOffset, this._planetRadiusSquared = this._planetRadius * this._planetRadius, this._atmosphereRadius = this._planetRadius + this._atmosphereThickness, this._atmosphereRadiusSquared = this._atmosphereRadius * this._atmosphereRadius, this._horizonDistanceToAtmosphereEdgeSquared = this._atmosphereRadiusSquared - this._planetRadiusSquared, this._horizonDistanceToAtmosphereEdge = Math.sqrt(this._horizonDistanceToAtmosphereEdgeSquared); };
436
+ A.prototype._recomputeRayleighScattering = function () { this._peakRayleighScattering.scaleToRef(this._rayleighScatteringScale, this._rayleighScattering); };
437
+ A.prototype._recomputeMieScattering = function () { this._peakMieScattering.scaleToRef(this._mieScatteringScale, this._mieScattering), this._recomputeMieExtinction(); };
438
+ A.prototype._recomputeMieAbsorption = function () { this._peakMieAbsorption.scaleToRef(this._mieAbsorptionScale, this._mieAbsorption), this._recomputeMieExtinction(); };
439
+ A.prototype._recomputeMieExtinction = function () { this._mieAbsorption.addToRef(this._mieScattering, this._mieExtinction); };
440
+ A.prototype._recomputeOzoneAbsorption = function () { this._peakOzoneAbsorption.scaleToRef(this._ozoneAbsorptionScale, this._ozoneAbsorption); };
441
+ return A;
442
+ }());
443
+ var P = function () { return ({ r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN }); }, L = P(), R = P(), E = P(), C = P(), x = function (e) { return e / 255; };
444
+ function I(e, i, n, r, a, s, o) {
445
+ if (o === void 0) { o = x; }
446
+ if (n <= 0 || r <= 0)
447
+ throw new Error("Sample2DRgbaToRef: widthPx and heightPx must be positive.");
448
+ var l = n * r * 4;
449
+ if (a.length < l)
450
+ throw new Error("Sample2DRgbaToRef: data length (".concat(a.length, ") is less than required (").concat(l, ")."));
451
+ e = t.Clamp(e), i = t.Clamp(i);
452
+ var c = Math.max(e * n - .5, 0), d = Math.max(i * r - .5, 0), h = Math.floor(c), u = Math.min(h + 1, n - 1), m = Math.floor(d), p = Math.min(m + 1, r - 1), f = w(h, m, n, r, a, L, o), g = w(h, p, n, r, a, R, o), v = w(u, m, n, r, a, E, o), S = w(u, p, n, r, a, C, o), _ = c - h, y = d - m, T = 1 - _, A = 1 - y, P = T * A, I = _ * A, M = T * y, b = _ * y;
453
+ return s.r = f.r * P + v.r * I + g.r * M + S.r * b, s.g = f.g * P + v.g * I + g.g * M + S.g * b, s.b = f.b * P + v.b * I + g.b * M + S.b * b, s.a = f.a * P + v.a * I + g.a * M + S.a * b, s;
454
+ }
455
+ var w = function (e, i, n, r, a, s, o) {
456
+ if (o === void 0) { o = x; }
457
+ var l = t.Clamp(e, 0, n - 1), c = 4 * (t.Clamp(i, 0, r - 1) * n + l);
458
+ return o ? (s.r = o(a[c]), s.g = o(a[c + 1]), s.b = o(a[c + 2]), s.a = o(a[c + 3])) : (s.r = a[c], s.g = a[c + 1], s.b = a[c + 2], s.a = a[c + 3]), s;
459
+ }, M = { x: Number.NaN, y: Number.NaN }, b = { r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN };
460
+ var D = /** @class */ (function () {
461
+ function D(e) {
462
+ var _this = this;
463
+ this._renderTarget = null, this._effectWrapper = null, this._effectRenderer = null, this._isDirty = !0, this._isDisposed = !1, this._needsReadPixels = !1, this._lutData = new Float32Array(0), t.RegisterEnginesExtensionsEngineRenderTarget(), t.RegisterEnginesExtensionsEngineReadTexture(), this._atmosphere = e;
464
+ var n = e.scene, r = n.getEngine(), a = "atmo-diffuseSkyIrradiance", s = r.getCaps().textureHalfFloatRender ? t.Constants.TEXTURETYPE_HALF_FLOAT : t.Constants.TEXTURETYPE_UNSIGNED_BYTE, o = this._renderTarget = new t.RenderTargetTexture(a, { width: 64, height: 16 }, n, { generateMipMaps: !1, type: s, samplingMode: t.Constants.TEXTURE_BILINEAR_SAMPLINGMODE, generateDepthBuffer: !1, gammaSpace: !1 });
465
+ o.wrapU = t.Constants.TEXTURE_CLAMP_ADDRESSMODE, o.wrapV = t.Constants.TEXTURE_CLAMP_ADDRESSMODE, o.anisotropicFilteringLevel = 1, o.skipInitialClear = !0;
466
+ var l = e.uniformBuffer, c = l.useUbo, d = r.isWebGPU && !t.EffectWrapper.ForceGLSL, h = d ? "atmosphere" : l.name;
467
+ this._effectWrapper = new t.EffectWrapper({ engine: r, name: a, vertexShader: "fullscreenTriangle", fragmentShader: "diffuseSkyIrradiance", attributeNames: ["position"], uniformNames: __spreadArray(["depth"], __read(c ? [] : l.getUniformNames()), false), uniformBuffers: c ? [h] : [], defines: ["#define POSITION_VEC2", "#define NUM_SAMPLES 128u", "#define CUSTOM_IRRADIANCE_FILTERING_INPUT", "#define CUSTOM_IRRADIANCE_FILTERING_FUNCTION"], samplers: ["transmittanceLut", "multiScatteringLut"], useShaderStore: !0, shaderLanguage: d ? 1 : 0, extraInitializationsAsync: function () { return i(_this, void 0, void 0, function () { var e, i, n; return __generator(this, function (_a) {
468
+ switch (_a.label) {
469
+ case 0: return [4 /*yield*/, Promise.all(d ? [Promise.resolve().then(function () { return Ft; }), Promise.resolve().then(function () { return zt; })] : [Promise.resolve().then(function () { return qt; }), Promise.resolve().then(function () { return jt; })])];
470
+ case 1:
471
+ _a.sent();
472
+ e = (d ? t.ShaderStore.IncludesShadersStoreWGSL : t.ShaderStore.IncludesShadersStore).hdrFilteringFunctions;
473
+ e = e.replace(/^CUSTOM_IRRADIANCE_FILTERING_INPUT\s*$/gm, ""), e = e.replace(/^CUSTOM_IRRADIANCE_FILTERING_FUNCTION\s*$/gm, d ? "var c = integrateForIrradiance(n, Ls, vec3f(0., filteringInfo.x, 0.));" : "vec3 c = integrateForIrradiance(n, Ls, vec3(0., filteringInfo.x, 0.));");
474
+ i = d ? t.ShaderStore.ShadersStoreWGSL : t.ShaderStore.ShadersStore;
475
+ n = i.diffuseSkyIrradiancePixelShader;
476
+ n = n.replace("#include<hdrFilteringFunctions>", e), i.diffuseSkyIrradiancePixelShader = n;
477
+ return [2 /*return*/];
478
+ }
479
+ }); }); } }), this._effectRenderer = new t.EffectRenderer(r, { indices: [0, 2, 1], positions: [-1, -1, -1, 3, 3, -1] }), n.environmentTexture = o, n.environmentTexture.irradianceTexture = o, n.environmentIntensity = 1, n.environmentTexture.isRenderTarget = !1;
480
+ }
481
+ Object.defineProperty(D.prototype, "isDirty", {
482
+ get: function () { return this._isDirty; },
483
+ enumerable: false,
484
+ configurable: true
485
+ });
486
+ Object.defineProperty(D.prototype, "isDisposed", {
487
+ get: function () { return this._isDisposed; },
488
+ enumerable: false,
489
+ configurable: true
490
+ });
491
+ Object.defineProperty(D.prototype, "renderTarget", {
492
+ get: function () { if (this._isDisposed || null === this._renderTarget)
493
+ throw new Error; return this._renderTarget; },
494
+ enumerable: false,
495
+ configurable: true
496
+ });
497
+ Object.defineProperty(D.prototype, "hasLutData", {
498
+ get: function () { return void 0 !== this._lutData[0]; },
499
+ enumerable: false,
500
+ configurable: true
501
+ });
502
+ D.prototype.getDiffuseSkyIrradianceToRef = function (e, i, n, r, a) { var s = this._atmosphere, o = s.additionalDiffuseSkyIrradiance, l = s.physicalProperties; if (void 0 === this._lutData[0] || i > l.atmosphereRadius)
503
+ return a.r = o.r, a.g = o.g, a.b = o.b, a; (function (e, i, n, r) { var a = t.Clamp(.5 + .5 * n), s = t.Clamp((i - e.planetRadius) / e.atmosphereThickness); r.x = .984375 * a + .0078125, r.y = .9375 * s + .03125; })(l, i, t.Vector3Dot(e, n), M), I(M.x, M.y, 64, 16, this._lutData, b, null); var c = s.diffuseSkyIrradianceIntensity; return a.r = c * (r * b.r + o.r), a.g = c * (r * b.g + o.g), a.b = c * (r * b.b + o.b), a; };
504
+ D.prototype.render = function () {
505
+ var _this = this;
506
+ var e;
507
+ var t = this._effectWrapper;
508
+ if (!this._isDirty || !(null == t ? void 0 : t.isReady()) || !(null === (e = this._renderTarget) || void 0 === e ? void 0 : e.isReady()))
509
+ return !1;
510
+ var n = this._effectRenderer;
511
+ n.saveStates();
512
+ var r = this._atmosphere.scene.getEngine();
513
+ r.bindFramebuffer(this.renderTarget.renderTarget, void 0, void 0, void 0, !0), n.setViewport(), n.applyEffectWrapper(t);
514
+ var a = t.effect;
515
+ return n.bindBuffers(a), a.setTexture("transmittanceLut", this._atmosphere.transmittanceLut.renderTarget), a.setTexture("multiScatteringLut", this._atmosphere.multiScatteringLutRenderTarget), this._atmosphere.bindUniformBufferToEffect(a), a.setFloat("depth", 0), n.draw(), n.restoreStates(), r.restoreDefaultFramebuffer(), this._isDirty = !1, this._needsReadPixels = !0, this._atmosphere.scene.onAfterRenderObservable.addOnce(function () { return i(_this, void 0, void 0, function () { return __generator(this, function (_a) {
516
+ switch (_a.label) {
517
+ case 0: return [4 /*yield*/, this.readPixelsAsync()];
518
+ case 1:
519
+ _a.sent();
520
+ return [2 /*return*/];
521
+ }
522
+ }); }); }), !0;
523
+ };
524
+ D.prototype.readPixelsAsync = function () { return i(this, void 0, void 0, function () { var e, i_2, n_2, e_25, e_26; return __generator(this, function (_a) {
525
+ switch (_a.label) {
526
+ case 0:
527
+ if (!this._needsReadPixels || this._isDisposed)
528
+ return [2 /*return*/];
529
+ this._needsReadPixels = !1;
530
+ return [4 /*yield*/, this.renderTarget.readPixels(0, 0, void 0, !0, !0)];
531
+ case 1:
532
+ e = _a.sent();
533
+ if (e && !this._isDisposed) {
534
+ i_2 = e, n_2 = this._lutData = new Float32Array(i_2.length);
535
+ if (i_2 instanceof Uint16Array)
536
+ for (e_25 = 0; e_25 < i_2.length; e_25++)
537
+ n_2[e_25] = t.FromHalfFloat(i_2[e_25]);
538
+ else
539
+ for (e_26 = 0; e_26 < i_2.length; e_26++)
540
+ n_2[e_26] = i_2[e_26] / 255;
541
+ }
542
+ return [2 /*return*/];
543
+ }
544
+ }); }); };
545
+ D.prototype.markDirty = function () { this._isDirty = !0; };
546
+ D.prototype.dispose = function () { var e, t; this._renderTarget && (this._renderTarget.irradianceTexture = null, this._renderTarget.dispose()), this._renderTarget = null, null === (e = this._effectWrapper) || void 0 === e || e.dispose(), this._effectWrapper = null, null === (t = this._effectRenderer) || void 0 === t || t.dispose(), this._effectRenderer = null, this._isDisposed = !0; };
547
+ return D;
548
+ }());
549
+ var O = .001953125, N = .00390625, V = { x: Number.NaN, y: Number.NaN }, F = { r: Number.NaN, g: Number.NaN, b: Number.NaN }, U = { x: Number.NaN, y: Number.NaN, z: Number.NaN }, k = { r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN };
550
+ var G = /** @class */ (function () {
551
+ function G(e) {
552
+ this.onUpdatedObservable = new t.Observable, this._lutData = new Float32Array(0), this._isDirty = !0, this._isDisposed = !1, this._needsReadPixels = !1, t.RegisterEnginesExtensionsEngineRenderTarget(), t.RegisterEnginesExtensionsEngineReadTexture(), this._atmosphere = e;
553
+ var i = this._atmosphere.scene, n = i.getEngine(), r = "atmo-transmittance", a = this._renderTarget = new t.RenderTargetTexture(r, { width: 256, height: 64 }, i, { type: t.Constants.TEXTURETYPE_UNSIGNED_BYTE, samplingMode: t.Constants.TEXTURE_BILINEAR_SAMPLINGMODE, generateDepthBuffer: !1, gammaSpace: !1 });
554
+ a.wrapU = t.Constants.TEXTURE_CLAMP_ADDRESSMODE, a.wrapV = t.Constants.TEXTURE_CLAMP_ADDRESSMODE, a.anisotropicFilteringLevel = 1, a.skipInitialClear = !0;
555
+ var s = e.uniformBuffer, o = s.useUbo, l = n.isWebGPU && !t.EffectWrapper.ForceGLSL, c = l ? "atmosphere" : s.name;
556
+ this._effectWrapper = new t.EffectWrapper({ engine: n, name: r, vertexShader: "fullscreenTriangle", fragmentShader: "transmittance", attributeNames: ["position"], uniformNames: __spreadArray(["depth"], __read(o ? [] : s.getUniformNames()), false), uniformBuffers: o ? [c] : [], defines: ["#define POSITION_VEC2"], useShaderStore: !0, shaderLanguage: l ? 1 : 0, extraInitializations: function (e, t) { t.push.apply(t, __spreadArray([], __read(l ? [Promise.resolve().then(function () { return Ft; }), Promise.resolve().then(function () { return Jt; })] : [Promise.resolve().then(function () { return qt; }), Promise.resolve().then(function () { return ni; })]), false)); } }), this._effectRenderer = new t.EffectRenderer(n, { indices: [0, 2, 1], positions: [-1, -1, -1, 3, 3, -1] });
557
+ }
558
+ Object.defineProperty(G.prototype, "isDirty", {
559
+ get: function () { return this._isDirty; },
560
+ enumerable: false,
561
+ configurable: true
562
+ });
563
+ Object.defineProperty(G.prototype, "renderTarget", {
564
+ get: function () { if (this._isDisposed || null === this._renderTarget)
565
+ throw new Error; return this._renderTarget; },
566
+ enumerable: false,
567
+ configurable: true
568
+ });
569
+ Object.defineProperty(G.prototype, "hasLutData", {
570
+ get: function () { return void 0 !== this._lutData[0]; },
571
+ enumerable: false,
572
+ configurable: true
573
+ });
574
+ G.prototype.getTransmittedColorToRef = function (e, i, n, r) { if (void 0 !== this._lutData[0]) {
575
+ var a_1 = t.Vector3Dot(e, n);
576
+ (function (e, i, n, r, a) { if (n > e.atmosphereRadius)
577
+ return void (a.r = a.g = a.b = a.a = 1); (function (e, t, i, n) { var r = t * t, a = Math.sqrt(Math.max(0, r - e.planetRadiusSquared)), s = r * (i * i - 1) + e.atmosphereRadiusSquared, o = Math.max(0, -t * i + Math.sqrt(Math.max(0, s))), l = Math.max(0, e.atmosphereRadius - t), c = a + e.horizonDistanceToAtmosphereEdge, d = (o - l) / Math.max(1e-6, c - l), h = a / Math.max(1e-6, e.horizonDistanceToAtmosphereEdge); n.x = .99609375 * d + O, n.y = .984375 * h + .0078125; })(e, n, r, V), I(V.x, V.y, 256, 64, i, a, null); var s = t.Clamp(t.SmoothStep(1, 0, t.Clamp((V.x - .998046875) / N))); a.r *= s, a.g *= s, a.b *= s, a.a *= s; })(this._atmosphere.physicalProperties, this._lutData, i, a_1, k), r.r = k.r, r.g = k.g, r.b = k.b;
578
+ }
579
+ else
580
+ r.r = r.g = r.b = 1; return r; };
581
+ G.prototype.updateLightParameters = function (e, t, i) { var n = e.direction; U.x = -n.x, U.y = -n.y, U.z = -n.z, this.getTransmittedColorToRef(U, t, i, F), e.diffuse.copyFromFloats(F.r, F.g, F.b), e.specular.copyFromFloats(F.r, F.g, F.b); };
582
+ G.prototype.render = function () {
583
+ var _this = this;
584
+ var e;
585
+ var t = this._effectWrapper;
586
+ if (!this._isDirty || !(null == t ? void 0 : t.isReady()) || !(null === (e = this._renderTarget) || void 0 === e ? void 0 : e.isReady()))
587
+ return !1;
588
+ var n = this._effectRenderer;
589
+ n.saveStates();
590
+ var r = this._atmosphere.scene.getEngine();
591
+ r.bindFramebuffer(this.renderTarget.renderTarget, void 0, void 0, void 0, !0), n.setViewport(), n.applyEffectWrapper(t);
592
+ var a = t.effect;
593
+ return n.bindBuffers(a), this._atmosphere.bindUniformBufferToEffect(a), a.setFloat("depth", 0), n.draw(), n.restoreStates(), r.restoreDefaultFramebuffer(), this._isDirty = !1, this._needsReadPixels = !0, this._atmosphere.scene.onAfterRenderObservable.addOnce(function () { return i(_this, void 0, void 0, function () { return __generator(this, function (_a) {
594
+ switch (_a.label) {
595
+ case 0: return [4 /*yield*/, this.readPixelsAsync()];
596
+ case 1:
597
+ _a.sent();
598
+ return [2 /*return*/];
599
+ }
600
+ }); }); }), !0;
601
+ };
602
+ G.prototype.readPixelsAsync = function () { return i(this, void 0, void 0, function () { var e, i_3, n_3, e_27, e_28; return __generator(this, function (_a) {
603
+ switch (_a.label) {
604
+ case 0:
605
+ if (!this._needsReadPixels || this._isDisposed)
606
+ return [2 /*return*/];
607
+ this._needsReadPixels = !1;
608
+ return [4 /*yield*/, this.renderTarget.readPixels(0, 0, void 0, void 0, !0)];
609
+ case 1:
610
+ e = _a.sent();
611
+ if (e && !this._isDisposed) {
612
+ i_3 = e, n_3 = this._lutData = new Float32Array(i_3.length);
613
+ if (i_3 instanceof Uint16Array)
614
+ for (e_27 = 0; e_27 < i_3.length; e_27++)
615
+ n_3[e_27] = t.FromHalfFloat(i_3[e_27]);
616
+ else
617
+ for (e_28 = 0; e_28 < i_3.length; e_28++)
618
+ n_3[e_28] = i_3[e_28] / 255;
619
+ this.onUpdatedObservable.notifyObservers();
620
+ }
621
+ return [2 /*return*/];
622
+ }
623
+ }); }); };
624
+ G.prototype.markDirty = function () { this._isDirty = !0; };
625
+ G.prototype.dispose = function () { var e, t, i; null === (e = this._renderTarget) || void 0 === e || e.dispose(), this._renderTarget = null, null === (t = this._effectWrapper) || void 0 === t || t.dispose(), this._effectWrapper = null, null === (i = this._effectRenderer) || void 0 === i || i.dispose(), this._effectRenderer = null, this._isDisposed = !0; };
626
+ return G;
627
+ }());
628
+ var z = "atmo-pbr";
629
+ var B = 0;
630
+ var H = function (e, i, n, r, a, s, o, l, c) {
631
+ if (l === void 0) { l = !1; }
632
+ var d;
633
+ var h = null !== (d = null == o ? void 0 : o.map(function (e) { return "#define ".concat(e); })) && void 0 !== d ? d : [];
634
+ return new t.EffectWrapper({ engine: e, name: i, vertexShader: "fullscreenTriangle", fragmentShader: n, attributeNames: ["position"], uniformNames: r, uniformBuffers: s, samplerNames: a, defines: h, useShaderStore: !0, shaderLanguage: l ? 1 : 0, extraInitializations: c });
635
+ }, W = function (e, i, n) { var r = i.useUbo, a = e.isWebGPU && !t.EffectWrapper.ForceGLSL, s = a ? "atmosphere" : i.name, o = ["#define POSITION_VEC2"]; return n.equals(t.Color3.BlackReadOnly) || o.push("#define USE_GROUND_ALBEDO"), new t.EffectWrapper({ engine: e, name: "atmo-multiScattering", vertexShader: "fullscreenTriangle", fragmentShader: "multiScattering", attributeNames: ["position"], uniformNames: __spreadArray(["depth"], __read(r ? [] : i.getUniformNames()), false), uniformBuffers: r ? [s] : [], samplerNames: ["transmittanceLut"], defines: o, useShaderStore: !0, shaderLanguage: a ? 1 : 0, extraInitializations: function (e, t) { t.push.apply(t, __spreadArray([], __read(a ? [Promise.resolve().then(function () { return Ft; }), Promise.resolve().then(function () { return oi; })] : [Promise.resolve().then(function () { return qt; }), Promise.resolve().then(function () { return hi; })]), false)); } }); }, q = function (e, i, n, r) { var a = n.getEngine().getCaps(), s = a.textureHalfFloatRender ? t.Constants.TEXTURETYPE_HALF_FLOAT : a.textureFloatRender ? t.Constants.TEXTURETYPE_FLOAT : t.Constants.TEXTURETYPE_UNSIGNED_BYTE, o = Object.assign({ generateMipMaps: !1, generateDepthBuffer: !1, generateStencilBuffer: !1, gammaSpace: !1, samplingMode: t.Constants.TEXTURE_BILINEAR_SAMPLINGMODE, type: s, format: t.Constants.TEXTUREFORMAT_RGBA }, r), l = new t.RenderTargetTexture(e, i, n, o); return l.wrapU = t.Constants.TEXTURE_CLAMP_ADDRESSMODE, l.wrapV = t.Constants.TEXTURE_CLAMP_ADDRESSMODE, l.anisotropicFilteringLevel = 1, l.skipInitialClear = !0, l; }, Z = function (e, i, n, r, a, s, o, l, c, d, h) {
636
+ if (s === void 0) { s = 0; }
637
+ if (o === void 0) { o = t.Constants.ALPHA_DISABLE; }
638
+ if (l === void 0) { l = !0; }
639
+ if (d === void 0) { d = t.Constants.LEQUAL; }
640
+ if (h === void 0) { h = !0; }
641
+ if (null !== r && !r.isReady() || !(null == n ? void 0 : n.isReady()))
642
+ return;
643
+ i.saveStates();
644
+ var u = e.getDepthWrite();
645
+ void 0 !== c && e.setDepthWrite(c);
646
+ var m = e.getDepthFunction();
647
+ e.setDepthFunction(d);
648
+ var p = e.getAlphaMode();
649
+ e.setAlphaMode(o, !0);
650
+ var f = e.depthCullingState.cull;
651
+ i.setViewport(), i.applyEffectWrapper(n, l), e.depthCullingState.cull = !1;
652
+ var g = n.effect;
653
+ g.setFloat("depth", s), a(i, null == r ? void 0 : r.renderTarget, g, e), e.depthCullingState.cull = f, e.setAlphaMode(p, !0), void 0 !== u && e.setDepthWrite(u), m && e.setDepthFunction(m), i.restoreStates(), h && e.restoreDefaultFramebuffer();
654
+ }, Y = function (e, i, n, r, a) { var s = i.useUbo, o = e.isWebGPU && !t.EffectWrapper.ForceGLSL, l = o ? "atmosphere" : i.name, c = ["POSITION_VEC2", "COMPUTE_WORLD_RAY"]; n && c.push("USE_SKY_VIEW_LUT"), r || c.push("OUTPUT_TO_SRGB"), a && c.push("APPLY_TRANSMITTANCE_BLENDING"); var d = n ? ["skyViewLut"] : ["transmittanceLut", "multiScatteringLut"]; return H(e, "atmo-skyCompositor", "compositeSky", __spreadArray(["depth"], __read(s ? [] : i.getUniformNames()), false), d, s ? [l] : [], c, o, function (e, t) { t.push.apply(t, __spreadArray([], __read(o ? [Promise.resolve().then(function () { return Ft; }), Promise.resolve().then(function () { return fi; })] : [Promise.resolve().then(function () { return qt; }), Promise.resolve().then(function () { return _i; })]), false)); }); }, $ = function (e, i, n, r, a, s, o, l) { var c = i.useUbo, d = e.isWebGPU && !t.EffectWrapper.ForceGLSL, h = d ? "atmosphere" : i.name, u = ["POSITION_VEC2", "COMPUTE_WORLD_RAY"]; n && u.push("USE_AERIAL_PERSPECTIVE_LUT"), r && u.push("USE_SKY_VIEW_LUT"), 1 !== o && u.push("APPLY_AERIAL_PERSPECTIVE_INTENSITY"), a || u.push("OUTPUT_TO_SRGB"), s && u.push("APPLY_TRANSMITTANCE_BLENDING"), 0 !== l && u.push("APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS"); var m = ["transmittanceLut", "multiScatteringLut", "depthTexture"]; return r && m.push("skyViewLut"), n && m.push("aerialPerspectiveLut"), H(e, "atmo-aerialPerspectiveCompositor", "compositeAerialPerspective", __spreadArray(["depth"], __read(c ? [] : i.getUniformNames()), false), m, c ? [h] : [], u, d, function (e, t) { t.push.apply(t, __spreadArray([], __read(d ? [Promise.resolve().then(function () { return Ft; }), Promise.resolve().then(function () { return Oi; })] : [Promise.resolve().then(function () { return qt; }), Promise.resolve().then(function () { return zi; })]), false)); }); }, j = function (e, i, n, r, a, s, o, l) { var c = i.useUbo, d = e.isWebGPU && !t.EffectWrapper.ForceGLSL, h = d ? "atmosphere" : i.name, u = ["POSITION_VEC2", "COMPUTE_WORLD_RAY"]; n && u.push("USE_SKY_VIEW_LUT"), 1 !== s && u.push("APPLY_AERIAL_PERSPECTIVE_INTENSITY"), r || u.push("OUTPUT_TO_SRGB"), l && u.push("HAS_DEPTH_TEXTURE"), a && u.push("APPLY_TRANSMITTANCE_BLENDING"), 0 !== o && u.push("APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS"); var m = ["transmittanceLut", "multiScatteringLut"]; return n && m.push("skyViewLut"), l && m.push("depthTexture"), H(e, "atmo-globeAtmosphereCompositor", "compositeGlobeAtmosphere", __spreadArray(["depth"], __read(c ? [] : i.getUniformNames()), false), m, c ? [h] : [], u, d, function (e, t) { t.push.apply(t, __spreadArray([], __read(d ? [Promise.resolve().then(function () { return Ft; }), Promise.resolve().then(function () { return qi; })] : [Promise.resolve().then(function () { return qt; }), Promise.resolve().then(function () { return ji; })]), false)); }); }, Q = 100, K = function (e) { return function (t, i) { var n = t.getMesh(), r = i.getMesh(), a = n.isHtmlMesh, s = r.isHtmlMesh; return a ? s && n.absolutePosition.z <= r.absolutePosition.z ? 1 : -1 : s ? 1 : e(t, i); }; };
655
+ var X = /** @class */ (function () {
656
+ function X(e, _a) {
657
+ var _b = _a === void 0 ? {} : _a, _c = _b.parentContainerId, i = _c === void 0 ? null : _c, _d = _b._containerId, n = _d === void 0 ? "css-container" : _d, _f = _b.enableOverlayRender, r = _f === void 0 ? !0 : _f, _g = _b.defaultOpaqueRenderOrder, a = _g === void 0 ? t.RenderingGroup.PainterSortCompare : _g, _h = _b.defaultAlphaTestRenderOrder, s = _h === void 0 ? t.RenderingGroup.PainterSortCompare : _h, _j = _b.defaultTransparentRenderOrder, o = _j === void 0 ? t.RenderingGroup.defaultTransparentSortCompare : _j;
658
+ var _this = this;
659
+ this._cache = { cameraData: { fov: 0, position: new t.Vector3, style: "" }, htmlMeshData: new WeakMap }, this._width = 0, this._height = 0, this._heightHalf = 0, this._temp = { scaleTransform: new t.Vector3, rotationTransform: new t.Quaternion, positionTransform: new t.Vector3, objectMatrix: t.Matrix.Identity(), cameraWorldMatrix: t.Matrix.Identity(), cameraRotationMatrix: t.Matrix.Identity(), cameraWorldMatrixAsArray: new Array(16) }, this._lastDevicePixelRatio = window.devicePixelRatio, this._cameraMatrixUpdated = !0, this._previousCanvasDocumentPosition = { top: 0, left: 0 }, this._renderObserver = null, this._onCameraMatrixChanged = function (e) { _this._cameraWorldMatrix = e.getWorldMatrix(), _this._cameraMatrixUpdated = !0; }, "undefined" != typeof document && (this._containerId = n, this._init(e, i, r, a, s, o));
660
+ }
661
+ X.prototype.dispose = function () { var e, t; this._renderObserver && (this._renderObserver.remove(), this._renderObserver = null), null === (e = this._overlayElements) || void 0 === e || e.container.remove(), this._overlayElements = null, null === (t = this._inSceneElements) || void 0 === t || t.container.remove(), this._inSceneElements = null; };
662
+ X.prototype._init = function (e, t, i, n, r, a) {
663
+ var _this = this;
664
+ var s;
665
+ if ("undefined" == typeof document)
666
+ return;
667
+ var o = t ? document.getElementById(t) : document.body;
668
+ o || (o = document.body);
669
+ var l = "".concat(this._containerId, "_in_scene");
670
+ if (this._inSceneElements = this._createRenderLayerElements(l), o.insertBefore(this._inSceneElements.container, o.firstChild), i) {
671
+ var t_3 = "".concat(this._containerId, "_overlay");
672
+ this._overlayElements = this._createRenderLayerElements(t_3);
673
+ var i_4 = +(null !== (s = e.getEngine().getRenderingCanvas().style.zIndex) && void 0 !== s ? s : "0") + 1;
674
+ this._overlayElements.container.style.zIndex = "".concat(i_4), this._overlayElements.container.style.pointerEvents = "none", o.insertBefore(this._overlayElements.container, o.firstChild);
675
+ }
676
+ this._engine = e.getEngine();
677
+ var c = this._engine.getRenderingCanvasClientRect();
678
+ if (!c)
679
+ throw new Error("Failed to get client rect for rendering canvas");
680
+ var d, h;
681
+ this._setSize(c.width, c.height), this._engine.onResizeObservable.add(function () { var e = _this._engine.getRenderingCanvasClientRect(); e && _this._setSize(e.width, e.height); });
682
+ var u = function () { var t = e.activeCamera; t && (d = t.onProjectionMatrixChangedObservable.add(function () { _this._onCameraMatrixChanged(t); }), h = t.onViewMatrixChangedObservable.add(function () { _this._onCameraMatrixChanged(t); })); };
683
+ u(), e.onActiveCameraChanged.add(function () { var t, i; d && (null === (t = e.activeCamera) || void 0 === t || t.onProjectionMatrixChangedObservable.remove(d)), h && (null === (i = e.activeCamera) || void 0 === i || i.onViewMatrixChangedObservable.remove(h)), u(); });
684
+ var m = K(n), p = K(r), f = K(a);
685
+ e.setRenderingOrder(0, m, p, f), this._renderObserver = e.onBeforeRenderObservable.add(function () { _this._render(e, e.activeCamera); });
686
+ };
687
+ X.prototype._createRenderLayerElements = function (e) { var t = document.getElementById(e); t && t.remove(); var i = document.createElement("div"); i.id = e, i.style.position = "absolute", i.style.width = "100%", i.style.height = "100%", i.style.zIndex = "-1"; var n = document.createElement("div"); n.style.overflow = "hidden"; var r = document.createElement("div"); return r.style.webkitTransformStyle = "preserve-3d", r.style.transformStyle = "preserve-3d", r.style.pointerEvents = "none", n.appendChild(r), i.appendChild(n), { container: i, domElement: n, cameraElement: r }; };
688
+ X.prototype._getSize = function () { return { width: this._width, height: this._height }; };
689
+ X.prototype._setSize = function (e, t) {
690
+ var e_29, _a;
691
+ if (this._width = e, this._height = t, this._heightHalf = this._height / 2, !this._inSceneElements || !this._overlayElements)
692
+ return;
693
+ var i = [this._inSceneElements.domElement, this._overlayElements.domElement, this._inSceneElements.cameraElement, this._overlayElements.cameraElement];
694
+ try {
695
+ for (var i_5 = __values(i), i_5_1 = i_5.next(); !i_5_1.done; i_5_1 = i_5.next()) {
696
+ var n_4 = i_5_1.value;
697
+ n_4 && (n_4.style.width = "".concat(e, "px"), n_4.style.height = "".concat(t, "px"));
698
+ }
699
+ }
700
+ catch (e_29_1) { e_29 = { error: e_29_1 }; }
701
+ finally {
702
+ try {
703
+ if (i_5_1 && !i_5_1.done && (_a = i_5.return)) _a.call(i_5);
704
+ }
705
+ finally { if (e_29) throw e_29.error; }
706
+ }
707
+ };
708
+ X.prototype._getCameraCssMatrix = function (e) { var t = e.m; return "matrix3d(".concat(this._epsilon(t[0]), ",").concat(this._epsilon(-t[1]), ",").concat(this._epsilon(t[2]), ",").concat(this._epsilon(t[3]), ",").concat(this._epsilon(t[4]), ",").concat(this._epsilon(-t[5]), ",").concat(this._epsilon(t[6]), ",").concat(this._epsilon(t[7]), ",").concat(this._epsilon(t[8]), ",").concat(this._epsilon(-t[9]), ",").concat(this._epsilon(t[10]), ",").concat(this._epsilon(t[11]), ",").concat(this._epsilon(t[12]), ",").concat(this._epsilon(-t[13]), ",").concat(this._epsilon(t[14]), ",").concat(this._epsilon(t[15]), ")"); };
709
+ X.prototype._getHtmlContentCssMatrix = function (e, t) { var i = e.m, n = t ? -1 : 1; return "matrix3d(".concat(this._epsilon(i[0]), ",").concat(this._epsilon(i[1]), ",").concat(this._epsilon(i[2] * -n), ",").concat(this._epsilon(i[3]), ",").concat(this._epsilon(-i[4]), ",").concat(this._epsilon(-i[5]), ",").concat(this._epsilon(i[6] * n), ",").concat(this._epsilon(-i[7]), ",").concat(this._epsilon(i[8] * -n), ",").concat(this._epsilon(i[9] * -n), ",").concat(this._epsilon(i[10]), ",").concat(this._epsilon(i[11] * n), ",").concat(this._epsilon(i[12] * n), ",").concat(this._epsilon(i[13] * n), ",").concat(this._epsilon(i[14] * n), ",").concat(this._epsilon(i[15]), ")"); };
710
+ X.prototype._getTransformationMatrix = function (e, i) { var n; if (this._cameraWorldMatrix || (this._cameraWorldMatrix = null === (n = e.getScene().activeCamera) || void 0 === n ? void 0 : n.getWorldMatrix()), !this._cameraWorldMatrix)
711
+ return t.Matrix.Identity(); var r = e.getWorldMatrix(); var a = 1, s = 1; e.sourceWidth && e.sourceHeight && (a = e.width / (e.sourceWidth / Q), s = e.height / (e.sourceHeight / Q)); var o = this._temp.scaleTransform, l = this._temp.rotationTransform, c = this._temp.positionTransform, d = this._temp.objectMatrix; r.decompose(o, l, c), o.x *= a, o.y *= s, t.Matrix.ComposeToRef(o, l, c, d); var h = i ? -1 : 1, u = e.getAbsolutePosition(); return d.setRowFromFloats(3, (-this._cameraWorldMatrix.m[12] + u.x) * Q * h, (-this._cameraWorldMatrix.m[13] + u.y) * Q * h, (this._cameraWorldMatrix.m[14] - u.z) * Q, this._cameraWorldMatrix.m[15] * X.PROJECTION_SCALE_FACTOR * Q), d.multiplyAtIndex(3, Q), d.multiplyAtIndex(7, Q), d.multiplyAtIndex(11, Q), d; };
712
+ X.prototype._renderHtmlMesh = function (e, i) { var n, r; if (!e.element || !e.element.firstElementChild)
713
+ return; var a = this._cache.htmlMeshData.get(e); a || (a = { style: "" }, this._cache.htmlMeshData.set(e, a)); var s = e._isCanvasOverlay ? null === (n = this._overlayElements) || void 0 === n ? void 0 : n.cameraElement : null === (r = this._inSceneElements) || void 0 === r ? void 0 : r.cameraElement; e.element.parentNode !== s && s.appendChild(e.element), e.requiresUpdate && this._updateBaseScaleFactor(e); var o = this._getTransformationMatrix(e, i); var l = "translate(-50%, -50%) ".concat(this._getHtmlContentCssMatrix(o, i)); l += i ? "matrix3d(".concat(e.billboardMode !== t.TransformNode.BILLBOARDMODE_NONE ? 1 : -1, ", 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1)") : "", a.style !== l && (e.element.style.webkitTransform = l, e.element.style.transform = l), e._markAsUpdated(); };
714
+ X.prototype._render = function (e, i) {
715
+ var e_30, _a, e_31, _b, e_32, _c, e_33, _d;
716
+ var n, r, a, s;
717
+ var o = !1;
718
+ var l = e.useRightHandedSystem;
719
+ this._updateContainerPositionIfNeeded(), this._cameraMatrixUpdated && (this._cameraMatrixUpdated = !1, o = !0), i.position.x === this._cache.cameraData.position.x && i.position.y === this._cache.cameraData.position.y && i.position.z === this._cache.cameraData.position.z || (this._cache.cameraData.position.copyFrom(i.position), o = !0), window.devicePixelRatio !== this._lastDevicePixelRatio && (this._lastDevicePixelRatio = window.devicePixelRatio, t.Logger.Log("In render - dpr changed: ", this._lastDevicePixelRatio), o = !0);
720
+ var c = e.meshes.filter(function (e) { return e.isHtmlMesh && (o || e.requiresUpdate); });
721
+ if (o = o || c.length > 0, !o)
722
+ return;
723
+ var d = i.getProjectionMatrix().m[5] * this._heightHalf;
724
+ if (this._cache.cameraData.fov !== d) {
725
+ var e_37 = [null === (n = this._overlayElements) || void 0 === n ? void 0 : n.domElement, null === (r = this._inSceneElements) || void 0 === r ? void 0 : r.domElement];
726
+ if (i.mode == t.Camera.PERSPECTIVE_CAMERA)
727
+ try {
728
+ for (var e_34 = __values(e_37), e_34_1 = e_34.next(); !e_34_1.done; e_34_1 = e_34.next()) {
729
+ var t_4 = e_34_1.value;
730
+ t_4 && (t_4.style.webkitPerspective = d + "px", t_4.style.perspective = d + "px");
731
+ }
732
+ }
733
+ catch (e_30_1) { e_30 = { error: e_30_1 }; }
734
+ finally {
735
+ try {
736
+ if (e_34_1 && !e_34_1.done && (_a = e_34.return)) _a.call(e_34);
737
+ }
738
+ finally { if (e_30) throw e_30.error; }
739
+ }
740
+ else
741
+ try {
742
+ for (var e_35 = __values(e_37), e_35_1 = e_35.next(); !e_35_1.done; e_35_1 = e_35.next()) {
743
+ var t_5 = e_35_1.value;
744
+ t_5 && (t_5.style.webkitPerspective = "", t_5.style.perspective = "");
745
+ }
746
+ }
747
+ catch (e_31_1) { e_31 = { error: e_31_1 }; }
748
+ finally {
749
+ try {
750
+ if (e_35_1 && !e_35_1.done && (_b = e_35.return)) _b.call(e_35);
751
+ }
752
+ finally { if (e_31) throw e_31.error; }
753
+ }
754
+ this._cache.cameraData.fov = d;
755
+ }
756
+ null === i.parent && i.computeWorldMatrix();
757
+ var h = this._temp.cameraWorldMatrix;
758
+ h.copyFrom(i.getWorldMatrix());
759
+ var u = this._temp.cameraRotationMatrix;
760
+ h.getRotationMatrix().transposeToRef(u);
761
+ var m = this._temp.cameraWorldMatrixAsArray;
762
+ h.copyToArray(m);
763
+ var p = l ? 1 : -1;
764
+ m[1] = u.m[1], m[2] = u.m[2] * p, m[4] = u.m[4] * p, m[6] = u.m[6] * p, m[8] = u.m[8] * p, m[9] = u.m[9] * p, t.Matrix.FromArrayToRef(m, 0, h);
765
+ var f = this._getCameraCssMatrix(h);
766
+ if (this._cache.cameraData.style !== f) {
767
+ var e_38 = [null === (a = this._inSceneElements) || void 0 === a ? void 0 : a.cameraElement, null === (s = this._overlayElements) || void 0 === s ? void 0 : s.cameraElement];
768
+ try {
769
+ for (var e_36 = __values(e_38), e_36_1 = e_36.next(); !e_36_1.done; e_36_1 = e_36.next()) {
770
+ var t_6 = e_36_1.value;
771
+ t_6 && (t_6.style.webkitTransform = f, t_6.style.transform = f);
772
+ }
773
+ }
774
+ catch (e_32_1) { e_32 = { error: e_32_1 }; }
775
+ finally {
776
+ try {
777
+ if (e_36_1 && !e_36_1.done && (_c = e_36.return)) _c.call(e_36);
778
+ }
779
+ finally { if (e_32) throw e_32.error; }
780
+ }
781
+ this._cache.cameraData.style = f;
782
+ }
783
+ try {
784
+ for (var c_1 = __values(c), c_1_1 = c_1.next(); !c_1_1.done; c_1_1 = c_1.next()) {
785
+ var e_39 = c_1_1.value;
786
+ this._renderHtmlMesh(e_39, l);
787
+ }
788
+ }
789
+ catch (e_33_1) { e_33 = { error: e_33_1 }; }
790
+ finally {
791
+ try {
792
+ if (c_1_1 && !c_1_1.done && (_d = c_1.return)) _d.call(c_1);
793
+ }
794
+ finally { if (e_33) throw e_33.error; }
795
+ }
796
+ };
797
+ X.prototype._updateBaseScaleFactor = function (e) { var t = this._width, i = this._height; var n = (e.width || 1) / (e.height || 1); n > t / i ? t = i * n : i = t / n, e.setContentSizePx(t, i); };
798
+ X.prototype._updateContainerPositionIfNeeded = function () {
799
+ var e_40, _a;
800
+ var e, i;
801
+ var n = this._engine.getRenderingCanvasClientRect();
802
+ if (!n)
803
+ return void t.Logger.Warn("Failed to update html mesh renderer position due to failure to get canvas rect. HtmlMesh instances may not render correctly");
804
+ var r = window.scrollY, a = window.scrollX, s = n.top + r, o = n.left + a;
805
+ if (this._previousCanvasDocumentPosition.top !== s || this._previousCanvasDocumentPosition.left !== o) {
806
+ this._previousCanvasDocumentPosition.top = s, this._previousCanvasDocumentPosition.left = o;
807
+ var t_8 = [null === (e = this._inSceneElements) || void 0 === e ? void 0 : e.container, null === (i = this._overlayElements) || void 0 === i ? void 0 : i.container];
808
+ try {
809
+ for (var t_7 = __values(t_8), t_7_1 = t_7.next(); !t_7_1.done; t_7_1 = t_7.next()) {
810
+ var e_41 = t_7_1.value;
811
+ if (!e_41)
812
+ continue;
813
+ var t_9 = e_41.offsetParent, i_6 = t_9.getBoundingClientRect(), n_5 = i_6.top + r, l_1 = i_6.left + a, c_2 = this._getAncestorMarginsAndPadding(t_9), d_1 = window.getComputedStyle(document.body), h_1 = parseInt(d_1.marginTop, 10), u_1 = parseInt(d_1.marginLeft, 10);
814
+ e_41.style.top = "".concat(s - n_5 - c_2.marginTop + c_2.paddingTop + h_1, "px"), e_41.style.left = "".concat(o - l_1 - c_2.marginLeft + c_2.paddingLeft + u_1, "px");
815
+ }
816
+ }
817
+ catch (e_40_1) { e_40 = { error: e_40_1 }; }
818
+ finally {
819
+ try {
820
+ if (t_7_1 && !t_7_1.done && (_a = t_7.return)) _a.call(t_7);
821
+ }
822
+ finally { if (e_40) throw e_40.error; }
823
+ }
824
+ }
825
+ };
826
+ X.prototype._epsilon = function (e) { return Math.abs(e) < 1e-10 ? 0 : e; };
827
+ X.prototype._getAncestorMarginsAndPadding = function (e) { var t = 0, i = 0, n = 0, r = 0; for (; e && e !== document.body && e !== document.documentElement;) {
828
+ var a_2 = window.getComputedStyle(e);
829
+ t += parseInt(a_2.marginTop, 10), i += parseInt(a_2.marginLeft, 10), n += parseInt(a_2.paddingTop, 10), r += parseInt(a_2.paddingLeft, 10), e = e.offsetParent;
830
+ } return { marginTop: t, marginLeft: i, paddingTop: n, paddingLeft: r }; };
831
+ return X;
832
+ }());
833
+ X.PROJECTION_SCALE_FACTOR = 1e-5;
834
+ var J = [];
835
+ var ee = new Map;
836
+ var te = [], ie = null;
837
+ var ne = function (e) { ce("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)), e && e !== ie ? re(e) ? ee.delete(e) : (ce("In pointerEventsCapture.requestRelease - Received release request ".concat(e, " but no matching capture request was received")), te.includes(e) || te.push(e)) : ae(); }, re = function (e) { var t = !1; return J = J.filter(function (i) { return i !== e || (t = !0, ce("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)), !1); }), t; }, ae = function () { var e = le(); ce("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(ie, " to ").concat(e)), se(), e && oe(e); }, se = function () { var e; ce("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(ie)), ie && (null === (e = ee.get(ie)) || void 0 === e || e.release(), ee.delete(ie), ie = null); }, oe = function (e) { var t; e && (null === (t = ee.get(e)) || void 0 === t || t.capture()), ie = e, ce("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e)); }, le = function () { return J.length > 0 ? J.shift() : null; }, ce = function (e) { ("undefined" == typeof window || window["pointer-events-capture-debug"]) && t.Tools.Log("".concat(performance.now(), " - game.scene.pointerEvents - ").concat(e, "\ncurrentOwner: ").concat(ie, "\nqueue: ").concat(J, "\nunmatched: ").concat(te)); };
838
+ var de = null, he = 0;
839
+ var ue = new WeakMap, me = function (e) { "undefined" != typeof document && (0 === he && (document.addEventListener("pointermove", ge), document.addEventListener("touchstart", ge), de = null != de ? de : e, t.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."), de.onDisposeObservable.add(pe)), he++); }, pe = function () { document.removeEventListener("pointermove", ge), document.removeEventListener("touchstart", ge), de = null, t.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."), he = 0; }, fe = function () { "undefined" != typeof document && de && (he--, he <= 0 && pe()); }, ge = function (e) { if (!de)
840
+ return; var t = de.getEngine().getRenderingCanvasClientRect(); if (!t)
841
+ return; var _a = "touches" in e ? e.touches[0] : e, i = _a.clientX, n = _a.clientY, r = i - t.left, a = n - t.top; var s; var o = de.pick(r, a, function (e) { var t = ue.get(e); return e.isEnabled() && void 0 !== t && t._captureOnPointerEnter; }); var l; l = o.hit ? o.pickedMesh : null; var c = parseInt(ie || ""); l && l.uniqueId === c || (!c || l && l.uniqueId === c || ne(ie), l && (s = ue.get(l), s.capturePointerEvents())); };
842
+ var ve = /** @class */ (function () {
843
+ function ve(e, i, _a) {
844
+ var _b = _a === void 0 ? {} : _a, _c = _b.captureOnPointerEnter, n = _c === void 0 ? !0 : _c;
845
+ this._captureCallback = e, this._releaseCallback = i, this.name = "PointerEventsCaptureBehavior", this._attachedMesh = null, this._captureOnPointerEnter = n, "undefined" == typeof document && t.Logger.Warn("Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.");
846
+ }
847
+ Object.defineProperty(ve.prototype, "attachedMesh", {
848
+ get: function () { return this._attachedMesh; },
849
+ set: function (e) { this._attachedMesh = e; },
850
+ enumerable: false,
851
+ configurable: true
852
+ });
853
+ Object.defineProperty(ve.prototype, "attachedNode", {
854
+ get: function () { return this._attachedMesh; },
855
+ enumerable: false,
856
+ configurable: true
857
+ });
858
+ Object.defineProperty(ve.prototype, "captureOnPointerEnter", {
859
+ set: function (e) { this._captureOnPointerEnter !== e && (this._captureOnPointerEnter = e, this._attachedMesh && (this._captureOnPointerEnter ? me(this._attachedMesh.getScene()) : fe())); },
860
+ enumerable: false,
861
+ configurable: true
862
+ });
863
+ ve.prototype.init = function () { };
864
+ ve.prototype.attach = function (e) { this.attachedMesh = e, ue.set(e, this), this._captureOnPointerEnter && me(e.getScene()); };
865
+ ve.prototype.detach = function () { this.attachedMesh && (ue.delete(this.attachedMesh), this._captureOnPointerEnter && fe(), this.attachedMesh = null); };
866
+ ve.prototype.dispose = function () { this.detach(); };
867
+ ve.prototype.releasePointerEvents = function () { this.attachedMesh && ne(this.attachedMesh.uniqueId.toString()); };
868
+ ve.prototype.capturePointerEvents = function () { var e, t, i; this.attachedMesh && (e = this.attachedMesh.uniqueId.toString(), t = this._captureCallback, i = this._releaseCallback, ce("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)), (function (e) { var t = !1; return te = te.filter(function (i) { return i !== e || (t = !0, !1); }), t; })(e) ? ce("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e, ". Cancelling capture request")) : (e !== ie && (function (e, t, i) { ce("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)), J.includes(e) || (J.push(e), ee.set(e, { capture: t, release: i })); })(e, t, i), ie || ae())); };
869
+ return ve;
870
+ }());
871
+ var Se = { CONTAIN: { wrapElement: function (e) { var t = document.createElement("div"); t.style.display = "flex", t.style.justifyContent = "center", t.style.alignItems = "center"; var i = document.createElement("div"); return i.style.visibility = "hidden", i.appendChild(e), t.appendChild(i), t; }, updateSize: function (e, t, i) { var n = e.firstElementChild; e.style.width = "".concat(t, "px"), e.style.height = "".concat(i, "px"); var _a = __read([n.offsetWidth, n.offsetHeight], 2), r = _a[0], a = _a[1], s = Math.min(t / r, i / a); n.style.transform = "scale(".concat(s, ")"), n.style.visibility = "visible"; } }, COVER: { wrapElement: function (e) { var t = document.createElement("div"); t.style.display = "flex", t.style.justifyContent = "center", t.style.alignItems = "center", t.style.overflow = "hidden"; var i = document.createElement("div"); return i.style.visibility = "hidden", i.appendChild(e), t.appendChild(i), t; }, updateSize: function (e, t, i) { var n = e.firstElementChild; e.style.width = "".concat(t, "px"), e.style.height = "".concat(i, "px"); var _a = __read([n.offsetWidth, n.offsetHeight], 2), r = _a[0], a = _a[1], s = Math.max(t / r, i / a); n.style.transform = "scale(".concat(s, ")"), n.style.visibility = "visible"; } }, STRETCH: { wrapElement: function (e) { var t = document.createElement("div"); t.style.display = "flex", t.style.justifyContent = "center", t.style.alignItems = "center"; var i = document.createElement("div"); return i.style.visibility = "hidden", i.appendChild(e), t.appendChild(i), t; }, updateSize: function (e, t, i) { var n = e.firstElementChild; e.style.width = "".concat(t, "px"), e.style.height = "".concat(i, "px"); var _a = __read([n.offsetWidth, n.offsetHeight], 2), r = _a[0], a = _a[1]; n.style.transform = "scale(".concat(t / r, ", ").concat(i / a, ")"), n.style.visibility = "visible"; } }, NONE: { wrapElement: function (e) { return e; }, updateSize: function (e, t, i) { e && (e.style.width = "".concat(t, "px"), e.style.height = "".concat(i, "px")); } } };
872
+ var _e = /** @class */ (function (_super) {
873
+ __extends(_e, _super);
874
+ function _e(e, i, _a) {
875
+ var _b = _a === void 0 ? {} : _a, _c = _b.captureOnPointerEnter, n = _c === void 0 ? !0 : _c, _d = _b.isCanvasOverlay, r = _d === void 0 ? !1 : _d, _f = _b.fitStrategy, a = _f === void 0 ? Se.NONE : _f;
876
+ var _this = this;
877
+ _this = _super.call(this, i, e) || this, _this._enabled = !1, _this._ready = !1, _this._isCanvasOverlay = !1, _this._requiresUpdate = !0, _this._inverseScaleMatrix = null, _this._captureOnPointerEnter = !0, _this._pointerEventCaptureBehavior = null, _this._sourceWidth = null, _this._sourceHeight = null, _this._fitStrategy = Se.NONE, "undefined" != typeof document ? (_this._fitStrategy = a, _this._isCanvasOverlay = r, _this._createMask(), _this._element = _this._createElement(), _this.setEnabled(!0), _this._captureOnPointerEnter = n, _this._pointerEventCaptureBehavior = new ve(_this.capturePointerEvents.bind(_this), _this.releasePointerEvents.bind(_this), { captureOnPointerEnter: _this._captureOnPointerEnter }), _this.addBehavior(_this._pointerEventCaptureBehavior)) : t.Logger.Warn("Creating an instance of an HtmlMesh with id ".concat(i, " outside of a browser. The mesh will not be visible."));
878
+ return _this;
879
+ }
880
+ Object.defineProperty(_e.prototype, "isHtmlMesh", {
881
+ get: function () { return !0; },
882
+ enumerable: false,
883
+ configurable: true
884
+ });
885
+ Object.defineProperty(_e.prototype, "sourceWidth", {
886
+ get: function () { return this._sourceWidth; },
887
+ enumerable: false,
888
+ configurable: true
889
+ });
890
+ Object.defineProperty(_e.prototype, "sourceHeight", {
891
+ get: function () { return this._sourceHeight; },
892
+ enumerable: false,
893
+ configurable: true
894
+ });
895
+ Object.defineProperty(_e.prototype, "width", {
896
+ get: function () { return this._width; },
897
+ enumerable: false,
898
+ configurable: true
899
+ });
900
+ Object.defineProperty(_e.prototype, "height", {
901
+ get: function () { return this._height; },
902
+ enumerable: false,
903
+ configurable: true
904
+ });
905
+ Object.defineProperty(_e.prototype, "element", {
906
+ get: function () { return this._element; },
907
+ enumerable: false,
908
+ configurable: true
909
+ });
910
+ Object.defineProperty(_e.prototype, "requiresUpdate", {
911
+ get: function () { return this._requiresUpdate; },
912
+ enumerable: false,
913
+ configurable: true
914
+ });
915
+ Object.defineProperty(_e.prototype, "captureOnPointerEnter", {
916
+ set: function (e) { this._captureOnPointerEnter = e, this._pointerEventCaptureBehavior && (this._pointerEventCaptureBehavior.captureOnPointerEnter = e); },
917
+ enumerable: false,
918
+ configurable: true
919
+ });
920
+ _e.prototype.dispose = function () { var e; _super.prototype.dispose.call(this), null === (e = this._element) || void 0 === e || e.remove(), this._element = void 0, this._pointerEventCaptureBehavior && (this._pointerEventCaptureBehavior.dispose(), this._pointerEventCaptureBehavior = null); };
921
+ _e.prototype._markAsUpdated = function () { this._requiresUpdate = !1; };
922
+ _e.prototype.setContent = function (e, t, i) { this._setAsReady(!1), this._sourceWidth = null, this._sourceHeight = null, this._element && (this._width = t, this._height = i, this._requiresUpdate = !0, this.scaling.setAll(1), e && (this._element.appendChild(this._fitStrategy.wrapElement(e)), this._updateScaleIfNecessary()), this.sourceWidth && this.sourceHeight && this._setAsReady(!0)); };
923
+ _e.prototype.setEnabled = function (e) { this._enabled = e, e && !this._ready || this._doSetEnabled(e); };
924
+ _e.prototype.setContentSizePx = function (e, t) { this._sourceWidth = e, this._sourceHeight = t, this._element && this._element.firstElementChild && (this._fitStrategy.updateSize(this._element.firstElementChild, e, t), this._updateScaleIfNecessary(), this.width && this.height && this._setAsReady(!0)); };
925
+ _e.prototype._setAsReady = function (e) { this._ready = e, e ? this._doSetEnabled(this._enabled) : this._doSetEnabled(!1); };
926
+ _e.prototype._doSetEnabled = function (e) {
927
+ var _this = this;
928
+ var t;
929
+ this._element && (e && !this._worldMatrixUpdateObserver ? this._worldMatrixUpdateObserver = this.onAfterWorldMatrixUpdateObservable.add(function () { _this._requiresUpdate = !0; }) : e || (null === (t = this._worldMatrixUpdateObserver) || void 0 === t || t.remove(), this._worldMatrixUpdateObserver = null), this._element.style.display = e ? "" : "none", this._setElementzIndex(-1e4 * this.position.z), _super.prototype.setEnabled.call(this, e));
930
+ };
931
+ _e.prototype._updateScaleIfNecessary = function () { this.scaling.setAll(1), this._inverseScaleMatrix && (this.bakeTransformIntoVertices(this._inverseScaleMatrix), this._inverseScaleMatrix = null); var e = this._width || 1, i = this._height || 1, n = t.Matrix.Scaling(e, i, 1); this.bakeTransformIntoVertices(n), this._inverseScaleMatrix = new t.Matrix, n.invertToRef(this._inverseScaleMatrix); };
932
+ _e.prototype._createMask = function () { t.CreatePlaneVertexData({ width: 1, height: 1 }).applyToMesh(this); var e = this.getScene(); this.checkCollisions = !0; var i = new t.StandardMaterial("".concat(this.id, "-mat"), e); this._isCanvasOverlay || (i.backFaceCulling = !1, i.disableColorWrite = !0, i.disableLighting = !0), this.material = i, this.material.freeze(); };
933
+ _e.prototype._setElementzIndex = function (e) { this._element && (this._element.style.zIndex = "".concat(e)); };
934
+ _e.prototype.capturePointerEvents = function () { this._element && (this._element.style.pointerEvents = "auto", document.getElementsByTagName("body")[0].style.pointerEvents = "none"); };
935
+ _e.prototype.releasePointerEvents = function () { this._element && (document.getElementsByTagName("body")[0].style.pointerEvents = "auto", this._element.style.pointerEvents = "none"); };
936
+ _e.prototype._createElement = function () { if ("undefined" == typeof document)
937
+ return; var e = document.createElement("div"); return e.id = this.id, e.style.backgroundColor = this._isCanvasOverlay ? "transparent" : "#000", e.style.zIndex = "1", e.style.position = "absolute", e.style.pointerEvents = "none", e.style.backfaceVisibility = "hidden", e; };
938
+ return _e;
939
+ }(t.Mesh));
940
+ var ye;
941
+ !function (e) { e[e.SPACE = 32] = "SPACE", e[e.TOFU = 65532] = "TOFU"; }(ye || (ye = {}));
942
+ var Te = { maxWidth: 1 / 0, lineHeight: 1, letterSpacing: 1, tabSize: 4, whiteSpace: "pre-line", textAlign: "center", translate: { x: -.5, y: -.5 } };
943
+ var Ae = /** @class */ (function () {
944
+ function Ae(e, t, i) {
945
+ this.text = e, this.fontAsset = t, this.options = Object.assign(Object.assign({}, Te), i);
946
+ var _a = this.options.customLayoutEngine ? this.options.customLayoutEngine(e, this.options) : this._computeMetrics(e), n = _a.paragraph, r = _a.lines, a = _a.glyphs, s = _a.width, o = _a.height;
947
+ this.paragraph = n, this.lines = r, this.glyphs = a, this.width = s, this.height = o;
948
+ }
949
+ Object.defineProperty(Ae.prototype, "lineHeight", {
950
+ get: function () { return this.fontAsset._font.common.lineHeight * this.options.lineHeight; },
951
+ enumerable: false,
952
+ configurable: true
953
+ });
954
+ Ae.prototype._computeMetrics = function (e) {
955
+ var e_42, _a;
956
+ var _this = this;
957
+ var t = this._collapse(e), i = this._breakLines(t).map(function (e) { return e.trim(); }), n = [];
958
+ try {
959
+ for (var i_7 = __values(i), i_7_1 = i_7.next(); !i_7_1.done; i_7_1 = i_7.next()) {
960
+ var e_43 = i_7_1.value;
961
+ n.push.apply(n, __spreadArray([], __read(this._wrap(e_43, n.length)), false));
962
+ }
963
+ }
964
+ catch (e_42_1) { e_42 = { error: e_42_1 }; }
965
+ finally {
966
+ try {
967
+ if (i_7_1 && !i_7_1.done && (_a = i_7.return)) _a.call(i_7);
968
+ }
969
+ finally { if (e_42) throw e_42.error; }
970
+ }
971
+ var r = Math.max.apply(Math, __spreadArray([], __read(n.map(function (e) { return e.width; })), false)), a = this.lineHeight * n.length;
972
+ ("left" !== this.options.textAlign || this.options.translate) && n.forEach(function (e) {
973
+ var e_44, _a;
974
+ var t = (function () { switch (_this.options.textAlign) {
975
+ case "right": return r - e.width;
976
+ case "center": return (r - e.width) / 2;
977
+ default: return 0;
978
+ } })(), i = _this.options.translate ? _this.options.translate.x * r : 0, n = _this.options.translate ? _this.options.translate.y * a : 0;
979
+ try {
980
+ for (var _b = __values(e.glyphs), _c = _b.next(); !_c.done; _c = _b.next()) {
981
+ var r_1 = _c.value;
982
+ r_1.x += t, r_1.x += i, r_1.y += n;
983
+ }
984
+ }
985
+ catch (e_44_1) { e_44 = { error: e_44_1 }; }
986
+ finally {
987
+ try {
988
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
989
+ }
990
+ finally { if (e_44) throw e_44.error; }
991
+ }
992
+ });
993
+ var s = n.flatMap(function (e) { return e.glyphs; });
994
+ return { paragraph: i.join("\n"), lines: n, glyphs: s, width: r, height: a };
995
+ };
996
+ Ae.prototype._breakLines = function (e) { return e.split("\n"); };
997
+ Ae.prototype._collapse = function (e) { return e.replace(/\t/g, " ".repeat(this.options.tabSize)).replace(/ +/g, " "); };
998
+ Ae.prototype._wrap = function (e, t) {
999
+ if (t === void 0) { t = 0; }
1000
+ var i = new Array;
1001
+ var n, r = t, a = new Array, s = 0, o = 0, l = 0, c = l;
1002
+ var d = function () { i.push({ text: e.slice(l, c), glyphs: a, start: l, end: c, width: o }); };
1003
+ for (; c < e.length;) {
1004
+ var t_10 = c, i_8 = e.charCodeAt(t_10), h_2 = this.fontAsset._getChar(i_8), u_2 = h_2.width;
1005
+ s += n ? this.fontAsset._getKerning(n.id, h_2.id) : 0;
1006
+ var m_1 = s + u_2, p_1 = h_2.xadvance + this.options.letterSpacing, f_1 = s + p_1, g_1 = f_1 > this.options.maxWidth || m_1 > this.options.maxWidth;
1007
+ g_1 && (d(), r++, n = void 0, s = 0, o = 0, l = c, c = l + 1, a = []);
1008
+ var v_1 = s, S_1 = r * this.lineHeight;
1009
+ a.push({ char: h_2, line: r, position: a.length, x: v_1, y: S_1 }), g_1 ? s = p_1 : (n = h_2, s = f_1, o = m_1, c++);
1010
+ }
1011
+ return a.length > 0 && d(), i;
1012
+ };
1013
+ return Ae;
1014
+ }());
1015
+ var Pe = /** @class */ (function () {
1016
+ function Pe(e, i, n) {
1017
+ if (i === void 0) { i = 0; }
1018
+ this._useVAO = !1, this._vertexBuffers = {}, this._charMatrices = new Array, this._charUvs = new Array, this._isDirty = !0, this._baseLine = 0, this._scalingMatrix = new t.ThinMatrix, this._fontScaleMatrix = new t.ThinMatrix, this._offsetMatrix = new t.ThinMatrix, this._translationMatrix = new t.ThinMatrix, this._baseMatrix = new t.ThinMatrix, this._scaledMatrix = new t.ThinMatrix, this._localMatrix = new t.ThinMatrix, this._finalMatrix = new t.ThinMatrix, this._lineMatrix = new t.ThinMatrix, this._parentWorldMatrix = new t.ThinMatrix, this.color = { r: 1, g: 1, b: 1, a: 1 }, this.strokeColor = { r: 1, g: 1, b: 1, a: 1 }, this.strokeInsetWidth = 0, this.strokeOutsetWidth = 0, this.thicknessControl = 0, this._parent = null, this._transformMatrix = new t.ThinMatrix, this.isBillboard = !1, this.isBillboardScreenProjected = !1, this.ignoreDepthBuffer = !1, this.writeToDepthBuffer = !1, this._engine = e, this._shaderLanguage = i, this._font = n, this._baseLine = n._font.common.lineHeight * n.scale, this._useVAO = e.getCaps().vertexArrayObject && !e.disableVertexArrayObjects;
1019
+ var r = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
1020
+ this._spriteBuffer = new t.Buffer(e, r, !1, 2), this._vertexBuffers.offsets = this._spriteBuffer.createVertexBuffer("offsets", 0, 2), this._resizeBuffers(128);
1021
+ }
1022
+ Object.defineProperty(Pe.prototype, "parent", {
1023
+ get: function () { return this._parent; },
1024
+ set: function (e) { this._parent = e; },
1025
+ enumerable: false,
1026
+ configurable: true
1027
+ });
1028
+ Object.defineProperty(Pe.prototype, "transformMatrix", {
1029
+ get: function () { return this._transformMatrix; },
1030
+ set: function (e) { this._transformMatrix = e; },
1031
+ enumerable: false,
1032
+ configurable: true
1033
+ });
1034
+ Object.defineProperty(Pe.prototype, "characterCount", {
1035
+ get: function () { return this._charMatrices.length / 16; },
1036
+ enumerable: false,
1037
+ configurable: true
1038
+ });
1039
+ Pe.prototype._resizeBuffers = function (e) { this._worldBuffer && (this._worldBuffer.dispose(), this._worldBuffer = null), this._uvBuffer && (this._uvBuffer.dispose(), this._uvBuffer = null), this._worldBuffer = new t.Buffer(this._engine, new Float32Array(16 * e), !0, 16), this._vertexBuffers.world0 = this._worldBuffer.createVertexBuffer("world0", 0, 4, 16, !0), this._vertexBuffers.world1 = this._worldBuffer.createVertexBuffer("world1", 4, 4, 16, !0), this._vertexBuffers.world2 = this._worldBuffer.createVertexBuffer("world2", 8, 4, 16, !0), this._vertexBuffers.world3 = this._worldBuffer.createVertexBuffer("world3", 12, 4, 16, !0), this._uvBuffer = new t.Buffer(this._engine, new Float32Array(4 * e), !0, 4), this._vertexBuffers.uvs = this._uvBuffer.createVertexBuffer("uvs", 0, 4, 4, !0); };
1040
+ Pe.prototype._setShaders = function (e, i) { var n; null === (n = this._drawWrapperBase) || void 0 === n || n.dispose(), this._drawWrapperBase = new t.DrawWrapper(this._engine), this._drawWrapperBase.drawContext && (this._drawWrapperBase.drawContext.useInstancing = !0), this._drawWrapperBase.effect = this._engine.createEffect({ vertexSource: e, fragmentSource: i }, ["offsets", "world0", "world1", "world2", "world3", "uvs"], ["parentWorld", "view", "projection", "uColor", "thickness", "uStrokeColor", "uStrokeInsetWidth", "uStrokeOutsetWidth", "mode", "transform", "uDepthWrite"], ["fontAtlas"], "", void 0, void 0, void 0, void 0, this._shaderLanguage), this._drawWrapperBase.effect._refCount++; };
1041
+ Pe.prototype.addParagraph = function (e, i, n) {
1042
+ var _this = this;
1043
+ var r = new Ae(e, this._font, i), a = this._font.scale, s = this._font._font.common.scaleW, o = this._font._font.common.scaleH, l = r.glyphs.filter(function (e) { return e.char.page >= 0; });
1044
+ var c = n;
1045
+ if (!c) {
1046
+ var e_45 = r.lineHeight * a, i_9 = r.lines.length * e_45 / 2;
1047
+ t.TranslationMatrixToRef(0, this._baseLine - i_9, 0, this._lineMatrix), c = this._lineMatrix;
1048
+ }
1049
+ t.ScalingMatrixToRef(a, a, 1, this._fontScaleMatrix), t.TranslationMatrixToRef(.5, -.5, 0, this._offsetMatrix);
1050
+ var d = this._charUvs.length, h = this._charMatrices.length;
1051
+ l.forEach(function (e, i) { _this._charUvs[d + 4 * i + 0] = e.char.x / s, _this._charUvs[d + 4 * i + 1] = e.char.y / o, _this._charUvs[d + 4 * i + 2] = e.char.width / s, _this._charUvs[d + 4 * i + 3] = e.char.height / o; var n = e.x + e.char.xoffset, r = 1 - (e.y + e.char.yoffset); t.ScalingMatrixToRef(e.char.width, e.char.height, 1, _this._scalingMatrix), t.MultiplyMatricesToRef(_this._offsetMatrix, _this._scalingMatrix, _this._baseMatrix), t.TranslationMatrixToRef(n * a, r * a, 0, _this._translationMatrix), t.MultiplyMatricesToRef(_this._baseMatrix, _this._fontScaleMatrix, _this._scaledMatrix), t.MultiplyMatricesToRef(_this._scaledMatrix, _this._translationMatrix, _this._localMatrix), t.MultiplyMatricesToRef(_this._localMatrix, c, _this._finalMatrix), t.CopyMatrixToArray(_this._finalMatrix, _this._charMatrices, h + 16 * i); }), this._isDirty = !0, this._baseLine -= r.lineHeight * a * r.lines.length;
1052
+ };
1053
+ Pe.prototype.clearParagraphs = function () { this._charMatrices.length = 0, this._charUvs.length = 0, this._baseLine = 0, this._isDirty = !0; };
1054
+ Pe.prototype.render = function (e, i) { var n = this._drawWrapperBase, r = n.effect; if (!r.isReady())
1055
+ return; var a = this._engine; a.setState(!1), a.enableEffect(n), this.ignoreDepthBuffer && a.setDepthBuffer(!1), this._parent ? t.CopyMatrixToRef(this._parent.getWorldMatrix(), this._parentWorldMatrix) : t.IdentityMatrixToRef(this._parentWorldMatrix), r.setInt("mode", this.isBillboard ? this.isBillboardScreenProjected ? 2 : 1 : 0), r.setMatrix("parentWorld", this._parentWorldMatrix), r.setMatrix("view", e), r.setMatrix("projection", i), r.setMatrix("transform", this.transformMatrix), r.setTexture("fontAtlas", this._font.textures[0]), r.setDirectColor4("uColor", this.color), r.setDirectColor4("uStrokeColor", this.strokeColor), r.setFloat("thickness", .9 * this.thicknessControl), r.setFloat("uStrokeInsetWidth", this.strokeInsetWidth), r.setFloat("uStrokeOutsetWidth", this.strokeOutsetWidth); var s = this.writeToDepthBuffer && !this.ignoreDepthBuffer; r.setFloat("uDepthWrite", s ? 1 : 0); var o = this._charMatrices.length / 16; this._isDirty && (this._isDirty = !1, this._worldBuffer.getBuffer().capacity / 4 < 16 * o && this._resizeBuffers(o), this._worldBuffer.update(this._charMatrices), this._uvBuffer.update(this._charUvs)), this._useVAO ? (this._vertexArrayObject || (this._vertexArrayObject = a.recordVertexArrayObject(this._vertexBuffers, null, r)), a.bindVertexArrayObject(this._vertexArrayObject, null)) : a.bindBuffers(this._vertexBuffers, null, r); var l = a, c = s && l.currentSampleCount > 1, d = l.getAlphaToCoverage(); c && l.setAlphaToCoverage(!0), a.setAlphaMode(c ? t.Constants.ALPHA_REPLACE_COLOR : t.Constants.ALPHA_COMBINE, s), s && a.setDepthWrite(!0), a.drawArraysType(t.Constants.MATERIAL_TriangleStripDrawMode, 0, 4, o), c && l.setAlphaToCoverage(d), a.unbindInstanceAttributes(), a.setAlphaMode(t.Constants.ALPHA_DISABLE), this.ignoreDepthBuffer && a.setDepthBuffer(!0); };
1056
+ Pe.prototype.dispose = function () { this._worldBuffer && (this._worldBuffer.dispose(), this._worldBuffer = null), this._uvBuffer && (this._uvBuffer.dispose(), this._uvBuffer = null), this._spriteBuffer && (this._spriteBuffer.dispose(), this._spriteBuffer = null), this._vertexArrayObject && (this._engine.releaseVertexArrayObject(this._vertexArrayObject), this._vertexArrayObject = null); };
1057
+ Pe.CreateTextRendererAsync = function (e, t) { return i(this, void 0, void 0, function () { var e_46, e_47, i, n, r, _a, a; return __generator(this, function (_b) {
1058
+ switch (_b.label) {
1059
+ case 0:
1060
+ if (!t.isWebGPU) return [3 /*break*/, 2];
1061
+ return [4 /*yield*/, Promise.resolve(BABYLON)];
1062
+ case 1:
1063
+ e_46 = (_b.sent()).RegisterEnginesWebGPUExtensionsEngineAlphaToCoverage;
1064
+ e_46();
1065
+ return [3 /*break*/, 4];
1066
+ case 2: return [4 /*yield*/, Promise.resolve(BABYLON)];
1067
+ case 3:
1068
+ e_47 = (_b.sent()).RegisterEnginesExtensionsEngineAlphaToCoverage;
1069
+ e_47();
1070
+ _b.label = 4;
1071
+ case 4:
1072
+ if (!t.getCaps().instancedArrays || !t._features.supportSpriteInstancing)
1073
+ throw new Error("Instanced arrays are required for MSDF text rendering.");
1074
+ r = 0;
1075
+ if (!t.isWebGPU) return [3 /*break*/, 7];
1076
+ r = 1;
1077
+ return [4 /*yield*/, Promise.resolve().then(function () { return Ne; })];
1078
+ case 5:
1079
+ i = (_b.sent()).msdfVertexShaderWGSL.shader;
1080
+ return [4 /*yield*/, Promise.resolve().then(function () { return ke; })];
1081
+ case 6:
1082
+ _a = (n = (_b.sent()).msdfPixelShaderWGSL.shader);
1083
+ return [3 /*break*/, 10];
1084
+ case 7: return [4 /*yield*/, Promise.resolve().then(function () { return Ce; })];
1085
+ case 8:
1086
+ i = (_b.sent()).msdfVertexShader.shader;
1087
+ return [4 /*yield*/, Promise.resolve().then(function () { return Me; })];
1088
+ case 9:
1089
+ _a = (n = (_b.sent()).msdfPixelShader.shader);
1090
+ _b.label = 10;
1091
+ case 10:
1092
+ _a;
1093
+ a = new Pe(t, r, e);
1094
+ return [2 /*return*/, (a._setShaders(i, n), a)];
1095
+ }
1096
+ }); }); };
1097
+ return Pe;
1098
+ }());
1099
+ var Le = "msdfVertexShader", Re = "#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute vec2 offsets;attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3;attribute vec4 uvs;uniform mat4 transform;uniform mat4 parentWorld;uniform mat4 view;uniform mat4 projection;uniform vec3 center;uniform int mode;varying vec2 atlasUV;void main(void) {mat4 world=mat4(world0,world1,world2,world3);vec4 worldPos=transform*(world*vec4(offsets.xy-vec2(0.5,0.5),0.,1.0));if (mode>=BILLBOARD) {vec3 viewPos=(view*parentWorld*vec4(0.,0.,0.,1.0)).xyz; \nif (mode==BILLBOARDSCREENPROJECTED) {viewPos.x/=viewPos.z;viewPos.y/=viewPos.z;viewPos.z=1.0;}\ngl_Position=projection*vec4(viewPos+worldPos.xyz,1.0); } else {vec3 viewPos=(view*parentWorld*worldPos).xyz; \ngl_Position=projection*vec4(viewPos,1.0); }\natlasUV=vec2(uvs.x+offsets.x*uvs.z,uvs.y+(1.0-offsets.y)*uvs.w);}";
1100
+ t.ShaderStore.ShadersStore[Le] || (t.ShaderStore.ShadersStore[Le] = Re);
1101
+ var Ee = { name: Le, shader: Re };
1102
+ var Ce = { __proto__: null, msdfVertexShader: Ee };
1103
+ var xe = "msdfPixelShader", Ie = "#extension GL_OES_standard_derivatives : enable\nprecision highp float;uniform sampler2D fontAtlas;uniform vec4 uColor;uniform vec4 uStrokeColor;uniform float uStrokeInsetWidth;uniform float uStrokeOutsetWidth;uniform float thickness;uniform float uDepthWrite;varying vec2 atlasUV;float median(vec3 msdf) {return max(min(msdf.r,msdf.g),min(max(msdf.r,msdf.g),msdf.b));}\nvoid main(void)\n{vec3 s=texture2D(fontAtlas,atlasUV).rgb;float sigDist=median(s)-0.5+thickness;float alpha=clamp(sigDist/fwidth(sigDist)+0.5,0.0,1.0);float sigDistOutset=sigDist+uStrokeOutsetWidth*0.5;float sigDistInset=sigDist-uStrokeInsetWidth*0.5;float outset=clamp(sigDistOutset/fwidth(sigDistOutset)+0.5,0.0,1.0);float inset=1.0-clamp(sigDistInset/fwidth(sigDistInset)+0.5,0.0,1.0);float border=outset*inset;if (uDepthWrite>0.5 && max(alpha,border)<=0.0) {discard;}\nvec4 filledFragColor=vec4(uColor.rgb,alpha*uColor.a);vec4 strokedFragColor=vec4(uStrokeColor.rgb,border*uStrokeColor.a);gl_FragColor=mix(filledFragColor,strokedFragColor,border);}";
1104
+ t.ShaderStore.ShadersStore[xe] || (t.ShaderStore.ShadersStore[xe] = Ie);
1105
+ var we = { name: xe, shader: Ie };
1106
+ var Me = { __proto__: null, msdfPixelShader: we };
1107
+ var be = "msdfVertexShader", De = "#define BILLBOARD 1\n#define BILLBOARDSCREENPROJECTED 2\nattribute offsets: vec2f;attribute world0: vec4f;attribute world1: vec4f;attribute world2: vec4f;attribute world3: vec4f;attribute uvs: vec4f;uniform transform: mat4x4f;uniform parentWorld: mat4x4f;uniform view: mat4x4f;uniform projection: mat4x4f;uniform mode: u32;varying atlasUV: vec2f;@vertex\nfn main(input: VertexInputs)->FragmentInputs {let world=mat4x4<f32>(input.world0,input.world1,input.world2,input.world3);let localOffset=vec4<f32>(input.offsets-vec2<f32>(0.5,0.5),0.0,1.0);let worldPos=uniforms.transform*world*localOffset;if (uniforms.mode>=BILLBOARD) { \nvar viewPos=(uniforms.view*uniforms.parentWorld*vec4f(0.,0.,0.,1.0)).xyz;if (uniforms.mode==BILLBOARDSCREENPROJECTED) {viewPos=vec3f(viewPos.x/viewPos.z,viewPos.y/viewPos.z,1.0);} \nvertexOutputs.position=uniforms.projection*vec4<f32>(viewPos+worldPos.xyz,1.0);} else { \nlet viewPos=(uniforms.view*uniforms.parentWorld*worldPos).xyz;vertexOutputs.position=uniforms.projection*vec4<f32>(viewPos,1.0);}\nvertexOutputs.atlasUV=vec2<f32>(\ninput.uvs.x+input.offsets.x*input.uvs.z,\ninput.uvs.y+(1.0-input.offsets.y)*input.uvs.w\n);}";
1108
+ t.ShaderStore.ShadersStoreWGSL[be] || (t.ShaderStore.ShadersStoreWGSL[be] = De);
1109
+ var Oe = { name: be, shader: De };
1110
+ var Ne = { __proto__: null, msdfVertexShaderWGSL: Oe };
1111
+ var Ve = "msdfPixelShader", Fe = "var fontAtlas: texture_2d<f32>;var fontAtlasSampler: sampler;uniform uColor: vec4f;uniform thickness: f32;uniform uStrokeColor: vec4f;uniform uStrokeInsetWidth: f32;uniform uStrokeOutsetWidth: f32;uniform uDepthWrite: f32;varying atlasUV: vec2f;fn median(msdf: vec3<f32>)->f32 {let a=min(msdf.r,msdf.g);let b=max(msdf.r,msdf.g);return max(a,min(b,msdf.b));}\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let s=textureSample(fontAtlas,fontAtlasSampler,input.atlasUV).rgb;let sigDist=median(s)-0.5+uniforms.thickness;let afwidth=length(vec2<f32>(dpdx(sigDist),dpdy(sigDist)));let alpha=clamp(sigDist/afwidth+0.5,0.0,1.0);let sigDistOutset=sigDist+uniforms.uStrokeOutsetWidth*0.5;let sigDistInset=sigDist-uniforms.uStrokeInsetWidth*0.5;let afwidthOutset=length(vec2<f32>(dpdx(sigDistOutset),dpdy(sigDistOutset)));let afwidthInset=length(vec2<f32>(dpdx(sigDistInset),dpdy(sigDistInset)));let outset=clamp(sigDistOutset/afwidthOutset+0.5,0.0,1.0);let inset=1.0-clamp(sigDistInset/afwidthInset+0.5,0.0,1.0);let border=outset*inset;if (uniforms.uDepthWrite>0.5 && max(alpha,border)<=0.0) {discard;}\nlet filledFragColor=vec4<f32>(uniforms.uColor.rgb,alpha*uniforms.uColor.a);let strokedFragColor=vec4<f32>(uniforms.uStrokeColor.rgb,border*uniforms.uStrokeColor.a);fragmentOutputs.color=mix(filledFragColor,strokedFragColor,border);}";
1112
+ t.ShaderStore.ShadersStoreWGSL[Ve] || (t.ShaderStore.ShadersStoreWGSL[Ve] = Fe);
1113
+ var Ue = { name: Ve, shader: Fe };
1114
+ var ke = { __proto__: null, msdfPixelShaderWGSL: Ue };
1115
+ function Ge() { if (!ze)
1116
+ throw new Error("Recast is not initialized. Please call InitRecast first."); return ze; }
1117
+ var ze, Be = null;
1118
+ function He(e, t, i) {
1119
+ if (e === void 0) { e = []; }
1120
+ if (t === void 0) { t = 0; }
1121
+ if (i === void 0) { i = 1; }
1122
+ return new (Ge().TileCacheMeshProcess)(function (n, r, a) { for (var e_48 = 0; e_48 < n.polyCount(); ++e_48)
1123
+ r.set(e_48, t), a.set(e_48, i); e.length > 0 && n.setOffMeshConnections(e); });
1124
+ }
1125
+ function We(e, t) { var i = !1; for (; !i;)
1126
+ i = t.update(e).upToDate; }
1127
+ function qe(e) { return $e(e); }
1128
+ function Ze(e) { var t; return Object.assign(Object.assign({}, qe(e)), { tileSize: null !== (t = e.tileSize) && void 0 !== t ? t : 32 }); }
1129
+ function Ye(e) { var i, n; var r = Object.assign(Object.assign({}, Ze(e)), { expectedLayersPerTile: null !== (i = e.expectedLayersPerTile) && void 0 !== i ? i : 1, maxObstacles: null !== (n = e.maxObstacles) && void 0 !== n ? n : 128 }); return e.tileCacheMeshProcess ? r.tileCacheMeshProcess = e.tileCacheMeshProcess : e.offMeshConnections && (t.Logger.Warn("offMeshConnections are required but no tileCacheMeshProcess is set. Using fallback DefaultTileCacheMeshProcess."), r.tileCacheMeshProcess = He(e.offMeshConnections)), r; }
1130
+ function $e(e) { return Object.fromEntries(Object.entries(e).filter(function (_a) {
1131
+ var _b = __read(_a, 2), e = _b[0], t = _b[1];
1132
+ return void 0 !== t;
1133
+ })); }
1134
+ function je(e) { return Object.fromEntries(Object.entries(e).filter(function (_a) {
1135
+ var _b = __read(_a, 2), e = _b[0], t = _b[1];
1136
+ return void 0 !== t;
1137
+ })); }
1138
+ var Qe = /** @class */ (function () {
1139
+ function Qe(e, i, n, r) {
1140
+ var _this = this;
1141
+ if (this._transforms = [], this._agents = [], this._reachRadii = [], this._agentDestinationArmed = new Array, this._agentDestination = new Array, this._onBeforeAnimationsObserver = null, this.onReachTargetObservable = new t.Observable, this._navigationPlugin = e, !e.navMesh)
1142
+ throw new Error("There is no NavMesh generated.");
1143
+ this._recastCrowd = new (Ge().Crowd)(e.navMesh, { maxAgents: i, maxAgentRadius: n }), this._scene = r, this._engine = r.getEngine(), this._onBeforeAnimationsObserver = r.onBeforeAnimationsObservable.add(function () { _this.update(.001 * _this._engine.getDeltaTime() * e.timeFactor); });
1144
+ }
1145
+ Object.defineProperty(Qe.prototype, "navigationPlugin", {
1146
+ get: function () { return this._navigationPlugin; },
1147
+ enumerable: false,
1148
+ configurable: true
1149
+ });
1150
+ Object.defineProperty(Qe.prototype, "recastCrowd", {
1151
+ get: function () { return this._recastCrowd; },
1152
+ enumerable: false,
1153
+ configurable: true
1154
+ });
1155
+ Object.defineProperty(Qe.prototype, "transforms", {
1156
+ get: function () { return this._transforms; },
1157
+ enumerable: false,
1158
+ configurable: true
1159
+ });
1160
+ Object.defineProperty(Qe.prototype, "agents", {
1161
+ get: function () { return Object.freeze(this._agents); },
1162
+ enumerable: false,
1163
+ configurable: true
1164
+ });
1165
+ Object.defineProperty(Qe.prototype, "reachRadii", {
1166
+ get: function () { return Object.freeze(this._reachRadii); },
1167
+ enumerable: false,
1168
+ configurable: true
1169
+ });
1170
+ Qe.prototype.addAgent = function (e, i, n) { var r = je(i), a = this._recastCrowd.addAgent({ x: e.x, y: e.y, z: e.z }, r); return this._transforms.push(n), this._agents.push(a.agentIndex), this._reachRadii.push(i.reachRadius ? i.reachRadius : i.radius), this._agentDestinationArmed.push(!1), this._agentDestination.push(new t.Vector3(0, 0, 0)), a.agentIndex; };
1171
+ Qe.prototype.getAgentPosition = function (e) { var i, n; var r = null !== (n = null === (i = this._recastCrowd.getAgent(e)) || void 0 === i ? void 0 : i.position()) && void 0 !== n ? n : t.Vector3.ZeroReadOnly; return new t.Vector3(r.x, r.y, r.z); };
1172
+ Qe.prototype.getAgentPositionToRef = function (e, i) { var n, r; var a = null !== (r = null === (n = this._recastCrowd.getAgent(e)) || void 0 === n ? void 0 : n.position()) && void 0 !== r ? r : t.Vector3.ZeroReadOnly; i.set(a.x, a.y, a.z); };
1173
+ Qe.prototype.getAgentVelocity = function (e) { var i, n; var r = null !== (n = null === (i = this._recastCrowd.getAgent(e)) || void 0 === i ? void 0 : i.velocity()) && void 0 !== n ? n : t.Vector3.ZeroReadOnly; return new t.Vector3(r.x, r.y, r.z); };
1174
+ Qe.prototype.getAgentVelocityToRef = function (e, i) { var n, r; var a = null !== (r = null === (n = this._recastCrowd.getAgent(e)) || void 0 === n ? void 0 : n.velocity()) && void 0 !== r ? r : t.Vector3.ZeroReadOnly; i.set(a.x, a.y, a.z); };
1175
+ Qe.prototype.getAgentNextTargetPath = function (e) { var i, n; var r = null !== (n = null === (i = this._recastCrowd.getAgent(e)) || void 0 === i ? void 0 : i.nextTargetInPath()) && void 0 !== n ? n : t.Vector3.ZeroReadOnly; return new t.Vector3(r.x, r.y, r.z); };
1176
+ Qe.prototype.getAgentNextTargetPathToRef = function (e, i) { var n, r; var a = null !== (r = null === (n = this._recastCrowd.getAgent(e)) || void 0 === n ? void 0 : n.nextTargetInPath()) && void 0 !== r ? r : t.Vector3.ZeroReadOnly; i.set(a.x, a.y, a.z); };
1177
+ Qe.prototype.getAgentState = function (e) { var t, i; return null !== (i = null === (t = this._recastCrowd.getAgent(e)) || void 0 === t ? void 0 : t.state()) && void 0 !== i ? i : 0; };
1178
+ Qe.prototype.overOffmeshConnection = function (e) { var t, i; return null !== (i = null === (t = this._recastCrowd.getAgent(e)) || void 0 === t ? void 0 : t.overOffMeshConnection()) && void 0 !== i && i; };
1179
+ Qe.prototype.agentGoto = function (e, t) { var i; null === (i = this._recastCrowd.getAgent(e)) || void 0 === i || i.requestMoveTarget(t); var n = this._agents.indexOf(e); n > -1 && (this._agentDestinationArmed[n] = !0, this._agentDestination[n].set(t.x, t.y, t.z)); };
1180
+ Qe.prototype.agentTeleport = function (e, t) { var i; null === (i = this._recastCrowd.getAgent(e)) || void 0 === i || i.teleport(t); };
1181
+ Qe.prototype.updateAgentParameters = function (e, t) { var i = this._recastCrowd.getAgent(e); if (!i)
1182
+ return; var n = i.parameters(); n && (void 0 !== t.radius && (n.radius = t.radius), void 0 !== t.height && (n.height = t.height), void 0 !== t.maxAcceleration && (n.maxAcceleration = t.maxAcceleration), void 0 !== t.maxSpeed && (n.maxSpeed = t.maxSpeed), void 0 !== t.collisionQueryRange && (n.collisionQueryRange = t.collisionQueryRange), void 0 !== t.pathOptimizationRange && (n.pathOptimizationRange = t.pathOptimizationRange), void 0 !== t.separationWeight && (n.separationWeight = t.separationWeight), i.updateParameters(n)); };
1183
+ Qe.prototype.removeAgent = function (e) { this._recastCrowd.removeAgent(e); var t = this._agents.indexOf(e); t > -1 && (this._agents.splice(t, 1), this._transforms.splice(t, 1), this._reachRadii.splice(t, 1), this._agentDestinationArmed.splice(t, 1), this._agentDestination.splice(t, 1)); };
1184
+ Qe.prototype.getAgents = function () { return this._agents; };
1185
+ Qe.prototype.update = function (e) { if (e <= t.Epsilon)
1186
+ return; var i = this._navigationPlugin.getTimeStep(), n = this._navigationPlugin.getMaximumSubStepCount(); if (i <= t.Epsilon)
1187
+ this._recastCrowd.update(e);
1188
+ else {
1189
+ var t_11 = Math.floor(e / i);
1190
+ n && t_11 > n && (t_11 = n), t_11 < 1 && (t_11 = 1);
1191
+ var r_2 = e / t_11;
1192
+ for (var e_49 = 0; e_49 < t_11; e_49++)
1193
+ this._recastCrowd.update(r_2);
1194
+ } for (var e_50 = 0; e_50 < this._agents.length; e_50++) {
1195
+ var t_12 = this._agents[e_50], i_10 = this.getAgentPosition(t_12);
1196
+ if (this._transforms[e_50].position = i_10, this._agentDestinationArmed[e_50]) {
1197
+ var n_6 = i_10.x - this._agentDestination[e_50].x, r_3 = i_10.z - this._agentDestination[e_50].z, a_3 = this._reachRadii[e_50], s_1 = this._agentDestination[e_50].y - this._reachRadii[e_50], o_1 = this._agentDestination[e_50].y + this._reachRadii[e_50], l_2 = n_6 * n_6 + r_3 * r_3;
1198
+ i_10.y > s_1 && i_10.y < o_1 && l_2 < a_3 * a_3 && (this._agentDestinationArmed[e_50] = !1, this.onReachTargetObservable.notifyObservers({ agentIndex: t_12, destination: this._agentDestination[e_50] }));
1199
+ }
1200
+ } };
1201
+ Qe.prototype.setDefaultQueryExtent = function (e) { this._navigationPlugin.setDefaultQueryExtent(e); };
1202
+ Qe.prototype.getDefaultQueryExtent = function () { var e = this._navigationPlugin.getDefaultQueryExtent(); return new t.Vector3(e.x, e.y, e.z); };
1203
+ Qe.prototype.getDefaultQueryExtentToRef = function (e) { var t = this._navigationPlugin.getDefaultQueryExtent(); e.set(t.x, t.y, t.z); };
1204
+ Qe.prototype.getCorners = function (e) { var i; var n = null === (i = this._recastCrowd.getAgent(e)) || void 0 === i ? void 0 : i.corners(); if (!n)
1205
+ return []; var r = []; for (var e_51 = 0; e_51 < n.length; e_51++)
1206
+ r.push(new t.Vector3(n[e_51].x, n[e_51].y, n[e_51].z)); return r; };
1207
+ Qe.prototype.dispose = function () { this._recastCrowd.destroy(), this._onBeforeAnimationsObserver && (this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver), this._onBeforeAnimationsObserver = null), this.onReachTargetObservable.clear(); };
1208
+ return Qe;
1209
+ }());
1210
+ function Ke(e) { var i = []; if (e.success) {
1211
+ var n_7 = e.path.length;
1212
+ for (var r_4 = 0; r_4 < n_7; r_4++) {
1213
+ var n_8 = e.path[r_4];
1214
+ i.push(new t.Vector3(n_8.x, n_8.y, n_8.z));
1215
+ }
1216
+ }
1217
+ else
1218
+ t.Logger.Warn("Unable to convert navigation path point, because navPath generation has failed."); return i; }
1219
+ var Xe = new t.Vector3, Je = new t.Vector3;
1220
+ function et(e, i, n, r, a) { return Ke(function (e, i, n, r, a) { var s, o, l, c, d, h; var u = Ge(), m = null !== (s = null == a ? void 0 : a.filter) && void 0 !== s ? s : i.defaultFilter, p = null !== (o = null == a ? void 0 : a.halfExtents) && void 0 !== o ? o : i.defaultQueryHalfExtents, f = null !== (l = null == a ? void 0 : a.maxSmoothPathPoints) && void 0 !== l ? l : 2048, g = null !== (c = null == a ? void 0 : a.maxPathPolys) && void 0 !== c ? c : 256, v = null !== (d = null == a ? void 0 : a.stepSize) && void 0 !== d ? d : .5, S = null !== (h = null == a ? void 0 : a.slop) && void 0 !== h ? h : .01, _ = i.findNearestPoly(n, { filter: m, halfExtents: p }); if (!_.success)
1221
+ return { success: !1, error: { type: "START_NEAREST_POLY_FAILED", status: _.status }, path: [] }; var y = i.findNearestPoly(r, { filter: m, halfExtents: p }); if (!y.success)
1222
+ return { success: !1, error: { type: "END_NEAREST_POLY_FAILED", status: y.status }, path: [] }; var T = _.nearestRef, A = y.nearestRef, P = i.findPath(T, A, n, r, { filter: m, maxPathPolys: g }); if (!P.success)
1223
+ return { success: !1, error: { type: "FIND_PATH_FAILED", status: P.status }, path: [] }; if (P.polys.size <= 0)
1224
+ return { success: !1, error: { type: "NO_POLYGON_PATH_FOUND" }, path: [] }; var L = P.polys.get(P.polys.size - 1); var R = r; if (L !== A) {
1225
+ var e_52 = i.closestPointOnPoly(L, r);
1226
+ if (!e_52.success)
1227
+ return { success: !1, error: { type: "NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND", status: e_52.status }, path: [] };
1228
+ R = e_52.closestPoint;
1229
+ } var E = new t.Vector3(n.x, n.y, n.z), C = new t.Vector3(R.x, R.y, R.z), x = Array.from(P.polys.getHeapView()), I = []; for (I.push(E.clone()); x.length > 0 && I.length < f;) {
1230
+ var n_9 = tt(i, E, C, S, x, u);
1231
+ if (!n_9.success)
1232
+ break;
1233
+ var r_5 = n_9.steerPosFlag & u.Detour.DT_STRAIGHTPATH_END, a_4 = n_9.steerPosFlag & u.Detour.DT_STRAIGHTPATH_OFFMESH_CONNECTION, s_2 = n_9.steerPos, o_2 = Xe.copyFrom(s_2).subtract(E);
1234
+ var l_3 = Math.sqrt(o_2.dot(o_2));
1235
+ l_3 = (r_5 || a_4) && l_3 < v ? 1 : v / l_3;
1236
+ var c_3 = Je.copyFrom(E).addInPlace(o_2.scale(l_3)), d_2 = i.moveAlongSurface(x[0], E, c_3, { filter: m, maxVisitedSize: 16 });
1237
+ if (!d_2.success)
1238
+ break;
1239
+ var h_3 = d_2.resultPosition;
1240
+ nt(x, g, d_2.visited), rt(x, e, u);
1241
+ var p_2 = i.getPolyHeight(x[0], h_3);
1242
+ if (p_2.success && (h_3.y = p_2.height), E.copyFromFloats(h_3.x, h_3.y, h_3.z), r_5 && it(E, n_9.steerPos, S, 1)) {
1243
+ E.copyFrom(C), I.length < f && I.push(new t.Vector3(E.x, E.y, E.z));
1244
+ break;
1245
+ }
1246
+ if (a_4 && it(E, n_9.steerPos, S, 1)) {
1247
+ var r_6 = n_9.steerPosRef;
1248
+ var a_5 = 0, s_3 = x[0], o_3 = 0;
1249
+ for (; o_3 < x.length && s_3 !== r_6;)
1250
+ a_5 = s_3, s_3 = x[o_3], o_3++;
1251
+ for (var e_53 = o_3; e_53 < x.length; e_53++)
1252
+ x[e_53 - o_3] = x[e_53];
1253
+ x.splice(o_3, x.length - o_3);
1254
+ var l_4 = e.getOffMeshConnectionPolyEndPoints(a_5, s_3);
1255
+ if (l_4.success && I.length < f) {
1256
+ I.push(new t.Vector3(E.x, E.y, E.z)), 1 & I.length && I.push(new t.Vector3(E.x, E.y, E.z)), E.copyFromFloats(l_4.end.x, l_4.end.y, l_4.end.z);
1257
+ var e_54 = i.getPolyHeight(x[0], E);
1258
+ e_54.success && (E.y = e_54.height);
1259
+ }
1260
+ }
1261
+ I.length < f && I.push(new t.Vector3(E.x, E.y, E.z));
1262
+ } return { success: !0, path: I }; }(e, i, n, r, a)); }
1263
+ function tt(e, i, n, r, a, s) { var o = e.findStraightPath(i, n, a, { maxStraightPathPoints: 3 }); if (!o.success)
1264
+ return { success: !1 }; var l = []; for (var e_55 = 0; e_55 < o.straightPathCount; e_55++) {
1265
+ var i_11 = new t.Vector3(o.straightPath.get(3 * e_55), o.straightPath.get(3 * e_55 + 1), o.straightPath.get(3 * e_55 + 2));
1266
+ l.push(i_11);
1267
+ } var c = 0; for (; c < l.length && !(o.straightPathFlags.get(c) & s.Detour.DT_STRAIGHTPATH_OFFMESH_CONNECTION) && it(l[c], i, r, 1e3);)
1268
+ c++; return c >= o.straightPathCount ? { success: !1 } : { success: !0, steerPos: l[c], steerPosFlag: o.straightPathFlags.get(c), steerPosRef: o.straightPathRefs.get(c), points: l }; }
1269
+ function it(e, t, i, n) { var r = t.x - e.x, a = t.y - e.y, s = t.z - e.z; return r * r + s * s < i * i && Math.abs(a) < n; }
1270
+ function nt(e, t, i) { var n = -1, r = -1; for (var t_13 = e.length - 1; t_13 >= 0; t_13--) {
1271
+ var a_6 = !1;
1272
+ for (var s_4 = i.length - 1; s_4 >= 0; s_4--)
1273
+ e[t_13] === i[s_4] && (n = t_13, r = s_4, a_6 = !0);
1274
+ if (a_6)
1275
+ break;
1276
+ } if (-1 === n || -1 === r)
1277
+ return e; var a = i.length - r, s = Math.min(n + 1, e.length); var o = Math.max(0, e.length - s); a + o > t && (o = t - a), o && e.splice.apply(e, __spreadArray([a, o], __read(e.slice(s, s + o)), false)); for (var t_14 = 0; t_14 < a; t_14++)
1278
+ e[t_14] = i[i.length - (1 + t_14)]; return e; }
1279
+ function rt(e, t, i) { if (e.length < 3)
1280
+ return; var n = 0; var r = [], a = t.getTileAndPolyByRef(e[0]); if (!a.success)
1281
+ return; var s = a.poly, o = a.tile; for (var e_56 = s.firstLink(); e_56 !== i.Detour.DT_NULL_LINK; e_56 = o.links(e_56).next()) {
1282
+ var t_15 = o.links(e_56);
1283
+ 0 !== t_15.ref() && n < 16 && (r.push(t_15.ref()), n++);
1284
+ } var l = 0; for (var t_16 = Math.min(6, e.length) - 1; t_16 > 1 && 0 === l; t_16--)
1285
+ for (var i_12 = 0; i_12 < n; i_12++)
1286
+ if (e[t_16] === r[i_12]) {
1287
+ l = t_16;
1288
+ break;
1289
+ } l > 1 && e.splice(1, l - 1); }
1290
+ function at(e, i) { var n, r, a, s = 0; var o = [], l = []; for (n = 0; n < e.length; n++)
1291
+ if (e[n]) {
1292
+ var c_4 = e[n], d_3 = (null == i ? void 0 : i.doNotReverseIndices) ? c_4.getIndices(!1, !0) : st(c_4);
1293
+ if (!d_3)
1294
+ continue;
1295
+ var h_4 = c_4.getVerticesData(t.VertexBuffer.PositionKind, !1, !1);
1296
+ if (!h_4)
1297
+ continue;
1298
+ var u_3 = [], m_2 = c_4.computeWorldMatrix(!0);
1299
+ if (c_4.hasThinInstances) {
1300
+ var e_57 = c_4.thinInstanceGetWorldMatrices();
1301
+ for (var i_13 = 0; i_13 < e_57.length; i_13++) {
1302
+ var n_10 = new t.Matrix;
1303
+ e_57[i_13].multiplyToRef(m_2, n_10), u_3.push(n_10);
1304
+ }
1305
+ }
1306
+ else
1307
+ u_3.push(m_2);
1308
+ var p_3 = t.Vector3.Zero(), f_2 = t.Vector3.Zero();
1309
+ for (var e_58 = 0; e_58 < u_3.length; e_58++) {
1310
+ var i_14 = u_3[e_58];
1311
+ for (r = 0; r < d_3.length; r++)
1312
+ l.push(d_3[r] + s);
1313
+ for (a = 0; a < h_4.length; a += 3)
1314
+ t.Vector3.FromArrayToRef(h_4, a, f_2), t.Vector3.TransformCoordinatesToRef(f_2, i_14, p_3), o.push(p_3.x, p_3.y, p_3.z);
1315
+ s += h_4.length / 3;
1316
+ }
1317
+ } return [Float32Array.from(o), Uint32Array.from(l)]; }
1318
+ function st(e) {
1319
+ var _a;
1320
+ var i = e instanceof t.Mesh ? e.getIndices(!1, !0) : e;
1321
+ if (i)
1322
+ for (var e_59 = 0; e_59 < i.length; e_59 += 3)
1323
+ _a = __read([i[e_59 + 2], i[e_59 + 1]], 2), i[e_59 + 1] = _a[0], i[e_59 + 2] = _a[1];
1324
+ return i;
1325
+ }
1326
+ function ot(e, i, n, r) { var _a = __read(Ge().getNavMeshPositionsAndIndices(e, r), 2), a = _a[0], s = _a[1], o = new t.Mesh("NavMeshDebug", i), l = new t.VertexData; return l.indices = st(s), l.positions = a, l.applyToMesh(o, !1), n && (o.parent = n), o; }
1327
+ function lt(e, i) { var n, r; var a = Ge(); if (0 === e.length)
1328
+ throw new Error("At least one mesh is needed to create the nav mesh."); var _a = __read(at(e, { doNotReverseIndices: i.doNotReverseIndices }), 2), s = _a[0], o = _a[1]; if (!s || !o)
1329
+ throw new Error("Unable to get nav mesh. No vertices or indices."); var l = null !== (n = i.tileSize) && void 0 !== n ? n : 0, c = (null !== (r = i.maxObstacles) && void 0 !== r ? r : 0) > 0, d = l > 0; c && (l < 32 || l > 64) && t.Logger.Warn("NavigationPlugin: Tile cache is enabled. Recommended tileSize is 32 to 64. Other values may lead to unexpected behavior."); var h = c ? Ye(i) : d ? Ze(i) : qe(i), u = c ? a.generateTileCache(s, o, h, i.keepIntermediates) : d ? a.generateTiledNavMesh(s, o, h, i.keepIntermediates) : a.generateSoloNavMesh(s, o, h, i.keepIntermediates); if (!u.success)
1330
+ throw new Error("Unable to generateSoloNavMesh: ".concat(u.error)); return { navMesh: u.navMesh, intermediates: u.intermediates, navMeshQuery: new a.NavMeshQuery(u.navMesh), tileCache: "tileCache" in u ? u.tileCache : void 0 }; }
1331
+ function ct(e) {
1332
+ var _this = this;
1333
+ e.createNavMeshImpl = function (e, t) { return lt(e, t); }, e.createNavMeshAsyncImpl = function (e, t) { return i(_this, void 0, void 0, function () { return __generator(this, function (_a) {
1334
+ switch (_a.label) {
1335
+ case 0: return [4 /*yield*/, new Promise(function (i) { i(lt(e, t)); })];
1336
+ case 1: return [2 /*return*/, _a.sent()];
1337
+ }
1338
+ }); }); };
1339
+ }
1340
+ var dt = /** @class */ (function () {
1341
+ function dt(e) {
1342
+ this.name = "RecastNavigationJSPlugin", this._maximumSubStepCount = 10, this._timeStep = 1 / 60, this._timeFactor = 1, e || (e = Ge(), ct(this)), this.bjsRECAST = e, this.isSupported() ? this.setTimeStep() : t.Logger.Error("RecastJS is not available. Please make sure you included the js file.");
1343
+ }
1344
+ Object.defineProperty(dt.prototype, "navMeshQuery", {
1345
+ get: function () { return this._navMeshQuery; },
1346
+ enumerable: false,
1347
+ configurable: true
1348
+ });
1349
+ Object.defineProperty(dt.prototype, "intermediates", {
1350
+ get: function () { return this._intermediates; },
1351
+ enumerable: false,
1352
+ configurable: true
1353
+ });
1354
+ Object.defineProperty(dt.prototype, "tileCache", {
1355
+ get: function () { return this._tileCache; },
1356
+ enumerable: false,
1357
+ configurable: true
1358
+ });
1359
+ dt.prototype.setTimeStep = function (e) {
1360
+ if (e === void 0) { e = 1 / 60; }
1361
+ this._timeStep = e;
1362
+ };
1363
+ dt.prototype.getTimeStep = function () { return this._timeStep; };
1364
+ dt.prototype.setMaximumSubStepCount = function (e) {
1365
+ if (e === void 0) { e = 10; }
1366
+ this._maximumSubStepCount = e;
1367
+ };
1368
+ dt.prototype.getMaximumSubStepCount = function () { return this._maximumSubStepCount; };
1369
+ Object.defineProperty(dt.prototype, "timeFactor", {
1370
+ get: function () { return this._timeFactor; },
1371
+ set: function (e) { this._timeFactor = Math.max(e, 0); },
1372
+ enumerable: false,
1373
+ configurable: true
1374
+ });
1375
+ dt.prototype.createNavMesh = function (e, t) { if (!this.createNavMeshImpl)
1376
+ throw new Error("Function not injected yet. Use the factory to create the plugin."); this._preprocessParameters(t); var i = this.createNavMeshImpl(e, t); return this._processNavMeshResult(i); };
1377
+ dt.prototype.createNavMeshAsync = function (e, t) { return i(this, void 0, void 0, function () { var i; return __generator(this, function (_a) {
1378
+ switch (_a.label) {
1379
+ case 0:
1380
+ if (!this.createNavMeshAsyncImpl)
1381
+ throw new Error("Function not injected yet. Use the factory to create the plugin.");
1382
+ this._preprocessParameters(t);
1383
+ return [4 /*yield*/, this.createNavMeshAsyncImpl(e, t)];
1384
+ case 1:
1385
+ i = _a.sent();
1386
+ return [2 /*return*/, this._processNavMeshResult(i)];
1387
+ }
1388
+ }); }); };
1389
+ dt.prototype.createDebugNavMesh = function (e) { if (!this.navMesh)
1390
+ throw new Error("There is no navMesh generated."); return this.navMesh && this._tileCache && We(this.navMesh, this._tileCache), ot(this.navMesh, e); };
1391
+ dt.prototype.getClosestPoint = function (e, i) { var n = this._navMeshQuery.findClosestPoint(e, i); return new t.Vector3(n.point.x, n.point.y, n.point.z); };
1392
+ dt.prototype.getClosestPointToRef = function (e, t, i) { var n = this._navMeshQuery.findClosestPoint(e, i); t.set(n.point.x, n.point.y, n.point.z); };
1393
+ dt.prototype.getRandomPointAround = function (e, i, n) { var r = this._navMeshQuery.findRandomPointAroundCircle(e, i, n); return new t.Vector3(r.randomPoint.x, r.randomPoint.y, r.randomPoint.z); };
1394
+ dt.prototype.getRandomPointAroundToRef = function (e, t, i, n) { var r = this._navMeshQuery.findRandomPointAroundCircle(e, t, n); i.set(r.randomPoint.x, r.randomPoint.y, r.randomPoint.z); };
1395
+ dt.prototype.moveAlong = function (e, i, n, r) {
1396
+ if (n === void 0) { n = 0; }
1397
+ var a = this._navMeshQuery.moveAlongSurface(n, e, i, r);
1398
+ return new t.Vector3(a.resultPosition.x, a.resultPosition.y, a.resultPosition.z);
1399
+ };
1400
+ dt.prototype.moveAlongToRef = function (e, t, i, n, r) {
1401
+ if (n === void 0) { n = 0; }
1402
+ var a = this._navMeshQuery.moveAlongSurface(n, e, t, r);
1403
+ i.set(a.resultPosition.x, a.resultPosition.y, a.resultPosition.z);
1404
+ };
1405
+ dt.prototype.computePath = function (e, t, i) { return Ke(this._navMeshQuery.computePath(e, t, i)); };
1406
+ dt.prototype.computePathSmooth = function (e, i, n) { return this.navMesh ? et(this.navMesh, this._navMeshQuery, e, i, n) : (t.Logger.Error("No navmesh available. Cannot compute smooth path."), []); };
1407
+ dt.prototype.createCrowd = function (e, t, i) { var n = new Qe(this, e, t, i); return this._crowd = n, n; };
1408
+ dt.prototype.setDefaultQueryExtent = function (e) { this._navMeshQuery.defaultQueryHalfExtents = e; };
1409
+ dt.prototype.getDefaultQueryExtent = function () { return new t.Vector3(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z); };
1410
+ dt.prototype.getDefaultQueryExtentToRef = function (e) { e.set(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z); };
1411
+ dt.prototype.buildFromNavmeshData = function (e) { var t = this.bjsRECAST.importNavMesh(e); this.navMesh = t.navMesh, this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh); };
1412
+ dt.prototype.getNavmeshData = function () { if (!this.navMesh)
1413
+ throw new Error("There is no NavMesh generated."); return this.bjsRECAST.exportNavMesh(this.navMesh); };
1414
+ dt.prototype.buildFromTileCacheData = function (e, t) { var i = this.bjsRECAST.importTileCache(e, null != t ? t : He([])); this.navMesh = i.navMesh, this._tileCache = i.tileCache, this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh); };
1415
+ dt.prototype.getTileCacheData = function () { if (!this.navMesh || !this._tileCache)
1416
+ throw new Error("There is no TileCache generated."); return this.bjsRECAST.exportTileCache(this.navMesh, this._tileCache); };
1417
+ dt.prototype.dispose = function () { var e, t, i, n; null === (e = this._crowd) || void 0 === e || e.dispose(), null === (t = this.navMesh) || void 0 === t || t.destroy(), null === (i = this._navMeshQuery) || void 0 === i || i.destroy(), null === (n = this._tileCache) || void 0 === n || n.destroy(); };
1418
+ dt.prototype.addCylinderObstacle = function (e, t, i, n) {
1419
+ if (n === void 0) { n = !1; }
1420
+ var r, a;
1421
+ var s = null === (r = this._tileCache) || void 0 === r ? void 0 : r.addCylinderObstacle(e, t, i);
1422
+ return (null == s ? void 0 : s.success) ? (!n && this.navMesh && this._tileCache && We(this.navMesh, this._tileCache), null !== (a = s.obstacle) && void 0 !== a ? a : null) : null;
1423
+ };
1424
+ dt.prototype.addBoxObstacle = function (e, t, i, n) {
1425
+ if (n === void 0) { n = !1; }
1426
+ var r, a;
1427
+ var s = null === (r = this._tileCache) || void 0 === r ? void 0 : r.addBoxObstacle(e, t, i);
1428
+ return (null == s ? void 0 : s.success) ? (!n && this.navMesh && this._tileCache && We(this.navMesh, this._tileCache), null !== (a = s.obstacle) && void 0 !== a ? a : null) : null;
1429
+ };
1430
+ dt.prototype.removeObstacle = function (e, t) {
1431
+ if (t === void 0) { t = !1; }
1432
+ var i;
1433
+ null === (i = this._tileCache) || void 0 === i || i.removeObstacle(e), !t && this.navMesh && this._tileCache && We(this.navMesh, this._tileCache);
1434
+ };
1435
+ dt.prototype.isSupported = function () { return !!this.bjsRECAST; };
1436
+ dt.prototype.getRandomSeed = function () { return this.bjsRECAST.getRandomSeed(); };
1437
+ dt.prototype.setRandomSeed = function (e) { this.bjsRECAST.setRandomSeed(e); };
1438
+ dt.prototype.raycast = function (e, i) { var n; var r = this._navMeshQuery.findNearestPoly(e), a = this._navMeshQuery.raycast(r.nearestRef, e, i); if (0 < a.t && a.t < 1) {
1439
+ t.TmpVectors.Vector3[0].set(e.x, e.y, e.z), t.TmpVectors.Vector3[1].set(i.x, i.y, i.z);
1440
+ var r_7 = t.Vector3.Distance(t.TmpVectors.Vector3[0], t.TmpVectors.Vector3[1]) * (null !== (n = null == a ? void 0 : a.t) && void 0 !== n ? n : 0), s_5 = t.TmpVectors.Vector3[1].subtract(t.TmpVectors.Vector3[0]).normalize();
1441
+ return { hit: !0, hitPoint: t.TmpVectors.Vector3[0].add(s_5.multiplyByFloats(r_7, r_7, r_7)) };
1442
+ } return { hit: !1 }; };
1443
+ dt.prototype.moveAlongWithVelocity = function (e, t, i) { var _a = this._navMeshQuery.findClosestPoint({ x: e.x, y: e.y, z: e.z }, i), n = _a.point, r = _a.polyRef, a = this._navMeshQuery.moveAlongSurface(r, n, { x: n.x + t.x, y: n.y + t.y, z: n.z + t.z }, i).resultPosition, s = this._navMeshQuery.getPolyHeight(r, a); return { position: { x: a.x, y: s.success ? s.height : a.y, z: a.z }, polyRef: r, height: s.height }; };
1444
+ dt.prototype._processNavMeshResult = function (e) { if (!(null == e ? void 0 : e.navMesh) || !(null == e ? void 0 : e.navMeshQuery))
1445
+ throw new Error("Unable to create navmesh. No navMesh or navMeshQuery returned."); return this.navMesh = e.navMesh, this._navMeshQuery = e.navMeshQuery, this._intermediates = e.intermediates, this._tileCache = e.tileCache, { navMesh: e.navMesh, navMeshQuery: e.navMeshQuery, intermediates: e.intermediates, tileCache: e.tileCache }; };
1446
+ dt.prototype._preprocessParameters = function (e) { var t, i; void 0 === e.maxObstacles && (e.tileSize = null !== (t = e.tileSize) && void 0 !== t ? t : 32, e.maxObstacles = 128), e.walkableSlopeAngle = Math.max(.1, null !== (i = e.walkableSlopeAngle) && void 0 !== i ? i : 60); };
1447
+ return dt;
1448
+ }());
1449
+ function ht(e, t) { var i = e.x, n = e.z, r = t.x, a = t.z; var s; return s = Math.abs(r - i) >= Math.abs(a - n) ? { x: r, z: n } : { x: i, z: a }, s; }
1450
+ var ut = { HEIGHTFIELD_SOLID: "heightfield solid", HEIGHTFIELD_WALKABLE: "heightfield walkable", COMPACT_HEIGHTFIELD_SOLID: "compact heightfield solid", COMPACT_HEIGHTFIELD_REGIONS: "compact heightfield regions", COMPACT_HEIGHTFIELD_DISTANCE: "compact heightfield distance", RAW_CONTOURS: "raw contours", CONTOURS: "contours", POLY_MESH: "poly mesh", POLY_MESH_DETAIL: "poly mesh detail", NAVMESH: "navmesh", NAVMESH_BV_TREE: "navmesh bv tree" };
1451
+ var mt = /** @class */ (function () {
1452
+ function mt(e, i) {
1453
+ var n, r, a, s;
1454
+ this._scene = e, this.lineMaterials = [], this.getIntermediates = function (e) {
1455
+ var e_60, _a, e_61, _b;
1456
+ var t = [], i = [], n = [], r = [], a = [];
1457
+ if (e)
1458
+ if ("solo" === e.type)
1459
+ e.heightfield && t.push(e.heightfield), e.compactHeightfield && i.push(e.compactHeightfield), e.contourSet && n.push(e.contourSet), e.polyMesh && r.push(e.polyMesh), e.polyMeshDetail && a.push(e.polyMeshDetail);
1460
+ else if ("tiled" === e.type)
1461
+ try {
1462
+ for (var _c = __values(e.tileIntermediates), _d = _c.next(); !_d.done; _d = _c.next()) {
1463
+ var s_6 = _d.value;
1464
+ s_6.heightfield && t.push(s_6.heightfield), s_6.compactHeightfield && i.push(s_6.compactHeightfield), s_6.contourSet && n.push(s_6.contourSet), s_6.polyMesh && r.push(s_6.polyMesh), s_6.polyMeshDetail && a.push(s_6.polyMeshDetail);
1465
+ }
1466
+ }
1467
+ catch (e_60_1) { e_60 = { error: e_60_1 }; }
1468
+ finally {
1469
+ try {
1470
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
1471
+ }
1472
+ finally { if (e_60) throw e_60.error; }
1473
+ }
1474
+ else if ("tilecache" === e.type)
1475
+ try {
1476
+ for (var _f = __values(e.tileIntermediates), _g = _f.next(); !_g.done; _g = _f.next()) {
1477
+ var n_11 = _g.value;
1478
+ n_11.heightfield && t.push(n_11.heightfield), n_11.compactHeightfield && i.push(n_11.compactHeightfield);
1479
+ }
1480
+ }
1481
+ catch (e_61_1) { e_61 = { error: e_61_1 }; }
1482
+ finally {
1483
+ try {
1484
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
1485
+ }
1486
+ finally { if (e_61) throw e_61.error; }
1487
+ }
1488
+ return { heightfieldList: t, compactHeightfieldList: i, contourSetList: n, polyMeshList: r, polyMeshDetailList: a };
1489
+ }, this._debugDrawerUtils = new (Ge().DebugDrawerUtils), this._primitiveTypes = null !== (n = null == i ? void 0 : i.primitiveTypes) && void 0 !== n ? n : ["points", "lines", "tris", "quads"], this.debugDrawerParentNode = (null === (r = null == i ? void 0 : i.parent) || void 0 === r ? void 0 : r.node) instanceof t.TransformNode ? i.parent.node : new t.TransformNode(null !== (s = null === (a = null == i ? void 0 : i.parent) || void 0 === a ? void 0 : a.node) && void 0 !== s ? s : "nav-mesh-debug-parent", this._scene);
1490
+ var o = null == i ? void 0 : i.materials;
1491
+ (null == o ? void 0 : o.triMaterial) ? this.triMaterial = o.triMaterial : (this.triMaterial = new t.StandardMaterial("nav-debug-tris-material"), this.triMaterial.backFaceCulling = !1, this.triMaterial.specularColor = t.Color3.Black(), this.triMaterial.alpha = .5), (null == o ? void 0 : o.pointMaterial) ? this.pointMaterial = o.pointMaterial : (this.pointMaterial = new t.StandardMaterial("nav-debug-points-material"), this.pointMaterial.backFaceCulling = !1, this.pointMaterial.specularColor = t.Color3.Black()), (null == o ? void 0 : o.lineMaterialOptions) ? this._lineMaterialOptions = o.lineMaterialOptions : this._lineMaterialOptions = { greasedLineMaterialOptions: { width: 2, sizeAttenuation: !0 }, greasedLineMeshOptions: {} }, this._pointMesh = t.CreateBox(mt.NAV_MESH_DEBUG_NAME_POINTS, { size: .02 });
1492
+ }
1493
+ Object.defineProperty(mt.prototype, "primitiveTypes", {
1494
+ get: function () { return this._primitiveTypes; },
1495
+ set: function (e) { this._primitiveTypes = e; },
1496
+ enumerable: false,
1497
+ configurable: true
1498
+ });
1499
+ mt.prototype.clear = function () {
1500
+ var e_62, _a;
1501
+ try {
1502
+ for (var _b = __values(this.debugDrawerParentNode.getChildMeshes()), _c = _b.next(); !_c.done; _c = _b.next()) {
1503
+ var e_63 = _c.value;
1504
+ e_63.dispose();
1505
+ }
1506
+ }
1507
+ catch (e_62_1) { e_62 = { error: e_62_1 }; }
1508
+ finally {
1509
+ try {
1510
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1511
+ }
1512
+ finally { if (e_62) throw e_62.error; }
1513
+ }
1514
+ };
1515
+ mt.prototype.dispose = function () { this.clear(), this._debugDrawerUtils.dispose(), this._pointMesh.dispose(), this.triMaterial.dispose(), this.pointMaterial.dispose(); };
1516
+ mt.prototype.drawPrimitives = function (e, t) {
1517
+ var e_64, _a;
1518
+ var i;
1519
+ var n = null;
1520
+ try {
1521
+ for (var e_65 = __values(e), e_65_1 = e_65.next(); !e_65_1.done; e_65_1 = e_65.next()) {
1522
+ var t_17 = e_65_1.value;
1523
+ if (this._primitiveTypes.includes(t_17.type))
1524
+ switch (t_17.type) {
1525
+ case "points":
1526
+ this._drawPoints(t_17);
1527
+ break;
1528
+ case "lines": {
1529
+ var e_66 = this._drawLines(t_17, n);
1530
+ n || (n = e_66);
1531
+ break;
1532
+ }
1533
+ case "tris":
1534
+ this._drawTris(t_17);
1535
+ break;
1536
+ case "quads": this._drawQuads(t_17);
1537
+ }
1538
+ }
1539
+ }
1540
+ catch (e_64_1) { e_64 = { error: e_64_1 }; }
1541
+ finally {
1542
+ try {
1543
+ if (e_65_1 && !e_65_1.done && (_a = e_65.return)) _a.call(e_65);
1544
+ }
1545
+ finally { if (e_64) throw e_64.error; }
1546
+ }
1547
+ null == n || n.updateLazy(), (null === (i = null == t ? void 0 : t.joinMeshes) || void 0 === i || i) && this._joinDebugMeshes();
1548
+ };
1549
+ mt.prototype.drawHeightfieldSolid = function (e) { var t = this._debugDrawerUtils.drawHeightfieldSolid(e); this.drawPrimitives(t); };
1550
+ mt.prototype.drawHeightfieldWalkable = function (e) { var t = this._debugDrawerUtils.drawHeightfieldWalkable(e); this.drawPrimitives(t); };
1551
+ mt.prototype.drawCompactHeightfieldSolid = function (e) { var t = this._debugDrawerUtils.drawCompactHeightfieldSolid(e); this.drawPrimitives(t); };
1552
+ mt.prototype.drawCompactHeightfieldRegions = function (e) { var t = this._debugDrawerUtils.drawCompactHeightfieldRegions(e); this.drawPrimitives(t); };
1553
+ mt.prototype.drawCompactHeightfieldDistance = function (e) { var t = this._debugDrawerUtils.drawCompactHeightfieldDistance(e); this.drawPrimitives(t); };
1554
+ mt.prototype.drawHeightfieldLayer = function (e, t) { var i = this._debugDrawerUtils.drawHeightfieldLayer(e, t); this.drawPrimitives(i); };
1555
+ mt.prototype.drawHeightfieldLayers = function (e) { var t = this._debugDrawerUtils.drawHeightfieldLayers(e); this.drawPrimitives(t); };
1556
+ mt.prototype.drawRegionConnections = function (e, t) {
1557
+ if (t === void 0) { t = 1; }
1558
+ var i = this._debugDrawerUtils.drawRegionConnections(e, t);
1559
+ this.drawPrimitives(i);
1560
+ };
1561
+ mt.prototype.drawRawContours = function (e, t) {
1562
+ if (t === void 0) { t = 1; }
1563
+ var i = this._debugDrawerUtils.drawRawContours(e, t);
1564
+ this.drawPrimitives(i);
1565
+ };
1566
+ mt.prototype.drawContours = function (e, t) {
1567
+ if (t === void 0) { t = 1; }
1568
+ var i = this._debugDrawerUtils.drawContours(e, t);
1569
+ this.drawPrimitives(i);
1570
+ };
1571
+ mt.prototype.drawPolyMesh = function (e) { var t = this._debugDrawerUtils.drawPolyMesh(e); this.drawPrimitives(t); };
1572
+ mt.prototype.drawPolyMeshDetail = function (e) { var t = this._debugDrawerUtils.drawPolyMeshDetail(e); this.drawPrimitives(t); };
1573
+ mt.prototype.drawNavMesh = function (e, t) {
1574
+ if (t === void 0) { t = 0; }
1575
+ var i = this._debugDrawerUtils.drawNavMesh(e, t);
1576
+ this.drawPrimitives(i);
1577
+ };
1578
+ mt.prototype.drawNavMeshWithClosedList = function (e, t, i) {
1579
+ if (i === void 0) { i = 0; }
1580
+ var n = this._debugDrawerUtils.drawNavMeshWithClosedList(e, t, i);
1581
+ this.drawPrimitives(n);
1582
+ };
1583
+ mt.prototype.drawNavMeshNodes = function (e) { var t = this._debugDrawerUtils.drawNavMeshNodes(e); this.drawPrimitives(t); };
1584
+ mt.prototype.drawNavMeshBVTree = function (e) { var t = this._debugDrawerUtils.drawNavMeshBVTree(e); this.drawPrimitives(t); };
1585
+ mt.prototype.drawNavMeshPortals = function (e) { var t = this._debugDrawerUtils.drawNavMeshPortals(e); this.drawPrimitives(t); };
1586
+ mt.prototype.drawNavMeshPolysWithFlags = function (e, t, i) { var n = this._debugDrawerUtils.drawNavMeshPolysWithFlags(e, t, i); this.drawPrimitives(n); };
1587
+ mt.prototype.drawNavMeshPoly = function (e, t, i) { var n = this._debugDrawerUtils.drawNavMeshPoly(e, t, i); this.drawPrimitives(n); };
1588
+ mt.prototype.draw = function (e, t, i, n) {
1589
+ var e_67, _a, e_68, _b, e_69, _c, e_70, _d, e_71, _f, e_72, _g, e_73, _h, e_74, _j, e_75, _k;
1590
+ this.clear();
1591
+ var _l = this.getIntermediates(t), r = _l.heightfieldList, a = _l.compactHeightfieldList, s = _l.contourSetList, o = _l.polyMeshList, l = _l.polyMeshDetailList;
1592
+ if (n === ut.HEIGHTFIELD_SOLID)
1593
+ try {
1594
+ for (var r_8 = __values(r), r_8_1 = r_8.next(); !r_8_1.done; r_8_1 = r_8.next()) {
1595
+ var e_76 = r_8_1.value;
1596
+ this.drawHeightfieldSolid(e_76);
1597
+ }
1598
+ }
1599
+ catch (e_67_1) { e_67 = { error: e_67_1 }; }
1600
+ finally {
1601
+ try {
1602
+ if (r_8_1 && !r_8_1.done && (_a = r_8.return)) _a.call(r_8);
1603
+ }
1604
+ finally { if (e_67) throw e_67.error; }
1605
+ }
1606
+ else if (n === ut.HEIGHTFIELD_WALKABLE)
1607
+ try {
1608
+ for (var r_9 = __values(r), r_9_1 = r_9.next(); !r_9_1.done; r_9_1 = r_9.next()) {
1609
+ var e_77 = r_9_1.value;
1610
+ this.drawHeightfieldWalkable(e_77);
1611
+ }
1612
+ }
1613
+ catch (e_68_1) { e_68 = { error: e_68_1 }; }
1614
+ finally {
1615
+ try {
1616
+ if (r_9_1 && !r_9_1.done && (_b = r_9.return)) _b.call(r_9);
1617
+ }
1618
+ finally { if (e_68) throw e_68.error; }
1619
+ }
1620
+ else if (n === ut.COMPACT_HEIGHTFIELD_SOLID)
1621
+ try {
1622
+ for (var a_7 = __values(a), a_7_1 = a_7.next(); !a_7_1.done; a_7_1 = a_7.next()) {
1623
+ var e_78 = a_7_1.value;
1624
+ this.drawCompactHeightfieldSolid(e_78);
1625
+ }
1626
+ }
1627
+ catch (e_69_1) { e_69 = { error: e_69_1 }; }
1628
+ finally {
1629
+ try {
1630
+ if (a_7_1 && !a_7_1.done && (_c = a_7.return)) _c.call(a_7);
1631
+ }
1632
+ finally { if (e_69) throw e_69.error; }
1633
+ }
1634
+ else if (n === ut.COMPACT_HEIGHTFIELD_REGIONS)
1635
+ try {
1636
+ for (var a_8 = __values(a), a_8_1 = a_8.next(); !a_8_1.done; a_8_1 = a_8.next()) {
1637
+ var e_79 = a_8_1.value;
1638
+ this.drawCompactHeightfieldRegions(e_79);
1639
+ }
1640
+ }
1641
+ catch (e_70_1) { e_70 = { error: e_70_1 }; }
1642
+ finally {
1643
+ try {
1644
+ if (a_8_1 && !a_8_1.done && (_d = a_8.return)) _d.call(a_8);
1645
+ }
1646
+ finally { if (e_70) throw e_70.error; }
1647
+ }
1648
+ else if (n === ut.COMPACT_HEIGHTFIELD_DISTANCE)
1649
+ try {
1650
+ for (var a_9 = __values(a), a_9_1 = a_9.next(); !a_9_1.done; a_9_1 = a_9.next()) {
1651
+ var e_80 = a_9_1.value;
1652
+ this.drawCompactHeightfieldDistance(e_80);
1653
+ }
1654
+ }
1655
+ catch (e_71_1) { e_71 = { error: e_71_1 }; }
1656
+ finally {
1657
+ try {
1658
+ if (a_9_1 && !a_9_1.done && (_f = a_9.return)) _f.call(a_9);
1659
+ }
1660
+ finally { if (e_71) throw e_71.error; }
1661
+ }
1662
+ else if (n === ut.RAW_CONTOURS)
1663
+ try {
1664
+ for (var s_7 = __values(s), s_7_1 = s_7.next(); !s_7_1.done; s_7_1 = s_7.next()) {
1665
+ var e_81 = s_7_1.value;
1666
+ this.drawRawContours(e_81);
1667
+ }
1668
+ }
1669
+ catch (e_72_1) { e_72 = { error: e_72_1 }; }
1670
+ finally {
1671
+ try {
1672
+ if (s_7_1 && !s_7_1.done && (_g = s_7.return)) _g.call(s_7);
1673
+ }
1674
+ finally { if (e_72) throw e_72.error; }
1675
+ }
1676
+ else if (n === ut.CONTOURS)
1677
+ try {
1678
+ for (var s_8 = __values(s), s_8_1 = s_8.next(); !s_8_1.done; s_8_1 = s_8.next()) {
1679
+ var e_82 = s_8_1.value;
1680
+ this.drawContours(e_82);
1681
+ }
1682
+ }
1683
+ catch (e_73_1) { e_73 = { error: e_73_1 }; }
1684
+ finally {
1685
+ try {
1686
+ if (s_8_1 && !s_8_1.done && (_h = s_8.return)) _h.call(s_8);
1687
+ }
1688
+ finally { if (e_73) throw e_73.error; }
1689
+ }
1690
+ else if (n === ut.POLY_MESH)
1691
+ try {
1692
+ for (var o_4 = __values(o), o_4_1 = o_4.next(); !o_4_1.done; o_4_1 = o_4.next()) {
1693
+ var e_83 = o_4_1.value;
1694
+ this.drawPolyMesh(e_83);
1695
+ }
1696
+ }
1697
+ catch (e_74_1) { e_74 = { error: e_74_1 }; }
1698
+ finally {
1699
+ try {
1700
+ if (o_4_1 && !o_4_1.done && (_j = o_4.return)) _j.call(o_4);
1701
+ }
1702
+ finally { if (e_74) throw e_74.error; }
1703
+ }
1704
+ else if (n === ut.POLY_MESH_DETAIL)
1705
+ try {
1706
+ for (var l_5 = __values(l), l_5_1 = l_5.next(); !l_5_1.done; l_5_1 = l_5.next()) {
1707
+ var e_84 = l_5_1.value;
1708
+ this.drawPolyMeshDetail(e_84);
1709
+ }
1710
+ }
1711
+ catch (e_75_1) { e_75 = { error: e_75_1 }; }
1712
+ finally {
1713
+ try {
1714
+ if (l_5_1 && !l_5_1.done && (_k = l_5.return)) _k.call(l_5);
1715
+ }
1716
+ finally { if (e_75) throw e_75.error; }
1717
+ }
1718
+ else
1719
+ n === ut.NAVMESH ? this.drawNavMesh(e) : n === ut.NAVMESH_BV_TREE && this.drawNavMeshBVTree(e);
1720
+ };
1721
+ mt.prototype._drawPoints = function (e) { if (0 === e.vertices.length)
1722
+ return; var i = new Float32Array(16 * e.vertices.length), n = new Float32Array(4 * e.vertices.length); for (var r_10 = 0; r_10 < e.vertices.length; r_10++) {
1723
+ var _a = __read(e.vertices[r_10], 7), a_10 = _a[0], s_9 = _a[1], o_5 = _a[2], l_6 = _a[3], c_5 = _a[4], d_4 = _a[5], h_5 = _a[6];
1724
+ n[4 * r_10] = l_6, n[4 * r_10 + 1] = c_5, n[4 * r_10 + 2] = d_4, n[4 * r_10 + 3] = h_5, t.Matrix.Translation(a_10, s_9, o_5).copyToArray(i, 16 * r_10);
1725
+ } this._pointMesh.thinInstanceSetBuffer("matrix", i, 16), this._pointMesh.thinInstanceSetBuffer("color", n, 4), this._pointMesh.parent = this.debugDrawerParentNode; };
1726
+ mt.prototype._drawLines = function (e, i) { if (0 === e.vertices.length)
1727
+ return null; var n = [], r = []; for (var i_15 = 0; i_15 < e.vertices.length; i_15 += 2) {
1728
+ var _a = __read(e.vertices[i_15], 6), a_11 = _a[0], s_10 = _a[1], o_6 = _a[2], l_7 = _a[3], c_6 = _a[4], d_5 = _a[5], _b = __read(e.vertices[i_15 + 1], 6), h_6 = _b[0], u_4 = _b[1], m_3 = _b[2], p_4 = _b[3], f_3 = _b[4], g_2 = _b[5];
1729
+ n.push([a_11, s_10, o_6, h_6, u_4, m_3]), r.push(new t.Color3(l_7, c_6, d_5)), r.push(new t.Color3(p_4, f_3, g_2));
1730
+ } var a = Object.assign(Object.assign({}, this._lineMaterialOptions.greasedLineMeshOptions), { points: n, instance: null != i ? i : void 0 }), s = Object.assign(Object.assign({}, this._lineMaterialOptions.greasedLineMaterialOptions), { colors: r }), o = t.CreateGreasedLine(mt.NAV_MESH_DEBUG_NAME_LINES, a, s); return o.parent = this.debugDrawerParentNode, this.lineMaterials.push(o.material), o; };
1731
+ mt.prototype._drawTris = function (e) { if (0 === e.vertices.length)
1732
+ return; var i = new Float32Array(3 * e.vertices.length), n = new Float32Array(4 * e.vertices.length); for (var t_18 = 0; t_18 < e.vertices.length; t_18++) {
1733
+ var _a = __read(e.vertices[t_18], 6), r_11 = _a[0], a_12 = _a[1], s_11 = _a[2], o_7 = _a[3], l_8 = _a[4], c_7 = _a[5];
1734
+ i[3 * t_18 + 0] = r_11, i[3 * t_18 + 1] = a_12, i[3 * t_18 + 2] = s_11, n[4 * t_18 + 0] = o_7, n[4 * t_18 + 1] = l_8, n[4 * t_18 + 2] = c_7, n[4 * t_18 + 3] = 1;
1735
+ } var r = new t.VertexData; r.positions = i, r.colors = n; var a = new t.Mesh(mt.NAV_MESH_DEBUG_NAME_TRIS); a.isUnIndexed = !0, r.applyToMesh(a), a.material = this.triMaterial, a.parent = this.debugDrawerParentNode; };
1736
+ mt.prototype._drawQuads = function (e) {
1737
+ var e_85, _a;
1738
+ if (0 === e.vertices.length)
1739
+ return;
1740
+ var i = [], n = [];
1741
+ for (var t_19 = 0; t_19 < e.vertices.length; t_19 += 4) {
1742
+ var r_13 = [e.vertices[t_19], e.vertices[t_19 + 1], e.vertices[t_19 + 2], e.vertices[t_19], e.vertices[t_19 + 2], e.vertices[t_19 + 3]];
1743
+ try {
1744
+ for (var r_12 = (e_85 = void 0, __values(r_13)), r_12_1 = r_12.next(); !r_12_1.done; r_12_1 = r_12.next()) {
1745
+ var _b = __read(r_12_1.value, 6), e_86 = _b[0], t_20 = _b[1], a_13 = _b[2], s_12 = _b[3], o_8 = _b[4], l_9 = _b[5];
1746
+ i.push(e_86, t_20, a_13), n.push(s_12, o_8, l_9, 1);
1747
+ }
1748
+ }
1749
+ catch (e_85_1) { e_85 = { error: e_85_1 }; }
1750
+ finally {
1751
+ try {
1752
+ if (r_12_1 && !r_12_1.done && (_a = r_12.return)) _a.call(r_12);
1753
+ }
1754
+ finally { if (e_85) throw e_85.error; }
1755
+ }
1756
+ }
1757
+ var r = new t.VertexData;
1758
+ r.positions = i, r.colors = n;
1759
+ var a = new t.Mesh(mt.NAV_MESH_DEBUG_NAME_QUADS);
1760
+ a.isUnIndexed = !0, r.applyToMesh(a), a.material = this.triMaterial, a.parent = this.debugDrawerParentNode;
1761
+ };
1762
+ mt.prototype._joinDebugMeshes = function () {
1763
+ var _this = this;
1764
+ var e = this._scene.meshes.filter(function (e) { return e.name === mt.NAV_MESH_DEBUG_NAME; });
1765
+ e.forEach(function (e) { _this._convertUnindexedToIndexed(e); });
1766
+ var i = t.Mesh.MergeMeshes(e, !0);
1767
+ i && (i.name = mt.NAV_MESH_DEBUG_NAME, i.parent = this.debugDrawerParentNode);
1768
+ };
1769
+ mt.prototype._convertUnindexedToIndexed = function (e) { var i = t.VertexData.ExtractFromMesh(e).positions; if (!i || i.length % 9 != 0)
1770
+ return void t.Logger.Warn("Mesh must be fully unindexed with triangles."); var n = i.length / 3, r = Array.from({ length: n }, function (e, t) { return t; }), a = new t.VertexData; a.positions = i, a.indices = r, a.applyToMesh(e, !0); };
1771
+ return mt;
1772
+ }());
1773
+ mt.NAV_MESH_DEBUG_NAME = "nav-mesh-debug", mt.NAV_MESH_DEBUG_NAME_POINTS = "nav-mesh-debug-points", mt.NAV_MESH_DEBUG_NAME_TRIS = "nav-mesh-debug-tris", mt.NAV_MESH_DEBUG_NAME_QUADS = "nav-mesh-debug-quads", mt.NAV_MESH_DEBUG_NAME_LINES = "nav-mesh-debug-lines";
1774
+ var pt = "atmosphereFunctions", ft = "#include<intersectionFunctions>\nconst MultiScatteringLutSize=vec2f(32.,32.);const MultiScatteringLutDomainInUVSpace=(MultiScatteringLutSize-vec2f(1.))/MultiScatteringLutSize;const MultiScatteringLutHalfTexelSize=vec2f(.5)/MultiScatteringLutSize;const NumAerialPerspectiveLutLayers=32.;const AerialPerspectiveLutSize=vec3f(16.,64.,NumAerialPerspectiveLutLayers);const DiffuseSkyIrradianceLutSize=vec2f(64.,16.);const DiffuseSkyIrradianceLutDomainInUVSpace=(DiffuseSkyIrradianceLutSize-vec2f(1.))/DiffuseSkyIrradianceLutSize;const DiffuseSkyIrradianceLutHalfTexelSize=vec2f(.5)/DiffuseSkyIrradianceLutSize;const SkyViewLutSize=vec2f(128.,128.);const SkyViewLutDomainInUVSpace=(SkyViewLutSize-vec2f(1.))/SkyViewLutSize;const SkyViewLutHalfTexelSize=vec2f(.5)/SkyViewLutSize;const AerialPerspectiveLutKMPerSlice=4.;const AerialPerspectiveLutRangeKM=AerialPerspectiveLutKMPerSlice*NumAerialPerspectiveLutLayers;const TransmittanceLutSize=vec2f(256.,64.);const TransmittanceLutDomainInUVSpace=(TransmittanceLutSize-vec2f(1.))/TransmittanceLutSize;const TransmittanceLutHalfTexelSize=vec2f(.5)/TransmittanceLutSize;const TransmittanceHorizonRange=2.*TransmittanceLutHalfTexelSize.x;const TransmittanceMaxUnoccludedU=1.-.5*TransmittanceHorizonRange;const TransmittanceMinOccludedU=1.+.5*TransmittanceHorizonRange;fn uvToUnit(uv: vec2f,domainInUVSpace: vec2f,halfTexelSize: vec2f)->vec2f {return (uv-halfTexelSize)/domainInUVSpace;}\nfn unitToUV(unit: vec2f,domainInUVSpace: vec2f,halfTexelSize: vec2f)->vec2f {return unit*domainInUVSpace+halfTexelSize;}\nfn sphereIntersectNearest(rayOrigin: vec3f,rayDirection: vec3f,sphereRadius: f32)->f32 {let result=sphereIntersectFromOrigin(rayOrigin,rayDirection,sphereRadius);let c=dot(rayOrigin,rayOrigin)-sphereRadius*sphereRadius;return select(result.x,result.y,c>=0.);}\nfn moveToTopAtmosphere(\ncameraPosition: vec3f,\npositionRadius: f32,\npositionGeocentricNormal: vec3f,\nrayDirection: vec3f,\nintersectsAtmosphere: ptr<function,bool>,\ncameraPositionClampedToTopOfAtmosphere: ptr<function,vec3f>\n) {*intersectsAtmosphere=true;*cameraPositionClampedToTopOfAtmosphere=cameraPosition;if (positionRadius>atmosphere.atmosphereRadius) {let tTop=sphereIntersectNearest(cameraPosition,rayDirection,atmosphere.atmosphereRadius);if (tTop>=0.) {let upOffset=-atmosphere.planetRadiusOffset*positionGeocentricNormal;*cameraPositionClampedToTopOfAtmosphere=cameraPosition+rayDirection*tTop+upOffset;} else {*intersectsAtmosphere=false;}}}\nfn getSkyViewUVFromParameters(\nintersectsGround: bool,\ncosHorizonAngleFromZenith: f32,\ncosAngleBetweenViewAndZenith: f32,\ncosAngleBetweenViewAndLightOnPlane: f32,\nuv: ptr<function,vec2f>\n) {var unit=vec2f(0.);if (intersectsGround) {var coord=(cosAngleBetweenViewAndZenith+1.)/(cosHorizonAngleFromZenith+1.);coord=sqrtClamped(coord); \nunit.y=.5*coord; } else {var coord=(cosAngleBetweenViewAndZenith-cosHorizonAngleFromZenith)/(1.-cosHorizonAngleFromZenith);coord=sqrtClamped(coord); \nunit.y=.5*coord+.5; }\nunit.x=.5-.5*cosAngleBetweenViewAndLightOnPlane;*uv=unitToUV(unit,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);}\n#if USE_SKY_VIEW_LUT && SAMPLE_SKY_VIEW_LUT\nfn sampleSkyViewLut(\nskyViewLut: texture_2d<f32>,\npositionRadius: f32,\ngeocentricNormal: vec3f,\nrayDirection: vec3f,\ndirectionToLight: vec3f,\ncosHorizonAngleFromZenith: f32,\ncosAngleBetweenViewAndZenith: ptr<function,f32>,\nisRayIntersectingGround: ptr<function,bool>\n)->vec4f {*cosAngleBetweenViewAndZenith=dot(rayDirection,geocentricNormal);if (positionRadius>atmosphere.atmosphereRadius) {let sinAngleBetweenViewAndNadir=sqrtClamped(1.-*cosAngleBetweenViewAndZenith**cosAngleBetweenViewAndZenith);if (sinAngleBetweenViewAndNadir>atmosphere.sinCameraAtmosphereHorizonAngleFromNadir) {*isRayIntersectingGround=false;return vec4f(0.);}}\nlet sideVector=normalize(cross(geocentricNormal,rayDirection));let forwardVector=normalize(cross(sideVector,geocentricNormal));let lightOnPlane=normalize(vec2f(dot(directionToLight,forwardVector),dot(directionToLight,sideVector)));let cosAngleBetweenViewAndLightOnPlane=lightOnPlane.x;let rayIntersectionScale=mix(.95,1.,saturate((positionRadius-atmosphere.planetRadius)/atmosphere.atmosphereThickness));*isRayIntersectingGround =\npositionRadius>atmosphere.planetRadius &&\n(rayIntersectionScale**cosAngleBetweenViewAndZenith)<=cosHorizonAngleFromZenith;var uv: vec2f;getSkyViewUVFromParameters(\n*isRayIntersectingGround,\ncosHorizonAngleFromZenith,\n*cosAngleBetweenViewAndZenith,\ncosAngleBetweenViewAndLightOnPlane,\n&uv);return textureSampleLevel(skyViewLut,skyViewLutSampler,uv,0.);}\n#endif\nfn computeRayleighPhase(onePlusCosThetaSq: f32)->f32 {return 0.0596831037*onePlusCosThetaSq;}\nfn computeMiePhaseCornetteShanks(cosTheta: f32,onePlusCosThetaSq: f32)->f32 {const g=.8;const gSquared=g*g;const oneMinusGSquared=1.-gSquared;const onePlusGSquared=1.+gSquared;const twoPlusGSquared=2.+gSquared;const twoG=2.*g;const threeOverEightPi=3./(8.*PI);return threeOverEightPi*oneMinusGSquared*onePlusCosThetaSq/(twoPlusGSquared*pow(onePlusGSquared-twoG*cosTheta,1.5));}\nfn computeOzoneDensity(normalizedViewHeight: f32)->f32 {const MinOzoneDensity=.135;const OneMinusMinOzoneDensity=1.-MinOzoneDensity;const OzoneStartHeight=.15; \nconst PeakOzoneHeight=.25;const MaxOzoneHeight=.6;const InverseRampupDistance=1./(PeakOzoneHeight-OzoneStartHeight);const InverseRampdownDistance=1./(MaxOzoneHeight-PeakOzoneHeight);let lowerAtmosphereDensity=MinOzoneDensity+OneMinusMinOzoneDensity*max(0.,normalizedViewHeight-OzoneStartHeight)*InverseRampupDistance;let sqrtUpperAtmosphereDensity=max(0.,1.-(normalizedViewHeight-PeakOzoneHeight)*InverseRampdownDistance);let upperAtmosphereDensity=sqrtUpperAtmosphereDensity*sqrtUpperAtmosphereDensity;let densityOzone=select(upperAtmosphereDensity,lowerAtmosphereDensity,normalizedViewHeight<PeakOzoneHeight);return densityOzone;}\nfn sampleMediumRGB(\nviewHeight: f32,\nscatteringRayleigh: ptr<function,vec3f>,\nscatteringMie: ptr<function,vec3f>,\nextinction: ptr<function,vec3f>,\nscattering: ptr<function,vec3f>\n) {let normalizedViewHeight=saturate(viewHeight*atmosphere.inverseAtmosphereThickness);let densityMie=exp(-83.333*normalizedViewHeight);let densityRayleigh=exp(-12.5*normalizedViewHeight);let densityOzone=computeOzoneDensity(normalizedViewHeight);*scatteringRayleigh=densityRayleigh*atmosphere.peakRayleighScattering;*scatteringMie=densityMie*atmosphere.peakMieScattering;*scattering=*scatteringMie+*scatteringRayleigh;let extinctionRayleigh=*scatteringRayleigh;let extinctionMie=densityMie*atmosphere.peakMieExtinction;let extinctionOzone=densityOzone*atmosphere.peakOzoneAbsorption;*extinction=extinctionRayleigh+extinctionMie+extinctionOzone;}\nfn computeTransmittance(rayOriginGlobal: vec3f,rayDirection: vec3f,tMax: f32,sampleCount: f32)->vec3f {var opticalDepth=vec3f(0.);var t=0.;let sampleSegmentWeight=tMax/sampleCount;const sampleSegmentT=.3;for (var s=0.; s<sampleCount; s+=1.) {let newT=sampleSegmentWeight*(s+sampleSegmentT);let dt=newT-t;t=newT;var scatteringRayleigh: vec3f;var scatteringMie: vec3f;var extinction: vec3f;var scattering: vec3f;let samplePositionGlobal=rayOriginGlobal+t*rayDirection;sampleMediumRGB(length(samplePositionGlobal)-atmosphere.planetRadius,&scatteringRayleigh,&scatteringMie,&extinction,&scattering);opticalDepth+=extinction*dt;}\nreturn exp(-opticalDepth);}\n#if defined(SAMPLE_TRANSMITTANCE_LUT) || !defined(EXCLUDE_RAY_MARCHING_FUNCTIONS)\nfn getTransmittanceUV(radius: f32,cosAngleLightToZenith: f32,distanceToHorizon: ptr<function,f32>)->vec2f {let radiusSquared=radius*radius;let horizonDistance=sqrtClamped(radiusSquared-atmosphere.planetRadiusSquared);*distanceToHorizon=horizonDistance;let cosAngleLightToZenithSquared=cosAngleLightToZenith*cosAngleLightToZenith;let discriminant=radiusSquared*(cosAngleLightToZenithSquared-1.)+atmosphere.atmosphereRadiusSquared;let distanceToAtmosphereEdge=max(0.,-radius*cosAngleLightToZenith+sqrtClamped(discriminant));let minDistanceToAtmosphereEdge=max(0.,atmosphere.atmosphereRadius-radius);let maxDistanceToAtmosphereEdge=horizonDistance+atmosphere.horizonDistanceToAtmosphereEdge;let cosAngleLightToZenithCoordinate=(distanceToAtmosphereEdge-minDistanceToAtmosphereEdge)/max(.000001,maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);let distanceToHorizonCoordinate=horizonDistance/max(.000001,atmosphere.horizonDistanceToAtmosphereEdge);let unit=vec2f(cosAngleLightToZenithCoordinate,distanceToHorizonCoordinate);return unit*TransmittanceLutDomainInUVSpace+TransmittanceLutHalfTexelSize; }\nfn sampleTransmittanceLut(transmittanceLut: texture_2d<f32>,positionRadius: f32,cosAngleLightToZenith: f32)->vec4f {var distanceToHorizon=0.;let uv=getTransmittanceUV(positionRadius,cosAngleLightToZenith,&distanceToHorizon);let weight=smoothstep(TransmittanceMinOccludedU,TransmittanceMaxUnoccludedU,uv.x);return weight*textureSampleLevel(transmittanceLut,transmittanceLutSampler,uv,0.);}\n#endif\n#ifndef EXCLUDE_RAY_MARCHING_FUNCTIONS\n#ifndef COMPUTE_MULTI_SCATTERING\nfn sampleMultiScatteringLut(multiScatteringLut: texture_2d<f32>,radius: f32,cosAngleLightToZenith: f32)->vec3f {let unit=vec2f(.5+.5*cosAngleLightToZenith,(radius-atmosphere.planetRadius)/atmosphere.atmosphereThickness);let uv=unitToUV(unit,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);let multiScattering=textureSampleLevel(multiScatteringLut,multiScatteringLutSampler,uv,0.).rgb;return max(atmosphere.minMultiScattering,multiScattering);}\n#endif\nconst uniformPhase=RECIPROCAL_PI4;fn integrateScatteredRadiance(\nisAerialPerspectiveLut: bool,\nlightIntensityParam: f32,\ntransmittanceLut: texture_2d<f32>,\n#ifndef COMPUTE_MULTI_SCATTERING\nmultiScatteringLut: texture_2d<f32>,\nmultiScatteringIntensityParam: f32,\n#endif\nrayOriginGlobal: vec3f,\nrayDirection: vec3f,\ndirectionToLightParam: vec3f,\ntMaxMax: f32,\nsampleCount: f32,\ndistanceToSurface: f32,\ntransmittance: ptr<function,vec3f>\n#if COMPUTE_MULTI_SCATTERING\n,multiScattering: ptr<function,vec3f>\n#endif\n)->vec3f {var radiance=vec3f(0.);*transmittance=vec3f(1.);\n#if COMPUTE_MULTI_SCATTERING\n*multiScattering=vec3f(0.);\n#endif\nlet tBottom=sphereIntersectNearest(rayOriginGlobal,rayDirection,atmosphere.planetRadius);let tTop=sphereIntersectNearest(rayOriginGlobal,rayDirection,atmosphere.atmosphereRadius);var tMax=0.;if (tBottom<0.) {if (tTop<0.) {return radiance;} else {tMax=tTop;}} else {if (tTop>0.) {if (isAerialPerspectiveLut) {tMax=tTop;} else {tMax=min(tBottom,tTop);}}}\nif (distanceToSurface>0. && distanceToSurface<tMax) {tMax=distanceToSurface;}\ntMax=min(tMax,tMaxMax);\n#ifndef COMPUTE_MULTI_SCATTERING\nlet cosTheta=dot(rayDirection,directionToLightParam);let onePlusCosThetaSq=1.+cosTheta*cosTheta;let rayleighPhase=computeRayleighPhase(onePlusCosThetaSq);let miePhase=computeMiePhaseCornetteShanks(cosTheta,onePlusCosThetaSq);\n#endif\nlet transmittanceScale=select(1.,atmosphere.aerialPerspectiveTransmittanceScale,isAerialPerspectiveLut);var t=0.;let sampleSegmentWeight=tMax/sampleCount;const sampleSegmentT=.3;for (var s=0.; s<sampleCount; s+=1.) {let newT=sampleSegmentWeight*(s+sampleSegmentT);let dt=newT-t;t=newT;let samplePositionGlobal=rayOriginGlobal+t*rayDirection;let sampleRadiusGlobal=length(samplePositionGlobal);let sampleGeocentricNormal=samplePositionGlobal/sampleRadiusGlobal;let sampleCosAngleLightToZenith=dot(directionToLightParam,sampleGeocentricNormal);var scatteringRayleigh: vec3f;var scatteringMie: vec3f;var extinction: vec3f;var scattering: vec3f;sampleMediumRGB(sampleRadiusGlobal-atmosphere.planetRadius,&scatteringRayleigh,&scatteringMie,&extinction,&scattering);let transmittanceToLight=sampleTransmittanceLut(transmittanceLut,sampleRadiusGlobal,sampleCosAngleLightToZenith).rgb;\n#if COMPUTE_MULTI_SCATTERING\nlet phaseTimesScattering=uniformPhase*scattering;let S=transmittanceToLight*phaseTimesScattering;\n#else\nlet phaseTimesScattering=scatteringMie*miePhase+scatteringRayleigh*rayleighPhase;let multiScatteredRadiance=sampleMultiScatteringLut(multiScatteringLut,sampleRadiusGlobal,sampleCosAngleLightToZenith);let S=transmittanceScale*transmittanceToLight*phaseTimesScattering+multiScatteringIntensityParam*multiScatteredRadiance*scattering;\n#endif\nlet sampleOpticalDepth=extinction*dt;let sampleTransmittanceVal=exp(-sampleOpticalDepth);let clampedExtinction=max(vec3f(.0000001),extinction);let SInt=(S-S*sampleTransmittanceVal)/clampedExtinction;radiance+=*transmittance*SInt;\n#if COMPUTE_MULTI_SCATTERING\nlet MSInt=(scattering-scattering*sampleTransmittanceVal)/clampedExtinction;*multiScattering+=*transmittance*MSInt;\n#endif\n*transmittance*=sampleTransmittanceVal;}\n#if USE_GROUND_ALBEDO\nif (tMax==tBottom && tBottom>0.) {let planetPos=rayOriginGlobal+tBottom*rayDirection;let planetPosRadius=length(planetPos);let planetPosGeocentricNormal=planetPos/planetPosRadius;let nDotL=dot(directionToLightParam,planetPosGeocentricNormal);let lightTransmittance=sampleTransmittanceLut(transmittanceLut,planetPosRadius,nDotL).rgb;const diffuseBrdf=RECIPROCAL_PI;radiance+=lightTransmittance**transmittance*atmosphere.groundAlbedo*(nDotL*diffuseBrdf);}\n#endif\nradiance*=lightIntensityParam;return radiance;}\n#endif\nfn layerIdxToAerialPerspectiveLayer(layerIdx: f32)->f32 {var layer=(layerIdx+1.)/NumAerialPerspectiveLutLayers;layer*=layer; \nlayer*=NumAerialPerspectiveLutLayers;return layer;}\nfn toAerialPerspectiveDepth(layer: f32)->f32 {return layer*AerialPerspectiveLutKMPerSlice;}\nfn toAerialPerspectiveLayer(distance: f32,aerialPerspectiveLutDistancePerSlice: f32)->f32 {return distance/aerialPerspectiveLutDistancePerSlice;}\nfn applyAerialPerspectiveSaturation(aerialPerspective: vec4f)->vec4f {let previousRadiance=getLuminanceUnclamped(aerialPerspective.rgb);let mixed=mix(vec3f(previousRadiance),aerialPerspective.rgb,atmosphere.aerialPerspectiveSaturation);return vec4f(mixed,aerialPerspective.a);}\nfn applyAerialPerspectiveIntensity(aerialPerspective: vec4f)->vec4f {var result=aerialPerspective;\n#if APPLY_AERIAL_PERSPECTIVE_INTENSITY\nif (atmosphere.aerialPerspectiveIntensity==0.) {result=vec4f(0.);} else {let previousAlpha=result.a;result=result/max(.00001,previousAlpha);result=result*pow(previousAlpha,1./atmosphere.aerialPerspectiveIntensity);}\n#endif\nreturn result;}\nfn applyAerialPerspectiveRadianceBias(aerialPerspective: vec4f)->vec4f {var result=aerialPerspective;\n#if APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS\nlet originalRadiance=dot(result.rgb,LuminanceEncodeApprox);let targetRadiance=originalRadiance+atmosphere.aerialPerspectiveRadianceBias;if (originalRadiance>0.) {result=result*max(0.,targetRadiance/originalRadiance);} else {result=max(vec4f(0.),vec4f(atmosphere.aerialPerspectiveRadianceBias));}\nresult.a=min(result.a,1.);\n#endif\nreturn result;}\nfn sampleAerialPerspectiveLut(\nscreenUV: vec2f,\nclampToLutRange: bool,\ndistanceFromCamera: f32,\nnumAerialPerspectiveLutLayers: f32,\naerialPerspectiveLutKMPerSlice: f32,\naerialPerspectiveLutRangeKM: f32,\naerialPerspective: ptr<function,vec4f>\n)->bool {*aerialPerspective=vec4f(0.);\n#if USE_AERIAL_PERSPECTIVE_LUT\nif (distanceFromCamera>0. &&\n(clampToLutRange || distanceFromCamera<aerialPerspectiveLutRangeKM) &&\natmosphere.clampedCameraRadius<=atmosphere.atmosphereRadius) {var layer=toAerialPerspectiveLayer(distanceFromCamera,aerialPerspectiveLutKMPerSlice);let normalizedLayer=sqrt(layer/numAerialPerspectiveLutLayers); \nlayer=min(normalizedLayer*numAerialPerspectiveLutLayers,numAerialPerspectiveLutLayers);let weight=min(layer,1.);let layerIdx=max(0.,layer-1.);let floorLayerIdx=floor(layerIdx);let aerialPerspectiveLayer0=textureSampleLevel(aerialPerspectiveLut,aerialPerspectiveLutSampler,screenUV,i32(floorLayerIdx),0.);let aerialPerspectiveLayer1=textureSampleLevel(aerialPerspectiveLut,aerialPerspectiveLutSampler,screenUV,i32(floorLayerIdx+1.),0.);var interpolated=mix(aerialPerspectiveLayer0,aerialPerspectiveLayer1,layerIdx-floorLayerIdx);interpolated=vec4f(interpolated.rgb*atmosphere.atmosphereExposure,interpolated.a);interpolated=applyAerialPerspectiveSaturation(interpolated);interpolated=weight*applyAerialPerspectiveIntensity(interpolated);interpolated=applyAerialPerspectiveRadianceBias(interpolated);*aerialPerspective=interpolated;return true;}\n#endif\nreturn false;}\n#if RENDER_TRANSMITTANCE\nfn getTransmittanceParameters(uv: vec2f,radius: ptr<function,f32>,cosAngleLightToZenith: ptr<function,f32>,distanceToAtmosphereEdge: ptr<function,f32>) {let unit=uvToUnit(uv,TransmittanceLutDomainInUVSpace,TransmittanceLutHalfTexelSize);let distanceToHorizon=unit.y*atmosphere.horizonDistanceToAtmosphereEdge;let distanceToHorizonSquared=distanceToHorizon*distanceToHorizon;*radius=sqrtClamped(distanceToHorizonSquared+atmosphere.planetRadiusSquared);let minDistanceToAtmosphereEdge=atmosphere.atmosphereRadius-*radius;let maxDistanceToAtmosphereEdge=distanceToHorizon+atmosphere.horizonDistanceToAtmosphereEdge;*distanceToAtmosphereEdge=minDistanceToAtmosphereEdge+unit.x*(maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);let distanceToAtmosphereEdgeSquared=*distanceToAtmosphereEdge**distanceToAtmosphereEdge;*cosAngleLightToZenith=select(\n(atmosphere.horizonDistanceToAtmosphereEdgeSquared-distanceToAtmosphereEdgeSquared-distanceToHorizonSquared)/(2.**radius**distanceToAtmosphereEdge),\n1.,\n*distanceToAtmosphereEdge<=0.\n);*cosAngleLightToZenith=clamp(*cosAngleLightToZenith,-1.,1.);}\nfn renderTransmittance(uv: vec2f)->vec4f {var radius: f32;var cosAngleLightToZenith: f32;var distanceToAtmosphereEdgeAlongAngle: f32;getTransmittanceParameters(uv,&radius,&cosAngleLightToZenith,&distanceToAtmosphereEdgeAlongAngle);let sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);let directionToLight=normalize(vec3f(0.,cosAngleLightToZenith,sinAngleLightToZenith));let transmittance=computeTransmittance(vec3f(0.,radius,0.),directionToLight,distanceToAtmosphereEdgeAlongAngle,atmosphere.transmittanceSampleCount);return vec4f(transmittance,avg(transmittance));}\n#endif\n#if RENDER_MULTI_SCATTERING\nfn getSphereSample(azimuth: f32,inclination: f32,sinInclination: ptr<function,f32>)->vec3f {*sinInclination=sin(inclination);return vec3f(*sinInclination*sin(azimuth),cos(inclination),*sinInclination*cos(azimuth));}\nfn renderMultiScattering(uv: vec2f,transmittanceLut: texture_2d<f32>)->vec4f {let MultiScatteringAzimuthIterationAngle=TWO_PI/atmosphere.multiScatteringAzimuthSampleCount;let MultiScatteringInclinationIterationAngle=PI/atmosphere.multiScatteringInclinationSampleCount;let MultiScatteringAngleStepProduct=MultiScatteringAzimuthIterationAngle*MultiScatteringInclinationIterationAngle;let unit=uvToUnit(uv,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);let cosAngleLightToZenith=2.*unit.x-1.;let sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);let directionToLightLocal=normalize(vec3f(0.,cosAngleLightToZenith,sinAngleLightToZenith));let rayOriginRadius=atmosphere.planetRadius+max(unit.y,.001)*atmosphere.atmosphereThickness;let rayOrigin=vec3f(0.,rayOriginRadius,0.);var inscattered=vec3f(0.);var multiScatteringTotal=vec3f(0.);for (var i=.5; i<atmosphere.multiScatteringAzimuthSampleCount; i+=1.) {let azimuth=MultiScatteringAzimuthIterationAngle*i;for (var j=.5; j<atmosphere.multiScatteringInclinationSampleCount; j+=1.) {let inclination=MultiScatteringInclinationIterationAngle*j;var sinInclination: f32;let rayDirection=getSphereSample(azimuth,inclination,&sinInclination);var transmittanceVal: vec3f;var multiScatteringVal: vec3f;let radianceVal=integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nrayOrigin,\nrayDirection,\ndirectionToLightLocal,\n100000000.,\natmosphere.multiScatteringLutSampleCount,\n-1.,\n&transmittanceVal,\n&multiScatteringVal);let weight=RECIPROCAL_PI4*abs(sinInclination)*MultiScatteringAngleStepProduct;multiScatteringTotal+=multiScatteringVal*weight;inscattered+=radianceVal*weight;}}\nlet multiScatteringResult=inscattered/max(vec3f(.000001),vec3f(1.)-multiScatteringTotal);return vec4f(multiScatteringResult,1.);}\n#endif\nfn computeCosHorizonAngleFromZenith(radius: f32)->f32 {let sinAngleBetweenHorizonAndNadir=min(1.,atmosphere.planetRadius/radius);let cosHorizonAngleFromNadir=sqrt(1.-sinAngleBetweenHorizonAndNadir*sinAngleBetweenHorizonAndNadir);let cosHorizonAngleFromZenith=-cosHorizonAngleFromNadir;return cosHorizonAngleFromZenith;}\n#if RENDER_SKY_VIEW\nfn getSkyViewParametersFromUV(\nradius: f32,\nuv: vec2f,\ncosAngleBetweenViewAndZenith: ptr<function,f32>,\ncosAngleBetweenViewAndLightOnPlane: ptr<function,f32>\n) {let unit=uvToUnit(uv,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);let cosHorizonAngleFromZenith=computeCosHorizonAngleFromZenith(radius);if (unit.y<.5) {var coord=2.*unit.y; \ncoord*=coord; \n*cosAngleBetweenViewAndZenith=mix(-1.,cosHorizonAngleFromZenith,coord); } else {var coord=2.*unit.y-1.; \ncoord*=coord; \n*cosAngleBetweenViewAndZenith=mix(cosHorizonAngleFromZenith,1.,coord); }\n*cosAngleBetweenViewAndLightOnPlane=1.-2.*unit.x;}\nfn renderSkyView(uv: vec2f,transmittanceLut: texture_2d<f32>,multiScatteringLut: texture_2d<f32>)->vec4f {var cosAngleBetweenViewAndZenith: f32;var cosAngleBetweenViewAndLightOnPlane: f32;getSkyViewParametersFromUV(atmosphere.clampedCameraRadius,uv,&cosAngleBetweenViewAndZenith,&cosAngleBetweenViewAndLightOnPlane);let sinAngleBetweenViewAndZenith=sqrtClamped(1.-cosAngleBetweenViewAndZenith*cosAngleBetweenViewAndZenith);let sinAngleBetweenViewAndLightOnPlane=sqrtClamped(1.-cosAngleBetweenViewAndLightOnPlane*cosAngleBetweenViewAndLightOnPlane);let rayDirection =\nvec3f(\nsinAngleBetweenViewAndZenith*cosAngleBetweenViewAndLightOnPlane,\ncosAngleBetweenViewAndZenith,\nsinAngleBetweenViewAndZenith*sinAngleBetweenViewAndLightOnPlane);var intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\nvec3f(0.,atmosphere.clampedCameraRadius,0.),\natmosphere.clampedCameraRadius,\nvec3f(0.,1.,0.),\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere\n);if (!intersectsAtmosphere) {return vec4f(0.);}\nvar transmittanceVal: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLightRelativeToCameraGeocentricNormal,\n100000000.,\natmosphere.skyViewLutSampleCount,\n-1.,\n&transmittanceVal\n);let transparency=1.-avg(transmittanceVal);return vec4f(radiance,transparency);}\n#endif\n#if RENDER_CAMERA_VOLUME\nfn renderCameraVolume(\npositionOnNearPlane: vec3f,\nlayerIdx: f32,\ntransmittanceLut: texture_2d<f32>,\nmultiScatteringLut: texture_2d<f32>\n)->vec4f {var result=vec4f(0.);let rayDirection=normalize(positionOnNearPlane);let layer=layerIdxToAerialPerspectiveLayer(layerIdx);let tMax=toAerialPerspectiveDepth(layer);var tMaxMax=tMax;var cameraPositionGlobalClampedToTopOfAtmosphere=atmosphere.clampedCameraPositionGlobal;if (atmosphere.clampedCameraRadius>=atmosphere.atmosphereRadius) {var intersectsAtmosphere=false;moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return result;}\nlet distanceToAtmosphere=distance(atmosphere.clampedCameraPositionGlobal,cameraPositionGlobalClampedToTopOfAtmosphere);if (tMaxMax<distanceToAtmosphere) {return result;}\ntMaxMax=max(0.,tMaxMax-distanceToAtmosphere);}\nlet sampleCount=min(atmosphere.skyViewLutSampleCount,2.*layer+2.);var transmittance: vec3f;let radiance=integrateScatteredRadiance(\ntrue,\natmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\ntMaxMax,\nsampleCount,\n-1.,\n&transmittance);let transparency=1.-avg(transmittance);result=vec4f(radiance,transparency);return result;}\n#endif\n";
1775
+ t.ShaderStore.IncludesShadersStoreWGSL[pt] || (t.ShaderStore.IncludesShadersStoreWGSL[pt] = ft);
1776
+ var gt = { name: pt, shader: ft };
1777
+ var vt = { __proto__: null, atmosphereFunctionsWGSL: gt };
1778
+ var St = "atmosphereUboDeclaration", _t = "struct Atmosphere {peakRayleighScattering: vec3<f32>,\nplanetRadius: f32,\npeakMieScattering: vec3<f32>,\natmosphereThickness: f32,\npeakMieAbsorption: vec3<f32>,\nplanetRadiusSquared: f32,\npeakMieExtinction: vec3<f32>,\natmosphereRadius: f32,\npeakOzoneAbsorption: vec3<f32>,\natmosphereRadiusSquared: f32,\nhorizonDistanceToAtmosphereEdge: f32,\nhorizonDistanceToAtmosphereEdgeSquared: f32,\nplanetRadiusWithOffset: f32,\nplanetRadiusOffset: f32,\natmosphereExposure: f32,\naerialPerspectiveRadianceBias: f32,\ninverseAtmosphereThickness: f32,\naerialPerspectiveTransmittanceScale: f32,\ninverseViewProjectionWithoutTranslation: mat4x4<f32>,\ndirectionToLight: vec3<f32>,\nmultiScatteringIntensity: f32,\ndirectionToLightRelativeToCameraGeocentricNormal: vec3<f32>,\ncameraRadius: f32,\nlightRadianceAtCamera: vec3<f32>,\ndiffuseSkyIrradianceDesaturationFactor: f32,\ngroundAlbedo: vec3<f32>,\naerialPerspectiveSaturation: f32,\nminMultiScattering: vec3<f32>,\ndiffuseSkyIrradianceIntensity: f32,\ncameraPositionGlobal: vec3<f32>,\nlightIntensity: f32,\nclampedCameraPositionGlobal: vec3<f32>,\naerialPerspectiveIntensity: f32,\ncameraGeocentricNormal: vec3<f32>,\nclampedCameraRadius: f32,\ncameraForward: vec3<f32>,\nclampedCameraHeight: f32,\ncameraPosition: vec3<f32>,\ncosCameraHorizonAngleFromZenith: f32,\nviewport: vec4<f32>,\nadditionalDiffuseSkyIrradiance: vec3<f32>,\ncameraHeight: f32,\ncameraNearPlane: f32,\noriginHeight: f32,\nsinCameraAtmosphereHorizonAngleFromNadir: f32,\ntransmittanceSampleCount: f32,\nskyViewLutSampleCount: f32,\nmultiScatteringLutSampleCount: f32,\nmultiScatteringAzimuthSampleCount: f32,\nmultiScatteringInclinationSampleCount: f32,\ndiffuseSkyIrradianceLutSampleCount: f32};var<uniform> atmosphere : Atmosphere;\n";
1779
+ t.ShaderStore.IncludesShadersStoreWGSL[St] || (t.ShaderStore.IncludesShadersStoreWGSL[St] = _t);
1780
+ var yt = { name: St, shader: _t };
1781
+ var Tt = { __proto__: null, atmosphereUboDeclarationWGSL: yt };
1782
+ var At = "atmosphereFunctions", Pt = "#include<intersectionFunctions>\nconst vec2 MultiScatteringLutSize=vec2(32.0,32.0);const vec2 MultiScatteringLutDomainInUVSpace=(MultiScatteringLutSize-vec2(1.0))/MultiScatteringLutSize;const vec2 MultiScatteringLutHalfTexelSize=vec2(0.5)/MultiScatteringLutSize;const float NumAerialPerspectiveLutLayers=32.0;const vec3 AerialPerspectiveLutSize=vec3(16.0,64.0,NumAerialPerspectiveLutLayers);const vec2 DiffuseSkyIrradianceLutSize=vec2(64.0,16.0);const vec2 DiffuseSkyIrradianceLutDomainInUVSpace=(DiffuseSkyIrradianceLutSize-vec2(1.0))/DiffuseSkyIrradianceLutSize;const vec2 DiffuseSkyIrradianceLutHalfTexelSize=vec2(0.5)/DiffuseSkyIrradianceLutSize;const vec2 SkyViewLutSize=vec2(128.0,128.0);const vec2 SkyViewLutDomainInUVSpace=(SkyViewLutSize-vec2(1.0))/SkyViewLutSize;const vec2 SkyViewLutHalfTexelSize=vec2(0.5)/SkyViewLutSize;const float AerialPerspectiveLutKMPerSlice=4.0;const float AerialPerspectiveLutRangeKM=AerialPerspectiveLutKMPerSlice*NumAerialPerspectiveLutLayers;const vec2 TransmittanceLutSize=vec2(256.,64.);const vec2 TransmittanceLutDomainInUVSpace=(TransmittanceLutSize-vec2(1.))/TransmittanceLutSize;const vec2 TransmittanceLutHalfTexelSize=vec2(0.5)/TransmittanceLutSize;const float TransmittanceHorizonRange=2.*TransmittanceLutHalfTexelSize.x;const float TransmittanceMaxUnoccludedU=1.-0.5*TransmittanceHorizonRange;const float TransmittanceMinOccludedU=1.+0.5*TransmittanceHorizonRange;vec2 uvToUnit(vec2 uv,vec2 domainInUVSpace,vec2 halfTexelSize) {return (uv-halfTexelSize)/domainInUVSpace;}\nvec2 unitToUV(vec2 unit,vec2 domainInUVSpace,vec2 halfTexelSize) {return unit*domainInUVSpace+halfTexelSize;}\nfloat sphereIntersectNearest(vec3 rayOrigin,vec3 rayDirection,float sphereRadius) {vec2 result=sphereIntersectFromOrigin(rayOrigin,rayDirection,sphereRadius);float c=dot(rayOrigin,rayOrigin)-sphereRadius*sphereRadius;return c>=0.0 ?\nresult.y :\nresult.x;}\nvoid moveToTopAtmosphere(\nvec3 cameraPosition,\nfloat positionRadius,\nvec3 positionGeocentricNormal,\nvec3 rayDirection,\nout bool intersectsAtmosphere,\nout vec3 cameraPositionClampedToTopOfAtmosphere) {intersectsAtmosphere=true;cameraPositionClampedToTopOfAtmosphere=cameraPosition;if (positionRadius>atmosphereRadius) {float tTop=sphereIntersectNearest(cameraPosition,rayDirection,atmosphereRadius);if (tTop>=0.0) {vec3 upOffset=-planetRadiusOffset*positionGeocentricNormal;cameraPositionClampedToTopOfAtmosphere=cameraPosition+rayDirection*tTop+upOffset;} else {intersectsAtmosphere=false;}}}\nvoid getSkyViewUVFromParameters(\nbool intersectsGround,\nfloat cosHorizonAngleFromZenith,\nfloat cosAngleBetweenViewAndZenith,\nfloat cosAngleBetweenViewAndLightOnPlane,\nout vec2 uv)\n{vec2 unit=vec2(0.);if (intersectsGround) {float coord=(cosAngleBetweenViewAndZenith+1.)/(cosHorizonAngleFromZenith+1.);coord=sqrtClamped(coord); \nunit.y=0.5*coord; } else {float coord=(cosAngleBetweenViewAndZenith-cosHorizonAngleFromZenith)/(1.-cosHorizonAngleFromZenith);coord=sqrtClamped(coord); \nunit.y=0.5*coord+0.5; }\n{float coord=0.5-0.5*cosAngleBetweenViewAndLightOnPlane;unit.x=coord;}\nuv=unitToUV(unit,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);}\n#if USE_SKY_VIEW_LUT && SAMPLE_SKY_VIEW_LUT\nvec4 sampleSkyViewLut(\nsampler2D skyViewLut,\nfloat positionRadius,\nvec3 geocentricNormal,\nvec3 rayDirection,\nvec3 directionToLight,\nfloat cosHorizonAngleFromZenith,\nout float cosAngleBetweenViewAndZenith,\nout bool isRayIntersectingGround) {cosAngleBetweenViewAndZenith=dot(rayDirection,geocentricNormal);if (positionRadius>atmosphereRadius) {float sinAngleBetweenViewAndNadir=sqrtClamped(1.-cosAngleBetweenViewAndZenith*cosAngleBetweenViewAndZenith);if (sinAngleBetweenViewAndNadir>sinCameraAtmosphereHorizonAngleFromNadir) {isRayIntersectingGround=false;return vec4(0.);}}\nvec3 sideVector=normalize(cross(geocentricNormal,rayDirection));vec3 forwardVector=normalize(cross(sideVector,geocentricNormal));vec2 lightOnPlane=normalize(vec2(dot(directionToLight,forwardVector),dot(directionToLight,sideVector)));float cosAngleBetweenViewAndLightOnPlane=lightOnPlane.x;float rayIntersectionScale=mix(0.95,1.,saturate((positionRadius-planetRadius)/atmosphereThickness));isRayIntersectingGround =\npositionRadius>planetRadius &&\n(rayIntersectionScale*cosAngleBetweenViewAndZenith)<=cosHorizonAngleFromZenith;vec2 uv;getSkyViewUVFromParameters(\nisRayIntersectingGround,\ncosHorizonAngleFromZenith,\ncosAngleBetweenViewAndZenith,\ncosAngleBetweenViewAndLightOnPlane,\nuv);return textureLod(skyViewLut,uv,0.);}\n#endif\nfloat computeRayleighPhase(float onePlusCosThetaSq) {return 0.0596831037*onePlusCosThetaSq;}\nfloat computeMiePhaseCornetteShanks(float cosTheta,float onePlusCosThetaSq) {const float g=0.8;const float gSquared=g*g;const float oneMinusGSquared=1.-gSquared;const float onePlusGSquared=1.+gSquared;const float twoPlusGSquared=2.+gSquared;const float twoG=2.*g;const float threeOverEightPi=3./(8.*PI);return threeOverEightPi*oneMinusGSquared*onePlusCosThetaSq/(twoPlusGSquared*pow(onePlusGSquared-twoG*cosTheta,1.5));}\nfloat computeOzoneDensity(float normalizedViewHeight) {const float MinOzoneDensity=0.135;const float OneMinusMinOzoneDensity=1.-MinOzoneDensity;const float OzoneStartHeight=.15; \nconst float PeakOzoneHeight=.25;const float MaxOzoneHeight=0.6;const float InverseRampupDistance=1./(PeakOzoneHeight-OzoneStartHeight);const float InverseRampdownDistance=1./(MaxOzoneHeight-PeakOzoneHeight);float lowerAtmosphereDensity=MinOzoneDensity+OneMinusMinOzoneDensity*max(0.,normalizedViewHeight-OzoneStartHeight)*InverseRampupDistance;float sqrtUpperAtmosphereDensity=max(0.,1.-(normalizedViewHeight-PeakOzoneHeight)*InverseRampdownDistance);float upperAtmosphereDensity=sqrtUpperAtmosphereDensity*sqrtUpperAtmosphereDensity;float densityOzone=normalizedViewHeight<PeakOzoneHeight ? lowerAtmosphereDensity : upperAtmosphereDensity;return densityOzone;}\nvoid sampleMediumRGB(\nfloat viewHeight,\nout vec3 scatteringRayleigh,\nout vec3 scatteringMie,\nout vec3 extinction,\nout vec3 scattering) {float normalizedViewHeight=saturate(viewHeight*inverseAtmosphereThickness);float densityMie=exp(-83.333*normalizedViewHeight);float densityRayleigh=exp(-12.5*normalizedViewHeight);float densityOzone=computeOzoneDensity(normalizedViewHeight);scatteringRayleigh=densityRayleigh*peakRayleighScattering;scatteringMie=densityMie*peakMieScattering;scattering=scatteringMie+scatteringRayleigh;vec3 extinctionRayleigh=scatteringRayleigh;vec3 extinctionMie=densityMie*peakMieExtinction;vec3 extinctionOzone=densityOzone*peakOzoneAbsorption;extinction=extinctionRayleigh+extinctionMie+extinctionOzone;}\nvec3 computeTransmittance(vec3 rayOriginGlobal,vec3 rayDirection,float tMax,float sampleCount) {vec3 opticalDepth=vec3(0.);float t=0.;float sampleSegmentWeight=tMax/sampleCount;const float sampleSegmentT=0.3;for (float s=0.; s<sampleCount; s+=1.) {float newT=sampleSegmentWeight*(s+sampleSegmentT);float dt=newT-t;t=newT;vec3 scatteringRayleigh,scatteringMie,extinction,scattering;vec3 samplePositionGlobal=rayOriginGlobal+t*rayDirection;sampleMediumRGB(length(samplePositionGlobal)-planetRadius,scatteringRayleigh,scatteringMie,extinction,scattering);opticalDepth+=extinction*dt;}\nreturn exp(-opticalDepth);}\n#if defined(SAMPLE_TRANSMITTANCE_LUT) || !defined(EXCLUDE_RAY_MARCHING_FUNCTIONS)\nvec2 getTransmittanceUV(float radius,float cosAngleLightToZenith,out float distanceToHorizon) {float radiusSquared=radius*radius;distanceToHorizon=sqrtClamped(radiusSquared-planetRadiusSquared);float cosAngleLightToZenithSquared=cosAngleLightToZenith*cosAngleLightToZenith;float discriminant=radiusSquared*(cosAngleLightToZenithSquared-1.)+atmosphereRadiusSquared;float distanceToAtmosphereEdge=max(0.,-radius*cosAngleLightToZenith+sqrtClamped(discriminant));float minDistanceToAtmosphereEdge=max(0.,atmosphereRadius-radius);float maxDistanceToAtmosphereEdge=distanceToHorizon+horizonDistanceToAtmosphereEdge;float cosAngleLightToZenithCoordinate=(distanceToAtmosphereEdge-minDistanceToAtmosphereEdge)/max(0.000001,maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);float distanceToHorizonCoordinate=distanceToHorizon/max(0.000001,horizonDistanceToAtmosphereEdge);vec2 unit=vec2(cosAngleLightToZenithCoordinate,distanceToHorizonCoordinate);return unit*TransmittanceLutDomainInUVSpace+TransmittanceLutHalfTexelSize; }\nvec4 sampleTransmittanceLut(sampler2D transmittanceLut,float positionRadius,float cosAngleLightToZenith) {float distanceToHorizon;vec2 uv=getTransmittanceUV(positionRadius,cosAngleLightToZenith,distanceToHorizon);float weight=smoothstep(TransmittanceMinOccludedU,TransmittanceMaxUnoccludedU,uv.x);return weight*textureLod(transmittanceLut,uv,0.);}\n#endif\n#ifndef EXCLUDE_RAY_MARCHING_FUNCTIONS\n#ifndef COMPUTE_MULTI_SCATTERING\nvec3 sampleMultiScatteringLut(sampler2D multiScatteringLut,float radius,float cosAngleLightToZenith) {vec2 unit=vec2(0.5+0.5*cosAngleLightToZenith,(radius-planetRadius)/atmosphereThickness);vec2 uv=unitToUV(unit,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);vec3 multiScattering=textureLod(multiScatteringLut,uv,0.).rgb;return max(minMultiScattering,multiScattering);}\n#endif\nconst float uniformPhase=RECIPROCAL_PI4;vec3 integrateScatteredRadiance(\nbool isAerialPerspectiveLut,\nfloat lightIntensity,\nsampler2D transmittanceLut,\n#ifndef COMPUTE_MULTI_SCATTERING\nsampler2D multiScatteringLut,\nfloat multiScatteringIntensity,\n#endif\nvec3 rayOriginGlobal,\nvec3 rayDirection,\nvec3 directionToLight,\nfloat tMaxMax,\nfloat sampleCount,\nfloat distanceToSurface,\nout vec3 transmittance\n#if COMPUTE_MULTI_SCATTERING\n,out vec3 multiScattering\n#endif\n) {vec3 radiance=vec3(0.);transmittance=vec3(1.);\n#if COMPUTE_MULTI_SCATTERING\nmultiScattering=vec3(0.);\n#endif\nfloat tBottom=sphereIntersectNearest(rayOriginGlobal,rayDirection,planetRadius);float tTop=sphereIntersectNearest(rayOriginGlobal,rayDirection,atmosphereRadius);float tMax=0.;if (tBottom<0.) {if (tTop<0.) {return radiance;} else {tMax=tTop;}} else {if (tTop>0.) {if (isAerialPerspectiveLut) {tMax=tTop;} else {tMax=min(tBottom,tTop);}}}\nif (distanceToSurface>0. && distanceToSurface<tMax) {tMax=distanceToSurface;}\ntMax=min(tMax,tMaxMax);\n#ifndef COMPUTE_MULTI_SCATTERING\nfloat cosTheta=dot(rayDirection,directionToLight);float onePlusCosThetaSq=1.+cosTheta*cosTheta;float rayleighPhase=computeRayleighPhase(onePlusCosThetaSq);float miePhase=computeMiePhaseCornetteShanks(cosTheta,onePlusCosThetaSq);\n#endif\nfloat transmittanceScale=isAerialPerspectiveLut ? aerialPerspectiveTransmittanceScale : 1.;float t=0.;float sampleSegmentWeight=tMax/sampleCount;const float sampleSegmentT=0.3;for (float s=0.; s<sampleCount; s+=1.) {float newT=sampleSegmentWeight*(s+sampleSegmentT);float dt=newT-t;t=newT;vec3 samplePositionGlobal=rayOriginGlobal+t*rayDirection;float sampleRadiusGlobal=length(samplePositionGlobal);vec3 sampleGeocentricNormal=samplePositionGlobal/sampleRadiusGlobal;float sampleCosAngleLightToZenith=dot(directionToLight,sampleGeocentricNormal);vec3 scatteringRayleigh,scatteringMie,extinction,scattering;sampleMediumRGB(sampleRadiusGlobal-planetRadius,scatteringRayleigh,scatteringMie,extinction,scattering);vec3 transmittanceToLight=sampleTransmittanceLut(transmittanceLut,sampleRadiusGlobal,sampleCosAngleLightToZenith).rgb;\n#if COMPUTE_MULTI_SCATTERING\nvec3 phaseTimesScattering=uniformPhase*scattering;vec3 S=transmittanceToLight*phaseTimesScattering;\n#else\nvec3 phaseTimesScattering=scatteringMie*miePhase+scatteringRayleigh*rayleighPhase;vec3 multiScatteredRadiance=sampleMultiScatteringLut(multiScatteringLut,sampleRadiusGlobal,sampleCosAngleLightToZenith);vec3 S=transmittanceScale*transmittanceToLight*phaseTimesScattering+multiScatteringIntensity*multiScatteredRadiance*scattering;\n#endif\nvec3 sampleOpticalDepth=extinction*dt;vec3 sampleTransmittance=exp(-sampleOpticalDepth);vec3 clampedExtinction=max(vec3(0.0000001),extinction);vec3 SInt=(S-S*sampleTransmittance)/clampedExtinction;radiance+=transmittance*SInt;\n#if COMPUTE_MULTI_SCATTERING\nvec3 MSInt=(scattering-scattering*sampleTransmittance)/clampedExtinction;multiScattering+=transmittance*MSInt;\n#endif\ntransmittance*=sampleTransmittance;}\n#if USE_GROUND_ALBEDO\nif (tMax==tBottom && tBottom>0.) {vec3 planetPos=rayOriginGlobal+tBottom*rayDirection;float planetPosRadius=length(planetPos);vec3 planetPosGeocentricNormal=planetPos/planetPosRadius;float nDotL=dot(directionToLight,planetPosGeocentricNormal);vec3 lightTransmittance=sampleTransmittanceLut(transmittanceLut,planetPosRadius,nDotL).rgb;const float diffuseBrdf=RECIPROCAL_PI;radiance+=lightTransmittance*transmittance*groundAlbedo*(nDotL*diffuseBrdf);}\n#endif\nradiance*=lightIntensity;return radiance;}\n#endif\nfloat layerIdxToAerialPerspectiveLayer(float layerIdx) {float layer=(layerIdx+1.)/NumAerialPerspectiveLutLayers;layer*=layer; \nlayer*=NumAerialPerspectiveLutLayers;return layer;}\nfloat toAerialPerspectiveDepth(float layer) {return layer*AerialPerspectiveLutKMPerSlice;}\nfloat toAerialPerspectiveLayer(float distance,float aerialPerspectiveLutDistancePerSlice) {return distance/aerialPerspectiveLutDistancePerSlice;}\nvec4 applyAerialPerspectiveSaturation(vec4 aerialPerspective) {float previousRadiance=getLuminanceUnclamped(aerialPerspective.rgb);aerialPerspective.rgb=mix(vec3(previousRadiance),aerialPerspective.rgb,aerialPerspectiveSaturation);return aerialPerspective;}\nvec4 applyAerialPerspectiveIntensity(vec4 aerialPerspective) {\n#if APPLY_AERIAL_PERSPECTIVE_INTENSITY\nif (aerialPerspectiveIntensity==0.) {aerialPerspective=vec4(0.);} else {float previousAlpha=aerialPerspective.a;aerialPerspective/=max(0.00001,previousAlpha);aerialPerspective*=pow(previousAlpha,1./aerialPerspectiveIntensity);}\n#endif\nreturn aerialPerspective;}\nvec4 applyAerialPerspectiveRadianceBias(vec4 aerialPerspective) {\n#if APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS\nfloat originalRadiance=dot(aerialPerspective.rgb,LuminanceEncodeApprox);float targetRadiance=originalRadiance+aerialPerspectiveRadianceBias;if (originalRadiance>0.) {aerialPerspective*=max(0.,targetRadiance/originalRadiance);} else {aerialPerspective=max(vec4(0.),vec4(aerialPerspectiveRadianceBias));}\naerialPerspective.a=min(aerialPerspective.a,1.);\n#endif\nreturn aerialPerspective;}\nbool sampleAerialPerspectiveLut(\nvec2 screenUV,\nbool clampToLutRange,\nfloat distanceFromCamera,\nfloat numAerialPerspectiveLutLayers,\nfloat aerialPerspectiveLutKMPerSlice,\nfloat aerialPerspectiveLutRangeKM,\nout vec4 aerialPerspective) {aerialPerspective=vec4(0.);\n#if USE_AERIAL_PERSPECTIVE_LUT\nif (distanceFromCamera>0. &&\n(clampToLutRange || distanceFromCamera<aerialPerspectiveLutRangeKM) &&\nclampedCameraRadius<=atmosphereRadius) {float layer=toAerialPerspectiveLayer(distanceFromCamera,aerialPerspectiveLutKMPerSlice);float normalizedLayer=sqrt(layer/numAerialPerspectiveLutLayers); \nlayer=min(normalizedLayer*numAerialPerspectiveLutLayers,numAerialPerspectiveLutLayers);float weight=min(layer,1.);float layerIdx=max(0.,layer-1.);float floorLayerIdx=floor(layerIdx);vec4 aerialPerspectiveLayer0=textureLod(aerialPerspectiveLut,vec3(screenUV,floorLayerIdx),0.);vec4 aerialPerspectiveLayer1=textureLod(aerialPerspectiveLut,vec3(screenUV,floorLayerIdx+1.),0.);aerialPerspective=mix(aerialPerspectiveLayer0,aerialPerspectiveLayer1,layerIdx-floorLayerIdx);aerialPerspective.rgb*=atmosphereExposure;aerialPerspective=applyAerialPerspectiveSaturation(aerialPerspective);aerialPerspective=weight*applyAerialPerspectiveIntensity(aerialPerspective);aerialPerspective=applyAerialPerspectiveRadianceBias(aerialPerspective);return true;}\n#endif\nreturn false;}\n#if RENDER_TRANSMITTANCE\nvoid getTransmittanceParameters(vec2 uv,out float radius,out float cosAngleLightToZenith,out float distanceToAtmosphereEdge) {vec2 unit=uvToUnit(uv,TransmittanceLutDomainInUVSpace,TransmittanceLutHalfTexelSize);float distanceToHorizon=unit.y*horizonDistanceToAtmosphereEdge;float distanceToHorizonSquared=distanceToHorizon*distanceToHorizon;radius=sqrtClamped(distanceToHorizonSquared+planetRadiusSquared);float minDistanceToAtmosphereEdge=atmosphereRadius-radius;float maxDistanceToAtmosphereEdge=distanceToHorizon+horizonDistanceToAtmosphereEdge;distanceToAtmosphereEdge=minDistanceToAtmosphereEdge+unit.x*(maxDistanceToAtmosphereEdge-minDistanceToAtmosphereEdge);float distanceToAtmosphereEdgeSquared=distanceToAtmosphereEdge*distanceToAtmosphereEdge;cosAngleLightToZenith =\ndistanceToAtmosphereEdge<=0. ?\n1. :\n(horizonDistanceToAtmosphereEdgeSquared-distanceToAtmosphereEdgeSquared-distanceToHorizonSquared)/(2.*radius*distanceToAtmosphereEdge);cosAngleLightToZenith=clamp(cosAngleLightToZenith,-1.,1.);}\nvec4 renderTransmittance(vec2 uv) {float radius,cosAngleLightToZenith,distanceToAtmosphereEdgeAlongAngle;getTransmittanceParameters(uv,radius,cosAngleLightToZenith,distanceToAtmosphereEdgeAlongAngle);float sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);vec3 directionToLight=normalize(vec3(0.,cosAngleLightToZenith,sinAngleLightToZenith));vec3 transmittance=computeTransmittance(vec3(0.,radius,0.),directionToLight,distanceToAtmosphereEdgeAlongAngle,transmittanceSampleCount);return vec4(transmittance,avg(transmittance));}\n#endif\n#if RENDER_MULTI_SCATTERING\nvec3 getSphereSample(float azimuth,float inclination,out float sinInclination) {sinInclination=sin(inclination);return vec3(sinInclination*sin(azimuth),cos(inclination),sinInclination*cos(azimuth));}\nvec4 renderMultiScattering(vec2 uv,sampler2D transmittanceLut) {float MultiScatteringAzimuthIterationAngle=TWO_PI/multiScatteringAzimuthSampleCount;float MultiScatteringInclinationIterationAngle=PI/multiScatteringInclinationSampleCount;float MultiScatteringAngleStepProduct=MultiScatteringAzimuthIterationAngle*MultiScatteringInclinationIterationAngle;vec2 unit=uvToUnit(uv,MultiScatteringLutDomainInUVSpace,MultiScatteringLutHalfTexelSize);float cosAngleLightToZenith=2.*unit.x-1.;float sinAngleLightToZenith=sqrtClamped(1.-cosAngleLightToZenith*cosAngleLightToZenith);vec3 directionToLight=normalize(vec3(0.,cosAngleLightToZenith,sinAngleLightToZenith));float rayOriginRadius=planetRadius+max(unit.y,0.001)*atmosphereThickness;vec3 rayOrigin=vec3(0.,rayOriginRadius,0.);vec3 inscattered=vec3(0.);vec3 multiScatteringTotal=vec3(0.);for (float i=0.5; i<multiScatteringAzimuthSampleCount; i+=1.) {float azimuth=MultiScatteringAzimuthIterationAngle*i;for (float j=0.5; j<multiScatteringInclinationSampleCount; j+=1.) {float inclination=MultiScatteringInclinationIterationAngle*j;float sinInclination;vec3 rayDirection=getSphereSample(azimuth,inclination,sinInclination);vec3 transmittance;vec3 multiScattering;vec3 radiance=integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nrayOrigin,\nrayDirection,\ndirectionToLight,\n100000000.,\nmultiScatteringLutSampleCount,\n-1.,\ntransmittance,\nmultiScattering);float weight=RECIPROCAL_PI4*abs(sinInclination)*MultiScatteringAngleStepProduct;multiScatteringTotal+=multiScattering*weight;inscattered+=radiance*weight;}}\nvec3 multiScattering=inscattered/max(vec3(0.000001),vec3(1.)-multiScatteringTotal);return vec4(multiScattering,1.);}\n#endif\nfloat computeCosHorizonAngleFromZenith(float radius) {float sinAngleBetweenHorizonAndNadir=min(1.,planetRadius/radius);float cosHorizonAngleFromNadir=sqrt(1.-sinAngleBetweenHorizonAndNadir*sinAngleBetweenHorizonAndNadir);float cosHorizonAngleFromZenith=-cosHorizonAngleFromNadir;return cosHorizonAngleFromZenith;}\n#if RENDER_SKY_VIEW\nvoid getSkyViewParametersFromUV(\nfloat radius,\nvec2 uv,\nout float cosAngleBetweenViewAndZenith,\nout float cosAngleBetweenViewAndLightOnPlane) {vec2 unit=uvToUnit(uv,SkyViewLutDomainInUVSpace,SkyViewLutHalfTexelSize);float cosHorizonAngleFromZenith=computeCosHorizonAngleFromZenith(radius);if (unit.y<0.5) {float coord=2.*unit.y; \ncoord*=coord; \ncosAngleBetweenViewAndZenith=mix(-1.,cosHorizonAngleFromZenith,coord); } else {float coord=2.*unit.y-1.; \ncoord*=coord; \ncosAngleBetweenViewAndZenith=mix(cosHorizonAngleFromZenith,1.,coord); }\n{float coord=unit.x;cosAngleBetweenViewAndLightOnPlane=1.-2.*coord;}}\nvec4 renderSkyView(vec2 uv,sampler2D transmittanceLut,sampler2D multiScatteringLut) {float cosAngleBetweenViewAndZenith;float cosAngleBetweenViewAndLightOnPlane;getSkyViewParametersFromUV(clampedCameraRadius,uv,cosAngleBetweenViewAndZenith,cosAngleBetweenViewAndLightOnPlane);float sinAngleBetweenViewAndZenith=sqrtClamped(1.-cosAngleBetweenViewAndZenith*cosAngleBetweenViewAndZenith);float sinAngleBetweenViewAndLightOnPlane=sqrtClamped(1.-cosAngleBetweenViewAndLightOnPlane*cosAngleBetweenViewAndLightOnPlane);vec3 rayDirection =\nvec3(\nsinAngleBetweenViewAndZenith*cosAngleBetweenViewAndLightOnPlane,\ncosAngleBetweenViewAndZenith,\nsinAngleBetweenViewAndZenith*sinAngleBetweenViewAndLightOnPlane);bool intersectsAtmosphere=false;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=vec3(0.);moveToTopAtmosphere(\nvec3(0.,clampedCameraRadius,0.),\nclampedCameraRadius,\nvec3(0.,1.,0.),\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return vec4(0.);}\nvec3 transmittance;vec3 radiance=integrateScatteredRadiance(\nfalse,\natmosphereExposure*lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLightRelativeToCameraGeocentricNormal,\n100000000.,\nskyViewLutSampleCount,\n-1.,\ntransmittance);float transparency=1.-avg(transmittance);return vec4(radiance,transparency);}\n#endif\n#if RENDER_CAMERA_VOLUME\nvec4 renderCameraVolume(\nvec3 positionOnNearPlane,\nfloat layerIdx,\nsampler2D transmittanceLut,\nsampler2D multiScatteringLut) {vec4 result=vec4(0.);vec3 rayDirection=normalize(positionOnNearPlane);float layer=layerIdxToAerialPerspectiveLayer(layerIdx);float tMax=toAerialPerspectiveDepth(layer);float tMaxMax=tMax;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=clampedCameraPositionGlobal;if (clampedCameraRadius>=atmosphereRadius) {bool intersectsAtmosphere=false;moveToTopAtmosphere(\nclampedCameraPositionGlobal,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return result;}\nfloat distanceToAtmosphere=distance(clampedCameraPositionGlobal,cameraPositionGlobalClampedToTopOfAtmosphere);if (tMaxMax<distanceToAtmosphere) {return result;}\ntMaxMax=max(0.,tMaxMax-distanceToAtmosphere);}\nfloat sampleCount=min(skyViewLutSampleCount,2.*layer+2.);vec3 transmittance;vec3 radiance=integrateScatteredRadiance(\ntrue,\nlightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLight,\ntMaxMax,\nsampleCount,\n-1.,\ntransmittance);float transparency=1.-avg(transmittance);result=vec4(radiance,transparency);return result;}\n#endif\n";
1783
+ t.ShaderStore.IncludesShadersStore[At] || (t.ShaderStore.IncludesShadersStore[At] = Pt);
1784
+ var Lt = { name: At, shader: Pt };
1785
+ var Rt = { __proto__: null, atmosphereFunctions: Lt };
1786
+ var Et = "atmosphereUboDeclaration", Ct = "layout(std140,column_major) uniform;uniform Atmosphere {vec3 peakRayleighScattering;float planetRadius;vec3 peakMieScattering;float atmosphereThickness;vec3 peakMieAbsorption;float planetRadiusSquared;vec3 peakMieExtinction;float atmosphereRadius;vec3 peakOzoneAbsorption;float atmosphereRadiusSquared;float horizonDistanceToAtmosphereEdge;float horizonDistanceToAtmosphereEdgeSquared;float planetRadiusWithOffset;float planetRadiusOffset;float atmosphereExposure;float aerialPerspectiveRadianceBias;float inverseAtmosphereThickness;float aerialPerspectiveTransmittanceScale;mat4 inverseViewProjectionWithoutTranslation;vec3 directionToLight;float multiScatteringIntensity;vec3 directionToLightRelativeToCameraGeocentricNormal;float cameraRadius;vec3 lightRadianceAtCamera;float diffuseSkyIrradianceDesaturationFactor;vec3 groundAlbedo;float aerialPerspectiveSaturation;vec3 minMultiScattering;float diffuseSkyIrradianceIntensity;vec3 cameraPositionGlobal;float lightIntensity;vec3 clampedCameraPositionGlobal;float aerialPerspectiveIntensity;vec3 cameraGeocentricNormal;float clampedCameraRadius;vec3 cameraForward;float clampedCameraHeight;vec3 cameraPosition;float cosCameraHorizonAngleFromZenith;vec4 viewport;vec3 additionalDiffuseSkyIrradiance;float cameraHeight;float cameraNearPlane;float originHeight;float sinCameraAtmosphereHorizonAngleFromNadir;float transmittanceSampleCount;float skyViewLutSampleCount;float multiScatteringLutSampleCount;float multiScatteringAzimuthSampleCount;float multiScatteringInclinationSampleCount;float diffuseSkyIrradianceLutSampleCount;};\n";
1787
+ t.ShaderStore.IncludesShadersStore[Et] || (t.ShaderStore.IncludesShadersStore[Et] = Ct);
1788
+ var xt = { name: Et, shader: Ct };
1789
+ var It = { __proto__: null, atmosphereUboDeclaration: xt };
1790
+ var wt = "atmosphereFragmentDeclaration", Mt = "uniform vec3 peakRayleighScattering;uniform float planetRadius;uniform vec3 peakMieScattering;uniform float atmosphereThickness;uniform vec3 peakMieAbsorption;uniform float planetRadiusSquared;uniform vec3 peakMieExtinction;uniform float atmosphereRadius;uniform vec3 peakOzoneAbsorption;uniform float atmosphereRadiusSquared;uniform float horizonDistanceToAtmosphereEdge;uniform float horizonDistanceToAtmosphereEdgeSquared;uniform float planetRadiusWithOffset;uniform float planetRadiusOffset;uniform float atmosphereExposure;uniform float aerialPerspectiveRadianceBias;uniform float inverseAtmosphereThickness;uniform float aerialPerspectiveTransmittanceScale;uniform mat4 inverseViewProjectionWithoutTranslation;uniform vec3 directionToLight;uniform float multiScatteringIntensity;uniform vec3 directionToLightRelativeToCameraGeocentricNormal;uniform float cameraRadius;uniform vec3 lightRadianceAtCamera;uniform float diffuseSkyIrradianceDesaturationFactor;uniform vec3 groundAlbedo;uniform float aerialPerspectiveSaturation;uniform vec3 minMultiScattering;uniform float diffuseSkyIrradianceIntensity;uniform vec3 cameraPositionGlobal;uniform float lightIntensity;uniform vec3 clampedCameraPositionGlobal;uniform float aerialPerspectiveIntensity;uniform vec3 cameraGeocentricNormal;uniform float clampedCameraRadius;uniform vec3 cameraForward;uniform float clampedCameraHeight;uniform vec3 cameraPosition;uniform float cosCameraHorizonAngleFromZenith;uniform vec4 viewport;uniform vec3 additionalDiffuseSkyIrradiance;uniform float cameraHeight;uniform float cameraNearPlane;uniform float originHeight;uniform float sinCameraAtmosphereHorizonAngleFromNadir;uniform float transmittanceSampleCount;uniform float skyViewLutSampleCount;uniform float multiScatteringLutSampleCount;uniform float multiScatteringAzimuthSampleCount;uniform float multiScatteringInclinationSampleCount;uniform float diffuseSkyIrradianceLutSampleCount;\n";
1791
+ t.ShaderStore.IncludesShadersStore[wt] || (t.ShaderStore.IncludesShadersStore[wt] = Mt);
1792
+ var bt = { name: wt, shader: Mt };
1793
+ var Dt = { __proto__: null, atmosphereFragmentDeclaration: bt };
1794
+ var Ot = "fullscreenTriangleVertexShader", Nt = "#include<atmosphereUboDeclaration>\n#if POSITION_VEC2\nattribute position: vec2f;\n#else\nattribute position: vec3f;\n#endif\nuniform depth: f32;varying vUV: vec2f;\n#if COMPUTE_WORLD_RAY\nvarying positionOnNearPlane: vec3f;\n#endif\n#if COMPUTE_WORLD_RAY\nconst nearPlaneNDC: f32=-1.0;\n#endif\n@vertex\nfn main(input: VertexInputs)->FragmentInputs {vertexOutputs.position=vec4f(input.position.xy,uniforms.depth,1.0);vertexOutputs.vUV=input.position.xy*vec2f(0.5,0.5)+vec2f(0.5,0.5);\n#if COMPUTE_WORLD_RAY\nvertexOutputs.positionOnNearPlane=(atmosphere.inverseViewProjectionWithoutTranslation*vec4f(input.position.xy,nearPlaneNDC,1.0)).xyz;\n#endif\n}\n";
1795
+ t.ShaderStore.ShadersStoreWGSL[Ot] || (t.ShaderStore.ShadersStoreWGSL[Ot] = Nt);
1796
+ var Vt = [yt];
1797
+ try {
1798
+ for (var Vt_1 = __values(Vt), Vt_1_1 = Vt_1.next(); !Vt_1_1.done; Vt_1_1 = Vt_1.next()) {
1799
+ var e_87 = Vt_1_1.value;
1800
+ t.ShaderStore.IncludesShadersStoreWGSL[e_87.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_87.name] = e_87.shader);
1801
+ }
1802
+ }
1803
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1804
+ finally {
1805
+ try {
1806
+ if (Vt_1_1 && !Vt_1_1.done && (_a = Vt_1.return)) _a.call(Vt_1);
1807
+ }
1808
+ finally { if (e_1) throw e_1.error; }
1809
+ }
1810
+ var Ft = { __proto__: null, fullscreenTriangleVertexShaderWGSL: { name: Ot, shader: Nt } };
1811
+ var Ut = "diffuseSkyIrradiancePixelShader", kt = "#include<atmosphereUboDeclaration>\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nfn integrateForIrradiance(directionToLightParam: vec3f,rayDirection: vec3f,rayOrigin: vec3f)->vec3f {var transmittance: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\nrayOrigin,\nrayDirection.xzy,\ndirectionToLightParam.xzy,\n100000000.,\natmosphere.diffuseSkyIrradianceLutSampleCount,\n-1.,\n&transmittance);return radiance;}\n#include<importanceSampling>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\nvarying vUV: vec2f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {let unit=uvToUnit(input.vUV,DiffuseSkyIrradianceLutDomainInUVSpace,DiffuseSkyIrradianceLutHalfTexelSize);let cosLightInclination=2.*unit.x-1.;let sinLightInclination=sqrtClamped(1.-cosLightInclination*cosLightInclination);let directionToLight=normalize(vec3f(0.,cosLightInclination,sinLightInclination));let radius=max(atmosphere.planetRadiusWithOffset,unit.y*atmosphere.atmosphereThickness+atmosphere.planetRadius);let swappedDirectionToLight=vec3f(directionToLight.x,directionToLight.z,directionToLight.y); \nvar irradianceResult=PI*irradiance(\nswappedDirectionToLight,\nvec2f(radius,0.),\n1.,\nvec3f(1.),\nvec3f(1.));let averageIrradiance=getLuminanceUnclamped(irradianceResult);let newIrradiance=mix(irradianceResult,vec3f(averageIrradiance),atmosphere.diffuseSkyIrradianceDesaturationFactor);let newIrradianceScale=getLuminanceUnclamped(newIrradiance);let rescaling=averageIrradiance/max(0.000001,newIrradianceScale);irradianceResult=newIrradiance*rescaling;fragmentOutputs.color=vec4f(irradianceResult,1.);}\n";
1812
+ t.ShaderStore.ShadersStoreWGSL[Ut] || (t.ShaderStore.ShadersStoreWGSL[Ut] = kt);
1813
+ var Gt = [yt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, gt, t.importanceSamplingWGSL, t.pbrBRDFFunctionsWGSL, t.hdrFilteringFunctionsWGSL];
1814
+ try {
1815
+ for (var Gt_1 = __values(Gt), Gt_1_1 = Gt_1.next(); !Gt_1_1.done; Gt_1_1 = Gt_1.next()) {
1816
+ var e_88 = Gt_1_1.value;
1817
+ t.ShaderStore.IncludesShadersStoreWGSL[e_88.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_88.name] = e_88.shader);
1818
+ }
1819
+ }
1820
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1821
+ finally {
1822
+ try {
1823
+ if (Gt_1_1 && !Gt_1_1.done && (_b = Gt_1.return)) _b.call(Gt_1);
1824
+ }
1825
+ finally { if (e_2) throw e_2.error; }
1826
+ }
1827
+ var zt = { __proto__: null, diffuseSkyIrradiancePixelShaderWGSL: { name: Ut, shader: kt } };
1828
+ var Bt = "fullscreenTriangleVertexShader", Ht = "precision highp float;\n#include<__decl__atmosphereFragment>\n#if POSITION_VEC2\nattribute vec2 position;\n#else\nattribute vec3 position;\n#endif\nuniform float depth;varying vec2 uv;\n#if COMPUTE_WORLD_RAY\nvarying vec3 positionOnNearPlane;\n#endif\n#if COMPUTE_WORLD_RAY\nconst float nearPlaneNDC=-1.;\n#endif\nvoid main() {gl_Position=vec4(position.xy,depth,1.);uv=0.5*position.xy+vec2(0.5);\n#if COMPUTE_WORLD_RAY\npositionOnNearPlane=(inverseViewProjectionWithoutTranslation*vec4(position.xy,nearPlaneNDC,1.)).xyz;\n#endif\n}";
1829
+ t.ShaderStore.ShadersStore[Bt] || (t.ShaderStore.ShadersStore[Bt] = Ht);
1830
+ var Wt = [bt, xt];
1831
+ try {
1832
+ for (var Wt_1 = __values(Wt), Wt_1_1 = Wt_1.next(); !Wt_1_1.done; Wt_1_1 = Wt_1.next()) {
1833
+ var e_89 = Wt_1_1.value;
1834
+ t.ShaderStore.IncludesShadersStore[e_89.name] || (t.ShaderStore.IncludesShadersStore[e_89.name] = e_89.shader);
1835
+ }
1836
+ }
1837
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1838
+ finally {
1839
+ try {
1840
+ if (Wt_1_1 && !Wt_1_1.done && (_c = Wt_1.return)) _c.call(Wt_1);
1841
+ }
1842
+ finally { if (e_3) throw e_3.error; }
1843
+ }
1844
+ var qt = { __proto__: null, fullscreenTriangleVertexShader: { name: Bt, shader: Ht } };
1845
+ var Zt = "diffuseSkyIrradiancePixelShader", Yt = "precision highp float;\n#include<__decl__atmosphereFragment>\nuniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvec3 integrateForIrradiance(vec3 directionToLight,vec3 rayDirection,vec3 rayOrigin) {vec3 transmittance;vec3 radiance=integrateScatteredRadiance(\nfalse,\n1.,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\nrayOrigin,\nrayDirection.xzy,\ndirectionToLight.xzy,\n100000000.,\ndiffuseSkyIrradianceLutSampleCount,\n-1.,\ntransmittance);return radiance;}\n#include<importanceSampling>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\nvarying vec2 uv;void main() {vec2 unit=uvToUnit(uv,DiffuseSkyIrradianceLutDomainInUVSpace,DiffuseSkyIrradianceLutHalfTexelSize);float cosLightInclination=2.*unit.x-1.;float sinLightInclination=sqrtClamped(1.-cosLightInclination*cosLightInclination);vec3 directionToLight=normalize(vec3(0.,cosLightInclination,sinLightInclination));float radius=max(planetRadiusWithOffset,unit.y*atmosphereThickness+planetRadius);vec3 swappedDirectionToLight=vec3(directionToLight.x,directionToLight.z,directionToLight.y); \nvec3 irradiance=PI*irradiance(\nswappedDirectionToLight,\nvec2(radius,0.),\n1.,\nvec3(1.),\nvec3(1.));float averageIrradiance=getLuminanceUnclamped(irradiance);vec3 newIrradiance=mix(irradiance,vec3(averageIrradiance),diffuseSkyIrradianceDesaturationFactor);float newIrradianceScale=getLuminanceUnclamped(newIrradiance);float rescaling=averageIrradiance/max(0.000001,newIrradianceScale);irradiance=newIrradiance*rescaling;gl_FragColor=vec4(irradiance,1.);}";
1846
+ t.ShaderStore.ShadersStore[Zt] || (t.ShaderStore.ShadersStore[Zt] = Yt);
1847
+ var $t = [bt, xt, t.helperFunctions, t.intersectionFunctions, Lt, t.importanceSampling, t.pbrBRDFFunctions, t.hdrFilteringFunctions];
1848
+ try {
1849
+ for (var $t_1 = __values($t), $t_1_1 = $t_1.next(); !$t_1_1.done; $t_1_1 = $t_1.next()) {
1850
+ var e_90 = $t_1_1.value;
1851
+ t.ShaderStore.IncludesShadersStore[e_90.name] || (t.ShaderStore.IncludesShadersStore[e_90.name] = e_90.shader);
1852
+ }
1853
+ }
1854
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1855
+ finally {
1856
+ try {
1857
+ if ($t_1_1 && !$t_1_1.done && (_d = $t_1.return)) _d.call($t_1);
1858
+ }
1859
+ finally { if (e_4) throw e_4.error; }
1860
+ }
1861
+ var jt = { __proto__: null, diffuseSkyIrradiancePixelShader: { name: Zt, shader: Yt } };
1862
+ var Qt = "transmittancePixelShader", Kt = "#define RENDER_TRANSMITTANCE\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#include<atmosphereUboDeclaration>\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=renderTransmittance(input.vUV);}\n";
1863
+ t.ShaderStore.ShadersStoreWGSL[Qt] || (t.ShaderStore.ShadersStoreWGSL[Qt] = Kt);
1864
+ var Xt = [yt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, gt];
1865
+ try {
1866
+ for (var Xt_1 = __values(Xt), Xt_1_1 = Xt_1.next(); !Xt_1_1.done; Xt_1_1 = Xt_1.next()) {
1867
+ var e_91 = Xt_1_1.value;
1868
+ t.ShaderStore.IncludesShadersStoreWGSL[e_91.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_91.name] = e_91.shader);
1869
+ }
1870
+ }
1871
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1872
+ finally {
1873
+ try {
1874
+ if (Xt_1_1 && !Xt_1_1.done && (_f = Xt_1.return)) _f.call(Xt_1);
1875
+ }
1876
+ finally { if (e_5) throw e_5.error; }
1877
+ }
1878
+ var Jt = { __proto__: null, transmittancePixelShaderWGSL: { name: Qt, shader: Kt } };
1879
+ var ei = "transmittancePixelShader", ti = "#define RENDER_TRANSMITTANCE\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\nprecision highp float;\n#include<__decl__atmosphereFragment>\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;void main() {gl_FragColor=renderTransmittance(uv);}";
1880
+ t.ShaderStore.ShadersStore[ei] || (t.ShaderStore.ShadersStore[ei] = ti);
1881
+ var ii = [bt, xt, t.helperFunctions, t.intersectionFunctions, Lt];
1882
+ try {
1883
+ for (var ii_1 = __values(ii), ii_1_1 = ii_1.next(); !ii_1_1.done; ii_1_1 = ii_1.next()) {
1884
+ var e_92 = ii_1_1.value;
1885
+ t.ShaderStore.IncludesShadersStore[e_92.name] || (t.ShaderStore.IncludesShadersStore[e_92.name] = e_92.shader);
1886
+ }
1887
+ }
1888
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1889
+ finally {
1890
+ try {
1891
+ if (ii_1_1 && !ii_1_1.done && (_g = ii_1.return)) _g.call(ii_1);
1892
+ }
1893
+ finally { if (e_6) throw e_6.error; }
1894
+ }
1895
+ var ni = { __proto__: null, transmittancePixelShader: { name: ei, shader: ti } };
1896
+ var ri = "multiScatteringPixelShader", ai = "#define RENDER_MULTI_SCATTERING\n#define COMPUTE_MULTI_SCATTERING\n#include<atmosphereUboDeclaration>\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=renderMultiScattering(input.vUV,transmittanceLut);}\n";
1897
+ t.ShaderStore.ShadersStoreWGSL[ri] || (t.ShaderStore.ShadersStoreWGSL[ri] = ai);
1898
+ var si = [yt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, gt];
1899
+ try {
1900
+ for (var si_1 = __values(si), si_1_1 = si_1.next(); !si_1_1.done; si_1_1 = si_1.next()) {
1901
+ var e_93 = si_1_1.value;
1902
+ t.ShaderStore.IncludesShadersStoreWGSL[e_93.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_93.name] = e_93.shader);
1903
+ }
1904
+ }
1905
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1906
+ finally {
1907
+ try {
1908
+ if (si_1_1 && !si_1_1.done && (_h = si_1.return)) _h.call(si_1);
1909
+ }
1910
+ finally { if (e_7) throw e_7.error; }
1911
+ }
1912
+ var oi = { __proto__: null, multiScatteringPixelShaderWGSL: { name: ri, shader: ai } };
1913
+ var li = "multiScatteringPixelShader", ci = "#define RENDER_MULTI_SCATTERING\n#define COMPUTE_MULTI_SCATTERING\nprecision highp float;\n#include<__decl__atmosphereFragment>\nuniform sampler2D transmittanceLut;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;void main() {gl_FragColor=renderMultiScattering(uv,transmittanceLut);}";
1914
+ t.ShaderStore.ShadersStore[li] || (t.ShaderStore.ShadersStore[li] = ci);
1915
+ var di = [bt, xt, t.helperFunctions, t.intersectionFunctions, Lt];
1916
+ try {
1917
+ for (var di_1 = __values(di), di_1_1 = di_1.next(); !di_1_1.done; di_1_1 = di_1.next()) {
1918
+ var e_94 = di_1_1.value;
1919
+ t.ShaderStore.IncludesShadersStore[e_94.name] || (t.ShaderStore.IncludesShadersStore[e_94.name] = e_94.shader);
1920
+ }
1921
+ }
1922
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
1923
+ finally {
1924
+ try {
1925
+ if (di_1_1 && !di_1_1.done && (_j = di_1.return)) _j.call(di_1);
1926
+ }
1927
+ finally { if (e_8) throw e_8.error; }
1928
+ }
1929
+ var hi = { __proto__: null, multiScatteringPixelShader: { name: li, shader: ci } };
1930
+ var ui = "compositeSkyPixelShader", mi = "#define SAMPLE_SKY_VIEW_LUT\n#if USE_SKY_VIEW_LUT\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#endif\n#include<atmosphereUboDeclaration>\n#if USE_SKY_VIEW_LUT\nvar skyViewLutSampler: sampler;var skyViewLut: texture_2d<f32>;\n#else\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#endif\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;varying positionOnNearPlane: vec3f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);let rayDirection=normalize(input.positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nvar cosAngleBetweenViewAndZenith: f32;var isRayIntersectingGround: bool;var skyColor=sampleSkyViewLut(\nskyViewLut,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\natmosphere.directionToLight,\natmosphere.cosCameraHorizonAngleFromZenith,\n&cosAngleBetweenViewAndZenith,\n&isRayIntersectingGround);\n#ifndef APPLY_TRANSMITTANCE_BLENDING\nskyColor=vec4f(skyColor.rgb,0.);\n#endif\nfragmentOutputs.color=skyColor;fragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,select(fragmentOutputs.color.a,1.,isRayIntersectingGround));\n#else\nvar intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return fragmentOutputs;}\nvar transmittance: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\n100000000.,\natmosphere.skyViewLutSampleCount,\n-1.,\n&transmittance);\n#if APPLY_TRANSMITTANCE_BLENDING\nlet transparency=1.-avg(transmittance);\n#else\nlet transparency=0.;\n#endif\nfragmentOutputs.color=vec4f(radiance,transparency);\n#endif\n#if OUTPUT_TO_SRGB\nfragmentOutputs.color=toGammaSpace(fragmentOutputs.color);\n#endif\n}\n";
1931
+ t.ShaderStore.ShadersStoreWGSL[ui] || (t.ShaderStore.ShadersStoreWGSL[ui] = mi);
1932
+ var pi = [yt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, gt];
1933
+ try {
1934
+ for (var pi_1 = __values(pi), pi_1_1 = pi_1.next(); !pi_1_1.done; pi_1_1 = pi_1.next()) {
1935
+ var e_95 = pi_1_1.value;
1936
+ t.ShaderStore.IncludesShadersStoreWGSL[e_95.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_95.name] = e_95.shader);
1937
+ }
1938
+ }
1939
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
1940
+ finally {
1941
+ try {
1942
+ if (pi_1_1 && !pi_1_1.done && (_k = pi_1.return)) _k.call(pi_1);
1943
+ }
1944
+ finally { if (e_9) throw e_9.error; }
1945
+ }
1946
+ var fi = { __proto__: null, compositeSkyPixelShaderWGSL: { name: ui, shader: mi } };
1947
+ var gi = "compositeSkyPixelShader", vi = "#define SAMPLE_SKY_VIEW_LUT\n#if USE_SKY_VIEW_LUT\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#endif\nprecision highp float;precision highp sampler2D;\n#include<__decl__atmosphereFragment>\n#if USE_SKY_VIEW_LUT\nuniform sampler2D skyViewLut;\n#else\nuniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;\n#endif\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;varying vec3 positionOnNearPlane;void main() {gl_FragColor=vec4(0.);vec3 rayDirection=normalize(positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nfloat cosAngleBetweenViewAndZenith;bool isRayIntersectingGround;vec4 skyColor=sampleSkyViewLut(\nskyViewLut,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\ndirectionToLight,\ncosCameraHorizonAngleFromZenith,\ncosAngleBetweenViewAndZenith,\nisRayIntersectingGround);\n#ifndef APPLY_TRANSMITTANCE_BLENDING\nskyColor.a=0.;\n#endif\ngl_FragColor=skyColor;gl_FragColor.a=isRayIntersectingGround ? 1. : gl_FragColor.a;\n#else\nbool intersectsAtmosphere=false;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=vec3(0.);moveToTopAtmosphere(\nclampedCameraPositionGlobal,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return;}\nvec3 transmittance;vec3 radiance=integrateScatteredRadiance(\nfalse,\natmosphereExposure*lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLight,\n100000000.,\nskyViewLutSampleCount,\n-1.,\ntransmittance);\n#if APPLY_TRANSMITTANCE_BLENDING\nfloat transparency=1.-avg(transmittance);\n#else\nfloat transparency=0.;\n#endif\ngl_FragColor=vec4(radiance,transparency);\n#endif\n#if OUTPUT_TO_SRGB\ngl_FragColor=toGammaSpace(gl_FragColor);\n#endif\n}";
1948
+ t.ShaderStore.ShadersStore[gi] || (t.ShaderStore.ShadersStore[gi] = vi);
1949
+ var Si = [bt, xt, t.helperFunctions, t.intersectionFunctions, Lt];
1950
+ try {
1951
+ for (var Si_1 = __values(Si), Si_1_1 = Si_1.next(); !Si_1_1.done; Si_1_1 = Si_1.next()) {
1952
+ var e_96 = Si_1_1.value;
1953
+ t.ShaderStore.IncludesShadersStore[e_96.name] || (t.ShaderStore.IncludesShadersStore[e_96.name] = e_96.shader);
1954
+ }
1955
+ }
1956
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
1957
+ finally {
1958
+ try {
1959
+ if (Si_1_1 && !Si_1_1.done && (_l = Si_1.return)) _l.call(Si_1);
1960
+ }
1961
+ finally { if (e_10) throw e_10.error; }
1962
+ }
1963
+ var _i = { __proto__: null, compositeSkyPixelShader: { name: gi, shader: vi } };
1964
+ var yi = "aerialPerspectivePixelShader", Ti = "#define RENDER_CAMERA_VOLUME\n#include<atmosphereUboDeclaration>\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying positionOnNearPlane: vec3f;uniform layerIdx: f32;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=renderCameraVolume(\ninput.positionOnNearPlane,\nuniforms.layerIdx,\ntransmittanceLut,\nmultiScatteringLut\n);}\n";
1965
+ t.ShaderStore.ShadersStoreWGSL[yi] || (t.ShaderStore.ShadersStoreWGSL[yi] = Ti);
1966
+ var Ai = [yt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, gt];
1967
+ try {
1968
+ for (var Ai_1 = __values(Ai), Ai_1_1 = Ai_1.next(); !Ai_1_1.done; Ai_1_1 = Ai_1.next()) {
1969
+ var e_97 = Ai_1_1.value;
1970
+ t.ShaderStore.IncludesShadersStoreWGSL[e_97.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_97.name] = e_97.shader);
1971
+ }
1972
+ }
1973
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1974
+ finally {
1975
+ try {
1976
+ if (Ai_1_1 && !Ai_1_1.done && (_m = Ai_1.return)) _m.call(Ai_1);
1977
+ }
1978
+ finally { if (e_11) throw e_11.error; }
1979
+ }
1980
+ var Pi = { __proto__: null, aerialPerspectivePixelShaderWGSL: { name: yi, shader: Ti } };
1981
+ var Li = "aerialPerspectivePixelShader", Ri = "#define RENDER_CAMERA_VOLUME\nprecision highp float;\n#include<__decl__atmosphereFragment>\nuniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vec3 positionOnNearPlane;uniform float layerIdx;void main() {gl_FragColor=renderCameraVolume(\npositionOnNearPlane,\nlayerIdx,\ntransmittanceLut,\nmultiScatteringLut\n);}";
1982
+ t.ShaderStore.ShadersStore[Li] || (t.ShaderStore.ShadersStore[Li] = Ri);
1983
+ var Ei = [bt, xt, t.helperFunctions, t.intersectionFunctions, Lt];
1984
+ try {
1985
+ for (var Ei_1 = __values(Ei), Ei_1_1 = Ei_1.next(); !Ei_1_1.done; Ei_1_1 = Ei_1.next()) {
1986
+ var e_98 = Ei_1_1.value;
1987
+ t.ShaderStore.IncludesShadersStore[e_98.name] || (t.ShaderStore.IncludesShadersStore[e_98.name] = e_98.shader);
1988
+ }
1989
+ }
1990
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
1991
+ finally {
1992
+ try {
1993
+ if (Ei_1_1 && !Ei_1_1.done && (_o = Ei_1.return)) _o.call(Ei_1);
1994
+ }
1995
+ finally { if (e_12) throw e_12.error; }
1996
+ }
1997
+ var Ci = { __proto__: null, aerialPerspectivePixelShader: { name: Li, shader: Ri } };
1998
+ var xi = "depthFunctions", Ii = "fn reconstructDistanceFromCameraPlane(depth: f32,cameraNearPlane: f32)->f32 {return cameraNearPlane/(1.-depth);}\nfn sampleDistanceFromCameraPlane(depthTex: texture_2d<f32>,depthSampler: sampler,uv: vec2f,cameraNearPlane: f32)->f32 {let depth=textureSampleLevel(depthTex,depthSampler,uv,0.).r;return select(reconstructDistanceFromCameraPlane(depth,cameraNearPlane),0.,depth>=1.);}\nfn reconstructDistanceFromCamera(depth: f32,cameraRayDirection: vec3f,cameraForward: vec3f,cameraNearPlane: f32)->f32 {let distanceFromCameraPlane=reconstructDistanceFromCameraPlane(depth,cameraNearPlane);return distanceFromCameraPlane/max(.00001,dot(cameraForward,cameraRayDirection));}\nfn reconstructDistanceFromCameraWithTexture(\ndepthTex: texture_2d<f32>,\ndepthSampler: sampler,\nuv: vec2f,\ncameraRayDirection: vec3f,\ncameraForward: vec3f,\ncameraNearPlane: f32)->f32 {let depth=textureSampleLevel(depthTex,depthSampler,uv,0.).r;return select(reconstructDistanceFromCamera(depth,cameraRayDirection,cameraForward,cameraNearPlane),0.,depth>=1.);}\n";
1999
+ t.ShaderStore.IncludesShadersStoreWGSL[xi] || (t.ShaderStore.IncludesShadersStoreWGSL[xi] = Ii);
2000
+ var wi = { name: xi, shader: Ii }, Mi = "compositeAerialPerspectivePixelShader", bi = "#include<atmosphereUboDeclaration>\n#if USE_AERIAL_PERSPECTIVE_LUT\nvar aerialPerspectiveLutSampler: sampler;var aerialPerspectiveLut: texture_2d_array<f32>;\n#endif\nvar depthTextureSampler: sampler;var depthTexture: texture_2d<f32>;var transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;varying positionOnNearPlane: vec3f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);let depth=textureSampleLevel(depthTexture,depthTextureSampler,input.vUV,0.).r;if (depth>=1.) {discard;}\nlet rayDirection=normalize(input.positionOnNearPlane);let distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\natmosphere.cameraForward,\natmosphere.cameraNearPlane);let distanceToSurface=distanceFromCamera/1000.;var aerialPerspective=vec4f(0.);if (sampleAerialPerspectiveLut(\ninput.vUV,\nfalse,\ndistanceToSurface,\nNumAerialPerspectiveLutLayers,\nAerialPerspectiveLutKMPerSlice,\nAerialPerspectiveLutRangeKM,\n&aerialPerspective)) {\n#ifndef APPLY_TRANSMITTANCE_BLENDING\naerialPerspective=vec4f(aerialPerspective.rgb,0.);\n#endif\nfragmentOutputs.color=aerialPerspective;} else {var intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {fragmentOutputs.color=vec4f(0.);return fragmentOutputs;}\nlet isAerialPerspectiveLut=atmosphere.clampedCameraRadius<atmosphere.atmosphereRadius;var transmittance: vec3f;let radiance=integrateScatteredRadiance(\nisAerialPerspectiveLut,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\n100000000.,\natmosphere.skyViewLutSampleCount,\ndistanceToSurface,\n&transmittance);let transparency=1.-avg(transmittance);fragmentOutputs.color =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(vec4f(radiance,transparency))));\n#ifndef APPLY_TRANSMITTANCE_BLENDING\nfragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,0.);\n#endif\n}\n#if OUTPUT_TO_SRGB\nfragmentOutputs.color=toGammaSpace(fragmentOutputs.color);\n#endif\n}\n";
2001
+ t.ShaderStore.ShadersStoreWGSL[Mi] || (t.ShaderStore.ShadersStoreWGSL[Mi] = bi);
2002
+ var Di = [yt, t.helperFunctionsWGSL, wi, t.intersectionFunctionsWGSL, gt];
2003
+ try {
2004
+ for (var Di_1 = __values(Di), Di_1_1 = Di_1.next(); !Di_1_1.done; Di_1_1 = Di_1.next()) {
2005
+ var e_99 = Di_1_1.value;
2006
+ t.ShaderStore.IncludesShadersStoreWGSL[e_99.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_99.name] = e_99.shader);
2007
+ }
2008
+ }
2009
+ catch (e_13_1) { e_13 = { error: e_13_1 }; }
2010
+ finally {
2011
+ try {
2012
+ if (Di_1_1 && !Di_1_1.done && (_p = Di_1.return)) _p.call(Di_1);
2013
+ }
2014
+ finally { if (e_13) throw e_13.error; }
2015
+ }
2016
+ var Oi = { __proto__: null, compositeAerialPerspectivePixelShaderWGSL: { name: Mi, shader: bi } };
2017
+ var Ni = "depthFunctions", Vi = "float reconstructDistanceFromCameraPlane(float depth,float cameraNearPlane) {return cameraNearPlane/(1.-depth);}\nfloat sampleDistanceFromCameraPlane(sampler2D depthTexture,vec2 uv,float cameraNearPlane) {float depth=textureLod(depthTexture,uv,0.).r;return depth>=1. ? 0. : reconstructDistanceFromCameraPlane(depth,cameraNearPlane);}\nfloat reconstructDistanceFromCamera(float depth,vec3 cameraRayDirection,vec3 cameraForward,float cameraNearPlane) {float distanceFromCameraPlane=reconstructDistanceFromCameraPlane(depth,cameraNearPlane);return distanceFromCameraPlane/max(0.00001,dot(cameraForward,cameraRayDirection));}\nfloat reconstructDistanceFromCamera(\nsampler2D depthTexture,\nvec2 uv,\nvec3 cameraRayDirection,\nvec3 cameraForward,\nfloat cameraNearPlane) {float depth=textureLod(depthTexture,uv,0.).r;return depth>=1. ? 0. : reconstructDistanceFromCamera(depth,cameraRayDirection,cameraForward,cameraNearPlane);}";
2018
+ t.ShaderStore.IncludesShadersStore[Ni] || (t.ShaderStore.IncludesShadersStore[Ni] = Vi);
2019
+ var Fi = { name: Ni, shader: Vi }, Ui = "compositeAerialPerspectivePixelShader", ki = "precision highp float;precision highp sampler2D;precision highp sampler2DArray;\n#include<__decl__atmosphereFragment>\n#if USE_AERIAL_PERSPECTIVE_LUT\nuniform sampler2DArray aerialPerspectiveLut;\n#endif\nuniform sampler2D depthTexture;uniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;varying vec3 positionOnNearPlane;void main() {gl_FragColor=vec4(0.);float depth=textureLod(depthTexture,uv,0.).r;if (depth>=1.) {discard;}\nvec3 rayDirection=normalize(positionOnNearPlane);float distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\ncameraForward,\ncameraNearPlane);float distanceToSurface=distanceFromCamera/1000.;vec4 aerialPerspective=vec4(0.);if (sampleAerialPerspectiveLut(\nuv,\nfalse,\ndistanceToSurface,\nNumAerialPerspectiveLutLayers,\nAerialPerspectiveLutKMPerSlice,\nAerialPerspectiveLutRangeKM,\naerialPerspective)) {\n#ifndef APPLY_TRANSMITTANCE_BLENDING\naerialPerspective.a=0.;\n#endif\ngl_FragColor=aerialPerspective;} else {bool intersectsAtmosphere=false;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=vec3(0.);moveToTopAtmosphere(\nclampedCameraPositionGlobal,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {gl_FragColor=vec4(0.);return;}\nbool isAerialPerspectiveLut=clampedCameraRadius<atmosphereRadius;vec3 transmittance;vec3 radiance=integrateScatteredRadiance(\nisAerialPerspectiveLut,\natmosphereExposure*lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLight,\n100000000.,\nskyViewLutSampleCount,\ndistanceToSurface,\ntransmittance);float transparency=1.-avg(transmittance);gl_FragColor =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(vec4(radiance,transparency))));\n#ifndef APPLY_TRANSMITTANCE_BLENDING\ngl_FragColor.a=0.;\n#endif\n}\n#if OUTPUT_TO_SRGB\ngl_FragColor=toGammaSpace(gl_FragColor);\n#endif\n}";
2020
+ t.ShaderStore.ShadersStore[Ui] || (t.ShaderStore.ShadersStore[Ui] = ki);
2021
+ var Gi = [bt, xt, t.helperFunctions, Fi, t.intersectionFunctions, Lt];
2022
+ try {
2023
+ for (var Gi_1 = __values(Gi), Gi_1_1 = Gi_1.next(); !Gi_1_1.done; Gi_1_1 = Gi_1.next()) {
2024
+ var e_100 = Gi_1_1.value;
2025
+ t.ShaderStore.IncludesShadersStore[e_100.name] || (t.ShaderStore.IncludesShadersStore[e_100.name] = e_100.shader);
2026
+ }
2027
+ }
2028
+ catch (e_14_1) { e_14 = { error: e_14_1 }; }
2029
+ finally {
2030
+ try {
2031
+ if (Gi_1_1 && !Gi_1_1.done && (_q = Gi_1.return)) _q.call(Gi_1);
2032
+ }
2033
+ finally { if (e_14) throw e_14.error; }
2034
+ }
2035
+ var zi = { __proto__: null, compositeAerialPerspectivePixelShader: { name: Ui, shader: ki } };
2036
+ var Bi = "compositeGlobeAtmospherePixelShader", Hi = "#define SAMPLE_SKY_VIEW_LUT\n#if USE_SKY_VIEW_LUT\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#endif\n#include<atmosphereUboDeclaration>\n#if HAS_DEPTH_TEXTURE\nvar depthTextureSampler: sampler;var depthTexture: texture_2d<f32>;\n#endif\n#if USE_SKY_VIEW_LUT\nvar skyViewLutSampler: sampler;var skyViewLut: texture_2d<f32>;\n#else\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#endif\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;varying positionOnNearPlane: vec3f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);\n#if HAS_DEPTH_TEXTURE\nlet depth=textureSampleLevel(depthTexture,depthTextureSampler,input.vUV,0.).r;\n#endif\nlet rayDirection=normalize(input.positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nvar cosAngleBetweenViewAndZenith: f32;var isRayIntersectingGround: bool;var skyColor=sampleSkyViewLut(\nskyViewLut,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\natmosphere.directionToLight,\natmosphere.cosCameraHorizonAngleFromZenith,\n&cosAngleBetweenViewAndZenith,\n&isRayIntersectingGround);fragmentOutputs.color=skyColor;if (isRayIntersectingGround) {fragmentOutputs.color =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(fragmentOutputs.color)));\n#if HAS_DEPTH_TEXTURE\nfragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,select(fragmentOutputs.color.a,1.,depth>=1.));\n#endif\n}\n#else\nvar intersectsAtmosphere=false;var cameraPositionGlobalClampedToTopOfAtmosphere=vec3f(0.);moveToTopAtmosphere(\natmosphere.clampedCameraPositionGlobal,\natmosphere.clampedCameraRadius,\natmosphere.cameraGeocentricNormal,\nrayDirection,\n&intersectsAtmosphere,\n&cameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return fragmentOutputs;}\n#if HAS_DEPTH_TEXTURE\nlet distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\natmosphere.cameraForward,\natmosphere.cameraNearPlane);let distanceToSurface=distanceFromCamera/1000.;\n#else\nlet distanceToSurface=0.;\n#endif\nvar transmittance: vec3f;let radiance=integrateScatteredRadiance(\nfalse,\natmosphere.atmosphereExposure*atmosphere.lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\natmosphere.multiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\natmosphere.directionToLight,\n100000000.,\natmosphere.skyViewLutSampleCount,\ndistanceToSurface,\n&transmittance);let transparency=1.-avg(transmittance);fragmentOutputs.color=vec4f(radiance,transparency);if (distanceToSurface>0.) {fragmentOutputs.color =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(fragmentOutputs.color)));\n#if HAS_DEPTH_TEXTURE\nfragmentOutputs.color=vec4f(fragmentOutputs.color.rgb,select(fragmentOutputs.color.a,1.,depth>=1.));\n#endif\n}\n#endif\n#if OUTPUT_TO_SRGB\nfragmentOutputs.color=toGammaSpace(fragmentOutputs.color);\n#endif\n}\n";
2037
+ t.ShaderStore.ShadersStoreWGSL[Bi] || (t.ShaderStore.ShadersStoreWGSL[Bi] = Hi);
2038
+ var Wi = [yt, t.helperFunctionsWGSL, wi, t.intersectionFunctionsWGSL, gt];
2039
+ try {
2040
+ for (var Wi_1 = __values(Wi), Wi_1_1 = Wi_1.next(); !Wi_1_1.done; Wi_1_1 = Wi_1.next()) {
2041
+ var e_101 = Wi_1_1.value;
2042
+ t.ShaderStore.IncludesShadersStoreWGSL[e_101.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_101.name] = e_101.shader);
2043
+ }
2044
+ }
2045
+ catch (e_15_1) { e_15 = { error: e_15_1 }; }
2046
+ finally {
2047
+ try {
2048
+ if (Wi_1_1 && !Wi_1_1.done && (_r = Wi_1.return)) _r.call(Wi_1);
2049
+ }
2050
+ finally { if (e_15) throw e_15.error; }
2051
+ }
2052
+ var qi = { __proto__: null, compositeGlobeAtmospherePixelShaderWGSL: { name: Bi, shader: Hi } };
2053
+ var Zi = "compositeGlobeAtmospherePixelShader", Yi = "#define SAMPLE_SKY_VIEW_LUT\n#if USE_SKY_VIEW_LUT\n#define EXCLUDE_RAY_MARCHING_FUNCTIONS\n#endif\nprecision highp float;precision highp sampler2D;\n#include<__decl__atmosphereFragment>\n#if HAS_DEPTH_TEXTURE\nuniform sampler2D depthTexture;\n#endif\n#if USE_SKY_VIEW_LUT\nuniform sampler2D skyViewLut;\n#else\nuniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;\n#endif\n#include<helperFunctions>\n#include<depthFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;varying vec3 positionOnNearPlane;void main() {gl_FragColor=vec4(0.);\n#if HAS_DEPTH_TEXTURE\nfloat depth=textureLod(depthTexture,uv,0.).r;\n#endif\nvec3 rayDirection=normalize(positionOnNearPlane);\n#if USE_SKY_VIEW_LUT\nfloat cosAngleBetweenViewAndZenith;bool isRayIntersectingGround;vec4 skyColor=sampleSkyViewLut(\nskyViewLut,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\ndirectionToLight,\ncosCameraHorizonAngleFromZenith,\ncosAngleBetweenViewAndZenith,\nisRayIntersectingGround);gl_FragColor=skyColor;if (isRayIntersectingGround) {gl_FragColor =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(gl_FragColor)));\n#if HAS_DEPTH_TEXTURE\ngl_FragColor.a=depth>=1. ? 1. : gl_FragColor.a;\n#endif\n}\n#else\nbool intersectsAtmosphere=false;vec3 cameraPositionGlobalClampedToTopOfAtmosphere=vec3(0.);moveToTopAtmosphere(\nclampedCameraPositionGlobal,\nclampedCameraRadius,\ncameraGeocentricNormal,\nrayDirection,\nintersectsAtmosphere,\ncameraPositionGlobalClampedToTopOfAtmosphere);if (!intersectsAtmosphere) {return;}\n#if HAS_DEPTH_TEXTURE\nfloat distanceFromCamera =\nreconstructDistanceFromCamera(\ndepth,\nrayDirection,\ncameraForward,\ncameraNearPlane);float distanceToSurface=distanceFromCamera/1000.;\n#else\nfloat distanceToSurface=0.;\n#endif\nvec3 transmittance;vec3 radiance=integrateScatteredRadiance(\nfalse,\natmosphereExposure*lightIntensity,\ntransmittanceLut,\nmultiScatteringLut,\nmultiScatteringIntensity,\ncameraPositionGlobalClampedToTopOfAtmosphere,\nrayDirection,\ndirectionToLight,\n100000000.,\nskyViewLutSampleCount,\ndistanceToSurface,\ntransmittance);float transparency=1.-avg(transmittance);gl_FragColor=vec4(radiance,transparency);if (distanceToSurface>0.) {gl_FragColor =\napplyAerialPerspectiveRadianceBias(\napplyAerialPerspectiveIntensity(\napplyAerialPerspectiveSaturation(gl_FragColor)));\n#if HAS_DEPTH_TEXTURE\ngl_FragColor.a=depth>=1. ? 1. : gl_FragColor.a;\n#endif\n}\n#endif\n#if OUTPUT_TO_SRGB\ngl_FragColor=toGammaSpace(gl_FragColor);\n#endif\n}";
2054
+ t.ShaderStore.ShadersStore[Zi] || (t.ShaderStore.ShadersStore[Zi] = Yi);
2055
+ var $i = [bt, xt, t.helperFunctions, Fi, t.intersectionFunctions, Lt];
2056
+ try {
2057
+ for (var $i_1 = __values($i), $i_1_1 = $i_1.next(); !$i_1_1.done; $i_1_1 = $i_1.next()) {
2058
+ var e_102 = $i_1_1.value;
2059
+ t.ShaderStore.IncludesShadersStore[e_102.name] || (t.ShaderStore.IncludesShadersStore[e_102.name] = e_102.shader);
2060
+ }
2061
+ }
2062
+ catch (e_16_1) { e_16 = { error: e_16_1 }; }
2063
+ finally {
2064
+ try {
2065
+ if ($i_1_1 && !$i_1_1.done && (_s = $i_1.return)) _s.call($i_1);
2066
+ }
2067
+ finally { if (e_16) throw e_16.error; }
2068
+ }
2069
+ var ji = { __proto__: null, compositeGlobeAtmospherePixelShader: { name: Zi, shader: Yi } };
2070
+ var Qi = "skyViewPixelShader", Ki = "#define RENDER_SKY_VIEW\n#include<atmosphereUboDeclaration>\nvar transmittanceLutSampler: sampler;var transmittanceLut: texture_2d<f32>;var multiScatteringLutSampler: sampler;var multiScatteringLut: texture_2d<f32>;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vUV: vec2f;@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=renderSkyView(input.vUV,transmittanceLut,multiScatteringLut);}\n";
2071
+ t.ShaderStore.ShadersStoreWGSL[Qi] || (t.ShaderStore.ShadersStoreWGSL[Qi] = Ki);
2072
+ var Xi = [yt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, gt];
2073
+ try {
2074
+ for (var Xi_1 = __values(Xi), Xi_1_1 = Xi_1.next(); !Xi_1_1.done; Xi_1_1 = Xi_1.next()) {
2075
+ var e_103 = Xi_1_1.value;
2076
+ t.ShaderStore.IncludesShadersStoreWGSL[e_103.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_103.name] = e_103.shader);
2077
+ }
2078
+ }
2079
+ catch (e_17_1) { e_17 = { error: e_17_1 }; }
2080
+ finally {
2081
+ try {
2082
+ if (Xi_1_1 && !Xi_1_1.done && (_u = Xi_1.return)) _u.call(Xi_1);
2083
+ }
2084
+ finally { if (e_17) throw e_17.error; }
2085
+ }
2086
+ var Ji = { __proto__: null, skyViewPixelShaderWGSL: { name: Qi, shader: Ki } };
2087
+ var en = "skyViewPixelShader", tn = "#define RENDER_SKY_VIEW\nprecision highp float;precision highp sampler2D;\n#include<__decl__atmosphereFragment>\nuniform sampler2D transmittanceLut;uniform sampler2D multiScatteringLut;\n#include<helperFunctions>\n#include<atmosphereFunctions>\nvarying vec2 uv;void main() {gl_FragColor=renderSkyView(uv,transmittanceLut,multiScatteringLut);}";
2088
+ t.ShaderStore.ShadersStore[en] || (t.ShaderStore.ShadersStore[en] = tn);
2089
+ var nn = [bt, xt, t.helperFunctions, t.intersectionFunctions, Lt];
2090
+ try {
2091
+ for (var nn_1 = __values(nn), nn_1_1 = nn_1.next(); !nn_1_1.done; nn_1_1 = nn_1.next()) {
2092
+ var e_104 = nn_1_1.value;
2093
+ t.ShaderStore.IncludesShadersStore[e_104.name] || (t.ShaderStore.IncludesShadersStore[e_104.name] = e_104.shader);
2094
+ }
2095
+ }
2096
+ catch (e_18_1) { e_18 = { error: e_18_1 }; }
2097
+ finally {
2098
+ try {
2099
+ if (nn_1_1 && !nn_1_1.done && (_v = nn_1.return)) _v.call(nn_1);
2100
+ }
2101
+ finally { if (e_18) throw e_18.error; }
2102
+ }
2103
+ var rn = { __proto__: null, skyViewPixelShader: { name: en, shader: tn } };
2104
+ e.Atmosphere = /** @class */ (function () {
2105
+ function Atmosphere(e, i, n, r) {
2106
+ var _this = this;
2107
+ var a, s, o, l, c, d, h, u, m, f, v, S, _, y, T, P, L, R, E, C, x, I;
2108
+ this.name = e, this.scene = i, this._directionToLight = t.Vector3.Zero(), this._tempSceneAmbient = new t.Color3, this._additionalDiffuseSkyIrradiance = new t.Color3, this._atmosphereUbo = null, this._minimumMultiScattering = new t.Vector3, this._cameraAtmosphereVariables = new g, this._lightRadianceAtCamera = new t.Vector3, this._linearLightColor = new t.Color3, this._atmosphereUniformBufferAsArray = [], this._effectRenderer = null, this._isEnabled = !0, this._aerialPerspectiveLutHasBeenRendered = !1, this._hasRenderedMultiScatteringLut = !1, this._hasEverRenderedMultiScatteringLut = !1, this._multiScatteringEffectWrapper = null, this._multiScatteringLutRenderTarget = null, this._aerialPerspectiveLutEffectWrapper = null, this._aerialPerspectiveLutEffectRenderer = null, this._aerialPerspectiveLutRenderTarget = null, this._skyViewLutEffectWrapper = null, this._skyViewLutEffectRenderer = null, this._skyViewLutRenderTarget = null, this._aerialPerspectiveCompositorEffectWrapper = null, this._skyCompositorEffectWrapper = null, this._globeAtmosphereCompositorEffectWrapper = null, this._onBeforeCameraRenderObserver = null, this._onBeforeRenderObserver = null, this._onBeforeDrawPhaseObserver = null, this._onAfterRenderingGroupObserver = null, this.uniqueId = B++, this.onAfterUpdateVariablesForCameraObservable = new t.Observable, this.onBeforeLightVariablesUpdateObservable = new t.Observable, this.onBeforeRenderLutsForCameraObservable = new t.Observable, this.onAfterRenderLutsForCameraObservable = new t.Observable, this.depthTexture = null, this.getTransmittedColorToRef = function (e, t, i, n) { return _this._transmittanceLut.getTransmittedColorToRef(e, t, i, n); }, this.getDiffuseSkyIrradianceToRef = function (e, t, i, n, r) { var a, s; return null !== (s = null === (a = _this._diffuseSkyIrradianceLut) || void 0 === a ? void 0 : a.getDiffuseSkyIrradianceToRef(e, t, i, n, r)) && void 0 !== s ? s : (r.r = 0, r.g = 0, r.b = 0, r); }, t.RegisterEngineUniformBuffer(), t.RegisterEnginesExtensionsEngineRenderTarget();
2109
+ var w = this._engine = i.getEngine();
2110
+ if (!w.isWebGPU && w.version < 2)
2111
+ throw new Error("Atmosphere is not supported on WebGL ".concat(w.version, "."));
2112
+ if (this._physicalProperties = null !== (a = null == r ? void 0 : r.physicalProperties) && void 0 !== a ? a : new A, this._physicalProperties.onChangedObservable.add(function () { var e; null === (e = _this._transmittanceLut) || void 0 === e || e.markDirty(); }), 1 !== n.length)
2113
+ throw new Error("Atmosphere only supports one light source currently.");
2114
+ this._lights = n, this.depthTexture = null !== (s = null == r ? void 0 : r.depthTexture) && void 0 !== s ? s : null, this._exposure = null !== (o = null == r ? void 0 : r.exposure) && void 0 !== o ? o : 1, this._isLinearSpaceLight = null !== (l = null == r ? void 0 : r.isLinearSpaceLight) && void 0 !== l && l, this._isLinearSpaceComposition = null !== (c = null == r ? void 0 : r.isLinearSpaceComposition) && void 0 !== c && c, this._applyApproximateTransmittance = null === (d = null == r ? void 0 : r.applyApproximateTransmittance) || void 0 === d || d, this._aerialPerspectiveRadianceBias = null !== (h = null == r ? void 0 : r.aerialPerspectiveRadianceBias) && void 0 !== h ? h : 0, this._aerialPerspectiveTransmittanceScale = null !== (u = null == r ? void 0 : r.aerialPerspectiveTransmittanceScale) && void 0 !== u ? u : 1, this._aerialPerspectiveSaturation = null !== (m = null == r ? void 0 : r.aerialPerspectiveSaturation) && void 0 !== m ? m : 1, this._aerialPerspectiveIntensity = null !== (f = null == r ? void 0 : r.aerialPerspectiveIntensity) && void 0 !== f ? f : 1, this._diffuseSkyIrradianceDesaturationFactor = null !== (v = null == r ? void 0 : r.diffuseSkyIrradianceDesaturationFactor) && void 0 !== v ? v : .5, this._diffuseSkyIrradianceIntensity = null !== (S = null == r ? void 0 : r.diffuseSkyIrradianceIntensity) && void 0 !== S ? S : 1, this._additionalDiffuseSkyIrradianceIntensity = null !== (_ = null == r ? void 0 : r.additionalDiffuseSkyIrradianceIntensity) && void 0 !== _ ? _ : .01, this._multiScatteringIntensity = null !== (y = null == r ? void 0 : r.multiScatteringIntensity) && void 0 !== y ? y : 1, this._minimumMultiScatteringIntensity = null !== (T = null == r ? void 0 : r.minimumMultiScatteringIntensity) && void 0 !== T ? T : 618e-6, this._isSkyViewLutEnabled = null === (P = null == r ? void 0 : r.isSkyViewLutEnabled) || void 0 === P || P, this._isAerialPerspectiveLutEnabled = null === (L = null == r ? void 0 : r.isAerialPerspectiveLutEnabled) || void 0 === L || L, this._originHeight = null !== (R = null == r ? void 0 : r.originHeight) && void 0 !== R ? R : 0, this._additionalDiffuseSkyIrradianceColor = (null == r ? void 0 : r.additionalDiffuseSkyIrradianceColor) ? (new t.Color3).copyFrom(r.additionalDiffuseSkyIrradianceColor) : new t.Color3(163 / 255, 199 / 255, 1), this._groundAlbedo = (null == r ? void 0 : r.groundAlbedo) ? (new t.Color3).copyFrom(r.groundAlbedo) : (new t.Color3).set(124 / 255, 165 / 255, 1);
2115
+ var M = this._minimumMultiScatteringColor = (null == r ? void 0 : r.minimumMultiScatteringColor) ? (new t.Color3).copyFrom(r.minimumMultiScatteringColor) : new t.Color3(30 / 255, 40 / 255, 77 / 255);
2116
+ this._skyRenderingGroup = null !== (E = null == r ? void 0 : r.skyRenderingGroup) && void 0 !== E ? E : 0, this._aerialPerspectiveRenderingGroup = null !== (C = null == r ? void 0 : r.aerialPerspectiveRenderingGroup) && void 0 !== C ? C : 0, this._globeAtmosphereRenderingGroup = null !== (x = null == r ? void 0 : r.globeAtmosphereRenderingGroup) && void 0 !== x ? x : 0, this._additionalDiffuseSkyIrradianceColor.scaleToRef(this._additionalDiffuseSkyIrradianceIntensity, this._additionalDiffuseSkyIrradiance), this._minimumMultiScattering.x = M.r * this._minimumMultiScatteringIntensity, this._minimumMultiScattering.y = M.g * this._minimumMultiScatteringIntensity, this._minimumMultiScattering.z = M.b * this._minimumMultiScatteringIntensity;
2117
+ {
2118
+ var e_105 = n[0];
2119
+ this._directionToLight.copyFrom(e_105.direction).scaleInPlace(-1);
2120
+ var t_21 = this._linearLightColor.copyFrom(e_105.diffuse);
2121
+ this._isLinearSpaceLight || t_21.toLinearSpaceToRef(t_21);
2122
+ var i_16 = e_105.intensity;
2123
+ this._lightRadianceAtCamera.set(i_16 * t_21.r, i_16 * t_21.g, i_16 * t_21.b);
2124
+ }
2125
+ this._effectRenderer = new t.EffectRenderer(w, { indices: [0, 2, 1], positions: [-1, -1, -1, 3, 3, -1] }), this._transmittanceLut = new G(this), this._multiScatteringLutRenderTarget = q("atmo-multiScattering", { width: 32, height: 32 }, i), this._multiScatteringEffectWrapper = W(w, this.uniformBuffer, this._groundAlbedo), this._isDiffuseSkyIrradianceLutEnabled = null === (I = null == r ? void 0 : r.isDiffuseSkyIrradianceLutEnabled) || void 0 === I || I, this._isDiffuseSkyIrradianceLutEnabled && (this._diffuseSkyIrradianceLut = new D(this)), this._isSkyViewLutEnabled && this.skyViewLutRenderTarget, this._isAerialPerspectiveLutEnabled && this.aerialPerspectiveLutRenderTarget, this._onBeforeRenderObserver = i.onBeforeRenderObservable.add(function () { _this.renderGlobalLuts(); }), this._onBeforeCameraRenderObserver = i.onBeforeCameraRenderObservable.add(function (e) { _this._updatePerCameraVariables(e), _this._renderLutsForCamera(e); });
2126
+ {
2127
+ var e_106 = i.renderingManager;
2128
+ this._skyRenderingGroup >= 0 && e_106.getRenderingGroup(this._skyRenderingGroup), this._aerialPerspectiveRenderingGroup >= 0 && e_106.getRenderingGroup(this._aerialPerspectiveRenderingGroup), this._globeAtmosphereRenderingGroup >= 0 && e_106.getRenderingGroup(this._globeAtmosphereRenderingGroup), this._onBeforeDrawPhaseObserver = i.onBeforeDrawPhaseObservable.add(function () { _this._skyRenderingGroup >= 0 && (e_106.getRenderingGroup(_this._skyRenderingGroup)._empty = !1), _this._aerialPerspectiveRenderingGroup >= 0 && (e_106.getRenderingGroup(_this._aerialPerspectiveRenderingGroup)._empty = !1), _this._globeAtmosphereRenderingGroup >= 0 && (e_106.getRenderingGroup(_this._globeAtmosphereRenderingGroup)._empty = !1); }), this._onAfterRenderingGroupObserver = i.onAfterRenderingGroupObservable.add(function (e) { if (e.renderingManager !== i.renderingManager)
2129
+ return; var t = e.renderingGroupId; _this._skyRenderingGroup === t && _this.drawSkyCompositor(), _this._aerialPerspectiveRenderingGroup === t && _this.drawAerialPerspectiveCompositor(), _this._globeAtmosphereRenderingGroup === t && _this.drawGlobeAtmosphereCompositor(); });
2130
+ }
2131
+ i.onDisposeObservable.addOnce(function () { i.removeExternalData("atmosphere"), _this.dispose(); }), i.addExternalData("atmosphere", this), t.UnregisterMaterialPlugin(z), t.RegisterMaterialPlugin(z, function (e) { return "PBRMaterial" === e.getClassName() ? new p(e, _this, null === _this.depthTexture) : null; }), this._eagerlyPreloadMaterialPluginShaderIncludesAsync(), i.addIsReadyCheck(this);
2132
+ }
2133
+ Atmosphere.IsSupported = function (e) { return !e._badOS && (e.isWebGPU || e.version >= 2); };
2134
+ Object.defineProperty(Atmosphere.prototype, "exposure", {
2135
+ get: function () { return this._exposure; },
2136
+ set: function (e) { this._exposure = Math.max(0, e); },
2137
+ enumerable: false,
2138
+ configurable: true
2139
+ });
2140
+ Object.defineProperty(Atmosphere.prototype, "multiScatteringIntensity", {
2141
+ get: function () { return this._multiScatteringIntensity; },
2142
+ set: function (e) { var t; Math.max(0, e) !== this._multiScatteringIntensity && (this._multiScatteringIntensity = e, null === (t = this._diffuseSkyIrradianceLut) || void 0 === t || t.markDirty()); },
2143
+ enumerable: false,
2144
+ configurable: true
2145
+ });
2146
+ Object.defineProperty(Atmosphere.prototype, "groundAlbedo", {
2147
+ get: function () { return this._groundAlbedo; },
2148
+ set: function (e) { var t; this._groundAlbedo.equals(e) || (this._groundAlbedo.copyFrom(e), null === (t = this._multiScatteringEffectWrapper) || void 0 === t || t.dispose(), this._multiScatteringEffectWrapper = null, this._hasRenderedMultiScatteringLut = !1); },
2149
+ enumerable: false,
2150
+ configurable: true
2151
+ });
2152
+ Object.defineProperty(Atmosphere.prototype, "minimumMultiScatteringColor", {
2153
+ get: function () { return this._minimumMultiScatteringColor; },
2154
+ set: function (e) { var t; if (!this._minimumMultiScatteringColor.equals(e)) {
2155
+ var i_17 = this._minimumMultiScatteringColor.copyFrom(e);
2156
+ this._minimumMultiScattering.x = i_17.r * this._minimumMultiScatteringIntensity, this._minimumMultiScattering.y = i_17.g * this._minimumMultiScatteringIntensity, this._minimumMultiScattering.z = i_17.b * this._minimumMultiScatteringIntensity, null === (t = this._diffuseSkyIrradianceLut) || void 0 === t || t.markDirty();
2157
+ } },
2158
+ enumerable: false,
2159
+ configurable: true
2160
+ });
2161
+ Object.defineProperty(Atmosphere.prototype, "minimumMultiScatteringIntensity", {
2162
+ get: function () { return this._minimumMultiScatteringIntensity; },
2163
+ set: function (e) { var t; Math.max(0, e) !== this._minimumMultiScatteringIntensity && (this._minimumMultiScatteringIntensity = e, this._minimumMultiScattering.x = this._minimumMultiScatteringColor.r * e, this._minimumMultiScattering.y = this._minimumMultiScatteringColor.g * e, this._minimumMultiScattering.z = this._minimumMultiScatteringColor.b * e, null === (t = this._diffuseSkyIrradianceLut) || void 0 === t || t.markDirty()); },
2164
+ enumerable: false,
2165
+ configurable: true
2166
+ });
2167
+ Object.defineProperty(Atmosphere.prototype, "diffuseSkyIrradianceDesaturationFactor", {
2168
+ get: function () { return this._diffuseSkyIrradianceDesaturationFactor; },
2169
+ set: function (e) { var t; var i = Math.max(e, 0); i !== this._diffuseSkyIrradianceDesaturationFactor && (this._diffuseSkyIrradianceDesaturationFactor = i, null === (t = this._diffuseSkyIrradianceLut) || void 0 === t || t.markDirty()); },
2170
+ enumerable: false,
2171
+ configurable: true
2172
+ });
2173
+ Object.defineProperty(Atmosphere.prototype, "additionalDiffuseSkyIrradianceIntensity", {
2174
+ get: function () { return this._additionalDiffuseSkyIrradianceIntensity; },
2175
+ set: function (e) { (e = Math.max(0, e)) !== this._additionalDiffuseSkyIrradianceIntensity && (this._additionalDiffuseSkyIrradianceIntensity = e, this._additionalDiffuseSkyIrradianceColor.scaleToRef(e, this._additionalDiffuseSkyIrradiance)); },
2176
+ enumerable: false,
2177
+ configurable: true
2178
+ });
2179
+ Object.defineProperty(Atmosphere.prototype, "additionalDiffuseSkyIrradianceColor", {
2180
+ get: function () { return this._additionalDiffuseSkyIrradianceColor; },
2181
+ set: function (e) { this._additionalDiffuseSkyIrradianceColor.equals(e) || this._additionalDiffuseSkyIrradianceColor.copyFrom(e).scaleToRef(this._additionalDiffuseSkyIrradianceIntensity, this._additionalDiffuseSkyIrradiance); },
2182
+ enumerable: false,
2183
+ configurable: true
2184
+ });
2185
+ Object.defineProperty(Atmosphere.prototype, "additionalDiffuseSkyIrradiance", {
2186
+ get: function () { return this._additionalDiffuseSkyIrradiance; },
2187
+ enumerable: false,
2188
+ configurable: true
2189
+ });
2190
+ Object.defineProperty(Atmosphere.prototype, "diffuseSkyIrradianceIntensity", {
2191
+ get: function () { return this._diffuseSkyIrradianceIntensity; },
2192
+ set: function (e) { this._diffuseSkyIrradianceIntensity = Math.max(e, 0); },
2193
+ enumerable: false,
2194
+ configurable: true
2195
+ });
2196
+ Object.defineProperty(Atmosphere.prototype, "isSkyViewLutEnabled", {
2197
+ get: function () { return this._isSkyViewLutEnabled; },
2198
+ set: function (e) { this._isSkyViewLutEnabled = e, this._disposeSkyCompositor(), this._disposeGlobeAtmosphereCompositor(); },
2199
+ enumerable: false,
2200
+ configurable: true
2201
+ });
2202
+ Object.defineProperty(Atmosphere.prototype, "skyViewLutRenderTarget", {
2203
+ get: function () { if (!this._isSkyViewLutEnabled)
2204
+ return null; if (null !== this._skyViewLutRenderTarget)
2205
+ return this._skyViewLutRenderTarget; var e = this._skyViewLutRenderTarget = q("atmo-skyView", { width: 128, height: 128 }, this.scene); return e.coordinatesMode = t.Constants.TEXTURE_EQUIRECTANGULAR_MODE, this._skyViewLutEffectWrapper = (function (e, i) { var n = e.isWebGPU && !t.EffectWrapper.ForceGLSL, r = n ? "atmosphere" : i.name; return H(e, "atmo-skyView", "skyView", __spreadArray(["depth"], __read(i.useUbo ? [] : i.getUniformNames()), false), ["transmittanceLut", "multiScatteringLut"], i.useUbo ? [r] : [], ["POSITION_VEC2"], n, function (e, t) { t.push.apply(t, __spreadArray([], __read(n ? [Promise.resolve().then(function () { return Ft; }), Promise.resolve().then(function () { return Ji; })] : [Promise.resolve().then(function () { return qt; }), Promise.resolve().then(function () { return rn; })]), false)); }); })(this._engine, this.uniformBuffer), e; },
2206
+ enumerable: false,
2207
+ configurable: true
2208
+ });
2209
+ Object.defineProperty(Atmosphere.prototype, "isAerialPerspectiveLutEnabled", {
2210
+ get: function () { return this._isAerialPerspectiveLutEnabled; },
2211
+ set: function (e) { this._isAerialPerspectiveLutEnabled = e, this._disposeAerialPerspectiveCompositor(); },
2212
+ enumerable: false,
2213
+ configurable: true
2214
+ });
2215
+ Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveLutRenderTarget", {
2216
+ get: function () { if (!this._isAerialPerspectiveLutEnabled)
2217
+ return null; if (null !== this._aerialPerspectiveLutRenderTarget)
2218
+ return this._aerialPerspectiveLutRenderTarget; var e = this.scene, i = this._aerialPerspectiveLutRenderTarget = q("atmo-aerialPerspective", { width: 16, height: 64, layers: 32 }, e, {}); return this._aerialPerspectiveLutEffectWrapper = (function (e, i) { var n = e.isWebGPU && !t.EffectWrapper.ForceGLSL, r = n ? "atmosphere" : i.name; return H(e, "atmo-aerialPerspective", "aerialPerspective", __spreadArray(["layerIdx"], __read(i.useUbo ? [] : i.getUniformNames()), false), ["transmittanceLut", "multiScatteringLut"], i.useUbo ? [r] : [], ["POSITION_VEC2", "COMPUTE_WORLD_RAY"], n, function (e, t) { t.push.apply(t, __spreadArray([], __read(n ? [Promise.resolve().then(function () { return Ft; }), Promise.resolve().then(function () { return Pi; })] : [Promise.resolve().then(function () { return qt; }), Promise.resolve().then(function () { return Ci; })]), false)); }); })(this._engine, this.uniformBuffer), i; },
2219
+ enumerable: false,
2220
+ configurable: true
2221
+ });
2222
+ Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveIntensity", {
2223
+ get: function () { return this._aerialPerspectiveIntensity; },
2224
+ set: function (e) { if ((e = Math.max(.001, e)) !== this._aerialPerspectiveIntensity) {
2225
+ var t_22 = 1 === e != (1 === this._aerialPerspectiveIntensity);
2226
+ this._aerialPerspectiveIntensity = e, t_22 && (this._disposeAerialPerspectiveCompositor(), this._disposeGlobeAtmosphereCompositor());
2227
+ } },
2228
+ enumerable: false,
2229
+ configurable: true
2230
+ });
2231
+ Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveTransmittanceScale", {
2232
+ get: function () { return this._aerialPerspectiveTransmittanceScale; },
2233
+ set: function (e) { (e = Math.max(0, e)) !== this._aerialPerspectiveTransmittanceScale && (this._aerialPerspectiveTransmittanceScale = e); },
2234
+ enumerable: false,
2235
+ configurable: true
2236
+ });
2237
+ Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveSaturation", {
2238
+ get: function () { return this._aerialPerspectiveSaturation; },
2239
+ set: function (e) { (e = Math.max(0, e)) !== this._aerialPerspectiveSaturation && (this._aerialPerspectiveSaturation = e); },
2240
+ enumerable: false,
2241
+ configurable: true
2242
+ });
2243
+ Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveRadianceBias", {
2244
+ get: function () { return this._aerialPerspectiveRadianceBias; },
2245
+ set: function (e) { if (e !== this._aerialPerspectiveRadianceBias) {
2246
+ var t_23 = 0 === e != (0 === this._aerialPerspectiveRadianceBias);
2247
+ this._aerialPerspectiveRadianceBias = e, t_23 && (this._disposeAerialPerspectiveCompositor(), this._disposeGlobeAtmosphereCompositor());
2248
+ } },
2249
+ enumerable: false,
2250
+ configurable: true
2251
+ });
2252
+ Object.defineProperty(Atmosphere.prototype, "isLinearSpaceComposition", {
2253
+ get: function () { return this._isLinearSpaceComposition; },
2254
+ set: function (e) { e !== this._isLinearSpaceComposition && (this._isLinearSpaceComposition = e, this._disposeSkyCompositor(), this._disposeAerialPerspectiveCompositor(), this._disposeGlobeAtmosphereCompositor()); },
2255
+ enumerable: false,
2256
+ configurable: true
2257
+ });
2258
+ Object.defineProperty(Atmosphere.prototype, "isLinearSpaceLight", {
2259
+ get: function () { return this._isLinearSpaceLight; },
2260
+ set: function (e) { this._isLinearSpaceLight = e; },
2261
+ enumerable: false,
2262
+ configurable: true
2263
+ });
2264
+ Object.defineProperty(Atmosphere.prototype, "transmittanceLut", {
2265
+ get: function () { return this._transmittanceLut; },
2266
+ enumerable: false,
2267
+ configurable: true
2268
+ });
2269
+ Object.defineProperty(Atmosphere.prototype, "multiScatteringLutRenderTarget", {
2270
+ get: function () { return this._multiScatteringLutRenderTarget; },
2271
+ enumerable: false,
2272
+ configurable: true
2273
+ });
2274
+ Object.defineProperty(Atmosphere.prototype, "diffuseSkyIrradianceLut", {
2275
+ get: function () { return this._diffuseSkyIrradianceLut; },
2276
+ enumerable: false,
2277
+ configurable: true
2278
+ });
2279
+ Object.defineProperty(Atmosphere.prototype, "physicalProperties", {
2280
+ get: function () { return this._physicalProperties; },
2281
+ enumerable: false,
2282
+ configurable: true
2283
+ });
2284
+ Object.defineProperty(Atmosphere.prototype, "originHeight", {
2285
+ get: function () { return this._originHeight; },
2286
+ set: function (e) { this._originHeight = e; },
2287
+ enumerable: false,
2288
+ configurable: true
2289
+ });
2290
+ Object.defineProperty(Atmosphere.prototype, "applyApproximateTransmittance", {
2291
+ get: function () { return this._applyApproximateTransmittance; },
2292
+ set: function (e) { this._applyApproximateTransmittance !== e && (this._applyApproximateTransmittance = e, this._disposeSkyCompositor(), this._disposeAerialPerspectiveCompositor(), this._disposeGlobeAtmosphereCompositor()); },
2293
+ enumerable: false,
2294
+ configurable: true
2295
+ });
2296
+ Object.defineProperty(Atmosphere.prototype, "lights", {
2297
+ get: function () { return this._lights; },
2298
+ enumerable: false,
2299
+ configurable: true
2300
+ });
2301
+ Object.defineProperty(Atmosphere.prototype, "skyRenderingGroup", {
2302
+ get: function () { return this._skyRenderingGroup; },
2303
+ set: function (e) { this._skyRenderingGroup = e, this.scene.renderingManager.getRenderingGroup(e); },
2304
+ enumerable: false,
2305
+ configurable: true
2306
+ });
2307
+ Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveRenderingGroup", {
2308
+ get: function () { return this._aerialPerspectiveRenderingGroup; },
2309
+ set: function (e) { this._aerialPerspectiveRenderingGroup = e, this.scene.renderingManager.getRenderingGroup(e); },
2310
+ enumerable: false,
2311
+ configurable: true
2312
+ });
2313
+ Object.defineProperty(Atmosphere.prototype, "globeAtmosphereRenderingGroup", {
2314
+ get: function () { return this._globeAtmosphereRenderingGroup; },
2315
+ set: function (e) { this._globeAtmosphereRenderingGroup = e, this.scene.renderingManager.getRenderingGroup(e); },
2316
+ enumerable: false,
2317
+ configurable: true
2318
+ });
2319
+ Object.defineProperty(Atmosphere.prototype, "uniformBuffer", {
2320
+ get: function () { if (null === this._atmosphereUbo) {
2321
+ var e_107 = this._atmosphereUbo = new t.UniformBuffer(this._engine, void 0, !0, "Atmosphere");
2322
+ e_107.addUniform("peakRayleighScattering", 3), e_107.addUniform("planetRadius", 1), e_107.addUniform("peakMieScattering", 3), e_107.addUniform("atmosphereThickness", 1), e_107.addUniform("peakMieAbsorption", 3), e_107.addUniform("planetRadiusSquared", 1), e_107.addUniform("peakMieExtinction", 3), e_107.addUniform("atmosphereRadius", 1), e_107.addUniform("peakOzoneAbsorption", 3), e_107.addUniform("atmosphereRadiusSquared", 1), e_107.addUniform("horizonDistanceToAtmosphereEdge", 1), e_107.addUniform("horizonDistanceToAtmosphereEdgeSquared", 1), e_107.addUniform("planetRadiusWithOffset", 1), e_107.addUniform("planetRadiusOffset", 1), e_107.addUniform("atmosphereExposure", 1), e_107.addUniform("aerialPerspectiveRadianceBias", 1), e_107.addUniform("inverseAtmosphereThickness", 1), e_107.addUniform("aerialPerspectiveTransmittanceScale", 1), e_107.addUniform("inverseViewProjectionWithoutTranslation", 16), e_107.addUniform("directionToLight", 3), e_107.addUniform("multiScatteringIntensity", 1), e_107.addUniform("directionToLightRelativeToCameraGeocentricNormal", 3), e_107.addUniform("cameraRadius", 1), e_107.addUniform("lightRadianceAtCamera", 3), e_107.addUniform("diffuseSkyIrradianceDesaturationFactor", 1), e_107.addUniform("groundAlbedo", 3), e_107.addUniform("aerialPerspectiveSaturation", 1), e_107.addUniform("minMultiScattering", 3), e_107.addUniform("diffuseSkyIrradianceIntensity", 1), e_107.addUniform("cameraPositionGlobal", 3), e_107.addUniform("lightIntensity", 1), e_107.addUniform("clampedCameraPositionGlobal", 3), e_107.addUniform("aerialPerspectiveIntensity", 1), e_107.addUniform("cameraGeocentricNormal", 3), e_107.addUniform("clampedCameraRadius", 1), e_107.addUniform("cameraForward", 3), e_107.addUniform("clampedCameraHeight", 1), e_107.addUniform("cameraPosition", 3), e_107.addUniform("cosCameraHorizonAngleFromZenith", 1), e_107.addUniform("viewport", 4), e_107.addUniform("additionalDiffuseSkyIrradiance", 3), e_107.addUniform("cameraHeight", 1), e_107.addUniform("cameraNearPlane", 1), e_107.addUniform("originHeight", 1), e_107.addUniform("sinCameraAtmosphereHorizonAngleFromNadir", 1), e_107.addUniform("transmittanceSampleCount", 1), e_107.addUniform("skyViewLutSampleCount", 1), e_107.addUniform("multiScatteringLutSampleCount", 1), e_107.addUniform("multiScatteringAzimuthSampleCount", 1), e_107.addUniform("multiScatteringInclinationSampleCount", 1), e_107.addUniform("diffuseSkyIrradianceLutSampleCount", 1), e_107.create();
2323
+ } return this._atmosphereUbo; },
2324
+ enumerable: false,
2325
+ configurable: true
2326
+ });
2327
+ Object.defineProperty(Atmosphere.prototype, "cameraAtmosphereVariables", {
2328
+ get: function () { return this._cameraAtmosphereVariables; },
2329
+ enumerable: false,
2330
+ configurable: true
2331
+ });
2332
+ Atmosphere.prototype._eagerlyPreloadMaterialPluginShaderIncludesAsync = function () { return i(this, void 0, void 0, function () { var e_108; return __generator(this, function (_a) {
2333
+ switch (_a.label) {
2334
+ case 0:
2335
+ _a.trys.push([0, 2, , 3]);
2336
+ return [4 /*yield*/, this.preloadMaterialPluginShaderIncludesAsync()];
2337
+ case 1:
2338
+ _a.sent();
2339
+ return [3 /*break*/, 3];
2340
+ case 2:
2341
+ e_108 = _a.sent();
2342
+ return [3 /*break*/, 3];
2343
+ case 3: return [2 /*return*/];
2344
+ }
2345
+ }); }); };
2346
+ Atmosphere.prototype.preloadMaterialPluginShaderIncludesAsync = function () { return i(this, void 0, void 0, function () { var e; return __generator(this, function (_a) {
2347
+ switch (_a.label) {
2348
+ case 0:
2349
+ e = this.scene.getEngine().isWebGPU && !t.EffectWrapper.ForceGLSL ? 1 : 0;
2350
+ return [4 /*yield*/, p.PreloadShaderIncludesAsync(e)];
2351
+ case 1:
2352
+ _a.sent();
2353
+ return [2 /*return*/];
2354
+ }
2355
+ }); }); };
2356
+ Atmosphere.prototype.dispose = function () { var e, i, n, r, a, s, o, l, c, d, h, u, m, p, f, g, v, S, _; this.scene.removeIsReadyCheck(this), null === (e = this._onBeforeCameraRenderObserver) || void 0 === e || e.remove(), this._onBeforeCameraRenderObserver = null, null === (i = this._onBeforeDrawPhaseObserver) || void 0 === i || i.remove(), this._onBeforeDrawPhaseObserver = null, null === (n = this._onAfterRenderingGroupObserver) || void 0 === n || n.remove(), this._onAfterRenderingGroupObserver = null, null === (r = this._onBeforeRenderObserver) || void 0 === r || r.remove(), this._onBeforeRenderObserver = null, null === (a = this._globeAtmosphereCompositorEffectWrapper) || void 0 === a || a.dispose(), this._globeAtmosphereCompositorEffectWrapper = null, null === (s = this._skyCompositorEffectWrapper) || void 0 === s || s.dispose(), this._skyCompositorEffectWrapper = null, null === (o = this._aerialPerspectiveCompositorEffectWrapper) || void 0 === o || o.dispose(), this._aerialPerspectiveCompositorEffectWrapper = null, null === (l = this._skyViewLutRenderTarget) || void 0 === l || l.dispose(), this._skyViewLutRenderTarget = null, null === (c = this._skyViewLutEffectWrapper) || void 0 === c || c.dispose(), this._skyViewLutEffectWrapper = null, null === (d = this._skyViewLutEffectRenderer) || void 0 === d || d.dispose(), this._skyViewLutEffectRenderer = null, null === (h = this._aerialPerspectiveLutRenderTarget) || void 0 === h || h.dispose(), this._aerialPerspectiveLutRenderTarget = null, null === (u = this._aerialPerspectiveLutEffectWrapper) || void 0 === u || u.dispose(), this._aerialPerspectiveLutEffectWrapper = null, null === (m = this._aerialPerspectiveLutEffectRenderer) || void 0 === m || m.dispose(), this._aerialPerspectiveLutEffectRenderer = null, null === (p = this._multiScatteringEffectWrapper) || void 0 === p || p.dispose(), this._multiScatteringEffectWrapper = null, null === (f = this._multiScatteringLutRenderTarget) || void 0 === f || f.dispose(), this._multiScatteringLutRenderTarget = null, null === (g = this._transmittanceLut) || void 0 === g || g.dispose(), this._transmittanceLut = null, null === (v = this._diffuseSkyIrradianceLut) || void 0 === v || v.dispose(), this._diffuseSkyIrradianceLut = null, null === (S = this._atmosphereUbo) || void 0 === S || S.dispose(), this._atmosphereUbo = null, null === (_ = this._effectRenderer) || void 0 === _ || _.dispose(), this._effectRenderer = null, this._atmosphereUniformBufferAsArray.length = 0, t.UnregisterMaterialPlugin(z); };
2357
+ Atmosphere.prototype.isEnabled = function () { return this._isEnabled; };
2358
+ Atmosphere.prototype.setEnabled = function (e) { this._isEnabled = e; };
2359
+ Atmosphere.prototype.isReady = function () { var e, t, i, n, r, a, s, o, l, c, d, h, u, m, p, f; if (!this._isEnabled)
2360
+ return !0; var g = this._engine, v = this.uniformBuffer, S = this._isSkyViewLutEnabled, _ = this._isLinearSpaceComposition, y = this._applyApproximateTransmittance, T = this.depthTexture; return null !== (e = this._skyCompositorEffectWrapper) && void 0 !== e || (this._skyCompositorEffectWrapper = Y(g, v, S, _, y)), null !== (t = this._globeAtmosphereCompositorEffectWrapper) && void 0 !== t || (this._globeAtmosphereCompositorEffectWrapper = j(g, v, S, _, y, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias, null !== T)), null !== T && (null !== (i = this._aerialPerspectiveCompositorEffectWrapper) && void 0 !== i || (this._aerialPerspectiveCompositorEffectWrapper = $(g, v, this._isAerialPerspectiveLutEnabled, S, _, y, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias))), null === (n = this._transmittanceLut) || void 0 === n || n.readPixelsAsync(), null === (r = this._diffuseSkyIrradianceLut) || void 0 === r || r.readPixelsAsync(), this.renderGlobalLuts(), !(!(null === (a = this._transmittanceLut) || void 0 === a ? void 0 : a.hasLutData) || this._isDiffuseSkyIrradianceLutEnabled && !(null === (s = this._diffuseSkyIrradianceLut) || void 0 === s ? void 0 : s.hasLutData) || !this._hasRenderedMultiScatteringLut || !1 === (null === (o = this._multiScatteringLutRenderTarget) || void 0 === o ? void 0 : o.isReady()) || !1 === (null === (l = this._multiScatteringEffectWrapper) || void 0 === l ? void 0 : l.isReady()) || this._isSkyViewLutEnabled && (!1 === (null === (c = this._skyViewLutRenderTarget) || void 0 === c ? void 0 : c.isReady()) || !1 === (null === (d = this._skyViewLutEffectWrapper) || void 0 === d ? void 0 : d.isReady())) || this._isAerialPerspectiveLutEnabled && (!1 === (null === (h = this._aerialPerspectiveLutRenderTarget) || void 0 === h ? void 0 : h.isReady()) || !1 === (null === (u = this._aerialPerspectiveLutEffectWrapper) || void 0 === u ? void 0 : u.isReady())) || !1 === (null === (m = this._skyCompositorEffectWrapper) || void 0 === m ? void 0 : m.isReady()) || !1 === (null === (p = this._aerialPerspectiveCompositorEffectWrapper) || void 0 === p ? void 0 : p.isReady()) || !1 === (null === (f = this._globeAtmosphereCompositorEffectWrapper) || void 0 === f ? void 0 : f.isReady())); };
2361
+ Atmosphere.prototype.getClassName = function () { return "Atmosphere"; };
2362
+ Atmosphere.prototype._drawMultiScatteringLut = function () {
2363
+ var _this = this;
2364
+ var e = this._transmittanceLut.renderTarget;
2365
+ Z(this._engine, this._effectRenderer, this._multiScatteringEffectWrapper, this._multiScatteringLutRenderTarget, function (t, i, n, r) { _this.bindUniformBufferToEffect(n), r.bindFramebuffer(i, void 0, void 0, void 0, !0), t.bindBuffers(n), n.setTexture("transmittanceLut", e), t.draw(); });
2366
+ };
2367
+ Atmosphere.prototype.drawAerialPerspectiveCompositor = function () {
2368
+ var _this = this;
2369
+ var e, i, n;
2370
+ if (null === this.depthTexture)
2371
+ return;
2372
+ if (!this.isEnabled())
2373
+ return;
2374
+ var r = this._engine, a = null !== (e = this._aerialPerspectiveCompositorEffectWrapper) && void 0 !== e ? e : this._aerialPerspectiveCompositorEffectWrapper = $(r, this.uniformBuffer, this._isAerialPerspectiveLutEnabled, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias);
2375
+ if (!this._isGlobalLutsReady)
2376
+ return;
2377
+ if (this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius)
2378
+ return;
2379
+ var s = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null, o = this._multiScatteringLutRenderTarget, l = this._transmittanceLut.renderTarget, c = this._isAerialPerspectiveLutEnabled ? this.aerialPerspectiveLutRenderTarget : null;
2380
+ a.isReady() && (null === (i = null == s ? void 0 : s.isReady()) || void 0 === i || i) && o.isReady() && l.isReady() && (null === (n = null == c ? void 0 : c.isReady()) || void 0 === n || n) && this.depthTexture.isReady() && Z(r, this._effectRenderer, a, null, function (e, t, i) { if (null === _this.depthTexture)
2381
+ throw new Error("Depth texture is required for aerial perspective compositor."); _this.bindUniformBufferToEffect(i), e.bindBuffers(i), i.setTexture("transmittanceLut", l), i.setTexture("multiScatteringLut", o), _this._isSkyViewLutEnabled && i.setTexture("skyViewLut", s), _this._isAerialPerspectiveLutEnabled && i.setTexture("aerialPerspectiveLut", c), i.setTexture("depthTexture", _this.depthTexture), e.draw(); }, 1, this.applyApproximateTransmittance ? t.Constants.ALPHA_PREMULTIPLIED_PORTERDUFF : t.Constants.ALPHA_ONEONE, !0, !1, t.Constants.ALWAYS, !1);
2382
+ };
2383
+ Atmosphere.prototype.drawSkyCompositor = function () {
2384
+ var _this = this;
2385
+ var e, i;
2386
+ if (!this.isEnabled())
2387
+ return;
2388
+ var n = this._engine, r = null !== (e = this._skyCompositorEffectWrapper) && void 0 !== e ? e : this._skyCompositorEffectWrapper = Y(n, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance);
2389
+ if (!this._isGlobalLutsReady)
2390
+ return;
2391
+ if (this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius)
2392
+ return;
2393
+ if (null !== this.depthTexture && !this.depthTexture.isReady())
2394
+ return;
2395
+ var a = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null, s = this._multiScatteringLutRenderTarget, o = this._transmittanceLut.renderTarget;
2396
+ r.isReady() && (null === (i = null == a ? void 0 : a.isReady()) || void 0 === i || i) && s.isReady() && o.isReady() && Z(n, this._effectRenderer, r, null, function (e, t, i) { _this.bindUniformBufferToEffect(i), e.bindBuffers(i), i.setTexture("multiScatteringLut", s), i.setTexture("transmittanceLut", o), _this._isSkyViewLutEnabled && i.setTexture("skyViewLut", a), e.draw(); }, 1, this._applyApproximateTransmittance ? t.Constants.ALPHA_PREMULTIPLIED_PORTERDUFF : t.Constants.ALPHA_ONEONE, !0, !1, t.Constants.EQUAL, !1);
2397
+ };
2398
+ Atmosphere.prototype.drawGlobeAtmosphereCompositor = function () {
2399
+ var _this = this;
2400
+ var e, i;
2401
+ if (!this.isEnabled())
2402
+ return;
2403
+ var n = this._engine, r = null !== (e = this._globeAtmosphereCompositorEffectWrapper) && void 0 !== e ? e : this._globeAtmosphereCompositorEffectWrapper = j(n, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias, null !== this.depthTexture);
2404
+ if (!this._isGlobalLutsReady)
2405
+ return;
2406
+ if (!(this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius))
2407
+ return;
2408
+ var a = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null, s = this._multiScatteringLutRenderTarget, o = this._transmittanceLut.renderTarget;
2409
+ r.isReady() && (null === (i = null == a ? void 0 : a.isReady()) || void 0 === i || i) && s.isReady() && o.isReady() && (null === this.depthTexture || this.depthTexture.isReady()) && Z(n, this._effectRenderer, r, null, function (e, t, i) { _this.bindUniformBufferToEffect(i), e.bindBuffers(i), i.setTexture("transmittanceLut", o), i.setTexture("multiScatteringLut", s), _this._isSkyViewLutEnabled && i.setTexture("skyViewLut", a), null !== _this.depthTexture && i.setTexture("depthTexture", _this.depthTexture), e.draw(); }, 1, this._applyApproximateTransmittance ? t.Constants.ALPHA_PREMULTIPLIED_PORTERDUFF : t.Constants.ALPHA_ONEONE, !0, !1, t.Constants.ALWAYS, !1);
2410
+ };
2411
+ Atmosphere.prototype._disposeSkyCompositor = function () { var e; null === (e = this._skyCompositorEffectWrapper) || void 0 === e || e.dispose(), this._skyCompositorEffectWrapper = null; };
2412
+ Atmosphere.prototype._disposeAerialPerspectiveCompositor = function () { var e; null === (e = this._aerialPerspectiveCompositorEffectWrapper) || void 0 === e || e.dispose(), this._aerialPerspectiveCompositorEffectWrapper = null; };
2413
+ Atmosphere.prototype._disposeGlobeAtmosphereCompositor = function () { var e; null === (e = this._globeAtmosphereCompositorEffectWrapper) || void 0 === e || e.dispose(), this._globeAtmosphereCompositorEffectWrapper = null; };
2414
+ Object.defineProperty(Atmosphere.prototype, "_isGlobalLutsReady", {
2415
+ get: function () { var e; return this._hasEverRenderedMultiScatteringLut && !!(null === (e = this._transmittanceLut) || void 0 === e ? void 0 : e.hasLutData) && (!this._isDiffuseSkyIrradianceLutEnabled || this._diffuseSkyIrradianceLut.hasLutData); },
2416
+ enumerable: false,
2417
+ configurable: true
2418
+ });
2419
+ Atmosphere.prototype._updatePerCameraVariables = function (e) { var t = this._lights[0], i = this._directionToLight.copyFrom(t.direction).scaleInPlace(-1), n = this._physicalProperties, r = this._cameraAtmosphereVariables; r.update(e, n.planetRadius, n.planetRadiusWithOffset, n.atmosphereRadius, i, this.originHeight), this._transmittanceLut.updateLightParameters(t, r.clampedCameraRadius, r.cameraGeocentricNormal), this._linearLightColor.copyFrom(t.diffuse), this.getDiffuseSkyIrradianceToRef(i, 0, r.cameraGeocentricNormal, t.intensity, this._tempSceneAmbient), this.isLinearSpaceLight || this._tempSceneAmbient.toGammaSpaceToRef(this._tempSceneAmbient), this.scene.ambientColor = this._tempSceneAmbient, this.onAfterUpdateVariablesForCameraObservable.notifyObservers(e); };
2420
+ Atmosphere.prototype._renderLutsForCamera = function (e) { {
2421
+ this.onBeforeLightVariablesUpdateObservable.notifyObservers();
2422
+ var e_109 = this.lights[0];
2423
+ this.isLinearSpaceLight || (e_109.diffuse = e_109.diffuse.toGammaSpaceToRef(e_109.diffuse), e_109.specular = e_109.specular.toGammaSpaceToRef(e_109.specular));
2424
+ var t_24 = e_109.intensity;
2425
+ this._lightRadianceAtCamera.set(t_24 * this._linearLightColor.r, t_24 * this._linearLightColor.g, t_24 * this._linearLightColor.b);
2426
+ } this.uniformBuffer.useUbo && this.updateUniformBuffer(); var t = this.isEnabled(); this.onBeforeRenderLutsForCameraObservable.notifyObservers(e), t && !this._transmittanceLut.isDirty && this._hasRenderedMultiScatteringLut && (this._isSkyViewLutEnabled && this._drawSkyViewLut(), this._isAerialPerspectiveLutEnabled && (this._cameraAtmosphereVariables.clampedCameraRadius <= this._physicalProperties.atmosphereRadius ? this._drawAerialPerspectiveLut() : this._aerialPerspectiveLutHasBeenRendered || this._clearAerialPerspectiveLut(), this._aerialPerspectiveLutHasBeenRendered = !0)), this.onAfterRenderLutsForCameraObservable.notifyObservers(e); };
2427
+ Atmosphere.prototype.renderGlobalLuts = function () { var e, t, i, n, r; this.uniformBuffer.useUbo && this.updateUniformBuffer(), this._transmittanceLut.render() && (this._hasRenderedMultiScatteringLut = !1, null === (e = this._diffuseSkyIrradianceLut) || void 0 === e || e.markDirty()), this._transmittanceLut.isDirty || this._hasRenderedMultiScatteringLut || (null !== (t = this._multiScatteringEffectWrapper) && void 0 !== t || (this._multiScatteringEffectWrapper = W(this._engine, this.uniformBuffer, this._groundAlbedo)), (null === (i = this._multiScatteringEffectWrapper) || void 0 === i ? void 0 : i.isReady()) && (null === (n = this._multiScatteringLutRenderTarget) || void 0 === n ? void 0 : n.isReady()) && (this._drawMultiScatteringLut(), this._hasRenderedMultiScatteringLut = !0, this._hasEverRenderedMultiScatteringLut = !0)), !this._transmittanceLut.isDirty && this._hasRenderedMultiScatteringLut && (null === (r = this._diffuseSkyIrradianceLut) || void 0 === r || r.render()); };
2428
+ Atmosphere.prototype.bindUniformBufferToEffect = function (e) { var t = this.uniformBuffer, i = 1 === e.shaderLanguage ? "atmosphere" : t.name; t.bindToEffect(e, i), t.useUbo ? t.update() : this.updateUniformBuffer(); };
2429
+ Atmosphere.prototype.updateUniformBuffer = function () { var e = this._physicalProperties, t = this._cameraAtmosphereVariables, i = this.uniformBuffer; i.updateVector3("peakRayleighScattering", e.rayleighScattering), i.updateFloat("planetRadius", e.planetRadius), i.updateVector3("peakMieScattering", e.mieScattering), i.updateFloat("atmosphereThickness", e.atmosphereThickness), i.updateVector3("peakMieAbsorption", e.mieAbsorption), i.updateFloat("planetRadiusSquared", e.planetRadiusSquared), i.updateVector3("peakMieExtinction", e.mieExtinction), i.updateFloat("atmosphereRadius", e.atmosphereRadius), i.updateVector3("peakOzoneAbsorption", e.ozoneAbsorption), i.updateFloat("atmosphereRadiusSquared", e.atmosphereRadiusSquared), i.updateFloat("horizonDistanceToAtmosphereEdge", e.horizonDistanceToAtmosphereEdge), i.updateFloat("horizonDistanceToAtmosphereEdgeSquared", e.horizonDistanceToAtmosphereEdgeSquared), i.updateFloat("planetRadiusWithOffset", e.planetRadiusWithOffset), i.updateFloat("planetRadiusOffset", e.planetRadiusOffset), i.updateFloat("aerialPerspectiveRadianceBias", this._aerialPerspectiveRadianceBias), i.updateFloat("inverseAtmosphereThickness", 1 / e.atmosphereThickness), i.updateFloat("aerialPerspectiveTransmittanceScale", this._aerialPerspectiveTransmittanceScale), i.updateMatrix("inverseViewProjectionWithoutTranslation", t.inverseViewProjectionMatrixWithoutTranslation), i.updateVector3("directionToLight", this._directionToLight), i.updateFloat("multiScatteringIntensity", this.multiScatteringIntensity), i.updateVector3("directionToLightRelativeToCameraGeocentricNormal", t.directionToLightRelativeToCameraGeocentricNormal), i.updateFloat("cameraRadius", t.cameraRadius), i.updateVector3("lightRadianceAtCamera", this._lightRadianceAtCamera), i.updateFloat("diffuseSkyIrradianceDesaturationFactor", this._diffuseSkyIrradianceDesaturationFactor), i.updateColor3("groundAlbedo", this._groundAlbedo), i.updateFloat("aerialPerspectiveSaturation", this._aerialPerspectiveSaturation), i.updateVector3("minMultiScattering", this._minimumMultiScattering), i.updateFloat("diffuseSkyIrradianceIntensity", this._diffuseSkyIrradianceIntensity), i.updateVector3("cameraPositionGlobal", t.cameraPositionGlobal), i.updateFloat("lightIntensity", this.lights[0].getScaledIntensity()), i.updateVector3("clampedCameraPositionGlobal", t.clampedCameraPositionGlobal), i.updateFloat("aerialPerspectiveIntensity", this._aerialPerspectiveIntensity), i.updateVector3("cameraGeocentricNormal", t.cameraGeocentricNormal), i.updateFloat("clampedCameraRadius", t.clampedCameraRadius), i.updateVector3("cameraForward", t.cameraForward), i.updateFloat("clampedCameraHeight", t.clampedCameraHeight), i.updateVector3("cameraPosition", t.cameraPosition), i.updateFloat("cosCameraHorizonAngleFromZenith", t.cosCameraHorizonAngleFromZenith), i.updateVector4("viewport", t.viewport), i.updateColor3("additionalDiffuseSkyIrradiance", this._additionalDiffuseSkyIrradiance), i.updateFloat("cameraHeight", t.cameraHeight), i.updateFloat("cameraNearPlane", t.cameraNearPlane), i.updateFloat("originHeight", this._originHeight), i.updateFloat("sinCameraAtmosphereHorizonAngleFromNadir", t.sinCameraAtmosphereHorizonAngleFromNadir), i.updateFloat("transmittanceSampleCount", 128), i.updateFloat("skyViewLutSampleCount", 30), i.updateFloat("multiScatteringLutSampleCount", 64), i.updateFloat("multiScatteringAzimuthSampleCount", 16), i.updateFloat("multiScatteringInclinationSampleCount", 8), i.updateFloat("diffuseSkyIrradianceLutSampleCount", 32), i.updateFloat("atmosphereExposure", this._exposure); };
2430
+ Atmosphere.prototype._drawAerialPerspectiveLut = function () {
2431
+ var _this = this;
2432
+ var e = this._transmittanceLut.renderTarget, t = this._multiScatteringLutRenderTarget;
2433
+ Z(this._engine, this._effectRenderer, this._aerialPerspectiveLutEffectWrapper, this._aerialPerspectiveLutRenderTarget, function (i, n, r, a) { _this.bindUniformBufferToEffect(r), r.setTexture("transmittanceLut", e), r.setTexture("multiScatteringLut", t); for (var e_110 = 0; e_110 < 32; e_110++)
2434
+ a.bindFramebuffer(n, void 0, void 0, void 0, !0, void 0, e_110), i.bindBuffers(r), r.setFloat("layerIdx", e_110), i.draw(); });
2435
+ };
2436
+ Atmosphere.prototype._clearAerialPerspectiveLut = function () { var e; var t = null === (e = this._aerialPerspectiveLutRenderTarget) || void 0 === e ? void 0 : e.renderTarget; if (t) {
2437
+ var e_111 = this._engine, i_18 = { r: 0, g: 0, b: 0, a: 0 };
2438
+ for (var n_12 = 0; n_12 < 32; n_12++)
2439
+ e_111.bindFramebuffer(t, void 0, void 0, void 0, !0, void 0, n_12), e_111.clear(i_18, !0, !1, !1);
2440
+ } };
2441
+ Atmosphere.prototype._drawSkyViewLut = function () {
2442
+ var _this = this;
2443
+ var e = this._transmittanceLut.renderTarget, t = this._multiScatteringLutRenderTarget;
2444
+ Z(this._engine, this._effectRenderer, this._skyViewLutEffectWrapper, this._skyViewLutRenderTarget, function (i, n, r, a) { _this.bindUniformBufferToEffect(r), a.bindFramebuffer(n, void 0, void 0, void 0, !0), i.bindBuffers(r), r.setTexture("transmittanceLut", e), r.setTexture("multiScatteringLut", t), i.draw(); });
2445
+ };
2446
+ return Atmosphere;
2447
+ }()), e.AtmospherePhysicalProperties = A, e.BuildFromNavmeshData = function (e) { var t = Ge(), i = t.importNavMesh(e); if (!i.navMesh)
2448
+ throw new Error("Unable to deserialize NavMesh."); return { navMesh: i.navMesh, navMeshQuery: new t.NavMeshQuery(i.navMesh), tileCache: void 0 }; }, e.BuildFromTileCacheData = function (e, t) { var i = Ge(), n = i.importTileCache(e, t); if (!n.tileCache)
2449
+ throw new Error("Unable to deserialize TileCache."); return { navMesh: n.navMesh, navMeshQuery: new i.NavMeshQuery(n.navMesh), tileCache: n.tileCache }; }, e.ComputeSmoothPath = et, e.ConvertNavPathPoints = Ke, e.CreateDebugNavMesh = ot, e.CreateDefaultTileCacheMeshProcess = He, e.CreateNavigationPluginAsync = function (e) { return i(this, void 0, void 0, function () { var n; return __generator(this, function (_a) {
2450
+ switch (_a.label) {
2451
+ case 0: return [4 /*yield*/, function (e) { return i(this, void 0, void 0, function () { var n, r, a, e_112; return __generator(this, function (_a) {
2452
+ switch (_a.label) {
2453
+ case 0:
2454
+ r = null !== (n = null == e ? void 0 : e.version) && void 0 !== n ? n : "0.43.0", a = Object.assign({ url: "https://unpkg.com/@recast-navigation", version: r }, e);
2455
+ if (!!ze) return [3 /*break*/, 6];
2456
+ if (!Be) return [3 /*break*/, 2];
2457
+ return [4 /*yield*/, Be];
2458
+ case 1:
2459
+ _a.sent();
2460
+ return [3 /*break*/, 6];
2461
+ case 2:
2462
+ if (!a.instance) return [3 /*break*/, 3];
2463
+ ze = a.instance;
2464
+ return [3 /*break*/, 6];
2465
+ case 3:
2466
+ Be = function (e, n) { return i(this, void 0, void 0, function () { var i, r; return __generator(this, function (_a) {
2467
+ switch (_a.label) {
2468
+ case 0:
2469
+ i = { imports: { "@recast-navigation/core": "".concat(e, "/core@").concat(n, "/dist/index.mjs"), "@recast-navigation/wasm": "".concat(e, "/wasm@").concat(n, "/dist/recast-navigation.wasm-compat.js"), "@recast-navigation/generators": "".concat(e, "/generators@").concat(n, "/dist/index.mjs") } }, r = document.createElement("script");
2470
+ r.type = "importmap", r.textContent = JSON.stringify(i), document.body.appendChild(r);
2471
+ return [4 /*yield*/, t._LoadScriptModuleAsync("\n import * as CoreModule from '".concat(e, "/core@").concat(n, "/dist/index.mjs';\n import * as GeneratorsModule from '").concat(e, "/generators@").concat(n, "/dist/index.mjs';\n const returnedValue = {core: CoreModule, generators: GeneratorsModule};\n "))];
2472
+ case 1: return [2 /*return*/, _a.sent()];
2473
+ }
2474
+ }); }); }(a.url, a.version);
2475
+ return [4 /*yield*/, Be];
2476
+ case 4:
2477
+ e_112 = _a.sent();
2478
+ ze = Object.assign(Object.assign({}, e_112.core), e_112.generators);
2479
+ return [4 /*yield*/, ze.init()];
2480
+ case 5:
2481
+ _a.sent();
2482
+ _a.label = 6;
2483
+ case 6: return [2 /*return*/];
2484
+ }
2485
+ }); }); }(e)];
2486
+ case 1:
2487
+ _a.sent();
2488
+ n = new dt(Ge());
2489
+ return [2 /*return*/, (ct(n), n)];
2490
+ }
2491
+ }); }); }, e.CreateSoloNavMeshConfig = qe, e.CreateTileCacheNavMeshConfig = Ye, e.CreateTiledNavMeshConfig = Ze, e.DebugLayerOption = ut, e.DefaultMaxObstacles = 128, e.DefaultParagraphOptions = Te, e.DiffuseSkyIrradianceLut = D, e.FitStrategy = Se, e.FontAsset = /** @class */ (function () {
2492
+ function FontAsset(e, i, n) {
2493
+ var _this = this;
2494
+ this._chars = new Map, this._kernings = new Map, this._font = JSON.parse(e), this._font.pages = [i], this._font.chars.forEach(function (e) { return _this._chars.set(e.id, e); }), this._font.kernings.forEach(function (e) { var t = _this._kernings.get(e.first); t || (t = new Map, _this._kernings.set(e.first, t)), t.set(e.second, e.amount); }), this._charsRegex = new RegExp("[".concat(this._font.chars.map(function (e) { return e.char.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); }).join(""), "]"), "g"), this._updateFallbacks(), this.scale = 1 / this._font.info.size, this.textures = this._font.pages.map(function (e) { var i = new t.Texture(e, n, { noMipmap: !1, invertY: !1 }); return i.anisotropicFilteringLevel = 16, i; });
2495
+ }
2496
+ FontAsset.prototype.dispose = function () {
2497
+ var e_113, _a;
2498
+ try {
2499
+ for (var _b = __values(this.textures), _c = _b.next(); !_c.done; _c = _b.next()) {
2500
+ var e_114 = _c.value;
2501
+ e_114.dispose();
2502
+ }
2503
+ }
2504
+ catch (e_113_1) { e_113 = { error: e_113_1 }; }
2505
+ finally {
2506
+ try {
2507
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2508
+ }
2509
+ finally { if (e_113) throw e_113.error; }
2510
+ }
2511
+ this.textures.length = 0;
2512
+ };
2513
+ FontAsset.prototype._updateFallbacks = function () { this._chars.has(ye.SPACE) || this._chars.set(ye.SPACE, { id: ye.SPACE, x: 0, y: 0, width: 0, height: 0, xoffset: 0, yoffset: 0, xadvance: .5 * this._font.info.size, page: -1, chnl: -1, index: -1, char: " " }), this._chars.has(ye.TOFU) || this._chars.set(ye.TOFU, { id: ye.TOFU, x: 0, y: 0, width: this._font.info.size, height: this._font.info.size, xoffset: 0, yoffset: 0, xadvance: .5 * this._font.info.size, page: -1, chnl: -1, index: -1, char: "￿" }); };
2514
+ FontAsset.prototype._getChar = function (e) { return this._chars.get(e) || this._chars.get(ye.TOFU); };
2515
+ FontAsset.prototype._getKerning = function (e, t) { var i; return (null === (i = this._kernings.get(e)) || void 0 === i ? void 0 : i.get(t)) || 0; };
2516
+ FontAsset.prototype._unsupportedChars = function (e) { return e.replace(this._charsRegex, ""); };
2517
+ return FontAsset;
2518
+ }()), e.GenerateNavMesh = lt, e.GetChaikinSmoothPath = function (e, t) {
2519
+ if (t === void 0) { t = 1; }
2520
+ for (var i_19 = 0; i_19 < t; i_19++) {
2521
+ var t_25 = [];
2522
+ for (var i_20 = 0; i_20 < e.length - 1; i_20++) {
2523
+ var n_13 = e[i_20], r_14 = e[i_20 + 1];
2524
+ t_25.push({ x: .75 * n_13.x + .25 * r_14.x, y: .75 * n_13.y + .25 * r_14.y, z: .75 * n_13.z + .25 * r_14.z }), t_25.push({ x: .25 * n_13.x + .75 * r_14.x, y: .25 * n_13.y + .75 * r_14.y, z: .25 * n_13.z + .75 * r_14.z });
2525
+ }
2526
+ e[0].x === e[e.length - 1].x && e[0].y === e[e.length - 1].y && e[0].z === e[e.length - 1].z && t_25.push(t_25[0]), e = t_25;
2527
+ }
2528
+ return e;
2529
+ }, e.GetLShapedPath = function (e) { var i = []; for (var n_14 = 0; n_14 < e.length - 1; n_14++) {
2530
+ var r_15 = e[n_14], a_14 = e[n_14 + 1], s_13 = ht(r_15, a_14);
2531
+ i.push(r_15, new t.Vector3(s_13.x, a_14.y, s_13.z), a_14);
2532
+ } return i; }, e.GetPositionsAndIndices = at, e.GetReversedIndices = st, e.HtmlMesh = _e, e.HtmlMeshRenderer = X, e.InjectGenerators = ct, e.NavigationDebugger = mt, e.PointerEventsCaptureBehavior = ve, e.RecastNavigationJSPluginV2 = dt, e.SdfTextParagraph = Ae, e.TextRenderer = Pe, e.ToCrowdAgentParams = je, e.ToSoloNavMeshGeneratorConfig = $e, e.TransmittanceLut = G, e.WaitForFullTileCacheUpdate = We, e.msdfPixelShader = we, e.msdfPixelShaderWGSL = Ue, e.msdfVertexShader = Ee, e.msdfVertexShaderWGSL = Oe;
2533
+ });