|
@@ -666,11 +666,17 @@ function selectWhichFace(lineArr, faceArr, current, scaleTime, scaleTimeH) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
-*
|
|
|
-* @param {*} point
|
|
|
+* 求与该平面相交的线段的相关信息
|
|
|
+* @param {array} faceLine 面的索引数组
|
|
|
+* @return {object} verticalLineData
|
|
|
*/
|
|
|
-function findverticalLine(point, faceLine) {
|
|
|
+function findverticalLine(faceLine) {
|
|
|
let lineAry = [];
|
|
|
+ let verticalLineData = {
|
|
|
+ lineAry: [],
|
|
|
+ vecAry: [],
|
|
|
+ verticalVec: []
|
|
|
+ }
|
|
|
for (let k = 0; k < faceLine.length; k++) {
|
|
|
n_panorama_line_3d.find(item => {
|
|
|
if (item['3d_id'] === faceLine[k]) {
|
|
@@ -678,23 +684,55 @@ function findverticalLine(point, faceLine) {
|
|
|
let sta_point = item[geoKeys[l]];
|
|
|
for (let i = 0; i < n_panorama_line_3d.length; i++) {
|
|
|
for (let j = 0; j < geoKeys.length; j++) {
|
|
|
- let curpoint = n_panorama_line_3d[i][geoKeys[j]];
|
|
|
+ let line = n_panorama_line_3d[i];
|
|
|
+ let curpoint = line[geoKeys[j]];
|
|
|
let id = n_panorama_line_3d[i]['3d_id'];
|
|
|
- if (arrayEquals(sta_point, curpoint) && faceLine.indexOf(id) < 0 && lineAry.indexOf(id) < 0) {
|
|
|
- lineAry.push(id);
|
|
|
+ // 如果相交线段在当前面中, 则求它对应的向量
|
|
|
+ if (arrayEquals(sta_point, curpoint) && faceLine.indexOf(id) >= 0 && verticalLineData.vecAry.length < 2) {
|
|
|
+ let croodData = getThreeDVec(line['3d_point1'], line['3d_point2']);
|
|
|
+ let vec3 = new THREE.Vector3(croodData[0], croodData[1], croodData[2])
|
|
|
+ verticalLineData.vecAry.push(vec3);
|
|
|
+ }
|
|
|
+ if (arrayEquals(sta_point, curpoint) && faceLine.indexOf(id) < 0 && verticalLineData.lineAry.indexOf(id) < 0) {
|
|
|
+ verticalLineData.lineAry.push(id);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
}
|
|
|
- console.log(lineAry);
|
|
|
+ let crossVec = new THREE.Vector3();
|
|
|
+ crossVec.crossVectors(verticalLineData.vecAry[0], verticalLineData.vecAry[1]);
|
|
|
+ verticalLineData.verticalVec.push(crossVec.x, crossVec.y, crossVec.z)
|
|
|
+ // console.log(tmp);
|
|
|
+ // console.log(lineAry);
|
|
|
return lineAry;
|
|
|
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 计算三维空间中的向量
|
|
|
+ * @param {array} point1
|
|
|
+ * @param {array} point2
|
|
|
+ */
|
|
|
+function getThreeDVec(point1, point2) {
|
|
|
+ if (!point1 || !point2 || (point1.length !== point2.length)) {
|
|
|
+ console.log('点数据有误, 请检查');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let vec = [];
|
|
|
+ for (let i = 0; i < point1.length; i++) {
|
|
|
+ let val = point1[i] - point2[i];
|
|
|
+ vec.push(val);
|
|
|
+ }
|
|
|
+ if (vec.length < 3) {
|
|
|
+ console.log('所求三维向量有误, 请检查');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ return vec;
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 根据sta查找点
|