GameObject Class
Main class for creating objects in aexolGL engine. Takes care for connecting RenderTree objects.
Constructor
GameObject
-
scene
Parameters:
-
scene
Scenescene where GameObject exists
Example:
world = new Scene();
gshader = new basicShader()
skyMat = new Material({color:[0.4,0.7,1],shininess:13.0,specularWeight:0.0 })
skyMesh = Mesh.sphere().scale(30.0,10.0,30.0)
someLight = new Light({
lightPosition: new Vector(1.3,4.0,-2.0),
attenuation: 40.0,
intensity: 1.33,
color: [0.8,1.0,1.0]
})
sky = new GameObject(world,{
shader:gshader,
material:skyMat,
mesh:skyMesh,
light:someLight
})
Item Index
Methods
addAnimation
-
animation
Adds animation to GameObject
Parameters:
-
animation
Animationto add to animations.
move
-
x
-
y
-
z
-
r
Move the object
Parameters:
-
x
FloatMove in x axis
-
y
FloatMove in y axis
-
z
FloatMove in z axis
-
r
BooleanMove relative to actual position
Example:
world = new Scene()
game = new GameObject(world,{})
//absolute move
game.move(0,1,0)
//relative move
game.move(0,1,0,1)
remove
()
Removes GameObject
rotate
-
x
-
y
-
z
-
r
Rotate the object (degrees)
Parameters:
-
x
FloatRotate in x axis
-
y
FloatRotate in y axis
-
z
FloatRotate in z axis
-
r
BooleanRotate relative to actual rotation
Example:
world = new Scene()
game = new GameObject(world,{})
//absolute rotate
game.rotate(0,1,0)
//relative rotate
game.rotate(0,1,0,1)
scale
-
x
-
y
-
z
-
r
Scale the object
Parameters:
-
x
FloatScale in x axis
-
y
FloatScale in y axis
-
z
FloatScale in z axis
-
r
BooleanScale relative to actual scale
Example:
world = new Scene()
game = new GameObject(world,{})
//absolute scale
game.scale(1.2,1.2,1.3)
//relative scale
game.scale(0,1,0,1)
scaleUniform
-
f
-
r
Scale the object uniform in all axes
Parameters:
-
f
FloatScale factor
-
r
BooleanScale relative to actual scale
setModelView
()
Replace modelView in RenderNode
Properties
aex
Aex
Aex connected to this game object
Example:
world = new Scene()
game = new GameObject(world,{...})
game.aex = new Aex()
light
Light
Light system connected to this game object
Example:
world = new Scene()
game = new GameObject(world,{...})
game.light = new Light({})
material
Material
Material connected to this game object
Example:
world = new Scene()
game = new GameObject(world,{...})
game.material = new Material({})
mesh
Mesh
Mesh connected to this game object
Example:
world = new Scene()
game = new GameObject(world,{...})
game.mesh = Mesh.sphere()
position
Vector
Position of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.position = new Vector(1.0,2.0,3.0)
rotation
Vector
Rotation of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.rotation = new Vector(0.0,90.0,0.0)
rotX
Float
x Rotation of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.rotX = 20.0
rotY
Float
y Rotation of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.rotY = 20.0
rotZ
Float
z Rotation of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.rotZ = 20.0
scaleX
Float
x scale of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.scaleX = 2.0
scaleY
Float
y scale of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.scaleY = 2.0
scaleZ
Float
z scale of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.scaleZ = 2.0
shader
Shader
Shader connected to this game object
Example:
world = new Scene()
game = new GameObject(world,{...})
game.shader = new Shader({})
uniforms
Dict
Uniforms of object
Example:
world = new Scene()
game = new GameObject(world,{...})
game.uniforms["tiling"] = [1.0,10.0]
You can also set uniforms of the material easily
world = new Scene()
game = new GameObject(world,{...})
game.uniforms["color"] = [1.0,0.0,0.0]
game.uniforms["alpha"] = 0.2
x
Float
x Position of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.x = 20.0
y
Float
y Position of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.y = 20.0
z
Float
z Position of object
Example:
world = new Scene()
game = new GameObject(world,{})
game.z = 20.0