babylon.light.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. "use strict";
  2. var BABYLON = BABYLON || {};
  3. (function () {
  4. BABYLON.Light = function (name, scene) {
  5. this.name = name;
  6. this.id = name;
  7. this._childrenFlag = true;
  8. this._scene = scene;
  9. scene.lights.push(this);
  10. // Animations
  11. this.animations = [];
  12. // Exclusions
  13. this.excludedMeshes = [];
  14. };
  15. BABYLON.Light.prototype = Object.create(BABYLON.Node.prototype);
  16. // Members
  17. BABYLON.Light.prototype.intensity = 1.0;
  18. // Properties
  19. BABYLON.Light.prototype.getScene = function () {
  20. return this._scene;
  21. };
  22. BABYLON.Light.prototype.getShadowGenerator = function() {
  23. return this._shadowGenerator;
  24. };
  25. // Methods
  26. BABYLON.Light.prototype.transferToEffect = function() {
  27. };
  28. BABYLON.Light.prototype.getWorldMatrix = function() {
  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. })();