【问题标题】:Three.js - wrong axes or camera rotationThree.js - 错误的轴或相机旋转
【发布时间】:2012-10-16 15:11:37
【问题描述】:

我正在尝试使地板水平放置,但它是垂直放置的。我的代码有什么问题?也许相机旋转关闭?我正在使用three.js r52。

    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; 

【问题讨论】:

    标签: javascript three.js


    【解决方案1】:

    您的代码很好,但您必须添加它才能将其旋转 90 度。看看这个:http://cssdeck.com/labs/threejsrotation/0(第 18 行:floor.rotation.x = -Math.PI / 2;

    Rotation 只是一个THREE.Vector3,类似位置。

    【讨论】:

    • 奇怪.. 我这样做了,但我仍然看到相同的结果。
    • @nnyby 啊,对不起,我给了你错误的轴。答案已更新为一个工作示例。我希望这会有所帮助! :-)
    猜你喜欢
    • 2012-07-23
    • 2015-08-07
    • 2013-03-19
    • 2021-08-23
    • 1970-01-01
    • 2017-04-22
    • 2017-10-01
    • 1970-01-01
    • 2013-07-15
    相关资源
    最近更新 更多