@galacean/effects-plugin-model 2.0.3 → 2.1.0-alpha.0

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 +1,294 @@
1
+ import type { Engine, HitTestBoxParams, HitTestCustomParams, HitTestSphereParams, Renderer, VFXItem } from '@galacean/effects';
2
+ import { Behaviour, RendererComponent, AnimationClip } from '@galacean/effects';
3
+ import type { ModelCameraComponentData, ModelItemBounding, ModelLightComponentData, ModelMeshComponentData, ModelSkyboxComponentData, AnimationComponentData } from '../index';
4
+ import type { PSceneManager } from '../runtime';
5
+ import { PCamera, PLight, PMesh, PSkybox } from '../runtime';
6
+ import type { Euler } from '../runtime/math';
7
+ import { Vector3 } from '../runtime/math';
8
+ /**
9
+ * 插件 Mesh 组件类,支持 3D Mesh 渲染能力
10
+ * @since 2.0.0
11
+ */
12
+ export declare class ModelMeshComponent extends RendererComponent {
13
+ /**
14
+ * 内部 Mesh 对象
15
+ */
16
+ content: PMesh;
17
+ /**
18
+ * 参数
19
+ */
20
+ data?: ModelMeshComponentData;
21
+ /**
22
+ * 包围盒
23
+ */
24
+ bounding?: ModelItemBounding;
25
+ /**
26
+ * 场景管理器
27
+ */
28
+ sceneManager?: PSceneManager;
29
+ /**
30
+ * morph 动画权重
31
+ */
32
+ morphWeights: number[];
33
+ /**
34
+ * 构造函数,只保存传入参数,不在这里创建内部对象
35
+ * @param engine - 引擎
36
+ * @param data - Mesh 参数
37
+ */
38
+ constructor(engine: Engine, data?: ModelMeshComponentData);
39
+ /**
40
+ * 组件开始,需要创建内部对象,更新父元素信息和添加到场景管理器中
41
+ */
42
+ onStart(): void;
43
+ /**
44
+ * 组件更新,更新内部对象状态
45
+ * @param dt - 更新间隔
46
+ */
47
+ onUpdate(dt: number): void;
48
+ /**
49
+ * 组件晚更新,晚更新内部对象状态
50
+ * @param dt - 更新间隔
51
+ */
52
+ onLateUpdate(dt: number): void;
53
+ /**
54
+ * 组件渲染,需要检查可见性
55
+ * @param renderer - 渲染器
56
+ * @returns
57
+ */
58
+ render(renderer: Renderer): void;
59
+ /**
60
+ * 组件销毁,需要重场景管理器中删除
61
+ */
62
+ onDestroy(): void;
63
+ /**
64
+ * 反序列化,记录传入参数
65
+ * @param data - 组件参数
66
+ */
67
+ fromData(data: ModelMeshComponentData): void;
68
+ /**
69
+ * 创建内部对象
70
+ */
71
+ createContent(): void;
72
+ /**
73
+ * 设置当前 Mesh 的可见性。
74
+ * @param visible - true:可见,false:不可见
75
+ */
76
+ setVisible(visible: boolean): void;
77
+ /**
78
+ * 获取当前 Mesh 的可见性。
79
+ */
80
+ getVisible(): boolean;
81
+ /**
82
+ * 获取点击测试参数,根据元素包围盒进行相交测试,Mesh 对象会进行更加精确的点击测试
83
+ * @param force - 是否强制进行点击测试
84
+ * @returns 点击测试参数
85
+ */
86
+ getHitTestParams: (force?: boolean) => HitTestBoxParams | HitTestSphereParams | HitTestCustomParams | undefined;
87
+ /**
88
+ * 计算元素包围盒,只针对 Mesh 对象
89
+ * @returns 包围盒
90
+ */
91
+ computeBoundingBox(): ModelItemBounding | undefined;
92
+ }
93
+ /**
94
+ * 插件天空盒组件类,支持 3D 天空盒渲染能力
95
+ * @since 2.0.0
96
+ */
97
+ export declare class ModelSkyboxComponent extends RendererComponent {
98
+ /**
99
+ * 内部天空盒对象
100
+ */
101
+ content: PSkybox;
102
+ /**
103
+ * 天空盒参数
104
+ */
105
+ data?: ModelSkyboxComponentData;
106
+ /**
107
+ * 场景管理器
108
+ */
109
+ sceneManager?: PSceneManager;
110
+ /**
111
+ * 构造函数,只保存传入参数,不在这里创建内部对象
112
+ * @param engine - 引擎
113
+ * @param data - Mesh 参数
114
+ */
115
+ constructor(engine: Engine, data?: ModelSkyboxComponentData);
116
+ /**
117
+ * 组件开始,需要创建内部对象和添加到场景管理器中
118
+ */
119
+ onStart(): void;
120
+ /**
121
+ * 组件渲染,需要检查可见性
122
+ * @param renderer - 渲染器
123
+ * @returns
124
+ */
125
+ render(renderer: Renderer): void;
126
+ /**
127
+ * 组件销毁,需要重场景管理器中删除
128
+ */
129
+ onDestroy(): void;
130
+ /**
131
+ * 反序列化,记录传入参数
132
+ * @param data - 组件参数
133
+ */
134
+ fromData(data: ModelSkyboxComponentData): void;
135
+ /**
136
+ * 创建内部对象
137
+ */
138
+ createContent(): void;
139
+ /**
140
+ * 设置当前可见性。
141
+ * @param visible - true:可见,false:不可见
142
+ */
143
+ setVisible(visible: boolean): void;
144
+ /**
145
+ * 获取当前可见性。
146
+ */
147
+ getVisible(): boolean;
148
+ }
149
+ /**
150
+ * 插件灯光组件类,支持 3D 灯光能力
151
+ * @since 2.0.0
152
+ */
153
+ export declare class ModelLightComponent extends Behaviour {
154
+ /**
155
+ * 内部灯光对象
156
+ */
157
+ content: PLight;
158
+ /**
159
+ * 参数
160
+ */
161
+ data?: ModelLightComponentData;
162
+ /**
163
+ * 构造函数,只保存传入参数,不在这里创建内部对象
164
+ * @param engine - 引擎
165
+ * @param data - Mesh 参数
166
+ */
167
+ constructor(engine: Engine, data?: ModelLightComponentData);
168
+ /**
169
+ * 组件开始,需要创建内部对象和添加到场景管理器中
170
+ */
171
+ onStart(): void;
172
+ /**
173
+ * 组件更新,更新内部对象状态
174
+ * @param dt - 更新间隔
175
+ */
176
+ onUpdate(dt: number): void;
177
+ /**
178
+ * 组件销毁
179
+ */
180
+ onDestroy(): void;
181
+ /**
182
+ * 反序列化,记录传入参数
183
+ * @param data - 组件参数
184
+ */
185
+ fromData(data: ModelLightComponentData): void;
186
+ /**
187
+ * 创建内部对象
188
+ */
189
+ createContent(): void;
190
+ /**
191
+ * 设置当前可见性。
192
+ * @param visible - true:可见,false:不可见
193
+ */
194
+ setVisible(visible: boolean): void;
195
+ /**
196
+ * 获取当前 Mesh 的可见性。
197
+ */
198
+ getVisible(): boolean;
199
+ }
200
+ /**
201
+ * 插件相机组件类,支持 3D 相机能力
202
+ * @since 2.0.0
203
+ */
204
+ export declare class ModelCameraComponent extends Behaviour {
205
+ /**
206
+ * 内部相机对象
207
+ */
208
+ content: PCamera;
209
+ /**
210
+ * 参数
211
+ */
212
+ data?: ModelCameraComponentData;
213
+ /**
214
+ * 构造函数,只保存传入参数,不在这里创建内部对象
215
+ * @param engine - 引擎
216
+ * @param data - Mesh 参数
217
+ */
218
+ constructor(engine: Engine, data?: ModelCameraComponentData);
219
+ /**
220
+ * 组件开始,需要创建内部对象和添加到场景管理器中
221
+ */
222
+ onStart(): void;
223
+ /**
224
+ * 组件更新,更新内部对象状态
225
+ * @param dt - 更新间隔
226
+ */
227
+ onUpdate(dt: number): void;
228
+ /**
229
+ * 组件销毁
230
+ */
231
+ onDestroy(): void;
232
+ /**
233
+ * 反序列化,记录传入参数
234
+ * @param data - 组件参数
235
+ */
236
+ fromData(data: ModelCameraComponentData): void;
237
+ /**
238
+ * 创建内部对象
239
+ */
240
+ createContent(): void;
241
+ /**
242
+ * 更新合成主相机,更加当前相机元素状态
243
+ */
244
+ updateMainCamera(): void;
245
+ /**
246
+ * 设置变换
247
+ * @param position - 位置
248
+ * @param rotation - 旋转
249
+ */
250
+ setTransform(position?: Vector3, rotation?: Euler): void;
251
+ }
252
+ /**
253
+ * 插件动画组件类,支持 3D 动画能力
254
+ * @since 2.0.0
255
+ */
256
+ export declare class AnimationComponent extends Behaviour {
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
+ onStart(): void;
273
+ /**
274
+ * 组件更新,更新内部对象状态
275
+ * @param dt - 更新间隔
276
+ */
277
+ onUpdate(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
+ }
1
294
  export {};
@@ -1,6 +1,6 @@
1
- import type { VFXItem } from '@galacean/effects';
2
- import { Transform } from '@galacean/effects';
3
- import type { ModelTreeOptions } from '../index';
1
+ import type { Engine, VFXItem } from '@galacean/effects';
2
+ import { Behaviour, Transform } from '@galacean/effects';
3
+ import type { ModelTreeContent, ModelTreeOptions } from '../index';
4
4
  import { PAnimationManager } from '../runtime';
5
5
  /**
6
6
  * 场景树节点描述
@@ -82,3 +82,51 @@ export declare class ModelTreeItem {
82
82
  dispose(): void;
83
83
  private build;
84
84
  }
85
+ /**
86
+ * 插件场景树组件类,实现 3D 场景树功能
87
+ * @since 2.0.0
88
+ */
89
+ export declare class ModelTreeComponent extends Behaviour {
90
+ /**
91
+ * 内部节点树元素
92
+ */
93
+ content: ModelTreeItem;
94
+ /**
95
+ * 参数
96
+ */
97
+ options?: ModelTreeContent;
98
+ /**
99
+ * 构造函数,创建节点树元素
100
+ * @param engine
101
+ * @param options
102
+ */
103
+ constructor(engine: Engine, options?: ModelTreeContent);
104
+ /**
105
+ * 反序列化,保存入参和创建节点树元素
106
+ * @param options
107
+ */
108
+ fromData(options: ModelTreeContent): void;
109
+ /**
110
+ * 组件开始,查询合成中场景管理器并设置到动画管理器中
111
+ */
112
+ onStart(): void;
113
+ /**
114
+ * 组件更新,内部对象更新
115
+ * @param dt
116
+ */
117
+ onUpdate(dt: number): void;
118
+ /**
119
+ * 组件销毁,内部对象销毁
120
+ */
121
+ onDestroy(): void;
122
+ /**
123
+ * 创建内部场景树元素
124
+ */
125
+ createContent(): void;
126
+ /**
127
+ * 获取元素的变换
128
+ * @param itemId - 元素索引
129
+ * @returns
130
+ */
131
+ getNodeTransform(itemId: string): Transform;
132
+ }
package/dist/weapp.js CHANGED
@@ -4443,7 +4443,7 @@ exports.ModelMeshComponent = /*#__PURE__*/ function(RendererComponent) {
4443
4443
  var _proto = ModelMeshComponent.prototype;
4444
4444
  /**
4445
4445
  * 组件开始,需要创建内部对象,更新父元素信息和添加到场景管理器中
4446
- */ _proto.start = function start() {
4446
+ */ _proto.onStart = function onStart() {
4447
4447
  var _this_sceneManager;
4448
4448
  this.sceneManager = getSceneManager(this);
4449
4449
  this.createContent();
@@ -4459,7 +4459,7 @@ exports.ModelMeshComponent = /*#__PURE__*/ function(RendererComponent) {
4459
4459
  /**
4460
4460
  * 组件更新,更新内部对象状态
4461
4461
  * @param dt - 更新间隔
4462
- */ _proto.update = function update(dt) {
4462
+ */ _proto.onUpdate = function onUpdate(dt) {
4463
4463
  if (this.sceneManager) {
4464
4464
  this.content.build(this.sceneManager);
4465
4465
  }
@@ -4468,7 +4468,7 @@ exports.ModelMeshComponent = /*#__PURE__*/ function(RendererComponent) {
4468
4468
  /**
4469
4469
  * 组件晚更新,晚更新内部对象状态
4470
4470
  * @param dt - 更新间隔
4471
- */ _proto.lateUpdate = function lateUpdate(dt) {
4471
+ */ _proto.onLateUpdate = function onLateUpdate(dt) {
4472
4472
  this.content.lateUpdate();
4473
4473
  };
4474
4474
  /**
@@ -4566,7 +4566,7 @@ exports.ModelSkyboxComponent = /*#__PURE__*/ function(RendererComponent) {
4566
4566
  var _proto = ModelSkyboxComponent.prototype;
4567
4567
  /**
4568
4568
  * 组件开始,需要创建内部对象和添加到场景管理器中
4569
- */ _proto.start = function start() {
4569
+ */ _proto.onStart = function onStart() {
4570
4570
  var _this_sceneManager;
4571
4571
  this.createContent();
4572
4572
  this.item.type = VFX_ITEM_TYPE_3D;
@@ -4640,7 +4640,7 @@ exports.ModelLightComponent = /*#__PURE__*/ function(Behaviour) {
4640
4640
  var _proto = ModelLightComponent.prototype;
4641
4641
  /**
4642
4642
  * 组件开始,需要创建内部对象和添加到场景管理器中
4643
- */ _proto.start = function start() {
4643
+ */ _proto.onStart = function onStart() {
4644
4644
  this.createContent();
4645
4645
  this.item.type = VFX_ITEM_TYPE_3D;
4646
4646
  var scene = getSceneManager(this);
@@ -4650,7 +4650,7 @@ exports.ModelLightComponent = /*#__PURE__*/ function(Behaviour) {
4650
4650
  /**
4651
4651
  * 组件更新,更新内部对象状态
4652
4652
  * @param dt - 更新间隔
4653
- */ _proto.update = function update(dt) {
4653
+ */ _proto.onUpdate = function onUpdate(dt) {
4654
4654
  this.content.update();
4655
4655
  };
4656
4656
  /**
@@ -4705,7 +4705,7 @@ exports.ModelCameraComponent = /*#__PURE__*/ function(Behaviour) {
4705
4705
  var _proto = ModelCameraComponent.prototype;
4706
4706
  /**
4707
4707
  * 组件开始,需要创建内部对象和添加到场景管理器中
4708
- */ _proto.start = function start() {
4708
+ */ _proto.onStart = function onStart() {
4709
4709
  this.createContent();
4710
4710
  this.item.type = VFX_ITEM_TYPE_3D;
4711
4711
  var scene = getSceneManager(this);
@@ -4715,7 +4715,7 @@ exports.ModelCameraComponent = /*#__PURE__*/ function(Behaviour) {
4715
4715
  /**
4716
4716
  * 组件更新,更新内部对象状态
4717
4717
  * @param dt - 更新间隔
4718
- */ _proto.update = function update(dt) {
4718
+ */ _proto.onUpdate = function onUpdate(dt) {
4719
4719
  this.content.update();
4720
4720
  this.updateMainCamera();
4721
4721
  };
@@ -4786,14 +4786,14 @@ exports.AnimationComponent = /*#__PURE__*/ function(Behaviour) {
4786
4786
  var _proto = AnimationComponent.prototype;
4787
4787
  /**
4788
4788
  * 组件开始,需要创建内部对象和添加到场景管理器中
4789
- */ _proto.start = function start() {
4789
+ */ _proto.onStart = function onStart() {
4790
4790
  this.elapsedTime = 0;
4791
4791
  this.item.type = VFX_ITEM_TYPE_3D;
4792
4792
  };
4793
4793
  /**
4794
4794
  * 组件更新,更新内部对象状态
4795
4795
  * @param dt - 更新间隔
4796
- */ _proto.update = function update(dt) {
4796
+ */ _proto.onUpdate = function onUpdate(dt) {
4797
4797
  this.elapsedTime += dt * 0.001;
4798
4798
  if (this.animation >= 0 && this.animation < this.clips.length) {
4799
4799
  this.clips[this.animation].sampleAnimation(this.item, this.elapsedTime);
@@ -9771,7 +9771,7 @@ exports.ModelPluginComponent = /*#__PURE__*/ function(Behaviour) {
9771
9771
  /**
9772
9772
  * 组件后更新,合成相机和场景管理器更新
9773
9773
  * @param dt - 更新间隔
9774
- */ _proto.lateUpdate = function lateUpdate(dt) {
9774
+ */ _proto.onLateUpdate = function onLateUpdate(dt) {
9775
9775
  var composition = this.item.composition;
9776
9776
  if (this.autoAdjustScene && this.scene.tickCount == 1) {
9777
9777
  var _composition_items;
@@ -10061,7 +10061,7 @@ exports.ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
10061
10061
  };
10062
10062
  /**
10063
10063
  * 组件开始,查询合成中场景管理器并设置到动画管理器中
10064
- */ _proto.start = function start() {
10064
+ */ _proto.onStart = function onStart() {
10065
10065
  this.item.type = EFFECTS.spec.ItemType.tree;
10066
10066
  this.content.baseTransform.setValid(true);
10067
10067
  var sceneManager = getSceneManager(this);
@@ -10072,7 +10072,7 @@ exports.ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
10072
10072
  /**
10073
10073
  * 组件更新,内部对象更新
10074
10074
  * @param dt
10075
- */ _proto.update = function update(dt) {
10075
+ */ _proto.onUpdate = function onUpdate(dt) {
10076
10076
  var // this.timeline?.getRenderData(time, true);
10077
10077
  // TODO: 需要使用lifetime
10078
10078
  _this_content;
@@ -13794,7 +13794,7 @@ var GLTFHelper = /*#__PURE__*/ function() {
13794
13794
 
13795
13795
  EFFECTS.registerPlugin("tree", ModelTreePlugin, EFFECTS.VFXItem, true);
13796
13796
  EFFECTS.registerPlugin("model", ModelPlugin, EFFECTS.VFXItem);
13797
- var version = "2.0.3";
13797
+ var version = "2.1.0-alpha.0";
13798
13798
  EFFECTS.logger.info("Plugin model version: " + version + ".");
13799
13799
  if (version !== EFFECTS__namespace.version) {
13800
13800
  console.error("注意:请统一 Model 插件与 Player 版本,不统一的版本混用会有不可预知的后果!", "\nAttention: Please ensure the Model plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!");