@almadar/ui 5.142.0 → 5.143.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.
@@ -16269,6 +16269,83 @@ var init_DrawText = __esm({
16269
16269
  };
16270
16270
  }
16271
16271
  });
16272
+ function isAnimatedGroup(node) {
16273
+ return Boolean(node.animation && node.animation.durationMs > 0 && node.animation.keyframes.length > 0);
16274
+ }
16275
+ function DrawGroup(props) {
16276
+ const register = useContext(DrawableRegistryContext);
16277
+ if (register) register({ ...props, type: "draw-group" });
16278
+ return null;
16279
+ }
16280
+ var init_DrawGroup = __esm({
16281
+ "components/game/atoms/DrawGroup.tsx"() {
16282
+ "use client";
16283
+ init_registry();
16284
+ }
16285
+ });
16286
+ function applyMeshAnimation(node, timeMs) {
16287
+ const anim = node.animation;
16288
+ if (!anim || !(anim.durationMs > 0) || anim.keyframes.length === 0) return null;
16289
+ const frames = [...anim.keyframes].sort((a, b) => a.at - b.at);
16290
+ const cycle = timeMs / anim.durationMs;
16291
+ const t = anim.loop === false ? Math.min(cycle, 1) : cycle - Math.floor(cycle);
16292
+ const trackValue = (key) => {
16293
+ const defined = frames.filter((f3) => f3[key] !== void 0);
16294
+ if (defined.length === 0) return void 0;
16295
+ let prev;
16296
+ let next;
16297
+ for (const f3 of defined) {
16298
+ if (f3.at <= t) prev = f3;
16299
+ else if (!next) next = f3;
16300
+ }
16301
+ if (!prev) return defined[0][key];
16302
+ if (!next) return prev[key];
16303
+ const span = next.at - prev.at;
16304
+ const k = span > 0 ? (t - prev.at) / span : 1;
16305
+ const a = prev[key];
16306
+ const b = next[key];
16307
+ if (typeof a === "number" && typeof b === "number") return lerp2(a, b, k);
16308
+ return a;
16309
+ };
16310
+ const num2 = {};
16311
+ for (const key of NUMERIC_TRACKS2) {
16312
+ const v = trackValue(key);
16313
+ if (v !== void 0) num2[key] = v;
16314
+ }
16315
+ return {
16316
+ offset: [num2.offsetX ?? 0, num2.offsetY ?? 0, num2.offsetZ ?? 0],
16317
+ rotate: [num2.rotateX ?? 0, num2.rotateY ?? 0, num2.rotateZ ?? 0],
16318
+ scale: num2.scale ?? 1,
16319
+ opacity: num2.opacity,
16320
+ emissiveIntensity: num2.emissiveIntensity,
16321
+ color: trackValue("color"),
16322
+ emissive: trackValue("emissive")
16323
+ };
16324
+ }
16325
+ function DrawMesh(props) {
16326
+ const register = useContext(DrawableRegistryContext);
16327
+ if (register) register({ ...props, type: "draw-mesh" });
16328
+ return null;
16329
+ }
16330
+ var lerp2, NUMERIC_TRACKS2;
16331
+ var init_DrawMesh = __esm({
16332
+ "components/game/atoms/DrawMesh.tsx"() {
16333
+ "use client";
16334
+ init_registry();
16335
+ lerp2 = (a, b, k) => a + (b - a) * k;
16336
+ NUMERIC_TRACKS2 = [
16337
+ "offsetX",
16338
+ "offsetY",
16339
+ "offsetZ",
16340
+ "rotateX",
16341
+ "rotateY",
16342
+ "rotateZ",
16343
+ "scale",
16344
+ "opacity",
16345
+ "emissiveIntensity"
16346
+ ];
16347
+ }
16348
+ });
16272
16349
 
16273
16350
  // components/game/molecules/DrawSpriteLayer.tsx
