@galacean/effects-core 2.0.0-alpha.3 → 2.0.0-alpha.31

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 (122) hide show
  1. package/dist/__definations__/fbeffects-object-data.d.ts +28 -0
  2. package/dist/__definations__/fbeffects-package-data.d.ts +26 -0
  3. package/dist/__definations__/fbgeometry-data.d.ts +77 -0
  4. package/dist/__definations__/fbsub-mesh.d.ts +26 -0
  5. package/dist/__definations__/fbvertex-channel.d.ts +33 -0
  6. package/dist/__definations__/fbvertex-data.d.ts +27 -0
  7. package/dist/__definations__/index.d.ts +6 -0
  8. package/dist/asset-loader.d.ts +8 -90
  9. package/dist/asset-manager.d.ts +1 -80
  10. package/dist/binary-asset.d.ts +6 -0
  11. package/dist/camera.d.ts +10 -1
  12. package/dist/canvas-pool.d.ts +10 -0
  13. package/dist/comp-vfx-item.d.ts +24 -10
  14. package/dist/components/component.d.ts +5 -5
  15. package/dist/components/effect-component.d.ts +1 -1
  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 +1 -1
  19. package/dist/composition-source-manager.d.ts +8 -7
  20. package/dist/composition.d.ts +70 -40
  21. package/dist/constants.d.ts +1 -2
  22. package/dist/decorators.d.ts +4 -3
  23. package/dist/downloader.d.ts +11 -8
  24. package/dist/effects-object.d.ts +3 -2
  25. package/dist/effects-package.d.ts +19 -0
  26. package/dist/engine.d.ts +11 -7
  27. package/dist/fallback/camera.d.ts +2 -0
  28. package/dist/fallback/index.d.ts +12 -0
  29. package/dist/fallback/interact.d.ts +2 -0
  30. package/dist/fallback/migration.d.ts +20 -0
  31. package/dist/fallback/particle.d.ts +2 -0
  32. package/dist/fallback/sprite.d.ts +3 -0
  33. package/dist/fallback/utils.d.ts +25 -0
  34. package/dist/gl/create-gl-context.d.ts +2 -1
  35. package/dist/gl/index.d.ts +3 -0
  36. package/dist/image-asset.d.ts +5 -0
  37. package/dist/index.d.ts +8 -4
  38. package/dist/index.js +21140 -19641
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +21563 -20062
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/material/material.d.ts +19 -5
  43. package/dist/material/types.d.ts +0 -5
  44. package/dist/material/utils.d.ts +4 -4
  45. package/dist/math/bezier.d.ts +99 -0
  46. package/dist/math/keyframe-info.d.ts +39 -0
  47. package/dist/math/translate.d.ts +3 -2
  48. package/dist/math/utils.d.ts +6 -2
  49. package/dist/math/value-getter.d.ts +52 -26
  50. package/dist/pass-render-level.d.ts +3 -1
  51. package/dist/plugin-system.d.ts +3 -4
  52. package/dist/plugins/cal/animation-playable.d.ts +2 -1
  53. package/dist/plugins/cal/calculate-item.d.ts +5 -39
  54. package/dist/plugins/cal/calculate-vfx-item.d.ts +54 -13
  55. package/dist/plugins/cal/playable-graph.d.ts +72 -21
  56. package/dist/plugins/cal/timeline-asset.d.ts +27 -0
  57. package/dist/plugins/camera/camera-controller-node.d.ts +1 -12
  58. package/dist/plugins/index.d.ts +8 -3
  59. package/dist/plugins/interact/click-handler.d.ts +3 -3
  60. package/dist/plugins/interact/event-system.d.ts +0 -2
  61. package/dist/plugins/interact/interact-item.d.ts +15 -1
  62. package/dist/plugins/interact/interact-mesh.d.ts +1 -1
  63. package/dist/plugins/particle/particle-loader.d.ts +1 -1
  64. package/dist/plugins/particle/particle-mesh.d.ts +7 -7
  65. package/dist/plugins/particle/particle-system-renderer.d.ts +1 -1
  66. package/dist/plugins/particle/particle-system.d.ts +5 -3
  67. package/dist/plugins/particle/particle-vfx-item.d.ts +8 -3
  68. package/dist/plugins/particle/trail-mesh.d.ts +7 -7
  69. package/dist/plugins/plugin.d.ts +7 -8
  70. package/dist/plugins/sprite/sprite-item.d.ts +29 -15
  71. package/dist/plugins/sprite/sprite-mesh.d.ts +0 -4
  72. package/dist/plugins/text/index.d.ts +4 -0
  73. package/dist/plugins/text/text-item.d.ts +33 -5
  74. package/dist/plugins/text/text-layout.d.ts +9 -1
  75. package/dist/plugins/timeline/playables/activation-mixer-playable.d.ts +7 -0
  76. package/dist/plugins/timeline/playables/sub-composition-clip-playable.d.ts +5 -0
  77. package/dist/plugins/timeline/playables/sub-composition-playable-asset.d.ts +5 -0
  78. package/dist/plugins/timeline/track.d.ts +72 -0
  79. package/dist/plugins/timeline/tracks/activation-track.d.ts +5 -0
  80. package/dist/plugins/timeline/tracks/sprite-color-track.d.ts +3 -0
  81. package/dist/plugins/timeline/tracks/sub-composition-track.d.ts +4 -0
  82. package/dist/plugins/timeline/tracks/transform-track.d.ts +3 -0
  83. package/dist/render/create-copy-shader.d.ts +1 -1
  84. package/dist/render/{frame-buffer.d.ts → framebuffer.d.ts} +7 -7
  85. package/dist/render/geometry.d.ts +14 -1
  86. package/dist/render/global-volume.d.ts +7 -5
  87. package/dist/render/gpu-capability.d.ts +6 -6
  88. package/dist/render/index.d.ts +3 -2
  89. package/dist/render/render-frame.d.ts +12 -12
  90. package/dist/render/render-pass.d.ts +10 -10
  91. package/dist/render/{render-buffer.d.ts → renderbuffer.d.ts} +4 -4
  92. package/dist/render/renderer.d.ts +7 -6
  93. package/dist/render/semantic-map.d.ts +14 -0
  94. package/dist/render/shader.d.ts +12 -5
  95. package/dist/scene.d.ts +86 -4
  96. package/dist/serialization-helper.d.ts +6 -4
  97. package/dist/shader/index.d.ts +0 -11
  98. package/dist/shape/shape.d.ts +1 -1
  99. package/dist/shape/sphere.d.ts +0 -3
  100. package/dist/template-image.d.ts +10 -0
  101. package/dist/texture/texture.d.ts +8 -0
  102. package/dist/texture/types.d.ts +2 -2
  103. package/dist/texture/utils.d.ts +2 -1
  104. package/dist/ticker.d.ts +2 -2
  105. package/dist/transform.d.ts +3 -3
  106. package/dist/utils/array.d.ts +1 -1
  107. package/dist/utils/device.d.ts +4 -0
  108. package/dist/utils/index.d.ts +29 -14
  109. package/dist/utils/text.d.ts +8 -0
  110. package/dist/vfx-item.d.ts +37 -61
  111. package/package.json +8 -6
  112. package/dist/asset-migrations.d.ts +0 -7
  113. package/dist/plugins/cal/animation-mixer-playable.d.ts +0 -4
  114. package/dist/plugins/cal/animation-playable-output.d.ts +0 -4
  115. package/dist/plugins/cal/track.d.ts +0 -34
  116. package/dist/semantic-map.d.ts +0 -14
  117. package/dist/template-image/index.d.ts +0 -67
  118. package/dist/template-image/qcanvas-viewer.d.ts +0 -21
  119. package/dist/template-image/qtext.d.ts +0 -96
  120. package/dist/template-image/template-v1.d.ts +0 -27
  121. package/dist/template-image/text-metrics.d.ts +0 -18
  122. package/dist/utils/timeline-component.d.ts +0 -6
