@galacean/effects-plugin-model 1.2.3 → 2.0.0-alpha.1

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 (41) hide show
  1. package/dist/gesture/index.d.ts +5 -4
  2. package/dist/gltf/loader-helper.d.ts +1 -3
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.js +8358 -6785
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +2 -2
  7. package/dist/index.mjs +8357 -6784
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/loader.mjs +10070 -4913
  10. package/dist/loader.mjs.map +1 -1
  11. package/dist/plugin/const.d.ts +3 -0
  12. package/dist/plugin/index.d.ts +0 -2
  13. package/dist/plugin/model-item.d.ts +258 -0
  14. package/dist/plugin/model-plugin.d.ts +91 -18
  15. package/dist/plugin/model-tree-item.d.ts +113 -6
  16. package/dist/plugin/model-tree-plugin.d.ts +9 -8
  17. package/dist/runtime/anim-sampler.d.ts +20 -0
  18. package/dist/runtime/animation.d.ts +179 -26
  19. package/dist/runtime/cache.d.ts +75 -0
  20. package/dist/runtime/camera.d.ts +130 -5
  21. package/dist/runtime/common.d.ts +143 -4
  22. package/dist/runtime/light.d.ts +95 -6
  23. package/dist/runtime/material.d.ts +306 -1
  24. package/dist/runtime/math.d.ts +2 -0
  25. package/dist/runtime/mesh.d.ts +242 -32
  26. package/dist/runtime/object.d.ts +88 -10
  27. package/dist/runtime/scene.d.ts +156 -27
  28. package/dist/runtime/shader-libs/standard-shader-source.d.ts +10 -0
  29. package/dist/runtime/shader-libs/standard-shader.d.ts +16 -0
  30. package/dist/runtime/shader.d.ts +33 -1
  31. package/dist/runtime/skybox.d.ts +233 -9
  32. package/dist/utility/debug-helper.d.ts +14 -0
  33. package/dist/utility/hit-test-helper.d.ts +39 -3
  34. package/dist/utility/plugin-helper.d.ts +665 -14
  35. package/dist/utility/ri-helper.d.ts +67 -0
  36. package/dist/utility/shader-helper.d.ts +55 -0
  37. package/dist/utility/ts-helper.d.ts +6 -0
  38. package/package.json +4 -4
  39. package/dist/plugin/model-tree-vfx-item.d.ts +0 -15
  40. package/dist/plugin/model-vfx-item.d.ts +0 -28
  41. package/dist/runtime/shadow.d.ts +0 -230
@@ -1,51 +1,106 @@
1
- import type { Geometry, Engine, math } from '@galacean/effects';
1
+ import type { Geometry, Engine, math, VFXItemContent, VFXItem, Renderer } from '@galacean/effects';
2
2
  import { spec, Mesh, Material } from '@galacean/effects';
3
- import type { ModelItemMesh, ModelMaterialOptions, ModelPrimitiveOptions } from '../index';
4
- import { PShadowType } from './common';
3
+ import type { ModelMeshContent, ModelMaterialOptions, ModelPrimitiveOptions } from '../index';
5
4
  import { PEntity } from './object';
6
5
  import type { PMaterial } from './material';
7
6
  import { Matrix4, Vector3, Box3 } from './math';
8
7
  import { PSkin, PMorph } from './animation';
9
- import type { PSceneStates } from './scene';
8
+ import type { PSceneManager, PSceneStates } from './scene';
10
9
  import type { PSkybox } from './skybox';
11
- import type { PMaterialShadowBase, PShadowRuntimeOptions } from './shadow';
12
- import type { ModelVFXItem } from '../plugin/model-vfx-item';
13
10
  import { BoxMesh } from '../utility/ri-helper';
14
- import type { ModelTreeVFXItem } from '../plugin';
11
+ import type { ModelMeshComponent } from '../plugin/model-item';
15
12
  type Box3 = math.Box3;
