@zaisma/effects 1.2.0 → 2.0.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/piece.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "statement_version_number": 2,
3
3
  "name": "@zaisma/effects",
4
4
  "title": "Effects",
5
- "piece_version": "1.2.0",
5
+ "piece_version": "2.0.0",
6
6
  "kind": "foundation",
7
7
  "standard": "@zaisma/standard",
8
8
  "summary": "Spectacle that holds a phone's frame rate, for three.js: thousands of lit particles, hits, explosions, magic, trails, screen warps, marks on surfaces, debris that bounces and weather, in the look a game picks. An effect is a small file an AI writes; 92 come with it. Flashes light the scene, the character and physics bring effects free, and online every player sees the same effect at once.",
@@ -15,6 +15,7 @@
15
15
  "README.md",
16
16
  "batches/chunks.js",
17
17
  "batches/marks.js",
18
+ "batches/motion-nodes.js",
18
19
  "batches/ribbons.js",
19
20
  "batches/shared.js",
20
21
  "batches/sprites.js",
@@ -153,7 +154,7 @@
153
154
  },
154
155
  {
155
156
  "name": "three",
156
- "version_range": ">=0.163.0 <1.0.0",
157
+ "version_range": ">=0.187.0 <1.0.0",
157
158
  "kind": "library"
158
159
  }
159
160
  ],
@@ -187,7 +188,7 @@
187
188
  "medium",
188
189
  "high"
189
190
  ],
190
- "summary": "How much the effects draw. low: 2,000 particles, no flash lights, warps or rain shelter. medium: 6,000 particles, two flash lights. high: 20,000 particles, four flash lights, particles darkened inside the sun's shadow. auto follows the lighting piece's quality when the game gave it, and otherwise starts at medium on phones and tablets, high elsewhere, and steps down while frames run slow."
191
+ "summary": "How much the effects draw. low: 2,000 particles, no flash lights, warps or rain shelter. medium: 6,000 particles, two flash lights. high: 20,000 particles, four flash lights. auto follows the lighting piece's quality when the game gave it, and otherwise starts at medium on phones and tablets, high elsewhere, and steps down while frames run slow."
191
192
  },
192
193
  {
193
194
  "name": "particle_budget_pct",
@@ -257,7 +258,7 @@
257
258
  "maximum_number": 100,
258
259
  "maximum_character_count": null,
259
260
  "choices": null,
260
- "summary": "How hard it rains: 0 is dry, 100 a downpour. Rain falls round the camera, leans with the wind, stays out from under roofs and splashes where it lands."
261
+ "summary": "How hard it rains: 0 is dry, 100 a downpour. Rain falls round the camera, leans with the wind, stays out from under roofs and splashes where it lands. With the lighting piece given, its weather's rain falls too: the heavier of the two."
261
262
  },
262
263
  {
263
264
  "name": "snow_pct",
@@ -267,7 +268,7 @@
267
268
  "maximum_number": 100,
268
269
  "maximum_character_count": null,
269
270
  "choices": null,
270
- "summary": "How hard it snows: 0 is none, 100 a blizzard. Snow drifts with the wind and stays out from under roofs."
271
+ "summary": "How hard it snows: 0 is none, 100 a blizzard. Snow drifts with the wind and stays out from under roofs. With the lighting piece given, its weather's snow falls too: the heavier of the two."
271
272
  },
272
273
  {
273
274
  "name": "fog_pct",
@@ -287,7 +288,7 @@
287
288
  "maximum_number": 40,
288
289
  "maximum_character_count": null,
289
290
  "choices": null,
290
- "summary": "How fast the wind blows. It carries every particle by as much as its effect says (wind_pct): smoke leans, rain slants, sparks barely notice."
291
+ "summary": "How fast the wind blows. It carries every particle by as much as its effect says (wind_pct): smoke leans, rain slants, sparks barely notice. With the lighting piece given, its wind blows here too when it's the stronger, at 12 m/s at its strongest."
291
292
  },
