@galacean/effects-plugin-model 2.8.0-alpha.1 → 2.8.0-alpha.2

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/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects player model plugin
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 飂兮
6
- * Version: v2.8.0-alpha.1
6
+ * Version: v2.8.0-alpha.2
7
7
  */
8
8
 
9
9
  import * as EFFECTS from '@galacean/effects';
@@ -9166,8 +9166,55 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
9166
9166
  return _this;
9167
9167
  }
9168
9168
  var _proto = ModelPlugin.prototype;
9169
- _proto.precompile = function precompile(compositions, renderer) {
9170
- var isWebGL2 = renderer.engine.gpuCapability.level === 2;
9169
+ _proto.processAssets = function processAssets(scene, options) {
9170
+ return _async_to_generator(function() {
9171
+ return __generator(this, function(_state) {
9172
+ switch(_state.label){
9173
+ case 0:
9174
+ return [
9175
+ 4,
9176
+ CompositionCache.loadStaticResources()
9177
+ ];
9178
+ case 1:
9179
+ _state.sent();
9180
+ return [
9181
+ 2
9182
+ ];
9183
+ }
9184
+ });
9185
+ })();
9186
+ };
9187
+ /**
9188
+ * 整个 load 阶段都不会创建 GL 相关的对象,只创建 JS 对象
9189
+ * @param scene - 场景
9190
+ * @param options - 加载选项
9191
+ */ _proto.prepareResource = function prepareResource(scene, options, engine) {
9192
+ var _options_pluginData;
9193
+ if (options.pluginData !== undefined) {
9194
+ var keyList = [
9195
+ "compatibleMode",
9196
+ "renderSkybox",
9197
+ "visBoundingBox",
9198
+ "autoAdjustScene",
9199
+ "enableDynamicSort",
9200
+ "renderMode3D",
9201
+ "renderMode3DUVGridSize"
9202
+ ];
9203
+ var pluginData = options.pluginData;
9204
+ keyList.forEach(function(key) {
9205
+ return scene.storage[key] = pluginData[key];
9206
+ });
9207
+ }
9208
+ var _options_env;
9209
+ //
9210
+ var runtimeEnv = (_options_env = options.env) != null ? _options_env : "";
9211
+ scene.storage["runtimeEnv"] = runtimeEnv;
9212
+ var _options_pluginData_compatibleMode;
9213
+ var compatibleMode = (_options_pluginData_compatibleMode = (_options_pluginData = options.pluginData) == null ? void 0 : _options_pluginData["compatibleMode"]) != null ? _options_pluginData_compatibleMode : "gltf";
9214
+ //
9215
+ PluginHelper.preprocessScene(scene, runtimeEnv, compatibleMode);
9216
+ // Add PBR and Unlit shader data
9217
+ var isWebGL2 = engine.gpuCapability.level === 2;
9171
9218
  var pbrShaderCode = fetchPBRShaderCode();
9172
9219
  var unlitShaderCode = fetchUnlitShaderCode();
9173
9220
  var pbrShaderData = {
@@ -9188,25 +9235,14 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
9188
9235
  // @ts-expect-error
9189
9236
  glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
9190
9237
  };
9191
- renderer.engine.addEffectsObjectData(pbrShaderData);
9192
- renderer.engine.addEffectsObjectData(unlitShaderData);
9193
- return Promise.resolve();
9238
+ engine.addEffectsObjectData(pbrShaderData);
9239
+ engine.addEffectsObjectData(unlitShaderData);
9194
9240
  };
9195
9241
  /**
9196
9242
  * 创建 3D 场景管理器和缓存器
9197
9243
  * @param composition - 合成
9198
9244
  * @param scene - 场景
9199
9245
  */ _proto.onCompositionConstructed = function onCompositionConstructed(composition, scene) {
9200
- this.sceneParams = scene.storage;
9201
- var engine = composition.renderer.engine;
9202
- this.cache = new CompositionCache(engine);
9203
- this.cache.setup(false);
9204
- };
9205
- /**
9206
- * 每次播放都会执行,包括重播,所以这里执行“小的销毁”和新的初始化
9207
- * @param composition - 合成
9208
- * @param renderFrame - 渲染帧
9209
- */ _proto.onCompositionReset = function onCompositionReset(composition, renderFrame) {
9210
9246
  var props = {
9211
9247
  id: "ModelPluginItem",
9212
9248
  name: "ModelPluginItem",
@@ -9215,72 +9251,14 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
9215
9251
  };
9216
9252
  var item = new VFXItem(composition.getEngine(), props);
9217
9253
  composition.addItem(item);
9218
- //
9219
- var comp = item.addComponent(ModelPluginComponent);
9220
- comp.fromData({
9221
- cache: this.cache
9222
- });
9223
- comp.initial(this.sceneParams);
9224
- };
9225
- /**
9226
- * 合成销毁,同时销毁 3D 场景对象和缓存
9227
- * @param composition - 合成
9228
- */ _proto.onCompositionDestroyed = function onCompositionDestroyed(composition) {
9229
- this.cache.dispose();
9230
- // @ts-expect-error
9231
- this.cache = null;
9232
- // @ts-expect-error
9233
- this.sceneParams = null;
9234
- };
9235
- /**
9236
- * 整个 load 阶段都不会创建 GL 相关的对象,只创建 JS 对象
9237
- * @param scene - 场景
9238
- * @param options - 加载选项
9239
- */ ModelPlugin.prepareResource = function prepareResource(scene, options) {
9240
- return _async_to_generator(function() {
9241
- var _options_pluginData, keyList, pluginData, _options_env, runtimeEnv, _options_pluginData_compatibleMode, compatibleMode;
9242
- return __generator(this, function(_state) {
9243
- switch(_state.label){
9244
- case 0:
9245
- if (options.pluginData !== undefined) {
9246
- keyList = [
9247
- "compatibleMode",
9248
- "renderSkybox",
9249
- "visBoundingBox",
9250
- "autoAdjustScene",
9251
- "enableDynamicSort",
9252
- "renderMode3D",
9253
- "renderMode3DUVGridSize"
9254
- ];
9255
- pluginData = options.pluginData;
9256
- keyList.forEach(function(key) {
9257
- return scene.storage[key] = pluginData[key];
9258
- });
9259
- }
9260
- //
9261
- runtimeEnv = (_options_env = options.env) != null ? _options_env : "";
9262
- scene.storage["runtimeEnv"] = runtimeEnv;
9263
- compatibleMode = (_options_pluginData_compatibleMode = (_options_pluginData = options.pluginData) == null ? void 0 : _options_pluginData["compatibleMode"]) != null ? _options_pluginData_compatibleMode : "gltf";
9264
- //
9265
- PluginHelper.preprocessScene(scene, runtimeEnv, compatibleMode);
9266
- return [
9267
- 4,
9268
- CompositionCache.loadStaticResources()
9269
- ];
9270
- case 1:
9271
- _state.sent();
9272
- return [
9273
- 2
9274
- ];
9275
- }
9276
- });
9277
- })();
9254
+ var modelPluginComponent = item.addComponent(ModelPluginComponent);
9255
+ modelPluginComponent.sceneParams = scene.storage;
9278
9256
  };
9279
9257
  return ModelPlugin;
9280
9258
  }(AbstractPlugin);
