AmmoComponent extends Component

goo/addons/ammopack/AmmoComponent (requires ammopack.js)
Adds Ammo physics to a Goo entity. Ammo is a powerful physics engine converted from the C language project Bullet. Use Ammo.js if you need to support any 3D shape (trimesh). Also see AmmoSystem.
Example: Working example
var entity = world.createEntity(new Box(20, 10, 1));
entity.setComponent(new AmmoComponent({ mass: 5 }));
Deprecated as of v0.11.x and scheduled for removal in v0.13.0; consider using the Cannon system/component instead.
new
AmmoComponent
(settings)
settings :: Object optional The settings object can contain the following properties:
settings.mass :: number optional default = 0 (0 means immovable)
settings.useBounds :: boolean optional default = false use the model bounds or use the real (must-be-convex) vertices
settings.useWorldBounds :: boolean optional default = false use the model world bounds or use the real (must-be-convex) vertices (this setting is experimental)
settings.useWorldTransform :: boolean optional default = false use the model world transform instead of local (this setting is experimental)
settings.showBounds :: boolean optional default = false show the model world bounding box (this setting is experimental)

Instance methods

getAmmoShapefromGooShape(entitygooTransform)
initialize(entity)
showBounds(entity)

AmmoSystem extends System

goo/addons/ammopack/AmmoSystem (requires ammopack.js)
Handles integration with Ammo.js. Depends on the global Ammo object, so load ammo.small.js using a script tag before using this system. Direct access to the ammoWorld is available like this: myAmmoSystem.ammoWorld See also AmmoComponent
var ammoSystem = new AmmoSystem({stepFrequency: 60});
goo.world.setSystem(ammoSystem);
Deprecated as of v0.11.x and scheduled for removal in v0.13.0; consider using the Cannon system/component instead.
new
AmmoSystem
(settings)
settings :: Object The settings object can contain the following properties:
settings.gravity :: number (defaults to -9.81)
settings.maxSubSteps :: number (defaults to 5)
settings.stepFrequency :: number (defaults to 60)

Instance methods

inserted(entity)
deleted(entity)
process(entitiestpf)

Box2DComponent extends Component

goo/addons/box2dpack/components/Box2DComponent (requires box2dpack.js)
Box2DComponent
Example: Working example
new
Box2DComponent
()

Box2DSystem extends System

goo/addons/box2dpack/systems/Box2DSystem (requires box2dpack.js)
Physics simulation using Box2D. Depends on the global Box2D object. Load box2d.js using a <script> tag before using this system
Example: Working example
new
Box2DSystem
()

Instance methods

inserted(entity)
deleted(entity)
process(entitiestpf)

CannonBoxColliderComponent extends Component

goo/addons/cannonpack/CannonBoxColliderComponent (requires cannonpack.js)
Physics box collider for Cannon.js. To be attached to an entity with a CannonRigidbodyComponent. Also see the CannonSystem.
Example: Working example
new
CannonBoxColliderComponent
(settings)
settings :: Object optional
settings.halfExtents :: Vector3 optional The half-extents of the box collider.

CannonCylinderColliderComponent

goo/addons/cannonpack/CannonCylinderColliderComponent (requires cannonpack.js)
Sphere collider for the CannonSystem.
Example: Working example
new
CannonCylinderColliderComponent
(settings)
settings :: Object optional
settings.radiusTop :: number optional default = 0.5
settings.radiusBottom :: number optional default = 0.5
settings.height :: number optional default = 0.5
settings.numSegments :: number optional default = 10

CannonDistanceJointComponent extends Component

goo/addons/cannonpack/CannonDistanceJointComponent (requires cannonpack.js)
Distance joint. Add to an entity with a CannonRigidbodyComponent and physically link it to another entity!
Example: Working example
new
CannonDistanceJointComponent
(settings)
settings :: Object optional
settings.distance :: number optional default = 1
settings.connectedBody :: CannonRigidbodyComponent

Instance methods

CannonPlaneColliderComponent

goo/addons/cannonpack/CannonPlaneColliderComponent (requires cannonpack.js)
Plane collider. Attach to an entity with a CannonRigidbodyComponent.
Example: Working example
new
CannonPlaneColliderComponent
(settings)
settings :: Object optional

CannonRigidbodyComponent extends Component

goo/addons/cannonpack/CannonRigidbodyComponent (requires cannonpack.js)
Adds Cannon physics to an entity. Should be combined with one of the CannonCollider components, such as the CannonSphereColliderComponent. Also see CannonSystem.
Example: Working example
world.setSystem(new CannonSystem());
var entity = world.createEntity();
var rigidBodyComponent = new CannonRigidBodyComponent({
  mass: 1
});
entity.setComponent(rigidBodyComponent);
var boxColliderComponent = new CannonBoxColliderComponent({
  halfExtents: new Vector3(1, 1, 1)
});
entity.setComponent(boxColliderComponent);
new
CannonRigidbodyComponent
(settings)
settings :: Object optional
settings.mass :: number optional default = 1

Instance methods

setForce(force)
Set the force on the body
force :: Vector3
setVelocity(velocity)
Set the velocity on the body
velocity :: Vector3
setPosition(pos)
Set the body position.
position :: Vector3
setAngularVelocity(angularVelocity)
Set the body angular velocity position.
angularVelocity :: Vector3

Static methods

getCollider(entity) -> mixed
Get the collider component from an entity, if one exist.

CannonSphereColliderComponent

goo/addons/cannonpack/CannonSphereColliderComponent (requires cannonpack.js)
Sphere collider for the CannonSystem.
Example: Working example
new
CannonSphereColliderComponent
(settings)
settings :: Object optional
settings.radius :: number optional default = 0.5

CannonSystem extends System

goo/addons/cannonpack/CannonSystem (requires cannonpack.js)
Cannon.js physics system. Depends on the global CANNON object, so load cannon.js using a script tag before using this system. See also CannonRigidbodyComponent.
Example: Working example
var cannonSystem = new CannonSystem({
    stepFrequency: 60,
    gravity: new Vector3(0, -10, 0)
});
goo.world.setSystem(cannonSystem);
new
CannonSystem
(settings)
settings :: Object optional
settings.stepFrequency :: number optional default = 60
settings.gravity :: Vector3 optional The gravity to use in the scene. Default is (0, -10, 0)
settings.broadphase :: string optional default = 'naive' One of: 'naive' (NaiveBroadphase), 'sap' (SAPBroadphase)

Instance methods

inserted(entity)
deleted(entity)
process(entities)
setBroadphaseAlgorithm(algorithm)
Set the broadphase algorithm to use
algorithm :: string One of: 'naive' (NaiveBroadphase), 'sap' (SAPBroadphase)

CannonTerrainColliderComponent

goo/addons/cannonpack/CannonTerrainColliderComponent (requires cannonpack.js)
Terrain collider. Attach to an entity with a CannonRigidbodyComponent.
new
CannonTerrainColliderComponent
(settings)
settings :: Object optional
settings.data :: Object optional
settings.shapeOptions :: Object optional

GamepadComponent extends Component

goo/addons/gamepadpack/GamepadComponent (requires gamepadpack.js)
Example: Working example
new
GamepadComponent
()

Instance methods

setButtonDownFunction(buttonIndexbuttonFunction)
setButtonUpFunction(buttonIndexbuttonFunction)
setButtonPressedFunction(buttonIndexbuttonFunction)
setLeftStickFunction(stickFunction)
setRightStickFunction(stickFunction)

GamepadData

goo/addons/gamepadpack/GamepadData (requires gamepadpack.js)
Used for storing derived data from gamepads
new
GamepadData
()

Instance methods

resetData(gamepad)
calculateStickDirection(dirVectorxy)
dirVector :: Vector2
x :: number
y :: number

GamepadSystem extends System

goo/addons/gamepadpack/GamepadSystem (requires gamepadpack.js)
Example: Working example
new
GamepadSystem
()

Instance methods

mozGamepadHandler(eventconnecting)
process(entities)

LineRenderSystem

goo/addons/linerenderpack/LineRenderSystem (requires linerenderpack.js)
Updates all of it's LineRenderers and exposes methods for drawing primitive line shapes.
new
LineRenderSystem
(world)
world :: World the world this system exists in.

Members

renderList :: Object A managed array of all the LineRenderers render objects.

Instance methods

drawLine(startendcolor)
Draws a line between two Vector3's with the specified color.
start :: Vector3
end :: Vector3
color :: Vector3 A vector with its components between 0-1.
var vector1 = new Vector3(0, 0, 0);
var vector2 = new Vector3(13, 3, 7);
var redColor = lineRenderSystem.RED;
lineRenderSystem.drawLine(v1, v2, redColor);
drawAABox(minmaxcolortransformMatrix)
Draws an axis aligned box between the min and max points, can be transformed to a specific space using the matrix.
min :: Vector3
max :: Vector3
color :: Vector3 A vector with its components between 0-1.
transformMatrix :: Matrix4 optional
drawCross(positioncolorsize)
Draws a cross at a position with the given color and size.
position :: Vector3
color :: Vector3 A vector with its components between 0-1.
size :: number optional default = 0.05
render(renderer)

LineRenderer

goo/addons/linerenderpack/LineRenderer (requires linerenderpack.js)
Used internally to render a batch of lines all with the same color.
new
LineRenderer
(world)
world :: World The world lines are rendered in.

P2Component extends Component

goo/addons/p2pack/P2Component (requires p2pack.js)
P2 physics component. P2 supports convex and primitive shapes. See also P2System
Example: Working example
var entity = goo.world.createEntity(new Box());
var p2comp = new P2Component({
    shapes:[{
        type: 'circle',
        radius: 1
    }],
});
entity.setComponent(p2comp);
new
P2Component
(options)
options :: Object optional The options object can contain the following properties:
options.mass :: number optional default = 0 Mass of the body. 0 means immovable.
options.linearDamping :: number optional default = 0 Movement damping.
options.angularDamping :: number optional default = 0 Rotational damping.
options.shapes :: Array optional default = [] Collision shapes.
options.scale :: number optional default = 1 Scale to apply from physics to rendering.
options.offsetX :: number optional default = 0 Offset from physics to rendering.
options.offsetY :: number optional default = 0
options.offsetZ :: number optional default = 0
options.offsetAngleX :: number optional default = 0 Angular offset from physics to rendering.
options.offsetAngleY :: number optional default = 0
options.offsetAngleZ :: number optional default = 0

P2System extends System

goo/addons/p2pack/P2System (requires p2pack.js)
Handles integration with p2.js. Depends on the global p2 object, so load p2.js using a script tag before using this system. See also P2Component
Example: Working example
var p2System = new P2System({
    stepFrequency: 60,
    gravity: [0, -10]
});
goo.world.setSystem(p2System);
new
P2System
(settings)
settings :: Object optional
settings.stepFrequency :: number optional default = 60
settings.gravity :: number[] optional default = [0,-9.82]

Instance methods

inserted(entity)
deleted(entity)
process(entities)

ParticleData

goo/addons/particlepack/ParticleData (requires particlepack.js)
Container for particle data in the ParticleSystemComponent.
new
ParticleData
(particleComponent)
particleComponent :: ParticleSystemComponent

Members

component :: number The owner component
index :: number
lifeTime :: number
emitTime :: number
active :: number
startPosition :: Vector3
startDirection :: Vector3
startAngle :: number
startSize :: number
sortValue :: number
emitRandom :: number
loopAfter :: number

Instance methods

getWorldPosition(store)
Get the world position of the particle
store :: Vector3

ParticleSystemComponent

goo/addons/particlepack/components/ParticleSystemComponent (requires particlepack.js)
A Particle System component simulates things like clouds and flames by generating and animating large numbers of small 2D images in the scene.
var particleComponent = new ParticleSystemComponent({
    loop: true,
    preWarm: true,
    shapeType: 'sphere',
    sphereRadius: 0.5
});
var entity = world.createEntity([0, 0, 0], particleComponent).addToWorld();
new
ParticleSystemComponent
(options)
options :: Object optional Particle options
options.billboard :: boolean optional default = true
options.depthTest :: boolean optional default = true
options.depthWrite :: boolean optional default = true
options.loop :: boolean optional default = true
options.paused :: boolean optional default = false
options.preWarm :: boolean optional default = false
options.randomDirection :: boolean optional default = false
options.sphereEmitFromShell :: boolean optional default = false
options.colorOverLifetime :: Curve optional
options.localVelocityOverLifetime :: Curve optional
options.rotationSpeedOverLifetime :: Curve optional
options.sizeOverLifetime :: Curve optional
options.startAngle :: Curve optional
options.startColor :: Curve optional
options.startLifetime :: Curve optional
options.startSize :: Curve optional
options.startSpeed :: Curve optional
options.textureFrameOverLifetime :: Curve optional
options.worldVelocityOverLifetime :: Curve optional
options.blending :: number optional default = 'NoBlending'
options.coneAngle :: number optional Default is pi/8
options.coneLength :: number optional default = 1
options.coneRadius :: number optional default = 1
options.discardThreshold :: number optional default = 0
options.duration :: number optional default = 5
options.localSpace :: number optional default = true
options.maxParticles :: number optional default = 100
options.renderQueue :: number optional default = 3010
options.rotationSpeedScale :: number optional default = 1
options.seed :: number optional default = -1
options.startAngleScale :: number optional default = 1
options.startSizeScale :: number optional default = 1
options.texture :: number optional
options.textureAnimationCycles :: number optional default = 1
options.textureTilesX :: number optional default = 1
options.textureTilesY :: number optional default = 1
options.time :: number optional default = 0
options.coneEmitFrom :: string optional default = 'base'
options.shapeType :: string optional default = 'cone'
options.boxExtents :: Vector3 optional Default is new Vector3(1,1,1)
options.gravity :: Vector3 optional Default is zero
options.startColorScale :: Vector4 optional Default is new Vector4(1,1,1,1)

Members

entity :: Entity|null readonly The entity which the component is attached on. Will be set when the component is attached to the entity.
paused :: boolean readonly Use the pause/play/stop methods if you want to modify the state.
autoPlay :: boolean Whether to start playing when the ParticleSystemSystem plays.
particles :: ParticleData[] readonly The current particles in the system.
particlesSorted :: ParticleData[] readonly The particles in the system, sorted according to the sortMode.
time :: number readonly Current time in the system.
gravity :: Vector3 Force that makes particles fall.
boxExtents :: Vector3 readonly Extents of the box, if box shape is used. Read only. To change it, see the method setBoxExtents().
startColorScale :: Vector4 Acts as a scale on the color curve. Should be used at runtime.
billboard :: boolean If set to true, the particles will always face the camera.
blending :: string What type of blending to use for the particle mesh.
colorOverLifetime :: Vector4Curve|null Color of particles, as a curve over their life time.
coneAngle :: number Angle of the cone, if cone shape is used.
coneEmitFrom :: string Where to emit from, if using the cone shape. Set to 'base', 'volume' or 'volumeshell'.
coneLength :: number Length of the cone, if cone shape is used.
coneRadius :: number Radius of the cone, if cone shape is used.
depthTest :: boolean
depthWrite :: boolean
discardThreshold :: number At what alpha threshold should the fragments be discarded?
duration :: number The time for a full animation cycle of the emission.
emissionRate :: Curve
localSpace :: boolean If set to true, the partiles will be simulated in local entity space. If set to false, world space is used.
localVelocityOverLifetime :: Vector3Curve|null The velocity of particles in local particle space.
loop :: boolean Whether to loop the particle emission after one duration cycle.
maxParticles :: number Maximum number of particles visible at the same time.
mesh :: MeshData
preWarm :: boolean Pre-warm the emission (fast forward time one duration). Not available if looping is on.
randomDirection :: boolean Emit in random directions, instead of in the emitter volume direction.
renderQueue :: number
rotationSpeedOverLifetime :: Curve|null The rotation speed in radians per second, specified using a curve over the particle life time.
rotationSpeedScale :: number Acts as a scale on the rotationSpeed curve.
seed :: number Randomization seed.
shapeType :: string Emitter volume. Set to 'sphere', 'cone', or 'box'.
sizeOverLifetime :: Curve|null This curve alters the size of particles over their life time.
sortMode :: string
sphereEmitFromShell :: boolean Whether to emit from the sphere shell, if sphere shape is used.
startAngle :: Curve|null The initial angle of particles, as a curve over the emitter duration.
startAngleScale :: number Acts as a scale on the startAngle curve.
startColor :: Vector4Curve|null The initial color of particles as a color curve over the emitter duration.
startLifetime :: Curve|null Initial life time of particles, as a curve over the emitter duration.
startSize :: Curve|null Initial size of particles, as a curve over the emitter duration.
startSizeScale :: number Acts as a scale on the startSize curve.
startSpeed :: Curve|null Initial speed of the particles, described by a curve over the emitter duration.
texture :: Texture|null A texture for the particles.
textureAnimationCycles :: number How fast the texture animation should cycle. Acts as a scale on the textureFrameOverLifetime curve.
textureFrameOverLifetime :: Curve|null The current texture frame, given by a curve over the particle life time.
textureTilesX :: number Texture tiling in the X direction.
textureTilesY :: number Texture tiling in the Y direction.
worldVelocityOverLifetime :: Vector3Curve|null Velocity of particles in world space.

Static members

SORT_NONE :: number readonly No sorting of particles.
SORT_CAMERA_DISTANCE :: number readonly Sort particles by camera distance.

Instance methods

setBoxExtents(extents)
Set the boxExtents.
extents :: Vector3
pause()
Pause the animation.
resume()
Resume the animation.
play()
Play the animation.
stop()
Stop the animation.
emitOne(positiondirection)
Emit a particle.
position :: Vector3
direction :: Vector3

ConstantCurve extends Curve

goo/addons/particlepack/curves/ConstantCurve (requires particlepack.js)
A curve with a constant value.
new
ConstantCurve
(options)
options :: object optional
options.value :: number optional default = 1

Members

value :: number

Instance methods

integralToGLSL(timeVariableName)

Curve

goo/addons/particlepack/curves/Curve (requires particlepack.js)
A curve that has a time-dependent value (time is always between 0 and 1), and can be translated into GLSL code.
new
Curve
(options)
options :: object optional
options.type :: string optional
options.timeOffset :: number optional default = 0

Members

type The value type. Should be 'float', 'vec3' or 'vec4' to indicate which getValueAt method to use.
timeOffset :: Number The offset of this curve, when used in a PolyCurve. Needs to be a number between 0 and 1.

Static methods

numberToGLSL(n) -> string
Convert a number to GLSL code.
n :: number

LerpCurve extends Curve

goo/addons/particlepack/curves/LerpCurve (requires particlepack.js)
Curve that can lerp between two other curves.
new
LerpCurve
(options)
options :: object optional
options.curveA :: Curve optional
options.curveB :: Curve optional

Members

curveA :: Curve
curveB :: Curve

Instance methods

toGLSL(timeVariableNamelerpVariableName)
integralToGLSL(timeVariableNamelerpVariableName)
getValueAt(tlerpValue)
getIntegralValueAt(tlerpValue)

LinearCurve extends Curve

goo/addons/particlepack/curves/LinearCurve (requires particlepack.js)
new
LinearCurve
(options)
options :: object optional
options.k :: number optional
options.m :: number optional

Members

k :: number Slope of the line.
m :: number Value of the line when time is 0.

Instance methods

fromStartEnd(startValueendValue)
Create the linar curve from a start and end value.
startValue :: number
endValue :: number
toGLSL(timeVariableName)
integralToGLSL(timeVariableName)

PolyCurve extends Curve

goo/addons/particlepack/curves/PolyCurve (requires particlepack.js)
A collection of Curve instances. Used to connect different types curves, joining them at their given time offsets.
new
PolyCurve
(options)
options :: object optional
options.segments :: Curve[] optional

Members

segments :: Curve[]

Vector3Curve

goo/addons/particlepack/curves/Vector3Curve (requires particlepack.js)
Three scalar curves. Can be converted to a vec3-valued expression in GLSL code.
new
Vector3Curve
(options)
options :: object optional
options.x :: Curve optional
options.y :: Curve optional
options.z :: Curve optional

Instance methods

toGLSL(timeVariableNamelerpValueVariableName)
integralToGLSL(timeVariableNamelerpValueVariableName)
getVec3ValueAt(tlerpValuestore)
getVec3IntegralValueAt(tlerpValuestore)

Vector4Curve

goo/addons/particlepack/curves/Vector4Curve (requires particlepack.js)
Three scalar curves. Can be converted to a vec4-valued expression in GLSL code.
new
Vector4Curve
(options)
options :: object optional
options.x :: Curve optional
options.y :: Curve optional
options.z :: Curve optional
options.w :: Curve optional