13
+ /**
14
+ * Mesh 类,负责 Mesh 相关的骨骼动画和 PBR 渲染
15
+ */
16
16
  export declare class PMesh extends PEntity {
17
17
  private engine;
18
18
  /**
19
- * 3D 元素父节点
19
+ * 所属的 Mesh 组件
20
+ */
21
+ owner?: ModelMeshComponent;
22
+ /**
23
+ * 父节点索引
20
24
  */
21
25
  parentIndex: number;
22
26
  /**
23
- * 元素的父节点
27
+ * 父元素
24
28
  */
25
- parentItem?: ModelTreeVFXItem;
29
+ parentItem?: VFXItem<VFXItemContent>;
26
30
  /**
27
- * 元素的父节点 Id
31
+ * 父元素索引
28
32
  */
29
33
  parentItemId?: string;
34
+ /**
35
+ * 蒙皮
36
+ */
30
37
  skin?: PSkin;
31
38
  /**
32
39
  * morph 动画状态数据,主要是 weights 数组
33
40
  */
34
41
  morph?: PMorph;
42
+ /**
43
+ * primitive 对象数组
44
+ */
35
45
  primitives: PPrimitive[];
46
+ /**
47
+ * 是否隐藏,默认是隐藏
48
+ */
36
49
  hide: boolean;
50
+ /**
51
+ * 优先级
52
+ */
37
53
  priority: number;
54
+ /**
55
+ * 包围盒
56
+ */
38
57
  boundingBox: Box3;
58
+ /**
59
+ * 是否显示包围盒
60
+ */
39
61
  visBoundingBox: boolean;
62
+ /**
63
+ * 包围盒 Mesh
64
+ */
40
65
  boundingBoxMesh?: BoxMesh;
66
+ /**
67
+ * 是否调用 Build
68
+ */
41
69
  isBuilt: boolean;
70
+ /**
71
+ * 是否销毁
72
+ */
42
73
  isDisposed: boolean;
43
- constructor(engine: Engine, itemMesh: ModelItemMesh, ownerItem?: ModelVFXItem, parentItem?: ModelTreeVFXItem);
44
- build(lightCount: number, uniformSemantics: {
45
- [k: string]: any;
46
- }, skybox?: PSkybox): void;
47
- tick(deltaSeconds: number): void;
48
- addToRenderObjectSet(renderObjectSet: Set<Mesh>): void;
74
+ /**
75
+ * 构造函数,创建 Mesh 对象,并与所属组件和父元素相关联
76
+ * @param engine - 引擎
77
+ * @param name - 名称
78
+ * @param meshContent - Mesh 参数
79
+ * @param owner - 所属的 Mesh 组件
80
+ * @param parentId - 父元素索引
81
+ * @param parent - 父元素
82
+ */
83
+ constructor(engine: Engine, name: string, meshContent: ModelMeshContent, owner?: ModelMeshComponent, parentId?: string, parent?: VFXItem<VFXItemContent>);
84
+ /**
85
+ * 创建 GE 的 Mesh、Geometry 和 Material 对象
86
+ * @param scene - 场景管理器
87
+ * @returns
88
+ */
89
+ build(scene: PSceneManager): void;
90
+ /**
91
+ * 更新变换数据和蒙皮数据
92
+ */
93
+ update(): void;
94
+ /**
95
+ * 渲染 Mesh 对象,需要将内部相关数据传给渲染器
96
+ * @param scene - 场景
97
+ * @param renderer - 渲染器
98
+ */
99
+ render(scene: PSceneManager, renderer: Renderer): void;
100
+ /**
101
+ * 销毁,需要主动释放蒙皮、morph 和 Mesh 等相关的对象
102
+ * @returns
103
+ */
49
104
  dispose(): void;
50
105
  /**
51
106
  * 更新 Morph 动画权重
@@ -55,16 +110,48 @@ export declare class PMesh extends PEntity {
55
110
  * @param weightsArray - Morph 动画的权重数组
56
111
  */
57
112
  updateMorphWeights(weightsArray: Float32Array): void;
58
- updateParentItem(parentItem: ModelTreeVFXItem): void;
59
- updateUniformsForScene(sceneStates: PSceneStates): void;
60
- updateUniformForShadow(shadowOptions: PShadowRuntimeOptions): void;
113
+ /**
114
+ * 更新父 VFX 元素
115
+ * @param parentId - 父元素索引
116
+ * @param parentItem - 父 VFX 元素
117
+ */
118
+ updateParentInfo(parentId: string, parentItem: VFXItem<VFXItemContent>): void;
119
+ /**
120
+ * 根据当前场景状态更新内部材质数据
121
+ * @param scene - 场景管理器
122
+ */
123
+ updateMaterial(scene: PSceneManager): void;
124
+ /**
125
+ * 点击测试,对于编辑器模式会进行精准的点击测试,否则就和内部的包围盒进行测试
126
+ * @param rayOrigin - 射线原点
127
+ * @param rayDirection - 射线方向
128
+ * @returns 交点列表
129
+ */
61
130
  hitTesting(rayOrigin: Vector3, rayDirection: Vector3): Vector3[];
131
+ /**
132
+ * 计算包围盒,根据传入的世界矩阵
133
+ * @param worldMatrix - 世界矩阵
134
+ * @returns
135
+ */
62
136
  computeBoundingBox(worldMatrix: Matrix4): Box3;
63
137
  private getItemBoundingBox;
138
+ /**
139
+ * 获取父节点 id
140
+ * @returns
141
+ */
64
142
  getParentId(): string | undefined;
143
+ /**
144
+ * 是否有蒙皮
145
+ */
65
146
  get hasSkin(): boolean;
147
+ /**
148
+ * 获取 GE Mesh 数组
149
+ */
66
150
  get mriMeshs(): Mesh[];
67
151
  }