16274
16351
  function DrawSpriteLayer(_props) {
@@ -16335,18 +16412,22 @@ function paintDrawable(painter, node, dctx) {
16335
16412
  if (!isValidScenePos(node.position)) break;
16336
16413
  if (!Array.isArray(node.items)) break;
16337
16414
  const p = dctx.projector.project(node.position);
16415
+ const anim = dctx.time > 0 && isAnimatedGroup(node) ? applyMeshAnimation(node, dctx.time) : null;
16416
+ const tw = dctx.projector.tileWidth;
16338
16417
  painter.save();
16339
- painter.translate(p.x, p.y);
16340
- if (node.scale !== void 0) painter.scale(node.scale, node.scale);
16341
- if (node.rotate !== void 0) painter.rotate(node.rotate);
16342
- if (node.opacity !== void 0 && node.opacity !== 1) painter.setAlpha(node.opacity);
16418
+ painter.translate(p.x + (anim ? anim.offset[0] * tw : 0), p.y + (anim ? anim.offset[1] * tw : 0));
16419
+ const scale = (node.scale ?? 1) * (anim?.scale ?? 1);
16420
+ if (scale !== 1) painter.scale(scale, scale);
16421
+ const rotate = (node.rotate ?? 0) + (node.rotation?.[2] ?? 0) + (anim?.rotate[2] ?? 0);
16422
+ if (rotate !== 0) painter.rotate(rotate);
16423
+ const opacity = (node.opacity ?? 1) * (anim?.opacity ?? 1);
16424
+ if (opacity !== 1) painter.setAlpha(opacity);
16343
16425
  if (node.clip) {
16344
- const tw = dctx.projector.tileWidth;
16345
16426
  painter.scale(tw, tw);
16346
16427
  painter.clipPath(node.clip);
16347
16428
  painter.scale(1 / tw, 1 / tw);
16348
16429
  }
16349
- const childCtx = node.scale !== void 0 && node.scale !== 1 ? { ...dctx, groupScale: (dctx.groupScale ?? 1) * node.scale } : dctx;
16430
+ const childCtx = scale !== 1 ? { ...dctx, groupScale: (dctx.groupScale ?? 1) * scale } : dctx;
16350
16431
  for (const item of node.items) paintDrawable(painter, item, childCtx);
16351
16432
  painter.restore();
16352
16433
  break;
@@ -16372,6 +16453,8 @@ var init_paintDispatch = __esm({
16372
16453
  init_DrawSprite();
16373
16454
  init_DrawShape();
16374
16455
  init_DrawText();
16456
+ init_DrawGroup();
16457
+ init_DrawMesh();
16375
16458
  init_DrawSpriteLayer();
16376
16459
  init_DrawShapeLayer();
16377
16460
  init_DrawTextLayer();
@@ -16618,7 +16701,8 @@ function Canvas2D({
16618
16701
  const miniMapHeight = gridExtent.height || 10;
16619
16702
  const drawableIsAnimated = (node) => {
16620
16703
  if (node.type === "draw-shape") return isAnimatedShape(node);
16621
- if (node.type === "draw-group") return Array.isArray(node.items) && node.items.some(drawableIsAnimated);
16704
+ if (node.type === "draw-group")
16705
+ return isAnimatedGroup(node) || Array.isArray(node.items) && node.items.some(drawableIsAnimated);
16622
16706
  if (node.type === "draw-shape-layer") return Array.isArray(node.items) && node.items.some(isAnimatedShape);
16623
16707
  return false;
16624
16708
  };
@@ -16960,6 +17044,7 @@ var init_Canvas2D = __esm({
16960
17044
  init_projector();
16961
17045
  init_paintDispatch();
16962
17046
  init_DrawShape();
17047
+ init_DrawGroup();
16963
17048
  init_registry();
16964
17049
  init_hitTest();
16965
17050
  init_isometric();
@@ -40274,28 +40359,6 @@ var init_DetailPanel = __esm({
40274
40359
  DetailPanel.displayName = "DetailPanel";
40275
40360
  }
40276
40361
  });
40277
- function DrawGroup(props) {
40278
- const register = useContext(DrawableRegistryContext);
40279
- if (register) register({ ...props, type: "draw-group" });
40280
- return null;
40281
- }
40282
- var init_DrawGroup = __esm({
40283
- "components/game/atoms/DrawGroup.tsx"() {
40284
- "use client";
40285
- init_registry();
40286
- }
40287
- });
40288
- function DrawMesh(props) {
40289
- const register = useContext(DrawableRegistryContext);
40290
- if (register) register({ ...props, type: "draw-mesh" });
40291
- return null;
40292
- }
40293
- var init_DrawMesh = __esm({
40294
- "components/game/atoms/DrawMesh.tsx"() {
40295
- "use client";
40296
- init_registry();
40297
- }
40298
- });
40299
40362
  function extractTitle(children) {
40300
40363
  if (!React77__default.isValidElement(children)) return void 0;
40301
40364
  const props = children.props;