|
|
@@ -6,7 +6,8 @@ import {Line2} from "../../../libs/three.js/lines/Line2.js";
|
|
|
import {LineGeometry} from "../../../libs/three.js/lines/LineGeometry.js";
|
|
|
import {LineMaterial} from "../../../libs/three.js/lines/LineMaterial.js";
|
|
|
//画线等函数--by 许钟文
|
|
|
-import {Features} from "../../Features.js";
|
|
|
+import {Features} from "../../Features.js";
|
|
|
+import Common from './Common.js'
|
|
|
|
|
|
var defaultColor = new THREE.Color(1,1,1);//config.applicationName == "zhiHouse" ? Colors.zhiBlue : Colors.lightGreen;
|
|
|
|
|
|
@@ -28,6 +29,21 @@ function dealPosArr(points){//识别是否每个点都不一样,把连续点
|
|
|
|
|
|
}
|
|
|
|
|
|
+let center = new THREE.Vector3
|
|
|
+function extractPos(posArr){//尽量让所有点都靠近原点
|
|
|
+
|
|
|
+ //console.log('extractPos', posArr.map(e=>e.clone()))
|
|
|
+ let bound = new THREE.Box3
|
|
|
+ posArr.forEach(e=>bound.expandByPoint(e))
|
|
|
+ bound.getCenter(center)
|
|
|
+
|
|
|
+ posArr.forEach(e=>e.sub(center))
|
|
|
+
|
|
|
+ //console.log('extractPos2 ', posArr.map(e=>e.clone()), center.clone())
|
|
|
+
|
|
|
+ return center.clone()
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
var LineDraw = {
|
|
|
|
|
|
@@ -65,6 +81,10 @@ var LineDraw = {
|
|
|
if(!line.uncontinuous || posArr[0] && posArr[0] instanceof Array)posArr = dealPosArr(posArr)
|
|
|
let position = []
|
|
|
posArr.forEach(e=>position.push(e.x,e.y,e.z))
|
|
|
+ if(line.avoidBigNumber){
|
|
|
+ let moveVec = extractPos(posArr)
|
|
|
+ line.position.copy(moveVec)//无视原本的position!
|
|
|
+ }
|
|
|
line.geometry.setAttribute('position', new THREE.Float32BufferAttribute(/* new Float32Array( */position/* ) */, 3));
|
|
|
|
|
|
line.geometry.attributes.position.needsUpdate = true;
|
|
|
@@ -131,10 +151,19 @@ var LineDraw = {
|
|
|
|
|
|
|
|
|
|
|
|
- moveFatLine: function(line, posArr){
|
|
|
+ moveFatLine: function(line, posArr ){
|
|
|
+ posArr = Common.CloneObject(posArr)
|
|
|
+
|
|
|
var geometry = line.geometry;
|
|
|
var positions = [];
|
|
|
if(!line.uncontinuous || posArr[0] && posArr[0] instanceof Array) posArr = dealPosArr(posArr)
|
|
|
+
|
|
|
+ if(line.avoidBigNumber){
|
|
|
+ let moveVec = extractPos(posArr)
|
|
|
+ line.position.copy(moveVec)//无视原本的position!
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
posArr.forEach(e=>{positions.push(...e.toArray())})
|
|
|
|
|
|
|