|
@@ -2,10 +2,27 @@ import * as THREE from "three";
|
|
|
import TouchEdge from "./TouchEdge";
|
|
|
|
|
|
export default class ImgLabel extends THREE.Mesh {
|
|
|
- constructor(texture, matLine) {
|
|
|
- const width = 1.5;
|
|
|
- const height = 0.85;
|
|
|
-
|
|
|
+ constructor(texture, matLine, isHorizontal = true) {
|
|
|
+ let width, height, p;
|
|
|
+ if (isHorizontal) {
|
|
|
+ width = 1.5;
|
|
|
+ height = 0.85;
|
|
|
+ p = [
|
|
|
+ [-0.75, 0, -0.425, 0.75, 0, -0.425],
|
|
|
+ [-0.75, 0, -0.425, -0.75, 0, 0.425],
|
|
|
+ [-0.75, 0, 0.425, 0.75, 0, 0.425],
|
|
|
+ [0.75, 0, 0.425, 0.75, 0, -0.425],
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ width = 1.5;
|
|
|
+ height = 2;
|
|
|
+ p = [
|
|
|
+ [-0.75, 0, -1, 0.75, 0, -1],
|
|
|
+ [-0.75, 0, -1, -0.75, 0, 1],
|
|
|
+ [-0.75, 0, 1, 0.75, 0, 1],
|
|
|
+ [0.75, 0, 1, 0.75, 0, -1],
|
|
|
+ ];
|
|
|
+ }
|
|
|
const g = new THREE.PlaneGeometry(width, height);
|
|
|
g.rotateX(-Math.PI / 2);
|
|
|
|
|
@@ -13,17 +30,14 @@ export default class ImgLabel extends THREE.Mesh {
|
|
|
map: texture,
|
|
|
});
|
|
|
super(g, m);
|
|
|
- // console.log(g);
|
|
|
- const p = [
|
|
|
- [-0.75, 0, -0.425, 0.75, 0, -0.425],
|
|
|
- [-0.75, 0, -0.425, -0.75, 0, 0.425],
|
|
|
- [-0.75, 0, 0.425, 0.75, 0, 0.425],
|
|
|
- [0.75, 0, 0.425, 0.75, 0, -0.425],
|
|
|
- ];
|
|
|
+
|
|
|
+ this.width = width;
|
|
|
+ this.height = height;
|
|
|
this.touchLines = new TouchEdge(p, matLine);
|
|
|
|
|
|
this.touchLines.position.y += 0.5;
|
|
|
this.add(this.touchLines);
|
|
|
+ // this.touchLines.children.forEach((child) => (child.visible = true));
|
|
|
|
|
|
this.name = "imglabel";
|
|
|
}
|