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 73, 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 `{x: 0, y: 0, z: 0}`
var color = Entities.getEntityProperties(<entity id>).color;
print(JSON.stringify(color)); // prints `{x: 255, y: 0, z: 0}`
color.r = 127;
print(JSON.stringify(color)); // prints `{x: 127, y: 0, z: 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

The only way this will effect you is if you are passing colors around as strings. Colors now stringify with only xyz properties. You lose all of the alias information. If you are passing colors around as strings, on the receiving side, you should now expect xyz.

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.