babylon.light.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. var __extends = this.__extends || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. __.prototype = b.prototype;
  5. d.prototype = new __();
  6. };
  7. var BABYLON;
  8. (function (BABYLON) {
  9. var Light = (function (_super) {
  10. __extends(Light, _super);
  11. function Light(name, scene) {
  12. _super.call(this, name, scene);
  13. this.diffuse = new BABYLON.Color3(1.0, 1.0, 1.0);
  14. this.specular = new BABYLON.Color3(1.0, 1.0, 1.0);
  15. this.intensity = 1.0;
  16. this.range = Number.MAX_VALUE;
  17. this.includedOnlyMeshes = new Array();
  18. this.excludedMeshes = new Array();
  19. this._excludedMeshesIds = new Array();
  20. this._includedOnlyMeshesIds = new Array();
  21. scene.lights.push(this);
  22. }
  23. Light.prototype.getShadowGenerator = function () {
  24. return this._shadowGenerator;
  25. };
  26. Light.prototype.transferToEffect = function (effect, uniformName0, uniformName1) {
  27. };
  28. Light.prototype._getWorldMatrix = function () {
  29. return BABYLON.Matrix.Identity();
  30. };
  31. Light.prototype.canAffectMesh = function (mesh) {
  32. if (!mesh) {
  33. return true;
  34. }
  35. if (this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  36. return false;
  37. }
  38. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  39. return false;
  40. }
  41. return true;
  42. };
  43. Light.prototype.getWorldMatrix = function () {
  44. this._currentRenderId = this.getScene().getRenderId();
  45. var worldMatrix = this._getWorldMatrix();
  46. if (this.parent && this.parent.getWorldMatrix) {
  47. if (!this._parentedWorldMatrix) {
  48. this._parentedWorldMatrix = BABYLON.Matrix.Identity();
  49. }
  50. worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
  51. return this._parentedWorldMatrix;
  52. }
  53. return worldMatrix;
  54. };
  55. Light.prototype.dispose = function () {
  56. if (this._shadowGenerator) {
  57. this._shadowGenerator.dispose();
  58. this._shadowGenerator = null;
  59. }
  60. // Remove from scene
  61. var index = this.getScene().lights.indexOf(this);
  62. this.getScene().lights.splice(index, 1);
  63. };
  64. return Light;
  65. })(BABYLON.Node);
  66. BABYLON.Light = Light;
  67. })(BABYLON || (BABYLON = {}));
  68. //# sourceMappingURL=babylon.light.js.map