@combos-fun/plugin-renderer-3d-sprite-animation 0.0.44 → 0.0.46

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.
Files changed (2) hide show
  1. package/agent-skill.md +28 -35
  2. package/package.json +4 -4
package/agent-skill.md CHANGED
@@ -1,57 +1,50 @@
1
1
  # `@combos-fun/plugin-renderer-3d-sprite-animation` — Agent notes
2
2
 
3
- Spritesheet animation projected onto a `PlaneGeometry` in 3D space. Animates UV offsets each frame. `resource` is an engine **name** (`RESOURCE_TYPE.SPRITE_ANIMATION` with both `src.image` and `src.json`), never a URL.
3
+ Animates spritesheet UVs on a double-sided Three.js plane for effects, animated billboards, and flat characters.
4
4
 
5
- ## When to read
6
-
7
- Read for any 2D-styled animation in a 3D scene: power-up effects, FX sprites, animated billboards, decals.
5
+ Prerequisite: follow the parent `@combos-fun/plugin-renderer-3d` skill for system order, named resources, pose seeding, hierarchy, and stale-async handling.
8
6
 
9
7
  ## Public API
10
8
 
11
9
  ```ts
12
- import { SpriteAnimation3D, SpriteAnimation3DSystem, type SpriteAnimation3DParams } from '@combos-fun/plugin-renderer-3d-sprite-animation';
10
+ import {
11
+ SpriteAnimation3D,
12
+ SpriteAnimation3DSystem,
13
+ type SpriteAnimation3DParams,
14
+ } from '@combos-fun/plugin-renderer-3d-sprite-animation';
13
15
  ```
14
16
 
15
- `componentName = 'SpriteAnimation3D'`, `systemName = 'SpriteAnimation3DSystem'`.
17
+ `componentName = 'SpriteAnimation3D'`; `systemName = 'SpriteAnimation3DSystem'`.
16
18
 
17
- ### `SpriteAnimation3DParams`
19
+ ## Parameters
18
20
 
19
21
  | Field | Type | Default |
20
22
  |-------|------|---------|
21
- | `resource` | `string` | `''` (engine resource name, `RESOURCE_TYPE.SPRITE_ANIMATION`) |
23
+ | `resource` | `string` | `''`; empty on ADD is a silent no-op |
22
24
  | `autoPlay` | `boolean` | `true` |
23
- | `speed` | `number` | `100` (ms per frame) |
24
- | `positionX` / `Y` / `Z` | `number` | `0` |
25
- | `rotationX` / `Y` / `Z` | `number` | `0` |
26
- | `scaleX` / `Y` | `number` | `1` (no `scaleZ` — plane is 2D) |
25
+ | `speed` | `number` | `100` milliseconds per frame |
26
+ | `positionX/Y/Z` | `number` | `0` |
27
+ | `rotationX/Y/Z` | `number` | `0` radians |
28
+ | `scaleX/Y` | `number` | `1` |
27
29
 
28
- The system reads `data.json` (`frames` array or name-map, plus `meta.size` when present) and `data.image`. It does **not** overwrite the 2D Pixi `SPRITE_ANIMATION` instance.
30
+ There is no `scaleZ` and no public `play()`, `stop()`, or `gotoAndPlay()`.
29
31
 
30
- ## Required setup
32
+ ## Resource and lifecycle
31
33
 
32
- `Renderer3DSystem` then `SpriteAnimation3DSystem`. Register both image and json slots:
34
+ A `SPRITE_ANIMATION` resource needs both `src.image` and `src.json`. The system reads `data.image` and a top-level `data.json.frames`; `meta.size` is optional and falls back to image dimensions. It creates its own Three texture and does not overwrite the Pixi resource instance.
33
35
 
34
- ```ts
35
- resource.addResource([{
36
- name: 'explosion',
37
- type: RESOURCE_TYPE.SPRITE_ANIMATION,
38
- src: {
39
- image: { type: 'png', url: 'https://cdn.example/explosion.png' },
40
- json: { type: 'json', url: 'https://cdn.example/explosion.json' },
41
- },
42
- preload: true,
43
- }]);
44
- ```
36
+ Loading is async and validates the request before attachment. Resource replacement/removal invalidates old work and disposes an already-created stale texture. Removing an attached animation disposes geometry, material, and texture.
37
+
38
+ `autoPlay` initializes the private `playing` flag only when the sheet loads; changing `autoPlay` later has no effect. `speed` is read every frame, so runtime changes affect the next frame interval without reloading. Changing `resource` rebuilds the entry.
39
+
40
+ The first frame determines plane aspect ratio. Array frames retain array order; object-map frame keys are sorted lexically.
45
41
 
46
- ## Common pitfalls
42
+ ## Package-specific pitfalls
47
43
 
48
- | Symptom | Fix |
49
- |---------|-----|
50
- | `Unknown resource` / missing json | Register `RESOURCE_TYPE.SPRITE_ANIMATION` with both `image` and `json` slots; do not pass a JSON URL to `resource` |
51
- | Animation never starts | `autoPlay` defaults to `true` |
52
- | Black plane / load error | JSON must have top-level `frames`; `meta.size` is optional (falls back to image size) |
53
- | Frames in wrong order | Hash `frames` keys are `Object.keys().sort()`; prefer array `frames` for playback order |
54
- | Stuck on first frame | Single-frame sheet; verify the JSON contains multiple frame entries |
44
+ - Missing JSON, missing frames, or malformed `{ frame: { x, y, w, h } }` entries fail loading.
45
+ - A one-frame sheet appears static.
46
+ - Use an array when lexical filename sorting is not the desired sequence.
47
+ - `speed` is a frame duration, not an FPS multiplier.
55
48
 
56
49
  ## Minimal example
57
50
 
@@ -67,4 +60,4 @@ fx.addComponent(new SpriteAnimation3D({
67
60
 
68
61
  ## Verification
69
62
 
70
- `pnpm --filter @combos-fun/plugin-renderer-3d-sprite-animation run build`.
63
+ `pnpm --filter @combos-fun/plugin-renderer-3d-sprite-animation run build`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@combos-fun/plugin-renderer-3d-sprite-animation",
3
- "version": "0.0.44",
3
+ "version": "0.0.46",
4
4
  "description": "Spritesheet animation projected onto a PlaneGeometry in 3D space",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-3d-sprite-animation.esm.js",
@@ -27,9 +27,9 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "three": "^0.172.0",
30
- "@combos-fun/engine": "0.0.44",
31
- "@combos-fun/inspector-decorator": "0.0.44",
32
- "@combos-fun/plugin-renderer-3d": "0.0.44"
30
+ "@combos-fun/engine": "0.0.46",
31
+ "@combos-fun/inspector-decorator": "0.0.46",
32
+ "@combos-fun/plugin-renderer-3d": "0.0.46"
33
33
  },
34
34
  "keywords": [
35
35
  "combos-fun",