Instance methods

toGLSL(timeVariableNamelerpValueVariableName)
integralToGLSL(timeVariableNamelerpValueVariableName)
getVec4ValueAt(tlerpValuestore)
getVec4IntegralValueAt(tlerpValuestore)

ParticleSystemComponentHandler extends ComponentHandler

goo/addons/particlepack/handlers/ParticleSystemComponentHandler (requires particlepack.js)
new
ParticleSystemComponentHandler
()

Instance methods

update(entityconfigoptions) -> RSVP.Promise
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

ParticleDebugRenderSystem extends System

goo/addons/particlepack/systems/ParticleDebugRenderSystem (requires particlepack.js)
Renders all ParticleSystemComponents in the scene.
new
ParticleDebugRenderSystem
()

Members

renderAll :: boolean If set to true, all entities with a ParticleSystemComponent attached is rendered, and the selection is disregarded.
selection :: EntitySelection The selected entities to be rendered.

ParticleSystemSystem extends System

goo/addons/particlepack/systems/ParticleSystemSystem (requires particlepack.js)
System that runs all the ParticleSystemComponents.
new
ParticleSystemSystem
()

Instance methods

pause()
Pause all ParticleSystemComponents.
resume()
Resume all ParticleSystemComponents.
play()
Play all ParticleSystemComponents.

PhysicsMaterial

goo/addons/physicspack/PhysicsMaterial (requires physicspack.js)
new
PhysicsMaterial
(settings)
settings :: Object optional
settings.friction :: number optional default = 0.3
settings.restitution :: number optional default = 0

Members

friction :: number The friction coefficient. Multiplication is used to combine two friction values.
restitution :: number The "bounciness" of the collider.

RaycastResult

goo/addons/physicspack/RaycastResult (requires physicspack.js)
Structure used to get information back from a raycast.
new
RaycastResult
(settings)
settings :: Object optional
settings.normal :: Vector3 optional
settings.point :: Vector3 optional
settings.entity :: Entity optional
settings.distance :: number optional

Members

point :: Vector3 The impact point in world space where the ray hit the collider.
normal :: Vector3 The normal of the surface the ray hit.
entity :: Entity The Collider that was hit.
distance :: number The distance from the ray's origin to the impact point.

Instance methods

BoxCollider extends Collider

goo/addons/physicspack/colliders/BoxCollider (requires physicspack.js)
Physics box collider.
new
BoxCollider
(settings)
settings :: Object optional
settings.halfExtents :: Vector3 optional The half-extents of the box collider.

Members

halfExtents :: Vector3

Instance methods

clone() -> BoxCollider
Clone the collider

Collider

goo/addons/physicspack/colliders/Collider (requires physicspack.js)
Base class for Colliders.
new
Collider
()

Instance methods

virtual clone() -> Collider

CylinderCollider extends Collider

goo/addons/physicspack/colliders/CylinderCollider (requires physicspack.js)
Cylinder collider, that extends along the Z axis.
new
CylinderCollider
(settings)
settings :: Object optional
settings.radius :: number optional default = 0.5
settings.height :: number optional default = 1

Members

radius :: number
height :: number

Instance methods

MeshCollider extends Collider

goo/addons/physicspack/colliders/MeshCollider (requires physicspack.js)
Physics mesh collider.
new
MeshCollider
(settings)
settings :: Object optional
settings.meshData :: MeshData optional
settings.scale :: Vector3 optional

Members

meshData :: MeshData
scale :: Vector3

Instance methods

PlaneCollider extends Collider

goo/addons/physicspack/colliders/PlaneCollider (requires physicspack.js)
Plane collider, that faces in the Z direction.
new
PlaneCollider
()

Instance methods

SphereCollider extends Collider

goo/addons/physicspack/colliders/SphereCollider (requires physicspack.js)
new
SphereCollider
(settings)
settings :: Object optional
settings.radius :: number optional default = 0.5

Members

radius :: number

Instance methods

AbstractColliderComponent extends Component

goo/addons/physicspack/components/AbstractColliderComponent (requires physicspack.js)
Adds a physics collider to the entity. If the entity or any of its ancestors have a {RigidBodyComponent}, the collider is added to the physics world.
new
AbstractColliderComponent
(settings)
settings :: Object optional
settings.collider :: Collider optional
settings.isTrigger :: boolean optional default = false

Members

collider :: Collider
worldCollider :: Collider The world-scaled version of the collider. Use .updateWorldCollider() to update it.
isTrigger :: boolean If the collider is a Trigger, it does not interact with other objects, but it does emit contact events.
bodyEntity :: Entity The entity with a rigid body component that instantiated the collider, or null if it wasn't instantiated.
material :: PhysicsMaterial The collider material.

Instance methods

getBodyEntity() -> Entity
Get the closest parent (or self) entity that has a RigidBodyComponent. Returns undefined if none was found.
updateWorldCollider()
Updates the .worldCollider

AbstractRigidBodyComponent extends Component

goo/addons/physicspack/components/AbstractRigidBodyComponent (requires physicspack.js)
Base class for rigid bodies.
new
AbstractRigidBodyComponent
()

Members

joints :: Array Joints on the body. Use .addJoint to add one, or .removeJoint to remove.

Instance methods

addJoint(joint)
joint :: PhysicsJoint
removeJoint(joint)
joint :: PhysicsJoint
emitInitialized(entity)
Should be called by subclasses when initializing the physics engine body.
entity :: Entity
virtual initialize()
Creates the physics engine rigid body and adds it to the simulation
virtual destroy()
virtual initializeJoint()
Creates a joint in the physics engine.
joint :: PhysicsJoint
entity :: Entity
system :: System
virtual destroyJoint()
Removes a joint from the physics engine.
joint :: PhysicsJoint
traverseColliders(entitycallback)
Traverse the tree of colliders from a root entity and down.
entity :: Entity
callback :: Function A callback to be called for each collider below or on the same entity. The arguments to the callback are: colliderEntity, collider, localPosition and localQuaternion.

ColliderComponent extends AbstractColliderComponent

goo/addons/physicspack/components/ColliderComponent (requires physicspack.js)
Adds a physics collider to the entity. If the entity or any of its ancestors have a {RigidBodyComponent}, the collider is added to the physics world.
new
ColliderComponent
(settings)
settings :: Object optional
settings.collider :: Collider optional
settings.isTrigger :: boolean optional default = false

Members

cannonBody :: CANNON.Body The Cannon.js Body instance, if the ColliderComponent was initialized without a RigidBodyComponent.
cannonShape :: CANNON.Body The Cannon.js Shape instance

Instance methods

initialize()
Initialize the collider as a static rigid body in the physics world.
destroy()
Remove the collider from the physics world. Does the opposite of .initialize()

RigidBodyComponent extends AbstractRigidBodyComponent

goo/addons/physicspack/components/RigidBodyComponent (requires physicspack.js)
Adds rigid body dynamics the entity. To be used with the PhysicsSystem. If the entity or its children have ColliderComponents, they are added as collision shapes to the rigid body.
new
RigidBodyComponent
(settings)
settings :: Object optional
settings.mass :: number optional default = 1
settings.isKinematic :: boolean optional default = false
settings.velocity :: Vector3 optional
settings.angularVelocity :: Vector3 optional
settings.linearDamping :: number optional default = 0.01
settings.angularDamping :: number optional default = 0.05

Members

cannonBody :: CANNON.Body
interpolation :: number How smoothing of the rigid body movement should be done. Set it to {@link RigidBodyComponent.NONE} or {@link RigidBodyComponent.INTERPOLATE}.
linearDamping :: number
angularDamping :: number
isKinematic :: number
sleepingThreshold :: number
mass :: number
sleepingTimeLimit :: number
constraints :: number Constraint the movement of the rigid body. Set it to RigidBodyComponent.FREEZE_NONE, RigidBodyComponent.FREEZE_POSITION_X, RigidBodyComponent.FREEZE_POSITION_Y, RigidBodyComponent.FREEZE_POSITION_Z, RigidBodyComponent.FREEZE_ROTATION_X, RigidBodyComponent.FREEZE_ROTATION_Y, RigidBodyComponent.FREEZE_ROTATION_Z, RigidBodyComponent.FREEZE_POSITION, RigidBodyComponent.FREEZE_ROTATION or RigidBodyComponent.FREEZE_ALL.

Static members

FREEZE_NONE :: number No constraints.
FREEZE_POSITION_X :: number Freeze motion along the X-axis.
FREEZE_POSITION_Y :: number Freeze motion along the Y-axis.
FREEZE_POSITION_Z :: number Freeze motion along the Z-axis.
FREEZE_ROTATION_X :: number Freeze rotation along the X-axis.
FREEZE_ROTATION_Y :: number Freeze rotation along the Y-axis.
FREEZE_ROTATION_Z :: number Freeze rotation along the Z-axis.
NONE No rigid body smoothing.
INTERPOLATE Transform is smoothed based on the Transform of the previous frame.
numCylinderSegments :: number Cannon.js uses ConvexPolyhedron shapes for collision checking sometimes (for example, for cylinders). Therefore it needs a number of segments to use.

Instance methods

applyForceWorld(forceworldPoint)
Apply a world-oriented force to a world point.
force :: Vector3 The force vector, oriented in world space.
worldPoint :: Vector3 Where to apply the force, in world space.
var direction = new Vector3();
direction
    .copy(entity.transformComponent.worldTransform.translation)
    .sub(bombEntity.transformComponent.worldTransform.translation)
    .normalize()
    .scale(100);
entity.applyForceWorld(direction, entity.transformComponent.worldTransform.translation);
applyForceLocal(forcerelativePoint)
Apply a local force to the body in local body space.
force :: Vector3 The force vector, oriented in local space.
relativePoint :: Vector3 optional Where to apply the force. This point is relative to the Body, oriented in local space. Defaults to the zero vector (the center of mass).
var localThrusterForce = new Vector3(0, 0, 1); // Thrust in forward direction of ship
var localPosition = new Vector3(0, 0, -1); // Applies to the back part of the ship
shapeShip.rigidBodyComponent.applyForce(localThrusterForce, localPosition);
applyForce(forcerelativePoint)
Apply a force to a point on the body in world space.
force :: Vector3 The force vector, oriented in world space.
relativePoint :: Vector3 optional Where to apply the force. This point is relative to the Body, oriented in World space. Defaults to the zero vector (the center of mass).
applyTorque(torque)
Apply a torque to a point on the body in world space.
torque :: Vector3 The torque vector, oriented in world space.
applyTorqueLocal(torque)
Apply a torque to the body in local body space.
torque :: Vector3 The torque vector, oriented in local body space.
applyImpulse(impulserelativePoint)
Apply an impulse to the body.
impulse :: Vector3 The impulse vector, oriented in world space.
relativePoint :: Vector3 Where the impulse should be applied
applyImpulseLocal(impulserelativePoint)
Apply an impulse to the center of mass of the body.
impulse :: Vector3 The force vector, oriented in local space.
relativePoint :: Vector3
setVelocity(velocity)
velocity :: Vector3
getVelocity(targetVector)
targetVector :: Vector3
setAngularVelocity(angularVelocity)
angularVelocity :: Vector3
getAngularVelocity(targetVector)
targetVector :: Vector3
setPosition(position)
position :: Vector3
getPosition(targetVector)
targetVector :: Vector3
getInterpolatedPosition(targetVector)
Get the interpolated position from the rigid body. Use this for rendering. The resulting vector is a linear interpolation between the current and previous physics position, that matches the current rendering frame.
targetVector :: Vector3
setQuaternion(quaternion)
quaternion :: Quaternion
getQuaternion(targetQuat)
targetQuat :: Quaternion
getInterpolatedQuaternion(targetQuat)
Get the interpolated quaternion from the rigid body. Use this for rendering. The resulting quaternion is a spherical interpolation between the current and previous physics position, that matches the current rendering frame.
targetQuat :: Quaternion
destroy()
Removes the body from the physics engine
initialize()
Initialize the Cannon.js body available in the .cannonBody property. This is useful if the intention is to work with the CANNON.Body instance directly after the component is created.
clone() ->
Creates a new instance indentical to this component.

Static methods

constraintsToCannonFactors(constraintslinearangular)
copyScaleFromColliderToCannonShape(cannonShapecollider)

ColliderComponentHandler extends ComponentHandler

goo/addons/physicspack/handlers/ColliderComponentHandler (requires physicspack.js)
For handling loading of collider components
new
ColliderComponentHandler
()

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine collider component object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

RigidBodyComponentHandler extends ComponentHandler

goo/addons/physicspack/handlers/RigidBodyComponentHandler (requires physicspack.js)
For handling loading of rigid body components
new
RigidBodyComponentHandler
()

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine rigid body component object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

BallJoint extends PhysicsJoint

goo/addons/physicspack/joints/BallJoint (requires physicspack.js)
A physics ball joint. A ball joint (or "constraint") will try to keep a point in each of two connected bodies the same.
new
BallJoint
(settings)
settings :: Object optional
settings.localPivot :: Vector3 optional
settings.connectedEntity :: Entity optional
settings.collideConnected :: boolean optional default = false

Members

localPivot :: Vector3
autoConfigureConnectedPivot :: boolean Automatically compute the connectedLocalPivot by using the entities initial transforms.
connectedLocalPivot :: Vector3 The pivot point defined inside the connected entity.

HingeJoint extends PhysicsJoint

goo/addons/physicspack/joints/HingeJoint (requires physicspack.js)
Physics hinge joint. To be added to a RigidBodyComponent.
new
HingeJoint
(settings)
settings :: Object optional
settings.localPivot :: Vector3 optional
settings.localAxis :: Vector3 optional
settings.connectedEntity :: Entity optional
settings.collideConnected :: boolean optional default = false

Members

localPivot :: Vector3 A point defined locally in the entity that the Hinge should rotate around.
autoConfigureConnectedPivot :: boolean Automatically compute the connectedLocalPivot
connectedLocalPivot :: Vector3 The pivot point defined inside the connected entity.
localAxis :: Vector3

PhysicsJoint

goo/addons/physicspack/joints/PhysicsJoint (requires physicspack.js)
Base class for physics joints, for example hinge or balljoint.
new
PhysicsJoint
(settings)
settings :: Object optional
settings.connectedEntity :: Entity optional
settings.collideConnected :: boolean optional default = false

Members

connectedEntity :: Entity The entity connected
collideConnected :: boolean Indicates if the connected entities should collide.

PhysicsBoxDebugShape extends MeshData

goo/addons/physicspack/shapes/PhysicsBoxDebugShape (requires physicspack.js)
A wireframe mesh indicating the position and orientation of a BoxCollider.
new
PhysicsBoxDebugShape
()

Instance methods

PhysicsCylinderDebugShape extends MeshData

goo/addons/physicspack/shapes/PhysicsCylinderDebugShape (requires physicspack.js)
A wireframe mesh indicating the position and orientation of a CylinderCollider.
new
PhysicsCylinderDebugShape
(numSegments)
numSegments :: number optional default = 32

Instance methods

PhysicsPlaneDebugShape extends MeshData

goo/addons/physicspack/shapes/PhysicsPlaneDebugShape (requires physicspack.js)
A wireframe mesh indicating the position and orientation of a PlaneCollider.
new
PhysicsPlaneDebugShape
()

Instance methods

PhysicsSphereDebugShape extends MeshData

goo/addons/physicspack/shapes/PhysicsSphereDebugShape (requires physicspack.js)
A wireframe mesh indicating the position and orientation of a SphereCollider.
new
PhysicsSphereDebugShape
(numSegments)
numSegments :: number optional default = 32

Instance methods

AbstractPhysicsSystem extends System

goo/addons/physicspack/systems/AbstractPhysicsSystem (requires physicspack.js)
Base class for physics systems.
new
AbstractPhysicsSystem
()

Instance methods

virtual setGravity()
gravityVector :: Vector3

ColliderSystem extends System

goo/addons/physicspack/systems/ColliderSystem (requires physicspack.js)
Processes all entities with collider components, making sure they are up to date.
new
ColliderSystem
()

PhysicsDebugRenderSystem extends System

goo/addons/physicspack/systems/PhysicsDebugRenderSystem (requires physicspack.js)
Renders all ColliderComponents in the scene.
world.setSystem(new PhysicsDebugRenderSystem());
new
PhysicsDebugRenderSystem
()

Members

renderAll :: boolean If set to true, all entities with a ColliderComponent attached is rendered, and the selection is disregarded.
selection :: EntitySelection The selected entities to be rendered.

PhysicsSystem extends AbstractPhysicsSystem

goo/addons/physicspack/systems/PhysicsSystem (requires physicspack.js)
A physics system using Cannon.js.
new
PhysicsSystem
(settings)
settings :: Object optional
settings.gravity :: Vector3 optional

Members

cannonWorld :: CANNON.World

Instance methods

setGravity(gravityVector)
gravityVector :: Vector3
getGravity(store)
store :: Vector3
raycastAny(startdirectionmaxDistanceoptionsresult) -> boolean
Make a ray cast into the world of colliders, stopping at the first hit that the ray intersects. Note that there's no given order in the traversal, and there's no control over what will be returned.
start :: Vector3
direction :: Vector3
maxDistance :: number
options :: Object optional
options.collisionMask :: number optional default = -1
options.collisionGroup :: number optional default = -1
options.skipBackFaces :: number optional default = true
result :: RaycastResult optional
raycastClosest(startdirectionmaxDistanceoptionsresult) -> boolean
Make a ray cast into the world of colliders, and only return the closest hit.
start :: Vector3
direction :: Vector3
maxDistance :: number
options :: Object optional
options.collisionMask :: number optional default = -1
options.collisionGroup :: number optional default = -1
options.skipBackFaces :: number optional default = true
result :: RaycastResult optional
raycastAll(startdirectionmaxDistanceoptionscallback) -> boolean
Make a ray cast into the world of colliders, evaluating the given callback once at every hit.
start :: Vector3
direction :: Vector3
maxDistance :: number
options :: Object optional
options.collisionMask :: number optional default = -1
options.collisionGroup :: number optional default = -1
options.skipBackFaces :: number optional default = true
callback :: function (result: RaycastResult) -> boolean
play()
Resumes simulation and starts updating the entities after stop() or pause().
pause()
Stops simulation and updating of the entitiy transforms.
resume()
Resumes simulation and starts updating the entities after stop() or pause(); an alias for `.play`
stop()
Stops simulation.
process(entities)

Pool

goo/addons/physicspack/util/Pool (requires physicspack.js)
Abstract pool class for object pooling.
var vectorPool = new Pool({
    create: function () {
        return new Vector3();
    },
    init: function (x, y, z) {
        this.set(x, y, z);
    },
    destroy: function (vector) {
        vector.set(0, 0, 0);
    }
});
var vector = vectorPool.get(1, 2, 3);
vectorPool.release(vector);
new
Pool
(settings)
settings :: Object optional
settings.init :: Function optional
settings.create :: Function optional
settings.destroy :: Function optional

Instance methods

resize(size)
Fill the pool so it has exactly "size" objects. If the current number of objects is larger than the requested size, the excess objects are destroyed.
size :: number
get() -> Object
Get an object from the pool if there are free ones, or create a new object.
release(object)
Put an object back into the pool.
object :: Object

Forrest

goo/addons/terrainpack/Forrest (requires terrainpack.js)

Instance methods

init(worldterrainQueryforrestAtlasTextureforrestAtlasNormalsforrestTypesentityMap)
loadLODTrees(worldterrainQueryforrestAtlasTextureforrestAtlasNormalsforrestTypesentityMap)
update(xz)
fetchTreeMesh(vegetationType)
fetchTreeBillboard(vegetationTypesize)
getPointInPatch(xzpatchXpatchZpatchSpacing)
addVegMeshToPatch(vegetationTypeposmeshBuilderlevelOfDetailgridEntity)
createForrestPatch(patchXpatchZlevelOfDetailgridEntity)

Terrain

goo/addons/terrainpack/Terrain (requires terrainpack.js)
A terrain
new
Terrain
()

Instance methods

init(terrainTextures)
setMarker(typesizexypowerbrushTexture)
pick(cameraxystore)
draw(modetypesizexyzpowerbrushTexturergba)
update(pos)
createClipmapLevel(worldmateriallevel)
createQuadEntity(worldmateriallevelparentEntityxywh)

TerrainHandler

goo/addons/terrainpack/TerrainHandler (requires terrainpack.js)

Instance methods

initLevel(terrainDatasettingsforrestLODEntityMap)
useLightmap(datasize)
useLightmap(datasize)
update(cameraEntity)

