@galacean/effects-core 2.0.0-alpha.9 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +25 -21
  2. package/dist/__definations__/fbeffects-object-data.d.ts +28 -0
  3. package/dist/__definations__/fbeffects-package-data.d.ts +26 -0
  4. package/dist/__definations__/fbgeometry-data.d.ts +77 -0
  5. package/dist/__definations__/fbsub-mesh.d.ts +26 -0
  6. package/dist/__definations__/fbvertex-channel.d.ts +33 -0
  7. package/dist/__definations__/fbvertex-data.d.ts +27 -0
  8. package/dist/__definations__/index.d.ts +6 -0
  9. package/dist/asset-loader.d.ts +0 -13
  10. package/dist/binary-asset.d.ts +6 -0
  11. package/dist/camera.d.ts +11 -2
  12. package/dist/canvas-pool.d.ts +0 -1
  13. package/dist/comp-vfx-item.d.ts +26 -12
  14. package/dist/components/component.d.ts +9 -14
  15. package/dist/components/effect-component.d.ts +3 -23
  16. package/dist/components/index.d.ts +1 -0
  17. package/dist/components/post-process-volume.d.ts +15 -0
  18. package/dist/components/renderer-component.d.ts +2 -2
  19. package/dist/composition-source-manager.d.ts +8 -7
  20. package/dist/composition.d.ts +65 -62
  21. package/dist/constants.d.ts +1 -1
  22. package/dist/decorators.d.ts +4 -3
  23. package/dist/downloader.d.ts +9 -0
  24. package/dist/effects-object.d.ts +1 -0
  25. package/dist/effects-package.d.ts +19 -0
  26. package/dist/engine.d.ts +7 -4
  27. package/dist/events/event-emitter.d.ts +46 -0
  28. package/dist/events/index.d.ts +2 -0
  29. package/dist/events/types.d.ts +37 -0
  30. package/dist/fallback/camera.d.ts +2 -0
  31. package/dist/fallback/index.d.ts +12 -0
  32. package/dist/fallback/interact.d.ts +2 -0
  33. package/dist/fallback/migration.d.ts +20 -0
  34. package/dist/fallback/particle.d.ts +2 -0
  35. package/dist/fallback/sprite.d.ts +3 -0
  36. package/dist/fallback/utils.d.ts +25 -0
  37. package/dist/gl/create-gl-context.d.ts +2 -1
  38. package/dist/gl/index.d.ts +3 -0
  39. package/dist/image-asset.d.ts +5 -0
  40. package/dist/index.d.ts +9 -4
  41. package/dist/index.js +19373 -14510
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +19333 -14477
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/material/material.d.ts +5 -6
  46. package/dist/material/utils.d.ts +0 -10
  47. package/dist/math/bezier.d.ts +99 -0
  48. package/dist/math/keyframe-info.d.ts +39 -0
  49. package/dist/math/translate.d.ts +3 -2
  50. package/dist/math/utils.d.ts +5 -4
  51. package/dist/math/value-getter.d.ts +52 -26
  52. package/dist/pass-render-level.d.ts +3 -1
  53. package/dist/plugin-system.d.ts +2 -2
  54. package/dist/plugins/cal/animation-playable.d.ts +2 -1
  55. package/dist/plugins/cal/calculate-item.d.ts +5 -39
  56. package/dist/plugins/cal/calculate-vfx-item.d.ts +54 -13
  57. package/dist/plugins/cal/playable-graph.d.ts +72 -21
  58. package/dist/plugins/cal/timeline-asset.d.ts +27 -0
  59. package/dist/plugins/camera/camera-controller-node.d.ts +2 -13
  60. package/dist/plugins/index.d.ts +8 -3
  61. package/dist/plugins/interact/click-handler.d.ts +3 -3
  62. package/dist/plugins/interact/event-system.d.ts +0 -2
  63. package/dist/plugins/interact/interact-item.d.ts +15 -1
  64. package/dist/plugins/particle/burst.d.ts +10 -3
  65. package/dist/plugins/particle/link.d.ts +1 -0
  66. package/dist/plugins/particle/particle-loader.d.ts +2 -2
  67. package/dist/plugins/particle/particle-mesh.d.ts +5 -9
  68. package/dist/plugins/particle/particle-system-renderer.d.ts +1 -1
  69. package/dist/plugins/particle/particle-system.d.ts +13 -6
  70. package/dist/plugins/particle/particle-vfx-item.d.ts +9 -3
  71. package/dist/plugins/particle/trail-mesh.d.ts +2 -2
  72. package/dist/plugins/plugin.d.ts +6 -6
  73. package/dist/plugins/sprite/sprite-item.d.ts +16 -12
  74. package/dist/plugins/sprite/sprite-mesh.d.ts +0 -4
  75. package/dist/plugins/text/index.d.ts +4 -0
  76. package/dist/plugins/text/text-item.d.ts +32 -5
  77. package/dist/plugins/text/text-layout.d.ts +9 -1
  78. package/dist/plugins/timeline/playables/activation-mixer-playable.d.ts +7 -0
  79. package/dist/plugins/timeline/playables/sub-composition-clip-playable.d.ts +5 -0
  80. package/dist/plugins/timeline/playables/sub-composition-playable-asset.d.ts +5 -0
  81. package/dist/plugins/timeline/track.d.ts +72 -0
  82. package/dist/plugins/timeline/tracks/activation-track.d.ts +5 -0
  83. package/dist/plugins/timeline/tracks/sprite-color-track.d.ts +3 -0
  84. package/dist/plugins/timeline/tracks/sub-composition-track.d.ts +4 -0
  85. package/dist/plugins/timeline/tracks/transform-track.d.ts +3 -0
  86. package/dist/render/create-copy-shader.d.ts +2 -2
  87. package/dist/render/{frame-buffer.d.ts → framebuffer.d.ts} +7 -7
  88. package/dist/render/geometry.d.ts +14 -1
  89. package/dist/render/global-volume.d.ts +4 -5
  90. package/dist/render/gpu-capability.d.ts +6 -6
  91. package/dist/render/index.d.ts +2 -2
  92. package/dist/render/mesh.d.ts +1 -1
  93. package/dist/render/render-frame.d.ts +11 -10
  94. package/dist/render/render-pass.d.ts +8 -8
  95. package/dist/render/{render-buffer.d.ts → renderbuffer.d.ts} +4 -4
  96. package/dist/render/renderer.d.ts +9 -7
  97. package/dist/render/semantic-map.d.ts +1 -1
  98. package/dist/render/shader.d.ts +4 -4
  99. package/dist/scene.d.ts +10 -4
  100. package/dist/serialization-helper.d.ts +6 -4
  101. package/dist/shader/index.d.ts +1 -3
  102. package/dist/shader/shader-factory.d.ts +35 -0
  103. package/dist/shape/shape.d.ts +1 -1
  104. package/dist/template-image.d.ts +3 -3
  105. package/dist/texture/texture.d.ts +2 -0
  106. package/dist/texture/types.d.ts +2 -2
  107. package/dist/texture/utils.d.ts +2 -1
  108. package/dist/ticker.d.ts +2 -2
  109. package/dist/transform.d.ts +3 -3
  110. package/dist/utils/array.d.ts +1 -1
  111. package/dist/utils/device.d.ts +4 -0
  112. package/dist/utils/index.d.ts +29 -14
  113. package/dist/utils/text.d.ts +8 -0
  114. package/dist/vfx-item.d.ts +75 -62
  115. package/package.json +7 -5
  116. package/dist/asset-migrations.d.ts +0 -5
  117. package/dist/plugins/cal/animation-mixer-playable.d.ts +0 -4
  118. package/dist/plugins/cal/animation-playable-output.d.ts +0 -4
  119. package/dist/plugins/cal/track.d.ts +0 -34
  120. package/dist/utils/timeline-component.d.ts +0 -6
