@galacean/effects-plugin-model 2.3.0-alpha.2 → 2.3.0-beta.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.
package/dist/index.js 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.3.0-alpha.2
6
+ * Version: v2.3.0-beta.1
7
7
  */
8
8
 
9
9
  'use strict';
@@ -2139,11 +2139,10 @@ exports.ModelCameraComponent = /*#__PURE__*/ function(Behaviour) {
2139
2139
  this.content.matrix = this.transform.getWorldMatrix();
2140
2140
  var composition = this.item.composition;
2141
2141
  if (composition) {
2142
- composition.camera.position = this.transform.position.clone();
2143
- composition.camera.setQuat(this.transform.quat);
2144
2142
  composition.camera.near = this.content.nearPlane;
2145
2143
  composition.camera.far = this.content.farPlane;
2146
2144
  composition.camera.fov = this.content.fov;
2145
+ composition.camera.setTransform(this.transform);
2147
2146
  }
2148
2147
  };
2149
2148
  /**
@@ -3513,86 +3512,6 @@ var normal = new Vector3();
3513
3512
  }
3514
3513
  };
3515
3514
  /**
3516
- * 设置 3D 元素参数,在播放器创建 3D 元素前
3517
- * @param scene - 场景
3518
- * @param cache - 缓存
3519
- * @param composition - 合成
3520
- * @returns
3521
- */ PluginHelper.setupItem3DOptions = function setupItem3DOptions(scene, cache, composition) {
3522
- var _this = this;
3523
- if (scene === undefined || scene.bins.length <= 0) {
3524
- return;
3525
- }
3526
- var jsonScene = scene.jsonScene;
3527
- var compIndexSet = new Set();
3528
- if (jsonScene.compositionId === undefined) {
3529
- compIndexSet.add(0);
3530
- }
3531
- jsonScene.compositions.forEach(function(comp, index) {
3532
- if (comp.id === jsonScene.compositionId || composition.refCompositionProps.has(comp.id)) {
3533
- compIndexSet.add(index);
3534
- }
3535
- });
3536
- compIndexSet.forEach(function(compIndex) {
3537
- var sceneComp = jsonScene.compositions[compIndex];
3538
- sceneComp.items.forEach(function(data) {
3539
- var itemId = data.id;
3540
- var item = composition.getEngine().jsonSceneData[itemId];
3541
- if (item.type === EFFECTS.spec.ItemType.mesh) {
3542
- var meshItem = item;
3543
- var skin = meshItem.content.options.skin;
3544
- var primitives = meshItem.content.options.primitives;
3545
- primitives.forEach(function(prim, primId) {
3546
- if (_instanceof1(prim.geometry, EFFECTS.Geometry)) {
3547
- // 可能已经创建,直接返回
3548
- return;
3549
- }
3550
- var name = "Geom_C" + compIndex + "_I" + itemId + "_P" + primId;
3551
- var riGeometry = cache.getOrCreateGeometry(name, prim.geometry, scene.bins);
3552
- var studioPrim = prim;
3553
- studioPrim.geometry = riGeometry;
3554
- var material = prim.material;
3555
- if (material.type === EFFECTS.spec.MaterialType.pbr) {
3556
- var studioMat = studioPrim.material;
3557
- studioMat.baseColorTexture = _this.getTextureObj(composition.textures, material.baseColorTexture);
3558
- studioMat.metallicRoughnessTexture = _this.getTextureObj(composition.textures, material.metallicRoughnessTexture);
3559
- studioMat.normalTexture = _this.getTextureObj(composition.textures, material.normalTexture);
3560
- studioMat.occlusionTexture = _this.getTextureObj(composition.textures, material.occlusionTexture);
3561
- studioMat.emissiveTexture = _this.getTextureObj(composition.textures, material.emissiveTexture);
3562
- } else {
3563
- var studioMat1 = studioPrim.material;
3564
- studioMat1.baseColorTexture = _this.getTextureObj(composition.textures, material.baseColorTexture);
3565
- }
3566
- });
3567
- if (skin !== undefined && skin.inverseBindMatrices !== undefined) {
3568
- var studioSkin = skin;
3569
- var inverseBindMatrices = typedArrayFromBinary(scene.bins, skin.inverseBindMatrices);
3570
- if (_instanceof1(inverseBindMatrices, Float32Array)) {
3571
- studioSkin.inverseBindMatrices = inverseBindMatrices;
3572
- } else {
3573
- console.error("setupItem3DOptions: Invalid inverseBindMatrices type, " + inverseBindMatrices + ".");
3574
- }
3575
- }
3576
- } else if (item.type === EFFECTS.spec.ItemType.skybox) {
3577
- var skybox = item;
3578
- var studioSkybox = item;
3579
- var options = skybox.content.options;
3580
- var studioOptions = studioSkybox.content.options;
3581
- var specularImage = _this.getTextureObj(composition.textures, options.specularImage);
3582
- if (specularImage === undefined) {
3583
- console.error("setupItem3DOptions: skybox specualrImage is undefined, " + CheckerHelper.stringify(options) + ".");
3584
- }
3585
- studioOptions.specularImage = specularImage;
3586
- //
3587
- var diffuseImage = _this.getTextureObj(composition.textures, options.diffuseImage);
3588
- if (diffuseImage !== undefined) {
3589
- studioOptions.diffuseImage = diffuseImage;
3590
- }
3591
- }
3592
- });
3593
- });
3594
- };
3595
- /**
3596
3515
  * 创建几何体,根据几何参数描述 JSON 和数据数组
3597
3516
  * @param engine - 引擎
3598
3517
  * @param geomJson - 几何参数描述 JSON
@@ -9329,6 +9248,32 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
9329
9248
  return _this;
9330
9249
  }
9331
9250
  var _proto = ModelPlugin.prototype;
9251
+ _proto.precompile = function precompile(compositions, renderer) {
9252
+ var isWebGL2 = renderer.engine.gpuCapability.level === 2;
9253
+ var pbrShaderCode = fetchPBRShaderCode();
9254
+ var unlitShaderCode = fetchUnlitShaderCode();
9255
+ var pbrShaderData = {
9256
+ id: PBRShaderGUID,
9257
+ name: "PBR Shader",
9258
+ dataType: EFFECTS.spec.DataType.Shader,
9259
+ fragment: pbrShaderCode.fragmentShaderCode,
9260
+ vertex: pbrShaderCode.vertexShaderCode,
9261
+ // @ts-expect-error
9262
+ glslVersion: isWebGL2 ? EFFECTS.GLSLVersion.GLSL3 : EFFECTS.GLSLVersion.GLSL1
9263
+ };
9264
+ var unlitShaderData = {
9265
+ id: UnlitShaderGUID,
9266
+ name: "Unlit Shader",
9267
+ dataType: EFFECTS.spec.DataType.Shader,
9268
+ fragment: unlitShaderCode.fragmentShaderCode,
9269
+ vertex: unlitShaderCode.vertexShaderCode,
9270
+ // @ts-expect-error
9271
+ glslVersion: isWebGL2 ? EFFECTS.GLSLVersion.GLSL3 : EFFECTS.GLSLVersion.GLSL1
9272
+ };
9273
+ renderer.engine.addEffectsObjectData(pbrShaderData);
9274
+ renderer.engine.addEffectsObjectData(unlitShaderData);
9275
+ return Promise.resolve();
9276
+ };
9332
9277
  /**
9333
9278
  * 创建 3D 场景管理器和缓存器
9334
9279
  * @param composition - 合成
@@ -9338,8 +9283,6 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
9338
9283
  var engine = composition.renderer.engine;
9339
9284
  this.cache = new CompositionCache(engine);
9340
9285
  this.cache.setup(false);
9341
- // FIXME: 先注释元素参数的配置
9342
- //PluginHelper.setupItem3DOptions(scene, this.cache, composition);
9343
9286
  };
9344
9287
  /**
9345
9288
  * 每次播放都会执行,包括重播,所以这里执行“小的销毁”和新的初始化
@@ -9415,32 +9358,6 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
9415
9358
  });
9416
9359
  })();
9417
9360
  };
9418
- ModelPlugin.precompile = function precompile(compositions, renderer) {
9419
- var isWebGL2 = renderer.engine.gpuCapability.level === 2;
9420
- var pbrShaderCode = fetchPBRShaderCode();
9421
- var unlitShaderCode = fetchUnlitShaderCode();
9422
- var pbrShaderData = {
9423
- id: PBRShaderGUID,
9424
- name: "PBR Shader",
9425
- dataType: EFFECTS.spec.DataType.Shader,
9426
- fragment: pbrShaderCode.fragmentShaderCode,
9427
- vertex: pbrShaderCode.vertexShaderCode,
9428
- // @ts-expect-error
9429
- glslVersion: isWebGL2 ? EFFECTS.GLSLVersion.GLSL3 : EFFECTS.GLSLVersion.GLSL1
9430
- };
9431
- var unlitShaderData = {
9432
- id: UnlitShaderGUID,
9433
- name: "Unlit Shader",
9434
- dataType: EFFECTS.spec.DataType.Shader,
9435
- fragment: unlitShaderCode.fragmentShaderCode,
9436
- vertex: unlitShaderCode.vertexShaderCode,
9437
- // @ts-expect-error
9438
- glslVersion: isWebGL2 ? EFFECTS.GLSLVersion.GLSL3 : EFFECTS.GLSLVersion.GLSL1
9439
- };
9440
- renderer.engine.addEffectsObjectData(pbrShaderData);
9441
- renderer.engine.addEffectsObjectData(unlitShaderData);
9442
- return Promise.resolve();
9443
- };
9444
9361
  return ModelPlugin;
9445
9362
  }(EFFECTS.AbstractPlugin);
9446
9363
  exports.ModelPluginComponent = /*#__PURE__*/ function(Behaviour) {
@@ -13295,7 +13212,7 @@ var GLTFHelper = /*#__PURE__*/ function() {
13295
13212
  EFFECTS.registerPlugin("model", ModelPlugin, EFFECTS.VFXItem);
13296
13213
  /**
13297
13214
  * 插件版本号
13298
- */ var version = "2.3.0-alpha.2";
13215
+ */ var version = "2.3.0-beta.1";
13299
13216
  EFFECTS.logger.info("Plugin model version: " + version + ".");
13300
13217
  if (version !== EFFECTS__namespace.version) {
13301
13218
  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!");