@@ -1,13 +1,15 @@
1
+ import type * as spec from '@galacean/effects-specification';
1
2
  import { EffectsObject } from './effects-object';
2
3
  export declare class SerializationHelper {
3
4
  static collectSerializableObject(effectsObject: EffectsObject, res: Record<string, EffectsObject>): void;
4
5
  static serializeEffectObject(effectsObject: EffectsObject): Record<string, any>;
5
6
  static serializeTaggedProperties(effectsObject: EffectsObject, serializedData?: Record<string, any>): Record<string, any>;
6
- static deserializeTaggedProperties(serializedData: Record<string, any>, effectsObject: EffectsObject): void;
7
- static deserializeTaggedPropertiesAsync(serializedData: Record<string, any>, effectsObject: EffectsObject): Promise<void>;
8
- static checkTypedArray(obj: any): boolean;
9
- static checkDataPath(value: any): boolean;
7
+ static deserializeTaggedProperties(serializedData: spec.EffectsObjectData, effectsObject: EffectsObject): void;
8
+ static deserializeTaggedPropertiesAsync(serializedData: spec.EffectsObjectData, effectsObject: EffectsObject): Promise<void>;
9
+ static checkTypedArray(obj: unknown): boolean;
10
+ static checkDataPath(value: unknown): value is spec.DataPath;
10
11
  static checkGLTFNode(value: any): boolean;
12
+ static checkImageSource(value: HTMLCanvasElement): boolean;
11
13
  private static deserializeProperty;
12
14
  private static deserializePropertyAsync;
13
15
  private static serializeObjectProperty;
@@ -4,23 +4,12 @@ export { default as compatibleVert } from './compatible.vert.glsl';
4
4
  export { default as itemFrameFrag } from './item-frame.frag.glsl';
5
5
  export { default as integrate } from './integrate.glsl';
6
6
  export { default as itemVert } from './item.vert.glsl';
7
- export { default as itemDefine } from './item.define.glsl';
8
7
  export { default as itemFrag } from './item.frag.glsl';
9
8
  export { default as particleFrag } from './particle.frag.glsl';
10
9
  export { default as particleVert } from './particle.vert.glsl';
11
10
  export { default as trailVert } from './trail.vert.glsl';
12
11
  export { default as value } from './value.glsl';
13
12
  export { default as valueDefine } from './value-define.glsl';
14
- export { default as copyFrag } from './adjust/copy.frag.glsl';
15
- export { default as alphaFrameFrag } from './adjust/alpha-frame.frag.glsl';
16
- export { default as alphaMaskFrag } from './adjust/alpha-mask.frag.glsl';
17
- export { default as cameraMoveFrag } from './adjust/camera-move.frag.glsl';
18
- export { default as cameraMoveVert } from './adjust/camera-move.vert.glsl';
19
- export { default as delayFrag } from './adjust/delay.frag.glsl';
20
- export { default as distortionFrag } from './adjust/distortion.frag.glsl';
21
- export { default as distortionVert } from './adjust/distortion.vert.glsl';
22
- export { default as bloomMixVert } from './adjust/bloom-mix.frag.glsl';
23
- export { default as bloomThresholdVert } from './adjust/bloom-threshold.frag.glsl';
24
13
  export { default as screenMeshVert } from './post-processing/screen-mesh.vert.glsl';
25
14
  export { default as colorGradingFrag } from './post-processing/color-grading.frag.glsl';
26
15
  export { default as gaussianDownFrag } from './post-processing/gaussian-down.frag.glsl';
@@ -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;
@@ -8,8 +8,5 @@ export declare class Sphere implements Shape {
8
8
  generate(opt: ShapeGeneratorOptions): ShapeParticle;
9
9
  }
10
10
  export declare class Hemisphere extends Sphere {
11
- arc: number;
12
- radius: number;
13
- arcMode: number;
14
11
  getHorizontalAngle(): number;
15
12
  }
@@ -0,0 +1,10 @@
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
+ /**
4
+ * @param url
5
+ * @param template
6
+ * @param variables
7
+ * @param options
8
+ * @returns
9
+ */
10
+ export declare function combineImageTemplate(url: string | HTMLImageElement, template?: spec.TemplateContent, variables?: spec.TemplateVariables): Promise<HTMLImageElement>;
@@ -31,6 +31,12 @@ export declare abstract class Texture extends EffectsObject {
31
31
  * 创建一个新的 Texture 对象。
32
32
  */
33
33
  static create: (engine: Engine, options?: TextureSourceOptions) => Texture;
34
+ /**
35
+ * 通过 URL 创建 Texture 对象。
36
+ * @param url - 要创建的 Texture URL
37
+ * @since 2.0.0
38
+ */
39
+ static fromImage(url: string, engine: Engine): Promise<Texture>;
34
40
  /**
35
41
  * 通过数据创建 Texture 对象。
36
42
  * @param data - 要创建的 Texture 数据
@@ -76,3 +82,5 @@ export declare abstract class Texture extends EffectsObject {
76
82
  protected assembleOptions(options: TextureSourceOptions): TextureSourceOptions;
77
83
  }
78
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,15 @@
1
1
  import { Vector3 } from '@galacean/effects-math/es/core/vector3';
2
2
  import * as spec from '@galacean/effects-specification';
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';
3
+ import type { VFXItemData } from './asset-loader';
4
+ import type { Component, RendererComponent, ItemBehaviour } from './components';
7
5
  import type { Composition } from './composition';
8
6
  import { EffectsObject } from './effects-object';
9
7
  import type { Engine } from './engine';
10
8
  import type { BoundingBoxData, CameraController, HitTestBoxParams, HitTestCustomParams, HitTestSphereParams, HitTestTriangleParams, InteractComponent, ParticleSystem, SpriteComponent } from './plugins';
11
- import { TimelineComponent } from './plugins';
12
9
  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>;
10
+ import type { Constructor, Disposable } from './utils';
11
+ export type VFXItemContent = ParticleSystem | SpriteComponent | CameraController | InteractComponent | undefined | {};
12
+ export type VFXItemConstructor = new (engine: Engine, props: VFXItemProps, composition: Composition) => VFXItem;
16
13
  export type VFXItemProps = spec.Item & {
17
14
  items: VFXItemProps[];
18
15
  startTime: number;
@@ -23,7 +20,7 @@ export type VFXItemProps = spec.Item & {
23
20
  /**
24
21
  * 所有元素的继承的抽象类
25
22
  */
26
- export declare class VFXItem<T extends VFXItemContent> extends EffectsObject implements Disposable {
23
+ export declare class VFXItem extends EffectsObject implements Disposable {
27
24
  /**
28
25
  * 元素绑定的父元素,
29
26
  * 1. 当元素没有绑定任何父元素时,parent为空,transform.parentTransform 为 composition.transform
@@ -31,8 +28,8 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
31
28
  * 3. 当元素绑定 TreeItem 的node时,parent为treeItem, transform.parentTransform 为 tree.nodes[i].transform(绑定的node节点上的transform)
32
29
  * 4. 当元素绑定 TreeItem 本身时,行为表现和绑定 nullItem 相同
33
30
  */
34
- parent?: VFXItem<VFXItemContent>;
35
- children: VFXItem<VFXItemContent>[];
31
+ parent?: VFXItem;
32
+ children: VFXItem[];
36
33
  /**
37
34
  * 元素的变换包含位置、旋转、缩放。
38
35
  */
@@ -45,10 +42,6 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
45
42
  * 元素动画的持续时间
46
43
  */
47
44
  duration: number;
48
- /**
49
- * 元素当前更新归一化时间,开始时为 0,结束时为 1
50
- */
51
- lifetime: number;
52
45
  /**
53
46
  * 父元素的 id
54
47
  */
@@ -60,15 +53,11 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
60
53
  /**
61
54
  * 元素动画结束时行为(如何处理元素)
62
55
  */
63
- endBehavior: spec.ItemEndBehavior | spec.ParentItemEndBehavior;
56
+ endBehavior: spec.EndBehavior | spec.ParentItemEndBehavior;
64
57
  /**
65
58
  * 元素是否可用
66
59
  */
67
60
  ended: boolean;
68
- /**
69
- * 元素在合成中的索引
70
- */
71
- listIndex: number;
72
61
  /**
73
62
  * 元素名称
74
63
  */
@@ -81,16 +70,9 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
81
70
  /**
82
71
  * 元素创建的数据图层/粒子/模型等
83
72
  */
84
- _content?: T;
85
- /**
86
- * 元素动画是否延迟播放
87
- */
88
- delaying: boolean;
89
- /**
90
- * 元素动画的速度
91
- */
73
+ _content?: VFXItemContent;
74
+ reusable: boolean;
92
75
  type: spec.ItemType;
93
- stopped: boolean;
94
76
  props: VFXItemProps;
95
77
  components: Component[];
96
78
  itemBehaviours: ItemBehaviour[];
@@ -101,31 +83,31 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
101
83
  */
102
84
  protected visible: boolean;
103
85
  /**
104
- * 是否允许渲染,元素生命周期开始后为 true,结束时为 false
105
- * @protected
86
+ * 元素动画的速度
106
87
  */
107
- protected _contentVisible: boolean;
108
88
  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>;
89
+ private listIndex;
90
+ static isComposition(item: VFXItem): boolean;
91
+ static isSprite(item: VFXItem): boolean;
92
+ static isParticle(item: VFXItem): boolean;
93
+ static isNull(item: VFXItem): boolean;
94
+ static isTree(item: VFXItem): boolean;
95
+ static isCamera(item: VFXItem): boolean;
96
+ static isExtraCamera(item: VFXItem): boolean;
116
97
  constructor(engine: Engine, props?: VFXItemProps);
117
98
  /**
118
99
  * 返回元素创建的数据
119
100
  */
120
- get content(): T;
101
+ get content(): VFXItemContent;
121
102
  /**
122
103
  * 播放完成后是否需要再使用,是的话生命周期结束后不会 dispose
123
104
  */
124
- get reusable(): boolean;
105
+ get compositionReusable(): boolean;
125
106
  /**
126
- * 获取元素生命周期是否开始
107
+ * 元素在合成中的索引
127
108
  */
128
- get lifetimeStarted(): boolean;
109
+ get renderOrder(): number;
110
+ set renderOrder(value: number);
129
111
  /**
130
112
  * 设置元素的动画速度
131
113
  * @param speed - 速度
@@ -140,24 +122,20 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
140
122
  * 添加组件
141
123
  * @param classConstructor - 要添加的组件类型
142
124
  */
143
- addComponent<T extends Component>(classConstructor: new (engine: Engine) => T): T;
125
+ addComponent<T extends Component>(classConstructor: Constructor<T>): T;
144
126
  /**
145
127
  * 获取某一类型的组件。如果当前元素绑定了多个同类型的组件只返回第一个
146
128
  * @param classConstructor - 要获取的组件类型
147
129
  * @returns 查询结果中符合类型的第一个组件
148
130
  */
149
- getComponent<T extends Component>(classConstructor: new (engine: Engine) => T): T | undefined;
131
+ getComponent<T extends Component>(classConstructor: Constructor<T>): T;
150
132
  /**
151
133
  * 获取某一类型的所有组件
152
134
  * @param classConstructor - 要获取的组件
153
135
  * @returns 一个组件列表,包含所有符合类型的组件
154
136
  */
155
- getComponents<T extends Component>(classConstructor: new (engine: Engine) => T): T[];
156
- setParent(vfxItem: VFXItem<VFXItemContent>): void;
157
- /**
158
- * 停止播放元素动画
159
- */
160
- stop(): void;
137
+ getComponents<T extends Component>(classConstructor: Constructor<T>): T[];
138
+ setParent(vfxItem: VFXItem): void;
161
139
  /**
162
140
  * 元素动画结束播放时回调函数
163
141
  * @override
@@ -210,7 +188,12 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
210
188
  */
211
189
  scale(x: number, y: number, z: number): void;
212
190
  /**
213
- * 设置元素的在画布上的像素位置, 坐标原点在 canvas 中心,x 正方向水平向右, y 正方向垂直向下
191
+ * 设置元素在画布上的像素位置
192
+ * Tips:
193
+ * - 坐标原点在 canvas 左上角,x 正方向水平向右, y 正方向垂直向下
194
+ * - 设置后会覆盖原有的位置信息
195
+ * @param x - x 坐标
196
+ * @param y - y 坐标
214
197
  */
215
198
  setPositionByPixel(x: number, y: number): void;
216
199
  /**
@@ -233,7 +216,7 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
233
216
  /**
234
217
  * 获取元素用于计算光线投射的面片类型和参数
235
218
  * @override
236
- * @param force 元素没有开启交互也返回参数
219
+ * @param force - 元素没有开启交互也返回参数
237
220
  */
238
221
  getHitTestParams(force?: boolean): void | HitTestBoxParams | HitTestTriangleParams | HitTestSphereParams | HitTestCustomParams;
239
222
  /**
@@ -246,7 +229,7 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
246
229
  * @returns
247
230
  */
248
231
  isEnded(now: number): boolean;
249
- find(name: string): VFXItem<VFXItemContent> | undefined;
232
+ find(name: string): VFXItem | undefined;
250
233
  fromData(data: VFXItemData): void;
251
234
  toData(): void;
252
235
  translateByPixel(x: number, y: number): void;
@@ -258,14 +241,7 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
258
241
  }
259
242
  export declare namespace Item {
260
243
  function is<T extends spec.Item>(item: spec.Item, type: spec.ItemType): item is T;
261
- function isFilter(item: spec.Item): item is spec.FilterItem;
262
244
  function isComposition(item: spec.Item): item is spec.CompositionItem;
263
245
  function isParticle(item: spec.Item): item is spec.ParticleItem;
264
246
  function isNull(item: spec.Item): item is spec.NullItem;
265
247
  }
266
- /**
267
- * (待废弃) 根据元素的类型创建对应的 `VFXItem` 实例
268
- * @param props
269
- * @param composition
270
- */
271
- 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.3",
3
+ "version": "2.0.0-alpha.31",
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": "1.0.1",
46
- "@galacean/effects-math": "1.0.1",
45
+ "@galacean/effects-specification": "2.0.0-alpha.23",
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
- "build:declaration": "tsc -d --declarationDir dist --emitDeclarationOnly",
54
- "clean": "rimraf dist && rimraf '*+(.tsbuildinfo)'"
55
+ "build:declaration": "tsc -d --emitDeclarationOnly",
56
+ "clean": "rimraf dist && rimraf \"*+(.tsbuildinfo)\""
55
57
  }
56
58
  }
@@ -1,7 +0,0 @@
1
- import * as spec from '@galacean/effects-specification';
2
- import type { Scene } from './scene';
3
- export declare function version3Migration(scene: Record<string, any>): Scene;
4
- /**
5
- * 提取并转换 JSON 数据中的 anchor 值
6
- */
7
- 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,14 +0,0 @@
1
- import type { UniformValue } from './material';
2
- import type { RenderingData } from './render';
3
- import type { Disposable } from './utils';
4
- export type SemanticFunc = (state: RenderingData) => UniformValue | undefined;
5
- export type SemanticGetter = UniformValue | SemanticFunc;
6
- export declare class SemanticMap implements Disposable {
7
- readonly semantics: Record<string, SemanticGetter>;
8
- constructor(semantics?: Record<string, SemanticGetter>);
9
- toObject(): Record<string, SemanticGetter>;
10
- setSemantic(name: string, value?: SemanticGetter): void;
11
- getSemanticValue(name: string, state: RenderingData): number | Float32Array | Int32Array | Float64Array | Uint8Array | Uint32Array | Uint16Array | Int8Array | Int16Array | number[] | number[][] | import("@galacean/effects-math/es/core").Vector3 | import("./texture").Texture | import("@galacean/effects-math/es/core").Vector2 | import("@galacean/effects-math/es/core").Vector4 | import("@galacean/effects-math/es/core").Matrix3 | import("@galacean/effects-math/es/core").Matrix4 | import("./texture").Texture[] | import("./material").UniformStruct | import("./material").UniformStruct[] | SemanticFunc | undefined;
12
- hasSemanticValue(name: string): boolean;
13
- dispose(): void;
14
- }
@@ -1,67 +0,0 @@
1
- import type { TemplateContentV1, TemplateContentV2 } from '@galacean/effects-specification';
2
- export * from './qcanvas-viewer';
3
- export * from './qtext';
4
- export * from './template-v1';
5
- export declare const DEFAULT_FONTS: string[];
6
- export interface TextLayout {
7
- x: number;
8
- y: number;
9
- width: number;
10
- height: number;
11
- }
12
- export interface TemplateOptions {
13
- templateScale?: number;
14
- canvas?: HTMLCanvasElement;
15
- textLayouts?: TextLayout[];
16
- debug?: boolean;
17
- borderColor?: string;
18
- borderWidth?: number;
19
- flipY?: boolean;
20
- scaleX?: number;
21
- scaleY?: number;
22
- toData?: boolean;
23
- }
24
- declare class CanvasPool {
25
- readonly elements: HTMLCanvasElement[];
26
- constructor();
27
- dispose(): void;
28
- getCanvas(): HTMLCanvasElement;
29
- saveCanvas(cvs: HTMLCanvasElement): void;
30
- }
31
- export declare const canvasPool: CanvasPool;
32
- export declare function getDefaultTemplateCanvasPool(): CanvasPool;
33
- export declare function getBackgroundImage(template: TemplateContentV2, variables?: Record<string, number | string | string[]>): string | number | string[] | undefined;
34
- /**
35
- * @param {string|HTMLImageElement} url
36
- * @param {TemplateContentV2} [template]
37
- * @param {Record<string, number | string>} [variables]
38
- * @param {TemplateOptions} [opts]
39
- * @param {boolean} [flipY]
40
- * @returns
41
- */
42
- export declare function combineImageTemplate2(url: string | HTMLImageElement, template?: TemplateContentV2, variables?: Record<string, number | string>, opts?: TemplateOptions, flipY?: boolean): Promise<HTMLCanvasElement>;
43
- /**
44
- * @internal
45
- * @deprecated since 2.0.0 - use `combineImageTemplate2` instead
46
- */
47
- export declare function combineImageTemplate2Async(url: string | HTMLImageElement, template?: TemplateContentV2, variables?: Record<string, number | string>, opts?: TemplateOptions, flipY?: boolean): Promise<HTMLCanvasElement | ImageData>;
48
- /**
49
- * @param url
50
- * @param template
51
- * @param variables
52
- * @param opts
53
- * @param flipY
54
- * @returns
55
- */
56
- export declare function combineImageTemplate(url: string | HTMLImageElement, template: TemplateContentV1 | TemplateContentV2, variables: Record<string, number | string>, opts?: {
57
- templateScale?: number;
58
- canvas?: HTMLCanvasElement;
59
- }, flipY?: boolean): Promise<HTMLCanvasElement>;
60
- /**
61
- * @internal
62
- * @deprecated since 2.0.0 - use `combineImageTemplate` instead
63
- */
64
- export declare function combineImageTemplateAsync(url: string | HTMLImageElement, template: TemplateContentV1 | TemplateContentV2, variables: Record<string, number | string>, opts?: {
65
- templateScale?: number;
66
- canvas?: HTMLCanvasElement;
67
- }, flipY?: boolean): Promise<HTMLCanvasElement | HTMLImageElement | ImageData>;