2012-10-16 116 views
3

我試圖使水平放置的地板,但它的位置是直立的。我的代碼有什麼問題?也許相機旋轉關閉?我正在使用three.js r52。Three.js - 錯誤的軸或相機旋轉

camera = new THREE.PerspectiveCamera                        
     (45, window.innerWidth/window.innerHeight, 1, 10000);                  
    camera.position.x = -500;                          
    camera.position.z = 0;                           

    scene = new THREE.Scene(); 

    var floorGeometry = new THREE.PlaneGeometry(1000, 1000, 1, 1);                 
    var floorMaterial = new THREE.MeshBasicMaterial({color:0x448844});                
    var floor = new THREE.Mesh(floorGeometry, floorMaterial);                  

    scene.add(floor); 

    controls = new THREE.FirstPersonControls(camera);                    
    controls.movementSpeed = 1000;                         
    controls.lookSpeed = 0.0;                          
    controls.lookVertical = true; 

upright PlaneGeometry

回答

4

你的代碼是好的,但必須添加這旋轉90度。看看這個:http://cssdeck.com/labs/threejsrotation/0(line 18:floor.rotation.x = -Math.PI/2;

旋轉只是一個THREE.Vector3,就像位置。

+0

奇怪..我做到了,我仍然看到相同的結果。 – nnyby

+0

@nnyby啊,對不起,我給你錯了軸。答案已經通過一個工作示例進行了更新。我希望這有助於! :-) – oal