parallax
Background bands for 2D parallax, any number of layers, driven by your own camera code. `create(layers, opts)` spawns one band per layer (`{ material, factor, yFactor?, stretch? }`, far first; `opts` = `baseY`, `depth`, `parent`, `name`), `update(p, { x, y, halfW, halfH, zoom? })…
pixelParallax.parallax
Background bands for 2D parallax, any number of layers, driven by your own camera code. create(layers, opts) spawns one band per layer ({ material, factor, yFactor?, stretch? }, far first; opts = baseY, depth, parent, name), update(p, { x, y, halfW, halfH, zoom? }) moves and rescrolls them for a view, setVisible, destroy. bandUV(view, factor, yFactor, baseY, zoom) is the pixel-exact mapping (scroll rounded to whole screen pixels). IMAGE_W / IMAGE_H = 20 x 11.25 world units per picture. Used by pixelParallax.ParallaxBackground and twoDKit.parallax.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2strict
create(layers: { Layer }, opts: { baseY: number?, anchorY: number?, depth: number?, parent: string?, name: string? }?) → Parallax
Spawn one band per layer, far first. `material` may be a material or a function returning one (a failing one is skipped). opts: baseY (world height of the pictures' bottom edge when the camera is at `anchorY`), anchorY (default 0; set it to your scene's bottom when the scene is not at the origin), depth (z of the farthest band, default -30), parent, name.
| arg | type | description |
|---|---|---|
| layers | { Layer } | |
| opts | { baseY: number?, anchorY: number?, depth: number?, parent: string?, name: string? }? |
bandUV(v: { x: number, y: number, halfW: number, halfH: number }, factor: number, yFactor: number, baseY: number, zoom: number?, anchorY: number?) → void
The texture mapping of one band for a view: (offU, offV, scaleU, scaleV, quadW, quadH). One image pixel is one art pixel, and the scroll is rounded so the image's pixel edges fall on whole screen pixels, measured from the view's own edges: every background pixel is exactly zoom x zoom screen pixels, nothing crawls as the camera moves, and odd window sizes are no different. `factor` / `yFactor` are how fast the band follows the camera. The pictures' bottom edge sits at baseY + (camera y - anchorY) x (1 - yFactor).
| arg | type | description |
|---|---|---|
| v | { x: number, y: number, halfW: number, halfH: number } | |
| factor | number | |
| yFactor | number | |
| baseY | number | |
| zoom | number? | |
| anchorY | number? |
update(p: Parallax, v: { x: number, y: number, halfW: number, halfH: number }) → void
Move and rescroll every band for a view { x, y, halfW, halfH, zoom? }.
| arg | type | description |
|---|---|---|
| p | Parallax | |
| v | { x: number, y: number, halfW: number, halfH: number } |
setVisible(p: Parallax, visible: boolean) → void
Show or hide every band.
| arg | type | description |
|---|---|---|
| p | Parallax | |
| visible | boolean |
destroy(p: Parallax?) → void
| arg | type | description |
|---|---|---|
| p | Parallax? |
Layer = { material: any, factor: number, yFactor: number?, stretch: boolean? }Band = { id: string, factor: number, yFactor: number, stretch: boolean }Parallax = { id: string, bands: { Band }, baseY: number, anchorY: number, depth: number, root: string }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.