|
@@ -3,6 +3,7 @@ import * as THREE from "three";
|
|
import FloorplanControls from "../controls/FloorplanControls.js";
|
|
import FloorplanControls from "../controls/FloorplanControls.js";
|
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
|
|
import Line from "../box/object/Line";
|
|
import Line from "../box/object/Line";
|
|
|
|
+import LinePoints from "../box/object/LinePoints.js";
|
|
import { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js";
|
|
import { LineMaterial } from "three/examples/jsm/lines/LineMaterial.js";
|
|
|
|
|
|
const convertScreenToNDC = function (event, domElement) {
|
|
const convertScreenToNDC = function (event, domElement) {
|
|
@@ -39,7 +40,6 @@ export default class Player {
|
|
init = () => {
|
|
init = () => {
|
|
// //floorplanControls
|
|
// //floorplanControls
|
|
// this.floorplanControls = new FloorplanControls(this.orthCamera, this.scene.domElement, this);
|
|
// this.floorplanControls = new FloorplanControls(this.orthCamera, this.scene.domElement, this);
|
|
-
|
|
|
|
this.floorplanControls = new OrbitControls(
|
|
this.floorplanControls = new OrbitControls(
|
|
this.orthCamera,
|
|
this.orthCamera,
|
|
this.scene.domElement
|
|
this.scene.domElement
|
|
@@ -59,6 +59,26 @@ export default class Player {
|
|
this.onBindEvent();
|
|
this.onBindEvent();
|
|
this.inited = true;
|
|
this.inited = true;
|
|
console.log("this.floorplanControls", this.floorplanControls);
|
|
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,
|
|
|
|
+ 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);
|
|
};
|
|
};
|
|
|
|
|
|
onPointerMove = (e) => {
|
|
onPointerMove = (e) => {
|
|
@@ -95,14 +115,30 @@ export default class Player {
|
|
// this.floorplanControls.enabled = false;
|
|
// this.floorplanControls.enabled = false;
|
|
};
|
|
};
|
|
onPointerUp = (e) => {
|
|
onPointerUp = (e) => {
|
|
|
|
+ console.log("last Line dir", this.drawLine);
|
|
// this.renderLines.push(this.drawLine);
|
|
// this.renderLines.push(this.drawLine);
|
|
- console.log("last Line", this.drawLine);
|
|
|
|
|
|
+ const points = this.getPostionsFromDrawLine();
|
|
|
|
+ console.log("last Line-wPos", points);
|
|
|
|
+
|
|
this.pointerup = convertScreenToNDC(e, this.scene.domElement);
|
|
this.pointerup = convertScreenToNDC(e, this.scene.domElement);
|
|
this.drawing = false;
|
|
this.drawing = false;
|
|
this.floorplanControls.enabled = true;
|
|
this.floorplanControls.enabled = true;
|
|
this.startObj = null;
|
|
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);
|
|
|
|
+ }
|
|
|
|
+ return wPos;
|
|
|
|
+ }
|
|
Listener = {
|
|
Listener = {
|
|
onPointerDown: this.onPointerDown.bind(this),
|
|
onPointerDown: this.onPointerDown.bind(this),
|
|
onPointerMove: this.onPointerMove.bind(this),
|
|
onPointerMove: this.onPointerMove.bind(this),
|