JS Vec3 xyx/rgb/red,green,blue aliases


#1

Hey folks,

Some have you may have noticed recently that Vec3s in scripts are stringifying with both xyz and red/green/blue properties. This was a bug that resulted from trying to support setting Vec3 properties with alternative property names. Obviously it didn’t exactly work as intented. In RC 75, this will be fixed.

What does this mean?

This is how Vec3 properties currently behave in master:

print(JSON.stringify(MyAvatar.position)); // prints `{x: 0, y: 0, z: 0, red: 0, green: 0, blue: 0}`
var color = Entities.getEntityProperties(<entity id>).color;
print(JSON.stringify(color)); // prints `{red: 255, green: 0, blue: 0}`
color.r = 127;
print(JSON.stringify(color)); // prints `{red: 255, green: 0, blue: 0, r: 127}`
Entities.editEntity(<entity id>, { color: {red: 0, green: 255, blue: 0} }); // works
Entities.editEntity(<entity id>, { color: {r: 0, g: 255, b: 0} }); // doesn't work
Entities.editEntity(<entity id>, { color: {x: 0, y: 255, z: 0} }); // doesn't work

This is how they will behave now:

print(JSON.stringify(MyAvatar.position)); // prints `{red: 0, green: 0, blue: 0}`
var color = Entities.getEntityProperties(<entity id>).color;
print(JSON.stringify(color)); // prints `{red: 255, green: 0, blue: 0}`
color.r = 127;
print(JSON.stringify(color)); // prints `{red: 127, green: 0, blue: 0}`
Entities.editEntity(<entity id>, { color: {red: 0, green: 255, blue: 0} }); // works
Entities.editEntity(<entity id>, { color: {r: 0, g: 255, b: 0} }); // works
Entities.editEntity(<entity id>, { color: {x: 0, y: 255, z: 0} }); // works

This shouldn’t affect existing content at all, except fixing some JSON stringifying bugs and enabling editing properties with the aliases.

If you have any questions or concerns please let us know!


Adding more marketplace items
#2

Just kidding we’re making a few more changes! Ignore this for now.


#3

OK! The changes have been updated slightly! Basically, you won’t notice any change and everything will work better! Hooray!

If you’re curious, you can try the changes here: https://github.com/highfidelity/hifi/pull/13596