五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

粒子特效

2023-08-11 16:04 作者:fun-無痕  | 我要投稿

console.clear()


function particleSpread(entity, colorList, scale = 1) {

? ? entity.particleRate = 550//粒子生成速率

? ? entity.particleLifetime = 2//粒子存活時間為2秒

? ? entity.particleColor = colorList//粒子的顏色列表

? ? entity.particleSize = [15 * scale, 10 * scale, 5 * scale, 2 * scale, scale]//粒子在5個階段的大小

? ? entity.particleSizeSpread = 2 * scale//粒子的大小的隨機變化幅度

? ? entity.particleVelocitySpread = [20 * scale, 20 * scale, 20 * scale]//粒子XYZ方向速度的隨機變化幅度

? ? entity.particleAcceleration = [0, -10 * scale, 0]//粒子往下飄落模擬重力效果

}


const YELLOW = new Box3RGBColor(10, 10, 2)//黃

const CYAN = new Box3RGBColor(2, 10, 10)//青

const MAGENTA = new Box3RGBColor(10, 2, 10)//品紅

const RED = new Box3RGBColor(10, 2, 2)//紅

const GREEN = new Box3RGBColor(2, 10, 2)//綠

const BLUE = new Box3RGBColor(2, 2, 10)//藍(lán)


//各個顏色5個粒子階段的顏色列表

const ColorList = [

? ? [YELLOW, YELLOW, YELLOW, YELLOW, YELLOW],

? ? [CYAN, CYAN, CYAN, CYAN, CYAN],

? ? [MAGENTA, MAGENTA, MAGENTA, MAGENTA, MAGENTA],

? ? [RED, RED, RED, RED, RED],

? ? [GREEN, GREEN, GREEN, GREEN, GREEN],

? ? [BLUE, BLUE, BLUE, BLUE, BLUE],

]



function randomColor() {

? ? return ColorList[Math.floor(ColorList.length * Math.random())] //隨機選取一個顏色列表

}


const MeshScale = [1 / 16, 1 / 16, 1 / 16] //默認(rèn)的模型縮放系數(shù)

async function particleShoot(entity) {

? ? const fireball = world.createEntity({

? ? ? ? bounds: [0, 0, 0], // 隱形實體默認(rèn)大小是1x1x1的方塊, 現(xiàn)在把它從方塊縮成大小為0x0x0的1個點

? ? ? ? collides: false, // 開啟碰撞

? ? ? ? gravity: false, // 不受重力影響

? ? ? ? position: entity.position,

? ? })


? ? const color = randomColor()//隨機顏色

? ? particleSpread(fireball, color, 0.3) //粒子大小系數(shù)縮到0.3, 形成小火球


? ? await sleep(100) // 等待0.1秒后升空

? ? fireball.velocity.set(0, 1, 0) // 火球速度為每秒向上1格


? ? await sleep(2000) //升空2秒后爆炸


? ? fireball.velocity.set(0, 0, 0) // 火球停止運動

? ? particleSpread(fireball, color, 1) // 系數(shù)增大到1, 讓火球變大


? ? await sleep(1500) //大火球等待1.5秒后消失

? ? fireball.destroy()

}


const firework = world.querySelector('#新年煙花-1')

firework.enableInteract = true

firework.interactRadius = 3

firework.onInteract(async () => {

? ? var n = 3 //每次

? ? while (n-- > 0) {

? ? ? ? particleShoot(firework)//在"新年煙花-1"實體的位置發(fā)射煙花

? ? ? ? await sleep(2000)//每隔2秒射1發(fā)

? ? }

})


粒子特效的評論 (共 條)

分享到微博請遵守國家法律
佛学| 东安县| 石泉县| 漯河市| 延长县| 横山县| 昭通市| 宜川县| 青海省| 伊宁市| 成安县| 兴城市| 宿州市| 玉山县| 东山县| 绩溪县| 泰顺县| 凤城市| 黎城县| 玛纳斯县| 台湾省| 通许县| 阳东县| 华容县| 绩溪县| 寿光市| 五常市| 务川| 遵义市| 吉安市| 广宗县| 广南县| 鄱阳县| 启东市| 山阳县| 临朐县| 余姚市| 白朗县| 宁海县| 丰台区| 敖汉旗|