babylon.light.js 1.7 KB

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