粒子系统事件

Particle system on event

我想让粒子系统出现在我的项目结束时,就像五彩纸屑一样。我拥有的是这个,但它不起作用,也不能将可见性设置为 false,然后为 true。不确定我可以使用哪个属性来设置可见性,然后再打开。

html:

<a-entity id="confetti" particle-system="accelerationSpread: 20 0 20; color: white; enabled: false;  particleCount: 300; opacity: 0.3; preset: default; size: 0.5; velocityValue: 0 15 0" position="5.584 1.250 -1.4"  ></a-entity>

js:

if (score == 7) {
    function tada() {
        congrats.setAttribute('visible', true);
        confetti.setAttribute('enabled', true);
    }
}

谢谢!

confetti.object3D.visible = falseconfetti.removeAttribute('particle-system')

您可以使用

AFRAME.utils.entity.setComponentProperty(confetti, 'particle-system.enabled', true);

显然setAttribute不支持多级组件。

它记录在这里: https://aframe.io/docs/1.0.0/core/utils.html#setcomponentproperty-entity-componentname-value-delimiter