@galacean/effects-core 2.9.1-beta.0 → 2.10.0-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/dist/canvas-pool.d.ts +58 -3
- package/dist/components/canvas-item.d.ts +131 -0
- package/dist/components/canvas-layer.d.ts +23 -0
- package/dist/components/control.d.ts +18 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/composition.d.ts +12 -3
- package/dist/engine.d.ts +6 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10192 -7722
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10181 -7721
- package/dist/index.mjs.map +1 -1
- package/dist/math/index.d.ts +3 -2
- package/dist/math/shape/build-adaptive-bezier.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/shape/contour-measure.d.ts +43 -0
- package/dist/plugins/shape/contour-path-utils.d.ts +10 -0
- package/dist/plugins/shape/contour-path.d.ts +20 -0
- package/dist/{math → plugins}/shape/graphics-path.d.ts +1 -1
- package/dist/plugins/shape/index.d.ts +2 -0
- package/dist/{components → plugins/shape}/shape-component.d.ts +13 -7
- package/dist/{math → plugins}/shape/shape-path.d.ts +3 -3
- package/dist/plugins/shape/trim-path.d.ts +25 -0
- package/dist/plugins/text/text-component-base.d.ts +1 -0
- package/dist/rect-transform.d.ts +145 -0
- package/dist/render/graphics.d.ts +127 -51
- package/dist/render/index.d.ts +1 -0
- package/dist/render/text-cache.d.ts +109 -0
- package/dist/transform.d.ts +14 -3
- package/package.json +1 -1
package/dist/canvas-pool.d.ts
CHANGED
|
@@ -1,9 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 池内缓存的一组 canvas 与其 2D context。
|
|
3
|
+
*/
|
|
4
|
+
export type CanvasAndContext = {
|
|
5
|
+
canvas: HTMLCanvasElement;
|
|
6
|
+
context: CanvasRenderingContext2D;
|
|
7
|
+
};
|
|
1
8
|
declare class CanvasPool {
|
|
2
|
-
|
|
9
|
+
/**
|
|
10
|
+
* 空闲 canvas 的全局缓存上限。
|
|
11
|
+
*/
|
|
12
|
+
private readonly _maxCachedCount;
|
|
13
|
+
/**
|
|
14
|
+
* 按尺寸 key 分桶的空闲 canvas 池。
|
|
15
|
+
*/
|
|
16
|
+
private readonly _canvasPool;
|
|
17
|
+
/**
|
|
18
|
+
* 全局空闲队列,顺序表示最近归还时间,头部最久未使用。
|
|
19
|
+
*/
|
|
20
|
+
private readonly _cachedCanvasAndContexts;
|
|
3
21
|
constructor();
|
|
22
|
+
/**
|
|
23
|
+
* 释放池内所有空闲 canvas。
|
|
24
|
+
*/
|
|
4
25
|
dispose(): void;
|
|
5
|
-
|
|
6
|
-
|
|
26
|
+
/**
|
|
27
|
+
* 清空当前池里的所有空闲项。
|
|
28
|
+
*/
|
|
29
|
+
clear(): void;
|
|
30
|
+
/**
|
|
31
|
+
* 按目标尺寸获取一组可复用的 canvas 与 context。
|
|
32
|
+
*/
|
|
33
|
+
getCanvasAndContext(width: number, height: number): CanvasAndContext;
|
|
34
|
+
/**
|
|
35
|
+
* 归还一组 canvas 与 context,并在超过上限时收缩空闲缓存池。
|
|
36
|
+
*/
|
|
37
|
+
releaseCanvasAndContext(canvasAndContext: CanvasAndContext): void;
|
|
38
|
+
/**
|
|
39
|
+
* 新建一组指定尺寸的 canvas 与 context。
|
|
40
|
+
*/
|
|
41
|
+
private createCanvasAndContext;
|
|
42
|
+
/**
|
|
43
|
+
* 清理归还对象上的绘制状态,确保下次复用时是干净的。
|
|
44
|
+
*/
|
|
45
|
+
private resetCanvasAndContext;
|
|
46
|
+
/**
|
|
47
|
+
* 计算尺寸分桶使用的整数 key。
|
|
48
|
+
*/
|
|
49
|
+
private getKey;
|
|
50
|
+
/**
|
|
51
|
+
* 当前池内空闲对象总数。
|
|
52
|
+
*/
|
|
53
|
+
private getCachedCount;
|
|
54
|
+
/**
|
|
55
|
+
* 收缩空闲缓存池,移除最久未使用的一半空闲项。
|
|
56
|
+
*/
|
|
57
|
+
private cleanUnusedCachedCanvasPool;
|
|
58
|
+
/**
|
|
59
|
+
* 销毁单个 canvas 节点。
|
|
60
|
+
*/
|
|
61
|
+
private destroyCanvas;
|
|
7
62
|
}
|
|
8
63
|
export declare const canvasPool: CanvasPool;
|
|
9
64
|
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -6,6 +6,8 @@ export * from './effect-component';
|
|
|
6
6
|
export * from './position-constraint';
|
|
7
7
|
export * from './post-process-volume';
|
|
8
8
|
export * from './base-render-component';
|
|
9
|
-
export * from './shape-component';
|
|
10
9
|
export * from './fake-3d-component';
|
|
11
10
|
export * from './frame-component';
|
|
11
|
+
export * from './canvas-layer';
|
|
12
|
+
export * from './canvas-item';
|
|
13
|
+
export * from './control';
|
package/dist/composition.d.ts
CHANGED
|
@@ -168,9 +168,9 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
168
168
|
*/
|
|
169
169
|
readonly url: Scene.LoadType;
|
|
170
170
|
/**
|
|
171
|
-
*
|
|
171
|
+
* 合成场景根元素
|
|
172
172
|
*/
|
|
173
|
-
readonly
|
|
173
|
+
readonly sceneRoot: VFXItem;
|
|
174
174
|
/**
|
|
175
175
|
* 合成的相机对象
|
|
176
176
|
*/
|
|
@@ -179,6 +179,10 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
179
179
|
* 合成开始渲染的时间
|
|
180
180
|
*/
|
|
181
181
|
readonly startTime: number;
|
|
182
|
+
/**
|
|
183
|
+
* 插件元素根元素
|
|
184
|
+
*/
|
|
185
|
+
readonly pluginRoot: VFXItem;
|
|
182
186
|
/**
|
|
183
187
|
* 场景中视频列表
|
|
184
188
|
*/
|
|
@@ -222,6 +226,10 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
222
226
|
*/
|
|
223
227
|
get height(): number;
|
|
224
228
|
get renderer(): import("packages/effects-core/src/render/renderer").Renderer;
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated 2.10.0 Please use `sceneRoot` instead
|
|
231
|
+
*/
|
|
232
|
+
get rootItem(): VFXItem;
|
|
225
233
|
/**
|
|
226
234
|
* 所有合成 Item 的根变换
|
|
227
235
|
*/
|
|
@@ -331,7 +339,7 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
331
339
|
* 重置状态函数
|
|
332
340
|
*/
|
|
333
341
|
protected reset(): void;
|
|
334
|
-
|
|
342
|
+
render(): void;
|
|
335
343
|
/**
|
|
336
344
|
* 合成更新,针对所有 item 的更新
|
|
337
345
|
* @param deltaTime - 更新的时间步长
|
|
@@ -347,6 +355,7 @@ export declare class Composition extends EventEmitter<CompositionEvent<Compositi
|
|
|
347
355
|
* 更新主合成组件
|
|
348
356
|
*/
|
|
349
357
|
private updateCompositionTime;
|
|
358
|
+
private renderCanvasLayers;
|
|
350
359
|
/**
|
|
351
360
|
* 通过名称获取元素
|
|
352
361
|
* @param name - 元素名称
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as spec from '@galacean/effects-specification';
|
|
2
|
+
import type { Matrix4 } from '@galacean/effects-math/es/core/matrix4';
|
|
2
3
|
import type { Database, SceneData } from './asset-loader';
|
|
3
4
|
import type { EffectsObject } from './effects-object';
|
|
4
5
|
import type { Material } from './material';
|
|
5
6
|
import type { GPUCapability, Geometry, Mesh, RenderPass, RenderPassClearAction, Renderer, RenderingData, ShaderLibrary } from './render';
|
|
6
|
-
import { RenderTargetPool } from './render';
|
|
7
|
+
import { Graphics, RenderTargetPool } from './render';
|
|
7
8
|
import type { Scene, SceneRenderLevel } from './scene';
|
|
8
9
|
import type { Texture } from './texture';
|
|
9
10
|
import type { Disposable } from './utils';
|
|
@@ -11,11 +12,10 @@ import type { Composition } from './composition';
|
|
|
11
12
|
import type { AssetManager } from './asset-manager';
|
|
12
13
|
import { AssetService } from './asset-service';
|
|
13
14
|
import { Ticker } from './ticker';
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
16
|
-
import type {
|
|
15
|
+
import type { PointerEventData, Region } from './plugins';
|
|
16
|
+
import { EventSystem } from './plugins';
|
|
17
|
+
import type { GLType } from './gl';
|
|
17
18
|
import { EventEmitter } from './events';
|
|
18
|
-
import type { Matrix4 } from '@galacean/effects-math/es/core/matrix4';
|
|
19
19
|
export interface EngineOptions extends WebGLContextAttributes {
|
|
20
20
|
name?: string;
|
|
21
21
|
glType?: GLType;
|
|
@@ -94,6 +94,7 @@ export declare class Engine extends EventEmitter<EngineEvent> implements Disposa
|
|
|
94
94
|
* 存放渲染需要用到的数据
|
|
95
95
|
*/
|
|
96
96
|
renderingData: RenderingData;
|
|
97
|
+
graphics: Graphics;
|
|
97
98
|
protected _disposed: boolean;
|
|
98
99
|
protected textures: Texture[];
|
|
99
100
|
protected materials: Material[];
|
package/dist/index.d.ts
CHANGED