2017-08-10 141 views
1

我試圖用material.clippingPlanes剪切planeBuffer的左半部分。 當物體處於旋轉中心(0,0,0)時,剪切就起作用。基於局部座標軸的局部剪切

object.material.clippingPlanes = 
[object.getWorldDirection().cross(object.up).normalize(), object.position.z)]; 

但是,當該對象是在具有非零旋轉非零位置和切割不與對象的方向改變該代碼失敗。

回答

2

Material.clippingPlanes:在世界空間指定爲THREE.Plane對象

用戶定義的裁剪平面。

由於飛機是在世界空間,他們不會將您的對象的局部空間內定向。您需要將對象的世界變換矩陣應用於平面,以便將它們與對象對齊。

myMesh.material.clippingPlanes[0].applyMatrix4(myMesh.matrixWorld); 

請注意,如果你的網是走動,你需要存儲原始裁剪平面從每個轉化應用的新matrixWorld的。

// somehwere else in the code: 
var clipPlane1 = new THREE.Plane(); // however you configure it is up to you 

// later, probably in your render method: 
myMesh.material.clippingPlanes[0].copy(clipPlane1); 
myMesh.material.clippingPlanes[0].applyMatrix4(myMesh.matrixWorld); 
+0

謝謝。 我也必須移動飛機使用 object.material.clippingPlanes [0] .constant - = object.material.clippingPlanes [0] .distanceToPoint(object.position); –

+0

@AmriteshAnand很好!感謝您分享這些額外信息。 :) – TheJim01