@vvfx/artis 0.0.1-alpha.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 +22 -0
- package/dist/artis/artis.d.ts +44 -0
- package/dist/artis/base-artis.d.ts +520 -0
- package/dist/artis/canvas-layer-order.d.ts +19 -0
- package/dist/artis/create-info-to-schema.d.ts +21 -0
- package/dist/artis/index.d.ts +15 -0
- package/dist/artis/operations/index.d.ts +3 -0
- package/dist/artis/operations/operations.d.ts +362 -0
- package/dist/artis/operations/scene-operations.d.ts +26 -0
- package/dist/artis/operations/types.d.ts +39 -0
- package/dist/artis/scene-artis.d.ts +386 -0
- package/dist/artis/screenshot-service.d.ts +83 -0
- package/dist/artis/types.d.ts +130 -0
- package/dist/artis/wiring/index.d.ts +17 -0
- package/dist/artis/wiring/register-commands.d.ts +44 -0
- package/dist/artis/wiring/setup-commands.d.ts +5 -0
- package/dist/artis/wiring/setup-event-bindings.d.ts +16 -0
- package/dist/artis/wiring/setup-keybindings.d.ts +38 -0
- package/dist/artis/wiring/setup-plugins.d.ts +5 -0
- package/dist/artis/wiring/wiring-context.d.ts +34 -0
- package/dist/artis-sdk/artis-sdk.d.ts +1117 -0
- package/dist/artis-sdk/index.d.ts +1 -0
- package/dist/core/asset/asset-manager.d.ts +288 -0
- package/dist/core/asset/index.d.ts +3 -0
- package/dist/core/command/command-service.d.ts +315 -0
- package/dist/core/command/commands/composite-command.d.ts +45 -0
- package/dist/core/command/commands/frame-layout-command.d.ts +81 -0
- package/dist/core/command/commands/frame-layout-mode-command.d.ts +55 -0
- package/dist/core/command/commands/frame-move-in-command.d.ts +54 -0
- package/dist/core/command/commands/frame-move-out-command.d.ts +54 -0
- package/dist/core/command/commands/group-children-detach-command.d.ts +28 -0
- package/dist/core/command/commands/index.d.ts +98 -0
- package/dist/core/command/commands/item-align-command.d.ts +52 -0
- package/dist/core/command/commands/item-create-command.d.ts +66 -0
- package/dist/core/command/commands/item-delete-command.d.ts +40 -0
- package/dist/core/command/commands/item-distribute-command.d.ts +53 -0
- package/dist/core/command/commands/item-group-command.d.ts +41 -0
- package/dist/core/command/commands/item-reorder-command.d.ts +41 -0
- package/dist/core/command/commands/item-replace-source-command.d.ts +48 -0
- package/dist/core/command/commands/item-set-font-family-command.d.ts +46 -0
- package/dist/core/command/commands/item-set-generator-resource-command.d.ts +40 -0
- package/dist/core/command/commands/item-transform-command.d.ts +51 -0
- package/dist/core/command/commands/item-ungroup-command.d.ts +34 -0
- package/dist/core/command/commands/item-update-property-by-create-info-command.d.ts +41 -0
- package/dist/core/command/commands/item-update-property-command.d.ts +82 -0
- package/dist/core/command/commands/mask-commit-command.d.ts +53 -0
- package/dist/core/command/commands/page-auto-layout-command.d.ts +53 -0
- package/dist/core/command/commands/picture-cut-commit-command.d.ts +43 -0
- package/dist/core/command/commands/picture-expand-commit-command.d.ts +35 -0
- package/dist/core/command/commands/scene-switch-command.d.ts +35 -0
- package/dist/core/command/commands/selection-set-command.d.ts +38 -0
- package/dist/core/command/commands/sprite-image-command.d.ts +36 -0
- package/dist/core/command/commands/sprite-text-edit-commit-command.d.ts +43 -0
- package/dist/core/command/commands/state-hand-command.d.ts +14 -0
- package/dist/core/command/commands/state-image-cut-command.d.ts +14 -0
- package/dist/core/command/commands/state-image-expand-command.d.ts +14 -0
- package/dist/core/command/commands/state-image-mask-command.d.ts +15 -0
- package/dist/core/command/commands/state-image-text-edit-command.d.ts +14 -0
- package/dist/core/command/commands/state-item-create-command.d.ts +34 -0
- package/dist/core/command/commands/state-move-command.d.ts +14 -0
- package/dist/core/command/commands/state-switch-command-base.d.ts +41 -0
- package/dist/core/command/commands/text-move-command.d.ts +47 -0
- package/dist/core/command/commands/text-rotate-command.d.ts +52 -0
- package/dist/core/command/commands/text-scale-command.d.ts +56 -0
- package/dist/core/command/commands/text-update-content-command.d.ts +51 -0
- package/dist/core/command/commands/transform-move-command.d.ts +56 -0
- package/dist/core/command/commands/transform-move-with-frame-change-command.d.ts +80 -0
- package/dist/core/command/commands/transform-move-with-layout-command.d.ts +56 -0
- package/dist/core/command/commands/transform-rotate-command.d.ts +51 -0
- package/dist/core/command/commands/transform-scale-command.d.ts +54 -0
- package/dist/core/command/commands/video-play-command.d.ts +28 -0
- package/dist/core/command/commands/video-source-command.d.ts +39 -0
- package/dist/core/command/commands/viewport-fit-to-box-command.d.ts +37 -0
- package/dist/core/command/commands/viewport-fit-to-items-command.d.ts +43 -0
- package/dist/core/command/commands/viewport-move-command.d.ts +34 -0
- package/dist/core/command/commands/viewport-zoom-command.d.ts +35 -0
- package/dist/core/command/index.d.ts +5 -0
- package/dist/core/command/registry.d.ts +246 -0
- package/dist/core/command/types.d.ts +124 -0
- package/dist/core/element-registry/element-facade.d.ts +35 -0
- package/dist/core/element-registry/element-identity-strategy.d.ts +75 -0
- package/dist/core/element-registry/element-registry.d.ts +72 -0
- package/dist/core/element-registry/index.d.ts +5 -0
- package/dist/core/element-registry/types.d.ts +15 -0
- package/dist/core/gizmo/gizmo-bootstrap.d.ts +70 -0
- package/dist/core/gizmo/gizmo-command-binder.d.ts +55 -0
- package/dist/core/gizmo/gizmo-config-override.d.ts +24 -0
- package/dist/core/gizmo/gizmo-registry.d.ts +39 -0
- package/dist/core/gizmo/index.d.ts +19 -0
- package/dist/core/gizmo/register-gizmo-command-bindings.d.ts +20 -0
- package/dist/core/gizmo/state-gizmo-controller.d.ts +20 -0
- package/dist/core/history/history-manager.d.ts +174 -0
- package/dist/core/history/index.d.ts +1 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/item/base-item.d.ts +154 -0
- package/dist/core/item/card-item.d.ts +91 -0
- package/dist/core/item/default-item-schema.d.ts +20 -0
- package/dist/core/item/effects-item.d.ts +99 -0
- package/dist/core/item/frame-item.d.ts +153 -0
- package/dist/core/item/generator-item.d.ts +114 -0
- package/dist/core/item/group-item.d.ts +51 -0
- package/dist/core/item/index.d.ts +25 -0
- package/dist/core/item/sprite-item.d.ts +80 -0
- package/dist/core/item/text-item.d.ts +171 -0
- package/dist/core/item/types.d.ts +158 -0
- package/dist/core/item/video-item.d.ts +120 -0
- package/dist/core/keybinding/index.d.ts +11 -0
- package/dist/core/keybinding/key-binding-controller.d.ts +44 -0
- package/dist/core/keybinding/key-binding-registry.d.ts +92 -0
- package/dist/core/keybinding/key-binding-store.d.ts +29 -0
- package/dist/core/keybinding/key-matcher.d.ts +24 -0
- package/dist/core/keybinding/types.d.ts +84 -0
- package/dist/core/plugin/index.d.ts +3 -0
- package/dist/core/plugin/io-plugin.d.ts +167 -0
- package/dist/core/plugin/plugin-system.d.ts +77 -0
- package/dist/core/predict/align-predict.d.ts +20 -0
- package/dist/core/predict/base/box-ops.d.ts +40 -0
- package/dist/core/predict/base/index.d.ts +14 -0
- package/dist/core/predict/base/parent-coord.d.ts +29 -0
- package/dist/core/predict/base/schema-box.d.ts +21 -0
- package/dist/core/predict/distribute-predict.d.ts +19 -0
- package/dist/core/predict/frame-layout-predict.d.ts +24 -0
- package/dist/core/predict/index.d.ts +12 -0
- package/dist/core/preferences/index.d.ts +2 -0
- package/dist/core/preferences/user-preferences-manager.d.ts +130 -0
- package/dist/core/quality/error-monitor/error-monitor-facade.d.ts +73 -0
- package/dist/core/quality/error-monitor/error-monitor.d.ts +106 -0
- package/dist/core/quality/error-monitor/index.d.ts +4 -0
- package/dist/core/quality/error-monitor/types.d.ts +198 -0
- package/dist/core/quality/index.d.ts +3 -0
- package/dist/core/quality/perf-monitor/index.d.ts +5 -0
- package/dist/core/quality/perf-monitor/perf-monitor-facade.d.ts +45 -0
- package/dist/core/quality/perf-monitor/perf-monitor.d.ts +60 -0
- package/dist/core/quality/perf-monitor/types.d.ts +66 -0
- package/dist/core/quality/stability-monitor/index.d.ts +5 -0
- package/dist/core/quality/stability-monitor/stability-monitor-facade.d.ts +50 -0
- package/dist/core/quality/stability-monitor/stability-monitor.d.ts +61 -0
- package/dist/core/quality/stability-monitor/types.d.ts +69 -0
- package/dist/core/renderer/background-controller.d.ts +56 -0
- package/dist/core/renderer/index.d.ts +5 -0
- package/dist/core/renderer/player-adapter.d.ts +129 -0
- package/dist/core/renderer/renderer.d.ts +134 -0
- package/dist/core/service/frame-service.d.ts +116 -0
- package/dist/core/service/index.d.ts +9 -0
- package/dist/core/service/interaction-providers.d.ts +20 -0
- package/dist/core/service/interaction-service.d.ts +211 -0
- package/dist/core/service/item-asset-service.d.ts +120 -0
- package/dist/core/service/item-creator-service.d.ts +211 -0
- package/dist/core/service/item-service.d.ts +641 -0
- package/dist/core/service/item-sync-service.d.ts +66 -0
- package/dist/core/service/json-scene-sync-service.d.ts +140 -0
- package/dist/core/service/refresh-animation-base-service.d.ts +1 -0
- package/dist/core/service/scene-data-assembler.d.ts +166 -0
- package/dist/core/service/view-service.d.ts +202 -0
- package/dist/core/state/base-state.d.ts +28 -0
- package/dist/core/state/index.d.ts +6 -0
- package/dist/core/state/presets.d.ts +25 -0
- package/dist/core/state/state-manager.d.ts +50 -0
- package/dist/core/state/types.d.ts +52 -0
- package/dist/core/store/index.d.ts +3 -0
- package/dist/core/store/scene-store.d.ts +194 -0
- package/dist/core/store/store.d.ts +36 -0
- package/dist/core/types/artis-config.d.ts +186 -0
- package/dist/core/types/artis-events.d.ts +101 -0
- package/dist/core/types/frame.d.ts +3 -0
- package/dist/core/types/generator.d.ts +28 -0
- package/dist/core/types/index.d.ts +15 -0
- package/dist/core/types/item-create-info.d.ts +205 -0
- package/dist/core/types/item-property.d.ts +149 -0
- package/dist/core/types/item-reorder.d.ts +12 -0
- package/dist/core/types/item-schema.d.ts +263 -0
- package/dist/core/types/item-set-property.d.ts +48 -0
- package/dist/core/types/page.d.ts +40 -0
- package/dist/core/types/sdk.d.ts +28 -0
- package/dist/core/types/view.d.ts +39 -0
- package/dist/helper/exporter/config.d.ts +18 -0
- package/dist/helper/exporter/const.d.ts +71 -0
- package/dist/helper/exporter/export-media.d.ts +189 -0
- package/dist/helper/exporter/exporter.d.ts +58 -0
- package/dist/helper/exporter/index.d.ts +2 -0
- package/dist/helper/exporter/types.d.ts +194 -0
- package/dist/helper/exporter/utils.d.ts +71 -0
- package/dist/helper/exporter/wav-audio.d.ts +35 -0
- package/dist/helper/html-overlay/anchor-navigation-runtime.d.ts +1 -0
- package/dist/helper/html-overlay/auto-height-layout.d.ts +16 -0
- package/dist/helper/html-overlay/auto-height-runtime.d.ts +40 -0
- package/dist/helper/html-overlay/document-runtime.d.ts +18 -0
- package/dist/helper/html-overlay/document-transform.d.ts +46 -0
- package/dist/helper/html-overlay/dom-order.d.ts +5 -0
- package/dist/helper/html-overlay/host-message-runtime.d.ts +15 -0
- package/dist/helper/html-overlay/html-capture-runtime.d.ts +12 -0
- package/dist/helper/html-overlay/html-card-service.d.ts +287 -0
- package/dist/helper/html-overlay/html-viewport-style.d.ts +6 -0
- package/dist/helper/html-overlay/index.d.ts +1 -0
- package/dist/helper/html-overlay/inline-script-json.d.ts +1 -0
- package/dist/helper/html-overlay/mime-utils.d.ts +13 -0
- package/dist/helper/html-overlay/overlay-transform.d.ts +30 -0
- package/dist/helper/html-overlay/path-utils.d.ts +34 -0
- package/dist/helper/html-overlay/runtime-context.d.ts +2 -0
- package/dist/helper/html-overlay/shell-runtime.d.ts +13 -0
- package/dist/helper/index.d.ts +5 -0
- package/dist/helper/scene-builder.d.ts +111 -0
- package/dist/helper/screen-shot.d.ts +51 -0
- package/dist/helper/size-adapt.d.ts +88 -0
- package/dist/index.cjs +69350 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.mjs +68963 -0
- package/dist/index.mjs.map +1 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/player.d.ts +9 -0
- package/dist/utils/background-manager.d.ts +76 -0
- package/dist/utils/common-utils.d.ts +39 -0
- package/dist/utils/container-size.d.ts +7 -0
- package/dist/utils/find-player-item.d.ts +9 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/json-data-utils.d.ts +198 -0
- package/dist/utils/layout-utils.d.ts +144 -0
- package/dist/utils/pixel-box-utils.d.ts +26 -0
- package/dist/utils/player-data-utils.d.ts +9 -0
- package/dist/utils/player-utils.d.ts +42 -0
- package/dist/utils/replay-utils.d.ts +22 -0
- package/dist/utils/types.d.ts +130 -0
- package/package.json +66 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Store } from '../store';
|
|
2
|
+
import type { Selection } from '@vvfx/gizmo';
|
|
3
|
+
import type { InteractionService } from './interaction-service';
|
|
4
|
+
import type { Renderer } from '../renderer';
|
|
5
|
+
/**
|
|
6
|
+
* ItemSyncService - Player → Store 数据同步服务
|
|
7
|
+
*
|
|
8
|
+
* 负责将 Player 层 VFXItem 的 transform 数据回写到 Store 中的 ArtisItem.property,
|
|
9
|
+
* 包括:
|
|
10
|
+
* 1. syncItemTransform:单个元素同步
|
|
11
|
+
* 2. syncAllItemsFromPlayer:全量同步(Command 执行后)
|
|
12
|
+
* 3. syncSelectedItemsTransform:选中元素同步(Gizmo 拖拽后)
|
|
13
|
+
* 4. syncRenderOrder:图层顺序同步
|
|
14
|
+
*/
|
|
15
|
+
export declare class ItemSyncService {
|
|
16
|
+
private _store;
|
|
17
|
+
private _renderer;
|
|
18
|
+
private _selection?;
|
|
19
|
+
private _interactionService;
|
|
20
|
+
/** 查找 Player 元素(注入避免循环依赖) */
|
|
21
|
+
private _findPlayerItemById;
|
|
22
|
+
/** vfxItemId → 元素ID 翻译(反向同步用,注入避免循环依赖)。未注册时返回 undefined,调用方兜底原值 */
|
|
23
|
+
private _elementIdOf;
|
|
24
|
+
/**
|
|
25
|
+
* 注入依赖与 Player 元素查找回调
|
|
26
|
+
*
|
|
27
|
+
* selection 在 GizmoManager 装配后才存在,故构造时不传,
|
|
28
|
+
* 由 {@link ItemService.setSelection} 在装配后回填。
|
|
29
|
+
* @param options 构造选项
|
|
30
|
+
*/
|
|
31
|
+
constructor(options: {
|
|
32
|
+
store: Store;
|
|
33
|
+
renderer: Renderer;
|
|
34
|
+
interactionService: InteractionService;
|
|
35
|
+
findPlayerItemById: (id: string) => any;
|
|
36
|
+
elementIdOf: (vfxItemId: string) => string | undefined;
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* 回填 Selection 实例(由 ItemService 在 GizmoManager 装配后注入)。
|
|
40
|
+
* @param selection 选中态真源(来自 GizmoManager)
|
|
41
|
+
*/
|
|
42
|
+
setSelection(selection: Selection): void;
|
|
43
|
+
/**
|
|
44
|
+
* 同步 Store.items 的顺序到 Player 层的 renderOrder
|
|
45
|
+
*
|
|
46
|
+
* 在图层顺序变更后调用,将 Store 中的 items 顺序同步到 Player VFXItem 的 renderOrder。
|
|
47
|
+
*/
|
|
48
|
+
syncRenderOrder(): void;
|
|
49
|
+
/**
|
|
50
|
+
* 同步选中元素的变换信息(VFXItem.transform → ArtisItem.property)
|
|
51
|
+
*
|
|
52
|
+
* 在 ResizeSelectionGizmo 拖拽结束后调用,将 Player 层的变换数据回写到 Store。
|
|
53
|
+
*/
|
|
54
|
+
syncSelectedItemsTransform(): void;
|
|
55
|
+
/**
|
|
56
|
+
* 同步所有元素的变换(VFXItem.transform → ArtisItem.property)
|
|
57
|
+
*
|
|
58
|
+
* 在 Command 执行后调用,确保 Store 中的数据与 Player 层保持一致。
|
|
59
|
+
*/
|
|
60
|
+
syncAllItemsFromPlayer(): void;
|
|
61
|
+
/**
|
|
62
|
+
* 同步单个元素的变换(VFXItem.transform → ArtisItem.property + Scene JSON)
|
|
63
|
+
* @param id 元素实例 ID
|
|
64
|
+
*/
|
|
65
|
+
syncItemTransform(id: string): void;
|
|
66
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { spec } from '../../shared';
|
|
2
|
+
import { type ArtisItem } from '../item';
|
|
3
|
+
import { type SceneStore } from '../store';
|
|
4
|
+
import { type Renderer } from '../renderer';
|
|
5
|
+
import { type AssetManager } from '../asset';
|
|
6
|
+
import { type IOPlugin } from '../plugin/io-plugin';
|
|
7
|
+
/**
|
|
8
|
+
* JsonSceneSyncService - ArtisItem 变更 → 激活场景 JSONScene 回写
|
|
9
|
+
*
|
|
10
|
+
* 承载需求4「修改元素时同步修改场景 JSON」。在现有「ArtisItem → VFXItem」单向同步之上,
|
|
11
|
+
* 增加「ArtisItem → JSONScene」原地回写。
|
|
12
|
+
*
|
|
13
|
+
* 与 IOPlugin.exportScene 的本质区别:后者现场拼装新 JSONScene;
|
|
14
|
+
* 本服务是**原地保活现有 JSON 的动画时间线**(TimelineAsset / Track),
|
|
15
|
+
* 仅更新静态 transform / content 字段,不破坏关键帧。
|
|
16
|
+
*
|
|
17
|
+
* v1 采用「按需全量回写变更 item」(简单可靠);增量脏标记优化列为后续。
|
|
18
|
+
*/
|
|
19
|
+
export declare class JsonSceneSyncService {
|
|
20
|
+
private _sceneStore;
|
|
21
|
+
private _renderer;
|
|
22
|
+
private _assetManager;
|
|
23
|
+
/** IOPlugin 引用(含资源序列化,由 SceneArtis 在 IOPlugin 激活后回填;空时 insert 降级单体骨架) */
|
|
24
|
+
private _ioPlugin?;
|
|
25
|
+
/**
|
|
26
|
+
* 注入场景存储、渲染管线与资源管理器(后两者预留给后续资源类回写扩展)
|
|
27
|
+
* @param deps 依赖项
|
|
28
|
+
*/
|
|
29
|
+
constructor(deps: {
|
|
30
|
+
sceneStore: SceneStore;
|
|
31
|
+
renderer: Renderer;
|
|
32
|
+
assetManager: AssetManager;
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* 回填 IOPlugin 引用(由 SceneArtis 在 setupPlugins 激活 IOPlugin 后注入)。
|
|
36
|
+
*
|
|
37
|
+
* IOPlugin 激活晚于本服务构造(BaseArtis ctor step 6 vs SceneArtis ctor),
|
|
38
|
+
* 故构造时不传、激活后回填。注入后,会话内新建元素 insert 走 {@link IOPlugin.serializeItemWithAssets}
|
|
39
|
+
* 联动并入 images/videos/textures,保证 reload 后图/视频资源可复建;未注入时降级单体骨架。
|
|
40
|
+
* @param ioPlugin IOPlugin 实例;undefined 可解绑
|
|
41
|
+
*/
|
|
42
|
+
setIOPlugin(ioPlugin?: IOPlugin): void;
|
|
43
|
+
/**
|
|
44
|
+
* 同步发生变更的 item(全量回写),写入当前激活 SceneEntry.scene。
|
|
45
|
+
* 不存在的 item 跳过;JSON 中找不到对应 id 的 item 跳过。
|
|
46
|
+
* @param items 发生变更的 ArtisItem 列表
|
|
47
|
+
*/
|
|
48
|
+
syncDirty(items: ArtisItem[]): void;
|
|
49
|
+
/**
|
|
50
|
+
* 同步单个 ArtisItem 到激活场景 JSON。
|
|
51
|
+
* @param item 待同步的 ArtisItem
|
|
52
|
+
*/
|
|
53
|
+
syncItem(item: ArtisItem): void;
|
|
54
|
+
/**
|
|
55
|
+
* 把单个 ArtisItem 的静态字段回写到 JSONScene.items 中对应 id 的 item。
|
|
56
|
+
* 仅写 transform(position/eulerHint/scale/size)与类型专属 content;不动 timeline。
|
|
57
|
+
*
|
|
58
|
+
* **新建元素 insert**(F1):会话内 createItem 产出的元素(id 为 runtime instanceId,
|
|
59
|
+
* 原不在 JSON 中)经 afterExecute → syncDirty 首次回写时,由 {@link serializeArtisItemToJSON}
|
|
60
|
+
* 构造 VFXItemData 骨架插入 scene.items,使其持久化/可导出。reload 后 Player 以 JSON item.id
|
|
61
|
+
* 作 instanceId,artisItem.id 不变,自洽。
|
|
62
|
+
*
|
|
63
|
+
* 资源引用完整化(sprite/video 的 texture、effects/frame 的子预合成 scene)为后续阶段(F1b);
|
|
64
|
+
* 当前骨架 insert 已保证元素不彻底丢失、transform/结构/text 内容持久。
|
|
65
|
+
*
|
|
66
|
+
* @param artisItem 待回写的 ArtisItem
|
|
67
|
+
* @param scene 目标 JSONScene
|
|
68
|
+
* @returns 是否实际发生回写
|
|
69
|
+
*/
|
|
70
|
+
private _syncItemIntoScene;
|
|
71
|
+
/**
|
|
72
|
+
* 会话内新建元素(id 不在原 JSON)insert 到 scene。
|
|
73
|
+
*
|
|
74
|
+
* 优先走 {@link IOPlugin.serializeItemWithAssets}:取含资源的完整 item+components+images/videos/textures,
|
|
75
|
+
* 联动并入 scene 各数组,使 reload 后图/视频资源可复建(sprite/video 完整)。
|
|
76
|
+
* IOPlugin 未注入或元素不支持序列化时,降级用 {@link serializeArtisItemToJSON} 单体骨架
|
|
77
|
+
* (仅 item+transform+text content,无资源——F1 主路径行为)。
|
|
78
|
+
*
|
|
79
|
+
* effects/frame 的子预合成 scene 暂未序列化(reload 后 composition 为空壳),列为 F1c。
|
|
80
|
+
* @returns 是否成功 insert
|
|
81
|
+
*/
|
|
82
|
+
private _insertItemIntoScene;
|
|
83
|
+
/**
|
|
84
|
+
* 会话内新建 FRAME 元素 insert:用 {@link createFrameCompositionScene} 重建子预合成 scene,
|
|
85
|
+
* 委托通用 {@link _insertCompositionItemIntoScene} embed(F1c-frame)。
|
|
86
|
+
*/
|
|
87
|
+
private _insertFrameIntoScene;
|
|
88
|
+
/**
|
|
89
|
+
* 会话内新建 composition 型元素(FRAME / EFFECTS)insert 通用逻辑:
|
|
90
|
+
* 把子预合成 scene 整体 merge 进主 scene(extractSubCompositionToScene 的逆协议),
|
|
91
|
+
* 并 push 带 refId 的 placeholder composition item(refId 指向子 scene 顶层 composition)。
|
|
92
|
+
*
|
|
93
|
+
* 去重:子 composition id(subScene.compositionId)已在主 scene.compositions 时跳过 merge
|
|
94
|
+
* (二次 afterExecute 不重复插入;此时该元素 id 已在 items 走 update,正常情况下不会进此分支)。
|
|
95
|
+
*
|
|
96
|
+
* @param artisItem 元素(取 id/name/property.transform)
|
|
97
|
+
* @param subScene 子预合成 scene(frame 重建 / effects 缓存)
|
|
98
|
+
* @param scene 主 scene
|
|
99
|
+
* @returns 是否成功 insert
|
|
100
|
+
*/
|
|
101
|
+
private _insertCompositionItemIntoScene;
|
|
102
|
+
/**
|
|
103
|
+
* 把子预合成 scene 整体 merge 进主 scene(extractSubCompositionToScene 的逆)。
|
|
104
|
+
* 联动并入 items/components/compositions/miscs/textures/images/videos 等数组,
|
|
105
|
+
* 按 id 去重防重复。子 scene 的顶层 composition(即子预合成本身)作为一条 CompositionData 进主 compositions。
|
|
106
|
+
*/
|
|
107
|
+
private _mergeSubSceneIntoScene;
|
|
108
|
+
/** 按 keyFn 的 key 去重后把 values push 到 scene[key](数组不存在则创建) */
|
|
109
|
+
private _pushArrayDedup;
|
|
110
|
+
/** 把 item push 到 scene.items(数组不存在则创建) */
|
|
111
|
+
private _pushItems;
|
|
112
|
+
/** 把 values push 到 scene[key](数组不存在则创建);values 为空时不动 */
|
|
113
|
+
private _pushArray;
|
|
114
|
+
/**
|
|
115
|
+
* 类型专属 content 回写。v1 仅处理 TEXT 的文字内容(最常见编辑场景);
|
|
116
|
+
* 纹理 / 视频源等资源类变更由 AssetManager 走引用更新,不在本服务重复处理。
|
|
117
|
+
* @param artisItem 待回写的 ArtisItem
|
|
118
|
+
* @param jsonItem 目标 JSON item 数据
|
|
119
|
+
* @param scene 所属 JSONScene(预留资源表扩展)
|
|
120
|
+
*/
|
|
121
|
+
private _syncTypeSpecificContent;
|
|
122
|
+
/**
|
|
123
|
+
* 在 JSONScene.items 中按 id 查找 VFXItemData(含 composition 子项)
|
|
124
|
+
* @param scene 目标 JSONScene
|
|
125
|
+
* @param id 元素实例 ID
|
|
126
|
+
* @returns 命中的 VFXItemData;找不到时返回 undefined
|
|
127
|
+
*/
|
|
128
|
+
private _findJSONItem;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 把单个 ArtisItem 序列化为 spec.VFXItemData(导出与回写共用底层)。
|
|
132
|
+
* 复用 json-data-utils 的 createXxxItemJSON 思路,按 ArtisItemType 分派。
|
|
133
|
+
*
|
|
134
|
+
* 注意:本方法生成的是「独立 JSON item」,不保活原 scene 动画。
|
|
135
|
+
* 导出主路径优先用 SceneStore.exportEntry(保活原 JSON);此方法供局部序列化场景。
|
|
136
|
+
*
|
|
137
|
+
* @param artisItem 待序列化的 ArtisItem
|
|
138
|
+
* @returns 序列化后的 VFXItemData;未知类型返回 undefined
|
|
139
|
+
*/
|
|
140
|
+
export declare function serializeArtisItemToJSON(artisItem: ArtisItem): spec.VFXItemData | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { FrameManager } from '@vvfx/gizmo';
|
|
2
|
+
import { ArtisItemType, type ArtisItem } from '../item';
|
|
3
|
+
import { type InteractionService } from './interaction-service';
|
|
4
|
+
import { type Renderer } from '../renderer';
|
|
5
|
+
/**
|
|
6
|
+
* id → ArtisItemType 类型表(可选)。
|
|
7
|
+
*
|
|
8
|
+
* 调用方在加载前若已知各元素的精确类型(来自原 JSON 的 className / 扩展字段 / 外部元数据),
|
|
9
|
+
* 可传入此表消除歧义。无表时按 VFXItem 兜底推断:
|
|
10
|
+
* - sprite → SPRITE(GENERATOR / CARD 无法仅靠 VFXItem 区分,需类型表)
|
|
11
|
+
* - null + FrameComponent → FRAME(EFFECTS 无法仅靠 VFXItem 区分,需类型表)
|
|
12
|
+
* - null + 无 FrameComponent → GROUP
|
|
13
|
+
* - text → TEXT,video → VIDEO
|
|
14
|
+
* - composition(顶层) → 跳过(属 EFFECTS/FRAME 内部子预合成)
|
|
15
|
+
*/
|
|
16
|
+
export type ArtisItemTypeTable = Record<string, ArtisItemType>;
|
|
17
|
+
/**
|
|
18
|
+
* SceneDataAssembler 依赖
|
|
19
|
+
*/
|
|
20
|
+
export type SceneDataAssemblerDeps = {
|
|
21
|
+
/** 已完成 refreshViewport/refreshCamera 的交互服务,用于 VFXItem→像素换算 */
|
|
22
|
+
interactionService: InteractionService;
|
|
23
|
+
/** 渲染管线,用于访问 Player/Composition(traverseItems) */
|
|
24
|
+
renderer: Renderer;
|
|
25
|
+
frameManager: FrameManager;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* SceneDataAssembler - JSON + runtime VFXItem → ArtisItem 装配器
|
|
29
|
+
*
|
|
30
|
+
* 与 {@link ItemService.createItem}(schema → item + VFXItem)互为逆向:
|
|
31
|
+
* 在一个已 player.loadScene(json) 并 gotoAndStop 冻结的 composition 上,
|
|
32
|
+
* 遍历 runtime VFXItem,反推编辑属性(复用 InteractionService 世界矩阵→像素坐标逻辑),
|
|
33
|
+
* 实例化对应 ArtisItem 子类,返回编辑模型数据 ArtisItem[]。
|
|
34
|
+
*
|
|
35
|
+
* 类型反推:见 {@link ArtisItemTypeTable}。GENERATOR/CARD/SPRITE、EFFECTS/FRAME
|
|
36
|
+
* 三组无法仅靠 VFXItem 区分,需调用方传类型表;无表时兜底到 SPRITE/FRAME。
|
|
37
|
+
*/
|
|
38
|
+
export declare class SceneDataAssembler {
|
|
39
|
+
private _interactionService;
|
|
40
|
+
private _renderer;
|
|
41
|
+
private _frameManager;
|
|
42
|
+
/**
|
|
43
|
+
* 注入交互服务与渲染管线
|
|
44
|
+
* @param deps 依赖项
|
|
45
|
+
*/
|
|
46
|
+
constructor(deps: SceneDataAssemblerDeps);
|
|
47
|
+
/**
|
|
48
|
+
* 在一个已 loadScene 并 gotoAndStop 的 composition 上组装全部顶层 ArtisItem。
|
|
49
|
+
* 递归遍历 composition.items,跳过 EFFECTS/FRAME 的内部子预合成。
|
|
50
|
+
*
|
|
51
|
+
* @param composition 已加载冻结的 composition(缺省取 Player 第一个)
|
|
52
|
+
* @param typeTable 可选的类型表,消除 GENERATOR/CARD/EFFECTS 歧义
|
|
53
|
+
* @returns 顶层 ArtisItem 列表;composition 不存在时返回空数组
|
|
54
|
+
*/
|
|
55
|
+
assemble(composition?: any, typeTable?: ArtisItemTypeTable): ArtisItem[];
|
|
56
|
+
/**
|
|
57
|
+
* 单元素组装(增量/局部刷新用)。元素无法装配时返回 undefined。
|
|
58
|
+
* @param item VFXItem
|
|
59
|
+
* @param typeTable 可选的类型表
|
|
60
|
+
* @returns 装配出的 ArtisItem;无法装配时返回 undefined
|
|
61
|
+
*/
|
|
62
|
+
assembleItem(item: any, typeTable?: ArtisItemTypeTable): ArtisItem | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* 遍历装配。`composition.items` 返回 `sceneRoot.getDescendants()`——全量扁平后代列表
|
|
65
|
+
* (含所有层级,非仅顶层),故**只需遍历一次**,不可再递归 `item.children`:否则非
|
|
66
|
+
* composition 子节点会被装配两次,产生重复 id(React key 冲突)。各 ArtisItem 的
|
|
67
|
+
* parentId / children 由 {@link _assembleOne} 从 VFXItem 自身反推,不依赖递归层级。
|
|
68
|
+
* @param items VFXItem 列表(composition.items 全量扁平后代)
|
|
69
|
+
* @param typeTable 可选的类型表
|
|
70
|
+
* @param result 输出累加的 ArtisItem 列表
|
|
71
|
+
*/
|
|
72
|
+
private _traverse;
|
|
73
|
+
/**
|
|
74
|
+
* 装配单个 VFXItem 为 ArtisItem
|
|
75
|
+
* @param item VFXItem
|
|
76
|
+
* @param typeTable 可选的类型表
|
|
77
|
+
* @returns 装配出的 ArtisItem;无法识别类型时返回 undefined
|
|
78
|
+
*/
|
|
79
|
+
private _assembleOne;
|
|
80
|
+
/**
|
|
81
|
+
* 反推 ArtisItemType。优先用类型表,否则按 VFXItem 兜底。
|
|
82
|
+
* composition 顶层 → 视作 FRAME 兜底(也可能是 EFFECTS,需类型表区分);非顶层 composition 跳过。
|
|
83
|
+
* @param item VFXItem
|
|
84
|
+
* @param id 元素实例 ID
|
|
85
|
+
* @param typeTable 可选的类型表
|
|
86
|
+
* @returns 推断出的 ArtisItemType;无法识别时返回 undefined
|
|
87
|
+
*/
|
|
88
|
+
private _resolveArtisType;
|
|
89
|
+
/**
|
|
90
|
+
* VFXItem.transform → 像素坐标 position/rotation/scale/width/height。
|
|
91
|
+
* 算法复刻自 ItemSyncService.syncItemTransform(VFXItem→像素的逆向算子)。
|
|
92
|
+
* @param item VFXItem
|
|
93
|
+
* @returns 像素坐标系下的 position/rotation/scale/width/height
|
|
94
|
+
*/
|
|
95
|
+
private _resolveTransform;
|
|
96
|
+
/**
|
|
97
|
+
* 反推 parentId(与 ItemSyncService 一致:composition 嵌套时取上上级)
|
|
98
|
+
* @param item VFXItem
|
|
99
|
+
* @returns 父元素 ID;无父级时返回 undefined
|
|
100
|
+
*/
|
|
101
|
+
private _resolveParentId;
|
|
102
|
+
/**
|
|
103
|
+
* 读取 VFXItem 子元素 ID 列表
|
|
104
|
+
* @param item VFXItem
|
|
105
|
+
* @returns 子元素实例 ID 列表
|
|
106
|
+
*/
|
|
107
|
+
private _readChildrenIds;
|
|
108
|
+
/**
|
|
109
|
+
* 读取 Sprite 图片地址。runtime 上 url 一般挂在 texture,GE 无统一 getter,兜底空串。
|
|
110
|
+
* TODO: 后续可由 AssetManager 反查 url(按 texture 引用)。
|
|
111
|
+
* @param item VFXItem
|
|
112
|
+
* @returns 图片地址;读取失败时返回空串
|
|
113
|
+
*/
|
|
114
|
+
private _readSpriteImage;
|
|
115
|
+
/**
|
|
116
|
+
* 读取 EffectsItem 自适应大小标志。
|
|
117
|
+
* autoFit 是语义布尔(非几何量),不存于 VFXItem.transform,由 JsonSceneSyncService 写进
|
|
118
|
+
* placeholder item 的 content.options.autoFit 持久化,故从此读回;旧档无该字段默认 false。
|
|
119
|
+
* @param item VFXItem
|
|
120
|
+
* @returns autoFit 标志
|
|
121
|
+
*/
|
|
122
|
+
private _readAutoFit;
|
|
123
|
+
/**
|
|
124
|
+
* 读取 sprite/video 尺寸模式。sizeMode 是语义布尔(非几何量),不存于 VFXItem.transform,
|
|
125
|
+
* 由 JsonSceneSyncService 写进 item 的 content.options.sizeMode 持久化,故从此读回;
|
|
126
|
+
* 旧档无该字段默认 'fixed'(旧档尺寸显式给定)。
|
|
127
|
+
* @param item VFXItem
|
|
128
|
+
* @returns sizeMode,缺省 'fixed'
|
|
129
|
+
*/
|
|
130
|
+
private _readSizeMode;
|
|
131
|
+
/**
|
|
132
|
+
* 读取 Text 文本属性(GE TextComponent 暴露 text/fontSize/fontFamily 等可读属性)
|
|
133
|
+
* @param item VFXItem
|
|
134
|
+
* @returns 文本相关属性;读取失败时返回兜底默认值
|
|
135
|
+
*/
|
|
136
|
+
private _readTextProps;
|
|
137
|
+
/**
|
|
138
|
+
* 读取 Video 属性。url 兜底空串。
|
|
139
|
+
* @param item VFXItem
|
|
140
|
+
* @returns 视频相关属性;读取失败时返回兜底默认值
|
|
141
|
+
*/
|
|
142
|
+
private _readVideoProps;
|
|
143
|
+
/**
|
|
144
|
+
* 读取 generatorType。VFXItem 无标记,默认 IMAGE;调用方可通过类型表已知是 GENERATOR,
|
|
145
|
+
* 具体 generatorType 需外部元数据,此处兜底 IMAGE。
|
|
146
|
+
* @param _item VFXItem(暂未使用,预留)
|
|
147
|
+
* @param _id 元素实例 ID(暂未使用,预留)
|
|
148
|
+
* @param _typeTable 可选的类型表(暂未使用,预留)
|
|
149
|
+
* @returns 生成器类型,当前兜底返回 IMAGE
|
|
150
|
+
*/
|
|
151
|
+
private _readGeneratorType;
|
|
152
|
+
/**
|
|
153
|
+
* 读取 cardType。同上,兜底空串。
|
|
154
|
+
* @param _item VFXItem(暂未使用,预留)
|
|
155
|
+
* @param _id 元素实例 ID(暂未使用,预留)
|
|
156
|
+
* @param _typeTable 可选的类型表(暂未使用,预留)
|
|
157
|
+
* @returns 卡片类型,当前兜底返回空串
|
|
158
|
+
*/
|
|
159
|
+
private _readCardType;
|
|
160
|
+
/**
|
|
161
|
+
* 读取 Frame 布局模式。runtime 无标记,兜底 FREE。
|
|
162
|
+
* @param _item VFXItem(暂未使用,预留)
|
|
163
|
+
* @returns 布局模式,当前兜底返回 FREE
|
|
164
|
+
*/
|
|
165
|
+
private _readFrameLayoutMode;
|
|
166
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { EventEmitter, spec } from '../../shared';
|
|
2
|
+
import { Box2, Vector2 } from '@vvfx/gizmo';
|
|
3
|
+
import type { ViewportFitShiftParam } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* 视口状态变更来源:决定 wiring change 监听是否回写相机 viewportMatrix。
|
|
6
|
+
* - `view`:ViewService 为相机真源(外部主动 setZoom / setRatios / setClipMode / resize 等),需 applyViewportToPlayer。
|
|
7
|
+
* - `gizmo`:相机已被 gizmo 直写,ViewService 仅记账 + 通知外部,**不**再 apply(避免重复写相机/抖动)。
|
|
8
|
+
*/
|
|
9
|
+
export type ViewportSource = 'view' | 'gizmo';
|
|
10
|
+
/**
|
|
11
|
+
* 视口状态
|
|
12
|
+
*/
|
|
13
|
+
export type ViewportState = {
|
|
14
|
+
zoom: number;
|
|
15
|
+
translation: spec.vec2;
|
|
16
|
+
contentRatio: number;
|
|
17
|
+
/** 本次状态变更来源(缺省 view)。供 wiring 决定是否回写相机 matrix。 */
|
|
18
|
+
source?: ViewportSource;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 视口补偿比例更新项:全部可选,仅传需要变更的字段,未传字段保持原值。
|
|
22
|
+
*/
|
|
23
|
+
export type ViewportRatios = {
|
|
24
|
+
widthRatio?: number;
|
|
25
|
+
heightRatio?: number;
|
|
26
|
+
pixelRatio?: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* ViewService 事件类型
|
|
30
|
+
*/
|
|
31
|
+
export type ViewServiceEventMap = {
|
|
32
|
+
'change': [state: ViewportState];
|
|
33
|
+
'resize': [size: spec.vec2];
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* ViewService 初始化选项
|
|
37
|
+
*/
|
|
38
|
+
export type ViewServiceOptions = {
|
|
39
|
+
minZoom?: number;
|
|
40
|
+
maxZoom?: number;
|
|
41
|
+
initialZoom?: number;
|
|
42
|
+
/** 监听 resize 的容器元素。传入后将自动创建 ResizeObserver 监听容器尺寸变化 */
|
|
43
|
+
container?: HTMLElement;
|
|
44
|
+
initialTranslation?: Vector2;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* ViewService - 视口服务
|
|
48
|
+
*
|
|
49
|
+
* 职责:
|
|
50
|
+
* 1. 管理 zoom / translation / size 状态
|
|
51
|
+
* 2. 监听容器 resize,自动更新 size 并触发 resize 事件
|
|
52
|
+
* 3. 提供 setZoom / setTranslation / pan / fitToBox 方法
|
|
53
|
+
* 4. 约束 minZoom / maxZoom
|
|
54
|
+
* 5. 触发 change / resize 事件
|
|
55
|
+
*/
|
|
56
|
+
export declare class ViewService extends EventEmitter<ViewServiceEventMap> {
|
|
57
|
+
private _zoom;
|
|
58
|
+
private _translation;
|
|
59
|
+
private _size;
|
|
60
|
+
private _minZoom;
|
|
61
|
+
private _maxZoom;
|
|
62
|
+
private _clipMode;
|
|
63
|
+
protected _widthRatio: number;
|
|
64
|
+
protected _heightRatio: number;
|
|
65
|
+
/** 保持场景渲染比例,用于确定容器 resize 时,是否需要保持元素相对容器比例不变 */
|
|
66
|
+
private _keepViewRatio;
|
|
67
|
+
/** 视口像素与真实像素比例 */
|
|
68
|
+
private _pixelRatio;
|
|
69
|
+
private _container;
|
|
70
|
+
private _resizeObserver;
|
|
71
|
+
private _disposed;
|
|
72
|
+
/**
|
|
73
|
+
* 下一次 emit('change') 携带的变更来源标记。默认 'view';gizmo 回写入口前置置 'gizmo',
|
|
74
|
+
* _emitChange 发出后立即复位为 'view',保证不污染后续非 gizmo 写入。
|
|
75
|
+
*/
|
|
76
|
+
private _pendingSource;
|
|
77
|
+
/**
|
|
78
|
+
* 初始化视口状态与可选的容器 resize 监听
|
|
79
|
+
* @param size 初始视口尺寸
|
|
80
|
+
* @param options 初始化选项
|
|
81
|
+
*/
|
|
82
|
+
constructor(size: Vector2, options?: ViewServiceOptions);
|
|
83
|
+
/** 视口尺寸(宽高) */
|
|
84
|
+
get size(): Vector2;
|
|
85
|
+
/**
|
|
86
|
+
* 设置视口尺寸(不触发事件)
|
|
87
|
+
* @param value 视口尺寸
|
|
88
|
+
*/
|
|
89
|
+
set size(value: Vector2);
|
|
90
|
+
/** 视口中心点坐标(size / 2) */
|
|
91
|
+
get center(): Vector2;
|
|
92
|
+
/** 当前缩放值 */
|
|
93
|
+
get zoom(): number;
|
|
94
|
+
/**
|
|
95
|
+
* 设置缩放值(经 setZoom 处理,受 minZoom/maxZoom 约束)
|
|
96
|
+
* @param value 缩放值
|
|
97
|
+
*/
|
|
98
|
+
set zoom(value: number);
|
|
99
|
+
/** 当前平移量 */
|
|
100
|
+
get translation(): Vector2;
|
|
101
|
+
/**
|
|
102
|
+
* 设置平移量(经 setTranslation 处理)
|
|
103
|
+
* @param value 平移量
|
|
104
|
+
*/
|
|
105
|
+
set translation(value: Vector2);
|
|
106
|
+
get keepViewRatio(): boolean;
|
|
107
|
+
set keepViewRatio(value: boolean);
|
|
108
|
+
/** 容器缩放比(只读,补偿 resize 时 容器变化对元素大小的影响) */
|
|
109
|
+
get contentRatio(): number;
|
|
110
|
+
get widthRatio(): number;
|
|
111
|
+
get heightRatio(): number;
|
|
112
|
+
get pixelRatio(): number;
|
|
113
|
+
/** 当前视口状态快照(zoom / translation / contentRatio + source) */
|
|
114
|
+
get state(): ViewportState;
|
|
115
|
+
/**
|
|
116
|
+
* 统一的 change 发射口:payload 携带本次变更来源(`_pendingSource`),发出后复位为 'view'。
|
|
117
|
+
* 所有写状态后需通知外部的路径统一调本方法,保证来源标记不残留、不污染后续写入。
|
|
118
|
+
*/
|
|
119
|
+
private _emitChange;
|
|
120
|
+
/**
|
|
121
|
+
* 设置缩放值
|
|
122
|
+
* @param zoom 目标缩放值
|
|
123
|
+
* @param anchor 缩放锚点 [x, y](相对容器的坐标),默认中心
|
|
124
|
+
*/
|
|
125
|
+
setZoom(zoom: number, anchor?: Vector2): void;
|
|
126
|
+
/**
|
|
127
|
+
* 批量设置视口补偿比例(widthRatio / heightRatio / pixelRatio)。
|
|
128
|
+
*
|
|
129
|
+
* @param ratios 需要变更的比例字段(全部可选)
|
|
130
|
+
*/
|
|
131
|
+
setRatios(ratios: ViewportRatios): void;
|
|
132
|
+
/**
|
|
133
|
+
* 设置相机裁剪模式:决定 contentRatio 取 widthRatio 还是 heightRatio(见 contentRatio getter,
|
|
134
|
+
* portrait→heightRatio、landscape→widthRatio)。
|
|
135
|
+
*
|
|
136
|
+
* 由 wiring 在 sceneLoaded 时从 composition.camera.clipMode 同步(Artis/SceneArtis 共用)。
|
|
137
|
+
* emit change 触发 renderer applyViewportToPlayer 按 contentRatio 写 viewportMatrix,
|
|
138
|
+
* 并经 GestureHandler 同步 ResizeSelectionGizmo。
|
|
139
|
+
*/
|
|
140
|
+
setClipMode(clipMode: spec.CameraClipMode): void;
|
|
141
|
+
/**
|
|
142
|
+
* 设置平移
|
|
143
|
+
* @param translation 目标平移量
|
|
144
|
+
*/
|
|
145
|
+
setTranslation(translation: Vector2): void;
|
|
146
|
+
/**
|
|
147
|
+
* gizmo 视口导航回写入口:相机已被 gizmo(zoomView/panView)直写,ViewService 仅记账 + 通知外部,
|
|
148
|
+
* 标记 source='gizmo' 使 wiring change 监听跳过 applyViewportToPlayer(不重复写相机,防抖动)。
|
|
149
|
+
*
|
|
150
|
+
* 与 {@link setZoom}/{@link setTranslation} 的差异:
|
|
151
|
+
* 1. 不走 setZoom 的 `resultZoom === _zoom` 早退——gizmo 平移/钳位场景换算后 zoom 可能不变,但 translation
|
|
152
|
+
* 已变,仍须通知外部(避免外部盲区)。
|
|
153
|
+
* 2. 钳位 zoom 到 [minZoom, maxZoom] 保持不变,但不以"值未变"为由跳过 emit。
|
|
154
|
+
* 3. 不重算 translation(不像 setZoom 按 anchor 偏移)——gizmo 已给出最终 translation,直接落值。
|
|
155
|
+
*
|
|
156
|
+
* @param zoom gizmo 相机 scale 折算后的 zoom(= camera scale / contentRatio)
|
|
157
|
+
* @param translation gizmo 视口快照 translation(view-size 变体)
|
|
158
|
+
*/
|
|
159
|
+
applyGizmoViewport(zoom: number, translation: Vector2): void;
|
|
160
|
+
/**
|
|
161
|
+
* 同时设置 zoom 与 translation 的原子写入口:只触发一次 change 事件。
|
|
162
|
+
*
|
|
163
|
+
* 收敛 fitToBox(view 源,需 apply)与 applyGizmoViewport(gizmo 源,不 apply)的共性——
|
|
164
|
+
* 二者都需要"一次性更新 zoom+translation 并只通知外部一次",避免 setTranslation+setZoom 各 emit 的多次触发。
|
|
165
|
+
*
|
|
166
|
+
* @param zoom 目标 zoom(钳位到 [minZoom, maxZoom];不以"值未变"早退——translation 可能已变仍须通知)
|
|
167
|
+
* @param translation 目标 translation(锚点变换前的基准值)
|
|
168
|
+
* @param anchor 缩放锚点(相对容器坐标);缺省时直接采用传入 translation,不重算(gizmo 路径)
|
|
169
|
+
* @param source 变更来源,决定 wiring 是否 applyViewportToPlayer
|
|
170
|
+
*/
|
|
171
|
+
applyViewport(zoom: number, translation: Vector2, anchor: Vector2 | undefined, source: ViewportSource): void;
|
|
172
|
+
/**
|
|
173
|
+
* 相对平移,将 delta 累加到当前 translation
|
|
174
|
+
*
|
|
175
|
+
* @param delta 平移增量(屏幕坐标系)
|
|
176
|
+
*/
|
|
177
|
+
pan(delta: Vector2): void;
|
|
178
|
+
/** 重置视口:zoom 回到 1,translation 归零,并触发 change 事件 */
|
|
179
|
+
reset(): void;
|
|
180
|
+
/**
|
|
181
|
+
* 自适应视口:使传入包围盒完整显示在容器中。
|
|
182
|
+
*
|
|
183
|
+
* @param box 目标内容包围盒(像素坐标系);空 box 时重置视口
|
|
184
|
+
* @param shiftParam 上下左右内边距偏移(像素),缺省四边为 0
|
|
185
|
+
* @param contentRatio 内容包围盒放大系数,默认 1.1
|
|
186
|
+
*/
|
|
187
|
+
fitToBox(box: Box2, shiftParam?: ViewportFitShiftParam): void;
|
|
188
|
+
/**
|
|
189
|
+
* 销毁,断开 ResizeObserver
|
|
190
|
+
*
|
|
191
|
+
* 边界:重复调用安全,已销毁时直接返回
|
|
192
|
+
*/
|
|
193
|
+
dispose(): void;
|
|
194
|
+
/**
|
|
195
|
+
* 创建并启动容器 ResizeObserver 监听
|
|
196
|
+
*/
|
|
197
|
+
protected setupResizeObserver(): void;
|
|
198
|
+
/**
|
|
199
|
+
* 处理容器 resize:更新尺寸、平移量与 contentRatio,并触发 resize / change 事件
|
|
200
|
+
*/
|
|
201
|
+
protected handleResize(): void;
|
|
202
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EventEmitter } from '@galacean/effects';
|
|
2
|
+
import type { StateGizmoBinding } from '../gizmo/gizmo-registry';
|
|
3
|
+
import type { BaseStateEventMap, StateGizmoToolConstructor, StateId, StateInteractionDefinition } from './types';
|
|
4
|
+
/** Business state that directly selects its GizmoTool type. */
|
|
5
|
+
export declare class BaseState extends EventEmitter<BaseStateEventMap> {
|
|
6
|
+
readonly id: StateId;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
/** Ordered registered graph used when this State does not provide a Tool type. */
|
|
9
|
+
readonly gizmos: readonly StateGizmoBinding[];
|
|
10
|
+
/** Tool type directly owned by this State. */
|
|
11
|
+
readonly tool: StateGizmoToolConstructor | undefined;
|
|
12
|
+
isolated: boolean;
|
|
13
|
+
constructor(id: StateId, name: string, toolOrInteraction?: StateGizmoToolConstructor | StateInteractionDefinition);
|
|
14
|
+
enter(): void;
|
|
15
|
+
exit(): void;
|
|
16
|
+
suspend(): void;
|
|
17
|
+
resume(): void;
|
|
18
|
+
onEnter(): void;
|
|
19
|
+
onExit(): void;
|
|
20
|
+
onSuspend(): void;
|
|
21
|
+
onResume(): void;
|
|
22
|
+
/** Whether navigation to another State should temporarily suspend this State. */
|
|
23
|
+
shouldSuspendFor(_nextStateId: StateId): boolean;
|
|
24
|
+
/** Whether a navigation request should restore this State from the suspended stack. */
|
|
25
|
+
shouldResumeFor(_requestedStateId: StateId): boolean;
|
|
26
|
+
/** Called after the state's GizmoTool has been activated. */
|
|
27
|
+
onGizmoToolReady(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { BaseState } from './base-state';
|
|
2
|
+
export { StateManager } from './state-manager';
|
|
3
|
+
export { HandState, ImageCutState, ImageExpandState, ImageMaskState, ImageTextEditState, ItemCreateState, MoveState, createDefaultStates, createStatesByIds, } from './presets';
|
|
4
|
+
export { OfficialStateId } from './types';
|
|
5
|
+
export type { BaseStateEventMap, StateChangeEvent, StateId, StateInteractionDefinition, StateManagerEventMap, StateTransition, StateNavigator, StateLifecyclePhase, StateGizmoToolConstructor, } from './types';
|
|
6
|
+
export type { StateBundleRegistration, StateBundleHandle, } from './state-manager';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseState } from './base-state';
|
|
2
|
+
import { OfficialStateId } from './types';
|
|
3
|
+
export declare class MoveState extends BaseState {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
export declare class HandState extends BaseState {
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
export declare class ImageCutState extends BaseState {
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
export declare class ImageExpandState extends BaseState {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
export declare class ImageTextEditState extends BaseState {
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
export declare class ImageMaskState extends BaseState {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
export declare class ItemCreateState extends BaseState {
|
|
22
|
+
constructor();
|
|
23
|
+
}
|
|
24
|
+
export declare function createStatesByIds(ids: readonly OfficialStateId[]): BaseState[];
|
|
25
|
+
export declare function createDefaultStates(): BaseState[];
|