|
@@ -7826,12 +7826,11 @@
|
|
|
},
|
|
|
getFootPoint: function getFootPoint(oldPos, p1, p2, restricInline) {
|
|
|
//找oldPos在线段p1, p2上的垂足
|
|
|
- /* if(isWorld){//输出全局坐标 需要考虑meshGroup.position
|
|
|
- p1 = p1.clone();
|
|
|
- p2 = p2.clone();
|
|
|
- p1.y += mainDesign.meshGroup.position.y;
|
|
|
- p2.y += mainDesign.meshGroup.position.y;
|
|
|
- } */
|
|
|
+ /*
|
|
|
+ let p1o = new THREE.Vector3().subVectors(o,p1)
|
|
|
+ let p1p2 = new THREE.Vector3().subVectors(p2,p1)
|
|
|
+ let p1F = p1o.projectOnVector(p1p2)
|
|
|
+ return new THREE.Vector3().addVectors(p1,p1F) */ //也可以这样
|
|
|
if (p1.equals(p2)) return p1.clone();
|
|
|
var op1 = oldPos.clone().sub(p1);
|
|
|
var p1p2 = p1.clone().sub(p2);
|
|
@@ -49298,7 +49297,7 @@
|
|
|
};
|
|
|
var planeGeo$2 = new PlaneBufferGeometry(1, 1);
|
|
|
var voidGeometry = new BufferGeometry();
|
|
|
- var markerMats;
|
|
|
+ var markerMats, dragPointMat;
|
|
|
var getMarkerMat = function getMarkerMat(name) {
|
|
|
if (!markerMats) {
|
|
|
markerMats = {
|
|
@@ -49396,6 +49395,7 @@
|
|
|
this.selectStates = {};
|
|
|
this.setFadeFar(null);
|
|
|
this.geoPoints = [];
|
|
|
+ this.lineHeight = prop.lineHeight == void 0 ? titleLineHeight : prop.lineHeight;
|
|
|
{
|
|
|
var group = new Object3D();
|
|
|
group.name = 'titleGroup';
|
|
@@ -49431,54 +49431,107 @@
|
|
|
textAlign: Potree.settings.isOfficial && 'left'
|
|
|
}));
|
|
|
this.titleLabel.sprite.material.depthTest = false;
|
|
|
- var line = LineDraw.createFatLine([new Vector3(0, 0, 0), new Vector3(0, 0, titleLineHeight)], Object.assign({}, depthProps, {
|
|
|
+ var line = LineDraw.createFatLine([new Vector3(0, 0, 0), new Vector3(0, 0, this.lineHeight)], Object.assign({}, depthProps, {
|
|
|
color: '#ffffff',
|
|
|
lineWidth: 1,
|
|
|
transparent: true,
|
|
|
fadeFar: this.fadeFar
|
|
|
}));
|
|
|
line.renderOrder = Potree.config.renderOrders.line;
|
|
|
+ line.name = 'line';
|
|
|
+ this.titleLine = line;
|
|
|
group.add(line);
|
|
|
group.add(this.titleLabel);
|
|
|
- this.titleLabel.position.z = titleLineHeight;
|
|
|
+ this.titleLabel.position.z = this.lineHeight;
|
|
|
this.add(group);
|
|
|
this.setTitleVisi(this.titleLabel.parent, false, 'noPoint');
|
|
|
this.setTitle(Potree.settings.isOfficial ? '' : 'title');
|
|
|
- line.addEventListener('mouseover', e => {
|
|
|
- this.editEnable && CursorDeal.add('hoverGrab');
|
|
|
- });
|
|
|
- line.addEventListener('startDragging', e => {
|
|
|
+ if (!dragPointMat) {
|
|
|
+ var map = texLoader$7.load(Potree.resourcePath + '/textures/whiteCircle.png', () => {});
|
|
|
+ dragPointMat = {
|
|
|
+ default: new MeshBasicMaterial({
|
|
|
+ map,
|
|
|
+ transparent: true,
|
|
|
+ color: '#0fe',
|
|
|
+ opacity: 0,
|
|
|
+ depthTest: false
|
|
|
+ }),
|
|
|
+ hover: new MeshBasicMaterial({
|
|
|
+ map,
|
|
|
+ transparent: true,
|
|
|
+ color: '#0fe',
|
|
|
+ opacity: 0.4,
|
|
|
+ depthTest: false
|
|
|
+ })
|
|
|
+ };
|
|
|
+ }
|
|
|
+ this.lineDragPoint = new Mesh(planeGeo$2, dragPointMat.default); //修改线高度时出现的小圆点
|
|
|
+ this.lineDragPoint.scale.set(0.15, 0.15, 0.15);
|
|
|
+ this.lineDragPoint.name = 'lineDragPoint';
|
|
|
+ this.lineDragPoint.renderOrder = this.lineDragPoint.pickOrder = 10;
|
|
|
+ this.titleLabel.add(this.lineDragPoint);
|
|
|
+ var hoverState = {},
|
|
|
+ grabbingObject;
|
|
|
+ var setDragPointState = state => {
|
|
|
+ this.lineDragPoint.material = state ? dragPointMat.hover : dragPointMat.default;
|
|
|
+ this.titleLabel.sprite.material.opacity = state ? 0.5 : 1;
|
|
|
+ };
|
|
|
+ var autoPointState = () => {
|
|
|
+ setDragPointState(hoverState.lineDragPoint || grabbingObject == 'lineDragPoint');
|
|
|
+ };
|
|
|
+ var autoCursor = () => {
|
|
|
+ if (this.editEnable && Object.values(hoverState).some(e => e)) {
|
|
|
+ CursorDeal.add('hoverGrab');
|
|
|
+ } else {
|
|
|
+ CursorDeal.remove('hoverGrab');
|
|
|
+ }
|
|
|
+ autoPointState();
|
|
|
+ };
|
|
|
+ [line, this.lineDragPoint].forEach(e => e.addEventListener('mouseover', e => {
|
|
|
+ hoverState[e.target.name] = 1;
|
|
|
+ autoCursor();
|
|
|
+ }));
|
|
|
+ [line, this.lineDragPoint].forEach(e => e.addEventListener('mouseleave', e => {
|
|
|
+ hoverState[e.target.name] = 0;
|
|
|
+ autoCursor();
|
|
|
+ }));
|
|
|
+ [line, this.lineDragPoint].forEach(e => e.addEventListener('startDragging', e => {
|
|
|
this.editEnable && CursorDeal.add('grabbing');
|
|
|
- });
|
|
|
- line.addEventListener('drop', e => {
|
|
|
+ grabbingObject = e.target.name;
|
|
|
+ autoPointState();
|
|
|
+ }));
|
|
|
+ [line, this.lineDragPoint].forEach(e => e.addEventListener('drop', e => {
|
|
|
this.editEnable && CursorDeal.remove('grabbing');
|
|
|
- });
|
|
|
- line.addEventListener('mouseleave', e => {
|
|
|
- this.editEnable && CursorDeal.remove('hoverGrab');
|
|
|
- });
|
|
|
- line.addEventListener('drag', e => {
|
|
|
+ grabbingObject = null;
|
|
|
+ autoPointState();
|
|
|
+ }));
|
|
|
+ [line, this.lineDragPoint].forEach(e => e.addEventListener('drag', e => {
|
|
|
if (this.editEnable) {
|
|
|
- var _e$intersect, _e$intersect3, _e$intersect4;
|
|
|
//一旦用户拖动了title,title就固定了,不再随着path居中
|
|
|
- var position;
|
|
|
- if ((_e$intersect = e.intersect) !== null && _e$intersect !== void 0 && _e$intersect.location) {
|
|
|
- var _e$intersect2;
|
|
|
- position = (_e$intersect2 = e.intersect) === null || _e$intersect2 === void 0 ? void 0 : _e$intersect2.location;
|
|
|
- } else {
|
|
|
- var {
|
|
|
- x,
|
|
|
- y
|
|
|
- } = Potree.Utils.getPointerPosAtHeight(0, e.pointer);
|
|
|
- position = new Vector3(x, y, 0);
|
|
|
+ if (e.target.name == 'line') {
|
|
|
+ var _e$intersect, _e$intersect3, _e$intersect4;
|
|
|
+ var position;
|
|
|
+ if ((_e$intersect = e.intersect) !== null && _e$intersect !== void 0 && _e$intersect.location) {
|
|
|
+ var _e$intersect2;
|
|
|
+ position = (_e$intersect2 = e.intersect) === null || _e$intersect2 === void 0 ? void 0 : _e$intersect2.location;
|
|
|
+ } else {
|
|
|
+ var {
|
|
|
+ x,
|
|
|
+ y
|
|
|
+ } = Potree.Utils.getPointerPosAtHeight(0, e.pointer);
|
|
|
+ position = new Vector3(x, y, 0);
|
|
|
+ }
|
|
|
+ this.updateTitlePos(position);
|
|
|
+ this.dispatchEvent({
|
|
|
+ type: 'titlePosChanged',
|
|
|
+ position,
|
|
|
+ root: ((_e$intersect3 = e.intersect) === null || _e$intersect3 === void 0 ? void 0 : _e$intersect3.pointcloud) || ((_e$intersect4 = e.intersect) === null || _e$intersect4 === void 0 ? void 0 : _e$intersect4.object)
|
|
|
+ });
|
|
|
+ } else if (e.target.name == 'lineDragPoint') {
|
|
|
+ this.dragLineLen(e);
|
|
|
}
|
|
|
- this.updateTitlePos(position);
|
|
|
- this.dispatchEvent({
|
|
|
- type: 'titlePosChanged',
|
|
|
- position,
|
|
|
- root: ((_e$intersect3 = e.intersect) === null || _e$intersect3 === void 0 ? void 0 : _e$intersect3.pointcloud) || ((_e$intersect4 = e.intersect) === null || _e$intersect4 === void 0 ? void 0 : _e$intersect4.object)
|
|
|
- });
|
|
|
}
|
|
|
- });
|
|
|
+ }));
|
|
|
}
|
|
|
{
|
|
|
//和measure不同的是它的边是连在一起的一整条
|
|
@@ -49742,6 +49795,27 @@
|
|
|
|
|
|
viewer.dispatchEvent('content_changed');
|
|
|
}
|
|
|
+ setLineHeight(len) {
|
|
|
+ this.lineHeight = parseFloat(len);
|
|
|
+ this.titleLabel.position.z = this.lineHeight;
|
|
|
+ this.titleLabel.updatePose();
|
|
|
+ LineDraw.updateLine(this.titleLine, [new Vector3(0, 0, 0), new Vector3(0, 0, this.lineHeight)]);
|
|
|
+ }
|
|
|
+ dragLineLen(e) {
|
|
|
+ //拖拽线的顶端修改线长度
|
|
|
+ var endPos = this.titleLabel.getWorldPosition(new Vector3());
|
|
|
+ var normal = new Vector3(0, 0, 1);
|
|
|
+ var projected = endPos.clone().project(e.drag.dragViewport.camera);
|
|
|
+ projected.x = e.pointer.x;
|
|
|
+ projected.y = e.pointer.y;
|
|
|
+ var unprojected = projected.clone().unproject(e.drag.dragViewport.camera);
|
|
|
+ var moveVec = new Vector3().subVectors(unprojected, endPos);
|
|
|
+ moveVec = moveVec.projectOnVector(normal);
|
|
|
+ var newLength = Math.max(0, this.lineHeight + moveVec.dot(normal));
|
|
|
+ //console.log(moveVec,newLength)
|
|
|
+ this.setLineHeight(newLength);
|
|
|
+ this.dispatchEvent('dragLineLen');
|
|
|
+ }
|
|
|
updateEdge() {
|
|
|
if (this.lastUpdatePoints_ && Potree.Common.ifSame(this.lastUpdatePoints_, this.points) && this.halfPathWidth == this.lastHalfPathWidth) return; //没变 不更新
|
|
|
//this.edge.geometry = MeshDraw.getExtrudeGeo(edgeExtrudePoints, null, {extrudePath: this.points, openEnded:true, shapeDontClose:true/* , dontSmooth:true, steps: this.points.length-1 */})
|
|
@@ -60932,7 +61006,7 @@
|
|
|
};
|
|
|
var planeGeo$3 = new PlaneBufferGeometry(1, 1);
|
|
|
var texLoader$8 = new TextureLoader();
|
|
|
- var lineMat;
|
|
|
+ var lineMat, dragPointMat$1;
|
|
|
var defaultLineLength = 1;
|
|
|
var defaultSpotScale = 0.35;
|
|
|
var titleHeight = {
|
|
@@ -60951,9 +61025,15 @@
|
|
|
this.lineLength = o.lineLength != void 0 ? o.lineLength : defaultLineLength;
|
|
|
this.position.copy(o.position);
|
|
|
this.normal = o.normal != void 0 ? o.normal : new Vector3(0, 0, 1);
|
|
|
- this.dragEnable = true;
|
|
|
this.build(o);
|
|
|
this.bindEvent();
|
|
|
+ this.dragEnable = true;
|
|
|
+ }
|
|
|
+ set dragEnable(state) {
|
|
|
+ this.lineDragPoint.visible = state;
|
|
|
+ }
|
|
|
+ get dragEnable() {
|
|
|
+ return this.lineDragPoint.visible;
|
|
|
}
|
|
|
build(o) {
|
|
|
lineMat || (lineMat = LineDraw.createFatLineMat(Object.assign({}, depthMatProp, {
|
|
@@ -60965,6 +61045,7 @@
|
|
|
this.spot = new Mesh(planeGeo$3, new DepthBasicMaterial(Object.assign({}, depthMatProp, {
|
|
|
transparent: true
|
|
|
})));
|
|
|
+ this.spot.name = 'spot';
|
|
|
this.spot.scale.set(defaultSpotScale, defaultSpotScale, defaultSpotScale);
|
|
|
this.spot.renderOrder = this.spot.pickOrder = Potree.config.renderOrders.tag.spot;
|
|
|
Potree.settings.isOfficial || this.changeMap(Potree.resourcePath + '/textures/spot_default.png');
|
|
@@ -61013,13 +61094,39 @@
|
|
|
this.add(group);
|
|
|
this.add(this.line);
|
|
|
viewer.tags.add(this);
|
|
|
+ if (!dragPointMat$1) {
|
|
|
+ var map = texLoader$8.load(Potree.resourcePath + '/textures/whiteCircle.png', () => {});
|
|
|
+ dragPointMat$1 = {
|
|
|
+ default: new MeshBasicMaterial({
|
|
|
+ map,
|
|
|
+ transparent: true,
|
|
|
+ color: '#0fe',
|
|
|
+ opacity: 0,
|
|
|
+ depthTest: false
|
|
|
+ }),
|
|
|
+ hover: new MeshBasicMaterial({
|
|
|
+ map,
|
|
|
+ transparent: true,
|
|
|
+ color: '#0fe',
|
|
|
+ opacity: 0.4,
|
|
|
+ depthTest: false
|
|
|
+ })
|
|
|
+ };
|
|
|
+ }
|
|
|
+ this.lineDragPoint = new Mesh(planeGeo$3, dragPointMat$1.default); //修改线高度时出现的小圆点
|
|
|
+ this.lineDragPoint.scale.set(0.15, 0.15, 0.15);
|
|
|
+ this.lineDragPoint.name = 'lineDragPoint';
|
|
|
+ this.lineDragPoint.renderOrder = this.lineDragPoint.pickOrder = Potree.config.renderOrders.tag.spot + 3;
|
|
|
+ group.add(this.lineDragPoint);
|
|
|
this.updatePose();
|
|
|
}
|
|
|
bindEvent() {
|
|
|
- var hoverState = {
|
|
|
- line: 0,
|
|
|
- spot: 0,
|
|
|
- label: 0
|
|
|
+ var hoverState = {},
|
|
|
+ grabbingObject;
|
|
|
+ var setDragPointState = state => {
|
|
|
+ this.lineDragPoint.material = state ? dragPointMat$1.hover : dragPointMat$1.default;
|
|
|
+ this.spot.material.opacity = state ? 0.5 : 1;
|
|
|
+ this.titleLabel.sprite.material.opacity = state ? 0.5 : 1;
|
|
|
};
|
|
|
{
|
|
|
//因为只有有intersect时才能拖拽,所以写得比较麻烦
|
|
@@ -61038,18 +61145,18 @@
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
- [this.line, this.spot].forEach(e => e.addEventListener('mousemove', e => {
|
|
|
- hoverState[e.target.name == 'tagLine' ? 'line' : 'spot'] = 1;
|
|
|
- if (this.dragEnable && viewer.inputHandler.intersect) {
|
|
|
+ [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('mousemove', e => {
|
|
|
+ hoverState[e.target.name] = 1;
|
|
|
+ if (this.dragEnable && (viewer.inputHandler.intersect || hoverState['lineDragPoint'])) {
|
|
|
//能拖拽时
|
|
|
setCursor('hoverGrab', 'add');
|
|
|
} else {
|
|
|
setCursor('hoverGrab', 'remove');
|
|
|
}
|
|
|
}));
|
|
|
- [this.line, this.spot].forEach(e => e.addEventListener('mouseleave', e => {
|
|
|
- hoverState[e.target.name == 'tagLine' ? 'line' : 'spot'] = 0;
|
|
|
- if (!hoverState.line && !hoverState.spot) {
|
|
|
+ [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('mouseleave', e => {
|
|
|
+ hoverState[e.target.name] = 0;
|
|
|
+ if (!Object.values(hoverState).some(e => e)) {
|
|
|
//都没hover才取消
|
|
|
setCursor('hoverGrab', 'remove');
|
|
|
}
|
|
@@ -61057,17 +61164,25 @@
|
|
|
this.dispatchEvent('mouseleave')
|
|
|
} */
|
|
|
}));
|
|
|
- [this.line, this.spot].forEach(e => e.addEventListener('drag', e => {
|
|
|
+ [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('drag', e => {
|
|
|
if (this.dragEnable && cursor.grabbing) {
|
|
|
- var info = viewer.tagTool.getPoseByIntersect(e);
|
|
|
- info && this.changePos(info);
|
|
|
+ if (e.target.name == 'lineDragPoint') {
|
|
|
+ this.dragLineLen(e);
|
|
|
+ } else {
|
|
|
+ var info = viewer.tagTool.getPoseByIntersect(e);
|
|
|
+ info && this.changePos(info);
|
|
|
+ }
|
|
|
}
|
|
|
}));
|
|
|
- [this.line, this.spot].forEach(e => e.addEventListener('startDragging', e => {
|
|
|
- this.dragEnable && viewer.inputHandler.intersect && setCursor('grabbing', 'add');
|
|
|
+ [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('startDragging', e => {
|
|
|
+ this.dragEnable && (viewer.inputHandler.intersect || e.target.name == 'lineDragPoint') && setCursor('grabbing', 'add');
|
|
|
+ grabbingObject = e.target.name;
|
|
|
+ grabbingObject == 'lineDragPoint' && setDragPointState(true);
|
|
|
}));
|
|
|
- [this.line, this.spot].forEach(e => e.addEventListener('drop', e => {
|
|
|
+ [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('drop', e => {
|
|
|
this.dragEnable && setCursor('grabbing', 'remove');
|
|
|
+ grabbingObject = null;
|
|
|
+ hoverState['lineDragPoint'] || setDragPointState(false);
|
|
|
}));
|
|
|
//拖拽线来移动。虽然理想方式是拟真,拖拽时不改变在线上的位置,使之平移,但仔细想想似乎办不到。因为墙面normal是不固定的,尤其在交界处难以确定。不知鼠标在空中的位置,即使是平行镜头移动也无法满足所有情况。matterport是加了底座,移动也是改变底座中心。
|
|
|
}
|
|
@@ -61093,6 +61208,16 @@
|
|
|
this.titleLabel.sprite.addEventListener('spriteUpdated', () => {
|
|
|
this.updateDepthParams();
|
|
|
});
|
|
|
+
|
|
|
+ //-----------set line length
|
|
|
+
|
|
|
+ // CursorDeal
|
|
|
+ this.lineDragPoint.addEventListener('mouseover', e => {
|
|
|
+ setDragPointState(true);
|
|
|
+ });
|
|
|
+ this.lineDragPoint.addEventListener('mouseleave', e => {
|
|
|
+ grabbingObject != 'lineDragPoint' && setDragPointState(false);
|
|
|
+ });
|
|
|
}
|
|
|
updateDepthParams() {
|
|
|
//为了避免热点嵌入墙壁,实时根据其大小更新材质系数。 但是在倾斜的角度看由于遮挡距离很大肯定会嵌入的
|
|
@@ -61122,9 +61247,24 @@
|
|
|
viewer.dispatchEvent('content_changed');
|
|
|
}
|
|
|
changeLineLen(len) {
|
|
|
- this.lineLength = len;
|
|
|
+ this.lineLength = parseFloat(len);
|
|
|
this.updatePose();
|
|
|
}
|
|
|
+ dragLineLen(e) {
|
|
|
+ //拖拽线的顶端修改线长度
|
|
|
+ var endPos = this.normal.clone().multiplyScalar(this.lineLength).applyMatrix4(this.matrixWorld);
|
|
|
+ var normal = this.normal.clone().applyQuaternion(this.getWorldQuaternion(new Quaternion()));
|
|
|
+ var projected = endPos.clone().project(e.drag.dragViewport.camera);
|
|
|
+ projected.x = e.pointer.x;
|
|
|
+ projected.y = e.pointer.y;
|
|
|
+ var unprojected = projected.clone().unproject(e.drag.dragViewport.camera);
|
|
|
+ var moveVec = new Vector3().subVectors(unprojected, endPos);
|
|
|
+ moveVec = moveVec.projectOnVector(normal);
|
|
|
+ var newLength = Math.max(0, this.lineLength + moveVec.dot(normal));
|
|
|
+ //console.log(moveVec,newLength)
|
|
|
+ this.changeLineLen(newLength);
|
|
|
+ this.dispatchEvent('dragLineLen');
|
|
|
+ }
|
|
|
changePos(info) {
|
|
|
//注:onMesh时在非平地上拖拽,热点旋转会一直变
|
|
|
this.position.copy(info.position);
|