152
+ /**
153
+ * Primitive 类,负责 Sub Mesh相关的功能,支持骨骼动画和 PBR 渲染
154
+ */
68
155
  export declare class PPrimitive {
69
156
  private engine;
70
157
  /**
@@ -82,66 +169,189 @@ export declare class PPrimitive {
82
169
  private jointNormalMatList?;
83
170
  private jointMatrixTexture?;
84
171
  private jointNormalMatTexture?;
172
+ /**
173
+ * 名称
174
+ */
85
175
  name: string;
176
+ /**
177
+ * GE Mesh
178
+ */
86
179
  effectsMesh: Mesh;
180
+ /**
181
+ * 渲染优先级
182
+ */
87
183
  effectsPriority: number;
184
+ /**
185
+ * 包围盒
186
+ */
88
187
  boundingBox: math.Box3;
188
+ /**
189
+ * 是否压缩,模式不压缩
190
+ */
89
191
  isCompressed: boolean;
90
- shadowType: PShadowType;
91
- shadowMesh?: Mesh;
92
- shadowMaterial?: PMaterialShadowBase;
93
192
  constructor(engine: Engine);
193
+ /**
194
+ * 创建 Primitive 对象
195
+ * @param options - Primitive 参数
196
+ * @param parent - 所属 Mesh 对象
197
+ */
94
198
  create(options: ModelPrimitiveOptions, parent: PMesh): void;
199
+ /**
200
+ * 创建 GE Mesh、Geometry 和 Material 对象,用于后面的渲染
201
+ * 着色器部分 Uniform 数据来自 uniformSemantics
202
+ * @param lightCount - 灯光数目
203
+ * @param uniformSemantics - Uniform 语义数据
204
+ * @param skybox - 天空盒
205
+ */
95
206
  build(lightCount: number, uniformSemantics: {
96
207
  [k: string]: any;
97
208
  }, skybox?: PSkybox): void;
98
209
  private getFeatureList;
99
- addToRenderObjectSet(renderObjectSet: Set<Mesh>): void;
210
+ /**
211
+ * 销毁,需要释放创建的 GE 对象
212
+ */
100
213
  dispose(): void;
101
- updateUniformsForScene(worldMatrix: Matrix4, nomralMatrix: Matrix4, sceneStates: PSceneStates): void;
102
- updateUniformForShadow(shadowOpts: PShadowRuntimeOptions): void;
214
+ /**
215
+ * 更新内部 GE 材质着色器 Uniform 数据,根据场景状态
216
+ * @param worldMatrix - 世界矩阵
217
+ * @param nomralMatrix - 法线矩阵
218
+ * @param sceneStates - 场景状态
219
+ */
220
+ updateMaterial(worldMatrix: Matrix4, nomralMatrix: Matrix4, sceneStates: PSceneStates): void;
221
+ /**
222
+ * 点击测试,先进行简单的包围合测试,然后再计算精准的点击测试,这个测试非常耗时不要在移动端上使用
223
+ * @param newOrigin - 射线原点
224
+ * @param newDirection - 射线方向
225
+ * @param worldMatrix - 世界矩阵
226
+ * @param invWorldMatrix - 逆世界矩阵
227
+ * @returns 射线的 t 参数
228
+ */
103
229
  hitTesting(newOrigin: Vector3, newDirection: Vector3, worldMatrix: Matrix4, invWorldMatrix: Matrix4): number | undefined;
230
+ /**
231
+ * 计算包围盒
232
+ * @param inverseWorldMatrix - 逆世界矩阵
233
+ * @returns
234
+ */
104
235
  computeBoundingBox(inverseWorldMatrix: Matrix4): Box3;
105
236
  /**
106
- * 渲染输出模式转成 Shader 中的宏定义
107
- *
237
+ * 渲染输出模式转成着色器中的宏定义
108
238
  * @param mode - 渲染输出模式
109
- * @returns none 模式返回 undefined,其他模式返回相应宏定义
239
+ * @returns 返回相应的宏定义
110
240
  */
111
241
  getRenderMode3DDefine(mode: spec.RenderMode3D): string | undefined;
112
242
  private updateUniformsByAnimation;
113
243
  private updateUniformsByScene;
244
+ /**
245
+ * 是否有蒙皮
246
+ * @returns
247
+ */
114
248
  hasSkin(): boolean;
249
+ /**
250
+ * 获取 GE 几何体
251
+ * @returns
252
+ */
115
253
  getEffectsGeometry(): Geometry;
254
+ /**
255
+ * 设置几何体
256
+ * @param val - 插件或 GE 几何体
257
+ */
116
258
  setGeometry(val: PGeometry | Geometry): void;
259
+ /**
260
+ * 设置材质
261
+ * @param val - 插件材质对象或材质参数
262
+ */
117
263
  setMaterial(val: PMaterial | ModelMaterialOptions): void;
264
+ /**
265
+ * 获取 GE 材质
266
+ * @returns
267
+ */
118
268
  getModelMaterial(): Material;
119
- getShadowModelMaterial(): Material | undefined;
120
- isEnableShadow(): boolean;
269
+ /**
270
+ * 是否无光照材质
271
+ * @returns
272
+ */
121
273
  isUnlitMaterial(): boolean;
122
274
  /**
123
275
  * 是否有 Morph 动画:
124
276
  * 需要注意 Morph 对象存在,但还是没有 Morph 动画的情况
125
- *
126
277
  * @returns 返回是否有 Morph 动画
127
278
  */
128
279
  hasMorph(): boolean;
280
+ /**
281
+ * 获取世界坐标下的包围盒
282
+ * @returns
283
+ */
129
284
  getWorldBoundingBox(): Box3;
130
285
  }
