W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
創(chuàng)建一個沿著三維曲線延伸的管道。
class CustomSinCurve extends THREE.Curve {
constructor( scale = 1 ) {
super();
this.scale = scale;
}
getPoint( t, optionalTarget = new THREE.Vector3() ) {
const tx = t * 3 - 1.5;
const ty = Math.sin( 2 * Math.PI * t );
const tz = 0;
return optionalTarget.set( tx, ty, tz ).multiplyScalar( this.scale );
}
}
const path = new CustomSinCurve( 10 );
const geometry = new THREE.TubeGeometry( path, 20, 2, 8, false );
const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
const mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
path — Curve - 一個由基類Curve繼承而來的3D路徑。 默認是二次貝塞爾曲線。
tubularSegments — Integer - 組成這一管道的分段數(shù),默認值為64。
radius — Float - 管道的半徑,默認值為1。
radialSegments — Integer - 管道橫截面的分段數(shù)目,默認值為8。
closed — Boolean 管道的兩端是否閉合,默認值為false。
共有屬性請參見其基類BufferGeometry。
一個包含著構造函數(shù)中每個參數(shù)的對象。在對象實例化之后,對該屬性的任何修改都不會改變這個幾何體。
一個Vector3切線數(shù)組。
一個Vector3法線數(shù)組。
一個Vector3次法線數(shù)組。
共有方法請參見其基類BufferGeometry。
src/geometries/TubeGeometry.js
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: