Urbject

Home

An Urbject is an object that can be added to a Scene. There are many sub-classes of an Urbject such as MeshUrbject, AmbientLight, DirectionalLight, PointLight, and Camera. The base Urbject class holds positional and classification data, and on its own can be used as a "parent" object to contain children Urbjects and transform them locally to itself.

See also: Scene, MeshUrbject, AmbientLight, DirectionalLight, PointLight, Camera

Urbjects are named after Urchin to avoid confusion with the basic JavaScript "Object".

Constructors

Urbject( ): Urbject Creates an Urbject with default attributes.
Urbject( { type?: number, position?: Vector, orientation?: Quaternion, scale?: number | Vector, state?: number, group?: number, superCopy?: Urbject } ): Urbject Creates an Urbject with the given values. The default values are:

type Urbject.PARENT Specifies the type of Urbject. Note: If you need to construct a sub-type of the Urbject class, it is best to use the constructor of the sub-type rather than setting this value.

See also: MeshUrbject, AmbientLight, DirectionalLight, PointLight, Camera
position new Vector() The position of the Urbject in 3D space. See also: Vector
orientation new Quaternion() The orientation of the Urbject in 3D space. See also: Quaternion
scale 1 The scale of the Urbject in 3D space. If a vector is provided, each individual axis will be multiplied by the corresponding component of the vector.
state Urbject.DYNAMIC The state of the Urbject used to determine the way the FrameInstance for the Urbject is calculated. See also: FrameInstance
group 0 The render group that the Urbject is a part of. Smaller group numbers are rendered first. Note: The minimum group that can be assigned is -100, and the maximum is equal to 232 - 101.
superCopy undefined A Urbject to copy values from. This is used by sub-classes of Urbject to copy data to a new sub-class.

Constants

Urbject Types

Urbject.PARENT = 0 A non-explicit value used to classify an Urbject as a standard Urbject.
Urbject.MESH_URBJECT = 1 A non-explicit value used to classify an Urbject as a MeshUrbject. See also: MeshUrbject
Urbject.AMBIENT_LIGHT = 2 A non-explicit value used to classify an Urbject as an AmbientLight. See also: AmbientLight
Urbject.DIRECTIONAL_LIGHT = 3 A non-explicit value used to classify an Urbject as a DirectionalLight. See also: DirectionalLight
Urbject.SPOT_LIGHT = 4 A non-explicit value used to classify an Urbject as a PointLight. See also: PointLight
Urbject.CAMERA = 5 A non-explicit value used to classify an Urbject as a Camera. See also: Camera

Urbject States

Urbject.DYNAMIC = 100 A non-explicit value used to classify the state of the Urbject as Dynamic. A Dynamic Urbject will assume that it has moved or changed visual properties in some way since the last frame render. This is the default state of all Urbjects.
Urbject.STATIC = 101 A non-explicit value used to classify the state of the Urbject as Static. A Static Urbject will assume that it and any of its children have NOT moved or changed visual properties in any way since the last frame render. When a FrameInstance is calculated, this object's FrameInstance will be pulled from the instanceCache if it exists, or calculated and then stored in the instanceCache if it does not exist. See also: FrameInstance
Urbject.BILLBOARD = 102 A non-explicit value used to classify the state of the Urbject as a Billboard. A Billboard Urbject will always rotate so that its default orientation faces the camera. i.e. The local X-Axis of the Urbject will rotate to point towards the camera.
Urbject.Z_BILLBOARD = 103 A non-explicit value used to classify the state of the Urbject as a Billboard about the Z-Axis. A Z-Billboard Urbject will always rotate so that its default orientation rotates around the Z-Axis to face the camera.
Urbject.X_BILLBOARD = 104 A non-explicit value used to classify the state of the Urbject as a Billboard about the X-Axis. A X-Billboard Urbject will always rotate so that its default orientation rotates around the X-Axis to face the camera.
Urbject.Y_BILLBOARD = 105 A non-explicit value used to classify the state of the Urbject as a Billboard about the Y-Axis. A Y-Billboard Urbject will always rotate so that its default orientation rotates around the Y-Axis to face the camera.

Other

Urbject.DEFAULT_GROUP = 100 The translation that is added to a group number of an Urbject when calculating its position in the render queue. This allows all Urbjects to be positioned at group 0, and there can be up to 100 groups that come before group 0.

