|
@@ -63567,17 +63567,17 @@ void main() {
|
|
|
};
|
|
|
|
|
|
|
|
|
- /* var transformPointcloud = (pointcloud )=>{ //初始化位置
|
|
|
- viewer.sidebar && viewer.sidebar.addAlignmentButton(pointcloud)
|
|
|
+ var transformPointcloud = (pointcloud )=>{ //初始化位置
|
|
|
+ viewer.sidebar && viewer.sidebar.addAlignmentButton(pointcloud);
|
|
|
|
|
|
- let orientation = pointcloud.panos[0].dataRotation.z
|
|
|
- let location = pointcloud.panos[0].dataPosition.clone().negate()
|
|
|
- Alignment.rotate(pointcloud, null, orientation )
|
|
|
- Alignment.translate(pointcloud, location )
|
|
|
+ let orientation = pointcloud.panos[0].dataRotation.z;
|
|
|
+ let location = pointcloud.panos[0].dataPosition.clone().negate();
|
|
|
+ Alignment.rotate(pointcloud, null, orientation );
|
|
|
+ Alignment.translate(pointcloud, location );
|
|
|
|
|
|
- pointcloud.updateMatrixWorld()
|
|
|
+ pointcloud.updateMatrixWorld();
|
|
|
|
|
|
- } */
|
|
|
+ };
|
|
|
|
|
|
|
|
|
|
|
@@ -63680,7 +63680,7 @@ void main() {
|
|
|
}
|
|
|
|
|
|
Potree.settings.sizeFitToLevel = true;//当type为衰减模式时自动根据level调节大小。每长一级,大小就除以2
|
|
|
- Potree.loadPointCloudScene = function(sceneCode, done){//对应4dkk的场景码
|
|
|
+ Potree.loadPointCloudScene = function(sceneCode, done, onError){//对应4dkk的场景码
|
|
|
Potree.loadDatasets((data)=>{
|
|
|
var originDataset = data.find(e=>e.sceneCode == sceneCode);//只加载初始数据集
|
|
|
var cloudPath = `${Potree.settings.urls.prefix}/${Potree.settings.webSite}/${sceneCode}/data/${sceneCode}/webcloud/cloud.js`;
|
|
@@ -63722,10 +63722,10 @@ void main() {
|
|
|
viewer.scene.add360Images(viewer.images360); */
|
|
|
viewer.dispatchEvent('allLoaded');
|
|
|
done(pointcloud);
|
|
|
- });
|
|
|
+ },onError);
|
|
|
|
|
|
|
|
|
- }, sceneCode);
|
|
|
+ }, sceneCode, onError);
|
|
|
|
|
|
|
|
|
};
|
|
@@ -63787,7 +63787,7 @@ void main() {
|
|
|
|
|
|
|
|
|
let modelType, modelEditing, MergeEditor = viewer.modules.MergeEditor;
|
|
|
- Potree.addModel = function(prop, done, onprogress){ //加载模型
|
|
|
+ Potree.addModel = function(prop, done, onProgress, onError){ //加载模型
|
|
|
let isFirstLoad = !prop.position; //在编辑时用户添加的
|
|
|
|
|
|
let loadDone = (model)=>{
|
|
@@ -63865,7 +63865,7 @@ void main() {
|
|
|
viewer.outlinePass.selectedObjects = []
|
|
|
}) */
|
|
|
|
|
|
- });
|
|
|
+ }, onError);
|
|
|
}else {
|
|
|
|
|
|
|
|
@@ -63906,17 +63906,23 @@ void main() {
|
|
|
loadDone(object);
|
|
|
};
|
|
|
|
|
|
-
|
|
|
- viewer.loadModel({
|
|
|
- name: 'glb',
|
|
|
- glburl: prop.url, //0.3s
|
|
|
+
|
|
|
+ let info = {
|
|
|
+ name: prop.type,
|
|
|
transform : {
|
|
|
position : prop.position,
|
|
|
rotation : new Euler().setFromVector3(prop.rotation),
|
|
|
scale: new Vector3(prop.scale,prop.scale,prop.scale),
|
|
|
- }
|
|
|
-
|
|
|
- },callback,onprogress);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ if(prop.type == 'glb'){
|
|
|
+ info.glburl = prop.url;
|
|
|
+ }else {
|
|
|
+ info.objurl = prop.url;
|
|
|
+ info.mtlurl = prop.mtlurl;
|
|
|
+ }
|
|
|
+ viewer.loadModel(info , callback, onProgress, onError);
|
|
|
|
|
|
}
|
|
|
};
|
|
@@ -84014,6 +84020,7 @@ void main() {
|
|
|
|
|
|
let pointclouds;
|
|
|
let Alignment = window.viewer.modules.Alignment;
|
|
|
+ let MergeEditor = window.viewer.modules.MergeEditor;
|
|
|
let handleState = Alignment.handleState;
|
|
|
|
|
|
let a = e.buttons === Buttons.LEFT && viewport.alignment && handleState && viewport.alignment[handleState];
|
|
@@ -84033,8 +84040,13 @@ void main() {
|
|
|
}
|
|
|
|
|
|
if(!pointclouds && e.buttons === Buttons.LEFT && viewport.alignment.rotateSide){
|
|
|
- return PanoEditor.rotateSideCamera(e.drag.pointerDelta.x)
|
|
|
+ return PanoEditor.rotateSideCamera(-e.drag.pointerDelta.x)
|
|
|
}
|
|
|
+ }else if(Potree.settings.editType == 'merge'){
|
|
|
+ if(e.buttons === Buttons.LEFT && viewport.alignment.rotateSide){
|
|
|
+ return MergeEditor.rotateSideCamera(-e.drag.pointerDelta.x)
|
|
|
+ }
|
|
|
+
|
|
|
}else {
|
|
|
/* if(Alignment.selectedClouds && Alignment.selectedClouds.length){
|
|
|
pointclouds = a && e.drag.intersectStart.pointclouds && Common.getMixedSet(Alignment.selectedClouds, e.drag.intersectStart.pointclouds).length && Alignment.selectedClouds
|
|
@@ -84744,6 +84756,7 @@ void main() {
|
|
|
this.domElement.tabIndex = 2222;
|
|
|
}
|
|
|
|
|
|
+ this.lastPointerUpTime = 0;
|
|
|
|
|
|
this.touches = [];
|
|
|
|
|
@@ -84766,7 +84779,7 @@ void main() {
|
|
|
this.domElement.addEventListener('mousewheel', this.onMouseWheel.bind(this), false);
|
|
|
this.domElement.addEventListener('DOMMouseScroll', this.onMouseWheel.bind(this), false); // Firefox
|
|
|
|
|
|
- this.domElement.addEventListener('dblclick', this.onDoubleClick.bind(this));
|
|
|
+ //this.domElement.addEventListener('dblclick', this.onDoubleClick.bind(this)); //因为双击时间间隔是跟随系统的所以不好判断
|
|
|
|
|
|
this.domElement.addEventListener('keydown', this.onKeyDown.bind(this));
|
|
|
window.addEventListener('keyup', this.onKeyUp.bind(this));
|
|
@@ -85057,7 +85070,7 @@ void main() {
|
|
|
});
|
|
|
//}
|
|
|
}
|
|
|
-
|
|
|
+ this.needSingleClick = false;//add
|
|
|
e.preventDefault();
|
|
|
}
|
|
|
|
|
@@ -85215,6 +85228,7 @@ void main() {
|
|
|
if(isTouch && e.touches.length >= 1){
|
|
|
return
|
|
|
}
|
|
|
+ let now = Date.now();
|
|
|
|
|
|
|
|
|
if (this.logMessages) console.log(this.constructor.name + ': onMouseUp');
|
|
@@ -85222,7 +85236,7 @@ void main() {
|
|
|
e.preventDefault();
|
|
|
|
|
|
let pressDistance = this.mouseDownMouse.distanceTo(this.mouse);
|
|
|
- let pressTime = Date.now() - this.pointerDownTime;
|
|
|
+ let pressTime = now - this.pointerDownTime;
|
|
|
|
|
|
let noMovement = this.drag.pointerDelta.length() == 0;//this.getNormalizedDrag().length() === 0;
|
|
|
|
|
@@ -85301,7 +85315,9 @@ void main() {
|
|
|
pressDistance
|
|
|
}
|
|
|
));
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//if(!clickElement){
|
|
@@ -85312,7 +85328,32 @@ void main() {
|
|
|
pressDistance
|
|
|
}
|
|
|
));
|
|
|
- //}
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //增加 单击:
|
|
|
+ this.needSingleClick = true;
|
|
|
+ this.doubleClickTime = 200; //双击间隔时间
|
|
|
+ setTimeout(()=>{
|
|
|
+ if(this.needSingleClick){
|
|
|
+ this.viewer.dispatchEvent($.extend(
|
|
|
+ this.getEventDesc(e,isTouch),
|
|
|
+ {
|
|
|
+ type: 'global_single_click',
|
|
|
+ pressDistance
|
|
|
+ }
|
|
|
+ ));
|
|
|
+ }
|
|
|
+ }, this.doubleClickTime+1);
|
|
|
+
|
|
|
+ //自行执行双击:
|
|
|
+
|
|
|
+ if(now - this.lastClickTime < this.doubleClickTime){
|
|
|
+ this.onDoubleClick(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.lastClickTime = now;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -85347,6 +85388,8 @@ void main() {
|
|
|
this.deselectAll();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
onMouseUp (e) {
|
|
@@ -103286,7 +103329,10 @@ ENDSEC
|
|
|
}
|
|
|
if(!I)return;
|
|
|
|
|
|
- viewer.setView({position:I, duration:1000});
|
|
|
+ let dis = this.scene.view.position.distanceTo(I);
|
|
|
+ let distance = MathUtils.clamp(dis, 0.3, 3);
|
|
|
+
|
|
|
+ viewer.focusOnObject({ position:I }, 'point', null, {distance});
|
|
|
|
|
|
}
|
|
|
|
|
@@ -111971,29 +112017,26 @@ ENDSEC
|
|
|
viewer.updateScreenSize({forceUpdateSize:true});
|
|
|
}
|
|
|
|
|
|
- viewportFitBound(viewport, bound, center, duration=0){
|
|
|
+ viewportFitBound(viewport, bound, center, duration=0, margin){
|
|
|
let view = viewport.view;
|
|
|
let info = {bound};
|
|
|
|
|
|
viewport.targetPlane.setFromNormalAndCoplanarPoint( view.direction.clone(), viewer.bound.center );
|
|
|
viewport.targetPlane.projectPoint(center, viewport.shiftTarget); //target转换到过模型中心的平面,以保证镜头一定在模型外 this.shiftTarget是得到的
|
|
|
|
|
|
- info.endPosition = this.getPosOutOfModel(viewport.shiftTarget, view );
|
|
|
+ info.endPosition = this.getPosOutOfModel(viewport);
|
|
|
|
|
|
//if(viewport.name == 'mapViewport')info.endPosition.z = Math.max(Potree.config.map.cameraHeight, info.endPosition.z)
|
|
|
-
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- info.margin = {x:30, y:30};
|
|
|
+ info.margin = margin || {x:30, y:30};
|
|
|
view.moveOrthoCamera(viewport, info , duration );
|
|
|
}
|
|
|
|
|
|
- getPosOutOfModel(shiftTarget, view){
|
|
|
+ getPosOutOfModel(viewport){
|
|
|
let {boundSize, center} = viewer.bound;
|
|
|
let expand = 10;
|
|
|
let radius = boundSize.length() / 2;
|
|
|
- let position = shiftTarget.clone().sub(view.direction.clone().multiplyScalar(radius + expand));
|
|
|
+ let position = viewport.shiftTarget.clone().sub(viewport.view.direction.clone().multiplyScalar(radius + expand));
|
|
|
|
|
|
return position
|
|
|
}
|
|
@@ -112011,7 +112054,28 @@ ENDSEC
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ rotateSideCamera(viewport, angle){//侧视图绕模型中心水平旋转
|
|
|
+
|
|
|
+ let {boundSize, center} = viewer.bound;
|
|
|
+
|
|
|
+ //找到平移向量
|
|
|
+ viewport.targetPlane.setFromNormalAndCoplanarPoint(viewport.view.direction , center );
|
|
|
+ viewport.targetPlane.projectPoint(viewport.view.position, viewport.shiftTarget ); //target转换到过模型中心的平面,以保证镜头一定在模型外
|
|
|
+ let vec = new Vector3().subVectors(center, viewport.shiftTarget);//相对于中心的偏移值,旋转后偏移值也旋转
|
|
|
+
|
|
|
+ //旋转
|
|
|
+ var rotMatrix = new Matrix4().makeRotationAxis(new Vector3(0,0,1), angle);
|
|
|
+
|
|
|
+ viewport.view.direction = viewport.view.direction.applyMatrix4(rotMatrix);
|
|
|
+
|
|
|
+
|
|
|
+ vec.applyMatrix4(rotMatrix);
|
|
|
+ viewport.shiftTarget.subVectors(center,vec); //新的
|
|
|
+
|
|
|
+
|
|
|
+ viewport.view.position = this.getPosOutOfModel(viewport);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
getOrthoCamera(){
|
|
|
return new OrthographicCamera(-100, 100, 100, 100, 0.01, 10000)
|
|
@@ -115021,7 +115085,7 @@ ENDSEC
|
|
|
|
|
|
|
|
|
|
|
|
- viewer.addEventListener('global_click',(e)=>{
|
|
|
+ viewer.addEventListener('global_single_click',(e)=>{
|
|
|
if(viewer.inputHandler.selection[0] ||//正在平移和旋转,不允许更换
|
|
|
viewer.scene.cameraAnimations.length //正在播放
|
|
|
){
|
|
@@ -115044,17 +115108,20 @@ ENDSEC
|
|
|
},
|
|
|
|
|
|
|
|
|
- enterSplit(){
|
|
|
+ enterSplit(){
|
|
|
this.SplitScreen.splitStart(viewportProps$1);
|
|
|
-
|
|
|
-
|
|
|
+ viewer.setControls(viewer.fpControls);
|
|
|
+ viewer.viewports.find(e=>e.name == 'right').alignment = {rotateSide : true};
|
|
|
},
|
|
|
|
|
|
leaveSplit(){
|
|
|
this.SplitScreen.unSplit();
|
|
|
+ viewer.setControls(viewer.orbitControls);
|
|
|
},
|
|
|
|
|
|
-
|
|
|
+ rotateSideCamera(angle){
|
|
|
+ this.SplitScreen.rotateSideCamera(viewer.viewports.find(e=>e.name == 'right'), angle);
|
|
|
+ },
|
|
|
|
|
|
//---------------------------
|
|
|
|
|
@@ -115112,28 +115179,32 @@ ENDSEC
|
|
|
},
|
|
|
|
|
|
|
|
|
- focusOnSelect(object, duration = 400){
|
|
|
- let boundingBox = object.boundingBox.clone().applyMatrix4(object.matrixWorld);
|
|
|
- let center = boundingBox.getCenter(new Vector3);
|
|
|
- let size = boundingBox.getSize(new Vector3);
|
|
|
- let maxSize = size.length(); //对角线长度
|
|
|
+ /* focusOnSelect(object, duration = 400){
|
|
|
+ let boundingBox = object.boundingBox.clone().applyMatrix4(object.matrixWorld)
|
|
|
+ let center = boundingBox.getCenter(new THREE.Vector3)
|
|
|
+ let size = boundingBox.getSize(new THREE.Vector3)
|
|
|
+ let maxSize = size.length() //对角线长度
|
|
|
|
|
|
if(object.isPointcloud){
|
|
|
- maxSize /= 2;
|
|
|
+ maxSize /= 2
|
|
|
}
|
|
|
|
|
|
- let hfov = cameraLight.getHFOVForCamera(viewer.mainViewport.camera,true);
|
|
|
- let minRadius = maxSize / Math.tan(hfov/2);
|
|
|
+ let hfov = cameraLight.getHFOVForCamera(viewer.mainViewport.camera,true)
|
|
|
+ let minRadius = maxSize / Math.tan(hfov/2)
|
|
|
//viewer.mainViewport.view.lookAt(center)
|
|
|
viewer.mainViewport.view.setView({
|
|
|
position: center.clone().sub(viewer.mainViewport.view.direction.clone().multiplyScalar(minRadius)),
|
|
|
target: center,
|
|
|
duration
|
|
|
- }); //setView can cancel bump
|
|
|
+ }) //setView can cancel bump
|
|
|
+
|
|
|
+ }, */
|
|
|
+ focusOnSelect(object, duration = 400){
|
|
|
+ let boundingBox = object.boundingBox.clone().applyMatrix4(object.matrixWorld);
|
|
|
+ viewer.focusOnObject({boundingBox}, 'boundingBox', duration );
|
|
|
|
|
|
},
|
|
|
|
|
|
-
|
|
|
setModelBtmHeight(model, z ){
|
|
|
|
|
|
//无论模型怎么缩放、旋转,都使最低点为z
|
|
@@ -118767,7 +118838,7 @@ ENDSEC
|
|
|
}
|
|
|
];
|
|
|
|
|
|
- const targetPlane = new Plane();
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -118786,8 +118857,7 @@ ENDSEC
|
|
|
this.orthoCamera = new OrthographicCamera(-100, 100, 100, 100, 0.01, 10000);
|
|
|
this.selectedPano;
|
|
|
this.selectedGroup;
|
|
|
- this.operation;
|
|
|
- this.shiftTarget = new Vector3; //project在targetPlane上的位置
|
|
|
+ this.operation;
|
|
|
this.visiblePanos = [];
|
|
|
}
|
|
|
|
|
@@ -118841,7 +118911,7 @@ ENDSEC
|
|
|
|
|
|
|
|
|
|
|
|
- this.switchView('top');
|
|
|
+ this.switchView('right'/* 'top' */);
|
|
|
|
|
|
SiteModel$1.bus.addEventListener('initDataDone',()=>{
|
|
|
this.gotoFloor(SiteModel$1.entities.find(e=>e.buildType == 'floor')); //任意一层
|
|
@@ -118918,13 +118988,18 @@ ENDSEC
|
|
|
|
|
|
|
|
|
//////////////////////////////////
|
|
|
- initViews(){
|
|
|
+ initViews(){
|
|
|
+ this.splitScreenTool = new SplitScreen;
|
|
|
+ this.targetPlane = viewer.mainViewport.targetPlane = new Plane();
|
|
|
+ this.shiftTarget = viewer.mainViewport.shiftTarget = new Vector3; //project在targetPlane上的位置
|
|
|
+
|
|
|
+
|
|
|
for(let i=0;i<2;i++){
|
|
|
let prop = cameraProps[i];
|
|
|
let view = new View();
|
|
|
this.views[prop.name] = view;
|
|
|
this.cameras[prop.name] = this.orthoCamera;
|
|
|
-
|
|
|
+
|
|
|
view.direction = prop.direction;
|
|
|
}
|
|
|
this.views.mainView = viewer.mainViewport.view;
|
|
@@ -118943,14 +119018,15 @@ ENDSEC
|
|
|
this.activeViewName = name;
|
|
|
let lastView = this.views[this.lastViewName];
|
|
|
let lastCamera = this.cameras[this.lastViewName];
|
|
|
-
|
|
|
- //let aspect = viewer.mainViewport.camera.aspect
|
|
|
viewer.mainViewport.view = view;
|
|
|
viewer.mainViewport.camera = camera;
|
|
|
- //targetPlane.setFromNormalAndCoplanarPoint( prop.direction.clone(), center )
|
|
|
- targetPlane.setFromNormalAndCoplanarPoint( view.direction.clone(), center );
|
|
|
- targetPlane.projectPoint(view.position, this.shiftTarget ); //target转换到过模型中心的平面,以保证镜头一定在模型外
|
|
|
- view.position.copy(this.getPosOutOfModel());
|
|
|
+ if(lastCamera)lastView.zoom = lastCamera.zoom;
|
|
|
+
|
|
|
+ this.targetPlane.setFromNormalAndCoplanarPoint( view.direction.clone(), center );
|
|
|
+ this.targetPlane.projectPoint(view.position, this.shiftTarget ); //target转换到过模型中心的平面,以保证镜头一定在模型外
|
|
|
+ view.position.copy(this.splitScreenTool.getPosOutOfModel(viewer.mainViewport));
|
|
|
+ if(view.zoom)camera.zoom = view.zoom;//恢复上次的zoom
|
|
|
+
|
|
|
|
|
|
viewer.updateScreenSize({forceUpdateSize:true});//更新camera aspect left等
|
|
|
this.updateCursor();
|
|
@@ -118981,13 +119057,12 @@ ENDSEC
|
|
|
|
|
|
console.log('最近',nearestPano );
|
|
|
|
|
|
- if(nearestPano && nearestPano[0] ){
|
|
|
-
|
|
|
-
|
|
|
+ if(nearestPano && nearestPano[0] ){ //尽量不变画面范围,使pano点保持原位,转换到mainView
|
|
|
let halfHeight = lastCamera.top/lastCamera.zoom;
|
|
|
let dis = halfHeight / Math.tan( MathUtils.degToRad(camera.fov/2));
|
|
|
view.position.add(direction.clone().multiplyScalar(-nearestPano[0].score - dis));
|
|
|
- console.log('getCloser', -nearestPano[0].score - dis);
|
|
|
+ //console.log('getCloser', -nearestPano[0].score - dis)
|
|
|
+ this.lastDisToPano = dis; //记录一下
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -119014,7 +119089,9 @@ ENDSEC
|
|
|
viewer.updateVisible(viewer.reticule, 'force', false);
|
|
|
|
|
|
if(name == 'top') viewer.mainViewport.alignment = {rotate:true,translate:true};
|
|
|
- else if(name == 'right') viewer.mainViewport.alignment = {translate:true, rotateSide:true};
|
|
|
+ if(name == 'right'){
|
|
|
+ viewer.mainViewport.alignment = {translate:true, rotateSide:true};
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -119024,7 +119101,7 @@ ENDSEC
|
|
|
|
|
|
//new THREE.Plane().setFromNormalAndCoplanarPoint( normal, this.points[0] )
|
|
|
|
|
|
- viewportFitBound(name, boundSize_, target){ //使一个viewport聚焦在某个范围
|
|
|
+ viewportFitBound(/* name, boundSize_, target */){ //使一个viewport聚焦在某个范围
|
|
|
/* let viewport = viewer.mainViewport
|
|
|
let {boundSize, center} = viewer.bound
|
|
|
|
|
@@ -119058,7 +119135,7 @@ ENDSEC
|
|
|
|
|
|
if(viewer.mainViewport.resolution.x == 0 || viewer.mainViewport.resolution.y == 0){
|
|
|
return setTimeout(()=>{
|
|
|
- this.viewportFitBound(name, boundSize_, target);
|
|
|
+ this.viewportFitBound(/* name, boundSize_, target */);
|
|
|
},10)
|
|
|
}
|
|
|
|
|
@@ -119068,46 +119145,48 @@ ENDSEC
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
rotateSideCamera(angle){//侧视图绕模型中心水平旋转
|
|
|
- var prop = cameraProps.find(v => v.name == 'right' );
|
|
|
+ this.splitScreenTool.rotateSideCamera(viewer.mainViewport, angle);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* rotateSideCamera(angle){//侧视图绕模型中心水平旋转
|
|
|
+ var prop = cameraProps.find(v => v.name == 'right' )
|
|
|
|
|
|
- let {boundSize, center} = viewer.bound;
|
|
|
+ let {boundSize, center} = viewer.bound
|
|
|
|
|
|
|
|
|
//找到平移向量
|
|
|
- targetPlane.setFromNormalAndCoplanarPoint(viewer.mainViewport.view.direction /* prop.direction.clone() */, center );
|
|
|
- targetPlane.projectPoint(viewer.mainViewport.view.position, this.shiftTarget ); //target转换到过模型中心的平面,以保证镜头一定在模型外
|
|
|
- let vec = new Vector3().subVectors(center, this.shiftTarget);//相对于中心的偏移值,旋转后偏移值也旋转
|
|
|
+ targetPlane.setFromNormalAndCoplanarPoint(viewer.mainViewport.view.direction , center )
|
|
|
+ targetPlane.projectPoint(viewer.mainViewport.view.position, this.shiftTarget ) //target转换到过模型中心的平面,以保证镜头一定在模型外
|
|
|
+ let vec = new THREE.Vector3().subVectors(center, this.shiftTarget)//相对于中心的偏移值,旋转后偏移值也旋转
|
|
|
|
|
|
//旋转
|
|
|
- var rotMatrix = new Matrix4().makeRotationAxis(new Vector3(0,0,1), angle);
|
|
|
+ var rotMatrix = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(0,0,1), angle)
|
|
|
//prop.direction.applyMatrix4(rotMatrix)
|
|
|
- viewer.mainViewport.view.direction = viewer.mainViewport.view.direction.applyMatrix4(rotMatrix);
|
|
|
+ viewer.mainViewport.view.direction = viewer.mainViewport.view.direction.applyMatrix4(rotMatrix)
|
|
|
|
|
|
|
|
|
- vec.applyMatrix4(rotMatrix);
|
|
|
- this.shiftTarget.subVectors(center,vec); //新的
|
|
|
+ vec.applyMatrix4(rotMatrix)
|
|
|
+ this.shiftTarget.subVectors(center,vec) //新的
|
|
|
|
|
|
|
|
|
- viewer.mainViewport.view.position = this.getPosOutOfModel();
|
|
|
- //this.setCameraPose(/* this.shiftTarget, prop.direction */)
|
|
|
+ viewer.mainViewport.view.position = this.splitScreenTool.getPosOutOfModel(viewer.mainViewport) // this.getPosOutOfModel()
|
|
|
+
|
|
|
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
|
|
|
- getPosOutOfModel(){//已知shiftTarget和currentDir后
|
|
|
- let {boundSize, center} = viewer.bound;
|
|
|
+ /* getPosOutOfModel(){//已知shiftTarget和currentDir后
|
|
|
+ let {boundSize, center} = viewer.bound
|
|
|
let expand = 10;
|
|
|
- let view = viewer.mainViewport.view;
|
|
|
- let radius = boundSize.length() / 2;
|
|
|
- let position = this.shiftTarget.clone().sub(view.direction.clone().multiplyScalar(radius + expand));
|
|
|
+ let view = viewer.mainViewport.view
|
|
|
+ let radius = boundSize.length() / 2
|
|
|
+ let position = this.shiftTarget.clone().sub(view.direction.clone().multiplyScalar(radius + expand))
|
|
|
|
|
|
return position
|
|
|
|
|
|
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
zoomIn(intersectPoint, pointer){
|
|
|
let camera = viewer.mainViewport.camera;
|
|
@@ -119125,12 +119204,14 @@ ENDSEC
|
|
|
let radius = boundSize.length() / 2
|
|
|
return radius + expand
|
|
|
} */
|
|
|
- moveFit(pos, info, duration){
|
|
|
- targetPlane.projectPoint(pos, this.shiftTarget); //target转换到过模型中心的平面,以保证镜头一定在模型外 this.shiftTarget是得到的
|
|
|
- info.endPosition = this.getPosOutOfModel();
|
|
|
- info.margin = {x:200, y:230};
|
|
|
- let view = viewer.mainViewport.view;
|
|
|
- view.moveOrthoCamera(viewer.mainViewport, info , duration );
|
|
|
+ moveFit(pos, info, duration){
|
|
|
+ var margin = {x:200, y:230};
|
|
|
+ this.splitScreenTool.viewportFitBound(viewer.mainViewport, info.bound, pos, duration, margin );
|
|
|
+ /* targetPlane.projectPoint(pos, this.shiftTarget) //target转换到过模型中心的平面,以保证镜头一定在模型外 this.shiftTarget是得到的
|
|
|
+ info.endPosition = this.getPosOutOfModel()
|
|
|
+ info
|
|
|
+ let view = viewer.mainViewport.view
|
|
|
+ view.moveOrthoCamera(viewer.mainViewport, info , duration ) */
|
|
|
|
|
|
}
|
|
|
|
|
@@ -119592,8 +119673,9 @@ ENDSEC
|
|
|
selectPano(pano, informinformBy2d, force){
|
|
|
if(this.selectedPano == pano && !force)return
|
|
|
|
|
|
-
|
|
|
+ let lastSeletedPano = this.selectedPano;
|
|
|
if(this.selectedPano){
|
|
|
+
|
|
|
this.selectedPano.circle.material = circleMats.default;
|
|
|
this.selectedPano.circle.renderOrder = renderOrders.circle;
|
|
|
|
|
@@ -119648,9 +119730,21 @@ ENDSEC
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
- informinformBy2d || this.dispatchEvent({type:'panoSelect', pano });
|
|
|
-
|
|
|
+ if(informinformBy2d){
|
|
|
+ if(this.selectedPano){
|
|
|
+ if(this.activeViewName == 'mainView'){ //平移,focus选中的pano
|
|
|
+ let distance = this.lastDisToPano || 5;
|
|
|
+ if(lastSeletedPano){
|
|
|
+ distance = viewer.mainViewport.camera.position.distanceTo(lastSeletedPano.position);
|
|
|
+ }
|
|
|
+ viewer.focusOnObject({ position:this.selectedPano.position}, 'point', null, {distance });
|
|
|
+ }else {
|
|
|
+ this.moveFit(this.selectedPano.position, {}, 500);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ this.dispatchEvent({type:'panoSelect', pano });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -126481,7 +126575,7 @@ ENDSEC
|
|
|
this.boundBox = new Mesh(new BoxGeometry(1,1,1,1));
|
|
|
this.boundBox.material.wireframe = true;
|
|
|
this.boundBox.up.set(0,0,1);
|
|
|
- this.boundBox.visible = false; //打开以检查box
|
|
|
+ viewer.updateVisible(this.boundBox, 'hidden', false);//打开以检查box
|
|
|
this.setObjectLayers(this.boundBox,'sceneObjects');
|
|
|
this.scene.scene.add(this.boundBox);
|
|
|
}
|
|
@@ -127257,7 +127351,7 @@ ENDSEC
|
|
|
}
|
|
|
*/
|
|
|
|
|
|
- loadModel(fileInfo, done, onProgress_){
|
|
|
+ loadModel(fileInfo, done, onProgress_, onError){
|
|
|
let boundingBox = new Box3();
|
|
|
if(!Potree.settings.boundAddObjs){
|
|
|
boundingBox.min.set(-0.5,-0.5,-0.5); boundingBox.max.set(0.5,0.5,0.5);
|
|
@@ -127348,7 +127442,8 @@ ENDSEC
|
|
|
console.log( item, loaded, total );
|
|
|
}; */
|
|
|
|
|
|
- let onError = function ( xhr ) {};
|
|
|
+ /* let onError = function ( xhr ) {
|
|
|
+ }; */
|
|
|
|
|
|
loaders.mtlLoader.load( fileInfo.mtlurl , (materials)=>{
|
|
|
materials.preload();
|
|
@@ -127356,14 +127451,14 @@ ENDSEC
|
|
|
loaders.objLoader.setMaterials( materials ).load(fileInfo.objurl, (object)=>{
|
|
|
loadDone(object);
|
|
|
});
|
|
|
- } , onProgress, /*onError */ );
|
|
|
+ } , onProgress, onError );
|
|
|
|
|
|
}else if(fileType == 'glb'){
|
|
|
loaders.glbLoader.load(fileInfo.glburl, ( gltf )=>{ //.setPath( Potree.resourcePath + '/models/glb/' );
|
|
|
|
|
|
console.log('loadGLTF', gltf);
|
|
|
loadDone(gltf.scene);
|
|
|
- }, onProgress);
|
|
|
+ }, onProgress, onError);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -128142,24 +128237,29 @@ ENDSEC
|
|
|
|
|
|
|
|
|
|
|
|
- async function loadFile(path, callback){
|
|
|
+ async function loadFile(path, callback, onError){
|
|
|
if(Potree.fileServer){
|
|
|
Potree.fileServer.get(path).then(data=>{
|
|
|
callback && callback(data);
|
|
|
- });
|
|
|
+ }).fail(onError);
|
|
|
}else {
|
|
|
- let response = await fetch(path);
|
|
|
- let text = await response.text();
|
|
|
- var data = JSON.parse(text);
|
|
|
- if(data.data) data = data.data;
|
|
|
- callback && callback(data);
|
|
|
- return data
|
|
|
+ try{
|
|
|
+ let response = await fetch(path);
|
|
|
+ let text = await response.text();
|
|
|
+ var data = JSON.parse(text);
|
|
|
+ if(data.data) data = data.data;
|
|
|
+ callback && callback(data);
|
|
|
+ return data
|
|
|
+ }catch(e){
|
|
|
+ onError && onError(e);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//查询: http://192.168.0.26:8080/doc.html#/default/filter-%E6%BC%AB%E6%B8%B8%E7%82%B9/filterUsingGET
|
|
|
}
|
|
|
|
|
|
- async function loadDatasets(callback,sceneCode){//之后直接把path写进来
|
|
|
+ async function loadDatasets(callback,sceneCode,onError){//之后直接把path写进来
|
|
|
let path;
|
|
|
sceneCode = sceneCode || Potree.settings.number;
|
|
|
if(Potree.fileServer){
|
|
@@ -128172,7 +128272,7 @@ ENDSEC
|
|
|
//path = `${Potree.scriptPath}/data/${sceneCode}/getDataSet.json`
|
|
|
|
|
|
}
|
|
|
- return loadFile(path, callback)
|
|
|
+ return loadFile(path, callback,onError)
|
|
|
|
|
|
}
|
|
|
|
|
@@ -128307,7 +128407,7 @@ ENDSEC
|
|
|
|
|
|
|
|
|
|
|
|
- function loadPointCloud$1(path, name, sceneCode, timeStamp, callback){
|
|
|
+ function loadPointCloud$1(path, name, sceneCode, timeStamp, callback, onError){
|
|
|
let loaded = function(e){
|
|
|
e.pointcloud.name = name;
|
|
|
e.pointcloud.sceneCode = sceneCode; //对应4dkk的场景码
|
|
@@ -128336,6 +128436,7 @@ ENDSEC
|
|
|
if (!geometry) {
|
|
|
//callback({type: 'loading_failed'});
|
|
|
console.error(new Error(`failed to load point cloud from URL: ${path}`));
|
|
|
+ onError && onError();
|
|
|
} else {
|
|
|
let pointcloud = new PointCloudOctree(geometry);
|
|
|
// loaded(pointcloud);
|