Class: GrObject

GrObject.GrObject(name, objectOrObjects, paramInfoopt)

GrObject

GrObjects have:

  • a name - each object should have a unique name (like an id), but this is not enforced
  • parameters (these are things that the user may want to control with sliders)
  • geometry / "Object3D" - they kind of serve like three's groups note: animation should not update the parameters

any new object should provide methods for:

  • construction - the constructor needs to call the base class constructor and provide the parameters and geometry
  • update - which takes an array of parameters and sets things accordingly
  • stepWorld - which moves the animation ahead a small amount

and optionally

  • lookfrom/lookat

Note that a GrObject does not add itself to the scene (other things take care of that). When the object is added to the world, it's THREE objects are added to the Scene (the THREE world container).

Constructor

new GrObject(name, objectOrObjects, paramInfoopt)

The parameter list (if provided) should be either a string (with the name of the parameter) or an Array with the first value being a string (the name), and the remaining 4 values being numbers: min, max, initial value, and step size (all optional).

Parameters:
Name Type Attributes Description
name String

unique name for the object

objectOrObjects THREE.Object3D | Array.<THREE.Object3D>
paramInfo Array.<(string|Array)> <optional>

a list of the parameters for the object

Source:
See:
  • paramObjFromParam

Members

highlighted :Boolean

Type:
  • Boolean
Source:

id :Number

Type:
  • Number
Source:

name :String

Type:
  • String
Source:

objects :Array.<THREE.Object3D>

Type:
  • Array.<THREE.Object3D>
Source:

params :Array.<Object>

Type:
  • Array.<Object>
Source:

rideable :THREE.Object3D|undefined

Type:
  • THREE.Object3D | undefined
Source:

Methods

lookFromLookAt() → {Array.<Number>}

return a plausible lookfrom/lookat pair to look at this object this makes a guess based on the bounding box, but an object may want to override to give a better view

Returns an array of 6 numbers (lookfrom X,Y,Z, lookat X, Y, Z)

Source:
Returns:
Type
Array.<Number>

setPos(x, y, z)

set the position of each (root level) object

Parameters:
Name Type Default Description
x number 0
y number 0
z number 0
Source:

setScale(scale, sy, sz)

helper method - set the scale of the objects note: this sets the scale of all the root level objects it doesn't consider what was already there also, it is only a uniform method

Parameters:
Name Type Default Description
scale number 1.0
sy number 0
sz number 0
Source:

stepWorld(delta, timeOfDay)

Advance the object by an amount of time. Time only flows forward so use this to figure out how fast things should move. In theory, it is always a "step" (1/60th of a second) In the past, so many things were stochastic and only computed the delta, that this became the norm (if you need to accumulate time you can sum the delta) time of day is provided so you can make objects that change over the course of the day - it is a number between 0-24 (midnight->midnight) it does not necessarily change smoothly. Delta is intended to be in "milliseconds" - but it is scaled by the current "speed" (and will be zero if time is stopped).

Parameters:
Name Type Description
delta number
timeOfDay number
Source:

update(paramValues)

set the parameter values to new values this gets called when the sliders are moved

Parameters:
Name Type Description
paramValues Array.<Number>
Source: