-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
When updating component attrValue has to be used instead of component.data #2184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ngokevin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+wc
src/utils/coordinates.js
Outdated
|
|
||
| if (value && typeof value === 'object') { | ||
| return vecParseFloat(value); | ||
| coordinate = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Fill in missing values for each vector component.
return vecParseFloat({
x: value.x || defaultVec & defaultVec.x,
// ...
});
tests/core/a-entity.test.js
Outdated
| var el = this.el; | ||
| el.setAttribute('geometry', {primitive: 'sphere', radius: 10}); | ||
| el.setAttribute('geometry', {primitive: 'box'}); | ||
| assert.deepEqual(el.components.geometry.attrValue, {primitive: 'box', radius: 10}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should assert the component data as well with getAttribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, I should probably move this to the setAttribute suite
tests/core/a-entity.test.js
Outdated
|
|
||
| test('the attribute cache only stores the modified properties', function () { | ||
| var el = this.el; | ||
| el.setAttribute('geometry', {primitive: 'sphere', radius: 10}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assert the attrValue before the change too for clarity. Perhaps start with a box.
3e1f3d3 to
ee8a331
Compare
ee8a331 to
8b51f94
Compare
The bug was discovered when doing:
After the first line the value of el.components.geometry.attrValue was
{primitive: box}After the update
{"buffer":true,"primitive":"sphere","skipCache":false,"depth":1,"height":1,"width":1,"segmentsHeight":1,"segmentsWidth":1,"segmentsDepth":1}causing the default values of the box primitive to be applied to the sphere primitive after update.