|
@@ -34,6 +34,9 @@ export default class Player {
|
|
|
this.drawing = false;
|
|
|
this.inited = false;
|
|
|
this.renderLines = [];
|
|
|
+ this.activeEdges = [];
|
|
|
+ this.matLine = null;
|
|
|
+ this.lineColor = 0xe44d54;
|
|
|
this.init();
|
|
|
}
|
|
|
|
|
@@ -45,40 +48,32 @@ export default class Player {
|
|
|
this.scene.domElement
|
|
|
);
|
|
|
|
|
|
- // this.floorplanControls.enablePan = true;
|
|
|
- // this.floorplanControls.target.set(0,0,0);
|
|
|
+ this.floorplanControls.enablePan = true;
|
|
|
+ // this.floorplanControls.target.set(0, 1, 0);
|
|
|
// this.floorplanControls.rotateSpeed = 0.5;
|
|
|
// this.floorplanControls.panSpeed = 0.75
|
|
|
// this.floorplanControls.maxDistance = 100
|
|
|
// this.floorplanControls.minDistance = 3.5
|
|
|
- // this.floorplanControls.maxZoom = 500
|
|
|
- // this.floorplanControls.minZoom = 1
|
|
|
+ this.floorplanControls.maxZoom = 500;
|
|
|
+ this.floorplanControls.minZoom = 100;
|
|
|
|
|
|
this.floorplanControls.enableRotate = false;
|
|
|
this.raycaster = new THREE.Raycaster();
|
|
|
this.onBindEvent();
|
|
|
this.inited = true;
|
|
|
+
|
|
|
console.log("this.floorplanControls", this.floorplanControls);
|
|
|
|
|
|
- // const demoData = [
|
|
|
- // -0.005454589843750136, 5, -0.4604446894034718, -0.005454589843750136, 5,
|
|
|
- // -0.175, -0.02363647460937501, 5, -0.175, -0.02363647460937501, 5,
|
|
|
- // 0.07500000000000001,
|
|
|
- // ];
|
|
|
- const demoData = [
|
|
|
- 0.48909057617188, 5, -0.5113538080557902, 0.48909057617188, 5,
|
|
|
- -0.12500000000000006, 2.0018179931640683, 5, -0.12500000000000006,
|
|
|
- 2.0018179931640683, 5, -0.37500000000000006,
|
|
|
- ];
|
|
|
- const matLine = new LineMaterial({
|
|
|
- color: 0x26559b,
|
|
|
+ this.matLine = new LineMaterial({
|
|
|
+ color: this.lineColor,
|
|
|
linewidth: 3, // in world units with size attenuation, pixels otherwise
|
|
|
dashed: false,
|
|
|
alphaToCoverage: true,
|
|
|
});
|
|
|
- matLine.resolution = new THREE.Vector2(this.scene.width, this.scene.height);
|
|
|
- const demoLine = new LinePoints(demoData, 2, matLine);
|
|
|
- this.scene.scene.add(demoLine);
|
|
|
+ this.matLine.resolution = new THREE.Vector2(
|
|
|
+ this.scene.width,
|
|
|
+ this.scene.height
|
|
|
+ );
|
|
|
};
|
|
|
|
|
|
onPointerMove = (e) => {
|
|
@@ -115,30 +110,23 @@ export default class Player {
|
|
|
// this.floorplanControls.enabled = false;
|
|
|
};
|
|
|
onPointerUp = (e) => {
|
|
|
- console.log("last Line dir", this.drawLine);
|
|
|
- // this.renderLines.push(this.drawLine);
|
|
|
- const points = this.getPostionsFromDrawLine();
|
|
|
- console.log("last Line-wPos", points);
|
|
|
-
|
|
|
+ // console.log("last Line-wPos", points);
|
|
|
this.pointerup = convertScreenToNDC(e, this.scene.domElement);
|
|
|
this.drawing = false;
|
|
|
this.floorplanControls.enabled = true;
|
|
|
this.startObj = null;
|
|
|
- };
|
|
|
|
|
|
- getPostionsFromDrawLine() {
|
|
|
- if (!this.drawLine) {
|
|
|
- return [];
|
|
|
- }
|
|
|
- let gp = this.drawLine.geometry.attributes.position;
|
|
|
- let wPos = [];
|
|
|
- for (let i = 0; i < gp.count; i++) {
|
|
|
- let p = new THREE.Vector3().fromBufferAttribute(gp, i); // set p from `position`
|
|
|
- this.drawLine.localToWorld(p); // p has wordl coords
|
|
|
- wPos.push(p);
|
|
|
+ if (this.drawLine) {
|
|
|
+ const points = this.drawLine.userData.points;
|
|
|
+ const dir = this.drawLine.userData.dir;
|
|
|
+ const finishLine = new LinePoints(points, 0, this.matLine);
|
|
|
+ this.renderLines.push(points);
|
|
|
+ this.scene.scene.add(finishLine);
|
|
|
+ const imageId = this.touchImg.object.userData;
|
|
|
+ console.log("this.touchImg", dir, imageId, points);
|
|
|
}
|
|
|
- return wPos;
|
|
|
- }
|
|
|
+ };
|
|
|
+
|
|
|
Listener = {
|
|
|
onPointerDown: this.onPointerDown.bind(this),
|
|
|
onPointerMove: this.onPointerMove.bind(this),
|
|
@@ -186,10 +174,8 @@ export default class Player {
|
|
|
e.unproject(this.orthCamera);
|
|
|
s.y = 5;
|
|
|
e.y = 5;
|
|
|
-
|
|
|
- // console.log(s)
|
|
|
const matLine = new LineMaterial({
|
|
|
- color: 0x26559b,
|
|
|
+ color: this.lineColor,
|
|
|
linewidth: 3, // in world units with size attenuation, pixels otherwise
|
|
|
dashed: false,
|
|
|
alphaToCoverage: true,
|