|
|
|
@ -1,7 +1,7 @@ |
|
|
|
import * as THREE from 'three' |
|
|
|
import Toolbox from '@/model/itemType/Toolbox.ts' |
|
|
|
import type ItemTypeLine from '@/model/itemType/ItemTypeLine.ts' |
|
|
|
import { findObject3DById } from '@/model/ModelUtils.ts' |
|
|
|
import { findObject3DById, getAllControlPoints } from '@/model/ModelUtils.ts' |
|
|
|
import EventBus from '@/runtime/EventBus' |
|
|
|
|
|
|
|
/** |
|
|
|
@ -24,13 +24,13 @@ export default class ToolboxLine extends Toolbox { |
|
|
|
afterMoveTemplateLine(line: THREE.Mesh, startPoint: THREE.Object3D, endPoint: THREE.Object3D) { |
|
|
|
} |
|
|
|
|
|
|
|
afterDeleteLine(line: THREE.Object3D, point: THREE.Object3D, relationPointIds: string[]) { |
|
|
|
afterDeleteLine(line: THREE.Object3D, point: THREE.Object3D) { |
|
|
|
} |
|
|
|
|
|
|
|
stop() { |
|
|
|
super.stop() |
|
|
|
|
|
|
|
this.tempLine && this.viewport.scene.remove(this.tempLine) |
|
|
|
this.tempLine && this.removeFromScene(this.tempLine) |
|
|
|
this.tempLine = undefined |
|
|
|
} |
|
|
|
|
|
|
|
@ -44,9 +44,9 @@ export default class ToolboxLine extends Toolbox { |
|
|
|
* 删除点 |
|
|
|
*/ |
|
|
|
deletePoint(point: THREE.Object3D) { |
|
|
|
const relationPointIds = [] |
|
|
|
const allPoints = getAllControlPoints() |
|
|
|
|
|
|
|
const deletedPoints = _.remove(this.itemType.pointArray, (p) => p.uuid === point.uuid) |
|
|
|
const deletedPoints = _.remove(getAllControlPoints(), (p) => p.uuid === point.uuid) |
|
|
|
if (!deletedPoints || deletedPoints.length !== 1) { |
|
|
|
console.warn('没有找到要删除的点:', point.uuid) |
|
|
|
return |
|
|
|
@ -62,15 +62,10 @@ export default class ToolboxLine extends Toolbox { |
|
|
|
} |
|
|
|
|
|
|
|
// 找出与这个点相关的其他点
|
|
|
|
this.itemType.pointArray.forEach(p => { |
|
|
|
allPoints.forEach(p => { |
|
|
|
if (p.userData.center) { |
|
|
|
relationPointIds.push(..._.filter(p.userData.center, i => i === point.uuid)) |
|
|
|
_.remove(p.userData.center, i => i === point.uuid) |
|
|
|
|
|
|
|
relationPointIds.push(..._.filter(p.userData.in, i => i === point.uuid)) |
|
|
|
_.remove(p.userData.in, i => i === point.uuid) |
|
|
|
|
|
|
|
relationPointIds.push(..._.filter(p.userData.out, i => i === point.uuid)) |
|
|
|
_.remove(p.userData.out, i => i === point.uuid) |
|
|
|
} |
|
|
|
}) |
|
|
|
@ -79,7 +74,7 @@ export default class ToolboxLine extends Toolbox { |
|
|
|
_.forEach(point.userData.lines, (line) => { |
|
|
|
const lineObject = findObject3DById(this.viewport.scene, line) |
|
|
|
this.removeFromScene(lineObject) |
|
|
|
this.afterDeleteLine(lineObject, point, relationPointIds) |
|
|
|
this.afterDeleteLine(lineObject, point) |
|
|
|
}) |
|
|
|
|
|
|
|
// 从场景中删除点
|
|
|
|
@ -136,7 +131,7 @@ export default class ToolboxLine extends Toolbox { |
|
|
|
if (this.startPoint) { |
|
|
|
this.afterAddPoint(this.startPoint, catchPoint) |
|
|
|
} |
|
|
|
this.tempLine && this.viewport.scene.remove(this.tempLine) |
|
|
|
this.tempLine && this.removeFromScene(this.tempLine) |
|
|
|
this.tempLine = undefined |
|
|
|
return |
|
|
|
} |
|
|
|
@ -147,7 +142,7 @@ export default class ToolboxLine extends Toolbox { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
this.tempLine && this.viewport.scene.remove(this.tempLine) |
|
|
|
this.tempLine && this.removeFromScene(this.tempLine) |
|
|
|
this.tempLine = undefined |
|
|
|
return r |
|
|
|
} |
|
|
|
|