|
@@ -10,6 +10,9 @@ import DepthBasicMaterial from "../materials/DepthBasicMaterial.js";
|
|
|
import Sprite from '../viewer/Sprite'
|
|
|
import {config} from '../settings'
|
|
|
|
|
|
+import {ctrlPolygon} from './ctrlPolygon'
|
|
|
+
|
|
|
+
|
|
|
let texLoader = new THREE.TextureLoader()
|
|
|
const defaultNormal = new THREE.Vector2(0,1)
|
|
|
let color = new THREE.Color(config.measure.lineColor)
|
|
@@ -37,25 +40,18 @@ const subLabelProp = {
|
|
|
renderOrder : 4
|
|
|
}
|
|
|
|
|
|
-const verticalLine = new THREE.Line3()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-export class Measure extends THREE.Object3D {
|
|
|
+export class Measure extends ctrlPolygon{
|
|
|
constructor (prop) {
|
|
|
- super();
|
|
|
+ super('measure',prop);
|
|
|
this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1;
|
|
|
-
|
|
|
- this.maxMarkers = Number.MAX_SAFE_INTEGER;
|
|
|
+
|
|
|
|
|
|
- this.transformData(prop);
|
|
|
- for(let i in prop){
|
|
|
- this[i] = prop[i]
|
|
|
- }
|
|
|
this.name = this.measureType + this.constructor.counter //'Measure_' + this.constructor.counter;
|
|
|
-
|
|
|
- this.points = [];
|
|
|
+
|
|
|
this._showDistances = true;
|
|
|
this._showCoordinates = false;
|
|
|
this._showArea = false;
|
|
@@ -66,22 +62,21 @@ export class Measure extends THREE.Object3D {
|
|
|
this._showEdges = true;
|
|
|
this._showAzimuth = false;
|
|
|
|
|
|
- this.sphereGeometry = new THREE.SphereGeometry(0.4, 10, 10);
|
|
|
+ //this.sphereGeometry = new THREE.SphereGeometry(0.4, 10, 10);
|
|
|
this.color = new THREE.Color(config.measure.lineColor)//new THREE.Color(0xff0000);
|
|
|
|
|
|
- this.spheres = [];
|
|
|
- this.edges = [];
|
|
|
+
|
|
|
this.sphereLabels = [];
|
|
|
this.edgeLabels = [];
|
|
|
this.angleLabels = [];
|
|
|
this.coordinateLabels = [];
|
|
|
this.area = {value:0,string:''}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
if(this.showArea){
|
|
|
this.areaLabel = this.createAreaLabel();
|
|
|
- this.areaPlane = createAreaPlane();
|
|
|
+ this.areaPlane = this.createAreaPlane();
|
|
|
this.add(this.areaPlane)
|
|
|
this.add(this.areaLabel)
|
|
|
}
|
|
@@ -115,7 +110,10 @@ export class Measure extends THREE.Object3D {
|
|
|
this.selectStates = {}
|
|
|
|
|
|
this.setUnitSystem(prop.unit || viewer.unitConvert.UnitService.defaultSystem)
|
|
|
-
|
|
|
+ viewer.setObjectLayers(this, 'measure' )
|
|
|
+
|
|
|
+ //addMarkers:
|
|
|
+ this.initData(prop)
|
|
|
}
|
|
|
|
|
|
|
|
@@ -131,7 +129,7 @@ export class Measure extends THREE.Object3D {
|
|
|
if(this.showCoordinates){
|
|
|
let point = this.points[0];
|
|
|
let position = point
|
|
|
- this.spheres[0].position.copy(position);
|
|
|
+ this.markers[0].position.copy(position);
|
|
|
|
|
|
{ // coordinate labels
|
|
|
let coordinateLabel = this.coordinateLabels[0];
|
|
@@ -228,29 +226,11 @@ export class Measure extends THREE.Object3D {
|
|
|
|
|
|
if(this.showArea && this.point2dInfo){ // update area
|
|
|
|
|
|
- this.areaPlane.geometry = MeshDraw.getShapeGeo(this.point2dInfo.points2d)
|
|
|
- var center = math.getCenterOfGravityPoint(this.point2dInfo.points2d) //重心
|
|
|
-
|
|
|
- var firstPos = this.point2dInfo.points2d[0].clone()
|
|
|
- firstPos.z = 0 //因为shape只读取了xy,所以位移下, 再算出最终位置,得到差距
|
|
|
- firstPos.applyQuaternion(this.point2dInfo.quaInverse)
|
|
|
- var vec = this.point2dInfo.originPoint0.clone().sub(firstPos)
|
|
|
- center = new THREE.Vector3(center.x, center.y, 0)
|
|
|
- center.applyQuaternion(this.point2dInfo.quaInverse)
|
|
|
- this.areaPlane.quaternion.copy(this.point2dInfo.quaInverse)
|
|
|
- this.areaPlane.position.copy(vec)
|
|
|
- center.add(vec)
|
|
|
- this.center = center
|
|
|
- let area = Math.abs(math.getArea(this.point2dInfo.points2d))//this.getArea();
|
|
|
- //label
|
|
|
- this.areaLabel.setPos(center);
|
|
|
- /*
|
|
|
-
|
|
|
- let suffix = "m";
|
|
|
- this.area = area
|
|
|
- let txtArea = Utils.addCommas(area.toFixed(2));
|
|
|
- let msg = `${this.measureType} ${txtArea} ${suffix}\u00B2`; */
|
|
|
+ this.updateAreaPlane()
|
|
|
|
|
|
+ let area = Math.abs(math.getArea(this.point2dInfo.points2d))//this.getArea();
|
|
|
+
|
|
|
+ this.areaLabel.setPos(this.center);
|
|
|
|
|
|
let msg = viewer.unitConvert.convert(area, 'area', void 0, this.unitSystem/* , 0.1 */ )
|
|
|
this.area = {value:area, string:msg}
|
|
@@ -320,42 +300,27 @@ export class Measure extends THREE.Object3D {
|
|
|
};
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
- addMarker (point) {
|
|
|
- if(point instanceof Array){
|
|
|
- point = new THREE.Vector3(...point)
|
|
|
- }
|
|
|
- this.points.push(point);
|
|
|
+ addMarker (o={}) {
|
|
|
|
|
|
-
|
|
|
- // sphere
|
|
|
- //let sphere = new THREE.Sprite(this.getSphereMaterial('default') );
|
|
|
-
|
|
|
let sphere = new Sprite({mat:this.getSphereMaterial('default'), sizeInfo: sphereSizeInfo, name:"measure_point"} )
|
|
|
viewer.setObjectLayers(sphere, 'measure' )
|
|
|
- sphere.renderOrder = 3
|
|
|
+ sphere.renderOrder = 3
|
|
|
sphere.sphereSelectStates = {}
|
|
|
- this.add(sphere);
|
|
|
- this.spheres.push(sphere);
|
|
|
- this.updateSphere(sphere, point)
|
|
|
|
|
|
|
|
|
+
|
|
|
+ this.updateMarker(sphere, o.point)
|
|
|
+
|
|
|
+ let edge
|
|
|
{ // edges
|
|
|
- let edge = LineDraw.createFatLine( [
|
|
|
+ edge = LineDraw.createFatLine( [
|
|
|
0, 0, 0,
|
|
|
0, 0, 0,
|
|
|
- ],{material:this.getLineMat('edgeDefault')} )
|
|
|
-
|
|
|
-
|
|
|
- viewer.setObjectLayers(edge, 'measure' )
|
|
|
- this.add(edge);
|
|
|
- this.edges.push(edge);
|
|
|
-
|
|
|
-
|
|
|
+ ],{material:this.getLineMat('edgeDefault')} )
|
|
|
+ viewer.setObjectLayers(edge, 'measure' )
|
|
|
|
|
|
//----
|
|
|
let mouseover = (e) => {this.setSelected(true, 'edge')};
|
|
@@ -364,13 +329,15 @@ export class Measure extends THREE.Object3D {
|
|
|
|
|
|
edge.addEventListener('mouseover', mouseover);
|
|
|
edge.addEventListener('mouseleave', mouseleave);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ super.addMarker({point:o.point, marker:sphere, edge})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if(this.showEdges){ // edge labels
|
|
|
var className = 'measure_length';
|
|
|
if(this.closed){
|
|
@@ -426,72 +393,7 @@ export class Measure extends THREE.Object3D {
|
|
|
|
|
|
|
|
|
|
|
|
- { // Event Listeners
|
|
|
- let drag = (e) => {
|
|
|
-
|
|
|
- var I, atMap
|
|
|
-
|
|
|
-
|
|
|
- atMap = e.drag.dragViewport.name == 'mapViewport'
|
|
|
- I = e.intersectPoint && (e.intersectPoint.location ? e.intersectPoint.location : e.intersectPoint)
|
|
|
-
|
|
|
- //在三维中脱离点云(在map中拉到周围都没有点云的地方)的顶点,无法拖拽怎么办
|
|
|
-
|
|
|
-
|
|
|
- if (I) {
|
|
|
- let i = this.spheres.indexOf(e.drag.object);
|
|
|
- if (i !== -1) {
|
|
|
- this.dragChange(I, i, atMap)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- this.editStateChange(true)
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- let drop = e => {
|
|
|
- if(!e.isAtDomElement && this.isNew){//如果是刚添加时在其他dom点击, 不要响应
|
|
|
- setTimeout(()=>{//等 drag=null之后 //右键拖拽结束后需要重新得到drag
|
|
|
- if(viewer.scene.measurements.includes(this)){
|
|
|
- viewer.inputHandler.startDragging(e.drag.object,
|
|
|
- {endDragFun: e.drag.endDragFun}
|
|
|
- )
|
|
|
- }
|
|
|
- },1)
|
|
|
- return
|
|
|
- }
|
|
|
- let i = this.spheres.indexOf(e.drag.object);
|
|
|
- if (i !== -1) {
|
|
|
- this.dispatchEvent({
|
|
|
- 'type': 'marker_dropped',
|
|
|
- 'measurement': this,
|
|
|
- 'index': i
|
|
|
- });
|
|
|
- if(this.spheres.length>2 && this.facePlane)this.cannotConfirmNormal = false
|
|
|
- this.guideLine &&(this.guideLine.visible = false)
|
|
|
- }
|
|
|
-
|
|
|
- viewer.dispatchEvent({
|
|
|
- type : "CursorChange", action : "remove", name:"measure_isIntersectSelf"
|
|
|
- })
|
|
|
-
|
|
|
- this.setSphereSelected(e.drag.object, false, 'single')
|
|
|
-
|
|
|
- this.editStateChange(false)
|
|
|
- e.drag.endDragFun && e.drag.endDragFun(e)// addmarker
|
|
|
- if(this.changeCallBack)this.changeCallBack()
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- let mouseover = (e) => {this.setSphereSelected(e.object, true, 'single');/* console.log('hover') */};
|
|
|
- let mouseleave = (e) => {this.setSphereSelected(e.object, false, 'single');/* console.log('hoveroff') */}
|
|
|
-
|
|
|
- sphere.addEventListener('drag', drag);
|
|
|
- sphere.addEventListener('drop', drop);
|
|
|
- sphere.addEventListener('mouseover', mouseover);
|
|
|
- sphere.addEventListener('mouseleave', mouseleave);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
let event = {
|
|
|
type: 'marker_added',
|
|
@@ -509,173 +411,7 @@ export class Measure extends THREE.Object3D {
|
|
|
|
|
|
|
|
|
|
|
|
- dragChange(intersectPos,i, atMap){
|
|
|
- var len = this.spheres.length
|
|
|
- var location = intersectPos.clone()
|
|
|
-
|
|
|
- if(this.faceDirection && this.maxMarkers == 2 && len == 2){//add 固定方向的点不直接拖拽
|
|
|
- var p1 = this.spheres[0].position
|
|
|
- if(this.faceDirection == 'horizontal'){
|
|
|
- var projectPos = location.clone().setZ(p1.z)
|
|
|
- }else{
|
|
|
- var projectPos = p1.clone().setZ(location.z)
|
|
|
- }
|
|
|
- //var p2 = p1.clone().add(this.direction)
|
|
|
- //var projectPos = math.getFootPoint(location, p1, p2)
|
|
|
-
|
|
|
-
|
|
|
- this.updateLine(this.guideLine, location, projectPos)
|
|
|
- this.setPosition(i, projectPos);
|
|
|
- this.guideLine.visible = true
|
|
|
- }else if( len > 1){
|
|
|
-
|
|
|
- var points = this.points//.map(e=>e.position.clone())
|
|
|
- points[i].copy(location) //算normal需要提前确认point
|
|
|
-
|
|
|
- //若为定义了面朝向的矩形
|
|
|
- if(this.faceDirection == 'horizontal'){
|
|
|
- if(len == 2){
|
|
|
- location.setZ(this.points[0].z)
|
|
|
- }
|
|
|
- if(!this.facePlane){//一个点就能确定面
|
|
|
- this.facePlane = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3(0,0,1), this.points[0] )
|
|
|
- }
|
|
|
- }else if(this.faceDirection == 'vertical'){//当有两个点时, 有两个方向的可能
|
|
|
- if(len == 2){
|
|
|
- if(this.isRect){
|
|
|
- let vec = points[0].clone().sub(location)
|
|
|
- if(Math.sqrt(vec.x*vec.x+vec.y*vec.y) > Math.abs(vec.z) ){//水平(高度差小于水平距离时)
|
|
|
- location.setZ(this.points[0].z)
|
|
|
- //this.cannotConfirmNormal = false;//能确定面为水平方向
|
|
|
- }else{//垂直 (当两点一样时也属于这种)
|
|
|
- location.setX(points[0].x);
|
|
|
- location.setY(points[0].y);
|
|
|
- //this.cannotConfirmNormal = true; //不能确定面,因第三点可绕着纵轴线自由移动
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- {//判断cannotConfirmNormal. 如果前几段都在竖直线上,就不能固定出面方向。
|
|
|
- this.cannotConfirmNormal = true
|
|
|
- let max = this.isRect ? 1 : len-2
|
|
|
- for(let i=0;i<max;i++){
|
|
|
- let p1 = points[i].clone()
|
|
|
- let p2 = points[i+1].clone()
|
|
|
- let vec = p1.sub(p2);
|
|
|
- if(vec.x != 0 || vec.y != 0){
|
|
|
- this.cannotConfirmNormal = false
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(!this.facePlane || this.cannotConfirmNormal){//三个点且为水平方向时,计算面
|
|
|
-
|
|
|
- var points_ = points.map(e=>new THREE.Vector2(e.x,e.y))
|
|
|
- var points2 = getDifferentPoint(points_, 2);
|
|
|
- if(points2){
|
|
|
- let normal = math.getNormal2d({p1:points2[0], p2:points2[1]})
|
|
|
- normal = new THREE.Vector3(normal.x, normal.y, 0)
|
|
|
- this.facePlane = new THREE.Plane().setFromNormalAndCoplanarPoint( normal, this.points[0] )
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(len > 2){//area
|
|
|
-
|
|
|
- if(!this.faceDirection){
|
|
|
- if(len == 3 || this.isRect) this.cannotConfirmNormal = true //当第三个点固定后(有四个点时)才能固定面
|
|
|
- if(!this.facePlane || this.cannotConfirmNormal){
|
|
|
- var points3 = getDifferentPoint(points, 3);//只有找到三个不同的点算拥有面和area
|
|
|
- if(points3){
|
|
|
- this.facePlane = new THREE.Plane().setFromCoplanarPoints(...points3 )
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if( this.facePlane && !this.cannotConfirmNormal ){//之后加的点一定要在面上
|
|
|
- if(atMap){
|
|
|
- //地图上用垂直线,得到和面的交点。
|
|
|
- verticalLine.set(location.clone().setZ(100000), location.clone().setZ(-100000))//确保长度范围覆盖所有测量面
|
|
|
- location = this.facePlane.intersectLine(verticalLine, new THREE.Vector3() )
|
|
|
- if(!location) return;
|
|
|
- }else{
|
|
|
- location = this.facePlane.projectPoint(intersectPos, new THREE.Vector3() )
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- points[i].copy(location)//再copy确认一次
|
|
|
-
|
|
|
- if(this.isRect){ //是矩形 (即使没有faceDirection也能执行)
|
|
|
- //根据前两个点计算当前和下一个点
|
|
|
- var p1 = this.points[(i-2+len)%len]
|
|
|
- var p2 = this.points[(i-1+len)%len]
|
|
|
- if(p1.equals(p2)){//意外情况:重复点两次 ( bug点,改了好多遍)
|
|
|
- if(this.faceDirection == 'vertical'){
|
|
|
- p2.add(new THREE.Vector3(0,0,0.0001))
|
|
|
- }else{
|
|
|
- p2.add(new THREE.Vector3(0,0.0001,0))
|
|
|
- }
|
|
|
- }
|
|
|
- //p3 : location
|
|
|
- var foot = math.getFootPoint(location, p1, p2)//p2 修改p2到垂足的位置
|
|
|
- var vec = foot.clone().sub(location)
|
|
|
- var p4 = p1.clone().sub(vec)
|
|
|
-
|
|
|
-
|
|
|
- points[(i-1+len)%len].copy(foot)
|
|
|
- points[(i+1)%len].copy(p4)
|
|
|
- this.setPosition((i-1+len)%len, foot);//p2
|
|
|
- this.setPosition((i+1)%len, p4);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- let points2d;
|
|
|
- if(this.facePlane){
|
|
|
- var originPoint0 = points[0].clone()
|
|
|
- var qua = math.getQuaBetween2Vector(this.facePlane.normal, new THREE.Vector3(0,0,1), new THREE.Vector3(0,0,1));
|
|
|
- points2d = points.map(e=>e.clone().applyQuaternion(qua))
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- var isIntersectSelf = !this.isRect && len > 3 && this.intersectSelf(points2d)//检测相交
|
|
|
- if(isIntersectSelf){
|
|
|
- //not-allowed
|
|
|
- viewer.dispatchEvent({
|
|
|
- type : "CursorChange", action : "add", name:"measure_isIntersectSelf"
|
|
|
- })
|
|
|
- return
|
|
|
- }else{
|
|
|
- viewer.dispatchEvent({
|
|
|
- type : "CursorChange", action : "remove", name:"measure_isIntersectSelf"
|
|
|
- })
|
|
|
- this.facePlane && (this.point2dInfo = {
|
|
|
- originPoint0 ,
|
|
|
- points2d,
|
|
|
- quaInverse : qua.clone().invert()
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- var showGuideLine = len>1 && (this.faceDirection || len > 3)
|
|
|
- if(showGuideLine){
|
|
|
- this.updateLine(this.guideLine, intersectPos, location)
|
|
|
- this.guideLine.visible = true
|
|
|
- }
|
|
|
- this.setPosition(i, location);
|
|
|
- //console.log(this.points.map(e=>e.toArray()))
|
|
|
-
|
|
|
- }else{
|
|
|
- this.setPosition(i, location);
|
|
|
- }
|
|
|
-
|
|
|
- this.update()
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -704,7 +440,7 @@ export class Measure extends THREE.Object3D {
|
|
|
|
|
|
|
|
|
|
|
|
- setSphereSelected(sphere, state, hoverObject){
|
|
|
+ setMarkerSelected(sphere, state, hoverObject){
|
|
|
|
|
|
//console.warn(sphere.id , state, hoverObject)
|
|
|
|
|
@@ -738,7 +474,7 @@ export class Measure extends THREE.Object3D {
|
|
|
|
|
|
|
|
|
if(absoluteState){
|
|
|
- this.spheres.forEach(e=>this.setSphereSelected(e,true,'selectAll' ) )
|
|
|
+ this.markers.forEach(e=>this.setMarkerSelected(e,true,'selectAll' ) )
|
|
|
|
|
|
this.edges.forEach(e=>e.material = this.getLineMat('edgeSelect') )
|
|
|
|
|
@@ -756,7 +492,7 @@ export class Measure extends THREE.Object3D {
|
|
|
|
|
|
|
|
|
}else{
|
|
|
- this.spheres.forEach(e=>this.setSphereSelected(e,false,'selectAll' ))
|
|
|
+ this.markers.forEach(e=>this.setMarkerSelected(e,false,'selectAll' ))
|
|
|
this.edges.forEach(e=>e.material = this.getLineMat('edgeDefault') )
|
|
|
this.areaPlane && (this.areaPlane.material = planeMats.default)
|
|
|
this.closed && this.edgeLabels.forEach(e=>e.setVisible( false))
|
|
@@ -771,55 +507,30 @@ export class Measure extends THREE.Object3D {
|
|
|
viewer.mapViewer.emit('content_changed')
|
|
|
}
|
|
|
|
|
|
- removeMarker (index) {
|
|
|
- this.points.splice(index, 1);
|
|
|
-
|
|
|
- this.remove(this.spheres[index]);
|
|
|
- this.coordinateLabels.splice(index, 1);
|
|
|
-
|
|
|
-
|
|
|
- let edgeIndex = (index === 0) ? 0 : (index - 1);
|
|
|
- this.remove(this.edges[edgeIndex]);
|
|
|
- this.edges.splice(edgeIndex, 1);
|
|
|
-
|
|
|
-
|
|
|
- if(this.edgeLabels[edgeIndex]){
|
|
|
- //this.edgeLabels[edgeIndex].remove();
|
|
|
+ removeMarker(index){
|
|
|
+ super.removeMarker(index)
|
|
|
+ this.coordinateLabels.splice(index, 1);
|
|
|
+ if(this.edgeLabels[edgeIndex]){
|
|
|
this.edgeLabels[edgeIndex].parent.remove(this.edgeLabels[edgeIndex])
|
|
|
this.edgeLabels.splice(edgeIndex, 1);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
if(this.angleLabels[index]){
|
|
|
this.angleLabels[index].remove()
|
|
|
this.angleLabels.splice(index, 1);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- this.spheres.splice(index, 1);
|
|
|
-
|
|
|
- this.point2dInfo && this.point2dInfo.points2d.splice(index, 1); //add
|
|
|
-
|
|
|
-
|
|
|
- this.update();
|
|
|
-
|
|
|
- this.dispatchEvent({type: 'marker_removed', measurement: this});
|
|
|
- };
|
|
|
-
|
|
|
- /* setMarker (index, point) {
|
|
|
- this.points[index] = point;
|
|
|
-
|
|
|
- let event = {
|
|
|
+ this.dispatchEvent({type: 'marker_removed', measurement: this});
|
|
|
+ }
|
|
|
+
|
|
|
+ setPosition(index, position) {
|
|
|
+ super.setPosition(index, position)
|
|
|
+ let event = {
|
|
|
type: 'marker_moved',
|
|
|
measure: this,
|
|
|
index: index,
|
|
|
- position: point.position.clone()
|
|
|
+ position: position.clone()
|
|
|
};
|
|
|
- this.dispatchEvent(event);
|
|
|
-
|
|
|
- this.update();
|
|
|
- } */
|
|
|
-
|
|
|
+ this.dispatchEvent(event);
|
|
|
+ }
|
|
|
|
|
|
dispose(){//add
|
|
|
var labels = this.edgeLabels.concat(this.coordinateLabels)
|
|
@@ -829,49 +540,7 @@ export class Measure extends THREE.Object3D {
|
|
|
this.parent.remove(this)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- setPosition (index, position) {
|
|
|
- let point = this.points[index];
|
|
|
- point.copy(position);
|
|
|
-
|
|
|
- let event = {
|
|
|
- type: 'marker_moved',
|
|
|
- measure: this,
|
|
|
- index: index,
|
|
|
- position: position.clone()
|
|
|
- };
|
|
|
- this.dispatchEvent(event);
|
|
|
-
|
|
|
- let sphere = this.spheres[index];
|
|
|
- this.updateSphere(sphere, point)
|
|
|
-
|
|
|
- };
|
|
|
- intersectSelf(points2d){//add
|
|
|
- var len = points2d.length
|
|
|
- for(var i=0;i<len;i++){
|
|
|
- for(var j=i+2;j<len;j++){
|
|
|
- if(Math.abs(j-len-i)<2)continue;//不和邻边比
|
|
|
-
|
|
|
- var p1 = points2d[i]
|
|
|
- var p2 = points2d[i+1]
|
|
|
- var p3 = points2d[j]
|
|
|
- var p4 = points2d[(j+1)%len]
|
|
|
- if(p1.equals(p2) || p3.equals(p4) || p1.equals(p3) || p2.equals(p3) || p1.equals(p4) || p2.equals(p4))continue
|
|
|
-
|
|
|
-
|
|
|
- var line1 = [p1,p2]
|
|
|
- var line2 = [p3,p4]
|
|
|
- var intersect = math.isLineIntersect(line1, line2, false, 0.001)
|
|
|
- if(intersect){
|
|
|
- return true
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
getTotalDistance () {
|
|
|
if (this.points.length === 0) {
|
|
|
return 0;
|
|
@@ -954,6 +623,7 @@ export class Measure extends THREE.Object3D {
|
|
|
0, 0, 0,
|
|
|
],{material:this.getLineMat('guide')} )
|
|
|
guideEdge.visible = false
|
|
|
+
|
|
|
return guideEdge;
|
|
|
}
|
|
|
|
|
@@ -1048,6 +718,25 @@ export class Measure extends THREE.Object3D {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ createAreaPlane(){
|
|
|
+ planeMats || (planeMats = {
|
|
|
+ default: new DepthBasicMaterial({
|
|
|
+ color:color,
|
|
|
+ side:THREE.DoubleSide,
|
|
|
+ opacity:0.2,
|
|
|
+ transparent:true,
|
|
|
+ useDepth:true
|
|
|
+ }),
|
|
|
+ selected: new DepthBasicMaterial({
|
|
|
+ color:color,
|
|
|
+ side:THREE.DoubleSide,
|
|
|
+ opacity:0.3,
|
|
|
+ transparent:true
|
|
|
+ })
|
|
|
+ },Measure.planeMats = planeMats)
|
|
|
+ return super.createAreaPlane(planeMats.default)
|
|
|
+ }
|
|
|
+
|
|
|
updateLine(line, p1,p2){
|
|
|
|
|
|
LineDraw.moveFatLine(line,[
|
|
@@ -1056,7 +745,7 @@ export class Measure extends THREE.Object3D {
|
|
|
}
|
|
|
raycast (raycaster, intersects) {
|
|
|
for (let i = 0; i < this.points.length; i++) {
|
|
|
- let sphere = this.spheres[i];
|
|
|
+ let sphere = this.markers[i];
|
|
|
|
|
|
sphere.raycast(raycaster, intersects);
|
|
|
}
|
|
@@ -1072,10 +761,7 @@ export class Measure extends THREE.Object3D {
|
|
|
intersects.sort(function (a, b) { return a.distance - b.distance; });
|
|
|
};
|
|
|
|
|
|
- updateSphere(sphere, pos){
|
|
|
- sphere.position.copy(pos);
|
|
|
- sphere.update();
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
transformData(prop){
|
|
|
if(prop.measureType == 'Point'){
|
|
@@ -1257,38 +943,9 @@ export class Measure extends THREE.Object3D {
|
|
|
|
|
|
|
|
|
|
|
|
-function getDifferentPoint(points, count){//for facePlane
|
|
|
- var result = [];
|
|
|
- for(let i=0;i<points.length;i++){
|
|
|
- var p = points[i];
|
|
|
- if(result.find(e=>e.equals(p)))continue;
|
|
|
- else result.push(p)
|
|
|
- if(result.length == count)break
|
|
|
- }
|
|
|
- if(result.length == count)return result
|
|
|
-}
|
|
|
|
|
|
-function createAreaPlane(){
|
|
|
- planeMats || (planeMats = {
|
|
|
- default: new DepthBasicMaterial({
|
|
|
- color:color,
|
|
|
- side:THREE.DoubleSide,
|
|
|
- opacity:0.2,
|
|
|
- transparent:true,
|
|
|
- useDepth:true
|
|
|
- }),
|
|
|
- selected: new DepthBasicMaterial({
|
|
|
- color:color,
|
|
|
- side:THREE.DoubleSide,
|
|
|
- opacity:0.3,
|
|
|
- transparent:true
|
|
|
- })
|
|
|
- },Measure.planeMats = planeMats)
|
|
|
- var geometry = new THREE.Geometry();
|
|
|
- var mesh = new THREE.Mesh(geometry, planeMats.default)
|
|
|
- viewer.setObjectLayers(mesh, 'measure' )
|
|
|
- return mesh
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
|
|
|
function setLabelHightState(label, state){
|
|
|
if(state){
|