@galacean/effects-core 2.0.0-alpha.1 → 2.0.0-alpha.10

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 (56) hide show
  1. package/dist/asset-loader.d.ts +16 -85
  2. package/dist/asset-manager.d.ts +1 -80
  3. package/dist/asset-migrations.d.ts +1 -3
  4. package/dist/canvas-pool.d.ts +10 -0
  5. package/dist/components/component.d.ts +1 -1
  6. package/dist/composition.d.ts +8 -3
  7. package/dist/constants.d.ts +0 -1
  8. package/dist/decorators.d.ts +1 -1
  9. package/dist/downloader.d.ts +2 -8
  10. package/dist/effects-object.d.ts +2 -2
  11. package/dist/engine.d.ts +4 -3
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +17014 -19609
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +17751 -20334
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/material/material.d.ts +18 -5
  18. package/dist/material/types.d.ts +0 -5
  19. package/dist/material/utils.d.ts +1 -1
  20. package/dist/math/bezier.d.ts +84 -0
  21. package/dist/math/keyframe-info.d.ts +39 -0
  22. package/dist/math/utils.d.ts +6 -2
  23. package/dist/math/value-getter.d.ts +32 -31
  24. package/dist/plugin-system.d.ts +1 -2
  25. package/dist/plugins/cal/calculate-item.d.ts +1 -1
  26. package/dist/plugins/cal/calculate-vfx-item.d.ts +8 -3
  27. package/dist/plugins/cal/playable-graph.d.ts +4 -0
  28. package/dist/plugins/cal/track.d.ts +3 -4
  29. package/dist/plugins/camera/camera-controller-node.d.ts +1 -1
  30. package/dist/plugins/interact/interact-mesh.d.ts +1 -1
  31. package/dist/plugins/particle/particle-loader.d.ts +1 -1
  32. package/dist/plugins/particle/particle-mesh.d.ts +6 -6
  33. package/dist/plugins/particle/particle-vfx-item.d.ts +1 -0
  34. package/dist/plugins/particle/trail-mesh.d.ts +6 -6
  35. package/dist/plugins/plugin.d.ts +1 -2
  36. package/dist/plugins/sprite/sprite-item.d.ts +13 -3
  37. package/dist/plugins/text/text-item.d.ts +1 -0
  38. package/dist/render/create-copy-shader.d.ts +1 -1
  39. package/dist/render/global-volume.d.ts +3 -0
  40. package/dist/render/index.d.ts +1 -0
  41. package/dist/render/render-frame.d.ts +2 -2
  42. package/dist/render/render-pass.d.ts +2 -2
  43. package/dist/{semantic-map.d.ts → render/semantic-map.d.ts} +4 -4
  44. package/dist/render/shader.d.ts +9 -2
  45. package/dist/scene.d.ts +79 -3
  46. package/dist/shader/index.d.ts +0 -11
  47. package/dist/shape/sphere.d.ts +0 -3
  48. package/dist/template-image.d.ts +10 -0
  49. package/dist/texture/texture.d.ts +6 -0
  50. package/dist/vfx-item.d.ts +2 -3
  51. package/package.json +4 -4
  52. package/dist/template-image/index.d.ts +0 -67
  53. package/dist/template-image/qcanvas-viewer.d.ts +0 -21
  54. package/dist/template-image/qtext.d.ts +0 -96
  55. package/dist/template-image/template-v1.d.ts +0 -27
  56. package/dist/template-image/text-metrics.d.ts +0 -18
package/dist/scene.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  import type * as spec from '@galacean/effects-specification';
2
- import type { SceneType } from './asset-manager';
3
2
  import type { Texture } from './texture';
4
3
  import type { PluginSystem } from './plugin-system';
5
4
  export type ImageSource = spec.TemplateImage | spec.Image | spec.CompressedImage;
6
5
  /**
7
- *
6
+ * 场景类型
8
7
  */
