Pārlūkot izejas kodu

feat(map): update

gemercheung 1 gadu atpakaļ
vecāks
revīzija
c89939f919
1 mainītis faili ar 13 papildinājumiem un 2 dzēšanām
  1. 13 2
      src/core/player/Player.js

+ 13 - 2
src/core/player/Player.js

@@ -79,7 +79,9 @@ export default class Player {
       let pos = new THREE.Vector3(0, 0, -1);
       pos.unproject(this.orthCamera);
       pos.y = 5;
-      this.symbolIndex += 1;
+      const lastIndex = this.getLaSybIndex();
+      this.symbolIndex = lastIndex + 1;
+
       this.symbol = new CircleTextLabel(this.symbolIndex, pos);
       this.symbol.visible = false;
       this.scene.scene.add(this.symbol);
@@ -103,6 +105,15 @@ export default class Player {
     }
     this.scene.emit("mode", this.mode);
   }
+  getLaSybIndex() {
+    const maxIndexObject = this.renderSymbols.reduce(
+      (max, current) => {
+        return current.index > max.index ? current : max;
+      },
+      { index: 0, point: [] }
+    );
+    return maxIndexObject.index;
+  }
 
   // removeMarker() {
   //   if (this.marker) {
@@ -339,7 +350,7 @@ export default class Player {
         );
         lasPos.unproject(this.orthCamera);
         lasPos.y = 5;
-        
+
         const activeSymbolItem = {
           index: this.symbolIndex,
           point: lasPos.toArray(),