@@ -0,0 +1,35 @@
1
+ import type { ShaderMacros } from '../render';
2
+ import { ShaderType } from '../material';
3
+ export interface ShaderCodeOptions {
4
+ level: number;
5
+ shaderType: ShaderType;
6
+ shader: string;
7
+ macros?: ShaderMacros;
8
+ removeVersion?: boolean;
9
+ }
10
+ export declare class ShaderFactory {
11
+ static registerInclude(includeName: string, includeSource: string): void;
12
+ static unRegisterInclude(includeName: string): void;
13
+ static unRegisterAllIncludes(): void;
14
+ /**
15
+ * 生成 shader,检测到 WebGL1 上下文会降级
16
+ * @param macros - 宏定义数组
17
+ * @param shader - 原始 shader 文本
18
+ * @param shaderType - shader 类型
19
+ * @return 去除版本号的 shader 文本
20
+ */
21
+ static genFinalShaderCode(options: ShaderCodeOptions): string;
22
+ /**
23
+ * Convert lower GLSL version to GLSL 300 es.
24
+ * @param source - code
25
+ * @param isFragment - Whether it is a fragment shader.
26
+ * */
27
+ private static convertTo300;
28
+ private static parseIncludes;
29
+ private static genMacroString;
30
+ private static genShaderVersion;
31
+ private static isVersion300;
32
+ private static removeWebGLVersion;
33
+ private static has300Output;
34
+ private static replaceMRTShader;
35
+ }
@@ -18,4 +18,4 @@ export type ShapeGenerator = Shape & {
18
18
  alignSpeedDirection?: boolean;
19
19
  upDirection?: Vector3;
20
20
  };
