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

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