Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08dd3e6
commit 72b2dc9
Showing
3 changed files
with
36 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,3 @@ | ||
class Camera extends WorldObject | ||
pitch: 0 | ||
yaw: 0 | ||
look: 0 | ||
fresh_look: false | ||
constructor: (x=0,y=0,z=0)-> | ||
super(x,y,z) | ||
this.look = new Vector3(x,y,z) | ||
setPitch: (p) -> | ||
this.pitch = p | ||
this.fresh_look = false | ||
setYaw: (y) -> | ||
this.yaw = y | ||
this.fresh_look = false | ||
getPitch: -> | ||
return this.pitch | ||
getYaw: -> | ||
return this.yaw | ||
getLook: -> | ||
if not this.fresh_look | ||
this.look = new Vector3(Math.sin((this.yaw*Math.PI)/180)*Math.cos((this.pitch*Math.PI)/180), -Math.sin((this.pitch*Math.PI)/180), -Math.cos((this.yaw*Math.PI)/180)*Math.cos((this.pitch*Math.PI)/180)) | ||
this.look.normalize() | ||
this.fresh_look = true | ||
return this.look | ||
getHorizontalLook: -> | ||
vlook = this.getLook() | ||
hlook = new Vector2(vlook.x, vlook.z) | ||
hlook.normalize() | ||
return hlook | ||
super(x,y,z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
class Player extends WorldObject | ||
constructor: (x=0, y=0, z=0) -> | ||
super(x,y,z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,36 @@ | ||
class WorldObject | ||
pos : new Vector3(0,0,0) | ||
location : new Vector3(0,0,0) | ||
look: 0 | ||
pitch: 0 | ||
yaw: 0 | ||
fresh_look: false | ||
constructor: (x=0,y=0,z=0)-> | ||
this.pos = new Vector3(x,y,z) | ||
this.location = new Vector3(x,y,z) | ||
this.look = new Vector3(x,y,z) | ||
setLocation: (x=0,y=0,z=0)-> | ||
this.pos = new Vector3(x,y,z) | ||
this.location = new Vector3(x,y,z) | ||
setPitch: (p) -> | ||
this.pitch = p | ||
this.fresh_look = false | ||
setYaw: (y) -> | ||
this.yaw = y | ||
this.fresh_look = false | ||
getPitch: -> | ||
return this.pitch | ||
getYaw: -> | ||
return this.yaw | ||
getLocation: -> | ||
return this.location | ||
getLook: -> | ||
if not this.fresh_look | ||
this.look = new Vector3(Math.sin((this.yaw*Math.PI)/180)*Math.cos((this.pitch*Math.PI)/180), -Math.sin((this.pitch*Math.PI)/180), -Math.cos((this.yaw*Math.PI)/180)*Math.cos((this.pitch*Math.PI)/180)) | ||
this.look.normalize() | ||
this.fresh_look = true | ||
return this.look | ||
getHorizontalLook: -> | ||
vlook = this.getLook() | ||
hlook = new Vector2(vlook.x, vlook.z) | ||
hlook.normalize() | ||
return hlook | ||
synchronizeWithWorldObject: (obj)-> | ||
this.location = obj.getLocation() |