TerrainSurface

goo/addons/terrainpack/TerrainSurface (requires terrainpack.js)
A grid-like surface shape
new
TerrainSurface
(heightMatrixxWidthyHeightzWidth)
heightMatrix :: array The height data by x and z axis.
xWidth :: number x axis size in units
yHeight :: number y axis size in units
zWidth :: number z axis size in units

Instance methods

rebuild() -> Surface
Builds or rebuilds the mesh data

Vegetation

goo/addons/terrainpack/Vegetation (requires terrainpack.js)

Instance methods

init(worldterrainQueryvegetationAtlasTexturevegetationTypessettings)
update(xz)
createPatch(patchXpatchZ)
lookAt(matrixdirectionup)

FlatWaterRenderer

goo/addons/waterpack/FlatWaterRenderer (requires waterpack.js)
Handles pre-rendering of water planes. Attach this to the rendersystem pre-renderers.
Example: Working example
new
FlatWaterRenderer
(settings)
settings :: Object optional Water settings passed in a JSON object
settings.useRefraction :: boolean optional default = true Render refraction in water
settings.divider :: boolean optional default = 2 Resolution divider for reflection/refraction
settings.normalsUrl :: boolean optional Url to texture to use as normalmap
settings.normalsTexture :: boolean optional Texture instance to use as normalmap
settings.updateWaterPlaneFromEntity :: boolean optional default = true Use water entity y for water plane position

Instance methods

updateSize(renderer)
process(rendererentitiespartitionercameralights)
setSkyBox(skyboxEntity)

ProjectedGrid

goo/addons/waterpack/ProjectedGrid (requires waterpack.js)
Projected grid mesh
new
ProjectedGrid
(densityXdensityY)
densityX :: number optional default = 20 Density in X of grid
densityY :: number optional default = 20 Density in Y of grid

Instance methods

update(camera)
getWorldIntersectionHomogenous(planeHeightscreenPositionmodelViewProjectionInverseMatrixstore)
getWorldIntersection(planeHeightscreenPositionmodelViewProjectionInverseMatrixstore)
getWorldIntersectionSimple(planeHeightsourcedestinationstoretmpStorage)
calculateIntersection(planeHeightscreenPositionmodelViewProjectionInverseMatrix)
rebuild() -> ProjectedGrid
Builds or rebuilds the mesh data.

ProjectedGridWaterRenderer

goo/addons/waterpack/ProjectedGridWaterRenderer (requires waterpack.js)
Handles pre-rendering of water planes. Attach this to the rendersystem pre-renderers.
new
ProjectedGridWaterRenderer
(settings)
settings :: Object optional Water settings passed in a JSON object
settings.divider :: boolean optional default = 1 Resolution divider for reflection/refraction

Instance methods

updateHelper(intersectBottomLeftintersectBottomRightintersectTopRightintersectTopLeft)
process(rendererentitiespartitionercameralights)
setSkyBox(skyboxEntity)

Joint

goo/animationpack/Joint (requires animationpack.js)
Representation of a Joint in a Skeleton. Meant to be used within a specific Skeleton object.
new
Joint
(name)
name :: string Name of joint

Skeleton

goo/animationpack/Skeleton (requires animationpack.js)
Describes a collection of Joints. This class represents the hierarchy of a Skeleton and its original aspect (via the Joint class). This does not support posing the joints in any way... Use with a SkeletonPose to describe a skeleton in a specific pose.
new
Skeleton
(namejoints)
name :: string
joints :: Joint[]

Instance methods

SkeletonPose

goo/animationpack/SkeletonPose (requires animationpack.js)
Joins a Skeleton with an array of Joint poses. This allows the skeleton to exist and be reused between multiple instances of poses.
new
SkeletonPose
(skeleton)
skeleton :: Skeleton

Instance methods

setToBindPose()
Update our local joint transforms so that they reflect the skeleton in bind pose.
updateTransforms()
Update the global and palette transforms of our posed joints based on the current local joint transforms.

BinaryLerpSource extends Source

goo/animationpack/blendtree/BinaryLerpSource (requires animationpack.js)
Takes two blend sources and uses linear interpolation to merge TransformData values. If one of the sources is null, or does not have a key that the other does, we disregard weighting and use the non-null side's full value. Source data that is not TransformData, JointData or float data is not combined, rather A's value will always be used unless it is null.
new
BinaryLerpSource
(sourceAsourceBblendKey)
blendKey :: number A key into the related AnimationManager's values store for pulling blend weighting.

Instance methods

setTime(globalTime)
Sets the current time and moves the AnimationClipInstance forward
globalTime :: number
resetClips(globalStartTime)
Sets start time of clipinstance. If set to current time, clip is reset
globalStartTime :: number
shiftClipTime(shiftTime)
setTimeScale(timeScale)
Sets the time scale for sources A and B
timeScale :: number
isActive() -> boolean

Static methods

combineSourceData(sourceADatasourceBDatablendWeightstore) -> Object
Blends two sourceData maps together
sourceAData :: Object
sourceBData :: Object
blendWeight :: number
store :: Object optional If store is supplied, the result is stored there
blendFloatValues(rValkeyblendWeightdataAdataB)
Blends two float values and stores them in rVal
rVal :: Object The object in which to store result
key :: string The key to object rVal, so rVal[key] is the store
blendWeight :: number
dataA :: number[] The float is wrapped in an array
dataB :: number[] The float is wrapped in an array

ClipSource extends Source

goo/animationpack/blendtree/ClipSource (requires animationpack.js)
A blend tree leaf node that samples and returns values from the channels of an AnimationClip.
new
ClipSource
(clipfilterchannelNames)
clip :: AnimationClip the clip to use.
filter :: string optional 'Exclude' or 'Include'
channelNames :: string[] optional

Instance methods

setFilter(filterchannelNames)
Sets the filter on the joints which the clipsource will affect
filter :: string optional 'Exclude' or 'Include'
channelNames :: string[] optional

FrozenClipSource extends Source

goo/animationpack/blendtree/FrozenClipSource (requires animationpack.js)
A blend tree node that does not update any clips or sources below it in the blend tree. This is useful for freezing an animation, often for purposes of transitioning between two unrelated animations.
new
FrozenClipSource
(sourcefrozenTime)
frozenTime :: number The time we are frozen at.

Instance methods

resetClips()
Sets start time of clipinstance to 0, so frozenTime will calculate correctly
setTime()
This will be called by a SteadyState, but will not update the animation, and will return true, to indicate animation is still active

ManagedTransformSource extends Source

goo/animationpack/blendtree/ManagedTransformSource (requires animationpack.js)
This tree source maintains its own source data, which can be modified directly using instance functions. This source is meant to be used for controlling a particular joint or set of joints programatically.
new
ManagedTransformSource
(sourceName)
sourceName :: string optional Name of source we were initialized from, if given.

Instance methods

setTranslation(channelNametranslation)
Sets a translation to the local transformdata for a given channelName. The channel has to be an instance of TransformChannel
channelName :: string
translation :: Vector3 the translation to set
getTranslation(channelNamestore) ->
Gets the translation of the local transformdata for a given channelName. The channel has to be an instance of TransformChannel
channelName :: string
store :: Vector3 optional to store the result in
setScale(channelNamescale)
Sets a scale to the local transformdata for a given channelName. The channel has to be an instance of TransformChannel
channelName :: string
scale :: Vector3 the scale to set
getScale(channelNamestore) -> Vector3
Gets the scale from the local transformdata for a given channelName. The channel has to be an instance of TransformChannel
channelName :: string
store :: Vector3 optional to store the result in
setRotation(channelNamerotation)
Sets a rotation to the local transformdata for a given channelName. The channel has to be an instance of TransformChannel
channelName :: string
rotation :: Quaternion the rotation to set
getRotation(channelNamestore)
Gets rotation from the local transformdata for a given channelName. The channel has to be an instance of TransformChannel
channelName :: string
store :: Quaternion optional to store the result in
initFromClip(clipfilterchannelNames)
Setup transform data for specific joints on this source, using the first frame from a given clip.
clip :: AnimationClip the animation clip to pull data from
jointIndices :: string[] the indices of the joints to initialize data for.
getChannelData(channelName)

Source

goo/animationpack/blendtree/Source (requires animationpack.js)
Class to use for animation sources. Base class - not supposed to be used directly.
new
Source
()

Instance methods

setTime() -> boolean
Sets the current time and moves the AnimationClipInstance forward.
globalTime :: number
resetClips()
Sets start time. If set to current time, clip is reset
globalStartTime :: number
shiftClipTime()
shiftTime :: number
setTimeScale()
Sets the time scale for the source.
timeScale :: number
isActive() -> boolean

AbstractAnimationChannel

goo/animationpack/clip/AbstractAnimationChannel (requires animationpack.js)
Base class for animation channels. An animation channel describes a single element of an animation (such as the movement of a single joint, or the play back of a specific sound, etc.) These channels are grouped together in an AnimationClip to describe a full animation.
new
AbstractAnimationChannel
(channelNametimesblendType)
channelName :: string the name of our channel. This is immutable to this instance of the class.
times :: number[] our time indices. Copied into the channel.
blendType :: string the blendtype between transform keyframes of the channel. Defaults to AbstractAnimationChannel.BLENDTYPES.LINEAR

Instance methods

updateSample(clockTimeapplyTo)

AnimationClip

goo/animationpack/clip/AnimationClip (requires animationpack.js)
AnimationClip manages a set of animation channels as a single clip entity.
new
AnimationClip
(namechannels)
name :: string Name of joint
channels :: AbstractAnimationChannel[] optional default = [] an array of channels to shallow copy locally.

Instance methods

update(clockTimeinstance)
addChannel(channel)
Add a channel to this clip.
channel :: AbstractAnimationChannel the channel to add.
removeChannel(channel) -> boolean
Remove a given channel from this clip.
channel :: AbstractAnimationChannel the channel to remove.
findChannelByName(channelName) -> AbstractAnimationChannel
Locate a channel in this clip using its channel name.
channelName :: string the name to match against.

AnimationClipInstance

goo/animationpack/clip/AnimationClipInstance (requires animationpack.js)
Maintains state information about an instance of a specific animation clip, such as time scaling applied, active flag, start time of the instance, etc.
new
AnimationClipInstance
()

Instance methods

setTimeScale(scaleglobalTime)
Sets the timescale of the animation, speeding it up or slowing it down
scale :: number
globalTime :: number optional default = World.time
getApplyTo(channel) -> TransformData|TriggerData|number[]
Gives the corresponding data for a channel, to apply animations to

InterpolatedFloatChannel

goo/animationpack/clip/InterpolatedFloatChannel (requires animationpack.js)
An animation source channel consisting of float value samples. These samples are interpolated between key frames. Potential uses for this channel include extracting and using forward motion from walk animations, animating colors or texture coordinates, etc.
new
InterpolatedFloatChannel
(channelNametimesvalues)
channelName :: string the name of this channel.
times :: number[] the time samples
values :: number[] our value samples. Entries may be null. Should have as many entries as the times array.

Instance methods

setCurrentSample(sampleIndexprogressPercentvalue)
getData(indexstore) -> number[]
Apply a specific index of this channel to a TransformData object.
index :: number the index to grab.
store :: number[] optional the TransformData to store in. If null, a new one is created.

JointChannel

goo/animationpack/clip/JointChannel (requires animationpack.js)
Transform animation channel, specifically geared towards describing the motion of skeleton joints.
new
JointChannel
(jointNamejointIndextimesrotationstranslationsscales)
jointName :: string our joint name.
jointIndex :: number our joint index
times :: number[] our time offset values.
rotations :: number[] the rotations to set on this channel at each time offset.
translations :: number[] the translations to set on this channel at each time offset.
scales :: number[] the scales to set on this channel at each time offset.

Static members

JOINT_CHANNEL_NAME :: string readonly

Instance methods

setCurrentSample(sampleIndexprogressPercentjointData)
getData(indexstore) -> JointData
Apply a specific index of this channel to a TransformData object.
index :: number the index to grab.
store :: JointData optional the TransformData to store in. If null, a new one is created.

JointData

goo/animationpack/clip/JointData (requires animationpack.js)
Describes transform of a joint.
new
JointData
(source)
source :: JointData optional source to copy

Instance methods

set(jointData)
Copy the jointData's values into this transform data object.
jointData :: JointData our source to copy. Must not be null.
blend(blendToblendWeightstore) -> TransformData
Blend this transform with the given transform.
blendTo :: TransformData The transform to blend to
blendWeight :: number The blend weight
store :: TransformData The transform store.

TransformChannel

goo/animationpack/clip/TransformChannel (requires animationpack.js)
An animation channel consisting of a series of transforms interpolated over time.
new
TransformChannel
(channelNametimesrotationstranslationsscales)
channelName :: our name.
times :: Array our time offset values.
rotations :: Array the rotations to set on this channel at each time offset.
translations :: Array the translations to set on this channel at each time offset.
scales :: Array the scales to set on this channel at each time offset.

Instance methods

setCurrentSample(sampleIndexfractionapplyTo)
getData(indexstore) -> TransformData
Apply a specific index of this channel to a TransformData object.
index :: number the index to grab.
store :: TransformData optional the TransformData to store in. If null, a new one is created.

TransformData

goo/animationpack/clip/TransformData (requires animationpack.js)
Describes a relative transform as a Quaternion-Vector-Vector tuple. We use QVV to make it simpler to do LERP blending.
new
TransformData
(source)
source :: TransformData optional source to copy.

Instance methods

applyTo(transform)
set(source)
Copy the source's values into this transform data object.
source :: TransformData our source to copy.
blend(blendToblendWeightstore) -> TransformData
Blend this TransformData with the given TransformData.
blendTo :: TransformData The TransformData to blend to
blendWeight :: number The blend weight
store :: TransformData The TransformData store.

TriggerChannel

goo/animationpack/clip/TriggerChannel (requires animationpack.js)
An animation source channel consisting of keyword samples indicating when a specific trigger condition is met. Each channel can only be in one keyword "state" at a given moment in time.
new
TriggerChannel
(channelNametimeskeys)
channelName :: string the name of this channel.
times :: number[] the time samples
keys :: string[] our key samples. Entries may be null. Should have as many entries as the times array.

Instance methods

createStateDataObject() -> TriggerData
Creates a data item for this type of channel
setCurrentSample(sampleIndexprogressPercenttriggerData)
Applies the channels animation state to supplied data item
sampleIndex :: number
progressPercent :: number
value :: TriggerData The data item to apply animation to

TriggerData

goo/animationpack/clip/TriggerData (requires animationpack.js)
Transient class that maintains the current triggers and armed status for a TriggerChannel.
new
TriggerData
()

Instance methods

arm(indextriggers)

AnimationComponent extends Component

goo/animationpack/components/AnimationComponent (requires animationpack.js)
Holds the animation data.
new
AnimationComponent
(pose)
pose :: SkeletonPose pose

Members

layers :: AnimationLayer[]

Instance methods

transitionTo(stateKeyallowDirectSwitchcallback) -> boolean
Transition to another state. This is shorthand for applying transitions on the base layer, see {@link AnimationLayer.transitionTo} for more info
stateKey :: string
allowDirectSwitch :: boolean Allow the function to directly switch state if transitioning fails (missing or transition already in progress)
callback :: Function If the target state has a limited number of repeats, this callback is called when the animation finishes.
getStates()
Get available states returns {Array} available state keys
getTransitions()
Get available transitions returns {Array} available state keys
update(globalTime)
apply(transformComponent)
addLayer(layerindex)
Add a new AnimationLayer to the stack
layer :: AnimationLayer
index :: number optional if no index is supplied, it's put on top of the stack
resetClips(globalTime)
shiftClipTime(shiftTime)
setTimeScale(timeScale)

AnimationClipHandler extends ConfigHandler

goo/animationpack/handlers/AnimationClipHandler (requires animationpack.js)
Handler for loading animation clips into engine
new
AnimationClipHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

AnimationComponentHandler extends ComponentHandler

goo/animationpack/handlers/AnimationComponentHandler (requires animationpack.js)
For handling loading of animation components
new
AnimationComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine animation component object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

AnimationLayersHandler extends ConfigHandler

goo/animationpack/handlers/AnimationLayersHandler (requires animationpack.js)
Handler for loading animation layers
new
AnimationLayersHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

AnimationStateHandler extends ConfigHandler

goo/animationpack/handlers/AnimationStateHandler (requires animationpack.js)
Handler for loading animation states into engine
new
AnimationStateHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

SkeletonHandler extends ConfigHandler

goo/animationpack/handlers/SkeletonHandler (requires animationpack.js)
Handler for loading skeletons into engine
new
SkeletonHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

AnimationLayer

goo/animationpack/layer/AnimationLayer (requires animationpack.js)
Animation layers are essentially independent state machines, managed by a single AnimationManager. Each maintains a set of possible "steady states" - main states that the layer can be in. The layer can only be in one state at any given time. It may transition between states, provided that a path is defined for transition from the current state to the desired one. *
new
AnimationLayer
(nameid)
name :: string Name of layer
id :: string Id of layer

Instance methods

getStates() -> string[]
Get available states for layer
setState(stateKeystate)
Add a state to the layer with the associated stateKey
stateKey :: string
state :: SteadyState
setBlendWeight(weight)
Sets the blend weight of a layer. This will not affect the base layer in the animation component.
weight :: number Should be between 0 and 1 and will be clamped
getTransitions() -> string[]
Get available transitions for current State
transitionTo(stateglobalTimefinishCallback) -> boolean
Transition the layer to another state. The transition must be specified either on the state or on the layer (as a general transition), see FileFormat spec for more info
state :: string
globalTime :: number optional default = World.time start time for the transition, defaults to current time
finishCallback :: Function If the target state has a limited number of repeats, this callback is called when the animation finishes.
setCurrentState(staterewindglobalTimefinishCallback)
Sets the current state to the given state. Generally for transitional state use.
state :: AbstractState our new state. If null, then no state is currently set on this layer.
rewind :: boolean optional default = false if true, the clip(s) in the given state will be rewound by setting its start time to the current time and setting it active.
globalTime :: number optional default = World.time start time for the transition, defaults to current time
finishCallback :: Function If the target state has a limited number of repeats, this callback is called when the animation finishes.
getCurrentState() -> AbstractState
Get the current state
setCurrentStateById(idrewindglobalTimecallback)
Set the current state by state id.
id :: string
rewind :: boolean optional default = false if true, the clip(s) in the given state will be rewound by setting its start time to the current time and setting it active.
globalTime :: number optional default = World.time start time for the transition, defaults to current time
callback :: Function If the target state has a limited number of repeats, this callback is called when the animation finishes.
getStateById(id) -> AbstractState
Get the current state by id.
id :: string
getStateByName(name) -> AbstractState
Get the current state by name.
name :: string
setCurrentStateByName(stateNamerewindglobalTime) -> boolean
Force the current state of the machine to the state with the given name.
stateName :: AbstractState the name of our state. If null, or is not present in this state machine, the current state is not changed.
rewind :: boolean if true, the clip(s) in the given state will be rewound by setting its start time to the current time and setting it active.
globalTime :: number optional default = World.time start time for the transition, defaults to current time
clearCurrentState()
Set the currently playing state on this layer to null.
resetClips(globalTime)
shiftClipTime(shiftTime)
setTimeScale(timeScale)

LayerLerpBlender

goo/animationpack/layer/LayerLerpBlender (requires animationpack.js)
A layer blender that uses linear interpolation to merge the results of two layers.
new
LayerLerpBlender
()

Instance methods

AbstractState

goo/animationpack/state/AbstractState (requires animationpack.js)
Base class for a state in our animation system
new
AbstractState
()

Instance methods

resetClips(globalTime)
shiftClipTime(shiftTime)

AbstractTransitionState extends AbstractState

goo/animationpack/state/AbstractTransitionState (requires animationpack.js)
An abstract transition state that blends between two other states.
new
AbstractTransitionState
()

Instance methods

update(globalTime)
Update this state using the current global time.
globalTime :: number the current global time.
readFromConfig(config)
Method for setting fade time and blend type from config data.
configuration :: Object data
isValid(timeWindowglobalTime) -> boolean
Check if a transition is valid within a given time window.
timeWindow :: Array start and end time
current :: number world time
resetClips(globalTime)
shiftClipTime(shiftTime)
setTimeScale(timeScale)

FadeTransitionState extends AbstractTransitionState

goo/animationpack/state/FadeTransitionState (requires animationpack.js)
A transition that blends over a given time from one animation state to another, beginning the target clip from local time 0 at the start of the transition. This is best used with two clips that have similar motions.
new
FadeTransitionState
()

