Operation |
Name |
Example |
+ |
p |
var d=x.p(y); |
+= |
pe |
x.pe(y); |
- |
m |
var e=x.m(y); |
-= |
me |
x.me(y); |
* (a scalar) |
t |
var f=x.t(2); |
*= |
te |
x.te(2); |
Field |
Purpose |
lib.time |
Simulated time so far, in seconds.
Try "camera.position.z=Math.sin(lib.time);" to get a
pretty extreme view bob. |
lib.dt |
Simulated time per frame. Use this
to make your physics animate correctly despite
variations in frame rate, like
"camera.position.pe(cameraVelocity.t(lib.dt));" |
lib.mouseleft |
True if the mouse button is currently
down. |
lib.mousex |
The mouse's current absolute X position
onscreen, in pixels. (Also "lib.mousey" for Y
coordinate.) |
lib.mousedx |
The mouse's relative X motion this frame,
in pixels per frame. This is nonzero whenever the
mouse is moving. (Also "lib.mousedy") |
lib.key[] |
Array of booleans indexed by keyboard
key. "lib.key['x']" is true while the 'x' key is
down. Useful for smooth keyboard motion and
control. (Annoyingly, you may need to click once
in the simulation window to tell the browser to route
keystrokes there, not the code area.) |