9
8
  export interface Scene {
10
9
  readonly jsonScene: spec.JSONScene;
@@ -27,4 +26,81 @@ export interface Scene {
27
26
  url: SceneType;
28
27
  usedImages: Record<number, boolean>;
29
28
  }
30
- export declare function isScene(scene: any): scene is Scene;
29
+ /**
30
+ * 场景加载参数
31
+ */
32
+ export interface SceneLoadOptions {
33
+ /**
34
+ * 动态数据的参数
35
+ * key 是 JSON 中配置的字段名
36
+ * value 是要使用的值,图片使用 url 链接
37
+ * 图片链接可以使用数组传递,如果第一个加载失败,将尝试使用第二个地址
38
+ *
39
+ * @example
40
+ * ``` ts
41
+ * {
42
+ * variables: {
43
+ * bg: ['url','fallback_url'], // 如果两个图片都失败,将会触发加载失败
44
+ * fg: 'url' // 如果图片加载失败,将会触发加载失败,
45
+ * amount: 88.8,
46
+ * name: 'abc'
47
+ * }
48
+ * }
49
+ * ```
50
+ */
51
+ variables?: Record<string, number | string | string[]>;
52
+ /**
53
+ * 是否使用压缩纹理
54
+ */
55
+ useCompressedTexture?: boolean;
56
+ /**
57
+ * 渲染分级。
58
+ * 分级之后,只会加载当前渲染等级的资源。
59
+ * 当渲染等级被设置为 B 后,player 的 fps 会降到 30 帧
60
+ * @default 's'
61
+ */
62
+ renderLevel?: spec.RenderLevel;
63
+ /**
64
+ * 资源加载超时,时间单位秒
65
+ * @default 10s
66
+ */
67
+ timeout?: number;
68
+ /***
69
+ * 用于给 plugin 的加载数据
70
+ * key/value 的内容由 plugin 自己实现
71
+ */
72
+ pluginData?: Record<string, any>;
73
+ /**
74
+ * 场景加载时的环境(加载后把 env 结果写入 scene)
75
+ * @default '' - 编辑器中为 'editor'
76
+ */
77
+ env?: string;
78
+ /**
79
+ * 加载后是否自动播放
80
+ * @default true
81
+ */
82
+ autoplay?: boolean;
83
+ /**
84
+ * 合成播放完成后是否需要再使用,是的话生命周期结束后不会 `dispose`
85
+ * @default false
86
+ */
87
+ reusable?: boolean;
88
+ /**
89
+ * 播放速度,当速度为负数时,合成倒播
90
+ */
91
+ speed?: number;
92
+ }
93
+ /**
94
+ * 接受用于加载的数据类型
95
+ */
96
+ export type SceneURLType = {
97
+ url: string;
98
+ };
99
+ export type SceneType = string | Scene | SceneURLType | Record<string, any>;
100
+ export type SceneWithOptionsType = {
101
+ options: SceneLoadOptions;
102
+ };
103
+ export type SceneLoadType = SceneType | SceneWithOptionsType;
104
+ export declare function isSceneJSON(scene: any): scene is Scene;
105
+ export declare function isSceneURL(scene: any): scene is Scene;
106
+ export declare function isSceneWithOptions(scene: any): scene is SceneWithOptionsType;
@@ -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';
@@ -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 { TemplateContent } from '@galacean/effects-specification';
2
+ export declare function getBackgroundImage(template: TemplateContent, variables?: Record<string, number | string | string[]>): string | number | string[] | 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?: TemplateContent, variables?: Record<string, number | string>): 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 数据
@@ -1,10 +1,10 @@
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';
3
4
  import { RendererComponent } from './components';
4
5
  import type { Component } from './components/component';
5
6
  import { ItemBehaviour } from './components/component';
6
7
  import type { Composition } from './composition';
7
- import { type VFXItemData } from './asset-loader';
8
8
  import { EffectsObject } from './effects-object';
