优化:角度标注的绘制逻辑(性能更高)

pull/1495/MERGE
ChenX 3 years ago
parent 14c79089e3
commit 1eb8731f56

@ -123,6 +123,7 @@ export class LineAngularDimension extends Entity
}
MoveGripPoints(indexList: number[], vec: Vector3)
{
this.WriteAllObjectRecord();
let arr = [
this._L1StartPoint,
this._L1EndPoint,
@ -194,8 +195,6 @@ export class LineAngularDimension extends Entity
let colorMaterial = GetDimLineMaterial(this, renderType);
let line = this._Arc.GetDrawObjectFromRenderType(renderType);
let arrow1 = new Mesh(BufferGeometryUtils.ArrowGeometry(), colorMaterial);
let arrow2 = new Mesh(BufferGeometryUtils.ArrowGeometry(), colorMaterial);
let arrowSize = 10;
@ -218,8 +217,7 @@ export class LineAngularDimension extends Entity
arrow2.scale.set(arrowSize, arrowSize, arrowSize);
let obj = new Object3D();
obj.add(arrow1, arrow2, l, l2, line);
AddEntityDrawObject(obj, this._Text, renderType);
obj.add(arrow1, arrow2, l, l2);
this.UpdateDrawObject(renderType, obj);
return obj;
}
@ -286,7 +284,8 @@ export class LineAngularDimension extends Entity
}
UpdateDrawObject(renderType: RenderType, obj: Object3D)
{
let [arrow1, arrow2, li1, li2, line, textObj] = obj.children;
let [arrow1, arrow2, li1, li2] = obj.children;
obj.remove(...obj.children.splice(4));
let l1 = new Line(this._L1StartPoint, this._L1EndPoint);
let l2 = new Line(this._L2StartPoint, this._L2EndPoint);
@ -294,6 +293,7 @@ export class LineAngularDimension extends Entity
let insP = l1.IntersectWith(l2, IntersectOption.ExtendBoth)[0];
if (insP)
{
this._Arc.AutoUpdate = false;//如果没有在这边关闭这个,那么Arc的盒子将错误
this._Arc.Center = insP;
this._Arc.Radius = insP.distanceTo(this._DimPoint);
@ -313,12 +313,15 @@ export class LineAngularDimension extends Entity
for (let i = 0; i < ans.length; i++)
{
let ni = FixIndex(i + 1, ans.length);
this._Arc.StartAngle = ans[ni];
this._Arc.EndAngle = ans[i];
if (this._Arc.ParamOnCurve(this._Arc.GetParamAtAngle(dimAn)))
{
obj.remove(line);
obj.remove(textObj);
this._Arc.AutoUpdate = true;
this._Arc.DeferUpdate();
AddEntityDrawObject(obj, this._Arc, renderType);
arrow1.position.copy(this._Arc.StartPoint);
arrow1.rotation.z = this._Arc.GetFistDerivAngle(0) + Math.PI / 2;
@ -328,10 +331,14 @@ export class LineAngularDimension extends Entity
arrow2.rotation.z = this._Arc.GetFistDerivAngle(1) - Math.PI / 2;
arrow2.updateMatrix();
this._Text.AutoUpdate = false;//更新标记
this._Text.TextString = this._TextString ? this._TextString.replace("<>", this.GetString()) : this.GetString();
this._Text.Position = this._Arc.GetPointAtParam(0.5);
this._Text.TextRotation = this._Arc.GetAngleAtParam(0.5) % (Math.PI) - Math.PI / 2;
this._Text.AutoUpdate = true;//更新标记
this._Text.DeferUpdate();
AddEntityDrawObject(obj, this._Text, renderType);
break;
}

@ -19,11 +19,10 @@ export namespace BufferGeometryUtils
let bf = geo.getAttribute("position") as BufferAttribute;
if (bf === undefined)
geo.setFromPoints(pts);
else if (bf.count >= pts.length)
else if (bf.count === pts.length)//现在我们只有等于的时候才更新,因为如果不是这样,那么计算盒子的时候会出错(因为盒子内部的代码用的是所有的顶点)
{
bf.copyVector3sArray(pts);
bf.needsUpdate = true;
geo.drawRange.count = pts.length;
}
else
return false;

Loading…
Cancel
Save