午梦初回,卷帘尽放春愁去。昼长无侣。自对黄鹂语。

63 阅读1分钟

three暂停多个requestAnimationFrame动画

const hydranLoopStopArr: any = [];
for (let i = 0; i < modelWaiGroup.children[0].children.length; i++) {
        const waiMesh = modelWaiGroup.children[0].children[i];
        if (waiMesh.name.includes('消防栓')) {

           const shandeHydran = 扩散围墙2('喵', i)
           fireHydrantGroup.add(shandeHydran);
        }
}

let 扩散围墙2: any = (LoopStopMsg: any = 'LoopStopMsg', i: number) => {

    if (LoopStopMsg == '消防栓shander') {
        return cancelAnimationFrame(hydranLoopStopArr[i])
    };
    
    // mesh
    
    const animate = () => {
        hydranLoopStopArr[i] = requestAnimationFrame(animate);
        // 更新时间uniform
        material.uniforms.time.value += 0.01;
    };animate();
    
    return mesh.clone()
}

绑定id暂停多个动画

for (let i = 0; i < modelWaiGroup.children[0].children.length; i++) {
    const waiMesh = modelWaiGroup.children[0].children[i];

    if (waiMesh.name.includes('消防栓')) {
        扩散围墙2('消防栓shander', i);
    }
}