Instance methods

update(globalTime)
Update this state using the current global time.
globalTime :: the current global time.
layer :: the layer this state belongs to.
postUpdate()
Post update. If the state has no more clips and no end transition, this will clear this state from the layer.
layer :: the layer this state belongs to.
resetClips(globalTime)
shiftClipTime(shiftTime)

FrozenTransitionState

goo/animationpack/state/FrozenTransitionState (requires animationpack.js)
A two state transition that freezes the starting state at its current position and blends that over time with a target state. The target state moves forward in time during the blend as normal.
new
FrozenTransitionState
()

Instance methods

update(globalTime)
Update this state using the current global time.
globalTime :: number the current global time.
postUpdate()
Post update. If the state has no more clips and no end transition, this will clear this state from the layer.
layer :: the layer this state belongs to.
resetClips(globalTime)
Resets the clips to start at given time
globalTime :: number
shiftClipTime(shiftTime)

SteadyState extends AbstractState

goo/animationpack/state/SteadyState (requires animationpack.js)
A "steady" state is an animation state that is concrete and stand-alone (vs. a state that handles transitioning between two states, for example.)
new
SteadyState
(name)
name :: string Name of state

Instance methods

setClipSource(clipSource)
Sets the clipsource of the steadystate
update(globalTime)
resetClips(globalStartTime)
shiftClipTime(shiftTime)
setTimeScale(timeScale)

SyncFadeTransitionState

goo/animationpack/state/SyncFadeTransitionState (requires animationpack.js)
A transition that blends over a given time from one animation state to another, synchronizing the target state to the initial state's start time. This is best used with two clips that have similar motions.
new
SyncFadeTransitionState
(targetStatefadeTimethe)
targetState :: the name of the steady state we want the Animation Layer to be in at the end of the transition.
fadeTime :: the amount of time we should take to do the transition.
the :: StateBlendType way we should interpolate the weighting during the transition.

Instance methods

resetClips(globalTime)
shiftClipTime(shiftTime)

AnimationSystem extends System

goo/animationpack/systems/AnimationSystem (requires animationpack.js)
Processes all entities with animation components, updating the animations
new
AnimationSystem
()

Instance methods

BoundingVolumeMeshBuilder

goo/debugpack/BoundingVolumeMeshBuilder (requires debugpack.js)
Provides methods for building bounding volume debug meshes
new
BoundingVolumeMeshBuilder
()

Static methods

buildBox(boundingBox)
buildSphere(boundingSphere)
build(boundingVolume)

Debugger

goo/debugpack/Debugger (requires debugpack.js)
The debugger utility class adds a way to "select" entities and run a filtered serializer on them. It can also create a REPL and export the selected entity to global scope to aid in debugging with the browser's web console.
new
Debugger
(exportPickedmaximumDeph)
exportPicked :: boolean optional True if the debugger should create and update window.picked that points to the currently picked entity
maximumDeph :: boolean optional True if the debugger should come with it's own REPL

Instance methods

inject(goo) -> Debugger
Inject the debugger into the engine and create the debug panel
goo :: GooRunner A GooRunner reference

EntityCounter

goo/debugpack/EntityCounter (requires debugpack.js)
The entity counter utility class creates a panel and updates it with data on the systems in the world and how many entities each contains
new
EntityCounter
(skipFrames)
skipFrames :: number optional Sets how many frames should it skip between refreshes

Instance methods

inject(goo) -> EntityCounter
Inject the entity counter into the GooRunner instance and create the entity counter panel
goo :: GooRunner A GooRunner reference

MarkerComponent extends Component

goo/debugpack/components/MarkerComponent (requires debugpack.js)
Holds the necessary data for a marker
new
MarkerComponent
(entity)
entity :: Entity The entity this component is attached to

CameraDebug

goo/debugpack/shapes/CameraDebug (requires debugpack.js)

Instance methods

getMesh(cameraoptions)

Static methods

buildFrustum(camera)
buildCamera()

LightDebug

goo/debugpack/shapes/LightDebug (requires debugpack.js)

Instance methods

getMesh(lightoptions)

MeshRendererDebug

goo/debugpack/shapes/MeshRendererDebug (requires debugpack.js)

Instance methods

SkeletonDebug

goo/debugpack/shapes/SkeletonDebug (requires debugpack.js)

Instance methods

getMesh(pose)

DebugRenderSystem extends System

goo/debugpack/systems/DebugRenderSystem (requires debugpack.js)
Renders entities/renderables using a configurable partitioner for culling
new
DebugRenderSystem
()

Members

doRender :: boolean Only render if set to true

Instance methods

deleted(entity)
process(entitiestpf)
render(renderer)
renderToPick(rendererskipUpdateBuffer)

MarkerSystem extends System

goo/debugpack/systems/MarkerSystem (requires debugpack.js)
Processes all entities with a marker component
new
MarkerSystem
()

Instance methods

process(entities)

Bus

goo/entities/Bus
A generic message bus. Offers ways to receive and subscribe to messages on a hierarchy of channels.
// Listen to an event on the global system bus
function listener() {
    console.log('caught message!');
}
SystemBus.addListener('eventName', listener);

// Emit an event on the bus
SystemBus.emit('eventName');

// Remove the listener after you're done with it
SystemBus.removeListener('eventName', listener);
new
Bus
()

Instance methods

emit(channelsdatastoreEmit)
Sends messages to all listeners with provided callback function.
channels :: string|string[] channel(s) addressed
data :: Object
storeEmit :: boolean optional default = false Store the emit data for transmitting to future listeners
bus.emit('emptyEvent');
bus.emit('eventWithData', data);
bus.emit(['channel1', 'channel2'], data);
addListener(channelNamecallbackretrieveLatestEmit)
Register callback for a channel
channelName :: string
callback :: Function function (data)
retrieveLatestEmit :: boolean optional default = false Retrieve the last emit done before this listener was added (if emitted with storeEmit)
bus.addListener('channel', function (data){
    console.log('Received message with data:', data);
});
removeListener(channelNamecallbackToRemove)
Remove a listener from a channel but not from its children
channelName :: string
callbackToRemove :: function
bus.removeListener('channel', listener);
getLastMessageOn(channelName)
Retrieves the last message sent on a channel. This will only work if message preservation is enabled when emitting.
removeAllOnChannel(channelName)
Removes all listeners on a specific channel
removeChannelAndChildren(channelName)
Removes a channel and its children
removeListenerFromAllChannels(callbackToRemove)
Removes a listener from all channels

Entity

goo/entities/Entity
An Entity is a generic container of data. This data is wrapped in Components, which usually provide isolated features (transforms, geometries, materials, scripts and so on). By setting components to an entity, the entity will get the functionality provided by the components. For example, an entity with a TransformComponent and a LightComponent will be a light source in 3D space. Note that when attaching components to an entity, methods of the component will be injected into the entity, extending its interface.
new
Entity
(worldnameid)
world :: World The World this entity will be part of after calling .addToWorld().
name :: string optional Entity name.
id :: number optional Entity id.

Members

skip :: boolean Set to true to skip all processing (rendering, script updating, et cetera) of the entity.
hidden :: boolean Holds the hidden status of the entity. The hidden status will not however propagate to components or child entities.
The usage of this flag changed. Please use entity.hide/show() instead to change the hidden status of the entity and entity.isHidden/isVisiblyHidden() to query the status
isVisible :: boolean True if the entity is within the frustum
static :: boolean Mark entity as static. Non static entities become roots in the tree of combined ones so one can have statics under a moving node that combines but you can still move the parent node.

Instance methods

set() -> Entity
Sets components on the entity or tries to create and set components out of the supplied parameters.
// Create three entities with different components, add them to world
var sphereEntity = new Entity(world).set(sphere, material, [2, 0, 0]).addToWorld();
var lightEntity = new Entity(world).set(light, [0, 1, 0]).addToWorld();
var spinningEntity = new Entity(world).set(box, material, [-2, 0, 0], script).addToWorld();
addToWorld(recursive) -> Entity
Add the entity to the world, making it active and processed by systems and managers.
recursive :: boolean optional default = true Add children of the transform hierarchy recursively.
removeFromWorld(recursive) -> Entity
Remove entity from the world.
recursive :: boolean optional default = true Remove children of the transform hierarchy recursively.
setComponent(component) -> Entity
Set component of a certain type on entity. The operation has no effect if the entity already contains a component of the same type.
component :: Component Component to set on the entity.
hasComponent(type) -> boolean
Checks if a component of a specific type is present or not.
type :: string Type of component to check for (eg. 'meshDataComponent').
getComponent(type) -> Component
Retrieve a component of a specific type.
type :: string Type of component to retrieve (eg. 'transformComponent').
clearComponent(type) -> Entity
Remove a component of a specific type from entity.
type :: string Type of component to remove (eg. 'meshDataComponent').
setTag(tag) -> Entity
Adds a tag to the entity.
tag :: string
var banana = world.createEntity().setTag('fruit').setTag('green');
hasTag(tag) -> boolean
Checks whether an entity has a tag or not.
tag :: string
if (banana.hasTag('yellow')) {
    console.log('The banana is yellow');
}
clearTag(tag) -> Entity
Clears a tag on an entity.
tag :: string
// Remove 'alive' tag if hit points drops to zero
if (hero.getAttribute('hit-points') <= 0) {
    hero.clearTag('alive');
}
setAttribute(attributevalue) -> Entity
Sets an attribute and its value on the entity.
attribute :: string
value ::
// Create an entity with tags and attributes, and add it to world
var hero = world.createEntity()
                .setTag('hero')
                .setAttribute('hit-points', 30)
                .setAttribute('attack-power', 3)
                .setTag('alive')
                .addToWorld();
hasAttribute(attribute) -> boolean
Checks whether an entity has an attribute or not.
attribute :: string
getAttribute(attribute) -> *
Gets the value of the specified attribute.
attribute :: string
// Check hit points on monster entity
if (monster.getAttribute('hit-points') <= 0) {
    console.log('The hero triumphs!');
}
clearAttribute(attribute) -> Entity
Clears an attribute of the entity.
attribute :: string
toString() -> string
setTranslation(translation) -> Entity
Sets the translation of this entity. Injected on entities with a transformComponent
translation :: Vector3|number[]
setRotation(angle) -> Entity
Sets the rotation of this entity. Injected on entities with a transformComponent
angle :: Vector3|number[]
setScale(scale) -> Entity
Sets the scale of this entity. Injected on entities with a transformComponent
scale :: Vector3|number[]
lookAt(lookAtPoint) -> Entity
Orients the entity so it faces the supplied look at point. Injected on entities with a transformComponent
lookAtPoint :: Vector3|number[]
move(translation) -> Entity
Translates the entity with the supplied amount multipled by the entity's orientation. Injected on entities with a transformComponent
translation :: Vector3|number[]
getTranslation() -> Vector3
Returns the local translation of the entity. Injected on entities with a transformComponent
getRotation() -> Vector3
Returns the local rotation of the entity. Injected on entities with a transformComponent
getScale() -> Vector3
Returns the local scale of the entity. Injected on entities with a transformComponent
addTranslation(translation) -> Entity
Translates the entity with the given amount. Injected on entities with a transformComponent
translation :: Vector3|number[]
addRotation(rotation) -> Entity
Rotates the entity with the given amount. Injected on entities with a transformComponent
rotation :: Vector3|number[]
attachChild(childEntitykeepTransform) -> Entity
Attaches the supplied entity to this entity as a child. Injected on entities with a transformComponent
childEntity :: Entity
keepTransform :: boolean If enabled will preserve the world transform of the child entity
detachChild(childEntitykeepTransform) -> Entity
Detaches the supplied entity from this entity. Injected on entities with a transformComponent
childEntity :: Entity
keepTransform :: boolean If enabled will preserve the world transform of the child entity
children() -> EntitySelection
Returns an EntitySelection of the children of this entity. Injected on entities with a transformComponent
parent() -> EntitySelection
Returns an EntitySelection of the parent of this entity. Injected on entities with a transformComponent
traverse(callbacklevel) -> Entity
Traverses the entity hierarchy downwards starting from this entity and applies a function to all entities traversed. Traversal can be stopped if the function returns 'false'. Injected on entities with a transformComponent
callback :: function (entity: Entity, level: number) -> boolean The function to be applied to traversed entities. Takes an entity and the current deph level and returns a boolean.
level :: number optional default = 0
traverseUp(callback) -> Entity
Traverses the entity hierarchy upwards starting from this entity and applies a function to all entities traversed. Traversal can be stopped if the function returns 'false'. Injected on entities with a transformComponent
callback :: function (entity: Entity) -> boolean The function to be applied to traversed entities. Takes an entity and returns a boolean.
hide() -> Entity
Hides the entity and its children. Injected on entities with a transformComponent
show() -> Entity
Clears the hidden flag on this entity. The entity may still not show if it has a hidden ancestor. Injected on entities with a transformComponent
isVisiblyHidden() -> boolean
Returns whether the entity or any of its ancestors are hidden. Injected on entities with a transformComponent
isHidden() -> boolean
Returns the 'hidden' status of this entity. The entity may still be hidden if one of its ancestors is hidden. Injected on entities with a transformComponent

EntitySelection extends Selection

goo/entities/EntitySelection
A specialised selection object for entities
new
EntitySelection
()

Instance methods

and() -> EntitySelection
Adds entities to this selection. Any resulting duplicates are removed.
entities :: Entity|Entity[]|EntitySelection The entities to add
intersects() -> EntitySelection
Returns the common entities between this selection and the given parameter(s)
entities :: Entity|Entity[]|EntitySelection
without() -> EntitySelection
Removes entities from the current selection
entities :: Entity|Entity[]|EntitySelection Entities to remove from the selection
andSelf() -> EntitySelection
Adds the previous selection to the current selection. Resulting duplicates are removed.
parent() -> EntitySelection
Returns the parents of all entities in this selection
children() -> EntitySelection
Returns the children of all entities in this selection

EntityUtils

goo/entities/EntityUtils
Utilities for entity creation etc Only used to define the class. Should never be instantiated.
new
EntityUtils
()

Static methods

clone(worldentitysettings) -> Entity
Clone entity hierarchy with optional settings for sharing data and callbacks.
world :: World
entity :: Entity The entity to clone
settings :: Object optional
settings.shareMeshData :: boolean optional default = false Cloning entities clones their mesh data by default
settings.shareMaterials :: boolean optional default = false Cloning entities clones their materials by default
settings.shareUniforms :: boolean optional default = false Cloning entities clones their materials' uniforms by default
settings.shareTextures :: boolean optional default = false Cloning entities clones their materials' textures by default
settings.callback :: function (entity: Entity) optional Callback to be run on every new entity. Takes entity as argument. Runs bottom to top in the cloned hierarchy.
    var clonedEntity = EntityUtils.clone(world, entity, {
        shareMeshData: false,
        shareMaterials: false,
        shareUniforms: false,
        shareTextures: false
    });
getRoot(entity) -> Entity
Traverse the entity hierarchy upwards, returning the root entity
entity :: Entity The entity to begin traversing from
getTotalBoundingBox(entity)
Returns the merged bounding box of the entity and its children

GooRunner

goo/entities/GooRunner
The main class that updates the world and calls the renderers. See this engine overview article for more info.
new
GooRunner
(parameters)
parameters :: Object optional GooRunner settings passed in a JSON object
parameters.alpha :: boolean optional default = false Specifies if the canvas should have an alpha channel or not.
parameters.premultipliedAlpha :: boolean optional default = true Enables or disables premultiplication of color by alpha
parameters.antialias :: boolean optional default = true Specifies if antialiasing should be turned on or no
parameters.stencil :: boolean optional default = false Enables the stencil buffer
parameters.preserveDrawingBuffer :: boolean optional default = false By default the drawing buffer will be cleared after it is presented to the HTML compositor. Enable this option to not clear the drawing buffer
parameters.canvas :: HTMLCanvasElement optional If not supplied, Renderer will create a new canvas
parameters.showStats :: boolean optional default = false If enabled a small stats widget showing stats will be displayed
parameters.useDevicePixelRatio :: boolean optional default = false Take into account the device pixel ratio (for retina screens etc)
parameters.manuallyStartGameLoop :: boolean optional default = false By default the 'game loop' will start automatically. Enable this option to manually start the game loop at any time
parameters.logo :: boolean|string|{ position?, color? } optional default = 'topright' Specifies whether the Goo logo is visible or not and where should and be placed and what color should it have. If the parameter is not specified then the logo is placed in the top right corner. If no logo is desired then this parameter should have the 'false' value. If the supplied parameter is one of the following: 'topleft', 'topright', 'bottomleft', 'bottomright' then the logo will be positioned in the according corner If the parameter is of type object then the logo will be positioned according to the 'position' key and will be colored according to the 'color' key
parameters.tpfSmoothingCount :: boolean optional default = 10 Specifies the amount of previous frames to use when computing the 'time per frame'
parameters.debugKeys :: boolean optional default = false If enabled the hotkeys Shift+[1..6] will be enabled
parameters.useTryCatch :: boolean optional default = true

Members

world :: World The Goo world.
renderer :: Renderer Automatically created renderer.
useTryCatch :: boolean Set to true to run user-defined callbacks within try/catch statements. Errors will be printed to console.
callbacksPreProcess :: function (tpf: number)[] A list of callbacks to call every frame, before the world is processed.
callbacksPreRender :: function (tpf: number)[] A list of callbacks to call every frame, after the world is processed and before the rendering is done.
callbacks :: function (tpf: number)[] A list of callbacks to call every frame, after the rendering is done.
callbacksNextFrame :: function (tpf: number)[] A list of callbacks to call once, in the following frame, before the world is processed.

Instance methods

addEventListener(typecallback)
Adds an event listener to the GooRunner.
type :: string Can currently be 'click', 'mousedown', 'mousemove', 'mouseup', 'touchstart', 'touchend' or 'touchmove'.
callback :: function (event: ?) Callback function.
callback.event.entity :: Entity Picked entity, undefined if no entity is picked.
callback.event.intersection :: Vector3 Point of pick ray intersection with scene.
callback.event.depth :: number Depth of pick ray intersection.
callback.event.x :: number Canvas x coordinate.
callback.event.y :: number Canvas y coordinate.
callback.event.type :: string Type of triggered event ('mousedown', 'touchstart', etc).
callback.event.domEvent :: Event Original DOM event.
callback.event.id :: number Entity pick ID. -1 if no entity was picked.
gooRunner.addEventListener('mousedown', function (event) {
  if (event.entity) {
    console.log('clicked entity', event.entity.name);
    console.log('clicked point', event.intersection);
  }
});
removeEventListener(typecallback)
Removes an event listener from the GooRunner.
type :: string Can currently be 'click', 'mousedown', 'mousemove', 'mouseup', 'touchstart', 'touchend' or 'touchmove'.
callback :: function (event: ?) Callback to remove from event listener.
triggerEvent(typeevt)
Triggers an event on the GooRunner (force).
type :: string Can currently be 'click', 'mousedown', 'mousemove', 'mouseup', 'touchstart', 'touchend' or 'touchmove'.
evt :: Object The GooRunner-style event
evt.entity :: Entity Event entity.
evt.x :: number Event canvas X coordinate.
evt.y :: number Event canvas Y coordinate.
evt.domEvent :: Event The original DOM event.
startGameLoop()
Starts the game loop (done through requestAnimationFrame).
stopGameLoop()
Stops the game loop.
takeSnapshot(callback)
Takes an image snapshot from the 3d scene at next render call.
callback :: Function
pick(xycallbackskipUpdateBuffer)
Requests a pick from screen space coordinates. A successful pick returns id and depth of the pick target.
x :: number screen coordinate
y :: number screen coordinate
callback :: Function to handle the pick result
skipUpdateBuffer :: boolean when true picking will be attempted against existing buffer
pickSync(xyskipUpdateBuffer)
Pick, the synchronous method. Uses the same pickbuffer so it will affect asynch picking. Also goes only through the normal render system.
x :: number screen coordinate
y :: number screen coordinate
skipUpdateBuffer :: boolean when true picking will be attempted against existing buffer
clear()
Clears the GooRunner and anything associated with it. Once this method is called this instanceof of GooRunner is unusable.
addStats()
Adds a small stats widget showing fps, rendercalls, vertices, indices, transform updates and cached shaders
removeStats()
Removes stats widget

Selection

goo/entities/Selection
Generic selection class
new
Selection
()

Instance methods

