gpt4 book ai didi

javascript - Three.js toShapes() 移至 v81 中的新类,如何访问它

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:13:15 30 4
gpt4 key购买 nike

我已将 Three.js 从 v73 更新到 v81。我收到此错误:

Uncaught TypeError: path.toShapes is not a function

查看 release documents ,我发现:

路径的改变:

  • 摆脱了 .actions (yay)
  • getPoints() 移动到 CurvePath
  • toShapes() 移至新类 ShapePath

我的代码段是这样的:

var shapes = [];
for (var i = 0; i < paths.length; ++i) {
// Turn each SVG path into a three.js shape
var path = d3.transformSVGPath( paths[i] );
// We may have had the winding order backward.
**var newShapes = path.toShapes(effectController.reverseWO);**
// Add these three.js shapes to an array.
shapes = shapes.concat(newShapes);
}

我在任何地方都找不到 THREE.Path 所以我导入了 Path.js万一它会有所帮助,但无济于事。我是 Three.js 的新手,所以不知道这是否是一个菜鸟问题,但我已经研究了一天,无法弄清楚。

最佳答案

ShapePath类包含您要查找的方法:.toShapes() . example文档也链接到 utilizes this method :

path = $d3g.transformSVGPath( thePaths[i] );
...
simpleShapes = path.toShapes(true);

问题是 d3-threeD包含 .transformSVGPath() 方法的源代码仍然定义了 var path = new THREE.Shape();

通知在example , 有一个 snippet of code从 d3-threeD 获取/派生,但已更新为使用 THREE.ShapePath():

...
function transformSVGPath(pathStr) {
var path = new THREE.ShapePath();
...

我建议您遵循示例源代码并包含更新的 .transformSVGPath() 方法,该方法使用 THREE.ShapePath()

关于javascript - Three.js toShapes() 移至 v81 中的新类,如何访问它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40064766/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com