Class: Controller

Controller(camera, height, weight, moveSpeed, sensitivity)

Helper class to control the player / camera.

Constructor

new Controller(camera, height, weight, moveSpeed, sensitivity)

Controller to manage these Camera.
Parameters:
Name Type Default Description
camera THREE.Camera
height number 5 Min. disctance from the ground. Default to 5
weight number 2 Weight for calculation of the forces. Default to 2
moveSpeed number 0.5 Speed of the WASD-Movement. Default to 0.5
sensitivity number 0.005 How sensitiv the mouse movement to the camera is. Default to 0.005
Source:

Methods

addObjectForCollision(obj)

Add the object to not pass through these objects with the camera.
Parameters:
Name Type Description
obj THREE.Object3D
Source:

applyForce(force)

Add a force to the movement with weight of the object
Parameters:
Name Type Description
force THREE.Vector3 Some Forces
Source:

checkOutOfWorld()

Reset the Camera to 10, 18, -30 if the player is fallen out of the world
Source:

checkYCollisions()

Check the Colissions with the added objects from `addObjectForCollision(obj)`
Source:

kameraMove()

Function that update the position of the camera if you pressed one of the movement keys.
Source:

lock()

Lock the Mouse-Pointer
Source:
See:

lockChanged()

Toggle the information if the Mouse is locked
Source:

mouseMove(ev)

Call this function if the Mouse is moved to update the camera.
Parameters:
Name Type Description
ev MouseEvent Fired Event
Source:

moveForward(distance)

Move the camera to the forward/back with the `distance`
Parameters:
Name Type Description
distance number
Source:

moveRight(distance)

Move the camera to the right/left with the `distance`
Parameters:
Name Type Description
distance number
Source:

removeObjectForCollision(obj)

Remove one object to not do object collision with it anymore.
Parameters:
Name Type Description
obj THREE.Mesh
Source:

setFixedPosition(newPosition, quaternion)

Set a new location with rotation for the camera
Parameters:
Name Type Description
newPosition THREE.Vector3
quaternion THREE.Quaternion
Source:

unlock()

Unlock the Mouse-Pointer
Source:
See:

update()

Need to be called each frame to update the position of the camera.
Source: