@galacean/effects-core 2.10.0-alpha.1 → 2.10.0-alpha.3
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/dist/components/component.d.ts +4 -0
- package/dist/components/frame-component.d.ts +10 -0
- package/dist/components/index.d.ts +2 -3
- package/dist/components/mesh-component.d.ts +1 -1
- package/dist/components/ui-canvas.d.ts +28 -0
- package/dist/components/ui-control.d.ts +38 -0
- package/dist/composition.d.ts +19 -13
- package/dist/engine.d.ts +49 -12
- package/dist/gui/control.d.ts +189 -0
- package/dist/gui/index.d.ts +2 -0
- package/dist/gui/roots.d.ts +79 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4759 -1898
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4737 -1895
- package/dist/index.mjs.map +1 -1
- package/dist/input/enums.d.ts +65 -0
- package/dist/input/index.d.ts +2 -0
- package/dist/input/input-event.d.ts +77 -0
- package/dist/plugins/interact/event-system.d.ts +49 -2
- package/dist/plugins/particle/particle-mesh.d.ts +4 -1
- package/dist/plugins/particle/particle-system.d.ts +7 -0
- package/dist/plugins/particle/trail-mesh.d.ts +4 -0
- package/dist/plugins/shape/shape-component.d.ts +1 -0
- package/dist/plugins/sprite/sprite-item.d.ts +1 -0
- package/dist/render/buffer.d.ts +33 -0
- package/dist/render/data-buffer.d.ts +39 -0
- package/dist/render/geometry.d.ts +72 -94
- package/dist/render/gpu-capability.d.ts +2 -0
- package/dist/render/graphics.d.ts +2 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/shader.d.ts +2 -1
- package/dist/render/text-cache.d.ts +8 -9
- package/dist/render/vertex-buffer.d.ts +72 -0
- package/dist/transform.d.ts +7 -0
- package/dist/vfx-item.d.ts +4 -0
- package/package.json +1 -1
- package/dist/components/canvas-item.d.ts +0 -131
- package/dist/components/canvas-layer.d.ts +0 -23
- package/dist/components/control.d.ts +0 -18
- package/dist/rect-transform.d.ts +0 -145
|
@@ -64,6 +64,10 @@ export declare abstract class Component extends EffectsObject {
|
|
|
64
64
|
* 当父级或间接父级发生改变时调用
|
|
65
65
|
*/
|
|
66
66
|
onParentChanged(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Called when the owning item's sibling order changes.
|
|
69
|
+
*/
|
|
70
|
+
onOrderInParentChanged(): void;
|
|
67
71
|
setVFXItem(item: VFXItem): void;
|
|
68
72
|
fromData(data: spec.ComponentData): void;
|
|
69
73
|
dispose(): void;
|
|
@@ -18,6 +18,16 @@ export declare class FrameComponent extends RendererComponent implements Maskabl
|
|
|
18
18
|
drawStencilMask(maskRef: number): void;
|
|
19
19
|
fromData(data: FrameComponentData): void;
|
|
20
20
|
private getHitTestParams;
|
|
21
|
+
/**
|
|
22
|
+
* 由相机把命中带的屏幕像素厚度换算成世界厚度。对齐 Excalidraw frame 命中阈值:
|
|
23
|
+
* 描边两侧各 0.85 × DEFAULT_COLLISION_THRESHOLD(≈8px),整条带 ≈13.6px,不受 size/scale/zoom 影响。
|
|
24
|
+
*/
|
|
25
|
+
private getBorderWorldThickness;
|
|
26
|
+
/**
|
|
27
|
+
* 构造以 frame 边为中心、给定世界厚度的边框环带三角形(内部镂空)。
|
|
28
|
+
* 带中心落在 frame 边上:half 向外、half 向内;沿 frame 局部坐标轴偏移以兼容旋转。
|
|
29
|
+
*/
|
|
30
|
+
private getBorderTriangles;
|
|
21
31
|
private setClipRectangle;
|
|
22
32
|
private setClipRectangleRecursive;
|
|
23
33
|
}
|
|
@@ -8,6 +8,5 @@ export * from './post-process-volume';
|
|
|
8
8
|
export * from './base-render-component';
|
|
9
9
|
export * from './fake-3d-component';
|
|
10
10
|
export * from './frame-component';
|
|
11
|
-
export * from './canvas
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './control';
|
|
11
|
+
export * from './ui-canvas';
|
|
12
|
+
export * from './ui-control';
|
|
@@ -2,7 +2,7 @@ import type * as spec from '@galacean/effects-specification';
|
|
|
2
2
|
import type { Engine } from '../engine';
|
|
3
3
|
import type { Maskable } from '../material';
|
|
4
4
|
import type { BoundingBoxTriangle, HitTestTriangleParams, BoundingBoxInfo } from '../plugins';
|
|
5
|
-
import type
|
|
5
|
+
import { type Geometry, type Renderer } from '../render';
|
|
6
6
|
import { RendererComponent } from './renderer-component';
|
|
7
7
|
interface MeshComponentData extends spec.ComponentData {
|
|
8
8
|
mask?: spec.MaskOptions;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Engine } from '../engine';
|
|
2
|
+
import { CanvasRootControl } from '../gui';
|
|
3
|
+
import { Component } from './component';
|
|
4
|
+
export declare enum CanvasRenderMode {
|
|
5
|
+
ScreenSpace = 0,
|
|
6
|
+
CameraSpace = 1,
|
|
7
|
+
WorldSpace = 2,
|
|
8
|
+
WorldSpaceFaceCamera = 3
|
|
9
|
+
}
|
|
10
|
+
/** Canvas-layer boundary attached to a VFXItem. Input state remains owned by the window root. */
|
|
11
|
+
export declare class UICanvas extends Component {
|
|
12
|
+
readonly rootControl: CanvasRootControl;
|
|
13
|
+
renderMode: CanvasRenderMode;
|
|
14
|
+
receivesEvents: boolean;
|
|
15
|
+
private _order;
|
|
16
|
+
private registered;
|
|
17
|
+
constructor(engine: Engine);
|
|
18
|
+
get order(): number;
|
|
19
|
+
set order(value: number);
|
|
20
|
+
get isVisible(): boolean;
|
|
21
|
+
onEnable(): void;
|
|
22
|
+
onDisable(): void;
|
|
23
|
+
onDestroy(): void;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
private register;
|
|
26
|
+
private unregister;
|
|
27
|
+
private destroyCanvas;
|
|
28
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ContainerControl, Control } from '../gui';
|
|
2
|
+
import type { Engine } from '../engine';
|
|
3
|
+
import { Component } from './component';
|
|
4
|
+
/**
|
|
5
|
+
* Scene-tree bridge for a GUI Control. The VFXItem tree owns lifecycle and
|
|
6
|
+
* serialization while the Control tree owns layout, drawing and input.
|
|
7
|
+
*/
|
|
8
|
+
export declare class UIControl extends Component {
|
|
9
|
+
static fallbackParentGetDelegate?: (control: UIControl) => ContainerControl | null;
|
|
10
|
+
private controlNode;
|
|
11
|
+
private linkedItemTransform;
|
|
12
|
+
private linkedControl;
|
|
13
|
+
private syncingLocation;
|
|
14
|
+
private readonly itemTransformChanged;
|
|
15
|
+
private readonly controlLocationChanged;
|
|
16
|
+
constructor(engine: Engine);
|
|
17
|
+
get control(): Control | null;
|
|
18
|
+
set control(value: Control | null);
|
|
19
|
+
get hasControl(): boolean;
|
|
20
|
+
onAwake(): void;
|
|
21
|
+
onEnable(): void;
|
|
22
|
+
onDisable(): void;
|
|
23
|
+
onParentChanged(): void;
|
|
24
|
+
onOrderInParentChanged(): void;
|
|
25
|
+
onDestroy(): void;
|
|
26
|
+
dispose(): void;
|
|
27
|
+
/** Unlinks the GUI object without disposing or modifying it. */
|
|
28
|
+
unlinkControl(): void;
|
|
29
|
+
private disposeControl;
|
|
30
|
+
private syncControl;
|
|
31
|
+
private syncControlOrder;
|
|
32
|
+
private resolveParent;
|
|
33
|
+
private bindLocationSync;
|
|
34
|
+
private unbindLocationSync;
|
|
35
|
+
private syncItemLocationToControl;
|
|
36
|
+
private syncControlLocationToItem;
|
|
37
|
+
private copyItemLocationToControl;
|
|
38
|
+
}
|
package/dist/composition.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import type { Ray } from '@galacean/effects-math/es/core/ray';
|
|
|
3
3
|
import type { Matrix4 } from '@galacean/effects-math/es/core/matrix4';
|
|
4
4
|
import { Camera } from './camera';
|
|
5
5
|
import type { Component, PostProcessVolume } from './components';
|
|
6
|
-
import { CompositionComponent } from './components';
|
|
6
|
+
import { CompositionComponent, UICanvas } from './components';
|
|
7
7
|
import type { EventSystem, Region } from './plugins';
|
|
8
8
|
import { RenderFrame } from './render';
|
|
9
9
|
import type { Scene } from './scene';
|
|
10
|
-
import type
|
|
10
|
+
import { type Texture } from './texture';
|
|
11
11
|
import type { Constructor, Disposable, LostHandler } from './utils';
|
|
12
12
|
import { VFXItem } from './vfx-item';
|
|
13
13
|
import type { CompositionEvent } from './events';
|
|
@@ -88,18 +88,14 @@ export interface CompositionProps {
|
|
|
88
88
|
baseRenderOrder?: number;
|
|
89
89
|
/**
|
|
90
90
|
*
|
|
91
|
-
* @param message
|
|
92
|
-
* @returns
|
|
93
91
|
*/
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
*
|
|
97
|
-
*/
|
|
98
|
-
event?: EventSystem;
|
|
92
|
+
speed?: number;
|
|
99
93
|
/**
|
|
100
94
|
*
|
|
95
|
+
* @param message
|
|
96
|
+
* @returns
|
|
101
97
|
*/
|
|
102
|
-
|
|
98
|
+
onItemMessage?: (message: MessageItem) => void;
|
|
103
99
|
}
|
|
104
100
|
/**
|
|
105
101
|
* 合成抽象类:核心对象,通常一个场景只包含一个合成,可能会有多个合成。
|
|
@@ -128,7 +124,8 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
128
124
|
/**
|
|
129
125
|
* 合成渲染顺序,默认按升序渲染
|
|
130
126
|
*/
|
|
131
|
-
renderOrder: number;
|
|
127
|
+
get renderOrder(): number;
|
|
128
|
+
set renderOrder(value: number);
|
|
132
129
|
/**
|
|
133
130
|
* 播放完成后是否需要再使用,是的话生命周期结束后不会自动 dispose
|
|
134
131
|
* @deprecated
|
|
@@ -138,7 +135,8 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
138
135
|
* 合成内的元素否允许点击、拖拽交互
|
|
139
136
|
* @since 1.6.0
|
|
140
137
|
*/
|
|
141
|
-
interactive: boolean;
|
|
138
|
+
get interactive(): boolean;
|
|
139
|
+
set interactive(value: boolean);
|
|
142
140
|
/**
|
|
143
141
|
* 合成是否结束
|
|
144
142
|
*/
|
|
@@ -199,6 +197,8 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
199
197
|
* 合成中消息元素创建/销毁时触发的回调
|
|
200
198
|
*/
|
|
201
199
|
onItemMessage?: (message: MessageItem) => void;
|
|
200
|
+
/** Screen-space GUI boundary owned by this Composition. */
|
|
201
|
+
readonly uiCanvas: UICanvas;
|
|
202
202
|
/**
|
|
203
203
|
* 销毁状态位
|
|
204
204
|
*/
|
|
@@ -209,6 +209,8 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
209
209
|
*/
|
|
210
210
|
private paused;
|
|
211
211
|
private isEndCalled;
|
|
212
|
+
private _renderOrder;
|
|
213
|
+
private _interactive;
|
|
212
214
|
private _textures;
|
|
213
215
|
/**
|
|
214
216
|
* Composition 构造函数
|
|
@@ -339,7 +341,12 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
339
341
|
* 重置状态函数
|
|
340
342
|
*/
|
|
341
343
|
protected reset(): void;
|
|
344
|
+
/** Renders this Composition content. Screen-space UI is rendered by Engine. */
|
|
342
345
|
render(): void;
|
|
346
|
+
/**
|
|
347
|
+
* Renders only the Composition scene content.
|
|
348
|
+
*/
|
|
349
|
+
renderContent(): void;
|
|
343
350
|
/**
|
|
344
351
|
* 合成更新,针对所有 item 的更新
|
|
345
352
|
* @param deltaTime - 更新的时间步长
|
|
@@ -355,7 +362,6 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
355
362
|
* 更新主合成组件
|
|
356
363
|
*/
|
|
357
364
|
private updateCompositionTime;
|
|
358
|
-
private renderCanvasLayers;
|
|
359
365
|
/**
|
|
360
366
|
* 通过名称获取元素
|
|
361
367
|
* @param name - 元素名称
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as spec from '@galacean/effects-specification';
|
|
2
|
-
import type { Matrix4 } from '@galacean/effects-math/es/core/matrix4';
|
|
3
2
|
import type { Database, SceneData } from './asset-loader';
|
|
4
3
|
import type { EffectsObject } from './effects-object';
|
|
5
4
|
import type { Material } from './material';
|
|
6
|
-
import type { GPUCapability, Geometry, Mesh, RenderPass, RenderPassClearAction, Renderer, RenderingData, ShaderLibrary } from './render';
|
|
5
|
+
import type { DataArray, DataBuffer, DataBufferOptions, GPUCapability, Geometry, IndicesArray, Mesh, RenderPass, RenderPassClearAction, Renderer, RenderingData, ShaderLibrary, ShaderVariant, VertexBuffer } from './render';
|
|
7
6
|
import type { Framebuffer, Renderbuffer } from './render';
|
|
8
7
|
import { Graphics, RenderTargetPool } from './render';
|
|
9
8
|
import type { Scene, SceneRenderLevel } from './scene';
|
|
@@ -15,8 +14,11 @@ import { AssetService } from './asset-service';
|
|
|
15
14
|
import { Ticker } from './ticker';
|
|
16
15
|
import type { PointerEventData, Region } from './plugins';
|
|
17
16
|
import { EventSystem } from './plugins';
|
|
17
|
+
import type { ParticleSystem } from './plugins/particle/particle-system';
|
|
18
18
|
import type { GLType } from './gl';
|
|
19
19
|
import { EventEmitter } from './events';
|
|
20
|
+
import { VFXItem } from './vfx-item';
|
|
21
|
+
import { WindowRootControl } from './gui';
|
|
20
22
|
export interface EngineOptions extends WebGLContextAttributes {
|
|
21
23
|
name?: string;
|
|
22
24
|
glType?: GLType;
|
|
@@ -52,6 +54,10 @@ type EngineEvent = {
|
|
|
52
54
|
* Engine 基类,负责维护所有 GPU 资源的管理及销毁
|
|
53
55
|
*/
|
|
54
56
|
export declare class Engine extends EventEmitter<EngineEvent> implements Disposable {
|
|
57
|
+
/**
|
|
58
|
+
* 创建 Engine 对象。
|
|
59
|
+
*/
|
|
60
|
+
static create: (canvas: HTMLCanvasElement, options?: EngineOptions) => Engine;
|
|
55
61
|
name: string;
|
|
56
62
|
speed: number;
|
|
57
63
|
displayAspect: number;
|
|
@@ -78,10 +84,15 @@ export declare class Engine extends EventEmitter<EngineEvent> implements Disposa
|
|
|
78
84
|
* 渲染过程中错误队列
|
|
79
85
|
*/
|
|
80
86
|
renderErrors: Set<Error>;
|
|
81
|
-
compositions: Composition[];
|
|
82
87
|
assetManagers: AssetManager[];
|
|
83
88
|
assetService: AssetService;
|
|
84
89
|
eventSystem: EventSystem;
|
|
90
|
+
/** Window-level GUI owner and input router. */
|
|
91
|
+
readonly windowRoot: WindowRootControl;
|
|
92
|
+
/**
|
|
93
|
+
* Root of the unified runtime scene tree.
|
|
94
|
+
*/
|
|
95
|
+
root: VFXItem;
|
|
85
96
|
env: string;
|
|
86
97
|
/**
|
|
87
98
|
* 计时器
|
|
@@ -103,7 +114,6 @@ export declare class Engine extends EventEmitter<EngineEvent> implements Disposa
|
|
|
103
114
|
* 存放渲染需要用到的数据
|
|
104
115
|
*/
|
|
105
116
|
renderingData: RenderingData;
|
|
106
|
-
graphics: Graphics;
|
|
107
117
|
/**
|
|
108
118
|
* 是否不处理上下文丢失恢复(构造期配置,默认 true)
|
|
109
119
|
*/
|
|
@@ -120,17 +130,18 @@ export declare class Engine extends EventEmitter<EngineEvent> implements Disposa
|
|
|
120
130
|
protected renderPasses: RenderPass[];
|
|
121
131
|
protected framebuffers: Framebuffer[];
|
|
122
132
|
protected renderbuffers: Renderbuffer[];
|
|
133
|
+
protected particleSystems: ParticleSystem[];
|
|
134
|
+
private _compositions;
|
|
135
|
+
private _graphics;
|
|
123
136
|
private assetLoader;
|
|
124
137
|
private clearAction;
|
|
125
|
-
get disposed(): boolean;
|
|
126
138
|
/**
|
|
127
139
|
*
|
|
128
140
|
*/
|
|
129
141
|
constructor(canvas: HTMLCanvasElement, options?: EngineOptions);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
static create: (canvas: HTMLCanvasElement, options?: EngineOptions) => Engine;
|
|
142
|
+
get compositions(): Composition[];
|
|
143
|
+
get graphics(): Graphics;
|
|
144
|
+
get disposed(): boolean;
|
|
134
145
|
clearResources(): void;
|
|
135
146
|
addEffectsObjectData(data: spec.EffectsObjectData): void;
|
|
136
147
|
findEffectsObjectData(uuid: string): spec.EffectsObjectData;
|
|
@@ -148,7 +159,33 @@ export declare class Engine extends EventEmitter<EngineEvent> implements Disposa
|
|
|
148
159
|
*/
|
|
149
160
|
resize(): void;
|
|
150
161
|
setSize(width: number, height: number): void;
|
|
151
|
-
|
|
162
|
+
createVertexBuffer(data: DataArray | number, options: DataBufferOptions): DataBuffer;
|
|
163
|
+
createDynamicVertexBuffer(data: DataArray | number, options: DataBufferOptions): DataBuffer;
|
|
164
|
+
createIndexBuffer(indices: IndicesArray, options: DataBufferOptions): DataBuffer;
|
|
165
|
+
updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
|
|
166
|
+
updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, byteOffset?: number): void;
|
|
167
|
+
/** @hide */
|
|
168
|
+
releaseBuffer(buffer: DataBuffer): boolean;
|
|
169
|
+
/** @hide */
|
|
170
|
+
bindBuffers(vertexBuffers: Record<string, VertexBuffer>, indexBuffer: DataBuffer | null, effect: ShaderVariant): void;
|
|
171
|
+
/**
|
|
172
|
+
* 使用当前绑定的顶点和索引缓冲区绘制图元。
|
|
173
|
+
* @param mode - 图元类型
|
|
174
|
+
* @param indexOffset - 索引缓冲区中的字节偏移
|
|
175
|
+
* @param indexCount - 索引数量
|
|
176
|
+
* @param instanceCount - 实例数量
|
|
177
|
+
* @hide
|
|
178
|
+
*/
|
|
179
|
+
drawElementsType(mode: number, indexOffset: number, indexCount: number, instanceCount?: number): void;
|
|
180
|
+
/**
|
|
181
|
+
* 使用当前绑定的顶点缓冲区绘制图元。
|
|
182
|
+
* @param mode - 图元类型
|
|
183
|
+
* @param vertexStart - 起始顶点
|
|
184
|
+
* @param vertexCount - 顶点数量
|
|
185
|
+
* @param instanceCount - 实例数量
|
|
186
|
+
* @hide
|
|
187
|
+
*/
|
|
188
|
+
drawArraysType(mode: number, vertexStart: number, vertexCount: number, instanceCount?: number): void;
|
|
152
189
|
addTexture(tex: Texture): void;
|
|
153
190
|
removeTexture(tex: Texture): void;
|
|
154
191
|
addMaterial(mat: Material): void;
|
|
@@ -178,9 +215,8 @@ export declare class Engine extends EventEmitter<EngineEvent> implements Disposa
|
|
|
178
215
|
* example:
|
|
179
216
|
* gl.viewport(0, 0, width, height);
|
|
180
217
|
*/
|
|
181
|
-
|
|
218
|
+
setViewport(x: number, y: number, width: number, height: number): void;
|
|
182
219
|
clear(action: RenderPassClearAction): void;
|
|
183
|
-
drawGeometry(geometry: Geometry, matrix: Matrix4, material: Material, subMeshIndex?: number): void;
|
|
184
220
|
/*** 渲染状态控制 ***/
|
|
185
221
|
setSampleAlphaToCoverage(enable: boolean): void;
|
|
186
222
|
setBlending(enable: boolean): void;
|
|
@@ -205,5 +241,6 @@ export declare class Engine extends EventEmitter<EngineEvent> implements Disposa
|
|
|
205
241
|
* 销毁所有缓存的资源
|
|
206
242
|
*/
|
|
207
243
|
dispose(): void;
|
|
244
|
+
private getTargetSize;
|
|
208
245
|
}
|
|
209
246
|
export {};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { Color } from '@galacean/effects-math/es/core';
|
|
2
|
+
import { Matrix3 } from '@galacean/effects-math/es/core/matrix3';
|
|
3
|
+
import { Vector2 } from '@galacean/effects-math/es/core/vector2';
|
|
4
|
+
import type { Engine } from '../engine';
|
|
5
|
+
import type { InputEventKey, InputEventMouseButton, InputEventMouseMotion, InputEventScreenDrag, InputEventScreenTouch, MouseButton } from '../input';
|
|
6
|
+
import { CursorShape, FocusBehaviorRecursive, FocusMode, MouseBehaviorRecursive, MouseFilter } from '../input';
|
|
7
|
+
import type { EventEmitterListener, EventEmitterOptions } from '../events';
|
|
8
|
+
import type { FontStyle, FontWeight, TextureRegion } from '../render';
|
|
9
|
+
import type { Texture } from '../texture';
|
|
10
|
+
import type { UIControl } from '../components/ui-control';
|
|
11
|
+
import type { VFXItem } from '../vfx-item';
|
|
12
|
+
export type Rect = {
|
|
13
|
+
position: Vector2;
|
|
14
|
+
size: Vector2;
|
|
15
|
+
};
|
|
16
|
+
export type LayoutPreset = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'centerLeft' | 'centerTop' | 'centerRight' | 'centerBottom' | 'center' | 'leftWide' | 'topWide' | 'rightWide' | 'bottomWide' | 'vcenterWide' | 'hcenterWide' | 'fullRect';
|
|
17
|
+
export type ControlEvent = {
|
|
18
|
+
locationChanged: [control: Control];
|
|
19
|
+
sizeChanged: [control: Control];
|
|
20
|
+
parentChanged: [control: Control];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A drawable GUI object. Controls form a tree independent from the VFXItem
|
|
24
|
+
* scene tree. UIControl is the bridge between both trees.
|
|
25
|
+
*/
|
|
26
|
+
export declare class Control {
|
|
27
|
+
readonly engine: Engine;
|
|
28
|
+
private _parent;
|
|
29
|
+
private _visible;
|
|
30
|
+
private _enabled;
|
|
31
|
+
private _mouseFilter;
|
|
32
|
+
private _mouseBehaviorRecursive;
|
|
33
|
+
private _focusMode;
|
|
34
|
+
private _focusBehaviorRecursive;
|
|
35
|
+
private _defaultCursorShape;
|
|
36
|
+
private _rotation;
|
|
37
|
+
private transformDirty;
|
|
38
|
+
private readonly cachedTransform;
|
|
39
|
+
private readonly eventEmitter;
|
|
40
|
+
private disposed;
|
|
41
|
+
/** Scene-tree bridge that owns this GUI object, if any. */
|
|
42
|
+
owner: UIControl | null;
|
|
43
|
+
readonly position: Vector2;
|
|
44
|
+
readonly size: Vector2;
|
|
45
|
+
readonly anchorMin: Vector2;
|
|
46
|
+
readonly anchorMax: Vector2;
|
|
47
|
+
readonly offsetMin: Vector2;
|
|
48
|
+
readonly offsetMax: Vector2;
|
|
49
|
+
readonly pivot: Vector2;
|
|
50
|
+
readonly scale: Vector2;
|
|
51
|
+
readonly shear: Vector2;
|
|
52
|
+
mouseForcePassScrollEvents: boolean;
|
|
53
|
+
clipContents: boolean;
|
|
54
|
+
constructor(engine: Engine);
|
|
55
|
+
get parent(): ContainerControl | null;
|
|
56
|
+
/** Scene item exposed through the optional UIControl bridge. */
|
|
57
|
+
get item(): VFXItem | null;
|
|
58
|
+
set parent(value: ContainerControl | null);
|
|
59
|
+
get indexInParent(): number;
|
|
60
|
+
set indexInParent(value: number);
|
|
61
|
+
get visible(): boolean;
|
|
62
|
+
set visible(value: boolean);
|
|
63
|
+
get visibleInHierarchy(): boolean;
|
|
64
|
+
get enabled(): boolean;
|
|
65
|
+
set enabled(value: boolean);
|
|
66
|
+
get enabledInHierarchy(): boolean;
|
|
67
|
+
get mouseFilter(): MouseFilter;
|
|
68
|
+
set mouseFilter(value: MouseFilter);
|
|
69
|
+
get mouseBehaviorRecursive(): MouseBehaviorRecursive;
|
|
70
|
+
set mouseBehaviorRecursive(value: MouseBehaviorRecursive);
|
|
71
|
+
get focusMode(): FocusMode;
|
|
72
|
+
set focusMode(value: FocusMode);
|
|
73
|
+
get focusBehaviorRecursive(): FocusBehaviorRecursive;
|
|
74
|
+
set focusBehaviorRecursive(value: FocusBehaviorRecursive);
|
|
75
|
+
get defaultCursorShape(): CursorShape;
|
|
76
|
+
set defaultCursorShape(value: CursorShape);
|
|
77
|
+
get location(): Vector2;
|
|
78
|
+
set location(value: Vector2);
|
|
79
|
+
get rotation(): number;
|
|
80
|
+
get x(): number;
|
|
81
|
+
set x(value: number);
|
|
82
|
+
get y(): number;
|
|
83
|
+
set y(value: number);
|
|
84
|
+
get width(): number;
|
|
85
|
+
set width(value: number);
|
|
86
|
+
get height(): number;
|
|
87
|
+
set height(value: number);
|
|
88
|
+
on<E extends keyof ControlEvent>(eventName: E, listener: EventEmitterListener<ControlEvent[E]>, options?: EventEmitterOptions): void;
|
|
89
|
+
off<E extends keyof ControlEvent>(eventName: E, listener: EventEmitterListener<ControlEvent[E]>): void;
|
|
90
|
+
setPosition(x: number, y: number, keepOffsets?: boolean): void;
|
|
91
|
+
setSize(width: number, height: number): void;
|
|
92
|
+
setScale(x: number, y: number): void;
|
|
93
|
+
setRotation(degrees: number): void;
|
|
94
|
+
setShear(x: number, y: number): void;
|
|
95
|
+
setPivot(x: number, y: number): void;
|
|
96
|
+
setAnchorMin(x: number, y: number): void;
|
|
97
|
+
setAnchorMax(x: number, y: number): void;
|
|
98
|
+
setOffsetMin(x: number, y: number): void;
|
|
99
|
+
setOffsetMax(x: number, y: number): void;
|
|
100
|
+
getRect(): Rect;
|
|
101
|
+
getTransform2D(): Matrix3;
|
|
102
|
+
setAnchorsPreset(preset: LayoutPreset, keepOffsets?: boolean): void;
|
|
103
|
+
setOffsetsPreset(preset: LayoutPreset, margin?: number): void;
|
|
104
|
+
setAnchorsAndOffsetsPreset(preset: LayoutPreset, margin?: number): void;
|
|
105
|
+
get root(): RootControl | null;
|
|
106
|
+
get isDisposed(): boolean;
|
|
107
|
+
getGlobalTransform2D(): Matrix3;
|
|
108
|
+
hasPoint(point: Vector2): boolean;
|
|
109
|
+
getEffectiveMouseFilter(): MouseFilter;
|
|
110
|
+
getFocusModeWithOverride(): FocusMode;
|
|
111
|
+
getCursorShape(position: Vector2): CursorShape;
|
|
112
|
+
acceptEvent(): void;
|
|
113
|
+
focus(): void;
|
|
114
|
+
grabFocus(): void;
|
|
115
|
+
grabClickFocus(): void;
|
|
116
|
+
releaseFocus(): void;
|
|
117
|
+
warpMouse(position: Vector2): void;
|
|
118
|
+
/** Converts a window-space position into this control's local coordinates. */
|
|
119
|
+
makePositionLocal(position: Vector2): Vector2;
|
|
120
|
+
/** Gets the current mouse position transformed into this control's coordinates. */
|
|
121
|
+
getLocalMousePosition(): Vector2;
|
|
122
|
+
update(deltaTime: number): void;
|
|
123
|
+
draw(): void;
|
|
124
|
+
onDestroy(): void;
|
|
125
|
+
drawLine(x1: number, y1: number, x2: number, y2: number, color?: Color, thickness?: number): void;
|
|
126
|
+
drawPolyline(points: number[], color?: Color, thickness?: number): void;
|
|
127
|
+
drawBezier(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, color?: Color, thickness?: number): void;
|
|
128
|
+
drawTriangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, color?: Color, thickness?: number): void;
|
|
129
|
+
drawRect(x: number, y: number, width: number, height: number, color?: Color, thickness?: number): void;
|
|
130
|
+
drawCircle(cx: number, cy: number, radius: number, color?: Color, thickness?: number): void;
|
|
131
|
+
fillTriangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, color?: Color): void;
|
|
132
|
+
fillRect(x: number, y: number, width: number, height: number, color?: Color): void;
|
|
133
|
+
fillCircle(cx: number, cy: number, radius: number, color?: Color): void;
|
|
134
|
+
drawTexture(x: number, y: number, width: number, height: number, texture: Texture, region?: TextureRegion, color?: Color): void;
|
|
135
|
+
drawText(x: number, y: number, text: string, fontSize: number, color?: Color, fontFamily?: string, fontWeight?: FontWeight, fontStyle?: FontStyle): void;
|
|
136
|
+
onMouseEnter(location: Vector2): void;
|
|
137
|
+
onMouseMove(location: Vector2, event: InputEventMouseMotion): void;
|
|
138
|
+
onMouseLeave(): void;
|
|
139
|
+
onMouseWheel(location: Vector2, delta: number, event: InputEventMouseButton): void;
|
|
140
|
+
onMouseDown(location: Vector2, button: MouseButton, event: InputEventMouseButton): void;
|
|
141
|
+
onMouseUp(location: Vector2, button: MouseButton, event: InputEventMouseButton): void;
|
|
142
|
+
onTouchDown(location: Vector2, pointerId: number, event: InputEventScreenTouch): void;
|
|
143
|
+
onTouchMove(location: Vector2, pointerId: number, event: InputEventScreenDrag): void;
|
|
144
|
+
onTouchUp(location: Vector2, pointerId: number, event: InputEventScreenTouch): void;
|
|
145
|
+
onKeyDown(event: InputEventKey): void;
|
|
146
|
+
onKeyUp(event: InputEventKey): void;
|
|
147
|
+
onGotFocus(): void;
|
|
148
|
+
onLostFocus(): void;
|
|
149
|
+
protected getDragData(position: Vector2): unknown;
|
|
150
|
+
protected canDropData(position: Vector2, data: unknown): boolean;
|
|
151
|
+
protected dropData(position: Vector2, data: unknown): void;
|
|
152
|
+
dispose(): void;
|
|
153
|
+
private applyBounds;
|
|
154
|
+
private markTransformDirty;
|
|
155
|
+
private getParentRect;
|
|
156
|
+
private computeOffsets;
|
|
157
|
+
private computeAnchors;
|
|
158
|
+
private isMouseRecursiveEnabled;
|
|
159
|
+
private isFocusRecursiveEnabled;
|
|
160
|
+
}
|
|
161
|
+
/** A Control that owns child Controls. */
|
|
162
|
+
export declare class ContainerControl extends Control {
|
|
163
|
+
readonly children: Control[];
|
|
164
|
+
addChild<T extends Control>(child: T): T;
|
|
165
|
+
removeChild(child: Control): void;
|
|
166
|
+
getChildIndex(child: Control): number;
|
|
167
|
+
drawSelf(): void;
|
|
168
|
+
draw(): void;
|
|
169
|
+
protected drawChildren(): void;
|
|
170
|
+
update(deltaTime: number): void;
|
|
171
|
+
dispose(): void;
|
|
172
|
+
}
|
|
173
|
+
/** Base class for GUI tree roots and input dispatchers. */
|
|
174
|
+
export declare abstract class RootControl extends ContainerControl {
|
|
175
|
+
abstract getMousePosition(): Vector2;
|
|
176
|
+
abstract guiGetFocusOwner(): Control | null;
|
|
177
|
+
abstract guiIsDragging(): boolean;
|
|
178
|
+
abstract guiGetDragData(): unknown;
|
|
179
|
+
abstract guiIsDragSuccessful(): boolean;
|
|
180
|
+
abstract guiCancelDrag(): void;
|
|
181
|
+
abstract acceptControlEvent(control: Control): void;
|
|
182
|
+
abstract grabControlFocus(control: Control): void;
|
|
183
|
+
abstract grabControlClickFocus(control: Control): void;
|
|
184
|
+
abstract releaseControlFocus(control?: Control): void;
|
|
185
|
+
abstract warpControlMouse(position: Vector2): void;
|
|
186
|
+
abstract controlStateChanged(control: Control): void;
|
|
187
|
+
abstract controlRemoved(control: Control): void;
|
|
188
|
+
abstract controlTreeChanged(): void;
|
|
189
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Vector2 } from '@galacean/effects-math/es/core/vector2';
|
|
2
|
+
import type { UICanvas } from '../components/ui-canvas';
|
|
3
|
+
import type { Engine } from '../engine';
|
|
4
|
+
import type { InputEvent } from '../input';
|
|
5
|
+
import type { Control } from './control';
|
|
6
|
+
import { ContainerControl, RootControl } from './control';
|
|
7
|
+
/** CanvasLayer-like boundary for a single UICanvas GUI tree. */
|
|
8
|
+
export declare class CanvasRootControl extends ContainerControl {
|
|
9
|
+
readonly canvas: UICanvas;
|
|
10
|
+
constructor(engine: Engine, canvas: UICanvas);
|
|
11
|
+
get inputDisabled(): boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Global ordered collection of UICanvas roots. */
|
|
14
|
+
export declare class CanvasContainer extends ContainerControl {
|
|
15
|
+
constructor(engine: Engine);
|
|
16
|
+
sortCanvases(): void;
|
|
17
|
+
addChildInternal(child: Control): void;
|
|
18
|
+
draw(): void;
|
|
19
|
+
}
|
|
20
|
+
/** Engine window GUI root. Routes events across all UICanvas roots. */
|
|
21
|
+
export declare class WindowRootControl extends RootControl {
|
|
22
|
+
readonly canvases: CanvasContainer;
|
|
23
|
+
dragThreshold: number;
|
|
24
|
+
private inputHandled;
|
|
25
|
+
private readonly gui;
|
|
26
|
+
constructor(engine: Engine);
|
|
27
|
+
pushInput(event: InputEvent): void;
|
|
28
|
+
isInputHandled(): boolean;
|
|
29
|
+
getMousePosition(): Vector2;
|
|
30
|
+
guiGetFocusOwner(): Control | null;
|
|
31
|
+
guiReleaseFocus(): void;
|
|
32
|
+
guiIsDragging(): boolean;
|
|
33
|
+
guiGetDragData(): unknown;
|
|
34
|
+
guiIsDragSuccessful(): boolean;
|
|
35
|
+
guiCancelDrag(): void;
|
|
36
|
+
acceptControlEvent(control: Control): void;
|
|
37
|
+
grabControlFocus(control: Control): void;
|
|
38
|
+
grabControlClickFocus(control: Control): void;
|
|
39
|
+
releaseControlFocus(control?: Control): void;
|
|
40
|
+
warpControlMouse(position: Vector2): void;
|
|
41
|
+
controlStateChanged(control: Control): void;
|
|
42
|
+
controlRemoved(control: Control): void;
|
|
43
|
+
controlTreeChanged(): void;
|
|
44
|
+
cancelPointerInput(): void;
|
|
45
|
+
resize(width: number, height: number): void;
|
|
46
|
+
render(): void;
|
|
47
|
+
update(deltaTime: number): void;
|
|
48
|
+
dispose(): void;
|
|
49
|
+
private processGUIInput;
|
|
50
|
+
private processMouseButton;
|
|
51
|
+
private processMouseMotion;
|
|
52
|
+
private processScreenTouch;
|
|
53
|
+
private processScreenDrag;
|
|
54
|
+
private callGUIInput;
|
|
55
|
+
private callControlInput;
|
|
56
|
+
private findInputControl;
|
|
57
|
+
private findControlAtPosition;
|
|
58
|
+
private updateMouseOver;
|
|
59
|
+
private buildHoverHierarchy;
|
|
60
|
+
private findClickFocus;
|
|
61
|
+
private beginDragging;
|
|
62
|
+
private finishDrop;
|
|
63
|
+
private findDropTarget;
|
|
64
|
+
private endDragging;
|
|
65
|
+
private updateCursor;
|
|
66
|
+
private postGrabClickFocus;
|
|
67
|
+
private cleanupInternalState;
|
|
68
|
+
private dropMouseFocus;
|
|
69
|
+
private dropMouseOver;
|
|
70
|
+
private dropControlState;
|
|
71
|
+
private requestMouseOverUpdate;
|
|
72
|
+
private getGlobalInverse;
|
|
73
|
+
private toLocal;
|
|
74
|
+
private controlBelongsToSubtree;
|
|
75
|
+
private isControlValid;
|
|
76
|
+
private isControlUsable;
|
|
77
|
+
private findCanvasRoot;
|
|
78
|
+
private isFocusTargetUsable;
|
|
79
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export * from './decorators';
|
|
|
16
16
|
export * from './downloader';
|
|
17
17
|
export * from './effects-object';
|
|
18
18
|
export * from './engine';
|
|
19
|
+
export * from './input';
|
|
20
|
+
export * from './gui';
|
|
19
21
|
export { ensureFixedNumber, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, normalizeColor, } from './fallback';
|
|
20
22
|
export * from './gl';
|
|
21
23
|
export * from './material';
|
|
@@ -33,7 +35,6 @@ export * from './template-image';
|
|
|
33
35
|
export * from './texture';
|
|
34
36
|
export * from './ticker';
|
|
35
37
|
export * from './transform';
|
|
36
|
-
export * from './rect-transform';
|
|
37
38
|
export * from './utils';
|
|
38
39
|
export * from './vfx-item';
|
|
39
40
|
export * from './effects-object';
|