功能:折线洞的参数修改器

pull/1918/head
ChenX 2 years ago
parent 8f57ac3f38
commit 5a065b7783

@ -201,3 +201,100 @@ export class RoomIHoleParseAndModify
//get max length? //get max length?
//get max height? //get max height?
} }
export class RoomLHoleParseAndModify
{
private _LeftDist: number;
private _RightDist: number;
private _TopDist: number;
private _BottomDist: number;
private _Wall: RoomWallBase;
MaxLeftDist: number;
MaxRightDist: number;
leftDir: Vector3;
rightDir: Vector3;
constructor(public hole: RoomHolePolyline)
{
let wall1 = hole.RelevancyWalls[0].Object;
let wall2 = hole.RelevancyWalls[hole.RelevancyWalls.length - 1].Object;
let getParam1 = CreateGetCurveParam(wall1);
let getParam2 = CreateGetCurveParam(wall2);
let pts = hole.Points;
let p1 = pts[0];
let p2 = pts[pts.length - 1];
let param1 = getParam1.GetParamAtPoint(p1);
let param2 = getParam2.GetParamAtPoint(p2);
let ranges1 = ParseWallRange(wall1, getParam1);
let ranges2 = ParseWallRange(wall2, getParam2);
let range1 = FindBestRange(param1, ranges1);
let range2 = FindBestRange(param2, ranges2);
this.MaxLeftDist = (range1[1] - range1[0]) * wall1.Length;
this.MaxRightDist = (range2[1] - range2[0]) * wall2.Length;
this._LeftDist = p1.distanceTo(pts[1]);
this._RightDist = p2.distanceTo(pts[pts.length - 2]);
this._BottomDist = hole.Z - wall1.Z;
this._TopDist = wall1.Height - hole.Height - this._BottomDist;
this._Wall = wall1;
this.leftDir = pts[0].clone().sub(pts[1]).normalize();
this.rightDir = pts[pts.length - 1].clone().sub(pts[pts.length - 2]).normalize();
}
get LeftDist() { return this._LeftDist; }
set LeftDist(value: number)
{
let pts = this.hole.Points;
pts[0] = pts[1].add(this.leftDir.clone().multiplyScalar(value));
this.hole.Points = pts;
this._LeftDist = value;
}
get RightDist() { return this._RightDist; }
set RightDist(value: number)
{
let pts = this.hole.Points;
pts[pts.length - 1] = pts[pts.length - 2].add(this.rightDir.clone().multiplyScalar(value));
this.hole.Points = pts;
this._RightDist = value;
}
set BottomDist(value: number)
{
this.hole.Move(new Vector3(0, 0, value - this._BottomDist));
this._BottomDist = value;
this._TopDist = this._Wall.Height - this._BottomDist - this.hole.Height;
}
set TopDist(value: number)
{
this.hole.Move(new Vector3(0, 0, this._TopDist - value));
this._TopDist = value;
this._BottomDist = this._Wall.Height - this._TopDist - this.hole.Height;
}
set Height(newHeight: number)
{
let diff = newHeight - this.hole.Height;
if (this._TopDist < diff)
{
this._BottomDist = this._Wall.Height - newHeight;
this._TopDist = 0;
this.hole.OCSNoClone.elements[14] = this._BottomDist + this._Wall.Z;
}
this.hole.Height = newHeight;
}
}

Loading…
Cancel
Save