WardicStage
The context a scene's Stage is found through. A Stage runs a scene for its owner: its Host loop, its input and its canvas's size. Under one, the hooks run in its scene instead of on the page:
import { ward, WardicStage } from "@wardic/solid"
<WardicStage value={stage}>
<Crate mesh={crate} />
</WardicStage>
function Crate(props: { readonly mesh: Mesh }) {
const crate = ward(props.mesh, { whileHover: { scale: 1.08 } })
return crate.held
}ward(subject, config)hands the Stage a Subject that's its own, and any accessor of one: the Stage's ward moves it, and has the same events andreada ward on an element has.createFrameEffectruns in the Stage's Host loop, after Wardic's writes and before the scene renders.createHover(mesh)andcreatePress(mesh)read the pointer over the Subject, and pressed on it, through the Stage's input.- An element stays the page's, under a Stage or not.
A scene's hooks alone
ward, createBatch and the sensors take a page's element as well as a scene's object, so each brings the page's half with it. For ward, that's the page's ward and every Feature, 57.6 KB gzipped, in an app that may have no page wards at all. Their Stage halves are exported apart, taking only what the Stage above takes:
| Hook | Its Stage half |
|---|---|
ward(subject, config) | wardOnStage |
createBatch({ object | instances, … }) | createBatchOnStage |
createHover(subject) | createHoverOnStage |
createPress(subject) | createPressOnStage |
createDrag(subject) | createDragOnStage |
An Environment's binding re-exports them under the hooks' own names. A scene with no page wards imports them from there, as @wardic/three/solid's ward, createBatch, createHover, createPress and createDrag, and its app carries none of the page's code: a three.js scene and one ward come to 243.1 KB gzipped, against 300.5 through @wardic/solid's ward. A page with both can use either. Given a page's element, each says to import its hook from @wardic/solid, in development.
A ward on a scene's Subject
It takes initial, animate, transition, its own variants, whileHover, whileTap and custom. A key of the page's alone (whileFocus, whileInView) or of an element's (drag, exit, layout, style) is an error in development, naming it.
heldrenders nothing. While its Subject or itsanimateis still loading, it holds its component's<Loading>, so the fallback shows and<Reveal>orders it.- Its events are a ward's:
settled(),tapped(), andnext,eachandwhenforsettled, the hover events and the press events. Each event'selementis the Subject. read(key)andatom(key)give the Subject's value forkeyas Wardic draws it. A key the ward hasn't moved reads what the Subject holds, soward(light, {}).read("intensity")()is the light's intensity from the start. A key its Subject has reads at its type:ward(mesh, {}).read("y")is anAccessor<number>, andundefinedonly while an accessor gives no Subject. A colour reads by its channels in linear light,colorR,colorGandcolorB.- An accessor Subject:
ward(() => active(), config)follows each Subject it gives. A new one takes the ward over, starting frominitialas the ward did, and the last keeps where it was, with no exit. - A key a gesture moves returns, once the gesture ends, to the value the Subject had before the ward first moved it.
- The Stage's
animateon a Subject a ward is on goes through the ward, which takes the key back at its next change.
WardicStage is Solid 2's own provider, <WardicStage value={stage}>; read it with useContext(WardicStage), which is null outside one. A scene's Subject given to ward with no Stage above it is an error that names it, in development.
Scenes come with @wardic/three/solid's createStage, which makes a Stage for a three.js scene. The Stage interface names no three.js code, so another Environment can fill it: its ward is stageWard(environment), given what Wardic's runtime for its Subjects runs on and the scene's input. Solid 2 only.
Types
Stage: what the hooks read of a Stage: whether a value is one of its Subjects, its ward,animate, its Frame effects and its pointer input.StageWard: a ward on a Stage's Subject:held,settled,next,each,whenandread.StageSubjects: the Subjects a Stage takes, which an Environment adds to by declaration merging:@wardic/three/solidadds three.js's objects, soward(mesh, config)is typed.StageSubject: any of them.StageValues,StageValueKey: the values a Stage's Subjects take beyond an element's, which an Environment adds to by declaration merging:@wardic/three/solidadds three.js's, soward(mesh, { animate: { roughness: 0.2, emissive: "#ff6a00" } })typechecks, and a name in neither is still an error naming it.StageReads: what each key of a Stage's Subject reads as, which an Environment adds to by declaration merging, a generic interface of the Subject:@wardic/three/solidadds three.js's, each number a scene object has, its material's and its vectors' axes, soreadgives a mesh'sroughness, a light'sintensityor a number of your own on aGroupas anumber.StageRead,StageReadKey,StageValueOf: a Stage ward'sread, the keys it reads at its Subject's types, and the type it reads for a key: the Subject's for a key it has, as a page ward's for any other.StageSubjectOf: the Subject a ward is given: itself, or what an accessor gives,undefinedamong it.StageEvent,StageEvents: the events a ward on a Stage's Subject tells, and each one's info.stageWard,StageWardEnvironment: a Stage'sward, bound to what it runs on: ananimateenvironment, where a Subject's keys start (startLinksOf) and the scene'sinput.stageSceneObject,StageMembership: a Scene object's ward, what an Environment'screateSceneObjectbuilds on. Given what joins its Subject to the scene and what takes it out, it joins once the ward can start, and plays itsexitbefore its Subject leaves, past its owner.StageGraph: a scene's graph, which an Environment with one gives its Stage: a Subject's parent, its moves, its place among an ancestor's children, and its descendants. On a Stage with one, a ward with variants and no names of its own follows the nearest ward above its Subject, and its stagger slot is its place among that ward's Subject's children.StageDrag,StageDragHandlers: what a Stage drags its Subjects with, its Environment's: it watches a Subject's drags on the Stage's input, moves it, and tells each pointer sample and its release coming to rest. A ward'sdragon a Stage with none is an error in development.StageDragConfig,StageDragRange,StageDragTransition: a scene's drag keys, in the page's drag keys' place:drag(true, or"x","y"or"z"),dragConstraintsper axis as[min, max],dragElastic,dragMomentum,dragTransition(its release's inertia) anddragSnapToOrigin. An Environment adds its own by declaration merging:@wardic/three/solidaddsdragPlane.StageWardConfig,StageWardConfigValues,StageWardChecked: a ward's config on a Stage's Subject: a ward's, with the scene's drag keys.StageBatch,StageKeyedBatchConfig,StageCountBatchConfig,StageBatchMembers,StageBatchValues,StageBatchTarget,StageBatchEvents,StageBatchMemberInfo: a scene's Batch, whatcreateBatchmakes under a Stage givenobject(a three.js object per member, added as it enters and removed once its exit lands) orinstances(anInstancedMesh's instances), keyed byeachandkeyor bycount, with its landings and its members' hovers and presses as a page's Batch's.StageBatchBinding,StageBatchHooks: what a Stage'sbatchgivescreateBatch, and what it tells it: an Environment's side of a scene's Batch.SceneWard,SceneObjectEvent,SceneObjectEvents,SceneObjectExit: a Scene object's handle, a ward that also tellsexitStartandexitComplete, and their info: the Subject leaving, aselement.