用户:
迷失冷光查看:10 回复:14 评论:10 创建时间:2021-02-26T12:44:08
今天我花了一中午的时间研究了一个模型旋转器
不喜勿喷
这个先放在代码区最上方:
class Direction{
constructor(x = 0,y = 0,z = 0){
const dx = Math.sin(x/90*Math.PI);
const dy = Math.cos(y/90*Math.PI);
const dz = Math.cos(z/90*Math.PI);
const direction = new Box3Vector3(dx,dy,dz).sub(new Box3Vector3(0,0,0));
const dist = direction.mag();
const face = new Box3Vector3(direction.x/dist,direction.y/dist,direction.z/dist);
let orientation = new Box3Quaternion(0,0,0,1).rotateY(Math.atan2(face.z,face.x));
orientation = orientation.rotateX(Math.atan2(face.z,face.y));
orientation = orientation.rotateZ(Math.atan2(face.y,face.x));
return orientation;
}
}
是不是看起来有点熟悉?
调用:
Box3Entity.meshOrientation = new Direction(90,180,45);
填三个我们最熟悉的角度(∠)
就是360°的那种
QQ: 3613545261
治愈绾兮(async function(){
angle=0;
while(true){
world.querySelectorAll(".核心").forEach((entity)=>{
entity.meshOrientation.x=Math.sin(angle*180/Math.PI);
entity.meshOrientation.y=Math.cos(angle*180/Math.PI);
entity.meshOrientation.z=Math.cos(angle*180/Math.PI);
})
angle+=0.00001;
await sleep(1);
}
})()点赞0
评论