babylon.light.js 3.1 KB

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