babylon.camera.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. var BABYLON = BABYLON || {};
  2. (function () {
  3. BABYLON.Camera = function (name, position, scene) {
  4. this.name = name;
  5. this.id = name;
  6. this.position = position;
  7. this._scene = scene;
  8. scene.cameras.push(this);
  9. if (!scene.activeCamera) {
  10. scene.activeCamera = this;
  11. }
  12. };
  13. // Statics
  14. BABYLON.Camera.PERSPECTIVE_CAMERA = 0;
  15. BABYLON.Camera.ORTHOGRAPHIC_CAMERA = 1;
  16. // Members
  17. BABYLON.Camera.prototype.fov = 0.8;
  18. BABYLON.Camera.prototype.orthoLeft = null;
  19. BABYLON.Camera.prototype.orthoRight = null;
  20. BABYLON.Camera.prototype.orthoBottom = null;
  21. BABYLON.Camera.prototype.orthoTop = null;
  22. BABYLON.Camera.prototype.fov = 0.8;
  23. BABYLON.Camera.prototype.minZ = 0.1;
  24. BABYLON.Camera.prototype.maxZ = 1000.0;
  25. BABYLON.Camera.prototype.inertia = 0.9;
  26. BABYLON.Camera.prototype.mode = BABYLON.Camera.PERSPECTIVE_CAMERA;
  27. // Methods
  28. BABYLON.Camera.prototype.attachControl = function (canvas) {
  29. };
  30. BABYLON.Camera.prototype.detachControl = function (canvas) {
  31. };
  32. BABYLON.Camera.prototype._update = function () {
  33. };
  34. BABYLON.Camera.prototype.getViewMatrix = function () {
  35. return BABYLON.Matrix.Identity();
  36. };
  37. BABYLON.Camera.prototype.getProjectionMatrix = function () {
  38. var engine = this._scene.getEngine();
  39. if (this.mode === BABYLON.Camera.PERSPECTIVE_CAMERA) {
  40. return new BABYLON.Matrix.PerspectiveFovLH(this.fov, engine.getAspectRatio(), this.minZ, this.maxZ);
  41. }
  42. var halfWidth = engine.getRenderWidth() / 2.0;
  43. var halfHeight = engine.getRenderHeight() / 2.0;
  44. return new BABYLON.Matrix.OrthoOffCenterLH(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ)
  45. };
  46. })();