9281
9259
  var ModelPluginComponent = /*#__PURE__*/ function(Behaviour) {
9282
9260
  _inherits(ModelPluginComponent, Behaviour);
9283
- function ModelPluginComponent(engine, options) {
9261
+ function ModelPluginComponent(engine) {
9284
9262
  var _this;
9285
9263
  _this = Behaviour.call(this, engine) || this;
9286
9264
  _this.runtimeEnv = PLAYER_OPTIONS_ENV_EDITOR;
@@ -9300,12 +9278,15 @@ var ModelPluginComponent = /*#__PURE__*/ function(Behaviour) {
9300
9278
  * UV 渲染模式中,指定棋盘格的大小,相对于大小为 1 的纹理
9301
9279
  * 取值范围(0, 1)
9302
9280
  */ _this.renderMode3DUVGridSize = 1 / 16;
9303
- if (options) {
9304
- _this.fromData(options);
9305
- }
9306
9281
  return _this;
9307
9282
  }
9308
9283
  var _proto = ModelPluginComponent.prototype;
9284
+ _proto.onAwake = function onAwake() {
9285
+ this.cache = new CompositionCache(this.engine);
9286
+ this.cache.setup(false);
9287
+ this.scene = new PSceneManager(this.engine);
9288
+ this.initial(this.sceneParams);
9289
+ };
9309
9290
  /**
9310
9291
  * 组件后更新,合成相机和场景管理器更新
9311
9292
  * @param dt - 更新间隔
@@ -9361,20 +9342,11 @@ var ModelPluginComponent = /*#__PURE__*/ function(Behaviour) {
9361
9342
  this.scene.dispose();
9362
9343
  // @ts-expect-error
9363
9344
  this.scene = null;
9345
+ this.cache.dispose();
9364
9346
  // @ts-expect-error
9365
9347
  this.cache = null;
9366
9348
  };
9367
9349
  /**
9368
- * 反序列化,创建场景管理器
9369
- * @param date - 组件参数
9370
- */ _proto.fromData = function fromData(data) {
9371
- Behaviour.prototype.fromData.call(this, data);
9372
- //
9373
- var options = data;
9374
- this.cache = options.cache;
9375
- this.scene = new PSceneManager(this.engine);
9376
- };
9377
- /**
9378
9350
  * 组件初始化,初始化场景管理器并更新合成相机
9379
9351
  * @param sceneParams - 场景参数
9380
9352
  */ _proto.initial = function initial(sceneParams) {
@@ -13131,10 +13103,10 @@ var GLTFHelper = /*#__PURE__*/ function() {
13131
13103
  return GLTFHelper;
13132
13104
  }();
13133
13105
 
13134
- registerPlugin("model", ModelPlugin, VFXItem);
13106
+ registerPlugin("model", ModelPlugin);
13135
13107
  /**
13136
13108
  * 插件版本号
13137
- */ var version = "2.8.0-alpha.1";
13109
+ */ var version = "2.8.0-alpha.2";
13138
13110
  logger.info("Plugin model version: " + version + ".");
13139
13111
  if (version !== EFFECTS.version) {
13140
13112
  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!");