Every game object in Fraxel is built from nodes — JSX elements that map directly to engine classes. Nodes are the building blocks of the scene tree: each one owns its own lifecycle, children, events, and (for 2D nodes) aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sanchedev/fraxel/llms.txt
Use this file to discover all available pages before exploring further.
position in world space. You compose nodes by nesting JSX, and the engine manages their start, update, draw, and destroy phases automatically.
Node Overview
| Node | JSX Tag | Description |
|---|---|---|
Transform | <transform> | Positioning container for child nodes |
Group | <group> | Logical container (no spatial positioning) |
Sprite | <sprite> | Displays a texture with optional filters |
AnimationPlayer | <animation-player> | Plays frame-based animations |
Collider | <collider> | Detects overlaps with other colliders |
RayCast | <ray-cast> | Projects a ray to detect colliders |
Clickable | <clickable> | Detects click/hover pointer events |
Rectangle | <rectangle> | Renders a filled/stroked rectangle |
Timer | <timer> | Counts up and fires events |
Text | <text> | Renders text on the canvas |
AudioPlayer | <audio-player> | Plays audio buffers |
Camera | <camera> | Controls the viewport |
RigidBody | <rigid-body> | Adds physics simulation |
To get a typed reference to a node at runtime, pass a
PrimaryNode enum value to useNode(). For example: useNode(PrimaryNode.Sprite), useNode(PrimaryNode.Collider), useNode(PrimaryNode.Timer). Every built-in node type has a corresponding PrimaryNode variant: Group, Transform, Sprite, AnimationPlayer, Collider, RayCast, Clickable, Timer, Rectangle, Text, AudioPlayer, Camera, and RigidBody.Common Node Props
Every node, regardless of type, accepts these shared props inherited from the baseNode class:
| Prop | Type | Default | Description |
|---|---|---|---|
ref | NodeReference<T> | — | Attach a useNode() reference to access the node imperatively |
id | string | symbol | auto symbol | Identifier for useChild() path lookup. Must match [a-zA-Z][a-zA-Z0-9-_]* |
zIndex | number | 0 | Draw order relative to siblings (higher = drawn later / on top) |
deltaIncrease | number | 1 | Multiplies delta for this node and all its children (speed scaling) |
script | FraxelScript<T> | — | Attach a FraxelScript instance to this node |
children | Node[] | — | Child nodes (normally written as JSX children) |
Nodes
Transform
Transform
A Props
Inherits all common node props.
Transform is a spatial container that positions its children in 2D space. It has no visual output itself — it simply applies a coordinate offset to everything inside it. Use <transform> to group related nodes or to give a logical game object a single point of control.| Prop | Type | Default | Description |
|---|---|---|---|
position | VectorLike | SignalGetter | [0, 0] | Position in world space. Accepts [x, y], Vector2, or a signal getter |
Group
Group
A
Group is a logical container without spatial positioning. Unlike <transform>, it does not apply any coordinate offset to its children — it simply groups them for organizational or lifecycle purposes.<group> is used internally by the <List> component as an anchor for keyed reconciliation.PropsInherits all common node props. No additional props.Sprite
Sprite
The Props
Sprite node draws a texture on the canvas. It supports texture atlas slicing via margin and sourceSize, display scaling via displaySize, axis flipping, and a rich set of CSS-compatible visual filters. All filter props are reactive.| Prop | Type | Default | Description |
|---|---|---|---|
position | VectorLike | SignalGetter | [0, 0] | Position in world/parent space |
textureId | symbol | SignalGetter<symbol> | — | Symbol returned by loadTexture() |
margin | VectorLike | SignalGetter | [0, 0] | Texture offset (for sprite sheet frames) |
sourceSize | VectorLike | SignalGetter | Full texture | Region of the texture to render |
displaySize | VectorLike | SignalGetter | sourceSize | Rendered size of the sprite on canvas |
flipX | boolean | SignalGetter<boolean> | false | Mirror horizontally |
flipY | boolean | SignalGetter<boolean> | false | Mirror vertically |
brightness | number | SignalGetter<number> | 1 | 0 = black, 1 = base, 2 = white |
grayscale | number | SignalGetter<number> | 0 | 0 = full color, 1 = fully grayscale |
modulate | Color | SignalGetter<Color> | [1,1,1,1] | RGBA tint multiplier. Each channel 0–1 |
contrast | number | SignalGetter<number> | 1 | 0 = flat, 1 = base, 2 = double contrast |
saturate | number | SignalGetter<number> | 1 | 0 = desaturated, 1 = base, 2 = double saturation |
hueRotate | number | SignalGetter<number> | 0 | Hue rotation in degrees (0–360) |
invert | number | SignalGetter<number> | 0 | 0 = normal, 1 = fully inverted |
opacity | number | SignalGetter<number> | 1 | 0 = transparent, 1 = opaque |
Clickable
Clickable
The Props
Events (for
Clickable node detects pointer interactions within a defined hit area. Place it as a child of a <sprite> or <transform> to make that area interactive.| Prop | Type | Default | Description |
|---|---|---|---|
size | VectorLike | — | Required. Width and height of the clickable hit area |
disabled | boolean | false | Disables all pointer interactions when true |
onClick | (pos: Vector2) => void | — | Fires once when the pointer clicks inside the area; receives local position |
onMouseEnter | () => void | — | Fires once when the pointer enters the area |
onMouseExit | () => void | — | Fires once when the pointer leaves the area |
useEvent)| Event Name | Callback Signature | Description |
|---|---|---|
clicked | (pos: Vector2) => void | Pointer clicked inside the area; receives local position |
mouseEntered | () => void | Pointer entered the area |
mouseExited | () => void | Pointer left the area |
mouseOver | (pos: Vector2) => void | Fires every frame while the pointer is inside; pos is local |
Timer
Timer
The Props
Events (for
Methods (on
Timer node counts elapsed time and fires events at each tick and when it reaches its duration. It has no visual output but can hold child nodes.| Prop | Type | Default | Description |
|---|---|---|---|
duration | number | SignalGetter<number> | — | Required. Total duration in seconds |
autoPlay | boolean | false | If true, timer starts as soon as the node mounts |
useEvent)| Event Name | Callback Signature | Description |
|---|---|---|
timeout | () => void | Fires when the timer reaches duration |
timeChanged | (elapsed: number) => void | Fires every frame while playing; receives elapsed seconds |
timer.node)| Method | Signature | Description |
|---|---|---|
play(from?) | (from?: number) => void | Start or resume. Optionally start from a time in seconds |
pause() | () => void | Pause without resetting elapsed time |
stop() | () => void | Stop and reset elapsed time to 0 |
Collider
Collider
The Props
Events (for
Collider node detects overlapping collisions with other Collider nodes. It supports rectangle and circle shapes and uses a group-based filter to control which colliders interact with which.| Prop | Type | Default | Description |
|---|---|---|---|
shape | Shape | — | Required. shapes.rectangle(w, h) or shapes.circle(r) |
group | string[] | — | Required. Groups this collider belongs to |
collidesWith | string[] | — | Required. Groups this collider reacts to |
useEvent)| Event Name | Callback Signature | Description |
|---|---|---|
colliderEntered | (other: Collider) => void | Fires once when overlap begins |
collided | (other: Collider) => void | Fires every frame while overlapping |
colliderExited | (other: Collider) => void | Fires once when overlap ends |
RayCast
RayCast
The Props
Events (for
RayCast node projects a ray from its position in a given direction and fires events when that ray intersects a Collider belonging to one of the collidesWith groups.| Prop | Type | Default | Description |
|---|---|---|---|
direction | VectorLike | — | Ray direction vector (also encodes length) |
collidesWith | string[] | — | Required. Groups the ray detects |
useEvent)| Event Name | Callback Signature | Description |
|---|---|---|
colliderEntered | (collider: Collider) => void | Fires when the ray first hits a collider |
colliderExited | (collider: Collider) => void | Fires when the ray stops hitting a collider |
Rectangle
Rectangle
The Props
Rectangle node draws a filled and optionally stroked rectangle directly on the canvas. All visual props are reactive.| Prop | Type | Default | Description |
|---|---|---|---|
position | VectorLike | SignalGetter | [0, 0] | Position in parent space |
size | VectorLike | SignalGetter | — | Required. Width and height of the rectangle |
fillColor | Color | SignalGetter<Color> | [1,1,1,1] | RGBA fill color. Each channel 0–1 |
strokeColor | Color | SignalGetter<Color> | — | RGBA border color. If omitted, no border is drawn |
strokeWidth | number | SignalGetter<number> | 1 | Border width in pixels |
AnimationPlayer
AnimationPlayer
The Props
AnimationPlayer node drives frame-based sprite animations. It targets a <sprite> sibling and updates its margin, sourceSize, and displaySize each frame to step through keyframes.| Prop | Type | Default | Description |
|---|---|---|---|
animations | () => Record<string, Frame[]> | — | Required. Function returning the animation map (deferred call) |
currentAnim | string | SignalGetter<string> | — | Name of the animation to play. Reactive for auto-switching |
destroyOnEnd | boolean | false | Destroy the node after the animation finishes |
animations is called as a deferred function when the node starts, not during construction. This allows you to safely reference sibling sprite nodes that may not be available at JSX evaluation time.Text
Text
The Props
TextStyle fields
Text node renders a string on the canvas using ctx.fillText(). Its text prop is reactive, so it re-renders automatically when a signal changes.| Prop | Type | Default | Description |
|---|---|---|---|
position | VectorLike | SignalGetter | [0, 0] | Position in parent space |
text | string | SignalGetter<string> | — | Required. The string to render. Reactive via SignalGetter |
style | Partial<TextStyle> | TextStyle.DEFAULT | Partial style object. See TextStyle for all fields |
| Field | Type | Description |
|---|---|---|
fontSize | number | Font size in pixels |
fontFamily | string | CSS font family string |
fontWeight | string | CSS font weight ('normal', 'bold', etc.) |
foregroundColor | string | CSS color string for fill |
textAlign | CanvasTextAlign | 'left', 'center', 'right', etc. |
AudioPlayer
AudioPlayer
The Props
Events (for
Methods (on
AudioPlayer node plays audio buffers loaded with loadSound(). It supports looping, volume, playback rate, and deferred destruction until a sound finishes.| Prop | Type | Default | Description |
|---|---|---|---|
soundId | symbol | — | Required. Symbol returned by loadSound() |
loop | boolean | false | Loop the audio |
volume | number | 1 | Playback volume (0–1) |
playbackRate | number | 1 | Playback speed multiplier |
persistUntilEnd | boolean | false | Defer node destruction until the current sound finishes playing |
useEvent)| Event Name | Callback Signature | Description |
|---|---|---|
ended | () => void | Fires when playback finishes |
error | () => void | Fires on a playback error |
audio.node)| Method | Signature | Description |
|---|---|---|
play(offset?) | (offset?: number) => void | Start playback, optionally from offset |
pause() | () => void | Pause without resetting position |
stop() | () => void | Stop and reset to beginning |
Camera
Camera
The Props
Methods (on
Camera node controls the viewport — which part of the world is visible on screen. Its follow() method makes the camera track a target node automatically each frame.| Prop | Type | Default | Description |
|---|---|---|---|
position | VectorLike | SignalGetter | [0,0] | Camera position in world space |
zoom | number | 1 | Viewport zoom level |
camera.node)| Method | Signature | Description |
|---|---|---|
follow(target) | (target: Node2D | undefined) => void | Track a node every frame, or pass undefined to stop following |
RigidBody
RigidBody
The Props
RigidBody node adds physics simulation to a game object. It must be placed as a sibling of a <collider> node. The physics engine uses the collider’s shape for all calculations.| Prop | Type | Default | Description |
|---|---|---|---|
mass | number | 1 | Mass of the physics body |
friction | number | 0.5 | Surface friction coefficient |
bounce | number | 0 | Restitution (bounciness) coefficient |
isStatic | boolean | false | If true, the body does not move |
useGravity | boolean | true | Apply gravity each frame |
Access
rigidBody.node.physicsBody to call applyForce() and applyImpulse() for manual physics interactions. See the Physics guide for full documentation.The List Component
List renders a reactive array as a collection of nodes with keyed reconciliation — nodes are created once per key and reused as the array changes. It is imported from fraxel/jsx.
| Prop | Type | Default | Description |
|---|---|---|---|
array | T[] | SignalGetter<T[]> | — | Required. The reactive array to render |
itemKey | (value: T, index: number, arr: T[]) => string | symbol | — | Required. Unique key extractor per item |
empty | Fraxel.Node | — | Fallback node rendered when array is empty |
children | (value: T, index: number, arr: T[]) => Fraxel.Node | — | Required. Render function called for each item |
List produces no wrapper node in the tree — it renders a hidden <transform> as an internal anchor for reconciliation. Removed keys have their nodes destroyed; new keys create fresh nodes. Unchanged keys are left untouched.Related Pages
Hooks
useNode, useEvent, useSignal, and all other Fraxel hooks
Reactivity
How signals drive reactive prop updates without a Virtual DOM
Physics
Collider shapes, rigid bodies, and collision groups
Animation
Sprite sheet keyframes and AnimationPlayer usage