286
+ /**
287
+ * 3D 几何类
288
+ */
131
289
  export declare class PGeometry {
132
290
  geometry: Geometry;
291
+ /**
292
+ * 属性名称数组
293
+ */
133
294
  attributeNames: string[];
295
+ /**
296
+ * 创建 3D 几何体,根据 GE 几何体
297
+ * @param geometry - GE 几何体
298
+ */
134
299
  constructor(geometry: Geometry);
300
+ /**
301
+ * 销毁
302
+ */
135
303
  dispose(): void;
304
+ /**
305
+ * 是否有某个属性
306
+ * @param name - 属性名
307
+ * @returns
308
+ */
136
309
  hasAttribute(name: string): boolean;
310
+ /**
311
+ * 设置隐藏,通过修改几何体中的渲染数目
312
+ * @param hide - 隐藏值
313
+ */
137
314
  setHide(hide: boolean): void;
315
+ /**
316
+ * 是否压缩格式
317
+ * @returns
318
+ */
138
319
  isCompressed(): boolean;
320
+ /**
321
+ * 是否有位置属性
322
+ * @returns
323
+ */
139
324
  hasPositions(): boolean;
325
+ /**
326
+ * 是否有法线属性
327
+ * @returns
328
+ */
140
329
  hasNormals(): boolean;
330
+ /**
331
+ * 是否有切线属性
332
+ * @returns
333
+ */
141
334
  hasTangents(): boolean;
335
+ /**
336
+ * 是否有纹理坐标属性
337
+ * @param index - 纹理坐标索引
338
+ * @returns
339
+ */
142
340
  hasUVCoords(index: number): boolean;
341
+ /**
342
+ * 是否有颜色属性
343
+ * @returns
344
+ */
143
345
  hasColors(): boolean;
346
+ /**
347
+ * 是否有关节点属性
348
+ * @returns
349
+ */
144
350
  hasJoints(): boolean;
351
+ /**
352
+ * 是否有权重属性
353
+ * @returns
354
+ */
145
355
  hasWeights(): boolean;
146
356
  }
147
357
  export {};
