Namespace in reactor_3d.js

Reactor3D.MapScene

42 public functions in 5 groups · show internal (_) functions

A 3D map in the editor, with terrain and roads.

Quick Reference

Setup & Creation 2

initialize() Sets up a new instance.
build() Build.

Checks (True / False) 2

hasLights() Whether this map draws any lights at all.
hasAbove() Whether anything at all is drawn over the characters on this map.

Actions 13

setAnimationFrame() Sets the animation frame.
addParallaxGrounds() Lay the parallax under the map.
addParallaxGround() Adds the parallax ground.
addRoom() Build the room around a width x height tile map.
addRoomPiece() Adds the room piece.
setRoomCliff() The floor's cliff as { name, slope, tint } on a map already laid (the editor shows a change as it is made): t…
addSky() Adds the sky.
addSkyImage() Adds the sky image.
setSkyOffset() Sets the sky offset.
setPass() Show one pass and hide the other.
hideCrowdFromReflection() Hides the crowd from reflection.
clear() Clear.
destroy() Destroy.

Updating & Drawing 5

updateSky() Each frame: the sky stands around the camera and drifts by the frames elapsed.
syncLights() Lay this frame's lights on the ground.
syncVolumeLights() This frame's lights as a field: the nearest SHADER_LIGHTS to the focus written into the shared uniforms every…
renderShadows() The frame's shadow maps, before the first pass draws: see Reactor3D.Shadows.
updateDestination() Updates the destination each frame.

Other 20

facadeAt() Where this scene stood a cell's art up, if it did.
report() What actually got built, for when the view comes up empty.
extent() The world-space box the built geometry occupies.
groundPlane() A ground plane width x height tiles from the map's corner, lying in XZ at y: one quad on a flat map, a grid o…
skyOffset() Where the sky's drift has got to, and putting a new sky back there: the editor rebuilds the scene on an edit,…
belowGroup() The geometry drawn under the characters.
lightGroup() The light pools, drawn last and added to what is already there.
aboveGroup() The geometry drawn over them — the star-flagged tiles.
scene() Scene.
textureFor() Wrap a loaded Bitmap as a texture.
freezeStaticMeshes() The world never moves once built: tiles, structures, and parallax grounds stay where the map put them.
lightPool() One mesh holding every light of one shape.
reflectionProbe() Reflection probe.
mirrorHidden() Mirror hidden.
mirrorSubject() The points a mirror tries to show: the player's feet, chest and head.
reflectionHolders() The models reflections look at: the map's own, then any a host keeps outside it (guestModels, the battle room…
reflectionSubject() Who a mirror shows first: the player's model, or the host's pick (guestSubject, the battle's lead actor).
mirrorCandidates() The mirror-finish models near the camera, nearest first (at most two), for Reactor3D.Mirrors.
reflectionHidden() Reflection hidden.
lightBodies() The glowing bodies of the lights: a soft sphere at a point light, the cone of a spotlight, and a bright core…

Setup & Creation

initialize

method source
Reactor3D.MapScene.prototype.initialize(mapData, bitmaps, options)

Sets up a new instance.

build

method source
Reactor3D.MapScene.prototype.build(mapData, bitmaps, options)

Build.

Checks (True / False)

hasLights

method source
Reactor3D.MapScene.prototype.hasLights()

Whether this map draws any lights at all.

hasAbove

method source
Reactor3D.MapScene.prototype.hasAbove()

Whether anything at all is drawn over the characters on this map.

Actions

setAnimationFrame

method source
Reactor3D.MapScene.prototype.setAnimationFrame(frame)

Sets the animation frame.

addParallaxGrounds

method source
Reactor3D.MapScene.prototype.addParallaxGrounds(layers, load, tileSize)

Lay the parallax under the map.

Details

Lay the parallax under the map.

A hair below the tile ground rather than level with it, so a real tile painted over the parallax still wins the depth test instead of fighting it.

addParallaxGround

method source
Reactor3D.MapScene.prototype.addParallaxGround(bitmap, tileSize, index, opacity)

Adds the parallax ground.

addRoom

method source
Reactor3D.MapScene.prototype.addRoom(room, load, tileSize, width, height)

Build the room around a width x height tile map.

Details

Build the room around a width x height tile map.

load is the same loader the parallax grounds use; a bitmap still loading lays its piece down when it arrives, the way a parallax ground does.

addRoomPiece

method source
Reactor3D.MapScene.prototype.addRoomPiece(piece, bitmap, roomHeight, tileSize, width, height)

Adds the room piece.

setRoomCliff

method source
Reactor3D.MapScene.prototype.setRoomCliff(cliff, load)

The floor's cliff as { name, slope, tint } on a map already laid (the editor shows a change as it is made): the slope and the tint at once, another material when its image is in (load hands it over; without one, the scene's own loader).

