@holtjs/stage 0.13.0 → 0.14.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/dist/lighting.js CHANGED
@@ -247,34 +247,39 @@ const RADIAL_GLOW_SIZE = 128;
247
247
  function ensureRadialGlowTexture(textures) {
248
248
  if (textures.exists(RADIAL_GLOW_KEY)) return true;
249
249
  try {
250
- const ct = textures.createCanvas(RADIAL_GLOW_KEY, RADIAL_GLOW_SIZE, RADIAL_GLOW_SIZE);
251
- if (!ct) return false;
252
- const ctx = ct.canvas.getContext("2d");
253
- if (!ctx || typeof ctx.createImageData !== "function" || typeof ctx.putImageData !== "function") {
254
- textures.remove(RADIAL_GLOW_KEY);
255
- return false;
256
- }
257
- const img = ctx.createImageData(RADIAL_GLOW_SIZE, RADIAL_GLOW_SIZE);
258
- const data = img.data;
250
+ const raw = /* @__PURE__ */ new Uint8Array(65536);
259
251
  const half = 63.5;
260
252
  const invR = 1 / half;
261
253
  for (let y = 0; y < RADIAL_GLOW_SIZE; y++) for (let x = 0; x < RADIAL_GLOW_SIZE; x++) {
262
254
  const r = Math.hypot(x - half, y - half) * invR;
263
255
  const idx = (y * RADIAL_GLOW_SIZE + x) * 4;
264
- data[idx] = 255;
265
- data[idx + 1] = 255;
266
- data[idx + 2] = 255;
267
- if (r >= 1) data[idx + 3] = 0;
256
+ raw[idx] = 255;
257
+ raw[idx + 1] = 255;
258
+ raw[idx + 2] = 255;
259
+ if (r >= 1) raw[idx + 3] = 0;
268
260
  else {
269
261
  const u = 1 - r;
270
262
  const falloff = u * u * (.78 + .22 * u * u);
271
- data[idx + 3] = Math.round(falloff * 255);
263
+ raw[idx + 3] = Math.round(falloff * 255);
272
264
  }
273
265
  }
274
- ctx.putImageData(img, 0, 0);
275
- ct.refresh();
276
- ct.source[0]?.setFilter(FilterMode.LINEAR);
277
- return true;
266
+ const ct = textures.createCanvas(RADIAL_GLOW_KEY, RADIAL_GLOW_SIZE, RADIAL_GLOW_SIZE);
267
+ const ctx = ct?.canvas.getContext?.("2d");
268
+ if (ct && ctx && typeof ctx.createImageData === "function" && typeof ctx.putImageData === "function") {
269
+ const img = ctx.createImageData(RADIAL_GLOW_SIZE, RADIAL_GLOW_SIZE);
270
+ img.data.set(raw);
271
+ ctx.putImageData(img, 0, 0);
272
+ ct.refresh();
273
+ ct.source[0]?.setFilter(FilterMode.LINEAR);
274
+ return true;
275
+ }
276
+ if (ct) textures.remove(RADIAL_GLOW_KEY);
277
+ const dataTex = textures.addImage(RADIAL_GLOW_KEY, {
278
+ width: RADIAL_GLOW_SIZE,
279
+ height: RADIAL_GLOW_SIZE,
280
+ data: raw
281
+ }, { filterMode: FilterMode.LINEAR });
282
+ return Boolean(dataTex);
278
283
  } catch {
279
284
  if (textures.exists(RADIAL_GLOW_KEY)) textures.remove(RADIAL_GLOW_KEY);
280
285
  return false;
@@ -1,4 +1,4 @@
1
- import { Bn as SceneHostLike, bn as DisplayObject, pn as Container } from "./game-C8bz7tay.js";
1
+ import { Bn as SceneHostLike, bn as DisplayObject, pn as Container } from "./game-rKghsNlA.js";
2
2
  export interface Camera25DConfig {
3
3
  viewportWidth: number;
4
4
  viewportHeight: number;