Variables

Public Variables

children: Array<Urbject> An Array of Urbjects that are positioned relatively to this Urbject.
group: number The render group that the Urbject is a part of. Smaller group numbers are rendered first. Note: The minimum group that can be assigned is -100, and the maximum is equal to 232 - 101.
orientation: Quaternion The orientation of the Urbject in 3D space. See also: Quaternion
parent: Urbject This Urbject's parent Urbject. If this Urbject does not have a parent, then it is undefined.
position: Vector The position of the Urbject in 3D space. See also: Vector
scaleVector: Vector The scale of the Urbject in 3D space. See also: Vector
state: number The state of the Urbject used to determine the way the FrameInstance for the Urbject is calculated. Must be one of the Urbject states listed above under "Constants".See also: FrameInstance
type: number The type of the Urbject. Must be one of the Urbject types listed above under "Constants".

Protected Variables

protected instanceCache: FrameInstance A protected variable that stores the FrameInstance for Static Urbjects. See also: FrameInstance

Functions

Public Functions

addChild(c: Urbject): Urbject Sets this Urbject as the given Urbject's parent and adds it as a child. If the child had a previous parent, it is removed as a child from that parent.
applyTransform(transform: Urbject): Urbject Converts this Urbject's relative positional data to absolute positional data in the domain of the given transformation Urbject. For example, if an Urbject that is located 1 unit down the X-Axis is applied a transform that has a scale of 2 on the X-axis, then the Urbject will now be located 2 units down the X-Axis.
copy(options?: { shallow: boolean }): Urbject Returns a copy of the Urbject. If shallow is true, then a "shallow" copy of the Urbject will be returned without any children. shallow is false by default.
getInstance(camera: Camera): FrameInstance Returns the FrameInstance for this Urbject and its children. See also: FrameInstance
getWorldTransform(): Urbject Returns a "shallow" copy of the Urbject with its absolute position, orientation, and scale in the scene. See the implementation of copy() for more information on a "shallow" copy.
removeChild(c: Urbject): Urbject Attempts to remove the given Urbject as a child from this Urbject and return it if found. If the child does not exist, null is returned.
scale(a: number | Vector): Urbject Multiplies this Urbject's scale by the given number or vector. Returns this. See also: Vector
setScale(a: number | Vector): Urbject Sets this Urbject's scale to the given vector or a new vector with all components equal to the number given. Returns this. See also: Vector
translate(v: Vector): Urbject Adds the given vector to this Urbject's position. Returns this. See also: Vector

Static Functions

Urbject.addChild(u: Urbject, c: Urbject): Urbject Returns a copy of the first Urbject with the second Urbject added as a child.
Urbject.applyTransform(target: Urbject, transform: Urbject): Urbject Returns a copy of the target Urbject with the transform Urbject applied.
Urbject.copy(u: Urbject, options?: { typeCheck?: boolean, shallow?: boolean } ): Urbject Returns a copy of the given Urbject or makes a new Urbject from an Object that contains all public Urbject attributes. typeCheck is true by default and determines whether the type of the Urbject will be considered when copied. shallow is false by default and, if true, will prevent the Urbject's children from being copied as well.
Urbject.getInstance(u: Urbject, camera: Camera): FrameInstance Returns the FrameInstance for the given Urbject and its children. See also: FrameInstance
Urbject.getWorldTransform(u: Urbject): Urbject Returns a "shallow" copy of the Urbject with its absolute position, orientation, and scale in the scene. See the implementation of copy() for more information on a "shallow" copy.
Urbject.removeChild(u: Urbject, c: Urbject): Urbject Returns a copy of the first Urbject with the second Urbject removed as a child.
Urbject.scale(u: Urbject, a: number | Vector): Urbject Returns a copy of the given Urbject, scaled by the given number or vector. See also: Vector
Urbject.setScale(u: Urbject, a: number | Vector): Urbject Returns a copy of the given Urbject with the scale set to the given vector or a new vector with all components equal to the number given. See also: Vector
Urbject.transform(u: Urbject, v: Vector): Urbject Returns a copy of the given Urbject transformed by the given vector. See also: Vector

Home

Copyright © 2020 Trevor Richard