|
@@ -383,30 +383,33 @@ export default class Player {
|
|
|
if (this.mode === 1) {
|
|
|
this.drawing = false;
|
|
|
this.floorplanControls.enabled = true;
|
|
|
- this.startObj = null;
|
|
|
+
|
|
|
if (this.drawLine) {
|
|
|
const points = this.drawLine.userData.points;
|
|
|
const dir = this.drawLine.userData.dir;
|
|
|
const imageId = this.touchImg.object.userData;
|
|
|
const finishLine = new LinePoints(points, this.matLine, dir, imageId);
|
|
|
-
|
|
|
+ // console.log("startObj", this.startObj);
|
|
|
this.scene.scene.add(finishLine);
|
|
|
const activeLineItem = {
|
|
|
id: finishLine.uuid,
|
|
|
imgId: imageId,
|
|
|
+ startId: this.startObj.userData,
|
|
|
dir: dir,
|
|
|
points: points,
|
|
|
};
|
|
|
const activeEdgeItem = {
|
|
|
id: imageId,
|
|
|
+ startId: this.startObj.userData,
|
|
|
dir: [dir],
|
|
|
};
|
|
|
|
|
|
this.renderLines.push(activeLineItem);
|
|
|
- console.log("this.touchImg", activeLineItem, points);
|
|
|
+ // console.log("this.touchImg", activeLineItem, points);
|
|
|
this.insertActiveEdge(activeEdgeItem);
|
|
|
this.scene.scene.remove(this.drawLine);
|
|
|
this.drawLine = null;
|
|
|
+ this.startObj = null;
|
|
|
}
|
|
|
}
|
|
|
if (this.mode === 2) {
|
|
@@ -846,21 +849,48 @@ export default class Player {
|
|
|
//单多张图片删除时要删除相关数据
|
|
|
deleteImageDataByIds(ids) {
|
|
|
ids.forEach((id) => {
|
|
|
- const edgeIndex = this.activeEdges.findIndex((item) => item.id === id);
|
|
|
const makerIndex = this.renderMarkers.findIndex((item) => item.id === id);
|
|
|
- const lineIndex = this.renderLines.findIndex((item) => item.imgId === id);
|
|
|
- if (edgeIndex > -1) {
|
|
|
- this.activeEdges.splice(edgeIndex, 1);
|
|
|
- }
|
|
|
if (makerIndex > -1) {
|
|
|
- this.renderMarkers.splice(edgeIndex, 1);
|
|
|
- }
|
|
|
- if (lineIndex > -1) {
|
|
|
- this.renderLines.splice(lineIndex, 1);
|
|
|
+ this.renderMarkers.splice(makerIndex, 1);
|
|
|
}
|
|
|
- });
|
|
|
|
|
|
- console.log("deleteImageByIds", ids);
|
|
|
+ const lines = this.renderLines.filter(
|
|
|
+ (item) => item.imgId === id || item.startId === id
|
|
|
+ );
|
|
|
+
|
|
|
+ lines.forEach((line) => {
|
|
|
+ const edge = this.activeEdges.find(
|
|
|
+ (item) => item.id === line.imgId || item.startId === line.imgId
|
|
|
+ );
|
|
|
+ if (edge) {
|
|
|
+ if (edge.dir.length > 0) {
|
|
|
+ const dirIndex = Array.from(edge.dir).findIndex(
|
|
|
+ (d) => d === line.dir
|
|
|
+ );
|
|
|
+ edge.dir.splice(dirIndex, 1);
|
|
|
+ } else {
|
|
|
+ const indexEdge = this.activeEdges.findIndex(
|
|
|
+ (a) => a.id === edge.id
|
|
|
+ );
|
|
|
+ console.warn("edge没dir", indexEdge);
|
|
|
+ indexEdge > -1 && this.activeEdges.splice(indexEdge, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const lineIndex = this.renderLines.findIndex(
|
|
|
+ (item) => item.imageId === line.imageId
|
|
|
+ );
|
|
|
+ console.log("lineIndex", lineIndex);
|
|
|
+ if (lineIndex > -1) {
|
|
|
+ this.renderLines.splice(lineIndex, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ console.log("lines", lines);
|
|
|
+ });
|
|
|
+ this.syncDrawData();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.scene.emit("autoSave");
|
|
|
+ }, 2500);
|
|
|
}
|
|
|
update = () => {
|
|
|
if (this.floorplanControls.enabled) {
|