|
|
@ -10,7 +10,7 @@ import { ObjectId } from "../ObjectId";
|
|
|
|
import { Light } from "./Light";
|
|
|
|
import { Light } from "./Light";
|
|
|
|
import { RectAreaLightHelper } from "./RectAreaLightHelper";
|
|
|
|
import { RectAreaLightHelper } from "./RectAreaLightHelper";
|
|
|
|
|
|
|
|
|
|
|
|
const TARGET_DISTANCE = -1000;
|
|
|
|
const TARGET_DISTANCE = -100;
|
|
|
|
|
|
|
|
|
|
|
|
@Factory
|
|
|
|
@Factory
|
|
|
|
export class RectAreaLight extends Light
|
|
|
|
export class RectAreaLight extends Light
|
|
|
@ -54,10 +54,10 @@ export class RectAreaLight extends Light
|
|
|
|
let pos = this.Position;
|
|
|
|
let pos = this.Position;
|
|
|
|
|
|
|
|
|
|
|
|
let pts: Vector3[] = [
|
|
|
|
let pts: Vector3[] = [
|
|
|
|
new Vector3(-widthHalf, -heightHalf, 0).applyMatrix4(this.OCSNoClone),
|
|
|
|
new Vector3(-widthHalf, -heightHalf, 0).applyMatrix4(this.OCSNoClone),//左下
|
|
|
|
new Vector3(widthHalf, -heightHalf, 0).applyMatrix4(this.OCSNoClone),
|
|
|
|
new Vector3(widthHalf, -heightHalf, 0).applyMatrix4(this.OCSNoClone),//右下
|
|
|
|
new Vector3(widthHalf, heightHalf, 0).applyMatrix4(this.OCSNoClone),
|
|
|
|
new Vector3(widthHalf, heightHalf, 0).applyMatrix4(this.OCSNoClone),//右上
|
|
|
|
new Vector3(-widthHalf, heightHalf, 0).applyMatrix4(this.OCSNoClone),
|
|
|
|
new Vector3(-widthHalf, heightHalf, 0).applyMatrix4(this.OCSNoClone),//左上
|
|
|
|
pos,
|
|
|
|
pos,
|
|
|
|
pos.clone().add(this.Normal.multiplyScalar(TARGET_DISTANCE))
|
|
|
|
pos.clone().add(this.Normal.multiplyScalar(TARGET_DISTANCE))
|
|
|
|
];
|
|
|
|
];
|
|
|
@ -111,12 +111,94 @@ export class RectAreaLight extends Light
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (i === 5)
|
|
|
|
else if (i === 5)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.Target = this.Target.add(vec);
|
|
|
|
let target = this.Position.add(this.Normal.multiplyScalar(TARGET_DISTANCE)).add(vec);
|
|
|
|
|
|
|
|
this.Target = target;
|
|
|
|
this.lookAtTarget();
|
|
|
|
this.lookAtTarget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GetStretchPoints()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let heightHalf = this._Height * 0.5;
|
|
|
|
|
|
|
|
let widthHalf = this.Width * 0.5;
|
|
|
|
|
|
|
|
let pos = this.Position;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let pts: Vector3[] = [
|
|
|
|
|
|
|
|
new Vector3(-widthHalf, -heightHalf, 0).applyMatrix4(this.OCSNoClone),//左下
|
|
|
|
|
|
|
|
new Vector3(widthHalf, -heightHalf, 0).applyMatrix4(this.OCSNoClone),//右下
|
|
|
|
|
|
|
|
new Vector3(widthHalf, heightHalf, 0).applyMatrix4(this.OCSNoClone),//右上
|
|
|
|
|
|
|
|
new Vector3(-widthHalf, heightHalf, 0).applyMatrix4(this.OCSNoClone),//左上
|
|
|
|
|
|
|
|
pos.clone().add(this.Normal.multiplyScalar(TARGET_DISTANCE))
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
return pts;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MoveStretchPoints(ids: number[], vec: Vector3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ids.length === 4 || ids.length === 3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.Move(vec);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ids.length === 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let i = ids[0];
|
|
|
|
|
|
|
|
if (i < 4)
|
|
|
|
|
|
|
|
this.MoveGripPoints(ids, vec);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
this.MoveGripPoints([5], vec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else//===2
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ids.sort((a1, a2) => a1 - a2);
|
|
|
|
|
|
|
|
let inv = this.OCSInv.setPosition(0, 0, 0);
|
|
|
|
|
|
|
|
vec = vec.clone().applyMatrix4(inv);
|
|
|
|
|
|
|
|
let ocs = inv.copy(this._Matrix).setPosition(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ids[0] === 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ids[1] === 1)//下
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
vec.x = 0;
|
|
|
|
|
|
|
|
vec.z = 0;
|
|
|
|
|
|
|
|
vec.applyMatrix4(ocs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.MoveGripPoints([0], vec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ids[1] === 3)//左
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
vec.y = 0;
|
|
|
|
|
|
|
|
vec.z = 0;
|
|
|
|
|
|
|
|
vec.applyMatrix4(ocs);
|
|
|
|
|
|
|
|
this.MoveGripPoints([0], vec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ids[0] === 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ids[1] === 2)//右
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
vec.y = 0;
|
|
|
|
|
|
|
|
vec.z = 0;
|
|
|
|
|
|
|
|
vec.applyMatrix4(ocs);
|
|
|
|
|
|
|
|
this.MoveGripPoints([1], vec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (ids[0] === 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ids[1] === 3)//上
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
vec.x = 0;
|
|
|
|
|
|
|
|
vec.z = 0;
|
|
|
|
|
|
|
|
vec.applyMatrix4(ocs);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.MoveGripPoints([2], vec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lookAtTarget()
|
|
|
|
lookAtTarget()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
this.WriteAllObjectRecord();
|
|
|
|
this._Matrix.lookAt(this.Position, this.Target, YAxis);
|
|
|
|
this._Matrix.lookAt(this.Position, this.Target, YAxis);
|
|
|
|
this.Update(UpdateDraw.Matrix);
|
|
|
|
this.Update(UpdateDraw.Matrix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|