@doki-land/live2d-renderer 0.0.15 โ†’ 0.0.16

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/README.md +158 -1
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,3 +1,160 @@
1
1
  # @doki-land/live2d-renderer
2
2
 
3
- live2d.ts package 0.0.15.
3
+ Model execution and browser-native rendering backends for `live2d.ts`.
4
+
5
+ This package owns both MOC2/MOC3 runtime behavior and the WebGPU, WebGL2, and Canvas2D graphics implementations.
6
+ Applications should normally use these capabilities through `@doki-land/live2d`.
7
+
8
+ ## โœจ Features
9
+
10
+ - Pure TypeScript MOC2 and MOC3 parsing paths.
11
+ - CPU model programs and deterministic frame evaluation.
12
+ - WebGPU rendering.
13
+ - WebGL2 rendering.
14
+ - Canvas2D compatibility rendering.
15
+ - Texture, blend mode, clipping, and mask-atlas support.
16
+ - Parameter bindings for inspectors and interactive hosts.
17
+ - Renderer initialization fallback.
18
+ - Structural and model-fixture tests.
19
+
20
+ ## ๐Ÿงญ Package Role
21
+
22
+ The source tree separates three concerns:
23
+
24
+ ```text
25
+ src/moc/ model formats, deformation, and ModelBackend implementations
26
+ src/cpu/ model program parsing and CPU frame evaluation
27
+ src/backends/ WebGPU, WebGL2, and Canvas2D graphics backends
28
+ ```
29
+
30
+ MOC2 and MOC3 are model formats, not graphics backends. WebGPU, WebGL2, and Canvas2D are graphics backends, not model
31
+ formats.
32
+
33
+ ## ๐Ÿ“ฆ Installation
34
+
35
+ ```bash
36
+ pnpm add @doki-land/live2d-renderer
37
+ ```
38
+
39
+ Install this package directly when building renderer tools, conformance tests, custom facades, or specialized host
40
+ pipelines.
41
+
42
+ ## ๐Ÿš€ Creating a Renderer
43
+
44
+ ```ts
45
+ import { createRenderer } from "@doki-land/live2d-renderer";
46
+
47
+ const renderer = createRenderer({
48
+ prefer: ["webgpu", "webgl2", "canvas2d"],
49
+ });
50
+
51
+ await renderer.initialize(canvas);
52
+ ```
53
+
54
+ Fallback occurs during initialization. This matters because browser feature detection alone cannot prove that an
55
+ adapter, device, context, or required capability can be created.
56
+
57
+ ## ๐Ÿ–ผ๏ธ Backend Selection
58
+
59
+ ### WebGPU
60
+
61
+ Preferred for modern browsers and explicit GPU resource management. A valid `navigator.gpu` object is not sufficient;
62
+ adapter and device creation can still fail.
63
+
64
+ ### WebGL2
65
+
66
+ Primary GPU fallback with broad browser support. Shader compilation, framebuffer allocation, texture limits, and context
67
+ loss remain device-dependent.
68
+
69
+ ### Canvas2D
70
+
71
+ Compatibility and diagnostic path using textured triangle approximation. It is useful for fallback rendering and
72
+ CPU-output inspection but is not expected to match GPU throughput for complex models.
73
+
74
+ ## ๐Ÿง  Model Runtime
75
+
76
+ A `ModelBackend` is responsible for:
77
+
78
+ - determining whether it can handle normalized model settings;
79
+ - creating model state from settings and binary data;
80
+ - updating model time and parameters;
81
+ - producing drawable meshes or CPU frame snapshots;
82
+ - exposing parameter bindings;
83
+ - releasing model-owned state.
84
+
85
+ Model runtimes must not create their own application frame loop or DOM controls.
86
+
87
+ ## ๐ŸŽญ Rendering Semantics
88
+
89
+ The renderer preserves model-defined behavior including:
90
+
91
+ - drawable render order;
92
+ - opacity and visibility;
93
+ - normal, additive, and multiplicative blending where implemented;
94
+ - mask relationships;
95
+ - inverted masks;
96
+ - texture coordinates;
97
+ - model-space orientation.
98
+
99
+ Transparent drawables cannot be freely reordered across characters or masks merely to reduce state changes. Visual
100
+ correctness takes precedence over speculative batching.
101
+
102
+ ## ๐Ÿงญ Coordinate Contract
103
+
104
+ Model geometry uses a consistent model-space convention before reaching a graphics backend. Each backend is responsible
105
+ for exactly one conversion to its target coordinate system.
106
+
107
+ Do not fix orientation problems with CSS canvas transforms. CSS transforms also affect pointer mapping and can hide a
108
+ double conversion instead of correcting the model-to-renderer contract.
109
+
110
+ Orientation changes require a neutral fixture or pixel evidence across the affected backends.
111
+
112
+ ## โšก Performance Engineering
113
+
114
+ Performance work should target measured costs:
115
+
116
+ - model-program and instance lifetime;
117
+ - per-frame allocations;
118
+ - parameter dirty tracking;
119
+ - affected deformer and drawable evaluation;
120
+ - dynamic vertex upload ranges;
121
+ - mask-pass reuse;
122
+ - texture and pipeline state changes;
123
+ - overdraw and canvas resolution;
124
+ - multi-character scaling.
125
+
126
+ WebAssembly, TypeScript, WebGPU, and WebGL2 are implementation tools, not benchmark results. Comparisons must use
127
+ equivalent visual output and report CPU, GPU, allocation, upload, and memory metrics.
128
+
129
+ ## ๐Ÿงช Testing
130
+
131
+ ```bash
132
+ pnpm --filter @doki-land/live2d-renderer typecheck
133
+ pnpm --filter @doki-land/live2d-renderer test
134
+ ```
135
+
136
+ Renderer changes should add the smallest appropriate evidence:
137
+
138
+ - CPU golden snapshots for evaluation changes;
139
+ - structural assertions for format decoding;
140
+ - orientation tests for coordinate changes;
141
+ - mask and blend fixtures for compositing changes;
142
+ - pixel comparisons for graphics parity;
143
+ - browser checks for device-specific behavior.
144
+
145
+ Proprietary models must not be committed without redistribution permission.
146
+
147
+ ## ๐Ÿ”Œ Extending the Package
148
+
149
+ New model-format support belongs under `src/moc/`. New browser graphics implementations belong under `src/backends/`. Do
150
+ not create a separate published package for every MOC revision or GPU backend unless an independently useful public
151
+ contract justifies it.
152
+
153
+ ## ๐Ÿค Contributing
154
+
155
+ Keep hot paths allocation-aware, preserve deterministic CPU behavior, and document the visual invariant behind renderer
156
+ changes. Generated bundles must be rebuilt from source.
157
+
158
+ ## ๐Ÿ“„ License
159
+
160
+ See the repository license. Model assets used for local testing may have separate terms.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doki-land/live2d-renderer",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "Live2D rendering โ€” moc2/moc3 decode + WebGPU, WebGL2, Canvas2D backends for live2d.ts.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  "test": "vitest run"
46
46
  },
47
47
  "dependencies": {
48
- "@doki-land/live2d-core": "0.0.15"
48
+ "@doki-land/live2d-core": "0.0.16"
49
49
  },
50
50
  "sideEffects": false
51
51
  }