猫史档案馆


【教程】如何做一个带粒子效果的火车

用户:烤乳鸽RoastedSquab烤乳鸽RoastedSquab查看:9 回复:10 评论:9 创建时间:2020-06-09T14:45:49


—————————————————————————————————————————————————————————————————————————————————————————————————

记得礼貌拿代码,别忘记给我作品点赞emotion_doge

第一步一定是做一个火车模型并加标签了~

然后,我们需要一个触发的条件,这里就已开始为触发条件

(async function(){ 然后必须要重复执行,不然动不了太长时间   while (true) { 然后*****(保密emotion_doge 别打了!我告诉你们! 让火车向前需要设置加速度   for(let i=0;i<15;i++){//火车向前加速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z+=0.1;                 }) 然后保持47秒   await sleep(20)         } await sleep(4500)//行驶中 再减速   for(let i=0;i<15;i++){//火车向前减速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z-=0.1;                 })             await sleep(20)         } 到站了~           await sleep(6000)//停站中 回去用脚吧 不要打了,告诉你们!         for(let i=0;i<15;i++){//火车向后加速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z-=0.1;                 })             await sleep(20)         }                  await sleep(4500)//行驶中         for(let i=0;i<15;i++){//火车向后减速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z+=0.1;                 })             await sleep(20)         }         await sleep(6000)//停站中   } })();   然后就是粒子效果   world.querySelectorAll('.gb2').forEach((p) => {     Object.assign(p, {         particleRate: 220,         particleSize: [2, 2, 2, 2, 2],         particleColor: [             new Box3RGBColor(50, 50, 50),             new Box3RGBColor(5, 0.25, 0.1),             new Box3RGBColor(3, 0.05, 0.05),             new Box3RGBColor(0, 0, 0),             new Box3RGBColor(0, 0, 0),         ],         particleLifetime: 1,         particleVelocitySpread: new Box3Vector3(2, 2, 2),     }); }); 合起来~   (async function(){ while (true) {         for(let i=0;i<15;i++){//火车向前加速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z+=0.1;                 })             await sleep(20)         }                  await sleep(4500)//行驶中         for(let i=0;i<15;i++){//火车向前减速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z-=0.1;                 })             await sleep(20)         }         await sleep(6000)//停站中         for(let i=0;i<15;i++){//火车向后加速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z-=0.1;                 })             await sleep(20)         }                  await sleep(4500)//行驶中         for(let i=0;i<15;i++){//火车向后减速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z+=0.1;                 })             await sleep(20)         }         await sleep(6000)//停站中   } })(); world.querySelectorAll('.gb2').forEach((p) => {     Object.assign(p, {         particleRate: 220,         particleSize: [2, 2, 2, 2, 2],         particleColor: [             new Box3RGBColor(50, 50, 50),             new Box3RGBColor(5, 0.25, 0.1),             new Box3RGBColor(3, 0.05, 0.05),             new Box3RGBColor(0, 0, 0),             new Box3RGBColor(0, 0, 0),         ],         particleLifetime: 1,         particleVelocitySpread: new Box3Vector3(2, 2, 2),     }); }); 记得礼貌拿代码,别忘记给我作品点赞emotion_doge


回复

上一页1 页 / 共 1下一页
烤乳鸽RoastedSquab烤乳鸽RoastedSquab

额,我不是换行了吗……自行观看

点赞0


评论


烤乳鸽RoastedSquab烤乳鸽RoastedSquab

第一个教程贴~

点赞0


评论


烤乳鸽RoastedSquab烤乳鸽RoastedSquab

点赞0


评论


烤乳鸽RoastedSquab烤乳鸽RoastedSquab

点赞0


评论


烤乳鸽RoastedSquab烤乳鸽RoastedSquab

点赞0


评论


烤乳鸽RoastedSquab烤乳鸽RoastedSquab

 

点赞0


评论


wangjunjiecwangjunjiec

额,你不会用写代码功能吗

点赞0


评论


wangjunjiecwangjunjiec

 for(let i=0;i<15;i++){//火车向后加速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z-=0.1;                 })             await sleep(20)         }                  await sleep(4500)//行驶中         for(let i=0;i<15;i++){//火车向后减速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z+=0.1;                 })             await sleep(20)         }         await sleep(6000)//停站中   } })();   然后就是粒子效果   world.querySelectorAll('.gb2').forEach((p) => {     Object.assign(p, {         particleRate: 220,         particleSize: [2, 2, 2, 2, 2],         particleColor: [             new Box3RGBColor(50, 50, 50),             new Box3RGBColor(5, 0.25, 0.1),             new Box3RGBColor(3, 0.05, 0.05),             new Box3RGBColor(0, 0, 0),             new Box3RGBColor(0, 0, 0),         ],         particleLifetime: 1,         particleVelocitySpread: new Box3Vector3(2, 2, 2),     }); }); 合起来~   (async function(){ while (true) {         for(let i=0;i<15;i++){//火车向前加速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z+=0.1;                 })             await sleep(20)         }                  await sleep(4500)//行驶中         for(let i=0;i<15;i++){//火车向前减速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z-=0.1;                 })             await sleep(20)         }         await sleep(6000)//停站中         for(let i=0;i<15;i++){//火车向后加速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z-=0.1;                 })             await sleep(20)         }                  await sleep(4500)//行驶中         for(let i=0;i<15;i++){//火车向后减速             world.querySelectorAll(".gb2").forEach((entity)=>{                 entity.velocity.z+=0.1;                 })             await sleep(20)         }         await sleep(6000)//停站中   } })(); world.querySelectorAll('.gb2').forEach((p) => {     Object.assign(p, {         particleRate: 220,         particleSize: [2, 2, 2, 2, 2],         particleColor: [             new Box3RGBColor(50, 50, 50),             new Box3RGBColor(5, 0.25, 0.1),             new Box3RGBColor(3, 0.05, 0.05),             new Box3RGBColor(0, 0, 0),             new Box3RGBColor(0, 0, 0),         ],         particleLifetime: 1,         particleVelocitySpread: new Box3Vector3(2, 2, 2),     }); });

点赞0


评论


ashyashy

OVO

点赞0


评论


build_一只建筑师吖build_一只建筑师吖

我真服了你们

看我的吧↓

(async function(){
while (true) {
        for(let i=0;i<15;i++){//火车向前加速
            world.querySelectorAll(".gb2").forEach((entity)=>{
                entity.velocity.z-=0.07;    
            })
            await sleep(120)
        }
        
        await sleep(4500)//行驶中
        for(let i=0;i<15;i++){//火车向前减速
            world.querySelectorAll(".gb2").forEach((entity)=>{
                entity.velocity.z+=0.07;    
            })
            await sleep(120)
        }
        await sleep(3000)//停站中
        for(let i=0;i<15;i++){//火车向后加速
            world.querySelectorAll(".gb2").forEach((entity)=>{
                entity.velocity.z+=0.07;    
            })
            await sleep(120)
        }
        
        await sleep(4500)//行驶中
        for(let i=0;i<15;i++){//火车向后减速
            world.querySelectorAll(".gb2").forEach((entity)=>{
                entity.velocity.z-=0.07;    
            })
            await sleep(120)
        }
        await sleep(3000)//停站中
  } })();
world.querySelectorAll('.gb2').forEach((p) => {   
    Object.assign(p, {
        particleRate: 1000,
        particleSize: [10, 12, 14, 18, 20],
        particleColor: [
            new Box3RGBColor(10, 9, 2),
            new Box3RGBColor(5, 0.25, 0.1),
            new Box3RGBColor(3, 0.05, 0.05),
            new Box3RGBColor(0, 0, 0),
            new Box3RGBColor(0, 0, 0),
        ],
        particleLifetime: 10,
        particleVelocitySpread: new Box3Vector3(2, 2, 2),
    });
});
//此代码实现了火车着火的特效

效果图:

center_image

好玩~

点赞0


评论