babylon.light.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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<Mesh>();
  8. public _shadowGenerator: ShadowGenerator;
  9. private _parentedWorldMatrix: Matrix;
  10. constructor(name: string, scene: Scene) {
  11. super(name, scene);
  12. scene.lights.push(this);
  13. }
  14. public getShadowGenerator(): ShadowGenerator {
  15. return this._shadowGenerator;
  16. }
  17. public transferToEffect(effect: Effect, uniformName0?: string, uniformName1?: string): void {
  18. }
  19. public _getWorldMatrix(): Matrix {
  20. return Matrix.Identity();
  21. }
  22. public getWorldMatrix(): Matrix {
  23. this._currentRenderId = this.getScene().getRenderId();
  24. var worldMatrix = this._getWorldMatrix();
  25. if (this.parent && this.parent.getWorldMatrix) {
  26. if (!this._parentedWorldMatrix) {
  27. this._parentedWorldMatrix = BABYLON.Matrix.Identity();
  28. }
  29. worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._parentedWorldMatrix);
  30. return this._parentedWorldMatrix;
  31. }
  32. return worldMatrix;
  33. }
  34. public dispose(): void {
  35. if (this._shadowGenerator) {
  36. this._shadowGenerator.dispose();
  37. this._shadowGenerator = null;
  38. }
  39. // Remove from scene
  40. var index = this.getScene().lights.indexOf(this);
  41. this.getScene().lights.splice(index, 1);
  42. }
  43. }
  44. }