猫史档案馆


终于完成啦,模型旋转器~

用户:迷失冷光迷失冷光查看: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


回复

上一页1 页 / 共 1下一页
迷失冷光迷失冷光

沙发

点赞0


评论


没尾巴的鲸鱼没尾巴的鲸鱼

板凳

点赞0


评论


AlcalaAlcala

地板

点赞0


评论


该账号已被封禁该账号已被封禁

天花板

点赞0


评论


该账号已被封禁该账号已被封禁

提问:那是不是让模型持续旋转是while(true)调用此参数

点赞0


评论


倒吊人倒吊人

好帖号

点赞0


评论


Architect_海绵Architect_海绵

()

点赞0


评论


迷失冷光迷失冷光

还有这个工具我就不用发效果图了

点赞0


评论


月下樱花雨_中考退月下樱花雨_中考退

好帖要顶

点赞0


评论


冥界阴阳冥界阴阳

顶顶

 

点赞0


评论


迷失冷光迷失冷光

之所以我用class是因为我以后会加一些方法……

点赞0


评论


yuansyuans

请注意不要叫我名字()()()

                                                               今天我花了一中午的时间研究了一个模型旋转器

                                                                                              不喜勿喷

                                                                                   这个先放在代码区最上方:

 

点赞0


评论


治愈绾兮治愈绾兮

(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


评论


神炎暗月神炎暗月

有没有什么方法,利用这个代码,填写玩家的角度,让实体与玩家角度一样

点赞1


评论