or load it in HTML:
<script src=//xem.github.io/W/w.min.full.js></script>
// Start the framework
W.reset(canvasElement);
// Set clear color ("#fff" by default)
W.clearColor("#rgb");
// Set camera
// Settings: position (x, y, z), angle (rx, ry, rz), fov
W.camera({x, y, z, rx, ry, rz, fov});
// Set light direction
W.light({x, y, z});
// Set ambient light's force (between 0 and 1)
W.ambient(f);
// Create a group of objects: name, position, rotation
W.group({n, x, y, z, rx, ry, rz});
// Draw a built-in 3D object
// Settings: group, name, size, position, rotation, background, texture, smooth...
let settings = {g, n, size, x, y, z, rx, ry, rz, b, t, mix, s, ns, mode};
W.plane(settings);
W.billboard(settings);
W.cube(settings);
W.pyramid(settings);
W.sphere(settings);
// Add and draw a custom 3D model (see the OBJ file loader below)
W.add("custom_model", { vertices, uv, indices });
W.custom_model(settings);
// Move/resize a group or object: name, position, rotation, animation, delay (in ms)
W.move({n, size, x, y, z, rx, ry, rz, a}, delay);
// You can also use M to set a custom transformation matrix
W.move({n, M}, delay);
// Move camera / light: settings, animation, delay
W.camera({x, y, z, rx, ry, rz, a}, delay);
W.light({x, y, z, a}, delay);
// Delete an element: name, delay
W.delete(n, delay);
<canvas id=canvasElement>
and call W.reset(canvasElement)
.
W.camera({x, y, z, rx, ry, rz, fov})
.
W.light({x, y, z})
and the ambient light leved using W.ambient(n)
.
W.clearColor(c)
(where c is a hex RGB/RGBA string).
W.plane
, W.billboard
, W.cube
, W.pyramid
and W.sphere
.
{g, n, size, w, h, d, x, y, z, rx, ry, rz, b, t, mix, s, mode}
W.group({n, x, y, z, rx, ry, rz})
(or W.group({n, M})
) and can be nested.
W.add("custom_shape", {vertices, uv, indices})
and draw it using W.custom_shape(settings)
.
W.move({n, size, x, y, z, rx, ry, rz, b, t, a}, delay)
.
delay
is provided, the transformation will be done after that delay in milliseconds. (0 by default)
a
parameter is provided, the transformation will be animated. The animation will last for a
milliseconds. (0 by default)
W.camera({x, y, z, rx, ry, rz, a}, delay)
.
W.light({x, y, z, a}, delay)
.
W.projection=new DOMMatrix([...])
.
W.move({n, M:[...]})
.
(animation is not possible in that case)
W.move({g /* group / null */ })
.