@galacean/effects-plugin-model 2.1.0-alpha.7 → 2.1.0-alpha.8
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 +11 -597
- package/dist/alipay.js.map +1 -1
- package/dist/alipay.mjs +12 -593
- package/dist/alipay.mjs.map +1 -1
- package/dist/douyin.js +11 -597
- package/dist/douyin.js.map +1 -1
- package/dist/douyin.mjs +12 -593
- package/dist/douyin.mjs.map +1 -1
- package/dist/gltf/loader-impl.d.ts +2 -10
- package/dist/gltf/protocol.d.ts +2 -3
- package/dist/index.d.ts +0 -1
- package/dist/index.js +12 -598
- 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 +13 -594
- package/dist/index.mjs.map +1 -1
- package/dist/loader.mjs +12 -871
- package/dist/loader.mjs.map +1 -1
- package/dist/plugin/index.d.ts +1 -2
- package/dist/plugin/model-tree-component.d.ts +26 -0
- package/dist/runtime/animation.d.ts +0 -131
- package/dist/weapp.js +11 -597
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +12 -593
- package/dist/weapp.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/plugin/model-tree-item.d.ts +0 -132
- package/dist/plugin/model-tree-plugin.d.ts +0 -14
package/dist/alipay.js
CHANGED
|
@@ -1503,144 +1503,6 @@ exports.PAnimPathType = void 0;
|
|
|
1503
1503
|
PAnimPathType[PAnimPathType["scale"] = 2] = "scale";
|
|
1504
1504
|
PAnimPathType[PAnimPathType["weights"] = 3] = "weights";
|
|
1505
1505
|
})(exports.PAnimPathType || (exports.PAnimPathType = {}));
|
|
1506
|
-
/**
|
|
1507
|
-
* 动画轨道类
|
|
1508
|
-
*/ var PAnimTrack = /*#__PURE__*/ function() {
|
|
1509
|
-
function PAnimTrack(options) {
|
|
1510
|
-
/**
|
|
1511
|
-
* 路径类型
|
|
1512
|
-
*/ this.path = 0;
|
|
1513
|
-
/**
|
|
1514
|
-
* 插值类型
|
|
1515
|
-
*/ this.interp = 0;
|
|
1516
|
-
var node = options.node, input = options.input, output = options.output, path = options.path, interpolation = options.interpolation;
|
|
1517
|
-
this.node = node;
|
|
1518
|
-
this.timeArray = input;
|
|
1519
|
-
this.dataArray = output;
|
|
1520
|
-
//
|
|
1521
|
-
if (path === "translation") {
|
|
1522
|
-
this.path = 0;
|
|
1523
|
-
this.component = 3;
|
|
1524
|
-
} else if (path === "rotation") {
|
|
1525
|
-
this.path = 1;
|
|
1526
|
-
this.component = 4;
|
|
1527
|
-
} else if (path === "scale") {
|
|
1528
|
-
this.path = 2;
|
|
1529
|
-
this.component = 3;
|
|
1530
|
-
} else if (path === "weights") {
|
|
1531
|
-
this.path = 3;
|
|
1532
|
-
this.component = this.dataArray.length / this.timeArray.length;
|
|
1533
|
-
// special checker for weights animation
|
|
1534
|
-
if (this.component <= 0) {
|
|
1535
|
-
console.error("Invalid weights component: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
|
|
1536
|
-
} else if (this.timeArray.length * this.component != this.dataArray.length) {
|
|
1537
|
-
console.error("Invalid weights array length: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
|
|
1538
|
-
}
|
|
1539
|
-
} else {
|
|
1540
|
-
// should never happened
|
|
1541
|
-
console.error("Invalid path status: " + path + ".");
|
|
1542
|
-
}
|
|
1543
|
-
if (this.timeArray.length * this.component > this.dataArray.length) {
|
|
1544
|
-
throw new Error("Data length mismatch: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
|
|
1545
|
-
}
|
|
1546
|
-
if (interpolation === "LINEAR") {
|
|
1547
|
-
this.interp = 0;
|
|
1548
|
-
} else if (interpolation === "STEP") {
|
|
1549
|
-
this.interp = 1;
|
|
1550
|
-
} else {
|
|
1551
|
-
this.interp = 2;
|
|
1552
|
-
}
|
|
1553
|
-
this.sampler = createAnimationSampler(this.getInterpInfo(), this.timeArray, this.dataArray, this.component, this.getPathInfo());
|
|
1554
|
-
}
|
|
1555
|
-
var _proto = PAnimTrack.prototype;
|
|
1556
|
-
/**
|
|
1557
|
-
* 销毁
|
|
1558
|
-
*/ _proto.dispose = function dispose() {
|
|
1559
|
-
var _this_sampler;
|
|
1560
|
-
// @ts-expect-error
|
|
1561
|
-
this.timeArray = undefined;
|
|
1562
|
-
// @ts-expect-error
|
|
1563
|
-
this.dataArray = undefined;
|
|
1564
|
-
(_this_sampler = this.sampler) == null ? void 0 : _this_sampler.dispose();
|
|
1565
|
-
this.sampler = undefined;
|
|
1566
|
-
};
|
|
1567
|
-
/**
|
|
1568
|
-
* 更新节点动画数据
|
|
1569
|
-
* @param time - 当前播放时间
|
|
1570
|
-
* @param treeItem - 节点树元素
|
|
1571
|
-
* @param sceneManager - 3D 场景管理器
|
|
1572
|
-
*/ _proto.tick = function tick(time, treeItem, sceneManager) {
|
|
1573
|
-
var _treeComponent_content;
|
|
1574
|
-
var treeComponent = treeItem.getComponent(exports.ModelTreeComponent);
|
|
1575
|
-
var node = treeComponent == null ? void 0 : (_treeComponent_content = treeComponent.content) == null ? void 0 : _treeComponent_content.getNodeById(this.node);
|
|
1576
|
-
if (this.sampler !== undefined && node !== undefined) {
|
|
1577
|
-
var result = this.sampler.evaluate(time);
|
|
1578
|
-
switch(this.path){
|
|
1579
|
-
case 0:
|
|
1580
|
-
node.transform.setPosition(result[0], result[1], result[2]);
|
|
1581
|
-
break;
|
|
1582
|
-
case 1:
|
|
1583
|
-
node.transform.setQuaternion(result[0], result[1], result[2], result[3]);
|
|
1584
|
-
break;
|
|
1585
|
-
case 2:
|
|
1586
|
-
node.transform.setScale(result[0], result[1], result[2]);
|
|
1587
|
-
break;
|
|
1588
|
-
case 3:
|
|
1589
|
-
{
|
|
1590
|
-
/**
|
|
1591
|
-
* 先生成Mesh的父节点id,然后通过id查询Mesh对象
|
|
1592
|
-
* 最后更新Mesh对象权重数据
|
|
1593
|
-
*/ var parentId = this.genParentId(treeItem.id, this.node);
|
|
1594
|
-
var mesh = sceneManager == null ? void 0 : sceneManager.queryMesh(parentId);
|
|
1595
|
-
if (mesh !== undefined) {
|
|
1596
|
-
mesh.updateMorphWeights(result);
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
break;
|
|
1600
|
-
}
|
|
1601
|
-
} else {
|
|
1602
|
-
if (this.sampler !== undefined) {
|
|
1603
|
-
console.error("AnimTrack: error", this.sampler, node);
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
};
|
|
1607
|
-
/**
|
|
1608
|
-
* 获取动画结束时间
|
|
1609
|
-
* @returns
|
|
1610
|
-
*/ _proto.getEndTime = function getEndTime() {
|
|
1611
|
-
var index = this.timeArray.length - 1;
|
|
1612
|
-
return this.timeArray[index];
|
|
1613
|
-
};
|
|
1614
|
-
/**
|
|
1615
|
-
* 生成 Mesh 元素的父节点
|
|
1616
|
-
*
|
|
1617
|
-
* @param parentId - 父节点 id 名称
|
|
1618
|
-
* @param nodeIndex - Mesh 节点索引
|
|
1619
|
-
*
|
|
1620
|
-
* @returns 生成的 Mesh 节点名称
|
|
1621
|
-
*/ _proto.genParentId = function genParentId(parentId, nodeIndex) {
|
|
1622
|
-
return parentId + "^" + nodeIndex;
|
|
1623
|
-
};
|
|
1624
|
-
_proto.getPathInfo = function getPathInfo() {
|
|
1625
|
-
if (this.path === 2) {
|
|
1626
|
-
return "scale";
|
|
1627
|
-
} else if (this.path === 1) {
|
|
1628
|
-
return "rotation";
|
|
1629
|
-
} else {
|
|
1630
|
-
return "translation";
|
|
1631
|
-
}
|
|
1632
|
-
};
|
|
1633
|
-
_proto.getInterpInfo = function getInterpInfo() {
|
|
1634
|
-
if (this.interp === 2) {
|
|
1635
|
-
return "CUBICSPLINE";
|
|
1636
|
-
} else if (this.interp === 1) {
|
|
1637
|
-
return "STEP";
|
|
1638
|
-
} else {
|
|
1639
|
-
return "LINEAR";
|
|
1640
|
-
}
|
|
1641
|
-
};
|
|
1642
|
-
return PAnimTrack;
|
|
1643
|
-
}();
|
|
1644
1506
|
/**
|
|
1645
1507
|
* 动画纹理类
|
|
1646
1508
|
*/ var PAnimTexture = /*#__PURE__*/ function() {
|
|
@@ -1727,148 +1589,6 @@ exports.PAnimPathType = void 0;
|
|
|
1727
1589
|
};
|
|
1728
1590
|
return PAnimTexture;
|
|
1729
1591
|
}();
|
|
1730
|
-
/**
|
|
1731
|
-
* 动画类,负责动画数据创建、更新和销毁
|
|
1732
|
-
*/ var PAnimation = /*#__PURE__*/ function(PObject) {
|
|
1733
|
-
_inherits(PAnimation, PObject);
|
|
1734
|
-
function PAnimation() {
|
|
1735
|
-
var _this;
|
|
1736
|
-
_this = PObject.apply(this, arguments) || this;
|
|
1737
|
-
_this.time = 0;
|
|
1738
|
-
_this.duration = 0;
|
|
1739
|
-
_this.tracks = [];
|
|
1740
|
-
return _this;
|
|
1741
|
-
}
|
|
1742
|
-
var _proto = PAnimation.prototype;
|
|
1743
|
-
/**
|
|
1744
|
-
* 创建动画对象
|
|
1745
|
-
* @param options - 动画参数
|
|
1746
|
-
*/ _proto.create = function create(options) {
|
|
1747
|
-
var _this = this;
|
|
1748
|
-
var _options_name;
|
|
1749
|
-
this.name = this.genName((_options_name = options.name) != null ? _options_name : "Unnamed animation");
|
|
1750
|
-
this.type = exports.PObjectType.animation;
|
|
1751
|
-
//
|
|
1752
|
-
this.time = 0;
|
|
1753
|
-
this.duration = 0;
|
|
1754
|
-
//
|
|
1755
|
-
this.tracks = [];
|
|
1756
|
-
options.tracks.forEach(function(inTrack) {
|
|
1757
|
-
var track = new PAnimTrack(inTrack);
|
|
1758
|
-
_this.tracks.push(track);
|
|
1759
|
-
_this.duration = Math.max(_this.duration, track.getEndTime());
|
|
1760
|
-
});
|
|
1761
|
-
};
|
|
1762
|
-
/**
|
|
1763
|
-
* 动画更新
|
|
1764
|
-
* @param time - 当前时间
|
|
1765
|
-
* @param treeItem - 场景树元素
|
|
1766
|
-
* @param sceneManager - 3D 场景管理器
|
|
1767
|
-
*/ _proto.tick = function tick(time, treeItem, sceneManager) {
|
|
1768
|
-
this.time = time;
|
|
1769
|
-
// TODO: 这里时间事件定义不明确,先兼容原先实现
|
|
1770
|
-
var newTime = this.time % this.duration;
|
|
1771
|
-
this.tracks.forEach(function(track) {
|
|
1772
|
-
track.tick(newTime, treeItem, sceneManager);
|
|
1773
|
-
});
|
|
1774
|
-
};
|
|
1775
|
-
/**
|
|
1776
|
-
* 销毁
|
|
1777
|
-
*/ _proto.dispose = function dispose() {
|
|
1778
|
-
this.tracks.forEach(function(track) {
|
|
1779
|
-
track.dispose();
|
|
1780
|
-
});
|
|
1781
|
-
this.tracks = [];
|
|
1782
|
-
};
|
|
1783
|
-
return PAnimation;
|
|
1784
|
-
}(PObject);
|
|
1785
|
-
/**
|
|
1786
|
-
* 动画管理类,负责管理动画对象
|
|
1787
|
-
*/ var PAnimationManager = /*#__PURE__*/ function(PObject) {
|
|
1788
|
-
_inherits(PAnimationManager, PObject);
|
|
1789
|
-
function PAnimationManager(treeOptions, ownerItem) {
|
|
1790
|
-
var _this;
|
|
1791
|
-
_this = PObject.call(this) || this;
|
|
1792
|
-
_this.animation = 0;
|
|
1793
|
-
_this.speed = 0;
|
|
1794
|
-
_this.delay = 0;
|
|
1795
|
-
_this.time = 0;
|
|
1796
|
-
_this.animations = [];
|
|
1797
|
-
var _ownerItem_name;
|
|
1798
|
-
_this.name = _this.genName((_ownerItem_name = ownerItem.name) != null ? _ownerItem_name : "Unnamed tree");
|
|
1799
|
-
_this.type = exports.PObjectType.animationManager;
|
|
1800
|
-
//
|
|
1801
|
-
_this.ownerItem = ownerItem;
|
|
1802
|
-
var _treeOptions_animation;
|
|
1803
|
-
_this.animation = (_treeOptions_animation = treeOptions.animation) != null ? _treeOptions_animation : -1;
|
|
1804
|
-
_this.speed = 1.0;
|
|
1805
|
-
var _ownerItem_start;
|
|
1806
|
-
_this.delay = (_ownerItem_start = ownerItem.start) != null ? _ownerItem_start : 0;
|
|
1807
|
-
_this.animations = [];
|
|
1808
|
-
if (treeOptions.animations !== undefined) {
|
|
1809
|
-
treeOptions.animations.forEach(function(animOpts) {
|
|
1810
|
-
var anim = _this.createAnimation(animOpts);
|
|
1811
|
-
_this.animations.push(anim);
|
|
1812
|
-
});
|
|
1813
|
-
}
|
|
1814
|
-
return _this;
|
|
1815
|
-
}
|
|
1816
|
-
var _proto = PAnimationManager.prototype;
|
|
1817
|
-
/**
|
|
1818
|
-
* 设置场景管理器
|
|
1819
|
-
* @param sceneManager - 场景管理器
|
|
1820
|
-
*/ _proto.setSceneManager = function setSceneManager(sceneManager) {
|
|
1821
|
-
this.sceneManager = sceneManager;
|
|
1822
|
-
};
|
|
1823
|
-
/**
|
|
1824
|
-
* 创建动画对象
|
|
1825
|
-
* @param animationOpts - 动画参数
|
|
1826
|
-
* @returns 动画对象
|
|
1827
|
-
*/ _proto.createAnimation = function createAnimation(animationOpts) {
|
|
1828
|
-
var animation = new PAnimation();
|
|
1829
|
-
animation.create(animationOpts);
|
|
1830
|
-
return animation;
|
|
1831
|
-
};
|
|
1832
|
-
/**
|
|
1833
|
-
* 动画更新
|
|
1834
|
-
* @param deltaSeconds - 更新间隔
|
|
1835
|
-
*/ _proto.tick = function tick(deltaSeconds) {
|
|
1836
|
-
var _this = this;
|
|
1837
|
-
var newDeltaSeconds = deltaSeconds * this.speed * 0.001;
|
|
1838
|
-
this.time += newDeltaSeconds;
|
|
1839
|
-
// TODO: 需要合并到TreeItem中,通过lifetime进行计算
|
|
1840
|
-
var itemTime = this.time - this.delay;
|
|
1841
|
-
if (itemTime >= 0) {
|
|
1842
|
-
if (this.animation >= 0 && this.animation < this.animations.length) {
|
|
1843
|
-
var anim = this.animations[this.animation];
|
|
1844
|
-
anim.tick(itemTime, this.ownerItem, this.sceneManager);
|
|
1845
|
-
} else if (this.animation == -88888888) {
|
|
1846
|
-
this.animations.forEach(function(anim) {
|
|
1847
|
-
anim.tick(itemTime, _this.ownerItem, _this.sceneManager);
|
|
1848
|
-
});
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
};
|
|
1852
|
-
/**
|
|
1853
|
-
* 销毁
|
|
1854
|
-
*/ _proto.dispose = function dispose() {
|
|
1855
|
-
// @ts-expect-error
|
|
1856
|
-
this.ownerItem = null;
|
|
1857
|
-
this.animations.forEach(function(anim) {
|
|
1858
|
-
anim.dispose();
|
|
1859
|
-
});
|
|
1860
|
-
this.animations = [];
|
|
1861
|
-
// @ts-expect-error
|
|
1862
|
-
this.sceneManager = null;
|
|
1863
|
-
};
|
|
1864
|
-
/**
|
|
1865
|
-
* 获取场景树元素
|
|
1866
|
-
* @returns
|
|
1867
|
-
*/ _proto.getTreeItem = function getTreeItem() {
|
|
1868
|
-
return this.ownerItem;
|
|
1869
|
-
};
|
|
1870
|
-
return PAnimationManager;
|
|
1871
|
-
}(PObject);
|
|
1872
1592
|
|
|
1873
1593
|
var deg2rad = Math.PI / 180;
|
|
1874
1594
|
/**
|
|
@@ -3518,15 +3238,6 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
3518
3238
|
_proto.isHide = function isHide() {
|
|
3519
3239
|
return this.data.hide === true;
|
|
3520
3240
|
};
|
|
3521
|
-
_proto.getParentNode = function getParentNode() {
|
|
3522
|
-
var _this_parentItem;
|
|
3523
|
-
var nodeIndex = this.getParentIndex();
|
|
3524
|
-
var parentTree = (_this_parentItem = this.parentItem) == null ? void 0 : _this_parentItem.getComponent(exports.ModelTreeComponent);
|
|
3525
|
-
if (parentTree !== undefined && nodeIndex >= 0) {
|
|
3526
|
-
return parentTree.content.getNodeById(nodeIndex);
|
|
3527
|
-
}
|
|
3528
|
-
return undefined;
|
|
3529
|
-
};
|
|
3530
3241
|
_proto.getParentIndex = function getParentIndex() {
|
|
3531
3242
|
return -1;
|
|
3532
3243
|
};
|
|
@@ -6197,31 +5908,6 @@ var normal = new Vector3();
|
|
|
6197
5908
|
console.error("setupItem3DOptions: Invalid inverseBindMatrices type, " + inverseBindMatrices + ".");
|
|
6198
5909
|
}
|
|
6199
5910
|
}
|
|
6200
|
-
} else if (item.type === EFFECTS.spec.ItemType.tree) {
|
|
6201
|
-
var jsonItem = item;
|
|
6202
|
-
var studioItem = item;
|
|
6203
|
-
var jsonAnimations = jsonItem.content.options.tree.animations;
|
|
6204
|
-
var studioAnimations = studioItem.content.options.tree.animations;
|
|
6205
|
-
if (jsonAnimations !== undefined && studioAnimations !== undefined) {
|
|
6206
|
-
jsonAnimations.forEach(function(jsonAnim, i) {
|
|
6207
|
-
var studioAnim = studioAnimations[i];
|
|
6208
|
-
jsonAnim.tracks.forEach(function(jsonTrack, j) {
|
|
6209
|
-
var inputArray = typedArrayFromBinary(scene.bins, jsonTrack.input);
|
|
6210
|
-
var outputArray = typedArrayFromBinary(scene.bins, jsonTrack.output);
|
|
6211
|
-
var studioTrack = studioAnim.tracks[j];
|
|
6212
|
-
if (_instanceof1(inputArray, Float32Array)) {
|
|
6213
|
-
studioTrack.input = inputArray;
|
|
6214
|
-
} else {
|
|
6215
|
-
console.error("setupItem3DOptions: Type of inputArray should be float32, " + inputArray + ".");
|
|
6216
|
-
}
|
|
6217
|
-
if (_instanceof1(outputArray, Float32Array)) {
|
|
6218
|
-
studioTrack.output = outputArray;
|
|
6219
|
-
} else {
|
|
6220
|
-
console.error("setupItem3DOptions: Type of outputArray should be float32, " + outputArray + ".");
|
|
6221
|
-
}
|
|
6222
|
-
});
|
|
6223
|
-
});
|
|
6224
|
-
}
|
|
6225
5911
|
} else if (item.type === EFFECTS.spec.ItemType.skybox) {
|
|
6226
5912
|
var skybox = item;
|
|
6227
5913
|
var studioSkybox = item;
|
|
@@ -9944,117 +9630,6 @@ exports.ModelPluginComponent = __decorate([
|
|
|
9944
9630
|
return pluginComp == null ? void 0 : pluginComp.scene;
|
|
9945
9631
|
}
|
|
9946
9632
|
|
|
9947
|
-
/**
|
|
9948
|
-
* 场景树元素类,支持插件中节点树相关的动画能力
|
|
9949
|
-
*/ var ModelTreeItem = /*#__PURE__*/ function() {
|
|
9950
|
-
function ModelTreeItem(props, owner) {
|
|
9951
|
-
this.baseTransform = owner.transform;
|
|
9952
|
-
this.animationManager = new PAnimationManager(props, owner);
|
|
9953
|
-
this.build(props);
|
|
9954
|
-
}
|
|
9955
|
-
var _proto = ModelTreeItem.prototype;
|
|
9956
|
-
/**
|
|
9957
|
-
* 场景树更新,主要是动画更新
|
|
9958
|
-
* @param dt - 时间间隔
|
|
9959
|
-
*/ _proto.tick = function tick(dt) {
|
|
9960
|
-
this.animationManager.tick(dt);
|
|
9961
|
-
};
|
|
9962
|
-
/**
|
|
9963
|
-
* 获取所有节点
|
|
9964
|
-
* @returns
|
|
9965
|
-
*/ _proto.getNodes = function getNodes() {
|
|
9966
|
-
return this.nodes;
|
|
9967
|
-
};
|
|
9968
|
-
/**
|
|
9969
|
-
* 根据节点编号,查询节点
|
|
9970
|
-
* @param nodeId - 节点编号
|
|
9971
|
-
* @returns
|
|
9972
|
-
*/ _proto.getNodeById = function getNodeById(nodeId) {
|
|
9973
|
-
var cache = this.cacheMap;
|
|
9974
|
-
if (!cache[nodeId]) {
|
|
9975
|
-
var index = "^" + nodeId;
|
|
9976
|
-
// @ts-expect-error
|
|
9977
|
-
cache[nodeId] = this.allNodes.find(function(node) {
|
|
9978
|
-
return node.id === index;
|
|
9979
|
-
});
|
|
9980
|
-
}
|
|
9981
|
-
return cache[nodeId];
|
|
9982
|
-
};
|
|
9983
|
-
/**
|
|
9984
|
-
* 根据节点名称,查询节点
|
|
9985
|
-
* @param name - 名称
|
|
9986
|
-
* @returns
|
|
9987
|
-
*/ _proto.getNodeByName = function getNodeByName(name) {
|
|
9988
|
-
var cache = this.cacheMap;
|
|
9989
|
-
if (!cache[name]) {
|
|
9990
|
-
// @ts-expect-error
|
|
9991
|
-
cache[name] = this.allNodes.find(function(node) {
|
|
9992
|
-
return node.name === name;
|
|
9993
|
-
});
|
|
9994
|
-
}
|
|
9995
|
-
return cache[name];
|
|
9996
|
-
};
|
|
9997
|
-
/**
|
|
9998
|
-
* 根据节点 id 查询节点变换,如果查询不到节点就直接返回基础变换
|
|
9999
|
-
* @param nodeId - 节点 id
|
|
10000
|
-
* @returns
|
|
10001
|
-
*/ _proto.getNodeTransform = function getNodeTransform(nodeId) {
|
|
10002
|
-
var node = this.getNodeById(nodeId);
|
|
10003
|
-
return node ? node.transform : this.baseTransform;
|
|
10004
|
-
};
|
|
10005
|
-
/**
|
|
10006
|
-
* 销毁场景树对象
|
|
10007
|
-
*/ _proto.dispose = function dispose() {
|
|
10008
|
-
var _this_animationManager;
|
|
10009
|
-
this.allNodes = [];
|
|
10010
|
-
this.nodes = [];
|
|
10011
|
-
this.cacheMap = {};
|
|
10012
|
-
// @ts-expect-error
|
|
10013
|
-
this.baseTransform = null;
|
|
10014
|
-
(_this_animationManager = this.animationManager) == null ? void 0 : _this_animationManager.dispose();
|
|
10015
|
-
// @ts-expect-error
|
|
10016
|
-
this.animationManager = null;
|
|
10017
|
-
};
|
|
10018
|
-
_proto.build = function build(options) {
|
|
10019
|
-
var _this = this;
|
|
10020
|
-
var topTransform = this.baseTransform;
|
|
10021
|
-
var nodes = options.nodes.map(function(node, i) {
|
|
10022
|
-
return {
|
|
10023
|
-
name: node.name || node.id || i + "",
|
|
10024
|
-
transform: new EFFECTS.Transform(_extends({}, node.transform, {
|
|
10025
|
-
valid: true
|
|
10026
|
-
}), topTransform),
|
|
10027
|
-
id: "^" + (node.id || i),
|
|
10028
|
-
children: [],
|
|
10029
|
-
tree: _this
|
|
10030
|
-
};
|
|
10031
|
-
});
|
|
10032
|
-
this.cacheMap = {};
|
|
10033
|
-
nodes.forEach(function(node, i) {
|
|
10034
|
-
var children = options.nodes[i].children;
|
|
10035
|
-
// @ts-expect-error
|
|
10036
|
-
node.transform.name = node.name;
|
|
10037
|
-
node.transform.setValid(true);
|
|
10038
|
-
if (children) {
|
|
10039
|
-
children.forEach(function(index) {
|
|
10040
|
-
var child = nodes[index];
|
|
10041
|
-
if (child && child !== node) {
|
|
10042
|
-
if (child.transform.parentTransform !== topTransform) {
|
|
10043
|
-
console.error("Node parent has been set.");
|
|
10044
|
-
}
|
|
10045
|
-
child.transform.parentTransform = node.transform;
|
|
10046
|
-
node.children.push(child);
|
|
10047
|
-
}
|
|
10048
|
-
});
|
|
10049
|
-
}
|
|
10050
|
-
});
|
|
10051
|
-
this.allNodes = nodes;
|
|
10052
|
-
this.nodes = options.children.map(function(i) {
|
|
10053
|
-
return nodes[i];
|
|
10054
|
-
});
|
|
10055
|
-
};
|
|
10056
|
-
return ModelTreeItem;
|
|
10057
|
-
}();
|
|
10058
9633
|
exports.ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
|
|
10059
9634
|
_inherits(ModelTreeComponent, Behaviour);
|
|
10060
9635
|
function ModelTreeComponent(engine, options) {
|
|
@@ -10072,56 +9647,6 @@ exports.ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
|
|
|
10072
9647
|
*/ _proto.fromData = function fromData(options) {
|
|
10073
9648
|
Behaviour.prototype.fromData.call(this, options);
|
|
10074
9649
|
this.options = options;
|
|
10075
|
-
this.createContent();
|
|
10076
|
-
};
|
|
10077
|
-
/**
|
|
10078
|
-
* 组件开始,查询合成中场景管理器并设置到动画管理器中
|
|
10079
|
-
*/ _proto.onStart = function onStart() {
|
|
10080
|
-
this.item.type = EFFECTS.spec.ItemType.tree;
|
|
10081
|
-
this.content.baseTransform.setValid(true);
|
|
10082
|
-
var sceneManager = getSceneManager(this);
|
|
10083
|
-
if (sceneManager) {
|
|
10084
|
-
this.content.animationManager.setSceneManager(sceneManager);
|
|
10085
|
-
}
|
|
10086
|
-
};
|
|
10087
|
-
/**
|
|
10088
|
-
* 组件更新,内部对象更新
|
|
10089
|
-
* @param dt
|
|
10090
|
-
*/ _proto.onUpdate = function onUpdate(dt) {
|
|
10091
|
-
var // this.timeline?.getRenderData(time, true);
|
|
10092
|
-
// TODO: 需要使用lifetime
|
|
10093
|
-
_this_content;
|
|
10094
|
-
(_this_content = this.content) == null ? void 0 : _this_content.tick(dt);
|
|
10095
|
-
};
|
|
10096
|
-
/**
|
|
10097
|
-
* 组件销毁,内部对象销毁
|
|
10098
|
-
*/ _proto.onDestroy = function onDestroy() {
|
|
10099
|
-
var _this_content;
|
|
10100
|
-
(_this_content = this.content) == null ? void 0 : _this_content.dispose();
|
|
10101
|
-
};
|
|
10102
|
-
/**
|
|
10103
|
-
* 创建内部场景树元素
|
|
10104
|
-
*/ _proto.createContent = function createContent() {
|
|
10105
|
-
if (this.options) {
|
|
10106
|
-
var treeOptions = this.options.options.tree;
|
|
10107
|
-
this.content = new ModelTreeItem(treeOptions, this.item);
|
|
10108
|
-
}
|
|
10109
|
-
};
|
|
10110
|
-
/**
|
|
10111
|
-
* 获取元素的变换
|
|
10112
|
-
* @param itemId - 元素索引
|
|
10113
|
-
* @returns
|
|
10114
|
-
*/ _proto.getNodeTransform = function getNodeTransform(itemId) {
|
|
10115
|
-
if (this.content === undefined) {
|
|
10116
|
-
return this.transform;
|
|
10117
|
-
}
|
|
10118
|
-
var idWithSubfix = this.item.id + "^";
|
|
10119
|
-
if (itemId.indexOf(idWithSubfix) === 0) {
|
|
10120
|
-
var nodeId = itemId.substring(idWithSubfix.length);
|
|
10121
|
-
return this.content.getNodeTransform(nodeId);
|
|
10122
|
-
} else {
|
|
10123
|
-
return this.transform;
|
|
10124
|
-
}
|
|
10125
9650
|
};
|
|
10126
9651
|
return ModelTreeComponent;
|
|
10127
9652
|
}(EFFECTS.Behaviour);
|
|
@@ -10129,24 +9654,6 @@ exports.ModelTreeComponent = __decorate([
|
|
|
10129
9654
|
EFFECTS.effectsClass(EFFECTS.spec.DataType.TreeComponent)
|
|
10130
9655
|
], exports.ModelTreeComponent);
|
|
10131
9656
|
|
|
10132
|
-
/**
|
|
10133
|
-
* 场景树插件类,支持 3D 相关的节点动画和骨骼动画等
|
|
10134
|
-
*/ var ModelTreePlugin = /*#__PURE__*/ function(AbstractPlugin) {
|
|
10135
|
-
_inherits(ModelTreePlugin, AbstractPlugin);
|
|
10136
|
-
function ModelTreePlugin() {
|
|
10137
|
-
var _this;
|
|
10138
|
-
_this = AbstractPlugin.apply(this, arguments) || this;
|
|
10139
|
-
/**
|
|
10140
|
-
* 插件名称
|
|
10141
|
-
*/ _this.name = "tree";
|
|
10142
|
-
/**
|
|
10143
|
-
* 高优先级更新
|
|
10144
|
-
*/ _this.order = 2;
|
|
10145
|
-
return _this;
|
|
10146
|
-
}
|
|
10147
|
-
return ModelTreePlugin;
|
|
10148
|
-
}(EFFECTS.AbstractPlugin);
|
|
10149
|
-
|
|
10150
9657
|
exports.CameraGestureType = void 0;
|
|
10151
9658
|
(function(CameraGestureType) {
|
|
10152
9659
|
CameraGestureType[CameraGestureType["none"] = 0] = "none";
|
|
@@ -10684,7 +10191,7 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
10684
10191
|
_proto.processScene = function processScene(sceneData) {
|
|
10685
10192
|
var _this = this;
|
|
10686
10193
|
return _async_to_generator(function() {
|
|
10687
|
-
var sceneJSON, _tmp, oldScene, _oldScene_bins, oldBinUrls, binFiles, _iterator, _step, bin, _, newScene;
|
|
10194
|
+
var sceneJSON, _tmp, oldScene, _oldScene_bins, oldBinUrls, binFiles, v, _iterator, _step, bin, _, newScene;
|
|
10688
10195
|
return __generator(this, function(_state) {
|
|
10689
10196
|
switch(_state.label){
|
|
10690
10197
|
case 0:
|
|
@@ -10721,6 +10228,14 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
10721
10228
|
oldScene = EFFECTS.getStandardJSON(sceneJSON);
|
|
10722
10229
|
oldBinUrls = (_oldScene_bins = oldScene.bins) != null ? _oldScene_bins : [];
|
|
10723
10230
|
binFiles = [];
|
|
10231
|
+
//@ts-expect-error
|
|
10232
|
+
v = sceneJSON.version.split(".");
|
|
10233
|
+
if (Number(v[0]) >= 3) {
|
|
10234
|
+
return [
|
|
10235
|
+
2,
|
|
10236
|
+
oldScene
|
|
10237
|
+
];
|
|
10238
|
+
}
|
|
10724
10239
|
if (!oldScene.bins) return [
|
|
10725
10240
|
3,
|
|
10726
10241
|
7
|
|
@@ -10920,7 +10435,6 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
10920
10435
|
this.createItemsFromTreeComponent(comp, newScene, oldScene);
|
|
10921
10436
|
treeComp.options.tree.animation = undefined;
|
|
10922
10437
|
treeComp.options.tree.animations = undefined;
|
|
10923
|
-
newComponents.push(comp);
|
|
10924
10438
|
} else if (comp.dataType !== EFFECTS.spec.DataType.MeshComponent) {
|
|
10925
10439
|
newComponents.push(comp);
|
|
10926
10440
|
}
|
|
@@ -11358,6 +10872,7 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
11358
10872
|
});
|
|
11359
10873
|
});
|
|
11360
10874
|
}
|
|
10875
|
+
treeItem.components = [];
|
|
11361
10876
|
treeItem.components.push({
|
|
11362
10877
|
id: animationComponent.id
|
|
11363
10878
|
});
|
|
@@ -12829,43 +12344,6 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12829
12344
|
});
|
|
12830
12345
|
return sceneAABB;
|
|
12831
12346
|
};
|
|
12832
|
-
/**
|
|
12833
|
-
* 按照传入的动画播放参数,计算需要播放的动画索引
|
|
12834
|
-
*
|
|
12835
|
-
* @param treeOptions 节点树属性,需要初始化animations列表。
|
|
12836
|
-
* @returns 返回计算的动画索引,-1表示没有动画需要播放,-88888888表示播放所有动画。
|
|
12837
|
-
*/ _proto.getPlayAnimationIndex = function getPlayAnimationIndex(treeOptions) {
|
|
12838
|
-
var animations = treeOptions.animations;
|
|
12839
|
-
if (animations === undefined || animations.length <= 0) {
|
|
12840
|
-
// 硬编码,内部指定的不播放动画的索引值
|
|
12841
|
-
return -1;
|
|
12842
|
-
}
|
|
12843
|
-
if (this.isPlayAllAnimation()) {
|
|
12844
|
-
// 硬编码,内部指定的播放全部动画的索引值
|
|
12845
|
-
return -88888888;
|
|
12846
|
-
}
|
|
12847
|
-
var animationInfo = this.sceneOptions.effects.playAnimation;
|
|
12848
|
-
if (animationInfo === undefined) {
|
|
12849
|
-
return -1;
|
|
12850
|
-
}
|
|
12851
|
-
if (typeof animationInfo === "number") {
|
|
12852
|
-
if (animationInfo >= 0 && animationInfo < animations.length) {
|
|
12853
|
-
return animationInfo;
|
|
12854
|
-
} else {
|
|
12855
|
-
return -1;
|
|
12856
|
-
}
|
|
12857
|
-
} else {
|
|
12858
|
-
// typeof animationInfo === 'string'
|
|
12859
|
-
var animationIndex = -1;
|
|
12860
|
-
// 通过动画名字查找动画索引
|
|
12861
|
-
animations.forEach(function(anim, index) {
|
|
12862
|
-
if (anim.name === animationInfo) {
|
|
12863
|
-
animationIndex = index;
|
|
12864
|
-
}
|
|
12865
|
-
});
|
|
12866
|
-
return animationIndex;
|
|
12867
|
-
}
|
|
12868
|
-
};
|
|
12869
12347
|
_proto.isPlayAnimation = function isPlayAnimation() {
|
|
12870
12348
|
return this.sceneOptions.effects.playAnimation !== undefined;
|
|
12871
12349
|
};
|
|
@@ -13007,64 +12485,6 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
13007
12485
|
}
|
|
13008
12486
|
});
|
|
13009
12487
|
};
|
|
13010
|
-
_proto.createTreeOptions = function createTreeOptions(scene) {
|
|
13011
|
-
var nodeList = scene.nodes.map(function(node, nodeIndex) {
|
|
13012
|
-
var children = node.children.map(function(child) {
|
|
13013
|
-
if (child.nodeIndex === undefined) {
|
|
13014
|
-
throw new Error("Undefined nodeIndex for child " + child);
|
|
13015
|
-
}
|
|
13016
|
-
return child.nodeIndex;
|
|
13017
|
-
});
|
|
13018
|
-
var pos;
|
|
13019
|
-
var quat;
|
|
13020
|
-
var scale;
|
|
13021
|
-
if (node.matrix !== undefined) {
|
|
13022
|
-
if (node.matrix.length !== 16) {
|
|
13023
|
-
throw new Error("Invalid matrix length " + node.matrix.length + " for node " + node);
|
|
13024
|
-
}
|
|
13025
|
-
var mat = Matrix4.fromArray(node.matrix);
|
|
13026
|
-
var transform = mat.getTransform();
|
|
13027
|
-
pos = transform.translation.toArray();
|
|
13028
|
-
quat = transform.rotation.toArray();
|
|
13029
|
-
scale = transform.scale.toArray();
|
|
13030
|
-
} else {
|
|
13031
|
-
if (node.translation !== undefined) {
|
|
13032
|
-
pos = node.translation;
|
|
13033
|
-
}
|
|
13034
|
-
if (node.rotation !== undefined) {
|
|
13035
|
-
quat = node.rotation;
|
|
13036
|
-
}
|
|
13037
|
-
if (node.scale !== undefined) {
|
|
13038
|
-
scale = node.scale;
|
|
13039
|
-
}
|
|
13040
|
-
}
|
|
13041
|
-
node.nodeIndex = nodeIndex;
|
|
13042
|
-
var treeNode = {
|
|
13043
|
-
name: node.name,
|
|
13044
|
-
transform: {
|
|
13045
|
-
position: pos,
|
|
13046
|
-
quat: quat,
|
|
13047
|
-
scale: scale
|
|
13048
|
-
},
|
|
13049
|
-
children: children,
|
|
13050
|
-
id: "" + node.nodeIndex
|
|
13051
|
-
};
|
|
13052
|
-
return treeNode;
|
|
13053
|
-
});
|
|
13054
|
-
var rootNodes = scene.rootNodes.map(function(root) {
|
|
13055
|
-
if (root.nodeIndex === undefined) {
|
|
13056
|
-
throw new Error("Undefined nodeIndex for root " + root);
|
|
13057
|
-
}
|
|
13058
|
-
return root.nodeIndex;
|
|
13059
|
-
});
|
|
13060
|
-
var treeOptions = {
|
|
13061
|
-
nodes: nodeList,
|
|
13062
|
-
children: rootNodes,
|
|
13063
|
-
animation: -1,
|
|
13064
|
-
animations: []
|
|
13065
|
-
};
|
|
13066
|
-
return treeOptions;
|
|
13067
|
-
};
|
|
13068
12488
|
_proto.createAnimations = function createAnimations(animations) {
|
|
13069
12489
|
return animations.map(function(anim) {
|
|
13070
12490
|
var tracks = anim.channels.map(function(channel) {
|
|
@@ -13814,9 +13234,8 @@ var GLTFHelper = /*#__PURE__*/ function() {
|
|
|
13814
13234
|
return GLTFHelper;
|
|
13815
13235
|
}();
|
|
13816
13236
|
|
|
13817
|
-
EFFECTS.registerPlugin("tree", ModelTreePlugin, EFFECTS.VFXItem, true);
|
|
13818
13237
|
EFFECTS.registerPlugin("model", ModelPlugin, EFFECTS.VFXItem);
|
|
13819
|
-
var version = "2.1.0-alpha.
|
|
13238
|
+
var version = "2.1.0-alpha.8";
|
|
13820
13239
|
EFFECTS.logger.info("Plugin model version: " + version + ".");
|
|
13821
13240
|
if (version !== EFFECTS__namespace.version) {
|
|
13822
13241
|
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!");
|
|
@@ -13845,12 +13264,7 @@ exports.Matrix3 = Matrix3;
|
|
|
13845
13264
|
exports.Matrix4 = Matrix4;
|
|
13846
13265
|
exports.MeshHelper = MeshHelper;
|
|
13847
13266
|
exports.ModelPlugin = ModelPlugin;
|
|
13848
|
-
exports.ModelTreeItem = ModelTreeItem;
|
|
13849
|
-
exports.ModelTreePlugin = ModelTreePlugin;
|
|
13850
13267
|
exports.PAnimTexture = PAnimTexture;
|
|
13851
|
-
exports.PAnimTrack = PAnimTrack;
|
|
13852
|
-
exports.PAnimation = PAnimation;
|
|
13853
|
-
exports.PAnimationManager = PAnimationManager;
|
|
13854
13268
|
exports.PBRShaderGUID = PBRShaderGUID;
|
|
13855
13269
|
exports.PCamera = PCamera;
|
|
13856
13270
|
exports.PCameraManager = PCameraManager;
|