开发:修复因为BufferGeometryUtils.UpdatePts造成的光标丢失的错误

pull/1496/MERGE
ChenX 3 years ago
parent 25baa00f2f
commit a78601cf96

@ -396,8 +396,7 @@ export class AlignedDimension extends Entity
geometry.setPositions(nums);
}
else
BufferGeometryUtils.UpdatePts((<TLine>line).geometry as BufferGeometry, [this._FootP1, this._ArmP1, this._ArmP2, this._FootP2]);
BufferGeometryUtils.UpdatePts((<TLine>line).geometry as BufferGeometry, [this._FootP1, this._ArmP1, this._ArmP2, this._FootP2], true);
arrow1.scale.set(arrowSize, arrowSize, arrowSize);
arrow2.scale.set(arrowSize, arrowSize, arrowSize);

@ -65,7 +65,7 @@ export class DiameterDimension extends RadiusDimension
geo.setPositions([...sp.toArray(), ...this.center.toArray(), ...this.endPt.toArray()]);
}
else
BufferGeometryUtils.UpdatePts((<THREE.Line>line).geometry as BufferGeometry, [sp, this.center, this.endPt]);
BufferGeometryUtils.UpdatePts((<THREE.Line>line).geometry as BufferGeometry, [sp, this.center, this.endPt], true);
arrow.scale.set(arrowSize, arrowSize, arrowSize);
arrow2.scale.set(arrowSize, arrowSize, arrowSize);

@ -157,7 +157,7 @@ export class RadiusDimension extends Entity
geo.setPositions([...this.startPt.toArray(), ...this.center.toArray(), ...this.endPt.toArray()]);
}
else
BufferGeometryUtils.UpdatePts((<THREE.Line>line).geometry as BufferGeometry, [this.startPt, this.center, this.endPt]);
BufferGeometryUtils.UpdatePts((<THREE.Line>line).geometry as BufferGeometry, [this.startPt, this.center, this.endPt], true);
arrow.scale.set(arrowSize, arrowSize, arrowSize);

@ -183,7 +183,7 @@ export class SpotLight extends Light
con.updateMatrixWorld(false);
let line = light.children[1] as Line;
BufferGeometryUtils.UpdatePts(line.geometry as BufferGeometry, [new Vector3(), this.Target.applyMatrix4(this.OCSInv)]);
BufferGeometryUtils.UpdatePts(line.geometry as BufferGeometry, [new Vector3(), this.Target.applyMatrix4(this.OCSInv)], true);
if (light.target)
{

@ -241,7 +241,7 @@ export class GetPointServices implements EditorService
[
preView.WorldToViewPoint(prompt.BasePoint.clone()),
preView.WorldToViewPoint(this.curPoint.clone())
]);
], true);
line.computeLineDistances();
preView.UpdateScreen();
};

@ -184,7 +184,7 @@ export class GetRectPointServices
p.applyMatrix4(this._UCSMatrix);
app.Viewer.PreViewer.WorldToViewPoint(p);
}
BufferGeometryUtils.UpdatePts(this.rubberBandLine.geometry as BufferGeometry, pts);
BufferGeometryUtils.UpdatePts(this.rubberBandLine.geometry as BufferGeometry, pts, true);
this.rubberBandLine.geometry.computeBoundingSphere();
this.dynPrompt.UpdatePosition(
app.Viewer.PreViewer.ViewerPointToScreenPoint(midPoint(pts[0], pts[1])),

@ -46,7 +46,7 @@ export class GripDragServices implements EditorService
if (this.previewCrossLine)
{
let geo = this.previewCrossLine.geometry as BufferGeometry;
BufferGeometryUtils.UpdatePts(geo, PointShapeUtils.CrossLinePts(this._SnapSize));
BufferGeometryUtils.UpdatePts(geo, PointShapeUtils.CrossLinePts(this._SnapSize), true);
}
}
}

