Files
cocos4/cocos/renderer/scene/directional-light.ts
T
Yun Hsiao Wu 048347b25d fix luminance (#4094)
* fix web audio volume

* fix luminance
2019-03-25 13:53:39 +08:00

46 lines
1.1 KiB
TypeScript

import { Quat, Vec3 } from '../../core/value-types';
import { vec3 } from '../../core/vmath';
import { Node } from '../../scene-graph';
import { Light, LightType } from './light';
import { RenderScene } from './render-scene';
const _forward = new Vec3(0, 0, -1);
const _v3 = new Vec3();
const _qt = new Quat();
export class DirectionalLight extends Light {
protected _dir: Vec3 = new Vec3(1.0, -1.0, -1.0);
protected _illum: number = 65000.0;
set direction (dir: Vec3) {
this._dir = dir;
vec3.normalize(this._dir, this._dir);
}
get direction (): Vec3 {
return this._dir;
}
// in Lux(lx)
set illuminance (illum: number) {
this._illum = illum;
}
get illuminance (): number {
return this._illum;
}
constructor (scene: RenderScene, name: string, node: Node) {
super(scene, name, node);
this._type = LightType.DIRECTIONAL;
}
public update () {
if (this._node) {
this._dir = vec3.transformQuat(_v3, _forward, this._node.getWorldRotation(_qt));
vec3.normalize(this._dir, this._dir);
}
}
}