@@ -1,46 +1,124 @@
1
- import type { spec, Mesh, math } from '@galacean/effects';
2
- import type { ModelVFXItem } from '../plugin/model-vfx-item';
1
+ import type { spec, Renderer } from '@galacean/effects';
3
2
  import type { BaseTransform } from '../index';
4
3
  import type { Quaternion, Euler, Vector3, Matrix4 } from './math';
5
4
  import { PObjectType, PTransform, PCoordinate } from './common';
6
- import type { PSceneStates } from './scene';
7
- type Euler = math.Euler;
5
+ import type { PSceneManager } from './scene';
6
+ /**
7
+ * 抽象对象类,提供公共的成员变量和成员函数
8
+ */
8
9
  export declare abstract class PObject {
10
+ /**
11
+ * 名称
12
+ */
9
13
  name: string;
14
+ /**
15
+ * 类型
16
+ */
10
17
  type: PObjectType;
18
+ /**
19
+ * 销毁
20
+ */
11
21
  dispose(): void;
22
+ /**
23
+ * 是否空对象
24
+ * @returns
25
+ */
12
26
  isNone(): boolean;
27
+ /**
28
+ * 是否有效,也就是类型不是 PObjectType.none
29
+ * @returns
30
+ */
13
31
  isValid(): boolean;
14
32
  protected genName(name: string): string;
15
33
  }
34
+ /**
35
+ * 抽象实体类,支持可见性、变换和所属 VFX 元素
36
+ */
16
37
  export declare abstract class PEntity extends PObject {
17
38
  private _visible;
18
39
  private _transform;
40
+ /**
41
+ * 是否删除
42
+ */
19
43
  deleted: boolean;
20
- ownerItem?: ModelVFXItem;
21
- tick(deltaSeconds: number): void;
44
+ /**
45
+ * 逻辑更新
46
+ */
47
+ update(): void;
48
+ /**
49
+ * 渲染对象
50
+ * @param scene - 场景管理器
51
+ * @param renderer 渲染器
52
+ */
53
+ render(scene: PSceneManager, renderer: Renderer): void;
54
+ /**
55
+ * 外部改变可见性时的回调
56
+ * @param visible - 可见性
57
+ */
22
58
  onVisibleChanged(visible: boolean): void;
23
- addToRenderObjectSet(renderObjectSet: Set<Mesh>): void;
24
- updateUniformsForScene(sceneStates: PSceneStates): void;
25
59
  /**
26
60
  * 仅标记不可见和删除状态,但不进行 WebGL 相关资源的释放
27
61
  * 最终释放 WebGL 相关资源是在 plugin destroy 的时候
28
62
  */
29
- onEntityRemoved(): void;
63
+ dispose(): void;
64
+ /**
65
+ * 获取可见性,如果实体非法也是不可见
66
+ */
30
67
  get visible(): boolean;
68
+ /**
69
+ * 设置可见性
70
+ */
31
71
  set visible(val: boolean);
72
+ /**
73
+ * 获取变换
74
+ */
32
75
  get transform(): PTransform;
76
+ /**
77
+ * 设置变换,可以传入插件变换对象或变换参数
78
+ */
33
79
  set transform(val: PTransform | BaseTransform);
80
+ /**
81
+ * 获取位移
82
+ */
34
83
  get translation(): Vector3;
84
+ /**
85
+ * 设置位移
86
+ */
35
87
  set translation(val: Vector3 | spec.vec3);
88
+ /**
89
+ * 获取位置
90
+ */
36
91
  get position(): Vector3;
92
+ /**
93
+ * 设置位置
94
+ */
37
95
  set position(val: Vector3 | spec.vec3);
96
+ /**
97
+ * 获取旋转
98
+ */
38
99
  get rotation(): Quaternion;
100
+ /**
101
+ * 设置旋转
102
+ */
39
103
  set rotation(val: Quaternion | Euler | Vector3 | spec.vec4 | spec.vec3);
104
+ /**
105
+ * 获取缩放
106
+ */
40
107
  get scale(): Vector3;
108
+ /**
109
+ * 设置缩放
110
+ */
41
111
  set scale(val: Vector3 | spec.vec3);
112
+ /**
113
+ * 获取矩阵
114
+ */
42
115
  get matrix(): Matrix4;
116
+ /**
117
+ * 设置矩阵
118
+ */
43
119
  set matrix(val: Matrix4);
120
+ /**
121
+ * 获取坐标系
122
+ */
44
123
  get coordinate(): PCoordinate;
45
124
  }
46
- export {};