contains(element) -> boolean
Returns true if the selection contains a specific element
size() -> number
Returns the size of this selection
each(fun) -> Selection
Applies a function on each element until `false` is returned
fun :: Function The function to apply
filter(predicate) -> Selection
Applies a filter on the elements of this selection
predicate :: The filter used for filtering
map(fun) -> Selection
Applies a function on the elements of this selection producing a new collection
fun :: The function to apply to each element
reduce(funinitialValue) -> Selection
Reduces the entire selection to a single element by applying a function on every element and an accumulated value
fun :: The function used to reduce the selection
initialValue :: The value used for the first call of `fun`
and() -> Selection
Adds elements to this selection. Any resulting duplicates are removed.
elements :: Element|Element[]|Selection The element(s) to add
intersects() -> Selection
Returns the common elements between this selection and the given parameter(s)
elements :: Element|Element[]|Selection
without() -> Selection
Removes elements from the current selection
Elements :: Element|Element[]|Selection to remove from the selection
andSelf() -> Selection
Adds the previous selection to the current selection. Resulting duplicates are removed.
end() -> Selection
Discards the last operation done on the selection
first() -> Element
Returns the first object of the selection
clone() -> Selection
Clones the selection and its history
get(index) -> Array
Returns the element on the specified position or the whole selection as an array if position is not given
index :: number optional Index of the desired element; can handle negative indices (Ex: -1 is the last element)
toArray() -> Array
Returns the selection as an array

World

goo/entities/World
Main handler for an entity world. The World keeps track of managers and systems, and also provides methods to create, select and remove entities. Note that process() has to be called manually if objects need to be added and retrieved within the same update loop. See this engine overview article for more info.
new
World
(options)
options :: object optional
options.gooRunner :: GooRunner optional
options.tpfSmoothingCount :: boolean optional default = 10 Specifies the amount of previous frames to use when computing the 'time per frame'

Members

gooRunner :: GooRunner GooRunner for updating the world and calling the renderers.
time :: number Accumulated time per frames(tpf) the world has been running. Calculated at the start of each frame.
fixedTpfTime :: number Current fixed step accumulated time.
fixedTpf :: number The fixed time step to use for physics and other fixed-updates.
maxSubSteps :: number Max fixed steps to use for the fixed update loop.
tpf :: number Time since last frame in seconds.
smoothedTpf :: number The tpf, averaged by a number of samples.
interpolationTime :: number Interpolation alpha time value: a number between 0 and 1. Use to interpolate between two fixed updates from the frame update.
tpfSmoothingCount :: number Number of samples to use for smoothing the tpf.
entityManager :: EntityManager Main keeper of entities.

Instance methods

add() -> World
Universal shorthand for adding managers, systems, entities and registering components. Arguments can be of types Entity, Manager, System or Component and added in any order or combination.
entity :: Entity optional
manager :: Manager optional
system :: System optional
component :: Component optional
// Add two entities and register a component, all in one swoop
var entity1 = new Entity(gooRunner.world, 'Entity 1');
var entity2 = new Entity(gooRunner.world, 'Entity 2');
var animationComponent = new AnimationComponent();
gooRunner.world.add(entity1, animationComponent, entity2);
registerComponent(componentConstructor) -> World
Registers a component type. This is necessary to allow automatic creation of components from 'basic' data types (CameraComponents from Cameras, MeshRendererComponents from materials and so on). When a GooRunner is created, it registers TransformComponent, MeshDataComponent, MeshRendererComponent, CameraComponent, LightComponent and ScriptComponent automatically.
componentConstructor :: Component
// Register the animation component type so that animations
// can be automatically created.
gooRunner.world.registerComponent(AnimationComponent);
setManager(manager) -> World
Adds a Manager to the world.
manager :: Manager
getManager(type) -> Manager
Retrieves a Manager of a certain type.
type :: string Type of manager to retrieve eg. 'EntityManager'.
setSystem(system) -> World
Adds a System to the world.
system :: System
getSystem(type) -> System
Retrieve a System of type 'type'.
type :: string Type of system to retrieve.
clearSystem(type) -> World
Removes the System of type 'type'. Entities tracked by the removed system will not get handled properly when they are removed from the world or when their components (that are tracked by this system) change.
type :: string Type of system to remove.
createEntity() -> Entity
Creates a new Entity with an optional MeshData, MeshRenderer, Camera, Script and Light component, placed optionally at a location. Parameters can be given in any order.
meshData :: MeshData optional
material :: Material optional
name :: string optional
camera :: Camera optional
light :: Light optional
// Create a sphere entity and add it to the world
var sphereEntity = world.createEntity(new Sphere(32, 32), material, [0, 0, 5]).addToWorld();
// Create a camera entity and add it to the world
var cameraEntity = world.createEntity(new Camera(), [0, 0, 3]).lookAt(new Vector3(0, 0, 0)).addToWorld();
getEntities() -> Entity[]
Get an array of all entities in world.
addEntity(entityrecursive) -> World
Add an Entity to the world.
entity :: Entity Entity to add.
recursive :: boolean optional default = true If entity hierarchy should be added recursively.
removeEntity(entityrecursive) -> World
Remove an Entity from the world.
entity :: Entity Entity to remove.
recursive :: boolean optional default = true If entity hierarchy should be removed recursively.
changedEntity(entitycomponenteventType)
Let the world and its systems know that an entity has been changed/updated.
processEntityChanges()
Processes newly added entities, changed entities and removed entities
update(tpf)
Update the world. This will run process and fixedUpdate.
tpf :: number Time since last called, in seconds.
fixedUpdate()
Do a fixed time update of all systems.
process()
Process all added/changed/removed entities and callback to active systems and managers. Usually called automatically each frame. Has to be called between adding an entity to the world and getting it back.
clear()
Calls .clear on all systems that support this method

CameraComponent extends Component

goo/entities/components/CameraComponent
Holds a camera.
new
CameraComponent
(camera)
camera :: Camera Camera to contain in this component.

Members

camera :: Camera The camera contained by the component.
leftVec :: Vector3 Left vector.
upVec :: Vector3 Up vector.
dirVec :: Vector3 Direction vector.

Instance methods

setUpVector(axisId)
axisId :: number Axis to use as up-vector (0=X, 1=Y, 2=Z).
updateCamera(transform)
Updates the contained camera according to a transform (coming from the TransformComponent).
transform :: Transform
copy(source)

Static methods

applyOnEntity(objentity)

Component

goo/entities/components/Component
Base class/module for all components. Should not be used directly.
new
Component
()

Members

enabled :: boolean If the component should be processed for containing entities.
entity :: Entity|null The entity the component is added to.
debugLevel :: string Debug level for the component. Can be 'none', 'normal' or 'full'. None will prevent the rendering of any debug meshes for the component.

Instance methods

attached()
Called when the component was added to an entity
entity :: Entity
detached()
Called when the component was removed from an entity
entity :: Entity

Static methods

applyOnEntity() -> boolean
Should be implemented in the same way in subclasses. Will be called by the World for each argument to world.createEntity(arg0, arg1, ...). If this function returns true, it indicates that the passed argument was used and should not be passed to other components. See World.prototype.createEntity.
argument ::
entity :: Entity
applyEntitySelectionAPI(entitySelectionAPIcomponentType)

CssTransformComponent extends Component

goo/entities/components/CssTransformComponent
Connects a domElement to an entity and applies the transformComponent of the entity to the domElement with CSS3 3D transforms.
new
CssTransformComponent
(domElementfaceCamera)
domElement :: domElement
faceCamera :: boolean

Members

domElement DOM element.
scale :: number
faceCamera :: boolean

Dom3dComponent extends Component

goo/entities/components/Dom3dComponent
Connects a domElement to an entity and applies the transforms of the entity to the domElement with CSS3 3D transforms.
Example: Working example
new
Dom3dComponent
(domElementsettings)
domElement :: domElement
settings :: Object

Members

hidden :: boolean

Instance methods

attached(entity)
detached(entity)
initDom(domElement)
setSize(widthheight)
destroy(context)

HtmlComponent extends Component

goo/entities/components/HtmlComponent
Adds a 2D DOM element to the entity, that can move with its transform.
Example: Working example
new
HtmlComponent
(domElementoptions)
domElement :: DOMElement
options :: object optional
options.hidden :: boolean optional default = false
options.useTransformComponent :: boolean optional default = true
options.pixelPerfect :: boolean optional default = true

Members

domElement DOM element.
hidden :: boolean
useTransformComponent :: boolean Move with the screen position of the entity.
pixelPerfect :: boolean Snap to integer pixel positions.

LightComponent extends Component

goo/entities/components/LightComponent
Defines a light
Example: Working example
new
LightComponent
(light)
light :: Light Light to contain in this component (directional, spot, point)

Members

light Light contained in this component.
hidden :: boolean

Instance methods

updateLight(transform)
copy(source)

Static methods

applyOnEntity(objentity)

MeshDataComponent extends Component

goo/entities/components/MeshDataComponent
Holds the mesh data, like vertices, normals, indices etc. Also defines the local bounding volume.
Example: Working example
new
MeshDataComponent
(meshData)
meshData :: MeshData Target mesh data for this component.

Members

meshData :: MeshData
modelBound :: BoundingVolume Bounding volume in local space.
modelBoundDirty :: boolean
currentPose :: SkeletonPose

Instance methods

setModelBound(modelBoundsetBoundsDirty)
Set the bounding volume type (sphere, box etc).
modelBound :: BoundingVolume Bounding to apply to this meshdata component.
setBoundsDirty :: boolean optional default = true Whether to set modelBoundDirty=true.
computeBoundFromPoints()
Compute bounding center and bounds for this mesh.
clone(options) -> MeshDataComponent
Returns a clone of this mesh data component
options :: Object optional
options.shareMeshData :: boolean optional default = false Cloning this component clones the mesh data by default

Static methods

applyOnEntity(objentity)

MeshRendererComponent extends Component

goo/entities/components/MeshRendererComponent
Defines the appearance of a mesh, through materials. Using several materials results in multi-pass rendering.
Example: Working example
new
MeshRendererComponent
()

Members

materials :: Material[] Materials to use when rendering
worldBound :: BoundingVolume Worldspace bounding considering entity transformations
cullMode :: string Culling mode. Other valid values: 'Never'
castShadows :: boolean
receiveShadows :: boolean
isPickable :: boolean
isReflectable :: boolean
hidden :: boolean

Instance methods

updateBounds(boundingtransform)
Update world bounding
bounding :: BoundingVolume Bounding volume in local space
transform :: Transform Transform to apply to local bounding -> world bounding
clone(options) -> MeshRendererComponent
Returns a clone of this mesh renderer component
options :: Object optional
options.shareMaterials :: boolean optional default = false Cloning this component clones the materials by default

Static methods

applyOnEntity(objentity)

MovementComponent extends Component

goo/entities/components/MovementComponent
Holds the movement parameters of an entity. Typically useful for anything which has a speed and/or rotation.
new
MovementComponent
()

Instance methods

addVelocity(vec3)
Adds velocity to movement. Typically useful for things such as gravity and slingshots.
vec3 :: Vector3 velocity impulse vector.
setVelocity(vec3)
Adds velocity to movement. Typically useful for things such as gravity and slingshots.
vec3 :: Vector3 velocity impulse vector.
getVelocity() -> Vector3
Reads the movement velocity vector
addRotationVelocity(vec3)
Adds rotational velocity to movement. Typically useful for spinning or turning things.
vec3 :: Vector3 rotational velocity impulse vector.
setRotationVelocity(vec3)
Sets rotational velocity of the movement.
vec3 :: Vector3 rotational velocity vector.
getRotationVelocity() -> Vector3
Read the rotational velocity of movement

ParticleComponent extends Component

goo/entities/components/ParticleComponent
Creates and modifies MeshData to simulate particle effects.

ParticleComponents may have one or more emitters. Each emitter spawns particles, controlling spawn rate, lifetime, initial velocity vector and position of each particle. Each Particle System also contains a timeline describing changes each particle should perform over its lifetime, including:
  • Size of particle
  • Color of particle
  • Orientation of particle (rotation on screen plane)
  • Texture coords used.
  • Other user defined params.

External influences can exert on particles via a defined callback function system.

Particles billboard toward the screen using a provided Camera as reference.
new
ParticleComponent
(settings)
settings :: Object optional
settings.emitters :: Array optional Array of emitter settings
settings.timeline :: Array optional
settings.uRange :: number optional default = 1
settings.vRange :: number optional default = 1
settings.particleCount :: number optional default = 100

Instance methods

recreateParticles(particleCount)

PortalComponent extends Component

