babylonjs-addons 9.27.1 → 9.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/babylonjs.addons.es5.js
CHANGED
|
@@ -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 At; }), Promise.resolve().then(function () { return Rt; })])];
|
|
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 It; }), Promise.resolve().then(function () { return Dt; }), Promise.resolve().then(function () { return Vt; })])];
|
|
133
133
|
case 3:
|
|
134
134
|
_a = _b.sent();
|
|
135
135
|
_b.label = 4;
|
|
@@ -466,7 +466,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
466
466
|
var l = e.uniformBuffer, c = l.useUbo, u = n.isWebGPU && !t.EffectWrapper.ForceGLSL, h = u ? "atmosphere" : l.name;
|
|
467
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(u ? [Promise.resolve().then(function () { return
|
|
469
|
+
case 0: return [4 /*yield*/, Promise.all(u ? [Promise.resolve().then(function () { return Bt; }), Promise.resolve().then(function () { return Zt; })] : [Promise.resolve().then(function () { return Xt; }), Promise.resolve().then(function () { return ei; })])];
|
|
470
470
|
case 1:
|
|
471
471
|
_a.sent();
|
|
472
472
|
e = (u ? t.ShaderStore.IncludesShadersStoreWGSL : t.ShaderStore.IncludesShadersStore).hdrFilteringFunctions;
|
|
@@ -553,7 +553,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
553
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
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
|
|
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 Bt; }), Promise.resolve().then(function () { return ni; })] : [Promise.resolve().then(function () { return Xt; }), Promise.resolve().then(function () { return li; })]), false)); } }), this._effectRenderer = new t.EffectRenderer(r, { indices: [0, 2, 1], positions: [-1, -1, -1, 3, 3, -1] });
|
|
557
557
|
}
|
|
558
558
|
Object.defineProperty(k.prototype, "isDirty", {
|
|
559
559
|
get: function () { return this._isDirty; },
|
|
@@ -625,14 +625,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
625
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
626
|
return k;
|
|
627
627
|
}());
|
|
628
|
-
var z =
|
|
629
|
-
var B =
|
|
630
|
-
var W = function (e, i, r, n, a, s, o, l, c) {
|
|
628
|
+
var z = 0;
|
|
629
|
+
var B = function (e, i, r, n, a, s, o, l, c) {
|
|
631
630
|
if (l === void 0) { l = !1; }
|
|
632
631
|
var u;
|
|
633
632
|
var h = null !== (u = null == o ? void 0 : o.map(function (e) { return "#define ".concat(e); })) && void 0 !== u ? u : [];
|
|
634
633
|
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
|
-
},
|
|
634
|
+
}, W = 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 Bt; }), Promise.resolve().then(function () { return di; })] : [Promise.resolve().then(function () { return Xt; }), Promise.resolve().then(function () { return gi; })]), false)); } }); }, H = 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; }, q = function (e, i, r, n, a, s, o, l, c, u, h) {
|
|
636
635
|
if (s === void 0) { s = 0; }
|
|
637
636
|
if (o === void 0) { o = t.Constants.ALPHA_DISABLE; }
|
|
638
637
|
if (l === void 0) { l = !0; }
|
|
@@ -651,15 +650,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
651
650
|
i.setViewport(), i.applyEffectWrapper(r, l), e.depthCullingState.cull = !1;
|
|
652
651
|
var g = r.effect;
|
|
653
652
|
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
|
-
},
|
|
655
|
-
var
|
|
656
|
-
function
|
|
653
|
+
}, Z = 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 B(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 Bt; }), Promise.resolve().then(function () { return yi; })] : [Promise.resolve().then(function () { return Xt; }), Promise.resolve().then(function () { return Pi; })]), false)); }); }, $ = 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"), B(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 Bt; }), Promise.resolve().then(function () { return Gi; })] : [Promise.resolve().then(function () { return Xt; }), Promise.resolve().then(function () { return Zi; })]), 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_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"), B(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 Bt; }), Promise.resolve().then(function () { return Xi; })] : [Promise.resolve().then(function () { return Xt; }), Promise.resolve().then(function () { return er; })]), false)); }); }, j = 100, X = 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); }; };
|
|
654
|
+
var Q = /** @class */ (function () {
|
|
655
|
+
function Q(e, _a) {
|
|
657
656
|
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
657
|
var _this = this;
|
|
659
658
|
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
659
|
}
|
|
661
|
-
|
|
662
|
-
|
|
660
|
+
Q.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; };
|
|
661
|
+
Q.prototype._init = function (e, t, i, r, n, a) {
|
|
663
662
|
var _this = this;
|
|
664
663
|
var s;
|
|
665
664
|
if ("undefined" == typeof document)
|
|
@@ -681,12 +680,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
681
680
|
this._setSize(c.width, c.height), this._engine.onResizeObservable.add(function () { var e = _this._engine.getRenderingCanvasClientRect(); e && _this._setSize(e.width, e.height); });
|
|
682
681
|
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
682
|
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 =
|
|
683
|
+
var m = X(r), p = X(n), f = X(a);
|
|
685
684
|
e.setRenderingOrder(0, m, p, f), this._renderObserver = e.onBeforeRenderObservable.add(function () { _this._render(e, e.activeCamera); });
|
|
686
685
|
};
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
686
|
+
Q.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 }; };
|
|
687
|
+
Q.prototype._getSize = function () { return { width: this._width, height: this._height }; };
|
|
688
|
+
Q.prototype._setSize = function (e, t) {
|
|
690
689
|
var e_29, _a;
|
|
691
690
|
if (this._width = e, this._height = t, this._heightHalf = this._height / 2, !this._inSceneElements || !this._overlayElements)
|
|
692
691
|
return;
|
|
@@ -705,13 +704,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
705
704
|
finally { if (e_29) throw e_29.error; }
|
|
706
705
|
}
|
|
707
706
|
};
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
return t.Matrix.Identity(); var n = e.getWorldMatrix(); var a = 1, s = 1; e.sourceWidth && e.sourceHeight && (a = e.width / (e.sourceWidth /
|
|
712
|
-
|
|
707
|
+
Q.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]), ")"); };
|
|
708
|
+
Q.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]), ")"); };
|
|
709
|
+
Q.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)
|
|
710
|
+
return t.Matrix.Identity(); var n = e.getWorldMatrix(); var a = 1, s = 1; e.sourceWidth && e.sourceHeight && (a = e.width / (e.sourceWidth / j), s = e.height / (e.sourceHeight / j)); 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) * j * h, (-this._cameraWorldMatrix.m[13] + d.y) * j * h, (this._cameraWorldMatrix.m[14] - d.z) * j, this._cameraWorldMatrix.m[15] * Q.PROJECTION_SCALE_FACTOR * j), u.multiplyAtIndex(3, j), u.multiplyAtIndex(7, j), u.multiplyAtIndex(11, j), u; };
|
|
711
|
+
Q.prototype._renderHtmlMesh = function (e, i) { var r, n; if (!e.element || !e.element.firstElementChild)
|
|
713
712
|
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
|
-
|
|
713
|
+
Q.prototype._render = function (e, i) {
|
|
715
714
|
var e_30, _a, e_31, _b, e_32, _c, e_33, _d;
|
|
716
715
|
var r, n, a, s;
|
|
717
716
|
var o = !1;
|
|
@@ -794,8 +793,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
794
793
|
finally { if (e_33) throw e_33.error; }
|
|
795
794
|
}
|
|
796
795
|
};
|
|
797
|
-
|
|
798
|
-
|
|
796
|
+
Q.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); };
|
|
797
|
+
Q.prototype._updateContainerPositionIfNeeded = function () {
|
|
799
798
|
var e_40, _a;
|
|
800
799
|
var e, i;
|
|
801
800
|
var r = this._engine.getRenderingCanvasClientRect();
|
|
@@ -823,135 +822,135 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
823
822
|
}
|
|
824
823
|
}
|
|
825
824
|
};
|
|
826
|
-
|
|
827
|
-
|
|
825
|
+
Q.prototype._epsilon = function (e) { return Math.abs(e) < 1e-10 ? 0 : e; };
|
|
826
|
+
Q.prototype._getAncestorMarginsAndPadding = function (e) { var t = 0, i = 0, r = 0, n = 0; for (; e && e !== document.body && e !== document.documentElement;) {
|
|
828
827
|
var a_2 = window.getComputedStyle(e);
|
|
829
828
|
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
829
|
} return { marginTop: t, marginLeft: i, paddingTop: r, paddingLeft: n }; };
|
|
831
|
-
return
|
|
830
|
+
return Q;
|
|
832
831
|
}());
|
|
833
|
-
|
|
834
|
-
var
|
|
835
|
-
var
|
|
836
|
-
var
|
|
837
|
-
var
|
|
838
|
-
var
|
|
839
|
-
var
|
|
840
|
-
return; var 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 =
|
|
842
|
-
var
|
|
843
|
-
function
|
|
832
|
+
Q.PROJECTION_SCALE_FACTOR = 1e-5;
|
|
833
|
+
var K = [];
|
|
834
|
+
var J = new Map;
|
|
835
|
+
var ee = [], te = null;
|
|
836
|
+
var ie = function (e) { le("In pointerEventsCapture.requestRelease - Pointer events release requested for ".concat(e)), e && e !== te ? re(e) ? J.delete(e) : (le("In pointerEventsCapture.requestRelease - Received release request ".concat(e, " but no matching capture request was received")), ee.includes(e) || ee.push(e)) : ne(); }, re = function (e) { var t = !1; return K = K.filter(function (i) { return i !== e || (t = !0, le("In pointerEventsCapture.cancelRequest - Canceling pointer events capture request ".concat(e)), !1); }), t; }, ne = function () { var e = oe(); le("In pointerEventsCapture.transferPointerEventsOwnership - Transferrring pointer events from ".concat(te, " to ").concat(e)), ae(), e && se(e); }, ae = function () { var e; le("In pointerEventsCapture.doRelease - Releasing pointer events from ".concat(te)), te && (null === (e = J.get(te)) || void 0 === e || e.release(), J.delete(te), te = null); }, se = function (e) { var t; e && (null === (t = J.get(e)) || void 0 === t || t.capture()), te = e, le("In pointerEventsCapture.doCapture - Pointer events now captured by ".concat(e)); }, oe = function () { return K.length > 0 ? K.shift() : null; }, le = function (e) { ("undefined" == typeof window || window["pointer-events-capture-debug"]) && t.Tools.Log("".concat(performance.now(), " - game.scene.pointerEvents - ").concat(e, "\ncurrentOwner: ").concat(te, "\nqueue: ").concat(K, "\nunmatched: ").concat(ee)); };
|
|
837
|
+
var ce = null, ue = 0;
|
|
838
|
+
var he = new WeakMap, de = function (e) { "undefined" != typeof document && (0 === ue && (document.addEventListener("pointermove", fe), document.addEventListener("touchstart", fe), ce = null != ce ? ce : e, t.Logger.Log("PointerEventsCaptureBehavior: Starting observation of pointer move events."), ce.onDisposeObservable.add(me)), ue++); }, me = function () { document.removeEventListener("pointermove", fe), document.removeEventListener("touchstart", fe), ce = null, t.Logger.Log("PointerEventsCaptureBehavior: Stopping observation of pointer move events."), ue = 0; }, pe = function () { "undefined" != typeof document && ce && (ue--, ue <= 0 && me()); }, fe = function (e) { if (!ce)
|
|
839
|
+
return; var t = ce.getEngine().getRenderingCanvasClientRect(); if (!t)
|
|
840
|
+
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 = ce.pick(n, a, function (e) { var t = he.get(e); return e.isEnabled() && void 0 !== t && t._captureOnPointerEnter; }); var l; l = o.hit ? o.pickedMesh : null; var c = parseInt(te || ""); l && l.uniqueId === c || (!c || l && l.uniqueId === c || ie(te), l && (s = he.get(l), s.capturePointerEvents())); };
|
|
841
|
+
var ge = /** @class */ (function () {
|
|
842
|
+
function ge(e, i, _a) {
|
|
844
843
|
var _b = _a === void 0 ? {} : _a, _c = _b.captureOnPointerEnter, r = _c === void 0 ? !0 : _c;
|
|
845
844
|
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
845
|
}
|
|
847
|
-
Object.defineProperty(
|
|
846
|
+
Object.defineProperty(ge.prototype, "attachedMesh", {
|
|
848
847
|
get: function () { return this._attachedMesh; },
|
|
849
848
|
set: function (e) { this._attachedMesh = e; },
|
|
850
849
|
enumerable: false,
|
|
851
850
|
configurable: true
|
|
852
851
|
});
|
|
853
|
-
Object.defineProperty(
|
|
852
|
+
Object.defineProperty(ge.prototype, "attachedNode", {
|
|
854
853
|
get: function () { return this._attachedMesh; },
|
|
855
854
|
enumerable: false,
|
|
856
855
|
configurable: true
|
|
857
856
|
});
|
|
858
|
-
Object.defineProperty(
|
|
859
|
-
set: function (e) { this._captureOnPointerEnter !== e && (this._captureOnPointerEnter = e, this._attachedMesh && (this._captureOnPointerEnter ?
|
|
857
|
+
Object.defineProperty(ge.prototype, "captureOnPointerEnter", {
|
|
858
|
+
set: function (e) { this._captureOnPointerEnter !== e && (this._captureOnPointerEnter = e, this._attachedMesh && (this._captureOnPointerEnter ? de(this._attachedMesh.getScene()) : pe())); },
|
|
860
859
|
enumerable: false,
|
|
861
860
|
configurable: true
|
|
862
861
|
});
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
return
|
|
862
|
+
ge.prototype.init = function () { };
|
|
863
|
+
ge.prototype.attach = function (e) { this.attachedMesh = e, he.set(e, this), this._captureOnPointerEnter && de(e.getScene()); };
|
|
864
|
+
ge.prototype.detach = function () { this.attachedMesh && (he.delete(this.attachedMesh), this._captureOnPointerEnter && pe(), this.attachedMesh = null); };
|
|
865
|
+
ge.prototype.dispose = function () { this.detach(); };
|
|
866
|
+
ge.prototype.releasePointerEvents = function () { this.attachedMesh && ie(this.attachedMesh.uniqueId.toString()); };
|
|
867
|
+
ge.prototype.capturePointerEvents = function () { var e, t, i; this.attachedMesh && (e = this.attachedMesh.uniqueId.toString(), t = this._captureCallback, i = this._releaseCallback, le("In pointerEventsCapture.requestCapture - Pointer events capture requested for ".concat(e)), (function (e) { var t = !1; return ee = ee.filter(function (i) { return i !== e || (t = !0, !1); }), t; })(e) ? le("In pointerEventsCapture.requestCapture - Capture request matched previous release request ".concat(e, ". Cancelling capture request")) : (e !== te && (function (e, t, i) { le("In pointerEventsCapture.enqueueCaptureRequest - Enqueueing capture request for ".concat(e)), K.includes(e) || (K.push(e), J.set(e, { capture: t, release: i })); })(e, t, i), te || ne())); };
|
|
868
|
+
return ge;
|
|
870
869
|
}());
|
|
871
|
-
var
|
|
872
|
-
var
|
|
873
|
-
__extends(
|
|
874
|
-
function
|
|
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 ?
|
|
870
|
+
var ve = { 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")); } } };
|
|
871
|
+
var _e = /** @class */ (function (_super) {
|
|
872
|
+
__extends(_e, _super);
|
|
873
|
+
function _e(e, i, _a) {
|
|
874
|
+
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 ? ve.NONE : _f;
|
|
876
875
|
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 =
|
|
876
|
+
_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 = ve.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 ge(_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
877
|
return _this;
|
|
879
878
|
}
|
|
880
|
-
Object.defineProperty(
|
|
879
|
+
Object.defineProperty(_e.prototype, "isHtmlMesh", {
|
|
881
880
|
get: function () { return !0; },
|
|
882
881
|
enumerable: false,
|
|
883
882
|
configurable: true
|
|
884
883
|
});
|
|
885
|
-
Object.defineProperty(
|
|
884
|
+
Object.defineProperty(_e.prototype, "sourceWidth", {
|
|
886
885
|
get: function () { return this._sourceWidth; },
|
|
887
886
|
enumerable: false,
|
|
888
887
|
configurable: true
|
|
889
888
|
});
|
|
890
|
-
Object.defineProperty(
|
|
889
|
+
Object.defineProperty(_e.prototype, "sourceHeight", {
|
|
891
890
|
get: function () { return this._sourceHeight; },
|
|
892
891
|
enumerable: false,
|
|
893
892
|
configurable: true
|
|
894
893
|
});
|
|
895
|
-
Object.defineProperty(
|
|
894
|
+
Object.defineProperty(_e.prototype, "width", {
|
|
896
895
|
get: function () { return this._width; },
|
|
897
896
|
enumerable: false,
|
|
898
897
|
configurable: true
|
|
899
898
|
});
|
|
900
|
-
Object.defineProperty(
|
|
899
|
+
Object.defineProperty(_e.prototype, "height", {
|
|
901
900
|
get: function () { return this._height; },
|
|
902
901
|
enumerable: false,
|
|
903
902
|
configurable: true
|
|
904
903
|
});
|
|
905
|
-
Object.defineProperty(
|
|
904
|
+
Object.defineProperty(_e.prototype, "element", {
|
|
906
905
|
get: function () { return this._element; },
|
|
907
906
|
enumerable: false,
|
|
908
907
|
configurable: true
|
|
909
908
|
});
|
|
910
|
-
Object.defineProperty(
|
|
909
|
+
Object.defineProperty(_e.prototype, "requiresUpdate", {
|
|
911
910
|
get: function () { return this._requiresUpdate; },
|
|
912
911
|
enumerable: false,
|
|
913
912
|
configurable: true
|
|
914
913
|
});
|
|
915
|
-
Object.defineProperty(
|
|
914
|
+
Object.defineProperty(_e.prototype, "captureOnPointerEnter", {
|
|
916
915
|
set: function (e) { this._captureOnPointerEnter = e, this._pointerEventCaptureBehavior && (this._pointerEventCaptureBehavior.captureOnPointerEnter = e); },
|
|
917
916
|
enumerable: false,
|
|
918
917
|
configurable: true
|
|
919
918
|
});
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
919
|
+
_e.prototype.dispose = function () { var e; _super.prototype.dispose.call(this), null === (e = this._element) || void 0 === e || e.remove(), this._element = void 0, this._pointerEventCaptureBehavior && (this._pointerEventCaptureBehavior.dispose(), this._pointerEventCaptureBehavior = null); };
|
|
920
|
+
_e.prototype._markAsUpdated = function () { this._requiresUpdate = !1; };
|
|
921
|
+
_e.prototype.setContent = function (e, t, i) { this._setAsReady(!1), this._sourceWidth = null, this._sourceHeight = null, this._element && (this._width = t, this._height = i, this._requiresUpdate = !0, this.scaling.setAll(1), e && (this._element.appendChild(this._fitStrategy.wrapElement(e)), this._updateScaleIfNecessary()), this.sourceWidth && this.sourceHeight && this._setAsReady(!0)); };
|
|
922
|
+
_e.prototype.setEnabled = function (e) { this._enabled = e, e && !this._ready || this._doSetEnabled(e); };
|
|
923
|
+
_e.prototype.setContentSizePx = function (e, t) { this._sourceWidth = e, this._sourceHeight = t, this._element && this._element.firstElementChild && (this._fitStrategy.updateSize(this._element.firstElementChild, e, t), this._updateScaleIfNecessary(), this.width && this.height && this._setAsReady(!0)); };
|
|
924
|
+
_e.prototype._setAsReady = function (e) { this._ready = e, e ? this._doSetEnabled(this._enabled) : this._doSetEnabled(!1); };
|
|
925
|
+
_e.prototype._doSetEnabled = function (e) {
|
|
927
926
|
var _this = this;
|
|
928
927
|
var t;
|
|
929
928
|
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
929
|
};
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
930
|
+
_e.prototype._updateScaleIfNecessary = function () { this.scaling.setAll(1), this._inverseScaleMatrix && (this.bakeTransformIntoVertices(this._inverseScaleMatrix), this._inverseScaleMatrix = null); var e = this._width || 1, i = this._height || 1, r = t.Matrix.Scaling(e, i, 1); this.bakeTransformIntoVertices(r), this._inverseScaleMatrix = new t.Matrix, r.invertToRef(this._inverseScaleMatrix); };
|
|
931
|
+
_e.prototype._createMask = function () { t.CreatePlaneVertexData({ width: 1, height: 1 }).applyToMesh(this); var e = this.getScene(); this.checkCollisions = !0; var i = new t.StandardMaterial("".concat(this.id, "-mat"), e); this._isCanvasOverlay || (i.backFaceCulling = !1, i.disableColorWrite = !0, i.disableLighting = !0), this.material = i, this.material.freeze(); };
|
|
932
|
+
_e.prototype._setElementzIndex = function (e) { this._element && (this._element.style.zIndex = "".concat(e)); };
|
|
933
|
+
_e.prototype.capturePointerEvents = function () { this._element && (this._element.style.pointerEvents = "auto", document.getElementsByTagName("body")[0].style.pointerEvents = "none"); };
|
|
934
|
+
_e.prototype.releasePointerEvents = function () { this._element && (document.getElementsByTagName("body")[0].style.pointerEvents = "auto", this._element.style.pointerEvents = "none"); };
|
|
935
|
+
_e.prototype._createElement = function () { if ("undefined" == typeof document)
|
|
937
936
|
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
|
|
937
|
+
return _e;
|
|
939
938
|
}(t.Mesh));
|
|
940
|
-
var
|
|
941
|
-
!function (e) { e[e.SPACE = 32] = "SPACE", e[e.TOFU = 65532] = "TOFU"; }(
|
|
942
|
-
var
|
|
943
|
-
var
|
|
944
|
-
function
|
|
945
|
-
this.text = e, this.fontAsset = t, this.options = Object.assign(Object.assign({},
|
|
939
|
+
var Se;
|
|
940
|
+
!function (e) { e[e.SPACE = 32] = "SPACE", e[e.TOFU = 65532] = "TOFU"; }(Se || (Se = {}));
|
|
941
|
+
var ye = { maxWidth: 1 / 0, lineHeight: 1, letterSpacing: 1, tabSize: 4, whiteSpace: "pre-line", textAlign: "center", translate: { x: -.5, y: -.5 } };
|
|
942
|
+
var Te = /** @class */ (function () {
|
|
943
|
+
function Te(e, t, i) {
|
|
944
|
+
this.text = e, this.fontAsset = t, this.options = Object.assign(Object.assign({}, ye), i);
|
|
946
945
|
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
946
|
this.paragraph = r, this.lines = n, this.glyphs = a, this.width = s, this.height = o;
|
|
948
947
|
}
|
|
949
|
-
Object.defineProperty(
|
|
948
|
+
Object.defineProperty(Te.prototype, "lineHeight", {
|
|
950
949
|
get: function () { return this.fontAsset._font.common.lineHeight * this.options.lineHeight; },
|
|
951
950
|
enumerable: false,
|
|
952
951
|
configurable: true
|
|
953
952
|
});
|
|
954
|
-
|
|
953
|
+
Te.prototype._computeMetrics = function (e) {
|
|
955
954
|
var e_42, _a;
|
|
956
955
|
var _this = this;
|
|
957
956
|
var t = this._collapse(e), i = this._breakLines(t).map(function (e) { return e.trim(); }), r = [];
|
|
@@ -993,9 +992,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
993
992
|
var s = r.flatMap(function (e) { return e.glyphs; });
|
|
994
993
|
return { paragraph: i.join("\n"), lines: r, glyphs: s, width: n, height: a };
|
|
995
994
|
};
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
995
|
+
Te.prototype._breakLines = function (e) { return e.split("\n"); };
|
|
996
|
+
Te.prototype._collapse = function (e) { return e.replace(/\t/g, " ".repeat(this.options.tabSize)).replace(/ +/g, " "); };
|
|
997
|
+
Te.prototype._wrap = function (e, t) {
|
|
999
998
|
if (t === void 0) { t = 0; }
|
|
1000
999
|
var i = new Array;
|
|
1001
1000
|
var r, n = t, a = new Array, s = 0, o = 0, l = 0, c = l;
|
|
@@ -1010,37 +1009,37 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1010
1009
|
}
|
|
1011
1010
|
return a.length > 0 && u(), i;
|
|
1012
1011
|
};
|
|
1013
|
-
return
|
|
1012
|
+
return Te;
|
|
1014
1013
|
}());
|
|
1015
|
-
var
|
|
1016
|
-
function
|
|
1014
|
+
var Ae = /** @class */ (function () {
|
|
1015
|
+
function Ae(e, i, r) {
|
|
1017
1016
|
if (i === void 0) { i = 0; }
|
|
1018
1017
|
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
1018
|
var n = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
|
|
1020
1019
|
this._spriteBuffer = new t.Buffer(e, n, !1, 2), this._vertexBuffers.offsets = this._spriteBuffer.createVertexBuffer("offsets", 0, 2), this._resizeBuffers(128);
|
|
1021
1020
|
}
|
|
1022
|
-
Object.defineProperty(
|
|
1021
|
+
Object.defineProperty(Ae.prototype, "parent", {
|
|
1023
1022
|
get: function () { return this._parent; },
|
|
1024
1023
|
set: function (e) { this._parent = e; },
|
|
1025
1024
|
enumerable: false,
|
|
1026
1025
|
configurable: true
|
|
1027
1026
|
});
|
|
1028
|
-
Object.defineProperty(
|
|
1027
|
+
Object.defineProperty(Ae.prototype, "transformMatrix", {
|
|
1029
1028
|
get: function () { return this._transformMatrix; },
|
|
1030
1029
|
set: function (e) { this._transformMatrix = e; },
|
|
1031
1030
|
enumerable: false,
|
|
1032
1031
|
configurable: true
|
|
1033
1032
|
});
|
|
1034
|
-
Object.defineProperty(
|
|
1033
|
+
Object.defineProperty(Ae.prototype, "characterCount", {
|
|
1035
1034
|
get: function () { return this._charMatrices.length / 16; },
|
|
1036
1035
|
enumerable: false,
|
|
1037
1036
|
configurable: true
|
|
1038
1037
|
});
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1038
|
+
Ae.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); };
|
|
1039
|
+
Ae.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++; };
|
|
1040
|
+
Ae.prototype.addParagraph = function (e, i, r) {
|
|
1042
1041
|
var _this = this;
|
|
1043
|
-
var n = new
|
|
1042
|
+
var n = new Te(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
1043
|
var c = r;
|
|
1045
1044
|
if (!c) {
|
|
1046
1045
|
var e_45 = n.lineHeight * a, i_9 = n.lines.length * e_45 / 2;
|
|
@@ -1050,11 +1049,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1050
1049
|
var u = this._charUvs.length, h = this._charMatrices.length;
|
|
1051
1050
|
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
1051
|
};
|
|
1053
|
-
|
|
1054
|
-
|
|
1052
|
+
Ae.prototype.clearParagraphs = function () { this._charMatrices.length = 0, this._charUvs.length = 0, this._baseLine = 0, this._isDirty = !0; };
|
|
1053
|
+
Ae.prototype.render = function (e, i) { var r = this._drawWrapperBase, n = r.effect; if (!n.isReady())
|
|
1055
1054
|
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
|
-
|
|
1057
|
-
|
|
1055
|
+
Ae.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); };
|
|
1056
|
+
Ae.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
1057
|
switch (_b.label) {
|
|
1059
1058
|
case 0:
|
|
1060
1059
|
if (!t.isWebGPU) return [3 /*break*/, 2];
|
|
@@ -1074,53 +1073,53 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1074
1073
|
n = 0;
|
|
1075
1074
|
if (!t.isWebGPU) return [3 /*break*/, 7];
|
|
1076
1075
|
n = 1;
|
|
1077
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return
|
|
1076
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return De; })];
|
|
1078
1077
|
case 5:
|
|
1079
1078
|
i = (_b.sent()).msdfVertexShaderWGSL.shader;
|
|
1080
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return
|
|
1079
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return Ve; })];
|
|
1081
1080
|
case 6:
|
|
1082
1081
|
_a = (r = (_b.sent()).msdfPixelShaderWGSL.shader);
|
|
1083
1082
|
return [3 /*break*/, 10];
|
|
1084
|
-
case 7: return [4 /*yield*/, Promise.resolve().then(function () { return
|
|
1083
|
+
case 7: return [4 /*yield*/, Promise.resolve().then(function () { return Re; })];
|
|
1085
1084
|
case 8:
|
|
1086
1085
|
i = (_b.sent()).msdfVertexShader.shader;
|
|
1087
|
-
return [4 /*yield*/, Promise.resolve().then(function () { return
|
|
1086
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return Ie; })];
|
|
1088
1087
|
case 9:
|
|
1089
1088
|
_a = (r = (_b.sent()).msdfPixelShader.shader);
|
|
1090
1089
|
_b.label = 10;
|
|
1091
1090
|
case 10:
|
|
1092
1091
|
_a;
|
|
1093
|
-
a = new
|
|
1092
|
+
a = new Ae(t, n, e);
|
|
1094
1093
|
return [2 /*return*/, (a._setShaders(i, r), a)];
|
|
1095
1094
|
}
|
|
1096
1095
|
}); }); };
|
|
1097
|
-
return
|
|
1096
|
+
return Ae;
|
|
1098
1097
|
}());
|
|
1099
|
-
var
|
|
1100
|
-
t.ShaderStore.ShadersStore[
|
|
1101
|
-
var
|
|
1102
|
-
var
|
|
1103
|
-
var
|
|
1104
|
-
t.ShaderStore.ShadersStore[
|
|
1105
|
-
var
|
|
1106
|
-
var
|
|
1107
|
-
var
|
|
1108
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
1109
|
-
var
|
|
1110
|
-
var
|
|
1111
|
-
var
|
|
1112
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
1113
|
-
var
|
|
1114
|
-
var
|
|
1115
|
-
var
|
|
1116
|
-
var
|
|
1117
|
-
function
|
|
1118
|
-
var
|
|
1119
|
-
__extends(
|
|
1120
|
-
function
|
|
1098
|
+
var Le = "msdfVertexShader", Pe = "#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);}";
|
|
1099
|
+
t.ShaderStore.ShadersStore[Le] || (t.ShaderStore.ShadersStore[Le] = Pe);
|
|
1100
|
+
var Ee = { name: Le, shader: Pe };
|
|
1101
|
+
var Re = { __proto__: null, msdfVertexShader: Ee };
|
|
1102
|
+
var Ce = "msdfPixelShader", xe = "#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);}";
|
|
1103
|
+
t.ShaderStore.ShadersStore[Ce] || (t.ShaderStore.ShadersStore[Ce] = xe);
|
|
1104
|
+
var Me = { name: Ce, shader: xe };
|
|
1105
|
+
var Ie = { __proto__: null, msdfPixelShader: Me };
|
|
1106
|
+
var we = "msdfVertexShader", be = "#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);}";
|
|
1107
|
+
t.ShaderStore.ShadersStoreWGSL[we] || (t.ShaderStore.ShadersStoreWGSL[we] = be);
|
|
1108
|
+
var Oe = { name: we, shader: be };
|
|
1109
|
+
var De = { __proto__: null, msdfVertexShaderWGSL: Oe };
|
|
1110
|
+
var Ne = "msdfPixelShader", Ue = "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);}";
|
|
1111
|
+
t.ShaderStore.ShadersStoreWGSL[Ne] || (t.ShaderStore.ShadersStoreWGSL[Ne] = Ue);
|
|
1112
|
+
var Fe = { name: Ne, shader: Ue };
|
|
1113
|
+
var Ve = { __proto__: null, msdfPixelShaderWGSL: Fe };
|
|
1114
|
+
var Ge = ["multiTextureCompositeAlphaBlend", "multiTextureCompositeAlphaMax", "multiTextureCompositeAdd", "multiTextureCompositeMultiply", "multiTextureCompositeSubtract", "multiTextureCompositeScreen"], ke = ["ALPHA_BLEND", "ALPHA_MAX", "ADD", "MULTIPLY", "SUBTRACT", "SCREEN"];
|
|
1115
|
+
var ze = !1;
|
|
1116
|
+
function Be() { ze || (ze = !0, t.RegisterEnginesExtensionsEngineTexture2DArrayImageSource(), t.RegisterEnginesWebGPUExtensionsEngineTexture2DArrayImageSource()); }
|
|
1117
|
+
var We = /** @class */ (function (_super) {
|
|
1118
|
+
__extends(We, _super);
|
|
1119
|
+
function We(r, n, a, s) {
|
|
1121
1120
|
var _this = this;
|
|
1122
1121
|
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,
|
|
1122
|
+
_this = _super.call(this, a) || this, _this.onLoadObservable = new t.Observable, _this._pollTimer = null, _this._pollInFlight = !1, _this._disposed = !1, _this._mipSuppressCount = 0, Be();
|
|
1124
1123
|
var y = !1, T = !1;
|
|
1125
1124
|
try {
|
|
1126
1125
|
var A_1 = a.getEngine();
|
|
@@ -1142,11 +1141,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1142
1141
|
switch (_b.label) {
|
|
1143
1142
|
case 0:
|
|
1144
1143
|
if (!(1 === M_1)) return [3 /*break*/, 2];
|
|
1145
|
-
return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return
|
|
1144
|
+
return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return hr; }), Promise.resolve().then(function () { return pr; }), Promise.resolve().then(function () { return vr; }), Promise.resolve().then(function () { return yr; }), Promise.resolve().then(function () { return Lr; }), Promise.resolve().then(function () { return Rr; })])];
|
|
1146
1145
|
case 1:
|
|
1147
1146
|
_a = _b.sent();
|
|
1148
1147
|
return [3 /*break*/, 4];
|
|
1149
|
-
case 2: return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return
|
|
1148
|
+
case 2: return [4 /*yield*/, Promise.all([Promise.resolve().then(function () { return Mr; }), Promise.resolve().then(function () { return br; }), Promise.resolve().then(function () { return Nr; }), Promise.resolve().then(function () { return Vr; }), Promise.resolve().then(function () { return zr; }), Promise.resolve().then(function () { return Hr; })])];
|
|
1150
1149
|
case 3:
|
|
1151
1150
|
_a = _b.sent();
|
|
1152
1151
|
_b.label = 4;
|
|
@@ -1155,7 +1154,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1155
1154
|
return [2 /*return*/];
|
|
1156
1155
|
}
|
|
1157
1156
|
}); }); } };
|
|
1158
|
-
_this._compositeInternal = new t.ProceduralTexture(r, { width: R_1, height: C_1 },
|
|
1157
|
+
_this._compositeInternal = new t.ProceduralTexture(r, { width: R_1, height: C_1 }, Ge[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(ke[P_1]), _this.composite.setTexture("uLayers", _this._arrayTexture), _this.composite.setInt("uLayerCount", _this._layerCount);
|
|
1159
1158
|
var w_1 = null;
|
|
1160
1159
|
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
1160
|
throw new Error("MultiTexture: no 2D canvas surface available (requires DOM or OffscreenCanvas).");
|
|
@@ -1180,57 +1179,57 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1180
1179
|
}
|
|
1181
1180
|
return _this;
|
|
1182
1181
|
}
|
|
1183
|
-
Object.defineProperty(
|
|
1182
|
+
Object.defineProperty(We.prototype, "composite", {
|
|
1184
1183
|
get: function () { return this._compositeInternal; },
|
|
1185
1184
|
enumerable: false,
|
|
1186
1185
|
configurable: true
|
|
1187
1186
|
});
|
|
1188
|
-
Object.defineProperty(
|
|
1187
|
+
Object.defineProperty(We.prototype, "layerCount", {
|
|
1189
1188
|
get: function () { return this._layerCount; },
|
|
1190
1189
|
enumerable: false,
|
|
1191
1190
|
configurable: true
|
|
1192
1191
|
});
|
|
1193
|
-
Object.defineProperty(
|
|
1192
|
+
Object.defineProperty(We.prototype, "arrayTexture", {
|
|
1194
1193
|
get: function () { return this._arrayTexture; },
|
|
1195
1194
|
enumerable: false,
|
|
1196
1195
|
configurable: true
|
|
1197
1196
|
});
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1197
|
+
We.prototype.getInternalTexture = function () { return this.composite.getInternalTexture(); };
|
|
1198
|
+
We.prototype.isReady = function () { return this.composite.isReady(); };
|
|
1199
|
+
We.prototype._renderComposite = function () {
|
|
1201
1200
|
var _this = this;
|
|
1202
1201
|
this.composite.isReady(), this.composite.executeWhenReady(function () { _this._disposed || _this.composite.render(); });
|
|
1203
1202
|
};
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
Object.defineProperty(
|
|
1203
|
+
We.prototype.getSize = function () { return this.composite.getSize(); };
|
|
1204
|
+
We.prototype.getBaseSize = function () { return this.composite.getBaseSize(); };
|
|
1205
|
+
Object.defineProperty(We.prototype, "samplingMode", {
|
|
1207
1206
|
get: function () { return this.composite.samplingMode; },
|
|
1208
1207
|
enumerable: false,
|
|
1209
1208
|
configurable: true
|
|
1210
1209
|
});
|
|
1211
|
-
|
|
1210
|
+
We.prototype.updateSamplingMode = function (e, t) {
|
|
1212
1211
|
if (t === void 0) { t = !1; }
|
|
1213
1212
|
this.composite.updateSamplingMode(e, t);
|
|
1214
1213
|
};
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
Object.defineProperty(
|
|
1214
|
+
We.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); };
|
|
1215
|
+
We.prototype._readPixelsSync = function (e, t, i, r, n) { return this.composite._readPixelsSync(e, t, i, r, n); };
|
|
1216
|
+
Object.defineProperty(We.prototype, "textureFormat", {
|
|
1218
1217
|
get: function () { return this.composite.textureFormat; },
|
|
1219
1218
|
enumerable: false,
|
|
1220
1219
|
configurable: true
|
|
1221
1220
|
});
|
|
1222
|
-
Object.defineProperty(
|
|
1221
|
+
Object.defineProperty(We.prototype, "textureType", {
|
|
1223
1222
|
get: function () { return this.composite.textureType; },
|
|
1224
1223
|
enumerable: false,
|
|
1225
1224
|
configurable: true
|
|
1226
1225
|
});
|
|
1227
|
-
Object.defineProperty(
|
|
1226
|
+
Object.defineProperty(We.prototype, "blendMode", {
|
|
1228
1227
|
get: function () { return this._blendMode; },
|
|
1229
|
-
set: function (e) { e !== this._blendMode && (this._blendMode = e, this.composite.setFragment(
|
|
1228
|
+
set: function (e) { e !== this._blendMode && (this._blendMode = e, this.composite.setFragment(Ge[e]), this.composite.defines = this._buildDefines(ke[e]), this._renderComposite()); },
|
|
1230
1229
|
enumerable: false,
|
|
1231
1230
|
configurable: true
|
|
1232
1231
|
});
|
|
1233
|
-
|
|
1232
|
+
We.prototype.updateLayerAsync = function (e, t) { return i(this, void 0, void 0, function () { var i; return __generator(this, function (_a) {
|
|
1234
1233
|
switch (_a.label) {
|
|
1235
1234
|
case 0:
|
|
1236
1235
|
if (!Number.isInteger(e) || e < 0 || e >= this._layerCount)
|
|
@@ -1243,7 +1242,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1243
1242
|
return [2 /*return*/];
|
|
1244
1243
|
}
|
|
1245
1244
|
}); }); };
|
|
1246
|
-
|
|
1245
|
+
We.prototype.addLayerAsync = function (e) { return i(this, void 0, void 0, function () { var t, i; return __generator(this, function (_a) {
|
|
1247
1246
|
switch (_a.label) {
|
|
1248
1247
|
case 0:
|
|
1249
1248
|
t = this._layerCount;
|
|
@@ -1267,7 +1266,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1267
1266
|
case 4: return [2 /*return*/, t];
|
|
1268
1267
|
}
|
|
1269
1268
|
}); }); };
|
|
1270
|
-
|
|
1269
|
+
We.prototype.insertLayerAsync = function (e, t) { return i(this, void 0, void 0, function () { var i, t_11; return __generator(this, function (_a) {
|
|
1271
1270
|
switch (_a.label) {
|
|
1272
1271
|
case 0:
|
|
1273
1272
|
if (!Number.isInteger(e) || e < 0 || e > this._layerCount)
|
|
@@ -1295,7 +1294,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1295
1294
|
case 4: return [2 /*return*/, e];
|
|
1296
1295
|
}
|
|
1297
1296
|
}); }); };
|
|
1298
|
-
|
|
1297
|
+
We.prototype.removeLayerAsync = function (e) { return i(this, void 0, void 0, function () { var t, t_12; return __generator(this, function (_a) {
|
|
1299
1298
|
if (!Number.isInteger(e) || e < 0 || e >= this._layerCount)
|
|
1300
1299
|
throw new RangeError("MultiTexture: layer index ".concat(e, " out of range [0, ").concat(this._layerCount, ")."));
|
|
1301
1300
|
t = this._layers.splice(e, 1)[0];
|
|
@@ -1310,7 +1309,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1310
1309
|
}
|
|
1311
1310
|
return [2 /*return*/];
|
|
1312
1311
|
}); }); };
|
|
1313
|
-
|
|
1312
|
+
We.prototype.dispose = function () { if (!this._disposed) {
|
|
1314
1313
|
this._disposed = !0, null !== this._pollTimer && (clearInterval(this._pollTimer), this._pollTimer = null);
|
|
1315
1314
|
for (var e_49 = 0; e_49 < this._layers.length; e_49++) {
|
|
1316
1315
|
var t_13 = this._layers[e_49];
|
|
@@ -1320,16 +1319,16 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1320
1319
|
this.pixels[e_50] = null;
|
|
1321
1320
|
this._layers.length = 0, this._canvas = null, this._ctx = null, this._arrayTexture.dispose(), this.composite.dispose(), _super.prototype.dispose.call(this);
|
|
1322
1321
|
} };
|
|
1323
|
-
|
|
1324
|
-
|
|
1322
|
+
We.prototype.clone = function () { var e = new We(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; };
|
|
1323
|
+
We.prototype.serialize = function (e) {
|
|
1325
1324
|
if (e === void 0) { e = !1; }
|
|
1326
1325
|
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
1326
|
};
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1327
|
+
We.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" : ""); };
|
|
1328
|
+
We.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; };
|
|
1329
|
+
We.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); };
|
|
1330
|
+
We.prototype._createLayerEntry = function (e) { return { url: e, etag: null, lastModified: null, bitmap: null, loaded: !1, generation: 0, warnedLoadFailure: !1 }; };
|
|
1331
|
+
We.prototype._loadEntryOrThrow = function (e) { return i(this, void 0, void 0, function () { var e_51; return __generator(this, function (_a) {
|
|
1333
1332
|
switch (_a.label) {
|
|
1334
1333
|
case 0:
|
|
1335
1334
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -1343,7 +1342,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1343
1342
|
case 3: return [2 /*return*/];
|
|
1344
1343
|
}
|
|
1345
1344
|
}); }); };
|
|
1346
|
-
|
|
1345
|
+
We.prototype._loadEntryAndReport = function (e) { return i(this, void 0, void 0, function () { var e_52; return __generator(this, function (_a) {
|
|
1347
1346
|
switch (_a.label) {
|
|
1348
1347
|
case 0:
|
|
1349
1348
|
_a.trys.push([0, 2, , 3]);
|
|
@@ -1358,18 +1357,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1358
1357
|
case 3: return [2 /*return*/];
|
|
1359
1358
|
}
|
|
1360
1359
|
}); }); };
|
|
1361
|
-
|
|
1360
|
+
We.prototype._warnWatchFailure = function (e, i) { var r, n; if (e.warnedLoadFailure)
|
|
1362
1361
|
return; var a = this._layers.indexOf(e); if (-1 === a)
|
|
1363
1362
|
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
|
-
|
|
1363
|
+
We.prototype._uploadToLayer = function (e, i, r) { if (this._mtOptions.premultiplyAlpha)
|
|
1365
1364
|
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
|
-
|
|
1365
|
+
We.prototype._reuploadSlot = function (e, t) {
|
|
1367
1366
|
if (t === void 0) { t = this._arrayTexture; }
|
|
1368
1367
|
var i = this._layers[e].bitmap;
|
|
1369
1368
|
null !== i ? this._uploadToLayer(t, e, i) : this._clearLayerSlot(t, e);
|
|
1370
1369
|
};
|
|
1371
|
-
|
|
1372
|
-
|
|
1370
|
+
We.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 })); };
|
|
1371
|
+
We.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
1372
|
switch (_a.label) {
|
|
1374
1373
|
case 0:
|
|
1375
1374
|
if (this._disposed)
|
|
@@ -1399,9 +1398,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1399
1398
|
return [2 /*return*/];
|
|
1400
1399
|
}
|
|
1401
1400
|
}); }); };
|
|
1402
|
-
|
|
1401
|
+
We.prototype._uploadBitmap = function (e, t, i) { if (this._disposed)
|
|
1403
1402
|
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
|
-
|
|
1403
|
+
We.prototype._initialize = function () { return i(this, void 0, void 0, function () {
|
|
1405
1404
|
var e, t, r_7, n_3, a_3, s_1, o_1, e_54, e_53;
|
|
1406
1405
|
var _this = this;
|
|
1407
1406
|
return __generator(this, function (_a) {
|
|
@@ -1442,19 +1441,19 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1442
1441
|
}
|
|
1443
1442
|
});
|
|
1444
1443
|
}); };
|
|
1445
|
-
|
|
1446
|
-
|
|
1444
|
+
We.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; };
|
|
1445
|
+
We.prototype._growArray = function () { var e, i, r; var n = this.getScene(), a = 2 * this._maxLayers; if (a > this._deviceMaxLayerCap)
|
|
1447
1446
|
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
1447
|
this._reuploadSlot(e_55, s); this._arrayTexture.dispose(), this._arrayTexture = s, this.composite.setTexture("uLayers", s), this._maxLayers = a, this._renderComposite(); };
|
|
1449
|
-
|
|
1448
|
+
We.prototype._suppressArrayMips = function () { var e; if (null === (e = this._mtOptions.generateMipMaps) || void 0 === e || !e || this._disposed)
|
|
1450
1449
|
return; var t = this._arrayTexture.getInternalTexture(); t && (t.generateMipMaps = !1), this._mipSuppressCount++; };
|
|
1451
|
-
|
|
1450
|
+
We.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
1451
|
return; var t = this._arrayTexture.getInternalTexture(); t && (t.generateMipMaps = !0, this.getScene().getEngine().generateMipmaps(t)); };
|
|
1453
|
-
|
|
1452
|
+
We.prototype._startPolling = function () {
|
|
1454
1453
|
var _this = this;
|
|
1455
1454
|
null !== this._pollTimer || this._disposed || (this._pollTimer = setInterval(function () { _this._poll(); }, this._mtOptions.pollInterval));
|
|
1456
1455
|
};
|
|
1457
|
-
|
|
1456
|
+
We.prototype._poll = function () { return i(this, void 0, void 0, function () {
|
|
1458
1457
|
var e, t, r, n, a, e_56;
|
|
1459
1458
|
var _this = this;
|
|
1460
1459
|
return __generator(this, function (_a) {
|
|
@@ -1526,82 +1525,82 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1526
1525
|
}
|
|
1527
1526
|
});
|
|
1528
1527
|
}); };
|
|
1529
|
-
return
|
|
1528
|
+
return We;
|
|
1530
1529
|
}(t.BaseTexture));
|
|
1531
|
-
var
|
|
1532
|
-
function
|
|
1533
|
-
throw new Error("Recast is not initialized. Please call InitRecast first."); return
|
|
1534
|
-
var
|
|
1535
|
-
e.MultiBlendMode = void 0, (
|
|
1536
|
-
var
|
|
1537
|
-
function
|
|
1530
|
+
var He;
|
|
1531
|
+
function qe() { if (!Ze)
|
|
1532
|
+
throw new Error("Recast is not initialized. Please call InitRecast first."); return Ze; }
|
|
1533
|
+
var Ze;
|
|
1534
|
+
e.MultiBlendMode = void 0, (He = e.MultiBlendMode || (e.MultiBlendMode = {}))[He.ALPHA_BLEND = 0] = "ALPHA_BLEND", He[He.ALPHA_MAX = 1] = "ALPHA_MAX", He[He.ADD = 2] = "ADD", He[He.MULTIPLY = 3] = "MULTIPLY", He[He.SUBTRACT = 4] = "SUBTRACT", He[He.SCREEN = 5] = "SCREEN";
|
|
1535
|
+
var $e = null;
|
|
1536
|
+
function Ye(e, t, i) {
|
|
1538
1537
|
if (e === void 0) { e = []; }
|
|
1539
1538
|
if (t === void 0) { t = 0; }
|
|
1540
1539
|
if (i === void 0) { i = 1; }
|
|
1541
|
-
return new (
|
|
1540
|
+
return new (qe().TileCacheMeshProcess)(function (r, n, a) { for (var e_60 = 0; e_60 < r.polyCount(); ++e_60)
|
|
1542
1541
|
n.set(e_60, t), a.set(e_60, i); e.length > 0 && r.setOffMeshConnections(e); });
|
|
1543
1542
|
}
|
|
1544
|
-
function
|
|
1543
|
+
function je(e, t) { var i = !1; for (; !i;)
|
|
1545
1544
|
i = t.update(e).upToDate; }
|
|
1546
|
-
function
|
|
1547
|
-
function
|
|
1548
|
-
function
|
|
1549
|
-
function
|
|
1545
|
+
function Xe(e) { return Je(e); }
|
|
1546
|
+
function Qe(e) { var t; return Object.assign(Object.assign({}, Xe(e)), { tileSize: null !== (t = e.tileSize) && void 0 !== t ? t : 32 }); }
|
|
1547
|
+
function Ke(e) { var i, r; var n = Object.assign(Object.assign({}, Qe(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 = Ye(e.offMeshConnections)), n; }
|
|
1548
|
+
function Je(e) { return Object.fromEntries(Object.entries(e).filter(function (_a) {
|
|
1550
1549
|
var _b = __read(_a, 2), e = _b[0], t = _b[1];
|
|
1551
1550
|
return void 0 !== t;
|
|
1552
1551
|
})); }
|
|
1553
|
-
function
|
|
1552
|
+
function et(e) { return Object.fromEntries(Object.entries(e).filter(function (_a) {
|
|
1554
1553
|
var _b = __read(_a, 2), e = _b[0], t = _b[1];
|
|
1555
1554
|
return void 0 !== t;
|
|
1556
1555
|
})); }
|
|
1557
|
-
var
|
|
1558
|
-
function
|
|
1556
|
+
var tt = /** @class */ (function () {
|
|
1557
|
+
function tt(e, i, r, n) {
|
|
1559
1558
|
var _this = this;
|
|
1560
1559
|
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)
|
|
1561
1560
|
throw new Error("There is no NavMesh generated.");
|
|
1562
|
-
this._recastCrowd = new (
|
|
1561
|
+
this._recastCrowd = new (qe().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); });
|
|
1563
1562
|
}
|
|
1564
|
-
Object.defineProperty(
|
|
1563
|
+
Object.defineProperty(tt.prototype, "navigationPlugin", {
|
|
1565
1564
|
get: function () { return this._navigationPlugin; },
|
|
1566
1565
|
enumerable: false,
|
|
1567
1566
|
configurable: true
|
|
1568
1567
|
});
|
|
1569
|
-
Object.defineProperty(
|
|
1568
|
+
Object.defineProperty(tt.prototype, "recastCrowd", {
|
|
1570
1569
|
get: function () { return this._recastCrowd; },
|
|
1571
1570
|
enumerable: false,
|
|
1572
1571
|
configurable: true
|
|
1573
1572
|
});
|
|
1574
|
-
Object.defineProperty(
|
|
1573
|
+
Object.defineProperty(tt.prototype, "transforms", {
|
|
1575
1574
|
get: function () { return this._transforms; },
|
|
1576
1575
|
enumerable: false,
|
|
1577
1576
|
configurable: true
|
|
1578
1577
|
});
|
|
1579
|
-
Object.defineProperty(
|
|
1578
|
+
Object.defineProperty(tt.prototype, "agents", {
|
|
1580
1579
|
get: function () { return Object.freeze(this._agents); },
|
|
1581
1580
|
enumerable: false,
|
|
1582
1581
|
configurable: true
|
|
1583
1582
|
});
|
|
1584
|
-
Object.defineProperty(
|
|
1583
|
+
Object.defineProperty(tt.prototype, "reachRadii", {
|
|
1585
1584
|
get: function () { return Object.freeze(this._reachRadii); },
|
|
1586
1585
|
enumerable: false,
|
|
1587
1586
|
configurable: true
|
|
1588
1587
|
});
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1588
|
+
tt.prototype.addAgent = function (e, i, r) { var n = et(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; };
|
|
1589
|
+
tt.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); };
|
|
1590
|
+
tt.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); };
|
|
1591
|
+
tt.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); };
|
|
1592
|
+
tt.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); };
|
|
1593
|
+
tt.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); };
|
|
1594
|
+
tt.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); };
|
|
1595
|
+
tt.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; };
|
|
1596
|
+
tt.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; };
|
|
1597
|
+
tt.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)); };
|
|
1598
|
+
tt.prototype.agentTeleport = function (e, t) { var i; null === (i = this._recastCrowd.getAgent(e)) || void 0 === i || i.teleport(t); };
|
|
1599
|
+
tt.prototype.updateAgentParameters = function (e, t) { var i = this._recastCrowd.getAgent(e); if (!i)
|
|
1601
1600
|
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
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1601
|
+
tt.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)); };
|
|
1602
|
+
tt.prototype.getAgents = function () { return this._agents; };
|
|
1603
|
+
tt.prototype.update = function (e) { if (e <= t.Epsilon)
|
|
1605
1604
|
return; var i = this._navigationPlugin.getTimeStep(), r = this._navigationPlugin.getMaximumSubStepCount(); if (i <= t.Epsilon)
|
|
1606
1605
|
this._recastCrowd.update(e);
|
|
1607
1606
|
else {
|
|
@@ -1617,16 +1616,16 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1617
1616
|
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] }));
|
|
1618
1617
|
}
|
|
1619
1618
|
} };
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1619
|
+
tt.prototype.setDefaultQueryExtent = function (e) { this._navigationPlugin.setDefaultQueryExtent(e); };
|
|
1620
|
+
tt.prototype.getDefaultQueryExtent = function () { var e = this._navigationPlugin.getDefaultQueryExtent(); return new t.Vector3(e.x, e.y, e.z); };
|
|
1621
|
+
tt.prototype.getDefaultQueryExtentToRef = function (e) { var t = this._navigationPlugin.getDefaultQueryExtent(); e.set(t.x, t.y, t.z); };
|
|
1622
|
+
tt.prototype.getCorners = function (e) { var i; var r = null === (i = this._recastCrowd.getAgent(e)) || void 0 === i ? void 0 : i.corners(); if (!r)
|
|
1624
1623
|
return []; var n = []; for (var e_63 = 0; e_63 < r.length; e_63++)
|
|
1625
1624
|
n.push(new t.Vector3(r[e_63].x, r[e_63].y, r[e_63].z)); return n; };
|
|
1626
|
-
|
|
1627
|
-
return
|
|
1625
|
+
tt.prototype.dispose = function () { this._recastCrowd.destroy(), this._onBeforeAnimationsObserver && (this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver), this._onBeforeAnimationsObserver = null), this.onReachTargetObservable.clear(); };
|
|
1626
|
+
return tt;
|
|
1628
1627
|
}());
|
|
1629
|
-
function
|
|
1628
|
+
function it(e) { var i = []; if (e.success) {
|
|
1630
1629
|
var r_10 = e.path.length;
|
|
1631
1630
|
for (var n_7 = 0; n_7 < r_10; n_7++) {
|
|
1632
1631
|
var r_11 = e.path[n_7];
|
|
@@ -1635,8 +1634,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1635
1634
|
}
|
|
1636
1635
|
else
|
|
1637
1636
|
t.Logger.Warn("Unable to convert navigation path point, because navPath generation has failed."); return i; }
|
|
1638
|
-
var
|
|
1639
|
-
function
|
|
1637
|
+
var rt = new t.Vector3, nt = new t.Vector3;
|
|
1638
|
+
function at(e, i, r, n, a) { return it(function (e, i, r, n, a) { var s, o, l, c, u, h; var d = qe(), 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
1639
|
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
1640
|
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
1641
|
return { success: !1, error: { type: "FIND_PATH_FAILED", status: L.status }, path: [] }; if (L.polys.size <= 0)
|
|
@@ -1646,23 +1645,23 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1646
1645
|
return { success: !1, error: { type: "NO_CLOSEST_POINT_ON_LAST_POLYGON_FOUND", status: e_64.status }, path: [] };
|
|
1647
1646
|
E = e_64.closestPoint;
|
|
1648
1647
|
} 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 =
|
|
1648
|
+
var r_12 = st(i, R, C, _, x, d);
|
|
1650
1649
|
if (!r_12.success)
|
|
1651
1650
|
break;
|
|
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 =
|
|
1651
|
+
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 = rt.copyFrom(s_3).subtract(R);
|
|
1653
1652
|
var l_3 = Math.sqrt(o_3.dot(o_3));
|
|
1654
1653
|
l_3 = (n_8 || a_5) && l_3 < v ? 1 : v / l_3;
|
|
1655
|
-
var c_3 =
|
|
1654
|
+
var c_3 = nt.copyFrom(R).addInPlace(o_3.scale(l_3)), u_2 = i.moveAlongSurface(x[0], R, c_3, { filter: m, maxVisitedSize: 16 });
|
|
1656
1655
|
if (!u_2.success)
|
|
1657
1656
|
break;
|
|
1658
1657
|
var h_3 = u_2.resultPosition;
|
|
1659
|
-
|
|
1658
|
+
lt(x, g, u_2.visited), ct(x, e, d);
|
|
1660
1659
|
var p_2 = i.getPolyHeight(x[0], h_3);
|
|
1661
|
-
if (p_2.success && (h_3.y = p_2.height), R.copyFromFloats(h_3.x, h_3.y, h_3.z), n_8 &&
|
|
1660
|
+
if (p_2.success && (h_3.y = p_2.height), R.copyFromFloats(h_3.x, h_3.y, h_3.z), n_8 && ot(R, r_12.steerPos, _, 1)) {
|
|
1662
1661
|
R.copyFrom(C), M.length < f && M.push(new t.Vector3(R.x, R.y, R.z));
|
|
1663
1662
|
break;
|
|
1664
1663
|
}
|
|
1665
|
-
if (a_5 &&
|
|
1664
|
+
if (a_5 && ot(R, r_12.steerPos, _, 1)) {
|
|
1666
1665
|
var n_9 = r_12.steerPosRef;
|
|
1667
1666
|
var a_6 = 0, s_4 = x[0], o_4 = 0;
|
|
1668
1667
|
for (; o_4 < x.length && s_4 !== n_9;)
|
|
@@ -1679,14 +1678,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1679
1678
|
}
|
|
1680
1679
|
M.length < f && M.push(new t.Vector3(R.x, R.y, R.z));
|
|
1681
1680
|
} return { success: !0, path: M }; }(e, i, r, n, a)); }
|
|
1682
|
-
function
|
|
1681
|
+
function st(e, i, r, n, a, s) { var o = e.findStraightPath(i, r, a, { maxStraightPathPoints: 3 }); if (!o.success)
|
|
1683
1682
|
return { success: !1 }; var l = []; for (var e_67 = 0; e_67 < o.straightPathCount; e_67++) {
|
|
1684
1683
|
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));
|
|
1685
1684
|
l.push(i_11);
|
|
1686
|
-
} var c = 0; for (; c < l.length && !(o.straightPathFlags.get(c) & s.Detour.DT_STRAIGHTPATH_OFFMESH_CONNECTION) &&
|
|
1685
|
+
} var c = 0; for (; c < l.length && !(o.straightPathFlags.get(c) & s.Detour.DT_STRAIGHTPATH_OFFMESH_CONNECTION) && ot(l[c], i, n, 1e3);)
|
|
1687
1686
|
c++; return c >= o.straightPathCount ? { success: !1 } : { success: !0, steerPos: l[c], steerPosFlag: o.straightPathFlags.get(c), steerPosRef: o.straightPathRefs.get(c), points: l }; }
|
|
1688
|
-
function
|
|
1689
|
-
function
|
|
1687
|
+
function ot(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; }
|
|
1688
|
+
function lt(e, t, i) { var r = -1, n = -1; for (var t_18 = e.length - 1; t_18 >= 0; t_18--) {
|
|
1690
1689
|
var a_7 = !1;
|
|
1691
1690
|
for (var s_5 = i.length - 1; s_5 >= 0; s_5--)
|
|
1692
1691
|
e[t_18] === i[s_5] && (r = t_18, n = s_5, a_7 = !0);
|
|
@@ -1695,7 +1694,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1695
1694
|
} if (-1 === r || -1 === n)
|
|
1696
1695
|
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
1696
|
e[t_19] = i[i.length - (1 + t_19)]; return e; }
|
|
1698
|
-
function
|
|
1697
|
+
function ct(e, t, i) { if (e.length < 3)
|
|
1699
1698
|
return; var r = 0; var n = [], a = t.getTileAndPolyByRef(e[0]); if (!a.success)
|
|
1700
1699
|
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
1700
|
var t_20 = o.links(e_68);
|
|
@@ -1706,9 +1705,9 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1706
1705
|
l = t_21;
|
|
1707
1706
|
break;
|
|
1708
1707
|
} l > 1 && e.splice(1, l - 1); }
|
|
1709
|
-
function
|
|
1708
|
+
function ut(e, i) { var r, n, a, s = 0; var o = [], l = []; for (r = 0; r < e.length; r++)
|
|
1710
1709
|
if (e[r]) {
|
|
1711
|
-
var c_4 = e[r], u_3 = (null == i ? void 0 : i.doNotReverseIndices) ? c_4.getIndices(!1, !0) :
|
|
1710
|
+
var c_4 = e[r], u_3 = (null == i ? void 0 : i.doNotReverseIndices) ? c_4.getIndices(!1, !0) : ht(c_4);
|
|
1712
1711
|
if (!u_3)
|
|
1713
1712
|
continue;
|
|
1714
1713
|
var h_4 = c_4.getVerticesData(t.VertexBuffer.PositionKind, !1, !1);
|
|
@@ -1734,7 +1733,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1734
1733
|
s += h_4.length / 3;
|
|
1735
1734
|
}
|
|
1736
1735
|
} return [Float32Array.from(o), Uint32Array.from(l)]; }
|
|
1737
|
-
function
|
|
1736
|
+
function ht(e) {
|
|
1738
1737
|
var _a;
|
|
1739
1738
|
var i = e instanceof t.Mesh ? e.getIndices(!1, !0) : e;
|
|
1740
1739
|
if (i)
|
|
@@ -1742,58 +1741,58 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1742
1741
|
_a = __read([i[e_71 + 2], i[e_71 + 1]], 2), i[e_71 + 1] = _a[0], i[e_71 + 2] = _a[1];
|
|
1743
1742
|
return i;
|
|
1744
1743
|
}
|
|
1745
|
-
function
|
|
1746
|
-
function
|
|
1747
|
-
throw new Error("At least one mesh is needed to create the nav mesh."); var _a = __read(
|
|
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 ?
|
|
1744
|
+
function dt(e, i, r, n) { var _a = __read(qe().getNavMeshPositionsAndIndices(e, n), 2), a = _a[0], s = _a[1], o = new t.Mesh("NavMeshDebug", i), l = new t.VertexData; return l.indices = ht(s), l.positions = a, l.applyToMesh(o, !1), r && (o.parent = r), o; }
|
|
1745
|
+
function mt(e, i) { var r, n; var a = qe(); if (0 === e.length)
|
|
1746
|
+
throw new Error("At least one mesh is needed to create the nav mesh."); var _a = __read(ut(e, { doNotReverseIndices: i.doNotReverseIndices }), 2), s = _a[0], o = _a[1]; if (!s || !o)
|
|
1747
|
+
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 ? Ke(i) : u ? Qe(i) : Xe(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
1748
|
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
|
|
1749
|
+
function pt(e) {
|
|
1751
1750
|
var _this = this;
|
|
1752
|
-
e.createNavMeshImpl = function (e, t) { return
|
|
1751
|
+
e.createNavMeshImpl = function (e, t) { return mt(e, t); }, e.createNavMeshAsyncImpl = function (e, t) { return i(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
1753
1752
|
switch (_a.label) {
|
|
1754
|
-
case 0: return [4 /*yield*/, new Promise(function (i) { i(
|
|
1753
|
+
case 0: return [4 /*yield*/, new Promise(function (i) { i(mt(e, t)); })];
|
|
1755
1754
|
case 1: return [2 /*return*/, _a.sent()];
|
|
1756
1755
|
}
|
|
1757
1756
|
}); }); };
|
|
1758
1757
|
}
|
|
1759
|
-
var
|
|
1760
|
-
function
|
|
1761
|
-
this.name = "RecastNavigationJSPlugin", this._maximumSubStepCount = 10, this._timeStep = 1 / 60, this._timeFactor = 1, e || (e =
|
|
1758
|
+
var ft = /** @class */ (function () {
|
|
1759
|
+
function ft(e) {
|
|
1760
|
+
this.name = "RecastNavigationJSPlugin", this._maximumSubStepCount = 10, this._timeStep = 1 / 60, this._timeFactor = 1, e || (e = qe(), pt(this)), this.bjsRECAST = e, this.isSupported() ? this.setTimeStep() : t.Logger.Error("RecastJS is not available. Please make sure you included the js file.");
|
|
1762
1761
|
}
|
|
1763
|
-
Object.defineProperty(
|
|
1762
|
+
Object.defineProperty(ft.prototype, "navMeshQuery", {
|
|
1764
1763
|
get: function () { return this._navMeshQuery; },
|
|
1765
1764
|
enumerable: false,
|
|
1766
1765
|
configurable: true
|
|
1767
1766
|
});
|
|
1768
|
-
Object.defineProperty(
|
|
1767
|
+
Object.defineProperty(ft.prototype, "intermediates", {
|
|
1769
1768
|
get: function () { return this._intermediates; },
|
|
1770
1769
|
enumerable: false,
|
|
1771
1770
|
configurable: true
|
|
1772
1771
|
});
|
|
1773
|
-
Object.defineProperty(
|
|
1772
|
+
Object.defineProperty(ft.prototype, "tileCache", {
|
|
1774
1773
|
get: function () { return this._tileCache; },
|
|
1775
1774
|
enumerable: false,
|
|
1776
1775
|
configurable: true
|
|
1777
1776
|
});
|
|
1778
|
-
|
|
1777
|
+
ft.prototype.setTimeStep = function (e) {
|
|
1779
1778
|
if (e === void 0) { e = 1 / 60; }
|
|
1780
1779
|
this._timeStep = e;
|
|
1781
1780
|
};
|
|
1782
|
-
|
|
1783
|
-
|
|
1781
|
+
ft.prototype.getTimeStep = function () { return this._timeStep; };
|
|
1782
|
+
ft.prototype.setMaximumSubStepCount = function (e) {
|
|
1784
1783
|
if (e === void 0) { e = 10; }
|
|
1785
1784
|
this._maximumSubStepCount = e;
|
|
1786
1785
|
};
|
|
1787
|
-
|
|
1788
|
-
Object.defineProperty(
|
|
1786
|
+
ft.prototype.getMaximumSubStepCount = function () { return this._maximumSubStepCount; };
|
|
1787
|
+
Object.defineProperty(ft.prototype, "timeFactor", {
|
|
1789
1788
|
get: function () { return this._timeFactor; },
|
|
1790
1789
|
set: function (e) { this._timeFactor = Math.max(e, 0); },
|
|
1791
1790
|
enumerable: false,
|
|
1792
1791
|
configurable: true
|
|
1793
1792
|
});
|
|
1794
|
-
|
|
1793
|
+
ft.prototype.createNavMesh = function (e, t) { if (!this.createNavMeshImpl)
|
|
1795
1794
|
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); };
|
|
1796
|
-
|
|
1795
|
+
ft.prototype.createNavMeshAsync = function (e, t) { return i(this, void 0, void 0, function () { var i; return __generator(this, function (_a) {
|
|
1797
1796
|
switch (_a.label) {
|
|
1798
1797
|
case 0:
|
|
1799
1798
|
if (!this.createNavMeshAsyncImpl)
|
|
@@ -1805,70 +1804,70 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1805
1804
|
return [2 /*return*/, this._processNavMeshResult(i)];
|
|
1806
1805
|
}
|
|
1807
1806
|
}); }); };
|
|
1808
|
-
|
|
1809
|
-
throw new Error("There is no navMesh generated."); return this.navMesh && this._tileCache &&
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1807
|
+
ft.prototype.createDebugNavMesh = function (e) { if (!this.navMesh)
|
|
1808
|
+
throw new Error("There is no navMesh generated."); return this.navMesh && this._tileCache && je(this.navMesh, this._tileCache), dt(this.navMesh, e); };
|
|
1809
|
+
ft.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); };
|
|
1810
|
+
ft.prototype.getClosestPointToRef = function (e, t, i) { var r = this._navMeshQuery.findClosestPoint(e, i); t.set(r.point.x, r.point.y, r.point.z); };
|
|
1811
|
+
ft.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); };
|
|
1812
|
+
ft.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); };
|
|
1813
|
+
ft.prototype.moveAlong = function (e, i, r, n) {
|
|
1815
1814
|
if (r === void 0) { r = 0; }
|
|
1816
1815
|
var a = this._navMeshQuery.moveAlongSurface(r, e, i, n);
|
|
1817
1816
|
return new t.Vector3(a.resultPosition.x, a.resultPosition.y, a.resultPosition.z);
|
|
1818
1817
|
};
|
|
1819
|
-
|
|
1818
|
+
ft.prototype.moveAlongToRef = function (e, t, i, r, n) {
|
|
1820
1819
|
if (r === void 0) { r = 0; }
|
|
1821
1820
|
var a = this._navMeshQuery.moveAlongSurface(r, e, t, n);
|
|
1822
1821
|
i.set(a.resultPosition.x, a.resultPosition.y, a.resultPosition.z);
|
|
1823
1822
|
};
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1823
|
+
ft.prototype.computePath = function (e, t, i) { return it(this._navMeshQuery.computePath(e, t, i)); };
|
|
1824
|
+
ft.prototype.computePathSmooth = function (e, i, r) { return this.navMesh ? at(this.navMesh, this._navMeshQuery, e, i, r) : (t.Logger.Error("No navmesh available. Cannot compute smooth path."), []); };
|
|
1825
|
+
ft.prototype.createCrowd = function (e, t, i) { var r = new tt(this, e, t, i); return this._crowd = r, r; };
|
|
1826
|
+
ft.prototype.setDefaultQueryExtent = function (e) { this._navMeshQuery.defaultQueryHalfExtents = e; };
|
|
1827
|
+
ft.prototype.getDefaultQueryExtent = function () { return new t.Vector3(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z); };
|
|
1828
|
+
ft.prototype.getDefaultQueryExtentToRef = function (e) { e.set(this._navMeshQuery.defaultQueryHalfExtents.x, this._navMeshQuery.defaultQueryHalfExtents.y, this._navMeshQuery.defaultQueryHalfExtents.z); };
|
|
1829
|
+
ft.prototype.buildFromNavmeshData = function (e) { var t = this.bjsRECAST.importNavMesh(e); this.navMesh = t.navMesh, this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh); };
|
|
1830
|
+
ft.prototype.getNavmeshData = function () { if (!this.navMesh)
|
|
1832
1831
|
throw new Error("There is no NavMesh generated."); return this.bjsRECAST.exportNavMesh(this.navMesh); };
|
|
1833
|
-
|
|
1834
|
-
|
|
1832
|
+
ft.prototype.buildFromTileCacheData = function (e, t) { var i = this.bjsRECAST.importTileCache(e, null != t ? t : Ye([])); this.navMesh = i.navMesh, this._tileCache = i.tileCache, this._navMeshQuery = new this.bjsRECAST.NavMeshQuery(this.navMesh); };
|
|
1833
|
+
ft.prototype.getTileCacheData = function () { if (!this.navMesh || !this._tileCache)
|
|
1835
1834
|
throw new Error("There is no TileCache generated."); return this.bjsRECAST.exportTileCache(this.navMesh, this._tileCache); };
|
|
1836
|
-
|
|
1837
|
-
|
|
1835
|
+
ft.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(); };
|
|
1836
|
+
ft.prototype.addCylinderObstacle = function (e, t, i, r) {
|
|
1838
1837
|
if (r === void 0) { r = !1; }
|
|
1839
1838
|
var n, a;
|
|
1840
1839
|
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 &&
|
|
1840
|
+
return (null == s ? void 0 : s.success) ? (!r && this.navMesh && this._tileCache && je(this.navMesh, this._tileCache), null !== (a = s.obstacle) && void 0 !== a ? a : null) : null;
|
|
1842
1841
|
};
|
|
1843
|
-
|
|
1842
|
+
ft.prototype.addBoxObstacle = function (e, t, i, r) {
|
|
1844
1843
|
if (r === void 0) { r = !1; }
|
|
1845
1844
|
var n, a;
|
|
1846
1845
|
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 &&
|
|
1846
|
+
return (null == s ? void 0 : s.success) ? (!r && this.navMesh && this._tileCache && je(this.navMesh, this._tileCache), null !== (a = s.obstacle) && void 0 !== a ? a : null) : null;
|
|
1848
1847
|
};
|
|
1849
|
-
|
|
1848
|
+
ft.prototype.removeObstacle = function (e, t) {
|
|
1850
1849
|
if (t === void 0) { t = !1; }
|
|
1851
1850
|
var i;
|
|
1852
|
-
null === (i = this._tileCache) || void 0 === i || i.removeObstacle(e), !t && this.navMesh && this._tileCache &&
|
|
1851
|
+
null === (i = this._tileCache) || void 0 === i || i.removeObstacle(e), !t && this.navMesh && this._tileCache && je(this.navMesh, this._tileCache);
|
|
1853
1852
|
};
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1853
|
+
ft.prototype.isSupported = function () { return !!this.bjsRECAST; };
|
|
1854
|
+
ft.prototype.getRandomSeed = function () { return this.bjsRECAST.getRandomSeed(); };
|
|
1855
|
+
ft.prototype.setRandomSeed = function (e) { this.bjsRECAST.setRandomSeed(e); };
|
|
1856
|
+
ft.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) {
|
|
1858
1857
|
t.TmpVectors.Vector3[0].set(e.x, e.y, e.z), t.TmpVectors.Vector3[1].set(i.x, i.y, i.z);
|
|
1859
1858
|
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
1859
|
return { hit: !0, hitPoint: t.TmpVectors.Vector3[0].add(s_6.multiplyByFloats(n_10, n_10, n_10)) };
|
|
1861
1860
|
} return { hit: !1 }; };
|
|
1862
|
-
|
|
1863
|
-
|
|
1861
|
+
ft.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 }; };
|
|
1862
|
+
ft.prototype._processNavMeshResult = function (e) { if (!(null == e ? void 0 : e.navMesh) || !(null == e ? void 0 : e.navMeshQuery))
|
|
1864
1863
|
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 }; };
|
|
1865
|
-
|
|
1866
|
-
return
|
|
1864
|
+
ft.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); };
|
|
1865
|
+
return ft;
|
|
1867
1866
|
}());
|
|
1868
|
-
function
|
|
1869
|
-
var
|
|
1870
|
-
var
|
|
1871
|
-
function
|
|
1867
|
+
function gt(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; }
|
|
1868
|
+
var vt = { 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" };
|
|
1869
|
+
var _t = /** @class */ (function () {
|
|
1870
|
+
function _t(e, i) {
|
|
1872
1871
|
var r, n, a, s;
|
|
1873
1872
|
this._scene = e, this.lineMaterials = [], this.getIntermediates = function (e) {
|
|
1874
1873
|
var e_72, _a, e_73, _b;
|
|
@@ -1905,17 +1904,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1905
1904
|
finally { if (e_73) throw e_73.error; }
|
|
1906
1905
|
}
|
|
1907
1906
|
return { heightfieldList: t, compactHeightfieldList: i, contourSetList: r, polyMeshList: n, polyMeshDetailList: a };
|
|
1908
|
-
}, this._debugDrawerUtils = new (
|
|
1907
|
+
}, this._debugDrawerUtils = new (qe().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);
|
|
1909
1908
|
var o = null == i ? void 0 : i.materials;
|
|
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(
|
|
1909
|
+
(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(_t.NAV_MESH_DEBUG_NAME_POINTS, { size: .02 });
|
|
1911
1910
|
}
|
|
1912
|
-
Object.defineProperty(
|
|
1911
|
+
Object.defineProperty(_t.prototype, "primitiveTypes", {
|
|
1913
1912
|
get: function () { return this._primitiveTypes; },
|
|
1914
1913
|
set: function (e) { this._primitiveTypes = e; },
|
|
1915
1914
|
enumerable: false,
|
|
1916
1915
|
configurable: true
|
|
1917
1916
|
});
|
|
1918
|
-
|
|
1917
|
+
_t.prototype.clear = function () {
|
|
1919
1918
|
var e_74, _a;
|
|
1920
1919
|
try {
|
|
1921
1920
|
for (var _b = __values(this.debugDrawerParentNode.getChildMeshes()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -1931,8 +1930,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1931
1930
|
finally { if (e_74) throw e_74.error; }
|
|
1932
1931
|
}
|
|
1933
1932
|
};
|
|
1934
|
-
|
|
1935
|
-
|
|
1933
|
+
_t.prototype.dispose = function () { this.clear(), this._debugDrawerUtils.dispose(), this._pointMesh.dispose(), this.triMaterial.dispose(), this.pointMaterial.dispose(); };
|
|
1934
|
+
_t.prototype.drawPrimitives = function (e, t) {
|
|
1936
1935
|
var e_76, _a;
|
|
1937
1936
|
var i;
|
|
1938
1937
|
var r = null;
|
|
@@ -1965,50 +1964,50 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1965
1964
|
}
|
|
1966
1965
|
null == r || r.updateLazy(), (null === (i = null == t ? void 0 : t.joinMeshes) || void 0 === i || i) && this._joinDebugMeshes();
|
|
1967
1966
|
};
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1967
|
+
_t.prototype.drawHeightfieldSolid = function (e) { var t = this._debugDrawerUtils.drawHeightfieldSolid(e); this.drawPrimitives(t); };
|
|
1968
|
+
_t.prototype.drawHeightfieldWalkable = function (e) { var t = this._debugDrawerUtils.drawHeightfieldWalkable(e); this.drawPrimitives(t); };
|
|
1969
|
+
_t.prototype.drawCompactHeightfieldSolid = function (e) { var t = this._debugDrawerUtils.drawCompactHeightfieldSolid(e); this.drawPrimitives(t); };
|
|
1970
|
+
_t.prototype.drawCompactHeightfieldRegions = function (e) { var t = this._debugDrawerUtils.drawCompactHeightfieldRegions(e); this.drawPrimitives(t); };
|
|
1971
|
+
_t.prototype.drawCompactHeightfieldDistance = function (e) { var t = this._debugDrawerUtils.drawCompactHeightfieldDistance(e); this.drawPrimitives(t); };
|
|
1972
|
+
_t.prototype.drawHeightfieldLayer = function (e, t) { var i = this._debugDrawerUtils.drawHeightfieldLayer(e, t); this.drawPrimitives(i); };
|
|
1973
|
+
_t.prototype.drawHeightfieldLayers = function (e) { var t = this._debugDrawerUtils.drawHeightfieldLayers(e); this.drawPrimitives(t); };
|
|
1974
|
+
_t.prototype.drawRegionConnections = function (e, t) {
|
|
1976
1975
|
if (t === void 0) { t = 1; }
|
|
1977
1976
|
var i = this._debugDrawerUtils.drawRegionConnections(e, t);
|
|
1978
1977
|
this.drawPrimitives(i);
|
|
1979
1978
|
};
|
|
1980
|
-
|
|
1979
|
+
_t.prototype.drawRawContours = function (e, t) {
|
|
1981
1980
|
if (t === void 0) { t = 1; }
|
|
1982
1981
|
var i = this._debugDrawerUtils.drawRawContours(e, t);
|
|
1983
1982
|
this.drawPrimitives(i);
|
|
1984
1983
|
};
|
|
1985
|
-
|
|
1984
|
+
_t.prototype.drawContours = function (e, t) {
|
|
1986
1985
|
if (t === void 0) { t = 1; }
|
|
1987
1986
|
var i = this._debugDrawerUtils.drawContours(e, t);
|
|
1988
1987
|
this.drawPrimitives(i);
|
|
1989
1988
|
};
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1989
|
+
_t.prototype.drawPolyMesh = function (e) { var t = this._debugDrawerUtils.drawPolyMesh(e); this.drawPrimitives(t); };
|
|
1990
|
+
_t.prototype.drawPolyMeshDetail = function (e) { var t = this._debugDrawerUtils.drawPolyMeshDetail(e); this.drawPrimitives(t); };
|
|
1991
|
+
_t.prototype.drawNavMesh = function (e, t) {
|
|
1993
1992
|
if (t === void 0) { t = 0; }
|
|
1994
1993
|
var i = this._debugDrawerUtils.drawNavMesh(e, t);
|
|
1995
1994
|
this.drawPrimitives(i);
|
|
1996
1995
|
};
|
|
1997
|
-
|
|
1996
|
+
_t.prototype.drawNavMeshWithClosedList = function (e, t, i) {
|
|
1998
1997
|
if (i === void 0) { i = 0; }
|
|
1999
1998
|
var r = this._debugDrawerUtils.drawNavMeshWithClosedList(e, t, i);
|
|
2000
1999
|
this.drawPrimitives(r);
|
|
2001
2000
|
};
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2001
|
+
_t.prototype.drawNavMeshNodes = function (e) { var t = this._debugDrawerUtils.drawNavMeshNodes(e); this.drawPrimitives(t); };
|
|
2002
|
+
_t.prototype.drawNavMeshBVTree = function (e) { var t = this._debugDrawerUtils.drawNavMeshBVTree(e); this.drawPrimitives(t); };
|
|
2003
|
+
_t.prototype.drawNavMeshPortals = function (e) { var t = this._debugDrawerUtils.drawNavMeshPortals(e); this.drawPrimitives(t); };
|
|
2004
|
+
_t.prototype.drawNavMeshPolysWithFlags = function (e, t, i) { var r = this._debugDrawerUtils.drawNavMeshPolysWithFlags(e, t, i); this.drawPrimitives(r); };
|
|
2005
|
+
_t.prototype.drawNavMeshPoly = function (e, t, i) { var r = this._debugDrawerUtils.drawNavMeshPoly(e, t, i); this.drawPrimitives(r); };
|
|
2006
|
+
_t.prototype.draw = function (e, t, i, r) {
|
|
2008
2007
|
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;
|
|
2009
2008
|
this.clear();
|
|
2010
2009
|
var _l = this.getIntermediates(t), n = _l.heightfieldList, a = _l.compactHeightfieldList, s = _l.contourSetList, o = _l.polyMeshList, l = _l.polyMeshDetailList;
|
|
2011
|
-
if (r ===
|
|
2010
|
+
if (r === vt.HEIGHTFIELD_SOLID)
|
|
2012
2011
|
try {
|
|
2013
2012
|
for (var n_11 = __values(n), n_11_1 = n_11.next(); !n_11_1.done; n_11_1 = n_11.next()) {
|
|
2014
2013
|
var e_88 = n_11_1.value;
|
|
@@ -2022,7 +2021,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2022
2021
|
}
|
|
2023
2022
|
finally { if (e_79) throw e_79.error; }
|
|
2024
2023
|
}
|
|
2025
|
-
else if (r ===
|
|
2024
|
+
else if (r === vt.HEIGHTFIELD_WALKABLE)
|
|
2026
2025
|
try {
|
|
2027
2026
|
for (var n_12 = __values(n), n_12_1 = n_12.next(); !n_12_1.done; n_12_1 = n_12.next()) {
|
|
2028
2027
|
var e_89 = n_12_1.value;
|
|
@@ -2036,7 +2035,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2036
2035
|
}
|
|
2037
2036
|
finally { if (e_80) throw e_80.error; }
|
|
2038
2037
|
}
|
|
2039
|
-
else if (r ===
|
|
2038
|
+
else if (r === vt.COMPACT_HEIGHTFIELD_SOLID)
|
|
2040
2039
|
try {
|
|
2041
2040
|
for (var a_8 = __values(a), a_8_1 = a_8.next(); !a_8_1.done; a_8_1 = a_8.next()) {
|
|
2042
2041
|
var e_90 = a_8_1.value;
|
|
@@ -2050,7 +2049,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2050
2049
|
}
|
|
2051
2050
|
finally { if (e_81) throw e_81.error; }
|
|
2052
2051
|
}
|
|
2053
|
-
else if (r ===
|
|
2052
|
+
else if (r === vt.COMPACT_HEIGHTFIELD_REGIONS)
|
|
2054
2053
|
try {
|
|
2055
2054
|
for (var a_9 = __values(a), a_9_1 = a_9.next(); !a_9_1.done; a_9_1 = a_9.next()) {
|
|
2056
2055
|
var e_91 = a_9_1.value;
|
|
@@ -2064,7 +2063,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2064
2063
|
}
|
|
2065
2064
|
finally { if (e_82) throw e_82.error; }
|
|
2066
2065
|
}
|
|
2067
|
-
else if (r ===
|
|
2066
|
+
else if (r === vt.COMPACT_HEIGHTFIELD_DISTANCE)
|
|
2068
2067
|
try {
|
|
2069
2068
|
for (var a_10 = __values(a), a_10_1 = a_10.next(); !a_10_1.done; a_10_1 = a_10.next()) {
|
|
2070
2069
|
var e_92 = a_10_1.value;
|
|
@@ -2078,7 +2077,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2078
2077
|
}
|
|
2079
2078
|
finally { if (e_83) throw e_83.error; }
|
|
2080
2079
|
}
|
|
2081
|
-
else if (r ===
|
|
2080
|
+
else if (r === vt.RAW_CONTOURS)
|
|
2082
2081
|
try {
|
|
2083
2082
|
for (var s_8 = __values(s), s_8_1 = s_8.next(); !s_8_1.done; s_8_1 = s_8.next()) {
|
|
2084
2083
|
var e_93 = s_8_1.value;
|
|
@@ -2092,7 +2091,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2092
2091
|
}
|
|
2093
2092
|
finally { if (e_84) throw e_84.error; }
|
|
2094
2093
|
}
|
|
2095
|
-
else if (r ===
|
|
2094
|
+
else if (r === vt.CONTOURS)
|
|
2096
2095
|
try {
|
|
2097
2096
|
for (var s_9 = __values(s), s_9_1 = s_9.next(); !s_9_1.done; s_9_1 = s_9.next()) {
|
|
2098
2097
|
var e_94 = s_9_1.value;
|
|
@@ -2106,7 +2105,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2106
2105
|
}
|
|
2107
2106
|
finally { if (e_85) throw e_85.error; }
|
|
2108
2107
|
}
|
|
2109
|
-
else if (r ===
|
|
2108
|
+
else if (r === vt.POLY_MESH)
|
|
2110
2109
|
try {
|
|
2111
2110
|
for (var o_5 = __values(o), o_5_1 = o_5.next(); !o_5_1.done; o_5_1 = o_5.next()) {
|
|
2112
2111
|
var e_95 = o_5_1.value;
|
|
@@ -2120,7 +2119,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2120
2119
|
}
|
|
2121
2120
|
finally { if (e_86) throw e_86.error; }
|
|
2122
2121
|
}
|
|
2123
|
-
else if (r ===
|
|
2122
|
+
else if (r === vt.POLY_MESH_DETAIL)
|
|
2124
2123
|
try {
|
|
2125
2124
|
for (var l_5 = __values(l), l_5_1 = l_5.next(); !l_5_1.done; l_5_1 = l_5.next()) {
|
|
2126
2125
|
var e_96 = l_5_1.value;
|
|
@@ -2135,24 +2134,24 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2135
2134
|
finally { if (e_87) throw e_87.error; }
|
|
2136
2135
|
}
|
|
2137
2136
|
else
|
|
2138
|
-
r ===
|
|
2137
|
+
r === vt.NAVMESH ? this.drawNavMesh(e) : r === vt.NAVMESH_BV_TREE && this.drawNavMeshBVTree(e);
|
|
2139
2138
|
};
|
|
2140
|
-
|
|
2139
|
+
_t.prototype._drawPoints = function (e) { if (0 === e.vertices.length)
|
|
2141
2140
|
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
2141
|
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
2142
|
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
2143
|
} this._pointMesh.thinInstanceSetBuffer("matrix", i, 16), this._pointMesh.thinInstanceSetBuffer("color", r, 4), this._pointMesh.parent = this.debugDrawerParentNode; };
|
|
2145
|
-
|
|
2144
|
+
_t.prototype._drawLines = function (e, i) { if (0 === e.vertices.length)
|
|
2146
2145
|
return null; var r = [], n = []; for (var i_15 = 0; i_15 < e.vertices.length; i_15 += 2) {
|
|
2147
2146
|
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
2147
|
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(
|
|
2150
|
-
|
|
2148
|
+
} 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(_t.NAV_MESH_DEBUG_NAME_LINES, a, s); return o.parent = this.debugDrawerParentNode, this.lineMaterials.push(o.material), o; };
|
|
2149
|
+
_t.prototype._drawTris = function (e) { if (0 === e.vertices.length)
|
|
2151
2150
|
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
2151
|
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
2152
|
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(
|
|
2155
|
-
|
|
2153
|
+
} var n = new t.VertexData; n.positions = i, n.colors = r; var a = new t.Mesh(_t.NAV_MESH_DEBUG_NAME_TRIS); a.isUnIndexed = !0, n.applyToMesh(a), a.material = this.triMaterial, a.parent = this.debugDrawerParentNode; };
|
|
2154
|
+
_t.prototype._drawQuads = function (e) {
|
|
2156
2155
|
var e_97, _a;
|
|
2157
2156
|
if (0 === e.vertices.length)
|
|
2158
2157
|
return;
|
|
@@ -2175,392 +2174,392 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2175
2174
|
}
|
|
2176
2175
|
var n = new t.VertexData;
|
|
2177
2176
|
n.positions = i, n.colors = r;
|
|
2178
|
-
var a = new t.Mesh(
|
|
2177
|
+
var a = new t.Mesh(_t.NAV_MESH_DEBUG_NAME_QUADS);
|
|
2179
2178
|
a.isUnIndexed = !0, n.applyToMesh(a), a.material = this.triMaterial, a.parent = this.debugDrawerParentNode;
|
|
2180
2179
|
};
|
|
2181
|
-
|
|
2180
|
+
_t.prototype._joinDebugMeshes = function () {
|
|
2182
2181
|
var _this = this;
|
|
2183
|
-
var e = this._scene.meshes.filter(function (e) { return e.name ===
|
|
2182
|
+
var e = this._scene.meshes.filter(function (e) { return e.name === _t.NAV_MESH_DEBUG_NAME; });
|
|
2184
2183
|
e.forEach(function (e) { _this._convertUnindexedToIndexed(e); });
|
|
2185
2184
|
var i = t.Mesh.MergeMeshes(e, !0);
|
|
2186
|
-
i && (i.name =
|
|
2185
|
+
i && (i.name = _t.NAV_MESH_DEBUG_NAME, i.parent = this.debugDrawerParentNode);
|
|
2187
2186
|
};
|
|
2188
|
-
|
|
2187
|
+
_t.prototype._convertUnindexedToIndexed = function (e) { var i = t.VertexData.ExtractFromMesh(e).positions; if (!i || i.length % 9 != 0)
|
|
2189
2188
|
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
|
|
2189
|
+
return _t;
|
|
2191
2190
|
}());
|
|
2192
|
-
|
|
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[
|
|
2195
|
-
var
|
|
2196
|
-
var
|
|
2197
|
-
var
|
|
2198
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2199
|
-
var
|
|
2200
|
-
var
|
|
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[
|
|
2203
|
-
var
|
|
2204
|
-
var
|
|
2205
|
-
var
|
|
2206
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2207
|
-
var
|
|
2208
|
-
var
|
|
2209
|
-
var
|
|
2210
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2211
|
-
var
|
|
2212
|
-
var
|
|
2213
|
-
var
|
|
2214
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2215
|
-
var
|
|
2191
|
+
_t.NAV_MESH_DEBUG_NAME = "nav-mesh-debug", _t.NAV_MESH_DEBUG_NAME_POINTS = "nav-mesh-debug-points", _t.NAV_MESH_DEBUG_NAME_TRIS = "nav-mesh-debug-tris", _t.NAV_MESH_DEBUG_NAME_QUADS = "nav-mesh-debug-quads", _t.NAV_MESH_DEBUG_NAME_LINES = "nav-mesh-debug-lines";
|
|
2192
|
+
var St = "atmosphereFunctions", yt = "#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";
|
|
2193
|
+
t.ShaderStore.IncludesShadersStoreWGSL[St] || (t.ShaderStore.IncludesShadersStoreWGSL[St] = yt);
|
|
2194
|
+
var Tt = { name: St, shader: yt };
|
|
2195
|
+
var At = { __proto__: null, atmosphereFunctionsWGSL: Tt };
|
|
2196
|
+
var Lt = "atmosphereUboDeclaration", Pt = "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";
|
|
2197
|
+
t.ShaderStore.IncludesShadersStoreWGSL[Lt] || (t.ShaderStore.IncludesShadersStoreWGSL[Lt] = Pt);
|
|
2198
|
+
var Et = { name: Lt, shader: Pt };
|
|
2199
|
+
var Rt = { __proto__: null, atmosphereUboDeclarationWGSL: Et };
|
|
2200
|
+
var Ct = "atmosphereFunctions", xt = "#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";
|
|
2201
|
+
t.ShaderStore.IncludesShadersStore[Ct] || (t.ShaderStore.IncludesShadersStore[Ct] = xt);
|
|
2202
|
+
var Mt = { name: Ct, shader: xt };
|
|
2203
|
+
var It = { __proto__: null, atmosphereFunctions: Mt };
|
|
2204
|
+
var wt = "atmosphereUboDeclaration", bt = "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";
|
|
2205
|
+
t.ShaderStore.IncludesShadersStore[wt] || (t.ShaderStore.IncludesShadersStore[wt] = bt);
|
|
2206
|
+
var Ot = { name: wt, shader: bt };
|
|
2207
|
+
var Dt = { __proto__: null, atmosphereUboDeclaration: Ot };
|
|
2208
|
+
var Nt = "atmosphereFragmentDeclaration", Ut = "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";
|
|
2209
|
+
t.ShaderStore.IncludesShadersStore[Nt] || (t.ShaderStore.IncludesShadersStore[Nt] = Ut);
|
|
2210
|
+
var Ft = { name: Nt, shader: Ut };
|
|
2211
|
+
var Vt = { __proto__: null, atmosphereFragmentDeclaration: Ft };
|
|
2212
|
+
var Gt = "fullscreenTriangleVertexShader", kt = "#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";
|
|
2213
|
+
t.ShaderStore.ShadersStoreWGSL[Gt] || (t.ShaderStore.ShadersStoreWGSL[Gt] = kt);
|
|
2214
|
+
var zt = [Et];
|
|
2216
2215
|
try {
|
|
2217
|
-
for (var
|
|
2218
|
-
var e_99 =
|
|
2216
|
+
for (var zt_1 = __values(zt), zt_1_1 = zt_1.next(); !zt_1_1.done; zt_1_1 = zt_1.next()) {
|
|
2217
|
+
var e_99 = zt_1_1.value;
|
|
2219
2218
|
t.ShaderStore.IncludesShadersStoreWGSL[e_99.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_99.name] = e_99.shader);
|
|
2220
2219
|
}
|
|
2221
2220
|
}
|
|
2222
2221
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2223
2222
|
finally {
|
|
2224
2223
|
try {
|
|
2225
|
-
if (
|
|
2224
|
+
if (zt_1_1 && !zt_1_1.done && (_a = zt_1.return)) _a.call(zt_1);
|
|
2226
2225
|
}
|
|
2227
2226
|
finally { if (e_1) throw e_1.error; }
|
|
2228
2227
|
}
|
|
2229
|
-
var
|
|
2230
|
-
var
|
|
2231
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2232
|
-
var
|
|
2228
|
+
var Bt = { __proto__: null, fullscreenTriangleVertexShaderWGSL: { name: Gt, shader: kt } };
|
|
2229
|
+
var Wt = "diffuseSkyIrradiancePixelShader", Ht = "#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";
|
|
2230
|
+
t.ShaderStore.ShadersStoreWGSL[Wt] || (t.ShaderStore.ShadersStoreWGSL[Wt] = Ht);
|
|
2231
|
+
var qt = [Et, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, Tt, t.importanceSamplingWGSL, t.pbrBRDFFunctionsWGSL, t.hdrFilteringFunctionsWGSL];
|
|
2233
2232
|
try {
|
|
2234
|
-
for (var
|
|
2235
|
-
var e_100 =
|
|
2233
|
+
for (var qt_1 = __values(qt), qt_1_1 = qt_1.next(); !qt_1_1.done; qt_1_1 = qt_1.next()) {
|
|
2234
|
+
var e_100 = qt_1_1.value;
|
|
2236
2235
|
t.ShaderStore.IncludesShadersStoreWGSL[e_100.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_100.name] = e_100.shader);
|
|
2237
2236
|
}
|
|
2238
2237
|
}
|
|
2239
2238
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2240
2239
|
finally {
|
|
2241
2240
|
try {
|
|
2242
|
-
if (
|
|
2241
|
+
if (qt_1_1 && !qt_1_1.done && (_b = qt_1.return)) _b.call(qt_1);
|
|
2243
2242
|
}
|
|
2244
2243
|
finally { if (e_2) throw e_2.error; }
|
|
2245
2244
|
}
|
|
2246
|
-
var
|
|
2247
|
-
var
|
|
2248
|
-
t.ShaderStore.ShadersStore[
|
|
2249
|
-
var
|
|
2245
|
+
var Zt = { __proto__: null, diffuseSkyIrradiancePixelShaderWGSL: { name: Wt, shader: Ht } };
|
|
2246
|
+
var $t = "fullscreenTriangleVertexShader", Yt = "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}";
|
|
2247
|
+
t.ShaderStore.ShadersStore[$t] || (t.ShaderStore.ShadersStore[$t] = Yt);
|
|
2248
|
+
var jt = [Ft, Ot];
|
|
2250
2249
|
try {
|
|
2251
|
-
for (var
|
|
2252
|
-
var e_101 =
|
|
2250
|
+
for (var jt_1 = __values(jt), jt_1_1 = jt_1.next(); !jt_1_1.done; jt_1_1 = jt_1.next()) {
|
|
2251
|
+
var e_101 = jt_1_1.value;
|
|
2253
2252
|
t.ShaderStore.IncludesShadersStore[e_101.name] || (t.ShaderStore.IncludesShadersStore[e_101.name] = e_101.shader);
|
|
2254
2253
|
}
|
|
2255
2254
|
}
|
|
2256
2255
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
2257
2256
|
finally {
|
|
2258
2257
|
try {
|
|
2259
|
-
if (
|
|
2258
|
+
if (jt_1_1 && !jt_1_1.done && (_c = jt_1.return)) _c.call(jt_1);
|
|
2260
2259
|
}
|
|
2261
2260
|
finally { if (e_3) throw e_3.error; }
|
|
2262
2261
|
}
|
|
2263
|
-
var
|
|
2264
|
-
var
|
|
2265
|
-
t.ShaderStore.ShadersStore[
|
|
2266
|
-
var
|
|
2262
|
+
var Xt = { __proto__: null, fullscreenTriangleVertexShader: { name: $t, shader: Yt } };
|
|
2263
|
+
var Qt = "diffuseSkyIrradiancePixelShader", Kt = "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.);}";
|
|
2264
|
+
t.ShaderStore.ShadersStore[Qt] || (t.ShaderStore.ShadersStore[Qt] = Kt);
|
|
2265
|
+
var Jt = [Ft, Ot, t.helperFunctions, t.intersectionFunctions, Mt, t.importanceSampling, t.pbrBRDFFunctions, t.hdrFilteringFunctions];
|
|
2267
2266
|
try {
|
|
2268
|
-
for (var
|
|
2269
|
-
var e_102 =
|
|
2267
|
+
for (var Jt_1 = __values(Jt), Jt_1_1 = Jt_1.next(); !Jt_1_1.done; Jt_1_1 = Jt_1.next()) {
|
|
2268
|
+
var e_102 = Jt_1_1.value;
|
|
2270
2269
|
t.ShaderStore.IncludesShadersStore[e_102.name] || (t.ShaderStore.IncludesShadersStore[e_102.name] = e_102.shader);
|
|
2271
2270
|
}
|
|
2272
2271
|
}
|
|
2273
2272
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
2274
2273
|
finally {
|
|
2275
2274
|
try {
|
|
2276
|
-
if (
|
|
2275
|
+
if (Jt_1_1 && !Jt_1_1.done && (_d = Jt_1.return)) _d.call(Jt_1);
|
|
2277
2276
|
}
|
|
2278
2277
|
finally { if (e_4) throw e_4.error; }
|
|
2279
2278
|
}
|
|
2280
|
-
var
|
|
2281
|
-
var
|
|
2282
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2283
|
-
var
|
|
2279
|
+
var ei = { __proto__: null, diffuseSkyIrradiancePixelShader: { name: Qt, shader: Kt } };
|
|
2280
|
+
var ti = "transmittancePixelShader", ii = "#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";
|
|
2281
|
+
t.ShaderStore.ShadersStoreWGSL[ti] || (t.ShaderStore.ShadersStoreWGSL[ti] = ii);
|
|
2282
|
+
var ri = [Et, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, Tt];
|
|
2284
2283
|
try {
|
|
2285
|
-
for (var
|
|
2286
|
-
var e_103 =
|
|
2284
|
+
for (var ri_1 = __values(ri), ri_1_1 = ri_1.next(); !ri_1_1.done; ri_1_1 = ri_1.next()) {
|
|
2285
|
+
var e_103 = ri_1_1.value;
|
|
2287
2286
|
t.ShaderStore.IncludesShadersStoreWGSL[e_103.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_103.name] = e_103.shader);
|
|
2288
2287
|
}
|
|
2289
2288
|
}
|
|
2290
2289
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
2291
2290
|
finally {
|
|
2292
2291
|
try {
|
|
2293
|
-
if (
|
|
2292
|
+
if (ri_1_1 && !ri_1_1.done && (_f = ri_1.return)) _f.call(ri_1);
|
|
2294
2293
|
}
|
|
2295
2294
|
finally { if (e_5) throw e_5.error; }
|
|
2296
2295
|
}
|
|
2297
|
-
var
|
|
2298
|
-
var
|
|
2299
|
-
t.ShaderStore.ShadersStore[
|
|
2300
|
-
var
|
|
2296
|
+
var ni = { __proto__: null, transmittancePixelShaderWGSL: { name: ti, shader: ii } };
|
|
2297
|
+
var ai = "transmittancePixelShader", si = "#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);}";
|
|
2298
|
+
t.ShaderStore.ShadersStore[ai] || (t.ShaderStore.ShadersStore[ai] = si);
|
|
2299
|
+
var oi = [Ft, Ot, t.helperFunctions, t.intersectionFunctions, Mt];
|
|
2301
2300
|
try {
|
|
2302
|
-
for (var
|
|
2303
|
-
var e_104 =
|
|
2301
|
+
for (var oi_1 = __values(oi), oi_1_1 = oi_1.next(); !oi_1_1.done; oi_1_1 = oi_1.next()) {
|
|
2302
|
+
var e_104 = oi_1_1.value;
|
|
2304
2303
|
t.ShaderStore.IncludesShadersStore[e_104.name] || (t.ShaderStore.IncludesShadersStore[e_104.name] = e_104.shader);
|
|
2305
2304
|
}
|
|
2306
2305
|
}
|
|
2307
2306
|
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
2308
2307
|
finally {
|
|
2309
2308
|
try {
|
|
2310
|
-
if (
|
|
2309
|
+
if (oi_1_1 && !oi_1_1.done && (_g = oi_1.return)) _g.call(oi_1);
|
|
2311
2310
|
}
|
|
2312
2311
|
finally { if (e_6) throw e_6.error; }
|
|
2313
2312
|
}
|
|
2314
|
-
var
|
|
2315
|
-
var
|
|
2316
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2317
|
-
var
|
|
2313
|
+
var li = { __proto__: null, transmittancePixelShader: { name: ai, shader: si } };
|
|
2314
|
+
var ci = "multiScatteringPixelShader", ui = "#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";
|
|
2315
|
+
t.ShaderStore.ShadersStoreWGSL[ci] || (t.ShaderStore.ShadersStoreWGSL[ci] = ui);
|
|
2316
|
+
var hi = [Et, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, Tt];
|
|
2318
2317
|
try {
|
|
2319
|
-
for (var
|
|
2320
|
-
var e_105 =
|
|
2318
|
+
for (var hi_1 = __values(hi), hi_1_1 = hi_1.next(); !hi_1_1.done; hi_1_1 = hi_1.next()) {
|
|
2319
|
+
var e_105 = hi_1_1.value;
|
|
2321
2320
|
t.ShaderStore.IncludesShadersStoreWGSL[e_105.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_105.name] = e_105.shader);
|
|
2322
2321
|
}
|
|
2323
2322
|
}
|
|
2324
2323
|
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
2325
2324
|
finally {
|
|
2326
2325
|
try {
|
|
2327
|
-
if (
|
|
2326
|
+
if (hi_1_1 && !hi_1_1.done && (_h = hi_1.return)) _h.call(hi_1);
|
|
2328
2327
|
}
|
|
2329
2328
|
finally { if (e_7) throw e_7.error; }
|
|
2330
2329
|
}
|
|
2331
|
-
var
|
|
2332
|
-
var
|
|
2333
|
-
t.ShaderStore.ShadersStore[
|
|
2334
|
-
var
|
|
2330
|
+
var di = { __proto__: null, multiScatteringPixelShaderWGSL: { name: ci, shader: ui } };
|
|
2331
|
+
var mi = "multiScatteringPixelShader", pi = "#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);}";
|
|
2332
|
+
t.ShaderStore.ShadersStore[mi] || (t.ShaderStore.ShadersStore[mi] = pi);
|
|
2333
|
+
var fi = [Ft, Ot, t.helperFunctions, t.intersectionFunctions, Mt];
|
|
2335
2334
|
try {
|
|
2336
|
-
for (var
|
|
2337
|
-
var e_106 =
|
|
2335
|
+
for (var fi_1 = __values(fi), fi_1_1 = fi_1.next(); !fi_1_1.done; fi_1_1 = fi_1.next()) {
|
|
2336
|
+
var e_106 = fi_1_1.value;
|
|
2338
2337
|
t.ShaderStore.IncludesShadersStore[e_106.name] || (t.ShaderStore.IncludesShadersStore[e_106.name] = e_106.shader);
|
|
2339
2338
|
}
|
|
2340
2339
|
}
|
|
2341
2340
|
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
2342
2341
|
finally {
|
|
2343
2342
|
try {
|
|
2344
|
-
if (
|
|
2343
|
+
if (fi_1_1 && !fi_1_1.done && (_j = fi_1.return)) _j.call(fi_1);
|
|
2345
2344
|
}
|
|
2346
2345
|
finally { if (e_8) throw e_8.error; }
|
|
2347
2346
|
}
|
|
2348
|
-
var
|
|
2349
|
-
var
|
|
2350
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2351
|
-
var
|
|
2347
|
+
var gi = { __proto__: null, multiScatteringPixelShader: { name: mi, shader: pi } };
|
|
2348
|
+
var vi = "compositeSkyPixelShader", _i = "#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";
|
|
2349
|
+
t.ShaderStore.ShadersStoreWGSL[vi] || (t.ShaderStore.ShadersStoreWGSL[vi] = _i);
|
|
2350
|
+
var Si = [Et, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, Tt];
|
|
2352
2351
|
try {
|
|
2353
|
-
for (var
|
|
2354
|
-
var e_107 =
|
|
2352
|
+
for (var Si_1 = __values(Si), Si_1_1 = Si_1.next(); !Si_1_1.done; Si_1_1 = Si_1.next()) {
|
|
2353
|
+
var e_107 = Si_1_1.value;
|
|
2355
2354
|
t.ShaderStore.IncludesShadersStoreWGSL[e_107.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_107.name] = e_107.shader);
|
|
2356
2355
|
}
|
|
2357
2356
|
}
|
|
2358
2357
|
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
2359
2358
|
finally {
|
|
2360
2359
|
try {
|
|
2361
|
-
if (
|
|
2360
|
+
if (Si_1_1 && !Si_1_1.done && (_k = Si_1.return)) _k.call(Si_1);
|
|
2362
2361
|
}
|
|
2363
2362
|
finally { if (e_9) throw e_9.error; }
|
|
2364
2363
|
}
|
|
2365
|
-
var
|
|
2366
|
-
var
|
|
2367
|
-
t.ShaderStore.ShadersStore[
|
|
2368
|
-
var
|
|
2364
|
+
var yi = { __proto__: null, compositeSkyPixelShaderWGSL: { name: vi, shader: _i } };
|
|
2365
|
+
var Ti = "compositeSkyPixelShader", Ai = "#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}";
|
|
2366
|
+
t.ShaderStore.ShadersStore[Ti] || (t.ShaderStore.ShadersStore[Ti] = Ai);
|
|
2367
|
+
var Li = [Ft, Ot, t.helperFunctions, t.intersectionFunctions, Mt];
|
|
2369
2368
|
try {
|
|
2370
|
-
for (var
|
|
2371
|
-
var e_108 =
|
|
2369
|
+
for (var Li_1 = __values(Li), Li_1_1 = Li_1.next(); !Li_1_1.done; Li_1_1 = Li_1.next()) {
|
|
2370
|
+
var e_108 = Li_1_1.value;
|
|
2372
2371
|
t.ShaderStore.IncludesShadersStore[e_108.name] || (t.ShaderStore.IncludesShadersStore[e_108.name] = e_108.shader);
|
|
2373
2372
|
}
|
|
2374
2373
|
}
|
|
2375
2374
|
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
2376
2375
|
finally {
|
|
2377
2376
|
try {
|
|
2378
|
-
if (
|
|
2377
|
+
if (Li_1_1 && !Li_1_1.done && (_l = Li_1.return)) _l.call(Li_1);
|
|
2379
2378
|
}
|
|
2380
2379
|
finally { if (e_10) throw e_10.error; }
|
|
2381
2380
|
}
|
|
2382
|
-
var
|
|
2383
|
-
var
|
|
2384
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2385
|
-
var
|
|
2381
|
+
var Pi = { __proto__: null, compositeSkyPixelShader: { name: Ti, shader: Ai } };
|
|
2382
|
+
var Ei = "aerialPerspectivePixelShader", Ri = "#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";
|
|
2383
|
+
t.ShaderStore.ShadersStoreWGSL[Ei] || (t.ShaderStore.ShadersStoreWGSL[Ei] = Ri);
|
|
2384
|
+
var Ci = [Et, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, Tt];
|
|
2386
2385
|
try {
|
|
2387
|
-
for (var
|
|
2388
|
-
var e_109 =
|
|
2386
|
+
for (var Ci_1 = __values(Ci), Ci_1_1 = Ci_1.next(); !Ci_1_1.done; Ci_1_1 = Ci_1.next()) {
|
|
2387
|
+
var e_109 = Ci_1_1.value;
|
|
2389
2388
|
t.ShaderStore.IncludesShadersStoreWGSL[e_109.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_109.name] = e_109.shader);
|
|
2390
2389
|
}
|
|
2391
2390
|
}
|
|
2392
2391
|
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
2393
2392
|
finally {
|
|
2394
2393
|
try {
|
|
2395
|
-
if (
|
|
2394
|
+
if (Ci_1_1 && !Ci_1_1.done && (_m = Ci_1.return)) _m.call(Ci_1);
|
|
2396
2395
|
}
|
|
2397
2396
|
finally { if (e_11) throw e_11.error; }
|
|
2398
2397
|
}
|
|
2399
|
-
var
|
|
2400
|
-
var
|
|
2401
|
-
t.ShaderStore.ShadersStore[
|
|
2402
|
-
var
|
|
2398
|
+
var xi = { __proto__: null, aerialPerspectivePixelShaderWGSL: { name: Ei, shader: Ri } };
|
|
2399
|
+
var Mi = "aerialPerspectivePixelShader", Ii = "#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);}";
|
|
2400
|
+
t.ShaderStore.ShadersStore[Mi] || (t.ShaderStore.ShadersStore[Mi] = Ii);
|
|
2401
|
+
var wi = [Ft, Ot, t.helperFunctions, t.intersectionFunctions, Mt];
|
|
2403
2402
|
try {
|
|
2404
|
-
for (var
|
|
2405
|
-
var e_110 =
|
|
2403
|
+
for (var wi_1 = __values(wi), wi_1_1 = wi_1.next(); !wi_1_1.done; wi_1_1 = wi_1.next()) {
|
|
2404
|
+
var e_110 = wi_1_1.value;
|
|
2406
2405
|
t.ShaderStore.IncludesShadersStore[e_110.name] || (t.ShaderStore.IncludesShadersStore[e_110.name] = e_110.shader);
|
|
2407
2406
|
}
|
|
2408
2407
|
}
|
|
2409
2408
|
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
2410
2409
|
finally {
|
|
2411
2410
|
try {
|
|
2412
|
-
if (
|
|
2411
|
+
if (wi_1_1 && !wi_1_1.done && (_o = wi_1.return)) _o.call(wi_1);
|
|
2413
2412
|
}
|
|
2414
2413
|
finally { if (e_12) throw e_12.error; }
|
|
2415
2414
|
}
|
|
2416
|
-
var
|
|
2417
|
-
var
|
|
2418
|
-
t.ShaderStore.IncludesShadersStoreWGSL[
|
|
2419
|
-
var
|
|
2420
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2421
|
-
var
|
|
2415
|
+
var bi = { __proto__: null, aerialPerspectivePixelShader: { name: Mi, shader: Ii } };
|
|
2416
|
+
var Oi = "depthFunctions", Di = "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";
|
|
2417
|
+
t.ShaderStore.IncludesShadersStoreWGSL[Oi] || (t.ShaderStore.IncludesShadersStoreWGSL[Oi] = Di);
|
|
2418
|
+
var Ni = { name: Oi, shader: Di }, Ui = "compositeAerialPerspectivePixelShader", Fi = "#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";
|
|
2419
|
+
t.ShaderStore.ShadersStoreWGSL[Ui] || (t.ShaderStore.ShadersStoreWGSL[Ui] = Fi);
|
|
2420
|
+
var Vi = [Et, t.helperFunctionsWGSL, Ni, t.intersectionFunctionsWGSL, Tt];
|
|
2422
2421
|
try {
|
|
2423
|
-
for (var
|
|
2424
|
-
var e_111 =
|
|
2422
|
+
for (var Vi_1 = __values(Vi), Vi_1_1 = Vi_1.next(); !Vi_1_1.done; Vi_1_1 = Vi_1.next()) {
|
|
2423
|
+
var e_111 = Vi_1_1.value;
|
|
2425
2424
|
t.ShaderStore.IncludesShadersStoreWGSL[e_111.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_111.name] = e_111.shader);
|
|
2426
2425
|
}
|
|
2427
2426
|
}
|
|
2428
2427
|
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
2429
2428
|
finally {
|
|
2430
2429
|
try {
|
|
2431
|
-
if (
|
|
2430
|
+
if (Vi_1_1 && !Vi_1_1.done && (_p = Vi_1.return)) _p.call(Vi_1);
|
|
2432
2431
|
}
|
|
2433
2432
|
finally { if (e_13) throw e_13.error; }
|
|
2434
2433
|
}
|
|
2435
|
-
var
|
|
2436
|
-
var
|
|
2437
|
-
t.ShaderStore.IncludesShadersStore[
|
|
2438
|
-
var
|
|
2439
|
-
t.ShaderStore.ShadersStore[
|
|
2440
|
-
var
|
|
2434
|
+
var Gi = { __proto__: null, compositeAerialPerspectivePixelShaderWGSL: { name: Ui, shader: Fi } };
|
|
2435
|
+
var ki = "depthFunctions", zi = "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);}";
|
|
2436
|
+
t.ShaderStore.IncludesShadersStore[ki] || (t.ShaderStore.IncludesShadersStore[ki] = zi);
|
|
2437
|
+
var Bi = { name: ki, shader: zi }, Wi = "compositeAerialPerspectivePixelShader", Hi = "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}";
|
|
2438
|
+
t.ShaderStore.ShadersStore[Wi] || (t.ShaderStore.ShadersStore[Wi] = Hi);
|
|
2439
|
+
var qi = [Ft, Ot, t.helperFunctions, Bi, t.intersectionFunctions, Mt];
|
|
2441
2440
|
try {
|
|
2442
|
-
for (var
|
|
2443
|
-
var e_112 =
|
|
2441
|
+
for (var qi_1 = __values(qi), qi_1_1 = qi_1.next(); !qi_1_1.done; qi_1_1 = qi_1.next()) {
|
|
2442
|
+
var e_112 = qi_1_1.value;
|
|
2444
2443
|
t.ShaderStore.IncludesShadersStore[e_112.name] || (t.ShaderStore.IncludesShadersStore[e_112.name] = e_112.shader);
|
|
2445
2444
|
}
|
|
2446
2445
|
}
|
|
2447
2446
|
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
2448
2447
|
finally {
|
|
2449
2448
|
try {
|
|
2450
|
-
if (
|
|
2449
|
+
if (qi_1_1 && !qi_1_1.done && (_q = qi_1.return)) _q.call(qi_1);
|
|
2451
2450
|
}
|
|
2452
2451
|
finally { if (e_14) throw e_14.error; }
|
|
2453
2452
|
}
|
|
2454
|
-
var
|
|
2455
|
-
var
|
|
2456
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2457
|
-
var
|
|
2453
|
+
var Zi = { __proto__: null, compositeAerialPerspectivePixelShader: { name: Wi, shader: Hi } };
|
|
2454
|
+
var $i = "compositeGlobeAtmospherePixelShader", Yi = "#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";
|
|
2455
|
+
t.ShaderStore.ShadersStoreWGSL[$i] || (t.ShaderStore.ShadersStoreWGSL[$i] = Yi);
|
|
2456
|
+
var ji = [Et, t.helperFunctionsWGSL, Ni, t.intersectionFunctionsWGSL, Tt];
|
|
2458
2457
|
try {
|
|
2459
|
-
for (var
|
|
2460
|
-
var e_113 =
|
|
2458
|
+
for (var ji_1 = __values(ji), ji_1_1 = ji_1.next(); !ji_1_1.done; ji_1_1 = ji_1.next()) {
|
|
2459
|
+
var e_113 = ji_1_1.value;
|
|
2461
2460
|
t.ShaderStore.IncludesShadersStoreWGSL[e_113.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_113.name] = e_113.shader);
|
|
2462
2461
|
}
|
|
2463
2462
|
}
|
|
2464
2463
|
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
2465
2464
|
finally {
|
|
2466
2465
|
try {
|
|
2467
|
-
if (
|
|
2466
|
+
if (ji_1_1 && !ji_1_1.done && (_s = ji_1.return)) _s.call(ji_1);
|
|
2468
2467
|
}
|
|
2469
2468
|
finally { if (e_15) throw e_15.error; }
|
|
2470
2469
|
}
|
|
2471
|
-
var
|
|
2472
|
-
var
|
|
2473
|
-
t.ShaderStore.ShadersStore[
|
|
2474
|
-
var
|
|
2470
|
+
var Xi = { __proto__: null, compositeGlobeAtmospherePixelShaderWGSL: { name: $i, shader: Yi } };
|
|
2471
|
+
var Qi = "compositeGlobeAtmospherePixelShader", Ki = "#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}";
|
|
2472
|
+
t.ShaderStore.ShadersStore[Qi] || (t.ShaderStore.ShadersStore[Qi] = Ki);
|
|
2473
|
+
var Ji = [Ft, Ot, t.helperFunctions, Bi, t.intersectionFunctions, Mt];
|
|
2475
2474
|
try {
|
|
2476
|
-
for (var
|
|
2477
|
-
var e_114 =
|
|
2475
|
+
for (var Ji_1 = __values(Ji), Ji_1_1 = Ji_1.next(); !Ji_1_1.done; Ji_1_1 = Ji_1.next()) {
|
|
2476
|
+
var e_114 = Ji_1_1.value;
|
|
2478
2477
|
t.ShaderStore.IncludesShadersStore[e_114.name] || (t.ShaderStore.IncludesShadersStore[e_114.name] = e_114.shader);
|
|
2479
2478
|
}
|
|
2480
2479
|
}
|
|
2481
2480
|
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
2482
2481
|
finally {
|
|
2483
2482
|
try {
|
|
2484
|
-
if (
|
|
2483
|
+
if (Ji_1_1 && !Ji_1_1.done && (_u = Ji_1.return)) _u.call(Ji_1);
|
|
2485
2484
|
}
|
|
2486
2485
|
finally { if (e_16) throw e_16.error; }
|
|
2487
2486
|
}
|
|
2488
|
-
var
|
|
2489
|
-
var
|
|
2490
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2491
|
-
var
|
|
2487
|
+
var er = { __proto__: null, compositeGlobeAtmospherePixelShader: { name: Qi, shader: Ki } };
|
|
2488
|
+
var tr = "skyViewPixelShader", ir = "#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";
|
|
2489
|
+
t.ShaderStore.ShadersStoreWGSL[tr] || (t.ShaderStore.ShadersStoreWGSL[tr] = ir);
|
|
2490
|
+
var rr = [Et, t.helperFunctionsWGSL, t.intersectionFunctionsWGSL, Tt];
|
|
2492
2491
|
try {
|
|
2493
|
-
for (var
|
|
2494
|
-
var e_115 =
|
|
2492
|
+
for (var rr_1 = __values(rr), rr_1_1 = rr_1.next(); !rr_1_1.done; rr_1_1 = rr_1.next()) {
|
|
2493
|
+
var e_115 = rr_1_1.value;
|
|
2495
2494
|
t.ShaderStore.IncludesShadersStoreWGSL[e_115.name] || (t.ShaderStore.IncludesShadersStoreWGSL[e_115.name] = e_115.shader);
|
|
2496
2495
|
}
|
|
2497
2496
|
}
|
|
2498
2497
|
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
2499
2498
|
finally {
|
|
2500
2499
|
try {
|
|
2501
|
-
if (
|
|
2500
|
+
if (rr_1_1 && !rr_1_1.done && (_v = rr_1.return)) _v.call(rr_1);
|
|
2502
2501
|
}
|
|
2503
2502
|
finally { if (e_17) throw e_17.error; }
|
|
2504
2503
|
}
|
|
2505
|
-
var
|
|
2506
|
-
var
|
|
2507
|
-
t.ShaderStore.ShadersStore[
|
|
2508
|
-
var
|
|
2504
|
+
var nr = { __proto__: null, skyViewPixelShaderWGSL: { name: tr, shader: ir } };
|
|
2505
|
+
var ar = "skyViewPixelShader", sr = "#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);}";
|
|
2506
|
+
t.ShaderStore.ShadersStore[ar] || (t.ShaderStore.ShadersStore[ar] = sr);
|
|
2507
|
+
var or = [Ft, Ot, t.helperFunctions, t.intersectionFunctions, Mt];
|
|
2509
2508
|
try {
|
|
2510
|
-
for (var
|
|
2511
|
-
var e_116 =
|
|
2509
|
+
for (var or_1 = __values(or), or_1_1 = or_1.next(); !or_1_1.done; or_1_1 = or_1.next()) {
|
|
2510
|
+
var e_116 = or_1_1.value;
|
|
2512
2511
|
t.ShaderStore.IncludesShadersStore[e_116.name] || (t.ShaderStore.IncludesShadersStore[e_116.name] = e_116.shader);
|
|
2513
2512
|
}
|
|
2514
2513
|
}
|
|
2515
2514
|
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
2516
2515
|
finally {
|
|
2517
2516
|
try {
|
|
2518
|
-
if (
|
|
2517
|
+
if (or_1_1 && !or_1_1.done && (_w = or_1.return)) _w.call(or_1);
|
|
2519
2518
|
}
|
|
2520
2519
|
finally { if (e_18) throw e_18.error; }
|
|
2521
2520
|
}
|
|
2522
|
-
var
|
|
2523
|
-
var
|
|
2524
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2525
|
-
var
|
|
2526
|
-
var
|
|
2527
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2528
|
-
var
|
|
2529
|
-
var
|
|
2530
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2531
|
-
var
|
|
2532
|
-
var
|
|
2533
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2534
|
-
var
|
|
2535
|
-
var
|
|
2536
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2537
|
-
var
|
|
2538
|
-
var
|
|
2539
|
-
t.ShaderStore.ShadersStoreWGSL[
|
|
2540
|
-
var
|
|
2541
|
-
var
|
|
2542
|
-
t.ShaderStore.ShadersStore[
|
|
2543
|
-
var
|
|
2544
|
-
var
|
|
2545
|
-
t.ShaderStore.ShadersStore[
|
|
2546
|
-
var
|
|
2547
|
-
var
|
|
2548
|
-
t.ShaderStore.ShadersStore[
|
|
2549
|
-
var
|
|
2550
|
-
var
|
|
2551
|
-
t.ShaderStore.ShadersStore[
|
|
2552
|
-
var
|
|
2553
|
-
var
|
|
2554
|
-
t.ShaderStore.ShadersStore[
|
|
2555
|
-
var
|
|
2556
|
-
var
|
|
2557
|
-
t.ShaderStore.ShadersStore[
|
|
2558
|
-
var
|
|
2521
|
+
var lr = { __proto__: null, skyViewPixelShader: { name: ar, shader: sr } };
|
|
2522
|
+
var cr = "multiTextureCompositeAlphaBlendPixelShader", ur = "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";
|
|
2523
|
+
t.ShaderStore.ShadersStoreWGSL[cr] || (t.ShaderStore.ShadersStoreWGSL[cr] = ur);
|
|
2524
|
+
var hr = { __proto__: null, multiTextureCompositeAlphaBlendPixelShaderWGSL: { name: cr, shader: ur } };
|
|
2525
|
+
var dr = "multiTextureCompositeAlphaMaxPixelShader", mr = "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";
|
|
2526
|
+
t.ShaderStore.ShadersStoreWGSL[dr] || (t.ShaderStore.ShadersStoreWGSL[dr] = mr);
|
|
2527
|
+
var pr = { __proto__: null, multiTextureCompositeAlphaMaxPixelShaderWGSL: { name: dr, shader: mr } };
|
|
2528
|
+
var fr = "multiTextureCompositeAddPixelShader", gr = "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";
|
|
2529
|
+
t.ShaderStore.ShadersStoreWGSL[fr] || (t.ShaderStore.ShadersStoreWGSL[fr] = gr);
|
|
2530
|
+
var vr = { __proto__: null, multiTextureCompositeAddPixelShaderWGSL: { name: fr, shader: gr } };
|
|
2531
|
+
var _r = "multiTextureCompositeMultiplyPixelShader", Sr = "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;} ";
|
|
2532
|
+
t.ShaderStore.ShadersStoreWGSL[_r] || (t.ShaderStore.ShadersStoreWGSL[_r] = Sr);
|
|
2533
|
+
var yr = { __proto__: null, multiTextureCompositeMultiplyPixelShaderWGSL: { name: _r, shader: Sr } };
|
|
2534
|
+
var Tr = "multiTextureCompositeSubtractPixelShader", Ar = "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";
|
|
2535
|
+
t.ShaderStore.ShadersStoreWGSL[Tr] || (t.ShaderStore.ShadersStoreWGSL[Tr] = Ar);
|
|
2536
|
+
var Lr = { __proto__: null, multiTextureCompositeSubtractPixelShaderWGSL: { name: Tr, shader: Ar } };
|
|
2537
|
+
var Pr = "multiTextureCompositeScreenPixelShader", Er = "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";
|
|
2538
|
+
t.ShaderStore.ShadersStoreWGSL[Pr] || (t.ShaderStore.ShadersStoreWGSL[Pr] = Er);
|
|
2539
|
+
var Rr = { __proto__: null, multiTextureCompositeScreenPixelShaderWGSL: { name: Pr, shader: Er } };
|
|
2540
|
+
var Cr = "multiTextureCompositeAlphaBlendPixelShader", xr = "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";
|
|
2541
|
+
t.ShaderStore.ShadersStore[Cr] || (t.ShaderStore.ShadersStore[Cr] = xr);
|
|
2542
|
+
var Mr = { __proto__: null, multiTextureCompositeAlphaBlendPixelShader: { name: Cr, shader: xr } };
|
|
2543
|
+
var Ir = "multiTextureCompositeAlphaMaxPixelShader", wr = "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";
|
|
2544
|
+
t.ShaderStore.ShadersStore[Ir] || (t.ShaderStore.ShadersStore[Ir] = wr);
|
|
2545
|
+
var br = { __proto__: null, multiTextureCompositeAlphaMaxPixelShader: { name: Ir, shader: wr } };
|
|
2546
|
+
var Or = "multiTextureCompositeAddPixelShader", Dr = "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";
|
|
2547
|
+
t.ShaderStore.ShadersStore[Or] || (t.ShaderStore.ShadersStore[Or] = Dr);
|
|
2548
|
+
var Nr = { __proto__: null, multiTextureCompositeAddPixelShader: { name: Or, shader: Dr } };
|
|
2549
|
+
var Ur = "multiTextureCompositeMultiplyPixelShader", Fr = "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";
|
|
2550
|
+
t.ShaderStore.ShadersStore[Ur] || (t.ShaderStore.ShadersStore[Ur] = Fr);
|
|
2551
|
+
var Vr = { __proto__: null, multiTextureCompositeMultiplyPixelShader: { name: Ur, shader: Fr } };
|
|
2552
|
+
var Gr = "multiTextureCompositeSubtractPixelShader", kr = "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";
|
|
2553
|
+
t.ShaderStore.ShadersStore[Gr] || (t.ShaderStore.ShadersStore[Gr] = kr);
|
|
2554
|
+
var zr = { __proto__: null, multiTextureCompositeSubtractPixelShader: { name: Gr, shader: kr } };
|
|
2555
|
+
var Br = "multiTextureCompositeScreenPixelShader", Wr = "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";
|
|
2556
|
+
t.ShaderStore.ShadersStore[Br] || (t.ShaderStore.ShadersStore[Br] = Wr);
|
|
2557
|
+
var Hr = { __proto__: null, multiTextureCompositeScreenPixelShader: { name: Br, shader: Wr } };
|
|
2559
2558
|
e.Atmosphere = /** @class */ (function () {
|
|
2560
2559
|
function Atmosphere(e, i, r, n) {
|
|
2561
2560
|
var _this = this;
|
|
2562
2561
|
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 =
|
|
2562
|
+
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 = z++, this._materialPluginName = "atmo-pbr-".concat(this.uniqueId), 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
2563
|
var I = this._engine = i.getEngine();
|
|
2565
2564
|
if (!I.isWebGPU && I.version < 2)
|
|
2566
2565
|
throw new Error("Atmosphere is not supported on WebGL ".concat(I.version, "."));
|
|
@@ -2577,13 +2576,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2577
2576
|
var i_16 = e_117.intensity;
|
|
2578
2577
|
this._lightRadianceAtCamera.set(i_16 * t_26.r, i_16 * t_26.g, i_16 * t_26.b);
|
|
2579
2578
|
}
|
|
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 =
|
|
2579
|
+
this._effectRenderer = new t.EffectRenderer(I, { indices: [0, 2, 1], positions: [-1, -1, -1, 3, 3, -1] }), this._transmittanceLut = new k(this), this._multiScatteringLutRenderTarget = H("atmo-multiScattering", { width: 32, height: 32 }, i), this._multiScatteringEffectWrapper = W(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); });
|
|
2581
2580
|
{
|
|
2582
2581
|
var e_118 = i.renderingManager;
|
|
2583
2582
|
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)
|
|
2584
2583
|
return; var t = e.renderingGroupId; _this._skyRenderingGroup === t && _this.drawSkyCompositor(), _this._aerialPerspectiveRenderingGroup === t && _this.drawAerialPerspectiveCompositor(), _this._globeAtmosphereRenderingGroup === t && _this.drawGlobeAtmosphereCompositor(); });
|
|
2585
2584
|
}
|
|
2586
|
-
i.onDisposeObservable.addOnce(function () { i.removeExternalData("atmosphere"), _this.dispose(); }), i.addExternalData("atmosphere", this), t.
|
|
2585
|
+
i.onDisposeObservable.addOnce(function () { i.removeExternalData("atmosphere"), _this.dispose(); }), i.addExternalData("atmosphere", this), t.RegisterMaterialPlugin(this._materialPluginName, function (e) { var t; return "PBRMaterial" !== e.getClassName() || e.getScene() !== _this.scene || (null === (t = e.pluginManager) || void 0 === t ? void 0 : t.getPlugin("AtmospherePBRMaterialPlugin")) ? null : new p(e, _this, null === _this.depthTexture); }), this._eagerlyPreloadMaterialPluginShaderIncludesAsync(), i.addIsReadyCheck(this);
|
|
2587
2586
|
}
|
|
2588
2587
|
Atmosphere.IsSupported = function (e) { return !e._badOS && (e.isWebGPU || e.version >= 2); };
|
|
2589
2588
|
Object.defineProperty(Atmosphere.prototype, "exposure", {
|
|
@@ -2657,7 +2656,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2657
2656
|
Object.defineProperty(Atmosphere.prototype, "skyViewLutRenderTarget", {
|
|
2658
2657
|
get: function () { if (!this._isSkyViewLutEnabled)
|
|
2659
2658
|
return null; if (null !== this._skyViewLutRenderTarget)
|
|
2660
|
-
return this._skyViewLutRenderTarget; var e = this._skyViewLutRenderTarget =
|
|
2659
|
+
return this._skyViewLutRenderTarget; var e = this._skyViewLutRenderTarget = H("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 B(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 Bt; }), Promise.resolve().then(function () { return nr; })] : [Promise.resolve().then(function () { return Xt; }), Promise.resolve().then(function () { return lr; })]), false)); }); })(this._engine, this.uniformBuffer), e; },
|
|
2661
2660
|
enumerable: false,
|
|
2662
2661
|
configurable: true
|
|
2663
2662
|
});
|
|
@@ -2670,7 +2669,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2670
2669
|
Object.defineProperty(Atmosphere.prototype, "aerialPerspectiveLutRenderTarget", {
|
|
2671
2670
|
get: function () { if (!this._isAerialPerspectiveLutEnabled)
|
|
2672
2671
|
return null; if (null !== this._aerialPerspectiveLutRenderTarget)
|
|
2673
|
-
return this._aerialPerspectiveLutRenderTarget; var e = this.scene, i = this._aerialPerspectiveLutRenderTarget =
|
|
2672
|
+
return this._aerialPerspectiveLutRenderTarget; var e = this.scene, i = this._aerialPerspectiveLutRenderTarget = H("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 B(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 Bt; }), Promise.resolve().then(function () { return xi; })] : [Promise.resolve().then(function () { return Xt; }), Promise.resolve().then(function () { return bi; })]), false)); }); })(this._engine, this.uniformBuffer), i; },
|
|
2674
2673
|
enumerable: false,
|
|
2675
2674
|
configurable: true
|
|
2676
2675
|
});
|
|
@@ -2808,16 +2807,16 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2808
2807
|
return [2 /*return*/];
|
|
2809
2808
|
}
|
|
2810
2809
|
}); }); };
|
|
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(
|
|
2810
|
+
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(this._materialPluginName); };
|
|
2812
2811
|
Atmosphere.prototype.isEnabled = function () { return this._isEnabled; };
|
|
2813
2812
|
Atmosphere.prototype.setEnabled = function (e) { this._isEnabled = e; };
|
|
2814
2813
|
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 =
|
|
2814
|
+
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 = Z(g, v, _, S, y)), null !== (t = this._globeAtmosphereCompositorEffectWrapper) && void 0 !== t || (this._globeAtmosphereCompositorEffectWrapper = Y(g, v, _, S, y, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias, null !== T)), null !== T && (null !== (i = this._aerialPerspectiveCompositorEffectWrapper) && void 0 !== i || (this._aerialPerspectiveCompositorEffectWrapper = $(g, v, this._isAerialPerspectiveLutEnabled, _, S, y, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias))), null === (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())); };
|
|
2816
2815
|
Atmosphere.prototype.getClassName = function () { return "Atmosphere"; };
|
|
2817
2816
|
Atmosphere.prototype._drawMultiScatteringLut = function () {
|
|
2818
2817
|
var _this = this;
|
|
2819
2818
|
var e = this._transmittanceLut.renderTarget;
|
|
2820
|
-
|
|
2819
|
+
q(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(); });
|
|
2821
2820
|
};
|
|
2822
2821
|
Atmosphere.prototype.drawAerialPerspectiveCompositor = function () {
|
|
2823
2822
|
var _this = this;
|
|
@@ -2826,13 +2825,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2826
2825
|
return;
|
|
2827
2826
|
if (!this.isEnabled())
|
|
2828
2827
|
return;
|
|
2829
|
-
var n = this._engine, a = null !== (e = this._aerialPerspectiveCompositorEffectWrapper) && void 0 !== e ? e : this._aerialPerspectiveCompositorEffectWrapper =
|
|
2828
|
+
var n = this._engine, a = null !== (e = this._aerialPerspectiveCompositorEffectWrapper) && void 0 !== e ? e : this._aerialPerspectiveCompositorEffectWrapper = $(n, this.uniformBuffer, this._isAerialPerspectiveLutEnabled, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias);
|
|
2830
2829
|
if (!this._isGlobalLutsReady)
|
|
2831
2830
|
return;
|
|
2832
2831
|
if (this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius)
|
|
2833
2832
|
return;
|
|
2834
2833
|
var s = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null, o = this._multiScatteringLutRenderTarget, l = this._transmittanceLut.renderTarget, c = this._isAerialPerspectiveLutEnabled ? this.aerialPerspectiveLutRenderTarget : 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() &&
|
|
2834
|
+
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() && q(n, this._effectRenderer, a, null, function (e, t, i) { if (null === _this.depthTexture)
|
|
2836
2835
|
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);
|
|
2837
2836
|
};
|
|
2838
2837
|
Atmosphere.prototype.drawSkyCompositor = function () {
|
|
@@ -2840,7 +2839,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2840
2839
|
var e, i;
|
|
2841
2840
|
if (!this.isEnabled())
|
|
2842
2841
|
return;
|
|
2843
|
-
var r = this._engine, n = null !== (e = this._skyCompositorEffectWrapper) && void 0 !== e ? e : this._skyCompositorEffectWrapper =
|
|
2842
|
+
var r = this._engine, n = null !== (e = this._skyCompositorEffectWrapper) && void 0 !== e ? e : this._skyCompositorEffectWrapper = Z(r, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance);
|
|
2844
2843
|
if (!this._isGlobalLutsReady)
|
|
2845
2844
|
return;
|
|
2846
2845
|
if (this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius)
|
|
@@ -2848,20 +2847,20 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2848
2847
|
if (null !== this.depthTexture && !this.depthTexture.isReady())
|
|
2849
2848
|
return;
|
|
2850
2849
|
var a = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null, s = this._multiScatteringLutRenderTarget, o = this._transmittanceLut.renderTarget;
|
|
2851
|
-
n.isReady() && (null === (i = null == a ? void 0 : a.isReady()) || void 0 === i || i) && s.isReady() && o.isReady() &&
|
|
2850
|
+
n.isReady() && (null === (i = null == a ? void 0 : a.isReady()) || void 0 === i || i) && s.isReady() && o.isReady() && q(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);
|
|
2852
2851
|
};
|
|
2853
2852
|
Atmosphere.prototype.drawGlobeAtmosphereCompositor = function () {
|
|
2854
2853
|
var _this = this;
|
|
2855
2854
|
var e, i;
|
|
2856
2855
|
if (!this.isEnabled())
|
|
2857
2856
|
return;
|
|
2858
|
-
var r = this._engine, n = null !== (e = this._globeAtmosphereCompositorEffectWrapper) && void 0 !== e ? e : this._globeAtmosphereCompositorEffectWrapper =
|
|
2857
|
+
var r = this._engine, n = null !== (e = this._globeAtmosphereCompositorEffectWrapper) && void 0 !== e ? e : this._globeAtmosphereCompositorEffectWrapper = Y(r, this.uniformBuffer, this._isSkyViewLutEnabled, this._isLinearSpaceComposition, this._applyApproximateTransmittance, this._aerialPerspectiveIntensity, this._aerialPerspectiveRadianceBias, null !== this.depthTexture);
|
|
2859
2858
|
if (!this._isGlobalLutsReady)
|
|
2860
2859
|
return;
|
|
2861
2860
|
if (!(this._cameraAtmosphereVariables.clampedCameraRadius > this._physicalProperties.atmosphereRadius))
|
|
2862
2861
|
return;
|
|
2863
2862
|
var a = this._isSkyViewLutEnabled ? this.skyViewLutRenderTarget : null, s = this._multiScatteringLutRenderTarget, o = this._transmittanceLut.renderTarget;
|
|
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()) &&
|
|
2863
|
+
n.isReady() && (null === (i = null == a ? void 0 : a.isReady()) || void 0 === i || i) && s.isReady() && o.isReady() && (null === this.depthTexture || this.depthTexture.isReady()) && q(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);
|
|
2865
2864
|
};
|
|
2866
2865
|
Atmosphere.prototype._disposeSkyCompositor = function () { var e; null === (e = this._skyCompositorEffectWrapper) || void 0 === e || e.dispose(), this._skyCompositorEffectWrapper = null; };
|
|
2867
2866
|
Atmosphere.prototype._disposeAerialPerspectiveCompositor = function () { var e; null === (e = this._aerialPerspectiveCompositorEffectWrapper) || void 0 === e || e.dispose(), this._aerialPerspectiveCompositorEffectWrapper = null; };
|
|
@@ -2879,13 +2878,13 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2879
2878
|
var t_29 = e_121.intensity;
|
|
2880
2879
|
this._lightRadianceAtCamera.set(t_29 * this._linearLightColor.r, t_29 * this._linearLightColor.g, t_29 * this._linearLightColor.b);
|
|
2881
2880
|
} 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); };
|
|
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 =
|
|
2881
|
+
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 = W(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()); };
|
|
2883
2882
|
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(); };
|
|
2884
2883
|
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); };
|
|
2885
2884
|
Atmosphere.prototype._drawAerialPerspectiveLut = function () {
|
|
2886
2885
|
var _this = this;
|
|
2887
2886
|
var e = this._transmittanceLut.renderTarget, t = this._multiScatteringLutRenderTarget;
|
|
2888
|
-
|
|
2887
|
+
q(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
2888
|
a.bindFramebuffer(r, void 0, void 0, void 0, !0, void 0, e_122), i.bindBuffers(n), n.setFloat("layerIdx", e_122), i.draw(); });
|
|
2890
2889
|
};
|
|
2891
2890
|
Atmosphere.prototype._clearAerialPerspectiveLut = function () { var e; var t = null === (e = this._aerialPerspectiveLutRenderTarget) || void 0 === e ? void 0 : e.renderTarget; if (t) {
|
|
@@ -2896,29 +2895,29 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2896
2895
|
Atmosphere.prototype._drawSkyViewLut = function () {
|
|
2897
2896
|
var _this = this;
|
|
2898
2897
|
var e = this._transmittanceLut.renderTarget, t = this._multiScatteringLutRenderTarget;
|
|
2899
|
-
|
|
2898
|
+
q(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(); });
|
|
2900
2899
|
};
|
|
2901
2900
|
return Atmosphere;
|
|
2902
|
-
}()), e.AtmospherePhysicalProperties = A, e.BuildFromNavmeshData = function (e) { var t =
|
|
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 =
|
|
2904
|
-
throw new Error("Unable to deserialize TileCache."); return { navMesh: r.navMesh, navMeshQuery: new i.NavMeshQuery(r.navMesh), tileCache: r.tileCache }; }, e.ComputeSmoothPath =
|
|
2901
|
+
}()), e.AtmospherePhysicalProperties = A, e.BuildFromNavmeshData = function (e) { var t = qe(), i = t.importNavMesh(e); if (!i.navMesh)
|
|
2902
|
+
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 = qe(), r = i.importTileCache(e, t); if (!r.tileCache)
|
|
2903
|
+
throw new Error("Unable to deserialize TileCache."); return { navMesh: r.navMesh, navMeshQuery: new i.NavMeshQuery(r.navMesh), tileCache: r.tileCache }; }, e.ComputeSmoothPath = at, e.ConvertNavPathPoints = it, e.CreateDebugNavMesh = dt, e.CreateDefaultTileCacheMeshProcess = Ye, e.CreateNavigationPluginAsync = function (e) { return i(this, void 0, void 0, function () { var r; return __generator(this, function (_a) {
|
|
2905
2904
|
switch (_a.label) {
|
|
2906
2905
|
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) {
|
|
2907
2906
|
switch (_a.label) {
|
|
2908
2907
|
case 0:
|
|
2909
2908
|
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 (
|
|
2911
|
-
if (
|
|
2912
|
-
return [4 /*yield*/,
|
|
2909
|
+
if (!!Ze) return [3 /*break*/, 6];
|
|
2910
|
+
if (!$e) return [3 /*break*/, 2];
|
|
2911
|
+
return [4 /*yield*/, $e];
|
|
2913
2912
|
case 1:
|
|
2914
2913
|
_a.sent();
|
|
2915
2914
|
return [3 /*break*/, 6];
|
|
2916
2915
|
case 2:
|
|
2917
2916
|
if (!a.instance) return [3 /*break*/, 3];
|
|
2918
|
-
|
|
2917
|
+
Ze = a.instance;
|
|
2919
2918
|
return [3 /*break*/, 6];
|
|
2920
2919
|
case 3:
|
|
2921
|
-
|
|
2920
|
+
$e = function (e, r) { return i(this, void 0, void 0, function () { var i, n; return __generator(this, function (_a) {
|
|
2922
2921
|
switch (_a.label) {
|
|
2923
2922
|
case 0:
|
|
2924
2923
|
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");
|
|
@@ -2927,11 +2926,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2927
2926
|
case 1: return [2 /*return*/, _a.sent()];
|
|
2928
2927
|
}
|
|
2929
2928
|
}); }); }(a.url, a.version);
|
|
2930
|
-
return [4 /*yield*/,
|
|
2929
|
+
return [4 /*yield*/, $e];
|
|
2931
2930
|
case 4:
|
|
2932
2931
|
e_124 = _a.sent();
|
|
2933
|
-
|
|
2934
|
-
return [4 /*yield*/,
|
|
2932
|
+
Ze = Object.assign(Object.assign({}, e_124.core), e_124.generators);
|
|
2933
|
+
return [4 /*yield*/, Ze.init()];
|
|
2935
2934
|
case 5:
|
|
2936
2935
|
_a.sent();
|
|
2937
2936
|
_a.label = 6;
|
|
@@ -2940,10 +2939,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2940
2939
|
}); }); }(e)];
|
|
2941
2940
|
case 1:
|
|
2942
2941
|
_a.sent();
|
|
2943
|
-
r = new
|
|
2944
|
-
return [2 /*return*/, (
|
|
2942
|
+
r = new ft(qe());
|
|
2943
|
+
return [2 /*return*/, (pt(r), r)];
|
|
2945
2944
|
}
|
|
2946
|
-
}); }); }, e.CreateSoloNavMeshConfig =
|
|
2945
|
+
}); }); }, e.CreateSoloNavMeshConfig = Xe, e.CreateTileCacheNavMeshConfig = Ke, e.CreateTiledNavMeshConfig = Qe, e.DebugLayerOption = vt, e.DefaultMaxObstacles = 128, e.DefaultParagraphOptions = ye, e.DiffuseSkyIrradianceLut = O, e.FitStrategy = ve, e.FontAsset = /** @class */ (function () {
|
|
2947
2946
|
function FontAsset(e, i, r) {
|
|
2948
2947
|
var _this = this;
|
|
2949
2948
|
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; });
|
|
@@ -2965,12 +2964,12 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2965
2964
|
}
|
|
2966
2965
|
this.textures.length = 0;
|
|
2967
2966
|
};
|
|
2968
|
-
FontAsset.prototype._updateFallbacks = function () { this._chars.has(
|
|
2969
|
-
FontAsset.prototype._getChar = function (e) { return this._chars.get(e) || this._chars.get(
|
|
2967
|
+
FontAsset.prototype._updateFallbacks = function () { this._chars.has(Se.SPACE) || this._chars.set(Se.SPACE, { id: Se.SPACE, x: 0, y: 0, width: 0, height: 0, xoffset: 0, yoffset: 0, xadvance: .5 * this._font.info.size, page: -1, chnl: -1, index: -1, char: " " }), this._chars.has(Se.TOFU) || this._chars.set(Se.TOFU, { id: Se.TOFU, x: 0, y: 0, width: this._font.info.size, height: this._font.info.size, xoffset: 0, yoffset: 0, xadvance: .5 * this._font.info.size, page: -1, chnl: -1, index: -1, char: "" }); };
|
|
2968
|
+
FontAsset.prototype._getChar = function (e) { return this._chars.get(e) || this._chars.get(Se.TOFU); };
|
|
2970
2969
|
FontAsset.prototype._getKerning = function (e, t) { var i; return (null === (i = this._kernings.get(e)) || void 0 === i ? void 0 : i.get(t)) || 0; };
|
|
2971
2970
|
FontAsset.prototype._unsupportedChars = function (e) { return e.replace(this._charsRegex, ""); };
|
|
2972
2971
|
return FontAsset;
|
|
2973
|
-
}()), e.GenerateNavMesh =
|
|
2972
|
+
}()), e.GenerateNavMesh = mt, e.GetChaikinSmoothPath = function (e, t) {
|
|
2974
2973
|
if (t === void 0) { t = 1; }
|
|
2975
2974
|
for (var i_19 = 0; i_19 < t; i_19++) {
|
|
2976
2975
|
var t_30 = [];
|
|
@@ -2982,7 +2981,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
2982
2981
|
}
|
|
2983
2982
|
return e;
|
|
2984
2983
|
}, 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 =
|
|
2984
|
+
var n_18 = e[r_17], a_15 = e[r_17 + 1], s_14 = gt(n_18, a_15);
|
|
2986
2985
|
i.push(n_18, new t.Vector3(s_14.x, a_15.y, s_14.z), a_15);
|
|
2987
|
-
} return i; }, e.GetPositionsAndIndices =
|
|
2986
|
+
} return i; }, e.GetPositionsAndIndices = ut, e.GetReversedIndices = ht, e.HtmlMesh = _e, e.HtmlMeshRenderer = Q, e.InjectGenerators = pt, e.MultiTexture = We, e.NavigationDebugger = _t, e.PointerEventsCaptureBehavior = ge, e.RecastNavigationJSPluginV2 = ft, e.RegisterMultiTexture = Be, e.SdfTextParagraph = Te, e.TextRenderer = Ae, e.ToCrowdAgentParams = et, e.ToSoloNavMeshGeneratorConfig = Je, e.TransmittanceLut = k, e.WaitForFullTileCacheUpdate = je, e.msdfPixelShader = Me, e.msdfPixelShaderWGSL = Fe, e.msdfVertexShader = Ee, e.msdfVertexShaderWGSL = Oe;
|
|
2988
2987
|
});
|