@takram/three-clouds 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/shared.js CHANGED
@@ -1,7 +1,7 @@
1
- import { Pass as Fe, ShaderPass as q, Resolution as $, Effect as ze, EffectAttribute as We } from "postprocessing";
1
+ import { Pass as Fe, ShaderPass as K, Resolution as $, Effect as ze, EffectAttribute as We } from "postprocessing";
2
2
  import { Vector3 as p, Vector2 as f, Matrix4 as m, Object3D as se, Box3 as Be, Uniform as r, GLSL3 as G, Vector4 as S, RawShaderMaterial as Q, Camera as we, WebGLRenderTarget as Ge, HalfFloatType as Ce, LinearFilter as B, RedFormat as Ve, WebGLArrayRenderTarget as ke, EventDispatcher as je, Matrix3 as Ye, Texture as ce, Data3DTexture as le } from "three";
3
- import { AtmosphereMaterialBase as Ze, AtmosphereParameters as Te, getAltitudeCorrectionOffset as Ke } from "@takram/three-atmosphere";
4
- import { lerp as De, defineInt as L, defineExpression as Ee, define as x, defineFloat as ee, unrollLoops as V, resolveIncludes as H, reinterpretType as qe, Geodetic as $e, definePropertyShorthand as he, defineUniformShorthand as ue } from "@takram/three-geospatial";
3
+ import { AtmosphereMaterialBase as Ze, AtmosphereParameters as Te, getAltitudeCorrectionOffset as qe } from "@takram/three-atmosphere";
4
+ import { lerp as De, defineInt as L, defineExpression as Ee, define as x, defineFloat as ee, unrollLoops as V, resolveIncludes as H, reinterpretType as Ke, Geodetic as $e, definePropertyShorthand as he, defineUniformShorthand as ue } from "@takram/three-geospatial";
5
5
  import { runtime as de, definitions as pe, common as fe } from "@takram/three-atmosphere/shaders/bruneton";
6
6
  import { vogelDisk as Xe, interleavedGradientNoise as Je, cascadedShadowMaps as Qe, raySphereIntersection as Ae, generators as et, turbo as _e, math as Pe, depth as tt } from "@takram/three-geospatial/shaders";
7
7
  class k {
@@ -62,7 +62,7 @@ let w = b;
62
62
  const R = /* @__PURE__ */ Array.from(
63
63
  { length: 8 },
64
64
  () => ({ value: 0, flag: 0 })
65
- ), M = /* @__PURE__ */ Array.from(
65
+ ), I = /* @__PURE__ */ Array.from(
66
66
  { length: 3 },
67
67
  () => ({ min: 0, max: 0 })
68
68
  );
@@ -124,17 +124,17 @@ const U = class U extends Array {
124
124
  for (let s = 0; s < R.length; ++s) {
125
125
  const { value: l, flag: h } = R[s];
126
126
  if (a === 0 && s > 0) {
127
- const u = M[n++];
127
+ const u = I[n++];
128
128
  u.min = R[s - 1].value, u.max = l;
129
129
  }
130
130
  a += h === 0 ? 1 : -1;
131
131
  }
132
132
  for (; n < 3; ++n) {
133
- const s = M[n];
133
+ const s = I[n];
134
134
  s.min = 0, s.max = 0;
135
135
  }
136
- let i = M[0];
137
- e.x = i.min, t.x = i.max, i = M[1], e.y = i.min, t.y = i.max, i = M[2], e.z = i.min, t.z = i.max;
136
+ let i = I[0];
137
+ e.x = i.min, t.x = i.max, i = I[1], e.y = i.min, t.y = i.max, i = I[2], e.z = i.min, t.z = i.max;
138
138
  }
139
139
  };
