aframe-particle-system-component icon indicating copy to clipboard operation
aframe-particle-system-component copied to clipboard

entity.setAttribute does not Render new Color, although Updates DOM

Open kkruups opened this issue 8 years ago • 0 comments
trafficstars

Problem:

Calling entity.setAttribute to change color updates the DOM, however does not render the new color (even when the entity has an element which refreshes per each frame).

Code Excerpt:

=================

...<html>
<!-- initial color: green -->
<a-entity debug  id="rain" particle-system="preset: rain; color: #00ff00; particleCount: 5000"></a-entity>
...</html>

JS

var rain = document.querySelector('#rain')
rain.setAttribute('particle-system', {preset: 'snow', color: '#ff0000'});  //color: red

DOM Updated: ["components"]['particle-system']['data']['color'] =[ #ff0000 ], however not rendered.

================ Expected Behavior: change in color via entity.setAttribute results in change in color w/o having to remove the particle-system component from the entity.

WorkAround

In order to get the color to update need to call removeAttribute then setAttribute

var rain = document.querySelector('#rain');
rain.removeAttribute('particle-system');
rain.setAttribute('particle-system', {preset: 'snow', color: '#ff0000'});  //color: red

==================== Additional Info: [debug] aframe component added to force update on each frame, however setAttribute does not behave as expected.


Is this API not designed to update after the page is loaded?

Please advise.

kkruups avatar Jun 19 '17 06:06 kkruups