Surface input
Assign a live authored Raycast once or pass a fresh complete jolt_raycast result each frame. Never pass its .hit boolean. Successful queries include ray:{world,origin,target}, even when they miss physics. Snapshot mode reuses the first obstacle and performs no second physics query; authored rays follow their owner and cast during touch updates.
Example#
var hit = jolt_raycast(x1, y1, z1, x2, y2, z2);
if (display.set_touch_raycast(hit)) {
display.update_touch(mouse_check_button(mb_left));
if (display.is_touch_pressed()) {
var pixel = display.get_touch_position();
show_debug_message(pixel);
}
}Usage and limits#
Pass held state, not pressed-edge input. update_touch returns update success; is_touch_hovered reports a hit. pressed/down/released/cancelled describe capture. get_touch_position returns pixels, get_touch_uv returns normalized coordinates while hovered. Hiding, disconnecting or destroying cancels capture. Disconnect unavailable input explicitly through set_touch_raycast(undefined).
For multiple displays pass the same result object to all, then call update_touch once per shared ray and read all states. The nearest visible front-facing +Z rectangle wins. A closer physics hit blocks it; the owner is not automatically ignored. A physics miss can still hit a non-colliding display. These are coordinates and input states, not ready-made UI widgets.
API reference#
Public function and method signatures. Call methods on the returned instance; parameters with defaults are optional.
Related guides#
Verified operation contracts#
These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.
| Symbol / owner | Signature | Operation contract |
|---|---|---|
| JoltRenderSurface.get_touch_position | JoltRenderSurface.get_touch_position() | Copy of {u, v}0..1 or {x, y}pixels at current resolution, top-left origin; undefined without a valid touch point. |
| JoltRenderSurface.get_touch_uv | JoltRenderSurface.get_touch_uv() | Copy of {u, v}0..1 or {x, y}pixels at current resolution, top-left origin; undefined without a valid touch point. |
| JoltRenderSurface.is_touch_cancelled | JoltRenderSurface.is_touch_cancelled() | Boolean state of latest touch update; pressed/released are edges, cancelled indicates lost capture. Invalid/hidden owner or source cancels capture even on read. |
| JoltRenderSurface.is_touch_down | JoltRenderSurface.is_touch_down() | Boolean state of latest touch update; pressed/released are edges, cancelled indicates lost capture. Invalid/hidden owner or source cancels capture even on read. |
| JoltRenderSurface.is_touch_hovered | JoltRenderSurface.is_touch_hovered() | Boolean state of latest touch update; pressed/released are edges, cancelled indicates lost capture. Invalid/hidden owner or source cancels capture even on read. |
| JoltRenderSurface.is_touch_pressed | JoltRenderSurface.is_touch_pressed() | Boolean state of latest touch update; pressed/released are edges, cancelled indicates lost capture. Invalid/hidden owner or source cancels capture even on read. |
| JoltRenderSurface.is_touch_released | JoltRenderSurface.is_touch_released() | Boolean state of latest touch update; pressed/released are edges, cancelled indicates lost capture. Invalid/hidden owner or source cancels capture even on read. |
| JoltRenderSurface.set_touch_raycast | JoltRenderSurface.set_touch_raycast(ray) | Authored AssetRaycast or fresh complete jolt_raycast result including ray metadata, undefined detaches. Boolean; do not pass only .hit. Multiple surfaces can share a source. |
| JoltRenderSurface.update_touch | JoltRenderSurface.update_touch(down) | Boolean down/0/1 held state → Boolean. Once per source after transform updates; updates all sharing surfaces, tests +Z front and occlusion. Getters do not raycast. |
| SurfaceRaycastResult.cast | SurfaceRaycastResult.cast() | Touch snapshot adapter, not a new physics query. is_valid checks world; get_ray stored sample/undefined, cast only {hit, distance} from sample. Refresh input with a new raycast result. |
| SurfaceRaycastResult.get_ray | SurfaceRaycastResult.get_ray() | Touch snapshot adapter, not a new physics query. is_valid checks world; get_ray stored sample/undefined, cast only {hit, distance} from sample. Refresh input with a new raycast result. |
| SurfaceRaycastResult.is_valid | SurfaceRaycastResult.is_valid() | Touch snapshot adapter, not a new physics query. is_valid checks world; get_ray stored sample/undefined, cast only {hit, distance} from sample. Refresh input with a new raycast result. |