Removed Camera3D folder and merged into cameras folder and namespace.

This commit is contained in:
Richard Davey 2017-09-16 03:07:57 +01:00
parent 2d6c00125f
commit 39d1f64030
6 changed files with 67 additions and 20 deletions

View file

@ -39,6 +39,13 @@ var Camera3D = new Class({
this.viewportHeight = 0;
},
setPosition: function (x, y, z)
{
this.position.set(x, y, z);
return this.update();
},
/**
* Sets the width and height of the viewport. Does not
* update any matrices.
@ -190,7 +197,48 @@ var Camera3D = new Class({
update: function ()
{
// Left empty for subclasses
return this;
},
x: {
get: function ()
{
return this.position.x;
},
set: function (value)
{
this.position.x = value;
this.update();
}
},
y: {
get: function ()
{
return this.position.y;
},
set: function (value)
{
this.position.y = value;
this.update();
}
},
z: {
get: function ()
{
return this.position.z;
},
set: function (value)
{
this.position.z = value;
this.update();
}
}
});
Camera3D.FAR_RANGE = 1.0;

View file

@ -1,4 +1,4 @@
var Camera = require('./Camera3D');
var Camera3D = require('./Camera3D');
var Class = require('../utils/Class');
var Matrix4 = require('../math/Matrix4');
var Vector3 = require('../math/Vector3');
@ -10,14 +10,14 @@ var tmpVec3 = new Vector3();
var OrthographicCamera = new Class({
Extends: Camera,
Extends: Camera3D,
initialize: function (viewportWidth, viewportHeight)
{
if (viewportWidth === undefined) { viewportWidth = 0; }
if (viewportHeight === undefined) { viewportHeight = 0; }
Camera.call(this);
Camera3D.call(this);
this.viewportWidth = viewportWidth;
this.viewportHeight = viewportHeight;
@ -55,7 +55,7 @@ var OrthographicCamera = new Class({
var far = Math.abs(this.far);
var zoom = this.zoom;
if (w===0 || h===0)
if (w === 0 || h === 0)
{
// What to do here... hmm?
return this;
@ -84,14 +84,15 @@ var OrthographicCamera = new Class({
zoom: {
set: function (value)
{
this._zoom = value;
},
get: function ()
{
return this._zoom;
},
set: function (value)
{
this._zoom = value;
this.update();
}
}

View file

@ -1,6 +1,7 @@
var Camera = require('./Camera3D');
var Camera3D = require('./Camera3D');
var Class = require('../utils/Class');
var Matrix4 = require('../math/Matrix4');
var Vector2 = require('../math/Vector2');
var Vector3 = require('../math/Vector3');
var Vector4 = require('../math/Vector4');
@ -13,7 +14,7 @@ var billboardMatrix = new Matrix4();
var PerspectiveCamera = new Class({
Extends: Camera,
Extends: Camera3D,
// FOV is converted to radians
initialize: function (fieldOfView, viewportWidth, viewportHeight)
@ -22,7 +23,7 @@ var PerspectiveCamera = new Class({
if (viewportWidth === undefined) { viewportWidth = 0; }
if (viewportHeight === undefined) { viewportHeight = 0; }
Camera.call(this);
Camera3D.call(this);
this.viewportWidth = viewportWidth;
this.viewportHeight = viewportHeight;

View file

@ -3,6 +3,10 @@
module.exports = {
Camera: require('./Camera'),
Camera3D: require('./Camera3D'),
PerspectiveCamera: require('./PerspectiveCamera'),
OrthographicCamera: require('./OrthographicCamera'),
KeyControl: require('./KeyControl'),
SmoothedKeyControl: require('./SmoothedKeyControl')

View file

@ -1,7 +0,0 @@
module.exports = {
Camera3D: require('./Camera3D'),
PerspectiveCamera: require('./PerspectiveCamera'),
OrthographicCamera: require('./OrthographicCamera')
};

View file

@ -19,7 +19,7 @@ var Phaser = {
Create: require('./create/'),
Cameras3D: require('./camera3d/'),
Cameras: require('./camera/'),
DOM: require('./dom/'),