goo/entities/components/PortalComponent
Renders to the texture of the host object
Example: Working example
new
PortalComponent
(cameraheightoptionsoverrideMaterial)
camera :: Camera The camera used for rendering
height :: number optional default = 200 Height of the texture to render to (the width is calculated automatically from the camera's aspect ratio)
options :: Object
options.autoUpdate :: boolean optional default = true If set to true then updating is done every frame, otherwise updating is done only when solicited via the `requestUpdate` method
options.preciseRecursion :: boolean optional default = false By default the "portal depth" (the number of portals seen through a portal) is of 4. By enabling this option the limitation disappears, but at the cost of using more memory.
overrideMaterial :: Material optional default = null Optional override material to use when rendering to the host object

Members

camera :: Camera
target :: RenderTarget

Instance methods

requestUpdate()
Requests a rendering to be done to the material of the host object

ScriptComponent extends Component

goo/entities/components/ScriptComponent
Contains scripts to be executed each frame when set on an active entity.
new
ScriptComponent
(scripts)
scripts :: Object|Object[] optional A script-object or an array of script-objects to attach to the entity. The script-object needs to define the function run(Entity entity, number tpf), which runs on every frame update. The script object can also define the function setup(Entity entity), called upon script creation.

Members

scripts :: Array Array of scripts tied to this script component. Scripts can be added to the component using the constructor or by manually adding to the array.

Instance methods

startScripts()
Enables all the scripts that are in the component.
stopScripts()
Disables all the scripts that are in the component.

SoundComponent extends {Component}

goo/entities/components/SoundComponent
Component that adds sound to an entity.
Example: Working example
new
SoundComponent
()

Members

sounds :: Sound[] Current sounds in the entity. Add a sound using {@link SoundComponent#addSound}.

Instance methods

addSound(sound)
Add a sound to the component
sound :: Sound
removeSound(sound)
Remove sound from component
sound :: Sound
getSoundById(id) -> Sound
Get a component's sound by id
id :: string
connectTo(nodes)
Connect output of component to audionodes
nodes :: Object optional
nodes.dry :: AudioNode optional
nodes.wet :: AudioNode optional
updateConfig(config)
Updates the component valueas according to config
config :: Object optional
config.volume :: number optional A number between 0 and 1.
config.reverb :: number optional A number between 0 and 1.

TextComponent

goo/geometrypack/text/TextComponent (requires geometrypack.js)
Stores a font and handles the text mesh on an entity Depends on opentype.js
new
TextComponent
()

Instance methods

attached(entity)
setFont(font) -> TextComponent
Set the font of this component
font :: The font loaded through opentype.js
setText(textoptions) -> TextComponent
Set the text to generate the mesh for; recomputes the mesh
text :: string
options :: Object optional
options.extrusion :: number optional default = 4 Extrusion amount
options.fontSize :: number optional default = 48
options.stepLength :: number optional default = 1 Lower values result in a more detailed mesh

TransformComponent extends Component

goo/entities/components/TransformComponent
Holds the transform of an entity. It also allows for a scene graph to be created, in which transforms are inherited down the tree.
Example: Working example
new
TransformComponent
()

Members

parent :: TransformComponent Parent TransformComponent in the "scene graph".
children :: TransformComponent[] Child TransformComponents in the "scene graph".
transform :: Transform The entity's transform in local space.
worldTransform :: Transform readonly The entity's transform in world space.

Instance methods

getTranslation() -> Vector3
Returns the local translation vector. Do not modify the returned value, use .setTranslation() instead.
var translation = entity.transformComponent.getTranslation();
getWorldTranslation() -> Vector3
Returns the world translation vector. Do not modify the returned value, use .setTranslation() instead.
var worldTranslation = entity.transformComponent.getWorldTranslation();
setTranslation() -> TransformComponent
Set the local translation vector.
translation :: Vector|number[]
entity.transformComponent.setTranslation(1, 1, 0);
entity.transformComponent.setTranslation(new Vector3(1, 1, 0));
entity.transformComponent.setTranslation([1, 1, 0]);
addTranslation() -> TransformComponent
Adds to this transform's local translation.
Component :: Vector|number[] values.
entity.transformComponent.addTranslation(1, 2, 1);
entity.transformComponent.addTranslation(new Vector3(1, 2, 1));
entity.transformComponent.addTranslation([1, 2, 1]);
getScale() -> Vector3
Get the local transform scale. Do not modify the returned value, use .setScale() instead.
var scale = entity.transformComponent.getScale();
getWorldScale() -> Vector3
Get the world transform scale. Do not modify the returned value, use .setScale() instead.
var scale = entity.transformComponent.getWorldScale();
setScale() -> TransformComponent
Sets this transform local scale.
Component :: Vector|number[] values.
entity.transformComponent.setScale(1, 1, 0);
entity.transformComponent.setScale(new Vector3(1, 1, 0));
entity.transformComponent.setScale([1, 1, 0]);
getRotationMatrix() -> Matrix3
Returns the local rotation matrix. Do not modify the returned value, use .setRotationMatrix() instead.
var matrix = entity.transformComponent.getRotationMatrix();
setRotationMatrix(matrix) -> TransformComponent
Sets the local rotation matrix.
entity.transformComponent.setRotationMatrix(new Matrix3());
getWorldRotationMatrix() -> Matrix3
Returns the world rotation matrix. Do not modify the returned value, use .setRotationMatrix() instead.
var worldRotation = entity.transformComponent.getWorldRotationMatrix();
getRotation(target) -> Vector3
Gets the local rotation in Euler angles (in radians, Euler order YZX).
target :: Vector3 optional Target vector for storage. If not provided, a new vector object will be created and returned.
var localRotation = entity.transformComponent.getRotation(); // warning: creates a new Vector3 object
var localRotation2 = new Vector3();
entity.transformComponent.getRotation(localRotation2); // stores the result without creating a new object
addRotation() -> TransformComponent
Adds to this transform's rotation using Euler angles (in radians, Euler order YZX).
Component :: Vector|number[] values.
entity.transformComponent.addRotation(Math.PI / 4, 0, 0);
entity.transformComponent.addRotation(new Vector3(Math.PI / 4, 0, 0));
entity.transformComponent.addRotation([Math.PI / 4, 0, 0]);
setRotation() -> TransformComponent
Sets this transform's rotation around X, Y and Z axis (in radians, Euler order YZX). The rotation is applied in X, Y, Z order.
Component :: Vector|number[] values.
entity.transformComponent.setRotation(Math.PI / 4, 0, 0);
entity.transformComponent.setRotation(new Vector3(Math.PI / 4, 0, 0));
entity.transformComponent.setRotation([Math.PI / 4, 0, 0]);
lookAt(positionup) -> TransformComponent
Sets the transform to look in a specific direction.
Injected into entity when adding component.
position :: Vector3|Entity Target position.
up :: Vector3 optional default = (0, 1, 0) Up vector.
// Omitted up vector assumes Y is up:
entity.transformComponent.lookAt(1, 2, 3);
entity.transformComponent.lookAt([1, 2, 3]);
entity.transformComponent.lookAt(new Vector3(1, 2, 3));
entity.transformComponent.lookAt(otherEntity);

// However, you can pass the up vector as well:
entity.transformComponent.lookAt([1, 2, 3], [0, 1, 0]);
entity.transformComponent.lookAt(new Vector3(1, 2, 3), new Vector3(0, 1, 0));
entity.transformComponent.lookAt(otherEntity, new Vector3(0, 1, 0));
setUpdated()
Mark the component for updates of world transform. Needs to be called after manually changing the transform without using helper functions.
attachChild(childComponentkeepTransform)
Attach a child transform to this component tree
Injected into entity when adding component.
childComponent :: TransformComponent Child transform component to attach
keepTransform :: boolean optional default = false If enabled, the child's position, rotation and scale will appear unaffected
detachChild(childComponentkeepTransform)
Detach a child transform from this component tree.
Injected into entity when adding component.
childComponent :: TransformComponent child transform component to detach
keepTransform :: boolean optional default = false If enabled, the child's position, rotation and scale will appear unaffected
updateTransform()
Update component's transform.

Static methods

applyOnEntity(objentity)

EntityManager extends Manager

goo/entities/managers/EntityManager
Main handler of all entities in the world.
new
EntityManager
()

Members

api Entity selector. Its methods return an EntitySelection. Can select by id or name, see examples for usage.
Injected into World.

Instance methods

added(entity)
removed(entity)
containsEntity(entity) -> boolean
Checks if an entity exists
entity :: Entity to check for
getEntityById(id) ->
Retrieve an entity based on an id
id :: Id to retrieve entity for
getEntityByIndex(index) ->
Retrieve an entity based on an index
index :: Index to retrieve entity for
getEntityByName(name) ->
Retrieve an entity based on its name
name :: Name to retrieve entity for
size() -> number
Get the number of entities currently indexed by the Entity Manager
getEntities() -> Array
Get all entities in the world
getTopEntities() -> Array
Get all entities on top level based on the transform scenegraph
clear()
Removes all entities

Manager

goo/entities/managers/Manager
Base class for managers.
new
Manager
()

Instance methods

applyAPI(worldBy)

BoundingUpdateSystem extends System

goo/entities/systems/BoundingUpdateSystem
Calculates and updates all boundings on entities with both transform, meshrenderer and meshdata components
new
BoundingUpdateSystem
()

Instance methods

process(entities)
getWorldBound(callback)
deleted(entity)

CameraSystem extends System

goo/entities/systems/CameraSystem
Updates cameras/cameracomponents with their transform component transforms
new
CameraSystem
()

Instance methods

findMainCamera()
Sets the Renderer's main camera to be the first camera of the CameraComponents in the currently active entities of this system.
inserted(entity)

CssTransformSystem extends System

goo/entities/systems/CssTransformSystem
new
CssTransformSystem
()

Instance methods

process(entities)

Dom3dSystem extends System

goo/entities/systems/Dom3dSystem
Example: Working example
new
Dom3dSystem
()

Instance methods

setStyle(elementpropertystyle)
inserted(entity)

GridRenderSystem extends System

goo/entities/systems/GridRenderSystem
Renders entities/renderables using a configurable partitioner for culling
new
GridRenderSystem
()

Members

doRender :: boolean Only render if set to true

Instance methods

render(renderer)

HtmlSystem extends System

goo/entities/systems/HtmlSystem
Example: Working example
new
HtmlSystem
()

Instance methods

setStyle(elementpropertystyledoPrefix)
process(entities)
deleted(entity)

LightingSystem extends System

goo/entities/systems/LightingSystem
Processes all entities with a light component making sure that lights are placed according to its transforms
Example: Working example
new
LightingSystem
()

Instance methods

setOverrideLights(overrideLights)
Replaces the lights tracked by the system with custom ones.
clearOverrideLights()
Disables overriding of lights tracked by the system
inserted(entity)
process(entities)

MovementSystem extends System

goo/entities/systems/MovementSystem
Processes all entities with movement components. This system applies movement vectors for translation and rotation to the transform of the entity which has it every frame.
new
MovementSystem
()

Instance methods

addVelocityToTransform(veltransformtpf)
addRotToTransform(rotVeltransformtpf)
process(entities)

ParticlesSystem extends System

goo/entities/systems/ParticlesSystem
Manages and reacts to particle components on entities.
new
ParticlesSystem
()

Instance methods

process(entitiestpf)
updateParticles(particleEntityparticleComponenttpf)

PickingSystem extends System

goo/entities/systems/PickingSystem
Helps gather pickable entities
new
PickingSystem
()

Instance methods

setPickLogic(pickLogic)
inserted(entity)
deleted(entity)
process(entities)

PipRenderSystem extends System

goo/entities/systems/PipRenderSystem
Renders transform gizmos
Example: Working example
new
PipRenderSystem
()

Members

doRender :: boolean Only render if set to true

Instance methods

updateQuad(quadxywidthheight)
render(renderer)

PortalSystem extends System

goo/entities/systems/PortalSystem
Processes all entities with a portal component, a mesh renderer component and a mesh data component
Example: Working example
new
PortalSystem
(rendererrenderSystem)
renderer :: Renderer
renderSystem :: RenderSystem

Instance methods

process(entities)
render(renderercameratargetoverrideMaterial)

RenderSystem extends System

goo/entities/systems/RenderSystem
Renders entities/renderables using a configurable partitioner for culling
new
RenderSystem
()

Members

doRender :: boolean Only render if set to true

Instance methods

pick(xycallbackskipUpdateBuffer)
inserted(entity)
deleted(entity)
process(entitiestpf)
render(renderer)
renderToPick(rendererskipUpdateBuffer)
enableComposers(activate)

ScriptSystem extends System

goo/entities/systems/ScriptSystem
Processes all entities with script components, running the scripts where applicable
new
ScriptSystem
()

Instance methods

fixedUpdate(entitiesfixedTpf)
process(entitiestpf)
addedComponent(entitycomponent)
removedComponent(entitycomponent)

SoundSystem extends System

goo/entities/systems/SoundSystem
System responsible for sound.
Example: Working example
new
SoundSystem
()

Members

rolloffFactor :: number readonly
maxDistance :: number readonly
volume :: number readonly
reverb :: number readonly
muted :: boolean readonly The muted state. To mute or unmute, see the mute() and unmute() methods.

Instance methods

updateConfig(config)
Update the environmental sound system properties. The settings are applied on the next process().
config :: Object optional
config.rolloffFactor :: number optional How fast the sound fades with distance.
config.maxDistance :: number optional After this distance, sound will keep its volume.
config.volume :: number optional Will be clamped between 0 and 1.
config.reverb :: number optional Will be clamped between 0 and 1.
config.muted :: boolean optional
setReverb(audioBuffer)
Set the reverb impulse response. The settings are not applied immediately.
audioBuffer :: AudioBuffer optional if empty will also empty existing reverb
pause()
Pause the sound system and thereby all sounds in the scene
mute()
Mute all sounds.
unmute()
Unmute all sounds.
resume()
Resumes playing of all sounds that were paused
play()
Resumes playing of all sounds that were paused.
stop()
Stopping the sound system and all sounds in scene
process(entitiestpf)

System

goo/entities/systems/System
Creates a new System Base class for all entity systems
  • interests = null -> listen to all entities
  • interests = [] -> don't listen to any entities
  • interests = ['coolComponent', 'testComponent'] -> listen to entities that contains at minimum 'coolComponent' and 'testComponent'
See this engine overview article for more info.
new
System
(typeinterests)
type :: string System type name as a string
interests :: String[] Array of component types this system is interested in

Members

world :: World
type :: string
interests :: array
passive :: boolean
priority :: number Priority of a system. The lower the number the higher the priority is. By default a systems has priority 0. Internal goo systems (like TransformSystem and CameraSystem) should have negative priority.
type :: string System type
interests :: Array Array of component types this system is interested in

Instance methods

process()
Called on each render frame, if the system is not passive.
entities :: array
tpf :: number
fixedUpdate()
Called on each physics tick, if the system is not passive.
entities :: array
fixedTpf :: number
inserted()
Called when an entity is added to the world and systems need to be informed. To be implemented in subclasses.
deleted()
Called when an entity is remove from the world and systems need to be informed. To be implemented in subclasses.
changed(entity)
Called when an entity gets/loses components
removed(entity)
Called when an entity is removed from the world
setup(world)
Called when the system is added to the world. This method is called automatically when the system is added to a world. By default it will go through all entities accounted by the entity manager and try to add them to this system.
world :: World
cleanup()
Called when the system is removed from the world. By default it will call the deleted method on all entities it is keeping track of.
onPreRender()
Called before the scene is being rendered
onPostRender()
Called after the scene is being rendered

TextSystem extends System

goo/entities/systems/TextSystem
Processes all entities with a text component
Example: Working example
new
TextSystem
()

Instance methods

process(entities)

TransformSystem extends System

goo/entities/systems/TransformSystem
Processes all entities with transform components, making sure they are up to date and valid according to the "scenegraph"
Example: Working example
new
TransformSystem
()

Instance methods

MachineHandler extends ConfigHandler

goo/fsmpack/MachineHandler (requires fsmpack.js)
Handler for loading materials into engine
new
MachineHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

StateMachineComponentHandler extends ComponentHandler

goo/fsmpack/StateMachineComponentHandler (requires fsmpack.js)
For handling loading of state machine components
new
StateMachineComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine statemachine component object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

ProximityComponent

goo/fsmpack/proximity/ProximityComponent (requires fsmpack.js)
new
ProximityComponent
()

Instance methods

attached(entity)
detached(entity)

ProximitySystem extends System

goo/fsmpack/proximity/ProximitySystem (requires fsmpack.js)
Processes all entities with a proximity component
new
ProximitySystem
(rendererrenderSystem)
renderer :: Renderer
renderSystem :: RenderSystem

Instance methods

getFor(tag)
add(entitytag)
remove(entitytag)

FsmUtils

goo/fsmpack/statemachine/FsmUtils (requires fsmpack.js)

Static methods

setParameters(settingsexternalParameters)
setTransitions(settingsexternalTransitions)
getKey(str)
keyForCode(code)
guid()
getValue(parfsm)

Machine

goo/fsmpack/statemachine/Machine (requires fsmpack.js)

Instance methods

setRefs(parentFSM)
contains(uuid)
setState(state)
addState(state)
setInitialState(initialState)

State

goo/fsmpack/statemachine/State (requires fsmpack.js)

Instance methods

setRefs(parentFSM)
setTransition(eventNametarget)
clearTransition(eventName)
addAction(action)
removeAction(action)
addMachine(machine)
removeMachine(machine)

StateMachineComponent

goo/fsmpack/statemachine/StateMachineComponent (requires fsmpack.js)
StateMachineComponent
new
StateMachineComponent
()

Instance methods

defineVariable(nameinitialValue)
addMachine(machine)
removeMachine(machine)
getMachineById(id)
Gets the state machine with the specified identifier.
id :: string The identifier of the machine which is to be returned.
init()
Resets all state machines to their initial state
kill()
Kills the state machines triggering exit functions in all current states
cleanup()
Performs a cleanup; undoes any changes not undone by exit methods
update()
Updates the state machines
pause()
Stops updating the state machines
play()
Resumes updating the state machines

Static methods

getVariable(name)
applyOnVariable(namefun)
applyOnVariable(namefun)

StateMachineSystem

goo/fsmpack/statemachine/StateMachineSystem (requires fsmpack.js)
Processes all entities with a FSM component
new
StateMachineSystem
()

Members

time :: number Current time, in seconds.

Instance methods

process(entitiestpf)
inserted(entity)
play()
Resumes updating the entities
pause()
Stops updating the entities
stop()
Stop updating entities and resets the state machines to their initial state

Action

goo/fsmpack/statemachine/actions/Action (requires fsmpack.js)
new
Action
(idsettings)
id :: string
settings :: Object

Instance methods

configure(settings)

AddLightAction

goo/fsmpack/statemachine/actions/AddLightAction (requires fsmpack.js)

Instance methods

enter(fsm)
cleanup(fsm)

AddPositionAction

goo/fsmpack/statemachine/actions/AddPositionAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

AddVariableAction

goo/fsmpack/statemachine/actions/AddVariableAction (requires fsmpack.js)

Instance methods

add(fsm)
enter(fsm)
update(fsm)

ApplyForceAction

goo/fsmpack/statemachine/actions/ApplyForceAction (requires fsmpack.js)

Instance methods

enter(fsm)

ApplyImpulseAction

goo/fsmpack/statemachine/actions/ApplyImpulseAction (requires fsmpack.js)

Instance methods

enter(fsm)

ApplyTorqueAction

goo/fsmpack/statemachine/actions/ApplyTorqueAction (requires fsmpack.js)

Instance methods

enter(fsm)

ArrowsAction

goo/fsmpack/statemachine/actions/ArrowsAction (requires fsmpack.js)

Instance methods

configure(settings)
enter(fsm)

Static methods

getTransitionLabel(transitionKey)

ClickAction

goo/fsmpack/statemachine/actions/ClickAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel()

CollidesAction

goo/fsmpack/statemachine/actions/CollidesAction (requires fsmpack.js)

Instance methods

ready(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

CompareCounterAction

goo/fsmpack/statemachine/actions/CompareCounterAction (requires fsmpack.js)

Instance methods

compare(fsm)
enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKeyactionConfig)

CompareCountersAction

goo/fsmpack/statemachine/actions/CompareCountersAction (requires fsmpack.js)

Instance methods

compare(fsm)
enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKeyactionConfig)

CompareDistanceAction

goo/fsmpack/statemachine/actions/CompareDistanceAction (requires fsmpack.js)

Instance methods

compare(fsm)
enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

CopyJointTransformAction

goo/fsmpack/statemachine/actions/CopyJointTransformAction (requires fsmpack.js)

Instance methods

update(fsm)

CopyVariableAction

goo/fsmpack/statemachine/actions/CopyVariableAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)
copy(fsm)

DollyZoomAction

goo/fsmpack/statemachine/actions/DollyZoomAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel()

DomEventAction

goo/fsmpack/statemachine/actions/DomEventAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKeyactionConfig)

EmitAction

goo/fsmpack/statemachine/actions/EmitAction (requires fsmpack.js)

Instance methods

EvalAction

goo/fsmpack/statemachine/actions/EvalAction (requires fsmpack.js)

Instance methods

update(fsm)

FireAction

goo/fsmpack/statemachine/actions/FireAction (requires fsmpack.js)

Instance methods

enter(fsm)

GetPositionAction

goo/fsmpack/statemachine/actions/GetPositionAction (requires fsmpack.js)

Instance methods

configure(settings)
update(fsm)

HideAction

goo/fsmpack/statemachine/actions/HideAction (requires fsmpack.js)

Instance methods

enter(fsm)

HoverEnterAction

goo/fsmpack/statemachine/actions/HoverEnterAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel()

HoverExitAction

goo/fsmpack/statemachine/actions/HoverExitAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel()

HtmlAction

goo/fsmpack/statemachine/actions/HtmlAction (requires fsmpack.js)

Instance methods

enter(fsm)
exit(fsm)

Static methods

getTransitionLabel()

InBoxAction

goo/fsmpack/statemachine/actions/InBoxAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

InFrustumAction

goo/fsmpack/statemachine/actions/InFrustumAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

IncrementCounterAction

goo/fsmpack/statemachine/actions/IncrementCounterAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)
cleanup(fsm)

KeyDownAction

goo/fsmpack/statemachine/actions/KeyDownAction (requires fsmpack.js)

Instance methods

configure(settings)
enter(fsm)

Static methods

getTransitionLabel(transitionKeyactionConfig)

KeyPressedAction

goo/fsmpack/statemachine/actions/KeyPressedAction (requires fsmpack.js)

Instance methods

configure(settings)
enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKeyactionConfig)

KeyUpAction

goo/fsmpack/statemachine/actions/KeyUpAction (requires fsmpack.js)

Instance methods

configure(settings)
enter(fsm)

Static methods

getTransitionLabel(transitionKeyactionConfig)

LogMessageAction

goo/fsmpack/statemachine/actions/LogMessageAction (requires fsmpack.js)

Instance methods

LookAtAction

goo/fsmpack/statemachine/actions/LookAtAction (requires fsmpack.js)

Instance methods

doLookAt(fsm)
enter(fsm)
update(fsm)

MouseDownAction

goo/fsmpack/statemachine/actions/MouseDownAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

MouseMoveAction

goo/fsmpack/statemachine/actions/MouseMoveAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

MousePressedAction

goo/fsmpack/statemachine/actions/MousePressedAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKeyactionConfig)

MouseUpAction

goo/fsmpack/statemachine/actions/MouseUpAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

MoveAction

goo/fsmpack/statemachine/actions/MoveAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

MultiplyVariableAction

goo/fsmpack/statemachine/actions/MultiplyVariableAction (requires fsmpack.js)

Instance methods

update(fsm)

MuteAction

goo/fsmpack/statemachine/actions/MuteAction (requires fsmpack.js)

Instance methods

enter(fsm)

NextFrameAction

goo/fsmpack/statemachine/actions/NextFrameAction (requires fsmpack.js)

Instance methods

update(fsm)

Static methods

getTransitionLabel(transitionKey)

NumberCompareAction

goo/fsmpack/statemachine/actions/NumberCompareAction (requires fsmpack.js)

Instance methods

configure(settings)
compare(fsm)
enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

PauseAnimationAction

goo/fsmpack/statemachine/actions/PauseAnimationAction (requires fsmpack.js)

Instance methods

enter(fsm)

PauseParticleSystemAction

goo/fsmpack/statemachine/actions/PauseParticleSystemAction (requires fsmpack.js)

Instance methods

enter(fsm)

PauseSoundAction

goo/fsmpack/statemachine/actions/PauseSoundAction (requires fsmpack.js)

Instance methods

enter(fsm)

PauseTimelineAction

goo/fsmpack/statemachine/actions/PauseTimelineAction (requires fsmpack.js)

Instance methods

enter(fsm)

PickAction

goo/fsmpack/statemachine/actions/PickAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

PickAndExitAction

goo/fsmpack/statemachine/actions/PickAndExitAction (requires fsmpack.js)

Instance methods

enter(fsm)

PlaySoundAction

goo/fsmpack/statemachine/actions/PlaySoundAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

RandomTransitionAction

goo/fsmpack/statemachine/actions/RandomTransitionAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

RemoveAction

goo/fsmpack/statemachine/actions/RemoveAction (requires fsmpack.js)

Instance methods

enter(fsm)

RemoveLightAction

goo/fsmpack/statemachine/actions/RemoveLightAction (requires fsmpack.js)

Instance methods

enter(fsm)

RemoveParticlesAction

goo/fsmpack/statemachine/actions/RemoveParticlesAction (requires fsmpack.js)

Instance methods

enter(fsm)

ResumeAnimationAction

goo/fsmpack/statemachine/actions/ResumeAnimationAction (requires fsmpack.js)

Instance methods

enter(fsm)

RotateAction

goo/fsmpack/statemachine/actions/RotateAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

ScaleAction

goo/fsmpack/statemachine/actions/ScaleAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

ScriptAction

goo/fsmpack/statemachine/actions/ScriptAction (requires fsmpack.js)

Instance methods

ready(fsm)

SetAnimationAction

goo/fsmpack/statemachine/actions/SetAnimationAction (requires fsmpack.js)

Instance methods

update(fsm)

Static methods

getTransitionLabel(transitionKey)

SetAnimationOffsetAction

goo/fsmpack/statemachine/actions/SetAnimationOffsetAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetClearColorAction

goo/fsmpack/statemachine/actions/SetClearColorAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetCounterAction

goo/fsmpack/statemachine/actions/SetCounterAction (requires fsmpack.js)

Instance methods

enter(fsm)
cleanup(fsm)

SetHtmlTextAction

goo/fsmpack/statemachine/actions/SetHtmlTextAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetLightPropertiesAction

goo/fsmpack/statemachine/actions/SetLightPropertiesAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetLightRangeAction

goo/fsmpack/statemachine/actions/SetLightRangeAction (requires fsmpack.js)

Instance methods

configure(settings)

SetMaterialColorAction

goo/fsmpack/statemachine/actions/SetMaterialColorAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetPositionAction

goo/fsmpack/statemachine/actions/SetPositionAction (requires fsmpack.js)

Instance methods

configure(settings)
update(fsm)

SetRenderTargetAction

goo/fsmpack/statemachine/actions/SetRenderTargetAction (requires fsmpack.js)

Instance methods

ready(fsm)
enter(fsm)
cleanup(fsm)

SetRigidBodyAngularVelocityAction

goo/fsmpack/statemachine/actions/SetRigidBodyAngularVelocityAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetRigidBodyPositionAction

goo/fsmpack/statemachine/actions/SetRigidBodyPositionAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetRigidBodyRotationAction

goo/fsmpack/statemachine/actions/SetRigidBodyRotationAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetRigidBodyVelocityAction

goo/fsmpack/statemachine/actions/SetRigidBodyVelocityAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetRotationAction

goo/fsmpack/statemachine/actions/SetRotationAction (requires fsmpack.js)

Instance methods

configure(settings)
enter(fsm)
update(fsm)

SetTimeScaleAction

goo/fsmpack/statemachine/actions/SetTimeScaleAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetTimelineTimeAction

goo/fsmpack/statemachine/actions/SetTimelineTimeAction (requires fsmpack.js)

Instance methods

enter(fsm)

SetVariableAction

goo/fsmpack/statemachine/actions/SetVariableAction (requires fsmpack.js)

Instance methods

enter(fsm)

ShakeAction

goo/fsmpack/statemachine/actions/ShakeAction (requires fsmpack.js)

Instance methods

configure(settings)
enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

ShowAction

