@galacean/effects-plugin-model 2.0.0-alpha.2 → 2.0.0-alpha.21

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,18 +1,10 @@
1
- import type { HitTestBoxParams, HitTestCustomParams, HitTestSphereParams, Engine, Renderer } from '@galacean/effects';
2
- import { ItemBehaviour, RendererComponent, TimelineComponent } from '@galacean/effects';
3
- import { Vector3 } from '../runtime/math';
4
- import type { Euler } from '../runtime/math';
5
- import type { ModelItemBounding, ModelLightContent, ModelCameraContent, ModelMeshContent, ModelSkyboxContent } from '../index';
1
+ import type { Engine, HitTestBoxParams, HitTestCustomParams, HitTestSphereParams, Renderer, VFXItem } from '@galacean/effects';
2
+ import { ItemBehaviour, RendererComponent, AnimationClip } from '@galacean/effects';
3
+ import type { ModelCameraComponentData, ModelItemBounding, ModelLightComponentData, ModelMeshComponentData, ModelSkyboxComponentData, AnimationComponentData } from '../index';
6
4
  import type { PSceneManager } from '../runtime';
7
5
  import { PCamera, PLight, PMesh, PSkybox } from '../runtime';
8
- export declare enum ModelDataType {
9
- MeshComponent = 10000,
10
- SkyboxComponent = 10001,
11
- LightComponent = 10002,
12
- CameraComponent = 10003,
13
- ModelPluginComponent = 10004,
14
- TreeComponent = 10005
15
- }
6
+ import type { Euler } from '../runtime/math';
7
+ import { Vector3 } from '../runtime/math';
16
8
  /**
17
9
  * 插件 Mesh 组件类,支持 3D Mesh 渲染能力
18
10
  * @since 2.0.0
@@ -26,7 +18,7 @@ export declare class ModelMeshComponent extends RendererComponent {
26
18
  /**
27
19
  * 参数
28
20
  */
29
- options?: ModelMeshContent;
21
+ data?: ModelMeshComponentData;
30
22
  /**
31
23
  * 包围盒
32
24
  */
