@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/douyin.mjs
CHANGED
|
@@ -1480,144 +1480,6 @@ var PAnimPathType;
|
|
|
1480
1480
|
PAnimPathType[PAnimPathType["scale"] = 2] = "scale";
|
|
1481
1481
|
PAnimPathType[PAnimPathType["weights"] = 3] = "weights";
|
|
1482
1482
|
})(PAnimPathType || (PAnimPathType = {}));
|
|
1483
|
-
/**
|
|
1484
|
-
* 动画轨道类
|
|
1485
|
-
*/ var PAnimTrack = /*#__PURE__*/ function() {
|
|
1486
|
-
function PAnimTrack(options) {
|
|
1487
|
-
/**
|
|
1488
|
-
* 路径类型
|
|
1489
|
-
*/ this.path = 0;
|
|
1490
|
-
/**
|
|
1491
|
-
* 插值类型
|
|
1492
|
-
*/ this.interp = 0;
|
|
1493
|
-
var node = options.node, input = options.input, output = options.output, path = options.path, interpolation = options.interpolation;
|
|
1494
|
-
this.node = node;
|
|
1495
|
-
this.timeArray = input;
|
|
1496
|
-
this.dataArray = output;
|
|
1497
|
-
//
|
|
1498
|
-
if (path === "translation") {
|
|
1499
|
-
this.path = 0;
|
|
1500
|
-
this.component = 3;
|
|
1501
|
-
} else if (path === "rotation") {
|
|
1502
|
-
this.path = 1;
|
|
1503
|
-
this.component = 4;
|
|
1504
|
-
} else if (path === "scale") {
|
|
1505
|
-
this.path = 2;
|
|
1506
|
-
this.component = 3;
|
|
1507
|
-
} else if (path === "weights") {
|
|
1508
|
-
this.path = 3;
|
|
1509
|
-
this.component = this.dataArray.length / this.timeArray.length;
|
|
1510
|
-
// special checker for weights animation
|
|
1511
|
-
if (this.component <= 0) {
|
|
1512
|
-
console.error("Invalid weights component: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
|
|
1513
|
-
} else if (this.timeArray.length * this.component != this.dataArray.length) {
|
|
1514
|
-
console.error("Invalid weights array length: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
|
|
1515
|
-
}
|
|
1516
|
-
} else {
|
|
1517
|
-
// should never happened
|
|
1518
|
-
console.error("Invalid path status: " + path + ".");
|
|
1519
|
-
}
|
|
1520
|
-
if (this.timeArray.length * this.component > this.dataArray.length) {
|
|
1521
|
-
throw new Error("Data length mismatch: " + this.timeArray.length + ", " + this.component + ", " + this.dataArray.length + ".");
|
|
1522
|
-
}
|
|
1523
|
-
if (interpolation === "LINEAR") {
|
|
1524
|
-
this.interp = 0;
|
|
1525
|
-
} else if (interpolation === "STEP") {
|
|
1526
|
-
this.interp = 1;
|
|
1527
|
-
} else {
|
|
1528
|
-
this.interp = 2;
|
|
1529
|
-
}
|
|
1530
|
-
this.sampler = createAnimationSampler(this.getInterpInfo(), this.timeArray, this.dataArray, this.component, this.getPathInfo());
|
|
1531
|
-
}
|
|
1532
|
-
var _proto = PAnimTrack.prototype;
|
|
1533
|
-
/**
|
|
1534
|
-
* 销毁
|
|
1535
|
-
*/ _proto.dispose = function dispose() {
|
|
1536
|
-
var _this_sampler;
|
|
1537
|
-
// @ts-expect-error
|
|
1538
|
-
this.timeArray = undefined;
|
|
1539
|
-
// @ts-expect-error
|
|
1540
|
-
this.dataArray = undefined;
|
|
1541
|
-
(_this_sampler = this.sampler) == null ? void 0 : _this_sampler.dispose();
|
|
1542
|
-
this.sampler = undefined;
|
|
1543
|
-
};
|
|
1544
|
-
/**
|
|
1545
|
-
* 更新节点动画数据
|
|
1546
|
-
* @param time - 当前播放时间
|
|
1547
|
-
* @param treeItem - 节点树元素
|
|
1548
|
-
* @param sceneManager - 3D 场景管理器
|
|
1549
|
-
*/ _proto.tick = function tick(time, treeItem, sceneManager) {
|
|
1550
|
-
var _treeComponent_content;
|
|
1551
|
-
var treeComponent = treeItem.getComponent(ModelTreeComponent);
|
|
1552
|
-
var node = treeComponent == null ? void 0 : (_treeComponent_content = treeComponent.content) == null ? void 0 : _treeComponent_content.getNodeById(this.node);
|
|
1553
|
-
if (this.sampler !== undefined && node !== undefined) {
|
|
1554
|
-
var result = this.sampler.evaluate(time);
|
|
1555
|
-
switch(this.path){
|
|
1556
|
-
case 0:
|
|
1557
|
-
node.transform.setPosition(result[0], result[1], result[2]);
|
|
1558
|
-
break;
|
|
1559
|
-
case 1:
|
|
1560
|
-
node.transform.setQuaternion(result[0], result[1], result[2], result[3]);
|
|
1561
|
-
break;
|
|
1562
|
-
case 2:
|
|
1563
|
-
node.transform.setScale(result[0], result[1], result[2]);
|
|
1564
|
-
break;
|
|
1565
|
-
case 3:
|
|
1566
|
-
{
|
|
1567
|
-
/**
|
|
1568
|
-
* 先生成Mesh的父节点id,然后通过id查询Mesh对象
|
|
1569
|
-
* 最后更新Mesh对象权重数据
|
|
1570
|
-
*/ var parentId = this.genParentId(treeItem.id, this.node);
|
|
1571
|
-
var mesh = sceneManager == null ? void 0 : sceneManager.queryMesh(parentId);
|
|
1572
|
-
if (mesh !== undefined) {
|
|
1573
|
-
mesh.updateMorphWeights(result);
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
break;
|
|
1577
|
-
}
|
|
1578
|
-
} else {
|
|
1579
|
-
if (this.sampler !== undefined) {
|
|
1580
|
-
console.error("AnimTrack: error", this.sampler, node);
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
};
|
|
1584
|
-
/**
|
|
1585
|
-
* 获取动画结束时间
|
|
1586
|
-
* @returns
|
|
1587
|
-
*/ _proto.getEndTime = function getEndTime() {
|
|
1588
|
-
var index = this.timeArray.length - 1;
|
|
1589
|
-
return this.timeArray[index];
|
|
1590
|
-
};
|
|
1591
|
-
/**
|
|
1592
|
-
* 生成 Mesh 元素的父节点
|
|
1593
|
-
*
|
|
1594
|
-
* @param parentId - 父节点 id 名称
|
|
1595
|
-
* @param nodeIndex - Mesh 节点索引
|
|
1596
|
-
*
|
|
1597
|
-
* @returns 生成的 Mesh 节点名称
|
|
1598
|
-
*/ _proto.genParentId = function genParentId(parentId, nodeIndex) {
|
|
1599
|
-
return parentId + "^" + nodeIndex;
|
|
1600
|
-
};
|
|
1601
|
-
_proto.getPathInfo = function getPathInfo() {
|
|
1602
|
-
if (this.path === 2) {
|
|
1603
|
-
return "scale";
|
|
1604
|
-
} else if (this.path === 1) {
|
|
1605
|
-
return "rotation";
|
|
1606
|
-
} else {
|
|
1607
|
-
return "translation";
|
|
1608
|
-
}
|
|
1609
|
-
};
|
|
1610
|
-
_proto.getInterpInfo = function getInterpInfo() {
|
|
1611
|
-
if (this.interp === 2) {
|
|
1612
|
-
return "CUBICSPLINE";
|
|
1613
|
-
} else if (this.interp === 1) {
|
|
1614
|
-
return "STEP";
|
|
1615
|
-
} else {
|
|
1616
|
-
return "LINEAR";
|
|
1617
|
-
}
|
|
1618
|
-
};
|
|
1619
|
-
return PAnimTrack;
|
|
1620
|
-
}();
|
|
1621
1483
|
/**
|
|
1622
1484
|
* 动画纹理类
|
|
1623
1485
|
*/ var PAnimTexture = /*#__PURE__*/ function() {
|
|
@@ -1704,148 +1566,6 @@ var PAnimPathType;
|
|
|
1704
1566
|
};
|
|
1705
1567
|
return PAnimTexture;
|
|
1706
1568
|
}();
|
|
1707
|
-
/**
|
|
1708
|
-
* 动画类,负责动画数据创建、更新和销毁
|
|
1709
|
-
*/ var PAnimation = /*#__PURE__*/ function(PObject) {
|
|
1710
|
-
_inherits(PAnimation, PObject);
|
|
1711
|
-
function PAnimation() {
|
|
1712
|
-
var _this;
|
|
1713
|
-
_this = PObject.apply(this, arguments) || this;
|
|
1714
|
-
_this.time = 0;
|
|
1715
|
-
_this.duration = 0;
|
|
1716
|
-
_this.tracks = [];
|
|
1717
|
-
return _this;
|
|
1718
|
-
}
|
|
1719
|
-
var _proto = PAnimation.prototype;
|
|
1720
|
-
/**
|
|
1721
|
-
* 创建动画对象
|
|
1722
|
-
* @param options - 动画参数
|
|
1723
|
-
*/ _proto.create = function create(options) {
|
|
1724
|
-
var _this = this;
|
|
1725
|
-
var _options_name;
|
|
1726
|
-
this.name = this.genName((_options_name = options.name) != null ? _options_name : "Unnamed animation");
|
|
1727
|
-
this.type = PObjectType.animation;
|
|
1728
|
-
//
|
|
1729
|
-
this.time = 0;
|
|
1730
|
-
this.duration = 0;
|
|
1731
|
-
//
|
|
1732
|
-
this.tracks = [];
|
|
1733
|
-
options.tracks.forEach(function(inTrack) {
|
|
1734
|
-
var track = new PAnimTrack(inTrack);
|
|
1735
|
-
_this.tracks.push(track);
|
|
1736
|
-
_this.duration = Math.max(_this.duration, track.getEndTime());
|
|
1737
|
-
});
|
|
1738
|
-
};
|
|
1739
|
-
/**
|
|
1740
|
-
* 动画更新
|
|
1741
|
-
* @param time - 当前时间
|
|
1742
|
-
* @param treeItem - 场景树元素
|
|
1743
|
-
* @param sceneManager - 3D 场景管理器
|
|
1744
|
-
*/ _proto.tick = function tick(time, treeItem, sceneManager) {
|
|
1745
|
-
this.time = time;
|
|
1746
|
-
// TODO: 这里时间事件定义不明确,先兼容原先实现
|
|
1747
|
-
var newTime = this.time % this.duration;
|
|
1748
|
-
this.tracks.forEach(function(track) {
|
|
1749
|
-
track.tick(newTime, treeItem, sceneManager);
|
|
1750
|
-
});
|
|
1751
|
-
};
|
|
1752
|
-
/**
|
|
1753
|
-
* 销毁
|
|
1754
|
-
*/ _proto.dispose = function dispose() {
|
|
1755
|
-
this.tracks.forEach(function(track) {
|
|
1756
|
-
track.dispose();
|
|
1757
|
-
});
|
|
1758
|
-
this.tracks = [];
|
|
1759
|
-
};
|
|
1760
|
-
return PAnimation;
|
|
1761
|
-
}(PObject);
|
|
1762
|
-
/**
|
|
1763
|
-
* 动画管理类,负责管理动画对象
|
|
1764
|
-
*/ var PAnimationManager = /*#__PURE__*/ function(PObject) {
|
|
1765
|
-
_inherits(PAnimationManager, PObject);
|
|
1766
|
-
function PAnimationManager(treeOptions, ownerItem) {
|
|
1767
|
-
var _this;
|
|
1768
|
-
_this = PObject.call(this) || this;
|
|
1769
|
-
_this.animation = 0;
|
|
1770
|
-
_this.speed = 0;
|
|
1771
|
-
_this.delay = 0;
|
|
1772
|
-
_this.time = 0;
|
|
1773
|
-
_this.animations = [];
|
|
1774
|
-
var _ownerItem_name;
|
|
1775
|
-
_this.name = _this.genName((_ownerItem_name = ownerItem.name) != null ? _ownerItem_name : "Unnamed tree");
|
|
1776
|
-
_this.type = PObjectType.animationManager;
|
|
1777
|
-
//
|
|
1778
|
-
_this.ownerItem = ownerItem;
|
|
1779
|
-
var _treeOptions_animation;
|
|
1780
|
-
_this.animation = (_treeOptions_animation = treeOptions.animation) != null ? _treeOptions_animation : -1;
|
|
1781
|
-
_this.speed = 1.0;
|
|
1782
|
-
var _ownerItem_start;
|
|
1783
|
-
_this.delay = (_ownerItem_start = ownerItem.start) != null ? _ownerItem_start : 0;
|
|
1784
|
-
_this.animations = [];
|
|
1785
|
-
if (treeOptions.animations !== undefined) {
|
|
1786
|
-
treeOptions.animations.forEach(function(animOpts) {
|
|
1787
|
-
var anim = _this.createAnimation(animOpts);
|
|
1788
|
-
_this.animations.push(anim);
|
|
1789
|
-
});
|
|
1790
|
-
}
|
|
1791
|
-
return _this;
|
|
1792
|
-
}
|
|
1793
|
-
var _proto = PAnimationManager.prototype;
|
|
1794
|
-
/**
|
|
1795
|
-
* 设置场景管理器
|
|
1796
|
-
* @param sceneManager - 场景管理器
|
|
1797
|
-
*/ _proto.setSceneManager = function setSceneManager(sceneManager) {
|
|
1798
|
-
this.sceneManager = sceneManager;
|
|
1799
|
-
};
|
|
1800
|
-
/**
|
|
1801
|
-
* 创建动画对象
|
|
1802
|
-
* @param animationOpts - 动画参数
|
|
1803
|
-
* @returns 动画对象
|
|
1804
|
-
*/ _proto.createAnimation = function createAnimation(animationOpts) {
|
|
1805
|
-
var animation = new PAnimation();
|
|
1806
|
-
animation.create(animationOpts);
|
|
1807
|
-
return animation;
|
|
1808
|
-
};
|
|
1809
|
-
/**
|
|
1810
|
-
* 动画更新
|
|
1811
|
-
* @param deltaSeconds - 更新间隔
|
|
1812
|
-
*/ _proto.tick = function tick(deltaSeconds) {
|
|
1813
|
-
var _this = this;
|
|
1814
|
-
var newDeltaSeconds = deltaSeconds * this.speed * 0.001;
|
|
1815
|
-
this.time += newDeltaSeconds;
|
|
1816
|
-
// TODO: 需要合并到TreeItem中,通过lifetime进行计算
|
|
1817
|
-
var itemTime = this.time - this.delay;
|
|
1818
|
-
if (itemTime >= 0) {
|
|
1819
|
-
if (this.animation >= 0 && this.animation < this.animations.length) {
|
|
1820
|
-
var anim = this.animations[this.animation];
|
|
1821
|
-
anim.tick(itemTime, this.ownerItem, this.sceneManager);
|
|
1822
|
-
} else if (this.animation == -88888888) {
|
|
1823
|
-
this.animations.forEach(function(anim) {
|
|
1824
|
-
anim.tick(itemTime, _this.ownerItem, _this.sceneManager);
|
|
1825
|
-
});
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
};
|
|
1829
|
-
/**
|
|
1830
|
-
* 销毁
|
|
1831
|
-
*/ _proto.dispose = function dispose() {
|
|
1832
|
-
// @ts-expect-error
|
|
1833
|
-
this.ownerItem = null;
|
|
1834
|
-
this.animations.forEach(function(anim) {
|
|
1835
|
-
anim.dispose();
|
|
1836
|
-
});
|
|
1837
|
-
this.animations = [];
|
|
1838
|
-
// @ts-expect-error
|
|
1839
|
-
this.sceneManager = null;
|
|
1840
|
-
};
|
|
1841
|
-
/**
|
|
1842
|
-
* 获取场景树元素
|
|
1843
|
-
* @returns
|
|
1844
|
-
*/ _proto.getTreeItem = function getTreeItem() {
|
|
1845
|
-
return this.ownerItem;
|
|
1846
|
-
};
|
|
1847
|
-
return PAnimationManager;
|
|
1848
|
-
}(PObject);
|
|
1849
1569
|
|
|
1850
1570
|
var deg2rad = Math.PI / 180;
|
|
1851
1571
|
/**
|
|
@@ -3495,15 +3215,6 @@ var EffectsMeshProxy = /*#__PURE__*/ function() {
|
|
|
3495
3215
|
_proto.isHide = function isHide() {
|
|
3496
3216
|
return this.data.hide === true;
|
|
3497
3217
|
};
|
|
3498
|
-
_proto.getParentNode = function getParentNode() {
|
|
3499
|
-
var _this_parentItem;
|
|
3500
|
-
var nodeIndex = this.getParentIndex();
|
|
3501
|
-
var parentTree = (_this_parentItem = this.parentItem) == null ? void 0 : _this_parentItem.getComponent(ModelTreeComponent);
|
|
3502
|
-
if (parentTree !== undefined && nodeIndex >= 0) {
|
|
3503
|
-
return parentTree.content.getNodeById(nodeIndex);
|
|
3504
|
-
}
|
|
3505
|
-
return undefined;
|
|
3506
|
-
};
|
|
3507
3218
|
_proto.getParentIndex = function getParentIndex() {
|
|
3508
3219
|
return -1;
|
|
3509
3220
|
};
|
|
@@ -6174,31 +5885,6 @@ var normal = new Vector3();
|
|
|
6174
5885
|
console.error("setupItem3DOptions: Invalid inverseBindMatrices type, " + inverseBindMatrices + ".");
|
|
6175
5886
|
}
|
|
6176
5887
|
}
|
|
6177
|
-
} else if (item.type === spec.ItemType.tree) {
|
|
6178
|
-
var jsonItem = item;
|
|
6179
|
-
var studioItem = item;
|
|
6180
|
-
var jsonAnimations = jsonItem.content.options.tree.animations;
|
|
6181
|
-
var studioAnimations = studioItem.content.options.tree.animations;
|
|
6182
|
-
if (jsonAnimations !== undefined && studioAnimations !== undefined) {
|
|
6183
|
-
jsonAnimations.forEach(function(jsonAnim, i) {
|
|
6184
|
-
var studioAnim = studioAnimations[i];
|
|
6185
|
-
jsonAnim.tracks.forEach(function(jsonTrack, j) {
|
|
6186
|
-
var inputArray = typedArrayFromBinary(scene.bins, jsonTrack.input);
|
|
6187
|
-
var outputArray = typedArrayFromBinary(scene.bins, jsonTrack.output);
|
|
6188
|
-
var studioTrack = studioAnim.tracks[j];
|
|
6189
|
-
if (_instanceof1(inputArray, Float32Array)) {
|
|
6190
|
-
studioTrack.input = inputArray;
|
|
6191
|
-
} else {
|
|
6192
|
-
console.error("setupItem3DOptions: Type of inputArray should be float32, " + inputArray + ".");
|
|
6193
|
-
}
|
|
6194
|
-
if (_instanceof1(outputArray, Float32Array)) {
|
|
6195
|
-
studioTrack.output = outputArray;
|
|
6196
|
-
} else {
|
|
6197
|
-
console.error("setupItem3DOptions: Type of outputArray should be float32, " + outputArray + ".");
|
|
6198
|
-
}
|
|
6199
|
-
});
|
|
6200
|
-
});
|
|
6201
|
-
}
|
|
6202
5888
|
} else if (item.type === spec.ItemType.skybox) {
|
|
6203
5889
|
var skybox = item;
|
|
6204
5890
|
var studioSkybox = item;
|
|
@@ -9921,117 +9607,6 @@ ModelPluginComponent = __decorate([
|
|
|
9921
9607
|
return pluginComp == null ? void 0 : pluginComp.scene;
|
|
9922
9608
|
}
|
|
9923
9609
|
|
|
9924
|
-
/**
|
|
9925
|
-
* 场景树元素类,支持插件中节点树相关的动画能力
|
|
9926
|
-
*/ var ModelTreeItem = /*#__PURE__*/ function() {
|
|
9927
|
-
function ModelTreeItem(props, owner) {
|
|
9928
|
-
this.baseTransform = owner.transform;
|
|
9929
|
-
this.animationManager = new PAnimationManager(props, owner);
|
|
9930
|
-
this.build(props);
|
|
9931
|
-
}
|
|
9932
|
-
var _proto = ModelTreeItem.prototype;
|
|
9933
|
-
/**
|
|
9934
|
-
* 场景树更新,主要是动画更新
|
|
9935
|
-
* @param dt - 时间间隔
|
|
9936
|
-
*/ _proto.tick = function tick(dt) {
|
|
9937
|
-
this.animationManager.tick(dt);
|
|
9938
|
-
};
|
|
9939
|
-
/**
|
|
9940
|
-
* 获取所有节点
|
|
9941
|
-
* @returns
|
|
9942
|
-
*/ _proto.getNodes = function getNodes() {
|
|
9943
|
-
return this.nodes;
|
|
9944
|
-
};
|
|
9945
|
-
/**
|
|
9946
|
-
* 根据节点编号,查询节点
|
|
9947
|
-
* @param nodeId - 节点编号
|
|
9948
|
-
* @returns
|
|
9949
|
-
*/ _proto.getNodeById = function getNodeById(nodeId) {
|
|
9950
|
-
var cache = this.cacheMap;
|
|
9951
|
-
if (!cache[nodeId]) {
|
|
9952
|
-
var index = "^" + nodeId;
|
|
9953
|
-
// @ts-expect-error
|
|
9954
|
-
cache[nodeId] = this.allNodes.find(function(node) {
|
|
9955
|
-
return node.id === index;
|
|
9956
|
-
});
|
|
9957
|
-
}
|
|
9958
|
-
return cache[nodeId];
|
|
9959
|
-
};
|
|
9960
|
-
/**
|
|
9961
|
-
* 根据节点名称,查询节点
|
|
9962
|
-
* @param name - 名称
|
|
9963
|
-
* @returns
|
|
9964
|
-
*/ _proto.getNodeByName = function getNodeByName(name) {
|
|
9965
|
-
var cache = this.cacheMap;
|
|
9966
|
-
if (!cache[name]) {
|
|
9967
|
-
// @ts-expect-error
|
|
9968
|
-
cache[name] = this.allNodes.find(function(node) {
|
|
9969
|
-
return node.name === name;
|
|
9970
|
-
});
|
|
9971
|
-
}
|
|
9972
|
-
return cache[name];
|
|
9973
|
-
};
|
|
9974
|
-
/**
|
|
9975
|
-
* 根据节点 id 查询节点变换,如果查询不到节点就直接返回基础变换
|
|
9976
|
-
* @param nodeId - 节点 id
|
|
9977
|
-
* @returns
|
|
9978
|
-
*/ _proto.getNodeTransform = function getNodeTransform(nodeId) {
|
|
9979
|
-
var node = this.getNodeById(nodeId);
|
|
9980
|
-
return node ? node.transform : this.baseTransform;
|
|
9981
|
-
};
|
|
9982
|
-
/**
|
|
9983
|
-
* 销毁场景树对象
|
|
9984
|
-
*/ _proto.dispose = function dispose() {
|
|
9985
|
-
var _this_animationManager;
|
|
9986
|
-
this.allNodes = [];
|
|
9987
|
-
this.nodes = [];
|
|
9988
|
-
this.cacheMap = {};
|
|
9989
|
-
// @ts-expect-error
|
|
9990
|
-
this.baseTransform = null;
|
|
9991
|
-
(_this_animationManager = this.animationManager) == null ? void 0 : _this_animationManager.dispose();
|
|
9992
|
-
// @ts-expect-error
|
|
9993
|
-
this.animationManager = null;
|
|
9994
|
-
};
|
|
9995
|
-
_proto.build = function build(options) {
|
|
9996
|
-
var _this = this;
|
|
9997
|
-
var topTransform = this.baseTransform;
|
|
9998
|
-
var nodes = options.nodes.map(function(node, i) {
|
|
9999
|
-
return {
|
|
10000
|
-
name: node.name || node.id || i + "",
|
|
10001
|
-
transform: new Transform(_extends({}, node.transform, {
|
|
10002
|
-
valid: true
|
|
10003
|
-
}), topTransform),
|
|
10004
|
-
id: "^" + (node.id || i),
|
|
10005
|
-
children: [],
|
|
10006
|
-
tree: _this
|
|
10007
|
-
};
|
|
10008
|
-
});
|
|
10009
|
-
this.cacheMap = {};
|
|
10010
|
-
nodes.forEach(function(node, i) {
|
|
10011
|
-
var children = options.nodes[i].children;
|
|
10012
|
-
// @ts-expect-error
|
|
10013
|
-
node.transform.name = node.name;
|
|
10014
|
-
node.transform.setValid(true);
|
|
10015
|
-
if (children) {
|
|
10016
|
-
children.forEach(function(index) {
|
|
10017
|
-
var child = nodes[index];
|
|
10018
|
-
if (child && child !== node) {
|
|
10019
|
-
if (child.transform.parentTransform !== topTransform) {
|
|
10020
|
-
console.error("Node parent has been set.");
|
|
10021
|
-
}
|
|
10022
|
-
child.transform.parentTransform = node.transform;
|
|
10023
|
-
node.children.push(child);
|
|
10024
|
-
}
|
|
10025
|
-
});
|
|
10026
|
-
}
|
|
10027
|
-
});
|
|
10028
|
-
this.allNodes = nodes;
|
|
10029
|
-
this.nodes = options.children.map(function(i) {
|
|
10030
|
-
return nodes[i];
|
|
10031
|
-
});
|
|
10032
|
-
};
|
|
10033
|
-
return ModelTreeItem;
|
|
10034
|
-
}();
|
|
10035
9610
|
var ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
|
|
10036
9611
|
_inherits(ModelTreeComponent, Behaviour);
|
|
10037
9612
|
function ModelTreeComponent(engine, options) {
|
|
@@ -10049,56 +9624,6 @@ var ModelTreeComponent = /*#__PURE__*/ function(Behaviour) {
|
|
|
10049
9624
|
*/ _proto.fromData = function fromData(options) {
|
|
10050
9625
|
Behaviour.prototype.fromData.call(this, options);
|
|
10051
9626
|
this.options = options;
|
|
10052
|
-
this.createContent();
|
|
10053
|
-
};
|
|
10054
|
-
/**
|
|
10055
|
-
* 组件开始,查询合成中场景管理器并设置到动画管理器中
|
|
10056
|
-
*/ _proto.onStart = function onStart() {
|
|
10057
|
-
this.item.type = spec.ItemType.tree;
|
|
10058
|
-
this.content.baseTransform.setValid(true);
|
|
10059
|
-
var sceneManager = getSceneManager(this);
|
|
10060
|
-
if (sceneManager) {
|
|
10061
|
-
this.content.animationManager.setSceneManager(sceneManager);
|
|
10062
|
-
}
|
|
10063
|
-
};
|
|
10064
|
-
/**
|
|
10065
|
-
* 组件更新,内部对象更新
|
|
10066
|
-
* @param dt
|
|
10067
|
-
*/ _proto.onUpdate = function onUpdate(dt) {
|
|
10068
|
-
var // this.timeline?.getRenderData(time, true);
|
|
10069
|
-
// TODO: 需要使用lifetime
|
|
10070
|
-
_this_content;
|
|
10071
|
-
(_this_content = this.content) == null ? void 0 : _this_content.tick(dt);
|
|
10072
|
-
};
|
|
10073
|
-
/**
|
|
10074
|
-
* 组件销毁,内部对象销毁
|
|
10075
|
-
*/ _proto.onDestroy = function onDestroy() {
|
|
10076
|
-
var _this_content;
|
|
10077
|
-
(_this_content = this.content) == null ? void 0 : _this_content.dispose();
|
|
10078
|
-
};
|
|
10079
|
-
/**
|
|
10080
|
-
* 创建内部场景树元素
|
|
10081
|
-
*/ _proto.createContent = function createContent() {
|
|
10082
|
-
if (this.options) {
|
|
10083
|
-
var treeOptions = this.options.options.tree;
|
|
10084
|
-
this.content = new ModelTreeItem(treeOptions, this.item);
|
|
10085
|
-
}
|
|
10086
|
-
};
|
|
10087
|
-
/**
|
|
10088
|
-
* 获取元素的变换
|
|
10089
|
-
* @param itemId - 元素索引
|
|
10090
|
-
* @returns
|
|
10091
|
-
*/ _proto.getNodeTransform = function getNodeTransform(itemId) {
|
|
10092
|
-
if (this.content === undefined) {
|
|
10093
|
-
return this.transform;
|
|
10094
|
-
}
|
|
10095
|
-
var idWithSubfix = this.item.id + "^";
|
|
10096
|
-
if (itemId.indexOf(idWithSubfix) === 0) {
|
|
10097
|
-
var nodeId = itemId.substring(idWithSubfix.length);
|
|
10098
|
-
return this.content.getNodeTransform(nodeId);
|
|
10099
|
-
} else {
|
|
10100
|
-
return this.transform;
|
|
10101
|
-
}
|
|
10102
9627
|
};
|
|
10103
9628
|
return ModelTreeComponent;
|
|
10104
9629
|
}(Behaviour);
|
|
@@ -10106,24 +9631,6 @@ ModelTreeComponent = __decorate([
|
|
|
10106
9631
|
effectsClass(spec.DataType.TreeComponent)
|
|
10107
9632
|
], ModelTreeComponent);
|
|
10108
9633
|
|
|
10109
|
-
/**
|
|
10110
|
-
* 场景树插件类,支持 3D 相关的节点动画和骨骼动画等
|
|
10111
|
-
*/ var ModelTreePlugin = /*#__PURE__*/ function(AbstractPlugin) {
|
|
10112
|
-
_inherits(ModelTreePlugin, AbstractPlugin);
|
|
10113
|
-
function ModelTreePlugin() {
|
|
10114
|
-
var _this;
|
|
10115
|
-
_this = AbstractPlugin.apply(this, arguments) || this;
|
|
10116
|
-
/**
|
|
10117
|
-
* 插件名称
|
|
10118
|
-
*/ _this.name = "tree";
|
|
10119
|
-
/**
|
|
10120
|
-
* 高优先级更新
|
|
10121
|
-
*/ _this.order = 2;
|
|
10122
|
-
return _this;
|
|
10123
|
-
}
|
|
10124
|
-
return ModelTreePlugin;
|
|
10125
|
-
}(AbstractPlugin);
|
|
10126
|
-
|
|
10127
9634
|
var CameraGestureType;
|
|
10128
9635
|
(function(CameraGestureType) {
|
|
10129
9636
|
CameraGestureType[CameraGestureType["none"] = 0] = "none";
|
|
@@ -10661,7 +10168,7 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
10661
10168
|
_proto.processScene = function processScene(sceneData) {
|
|
10662
10169
|
var _this = this;
|
|
10663
10170
|
return _async_to_generator(function() {
|
|
10664
|
-
var sceneJSON, _tmp, oldScene, _oldScene_bins, oldBinUrls, binFiles, _iterator, _step, bin, _, newScene;
|
|
10171
|
+
var sceneJSON, _tmp, oldScene, _oldScene_bins, oldBinUrls, binFiles, v, _iterator, _step, bin, _, newScene;
|
|
10665
10172
|
return __generator(this, function(_state) {
|
|
10666
10173
|
switch(_state.label){
|
|
10667
10174
|
case 0:
|
|
@@ -10698,6 +10205,14 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
10698
10205
|
oldScene = getStandardJSON(sceneJSON);
|
|
10699
10206
|
oldBinUrls = (_oldScene_bins = oldScene.bins) != null ? _oldScene_bins : [];
|
|
10700
10207
|
binFiles = [];
|
|
10208
|
+
//@ts-expect-error
|
|
10209
|
+
v = sceneJSON.version.split(".");
|
|
10210
|
+
if (Number(v[0]) >= 3) {
|
|
10211
|
+
return [
|
|
10212
|
+
2,
|
|
10213
|
+
oldScene
|
|
10214
|
+
];
|
|
10215
|
+
}
|
|
10701
10216
|
if (!oldScene.bins) return [
|
|
10702
10217
|
3,
|
|
10703
10218
|
7
|
|
@@ -10897,7 +10412,6 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
10897
10412
|
this.createItemsFromTreeComponent(comp, newScene, oldScene);
|
|
10898
10413
|
treeComp.options.tree.animation = undefined;
|
|
10899
10414
|
treeComp.options.tree.animations = undefined;
|
|
10900
|
-
newComponents.push(comp);
|
|
10901
10415
|
} else if (comp.dataType !== spec.DataType.MeshComponent) {
|
|
10902
10416
|
newComponents.push(comp);
|
|
10903
10417
|
}
|
|
@@ -11335,6 +10849,7 @@ var JSONConverter = /*#__PURE__*/ function() {
|
|
|
11335
10849
|
});
|
|
11336
10850
|
});
|
|
11337
10851
|
}
|
|
10852
|
+
treeItem.components = [];
|
|
11338
10853
|
treeItem.components.push({
|
|
11339
10854
|
id: animationComponent.id
|
|
11340
10855
|
});
|
|
@@ -12806,43 +12321,6 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12806
12321
|
});
|
|
12807
12322
|
return sceneAABB;
|
|
12808
12323
|
};
|
|
12809
|
-
/**
|
|
12810
|
-
* 按照传入的动画播放参数,计算需要播放的动画索引
|
|
12811
|
-
*
|
|
12812
|
-
* @param treeOptions 节点树属性,需要初始化animations列表。
|
|
12813
|
-
* @returns 返回计算的动画索引,-1表示没有动画需要播放,-88888888表示播放所有动画。
|
|
12814
|
-
*/ _proto.getPlayAnimationIndex = function getPlayAnimationIndex(treeOptions) {
|
|
12815
|
-
var animations = treeOptions.animations;
|
|
12816
|
-
if (animations === undefined || animations.length <= 0) {
|
|
12817
|
-
// 硬编码,内部指定的不播放动画的索引值
|
|
12818
|
-
return -1;
|
|
12819
|
-
}
|
|
12820
|
-
if (this.isPlayAllAnimation()) {
|
|
12821
|
-
// 硬编码,内部指定的播放全部动画的索引值
|
|
12822
|
-
return -88888888;
|
|
12823
|
-
}
|
|
12824
|
-
var animationInfo = this.sceneOptions.effects.playAnimation;
|
|
12825
|
-
if (animationInfo === undefined) {
|
|
12826
|
-
return -1;
|
|
12827
|
-
}
|
|
12828
|
-
if (typeof animationInfo === "number") {
|
|
12829
|
-
if (animationInfo >= 0 && animationInfo < animations.length) {
|
|
12830
|
-
return animationInfo;
|
|
12831
|
-
} else {
|
|
12832
|
-
return -1;
|
|
12833
|
-
}
|
|
12834
|
-
} else {
|
|
12835
|
-
// typeof animationInfo === 'string'
|
|
12836
|
-
var animationIndex = -1;
|
|
12837
|
-
// 通过动画名字查找动画索引
|
|
12838
|
-
animations.forEach(function(anim, index) {
|
|
12839
|
-
if (anim.name === animationInfo) {
|
|
12840
|
-
animationIndex = index;
|
|
12841
|
-
}
|
|
12842
|
-
});
|
|
12843
|
-
return animationIndex;
|
|
12844
|
-
}
|
|
12845
|
-
};
|
|
12846
12324
|
_proto.isPlayAnimation = function isPlayAnimation() {
|
|
12847
12325
|
return this.sceneOptions.effects.playAnimation !== undefined;
|
|
12848
12326
|
};
|
|
@@ -12984,64 +12462,6 @@ var LoaderImpl = /*#__PURE__*/ function() {
|
|
|
12984
12462
|
}
|
|
12985
12463
|
});
|
|
12986
12464
|
};
|
|
12987
|
-
_proto.createTreeOptions = function createTreeOptions(scene) {
|
|
12988
|
-
var nodeList = scene.nodes.map(function(node, nodeIndex) {
|
|
12989
|
-
var children = node.children.map(function(child) {
|
|
12990
|
-
if (child.nodeIndex === undefined) {
|
|
12991
|
-
throw new Error("Undefined nodeIndex for child " + child);
|
|
12992
|
-
}
|
|
12993
|
-
return child.nodeIndex;
|
|
12994
|
-
});
|
|
12995
|
-
var pos;
|
|
12996
|
-
var quat;
|
|
12997
|
-
var scale;
|
|
12998
|
-
if (node.matrix !== undefined) {
|
|
12999
|
-
if (node.matrix.length !== 16) {
|
|
13000
|
-
throw new Error("Invalid matrix length " + node.matrix.length + " for node " + node);
|
|
13001
|
-
}
|
|
13002
|
-
var mat = Matrix4.fromArray(node.matrix);
|
|
13003
|
-
var transform = mat.getTransform();
|
|
13004
|
-
pos = transform.translation.toArray();
|
|
13005
|
-
quat = transform.rotation.toArray();
|
|
13006
|
-
scale = transform.scale.toArray();
|
|
13007
|
-
} else {
|
|
13008
|
-
if (node.translation !== undefined) {
|
|
13009
|
-
pos = node.translation;
|
|
13010
|
-
}
|
|
13011
|
-
if (node.rotation !== undefined) {
|
|
13012
|
-
quat = node.rotation;
|
|
13013
|
-
}
|
|
13014
|
-
if (node.scale !== undefined) {
|
|
13015
|
-
scale = node.scale;
|
|
13016
|
-
}
|
|
13017
|
-
}
|
|
13018
|
-
node.nodeIndex = nodeIndex;
|
|
13019
|
-
var treeNode = {
|
|
13020
|
-
name: node.name,
|
|
13021
|
-
transform: {
|
|
13022
|
-
position: pos,
|
|
13023
|
-
quat: quat,
|
|
13024
|
-
scale: scale
|
|
13025
|
-
},
|
|
13026
|
-
children: children,
|
|
13027
|
-
id: "" + node.nodeIndex
|
|
13028
|
-
};
|
|
13029
|
-
return treeNode;
|
|
13030
|
-
});
|
|
13031
|
-
var rootNodes = scene.rootNodes.map(function(root) {
|
|
13032
|
-
if (root.nodeIndex === undefined) {
|
|
13033
|
-
throw new Error("Undefined nodeIndex for root " + root);
|
|
13034
|
-
}
|
|
13035
|
-
return root.nodeIndex;
|
|
13036
|
-
});
|
|
13037
|
-
var treeOptions = {
|
|
13038
|
-
nodes: nodeList,
|
|
13039
|
-
children: rootNodes,
|
|
13040
|
-
animation: -1,
|
|
13041
|
-
animations: []
|
|
13042
|
-
};
|
|
13043
|
-
return treeOptions;
|
|
13044
|
-
};
|
|
13045
12465
|
_proto.createAnimations = function createAnimations(animations) {
|
|
13046
12466
|
return animations.map(function(anim) {
|
|
13047
12467
|
var tracks = anim.channels.map(function(channel) {
|
|
@@ -13791,13 +13211,12 @@ var GLTFHelper = /*#__PURE__*/ function() {
|
|
|
13791
13211
|
return GLTFHelper;
|
|
13792
13212
|
}();
|
|
13793
13213
|
|
|
13794
|
-
registerPlugin("tree", ModelTreePlugin, VFXItem, true);
|
|
13795
13214
|
registerPlugin("model", ModelPlugin, VFXItem);
|
|
13796
|
-
var version = "2.1.0-alpha.
|
|
13215
|
+
var version = "2.1.0-alpha.8";
|
|
13797
13216
|
logger.info("Plugin model version: " + version + ".");
|
|
13798
13217
|
if (version !== EFFECTS.version) {
|
|
13799
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!");
|
|
13800
13219
|
}
|
|
13801
13220
|
|
|
13802
|
-
export { AnimationComponent, Box3, BoxMesh, CameraGestureHandlerImp, CameraGestureType, CheckerHelper, Color, CompositionCache, CompositionHitTest, DEG2RAD, Euler, EulerOrder, FBOOptions, Float16ArrayWrapper, GeometryBoxProxy, HitTestingProxy, HookOGLFunc, InterpolationSampler, JSONConverter, LoaderHelper, LoaderImpl, Matrix3, Matrix4, MeshHelper, ModelCameraComponent, ModelLightComponent, ModelMeshComponent, ModelPlugin, ModelPluginComponent, ModelSkyboxComponent, ModelTreeComponent,
|
|
13221
|
+
export { AnimationComponent, Box3, BoxMesh, CameraGestureHandlerImp, CameraGestureType, CheckerHelper, Color, CompositionCache, CompositionHitTest, DEG2RAD, Euler, EulerOrder, FBOOptions, Float16ArrayWrapper, GeometryBoxProxy, HitTestingProxy, HookOGLFunc, InterpolationSampler, JSONConverter, LoaderHelper, LoaderImpl, Matrix3, Matrix4, MeshHelper, ModelCameraComponent, ModelLightComponent, ModelMeshComponent, ModelPlugin, ModelPluginComponent, ModelSkyboxComponent, ModelTreeComponent, PAnimInterpType, PAnimPathType, PAnimTexture, PBRShaderGUID, PBlendMode, PCamera, PCameraManager, PCoordinate, PEntity, PFaceSideMode, PGeometry, PGlobalState, PLight, PLightManager, PLightType, PMaterialBase, PMaterialPBR, PMaterialSkyboxFilter, PMaterialType, PMaterialUnlit, PMesh, PMorph, PObject, PObjectType, PSceneManager, PShaderManager, PShadowType, PSkin, PSkybox, PSkyboxCreator, PSkyboxType, PSubMesh, PTextureType, PTransform, PluginHelper, Quaternion, Ray, RayBoxTesting, RayIntersectsBoxWithRotation, RayTriangleTesting, Sphere, TextureDataMode, ToggleItemBounding, TwoStatesSet, UnlitShaderGUID, VFX_ITEM_TYPE_3D, Vector2, Vector3, Vector4, VertexAttribBuffer, WebGLHelper, WebHelper, createAnimationSampler, createPluginMaterial, fetchPBRShaderCode, fetchUnlitShaderCode, getDefaultEffectsGLTFLoader, getDefaultPBRMaterialData, getDefaultUnlitMaterialData, getDiffuseOnlyShaderCode, getGaussianBlurShaderCodeV1, getGaussianBlurShaderCodeV2, getGeometryDataFromOptions, getGeometryDataFromPropsList, getKawaseBlurShaderCode, getNormalVisShaderCode, getPBRPassShaderCode, getPBRShaderProperties, getPMeshList, getQuadFilterShaderCode, getRendererGPUInfo, getSceneManager, getShadowPassShaderCode, getSimpleFilterShaderCode, getSkyBoxShaderCode, getTransparecyBaseShader, getTransparecyFilterShader, getUnlitShaderProperties, setDefaultEffectsGLTFLoader, version };
|
|
13803
13222
|
//# sourceMappingURL=douyin.mjs.map
|