2015-11-04 31 views
9

我想在管幾何的一段(背面)中貼上貼花。three.js - TubeGeometry +管段上的DecalGeometry

我的方法是使用TubeGeometry作爲貼花幾何。

這是我有: enter image description here

而這正是我想要的: enter image description here (壞圖)

示例代碼:

//code 
var tube = new THREE.TubeGeometry(pipelineSpline, 200, 20, 20, closed2); 

tubeMesh = THREE.SceneUtils.createMultiMaterialObject(
     geometry, [ 
      material,  // a phong material 
      materialInside // a material for the inside    
     ]); 

scene.add(tubeMesh); 

var decalGeometry = new THREE.DecalGeometry(
     tubeMesh.children[0], 
     new THREE.Vector3(0,0,0),  //position 
     new THREE.Vector3(0,1,0),  //direction 
     new THREE.Vector3(10,10,10), //dimensions 
     new THREE.Vector3(0,0,0)  //check 
    ); 

然而,這似乎沿着所有背面幾何路徑應用管的貼花。我只希望它在關鍵位置的管子後部的一部分上。

如何使用THREE.DecalGeometry在TubeGeometry中製作局部貼花?可能嗎?

回答

3

您需要在三個傳遞給它的着色器代碼和各種uniform(例如,新的紋理)和parameter(如UV)值用於此一ShaderMaterial,明確定位和透明度規則。 JS。

+0

謝謝你的回答。並不能完成使用THREE.DecalGeometry https://github.com/spite/THREE.DecalGeometry?最好的 –

+2

這不在標準庫中:)像這樣的一個地理位置很重的方法適用於裝飾,但如果將貼花動態放置(比如遊戲中的爆炸),將會很困難。只有你知道你需要的環境。 – bjorke

+0

謝謝@bjorke他們將被放置在現場的開始...像10管道,然後將是靜態的 –