21
- export declare function createShape(shapeOptions: spec.ParticleShape): Shape;
21
+ export declare function createShape(shapeOptions?: spec.ParticleShape): Shape;
@@ -1,5 +1,5 @@
1
- import type { TemplateContent } from '@galacean/effects-specification';
2
- export declare function getBackgroundImage(template: TemplateContent, variables?: Record<string, number | string | string[]>): string | number | string[] | undefined;
1
+ import type * as spec from '@galacean/effects-specification';
2
+ export declare function getBackgroundImage(template: spec.TemplateContent, variables?: spec.TemplateVariables): string | string[] | HTMLImageElement | HTMLImageElement[] | undefined;
3
3
  /**
4
4
  * @param url
5
5
  * @param template
@@ -7,4 +7,4 @@ export declare function getBackgroundImage(template: TemplateContent, variables?
7
7
  * @param options
8
8
  * @returns
9
9
  */
10
- export declare function combineImageTemplate(url: string | HTMLImageElement, template?: TemplateContent, variables?: Record<string, number | string>): Promise<HTMLImageElement>;
10
+ export declare function combineImageTemplate(url: string | HTMLImageElement, template?: spec.TemplateContent, variables?: spec.TemplateVariables): Promise<HTMLImageElement>;
@@ -82,3 +82,5 @@ export declare abstract class Texture extends EffectsObject {
82
82
  protected assembleOptions(options: TextureSourceOptions): TextureSourceOptions;
83
83
  }
84
84
  export declare function generateHalfFloatTexture(engine: Engine, data: Uint16Array, width: number, height: number): Texture;
85
+ export declare function generateWhiteTexture(engine: Engine): Texture;
86
+ export declare function generateTransparentTexture(engine: Engine): Texture;
@@ -148,7 +148,7 @@ export interface Texture2DSourceOptionsCompressed extends TextureOptionsBase {
148
148
  mipmaps: TextureDataType[];
149
149
  target?: WebGLRenderingContext['TEXTURE_2D'] | WebGLRenderingContext['TEXTURE_CUBE_MAP'];
150
150
  }
