I’ve been thinking about various shorthand notations to make experimenting with the JavaScript Console more intuitive.
As an example, consider the “longhand” version of rotating an avatar’s right arm:
var deg15y = Quat.fromVec3Degrees( { x: 0, y: 15, z: 0 } );
var q = MyAvatar.getJointRotation("RightArm");
MyAvatar.setJointData("RightArm", Quat.multiply( q, deg15y ) );
The “shorthand” version would just be:
> avatar.right.arm.Y += 15
Since the command prompt remembers your recent commands, to “undo” this kind of rotation you could simply hit the up-arrow, change 15 to -15 and hit enter again.
A few more hypothetical examples:
// align left and right Y rotations (accounting for L-R symmetry)
avatar.left.arm.Y = -avatar.right.arm.Y
// advance avatar along the X axis:
avatar.position.x += 0.5
// make the nearest FBX model twice as big:
all.querySelector("Model[modelURL*='fbx']").scale *= 2
// make all nearby Sphere's blue:
all.querySelectorAll("Sphere").forEach(function(o) { o.color = [0,0,1] });
// teleport to the nearest "fireplace" entity:
avatar.position = all.querySelector(/fireplace/i).position;
These abstractions might seem a little strange (compared to the existing API), but everything above is really just syntatic sugar – and requires only pure JavaScript to implement as a wrapper around the existing API (no C++ changes needed!).
Thoughts? And are there other objects that would be interesting to work with using shorthand? Maybe creating certain kinds of placeholder entities in bulk?