ldj 1 éve
szülő
commit
6f06c3dc70

+ 23 - 12
src/core/box/object/Line.js

@@ -14,20 +14,31 @@ function pointsToArray(arr) {
 export default class TouchEdge extends Line2 {
 export default class TouchEdge extends Line2 {
   constructor(startPoint, endPoint, endEdge, matLine) {
   constructor(startPoint, endPoint, endEdge, matLine) {
     let points;
     let points;
-    // if(endEdge.name === 0) { //top
+    if(endEdge.name === 0) { //top
       let a = startPoint.clone()
       let a = startPoint.clone()
-      let b = new THREE.Vector3(startPoint.x, startPoint.y, endEdge.y - offset)
-      let c = new THREE.Vector3(endPoint.x, endPoint.y, endEdge.y - offset)
-      let d = new THREE.Vector3(endPoint.x, endPoint.y, endEdge.y)
+      let b = new THREE.Vector3(startPoint.x, startPoint.y, endEdge.y + endEdge.parent.parent.position.z - offset)
+      let c = new THREE.Vector3(endPoint.x, endPoint.y, endEdge.y + endEdge.parent.parent.position.z - offset)
+      let d = new THREE.Vector3(endPoint.x, endPoint.y, endEdge.y + endEdge.parent.parent.position.z)
       points = pointsToArray([a,b,c,d])
       points = pointsToArray([a,b,c,d])
-      console.log(points)
-    // } else if(endEdge.name === 1) { //left
-      
-    // } else if(endEdge.name === 2) { //bottom
-
-    // } else { //right
-
-    // }
+    } else if(endEdge.name === 1) { //left
+      let a = startPoint.clone()
+      let b = new THREE.Vector3((startPoint.x + endPoint.x) / 2, startPoint.y, startPoint.z)
+      let c = new THREE.Vector3((startPoint.x + endPoint.x) / 2, startPoint.y, endPoint.z)
+      let d = new THREE.Vector3(endEdge.x + endEdge.parent.parent.parent.position.x, startPoint.y, endPoint.z)
+      points = pointsToArray([a,b,c,d])
+    } else if(endEdge.name === 2) { //bottom
+      let a = startPoint.clone()
+      let b = new THREE.Vector3(startPoint.x, startPoint.y, endEdge.y + endEdge.parent.parent.position.z + offset)
+      let c = new THREE.Vector3(endPoint.x, endPoint.y, endEdge.y + endEdge.parent.parent.position.z + offset)
+      let d = new THREE.Vector3(endPoint.x, endPoint.y, endEdge.y + endEdge.parent.parent.position.z)
+      points = pointsToArray([a,b,c,d])
+    } else { //right 
+      let a = startPoint.clone()
+      let b = new THREE.Vector3((startPoint.x + endPoint.x) / 2, startPoint.y, startPoint.z)
+      let c = new THREE.Vector3((startPoint.x + endPoint.x) / 2, startPoint.y, endPoint.z)
+      let d = new THREE.Vector3(endEdge.x + endEdge.parent.parent.parent.position.x, startPoint.y, endPoint.z)
+      points = pointsToArray([a,b,c,d])
+    }
 
 
     const geometry = new LineGeometry();
     const geometry = new LineGeometry();
     geometry.setPositions(points);
     geometry.setPositions(points);

+ 1 - 0
src/core/box/object/TouchEdge.js

@@ -19,5 +19,6 @@ export default class TouchEdge extends THREE.Group {
       line.y = i[2]
       line.y = i[2]
       this.add( line );
       this.add( line );
     });
     });
+    console.log(this)
   }
   }
 }
 }

+ 19 - 4
src/core/player/Player.js

@@ -119,15 +119,30 @@ export default class Player {
   }
   }
 
 
   setActiveLine = (obj) => {
   setActiveLine = (obj) => {
-    function getTouchLine(x, y) {
-      if(x >= 0.5 && y >= 0.5) {
+    function getTouchLine(x, y) { // [0 - 1]
+      x -= 0.5
+      y -= 0.5
+      console.log(x,y)
+      if(x >= 0 && y >= 0) {
         if(x > y) {
         if(x > y) {
           return 3
           return 3
         } else {
         } else {
           return 0
           return 0
         }
         }
-      } else {
-        if(x < y) {
+      } else if(x >= 0 && y <= 0){
+        if(x > Math.abs(y)) {
+          return 3
+        } else {
+          return 2
+        }
+      } else if(x <= 0 && y >= 0) {
+        if(Math.abs(x) > y) {
+          return 1
+        } else {
+          return 0
+        }
+      } else if(x <= 0 && y <= 0){
+        if(-x > -y) {
           return 1
           return 1
         } else {
         } else {
           return 2
           return 2