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