Module: GrWorld

CS559 3D World Framework Code

GrWorld - bascially a wrapper around scene, except that it uses GrObject instead of Object3D (GrObjects have Object3D)

To make things simple, this keeps a renderer and a default camera. Of course, that might complicate things if you want to have multiple renderers and cameras

Basically, this keeps some of the basic stuff you need when you use three.

Source:

Classes

GrWorld

Type Definitions

GrWorldAutoUIOptions

AutoUI policy defaults for a world.

Properties:
Name Type Attributes Default Description
where Object <optional>

default container for object/world UI for this world

width number <optional>
300

default panel width

widthdiv number <optional>
1

panel width subdivision

adjusted boolean <optional>
false

slider label adjustment setting

useLilGUI boolean <optional>
true

true for lil-gui controls, false for div/slider controls

labelDisplay string <optional>
"inline-block"

CSS display style for slider labels in div mode

guiPlacement "where" | "floating" | "canvas-overlay" <optional>
"canvas-overlay"

lil-gui placement strategy

canvas-overlay anchors lil-gui to the renderer's containing element. This is intentionally container-relative (not always strict canvas-pixel-relative). For layouts where a container holds multiple canvases (for example side-by-side views), the panel appears at that container's top-right corner for each world. If strict per-canvas overlay is desired, place each world canvas in its own dedicated container (or set where accordingly).

Source:

GrWorldProperties

Document the parameters for making a world - all are optional we'll guess at something if you don't give it to us

Properties:
Name Type Attributes Default Description
camera <optional>

use this camera if passed

fov <optional>

camera property if we make one

near <optional>

camera property if we make one

far <optional>

camera property if we make one

renderer <optional>

if you don't give one, we'll make it

renderparams <optional>

parameters for making the renderer

width <optional>

canvas size

height <optional>

canvas size

where <optional>

where in the DOM to insert things

id <optional>

id to put on the canvas (if we make it)

lights <optional>

a list of lights, or else default ones are made

lightBrightness <optional>
.75

brightness of the default lights

lightColoring <optional>
"cool-to-warm"

either "c"ool-to-warm, "w"hite, or e"x"treme

sideLightColors <optional>

to make extreme lighting

ambient <optional>
.5

brightness of the ambient light in default light

groundplane <optional>

can be a groundplane, or False (otherwise, one gets made)

groundplanecolor <optional>
"green"

if we create a ground plane, what color

groundplanesize <optional>
5

if we create a ground plane, how big

lookfrom <optional>

where to put the camera (only if we make the camera)

lookat <optional>

where to have the camera looking (only if we make the camera)

background <optional>
"black"

color to set the background

runbutton Object <optional>

a checkbox-like object to switch things on or off

speedcontrol Object <optional>

a slider-like object to get the speed

Source:

WorldCallbacks

callback list - used in 2 places, so document once

Type:
  • Object
Properties:
Name Type Attributes Description
prefirst function <optional>

called before the first loop go around

prestep function <optional>

called before the step (even if there is no step)

stepWorld function <optional>

called after the step (only if there is a step)

predraw function <optional>

called before drawing (after the step - if there is one)

postdraw function <optional>

called after drawing

first function <optional>

called after the end of the first loop go-around

Source: