0

I want to extrude a shape along an extrudePath using THREE.ExtrudeBufferGeometry().

Basically this works fine, but the initial shape orientation is arbitrary, due to FrenetFrames as answered in this question.
The extrudePath is lying on one plane, so there will never be a problem regarding closing the Extrusion due to "wrong" orientation.

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 );

Is there a way to set the initial shape orientation manually?


EDIT 1

I would like to avoid editing the three.js-File. I found something here. Is it (still) possible to give normal-vectors or frames as options to the ExtrudeBufferGeometry() ?

I imagine something like:

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 );

This does not work so far. I get an Error in three.js:2582:4 :

TypeError: v is undefined

copy
ExtrudeBufferGeometry.prototype.addShape
ExtrudeBufferGeometry.prototype.addShapeList
ExtrudeBufferGeometry

benjamin
  • 789
  • 1
  • 5
  • 10
  • You have to hack the library. In `curve.js`, search for the code block `// select an initial normal` and hardwire the computed normal to whatever you want: `normal.set( x, y, z ).normalize();` – WestLangley Mar 26 '19 at 12:09
  • @WestLangley Is it possible to give normal vectors as an option to ExtrudeBufferGeometry() ? (See EDIT 1 above) – benjamin Apr 04 '19 at 07:59
  • The best answer I can give you now is for you to redefine `computeFrenetFrames()` in your application: `THREE.Curve.prototype.computeFrenetFrames = function( segments, closed ) { ... };` – WestLangley Apr 04 '19 at 18:21

0 Answers0