Utilizing THREE.ExtrudedGeometry in two distinct manners led me to anticipate the same outcome.
One method involved using the depth parameter to define the extrusion options, while the other utilized an extrude path, which was a line from Vector3(0, 0, 0)
to Vector3(0, 0, depth)
The peculiar observation was that the resulting geometry appeared unexpectedly rotated around the Z-axis. Why is this happening? Is it considered normal behavior or am I making a mistake somewhere?
You can find a demonstration on fiddle by clicking here, along with the following code:
Variables shared across both methods:
// Material for mesh
var material = new THREE.MeshBasicMaterial({color:0xff0000});
// Depth of extrusion
var depth = 10;
// Shape to be extruded
var shape = new THREE.Shape([
new THREE.Vector2( -20,-60 ),
new THREE.Vector2( -20, 60 ),
new THREE.Vector2( 20, 60 ),
new THREE.Vector2( 20,-60 )
]);
Using depth parameter:
var extrudeSettings1 = {
bevelEnabled: false,
steps: 1,
amount: depth
};
var geometry1 = new THREE.ExtrudeGeometry( shape, extrudeSettings1 );
var mesh1 = new THREE.Mesh( geometry1, material );
mesh1.position.set( -50, 0, 0 );
scene.add( mesh1 );
Now employing an extrude path:
var v1 = new THREE.Vector3( 0, 0, 0 );
var v2 = new THREE.Vector3( 0, 0, depth );
var path = new THREE.LineCurve3( v1, v2 )
var extrudeSettings2 = {
bevelEnabled: false,
steps: 1,
extrudePath: path
};
var geometry2 = new THREE.ExtrudeGeometry( shape, extrudeSettings2 );
var mesh2 = new THREE.Mesh( geometry2, material );
mesh2.position.set( 50, 0, 0 );
scene.add( mesh2 );
EDIT1:
Updated the position.set()
as per WestLangley's suggestion.
EDIT2:
After further consideration, although I reviewed WestLangley's response, I am still unable to comprehend it fully. The orientation of the shape should not impact its ability to return to the starting point. In my view, regardless of orientation, the shape should end up in the same position it started from.
To clarify, I have depicted two shapes on the x, y plane and displayed the extrusions to illustrate what I believe should be the correct outcome: