用户:
迷失冷光查看:608 回复: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
该账号已被封禁提问:那是不是让模型持续旋转是while(true)调用此参数
点赞0
评论
不是
可以设一个变量y
然后旋转是y++
调用就是Box3Entity.meshOrientation = new Direction(0,y,0);
迷失冷光之所以我用class是因为我以后会加一些方法……
点赞0
评论
帮我下
链接发一下
https://box3.codemao.cn/e/e68b35be2d771f58fd2c
我需要射线和漏水代码
琪贵,你怎么帮着帮着……就走了呢?况且你的发射子弹代码都没用了
治愈绾兮(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
评论