pixi-marrow 0.0.0-stage → 0.1.0-next.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/CHANGELOG.md +69 -0
- package/LICENSE +26 -0
- package/README.md +163 -2
- package/bin/pixi-marrow.mjs +25 -0
- package/dist/api/asset.d.ts +183 -0
- package/dist/api/asset.js +315 -0
- package/dist/api/assets.d.ts +52 -0
- package/dist/api/assets.js +208 -0
- package/dist/api/bone.d.ts +61 -0
- package/dist/api/bone.js +110 -0
- package/dist/api/cache-hook.js +21 -0
- package/dist/api/checks.js +71 -0
- package/dist/api/events.d.ts +23 -0
- package/dist/api/events.js +56 -0
- package/dist/api/links.d.ts +61 -0
- package/dist/api/links.js +150 -0
- package/dist/api/memory.js +71 -0
- package/dist/api/options.d.ts +176 -0
- package/dist/api/outline-scan.js +66 -0
- package/dist/api/perf-read.js +49 -0
- package/dist/api/play-fields.js +118 -0
- package/dist/api/report-base.d.ts +17 -0
- package/dist/api/report-base.js +24 -0
- package/dist/api/report-cuts.js +123 -0
- package/dist/api/report.js +313 -0
- package/dist/api/spine-links.d.ts +74 -0
- package/dist/api/spine-links.js +108 -0
- package/dist/api/spine-perf.d.ts +97 -0
- package/dist/api/spine-perf.js +56 -0
- package/dist/api/spine.d.ts +237 -0
- package/dist/api/spine.js +407 -0
- package/dist/api/textures.js +157 -0
- package/dist/api/track-book.js +85 -0
- package/dist/api/track.d.ts +46 -0
- package/dist/api/track.js +125 -0
- package/dist/base/errors.d.ts +33 -0
- package/dist/base/errors.js +30 -0
- package/dist/base/names.js +70 -0
- package/dist/base/version.d.ts +4 -0
- package/dist/base/version.js +8 -0
- package/dist/core.d.ts +23 -0
- package/dist/core.js +16 -0
- package/dist/formats/atlas.d.ts +10 -0
- package/dist/formats/atlas.js +164 -0
- package/dist/formats/binary42/animation.js +136 -0
- package/dist/formats/binary42/attachment-parts.js +166 -0
- package/dist/formats/binary42/attachment-timelines.js +112 -0
- package/dist/formats/binary42/attachments41.js +107 -0
- package/dist/formats/binary42/attachments42.js +102 -0
- package/dist/formats/binary42/constraint-timelines.js +164 -0
- package/dist/formats/binary42/constraints.js +255 -0
- package/dist/formats/binary42/curves.js +83 -0
- package/dist/formats/binary42/index.js +53 -0
- package/dist/formats/binary42/pose-timelines.js +106 -0
- package/dist/formats/binary42/skeleton.js +151 -0
- package/dist/formats/binary42/skins.js +117 -0
- package/dist/formats/binary42/state.js +33 -0
- package/dist/formats/binary43/animations.js +36 -0
- package/dist/formats/binary43/attachments.js +253 -0
- package/dist/formats/binary43/constraints.js +275 -0
- package/dist/formats/binary43/index.js +53 -0
- package/dist/formats/binary43/reader.js +40 -0
- package/dist/formats/binary43/skeleton.js +142 -0
- package/dist/formats/binary43/skins.js +97 -0
- package/dist/formats/binary43/timelines-attachment.js +112 -0
- package/dist/formats/binary43/timelines-constraint.js +146 -0
- package/dist/formats/binary43/timelines-curve.js +93 -0
- package/dist/formats/binary43/timelines-order.js +116 -0
- package/dist/formats/binary43/timelines-slot-bone.js +92 -0
- package/dist/formats/import.d.ts +15 -0
- package/dist/formats/import.js +44 -0
- package/dist/formats/json42/animations.js +39 -0
- package/dist/formats/json42/attachments.js +174 -0
- package/dist/formats/json42/constraints.js +139 -0
- package/dist/formats/json42/context.js +15 -0
- package/dist/formats/json42/curves.js +123 -0
- package/dist/formats/json42/index.js +64 -0
- package/dist/formats/json42/skeleton.js +115 -0
- package/dist/formats/json42/skins.js +105 -0
- package/dist/formats/json42/timelines-attachment.js +126 -0
- package/dist/formats/json42/timelines-bone.js +85 -0
- package/dist/formats/json42/timelines-constraint.js +143 -0
- package/dist/formats/json42/timelines-order.js +85 -0
- package/dist/formats/json42/timelines-slot.js +86 -0
- package/dist/formats/json42/values.js +113 -0
- package/dist/formats/json43/animations.js +40 -0
- package/dist/formats/json43/attachments.js +171 -0
- package/dist/formats/json43/constraints.js +227 -0
- package/dist/formats/json43/context.js +94 -0
- package/dist/formats/json43/index.js +56 -0
- package/dist/formats/json43/skeleton.js +94 -0
- package/dist/formats/json43/skins.js +94 -0
- package/dist/formats/json43/timelines-attachment.js +132 -0
- package/dist/formats/json43/timelines-constraint.js +109 -0
- package/dist/formats/json43/timelines-curve.js +94 -0
- package/dist/formats/json43/timelines-order.js +106 -0
- package/dist/formats/json43/timelines-slot-bone.js +129 -0
- package/dist/formats/shared/binary-input.js +91 -0
- package/dist/formats/shared/color.js +26 -0
- package/dist/formats/shared/timeline-writer.js +111 -0
- package/dist/formats/sniff.d.ts +21 -0
- package/dist/formats/sniff.js +63 -0
- package/dist/geometry/atlas-regions.d.ts +83 -0
- package/dist/geometry/atlas-regions.js +124 -0
- package/dist/geometry/clip-triangles-cut.js +236 -0
- package/dist/geometry/clip-triangles-parts.js +334 -0
- package/dist/geometry/clip-triangles-store.js +160 -0
- package/dist/geometry/clip-triangles-verdict.js +132 -0
- package/dist/geometry/clip-triangles.js +193 -0
- package/dist/geometry/convex.js +307 -0
- package/dist/geometry/mesh.d.ts +26 -0
- package/dist/geometry/mesh.js +78 -0
- package/dist/geometry/occlusion.js +35 -0
- package/dist/geometry/opaque-rect.js +82 -0
- package/dist/geometry/outline-vertices.js +50 -0
- package/dist/geometry/outlines.d.ts +84 -0
- package/dist/geometry/outlines.js +213 -0
- package/dist/geometry/region.d.ts +55 -0
- package/dist/geometry/region.js +100 -0
- package/dist/geometry/tight.js +183 -0
- package/dist/geometry/triangulator.js +122 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +5 -0
- package/dist/model/atlas.d.ts +43 -0
- package/dist/model/atlas.js +13 -0
- package/dist/model/attachments.d.ts +118 -0
- package/dist/model/constraints.d.ts +140 -0
- package/dist/model/info.d.ts +58 -0
- package/dist/model/info.js +105 -0
- package/dist/model/model.d.ts +116 -0
- package/dist/model/model.js +19 -0
- package/dist/model/outlines.d.ts +46 -0
- package/dist/model/timelines.d.ts +49 -0
- package/dist/optimize/cli.d.ts +20 -0
- package/dist/optimize/cli.js +101 -0
- package/dist/optimize/png.d.ts +21 -0
- package/dist/optimize/png.js +244 -0
- package/dist/optimize/typegen.d.ts +24 -0
- package/dist/optimize/typegen.js +38 -0
- package/dist/optimize.d.ts +9 -0
- package/dist/optimize.js +5 -0
- package/dist/perf/probe.d.ts +129 -0
- package/dist/perf/probe.js +167 -0
- package/dist/perf.d.ts +6 -0
- package/dist/perf.js +1 -0
- package/dist/pose/engine.d.ts +141 -0
- package/dist/pose/engine.js +34 -0
- package/dist/pose/legacy/applied.js +185 -0
- package/dist/pose/legacy/apply-timeline.js +102 -0
- package/dist/pose/legacy/apply.js +308 -0
- package/dist/pose/legacy/bones.js +236 -0
- package/dist/pose/legacy/cache.js +162 -0
- package/dist/pose/legacy/colors.js +112 -0
- package/dist/pose/legacy/constraint-timelines.js +91 -0
- package/dist/pose/legacy/constraints.js +278 -0
- package/dist/pose/legacy/curves.js +176 -0
- package/dist/pose/legacy/deform.js +126 -0
- package/dist/pose/legacy/entry.js +153 -0
- package/dist/pose/legacy/groups.js +143 -0
- package/dist/pose/legacy/hold.js +58 -0
- package/dist/pose/legacy/ik.js +15 -0
- package/dist/pose/legacy/ik1.js +120 -0
- package/dist/pose/legacy/ik2.js +280 -0
- package/dist/pose/legacy/index.js +198 -0
- package/dist/pose/legacy/math.js +21 -0
- package/dist/pose/legacy/pass.js +400 -0
- package/dist/pose/legacy/path-curves.js +166 -0
- package/dist/pose/legacy/path-positions.js +227 -0
- package/dist/pose/legacy/path-scratch.js +27 -0
- package/dist/pose/legacy/path.js +170 -0
- package/dist/pose/legacy/physics-rest.js +197 -0
- package/dist/pose/legacy/physics-state.js +63 -0
- package/dist/pose/legacy/physics-timelines.js +111 -0
- package/dist/pose/legacy/physics.js +307 -0
- package/dist/pose/legacy/player.js +204 -0
- package/dist/pose/legacy/rest.js +133 -0
- package/dist/pose/legacy/rig.js +221 -0
- package/dist/pose/legacy/rotate.js +119 -0
- package/dist/pose/legacy/skeleton.js +89 -0
- package/dist/pose/legacy/slots.js +149 -0
- package/dist/pose/legacy/solver.js +76 -0
- package/dist/pose/legacy/stamps.js +28 -0
- package/dist/pose/legacy/still.js +41 -0
- package/dist/pose/legacy/timelines.js +61 -0
- package/dist/pose/legacy/transform.js +222 -0
- package/dist/pose/legacy/update.js +86 -0
- package/dist/pose/legacy/world.js +253 -0
- package/dist/pose/shared/lookup.d.ts +34 -0
- package/dist/pose/shared/lookup.js +59 -0
- package/dist/pose/shared/read.d.ts +2 -0
- package/dist/pose/shared/read.js +51 -0
- package/dist/pose/shared/vertices.d.ts +26 -0
- package/dist/pose/shared/vertices.js +116 -0
- package/dist/pose/state.d.ts +127 -0
- package/dist/pose/state.js +97 -0
- package/dist/pose/v43/apply-events.js +76 -0
- package/dist/pose/v43/apply.js +353 -0
- package/dist/pose/v43/bone-pose.js +255 -0
- package/dist/pose/v43/cache.js +308 -0
- package/dist/pose/v43/commands.js +147 -0
- package/dist/pose/v43/configure.js +75 -0
- package/dist/pose/v43/curves.js +126 -0
- package/dist/pose/v43/entry.js +103 -0
- package/dist/pose/v43/hold.js +91 -0
- package/dist/pose/v43/ik-one.js +105 -0
- package/dist/pose/v43/ik-two.js +242 -0
- package/dist/pose/v43/ik.js +14 -0
- package/dist/pose/v43/index.js +179 -0
- package/dist/pose/v43/math.js +23 -0
- package/dist/pose/v43/path-positions.js +350 -0
- package/dist/pose/v43/path.js +191 -0
- package/dist/pose/v43/physics-rest.js +76 -0
- package/dist/pose/v43/physics.js +411 -0
- package/dist/pose/v43/plan-checks.js +36 -0
- package/dist/pose/v43/player.js +129 -0
- package/dist/pose/v43/pose.js +147 -0
- package/dist/pose/v43/rest.js +81 -0
- package/dist/pose/v43/rig.js +357 -0
- package/dist/pose/v43/skeleton.js +65 -0
- package/dist/pose/v43/slider-plan.js +125 -0
- package/dist/pose/v43/slider.js +56 -0
- package/dist/pose/v43/slots.js +92 -0
- package/dist/pose/v43/solve-step.js +42 -0
- package/dist/pose/v43/solve-tight.js +166 -0
- package/dist/pose/v43/solve.js +151 -0
- package/dist/pose/v43/solver.js +277 -0
- package/dist/pose/v43/split.js +281 -0
- package/dist/pose/v43/timelines-bone.js +124 -0
- package/dist/pose/v43/timelines-constraint.js +86 -0
- package/dist/pose/v43/timelines-deform.js +219 -0
- package/dist/pose/v43/timelines-misc.js +166 -0
- package/dist/pose/v43/timelines-physics.js +102 -0
- package/dist/pose/v43/timelines-slot.js +129 -0
- package/dist/pose/v43/timelines.js +86 -0
- package/dist/pose/v43/transform.js +254 -0
- package/dist/pose/v43/update.js +91 -0
- package/dist/pose/v43/world.js +171 -0
- package/dist/render/attach-code.d.ts +2 -0
- package/dist/render/attach-code.js +44 -0
- package/dist/render/attach-work.d.ts +70 -0
- package/dist/render/attach-work.js +208 -0
- package/dist/render/batch-body.d.ts +39 -0
- package/dist/render/batch-body.js +57 -0
- package/dist/render/batch-clip.js +296 -0
- package/dist/render/batch-cut.js +44 -0
- package/dist/render/batch-element.d.ts +220 -0
- package/dist/render/batch-element.js +320 -0
- package/dist/render/batch-layout.d.ts +14 -0
- package/dist/render/batch-layout.js +57 -0
- package/dist/render/batch-pack.d.ts +46 -0
- package/dist/render/batch-pack.js +226 -0
- package/dist/render/batch-pipe.js +115 -0
- package/dist/render/batch-shader.js +203 -0
- package/dist/render/batch-upload.js +97 -0
- package/dist/render/batcher.js +409 -0
- package/dist/render/bounds.js +43 -0
- package/dist/render/clip-check.js +19 -0
- package/dist/render/clip-code.js +40 -0
- package/dist/render/clip-mask.js +155 -0
- package/dist/render/clip-shape.d.ts +75 -0
- package/dist/render/clip-shape.js +282 -0
- package/dist/render/colors.js +123 -0
- package/dist/render/context-watch.js +36 -0
- package/dist/render/cover-search.d.ts +1 -0
- package/dist/render/cover-search.js +322 -0
- package/dist/render/cover.d.ts +47 -0
- package/dist/render/cover.js +67 -0
- package/dist/render/cut-code.d.ts +2 -0
- package/dist/render/cut-code.js +55 -0
- package/dist/render/cut-state.d.ts +89 -0
- package/dist/render/cut-state.js +131 -0
- package/dist/render/cut-work.d.ts +1 -0
- package/dist/render/cut-work.js +134 -0
- package/dist/render/cuts.d.ts +14 -0
- package/dist/render/cuts.js +8 -0
- package/dist/render/drafts.d.ts +3 -0
- package/dist/render/drafts.js +107 -0
- package/dist/render/entry-pose.js +78 -0
- package/dist/render/gate.d.ts +17 -0
- package/dist/render/gate.js +44 -0
- package/dist/render/inspect.d.ts +30 -0
- package/dist/render/inspect.js +174 -0
- package/dist/render/layouts.js +109 -0
- package/dist/render/measured-geometry.d.ts +1 -0
- package/dist/render/measured-geometry.js +23 -0
- package/dist/render/mesh-code.d.ts +1 -0
- package/dist/render/mesh-code.js +55 -0
- package/dist/render/mesh-paint.d.ts +63 -0
- package/dist/render/mesh-paint.js +133 -0
- package/dist/render/mesh-pipe.js +32 -0
- package/dist/render/mode.d.ts +12 -0
- package/dist/render/mode.js +84 -0
- package/dist/render/page-alpha.js +139 -0
- package/dist/render/page-block.d.ts +1 -0
- package/dist/render/page-block.js +34 -0
- package/dist/render/pages.js +34 -0
- package/dist/render/paints.d.ts +89 -0
- package/dist/render/paints.js +116 -0
- package/dist/render/pose-pass.d.ts +29 -0
- package/dist/render/pose-pass.js +168 -0
- package/dist/render/range-mesh.d.ts +11 -0
- package/dist/render/range-mesh.js +83 -0
- package/dist/render/ranges.d.ts +131 -0
- package/dist/render/ranges.js +350 -0
- package/dist/render/read.js +24 -0
- package/dist/render/shader.js +360 -0
- package/dist/render/skeleton-view.d.ts +201 -0
- package/dist/render/skeleton-view.js +424 -0
- package/dist/render/stats.d.ts +81 -0
- package/dist/render/stats.js +32 -0
- package/dist/render/template.d.ts +89 -0
- package/dist/render/template.js +223 -0
- package/dist/render/visible.d.ts +94 -0
- package/dist/render/visible.js +221 -0
- package/package.json +86 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# pixi-marrow
|
|
2
|
+
|
|
3
|
+
## 0.1.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#8](https://github.com/schmooky/pixi-marrow/pull/8) [`2a94aee`](https://github.com/schmooky/pixi-marrow/commit/2a94aeec08a98d9370c3be7f65fd665436a6b081) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Bone handles and containers in a skeleton. `hero.bone(name)` reads and writes the pose of a bone and reads its place in the skeleton. `hero.follow(bone, container)` moves a Pixi container with a bone. `hero.attach(slot, container)` draws a container at the place of a slot in the draw order and moves it with the bone of the slot, as `addSlotObject` of the official runtime does. `unfollow` and `detach` end it. The perf report has a row `links`.
|
|
8
|
+
|
|
9
|
+
Fixed: in a game whose bundle is tree-shaken and imports no Pixi `Mesh` of its own, the mesh mode threw when its code loaded after the renderer was created. It now gives the renderer the mesh pipe it lacks.
|
|
10
|
+
|
|
11
|
+
Fixed: the engine for Spine 4.1 and 4.2 lost a write to a bone from outside when `setSkin` was called with the skin that was set already, before the next update.
|
|
12
|
+
|
|
13
|
+
- [#1](https://github.com/schmooky/pixi-marrow/pull/1) [`06a882c`](https://github.com/schmooky/pixi-marrow/commit/06a882ce98a230806a6e186c6db5ef078dc9be9a) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Import Spine 4.1, 4.2 and 4.3 skeletons (JSON and binary) and texture atlases into a model, with `importSkeleton` and `importAtlas` from `pixi-marrow/core`. Add `describeSkeleton`, and `generateNames` plus the `pixi-marrow` command line tool (`info`, `typegen`) in `pixi-marrow/optimize`.
|
|
14
|
+
|
|
15
|
+
- [#2](https://github.com/schmooky/pixi-marrow/pull/2) [`825fe74`](https://github.com/schmooky/pixi-marrow/commit/825fe7432730c4295c4c691afd4c353026f8835b) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Play skeletons without a renderer. `createPoseEngine` from `pixi-marrow/core` gives a pose engine for Spine 4.1, 4.2 and 4.3 with tracks, queue, mixing, skins and events. Its pose equals the official runtime exactly. Constraints are not solved yet. Add the geometry functions that turn a pose into vertex positions and texture coordinates. Setup values in the model are now 64-bit.
|
|
16
|
+
|
|
17
|
+
- [#3](https://github.com/schmooky/pixi-marrow/pull/3) [`46c686e`](https://github.com/schmooky/pixi-marrow/commit/46c686e930b3d8cabf2daa05bc7316f970e12f3c) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Draw skeletons in PixiJS v8. `MarrowSpine` from `pixi-marrow` loads a skeleton and its atlas, plays animations with `play`, `queue` and `stop`, and draws in one draw call for most skeletons, on WebGL2 and WebGPU. Additive slots share the draw call. Showing, hiding and reordering slots rewrites the index buffer only. Constraints and clipping are not solved yet.
|
|
18
|
+
|
|
19
|
+
- [#4](https://github.com/schmooky/pixi-marrow/pull/4) [`5673491`](https://github.com/schmooky/pixi-marrow/commit/567349174f6f974879b7ef1ab1c719c5f6ca2552) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Solve IK, transform and path constraints for Spine 4.1, 4.2 and 4.3, with the same pose as the official runtime, bit for bit. `constraints: 'ignore'` now skips physics and slider constraints only, and only those throw without it.
|
|
20
|
+
|
|
21
|
+
Clipping attachments clip, through a stencil mask. A skeleton without a clip pays nothing for it.
|
|
22
|
+
|
|
23
|
+
Cut overdraw. After a load the page images are read in idle time (`asset.optimized` resolves when that is done). A region without a visible pixel is then not drawn, and a slot behind the opaque part of a later slot is skipped, with the same picture. The new option `tightMesh: 'on'` also draws regions as polygons around their visible pixels. The new command `pixi-marrow outlines <atlas>` writes the outlines at build time, for the new load option `outlines`.
|
|
24
|
+
|
|
25
|
+
`stats` has new counters: `clips`, `maskDraws`, `maskUploads`, `maskRebuilds`, `tightRanges` and `coveredSlots`. `clippingIgnored` is gone.
|
|
26
|
+
|
|
27
|
+
- [#5](https://github.com/schmooky/pixi-marrow/pull/5) [`159e97f`](https://github.com/schmooky/pixi-marrow/commit/159e97f43754f95757cd030ac85cf99119b21374) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Solve physics constraints (Spine 4.2 and 4.3) and sliders (4.3), with the same pose as the official runtime, bit for bit. Every constraint of the three versions is solved now. The load option `constraints` and the option of `createPoseEngine` are gone: there is nothing left to ignore.
|
|
28
|
+
|
|
29
|
+
Physics control on the display object: `physics` (`update`, `pose`, `reset`, `none`), `resetPhysics()`, `physicsTranslate(x, y)` and `physicsRotate(x, y, degrees)`. On a pose engine: `physics`, `physicsTranslate`, `physicsRotate`, and in its state `yDown`, `windX`, `windY`, `gravityX` and `gravityY`.
|
|
30
|
+
|
|
31
|
+
More play options: `additive`, `start`, `end`, `shortestRotation`, `eventThreshold`, and `entry` for any other field of the official track entry by its official name. `Track` has `configure(fields)` and `additive`. Options are checked before anything plays.
|
|
32
|
+
|
|
33
|
+
`await spine.perf.report()` lists what the runtime decided for an instance and why. `await spine.perf.memory()` gives the bytes shared per asset, per instance and on the GPU. Both load their code at the first call.
|
|
34
|
+
|
|
35
|
+
The new entry `pixi-marrow/perf` has `createProbe(spine)`: it times the pose, geometry and event work of every update and counts what the renderer did.
|
|
36
|
+
|
|
37
|
+
- [#6](https://github.com/schmooky/pixi-marrow/pull/6) [`52cd049`](https://github.com/schmooky/pixi-marrow/commit/52cd049b127a560c53538b311bd0b52f69605923) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - A batched render mode: skeletons of one render group share draw calls. 200 instances of a small rig draw in one call, where each took one or more before. The new option and property `renderMode` is `auto` by default, which batches every skeleton of up to 1024 vertices. `mesh` and `batched` force one side. `stats.renderMode` and a row of `await spine.perf.report()` name the mode in use and the reason.
|
|
38
|
+
|
|
39
|
+
In batched mode a draw order, visibility, attachment or color change rewrites data in place. Pixi does not rebuild the instructions of the render group for it.
|
|
40
|
+
|
|
41
|
+
Clipping no longer stops batching. In batched mode a clip is cut on the CPU, with the same triangles as the official runtime, bit for bit. The code for it loads with an asset that has a clipping attachment. Mesh mode keeps its stencil mask.
|
|
42
|
+
|
|
43
|
+
Less memory per instance. The static part of a layout is shared between the instances of an asset, and one shader serves all views of the same pages. A batched instance holds no Pixi mesh, geometry or buffer of its own.
|
|
44
|
+
|
|
45
|
+
The clip polygon of a region without weights or deform is triangulated once per attachment, not on every update.
|
|
46
|
+
|
|
47
|
+
Fixed: 1200 instances of a rig with a clip no longer fail on WebGPU with `ubo batch got too big`. They draw in one call.
|
|
48
|
+
|
|
49
|
+
- [#7](https://github.com/schmooky/pixi-marrow/pull/7) [`eeb8673`](https://github.com/schmooky/pixi-marrow/commit/eeb867354245fce06b4c72ef84955fed9cd50f4f) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Work follows change. A skeleton at rest costs close to nothing: its update runs no timeline, poses no bone, places no vertex and uploads nothing. A skeleton that moves a little costs a little: only the bones whose inputs changed are posed, and only the slots that changed are placed, colored and uploaded.
|
|
50
|
+
|
|
51
|
+
A pose state carries what changed: `version`, `boneStamps`, `slotStamps` and `drawOrderStamp`, with `isNewer`, `nextVersion` and `touchPose` in `pixi-marrow/core`. Code that writes the arrays of a pose state itself now calls `touchPose(state)` or sets the stamps of what it wrote. The engines and the views skip their work otherwise.
|
|
52
|
+
|
|
53
|
+
The root import is smaller. The mesh mode, the clip code and the cuts of overdraw load when a skeleton needs them. The new load option `renderMode: 'mesh'` loads the mesh mode with the asset. An instance that asks for meshes before they are loaded draws in the batch until they arrive.
|
|
54
|
+
|
|
55
|
+
`await spine.perf.report()` has a row `motion`: how much of the skeleton moved in the last update and whether the view rested. `stats` has `skips`, `placedSlots` and `coloredSlots`, and the probe counts `skippedUpdates` and `placedSlots`.
|
|
56
|
+
|
|
57
|
+
Fixed: the mesh mode drew stale triangles on pixi.js before 8.20 after a skin change, or after two updates between two draws. Partial uploads are used from pixi.js 8.23 only: 8.20 to 8.22 lose all but the last one of a frame.
|
|
58
|
+
|
|
59
|
+
- Load skeletons through Pixi `Assets`. `registerMarrowAssets()` adds parsers for `.skel` files, Spine `.json` files and `.atlas` files, so aliases, manifests and bundles load them, as AssetPack writes them. `MarrowSpine.from({ skeleton, atlas })` and `MarrowAsset.get` take the aliases and return at once. An atlas named like `hero@0.5x.webp.atlas` counts as resolution 0.5 in WebP for `texturePreference`. The `data` of an atlas takes `images` and `imageMetadata`, as in the official runtime. Unloading an atlas destroys the assets made from it.
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- First pre-release on npm, under the Spine Runtimes License in `LICENSE`. The pose core is ported from the official Spine Runtimes. Each user of pixi-marrow needs their own Spine Editor licence, as for the official runtimes.
|
|
64
|
+
|
|
65
|
+
- [#10](https://github.com/schmooky/pixi-marrow/pull/10) [`140194e`](https://github.com/schmooky/pixi-marrow/commit/140194e07a08d66b878a13bfd3558617aeafe56c) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fixed: a skeleton that was first drawn while the WebGL context was lost stayed invisible after the context came back. On pixi.js 8.16 it threw inside the render. A skeleton now draws nothing while the context of its renderer is lost, and draws again with the context that comes back. Skeletons that were drawn before the loss came back before this change and still do, at rest too.
|
|
66
|
+
|
|
67
|
+
The pixel check now loses and restores the context of a running game in both render modes, see `scripts/render/restore-check.mjs`.
|
|
68
|
+
|
|
69
|
+
- [#9](https://github.com/schmooky/pixi-marrow/pull/9) [`91de488`](https://github.com/schmooky/pixi-marrow/commit/91de488eb1da4d4aa4422e76b352c143230f8b68) Thanks [@igaming-bulochka](https://github.com/igaming-bulochka)! - Fixed: a display object whose asset was destroyed threw a `TypeError` from Pixi's shared ticker, which then stopped for every skeleton of the page. Its `update` now does nothing, and `autoUpdate` turns off. Destroy the display objects of an asset before the asset, as before.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Spine Runtimes License Agreement
|
|
2
|
+
Last updated April 5, 2025. Replaces all prior versions.
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2013-2025, Esoteric Software LLC
|
|
5
|
+
|
|
6
|
+
Integration of the Spine Runtimes into software or otherwise creating
|
|
7
|
+
derivative works of the Spine Runtimes is permitted under the terms and
|
|
8
|
+
conditions of Section 2 of the Spine Editor License Agreement:
|
|
9
|
+
http://esotericsoftware.com/spine-editor-license
|
|
10
|
+
|
|
11
|
+
Otherwise, it is permitted to integrate the Spine Runtimes into software
|
|
12
|
+
or otherwise create derivative works of the Spine Runtimes (collectively,
|
|
13
|
+
"Products"), provided that each user of the Products must obtain their own
|
|
14
|
+
Spine Editor license and redistribution of the Products in any form must
|
|
15
|
+
include this license and copyright notice.
|
|
16
|
+
|
|
17
|
+
THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
|
18
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
|
21
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
22
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
|
23
|
+
BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
|
24
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
26
|
+
THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,164 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pixi-marrow
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Spine runtime for PixiJS v8 with its own pose core. It plays Spine 4.1, 4.2 and 4.3 skeletons.
|
|
4
|
+
|
|
5
|
+
<!-- facts:status -->
|
|
6
|
+
Pre-release, published as `pixi-marrow@next`. Skeletons of Spine 4.1, 4.2 and 4.3 load, play and draw in PixiJS v8 with every constraint solved: IK, transform, path, physics and sliders. The poses equal the official cores to the bit, and the picture matches the official Pixi runtime. Small skeletons share draw calls, and a skeleton at rest costs close to nothing.
|
|
7
|
+
<!-- /facts:status -->
|
|
8
|
+
|
|
9
|
+
The plan is in [docs/DESIGN.md](docs/DESIGN.md).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install pixi-marrow@next pixi.js
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
It needs pixi.js 8.16 or later. Docs and live previews are at [pixi-marrow.schmooky.dev](https://pixi-marrow.schmooky.dev).
|
|
18
|
+
|
|
19
|
+
## Use
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { MarrowSpine } from 'pixi-marrow';
|
|
23
|
+
|
|
24
|
+
const hero = await MarrowSpine.load({ skeleton: 'hero.skel', atlas: 'hero.atlas' });
|
|
25
|
+
|
|
26
|
+
app.stage.addChild(hero);
|
|
27
|
+
hero.play('run', { loop: true });
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Every constraint is solved: IK, transform, path, physics and sliders. Clipping works.
|
|
31
|
+
|
|
32
|
+
## Pixi Assets and AssetPack
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { Assets } from 'pixi.js';
|
|
36
|
+
import { MarrowSpine, registerMarrowAssets } from 'pixi-marrow';
|
|
37
|
+
|
|
38
|
+
registerMarrowAssets();
|
|
39
|
+
await Assets.load(['hero.skel', 'hero.atlas']);
|
|
40
|
+
|
|
41
|
+
const hero = MarrowSpine.from({ skeleton: 'hero.skel', atlas: 'hero.atlas' });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`registerMarrowAssets` teaches Pixi `Assets` to load `.skel` files, Spine `.json` files and `.atlas` files. Call it once, before the first load. Then aliases, manifests and bundles load them too, as AssetPack writes them. `MarrowSpine.from` takes the aliases and returns at once.
|
|
45
|
+
|
|
46
|
+
An atlas named like `hero@0.5x.webp.atlas` counts as resolution 0.5 in WebP, so `texturePreference` picks among its variants. The `data` of an atlas takes `images` and `imageMetadata`, as in the official runtime.
|
|
47
|
+
|
|
48
|
+
Unloading an atlas destroys the assets made from it, so destroy their display objects first. Do not register another Spine runtime in the same game: both claim the same file extensions.
|
|
49
|
+
|
|
50
|
+
## Tracks and physics
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
hero.play('aim', { track: 1, additive: true, alpha: 0.5 });
|
|
54
|
+
hero.play('walk', { start: 0.2, end: 1.1, entry: { mixDrawOrderThreshold: 0.5 } });
|
|
55
|
+
|
|
56
|
+
hero.physics = 'pose';
|
|
57
|
+
hero.resetPhysics();
|
|
58
|
+
hero.physicsTranslate(dx, dy);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`entry` and `track.configure` take any field of the official `TrackEntry` by its official name. `physics` is the official mode: `update`, `pose`, `reset` or `none`. Physics does not follow the Pixi position by itself: tell it with `physicsTranslate` and `physicsRotate`.
|
|
62
|
+
|
|
63
|
+
## Bones and placeholders
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
const head = hero.bone('head');
|
|
67
|
+
console.log(head.worldX, head.worldY);
|
|
68
|
+
head.rotation += 15;
|
|
69
|
+
|
|
70
|
+
hero.addChild(flash);
|
|
71
|
+
hero.follow('gun', flash);
|
|
72
|
+
|
|
73
|
+
hero.attach('placeholder', symbol);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`bone` gives a handle: the pose next to the parent bone to read and write, and the place in the skeleton to read. `follow` moves a container with a bone. `attach` draws a container at the place of a slot in the draw order, between the parts of the skeleton, and moves it with the bone of the slot. An attached container costs one draw call.
|
|
77
|
+
|
|
78
|
+
## Many skeletons
|
|
79
|
+
|
|
80
|
+
Skeletons of up to 1024 vertices share draw calls: 200 instances of a small rig draw in one call. Nothing to set up. A Pixi object between two skeletons in draw order ends a batch, so keep skeletons next to each other in the display list where you can.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const boss = await MarrowSpine.load({ skeleton: 'boss.skel', atlas: 'boss.atlas', renderMode: 'mesh' });
|
|
84
|
+
console.log(boss.stats.renderMode);
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`renderMode` is `auto` by default. `mesh` draws a skeleton with meshes of its own, which pays for large rigs. `batched` forces the batch.
|
|
88
|
+
|
|
89
|
+
## Skeletons at rest
|
|
90
|
+
|
|
91
|
+
A skeleton whose animation ended, or that never played one, costs close to nothing: no timeline runs, no vertex is placed, nothing is uploaded. It wakes with the next `play`. Physics is the exception: a skeleton with physics constraints keeps simulating, as in the official runtime.
|
|
92
|
+
|
|
93
|
+
## Why is it slow
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
console.table(await hero.perf.report());
|
|
97
|
+
console.log(await hero.perf.memory());
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The report lists what the runtime decided for this instance and why: draw calls, blend ranges, tight meshes, covered slots, clipping, physics and more. For timings, `createProbe(hero)` from `pixi-marrow/perf` measures the pose, geometry and event work of every update.
|
|
101
|
+
|
|
102
|
+
## Less overdraw
|
|
103
|
+
|
|
104
|
+
After a load the page images are read in idle time. From then on a region without a visible pixel is not drawn, and a slot behind the opaque part of a later slot is skipped. The picture stays the same, bit for bit.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
const hero = await MarrowSpine.load({ skeleton: 'hero.skel', atlas: 'hero.atlas', tightMesh: 'on' });
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`tightMesh: 'on'` also draws every region as the polygon around its visible pixels. On the example rigs that shades 3 to 19 percent less triangle area. The picture is the same to the eye and not to the bit: some pixels move by 1 of 255 levels.
|
|
111
|
+
|
|
112
|
+
`pixi-marrow outlines hero.atlas` writes the outlines to `hero.outlines.json` at build time. Pass that URL as `outlines` in the load options and nothing is read at load time.
|
|
113
|
+
|
|
114
|
+
## Docs site
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pnpm site:dev
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The site in `apps/site`, served at [pixi-marrow.schmooky.dev](https://pixi-marrow.schmooky.dev), has two live previews. It shows the bee of the slot game Bzzz, whose symbol rigs are in `fixtures/bzzz`.
|
|
121
|
+
|
|
122
|
+
## Goals
|
|
123
|
+
|
|
124
|
+
- One runtime for 4.1, 4.2 and 4.3 files, mixed in one scene.
|
|
125
|
+
- Less overdraw, fewer batch breaks, and one premultiplied pipeline with additive slots in the same batch.
|
|
126
|
+
- A pose core built for speed and low memory. Typed arrays, no per-frame allocation, no work that cannot change the picture.
|
|
127
|
+
- A small API that people and AI agents can use from one page of docs.
|
|
128
|
+
- Every frame checked against the official `spine-core` of the file's own version.
|
|
129
|
+
|
|
130
|
+
## Entry points
|
|
131
|
+
|
|
132
|
+
<!-- facts:entry-points -->
|
|
133
|
+
| Import | Holds |
|
|
134
|
+
|---|---|
|
|
135
|
+
| `pixi-marrow` | `MarrowSpine`, the display object, with `MarrowAsset`, `Track` and `MarrowError`. Needs `pixi.js`. |
|
|
136
|
+
| `pixi-marrow/core` | `importSkeleton`, `importAtlas`, `createPoseEngine`, the geometry functions, `describeSkeleton` and the model types. No Pixi. Runs in Node. |
|
|
137
|
+
| `pixi-marrow/optimize` | `generateNames`, `buildAtlasOutlines`, `decodePng` and the `pixi-marrow` command line tool (`info`, `typegen`, `outlines`). Runs in Node. |
|
|
138
|
+
| `pixi-marrow/perf` | `createProbe`: times the pose, geometry and event work of every update of one `MarrowSpine` and counts what the renderer did. For benchmarks and profiling. |
|
|
139
|
+
<!-- /facts:entry-points -->
|
|
140
|
+
|
|
141
|
+
## Work on it
|
|
142
|
+
|
|
143
|
+
Node 24 and pnpm 10.
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
pnpm install
|
|
147
|
+
pnpm check # every gate CI runs
|
|
148
|
+
pnpm test # unit tests and the parity suite
|
|
149
|
+
pnpm parity:ref # one line per fixture: the poses the official cores give
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The parity suite runs on the official Spine example exports. `pnpm fixtures` downloads them into `fixtures/.cache`. They are not committed.
|
|
153
|
+
|
|
154
|
+
Your own rigs go into `fixtures/local/`: a `.json` or `.skel` file with its `.atlas` next to it. The suite picks them up. That folder is not committed either.
|
|
155
|
+
|
|
156
|
+
[AGENTS.md](AGENTS.md) explains the layout and the rules.
|
|
157
|
+
|
|
158
|
+
## Licence
|
|
159
|
+
|
|
160
|
+
The Spine Runtimes License, in [LICENSE](LICENSE). The pose core of pixi-marrow is ported from the official Spine Runtimes, so pixi-marrow is a derivative work of them.
|
|
161
|
+
|
|
162
|
+
Each user of pixi-marrow needs their own Spine Editor licence, as for the official runtimes. A copy of pixi-marrow in any form must include the licence and its copyright notice.
|
|
163
|
+
|
|
164
|
+
The rigs in `fixtures/bzzz` are not covered by it, see [their notes](fixtures/bzzz/README.md).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The `pixi-marrow` command line tool: `pixi-marrow info <skeleton>`,
|
|
4
|
+
* `pixi-marrow typegen <skeleton>` and `pixi-marrow outlines <atlas>`. The work is done by
|
|
5
|
+
* runCli from pixi-marrow/optimize.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { runCli } from '../dist/optimize.js';
|
|
9
|
+
|
|
10
|
+
/** Errors of the file system that are about the paths the user gave. They need no stack. */
|
|
11
|
+
const FILE_ERRORS = ['ENOENT', 'EACCES', 'EISDIR', 'ENOTDIR', 'EPERM'];
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
process.exitCode = await runCli(process.argv.slice(2), {
|
|
15
|
+
// a copy, because Node hands out small files as views into a shared pool
|
|
16
|
+
read: (path) => (path.endsWith('.json') ? readFileSync(path, 'utf8') : new Uint8Array(readFileSync(path))),
|
|
17
|
+
write: (path, text) => writeFileSync(path, text),
|
|
18
|
+
print: (line) => console.log(line),
|
|
19
|
+
printError: (line) => console.error(line),
|
|
20
|
+
});
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (!(error instanceof Error) || !FILE_ERRORS.includes(error.code)) throw error;
|
|
23
|
+
console.error(`pixi-marrow: ${error.message}`);
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { AtlasModel } from "../model/atlas.js";
|
|
2
|
+
import { SkeletonInfo } from "../model/info.js";
|
|
3
|
+
import { SkeletonModel } from "../model/model.js";
|
|
4
|
+
import { AtlasOutlines } from "../model/outlines.js";
|
|
5
|
+
import { PoseEngineFactory } from "../pose/engine.js";
|
|
6
|
+
import { MarrowAssetsOptions } from "./assets.js";
|
|
7
|
+
import { Texture } from "pixi.js";
|
|
8
|
+
/** What `MarrowAsset.load` and `MarrowSpine.load` take. */
|
|
9
|
+
export interface MarrowLoadOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The skeleton: a URL, the bytes of a `.skel` file, or parsed JSON. A URL that ends in
|
|
12
|
+
* `.json` is fetched as text, any other URL as bytes.
|
|
13
|
+
*/
|
|
14
|
+
skeleton: string | Uint8Array | ArrayBuffer | object;
|
|
15
|
+
/** The URL of the `.atlas` file. */
|
|
16
|
+
atlas: string;
|
|
17
|
+
/**
|
|
18
|
+
* Page images by page name: a texture, or the URL of the image. A page that is not named is
|
|
19
|
+
* loaded from next to the atlas. A name that is no page of the atlas throws.
|
|
20
|
+
*/
|
|
21
|
+
textures?: Readonly<Record<string, Texture | string>>;
|
|
22
|
+
/**
|
|
23
|
+
* Where the outlines of the atlas regions come from. With them a slot behind an opaque one
|
|
24
|
+
* is skipped and a region without a visible pixel is not drawn. The picture stays the same.
|
|
25
|
+
* `tightMesh: 'on'` of a display object also needs them.
|
|
26
|
+
*
|
|
27
|
+
* - `auto` (the default) reads the page images in idle time after the load. See `MarrowAsset.optimized`.
|
|
28
|
+
* - `off` loads none: every region stays a quad and every slot is drawn.
|
|
29
|
+
* - A string is the URL of the file that `pixi-marrow outlines` wrote. It is fetched during the load.
|
|
30
|
+
* - An object is the parsed content of such a file.
|
|
31
|
+
*
|
|
32
|
+
* A file or an object that does not fit the atlas throws.
|
|
33
|
+
*/
|
|
34
|
+
outlines?: "auto" | "off" | string | AtlasOutlines;
|
|
35
|
+
/**
|
|
36
|
+
* The render mode the display objects of the asset will ask for, so that the load brings
|
|
37
|
+
* the code they draw with. The code of the mesh mode is not in the root import. The load
|
|
38
|
+
* waits for it with `mesh`, and with `auto` (the default) for a skeleton that `auto` draws
|
|
39
|
+
* with meshes. A display object that asks for the mesh mode later loads the code itself and
|
|
40
|
+
* draws in a batch until it is there.
|
|
41
|
+
*/
|
|
42
|
+
renderMode?: "auto" | "mesh" | "batched";
|
|
43
|
+
}
|
|
44
|
+
/** What `MarrowAsset.from` takes: a skeleton and an atlas that are in memory. */
|
|
45
|
+
export interface MarrowAssetData {
|
|
46
|
+
model: SkeletonModel;
|
|
47
|
+
atlas: AtlasModel;
|
|
48
|
+
/** One texture per atlas page, in page order. */
|
|
49
|
+
textures: readonly Texture[];
|
|
50
|
+
/**
|
|
51
|
+
* Where the outlines of the atlas regions come from: `auto` (the default) reads the page
|
|
52
|
+
* textures in idle time, `off` uses none, an object is checked against the atlas and used.
|
|
53
|
+
*/
|
|
54
|
+
outlines?: "auto" | "off" | AtlasOutlines;
|
|
55
|
+
/** The render mode the display objects will ask for, see `MarrowLoadOptions.renderMode`. Default `auto`. */
|
|
56
|
+
renderMode?: "auto" | "mesh" | "batched";
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Where the outlines of an asset stand.
|
|
60
|
+
*
|
|
61
|
+
* - `given`: the load got them, as a file or as an object.
|
|
62
|
+
* - `scanned`: they were read from the page images after the load.
|
|
63
|
+
* - `scanning`: the page images are being read at the moment, and there are none yet.
|
|
64
|
+
* - `unread`: the scan ended and could read no page image. Every region keeps its quad.
|
|
65
|
+
* - `off`: the asset was loaded with `outlines: 'off'`.
|
|
66
|
+
*/
|
|
67
|
+
export type OutlinesState = "given" | "scanned" | "scanning" | "unread" | "off";
|
|
68
|
+
/**
|
|
69
|
+
* What all instances of one skeleton share: the model, the atlas, one texture per atlas page,
|
|
70
|
+
* the outlines of the atlas regions and the code that poses the skeleton. Create display
|
|
71
|
+
* objects from it with `new MarrowSpine(asset)`.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* const asset = await MarrowAsset.load({ skeleton: 'hero.skel', atlas: 'hero.atlas' });
|
|
75
|
+
* const first = new MarrowSpine(asset);
|
|
76
|
+
* const second = new MarrowSpine(asset);
|
|
77
|
+
* console.log(asset.info.animations.map((animation) => animation.name));
|
|
78
|
+
*/
|
|
79
|
+
export declare class MarrowAsset {
|
|
80
|
+
/** The skeleton as its file describes it. */
|
|
81
|
+
readonly model: SkeletonModel;
|
|
82
|
+
/** The atlas as its file describes it. */
|
|
83
|
+
readonly atlas: AtlasModel;
|
|
84
|
+
/** One texture per atlas page, in page order. */
|
|
85
|
+
readonly textures: readonly Texture[];
|
|
86
|
+
/** Creates the pose engine of one more instance. Synchronous. */
|
|
87
|
+
readonly createEngine: PoseEngineFactory;
|
|
88
|
+
/** The image URLs this asset loaded, which it unloads when it is destroyed. */
|
|
89
|
+
private readonly loaded;
|
|
90
|
+
/** What the asset is shared under, or undefined. */
|
|
91
|
+
private readonly key;
|
|
92
|
+
private description;
|
|
93
|
+
private gone;
|
|
94
|
+
private found;
|
|
95
|
+
/** The scan that reads the pages at the moment. */
|
|
96
|
+
private scan;
|
|
97
|
+
/** Resolves when the scan has ended. */
|
|
98
|
+
private work;
|
|
99
|
+
/** True when the outlines come from the pixels of the textures, and follow them. */
|
|
100
|
+
private readonly scans;
|
|
101
|
+
private constructor();
|
|
102
|
+
/** The names, counts and features of the skeleton, as plain data. */
|
|
103
|
+
get info(): SkeletonInfo;
|
|
104
|
+
/** True once {@link destroy} was called. */
|
|
105
|
+
get destroyed(): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* The outlines of the atlas regions, or undefined when there are none. With `outlines: 'auto'`
|
|
108
|
+
* they are undefined until the page images were read, and again while they are read once
|
|
109
|
+
* more after a page texture got other pixels.
|
|
110
|
+
*/
|
|
111
|
+
get outlines(): AtlasOutlines | undefined;
|
|
112
|
+
/** Where the {@link outlines} come from, and whether they are still being read. */
|
|
113
|
+
get outlinesState(): OutlinesState;
|
|
114
|
+
/**
|
|
115
|
+
* Resolves when the work in the background has ended: with `outlines: 'auto'` the scan of the
|
|
116
|
+
* page images, which sets {@link outlines}. Resolves at once when there is no such work. It
|
|
117
|
+
* never rejects: a page that cannot be read keeps its quads.
|
|
118
|
+
*
|
|
119
|
+
* Display objects take the outlines at their next update.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* const asset = await MarrowAsset.load({ skeleton: 'hero.skel', atlas: 'hero.atlas' });
|
|
123
|
+
* await asset.optimized;
|
|
124
|
+
* console.log(asset.outlines?.regions.length);
|
|
125
|
+
*/
|
|
126
|
+
get optimized(): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Loads a skeleton, its atlas and the page images. The images are loaded with Pixi `Assets`
|
|
129
|
+
* from next to the atlas, unless `textures` names them. Each page texture is set up from its
|
|
130
|
+
* atlas page: alpha mode, filters, mipmaps and wrap.
|
|
131
|
+
*
|
|
132
|
+
* Loads of the same skeleton URL, atlas URL and options share one asset. Throws a
|
|
133
|
+
* `MarrowError` when a file does not load or is not valid. Every constraint of the skeleton
|
|
134
|
+
* is solved: IK, transform, path, physics and sliders.
|
|
135
|
+
*
|
|
136
|
+
* The outlines of the atlas regions are read from the page images after the load, in idle
|
|
137
|
+
* time, unless `outlines` names a file, gives them or is `off`.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* const asset = await MarrowAsset.load({ skeleton: 'hero.json', atlas: 'hero.atlas' });
|
|
141
|
+
* const fromBytes = await MarrowAsset.load({ skeleton: bytes, atlas: 'hero.atlas' });
|
|
142
|
+
*/
|
|
143
|
+
static load(options: MarrowLoadOptions): Promise<MarrowAsset>;
|
|
144
|
+
/**
|
|
145
|
+
* Creates an asset from a skeleton and an atlas that are in memory, with one texture per
|
|
146
|
+
* atlas page in page order. Each texture is set up from its atlas page. It is asynchronous
|
|
147
|
+
* because the pose code for the skeleton's Spine version loads on demand.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* const model = await importSkeleton(bytes);
|
|
151
|
+
* const atlas = importAtlas(atlasText);
|
|
152
|
+
* const asset = await MarrowAsset.from({ model, atlas, textures: [pageTexture] });
|
|
153
|
+
*/
|
|
154
|
+
static from(data: MarrowAssetData): Promise<MarrowAsset>;
|
|
155
|
+
/**
|
|
156
|
+
* Gets the asset of a skeleton and an atlas that Pixi `Assets` loaded, by their aliases.
|
|
157
|
+
* Synchronous: the pose code loaded with the skeleton. Calls with the same aliases and
|
|
158
|
+
* outlines share one asset. Unloading the atlas from `Assets` destroys the asset.
|
|
159
|
+
*
|
|
160
|
+
* The code of the mesh mode starts to load here when the instances need it. They draw in a
|
|
161
|
+
* batch until it is there. Throws a `MarrowError` for an alias that holds nothing pixi-marrow
|
|
162
|
+
* loaded.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* await Assets.load(['hero.skel', 'hero.atlas']);
|
|
166
|
+
* const asset = MarrowAsset.get({ skeleton: 'hero.skel', atlas: 'hero.atlas' });
|
|
167
|
+
*/
|
|
168
|
+
static get(options: MarrowAssetsOptions): MarrowAsset;
|
|
169
|
+
private static fetch;
|
|
170
|
+
/**
|
|
171
|
+
* Unloads the page images this asset loaded and stops sharing the asset. Textures that were
|
|
172
|
+
* passed in are left alone. A scan of the page images ends before its next page. Destroy the
|
|
173
|
+
* display objects made from the asset first. One that is left no longer updates.
|
|
174
|
+
*/
|
|
175
|
+
destroy(): void;
|
|
176
|
+
/** Reads the page images in idle time and keeps the outlines they give. */
|
|
177
|
+
private startScan;
|
|
178
|
+
/**
|
|
179
|
+
* A page texture got other pixels, so outlines of the pixels before could cut visible ones.
|
|
180
|
+
* They are dropped at once and read again. A canvas or a video has no outlines to drop.
|
|
181
|
+
*/
|
|
182
|
+
private onPageUpdate;
|
|
183
|
+
}
|