我已经从v73更新了Three.js到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的新手所以不知道这是否是一个noob问题,但我现在已经有一天了,并且无法弄明白.
最佳答案
ShapePath类包含您要查找的方法:
.toShapes().
example文档链接到
utilizes this method:
path = $d3g.transformSVGPath( thePaths[i] );
...
simpleShapes = path.toShapes(true);
问题是包含.transformSVGPath()方法的d3-threeD源代码仍然定义了var path = new THREE.Shape();.
请注意,在example中,存在从d3-threeD获取/派生的snippet of code,但更新为使用THREE.ShapePath():
...
function transformSVGPath(pathStr) {
var path = new THREE.ShapePath();
...
我建议您按照示例源并包含更新的.transformSVGPath()方法,该方法使用THREE.ShapePath().