151
- export interface Texture2DSourceOptionsFrameBuffer extends TextureOptionsBase {
151
+ export interface Texture2DSourceOptionsFramebuffer extends TextureOptionsBase {
152
152
  sourceType: TextureSourceType.framebuffer;
153
153
  data?: {
154
154
  width: number;
@@ -160,6 +160,6 @@ export interface Texture2DSourceOptionsNone extends TextureOptionsBase {
160
160
  sourceType?: TextureSourceType.none;
161
161
  target?: GLenum;
162
162
  }
163
- export type Texture2DSourceOptions = Texture2DSourceOptionsImage | Texture2DSourceOptionsData | Texture2DSourceOptionsVideo | Texture2DSourceOptionsImageMipmaps | Texture2DSourceOptionsCompressed | Texture2DSourceOptionsFrameBuffer | Texture2DSourceOptionsNone;
163
+ export type Texture2DSourceOptions = Texture2DSourceOptionsImage | Texture2DSourceOptionsData | Texture2DSourceOptionsVideo | Texture2DSourceOptionsImageMipmaps | Texture2DSourceOptionsCompressed | Texture2DSourceOptionsFramebuffer | Texture2DSourceOptionsNone;
164
164
  export type TextureSourceOptions = Texture2DSourceOptions | TextureCubeSourceOptions;
165
165
  export {};
@@ -1,5 +1,6 @@
1
1
  import type * as spec from '@galacean/effects-specification';
2
2
  import type { Texture2DSourceOptions, TextureCubeSourceOptions } from './types';
3
+ import type { Engine } from '../engine';
3
4
  type TextureJSONOptions = spec.SerializedTextureSource & spec.TextureConfigOptionsBase & spec.TextureFormatOptions;
4
- export declare function deserializeMipmapTexture(texOpts: TextureJSONOptions, bins: ArrayBuffer[], files?: spec.BinaryFile[]): Promise<Texture2DSourceOptions | TextureCubeSourceOptions>;
5
+ export declare function deserializeMipmapTexture(textureOptions: TextureJSONOptions, bins: ArrayBuffer[], engine: Engine, files?: spec.BinaryFile[]): Promise<Texture2DSourceOptions | TextureCubeSourceOptions>;
5
6
  export {};
package/dist/ticker.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare class Ticker {
9
9
  private interval;
10
10
  private intervalId;
11
11
  private resetTickers;
12
- private _deltaTime;
12
+ private dt;
13
13
  constructor(fps?: number);
14
14
  /**
15
15
  * 获取定时器当前帧更新的时间
@@ -22,7 +22,7 @@ export declare class Ticker {
22
22
  setFPS(fps: number): void;
23
23
  /**
24
24
  * 获取定时器暂停标志位
25
- * @returns 暂停标志位
25
+ * @returns
26
26
  */
27
27
  getPaused(): boolean;
28
28
  /**
@@ -22,7 +22,7 @@ export declare class Transform implements Disposable {
22
22
  static getRotation(quat: Quaternion, out: Euler): Euler;
23
23
  engine: Engine;
24
24
  name: string;
25
- taggedProperties: Record<string, any>;
25
+ taggedProperties: spec.TransformData;
26
26
  /**
27
27
  * 自身位移
28
28
  */
@@ -223,8 +223,8 @@ export declare class Transform implements Disposable {
223
223
  * 获取 Transform 是否生效
224
224
  */
225
225
  getValid(): boolean;
226
- toData(): Record<string, any>;
227
- fromData(data: any): void;
226
+ toData(): spec.TransformData;
227
+ fromData(data: spec.TransformData): void;
228
228
  dispose(): void;
229
229
  private updateTRSCache;
230
230
  private dispatchValueChange;
@@ -16,4 +16,4 @@ export declare function removeItem<T>(arr: T[], value: T): T[];
16
16
  * @returns
17
17
  */
18
18
  export declare function addItemWithOrder<T extends Record<string, any>>(arr: T[], item: T, property: string, descending?: boolean): void;
19
- export declare function enlargeBuffer<T extends TypedArray>(typeArray: T, length: number, increase: number | undefined, maxSize: number): T;
19
+ export declare function enlargeBuffer<T extends TypedArray>(typeArray: T, length: number, maxSize: number, increase?: number): T;
@@ -1,4 +1,8 @@
1
1
  export declare function getPixelRatio(): number;
2
2
  export declare function isIOS(): boolean;
3
+ export declare function isIOSByUA(): number;
3
4
  export declare function isAndroid(): boolean;
4
5
  export declare function isSimulatorCellPhone(): boolean;
6
+ export declare function isMiniProgram(): boolean;
7
+ export declare function isAlipayMiniApp(): boolean;
8
+ export declare function isWechatMiniApp(): boolean;
@@ -4,11 +4,18 @@ export * from './device';
4
4
  export * from './image-data';
5
5
  export * from './sortable';
6
6
  export * from './asserts';
7
- export * from './timeline-component';
7
+ export * from './text';
8
8
  export * from './logger';
9
9
  export type Immutable<O> = O extends Record<any, any> ? {
10
10
  readonly [key in keyof O]: Immutable<O[key]>;
11
11
  } : O extends Array<infer X> ? ReadonlyArray<X> : O;
12
+ export type PickEnum<T, K extends T> = {
13
+ [P in keyof K]: P extends K ? P : never;
14
+ };
15
+ export interface Constructor<T = unknown> {
16
+ new (...args: any[]): T;
17
+ }
18
+ export type Nullable<T> = T | null;
12
19
  export declare enum DestroyOptions {
13
20
  destroy = 0,
14
21
  keep = 1,
@@ -32,17 +39,17 @@ export declare function noop(): void;
32
39
  *
33
40
  * @static
34
41
  * @function isString
35
- * @param {object} obj - 要判断的对象
36
- * @return {boolean}
42
+ * @param obj - 要判断的对象
43
+ * @return
37
44
  */
38
- export declare function isString(obj: any): obj is string;
45
+ export declare function isString(obj: unknown): obj is string;
39
46
  /**
40
47
  * 判断对象是否是`Array`类型
41
48
  *
42
49
  * @static
43
50
  * @function isArray
44
- * @param {object} obj - 要判断的对象
45
- * @return {boolean}
51
+ * @param obj - 要判断的对象
52
+ * @return
46
53
  */
47
54
  export declare const isArray: (arg: any) => arg is any[];
48
55
  /**
@@ -50,20 +57,28 @@ export declare const isArray: (arg: any) => arg is any[];
50
57
  *
51
58
  * @static
52
59
  * @function isFunction
53
- * @param {object} obj - 要判断的对象
54
- * @return {boolean}
60
+ * @param obj - 要判断的对象
61
+ * @return
55
62
  */
56
- export declare function isFunction(obj: any): boolean;
63
+ export declare function isFunction(obj: unknown): boolean;
57
64
  /**
58
65
  * 判断对象是否是`Object`类型
59
66
  *
60
67
  * @static
61
68
  * @function isObject
62
- * @param {object} obj - 要判断的对象
63
- * @return {boolean}
69
+ * @param obj - 要判断的对象
70
+ * @return
71
+ */
72
+ export declare function isObject(obj: unknown): obj is Record<string | symbol, unknown>;
73
+ export declare function isCanvas(canvas: HTMLCanvasElement): boolean;
74
+ /**
75
+ * 生成一个位于 min 和 max 之间的随机数
76
+ * @param min
77
+ * @param max
78
+ * @returns
64
79
  */
65
- export declare function isObject(obj: any): boolean;
66
- export declare function deepClone(obj: any): any;
67
- export declare function random(min: number, max: number): number;
80
+ export declare function randomInRange(min: number, max: number): number;
68
81
  export declare function throwDestroyedError(): void;
69
82
  export declare function generateGUID(): string;
83
+ export declare function base64ToFile(base64: string, filename?: string, contentType?: string): File;
84
+ export declare function applyMixins<T extends Constructor, K extends Constructor>(derivedCtrl: T, baseCtrls: K[]): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 判断是否为可解析的字体
3
+ * - 首字母不能为数字或 `.`
4
+ * - 不能包含特殊字符,`_-` 是被允许的
5
+ * @param fontFamily - 字体名称
6
+ * @returns
7
+ */
8
+ export declare function isValidFontFamily(fontFamily: string): boolean;
@@ -1,18 +1,18 @@
1
1
  import { Vector3 } from '@galacean/effects-math/es/core/vector3';
2
2
  import * as spec from '@galacean/effects-specification';
3
3
  import type { VFXItemData } from './asset-loader';
4
- import { RendererComponent } from './components';
5
- import type { Component } from './components/component';
6
- import { ItemBehaviour } from './components/component';
4
+ import type { Component } from './components';
5
+ import { RendererComponent, Behaviour } from './components';
7
6
  import type { Composition } from './composition';
8
7
  import { EffectsObject } from './effects-object';
9
8
  import type { Engine } from './engine';
10
- import type { BoundingBoxData, CameraController, HitTestBoxParams, HitTestCustomParams, HitTestSphereParams, HitTestTriangleParams, InteractComponent, ParticleSystem, SpriteComponent } from './plugins';
11
- import { TimelineComponent } from './plugins';
9
+ import type { BoundingBoxData, CameraController, HitTestBoxParams, HitTestCustomParams, HitTestSphereParams, HitTestTriangleParams, InteractComponent, SpriteComponent } from './plugins';
10
+ import { ParticleSystem } from './plugins';
12
11
  import { Transform } from './transform';
13
- import { type Disposable } from './utils';
14
- export type VFXItemContent = ParticleSystem | SpriteComponent | TimelineComponent | CameraController | InteractComponent | void | {};
15
- export type VFXItemConstructor = new (enigne: Engine, props: VFXItemProps, composition: Composition) => VFXItem<VFXItemContent>;
12
+ import type { Constructor, Disposable } from './utils';
13
+ import type { EventEmitterListener, EventEmitterOptions, ItemEvent } from './events';
14
+ export type VFXItemContent = ParticleSystem | SpriteComponent | CameraController | InteractComponent | undefined | {};
15
+ export type VFXItemConstructor = new (engine: Engine, props: VFXItemProps, composition: Composition) => VFXItem;
16
16
  export type VFXItemProps = spec.Item & {
17
17
  items: VFXItemProps[];
18
18
  startTime: number;
@@ -23,7 +23,7 @@ export type VFXItemProps = spec.Item & {
23
23
  /**
24
24
  * 所有元素的继承的抽象类
25
25
  */
26
- export declare class VFXItem<T extends VFXItemContent> extends EffectsObject implements Disposable {
26
+ export declare class VFXItem extends EffectsObject implements Disposable {
27
27
  /**
28
28
  * 元素绑定的父元素,
29
29
  * 1. 当元素没有绑定任何父元素时,parent为空,transform.parentTransform 为 composition.transform
@@ -31,8 +31,8 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
31
31
  * 3. 当元素绑定 TreeItem 的node时,parent为treeItem, transform.parentTransform 为 tree.nodes[i].transform(绑定的node节点上的transform)
32
32
  * 4. 当元素绑定 TreeItem 本身时,行为表现和绑定 nullItem 相同
33
33
  */
34
- parent?: VFXItem<VFXItemContent>;
35
- children: VFXItem<VFXItemContent>[];
34
+ parent?: VFXItem;
35
+ children: VFXItem[];
36
36
  /**
37
37
  * 元素的变换包含位置、旋转、缩放。
38
38
  */
@@ -45,10 +45,6 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
45
45
  * 元素动画的持续时间
46
46
  */
47
47
  duration: number;
48
- /**
49
- * 元素当前更新归一化时间,开始时为 0,结束时为 1
50
- */
51
- lifetime: number;
52
48
  /**
53
49
  * 父元素的 id
54
50
  */
@@ -60,15 +56,11 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
60
56
  /**
61
57
  * 元素动画结束时行为(如何处理元素)
62
58
  */
63
- endBehavior: spec.ItemEndBehavior | spec.ParentItemEndBehavior;
59
+ endBehavior: spec.EndBehavior;
64
60
  /**
65
61
  * 元素是否可用
66
62
  */
67
63
  ended: boolean;
68
- /**
69
- * 元素在合成中的索引
70
- */
71
- listIndex: number;
72
64
  /**
73
65
  * 元素名称
74
66
  */
@@ -77,23 +69,15 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
77
69
  * 元素 id 唯一
78
70
  */
79
71
  id: string;
80
- oldId: string;
81
72
  /**
82
73
  * 元素创建的数据图层/粒子/模型等
83
74
  */
84
- _content?: T;
85
- /**
86
- * 元素动画是否延迟播放
87
- */
88
- delaying: boolean;
89
- /**
90
- * 元素动画的速度
91
- */
75
+ _content?: VFXItemContent;
76
+ reusable: boolean;
92
77
  type: spec.ItemType;
93
- stopped: boolean;
94
78
  props: VFXItemProps;
95
79
  components: Component[];
96
- itemBehaviours: ItemBehaviour[];
80
+ itemBehaviours: Behaviour[];
97
81
  rendererComponents: RendererComponent[];
98
82
  /**
99
83
  * 元素可见性,该值的改变会触发 `handleVisibleChanged` 回调
@@ -101,31 +85,65 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
101
85
  */
102
86
  protected visible: boolean;
103
87
  /**
104
- * 是否允许渲染,元素生命周期开始后为 true,结束时为 false
105
- * @protected
88
+ * 元素动画的速度
106
89
  */
107
- protected _contentVisible: boolean;
108
90
  private speed;
109
- static isComposition(item: VFXItem<VFXItemContent>): item is VFXItem<void>;
110
- static isSprite(item: VFXItem<VFXItemContent>): item is VFXItem<SpriteComponent>;
111
- static isParticle(item: VFXItem<VFXItemContent>): item is VFXItem<ParticleSystem>;
112
- static isNull(item: VFXItem<VFXItemContent>): item is VFXItem<void>;
113
- static isTree(item: VFXItem<VFXItemContent>): item is VFXItem<void>;
114
- static isCamera(item: VFXItem<VFXItemContent>): item is VFXItem<void>;
115
- static isExtraCamera(item: VFXItem<VFXItemContent>): item is VFXItem<CameraController>;
91
+ private listIndex;
92
+ private eventProcessor;
93
+ static isComposition(item: VFXItem): boolean;
94
+ static isSprite(item: VFXItem): boolean;
95
+ static isParticle(item: VFXItem): boolean;
96
+ static isNull(item: VFXItem): boolean;
97
+ static isTree(item: VFXItem): boolean;
98
+ static isCamera(item: VFXItem): boolean;
99
+ static isExtraCamera(item: VFXItem): boolean;
116
100
  constructor(engine: Engine, props?: VFXItemProps);
117
101
  /**
118
102
  * 返回元素创建的数据
119
103
  */
120
- get content(): T;
104
+ get content(): VFXItemContent;
121
105
  /**
122
106
  * 播放完成后是否需要再使用,是的话生命周期结束后不会 dispose
123
107
  */
124
- get reusable(): boolean;
108
+ get compositionReusable(): boolean;
125
109
  /**
126
- * 获取元素生命周期是否开始
110
+ * 元素在合成中的索引
127
111
  */
128
- get lifetimeStarted(): boolean;
112
+ get renderOrder(): number;
113
+ set renderOrder(value: number);
114
+ /**
115
+ * 元素监听事件
116
+ * @param eventName - 事件名称
117
+ * @param listener - 事件监听器
118
+ * @param options - 事件监听器选项
119
+ * @returns
120
+ */
121
+ on<E extends keyof ItemEvent>(eventName: E, listener: EventEmitterListener<ItemEvent[E]>, options?: EventEmitterOptions): void;
122
+ /**
123
+ * 移除事件监听器
124
+ * @param eventName - 事件名称
125
+ * @param listener - 事件监听器
126
+ * @returns
127
+ */
128
+ off<E extends keyof ItemEvent>(eventName: E, listener: EventEmitterListener<ItemEvent[E]>): void;
129
+ /**
130
+ * 一次性监听事件
131
+ * @param eventName - 事件名称
132
+ * @param listener - 事件监听器
133
+ */
134
+ once<E extends keyof ItemEvent>(eventName: E, listener: EventEmitterListener<ItemEvent[E]>): void;
135
+ /**
136
+ * 触发事件
137
+ * @param eventName - 事件名称
138
+ * @param args - 事件参数
139
+ */
140
+ emit<E extends keyof ItemEvent>(eventName: E, ...args: ItemEvent[E]): void;
141
+ /**
142
+ * 获取事件名称对应的所有监听器
143
+ * @param eventName - 事件名称
144
+ * @returns - 返回事件名称对应的所有监听器
145
+ */
146
+ getListeners<E extends keyof ItemEvent>(eventName: E): EventEmitterListener<ItemEvent[E]>[];
129
147
  /**
130
148
  * 设置元素的动画速度
131
149
  * @param speed - 速度
@@ -140,24 +158,20 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
140
158
  * 添加组件
141
159
  * @param classConstructor - 要添加的组件类型
142
160
  */
143
- addComponent<T extends Component>(classConstructor: new (engine: Engine) => T): T;
161
+ addComponent<T extends Component>(classConstructor: Constructor<T>): T;
144
162
  /**
145
163
  * 获取某一类型的组件。如果当前元素绑定了多个同类型的组件只返回第一个
146
164
  * @param classConstructor - 要获取的组件类型
147
165
  * @returns 查询结果中符合类型的第一个组件
148
166
  */
149
- getComponent<T extends Component>(classConstructor: new (engine: Engine) => T): T | undefined;
167
+ getComponent<T extends Component>(classConstructor: Constructor<T>): T;
150
168
  /**
151
169
  * 获取某一类型的所有组件
152
170
  * @param classConstructor - 要获取的组件
153
171
  * @returns 一个组件列表,包含所有符合类型的组件
154
172
  */
155
- getComponents<T extends Component>(classConstructor: new (engine: Engine) => T): T[];
156
- setParent(vfxItem: VFXItem<VFXItemContent>): void;
157
- /**
158
- * 停止播放元素动画
159
- */
160
- stop(): void;
173
+ getComponents<T extends Component>(classConstructor: Constructor<T>): T[];
174
+ setParent(vfxItem: VFXItem): void;
161
175
  /**
162
176
  * 元素动画结束播放时回调函数
163
177
  * @override
@@ -210,7 +224,12 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
210
224
  */
211
225
  scale(x: number, y: number, z: number): void;
212
226
  /**
213
- * 设置元素的在画布上的像素位置, 坐标原点在 canvas 中心,x 正方向水平向右, y 正方向垂直向下
227
+ * 设置元素在画布上的像素位置
228
+ * Tips:
229
+ * - 坐标原点在 canvas 左上角,x 正方向水平向右, y 正方向垂直向下
230
+ * - 设置后会覆盖原有的位置信息
231
+ * @param x - x 坐标
232
+ * @param y - y 坐标
214
233
  */
215
234
  setPositionByPixel(x: number, y: number): void;
216
235
  /**
@@ -233,7 +252,7 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
233
252
  /**
234
253
  * 获取元素用于计算光线投射的面片类型和参数
235
254
  * @override
236
- * @param force 元素没有开启交互也返回参数
255
+ * @param force - 元素没有开启交互也返回参数
237
256
  */
238
257
  getHitTestParams(force?: boolean): void | HitTestBoxParams | HitTestTriangleParams | HitTestSphereParams | HitTestCustomParams;
239
258
  /**
@@ -246,7 +265,7 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
246
265
  * @returns
247
266
  */
248
267
  isEnded(now: number): boolean;
249
- find(name: string): VFXItem<VFXItemContent> | undefined;
268
+ find(name: string): VFXItem | undefined;
250
269
  fromData(data: VFXItemData): void;
251
270
  toData(): void;
252
271
  translateByPixel(x: number, y: number): void;
@@ -262,9 +281,3 @@ export declare namespace Item {
262
281
  function isParticle(item: spec.Item): item is spec.ParticleItem;
263
282
  function isNull(item: spec.Item): item is spec.NullItem;
264
283
  }
265
- /**
266
- * (待废弃) 根据元素的类型创建对应的 `VFXItem` 实例
267
- * @param props
268
- * @param composition
269
- */
270
- export declare function createVFXItem(props: VFXItemProps, composition: Composition): VFXItem<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/effects-core",
3
- "version": "2.0.0-alpha.9",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Galacean Effects runtime core for the web",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -42,15 +42,17 @@
42
42
  "registry": "https://registry.npmjs.org"
43
43
  },
44
44
  "dependencies": {
45
- "@galacean/effects-specification": "2.0.0-alpha.8",
46
- "@galacean/effects-math": "1.1.0-alpha.0",
45
+ "@galacean/effects-specification": "2.0.0-beta.0",
46
+ "@galacean/effects-math": "1.1.0",
47
+ "flatbuffers": "24.3.25",
47
48
  "uuid": "9.0.1"
48
49
  },
49
50
  "scripts": {
50
51
  "prebuild": "pnpm clean",
51
- "build": "pnpm build:declaration && pnpm build:module",
52
+ "build": "pnpm build:fbs && pnpm build:declaration && pnpm build:module",
53
+ "build:fbs": "node ../../scripts/flatc ./src/__definations__/index.fbs",
52
54
  "build:module": "rollup -c",
53
55
  "build:declaration": "tsc -d --emitDeclarationOnly",
54
- "clean": "rimraf dist && rimraf '*+(.tsbuildinfo)'"
56
+ "clean": "rimraf dist && rimraf \"*+(.tsbuildinfo)\""
55
57
  }
56
58
  }
@@ -1,5 +0,0 @@
1
- import type * as spec from '@galacean/effects-specification';
2
- /**
3
- * 提取并转换 JSON 数据中的 anchor 值
4
- */
5
- export declare function convertAnchor(anchor?: spec.vec2, particleOrigin?: spec.ParticleOrigin): spec.vec2;
@@ -1,4 +0,0 @@
1
- import { AnimationPlayable } from './animation-playable';
2
- export declare class AnimationMixerPlayable extends AnimationPlayable {
3
- processFrame(dt: number): void;
4
- }
@@ -1,4 +0,0 @@
1
- import { PlayableOutput } from './playable-graph';
2
- export declare class AnimationPlayableOutput extends PlayableOutput {
3
- processFrame(dt: number): void;
4
- }
@@ -1,34 +0,0 @@
1
- import type { VFXItem, VFXItemContent } from '../../vfx-item';
2
- import { Playable, PlayableAsset, PlayableOutput } from './playable-graph';
3
- /**
4
- * @since 2.0.0
5
- * @internal
6
- */
7
- export declare class Track extends PlayableAsset {
8
- id: string;
9
- name: string;
10
- bindingItem: VFXItem<VFXItemContent>;
11
- private clips;
12
- private clipSeed;
13
- createOutput(): PlayableOutput;
14
- /**
15
- * 重写该方法以创建自定义混合器
16
- */
17
- createMixerPlayable(): Playable;
18
- createPlayable(): Playable;
19
- createClip<T extends Playable>(classConstructor: new () => T, name?: string): TimelineClip;
20
- getClips(): TimelineClip[];
21
- findClip(name: string): TimelineClip | undefined;
22
- private addClip;
23
- }
24
- /**
25
- * @since 2.0.0
26
- * @internal
27
- */
28
- export declare class TimelineClip {
29
- id: string;
30
- name: string;
31
- start: number;
32
- duration: number;
33
- playable: Playable;
34
- }
@@ -1,6 +0,0 @@
1
- import type * as spec from '@galacean/effects-specification';
2
- export interface TimelineComponentOptions {
3
- sizeOverLifetime?: spec.SizeOverLifetime;
4
- rotationOverLifetime?: spec.RotationOverLifetime;
5
- positionOverLifetime?: spec.PositionOverLifetime;
6
- }