|
@@ -25178,6 +25178,7 @@
|
|
|
}
|
|
|
}
|
|
|
if (!intersect) {
|
|
|
+ var _intersect;
|
|
|
var canUseDepthTex = (Potree.settings.displayMode == 'showPanos' || useDepthTex) && viewer.images360.currentPano.pointcloud.hasDepthTex && viewport == viewer.mainViewport && !usePointcloud;
|
|
|
if (canUseDepthTex) getByDepthTex();else if (Potree.settings.mergeType2 && Potree.settings.displayMode == 'showPanos' && !viewer.images360.currentPano.pointcloud.isPointcloud) {} //融合页面进入非点云的场景的全景模式不用pick
|
|
|
else getByCloud();
|
|
@@ -25233,6 +25234,13 @@
|
|
|
} else {
|
|
|
intersect = intersectOnModel || intersectPoint;
|
|
|
}
|
|
|
+ if ((_intersect = intersect) !== null && _intersect !== void 0 && _intersect.normal) {
|
|
|
+ //尤其是点云屋顶上的normal都指向屋内了,需要根据站位反向一下
|
|
|
+ if (viewport.view.direction.angleTo(intersect.normal) < Math.PI / 2) {
|
|
|
+ intersect.normal.negate();
|
|
|
+ intersect.localNormal.negate();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (viewport.camera.type == 'OrthographicCamera' /* == 'mapViewport' */) {
|
|
|
var pos3d = new Vector3(this.pointer.x, this.pointer.y, -1).unproject(viewport.camera); //z:-1朝外
|
|
@@ -55598,7 +55606,7 @@
|
|
|
var planeGeo$2 = new PlaneGeometry(1, 1);
|
|
|
var texLoader$7 = new TextureLoader();
|
|
|
var lineMat;
|
|
|
- var defaultLineLength = 0.6;
|
|
|
+ var defaultLineLength = 1;
|
|
|
var defaultSpotScale = 0.4;
|
|
|
var titleHeight = {
|
|
|
uponSpot: 0.1,
|
|
@@ -55618,6 +55626,7 @@
|
|
|
this.root = o.root;
|
|
|
this.dragEnable = true;
|
|
|
this.build(o);
|
|
|
+ this.bindEvent();
|
|
|
}
|
|
|
build(o) {
|
|
|
lineMat || (lineMat = LineDraw.createFatLineMat(Object.assign({}, depthMatProp, {
|
|
@@ -55635,17 +55644,10 @@
|
|
|
this.line = LineDraw.createFatLine([], {
|
|
|
mat: lineMat
|
|
|
});
|
|
|
- this.line.addEventListener('drag', e => {
|
|
|
- this.dragEnable && this.changePos(e);
|
|
|
- });
|
|
|
- this.spot.addEventListener('drag', e => {
|
|
|
- this.dragEnable && this.onMesh && this.changePos(e);
|
|
|
- });
|
|
|
- //拖拽线来移动。虽然理想方式是拟真,拖拽时不改变在线上的位置,使之平移,但仔细想想似乎办不到。因为墙面normal是不固定的,尤其在交界处难以确定。不知鼠标在空中的位置,即使是平行镜头移动也无法满足所有情况。matterport是加了底座,移动也是改变底座中心。
|
|
|
-
|
|
|
+ this.line.name = 'tagLine';
|
|
|
this.titleLabel = new TextSprite$2(Object.assign({}, depthMatProp, {
|
|
|
root: group,
|
|
|
- text: this.title,
|
|
|
+ text: '',
|
|
|
sizeInfo: {
|
|
|
width2d: 200
|
|
|
},
|
|
@@ -55669,29 +55671,82 @@
|
|
|
pickOrder: renderOrders.label,
|
|
|
useDepth: true
|
|
|
})); //更新sprite时,实际更新的是root: spot的矩阵
|
|
|
-
|
|
|
+ this.setTitle(this.title);
|
|
|
this.updateTitlePos();
|
|
|
group.add(this.titleLabel);
|
|
|
- var mouseover = e => {
|
|
|
- this.dispatchEvent('mouseover');
|
|
|
- };
|
|
|
- var mouseleave = e => {
|
|
|
- this.dispatchEvent('mouseleave');
|
|
|
- };
|
|
|
- var click = e => {
|
|
|
- this.dispatchEvent('click');
|
|
|
- };
|
|
|
- this.spot.addEventListener('mouseover', mouseover);
|
|
|
- this.spot.addEventListener('mouseleave', mouseleave);
|
|
|
- this.titleLabel.addEventListener('mouseover', mouseover);
|
|
|
- this.titleLabel.addEventListener('mouseleave', mouseleave);
|
|
|
- this.spot.addEventListener('click', click);
|
|
|
- this.titleLabel.addEventListener('click', click);
|
|
|
group.add(this.spot);
|
|
|
this.add(group);
|
|
|
this.add(this.line);
|
|
|
- this.updatePose();
|
|
|
viewer.scene.tags.add(this);
|
|
|
+ this.updatePose();
|
|
|
+ }
|
|
|
+ bindEvent() {
|
|
|
+ var hoverState = {
|
|
|
+ line: 0,
|
|
|
+ spot: 0,
|
|
|
+ label: 0
|
|
|
+ };
|
|
|
+ {
|
|
|
+ //因为只有有intersect时才能拖拽,所以写得比较麻烦
|
|
|
+ var cursor = {
|
|
|
+ hoverGrab: 0,
|
|
|
+ grabbing: 0
|
|
|
+ };
|
|
|
+ var setCursor = (name, action) => {
|
|
|
+ var state = action == 'add' ? 1 : 0;
|
|
|
+ if (state != cursor[name]) {
|
|
|
+ cursor[name] = state;
|
|
|
+ viewer.dispatchEvent({
|
|
|
+ type: "CursorChange",
|
|
|
+ action,
|
|
|
+ name
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ [this.line, this.spot].forEach(e => e.addEventListener('mousemove', e => {
|
|
|
+ hoverState[e.target.name == 'tagLine' ? 'line' : 'spot'] = 1;
|
|
|
+ if (this.dragEnable && viewer.inputHandler.intersect) {
|
|
|
+ //能拖拽时
|
|
|
+ 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) {
|
|
|
+ //都没hover才取消
|
|
|
+ setCursor('hoverGrab', 'remove');
|
|
|
+ }
|
|
|
+ }));
|
|
|
+ [this.line, this.spot].forEach(e => e.addEventListener('drag', e => {
|
|
|
+ this.dragEnable && cursor.grabbing && this.changePos(e);
|
|
|
+ }));
|
|
|
+ [this.line, this.spot].forEach(e => e.addEventListener('startDragging', e => {
|
|
|
+ this.dragEnable && viewer.inputHandler.intersect && setCursor('grabbing', 'add');
|
|
|
+ }));
|
|
|
+ [this.line, this.spot].forEach(e => e.addEventListener('drop', e => {
|
|
|
+ this.dragEnable && setCursor('grabbing', 'remove');
|
|
|
+ }));
|
|
|
+ //拖拽线来移动。虽然理想方式是拟真,拖拽时不改变在线上的位置,使之平移,但仔细想想似乎办不到。因为墙面normal是不固定的,尤其在交界处难以确定。不知鼠标在空中的位置,即使是平行镜头移动也无法满足所有情况。matterport是加了底座,移动也是改变底座中心。
|
|
|
+ }
|
|
|
+ {
|
|
|
+ var mouseover = e => {
|
|
|
+ this.dispatchEvent('mouseover');
|
|
|
+ };
|
|
|
+ var mouseleave = e => {
|
|
|
+ this.dispatchEvent('mouseleave');
|
|
|
+ };
|
|
|
+ var click = e => {
|
|
|
+ this.dispatchEvent('click');
|
|
|
+ };
|
|
|
+ this.spot.addEventListener('mouseover', mouseover);
|
|
|
+ this.spot.addEventListener('mouseleave', mouseleave);
|
|
|
+ this.titleLabel.addEventListener('mouseover', mouseover);
|
|
|
+ this.titleLabel.addEventListener('mouseleave', mouseleave);
|
|
|
+ this.spot.addEventListener('click', click);
|
|
|
+ this.titleLabel.addEventListener('click', click);
|
|
|
+ }
|
|
|
this.titleLabel.sprite.addEventListener('spriteUpdated', () => {
|
|
|
this.updateDepthParams();
|
|
|
});
|
|
@@ -55727,25 +55782,48 @@
|
|
|
this.updatePose();
|
|
|
}
|
|
|
changePos(e) {
|
|
|
- var _e$intersect;
|
|
|
- if (!((_e$intersect = e.intersect) !== null && _e$intersect !== void 0 && _e$intersect.location)) return;
|
|
|
- this.root = e.intersect.pointcloud || e.intersect.object;
|
|
|
- var localPos = Potree.Utils.datasetPosTransform({
|
|
|
- toDataset: true,
|
|
|
- pointcloud: e.intersect.pointcloud,
|
|
|
- object: e.intersect.object,
|
|
|
- position: e.intersect.location
|
|
|
- });
|
|
|
- this.position.copy(localPos);
|
|
|
- this.normal.copy(e.intersect.localNormal);
|
|
|
+ var info = viewer.tagTool.getPoseByIntersect(e);
|
|
|
+ if (!info) return;
|
|
|
+ this.position.copy(info.position);
|
|
|
+ this.normal.copy(info.normal);
|
|
|
this.setNorQua();
|
|
|
this.updatePose();
|
|
|
this.dispatchEvent('posChanged');
|
|
|
}
|
|
|
- changeTitle(title) {
|
|
|
- this.titleLabel.changeText(title);
|
|
|
+ changeOnMesh(onMesh) {
|
|
|
+ //是否贴在mesh上
|
|
|
+ this.onMesh = onMesh;
|
|
|
+ if (onMesh) {
|
|
|
+ //贴mesh上时不是sprite,且可设置旋转值
|
|
|
+ this.add(this.spot);
|
|
|
+ this.titleLabel.position.y = 0;
|
|
|
+ this.spot.position.set(0, 0, 0.01); //在mesh之上偏移一点
|
|
|
+ this.setNorQua();
|
|
|
+ this.line.renderOrder = renderOrders.spot + 1; //比spot高,但比label低
|
|
|
+ } else {
|
|
|
+ this.titleLabel.parent.add(this.spot);
|
|
|
+ this.updateTitlePos();
|
|
|
+ this.spot.position.set(0, 0, 0);
|
|
|
+ this.spot.quaternion.set(0, 0, 0, 1); //this.titleLabel.update()
|
|
|
+ this.line.renderOrder = renderOrders.line; //还原
|
|
|
+ }
|
|
|
+ Potree.Utils.updateVisible(this.line, 'hideTitle', !this.titleLabel.visible && onMesh ? false : true);
|
|
|
+ this.updateDepthParams();
|
|
|
+ viewer.dispatchEvent('content_changed');
|
|
|
+ }
|
|
|
+ setTitle() {
|
|
|
+ var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
|
+ this.titleLabel.setText(title);
|
|
|
+ this.setTitleVisi(title.trim() != '', 'noText');
|
|
|
viewer.dispatchEvent('content_changed');
|
|
|
}
|
|
|
+ setTitleVisi(v) {
|
|
|
+ var reason = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
|
+ Potree.Utils.updateVisible(this.titleLabel, 'hideTitle-' + reason, v);
|
|
|
+ //tag.onMesh && Potree.Utils.updateVisible(tag.line, 'hideTitle-'+reason, v)
|
|
|
+ //line的可见性比较复杂,所以干脆跟随title的,reason不记录那么多
|
|
|
+ this.onMesh && Potree.Utils.updateVisible(this.line, 'hideTitle', this.titleLabel.visible);
|
|
|
+ }
|
|
|
changeMap(url) {
|
|
|
var map = texLoader$7.load(url, () => {
|
|
|
viewer.dispatchEvent('content_changed');
|
|
@@ -55763,24 +55841,6 @@
|
|
|
this.faceAngle = faceAngle;
|
|
|
viewer.dispatchEvent('content_changed');
|
|
|
}
|
|
|
- changeOnMesh(onMesh) {
|
|
|
- this.onMesh = onMesh;
|
|
|
- if (onMesh) {
|
|
|
- this.add(this.spot);
|
|
|
- this.titleLabel.position.y = 0;
|
|
|
- this.spot.position.set(0, 0, 0.01); //在mesh之上偏移一点
|
|
|
- this.setNorQua();
|
|
|
- this.line.renderOrder = renderOrders.spot + 1; //比spot高,但比label低
|
|
|
- } else {
|
|
|
- this.titleLabel.parent.add(this.spot);
|
|
|
- this.updateTitlePos();
|
|
|
- this.spot.position.set(0, 0, 0);
|
|
|
- this.spot.quaternion.set(0, 0, 0, 1); //this.titleLabel.update()
|
|
|
- this.line.renderOrder = renderOrders.line; //还原
|
|
|
- }
|
|
|
- this.updateDepthParams();
|
|
|
- viewer.dispatchEvent('content_changed');
|
|
|
- }
|
|
|
changeSpotScale(s) {
|
|
|
this.spot.scale.set(s, s, s);
|
|
|
viewer.dispatchEvent('content_changed');
|
|
@@ -55842,14 +55902,26 @@
|
|
|
});
|
|
|
}
|
|
|
createTagFromData(data) {
|
|
|
- var tag = new Tag({
|
|
|
- title: data.title,
|
|
|
- position: data.position,
|
|
|
- normal: data.normal,
|
|
|
- root: data.root //e.intersect.pointcloud || e.intersect.object
|
|
|
- });
|
|
|
+ var tag = new Tag(data);
|
|
|
return tag;
|
|
|
}
|
|
|
+ getPoseByIntersect(e) {
|
|
|
+ var _e$intersect;
|
|
|
+ if (!((_e$intersect = e.intersect) !== null && _e$intersect !== void 0 && _e$intersect.location)) return;
|
|
|
+ var root = e.intersect.pointcloud || e.intersect.object;
|
|
|
+ var position = Potree.Utils.datasetPosTransform({
|
|
|
+ toDataset: true,
|
|
|
+ pointcloud: e.intersect.pointcloud,
|
|
|
+ object: e.intersect.object,
|
|
|
+ position: e.intersect.location
|
|
|
+ });
|
|
|
+ var normal = e.intersect.localNormal.clone();
|
|
|
+ return {
|
|
|
+ root,
|
|
|
+ normal,
|
|
|
+ position
|
|
|
+ };
|
|
|
+ }
|
|
|
startInsertion() {
|
|
|
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -55870,22 +55942,18 @@
|
|
|
this.viewer.removeEventListener('global_click', click);
|
|
|
};
|
|
|
var click = e => {
|
|
|
- var worldPos = e.intersect && ( /* e.intersect.orthoIntersect || */e.intersect.location);
|
|
|
- if (!worldPos) {
|
|
|
- return;
|
|
|
+ /* var worldPos = e.intersect && ( e.intersect.location)
|
|
|
+ if(!worldPos){
|
|
|
+ return
|
|
|
}
|
|
|
- var localPos = Potree.Utils.datasetPosTransform({
|
|
|
- toDataset: true,
|
|
|
- pointcloud: e.intersect.pointcloud,
|
|
|
- object: e.intersect.object,
|
|
|
- position: worldPos
|
|
|
- });
|
|
|
- var tag = new Tag({
|
|
|
- title: '1',
|
|
|
- position: localPos,
|
|
|
- normal: e.intersect.localNormal,
|
|
|
- root: e.intersect.pointcloud || e.intersect.object
|
|
|
- });
|
|
|
+
|
|
|
+ let localPos = Potree.Utils.datasetPosTransform({ toDataset: true, pointcloud:e.intersect.pointcloud, object:e.intersect.object, position:worldPos })
|
|
|
+ */
|
|
|
+
|
|
|
+ var info = this.getPoseByIntersect(e);
|
|
|
+ if (!info) return;
|
|
|
+ info.title = '1';
|
|
|
+ var tag = new Tag(info);
|
|
|
|
|
|
//pointcloud里加一个normal 的非float32
|
|
|
|
|
@@ -63067,6 +63135,15 @@
|
|
|
}, {
|
|
|
'hoverTranHandle': 'grab'
|
|
|
}, {
|
|
|
+ 'grabbing': 'grabbing'
|
|
|
+ },
|
|
|
+ //通用
|
|
|
+ {
|
|
|
+ 'hoverGrab': 'grab'
|
|
|
+ },
|
|
|
+ //通用
|
|
|
+
|
|
|
+ {
|
|
|
"movePointcloud": 'move'
|
|
|
}, {
|
|
|
"polygon_isIntersectSelf": 'not-allowed'
|