2012-06-20 23 views

回答

41

Object3D貼有一些方便的方法。

object.translateZ(10); 
+0

謝謝。以及如何移動相機? – eqiproo

+3

@eqiproo camera.translateZ(10); – mrdoob

+5

@mrdoob是否有可能使三個j的文檔更精細? –

7

這裏是一個很好的教程 http://www.aerotwist.com/tutorials/getting-started-with-three-js/

// set position of YOUR_OBJECT 
YOUR_OBJECT.position.x = 10; 
YOUR_OBJECT.position.y = 50; 
YOUR_OBJECT.position.z = 130; 

好吧,夥計們,更細緻!

var STEP = 10; 
var newCubeMatrix = cube.matrix;   
newCubeMatrix.identity(); 
//newCubeMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(cube.rotation.y)); 
newCubeMatrix.multiplySelf(THREE.Matrix4.translationMatrix(cube.position.x, cube.position.y, cube.position.z + STEP)); 
cube.updateMatrix(); 

細節這裏https://gamedev.stackexchange.com/questions/7490/translate-object-in-world-space-usings-its-local-rotation

+0

對不起,但我還是不知道該怎麼做:S – eqiproo

+0

你有一些片段可以入門嗎?你有沒有試過任何教程?你檢查了鏈接嗎?告訴我你的擔憂? –

+0

我的場景中有一個紅色的立方體,它圍繞x,y和z軸旋轉。我想使用對象的當前方向並使用指定的步進值向前移動它。 – eqiproo

-2

另一種選擇是使用Vector3的set方法/函數。

position.set(x, y, z); 
+0

某些事情要反映在.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set –

相關問題