Have object revolve around vector point

后端 未结 2 941
小鲜肉
小鲜肉 2021-01-16 23:28

I am currently looking for a way to have an object orbit the vector coordinates 0,0,0. For instance if the object is located at X300,Y50,Z200 than I would like it to revolve

2条回答
  •  抹茶落季
    2021-01-17 00:05

    Using the following code allows an object to move in a circular pattern.

            function orbitRight() {
                var x = thisObj.position.x;
                var z = thisObj.position.z;
                thisObj.position.x = x * Math.cos(.02) - z * Math.sin(.02);
                thisObj.position.z = z * Math.cos(.02) + x * Math.sin(.02);
            }
    

提交回复
热议问题