targets
The touchTargetsKit front door: `require("touchTargetsKit.targets")`. `start`/`stop` recognition on this client, `add`/`remove` targets, and listen with `onHit` (every peer, once per resolved hit), `onMiss`, `onHoldProgress` and `onDrag` (local). It reads touches (`Zin.touch.slot…
targets
The touchTargetsKit front door: require("touchTargetsKit.targets"). start/stop recognition on this client, add/remove targets, and listen with onHit (every peer, once per resolved hit), onMiss, onHoldProgress and onDrag (local). It reads touches (Zin.touch.slots()) and the mouse each frame, tests them against every target's projected screen circle (fingertip-sized minimum radius), turns gestures (tap, doubleTap, hold, swipe, drag, any) into claims, resolves claims on the target's authority (its owner, else the host) over multiplayer.send, broadcasts hits, plays reactions and draws hold rings and highlights through the overlay. Game code and the TouchTarget component call it; the package README documents every call.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2nonstrict
current( ) → boolean
now( ) → number
pr( ) → number
sessionToken( ) → string
emit(kind: string, ev: ?) → void
| arg | type | description |
|---|---|---|
| kind | string | |
| ev | ? |
connected( ) → boolean
myPeer( ) → number
myUser( ) → string
send(channel: string, msg: ?) → void
| arg | type | description |
|---|---|---|
| channel | string | |
| msg | ? |
idOf(x: ?) → string
| arg | type | description |
|---|---|---|
| x | ? |
entityOf(x: ?) → void
| arg | type | description |
|---|---|---|
| x | ? |
isSynced(e: ?) → boolean
| arg | type | description |
|---|---|---|
| e | ? |
isHost( ) → boolean
isAuthority(e: ?) → boolean
The one peer that resolves claims on this entity: its owner, or the host for an entity no peer owns (and for one each peer holds its own copy of).
| arg | type | description |
|---|---|---|
| e | ? |
ownsSynced(e: ?) → boolean
| arg | type | description |
|---|---|---|
| e | ? |
gestureSet(g: ?) → void
| arg | type | description |
|---|---|---|
| g | ? |
pick(name: any, valid: (any) → void
| arg | type | description |
|---|---|---|
| name | any | |
| valid | (any |
cfgOf(t: ?) → void
The wire form of a target's settings (no functions, no proxies).
| arg | type | description |
|---|---|---|
| t | ? |
accepts(t: ?, g: string) → boolean
| arg | type | description |
|---|---|---|
| t | ? | |
| g | string |
posOf(t: ?) → void
Where a target is drawn: its `positionOf` callback when it has one, else its entity's position. Answers { x, y, z } or nil.
| arg | type | description |
|---|---|---|
| t | ? |
ensureDriver( ) → void
register(e: ?, opts: ?, fromWire: boolean) → string
| arg | type | description |
|---|---|---|
| e | ? | |
| opts | ? | |
| fromWire | boolean |
unregister(id: string, fromWire: boolean) → void
| arg | type | description |
|---|---|---|
| id | string | |
| fromWire | boolean |
currentLook( ) → void
applyHit(msg: ?) → void
| arg | type | description |
|---|---|---|
| msg | ? |
resolve(claim: ?, fromPeer: number) → void
The authority's side: accept or refuse one claim, then broadcast the hit.
| arg | type | description |
|---|---|---|
| claim | ? | |
| fromPeer | number |
claim(t: ?, gesture: string, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| t | ? | |
| gesture | string | |
| x | number | |
| y | number |
miss(gesture: string, x: number, y: number, reason: string, t: ?, extra: ?) → void
| arg | type | description |
|---|---|---|
| gesture | string | |
| x | number | |
| y | number | |
| reason | string | |
| t | ? | |
| extra | ? |
listen( ) → void
_deliver(channel: string, from: number, msg: ?) → void
Testing: hand this peer a message as if peer `from` sent it on `channel` ("claim", "hit", "reg", "unreg").
| arg | type | description |
|---|---|---|
| channel | string | |
| from | number | |
| msg | ? |
norm(x: number, y: number, z: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| z | number |
updateCamera( ) → boolean
pxPerWorld(d: number) → number
Pixels per world unit at depth `d` in front of the camera.
| arg | type | description |
|---|---|---|
| d | number |
project(t: ?, minR: number) → void
| arg | type | description |
|---|---|---|
| t | ? | |
| minR | number |
live(t: ?) → boolean
| arg | type | description |
|---|---|---|
| t | ? |
targetAt(x: number, y: number, want: ((any) → void
Best target under a point: the one whose hit circle holds it most centrally. `want` filters by gesture (nil = any target).
| arg | type | description |
|---|---|---|
| x | number | |
| y | number | |
| want | ((any |
segDist(px: number, py: number, ax: number, ay: number, bx: number, by: number) → void
Distance from point (px,py) to segment (ax,ay)-(bx,by), and the closest point.
| arg | type | description |
|---|---|---|
| px | number | |
| py | number | |
| ax | number | |
| ay | number | |
| bx | number | |
| by | number |
planePoint(t: ?, f: ?, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| t | ? | |
| f | ? | |
| x | number | |
| y | number |
dragEvent(t: ?, f: ?, phase: string, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| t | ? | |
| f | ? | |
| phase | string | |
| x | number | |
| y | number |
holdProgress(t: ?, p: number) → void
| arg | type | description |
|---|---|---|
| t | ? | |
| p | number |
wantTapish(t: ?) → void
| arg | type | description |
|---|---|---|
| t | ? |
wantHold(t: ?) → void
| arg | type | description |
|---|---|---|
| t | ? |
wantDrag(t: ?) → void
| arg | type | description |
|---|---|---|
| t | ? |
fingerBegan(key: ?, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| key | ? | |
| x | number | |
| y | number |
sliceSegment(f: ?, ax: number, ay: number, bx: number, by: number) → void
| arg | type | description |
|---|---|---|
| f | ? | |
| ax | number | |
| ay | number | |
| bx | number | |
| by | number |
fingerMoved(f: ?, x: number, y: number, dt: number) → void
| arg | type | description |
|---|---|---|
| f | ? | |
| x | number | |
| y | number | |
| dt | number |
finishTap(t: ?, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| t | ? | |
| x | number | |
| y | number |
fingerEnded(f: ?, x: number, y: number) → void
| arg | type | description |
|---|---|---|
| f | ? | |
| x | number | |
| y | number |
stepHold(f: ?, dt: number) → void
| arg | type | description |
|---|---|---|
| f | ? | |
| dt | number |
toWindow(x: number, y: number) → void
| arg | type | description |
|---|---|---|
| x | number | |
| y | number |
stateClaims( ) → void
releaseClaims( ) → void
readFingers(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
stepPendingTaps( ) → void
ringPiece(look: ?, t: ?, shape: string, a: number, rad: number, along: number, across: number, r: number, g: number, b: number, alpha: number, lift: number) → void
Push a dot/segment on the ring around target t: angle a (0 = top, clockwise on screen), ring radius rad (world), sizes along tangent / radial / depth.
| arg | type | description |
|---|---|---|
| look | ? | |
| t | ? | |
| shape | string | |
| a | number | |
| rad | number | |
| along | number | |
| across | number | |
| r | number | |
| g | number | |
| b | number | |
| alpha | number | |
| lift | number |
drawHold(t: ?, look: ?, p: number) → void
| arg | type | description |
|---|---|---|
| t | ? | |
| look | ? | |
| p | number |
drawHighlight(t: ?, look: ?, k: number, dt: number) → void
| arg | type | description |
|---|---|---|
| t | ? | |
| look | ? | |
| k | number | |
| dt | number |
settleGrow(t: ?) → void
| arg | type | description |
|---|---|---|
| t | ? |
step(dt: number) → void
| arg | type | description |
|---|---|---|
| dt | number |
hasWork( ) → void
step(dt: ?) → void
| arg | type | description |
|---|---|---|
| dt | ? |
start(opts: ?) → void
Begin recognising gestures on this client (idempotent). opts.look, opts.minRadius (logical points, default 44), opts.enabled.
| arg | type | description |
|---|---|---|
| opts | ? |
stop( ) → void
Stop recognising on this client. Targets stay registered; indicators clear; running reactions finish.
add(e: ?, opts: ?) → string
Make an entity a touch target. Returns its id. Calling it again on the same entity updates its settings.
| arg | type | description |
|---|---|---|
| e | ? | |
| opts | ? |
remove(entityOrId: ?) → void
Stop an entity (or id) being a target.
| arg | type | description |
|---|---|---|
| entityOrId | ? |
subscribe(kind: string, fn: ?, opts: any?) → void
| arg | type | description |
|---|---|---|
| kind | string | |
| fn | ? | |
| opts | any? |
onHit(fn: ?, opts: any?) → void
fn(ev) on every peer once per resolved hit: { entity, id, kind, gesture, player (winner's user id), peer (winner's peer id), isLocal, points, data, screenX, screenY, world }. opts.key replaces the listener registered before under that key. Returns an unsubscribe function.
| arg | type | description |
|---|---|---|
| fn | ? | |
| opts | any? |
onMiss(fn: ?, opts: any?) → void
Local: fn(ev) { gesture, screenX, screenY, reason = "empty"|"wrongGesture", entity? } when a gesture hits nothing it can. opts.key as for onHit.
| arg | type | description |
|---|---|---|
| fn | ? | |
| opts | any? |
onHoldProgress(fn: ?, opts: any?) → void
Local: fn(ev) { entity, id, progress 0..1 } while a finger holds a hold target (0 when it lets go early). opts.key as for onHit.
| arg | type | description |
|---|---|---|
| fn | ? | |
| opts | any? |
onDrag(fn: ?, opts: any?) → void
Local: fn(ev) { entity, id, phase = "begin"|"move"|"end", world, position, screenX, screenY } for a drag target. opts.key as for onHit.
| arg | type | description |
|---|---|---|
| fn | ? | |
| opts | any? |
setLook(name: string) → void
| arg | type | description |
|---|---|---|
| name | string |
getLook( ) → string return S
looks( ) → void
reactions( ) → void
holdRings( ) → void
highlights( ) → void
gestures( ) → void
setEnabled(on: boolean) → void
| arg | type | description |
|---|---|---|
| on | boolean |
isEnabled( ) → boolean return S
isStarted( ) → boolean return S
get(entityOrId: ?) → void
The target record for an entity or id (read-only view), or nil.
| arg | type | description |
|---|---|---|
| entityOrId | ? |
list( ) → void
Ids of every registered target.
stats( ) → void
Counters and live state, for tests and the profiler.
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.