TubeGeometry 管道模型

—> Geometry

沿着一条3D曲线拉伸成一根弯曲的管子. 参数中的 path 是 Curve 的子类. 源于 Curve 是抽象类, 不能直接使用. 可用继承于它的非抽象子类, 比如 LineCuve, CatmullRomCurve3 , 也可自定义子类. 如果把参数中的 radialSegments 设为2, 那就不再是管状了, 而是成为了纸条状.

function TubeGeometry( path, tubularSegments, radius, radialSegments, closed ) { } var points = []; for(var i = -8; i <= 8; i++){ var x = i, y = Math.sin(i) * 2, z = Math.random(); points.push(new THREE.Vector3(x, y, z)); } var curve = new THREE.CatmullRomCurve3( points ); var geometry = new THREE.TubeGeometry(curve, 100, 0.5, 20), material = new THREE.MeshBasicMaterial({color: 0x663399, side: THREE.DoubleSide}), tube = new THREE.Mesh( geometry, material ); scene.add( tube );

Parameters

path tubularSegments radius radialSegments closed
Curve Integer (default: 64) Float (default: 1) Integer (default: 8) Boolean (default: false)
曲线 曲线分段数 管道半径 管道分段数 是否闭合

Methods 继承自 Geometry 并自动调用

fromBufferGeometry( new TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed ) )
mergeVertices( )

TubeBufferGeometry

function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed ) { } var points = []; for(var i = -8; i <= 8; i++){ var x = i, y = Math.sin(i) * 2, z = Math.random(); points.push(new THREE.Vector3(x, y, z)); } var curve = new THREE.CatmullRomCurve3( points ); var geometry = new THREE.TubeBufferGeometry(curve, 100, 0.5, 20), material = new THREE.MeshBasicMaterial({color: 0x663399, side: THREE.DoubleSide}), tube = new THREE.Mesh( geometry, material ); scene.add( tube );

Methods 继承自 BufferGeometry 并自动调用

setIndex( )
addAttribute( )

图解API

纹理Texture来渲管道模型. 点开查看