Class: GrWorld

GrWorld.GrWorld(priv, params)

GrWorld

The GrWorld is basically a wrapper around THREE.js's scene, except that it keeps a list of GrObject rather than Object3D.

It contains a scene (and it puts things into it for you). It also contains a renderer and a camera.

When this creates a renderer, it places it into the dom (see the where option).

By default, the world is created with a reasonable default renderer, camera and groundplane. Orbit controls are installed.

Constructor

new GrWorld(priv, params)

Constructs an empty world.

This constructor function is private and should not be used directly. Instead, use await GrWorld.new() within an async context.

Parameters:
Name Type Description
priv Symbol

Private constructor symbol to ensure this constructor is not constructed outside the constructor new function.

params GrWorldProperties
Source:

Members

active_object :GrObject

Type:
  • GrObject
Source:

animCount :Number

Type:
  • Number
Source:

autoUIGUI :Object|undefined

Type:
  • Object | undefined
Source:

autoUIOptions :GrWorldAutoUIOptions

Type:
  • GrWorldAutoUIOptions
Source:

camera :T.PerspectiveCamera

Type:
  • T.PerspectiveCamera
Source:

chkSolo :HTMLInputElement|undefined

Type:
  • HTMLInputElement | undefined
Source:

gui :any

Type:
  • any
Source:

objCount :Number

Type:
  • Number
Source:

objNames :Object

Type:
  • Object
Source:

objects :Array.<GrObject>

Type:
  • Array.<GrObject>
Source:

renderer :T.WebGLRenderer|WebGPURenderer

Type:
  • T.WebGLRenderer | WebGPURenderer
Source:

runbutton :Object|undefined

Type:
  • Object | undefined
Source:

selectLook :HTMLSelectElement|undefined

Type:
  • HTMLSelectElement | undefined
Source:

selectRideable :HTMLSelectElement|undefined

Type:
  • HTMLSelectElement | undefined
Source:

selectViewMode :HTMLSelectElement|undefined

Type:
  • HTMLSelectElement | undefined
Source:

speedcontrol :Object|undefined

Type:
  • Object | undefined
Source:

Methods

add(grobj)

Add an object to the world - this takes care of putting everything into the scene, as well as assigning IDs

Parameters:
Name Type Description
grobj GrObject
Source:

animate(callbacksopt)

perform a cycle of the animation loop - this measures the time since the last redraw and advances that much before redrawing

because draw is part of animate, the callbacks are handled here

Parameters:
Name Type Attributes Description
callbacks WorldCallbacks <optional>
Source:

draw()

draw the default camera to the default renderer

Source:

enableVR()

adds VR capability

Source:

getAutoUIOptions() → {GrWorldAutoUIOptions}

Get the AutoUI defaults for this world.

Source:
Returns:
Type
GrWorldAutoUIOptions

go(callbacks)

start an (endless) animation loop - this just keeps going

Parameters:
Name Type Description
callbacks WorldCallbacks
Source:

setAutoUIOptions(options)

Set defaults for AutoUI controls in this world.

Parameters:
Name Type Description
options GrWorldAutoUIOptions
Source:

stepWorld()

advance all of the objects

Source:

viewStats()

adds performance stats to the DOM

Source:

(async, static) new(params) → {Promise.<GrWorld>}

Consructor function to consruct a await GrWorld.new.

This function is async and therefore must be awaited if code after it depends on the new GrWorld.

Example Use

const world = await GrWorld.new();
Parameters:
Name Type Description
params GrWorldProperties

The parameters for constructing the GrWorld.

Source:
Returns:

Returns a await GrWorld.new depending on the params.

Type
Promise.<GrWorld>