@roomle/web-sdk 3.10.0-alpha.2 → 3.10.0-alpha.4
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/lib/{BufferGeometry-Dxcf7n9V.mjs → BufferGeometry-Dj5loCTL.mjs} +2 -2
- package/lib/{BufferGeometry-Dxcf7n9V.mjs.map → BufferGeometry-Dj5loCTL.mjs.map} +1 -1
- package/lib/ConfiguratorKernel.wasm +0 -0
- package/lib/{GLTFExporter-kpv1e-Ks.mjs → GLTFExporter-CquK-kkI.mjs} +1 -1
- package/lib/{GLTFExporter-kpv1e-Ks.mjs.map → GLTFExporter-CquK-kkI.mjs.map} +1 -1
- package/lib/{GaussianBlurNode-CMVlBe39.mjs → GaussianBlurNode-CDYPio-x.mjs} +3 -3
- package/lib/{GaussianBlurNode-CMVlBe39.mjs.map → GaussianBlurNode-CDYPio-x.mjs.map} +1 -1
- package/lib/{Object3D-BZaiqQIE.mjs → Object3D-YXSPdGeJ.mjs} +1 -1
- package/lib/{Object3D-BZaiqQIE.mjs.map → Object3D-YXSPdGeJ.mjs.map} +1 -1
- package/lib/{PointLightHelper-fzRB58rC.mjs → PointLightHelper-g98giMRd.mjs} +4 -4
- package/lib/{PointLightHelper-fzRB58rC.mjs.map → PointLightHelper-g98giMRd.mjs.map} +1 -1
- package/lib/RoomleCore.wasm +0 -0
- package/lib/RoomleToolsCore.wasm +0 -0
- package/lib/{SpotLightHelper-D5UFwRPb.mjs → SpotLightHelper-xR8lCZau.mjs} +3 -3
- package/lib/{SpotLightHelper-D5UFwRPb.mjs.map → SpotLightHelper-xR8lCZau.mjs.map} +1 -1
- package/lib/{USDZExporter-Y0SSGr5_.mjs → USDZExporter-BMqBymZI.mjs} +2 -2
- package/lib/{USDZExporter-Y0SSGr5_.mjs.map → USDZExporter-BMqBymZI.mjs.map} +1 -1
- package/lib/{Vector4-BfZH1ecw.mjs → Vector4-CqzXUndP.mjs} +2 -2
- package/lib/{Vector4-BfZH1ecw.mjs.map → Vector4-CqzXUndP.mjs.map} +1 -1
- package/lib/{api-BXU3pZnX.mjs → api-ckpzIPty.mjs} +2 -2
- package/lib/{api-BXU3pZnX.mjs.map → api-ckpzIPty.mjs.map} +1 -1
- package/lib/{asset-loader.worker-C911tbNL.mjs → asset-loader.worker-CHyN7JB1.mjs} +1 -1
- package/lib/asset-loader.worker-CHyN7JB1.mjs.map +1 -0
- package/lib/{banana-for-scale-B_LIHI9q.mjs → banana-for-scale-Cs2s9dNp.mjs} +3 -3
- package/lib/{banana-for-scale-B_LIHI9q.mjs.map → banana-for-scale-Cs2s9dNp.mjs.map} +1 -1
- package/lib/{budgeteer.sw-D3VxiASa.mjs → budgeteer.sw-BCLEIWCW.mjs} +1 -1
- package/lib/budgeteer.sw-BCLEIWCW.mjs.map +1 -0
- package/lib/{common-utils-B9PC_rvS.mjs → common-utils-DMk5jc_R.mjs} +1 -1
- package/lib/{common-utils-B9PC_rvS.mjs.map → common-utils-DMk5jc_R.mjs.map} +1 -1
- package/lib/{component-dimensioning-5iIw1f_3.mjs → component-dimensioning-DcmDM6gV.mjs} +6 -6
- package/lib/{component-dimensioning-5iIw1f_3.mjs.map → component-dimensioning-DcmDM6gV.mjs.map} +1 -1
- package/lib/{component-raycast-helper-O27_buEg.mjs → component-raycast-helper-CXN2MHtG.mjs} +4 -4
- package/lib/{component-raycast-helper-O27_buEg.mjs.map → component-raycast-helper-CXN2MHtG.mjs.map} +1 -1
- package/lib/{configurator-BwxEIDv7.mjs → configurator-D6lTTIlU.mjs} +4 -4
- package/lib/{configurator-BwxEIDv7.mjs.map → configurator-D6lTTIlU.mjs.map} +1 -1
- package/lib/configurator-DZotRC5_.mjs +2 -0
- package/lib/{continuous-drawing-helper-D25YPUle.mjs → continuous-drawing-helper-BlGATN0C.mjs} +2 -2
- package/lib/{continuous-drawing-helper-D25YPUle.mjs.map → continuous-drawing-helper-BlGATN0C.mjs.map} +1 -1
- package/lib/{dat.gui.module-CZ-DIWHM.mjs → dat.gui.module-BLjoST8r.mjs} +1 -1
- package/lib/{dat.gui.module-CZ-DIWHM.mjs.map → dat.gui.module-BLjoST8r.mjs.map} +1 -1
- package/lib/{decorate-C9r0zXzz.mjs → decorate-CTUwswpM.mjs} +1 -1
- package/lib/{decorate-C9r0zXzz.mjs.map → decorate-CTUwswpM.mjs.map} +1 -1
- package/lib/dimensioning-helper-BwBj5QDM.mjs +2 -0
- package/lib/{dimensioning-helper-d6JA4UMr.mjs → dimensioning-helper-DMop5qcu.mjs} +4 -4
- package/lib/{dimensioning-helper-d6JA4UMr.mjs.map → dimensioning-helper-DMop5qcu.mjs.map} +1 -1
- package/lib/dist-DGov-RNo.mjs +438 -0
- package/lib/dist-DGov-RNo.mjs.map +1 -0
- package/lib/{fflate.module-CBz7CLOg.mjs → fflate.module-n0Jozp8Z.mjs} +1 -1
- package/lib/{fflate.module-CBz7CLOg.mjs.map → fflate.module-n0Jozp8Z.mjs.map} +1 -1
- package/lib/{glb-viewer-C0Et5SO6.mjs → glb-viewer-CuRDCxVq.mjs} +6 -6
- package/lib/{glb-viewer-C0Et5SO6.mjs.map → glb-viewer-CuRDCxVq.mjs.map} +1 -1
- package/lib/glb-viewer-DKWeC8wq.mjs +2 -0
- package/lib/{highlight-coordinator-DdQ8yNjO.mjs → highlight-coordinator-CTZ_qcde.mjs} +2 -2
- package/lib/{highlight-coordinator-DdQ8yNjO.mjs.map → highlight-coordinator-CTZ_qcde.mjs.map} +1 -1
- package/lib/{homag-intelligence-DrKayEjK.mjs → homag-intelligence-CIBPifJk.mjs} +3 -3
- package/lib/{homag-intelligence-DrKayEjK.mjs.map → homag-intelligence-CIBPifJk.mjs.map} +1 -1
- package/lib/{imos-ix-poc-export-helper-DU0ag-Lw.mjs → imos-ix-poc-export-helper-D2KaQu_v.mjs} +3 -3
- package/lib/{imos-ix-poc-export-helper-DU0ag-Lw.mjs.map → imos-ix-poc-export-helper-D2KaQu_v.mjs.map} +1 -1
- package/lib/{kernel-utils-Cj5B4fDD.mjs → kernel-utils-042AuCQh.mjs} +1 -1
- package/lib/{kernel-utils-Cj5B4fDD.mjs.map → kernel-utils-042AuCQh.mjs.map} +1 -1
- package/lib/{layer-C_JtkhdO.mjs → layer-CFAr2mK_.mjs} +1 -1
- package/lib/{layer-C_JtkhdO.mjs.map → layer-CFAr2mK_.mjs.map} +1 -1
- package/lib/{main-D2BulNeN.mjs → main-KSs3XdXO.mjs} +21603 -22104
- package/lib/main-KSs3XdXO.mjs.map +1 -0
- package/lib/{material-viewer-CZQwo8Nc.mjs → material-viewer-Ced_pruD.mjs} +6 -6
- package/lib/{material-viewer-CZQwo8Nc.mjs.map → material-viewer-Ced_pruD.mjs.map} +1 -1
- package/lib/packages-oEzg5zoT.mjs +4 -0
- package/lib/planner-QF8IrfPz.mjs +2 -0
- package/lib/{planner-OgIPgZ1m.mjs → planner-ykpwnVZa.mjs} +3 -3
- package/lib/{planner-OgIPgZ1m.mjs.map → planner-ykpwnVZa.mjs.map} +1 -1
- package/lib/{plugin-system-DlME_5b_.mjs → plugin-system-DRpL0Rer.mjs} +3 -3
- package/lib/{plugin-system-DlME_5b_.mjs.map → plugin-system-DRpL0Rer.mjs.map} +1 -1
- package/lib/rolldown-runtime-DgwB9i60.mjs +13 -0
- package/lib/{roomle-headless-setup-CMK-quZI.mjs → roomle-headless-setup-Cc8EAnVe.mjs} +1 -1
- package/lib/{roomle-headless-setup-CMK-quZI.mjs.map → roomle-headless-setup-Cc8EAnVe.mjs.map} +1 -1
- package/lib/roomle-headless.d.ts +69 -29
- package/lib/roomle-headless.js +9 -9
- package/lib/{roomle-renderer-DYQvV88j.mjs → roomle-renderer-BD3ZmpLS.mjs} +23 -5
- package/lib/roomle-renderer-BD3ZmpLS.mjs.map +1 -0
- package/lib/roomle-sdk.d.ts +69 -29
- package/lib/roomle-sdk.js +7 -7
- package/lib/{roomle-webgpu-renderer-5-aG3CMs.mjs → roomle-webgpu-renderer-NhCn2iM-.mjs} +386 -240
- package/lib/roomle-webgpu-renderer-NhCn2iM-.mjs.map +1 -0
- package/lib/{scene-renderer-DvXjoKHZ.mjs → scene-renderer-DbHi1plp.mjs} +367 -1467
- package/lib/scene-renderer-DbHi1plp.mjs.map +1 -0
- package/lib/{script-loader-CScqyQhc.mjs → script-loader-DKx7ZvkP.mjs} +3 -3
- package/lib/{script-loader-CScqyQhc.mjs.map → script-loader-DKx7ZvkP.mjs.map} +1 -1
- package/lib/shading-settings-BWeccIZv.mjs +1108 -0
- package/lib/shading-settings-BWeccIZv.mjs.map +1 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
- package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
- package/lib/{stats-helper-BYi5TI_H.mjs → stats-helper-Bs79UZne.mjs} +4 -4
- package/lib/{stats-helper-BYi5TI_H.mjs.map → stats-helper-Bs79UZne.mjs.map} +1 -1
- package/lib/{three.tsl-S0OKwamA.mjs → three.tsl-Bb8l7rD7.mjs} +1 -1
- package/lib/{three.tsl-CAEdYyg3.mjs → three.tsl-Caqi2VRr.mjs} +2 -2
- package/lib/{three.tsl-CAEdYyg3.mjs.map → three.tsl-Caqi2VRr.mjs.map} +1 -1
- package/lib/{three.webgpu-CkP2nkXM.mjs → three.webgpu-CT4fuV2X.mjs} +1 -1
- package/lib/{three.webgpu-CkP2nkXM.mjs.map → three.webgpu-CT4fuV2X.mjs.map} +1 -1
- package/lib/{three.webgpu-qrxDA_v0.mjs → three.webgpu-CxNhl3k-.mjs} +1 -1
- package/lib/{threejs-utils-C4J_TZ0o.mjs → threejs-utils-E4yVZATI.mjs} +4 -4
- package/lib/threejs-utils-E4yVZATI.mjs.map +1 -0
- package/lib/{tools-core-BCkbEbim.mjs → tools-core-D4EbqT91.mjs} +3 -3
- package/lib/{tools-core-BCkbEbim.mjs.map → tools-core-D4EbqT91.mjs.map} +1 -1
- package/lib/workers-Dc-RTL8D.mjs +6 -0
- package/lib/{workers-HXGCmmZS.mjs.map → workers-Dc-RTL8D.mjs.map} +1 -1
- package/package.json +1 -1
- package/lib/asset-loader.worker-C911tbNL.mjs.map +0 -1
- package/lib/budgeteer.sw-D3VxiASa.mjs.map +0 -1
- package/lib/configurator-BIyxKNI0.mjs +0 -2
- package/lib/dimensioning-helper-pPTkh8pl.mjs +0 -2
- package/lib/glb-viewer-DfMzLkqg.mjs +0 -2
- package/lib/main-D2BulNeN.mjs.map +0 -1
- package/lib/packages-BtLLQZLz.mjs +0 -4
- package/lib/planner-BF94NrwH.mjs +0 -2
- package/lib/rolldown-runtime-BwvMKf85.mjs +0 -23
- package/lib/roomle-renderer-DYQvV88j.mjs.map +0 -1
- package/lib/roomle-webgpu-renderer-5-aG3CMs.mjs.map +0 -1
- package/lib/scene-renderer-DvXjoKHZ.mjs.map +0 -1
- package/lib/threejs-utils-C4J_TZ0o.mjs.map +0 -1
- package/lib/workers-HXGCmmZS.mjs +0 -6
|
@@ -0,0 +1,1108 @@
|
|
|
1
|
+
import { Ci as e, Ei as t, En as n, Gn as r, Hr as i, Mr as a, On as o, Si as s, Ur as c, V as l, bn as u, cn as d, f, fi as p, h as m, in as h, on as g, pi as _, qt as v, sn as y, st as b, w as x, xi as S } from "./three.core-tV_4n8Wg.mjs";
|
|
2
|
+
import { h as C } from "./common-utils-DMk5jc_R.mjs";
|
|
3
|
+
//#region packages/common-core/src/webgl/renderer/shader-utility.ts
|
|
4
|
+
var w = {
|
|
5
|
+
uniforms: {
|
|
6
|
+
tDiffuse: { value: null },
|
|
7
|
+
colorTransform: { value: new y() },
|
|
8
|
+
colorBase: { value: new e(0, 0, 0, 0) },
|
|
9
|
+
multiplyChannels: { value: 0 },
|
|
10
|
+
uvTransform: { value: new g() }
|
|
11
|
+
},
|
|
12
|
+
vertexShader: "\n varying vec2 vUv;\n uniform mat3 uvTransform;\n\n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",
|
|
13
|
+
fragmentShader: "\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n\n void main() {\n vec4 color = texture2D(tDiffuse, vUv);\n #if PREMULTIPLIED_ALPHA == 1\n if (color.a > 0.0) color.rgb /= color.a;\n #endif\n color = colorTransform * color + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n #if LINEAR_TO_SRGB == 1\n color.rgb = mix(color.rgb * 12.92, 1.055 * pow(color.rgb, vec3(0.41666)) - 0.055, step(0.0031308, color.rgb));\n #endif\n gl_FragColor = color;\n }"
|
|
14
|
+
}, T = new y(), E = new y().set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0), D = new y().set(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0), O = new y().set(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1);
|
|
15
|
+
new y().set(0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1), new y().set(0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
16
|
+
var k = new y().set(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1), A = new e(0, 0, 0, 0), j = new e(0, 0, 0, 1), M = new g(), N = new g().set(1, 0, 0, 0, -1, 1, 0, 0, 1), P = {
|
|
17
|
+
DEFAULT: "default",
|
|
18
|
+
ADDITIVE: "additive"
|
|
19
|
+
}, F = class extends c {
|
|
20
|
+
constructor(e, t = P.ADDITIVE, n = !1, r = !1) {
|
|
21
|
+
let i = t === P.ADDITIVE ? {
|
|
22
|
+
blendSrc: 208,
|
|
23
|
+
blendDst: 200,
|
|
24
|
+
blendEquation: 100,
|
|
25
|
+
blendSrcAlpha: 206,
|
|
26
|
+
blendDstAlpha: 200,
|
|
27
|
+
blendEquationAlpha: 100
|
|
28
|
+
} : {};
|
|
29
|
+
super({
|
|
30
|
+
uniforms: p.clone(w.uniforms),
|
|
31
|
+
vertexShader: w.vertexShader,
|
|
32
|
+
fragmentShader: w.fragmentShader,
|
|
33
|
+
defines: {
|
|
34
|
+
LINEAR_TO_SRGB: n ? 1 : 0,
|
|
35
|
+
PREMULTIPLIED_ALPHA: r ? 1 : 0
|
|
36
|
+
},
|
|
37
|
+
transparent: !0,
|
|
38
|
+
depthTest: !1,
|
|
39
|
+
depthWrite: !1,
|
|
40
|
+
...i
|
|
41
|
+
}), this.update(e);
|
|
42
|
+
}
|
|
43
|
+
update(e) {
|
|
44
|
+
return e?.texture !== void 0 && (this.uniforms.tDiffuse.value = e?.texture), e?.colorTransform !== void 0 && (this.uniforms.colorTransform.value = e?.colorTransform), e?.colorBase !== void 0 && (this.uniforms.colorBase.value = e?.colorBase), e?.multiplyChannels !== void 0 && (this.uniforms.multiplyChannels.value = e?.multiplyChannels), e?.uvTransform !== void 0 && (this.uniforms.uvTransform.value = e?.uvTransform), e?.blending !== void 0 && (this.blending = e?.blending), e?.blendSrc !== void 0 && (this.blendSrc = e?.blendSrc), e?.blendDst !== void 0 && (this.blendDst = e?.blendDst), e?.blendEquation !== void 0 && (this.blendEquation = e?.blendEquation), e?.blendSrcAlpha !== void 0 && (this.blendSrcAlpha = e?.blendSrcAlpha), e?.blendDstAlpha !== void 0 && (this.blendDstAlpha = e?.blendDstAlpha), e?.blendEquationAlpha !== void 0 && (this.blendEquationAlpha = e?.blendEquationAlpha), this;
|
|
45
|
+
}
|
|
46
|
+
}, I = {
|
|
47
|
+
uniforms: {
|
|
48
|
+
tDiffuse: { value: null },
|
|
49
|
+
rangeMin: { value: new S(1 / 512, 1 / 512) },
|
|
50
|
+
rangeMax: { value: new S(1 / 512, 1 / 512) }
|
|
51
|
+
},
|
|
52
|
+
vertexShader: "\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",
|
|
53
|
+
fragmentShader: "\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n\n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"
|
|
54
|
+
};
|
|
55
|
+
new S(.1, .9), new S(.1, .9);
|
|
56
|
+
var ee = "varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }", te = "uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n\n #include <packing>\n\n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n\n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }", ne = class t extends c {
|
|
57
|
+
static {
|
|
58
|
+
this._linearDepthShader = {
|
|
59
|
+
uniforms: {
|
|
60
|
+
tDepth: { value: null },
|
|
61
|
+
depthFilter: { value: new e(1, 0, 0, 0) },
|
|
62
|
+
cameraNear: { value: .1 },
|
|
63
|
+
cameraFar: { value: 1 }
|
|
64
|
+
},
|
|
65
|
+
defines: {
|
|
66
|
+
PERSPECTIVE_CAMERA: 1,
|
|
67
|
+
ALPHA_DEPTH: 0
|
|
68
|
+
},
|
|
69
|
+
vertexShader: ee,
|
|
70
|
+
fragmentShader: te
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
constructor(e) {
|
|
74
|
+
super({
|
|
75
|
+
defines: Object.assign({}, t._linearDepthShader.defines),
|
|
76
|
+
uniforms: p.clone(t._linearDepthShader.uniforms),
|
|
77
|
+
vertexShader: t._linearDepthShader.vertexShader,
|
|
78
|
+
fragmentShader: t._linearDepthShader.fragmentShader,
|
|
79
|
+
blending: 0
|
|
80
|
+
}), this.update(e);
|
|
81
|
+
}
|
|
82
|
+
update(e) {
|
|
83
|
+
if (e?.depthTexture !== void 0 && (this.uniforms.tDepth.value = e?.depthTexture), e?.camera !== void 0) {
|
|
84
|
+
let t = e?.camera || e?.camera;
|
|
85
|
+
this.uniforms.cameraNear.value = t.near, this.uniforms.cameraFar.value = t.far;
|
|
86
|
+
}
|
|
87
|
+
return e?.depthFilter !== void 0 && (this.uniforms.depthFilter.value = e?.depthFilter), this;
|
|
88
|
+
}
|
|
89
|
+
}, re = class {
|
|
90
|
+
constructor() {
|
|
91
|
+
this.isPass = !0, this.enabled = !0, this.needsSwap = !0, this.clear = !1, this.renderToScreen = !1;
|
|
92
|
+
}
|
|
93
|
+
setSize() {}
|
|
94
|
+
render() {
|
|
95
|
+
console.error("THREE.Pass: .render() must be implemented in derived pass.");
|
|
96
|
+
}
|
|
97
|
+
dispose() {}
|
|
98
|
+
}, L = new n(-1, 1, 1, -1, 0, 1), R = new class extends m {
|
|
99
|
+
constructor() {
|
|
100
|
+
super(), this.setAttribute("position", new b([
|
|
101
|
+
-1,
|
|
102
|
+
3,
|
|
103
|
+
0,
|
|
104
|
+
-1,
|
|
105
|
+
-1,
|
|
106
|
+
0,
|
|
107
|
+
3,
|
|
108
|
+
-1,
|
|
109
|
+
0
|
|
110
|
+
], 3)), this.setAttribute("uv", new b([
|
|
111
|
+
0,
|
|
112
|
+
2,
|
|
113
|
+
0,
|
|
114
|
+
0,
|
|
115
|
+
2,
|
|
116
|
+
0
|
|
117
|
+
], 2));
|
|
118
|
+
}
|
|
119
|
+
}(), z = class {
|
|
120
|
+
constructor(e) {
|
|
121
|
+
this._mesh = new d(R, e);
|
|
122
|
+
}
|
|
123
|
+
dispose() {
|
|
124
|
+
this._mesh.geometry.dispose();
|
|
125
|
+
}
|
|
126
|
+
render(e) {
|
|
127
|
+
e.render(this._mesh, L);
|
|
128
|
+
}
|
|
129
|
+
get material() {
|
|
130
|
+
return this._mesh.material;
|
|
131
|
+
}
|
|
132
|
+
set material(e) {
|
|
133
|
+
this._mesh.material = e;
|
|
134
|
+
}
|
|
135
|
+
}, B = class {
|
|
136
|
+
constructor(e = Math) {
|
|
137
|
+
this.grad3 = [
|
|
138
|
+
[
|
|
139
|
+
1,
|
|
140
|
+
1,
|
|
141
|
+
0
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
-1,
|
|
145
|
+
1,
|
|
146
|
+
0
|
|
147
|
+
],
|
|
148
|
+
[
|
|
149
|
+
1,
|
|
150
|
+
-1,
|
|
151
|
+
0
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
-1,
|
|
155
|
+
-1,
|
|
156
|
+
0
|
|
157
|
+
],
|
|
158
|
+
[
|
|
159
|
+
1,
|
|
160
|
+
0,
|
|
161
|
+
1
|
|
162
|
+
],
|
|
163
|
+
[
|
|
164
|
+
-1,
|
|
165
|
+
0,
|
|
166
|
+
1
|
|
167
|
+
],
|
|
168
|
+
[
|
|
169
|
+
1,
|
|
170
|
+
0,
|
|
171
|
+
-1
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
-1,
|
|
175
|
+
0,
|
|
176
|
+
-1
|
|
177
|
+
],
|
|
178
|
+
[
|
|
179
|
+
0,
|
|
180
|
+
1,
|
|
181
|
+
1
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
0,
|
|
185
|
+
-1,
|
|
186
|
+
1
|
|
187
|
+
],
|
|
188
|
+
[
|
|
189
|
+
0,
|
|
190
|
+
1,
|
|
191
|
+
-1
|
|
192
|
+
],
|
|
193
|
+
[
|
|
194
|
+
0,
|
|
195
|
+
-1,
|
|
196
|
+
-1
|
|
197
|
+
]
|
|
198
|
+
], this.grad4 = [
|
|
199
|
+
[
|
|
200
|
+
0,
|
|
201
|
+
1,
|
|
202
|
+
1,
|
|
203
|
+
1
|
|
204
|
+
],
|
|
205
|
+
[
|
|
206
|
+
0,
|
|
207
|
+
1,
|
|
208
|
+
1,
|
|
209
|
+
-1
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
0,
|
|
213
|
+
1,
|
|
214
|
+
-1,
|
|
215
|
+
1
|
|
216
|
+
],
|
|
217
|
+
[
|
|
218
|
+
0,
|
|
219
|
+
1,
|
|
220
|
+
-1,
|
|
221
|
+
-1
|
|
222
|
+
],
|
|
223
|
+
[
|
|
224
|
+
0,
|
|
225
|
+
-1,
|
|
226
|
+
1,
|
|
227
|
+
1
|
|
228
|
+
],
|
|
229
|
+
[
|
|
230
|
+
0,
|
|
231
|
+
-1,
|
|
232
|
+
1,
|
|
233
|
+
-1
|
|
234
|
+
],
|
|
235
|
+
[
|
|
236
|
+
0,
|
|
237
|
+
-1,
|
|
238
|
+
-1,
|
|
239
|
+
1
|
|
240
|
+
],
|
|
241
|
+
[
|
|
242
|
+
0,
|
|
243
|
+
-1,
|
|
244
|
+
-1,
|
|
245
|
+
-1
|
|
246
|
+
],
|
|
247
|
+
[
|
|
248
|
+
1,
|
|
249
|
+
0,
|
|
250
|
+
1,
|
|
251
|
+
1
|
|
252
|
+
],
|
|
253
|
+
[
|
|
254
|
+
1,
|
|
255
|
+
0,
|
|
256
|
+
1,
|
|
257
|
+
-1
|
|
258
|
+
],
|
|
259
|
+
[
|
|
260
|
+
1,
|
|
261
|
+
0,
|
|
262
|
+
-1,
|
|
263
|
+
1
|
|
264
|
+
],
|
|
265
|
+
[
|
|
266
|
+
1,
|
|
267
|
+
0,
|
|
268
|
+
-1,
|
|
269
|
+
-1
|
|
270
|
+
],
|
|
271
|
+
[
|
|
272
|
+
-1,
|
|
273
|
+
0,
|
|
274
|
+
1,
|
|
275
|
+
1
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
-1,
|
|
279
|
+
0,
|
|
280
|
+
1,
|
|
281
|
+
-1
|
|
282
|
+
],
|
|
283
|
+
[
|
|
284
|
+
-1,
|
|
285
|
+
0,
|
|
286
|
+
-1,
|
|
287
|
+
1
|
|
288
|
+
],
|
|
289
|
+
[
|
|
290
|
+
-1,
|
|
291
|
+
0,
|
|
292
|
+
-1,
|
|
293
|
+
-1
|
|
294
|
+
],
|
|
295
|
+
[
|
|
296
|
+
1,
|
|
297
|
+
1,
|
|
298
|
+
0,
|
|
299
|
+
1
|
|
300
|
+
],
|
|
301
|
+
[
|
|
302
|
+
1,
|
|
303
|
+
1,
|
|
304
|
+
0,
|
|
305
|
+
-1
|
|
306
|
+
],
|
|
307
|
+
[
|
|
308
|
+
1,
|
|
309
|
+
-1,
|
|
310
|
+
0,
|
|
311
|
+
1
|
|
312
|
+
],
|
|
313
|
+
[
|
|
314
|
+
1,
|
|
315
|
+
-1,
|
|
316
|
+
0,
|
|
317
|
+
-1
|
|
318
|
+
],
|
|
319
|
+
[
|
|
320
|
+
-1,
|
|
321
|
+
1,
|
|
322
|
+
0,
|
|
323
|
+
1
|
|
324
|
+
],
|
|
325
|
+
[
|
|
326
|
+
-1,
|
|
327
|
+
1,
|
|
328
|
+
0,
|
|
329
|
+
-1
|
|
330
|
+
],
|
|
331
|
+
[
|
|
332
|
+
-1,
|
|
333
|
+
-1,
|
|
334
|
+
0,
|
|
335
|
+
1
|
|
336
|
+
],
|
|
337
|
+
[
|
|
338
|
+
-1,
|
|
339
|
+
-1,
|
|
340
|
+
0,
|
|
341
|
+
-1
|
|
342
|
+
],
|
|
343
|
+
[
|
|
344
|
+
1,
|
|
345
|
+
1,
|
|
346
|
+
1,
|
|
347
|
+
0
|
|
348
|
+
],
|
|
349
|
+
[
|
|
350
|
+
1,
|
|
351
|
+
1,
|
|
352
|
+
-1,
|
|
353
|
+
0
|
|
354
|
+
],
|
|
355
|
+
[
|
|
356
|
+
1,
|
|
357
|
+
-1,
|
|
358
|
+
1,
|
|
359
|
+
0
|
|
360
|
+
],
|
|
361
|
+
[
|
|
362
|
+
1,
|
|
363
|
+
-1,
|
|
364
|
+
-1,
|
|
365
|
+
0
|
|
366
|
+
],
|
|
367
|
+
[
|
|
368
|
+
-1,
|
|
369
|
+
1,
|
|
370
|
+
1,
|
|
371
|
+
0
|
|
372
|
+
],
|
|
373
|
+
[
|
|
374
|
+
-1,
|
|
375
|
+
1,
|
|
376
|
+
-1,
|
|
377
|
+
0
|
|
378
|
+
],
|
|
379
|
+
[
|
|
380
|
+
-1,
|
|
381
|
+
-1,
|
|
382
|
+
1,
|
|
383
|
+
0
|
|
384
|
+
],
|
|
385
|
+
[
|
|
386
|
+
-1,
|
|
387
|
+
-1,
|
|
388
|
+
-1,
|
|
389
|
+
0
|
|
390
|
+
]
|
|
391
|
+
], this.p = [];
|
|
392
|
+
for (let t = 0; t < 256; t++) this.p[t] = Math.floor(e.random() * 256);
|
|
393
|
+
this.perm = [];
|
|
394
|
+
for (let e = 0; e < 512; e++) this.perm[e] = this.p[e & 255];
|
|
395
|
+
this.simplex = [
|
|
396
|
+
[
|
|
397
|
+
0,
|
|
398
|
+
1,
|
|
399
|
+
2,
|
|
400
|
+
3
|
|
401
|
+
],
|
|
402
|
+
[
|
|
403
|
+
0,
|
|
404
|
+
1,
|
|
405
|
+
3,
|
|
406
|
+
2
|
|
407
|
+
],
|
|
408
|
+
[
|
|
409
|
+
0,
|
|
410
|
+
0,
|
|
411
|
+
0,
|
|
412
|
+
0
|
|
413
|
+
],
|
|
414
|
+
[
|
|
415
|
+
0,
|
|
416
|
+
2,
|
|
417
|
+
3,
|
|
418
|
+
1
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
0,
|
|
422
|
+
0,
|
|
423
|
+
0,
|
|
424
|
+
0
|
|
425
|
+
],
|
|
426
|
+
[
|
|
427
|
+
0,
|
|
428
|
+
0,
|
|
429
|
+
0,
|
|
430
|
+
0
|
|
431
|
+
],
|
|
432
|
+
[
|
|
433
|
+
0,
|
|
434
|
+
0,
|
|
435
|
+
0,
|
|
436
|
+
0
|
|
437
|
+
],
|
|
438
|
+
[
|
|
439
|
+
1,
|
|
440
|
+
2,
|
|
441
|
+
3,
|
|
442
|
+
0
|
|
443
|
+
],
|
|
444
|
+
[
|
|
445
|
+
0,
|
|
446
|
+
2,
|
|
447
|
+
1,
|
|
448
|
+
3
|
|
449
|
+
],
|
|
450
|
+
[
|
|
451
|
+
0,
|
|
452
|
+
0,
|
|
453
|
+
0,
|
|
454
|
+
0
|
|
455
|
+
],
|
|
456
|
+
[
|
|
457
|
+
0,
|
|
458
|
+
3,
|
|
459
|
+
1,
|
|
460
|
+
2
|
|
461
|
+
],
|
|
462
|
+
[
|
|
463
|
+
0,
|
|
464
|
+
3,
|
|
465
|
+
2,
|
|
466
|
+
1
|
|
467
|
+
],
|
|
468
|
+
[
|
|
469
|
+
0,
|
|
470
|
+
0,
|
|
471
|
+
0,
|
|
472
|
+
0
|
|
473
|
+
],
|
|
474
|
+
[
|
|
475
|
+
0,
|
|
476
|
+
0,
|
|
477
|
+
0,
|
|
478
|
+
0
|
|
479
|
+
],
|
|
480
|
+
[
|
|
481
|
+
0,
|
|
482
|
+
0,
|
|
483
|
+
0,
|
|
484
|
+
0
|
|
485
|
+
],
|
|
486
|
+
[
|
|
487
|
+
1,
|
|
488
|
+
3,
|
|
489
|
+
2,
|
|
490
|
+
0
|
|
491
|
+
],
|
|
492
|
+
[
|
|
493
|
+
0,
|
|
494
|
+
0,
|
|
495
|
+
0,
|
|
496
|
+
0
|
|
497
|
+
],
|
|
498
|
+
[
|
|
499
|
+
0,
|
|
500
|
+
0,
|
|
501
|
+
0,
|
|
502
|
+
0
|
|
503
|
+
],
|
|
504
|
+
[
|
|
505
|
+
0,
|
|
506
|
+
0,
|
|
507
|
+
0,
|
|
508
|
+
0
|
|
509
|
+
],
|
|
510
|
+
[
|
|
511
|
+
0,
|
|
512
|
+
0,
|
|
513
|
+
0,
|
|
514
|
+
0
|
|
515
|
+
],
|
|
516
|
+
[
|
|
517
|
+
0,
|
|
518
|
+
0,
|
|
519
|
+
0,
|
|
520
|
+
0
|
|
521
|
+
],
|
|
522
|
+
[
|
|
523
|
+
0,
|
|
524
|
+
0,
|
|
525
|
+
0,
|
|
526
|
+
0
|
|
527
|
+
],
|
|
528
|
+
[
|
|
529
|
+
0,
|
|
530
|
+
0,
|
|
531
|
+
0,
|
|
532
|
+
0
|
|
533
|
+
],
|
|
534
|
+
[
|
|
535
|
+
0,
|
|
536
|
+
0,
|
|
537
|
+
0,
|
|
538
|
+
0
|
|
539
|
+
],
|
|
540
|
+
[
|
|
541
|
+
1,
|
|
542
|
+
2,
|
|
543
|
+
0,
|
|
544
|
+
3
|
|
545
|
+
],
|
|
546
|
+
[
|
|
547
|
+
0,
|
|
548
|
+
0,
|
|
549
|
+
0,
|
|
550
|
+
0
|
|
551
|
+
],
|
|
552
|
+
[
|
|
553
|
+
1,
|
|
554
|
+
3,
|
|
555
|
+
0,
|
|
556
|
+
2
|
|
557
|
+
],
|
|
558
|
+
[
|
|
559
|
+
0,
|
|
560
|
+
0,
|
|
561
|
+
0,
|
|
562
|
+
0
|
|
563
|
+
],
|
|
564
|
+
[
|
|
565
|
+
0,
|
|
566
|
+
0,
|
|
567
|
+
0,
|
|
568
|
+
0
|
|
569
|
+
],
|
|
570
|
+
[
|
|
571
|
+
0,
|
|
572
|
+
0,
|
|
573
|
+
0,
|
|
574
|
+
0
|
|
575
|
+
],
|
|
576
|
+
[
|
|
577
|
+
2,
|
|
578
|
+
3,
|
|
579
|
+
0,
|
|
580
|
+
1
|
|
581
|
+
],
|
|
582
|
+
[
|
|
583
|
+
2,
|
|
584
|
+
3,
|
|
585
|
+
1,
|
|
586
|
+
0
|
|
587
|
+
],
|
|
588
|
+
[
|
|
589
|
+
1,
|
|
590
|
+
0,
|
|
591
|
+
2,
|
|
592
|
+
3
|
|
593
|
+
],
|
|
594
|
+
[
|
|
595
|
+
1,
|
|
596
|
+
0,
|
|
597
|
+
3,
|
|
598
|
+
2
|
|
599
|
+
],
|
|
600
|
+
[
|
|
601
|
+
0,
|
|
602
|
+
0,
|
|
603
|
+
0,
|
|
604
|
+
0
|
|
605
|
+
],
|
|
606
|
+
[
|
|
607
|
+
0,
|
|
608
|
+
0,
|
|
609
|
+
0,
|
|
610
|
+
0
|
|
611
|
+
],
|
|
612
|
+
[
|
|
613
|
+
0,
|
|
614
|
+
0,
|
|
615
|
+
0,
|
|
616
|
+
0
|
|
617
|
+
],
|
|
618
|
+
[
|
|
619
|
+
2,
|
|
620
|
+
0,
|
|
621
|
+
3,
|
|
622
|
+
1
|
|
623
|
+
],
|
|
624
|
+
[
|
|
625
|
+
0,
|
|
626
|
+
0,
|
|
627
|
+
0,
|
|
628
|
+
0
|
|
629
|
+
],
|
|
630
|
+
[
|
|
631
|
+
2,
|
|
632
|
+
1,
|
|
633
|
+
3,
|
|
634
|
+
0
|
|
635
|
+
],
|
|
636
|
+
[
|
|
637
|
+
0,
|
|
638
|
+
0,
|
|
639
|
+
0,
|
|
640
|
+
0
|
|
641
|
+
],
|
|
642
|
+
[
|
|
643
|
+
0,
|
|
644
|
+
0,
|
|
645
|
+
0,
|
|
646
|
+
0
|
|
647
|
+
],
|
|
648
|
+
[
|
|
649
|
+
0,
|
|
650
|
+
0,
|
|
651
|
+
0,
|
|
652
|
+
0
|
|
653
|
+
],
|
|
654
|
+
[
|
|
655
|
+
0,
|
|
656
|
+
0,
|
|
657
|
+
0,
|
|
658
|
+
0
|
|
659
|
+
],
|
|
660
|
+
[
|
|
661
|
+
0,
|
|
662
|
+
0,
|
|
663
|
+
0,
|
|
664
|
+
0
|
|
665
|
+
],
|
|
666
|
+
[
|
|
667
|
+
0,
|
|
668
|
+
0,
|
|
669
|
+
0,
|
|
670
|
+
0
|
|
671
|
+
],
|
|
672
|
+
[
|
|
673
|
+
0,
|
|
674
|
+
0,
|
|
675
|
+
0,
|
|
676
|
+
0
|
|
677
|
+
],
|
|
678
|
+
[
|
|
679
|
+
0,
|
|
680
|
+
0,
|
|
681
|
+
0,
|
|
682
|
+
0
|
|
683
|
+
],
|
|
684
|
+
[
|
|
685
|
+
2,
|
|
686
|
+
0,
|
|
687
|
+
1,
|
|
688
|
+
3
|
|
689
|
+
],
|
|
690
|
+
[
|
|
691
|
+
0,
|
|
692
|
+
0,
|
|
693
|
+
0,
|
|
694
|
+
0
|
|
695
|
+
],
|
|
696
|
+
[
|
|
697
|
+
0,
|
|
698
|
+
0,
|
|
699
|
+
0,
|
|
700
|
+
0
|
|
701
|
+
],
|
|
702
|
+
[
|
|
703
|
+
0,
|
|
704
|
+
0,
|
|
705
|
+
0,
|
|
706
|
+
0
|
|
707
|
+
],
|
|
708
|
+
[
|
|
709
|
+
3,
|
|
710
|
+
0,
|
|
711
|
+
1,
|
|
712
|
+
2
|
|
713
|
+
],
|
|
714
|
+
[
|
|
715
|
+
3,
|
|
716
|
+
0,
|
|
717
|
+
2,
|
|
718
|
+
1
|
|
719
|
+
],
|
|
720
|
+
[
|
|
721
|
+
0,
|
|
722
|
+
0,
|
|
723
|
+
0,
|
|
724
|
+
0
|
|
725
|
+
],
|
|
726
|
+
[
|
|
727
|
+
3,
|
|
728
|
+
1,
|
|
729
|
+
2,
|
|
730
|
+
0
|
|
731
|
+
],
|
|
732
|
+
[
|
|
733
|
+
2,
|
|
734
|
+
1,
|
|
735
|
+
0,
|
|
736
|
+
3
|
|
737
|
+
],
|
|
738
|
+
[
|
|
739
|
+
0,
|
|
740
|
+
0,
|
|
741
|
+
0,
|
|
742
|
+
0
|
|
743
|
+
],
|
|
744
|
+
[
|
|
745
|
+
0,
|
|
746
|
+
0,
|
|
747
|
+
0,
|
|
748
|
+
0
|
|
749
|
+
],
|
|
750
|
+
[
|
|
751
|
+
0,
|
|
752
|
+
0,
|
|
753
|
+
0,
|
|
754
|
+
0
|
|
755
|
+
],
|
|
756
|
+
[
|
|
757
|
+
3,
|
|
758
|
+
1,
|
|
759
|
+
0,
|
|
760
|
+
2
|
|
761
|
+
],
|
|
762
|
+
[
|
|
763
|
+
0,
|
|
764
|
+
0,
|
|
765
|
+
0,
|
|
766
|
+
0
|
|
767
|
+
],
|
|
768
|
+
[
|
|
769
|
+
3,
|
|
770
|
+
2,
|
|
771
|
+
0,
|
|
772
|
+
1
|
|
773
|
+
],
|
|
774
|
+
[
|
|
775
|
+
3,
|
|
776
|
+
2,
|
|
777
|
+
1,
|
|
778
|
+
0
|
|
779
|
+
]
|
|
780
|
+
];
|
|
781
|
+
}
|
|
782
|
+
noise(e, t) {
|
|
783
|
+
let n, r, i, a = .5 * (Math.sqrt(3) - 1), o = (e + t) * a, s = Math.floor(e + o), c = Math.floor(t + o), l = (3 - Math.sqrt(3)) / 6, u = (s + c) * l, d = s - u, f = c - u, p = e - d, m = t - f, h, g;
|
|
784
|
+
p > m ? (h = 1, g = 0) : (h = 0, g = 1);
|
|
785
|
+
let _ = p - h + l, v = m - g + l, y = p - 1 + 2 * l, b = m - 1 + 2 * l, x = s & 255, S = c & 255, C = this.perm[x + this.perm[S]] % 12, w = this.perm[x + h + this.perm[S + g]] % 12, T = this.perm[x + 1 + this.perm[S + 1]] % 12, E = .5 - p * p - m * m;
|
|
786
|
+
E < 0 ? n = 0 : (E *= E, n = E * E * this._dot(this.grad3[C], p, m));
|
|
787
|
+
let D = .5 - _ * _ - v * v;
|
|
788
|
+
D < 0 ? r = 0 : (D *= D, r = D * D * this._dot(this.grad3[w], _, v));
|
|
789
|
+
let O = .5 - y * y - b * b;
|
|
790
|
+
return O < 0 ? i = 0 : (O *= O, i = O * O * this._dot(this.grad3[T], y, b)), 70 * (n + r + i);
|
|
791
|
+
}
|
|
792
|
+
noise3d(e, t, n) {
|
|
793
|
+
let r, i, a, o, s = (e + t + n) * (1 / 3), c = Math.floor(e + s), l = Math.floor(t + s), u = Math.floor(n + s), d = 1 / 6, f = (c + l + u) * d, p = c - f, m = l - f, h = u - f, g = e - p, _ = t - m, v = n - h, y, b, x, S, C, w;
|
|
794
|
+
g >= _ ? _ >= v ? (y = 1, b = 0, x = 0, S = 1, C = 1, w = 0) : g >= v ? (y = 1, b = 0, x = 0, S = 1, C = 0, w = 1) : (y = 0, b = 0, x = 1, S = 1, C = 0, w = 1) : _ < v ? (y = 0, b = 0, x = 1, S = 0, C = 1, w = 1) : g < v ? (y = 0, b = 1, x = 0, S = 0, C = 1, w = 1) : (y = 0, b = 1, x = 0, S = 1, C = 1, w = 0);
|
|
795
|
+
let T = g - y + d, E = _ - b + d, D = v - x + d, O = g - S + 2 * d, k = _ - C + 2 * d, A = v - w + 2 * d, j = g - 1 + 3 * d, M = _ - 1 + 3 * d, N = v - 1 + 3 * d, P = c & 255, F = l & 255, I = u & 255, ee = this.perm[P + this.perm[F + this.perm[I]]] % 12, te = this.perm[P + y + this.perm[F + b + this.perm[I + x]]] % 12, ne = this.perm[P + S + this.perm[F + C + this.perm[I + w]]] % 12, re = this.perm[P + 1 + this.perm[F + 1 + this.perm[I + 1]]] % 12, L = .6 - g * g - _ * _ - v * v;
|
|
796
|
+
L < 0 ? r = 0 : (L *= L, r = L * L * this._dot3(this.grad3[ee], g, _, v));
|
|
797
|
+
let R = .6 - T * T - E * E - D * D;
|
|
798
|
+
R < 0 ? i = 0 : (R *= R, i = R * R * this._dot3(this.grad3[te], T, E, D));
|
|
799
|
+
let z = .6 - O * O - k * k - A * A;
|
|
800
|
+
z < 0 ? a = 0 : (z *= z, a = z * z * this._dot3(this.grad3[ne], O, k, A));
|
|
801
|
+
let B = .6 - j * j - M * M - N * N;
|
|
802
|
+
return B < 0 ? o = 0 : (B *= B, o = B * B * this._dot3(this.grad3[re], j, M, N)), 32 * (r + i + a + o);
|
|
803
|
+
}
|
|
804
|
+
noise4d(e, t, n, r) {
|
|
805
|
+
let i = this.grad4, a = this.simplex, o = this.perm, s = (Math.sqrt(5) - 1) / 4, c = (5 - Math.sqrt(5)) / 20, l, u, d, f, p, m = (e + t + n + r) * s, h = Math.floor(e + m), g = Math.floor(t + m), _ = Math.floor(n + m), v = Math.floor(r + m), y = (h + g + _ + v) * c, b = h - y, x = g - y, S = _ - y, C = v - y, w = e - b, T = t - x, E = n - S, D = r - C, O = w > T ? 32 : 0, k = w > E ? 16 : 0, A = T > E ? 8 : 0, j = w > D ? 4 : 0, M = T > D ? 2 : 0, N = E > D ? 1 : 0, P = O + k + A + j + M + N, F = a[P][0] >= 3 ? 1 : 0, I = a[P][1] >= 3 ? 1 : 0, ee = a[P][2] >= 3 ? 1 : 0, te = a[P][3] >= 3 ? 1 : 0, ne = a[P][0] >= 2 ? 1 : 0, re = a[P][1] >= 2 ? 1 : 0, L = a[P][2] >= 2 ? 1 : 0, R = a[P][3] >= 2 ? 1 : 0, z = a[P][0] >= 1 ? 1 : 0, B = a[P][1] >= 1 ? 1 : 0, ie = a[P][2] >= 1 ? 1 : 0, ae = a[P][3] >= 1 ? 1 : 0, oe = w - F + c, se = T - I + c, ce = E - ee + c, le = D - te + c, V = w - ne + 2 * c, ue = T - re + 2 * c, H = E - L + 2 * c, U = D - R + 2 * c, W = w - z + 3 * c, G = T - B + 3 * c, de = E - ie + 3 * c, K = D - ae + 3 * c, q = w - 1 + 4 * c, fe = T - 1 + 4 * c, J = E - 1 + 4 * c, pe = D - 1 + 4 * c, Y = h & 255, X = g & 255, Z = _ & 255, Q = v & 255, me = o[Y + o[X + o[Z + o[Q]]]] % 32, he = o[Y + F + o[X + I + o[Z + ee + o[Q + te]]]] % 32, ge = o[Y + ne + o[X + re + o[Z + L + o[Q + R]]]] % 32, _e = o[Y + z + o[X + B + o[Z + ie + o[Q + ae]]]] % 32, ve = o[Y + 1 + o[X + 1 + o[Z + 1 + o[Q + 1]]]] % 32, $ = .6 - w * w - T * T - E * E - D * D;
|
|
806
|
+
$ < 0 ? l = 0 : ($ *= $, l = $ * $ * this._dot4(i[me], w, T, E, D));
|
|
807
|
+
let ye = .6 - oe * oe - se * se - ce * ce - le * le;
|
|
808
|
+
ye < 0 ? u = 0 : (ye *= ye, u = ye * ye * this._dot4(i[he], oe, se, ce, le));
|
|
809
|
+
let be = .6 - V * V - ue * ue - H * H - U * U;
|
|
810
|
+
be < 0 ? d = 0 : (be *= be, d = be * be * this._dot4(i[ge], V, ue, H, U));
|
|
811
|
+
let xe = .6 - W * W - G * G - de * de - K * K;
|
|
812
|
+
xe < 0 ? f = 0 : (xe *= xe, f = xe * xe * this._dot4(i[_e], W, G, de, K));
|
|
813
|
+
let Se = .6 - q * q - fe * fe - J * J - pe * pe;
|
|
814
|
+
return Se < 0 ? p = 0 : (Se *= Se, p = Se * Se * this._dot4(i[ve], q, fe, J, pe)), 27 * (l + u + d + f + p);
|
|
815
|
+
}
|
|
816
|
+
_dot(e, t, n) {
|
|
817
|
+
return e[0] * t + e[1] * n;
|
|
818
|
+
}
|
|
819
|
+
_dot3(e, t, n, r) {
|
|
820
|
+
return e[0] * t + e[1] * n + e[2] * r;
|
|
821
|
+
}
|
|
822
|
+
_dot4(e, t, n, r, i) {
|
|
823
|
+
return e[0] * t + e[1] * n + e[2] * r + e[3] * i;
|
|
824
|
+
}
|
|
825
|
+
}, ie = (e, t) => {
|
|
826
|
+
e.left = t.min.x, e.right = t.max.x, e.bottom = t.min.y, e.top = t.max.y, e.near = Math.min(-t.min.z, -t.max.z), e.far = Math.max(-t.min.z, -t.max.z), e.updateProjectionMatrix();
|
|
827
|
+
}, ae = (e, t) => {
|
|
828
|
+
let n = Math.min(-t.min.z, -t.max.z), r = Math.max(-t.min.z, -t.max.z);
|
|
829
|
+
if (n < .001) return;
|
|
830
|
+
let i = Math.max(Math.abs(t.min.x), Math.abs(t.max.x)), a = Math.max(Math.abs(t.min.y), Math.abs(t.max.y));
|
|
831
|
+
e.aspect = i / a, e.fov = h.radToDeg(Math.atan2(a, n) * 2), e.near = n, e.far = r, e.updateProjectionMatrix();
|
|
832
|
+
}, oe = class {
|
|
833
|
+
constructor() {
|
|
834
|
+
this.bounds = new f(new s(-1, -1, -1), new s(1, 1, 1)), this.size = new s(2, 2, 2), this.center = new s(0, 0, 0), this.maxSceneDistanceFromCenter = Math.sqrt(3), this.maxSceneDistanceFrom0 = Math.sqrt(3);
|
|
835
|
+
}
|
|
836
|
+
updateFromBox(e) {
|
|
837
|
+
this.bounds !== e && this.bounds.copy(e), this.bounds.getSize(this.size), this.bounds.getCenter(this.center), this.maxSceneDistanceFromCenter = this.size.length() / 2, this.maxSceneDistanceFrom0 = new s(Math.max(Math.abs(this.bounds.min.x), Math.abs(this.bounds.max.x)), Math.max(Math.abs(this.bounds.min.y), Math.abs(this.bounds.max.y)), Math.max(Math.abs(this.bounds.min.z), Math.abs(this.bounds.max.z))).length();
|
|
838
|
+
}
|
|
839
|
+
updateCameraViewVolumeFromBounds(e) {
|
|
840
|
+
e.updateMatrixWorld();
|
|
841
|
+
let t = this.bounds.clone().applyMatrix4(e.matrixWorldInverse);
|
|
842
|
+
e instanceof n ? ie(e, t) : e instanceof o && ae(e, t);
|
|
843
|
+
}
|
|
844
|
+
getNearAndFarForPerspectiveCamera(e, t = 1) {
|
|
845
|
+
let n = e.clone().sub(this.center).length();
|
|
846
|
+
return [Math.max(.01, n - this.maxSceneDistanceFromCenter - .01), n + this.maxSceneDistanceFromCenter * t + .01];
|
|
847
|
+
}
|
|
848
|
+
}, se = class {
|
|
849
|
+
changed(e) {
|
|
850
|
+
let t = !this._lastCameraProjection?.equals(e.projectionMatrix) || !this._lastCameraWorld?.equals(e.matrixWorld);
|
|
851
|
+
return this._lastCameraProjection = e.projectionMatrix?.clone(), this._lastCameraWorld = e.matrixWorld?.clone(), t;
|
|
852
|
+
}
|
|
853
|
+
}, ce = (e) => {
|
|
854
|
+
let t = Math.floor(e) % 2 == 0 ? Math.floor(e) + 1 : Math.floor(e), n = t * t, r = Array(n).fill(0), i = Math.floor(t / 2), a = t - 1;
|
|
855
|
+
for (let e = 1; e <= n;) {
|
|
856
|
+
if (i === -1 && a === t ? (a = t - 2, i = 0) : (a === t && (a = 0), i < 0 && (i = t - 1)), r[i * t + a] !== 0) {
|
|
857
|
+
a -= 2, i++;
|
|
858
|
+
continue;
|
|
859
|
+
} else r[i * t + a] = e++;
|
|
860
|
+
a++, i--;
|
|
861
|
+
}
|
|
862
|
+
return r;
|
|
863
|
+
}, le = (e) => {
|
|
864
|
+
let t = new B(), n = Math.floor(e) % 2 == 0 ? Math.floor(e) + 1 : Math.floor(e), r = ce(n), i = r.length, o = new Uint8Array(i * 4);
|
|
865
|
+
for (let n = 0; n < i; ++n) {
|
|
866
|
+
let a = r[n], c = 2 * Math.PI * a / i, l = new s(Math.cos(c), Math.sin(c), 0).normalize();
|
|
867
|
+
o[n * 4] = (l.x * .5 + .5) * 255, o[n * 4 + 1] = (l.y * .5 + .5) * 255, o[n * 4 + 2] = 127, o[n * 4 + 3] = (t.noise(n / e, n % e) * .5 + .5) * 255;
|
|
868
|
+
}
|
|
869
|
+
let c = new l(o, n, n);
|
|
870
|
+
return c.wrapS = a, c.wrapT = a, c.needsUpdate = !0, c;
|
|
871
|
+
}, V = class {
|
|
872
|
+
constructor() {
|
|
873
|
+
this._originalClearColor = new x(), this._originalClearAlpha = 0, this._originalAutoClear = !1, this._originalRenderTarget = null, this._screenSpaceQuad = new z(void 0), this._emptyScene = new i(), this._defaultCamera = new o();
|
|
874
|
+
}
|
|
875
|
+
renderWithOverrideMaterial(e, t, n, r, i, a, o) {
|
|
876
|
+
this._backup(e), this._prepareRenderer(e, i, a, o);
|
|
877
|
+
let s = t.overrideMaterial;
|
|
878
|
+
t.overrideMaterial = r, e.render(t, n), t.overrideMaterial = s, this._restore(e);
|
|
879
|
+
}
|
|
880
|
+
clear(e, t, n, r) {
|
|
881
|
+
this._backup(e), this._prepareRenderer(e, t, n, r), e.render(this._emptyScene, this._defaultCamera), this._restore(e);
|
|
882
|
+
}
|
|
883
|
+
render(e, t, n, r, i, a) {
|
|
884
|
+
this._backup(e), this._prepareRenderer(e, r, i, a), e.render(t, n), this._restore(e);
|
|
885
|
+
}
|
|
886
|
+
renderScreenSpace(e, t, n, r, i) {
|
|
887
|
+
this._backup(e), this._prepareRenderer(e, n, r, i), this._screenSpaceQuad.material = t, this._screenSpaceQuad.render(e), this._restore(e);
|
|
888
|
+
}
|
|
889
|
+
_prepareRenderer(e, t, n, r) {
|
|
890
|
+
e.setRenderTarget(t), e.autoClear = !1, n != null && (e.setClearColor(n), e.setClearAlpha(r || 0), e.clear());
|
|
891
|
+
}
|
|
892
|
+
_backup(e) {
|
|
893
|
+
e.getClearColor(this._originalClearColor), this._originalClearAlpha = e.getClearAlpha(), this._originalAutoClear = e.autoClear, this._originalRenderTarget = e.getRenderTarget();
|
|
894
|
+
}
|
|
895
|
+
_restore(e) {
|
|
896
|
+
e.setClearColor(this._originalClearColor), e.setClearAlpha(this._originalClearAlpha), e.setRenderTarget(this._originalRenderTarget), e.autoClear = this._originalAutoClear;
|
|
897
|
+
}
|
|
898
|
+
}, ue = class {
|
|
899
|
+
constructor(e, t) {
|
|
900
|
+
this._passRenderer = t?.passRenderer ?? new V(), this._blurMaterial = new c(e ?? I), this._blurMaterial.depthTest = !1;
|
|
901
|
+
}
|
|
902
|
+
dispose() {
|
|
903
|
+
this._blurMaterial.dispose();
|
|
904
|
+
}
|
|
905
|
+
render(e, t, n, r) {
|
|
906
|
+
this._blurMaterial.uniforms.tDiffuse.value = t[0].texture, this._blurMaterial.uniforms.rangeMin.value.x = n[0], this._blurMaterial.uniforms.rangeMin.value.y = 0, this._blurMaterial.uniforms.rangeMax.value.x = r[0], this._blurMaterial.uniforms.rangeMax.value.y = 0, this._passRenderer.renderScreenSpace(e, this._blurMaterial, t[1]), this._blurMaterial.uniforms.tDiffuse.value = t[1].texture, this._blurMaterial.uniforms.rangeMin.value.x = 0, this._blurMaterial.uniforms.rangeMin.value.y = n[1], this._blurMaterial.uniforms.rangeMax.value.x = 0, this._blurMaterial.uniforms.rangeMax.value.y = r[1], this._passRenderer.renderScreenSpace(e, this._blurMaterial, t[2]);
|
|
907
|
+
}
|
|
908
|
+
}, H = {
|
|
909
|
+
INPUT_RGB_NORMAL: "inputRgbNormal",
|
|
910
|
+
FLOAT_BUFFER_NORMAL: "floatBufferNormal",
|
|
911
|
+
CONSTANT_Z: "constantZ"
|
|
912
|
+
}, U = {
|
|
913
|
+
SEPARATE_BUFFER: "separateBuffer",
|
|
914
|
+
NORMAL_VECTOR_ALPHA: "normalVectorAlpha"
|
|
915
|
+
}, W = {
|
|
916
|
+
SSAO: 0,
|
|
917
|
+
SAO: 1,
|
|
918
|
+
N8AO: 2,
|
|
919
|
+
HBAO: 3,
|
|
920
|
+
GTAO: 4
|
|
921
|
+
}, G = (e, t) => {
|
|
922
|
+
let n = de(e, t), r = "vec4[SAMPLES](";
|
|
923
|
+
for (let t = 0; t < e; t++) {
|
|
924
|
+
let i = n[t];
|
|
925
|
+
r += `vec4(${i.x}, ${i.y}, ${i.z}, ${i.w})${t < e - 1 ? "," : ")"}`;
|
|
926
|
+
}
|
|
927
|
+
return r;
|
|
928
|
+
}, de = (t, n) => {
|
|
929
|
+
let r = [];
|
|
930
|
+
for (let i = 0; i < t; i++) {
|
|
931
|
+
let a = i * Math.PI * (3 - Math.sqrt(5)), o = .01 + i / (t - 1) * .99, s = n ? Math.sqrt(1 - o * o) : 1 - o, c = Math.cos(a) * s, l = Math.sin(a) * s, u = Math.floor(t / 4), d = 1 - (Math.floor(i / 4) + i % 4 * u) / t;
|
|
932
|
+
d = .1 + .9 * d, r.push(new e(c, l, o, d));
|
|
933
|
+
}
|
|
934
|
+
return r;
|
|
935
|
+
}, K = {
|
|
936
|
+
name: "AOShader",
|
|
937
|
+
defines: {
|
|
938
|
+
PERSPECTIVE_CAMERA: 1,
|
|
939
|
+
SAMPLES: 16,
|
|
940
|
+
SAMPLE_VECTORS: G(16, !1),
|
|
941
|
+
NORMAL_VECTOR_TYPE: 1,
|
|
942
|
+
DEPTH_SWIZZLING: "x",
|
|
943
|
+
AO_ALGORITHM: W.GTAO,
|
|
944
|
+
NV_ALIGNED_SAMPLES: 1,
|
|
945
|
+
SCREEN_SPACE_RADIUS: 0,
|
|
946
|
+
SCREEN_SPACE_RADIUS_SCALE: 100,
|
|
947
|
+
SCENE_CLIP_BOX: 0,
|
|
948
|
+
NORMAL_VECTOR_ANTIALIAS: 2,
|
|
949
|
+
DEPTH_BUFFER_ANTIALIAS: 1
|
|
950
|
+
},
|
|
951
|
+
uniforms: {
|
|
952
|
+
tNormal: { value: null },
|
|
953
|
+
tDepth: { value: null },
|
|
954
|
+
tNoise: { value: null },
|
|
955
|
+
resolution: { value: new S() },
|
|
956
|
+
cameraNear: { value: null },
|
|
957
|
+
cameraFar: { value: null },
|
|
958
|
+
cameraProjectionMatrix: { value: new y() },
|
|
959
|
+
cameraProjectionMatrixInverse: { value: new y() },
|
|
960
|
+
cameraWorldMatrix: { value: new y() },
|
|
961
|
+
radius: { value: 1 },
|
|
962
|
+
distanceExponent: { value: 1 },
|
|
963
|
+
thickness: { value: 1 },
|
|
964
|
+
distanceFallOff: { value: 1 },
|
|
965
|
+
bias: { value: .001 },
|
|
966
|
+
scale: { value: 1 },
|
|
967
|
+
sceneBoxMin: { value: new s(-1, -1, -1) },
|
|
968
|
+
sceneBoxMax: { value: new s(1, 1, 1) }
|
|
969
|
+
},
|
|
970
|
+
vertexShader: "\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",
|
|
971
|
+
fragmentShader: "\n\n varying vec2 vUv;\n uniform highp sampler2D tNormal;\n uniform highp sampler2D tDepth;\n uniform sampler2D tNoise;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraProjectionMatrixInverse;\n uniform mat4 cameraWorldMatrix;\n uniform float radius;\n uniform float distanceExponent;\n uniform float thickness;\n uniform float distanceFallOff;\n uniform float bias;\n uniform float scale;\n #if SCENE_CLIP_BOX == 1\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n #endif\n\n #include <common>\n #include <packing>\n\n #ifndef FRAGMENT_OUTPUT\n #define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n #endif\n\n const vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n }\n\n float getDepth(const vec2 uv) {\n #if DEPTH_BUFFER_ANTIALIAS == 1\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float d0 = texelFetch(tDepth, p, 0).DEPTH_SWIZZLING;\n vec2 depth = vec2(d0, 1.0);\n float d1 = texelFetch(tDepth, p + ivec2(1, 0), 0).DEPTH_SWIZZLING;\n depth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n float d2 = texelFetch(tDepth, p - ivec2(1, 0), 0).DEPTH_SWIZZLING;\n depth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n float d3 = texelFetch(tDepth, p + ivec2(0, 1), 0).DEPTH_SWIZZLING;\n depth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n float d4 = texelFetch(tDepth, p - ivec2(0, 1), 0).DEPTH_SWIZZLING;\n depth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n return depth.x / depth.y;\n #else\n return textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n #endif\n }\n\n float fetchDepth(const ivec2 uv) {\n return texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n }\n\n vec3 getViewNormal(const vec2 uv) {\n #if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n #elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n #else\n return computeNormalFromDepth(uv);\n #endif\n }\n\n vec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n #if NORMAL_VECTOR_TYPE == 2\n #if NORMAL_VECTOR_ANTIALIAS == 1\n vec2 uv = screenPosition;\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n float c0 = texelFetch(tNormal, p, 0).a;\n float l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n float l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n float r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n float r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n float b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n float b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n float t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n float t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n #elif NORMAL_VECTOR_ANTIALIAS == 2\n vec2 size = vec2(textureSize(tNormal, 0));\n ivec2 p = ivec2(screenPosition * size);\n vec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n normalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n normalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n return normalize(normalVector);\n #else\n return texture2D(tNormal, screenPosition).xyz;\n #endif\n #elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, screenPosition, 0.).rgb);\n #else\n return computeNormalFromDepth(screenPosition);\n #endif\n }\n\n vec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n vec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n vec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n float sampleSceneDepth = getDepth(sampleUv);\n return vec3(sampleUv, sampleSceneDepth);\n }\n\n float sinusToPlane(vec3 pointOnPlane, vec3 planeNormal, vec3 point) {\n vec3 delta = point - pointOnPlane;\n float sinV = dot(planeNormal, normalize(delta));\n return sinV;\n }\n\n float getFallOff(float delta, float falloffDistance) {\n float fallOff = smoothstep(0., 1., 1. - distanceFallOff * abs(delta) / falloffDistance);\n return fallOff;\n }\n\n void main() {\n float depth = getDepth(vUv.xy);\n if (depth >= 1.0) {\n discard;\n return;\n }\n vec3 viewPos = getViewPosition(vUv, depth);\n vec3 viewNormal = getAntiAliasedViewNormal(vUv);\n\n float radiusToUse = radius;\n float distanceFalloffToUse = thickness;\n #if SCREEN_SPACE_RADIUS == 1\n float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n radiusToUse *= radiusScale;\n distanceFalloffToUse *= radiusScale;\n #endif\n\n #if SCENE_CLIP_BOX == 1\n vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n if (boxDistance > radiusToUse) {\n discard;\n return;\n }\n #endif\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\n #if NV_ALIGNED_SAMPLES == 1\n vec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n #else\n vec3 tangent = normalize(vec3(randomVec.xy, 0.));\n vec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n mat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n #endif\n\n #if AO_ALGORITHM == 4\n const int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n #elif AO_ALGORITHM == 3\n const int DIRECTIONS = SAMPLES < 16 ? 3 : 5;\n const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n #else\n const int DIRECTIONS = SAMPLES;\n const int STEPS = 1;\n #endif\n\n float ao = 0.0, totalWeight = 0.0;\n for (int i = 0; i < DIRECTIONS; ++i) {\n\n #if AO_ALGORITHM == 4\n float angle = float(i) / float(DIRECTIONS) * PI;\n vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);\n #elif AO_ALGORITHM == 3\n float angle = float(i) / float(DIRECTIONS) * 2. * PI;\n vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);\n #else\n vec4 sampleDir = sampleKernel[i];\n #endif\n sampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n vec3 viewDir = normalize(-viewPos.xyz);\n vec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n vec3 sliceTangent = cross(sliceBitangent, viewDir);\n vec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\n #if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n vec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n #if AO_ALGORITHM == 4\n vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n #else\n vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice));\n #endif\n for (int j = 0; j < STEPS; ++j) {\n vec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n vec3 sampleViewPos = viewPos + sampleViewOffset;\n #else\n vec3 sampleViewPos = viewPos + sampleDir.xyz * radiusToUse * pow(sampleDir.w, distanceExponent);\n #endif\n\n vec3 sampleSceneUvDepth = getSceneUvAndDepth(sampleViewPos);\n vec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n float sceneSampleDist = abs(sampleSceneViewPos.z);\n float sampleDist = abs(sampleViewPos.z);\n\n #if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n // HBAO || GTAO\n vec3 viewDelta = sampleSceneViewPos - viewPos;\n if (abs(viewDelta.z) < thickness) {\n vec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n float sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n cosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\n }\n #if AO_ALGORITHM == 4\n sampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n viewDelta = sampleSceneViewPos - viewPos;\n if (abs(viewDelta.z) < thickness) {\n vec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n float sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n cosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\n }\n #endif\n #elif AO_ALGORITHM == 2\n // N8AO\n float weight = dot(viewNormal, sampleDir.xyz);\n float occlusion = weight * step(sceneSampleDist + bias, sampleDist);\n #elif AO_ALGORITHM == 1\n // SAO\n vec3 viewDelta = sampleSceneViewPos - viewPos;\n float minResolution = 0.; // ?\n float scaledViewDist = length( viewDelta ) / scale;\n float weight = 1.;\n float occlusion = max(0., (dot(viewNormal, viewDelta) - minResolution) / scaledViewDist - bias) / (1. + scaledViewDist * scaledViewDist );\n #else\n // SSAO\n float weight = 1.;\n float occlusion = step(sceneSampleDist + bias, sampleDist);\n #endif\n\n #if AO_ALGORITHM == 4\n }\n // GTAO\n vec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n float nx = dot(normalInSlice, sliceTangent);\n float ny = dot(normalInSlice, viewDir);\n float nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n float nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n float occlusion = nx * nxb + ny * nyb;\n ao += occlusion;\n }\n ao = clamp(ao / float(DIRECTIONS), 0., 1.);\n #elif AO_ALGORITHM == 3\n }\n totalWeight += 1.;\n ao += max(0., cosHorizons.x - max(0., cosHorizons.y));\n }\n ao /= totalWeight + 1. - step(0., totalWeight);\n ao = clamp(1. - ao, 0., 1.);\n #else\n\n float fallOff = getFallOff(sceneSampleDist - sampleDist, distanceFalloffToUse);\n occlusion *= fallOff;\n vec2 diff = (vUv - sampleSceneUvDepth.xy) * resolution;\n occlusion *= step(1., dot(diff, diff));\n vec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n occlusion *= clipRangeCheck.x * clipRangeCheck.y;\n weight *= clipRangeCheck.x * clipRangeCheck.y;\n totalWeight += weight;\n ao += occlusion;\n }\n ao /= totalWeight + 1. - step(0., totalWeight);\n ao = clamp(1. - ao, 0., 1.);\n #endif\n\n #if SCENE_CLIP_BOX == 1\n ao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n #endif\n #if AO_ALGORITHM != 1\n ao = pow(ao, scale);\n #endif\n gl_FragColor = FRAGMENT_OUTPUT;\n }"
|
|
972
|
+
}, q = {
|
|
973
|
+
resolutionScale: 1,
|
|
974
|
+
algorithm: W.SSAO,
|
|
975
|
+
samples: 32,
|
|
976
|
+
radius: .25,
|
|
977
|
+
distanceExponent: 2,
|
|
978
|
+
thickness: .5,
|
|
979
|
+
distanceFallOff: .5,
|
|
980
|
+
scale: 1,
|
|
981
|
+
bias: .01,
|
|
982
|
+
screenSpaceRadius: !1
|
|
983
|
+
}, fe = class {
|
|
984
|
+
get texture() {
|
|
985
|
+
return this._renderTarget ? this._renderTarget?.texture : null;
|
|
986
|
+
}
|
|
987
|
+
constructor(e, t, n, r, i) {
|
|
988
|
+
this.needsUpdate = !0, this.parameters = { ...q }, this._width = 0, this._height = 0, this._samples = 0, this._gBufferAntiAliasing = !1, this._normalVectorSourceType = H.FLOAT_BUFFER_NORMAL, this._depthValueSourceType = U.NORMAL_VECTOR_ALPHA, this._modulateRedChannel = !1, this.depthTexture = null, this.normalTexture = null, this._noiseTexture = null, this._renderTarget = null, this._passRenderer = new V(), this._sceneClipBox = new f(new s(-1, -1, -1), new s(1, 1, 1)), this._sceneScale = 1, this._width = e, this._height = t, this._samples = n, this._gBufferAntiAliasing = r, this._normalVectorSourceType = i?.normalVectorSourceType || H.FLOAT_BUFFER_NORMAL, this._depthValueSourceType = i?.depthValueSourceType || U.NORMAL_VECTOR_ALPHA, this._modulateRedChannel = i?.modulateRedChannel || !1, i?.aoParameters && (this.parameters = i.aoParameters), i && this.updateTextures(i);
|
|
989
|
+
}
|
|
990
|
+
_getNoiseTexture(e = 64) {
|
|
991
|
+
if (!this._noiseTexture) {
|
|
992
|
+
let t = new B(), n = new Uint8Array(e * e * 4);
|
|
993
|
+
for (let r = 0; r < e; r++) for (let i = 0; i < e; i++) {
|
|
994
|
+
let a = r, o = i;
|
|
995
|
+
n[(r * e + i) * 4] = (t.noise(a, o) + 1) * 127.5, n[(r * e + i) * 4 + 1] = (t.noise(a + e, o) + 1) * 127.5, n[(r * e + i) * 4 + 2] = (t.noise(a, o + e) + 1) * 127.5, n[(r * e + i) * 4 + 3] = (t.noise(a + e, o + e) + 1) * 127.5;
|
|
996
|
+
}
|
|
997
|
+
this._noiseTexture = new l(n, e, e, r, _), this._noiseTexture.wrapS = a, this._noiseTexture.wrapT = a, this._noiseTexture.needsUpdate = !0;
|
|
998
|
+
}
|
|
999
|
+
return this._noiseTexture;
|
|
1000
|
+
}
|
|
1001
|
+
_getMaterial(e, t) {
|
|
1002
|
+
let n = t;
|
|
1003
|
+
return this._aoMaterial || (this._aoMaterial = this._newAoMaterial(), n = !0), n && (this._updateShader(this._aoMaterial, e), this._aoMaterial.needsUpdate = !0), this._updateUniforms(this._aoMaterial, e, n), this._aoMaterial;
|
|
1004
|
+
}
|
|
1005
|
+
_newAoMaterial() {
|
|
1006
|
+
let e = new c({
|
|
1007
|
+
defines: Object.assign({}, K.defines),
|
|
1008
|
+
uniforms: p.clone(K.uniforms),
|
|
1009
|
+
vertexShader: K.vertexShader,
|
|
1010
|
+
fragmentShader: K.fragmentShader,
|
|
1011
|
+
depthTest: !1,
|
|
1012
|
+
depthWrite: !1
|
|
1013
|
+
});
|
|
1014
|
+
return this._modulateRedChannel && (e.blending = 5, e.blendEquation = 103, e.blendEquationAlpha = null, e.blendSrc = 201, e.blendSrcAlpha = null, e.blendDst = 201, e.blendDstAlpha = null), e.defines.FRAGMENT_OUTPUT = this._modulateRedChannel ? "vec4(ao, 1., 1., 1.)" : void 0, e.uniforms.tNoise.value = le(5), e;
|
|
1015
|
+
}
|
|
1016
|
+
_updateShader(e, t) {
|
|
1017
|
+
e.defines.PERSPECTIVE_CAMERA = t.isPerspectiveCamera ? 1 : 0, e.defines.SAMPLES = this.parameters.samples, e.defines.SAMPLE_VECTORS = G(this.parameters.samples, this.parameters.algorithm === W.SSAO), e.defines.NORMAL_VECTOR_TYPE = this._normalVectorSourceType === H.FLOAT_BUFFER_NORMAL ? 2 : 1, e.defines.DEPTH_SWIZZLING = this._depthValueSourceType === U.NORMAL_VECTOR_ALPHA ? "a" : "x", e.defines.AO_ALGORITHM = this.parameters.algorithm, e.defines.NV_ALIGNED_SAMPLES = this.parameters.algorithm === W.HBAO || this.parameters.algorithm === W.GTAO ? 0 : 1, e.defines.SCREEN_SPACE_RADIUS = this.parameters.screenSpaceRadius ? 1 : 0, e.defines.SCENE_CLIP_BOX = 1, e.defines.NORMAL_VECTOR_ANTIALIAS = this._gBufferAntiAliasing ? 2 : 0, e.defines.DEPTH_BUFFER_ANTIALIAS = this._gBufferAntiAliasing ? 1 : 0;
|
|
1018
|
+
}
|
|
1019
|
+
_updateUniforms(e, t, n) {
|
|
1020
|
+
let r = this.parameters.screenSpaceRadius ? 1 : this._sceneScale, i = this._depthValueSourceType === U.NORMAL_VECTOR_ALPHA ? this.normalTexture : this.depthTexture;
|
|
1021
|
+
e.uniforms.tNormal.value = this.normalTexture, e.uniforms.tDepth.value = i, e.uniforms.resolution.value.set(this._width, this._height), e.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix), e.uniforms.cameraProjectionMatrixInverse.value.copy(t.projectionMatrixInverse), e.uniforms.cameraWorldMatrix.value.copy(t.matrixWorld);
|
|
1022
|
+
let a = t;
|
|
1023
|
+
e.uniforms.cameraNear.value = a.near, e.uniforms.cameraFar.value = a.far, n && (e.uniforms.radius.value = this.parameters.radius * r, e.uniforms.distanceExponent.value = this.parameters.distanceExponent, e.uniforms.thickness.value = this.parameters.thickness * r, e.uniforms.distanceFallOff.value = this.parameters.distanceFallOff, e.uniforms.scale.value = this.parameters.scale, this._sceneClipBox && (e.uniforms.sceneBoxMin.value.copy(this._sceneClipBox.min), e.uniforms.sceneBoxMax.value.copy(this._sceneClipBox.max)));
|
|
1024
|
+
}
|
|
1025
|
+
_getRenderTargets() {
|
|
1026
|
+
return this._renderTarget ||= new t(this._width, this._height, {
|
|
1027
|
+
samples: this._samples,
|
|
1028
|
+
magFilter: this._samples > 1 ? v : u,
|
|
1029
|
+
minFilter: this._samples > 1 ? v : u
|
|
1030
|
+
}), this._renderTarget;
|
|
1031
|
+
}
|
|
1032
|
+
dispose() {
|
|
1033
|
+
this._noiseTexture?.dispose(), this._aoMaterial?.dispose(), this._renderTarget?.dispose();
|
|
1034
|
+
}
|
|
1035
|
+
setSize(e, t) {
|
|
1036
|
+
this._width = e, this._height = t, this._renderTarget?.setSize(e, t), this.needsUpdate = !0;
|
|
1037
|
+
}
|
|
1038
|
+
updateBounds(e, t) {
|
|
1039
|
+
this._sceneClipBox = new f().copy(e), this._sceneScale = t ?? 1, this.needsUpdate = !0;
|
|
1040
|
+
}
|
|
1041
|
+
updateParameters(e) {
|
|
1042
|
+
for (let t in e) this.parameters.hasOwnProperty(t) && (this.parameters[t] = e[t], this.needsUpdate = !0);
|
|
1043
|
+
}
|
|
1044
|
+
updateTextures(e) {
|
|
1045
|
+
e.depthTexture && (this.depthTexture = e.depthTexture, this.needsUpdate = !0), e.normalTexture && (this.normalTexture = e.normalTexture, this.needsUpdate = !0);
|
|
1046
|
+
}
|
|
1047
|
+
clear(e, t) {
|
|
1048
|
+
this._passRenderer.clear(e, t || this._getRenderTargets(), 16777215, 1);
|
|
1049
|
+
}
|
|
1050
|
+
render(e, t, n, r) {
|
|
1051
|
+
let i = this._getMaterial(t, this.needsUpdate);
|
|
1052
|
+
this.needsUpdate = !1, this._passRenderer.renderScreenSpace(e, i, r || this._getRenderTargets());
|
|
1053
|
+
}
|
|
1054
|
+
}, J = {
|
|
1055
|
+
DEFAULT: "default",
|
|
1056
|
+
BRIGHT: "bright"
|
|
1057
|
+
}, pe = {
|
|
1058
|
+
shadowType: "PCFShadowMap",
|
|
1059
|
+
shAndAoPassParameters: {
|
|
1060
|
+
aoIntensity: .3,
|
|
1061
|
+
shadow: { shadowRadius: .1 },
|
|
1062
|
+
ao: {
|
|
1063
|
+
algorithm: W.SSAO,
|
|
1064
|
+
samples: 32,
|
|
1065
|
+
radius: .02,
|
|
1066
|
+
distanceExponent: 2,
|
|
1067
|
+
thickness: .1,
|
|
1068
|
+
distanceFallOff: 1,
|
|
1069
|
+
bias: .01
|
|
1070
|
+
},
|
|
1071
|
+
poissonDenoise: {
|
|
1072
|
+
iterations: 2,
|
|
1073
|
+
samples: 16,
|
|
1074
|
+
rings: 2.89,
|
|
1075
|
+
radius: 4,
|
|
1076
|
+
radiusExponent: 1.3,
|
|
1077
|
+
depthPhi: 2.5,
|
|
1078
|
+
normalPhi: .5
|
|
1079
|
+
}
|
|
1080
|
+
},
|
|
1081
|
+
groundReflectionParameters: { brightness: .5 }
|
|
1082
|
+
}, Y = (...e) => {
|
|
1083
|
+
if (e.length === 0) return null;
|
|
1084
|
+
if (e.length === 1) return e[0];
|
|
1085
|
+
let t = e[0];
|
|
1086
|
+
for (let n = 1; n < e.length; n++) t = C(t, e[n]);
|
|
1087
|
+
return t;
|
|
1088
|
+
}, X = (e) => e ? { groundReflectionParameters: { enabled: !1 } } : null, Z = (e) => !e || e === J.DEFAULT ? null : e === J.BRIGHT ? pe : null, Q = (e) => Math.max(0, Math.min(1, e)), me = (e) => {
|
|
1089
|
+
let t = {
|
|
1090
|
+
shAndAoPassParameters: {
|
|
1091
|
+
ao: {},
|
|
1092
|
+
shadow: {}
|
|
1093
|
+
},
|
|
1094
|
+
groundReflectionParameters: {},
|
|
1095
|
+
bakedGroundContactShadowParameters: {}
|
|
1096
|
+
};
|
|
1097
|
+
return he(t, e), ge(t, e), _e(t, e), t;
|
|
1098
|
+
}, he = (e, t) => {
|
|
1099
|
+
t.aoIntensity !== void 0 && (e.shAndAoPassParameters.aoIntensity = Q(t.aoIntensity)), t.aoExtent !== void 0 && (e.shAndAoPassParameters.ao.radius = Q(t.aoExtent) * .3, e.shAndAoPassParameters.ao.thickness = .1 + Q(t.aoExtent) * .2);
|
|
1100
|
+
}, ge = (e, t) => {
|
|
1101
|
+
t.shBakedOnGround ? (e.bakedGroundContactShadowParameters.enabled = !0, e.shAndAoPassParameters.shadowIntensity = 0, t.shadowIntensity !== void 0 && (e.bakedGroundContactShadowParameters.opacity = Q(t.shadowIntensity)), t.shadowIntensity !== void 0 && (e.bakedGroundContactShadowParameters.blurMax = Q(t.shadowIntensity) * .1, e.bakedGroundContactShadowParameters.blurMin = e.bakedGroundContactShadowParameters.blurMax * .01)) : (t.shBakedOnGround !== void 0 && (e.bakedGroundContactShadowParameters.enabled = !1), t.shadowIntensity !== void 0 && (e.shAndAoPassParameters.shadowIntensity = Q(t.shadowIntensity)), t.shadowSoftening !== void 0 && (e.shAndAoPassParameters.shadow.shadowRadius = .001 + Q(t.shadowSoftening) * .2));
|
|
1102
|
+
}, _e = (e, t) => {
|
|
1103
|
+
t.grReflectIntensity !== void 0 && (e.groundReflectionParameters.enabled = t.grReflectIntensity > 0, e.groundReflectionParameters.intensity = Q(t.grReflectIntensity)), t.grReflectFadeOut !== void 0 && (e.groundReflectionParameters.fadeOutDistance = (1 - Q(t.grReflectFadeOut)) * 4);
|
|
1104
|
+
};
|
|
1105
|
+
//#endregion
|
|
1106
|
+
export { A, T as C, ne as D, k as E, O, F as S, N as T, re as _, Y as a, I as b, W as c, ue as d, se as f, z as g, B as h, me as i, E as k, U as l, oe as m, X as n, fe as o, V as p, Z as r, q as s, J as t, H as u, j as v, M as w, P as x, D as y };
|
|
1107
|
+
|
|
1108
|
+
//# sourceMappingURL=shading-settings-BWeccIZv.mjs.map
|