@haiyue/animation-spec 0.1.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/LICENSE +21 -0
- package/README.md +190 -0
- package/SPECIFICATION.md +108 -0
- package/bin/hya-convert.mjs +31 -0
- package/dist/binary.d.ts +7 -0
- package/dist/chunks/types-l6nBVYwx.js +8 -0
- package/dist/chunks/types-l6nBVYwx.js.map +1 -0
- package/dist/errors.d.ts +7 -0
- package/dist/extensions.d.ts +19 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2927 -0
- package/dist/index.js.map +1 -0
- package/dist/lottie-merge-path.d.ts +11 -0
- package/dist/lottie.d.ts +62 -0
- package/dist/lottie.js +2642 -0
- package/dist/lottie.js.map +1 -0
- package/dist/native3d/Animation3DError.d.ts +8 -0
- package/dist/native3d/Animation3DParser.d.ts +7 -0
- package/dist/native3d/Animation3DTypes.d.ts +285 -0
- package/dist/native3d/index.d.ts +5 -0
- package/dist/native3d.d.ts +2 -0
- package/dist/native3d.js +907 -0
- package/dist/native3d.js.map +1 -0
- package/dist/parser.d.ts +2 -0
- package/dist/state-machine.d.ts +130 -0
- package/dist/text-selector.d.ts +2 -0
- package/dist/types.d.ts +419 -0
- package/dist/validation.d.ts +32 -0
- package/package.json +69 -0
- package/schema/animation-3d-carrier.schema.json +73 -0
- package/schema/animation-3d-extension.schema.json +573 -0
- package/schema/animation-3d.contract.json +130 -0
- package/schema/animation.schema.json +611 -0
- package/schema/fixtures/native-3d-mixed-invalid.hya.json +50 -0
- package/schema/fixtures/native-3d-valid.hya.json +284 -0
- package/src/binary.ts +1441 -0
- package/src/errors.ts +18 -0
- package/src/extensions.ts +55 -0
- package/src/index.ts +90 -0
- package/src/lottie-merge-path.ts +204 -0
- package/src/lottie.ts +3073 -0
- package/src/native3d/Animation3DError.ts +20 -0
- package/src/native3d/Animation3DParser.ts +964 -0
- package/src/native3d/Animation3DTypes.ts +322 -0
- package/src/native3d/index.ts +14 -0
- package/src/native3d.ts +2 -0
- package/src/parser.ts +41 -0
- package/src/state-machine.ts +645 -0
- package/src/text-selector.ts +7 -0
- package/src/types.ts +483 -0
- package/src/validation.ts +1286 -0
- package/test/fixtures/basic-lottie.json +31 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"document": {
|
|
3
|
+
"format": "haiyue-animation",
|
|
4
|
+
"version": "1.0",
|
|
5
|
+
"canvas": {
|
|
6
|
+
"width": 640,
|
|
7
|
+
"height": 360,
|
|
8
|
+
"coordinateSystem": "screen-y-down"
|
|
9
|
+
},
|
|
10
|
+
"duration": 1,
|
|
11
|
+
"nodes": [
|
|
12
|
+
{
|
|
13
|
+
"id": "forbidden-2d-node",
|
|
14
|
+
"components": [
|
|
15
|
+
{
|
|
16
|
+
"type": "shape2d",
|
|
17
|
+
"shape": "rect",
|
|
18
|
+
"size": [10, 10],
|
|
19
|
+
"fill": [1, 0, 0, 1]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"tracks": [],
|
|
25
|
+
"extensionsUsed": ["org.haiyue.animation-3d@1"],
|
|
26
|
+
"extensionsRequired": ["org.haiyue.animation-3d@1"],
|
|
27
|
+
"extensions": {
|
|
28
|
+
"org.haiyue.animation-3d@1": {
|
|
29
|
+
"format": "haiyue-animation-3d@1",
|
|
30
|
+
"mode": "native-3d",
|
|
31
|
+
"coordinateSystem": {
|
|
32
|
+
"handedness": "right",
|
|
33
|
+
"upAxis": "+y",
|
|
34
|
+
"forwardAxis": "-z",
|
|
35
|
+
"unit": "meter",
|
|
36
|
+
"angles": "radian",
|
|
37
|
+
"rotationStorage": "normalized-xyzw-quaternion"
|
|
38
|
+
},
|
|
39
|
+
"viewport": { "width": 640, "height": 360 },
|
|
40
|
+
"materials": [],
|
|
41
|
+
"nodes": [],
|
|
42
|
+
"clips": []
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"expectedDiagnostic": {
|
|
47
|
+
"code": "E_ANIMATION_3D_MIXED_DIMENSIONS",
|
|
48
|
+
"path": "$.nodes"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "haiyue-animation",
|
|
3
|
+
"version": "1.0",
|
|
4
|
+
"name": "Native 3D contract fixture",
|
|
5
|
+
"canvas": {
|
|
6
|
+
"width": 640,
|
|
7
|
+
"height": 360,
|
|
8
|
+
"coordinateSystem": "screen-y-down"
|
|
9
|
+
},
|
|
10
|
+
"duration": 2,
|
|
11
|
+
"frameRate": 30,
|
|
12
|
+
"endBehavior": "loop",
|
|
13
|
+
"resources": [
|
|
14
|
+
{
|
|
15
|
+
"id": "model:character",
|
|
16
|
+
"type": "binary",
|
|
17
|
+
"uri": "assets/character.glb",
|
|
18
|
+
"mimeType": "model/gltf-binary",
|
|
19
|
+
"integrity": "sha256-contract-character"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"id": "texture:spark",
|
|
23
|
+
"type": "image",
|
|
24
|
+
"uri": "assets/spark.png",
|
|
25
|
+
"mimeType": "image/png",
|
|
26
|
+
"integrity": "sha256-contract-spark",
|
|
27
|
+
"colorSpace": "srgb"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"nodes": [],
|
|
31
|
+
"tracks": [],
|
|
32
|
+
"extensionsUsed": ["org.haiyue.animation-3d@1"],
|
|
33
|
+
"extensionsRequired": ["org.haiyue.animation-3d@1"],
|
|
34
|
+
"extensions": {
|
|
35
|
+
"org.haiyue.animation-3d@1": {
|
|
36
|
+
"format": "haiyue-animation-3d@1",
|
|
37
|
+
"mode": "native-3d",
|
|
38
|
+
"coordinateSystem": {
|
|
39
|
+
"handedness": "right",
|
|
40
|
+
"upAxis": "+y",
|
|
41
|
+
"forwardAxis": "-z",
|
|
42
|
+
"unit": "meter",
|
|
43
|
+
"angles": "radian",
|
|
44
|
+
"rotationStorage": "normalized-xyzw-quaternion"
|
|
45
|
+
},
|
|
46
|
+
"viewport": {
|
|
47
|
+
"width": 640,
|
|
48
|
+
"height": 360
|
|
49
|
+
},
|
|
50
|
+
"materials": [
|
|
51
|
+
{
|
|
52
|
+
"id": "material:hero",
|
|
53
|
+
"name": "Hero",
|
|
54
|
+
"baseColorFactor": [0.2, 0.55, 1, 1],
|
|
55
|
+
"metallicFactor": 0.1,
|
|
56
|
+
"roughnessFactor": 0.65,
|
|
57
|
+
"emissiveFactor": [0, 0, 0],
|
|
58
|
+
"alphaMode": "opaque",
|
|
59
|
+
"doubleSided": false
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
"nodes": [
|
|
63
|
+
{
|
|
64
|
+
"id": "camera",
|
|
65
|
+
"name": "Camera",
|
|
66
|
+
"transform": {
|
|
67
|
+
"translation": [0, 1.5, 5],
|
|
68
|
+
"rotation": [0, 0, 0, 1],
|
|
69
|
+
"scale": [1, 1, 1]
|
|
70
|
+
},
|
|
71
|
+
"components": [
|
|
72
|
+
{
|
|
73
|
+
"id": "camera:main",
|
|
74
|
+
"kind": "camera3d",
|
|
75
|
+
"projection": {
|
|
76
|
+
"kind": "perspective",
|
|
77
|
+
"fovYRadians": 0.7853981633974483,
|
|
78
|
+
"near": 0.1,
|
|
79
|
+
"far": 100
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "ground",
|
|
86
|
+
"name": "Ground",
|
|
87
|
+
"transform": {
|
|
88
|
+
"translation": [0, -1, 0],
|
|
89
|
+
"rotation": [0, 0, 0, 1],
|
|
90
|
+
"scale": [5, 0.1, 5]
|
|
91
|
+
},
|
|
92
|
+
"components": [
|
|
93
|
+
{
|
|
94
|
+
"id": "ground:mesh",
|
|
95
|
+
"kind": "primitive3d",
|
|
96
|
+
"primitive": "box",
|
|
97
|
+
"materialId": "material:hero"
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "character",
|
|
103
|
+
"name": "Character",
|
|
104
|
+
"transform": {
|
|
105
|
+
"translation": [0, 0, 0],
|
|
106
|
+
"rotation": [0, 0, 0, 1],
|
|
107
|
+
"scale": [1, 1, 1]
|
|
108
|
+
},
|
|
109
|
+
"components": [
|
|
110
|
+
{
|
|
111
|
+
"id": "character:model",
|
|
112
|
+
"kind": "model3d",
|
|
113
|
+
"resource": "model:character",
|
|
114
|
+
"materialOverrides": [
|
|
115
|
+
{
|
|
116
|
+
"slot": "Body",
|
|
117
|
+
"materialId": "material:hero"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"id": "sparks",
|
|
125
|
+
"name": "Sparks",
|
|
126
|
+
"parent": "character",
|
|
127
|
+
"transform": {
|
|
128
|
+
"translation": [0, 1, 0],
|
|
129
|
+
"rotation": [0, 0, 0, 1],
|
|
130
|
+
"scale": [1, 1, 1]
|
|
131
|
+
},
|
|
132
|
+
"components": [
|
|
133
|
+
{
|
|
134
|
+
"id": "sparks:emitter",
|
|
135
|
+
"kind": "particle3d",
|
|
136
|
+
"descriptor": {
|
|
137
|
+
"maxParticles": 256,
|
|
138
|
+
"emissionRate": 24,
|
|
139
|
+
"burst": 8,
|
|
140
|
+
"duration": 2,
|
|
141
|
+
"loop": true,
|
|
142
|
+
"seed": 1732584193,
|
|
143
|
+
"lifetime": [0.4, 0.8],
|
|
144
|
+
"speed": [0.5, 1.5],
|
|
145
|
+
"direction": [0, 1, 0],
|
|
146
|
+
"spread": 0.5,
|
|
147
|
+
"gravity": [0, -1, 0],
|
|
148
|
+
"startSize": [0.04, 0.08],
|
|
149
|
+
"endSize": [0, 0.02],
|
|
150
|
+
"rotation": [0, 6.283185307179586],
|
|
151
|
+
"angularVelocity": [-1, 1],
|
|
152
|
+
"startColor": [1, 0.8, 0.2, 1],
|
|
153
|
+
"endColor": [1, 0.1, 0, 0],
|
|
154
|
+
"shape": "sphere",
|
|
155
|
+
"shapeSize": [0.2, 0.2, 0.2],
|
|
156
|
+
"shapeRadius": 0.1,
|
|
157
|
+
"blendMode": "additive",
|
|
158
|
+
"textureResource": "texture:spark",
|
|
159
|
+
"radial": true,
|
|
160
|
+
"opacity": 1,
|
|
161
|
+
"depthTest": true,
|
|
162
|
+
"depthWrite": false,
|
|
163
|
+
"sortMode": "none"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"clips": [
|
|
170
|
+
{
|
|
171
|
+
"format": "haiyue-animation3d-clip@1",
|
|
172
|
+
"id": "clip:idle",
|
|
173
|
+
"name": "Idle",
|
|
174
|
+
"duration": 2,
|
|
175
|
+
"tracks": [
|
|
176
|
+
{
|
|
177
|
+
"id": "track:root-translation",
|
|
178
|
+
"binding": {
|
|
179
|
+
"id": "binding:root-translation",
|
|
180
|
+
"target": { "kind": "node-id", "nodeId": "character" },
|
|
181
|
+
"path": "transform.translation",
|
|
182
|
+
"valueType": "vec3",
|
|
183
|
+
"valueSize": 3
|
|
184
|
+
},
|
|
185
|
+
"interpolation": "linear",
|
|
186
|
+
"times": [0, 2],
|
|
187
|
+
"values": [0, 0, 0, 0, 0.05, 0]
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"id": "track:spine-rotation",
|
|
191
|
+
"binding": {
|
|
192
|
+
"id": "binding:spine-rotation",
|
|
193
|
+
"target": { "kind": "node-path", "segments": ["character", "Armature", "Spine"] },
|
|
194
|
+
"path": "transform.rotation",
|
|
195
|
+
"valueType": "quaternion",
|
|
196
|
+
"valueSize": 4
|
|
197
|
+
},
|
|
198
|
+
"interpolation": "linear",
|
|
199
|
+
"times": [0, 2],
|
|
200
|
+
"values": [0, 0, 0, 1, 0, 0.043619387, 0, 0.999048222]
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"id": "track:face-morph",
|
|
204
|
+
"binding": {
|
|
205
|
+
"id": "binding:face-morph",
|
|
206
|
+
"target": { "kind": "slot", "slot": "character:Face" },
|
|
207
|
+
"path": "morph.weights",
|
|
208
|
+
"valueType": "weights",
|
|
209
|
+
"valueSize": 2
|
|
210
|
+
},
|
|
211
|
+
"interpolation": "linear",
|
|
212
|
+
"times": [0, 1, 2],
|
|
213
|
+
"values": [0, 0, 0.5, 0.2, 0, 0]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"id": "track:material-color",
|
|
217
|
+
"binding": {
|
|
218
|
+
"id": "binding:material-color",
|
|
219
|
+
"target": { "kind": "slot", "slot": "material:hero" },
|
|
220
|
+
"path": "property",
|
|
221
|
+
"component": "material3d",
|
|
222
|
+
"property": "baseColorFactor",
|
|
223
|
+
"valueType": "vec4",
|
|
224
|
+
"valueSize": 4
|
|
225
|
+
},
|
|
226
|
+
"interpolation": "linear",
|
|
227
|
+
"times": [0, 2],
|
|
228
|
+
"values": [0.2, 0.55, 1, 1, 0.4, 0.7, 1, 1]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"id": "track:camera-fov",
|
|
232
|
+
"binding": {
|
|
233
|
+
"id": "binding:camera-fov",
|
|
234
|
+
"target": { "kind": "node-id", "nodeId": "camera" },
|
|
235
|
+
"path": "property",
|
|
236
|
+
"component": "camera3d",
|
|
237
|
+
"property": "fovYRadians",
|
|
238
|
+
"valueType": "scalar",
|
|
239
|
+
"valueSize": 1
|
|
240
|
+
},
|
|
241
|
+
"interpolation": "step",
|
|
242
|
+
"times": [0, 2],
|
|
243
|
+
"values": [0.7853981633974483, 0.8726646259971648]
|
|
244
|
+
}
|
|
245
|
+
],
|
|
246
|
+
"events": []
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
"stateMachine": {
|
|
250
|
+
"format": "haiyue-animation3d-state-machine@1",
|
|
251
|
+
"id": "machine:character",
|
|
252
|
+
"name": "Character",
|
|
253
|
+
"parameters": [],
|
|
254
|
+
"layers": [
|
|
255
|
+
{
|
|
256
|
+
"id": "layer:base",
|
|
257
|
+
"name": "Base",
|
|
258
|
+
"initialStateId": "state:idle",
|
|
259
|
+
"states": [
|
|
260
|
+
{
|
|
261
|
+
"id": "state:idle",
|
|
262
|
+
"name": "Idle",
|
|
263
|
+
"motion": { "kind": "clip", "clipId": "clip:idle" },
|
|
264
|
+
"loop": "repeat"
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"transitions": [],
|
|
268
|
+
"blendMode": "override",
|
|
269
|
+
"weight": 1,
|
|
270
|
+
"mask": {
|
|
271
|
+
"include": [
|
|
272
|
+
"binding:root-translation",
|
|
273
|
+
"binding:spine-rotation",
|
|
274
|
+
"binding:face-morph",
|
|
275
|
+
"binding:material-color",
|
|
276
|
+
"binding:camera-fov"
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|