@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/alipay.js +1 -13387
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +1 -13273
- package/dist/alipay.mjs.map +1 -1
- package/dist/douyin.js +1 -13387
- package/dist/douyin.js.map +1 -1
- package/dist/douyin.mjs +1 -13273
- package/dist/douyin.mjs.map +1 -1
- package/dist/index.js +29 -112
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +29 -112
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +30 -970
- package/dist/loader.mjs.map +1 -1
- package/dist/plugin/model-plugin.d.ts +1 -1
- package/dist/utility/plugin-helper.d.ts +3 -13
- package/dist/weapp.js +1 -13387
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +1 -13273
- package/dist/weapp.mjs.map +1 -1
- package/package.json +4 -4
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.3.0-
|
|
6
|
+
* Version: v2.3.0-beta.1
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -2116,11 +2116,10 @@ var ModelCameraComponent = /*#__PURE__*/ function(Behaviour) {
|
|
|
2116
2116
|
this.content.matrix = this.transform.getWorldMatrix();
|
|
2117
2117
|
var composition = this.item.composition;
|
|
2118
2118
|
if (composition) {
|
|
2119
|
-
composition.camera.position = this.transform.position.clone();
|
|
2120
|
-
composition.camera.setQuat(this.transform.quat);
|
|
2121
2119
|
composition.camera.near = this.content.nearPlane;
|
|
2122
2120
|
composition.camera.far = this.content.farPlane;
|
|
2123
2121
|
composition.camera.fov = this.content.fov;
|
|
2122
|
+
composition.camera.setTransform(this.transform);
|
|
2124
2123
|
}
|
|
2125
2124
|
};
|
|
2126
2125
|
/**
|
|
@@ -3490,86 +3489,6 @@ var normal = new Vector3();
|
|
|
3490
3489
|
}
|
|
3491
3490
|
};
|
|
3492
3491
|
/**
|
|
3493
|
-
* 设置 3D 元素参数,在播放器创建 3D 元素前
|
|
3494
|
-
* @param scene - 场景
|
|
3495
|
-
* @param cache - 缓存
|
|
3496
|
-
* @param composition - 合成
|
|
3497
|
-
* @returns
|
|
3498
|
-
*/ PluginHelper.setupItem3DOptions = function setupItem3DOptions(scene, cache, composition) {
|
|
3499
|
-
var _this = this;
|
|
3500
|
-
if (scene === undefined || scene.bins.length <= 0) {
|
|
3501
|
-
return;
|
|
3502
|
-
}
|
|
3503
|
-
var jsonScene = scene.jsonScene;
|
|
3504
|
-
var compIndexSet = new Set();
|
|
3505
|
-
if (jsonScene.compositionId === undefined) {
|
|
3506
|
-
compIndexSet.add(0);
|
|
3507
|
-
}
|
|
3508
|
-
jsonScene.compositions.forEach(function(comp, index) {
|
|
3509
|
-
if (comp.id === jsonScene.compositionId || composition.refCompositionProps.has(comp.id)) {
|
|
3510
|
-
compIndexSet.add(index);
|
|
3511
|
-
}
|
|
3512
|
-
});
|
|
3513
|
-
compIndexSet.forEach(function(compIndex) {
|
|
3514
|
-
var sceneComp = jsonScene.compositions[compIndex];
|
|
3515
|
-
sceneComp.items.forEach(function(data) {
|
|
3516
|
-
var itemId = data.id;
|
|
3517
|
-
var item = composition.getEngine().jsonSceneData[itemId];
|
|
3518
|
-
if (item.type === spec.ItemType.mesh) {
|
|
3519
|
-
var meshItem = item;
|
|
3520
|
-
var skin = meshItem.content.options.skin;
|
|
3521
|
-
var primitives = meshItem.content.options.primitives;
|
|
3522
|
-
primitives.forEach(function(prim, primId) {
|
|
3523
|
-
if (_instanceof1(prim.geometry, Geometry)) {
|
|
3524
|
-
// 可能已经创建,直接返回
|
|
3525
|
-
return;
|
|
3526
|
-
}
|
|
3527
|
-
var name = "Geom_C" + compIndex + "_I" + itemId + "_P" + primId;
|
|
3528
|
-
var riGeometry = cache.getOrCreateGeometry(name, prim.geometry, scene.bins);
|
|
3529
|
-
var studioPrim = prim;
|
|
3530
|
-
studioPrim.geometry = riGeometry;
|
|
3531
|
-
var material = prim.material;
|
|
3532
|
-
if (material.type === spec.MaterialType.pbr) {
|
|
3533
|
-
var studioMat = studioPrim.material;
|
|
3534
|
-
studioMat.baseColorTexture = _this.getTextureObj(composition.textures, material.baseColorTexture);
|
|
3535
|
-
studioMat.metallicRoughnessTexture = _this.getTextureObj(composition.textures, material.metallicRoughnessTexture);
|
|
3536
|
-
studioMat.normalTexture = _this.getTextureObj(composition.textures, material.normalTexture);
|
|
3537
|
-
studioMat.occlusionTexture = _this.getTextureObj(composition.textures, material.occlusionTexture);
|
|
3538
|
-
studioMat.emissiveTexture = _this.getTextureObj(composition.textures, material.emissiveTexture);
|
|
3539
|
-
} else {
|
|
3540
|
-
var studioMat1 = studioPrim.material;
|
|
3541
|
-
studioMat1.baseColorTexture = _this.getTextureObj(composition.textures, material.baseColorTexture);
|
|
3542
|
-
}
|
|
3543
|
-
});
|
|
3544
|
-
if (skin !== undefined && skin.inverseBindMatrices !== undefined) {
|
|
3545
|
-
var studioSkin = skin;
|
|
3546
|
-
var inverseBindMatrices = typedArrayFromBinary(scene.bins, skin.inverseBindMatrices);
|
|
3547
|
-
if (_instanceof1(inverseBindMatrices, Float32Array)) {
|
|
3548
|
-
studioSkin.inverseBindMatrices = inverseBindMatrices;
|
|
3549
|
-
} else {
|
|
3550
|
-
console.error("setupItem3DOptions: Invalid inverseBindMatrices type, " + inverseBindMatrices + ".");
|
|
3551
|
-
}
|
|
3552
|
-
}
|
|
3553
|
-
} else if (item.type === spec.ItemType.skybox) {
|
|
3554
|
-
var skybox = item;
|
|
3555
|
-
var studioSkybox = item;
|
|
3556
|
-
var options = skybox.content.options;
|
|
3557
|
-
var studioOptions = studioSkybox.content.options;
|
|
3558
|
-
var specularImage = _this.getTextureObj(composition.textures, options.specularImage);
|
|
3559
|
-
if (specularImage === undefined) {
|
|
3560
|
-
console.error("setupItem3DOptions: skybox specualrImage is undefined, " + CheckerHelper.stringify(options) + ".");
|
|
3561
|
-
}
|
|
3562
|
-
studioOptions.specularImage = specularImage;
|
|
3563
|
-
//
|
|
3564
|
-
var diffuseImage = _this.getTextureObj(composition.textures, options.diffuseImage);
|
|
3565
|
-
if (diffuseImage !== undefined) {
|
|
3566
|
-
studioOptions.diffuseImage = diffuseImage;
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
3569
|
-
});
|
|
3570
|
-
});
|
|
3571
|
-
};
|
|
3572
|
-
/**
|
|
3573
3492
|
* 创建几何体,根据几何参数描述 JSON 和数据数组
|
|
3574
3493
|
* @param engine - 引擎
|
|
3575
3494
|
* @param geomJson - 几何参数描述 JSON
|
|
@@ -9306,6 +9225,32 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
9306
9225
|
return _this;
|
|
9307
9226
|
}
|
|
9308
9227
|
var _proto = ModelPlugin.prototype;
|
|
9228
|
+
_proto.precompile = function precompile(compositions, renderer) {
|
|
9229
|
+
var isWebGL2 = renderer.engine.gpuCapability.level === 2;
|
|
9230
|
+
var pbrShaderCode = fetchPBRShaderCode();
|
|
9231
|
+
var unlitShaderCode = fetchUnlitShaderCode();
|
|
9232
|
+
var pbrShaderData = {
|
|
9233
|
+
id: PBRShaderGUID,
|
|
9234
|
+
name: "PBR Shader",
|
|
9235
|
+
dataType: spec.DataType.Shader,
|
|
9236
|
+
fragment: pbrShaderCode.fragmentShaderCode,
|
|
9237
|
+
vertex: pbrShaderCode.vertexShaderCode,
|
|
9238
|
+
// @ts-expect-error
|
|
9239
|
+
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
9240
|
+
};
|
|
9241
|
+
var unlitShaderData = {
|
|
9242
|
+
id: UnlitShaderGUID,
|
|
9243
|
+
name: "Unlit Shader",
|
|
9244
|
+
dataType: spec.DataType.Shader,
|
|
9245
|
+
fragment: unlitShaderCode.fragmentShaderCode,
|
|
9246
|
+
vertex: unlitShaderCode.vertexShaderCode,
|
|
9247
|
+
// @ts-expect-error
|
|
9248
|
+
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
9249
|
+
};
|
|
9250
|
+
renderer.engine.addEffectsObjectData(pbrShaderData);
|
|
9251
|
+
renderer.engine.addEffectsObjectData(unlitShaderData);
|
|
9252
|
+
return Promise.resolve();
|
|
9253
|
+
};
|
|
9309
9254
|
/**
|
|
9310
9255
|
* 创建 3D 场景管理器和缓存器
|
|
9311
9256
|
* @param composition - 合成
|
|
@@ -9315,8 +9260,6 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
9315
9260
|
var engine = composition.renderer.engine;
|
|
9316
9261
|
this.cache = new CompositionCache(engine);
|
|
9317
9262
|
this.cache.setup(false);
|
|
9318
|
-
// FIXME: 先注释元素参数的配置
|
|
9319
|
-
//PluginHelper.setupItem3DOptions(scene, this.cache, composition);
|
|
9320
9263
|
};
|
|
9321
9264
|
/**
|
|
9322
9265
|
* 每次播放都会执行,包括重播,所以这里执行“小的销毁”和新的初始化
|
|
@@ -9392,32 +9335,6 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
9392
9335
|
});
|
|
9393
9336
|
})();
|
|
9394
9337
|
};
|
|
9395
|
-
ModelPlugin.precompile = function precompile(compositions, renderer) {
|
|
9396
|
-
var isWebGL2 = renderer.engine.gpuCapability.level === 2;
|
|
9397
|
-
var pbrShaderCode = fetchPBRShaderCode();
|
|
9398
|
-
var unlitShaderCode = fetchUnlitShaderCode();
|
|
9399
|
-
var pbrShaderData = {
|
|
9400
|
-
id: PBRShaderGUID,
|
|
9401
|
-
name: "PBR Shader",
|
|
9402
|
-
dataType: spec.DataType.Shader,
|
|
9403
|
-
fragment: pbrShaderCode.fragmentShaderCode,
|
|
9404
|
-
vertex: pbrShaderCode.vertexShaderCode,
|
|
9405
|
-
// @ts-expect-error
|
|
9406
|
-
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
9407
|
-
};
|
|
9408
|
-
var unlitShaderData = {
|
|
9409
|
-
id: UnlitShaderGUID,
|
|
9410
|
-
name: "Unlit Shader",
|
|
9411
|
-
dataType: spec.DataType.Shader,
|
|
9412
|
-
fragment: unlitShaderCode.fragmentShaderCode,
|
|
9413
|
-
vertex: unlitShaderCode.vertexShaderCode,
|
|
9414
|
-
// @ts-expect-error
|
|
9415
|
-
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
9416
|
-
};
|
|
9417
|
-
renderer.engine.addEffectsObjectData(pbrShaderData);
|
|
9418
|
-
renderer.engine.addEffectsObjectData(unlitShaderData);
|
|
9419
|
-
return Promise.resolve();
|
|
9420
|
-
};
|
|
9421
9338
|
return ModelPlugin;
|
|
9422
9339
|
}(AbstractPlugin);
|
|
9423
9340
|
var ModelPluginComponent = /*#__PURE__*/ function(Behaviour) {
|
|
@@ -13272,7 +13189,7 @@ var GLTFHelper = /*#__PURE__*/ function() {
|
|
|
13272
13189
|
registerPlugin("model", ModelPlugin, VFXItem);
|
|
13273
13190
|
/**
|
|
13274
13191
|
* 插件版本号
|
|
13275
|
-
*/ var version = "2.3.0-
|
|
13192
|
+
*/ var version = "2.3.0-beta.1";
|
|
13276
13193
|
logger.info("Plugin model version: " + version + ".");
|
|
13277
13194
|
if (version !== EFFECTS.version) {
|
|
13278
13195
|
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!");
|