babylon.hemisphericLight.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. module BABYLON {
  2. export class HemisphericLight extends Light {
  3. public groundColor = new BABYLON.Color3(0.0, 0.0, 0.0);
  4. private _worldMatrix: Matrix;
  5. constructor(name: string, public direction: Vector3, scene: Scene) {
  6. super(name, scene);
  7. }
  8. public setDirectionToTarget(target: Vector3): Vector3 {
  9. this.direction = BABYLON.Vector3.Normalize(target.subtract(Vector3.Zero()));
  10. return this.direction;
  11. }
  12. public getShadowGenerator(): ShadowGenerator {
  13. return null;
  14. }
  15. public transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): void {
  16. var normalizeDirection = BABYLON.Vector3.Normalize(this.direction);
  17. effect.setFloat4(directionUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0);
  18. effect.setColor3(groundColorUniformName, this.groundColor.scale(this.intensity));
  19. }
  20. public _getWorldMatrix(): Matrix {
  21. if (!this._worldMatrix) {
  22. this._worldMatrix = BABYLON.Matrix.Identity();
  23. }
  24. return this._worldMatrix;
  25. }
  26. }
  27. }