翻译半径/直径而不是x,y,z的相机?

Loi*_*iou 2 javascript math radius translate three.js

所以我有如下所示的这个例子,我想知道是否可以通过改变半径和直径而不是使用x,y,z位置(矢量)来翻译相机.现在我使用立方体但我想基本上添加第二个相机.

在此输入图像描述

既然我知道0,0,0(原点)在哪里,有没有办法通过设置直径半径或任何需要来翻译立方体并将其锁定在原点上?

我用什么来移动立方体(Three.js)

var posX,posY,posZ;
var scene, camera, render;
var cubeMesh,cube_Geometry, cube_Material;

class myWorld{
    /* ... Setup World ... */
    //excecute cube();
    /* ... Set/Get positions (xyz) ... */

    cube(){
        cube_Geometry = new THREE.BoxGeometry(20, 20, 20);
        cube_Material = new THREE.MeshNormalMaterial();
        cube_Mesh = new THREE.Mesh(cube_Geometry, cube_Material);
        cube_Mesh.position.set(0, 100, 100);
        scene.add(cube_Mesh);
    }

    animate(){ //loop function
        //THREE.Mesh.position.set (Three.js)
        cube_Mesh.position.set(posX, posY, posZ);
    }
}
Run Code Online (Sandbox Code Playgroud)

我想要实现的目标: 在此输入图像描述

Ork*_*nov 6

使用SphericalsetFromSpherical:

var r = 10;
var theta = 310 * (Math.PI / 180); /// 310 degree to radians

var sphericalPos = new THREE.Spherical(r, 0, theta);
cube_Mesh.position.setFromSpherical(sphericalPos);
// or just do cube_Mesh.position.setFromSphericalCoords(radius, phi, theta)
Run Code Online (Sandbox Code Playgroud)

球形(半径:浮点数,phi:浮点数,θ:浮点数)

  • radius - 从点到原点的半径或欧几里德距离(直线距离).默认值为1.0.
  • phi - y(向上)轴的极角.默认值为0.
  • theta - 围绕y(向上)轴的赤道角.默认值为0.

极点(phi)位于正y轴和负y轴.赤道(theta)从正z开始.