babylonjs-addons 9.26.0 → 9.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babylonjs.addons.d.ts +426 -0
- package/babylonjs.addons.es5.js +1339 -884
- package/babylonjs.addons.js +1 -1
- package/babylonjs.addons.js.map +1 -1
- package/babylonjs.addons.min.js +1 -1
- package/babylonjs.addons.min.js.map +1 -1
- package/babylonjs.addons.module.d.ts +876 -0
- package/package.json +2 -2
package/babylonjs.addons.es5.js
CHANGED
|
@@ -79,27 +79,27 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
79
79
|
};
|
|
80
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
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,
|
|
83
|
-
function i(e, t, i,
|
|
84
|
-
l(
|
|
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, _s, e_16, _u, e_17, _v, e_18, _w;
|
|
83
|
+
function i(e, t, i, r) { return new (i || (i = Promise))(function (n, a) { function s(e) { try {
|
|
84
|
+
l(r.next(e));
|
|
85
85
|
}
|
|
86
86
|
catch (e) {
|
|
87
87
|
a(e);
|
|
88
88
|
} } function o(e) { try {
|
|
89
|
-
l(
|
|
89
|
+
l(r.throw(e));
|
|
90
90
|
}
|
|
91
91
|
catch (e) {
|
|
92
92
|
a(e);
|
|
93
|
-
} } function l(e) { var t; e.done ?
|
|
93
|
+
} } function l(e) { var t; e.done ? n(e.value) : (t = e.value, t instanceof i ? t : new i(function (e) { e(t); })).then(s, o); } l((r = r.apply(e, t || [])).next()); }); }
|
|
94
94
|
Object.create, Object.create, "function" == typeof SuppressedError && SuppressedError, t.MaterialDefines;
|
|
95
|
-
var
|
|
96
|
-
function h(e) { return 1 === e ?
|
|
97
|
-
function
|
|
95
|
+
var r = "originOffsetKm", n = "inverseViewportSize", a = [{ name: r, size: 3, type: "vec3" }, { name: "_atmoPbrPadding1", size: 1, type: "float" }, { name: n, 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 }, u = { loaded: !1, loadPromise: null, nextRetryTime: 0 };
|
|
96
|
+
function h(e) { return 1 === e ? u : c; }
|
|
97
|
+
function d(e) {
|
|
98
98
|
var e_19, _a;
|
|
99
|
-
var i = t.ShaderStore.GetIncludesShadersStore(e),
|
|
99
|
+
var i = t.ShaderStore.GetIncludesShadersStore(e), r = 1 === e ? l : o;
|
|
100
100
|
try {
|
|
101
|
-
for (var
|
|
102
|
-
var e_20 =
|
|
101
|
+
for (var r_1 = __values(r), r_1_1 = r_1.next(); !r_1_1.done; r_1_1 = r_1.next()) {
|
|
102
|
+
var e_20 = r_1_1.value;
|
|
103
103
|
if (void 0 === i[e_20])
|
|
104
104
|
return !1;
|
|
105
105
|
}
|
|
@@ -107,7 +107,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
107
107
|
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
108
108
|
finally {
|
|
109
109
|
try {
|
|
110
|
-
if (
|
|
110
|
+
if (r_1_1 && !r_1_1.done && (_a = r_1.return)) _a.call(r_1);
|
|
111
111
|
}
|
|
112
112
|
finally { if (e_19) throw e_19.error; }
|
|
113
113
|
}
|
|
@@ -117,7 +117,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
117
117
|
switch (_a.label) {
|
|
118
118
|
case 0:
|
|
119
119
|
t = h(e);
|
|
120
|
-
if (!(t.loaded ||
|
|
120
|
+
if (!(t.loaded || d(e))) return [3 /*break*/, 1];
|
|
121
121
|
t.loaded = !0;
|
|
122
122
|
return [3 /*break*/, 5];
|
|
123
123
|
case 1:
|
|
@@ -125,11 +125,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
125
125
|
switch (_b.label) {
|
|
126
126
|
case 0:
|
|
127
127
|
if (!(1 === e)) return [3 /*break*/, 2];
|
|
128
|
-
return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return
|
|
128
|
+
return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return Lt; }), Promise.resolve().then(function () { return Ct; })])];
|
|
129
129
|
case 1:
|
|
130
130
|
_a = _b.sent();
|
|
131
131
|
return [3 /*break*/, 4];
|
|
132
|
-
case 2: return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return
|
|
132
|
+
case 2: return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return wt; }), Promise.resolve().then(function () { return Nt; }), Promise.resolve().then(function () { return Gt; })])];
|
|
133
133
|
case 3:
|
|
134
134
|
_a = _b.sent();
|
|
135
135
|
_b.label = 4;
|
|
@@ -164,7 +164,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
164
164
|
var i_1 = 1 === this._material.shaderLanguage ? "atmosphere" : t.name;
|
|
165
165
|
e.push(i_1);
|
|
166
166
|
} };
|
|
167
|
-
p.prototype.getUniforms = function () { return e = this._atmosphere, { ubo: a, fragment: "uniform vec2 ".concat(
|
|
167
|
+
p.prototype.getUniforms = function () { return e = this._atmosphere, { ubo: a, fragment: "uniform vec2 ".concat(n, ";\nuniform vec3 ").concat(r, ";\n"), externalUniforms: e.uniformBuffer.getUniformNames() }; var e; };
|
|
168
168
|
p.prototype.isReadyForSubMesh = function () { var e; if (!this._ensureShaderIncludesLoaded())
|
|
169
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
170
|
return !1; if (this._isAerialPerspectiveEnabled && t.isAerialPerspectiveLutEnabled) {
|
|
@@ -172,8 +172,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
172
172
|
if (!(null == e_22 ? void 0 : e_22.isReady()))
|
|
173
173
|
return !1;
|
|
174
174
|
} return !0; };
|
|
175
|
-
p.prototype._ensureShaderIncludesLoaded = function () { var e = this._material.shaderLanguage, t = h(e); return t.loaded ||
|
|
176
|
-
p.prototype._tryLoadShaderIncludesAsync = function (e,
|
|
175
|
+
p.prototype._ensureShaderIncludesLoaded = function () { var e = this._material.shaderLanguage, t = h(e); return t.loaded || d(e) ? (t.loaded = !0, !0) : (!t.loadPromise && Date.now() >= t.nextRetryTime && this._tryLoadShaderIncludesAsync(e, t), !1); };
|
|
176
|
+
p.prototype._tryLoadShaderIncludesAsync = function (e, r) { return i(this, void 0, void 0, function () { var e_23; return __generator(this, function (_a) {
|
|
177
177
|
switch (_a.label) {
|
|
178
178
|
case 0:
|
|
179
179
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -183,7 +183,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
183
183
|
return [3 /*break*/, 3];
|
|
184
184
|
case 2:
|
|
185
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)),
|
|
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)), r.nextRetryTime = Date.now() + 5e3;
|
|
187
187
|
return [3 /*break*/, 3];
|
|
188
188
|
case 3: return [2 /*return*/];
|
|
189
189
|
}
|
|
@@ -199,18 +199,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
199
199
|
}
|
|
200
200
|
});
|
|
201
201
|
}); };
|
|
202
|
-
p.prototype.getActiveTextures = function (e) { var t, i; var
|
|
203
|
-
var t_1 =
|
|
202
|
+
p.prototype.getActiveTextures = function (e) { var t, i; var r = this._atmosphere; if (this._isAerialPerspectiveEnabled && r.isAerialPerspectiveLutEnabled) {
|
|
203
|
+
var t_1 = r.aerialPerspectiveLutRenderTarget;
|
|
204
204
|
t_1 && e.push(t_1);
|
|
205
|
-
} var
|
|
206
|
-
p.prototype.bindForSubMesh = function (e) { var i, a; var o = this._atmosphere, l = o.scene, c = l.getEngine(),
|
|
205
|
+
} var n = null !== (i = null === (t = r.transmittanceLut) || void 0 === t ? void 0 : t.renderTarget) && void 0 !== i ? i : null; n && e.push(n); };
|
|
206
|
+
p.prototype.bindForSubMesh = function (e) { var i, a; var o = this._atmosphere, l = o.scene, c = l.getEngine(), u = e.currentEffect; u && this._atmosphere.bindUniformBufferToEffect(u), e.updateVector3(r, l.floatingOriginMode ? t.Vector3ScaleToRef(l.floatingOriginOffset, .001, s) : t.Vector3FromFloatsToRef(0, o.physicalProperties.planetRadius, 0, s)); var h = c.getRenderWidth(), d = c.getRenderHeight(); if (e.updateFloat2(n, 1 / h, 1 / d), this._isAerialPerspectiveEnabled && o.isAerialPerspectiveLutEnabled) {
|
|
207
207
|
var t_2 = o.aerialPerspectiveLutRenderTarget;
|
|
208
208
|
e.setTexture("aerialPerspectiveLut", t_2);
|
|
209
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,
|
|
210
|
+
p.prototype.prepareDefines = function (e) { var t = e.USE_CUSTOM_REFLECTION, i = e.USE_AERIAL_PERSPECTIVE_LUT, r = e.APPLY_AERIAL_PERSPECTIVE_INTENSITY, n = 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 && r === e.APPLY_AERIAL_PERSPECTIVE_INTENSITY && n === e.APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS || e.markAllAsDirty(); };
|
|
211
211
|
p.prototype.getSamplers = function (e) { e.push("transmittanceLut"), this._isAerialPerspectiveEnabled && this._atmosphere.isAerialPerspectiveLutEnabled && e.push("aerialPerspectiveLut"); };
|
|
212
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(
|
|
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(r, ";\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(r, ";\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(n, ",\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(r, ";\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(r, ";\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(n, ",\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
214
|
return p;
|
|
215
215
|
}(t.MaterialPluginBase));
|
|
216
216
|
var f = new t.Ray(t.Vector3.Zero(), t.Vector3.Zero());
|
|
@@ -298,18 +298,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
298
298
|
enumerable: false,
|
|
299
299
|
configurable: true
|
|
300
300
|
});
|
|
301
|
-
g.prototype.update = function (e, i,
|
|
301
|
+
g.prototype.update = function (e, i, r, n, 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(), u = e.getProjectionMatrix(), h = this._lastViewMatrix, d = this._lastProjectionMatrix; h.equals(c) && d.equals(u) || (h.copyFrom(c), h.setTranslation(t.Vector3.ZeroReadOnly), h.invertToRef(this._inverseViewMatrixWithoutTranslation), d.copyFrom(u), d.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 < r ? (this._clampedCameraRadius = r, this._cameraGeocentricNormal.scaleToRef(r, this._clampedCameraPositionGlobal)) : this._clampedCameraPositionGlobal.copyFrom(m), this._cosCameraHorizonAngleFromZenith = v(i, this._clampedCameraRadius), this._sinCameraAtmosphereHorizonAngleFromNadir = Math.min(1, n / this._clampedCameraRadius), this._clampedCameraHeight = this._clampedCameraRadius - i; {
|
|
302
302
|
this._cosAngleLightToZenith = t.Vector3Dot(a, this._cameraGeocentricNormal);
|
|
303
303
|
var e_24 = Math.sqrt(Math.max(0, 1 - this._cosAngleLightToZenith * this._cosAngleLightToZenith));
|
|
304
304
|
this._directionToLightRelativeToCameraGeocentricNormal.copyFromFloats(e_24, this._cosAngleLightToZenith, 0), this._directionToLightRelativeToCameraGeocentricNormal.normalize();
|
|
305
305
|
} };
|
|
306
306
|
return g;
|
|
307
307
|
}());
|
|
308
|
-
var v = function (e, t) { var i = Math.min(1, e / t); return -Math.sqrt(1 - i * i); },
|
|
308
|
+
var v = function (e, t) { var i = Math.min(1, e / t); return -Math.sqrt(1 - i * i); }, _ = new t.Vector3(.005802, .013558, .0331), S = 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
309
|
var A = /** @class */ (function () {
|
|
310
310
|
function A(e) {
|
|
311
|
-
var i,
|
|
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 !== (
|
|
311
|
+
var i, r, n, a, s, o, l, c, u, h, d;
|
|
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 !== (r = null == e ? void 0 : e.planetRadiusOffset) && void 0 !== r ? r : .01, this._atmosphereThickness = null !== (n = null == e ? void 0 : e.atmosphereThickness) && void 0 !== n ? n : 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 : _), 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 : S), this._mieAbsorptionScale = null !== (c = null == e ? void 0 : e.mieAbsorptionScale) && void 0 !== c ? c : 1, this._peakMieAbsorption.copyFrom(null !== (u = null == e ? void 0 : e.peakMieAbsorption) && void 0 !== u ? u : y), this._ozoneAbsorptionScale = null !== (h = null == e ? void 0 : e.ozoneAbsorptionScale) && void 0 !== h ? h : 1, this._peakOzoneAbsorption.copyFrom(null !== (d = null == e ? void 0 : e.peakOzoneAbsorption) && void 0 !== d ? d : T), this._recomputeDimensionalParameters(), this._recomputeRayleighScattering(), this._recomputeMieScattering(), this._recomputeMieAbsorption(), this._recomputeOzoneAbsorption();
|
|
313
313
|
}
|
|
314
314
|
Object.defineProperty(A.prototype, "planetRadius", {
|
|
315
315
|
get: function () { return this._planetRadius; },
|
|
@@ -440,79 +440,79 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
440
440
|
A.prototype._recomputeOzoneAbsorption = function () { this._peakOzoneAbsorption.scaleToRef(this._ozoneAbsorptionScale, this._ozoneAbsorption); };
|
|
441
441
|
return A;
|
|
442
442
|
}());
|
|
443
|
-
var
|
|
444
|
-
function
|
|
443
|
+
var L = function () { return ({ r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN }); }, P = L(), E = L(), R = L(), C = L(), x = function (e) { return e / 255; };
|
|
444
|
+
function M(e, i, r, n, a, s, o) {
|
|
445
445
|
if (o === void 0) { o = x; }
|
|
446
|
-
if (
|
|
446
|
+
if (r <= 0 || n <= 0)
|
|
447
447
|
throw new Error("Sample2DRgbaToRef: widthPx and heightPx must be positive.");
|
|
448
|
-
var l =
|
|
448
|
+
var l = r * n * 4;
|
|
449
449
|
if (a.length < l)
|
|
450
450
|
throw new Error("Sample2DRgbaToRef: data length (".concat(a.length, ") is less than required (").concat(l, ")."));
|
|
451
451
|
e = t.Clamp(e), i = t.Clamp(i);
|
|
452
|
-
var c = Math.max(e *
|
|
453
|
-
return s.r = f.r *
|
|
452
|
+
var c = Math.max(e * r - .5, 0), u = Math.max(i * n - .5, 0), h = Math.floor(c), d = Math.min(h + 1, r - 1), m = Math.floor(u), p = Math.min(m + 1, n - 1), f = I(h, m, r, n, a, P, o), g = I(h, p, r, n, a, E, o), v = I(d, m, r, n, a, R, o), _ = I(d, p, r, n, a, C, o), S = c - h, y = u - m, T = 1 - S, A = 1 - y, L = T * A, M = S * A, w = T * y, b = S * y;
|
|
453
|
+
return s.r = f.r * L + v.r * M + g.r * w + _.r * b, s.g = f.g * L + v.g * M + g.g * w + _.g * b, s.b = f.b * L + v.b * M + g.b * w + _.b * b, s.a = f.a * L + v.a * M + g.a * w + _.a * b, s;
|
|
454
454
|
}
|
|
455
|
-
var
|
|
455
|
+
var I = function (e, i, r, n, a, s, o) {
|
|
456
456
|
if (o === void 0) { o = x; }
|
|
457
|
-
var l = t.Clamp(e, 0,
|
|
457
|
+
var l = t.Clamp(e, 0, r - 1), c = 4 * (t.Clamp(i, 0, n - 1) * r + l);
|
|
458
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
|
-
},
|
|
460
|
-
var
|
|
461
|
-
function
|
|
459
|
+
}, w = { x: Number.NaN, y: Number.NaN }, b = { r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN };
|
|
460
|
+
var O = /** @class */ (function () {
|
|
461
|
+
function O(e) {
|
|
462
462
|
var _this = this;
|
|
463
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
|
|
464
|
+
var r = e.scene, n = r.getEngine(), a = "atmo-diffuseSkyIrradiance", s = n.getCaps().textureHalfFloatRender ? t.Constants.TEXTURETYPE_HALF_FLOAT : t.Constants.TEXTURETYPE_UNSIGNED_BYTE, o = this._renderTarget = new t.RenderTargetTexture(a, { width: 64, height: 16 }, r, { generateMipMaps: !1, type: s, samplingMode: t.Constants.TEXTURE_BILINEAR_SAMPLINGMODE, generateDepthBuffer: !1, gammaSpace: !1 });
|
|
465
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,
|
|
467
|
-
this._effectWrapper = new t.EffectWrapper({ engine:
|
|
466
|
+
var l = e.uniformBuffer, c = l.useUbo, u = n.isWebGPU && !t.EffectWrapper.ForceGLSL, h = u ? "atmosphere" : l.name;
|
|
467
|
+
this._effectWrapper = new t.EffectWrapper({ engine: n, 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: u ? 1 : 0, extraInitializationsAsync: function () { return i(_this, void 0, void 0, function () { var e, i, r; return __generator(this, function (_a) {
|
|
468
468
|
switch (_a.label) {
|
|
469
|
-
case 0: return [4 /*yield*/, Promise.all(
|
|
469
|
+
case 0: return [4 /*yield*/, Promise.all(u ? [Promise.resolve().then(function () { return Wt; }), Promise.resolve().then(function () { return $t; })] : [Promise.resolve().then(function () { return Qt; }), Promise.resolve().then(function () { return ti; })])];
|
|
470
470
|
case 1:
|
|
471
471
|
_a.sent();
|
|
472
|
-
e = (
|
|
473
|
-
e = e.replace(/^CUSTOM_IRRADIANCE_FILTERING_INPUT\s*$/gm, ""), e = e.replace(/^CUSTOM_IRRADIANCE_FILTERING_FUNCTION\s*$/gm,
|
|
474
|
-
i =
|
|
475
|
-
|
|
476
|
-
|
|
472
|
+
e = (u ? 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, u ? "var c = integrateForIrradiance(n, Ls, vec3f(0., filteringInfo.x, 0.));" : "vec3 c = integrateForIrradiance(n, Ls, vec3(0., filteringInfo.x, 0.));");
|
|
474
|
+
i = u ? t.ShaderStore.ShadersStoreWGSL : t.ShaderStore.ShadersStore;
|
|
475
|
+
r = i.diffuseSkyIrradiancePixelShader;
|
|
476
|
+
r = r.replace("#include<hdrFilteringFunctions>", e), i.diffuseSkyIrradiancePixelShader = r;
|
|
477
477
|
return [2 /*return*/];
|
|
478
478
|
}
|
|
479
|
-
}); }); } }), this._effectRenderer = new t.EffectRenderer(
|
|
479
|
+
}); }); } }), this._effectRenderer = new t.EffectRenderer(n, { indices: [0, 2, 1], positions: [-1, -1, -1, 3, 3, -1] }), r.environmentTexture = o, r.environmentTexture.irradianceTexture = o, r.environmentIntensity = 1, r.environmentTexture.isRenderTarget = !1;
|
|
480
480
|
}
|
|
481
|
-
Object.defineProperty(
|
|
481
|
+
Object.defineProperty(O.prototype, "isDirty", {
|
|
482
482
|
get: function () { return this._isDirty; },
|
|
483
483
|
enumerable: false,
|
|
484
484
|
configurable: true
|
|
485
485
|
});
|
|
486
|
-
Object.defineProperty(
|
|
486
|
+
Object.defineProperty(O.prototype, "isDisposed", {
|
|
487
487
|
get: function () { return this._isDisposed; },
|
|
488
488
|
enumerable: false,
|
|
489
489
|
configurable: true
|
|
490
490
|
});
|
|
491
|
-
Object.defineProperty(
|
|
491
|
+
Object.defineProperty(O.prototype, "renderTarget", {
|
|
492
492
|
get: function () { if (this._isDisposed || null === this._renderTarget)
|
|
493
493
|
throw new Error; return this._renderTarget; },
|
|
494
494
|
enumerable: false,
|
|
495
495
|
configurable: true
|
|
496
496
|
});
|
|
497
|
-
Object.defineProperty(
|
|
497
|
+
Object.defineProperty(O.prototype, "hasLutData", {
|
|
498
498
|
get: function () { return void 0 !== this._lutData[0]; },
|
|
499
499
|
enumerable: false,
|
|
500
500
|
configurable: true
|
|
501
501
|
});
|
|
502
|
-
|
|
503
|
-
return a.r = o.r, a.g = o.g, a.b = o.b, a; (function (e, i,
|
|
504
|
-
|
|
502
|
+
O.prototype.getDiffuseSkyIrradianceToRef = function (e, i, r, n, 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, r, n) { var a = t.Clamp(.5 + .5 * r), s = t.Clamp((i - e.planetRadius) / e.atmosphereThickness); n.x = .984375 * a + .0078125, n.y = .9375 * s + .03125; })(l, i, t.Vector3Dot(e, r), w), M(w.x, w.y, 64, 16, this._lutData, b, null); var c = s.diffuseSkyIrradianceIntensity; return a.r = c * (n * b.r + o.r), a.g = c * (n * b.g + o.g), a.b = c * (n * b.b + o.b), a; };
|
|
504
|
+
O.prototype.render = function () {
|
|
505
505
|
var _this = this;
|
|
506
506
|
var e;
|
|
507
507
|
var t = this._effectWrapper;
|
|
508
508
|
if (!this._isDirty || !(null == t ? void 0 : t.isReady()) || !(null === (e = this._renderTarget) || void 0 === e ? void 0 : e.isReady()))
|
|
509
509
|
return !1;
|
|
510
|
-
var
|
|
511
|
-
|
|
512
|
-
var
|
|
513
|
-
|
|
510
|
+
var r = this._effectRenderer;
|
|
511
|
+
r.saveStates();
|
|
512
|
+
var n = this._atmosphere.scene.getEngine();
|
|
513
|
+
n.bindFramebuffer(this.renderTarget.renderTarget, void 0, void 0, void 0, !0), r.setViewport(), r.applyEffectWrapper(t);
|
|
514
514
|
var a = t.effect;
|
|
515
|
-
return
|
|
515
|
+
return r.bindBuffers(a), a.setTexture("transmittanceLut", this._atmosphere.transmittanceLut.renderTarget), a.setTexture("multiScatteringLut", this._atmosphere.multiScatteringLutRenderTarget), this._atmosphere.bindUniformBufferToEffect(a), a.setFloat("depth", 0), r.draw(), r.restoreStates(), n.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
516
|
switch (_a.label) {
|
|
517
517
|
case 0: return [4 /*yield*/, this.readPixelsAsync()];
|
|
518
518
|
case 1:
|
|
@@ -521,7 +521,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
521
521
|
}
|
|
522
522
|
}); }); }), !0;
|
|
523
523
|
};
|
|
524
|
-
|
|
524
|
+
O.prototype.readPixelsAsync = function () { return i(this, void 0, void 0, function () { var e, i_2, r_2, e_25, e_26; return __generator(this, function (_a) {
|
|
525
525
|
switch (_a.label) {
|
|
526
526
|
case 0:
|
|
527
527
|
if (!this._needsReadPixels || this._isDisposed)
|
|
@@ -531,66 +531,66 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
531
531
|
case 1:
|
|
532
532
|
e = _a.sent();
|
|
533
533
|
if (e && !this._isDisposed) {
|
|
534
|
-
i_2 = e,
|
|
534
|
+
i_2 = e, r_2 = this._lutData = new Float32Array(i_2.length);
|
|
535
535
|
if (i_2 instanceof Uint16Array)
|
|
536
536
|
for (e_25 = 0; e_25 < i_2.length; e_25++)
|
|
537
|
-
|
|
537
|
+
r_2[e_25] = t.FromHalfFloat(i_2[e_25]);
|
|
538
538
|
else
|
|
539
539
|
for (e_26 = 0; e_26 < i_2.length; e_26++)
|
|
540
|
-
|
|
540
|
+
r_2[e_26] = i_2[e_26] / 255;
|
|
541
541
|
}
|
|
542
542
|
return [2 /*return*/];
|
|
543
543
|
}
|
|
544
544
|
}); }); };
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
return
|
|
545
|
+
O.prototype.markDirty = function () { this._isDirty = !0; };
|
|
546
|
+
O.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 O;
|
|
548
548
|
}());
|
|
549
|
-
var
|
|
550
|
-
var
|
|
551
|
-
function
|
|
549
|
+
var D = .001953125, N = .00390625, U = { x: Number.NaN, y: Number.NaN }, F = { r: Number.NaN, g: Number.NaN, b: Number.NaN }, V = { x: Number.NaN, y: Number.NaN, z: Number.NaN }, G = { r: Number.NaN, g: Number.NaN, b: Number.NaN, a: Number.NaN };
|
|
550
|
+
var k = /** @class */ (function () {
|
|
551
|
+
function k(e) {
|
|
552
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,
|
|
553
|
+
var i = this._atmosphere.scene, r = i.getEngine(), n = "atmo-transmittance", a = this._renderTarget = new t.RenderTargetTexture(n, { width: 256, height: 64 }, i, { type: t.Constants.TEXTURETYPE_UNSIGNED_BYTE, samplingMode: t.Constants.TEXTURE_BILINEAR_SAMPLINGMODE, generateDepthBuffer: !1, gammaSpace: !1 });
|
|
554
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 =
|
|
556
|
-
this._effectWrapper = new t.EffectWrapper({ engine:
|
|
555
|
+
var s = e.uniformBuffer, o = s.useUbo, l = r.isWebGPU && !t.EffectWrapper.ForceGLSL, c = l ? "atmosphere" : s.name;
|
|
556
|
+
this._effectWrapper = new t.EffectWrapper({ engine: r, name: n, 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 Wt; }), Promise.resolve().then(function () { return ai; })] : [Promise.resolve().then(function () { return Qt; }), Promise.resolve().then(function () { return ci; })]), false)); } }), this._effectRenderer = new t.EffectRenderer(r, { indices: [0, 2, 1], positions: [-1, -1, -1, 3, 3, -1] });
|
|
557
557
|
}
|
|
558
|
-
Object.defineProperty(
|
|
558
|
+
Object.defineProperty(k.prototype, "isDirty", {
|
|
559
559
|
get: function () { return this._isDirty; },
|
|
560
560
|
enumerable: false,
|
|
561
561
|
configurable: true
|
|
562
562
|
});
|
|
563
|
-
Object.defineProperty(
|
|
563
|
+
Object.defineProperty(k.prototype, "renderTarget", {
|
|
564
564
|
get: function () { if (this._isDisposed || null === this._renderTarget)
|
|
565
565
|
throw new Error; return this._renderTarget; },
|
|
566
566
|
enumerable: false,
|
|
567
567
|
configurable: true
|
|
568
568
|
});
|
|
569
|
-
Object.defineProperty(
|
|
569
|
+
Object.defineProperty(k.prototype, "hasLutData", {
|
|
570
570
|
get: function () { return void 0 !== this._lutData[0]; },
|
|
571
571
|
enumerable: false,
|
|
572
572
|
configurable: true
|
|
573
573
|
});
|
|
574
|
-
|
|
575
|
-
var a_1 = t.Vector3Dot(e,
|
|
576
|
-
(function (e, i,
|
|
577
|
-
return void (a.r = a.g = a.b = a.a = 1); (function (e, t, i,
|
|
574
|
+
k.prototype.getTransmittedColorToRef = function (e, i, r, n) { if (void 0 !== this._lutData[0]) {
|
|
575
|
+
var a_1 = t.Vector3Dot(e, r);
|
|
576
|
+
(function (e, i, r, n, a) { if (r > e.atmosphereRadius)
|
|
577
|
+
return void (a.r = a.g = a.b = a.a = 1); (function (e, t, i, r) { var n = t * t, a = Math.sqrt(Math.max(0, n - e.planetRadiusSquared)), s = n * (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, u = (o - l) / Math.max(1e-6, c - l), h = a / Math.max(1e-6, e.horizonDistanceToAtmosphereEdge); r.x = .99609375 * u + D, r.y = .984375 * h + .0078125; })(e, r, n, U), M(U.x, U.y, 256, 64, i, a, null); var s = t.Clamp(t.SmoothStep(1, 0, t.Clamp((U.x - .998046875) / N))); a.r *= s, a.g *= s, a.b *= s, a.a *= s; })(this._atmosphere.physicalProperties, this._lutData, i, a_1, G), n.r = G.r, n.g = G.g, n.b = G.b;
|
|
578
578
|
}
|
|
579
579
|
else
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
580
|
+
n.r = n.g = n.b = 1; return n; };
|
|
581
|
+
k.prototype.updateLightParameters = function (e, t, i) { var r = e.direction; V.x = -r.x, V.y = -r.y, V.z = -r.z, this.getTransmittedColorToRef(V, t, i, F), e.diffuse.copyFromFloats(F.r, F.g, F.b), e.specular.copyFromFloats(F.r, F.g, F.b); };
|
|
582
|
+
k.prototype.render = function () {
|
|
583
583
|
var _this = this;
|
|
584
584
|
var e;
|
|
585
585
|
var t = this._effectWrapper;
|
|
586
586
|
if (!this._isDirty || !(null == t ? void 0 : t.isReady()) || !(null === (e = this._renderTarget) || void 0 === e ? void 0 : e.isReady()))
|
|
587
587
|
return !1;
|
|
588
|
-
var
|
|
589
|
-
|
|
590
|
-
var
|
|
591
|
-
|
|
588
|
+
var r = this._effectRenderer;
|
|
589
|
+
r.saveStates();
|
|
590
|
+
var n = this._atmosphere.scene.getEngine();
|
|
591
|
+
n.bindFramebuffer(this.renderTarget.renderTarget, void 0, void 0, void 0, !0), r.setViewport(), r.applyEffectWrapper(t);
|
|
592
592
|
var a = t.effect;
|
|
593
|
-
return
|
|
593
|
+
return r.bindBuffers(a), this._atmosphere.bindUniformBufferToEffect(a), a.setFloat("depth", 0), r.draw(), r.restoreStates(), n.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
594
|
switch (_a.label) {
|
|
595
595
|
case 0: return [4 /*yield*/, this.readPixelsAsync()];
|
|
596
596
|
case 1:
|
|
@@ -599,7 +599,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
599
599
|
}
|
|
600
600
|
}); }); }), !0;
|
|
601
601
|
};
|
|
602
|
-
|
|
602
|
+
k.prototype.readPixelsAsync = function () { return i(this, void 0, void 0, function () { var e, i_3, r_3, e_27, e_28; return __generator(this, function (_a) {
|
|
603
603
|
switch (_a.label) {
|
|
604
604
|
case 0:
|
|
605
605
|
if (!this._needsReadPixels || this._isDisposed)
|
|
@@ -609,57 +609,57 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
609
609
|
case 1:
|
|
610
610
|
e = _a.sent();
|
|
611
611
|
if (e && !this._isDisposed) {
|
|
612
|
-
i_3 = e,
|
|
612
|
+
i_3 = e, r_3 = this._lutData = new Float32Array(i_3.length);
|
|
613
613
|
if (i_3 instanceof Uint16Array)
|
|
614
614
|
for (e_27 = 0; e_27 < i_3.length; e_27++)
|
|
615
|
-
|
|
615
|
+
r_3[e_27] = t.FromHalfFloat(i_3[e_27]);
|
|
616
616
|
else
|
|
617
617
|
for (e_28 = 0; e_28 < i_3.length; e_28++)
|
|
618
|
-
|
|
618
|
+
r_3[e_28] = i_3[e_28] / 255;
|
|
619
619
|
this.onUpdatedObservable.notifyObservers();
|
|
620
620
|
}
|
|
621
621
|
return [2 /*return*/];
|
|
622
622
|
}
|
|
623
623
|
}); }); };
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
return
|
|
624
|
+
k.prototype.markDirty = function () { this._isDirty = !0; };
|
|
625
|
+
k.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 k;
|
|
627
627
|
}());
|
|
628
628
|
var z = "atmo-pbr";
|
|
629
629
|
var B = 0;
|
|
630
|
-
var
|
|
630
|
+
var W = function (e, i, r, n, a, s, o, l, c) {
|
|
631
631
|
if (l === void 0) { l = !1; }
|
|
632
|
-
var
|
|
633
|
-
var h = null !== (
|
|
634
|
-
return new t.EffectWrapper({ engine: e, name: i, vertexShader: "fullscreenTriangle", fragmentShader:
|
|
635
|
-
},
|
|
632
|
+
var u;
|
|
633
|
+
var h = null !== (u = null == o ? void 0 : o.map(function (e) { return "#define ".concat(e); })) && void 0 !== u ? u : [];
|
|
634
|
+
return new t.EffectWrapper({ engine: e, name: i, vertexShader: "fullscreenTriangle", fragmentShader: r, attributeNames: ["position"], uniformNames: n, uniformBuffers: s, samplerNames: a, defines: h, useShaderStore: !0, shaderLanguage: l ? 1 : 0, extraInitializations: c });
|
|
635
|
+
}, H = function (e, i, r) { var n = i.useUbo, a = e.isWebGPU && !t.EffectWrapper.ForceGLSL, s = a ? "atmosphere" : i.name, o = ["#define POSITION_VEC2"]; return r.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(n ? [] : i.getUniformNames()), false), uniformBuffers: n ? [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 Wt; }), Promise.resolve().then(function () { return mi; })] : [Promise.resolve().then(function () { return Qt; }), Promise.resolve().then(function () { return vi; })]), false)); } }); }, q = function (e, i, r, n) { var a = r.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 }, n), l = new t.RenderTargetTexture(e, i, r, 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, r, n, a, s, o, l, c, u, h) {
|
|
636
636
|
if (s === void 0) { s = 0; }
|
|
637
637
|
if (o === void 0) { o = t.Constants.ALPHA_DISABLE; }
|
|
638
638
|
if (l === void 0) { l = !0; }
|
|
639
|
-
if (
|
|
639
|
+
if (u === void 0) { u = t.Constants.LEQUAL; }
|
|
640
640
|
if (h === void 0) { h = !0; }
|
|
641
|
-
if (null !==
|
|
641
|
+
if (null !== n && !n.isReady() || !(null == r ? void 0 : r.isReady()))
|
|
642
642
|
return;
|
|
643
643
|
i.saveStates();
|
|
644
|
-
var
|
|
644
|
+
var d = e.getDepthWrite();
|
|
645
645
|
void 0 !== c && e.setDepthWrite(c);
|
|
646
646
|
var m = e.getDepthFunction();
|
|
647
|
-
e.setDepthFunction(
|
|
647
|
+
e.setDepthFunction(u);
|
|
648
648
|
var p = e.getAlphaMode();
|
|
649
649
|
e.setAlphaMode(o, !0);
|
|
650
650
|
var f = e.depthCullingState.cull;
|
|
651
|
-
i.setViewport(), i.applyEffectWrapper(
|
|
652
|
-
var g =
|
|
653
|
-
g.setFloat("depth", s), a(i, null ==
|
|
654
|
-
},
|
|
655
|
-
var
|
|
656
|
-
function
|
|
657
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.parentContainerId, i = _c === void 0 ? null : _c, _d = _b._containerId,
|
|
651
|
+
i.setViewport(), i.applyEffectWrapper(r, l), e.depthCullingState.cull = !1;
|
|
652
|
+
var g = r.effect;
|
|
653
|
+
g.setFloat("depth", s), a(i, null == n ? void 0 : n.renderTarget, g, e), e.depthCullingState.cull = f, e.setAlphaMode(p, !0), void 0 !== d && e.setDepthWrite(d), m && e.setDepthFunction(m), i.restoreStates(), h && e.restoreDefaultFramebuffer();
|
|
654
|
+
}, $ = function (e, i, r, n, a) { var s = i.useUbo, o = e.isWebGPU && !t.EffectWrapper.ForceGLSL, l = o ? "atmosphere" : i.name, c = ["POSITION_VEC2", "COMPUTE_WORLD_RAY"]; r && c.push("USE_SKY_VIEW_LUT"), n || c.push("OUTPUT_TO_SRGB"), a && c.push("APPLY_TRANSMITTANCE_BLENDING"); var u = r ? ["skyViewLut"] : ["transmittanceLut", "multiScatteringLut"]; return W(e, "atmo-skyCompositor", "compositeSky", __spreadArray(["depth"], __read(s ? [] : i.getUniformNames()), false), u, s ? [l] : [], c, o, function (e, t) { t.push.apply(t, __spreadArray([], __read(o ? [Promise.resolve().then(function () { return Wt; }), Promise.resolve().then(function () { return Ti; })] : [Promise.resolve().then(function () { return Qt; }), Promise.resolve().then(function () { return Ei; })]), false)); }); }, Y = function (e, i, r, n, a, s, o, l) { var c = i.useUbo, u = e.isWebGPU && !t.EffectWrapper.ForceGLSL, h = u ? "atmosphere" : i.name, d = ["POSITION_VEC2", "COMPUTE_WORLD_RAY"]; r && d.push("USE_AERIAL_PERSPECTIVE_LUT"), n && d.push("USE_SKY_VIEW_LUT"), 1 !== o && d.push("APPLY_AERIAL_PERSPECTIVE_INTENSITY"), a || d.push("OUTPUT_TO_SRGB"), s && d.push("APPLY_TRANSMITTANCE_BLENDING"), 0 !== l && d.push("APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS"); var m = ["transmittanceLut", "multiScatteringLut", "depthTexture"]; return n && m.push("skyViewLut"), r && m.push("aerialPerspectiveLut"), W(e, "atmo-aerialPerspectiveCompositor", "compositeAerialPerspective", __spreadArray(["depth"], __read(c ? [] : i.getUniformNames()), false), m, c ? [h] : [], d, u, function (e, t) { t.push.apply(t, __spreadArray([], __read(u ? [Promise.resolve().then(function () { return Wt; }), Promise.resolve().then(function () { return ki; })] : [Promise.resolve().then(function () { return Qt; }), Promise.resolve().then(function () { return $i; })]), false)); }); }, j = function (e, i, r, n, a, s, o, l) { var c = i.useUbo, u = e.isWebGPU && !t.EffectWrapper.ForceGLSL, h = u ? "atmosphere" : i.name, d = ["POSITION_VEC2", "COMPUTE_WORLD_RAY"]; r && d.push("USE_SKY_VIEW_LUT"), 1 !== s && d.push("APPLY_AERIAL_PERSPECTIVE_INTENSITY"), n || d.push("OUTPUT_TO_SRGB"), l && d.push("HAS_DEPTH_TEXTURE"), a && d.push("APPLY_TRANSMITTANCE_BLENDING"), 0 !== o && d.push("APPLY_AERIAL_PERSPECTIVE_RADIANCE_BIAS"); var m = ["transmittanceLut", "multiScatteringLut"]; return r && m.push("skyViewLut"), l && m.push("depthTexture"), W(e, "atmo-globeAtmosphereCompositor", "compositeGlobeAtmosphere", __spreadArray(["depth"], __read(c ? [] : i.getUniformNames()), false), m, c ? [h] : [], d, u, function (e, t) { t.push.apply(t, __spreadArray([], __read(u ? [Promise.resolve().then(function () { return Wt; }), Promise.resolve().then(function () { return Qi; })] : [Promise.resolve().then(function () { return Qt; }), Promise.resolve().then(function () { return tr; })]), false)); }); }, X = 100, Q = function (e) { return function (t, i) { var r = t.getMesh(), n = i.getMesh(), a = r.isHtmlMesh, s = n.isHtmlMesh; return a ? s && r.absolutePosition.z <= n.absolutePosition.z ? 1 : -1 : s ? 1 : e(t, i); }; };
|
|
655
|
+
var K = /** @class */ (function () {
|
|
656
|
+
function K(e, _a) {
|
|
657
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.parentContainerId, i = _c === void 0 ? null : _c, _d = _b._containerId, r = _d === void 0 ? "css-container" : _d, _f = _b.enableOverlayRender, n = _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
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 =
|
|
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 = r, this._init(e, i, n, a, s, o));
|
|
660
660
|
}
|
|
661
|
-
|
|
662
|
-
|
|
661
|
+
K.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
|
+
K.prototype._init = function (e, t, i, r, n, a) {
|
|
663
663
|
var _this = this;
|
|
664
664
|
var s;
|
|
665
665
|
if ("undefined" == typeof document)
|
|
@@ -677,24 +677,24 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
677
677
|
var c = this._engine.getRenderingCanvasClientRect();
|
|
678
678
|
if (!c)
|
|
679
679
|
throw new Error("Failed to get client rect for rendering canvas");
|
|
680
|
-
var
|
|
680
|
+
var u, h;
|
|
681
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
|
|
683
|
-
|
|
684
|
-
var m =
|
|
682
|
+
var d = function () { var t = e.activeCamera; t && (u = t.onProjectionMatrixChangedObservable.add(function () { _this._onCameraMatrixChanged(t); }), h = t.onViewMatrixChangedObservable.add(function () { _this._onCameraMatrixChanged(t); })); };
|
|
683
|
+
d(), e.onActiveCameraChanged.add(function () { var t, i; u && (null === (t = e.activeCamera) || void 0 === t || t.onProjectionMatrixChangedObservable.remove(u)), h && (null === (i = e.activeCamera) || void 0 === i || i.onViewMatrixChangedObservable.remove(h)), d(); });
|
|
684
|
+
var m = Q(r), p = Q(n), f = Q(a);
|
|
685
685
|
e.setRenderingOrder(0, m, p, f), this._renderObserver = e.onBeforeRenderObservable.add(function () { _this._render(e, e.activeCamera); });
|
|
686
686
|
};
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
687
|
+
K.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 r = document.createElement("div"); r.style.overflow = "hidden"; var n = document.createElement("div"); return n.style.webkitTransformStyle = "preserve-3d", n.style.transformStyle = "preserve-3d", n.style.pointerEvents = "none", r.appendChild(n), i.appendChild(r), { container: i, domElement: r, cameraElement: n }; };
|
|
688
|
+
K.prototype._getSize = function () { return { width: this._width, height: this._height }; };
|
|
689
|
+
K.prototype._setSize = function (e, t) {
|
|
690
690
|
var e_29, _a;
|
|
691
691
|
if (this._width = e, this._height = t, this._heightHalf = this._height / 2, !this._inSceneElements || !this._overlayElements)
|
|
692
692
|
return;
|
|
693
693
|
var i = [this._inSceneElements.domElement, this._overlayElements.domElement, this._inSceneElements.cameraElement, this._overlayElements.cameraElement];
|
|
694
694
|
try {
|
|
695
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
|
|
697
|
-
|
|
696
|
+
var r_4 = i_5_1.value;
|
|
697
|
+
r_4 && (r_4.style.width = "".concat(e, "px"), r_4.style.height = "".concat(t, "px"));
|
|
698
698
|
}
|
|
699
699
|
}
|
|
700
700
|
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
@@ -705,29 +705,29 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
705
705
|
finally { if (e_29) throw e_29.error; }
|
|
706
706
|
}
|
|
707
707
|
};
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
return t.Matrix.Identity(); var
|
|
712
|
-
|
|
713
|
-
return; var a = this._cache.htmlMeshData.get(e); a || (a = { style: "" }, this._cache.htmlMeshData.set(e, a)); var s = e._isCanvasOverlay ? null === (
|
|
714
|
-
|
|
708
|
+
K.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
|
+
K.prototype._getHtmlContentCssMatrix = function (e, t) { var i = e.m, r = t ? -1 : 1; return "matrix3d(".concat(this._epsilon(i[0]), ",").concat(this._epsilon(i[1]), ",").concat(this._epsilon(i[2] * -r), ",").concat(this._epsilon(i[3]), ",").concat(this._epsilon(-i[4]), ",").concat(this._epsilon(-i[5]), ",").concat(this._epsilon(i[6] * r), ",").concat(this._epsilon(-i[7]), ",").concat(this._epsilon(i[8] * -r), ",").concat(this._epsilon(i[9] * -r), ",").concat(this._epsilon(i[10]), ",").concat(this._epsilon(i[11] * r), ",").concat(this._epsilon(i[12] * r), ",").concat(this._epsilon(i[13] * r), ",").concat(this._epsilon(i[14] * r), ",").concat(this._epsilon(i[15]), ")"); };
|
|
710
|
+
K.prototype._getTransformationMatrix = function (e, i) { var r; if (this._cameraWorldMatrix || (this._cameraWorldMatrix = null === (r = e.getScene().activeCamera) || void 0 === r ? void 0 : r.getWorldMatrix()), !this._cameraWorldMatrix)
|
|
711
|
+
return t.Matrix.Identity(); var n = e.getWorldMatrix(); var a = 1, s = 1; e.sourceWidth && e.sourceHeight && (a = e.width / (e.sourceWidth / X), s = e.height / (e.sourceHeight / X)); var o = this._temp.scaleTransform, l = this._temp.rotationTransform, c = this._temp.positionTransform, u = this._temp.objectMatrix; n.decompose(o, l, c), o.x *= a, o.y *= s, t.Matrix.ComposeToRef(o, l, c, u); var h = i ? -1 : 1, d = e.getAbsolutePosition(); return u.setRowFromFloats(3, (-this._cameraWorldMatrix.m[12] + d.x) * X * h, (-this._cameraWorldMatrix.m[13] + d.y) * X * h, (this._cameraWorldMatrix.m[14] - d.z) * X, this._cameraWorldMatrix.m[15] * K.PROJECTION_SCALE_FACTOR * X), u.multiplyAtIndex(3, X), u.multiplyAtIndex(7, X), u.multiplyAtIndex(11, X), u; };
|
|
712
|
+
K.prototype._renderHtmlMesh = function (e, i) { var r, n; 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 === (r = this._overlayElements) || void 0 === r ? void 0 : r.cameraElement : null === (n = this._inSceneElements) || void 0 === n ? void 0 : n.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
|
+
K.prototype._render = function (e, i) {
|
|
715
715
|
var e_30, _a, e_31, _b, e_32, _c, e_33, _d;
|
|
716
|
-
var
|
|
716
|
+
var r, n, a, s;
|
|
717
717
|
var o = !1;
|
|
718
718
|
var l = e.useRightHandedSystem;
|
|
719
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
720
|
var c = e.meshes.filter(function (e) { return e.isHtmlMesh && (o || e.requiresUpdate); });
|
|
721
721
|
if (o = o || c.length > 0, !o)
|
|
722
722
|
return;
|
|
723
|
-
var
|
|
724
|
-
if (this._cache.cameraData.fov !==
|
|
725
|
-
var e_37 = [null === (
|
|
723
|
+
var u = i.getProjectionMatrix().m[5] * this._heightHalf;
|
|
724
|
+
if (this._cache.cameraData.fov !== u) {
|
|
725
|
+
var e_37 = [null === (r = this._overlayElements) || void 0 === r ? void 0 : r.domElement, null === (n = this._inSceneElements) || void 0 === n ? void 0 : n.domElement];
|
|
726
726
|
if (i.mode == t.Camera.PERSPECTIVE_CAMERA)
|
|
727
727
|
try {
|
|
728
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
729
|
var t_4 = e_34_1.value;
|
|
730
|
-
t_4 && (t_4.style.webkitPerspective =
|
|
730
|
+
t_4 && (t_4.style.webkitPerspective = u + "px", t_4.style.perspective = u + "px");
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
catch (e_30_1) { e_30 = { error: e_30_1 }; }
|
|
@@ -751,17 +751,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
751
751
|
}
|
|
752
752
|
finally { if (e_31) throw e_31.error; }
|
|
753
753
|
}
|
|
754
|
-
this._cache.cameraData.fov =
|
|
754
|
+
this._cache.cameraData.fov = u;
|
|
755
755
|
}
|
|
756
756
|
null === i.parent && i.computeWorldMatrix();
|
|
757
757
|
var h = this._temp.cameraWorldMatrix;
|
|
758
758
|
h.copyFrom(i.getWorldMatrix());
|
|
759
|
-
var
|
|
760
|
-
h.getRotationMatrix().transposeToRef(
|
|
759
|
+
var d = this._temp.cameraRotationMatrix;
|
|
760
|
+
h.getRotationMatrix().transposeToRef(d);
|
|
761
761
|
var m = this._temp.cameraWorldMatrixAsArray;
|
|
762
762
|
h.copyToArray(m);
|
|
763
763
|
var p = l ? 1 : -1;
|
|
764
|
-
m[1] =
|
|
764
|
+
m[1] = d.m[1], m[2] = d.m[2] * p, m[4] = d.m[4] * p, m[6] = d.m[6] * p, m[8] = d.m[8] * p, m[9] = d.m[9] * p, t.Matrix.FromArrayToRef(m, 0, h);
|
|
765
765
|
var f = this._getCameraCssMatrix(h);
|
|
766
766
|
if (this._cache.cameraData.style !== f) {
|
|
767
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];
|
|
@@ -794,14 +794,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
794
794
|
finally { if (e_33) throw e_33.error; }
|
|
795
795
|
}
|
|
796
796
|
};
|
|
797
|
-
|
|
798
|
-
|
|
797
|
+
K.prototype._updateBaseScaleFactor = function (e) { var t = this._width, i = this._height; var r = (e.width || 1) / (e.height || 1); r > t / i ? t = i * r : i = t / r, e.setContentSizePx(t, i); };
|
|
798
|
+
K.prototype._updateContainerPositionIfNeeded = function () {
|
|
799
799
|
var e_40, _a;
|
|
800
800
|
var e, i;
|
|
801
|
-
var
|
|
802
|
-
if (!
|
|
801
|
+
var r = this._engine.getRenderingCanvasClientRect();
|
|
802
|
+
if (!r)
|
|
803
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
|
|
804
|
+
var n = window.scrollY, a = window.scrollX, s = r.top + n, o = r.left + a;
|
|
805
805
|
if (this._previousCanvasDocumentPosition.top !== s || this._previousCanvasDocumentPosition.left !== o) {
|
|
806
806
|
this._previousCanvasDocumentPosition.top = s, this._previousCanvasDocumentPosition.left = o;
|
|
807
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];
|
|
@@ -810,8 +810,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
810
810
|
var e_41 = t_7_1.value;
|
|
811
811
|
if (!e_41)
|
|
812
812
|
continue;
|
|
813
|
-
var t_9 = e_41.offsetParent, i_6 = t_9.getBoundingClientRect(),
|
|
814
|
-
e_41.style.top = "".concat(s -
|
|
813
|
+
var t_9 = e_41.offsetParent, i_6 = t_9.getBoundingClientRect(), r_5 = i_6.top + n, l_1 = i_6.left + a, c_2 = this._getAncestorMarginsAndPadding(t_9), u_1 = window.getComputedStyle(document.body), h_1 = parseInt(u_1.marginTop, 10), d_1 = parseInt(u_1.marginLeft, 10);
|
|
814
|
+
e_41.style.top = "".concat(s - r_5 - c_2.marginTop + c_2.paddingTop + h_1, "px"), e_41.style.left = "".concat(o - l_1 - c_2.marginLeft + c_2.paddingLeft + d_1, "px");
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
817
|
catch (e_40_1) { e_40 = { error: e_40_1 }; }
|
|
@@ -823,26 +823,26 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
825
|
};
|
|
826
|
-
|
|
827
|
-
|
|
826
|
+
K.prototype._epsilon = function (e) { return Math.abs(e) < 1e-10 ? 0 : e; };
|
|
827
|
+
K.prototype._getAncestorMarginsAndPadding = function (e) { var t = 0, i = 0, r = 0, n = 0; for (; e && e !== document.body && e !== document.documentElement;) {
|
|
828
828
|
var a_2 = window.getComputedStyle(e);
|
|
829
|
-
t += parseInt(a_2.marginTop, 10), i += parseInt(a_2.marginLeft, 10),
|
|
830
|
-
} return { marginTop: t, marginLeft: i, paddingTop:
|
|
831
|
-
return
|
|
829
|
+
t += parseInt(a_2.marginTop, 10), i += parseInt(a_2.marginLeft, 10), r += parseInt(a_2.paddingTop, 10), n += parseInt(a_2.paddingLeft, 10), e = e.offsetParent;
|
|
830
|
+
} return { marginTop: t, marginLeft: i, paddingTop: r, paddingLeft: n }; };
|
|
831
|
+
return K;
|
|
832
832
|
}());
|
|
833
|
-
|
|
833
|
+
K.PROJECTION_SCALE_FACTOR = 1e-5;
|
|
834
834
|
var J = [];
|
|
835
835
|
var ee = new Map;
|
|
836
836
|
var te = [], ie = null;
|
|
837
|
-
var
|
|
838
|
-
var
|
|
839
|
-
var
|
|
840
|
-
return; var t =
|
|
841
|
-
return; var _a = "touches" in e ? e.touches[0] : e, i = _a.clientX,
|
|
837
|
+
var re = function (e) { ce("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)), e && e !== ie ? ne(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(); }, ne = 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 ue = null, he = 0;
|
|
839
|
+
var de = new WeakMap, me = function (e) { "undefined" != typeof document && (0 === he && (document.addEventListener("pointermove", ge), document.addEventListener("touchstart", ge), ue = null != ue ? ue : e, t.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."), ue.onDisposeObservable.add(pe)), he++); }, pe = function () { document.removeEventListener("pointermove", ge), document.removeEventListener("touchstart", ge), ue = null, t.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."), he = 0; }, fe = function () { "undefined" != typeof document && ue && (he--, he <= 0 && pe()); }, ge = function (e) { if (!ue)
|
|
840
|
+
return; var t = ue.getEngine().getRenderingCanvasClientRect(); if (!t)
|
|
841
|
+
return; var _a = "touches" in e ? e.touches[0] : e, i = _a.clientX, r = _a.clientY, n = i - t.left, a = r - t.top; var s; var o = ue.pick(n, a, function (e) { var t = de.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 || re(ie), l && (s = de.get(l), s.capturePointerEvents())); };
|
|
842
842
|
var ve = /** @class */ (function () {
|
|
843
843
|
function ve(e, i, _a) {
|
|
844
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.captureOnPointerEnter,
|
|
845
|
-
this._captureCallback = e, this._releaseCallback = i, this.name = "PointerEventsCaptureBehavior", this._attachedMesh = null, this._captureOnPointerEnter =
|
|
844
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.captureOnPointerEnter, r = _c === void 0 ? !0 : _c;
|
|
845
|
+
this._captureCallback = e, this._releaseCallback = i, this.name = "PointerEventsCaptureBehavior", this._attachedMesh = null, this._captureOnPointerEnter = r, "undefined" == typeof document && t.Logger.Warn("Creating an instance of PointerEventsCaptureBehavior outside of a browser. The behavior will not work.");
|
|
846
846
|
}
|
|
847
847
|
Object.defineProperty(ve.prototype, "attachedMesh", {
|
|
848
848
|
get: function () { return this._attachedMesh; },
|
|
@@ -861,81 +861,81 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
861
861
|
configurable: true
|
|
862
862
|
});
|
|
863
863
|
ve.prototype.init = function () { };
|
|
864
|
-
ve.prototype.attach = function (e) { this.attachedMesh = e,
|
|
865
|
-
ve.prototype.detach = function () { this.attachedMesh && (
|
|
864
|
+
ve.prototype.attach = function (e) { this.attachedMesh = e, de.set(e, this), this._captureOnPointerEnter && me(e.getScene()); };
|
|
865
|
+
ve.prototype.detach = function () { this.attachedMesh && (de.delete(this.attachedMesh), this._captureOnPointerEnter && fe(), this.attachedMesh = null); };
|
|
866
866
|
ve.prototype.dispose = function () { this.detach(); };
|
|
867
|
-
ve.prototype.releasePointerEvents = function () { this.attachedMesh &&
|
|
867
|
+
ve.prototype.releasePointerEvents = function () { this.attachedMesh && re(this.attachedMesh.uniqueId.toString()); };
|
|
868
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
869
|
return ve;
|
|
870
870
|
}());
|
|
871
|
-
var
|
|
872
|
-
var
|
|
873
|
-
__extends(
|
|
874
|
-
function
|
|
875
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.captureOnPointerEnter,
|
|
871
|
+
var _e = { 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 r = e.firstElementChild; e.style.width = "".concat(t, "px"), e.style.height = "".concat(i, "px"); var _a = __read([r.offsetWidth, r.offsetHeight], 2), n = _a[0], a = _a[1], s = Math.min(t / n, i / a); r.style.transform = "scale(".concat(s, ")"), r.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 r = e.firstElementChild; e.style.width = "".concat(t, "px"), e.style.height = "".concat(i, "px"); var _a = __read([r.offsetWidth, r.offsetHeight], 2), n = _a[0], a = _a[1], s = Math.max(t / n, i / a); r.style.transform = "scale(".concat(s, ")"), r.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 r = e.firstElementChild; e.style.width = "".concat(t, "px"), e.style.height = "".concat(i, "px"); var _a = __read([r.offsetWidth, r.offsetHeight], 2), n = _a[0], a = _a[1]; r.style.transform = "scale(".concat(t / n, ", ").concat(i / a, ")"), r.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 Se = /** @class */ (function (_super) {
|
|
873
|
+
__extends(Se, _super);
|
|
874
|
+
function Se(e, i, _a) {
|
|
875
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.captureOnPointerEnter, r = _c === void 0 ? !0 : _c, _d = _b.isCanvasOverlay, n = _d === void 0 ? !1 : _d, _f = _b.fitStrategy, a = _f === void 0 ? _e.NONE : _f;
|
|
876
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 =
|
|
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 = _e.NONE, "undefined" != typeof document ? (_this._fitStrategy = a, _this._isCanvasOverlay = n, _this._createMask(), _this._element = _this._createElement(), _this.setEnabled(!0), _this._captureOnPointerEnter = r, _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
878
|
return _this;
|
|
879
879
|
}
|
|
880
|
-
Object.defineProperty(
|
|
880
|
+
Object.defineProperty(Se.prototype, "isHtmlMesh", {
|
|
881
881
|
get: function () { return !0; },
|
|
882
882
|
enumerable: false,
|
|
883
883
|
configurable: true
|
|
884
884
|
});
|
|
885
|
-
Object.defineProperty(
|
|
885
|
+
Object.defineProperty(Se.prototype, "sourceWidth", {
|
|
886
886
|
get: function () { return this._sourceWidth; },
|
|
887
887
|
enumerable: false,
|
|
888
888
|
configurable: true
|
|
889
889
|
});
|
|
890
|
-
Object.defineProperty(
|
|
890
|
+
Object.defineProperty(Se.prototype, "sourceHeight", {
|
|
891
891
|
get: function () { return this._sourceHeight; },
|
|
892
892
|
enumerable: false,
|
|
893
893
|
configurable: true
|
|
894
894
|
});
|
|
895
|
-
Object.defineProperty(
|
|
895
|
+
Object.defineProperty(Se.prototype, "width", {
|
|
896
896
|
get: function () { return this._width; },
|
|
897
897
|
enumerable: false,
|
|
898
898
|
configurable: true
|
|
899
899
|
});
|
|
900
|
-
Object.defineProperty(
|
|
900
|
+
Object.defineProperty(Se.prototype, "height", {
|
|
901
901
|
get: function () { return this._height; },
|
|
902
902
|
enumerable: false,
|
|
903
903
|
configurable: true
|
|
904
904
|
});
|
|
905
|
-
Object.defineProperty(
|
|
905
|
+
Object.defineProperty(Se.prototype, "element", {
|
|
906
906
|
get: function () { return this._element; },
|
|
907
907
|
enumerable: false,
|
|
908
908
|
configurable: true
|
|
909
909
|
});
|
|
910
|
-
Object.defineProperty(
|
|
910
|
+
Object.defineProperty(Se.prototype, "requiresUpdate", {
|
|
911
911
|
get: function () { return this._requiresUpdate; },
|
|
912
912
|
enumerable: false,
|
|
913
913
|
configurable: true
|
|
914
914
|
});
|
|
915
|
-
Object.defineProperty(
|
|
915
|
+
Object.defineProperty(Se.prototype, "captureOnPointerEnter", {
|
|
916
916
|
set: function (e) { this._captureOnPointerEnter = e, this._pointerEventCaptureBehavior && (this._pointerEventCaptureBehavior.captureOnPointerEnter = e); },
|
|
917
917
|
enumerable: false,
|
|
918
918
|
configurable: true
|
|
919
919
|
});
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
920
|
+
Se.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
|
+
Se.prototype._markAsUpdated = function () { this._requiresUpdate = !1; };
|
|
922
|
+
Se.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
|
+
Se.prototype.setEnabled = function (e) { this._enabled = e, e && !this._ready || this._doSetEnabled(e); };
|
|
924
|
+
Se.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
|
+
Se.prototype._setAsReady = function (e) { this._ready = e, e ? this._doSetEnabled(this._enabled) : this._doSetEnabled(!1); };
|
|
926
|
+
Se.prototype._doSetEnabled = function (e) {
|
|
927
927
|
var _this = this;
|
|
928
928
|
var t;
|
|
929
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
930
|
};
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
931
|
+
Se.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, r = t.Matrix.Scaling(e, i, 1); this.bakeTransformIntoVertices(r), this._inverseScaleMatrix = new t.Matrix, r.invertToRef(this._inverseScaleMatrix); };
|
|
932
|
+
Se.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
|
+
Se.prototype._setElementzIndex = function (e) { this._element && (this._element.style.zIndex = "".concat(e)); };
|
|
934
|
+
Se.prototype.capturePointerEvents = function () { this._element && (this._element.style.pointerEvents = "auto", document.getElementsByTagName("body")[0].style.pointerEvents = "none"); };
|
|
935
|
+
Se.prototype.releasePointerEvents = function () { this._element && (document.getElementsByTagName("body")[0].style.pointerEvents = "auto", this._element.style.pointerEvents = "none"); };
|
|
936
|
+
Se.prototype._createElement = function () { if ("undefined" == typeof document)
|
|
937
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
|
|
938
|
+
return Se;
|
|
939
939
|
}(t.Mesh));
|
|
940
940
|
var ye;
|
|
941
941
|
!function (e) { e[e.SPACE = 32] = "SPACE", e[e.TOFU = 65532] = "TOFU"; }(ye || (ye = {}));
|
|
@@ -943,8 +943,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
943
943
|
var Ae = /** @class */ (function () {
|
|
944
944
|
function Ae(e, t, i) {
|
|
945
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),
|
|
947
|
-
this.paragraph =
|
|
946
|
+
var _a = this.options.customLayoutEngine ? this.options.customLayoutEngine(e, this.options) : this._computeMetrics(e), r = _a.paragraph, n = _a.lines, a = _a.glyphs, s = _a.width, o = _a.height;
|
|
947
|
+
this.paragraph = r, this.lines = n, this.glyphs = a, this.width = s, this.height = o;
|
|
948
948
|
}
|
|
949
949
|
Object.defineProperty(Ae.prototype, "lineHeight", {
|
|
950
950
|
get: function () { return this.fontAsset._font.common.lineHeight * this.options.lineHeight; },
|
|
@@ -954,11 +954,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
954
954
|
Ae.prototype._computeMetrics = function (e) {
|
|
955
955
|
var e_42, _a;
|
|
956
956
|
var _this = this;
|
|
957
|
-
var t = this._collapse(e), i = this._breakLines(t).map(function (e) { return e.trim(); }),
|
|
957
|
+
var t = this._collapse(e), i = this._breakLines(t).map(function (e) { return e.trim(); }), r = [];
|
|
958
958
|
try {
|
|
959
959
|
for (var i_7 = __values(i), i_7_1 = i_7.next(); !i_7_1.done; i_7_1 = i_7.next()) {
|
|
960
960
|
var e_43 = i_7_1.value;
|
|
961
|
-
|
|
961
|
+
r.push.apply(r, __spreadArray([], __read(this._wrap(e_43, r.length)), false));
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
964
|
catch (e_42_1) { e_42 = { error: e_42_1 }; }
|
|
@@ -968,18 +968,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
968
968
|
}
|
|
969
969
|
finally { if (e_42) throw e_42.error; }
|
|
970
970
|
}
|
|
971
|
-
var
|
|
972
|
-
("left" !== this.options.textAlign || this.options.translate) &&
|
|
971
|
+
var n = Math.max.apply(Math, __spreadArray([], __read(r.map(function (e) { return e.width; })), false)), a = this.lineHeight * r.length;
|
|
972
|
+
("left" !== this.options.textAlign || this.options.translate) && r.forEach(function (e) {
|
|
973
973
|
var e_44, _a;
|
|
974
974
|
var t = (function () { switch (_this.options.textAlign) {
|
|
975
|
-
case "right": return
|
|
976
|
-
case "center": return (
|
|
975
|
+
case "right": return n - e.width;
|
|
976
|
+
case "center": return (n - e.width) / 2;
|
|
977
977
|
default: return 0;
|
|
978
|
-
} })(), i = _this.options.translate ? _this.options.translate.x *
|
|
978
|
+
} })(), i = _this.options.translate ? _this.options.translate.x * n : 0, r = _this.options.translate ? _this.options.translate.y * a : 0;
|
|
979
979
|
try {
|
|
980
980
|
for (var _b = __values(e.glyphs), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
981
|
-
var
|
|
982
|
-
|
|
981
|
+
var n_1 = _c.value;
|
|
982
|
+
n_1.x += t, n_1.x += i, n_1.y += r;
|
|
983
983
|
}
|
|
984
984
|
}
|
|
985
985
|
catch (e_44_1) { e_44 = { error: e_44_1 }; }
|
|
@@ -990,71 +990,71 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
990
990
|
finally { if (e_44) throw e_44.error; }
|
|
991
991
|
}
|
|
992
992
|
});
|
|
993
|
-
var s =
|
|
994
|
-
return { paragraph: i.join("\n"), lines:
|
|
993
|
+
var s = r.flatMap(function (e) { return e.glyphs; });
|
|
994
|
+
return { paragraph: i.join("\n"), lines: r, glyphs: s, width: n, height: a };
|
|
995
995
|
};
|
|
996
996
|
Ae.prototype._breakLines = function (e) { return e.split("\n"); };
|
|
997
997
|
Ae.prototype._collapse = function (e) { return e.replace(/\t/g, " ".repeat(this.options.tabSize)).replace(/ +/g, " "); };
|
|
998
998
|
Ae.prototype._wrap = function (e, t) {
|
|
999
999
|
if (t === void 0) { t = 0; }
|
|
1000
1000
|
var i = new Array;
|
|
1001
|
-
var
|
|
1002
|
-
var
|
|
1001
|
+
var r, n = t, a = new Array, s = 0, o = 0, l = 0, c = l;
|
|
1002
|
+
var u = function () { i.push({ text: e.slice(l, c), glyphs: a, start: l, end: c, width: o }); };
|
|
1003
1003
|
for (; c < e.length;) {
|
|
1004
|
-
var t_10 = c, i_8 = e.charCodeAt(t_10), h_2 = this.fontAsset._getChar(i_8),
|
|
1005
|
-
s +=
|
|
1006
|
-
var m_1 = s +
|
|
1007
|
-
g_1 && (
|
|
1008
|
-
var v_1 = s,
|
|
1009
|
-
a.push({ char: h_2, line:
|
|
1004
|
+
var t_10 = c, i_8 = e.charCodeAt(t_10), h_2 = this.fontAsset._getChar(i_8), d_2 = h_2.width;
|
|
1005
|
+
s += r ? this.fontAsset._getKerning(r.id, h_2.id) : 0;
|
|
1006
|
+
var m_1 = s + d_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 && (u(), n++, r = void 0, s = 0, o = 0, l = c, c = l + 1, a = []);
|
|
1008
|
+
var v_1 = s, _1 = n * this.lineHeight;
|
|
1009
|
+
a.push({ char: h_2, line: n, position: a.length, x: v_1, y: _1 }), g_1 ? s = p_1 : (r = h_2, s = f_1, o = m_1, c++);
|
|
1010
1010
|
}
|
|
1011
|
-
return a.length > 0 &&
|
|
1011
|
+
return a.length > 0 && u(), i;
|
|
1012
1012
|
};
|
|
1013
1013
|
return Ae;
|
|
1014
1014
|
}());
|
|
1015
|
-
var
|
|
1016
|
-
function
|
|
1015
|
+
var Le = /** @class */ (function () {
|
|
1016
|
+
function Le(e, i, r) {
|
|
1017
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 =
|
|
1019
|
-
var
|
|
1020
|
-
this._spriteBuffer = new t.Buffer(e,
|
|
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 = r, this._baseLine = r._font.common.lineHeight * r.scale, this._useVAO = e.getCaps().vertexArrayObject && !e.disableVertexArrayObjects;
|
|
1019
|
+
var n = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
|
|
1020
|
+
this._spriteBuffer = new t.Buffer(e, n, !1, 2), this._vertexBuffers.offsets = this._spriteBuffer.createVertexBuffer("offsets", 0, 2), this._resizeBuffers(128);
|
|
1021
1021
|
}
|
|
1022
|
-
Object.defineProperty(
|
|
1022
|
+
Object.defineProperty(Le.prototype, "parent", {
|
|
1023
1023
|
get: function () { return this._parent; },
|
|
1024
1024
|
set: function (e) { this._parent = e; },
|
|
1025
1025
|
enumerable: false,
|
|
1026
1026
|
configurable: true
|
|
1027
1027
|
});
|
|
1028
|
-
Object.defineProperty(
|
|
1028
|
+
Object.defineProperty(Le.prototype, "transformMatrix", {
|
|
1029
1029
|
get: function () { return this._transformMatrix; },
|
|
1030
1030
|
set: function (e) { this._transformMatrix = e; },
|
|
1031
1031
|
enumerable: false,
|
|
1032
1032
|
configurable: true
|
|
1033
1033
|
});
|
|
1034
|
-
Object.defineProperty(
|
|
1034
|
+
Object.defineProperty(Le.prototype, "characterCount", {
|
|
1035
1035
|
get: function () { return this._charMatrices.length / 16; },
|
|
1036
1036
|
enumerable: false,
|
|
1037
1037
|
configurable: true
|
|
1038
1038
|
});
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1039
|
+
Le.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
|
+
Le.prototype._setShaders = function (e, i) { var r; null === (r = this._drawWrapperBase) || void 0 === r || r.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
|
+
Le.prototype.addParagraph = function (e, i, r) {
|
|
1042
1042
|
var _this = this;
|
|
1043
|
-
var
|
|
1044
|
-
var c =
|
|
1043
|
+
var n = new Ae(e, this._font, i), a = this._font.scale, s = this._font._font.common.scaleW, o = this._font._font.common.scaleH, l = n.glyphs.filter(function (e) { return e.char.page >= 0; });
|
|
1044
|
+
var c = r;
|
|
1045
1045
|
if (!c) {
|
|
1046
|
-
var e_45 =
|
|
1046
|
+
var e_45 = n.lineHeight * a, i_9 = n.lines.length * e_45 / 2;
|
|
1047
1047
|
t.TranslationMatrixToRef(0, this._baseLine - i_9, 0, this._lineMatrix), c = this._lineMatrix;
|
|
1048
1048
|
}
|
|
1049
1049
|
t.ScalingMatrixToRef(a, a, 1, this._fontScaleMatrix), t.TranslationMatrixToRef(.5, -.5, 0, this._offsetMatrix);
|
|
1050
|
-
var
|
|
1051
|
-
l.forEach(function (e, i) { _this._charUvs[
|
|
1050
|
+
var u = this._charUvs.length, h = this._charMatrices.length;
|
|
1051
|
+
l.forEach(function (e, i) { _this._charUvs[u + 4 * i + 0] = e.char.x / s, _this._charUvs[u + 4 * i + 1] = e.char.y / o, _this._charUvs[u + 4 * i + 2] = e.char.width / s, _this._charUvs[u + 4 * i + 3] = e.char.height / o; var r = e.x + e.char.xoffset, n = 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(r * a, n * 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 -= n.lineHeight * a * n.lines.length;
|
|
1052
1052
|
};
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
return; var a = this._engine; a.setState(!1), a.enableEffect(
|
|
1056
|
-
|
|
1057
|
-
|
|
1053
|
+
Le.prototype.clearParagraphs = function () { this._charMatrices.length = 0, this._charUvs.length = 0, this._baseLine = 0, this._isDirty = !0; };
|
|
1054
|
+
Le.prototype.render = function (e, i) { var r = this._drawWrapperBase, n = r.effect; if (!n.isReady())
|
|
1055
|
+
return; var a = this._engine; a.setState(!1), a.enableEffect(r), this.ignoreDepthBuffer && a.setDepthBuffer(!1), this._parent ? t.CopyMatrixToRef(this._parent.getWorldMatrix(), this._parentWorldMatrix) : t.IdentityMatrixToRef(this._parentWorldMatrix), n.setInt("mode", this.isBillboard ? this.isBillboardScreenProjected ? 2 : 1 : 0), n.setMatrix("parentWorld", this._parentWorldMatrix), n.setMatrix("view", e), n.setMatrix("projection", i), n.setMatrix("transform", this.transformMatrix), n.setTexture("fontAtlas", this._font.textures[0]), n.setDirectColor4("uColor", this.color), n.setDirectColor4("uStrokeColor", this.strokeColor), n.setFloat("thickness", .9 * this.thicknessControl), n.setFloat("uStrokeInsetWidth", this.strokeInsetWidth), n.setFloat("uStrokeOutsetWidth", this.strokeOutsetWidth); var s = this.writeToDepthBuffer && !this.ignoreDepthBuffer; n.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, n)), a.bindVertexArrayObject(this._vertexArrayObject, null)) : a.bindBuffers(this._vertexBuffers, null, n); var l = a, c = s && l.currentSampleCount > 1, u = 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(u), a.unbindInstanceAttributes(), a.setAlphaMode(t.Constants.ALPHA_DISABLE), this.ignoreDepthBuffer && a.setDepthBuffer(!0); };
|
|
1056
|
+
Le.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
|
+
Le.CreateTextRendererAsync = function (e, t) { return i(this, void 0, void 0, function () { var e_46, e_47, i, r, n, _a, a; return __generator(this, function (_b) {
|
|
1058
1058
|
switch (_b.label) {
|
|
1059
1059
|
case 0:
|
|
1060
1060
|
if (!t.isWebGPU) return [3 /*break*/, 2];
|
|
@@ -1071,310 +1071,729 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1071
1071
|
case 4:
|
|
1072
1072
|
if (!t.getCaps().instancedArrays || !t._features.supportSpriteInstancing)
|
|
1073
1073
|
throw new Error("Instanced arrays are required for MSDF text rendering.");
|
|
1074
|
-
|
|
1074
|
+
n = 0;
|
|
1075
1075
|
if (!t.isWebGPU) return [3 /*break*/, 7];
|
|
1076
|
-
|
|
1076
|
+
n = 1;
|
|
1077
1077
|
return [4 /*yield*/, Promise.resolve().then(function () { return Ne; })];
|
|
1078
1078
|
case 5:
|
|
1079
1079
|
i = (_b.sent()).msdfVertexShaderWGSL.shader;
|
|
1080
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return
|
|
1080
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return Ge; })];
|
|
1081
1081
|
case 6:
|
|
1082
|
-
_a = (
|
|
1082
|
+
_a = (r = (_b.sent()).msdfPixelShaderWGSL.shader);
|
|
1083
1083
|
return [3 /*break*/, 10];
|
|
1084
1084
|
case 7: return [4 /*yield*/, Promise.resolve().then(function () { return Ce; })];
|
|
1085
1085
|
case 8:
|
|
1086
1086
|
i = (_b.sent()).msdfVertexShader.shader;
|
|
1087
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return
|
|
1087
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return we; })];
|
|
1088
1088
|
case 9:
|
|
1089
|
-
_a = (
|
|
1089
|
+
_a = (r = (_b.sent()).msdfPixelShader.shader);
|
|
1090
1090
|
_b.label = 10;
|
|
1091
1091
|
case 10:
|
|
1092
1092
|
_a;
|
|
1093
|
-
a = new
|
|
1094
|
-
return [2 /*return*/, (a._setShaders(i,
|
|
1093
|
+
a = new Le(t, n, e);
|
|
1094
|
+
return [2 /*return*/, (a._setShaders(i, r), a)];
|
|
1095
1095
|
}
|
|
1096
1096
|
}); }); };
|
|
1097
|
-
return
|
|
1097
|
+
return Le;
|
|
1098
1098
|
}());
|
|
1099
|
-
var
|
|
1100
|
-
t.ShaderStore.ShadersStore[
|
|
1101
|
-
var
|
|
1102
|
-
var Ce = { __proto__: null, msdfVertexShader:
|
|
1103
|
-
var xe = "msdfPixelShader",
|
|
1104
|
-
t.ShaderStore.ShadersStore[xe] || (t.ShaderStore.ShadersStore[xe] =
|
|
1105
|
-
var
|
|
1106
|
-
var
|
|
1107
|
-
var be = "msdfVertexShader",
|
|
1108
|
-
t.ShaderStore.ShadersStoreWGSL[be] || (t.ShaderStore.ShadersStoreWGSL[be] =
|
|
1109
|
-
var
|
|
1110
|
-
var Ne = { __proto__: null, msdfVertexShaderWGSL:
|
|
1111
|
-
var
|
|
1112
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
1113
|
-
var
|
|
1114
|
-
var
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1099
|
+
var Pe = "msdfVertexShader", Ee = "#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[Pe] || (t.ShaderStore.ShadersStore[Pe] = Ee);
|
|
1101
|
+
var Re = { name: Pe, shader: Ee };
|
|
1102
|
+
var Ce = { __proto__: null, msdfVertexShader: Re };
|
|
1103
|
+
var xe = "msdfPixelShader", Me = "#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] = Me);
|
|
1105
|
+
var Ie = { name: xe, shader: Me };
|
|
1106
|
+
var we = { __proto__: null, msdfPixelShader: Ie };
|
|
1107
|
+
var be = "msdfVertexShader", Oe = "#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] = Oe);
|
|
1109
|
+
var De = { name: be, shader: Oe };
|
|
1110
|
+
var Ne = { __proto__: null, msdfVertexShaderWGSL: De };
|
|
1111
|
+
var Ue = "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[Ue] || (t.ShaderStore.ShadersStoreWGSL[Ue] = Fe);
|
|
1113
|
+
var Ve = { name: Ue, shader: Fe };
|
|
1114
|
+
var Ge = { __proto__: null, msdfPixelShaderWGSL: Ve };
|
|
1115
|
+
var ke = ["multiTextureCompositeAlphaBlend", "multiTextureCompositeAlphaMax", "multiTextureCompositeAdd", "multiTextureCompositeMultiply", "multiTextureCompositeSubtract", "multiTextureCompositeScreen"], ze = ["ALPHA_BLEND", "ALPHA_MAX", "ADD", "MULTIPLY", "SUBTRACT", "SCREEN"];
|
|
1116
|
+
var Be = !1;
|
|
1117
|
+
function We() { Be || (Be = !0, t.RegisterEnginesExtensionsEngineTexture2DArrayImageSource(), t.RegisterEnginesWebGPUExtensionsEngineTexture2DArrayImageSource()); }
|
|
1118
|
+
var He = /** @class */ (function (_super) {
|
|
1119
|
+
__extends(He, _super);
|
|
1120
|
+
function He(r, n, a, s) {
|
|
1121
|
+
var _this = this;
|
|
1122
|
+
var o, l, c, u, h, d, m, p, f, g, v, _, S;
|
|
1123
|
+
_this = _super.call(this, a) || this, _this.onLoadObservable = new t.Observable, _this._pollTimer = null, _this._pollInFlight = !1, _this._disposed = !1, _this._mipSuppressCount = 0, We();
|
|
1124
|
+
var y = !1, T = !1;
|
|
1125
|
+
try {
|
|
1126
|
+
var A_1 = a.getEngine();
|
|
1127
|
+
if (!A_1 || !A_1.isWebGPU && A_1.webGLVersion < 2)
|
|
1128
|
+
throw new Error("MultiTexture requires WebGL2 (TEXTURE_2D_ARRAY + sampler2DArray) or WebGPU. This context is WebGL1 or unavailable. Create the engine with WebGL2 enabled, e.g. new Engine(canvas, { webglVersion: 2 }).");
|
|
1129
|
+
if (!Number.isInteger(s.width) || s.width <= 0 || !Number.isInteger(s.height) || s.height <= 0)
|
|
1130
|
+
throw new Error("MultiTexture: width and height must be positive integers.");
|
|
1131
|
+
var L_1 = A_1.getCaps().texture2DArrayMaxLayerCount;
|
|
1132
|
+
if (void 0 !== s.maxLayers && (!Number.isInteger(s.maxLayers) || s.maxLayers < 1))
|
|
1133
|
+
throw new Error("MultiTexture: maxLayers must be a positive integer (got ".concat(s.maxLayers, ")."));
|
|
1134
|
+
if (void 0 === s.maxLayers && 0 === n.length)
|
|
1135
|
+
throw new Error("MultiTexture: urls is empty; pass options.maxLayers (positive integer, <= device limit ".concat(L_1, ") to define the array depth."));
|
|
1136
|
+
if (void 0 !== s.maxLayers && s.maxLayers < n.length)
|
|
1137
|
+
throw new Error("MultiTexture: maxLayers (".concat(s.maxLayers, ") must be >= urls.length (").concat(n.length, ")."));
|
|
1138
|
+
var P_1 = null !== (o = s.blendMode) && void 0 !== o ? o : e.MultiBlendMode.ALPHA_BLEND, E_1 = null !== (l = s.maxLayers) && void 0 !== l ? l : n.length;
|
|
1139
|
+
if (E_1 > L_1)
|
|
1140
|
+
throw new Error("MultiTexture: array depth ".concat(E_1, " exceeds the device limit texture2DArrayMaxLayerCount (").concat(L_1, "). Pass a smaller maxLayers (or fewer urls) or use a device with a higher limit."));
|
|
1141
|
+
var R_1 = Math.max(1, Math.round(s.width * (null !== (c = s.rttScale) && void 0 !== c ? c : 1))), C_1 = Math.max(1, Math.round(s.height * (null !== (u = s.rttScale) && void 0 !== u ? u : 1))), x_1 = null !== (h = s.generateMipMaps) && void 0 !== h && h, M_1 = A_1.isWebGPU ? 1 : 0, I_1 = { shaderLanguage: M_1, extraInitializationsAsync: function () { return i(_this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
|
|
1142
|
+
switch (_b.label) {
|
|
1143
|
+
case 0:
|
|
1144
|
+
if (!(1 === M_1)) return [3 /*break*/, 2];
|
|
1145
|
+
return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return dr; }), Promise.resolve().then(function () { return fr; }), Promise.resolve().then(function () { return _r; }), Promise.resolve().then(function () { return Tr; }), Promise.resolve().then(function () { return Pr; }), Promise.resolve().then(function () { return Cr; })])];
|
|
1146
|
+
case 1:
|
|
1147
|
+
_a = _b.sent();
|
|
1148
|
+
return [3 /*break*/, 4];
|
|
1149
|
+
case 2: return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return Ir; }), Promise.resolve().then(function () { return Or; }), Promise.resolve().then(function () { return Ur; }), Promise.resolve().then(function () { return Gr; }), Promise.resolve().then(function () { return Br; }), Promise.resolve().then(function () { return qr; })])];
|
|
1150
|
+
case 3:
|
|
1151
|
+
_a = _b.sent();
|
|
1152
|
+
_b.label = 4;
|
|
1153
|
+
case 4:
|
|
1154
|
+
_a;
|
|
1155
|
+
return [2 /*return*/];
|
|
1156
|
+
}
|
|
1157
|
+
}); }); } };
|
|
1158
|
+
_this._compositeInternal = new t.ProceduralTexture(r, { width: R_1, height: C_1 }, ke[P_1], a, Object.assign(Object.assign({}, I_1), { skipSceneRegistration: !0 }), !1, !1, t.Constants.TEXTURETYPE_UNSIGNED_BYTE), y = !0, _this.name = r, _this.isRenderTarget = !0, _this._mtOptions = Object.assign(Object.assign({}, s), { maxLayers: E_1, blendMode: P_1, generateMipMaps: x_1, samplingMode: null !== (d = s.samplingMode) && void 0 !== d ? d : t.Texture.TRILINEAR_SAMPLINGMODE, premultiplyAlpha: null !== (m = s.premultiplyAlpha) && void 0 !== m && m, fit: null !== (p = s.fit) && void 0 !== p ? p : "resize", rttScale: null !== (f = s.rttScale) && void 0 !== f ? f : 1, watch: null !== (g = s.watch) && void 0 !== g && g, pollInterval: null !== (v = s.pollInterval) && void 0 !== v ? v : 2e3 }), _this._maxLayers = E_1, _this._deviceMaxLayerCap = L_1, _this._blendMode = P_1, _this._arrayTexture = new t.RawTexture2DArray(null, s.width, s.height, E_1, t.Constants.TEXTUREFORMAT_RGBA, a, x_1, !1, null !== (_ = s.samplingMode) && void 0 !== _ ? _ : t.Texture.TRILINEAR_SAMPLINGMODE, t.Constants.TEXTURETYPE_UNSIGNED_BYTE), _this._arrayTexture.name = "".concat(_this.name, "_2DArray"), T = !0, _this._layers = n.map(function (e) { return _this._createLayerEntry(e); }), _this._layerCount = _this._layers.length, _this.urls = n.slice(), _this.pixels = new Array(_this._layerCount).fill(null), _this.composite.defines = _this._buildDefines(ze[P_1]), _this.composite.setTexture("uLayers", _this._arrayTexture), _this.composite.setInt("uLayerCount", _this._layerCount);
|
|
1159
|
+
var w_1 = null;
|
|
1160
|
+
if ("undefined" != typeof OffscreenCanvas ? w_1 = new OffscreenCanvas(s.width, s.height) : "undefined" != typeof document && (w_1 = document.createElement("canvas"), w_1.width = s.width, w_1.height = s.height), !w_1)
|
|
1161
|
+
throw new Error("MultiTexture: no 2D canvas surface available (requires DOM or OffscreenCanvas).");
|
|
1162
|
+
_this._canvas = w_1, _this._ctx = null !== (S = w_1.getContext("2d", { willReadFrequently: !0 })) && void 0 !== S ? S : null, _this._initialize();
|
|
1163
|
+
}
|
|
1164
|
+
catch (e) {
|
|
1165
|
+
if (y)
|
|
1166
|
+
try {
|
|
1167
|
+
_this._compositeInternal.dispose();
|
|
1168
|
+
}
|
|
1169
|
+
catch (e) { }
|
|
1170
|
+
if (T)
|
|
1171
|
+
try {
|
|
1172
|
+
_this._arrayTexture.dispose();
|
|
1173
|
+
}
|
|
1174
|
+
catch (e) { }
|
|
1175
|
+
if (a.textures) {
|
|
1176
|
+
var e_48 = a.textures.indexOf(_this);
|
|
1177
|
+
e_48 >= 0 && (a.textures.splice(e_48, 1), a.onTextureRemovedObservable.notifyObservers(_this));
|
|
1178
|
+
}
|
|
1179
|
+
throw e;
|
|
1180
|
+
}
|
|
1181
|
+
return _this;
|
|
1182
|
+
}
|
|
1183
|
+
Object.defineProperty(He.prototype, "composite", {
|
|
1184
|
+
get: function () { return this._compositeInternal; },
|
|
1185
|
+
enumerable: false,
|
|
1186
|
+
configurable: true
|
|
1187
|
+
});
|
|
1188
|
+
Object.defineProperty(He.prototype, "layerCount", {
|
|
1189
|
+
get: function () { return this._layerCount; },
|
|
1190
|
+
enumerable: false,
|
|
1191
|
+
configurable: true
|
|
1192
|
+
});
|
|
1193
|
+
Object.defineProperty(He.prototype, "arrayTexture", {
|
|
1194
|
+
get: function () { return this._arrayTexture; },
|
|
1195
|
+
enumerable: false,
|
|
1196
|
+
configurable: true
|
|
1197
|
+
});
|
|
1198
|
+
He.prototype.getInternalTexture = function () { return this.composite.getInternalTexture(); };
|
|
1199
|
+
He.prototype.isReady = function () { return this.composite.isReady(); };
|
|
1200
|
+
He.prototype._renderComposite = function () {
|
|
1201
|
+
var _this = this;
|
|
1202
|
+
this.composite.isReady(), this.composite.executeWhenReady(function () { _this._disposed || _this.composite.render(); });
|
|
1203
|
+
};
|
|
1204
|
+
He.prototype.getSize = function () { return this.composite.getSize(); };
|
|
1205
|
+
He.prototype.getBaseSize = function () { return this.composite.getBaseSize(); };
|
|
1206
|
+
Object.defineProperty(He.prototype, "samplingMode", {
|
|
1207
|
+
get: function () { return this.composite.samplingMode; },
|
|
1208
|
+
enumerable: false,
|
|
1209
|
+
configurable: true
|
|
1210
|
+
});
|
|
1211
|
+
He.prototype.updateSamplingMode = function (e, t) {
|
|
1212
|
+
if (t === void 0) { t = !1; }
|
|
1213
|
+
this.composite.updateSamplingMode(e, t);
|
|
1214
|
+
};
|
|
1215
|
+
He.prototype.readPixels = function (e, t, i, r, n, a, s, o, l) { return this.composite.readPixels(e, t, i, r, n, a, s, o, l); };
|
|
1216
|
+
He.prototype._readPixelsSync = function (e, t, i, r, n) { return this.composite._readPixelsSync(e, t, i, r, n); };
|
|
1217
|
+
Object.defineProperty(He.prototype, "textureFormat", {
|
|
1218
|
+
get: function () { return this.composite.textureFormat; },
|
|
1219
|
+
enumerable: false,
|
|
1220
|
+
configurable: true
|
|
1221
|
+
});
|
|
1222
|
+
Object.defineProperty(He.prototype, "textureType", {
|
|
1223
|
+
get: function () { return this.composite.textureType; },
|
|
1224
|
+
enumerable: false,
|
|
1225
|
+
configurable: true
|
|
1226
|
+
});
|
|
1227
|
+
Object.defineProperty(He.prototype, "blendMode", {
|
|
1228
|
+
get: function () { return this._blendMode; },
|
|
1229
|
+
set: function (e) { e !== this._blendMode && (this._blendMode = e, this.composite.setFragment(ke[e]), this.composite.defines = this._buildDefines(ze[e]), this._renderComposite()); },
|
|
1230
|
+
enumerable: false,
|
|
1231
|
+
configurable: true
|
|
1232
|
+
});
|
|
1233
|
+
He.prototype.updateLayerAsync = function (e, t) { return i(this, void 0, void 0, function () { var i; return __generator(this, function (_a) {
|
|
1234
|
+
switch (_a.label) {
|
|
1235
|
+
case 0:
|
|
1236
|
+
if (!Number.isInteger(e) || e < 0 || e >= this._layerCount)
|
|
1237
|
+
throw new RangeError("MultiTexture: layer index ".concat(e, " out of range [0, ").concat(this._layerCount, ")."));
|
|
1238
|
+
i = this._layers[e];
|
|
1239
|
+
i.url = t, i.etag = null, i.lastModified = null, i.warnedLoadFailure = !1, this.urls[e] = t;
|
|
1240
|
+
return [4 /*yield*/, this._loadEntryOrThrow(i)];
|
|
1241
|
+
case 1:
|
|
1242
|
+
_a.sent();
|
|
1243
|
+
return [2 /*return*/];
|
|
1244
|
+
}
|
|
1245
|
+
}); }); };
|
|
1246
|
+
He.prototype.addLayerAsync = function (e) { return i(this, void 0, void 0, function () { var t, i; return __generator(this, function (_a) {
|
|
1247
|
+
switch (_a.label) {
|
|
1248
|
+
case 0:
|
|
1249
|
+
t = this._layerCount;
|
|
1250
|
+
this._suppressArrayMips();
|
|
1251
|
+
try {
|
|
1252
|
+
t >= this._maxLayers && this._growArray(), i = this._pushLayerEntry(e), this.composite.setInt("uLayerCount", this._layerCount);
|
|
1253
|
+
}
|
|
1254
|
+
catch (e) {
|
|
1255
|
+
throw this._generateArrayMips(), this._reportError(e), e;
|
|
1256
|
+
}
|
|
1257
|
+
_a.label = 1;
|
|
1258
|
+
case 1:
|
|
1259
|
+
_a.trys.push([1, , 3, 4]);
|
|
1260
|
+
return [4 /*yield*/, this._loadEntryOrThrow(i)];
|
|
1261
|
+
case 2:
|
|
1262
|
+
_a.sent();
|
|
1263
|
+
return [3 /*break*/, 4];
|
|
1264
|
+
case 3:
|
|
1265
|
+
this._generateArrayMips();
|
|
1266
|
+
return [7 /*endfinally*/];
|
|
1267
|
+
case 4: return [2 /*return*/, t];
|
|
1268
|
+
}
|
|
1269
|
+
}); }); };
|
|
1270
|
+
He.prototype.insertLayerAsync = function (e, t) { return i(this, void 0, void 0, function () { var i, t_11; return __generator(this, function (_a) {
|
|
1271
|
+
switch (_a.label) {
|
|
1272
|
+
case 0:
|
|
1273
|
+
if (!Number.isInteger(e) || e < 0 || e > this._layerCount)
|
|
1274
|
+
throw new RangeError("MultiTexture: layer index ".concat(e, " out of range [0, ").concat(this._layerCount, "]."));
|
|
1275
|
+
this._suppressArrayMips();
|
|
1276
|
+
try {
|
|
1277
|
+
this._layerCount + 1 > this._maxLayers && this._growArray(), i = this._createLayerEntry(t), this._layers.splice(e, 0, i), this.pixels.splice(e, 0, null), this.urls.splice(e, 0, t), this._layerCount++;
|
|
1278
|
+
for (t_11 = this._layerCount - 1; t_11 > e; t_11--)
|
|
1279
|
+
this._reuploadSlot(t_11);
|
|
1280
|
+
this.composite.setInt("uLayerCount", this._layerCount), this._renderComposite();
|
|
1281
|
+
}
|
|
1282
|
+
catch (e) {
|
|
1283
|
+
throw this._generateArrayMips(), this._reportError(e), e;
|
|
1284
|
+
}
|
|
1285
|
+
_a.label = 1;
|
|
1286
|
+
case 1:
|
|
1287
|
+
_a.trys.push([1, , 3, 4]);
|
|
1288
|
+
return [4 /*yield*/, this._loadEntryOrThrow(i)];
|
|
1289
|
+
case 2:
|
|
1290
|
+
_a.sent();
|
|
1291
|
+
return [3 /*break*/, 4];
|
|
1292
|
+
case 3:
|
|
1293
|
+
this._generateArrayMips();
|
|
1294
|
+
return [7 /*endfinally*/];
|
|
1295
|
+
case 4: return [2 /*return*/, e];
|
|
1296
|
+
}
|
|
1297
|
+
}); }); };
|
|
1298
|
+
He.prototype.removeLayerAsync = function (e) { return i(this, void 0, void 0, function () { var t, t_12; return __generator(this, function (_a) {
|
|
1299
|
+
if (!Number.isInteger(e) || e < 0 || e >= this._layerCount)
|
|
1300
|
+
throw new RangeError("MultiTexture: layer index ".concat(e, " out of range [0, ").concat(this._layerCount, ")."));
|
|
1301
|
+
t = this._layers.splice(e, 1)[0];
|
|
1302
|
+
this.pixels.splice(e, 1), this.urls.splice(e, 1), t.bitmap && t.bitmap.close(), this._layerCount--, this._suppressArrayMips();
|
|
1303
|
+
try {
|
|
1304
|
+
for (t_12 = e; t_12 < this._layerCount; t_12++)
|
|
1305
|
+
this._reuploadSlot(t_12);
|
|
1306
|
+
this._clearLayerSlot(this._arrayTexture, this._layerCount), this.composite.setInt("uLayerCount", this._layerCount), this._renderComposite();
|
|
1307
|
+
}
|
|
1308
|
+
finally {
|
|
1309
|
+
this._generateArrayMips();
|
|
1310
|
+
}
|
|
1311
|
+
return [2 /*return*/];
|
|
1312
|
+
}); }); };
|
|
1313
|
+
He.prototype.dispose = function () { if (!this._disposed) {
|
|
1314
|
+
this._disposed = !0, null !== this._pollTimer && (clearInterval(this._pollTimer), this._pollTimer = null);
|
|
1315
|
+
for (var e_49 = 0; e_49 < this._layers.length; e_49++) {
|
|
1316
|
+
var t_13 = this._layers[e_49];
|
|
1317
|
+
t_13.bitmap && (t_13.bitmap.close(), t_13.bitmap = null);
|
|
1318
|
+
}
|
|
1319
|
+
for (var e_50 = 0; e_50 < this.pixels.length; e_50++)
|
|
1320
|
+
this.pixels[e_50] = null;
|
|
1321
|
+
this._layers.length = 0, this._canvas = null, this._ctx = null, this._arrayTexture.dispose(), this.composite.dispose(), _super.prototype.dispose.call(this);
|
|
1322
|
+
} };
|
|
1323
|
+
He.prototype.clone = function () { var e = new He(this.name, this.urls.slice(), this.getScene(), { width: this._mtOptions.width, height: this._mtOptions.height, maxLayers: this._maxLayers, blendMode: this._blendMode, generateMipMaps: this._mtOptions.generateMipMaps, samplingMode: this._mtOptions.samplingMode, premultiplyAlpha: this._mtOptions.premultiplyAlpha, fit: this._mtOptions.fit, rttScale: this._mtOptions.rttScale, watch: this._mtOptions.watch, pollInterval: this._mtOptions.pollInterval }); return e.hasAlpha = this.hasAlpha, e.level = this.level, e.coordinatesMode = this.coordinatesMode, e; };
|
|
1324
|
+
He.prototype.serialize = function (e) {
|
|
1325
|
+
if (e === void 0) { e = !1; }
|
|
1326
|
+
throw new Error("MultiTexture: serialize() is not supported. The scene loader has no MultiTexture parser (urls, capacity, blend mode and watch options cannot round-trip). Use clone() for an in-memory copy, or persist your urls/options to rebuild it.");
|
|
1327
|
+
};
|
|
1328
|
+
He.prototype._buildDefines = function (e) { return "#define MULTITEXTURE_MAXLAYERS " + this._deviceMaxLayerCap + "\n#define MULTITEXTURE_WIDTH " + this._mtOptions.width + "\n#define MULTITEXTURE_HEIGHT " + this._mtOptions.height + "\n#define MULTITEXTURE_BLEND_" + e + (this._mtOptions.premultiplyAlpha ? "\n#define MULTITEXTURE_PREMULTIPLY" : ""); };
|
|
1329
|
+
He.prototype._bitmapOptions = function () { var e = { premultiplyAlpha: this._mtOptions.premultiplyAlpha ? "premultiply" : "none" }; return "resize" === this._mtOptions.fit && this._mtOptions.premultiplyAlpha && (e.resizeWidth = this._mtOptions.width, e.resizeHeight = this._mtOptions.height, e.resizeQuality = "high"), e; };
|
|
1330
|
+
He.prototype._reportError = function (e) { var i, r, n; var a = String(null !== (i = null == e ? void 0 : e.message) && void 0 !== i ? i : e); t.Logger.Error(a), null === (n = (r = this._mtOptions).onError) || void 0 === n || n.call(r, a, e); };
|
|
1331
|
+
He.prototype._createLayerEntry = function (e) { return { url: e, etag: null, lastModified: null, bitmap: null, loaded: !1, generation: 0, warnedLoadFailure: !1 }; };
|
|
1332
|
+
He.prototype._loadEntryOrThrow = function (e) { return i(this, void 0, void 0, function () { var e_51; return __generator(this, function (_a) {
|
|
1333
|
+
switch (_a.label) {
|
|
1334
|
+
case 0:
|
|
1335
|
+
_a.trys.push([0, 2, , 3]);
|
|
1336
|
+
return [4 /*yield*/, this._loadEntry(e)];
|
|
1337
|
+
case 1:
|
|
1338
|
+
_a.sent();
|
|
1339
|
+
return [3 /*break*/, 3];
|
|
1340
|
+
case 2:
|
|
1341
|
+
e_51 = _a.sent();
|
|
1342
|
+
throw this._reportError(e_51), e_51;
|
|
1343
|
+
case 3: return [2 /*return*/];
|
|
1344
|
+
}
|
|
1345
|
+
}); }); };
|
|
1346
|
+
He.prototype._loadEntryAndReport = function (e) { return i(this, void 0, void 0, function () { var e_52; return __generator(this, function (_a) {
|
|
1347
|
+
switch (_a.label) {
|
|
1348
|
+
case 0:
|
|
1349
|
+
_a.trys.push([0, 2, , 3]);
|
|
1350
|
+
return [4 /*yield*/, this._loadEntry(e)];
|
|
1351
|
+
case 1:
|
|
1352
|
+
_a.sent();
|
|
1353
|
+
return [3 /*break*/, 3];
|
|
1354
|
+
case 2:
|
|
1355
|
+
e_52 = _a.sent();
|
|
1356
|
+
this._reportError(e_52);
|
|
1357
|
+
return [3 /*break*/, 3];
|
|
1358
|
+
case 3: return [2 /*return*/];
|
|
1359
|
+
}
|
|
1360
|
+
}); }); };
|
|
1361
|
+
He.prototype._warnWatchFailure = function (e, i) { var r, n; if (e.warnedLoadFailure)
|
|
1362
|
+
return; var a = this._layers.indexOf(e); if (-1 === a)
|
|
1363
|
+
return; e.warnedLoadFailure = !0; var s = "MultiTexture: watched layer ".concat(a, " (").concat(e.url, ") ").concat(i); t.Logger.Error(s), null === (n = (r = this._mtOptions).onError) || void 0 === n || n.call(r, s); };
|
|
1364
|
+
He.prototype._uploadToLayer = function (e, i, r) { if (this._mtOptions.premultiplyAlpha)
|
|
1365
|
+
return void t.UploadImageToTexture2DArrayLayer(e, r, i, { premultiplyAlpha: !0 }); var n = this._canvas, a = this._ctx; n && a && (r.width !== this._mtOptions.width || r.height !== this._mtOptions.height) ? (a.clearRect(0, 0, this._mtOptions.width, this._mtOptions.height), a.drawImage(r, 0, 0, this._mtOptions.width, this._mtOptions.height), t.UploadImageToTexture2DArrayLayer(e, n, i, { premultiplyAlpha: !1 })) : t.UploadImageToTexture2DArrayLayer(e, r, i, { premultiplyAlpha: !1 }); };
|
|
1366
|
+
He.prototype._reuploadSlot = function (e, t) {
|
|
1367
|
+
if (t === void 0) { t = this._arrayTexture; }
|
|
1368
|
+
var i = this._layers[e].bitmap;
|
|
1369
|
+
null !== i ? this._uploadToLayer(t, e, i) : this._clearLayerSlot(t, e);
|
|
1370
|
+
};
|
|
1371
|
+
He.prototype._clearLayerSlot = function (e, i) { this._canvas && this._ctx && (this._ctx.clearRect(0, 0, this._mtOptions.width, this._mtOptions.height), t.UploadImageToTexture2DArrayLayer(e, this._canvas, i, { premultiplyAlpha: !1 })); };
|
|
1372
|
+
He.prototype._loadEntry = function (e) { return i(this, void 0, void 0, function () { var t, i, r, n, a, s, o, t_14, r_6, n_2; return __generator(this, function (_a) {
|
|
1373
|
+
switch (_a.label) {
|
|
1374
|
+
case 0:
|
|
1375
|
+
if (this._disposed)
|
|
1376
|
+
return [2 /*return*/];
|
|
1377
|
+
t = ++e.generation, i = e.url;
|
|
1378
|
+
return [4 /*yield*/, fetch(i)];
|
|
1379
|
+
case 1:
|
|
1380
|
+
r = _a.sent();
|
|
1381
|
+
if (!r.ok)
|
|
1382
|
+
throw new Error("MultiTexture: failed to fetch ".concat(i, ": ").concat(r.status, " ").concat(r.statusText));
|
|
1383
|
+
n = r.headers.get("etag"), a = r.headers.get("last-modified");
|
|
1384
|
+
return [4 /*yield*/, r.blob()];
|
|
1385
|
+
case 2:
|
|
1386
|
+
s = _a.sent();
|
|
1387
|
+
return [4 /*yield*/, createImageBitmap(s, this._bitmapOptions())];
|
|
1388
|
+
case 3:
|
|
1389
|
+
o = _a.sent();
|
|
1390
|
+
if ("strict" === this._mtOptions.fit) {
|
|
1391
|
+
t_14 = o.width, r_6 = o.height;
|
|
1392
|
+
if (t_14 !== this._mtOptions.width || r_6 !== this._mtOptions.height) {
|
|
1393
|
+
o.close();
|
|
1394
|
+
n_2 = this._layers.indexOf(e);
|
|
1395
|
+
throw new Error("MultiTexture: layer ".concat(n_2, " (").concat(i, ") is ").concat(t_14, "x").concat(r_6, ", expected ").concat(this._mtOptions.width, "x").concat(this._mtOptions.height, ". Use fit: \"resize\" to auto-scale."));
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
this._uploadBitmap(e, o, { etag: n, lastModified: a, generation: t });
|
|
1399
|
+
return [2 /*return*/];
|
|
1400
|
+
}
|
|
1401
|
+
}); }); };
|
|
1402
|
+
He.prototype._uploadBitmap = function (e, t, i) { if (this._disposed)
|
|
1403
|
+
return void t.close(); var r = this._layers.indexOf(e); -1 !== r && e.generation === i.generation ? (this._uploadToLayer(this._arrayTexture, r, t), this._canvas && this._ctx ? (this._ctx.clearRect(0, 0, this._mtOptions.width, this._mtOptions.height), this._ctx.drawImage(t, 0, 0, this._mtOptions.width, this._mtOptions.height), this.pixels[r] = this._ctx.getImageData(0, 0, this._mtOptions.width, this._mtOptions.height).data.slice()) : this.pixels[r] = null, null !== e.bitmap && e.bitmap.close(), e.bitmap = t, e.loaded = !0, e.etag = i.etag, e.lastModified = i.lastModified, e.warnedLoadFailure = !1, this._renderComposite()) : t.close(); };
|
|
1404
|
+
He.prototype._initialize = function () { return i(this, void 0, void 0, function () {
|
|
1405
|
+
var e, t, r_7, n_3, a_3, s_1, o_1, e_54, e_53;
|
|
1406
|
+
var _this = this;
|
|
1407
|
+
return __generator(this, function (_a) {
|
|
1408
|
+
switch (_a.label) {
|
|
1409
|
+
case 0:
|
|
1410
|
+
_a.trys.push([0, 2, 3, 4]);
|
|
1411
|
+
if (this._disposed)
|
|
1412
|
+
return [2 /*return*/];
|
|
1413
|
+
this._suppressArrayMips();
|
|
1414
|
+
r_7 = this._layers.slice();
|
|
1415
|
+
n_3 = 0;
|
|
1416
|
+
a_3 = r_7.length, s_1 = function () { return i(_this, void 0, void 0, function () { var e; return __generator(this, function (_a) {
|
|
1417
|
+
switch (_a.label) {
|
|
1418
|
+
case 0:
|
|
1419
|
+
if (!((e = n_3++) < a_3)) return [3 /*break*/, 3];
|
|
1420
|
+
return [4 /*yield*/, this._loadEntryAndReport(r_7[e])];
|
|
1421
|
+
case 1:
|
|
1422
|
+
_a.sent();
|
|
1423
|
+
_a.label = 2;
|
|
1424
|
+
case 2: return [3 /*break*/, 0];
|
|
1425
|
+
case 3: return [2 /*return*/];
|
|
1426
|
+
}
|
|
1427
|
+
}); }); }, o_1 = [];
|
|
1428
|
+
for (e_54 = 0; e_54 < 4; e_54++)
|
|
1429
|
+
o_1.push(s_1());
|
|
1430
|
+
return [4 /*yield*/, Promise.all(o_1)];
|
|
1431
|
+
case 1:
|
|
1432
|
+
_a.sent(), this._disposed || (this.onLoadObservable.notifyObservers(this), null === (t = (e = this._mtOptions).onLoad) || void 0 === t || t.call(e), this._renderComposite()), this._mtOptions.watch && this._startPolling();
|
|
1433
|
+
return [3 /*break*/, 4];
|
|
1434
|
+
case 2:
|
|
1435
|
+
e_53 = _a.sent();
|
|
1436
|
+
this._reportError(e_53);
|
|
1437
|
+
return [3 /*break*/, 4];
|
|
1438
|
+
case 3:
|
|
1439
|
+
this._generateArrayMips();
|
|
1440
|
+
return [7 /*endfinally*/];
|
|
1441
|
+
case 4: return [2 /*return*/];
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
}); };
|
|
1445
|
+
He.prototype._pushLayerEntry = function (e) { var t = this._createLayerEntry(e); return this._layers.push(t), this.pixels.push(null), this.urls.push(e), this._layerCount++, t; };
|
|
1446
|
+
He.prototype._growArray = function () { var e, i, r; var n = this.getScene(), a = 2 * this._maxLayers; if (a > this._deviceMaxLayerCap)
|
|
1447
|
+
throw new RangeError("MultiTexture: cannot grow the array from depth ".concat(this._maxLayers, " to ").concat(a, ": the device limit texture2DArrayMaxLayerCount is ").concat(this._deviceMaxLayerCap, ". Remove a layer, or recreate the MultiTexture with a larger options.maxLayers (<= ").concat(this._deviceMaxLayerCap, ") to allow more growth headroom.")); var s = new t.RawTexture2DArray(null, this._mtOptions.width, this._mtOptions.height, a, t.Constants.TEXTUREFORMAT_RGBA, n, null !== (e = this._mtOptions.generateMipMaps) && void 0 !== e && e, !1, null !== (i = this._mtOptions.samplingMode) && void 0 !== i ? i : t.Texture.TRILINEAR_SAMPLINGMODE, t.Constants.TEXTURETYPE_UNSIGNED_BYTE), o = s.getInternalTexture(); null !== (r = this._mtOptions.generateMipMaps) && void 0 !== r && r && o && (o.generateMipMaps = !1); for (var e_55 = 0; e_55 < this._layerCount; e_55++)
|
|
1448
|
+
this._reuploadSlot(e_55, s); this._arrayTexture.dispose(), this._arrayTexture = s, this.composite.setTexture("uLayers", s), this._maxLayers = a, this._renderComposite(); };
|
|
1449
|
+
He.prototype._suppressArrayMips = function () { var e; if (null === (e = this._mtOptions.generateMipMaps) || void 0 === e || !e || this._disposed)
|
|
1450
|
+
return; var t = this._arrayTexture.getInternalTexture(); t && (t.generateMipMaps = !1), this._mipSuppressCount++; };
|
|
1451
|
+
He.prototype._generateArrayMips = function () { var e; if (this._mipSuppressCount > 0 && this._mipSuppressCount--, this._mipSuppressCount > 0 || null === (e = this._mtOptions.generateMipMaps) || void 0 === e || !e || this._disposed)
|
|
1452
|
+
return; var t = this._arrayTexture.getInternalTexture(); t && (t.generateMipMaps = !0, this.getScene().getEngine().generateMipmaps(t)); };
|
|
1453
|
+
He.prototype._startPolling = function () {
|
|
1454
|
+
var _this = this;
|
|
1455
|
+
null !== this._pollTimer || this._disposed || (this._pollTimer = setInterval(function () { _this._poll(); }, this._mtOptions.pollInterval));
|
|
1456
|
+
};
|
|
1457
|
+
He.prototype._poll = function () { return i(this, void 0, void 0, function () {
|
|
1458
|
+
var e, t, r, n, a, e_56;
|
|
1459
|
+
var _this = this;
|
|
1460
|
+
return __generator(this, function (_a) {
|
|
1461
|
+
switch (_a.label) {
|
|
1462
|
+
case 0:
|
|
1463
|
+
if (this._pollInFlight)
|
|
1464
|
+
return [2 /*return*/];
|
|
1465
|
+
if (this._pollInFlight = !0, this._disposed)
|
|
1466
|
+
return [2 /*return*/, void (this._pollInFlight = !1)];
|
|
1467
|
+
if ("undefined" != typeof document && "hidden" === document.visibilityState)
|
|
1468
|
+
return [2 /*return*/, void (this._pollInFlight = !1)];
|
|
1469
|
+
e = this._layers.slice();
|
|
1470
|
+
t = 0;
|
|
1471
|
+
r = e.length, n = function () { return i(_this, void 0, void 0, function () { var i, n, t_15, e_57, e_59, r_8, n_4, _a, e_58; return __generator(this, function (_b) {
|
|
1472
|
+
switch (_b.label) {
|
|
1473
|
+
case 0:
|
|
1474
|
+
if (!((n = t++) < r)) return [3 /*break*/, 12];
|
|
1475
|
+
t_15 = e[n];
|
|
1476
|
+
_b.label = 1;
|
|
1477
|
+
case 1:
|
|
1478
|
+
_b.trys.push([1, 10, , 11]);
|
|
1479
|
+
if (!(null === t_15.etag && null === t_15.lastModified)) return [3 /*break*/, 6];
|
|
1480
|
+
_b.label = 2;
|
|
1481
|
+
case 2:
|
|
1482
|
+
_b.trys.push([2, 4, , 5]);
|
|
1483
|
+
return [4 /*yield*/, this._loadEntry(t_15)];
|
|
1484
|
+
case 3:
|
|
1485
|
+
_b.sent();
|
|
1486
|
+
return [3 /*break*/, 5];
|
|
1487
|
+
case 4:
|
|
1488
|
+
e_57 = _b.sent();
|
|
1489
|
+
this._warnWatchFailure(t_15, "failed to load: ".concat(String(null !== (i = null == e_57 ? void 0 : e_57.message) && void 0 !== i ? i : e_57)));
|
|
1490
|
+
return [3 /*break*/, 5];
|
|
1491
|
+
case 5: return [3 /*break*/, 11];
|
|
1492
|
+
case 6: return [4 /*yield*/, fetch(t_15.url, { method: "HEAD" })];
|
|
1493
|
+
case 7:
|
|
1494
|
+
e_59 = _b.sent();
|
|
1495
|
+
if (404 === e_59.status) {
|
|
1496
|
+
this._warnWatchFailure(t_15, "returned 404.");
|
|
1497
|
+
return [3 /*break*/, 11];
|
|
1498
|
+
}
|
|
1499
|
+
if (!e_59.ok)
|
|
1500
|
+
return [3 /*break*/, 11];
|
|
1501
|
+
r_8 = e_59.headers.get("etag"), n_4 = e_59.headers.get("last-modified");
|
|
1502
|
+
if (null === r_8 && null === n_4)
|
|
1503
|
+
return [3 /*break*/, 11];
|
|
1504
|
+
_a = (null !== r_8 && r_8 !== t_15.etag || null !== n_4 && n_4 !== t_15.lastModified);
|
|
1505
|
+
if (!_a) return [3 /*break*/, 9];
|
|
1506
|
+
return [4 /*yield*/, this._loadEntryAndReport(t_15)];
|
|
1507
|
+
case 8:
|
|
1508
|
+
_a = (_b.sent());
|
|
1509
|
+
_b.label = 9;
|
|
1510
|
+
case 9:
|
|
1511
|
+
_a;
|
|
1512
|
+
return [3 /*break*/, 11];
|
|
1513
|
+
case 10:
|
|
1514
|
+
e_58 = _b.sent();
|
|
1515
|
+
return [3 /*break*/, 11];
|
|
1516
|
+
case 11: return [3 /*break*/, 0];
|
|
1517
|
+
case 12: return [2 /*return*/];
|
|
1518
|
+
}
|
|
1519
|
+
}); }); }, a = [];
|
|
1520
|
+
for (e_56 = 0; e_56 < 4; e_56++)
|
|
1521
|
+
a.push(n());
|
|
1522
|
+
return [4 /*yield*/, Promise.all(a)];
|
|
1523
|
+
case 1:
|
|
1524
|
+
_a.sent(), this._pollInFlight = !1;
|
|
1525
|
+
return [2 /*return*/];
|
|
1526
|
+
}
|
|
1527
|
+
});
|
|
1528
|
+
}); };
|
|
1529
|
+
return He;
|
|
1530
|
+
}(t.BaseTexture));
|
|
1531
|
+
var qe;
|
|
1532
|
+
function Ze() { if (!$e)
|
|
1533
|
+
throw new Error("Recast is not initialized. Please call InitRecast first."); return $e; }
|
|
1534
|
+
var $e;
|
|
1535
|
+
e.MultiBlendMode = void 0, (qe = e.MultiBlendMode || (e.MultiBlendMode = {}))[qe.ALPHA_BLEND = 0] = "ALPHA_BLEND", qe[qe.ALPHA_MAX = 1] = "ALPHA_MAX", qe[qe.ADD = 2] = "ADD", qe[qe.MULTIPLY = 3] = "MULTIPLY", qe[qe.SUBTRACT = 4] = "SUBTRACT", qe[qe.SCREEN = 5] = "SCREEN";
|
|
1536
|
+
var Ye = null;
|
|
1537
|
+
function je(e, t, i) {
|
|
1119
1538
|
if (e === void 0) { e = []; }
|
|
1120
1539
|
if (t === void 0) { t = 0; }
|
|
1121
1540
|
if (i === void 0) { i = 1; }
|
|
1122
|
-
return new (
|
|
1123
|
-
|
|
1541
|
+
return new (Ze().TileCacheMeshProcess)(function (r, n, a) { for (var e_60 = 0; e_60 < r.polyCount(); ++e_60)
|
|
1542
|
+
n.set(e_60, t), a.set(e_60, i); e.length > 0 && r.setOffMeshConnections(e); });
|
|
1124
1543
|
}
|
|
1125
|
-
function
|
|
1544
|
+
function Xe(e, t) { var i = !1; for (; !i;)
|
|
1126
1545
|
i = t.update(e).upToDate; }
|
|
1127
|
-
function
|
|
1128
|
-
function
|
|
1129
|
-
function
|
|
1130
|
-
function
|
|
1546
|
+
function Qe(e) { return et(e); }
|
|
1547
|
+
function Ke(e) { var t; return Object.assign(Object.assign({}, Qe(e)), { tileSize: null !== (t = e.tileSize) && void 0 !== t ? t : 32 }); }
|
|
1548
|
+
function Je(e) { var i, r; var n = Object.assign(Object.assign({}, Ke(e)), { expectedLayersPerTile: null !== (i = e.expectedLayersPerTile) && void 0 !== i ? i : 1, maxObstacles: null !== (r = e.maxObstacles) && void 0 !== r ? r : 128 }); return e.tileCacheMeshProcess ? n.tileCacheMeshProcess = e.tileCacheMeshProcess : e.offMeshConnections && (t.Logger.Warn("offMeshConnections are required but no tileCacheMeshProcess is set. Using fallback DefaultTileCacheMeshProcess."), n.tileCacheMeshProcess = je(e.offMeshConnections)), n; }
|
|
1549
|
+
function et(e) { return Object.fromEntries(Object.entries(e).filter(function (_a) {
|
|
1131
1550
|
var _b = __read(_a, 2), e = _b[0], t = _b[1];
|
|
1132
1551
|
return void 0 !== t;
|
|
1133
1552
|
})); }
|
|
1134
|
-
function
|
|
1553
|
+
function tt(e) { return Object.fromEntries(Object.entries(e).filter(function (_a) {
|
|
1135
1554
|
var _b = __read(_a, 2), e = _b[0], t = _b[1];
|
|
1136
1555
|
return void 0 !== t;
|
|
1137
1556
|
})); }
|
|
1138
|
-
var
|
|
1139
|
-
function
|
|
1557
|
+
var it = /** @class */ (function () {
|
|
1558
|
+
function it(e, i, r, n) {
|
|
1140
1559
|
var _this = this;
|
|
1141
1560
|
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
1561
|
throw new Error("There is no NavMesh generated.");
|
|
1143
|
-
this._recastCrowd = new (
|
|
1562
|
+
this._recastCrowd = new (Ze().Crowd)(e.navMesh, { maxAgents: i, maxAgentRadius: r }), this._scene = n, this._engine = n.getEngine(), this._onBeforeAnimationsObserver = n.onBeforeAnimationsObservable.add(function () { _this.update(.001 * _this._engine.getDeltaTime() * e.timeFactor); });
|
|
1144
1563
|
}
|
|
1145
|
-
Object.defineProperty(
|
|
1564
|
+
Object.defineProperty(it.prototype, "navigationPlugin", {
|
|
1146
1565
|
get: function () { return this._navigationPlugin; },
|
|
1147
1566
|
enumerable: false,
|
|
1148
1567
|
configurable: true
|
|
1149
1568
|
});
|
|
1150
|
-
Object.defineProperty(
|
|
1569
|
+
Object.defineProperty(it.prototype, "recastCrowd", {
|
|
1151
1570
|
get: function () { return this._recastCrowd; },
|
|
1152
1571
|
enumerable: false,
|
|
1153
1572
|
configurable: true
|
|
1154
1573
|
});
|
|
1155
|
-
Object.defineProperty(
|
|
1574
|
+
Object.defineProperty(it.prototype, "transforms", {
|
|
1156
1575
|
get: function () { return this._transforms; },
|
|
1157
1576
|
enumerable: false,
|
|
1158
1577
|
configurable: true
|
|
1159
1578
|
});
|
|
1160
|
-
Object.defineProperty(
|
|
1579
|
+
Object.defineProperty(it.prototype, "agents", {
|
|
1161
1580
|
get: function () { return Object.freeze(this._agents); },
|
|
1162
1581
|
enumerable: false,
|
|
1163
1582
|
configurable: true
|
|
1164
1583
|
});
|
|
1165
|
-
Object.defineProperty(
|
|
1584
|
+
Object.defineProperty(it.prototype, "reachRadii", {
|
|
1166
1585
|
get: function () { return Object.freeze(this._reachRadii); },
|
|
1167
1586
|
enumerable: false,
|
|
1168
1587
|
configurable: true
|
|
1169
1588
|
});
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
return; var
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
return; var i = this._navigationPlugin.getTimeStep(),
|
|
1589
|
+
it.prototype.addAgent = function (e, i, r) { var n = tt(i), a = this._recastCrowd.addAgent({ x: e.x, y: e.y, z: e.z }, n); return this._transforms.push(r), 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; };
|
|
1590
|
+
it.prototype.getAgentPosition = function (e) { var i, r; var n = null !== (r = null === (i = this._recastCrowd.getAgent(e)) || void 0 === i ? void 0 : i.position()) && void 0 !== r ? r : t.Vector3.ZeroReadOnly; return new t.Vector3(n.x, n.y, n.z); };
|
|
1591
|
+
it.prototype.getAgentPositionToRef = function (e, i) { var r, n; var a = null !== (n = null === (r = this._recastCrowd.getAgent(e)) || void 0 === r ? void 0 : r.position()) && void 0 !== n ? n : t.Vector3.ZeroReadOnly; i.set(a.x, a.y, a.z); };
|
|
1592
|
+
it.prototype.getAgentVelocity = function (e) { var i, r; var n = null !== (r = null === (i = this._recastCrowd.getAgent(e)) || void 0 === i ? void 0 : i.velocity()) && void 0 !== r ? r : t.Vector3.ZeroReadOnly; return new t.Vector3(n.x, n.y, n.z); };
|
|
1593
|
+
it.prototype.getAgentVelocityToRef = function (e, i) { var r, n; var a = null !== (n = null === (r = this._recastCrowd.getAgent(e)) || void 0 === r ? void 0 : r.velocity()) && void 0 !== n ? n : t.Vector3.ZeroReadOnly; i.set(a.x, a.y, a.z); };
|
|
1594
|
+
it.prototype.getAgentNextTargetPath = function (e) { var i, r; var n = null !== (r = null === (i = this._recastCrowd.getAgent(e)) || void 0 === i ? void 0 : i.nextTargetInPath()) && void 0 !== r ? r : t.Vector3.ZeroReadOnly; return new t.Vector3(n.x, n.y, n.z); };
|
|
1595
|
+
it.prototype.getAgentNextTargetPathToRef = function (e, i) { var r, n; var a = null !== (n = null === (r = this._recastCrowd.getAgent(e)) || void 0 === r ? void 0 : r.nextTargetInPath()) && void 0 !== n ? n : t.Vector3.ZeroReadOnly; i.set(a.x, a.y, a.z); };
|
|
1596
|
+
it.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; };
|
|
1597
|
+
it.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; };
|
|
1598
|
+
it.prototype.agentGoto = function (e, t) { var i; null === (i = this._recastCrowd.getAgent(e)) || void 0 === i || i.requestMoveTarget(t); var r = this._agents.indexOf(e); r > -1 && (this._agentDestinationArmed[r] = !0, this._agentDestination[r].set(t.x, t.y, t.z)); };
|
|
1599
|
+
it.prototype.agentTeleport = function (e, t) { var i; null === (i = this._recastCrowd.getAgent(e)) || void 0 === i || i.teleport(t); };
|
|
1600
|
+
it.prototype.updateAgentParameters = function (e, t) { var i = this._recastCrowd.getAgent(e); if (!i)
|
|
1601
|
+
return; var r = i.parameters(); r && (void 0 !== t.radius && (r.radius = t.radius), void 0 !== t.height && (r.height = t.height), void 0 !== t.maxAcceleration && (r.maxAcceleration = t.maxAcceleration), void 0 !== t.maxSpeed && (r.maxSpeed = t.maxSpeed), void 0 !== t.collisionQueryRange && (r.collisionQueryRange = t.collisionQueryRange), void 0 !== t.pathOptimizationRange && (r.pathOptimizationRange = t.pathOptimizationRange), void 0 !== t.separationWeight && (r.separationWeight = t.separationWeight), i.updateParameters(r)); };
|
|
1602
|
+
it.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)); };
|
|
1603
|
+
it.prototype.getAgents = function () { return this._agents; };
|
|
1604
|
+
it.prototype.update = function (e) { if (e <= t.Epsilon)
|
|
1605
|
+
return; var i = this._navigationPlugin.getTimeStep(), r = this._navigationPlugin.getMaximumSubStepCount(); if (i <= t.Epsilon)
|
|
1187
1606
|
this._recastCrowd.update(e);
|
|
1188
1607
|
else {
|
|
1189
|
-
var
|
|
1190
|
-
|
|
1191
|
-
var
|
|
1192
|
-
for (var
|
|
1193
|
-
this._recastCrowd.update(
|
|
1194
|
-
} for (var
|
|
1195
|
-
var
|
|
1196
|
-
if (this._transforms[
|
|
1197
|
-
var
|
|
1198
|
-
i_10.y >
|
|
1608
|
+
var t_16 = Math.floor(e / i);
|
|
1609
|
+
r && t_16 > r && (t_16 = r), t_16 < 1 && (t_16 = 1);
|
|
1610
|
+
var n_5 = e / t_16;
|
|
1611
|
+
for (var e_61 = 0; e_61 < t_16; e_61++)
|
|
1612
|
+
this._recastCrowd.update(n_5);
|
|
1613
|
+
} for (var e_62 = 0; e_62 < this._agents.length; e_62++) {
|
|
1614
|
+
var t_17 = this._agents[e_62], i_10 = this.getAgentPosition(t_17);
|
|
1615
|
+
if (this._transforms[e_62].position = i_10, this._agentDestinationArmed[e_62]) {
|
|
1616
|
+
var r_9 = i_10.x - this._agentDestination[e_62].x, n_6 = i_10.z - this._agentDestination[e_62].z, a_4 = this._reachRadii[e_62], s_2 = this._agentDestination[e_62].y - this._reachRadii[e_62], o_2 = this._agentDestination[e_62].y + this._reachRadii[e_62], l_2 = r_9 * r_9 + n_6 * n_6;
|
|
1617
|
+
i_10.y > s_2 && i_10.y < o_2 && l_2 < a_4 * a_4 && (this._agentDestinationArmed[e_62] = !1, this.onReachTargetObservable.notifyObservers({ agentIndex: t_17, destination: this._agentDestination[e_62] }));
|
|
1199
1618
|
}
|
|
1200
1619
|
} };
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
return []; var
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
return
|
|
1620
|
+
it.prototype.setDefaultQueryExtent = function (e) { this._navigationPlugin.setDefaultQueryExtent(e); };
|
|
1621
|
+
it.prototype.getDefaultQueryExtent = function () { var e = this._navigationPlugin.getDefaultQueryExtent(); return new t.Vector3(e.x, e.y, e.z); };
|
|
1622
|
+
it.prototype.getDefaultQueryExtentToRef = function (e) { var t = this._navigationPlugin.getDefaultQueryExtent(); e.set(t.x, t.y, t.z); };
|
|
1623
|
+
it.prototype.getCorners = function (e) { var i; var r = null === (i = this._recastCrowd.getAgent(e)) || void 0 === i ? void 0 : i.corners(); if (!r)
|
|
1624
|
+
return []; var n = []; for (var e_63 = 0; e_63 < r.length; e_63++)
|
|
1625
|
+
n.push(new t.Vector3(r[e_63].x, r[e_63].y, r[e_63].z)); return n; };
|
|
1626
|
+
it.prototype.dispose = function () { this._recastCrowd.destroy(), this._onBeforeAnimationsObserver && (this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver), this._onBeforeAnimationsObserver = null), this.onReachTargetObservable.clear(); };
|
|
1627
|
+
return it;
|
|
1209
1628
|
}());
|
|
1210
|
-
function
|
|
1211
|
-
var
|
|
1212
|
-
for (var
|
|
1213
|
-
var
|
|
1214
|
-
i.push(new t.Vector3(
|
|
1629
|
+
function rt(e) { var i = []; if (e.success) {
|
|
1630
|
+
var r_10 = e.path.length;
|
|
1631
|
+
for (var n_7 = 0; n_7 < r_10; n_7++) {
|
|
1632
|
+
var r_11 = e.path[n_7];
|
|
1633
|
+
i.push(new t.Vector3(r_11.x, r_11.y, r_11.z));
|
|
1215
1634
|
}
|
|
1216
1635
|
}
|
|
1217
1636
|
else
|
|
1218
1637
|
t.Logger.Warn("Unable to convert navigation path point, because navPath generation has failed."); return i; }
|
|
1219
|
-
var
|
|
1220
|
-
function
|
|
1221
|
-
return { success: !1, error: { type: "START_NEAREST_POLY_FAILED", status:
|
|
1222
|
-
return { success: !1, error: { type: "END_NEAREST_POLY_FAILED", status: y.status }, path: [] }; var T =
|
|
1223
|
-
return { success: !1, error: { type: "FIND_PATH_FAILED", status:
|
|
1224
|
-
return { success: !1, error: { type: "NO_POLYGON_PATH_FOUND" }, path: [] }; var
|
|
1225
|
-
var
|
|
1226
|
-
if (!
|
|
1227
|
-
return { success: !1, error: { type: "NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND", status:
|
|
1228
|
-
|
|
1229
|
-
} var
|
|
1230
|
-
var
|
|
1231
|
-
if (!
|
|
1638
|
+
var nt = new t.Vector3, at = new t.Vector3;
|
|
1639
|
+
function st(e, i, r, n, a) { return rt(function (e, i, r, n, a) { var s, o, l, c, u, h; var d = Ze(), 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 !== (u = null == a ? void 0 : a.stepSize) && void 0 !== u ? u : .5, _ = null !== (h = null == a ? void 0 : a.slop) && void 0 !== h ? h : .01, S = i.findNearestPoly(r, { filter: m, halfExtents: p }); if (!S.success)
|
|
1640
|
+
return { success: !1, error: { type: "START_NEAREST_POLY_FAILED", status: S.status }, path: [] }; var y = i.findNearestPoly(n, { filter: m, halfExtents: p }); if (!y.success)
|
|
1641
|
+
return { success: !1, error: { type: "END_NEAREST_POLY_FAILED", status: y.status }, path: [] }; var T = S.nearestRef, A = y.nearestRef, L = i.findPath(T, A, r, n, { filter: m, maxPathPolys: g }); if (!L.success)
|
|
1642
|
+
return { success: !1, error: { type: "FIND_PATH_FAILED", status: L.status }, path: [] }; if (L.polys.size <= 0)
|
|
1643
|
+
return { success: !1, error: { type: "NO_POLYGON_PATH_FOUND" }, path: [] }; var P = L.polys.get(L.polys.size - 1); var E = n; if (P !== A) {
|
|
1644
|
+
var e_64 = i.closestPointOnPoly(P, n);
|
|
1645
|
+
if (!e_64.success)
|
|
1646
|
+
return { success: !1, error: { type: "NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND", status: e_64.status }, path: [] };
|
|
1647
|
+
E = e_64.closestPoint;
|
|
1648
|
+
} var R = new t.Vector3(r.x, r.y, r.z), C = new t.Vector3(E.x, E.y, E.z), x = Array.from(L.polys.getHeapView()), M = []; for (M.push(R.clone()); x.length > 0 && M.length < f;) {
|
|
1649
|
+
var r_12 = ot(i, R, C, _, x, d);
|
|
1650
|
+
if (!r_12.success)
|
|
1232
1651
|
break;
|
|
1233
|
-
var
|
|
1234
|
-
var l_3 = Math.sqrt(
|
|
1235
|
-
l_3 = (
|
|
1236
|
-
var c_3 =
|
|
1237
|
-
if (!
|
|
1652
|
+
var n_8 = r_12.steerPosFlag & d.Detour.DT_STRAIGHTPATH_END, a_5 = r_12.steerPosFlag & d.Detour.DT_STRAIGHTPATH_OFFMESH_CONNECTION, s_3 = r_12.steerPos, o_3 = nt.copyFrom(s_3).subtract(R);
|
|
1653
|
+
var l_3 = Math.sqrt(o_3.dot(o_3));
|
|
1654
|
+
l_3 = (n_8 || a_5) && l_3 < v ? 1 : v / l_3;
|
|
1655
|
+
var c_3 = at.copyFrom(R).addInPlace(o_3.scale(l_3)), u_2 = i.moveAlongSurface(x[0], R, c_3, { filter: m, maxVisitedSize: 16 });
|
|
1656
|
+
if (!u_2.success)
|
|
1238
1657
|
break;
|
|
1239
|
-
var h_3 =
|
|
1240
|
-
|
|
1658
|
+
var h_3 = u_2.resultPosition;
|
|
1659
|
+
ct(x, g, u_2.visited), ut(x, e, d);
|
|
1241
1660
|
var p_2 = i.getPolyHeight(x[0], h_3);
|
|
1242
|
-
if (p_2.success && (h_3.y = p_2.height),
|
|
1243
|
-
|
|
1661
|
+
if (p_2.success && (h_3.y = p_2.height), R.copyFromFloats(h_3.x, h_3.y, h_3.z), n_8 && lt(R, r_12.steerPos, _, 1)) {
|
|
1662
|
+
R.copyFrom(C), M.length < f && M.push(new t.Vector3(R.x, R.y, R.z));
|
|
1244
1663
|
break;
|
|
1245
1664
|
}
|
|
1246
|
-
if (
|
|
1247
|
-
var
|
|
1248
|
-
var
|
|
1249
|
-
for (;
|
|
1250
|
-
|
|
1251
|
-
for (var
|
|
1252
|
-
x[
|
|
1253
|
-
x.splice(
|
|
1254
|
-
var l_4 = e.getOffMeshConnectionPolyEndPoints(
|
|
1255
|
-
if (l_4.success &&
|
|
1256
|
-
|
|
1257
|
-
var
|
|
1258
|
-
|
|
1665
|
+
if (a_5 && lt(R, r_12.steerPos, _, 1)) {
|
|
1666
|
+
var n_9 = r_12.steerPosRef;
|
|
1667
|
+
var a_6 = 0, s_4 = x[0], o_4 = 0;
|
|
1668
|
+
for (; o_4 < x.length && s_4 !== n_9;)
|
|
1669
|
+
a_6 = s_4, s_4 = x[o_4], o_4++;
|
|
1670
|
+
for (var e_65 = o_4; e_65 < x.length; e_65++)
|
|
1671
|
+
x[e_65 - o_4] = x[e_65];
|
|
1672
|
+
x.splice(o_4, x.length - o_4);
|
|
1673
|
+
var l_4 = e.getOffMeshConnectionPolyEndPoints(a_6, s_4);
|
|
1674
|
+
if (l_4.success && M.length < f) {
|
|
1675
|
+
M.push(new t.Vector3(R.x, R.y, R.z)), 1 & M.length && M.push(new t.Vector3(R.x, R.y, R.z)), R.copyFromFloats(l_4.end.x, l_4.end.y, l_4.end.z);
|
|
1676
|
+
var e_66 = i.getPolyHeight(x[0], R);
|
|
1677
|
+
e_66.success && (R.y = e_66.height);
|
|
1259
1678
|
}
|
|
1260
1679
|
}
|
|
1261
|
-
|
|
1262
|
-
} return { success: !0, path:
|
|
1263
|
-
function
|
|
1264
|
-
return { success: !1 }; var l = []; for (var
|
|
1265
|
-
var i_11 = new t.Vector3(o.straightPath.get(3 *
|
|
1680
|
+
M.length < f && M.push(new t.Vector3(R.x, R.y, R.z));
|
|
1681
|
+
} return { success: !0, path: M }; }(e, i, r, n, a)); }
|
|
1682
|
+
function ot(e, i, r, n, a, s) { var o = e.findStraightPath(i, r, a, { maxStraightPathPoints: 3 }); if (!o.success)
|
|
1683
|
+
return { success: !1 }; var l = []; for (var e_67 = 0; e_67 < o.straightPathCount; e_67++) {
|
|
1684
|
+
var i_11 = new t.Vector3(o.straightPath.get(3 * e_67), o.straightPath.get(3 * e_67 + 1), o.straightPath.get(3 * e_67 + 2));
|
|
1266
1685
|
l.push(i_11);
|
|
1267
|
-
} var c = 0; for (; c < l.length && !(o.straightPathFlags.get(c) & s.Detour.DT_STRAIGHTPATH_OFFMESH_CONNECTION) &&
|
|
1686
|
+
} var c = 0; for (; c < l.length && !(o.straightPathFlags.get(c) & s.Detour.DT_STRAIGHTPATH_OFFMESH_CONNECTION) && lt(l[c], i, n, 1e3);)
|
|
1268
1687
|
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
|
|
1270
|
-
function
|
|
1271
|
-
var
|
|
1272
|
-
for (var
|
|
1273
|
-
e[
|
|
1274
|
-
if (
|
|
1688
|
+
function lt(e, t, i, r) { var n = t.x - e.x, a = t.y - e.y, s = t.z - e.z; return n * n + s * s < i * i && Math.abs(a) < r; }
|
|
1689
|
+
function ct(e, t, i) { var r = -1, n = -1; for (var t_18 = e.length - 1; t_18 >= 0; t_18--) {
|
|
1690
|
+
var a_7 = !1;
|
|
1691
|
+
for (var s_5 = i.length - 1; s_5 >= 0; s_5--)
|
|
1692
|
+
e[t_18] === i[s_5] && (r = t_18, n = s_5, a_7 = !0);
|
|
1693
|
+
if (a_7)
|
|
1275
1694
|
break;
|
|
1276
|
-
} if (-1 ===
|
|
1277
|
-
return e; var a = i.length -
|
|
1278
|
-
e[
|
|
1279
|
-
function
|
|
1280
|
-
return; var
|
|
1281
|
-
return; var s = a.poly, o = a.tile; for (var
|
|
1282
|
-
var
|
|
1283
|
-
0 !==
|
|
1284
|
-
} var l = 0; for (var
|
|
1285
|
-
for (var i_12 = 0; i_12 <
|
|
1286
|
-
if (e[
|
|
1287
|
-
l =
|
|
1695
|
+
} if (-1 === r || -1 === n)
|
|
1696
|
+
return e; var a = i.length - n, s = Math.min(r + 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_19 = 0; t_19 < a; t_19++)
|
|
1697
|
+
e[t_19] = i[i.length - (1 + t_19)]; return e; }
|
|
1698
|
+
function ut(e, t, i) { if (e.length < 3)
|
|
1699
|
+
return; var r = 0; var n = [], a = t.getTileAndPolyByRef(e[0]); if (!a.success)
|
|
1700
|
+
return; var s = a.poly, o = a.tile; for (var e_68 = s.firstLink(); e_68 !== i.Detour.DT_NULL_LINK; e_68 = o.links(e_68).next()) {
|
|
1701
|
+
var t_20 = o.links(e_68);
|
|
1702
|
+
0 !== t_20.ref() && r < 16 && (n.push(t_20.ref()), r++);
|
|
1703
|
+
} var l = 0; for (var t_21 = Math.min(6, e.length) - 1; t_21 > 1 && 0 === l; t_21--)
|
|
1704
|
+
for (var i_12 = 0; i_12 < r; i_12++)
|
|
1705
|
+
if (e[t_21] === n[i_12]) {
|
|
1706
|
+
l = t_21;
|
|
1288
1707
|
break;
|
|
1289
1708
|
} l > 1 && e.splice(1, l - 1); }
|
|
1290
|
-
function
|
|
1291
|
-
if (e[
|
|
1292
|
-
var c_4 = e[
|
|
1293
|
-
if (!
|
|
1709
|
+
function ht(e, i) { var r, n, a, s = 0; var o = [], l = []; for (r = 0; r < e.length; r++)
|
|
1710
|
+
if (e[r]) {
|
|
1711
|
+
var c_4 = e[r], u_3 = (null == i ? void 0 : i.doNotReverseIndices) ? c_4.getIndices(!1, !0) : dt(c_4);
|
|
1712
|
+
if (!u_3)
|
|
1294
1713
|
continue;
|
|
1295
1714
|
var h_4 = c_4.getVerticesData(t.VertexBuffer.PositionKind, !1, !1);
|
|
1296
1715
|
if (!h_4)
|
|
1297
1716
|
continue;
|
|
1298
|
-
var
|
|
1717
|
+
var d_3 = [], m_2 = c_4.computeWorldMatrix(!0);
|
|
1299
1718
|
if (c_4.hasThinInstances) {
|
|
1300
|
-
var
|
|
1301
|
-
for (var i_13 = 0; i_13 <
|
|
1302
|
-
var
|
|
1303
|
-
|
|
1719
|
+
var e_69 = c_4.thinInstanceGetWorldMatrices();
|
|
1720
|
+
for (var i_13 = 0; i_13 < e_69.length; i_13++) {
|
|
1721
|
+
var r_13 = new t.Matrix;
|
|
1722
|
+
e_69[i_13].multiplyToRef(m_2, r_13), d_3.push(r_13);
|
|
1304
1723
|
}
|
|
1305
1724
|
}
|
|
1306
1725
|
else
|
|
1307
|
-
|
|
1726
|
+
d_3.push(m_2);
|
|
1308
1727
|
var p_3 = t.Vector3.Zero(), f_2 = t.Vector3.Zero();
|
|
1309
|
-
for (var
|
|
1310
|
-
var i_14 =
|
|
1311
|
-
for (
|
|
1312
|
-
l.push(
|
|
1728
|
+
for (var e_70 = 0; e_70 < d_3.length; e_70++) {
|
|
1729
|
+
var i_14 = d_3[e_70];
|
|
1730
|
+
for (n = 0; n < u_3.length; n++)
|
|
1731
|
+
l.push(u_3[n] + s);
|
|
1313
1732
|
for (a = 0; a < h_4.length; a += 3)
|
|
1314
1733
|
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
1734
|
s += h_4.length / 3;
|
|
1316
1735
|
}
|
|
1317
1736
|
} return [Float32Array.from(o), Uint32Array.from(l)]; }
|
|
1318
|
-
function
|
|
1737
|
+
function dt(e) {
|
|
1319
1738
|
var _a;
|
|
1320
1739
|
var i = e instanceof t.Mesh ? e.getIndices(!1, !0) : e;
|
|
1321
1740
|
if (i)
|
|
1322
|
-
for (var
|
|
1323
|
-
_a = __read([i[
|
|
1741
|
+
for (var e_71 = 0; e_71 < i.length; e_71 += 3)
|
|
1742
|
+
_a = __read([i[e_71 + 2], i[e_71 + 1]], 2), i[e_71 + 1] = _a[0], i[e_71 + 2] = _a[1];
|
|
1324
1743
|
return i;
|
|
1325
1744
|
}
|
|
1326
|
-
function
|
|
1327
|
-
function
|
|
1328
|
-
throw new Error("At least one mesh is needed to create the nav mesh."); var _a = __read(
|
|
1329
|
-
throw new Error("Unable to get nav mesh. No vertices or indices."); var l = null !== (
|
|
1330
|
-
throw new Error("Unable to generateSoloNavMesh: ".concat(
|
|
1331
|
-
function
|
|
1745
|
+
function mt(e, i, r, n) { var _a = __read(Ze().getNavMeshPositionsAndIndices(e, n), 2), a = _a[0], s = _a[1], o = new t.Mesh("NavMeshDebug", i), l = new t.VertexData; return l.indices = dt(s), l.positions = a, l.applyToMesh(o, !1), r && (o.parent = r), o; }
|
|
1746
|
+
function pt(e, i) { var r, n; var a = Ze(); if (0 === e.length)
|
|
1747
|
+
throw new Error("At least one mesh is needed to create the nav mesh."); var _a = __read(ht(e, { doNotReverseIndices: i.doNotReverseIndices }), 2), s = _a[0], o = _a[1]; if (!s || !o)
|
|
1748
|
+
throw new Error("Unable to get nav mesh. No vertices or indices."); var l = null !== (r = i.tileSize) && void 0 !== r ? r : 0, c = (null !== (n = i.maxObstacles) && void 0 !== n ? n : 0) > 0, u = 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 ? Je(i) : u ? Ke(i) : Qe(i), d = c ? a.generateTileCache(s, o, h, i.keepIntermediates) : u ? a.generateTiledNavMesh(s, o, h, i.keepIntermediates) : a.generateSoloNavMesh(s, o, h, i.keepIntermediates); if (!d.success)
|
|
1749
|
+
throw new Error("Unable to generateSoloNavMesh: ".concat(d.error)); return { navMesh: d.navMesh, intermediates: d.intermediates, navMeshQuery: new a.NavMeshQuery(d.navMesh), tileCache: "tileCache" in d ? d.tileCache : void 0 }; }
|
|
1750
|
+
function ft(e) {
|
|
1332
1751
|
var _this = this;
|
|
1333
|
-
e.createNavMeshImpl = function (e, t) { return
|
|
1752
|
+
e.createNavMeshImpl = function (e, t) { return pt(e, t); }, e.createNavMeshAsyncImpl = function (e, t) { return i(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
1334
1753
|
switch (_a.label) {
|
|
1335
|
-
case 0: return [4 /*yield*/, new Promise(function (i) { i(
|
|
1754
|
+
case 0: return [4 /*yield*/, new Promise(function (i) { i(pt(e, t)); })];
|
|
1336
1755
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1337
1756
|
}
|
|
1338
1757
|
}); }); };
|
|
1339
1758
|
}
|
|
1340
|
-
var
|
|
1341
|
-
function
|
|
1342
|
-
this.name = "RecastNavigationJSPlugin", this._maximumSubStepCount = 10, this._timeStep = 1 / 60, this._timeFactor = 1, e || (e =
|
|
1759
|
+
var gt = /** @class */ (function () {
|
|
1760
|
+
function gt(e) {
|
|
1761
|
+
this.name = "RecastNavigationJSPlugin", this._maximumSubStepCount = 10, this._timeStep = 1 / 60, this._timeFactor = 1, e || (e = Ze(), ft(this)), this.bjsRECAST = e, this.isSupported() ? this.setTimeStep() : t.Logger.Error("RecastJS is not available. Please make sure you included the js file.");
|
|
1343
1762
|
}
|
|
1344
|
-
Object.defineProperty(
|
|
1763
|
+
Object.defineProperty(gt.prototype, "navMeshQuery", {
|
|
1345
1764
|
get: function () { return this._navMeshQuery; },
|
|
1346
1765
|
enumerable: false,
|
|
1347
1766
|
configurable: true
|
|
1348
1767
|
});
|
|
1349
|
-
Object.defineProperty(
|
|
1768
|
+
Object.defineProperty(gt.prototype, "intermediates", {
|
|
1350
1769
|
get: function () { return this._intermediates; },
|
|
1351
1770
|
enumerable: false,
|
|
1352
1771
|
configurable: true
|
|
1353
1772
|
});
|
|
1354
|
-
Object.defineProperty(
|
|
1773
|
+
Object.defineProperty(gt.prototype, "tileCache", {
|
|
1355
1774
|
get: function () { return this._tileCache; },
|
|
1356
1775
|
enumerable: false,
|
|
1357
1776
|
configurable: true
|
|
1358
1777
|
});
|
|
1359
|
-
|
|
1778
|
+
gt.prototype.setTimeStep = function (e) {
|
|
1360
1779
|
if (e === void 0) { e = 1 / 60; }
|
|
1361
1780
|
this._timeStep = e;
|
|
1362
1781
|
};
|
|
1363
|
-
|
|
1364
|
-
|
|
1782
|
+
gt.prototype.getTimeStep = function () { return this._timeStep; };
|
|
1783
|
+
gt.prototype.setMaximumSubStepCount = function (e) {
|
|
1365
1784
|
if (e === void 0) { e = 10; }
|
|
1366
1785
|
this._maximumSubStepCount = e;
|
|
1367
1786
|
};
|
|
1368
|
-
|
|
1369
|
-
Object.defineProperty(
|
|
1787
|
+
gt.prototype.getMaximumSubStepCount = function () { return this._maximumSubStepCount; };
|
|
1788
|
+
Object.defineProperty(gt.prototype, "timeFactor", {
|
|
1370
1789
|
get: function () { return this._timeFactor; },
|
|
1371
1790
|
set: function (e) { this._timeFactor = Math.max(e, 0); },
|
|
1372
1791
|
enumerable: false,
|
|
1373
1792
|
configurable: true
|
|
1374
1793
|
});
|
|
1375
|
-
|
|
1794
|
+
gt.prototype.createNavMesh = function (e, t) { if (!this.createNavMeshImpl)
|
|
1376
1795
|
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
|
-
|
|
1796
|
+
gt.prototype.createNavMeshAsync = function (e, t) { return i(this, void 0, void 0, function () { var i; return __generator(this, function (_a) {
|
|
1378
1797
|
switch (_a.label) {
|
|
1379
1798
|
case 0:
|
|
1380
1799
|
if (!this.createNavMeshAsyncImpl)
|
|
@@ -1386,746 +1805,782 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1386
1805
|
return [2 /*return*/, this._processNavMeshResult(i)];
|
|
1387
1806
|
}
|
|
1388
1807
|
}); }); };
|
|
1389
|
-
|
|
1390
|
-
throw new Error("There is no navMesh generated."); return this.navMesh && this._tileCache &&
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
if (
|
|
1397
|
-
var a = this._navMeshQuery.moveAlongSurface(
|
|
1808
|
+
gt.prototype.createDebugNavMesh = function (e) { if (!this.navMesh)
|
|
1809
|
+
throw new Error("There is no navMesh generated."); return this.navMesh && this._tileCache && Xe(this.navMesh, this._tileCache), mt(this.navMesh, e); };
|
|
1810
|
+
gt.prototype.getClosestPoint = function (e, i) { var r = this._navMeshQuery.findClosestPoint(e, i); return new t.Vector3(r.point.x, r.point.y, r.point.z); };
|
|
1811
|
+
gt.prototype.getClosestPointToRef = function (e, t, i) { var r = this._navMeshQuery.findClosestPoint(e, i); t.set(r.point.x, r.point.y, r.point.z); };
|
|
1812
|
+
gt.prototype.getRandomPointAround = function (e, i, r) { var n = this._navMeshQuery.findRandomPointAroundCircle(e, i, r); return new t.Vector3(n.randomPoint.x, n.randomPoint.y, n.randomPoint.z); };
|
|
1813
|
+
gt.prototype.getRandomPointAroundToRef = function (e, t, i, r) { var n = this._navMeshQuery.findRandomPointAroundCircle(e, t, r); i.set(n.randomPoint.x, n.randomPoint.y, n.randomPoint.z); };
|
|
1814
|
+
gt.prototype.moveAlong = function (e, i, r, n) {
|
|
1815
|
+
if (r === void 0) { r = 0; }
|
|
1816
|
+
var a = this._navMeshQuery.moveAlongSurface(r, e, i, n);
|
|
1398
1817
|
return new t.Vector3(a.resultPosition.x, a.resultPosition.y, a.resultPosition.z);
|
|
1399
1818
|
};
|
|
1400
|
-
|
|
1401
|
-
if (
|
|
1402
|
-
var a = this._navMeshQuery.moveAlongSurface(
|
|
1819
|
+
gt.prototype.moveAlongToRef = function (e, t, i, r, n) {
|
|
1820
|
+
if (r === void 0) { r = 0; }
|
|
1821
|
+
var a = this._navMeshQuery.moveAlongSurface(r, e, t, n);
|
|
1403
1822
|
i.set(a.resultPosition.x, a.resultPosition.y, a.resultPosition.z);
|
|
1404
1823
|
};
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1824
|
+
gt.prototype.computePath = function (e, t, i) { return rt(this._navMeshQuery.computePath(e, t, i)); };
|
|
1825
|
+
gt.prototype.computePathSmooth = function (e, i, r) { return this.navMesh ? st(this.navMesh, this._navMeshQuery, e, i, r) : (t.Logger.Error("No navmesh available. Cannot compute smooth path."), []); };
|
|
1826
|
+
gt.prototype.createCrowd = function (e, t, i) { var r = new it(this, e, t, i); return this._crowd = r, r; };
|
|
1827
|
+
gt.prototype.setDefaultQueryExtent = function (e) { this._navMeshQuery.defaultQueryHalfExtents = e; };
|
|
1828
|
+
gt.prototype.getDefaultQueryExtent = function () { return new t.Vector3(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z); };
|
|
1829
|
+
gt.prototype.getDefaultQueryExtentToRef = function (e) { e.set(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z); };
|
|
1830
|
+
gt.prototype.buildFromNavmeshData = function (e) { var t = this.bjsRECAST.importNavMesh(e); this.navMesh = t.navMesh, this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh); };
|
|
1831
|
+
gt.prototype.getNavmeshData = function () { if (!this.navMesh)
|
|
1413
1832
|
throw new Error("There is no NavMesh generated."); return this.bjsRECAST.exportNavMesh(this.navMesh); };
|
|
1414
|
-
|
|
1415
|
-
|
|
1833
|
+
gt.prototype.buildFromTileCacheData = function (e, t) { var i = this.bjsRECAST.importTileCache(e, null != t ? t : je([])); this.navMesh = i.navMesh, this._tileCache = i.tileCache, this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh); };
|
|
1834
|
+
gt.prototype.getTileCacheData = function () { if (!this.navMesh || !this._tileCache)
|
|
1416
1835
|
throw new Error("There is no TileCache generated."); return this.bjsRECAST.exportTileCache(this.navMesh, this._tileCache); };
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
if (
|
|
1420
|
-
var
|
|
1421
|
-
var s = null === (
|
|
1422
|
-
return (null == s ? void 0 : s.success) ? (!
|
|
1836
|
+
gt.prototype.dispose = function () { var e, t, i, r; 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 === (r = this._tileCache) || void 0 === r || r.destroy(); };
|
|
1837
|
+
gt.prototype.addCylinderObstacle = function (e, t, i, r) {
|
|
1838
|
+
if (r === void 0) { r = !1; }
|
|
1839
|
+
var n, a;
|
|
1840
|
+
var s = null === (n = this._tileCache) || void 0 === n ? void 0 : n.addCylinderObstacle(e, t, i);
|
|
1841
|
+
return (null == s ? void 0 : s.success) ? (!r && this.navMesh && this._tileCache && Xe(this.navMesh, this._tileCache), null !== (a = s.obstacle) && void 0 !== a ? a : null) : null;
|
|
1423
1842
|
};
|
|
1424
|
-
|
|
1425
|
-
if (
|
|
1426
|
-
var
|
|
1427
|
-
var s = null === (
|
|
1428
|
-
return (null == s ? void 0 : s.success) ? (!
|
|
1843
|
+
gt.prototype.addBoxObstacle = function (e, t, i, r) {
|
|
1844
|
+
if (r === void 0) { r = !1; }
|
|
1845
|
+
var n, a;
|
|
1846
|
+
var s = null === (n = this._tileCache) || void 0 === n ? void 0 : n.addBoxObstacle(e, t, i);
|
|
1847
|
+
return (null == s ? void 0 : s.success) ? (!r && this.navMesh && this._tileCache && Xe(this.navMesh, this._tileCache), null !== (a = s.obstacle) && void 0 !== a ? a : null) : null;
|
|
1429
1848
|
};
|
|
1430
|
-
|
|
1849
|
+
gt.prototype.removeObstacle = function (e, t) {
|
|
1431
1850
|
if (t === void 0) { t = !1; }
|
|
1432
1851
|
var i;
|
|
1433
|
-
null === (i = this._tileCache) || void 0 === i || i.removeObstacle(e), !t && this.navMesh && this._tileCache &&
|
|
1852
|
+
null === (i = this._tileCache) || void 0 === i || i.removeObstacle(e), !t && this.navMesh && this._tileCache && Xe(this.navMesh, this._tileCache);
|
|
1434
1853
|
};
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1854
|
+
gt.prototype.isSupported = function () { return !!this.bjsRECAST; };
|
|
1855
|
+
gt.prototype.getRandomSeed = function () { return this.bjsRECAST.getRandomSeed(); };
|
|
1856
|
+
gt.prototype.setRandomSeed = function (e) { this.bjsRECAST.setRandomSeed(e); };
|
|
1857
|
+
gt.prototype.raycast = function (e, i) { var r; var n = this._navMeshQuery.findNearestPoly(e), a = this._navMeshQuery.raycast(n.nearestRef, e, i); if (0 < a.t && a.t < 1) {
|
|
1439
1858
|
t.TmpVectors.Vector3[0].set(e.x, e.y, e.z), t.TmpVectors.Vector3[1].set(i.x, i.y, i.z);
|
|
1440
|
-
var
|
|
1441
|
-
return { hit: !0, hitPoint: t.TmpVectors.Vector3[0].add(
|
|
1859
|
+
var n_10 = t.Vector3.Distance(t.TmpVectors.Vector3[0], t.TmpVectors.Vector3[1]) * (null !== (r = null == a ? void 0 : a.t) && void 0 !== r ? r : 0), s_6 = t.TmpVectors.Vector3[1].subtract(t.TmpVectors.Vector3[0]).normalize();
|
|
1860
|
+
return { hit: !0, hitPoint: t.TmpVectors.Vector3[0].add(s_6.multiplyByFloats(n_10, n_10, n_10)) };
|
|
1442
1861
|
} return { hit: !1 }; };
|
|
1443
|
-
|
|
1444
|
-
|
|
1862
|
+
gt.prototype.moveAlongWithVelocity = function (e, t, i) { var _a = this._navMeshQuery.findClosestPoint({ x: e.x, y: e.y, z: e.z }, i), r = _a.point, n = _a.polyRef, a = this._navMeshQuery.moveAlongSurface(n, r, { x: r.x + t.x, y: r.y + t.y, z: r.z + t.z }, i).resultPosition, s = this._navMeshQuery.getPolyHeight(n, a); return { position: { x: a.x, y: s.success ? s.height : a.y, z: a.z }, polyRef: n, height: s.height }; };
|
|
1863
|
+
gt.prototype._processNavMeshResult = function (e) { if (!(null == e ? void 0 : e.navMesh) || !(null == e ? void 0 : e.navMeshQuery))
|
|
1445
1864
|
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
|
-
|
|
1447
|
-
return
|
|
1865
|
+
gt.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); };
|
|
1866
|
+
return gt;
|
|
1448
1867
|
}());
|
|
1449
|
-
function
|
|
1450
|
-
var
|
|
1451
|
-
var
|
|
1452
|
-
function
|
|
1453
|
-
var
|
|
1868
|
+
function vt(e, t) { var i = e.x, r = e.z, n = t.x, a = t.z; var s; return s = Math.abs(n - i) >= Math.abs(a - r) ? { x: n, z: r } : { x: i, z: a }, s; }
|
|
1869
|
+
var _t = { 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" };
|
|
1870
|
+
var St = /** @class */ (function () {
|
|
1871
|
+
function St(e, i) {
|
|
1872
|
+
var r, n, a, s;
|
|
1454
1873
|
this._scene = e, this.lineMaterials = [], this.getIntermediates = function (e) {
|
|
1455
|
-
var
|
|
1456
|
-
var t = [], i = [],
|
|
1874
|
+
var e_72, _a, e_73, _b;
|
|
1875
|
+
var t = [], i = [], r = [], n = [], a = [];
|
|
1457
1876
|
if (e)
|
|
1458
1877
|
if ("solo" === e.type)
|
|
1459
|
-
e.heightfield && t.push(e.heightfield), e.compactHeightfield && i.push(e.compactHeightfield), e.contourSet &&
|
|
1878
|
+
e.heightfield && t.push(e.heightfield), e.compactHeightfield && i.push(e.compactHeightfield), e.contourSet && r.push(e.contourSet), e.polyMesh && n.push(e.polyMesh), e.polyMeshDetail && a.push(e.polyMeshDetail);
|
|
1460
1879
|
else if ("tiled" === e.type)
|
|
1461
1880
|
try {
|
|
1462
1881
|
for (var _c = __values(e.tileIntermediates), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1463
|
-
var
|
|
1464
|
-
|
|
1882
|
+
var s_7 = _d.value;
|
|
1883
|
+
s_7.heightfield && t.push(s_7.heightfield), s_7.compactHeightfield && i.push(s_7.compactHeightfield), s_7.contourSet && r.push(s_7.contourSet), s_7.polyMesh && n.push(s_7.polyMesh), s_7.polyMeshDetail && a.push(s_7.polyMeshDetail);
|
|
1465
1884
|
}
|
|
1466
1885
|
}
|
|
1467
|
-
catch (
|
|
1886
|
+
catch (e_72_1) { e_72 = { error: e_72_1 }; }
|
|
1468
1887
|
finally {
|
|
1469
1888
|
try {
|
|
1470
1889
|
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
1471
1890
|
}
|
|
1472
|
-
finally { if (
|
|
1891
|
+
finally { if (e_72) throw e_72.error; }
|
|
1473
1892
|
}
|
|
1474
1893
|
else if ("tilecache" === e.type)
|
|
1475
1894
|
try {
|
|
1476
1895
|
for (var _f = __values(e.tileIntermediates), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1477
|
-
var
|
|
1478
|
-
|
|
1896
|
+
var r_14 = _g.value;
|
|
1897
|
+
r_14.heightfield && t.push(r_14.heightfield), r_14.compactHeightfield && i.push(r_14.compactHeightfield);
|
|
1479
1898
|
}
|
|
1480
1899
|
}
|
|
1481
|
-
catch (
|
|
1900
|
+
catch (e_73_1) { e_73 = { error: e_73_1 }; }
|
|
1482
1901
|
finally {
|
|
1483
1902
|
try {
|
|
1484
1903
|
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1485
1904
|
}
|
|
1486
|
-
finally { if (
|
|
1905
|
+
finally { if (e_73) throw e_73.error; }
|
|
1487
1906
|
}
|
|
1488
|
-
return { heightfieldList: t, compactHeightfieldList: i, contourSetList:
|
|
1489
|
-
}, this._debugDrawerUtils = new (
|
|
1907
|
+
return { heightfieldList: t, compactHeightfieldList: i, contourSetList: r, polyMeshList: n, polyMeshDetailList: a };
|
|
1908
|
+
}, this._debugDrawerUtils = new (Ze().DebugDrawerUtils), this._primitiveTypes = null !== (r = null == i ? void 0 : i.primitiveTypes) && void 0 !== r ? r : ["points", "lines", "tris", "quads"], this.debugDrawerParentNode = (null === (n = null == i ? void 0 : i.parent) || void 0 === n ? void 0 : n.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
1909
|
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(
|
|
1910
|
+
(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(St.NAV_MESH_DEBUG_NAME_POINTS, { size: .02 });
|
|
1492
1911
|
}
|
|
1493
|
-
Object.defineProperty(
|
|
1912
|
+
Object.defineProperty(St.prototype, "primitiveTypes", {
|
|
1494
1913
|
get: function () { return this._primitiveTypes; },
|
|
1495
1914
|
set: function (e) { this._primitiveTypes = e; },
|
|
1496
1915
|
enumerable: false,
|
|
1497
1916
|
configurable: true
|
|
1498
1917
|
});
|
|
1499
|
-
|
|
1500
|
-
var
|
|
1918
|
+
St.prototype.clear = function () {
|
|
1919
|
+
var e_74, _a;
|
|
1501
1920
|
try {
|
|
1502
1921
|
for (var _b = __values(this.debugDrawerParentNode.getChildMeshes()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1503
|
-
var
|
|
1504
|
-
|
|
1922
|
+
var e_75 = _c.value;
|
|
1923
|
+
e_75.dispose();
|
|
1505
1924
|
}
|
|
1506
1925
|
}
|
|
1507
|
-
catch (
|
|
1926
|
+
catch (e_74_1) { e_74 = { error: e_74_1 }; }
|
|
1508
1927
|
finally {
|
|
1509
1928
|
try {
|
|
1510
1929
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1511
1930
|
}
|
|
1512
|
-
finally { if (
|
|
1931
|
+
finally { if (e_74) throw e_74.error; }
|
|
1513
1932
|
}
|
|
1514
1933
|
};
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
var
|
|
1934
|
+
St.prototype.dispose = function () { this.clear(), this._debugDrawerUtils.dispose(), this._pointMesh.dispose(), this.triMaterial.dispose(), this.pointMaterial.dispose(); };
|
|
1935
|
+
St.prototype.drawPrimitives = function (e, t) {
|
|
1936
|
+
var e_76, _a;
|
|
1518
1937
|
var i;
|
|
1519
|
-
var
|
|
1938
|
+
var r = null;
|
|
1520
1939
|
try {
|
|
1521
|
-
for (var
|
|
1522
|
-
var
|
|
1523
|
-
if (this._primitiveTypes.includes(
|
|
1524
|
-
switch (
|
|
1940
|
+
for (var e_77 = __values(e), e_77_1 = e_77.next(); !e_77_1.done; e_77_1 = e_77.next()) {
|
|
1941
|
+
var t_22 = e_77_1.value;
|
|
1942
|
+
if (this._primitiveTypes.includes(t_22.type))
|
|
1943
|
+
switch (t_22.type) {
|
|
1525
1944
|
case "points":
|
|
1526
|
-
this._drawPoints(
|
|
1945
|
+
this._drawPoints(t_22);
|
|
1527
1946
|
break;
|
|
1528
1947
|
case "lines": {
|
|
1529
|
-
var
|
|
1530
|
-
|
|
1948
|
+
var e_78 = this._drawLines(t_22, r);
|
|
1949
|
+
r || (r = e_78);
|
|
1531
1950
|
break;
|
|
1532
1951
|
}
|
|
1533
1952
|
case "tris":
|
|
1534
|
-
this._drawTris(
|
|
1953
|
+
this._drawTris(t_22);
|
|
1535
1954
|
break;
|
|
1536
|
-
case "quads": this._drawQuads(
|
|
1955
|
+
case "quads": this._drawQuads(t_22);
|
|
1537
1956
|
}
|
|
1538
1957
|
}
|
|
1539
1958
|
}
|
|
1540
|
-
catch (
|
|
1959
|
+
catch (e_76_1) { e_76 = { error: e_76_1 }; }
|
|
1541
1960
|
finally {
|
|
1542
1961
|
try {
|
|
1543
|
-
if (
|
|
1962
|
+
if (e_77_1 && !e_77_1.done && (_a = e_77.return)) _a.call(e_77);
|
|
1544
1963
|
}
|
|
1545
|
-
finally { if (
|
|
1964
|
+
finally { if (e_76) throw e_76.error; }
|
|
1546
1965
|
}
|
|
1547
|
-
null ==
|
|
1966
|
+
null == r || r.updateLazy(), (null === (i = null == t ? void 0 : t.joinMeshes) || void 0 === i || i) && this._joinDebugMeshes();
|
|
1548
1967
|
};
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1968
|
+
St.prototype.drawHeightfieldSolid = function (e) { var t = this._debugDrawerUtils.drawHeightfieldSolid(e); this.drawPrimitives(t); };
|
|
1969
|
+
St.prototype.drawHeightfieldWalkable = function (e) { var t = this._debugDrawerUtils.drawHeightfieldWalkable(e); this.drawPrimitives(t); };
|
|
1970
|
+
St.prototype.drawCompactHeightfieldSolid = function (e) { var t = this._debugDrawerUtils.drawCompactHeightfieldSolid(e); this.drawPrimitives(t); };
|
|
1971
|
+
St.prototype.drawCompactHeightfieldRegions = function (e) { var t = this._debugDrawerUtils.drawCompactHeightfieldRegions(e); this.drawPrimitives(t); };
|
|
1972
|
+
St.prototype.drawCompactHeightfieldDistance = function (e) { var t = this._debugDrawerUtils.drawCompactHeightfieldDistance(e); this.drawPrimitives(t); };
|
|
1973
|
+
St.prototype.drawHeightfieldLayer = function (e, t) { var i = this._debugDrawerUtils.drawHeightfieldLayer(e, t); this.drawPrimitives(i); };
|
|
1974
|
+
St.prototype.drawHeightfieldLayers = function (e) { var t = this._debugDrawerUtils.drawHeightfieldLayers(e); this.drawPrimitives(t); };
|
|
1975
|
+
St.prototype.drawRegionConnections = function (e, t) {
|
|
1557
1976
|
if (t === void 0) { t = 1; }
|
|
1558
1977
|
var i = this._debugDrawerUtils.drawRegionConnections(e, t);
|
|
1559
1978
|
this.drawPrimitives(i);
|
|
1560
1979
|
};
|
|
1561
|
-
|
|
1980
|
+
St.prototype.drawRawContours = function (e, t) {
|
|
1562
1981
|
if (t === void 0) { t = 1; }
|
|
1563
1982
|
var i = this._debugDrawerUtils.drawRawContours(e, t);
|
|
1564
1983
|
this.drawPrimitives(i);
|
|
1565
1984
|
};
|
|
1566
|
-
|
|
1985
|
+
St.prototype.drawContours = function (e, t) {
|
|
1567
1986
|
if (t === void 0) { t = 1; }
|
|
1568
1987
|
var i = this._debugDrawerUtils.drawContours(e, t);
|
|
1569
1988
|
this.drawPrimitives(i);
|
|
1570
1989
|
};
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1990
|
+
St.prototype.drawPolyMesh = function (e) { var t = this._debugDrawerUtils.drawPolyMesh(e); this.drawPrimitives(t); };
|
|
1991
|
+
St.prototype.drawPolyMeshDetail = function (e) { var t = this._debugDrawerUtils.drawPolyMeshDetail(e); this.drawPrimitives(t); };
|
|
1992
|
+
St.prototype.drawNavMesh = function (e, t) {
|
|
1574
1993
|
if (t === void 0) { t = 0; }
|
|
1575
1994
|
var i = this._debugDrawerUtils.drawNavMesh(e, t);
|
|
1576
1995
|
this.drawPrimitives(i);
|
|
1577
1996
|
};
|
|
1578
|
-
|
|
1997
|
+
St.prototype.drawNavMeshWithClosedList = function (e, t, i) {
|
|
1579
1998
|
if (i === void 0) { i = 0; }
|
|
1580
|
-
var
|
|
1581
|
-
this.drawPrimitives(
|
|
1999
|
+
var r = this._debugDrawerUtils.drawNavMeshWithClosedList(e, t, i);
|
|
2000
|
+
this.drawPrimitives(r);
|
|
1582
2001
|
};
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
var
|
|
2002
|
+
St.prototype.drawNavMeshNodes = function (e) { var t = this._debugDrawerUtils.drawNavMeshNodes(e); this.drawPrimitives(t); };
|
|
2003
|
+
St.prototype.drawNavMeshBVTree = function (e) { var t = this._debugDrawerUtils.drawNavMeshBVTree(e); this.drawPrimitives(t); };
|
|
2004
|
+
St.prototype.drawNavMeshPortals = function (e) { var t = this._debugDrawerUtils.drawNavMeshPortals(e); this.drawPrimitives(t); };
|
|
2005
|
+
St.prototype.drawNavMeshPolysWithFlags = function (e, t, i) { var r = this._debugDrawerUtils.drawNavMeshPolysWithFlags(e, t, i); this.drawPrimitives(r); };
|
|
2006
|
+
St.prototype.drawNavMeshPoly = function (e, t, i) { var r = this._debugDrawerUtils.drawNavMeshPoly(e, t, i); this.drawPrimitives(r); };
|
|
2007
|
+
St.prototype.draw = function (e, t, i, r) {
|
|
2008
|
+
var e_79, _a, e_80, _b, e_81, _c, e_82, _d, e_83, _f, e_84, _g, e_85, _h, e_86, _j, e_87, _k;
|
|
1590
2009
|
this.clear();
|
|
1591
|
-
var _l = this.getIntermediates(t),
|
|
1592
|
-
if (
|
|
2010
|
+
var _l = this.getIntermediates(t), n = _l.heightfieldList, a = _l.compactHeightfieldList, s = _l.contourSetList, o = _l.polyMeshList, l = _l.polyMeshDetailList;
|
|
2011
|
+
if (r === _t.HEIGHTFIELD_SOLID)
|
|
1593
2012
|
try {
|
|
1594
|
-
for (var
|
|
1595
|
-
var
|
|
1596
|
-
this.drawHeightfieldSolid(
|
|
2013
|
+
for (var n_11 = __values(n), n_11_1 = n_11.next(); !n_11_1.done; n_11_1 = n_11.next()) {
|
|
2014
|
+
var e_88 = n_11_1.value;
|
|
2015
|
+
this.drawHeightfieldSolid(e_88);
|
|
1597
2016
|
}
|
|
1598
2017
|
}
|
|
1599
|
-
catch (
|
|
2018
|
+
catch (e_79_1) { e_79 = { error: e_79_1 }; }
|
|
1600
2019
|
finally {
|
|
1601
2020
|
try {
|
|
1602
|
-
if (
|
|
2021
|
+
if (n_11_1 && !n_11_1.done && (_a = n_11.return)) _a.call(n_11);
|
|
1603
2022
|
}
|
|
1604
|
-
finally { if (
|
|
2023
|
+
finally { if (e_79) throw e_79.error; }
|
|
1605
2024
|
}
|
|
1606
|
-
else if (
|
|
2025
|
+
else if (r === _t.HEIGHTFIELD_WALKABLE)
|
|
1607
2026
|
try {
|
|
1608
|
-
for (var
|
|
1609
|
-
var
|
|
1610
|
-
this.drawHeightfieldWalkable(
|
|
2027
|
+
for (var n_12 = __values(n), n_12_1 = n_12.next(); !n_12_1.done; n_12_1 = n_12.next()) {
|
|
2028
|
+
var e_89 = n_12_1.value;
|
|
2029
|
+
this.drawHeightfieldWalkable(e_89);
|
|
1611
2030
|
}
|
|
1612
2031
|
}
|
|
1613
|
-
catch (
|
|
2032
|
+
catch (e_80_1) { e_80 = { error: e_80_1 }; }
|
|
1614
2033
|
finally {
|
|
1615
2034
|
try {
|
|
1616
|
-
if (
|
|
2035
|
+
if (n_12_1 && !n_12_1.done && (_b = n_12.return)) _b.call(n_12);
|
|
1617
2036
|
}
|
|
1618
|
-
finally { if (
|
|
2037
|
+
finally { if (e_80) throw e_80.error; }
|
|
1619
2038
|
}
|
|
1620
|
-
else if (
|
|
2039
|
+
else if (r === _t.COMPACT_HEIGHTFIELD_SOLID)
|
|
1621
2040
|
try {
|
|
1622
|
-
for (var
|
|
1623
|
-
var
|
|
1624
|
-
this.drawCompactHeightfieldSolid(
|
|
2041
|
+
for (var a_8 = __values(a), a_8_1 = a_8.next(); !a_8_1.done; a_8_1 = a_8.next()) {
|
|
2042
|
+
var e_90 = a_8_1.value;
|
|
2043
|
+
this.drawCompactHeightfieldSolid(e_90);
|
|
1625
2044
|
}
|
|
1626
2045
|
}
|
|
1627
|
-
catch (
|
|
2046
|
+
catch (e_81_1) { e_81 = { error: e_81_1 }; }
|
|
1628
2047
|
finally {
|
|
1629
2048
|
try {
|
|
1630
|
-
if (
|
|
2049
|
+
if (a_8_1 && !a_8_1.done && (_c = a_8.return)) _c.call(a_8);
|
|
1631
2050
|
}
|
|
1632
|
-
finally { if (
|
|
2051
|
+
finally { if (e_81) throw e_81.error; }
|
|
1633
2052
|
}
|
|
1634
|
-
else if (
|
|
2053
|
+
else if (r === _t.COMPACT_HEIGHTFIELD_REGIONS)
|
|
1635
2054
|
try {
|
|
1636
|
-
for (var
|
|
1637
|
-
var
|
|
1638
|
-
this.drawCompactHeightfieldRegions(
|
|
2055
|
+
for (var a_9 = __values(a), a_9_1 = a_9.next(); !a_9_1.done; a_9_1 = a_9.next()) {
|
|
2056
|
+
var e_91 = a_9_1.value;
|
|
2057
|
+
this.drawCompactHeightfieldRegions(e_91);
|
|
1639
2058
|
}
|
|
1640
2059
|
}
|
|
1641
|
-
catch (
|
|
2060
|
+
catch (e_82_1) { e_82 = { error: e_82_1 }; }
|
|
1642
2061
|
finally {
|
|
1643
2062
|
try {
|
|
1644
|
-
if (
|
|
2063
|
+
if (a_9_1 && !a_9_1.done && (_d = a_9.return)) _d.call(a_9);
|
|
1645
2064
|
}
|
|
1646
|
-
finally { if (
|
|
2065
|
+
finally { if (e_82) throw e_82.error; }
|
|
1647
2066
|
}
|
|
1648
|
-
else if (
|
|
2067
|
+
else if (r === _t.COMPACT_HEIGHTFIELD_DISTANCE)
|
|
1649
2068
|
try {
|
|
1650
|
-
for (var
|
|
1651
|
-
var
|
|
1652
|
-
this.drawCompactHeightfieldDistance(
|
|
2069
|
+
for (var a_10 = __values(a), a_10_1 = a_10.next(); !a_10_1.done; a_10_1 = a_10.next()) {
|
|
2070
|
+
var e_92 = a_10_1.value;
|
|
2071
|
+
this.drawCompactHeightfieldDistance(e_92);
|
|
1653
2072
|
}
|
|
1654
2073
|
}
|
|
1655
|
-
catch (
|
|
2074
|
+
catch (e_83_1) { e_83 = { error: e_83_1 }; }
|
|
1656
2075
|
finally {
|
|
1657
2076
|
try {
|
|
1658
|
-
if (
|
|
2077
|
+
if (a_10_1 && !a_10_1.done && (_f = a_10.return)) _f.call(a_10);
|
|
1659
2078
|
}
|
|
1660
|
-
finally { if (
|
|
2079
|
+
finally { if (e_83) throw e_83.error; }
|
|
1661
2080
|
}
|
|
1662
|
-
else if (
|
|
2081
|
+
else if (r === _t.RAW_CONTOURS)
|
|
1663
2082
|
try {
|
|
1664
|
-
for (var
|
|
1665
|
-
var
|
|
1666
|
-
this.drawRawContours(
|
|
2083
|
+
for (var s_8 = __values(s), s_8_1 = s_8.next(); !s_8_1.done; s_8_1 = s_8.next()) {
|
|
2084
|
+
var e_93 = s_8_1.value;
|
|
2085
|
+
this.drawRawContours(e_93);
|
|
1667
2086
|
}
|
|
1668
2087
|
}
|
|
1669
|
-
catch (
|
|
2088
|
+
catch (e_84_1) { e_84 = { error: e_84_1 }; }
|
|
1670
2089
|
finally {
|
|
1671
2090
|
try {
|
|
1672
|
-
if (
|
|
2091
|
+
if (s_8_1 && !s_8_1.done && (_g = s_8.return)) _g.call(s_8);
|
|
1673
2092
|
}
|
|
1674
|
-
finally { if (
|
|
2093
|
+
finally { if (e_84) throw e_84.error; }
|
|
1675
2094
|
}
|
|
1676
|
-
else if (
|
|
2095
|
+
else if (r === _t.CONTOURS)
|
|
1677
2096
|
try {
|
|
1678
|
-
for (var
|
|
1679
|
-
var
|
|
1680
|
-
this.drawContours(
|
|
2097
|
+
for (var s_9 = __values(s), s_9_1 = s_9.next(); !s_9_1.done; s_9_1 = s_9.next()) {
|
|
2098
|
+
var e_94 = s_9_1.value;
|
|
2099
|
+
this.drawContours(e_94);
|
|
1681
2100
|
}
|
|
1682
2101
|
}
|
|
1683
|
-
catch (
|
|
2102
|
+
catch (e_85_1) { e_85 = { error: e_85_1 }; }
|
|
1684
2103
|
finally {
|
|
1685
2104
|
try {
|
|
1686
|
-
if (
|
|
2105
|
+
if (s_9_1 && !s_9_1.done && (_h = s_9.return)) _h.call(s_9);
|
|
1687
2106
|
}
|
|
1688
|
-
finally { if (
|
|
2107
|
+
finally { if (e_85) throw e_85.error; }
|
|
1689
2108
|
}
|
|
1690
|
-
else if (
|
|
2109
|
+
else if (r === _t.POLY_MESH)
|
|
1691
2110
|
try {
|
|
1692
|
-
for (var
|
|
1693
|
-
var
|
|
1694
|
-
this.drawPolyMesh(
|
|
2111
|
+
for (var o_5 = __values(o), o_5_1 = o_5.next(); !o_5_1.done; o_5_1 = o_5.next()) {
|
|
2112
|
+
var e_95 = o_5_1.value;
|
|
2113
|
+
this.drawPolyMesh(e_95);
|
|
1695
2114
|
}
|
|
1696
2115
|
}
|
|
1697
|
-
catch (
|
|
2116
|
+
catch (e_86_1) { e_86 = { error: e_86_1 }; }
|
|
1698
2117
|
finally {
|
|
1699
2118
|
try {
|
|
1700
|
-
if (
|
|
2119
|
+
if (o_5_1 && !o_5_1.done && (_j = o_5.return)) _j.call(o_5);
|
|
1701
2120
|
}
|
|
1702
|
-
finally { if (
|
|
2121
|
+
finally { if (e_86) throw e_86.error; }
|
|
1703
2122
|
}
|
|
1704
|
-
else if (
|
|
2123
|
+
else if (r === _t.POLY_MESH_DETAIL)
|
|
1705
2124
|
try {
|
|
1706
2125
|
for (var l_5 = __values(l), l_5_1 = l_5.next(); !l_5_1.done; l_5_1 = l_5.next()) {
|
|
1707
|
-
var
|
|
1708
|
-
this.drawPolyMeshDetail(
|
|
2126
|
+
var e_96 = l_5_1.value;
|
|
2127
|
+
this.drawPolyMeshDetail(e_96);
|
|
1709
2128
|
}
|
|
1710
2129
|
}
|
|
1711
|
-
catch (
|
|
2130
|
+
catch (e_87_1) { e_87 = { error: e_87_1 }; }
|
|
1712
2131
|
finally {
|
|
1713
2132
|
try {
|
|
1714
2133
|
if (l_5_1 && !l_5_1.done && (_k = l_5.return)) _k.call(l_5);
|
|
1715
2134
|
}
|
|
1716
|
-
finally { if (
|
|
2135
|
+
finally { if (e_87) throw e_87.error; }
|
|
1717
2136
|
}
|
|
1718
2137
|
else
|
|
1719
|
-
|
|
2138
|
+
r === _t.NAVMESH ? this.drawNavMesh(e) : r === _t.NAVMESH_BV_TREE && this.drawNavMeshBVTree(e);
|
|
1720
2139
|
};
|
|
1721
|
-
|
|
1722
|
-
return; var i = new Float32Array(16 * e.vertices.length),
|
|
1723
|
-
var _a = __read(e.vertices[
|
|
1724
|
-
|
|
1725
|
-
} this._pointMesh.thinInstanceSetBuffer("matrix", i, 16), this._pointMesh.thinInstanceSetBuffer("color",
|
|
1726
|
-
|
|
1727
|
-
return null; var
|
|
1728
|
-
var _a = __read(e.vertices[i_15], 6),
|
|
1729
|
-
|
|
1730
|
-
} var a = Object.assign(Object.assign({}, this._lineMaterialOptions.greasedLineMeshOptions), { points:
|
|
1731
|
-
|
|
1732
|
-
return; var i = new Float32Array(3 * e.vertices.length),
|
|
1733
|
-
var _a = __read(e.vertices[
|
|
1734
|
-
i[3 *
|
|
1735
|
-
} var
|
|
1736
|
-
|
|
1737
|
-
var
|
|
2140
|
+
St.prototype._drawPoints = function (e) { if (0 === e.vertices.length)
|
|
2141
|
+
return; var i = new Float32Array(16 * e.vertices.length), r = new Float32Array(4 * e.vertices.length); for (var n_13 = 0; n_13 < e.vertices.length; n_13++) {
|
|
2142
|
+
var _a = __read(e.vertices[n_13], 7), a_11 = _a[0], s_10 = _a[1], o_6 = _a[2], l_6 = _a[3], c_5 = _a[4], u_4 = _a[5], h_5 = _a[6];
|
|
2143
|
+
r[4 * n_13] = l_6, r[4 * n_13 + 1] = c_5, r[4 * n_13 + 2] = u_4, r[4 * n_13 + 3] = h_5, t.Matrix.Translation(a_11, s_10, o_6).copyToArray(i, 16 * n_13);
|
|
2144
|
+
} this._pointMesh.thinInstanceSetBuffer("matrix", i, 16), this._pointMesh.thinInstanceSetBuffer("color", r, 4), this._pointMesh.parent = this.debugDrawerParentNode; };
|
|
2145
|
+
St.prototype._drawLines = function (e, i) { if (0 === e.vertices.length)
|
|
2146
|
+
return null; var r = [], n = []; for (var i_15 = 0; i_15 < e.vertices.length; i_15 += 2) {
|
|
2147
|
+
var _a = __read(e.vertices[i_15], 6), a_12 = _a[0], s_11 = _a[1], o_7 = _a[2], l_7 = _a[3], c_6 = _a[4], u_5 = _a[5], _b = __read(e.vertices[i_15 + 1], 6), h_6 = _b[0], d_4 = _b[1], m_3 = _b[2], p_4 = _b[3], f_3 = _b[4], g_2 = _b[5];
|
|
2148
|
+
r.push([a_12, s_11, o_7, h_6, d_4, m_3]), n.push(new t.Color3(l_7, c_6, u_5)), n.push(new t.Color3(p_4, f_3, g_2));
|
|
2149
|
+
} var a = Object.assign(Object.assign({}, this._lineMaterialOptions.greasedLineMeshOptions), { points: r, instance: null != i ? i : void 0 }), s = Object.assign(Object.assign({}, this._lineMaterialOptions.greasedLineMaterialOptions), { colors: n }), o = t.CreateGreasedLine(St.NAV_MESH_DEBUG_NAME_LINES, a, s); return o.parent = this.debugDrawerParentNode, this.lineMaterials.push(o.material), o; };
|
|
2150
|
+
St.prototype._drawTris = function (e) { if (0 === e.vertices.length)
|
|
2151
|
+
return; var i = new Float32Array(3 * e.vertices.length), r = new Float32Array(4 * e.vertices.length); for (var t_23 = 0; t_23 < e.vertices.length; t_23++) {
|
|
2152
|
+
var _a = __read(e.vertices[t_23], 6), n_14 = _a[0], a_13 = _a[1], s_12 = _a[2], o_8 = _a[3], l_8 = _a[4], c_7 = _a[5];
|
|
2153
|
+
i[3 * t_23 + 0] = n_14, i[3 * t_23 + 1] = a_13, i[3 * t_23 + 2] = s_12, r[4 * t_23 + 0] = o_8, r[4 * t_23 + 1] = l_8, r[4 * t_23 + 2] = c_7, r[4 * t_23 + 3] = 1;
|
|
2154
|
+
} var n = new t.VertexData; n.positions = i, n.colors = r; var a = new t.Mesh(St.NAV_MESH_DEBUG_NAME_TRIS); a.isUnIndexed = !0, n.applyToMesh(a), a.material = this.triMaterial, a.parent = this.debugDrawerParentNode; };
|
|
2155
|
+
St.prototype._drawQuads = function (e) {
|
|
2156
|
+
var e_97, _a;
|
|
1738
2157
|
if (0 === e.vertices.length)
|
|
1739
2158
|
return;
|
|
1740
|
-
var i = [],
|
|
1741
|
-
for (var
|
|
1742
|
-
var
|
|
2159
|
+
var i = [], r = [];
|
|
2160
|
+
for (var t_24 = 0; t_24 < e.vertices.length; t_24 += 4) {
|
|
2161
|
+
var n_16 = [e.vertices[t_24], e.vertices[t_24 + 1], e.vertices[t_24 + 2], e.vertices[t_24], e.vertices[t_24 + 2], e.vertices[t_24 + 3]];
|
|
1743
2162
|
try {
|
|
1744
|
-
for (var
|
|
1745
|
-
var _b = __read(
|
|
1746
|
-
i.push(
|
|
2163
|
+
for (var n_15 = (e_97 = void 0, __values(n_16)), n_15_1 = n_15.next(); !n_15_1.done; n_15_1 = n_15.next()) {
|
|
2164
|
+
var _b = __read(n_15_1.value, 6), e_98 = _b[0], t_25 = _b[1], a_14 = _b[2], s_13 = _b[3], o_9 = _b[4], l_9 = _b[5];
|
|
2165
|
+
i.push(e_98, t_25, a_14), r.push(s_13, o_9, l_9, 1);
|
|
1747
2166
|
}
|
|
1748
2167
|
}
|
|
1749
|
-
catch (
|
|
2168
|
+
catch (e_97_1) { e_97 = { error: e_97_1 }; }
|
|
1750
2169
|
finally {
|
|
1751
2170
|
try {
|
|
1752
|
-
if (
|
|
2171
|
+
if (n_15_1 && !n_15_1.done && (_a = n_15.return)) _a.call(n_15);
|
|
1753
2172
|
}
|
|
1754
|
-
finally { if (
|
|
2173
|
+
finally { if (e_97) throw e_97.error; }
|
|
1755
2174
|
}
|
|
1756
2175
|
}
|
|
1757
|
-
var
|
|
1758
|
-
|
|
1759
|
-
var a = new t.Mesh(
|
|
1760
|
-
a.isUnIndexed = !0,
|
|
2176
|
+
var n = new t.VertexData;
|
|
2177
|
+
n.positions = i, n.colors = r;
|
|
2178
|
+
var a = new t.Mesh(St.NAV_MESH_DEBUG_NAME_QUADS);
|
|
2179
|
+
a.isUnIndexed = !0, n.applyToMesh(a), a.material = this.triMaterial, a.parent = this.debugDrawerParentNode;
|
|
1761
2180
|
};
|
|
1762
|
-
|
|
2181
|
+
St.prototype._joinDebugMeshes = function () {
|
|
1763
2182
|
var _this = this;
|
|
1764
|
-
var e = this._scene.meshes.filter(function (e) { return e.name ===
|
|
2183
|
+
var e = this._scene.meshes.filter(function (e) { return e.name === St.NAV_MESH_DEBUG_NAME; });
|
|
1765
2184
|
e.forEach(function (e) { _this._convertUnindexedToIndexed(e); });
|
|
1766
2185
|
var i = t.Mesh.MergeMeshes(e, !0);
|
|
1767
|
-
i && (i.name =
|
|
2186
|
+
i && (i.name = St.NAV_MESH_DEBUG_NAME, i.parent = this.debugDrawerParentNode);
|
|
1768
2187
|
};
|
|
1769
|
-
|
|
1770
|
-
return void t.Logger.Warn("Mesh must be fully unindexed with triangles."); var
|
|
1771
|
-
return
|
|
2188
|
+
St.prototype._convertUnindexedToIndexed = function (e) { var i = t.VertexData.ExtractFromMesh(e).positions; if (!i || i.length % 9 != 0)
|
|
2189
|
+
return void t.Logger.Warn("Mesh must be fully unindexed with triangles."); var r = i.length / 3, n = Array.from({ length: r }, function (e, t) { return t; }), a = new t.VertexData; a.positions = i, a.indices = n, a.applyToMesh(e, !0); };
|
|
2190
|
+
return St;
|
|
1772
2191
|
}());
|
|
1773
|
-
|
|
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[
|
|
1776
|
-
var
|
|
1777
|
-
var
|
|
1778
|
-
var
|
|
1779
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
1780
|
-
var
|
|
1781
|
-
var
|
|
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[
|
|
1784
|
-
var
|
|
1785
|
-
var
|
|
1786
|
-
var
|
|
1787
|
-
t.ShaderStore.IncludesShadersStore[
|
|
1788
|
-
var
|
|
1789
|
-
var
|
|
1790
|
-
var
|
|
1791
|
-
t.ShaderStore.IncludesShadersStore[
|
|
1792
|
-
var
|
|
1793
|
-
var
|
|
1794
|
-
var
|
|
1795
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
1796
|
-
var
|
|
2192
|
+
St.NAV_MESH_DEBUG_NAME = "nav-mesh-debug", St.NAV_MESH_DEBUG_NAME_POINTS = "nav-mesh-debug-points", St.NAV_MESH_DEBUG_NAME_TRIS = "nav-mesh-debug-tris", St.NAV_MESH_DEBUG_NAME_QUADS = "nav-mesh-debug-quads", St.NAV_MESH_DEBUG_NAME_LINES = "nav-mesh-debug-lines";
|
|
2193
|
+
var yt = "atmosphereFunctions", Tt = "#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";
|
|
2194
|
+
t.ShaderStore.IncludesShadersStoreWGSL[yt] || (t.ShaderStore.IncludesShadersStoreWGSL[yt] = Tt);
|
|
2195
|
+
var At = { name: yt, shader: Tt };
|
|
2196
|
+
var Lt = { __proto__: null, atmosphereFunctionsWGSL: At };
|
|
2197
|
+
var Pt = "atmosphereUboDeclaration", Et = "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";
|
|
2198
|
+
t.ShaderStore.IncludesShadersStoreWGSL[Pt] || (t.ShaderStore.IncludesShadersStoreWGSL[Pt] = Et);
|
|
2199
|
+
var Rt = { name: Pt, shader: Et };
|
|
2200
|
+
var Ct = { __proto__: null, atmosphereUboDeclarationWGSL: Rt };
|
|
2201
|
+
var xt = "atmosphereFunctions", Mt = "#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";
|
|
2202
|
+
t.ShaderStore.IncludesShadersStore[xt] || (t.ShaderStore.IncludesShadersStore[xt] = Mt);
|
|
2203
|
+
var It = { name: xt, shader: Mt };
|
|
2204
|
+
var wt = { __proto__: null, atmosphereFunctions: It };
|
|
2205
|
+
var bt = "atmosphereUboDeclaration", Ot = "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";
|
|
2206
|
+
t.ShaderStore.IncludesShadersStore[bt] || (t.ShaderStore.IncludesShadersStore[bt] = Ot);
|
|
2207
|
+
var Dt = { name: bt, shader: Ot };
|
|
2208
|
+
var Nt = { __proto__: null, atmosphereUboDeclaration: Dt };
|
|
2209
|
+
var Ut = "atmosphereFragmentDeclaration", Ft = "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";
|
|
2210
|
+
t.ShaderStore.IncludesShadersStore[Ut] || (t.ShaderStore.IncludesShadersStore[Ut] = Ft);
|
|
2211
|
+
var Vt = { name: Ut, shader: Ft };
|
|
2212
|
+
var Gt = { __proto__: null, atmosphereFragmentDeclaration: Vt };
|
|
2213
|
+
var kt = "fullscreenTriangleVertexShader", zt = "#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";
|
|
2214
|
+
t.ShaderStore.ShadersStoreWGSL[kt] || (t.ShaderStore.ShadersStoreWGSL[kt] = zt);
|
|
2215
|
+
var Bt = [Rt];
|
|
1797
2216
|
try {
|
|
1798
|
-
for (var
|
|
1799
|
-
var
|
|
1800
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2217
|
+
for (var Bt_1 = __values(Bt), Bt_1_1 = Bt_1.next(); !Bt_1_1.done; Bt_1_1 = Bt_1.next()) {
|
|
2218
|
+
var e_99 = Bt_1_1.value;
|
|
2219
|
+
t.ShaderStore.IncludesShadersStoreWGSL[e_99.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_99.name] = e_99.shader);
|
|
1801
2220
|
}
|
|
1802
2221
|
}
|
|
1803
2222
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1804
2223
|
finally {
|
|
1805
2224
|
try {
|
|
1806
|
-
if (
|
|
2225
|
+
if (Bt_1_1 && !Bt_1_1.done && (_a = Bt_1.return)) _a.call(Bt_1);
|
|
1807
2226
|
}
|
|
1808
2227
|
finally { if (e_1) throw e_1.error; }
|
|
1809
2228
|
}
|
|
1810
|
-
var
|
|
1811
|
-
var
|
|
1812
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
1813
|
-
var
|
|
2229
|
+
var Wt = { __proto__: null, fullscreenTriangleVertexShaderWGSL: { name: kt, shader: zt } };
|
|
2230
|
+
var Ht = "diffuseSkyIrradiancePixelShader", qt = "#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";
|
|
2231
|
+
t.ShaderStore.ShadersStoreWGSL[Ht] || (t.ShaderStore.ShadersStoreWGSL[Ht] = qt);
|
|
2232
|
+
var Zt = [Rt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, At, t.importanceSamplingWGSL, t.pbrBRDFFunctionsWGSL, t.hdrFilteringFunctionsWGSL];
|
|
1814
2233
|
try {
|
|
1815
|
-
for (var
|
|
1816
|
-
var
|
|
1817
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2234
|
+
for (var Zt_1 = __values(Zt), Zt_1_1 = Zt_1.next(); !Zt_1_1.done; Zt_1_1 = Zt_1.next()) {
|
|
2235
|
+
var e_100 = Zt_1_1.value;
|
|
2236
|
+
t.ShaderStore.IncludesShadersStoreWGSL[e_100.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_100.name] = e_100.shader);
|
|
1818
2237
|
}
|
|
1819
2238
|
}
|
|
1820
2239
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1821
2240
|
finally {
|
|
1822
2241
|
try {
|
|
1823
|
-
if (
|
|
2242
|
+
if (Zt_1_1 && !Zt_1_1.done && (_b = Zt_1.return)) _b.call(Zt_1);
|
|
1824
2243
|
}
|
|
1825
2244
|
finally { if (e_2) throw e_2.error; }
|
|
1826
2245
|
}
|
|
1827
|
-
var
|
|
1828
|
-
var
|
|
1829
|
-
t.ShaderStore.ShadersStore[
|
|
1830
|
-
var
|
|
2246
|
+
var $t = { __proto__: null, diffuseSkyIrradiancePixelShaderWGSL: { name: Ht, shader: qt } };
|
|
2247
|
+
var Yt = "fullscreenTriangleVertexShader", jt = "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}";
|
|
2248
|
+
t.ShaderStore.ShadersStore[Yt] || (t.ShaderStore.ShadersStore[Yt] = jt);
|
|
2249
|
+
var Xt = [Vt, Dt];
|
|
1831
2250
|
try {
|
|
1832
|
-
for (var
|
|
1833
|
-
var
|
|
1834
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2251
|
+
for (var Xt_1 = __values(Xt), Xt_1_1 = Xt_1.next(); !Xt_1_1.done; Xt_1_1 = Xt_1.next()) {
|
|
2252
|
+
var e_101 = Xt_1_1.value;
|
|
2253
|
+
t.ShaderStore.IncludesShadersStore[e_101.name] || (t.ShaderStore.IncludesShadersStore[e_101.name] = e_101.shader);
|
|
1835
2254
|
}
|
|
1836
2255
|
}
|
|
1837
2256
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1838
2257
|
finally {
|
|
1839
2258
|
try {
|
|
1840
|
-
if (
|
|
2259
|
+
if (Xt_1_1 && !Xt_1_1.done && (_c = Xt_1.return)) _c.call(Xt_1);
|
|
1841
2260
|
}
|
|
1842
2261
|
finally { if (e_3) throw e_3.error; }
|
|
1843
2262
|
}
|
|
1844
|
-
var
|
|
1845
|
-
var
|
|
1846
|
-
t.ShaderStore.ShadersStore[
|
|
1847
|
-
var
|
|
2263
|
+
var Qt = { __proto__: null, fullscreenTriangleVertexShader: { name: Yt, shader: jt } };
|
|
2264
|
+
var Kt = "diffuseSkyIrradiancePixelShader", Jt = "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.);}";
|
|
2265
|
+
t.ShaderStore.ShadersStore[Kt] || (t.ShaderStore.ShadersStore[Kt] = Jt);
|
|
2266
|
+
var ei = [Vt, Dt, t.helperFunctions, t.intersectionFunctions, It, t.importanceSampling, t.pbrBRDFFunctions, t.hdrFilteringFunctions];
|
|
1848
2267
|
try {
|
|
1849
|
-
for (var
|
|
1850
|
-
var
|
|
1851
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2268
|
+
for (var ei_1 = __values(ei), ei_1_1 = ei_1.next(); !ei_1_1.done; ei_1_1 = ei_1.next()) {
|
|
2269
|
+
var e_102 = ei_1_1.value;
|
|
2270
|
+
t.ShaderStore.IncludesShadersStore[e_102.name] || (t.ShaderStore.IncludesShadersStore[e_102.name] = e_102.shader);
|
|
1852
2271
|
}
|
|
1853
2272
|
}
|
|
1854
2273
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
1855
2274
|
finally {
|
|
1856
2275
|
try {
|
|
1857
|
-
if (
|
|
2276
|
+
if (ei_1_1 && !ei_1_1.done && (_d = ei_1.return)) _d.call(ei_1);
|
|
1858
2277
|
}
|
|
1859
2278
|
finally { if (e_4) throw e_4.error; }
|
|
1860
2279
|
}
|
|
1861
|
-
var
|
|
1862
|
-
var
|
|
1863
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
1864
|
-
var
|
|
2280
|
+
var ti = { __proto__: null, diffuseSkyIrradiancePixelShader: { name: Kt, shader: Jt } };
|
|
2281
|
+
var ii = "transmittancePixelShader", ri = "#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";
|
|
2282
|
+
t.ShaderStore.ShadersStoreWGSL[ii] || (t.ShaderStore.ShadersStoreWGSL[ii] = ri);
|
|
2283
|
+
var ni = [Rt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, At];
|
|
1865
2284
|
try {
|
|
1866
|
-
for (var
|
|
1867
|
-
var
|
|
1868
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2285
|
+
for (var ni_1 = __values(ni), ni_1_1 = ni_1.next(); !ni_1_1.done; ni_1_1 = ni_1.next()) {
|
|
2286
|
+
var e_103 = ni_1_1.value;
|
|
2287
|
+
t.ShaderStore.IncludesShadersStoreWGSL[e_103.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_103.name] = e_103.shader);
|
|
1869
2288
|
}
|
|
1870
2289
|
}
|
|
1871
2290
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
1872
2291
|
finally {
|
|
1873
2292
|
try {
|
|
1874
|
-
if (
|
|
2293
|
+
if (ni_1_1 && !ni_1_1.done && (_f = ni_1.return)) _f.call(ni_1);
|
|
1875
2294
|
}
|
|
1876
2295
|
finally { if (e_5) throw e_5.error; }
|
|
1877
2296
|
}
|
|
1878
|
-
var
|
|
1879
|
-
var
|
|
1880
|
-
t.ShaderStore.ShadersStore[
|
|
1881
|
-
var
|
|
2297
|
+
var ai = { __proto__: null, transmittancePixelShaderWGSL: { name: ii, shader: ri } };
|
|
2298
|
+
var si = "transmittancePixelShader", oi = "#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);}";
|
|
2299
|
+
t.ShaderStore.ShadersStore[si] || (t.ShaderStore.ShadersStore[si] = oi);
|
|
2300
|
+
var li = [Vt, Dt, t.helperFunctions, t.intersectionFunctions, It];
|
|
1882
2301
|
try {
|
|
1883
|
-
for (var
|
|
1884
|
-
var
|
|
1885
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2302
|
+
for (var li_1 = __values(li), li_1_1 = li_1.next(); !li_1_1.done; li_1_1 = li_1.next()) {
|
|
2303
|
+
var e_104 = li_1_1.value;
|
|
2304
|
+
t.ShaderStore.IncludesShadersStore[e_104.name] || (t.ShaderStore.IncludesShadersStore[e_104.name] = e_104.shader);
|
|
1886
2305
|
}
|
|
1887
2306
|
}
|
|
1888
2307
|
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
1889
2308
|
finally {
|
|
1890
2309
|
try {
|
|
1891
|
-
if (
|
|
2310
|
+
if (li_1_1 && !li_1_1.done && (_g = li_1.return)) _g.call(li_1);
|
|
1892
2311
|
}
|
|
1893
2312
|
finally { if (e_6) throw e_6.error; }
|
|
1894
2313
|
}
|
|
1895
|
-
var
|
|
1896
|
-
var
|
|
1897
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
1898
|
-
var
|
|
2314
|
+
var ci = { __proto__: null, transmittancePixelShader: { name: si, shader: oi } };
|
|
2315
|
+
var ui = "multiScatteringPixelShader", hi = "#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";
|
|
2316
|
+
t.ShaderStore.ShadersStoreWGSL[ui] || (t.ShaderStore.ShadersStoreWGSL[ui] = hi);
|
|
2317
|
+
var di = [Rt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, At];
|
|
1899
2318
|
try {
|
|
1900
|
-
for (var
|
|
1901
|
-
var
|
|
1902
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2319
|
+
for (var di_1 = __values(di), di_1_1 = di_1.next(); !di_1_1.done; di_1_1 = di_1.next()) {
|
|
2320
|
+
var e_105 = di_1_1.value;
|
|
2321
|
+
t.ShaderStore.IncludesShadersStoreWGSL[e_105.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_105.name] = e_105.shader);
|
|
1903
2322
|
}
|
|
1904
2323
|
}
|
|
1905
2324
|
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
1906
2325
|
finally {
|
|
1907
2326
|
try {
|
|
1908
|
-
if (
|
|
2327
|
+
if (di_1_1 && !di_1_1.done && (_h = di_1.return)) _h.call(di_1);
|
|
1909
2328
|
}
|
|
1910
2329
|
finally { if (e_7) throw e_7.error; }
|
|
1911
2330
|
}
|
|
1912
|
-
var
|
|
1913
|
-
var
|
|
1914
|
-
t.ShaderStore.ShadersStore[
|
|
1915
|
-
var
|
|
2331
|
+
var mi = { __proto__: null, multiScatteringPixelShaderWGSL: { name: ui, shader: hi } };
|
|
2332
|
+
var pi = "multiScatteringPixelShader", fi = "#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);}";
|
|
2333
|
+
t.ShaderStore.ShadersStore[pi] || (t.ShaderStore.ShadersStore[pi] = fi);
|
|
2334
|
+
var gi = [Vt, Dt, t.helperFunctions, t.intersectionFunctions, It];
|
|
1916
2335
|
try {
|
|
1917
|
-
for (var
|
|
1918
|
-
var
|
|
1919
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2336
|
+
for (var gi_1 = __values(gi), gi_1_1 = gi_1.next(); !gi_1_1.done; gi_1_1 = gi_1.next()) {
|
|
2337
|
+
var e_106 = gi_1_1.value;
|
|
2338
|
+
t.ShaderStore.IncludesShadersStore[e_106.name] || (t.ShaderStore.IncludesShadersStore[e_106.name] = e_106.shader);
|
|
1920
2339
|
}
|
|
1921
2340
|
}
|
|
1922
2341
|
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
1923
2342
|
finally {
|
|
1924
2343
|
try {
|
|
1925
|
-
if (
|
|
2344
|
+
if (gi_1_1 && !gi_1_1.done && (_j = gi_1.return)) _j.call(gi_1);
|
|
1926
2345
|
}
|
|
1927
2346
|
finally { if (e_8) throw e_8.error; }
|
|
1928
2347
|
}
|
|
1929
|
-
var
|
|
1930
|
-
var
|
|
1931
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
1932
|
-
var
|
|
2348
|
+
var vi = { __proto__: null, multiScatteringPixelShader: { name: pi, shader: fi } };
|
|
2349
|
+
var _i = "compositeSkyPixelShader", Si = "#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";
|
|
2350
|
+
t.ShaderStore.ShadersStoreWGSL[_i] || (t.ShaderStore.ShadersStoreWGSL[_i] = Si);
|
|
2351
|
+
var yi = [Rt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, At];
|
|
1933
2352
|
try {
|
|
1934
|
-
for (var
|
|
1935
|
-
var
|
|
1936
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2353
|
+
for (var yi_1 = __values(yi), yi_1_1 = yi_1.next(); !yi_1_1.done; yi_1_1 = yi_1.next()) {
|
|
2354
|
+
var e_107 = yi_1_1.value;
|
|
2355
|
+
t.ShaderStore.IncludesShadersStoreWGSL[e_107.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_107.name] = e_107.shader);
|
|
1937
2356
|
}
|
|
1938
2357
|
}
|
|
1939
2358
|
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1940
2359
|
finally {
|
|
1941
2360
|
try {
|
|
1942
|
-
if (
|
|
2361
|
+
if (yi_1_1 && !yi_1_1.done && (_k = yi_1.return)) _k.call(yi_1);
|
|
1943
2362
|
}
|
|
1944
2363
|
finally { if (e_9) throw e_9.error; }
|
|
1945
2364
|
}
|
|
1946
|
-
var
|
|
1947
|
-
var
|
|
1948
|
-
t.ShaderStore.ShadersStore[
|
|
1949
|
-
var
|
|
2365
|
+
var Ti = { __proto__: null, compositeSkyPixelShaderWGSL: { name: _i, shader: Si } };
|
|
2366
|
+
var Ai = "compositeSkyPixelShader", Li = "#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}";
|
|
2367
|
+
t.ShaderStore.ShadersStore[Ai] || (t.ShaderStore.ShadersStore[Ai] = Li);
|
|
2368
|
+
var Pi = [Vt, Dt, t.helperFunctions, t.intersectionFunctions, It];
|
|
1950
2369
|
try {
|
|
1951
|
-
for (var
|
|
1952
|
-
var
|
|
1953
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2370
|
+
for (var Pi_1 = __values(Pi), Pi_1_1 = Pi_1.next(); !Pi_1_1.done; Pi_1_1 = Pi_1.next()) {
|
|
2371
|
+
var e_108 = Pi_1_1.value;
|
|
2372
|
+
t.ShaderStore.IncludesShadersStore[e_108.name] || (t.ShaderStore.IncludesShadersStore[e_108.name] = e_108.shader);
|
|
1954
2373
|
}
|
|
1955
2374
|
}
|
|
1956
2375
|
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1957
2376
|
finally {
|
|
1958
2377
|
try {
|
|
1959
|
-
if (
|
|
2378
|
+
if (Pi_1_1 && !Pi_1_1.done && (_l = Pi_1.return)) _l.call(Pi_1);
|
|
1960
2379
|
}
|
|
1961
2380
|
finally { if (e_10) throw e_10.error; }
|
|
1962
2381
|
}
|
|
1963
|
-
var
|
|
1964
|
-
var
|
|
1965
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
1966
|
-
var
|
|
2382
|
+
var Ei = { __proto__: null, compositeSkyPixelShader: { name: Ai, shader: Li } };
|
|
2383
|
+
var Ri = "aerialPerspectivePixelShader", Ci = "#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";
|
|
2384
|
+
t.ShaderStore.ShadersStoreWGSL[Ri] || (t.ShaderStore.ShadersStoreWGSL[Ri] = Ci);
|
|
2385
|
+
var xi = [Rt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, At];
|
|
1967
2386
|
try {
|
|
1968
|
-
for (var
|
|
1969
|
-
var
|
|
1970
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2387
|
+
for (var xi_1 = __values(xi), xi_1_1 = xi_1.next(); !xi_1_1.done; xi_1_1 = xi_1.next()) {
|
|
2388
|
+
var e_109 = xi_1_1.value;
|
|
2389
|
+
t.ShaderStore.IncludesShadersStoreWGSL[e_109.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_109.name] = e_109.shader);
|
|
1971
2390
|
}
|
|
1972
2391
|
}
|
|
1973
2392
|
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1974
2393
|
finally {
|
|
1975
2394
|
try {
|
|
1976
|
-
if (
|
|
2395
|
+
if (xi_1_1 && !xi_1_1.done && (_m = xi_1.return)) _m.call(xi_1);
|
|
1977
2396
|
}
|
|
1978
2397
|
finally { if (e_11) throw e_11.error; }
|
|
1979
2398
|
}
|
|
1980
|
-
var
|
|
1981
|
-
var
|
|
1982
|
-
t.ShaderStore.ShadersStore[
|
|
1983
|
-
var
|
|
2399
|
+
var Mi = { __proto__: null, aerialPerspectivePixelShaderWGSL: { name: Ri, shader: Ci } };
|
|
2400
|
+
var Ii = "aerialPerspectivePixelShader", wi = "#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);}";
|
|
2401
|
+
t.ShaderStore.ShadersStore[Ii] || (t.ShaderStore.ShadersStore[Ii] = wi);
|
|
2402
|
+
var bi = [Vt, Dt, t.helperFunctions, t.intersectionFunctions, It];
|
|
1984
2403
|
try {
|
|
1985
|
-
for (var
|
|
1986
|
-
var
|
|
1987
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2404
|
+
for (var bi_1 = __values(bi), bi_1_1 = bi_1.next(); !bi_1_1.done; bi_1_1 = bi_1.next()) {
|
|
2405
|
+
var e_110 = bi_1_1.value;
|
|
2406
|
+
t.ShaderStore.IncludesShadersStore[e_110.name] || (t.ShaderStore.IncludesShadersStore[e_110.name] = e_110.shader);
|
|
1988
2407
|
}
|
|
1989
2408
|
}
|
|
1990
2409
|
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1991
2410
|
finally {
|
|
1992
2411
|
try {
|
|
1993
|
-
if (
|
|
2412
|
+
if (bi_1_1 && !bi_1_1.done && (_o = bi_1.return)) _o.call(bi_1);
|
|
1994
2413
|
}
|
|
1995
2414
|
finally { if (e_12) throw e_12.error; }
|
|
1996
2415
|
}
|
|
1997
|
-
var
|
|
1998
|
-
var
|
|
1999
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2000
|
-
var
|
|
2001
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2002
|
-
var
|
|
2416
|
+
var Oi = { __proto__: null, aerialPerspectivePixelShader: { name: Ii, shader: wi } };
|
|
2417
|
+
var Di = "depthFunctions", Ni = "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";
|
|
2418
|
+
t.ShaderStore.IncludesShadersStoreWGSL[Di] || (t.ShaderStore.IncludesShadersStoreWGSL[Di] = Ni);
|
|
2419
|
+
var Ui = { name: Di, shader: Ni }, Fi = "compositeAerialPerspectivePixelShader", Vi = "#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";
|
|
2420
|
+
t.ShaderStore.ShadersStoreWGSL[Fi] || (t.ShaderStore.ShadersStoreWGSL[Fi] = Vi);
|
|
2421
|
+
var Gi = [Rt, t.helperFunctionsWGSL, Ui, t.intersectionFunctionsWGSL, At];
|
|
2003
2422
|
try {
|
|
2004
|
-
for (var
|
|
2005
|
-
var
|
|
2006
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2423
|
+
for (var Gi_1 = __values(Gi), Gi_1_1 = Gi_1.next(); !Gi_1_1.done; Gi_1_1 = Gi_1.next()) {
|
|
2424
|
+
var e_111 = Gi_1_1.value;
|
|
2425
|
+
t.ShaderStore.IncludesShadersStoreWGSL[e_111.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_111.name] = e_111.shader);
|
|
2007
2426
|
}
|
|
2008
2427
|
}
|
|
2009
2428
|
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
2010
2429
|
finally {
|
|
2011
2430
|
try {
|
|
2012
|
-
if (
|
|
2431
|
+
if (Gi_1_1 && !Gi_1_1.done && (_p = Gi_1.return)) _p.call(Gi_1);
|
|
2013
2432
|
}
|
|
2014
2433
|
finally { if (e_13) throw e_13.error; }
|
|
2015
2434
|
}
|
|
2016
|
-
var
|
|
2017
|
-
var
|
|
2018
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2019
|
-
var
|
|
2020
|
-
t.ShaderStore.ShadersStore[
|
|
2021
|
-
var
|
|
2435
|
+
var ki = { __proto__: null, compositeAerialPerspectivePixelShaderWGSL: { name: Fi, shader: Vi } };
|
|
2436
|
+
var zi = "depthFunctions", Bi = "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);}";
|
|
2437
|
+
t.ShaderStore.IncludesShadersStore[zi] || (t.ShaderStore.IncludesShadersStore[zi] = Bi);
|
|
2438
|
+
var Wi = { name: zi, shader: Bi }, Hi = "compositeAerialPerspectivePixelShader", qi = "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}";
|
|
2439
|
+
t.ShaderStore.ShadersStore[Hi] || (t.ShaderStore.ShadersStore[Hi] = qi);
|
|
2440
|
+
var Zi = [Vt, Dt, t.helperFunctions, Wi, t.intersectionFunctions, It];
|
|
2022
2441
|
try {
|
|
2023
|
-
for (var
|
|
2024
|
-
var
|
|
2025
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2442
|
+
for (var Zi_1 = __values(Zi), Zi_1_1 = Zi_1.next(); !Zi_1_1.done; Zi_1_1 = Zi_1.next()) {
|
|
2443
|
+
var e_112 = Zi_1_1.value;
|
|
2444
|
+
t.ShaderStore.IncludesShadersStore[e_112.name] || (t.ShaderStore.IncludesShadersStore[e_112.name] = e_112.shader);
|
|
2026
2445
|
}
|
|
2027
2446
|
}
|
|
2028
2447
|
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
2029
2448
|
finally {
|
|
2030
2449
|
try {
|
|
2031
|
-
if (
|
|
2450
|
+
if (Zi_1_1 && !Zi_1_1.done && (_q = Zi_1.return)) _q.call(Zi_1);
|
|
2032
2451
|
}
|
|
2033
2452
|
finally { if (e_14) throw e_14.error; }
|
|
2034
2453
|
}
|
|
2035
|
-
var
|
|
2036
|
-
var
|
|
2037
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2038
|
-
var
|
|
2454
|
+
var $i = { __proto__: null, compositeAerialPerspectivePixelShader: { name: Hi, shader: qi } };
|
|
2455
|
+
var Yi = "compositeGlobeAtmospherePixelShader", ji = "#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";
|
|
2456
|
+
t.ShaderStore.ShadersStoreWGSL[Yi] || (t.ShaderStore.ShadersStoreWGSL[Yi] = ji);
|
|
2457
|
+
var Xi = [Rt, t.helperFunctionsWGSL, Ui, t.intersectionFunctionsWGSL, At];
|
|
2039
2458
|
try {
|
|
2040
|
-
for (var
|
|
2041
|
-
var
|
|
2042
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2459
|
+
for (var Xi_1 = __values(Xi), Xi_1_1 = Xi_1.next(); !Xi_1_1.done; Xi_1_1 = Xi_1.next()) {
|
|
2460
|
+
var e_113 = Xi_1_1.value;
|
|
2461
|
+
t.ShaderStore.IncludesShadersStoreWGSL[e_113.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_113.name] = e_113.shader);
|
|
2043
2462
|
}
|
|
2044
2463
|
}
|
|
2045
2464
|
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
2046
2465
|
finally {
|
|
2047
2466
|
try {
|
|
2048
|
-
if (
|
|
2467
|
+
if (Xi_1_1 && !Xi_1_1.done && (_s = Xi_1.return)) _s.call(Xi_1);
|
|
2049
2468
|
}
|
|
2050
2469
|
finally { if (e_15) throw e_15.error; }
|
|
2051
2470
|
}
|
|
2052
|
-
var
|
|
2053
|
-
var
|
|
2054
|
-
t.ShaderStore.ShadersStore[
|
|
2055
|
-
var
|
|
2471
|
+
var Qi = { __proto__: null, compositeGlobeAtmospherePixelShaderWGSL: { name: Yi, shader: ji } };
|
|
2472
|
+
var Ki = "compositeGlobeAtmospherePixelShader", Ji = "#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}";
|
|
2473
|
+
t.ShaderStore.ShadersStore[Ki] || (t.ShaderStore.ShadersStore[Ki] = Ji);
|
|
2474
|
+
var er = [Vt, Dt, t.helperFunctions, Wi, t.intersectionFunctions, It];
|
|
2056
2475
|
try {
|
|
2057
|
-
for (var
|
|
2058
|
-
var
|
|
2059
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2476
|
+
for (var er_1 = __values(er), er_1_1 = er_1.next(); !er_1_1.done; er_1_1 = er_1.next()) {
|
|
2477
|
+
var e_114 = er_1_1.value;
|
|
2478
|
+
t.ShaderStore.IncludesShadersStore[e_114.name] || (t.ShaderStore.IncludesShadersStore[e_114.name] = e_114.shader);
|
|
2060
2479
|
}
|
|
2061
2480
|
}
|
|
2062
2481
|
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
2063
2482
|
finally {
|
|
2064
2483
|
try {
|
|
2065
|
-
if (
|
|
2484
|
+
if (er_1_1 && !er_1_1.done && (_u = er_1.return)) _u.call(er_1);
|
|
2066
2485
|
}
|
|
2067
2486
|
finally { if (e_16) throw e_16.error; }
|
|
2068
2487
|
}
|
|
2069
|
-
var
|
|
2070
|
-
var
|
|
2071
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2072
|
-
var
|
|
2488
|
+
var tr = { __proto__: null, compositeGlobeAtmospherePixelShader: { name: Ki, shader: Ji } };
|
|
2489
|
+
var ir = "skyViewPixelShader", rr = "#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";
|
|
2490
|
+
t.ShaderStore.ShadersStoreWGSL[ir] || (t.ShaderStore.ShadersStoreWGSL[ir] = rr);
|
|
2491
|
+
var nr = [Rt, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, At];
|
|
2073
2492
|
try {
|
|
2074
|
-
for (var
|
|
2075
|
-
var
|
|
2076
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2493
|
+
for (var nr_1 = __values(nr), nr_1_1 = nr_1.next(); !nr_1_1.done; nr_1_1 = nr_1.next()) {
|
|
2494
|
+
var e_115 = nr_1_1.value;
|
|
2495
|
+
t.ShaderStore.IncludesShadersStoreWGSL[e_115.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_115.name] = e_115.shader);
|
|
2077
2496
|
}
|
|
2078
2497
|
}
|
|
2079
2498
|
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
2080
2499
|
finally {
|
|
2081
2500
|
try {
|
|
2082
|
-
if (
|
|
2501
|
+
if (nr_1_1 && !nr_1_1.done && (_v = nr_1.return)) _v.call(nr_1);
|
|
2083
2502
|
}
|
|
2084
2503
|
finally { if (e_17) throw e_17.error; }
|
|
2085
2504
|
}
|
|
2086
|
-
var
|
|
2087
|
-
var
|
|
2088
|
-
t.ShaderStore.ShadersStore[
|
|
2089
|
-
var
|
|
2505
|
+
var ar = { __proto__: null, skyViewPixelShaderWGSL: { name: ir, shader: rr } };
|
|
2506
|
+
var sr = "skyViewPixelShader", or = "#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);}";
|
|
2507
|
+
t.ShaderStore.ShadersStore[sr] || (t.ShaderStore.ShadersStore[sr] = or);
|
|
2508
|
+
var lr = [Vt, Dt, t.helperFunctions, t.intersectionFunctions, It];
|
|
2090
2509
|
try {
|
|
2091
|
-
for (var
|
|
2092
|
-
var
|
|
2093
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2510
|
+
for (var lr_1 = __values(lr), lr_1_1 = lr_1.next(); !lr_1_1.done; lr_1_1 = lr_1.next()) {
|
|
2511
|
+
var e_116 = lr_1_1.value;
|
|
2512
|
+
t.ShaderStore.IncludesShadersStore[e_116.name] || (t.ShaderStore.IncludesShadersStore[e_116.name] = e_116.shader);
|
|
2094
2513
|
}
|
|
2095
2514
|
}
|
|
2096
2515
|
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
2097
2516
|
finally {
|
|
2098
2517
|
try {
|
|
2099
|
-
if (
|
|
2518
|
+
if (lr_1_1 && !lr_1_1.done && (_w = lr_1.return)) _w.call(lr_1);
|
|
2100
2519
|
}
|
|
2101
2520
|
finally { if (e_18) throw e_18.error; }
|
|
2102
2521
|
}
|
|
2103
|
-
var
|
|
2522
|
+
var cr = { __proto__: null, skyViewPixelShader: { name: sr, shader: or } };
|
|
2523
|
+
var ur = "multiTextureCompositeAlphaBlendPixelShader", hr = "var uLayers: texture_2d_array<f32>;var uLayersSampler: sampler;uniform uLayerCount: i32;varying vUV: vec2f;\n#define CUSTOM_FRAGMENT_DEFINITIONS\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {var result: vec4f=vec4f(0.0);for (var i: i32=0; i<MULTITEXTURE_MAXLAYERS; i++) {if (i>=uniforms.uLayerCount) { break; }\nlet s: vec4f=textureSampleLevel(uLayers,uLayersSampler,input.vUV,i,0.0);\n#ifdef MULTITEXTURE_PREMULTIPLY\nresult=s+result*(1.0-s.a);\n#else\nlet pm: vec4f=vec4f(s.rgb*s.a,s.a);result=pm+result*(1.0-s.a);\n#endif\n}\nlet outA: f32=result.a;fragmentOutputs.color=vec4f(select(vec3f(0.0),result.rgb/outA,outA>0.0),outA);}\n";
|
|
2524
|
+
t.ShaderStore.ShadersStoreWGSL[ur] || (t.ShaderStore.ShadersStoreWGSL[ur] = hr);
|
|
2525
|
+
var dr = { __proto__: null, multiTextureCompositeAlphaBlendPixelShaderWGSL: { name: ur, shader: hr } };
|
|
2526
|
+
var mr = "multiTextureCompositeAlphaMaxPixelShader", pr = "var uLayers: texture_2d_array<f32>;var uLayersSampler: sampler;uniform uLayerCount: i32;varying vUV: vec2f;\n#define CUSTOM_FRAGMENT_DEFINITIONS\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {var result: vec4f=vec4f(0.0);for (var i: i32=0; i<MULTITEXTURE_MAXLAYERS; i++) {if (i>=uniforms.uLayerCount) { break; }\nlet s: vec4f=textureSampleLevel(uLayers,uLayersSampler,input.vUV,i,0.0);if (s.a>=result.a) {result=s;}}\nfragmentOutputs.color=result;}\n";
|
|
2527
|
+
t.ShaderStore.ShadersStoreWGSL[mr] || (t.ShaderStore.ShadersStoreWGSL[mr] = pr);
|
|
2528
|
+
var fr = { __proto__: null, multiTextureCompositeAlphaMaxPixelShaderWGSL: { name: mr, shader: pr } };
|
|
2529
|
+
var gr = "multiTextureCompositeAddPixelShader", vr = "var uLayers: texture_2d_array<f32>;var uLayersSampler: sampler;uniform uLayerCount: i32;varying vUV: vec2f;\n#define CUSTOM_FRAGMENT_DEFINITIONS\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {var result: vec4f=vec4f(0.0);for (var i: i32=0; i<MULTITEXTURE_MAXLAYERS; i++) {if (i>=uniforms.uLayerCount) { break; }\nlet s: vec4f=textureSampleLevel(uLayers,uLayersSampler,input.vUV,i,0.0);result=min(result+s,vec4f(1.0));}\nfragmentOutputs.color=result;}\n";
|
|
2530
|
+
t.ShaderStore.ShadersStoreWGSL[gr] || (t.ShaderStore.ShadersStoreWGSL[gr] = vr);
|
|
2531
|
+
var _r = { __proto__: null, multiTextureCompositeAddPixelShaderWGSL: { name: gr, shader: vr } };
|
|
2532
|
+
var Sr = "multiTextureCompositeMultiplyPixelShader", yr = "var uLayers: texture_2d_array<f32>;var uLayersSampler: sampler;uniform uLayerCount: i32;varying vUV: vec2f;\n#define CUSTOM_FRAGMENT_DEFINITIONS\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {var result: vec4f=vec4f(1.0);for (var i: i32=0; i<MULTITEXTURE_MAXLAYERS; i++) {if (i>=uniforms.uLayerCount) { break; }\nlet s: vec4f=textureSampleLevel(uLayers,uLayersSampler,input.vUV,i,0.0);result=result*s;if (dot(result,vec4f(1.0))==0.0) { break; }}\nfragmentOutputs.color=result;} ";
|
|
2533
|
+
t.ShaderStore.ShadersStoreWGSL[Sr] || (t.ShaderStore.ShadersStoreWGSL[Sr] = yr);
|
|
2534
|
+
var Tr = { __proto__: null, multiTextureCompositeMultiplyPixelShaderWGSL: { name: Sr, shader: yr } };
|
|
2535
|
+
var Ar = "multiTextureCompositeSubtractPixelShader", Lr = "var uLayers: texture_2d_array<f32>;var uLayersSampler: sampler;uniform uLayerCount: i32;varying vUV: vec2f;\n#define CUSTOM_FRAGMENT_DEFINITIONS\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {var result: vec4f=textureSampleLevel(uLayers,uLayersSampler,input.vUV,0,0.0);for (var i: i32=1; i<MULTITEXTURE_MAXLAYERS; i++) {if (i>=uniforms.uLayerCount) { break; }\nlet s: vec4f=textureSampleLevel(uLayers,uLayersSampler,input.vUV,i,0.0);result=max(result-s,vec4f(0.0));if (dot(result,vec4f(1.0))==0.0) { break; }}\nfragmentOutputs.color=result;}\n";
|
|
2536
|
+
t.ShaderStore.ShadersStoreWGSL[Ar] || (t.ShaderStore.ShadersStoreWGSL[Ar] = Lr);
|
|
2537
|
+
var Pr = { __proto__: null, multiTextureCompositeSubtractPixelShaderWGSL: { name: Ar, shader: Lr } };
|
|
2538
|
+
var Er = "multiTextureCompositeScreenPixelShader", Rr = "var uLayers: texture_2d_array<f32>;var uLayersSampler: sampler;uniform uLayerCount: i32;varying vUV: vec2f;\n#define CUSTOM_FRAGMENT_DEFINITIONS\n@fragment\nfn main(input: FragmentInputs)->FragmentOutputs {var result: vec4f=vec4f(0.0);for (var i: i32=0; i<MULTITEXTURE_MAXLAYERS; i++) {if (i>=uniforms.uLayerCount) { break; }\nlet s: vec4f=textureSampleLevel(uLayers,uLayersSampler,input.vUV,i,0.0);result=vec4f(1.0)-(vec4f(1.0)-result)*(vec4f(1.0)-s);if (all(result==vec4f(1.0))) { break; }}\nfragmentOutputs.color=result;}\n";
|
|
2539
|
+
t.ShaderStore.ShadersStoreWGSL[Er] || (t.ShaderStore.ShadersStoreWGSL[Er] = Rr);
|
|
2540
|
+
var Cr = { __proto__: null, multiTextureCompositeScreenPixelShaderWGSL: { name: Er, shader: Rr } };
|
|
2541
|
+
var xr = "multiTextureCompositeAlphaBlendPixelShader", Mr = "uniform highp sampler2DArray uLayers;uniform int uLayerCount;varying vec2 vUV;void main() {vec4 result=vec4(0.0);for (int i=0; i<MULTITEXTURE_MAXLAYERS; ++i) {if (i>=uLayerCount) break;vec4 s=texture(uLayers,vec3(vUV,float(i)));\n#ifdef MULTITEXTURE_PREMULTIPLY\nresult=s+result*(1.0-s.a);\n#else\nresult=vec4(s.rgb*s.a,s.a)+result*(1.0-s.a);\n#endif\n}\ngl_FragColor=vec4((result.a>0.0) ? result.rgb/result.a : vec3(0.0),result.a);}\n";
|
|
2542
|
+
t.ShaderStore.ShadersStore[xr] || (t.ShaderStore.ShadersStore[xr] = Mr);
|
|
2543
|
+
var Ir = { __proto__: null, multiTextureCompositeAlphaBlendPixelShader: { name: xr, shader: Mr } };
|
|
2544
|
+
var wr = "multiTextureCompositeAlphaMaxPixelShader", br = "uniform highp sampler2DArray uLayers;uniform int uLayerCount;varying vec2 vUV;void main() {vec4 result=vec4(0.0);for (int i=0; i<MULTITEXTURE_MAXLAYERS; ++i) {if (i>=uLayerCount) break;vec4 s=texture(uLayers,vec3(vUV,float(i)));if (s.a>=result.a) {result=s;}}\ngl_FragColor=result;}\n";
|
|
2545
|
+
t.ShaderStore.ShadersStore[wr] || (t.ShaderStore.ShadersStore[wr] = br);
|
|
2546
|
+
var Or = { __proto__: null, multiTextureCompositeAlphaMaxPixelShader: { name: wr, shader: br } };
|
|
2547
|
+
var Dr = "multiTextureCompositeAddPixelShader", Nr = "uniform highp sampler2DArray uLayers;uniform int uLayerCount;varying vec2 vUV;void main() {vec4 result=vec4(0.0);for (int i=0; i<MULTITEXTURE_MAXLAYERS; ++i) {if (i>=uLayerCount) break;vec4 s=texture(uLayers,vec3(vUV,float(i)));result=min(result+s,vec4(1.0));}\ngl_FragColor=result;}\n";
|
|
2548
|
+
t.ShaderStore.ShadersStore[Dr] || (t.ShaderStore.ShadersStore[Dr] = Nr);
|
|
2549
|
+
var Ur = { __proto__: null, multiTextureCompositeAddPixelShader: { name: Dr, shader: Nr } };
|
|
2550
|
+
var Fr = "multiTextureCompositeMultiplyPixelShader", Vr = "uniform highp sampler2DArray uLayers;uniform int uLayerCount;varying vec2 vUV;void main() {vec4 result=vec4(1.0);for (int i=0; i<MULTITEXTURE_MAXLAYERS; ++i) {if (i>=uLayerCount) break;vec4 s=texture(uLayers,vec3(vUV,float(i)));result=result*s;if (dot(result,vec4(1.0))==0.0) break;}\ngl_FragColor=result;}\n";
|
|
2551
|
+
t.ShaderStore.ShadersStore[Fr] || (t.ShaderStore.ShadersStore[Fr] = Vr);
|
|
2552
|
+
var Gr = { __proto__: null, multiTextureCompositeMultiplyPixelShader: { name: Fr, shader: Vr } };
|
|
2553
|
+
var kr = "multiTextureCompositeSubtractPixelShader", zr = "uniform highp sampler2DArray uLayers;uniform int uLayerCount;varying vec2 vUV;void main() {vec4 result=texture(uLayers,vec3(vUV,0.0));for (int i=1; i<MULTITEXTURE_MAXLAYERS; ++i) {if (i>=uLayerCount) break;vec4 s=texture(uLayers,vec3(vUV,float(i)));result=max(result-s,vec4(0.0));if (dot(result,vec4(1.0))==0.0) break;}\ngl_FragColor=result;}\n";
|
|
2554
|
+
t.ShaderStore.ShadersStore[kr] || (t.ShaderStore.ShadersStore[kr] = zr);
|
|
2555
|
+
var Br = { __proto__: null, multiTextureCompositeSubtractPixelShader: { name: kr, shader: zr } };
|
|
2556
|
+
var Wr = "multiTextureCompositeScreenPixelShader", Hr = "uniform highp sampler2DArray uLayers;uniform int uLayerCount;varying vec2 vUV;void main() {vec4 result=vec4(0.0);for (int i=0; i<MULTITEXTURE_MAXLAYERS; ++i) {if (i>=uLayerCount) break;vec4 s=texture(uLayers,vec3(vUV,float(i)));result=1.0-(1.0-result)*(1.0-s);if (all(equal(result,vec4(1.0)))) break;}\ngl_FragColor=result;}\n";
|
|
2557
|
+
t.ShaderStore.ShadersStore[Wr] || (t.ShaderStore.ShadersStore[Wr] = Hr);
|
|
2558
|
+
var qr = { __proto__: null, multiTextureCompositeScreenPixelShader: { name: Wr, shader: Hr } };
|
|
2104
2559
|
e.Atmosphere = /** @class */ (function () {
|
|
2105
|
-
function Atmosphere(e, i,
|
|
2560
|
+
function Atmosphere(e, i, r, n) {
|
|
2106
2561
|
var _this = this;
|
|
2107
|
-
var a, s, o, l, c,
|
|
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,
|
|
2109
|
-
var
|
|
2110
|
-
if (!
|
|
2111
|
-
throw new Error("Atmosphere is not supported on WebGL ".concat(
|
|
2112
|
-
if (this._physicalProperties = null !== (a = null ==
|
|
2562
|
+
var a, s, o, l, c, u, h, d, m, f, v, _, S, y, T, L, P, E, R, C, x, M;
|
|
2563
|
+
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, r) { return _this._transmittanceLut.getTransmittedColorToRef(e, t, i, r); }, this.getDiffuseSkyIrradianceToRef = function (e, t, i, r, n) { var a, s; return null !== (s = null === (a = _this._diffuseSkyIrradianceLut) || void 0 === a ? void 0 : a.getDiffuseSkyIrradianceToRef(e, t, i, r, n)) && void 0 !== s ? s : (n.r = 0, n.g = 0, n.b = 0, n); }, t.RegisterEngineUniformBuffer(), t.RegisterEnginesExtensionsEngineRenderTarget();
|
|
2564
|
+
var I = this._engine = i.getEngine();
|
|
2565
|
+
if (!I.isWebGPU && I.version < 2)
|
|
2566
|
+
throw new Error("Atmosphere is not supported on WebGL ".concat(I.version, "."));
|
|
2567
|
+
if (this._physicalProperties = null !== (a = null == n ? void 0 : n.physicalProperties) && void 0 !== a ? a : new A, this._physicalProperties.onChangedObservable.add(function () { var e; null === (e = _this._transmittanceLut) || void 0 === e || e.markDirty(); }), 1 !== r.length)
|
|
2113
2568
|
throw new Error("Atmosphere only supports one light source currently.");
|
|
2114
|
-
this._lights =
|
|
2115
|
-
var
|
|
2116
|
-
this._skyRenderingGroup = null !== (
|
|
2569
|
+
this._lights = r, this.depthTexture = null !== (s = null == n ? void 0 : n.depthTexture) && void 0 !== s ? s : null, this._exposure = null !== (o = null == n ? void 0 : n.exposure) && void 0 !== o ? o : 1, this._isLinearSpaceLight = null !== (l = null == n ? void 0 : n.isLinearSpaceLight) && void 0 !== l && l, this._isLinearSpaceComposition = null !== (c = null == n ? void 0 : n.isLinearSpaceComposition) && void 0 !== c && c, this._applyApproximateTransmittance = null === (u = null == n ? void 0 : n.applyApproximateTransmittance) || void 0 === u || u, this._aerialPerspectiveRadianceBias = null !== (h = null == n ? void 0 : n.aerialPerspectiveRadianceBias) && void 0 !== h ? h : 0, this._aerialPerspectiveTransmittanceScale = null !== (d = null == n ? void 0 : n.aerialPerspectiveTransmittanceScale) && void 0 !== d ? d : 1, this._aerialPerspectiveSaturation = null !== (m = null == n ? void 0 : n.aerialPerspectiveSaturation) && void 0 !== m ? m : 1, this._aerialPerspectiveIntensity = null !== (f = null == n ? void 0 : n.aerialPerspectiveIntensity) && void 0 !== f ? f : 1, this._diffuseSkyIrradianceDesaturationFactor = null !== (v = null == n ? void 0 : n.diffuseSkyIrradianceDesaturationFactor) && void 0 !== v ? v : .5, this._diffuseSkyIrradianceIntensity = null !== (_ = null == n ? void 0 : n.diffuseSkyIrradianceIntensity) && void 0 !== _ ? _ : 1, this._additionalDiffuseSkyIrradianceIntensity = null !== (S = null == n ? void 0 : n.additionalDiffuseSkyIrradianceIntensity) && void 0 !== S ? S : .01, this._multiScatteringIntensity = null !== (y = null == n ? void 0 : n.multiScatteringIntensity) && void 0 !== y ? y : 1, this._minimumMultiScatteringIntensity = null !== (T = null == n ? void 0 : n.minimumMultiScatteringIntensity) && void 0 !== T ? T : 618e-6, this._isSkyViewLutEnabled = null === (L = null == n ? void 0 : n.isSkyViewLutEnabled) || void 0 === L || L, this._isAerialPerspectiveLutEnabled = null === (P = null == n ? void 0 : n.isAerialPerspectiveLutEnabled) || void 0 === P || P, this._originHeight = null !== (E = null == n ? void 0 : n.originHeight) && void 0 !== E ? E : 0, this._additionalDiffuseSkyIrradianceColor = (null == n ? void 0 : n.additionalDiffuseSkyIrradianceColor) ? (new t.Color3).copyFrom(n.additionalDiffuseSkyIrradianceColor) : new t.Color3(163 / 255, 199 / 255, 1), this._groundAlbedo = (null == n ? void 0 : n.groundAlbedo) ? (new t.Color3).copyFrom(n.groundAlbedo) : (new t.Color3).set(124 / 255, 165 / 255, 1);
|
|
2570
|
+
var w = this._minimumMultiScatteringColor = (null == n ? void 0 : n.minimumMultiScatteringColor) ? (new t.Color3).copyFrom(n.minimumMultiScatteringColor) : new t.Color3(30 / 255, 40 / 255, 77 / 255);
|
|
2571
|
+
this._skyRenderingGroup = null !== (R = null == n ? void 0 : n.skyRenderingGroup) && void 0 !== R ? R : 0, this._aerialPerspectiveRenderingGroup = null !== (C = null == n ? void 0 : n.aerialPerspectiveRenderingGroup) && void 0 !== C ? C : 0, this._globeAtmosphereRenderingGroup = null !== (x = null == n ? void 0 : n.globeAtmosphereRenderingGroup) && void 0 !== x ? x : 0, this._additionalDiffuseSkyIrradianceColor.scaleToRef(this._additionalDiffuseSkyIrradianceIntensity, this._additionalDiffuseSkyIrradiance), this._minimumMultiScattering.x = w.r * this._minimumMultiScatteringIntensity, this._minimumMultiScattering.y = w.g * this._minimumMultiScatteringIntensity, this._minimumMultiScattering.z = w.b * this._minimumMultiScatteringIntensity;
|
|
2117
2572
|
{
|
|
2118
|
-
var
|
|
2119
|
-
this._directionToLight.copyFrom(
|
|
2120
|
-
var
|
|
2121
|
-
this._isLinearSpaceLight ||
|
|
2122
|
-
var i_16 =
|
|
2123
|
-
this._lightRadianceAtCamera.set(i_16 *
|
|
2573
|
+
var e_117 = r[0];
|
|
2574
|
+
this._directionToLight.copyFrom(e_117.direction).scaleInPlace(-1);
|
|
2575
|
+
var t_26 = this._linearLightColor.copyFrom(e_117.diffuse);
|
|
2576
|
+
this._isLinearSpaceLight || t_26.toLinearSpaceToRef(t_26);
|
|
2577
|
+
var i_16 = e_117.intensity;
|
|
2578
|
+
this._lightRadianceAtCamera.set(i_16 * t_26.r, i_16 * t_26.g, i_16 * t_26.b);
|
|
2124
2579
|
}
|
|
2125
|
-
this._effectRenderer = new t.EffectRenderer(
|
|
2580
|
+
this._effectRenderer = new t.EffectRenderer(I, { indices: [0, 2, 1], positions: [-1, -1, -1, 3, 3, -1] }), this._transmittanceLut = new k(this), this._multiScatteringLutRenderTarget = q("atmo-multiScattering", { width: 32, height: 32 }, i), this._multiScatteringEffectWrapper = H(I, this.uniformBuffer, this._groundAlbedo), this._isDiffuseSkyIrradianceLutEnabled = null === (M = null == n ? void 0 : n.isDiffuseSkyIrradianceLutEnabled) || void 0 === M || M, this._isDiffuseSkyIrradianceLutEnabled && (this._diffuseSkyIrradianceLut = new O(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
2581
|
{
|
|
2127
|
-
var
|
|
2128
|
-
this._skyRenderingGroup >= 0 &&
|
|
2582
|
+
var e_118 = i.renderingManager;
|
|
2583
|
+
this._skyRenderingGroup >= 0 && e_118.getRenderingGroup(this._skyRenderingGroup), this._aerialPerspectiveRenderingGroup >= 0 && e_118.getRenderingGroup(this._aerialPerspectiveRenderingGroup), this._globeAtmosphereRenderingGroup >= 0 && e_118.getRenderingGroup(this._globeAtmosphereRenderingGroup), this._onBeforeDrawPhaseObserver = i.onBeforeDrawPhaseObservable.add(function () { _this._skyRenderingGroup >= 0 && (e_118.getRenderingGroup(_this._skyRenderingGroup)._empty = !1), _this._aerialPerspectiveRenderingGroup >= 0 && (e_118.getRenderingGroup(_this._aerialPerspectiveRenderingGroup)._empty = !1), _this._globeAtmosphereRenderingGroup >= 0 && (e_118.getRenderingGroup(_this._globeAtmosphereRenderingGroup)._empty = !1); }), this._onAfterRenderingGroupObserver = i.onAfterRenderingGroupObservable.add(function (e) { if (e.renderingManager !== i.renderingManager)
|
|
2129
2584
|
return; var t = e.renderingGroupId; _this._skyRenderingGroup === t && _this.drawSkyCompositor(), _this._aerialPerspectiveRenderingGroup === t && _this.drawAerialPerspectiveCompositor(), _this._globeAtmosphereRenderingGroup === t && _this.drawGlobeAtmosphereCompositor(); });
|
|
2130
2585
|
}
|
|
2131
2586
|
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);
|
|
@@ -2202,7 +2657,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2202
2657
|
Object.defineProperty(Atmosphere.prototype, "skyViewLutRenderTarget", {
|
|
2203
2658
|
get: function () { if (!this._isSkyViewLutEnabled)
|
|
2204
2659
|
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
|
|
2660
|
+
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 r = e.isWebGPU && !t.EffectWrapper.ForceGLSL, n = r ? "atmosphere" : i.name; return W(e, "atmo-skyView", "skyView", __spreadArray(["depth"], __read(i.useUbo ? [] : i.getUniformNames()), false), ["transmittanceLut", "multiScatteringLut"], i.useUbo ? [n] : [], ["POSITION_VEC2"], r, function (e, t) { t.push.apply(t, __spreadArray([], __read(r ? [Promise.resolve().then(function () { return Wt; }), Promise.resolve().then(function () { return ar; })] : [Promise.resolve().then(function () { return Qt; }), Promise.resolve().then(function () { return cr; })]), false)); }); })(this._engine, this.uniformBuffer), e; },
|
|
2206
2661
|
enumerable: false,
|
|
2207
2662
|
configurable: true
|
|
2208
2663
|
});
|
|
@@ -2215,15 +2670,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2215
2670
|
Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveLutRenderTarget", {
|
|
2216
2671
|
get: function () { if (!this._isAerialPerspectiveLutEnabled)
|
|
2217
2672
|
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
|
|
2673
|
+
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 r = e.isWebGPU && !t.EffectWrapper.ForceGLSL, n = r ? "atmosphere" : i.name; return W(e, "atmo-aerialPerspective", "aerialPerspective", __spreadArray(["layerIdx"], __read(i.useUbo ? [] : i.getUniformNames()), false), ["transmittanceLut", "multiScatteringLut"], i.useUbo ? [n] : [], ["POSITION_VEC2", "COMPUTE_WORLD_RAY"], r, function (e, t) { t.push.apply(t, __spreadArray([], __read(r ? [Promise.resolve().then(function () { return Wt; }), Promise.resolve().then(function () { return Mi; })] : [Promise.resolve().then(function () { return Qt; }), Promise.resolve().then(function () { return Oi; })]), false)); }); })(this._engine, this.uniformBuffer), i; },
|
|
2219
2674
|
enumerable: false,
|
|
2220
2675
|
configurable: true
|
|
2221
2676
|
});
|
|
2222
2677
|
Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveIntensity", {
|
|
2223
2678
|
get: function () { return this._aerialPerspectiveIntensity; },
|
|
2224
2679
|
set: function (e) { if ((e = Math.max(.001, e)) !== this._aerialPerspectiveIntensity) {
|
|
2225
|
-
var
|
|
2226
|
-
this._aerialPerspectiveIntensity = e,
|
|
2680
|
+
var t_27 = 1 === e != (1 === this._aerialPerspectiveIntensity);
|
|
2681
|
+
this._aerialPerspectiveIntensity = e, t_27 && (this._disposeAerialPerspectiveCompositor(), this._disposeGlobeAtmosphereCompositor());
|
|
2227
2682
|
} },
|
|
2228
2683
|
enumerable: false,
|
|
2229
2684
|
configurable: true
|
|
@@ -2243,8 +2698,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2243
2698
|
Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveRadianceBias", {
|
|
2244
2699
|
get: function () { return this._aerialPerspectiveRadianceBias; },
|
|
2245
2700
|
set: function (e) { if (e !== this._aerialPerspectiveRadianceBias) {
|
|
2246
|
-
var
|
|
2247
|
-
this._aerialPerspectiveRadianceBias = e,
|
|
2701
|
+
var t_28 = 0 === e != (0 === this._aerialPerspectiveRadianceBias);
|
|
2702
|
+
this._aerialPerspectiveRadianceBias = e, t_28 && (this._disposeAerialPerspectiveCompositor(), this._disposeGlobeAtmosphereCompositor());
|
|
2248
2703
|
} },
|
|
2249
2704
|
enumerable: false,
|
|
2250
2705
|
configurable: true
|
|
@@ -2318,8 +2773,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2318
2773
|
});
|
|
2319
2774
|
Object.defineProperty(Atmosphere.prototype, "uniformBuffer", {
|
|
2320
2775
|
get: function () { if (null === this._atmosphereUbo) {
|
|
2321
|
-
var
|
|
2322
|
-
|
|
2776
|
+
var e_119 = this._atmosphereUbo = new t.UniformBuffer(this._engine, void 0, !0, "Atmosphere");
|
|
2777
|
+
e_119.addUniform("peakRayleighScattering", 3), e_119.addUniform("planetRadius", 1), e_119.addUniform("peakMieScattering", 3), e_119.addUniform("atmosphereThickness", 1), e_119.addUniform("peakMieAbsorption", 3), e_119.addUniform("planetRadiusSquared", 1), e_119.addUniform("peakMieExtinction", 3), e_119.addUniform("atmosphereRadius", 1), e_119.addUniform("peakOzoneAbsorption", 3), e_119.addUniform("atmosphereRadiusSquared", 1), e_119.addUniform("horizonDistanceToAtmosphereEdge", 1), e_119.addUniform("horizonDistanceToAtmosphereEdgeSquared", 1), e_119.addUniform("planetRadiusWithOffset", 1), e_119.addUniform("planetRadiusOffset", 1), e_119.addUniform("atmosphereExposure", 1), e_119.addUniform("aerialPerspectiveRadianceBias", 1), e_119.addUniform("inverseAtmosphereThickness", 1), e_119.addUniform("aerialPerspectiveTransmittanceScale", 1), e_119.addUniform("inverseViewProjectionWithoutTranslation", 16), e_119.addUniform("directionToLight", 3), e_119.addUniform("multiScatteringIntensity", 1), e_119.addUniform("directionToLightRelativeToCameraGeocentricNormal", 3), e_119.addUniform("cameraRadius", 1), e_119.addUniform("lightRadianceAtCamera", 3), e_119.addUniform("diffuseSkyIrradianceDesaturationFactor", 1), e_119.addUniform("groundAlbedo", 3), e_119.addUniform("aerialPerspectiveSaturation", 1), e_119.addUniform("minMultiScattering", 3), e_119.addUniform("diffuseSkyIrradianceIntensity", 1), e_119.addUniform("cameraPositionGlobal", 3), e_119.addUniform("lightIntensity", 1), e_119.addUniform("clampedCameraPositionGlobal", 3), e_119.addUniform("aerialPerspectiveIntensity", 1), e_119.addUniform("cameraGeocentricNormal", 3), e_119.addUniform("clampedCameraRadius", 1), e_119.addUniform("cameraForward", 3), e_119.addUniform("clampedCameraHeight", 1), e_119.addUniform("cameraPosition", 3), e_119.addUniform("cosCameraHorizonAngleFromZenith", 1), e_119.addUniform("viewport", 4), e_119.addUniform("additionalDiffuseSkyIrradiance", 3), e_119.addUniform("cameraHeight", 1), e_119.addUniform("cameraNearPlane", 1), e_119.addUniform("originHeight", 1), e_119.addUniform("sinCameraAtmosphereHorizonAngleFromNadir", 1), e_119.addUniform("transmittanceSampleCount", 1), e_119.addUniform("skyViewLutSampleCount", 1), e_119.addUniform("multiScatteringLutSampleCount", 1), e_119.addUniform("multiScatteringAzimuthSampleCount", 1), e_119.addUniform("multiScatteringInclinationSampleCount", 1), e_119.addUniform("diffuseSkyIrradianceLutSampleCount", 1), e_119.create();
|
|
2323
2778
|
} return this._atmosphereUbo; },
|
|
2324
2779
|
enumerable: false,
|
|
2325
2780
|
configurable: true
|
|
@@ -2329,7 +2784,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2329
2784
|
enumerable: false,
|
|
2330
2785
|
configurable: true
|
|
2331
2786
|
});
|
|
2332
|
-
Atmosphere.prototype._eagerlyPreloadMaterialPluginShaderIncludesAsync = function () { return i(this, void 0, void 0, function () { var
|
|
2787
|
+
Atmosphere.prototype._eagerlyPreloadMaterialPluginShaderIncludesAsync = function () { return i(this, void 0, void 0, function () { var e_120; return __generator(this, function (_a) {
|
|
2333
2788
|
switch (_a.label) {
|
|
2334
2789
|
case 0:
|
|
2335
2790
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -2338,7 +2793,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2338
2793
|
_a.sent();
|
|
2339
2794
|
return [3 /*break*/, 3];
|
|
2340
2795
|
case 2:
|
|
2341
|
-
|
|
2796
|
+
e_120 = _a.sent();
|
|
2342
2797
|
return [3 /*break*/, 3];
|
|
2343
2798
|
case 3: return [2 /*return*/];
|
|
2344
2799
|
}
|
|
@@ -2353,31 +2808,31 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2353
2808
|
return [2 /*return*/];
|
|
2354
2809
|
}
|
|
2355
2810
|
}); }); };
|
|
2356
|
-
Atmosphere.prototype.dispose = function () { var e, i,
|
|
2811
|
+
Atmosphere.prototype.dispose = function () { var e, i, r, n, a, s, o, l, c, u, h, d, 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 === (r = this._onAfterRenderingGroupObserver) || void 0 === r || r.remove(), this._onAfterRenderingGroupObserver = null, null === (n = this._onBeforeRenderObserver) || void 0 === n || n.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 === (u = this._skyViewLutEffectRenderer) || void 0 === u || u.dispose(), this._skyViewLutEffectRenderer = null, null === (h = this._aerialPerspectiveLutRenderTarget) || void 0 === h || h.dispose(), this._aerialPerspectiveLutRenderTarget = null, null === (d = this._aerialPerspectiveLutEffectWrapper) || void 0 === d || d.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 === (_ = this._atmosphereUbo) || void 0 === _ || _.dispose(), this._atmosphereUbo = null, null === (S = this._effectRenderer) || void 0 === S || S.dispose(), this._effectRenderer = null, this._atmosphereUniformBufferAsArray.length = 0, t.UnregisterMaterialPlugin(z); };
|
|
2357
2812
|
Atmosphere.prototype.isEnabled = function () { return this._isEnabled; };
|
|
2358
2813
|
Atmosphere.prototype.setEnabled = function (e) { this._isEnabled = e; };
|
|
2359
|
-
Atmosphere.prototype.isReady = function () { var e, t, i,
|
|
2360
|
-
return !0; var g = this._engine, v = this.uniformBuffer,
|
|
2814
|
+
Atmosphere.prototype.isReady = function () { var e, t, i, r, n, a, s, o, l, c, u, h, d, m, p, f; if (!this._isEnabled)
|
|
2815
|
+
return !0; var g = this._engine, v = this.uniformBuffer, _ = this._isSkyViewLutEnabled, S = this._isLinearSpaceComposition, y = this._applyApproximateTransmittance, T = this.depthTexture; return null !== (e = this._skyCompositorEffectWrapper) && void 0 !== e || (this._skyCompositorEffectWrapper = $(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 = Y(g, v, this._isAerialPerspectiveLutEnabled, _, S, y, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias))), null === (r = this._transmittanceLut) || void 0 === r || r.readPixelsAsync(), null === (n = this._diffuseSkyIrradianceLut) || void 0 === n || n.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 === (u = this._skyViewLutEffectWrapper) || void 0 === u ? void 0 : u.isReady())) || this._isAerialPerspectiveLutEnabled && (!1 === (null === (h = this._aerialPerspectiveLutRenderTarget) || void 0 === h ? void 0 : h.isReady()) || !1 === (null === (d = this._aerialPerspectiveLutEffectWrapper) || void 0 === d ? void 0 : d.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
2816
|
Atmosphere.prototype.getClassName = function () { return "Atmosphere"; };
|
|
2362
2817
|
Atmosphere.prototype._drawMultiScatteringLut = function () {
|
|
2363
2818
|
var _this = this;
|
|
2364
2819
|
var e = this._transmittanceLut.renderTarget;
|
|
2365
|
-
Z(this._engine, this._effectRenderer, this._multiScatteringEffectWrapper, this._multiScatteringLutRenderTarget, function (t, i,
|
|
2820
|
+
Z(this._engine, this._effectRenderer, this._multiScatteringEffectWrapper, this._multiScatteringLutRenderTarget, function (t, i, r, n) { _this.bindUniformBufferToEffect(r), n.bindFramebuffer(i, void 0, void 0, void 0, !0), t.bindBuffers(r), r.setTexture("transmittanceLut", e), t.draw(); });
|
|
2366
2821
|
};
|
|
2367
2822
|
Atmosphere.prototype.drawAerialPerspectiveCompositor = function () {
|
|
2368
2823
|
var _this = this;
|
|
2369
|
-
var e, i,
|
|
2824
|
+
var e, i, r;
|
|
2370
2825
|
if (null === this.depthTexture)
|
|
2371
2826
|
return;
|
|
2372
2827
|
if (!this.isEnabled())
|
|
2373
2828
|
return;
|
|
2374
|
-
var
|
|
2829
|
+
var n = this._engine, a = null !== (e = this._aerialPerspectiveCompositorEffectWrapper) && void 0 !== e ? e : this._aerialPerspectiveCompositorEffectWrapper = Y(n, this.uniformBuffer, this._isAerialPerspectiveLutEnabled, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias);
|
|
2375
2830
|
if (!this._isGlobalLutsReady)
|
|
2376
2831
|
return;
|
|
2377
2832
|
if (this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius)
|
|
2378
2833
|
return;
|
|
2379
2834
|
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 === (
|
|
2835
|
+
a.isReady() && (null === (i = null == s ? void 0 : s.isReady()) || void 0 === i || i) && o.isReady() && l.isReady() && (null === (r = null == c ? void 0 : c.isReady()) || void 0 === r || r) && this.depthTexture.isReady() && Z(n, this._effectRenderer, a, null, function (e, t, i) { if (null === _this.depthTexture)
|
|
2381
2836
|
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
2837
|
};
|
|
2383
2838
|
Atmosphere.prototype.drawSkyCompositor = function () {
|
|
@@ -2385,7 +2840,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2385
2840
|
var e, i;
|
|
2386
2841
|
if (!this.isEnabled())
|
|
2387
2842
|
return;
|
|
2388
|
-
var
|
|
2843
|
+
var r = this._engine, n = null !== (e = this._skyCompositorEffectWrapper) && void 0 !== e ? e : this._skyCompositorEffectWrapper = $(r, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance);
|
|
2389
2844
|
if (!this._isGlobalLutsReady)
|
|
2390
2845
|
return;
|
|
2391
2846
|
if (this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius)
|
|
@@ -2393,20 +2848,20 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2393
2848
|
if (null !== this.depthTexture && !this.depthTexture.isReady())
|
|
2394
2849
|
return;
|
|
2395
2850
|
var a = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null, s = this._multiScatteringLutRenderTarget, o = this._transmittanceLut.renderTarget;
|
|
2396
|
-
|
|
2851
|
+
n.isReady() && (null === (i = null == a ? void 0 : a.isReady()) || void 0 === i || i) && s.isReady() && o.isReady() && Z(r, this._effectRenderer, n, 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
2852
|
};
|
|
2398
2853
|
Atmosphere.prototype.drawGlobeAtmosphereCompositor = function () {
|
|
2399
2854
|
var _this = this;
|
|
2400
2855
|
var e, i;
|
|
2401
2856
|
if (!this.isEnabled())
|
|
2402
2857
|
return;
|
|
2403
|
-
var
|
|
2858
|
+
var r = this._engine, n = null !== (e = this._globeAtmosphereCompositorEffectWrapper) && void 0 !== e ? e : this._globeAtmosphereCompositorEffectWrapper = j(r, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias, null !== this.depthTexture);
|
|
2404
2859
|
if (!this._isGlobalLutsReady)
|
|
2405
2860
|
return;
|
|
2406
2861
|
if (!(this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius))
|
|
2407
2862
|
return;
|
|
2408
2863
|
var a = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null, s = this._multiScatteringLutRenderTarget, o = this._transmittanceLut.renderTarget;
|
|
2409
|
-
|
|
2864
|
+
n.isReady() && (null === (i = null == a ? void 0 : a.isReady()) || void 0 === i || i) && s.isReady() && o.isReady() && (null === this.depthTexture || this.depthTexture.isReady()) && Z(r, this._effectRenderer, n, 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
2865
|
};
|
|
2411
2866
|
Atmosphere.prototype._disposeSkyCompositor = function () { var e; null === (e = this._skyCompositorEffectWrapper) || void 0 === e || e.dispose(), this._skyCompositorEffectWrapper = null; };
|
|
2412
2867
|
Atmosphere.prototype._disposeAerialPerspectiveCompositor = function () { var e; null === (e = this._aerialPerspectiveCompositorEffectWrapper) || void 0 === e || e.dispose(), this._aerialPerspectiveCompositorEffectWrapper = null; };
|
|
@@ -2416,67 +2871,67 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2416
2871
|
enumerable: false,
|
|
2417
2872
|
configurable: true
|
|
2418
2873
|
});
|
|
2419
|
-
Atmosphere.prototype._updatePerCameraVariables = function (e) { var t = this._lights[0], i = this._directionToLight.copyFrom(t.direction).scaleInPlace(-1),
|
|
2874
|
+
Atmosphere.prototype._updatePerCameraVariables = function (e) { var t = this._lights[0], i = this._directionToLight.copyFrom(t.direction).scaleInPlace(-1), r = this._physicalProperties, n = this._cameraAtmosphereVariables; n.update(e, r.planetRadius, r.planetRadiusWithOffset, r.atmosphereRadius, i, this.originHeight), this._transmittanceLut.updateLightParameters(t, n.clampedCameraRadius, n.cameraGeocentricNormal), this._linearLightColor.copyFrom(t.diffuse), this.getDiffuseSkyIrradianceToRef(i, 0, n.cameraGeocentricNormal, t.intensity, this._tempSceneAmbient), this.isLinearSpaceLight || this._tempSceneAmbient.toGammaSpaceToRef(this._tempSceneAmbient), this.scene.ambientColor = this._tempSceneAmbient, this.onAfterUpdateVariablesForCameraObservable.notifyObservers(e); };
|
|
2420
2875
|
Atmosphere.prototype._renderLutsForCamera = function (e) { {
|
|
2421
2876
|
this.onBeforeLightVariablesUpdateObservable.notifyObservers();
|
|
2422
|
-
var
|
|
2423
|
-
this.isLinearSpaceLight || (
|
|
2424
|
-
var
|
|
2425
|
-
this._lightRadianceAtCamera.set(
|
|
2877
|
+
var e_121 = this.lights[0];
|
|
2878
|
+
this.isLinearSpaceLight || (e_121.diffuse = e_121.diffuse.toGammaSpaceToRef(e_121.diffuse), e_121.specular = e_121.specular.toGammaSpaceToRef(e_121.specular));
|
|
2879
|
+
var t_29 = e_121.intensity;
|
|
2880
|
+
this._lightRadianceAtCamera.set(t_29 * this._linearLightColor.r, t_29 * this._linearLightColor.g, t_29 * this._linearLightColor.b);
|
|
2426
2881
|
} 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,
|
|
2882
|
+
Atmosphere.prototype.renderGlobalLuts = function () { var e, t, i, r, n; 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 = H(this._engine, this.uniformBuffer, this._groundAlbedo)), (null === (i = this._multiScatteringEffectWrapper) || void 0 === i ? void 0 : i.isReady()) && (null === (r = this._multiScatteringLutRenderTarget) || void 0 === r ? void 0 : r.isReady()) && (this._drawMultiScatteringLut(), this._hasRenderedMultiScatteringLut = !0, this._hasEverRenderedMultiScatteringLut = !0)), !this._transmittanceLut.isDirty && this._hasRenderedMultiScatteringLut && (null === (n = this._diffuseSkyIrradianceLut) || void 0 === n || n.render()); };
|
|
2428
2883
|
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
2884
|
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
2885
|
Atmosphere.prototype._drawAerialPerspectiveLut = function () {
|
|
2431
2886
|
var _this = this;
|
|
2432
2887
|
var e = this._transmittanceLut.renderTarget, t = this._multiScatteringLutRenderTarget;
|
|
2433
|
-
Z(this._engine, this._effectRenderer, this._aerialPerspectiveLutEffectWrapper, this._aerialPerspectiveLutRenderTarget, function (i,
|
|
2434
|
-
a.bindFramebuffer(
|
|
2888
|
+
Z(this._engine, this._effectRenderer, this._aerialPerspectiveLutEffectWrapper, this._aerialPerspectiveLutRenderTarget, function (i, r, n, a) { _this.bindUniformBufferToEffect(n), n.setTexture("transmittanceLut", e), n.setTexture("multiScatteringLut", t); for (var e_122 = 0; e_122 < 32; e_122++)
|
|
2889
|
+
a.bindFramebuffer(r, void 0, void 0, void 0, !0, void 0, e_122), i.bindBuffers(n), n.setFloat("layerIdx", e_122), i.draw(); });
|
|
2435
2890
|
};
|
|
2436
2891
|
Atmosphere.prototype._clearAerialPerspectiveLut = function () { var e; var t = null === (e = this._aerialPerspectiveLutRenderTarget) || void 0 === e ? void 0 : e.renderTarget; if (t) {
|
|
2437
|
-
var
|
|
2438
|
-
for (var
|
|
2439
|
-
|
|
2892
|
+
var e_123 = this._engine, i_18 = { r: 0, g: 0, b: 0, a: 0 };
|
|
2893
|
+
for (var r_15 = 0; r_15 < 32; r_15++)
|
|
2894
|
+
e_123.bindFramebuffer(t, void 0, void 0, void 0, !0, void 0, r_15), e_123.clear(i_18, !0, !1, !1);
|
|
2440
2895
|
} };
|
|
2441
2896
|
Atmosphere.prototype._drawSkyViewLut = function () {
|
|
2442
2897
|
var _this = this;
|
|
2443
2898
|
var e = this._transmittanceLut.renderTarget, t = this._multiScatteringLutRenderTarget;
|
|
2444
|
-
Z(this._engine, this._effectRenderer, this._skyViewLutEffectWrapper, this._skyViewLutRenderTarget, function (i,
|
|
2899
|
+
Z(this._engine, this._effectRenderer, this._skyViewLutEffectWrapper, this._skyViewLutRenderTarget, function (i, r, n, a) { _this.bindUniformBufferToEffect(n), a.bindFramebuffer(r, void 0, void 0, void 0, !0), i.bindBuffers(n), n.setTexture("transmittanceLut", e), n.setTexture("multiScatteringLut", t), i.draw(); });
|
|
2445
2900
|
};
|
|
2446
2901
|
return Atmosphere;
|
|
2447
|
-
}()), e.AtmospherePhysicalProperties = A, e.BuildFromNavmeshData = function (e) { var t =
|
|
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 =
|
|
2449
|
-
throw new Error("Unable to deserialize TileCache."); return { navMesh:
|
|
2902
|
+
}()), e.AtmospherePhysicalProperties = A, e.BuildFromNavmeshData = function (e) { var t = Ze(), i = t.importNavMesh(e); if (!i.navMesh)
|
|
2903
|
+
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 = Ze(), r = i.importTileCache(e, t); if (!r.tileCache)
|
|
2904
|
+
throw new Error("Unable to deserialize TileCache."); return { navMesh: r.navMesh, navMeshQuery: new i.NavMeshQuery(r.navMesh), tileCache: r.tileCache }; }, e.ComputeSmoothPath = st, e.ConvertNavPathPoints = rt, e.CreateDebugNavMesh = mt, e.CreateDefaultTileCacheMeshProcess = je, e.CreateNavigationPluginAsync = function (e) { return i(this, void 0, void 0, function () { var r; return __generator(this, function (_a) {
|
|
2450
2905
|
switch (_a.label) {
|
|
2451
|
-
case 0: return [4 /*yield*/, function (e) { return i(this, void 0, void 0, function () { var
|
|
2906
|
+
case 0: return [4 /*yield*/, function (e) { return i(this, void 0, void 0, function () { var r, n, a, e_124; return __generator(this, function (_a) {
|
|
2452
2907
|
switch (_a.label) {
|
|
2453
2908
|
case 0:
|
|
2454
|
-
|
|
2455
|
-
if (
|
|
2456
|
-
if (!
|
|
2457
|
-
return [4 /*yield*/,
|
|
2909
|
+
n = null !== (r = null == e ? void 0 : e.version) && void 0 !== r ? r : "0.43.0", a = Object.assign({ url: "https://unpkg.com/@recast-navigation", version: n }, e);
|
|
2910
|
+
if (!!$e) return [3 /*break*/, 6];
|
|
2911
|
+
if (!Ye) return [3 /*break*/, 2];
|
|
2912
|
+
return [4 /*yield*/, Ye];
|
|
2458
2913
|
case 1:
|
|
2459
2914
|
_a.sent();
|
|
2460
2915
|
return [3 /*break*/, 6];
|
|
2461
2916
|
case 2:
|
|
2462
2917
|
if (!a.instance) return [3 /*break*/, 3];
|
|
2463
|
-
|
|
2918
|
+
$e = a.instance;
|
|
2464
2919
|
return [3 /*break*/, 6];
|
|
2465
2920
|
case 3:
|
|
2466
|
-
|
|
2921
|
+
Ye = function (e, r) { return i(this, void 0, void 0, function () { var i, n; return __generator(this, function (_a) {
|
|
2467
2922
|
switch (_a.label) {
|
|
2468
2923
|
case 0:
|
|
2469
|
-
i = { imports: { "@recast-navigation/core": "".concat(e, "/core@").concat(
|
|
2470
|
-
|
|
2471
|
-
return [4 /*yield*/, t._LoadScriptModuleAsync("\n import * as CoreModule from '".concat(e, "/core@").concat(
|
|
2924
|
+
i = { imports: { "@recast-navigation/core": "".concat(e, "/core@").concat(r, "/dist/index.mjs"), "@recast-navigation/wasm": "".concat(e, "/wasm@").concat(r, "/dist/recast-navigation.wasm-compat.js"), "@recast-navigation/generators": "".concat(e, "/generators@").concat(r, "/dist/index.mjs") } }, n = document.createElement("script");
|
|
2925
|
+
n.type = "importmap", n.textContent = JSON.stringify(i), document.body.appendChild(n);
|
|
2926
|
+
return [4 /*yield*/, t._LoadScriptModuleAsync("\n import * as CoreModule from '".concat(e, "/core@").concat(r, "/dist/index.mjs';\n import * as GeneratorsModule from '").concat(e, "/generators@").concat(r, "/dist/index.mjs';\n const returnedValue = {core: CoreModule, generators: GeneratorsModule};\n "))];
|
|
2472
2927
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2473
2928
|
}
|
|
2474
2929
|
}); }); }(a.url, a.version);
|
|
2475
|
-
return [4 /*yield*/,
|
|
2930
|
+
return [4 /*yield*/, Ye];
|
|
2476
2931
|
case 4:
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
return [4 /*yield*/,
|
|
2932
|
+
e_124 = _a.sent();
|
|
2933
|
+
$e = Object.assign(Object.assign({}, e_124.core), e_124.generators);
|
|
2934
|
+
return [4 /*yield*/, $e.init()];
|
|
2480
2935
|
case 5:
|
|
2481
2936
|
_a.sent();
|
|
2482
2937
|
_a.label = 6;
|
|
@@ -2485,28 +2940,28 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2485
2940
|
}); }); }(e)];
|
|
2486
2941
|
case 1:
|
|
2487
2942
|
_a.sent();
|
|
2488
|
-
|
|
2489
|
-
return [2 /*return*/, (
|
|
2943
|
+
r = new gt(Ze());
|
|
2944
|
+
return [2 /*return*/, (ft(r), r)];
|
|
2490
2945
|
}
|
|
2491
|
-
}); }); }, e.CreateSoloNavMeshConfig =
|
|
2492
|
-
function FontAsset(e, i,
|
|
2946
|
+
}); }); }, e.CreateSoloNavMeshConfig = Qe, e.CreateTileCacheNavMeshConfig = Je, e.CreateTiledNavMeshConfig = Ke, e.DebugLayerOption = _t, e.DefaultMaxObstacles = 128, e.DefaultParagraphOptions = Te, e.DiffuseSkyIrradianceLut = O, e.FitStrategy = _e, e.FontAsset = /** @class */ (function () {
|
|
2947
|
+
function FontAsset(e, i, r) {
|
|
2493
2948
|
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,
|
|
2949
|
+
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, r, { noMipmap: !1, invertY: !1 }); return i.anisotropicFilteringLevel = 16, i; });
|
|
2495
2950
|
}
|
|
2496
2951
|
FontAsset.prototype.dispose = function () {
|
|
2497
|
-
var
|
|
2952
|
+
var e_125, _a;
|
|
2498
2953
|
try {
|
|
2499
2954
|
for (var _b = __values(this.textures), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2500
|
-
var
|
|
2501
|
-
|
|
2955
|
+
var e_126 = _c.value;
|
|
2956
|
+
e_126.dispose();
|
|
2502
2957
|
}
|
|
2503
2958
|
}
|
|
2504
|
-
catch (
|
|
2959
|
+
catch (e_125_1) { e_125 = { error: e_125_1 }; }
|
|
2505
2960
|
finally {
|
|
2506
2961
|
try {
|
|
2507
2962
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2508
2963
|
}
|
|
2509
|
-
finally { if (
|
|
2964
|
+
finally { if (e_125) throw e_125.error; }
|
|
2510
2965
|
}
|
|
2511
2966
|
this.textures.length = 0;
|
|
2512
2967
|
};
|
|
@@ -2515,19 +2970,19 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2515
2970
|
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
2971
|
FontAsset.prototype._unsupportedChars = function (e) { return e.replace(this._charsRegex, ""); };
|
|
2517
2972
|
return FontAsset;
|
|
2518
|
-
}()), e.GenerateNavMesh =
|
|
2973
|
+
}()), e.GenerateNavMesh = pt, e.GetChaikinSmoothPath = function (e, t) {
|
|
2519
2974
|
if (t === void 0) { t = 1; }
|
|
2520
2975
|
for (var i_19 = 0; i_19 < t; i_19++) {
|
|
2521
|
-
var
|
|
2976
|
+
var t_30 = [];
|
|
2522
2977
|
for (var i_20 = 0; i_20 < e.length - 1; i_20++) {
|
|
2523
|
-
var
|
|
2524
|
-
|
|
2978
|
+
var r_16 = e[i_20], n_17 = e[i_20 + 1];
|
|
2979
|
+
t_30.push({ x: .75 * r_16.x + .25 * n_17.x, y: .75 * r_16.y + .25 * n_17.y, z: .75 * r_16.z + .25 * n_17.z }), t_30.push({ x: .25 * r_16.x + .75 * n_17.x, y: .25 * r_16.y + .75 * n_17.y, z: .25 * r_16.z + .75 * n_17.z });
|
|
2525
2980
|
}
|
|
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 &&
|
|
2981
|
+
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_30.push(t_30[0]), e = t_30;
|
|
2527
2982
|
}
|
|
2528
2983
|
return e;
|
|
2529
|
-
}, e.GetLShapedPath = function (e) { var i = []; for (var
|
|
2530
|
-
var
|
|
2531
|
-
i.push(
|
|
2532
|
-
} return i; }, e.GetPositionsAndIndices =
|
|
2984
|
+
}, e.GetLShapedPath = function (e) { var i = []; for (var r_17 = 0; r_17 < e.length - 1; r_17++) {
|
|
2985
|
+
var n_18 = e[r_17], a_15 = e[r_17 + 1], s_14 = vt(n_18, a_15);
|
|
2986
|
+
i.push(n_18, new t.Vector3(s_14.x, a_15.y, s_14.z), a_15);
|
|
2987
|
+
} return i; }, e.GetPositionsAndIndices = ht, e.GetReversedIndices = dt, e.HtmlMesh = Se, e.HtmlMeshRenderer = K, e.InjectGenerators = ft, e.MultiTexture = He, e.NavigationDebugger = St, e.PointerEventsCaptureBehavior = ve, e.RecastNavigationJSPluginV2 = gt, e.RegisterMultiTexture = We, e.SdfTextParagraph = Ae, e.TextRenderer = Le, e.ToCrowdAgentParams = tt, e.ToSoloNavMeshGeneratorConfig = et, e.TransmittanceLut = k, e.WaitForFullTileCacheUpdate = Xe, e.msdfPixelShader = Ie, e.msdfPixelShaderWGSL = Ve, e.msdfVertexShader = Re, e.msdfVertexShaderWGSL = De;
|
|
2533
2988
|
});
|