@galacean/effects-core 2.0.0-alpha.8 → 2.0.0-alpha.9

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.
@@ -1,4 +1,4 @@
1
- import type { Matrix3, Matrix4, Quaternion, Vector2, Vector3, Vector4 } from '@galacean/effects-math/es/core/index';
1
+ import type { Matrix3, Matrix4, Quaternion, Vector2, Vector3, Vector4, Color } from '@galacean/effects-math/es/core/index';
2
2
  import type { GlobalUniforms, Renderer, Shader, ShaderWithSource } from '../render';
3
3
  import type { Texture } from '../texture';
4
4
  import type { DestroyOptions, Disposable } from '../utils';
@@ -249,6 +249,17 @@ export declare abstract class Material extends EffectsObject implements Disposab
249
249
  * @param value - 要设置的 uniform 数据
250
250
  */
251
251
  abstract setVector4(name: string, value: Vector4): void;
252
+ /**
253
+ * 获取 Material 的 Color 类型的 uniform 数据
254
+ * @param name
255
+ */
256
+ abstract getColor(name: string): Color | null;
257
+ /**
258
+ * 设置 Color 类型的 uniform 的数据
259
+ * @param name - uniform 名称
260
+ * @param value - 要设置的 uniform 数据
261
+ */
262
+ abstract setColor(name: string, value: Color): void;
252
263
  /**
253
264
  * 获取 Material 的 Quaternion 类型的 uniform 数据
254
265
  * @param name
@@ -1,9 +1,8 @@
1
1
  import type * as spec from '@galacean/effects-specification';
2
- import type { SceneLoadOptions } from './asset-manager';
3
2
  import type { Composition } from './composition';
4
3
  import type { Plugin, PluginConstructor } from './plugins';
5
4
  import type { RenderFrame, Renderer } from './render';
6
- import type { Scene } from './scene';
5
+ import type { Scene, SceneLoadOptions } from './scene';
7
6
  import type { VFXItemConstructor, VFXItemProps } from './vfx-item';
8
7
  import { VFXItem } from './vfx-item';
9
8
  export declare const pluginLoaderMap: Record<string, PluginConstructor>;
@@ -1,6 +1,5 @@
1
1
  import type * as spec from '@galacean/effects-specification';
2
- import type { SceneLoadOptions } from '../asset-manager';
3
- import type { Scene } from '../scene';
2
+ import type { Scene, SceneLoadOptions } from '../scene';
4
3
  import type { VFXItem } from '../vfx-item';
5
4
  import type { RenderFrame, Renderer } from '../render';
6
5
  import type { Composition } from '../composition';
@@ -109,6 +109,19 @@ export declare class SpriteComponent extends RendererComponent {
109
109
  * 获取当前 Mesh 的可见性。
110
110
  */
111
111
  getVisible(): boolean;
112
+ /**
113
+ * 设置当前图层的颜色
114
+ * > Tips: 透明度也属于颜色的一部分,当有透明度/颜色 K 帧变化时,该 API 会失效
115
+ * @since 2.0.0
116
+ * @param color - 颜色值
117
+ */
118
+ setColor(color: vec4): void;
119
+ /**
120
+ * 设置当前 Mesh 的纹理
121
+ * @since 2.0.0
122
+ * @param texture - 纹理对象
123
+ */
124
+ setTexture(texture: Texture): void;
112
125
  render(renderer: Renderer): void;
113
126
  start(): void;
114
127
  update(dt: number): void;
@@ -4,6 +4,7 @@ import type { SpriteItemProps } from '../sprite/sprite-item';
4
4
  import { SpriteComponent } from '../sprite/sprite-item';
5
5
  import { TextLayout } from './text-layout';
6
6
  import { TextStyle } from './text-style';
7
+ export declare const DEFAULT_FONTS: string[];
7
8
  /**
8
9
  * @since 2.0.0
9
10
  * @internal
@@ -10,3 +10,4 @@ export * from './geometry';
10
10
  export * from './frame-buffer';
11
11
  export * from './renderer';
12
12
  export * from './global-volume';
13
+ export * from './semantic-map';
@@ -4,8 +4,8 @@ import { Vector2, Vector4 } from '@galacean/effects-math/es/core/index';
4
4
  import type { Camera } from '../camera';
5
5
  import type { UniformValue } from '../material';
6
6
  import { PassTextureCache } from '../paas-texture-cache';
7
- import type { SemanticFunc } from '../semantic-map';
8
- import { SemanticMap } from '../semantic-map';
7
+ import type { SemanticFunc } from './semantic-map';
8
+ import { SemanticMap } from './semantic-map';
9
9
  import { Texture } from '../texture';
10
10
  import type { Disposable } from '../utils';
11
11
  import { DestroyOptions } from '../utils';
@@ -5,8 +5,8 @@ import type { RendererComponent } from '../components';
5
5
  import type { Engine } from '../engine';
6
6
  import type { MeshDestroyOptions, Renderer } from '../render';
7
7
  import { FrameBuffer } from '../render';
8
- import type { SemanticGetter } from '../semantic-map';
9
- import { SemanticMap } from '../semantic-map';
8
+ import type { SemanticGetter } from './semantic-map';
9
+ import { SemanticMap } from './semantic-map';
10
10
  import type { TextureConfigOptions, TextureLoadAction } from '../texture';
11
11
  import { Texture } from '../texture';
12
12
  import type { Disposable, Sortable } from '../utils';
@@ -1,6 +1,6 @@
1
- import type { UniformValue } from './material';
2
- import type { RenderingData } from './render';
3
- import type { Disposable } from './utils';
1
+ import type { UniformValue } from '../material';
2
+ import type { RenderingData } from '.';
3
+ import type { Disposable } from '../utils';
4
4
  export type SemanticFunc = (state: RenderingData) => UniformValue | undefined;
5
5
  export type SemanticGetter = UniformValue | SemanticFunc;
6
6
  export declare class SemanticMap implements Disposable {
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;
@@ -1,14 +1,4 @@
1
1
  import type { TemplateContent } from '@galacean/effects-specification';
2
- export declare const DEFAULT_FONTS: string[];
3
- declare class CanvasPool {
4
- readonly elements: HTMLCanvasElement[];
5
- constructor();
6
- dispose(): void;
7
- getCanvas(): HTMLCanvasElement;
8
- saveCanvas(cvs: HTMLCanvasElement): void;
9
- }
10
- export declare const canvasPool: CanvasPool;
11
- export declare function getDefaultTemplateCanvasPool(): CanvasPool;
12
2
  export declare function getBackgroundImage(template: TemplateContent, variables?: Record<string, number | string | string[]>): string | number | string[] | undefined;
13
3
  /**
14
4
  * @param url
@@ -17,5 +7,4 @@ export declare function getBackgroundImage(template: TemplateContent, variables?
17
7
  * @param options
18
8
  * @returns
19
9
  */
20
- export declare function combineImageTemplate(url: string | HTMLImageElement, template?: TemplateContent, variables?: Record<string, number | string>): Promise<number | HTMLImageElement | string[]>;
21
- export {};
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 数据
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/effects-core",
3
- "version": "2.0.0-alpha.8",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "Galacean Effects runtime core for the web",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",