minecraft-renderer 0.1.85 → 0.1.86
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/package.json
CHANGED
|
@@ -9,7 +9,7 @@ const threeVersion = parseInt(THREE.REVISION.replaceAll(/\D+/g, ''), 10)
|
|
|
9
9
|
class StarfieldMaterial extends THREE.ShaderMaterial {
|
|
10
10
|
constructor() {
|
|
11
11
|
super({
|
|
12
|
-
uniforms: { time: { value: 0 }
|
|
12
|
+
uniforms: { time: { value: 0 } },
|
|
13
13
|
vertexShader: /* glsl */ `
|
|
14
14
|
uniform float time;
|
|
15
15
|
attribute float size;
|
|
@@ -23,13 +23,9 @@ class StarfieldMaterial extends THREE.ShaderMaterial {
|
|
|
23
23
|
}`,
|
|
24
24
|
fragmentShader: /* glsl */ `
|
|
25
25
|
uniform sampler2D pointTexture;
|
|
26
|
-
uniform float fade;
|
|
27
26
|
varying vec3 vColor;
|
|
28
27
|
void main() {
|
|
29
|
-
|
|
30
|
-
// the only way to dim stars — scene fog never reaches this shader. Driven by the
|
|
31
|
-
// rain state so stars disappear in rain like in vanilla.
|
|
32
|
-
gl_FragColor = vec4(vColor * fade, 1.0);
|
|
28
|
+
gl_FragColor = vec4(vColor, 1.0);
|
|
33
29
|
|
|
34
30
|
#include <tonemapping_fragment>
|
|
35
31
|
#include <${threeVersion >= 154 ? 'colorspace_fragment' : 'encodings_fragment'}>
|
|
@@ -43,8 +39,6 @@ export class StarfieldModule implements RendererModuleController {
|
|
|
43
39
|
private timer = new THREE.Timer()
|
|
44
40
|
private enabled = false
|
|
45
41
|
private currentTime?: number
|
|
46
|
-
/** Current star brightness multiplier; lerps toward 0 while raining, 1 otherwise. */
|
|
47
|
-
private fade = 1
|
|
48
42
|
|
|
49
43
|
constructor(private readonly worldRenderer: WorldRendererThree) {}
|
|
50
44
|
|
|
@@ -76,20 +70,13 @@ export class StarfieldModule implements RendererModuleController {
|
|
|
76
70
|
return this.currentTime > nightTime && this.currentTime < morningStart
|
|
77
71
|
}
|
|
78
72
|
|
|
79
|
-
render?: (deltaTime: number) => void =
|
|
73
|
+
render?: (deltaTime: number) => void = () => {
|
|
80
74
|
if (!this.points) return
|
|
81
75
|
this.points.position.set(0, 0, 0)
|
|
82
76
|
|
|
83
77
|
const material = this.points.material as StarfieldMaterial
|
|
84
78
|
this.timer.update(performance.now())
|
|
85
79
|
material.uniforms.time.value = this.timer.getElapsed() * 0.2
|
|
86
|
-
|
|
87
|
-
// Fade stars out while raining (vanilla scales star brightness by 1 - rainLevel).
|
|
88
|
-
// isRaining is a boolean here, so ease toward the target instead of snapping.
|
|
89
|
-
const target = this.worldRenderer.worldRendererConfig.isRaining ? 0 : 1
|
|
90
|
-
const t = Math.min(1, deltaTime * 2)
|
|
91
|
-
this.fade += (target - this.fade) * t
|
|
92
|
-
material.uniforms.fade.value = this.fade
|
|
93
80
|
}
|
|
94
81
|
|
|
95
82
|
/**
|