babylon.light.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. var BABYLON = BABYLON || {};
  2. (function () {
  3. BABYLON.Light = function (name, scene) {
  4. this.name = name;
  5. this.id = name;
  6. this._childrenFlag = true;
  7. this._scene = scene;
  8. scene.lights.push(this);
  9. // Animations
  10. this.animations = [];
  11. };
  12. BABYLON.Light.prototype = Object.create(BABYLON.Node.prototype);
  13. // Members
  14. BABYLON.Light.prototype.intensity = 1.0;
  15. // Properties
  16. BABYLON.Light.prototype.getScene = function () {
  17. return this._scene;
  18. };
  19. BABYLON.Light.prototype.getShadowGenerator = function() {
  20. return this._shadowGenerator;
  21. };
  22. // Methods
  23. BABYLON.Light.prototype.transferToEffect = function() {
  24. };
  25. BABYLON.Light.prototype.getWorldMatrix = function() {
  26. var worldMatrix = this._getWorldMatrix();
  27. if (this.parent && this.parent.getWorldMatrix) {
  28. if (!this._parentedWorldMatrix) {
  29. this._parentedWorldMatrix = BABYLON.Matrix.Identity();
  30. }
  31. worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
  32. return this._parentedWorldMatrix;
  33. }
  34. return worldMatrix;
  35. };
  36. BABYLON.Light.prototype.dispose = function () {
  37. if (this._shadowGenerator) {
  38. this._shadowGenerator.dispose();
  39. this._shadowGenerator = null;
  40. }
  41. // Remove from scene
  42. var index = this._scene.lights.indexOf(this);
  43. this._scene.lights.splice(index, 1);
  44. };
  45. })();