首页 > 解决方案 > 有没有办法沿 Three.js 中的路径设置 ExtrudeBufferGeometrie 的初始形状方向?

问题描述

我想shape沿着extrudePathusing挤出 a THREE.ExtrudeBufferGeometry()

基本上这工作正常,但初始形状方向是任意的,因为 FrenetFrames 回答了这个问题
extrudePath 位于一个平面上,因此由于“错误”方向而关闭 Extrusion 永远不会出现问题。

var myExtrudePath = new THREE.CatmullRomCurve3( <some THREE.Vector3() vectors> );

var shape = new THREE.Shape();
shape.lineTo( ... );
...

var extrudeSettings = { extrudePath: myExtrudePath };

var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );

有没有办法手动设置初始形状方向?


编辑 1

我想避免编辑 three.js 文件。我在这里找到了一些东西。是否(仍然)可以将法线向量或帧作为 ExtrudeBufferGeometry() 的选项?

我想像:

var phi = Math.PI / 2;
var normal = new THREE.Vector3( Math.sin(phi), Math.cos(phi), 0);
var binormal = new THREE.Vector3( Math.cos(phi), Math.sin(phi), 0);
var frames = { normals: [normal, normal], binormals: [binormal, binormal] };

var extrudeSettings = {
    steps: 100,
    extrudePath: path,
    frames: frames
}

var geometry = new THREE.ExtrudeBufferGeometry( shape, extrudeSettings );

到目前为止,这行不通。我在 three.js:2582:4 中遇到错误:

类型错误:v 未定义

复制
ExtrudeBufferGeometry.prototype.addShape
ExtrudeBufferGeometry.prototype.addShapeList
ExtrudeBufferGeometry

标签: javascriptthree.jsorientation

解决方案


推荐阅读