aframe-react icon indicating copy to clipboard operation
aframe-react copied to clipboard

Bring clobbering back when updating component values

Open RSpace opened this issue 8 years ago • 0 comments

In my project, I'm switching between different models with different materials. When switching from a model using the standard shader to one using the flat shader, I get a bunch of core:schema:warn warnings about trying to set an unknown property.

Further investigation has led me to conclude that component values are not replaced on the A-Frame component when replaced on the A-Frame React Entity, but rather existing values are merged with new values, potentially leaving old values behind unintentionally.

I think this A-Frame commit that stopped clobbering by default could be where this problem started: https://github.com/aframevr/aframe/commit/704acfe68f2b0c0199cba3a7bd698cae3ee5c728

I realized this should be easy to fix by restoring the previous behavior by changing el.setAttribute(propName, props[propName]); to el.setAttribute(propName, props[propName], true); (adding true as third argument) in the doSetAttribute function.

However, when I do this - adding a test to verify it - two other tests break. One failure is a bit obscure, but the other clearly highlights a problem where the primitive special case is lost when geometry is updated.

I've made the change here: https://github.com/RSpace/aframe-react/tree/clobber. I'm using this branch in my own code, however, I can't make a PR because I can't really figure out a nice way to handle the primitive speciale case that results in two failing tests.

Thoughts?

RSpace avatar Jun 13 '17 13:06 RSpace