|
@@ -1,5 +1,5 @@
|
|
|
import mitt from 'mitt'
|
|
|
-
|
|
|
+import libTransform from 'coordtransform';
|
|
|
import axios from 'axios' //{ axios } from '@/api'
|
|
|
|
|
|
let requestLoadCount = 0
|
|
@@ -10,12 +10,44 @@ const ModelTypes = {
|
|
|
1 : {name:'看见(双目转台)', panos4dkk:true, rot90:true},
|
|
|
2 : {name:'深时', },
|
|
|
3 : {name:'用户上传三维模型'},
|
|
|
- 4 : {name:'深时mesh(激光转台)',panos4dkk:true, rot90:true},//3dtiles
|
|
|
+ 4 : {name:'深时mesh(激光转台)',panos4dkk:true, rot90:true},//3dtiles or obj
|
|
|
5 : {name:'深光点云' },
|
|
|
6 : {name:'深光mesh',panos4dkk:true, rot90:true},//3dtiles
|
|
|
+ 7 : {name:'圆周率相机' },//圆周率相机场景
|
|
|
}
|
|
|
let cesAspect
|
|
|
|
|
|
+
|
|
|
+/*
|
|
|
+const Id_noIntersect = -100 //path绘制在地图上的点,modelId传这个值,勿更改
|
|
|
+let isValidPoint = (modelId)=>{//所存的modelId没被删或者它本身不在模型上
|
|
|
+ return modelId == Id_noIntersect || viewer.objs.children.concat(viewer.scene.pointclouds).some(e=>e.dataset_id == modelId )
|
|
|
+}
|
|
|
+let curSelectPath */
|
|
|
+
|
|
|
+{
|
|
|
+ // 84坐标转高德 (国外地区用84,所以地理注册时填的是84,我这需要转成高德)
|
|
|
+ const wgs84ToAMap = (pos ) => {
|
|
|
+ const latlng = libTransform.wgs84togcj02(pos.x, pos.y)
|
|
|
+ return {
|
|
|
+ x: latlng[0],
|
|
|
+ y: latlng[1]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 高德坐标转84
|
|
|
+ const aMapToWgs84 = (pos ) => {
|
|
|
+ const latlng = libTransform.gcj02towgs84(pos.x, pos.y)
|
|
|
+ return {
|
|
|
+ x: latlng[0],
|
|
|
+ y: latlng[1]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ window.AMapWith84__ = { //在Potree里setLonlat时不管转不转效果都一样 很奇怪,所以这里改名。只在ces
|
|
|
+ aMapToWgs84, wgs84ToAMap
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
console.warn('新的页面')
|
|
|
Potree.settings.isOfficial = true //标记为正式、非测试版本
|
|
@@ -35,7 +67,9 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
|
|
|
|
|
|
const tagLimitDis = 8;
|
|
|
-
|
|
|
+ /* if(isLocal2){//本地配置
|
|
|
+ Potree.settings.isLocal = Potree.settings.tileOriginUrl = isLocal2
|
|
|
+ } */
|
|
|
Potree.settings.showCompass = true
|
|
|
Potree.settings.compassDom = dom.querySelector('#direction')
|
|
|
Potree.settings.mergeType2 = true //标识新版
|
|
@@ -43,16 +77,16 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
Potree.settings.tiles3DMaxMemory = 300 //稍微增加点
|
|
|
Potree.settings.mergeTransCtlOnClick = true
|
|
|
Potree.settings.canWalkThroughModel = true
|
|
|
-
|
|
|
-
|
|
|
+ window.cesErrorWords = '由于GPU占用过大, 将关闭地图,请更换更好的显卡!'
|
|
|
+ window.cesErrorCallback = ()=>{
|
|
|
+ sdk.setBackdrop('none')
|
|
|
+ }
|
|
|
|
|
|
let { THREE } = Potree.mergeEditStart(dom, mapDom)
|
|
|
let MergeEditor = viewer.modules.MergeEditor
|
|
|
Potree.settings.unableNavigate = true
|
|
|
-
|
|
|
- /* Potree.settings.showCesium = !!lonlat
|
|
|
- Potree.settings.showCesium && buildMap()
|
|
|
- */
|
|
|
+ lonlat && Potree.setLonlat(lonlat[0], lonlat[1])
|
|
|
+
|
|
|
|
|
|
//因为getPose里用的是target,俯视的yaw不准,所以限制一下不要完全俯视
|
|
|
viewer.mainViewport.view.maxPitch-=0.001
|
|
@@ -64,14 +98,14 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
var pos = camera.position
|
|
|
if (e.viewport.name == 'MainView') {
|
|
|
sceneBus.emit('cameraChange', { x: pos.x, y: pos.y, z: pos.z, rotate: camera.rotation })
|
|
|
-
|
|
|
- updateMap()
|
|
|
-
|
|
|
Potree.Common.intervalTool.isWaiting('updateCamNear', ()=>{
|
|
|
updateCamNear()
|
|
|
}, 1000)
|
|
|
-
|
|
|
+ updateCamFar()
|
|
|
}
|
|
|
+ if (e.viewport.name == 'MainView' || e.viewport.name == 'top' ) {
|
|
|
+ updateMap()
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
|
|
@@ -276,15 +310,30 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
//console.log('3d->2d highlight',e.state)
|
|
|
bus.emit('highlight', e.state)
|
|
|
})
|
|
|
- measure.addEventListener('marker_dropped', (e) => {//拖拽结束后发送changeCallBack
|
|
|
+
|
|
|
+ let update = (e)=>{ //拖拽结束后发送changeCallBack
|
|
|
if (measure.parent) {
|
|
|
- //未被删除
|
|
|
- bus.emit('update', [
|
|
|
- measure.dataset_points.map(p => p.clone()),
|
|
|
- measure.points_datasets
|
|
|
- ])
|
|
|
+ //未被删除
|
|
|
+ //console.warn('changePoints', measure.dataset_points.length )
|
|
|
+ /* if(measure.type == 'Path'){
|
|
|
+ bus.emit('changePoints', measure.dataset_points.map((p,i)=>{return {
|
|
|
+ position: (p || measure.points[i]).clone(),
|
|
|
+ modelId: measure.points_datasets[i] == void 0 ? Id_noIntersect : measure.points_datasets[i],
|
|
|
+ name: measure.markerLabels[i].originText
|
|
|
+ }}))
|
|
|
+ }else{ */
|
|
|
+ bus.emit('update', [
|
|
|
+ measure.dataset_points.map(p => p.clone()),
|
|
|
+ measure.points_datasets
|
|
|
+ ])
|
|
|
+ //}
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
+ measure.addEventListener('marker_dropped', update)
|
|
|
+ measure.addEventListener('changed', update)
|
|
|
+ measure.addEventListener('createDone', update)
|
|
|
+ measure.addEventListener('changeByHistory', update);
|
|
|
+
|
|
|
return {
|
|
|
/* quit: () => {
|
|
|
Potree.Log('quit结束且删除: ' + measure.id, '#00c7b2')
|
|
@@ -338,7 +387,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
|
|
|
|
|
|
changeSelect(isHight) {
|
|
|
- console.log('2d->3d isHight ', isHight)
|
|
|
+ //console.log('2d->3d isHight ', isHight)
|
|
|
measure.setSelected(isHight, 'byList')
|
|
|
},
|
|
|
|
|
@@ -353,11 +402,11 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
sceneBus, mapBus,
|
|
|
|
|
|
|
|
|
- canTurnToPanoMode(pos) {
|
|
|
+ canTurnToPanoMode(pos, far=Potree.config.panoFieldRadius) {
|
|
|
pos = pos ? new THREE.Vector3().copy(pos) : viewer.images360.position
|
|
|
|
|
|
let pano = viewer.images360.findNearestPano(pos)
|
|
|
- if (pano && pano.position.distanceTo(pos) < Potree.config.panoFieldRadius * pano.pointcloud.scale.x) {
|
|
|
+ if (pano && pano.position.distanceTo(pos) < far * pano.pointcloud.scale.x) {
|
|
|
return {model:pano.pointcloud.result_}
|
|
|
}
|
|
|
//poschange后会调用这个,如果返回false会变为点云模式,且不会自动变回原先的模式
|
|
@@ -368,7 +417,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
getPositionByScreen(pos2d, hopeModelId) {//通过屏幕坐标获取真实坐标 . hopeModelId: 如果指定了模型,优先返回hopeModelId上的intersect
|
|
|
//console.log('getPositionByScreen',hopeModelId)
|
|
|
hopeModelId = null
|
|
|
- let worldPos, localPos, modelId, intersect
|
|
|
+ let worldPos, localPos, modelId, intersect/* , normal, localNormal */
|
|
|
let Handler = viewer.inputHandler
|
|
|
|
|
|
let reGet = () => {//不使用当前鼠标所在位置的intersect,单独算
|
|
@@ -412,9 +461,11 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
} */
|
|
|
worldPos = intersect.location.clone()
|
|
|
localPos = Potree.Utils.datasetPosTransform({ toDataset: true, datasetId: modelId, position: worldPos })
|
|
|
+ /* normal = intersect.normal
|
|
|
+ localNormal = intersect.localNormal */
|
|
|
} else return null
|
|
|
|
|
|
- return { worldPos, modelId, localPos }
|
|
|
+ return { worldPos, modelId, localPos, /* normal, localNormal */ }
|
|
|
},
|
|
|
|
|
|
|
|
@@ -462,6 +513,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
console.log('bgOpacity', bgOpacity)
|
|
|
|
|
|
Potree.Utils.updateVisible(MergeEditor.boxHelper, 'screenshot', false)
|
|
|
+ Potree.Utils.updateVisible(viewer.scene.overlayScene, 'screenshot', false) //hide all
|
|
|
var { getImagePromise, finishPromise } = viewer.startScreenshot({ type: 'default', /* useRenderTarget:true, */bgOpacity }, width, height)
|
|
|
var deferred = $.Deferred();
|
|
|
finishPromise.done(({ dataUrl }) => {
|
|
@@ -484,6 +536,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
|
|
|
|
|
|
Potree.Utils.updateVisible(MergeEditor.boxHelper, 'screenshot', true)
|
|
|
+ Potree.Utils.updateVisible(viewer.scene.overlayScene, 'screenshot', true)
|
|
|
})
|
|
|
|
|
|
return deferred.promise()
|
|
@@ -528,9 +581,9 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
}else{
|
|
|
console.warn('没有找到漫游点',o)
|
|
|
}
|
|
|
- }else if(requestInPano){
|
|
|
+ }/* else if(requestInPano){
|
|
|
requestInPano.result_.flyOutPano()
|
|
|
- }else{
|
|
|
+ }*/else {
|
|
|
if (o.modelId != void 0) {
|
|
|
['position', 'target'].forEach(e => {
|
|
|
if (o[e]) {
|
|
@@ -540,13 +593,28 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if (o.distance) {
|
|
|
+ if (o.distance || o.maxDis) {
|
|
|
+ //o.isFlyToTag = true
|
|
|
+ let requestShowPano
|
|
|
let position = o.target || o.position
|
|
|
- return viewer.focusOnObject({ position }, 'tag', null, { distance: o.distance }).promise
|
|
|
+ if(o.isFlyToTag){
|
|
|
+ let r = sdk.canTurnToPanoMode(position, 5)//热点新需求:如果附近有漫游点就飞到全景模式
|
|
|
+ if(r){
|
|
|
+ requestShowPano = true
|
|
|
+ }else{
|
|
|
+ Potree.settings.displayMode = 'showPointCloud'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let rusult = viewer.focusOnObject({ position }, 'tag', null, { distance: o.distance || 1, maxDis : o.maxDis, requestShowPano /* , checkIntersect:true */ })
|
|
|
+ rusult.promise.then(()=>{
|
|
|
+ if(o.isFlyToTag){
|
|
|
+ Potree.settings.displayMode = requestShowPano ? 'showPanos' : 'showPointCloud'
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ return rusult.promise
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
viewer.scene.view.setView($.extend({}, o, {
|
|
|
duration: o.dur,
|
|
|
callback: () => {
|
|
@@ -558,7 +626,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
},
|
|
|
|
|
|
|
|
|
- setBackdrop(sky, type, { scale, rotate }) {//天空盒背景
|
|
|
+ setBackdrop(sky, type, { scale, rotate }={}) {//天空盒背景
|
|
|
//console.log('天空盒背景', sky,type)
|
|
|
|
|
|
let setGroundAndText = (color) => {
|
|
@@ -705,24 +773,35 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
|
|
|
|
|
|
addModel(props) {
|
|
|
-
|
|
|
+ let model
|
|
|
let bus = props.bus = mitt()
|
|
|
//console.log('addModel',props)
|
|
|
props.isFirstLoad = isLocal ? props.bottom == void 0 : (props.isDynamicAdded || props.mode == 'single') // 在编辑时用户添加的 或 展示单个模型 (props.mode='single'模型展示页, props.mode='many'融合页)
|
|
|
if (props.opacity == void 0) props.opacity = 1
|
|
|
- if (props.type == 'obj') props.type = 'glb'
|
|
|
- props.scale /= 100
|
|
|
+ //if (props.type == 'obj' ) props.type = 'glb'
|
|
|
+ props.scale /= 100
|
|
|
+
|
|
|
+ let getBaseRotation = () => {
|
|
|
+ if(ModelTypes[props.fromType]?.rot90 && props.type != 'obj'){
|
|
|
+ return new THREE.Euler(Math.PI / 2, 0, 0)
|
|
|
+ } else return new THREE.Euler(0, 0, 0)
|
|
|
+ }
|
|
|
+ let getDefaultRotation = () => {
|
|
|
+ if(model.lonLatRot){
|
|
|
+ return model.lonLatRot
|
|
|
+ }else{
|
|
|
+ return getBaseRotation()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (props.rotation) {
|
|
|
if (props.rotation._x == void 0 && props.rotation.x != void 0) {
|
|
|
props.rotation = new THREE.Euler().setFromVector3(props.rotation)
|
|
|
}
|
|
|
}
|
|
|
- let getDefaultRotation = () => {
|
|
|
- if(ModelTypes[props.fromType]?.rot90 && props.type != 'glb'){
|
|
|
- return new THREE.Euler(Math.PI / 2, 0, 0)
|
|
|
- } else return new THREE.Euler(0, 0, 0)
|
|
|
- }
|
|
|
-
|
|
|
+ props.baseRotation = getBaseRotation()
|
|
|
+ props.is4dkkModel = ModelTypes[props.fromType].panos4dkk
|
|
|
|
|
|
if (!props.isFirstLoad) {
|
|
|
if (autoLoads.length == 0) { //首次加载
|
|
@@ -745,7 +824,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
} else {
|
|
|
readyToAddModel = true
|
|
|
|
|
|
- props.rotation = getDefaultRotation()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -757,7 +836,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
|
|
|
|
|
|
|
|
|
- let model
|
|
|
+
|
|
|
let done = (model_) => {
|
|
|
model = model_
|
|
|
model.result_ = result
|
|
@@ -767,7 +846,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
if (!props.isFirstLoad) {
|
|
|
model.visible = false//先不显示,防止卡顿
|
|
|
}
|
|
|
- model.showInPano = props.raw.showInPano
|
|
|
+ model.showInPano = /* !model.is4dkkModel// */props.raw.showInPano //现在不用这个,所有模型都可见,非is4dkkModel的还显示原本的贴图
|
|
|
props.opacity < 100 && result.changeOpacity(props.opacity)
|
|
|
|
|
|
model.addEventListener('changeSelect', (e) => {
|
|
@@ -807,7 +886,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
}, 1)
|
|
|
}
|
|
|
if(ModelTypes[props.fromType].panos4dkk){
|
|
|
- Potree.load4dkkPanos(props.raw.num, model, getDefaultRotation(), () => {
|
|
|
+ Potree.load4dkkPanos(props.raw.num, model, getBaseRotation(), () => {
|
|
|
bus.emit('loadDone')
|
|
|
}, props.fromType == 0 ? '2k' : '4k' ) //看看场景是2k
|
|
|
} else {
|
|
@@ -890,7 +969,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
}
|
|
|
},
|
|
|
changeSelect(state) {
|
|
|
- console.error('select', state)
|
|
|
+ //console.error('select', state)
|
|
|
if (model) {
|
|
|
let fly = viewer.images360.latestRequestMode != 'showPanos'
|
|
|
MergeEditor.selectModel(model, state, fly, true)
|
|
@@ -924,14 +1003,24 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
model.dispatchEvent('transformChanged') //改了position */
|
|
|
},
|
|
|
changePosition(pos) {//校准取消时执行
|
|
|
- console.log('changePosition', pos.x, pos.y, pos.z)
|
|
|
- model && model.position.copy(pos)
|
|
|
+ //console.log('changePosition', model.name, pos.x, pos.y, pos.z)
|
|
|
+ if(pos.x == 0 && pos.y == 0 && pos.z == 0 && model.lonLatPos ){
|
|
|
+ model && model.position.copy(model.lonLatPos)
|
|
|
+ console.log('changePosition 使用经纬度坐标', model.name )
|
|
|
+ }else{
|
|
|
+ model && model.position.copy(pos)
|
|
|
+ }
|
|
|
model.dispatchEvent({ type: 'position_changed' })
|
|
|
},
|
|
|
changeRotation(rot) {//校准取消时执行
|
|
|
- console.log('changeRotation', rot.x, rot.y, rot.z)
|
|
|
- model && model.rotation.setFromVector3(rot)
|
|
|
- model.dispatchEvent({ type: 'rotation_changed' })
|
|
|
+ //console.log('changeRotation', model.name, rot.x, rot.y, rot.z)
|
|
|
+ /* if(rot.x == 0 && rot.y == 0 && rot.z == 0 && model.lonLatRot ){
|
|
|
+ model && model.rotation.copy(model.lonLatRot)
|
|
|
+ console.log('changePosition 使用经纬度坐标', model.name )
|
|
|
+ }else{ */
|
|
|
+ model && model.rotation.setFromVector3(rot)
|
|
|
+ //}
|
|
|
+ model.dispatchEvent({ type: 'rotation_changed' , by2d:true})
|
|
|
},
|
|
|
|
|
|
enterRotateMode() {
|
|
@@ -976,9 +1065,10 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
|
|
|
result.leaveTransform()
|
|
|
MergeEditor.enterSplit()
|
|
|
-
|
|
|
-
|
|
|
- //console.log('enterAlignment',model.position, model.rotation)
|
|
|
+ if(Potree.settings.showCesium){
|
|
|
+ cesiumViewer.scene.canvas.style.width = '50%'
|
|
|
+ //cesiumViewer.resize()
|
|
|
+ }
|
|
|
let bus = new mitt()
|
|
|
|
|
|
/* MergeEditor.transformControls.attach(model)
|
|
@@ -993,7 +1083,10 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
MergeEditor.leaveSplit()
|
|
|
MergeEditor.transformControls.detach()
|
|
|
MergeEditor.transformControls2.detach()
|
|
|
-
|
|
|
+ if(Potree.settings.showCesium){
|
|
|
+ cesiumViewer.scene.canvas.style.width = ''
|
|
|
+ updateMap()
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
enterScaleSet() {//设置比例
|
|
@@ -1007,14 +1100,21 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
MergeEditor.getAllObjects().forEach(m => {//隐藏其他的模型
|
|
|
if (m != model) Potree.Utils.updateVisible(m, 'enterScaleSet', false)
|
|
|
})
|
|
|
+ result.oldFar = Potree.settings.cameraFar
|
|
|
+ model.enterScaleOldState_ = {
|
|
|
+ //view: viewer.mainViewport.view.clone(),
|
|
|
+ scale: model.scale.x,
|
|
|
+ far: Potree.settings.cameraFar
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
let setScale = () => {
|
|
|
if (length == void 0 || !measureBuilded) return
|
|
|
|
|
|
let vec = new THREE.Vector3().subVectors(viewer.mainViewport.camera.position, scaleMeasure.points[1])
|
|
|
|
|
|
-
|
|
|
- let s = length / (scaleMeasure.points[0].distanceTo(scaleMeasure.points[1]))
|
|
|
+ let dis = scaleMeasure.points[0].distanceTo(scaleMeasure.points[1])
|
|
|
+ let s = length / Math.max(dis,0.00001)
|
|
|
result.changeScale(model.scale.x * s * 100)
|
|
|
/* setTimeout(()=>{
|
|
|
viewer.focusOnObject(scaleMeasure , 'measure', 500)
|
|
@@ -1056,6 +1156,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
//bus.emit('quit') //删除
|
|
|
}
|
|
|
)
|
|
|
+ scaleMeasure.forbitRepeatPoint = true //两个点不能相同,否则长度是0
|
|
|
scaleMeasure.addEventListener('marker_dropped', (e) => {//拖拽结束后发送changeCallBack
|
|
|
if (scaleMeasure.parent) {
|
|
|
//未被删除
|
|
@@ -1079,6 +1180,13 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
MergeEditor.getAllObjects().forEach(m => {//恢复其他的模型
|
|
|
if (m != model) Potree.Utils.updateVisible(m, 'enterScaleSet', true)
|
|
|
})
|
|
|
+
|
|
|
+ setTimeout(()=>{//可能还原了 相机位置移动回去
|
|
|
+ if(model.scale.x == model.enterScaleOldState_.scale){
|
|
|
+ MergeEditor.focusOn(model, 0) //reset orbitcontrol's minRadius //viewer.mainViewport.view.copy(model.enterScaleOldState_.view)
|
|
|
+ //Potree.settings.cameraFar = model.enterScaleOldState_.far
|
|
|
+ }
|
|
|
+ },10)
|
|
|
},
|
|
|
|
|
|
|
|
@@ -1115,10 +1223,10 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
} ) //完成 */
|
|
|
|
|
|
bus.emit('submit')
|
|
|
- bus.emit('update', [
|
|
|
+ /* bus.emit('update', [
|
|
|
measure.dataset_points.map(p => p.clone()),
|
|
|
measure.points_datasets
|
|
|
- ])
|
|
|
+ ]) */
|
|
|
|
|
|
|
|
|
|
|
@@ -1346,6 +1454,44 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
viewer.backgroundOpacity = 0
|
|
|
|
|
|
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI2ZGM2YzY0ZC1kNWE0LTRiYTgtYTkwNS1kYmJiODRjMWUwMmQiLCJpZCI6MjMzMTQ1LCJpYXQiOjE3MjI5OTUwNTB9.niqpkl6xOkQ2KeJjelyDDDydmSGqKXKb5cX2NyxSNAw'
|
|
|
+ class AmapMercatorTilingScheme extends Cesium.WebMercatorTilingScheme {
|
|
|
+ constructor(options) {
|
|
|
+ super(options)
|
|
|
+ let projection = new Cesium.WebMercatorProjection()
|
|
|
+ this._projection.project = function(cartographic, result) {
|
|
|
+ //WGS84转GCJ02坐标
|
|
|
+ /* result = gcoord.transform([
|
|
|
+ Cesium.Math.toDegrees(cartographic.longitude),
|
|
|
+ Cesium.Math.toDegrees(cartographic.latitude)
|
|
|
+ ], gcoord.WGS84, gcoord.GCJ02) */
|
|
|
+
|
|
|
+ result = AMapWith84__.wgs84ToAMap({
|
|
|
+ x: Cesium.Math.toDegrees(cartographic.longitude),
|
|
|
+ y: Cesium.Math.toDegrees(cartographic.latitude)
|
|
|
+ })
|
|
|
+
|
|
|
+ result = projection.project(new Cesium.Cartographic(Cesium.Math.toRadians(result.x),Cesium.Math.toRadians(result.y)))
|
|
|
+ return new Cesium.Cartesian2(result.x,result.y)
|
|
|
+ }
|
|
|
+ this._projection.unproject = function(cartesian, result) {
|
|
|
+ let cartographic = projection.unproject(cartesian)
|
|
|
+ //GCJ02转WGS84坐标
|
|
|
+ /* result = gcoord.transform([
|
|
|
+ Cesium.Math.toDegrees(cartographic.longitude),
|
|
|
+ Cesium.Math.toDegrees(cartographic.latitude)
|
|
|
+ ], gcoord.GCJ02, gcoord.WGS84) */
|
|
|
+
|
|
|
+ result = AMapWith84__.aMapToWgs84({
|
|
|
+ x: Cesium.Math.toDegrees(cartographic.longitude),
|
|
|
+ y: Cesium.Math.toDegrees(cartographic.latitude)
|
|
|
+ })
|
|
|
+
|
|
|
+ return new Cesium.Cartographic(Cesium.Math.toRadians(result.x),Cesium.Math.toRadians(result.y))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }//see : https://blog.csdn.net/hongxianqiang/article/details/140541555 cesium加载高德地图并纠偏
|
|
|
+
|
|
|
+
|
|
|
window.cesiumViewer = new Cesium.Viewer('app', {
|
|
|
useDefaultRenderLoop: true,
|
|
|
requestRenderMode: true, //add 只有需要render时才会render,如tile加载完后、镜头移动后
|
|
@@ -1358,27 +1504,26 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
sceneModePicker: false,
|
|
|
selectionIndicator: false,
|
|
|
timeline: false,
|
|
|
- navigationHelpButton: false,
|
|
|
- //imageryProvider : Cesium.createOpenStreetMapImageryProvider({url : 'https://a.tile.openstreetmap.org/'}),
|
|
|
- imageryProvider: Cesium.UrlTemplateImageryProvider({ //直接用84坐标,不用转高德
|
|
|
-
|
|
|
- //"https://wprd04.is.autonavi.com/appmaptile?lang=zh_cn&style=7&yrs=m&x=${x}&y=${y}&z=${z}" //
|
|
|
-
|
|
|
-
|
|
|
- //url : 'https://webst0{0-7}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}&token=YOUR_API_KEY',
|
|
|
- url: 'https://wprd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}&token=YOUR_API_KEY',
|
|
|
- minimumLevel: 0,
|
|
|
- maximumLevel: 19
|
|
|
- }),
|
|
|
+ navigationHelpButton: false,
|
|
|
+
|
|
|
//高德秘钥版 imageryProvider: new Cesium.AmapImageryProvider({key, mapStyle: 'normal'})
|
|
|
//报错 401 (Unauthorized) 的方法 https://blog.csdn.net/LBY_XK/article/details/121992641
|
|
|
|
|
|
- terrainShadows: Cesium.ShadowMode.DISABLED, //terrain地形
|
|
|
+ //terrainShadows: Cesium.ShadowMode.DISABLED, //terrain地形
|
|
|
});
|
|
|
|
|
|
- //lonlat = [113.595236803415,22.3665168584444]//[113.600356,22.364093]
|
|
|
- Potree.setLonlat(lonlat[0], lonlat[1])
|
|
|
-
|
|
|
+ let satellite = true
|
|
|
+ let gaoDeImageryProvider = /* cesImageryProvider || */new Cesium.UrlTemplateImageryProvider({
|
|
|
+ url: `//wprd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=${satellite?6:7}&x={x}&y={y}&z={z}&token=YOUR_API_KEY`, //style=6是卫星,7是标准
|
|
|
+ minimumLevel: 0,
|
|
|
+ maximumLevel: satellite?18:19,
|
|
|
+ credit: new Cesium.Credit('高德地图'),
|
|
|
+ tilingScheme: new AmapMercatorTilingScheme(), //修改投影,从84->高德
|
|
|
+ crossOrigin: 'anonymous',
|
|
|
+ })
|
|
|
+ cesiumViewer.imageryLayers.removeAll();
|
|
|
+ cesiumViewer.imageryLayers.addImageryProvider(gaoDeImageryProvider);
|
|
|
+
|
|
|
Potree.cesScreenshot = (w,h)=>{
|
|
|
console.log('cesScreenshot',w,h)
|
|
|
cesiumViewer.scene.canvas.style.width = w+'px'
|
|
@@ -1456,63 +1601,112 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes }) => {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function updateMap( ){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ function updateCamFar(){
|
|
|
+ let expand = 1.1 //for label
|
|
|
+ Potree.settings.cameraFar = THREE.Math.clamp((viewer.bound.boundingBox.distanceToPoint(viewer.mainViewport.camera.position)+viewer.bound.boundSize.length() ) * expand , 10000, 100000000000)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function updateMap(){
|
|
|
+
|
|
|
if (Potree.settings.showCesium && Potree.settings.displayMode == 'showPointCloud') {
|
|
|
- let camera = viewer.mainViewport.camera
|
|
|
+ let camera = MergeEditor.split ? viewer.viewports.find(e=>e.name == 'top').camera : viewer.mainViewport.camera
|
|
|
let pPos = new THREE.Vector3(0, 0, 0).applyMatrix4(camera.matrixWorld);
|
|
|
- let pRight = new THREE.Vector3(600, 0, 0).applyMatrix4(camera.matrixWorld);
|
|
|
- let pUp = new THREE.Vector3(0, 600, 0).applyMatrix4(camera.matrixWorld);
|
|
|
- let pTarget = viewer.scene.view.getPivot();
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let orientation
|
|
|
let toCes = (pos) => {
|
|
|
let xy = [pos.x, pos.y];
|
|
|
let height = pos.z;
|
|
|
let deg = viewer.transform.lonlatToLocal.inverse(xy) // toMap.forward(xy);
|
|
|
let cPos = Cesium.Cartesian3.fromDegrees(...deg, height);
|
|
|
-
|
|
|
+ //console.log('toCes',cPos,height) //数字过大如e35会崩溃
|
|
|
return cPos;
|
|
|
};
|
|
|
|
|
|
let cPos = toCes(pPos);
|
|
|
- let cUpTarget = toCes(pUp);
|
|
|
- let cTarget = toCes(pTarget);
|
|
|
-
|
|
|
- let cDir = Cesium.Cartesian3.subtract(cTarget, cPos, new Cesium.Cartesian3());
|
|
|
- let cUp = Cesium.Cartesian3.subtract(cUpTarget, cPos, new Cesium.Cartesian3());
|
|
|
-
|
|
|
- cDir = Cesium.Cartesian3.normalize(cDir, new Cesium.Cartesian3());
|
|
|
- cUp = Cesium.Cartesian3.normalize(cUp, new Cesium.Cartesian3());
|
|
|
-
|
|
|
- cesiumViewer.camera.setView({
|
|
|
- destination: cPos,
|
|
|
- orientation: {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(MergeEditor.split){
|
|
|
+ orientation = {
|
|
|
+ heading: Cesium.Math.toRadians(0.0), // 方向角
|
|
|
+ pitch: Cesium.Math.toRadians(-90.0), // 俯仰角
|
|
|
+ roll: 0.0 // 翻滚角
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!cesiumViewer.camera.perpFrustum_){
|
|
|
+ cesiumViewer.camera.perpFrustum_ = cesiumViewer.camera.frustum
|
|
|
+ cesiumViewer.camera.frustum = new Cesium.OrthographicOffCenterFrustum({//OrthographicFrustum OrthographicOffCenterFrustum
|
|
|
+ left: -10000, // 左边界
|
|
|
+ right: 10000, // 右边界
|
|
|
+ bottom: -10000, // 下边界
|
|
|
+ top: 10000, // 上边界
|
|
|
+ near: 1.0, // 近裁剪面距离
|
|
|
+ far: 100000000.0, // 远裁剪面距离
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ cesiumViewer.camera.frustum.left = camera.left / camera.zoom
|
|
|
+ cesiumViewer.camera.frustum.right = camera.right / camera.zoom
|
|
|
+ cesiumViewer.camera.frustum.top = camera.top / camera.zoom
|
|
|
+ cesiumViewer.camera.frustum.bottom = camera.bottom / camera.zoom
|
|
|
+ }else{
|
|
|
+
|
|
|
+ cesiumViewer.camera.perpFrustum_ && (cesiumViewer.camera.frustum = cesiumViewer.camera.perpFrustum_, cesiumViewer.camera.perpFrustum_ = null) //恢复
|
|
|
+
|
|
|
+ //let pRight = new THREE.Vector3(600, 0, 0).applyMatrix4(camera.matrixWorld);
|
|
|
+ let pUp = new THREE.Vector3(0, 600, 0).applyMatrix4(camera.matrixWorld);
|
|
|
+ let pTarget = viewer.scene.view.getPivot();
|
|
|
+
|
|
|
+ let cUpTarget = toCes(pUp);
|
|
|
+ let cTarget = toCes(pTarget);
|
|
|
+
|
|
|
+ let cDir = Cesium.Cartesian3.subtract(cTarget, cPos, new Cesium.Cartesian3());
|
|
|
+ let cUp = Cesium.Cartesian3.subtract(cUpTarget, cPos, new Cesium.Cartesian3());
|
|
|
+
|
|
|
+ cDir = Cesium.Cartesian3.normalize(cDir, new Cesium.Cartesian3());
|
|
|
+ cUp = Cesium.Cartesian3.normalize(cUp, new Cesium.Cartesian3());
|
|
|
+ //console.log('ces', 'cPos', cPos, 'cDir',cDir, 'cUp', cUp)
|
|
|
+
|
|
|
+
|
|
|
+ orientation = {
|
|
|
direction: cDir,
|
|
|
up: cUp
|
|
|
}
|
|
|
- });
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
- let aspect = cesAspect || viewer.scene.getActiveCamera().aspect;
|
|
|
-
|
|
|
- //console.log('updateMap', aspect)
|
|
|
+ let aspect = cesAspect || camera.aspect;
|
|
|
|
|
|
- if (aspect < 1) {
|
|
|
- let fovy = Math.PI * (viewer.scene.getActiveCamera().fov / 180);
|
|
|
- cesiumViewer.camera.frustum.fov = fovy;
|
|
|
- } else {
|
|
|
- let fovy = Math.PI * (viewer.scene.getActiveCamera().fov / 180);
|
|
|
- let fovx = Math.atan(Math.tan(0.5 * fovy) * aspect) * 2
|
|
|
- cesiumViewer.camera.frustum.fov = fovx;
|
|
|
+ //console.log('updateMap', aspect)
|
|
|
+
|
|
|
+ if (aspect < 1) {
|
|
|
+ let fovy = Math.PI * (viewer.scene.getActiveCamera().fov / 180);
|
|
|
+ cesiumViewer.camera.frustum.fov = fovy;
|
|
|
+ } else {
|
|
|
+ let fovy = Math.PI * (viewer.scene.getActiveCamera().fov / 180);
|
|
|
+ let fovx = Math.atan(Math.tan(0.5 * fovy) * aspect) * 2
|
|
|
+ cesiumViewer.camera.frustum.fov = fovx;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ cesiumViewer.camera.setView({
|
|
|
+ destination: cPos,
|
|
|
+ orientation
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
+
|
|
|
+ cesiumViewer.scene.globe.show = camera.position.z > 0 //在地面之下地球会闪烁,故隐藏
|
|
|
cesiumViewer.render(); //立即render,否则会和点云render不同步而错位
|
|
|
- }
|
|
|
+ }//cesium测试沙盒 https://sandcastle.cesium.com/
|
|
|
}
|
|
|
-
|
|
|
return sdk
|
|
|
}
|
|
|
|