character selector
This commit is contained in:
@@ -8,7 +8,7 @@ export class CharacterControls {
|
||||
rotateAngle = new THREE.Vector3(0, 1, 0)
|
||||
rotateQuarternion = new THREE.Quaternion()
|
||||
cameraTarget = new THREE.Vector3()
|
||||
storedFall = 0
|
||||
cameraY = 3
|
||||
|
||||
// constants
|
||||
fadeDuration = 0.2
|
||||
@@ -101,11 +101,16 @@ export class CharacterControls {
|
||||
}
|
||||
|
||||
this.actionStart += delta;
|
||||
|
||||
this.cameraDelta += delta * ( pointerControls.cameraLeft * -1 + pointerControls.cameraRight * 1)
|
||||
|
||||
this.walkDirection.x = this.walkDirection.y = this.walkDirection.z = 0
|
||||
|
||||
if (pointerControls.kb.KeyR && this.cameraY < 5){
|
||||
this.cameraY+=delta;
|
||||
}
|
||||
if (pointerControls.kb.KeyF && this.cameraY > 1){
|
||||
this.cameraY-=delta;
|
||||
}
|
||||
|
||||
if (pointerControls.motion) {
|
||||
this.directionVelocity = this.directionVelocity * 2.5 * Math.abs(input[0])
|
||||
this.direction += input[0] * delta * 2.5 //this.directionVelocity;
|
||||
@@ -145,13 +150,13 @@ export class CharacterControls {
|
||||
let cameraPosition = new THREE.Vector3().copy(this.camera.position)
|
||||
let cameraDesiredPosition = new THREE.Vector3(
|
||||
this.model.position.x + 5* Math.sin(this.model.rotation.y + Math.PI + this.cameraDelta + this.cameraIdleDelta),
|
||||
3,
|
||||
this.cameraY,
|
||||
this.model.position.z + 5* Math.cos(this.model.rotation.y + Math.PI + this.cameraDelta + this.cameraIdleDelta)
|
||||
)
|
||||
|
||||
cameraPosition.lerp(cameraDesiredPosition, delta*2)
|
||||
this.camera.position.copy(cameraPosition)
|
||||
this.orbitControl.target.set(this.model.position.x, 2, this.model.position.z)
|
||||
this.orbitControl.target.set(this.model.position.x, this.cameraY - 1, this.model.position.z)
|
||||
this.camera.lookAt(this.orbitControl.target)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user