开发:修复因为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); geometry.setPositions(nums);
} }
else 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); arrow1.scale.set(arrowSize, arrowSize, arrowSize);
arrow2.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()]); geo.setPositions([...sp.toArray(), ...this.center.toArray(), ...this.endPt.toArray()]);
} }
else 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); arrow.scale.set(arrowSize, arrowSize, arrowSize);
arrow2.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()]); geo.setPositions([...this.startPt.toArray(), ...this.center.toArray(), ...this.endPt.toArray()]);
} }
else 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); arrow.scale.set(arrowSize, arrowSize, arrowSize);

@ -183,7 +183,7 @@ export class SpotLight extends Light
con.updateMatrixWorld(false); con.updateMatrixWorld(false);
let line = light.children[1] as Line; 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) if (light.target)
{ {

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

@ -184,7 +184,7 @@ export class GetRectPointServices
p.applyMatrix4(this._UCSMatrix); p.applyMatrix4(this._UCSMatrix);
app.Viewer.PreViewer.WorldToViewPoint(p); 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.rubberBandLine.geometry.computeBoundingSphere();
this.dynPrompt.UpdatePosition( this.dynPrompt.UpdatePosition(
app.Viewer.PreViewer.ViewerPointToScreenPoint(midPoint(pts[0], pts[1])), app.Viewer.PreViewer.ViewerPointToScreenPoint(midPoint(pts[0], pts[1])),

@ -46,7 +46,7 @@ export class GripDragServices implements EditorService
if (this.previewCrossLine) if (this.previewCrossLine)
{ {
let geo = this.previewCrossLine.geometry as BufferGeometry; 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) if (pts)
{ {
BufferGeometryUtils.UpdatePts(geo, pts); BufferGeometryUtils.UpdatePts(geo, pts, true);
geo.drawRange.count = pts.length; geo.drawRange.count = pts.length;
} }
} }
@ -915,10 +915,7 @@ export class SnapServices
{ {
this.m_SupportExtLine.visible = true; this.m_SupportExtLine.visible = true;
let geo = this.m_SupportExtLine.geometry as BufferGeometry; let geo = this.m_SupportExtLine.geometry as BufferGeometry;
BufferGeometryUtils.UpdatePts( BufferGeometryUtils.UpdatePts(geo, this.m_SupportExtLinePts, true);
geo,
this.m_SupportExtLinePts
);
geo.drawRange.count = this.m_SupportExtLinePts.length; geo.drawRange.count = this.m_SupportExtLinePts.length;
this.m_SupportExtLine.computeLineDistances(); this.m_SupportExtLine.computeLineDistances();

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

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

Loading…
Cancel
Save