@vvfx/ge-ir 0.0.1-beat.2 → 0.0.1-beta.11

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 (93) hide show
  1. package/README.md +290 -42
  2. package/dist/common/anchor-mapping.d.ts +3 -0
  3. package/dist/common/coordinate-mapping.d.ts +19 -0
  4. package/dist/common/data-path.d.ts +14 -0
  5. package/dist/common/id.d.ts +2 -0
  6. package/dist/common/json-normalization.d.ts +3 -0
  7. package/dist/common/math.d.ts +4 -0
  8. package/dist/common/particle-expression.d.ts +4 -0
  9. package/dist/conversion.d.ts +21 -0
  10. package/dist/ge2ir/assemble.d.ts +4 -0
  11. package/dist/ge2ir/convert.d.ts +4 -0
  12. package/dist/ge2ir/extract-particle-source-data.d.ts +5 -0
  13. package/dist/ge2ir/mapping.d.ts +5 -0
  14. package/dist/ge2ir/{parsers/animation-parser.d.ts → parser/animation.d.ts} +2 -2
  15. package/dist/ge2ir/parser/component.d.ts +22 -0
  16. package/dist/ge2ir/{parsers/keyframe-parser.d.ts → parser/keyframe.d.ts} +1 -1
  17. package/dist/ge2ir/parser/layer.d.ts +13 -0
  18. package/dist/ge2ir/parser/parse-particle-component.d.ts +7 -0
  19. package/dist/ge2ir/parser/scene.d.ts +4 -0
  20. package/dist/ge2ir/{parsers/timeline-parser.d.ts → parser/timeline.d.ts} +5 -3
  21. package/dist/ge2ir/parser/transform.d.ts +3 -0
  22. package/dist/ge2ir/post-process/mask.d.ts +10 -0
  23. package/dist/ge2ir/{merge/merge.d.ts → post-process.d.ts} +5 -3
  24. package/dist/ge2ir/types.d.ts +31 -11
  25. package/dist/index.d.ts +11 -17
  26. package/dist/index.js +10025 -4210
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +10022 -4191
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/ir2ge/assemble.d.ts +9 -0
  31. package/dist/ir2ge/convert.d.ts +9 -0
  32. package/dist/ir2ge/converter/animation.d.ts +5 -0
  33. package/dist/ir2ge/converter/bezier.d.ts +35 -0
  34. package/dist/ir2ge/converter/normalized-animation.d.ts +15 -0
  35. package/dist/ir2ge/converter/opacity.d.ts +8 -0
  36. package/dist/ir2ge/converter/precomp.d.ts +17 -0
  37. package/dist/ir2ge/converter/timing.d.ts +9 -0
  38. package/dist/ir2ge/converter/transform.d.ts +14 -0
  39. package/dist/ir2ge/generator/build-particle-component.d.ts +3 -0
  40. package/dist/ir2ge/generator/component-preservation.d.ts +5 -0
  41. package/dist/ir2ge/generator/component.d.ts +10 -0
  42. package/dist/ir2ge/generator/layer-strategy.d.ts +19 -0
  43. package/dist/ir2ge/generator/layer.d.ts +6 -0
  44. package/dist/ir2ge/generator/timeline.d.ts +8 -0
  45. package/dist/ir2ge/map-particle-layout-to-ge-transform.d.ts +30 -0
  46. package/dist/ir2ge/mapping.d.ts +6 -0
  47. package/dist/ir2ge/post-process/cross-composition-mask.d.ts +4 -0
  48. package/dist/ir2ge/post-process/ge-mask-remap.d.ts +3 -15
  49. package/dist/ir2ge/post-process/mask-geometry.d.ts +16 -0
  50. package/dist/ir2ge/post-process/mask.d.ts +29 -22
  51. package/dist/ir2ge/post-process/matte.d.ts +5 -0
  52. package/dist/ir2ge/post-process/merge-preserved-resources.d.ts +3 -0
  53. package/dist/ir2ge/post-process/parenting.d.ts +3 -3
  54. package/dist/ir2ge/post-process/pipeline.d.ts +25 -0
  55. package/dist/ir2ge/post-process/visibility.d.ts +14 -18
  56. package/dist/ir2ge/types.d.ts +55 -24
  57. package/dist/layer-preserved-data.d.ts +11 -0
  58. package/dist/particle/merge-particle-fragment.d.ts +12 -0
  59. package/dist/particle/merge-particle-scenes.d.ts +21 -0
  60. package/dist/particle/particle-fragment.d.ts +10 -0
  61. package/dist/preserved-data.d.ts +66 -0
  62. package/dist/update-preserved-data.d.ts +12 -0
  63. package/package.json +19 -4
  64. package/dist/ge2ir/converter.d.ts +0 -3
  65. package/dist/ge2ir/index.d.ts +0 -2
  66. package/dist/ge2ir/parsers/component-parser.d.ts +0 -16
  67. package/dist/ge2ir/parsers/transform-parser.d.ts +0 -3
  68. package/dist/ge2ir/pool/pool.d.ts +0 -4
  69. package/dist/ge2ir/reverse/blend-mode.d.ts +0 -2
  70. package/dist/ge2ir/reverse/coordinate.d.ts +0 -1
  71. package/dist/ge2ir/reverse/end-behavior.d.ts +0 -3
  72. package/dist/ge2ir/reverse/timing.d.ts +0 -2
  73. package/dist/ge2ir/scene-reader.d.ts +0 -3
  74. package/dist/ir2ge/assembly/generator.d.ts +0 -23
  75. package/dist/ir2ge/assembly/scene-assembly.d.ts +0 -11
  76. package/dist/ir2ge/builders/animation.d.ts +0 -4
  77. package/dist/ir2ge/builders/bezier.d.ts +0 -44
  78. package/dist/ir2ge/builders/component.d.ts +0 -13
  79. package/dist/ir2ge/builders/effects.d.ts +0 -9
  80. package/dist/ir2ge/builders/layer.d.ts +0 -5
  81. package/dist/ir2ge/builders/timeline.d.ts +0 -9
  82. package/dist/ir2ge/builders/timing.d.ts +0 -17
  83. package/dist/ir2ge/index.d.ts +0 -14
  84. package/dist/ir2ge/ir/anchor-strategy.d.ts +0 -24
  85. package/dist/ir2ge/ir/layer-dimensions.d.ts +0 -13
  86. package/dist/ir2ge/ir/layer-utils.d.ts +0 -14
  87. package/dist/ir2ge/ir/parent-link.d.ts +0 -15
  88. package/dist/ir2ge/ir/specific.d.ts +0 -14
  89. package/dist/ir2ge/post-process/index.d.ts +0 -31
  90. package/dist/ir2ge/utils.d.ts +0 -14
  91. package/dist/shared/coordinate.d.ts +0 -11
  92. package/dist/shared/ge2ir-metadata.d.ts +0 -17
  93. package/dist/shared/types.d.ts +0 -60