@@ -35,12 +27,16 @@ export declare class ModelMeshComponent extends RendererComponent {
35
27
  * 场景管理器
36
28
  */
37
29
  sceneManager?: PSceneManager;
30
+ /**
31
+ * morph 动画权重
32
+ */
33
+ morphWeights: number[];
38
34
  /**
39
35
  * 构造函数,只保存传入参数,不在这里创建内部对象
40
36
  * @param engine - 引擎
41
- * @param options - Mesh 参数
37
+ * @param data - Mesh 参数
42
38
  */
43
- constructor(engine: Engine, options?: ModelMeshContent);
39
+ constructor(engine: Engine, data?: ModelMeshComponentData);
44
40
  /**
45
41
  * 组件开始,需要创建内部对象,更新父元素信息和添加到场景管理器中
46
42
  */
@@ -62,9 +58,9 @@ export declare class ModelMeshComponent extends RendererComponent {
62
58
  onDestroy(): void;
63
59
  /**
64
60
  * 反序列化,记录传入参数
65
- * @param options - 组件参数
61
+ * @param data - 组件参数
66
62
  */
67
- fromData(options: ModelMeshContent): void;
63
+ fromData(data: ModelMeshComponentData): void;
68
64
  /**
69
65
  * 创建内部对象
70
66
  */
@@ -103,7 +99,7 @@ export declare class ModelSkyboxComponent extends RendererComponent {
103
99
  /**
104
100
  * 天空盒参数
105
101
  */
106
- options?: ModelSkyboxContent;
102
+ data?: ModelSkyboxComponentData;
107
103
  /**
108
104
  * 场景管理器
109
105
  */
@@ -111,9 +107,9 @@ export declare class ModelSkyboxComponent extends RendererComponent {
111
107
  /**
112
108
  * 构造函数,只保存传入参数,不在这里创建内部对象
113
109
  * @param engine - 引擎
114
- * @param options - Mesh 参数
110
+ * @param data - Mesh 参数
115
111
  */
116
- constructor(engine: Engine, options?: ModelSkyboxContent);
112
+ constructor(engine: Engine, data?: ModelSkyboxComponentData);
117
113
  /**
118
114
  * 组件开始,需要创建内部对象和添加到场景管理器中
119
115
  */
@@ -130,9 +126,9 @@ export declare class ModelSkyboxComponent extends RendererComponent {
130
126
  onDestroy(): void;
131
127
  /**
132
128
  * 反序列化,记录传入参数
133
- * @param options - 组件参数
129
+ * @param data - 组件参数
134
130
  */
135
- fromData(options: ModelSkyboxContent): void;
131
+ fromData(data: ModelSkyboxComponentData): void;
136
132
  /**
137
133
  * 创建内部对象
138
134
  */
@@ -160,13 +156,13 @@ export declare class ModelLightComponent extends ItemBehaviour {
160
156
  /**
161
157
  * 参数
162
158
  */
163
- options?: ModelLightContent;
159
+ data?: ModelLightComponentData;
164
160
  /**
165
161
  * 构造函数,只保存传入参数,不在这里创建内部对象
166
162
  * @param engine - 引擎
167
- * @param options - Mesh 参数
163
+ * @param data - Mesh 参数
168
164
  */
169
- constructor(engine: Engine, options?: ModelLightContent);
165
+ constructor(engine: Engine, data?: ModelLightComponentData);
170
166
  /**
171
167
  * 组件开始,需要创建内部对象和添加到场景管理器中
172
168
  */
@@ -182,9 +178,9 @@ export declare class ModelLightComponent extends ItemBehaviour {
182
178
  onDestroy(): void;
183
179
  /**
184
180
  * 反序列化,记录传入参数
185
- * @param options - 组件参数
181
+ * @param data - 组件参数
186
182
  */
187
- fromData(options: ModelLightContent): void;
183
+ fromData(data: ModelLightComponentData): void;
188
184
  /**
189
185
  * 创建内部对象
190
186
  */
@@ -212,17 +208,13 @@ export declare class ModelCameraComponent extends ItemBehaviour {
212
208
  /**
213
209
  * 参数
214
210
  */
215
- options?: ModelCameraContent;
216
- /**
217
- * 时间轴组件
218
- */
219
- timeline?: TimelineComponent;
211
+ data?: ModelCameraComponentData;
220
212
  /**
221
213
  * 构造函数,只保存传入参数,不在这里创建内部对象
222
214
  * @param engine - 引擎
223
- * @param options - Mesh 参数
215
+ * @param data - Mesh 参数
224
216
  */
225
- constructor(engine: Engine, options?: ModelCameraContent);
217
+ constructor(engine: Engine, data?: ModelCameraComponentData);
226
218
  /**
227
219
  * 组件开始,需要创建内部对象和添加到场景管理器中
228
220
  */
@@ -238,9 +230,9 @@ export declare class ModelCameraComponent extends ItemBehaviour {
238
230
  onDestroy(): void;
239
231
  /**
240
232
  * 反序列化,记录传入参数
241
- * @param options - 组件参数
233
+ * @param data - 组件参数
242
234
  */
243
- fromData(options: ModelCameraContent): void;
235
+ fromData(data: ModelCameraComponentData): void;
244
236
  /**
245
237
  * 创建内部对象
246
238
  */
@@ -256,3 +248,47 @@ export declare class ModelCameraComponent extends ItemBehaviour {
256
248
  */
257
249
  setTransform(position?: Vector3, rotation?: Euler): void;
258
250
  }
251
+ /**
252
+ * 插件动画组件类,支持 3D 动画能力
253
+ * @since 2.0.0
254
+ * @internal
255
+ */
256
+ export declare class AnimationComponent extends ItemBehaviour {
257
+ /**
258
+ * 参数
259
+ */
260
+ data?: AnimationComponentData;
261
+ elapsedTime: number;
262
+ animation: number;
263
+ clips: ModelAnimationClip[];
264
+ /**
265
+ * 构造函数,只保存传入参数,不在这里创建内部对象
266
+ * @param engine - 引擎
267
+ */
268
+ constructor(engine: Engine);
269
+ /**
270
+ * 组件开始,需要创建内部对象和添加到场景管理器中
271
+ */
272
+ start(): void;
273
+ /**
274
+ * 组件更新,更新内部对象状态
275
+ * @param dt - 更新间隔
276
+ */
277
+ update(dt: number): void;
278
+ /**
279
+ * 组件销毁
280
+ */
281
+ onDestroy(): void;
282
+ /**
283
+ * 反序列化,记录传入参数
284
+ * @param data - 组件参数
285
+ */
286
+ fromData(data: AnimationComponentData): void;
287
+ }
288
+ declare class ModelAnimationClip extends AnimationClip {
289
+ path2Node: Record<string, VFXItem>;
290
+ sampleAnimation(vfxItem: VFXItem, time: number): void;
291
+ setFromAnimationClip(clip: AnimationClip): void;
292
+ getTargetItem(rootItem: VFXItem, path: string): VFXItem;
293
+ }
294
+ export {};
@@ -1,5 +1,5 @@
1
- import type { Scene, SceneLoadOptions, Composition, RenderFrame, Engine, Component } from '@galacean/effects';
2
- import { AbstractPlugin, ItemBehaviour } from '@galacean/effects';
1
+ import type { Scene, SceneLoadOptions, Composition, RenderFrame, Engine, Component, Renderer } from '@galacean/effects';
2
+ import { AbstractPlugin, spec, ItemBehaviour } from '@galacean/effects';
3
3
  import { CompositionCache } from '../runtime/cache';
4
4
  import { PSceneManager } from '../runtime';
5
5
  /**
@@ -24,6 +24,7 @@ export declare class ModelPlugin extends AbstractPlugin {
24
24
  * @param options - 加载选项
25
25
  */
26
26
  static prepareResource(scene: Scene, options: SceneLoadOptions): Promise<void>;
27
+ static precompile(compositions: spec.Composition[], renderer: Renderer): Promise<void>;
27
28
  /**
28
29
  * 创建 3D 场景管理器和缓存器
29
30
  * @param composition - 合成
@@ -98,7 +99,7 @@ export declare class ModelPluginComponent extends ItemBehaviour {
98
99
  * 反序列化,创建场景管理器
99
100
  * @param date - 组件参数
100
101
  */
101
- fromData(data: any): void;
102
+ fromData(data: ModelPluginOptions): void;
102
103
  /**
103
104
  * 组件初始化,初始化场景管理器并更新合成相机
104
105
  * @param sceneParams - 场景参数
@@ -1,6 +1,6 @@
1
- import { Transform, ItemBehaviour } from '@galacean/effects';
2
- import type { TimelineComponent, VFXItemContent, Engine, VFXItem } from '@galacean/effects';
3
- import type { ModelTreeOptions, ModelTreeContent } from '../index';
1
+ import type { Engine, VFXItem } from '@galacean/effects';
2
+ import { ItemBehaviour, Transform } from '@galacean/effects';
3
+ import type { ModelTreeContent, ModelTreeOptions } from '../index';
4
4
  import { PAnimationManager } from '../runtime';
5
5
  /**
6
6
  * 场景树节点描述
@@ -47,7 +47,7 @@ export declare class ModelTreeItem {
47
47
  * @param props - 场景树数据
48
48
  * @param owner - 场景树元素
49
49
  */
50
- constructor(props: ModelTreeOptions, owner: VFXItem<VFXItemContent>);
50
+ constructor(props: ModelTreeOptions, owner: VFXItem);
51
51
  /**
52
52
  * 场景树更新,主要是动画更新
53
53
  * @param dt - 时间间隔
@@ -96,10 +96,6 @@ export declare class ModelTreeComponent extends ItemBehaviour {
96
96
  * 参数
97
97
  */
98
98
  options?: ModelTreeContent;
99
- /**
100
- * 时间轴组件
101
- */
102
- timeline?: TimelineComponent;
103
99
  /**
104
100
  * 构造函数,创建节点树元素
105
101
  * @param engine
@@ -1,6 +1,6 @@
1
- import type { Geometry, Engine, VFXItemContent, VFXItem } from '@galacean/effects';
1
+ import type { Geometry, Engine, VFXItem, SkinProps } from '@galacean/effects';
2
2
  import { Texture } from '@galacean/effects';
3
- import type { ModelSkinOptions, ModelAnimTrackOptions, ModelAnimationOptions, ModelTreeOptions } from '../index';
3
+ import type { ModelAnimTrackOptions, ModelAnimationOptions, ModelTreeOptions } from '../index';
4
4
  import { Matrix4 } from './math';
5
5
  import { PObject } from './object';
6
6
  import type { PSceneManager } from './scene';
@@ -19,7 +19,7 @@ export declare class PSkin extends PObject {
19
19
  /**
20
20
  * 场景树父元素
21
21
  */
22
- parentItem?: VFXItem<VFXItemContent>;
22
+ rootBoneItem?: VFXItem;
23
23
  /**
24
24
  * 骨骼索引
25
25
  */
@@ -27,7 +27,7 @@ export declare class PSkin extends PObject {
27
27
  /**
28
28
  * 关节索引
29
29
  */
30
- jointList: number[];
30
+ jointItem: VFXItem[];
31
31
  /**
32
32
  * 逆绑定矩阵
33
33
  */
@@ -42,11 +42,11 @@ export declare class PSkin extends PObject {
42
42
  textureDataMode: TextureDataMode;
43
43
  /**
44
44
  * 创建蒙皮对象
45
- * @param options - 蒙皮相关数据
45
+ * @param props - 蒙皮相关数据
46
46
  * @param engine - 引擎对象
47
- * @param parentItem - 场景树父元素
47
+ * @param rootBoneItem - 场景树父元素
48
48
  */
49
- create(options: ModelSkinOptions, engine: Engine, parentItem?: VFXItem<VFXItemContent>): void;
49
+ create(props: SkinProps, engine: Engine, rootBoneItem: VFXItem): void;
50
50
  /**
51
51
  * 更新蒙皮矩阵
52
52
  */
@@ -62,7 +62,7 @@ export declare class PSkin extends PObject {
62
62
  * 更新父元素
63
63
  * @param parentItem - 场景树父元素
64
64
  */
65
- updateParentItem(parentItem: VFXItem<VFXItemContent>): void;
65
+ updateParentItem(parentItem: VFXItem): void;
66
66
  /**
67
67
  * 获取关节点数
68
68
  * @returns
@@ -78,6 +78,9 @@ export declare class PSkin extends PObject {
78
78
  */
79
79
  dispose(): void;
80
80
  private getTextureDataMode;
81
+ private getJointItems;
82
+ private genNodeName;
83
+ private genNodeNameDFS;
81
84
  }
82
85
  /**
83
86
  * Morph 动画类
@@ -95,7 +98,7 @@ export declare class PMorph extends PObject {
95
98
  * weights 数组的具体数据,来自动画控制器的每帧更新
96
99
  * 数组的长度必须和 morphWeightsLength 相同,否则会出错。
97
100
  */
98
- morphWeightsArray?: Float32Array;
101
+ morphWeightsArray: number[];
99
102
  /**
100
103
  * 是否有 Position 相关的 Morph 动画,shader 中需要知道
101
104
  */
@@ -114,12 +117,12 @@ export declare class PMorph extends PObject {
114
117
  * @returns 是否创建成功
115
118
  */
116
119
  create(geometry: Geometry): boolean;
117
- dispose(): void;
118
120
  /**
119
121
  * 初始化 Morph target 的权重数组
120
122
  * @param weights - glTF Mesh 的权重数组,长度必须严格一致
121
123
  */
122
124
  initWeights(weights: number[]): void;
125
+ updateWeights(weights: number[]): void;
123
126
  /**
124
127
  * 当前状态是否有 Morph 动画:
125
128
  * 需要判断 weights 数组长度,以及 Position、Normal 和 Tangent 是否有动画
@@ -133,7 +136,7 @@ export declare class PMorph extends PObject {
133
136
  * @returns 返回两个 Morph 动画状态是否相等
134
137
  */
135
138
  equals(morph: PMorph): boolean;
136
- getMorphWeightsArray(): Float32Array;
139
+ getMorphWeightsArray(): number[];
137
140
  /**
138
141
  * 统计 Geometry 中 Attribute 名称个数:
139
142
  * 主要用于统计 Morph 动画中新增的 Attribute 名称的个数,会作为最终的 weights 数组长度使用
@@ -216,7 +219,7 @@ export declare class PAnimTrack {
216
219
  * @param treeItem - 节点树元素
217
220
  * @param sceneManager - 3D 场景管理器
218
221
  */
219
- tick(time: number, treeItem: VFXItem<VFXItemContent>, sceneManager?: PSceneManager): void;
222
+ tick(time: number, treeItem: VFXItem, sceneManager?: PSceneManager): void;
220
223
  /**
221
224
  * 获取动画结束时间
222
225
  * @returns
@@ -290,7 +293,7 @@ export declare class PAnimation extends PObject {
290
293
  * @param treeItem - 场景树元素
291
294
  * @param sceneManager - 3D 场景管理器
292
295
  */
293
- tick(time: number, treeItem: VFXItem<VFXItemContent>, sceneManager?: PSceneManager): void;
296
+ tick(time: number, treeItem: VFXItem, sceneManager?: PSceneManager): void;
294
297
  /**
295
298
  * 销毁
296
299
  */
@@ -312,7 +315,7 @@ export declare class PAnimationManager extends PObject {
312
315
  * @param treeOptions - 场景树参数
313
316
  * @param ownerItem - 场景树所属元素
314
317
  */
315
- constructor(treeOptions: ModelTreeOptions, ownerItem: VFXItem<VFXItemContent>);
318
+ constructor(treeOptions: ModelTreeOptions, ownerItem: VFXItem);
316
319
  /**
317
320
  * 设置场景管理器
318
321
  * @param sceneManager - 场景管理器
@@ -337,5 +340,5 @@ export declare class PAnimationManager extends PObject {
337
340
  * 获取场景树元素
338
341
  * @returns
339
342
  */
340
- getTreeItem(): VFXItem<VFXItemContent>;
343
+ getTreeItem(): VFXItem;
341
344
  }
@@ -1,6 +1,6 @@
1
1
  import type { math } from '@galacean/effects';
2
2
  import { spec } from '@galacean/effects';
3
- import type { ModelCameraOptions } from '../index';
3
+ import type { ModelCameraComponentData } from '../index';
4
4
  import { Vector2, Vector3, Matrix4 } from './math';
5
5
  import { PEntity } from './object';
6
6
  import type { ModelCameraComponent } from '../plugin/model-item';
@@ -33,7 +33,7 @@ export declare class PCamera extends PEntity {
33
33
  /**
34
34
  * Y 轴上视角
35
35
  */
36
- fovy: number;
36
+ fov: number;
37
37
  /**
38
38
  * 纵横比
39
39
  */
@@ -57,7 +57,7 @@ export declare class PCamera extends PEntity {
57
57
  * @param height - 画布高度
58
58
  * @param owner - 所属的相机组件
59
59
  */
60
- constructor(name: string, width: number, height: number, options: ModelCameraOptions, owner?: ModelCameraComponent);
60
+ constructor(name: string, width: number, height: number, data: ModelCameraComponentData, owner?: ModelCameraComponent);
61
61
  /**
62
62
  * 更新相机矩阵和投影矩阵,从所属的元素中获取变换数据
63
63
  */
@@ -112,11 +112,12 @@ export declare class PCameraManager {
112
112
  initial(width: number, height: number): void;
113
113
  /**
114
114
  * 插入相机数据,创建新的相机对象
115
- * @param inCamera - 相机数据
116
- * @param owner - 所属的相机组件
115
+ * @param name - 相机名称
116
+ * @param data - 相机相关数据
117
+ * @param owner - 相机所属组件
117
118
  * @returns 新的相机对象
118
119
  */
119
- insert(name: string, options: ModelCameraOptions, owner?: ModelCameraComponent): PCamera;
120
+ insert(name: string, data: ModelCameraComponentData, owner?: ModelCameraComponent): PCamera;
120
121
  /**
121
122
  * 插入相机对象
122
123
  * @param camera - 相机对象
@@ -73,6 +73,8 @@ export declare enum PShadowType {
73
73
  variance = 2,
74
74
  expVariance = 3
75
75
  }
76
+ export declare const PBRShaderGUID = "pbr00000000000000000000000000000";
77
+ export declare const UnlitShaderGUID = "unlit000000000000000000000000000";
76
78
  /**
77
79
  * 插件变换类
78
80
  */
@@ -10,3 +10,4 @@ export * from './object';
10
10
  export * from './scene';
11
11
  export * from './shader';
12
12
  export * from './skybox';
13
+ export * from './math';
@@ -1,4 +1,4 @@
1
- import type { ModelLightOptions } from '../index';
1
+ import type { ModelLightComponentData } from '../index';
2
2
  import { Vector2, Vector3 } from './math';
3
3
  import { PLightType } from './common';
4
4
  import { PEntity } from './object';
@@ -42,10 +42,11 @@ export declare class PLight extends PEntity {
42
42
  padding: Vector2;
43
43
  /**
44
44
  * 创建灯光对象
45
- * @param light - 灯光参数
46
- * @param ownerI - 所属灯光组件
45
+ * @param name - 灯光名称
46
+ * @param data - 灯光相关数据
47
+ * @param owner - 所属灯光组件
47
48
  */
48
- constructor(name: string, options: ModelLightOptions, owner?: ModelLightComponent);
49
+ constructor(name: string, data: ModelLightComponentData, owner?: ModelLightComponent);
49
50
  /**
50
51
  * 更新灯光变换
51
52
  */
@@ -100,7 +101,7 @@ export declare class PLightManager {
100
101
  * @param owner - 所属灯光组件
101
102
  * @returns 插入的灯光对象
102
103
  */
103
- insertItem(name: string, inLight: ModelLightOptions, owner?: ModelLightComponent): PLight;
104
+ insertItem(name: string, inLight: ModelLightComponentData, owner?: ModelLightComponent): PLight;
104
105
  /**
105
106
  * 插入灯光对象
106
107
  * @param inLight - 灯光对象