9
9
  import type { Engine } from './engine';
10
10
  import type { BoundingBoxData, CameraController, HitTestBoxParams, HitTestCustomParams, HitTestSphereParams, HitTestTriangleParams, InteractComponent, ParticleSystem, SpriteComponent } from './plugins';
@@ -77,7 +77,7 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
77
77
  * 元素 id 唯一
78
78
  */
79
79
  id: string;
80
- oldId: number;
80
+ oldId: string;
81
81
  /**
82
82
  * 元素创建的数据图层/粒子/模型等
83
83
  */
@@ -258,7 +258,6 @@ export declare class VFXItem<T extends VFXItemContent> extends EffectsObject imp
258
258
  }
259
259
  export declare namespace Item {
260
260
  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
261
  function isComposition(item: spec.Item): item is spec.CompositionItem;
263
262
  function isParticle(item: spec.Item): item is spec.ParticleItem;
264
263
  function isNull(item: spec.Item): item is spec.NullItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/effects-core",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.10",
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,15 @@
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.9",
46
+ "@galacean/effects-math": "1.1.0-alpha.0",
47
47
  "uuid": "9.0.1"
48
48
  },
49
49
  "scripts": {
50
50
  "prebuild": "pnpm clean",
51
51
  "build": "pnpm build:declaration && pnpm build:module",
52
52
  "build:module": "rollup -c",
53
- "build:declaration": "tsc -d --declarationDir dist --emitDeclarationOnly",
53
+ "build:declaration": "tsc -d --emitDeclarationOnly",
54
54
  "clean": "rimraf dist && rimraf '*+(.tsbuildinfo)'"
55
55
  }
56
56
  }