140
140
  U.DEFAULT = /* @__PURE__ */ new U([
@@ -628,14 +628,6 @@ layout(location = 1) out vec3 outputDepthVelocity;
628
628
  layout(location = 2) out float outputShadowLength;
629
629
  #endif // SHADOW_LENGTH
630
630
 
631
- float readDepth(const vec2 uv) {
632
- #if DEPTH_PACKING == 3201
633
- return unpackRGBAToDepth(texture(depthBuffer, uv));
634
- #else // DEPTH_PACKING == 3201
635
- return texture(depthBuffer, uv).r;
636
- #endif // DEPTH_PACKING == 3201
637
- }
638
-
639
631
  float getViewZ(const float depth) {
640
632
  #ifdef PERSPECTIVE_CAMERA
641
633
  return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
@@ -1348,9 +1340,10 @@ vec2 getHazeRayNearFar(const IntersectionResult intersections) {
1348
1340
  #endif // HAZE
1349
1341
 
1350
1342
  float getRayDistanceToScene(const vec3 rayDirection, out float viewZ) {
1351
- float depth = readDepth(vUv * targetUvScale + temporalJitter);
1343
+ float depth = readDepthValue(depthBuffer, vUv * targetUvScale + temporalJitter);
1352
1344
  depth = reverseLogDepth(depth, cameraNear, cameraFar);
1353
1345
  if (depth < 1.0 - 1e-7) {
1346
+ depth = reverseLogDepth(depth, cameraNear, cameraFar);
1354
1347
  viewZ = getViewZ(depth);
1355
1348
  return -viewZ / dot(rayDirection, vCameraDirection);
1356
1349
  }
@@ -2031,7 +2024,7 @@ class g extends Ze {
2031
2024
  t.temporalJitter.value.set(P, O), t.mipLevelScale.value = 0.25, i.copy(e.projectionMatrix), i.elements[8] += P * 2, i.elements[9] += O * 2, i.invert(), l.copy(n), l.elements[8] += P * 2, l.elements[9] += O * 2, l.multiply(a), h.copy(l).multiply(s);
2032
2025
  } else
2033
2026
  t.temporalJitter.value.setScalar(0), t.mipLevelScale.value = 1, i.copy(e.projectionMatrixInverse), l.copy(n).multiply(a), h.copy(l).multiply(s);
2034
- qe(e), t.cameraNear.value = e.near, t.cameraFar.value = e.far;
2027
+ Ke(e), t.cameraNear.value = e.near, t.cameraFar.value = e.far;
2035
2028
  const u = e.getWorldPosition(
2036
2029
  t.cameraPosition.value
2037
2030
  ), d = St.copy(u).applyMatrix4(t.worldToECEFMatrix.value);
@@ -2405,7 +2398,7 @@ void main() {
2405
2398
  vUv = position.xy * 0.5 + 0.5;
2406
2399
  gl_Position = vec4(position.xy, 1.0, 1.0);
2407
2400
  }
2408
- `, Ie = `#ifdef VARIANCE_9_SAMPLES
2401
+ `, Me = `#ifdef VARIANCE_9_SAMPLES
2409
2402
  #define VARIANCE_OFFSET_COUNT 8
2410
2403
  const ivec2 varianceOffsets[8] = ivec2[8](
2411
2404
  ivec2(-1, -1),
@@ -2520,7 +2513,7 @@ vec4 varianceClipping(
2520
2513
  return varianceClipping(inputBuffer, coord, current, history, 1.0);
2521
2514
  }
2522
2515
  `;
2523
- var Tt = Object.defineProperty, Me = (o, e, t, n) => {
2516
+ var Tt = Object.defineProperty, Ie = (o, e, t, n) => {
2524
2517
  for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
2525
2518
  (s = o[i]) && (a = s(e, t, a) || a);
2526
2519
  return a && Tt(e, t, a), a;
@@ -2541,7 +2534,7 @@ class te extends Q {
2541
2534
  H(wt, {
2542
2535
  core: { turbo: _e },
2543
2536
  catmullRomSampling: xt,
2544
- varianceClipping: Ie
2537
+ varianceClipping: Me
2545
2538
  })
2546
2539
  ),
2547
2540
  uniforms: {
@@ -2566,10 +2559,10 @@ class te extends Q {
2566
2559
  this.uniforms.jitterOffset.value.set(d, v);
2567
2560
  }
2568
2561
  }
2569
- Me([
2562
+ Ie([
2570
2563
  x("TEMPORAL_UPSCALE")
2571
2564
  ], te.prototype, "temporalUpscale");
2572
- Me([
2565
+ Ie([
2573
2566
  x("SHADOW_LENGTH")
2574
2567
  ], te.prototype, "shadowLength");
2575
2568
  class Ne extends Fe {
@@ -2613,7 +2606,7 @@ class Dt extends Ne {
2613
2606
  atmosphereUniforms: n
2614
2607
  },
2615
2608
  i
2616
- ), this.currentPass = new q(this.currentMaterial), this.resolveMaterial = new te(), this.resolvePass = new q(this.resolveMaterial), this.initRenderTargets({
2609
+ ), this.currentPass = new K(this.currentMaterial), this.resolveMaterial = new te(), this.resolvePass = new K(this.resolveMaterial), this.initRenderTargets({
2617
2610
  depthVelocity: !0,
2618
2611
  shadowLength: c.lightShafts
2619
2612
  });
@@ -2719,7 +2712,7 @@ function Et(o, e) {
2719
2712
  ), i.push(a.COLOR_ATTACHMENT0 + s);
2720
2713
  a.drawBuffers(i);
2721
2714
  }
2722
- class xe extends q {
2715
+ class xe extends K {
2723
2716
  render(e, t, n, a, i) {
2724
2717
  const s = this.fullscreenMaterial.uniforms;
2725
2718
  t !== null && s?.[this.input] != null && (s[this.input].value = t.texture), Et(e, n), e.render(this.scene, this.camera);
@@ -3030,7 +3023,7 @@ void intersectStructuredPlanes(
3030
3023
  }
3031
3024
  }
3032
3025
  `;
3033
- var Ot = Object.defineProperty, I = (o, e, t, n) => {
3026
+ var Ot = Object.defineProperty, M = (o, e, t, n) => {
3034
3027
  for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
3035
3028
  (s = o[i]) && (a = s(e, t, a) || a);
3036
3029
  return a && Ot(e, t, a), a;
@@ -3092,24 +3085,24 @@ class _ extends Q {
3092
3085
  this.uniforms.resolution.value.set(e, t);
3093
3086
  }
3094
3087
  }
3095
- I([
3088
+ M([
3096
3089
  Ee("LOCAL_WEATHER_CHANNELS", {
3097
3090
  validate: (o) => /^[rgba]{4}$/.test(o)
3098
3091
  })
3099
3092
  ], _.prototype, "localWeatherChannels");
3100
- I([
3093
+ M([
3101
3094
  L("CASCADE_COUNT", { min: 1, max: 4 })
3102
3095
  ], _.prototype, "cascadeCount");
3103
- I([
3096
+ M([
3104
3097
  x("TEMPORAL_PASS")
3105
3098
  ], _.prototype, "temporalPass");
3106
- I([
3099
+ M([
3107
3100
  x("TEMPORAL_JITTER")
3108
3101
  ], _.prototype, "temporalJitter");
3109
- I([
3102
+ M([
3110
3103
  x("SHAPE_DETAIL")
3111
3104
  ], _.prototype, "shapeDetail");
3112
- I([
3105
+ M([
3113
3106
  x("TURBULENCE")
3114
3107
  ], _.prototype, "turbulence");
3115
3108
  const Rt = `precision highp float;
@@ -3199,10 +3192,10 @@ void main() {
3199
3192
  gl_Position = vec4(position.xy, 1.0, 1.0);
3200
3193
  }
3201
3194
  `;
3202
- var It = Object.defineProperty, Mt = (o, e, t, n) => {
3195
+ var Mt = Object.defineProperty, It = (o, e, t, n) => {
3203
3196
  for (var a = void 0, i = o.length - 1, s; i >= 0; i--)
3204
3197
  (s = o[i]) && (a = s(e, t, a) || a);
3205
- return a && It(e, t, a), a;
3198
+ return a && Mt(e, t, a), a;
3206
3199
  };
3207
3200
  class be extends Q {
3208
3201
  constructor({
@@ -3215,7 +3208,7 @@ class be extends Q {
3215
3208
  vertexShader: Lt,
3216
3209
  fragmentShader: V(
3217
3210
  H(Rt, {
3218
- varianceClipping: Ie
3211
+ varianceClipping: Me
3219
3212
  })
3220
3213
  ),
3221
3214
  uniforms: {
@@ -3236,7 +3229,7 @@ class be extends Q {
3236
3229
  this.uniforms.texelSize.value.set(1 / e, 1 / t);
3237
3230
  }
3238
3231
  }
3239
- Mt([
3232
+ It([
3240
3233
  L("CASCADE_COUNT", { min: 1, max: 4 })
3241
3234
  ], be.prototype, "cascadeCount");
3242
3235
  function Z(o) {
@@ -3354,7 +3347,7 @@ function Ut() {
3354
3347
  })
3355
3348
  };
3356
3349
  }
3357
- const K = [0, 0, 0, 0];
3350
+ const q = [0, 0, 0, 0];
3358
3351
  function Ht(o, e) {
3359
3352
  e.packValues("altitude", o.minLayerHeights.value), e.packSums("altitude", "height", o.maxLayerHeights.value), e.packIntervalHeights(
3360
3353
  o.minIntervalHeights.value,
@@ -3363,12 +3356,12 @@ function Ht(o, e) {
3363
3356
  const t = o.densityProfile.value;
3364
3357
  e.packDensityProfiles("expTerm", t.expTerms), e.packDensityProfiles("exponent", t.exponents), e.packDensityProfiles("linearTerm", t.linearTerms), e.packDensityProfiles("constantTerm", t.constantTerms);
3365
3358
  let n = 1 / 0, a = 0, i = 1 / 0, s = 0;
3366
- K.fill(0);
3359
+ q.fill(0);
3367
3360
  for (let l = 0; l < e.length; ++l) {
3368
3361
  const { altitude: h, height: u, shadow: d } = e[l], v = h + u;
3369
- u > 0 && (h < n && (n = h), d && h < i && (i = h), v > a && (a = v), d && v > s && (s = v)), K[l] = d ? 1 : 0;
3362
+ u > 0 && (h < n && (n = h), d && h < i && (i = h), v > a && (a = v), d && v > s && (s = v)), q[l] = d ? 1 : 0;
3370
3363
  }
3371
- n !== 1 / 0 ? (o.minHeight.value = n, o.maxHeight.value = a) : (A(a === 0), o.minHeight.value = 0), i !== 1 / 0 ? (o.shadowBottomHeight.value = i, o.shadowTopHeight.value = s) : (A(s === 0), o.shadowBottomHeight.value = 0), o.shadowLayerMask.value.fromArray(K);
3364
+ n !== 1 / 0 ? (o.minHeight.value = n, o.maxHeight.value = a) : (A(a === 0), o.minHeight.value = 0), i !== 1 / 0 ? (o.shadowBottomHeight.value = i, o.shadowTopHeight.value = s) : (A(s === 0), o.shadowBottomHeight.value = 0), o.shadowLayerMask.value.fromArray(q);
3372
3365
  }
3373
3366
  function Ft(o, e) {
3374
3367
  return {
@@ -3432,9 +3425,9 @@ const N = /* @__PURE__ */ new p(), Gt = /* @__PURE__ */ new f(), Vt = /* @__PURE
3432
3425
  "opticalDepthTailScale"
3433
3426
  ], Zt = [
3434
3427
  "temporalJitter"
3435
- ], Kt = [
3436
- "temporalPass"
3437
3428
  ], qt = [
3429
+ "temporalPass"
3430
+ ], Kt = [
3438
3431
  "cascadeCount",
3439
3432
  "mapSize",
3440
3433
  "maxFar",
@@ -3511,9 +3504,9 @@ class Xt extends ze {
3511
3504
  this.shadowPass.currentMaterial,
3512
3505
  Zt,
3513
3506
  this.shadowPass,
3514
- Kt,
3507
+ qt,
3515
3508
  this.shadowMaps,
3516
- qt
3509
+ Kt
3517
3510
  ), this.resolution = new $(
3518
3511
  this,
3519
3512
  l,
@@ -3543,7 +3536,7 @@ class Xt extends ze {
3543
3536
  const n = this.worldToECEFMatrix;
3544
3537
  this.ecefToWorldMatrix.copy(n).invert();
3545
3538
  const a = this.camera.getWorldPosition(N).applyMatrix4(this.worldToECEFMatrix), i = this.altitudeCorrection;
3546
- this.correctAltitude ? Ke(
3539
+ this.correctAltitude ? qe(
3547
3540
  a,
3548
3541
  this.atmosphere.bottomRadius,
3549
3542
  this.ellipsoid,