|
|
|
@ -3,6 +3,7 @@ import { UpdateDraw } from "../../Common/Status";
|
|
|
|
|
import { Box3Ext } from "../../Geometry/Box";
|
|
|
|
|
import { equalv3, YAxis, ZeroVec } from "../../Geometry/GeUtils";
|
|
|
|
|
import { RenderType } from "../../GraphicsSystem/RenderType";
|
|
|
|
|
import { equaln } from "../../Nest/Common/Util";
|
|
|
|
|
import { AutoRecord } from "../AutoRecord";
|
|
|
|
|
import { Factory } from "../CADFactory";
|
|
|
|
|
import { CADFiler } from "../CADFiler";
|
|
|
|
@ -25,8 +26,8 @@ export class RectAreaLight extends Light
|
|
|
|
|
@AutoRecord AttenuationRadius = 300; //衰减半径 10-1000
|
|
|
|
|
|
|
|
|
|
//RectLightComponent extends LocalLightComponent
|
|
|
|
|
@AutoRecord BarnDoorAngle: number = 90;//0-90 挡光板角度
|
|
|
|
|
@AutoRecord BarnDoorLength: number = 20;//0-100 挡光板长度
|
|
|
|
|
private _BarnDoorAngle: number = 0; //0-90 挡光板角度
|
|
|
|
|
private _BarnDoorLength: number = 0; //0-100 挡光板长度
|
|
|
|
|
@AutoRecord SourceTexture: ObjectId;//Texture 源纹理 默认无 可以追加一张贴图
|
|
|
|
|
|
|
|
|
|
get Target()
|
|
|
|
@ -41,6 +42,63 @@ export class RectAreaLight extends Light
|
|
|
|
|
this.Update(UpdateDraw.Geometry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get Height() { return this._Height; }
|
|
|
|
|
|
|
|
|
|
set Height(v: number)
|
|
|
|
|
{
|
|
|
|
|
if (equaln(v, this._Height, 1e-2)) return;
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
this._Height = v;
|
|
|
|
|
this.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get Width() { return this._Width; }
|
|
|
|
|
|
|
|
|
|
set Width(v: number)
|
|
|
|
|
{
|
|
|
|
|
if (equaln(v, this._Width, 1e-2)) return;
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
this._Width = v;
|
|
|
|
|
this.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get BarnDoorAngle() { return this._BarnDoorAngle; }
|
|
|
|
|
|
|
|
|
|
set BarnDoorAngle(v: number)
|
|
|
|
|
{
|
|
|
|
|
if (equaln(this._BarnDoorAngle, v, 1e-2)) return;
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
this._BarnDoorAngle = v;
|
|
|
|
|
this.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get BarnDoorLength() { return this._BarnDoorLength; }
|
|
|
|
|
|
|
|
|
|
set BarnDoorLength(v: number)
|
|
|
|
|
{
|
|
|
|
|
if (equaln(this._BarnDoorLength, v, 1e-2)) return;
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
this._BarnDoorLength = v;
|
|
|
|
|
this.Update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get WebIntensity()
|
|
|
|
|
{
|
|
|
|
|
let x = this._Intensity / 2000;
|
|
|
|
|
x = Math.pow(x, 0.5);
|
|
|
|
|
return (x * 50) / (Math.PI);//流明转cd 文档是4pi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get BoundingBoxInOCS()
|
|
|
|
|
{
|
|
|
|
|
return new Box3Ext(new Vector3(-this._Width * 0.5, -this._Height * 0.5, 0), new Vector3(this._Width * 0.5, this._Height * 0.5, 0.01));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get BoundingBox()
|
|
|
|
|
{
|
|
|
|
|
return new Box3().setFromCenterAndSize(new Vector3(), new Vector3(this._Width, this._Height)).applyMatrix4(this._Matrix);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GetGripPoints(): Array<Vector3>
|
|
|
|
|
{
|
|
|
|
|
let heightHalf = this._Height * 0.5;
|
|
|
|
@ -57,6 +115,7 @@ export class RectAreaLight extends Light
|
|
|
|
|
];
|
|
|
|
|
return pts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MoveGripPoints(indexList: number[], vec: Vector3)
|
|
|
|
|
{
|
|
|
|
|
let vecInv = vec.clone().applyMatrix4(this.OCSInv.setPosition(0, 0, 0));
|
|
|
|
@ -125,6 +184,7 @@ export class RectAreaLight extends Light
|
|
|
|
|
];
|
|
|
|
|
return pts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MoveStretchPoints(ids: number[], vec: Vector3)
|
|
|
|
|
{
|
|
|
|
|
if (ids.length === 4)
|
|
|
|
@ -203,43 +263,6 @@ export class RectAreaLight extends Light
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get Height()
|
|
|
|
|
{
|
|
|
|
|
return this._Height;
|
|
|
|
|
}
|
|
|
|
|
get Width()
|
|
|
|
|
{
|
|
|
|
|
return this._Width;
|
|
|
|
|
}
|
|
|
|
|
set Height(v: number)
|
|
|
|
|
{
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
this._Height = v;
|
|
|
|
|
this.Update();
|
|
|
|
|
}
|
|
|
|
|
set Width(v: number)
|
|
|
|
|
{
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
|
this._Width = v;
|
|
|
|
|
this.Update();
|
|
|
|
|
}
|
|
|
|
|
get WebIntensity()
|
|
|
|
|
{
|
|
|
|
|
let x = this._Intensity / 2000;
|
|
|
|
|
x = Math.pow(x, 0.5);
|
|
|
|
|
return (x * 50) / (Math.PI);//流明转cd 文档是4pi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get BoundingBoxInOCS()
|
|
|
|
|
{
|
|
|
|
|
return new Box3Ext(new Vector3(-this._Width * 0.5, -this._Height * 0.5, 0), new Vector3(this._Width * 0.5, this._Height * 0.5, 0.01));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get BoundingBox()
|
|
|
|
|
{
|
|
|
|
|
return new Box3().setFromCenterAndSize(new Vector3(), new Vector3(this._Width, this._Height)).applyMatrix4(this._Matrix);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D
|
|
|
|
|
{
|
|
|
|
|
let lightGroup = new Group();
|
|
|
|
@ -266,6 +289,14 @@ export class RectAreaLight extends Light
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
help = obj.children[1] as RectAreaLightHelper;
|
|
|
|
|
|
|
|
|
|
help.BarnDoorAngle = 90 - this.BarnDoorAngle;
|
|
|
|
|
help.BarnDoorLength = this.BarnDoorLength;
|
|
|
|
|
help.updataRange();
|
|
|
|
|
|
|
|
|
|
help.updateMatrixWorld();
|
|
|
|
|
|
|
|
|
|
help = obj.children[1] as RectAreaLightHelper;
|
|
|
|
|
help.visible = this._ShowHelper;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -281,11 +312,10 @@ export class RectAreaLight extends Light
|
|
|
|
|
if (ver > 1)
|
|
|
|
|
{
|
|
|
|
|
this.AttenuationRadius = file.Read();
|
|
|
|
|
this.BarnDoorAngle = file.Read();
|
|
|
|
|
this.BarnDoorLength = file.Read();
|
|
|
|
|
this._BarnDoorAngle = file.Read();
|
|
|
|
|
this._BarnDoorLength = file.Read();
|
|
|
|
|
this.SourceTexture = file.Read();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//对象将自身数据写入到文件.
|
|
|
|
|
WriteFile(file: CADFiler)
|
|
|
|
@ -298,8 +328,8 @@ export class RectAreaLight extends Light
|
|
|
|
|
|
|
|
|
|
//ver2
|
|
|
|
|
file.Write(this.AttenuationRadius);
|
|
|
|
|
file.Write(this.BarnDoorAngle);
|
|
|
|
|
file.Write(this.BarnDoorLength);
|
|
|
|
|
file.Write(this._BarnDoorAngle);
|
|
|
|
|
file.Write(this._BarnDoorLength);
|
|
|
|
|
file.Write(this.SourceTexture);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|