mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
4bc2739786
* Vmath (#4895) * vmath refactor * value-type API change * vmath change update * conflict fix * value types change * translate modify (#4917) * value types bug fixed (#4940) * playground update (#4946) * bug fixed * bug fixed * bug fixed * bug fix * util modify * create remove & ccenum rename * export by cc.math * Rename value-types to math * util funtion deprecated warn * value-types change * color test fix * color API change
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import { aabb } from '../../3d/geom-utils';
|
|
import { Vec3 } from '../../core/math';
|
|
import { Light, LightType, nt2lm } from './light';
|
|
import { RenderScene } from './render-scene';
|
|
import { INode } from '../../core/utils/interfaces';
|
|
|
|
export class SphereLight extends Light {
|
|
|
|
get position () {
|
|
return this._pos;
|
|
}
|
|
|
|
set size (size: number) {
|
|
this._size = size;
|
|
}
|
|
|
|
get size (): number {
|
|
return this._size;
|
|
}
|
|
|
|
set range (range: number) {
|
|
this._range = range;
|
|
}
|
|
|
|
get range (): number {
|
|
return this._range;
|
|
}
|
|
|
|
set luminance (lum: number) {
|
|
this._luminance = lum;
|
|
}
|
|
|
|
get luminance (): number {
|
|
return this._luminance;
|
|
}
|
|
|
|
get aabb () {
|
|
return this._aabb;
|
|
}
|
|
|
|
protected _size: number = 0.15;
|
|
protected _range: number = 1.0;
|
|
protected _luminance: number = 1700 / nt2lm(this._size);
|
|
protected _pos: Vec3;
|
|
protected _aabb: aabb;
|
|
|
|
constructor (scene: RenderScene, name: string, node: INode) {
|
|
super(scene, name, node);
|
|
this._type = LightType.SPHERE;
|
|
this._aabb = aabb.create();
|
|
this._pos = new Vec3();
|
|
}
|
|
|
|
public update () {
|
|
if (this._node) {
|
|
this._node.getWorldPosition(this._pos);
|
|
aabb.set(this._aabb, this._pos.x, this._pos.y, this._pos.z, this._range, this._range, this._range);
|
|
}
|
|
}
|
|
}
|