Namespace in reactor_3d.js
Reactor3D.Viewport
33 public functions in 5 groups · show internal (_) functions
Quick Reference
Setup & Creation 2
| initialize() | Two ways to get the 3D picture into the game. |
| createTarget() | A render target PIXI can sample as if it were an uploaded canvas. |
Checks (True / False) 1
| isShared() | Whether it is shared. |
Actions 5
| setRenderScale() | Change the pass resolution; the targets and their sprites rebuild. |
| setScene() | Sets the scene. |
| releaseSlot() | A slot's targets and the textures that show them, let go two refreshes from now (a sprite may draw them once… |
| runOwedWork() | Work an earlier update left for spare refreshes, done now (a new update came first, or the view is torn down). |
| setVisible() | Sets the visible. |
Updating & Drawing 6
| renderInto() | Render into. |
| renderer() | The three.js renderer, for anything that has to upload a texture on the spot. |
| render() | scene and camera: a guest's (a battle room on this view's context, renderGuest), drawn into slot as the map's… |
| renderGuest() | A scene that is not the map's (a battle room's), from its own camera, through the map's pipeline: the view's… |
| renderPass() | Draw one pass on its own, over a cleared canvas. |
| drawnAt() | The update (Graphics.frameCount) a pass's target was last drawn on; undefined when never. |
Other 19
| scale() | The resolution the passes render at, relative to the screen. |
| targetSize() | Target pixel size for the passes at the current scale. |
| upscaled() | Whether the passes are drawn smaller and enlarged by the sharpening upscale (Reactor3D.SharpUpscale). |
| passPixelRatio() | Backing pixels per game pixel the passes draw at: the canvas's, capped by maxPassPixelRatio. |
| passEnlarged() | Whether the passes are drawn smaller than the canvas and enlarged into it. |
| generation() | Bumps whenever the pass textures are replaced (a resize); sprites holding an older one rebuild. |
| pixi() | Pixi. |
| targetHandle() | The GL texture three renders target into, once it has been allocated. |
| passTexture() | The PIXI texture that shows one pass. |
| passSprite() | What PIXI shows one pass with: a sprite of its target, or, for a pass drawn smaller and enlarged (upscaled),… |
| enlargedInComposite() | Whether slot's small target is enlarged by PIXI's composite, so its draw stops there. |
| resize() | Match the game canvas's backing size and on-screen placement. |
| scene() | Scene. |
| camera() | Camera. |
| probe() | What is actually on the 3D canvas, and where that canvas actually is. |
| shadowsFollowRefresh() | Shadows follow refresh. |
| spreadsUpdateWork() | Spreads update work. |
| detachFromPage() | Stop showing the 3D canvas on its own and let PIXI draw it instead. |
| canvas() | The canvas the 3D pass draws on, for diagnostics. |
Setup & Creation
initialize
method sourceReactor3D.Viewport.prototype.initialize()
Two ways to get the 3D picture into the game.
Details
Two ways to get the 3D picture into the game.
Shared context (the default): three renders with PIXI's own WebGL context into render targets, and PIXI samples those textures directly. Nothing is copied and nothing is uploaded; a frame costs the draws and no more.
Canvas copy (the fallback, and the old way): three owns a second canvas,
and every pass is copied through a 2D canvas and uploaded to PIXI as a
full-screen texture, up to three times a frame. It stays for PIXI builds
without a WebGL2 context, and as a kill switch: ?r3dcopy on the URL or
Reactor3D.useSharedContext = false before the first map.
createTarget
method sourceReactor3D.Viewport.prototype.createTarget(width, height, scale, options)
A render target PIXI can sample as if it were an uploaded canvas.
Checks (True / False)
Actions
setRenderScale
method sourceReactor3D.Viewport.prototype.setRenderScale(scale)
Change the pass resolution; the targets and their sprites rebuild.
setScene
method sourceReactor3D.Viewport.prototype.setScene(scene, camera)
Sets the scene.
releaseSlot
method sourceReactor3D.Viewport.prototype.releaseSlot(slot)
A slot's targets and the textures that show them, let go two refreshes from now (a sprite may draw them once more).
runOwedWork
method sourceReactor3D.Viewport.prototype.runOwedWork(mapScene)
Work an earlier update left for spare refreshes, done now (a new update came first, or the view is torn down).
setVisible
method sourceReactor3D.Viewport.prototype.setVisible(visible)
Sets the visible.
Updating & Drawing
renderInto
method sourceReactor3D.Viewport.prototype.renderInto(target, scene, camera)
Render into.
renderer
method sourceReactor3D.Viewport.prototype.renderer()
The three.js renderer, for anything that has to upload a texture on the spot.
render
method sourceReactor3D.Viewport.prototype.render(slot, scene = this._scene, camera = this._camera)
scene and camera: a guest's (a battle room on this view's context, renderGuest), drawn into slot as the map's own scene is: at the view's scale, enlarged and sharpened, its frames counted for the scale's controller.
Details
scene and camera: a guest's (a battle room on this view's context, renderGuest), drawn into slot as the
map's own scene is: at the view's scale, enlarged and sharpened, its frames counted for the scale's controller.
renderGuest
method sourceReactor3D.Viewport.prototype.renderGuest(scene, camera)
A scene that is not the map's (a battle room's), from its own camera, through the map's pipeline: the view's work target at its scale (Auto quality's level), the sharpening enlargement, the colour draw's culling, detail levels and shader warm-up (renderInto, Reactor3D.renderScene), the texture bias, and the frame counted for the scale's controller.
Details
A scene that is not the map's (a battle room's), from its own camera, through the map's pipeline: the view's
work target at its scale (Auto quality's level), the sharpening enlargement, the colour draw's culling, detail
levels and shader warm-up (renderInto, Reactor3D.renderScene), the texture bias, and the frame counted for
the scale's controller. Only on the shared context. The guest shows passSprite(Reactor3D.GUEST_SLOT), made
again when generation() changes, and lets the slot go when it is done (releaseSlot). The guest's shadow
rows and reflections are its own to prepare first (Reactor3D.prepareWorldFrame).
renderPass
method sourceReactor3D.Viewport.prototype.renderPass(mapScene, which, slot)
Draw one pass on its own, over a cleared canvas.
Details
Draw one pass on its own, over a cleared canvas.
The two passes sandwich the character sprites: the ground goes down, PIXI draws the characters, and then the star-flagged tiles go over them. Both come off the same canvas, one after the other, so this costs a second draw and a second upload rather than a second WebGL context.
drawnAt
method sourceReactor3D.Viewport.prototype.drawnAt(slot)
The update (Graphics.frameCount) a pass's target was last drawn on; undefined when never.
Other
scale
method sourceReactor3D.Viewport.prototype.scale()
The resolution the passes render at, relative to the screen.
targetSize
method sourceReactor3D.Viewport.prototype.targetSize(scale = this._scale)
Target pixel size for the passes at the current scale.
Details
Target pixel size for the passes at the current scale. The canvas pixel ratio rides along so an enlarged game (fullscreen) renders its 3D at the pixels actually on screen instead of upscaling a game-sized pass.
upscaled
method sourceReactor3D.Viewport.prototype.upscaled()
Whether the passes are drawn smaller and enlarged by the sharpening upscale (Reactor3D.SharpUpscale).
passPixelRatio
method sourceReactor3D.Viewport.prototype.passPixelRatio()
Backing pixels per game pixel the passes draw at: the canvas's, capped by maxPassPixelRatio.
Details
Backing pixels per game pixel the passes draw at: the canvas's, capped
by maxPassPixelRatio. The cap holds at every enlargement, whole-number
or not: at 1.5x nearest-neighbour doubles every other pixel, and the
owner judged that sharper and better on a model than any smoothed
enlargement - "just like resizing an image in Photoshop".
passEnlarged
method sourceReactor3D.Viewport.prototype.passEnlarged()
Whether the passes are drawn smaller than the canvas and enlarged into it.
generation
method sourceReactor3D.Viewport.prototype.generation()
Bumps whenever the pass textures are replaced (a resize); sprites holding an older one rebuild.
pixi
method sourceReactor3D.Viewport.prototype.pixi()
Pixi.
targetHandle
method sourceReactor3D.Viewport.prototype.targetHandle(target)
The GL texture three renders target into, once it has been allocated.
passTexture
method sourceReactor3D.Viewport.prototype.passTexture(slot)
The PIXI texture that shows one pass.
Details
The PIXI texture that shows one pass. PIXI's texture system is handed the GL texture three renders into; it binds it like any other and never uploads to it. Flipped vertically: a framebuffer's first row is its bottom.
passSprite
method sourceReactor3D.Viewport.prototype.passSprite(slot)
What PIXI shows one pass with: a sprite of its target, or, for a pass drawn smaller and enlarged (upscaled), the small target itself drawn through the sharpening filter as PIXI composites it (SharpUpscale.mesh): the full-size target, written and read again every frame, is not made.
Details
What PIXI shows one pass with: a sprite of its target, or, for a pass
drawn smaller and enlarged (upscaled), the small target itself drawn
through the sharpening filter as PIXI composites it (SharpUpscale.mesh):
the full-size target, written and read again every frame, is not made.
Not on a canvas enlarged past the passes' pixel ratio (passEnlarged):
there the full-size target is itself enlarged, and the filter must run
at its pixels. The way a slot is shown is fixed for the generation its
object was made in (_shownWith), so SharpUpscale.inComposite takes
effect at the next rebuild of the passes (a resize, a new scale).
enlargedInComposite
method sourceReactor3D.Viewport.prototype.enlargedInComposite(slot)
Whether slot's small target is enlarged by PIXI's composite, so its draw stops there.
resize
method sourceReactor3D.Viewport.prototype.resize()
Match the game canvas's backing size and on-screen placement.
scene
method sourceReactor3D.Viewport.prototype.scene()
Scene.
camera
method sourceReactor3D.Viewport.prototype.camera()
Camera.
probe
method sourceReactor3D.Viewport.prototype.probe()
What is actually on the 3D canvas, and where that canvas actually is.
Details
What is actually on the 3D canvas, and where that canvas actually is.
An empty 3D view has survived every check that can be made from the outside — meshes, textures, camera, canvas size, visibility — so this reads the drawing buffer itself. Non-black pixels mean three is drawing and the problem is compositing; all black means it is not, whatever the scene says.
shadowsFollowRefresh
method sourceReactor3D.Viewport.prototype.shadowsFollowRefresh()
Shadows follow refresh.
spreadsUpdateWork
method sourceReactor3D.Viewport.prototype.spreadsUpdateWork()
Spreads update work.
detachFromPage
method sourceReactor3D.Viewport.prototype.detachFromPage()
Stop showing the 3D canvas on its own and let PIXI draw it instead.
Details
Stop showing the 3D canvas on its own and let PIXI draw it instead.
Stacked canvases put the 3D ground outside the PIXI scene, and everything a game draws over the map assumes the map is in that scene: a fog or a lighting overlay set to MULTIPLY has nothing to multiply against, so it composites as a flat wash — which is why fog reads heavier in 3D than in 2D — and the screen tone, which is a filter on the spriteset, never reaches the ground at all.
Rendering is unaffected by the canvas being hidden: a WebGL context draws into its buffer whether or not the element is laid out.
canvas
method sourceReactor3D.Viewport.prototype.canvas()
The canvas the 3D pass draws on, for diagnostics.