@galacean/effects 2.0.0-alpha.2 → 2.0.0-alpha.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/player.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Disposable, GPUCapability, LostHandler, RestoreHandler, SceneLoadOptions, math, SceneLoadType, SceneWithOptionsType } from '@galacean/effects-core';
1
+ import type { Disposable, GLType, GPUCapability, LostHandler, RestoreHandler, SceneLoadOptions, math, SceneLoadType } from '@galacean/effects-core';
2
2
  import { Composition, Renderer, Ticker } from '@galacean/effects-core';
3
3
  /**
4
4
  * `onItemClicked` 点击回调函数的传入参数
@@ -53,7 +53,7 @@ export interface PlayerConfig {
53
53
  /**
54
54
  * 指定 WebGL 创建的上下文类型,`debug-disable` 表示不创建
55
55
  */
56
- renderFramework?: 'webgl' | 'webgl2' | 'debug-disable';
56
+ renderFramework?: GLType | 'debug-disable';
57
57
  /**
58
58
  * player 的 name
59
59
  */
@@ -67,7 +67,7 @@ export interface PlayerConfig {
67
67
  * 图片预乘 Alpha
68
68
  * @default false
69
69
  */
70
- premultiplyAlpha?: boolean;
70
+ premultipliedAlpha?: boolean;
71
71
  };
72
72
  /**
73
73
  * 是否通知 container touchend / mouseup 事件, 默认不通知
@@ -117,7 +117,6 @@ export interface PlayerConfig {
117
117
  * @param time - GPU 渲染使用的时间,秒
118
118
  */
119
119
  reportGPUTime?: (time: number) => void;
120
- [key: string]: any;
121
120
  }
122
121
  /**
123
122
  * Galacean Effects 播放器
@@ -138,19 +137,20 @@ export declare class Player implements Disposable, LostHandler, RestoreHandler {
138
137
  * 手动渲染 `manualRender=true` 时不创建计时器
139
138
  */
140
139
  readonly ticker: Ticker;
141
- /**
142
- * 当前播放的合成对象数组,请不要修改内容
143
- */
144
- protected compositions: Composition[];
140
+ private readonly builtinObjects;
145
141
  private readonly event;
146
142
  private readonly handleWebGLContextLost?;
147
143
  private readonly handleWebGLContextRestored?;
148
144
  private readonly handleMessageItem?;
149
145
  private readonly handlePlayerPause?;
150
- private readonly reportGPUTime?;
151
146
  private readonly handleItemClicked?;
152
147
  private readonly handlePlayableUpdate?;
153
148
  private readonly handleRenderError?;
149
+ private readonly reportGPUTime?;
150
+ /**
151
+ * 当前播放的合成对象数组,请不要修改内容
152
+ */
153
+ private compositions;
154
154
  private displayAspect;
155
155
  private displayScale;
156
156
  private forceRenderNextFrame;
@@ -158,7 +158,7 @@ export declare class Player implements Disposable, LostHandler, RestoreHandler {
158
158
  private resumePending;
159
159
  private offscreenMode;
160
160
  private disposed;
161
- private assetManager;
161
+ private assetManagers;
162
162
  private speed;
163
163
  private baseCompositionIndex;
164
164
  /**
@@ -167,18 +167,26 @@ export declare class Player implements Disposable, LostHandler, RestoreHandler {
167
167
  */
168
168
  constructor(config: PlayerConfig);
169
169
  /**
170
- * 设置 player 的播放速度,
170
+ * 设置当前 Player 的播放速度
171
171
  * @param speed - 播放速度
172
172
  */
173
173
  setSpeed(speed: number): void;
174
+ /**
175
+ * 获取当前 Player 的播放速度
176
+ * @returns
177
+ */
174
178
  getSpeed(): number;
175
179
  /**
176
- * 根据名称查找对应的合成,可能找不到
180
+ * 根据名称查找对应的合成(可能找不到,如果有同名的合成,默认返回第一个)
181
+ * @example
182
+ * ``` ts
183
+ * const composition = player.getCompositionByName('新建合成1');
184
+ * ```
177
185
  * @param name - 目标合成名称
178
186
  */
179
187
  getCompositionByName(name: string): Composition | undefined;
180
188
  /**
181
- * 获取当前播放的所有合成, 请不要修改返回数组的内容
189
+ * 获取当前播放的所有合成(请不要修改返回的数组内容)
182
190
  */
183
191
  getCompositions(): Composition[];
184
192
  /**
@@ -199,6 +207,60 @@ export declare class Player implements Disposable, LostHandler, RestoreHandler {
199
207
  set interactive(enable: boolean);
200
208
  /**
201
209
  * 加载动画资源
210
+ * @example
211
+ * ``` ts
212
+ * // 1. 加载单个合成链接并设置可选参数
213
+ * const composition = await player.loadScene('xxx.json', { ... });
214
+ * const composition = await player.loadScene({ url: 'xxx.json' }, { ... });
215
+ *
216
+ * // 2. 加载单个合成的 JSON 对象并设置可选参数
217
+ * const composition = await player.loadScene(JSONValue, { ... });
218
+ *
219
+ * // 3. 加载多个合成链接或 JSON 对象
220
+ * const [_, _, _] = await player.loadScene(['x1.json', 'x2.json', JSONValue]);
221
+ *
222
+ * // 4. 加载多个合成链接并各自设置可选参数
223
+ * const [_, _] = await player.loadScene([{
224
+ * url: 'x1.json',
225
+ * options: { autoplay: false, ... },
226
+ * }, {
227
+ * url: 'x2.json',
228
+ * options: { speed: 2, ... },
229
+ * }, { ... }]);
230
+ *
231
+ * // 5. 加载多个合成链接并统一设置可选参数(共用)
232
+ * const [_, _, _] = await player.loadScene(['x1.json', 'x2.json', ...], { ... });
233
+ * const [_, _] = await player.loadScene(
234
+ * [{ url: 'x1.json' }, { url: 'x2.json' }, { ... }],
235
+ * {
236
+ * variables: {
237
+ * 'name': 'value',
238
+ * },
239
+ * speed: 2,
240
+ * ...
241
+ * },
242
+ * );
243
+ *
244
+ * // 6. 疯狂混合
245
+ * await player.loadScene([
246
+ * {
247
+ * url: 'x1.json',
248
+ * options: {
249
+ * variables: {
250
+ * 'name1': 'value1',
251
+ * },
252
+ * speed: 2,
253
+ * },
254
+ * },
255
+ * 'x2.json',
256
+ * JSONValue,
257
+ * ], {
258
+ * variables: {
259
+ * 'name2': 'value2',
260
+ * },
261
+ * speed: 0.1,
262
+ * });
263
+ * ```
202
264
  * @param scene - 一个或一组 URL 或者通过 URL 请求的 JSONObject 或者 Scene 对象
203
265
  * @param options - 加载可选参数
204
266
  * @returns
@@ -284,8 +346,8 @@ export declare class Player implements Disposable, LostHandler, RestoreHandler {
284
346
  private offloadTexture;
285
347
  private handleClick;
286
348
  private getTargetSize;
349
+ private destroyBuiltinObjects;
287
350
  }
288
- export declare function isSceneWithOptions(scene: any): scene is SceneWithOptionsType;
289
351
  /**
290
352
  * 禁止/允许创建新的播放器,已创建的不受影响
291
353
  * @param disable - 是否禁止
package/dist/utils.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export declare function isDowngradeIOS(): boolean;
2
+ export declare function throwError(destroyedErrorMessage: string): void;
3
+ export declare function throwErrorPromise(destroyedErrorMessage: string): Promise<never>;