1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- //export * from "./Potree_update_visibility.js"; //因加载顺序问题,该文件直接在shim中重写
-
- export * from "./custom/start.js";
-
- export {settings, config} from './custom/settings.js'
- export * from './custom/viewer/map/MapViewer.js'
-
-
-
- export * from "./Actions.js";
- export * from "./Annotation.js";
- export * from "./defines.js";
- export * from "./Enum.js";
- export * from "./EventDispatcher.js";
- export * from "./Features.js";
- export * from "./KeyCodes.js";
- export * from "./LRU.js";
- export * from "./PointCloudEptGeometry.js";
- export * from "./ExtendPointCloudOctree.js";
- export * from "./PointCloudOctreeGeometry.js";
- export * from "./PointCloudTree.js";
- export * from "./Points.js";
- export * from "./PotreeRenderer.js";
- export * from "./ProfileRequest.js";
- export * from "./custom/objects/TextSprite.js";
- export * from "./custom/objects/3dgs/Splat.js";
- export * from "./custom/objects/3dgs/SplatNPY.js";
- export * from "./utils.js";
- export * from "./Version.js";
- export * from "./WorkerPool.js";
- export * from "./XHRFactory.js";
- export * from "./viewer/SaveProject.js";
- export * from "./viewer/LoadProject.js";
- export * from "./materials/ClassificationScheme.js";
- export * from "./materials/EyeDomeLightingMaterial.js";
- export * from "./materials/Gradients.js";
- export * from "./materials/NormalizationEDLMaterial.js";
- export * from "./materials/NormalizationMaterial.js";
- export * from "./materials/ExtendPointCloudMaterial.js";
- export * from "./loader/POCLoaderNew.js";
- export * from "./modules/loader/2.0/OctreeLoader.js";
- export * from "./loader/EptLoader.js";
- export * from "./loader/ept/BinaryLoader.js";
- export * from "./loader/ept/LaszipLoader.js";
- export * from "./loader/ept/ZstandardLoader.js";
- export * from "./loader/PointAttributes.js";
- export * from "./loader/ShapefileLoader.js";
- export * from "./loader/GeoPackageLoader.js";
-
- export * from "./utils/Box3Helper.js";
- export * from "./utils/ClippingTool.js";
- export * from "./utils/ClipVolume.js";
- export * from "./utils/GeoTIFF.js";
-
-
- export * from "./utils/Message.js";
- export * from "./utils/PointCloudSM.js";
- // export * from "./objects/tool/PolygonClipVolume.js";
- // export * from "./objects/tool/Profile.js";
- // export * from "./objects/tool/ProfileTool.js";
- // export * from "./objects/tool/ScreenBoxSelectTool.js";
- // export * from "./objects/tool/SpotLightHelper.js";
- // export * from "./objects/tool/TransformationTool.js";
- // export * from "./objects/tool/Volume.js";
- // export * from "./objects/tool/VolumeTool.js";
- // export * from "./objects/tool/Compass.js";
-
- export * from "./custom/utils/DrawUtil.js";
- export * from "./custom/objects/tool/Measure.js";
- export * from "./custom/objects/tool/Path.js";
- export * from "./custom/objects/tool/MeasuringTool.js";
- export * from "./utils/PolygonClipVolume.js";
- export * from "./utils/Profile.js";
- export * from "./utils/ProfileTool.js";
- export * from "./utils/ScreenBoxSelectTool.js";
- export * from "./utils/SpotLightHelper.js";
- export * from "./utils/TransformationToolNew.js";
- export * from "./utils/VolumeNew.js";
- export * from "./utils/VolumeTool.js";
- //export * from "./custom/viewer/ExtendViewer.js";
- export * from "./custom/viewer/ViewerNew.js";
- export * from "./viewer/ExtendScene.js";
- export * from "./viewer/HierarchicalSlider.js";
- export * from "./modules/OrientedImages/OrientedImages.js";
- export * from "./custom/modules/panos/Images360.js";
- export * from "./custom/modules/CameraAnimation/CameraAnimation.js";
- export * from "./modules/loader/2.0/OctreeLoader.js";
- export {OrbitControls} from "./navigation/OrbitControls.js";
- export {FirstPersonControls} from "./navigation/FirstPersonControls.js";
-
-
-
-
-
- import "./extensions/OrthographicCamera.js";
- import "./extensions/PerspectiveCamera.js";
- import "./extensions/Ray.js";
- import {LRU} from "./LRU.js";
- import {OctreeLoader} from "./modules/loader/2.0/OctreeLoader.js";
- import {POCLoader} from "./loader/POCLoaderNew.js";
- import {EptLoader} from "./loader/EptLoader.js";
- import {ExtendPointCloudOctree} from "./ExtendPointCloudOctree.js";
- import {WorkerPool} from "./WorkerPool.js";
- export const workerPool = new WorkerPool();
- export const version = {
- major: 1,
- minor: 8,
- suffix: '.0'
- };
- export let lru = new LRU();
-
- console.log('Potree ' + version.major + '.' + version.minor + version.suffix);
- export let pointBudget = 1 * 1000 * 1000;
- export let framenumber = 0;
- export let numNodesLoading = 0;
- export let maxNodesLoading = 6//4;
- export const debug = {};
- let scriptPath = "";
- if (document.currentScript && document.currentScript.src) {
- scriptPath = new URL(document.currentScript.src + '/..').href;
- if (scriptPath.slice(-1) === '/') {
- scriptPath = scriptPath.slice(0, -1);
- }
- } else if(import.meta){
- scriptPath = new URL(import.meta.url + "/..").href;
- if (scriptPath.slice(-1) === '/') {
- scriptPath = scriptPath.slice(0, -1);
- }
- }else {
- console.error('Potree was unable to find its script path using document.currentScript. Is Potree included with a script tag? Does your browser support this function?');
- }
- let resourcePath = scriptPath + '/resources';
- // scriptPath: build/potree
- // resourcePath:build/potree/resources
- export {scriptPath, resourcePath};
- //add:
- export async function loadFile(path, params , callback, onError){
- params = params || {}
- let fetchMethod = params.fetchMethod || 'get'
- delete params.fetchMethod
- if(Potree.fileServer){
- Potree.fileServer[fetchMethod](path, { params }).then(data=>{
- if(data.data)data = data.data
- if(data.data)data = data.data //融合页面getdataset需要查找两次data
- callback && callback(data)
- }).catch(onError)
- }else{
- try{
- if(Object.keys(params).length > 0){
- path+='?'
- let index = 0
- for(let i in params){
- if(index>0) path += '&'
- path+=i; path+='='; path+=params[i]
- index ++
- }
- }
- let info={}
- if(fetchMethod == 'post')info.method = 'POST'
-
-
- if(Potree.fileStorage){//本地直接获取
- Potree.fileStorage.get(path).then(data=>{
- if(data.data)data = data.data
- if(data.data)data = data.data //融合页面getdataset需要查找两次data
- callback && callback(data)
- }).catch(onError)
- }else{
- let response = await fetch(path, info);
- if(!response.ok){
- console.log('loadFile失败' , path )
- return onError && onError()
- }
-
- let text = await response.text();
- var data = params.returnText ? text : JSON.parse(text)
- if(data.data) data = data.data
- callback && callback(data)
- return data
- }
- }catch(e){
- console.log('loadFile出错', e)
- onError && onError(e)
- }
-
- }
-
- //查询: http://192.168.0.26:8080/doc.html#/default/filter-%E6%BC%AB%E6%B8%B8%E7%82%B9/filterUsingGET
- }
- export async function loadDatasets(callback,sceneCode,onError,prefix){//之后直接把path写进来
- let path
- sceneCode = sceneCode || Potree.settings.number
- if(Potree.fileServer){
- path = `/laser/dataset/${sceneCode}/getDataSet`
- }else{
-
- //path = `${Potree.settings.urls.prefix2}/indoor/${Potree.settings.number}/api/datasets`
- //现在只能加载得了本地的了
- path = `${prefix || Potree.settings.urls.prefix}/laser/dataset/${sceneCode}/getDataSet`
- //path = `${Potree.scriptPath}/data/${sceneCode}/getDataSet.json`
-
- }
- return loadFile(path, null, callback,onError)
-
- }
- export function loadNeighborFile(){
- if(Potree.config.neighbourPath){
- let path = `${Potree.scriptPath}/${Potree.config.neighbourPath}`
-
- loadFile(path, null, (data)=>{
- Potree.extraNeighbours = data
- for(let datasetid in data){
- let pointcloud = viewer.scene.pointclouds.find(e=>e.dataset_id == datasetid)
-
- let types = ['enable','unable']
- types.forEach(type=>{
- if(!data[datasetid][type])return
- for(let id1 in data[datasetid][type]){
- data[datasetid][type][id1].forEach(id2=>{
- let pano2, sid = id2
- if(!id2.includes('|')){
- sid = datasetid+'|'+id2
- }
- Potree.setExtraNeighbour(datasetid+'|'+id1, sid, type, {dontWrite:true})
- })
- }
- })
- }
- })
- }
- }
- /*
- Potree.setExtraNeighbour('1765955963253690368|90','1768872851646451713|7', 'enable' )
- JSON.stringify(Potree.extraNeighbours)
- */
- export function setExtraNeighbour(sid1,sid2,type, {dontWrite}={}){
- if(!Potree.extraNeighbours)Potree.extraNeighbours = {};
-
-
- (()=>{
- if(!dontWrite){
- if(sid1 > sid2){//顺序固定一下要不然两边都要写
- let temp = sid1 //对调
- sid1 = sid2
- sid2 = temp
- }
-
- let id1 = sid1.split('|')[1], id2, object
- object = Potree.extraNeighbours[sid1.split('|')[0]]
- if(!object) {
- if(type == 'clear')return
- object = Potree.extraNeighbours[sid1.split('|')[0]] = {}
- }
- if(type!='clear'){
- if(!object[type]){
- object[type] = {}
- }
-
- if(!object[type][id1]){
- object[type][id1] = []
- }
- }
-
-
- if(sid1.split('|')[0] == sid2.split('|')[0]){
- id2 = sid2.split('|')[1]
- }else{
- id2 = sid2
- }
-
- let remove = (type_)=>{
- if(object[type_] && object[type_][id1] ){
- let index = object[type_][id1].indexOf(id2)
- index>-1 && object[type_][id1].splice(index,1)
- }
- }
-
- if(type != 'clear'){
- if(!object[type][id1].includes(id2)){
- object[type][id1].push(id2)
- }
- }else{
- remove('unable')
- }
-
- let anotherType = type == 'enable' ? 'unable' : 'enable'
- remove(anotherType)
-
-
- }
- })()
-
- let pano1 = viewer.images360.getPano(sid1,'sid'),
- pano2 = viewer.images360.getPano(sid2,'sid')
-
-
- if(type == 'enable'){
-
- viewer.images360.neighbourMap[pano1.id][pano2.id] = 1 //用0和1 表示是在此被强制修改的
- viewer.images360.neighbourMap[pano2.id][pano1.id] = 1
- pano1.neighbours.push(pano2)
- pano2.neighbours.push(pano1)
-
- }else{
- if(type == 'clear') {
- viewer.images360.neighbourMap[pano1.id][pano2.id] = undefined
- viewer.images360.neighbourMap[pano2.id][pano1.id] = undefined
- }else{
- viewer.images360.neighbourMap[pano1.id][pano2.id] = 0
- viewer.images360.neighbourMap[pano2.id][pano1.id] = 0
- }
- let index = pano1.neighbours.indexOf(pano2)
- index>-1 && pano1.neighbours.splice(index,1)
- index = pano2.neighbours.indexOf(pano1)
- index>-1 && pano2.neighbours.splice(index,1)
-
- }
-
- }
- /* 开启漫游点通行的强制设置: 在浏览器中加入后缀 &neighGui,如 http://127.0.0.1:5002/offline.html?m=1829339452406239232&neighGui#/
- 开启后面板右侧会出现一列按钮。 在需要更改连通性的两个漫游点点击第一个按钮,就能选中点位。然后点击第二个按钮可以强行连接漫游点,使原本无法通行的两个漫游点可以互相通行;
- 类似的,第三个按钮则是强行断开漫游点,使原本可以通行的两个漫游点无法通行。 第四个按钮则用于取消设置。点击第五个按钮可以导出设置好的数据在剪贴板里,直接粘贴到extraNeighbours.js里保存, 该文件在离线包的 www\static\lib\potree里。下次刷新场景设置就生效了。
-
-
- 注意:settings中neighbourPath需要设置才会读取extraNeighbours.js。 如果新的离线包也需要设置的话就先创建一个空的extraNeighbours.js
-
- Enable Roaming Point Passage Forced Settings:
- Add the suffix &neighGui to the URL in the browser, for example:http://127.0.0.1:5002/offline.html?m=1829339452406239232&neighGui#/
- After enabling, a column of buttons will appear on the right side of the backend panel.
- To change the connectivity between two roaming points, click the first button on both points to select them. Then, click the second button to forcibly connect the roaming points, allowing two originally unconnected roaming points to become interconnected.Similarly, the third button forcibly disconnects the roaming points, preventing two originally connected roaming points from being accessible to each other.The fourth button is used to cancel the settings.
- Clicking the fifth button exports the configured data to the clipboard. You can directly paste this data into extraNeighbours.js located in the offline package's www\static\lib\potree directory. The settings will take effect the next time you refresh the scene.
-
-
- */
- export function setNeighborGui(){//&neighGui
- if(!Potree.settings.showNeighSetGui)return
-
-
- let button1 = $('<button style="bottom:70%; background:#fff;">Select current roaming point</button>')
- let button2 = $('<button style="bottom:60%; background:#0F4;">Make the two points absolutely connected</button>')
- let button3 = $('<button style="bottom:50%; background:#766;">Make the two points absolutely disconnected</button>')
- let button4 = $('<button style="bottom:40%; background:#ffffff4d;">Clear the connection state of these two points</button>');
- let button5 = $('<button style="bottom:30%; background:#cacfff;">Copy Connections data </button>');
- ([button1,button2,button3,button4,button5]).forEach(button=>{
- button.css({
- right:'4px','z-index':100, position:'absolute', width:'130px',padding:'4px','border-radius':'6px',color:'#222'
- })
- viewer.renderer.domElement.parentElement.appendChild(button[0])
- })
-
-
-
- const bgColor = {
- normal: {r: 0, g: 0, b: 0, a: 0.4 },
- connected : {r: 0, g: 240, b: 100, a: 0.6 },
- disconnected : {r: 130, g: 120, b: 120, a: 0.6 },
- }
- let createLabel = ()=>{
- let panoLabel = new Potree.TextSprite({
- sizeInfo: {minSize : 40 , maxSize : 150, nearBound : 1, farBound : 50},
- backgroundColor:bgColor.normal,
- textColor:{r: 255, g: 255, b: 255, a: 1 },
- margin:{x:20,y:14},
- fontsize:20,
- borderRadius: 20,
- renderOrder:10,
- depthTest:false,
- text:'default'
- });
- viewer.images360.node.add(panoLabel);
- panoLabel.visible = false
- Potree.Utils.setObjectLayers(panoLabel,'bothMapAndScene')
- return panoLabel
- }
- let panoLabels = [createLabel(), createLabel()]
-
- let panoSelected = []
- let updateButton = ()=>{
- if(panoSelected.length == 2){
- button2.show()
- button3.show()
- button4.show()
- }else{
- button2.hide()
- button3.hide()
- button4.hide()
- }
-
-
- }
-
- let updateLabel = ()=>{
- let i=0
- let connectState
- if(panoSelected.length == 2){
- connectState = viewer.images360.neighbourMap[panoSelected[0].id][panoSelected[1].id]
-
- }
- while(i<2){
- if(panoSelected[i]) {
- panoLabels[i].visible = true
- panoLabels[i].position.copy(panoSelected[i].position)
- panoLabels[i].position.z -= 0.5
-
-
- let text = ['SID of current point:',panoSelected[i].sid]
- if(connectState === 1) {
- text.push('Already absolutely connected to:', panoSelected[(i+1)%2].sid)
- panoLabels[i].setBackgroundColor(bgColor.connected)
- }else if(connectState === 0){
- text.push('Already absolutely disconnected to:', panoSelected[(i+1)%2].sid)
- panoLabels[i].setBackgroundColor(bgColor.disconnected)
- }else{
- panoLabels[i].setBackgroundColor(bgColor.normal)
- }
-
- panoLabels[i].setText(text)
- }else{
- panoLabels[i].visible = false
- }
- i++
- }
- viewer.dispatchEvent('content_changed')
- viewer.mapViewer.dispatchEvent('content_changed')
- }
-
- button1.on('click',(e)=>{
- if(!viewer.images360.isAtPano())return alert('Please walk to the roaming point before clicking')
- if(panoSelected.includes(viewer.images360.currentPano))return
- if(panoSelected.length==2){
- panoSelected.splice(0,1)
- }
- panoSelected.push(viewer.images360.currentPano)
-
- updateLabel()
- updateButton()
- })
- button2.on('click',(e)=>{
- Potree.setExtraNeighbour(panoSelected[0].sid,panoSelected[1].sid,'enable')
- updateLabel()
- })
- button3.on('click',(e)=>{
- Potree.setExtraNeighbour(panoSelected[0].sid,panoSelected[1].sid,'unable')
- updateLabel()
- })
- button4.on('click',(e)=>{
- Potree.setExtraNeighbour(panoSelected[0].sid,panoSelected[1].sid,'clear')
- updateLabel()
- })
- button5.on('click',(e)=>{
- navigator.clipboard.writeText(JSON.stringify(Potree.extraNeighbours||{}))
- })
-
- updateButton()
- updateLabel()
-
- }
- //目前上传平面图后如果不点击保存按钮,数据还是旧的不生效
- export async function loadMapEntity(datasetId, force){
- if(!Potree.settings.floorplanEnable && !force && (Potree.fileServer||Potree.fileStorage) )return /* 等待平面图类型定义好会加载 */
-
-
- let loaded = 0
-
- let needLoads = datasetId == 'all' ? viewer.scene.pointclouds.map(e=>e.dataset_id) : [datasetId]
-
-
- let callback = (dataset_id, floorplanType, data )=>{
-
- if(!data || data.length == 0)return console.log('平面图没有数据', dataset_id, floorplanType )
-
- //要防止旧的比新的先获取到导致覆盖新的,因为两种type随时可能切换
- if(floorplanType != Potree.settings.floorplanType[dataset_id]) return //如果请求的floorplanType不是当前最新的floorplanType就返回
-
- var map = viewer.mapViewer.mapLayer.maps.find(e => e.name == 'floorplan_'+ dataset_id)
- if(map){
- viewer.mapViewer.mapLayer.removeMap(map)
- }
-
- var mapNew = viewer.mapViewer.mapLayer.addMapEntity(data.data || data, dataset_id)
- if(map){
- mapNew.visibleReasons = map.visibleReasons
- mapNew.unvisibleReasons = map.unvisibleReasons
- }
- loaded ++;
- }
-
- needLoads.forEach(dataset_id=>{
- let floorplanType = Potree.settings.floorplanType[dataset_id], prefix = ''
- if(!Potree.fileServer){
- prefix = Potree.settings.urls.prefix
- }
- if(!floorplanType)return
- var path
- /* if(Potree.fileServer){
- path = `/laser/tiledMap/${Potree.settings.number}/tiledMap/${floorplanType}/${dataset_id}`
- }else{
- path = `${Potree.settings.urls.prefix2}/indoor/${Potree.settings.number}/api/tiled_maps`
-
- } */
- path = `${prefix}/laser/tiledMap/${Potree.settings.number}/tiledMap/${floorplanType}/${dataset_id}`
-
- Potree.settings.floorplanRequests[dataset_id] = true //开始加载了
- return loadFile(path, null, callback.bind(this, dataset_id, floorplanType) )
- })
-
-
-
- }
-
- export async function loadPanos(datasetId, callback, number){
- let path
- number = number || Potree.settings.number
- //let query = `?datasetId=${datasetId}` //`?lat=${center.lat}&lon=${center.lon}&radius=200000`
- if(Potree.fileServer && !Potree.settings.mergeType){
- path = `/laser/filter/${number}/query`
- }/* else if(Potree.settings.mergeType2){ //每个场景只加载初始数据集
- path = `${Potree.settings.urls.prefix}/laser/filter/${number}/query`
- } */else{
- path = `${Potree.settings.urls.prefix}/laser/filter/${number}/query`
- }
- return loadFile(path, {datasetId:datasetId}, callback)
-
- }
- export async function loadPanosInfo(callback){
- var path
- if(Potree.fileServer){
-
- }else{
- path = `${Potree.scriptPath}/data/panoEdit/vision_edit.txt`
-
- }
- return loadFile(path, null, callback)
-
- }
- export function load4dkkPanos(sceneCode, model, defaultRotation, done, tileRes){ //加载四维看看的漫游点并转换
- model.is4dkkModel = true
- model.panos = []
- //模拟点云,需要rotX(90)+平移一段才能和四维看看的bound一样
- let rot1M = new THREE.Matrix4().makeRotationFromEuler(defaultRotation)
- let pos1 = new THREE.Vector3
-
- if(model.fileType == '3dTiles'){
- pos1.fromArray(model.runtime.getTileset().tileset.root.boundingVolume.box.slice(0,3))//必须要平移一段才能重合
- pos1.copy(Potree.math.convertVector.ZupToYup(pos1))
- //rot1M.makeRotationX(Math.PI/2);
- }
- let pos1M = new THREE.Matrix4().setPosition(pos1)
- model.posRot1MatrixInvert = new THREE.Matrix4().multiplyMatrices(pos1M, rot1M ).invert();
- model.rot1MatrixInvert = rot1M.clone().invert();
-
- model.transformMatrix = new THREE.Matrix4
- model.rotateMatrix = new THREE.Matrix4
- model.transformInvMatrix = new THREE.Matrix4
- model.rotateInvMatrix = new THREE.Matrix4
-
- model.datasetData = {
- sceneVersion : 'V4' ,
- mapping: model.props.raw.mapping
- }
- model.tileRes = tileRes
- model.bound = new THREE.Box3
-
- let path
- if(sceneCode.includes('/') ){
- path = sceneCode
- }else{
- let prefix = Potree.settings.urls.getPrefix(8,model) || 'https://4dkk.4dage.com'
-
- //path = `${prefix}/swkk/${sceneCode}/wwwroot/scene_view_data/${sceneCode}/images/vision.txt`
- if(Potree.settings.urls.templates.vision){
- path = prefix + Potree.Common.replaceAll(Potree.settings.urls.templates.vision, '{sceneCode}', sceneCode)
- }else{
- path = `${prefix}/scene_view_data/${sceneCode}/images/vision.txt`
- }
- }
- model.sceneCode = sceneCode
-
-
- loadFile(path,{},(data)=>{
-
- let panoData = data.sweepLocations.map(e=>{
- let qua = e.pose.rotation
- return {
- file_id : e.uuid,
- dataset_location : new THREE.Vector3().copy(e.pose.translation).toArray(),
- dataset_floor_location : new THREE.Vector3().copy(e.puck).toArray(),
- dataset_orientation: [qua.w, qua.x, qua.y, qua.z],
-
- }
- })
- viewer.images360.addPanoData(panoData, model)
- viewer.images360.loadDone()
- viewer.scene.add360Images(viewer.images360);
-
- {//neighbourMap全部填满,否则之后会被修改
- data.sweepLocations.forEach(pano1Data=>{
- let pano1 = model.panos.find(e=>e.originID == pano1Data.uuid)
- model.panos.forEach((pano2, i)=>{
- if(pano1 == pano2)return
- let v = pano1Data.visibles.includes(i)
- viewer.images360.neighbourMap[pano1.id][pano2.id] = v
- viewer.images360.neighbourMap[pano2.id][pano1.id] = v
- if(v){
- pano1.neighbours.includes(pano2) || pano1.neighbours.push(pano2)
- pano2.neighbours.includes(pano1) || pano2.neighbours.push(pano1)
- }
- })
- })
- }
-
-
-
- viewer.modules.MergeEditor.modelTransformCallback(model, true) //初始化pano的pose
- done && done()
- })
- /* neighbours: e.visibles3 || e.visibles,
- noBlocks: e.visibles2,
- seeMarkers: e.visibles, */
-
- }
- export async function loadImgVersion( callback){
- if(Potree.settings.isLocal || !Potree.settings.isOfficial){//potree本地请求不到
- return callback({})
- }
-
-
- var path
-
- path = `/laser/init/getSceneNumVersion/${Potree.settings.number}`
-
- return loadFile(path, {fetchMethod:'post'}, callback, callback)
-
- }
- export function setLonlat(lon,lat){
- let locationLonLat = [lon,lat]
- if(window.AMapWith84 && Potree.settings.mapCompany != 'google'){//需要转换为高德的,但该函数不准确,转入后再转出,和原来的有偏差. navvis的我看data中存的globalLocation直接输入到高德地图后的定位和其要展示的定位一致,而我们要转为高德后才一致,猜测是navvis后台转为了高德可用的经纬度。 若不转的话,其他看起来没问题,仅高德地图定位不准确,因其为被加密后的火星坐标系。
- locationLonLat = AMapWith84.wgs84ToAMap({x:lon, y:lat})
- locationLonLat = [locationLonLat.x,locationLonLat.y]
- }
-
-
-
- proj4.defs("LOCAL", "+proj=tmerc +ellps=WGS84 +lon_0=" + locationLonLat[0].toPrecision(15) + " +lat_0=" + locationLonLat[1].toPrecision(15)); //高德坐标系
- proj4.defs("LOCAL_MAP", "+proj=tmerc +ellps=WGS84 +lon_0=" + locationLonLat[0].toPrecision(15) + " +lat_0=" + locationLonLat[1].toPrecision(15)); //地图和本地一样
- proj4.defs("WGS84", "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
-
- let transform1 = proj4("WGS84", "LOCAL"); //这个ok 是展开的平面投影 LOCAL即NAVVIS:TMERC
- let transform2 = proj4("+proj=tmerc +lat_0=0 +lon_0=123 +k=1 +x_0=500000 +y_0=0 +ellps=GRS80 +units=m +no_defs;");
- //注:转入后再转出,和原来的有偏差。如果输入是local坐标,数字越大偏差越大,当百万时就明显了。如果是lonlat,很奇怪经度小于50时就乱了。
- viewer.transform = {
- lonlatToLocal : transform1,
- lonlatTo4550 : transform2 // 转大地坐标EPSG:4550
- }
-
-
- if(window.transform){
- viewer.transform.lonlatToLocal = window.transform.lonlatToLocal
- }
-
-
-
-
-
- Potree.Log(`setLonlat ${lon}, ${lat}`,{font:{color:"#f49",fontSize:13}} )
-
-
- if(window.AMapWith84 && Potree.settings.mapCompany != 'google'){//需要转换, 因本地高德用的lonlat和数据里的84不一样. (google地图在国内也用的高德,国外84)
- let change = (transform)=>{
- let forward = transform.forward
- let inverse = transform.inverse;
-
- transform.forward = function(e, not84){
- let needTran = e.x == void 0
- if(needTran)var a1 = {x:e[0],y:e[1]}
- else var a1 = e
- var a = not84 ? a1 : AMapWith84.wgs84ToAMap(a1)
- if(needTran){
- a = [a.x, a.y]; e[2] != void 0 && (a[2] = e[2])
- }else{
- e.z != void 0 && (a.z = e.z)
- }
- return forward(a)
- }
-
- transform.inverse = function(e, not84){
- let needTran = e.x == void 0
- var a = inverse(e)
- needTran && (a = {x:a[0],y:a[1]})
- a = not84 ? a : AMapWith84.aMapToWgs84(a)
-
- if(needTran){
- a = [a.x,a.y]; e[2] != void 0 && (a[2] = e[2])
- }else{
- e.z != void 0 && (a.z = e.z)
- }
- return a
-
- }
-
- }
- for(let f in viewer.transform){
- change(viewer.transform[f])
- }
- //注意:把几万米转成经纬度再转回来差值会很大
- }
- }
- //site_model
- /* {
- "area": 2503.30551910935,
- "attributes": {},
- "center": [
- 113.59568277455075,
- 22.366566635195288,
- 12.78751625
- ],
- "children": [],
- "geometry_hash": 1891071345,
- "id": 10,
- "name": "港湾一号",
- "parentId": null,
- "polygon": {
- "coordinates": [
- [
- [
- 113.59590810534583,
- 22.36679132753878
- ],
- [
- 113.59590810534583,
- 22.366807172528629
- ],
- [
- 113.59545610274934,
- 22.366807172528629
- ],
- [
- 113.59545610274934,
- 22.36679132753878
- ]
- ]
- ],
- "type": "Polygon"
- },
- "type": "BUILDING",
- "volume": null,
- "z_max": null,
- "z_min": null
- }
- */
- export function Log(){
-
- let args = Array.from(arguments)
- let params = args[args.length-1]
- if(params && params.font) {params = params.font, args.pop()}
- else params = {}
-
- let str = '', color = params.color || '#13f', fontSize = params.fontSize || 12
-
-
- args.forEach((e,i)=>{
- i > 0 && (str += ' , ' )
- /* if(params.toFixed && typeof e == 'number'){
- e = e.toFixed(params.toFixed)
- } */
- if(params.toFixed ){
- e = Potree.math.toPrecision(e, params.toFixed)
- }
- str += e //object可以JSON.stringify,但不是所有都行
- })
-
-
- console.warn(`%c${str}`, `color:${color};font-size:${fontSize}px`)
- }
-
- export function loadPointCloud(path, name, sceneCode, timeStamp, callback, onError){
- let loaded = function(e){
- e.pointcloud.name = name;
- e.pointcloud.sceneCode = sceneCode //对应4dkk的场景码
-
- callback(e);
- };
- let promise = new Promise( resolve => {
- // load pointcloud
- if (!path){
- // TODO: callback? comment? Hello? Bueller? Anyone?
- } else if (path.indexOf('ept.json') > 0) {
- EptLoader.load(path, function(geometry) {
- if (!geometry) {
- console.error(new Error(`failed to load point cloud from URL: ${path}`));
- }
- else {
- let pointcloud = new ExtendPointCloudOctree(geometry);
- //loaded(pointcloud);
- resolve({type: 'pointcloud_loaded', pointcloud: pointcloud});
- }
- });
- } else if (path.indexOf('cloud.js') > 0) {
- POCLoader.load(path, timeStamp, function (geometry) {
- if (!geometry) {
- //callback({type: 'loading_failed'});
- console.error(new Error(`failed to load point cloud from URL: ${path}`));
- onError && onError()
- } else {
- let pointcloud = new ExtendPointCloudOctree(geometry);
- // loaded(pointcloud);
- resolve({type: 'pointcloud_loaded', pointcloud: pointcloud});
- }
- });
- }/* else if (path.indexOf('metadata.json') > 0) { //部分浏览器(如uc)不支持NodeLoader中的1n的大数据写法
- Potree.OctreeLoader.load(path).then(e => {
- let geometry = e.geometry;
- if(!geometry){
- console.error(new Error(`failed to load point cloud from URL: ${path}`));
- }else{
- let pointcloud = new ExtendPointCloudOctree(geometry);
- let aPosition = pointcloud.getAttribute("position");
- let material = pointcloud.material;
- material.elevationRange = [
- aPosition.range[0][2],
- aPosition.range[1][2],
- ];
- // loaded(pointcloud);
- resolve({type: 'pointcloud_loaded', pointcloud: pointcloud});
- }
- });
- OctreeLoader.load(path, function (geometry) {
- if (!geometry) {
- //callback({type: 'loading_failed'});
- console.error(new Error(`failed to load point cloud from URL: ${path}`));
- } else {
- let pointcloud = new ExtendPointCloudOctree(geometry);
- // loaded(pointcloud);
- resolve({type: 'pointcloud_loaded', pointcloud: pointcloud});
- }
- });
- } */else if (path.indexOf('.vpc') > 0) {
- PointCloudArena4DGeometry.load(path, function (geometry) {
- if (!geometry) {
- //callback({type: 'loading_failed'});
- console.error(new Error(`failed to load point cloud from URL: ${path}`));
- } else {
- let pointcloud = new PointCloudArena4D(geometry);
- // loaded(pointcloud);
- resolve({type: 'pointcloud_loaded', pointcloud: pointcloud});
- }
- });
- } else {
- //callback({'type': 'loading_failed'});
- console.error(new Error(`failed to load point cloud from URL: ${path}`));
- }
- });
- if(callback){
- promise.then(pointcloud => {
- loaded(pointcloud);
- });
- }else{
- return promise;
- }
- };
- // add selectgroup
- (function($){
- $.fn.extend({
- selectgroup: function(args = {}){
- let elGroup = $(this);
- let rootID = elGroup.prop("id");
- let groupID = `${rootID}`;
- let groupTitle = (args.title !== undefined) ? args.title : "";
- let elButtons = [];
- elGroup.find("option").each((index, value) => {
- let buttonID = $(value).prop("id");
- let label = $(value).html();
- let optionValue = $(value).prop("value");
- let elButton = $(`
- <span style="flex-grow: 1; display: inherit">
- <label for="${buttonID}" class="ui-button" style="width: 100%; padding: .4em .1em">${label}</label>
- <input type="radio" name="${groupID}" id="${buttonID}" value="${optionValue}" style="display: none"/>
- </span>
- `);
- let elLabel = elButton.find("label");
- let elInput = elButton.find("input");
- elInput.change( () => {
- elGroup.find("label").removeClass("ui-state-active");
- elGroup.find("label").addClass("ui-state-default");
- if(elInput.is(":checked")){
- elLabel.addClass("ui-state-active");
- }else{
- //elLabel.addClass("ui-state-default");
- }
- });
- elButtons.push(elButton);
- });
- let elFieldset = $(`
- <fieldset style="border: none; margin: 0px; padding: 0px">
- <legend>${groupTitle}</legend>
- <span style="display: flex">
- </span>
- </fieldset>
- `);
- let elButtonContainer = elFieldset.find("span");
- for(let elButton of elButtons){
- elButtonContainer.append(elButton);
- }
- elButtonContainer.find("label").each( (index, value) => {
- $(value).css("margin", "0px");
- $(value).css("border-radius", "0px");
- $(value).css("border", "1px solid black");
- $(value).css("border-left", "none");
- });
- elButtonContainer.find("label:first").each( (index, value) => {
- $(value).css("border-radius", "4px 0px 0px 4px");
- });
- elButtonContainer.find("label:last").each( (index, value) => {
- $(value).css("border-radius", "0px 4px 4px 0px");
- $(value).css("border-left", "none");
- });
- elGroup.empty();
- elGroup.append(elFieldset);
- }
- });
- })(jQuery);
- //在这之后export的内容才赋值到Potree中
|