0

我正在尝试将一系列平面排列成一个圆圈,“面向”中心,但是在经过 180 度后我得到了一些奇怪的结果。我的对象围绕圆圈正确分布,但旋转已关闭。我附上了截图,我的代码如下:我的方程式有什么问题?

var circleRadius = 12;
var diameter = circleRadius*2;
var centerX = -5;
var centerZ = -2.5;

var mpi = Math.PI/180;
var startRadians = startAngle + mpi;
var totalSpheres = 8;
var incrementAngle = 360/totalSpheres;
var incrementRadians = incrementAngle * mpi;

for ( var i = 0; i < totalSpheres; i ++ ) {

    var xp = centerX + Math.sin(startRadians) * circleRadius;
    var zp = centerZ + Math.cos(startRadians) * circleRadius;

    var camObj = new THREE.Mesh( new THREE.PlaneGeometry( 1*camSize, .75*camSize ), material );

    camObj.position.x = xp;
    camObj.position.z = zp;
    camObj.rotation.y = i*incrementAngle; //MH - do this without degrees
    console.log(camObj.rotation.y);
    startRadians += incrementRadians;

    scene.add( camObj );

}

对象对齐

4

1 回答 1

2

我可能是错的。从未使用过该库,但在 github 中查看它似乎旋转应该是弧度而不是度数。

var circleRadius = 12;
var diameter = circleRadius*2;
var centerX = -5;
var centerZ = -2.5;

var mpi = Math.PI/180;
var startRadians = startAngle + mpi;
var totalSpheres = 8;
var incrementAngle = 360/totalSpheres;
var incrementRadians = incrementAngle * mpi;

for ( var i = 0; i < totalSpheres; i ++ ) {

    var xp = centerX + Math.sin(startRadians) * circleRadius;
    var zp = centerZ + Math.cos(startRadians) * circleRadius;

    var camObj = new THREE.Mesh( new THREE.PlaneGeometry( 1*camSize, .75*camSize ), material );

    camObj.position.x = xp;
    camObj.position.z = zp;
    camObj.rotation.y = i*incrementAngle * (Math.PI/180.0); //MH - do this without degrees
    console.log(camObj.rotation.y);
    startRadians += incrementRadians;

    scene.add( camObj );

}
于 2012-05-03T17:32:08.580 回答