goo/fsmpack/statemachine/actions/ShowAction (requires fsmpack.js)

Instance methods

enter(fsm)

SmokeAction

goo/fsmpack/statemachine/actions/SmokeAction (requires fsmpack.js)

Instance methods

enter(fsm)

SoundFadeInAction

goo/fsmpack/statemachine/actions/SoundFadeInAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

SoundFadeOutAction

goo/fsmpack/statemachine/actions/SoundFadeOutAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

SpriteAnimationAction

goo/fsmpack/statemachine/actions/SpriteAnimationAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel()

StartParticleSystemAction

goo/fsmpack/statemachine/actions/StartParticleSystemAction (requires fsmpack.js)

Instance methods

enter(fsm)

StartTimelineAction

goo/fsmpack/statemachine/actions/StartTimelineAction (requires fsmpack.js)

Instance methods

enter(fsm)

StopParticleSystemAction

goo/fsmpack/statemachine/actions/StopParticleSystemAction (requires fsmpack.js)

Instance methods

enter(fsm)

StopSoundAction

goo/fsmpack/statemachine/actions/StopSoundAction (requires fsmpack.js)

Instance methods

enter(fsm)

StopTimelineAction

goo/fsmpack/statemachine/actions/StopTimelineAction (requires fsmpack.js)

Instance methods

enter(fsm)

SwitchCameraAction

goo/fsmpack/statemachine/actions/SwitchCameraAction (requires fsmpack.js)

Instance methods

enter(fsm)

TagAction

goo/fsmpack/statemachine/actions/TagAction (requires fsmpack.js)

Instance methods

enter(fsm)
cleanup(fsm)

ToggleFullscreenAction

goo/fsmpack/statemachine/actions/ToggleFullscreenAction (requires fsmpack.js)

Instance methods

ToggleMuteAction

goo/fsmpack/statemachine/actions/ToggleMuteAction (requires fsmpack.js)

Instance methods

enter(fsm)

TogglePostFxAction

goo/fsmpack/statemachine/actions/TogglePostFxAction (requires fsmpack.js)

Instance methods

enter(fsm)

TransitionAction

goo/fsmpack/statemachine/actions/TransitionAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

TransitionOnMessageAction

goo/fsmpack/statemachine/actions/TransitionOnMessageAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKeyactionConfig)

TriggerEnterAction

goo/fsmpack/statemachine/actions/TriggerEnterAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

TriggerLeaveAction

goo/fsmpack/statemachine/actions/TriggerLeaveAction (requires fsmpack.js)

Instance methods

enter(fsm)

Static methods

getTransitionLabel(transitionKey)

TweenLightColorAction

goo/fsmpack/statemachine/actions/TweenLightColorAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

TweenLookAtAction

goo/fsmpack/statemachine/actions/TweenLookAtAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

TweenMaterialColorAction

goo/fsmpack/statemachine/actions/TweenMaterialColorAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKeyactionConfig)

TweenMoveAction

goo/fsmpack/statemachine/actions/TweenMoveAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

TweenOpacityAction

goo/fsmpack/statemachine/actions/TweenOpacityAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

TweenRotationAction

goo/fsmpack/statemachine/actions/TweenRotationAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

TweenScaleAction

goo/fsmpack/statemachine/actions/TweenScaleAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

TweenTextureOffsetAction

goo/fsmpack/statemachine/actions/TweenTextureOffsetAction (requires fsmpack.js)

Instance methods

enter(fsm)
update(fsm)

Static methods

getTransitionLabel(transitionKey)

UnmuteAction

goo/fsmpack/statemachine/actions/UnmuteAction (requires fsmpack.js)

Instance methods

enter(fsm)

WaitAction extends Action

goo/fsmpack/statemachine/actions/WaitAction (requires fsmpack.js)
new
WaitAction
()

Members

currentTime :: number Current time, in milliseconds.
totalWait :: number Wait time, in milliseconds.

Instance methods

update(fsm)

Static methods

getTransitionLabel(transitionKey)

WasdAction

goo/fsmpack/statemachine/actions/WasdAction (requires fsmpack.js)

Instance methods

configure(settings)
enter(fsm)

Static methods

getTransitionLabel(transitionKey)

FilledPolygon

goo/geometrypack/FilledPolygon (requires geometrypack.js)
A polygon shape
Example: Working example
new
FilledPolygon
(vertsindices)
verts :: Array Array of vertices
indices :: Array Array of indices

Instance methods

rebuild() -> FilledPolygon
Builds or rebuilds the mesh data.

PolyLine

goo/geometrypack/PolyLine (requires geometrypack.js)
A polygonal line
new
PolyLine
(vertsclosed)
verts :: number[] optional The vertices data array
closed :: boolean optional default = false True if its ends should be connected

Instance methods

rebuild() -> PolyLine
Builds or rebuilds the mesh data
mul(rhs) -> Surface
Builds a surface as a result of multiplying 2 polyLines
rhs :: PolyLine The second operand
pipe(polyLineoptions) -> Surface
Extrudes and rotates a PolyLine along another PolyLine.
that :: PolyLine The PolyLine to extrude; should be bidimensional and defined on the XY plane.
options :: Object optional
options.scale :: function (number: ?) -> number optional Takes values between 0 and 1; the returned value is used to scale the extruded PolyLine
options.twist :: function (number: ?) -> number optional Takes values between 0 and 1; the returned value is used to twist the extruded PolyLine along the tangent of the extruding PolyLine. The twist value is expressed in radians.
lathe(nSegments) -> Surface
Builds a surface as a result of rotating this polyLine around the Y axis
nSegments :: number optional default = 8 The number of segments for the resulting surface
concat(thatclosed) -> PolyLine
Returns a new polyLine as a result of concatenating the 2 polyLines
that :: PolyLine The other operand
closed :: boolean optional True if the resulting polyLine should be closed

Static methods

fromCubicBezier(vertsnSegmentsstartFraction) -> PolyLine
Creates a polyLine that approximates a given cubic Bezier curve
verts :: number[] optional The Bezier curve control vertices. This array must contain exactly 12 elements (4 control points with 3 coordinates each)
nSegments :: number optional default = 16 The number of segments (higher values result in smoother curves)
fromQuadraticSpline(vertsnSegmentsclosed)
fromCubicSpline(vertsnSegmentsclosed) -> PolyLine
Creates a polyLine that approximates a given cubic spline
verts :: number[] optional The spline control vertices. This array must contain exactly 3 * number_of_control_points (+ 1 if the spline is open) elements
nSegments :: number optional default = 16 The number of segments for each Bezier curve that forms the spline (higher values result in smoother curves)
closed :: boolean optional default = false True if the spline should be closed or not

RegularPolygon

goo/geometrypack/RegularPolygon (requires geometrypack.js)
Regular polygon mesh
new
RegularPolygon
()

Surface

goo/geometrypack/Surface (requires geometrypack.js)
A grid-like surface shape
new
Surface
(vertsverticesPerLine)
verts :: number[] The vertices data array
verticesPerLine :: number optional default = 2 The number of vertices

Instance methods

rebuild() -> Surface
Builds or rebuilds the mesh data

Static methods

createFromHeightMap(heightMapxScaleyScalezScale) -> Surface
Create a Surface from a supplied height map in the form of a matrix
heightMap :: number[] optional The height map
xScale :: number optional default = 1
yScale :: number optional default = 1
zScale :: number optional default = 1
Working example
createTessellatedFlat(xSizezSizexCountzCount) -> Surface
Create a tessellated Surface typically useful for a waterplane to reduce z-fighting
xSize :: number x axis size in units
zSize :: number z axis size in numbers
xCount :: number x axis vertex count
zCount :: number z axis vertex count
Working example

Triangle

goo/geometrypack/Triangle (requires geometrypack.js)
Only creates an attributeMap with MeshData.POSITION and MeshData.NORMAL.
new
Triangle
(verts)
verts :: number[] array with 9 elements. These 9 elements must be 3 x, y, z positions.

Instance methods

rebuild() -> Triangle
Builds or rebuilds the mesh data.

TextComponentHandler extends ComponentHandler

goo/geometrypack/text/TextComponentHandler (requires geometrypack.js)
For handling loading of text components
new
TextComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function.
updateObject :: Function The handler function.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine textComponent object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

DynamicLoader

goo/loaders/DynamicLoader
Class to load objects into the engine, or to update objects based on the data model.
new
DynamicLoader
(options)
options :: Object
options.world :: World The target World object.
options.rootPath :: string The root path from where to get resources.
options.ajax :: Ajax optional default = new Ajax(options.rootPath) Can be used to overwrite how the loader fetches refs. Good for testing.

Instance methods

preload(bundleclear)
Load configs into the loader cache without loading anything into the engine. Subsequent calls to load and update will draw configs from the prefilled cache.
configs :: Object Configs object. Keys should be refs, and values are the config objects. If a config is null, the loader will search for the appropriate config in the loader's internal cache.
clear :: boolean optional default = false If true, possible previous cache will be cleared. Otherwise the existing cache is extended.
clear() -> RSVP.Promise
Clears the cache of all the handlers. Also clears the engine.
load(refoptions) -> RSVP.Promise
Load an object with the specified path into the engine. The object can be of any type, what loading does is determined by the ref type and the registered ConfigHandler.
ref :: string Ref of object to load.
options :: Object
options.progressCallback :: function (handled: ?, total: ?) optional Function called while loading the world. Arguments handled and total are both integer numbers and represent the loaded elements so far as well as the total elements.
options.preloadBinaries :: boolean optional default = false Load the binary data as soon as the reference is loaded.
options.noCache :: boolean optional default = false Ignore cache, i.e. always load files fresh from the server.
update(refconfigoptions) -> RSVP.Promise
Update an object in the world with an updated config. The object can be of any type, updating behavior is determined by the registered {ConfigHandler}.
ref :: string Ref of object to update.
config :: Object optional New configuration (formatted according to data model). If omitted, works the same as {DynamicLoader.load}.
options :: Object
options.noCache :: boolean optional default = false Ignore cache, i.e. always load files fresh from the server.
remove(ref)

Static methods

getTypeForRef(ref) -> string
Gets the type of a reference.
ref :: string Reference.

CrunchLoader

goo/loaders/crunch/CrunchLoader
new
CrunchLoader
()

Instance methods

arrayBufferCopy(srcdstdstByteOffsetnumBytes)
load(arrayBuffertextureflipped)
dxtToRgb565(srcsrc16Offsetwidthheight) -> Uint16Array
Transcodes DXT into RGB565. Optimizations: 1. Use integer math to compute c2 and c3 instead of floating point math. Specifically: c2 = 5/8 * c0 + 3/8 * c1 c3 = 3/8 * c0 + 5/8 * c1 This is about a 40% performance improvement. It also appears to match what hardware DXT decoders do, as the colors produced by this integer math match what hardware produces, while the floating point in dxtToRgb565Unoptimized() produce slightly different colors (for one GPU this was tested on). 2. Unroll the inner loop. Another ~10% improvement. 3. Compute r0, g0, b0, r1, g1, b1 only once instead of twice. Another 10% improvement. 4. Use a Uint16Array instead of a Uint8Array. Another 10% improvement.
src :: Uint16Array The src DXT bits as a Uint16Array.
srcByteOffset :: number
width :: number
height :: number

DdsLoader

goo/loaders/dds/DdsLoader
Loads dds format images into a format usable by Goo.
new
DdsLoader
()

Instance methods

load(buffertexflippedarrayByteOffsetarrayByteLength)

Static methods

updateDepth(imageinfo)
readDXT(imgDatatotalSizeinfotexture)
readUncompressed(imgDatatotalSizeuseRgbuseLumuseAlphauseAlphaPixelsinfotexture)
populate(textureinfodata)

DdsUtils

goo/loaders/dds/DdsUtils

Static methods

isSupported()
shiftCount(mask) ->
Get the necessary bit shifts needed to align mask with 0.
mask :: the bit mask to test
isSet(valuebitMask) ->
Check a value against a bit mask to see if it is set.
value :: the value to check
bitMask :: our mask
getIntFromString(string) ->
Get the string as a dword int value.
string :: our string... should only be 1-4 chars long. Expected to be 1 byte chars.
getIntFromBytes(bytes) ->
Get the byte array as a dword int value.
bytes :: our array... should only be 1-4 bytes long.
getComponents(format)
flipDXT(rawDatawidthheightformat) ->
Flip a dxt mipmap/image. Inspired by similar code in opentk and the nvidia sdk.
rawData :: our unflipped image as raw bytes
width :: our image's width
height :: our image's height
format :: our image's format
getUInt24(inputoffset)
getBytesFromUInt24(inputoffsetuint24)
flipUInt24(uint24)

CameraComponentHandler extends ComponentHandler

goo/loaders/handlers/CameraComponentHandler
For handling loading of camera components
new
CameraComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine cameracomponent object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

ComponentHandler

goo/loaders/handlers/ComponentHandler
Base class for component handlers. All different types of components that an entity can have need to have a registered component handler. To handle a new type of component, create a class that inherits from this class, and override {_prepare}, {_create}, {update} and {remove} as needed ({update} must be overridden). In your class, call @_register('yourComponentType') to _register the handler with the loader.
new
ComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {DynamicLoader.update}.

Instance methods

update(entityconfig) -> RSVP.Promise
Update engine component object based on the config. Should be overridden in subclasses. This method is called by #{EntityHandler} to load new component configs into the engine.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

Static methods

getHandler(type) -> Class
Get a handler class for the specified type of component. The type can be e.g. 'camera', 'transform', etc. The type name should not end with "Component".
type :: string

ConfigHandler

goo/loaders/handlers/ConfigHandler
Base class for resource handlers, used to load all types of resources into the engine. All the resource types in the bundle (noted by their extension) need to have a registered config handler. To handle a new type of component, create a class that inherits from this class, and override {update}. In your class, call @_register('yourResourceExtension') to _register the handler with the loader.
new
ConfigHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {DynamicLoader.update}.

Instance methods

load(refoptions)
update(refconfigoptions) -> RSVP.Promise
Update engine object based on the config. Should be overridden in subclasses. This method is called by #{DynamicLoader} to load new resources into the engine.
ref :: string The ref of this config
config :: Object

Static methods

getTypeForRef(ref)
getHandler(type) -> Class
Get a handler class for the specified type of resource. The resource can be e.g. 'texture', 'mesh', etc.
type :: string

Dom3dComponentHandler extends ComponentHandler

goo/loaders/handlers/Dom3dComponentHandler
For handling loading of Dom3d components
new
Dom3dComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine cameracomponent object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

EntityHandler extends ConfigHandler

goo/loaders/handlers/EntityHandler
Handler for loading entities into engine
new
EntityHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

EnvironmentHandler

goo/loaders/handlers/EnvironmentHandler
Handling environments
new
EnvironmentHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

HtmlComponentHandler extends ComponentHandler

goo/loaders/handlers/HtmlComponentHandler
For handling loading of HTML components
new
HtmlComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine cameracomponent object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

JsonHandler extends ConfigHandler

goo/loaders/handlers/JsonHandler
Handler for loading json objects.
new
JsonHandler
(worldgetConfigupdateObject )
world :: World
getConfig :: Function
updateObject :: Function

LightComponentHandler extends ComponentHandler

goo/loaders/handlers/LightComponentHandler
For handling loading of light components
new
LightComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine cameracomponent object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

MaterialHandler extends ConfigHandler

goo/loaders/handlers/MaterialHandler
Handler for loading materials into engine
new
MaterialHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

MeshDataComponentHandler extends ComponentHandler

goo/loaders/handlers/MeshDataComponentHandler
For handling loading of meshdatacomponents
new
MeshDataComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine meshdatacomponent object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

MeshDataHandler

goo/loaders/handlers/MeshDataHandler
Handler for meshdata. Will not update, only create once
new
MeshDataHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

MeshRendererComponentHandler extends ComponentHandler

goo/loaders/handlers/MeshRendererComponentHandler
For handling loading of meshrenderercomponents
new
MeshRendererComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine meshrenderercomponent object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

ProjectHandler extends ConfigHandler

goo/loaders/handlers/ProjectHandler
Handler for loading project into engine (actually loading mainScene)
new
ProjectHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

SceneHandler extends ConfigHandler

goo/loaders/handlers/SceneHandler
Handler for loading scene into engine
new
SceneHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

ShaderHandler extends ConfigHandler

goo/loaders/handlers/ShaderHandler
Handler for loading shaders into engine
new
ShaderHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

SkyboxHandler

goo/loaders/handlers/SkyboxHandler

SoundComponentHandler extends ComponentHandler

goo/loaders/handlers/SoundComponentHandler
For handling loading of sound components
new
SoundComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine sound component object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

SoundHandler extends ConfigHandler

goo/loaders/handlers/SoundHandler
Handler for loading sounds into engine
new
SoundHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

TextureHandler extends ConfigHandler

goo/loaders/handlers/TextureHandler
Handler for loading materials into engine
new
TextureHandler
(worldgetConfigupdateObject)
world :: World
getConfig :: Function
updateObject :: Function

TransformComponentHandler extends ComponentHandler

goo/loaders/handlers/TransformComponentHandler
For handling loading of transform component
new
TransformComponentHandler
(worldgetConfigupdateObject)
world :: World The goo world
getConfig :: Function The config loader function. See {@see DynamicLoader._loadRef}.
updateObject :: Function The handler function. See {@see DynamicLoader.update}.

Instance methods

update(entityconfigoptions) -> RSVP.Promise
Update engine transform component object based on the config.
entity :: Entity The entity on which this component should be added.
config :: Object
options :: Object

TgaLoader

goo/loaders/tga/TgaLoader
new
TgaLoader
()

Instance methods

load(buffertex)
Load and parse a TGA file
loadData(data)
Parse TGA data
data :: Uint8Array - Binary data of the TGA file
checkHeader()
Check the header of TGA file to detect errors
parse(data)
Parse data from TGA file
data :: Uint8Array - Binary data of the TGA file
getImageData(imageData) -> imageData
Return a ImageData object from a TGA file
imageData :: imageData - Optional ImageData to work with
getCanvas() -> canvas
Return a canvas with the TGA render on it
getDataURL(type) -> canvas
Return a dataURI of the TGA file
type :: string - Optional image content-type to output (default: image/png)
getImageData8bits(imageDatay_starty_stepy_endx_startx_stepx_end) -> imageData
Return a ImageData object from a TGA file (8bits)
imageData :: imageData - ImageData to bind
y_start :: int - start at y pixel.
x_start :: int - start at x pixel.
y_step :: int - increment y pixel each time.
y_end :: int - stop at pixel y.
x_step :: int - increment x pixel each time.
x_end :: int - stop at pixel x.
getImageData16bits(imageDatay_starty_stepy_endx_startx_stepx_end) -> imageData
Return a ImageData object from a TGA file (16bits)
imageData :: imageData - ImageData to bind
y_start :: int - start at y pixel.
x_start :: int - start at x pixel.
y_step :: int - increment y pixel each time.
y_end :: int - stop at pixel y.
x_step :: int - increment x pixel each time.
x_end :: int - stop at pixel x.
getImageData24bits(imageDatay_starty_stepy_endx_startx_stepx_end) -> imageData
Return a ImageData object from a TGA file (24bits)
imageData :: imageData - ImageData to bind
y_start :: int - start at y pixel.
x_start :: int - start at x pixel.
y_step :: int - increment y pixel each time.
y_end :: int - stop at pixel y.
x_step :: int - increment x pixel each time.
x_end :: int - stop at pixel x.
getImageData32bits(imageDatay_starty_stepy_endx_startx_stepx_end) -> imageData
Return a ImageData object from a TGA file (32bits)
imageData :: imageData - ImageData to bind
y_start :: int - start at y pixel.
x_start :: int - start at x pixel.
y_step :: int - increment y pixel each time.
y_end :: int - stop at pixel y.
x_step :: int - increment x pixel each time.
x_end :: int - stop at pixel x.
getImageDataGrey8bits(imageDatay_starty_stepy_endx_startx_stepx_end) -> imageData
Return a ImageData object from a TGA file (8bits grey)
imageData :: imageData - ImageData to bind
y_start :: int - start at y pixel.
x_start :: int - start at x pixel.
y_step :: int - increment y pixel each time.
y_end :: int - stop at pixel y.
x_step :: int - increment x pixel each time.
x_end :: int - stop at pixel x.
getImageDataGrey16bits(imageDatay_starty_stepy_endx_startx_stepx_end) -> imageData
Return a ImageData object from a TGA file (16bits grey)
imageData :: imageData - ImageData to bind
y_start :: int - start at y pixel.
x_start :: int - start at x pixel.
y_step :: int - increment y pixel each time.
y_end :: int - stop at pixel y.
x_step :: int - increment x pixel each time.
x_end :: int - stop at pixel x.

