babylon.light.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. module BABYLON {
  2. export class Light extends Node {
  3. public diffuse = new Color3(1.0, 1.0, 1.0);
  4. public specular = new Color3(1.0, 1.0, 1.0);
  5. public intensity = 1.0;
  6. public range = Number.MAX_VALUE;
  7. public excludedMeshes = new Array<AbstractMesh>();
  8. public _shadowGenerator: ShadowGenerator;
  9. private _parentedWorldMatrix: Matrix;
  10. public _excludedMeshesIds = new Array<string>();
  11. constructor(name: string, scene: Scene) {
  12. super(name, scene);
  13. scene.lights.push(this);
  14. }
  15. public getShadowGenerator(): ShadowGenerator {
  16. return this._shadowGenerator;
  17. }
  18. public transferToEffect(effect: Effect, uniformName0?: string, uniformName1?: string): void {
  19. }
  20. public _getWorldMatrix(): Matrix {
  21. return Matrix.Identity();
  22. }
  23. public getWorldMatrix(): Matrix {
  24. this._currentRenderId = this.getScene().getRenderId();
  25. var worldMatrix = this._getWorldMatrix();
  26. if (this.parent && this.parent.getWorldMatrix) {
  27. if (!this._parentedWorldMatrix) {
  28. this._parentedWorldMatrix = BABYLON.Matrix.Identity();
  29. }
  30. worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
  31. return this._parentedWorldMatrix;
  32. }
  33. return worldMatrix;
  34. }
  35. public dispose(): void {
  36. if (this._shadowGenerator) {
  37. this._shadowGenerator.dispose();
  38. this._shadowGenerator = null;
  39. }
  40. // Remove from scene
  41. var index = this.getScene().lights.indexOf(this);
  42. this.getScene().lights.splice(index, 1);
  43. }
  44. }
  45. }