three.js VertexNormalsHelper

2023-02-16 17:50 更新

渲染箭頭輔助對象 arrows 來模擬頂點(diǎn)的法線. 需要定義了法線緩存屬性 custom attribute 或 使用了 computeVertexNormals 方法計(jì)算了頂點(diǎn)法線.

代碼示例

const geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 );
const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
const box = new THREE.Mesh( geometry, material );

const helper = new VertexNormalsHelper( box, 2, 0x00ff00, 1 );

scene.add( box );
scene.add( helper );

例子

WebGL / helpers

構(gòu)造函數(shù)

VertexNormalsHelper( object : Object3D, size : Number, color : Hex, linewidth : Number )

object -- 要渲染頂點(diǎn)法線輔助的對象.

size -- (可選的) 箭頭的長度. 默認(rèn)為 1.

color -- 16進(jìn)制顏色值. 默認(rèn)為 0xff0000.

linewidth -- (可選的) 箭頭線段的寬度. 默認(rèn)為 1.

屬性

請到基類 LineSegments 頁面查看公共屬性.

.matrixAutoUpdate : Object

請查看 Object3D.matrixAutoUpdate. 這里設(shè)置為 false 表示輔助對象 使用對象的世界矩陣 matrixWorld.

.object : Object3D

被渲染頂點(diǎn)法線輔助的對象.

.size : Number

箭頭的長度. 默認(rèn)為 1.

方法

請到基類 LineSegments 頁面查看公共方法.

.update () : undefined

基于對象的運(yùn)動(dòng)更新頂點(diǎn)法線輔助對象.

源碼

examples/jsm/helpers/VertexNormalsHelper.js


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號