MathUtils

goo/math/MathUtils
A collection of useful math-related functions, constants and helpers. Only used to define the class. Should never be instantiated.
new
MathUtils
()

Static members

EPSILON :: number
randomSeed :: number

Static methods

radFromDeg(degrees) -> Float
Converts an angle from degrees to radians.
degrees :: Float Angle in degrees.
// converts 70 degrees to a radian
var a = MathUtils.radFromDeg(70);
degFromRad(radians) -> Float
Converts an angle from radians to degrees.
radians :: Float Angle in radians.
// converts Math.PI to 180 degrees
var a = MathUtils.degFromRad(Math.PI);
lerp(factorstartend) -> number
Linearly interpolates between two values. Extrapolates if factor is smaller than zero or greater than one.
factor :: number Factor of interpolation.
start :: number Start value.
end :: number End value.
// earlier in code (outside of the update loop)
var x = 0;
// inside the update loop
x = MathUtils.lerp(tpf, x, 5);
clamp(valueminmax) -> number
Clamps a value to a given interval. The interval is defined by min and max where min should be smaller than max. If min is greater than max, the two parameters are reversed.
value :: number Input value.
min :: number Lower bound of interval (inclusive).
max :: number Upper bound of interval (inclusive).
var a = -1;
a = Math.clamp(a, 0, 9); // a == 0
radialClamp(valueminmax) -> number
Clamps an angle to a given interval. The interval is defined by min and max. If min is larger than max, the clamp will wrap around.
value :: number Input value.
min :: number Lower bound of interval (inclusive).
max :: number Upper bound of interval (inclusive).
var a = -1;
a = Math.radialClamp(a, 0, 9); // a == 0
moduloPositive(valuesize) -> number
Calculates the positive modulo
value :: number
size :: number
scurve3(x) -> number
Computes a value on the c1-continuous cubic s-curve "y = -2x^3 + 3x^2".
x :: number Input value in the range between zero and one.
scurve5(x) -> number
Computes a value on the c2-continuous quintic s-curve "y = 6x^5 - 15x^4 + 10x^3".
x :: number Input value in the range between zero and one.
sphericalToCartesian(radiusazimuthpolarstore)
Converts Spherical coordinates in radians to a Vector3 Cartesian point (using positive Y as up) and stores the results in the store var.
radius :: number (distance)
azimuth :: number (heading)
polar :: number (elevation)
store :: Vector3
var distance = 5;
var heading = 180;
var elevation = 30;
var position = new Vector3();
MathUtils.sphericalToCartesian(distance, heading, elevation, position);
cartesianToSpherical(xyzstore)
Converts a point from Cartesian coordinates to Spherical radian coordinates (using positive Y as up) and stores the results in the store var.
x :: number
y :: number
z :: number
store :: Vector3
var sphericalCoord = new Vector3();
var pos = entity.transformComponent.transform.translation.
MathUtils.cartesianToSpherical(pos.x, pos.y, pos.z, sphericalCoord);
getTriangleNormal(p1xp1yp1zp2xp2yp2zp3xp3yp3z) -> number[]
Computes the normal of a given triangle
P.x :: number
P.y :: number
P.z :: number
Q.x :: number
Q.y :: number
Q.z :: number
R.x :: number
R.y :: number
R.z :: number
isPowerOfTwo(value) -> boolean
Checks if a value is power of two
value :: number Number to check for power of two
nearestPowerOfTwo(value) -> number
Gets the nearest higher power of two for a value
value :: number Number to get the nearest power of two from
closeTo(v1v2tolerance) -> boolean
Returns true if the 2 values supplied are approximately the same
sign(value) -> number
Returns the sign of the supplied parameter
triangleArea(t1t2t3) -> number
Computes the area of a 2D triangle
t1 :: Vector2 First point of the triangle
t2 :: Vector2 Second point of the triangle
t3 :: Vector2 Third point of the triangle
barycentricInterpolation(t1t2t3p) -> Vector3
Computes the height of a point located inside a triangle. Height is assumed to bound to the Z axis.
t1 :: Vector3 First point of the triangle
t2 :: Vector3 Second point of the triangle
t3 :: Vector3 Third point of the triangle
p :: Vector3 The point for which to compute the height
smoothstep(edge0edge1x) -> number
Performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where a threshold function with a smooth transition is desired.
edge0 :: number Specifies the value of the lower edge of the Hermite function.
edge1 :: number Specifies the value of the upper edge of the Hermite function.
x :: number Specifies the source value for interpolation.
fastRandom() -> number
Rough random generation with seeding. Set random seed through MathUtils.randomSeed = {new seed value}

Matrix

goo/math/Matrix
Matrix with RxC components.
new
Matrix
(rowscols)
rows :: number Number of rows.
cols :: number Number of columns.

Members

data :: Float32Array Column-major storage for the matrix components.

Matrix2 extends Matrix

goo/math/Matrix2
Matrix with 2x2 components.
new
Matrix2
(arguments)
arguments :: number... Initial values for the matrix components.

Instance methods

add(rhs) -> Matrix2
Performs a component-wise addition.
rhs :: Matrix2 Matrix or scalar on the right-hand side.
sub(rhs) -> Matrix2
Performs a component-wise subtraction.
rhs :: Matrix2 Matrix or scalar on the right-hand side.
scale(scalar) -> Matrix2
Multiplies this matrix with a scalar
scalar :: number
mul(rhs) -> Matrix2
Multiplies this matrix with another matrix
rhs :: Matrix2 Matrix on the left-hand side
mul2(lhsrhs) -> Matrix2
Multiplies two matrices and stores the result in this matrix
lhs :: Matrix2 Matrix on the left-hand side
rhs :: Matrix2 Matrix on the right-hand side
transpose() -> Matrix2
Transposes a matrix (exchanges rows and columns).
invert() -> Matrix2
Computes the analytical inverse and stores the result locally.
isOrthogonal() -> boolean
Tests if the matrix is orthogonal.
isNormal() -> boolean
Tests if the matrix is normal.
isOrthonormal() -> boolean
Tests if the matrix is orthonormal.
determinant() -> number
Computes the determinant of the matrix.
setIdentity() -> Matrix2
Sets the matrix to identity.
equals(rhs) -> boolean
Compares two matrices for approximate equality
rhs :: Matrix2 The matrix to compare against
copy(rhs) -> Matrix2
Copies component values from another matrix to this matrix
rhs :: Matrix2 Source matrix
setArray(rhsData) -> Matrix2
Sets matrix values from an array.
rhsData :: number[] Array source
clone() -> Matrix2
Returns a new matrix with the same values as the existing one

Static methods

invert(sourcetarget) -> Matrix2
Computes the analytical inverse and stores the result in a separate matrix.
source :: Matrix2 Source matrix.
target :: Matrix2 optional Target matrix.

Matrix3 extends Matrix

goo/math/Matrix3
Matrix with 3x3 components. Used to store 3D rotations. It also contains common 3D Rotation operations. Creates a new Matrix3 by passing in either a current Matrix3, number Array, or a set of 9 numbers.
// Passing in no arguments
var m1 = new Matrix3(); // m1 == (1, 0, 0, 0, 1, 0, 0, 0, 1)

// Passing in a number Array
var m2 = new Matrix3([1, 0, 0, 0, 1, 0, 0, 0, 1]);

// Passing in numbers
var m3 = new Matrix3(1, 0, 0, 0, 1, 0, 0, 0, 1);

// Passing in an existing Matrix3
var m4 = new Matrix3(m1); // m4 == (1, 0, 0, 0, 1, 0, 0, 0, 1)
new
Matrix3
(arguments)
arguments :: Matrix3|number[]|number Initial values for the components.

Instance methods

add(rhs) -> Matrix3
Performs a component-wise addition.
rhs :: Matrix3 Matrix or scalar on the right-hand side.
sub(rhs) -> Matrix3
Performs a component-wise subtraction.
rhs :: Matrix3 Matrix or scalar on the right-hand side.
scale(scalar) -> Matrix3
Multiplies this matrix with a scalar
scalar :: number
mul(rhs) -> Matrix3
Multiplies this matrix with another matrix
rhs :: Matrix3 Matrix on the left-hand side
mul2(lhsrhs) -> Matrix3
Multiplies two matrices and stores the result in this matrix
lhs :: Matrix3 Matrix on the left-hand side
rhs :: Matrix3 Matrix on the right-hand side
transpose() -> Matrix3
Transposes a matrix (exchanges rows and columns) and stores the result in a separate matrix.
invert() -> Matrix3
Computes the analytical inverse and stores the result locally.
isOrthogonal() -> Boolean
Tests if the matrix is orthogonal.
isNormal() -> boolean
Tests if the matrix is normal.
isOrthonormal() -> boolean
Tests if the matrix is orthonormal.
determinant() -> number
Computes the determinant of the matrix.
setIdentity() -> Matrix3
Sets the matrix to identity: (1, 0, 0, 0, 1, 0, 0, 0, 1).
multiplyDiagonalPost(vecresult) -> Matrix3
Post-multiplies the matrix ("before") with a scaling vector.
vec :: Vector3 Vector on the right-hand side.
result :: Matrix3 Storage matrix.
fromAngles(pitchyawroll) -> Matrix3
Sets the Matrix3 from rotational angles in radians.
pitch :: number Pitch (X axis) angle in radians.
yaw :: number Yaw (Y axis) angle in radians.
roll :: number Roll (Z axis) angle in radians.
// sets the rotation to Math.PI (180 degrees) on the Y axis
entity.transformComponent.transform.rotation.fromAngles(0, Math.PI, 0);
rotateX(radstore) -> Matrix3
Rotates a Matrix3 by the given angle in radians, around the X axis.
rad :: number the angle in radians to rotate the Matrix3 by.
store :: Matrix3 optional the target Matrix3 to store the result or 'this', if undefined.
// rotates the entity on the X axis, by the amount of time per frame (tpf)
entity.transformComponent.transform.rotation.rotateX(goo.world.tpf);
rotateY(radstore) -> Matrix3
Rotates a Matrix3 by the given angle in radians, around the Y axis.
rad :: number the angle in radians to rotate the Matrix3 by.
store :: Matrix3 optional the target Matrix3 to store the result or 'this', if undefined.
// rotates the entity on the Y axis, by Math.PI * 0.5 (90 degrees)
entity.transformComponent.transform.rotation.rotateY(Math.PI * 0.5);
rotateZ(radstore) -> Matrix3
Rotates a Matrix3 by the given angle in radians, around the Z axis.
rad :: number the angle in radians to rotate the Matrix3 by.
store :: Matrix3 optional the target Matrix3 to store the result or 'this', if undefined.
// rotates the entity on the Z axis, by 3.14 (180 degrees)
entity.transformComponent.transform.rotation.rotateZ(3.14);
toAngles(store) -> Vector3
Converts the current Matrix3 to Euler rotation angles in radians: (X axis, Y axis, Z axis)
Vector3 :: Vector3 to store the computed angles in (or undefined to create a new one).
// Not passing in a Vector3 to store the result, one is created and returned
var rot = entity.transformComponent.transform.rotation.toAngles();

// Passing in an existing Vector3 to store the result
var angles = new Vector3();
entity.transformComponent.transform.rotation.toAngles(angles);
fromAngleNormalAxis(anglexyz) -> Matrix3
Sets this matrix to the rotation indicated by the given angle and a unit-length axis of rotation.
angle :: number the angle to rotate (in radians).
x :: number
y :: number
z :: number
lookAt(directionup) -> Matrix3
Sets the Matrix3 to look in a specific direction.
direction :: Vector3 Direction vector.
up :: Vector3 Up vector.
// get the direction from the current entity to the 'other' entity
var direction = Vector3.sub(other.transformComponent.transform.translation, entity.transformComponent.transform.translation);
// pass in the direction, and use Vector3.UNIT_Y as 'up'
entity.lookAt(direction, Vector3.UNIT_Y);
// update the transform component with the new rotation
entity.transformComponent.setUpdated();
copyQuaternion(quaternion) -> Matrix3
Sets the matrix from a quaternion.
quaternion :: Quaternion Rotational quaternion.
equals(rhs) -> boolean
Compares two matrices for approximate equality
rhs :: Matrix3 The matrix to compare against
copy(rhs) -> Matrix3
Copies component values and stores them locally.
rhs :: Matrix3 Source matrix.
copyMatrix4(rhs) -> Matrix3
Copies component values from the upper-left submatrix of a Matrix4.
rhs :: Matrix4 Source matrix.
setArray(rhsData) -> Matrix3
Sets matrix values from an array.
rhsData :: number[] Array source
clone() -> Matrix3
Returns a new matrix with the same values as the existing one.

Static methods

invert(sourcetarget) -> Matrix3
Computes the analytical inverse and stores the result in a separate matrix.
source :: Matrix3 Source matrix.
target :: Matrix3 optional Target matrix.

Matrix4 extends Matrix

goo/math/Matrix4
Matrix with 4x4 components.
new
Matrix4
(arguments)
arguments :: Matrix4|number[] Initial values for the components.

Instance methods

add(rhs) -> Matrix4
Performs a component-wise addition.
rhs :: Matrix4 Matrix or scalar on the right-hand side.
sub(rhs) -> Matrix4
Performs a component-wise subtraction.
rhs :: Matrix4 Matrix or scalar on the right-hand side.
scale(scalar) -> Matrix4
Multiplies this matrix with a scalar
scalar :: number
mul(rhs) -> Matrix4
Multiplies this matrix with another matrix
rhs :: Matrix4 Matrix on the left-hand side
mul2(lhsrhs) -> Matrix4
Multiplies two matrices and stores the result in this matrix
lhs :: Matrix4 Matrix on the left-hand side
rhs :: Matrix4 Matrix on the right-hand side
transpose() -> Matrix4
Transposes a matrix (exchanges rows and columns)
invert() -> Matrix4
Computes the analytical inverse and stores the result locally.
isOrthogonal() -> Boolean
Tests if the matrix is orthogonal.
isNormal() -> Boolean
Tests if the matrix is normal.
isOrthonormal() -> Boolean
Tests if the matrix is orthonormal.
determinant() -> Float
Computes the determinant of the matrix.
setIdentity() -> Matrix4
Sets the matrix to identity.
setRotationFromVector(angles) -> Matrix4
Sets the rotational part of the matrix from a vector of angles. Order convention is x followed by y followed by z.
angles :: Vector3 Rotational angles in radians.
setRotationFromQuaternion(quaternion) -> Matrix4
Sets the rotational part of the matrix from a quaternion.
quaternion :: Vector4 Rotational quaternion.
setTranslation(translation) -> Matrix4
Sets the translational part of the matrix.
translation :: Vector3 Translation vector.
getTranslation(store) -> Matrix4
Gets the translational part of the matrix.
store :: Vector3 Translation vector to store result in.
getRotation(store) -> Matrix4
Gets the rotational part of the matrix (the upper left 3x3 matrix).
store :: Matrix3 Rotation matrix to store in.
getScale(store) -> Matrix4
Gets the scaling part of the matrix.
store :: Vector3 Scaling vector to store result in.
setScale(scale) -> Matrix4
Sets the scale of the matrix.
scale :: Vector3 Scale vector.
scale(scale) -> Matrix4
Scales the matrix.
scale :: Vector3 Scale vector.
decompose(positionrotationscale)
equals(rhsepsilon) -> boolean
Compares two matrices for approximate equality
rhs :: Matrix4 The matrix to compare against
epsilon :: number optional Maximum tolerance
copy(rhs) -> Matrix4
Copies component values and stores them locally.
rhs :: Matrix4 Source matrix.
setArray(rhsData) -> Matrix4
Sets matrix values from an array.
rhsData :: number[] Array source
clone() -> Matrix4
Returns a new matrix with the same values as the existing one.

Static methods

invert(sourcetarget) -> Matrix4
Computes the analytical inverse and stores the result in a separate matrix.
source :: Matrix4 Source matrix.
target :: Matrix4 optional Target matrix.

Plane

goo/math/Plane
A representation of a mathematical plane using a normal vector and a plane constant (d) whose absolute value represents the distance from the origin to the plane. It is generally calculated by taking a point (X) on the plane and finding its dot-product with the plane's normal vector. In other words: d = N dot X
new
Plane
(normalconstant)
normal :: Vector3 Normal of the plane.
constant :: number The plane offset along the normal.

Instance methods

pseudoDistance(point) -> number
point :: Vector3
setPlanePoints(pointApointBpointC) -> Plane
Sets this plane to the plane defined by the given three points.
pointA :: Vector3
pointB :: Vector3
pointC :: Vector3
reflectVector(unitVectorstore) -> Vector3
Reflects an incoming vector across the normal of this Plane.
unitVector :: Vector3 the incoming vector. Must be a unit vector.
store :: Vector3 optional Vector to store the result in. May be the same as the unitVector.
rayIntersect(raystoresuppressWarningsprecision) -> Vector3
Get the intersection of a ray with a plane.
ray :: Ray
store :: Vector3 optional
suppressWarnings :: boolean optional default = false
precision :: boolean optional default = 1e-8
copy(source) -> Plane
Copies data from another plane
Source :: Plane plane to copy from
clone() -> Plane
Returns a clone of this plane

Quaternion

goo/math/Quaternion
Quaternions provide a convenient mathematical notation for representing orientations and rotations of objects in three dimensions. Compared to Euler angles, Quaternions are simpler to compose and can help avoid the problem of gimbal lock. Compared to rotation matrices, Quaternions are more numerically stable and the representation (4 numbers) is more compact. Quaternions are non-commutative and provide a convenient way to interpolate between rotations (using the slerp function).
new
Quaternion
(xyzw)
x :: number
y :: number
z :: number
w :: number

Instance methods

copy(rhs)
set(rhs)
negate() -> Quaternion
Multiplies this quaterion's values by -1.
conjugate() -> Quaternion
Conjugates this quaternion
invert() -> Quaternion
Inverts this quaternion
mul(rhs) -> Quaternion
Performs a multiplication between the current quaternion and another and stores the result locally. The result is a quaternion product.
rhs :: Quaternion Quaternion on the right-hand side.
slerp(endQuatchangeAmount) -> Quaternion
Computes the spherical linear interpolation from the current quaternion towards endQuat.
endQuat :: Quaternion End quaternion.
changeAmount :: number Interpolation factor between 0.0 and 1.0.
fromRotationMatrix(matrix) -> Quaternion
Sets the value of this quaternion to the rotation described by the given matrix values.
matrix :: Matrix3 Rotation matrix.
toRotationMatrix(store) -> Matrix3
Return a rotation matrix representing the current quaternion.
store :: Matrix3 optional The matrix to store our result in. If null, a new matrix is created.
fromVectorToVector(fromto) -> Quaternion
Sets this quaternion to the one that will rotate vector "from" into vector "to". Vectors do not have to be the same length.
from :: Vector3 The source vector.
to :: Vector3 The destination vector into which to rotate the source vector.
fromAngleAxis(angleaxis) -> Quaternion
Sets the values of this quaternion to the values represented by a given angle and axis of rotation. Note that this method creates an object, so use fromAngleNormalAxis if your axis is already normalized. If axis == (0, 0, 0) the quaternion is set to identity.
angle :: number The angle to rotate (in radians).
axis :: Vector3 The axis of rotation.
fromAngleNormalAxis(angleaxis) -> Quaternion
Sets the values of this quaternion to the values represented by a given angle and unit length axis of rotation. If axis == (0, 0, 0) the quaternion is set to identity.
angle :: number The angle to rotate (in radians).
axis :: Vector3 The axis of rotation (already normalized - unit length).
toAngleAxis(axisStore) -> number
Returns the rotation angle represented by this quaternion. If a non-null vector is provided, the axis of rotation is stored in that vector as well.
axisStore :: Vector3 The object to store the computed axis in. If null, no computations are done to determine axis.
clone() -> Quaternion
Clones the quaternion
dot(q) -> number
Calculates the dot product between the current quaternion and another quaternion.
rhs :: Quaternion on the right-hand side.
setDirect(xyzw) -> Quaternion
Sets the vector's values from 4 numeric arguments
x :: number
y :: number
z :: number
w :: number
var q = new Quaternion(); // q == (0, 0, 0, 0)
q.setDirect(2, 4, 6, 8); // q == (2, 4, 6, 8)
setArray(array)
Set the quaternion components from an array (ordered x, y, z, w).
array :: array

Static methods

slerp(startQuatendQuat<