new Render3DPlugin()render3d.js:561Create the global 3D renderer, call in gameInit
new Render3DPlugin;
render3D.camera.pos = vec3(0, 5, 10);
render3D.camera.lookAt(vec3());
new EngineObject3D(vec3(), buildBox());Render3D Plugin - The 3D renderer, camera, lights, shadows and fog
new Render3DPlugin()render3d.js:561Create the global 3D renderer, call in gameInit
new Render3DPlugin;
render3D.camera.pos = vec3(0, 5, 10);
render3D.camera.lookAt(vec3());
new EngineObject3D(vec3(), buildBox());additive : booleanrender3d.js:841Additive blending instead of alpha, in the transparent stage
ambientColor : Colorrender3d.js:591Ambient light color, from above when ambientGroundColor is set
ambientGroundColor : Color|undefinedrender3d.js:596Ambient light from below: set, the ambient blends from this on faces pointing down to ambientColor on faces pointing up, the way a sky and a ground light a scene; setSky sets both from its colors
anisotropy : numberrender3d.js:690Anisotropic filtering for textures seen at an angle, 1 to 16, 1 is off; needs mipmaps
attribValues : Array<Array<number>>render3d.js:803billboardMesh : Meshrender3d.js:706A square of size 1 facing +Z with the tile across it, the corners in the order drawBillboard writes them; a ParticleEmitter3D draws its particles as instances of it, each with its own matrix
blend : booleanrender3d.js:945Blending on, set by the stages
boxMesh : Meshrender3d.js:695A box of size 1 that drawBox uses, for any object that is a box; set the object's scale3D and color instead of editing the mesh, which would change every box that uses it
camera : Camera3Drender3d.js:581The camera
cameraDepthFramebuffer : WebGLFramebuffer|undefinedrender3d.js:777cameraDepthTexture : WebGLTexture|undefinedrender3d.js:775cameraForward : Vector3render3d.js:729Camera forward axis this frame
cameraRight : Vector3render3d.js:725Camera right axis this frame
cameraUp : Vector3render3d.js:727Camera up axis this frame
capture : Mesh|undefinedrender3d.js:814captureDepth : WebGLRenderbuffer|undefinedrender3d.js:757captureFramebuffer : WebGLFramebuffer|undefinedrender3d.js:755capturingCube : CubeMap|undefinedrender3d.js:753cubeCaptures : Set<CubeMap>render3d.js:751cullBackFaces : booleanrender3d.js:859Skip back faces, set by drawMesh from each mesh: off for strips so they show from both sides
currentProgram : WebGLProgram|undefinedrender3d.js:740depthTest : booleanrender3d.js:848Test against the depth buffer, reset to true before each object and callback; a draw with it off goes over what was drawn before it and under what is drawn after, by render order, which ends the batch of meshes before it, so one per object costs a draw per object
depthTexture : booleanrender3d.js:626Draw the camera's depth into a texture each frame for post processing: PostProcessPlugin hands it to its shader as iChannel2, read with sceneDepth(uv); off by default and free when off, on it draws the solid objects of the default layer once more, depth only
depthWrite : booleanrender3d.js:853Write to the depth buffer, owned by the stages: on for opaque, off for transparent
drawState : Render3DDrawStaterender3d.js:570emissive : numberrender3d.js:836How much a surface lights itself, set per object by its emissive
emissiveMap : TextureInfo|undefinedrender3d.js:897Emissive map for the next draws, set from each object's emissiveMap
emissiveMapColor : Colorrender3d.js:916Multiplies the emissive map, set from each object's emissiveMapColor; compared by its rgb, so a Color changed in place is seen when it is set again, and undefined is white
environment : CubeMap|undefinedrender3d.js:676The world around, what reflective surfaces reflect: an object's reflectivity says how much and its shininess how sharp, the same shininess that tightens its highlight: 10000 a mirror, 1000 polished, 10 a wide blur; undefined reflects the sky's colors as setSky gave them; a cube map holds GPU memory until its dispose(), so one made again and again, as for a sky that changes, disposes the one it replaces, or a captured one is captured into again
environmentMap : CubeMap|undefinedrender3d.js:902The cube map the next draws reflect in place of render3D.environment, set from each object's environment
fogColor : Color|undefinedrender3d.js:599Fog color, uses canvasClearColor when undefined
fogDepth : booleanrender3d.js:606Measure fog by depth along the view instead of distance from the camera, so fog is even across the screen like a classic depth fog; the fade below is measured the same way
fogEnd : numberrender3d.js:603Distance from the camera where fog is total, 0 disables fog
fogFadeEnd : numberrender3d.js:611Where see through draws are fully transparent, 0 turns the fade off; distant things melt into a sky or backdrop drawn behind them instead of into the fog color
fogFadeStart : numberrender3d.js:608Where see through draws start to fade to transparent, measured like the fog
fogStart : numberrender3d.js:601Distance from the camera where fog starts
frustumCulling : booleanrender3d.js:682Skip meshes whose bounding sphere is outside the view
frustumPlanes : Array<Array<number>>render3d.js:734gravity : Vector3render3d.js:614Added to the velocity3D of every object with a mass each frame, scaled by its gravityScale; sync2D objects use the 2D gravity
instanceBuffers : Array<WebGLBuffer>render3d.js:798instanceMeshes : Array<Mesh>render3d.js:801instancing : booleanrender3d.js:685Draw every use of a mesh in the opaque stage as one instanced call, mesh.instanced overrides it per mesh
isRendering : booleanrender3d.js:712True while the 3D pass is running, 3D draws are only valid then
lighting : booleanrender3d.js:831Apply lighting, when false draws plain vertex color times texture and casts no shadow; off for billboards, lines, ribbons and soft discs, an object sets emissive instead
mipmaps : booleanrender3d.js:688Sample textures through mipmaps so they do not shimmer in the distance, false uses each texture's own filtering like 2D
mirrored : booleanrender3d.js:865The transform mirrors the draw, so the other winding is the front, set by drawMesh from each transform
normalMap : TextureInfo|undefinedrender3d.js:882Normal map for the next draws, set from each object's normalMap
normalScale : numberrender3d.js:887How strongly the normal map bends the surface, set from each object's normalScale
onRenderOpaque : function|undefinedrender3d.js:658Draw solid world here, it runs again for shadows so only draw in it
onRenderTransparent : function|undefinedrender3d.js:661Draw see through things here, like glows, billboards and soft shadows
pixelated : booleanrender3d.js:940Keep texture pixels hard edged, no mipmaps and no blending between them, set per object by pixelated
planeMesh : Meshrender3d.js:700A flat square of size 1 facing +Y, seen from above only, for floors, water and decals; stand it up with the object's rotation3D, and size it with scale3D
planeMeshDoubleSided : Meshrender3d.js:703The same square seen and lit from both sides, for signs, cards and leaves
program : WebGLProgram|undefinedrender3d.js:738projectionMatrix : Matrix4render3d.js:718This frame's projection matrix
receiveShadow : booleanrender3d.js:934Darken by the shadow map when shadows are on, turn it off for things that should stay lit inside a shadow
reflectivity : numberrender3d.js:892How much the surface reflects the sky, 0 to 1, set from each object's reflectivity
renderAfter2D : booleanrender3d.js:678Draw the 3D scene on top of the 2D scene instead of under it
roundLighting : booleanrender3d.js:909Light the next billboards as if they bulge toward the camera like a ball, lit on the side toward each light, in place of the same all over; set from each object's roundLighting, a normal map overrides it
samplerKey : string|undefinedrender3d.js:768samplers : Map<number, WebGLSampler>render3d.js:766shader : Shader|undefinedrender3d.js:928Custom Shader for the next draws, set from each object's shader; undefined draws with the plugin's own
shadowBias : numberrender3d.js:651Stops surfaces shadowing themselves, raise for speckles, lower if shadows drift off; a share of the shadow map's depth, twice shadowRange for the sun and a spotlight's radius, so the gap behind a caster grows with the range as the map's texels do, and the speckles they make stay away
shadowCenter : Vector3|undefinedrender3d.js:647Center of the shadowed area, read each frame, undefined follows the camera
shadowFramebuffer : WebGLFramebuffer|undefinedrender3d.js:772shadowLight : Light3D|undefinedrender3d.js:640A spotlight, a Light3D with a coneAngle, to cast the shadows in place of the sun, a flashlight in the dark: the shadow map looks down its cone, as far as its radius, and the sun still lights the scene but casts none; undefined for the sun, as is a light that is off or has no cone
shadowMapSize : numberrender3d.js:635Size of the shadow map in pixels, bigger is sharper and slower
shadowMatrix : Matrix4render3d.js:722This frame's light view projection for the shadow map
shadowPass : booleanrender3d.js:714True while the shadow map is being drawn, draws go to the depth only shader
shadowPassMatrix : Matrix4render3d.js:747shadowPlanes : Array<Array<number>>render3d.js:736shadowProgram : WebGLProgram|undefinedrender3d.js:745shadowRange : numberrender3d.js:644World size the shadow map covers around shadowCenter, smaller is sharper; it is a square facing the light, so it turns as the light does, and about 1.5 times an area's width covers it from any angle
shadows : booleanrender3d.js:630Cast real shadows from the sun, off by default and free when off
shadowShader : WebGLProgram|undefinedrender3d.js:743shadowSoftness : numberrender3d.js:653How much to blur the shadow edges
shadowTexture : WebGLTexture|undefinedrender3d.js:770shininess : numberrender3d.js:877The highlight's exponent, how small and sharp it is: 4 is broad like rubber, 100 sharp like polished metal; set from each object's shininess
sky : Mesh|undefinedrender3d.js:664Sky dome from buildSky or setSky, drawn around the camera behind everything
skyBox : CubeMap|undefinedrender3d.js:669A cube map drawn as the sky, behind everything, in place of the sky dome; an orthographic camera looks the same way through every pixel, so it sees one color of it; fog fades to fogColor, not to the sky box, so with fog set fogColor to its horizon's color
skyBoxProgram : WebGLProgram|undefinedrender3d.js:760skyBoxVao : WebGLVertexArrayObject|undefinedrender3d.js:762smoothShading : booleanrender3d.js:621Default for every builder's smooth argument: true for smooth vertex normals, false for flat faces
softShadowHeight : number|HeightMap|functionrender3d.js:618Floor for objects with a softShadow: a height, a HeightMap, or (x, z) => y
sortTransparent : booleanrender3d.js:680Draw see through things far to near so they blend correctly
soundDefaultRange : numberrender3d.js:633How far a sound played with playSound is heard when it was made with no range of its own, in world units; further than the 2D soundDefaultRange, a 3D world is bigger
specular : numberrender3d.js:871Strength of the highlight where the sun and the Light3D objects reflect, 0 is none and 1 adds a light's full color at its brightest; shininess sets its size
sphereMesh : Meshrender3d.js:697A smooth sphere of diameter 1 that drawSphere uses, shared the same way as boxMesh
stateVersion : numberrender3d.js:576Goes up when a draw state field changes, so a batch sees at a glance that none did
streamBuffer : WebGLBuffer|undefinedrender3d.js:796streamState : Object|undefinedrender3d.js:811streamTileInfo : TextureInfo|undefinedrender3d.js:809sunColor : Colorrender3d.js:589Sunlight color
sunDirection : Vector3render3d.js:587Direction toward the sun, where its light comes from, like a directional Light3D; read at each draw, and any length will do, the shading and the shadows normalize it themselves; the sun is the one light that casts shadows
transparentQueue : Array<{distance: number, state: Object, draw: function(): void}>|undefinedrender3d.js:816uniforms : WeakMap<WebGLProgram, Object<string, (WebGLUniformLocation|null)>>render3d.js:783uniformValues : Object<string, Array<number>>render3d.js:785vao : WebGLVertexArrayObject|undefinedrender3d.js:749viewMatrix : Matrix4render3d.js:716This frame's view matrix
viewProjection : Matrix4render3d.js:720This frame's combined view projection
whiteTexture : WebGLTexture|undefinedrender3d.js:764bake(drawFunction) → Meshrender3d.js:1239Build a mesh once out of draw calls, instead of redrawing the shapes every frame
drawFunction functiondrawBillboard(pos, size, tileInfo, color, angle, upright) → voidrender3d.js:1462Draw a flat square that always faces the camera
pos Vector3Center
size Vector2 optionalWorld units
tileInfo TileInfo|TextureInfo optionalcolor Color optionalangle number optional, default 0Rotation in the camera plane, counter clockwise
upright boolean optional, default falseStand on world up and only turn to face the camera, for sprites on the ground
drawBox(pos, size, color, rotation)render3d.js:1434Draw a box, untextured, for blocking out a scene without meshes or objects
drawLine(posA, posB, width, color)render3d.js:1566Draw a line as a camera facing ribbon, unlit
drawMesh(mesh, matrix, tileInfo, color) → voidrender3d.js:1117Draw a mesh with the current draw state, batched with its other uses in the opaque stage when instancing is on
drawQuad(a, b, c, d, tileInfo, color)render3d.js:1538Draw a quad from four corners in loop order, counter clockwise seen from the front, a is the top left of the texture
drawRibbon(points, width, tileInfo, color, side)render3d.js:1580Draw a ribbon along a path, unlit and visible from both sides; width and color can change along it
points Array<Vector3>Center line in order, at least two
width number|Array<number> optional, default 0.1Full width, one for all or one per point
tileInfo TileInfo|TextureInfo optionalcolor Color|Array<Color> optionalOne for all or one per point
side Vector3|Array<Vector3> optionalDirection across the ribbon, one for all or one per point, default faces the camera
drawSky()render3d.js:1342Draw render3D.skyBox, or render3D.sky around the camera, unlit, unfogged and behind everything, called automatically by the pass
drawSoftDisc(pos, size, color, normal, sides) → voidrender3d.js:1620Draw a disc that fades to transparent at the rim, unlit, for glows, puffs and sky dots
drawSoftShadow(pos, size, floorHeight, color, lift) → voidrender3d.js:1645Draw a soft round shadow on the ground under something, much cheaper than a real shadow
pos Vector3Position of the thing casting the shadow
size number optional, default 1Diameter
floorHeight number|HeightMap|function optional, default 0Height of the ground, a HeightMap, or (x, z) => y to follow terrain
color Color optionallift number optional, default 0.02How far above the ground to draw, raise it if the shadow cuts into rough ground
drawSphere(pos, size, color)render3d.js:1443Draw a sphere, untextured and smooth shaded
drawStrip(points, normals, uvs, colors, tileInfo) → voidrender3d.js:1171Draw a triangle strip, batched into the stream with the current draw state
points Array<Vector3>In strip order
normals Vector3|Array<Vector3> optionalOne for all or one per point, default up
uvs Vector2|Array<Vector2> optionalOne for all or one per point, 0-1 across the tile
colors Color|Array<Color> optionalOne for all or one per point, vertex colors come before the texture
tileInfo TileInfo|TextureInfo optionalTexture for this strip
drawStripUnlit(points, normals, uvs, colors, tileInfo)render3d.js:1212Draw a strip with lighting off, for camera facing shapes where the light direction means nothing
drawTriangle(a, b, c, color)render3d.js:1554Draw a triangle, counter clockwise from outside is the front
flush()render3d.js:1216Draw the pending stream vertices as one strip with the state they were drawn under, called automatically when needed
flushTransparentQueue()render3d.js:1324Draw the queued transparent draws far to near with the state each was drawn under, called automatically at the end of the transparent stage
isSphereVisible(center, radius) → booleanrender3d.js:1106Is any part of a sphere on screen this frame, the test that skips meshes the camera cannot see
center Vector3radius numberpick(from, objects) → Object|undefinedrender3d.js:1044Find the nearest object under a screen position or along a ray, for clicking on things
from Vector2|Ray3DA screen position like mousePosScreen, or a ray to look along
objects Array<EngineObject> optionalDefaults to every object; only those with a mesh or a sprite count, and the height maps, voxel maps and mesh colliders, on their surfaces
playSound(sound, pos3D, volume, pitch, randomnessScale, loop, paused) → SoundInstance|undefinedrender3d.js:1068Play a sound at a 3D position, quieter with distance from the camera and panned by its side, like Sound.play with a 2D position; a sound made with no range of its own is heard to soundDefaultRange, 100, and one given a range keeps it
sound Soundpos3D Vector3volume number optional, default 1pitch number optional, default 1randomnessScale number optional, default 1How much to scale pitch randomness
loop boolean optional, default falsepaused boolean optional, default falseStart it paused
playSoundLoop(sound, pos3D, volume, pitch, randomnessScale) → SoundInstance|undefinedrender3d.js:1098Play a sound on a loop at a 3D position, the same as playSound with loop on
sound Soundpos3D Vector3volume number optional, default 1pitch number optional, default 1randomnessScale number optional, default 1How much to scale pitch randomness
queueTransparent(pos, draw) → voidrender3d.js:1309Queue a draw for the transparent stage, replayed far to near with the current draw state, or draw it now when sorting is off
pos Vector3Where the draw is, for sorting
draw functionrenderStages(objects, isDefault)render3d.js:1256Draw a layer's objects, solid ones first and see through ones after, called automatically
objects Array<EngineObject3D>isDefault boolean optional, default truescreenToGround(screenPos, groundHeight, canvasSize) → Vector3|undefinedrender3d.js:1029Where a screen position lands on a flat ground plane, for top down games; use HeightMap.raycast for terrain
screenPos Vector2Same space as mousePosScreen
groundHeight number optional, default 0World height of the ground plane
canvasSize Vector2 optionalDefaults to the main canvas size, as in screenToRay
screenToRay(screenPos, canvasSize) → Ray3Drender3d.js:1006Get the world ray under a screen position, for clicking on things in 3D
screenPos Vector2Same space as mousePosScreen
canvasSize Vector2 optionalDefaults to the main canvas size
setFog(fogStart, fogEnd, fogColor)render3d.js:1418Set where fog starts and ends, and its color
fogStart numberDistance from the camera where fog starts
fogEnd numberDistance where fog is total, 0 disables fog
fogColor Color optionalLeaves the color alone when not passed, setSky sets it to the horizon
setSky(topColor, horizonColor, bottomColor, ambient) → Meshrender3d.js:1404Build a sky dome, set it as the sky, and light the scene by it: the fog takes the horizon color, and the ambient light comes from the top color above and the bottom color below, both at the ambient strength
topColor Color optionalStraight up
horizonColor Color optionalLevel with the camera
bottomColor Color optionalStraight down, defaults to the horizon color
ambient number optional, default 0.5How much of the sky colors lights the scene as ambient, 0 for none
updateMatrices(aspect)render3d.js:953Rebuild the view and projection matrices from the camera, called automatically each frame
aspect number optionalWidth over height, defaults to the main canvas
updateShadowMatrix()render3d.js:1358Rebuild the light's view projection around the shadow center, called automatically each frame shadows are on
worldToClip(pos) → Vector3|undefinedrender3d.js:974Where a world point lands on screen as -1 to 1 across and up, with z as depth
pos Vector3worldToScreen(pos, canvasSize) → Vector2|undefinedrender3d.js:992Project a world point to screen space pixels, same space as mousePosScreen
pos Vector3canvasSize Vector2 optionalDefaults to the main canvas size, as in screenToRay; the projection is whatever updateMatrices last built, which screenToRay does for its canvas