|
|
|
@ -252,7 +252,14 @@ export class TemplateRecord extends SymbolTableRecord
|
|
|
|
|
|
|
|
|
|
for (let br of brs)
|
|
|
|
|
br.ApplyMatrix(br.SpaceOCSInv);
|
|
|
|
|
|
|
|
|
|
//#region 1.定位(坐标系和大小)
|
|
|
|
|
/**
|
|
|
|
|
* LWH在存在定位空间和继承空间时的表达式行为不一致.
|
|
|
|
|
* - 在存在定位空间的时候,LWH是修改定位空间旋转后的值.
|
|
|
|
|
* - 不存在定位空间的时候,修改的是空间旋转前的值,因为此时已经没有空间尺寸可供旋转了,
|
|
|
|
|
* 只能先提供空间尺寸,然后才进行旋转.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (this.positioning)
|
|
|
|
|
{
|
|
|
|
@ -263,11 +270,7 @@ export class TemplateRecord extends SymbolTableRecord
|
|
|
|
|
this._CacheSpaceCS = this.positioning.SpaceCS;
|
|
|
|
|
this._CacheSpaceSize = this.positioning.SpaceSize;
|
|
|
|
|
|
|
|
|
|
this._CacheSpaceCS = this.RotateSpaceCS(this._CacheParamVars, paramMap, evaled, this._CacheSpaceCS, this._CacheSpaceSize);
|
|
|
|
|
|
|
|
|
|
this._CacheParamVars["L"] = this._CacheSpaceSize.x;
|
|
|
|
|
this._CacheParamVars["W"] = this._CacheSpaceSize.y;
|
|
|
|
|
this._CacheParamVars["H"] = this._CacheSpaceSize.z;
|
|
|
|
|
this.RotateSpaceCS(paramMap, evaled);
|
|
|
|
|
|
|
|
|
|
if (this.LParam.expr)
|
|
|
|
|
this._CacheSpaceSize.x = this.LParam.EvalUpdate(this._CacheParamVars, paramMap, evaled, false);
|
|
|
|
@ -276,35 +279,17 @@ export class TemplateRecord extends SymbolTableRecord
|
|
|
|
|
if (this.HParam.expr)
|
|
|
|
|
this._CacheSpaceSize.z = this.HParam.EvalUpdate(this._CacheParamVars, paramMap, evaled, false);
|
|
|
|
|
|
|
|
|
|
//更新LWH(通过定位空间)
|
|
|
|
|
this.LParam.UpdateParam(this._CacheSpaceSize.x);
|
|
|
|
|
this.WParam.UpdateParam(this._CacheSpaceSize.y);
|
|
|
|
|
this.HParam.UpdateParam(this._CacheSpaceSize.z);
|
|
|
|
|
|
|
|
|
|
if (this.positioning instanceof PositioningTemporary)
|
|
|
|
|
this.positioning = undefined;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
this.LParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
this.WParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
this.HParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
|
|
|
|
|
this.PXParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
this.PYParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
this.PZParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
|
|
|
|
|
let l = this.LParam.value as number;
|
|
|
|
|
let w = this.WParam.value as number;
|
|
|
|
|
let h = this.HParam.value as number;
|
|
|
|
|
let l = this.LParam.EvalUpdate(this._CacheParamVars, paramMap, evaled, false);
|
|
|
|
|
let w = this.WParam.EvalUpdate(this._CacheParamVars, paramMap, evaled, false);
|
|
|
|
|
let h = this.HParam.EvalUpdate(this._CacheParamVars, paramMap, evaled, false);
|
|
|
|
|
this._CacheSpaceSize = new Vector3(l, w, h);
|
|
|
|
|
|
|
|
|
|
//相对定位. use PX PY pZ
|
|
|
|
|
let baseP = new Vector3(this.PXParam.value as number, this.PYParam.value as number, this.PZParam.value as number);
|
|
|
|
|
baseP.applyMatrix4(this._CacheSpaceCS);
|
|
|
|
|
this._CacheSpaceCS.setPosition(baseP);
|
|
|
|
|
this._CacheSpaceCS = this.RotateSpaceCS(this._CacheParamVars, paramMap, evaled, this._CacheSpaceCS, this._CacheSpaceSize);
|
|
|
|
|
this.RotateSpaceCS(paramMap, evaled);
|
|
|
|
|
|
|
|
|
|
if (!this.Parent)
|
|
|
|
|
{
|
|
|
|
@ -324,16 +309,19 @@ export class TemplateRecord extends SymbolTableRecord
|
|
|
|
|
this.RYParam.expr = "";
|
|
|
|
|
this.RZParam.expr = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新LWH(通过定位空间)
|
|
|
|
|
this.LParam.UpdateParam(this._CacheSpaceSize.x);
|
|
|
|
|
this.WParam.UpdateParam(this._CacheSpaceSize.y);
|
|
|
|
|
this.HParam.UpdateParam(this._CacheSpaceSize.z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._CacheParamVars["L"] = this._CacheSpaceSize.x;
|
|
|
|
|
this._CacheParamVars["W"] = this._CacheSpaceSize.y;
|
|
|
|
|
this._CacheParamVars["H"] = this._CacheSpaceSize.z;
|
|
|
|
|
//相对定位. use PX PY PZ
|
|
|
|
|
this.UpdatePosition(paramMap, evaled);
|
|
|
|
|
|
|
|
|
|
//更新LWH(通过定位空间)
|
|
|
|
|
this.LParam.UpdateParam(this._CacheSpaceSize.x);
|
|
|
|
|
this.WParam.UpdateParam(this._CacheSpaceSize.y);
|
|
|
|
|
this.HParam.UpdateParam(this._CacheSpaceSize.z);
|
|
|
|
|
|
|
|
|
|
evaled.add(this.LParam);
|
|
|
|
|
evaled.add(this.WParam);
|
|
|
|
|
evaled.add(this.HParam);
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
@ -371,14 +359,31 @@ export class TemplateRecord extends SymbolTableRecord
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 使用PXPYPZ更新空间位置
|
|
|
|
|
*/
|
|
|
|
|
private UpdatePosition(paramMap: Map<string, TemplateParam>, evaled: Set<TemplateParam>)
|
|
|
|
|
{
|
|
|
|
|
this.PXParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
this.PYParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
this.PZParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
|
|
|
|
|
if (this.PXParam.value !== 0 || this.PYParam.value !== 0 || this.PZParam.value !== 0)
|
|
|
|
|
{
|
|
|
|
|
let baseP = new Vector3(this.PXParam.value as number, this.PYParam.value as number, this.PZParam.value as number);
|
|
|
|
|
baseP.applyMatrix4(this._CacheSpaceCS);
|
|
|
|
|
this._CacheSpaceCS.setPosition(baseP);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 旋转空间定位,如果旋转成功,那么SpaceSize和SpaceCS都可能被更新
|
|
|
|
|
*/
|
|
|
|
|
private RotateSpaceCS(vardefines: any, paramMap: Map<string, TemplateParam>, evaled: Set<TemplateParam>, spaceCS: Matrix4, spaceSize: Vector3)
|
|
|
|
|
private RotateSpaceCS(paramMap: Map<string, TemplateParam>, evaled: Set<TemplateParam>)
|
|
|
|
|
{
|
|
|
|
|
this.RXParam.EvalUpdate(vardefines, paramMap, evaled);
|
|
|
|
|
this.RYParam.EvalUpdate(vardefines, paramMap, evaled);
|
|
|
|
|
this.RZParam.EvalUpdate(vardefines, paramMap, evaled);
|
|
|
|
|
this.RXParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
this.RYParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
this.RZParam.EvalUpdate(this._CacheParamVars, paramMap, evaled);
|
|
|
|
|
//use RX RY RZ
|
|
|
|
|
let rx = Math.degToRad(this.RXParam.value as number);
|
|
|
|
|
let ry = Math.degToRad(this.RYParam.value as number);
|
|
|
|
@ -389,21 +394,23 @@ export class TemplateRecord extends SymbolTableRecord
|
|
|
|
|
let mry = new Matrix4().makeRotationY(ry);
|
|
|
|
|
let mrz = new Matrix4().makeRotationZ(rz);
|
|
|
|
|
let mro = mrz.multiply(mry.multiply(mrx));
|
|
|
|
|
let roSpace = mro.multiply(spaceCS);
|
|
|
|
|
let roSpace = mro.multiply(this._CacheSpaceCS);
|
|
|
|
|
let roSpaceInv = mrx.getInverse(roSpace); //变量复用
|
|
|
|
|
let transfromToRoSpace = roSpaceInv.multiply(spaceCS);
|
|
|
|
|
let box = new Box3(new Vector3(), spaceSize.clone());
|
|
|
|
|
let transfromToRoSpace = roSpaceInv.multiply(this._CacheSpaceCS);
|
|
|
|
|
let box = new Box3(new Vector3(), this._CacheSpaceSize.clone());
|
|
|
|
|
box.applyMatrix4(transfromToRoSpace);
|
|
|
|
|
box.getSize(spaceSize);
|
|
|
|
|
box.getSize(this._CacheSpaceSize);
|
|
|
|
|
let baseP = box.min.clone().applyMatrix4(roSpace);
|
|
|
|
|
roSpace.setPosition(baseP);
|
|
|
|
|
//更新LWH(通过定位空间)
|
|
|
|
|
this.LParam.UpdateParam(spaceSize.x);
|
|
|
|
|
this.WParam.UpdateParam(spaceSize.y);
|
|
|
|
|
this.HParam.UpdateParam(spaceSize.z);
|
|
|
|
|
spaceCS = roSpace;
|
|
|
|
|
this.LParam.UpdateParam(this._CacheSpaceSize.x);
|
|
|
|
|
this.WParam.UpdateParam(this._CacheSpaceSize.y);
|
|
|
|
|
this.HParam.UpdateParam(this._CacheSpaceSize.z);
|
|
|
|
|
this._CacheSpaceCS = roSpace;
|
|
|
|
|
}
|
|
|
|
|
return spaceCS;
|
|
|
|
|
this._CacheParamVars["L"] = this._CacheSpaceSize.x;
|
|
|
|
|
this._CacheParamVars["W"] = this._CacheSpaceSize.y;
|
|
|
|
|
this._CacheParamVars["H"] = this._CacheSpaceSize.z;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 以广度搜索优先更新节点树 */
|
|
|
|
|