292
293
  {
293
294
  "name": "wind_direction_deg",
package/piece.json.js CHANGED
@@ -3,7 +3,7 @@ export default {
3
3
  "statement_version_number": 2,
4
4
  "name": "@zaisma/effects",
5
5
  "title": "Effects",
6
- "piece_version": "1.2.0",
6
+ "piece_version": "2.0.0",
7
7
  "kind": "foundation",
8
8
  "standard": "@zaisma/standard",
9
9
  "summary": "Spectacle that holds a phone's frame rate, for three.js: thousands of lit particles, hits, explosions, magic, trails, screen warps, marks on surfaces, debris that bounces and weather, in the look a game picks. An effect is a small file an AI writes; 92 come with it. Flashes light the scene, the character and physics bring effects free, and online every player sees the same effect at once.",
@@ -16,6 +16,7 @@ export default {
16
16
  "README.md",
17
17
  "batches/chunks.js",
18
18
  "batches/marks.js",
19
+ "batches/motion-nodes.js",
19
20
  "batches/ribbons.js",
20
21
  "batches/shared.js",
21
22
  "batches/sprites.js",
@@ -154,7 +155,7 @@ export default {
154
155
  },
155
156
  {
156
157
  "name": "three",
157
- "version_range": ">=0.163.0 <1.0.0",
158
+ "version_range": ">=0.187.0 <1.0.0",
158
159
  "kind": "library"
159
160
  }
160
161
  ],
@@ -188,7 +189,7 @@ export default {
188
189
  "medium",
189
190
  "high"
190
191
  ],
191
- "summary": "How much the effects draw. low: 2,000 particles, no flash lights, warps or rain shelter. medium: 6,000 particles, two flash lights. high: 20,000 particles, four flash lights, particles darkened inside the sun's shadow. auto follows the lighting piece's quality when the game gave it, and otherwise starts at medium on phones and tablets, high elsewhere, and steps down while frames run slow."
192
+ "summary": "How much the effects draw. low: 2,000 particles, no flash lights, warps or rain shelter. medium: 6,000 particles, two flash lights. high: 20,000 particles, four flash lights. auto follows the lighting piece's quality when the game gave it, and otherwise starts at medium on phones and tablets, high elsewhere, and steps down while frames run slow."
192
193
  },
193
194
  {
194
195
  "name": "particle_budget_pct",
@@ -258,7 +259,7 @@ export default {
258
259
  "maximum_number": 100,
259
260
  "maximum_character_count": null,
260
261
  "choices": null,
261
- "summary": "How hard it rains: 0 is dry, 100 a downpour. Rain falls round the camera, leans with the wind, stays out from under roofs and splashes where it lands."
262
+ "summary": "How hard it rains: 0 is dry, 100 a downpour. Rain falls round the camera, leans with the wind, stays out from under roofs and splashes where it lands. With the lighting piece given, its weather's rain falls too: the heavier of the two."
262
263
  },
263
264
  {
264
265
  "name": "snow_pct",
@@ -268,7 +269,7 @@ export default {
268
269
  "maximum_number": 100,
269
270
  "maximum_character_count": null,
270
271
  "choices": null,
271
- "summary": "How hard it snows: 0 is none, 100 a blizzard. Snow drifts with the wind and stays out from under roofs."
272
+ "summary": "How hard it snows: 0 is none, 100 a blizzard. Snow drifts with the wind and stays out from under roofs. With the lighting piece given, its weather's snow falls too: the heavier of the two."
272
273
  },
273
274
  {
274
275
  "name": "fog_pct",
@@ -288,7 +289,7 @@ export default {
288
289
  "maximum_number": 40,
289
290
  "maximum_character_count": null,
290
291
  "choices": null,
291
- "summary": "How fast the wind blows. It carries every particle by as much as its effect says (wind_pct): smoke leans, rain slants, sparks barely notice."
292
+ "summary": "How fast the wind blows. It carries every particle by as much as its effect says (wind_pct): smoke leans, rain slants, sparks barely notice. With the lighting piece given, its wind blows here too when it's the stronger, at 12 m/s at its strongest."
292
293
  },
293
294
  {
294
295
  "name": "wind_direction_deg",
package/shapes.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // things about a shape, one in each channel: how far inside its edge a point is (red, 0.5 on the edge, so the edge
4
4
  // stays crisp however big it's drawn), how thick it is there (green, for soft looks) and how near its hot core
5
5
  // (blue, for tones). The look decides which of them a particle is drawn from.
6
- import * as THREE from "three";
6
+ import * as THREE from "three/webgpu";
7
7
  import { MARK_SHAPE_NAMES, SHAPE_NAMES } from "./format.js";
8
8
 
9
9
  export const ATLAS_CELL_COUNT = 8;
@@ -224,39 +224,68 @@ void main() {
224
224
 
225
225
  /** Whether this renderer can draw: a test's stand-in can't, and the effects then keep count without pictures. */
226
226
  export function canRendererDraw(renderer) {
227
- return Boolean(renderer && typeof renderer.getContext === "function" && renderer.capabilities);
227
+ return Boolean(renderer && renderer.isRenderer === true && typeof document !== "undefined");
228
+ }
229
+
230
+ function compile(gl, kindNumber, source) {
231
+ const shader = gl.createShader(kindNumber);
232
+ gl.shaderSource(shader, source);
233
+ gl.compileShader(shader);
234
+ return shader;
235
+ }
236
+
237
+ /**
238
+ * Draws the picture of shapes once, with a small WebGL 2 canvas of the piece's own (so the same shapes come out
239
+ * whatever the game's renderer draws with), and reads it back. Answers its bytes, or null where it can't be drawn.
240
+ */
241
+ function drawAtlas(sizePx) {
242
+ const canvas = document.createElement("canvas");
243
+ canvas.width = sizePx;
244
+ canvas.height = sizePx;
245
+ const gl = canvas.getContext("webgl2", { alpha: true, antialias: false, depth: false, stencil: false, premultipliedAlpha: false, preserveDrawingBuffer: true });
246
+ if (!gl) return null;
247
+ const program = gl.createProgram();
248
+ gl.attachShader(program, compile(gl, gl.VERTEX_SHADER, `#version 300 es\nin vec3 position;\n#define varying out\n${ATLAS_VERTEX}`));
249
+ gl.attachShader(program, compile(gl, gl.FRAGMENT_SHADER, `#version 300 es\nprecision highp float;\nprecision highp int;\n#define varying in\nout vec4 zaismaColor;\n#define gl_FragColor zaismaColor\n${ATLAS_FRAGMENT}`));
250
+ gl.bindAttribLocation(program, 0, "position");
251
+ gl.linkProgram(program);
252
+ let drawn = null;
253
+ if (gl.getProgramParameter(program, gl.LINK_STATUS)) {
254
+ gl.useProgram(program);
255
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
256
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 0, 3, -1, 0, -1, 3, 0]), gl.STATIC_DRAW);
257
+ gl.enableVertexAttribArray(0);
258
+ gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
259
+ gl.viewport(0, 0, sizePx, sizePx);
260
+ gl.drawArrays(gl.TRIANGLES, 0, 3);
261
+ drawn = new Uint8Array(sizePx * sizePx * 4);
262
+ gl.readPixels(0, 0, sizePx, sizePx, gl.RGBA, gl.UNSIGNED_BYTE, drawn);
263
+ } else console.error("@zaisma/effects: the shapes couldn't be drawn.", gl.getProgramInfoLog(program));
264
+ gl.getExtension("WEBGL_lose_context")?.loseContext();
265
+ return drawn;
228
266
  }
229
267
 
230
268
  /**
231
- * Draws the picture of shapes once and answers its texture; { texture, dispose }. With a renderer that can't draw,
232
- * a blank one.
269
+ * Draws the picture of shapes once and answers its texture; { texture, depthOf, dispose }. With a renderer that
270
+ * can't draw, a blank one.
233
271
  */
234
272
  export function createShapeAtlas(renderer, sizePx) {
235
- if (!canRendererDraw(renderer)) {
273
+ const drawn = canRendererDraw(renderer) ? drawAtlas(sizePx) : null;
274
+ if (!drawn) {
236
275
  const blank = new THREE.DataTexture(new Uint8Array([128, 255, 255, 255]), 1, 1);
237
276
  blank.needsUpdate = true;
238
277
  return { texture: blank, depthOf: () => 1, dispose: () => blank.dispose() };
239
278
  }
240
- const target = new THREE.WebGLRenderTarget(sizePx, sizePx, { depthBuffer: false, generateMipmaps: true, minFilter: THREE.LinearMipmapLinearFilter, magFilter: THREE.LinearFilter, colorSpace: THREE.NoColorSpace });
241
- const material = new THREE.ShaderMaterial({ vertexShader: ATLAS_VERTEX, fragmentShader: ATLAS_FRAGMENT, depthTest: false, depthWrite: false, toneMapped: false });
242
- const geometry = new THREE.BufferGeometry();
243
- geometry.setAttribute("position", new THREE.BufferAttribute(new Float32Array([-1, -1, 0, 3, -1, 0, -1, 3, 0]), 3));
244
- const triangle = new THREE.Mesh(geometry, material);
245
- triangle.frustumCulled = false;
246
- const scene = new THREE.Scene();
247
- scene.add(triangle);
248
- const earlierTarget = renderer.getRenderTarget();
249
- renderer.setRenderTarget(target);
250
- renderer.render(scene, new THREE.Camera());
251
- renderer.setRenderTarget(earlierTarget);
252
- geometry.dispose();
253
- material.dispose();
254
- // How deep inside its edge each shape goes, read back once: a thin ring is never as deep as a disc, and a hard
255
- // shape closes in by its own depth as it fades.
279
+ // Its rows run from the bottom up, as they were drawn.
280
+ const texture = new THREE.DataTexture(drawn, sizePx, sizePx, THREE.RGBAFormat, THREE.UnsignedByteType);
281
+ texture.colorSpace = THREE.NoColorSpace;
282
+ texture.generateMipmaps = true;
283
+ texture.minFilter = THREE.LinearMipmapLinearFilter;
284
+ texture.magFilter = THREE.LinearFilter;
285
+ texture.needsUpdate = true;
286
+ // How deep inside its edge each shape goes: a thin ring is never as deep as a disc, and a hard shape closes in
287
+ // by its own depth as it fades.
256
288
  const cellPx = sizePx / ATLAS_CELL_COUNT;
257
- const rowCount = shapeRow(SHAPE_NAMES.length - 1) + 1;
258
- const drawn = new Uint8Array(sizePx * cellPx * rowCount * 4);
259
- renderer.readRenderTargetPixels(target, 0, 0, sizePx, cellPx * rowCount, drawn);
260
289
  const depths = SHAPE_NAMES.map((shapeName, index) => {
261
290
  const fromX = (index % ATLAS_CELL_COUNT) * cellPx;
262
291
  const fromY = shapeRow(index) * cellPx;
@@ -265,5 +294,5 @@ export function createShapeAtlas(renderer, sizePx) {
265
294
  for (let y = fromY; y < fromY + cellPx; y += 4) for (let x = fromX; x < fromX + cellPx; x += 4) deepestByte = Math.max(deepestByte, drawn[(y * sizePx + x) * 4]);
266
295
  return Math.max(deepestByte / 255, 0.52);
267
296
  });
268
- return { texture: target.texture, depthOf: (shapeName) => depths[SHAPE_NAMES.indexOf(shapeName)] ?? 1, dispose: () => target.dispose() };
297
+ return { texture, depthOf: (shapeName) => depths[SHAPE_NAMES.indexOf(shapeName)] ?? 1, dispose: () => texture.dispose() };
269
298
  }
package/tables.js CHANGED
@@ -2,7 +2,7 @@
2
2
  // how fast, when, its seed) and two row numbers: its element's row (how every particle of that element moves and
3
3
  // fades, in the look in use) and its play's row (where that play of the effect is now, its size and tint). So a
4
4
  // slider in the workbench, or an effect that moves, changes every live particle by writing one row.
5
- import * as THREE from "three";
5
+ import * as THREE from "three/webgpu";
6
6
 
7
7
  /** Texels in an element's row: see ELEMENT_ROW in batches/sprites.js for what each holds. */
8
8
  export const ELEMENT_ROW_TEXEL_COUNT = 16;
package/weather.js CHANGED
@@ -5,7 +5,8 @@
5
5
  // Rain and snow stay out from under roofs by a small picture of the level seen from above (the shelter map): each
6
6
  // texel holds the height of the highest thing there, and a drop below that height isn't drawn. Rain's splashes
7
7
  // land on the same heights. The picture is drawn again only when the camera has moved or a moment has passed.
8
- import * as THREE from "three";
8
+ import * as THREE from "three/webgpu";
9
+ import { positionWorld, renderGroup, uniform, vec4 } from "three/tsl";
9
10
  import { completeEffect, randomFrom } from "./format.js";
10
11
  import { windAt } from "./motion.js";
11
12
  import { canRendererDraw } from "./shapes.js";
@@ -67,29 +68,6 @@ const SHELTER_BELOW_M = 40;
67
68
  const SHELTER_REDRAW_DISTANCE_M = 3;
68
69
  const SHELTER_REDRAW_INTERVAL_SEC = 1.5;
69
70
 
70
- const SHELTER_VERTEX = /* glsl */ `
71
- #include <common>
72
- #include <skinning_pars_vertex>
73
- varying float vHeightM;
74
- void main() {
75
- #include <skinbase_vertex>
76
- #include <begin_vertex>
77
- #include <skinning_vertex>
78
- vec4 worldPlace = vec4(transformed, 1.0);
79
- #ifdef USE_INSTANCING
80
- worldPlace = instanceMatrix * worldPlace;
81
- #endif
82
- worldPlace = modelMatrix * worldPlace;
83
- vHeightM = worldPlace.y;
84
- gl_Position = projectionMatrix * viewMatrix * worldPlace;
85
- }`;
86
- const SHELTER_FRAGMENT = /* glsl */ `
87
- uniform float uBaseM;
88
- varying float vHeightM;
89
- void main() {
90
- gl_FragColor = vec4(vHeightM - uBaseM, 0.0, 0.0, 1.0);
91
- }`;
92
-
93
71
  const easeToward = (current, target, share, snap) => (Math.abs(target - current) <= snap ? target : current + (target - current) * share);
94
72
  const wrapInto = (positionM, sizeM) => ((positionM % sizeM) + sizeM) % sizeM;
95
73
 
@@ -108,7 +86,15 @@ export function createWeather({ sprites, sharedUniforms, scene, renderer, playRo
108
86
  // ---- The shelter map ----
109
87
  const canDraw = canRendererDraw(renderer);
110
88
  let shelterTarget = null;
111
- const shelterMaterial = new THREE.ShaderMaterial({ name: "zaisma_effect_shelter", vertexShader: SHELTER_VERTEX, fragmentShader: SHELTER_FRAGMENT, uniforms: { uBaseM: { value: 0 } }, toneMapped: false, fog: false, side: THREE.DoubleSide });
89
+ // Every mesh drawn as its own height above the map's floor, whatever its material: three keeps each one's own
90
+ // shape (bones, instances) under a material that stands in for the scene's.
91
+ const shelterBaseM = uniform(0).setGroup(renderGroup);
92
+ const shelterMaterial = new THREE.NodeMaterial();
93
+ shelterMaterial.name = "zaisma_effect_shelter";
94
+ shelterMaterial.lights = false;
95
+ shelterMaterial.fog = false;
96
+ shelterMaterial.side = THREE.DoubleSide;
97
+ shelterMaterial.fragmentNode = vec4(positionWorld.y.sub(shelterBaseM), 0.0, 0.0, 1.0);
112
98
  const shelterCamera = new THREE.OrthographicCamera(-SHELTER_WIDTH_M / 2, SHELTER_WIDTH_M / 2, SHELTER_WIDTH_M / 2, -SHELTER_WIDTH_M / 2, 0.1, SHELTER_ABOVE_M + SHELTER_BELOW_M);
113
99
  shelterCamera.up.set(0, 0, -1);
114
100
  const shelterCenter = new THREE.Vector3(Infinity, 0, 0);
@@ -120,7 +106,7 @@ export function createWeather({ sprites, sharedUniforms, scene, renderer, playRo
120
106
 
121
107
  function drawShelter(nowSec) {
122
108
  if (!shelterTarget) {
123
- shelterTarget = new THREE.WebGLRenderTarget(SHELTER_SIZE_PX, SHELTER_SIZE_PX, { type: THREE.HalfFloatType, minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter, depthBuffer: true, generateMipmaps: false, colorSpace: THREE.NoColorSpace });
109
+ shelterTarget = new THREE.RenderTarget(SHELTER_SIZE_PX, SHELTER_SIZE_PX, { type: THREE.HalfFloatType, minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter, depthBuffer: true, generateMipmaps: false, colorSpace: THREE.NoColorSpace });
124
110
  sharedUniforms.uShelter.value = shelterTarget.texture;
125
111
  }
126
112
  // Whole texels, so the map doesn't shimmer as the camera moves.
@@ -131,7 +117,7 @@ export function createWeather({ sprites, sharedUniforms, scene, renderer, playRo
131
117
  shelterCamera.position.set(shelterCenter.x, shelterCenter.y + SHELTER_ABOVE_M, shelterCenter.z);
132
118
  shelterCamera.lookAt(shelterCenter.x, shelterCenter.y, shelterCenter.z);
133
119
  shelterCamera.updateMatrixWorld();
134
- shelterMaterial.uniforms.uBaseM.value = baseM;
120
+ shelterBaseM.value = baseM;
135
121
 
136
122
  const hidden = [];
137
123
  for (const object of hiddenObjects) {
@@ -143,13 +129,11 @@ export function createWeather({ sprites, sharedUniforms, scene, renderer, playRo
143
129
  const earlierTarget = renderer.getRenderTarget();
144
130
  const earlierOverride = scene.overrideMaterial;
145
131
  const earlierBackground = scene.background;
146
- const earlierShadowUpdate = renderer.shadowMap.autoUpdate;
147
132
  const earlierXr = renderer.xr.enabled;
148
133
  const earlierClearAlpha = renderer.getClearAlpha();
149
134
  renderer.getClearColor(earlierClearColor);
150
135
  scene.overrideMaterial = shelterMaterial;
151
136
  scene.background = null;
152
- renderer.shadowMap.autoUpdate = false;
153
137
  renderer.xr.enabled = false;
154
138
  renderer.setRenderTarget(shelterTarget);
155
139
  renderer.setClearColor(0x000000, 0);
@@ -160,7 +144,6 @@ export function createWeather({ sprites, sharedUniforms, scene, renderer, playRo
160
144
  renderer.setRenderTarget(earlierTarget);
161
145
  renderer.setClearColor(earlierClearColor, earlierClearAlpha);
162
146
  renderer.xr.enabled = earlierXr;
163
- renderer.shadowMap.autoUpdate = earlierShadowUpdate;
164
147
  scene.background = earlierBackground;
165
148
  scene.overrideMaterial = earlierOverride;
166
149
  for (const object of hidden) object.visible = true;
@@ -239,21 +222,21 @@ export function createWeather({ sprites, sharedUniforms, scene, renderer, playRo
239
222
  fillLayer(layer);
240
223
  const [widthM, heightM, depthM] = layer.boxM;
241
224
  const index = layer.layerIndex;
242
- sharedUniforms.uWrapShare.value[index] = layerShareNumber;
243
- sharedUniforms.uWrapBox.value[index].set(widthM, heightM, depthM);
225
+ sharedUniforms.uWrapShare.array[index] = layerShareNumber;
226
+ sharedUniforms.uWrapBox.array[index].set(widthM, heightM, depthM);
244
227
  if (index === LANDING_LAYER_INDEX) {
245
- sharedUniforms.uWrapCenter.value[index].set(cameraPlace.x + cameraWay.x * widthM * 0.3, cameraPlace.y, cameraPlace.z + cameraWay.z * depthM * 0.3);
246
- sharedUniforms.uWrapVelocity.value[index].set(LANDINGS_PER_SEC, 0, 0);
228
+ sharedUniforms.uWrapCenter.array[index].set(cameraPlace.x + cameraWay.x * widthM * 0.3, cameraPlace.y, cameraPlace.z + cameraWay.z * depthM * 0.3);
229
+ sharedUniforms.uWrapVelocity.array[index].set(LANDINGS_PER_SEC, 0, 0);
247
230
  continue;
248
231
  }
249
232
  const velocityX = windM.x * layer.windShare;
250
233
  const velocityZ = windM.z * layer.windShare;
251
234
  layer.shift.set(wrapInto(layer.shift.x + velocityX * frameSec, widthM), wrapInto(layer.shift.y - layer.fallMPerSec * frameSec, heightM), wrapInto(layer.shift.z + velocityZ * frameSec, depthM));
252
- sharedUniforms.uWrapShift.value[index].copy(layer.shift);
253
- sharedUniforms.uWrapVelocity.value[index].set(velocityX, -layer.fallMPerSec, velocityZ);
235
+ sharedUniforms.uWrapShift.array[index].copy(layer.shift);
236
+ sharedUniforms.uWrapVelocity.array[index].set(velocityX, -layer.fallMPerSec, velocityZ);
254
237
  // The box sits a little ahead of the camera, so more of it is in view; fog lies on the ground.
255
238
  const centerY = layer.layerName === "fog" ? groundHeightM + heightM * 0.5 : cameraPlace.y + heightM * 0.2;
256
- sharedUniforms.uWrapCenter.value[index].set(cameraPlace.x + cameraWay.x * widthM * 0.25, centerY, cameraPlace.z + cameraWay.z * depthM * 0.25);
239
+ sharedUniforms.uWrapCenter.array[index].set(cameraPlace.x + cameraWay.x * widthM * 0.25, centerY, cameraPlace.z + cameraWay.z * depthM * 0.25);
257
240
  }
258
241
 
259
242
  const isFalling = now.rainPct > 0 || now.snowPct > 0;
@@ -282,7 +265,7 @@ export function createWeather({ sprites, sharedUniforms, scene, renderer, playRo
282
265
  for (const layer of layers) dropLayer(layer);
283
266
  shelterTarget?.dispose();
284
267
  shelterMaterial.dispose();
285
- sharedUniforms.uShelter.value = null;
268
+ sharedUniforms.uShelter.value = sharedUniforms.blanks[3];
286
269
  sharedUniforms.uShelterBox.value.w = 0;
287
270
  },
288
271
  };