@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/alipay.js +1 -1
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +1 -1
- package/dist/alipay.mjs.map +1 -1
- package/dist/douyin.js +1 -1
- package/dist/douyin.js.map +1 -1
- package/dist/douyin.mjs +1 -1
- package/dist/douyin.mjs.map +1 -1
- package/dist/index.js +65 -94
- 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 +65 -94
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +66 -95
- package/dist/loader.mjs.map +1 -1
- package/dist/plugin/model-plugin.d.ts +5 -27
- package/dist/weapp.js +1 -1
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +1 -1
- package/dist/weapp.mjs.map +1 -1
- package/package.json +4 -4
package/dist/loader.mjs
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Description: Galacean Effects player model plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 飂兮
|
|
6
|
-
* Version: v2.8.0-alpha.
|
|
6
|
+
* Version: v2.8.0-alpha.2
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
10
|
-
import { math, Transform, spec, PLAYER_OPTIONS_ENV_EDITOR, glContext, Material, Mesh, Geometry, ShaderFactory, effectsClass, GLSLVersion, VFXItem,
|
|
10
|
+
import { math, Transform, spec, PLAYER_OPTIONS_ENV_EDITOR, glContext, Material, Mesh, Geometry, ShaderFactory, effectsClass, GLSLVersion, VFXItem, AbstractPlugin, Behaviour, registerPlugin, logger, RendererComponent, HitTestType, AnimationClip, TextureSourceType, Texture, DestroyOptions, RenderPassDestroyAttachmentType, getDefaultTextureFactory, Player, loadImage, generateGUID, addItem, removeItem, glType2VertexFormatType, Downloader, getStandardJSON, isObject } from '@galacean/effects';
|
|
11
11
|
|
|
12
12
|
var Vector2 = math.Vector2, Vector3 = math.Vector3, Vector4 = math.Vector4, Matrix3 = math.Matrix3, Matrix4 = math.Matrix4, Color = math.Color, Euler = math.Euler, EulerOrder = math.EulerOrder, Quaternion = math.Quaternion, Box3 = math.Box3; math.Sphere; math.Ray; var DEG2RAD = math.DEG2RAD;
|
|
13
13
|
|
|
@@ -1361,8 +1361,55 @@ function getQuadFilterVS() {
|
|
|
1361
1361
|
return _this;
|
|
1362
1362
|
}
|
|
1363
1363
|
var _proto = ModelPlugin.prototype;
|
|
1364
|
-
_proto.
|
|
1365
|
-
|
|
1364
|
+
_proto.processAssets = function processAssets(scene, options) {
|
|
1365
|
+
return _async_to_generator(function() {
|
|
1366
|
+
return __generator(this, function(_state) {
|
|
1367
|
+
switch(_state.label){
|
|
1368
|
+
case 0:
|
|
1369
|
+
return [
|
|
1370
|
+
4,
|
|
1371
|
+
CompositionCache.loadStaticResources()
|
|
1372
|
+
];
|
|
1373
|
+
case 1:
|
|
1374
|
+
_state.sent();
|
|
1375
|
+
return [
|
|
1376
|
+
2
|
|
1377
|
+
];
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1380
|
+
})();
|
|
1381
|
+
};
|
|
1382
|
+
/**
|
|
1383
|
+
* 整个 load 阶段都不会创建 GL 相关的对象,只创建 JS 对象
|
|
1384
|
+
* @param scene - 场景
|
|
1385
|
+
* @param options - 加载选项
|
|
1386
|
+
*/ _proto.prepareResource = function prepareResource(scene, options, engine) {
|
|
1387
|
+
var _options_pluginData;
|
|
1388
|
+
if (options.pluginData !== undefined) {
|
|
1389
|
+
var keyList = [
|
|
1390
|
+
"compatibleMode",
|
|
1391
|
+
"renderSkybox",
|
|
1392
|
+
"visBoundingBox",
|
|
1393
|
+
"autoAdjustScene",
|
|
1394
|
+
"enableDynamicSort",
|
|
1395
|
+
"renderMode3D",
|
|
1396
|
+
"renderMode3DUVGridSize"
|
|
1397
|
+
];
|
|
1398
|
+
var pluginData = options.pluginData;
|
|
1399
|
+
keyList.forEach(function(key) {
|
|
1400
|
+
return scene.storage[key] = pluginData[key];
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
var _options_env;
|
|
1404
|
+
//
|
|
1405
|
+
var runtimeEnv = (_options_env = options.env) != null ? _options_env : "";
|
|
1406
|
+
scene.storage["runtimeEnv"] = runtimeEnv;
|
|
1407
|
+
var _options_pluginData_compatibleMode;
|
|
1408
|
+
var compatibleMode = (_options_pluginData_compatibleMode = (_options_pluginData = options.pluginData) == null ? void 0 : _options_pluginData["compatibleMode"]) != null ? _options_pluginData_compatibleMode : "gltf";
|
|
1409
|
+
//
|
|
1410
|
+
PluginHelper.preprocessScene(scene, runtimeEnv, compatibleMode);
|
|
1411
|
+
// Add PBR and Unlit shader data
|
|
1412
|
+
var isWebGL2 = engine.gpuCapability.level === 2;
|
|
1366
1413
|
var pbrShaderCode = fetchPBRShaderCode();
|
|
1367
1414
|
var unlitShaderCode = fetchUnlitShaderCode();
|
|
1368
1415
|
var pbrShaderData = {
|
|
@@ -1383,25 +1430,14 @@ function getQuadFilterVS() {
|
|
|
1383
1430
|
// @ts-expect-error
|
|
1384
1431
|
glslVersion: isWebGL2 ? GLSLVersion.GLSL3 : GLSLVersion.GLSL1
|
|
1385
1432
|
};
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
return Promise.resolve();
|
|
1433
|
+
engine.addEffectsObjectData(pbrShaderData);
|
|
1434
|
+
engine.addEffectsObjectData(unlitShaderData);
|
|
1389
1435
|
};
|
|
1390
1436
|
/**
|
|
1391
1437
|
* 创建 3D 场景管理器和缓存器
|
|
1392
1438
|
* @param composition - 合成
|
|
1393
1439
|
* @param scene - 场景
|
|
1394
1440
|
*/ _proto.onCompositionConstructed = function onCompositionConstructed(composition, scene) {
|
|
1395
|
-
this.sceneParams = scene.storage;
|
|
1396
|
-
var engine = composition.renderer.engine;
|
|
1397
|
-
this.cache = new CompositionCache(engine);
|
|
1398
|
-
this.cache.setup(false);
|
|
1399
|
-
};
|
|
1400
|
-
/**
|
|
1401
|
-
* 每次播放都会执行,包括重播,所以这里执行“小的销毁”和新的初始化
|
|
1402
|
-
* @param composition - 合成
|
|
1403
|
-
* @param renderFrame - 渲染帧
|
|
1404
|
-
*/ _proto.onCompositionReset = function onCompositionReset(composition, renderFrame) {
|
|
1405
1441
|
var props = {
|
|
1406
1442
|
id: "ModelPluginItem",
|
|
1407
1443
|
name: "ModelPluginItem",
|
|
@@ -1410,72 +1446,14 @@ function getQuadFilterVS() {
|
|
|
1410
1446
|
};
|
|
1411
1447
|
var item = new VFXItem(composition.getEngine(), props);
|
|
1412
1448
|
composition.addItem(item);
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
comp.fromData({
|
|
1416
|
-
cache: this.cache
|
|
1417
|
-
});
|
|
1418
|
-
comp.initial(this.sceneParams);
|
|
1419
|
-
};
|
|
1420
|
-
/**
|
|
1421
|
-
* 合成销毁,同时销毁 3D 场景对象和缓存
|
|
1422
|
-
* @param composition - 合成
|
|
1423
|
-
*/ _proto.onCompositionDestroyed = function onCompositionDestroyed(composition) {
|
|
1424
|
-
this.cache.dispose();
|
|
1425
|
-
// @ts-expect-error
|
|
1426
|
-
this.cache = null;
|
|
1427
|
-
// @ts-expect-error
|
|
1428
|
-
this.sceneParams = null;
|
|
1429
|
-
};
|
|
1430
|
-
/**
|
|
1431
|
-
* 整个 load 阶段都不会创建 GL 相关的对象,只创建 JS 对象
|
|
1432
|
-
* @param scene - 场景
|
|
1433
|
-
* @param options - 加载选项
|
|
1434
|
-
*/ ModelPlugin.prepareResource = function prepareResource(scene, options) {
|
|
1435
|
-
return _async_to_generator(function() {
|
|
1436
|
-
var _options_pluginData, keyList, pluginData, _options_env, runtimeEnv, _options_pluginData_compatibleMode, compatibleMode;
|
|
1437
|
-
return __generator(this, function(_state) {
|
|
1438
|
-
switch(_state.label){
|
|
1439
|
-
case 0:
|
|
1440
|
-
if (options.pluginData !== undefined) {
|
|
1441
|
-
keyList = [
|
|
1442
|
-
"compatibleMode",
|
|
1443
|
-
"renderSkybox",
|
|
1444
|
-
"visBoundingBox",
|
|
1445
|
-
"autoAdjustScene",
|
|
1446
|
-
"enableDynamicSort",
|
|
1447
|
-
"renderMode3D",
|
|
1448
|
-
"renderMode3DUVGridSize"
|
|
1449
|
-
];
|
|
1450
|
-
pluginData = options.pluginData;
|
|
1451
|
-
keyList.forEach(function(key) {
|
|
1452
|
-
return scene.storage[key] = pluginData[key];
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
//
|
|
1456
|
-
runtimeEnv = (_options_env = options.env) != null ? _options_env : "";
|
|
1457
|
-
scene.storage["runtimeEnv"] = runtimeEnv;
|
|
1458
|
-
compatibleMode = (_options_pluginData_compatibleMode = (_options_pluginData = options.pluginData) == null ? void 0 : _options_pluginData["compatibleMode"]) != null ? _options_pluginData_compatibleMode : "gltf";
|
|
1459
|
-
//
|
|
1460
|
-
PluginHelper.preprocessScene(scene, runtimeEnv, compatibleMode);
|
|
1461
|
-
return [
|
|
1462
|
-
4,
|
|
1463
|
-
CompositionCache.loadStaticResources()
|
|
1464
|
-
];
|
|
1465
|
-
case 1:
|
|
1466
|
-
_state.sent();
|
|
1467
|
-
return [
|
|
1468
|
-
2
|
|
1469
|
-
];
|
|
1470
|
-
}
|
|
1471
|
-
});
|
|
1472
|
-
})();
|
|
1449
|
+
var modelPluginComponent = item.addComponent(ModelPluginComponent);
|
|
1450
|
+
modelPluginComponent.sceneParams = scene.storage;
|
|
1473
1451
|
};
|
|
1474
1452
|
return ModelPlugin;
|
|
1475
1453
|
}(AbstractPlugin);
|
|
1476
1454
|
var ModelPluginComponent = /*#__PURE__*/ function(Behaviour) {
|
|
1477
1455
|
_inherits(ModelPluginComponent, Behaviour);
|
|
1478
|
-
function ModelPluginComponent(engine
|
|
1456
|
+
function ModelPluginComponent(engine) {
|
|
1479
1457
|
var _this;
|
|
1480
1458
|
_this = Behaviour.call(this, engine) || this;
|
|
1481
1459
|
_this.runtimeEnv = PLAYER_OPTIONS_ENV_EDITOR;
|
|
@@ -1495,12 +1473,15 @@ var ModelPluginComponent = /*#__PURE__*/ function(Behaviour) {
|
|
|
1495
1473
|
* UV 渲染模式中,指定棋盘格的大小,相对于大小为 1 的纹理
|
|
1496
1474
|
* 取值范围(0, 1)
|
|
1497
1475
|
*/ _this.renderMode3DUVGridSize = 1 / 16;
|
|
1498
|
-
if (options) {
|
|
1499
|
-
_this.fromData(options);
|
|
1500
|
-
}
|
|
1501
1476
|
return _this;
|
|
1502
1477
|
}
|
|
1503
1478
|
var _proto = ModelPluginComponent.prototype;
|
|
1479
|
+
_proto.onAwake = function onAwake() {
|
|
1480
|
+
this.cache = new CompositionCache(this.engine);
|
|
1481
|
+
this.cache.setup(false);
|
|
1482
|
+
this.scene = new PSceneManager(this.engine);
|
|
1483
|
+
this.initial(this.sceneParams);
|
|
1484
|
+
};
|
|
1504
1485
|
/**
|
|
1505
1486
|
* 组件后更新,合成相机和场景管理器更新
|
|
1506
1487
|
* @param dt - 更新间隔
|
|
@@ -1556,20 +1537,11 @@ var ModelPluginComponent = /*#__PURE__*/ function(Behaviour) {
|
|
|
1556
1537
|
this.scene.dispose();
|
|
1557
1538
|
// @ts-expect-error
|
|
1558
1539
|
this.scene = null;
|
|
1540
|
+
this.cache.dispose();
|
|
1559
1541
|
// @ts-expect-error
|
|
1560
1542
|
this.cache = null;
|
|
1561
1543
|
};
|
|
1562
1544
|
/**
|
|
1563
|
-
* 反序列化,创建场景管理器
|
|
1564
|
-
* @param date - 组件参数
|
|
1565
|
-
*/ _proto.fromData = function fromData(data) {
|
|
1566
|
-
Behaviour.prototype.fromData.call(this, data);
|
|
1567
|
-
//
|
|
1568
|
-
var options = data;
|
|
1569
|
-
this.cache = options.cache;
|
|
1570
|
-
this.scene = new PSceneManager(this.engine);
|
|
1571
|
-
};
|
|
1572
|
-
/**
|
|
1573
1545
|
* 组件初始化,初始化场景管理器并更新合成相机
|
|
1574
1546
|
* @param sceneParams - 场景参数
|
|
1575
1547
|
*/ _proto.initial = function initial(sceneParams) {
|
|
@@ -2093,10 +2065,10 @@ var CameraGestureHandlerImp = /*#__PURE__*/ function() {
|
|
|
2093
2065
|
return CameraGestureHandlerImp;
|
|
2094
2066
|
}();
|
|
2095
2067
|
|
|
2096
|
-
registerPlugin("model", ModelPlugin
|
|
2068
|
+
registerPlugin("model", ModelPlugin);
|
|
2097
2069
|
/**
|
|
2098
2070
|
* 插件版本号
|
|
2099
|
-
*/ var version = "2.8.0-alpha.
|
|
2071
|
+
*/ var version = "2.8.0-alpha.2";
|
|
2100
2072
|
logger.info("Plugin model version: " + version + ".");
|
|
2101
2073
|
if (version !== EFFECTS.version) {
|
|
2102
2074
|
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!");
|
|
@@ -3258,8 +3230,7 @@ var normal = new Vector3();
|
|
|
3258
3230
|
geometries: DestroyOptions.destroy
|
|
3259
3231
|
},
|
|
3260
3232
|
depthStencilAttachment: RenderPassDestroyAttachmentType.force,
|
|
3261
|
-
colorAttachment: RenderPassDestroyAttachmentType.force
|
|
3262
|
-
semantics: DestroyOptions.destroy
|
|
3233
|
+
colorAttachment: RenderPassDestroyAttachmentType.force
|
|
3263
3234
|
});
|
|
3264
3235
|
};
|
|
3265
3236
|
/**
|