@galacean/effects-core 2.10.0-alpha.2 → 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/index.d.ts +2 -3
- package/dist/components/ui-canvas.d.ts +28 -0
- package/dist/components/ui-control.d.ts +38 -0
- package/dist/composition.d.ts +15 -5
- package/dist/engine.d.ts +30 -5
- 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 +2763 -1056
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2749 -1053
- 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/render/graphics.d.ts +1 -0
- package/dist/render/text-cache.d.ts +8 -9
- 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
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export declare enum MouseFilter {
|
|
2
|
+
Stop = 0,
|
|
3
|
+
Pass = 1,
|
|
4
|
+
Ignore = 2
|
|
5
|
+
}
|
|
6
|
+
export declare enum MouseBehaviorRecursive {
|
|
7
|
+
Inherited = 0,
|
|
8
|
+
Disabled = 1,
|
|
9
|
+
Enabled = 2
|
|
10
|
+
}
|
|
11
|
+
export declare enum MouseButton {
|
|
12
|
+
None = 0,
|
|
13
|
+
Left = 1,
|
|
14
|
+
Right = 2,
|
|
15
|
+
Middle = 3,
|
|
16
|
+
WheelUp = 4,
|
|
17
|
+
WheelDown = 5,
|
|
18
|
+
WheelLeft = 6,
|
|
19
|
+
WheelRight = 7,
|
|
20
|
+
Xbutton1 = 8,
|
|
21
|
+
Xbutton2 = 9
|
|
22
|
+
}
|
|
23
|
+
export declare enum MouseButtonMask {
|
|
24
|
+
None = 0,
|
|
25
|
+
Left = 1,
|
|
26
|
+
Right = 2,
|
|
27
|
+
Middle = 4,
|
|
28
|
+
Xbutton1 = 128,
|
|
29
|
+
Xbutton2 = 256
|
|
30
|
+
}
|
|
31
|
+
export declare enum FocusMode {
|
|
32
|
+
None = 0,
|
|
33
|
+
Click = 1,
|
|
34
|
+
All = 2,
|
|
35
|
+
Accessibility = 3
|
|
36
|
+
}
|
|
37
|
+
export declare enum FocusBehaviorRecursive {
|
|
38
|
+
Inherited = 0,
|
|
39
|
+
Disabled = 1,
|
|
40
|
+
Enabled = 2
|
|
41
|
+
}
|
|
42
|
+
export declare enum KeyLocation {
|
|
43
|
+
Unspecified = 0,
|
|
44
|
+
Left = 1,
|
|
45
|
+
Right = 2
|
|
46
|
+
}
|
|
47
|
+
export declare enum CursorShape {
|
|
48
|
+
Arrow = 0,
|
|
49
|
+
Ibeam = 1,
|
|
50
|
+
PointingHand = 2,
|
|
51
|
+
Cross = 3,
|
|
52
|
+
Wait = 4,
|
|
53
|
+
Busy = 5,
|
|
54
|
+
Drag = 6,
|
|
55
|
+
CanDrop = 7,
|
|
56
|
+
Forbidden = 8,
|
|
57
|
+
Vsize = 9,
|
|
58
|
+
Hsize = 10,
|
|
59
|
+
Bdiagsize = 11,
|
|
60
|
+
Fdiagsize = 12,
|
|
61
|
+
Move = 13,
|
|
62
|
+
Vsplit = 14,
|
|
63
|
+
Hsplit = 15,
|
|
64
|
+
Help = 16
|
|
65
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Matrix3 } from '@galacean/effects-math/es/core/matrix3';
|
|
2
|
+
import { Vector2 } from '@galacean/effects-math/es/core/vector2';
|
|
3
|
+
import { KeyLocation, MouseButton, MouseButtonMask } from './enums';
|
|
4
|
+
export declare class InputEvent {
|
|
5
|
+
static readonly deviceIdEmulation = -1;
|
|
6
|
+
static readonly deviceIdInternal = -2;
|
|
7
|
+
static readonly deviceIdKeyboard = 16;
|
|
8
|
+
static readonly deviceIdMouse = 32;
|
|
9
|
+
device: number;
|
|
10
|
+
pressed: boolean;
|
|
11
|
+
canceled: boolean;
|
|
12
|
+
isPressed(): boolean;
|
|
13
|
+
isReleased(): boolean;
|
|
14
|
+
isCanceled(): boolean;
|
|
15
|
+
isEcho(): boolean;
|
|
16
|
+
xformedBy(transform: Matrix3): InputEvent;
|
|
17
|
+
}
|
|
18
|
+
export declare class InputEventWithModifiers extends InputEvent {
|
|
19
|
+
commandOrControlAutoremap: boolean;
|
|
20
|
+
shiftPressed: boolean;
|
|
21
|
+
altPressed: boolean;
|
|
22
|
+
metaPressed: boolean;
|
|
23
|
+
ctrlPressed: boolean;
|
|
24
|
+
protected copyModifiersTo(event: InputEventWithModifiers): void;
|
|
25
|
+
xformedBy(transform: Matrix3): InputEventWithModifiers;
|
|
26
|
+
}
|
|
27
|
+
export declare class InputEventKey extends InputEventWithModifiers {
|
|
28
|
+
keycode: string;
|
|
29
|
+
physicalKeycode: string;
|
|
30
|
+
keyLabel: string;
|
|
31
|
+
unicode: number;
|
|
32
|
+
location: KeyLocation;
|
|
33
|
+
echo: boolean;
|
|
34
|
+
isEcho(): boolean;
|
|
35
|
+
xformedBy(transform: Matrix3): InputEventKey;
|
|
36
|
+
}
|
|
37
|
+
export declare class InputEventMouse extends InputEventWithModifiers {
|
|
38
|
+
buttonMask: MouseButtonMask;
|
|
39
|
+
position: Vector2;
|
|
40
|
+
globalPosition: Vector2;
|
|
41
|
+
protected copyMouseTo(event: InputEventMouse): void;
|
|
42
|
+
xformedBy(transform: Matrix3): InputEventMouse;
|
|
43
|
+
}
|
|
44
|
+
export declare class InputEventMouseButton extends InputEventMouse {
|
|
45
|
+
factor: number;
|
|
46
|
+
buttonIndex: MouseButton;
|
|
47
|
+
doubleClick: boolean;
|
|
48
|
+
xformedBy(transform: Matrix3): InputEventMouseButton;
|
|
49
|
+
}
|
|
50
|
+
export declare class InputEventMouseMotion extends InputEventMouse {
|
|
51
|
+
tilt: Vector2;
|
|
52
|
+
pressure: number;
|
|
53
|
+
relative: Vector2;
|
|
54
|
+
screenRelative: Vector2;
|
|
55
|
+
velocity: Vector2;
|
|
56
|
+
screenVelocity: Vector2;
|
|
57
|
+
penInverted: boolean;
|
|
58
|
+
xformedBy(transform: Matrix3): InputEventMouseMotion;
|
|
59
|
+
}
|
|
60
|
+
export declare class InputEventScreenTouch extends InputEvent {
|
|
61
|
+
index: number;
|
|
62
|
+
position: Vector2;
|
|
63
|
+
doubleTap: boolean;
|
|
64
|
+
xformedBy(transform: Matrix3): InputEventScreenTouch;
|
|
65
|
+
}
|
|
66
|
+
export declare class InputEventScreenDrag extends InputEvent {
|
|
67
|
+
index: number;
|
|
68
|
+
position: Vector2;
|
|
69
|
+
relative: Vector2;
|
|
70
|
+
screenRelative: Vector2;
|
|
71
|
+
velocity: Vector2;
|
|
72
|
+
screenVelocity: Vector2;
|
|
73
|
+
pressure: number;
|
|
74
|
+
tilt: Vector2;
|
|
75
|
+
penInverted: boolean;
|
|
76
|
+
xformedBy(transform: Matrix3): InputEventScreenDrag;
|
|
77
|
+
}
|
|
@@ -29,20 +29,67 @@ export declare enum PointerEventType {
|
|
|
29
29
|
export declare class EventSystem implements Disposable {
|
|
30
30
|
engine: Engine;
|
|
31
31
|
allowPropagation: boolean;
|
|
32
|
-
enabled: boolean;
|
|
33
32
|
skipPointerMovePicking: boolean;
|
|
33
|
+
private readonly emulateMouseFromTouch;
|
|
34
|
+
private readonly emulateTouchFromMouse;
|
|
35
|
+
private _enabled;
|
|
34
36
|
private handlers;
|
|
35
37
|
private nativeHandlers;
|
|
36
38
|
private target;
|
|
39
|
+
private mouseState;
|
|
40
|
+
private touchStates;
|
|
41
|
+
private mouseFromTouchIndex;
|
|
42
|
+
private touchFromMousePressed;
|
|
43
|
+
private addedTabIndex;
|
|
44
|
+
private addedOutlineStyle;
|
|
37
45
|
constructor(engine: Engine, allowPropagation?: boolean);
|
|
46
|
+
get enabled(): boolean;
|
|
47
|
+
set enabled(value: boolean);
|
|
38
48
|
bindListeners(target: HTMLCanvasElement | null): void;
|
|
39
49
|
dispatchEvent(type: string, event: TouchEventType): void;
|
|
40
50
|
addEventListener(type: string, callback: (event: TouchEventType) => void): () => void;
|
|
41
51
|
removeEventListener(type: string, callback: (event: TouchEventType) => void): void;
|
|
52
|
+
dispose(): void;
|
|
53
|
+
private onNativeWheel;
|
|
54
|
+
private onNativeKeyDown;
|
|
55
|
+
private onNativeKeyUp;
|
|
56
|
+
private onNativeMouseDown;
|
|
57
|
+
private onNativeMouseMove;
|
|
58
|
+
private onNativeMouseUp;
|
|
59
|
+
private onNativeTouchStart;
|
|
60
|
+
private onNativeTouchMove;
|
|
61
|
+
private onNativeTouchEnd;
|
|
62
|
+
private onNativeTouchCancel;
|
|
63
|
+
private onWindowBlur;
|
|
64
|
+
private handleNativeMouseDown;
|
|
65
|
+
private handleNativeKey;
|
|
66
|
+
private handleNativeTouchEnd;
|
|
67
|
+
private pushNativeMouseButton;
|
|
68
|
+
private pushNativeMouseMotion;
|
|
69
|
+
private pushNativeScreenTouch;
|
|
70
|
+
private pushNativeScreenDrag;
|
|
71
|
+
private pushEmulatedMouseButton;
|
|
72
|
+
private pushEmulatedMouseMotion;
|
|
73
|
+
private pushMouseButton;
|
|
74
|
+
private pushWheelButton;
|
|
75
|
+
private pushMouseMotion;
|
|
76
|
+
private pushScreenTouch;
|
|
77
|
+
private pushScreenDrag;
|
|
78
|
+
private copyMouseFields;
|
|
42
79
|
private onClick;
|
|
43
80
|
private onPointerDown;
|
|
44
81
|
private onPointerUp;
|
|
45
82
|
private onPointerMove;
|
|
46
83
|
private handlePointerEvent;
|
|
47
|
-
|
|
84
|
+
private createPointerState;
|
|
85
|
+
private updatePointerState;
|
|
86
|
+
private getVelocity;
|
|
87
|
+
private isClick;
|
|
88
|
+
private createPointerEvent;
|
|
89
|
+
private getCanvasPosition;
|
|
90
|
+
private consumeNativeEvent;
|
|
91
|
+
private preventTouchDefaults;
|
|
92
|
+
private focusTarget;
|
|
93
|
+
private addNativeHandler;
|
|
94
|
+
private unbindListeners;
|
|
48
95
|
}
|
|
@@ -9,19 +9,14 @@ export type FontWeight = 'normal' | 'bold' | number;
|
|
|
9
9
|
*/
|
|
10
10
|
export type FontStyle = 'normal' | 'italic';
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* 但 quad 仍按 1x 逻辑尺寸绘制 — 双线性 downsample 后比原 1x 渲染清晰得多
|
|
14
|
-
*/
|
|
15
|
-
export declare const FONT_SCALE = 2;
|
|
16
|
-
/**
|
|
17
|
-
* 单张字符 atlas 的边长(像素,scale 后的实际像素,非逻辑尺寸)。
|
|
12
|
+
* 单张字符 atlas 的逻辑边长。实际 canvas 像素尺寸会乘以渲染 resolution。
|
|
18
13
|
* 512×512 在 24px 字号下约可容纳 250+ 字形,常见 demo 文本足够
|
|
19
14
|
*/
|
|
20
15
|
export declare const ATLAS_SIZE = 512;
|
|
21
16
|
/**
|
|
22
17
|
* 单个字形在 atlas 中的位置 / 度量。
|
|
23
18
|
*
|
|
24
|
-
* `px/py/pw/ph` 是 atlas canvas 像素(
|
|
19
|
+
* `px/py/pw/ph` 是 atlas canvas 像素(resolution 后,含四周 padding)。
|
|
25
20
|
* `advance` 是逻辑像素光标前进量(1x,不含 padding)— quad 宽度含 padding,
|
|
26
21
|
* 但相邻字只按 advance 前进,padding 区透明因此重叠无妨。
|
|
27
22
|
* `paddingLeft` 是逻辑像素左侧留白(1x),quad 起点左偏此量使字形 ink 落在 cursorX
|
|
@@ -47,12 +42,14 @@ export type GlyphInfo = {
|
|
|
47
42
|
export declare class GlyphAtlas {
|
|
48
43
|
private engine;
|
|
49
44
|
private readonly scaledFontString;
|
|
50
|
-
/** atlas canvas(像素 = ATLAS_SIZE ×
|
|
45
|
+
/** atlas canvas(像素 = ATLAS_SIZE × resolution,自有不进 canvasPool) */
|
|
51
46
|
readonly canvas: HTMLCanvasElement;
|
|
52
47
|
/** 与 canvas 绑定的纹理,内容变更后通过 updateSource 重传 */
|
|
53
48
|
readonly texture: Texture;
|
|
54
49
|
/** cell 高(逻辑像素,含 padding),用于 quad 高度 */
|
|
55
50
|
readonly lineHeight: number;
|
|
51
|
+
/** 字形 canvas 的像素密度,与 Pixi 的纹理 resolution 语义一致。 */
|
|
52
|
+
readonly resolution: number;
|
|
56
53
|
private readonly ctx;
|
|
57
54
|
private readonly glyphs;
|
|
58
55
|
/** baseline 距 cell 顶距离(像素,scale 后,含顶部 padding) */
|
|
@@ -74,7 +71,7 @@ export declare class GlyphAtlas {
|
|
|
74
71
|
/** baseline 距 cell 顶距离(像素,scale 后,仅 ascent 部分,不含 padding) */
|
|
75
72
|
ascentPx: number,
|
|
76
73
|
/** baseline 距 cell 底距离(像素,scale 后,仅 descent 部分) */
|
|
77
|
-
descentPx: number, fontStyle: FontStyle);
|
|
74
|
+
descentPx: number, fontStyle: FontStyle, resolution: number);
|
|
78
75
|
/**
|
|
79
76
|
* 取(必要时渲染并打包)单字。返回 GlyphInfo 或 null(atlas 已满)
|
|
80
77
|
*/
|
|
@@ -99,6 +96,7 @@ export declare class TextCache {
|
|
|
99
96
|
private engine;
|
|
100
97
|
/** fontKey -> 该字体的字符 atlas */
|
|
101
98
|
private readonly atlases;
|
|
99
|
+
private resolution;
|
|
102
100
|
constructor(engine: Engine);
|
|
103
101
|
/**
|
|
104
102
|
* 取(必要时新建)对应字体的字符 atlas
|
|
@@ -114,4 +112,5 @@ export declare class TextCache {
|
|
|
114
112
|
* 清空所有 atlas 并 dispose 对应纹理。Engine dispose 时调用
|
|
115
113
|
*/
|
|
116
114
|
dispose(): void;
|
|
115
|
+
private clear;
|
|
117
116
|
}
|
package/dist/transform.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Matrix3 } from '@galacean/effects-math/es/core/matrix3';
|
|
|
3
3
|
import type * as spec from '@galacean/effects-specification';
|
|
4
4
|
import type { Disposable } from './utils';
|
|
5
5
|
import type { Engine } from './engine';
|
|
6
|
+
import type { EventEmitterListener, EventEmitterOptions } from './events';
|
|
6
7
|
export interface TransformProps {
|
|
7
8
|
position?: spec.vec3 | Vector3;
|
|
8
9
|
rotation?: spec.vec3 | Euler;
|
|
@@ -13,6 +14,9 @@ export interface TransformProps {
|
|
|
13
14
|
anchor?: spec.vec2 | Vector2;
|
|
14
15
|
valid?: boolean;
|
|
15
16
|
}
|
|
17
|
+
export type TransformEvent = {
|
|
18
|
+
changed: [transform: Transform];
|
|
19
|
+
};
|
|
16
20
|
/**
|
|
17
21
|
* 变换组件,用于描述元素的位置、旋转、缩放等信息
|
|
18
22
|
*/
|
|
@@ -87,6 +91,7 @@ export declare class Transform implements Disposable {
|
|
|
87
91
|
* 最终模型矩阵对应变换的缓存,当自身矩阵或父矩阵有修改时需要更新
|
|
88
92
|
*/
|
|
89
93
|
private readonly worldTRSCache;
|
|
94
|
+
private readonly eventEmitter;
|
|
90
95
|
/**
|
|
91
96
|
*
|
|
92
97
|
* @param props
|
|
@@ -95,6 +100,8 @@ export declare class Transform implements Disposable {
|
|
|
95
100
|
constructor(props?: TransformProps, parent?: Transform);
|
|
96
101
|
set parentTransform(transform: Transform | null);
|
|
97
102
|
get parentTransform(): Transform | null;
|
|
103
|
+
on<E extends keyof TransformEvent>(eventName: E, listener: EventEmitterListener<TransformEvent[E]>, options?: EventEmitterOptions): void;
|
|
104
|
+
off<E extends keyof TransformEvent>(eventName: E, listener: EventEmitterListener<TransformEvent[E]>): void;
|
|
98
105
|
private set worldMatrixDirty(value);
|
|
99
106
|
private get worldMatrixDirty();
|
|
100
107
|
/**
|
package/dist/vfx-item.d.ts
CHANGED
|
@@ -141,6 +141,9 @@ export declare class VFXItem extends EffectsObject implements Disposable {
|
|
|
141
141
|
*/
|
|
142
142
|
get renderOrder(): number;
|
|
143
143
|
set renderOrder(value: number);
|
|
144
|
+
/** Zero-based sibling order within the parent item. */
|
|
145
|
+
get orderInParent(): number;
|
|
146
|
+
set orderInParent(value: number);
|
|
144
147
|
/**
|
|
145
148
|
* 元素监听事件
|
|
146
149
|
* @param eventName - 事件名称
|
|
@@ -301,6 +304,7 @@ export declare class VFXItem extends EffectsObject implements Disposable {
|
|
|
301
304
|
*/
|
|
302
305
|
duplicate(): VFXItem;
|
|
303
306
|
private onParentChanged;
|
|
307
|
+
private onOrderInParentChanged;
|
|
304
308
|
fromData(data: spec.VFXItemData): void;
|
|
305
309
|
toData(): void;
|
|
306
310
|
/**
|
package/package.json
CHANGED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import type { Color } from '@galacean/effects-math/es/core';
|
|
2
|
-
import type { FontStyle, FontWeight, TextureRegion } from '../render';
|
|
3
|
-
import type { Texture } from '../texture';
|
|
4
|
-
import { CanvasLayer } from './canvas-layer';
|
|
5
|
-
import { Component } from './component';
|
|
6
|
-
/**
|
|
7
|
-
* 画布元素组件
|
|
8
|
-
*
|
|
9
|
-
* 进入场景树时沿父链向上查找最近的 CanvasLayer 祖先并注册自己;
|
|
10
|
-
* 父级改变或自身销毁时,刷新 / 注销在所属 CanvasLayer 的登记。
|
|
11
|
-
*
|
|
12
|
-
* 注:拓扑(parent / children / 所属 layer)与 enabled/active 解耦 —
|
|
13
|
-
* `component.enabled=false` 仅让自身 draw 被跳过,**不**改父子关系,也**不**从 layer 注销;
|
|
14
|
-
* 整棵子树的隐藏由 `vfxItem.setActive(false)` 配合 drawInternal 中的 `isActive` 检查处理
|
|
15
|
-
*/
|
|
16
|
-
export declare class CanvasItem extends Component {
|
|
17
|
-
/**
|
|
18
|
-
* 父 CanvasItem
|
|
19
|
-
* 沿 VFXItem 父链向上查找到的最近的 CanvasItem(只看类型,不看 active/enabled — 拓扑跟激活状态解耦)。
|
|
20
|
-
* 若不存在 CanvasItem 祖先(即直属于 CanvasLayer 或处于游离状态),该值为 null。
|
|
21
|
-
*/
|
|
22
|
-
parent: CanvasItem | null;
|
|
23
|
-
/**
|
|
24
|
-
* 子 CanvasItem 列表(按注册顺序)
|
|
25
|
-
* 由子节点在维护自身 parent 时反向写入,draw 时按数组顺序递归绘制
|
|
26
|
-
*/
|
|
27
|
-
readonly children: CanvasItem[];
|
|
28
|
-
/**
|
|
29
|
-
* 当前所属的 CanvasLayer,未注册到任何 CanvasLayer 时为 null
|
|
30
|
-
*/
|
|
31
|
-
protected canvasLayerNode: CanvasLayer | null;
|
|
32
|
-
/**
|
|
33
|
-
* 获取当前所属的 CanvasLayer
|
|
34
|
-
*/
|
|
35
|
-
get canvasLayer(): CanvasLayer | null;
|
|
36
|
-
onEnable(): void;
|
|
37
|
-
onDisable(): void;
|
|
38
|
-
onParentChanged(): void;
|
|
39
|
-
onDestroy(): void;
|
|
40
|
-
/**
|
|
41
|
-
* 绘制函数
|
|
42
|
-
* 子类重写此方法以输出实际的绘制内容;调用时 graphics 的变换栈顶已经累积了从根到当前节点的所有父变换,
|
|
43
|
-
* 子类直接使用 this.drawXxx / this.fillXxx 系列封装方法绘制即可,绘制坐标视为本地坐标。
|
|
44
|
-
*/
|
|
45
|
-
draw(): void;
|
|
46
|
-
/**
|
|
47
|
-
* 绘制单条线段
|
|
48
|
-
* @param x1 - 起点 x
|
|
49
|
-
* @param y1 - 起点 y
|
|
50
|
-
* @param x2 - 终点 x
|
|
51
|
-
* @param y2 - 终点 y
|
|
52
|
-
* @param color - 线条颜色
|
|
53
|
-
* @param thickness - 线宽
|
|
54
|
-
*/
|
|
55
|
-
drawLine(x1: number, y1: number, x2: number, y2: number, color?: Color, thickness?: number): void;
|
|
56
|
-
/**
|
|
57
|
-
* 按顺序连接所有点绘制折线(首尾相同则视为闭合)
|
|
58
|
-
* @param points - 点数组,格式 [x1,y1,x2,y2,...]
|
|
59
|
-
* @param color - 线条颜色
|
|
60
|
-
* @param thickness - 线宽
|
|
61
|
-
*/
|
|
62
|
-
drawPolyline(points: number[], color?: Color, thickness?: number): void;
|
|
63
|
-
/**
|
|
64
|
-
* 绘制三次贝塞尔曲线
|
|
65
|
-
*/
|
|
66
|
-
drawBezier(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, color?: Color, thickness?: number): void;
|
|
67
|
-
/**
|
|
68
|
-
* 绘制三角形边框
|
|
69
|
-
*/
|
|
70
|
-
drawTriangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, color?: Color, thickness?: number): void;
|
|
71
|
-
/**
|
|
72
|
-
* 绘制矩形边框
|
|
73
|
-
* @param x - 矩形左下角 x 坐标
|
|
74
|
-
* @param y - 矩形左下角 y 坐标
|
|
75
|
-
*/
|
|
76
|
-
drawRect(x: number, y: number, width: number, height: number, color?: Color, thickness?: number): void;
|
|
77
|
-
/**
|
|
78
|
-
* 绘制圆形边框
|
|
79
|
-
*/
|
|
80
|
-
drawCircle(cx: number, cy: number, radius: number, color?: Color, thickness?: number): void;
|
|
81
|
-
/**
|
|
82
|
-
* 绘制填充三角形
|
|
83
|
-
*/
|
|
84
|
-
fillTriangle(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, color?: Color): void;
|
|
85
|
-
/**
|
|
86
|
-
* 绘制填充矩形
|
|
87
|
-
* @param x - 矩形左下角 x 坐标
|
|
88
|
-
* @param y - 矩形左下角 y 坐标
|
|
89
|
-
*/
|
|
90
|
-
fillRect(x: number, y: number, width: number, height: number, color?: Color): void;
|
|
91
|
-
/**
|
|
92
|
-
* 绘制填充圆形
|
|
93
|
-
*/
|
|
94
|
-
fillCircle(cx: number, cy: number, radius: number, color?: Color): void;
|
|
95
|
-
/**
|
|
96
|
-
* 绘制纹理矩形(本地坐标,Y 向上,(x, y) 为左下角)
|
|
97
|
-
* @param region - 纹理 UV 子矩形,默认全图。Y 向上,(u0, v0) 为左下角 UV
|
|
98
|
-
* @param color - 乘色,默认白色
|
|
99
|
-
*/
|
|
100
|
-
drawTexture(x: number, y: number, width: number, height: number, texture: Texture, region?: TextureRegion, color?: Color): void;
|
|
101
|
-
/**
|
|
102
|
-
* 绘制文本(本地坐标,Y 向上,(x, y) 为文本左下角)。
|
|
103
|
-
*
|
|
104
|
-
* 同一段文本不同颜色不会重复 upload — 颜色由 `color` 参数透传作为乘色,纹理只缓存白色字形。
|
|
105
|
-
* 字体参数全部展开,避免调用方每帧创建临时 style 对象触发 GC
|
|
106
|
-
*/
|
|
107
|
-
drawText(x: number, y: number, text: string, fontSize: number, color?: Color, fontFamily?: string, fontWeight?: FontWeight, fontStyle?: FontStyle): void;
|
|
108
|
-
/**
|
|
109
|
-
* 从当前所属的 CanvasLayer 注销自身(如果有)
|
|
110
|
-
* 仅当自身是顶层 CanvasItem 时,才会触发 layer 顶层列表的移除
|
|
111
|
-
*/
|
|
112
|
-
private removeFromCanvasLayer;
|
|
113
|
-
/**
|
|
114
|
-
* 从当前父 CanvasItem 的 children 中移除自身(如果有)
|
|
115
|
-
*/
|
|
116
|
-
private removeFromParent;
|
|
117
|
-
/**
|
|
118
|
-
* 更新所有子 CanvasItem 的层级归属。
|
|
119
|
-
* 自身失效时调用,子节点会跳过自己向上找到新的父 CanvasItem(可能为 null)。
|
|
120
|
-
*/
|
|
121
|
-
private updateChildrenParentItems;
|
|
122
|
-
/**
|
|
123
|
-
* 沿父链向上查找最近的 CanvasLayer 祖先
|
|
124
|
-
* 注意:自身所在 VFXItem 上的 CanvasLayer 也参与查找(同节点上可能并存 CanvasLayer 与 CanvasItem)
|
|
125
|
-
*/
|
|
126
|
-
private getCanvasLayerNode;
|
|
127
|
-
/**
|
|
128
|
-
* 沿 VFXItem 父链向上查找最近的 CanvasItem 祖先(不包含自身,只看类型不看 active/enabled)
|
|
129
|
-
*/
|
|
130
|
-
private getParentItem;
|
|
131
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { CanvasItem } from './canvas-item';
|
|
2
|
-
import { Component } from './component';
|
|
3
|
-
/**
|
|
4
|
-
* 画布层组件
|
|
5
|
-
*
|
|
6
|
-
* 作为一组顶层 CanvasItem 的容器:本层内所有 parent 为 null 的 CanvasItem 都登记在 canvasItems 中。
|
|
7
|
-
* 嵌套关系下的子 CanvasItem 通过其父 CanvasItem 的 children 数组管理,由父节点在 draw 时递归绘制。
|
|
8
|
-
*/
|
|
9
|
-
export declare class CanvasLayer extends Component {
|
|
10
|
-
/**
|
|
11
|
-
* 当前层中的顶层 CanvasItem 列表(按注册顺序)。
|
|
12
|
-
* 仅包含 parent 为 null 的 CanvasItem;嵌套的子 CanvasItem 不会出现在此列表
|
|
13
|
-
*/
|
|
14
|
-
readonly canvasItems: CanvasItem[];
|
|
15
|
-
/**
|
|
16
|
-
* 绘制层级,数值越小越先绘制
|
|
17
|
-
*/
|
|
18
|
-
layer: number;
|
|
19
|
-
onEnable(): void;
|
|
20
|
-
onDisable(): void;
|
|
21
|
-
private removeFromComposition;
|
|
22
|
-
private refreshCanvasItemsLayer;
|
|
23
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CanvasItem } from './canvas-item';
|
|
2
|
-
/**
|
|
3
|
-
* 锚点布局组件
|
|
4
|
-
*
|
|
5
|
-
* `Control extends CanvasItem`。CanvasItem 仅承担绘制与节点层级,Control 在挂到 VFXItem 时把
|
|
6
|
-
* `item.transform` 升级为 {@link RectTransform}。
|
|
7
|
-
*
|
|
8
|
-
* 布局完全由 RectTransform 自治:父子节点关系沿 `Transform.parentTransform / children` 走,
|
|
9
|
-
* 父节点 size 变化时通过 `RectTransform.sizeChanged()` 直接调用子节点 sizeChanged 链式传播。
|
|
10
|
-
* Control 本身不持有任何与布局相关的状态
|
|
11
|
-
*/
|
|
12
|
-
export declare class Control extends CanvasItem {
|
|
13
|
-
/**
|
|
14
|
-
* 在挂到 VFXItem 时确保 `item.transform` 是 `RectTransform`。
|
|
15
|
-
* 既有 Transform 状态(position / rotation / scale / size / anchor 等)通过 `RectTransform.fromTransform` 复制
|
|
16
|
-
*/
|
|
17
|
-
onAwake(): void;
|
|
18
|
-
}
|
package/dist/rect-transform.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { Vector2 } from '@galacean/effects-math/es/core/vector2';
|
|
2
|
-
import type * as spec from '@galacean/effects-specification';
|
|
3
|
-
import { Transform } from './transform';
|
|
4
|
-
/**
|
|
5
|
-
* 2D 矩形,`position` 为左下角(Y 向上),`size` 为宽高
|
|
6
|
-
*/
|
|
7
|
-
export type Rect = {
|
|
8
|
-
position: Vector2;
|
|
9
|
-
size: Vector2;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* 16 个内建锚点预设,字面意义对应屏幕视觉位置(Y 向上)
|
|
13
|
-
*/
|
|
14
|
-
export type LayoutPreset = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'centerLeft' | 'centerTop' | 'centerRight' | 'centerBottom' | 'center' | 'leftWide' | 'topWide' | 'rightWide' | 'bottomWide' | 'vcenterWide' | 'hcenterWide' | 'fullRect';
|
|
15
|
-
/**
|
|
16
|
-
* 锚点布局变换。`RectTransform extends Transform`,在 Transform 的 position/rotation/scale/size/anchor(=pivot 偏移)
|
|
17
|
-
* 之上额外维护 4 边锚点 + 4 边像素偏移,提供 rect 解算与编辑 API。
|
|
18
|
-
*
|
|
19
|
-
* 解算公式(Y 向上,父 vertex 坐标原点 = 父 rect 左下角):
|
|
20
|
-
* ```
|
|
21
|
-
* left = offsetMin.x + anchorMin.x * parentSize.x
|
|
22
|
-
* bottom = offsetMin.y + anchorMin.y * parentSize.y
|
|
23
|
-
* right = offsetMax.x + anchorMax.x * parentSize.x
|
|
24
|
-
* top = offsetMax.y + anchorMax.y * parentSize.y
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* 写回 Transform:
|
|
28
|
-
* - `position` ← `(left, bottom)`(rect 左下角,父 vertex 坐标)
|
|
29
|
-
* - `size` ← rect 尺寸
|
|
30
|
-
* - `anchor`(Vector3 像素 pivot 偏移)由用户独立设置,仅作旋转/缩放中心
|
|
31
|
-
*
|
|
32
|
-
* **解算入口** 是 `sizeChanged()` 方法:
|
|
33
|
-
* - 父是 RectTransform → 用 `parent.size` 作 parentSize 解算自身,写回 `position` / `size`
|
|
34
|
-
* - 否则(顶层 / 没父):自身 size 视为权威值(由外部 — 通常是 CanvasLayer — 直接写),不再自解算
|
|
35
|
-
* - 末尾遍历 `children` 中的 RectTransform,直接调它们的 `sizeChanged()`,链式向下传播
|
|
36
|
-
*
|
|
37
|
-
* **重写 `setPosition` / `setSize`** 让其语义变为"用户输入 rect 位置 / 尺寸":
|
|
38
|
-
* - 顶层(无 RectTransform 父):直接写 `super.setPosition / super.setSize`,然后 `sizeChanged` 传播给子节点
|
|
39
|
-
* - 否则:反推 offset 维持当前 anchor,然后 `sizeChanged` 重算并向下传
|
|
40
|
-
*/
|
|
41
|
-
export declare class RectTransform extends Transform {
|
|
42
|
-
/**
|
|
43
|
-
* 父 rect 上的归一化最小角 `(anchorLeft, anchorBottom)`
|
|
44
|
-
*/
|
|
45
|
-
readonly anchorMin: Vector2;
|
|
46
|
-
/**
|
|
47
|
-
* 父 rect 上的归一化最大角 `(anchorRight, anchorTop)`
|
|
48
|
-
*/
|
|
49
|
-
readonly anchorMax: Vector2;
|
|
50
|
-
/**
|
|
51
|
-
* rect 左/下边相对 anchorMin 锚点的像素偏移 `(offsetLeft, offsetBottom)`
|
|
52
|
-
*/
|
|
53
|
-
readonly offsetMin: Vector2;
|
|
54
|
-
/**
|
|
55
|
-
* rect 右/上边相对 anchorMax 锚点的像素偏移 `(offsetRight, offsetTop)`
|
|
56
|
-
*/
|
|
57
|
-
readonly offsetMax: Vector2;
|
|
58
|
-
/**
|
|
59
|
-
* 自身 rect 上的归一化轴心 `(0..1)`,默认 `(0.5, 0.5)`(中心)。两层效果:
|
|
60
|
-
* 1. **Layout**:`setSize` 时 rect 围绕此点对称缩放(pivot=(0.5, 0.5) → 居中扩展;pivot=(0, 0) → 从左下扩展;pivot=(1, 1) → 向左下缩)
|
|
61
|
-
* 2. **矩阵**:`pivot` 自动同步到 `transform.anchor = pivot * size`(像素值,矩阵旋转/缩放中心),
|
|
62
|
-
* 所以旋转/缩放也围绕同一点。`setPivot` 和每次 `sizeChanged`(size 重算后)都会刷新 `transform.anchor`
|
|
63
|
-
*/
|
|
64
|
-
readonly pivot: Vector2;
|
|
65
|
-
/**
|
|
66
|
-
* 用既有 Transform 的状态创建 RectTransform。
|
|
67
|
-
* 用于 Control / CanvasLayer 接管 VFXItem 时,把 VFXItem 自带的 Transform 升级为 RectTransform 而不丢失 position/rotation/scale 等已设置好的状态。
|
|
68
|
-
*/
|
|
69
|
-
static fromTransform(t: Transform): RectTransform;
|
|
70
|
-
/**
|
|
71
|
-
* 反序列化:在 `Transform.fromData` 基础上还原 RectTransform 特有的 `pivot` /
|
|
72
|
-
* `anchorMin` / `anchorMax` / `offsetMin` / `offsetMax`。
|
|
73
|
-
*
|
|
74
|
-
* 顺序:
|
|
75
|
-
* 1. `super.fromData` 还原 `position` / `rotation` / `scale` / `size` / `anchor`
|
|
76
|
-
* 2. 若数据有 size,从 `anchor / size` 反推 `pivot`,保持 `anchor = pivot * size` 一致
|
|
77
|
-
* 3. 应用 `anchorMin/Max` / `offsetMin/Max`,每个 setter 末尾会触发 `sizeChanged`
|
|
78
|
-
* 重新解算 rect 与同步 `transform.anchor`
|
|
79
|
-
*/
|
|
80
|
-
fromData(data: spec.TransformData): void;
|
|
81
|
-
setAnchorMin(x: number, y: number): void;
|
|
82
|
-
setAnchorMax(x: number, y: number): void;
|
|
83
|
-
setOffsetMin(x: number, y: number): void;
|
|
84
|
-
setOffsetMax(x: number, y: number): void;
|
|
85
|
-
/**
|
|
86
|
-
* 设置 rect 内的归一化轴心 `(0..1)`,同时把 `transform.anchor`(矩阵旋转/缩放中心)同步到 `pivot * size`。
|
|
87
|
-
* 不重算 rect(pivot 只决定 setSize 行为,不直接影响当前 rect 位置 / 尺寸)
|
|
88
|
-
*/
|
|
89
|
-
setPivot(x: number, y: number): void;
|
|
90
|
-
/**
|
|
91
|
-
* 重写父类 `setPosition`:
|
|
92
|
-
* - 顶层(无 RectTransform 父):直接 `super.setPosition` 写位置,触发 `sizeChanged` 传播
|
|
93
|
-
* - 非顶层:语义为"设置 rect 左下角到 (x, y)",反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
|
|
94
|
-
*
|
|
95
|
-
* @param keepOffsets - 默认 false。true 时反推 anchor 而非 offset(rect 在屏幕上不动,但 anchor 比例改变)
|
|
96
|
-
*/
|
|
97
|
-
setPosition(x: number, y: number, z: number, keepOffsets?: boolean): void;
|
|
98
|
-
/**
|
|
99
|
-
* 重写父类 `setSize`:
|
|
100
|
-
* - 顶层:直接 `super.setSize`,触发 `sizeChanged` 传播
|
|
101
|
-
* - 非顶层:反推 offset 维持当前 anchor,然后 `sizeChanged` 重算
|
|
102
|
-
*/
|
|
103
|
-
setSize(x: number, y: number): void;
|
|
104
|
-
/**
|
|
105
|
-
* 当前自身 rect(在父 vertex 坐标下,Y 向上)。`sizeChanged` 之后才有意义
|
|
106
|
-
*/
|
|
107
|
-
getRect(): Rect;
|
|
108
|
-
private onCanvasResize;
|
|
109
|
-
/**
|
|
110
|
-
* 解算入口:
|
|
111
|
-
*
|
|
112
|
-
* 1. 父是 RectTransform → 从 `parent.size` 求自身 rect,通过 `super.setPosition / super.setSize` 写回
|
|
113
|
-
* (避免触发本类 setPosition / setSize 重写)
|
|
114
|
-
* 2. 顶层(无 RectTransform 父):自身 size 视为权威值(由 CanvasLayer 等外部直接写),不自解算
|
|
115
|
-
* 3. 遍历 `children` 中所有 RectTransform 子节点,直接调它们的 `sizeChanged()` 链式传播
|
|
116
|
-
*/
|
|
117
|
-
sizeChanged(): void;
|
|
118
|
-
/**
|
|
119
|
-
* 给定目标 rect 反推 offsetMin/Max,保持当前 anchor 不变
|
|
120
|
-
*/
|
|
121
|
-
private computeOffsets;
|
|
122
|
-
/**
|
|
123
|
-
* 给定目标 rect 反推 anchorMin/Max,保持当前 offset 不变。父 size 为 0 的方向不修改
|
|
124
|
-
*/
|
|
125
|
-
private computeAnchors;
|
|
126
|
-
/**
|
|
127
|
-
* 把 anchorMin/Max 设为内建预设。
|
|
128
|
-
* @param keepOffsets - 默认 true:offset 不动,rect 实际位置会跳到新 anchor 计算的位置(要求保留视觉位置请用 setAnchorsAndOffsetsPreset)
|
|
129
|
-
*/
|
|
130
|
-
setAnchorsPreset(preset: LayoutPreset, keepOffsets?: boolean): void;
|
|
131
|
-
/**
|
|
132
|
-
* 把 offsetMin/Max 设为预设值,使 rect 在父 rect 内落在视觉上对应的位置(留 margin 像素边距)。
|
|
133
|
-
* 当 anchor 已经按相同 preset 设定时,等价于“贴边放置带 margin 的 rect”。
|
|
134
|
-
* 使用当前 size 作为 rect 尺寸。
|
|
135
|
-
*/
|
|
136
|
-
setOffsetsPreset(preset: LayoutPreset, margin?: number): void;
|
|
137
|
-
/**
|
|
138
|
-
* 同时设置 anchor 和 offset,达到“按 preset 摆放并贴边带 margin”的效果。
|
|
139
|
-
*
|
|
140
|
-
* 注意第一步用 `keepOffsets=false`(反推 offset 维持 rect 视觉位置),不能用默认 `true`:
|
|
141
|
-
* 后者会让 rect 的 size 在中间步先跳到错值(因为 anchor 改了 offset 没改),
|
|
142
|
-
* 第二步 `setOffsetsPreset` 又用这个错 size 算 offset,最终 rect size 不对
|
|
143
|
-
*/
|
|
144
|
-
setAnchorsAndOffsetsPreset(preset: LayoutPreset, margin?: number): void;
|
|
145
|
-
}
|