babylon.light.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.getAbsolutePosition = function () {
  27. return BABYLON.Vector3.Zero();
  28. };
  29. Light.prototype.transferToEffect = function (effect, uniformName0, uniformName1) {
  30. };
  31. Light.prototype._getWorldMatrix = function () {
  32. return BABYLON.Matrix.Identity();
  33. };
  34. Light.prototype.canAffectMesh = function (mesh) {
  35. if (!mesh) {
  36. return true;
  37. }
  38. if (this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  39. return false;
  40. }
  41. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  42. return false;
  43. }
  44. return true;
  45. };
  46. Light.prototype.getWorldMatrix = function () {
  47. this._currentRenderId = this.getScene().getRenderId();
  48. var worldMatrix = this._getWorldMatrix();
  49. if (this.parent && this.parent.getWorldMatrix) {
  50. if (!this._parentedWorldMatrix) {
  51. this._parentedWorldMatrix = BABYLON.Matrix.Identity();
  52. }
  53. worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
  54. return this._parentedWorldMatrix;
  55. }
  56. return worldMatrix;
  57. };
  58. Light.prototype.dispose = function () {
  59. if (this._shadowGenerator) {
  60. this._shadowGenerator.dispose();
  61. this._shadowGenerator = null;
  62. }
  63. // Remove from scene
  64. var index = this.getScene().lights.indexOf(this);
  65. this.getScene().lights.splice(index, 1);
  66. };
  67. return Light;
  68. })(BABYLON.Node);
  69. BABYLON.Light = Light;
  70. })(BABYLON || (BABYLON = {}));
  71. //# sourceMappingURL=babylon.light.js.map