babylon.light.js 2.9 KB

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