package/README.md CHANGED
@@ -1,66 +1,314 @@
1
1
  # @vvfx/ge-ir
2
2
 
3
- > 内部转换包。统一承载 Galacean Effects JSONScene 与 `@vvfx/animation-ir`
4
- > 之间的双向转换能力,供 monorepo 内的 `lottie2ge`、`dsl2ge`、调试页面等链路复用。
3
+ English | [简体中文](./README-zh_CN.md)
5
4
 
6
- ## 能力范围
5
+ Bidirectional conversion between Galacean Effects and source-neutral Animation IR.
7
6
 
7
+ The package converts supported GE content into normalized IR and retains GE-only data in an adapter-owned sidecar
8
+ for fidelity-preserving export. Applications compose this adapter with `@vvfx/dsl-ir` when editing DSL.
9
+
10
+ ## Contents
11
+
12
+ - [Install](#install)
13
+ - [Usage](#usage)
14
+ - [Preserved data](#preserved-data)
15
+ - [Data boundaries](#data-boundaries)
16
+ - [API](#api)
17
+ - [Project structure](#project-structure)
18
+ - [Contributing](#contributing)
19
+ - [License](#license)
20
+
21
+ ## Install
22
+
23
+ Node.js 22 or later is required.
24
+
25
+ ```bash
26
+ pnpm add @vvfx/ge-ir
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ### Convert GE to Animation IR
32
+
33
+ ```ts
34
+ import { convertGEToIR } from '@vvfx/ge-ir';
35
+
36
+ const imported = convertGEToIR(geScene, {
37
+ frameRate: 30,
38
+ resourceBaseUrl: 'https://cdn.example.com/scenes/demo.json',
39
+ });
40
+
41
+ console.info(imported.scene);
42
+ console.info(imported.diagnostics);
43
+ ```
44
+
45
+ `frameRate` converts GE timing in seconds to IR frames. `resourceBaseUrl` is optional and must be absolute when
46
+ supplied; it resolves relative image and font URLs at the GE import boundary.
47
+
48
+ ### Particle source data
49
+
50
+ `convertGEToIR` extracts the ParticleSystem bindings and source layout needed for final host placement:
51
+
52
+ ```ts
53
+ import { convertGEToIR } from '@vvfx/ge-ir';
54
+
55
+ const imported = convertGEToIR(geScene, { frameRate: 30 });
56
+
57
+ console.info(imported.preservedData.particleSourceData);
58
+ ```
59
+
60
+ Each source Composition containing ParticleSystems becomes one `particleEffectGroup`; every ParticleSystem retains an
61
+ independent binding and its original Item order. Because GE does not provide principal visual bounds, the adapter
62
+ stores `[0, 0, previewWidth, previewHeight]` as the fallback `authoringBounds` without a separate provenance marker.
63
+ Scenes without ParticleSystem components store empty group and Layer arrays. Complete renderer, shape, and resource
64
+ data remains in the GE-owned layer payload rather than this layout index.
65
+
66
+ ### Map particle layout to a GE transform
67
+
68
+ Layout mapping is handled internally when converting DSL with particles.
69
+
70
+ The internal mapping scales the source `authoringBounds` proportionally and aligns its center with `targetRegion.center`.
71
+ It follows the Python layout contract: FOV is vertical, world height is `2 * abs(camera.position.z) * tan(fov / 2)`,
72
+ and world width is world height times the preview aspect ratio. Camera `clipMode`, XY position, and rotation are
73
+ ignored. Returned world Z is zero; placement Z controls painter order.
74
+ When merging GE scenes, portrait-camera horizontal FOV is converted to equivalent vertical FOV for both
75
+ source and host before this mapping. The stored cameras remain unchanged.
76
+
77
+ ### Merge restored particle GE scenes
78
+
79
+ The caller restores particle scenes through `convertIRToGE`, then merges them into a host GE scene:
80
+
81
+ ```ts
82
+ import { mergeParticleScenes } from '@vvfx/ge-ir';
83
+
84
+ const scene = mergeParticleScenes(hostScene, [{
85
+ scene: restoredParticleScene,
86
+ preservedData: particleGEPreservedData,
87
+ placements,
88
+ }], hostStackingOrder);
89
+ ```
90
+
91
+ Each placement identifies a preserved effect group, its target width and height, and center position.
92
+ `irLayerId` selects one particle system; omit it to place the entire group. A group must have either one group placement
93
+ or one placement per system. The merger validates and resolves these bindings internally.
94
+ The merger preserves required ancestors and timelines, namespaces IDs, rebases binary pointers, and orders Items,
95
+ scene bindings, and timeline tracks together. Sources must share the host GE version and be self-contained.
96
+
97
+ `hostStackingOrder` optionally maps GE Item IDs to painter ranks independently of spatial Z. To carry source IR ranks
98
+ through conversion, read `itemLayerIds` from the `convertIRToGE` result. This JSON-serializable record maps generated
99
+ Item IDs to IR Layer IDs. The caller joins these bindings to its layer ranks. Without explicit ranks, the merger uses cumulative
100
+ host spatial Z.
101
+
102
+ DSL conversion, paired sidecars, model requests, and initial placement policies belong to the application.
103
+ See [the web workflows](../../web-packages/README.md#ge--dsl-集成边界) for a complete example.
104
+
105
+ ### Convert Animation IR to GE
106
+
107
+ ```ts
108
+ import { convertIRToGE } from '@vvfx/ge-ir';
109
+
110
+ const exported = convertIRToGE(irScene);
111
+
112
+ console.info(exported.scene);
113
+ console.info(exported.diagnostics);
114
+ ```
115
+
116
+ `convertIRToGE` validates the IR scene before conversion. `options.duration` can override the exported duration.
117
+
118
+ ### Preserve GE-only data across a round trip
119
+
120
+ Pass the sidecar returned by `convertGEToIR` back to `convertIRToGE` when the IR has not been edited:
121
+
122
+ ```ts
123
+ const imported = convertGEToIR(geScene, { frameRate: 30 });
124
+ const roundTripped = convertIRToGE(imported.scene, {
125
+ preservedData: imported.preservedData,
126
+ });
8
127
  ```
9
- JSONScene ── convertGEToIR ──> IRComposition ── convertIRToGE ──> JSONScene
10
- @vvfx/animation-ir
128
+
129
+ The IR scene remains valid without the sidecar. Most supported layer types are also exportable without it. Particle
130
+ layers require their trusted GE sidecar for export because renderer, shape, and resource bindings are outside the
131
+ source-neutral particle contract. Supplying the sidecar restores compatible GE object-pool data, raw
132
+ animation payloads, masks, precomposition payloads, sprite metadata, particle payloads, and source hierarchy data.
133
+
134
+ ### Export edited IR with retained GE data
135
+
136
+ After editing IR, reconcile the original sidecar before exporting:
137
+
138
+ ```ts
139
+ import { convertGEToIR, convertIRToGE, updateGEToIRPreservedData } from '@vvfx/ge-ir';
140
+
141
+ const imported = convertGEToIR(geScene, { frameRate: 30 });
142
+ const updatedScene = structuredClone(imported.scene);
143
+
144
+ updatedScene.compositions[0].layers[0].transform = {
145
+ ...updatedScene.compositions[0].layers[0].transform,
146
+ opacity: { type: 'static', value: 0.5 },
147
+ };
148
+
149
+ const updatedPreservedData = updateGEToIRPreservedData(
150
+ imported.scene,
151
+ updatedScene,
152
+ imported.preservedData,
153
+ );
154
+
155
+ const exported = convertIRToGE(updatedScene, {
156
+ preservedData: updatedPreservedData,
157
+ });
11
158
  ```
12
159
 
13
- 本包不定义 IR 数据模型;`@vvfx/animation-ir` 仍是 IR 类型和校验逻辑的唯一真源。
160
+ `updateGEToIRPreservedData` compares the baseline IR with the updated IR. It clones the supplied sidecar, removes only
161
+ GE values that conflict with changed IR fields, removes bindings for deleted compositions and layers, and returns the
162
+ reconciled sidecar. It does not modify either IR scene or generate GE output.
163
+
164
+ ## Preserved data
165
+
166
+ `GEToIRPreservedData` is owned by this adapter and stored outside the Animation IR contract. Persist it together with
167
+ the IR scene when GE round-trip fidelity is required. Applications should not edit its internal fields directly.
168
+
169
+ Layer-level preserved data can include:
170
+
171
+ - raw position, rotation, scale, and color animation payloads;
172
+ - sprite start color, texture splits, and texture-sheet animation settings;
173
+ - GE item and component identities plus Activation clip end behavior;
174
+ - masks and precomposition payloads that cannot be normalized losslessly;
175
+ - complete ParticleSystem payloads whose normalized IR fields override the corresponding values on export;
176
+ - the original single-item or null/sprite hierarchy.
177
+
178
+ Top-level `particleSourceData` indexes ParticleSystem source bounds, source order, and IR bindings used by final host
179
+ placement. A source Composition without a valid `previewSize` still imports into IR, but its host-placement bindings
180
+ are omitted and reported as
181
+ `GE_PARTICLE_SOURCE_LAYOUT_UNAVAILABLE`.
182
+
183
+ Use `updateGEToIRPreservedData` for an edited scene. It derives all supported invalidations from the difference
184
+ between the baseline and updated IR scenes; layer-level lookup and invalidation remain internal implementation details.
14
185
 
15
- ## 主要 API
186
+ ## Data boundaries
187
+
188
+ - `@vvfx/animation-ir` is the single source of truth for Animation IR types and validation.
189
+ - `GEToIRPreservedData` belongs to `@vvfx/ge-ir`; it is never embedded in the source-neutral IR schema.
190
+ - Preserved data is bound to specific IR composition and layer identities. Version and scene bindings are
191
+ validated before reuse.
192
+ - All source compositions are imported. The source entry composition becomes `IRScene.entryCompositionId`.
193
+ - External image and font resources entering IR must resolve to absolute URLs or Data URLs.
194
+ - Conversion diagnostics report normalization, approximation, dropped data, and unsupported features.
195
+ - Applications compose GE and DSL adapters through Animation IR. Their production code must not depend on each other.
196
+ - Particle import maps editable GE `options` fields to flat IR particle content, normalizes supported GE scalar forms
197
+ to the IR curve model, and
198
+ keeps engine-only particle data in the trusted sidecar. Export applies `maxParticles`, `startLifetime`,
199
+ `rateOverTime`, `bursts`, Layer blend mode, anchor, and static opacity to that baseline instead of fabricating
200
+ renderer, shape, or resource defaults. Animated Particle Layer opacity is reported as unsupported because GE has
201
+ no timeline-compatible Particle renderer opacity target.
202
+ - GE burst defaults are normalized to explicit IR `cycleCount` and `repeatIntervalFrames` values, including
203
+ unbounded cycles, with an informational normalization diagnostic. GE Item end behavior enters the normalized Layer;
204
+ Activation clip end behavior is retained independently in preserved data and restored during export.
205
+
206
+ Further documentation:
207
+
208
+ - [GE and Animation IR reference](../../docs/ge-ir-reference.md)
209
+ - [DSL, IR, and GE package boundaries](../../docs/dsl-ir-ge-ir-boundary.md)
210
+ - [DSL and IR editing capabilities](../../docs/dsl-ir-editing-capabilities.md)
211
+ - [Animation IR particle contract](../../docs/particle-ir-contract.md)
212
+
213
+ Ordinary and particle layers share the initial DSL `position.z` stacking order; higher values render above lower
214
+ values. Reordering input arrays does not change stacking. Ordinary child subtrees stay together at their root rank.
215
+ The rank-to-item mapping is internal and is not serialized into GE transforms.
216
+
217
+ ## API
218
+
219
+ ### Conversion and preservation
220
+
221
+ ```ts
222
+ function convertGEToIR(scene: Record<string, unknown>, options: GEToIROptions): GEToIRResult;
223
+
224
+ function convertIRToGE(scene: IRScene, options?: IRToGEOptions): IRToGEResult;
225
+
226
+ function updateGEToIRPreservedData(
227
+ baselineScene: IRScene,
228
+ updatedScene: IRScene,
229
+ preservedData: GEToIRPreservedData,
230
+ options?: UpdateGEToIRPreservedDataOptions,
231
+ ): GEToIRPreservedData;
232
+
233
+ ```
234
+
235
+ Results and options:
16
236
 
17
237
  ```ts
18
- import { convertGEToIR, convertIRToGE } from '@vvfx/ge-ir';
238
+ interface GEToIRResult {
239
+ scene: IRScene;
240
+ preservedData: GEToIRPreservedData;
241
+ diagnostics: ConversionDiagnostic[];
242
+ }
243
+
244
+ interface IRToGEResult {
245
+ itemLayerIds: Readonly<Record<string, string>>;
246
+ scene: JSONScene;
247
+ diagnostics: ConversionDiagnostic[];
248
+ }
249
+
250
+ interface GEToIROptions {
251
+ frameRate: number;
252
+ resourceBaseUrl?: string;
253
+ }
19
254
 
20
- const ir = convertGEToIR(scene, { frameRate: 30 });
21
- const roundTrippedScene = convertIRToGE(ir);
255
+ interface IRToGEOptions {
256
+ duration?: number;
257
+ preservedData?: GEToIRPreservedData;
258
+ }
22
259
  ```
23
260
 
24
- - `convertIRToGE(ir, duration?)`:IR -> GE JSONScene。
25
- - `convertGEToIR(scene, options)`:GE JSONScene -> IRComposition。
26
- - `GE2IROptions`:当前包含 `frameRate`。
27
- - `JSONScene` / `DataPath`:从 `@galacean/effects-specification` 透出,方便 sibling 包消费。
261
+ `UpdateGEToIRPreservedDataOptions.onChange` receives the composition, layer, and preserved field removed during
262
+ reconciliation.
28
263
 
29
- ## 共享契约
264
+ ### Runtime exports
30
265
 
31
- `src/shared/coordinate.ts` 是正反向坐标换算的共同真源:
266
+ | Export | Purpose |
267
+ | --- | --- |
268
+ | `convertGEToIR` | Import GE JSONScene as Animation IR and GE-owned preserved data |
269
+ | `convertIRToGE` | Export Animation IR as GE JSONScene |
270
+ | `mergeParticleScenes` | Merge restored particle GE scenes with explicit layout and painter order |
271
+ | `updateGEToIRPreservedData` | Reconcile GE preserved data after IR edits |
272
+ | `get2dTo3dRatio` | Calculate the coordinate conversion ratio |
32
273
 
33
- - `DEFAULT_CAMERA_Z`
34
- - `DEFAULT_CAMERA_FOV`
35
- - `DEFAULT_CLIP_MODE`
36
- - `get2dTo3dRatio`
37
- - `convert2dTo3dPoint`
274
+ ### Type exports
38
275
 
39
- `src/shared/ge2ir-metadata.ts` 是 round-trip passthrough metadata 的共同真源。`ge2ir`
40
- 写入 `layer.metadata.ge2ir`,`ir2ge` 在生成 GE 时读取并复用原始 GE 动画和 mask 信息。
276
+ All public types are imported from the package root:
41
277
 
42
- 当前支持的 metadata keys:
278
+ - Conversion: `GEToIROptions`, `GEToIRResult`, `IRToGEOptions`, and `IRToGEResult`.
279
+ - Particle merge: `GEParticlePlacement` and `ParticleSceneMergeInput`.
280
+ - GE preserved data: `GEToIRPreservedData`.
281
+ - Reconciliation: `GEToIRPreservedDataChange` and `UpdateGEToIRPreservedDataOptions`.
43
282
 
44
- - `positionOverLifetime`
45
- - `rotationOverLifetime`
46
- - `sizeOverLifetime`
47
- - `colorOverLifetime`
48
- - `geComponentId`
49
- - `geMask`
283
+ `JSONScene` is defined by `@galacean/effects-specification` and should be imported from that package.
50
284
 
51
- `src/shared/types.ts` 放置不属于单一方向的 GE wire/pool 基础结构:
285
+ ## Project structure
52
286
 
53
- - `GERecord`
54
- - `GEDataPath`
55
- - `GEPoolIndex`
56
- - `GETransform`
57
- - `GEItem`
58
- - `ECSCollector`
287
+ ```text
288
+ src/
289
+ ge2ir/ GE parsing, mapping, assembly, and post-processing
290
+ ir2ge/ IR conversion, GE generation, assembly, and post-processing
291
+ particle/ Particle fragment extraction, layout, and host-scene merge
292
+ common/ Coordinate, DataPath, JSON, ID, and math utilities
293
+ conversion.ts Public conversion result and option types
294
+ preserved-data.ts GE-owned composition and layer data contract
295
+ layer-preserved-data.ts Layer data lookup and field invalidation
296
+ update-preserved-data.ts Scene-level preserved-data reconciliation
297
+ index.ts Stable public entry
298
+ ```
299
+
300
+ ## Contributing
301
+
302
+ Use repository issues for questions and bug reports. Pull requests are welcome. Run the package checks after changing
303
+ public behavior:
304
+
305
+ ```bash
306
+ pnpm --filter @vvfx/ge-ir test
307
+ pnpm --filter @vvfx/ge-ir build
308
+ ```
59
309
 
60
- ## 稳定性分层
310
+ Rendering changes require representative visual comparison in addition to automated checks.
61
311
 
62
- `src/index.ts` 按三层导出:
312
+ ## License
63
313
 
64
- - 公开/主链路:`convertIRToGE`、`convertGEToIR`、基础类型。
65
- - sibling 包 API:`readLottieSpecific`、`isTransformOnlyParentLink`、部分 GE 处理中间类型。
66
- - debug internals:bezier/timeline/post-process/utils 等调试链路会用到的内部符号。
314
+ [MIT](./LICENSE) © 2019-present Ant Group Co., Ltd.
@@ -0,0 +1,3 @@
1
+ import type { IRLayerType, IRTransform } from '@vvfx/animation-ir';
2
+ /** Apply GE's parented visual rotation convention to an anchor position offset. */
3
+ export declare function rotateAnchorOffsetForParentedVisual(layerType: IRLayerType, hasParent: boolean, transform: IRTransform | undefined, offsetX: number, offsetY: number): [number, number];
@@ -0,0 +1,19 @@
1
+ import { CameraClipMode } from '@galacean/effects-specification';
2
+ /** Default camera Z position for 2D GE scenes. */
3
+ export declare const DEFAULT_CAMERA_Z = 8;
4
+ /** Default camera field of view for 2D GE scenes. */
5
+ export declare const DEFAULT_CAMERA_FOV = 60;
6
+ /** Default camera clipping mode for 2D GE scenes. */
7
+ export declare const DEFAULT_CLIP_MODE = CameraClipMode.portrait;
8
+ /** Return the pixel-to-world scale for the given canvas. */
9
+ export declare function get2dTo3dRatio(width: number, height: number): number;
10
+ /**
11
+ * Convert a canvas point from a top-left origin to GE world space with a centered
12
+ * origin and inverted Y axis. The Z value is included in the perspective adjustment.
13
+ */
14
+ export declare function convert2dTo3dPoint(x: number, y: number, z: number, width: number, height: number): [number, number, number];
15
+ /**
16
+ * Convert a GE world-space point to a top-left canvas coordinate while
17
+ * preserving its perspective-adjusted Z value.
18
+ */
19
+ export declare function convert3dTo2dPoint(x: number, y: number, z: number, width: number, height: number): [number, number, number];
@@ -0,0 +1,14 @@
1
+ import type { DataPath } from '@galacean/effects-specification';
2
+ type GERecord = Record<string, unknown>;
3
+ /** GE scene collection indexed by entity ID. */
4
+ export type GESceneCollectionIndex = Map<string, GERecord>;
5
+ /** Wrap an ID in a GE DataPath reference. */
6
+ export declare function toDataPath(id: string): DataPath;
7
+ /** Index GE scene collection entries by string ID. */
8
+ export declare function buildSceneCollectionIndex(collection: GERecord[] | undefined): GESceneCollectionIndex;
9
+ /** Resolve a GE DataPath against an indexed scene collection. */
10
+ export declare function resolveDataPath(collectionIndex: GESceneCollectionIndex, reference: unknown): GERecord | undefined;
11
+ /** Return the string ID stored in a GE DataPath-like value. */
12
+ export declare function resolveDataPathId(reference: unknown): string | undefined;
13
+ export declare function visitDataPathReferences(value: unknown, visit: (id: string) => void, visited?: WeakSet<object>): void;
14
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Generate a 32-character hexadecimal UUID v4. */
2
+ export declare function createId(): string;
@@ -0,0 +1,3 @@
1
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
2
+ /** Clone and normalize a value to its JSON-persisted runtime shape. */
3
+ export declare function normalizeJsonValue<T>(value: T): T;
@@ -0,0 +1,4 @@
1
+ /** Round a number to the given decimal precision. */
2
+ export declare function roundNumber(value: number, precision?: number): number;
3
+ /** Interpolate linearly between `a` and `b`. */
4
+ export declare function lerp(a: number, b: number, factor: number): number;
@@ -0,0 +1,4 @@
1
+ import type { IRParticleScalarExpression } from '@vvfx/animation-ir';
2
+ import { type NumberExpression } from '@galacean/effects-specification';
3
+ export declare function parseGEParticleScalarExpression(value: unknown): IRParticleScalarExpression | undefined;
4
+ export declare function convertIRParticleScalarExpressionToGE(expression: IRParticleScalarExpression): NumberExpression;
@@ -0,0 +1,21 @@
1
+ import type { JSONScene } from '@galacean/effects-specification';
2
+ import type { IRScene } from '@vvfx/animation-ir';
3
+ import type { ConversionDiagnostic } from '@vvfx/animation-ir/adapter';
4
+ import type { GEToIRPreservedData } from './preserved-data';
5
+ /** Result of importing a GE JSONScene into normalized Animation IR. */
6
+ export interface GEToIRResult {
7
+ scene: IRScene;
8
+ preservedData: GEToIRPreservedData;
9
+ diagnostics: ConversionDiagnostic[];
10
+ }
11
+ /** Result of lowering a normalized Animation IR scene to a GE JSONScene. */
12
+ export interface IRToGEResult {
13
+ /** Generated GE Item IDs mapped to their source IR Layer IDs. */
14
+ itemLayerIds: Readonly<Record<string, string>>;
15
+ scene: JSONScene;
16
+ diagnostics: ConversionDiagnostic[];
17
+ }
18
+ export interface IRToGEOptions {
19
+ duration?: number;
20
+ preservedData?: GEToIRPreservedData;
21
+ }
@@ -0,0 +1,4 @@
1
+ import type { IRComposition, IRLayer } from '@vvfx/animation-ir';
2
+ import type { GESceneContext } from './types';
3
+ /** Assemble parsed GE data into the final normalized IR composition. */
4
+ export declare function assembleIRComposition(layers: IRLayer[], ctx: GESceneContext): IRComposition;
@@ -0,0 +1,4 @@
1
+ import type { GEToIROptions } from './types';
2
+ import type { GEToIRResult } from '../conversion';
3
+ /** Convert a GE scene to normalized IR plus adapter-owned preserved data. */
4
+ export declare function convertGEToIR(scene: Record<string, unknown>, options: GEToIROptions): GEToIRResult;
@@ -0,0 +1,5 @@
1
+ import type { IRScene } from '@vvfx/animation-ir';
2
+ import type { ConversionDiagnostic } from '@vvfx/animation-ir/adapter';
3
+ import type { GEParticleSourceData, GEToIRPreservedData } from '../preserved-data';
4
+ /** Extract source bindings and layout metadata needed to place restored ParticleSystems in a host scene. */
5
+ export declare function extractGEParticleSourceData(scene: IRScene, preservedData: GEToIRPreservedData, diagnostics: ConversionDiagnostic[]): GEParticleSourceData;
@@ -0,0 +1,5 @@
1
+ import { IRBlendMode, IREndBehavior, type IRLayerTime } from '@vvfx/animation-ir';
2
+ import { EndBehavior } from '@galacean/effects-specification';
3
+ export declare function mapBlendModeToIR(GECode: number | undefined): IRBlendMode | undefined;
4
+ export declare function mapEndBehaviorToIR(GEBehavior: EndBehavior | undefined): IREndBehavior | undefined;
5
+ export declare function mapLayerTimingToIR(delay: number, duration: number, frameRate: number, compositionInPoint?: number): IRLayerTime;
@@ -1,4 +1,4 @@
1
- import type { IRAnimatedProperty, IRTransformChannels } from '@vvfx/animation-ir';
1
+ import type { IRAnimatedProperty, IRTransform } from '@vvfx/animation-ir';
2
2
  import type { GESceneContext } from '../types';
3
- export declare function parseTransformAnimation(asset: Record<string, unknown>, startFrame: number, endFrame: number, ctx: GESceneContext): Partial<IRTransformChannels>;
3
+ export declare function parseTransformAnimation(asset: Record<string, unknown>, startFrame: number, endFrame: number, ctx: GESceneContext): Partial<IRTransform>;
4
4
  export declare function parseOpacityAnimation(asset: Record<string, unknown>, startFrame: number, endFrame: number): IRAnimatedProperty<number> | undefined;
@@ -0,0 +1,22 @@
1
+ import type { IRBlendMode, IRColor, IRLocalBounds, IRParticleContent, IRShape, IRTextContent } from '@vvfx/animation-ir';
2
+ import type { GESceneContext } from '../types';
3
+ import type { EffectsSpriteSplit, EffectsTextSizeMode, EffectsTextureSheetAnimation } from '../../preserved-data';
4
+ interface ParsedComponentData {
5
+ type: 'image' | 'solid' | 'text' | 'shape' | 'particle';
6
+ imageAssetId?: string;
7
+ spriteStartColor?: IRColor;
8
+ text?: IRTextContent;
9
+ textBounds?: IRLocalBounds;
10
+ shapes?: IRShape[];
11
+ blendMode?: IRBlendMode;
12
+ anchorScale?: [number, number];
13
+ spriteSplits?: EffectsSpriteSplit[];
14
+ textureSheetAnimation?: EffectsTextureSheetAnimation;
15
+ textSizeMode?: EffectsTextSizeMode;
16
+ GEComponentId?: string;
17
+ rawMask?: Record<string, unknown>;
18
+ particle?: IRParticleContent;
19
+ rawParticleContent?: Record<string, unknown>;
20
+ }
21
+ export declare function parseComponent(item: Record<string, unknown>, ctx: GESceneContext): ParsedComponentData | undefined;
22
+ export {};
@@ -1,7 +1,7 @@
1
1
  import type { IRBezierHandle, IRKeyframe } from '@vvfx/animation-ir';
2
2
  export declare function parseBezierKeyframes(curves: unknown[], startFrame: number, endFrame: number): IRKeyframe<number>[];
3
3
  export declare function parsePositionTimingKeyframes(curves: unknown[], startFrame: number, endFrame: number): Array<{
4
- t: number;
4
+ frame: number;
5
5
  outTangent?: IRBezierHandle;
6
6
  inTangent?: IRBezierHandle;
7
7
  }>;
@@ -0,0 +1,13 @@
1
+ import { type IRLayer } from '@vvfx/animation-ir';
2
+ import type { GESceneContext } from '../types';
3
+ import type { EffectsLayerPreservedData } from '../../preserved-data';
4
+ export interface ParsedItemLayer {
5
+ layer: IRLayer;
6
+ preservedData: EffectsLayerPreservedData;
7
+ }
8
+ /** Parse one GE item and its referenced component data into an IR layer. */
9
+ export declare function parseItemToLayer(item: Record<string, unknown>, itemId: string, ctx: GESceneContext): ParsedItemLayer | undefined;
10
+ export declare function readItemSize(itemTransform: Record<string, unknown> | undefined): {
11
+ x: number;
12
+ y: number;
13
+ } | undefined;
@@ -0,0 +1,7 @@
1
+ import type { IRParticleContent } from '@vvfx/animation-ir';
2
+ export interface ParsedGEParticleComponent {
3
+ particle: IRParticleContent;
4
+ rawParticleContent: Record<string, unknown>;
5
+ normalizedBurstRuntimeDefaults: boolean;
6
+ }
7
+ export declare function parseParticleComponent(component: Record<string, unknown>, frameRate: number): ParsedGEParticleComponent | undefined;
@@ -0,0 +1,4 @@
1
+ import { type ConversionDiagnostic } from '@vvfx/animation-ir/adapter';
2
+ import type { GEAssetRegistry, GEToIROptions, GESceneContext } from '../types';
3
+ export declare function buildSceneContext(scene: Record<string, unknown>, options: GEToIROptions, compositionId?: string, compositionIdBySourceId?: ReadonlyMap<string, string>, compositionStartFrameBySourceId?: ReadonlyMap<string, number>, assetRegistry?: GEAssetRegistry, diagnostics?: ConversionDiagnostic[]): GESceneContext;
4
+ export declare function getCompositionItemIds(scene: Record<string, unknown>, compositionId?: string): string[];
@@ -1,9 +1,11 @@
1
+ import { EndBehavior } from '@galacean/effects-specification';
1
2
  import type { GESceneContext } from '../types';
2
- export interface TimelineData {
3
+ interface ParsedTimelineData {
3
4
  delay: number;
4
5
  duration: number;
5
- endBehavior: number;
6
+ activationEndBehavior?: EndBehavior;
6
7
  transformAsset?: Record<string, unknown>;
7
8
  spriteColorAsset?: Record<string, unknown>;
8
9
  }
9
- export declare function parseTimeline(itemId: string, ctx: GESceneContext): TimelineData | undefined;
10
+ export declare function parseTimeline(itemId: string, ctx: GESceneContext): ParsedTimelineData | undefined;
11
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { IRTransform } from '@vvfx/animation-ir';
2
+ import type { GESceneContext } from '../types';
3
+ export declare function parseStaticTransform(itemTransform: Record<string, unknown>, ctx: GESceneContext): Partial<IRTransform>;
@@ -0,0 +1,10 @@
1
+ import type { ConversionDiagnostic } from '@vvfx/animation-ir/adapter';
2
+ import type { RawLayerDescriptor } from '../post-process';
3
+ import type { GESceneContext } from '../types';
4
+ export interface GEMaskNormalizationComposition {
5
+ sourceCompositionId: string;
6
+ ctx: GESceneContext;
7
+ descriptors: RawLayerDescriptor[];
8
+ }
9
+ /** Normalize GE component mask references into Layer mattes or a strict cross-Composition path fallback. */
10
+ export declare function normalizeSingleGEMasks(compositions: GEMaskNormalizationComposition[], diagnostics: ConversionDiagnostic[]): void;
@@ -1,9 +1,11 @@
1
- import type { IRLayerNode } from '@vvfx/animation-ir';
2
- import type { GESceneContext } from '../types';
1
+ import type { IRLayer } from '@vvfx/animation-ir';
2
+ import type { GESceneContext } from './types';
3
+ import type { EffectsLayerPreservedData } from '../preserved-data';
3
4
  export interface RawLayerDescriptor {
4
5
  itemId: string;
5
6
  item: Record<string, unknown>;
6
- layer: IRLayerNode;
7
+ layer: IRLayer;
8
+ preservedData: EffectsLayerPreservedData;
7
9
  }
8
10
  export declare function mergeNullSpritePairs(descriptors: RawLayerDescriptor[], ctx: GESceneContext): RawLayerDescriptor[];
9
11
  export declare function resolveHierarchy(descriptors: RawLayerDescriptor[], ctx: GESceneContext): void;
@@ -1,10 +1,25 @@
1
- import type { IRColor, IREndBehavior } from '@vvfx/animation-ir';
2
- import type { GEPoolIndex } from '../shared/types';
3
- export interface GE2IROptions {
1
+ import type { IRColor, IREndBehavior, IRFontAsset, IRImageAsset } from '@vvfx/animation-ir';
2
+ import type { ConversionDiagnostic } from '@vvfx/animation-ir/adapter';
3
+ import type { GESceneCollectionIndex } from '../common/data-path';
4
+ /** Options for converting a GE scene to IR. */
5
+ export interface GEToIROptions {
4
6
  frameRate: number;
7
+ resourceBaseUrl?: string;
8
+ }
9
+ export interface GEAssetRegistry {
10
+ imageAssetById: Map<string, IRImageAsset>;
11
+ imageAssetIdBySourceId: Map<string, string>;
12
+ fontAssetById: Map<string, IRFontAsset>;
13
+ fontAssetIdByIdentity: Map<string, string>;
5
14
  }
6
- export type { GE2IRPassthroughMetadata } from '../shared/ge2ir-metadata';
7
15
  export interface GESceneContext {
16
+ diagnostics: ConversionDiagnostic[];
17
+ compositionId: string;
18
+ irCompositionId: string;
19
+ compositionIdBySourceId: ReadonlyMap<string, string>;
20
+ compositionStartFrameBySourceId: ReadonlyMap<string, number>;
21
+ compositionStartTime: number;
22
+ resourceBaseUrl?: string;
8
23
  width: number;
9
24
  height: number;
10
25
  frameRate: number;
@@ -12,13 +27,18 @@ export interface GESceneContext {
12
27
  duration: number;
13
28
  inPoint: number;
14
29
  outPoint: number;
15
- compositionName: string;
16
- endBehavior?: IREndBehavior;
30
+ compositionName?: string;
31
+ endBehavior: IREndBehavior;
17
32
  backgroundColor?: IRColor;
18
- itemById: GEPoolIndex;
19
- componentById: GEPoolIndex;
20
- miscById: GEPoolIndex;
21
- imageById: GEPoolIndex;
22
- textureById: GEPoolIndex;
33
+ itemById: GESceneCollectionIndex;
34
+ componentById: GESceneCollectionIndex;
35
+ miscById: GESceneCollectionIndex;
36
+ imageById: GESceneCollectionIndex;
37
+ textureById: GESceneCollectionIndex;
38
+ imageAssetById: Map<string, IRImageAsset>;
39
+ imageAssetIdBySourceId: Map<string, string>;
40
+ fontDefinitionByFamily: Map<string, Record<string, unknown>>;
41
+ fontAssetById: Map<string, IRFontAsset>;
42
+ fontAssetIdByIdentity: Map<string, string>;
23
43
  itemIdToTrackId: Map<string, string>;
24
44
  }