babylon.pointLight.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. module BABYLON {
  2. export class PointLight extends Light {
  3. private _worldMatrix: Matrix;
  4. private _transformedPosition: Vector3;
  5. constructor(name: string, public position: Vector3, scene: Scene) {
  6. super(name, scene);
  7. }
  8. public transferToEffect(effect: Effect, positionUniformName: string): void {
  9. if (this.parent && this.parent.getWorldMatrix) {
  10. if (!this._transformedPosition) {
  11. this._transformedPosition = BABYLON.Vector3.Zero();
  12. }
  13. BABYLON.Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this._transformedPosition);
  14. effect.setFloat4(positionUniformName, this._transformedPosition.x, this._transformedPosition.y, this._transformedPosition.z, 0);
  15. return;
  16. }
  17. effect.setFloat4(positionUniformName, this.position.x, this.position.y, this.position.z, 0);
  18. }
  19. public getShadowGenerator(): ShadowGenerator {
  20. return null;
  21. }
  22. public _getWorldMatrix(): Matrix {
  23. if (!this._worldMatrix) {
  24. this._worldMatrix = BABYLON.Matrix.Identity();
  25. }
  26. Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  27. return this._worldMatrix;
  28. }
  29. }
  30. }