@ -834,7 +834,7 @@ export class SnapServices
if (pts)
{
BufferGeometryUtils.UpdatePts(geo, pts);
BufferGeometryUtils.UpdatePts(geo, pts, true);
geo.drawRange.count = pts.length;
}
}
@ -915,10 +915,7 @@ export class SnapServices
{
this.m_SupportExtLine.visible = true;
let geo = this.m_SupportExtLine.geometry as BufferGeometry;
BufferGeometryUtils.UpdatePts(
geo,
this.m_SupportExtLinePts
);
BufferGeometryUtils.UpdatePts(geo, this.m_SupportExtLinePts, true);
geo.drawRange.count = this.m_SupportExtLinePts.length;
this.m_SupportExtLine.computeLineDistances();

@ -12,17 +12,19 @@ export namespace BufferGeometryUtils
* BufferGeometry
* @param geo
* @param pts
* @param ignoreBoxError
* @returns true,false
*/
export function UpdatePts(geo: BufferGeometry, pts: Vector3[]): boolean
export function UpdatePts(geo: BufferGeometry, pts: Vector3[], ignoreBoxError = false): boolean
{
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 || (ignoreBoxError && bf.count > pts.length))//现在我们只有等于的时候才更新,因为如果不是这样,那么计算盒子的时候会出错(因为盒子内部的代码用的是所有的顶点)
{
bf.copyVector3sArray(pts);
bf.needsUpdate = true;
geo.drawRange.count = pts.length;
}
else
return false;

@ -89,8 +89,8 @@ export class Cursor
{
if (this._LineLength === l) return;
this._LineLength = l;
BufferGeometryUtils.UpdatePts(this._CrossLineObject.geometry as BufferGeometry, this.CrossLinePts());
BufferGeometryUtils.UpdatePts(this._OutsideCrossLineObject.geometry as BufferGeometry, this.OutsideLinePts());
BufferGeometryUtils.UpdatePts(this._CrossLineObject.geometry as BufferGeometry, this.CrossLinePts(), true);
BufferGeometryUtils.UpdatePts(this._OutsideCrossLineObject.geometry as BufferGeometry, this.OutsideLinePts(), true);
}
set LineLength3D(l: number)
{
@ -100,7 +100,7 @@ export class Cursor
for (let i = 0; i < this._threeDLine.children.length; i++)
{
let line = this._threeDLine.children[i] as LineSegments;
BufferGeometryUtils.UpdatePts(line.geometry as BufferGeometry, ptList[i]);
BufferGeometryUtils.UpdatePts(line.geometry as BufferGeometry, ptList[i], true);
}
}
UpdateCursor()
@ -148,8 +148,8 @@ export class Cursor
set SquareSize(size: number)
{
this._SquareSize = size;
BufferGeometryUtils.UpdatePts(this._SquareObject.geometry as BufferGeometry, this.SquarePts());
BufferGeometryUtils.UpdatePts(this._OutsideCrossLineObject.geometry as BufferGeometry, this.OutsideLinePts());
BufferGeometryUtils.UpdatePts(this._SquareObject.geometry as BufferGeometry, this.SquarePts(), true);
BufferGeometryUtils.UpdatePts(this._OutsideCrossLineObject.geometry as BufferGeometry, this.OutsideLinePts(), true);
this.UpdateEvent();
}
@ -161,8 +161,8 @@ export class Cursor
set CrossLineLength(length: number)
{
this._LineLength = length;
BufferGeometryUtils.UpdatePts(this._OutsideCrossLineObject.geometry as BufferGeometry, this.OutsideLinePts());
BufferGeometryUtils.UpdatePts(this._CrossLineObject.geometry as BufferGeometry, this.CrossLinePts());
BufferGeometryUtils.UpdatePts(this._OutsideCrossLineObject.geometry as BufferGeometry, this.OutsideLinePts(), true);
BufferGeometryUtils.UpdatePts(this._CrossLineObject.geometry as BufferGeometry, this.CrossLinePts(), true);
this.UpdateEvent();
}

Loading…
Cancel
Save