Details

The floor's cliff as { name, slope, tint } on a map already laid (the editor shows a change as it is made): the slope and the tint at once, another material when its image is in (load hands it over; without one, the scene's own loader). False when this floor has no slopes that turn to rock.

addSky

method source
Reactor3D.MapScene.prototype.addSky(sky, load, tileSize)

Adds the sky.

addSkyImage

method source
Reactor3D.MapScene.prototype.addSkyImage(sky, bitmap, tileSize)

Adds the sky image.

setSkyOffset

method source
Reactor3D.MapScene.prototype.setSkyOffset(offset)

Sets the sky offset.

setPass

method source
Reactor3D.MapScene.prototype.setPass(which)

Show one pass and hide the other.

Details

Show one pass and hide the other.

"below" is the ground, "above" the star-flagged tiles, "all" both — which is what a single-pass caller (the editor's viewport) wants.

hideCrowdFromReflection

method source
Reactor3D.MapScene.prototype.hideCrowdFromReflection(hidden, position, keep = Reactor3D.REFLECTED_CHARACTERS)

Hides the crowd from reflection.

clear

method source
Reactor3D.MapScene.prototype.clear()

Clear.

destroy

method source
Reactor3D.MapScene.prototype.destroy()

Destroy.

Updating & Drawing

updateSky

method source
Reactor3D.MapScene.prototype.updateSky(camera, frame)

Each frame: the sky stands around the camera and drifts by the frames elapsed.

syncLights

method source
Reactor3D.MapScene.prototype.syncLights(focus)

Lay this frame's lights on the ground.

Details

Lay this frame's lights on the ground.

The ambient light is the only real one: it is the darkness everything is seen against, and being one light it costs the shader nothing. Everything else is geometry.

syncVolumeLights

method source
Reactor3D.MapScene.prototype.syncVolumeLights(declared, focus)

This frame's lights as a field: the nearest SHADER_LIGHTS to the focus written into the shared uniforms every lit material reads, and a glowing body stood at each source.

Details

This frame's lights as a field: the nearest SHADER_LIGHTS to the focus written into the shared uniforms every lit material reads, and a glowing body stood at each source. No pass, no quads, no buffer upload — three small arrays and a handful of transforms.

A light's world position is where the flat pool was centred (the middle across, the southern edge along, on the facade it hangs on) plus its authored height straight up — the one number the quads had to discard.

renderShadows

method source
Reactor3D.MapScene.prototype.renderShadows(renderer, mapData, options)

The frame's shadow maps, before the first pass draws: see Reactor3D.Shadows.

updateDestination

method source
Reactor3D.MapScene.prototype.updateDestination(temp, map, frame)

Updates the destination each frame.

Other

facadeAt

method source
Reactor3D.MapScene.prototype.facadeAt(x, y)

Where this scene stood a cell's art up, if it did.

Details

Where this scene stood a cell's art up, if it did.

See Reactor3D.facadeAt — this is the same answer for a scene held on its own rather than for the map the game is running.

report

method source
Reactor3D.MapScene.prototype.report()

What actually got built, for when the view comes up empty.

Details

What actually got built, for when the view comes up empty.

An empty 3D canvas has several causes that look identical on screen — no meshes, no textures, a camera pointing somewhere else — and none of them raise an error. The counts tell them apart in one line.

extent

method source
Reactor3D.MapScene.prototype.extent()

The world-space box the built geometry occupies.

Details

The world-space box the built geometry occupies.

Paired with the camera's position, this answers the only question an empty 3D view leaves open once the meshes are known to exist: whether the camera is anywhere near them.

groundPlane

method source
Reactor3D.MapScene.prototype.groundPlane(width, height, y)

A ground plane width x height tiles from the map's corner, lying in XZ at y: one quad on a flat map, a grid of tile-sized cells bent through the terrain on a shaped one (build sets _terrainMap first).

Details

A ground plane width x height tiles from the map's corner, lying in XZ at y: one quad on a flat map, a grid of tile-sized cells bent through the terrain on a shaped one (build sets _terrainMap first). Segments are capped so a giant parallax does not become a giant mesh.

skyOffset

method source
Reactor3D.MapScene.prototype.skyOffset()

Where the sky's drift has got to, and putting a new sky back there: the editor rebuilds the scene on an edit, and a sky that started over each time visibly jumped back while the map was being worked on.

belowGroup

method source
Reactor3D.MapScene.prototype.belowGroup()

The geometry drawn under the characters.

lightGroup

method source
Reactor3D.MapScene.prototype.lightGroup()

The light pools, drawn last and added to what is already there.

aboveGroup

method source
Reactor3D.MapScene.prototype.aboveGroup()

The geometry drawn over them — the star-flagged tiles.

scene

method source
Reactor3D.MapScene.prototype.scene()

Scene.

textureFor

method source
Reactor3D.MapScene.prototype.textureFor(bitmap, picture)

Wrap a loaded Bitmap as a texture.

Details

Wrap a loaded Bitmap as a texture.

Enlarged texels stay crisp. Minified texels are linearly sampled so narrow fractional-alpha shadows do not disappear into nearest-neighbour speckle; per-tile UV clamps keep that filter inside each atlas rectangle.

freezeStaticMeshes

method source
Reactor3D.MapScene.prototype.freezeStaticMeshes()

The world never moves once built: tiles, structures, and parallax grounds stay where the map put them.

Details

The world never moves once built: tiles, structures, and parallax grounds stay where the map put them. three recomposes every object's matrix every frame unless told the object is still; telling it saves that work for all of them, per frame, for the life of the map. Anything that does move (characters, billboards, lights) lives in other groups.

lightPool

method source
Reactor3D.MapScene.prototype.lightPool(kind)

One mesh holding every light of one shape.

Details

One mesh holding every light of one shape.

Buffers are allocated once at their largest and only the used part is drawn. Additive, because light adds; depth-tested so a wall hides the pool behind it, but not depth-written, so two overlapping pools do not punch holes in each other.

reflectionProbe

method source
Reactor3D.MapScene.prototype.reflectionProbe(camera)

Reflection probe.

mirrorHidden

method source
Reactor3D.MapScene.prototype.mirrorHidden(camera)

Mirror hidden.

mirrorSubject

method source
Reactor3D.MapScene.prototype.mirrorSubject()

The points a mirror tries to show: the player's feet, chest and head.

reflectionHolders

method source
Reactor3D.MapScene.prototype.reflectionHolders()

The models reflections look at: the map's own, then any a host keeps outside it (guestModels, the battle room's props and battlers).

reflectionSubject

method source
Reactor3D.MapScene.prototype.reflectionSubject()

Who a mirror shows first: the player's model, or the host's pick (guestSubject, the battle's lead actor).

mirrorCandidates

method source
Reactor3D.MapScene.prototype.mirrorCandidates(camera)

The mirror-finish models near the camera, nearest first (at most two), for Reactor3D.Mirrors.

reflectionHidden

method source
Reactor3D.MapScene.prototype.reflectionHidden()

Reflection hidden.

lightBodies

method source
Reactor3D.MapScene.prototype.lightBodies()

The glowing bodies of the lights: a soft sphere at a point light, the cone of a spotlight, and a bright core at either source.

Details

The glowing bodies of the lights: a soft sphere at a point light, the cone of a spotlight, and a bright core at either source. Additive, depth-tested and never depth-written, so a wall hides the lamp behind it and two glows pass through each other. Kept in the world's own pass, because they are things standing in the world.