ExtrudeGeometry 拉伸几何体

—> Geometry

把一个2D平面图形进行拉伸, 成为一个3D的立体图形. 拉伸的路径默认是 z 轴.

function ExtrudeGeometry( shapes, options ) { } var shape = new THREE.Shape(); shape.quadraticCurveTo(3, 5, 9, 1); shape.quadraticCurveTo(11, -1, 12, 3); shape.quadraticCurveTo(13, 0, 12, -3); shape.quadraticCurveTo(11, 1, 9, -1); shape.quadraticCurveTo(3, -5, 0, 0); var eye = new THREE.Path(); eye.arc(2, 0, 0.5); shape.holes.push(eye); var extrudeSettings = { steps: 1, depth: 2, bevelEnabled: true, bevelThickness: 0.5, bevelSize: 0.5, bevelSegments: 4 }; var geometry = new THREE.ExtrudeGeometry(shape, extrudeSettings), material = new THREE.MeshBasicMaterial({ color: #663399, side: THREE.DoubleSide }), extrude = new THREE.Mesh( geometry, material ); scene.add( extrude );

Parameters

shapes options
Array Object
Shape数组 拉伸参数
curveSegments Integer (default: 12) 二维平面的曲线分段数
depth Float (default: 100) 拉伸多高
steps Integer (default: 1) 拉伸分段数
bevelEnabled Boolean (default: true) 是否有斜角
bevelThickness Float (default: 6) 斜角厚度
bevelSize Float (default: 2) 斜角宽度, 图形边缘向外延伸到斜角的距离
bevelSegments Float (default: 3) 斜角分段数
extrudePath CurvePath 拉伸路径, 即沿着一条3D SplineCurve 进行拉伸,
如果没有指明, 默认 z 轴
UVGenerator Object 提供 UV 函数

Methods 继承自 Geometry 并自动调用

fromBufferGeometry( new ExtrudeBufferGeometry( shapes, options ) )
mergeVertices( )

ExtrudeBufferGeometry

function ExtrudeBufferGeometry( shapes, options ) { } var shape = new THREE.Shape(); shape.quadraticCurveTo(3, 5, 9, 1); shape.quadraticCurveTo(11, -1, 12, 3); shape.quadraticCurveTo(13, 0, 12, -3); shape.quadraticCurveTo(11, 1, 9, -1); shape.quadraticCurveTo(3, -5, 0, 0); var eye = new THREE.Path(); eye.arc(2, 0, 0.5); shape.holes.push(eye); var extrudeSettings = { steps: 1, depth: 2, bevelEnabled: true, bevelThickness: 0.5, bevelSize: 0.5, bevelSegments: 4 }; var geometry = new THREE.ExtrudeBufferGeometry(shape, extrudeSettings), material = new THREE.MeshBasicMaterial({ color: #663399, side: THREE.DoubleSide }), extrude = new THREE.Mesh( geometry, material ); scene.add( extrude );

图解API

纹理Texture来渲染拉伸几何体模型. 点开查看