@@ -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>;
@@ -1,21 +0,0 @@
1
- import type { QText } from './qtext';
2
- declare class QCanvasViewer {
3
- width: number;
4
- height: number;
5
- background: HTMLImageElement;
6
- scaleX: number;
7
- scaleY: number;
8
- renderCanvas: HTMLCanvasElement;
9
- renderContext: CanvasRenderingContext2D;
10
- textList: QText[];
11
- devicePixelRatio: number;
12
- flipY: boolean;
13
- constructor(canvas: string | HTMLCanvasElement, width: number, height: number, scaleX?: number, scaleY?: number, flipY?: boolean);
14
- initDimension(width: number, height: number, scaleX?: number, scaleY?: number): void;
15
- clearText(): void;
16
- clearCanvasWithContext(ctx: CanvasRenderingContext2D): void;
17
- clearCanvas(): void;
18
- addObject(text: QText): void;
19
- render(): void;
20
- }
21
- export { QCanvasViewer };
@@ -1,96 +0,0 @@
1
- import type { QCanvasViewer } from './qcanvas-viewer';
2
- import type { IFontMetrics } from './text-metrics';
3
- declare enum QTextWrapMode {
4
- Default = 0,
5
- Clip = 1,
6
- Ellipsis = 2
7
- }
8
- interface QTextOptions {
9
- left?: number;
10
- top?: number;
11
- maxWidth?: number;
12
- fontFamily?: string;
13
- fontSize?: number;
14
- fontWeight?: string;
15
- align?: string;
16
- verticalAlign?: string;
17
- padding?: number;
18
- letterSpacing?: number;
19
- wrap?: QTextWrapMode;
20
- color?: string;
21
- fontStyle?: string;
22
- angle?: number;
23
- name?: string;
24
- }
25
- interface QChar {
26
- left: number;
27
- top: number;
28
- char: string;
29
- width: number;
30
- heigh: number;
31
- font: string;
32
- fontSize: number;
33
- isEllipsis: boolean;
34
- scale: number;
35
- index: number;
36
- }
37
- declare class QText {
38
- left: number;
39
- top: number;
40
- width?: number;
41
- height?: number;
42
- text: string;
43
- name: string;
44
- fontSize: number;
45
- fontFamily: string;
46
- color: string;
47
- letterSpacing: number;
48
- maxLineWidth: number;
49
- wrap: QTextWrapMode;
50
- fontStyle: 'normal' | 'italic' | 'oblique' | 'initial' | 'inherit';
51
- textAlign: 'center' | 'end' | 'left' | 'right' | 'start';
52
- textBaseline: 'alphabetic' | 'bottom' | 'hanging' | 'ideographic' | 'middle' | 'top';
53
- scaleX: number;
54
- scaleY: number;
55
- angle: number;
56
- active: boolean;
57
- padding: number;
58
- fontWeight: string;
59
- chars: QChar[];
60
- borderColor: string;
61
- borderWidth: number;
62
- fontProperties: IFontMetrics;
63
- fontVariant: string;
64
- private viewer;
65
- private originX;
66
- private originY;
67
- private ellipsis;
68
- constructor(text: string, options: QTextOptions);
69
- update(): void;
70
- render(): void;
71
- init(viewer: QCanvasViewer): void;
72
- getLayout(): {
73
- x: number;
74
- y: number;
75
- width: number;
76
- height: number;
77
- };
78
- private updateDimension;
79
- private configTextStyle;
80
- private getFontDesc;
81
- private configTextLayout;
82
- private setRenderTransform;
83
- private renderText;
84
- private drawCharsInTextBox;
85
- private addEllipsisToChars;
86
- private createCharsFromText;
87
- private addOffsetToChars;
88
- private clipCharsWithTextBox;
89
- private cloneChars;
90
- private replaceCharWithEllipsis;
91
- private findEllipsisPositionAndReplaceCharsFromLeft;
92
- private findEllipsisPositionAndReplaceCharsFromRight;
93
- private drawCharsFromLeft;
94
- private drawBorders;
95
- }
96
- export { QText, QTextOptions, QTextWrapMode };
@@ -1,27 +0,0 @@
1
- import type { TemplateContentV1 } from '@galacean/effects-specification';
2
- export declare function requestAsync(url: string, opt?: {
3
- responseType?: XMLHttpRequestResponseType;
4
- method?: string;
5
- data?: Document | XMLHttpRequestBodyInit | null;
6
- }): Promise<unknown>;
7
- /**
8
- *
9
- * @param url
10
- * @param template
11
- * @param variables
12
- * @param opts
13
- * @param flipY
14
- * @returns
15
- */
16
- export declare function combineImageTemplate1(url: string | HTMLImageElement, template: TemplateContentV1, variables: Record<string, number | string | HTMLImageElement>, opts?: {
17
- templateScale?: number;
18
- canvas?: HTMLCanvasElement;
19
- }, flipY?: boolean): Promise<HTMLCanvasElement>;
20
- /**
21
- * @internal
22
- * @deprecated since 2.0.0 - use `combineImageTemplate1` instead
23
- */
24
- export declare function combineImageTemplate1Async(url: string | HTMLImageElement, template: TemplateContentV1, variables: Record<string, number | string | HTMLImageElement>, opts?: {
25
- templateScale?: number;
26
- canvas?: HTMLCanvasElement;
27
- }, flipY?: boolean): Promise<HTMLCanvasElement>;
@@ -1,18 +0,0 @@
1
- export interface IFontMetrics {
2
- ascent: number;
3
- descent: number;
4
- fontSize: number;
5
- }
6
- export declare class TextMetrics {
7
- static _fonts: {
8
- [font: string]: IFontMetrics;
9
- };
10
- static METRICS_STRING: string;
11
- static BASELINE_SYMBOL: string;
12
- static BASELINE_MULTIPLIER: number;
13
- static HEIGHT_MULTIPLIER: number;
14
- private static __canvas;
15
- private static __context;
16
- static measureFont(font: string): IFontMetrics;
17
- static get _canvas(): HTMLCanvasElement;
18
- }