TestStage
A scene's runtime for tests, with no renderer and no page: WardicThree.make on a stand-in canvas,
its frames pumped by frame(), and a pointer that hovers and presses objects through the scene's own
input, hit by three's real raycast. It runs in Node.
frame(ms?)runs one frame of the Host loop, 1/60 s on by default: Wardic's raycast and writes against the scene as it's built, as though the page had drawn it, then its matrices made current, as a render makes them.pointermoves a mouse over the stand-in canvas:over(mesh)to wheremeshis drawn,at(x, y),down(),up(),cancel()andleave(). A frame then finds what's under it, as on a page.
import * as TestStage from "@wardic/three/TestStage"
const stage = TestStage.make({ scene, camera, size: { width: 800, height: 600 } })
stage.hover(crate, () => {
stage.animate(crate, { scale: 1.1 })
return () => stage.animate(crate, { scale: 1 })
})
stage.pointer.over(crate)
stage.frame()Interfaces
Options
make's options: the scene, its camera, the stand-in canvas's size, and WardicThree.make's.
Extends
Omit<Options,"canvas"|"camera"|"scene"|"window"|"now">
Properties
camera
readonly camera: Camera;hitTest?
readonly hitTest?: HitTest;What a pointer hits, in the raycast's place: a BVH's, or a GPU pick's.
Inherited from
Omit.hitTest
scene
readonly scene: Object3D;size
readonly size: object;The stand-in canvas's size, in CSS pixels, at the page's top left.
height
readonly height: number;width
readonly width: number;unitScale?
readonly unitScale?: number;How many of Motion's units a metre is, for x, y and z's springs' rest: 100 (a scene in
metres), so a 10 m move rests within 5 mm. Give 1 for a scene in pixels.
Inherited from
Omit.unitScale
TestPointer
A mouse over the stand-in canvas.
Properties
at
readonly at: (x, y) => void;Moves it to x, y on the canvas, in CSS pixels.
Parameters
x
number
y
number
Returns
void
cancel
readonly cancel: () => void;The platform cancels its press.
Returns
void
down
readonly down: () => void;Presses its main button where it is.
Returns
void
leave
readonly leave: () => void;Takes it off the canvas.
Returns
void
over
readonly over: (target) => void;Moves it to where target is drawn: a scene object's middle, a Batch member's, an instance's.
Parameters
target
object
Returns
void
position
readonly position: () => object;Where it is now, in CSS pixels.
Returns
object
x
readonly x: number;y
readonly y: number;up
readonly up: () => void;Releases it where it is.
Returns
void
TestStage
A test's scene runtime: WardicThree's, its frames pumped by frame, with a pointer.
Extends
Omit<WardicThree,"frame">
Indexable
[key: string]: WardicObject[key: number]: WardicObject[key: symbol]: WardicObjectProperties
canvas
readonly canvas: EventTarget;The stand-in canvas the pointer's events reach.
frame
readonly frame: (ms?) => void;One frame of the Host loop, ms after the last (1/60 s): Wardic's frame on the scene as it's built, then its matrices, as a render makes them.
Parameters
ms?
number
Returns
void
now
readonly now: () => number;The stage's time now, in ms.
Returns
number
pointer
readonly pointer: TestPointer;Functions
make()
function make(options): TestStage;A scene runtime for a test, on a stand-in canvas of options.size.