xzw 2 years ago
parent
commit
c4fb9602af
35 changed files with 179 additions and 13486 deletions
  1. 2 12
      src/Potree.js
  2. 0 663
      src/custom/mergeStartTest.js
  3. 0 64
      src/custom/modules/CameraAnimation/CamAniEditor.js
  4. 0 650
      src/custom/modules/CameraAnimation/CameraAnimation.js
  5. 0 248
      src/custom/modules/Particles/ParticleEditor.js
  6. 0 411
      src/custom/modules/datasetAlignment/Alignment.js
  7. 0 708
      src/custom/modules/mergeModel/MergeEditor.js
  8. 0 1411
      src/custom/modules/panoEdit/panoEditor.js
  9. 51 793
      src/custom/modules/panos/Images360.js
  10. 73 363
      src/custom/modules/panos/Panorama.js
  11. 0 1235
      src/custom/modules/panos/tile/PanoRenderer.js
  12. 0 176
      src/custom/modules/panos/tile/QualityManager.js
  13. 0 556
      src/custom/modules/panos/tile/TileDownloader.js
  14. 0 415
      src/custom/modules/panos/tile/TilePrioritizer.js
  15. 0 168
      src/custom/modules/panos/tile/TileTree.js
  16. 0 283
      src/custom/modules/panos/tile/TileUtils.js
  17. 0 643
      src/custom/modules/route/RouteGuider.js
  18. 0 889
      src/custom/modules/siteModel/BuildingBox.js
  19. 0 1325
      src/custom/modules/siteModel/SiteModel.js
  20. 0 36
      src/custom/objects/fireParticle/Tween.js
  21. 0 475
      src/custom/objects/fireParticle/explode/ExplodeParticle.js
  22. 0 57
      src/custom/objects/fireParticle/explode/Particle.js
  23. 0 18
      src/custom/objects/fireParticle/explode/Util.js
  24. 0 4
      src/custom/objects/fireParticle/explode/const.js
  25. 0 40
      src/custom/objects/fireParticle/explode/shader.js
  26. 0 274
      src/custom/objects/fireParticle/fire/FireParticle.js
  27. 0 63
      src/custom/objects/fireParticle/fire/shader.js
  28. 0 57
      src/custom/objects/fireParticle/smoke/Particle.js
  29. 0 594
      src/custom/objects/fireParticle/smoke/SmokeParticle.js
  30. 0 44
      src/custom/objects/fireParticle/smoke/shader.js
  31. 9 9
      src/custom/potree.shim.js
  32. 30 679
      src/custom/start.js
  33. 14 121
      src/custom/viewer/ViewerNew.js
  34. 0 1
      src/viewer/PropertyPanels/PropertiesPanel.js
  35. 0 1
      src/viewer/sidebarNew.js

+ 2 - 12
src/Potree.js

@@ -52,16 +52,7 @@ 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/objects/tool/Measure.js";
 export * from "./custom/objects/tool/MeasuringTool.js";
@@ -79,8 +70,7 @@ 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 "./custom/modules/panos/Images360.js"; 
 
 export * from "./modules/loader/2.0/OctreeLoader.js";
 

+ 0 - 663
src/custom/mergeStartTest.js

@@ -1,663 +0,0 @@
-import * as THREE from "../../libs/three.js/build/three.module.js";
-import {settings, config} from './settings.js' 
-import math from './utils/math.js' 
-import browser from './utils/browser.js' 
-import {Utils} from "./../utils.js"
-import cameraLight from './utils/cameraLight.js' 
-import './three.shim.js'  
-import "./potree.shim.js"
-
- 
-
-
-
-//多元融合模块
-
-
-var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
-    //设置:
-    Potree.settings.editType = 'merge'
-    Potree.settings.sidebar = 'sidebar2.html'
-    Potree.settings.intersectOnObjs = true
-    Potree.settings.boundAddObjs = true
-    Potree.settings.showCompass = true
-    
-    
-    Potree.settings.number = number || 't-o5YMR13'// 't-iksBApb'// 写在viewer前 
-    Potree.fileServer = fileServer  
-    webSite && (Potree.settings.webSite = webSite)
-    
-    
-    let viewer = new Potree.Viewer(dom , mapDom);
-    
-    let Alignment = viewer.modules.Alignment
-       
-	viewer.setEDLEnabled(false);
-    viewer.setFOV(config.view.fov); 
-    viewer.loadSettingsFromURL(); 
-    
-    {
-        
-         
-        
-        viewer.mainViewport.view.position.set(100,100,200)
-        viewer.mainViewport.view.lookAt(0,0,0)
-        
-        viewer.updateModelBound()//init
-        //this.bound = new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1))
-        
-        viewer.transformationTool.setModeEnable('scale',false)
-        viewer.ssaaRenderPass.sampleLevel = 0 //奇怪好像没啥锯齿?  sampleLevel为1 的话,ground就不会
-    }
-    
-     
-    
-    
-    if(!Potree.settings.isOfficial){ 
-        viewer.loadGUI(() => {
-            viewer.setLanguage('en');
-            //$("#menu_appearance").next().show();
-            //$("#menu_tools").next().show();
-            //$("#menu_scene").next().hide();
-            $("#mergeModel").show();
-            viewer.toggleSidebar();
-        });
-        Potree.settings.sizeFitToLevel = true//当type为衰减模式时自动根据level调节大小。每长一级,大小就除以2
-    }
-
-    Potree.loadDatasetsCallback = function(data, ifReload){ 
-        if(!data || data.length == 0)return console.error('getDataSet加载的数据为空')
-           
-        Potree.datasetData = data
-        viewer.transform = null
-        var datasetLength = data.length 
-        var pointcloudLoaded = 0
-        var panosLoaded = 0
-        var pointcloudLoadDone = function(){//点云cloud.js加载完毕后 
-            viewer.updateModelBound()
-            let {boundSize, center} = viewer.bound
-           
-            Potree.Log(`中心点: ${math.toPrecision(center.toArray(),2)}, boundSize: ${math.toPrecision(boundSize.toArray(),2)} ` , null, 12)
-            
-            if(!Potree.settings.isOfficial){
-                Potree.loadMapEntity('all') //加载floorplan 
-            }
-            
-            
-            if(!ifReload){    
-                /* viewer.scene.view.setView({ 
-                    position: center.clone().add(new THREE.Vector3(10,5,10)), 
-                    target: center
-                }) */
-                 
-                viewer.dispatchEvent({type:'loadPointCloudDone'})
-            
-                if(!Potree.settings.UserPointDensity){
-                    Potree.settings.UserPointDensity = 'high'//'middle' 
-                }
-                 
-                Potree.Log('loadPointCloudDone  点云加载完毕', null, 10)  
-            }    
-            
-        }
-        
-        
-        var panosLoadDone = function(){  
-            viewer.images360.loadDone() 
-            viewer.scene.add360Images(viewer.images360); 
-              
-            {//初始位置 
-                var urlFirstView = false
-                var panoId = browser.urlHasValue('pano',true);
-                if(panoId !== ''){
-                    var pos
-                    var pano = viewer.images360.panos.find(e=>e.id==panoId);
-                    if(pano){
-                        viewer.images360.focusPano({
-                            pano,
-                            duration:0, 
-                            callback:()=>{/* Potree.settings.displayMode = 'showPanos' */}
-                        }) 
-                          
-                    }
-                }else{//考虑到多数据集距离很远,或者像隧道那种场景,要使视野范围内一定能看到点云,最好初始点设置在漫游点上
-                    
-                    let {boundSize, center} = viewer.bound 
-                    //let pano = viewer.images360.findNearestPano(center) 
-                    
-                } 
-            }
-             
-            
-            console.log('allLoaded')
-            viewer.dispatchEvent('allLoaded')
-        }
-        
-        var transformPointcloud = (pointcloud, dataset)=>{
-            var locationLonLat = dataset.location.slice(0,2)
-            //当只有一个dataset时,无论如何transform 点云和漫游点都能对应上。
-            var location = viewer.transform.lonlatToLocal.forward(locationLonLat)  //transform.inverse()
-            //初始化位置 
-            
-            viewer.sidebar && viewer.sidebar.addAlignmentButton(pointcloud)  
-            Alignment.rotate(pointcloud, null, dataset.orientation)   
-            Alignment.translate(pointcloud, new THREE.Vector3(location[0], location[1], dataset.location[2])) 
-            
-            pointcloud.updateMatrixWorld() 
-            Potree.Log(`点云${pointcloud.dataset_id}旋转值:${pointcloud.orientationUser}, 位置${math.toPrecision(pointcloud.translateUser.toArray(),3)}, 经纬度 ${locationLonLat}, spacing ${pointcloud.material.spacing}`, null, 17 )
-             
-        }
-        
-        if(!Potree.settings.originDatasetId)Potree.settings.originDatasetId = data[0].id
-        var originDataset =  data.find(e=>e.id == Potree.settings.originDatasetId)  
-        
-        {//拿初始数据集作为基准。它的位置是000
-            var locationLonLat = originDataset.location.slice(0,2)
-            proj4.defs("NAVVIS:TMERC", "+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", "NAVVIS:TMERC"); //这个ok  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;");
-            
-            
-            viewer.transform = {
-                lonlatToLocal : transform1,
-                lonlatTo4550 : transform2       // 转大地坐标EPSG:4550  
-            } 
-            
-            viewer.mapViewer && viewer.mapViewer.mapLayer.maps[0].updateProjection()
-            
-        }  
-          
-        
-        data.forEach((dataset,index)=>{  
-            if(!ifReload){
-                var datasetCode = dataset.sceneCode || dataset.name //对应4dkk的场景码
-                var cloudPath = `${Potree.settings.urls.prefix1}/${Potree.settings.webSite}/${datasetCode}/data/${datasetCode}/webcloud/cloud.js` 
-                var timeStamp = dataset.createTime ? dataset.createTime.replace(/[^0-9]/ig,'') : '';  //每重算一次后缀随createTime更新一次 
-                //console.warn(dataset.name, 'timeStamp', timeStamp)
-                Potree.loadPointCloud(cloudPath, dataset.name ,datasetCode, timeStamp, e => {
-                    let scene = viewer.scene;
-                    let pointcloud = e.pointcloud; 
-                    let config = Potree.config.material
-                    let material = pointcloud.material; 
-                    
-                    material.minSize =  config.minSize
-                    material.maxSize =  config.maxSize   
-                    material.pointSizeType = config.pointSizeType //Potree.PointSizeType[config.pointSizeType]//Potree.PointSizeType.ADAPTIVE;//FIXED
-                    pointcloud.changePointSize(config.realPointSize)  //material.size =  config.pointSize;
-                    pointcloud.changePointOpacity(1)
-                    material.shape = Potree.PointShape.SQUARE; 
-                    pointcloud.color = pointcloud.material.color = dataset.color  
-                    pointcloud.dataset_id = dataset.id;//供漫游点找到属于的dataset点云
-                    pointcloud.timeStamp = timeStamp 
-                    transformPointcloud(pointcloud,dataset)
-                    scene.addPointCloud(pointcloud);
-                    pointcloudLoaded ++;
-                    if(pointcloudLoaded == datasetLength)pointcloudLoadDone()
-                        
-                    Potree.loadPanos(dataset.id, (data) => { 
-                        //console.log('loadPanos',dataset.sceneCode, dataset.id, data)
-                        viewer.images360.addPanoData(data, dataset.id )
-                        panosLoaded ++; 
-                        if(panosLoaded == datasetLength){
-                            panosLoadDone() 
-                        } 
-                    })
-                })
-            }else{
-                let pointcloud = viewer.scene.pointclouds.find(p => p.dataset_id == dataset.id)
-                if(!pointcloud){
-                    Potree.Log('数据集id变了,自动使用第一个','#500')
-                    pointcloud = viewer.scene.pointclouds[0]
-                }
-                //先归零 
-                Alignment.translate(pointcloud,  pointcloud.translateUser.clone().negate())
-                Alignment.rotate(pointcloud, null,  - pointcloud.orientationUser)
-                
-                transformPointcloud(pointcloud, dataset)
-                 
-            } 
-                
-        }) 
-        
-    } 
-    
-    let setMatrix = (pointcloud)=>{//为了漫游点变换,要算一下 类似setMatrix
-        pointcloud.updateMatrixWorld()       
-        /* pointcloud.transformMatrix = new THREE.Matrix4().multiplyMatrices(pointcloud.matrix, pointcloud.pos1MatrixInvert)//还原一点位移
-        pointcloud.transformInvMatrix.copy(pointcloud.transformMatrix).invert()
-        
-        pointcloud.rotateMatrix = new THREE.Matrix4().makeRotationFromEuler(pointcloud.rotation);
-        pointcloud.rotateInvMatrix.copy(pointcloud.rotateMatrix).invert()
-        pointcloud.panos.forEach(e=>e.transformByPointcloud())   */
-        pointcloud.updateBound()
-        pointcloud.getPanosBound()  
-        viewer.updateModelBound()
-    } 
-
-    let moveModel = (e)=>{//根据鼠标移动的位置改变位置
-          
-        let camera = viewer.mainViewport.camera
-        var origin = new THREE.Vector3(e.pointer.x, e.pointer.y, -1).unproject(camera),
-        end = new THREE.Vector3(e.pointer.x, e.pointer.y, 1).unproject(camera)
-        var dir = end.sub(origin)
-        let planeZ = 0;
-        let r = (planeZ - origin.z)/dir.z
-        let x = r * dir.x + origin.x
-        let y = r * dir.y + origin.y
-        
-        
-        
-        /* if(modelType == 'laser'){ 
-            // modelEditing.translateUser.copy(pos)
-            //Alignment.setMatrix(modelEditing)   
-            let pos = new THREE.Vector3(x,y,  planeZ  )
-        
-            modelEditing.position.copy(modelEditing.initialPosition).add(pos) 
-            
-        }else{ 
-            let pos = new THREE.Vector3(x,y, modelEditing.position.z )
-                
-            modelEditing.position.copy(pos)
-             
-        } */
-        
-        MergeEditor.moveBoundCenterTo(modelEditing,new THREE.Vector3(x,y, modelEditing.boundCenter.z))  //使模型中心的xy在鼠标所在位置
-        
-        
-        modelEditing.dispatchEvent("position_changed")
-         
-    }
-    let cancelMove = ()=>{ 
-        modelEditing = null
-        viewer.removeEventListener('global_mousemove', moveModel); 
-        viewer.removeEventListener('global_click', confirmPos); 
-    }
-    let confirmPos = ()=>{ 
-        focusOnSelect(modelEditing)
-        cancelMove()  
-        return {stopContinue:true}
-    }
-    
-    
-    let 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
-        }
-        
-        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
-         
-    }
-    viewer.setControls(viewer.orbitControls) 
-    let modelType,  modelEditing, MergeEditor = viewer.modules.MergeEditor
-    Potree.addModel = function(name, done){ 
-        
-        let isFirstLoad = true
-        cancelMove()
-        modelType = name
-        
-        let loadDone = (model)=>{ 
-            if(isFirstLoad){
-                modelEditing = model;
-                MergeEditor.setModelBtmHeight(model, 0) //默认离地高度为0
-                viewer.addEventListener('global_mousemove', moveModel); 
-                viewer.addEventListener('global_click', confirmPos, 3);
-            }else{
-                modelEditing = null
-            }
-            {//transform
-                let updateBound = ()=>{ 
-                    model.updateMatrixWorld()
-                    viewer.updateModelBound() 
-                }  
-                let maintainBtmZAndCenter = ()=>{
-                    MergeEditor.maintainBoundXY(model)
-                    MergeEditor.setModelBtmHeight(model) 
-                    updateBound()
-                    model.dispatchEvent('transformChanged') 
-                }
-                model.addEventListener('position_changed', ()=>{
-                    updateBound()
-                    MergeEditor.getBoundCenter(model);//更新boundcenter
-                    MergeEditor.computeBtmHeight(model)
-                    model.dispatchEvent('transformChanged') 
-                }) 
-                model.addEventListener("rotation_changed", maintainBtmZAndCenter )
-                model.addEventListener("scale_changed", maintainBtmZAndCenter )
-                model.addEventListener('transformChanged', ()=>{
-                    MergeEditor.modelTransformCallback(model)
-                })
-            
-            }
-            model.updateMatrixWorld()
-            viewer.updateModelBound()
-            model.lastMatrixWorld = model.matrixWorld.clone();
-            MergeEditor.getBoundCenter(model) //初始化
-            
-            
-            
-            model.addEventListener('changeSelect',(e)=>{
-                 e.selected ? MergeEditor.transformControls.attach(model) : MergeEditor.transformControls.detach()
-                //viewer.transformObject(e.selected ? model : null);
-            }) 
-
-            
-            
-            
-            
-            done(model)
-        }
-        
-        
-        
-        if(name == 'laser'){
-            Potree.loadDatasets(Potree.loadDatasetsCallback) 
-            viewer.addEventListener('allLoaded',()=>{
-                let pointcloud = modelEditing = viewer.scene.pointclouds[0]; 
-                pointcloud.matrixAutoUpdate  = true
-                pointcloud.initialPosition = pointcloud.position.clone()
-                
-                 
-                
-                /* pointcloud.addEventListener('select',(e)=>{
-                    if(Potree.settings.displayMode == 'showPanos')return
-                    console.log('select',e) 
-                    //viewer.setControls(viewer.orbitControls) 
-                    focusOnSelect(pointcloud) 
-                    
-                    viewer.outlinePass.selectedObjects = [pointcloud]
-                    return {stopContinue:true}
-                },1)
-                pointcloud.addEventListener('deselect',(e)=>{
-                    console.log('deselect',e) 
-                    //viewer.setControls(viewer.fpControls)  
-                    viewer.outlinePass.selectedObjects = []
-                }) */
-                loadDone(pointcloud)
-            })
-        }else{
-            
-            let callback = (object)=>{
-                //focusOnSelect(object, 1000) 
-                object.traverse(e=>e.material && (e.material.transparent = true))
-                object.isModel = true
-                object.dataset_id = Date.now() //暂时
-                /* object.addEventListener('select',(e)=>{
-                    if(Potree.settings.displayMode == 'showPanos')return
-                    console.log('select',e) 
-                    viewer.setControls(viewer.orbitControls) 
-                    focusOnSelect(object) 
-                    
-                    viewer.outlinePass.selectedObjects = [object]
-                    return {stopContinue:true}
-                },1)
-                object.addEventListener('deselect',(e)=>{
-                    console.log('deselect',e) 
-                    viewer.setControls(viewer.fpControls)  
-                    viewer.outlinePass.selectedObjects = []
-                }) */
-                
-                /* object.addEventListener('click',(e)=>{
-                    //只是为了能得到hoverElement识别才加这个侦听
-                }) */
-                
-                
-                
-                $('#log').text('')  
-
-                  
-                loadDone(object)
-                
-            }
-            let onprogress = (num)=>{
-                $('#log').text("已加载 " + Math.round(num) +" %")
-            }
-            
-            
-            if(name == '4dkk'){ 
-                let num = 't-yAWONOn'
-                var path = `${Potree.scriptPath}/data/4dkk/${num}/` 
-                
-                viewer.loadModel({
-                    name, 
-                    objurl: path+'mesh.obj',    //0.6s
-                    mtlurl: path+'mesh.mtl',
-                    unlit:true,
-                    transform :{ 
-                        rotation : [0,  0,   0],
-                        position : [0,0,0]  
-                    } 
-                },callback,onprogress)
-            }else if(name == 'obj'){
-                /* var path = `${Potree.resourcePath}/models/13/`       
-                viewer.loadModel({
-                    name, 
-                    objurl: path+'w13.OBJ',
-                    mtlurl: path+'w13.mtl',  
-                    transform : { 
-                        rotation : [Math.PI/2,  0,   0],
-                        position : [0,0,0]  
-                    }  
-                },callback,onprogress)  */  
-                    
-                var path = `${Potree.resourcePath}/models/obj/28M/`
-                viewer.loadModel({
-                    name, 
-                    objurl: path+'GW1H.obj',  //解析时间4.392s
-                    mtlurl: path+'GW1H.mtl',    
-                    transform : { 
-                        rotation : [0,  0,   0],
-                        position : [0,0,0]  
-                    }  
-                },callback,onprogress)   
-                
-                /* var path = `${Potree.resourcePath}/models/obj/75M/`
-                viewer.loadModel({
-                    name, 
-                    objurl: path+'Tile_+070_+051.obj',  //解析时间4.945s
-                    mtlurl: path+'Tile_+070_+051.mtl',    
-                    transform : { 
-                        rotation : [0,  0,   0],
-                        position : [0,0,0]  
-                    }  
-                },callback,onprogress) */
-                
-                 
-                
-                
-                
-                /* var path = `${Potree.resourcePath}/models/obj/496M/`
-                viewer.loadModel({
-                    name, 
-                    objurl: path+'Model.obj',  //解析时间25.629 s  期间弹出崩溃提示。很卡 
-                    mtlurl: path+'Model.mtl',     
-                    transform : { 
-                        rotation : [0,  0,   0],
-                        position : [0,0,0]  
-                    }  
-                },callback,onprogress) */
-                
-            }else if(name == 'glb'){
-                
-                let angle = 0
-                let fileName = '87b3a367bc3e4273832cb4fa398782e5.glb'    
-                
-                
-                /* let angle = Math.PI/2
-                let fileName = 'coffeemat.glb',  //0.3s */
-                 
-                  
-                /* let angle =  Math.PI/2
-                let fileName = 'ModernJPHouseSofa44216499.glb' // 21M 
-                   */
-                
-                 
-                /* let angle = 0
-                let fileName = 'cloud_glb_47_loadErrored.glb' //176M  */
-                  
-               
-                
-                var path = `${Potree.resourcePath}/models/glb/` 
-                viewer.loadModel({ 
-                    fileType:'glb',
-                    name, 
-                    url: path+fileName,
-                    transform : { 
-                        rotation : [angle,  0,   0],
-                        position : [0,0,0]  
-                    } 
-                },callback,onprogress)
-                  
-                 
-            }else if(name == '3dTiles'){
-                 
-                viewer.loadModel({ 
-                    fileType:'3dTiles',
-                     url: 'https://4dkk.4dage.com/fusion/test/b3dm/tileset.json',
-                    transform : { 
-                        rotation : [Math.PI/2,  0,   0],
-                        position : [0,0,0]  
-                    }          
-       
-                    /* url: 'https://testgis.4dage.com/LVBADUI_qp/tileset.json',
-                    transform : { 
-                        rotation : [ 0,  0,   0],
-                        position : [0,0,0]   
-                    }  */  
-                    
-                    
-                },callback,onprogress)
-            }
-             
-        }  
-    }
-    
-    let getModelByName = (name)=>{
-        if(name == 'laser'){
-            return viewer.scene.pointclouds[0]
-        }else{
-            return viewer.objs.children.find(e=>e.name == name)
-        }    
-    }
-    
-    Potree.removeModel = function(name){
-        let model = getModelByName(name)
-        if(name == 'laser'){ 
-            viewer.scene.removePointCloud(model);
-            viewer.updateModelBound() 
-        }else{  
-            viewer.removeObj(model) 
-        }
-        cancelMove()
-    }
-     
-    
-    /* Potree.selectModel = function(name){
-        let model = getModelByName(name) 
-        model && viewer.transformObject(model)
-    } */
-    
-    //Potree.loadDatasets(Potree.loadDatasetsCallback) 
-     
-     
-   
-     
-    viewer.inputHandler.addEventListener('keydown', (e)=>{
-        if(e.event.key == "e" ){ 
-           MergeEditor.transformControls.mode = 'rotate'
-        }else if(e.event.key == "w"){
-            MergeEditor.transformControls.mode = 'translate'
-        }
-    })
-     
- 
-
-    window.THREE = THREE
-    window.buttonFunction = function(){ 
-        viewer.scene.pointclouds.forEach(e=>e.predictNodeMaxLevel())
-              
-    }
-}
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
- 
-/* var changeLog = ()=>{ //如果移动端加了test反而出不来bug的话,用这个
-        
-    
-        var textarea = document.createElement('textarea');
-          textarea.id = "consoleLog";
-          
-          textarea.style.width = '160px';
-          textarea.style.height =  '200px'
-          textarea.style.position = 'fixed'
-          textarea.style.right = 0
-          textarea.style.bottom = '0'
-          textarea.style['z-index'] = 9999;
-          textarea.style.color = 'black';
-          textarea.style.opacity = 0.9;
-          textarea.style['font-size'] = '12px';
-          textarea.style['backgroundColor'] = '#ffffff'
-         
-          
-
-          document.getElementsByTagName("body")[0].appendChild(textarea);
-          var list = ["log", "error", "warn", "debug", "info", "time", "timeEnd"]
-          var exchange = function (o) {
-            console["old" + o] = console[o];
-            console[o] = function () {
-              var args =   Array.from(arguments)
-              console["old" + o].apply(this, arguments)
-              var t = document.getElementById("consoleLog").innerHTML;
-              
-              var str = ''
-              args.forEach(a=>{
-                  str += a + ' '
-              })
-              document.getElementById("consoleLog").innerHTML = str + "\n\n" + t;
-            }
-          }
-
-          for (var i = 0; i < list.length; i++) {
-            exchange(list[i])
-          } 
-   
-    
-    
-}
- 
-changeLog() */
- //可以直接用edlShader来渲染obj的outline,但不能渲染被遮挡的部分 
- 
- 
- 
-export {start}
-
-
- 

+ 0 - 64
src/custom/modules/CameraAnimation/CamAniEditor.js

@@ -1,64 +0,0 @@
-import * as THREE from "../../../../libs/three.js/build/three.module.js"; 
-import {CameraAnimation} from './CameraAnimation.js'
-
-
-
-let CamAniEditor = {
-    
-    
-     
-    
-    createAnimation(data){
-        let animation = new CameraAnimation(viewer);
-        if(data) { 
-            animation.name = data.name;
-            animation.duration = data.duration;
-            animation.useDurSlice = data.useDurSlice
-             
-            for(const cpdata of data.points){ 
-                /* const position = Potree.Utils.datasetPosTransform({ fromDataset: true, position: cpdata.position, datasetId: Potree.settings.originDatasetId })
-                const target = Potree.Utils.datasetPosTransform({ fromDataset: true, position: cpdata.target, datasetId: Potree.settings.originDatasetId })
-                 */
-                const position = new THREE.Vector3().copy(cpdata.position)
-                const target = new THREE.Vector3().copy(cpdata.target)  
-                const duration = cpdata.time
-                const cp = animation.createControlPoint(null, {position, target, duration}); 
-            }
-        }
-        
-        animation.changeCallback()
-        viewer.scene.addCameraAnimation(animation);
-         
-        return animation
-        
-    },
-    
-    
-    removeAnimation(animation){
-        animation.dispatchEvent('dispose')
-        viewer.scene.removeCameraAnimation(animation)
-    }
-    
-    
-    
-     
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-    
-}
-
-
-export default CamAniEditor

+ 0 - 650
src/custom/modules/CameraAnimation/CameraAnimation.js

@@ -1,650 +0,0 @@
-
-import * as THREE from "../../../../libs/three.js/build/three.module.js"; 
-import { Utils } from "../../../utils.js";
-import math  from "../../utils/math.js";
-import {LineDraw} from "../../utils/DrawUtil.js"; 
-import CurveCtrl from  "../../objects/tool/CurveCtrl.js";
-import HandleSvg from  "../../objects/tool/HandleSvg.js";
-import {/* transitions,*/ easing,  lerp} from '../../utils/transitions.js'
- 
-const colors = {
-    position: 'red', 
-    target : 'blue'
-}
- 
-
-let lineMats 
-const getLineMat = function(name){
-    if(!lineMats){
-        lineMats = {
-            position: LineDraw.createFatLineMat({
-                color: colors.position,  
-                lineWidth: 3   
-            }),
-            target : LineDraw.createFatLineMat({
-                color: colors.target,  
-                lineWidth: 3  
-            }),
-            frustum:  LineDraw.createFatLineMat({
-                color: colors.position,  
-                lineWidth: 2   
-            }),
-            aimAtTarget: new THREE.LineBasicMaterial({color:colors.target, depthTest:false})
-        }
-    }
-    return lineMats[name]
-}
-
- 
-
-
-export class CameraAnimation extends THREE.EventDispatcher{
-
-	constructor(viewer){
-		super();
-		
-		this.viewer = viewer;
-
-		this.selectedElement = null;
-
-		//this.controlPoints = [];
-
-		this.uuid = THREE.Math.generateUUID();
-
-		this.node = new THREE.Object3D();
-		this.node.name = "camera animation";
-		this.viewer.scene.scene.add(this.node);
-
-		this.frustum = this.createFrustum();
-		this.node.add(this.frustum);
-       
-
-		this.name = "Camera Animation";
-		
-		// "centripetal", "chordal", "catmullrom"
-		this.curveType = "centripetal" 
-		this.visible = true;
-
-        this.targets = [];  
-		this.createPath();
-        this.duration = 5; 
-		this.percent = 0;
-        this.currentIndex = 0
-        this.durations = []
-        this.quaternions = [];
-        
-        if(!Potree.settings.isTest && Potree.settings.isOfficial ){
-            this.setVisible(false)
-        }
-        
-        
-        
-        this.addEventListener('dispose', ()=>{  
-            this.dispose()
-        })
-        
-        
-        this.targetLines = new THREE.Object3D
-        this.node.add(this.targetLines)
-        
-        
-        
-        
-        
-	}
-
-	static defaultFromView(viewer){
-		const animation = new CameraAnimation(viewer);
-
-		const camera = viewer.scene.getActiveCamera();
-		const target = viewer.scene.view.getPivot();
-
-		const cpCenter = new THREE.Vector3(
-			0.3 * camera.position.x + 0.7 * target.x,
-			0.3 * camera.position.y + 0.7 * target.y,
-			0.3 * camera.position.z + 0.7 * target.z,
-		);
-
-		const targetCenter = new THREE.Vector3(
-			0.05 * camera.position.x + 0.95 * target.x,
-			0.05 * camera.position.y + 0.95 * target.y,
-			0.05 * camera.position.z + 0.95 * target.z,
-		);
-
-		const r = 2//camera.position.distanceTo(target) * 0.3;
-
-		//const dir = target.clone().sub(camera.position).normalize();
-		const angle = Utils.computeAzimuth(camera.position, target);
-
-		const n = 5;
-		for(let i = 0; i < n; i++){
-			let u = 1.5 * Math.PI * (i / n) + angle;
-
-			const dx = r * Math.cos(u);
-			const dy = r * Math.sin(u);
-
-			const cpPos = new THREE.Vector3(
-				cpCenter.x + dx,
-				cpCenter.y + dy,
-				cpCenter.z,
-			)
-
-			const targetPos = new THREE.Vector3(
-				targetCenter.x + dx * 0.1,
-				targetCenter.y + dy * 0.1,
-				targetCenter.z,
-            )
-
-			animation.createControlPoint(null,{position:cpPos, target:targetPos});
-			 
-             
-		}
-
-        animation.changeCallback()
-		return animation;
-	}
-
-	 
-
-	createControlPoint(index, posInfo ){ 
-        const length = this.posCurve.points.length
-        const position = new THREE.Vector3
-        const target = new THREE.Vector3
-        
-		if(index == void 0 ){
-			index = length;
-		}
-        
-        if(!posInfo){
-        
-            if(length >= 2 && index === 0){ 
-                const dir = new THREE.Vector3().subVectors(this.posCurve.points[0], this.posCurve.points[1] ) 
-                position.copy(this.posCurve.points[0]).add(dir);
-                
-                const tDir = new THREE.Vector3().subVectors(this.targets[0].position, this.targets[1].position ) 
-                target.copy(this.targets[0].position).add(dir);
-                 
-            }else if(length >= 2 && index === length){ 
-                const dir = new THREE.Vector3().subVectors(this.posCurve.points[length-1], this.posCurve.points[length-2] ) 
-                position.copy(this.posCurve.points[length-2]).add(dir);
-                 
-                const tDir = new THREE.Vector3().subVectors(this.targets[length-1].position, this.targets[length-2].position ) 
-                target.copy(this.targets[length-2].position).add(dir);
-                 
-            }else if(length >= 2){ 
-                position.copy(this.posCurve.points[index-1].clone().add(this.posCurve.points[index]).multiplyScalar(0.5));
-                target.copy(this.targets[index-1].position.clone().add(this.targets[index]).multiplyScalar(0.5));
-            }
-        }else{
-            position.copy(posInfo.position)
-            target.copy(posInfo.target)
-             
-        }
-            
-        this.posCurve.addPoint(position, index/* , true */)
-        //this.targetCurve.addPoint(target, index/* , true */) 
-        let targetSvg = new HandleSvg(target, colors.target)
-        targetSvg.visible = this.visible 
-        this.targets = [...this.targets.slice(0,index), targetSvg, ...this.targets.slice(index,length)]
-        if(this.useDurSlice){//不使用全局的duration,而是分段的
-            this.durations = [...this.durations.slice(0,index), posInfo.duration, ...this.durations.slice(index,length)]
-        }
-        
-        
-		this.dispatchEvent({
-			type: "controlpoint_added", 
-            index
-		});
-        
-        {
-            let targetLine = LineDraw.createLine([position,target] ,{mat: getLineMat('aimAtTarget')})
-            this.targetLines.children = [...this.targetLines.children.slice(0,index), targetLine, ...this.targetLines.children.slice(index,length)]
-            
-            
-            
-            this.targets[index].addEventListener('dragged', (e)=>{ 
-                this.updatePathCallback()
-                this.dragPointCallback(e)
-            })
-        } 
-	}
-
-	 
-    dragPointCallback(e){
-        
-        let index = e.index
-        if(e.index == void 0){
-            index = this.targets.indexOf(e.target)
-        }
-        LineDraw.moveLine(this.targetLines.children[index], [this.posCurve.points[index], this.targets[index].position] )
-         
-        this.updateFrustum()
-    } 
-     
-    updatePathCallback(){
-        {
-            this.quaternions = [];
-            let length = this.posCurve.points.length;
-            for(let i=0; i<length; i++){
-                let quaternion = math.getQuaFromPosAim(this.posCurve.points[i], this.targets[i].position) 
-                this.quaternions.push( quaternion) 
-            }
-        }
-        this.reMapCurvePercent()
-    } 
-     
-     
-    removeControlPoint(index){
-        this.posCurve.removePoint(index)
-        //this.targetCurve.removePoint(index)
-        this.targets[index].dispose();
-        this.targets.splice(index, 1)
-         
-        this.dispatchEvent({
-			type: "controlpoint_removed",
-			index
-		});
-        this.targetLines.remove(this.targetLines.children[index])
-        if(this.useDurSlice){
-            this.durations.splice(index, 1)
-        }
-        
-    }
-
-
-
-	createPath(){
-        this.posCurve = new CurveCtrl([],getLineMat('position'), colors.position, 'posCurve'); 
-        //this.targetCurve = new CurveCtrl([], getLineMat('target'), colors.target, 'targetCurve', {noLine:true}); 
-        this.posCurve.needsPercent = true
-        this.node.add(this.posCurve)
-        //this.node.add(this.targetCurve)
-        
-        this.posCurve.addEventListener('dragCurvePoint', this.dragPointCallback.bind(this))
-        this.posCurve.addEventListener('updatePath', this.updatePathCallback.bind(this))
-            
-         
-        
-        
-	}
-
-
-     
-
-	createFrustum(){
-
-		const f = 0.3;
-
-		const positions = [
-			new THREE.Vector3( 0,  0,  0),
-			new THREE.Vector3(-f, -f, +1),
-
-			new THREE.Vector3( 0,  0,  0),
-			new THREE.Vector3( f, -f, +1),
-
-			new THREE.Vector3( 0,  0,  0),
-			new THREE.Vector3( f,  f, +1),
-
-			new THREE.Vector3( 0,  0,  0),
-			new THREE.Vector3(-f,  f, +1),
-
-			new THREE.Vector3(-f, -f, +1),
-			new THREE.Vector3( f, -f, +1),
-
-			new THREE.Vector3( f, -f, +1),
-			new THREE.Vector3( f,  f, +1),
-
-			new THREE.Vector3( f,  f, +1),
-			new THREE.Vector3(-f,  f, +1),
-
-			new THREE.Vector3(-f,  f, +1),
-			new THREE.Vector3(-f, -f, +1),
-		]
-        
-        positions.forEach(e=>e.z *= -1)  //因为得到的rotation是camera的,作用在物体上要反向,所以这里反向一下
-        
-		//geometry.computeBoundingSphere();//? 
-		const line = LineDraw.createFatLine( positions, {material:getLineMat('frustum')})
-         
-        //line.scale.set(20, 20, 20); 
-        line.visible = false
-		return line;
-	}
-
-
-    reMapCurvePercent(){  //因在不同点在相同位置旋转,由于间隔仅和位置距离相关,导致时间间隔为0,采取重新调整间隔的策略。
-        var length = this.posCurve.points.length
-        
-        if(length<2){
-            return this.newPointsPercents = []
-        }
-        var newPercents = [0];
-        
-        
-        
-        if(this.useDurSlice){ //已经设定好了每一段的duration的话
-            let sums = [0]
-            let sum = 0, last
-            for(let i=0;i<length-1;i++){ //去掉最后一个duration,因为已到终点
-                let duration = this.durations[i];
-                sum += duration;   
-                last = duration;
-                sums.push(sum) 
-            }
-            for(let i=1;i<length;i++){ 
-                newPercents.push(sum == 0 ? i/length : sums[i] / sum)
-            } 
-             
-        }else{
-            
-            const maxSpaceDur = this.duration / length  //每两点之间修改间隔时间后,最大时间
-            const durPerRad = 0.8     //每弧度应该占用的时间
-            const minSpaceDur =  Math.min(0.8, maxSpaceDur)//每两点之间修改间隔时间后,最小时间
-            const maxAngleSpaceDur = THREE.Math.clamp(durPerRad * Math.PI, minSpaceDur, maxSpaceDur )// 最大可能差距是180度
-            
-            
-            
-            var percents = this.posCurve.pointsPercent; 
-            
-            
-            
-            for(let i=1;i<length;i++){
-                let diff = (percents[i] - percents[i-1]) * this.duration  //间隔时间
-                let percent 
-                let curMin = minSpaceDur
-                if(diff < maxAngleSpaceDur){ //若小于最大旋转时间
-                    let rad = this.quaternions[i].angleTo(this.quaternions[i-1]) 
-                    curMin = THREE.Math.clamp(rad * durPerRad, minSpaceDur, maxSpaceDur)
-     
-                }  
-
-                diff = Math.max(diff, curMin) 
-                percent = newPercents[i-1] + (diff / this.duration) //得到新的percent
-                
-                
-                newPercents.push(percent) 
-            }
-            
-            let maxPercent = newPercents[length-1]  //最后一个,若扩充过时间,就会>1
-
-
-            if( !math.closeTo(maxPercent, 1)){
-                let scale = 1 / maxPercent //需要压缩的比例 <1  这一步会让实际得到的间隔更小 
-                newPercents = newPercents.map(e=> e*=scale ) 
-            }
-                
-            
-        }
-        
-        this.newPointsPercents = newPercents;
-        //console.log(newPercents)
-    }
-
-
-	at(originPercent, delta, transitionRatio){
-		 
-        originPercent = THREE.Math.clamp(originPercent, 0, 1)
-        //修改第一层:起始时间
-        let percent = originPercent;
-        /* const easePercent = 0.3; //缓动占比  //如果能在所有从静止到运动的中间加缓动就好了呀:lastPos * 0.9 + currentPos *  0.1 ?
-        if(originPercent < easePercent){
-            console.log('easeIn')
-            percent = easing.easeInSine(originPercent, 0, easePercent, easePercent) //currentTime, startY, wholeY, duration   选了一个衔接时接近斜率1的缓动函数
-        }else if(originPercent > 1-easePercent){ 
-            console.log('easeOut')
-            percent = easing.easeOutSine(originPercent-(1-easePercent), 1-easePercent, easePercent, easePercent)
-        } */
-        
-        
-		
-	 
-        let quaternion
-        
-        if(percent < 1){
-            //修改第二层:使用每个点的重定位的 newPointsPercents
-            
-            this.currentIndex = this.newPointsPercents.findIndex(e=> e>percent ) - 1   
-            //假设每个节点的百分比是精确的,那么:
-            let curIndexPercent = this.newPointsPercents[this.currentIndex];
-            let nextIndexPercent = this.newPointsPercents[this.currentIndex+1];
-            let progress = (percent - curIndexPercent) / (nextIndexPercent - curIndexPercent)//在这两个节点间的百分比
-            
-            //投影到原本的 posCurve.pointsPercent上:
-            let curIndexOriPercent = this.posCurve.pointsPercent[this.currentIndex] 
-            let nextIndexOriPercent = this.posCurve.pointsPercent[this.currentIndex+1] 
-            percent = curIndexOriPercent + (nextIndexOriPercent - curIndexOriPercent) * progress
-            
-            let endQuaternion = this.quaternions[this.currentIndex+1]
-            let startQuaternion = this.quaternions[this.currentIndex]       
-            quaternion = (new THREE.Quaternion()).copy(startQuaternion) 
-            lerp.quaternion(quaternion, endQuaternion)(progress) 
-            
-            
-        }else{
-             
-            
-            this.currentIndex = this.posCurve.points.length - 1;
-            
-            quaternion = math.getQuaFromPosAim(this.posCurve.points[this.currentIndex], this.targets[this.currentIndex].position)
-        }
-        
-        
-        const position = this.posCurve.getPointAt(percent); // 需要this.posCurve.points.length>1 否则报错
-        
-        
-        //console.log(this.currentIndex, originPercent)
-        //缓动:
-        var aimQua, aimPos;
-        if(delta != void 0 ){
-            if(Potree.settings.tourTestCameraMove){
-                aimQua = this.frustum.quaternion.clone();
-                aimPos = this.frustum.position.clone();
-            }else{
-                var camera = viewer.scene.getActiveCamera();
-                aimQua = camera.quaternion.clone();
-                aimPos = camera.position.clone();
-            }
-            
-            transitionRatio = transitionRatio || 1 / Potree.settings.cameraAniSmoothRatio//渐变系数,越小缓动程度越高,越平滑
-            transitionRatio *= delta * 60 //假设标准帧率为60fps,当帧率低时(delta大时)要降低缓动
-            //console.log(transitionRatio, delta) //画面ui变化会使delta变大
-            transitionRatio = THREE.Math.clamp(transitionRatio, 0, 1);
-            lerp.quaternion(aimQua, quaternion)(transitionRatio) //每次只改变一点点  
-            lerp.vector(aimPos, position)(transitionRatio)
-  
-        }else{
-            aimQua = quaternion;  aimPos = position
-        }
-        
-        
-        
-        let rotation = new THREE.Euler().setFromQuaternion(aimQua )
-  
- 
-        const frame = {
-			position: aimPos,  
-            rotation
-		};
-
-
-		return frame;
-	}
-
-	set(percent){
-		this.percent = percent;
-	}
-
-	 
-
-	setVisible(visible){
-		this.node.visible = visible;
- 
-        this.posCurve.visible = visible
-        this.targets.forEach(e=>e.visible = visible ) 
-
-		this.visible = visible;
-	}
-
-	setDuration(duration){
-        if(duration != this.duration){
-            this.duration = duration;
-            if(this.quaternions.length == this.posCurve.points.length)this.reMapCurvePercent()
-            
-        } 
-	}
-
-	getDuration(duration){
-		return this.duration;
-	}
-
-	play(startOptions={}){
-        if(this.onUpdate){
-            return console.error('已经开始播放')
-        }
-       
-        
-        
-        let startPercent = 0, currentIndex = 0  
-        if(startOptions.percent != void 0 ){
-            startPercent = startOptions.percent
-        }else if(startOptions.index){
-            currentIndex = index
-            //startPercent = index/(this.posCurve.points.length-1)
-            
-            startPercent = this.posCurve.pointsPercent[index]
-        }
-        
-        
-		//const tStart = performance.now();
-        
-        
-
-
-		const duration = this.duration;
-
-		this.originalyVisible = this.visible;
-		Potree.settings.tourTestCameraMove || this.setVisible(false);
-        
-        
-        let tStart, startTransitionRatio = 0.2
-        let startDelay = 1/startTransitionRatio / 20 ;//因为缓动所以延迟开始,前面前都是at(0),使过渡到开始点位(但是依旧不能准确停在起始点,因为缓动是乘百分比有残留。所以直接平滑衔接到开始后的位置)
-        let hasPlayedTime = 0
-        
-        let finishDelay = Potree.settings.cameraAniSmoothRatio / 60 * 3//结束后还需要多久时间才能大致达到缓动的最终目标
-        let hasStoppedTime = 0
-
-		this.onUpdate = (e) => {
-            if(this.posCurve.points.length<2){
-                if(this.posCurve.points.length == 1){
-                    viewer.scene.view.position.copy(this.posCurve.points[0]);
-                    viewer.scene.view.rotation = new THREE.Euler().setFromQuaternion(this.quaternions[0])
-                }
-                this.pause()
-                return 
-            }
-             
-            let percent, transitionRatio
-            
-            if(tStart){ 
-                let tNow = performance.now(); 
-                let elapsed = (tNow - tStart) / 1000;
-                percent = elapsed / duration + startPercent;
-            }else{//从当前位置过渡到开始位置 
-                percent = 0
-                hasPlayedTime += e.delta
-                transitionRatio = startTransitionRatio;
-                //console.log('延迟开始') 
-                if(hasPlayedTime > startDelay){
-                    tStart = performance.now(); 
-                }
-                
-            }
-             
-			this.set(percent);
-             
-			const frame = this.at(percent, e.delta, transitionRatio);
-            
-            if(currentIndex != this.currentIndex){
-                currentIndex = this.currentIndex
-                console.log('updateCurrentIndex', currentIndex)
-                this.dispatchEvent({type:'updateCurrentIndex', currentIndex  })
-            }
-            
-            
-            
-            if(!Potree.settings.tourTestCameraMove){
-                viewer.scene.view.position.copy(frame.position);
-                //viewer.scene.view.lookAt(frame.target);
-                viewer.scene.view.rotation = frame.rotation; 
-            }
-
-            this.updateFrustum(frame)
-
-            
-            
-            
-			if(percent >= 1){ 
-                if(hasStoppedTime > finishDelay){
-                    this.pause()
-                }else{ 
-                    hasStoppedTime += e.delta
-                    //console.log('延迟结束') 
-                }
-                
-			}
-             
-            
-            
-		};
-
-		this.viewer.addEventListener("update", this.onUpdate);
-         
-         
-	}
-
-    pause(){ 
-        this.setVisible(this.originalyVisible); 
-        this.viewer.removeEventListener("update", this.onUpdate);
-        this.dispatchEvent('playDone')
-        this.onUpdate = null
-    }
-
-
-
-    updateFrustum(frame){  
-        const frustum = this.frustum;
-        if(this.posCurve.points.length>1){
-            frustum.visible = true
-        }else{
-            frustum.visible = false;
-            return
-        }
-        
-        frame = frame || this.at(this.percent);
-        frustum.position.copy(frame.position);
-        //frustum.lookAt(...frame.target.toArray());
-        frustum.rotation.copy(frame.rotation)
-    }
-
-    changeCallback(){
-        this.posCurve.update()
-        //this.targetCurve.update()
-        this.targets.forEach(e=>e.update()) 
-        this.updateFrustum()
-    }
-
-    dispose(){//add
-        this.posCurve.dispose()
-        //this.targetCurve.dispatchEvent({type:'dispose'}) 
-        this.targets.forEach(e=>e.dispose())
-        this.durations = []
-        this.node.parent.remove(this.node);
-    }
-}
-
-
-//scene.removeCameraAnimation
-
-
-//修改:不使用targetCurve作为target曲线,因为播放时posCuve的节点和targetCurve并没有对应,且使用target的曲线会使角度变化大的情况过渡生硬。
-// 改完旋转了。但是位置也有问题。速度完全和路程相关,当在同一位置设置多点时,这段的总时长为0. (是否要设置最小时长?不过也做不到 - -)

+ 0 - 248
src/custom/modules/Particles/ParticleEditor.js

@@ -1,248 +0,0 @@
-
-import * as THREE from "../../../../libs/three.js/build/three.module.js";
-import FireParticle from '../../objects/fireParticle/fire/FireParticle.js'
-import SmokeParticle from '../../objects/fireParticle/smoke/SmokeParticle.js'
-import ExplodeParticle from '../../objects/fireParticle/explode/ExplodeParticle.js'
-import CurveCtrl from '../../objects/tool/CurveCtrl.js'
-import {LineDraw} from "../../utils/DrawUtil.js";
-import Common from '../../utils/Common.js' 
-import DepthBasicMaterial from "../../materials/DepthBasicMaterial.js";
-
-
-
-const colors = {
-    'fire+smoke':0xffffff,
-    'smoke': 0xffffff,
-    'explode':0xffffff,
-}
-
-
-let depthMatPrefix = {
-    clipDistance : 100, occlusionDistance:60, /* 变为backColor距离 */ 
-    maxClipFactor:0.5, backColor:"#777"  ,
-    useDepth:true, transparent: !0,
-}
-let lineMats; 
-let getLineMat = function(type){
-    if(!lineMats){
-        lineMats = {
-            'fire+smoke':LineDraw.createFatLineMat($.extend(depthMatPrefix,{  
-                color: colors['fire+smoke'],  
-                lineWidth: 2 
-            })),
-            'smoke' :LineDraw.createFatLineMat($.extend(depthMatPrefix,{  
-                color: colors['smoke'],  
-                lineWidth: 2   
-            })),
-            'explode' :LineDraw.createFatLineMat($.extend(depthMatPrefix,{  
-                color: colors['explode'],  
-                lineWidth: 2 
-            })),           
-        }        
-    }
-    return lineMats[type]
-}
-
-let handleMats
-let getHandleMat = function(type){ 
-    if(!handleMats){
-        let texLoader = new THREE.TextureLoader()
-        
-        handleMats = {   
-            "fire+smoke" :   new DepthBasicMaterial($.extend(depthMatPrefix,{  
-                map: texLoader.load(Potree.resourcePath+'/textures/icon-fire.png' ), 
-                color:  colors['fire+smoke'],                
-            })),
-            "smoke" :   new DepthBasicMaterial($.extend(depthMatPrefix,{     
-                map: texLoader.load(Potree.resourcePath+'/textures/icon-smoke.png' ),  
-                color:  colors['smoke'],              
-            })),
-            "explode" :   new DepthBasicMaterial($.extend(depthMatPrefix,{   
-                map: texLoader.load(Potree.resourcePath+'/textures/icon-explode.png' ), 
-                color:  colors['explode'],      
-            })), 
-        } 
-    }
-    return handleMats[type]
-}
-
-let ParticleEditor = {
-    
-    bus: new THREE.EventDispatcher,
-    particleGroup : new THREE.Object3D ,
-    curveGroup:new THREE.Object3D ,
-    init:function(){
-        this.particleGroup.name = 'particles'
-        viewer.scene.scene.add( this.particleGroup );
-        
-        
-        this.curveGroup.name = 'particles-curves'
-        viewer.scene.scene.add( this.curveGroup );
-        
-        
-    },
-    addParticle : function(prop={}){
-        
-         
-        let particle
-        if(prop.type == 'fire'){ 
-            particle = new FireParticle(prop) 
-            
-        }else if(prop.type == 'smoke'){
-            particle = new SmokeParticle(prop) 
-            
-        }else if(prop.type == 'explode'){
-            particle = new ExplodeParticle(prop) 
-        }
-        
-        this.particleGroup.add(particle)
-         
-        
-        
-        return particle
-    }
-    ,
-    removeParticle(particle){
-        //particle.dispatchEvent('delete')
-        particle.dispose();
-        this.particleGroup.remove(particle)
-        particle.curve.dispose()
-    }
-    ,
-    update(delta){
-        this.particleGroup.children.forEach(e=>e.update(delta))
-    }
-    ,
-    
-    startInsertion(type = 'fire', prop={}){  //viewer.modules.ParticleEditor.startInsertion()
-        let deferred = $.Deferred();
-        let particles = [];
-        
-        let finish = (ifDone)=>{ 
-            if(ifDone){
-                deferred.resolve(particles) 
-            }
-            viewer.dispatchEvent({
-                type : "CursorChange", action : "remove",  name:"addSth"
-            }); 
-            viewer.removeEventListener('global_click', click) 
-            this.bus.removeEventListener('cancel_insertions',cancel)
-        }
-        
-        let curve = new CurveCtrl([], getLineMat(type), colors[type], type+'_curve', {handleMat:getHandleMat(type)} )
-        this.curveGroup.add(curve)
-        prop.curve = curve
-        prop.type = type 
-        //console.log('创建curve',type,curve.uuid)
-        
-        let cancel = ()=>{
-            console.log('cancel_insertions', curve.uuid )
-            curve.dispose();
-            finish(false)
-        }
-        this.bus.dispatchEvent('cancel_insertions')//删除旧的
-        this.bus.addEventListener('cancel_insertions',cancel)
-        
-        var click = (e)=>{  
-            if(e.button === THREE.MOUSE.RIGHT){  
-                if(curve.points.length>=1){ //if(type.includes('fire') || type.includes('smoke')  ){ 
-                      
-                    particles = this.createFromData(prop) 
-                    finish(true)                        
-                } 
-                return  
-            }
-            
-             
-            var I = e.intersect && (e.intersect.orthoIntersect || e.intersect.location)
-            if(!I)return
-            
-            curve.addPoint(I, null, true) 
-            
-            if(type == 'explode'){ 
-                particles = this.createFromData(prop)   
-                
-                finish(true)
-            }
-            
-            return {stopContinue:true}//防止继续执行别的侦听,如flytopano
-        }
-     
-        
-        viewer.addEventListener('global_click', click, {importance:10})//add  importance
-        viewer.dispatchEvent({
-            type : "CursorChange", action : "add",  name:"addSth"
-        });
-        
-        return deferred.promise()
-    },
-    
-    
-    
-    createFromData(prop){
-        const type = prop.type;
-        var particles = []
-        let curve = prop.curve;
-        if(!curve){
-            curve = new CurveCtrl(prop.points, getLineMat(type), colors[type], type+'_curve', {handleMat:getHandleMat(type)} )
-            this.curveGroup.add(curve)
-        }
-        
-        if(type.includes('fire') || type.includes('smoke')  ){
-            if(type.includes('fire')){
-                var fire = this.addParticle({
-                    type : 'fire',
-                    positions : curve.points,
-                    curve,
-                    radius : prop.radius,
-                    height: prop.height,
-                    strength : prop.strength,
-                })
-                particles.push(fire)
-            }
-            if(type.includes('smoke')){ 
-                var smoke = this.addParticle({
-                    type : 'smoke', 
-                    positions : curve.points,
-                    curve,
-                    positionStyle : 'sphere' , 
-                    strength : prop.smokeStrength,
-                    radius: prop.smokeRadius,
-                    height: prop.smokeHeight,
-                })
-                particles.push(smoke)
-            }
-             
-            
-        }else if(type == 'explode'){
-            var explode = this.addParticle({
-                type : 'explode', 
-                position : curve.points[0],
-                strength: prop.strength,
-                radius : prop.radius,
-                particleSpaceTime: prop.particleSpaceTime,
-                curve,
-                delayStartTime:prop.delayStartTime,
-            })
-            particles.push(explode)
-        }    
-
-      
-        curve.addEventListener('dragCurvePoint',()=>{  
-            Common.intervalTool.isWaiting('particlePointChange', ()=>{ //延时update,防止卡顿   
-                particles.forEach(e=>e.updateGeometry())  
-                geoNeedsUpdate = false 
-                curve.dispatchEvent('sendUpdatePoints') 
-            }, 400)  
-        })
-        
-        
-        
-        
-        return particles
-    }
-}
-
-
-
-export default ParticleEditor

+ 0 - 411
src/custom/modules/datasetAlignment/Alignment.js

@@ -1,411 +0,0 @@
-
-import * as THREE from "../../../../libs/three.js/build/three.module.js";
-import SplitScreen4Views from "../../utils/SplitScreen4Views.js"
-import math from "../../utils/math.js"
-import History from "../../utils/History.js"
-
-var Alignment = {
-    SplitScreen: SplitScreen4Views, 
-    handleState:null,  //操作状态 'translate'|'rotate'
-    bus: new THREE.EventDispatcher(), 
-    
-    history : new History({ 
-        applyData: (data)=>{    
-            data.forEach(item=>{
-                Alignment.applyTemp(item)  
-            }) 
-        },
-        getData:(pointclouds)=>{ 
-            return Alignment.getTemp(pointclouds)
-        } 
-    }),
-
-    /* prepareRecord : true, 
-    
-      writeToHistory(pointclouds){ 
-        if(!this.prepareRecord)return;
-        this.prepareRecord = false
-        
-        let content = this.getTemp(pointclouds)
-        this.history.writeIn(content)
-    },
-    
-    
-    undo(){//撤销一步 
-        let last = this.history.pop();
-        last && last.forEach(item=>{
-            this.applyTemp(item)  
-        })
-        
-    },  */ 
-    
-    applyTemp(item){ 
-        var pointcloud = viewer.scene.pointclouds.find(p=>p.dataset_id+p.name == item.sid)
-            pointcloud.orientationUser = item.orientationUser
-            pointcloud.translateUser = item.translateUser
-            this.setMatrix( pointcloud )
-    },
-    getTemp(pointclouds){//记录最近一次保存后的状态,便于恢复
-        pointclouds = pointclouds || viewer.scene.pointclouds
-        return pointclouds.map(e=>{
-            return {
-                sid : e.dataset_id+e.name,
-                orientationUser : e.orientationUser,
-                translateUser : e.translateUser.clone(),
-            }
-        } )
-    },
-    
-    
-    
-    init:function(){ 
-        let transfromInfo   
-        
-        viewer.fpControls.addEventListener("transformPointcloud",(e)=>{ 
-            if(e.pointclouds[0].dataset_id == Potree.settings.originDatasetId){//禁止手动移动初始数据集
-                return this.bus.dispatchEvent('forbitMoveOriginDataset') 
-            }
-            
-                             
-            this.history.beforeChange(e.pointclouds)    
-            //this.writeToHistory( e.pointclouds ) 
-              
-            if(!transfromInfo){  
-                transfromInfo = {pointclouds:e.pointclouds}
-            }
-            
-            
-            if(this.handleState == 'translate'){
-                e.pointclouds.forEach(cloud=>Alignment.translate(cloud, e.moveVec))
-                
-                
-            }else if(this.handleState == 'rotate'){
-                if(Potree.settings.editType == 'pano'){  
-                    //旋转中心是intersectStart的版本
-                    /* let center = e.intersectStart //旋转中心是mousedown的位置
-                    if(e.intersect.equals(center))return
-                    if(!transfromInfo){  
-                        transfromInfo = {
-                            orientationUser : e.pointclouds[0].orientationUser,
-                            //vecStart : e.moveVec, // 首次移动向量 只有八个方向,精度太小,所以延迟 
-                            pointclouds: e.pointclouds
-                        } 
-                        this.bus.dispatchEvent({type:'rotateStart', startPoint:center})
-                        return
-                    }else if(!transfromInfo.vecStart){  
-                        let vec = new THREE.Vector3().subVectors(e.intersect, center).setZ(0)
-                        if(vec.length() * e.camera.zoom >  30){  //在屏幕上距离初始点有一定距离后开始算
-                            //console.log('moveVec',vec)
-                            transfromInfo.vecStart = vec
-                        } */ 
-                   
-                     
-                    let center = e.pointclouds[0].translateUser //旋转中心是第一个点云的位置  
-                    if(e.intersect.equals(center))return
-                    if(!transfromInfo.vecStart){  
-                        transfromInfo.orientationUser = e.pointclouds[0].orientationUser  
-                        transfromInfo.vecStart = new THREE.Vector3().subVectors(e.intersectStart, center).setZ(0)  
-                           
-                    }else{ 
-                    
-                        let vec = new THREE.Vector3().subVectors(e.intersect, center).setZ(0)
-                        let angle = math.getAngle(transfromInfo.vecStart,vec,'z')   
-                        let diffAngle = transfromInfo.orientationUser + angle - transfromInfo.pointclouds[0].orientationUser
-                        
-                        transfromInfo.pointclouds.forEach(cloud=>{ 
-                            
-                           /*  let centerNoTranfrom = Potree.Utils.datasetPosTransform({ toDataset: true, pointcloud:cloud, position: center }) //中心点在数据集中的位置
-                            Alignment.rotate(cloud, null, diffAngle)
-                             
-                            let centerNow = Potree.Utils.datasetPosTransform({ fromDataset: true, pointcloud:cloud, position: centerNoTranfrom }) //中心点的现在位置
-                            let shift = new THREE.Vector3().subVectors( center, centerNow); //偏移量
-                            Alignment.translate(cloud,shift)   //使center还保留在原位
-                            //let centerNow1 = Potree.Utils.datasetPosTransform({ fromDataset: true, pointcloud:transfromInfo.pointcloud, position: centerNoTranfrom }) //中心点的现在位置
-                                 */ 
-                                 
-                            Alignment.rotateAround(center, cloud, null, diffAngle)    
-                                
-                                 
-                        }) 
-                        
-                        
-                    }
-                    //this.bus.dispatchEvent({type:'rotate', endPoint: e.intersect})
-                    
-                }else{ 
-                    let center = e.pointclouds[0].translateUser //移动到的位置就是中心
-                    if(e.intersect.equals(center))return
-                    if(!transfromInfo.vecStart){  
-                        transfromInfo.orientationUser = e.pointclouds[0].orientationUser
-                        transfromInfo.vecStart = new THREE.Vector3().subVectors(e.intersectStart, center).setZ(0)  
-                    }else{ 
-                        let vec = new THREE.Vector3().subVectors(e.intersect, center).setZ(0)
-                        let angle = math.getAngle(transfromInfo.vecStart,vec,'z')   
-                        let diffAngle = transfromInfo.orientationUser + angle - transfromInfo.pointclouds[0].orientationUser
-                        Alignment.rotate(transfromInfo.pointclouds[0], null, diffAngle)
-                    }
-                }    
-            } 
-        })
-        
-        
-        viewer.fpControls.addEventListener("end",(e)=>{   
-            transfromInfo && this.history.afterChange(transfromInfo.pointclouds )
-            transfromInfo = null 
-        })
-        
-        viewer.inputHandler.addEventListener('keydown',e=>{ 
-            if(e.keyCode == 90 && e.event.ctrlKey){//Z
-                this.history.undo()
-            }else if(e.keyCode == 89 && e.event.ctrlKey){//Y
-                this.history.redo()
-            }
-        })  
-		 
-        
-        // cursor:
-        
-        let updateCursor = (e)=>{ 
-            if(e.drag || !this.editing)return  //仅在鼠标不按下时更新:
-            
-            let handleState = Alignment.handleState
-            
-            if(e.hoverViewport.alignment && handleState && e.hoverViewport.alignment[handleState]){
-                if(handleState == 'translate'){
-                    if( e.intersect && e.intersect.location ){ 
-                        viewer.dispatchEvent({
-                            type : "CursorChange", action : "add",  name:"movePointcloud"
-                        })
-                    }else{
-                        viewer.dispatchEvent({
-                            type : "CursorChange", action : "remove",  name:"movePointcloud"
-                        })
-                    }
-                }else if(handleState == 'rotate'){ 
-                    if( e.intersect && e.intersect.location ){ 
-                        viewer.dispatchEvent({
-                            type : "CursorChange", action : "add",  name:"rotatePointcloud"
-                        })
-                    }else{
-                        viewer.dispatchEvent({
-                            type : "CursorChange", action : "remove",  name:"rotatePointcloud"
-                        })
-                    }
-                }  
-            }else{
-                //清空:
-                viewer.dispatchEvent({
-                    type : "CursorChange", action : "remove",  name:"movePointcloud" 
-                })
-                viewer.dispatchEvent({
-                    type : "CursorChange", action : "remove",  name:"rotatePointcloud" 
-                })
-            }                
-        }
-        
-         
-        viewer.addEventListener('global_mousemove',updateCursor)  
-        viewer.addEventListener('global_drop',updateCursor)//拖拽结束  
-       
-            
-        
-        
-        viewer.addEventListener('updateModelBound', (e)=>{
-            if(this.editing){
-                this.SplitScreen.updateCameraOutOfModel() 
-            } 
-        })
-        
-        
-    },
-    
-    
-    setMatrix :  function(pointcloud){
-        var vec1 = pointcloud.position     //position为数据集内部的偏移,在navvis中对应的是dataset.pointCloudSceneNode的children[0].position
-        var vec2 = pointcloud.translateUser
-        var angle = pointcloud.orientationUser
-        var pos1Matrix = new THREE.Matrix4().setPosition(vec1);//先移动到点云本身应该在的初始位置(在4dkk里和其他应用中都是在这个位置的,也能和漫游点对应上)
-        var rotMatrix = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(0,0,1), angle)//再旋转 
-        var pos2Matrix = new THREE.Matrix4().setPosition(vec2);//最后是平移
-         
-        var matrix = new THREE.Matrix4().multiplyMatrices(pos2Matrix, rotMatrix);
-        pointcloud.transformMatrix = matrix.clone();//为该数据集的变化矩阵。 对应navvis的m2w_
-        pointcloud.transformInvMatrix.copy(matrix).invert()
-        pointcloud.rotateMatrix = rotMatrix
-        pointcloud.rotateInvMatrix.copy(rotMatrix).invert()
-        
-        
-        pointcloud.panos.forEach(e=>e.transformByPointcloud())
-        
-        
-        matrix = new THREE.Matrix4().multiplyMatrices(matrix, pos1Matrix);
-        
-        
-        
-        pointcloud.matrix = matrix;
-        //pointcloud.matrixWorldNeedsUpdate = true //更新matrixWorld (非计算,直接赋值)
-        pointcloud.updateMatrixWorld(true)
-        
-        
-        
-        if(this.editing){
-            Alignment.changeCallBack && Alignment.changeCallBack();
-        } 
-        
-        if(pointcloud.spriteNodeRoot){
-            pointcloud.spriteNodeRoot.matrixWorld.copy(pointcloud.matrixWorld)//.multiplyMatrices(pointcloud.matrixWorld, pointcloud.matrixWorld);	
-        } 
-
-        viewer.boundNeedUpdate = true
-        //pointcloud.updateBound()
-        pointcloud.getPanosBound()  
-        viewer.dispatchEvent('content_changed') 
-
-    },
-    
-    
-    rotateAround(center, pointcloud, deg, angle){//绕center点转动
-        var angle = angle != void 0 ? angle : THREE.Math.degToRad(deg) 
-        let vec1 = new THREE.Vector3().subVectors(pointcloud.translateUser, center);
-        let rotMatrix = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(0,0,1), angle)
-        let vec2 = vec1.clone().applyMatrix4(rotMatrix) //将到旋转中心的偏差也转动
-        let vec3 = new THREE.Vector3().subVectors(vec2,vec1); //这个就是多出来的一步translateUser
-        this.rotate(pointcloud, deg, angle) 
-        this.translate(pointcloud, vec3)
-        //绕点转动就是比普通转动多一步移动到相对center的某个位置。 1 初始点云移动到自己的position; 2 移动一个vec1  3绕原点旋转 4再移动一个原本的translateUser。 绘制出来后发现移动量就是第二步vec旋转后的偏移
-    },
-    
-    
-    rotate:function(pointcloud, deg, angle){//绕各自中心转动(各自的position)   假设点云位移position后0,0,0就是它的中心了(根据navvis观察这样做是绕同一个点旋转的)
-        var angle = angle != void 0 ? angle : THREE.Math.degToRad(deg)   //正逆负顺
-        pointcloud.orientationUser += angle
-        Alignment.setMatrix(pointcloud)
-    },
-    translate:function(pointcloud, vec){
-        pointcloud.translateUser.add(vec)
-        Alignment.setMatrix(pointcloud)
-    },
-    
-    
-    
-    
-    enter:function(){
-        //this.saveTemp()  
-        this.originData = this.getTemp() 
-        
-        this.SplitScreen.split({alignment:true})
-         
-        viewer.images360.panos.forEach(pano=>{
-            Potree.Utils.updateVisible(pano.mapMarker, 'split4Screens', false)
-        }) 
-        
-        viewer.viewports.find(e=>e.name == 'mapViewport').alignment = {rotate:true,translate:true};
-        viewer.viewports.find(e=>e.name == 'right').alignment = {translate:true, translateVec:new THREE.Vector3(0,0,1)}; //只能上下移动
-        viewer.viewports.find(e=>e.name == 'back').alignment = {translate:true, translateVec:new THREE.Vector3(0,0,1)}; //只能上下移动
-        
-        
-        this.editing = true
-        
-        viewer.updateFpVisiDatasets()
-        
-        
-        
-    },
-    leave:function(){
-        this.switchHandle(null)
-        
-        /* this.originData.forEach(e=>{//恢复
-            var pointcloud = viewer.scene.pointclouds.find(p=>p.dataset_id == e.id)
-            this.translate(pointcloud, new THREE.Vector3().subVectors(e.translateUser , pointcloud.translateUser))
-            this.rotate(pointcloud, null, e.orientationUser - pointcloud.orientationUser)
-        }) */
-        this.originData.forEach(e=>{//恢复
-            this.applyTemp(e)
-        })
-        
-        
-        this.SplitScreen.recover()
-        viewer.images360.panos.forEach(pano=>{
-            Potree.Utils.updateVisible(pano.mapMarker, 'split4Screens', true)
-        }) 
-        this.editing = false
-        this.history.clear() 
-        viewer.updateFpVisiDatasets()
-        viewer.dispatchEvent({
-            type : "CursorChange", action : "remove",  name:"movePointcloud" 
-        })
-        viewer.dispatchEvent({
-            type : "CursorChange", action : "remove",  name:"rotatePointcloud" 
-        })
-    } 
-    
-    ,
-    switchHandle:function(state){
-        this.handleState = state
-        //清空:
-        viewer.dispatchEvent({
-            type : "CursorChange", action : "remove",  name:"movePointcloud" 
-        })
-        viewer.dispatchEvent({
-            type : "CursorChange", action : "remove",  name:"rotatePointcloud" 
-        })
-        
-        this.bus.dispatchEvent({type:'switchHandle' , state })
-        
-        
-
-    },
-    
-    
-    save: function(){//保存所有数据集的位置和旋转
-        let callback = ()=>{//保存成功后
-            this.originData = this.getTemp()   //this.saveTemp();
-            //需要修改 测量线的position。漫游点已经实时修改了
-            
-            viewer.scene.measurements.forEach(e=>e.transformByPointcloud())
-            viewer.images360.updateCube(viewer.bound)
-        }
-        
-        var data = viewer.scene.pointclouds.map(e=>{
-            let pos = viewer.transform.lonlatToLocal.inverse(e.translateUser.clone())
-            
-            
-            return {
-                id: e.dataset_id,
-                orientation : e.orientationUser,
-                location:[pos.x, pos.y, pos.z],
-                //transformMatrix: e.transformMatrix.elements,
-            }
-        })
-        //data = JSON.stringify(data)
-        
-        //test: 退出后保留结果
-        if(!Potree.settings.isOfficial){
-            callback() 
-        }
-        
-        return {data, callback}
-    }
-        
-    
-}
-
-
-                                  
-                        
-                            
- 
-  
- 
-/* 
-
-关于控制点:
-
-两个控制点只能打在同一个数据集上。传输这两个点的4dkk中的本地坐标和经纬度,后台算出该数据集的旋转平移,
-然后其他数据集绕该数据集旋转,并保持相对位置不变。
-
-
- */
- 
-
-export {Alignment} 

+ 0 - 708
src/custom/modules/mergeModel/MergeEditor.js

@@ -1,708 +0,0 @@
- 
-import * as THREE from "../../../../libs/three.js/build/three.module.js";
-import cameraLight from '../../utils/cameraLight.js' 
-
-import math from "../../utils/math.js"
-import Common from '../../utils/Common.js' 
-import {LineDraw, MeshDraw} from "../../utils/DrawUtil.js"; 
-import {transitions, easing, lerp} from '../../utils/transitions.js'
-import SplitScreen from "../../utils/SplitScreen.js";
-import InfiniteGridHelper from '../../objects/InfiniteGridHelper.js'
-import Compass from "../../objects/tool/Compass.js";
-import {TransformControls} from "../../objects/tool/TransformControls.js";
-import History from "../../utils/History.js"
-
- 
-const texLoader = new THREE.TextureLoader() 
-      texLoader.crossOrigin = "anonymous" 
-  
-const edgeStrengths = {
-    pointcloud: 4,
-    glb: 100
-}
-const viewportProps = [{
-    left:0,
-    bottom:0,
-    width: 0.5,height:1,
-    name : 'top',    
-    axis:["x","y"],
-    direction : new THREE.Vector3(0,0,-1), //镜头朝向 
-    active: true,
-    //相机位置在z轴正向
-    limitBound: new THREE.Box3(new THREE.Vector3(-Infinity,-Infinity, 1),new THREE.Vector3(Infinity,Infinity,5000)), //在地面以上
-    margin:{x:50, y:150} ,
-},
-{
-    left:0.5,
-    bottom:0,
-    width: 0.5,height:1,
-    name : 'right', 
-    axis:["y","z"],
-    direction : new THREE.Vector3(1,0,0), 
-    active: true,
-    //相机位置在x轴负向  右下角屏
-    viewContainsPoints:[new THREE.Vector3(0,0,0)],
-    margin:{x:300, y:250} ,
-} ]
-let cylinderSkyGeo, oldSkyGeo
- 
- 
-let MergeEditor = {
-    bus:new THREE.EventDispatcher(), 
-     
-    
-    SplitScreen : new SplitScreen(),
-    
-    init(){  
-        { 
-        
-            Potree.settings.notAdditiveBlending = true
-        
-            let ground = this.ground = new InfiniteGridHelper(1, 10000, new THREE.Color('#eee'), 10000, 0.2, 0.3)
-            viewer.scene.scene.add(ground) 
-            //再加两条线否则在正侧边看不到
-            let line1 = LineDraw.createLine([new THREE.Vector3(-10000, 0, 0),new THREE.Vector3(10000, 0, 0) ], {color:'#aaa', })
-            let line2 = LineDraw.createLine([new THREE.Vector3(0, -10000, 0),new THREE.Vector3(0, 10000, 0) ], {mat:line1.material})
-            ground.renderOrder = Potree.config.renderOrders.model + 1//line1.renderOrder + 1  //要比模型低,否则模型透明时效果不对
-            ground.add(line1) 
-            ground.add(line2)
-            ground.material.opacity = 0.9 //为了滞后渲染,否则被rt遮住
-            ground.material.polygonOffset = true //多边形偏移(视觉上没有移动模型位置),防止闪烁
-            ground.material.polygonOffsetFactor = 100 //多边形偏移因子
-			ground.material.polygonOffsetUnits = 10 //多边形偏移单位  
-            ground.material.depthWrite = false            
-            //ground.material.depthTest = false
-            line1.material.polygonOffset = true
-            line1.material.polygonOffsetFactor = 130  
-			line1.material.polygonOffsetUnits = 10  
-            line1.material.depthWrite = false   
-            //见笔记:透明物体的材质设置
-        }
-        
-        let oriEdgeStrength = viewer.outlinePass.edgeStrength 
-        {
-            
-            this.transformControls = new TransformControls(viewer.mainViewport.camera, viewer.renderArea,{
-                dontHideWhenFaceCamera: true,
-            });
-            //this.transformControls.space = 'local'//为了在当前方向上平移
-            this.transformControls.setSize(1.5)
-            viewer.scene.scene.add(this.transformControls)
-            this.transformControls._gizmo.hideAxis = {rotate:['e']}
-            this.transformControls.setRotateMethod(2)
-            
-            
-            //右屏
-            this.transformControls2 = new TransformControls(viewer.mainViewport.camera, viewer.renderArea,{ 
-                dontHideWhenFaceCamera: true,
-            }); 
-            this.transformControls.setSize(1.5)
-            viewer.scene.scene.add(this.transformControls2) 
-            Potree.Utils.setObjectLayers(this.transformControls2, 'layer2' )  
-             
-             
-            let mouseDown = (e)=>{
-                 
-                viewer.outlinePass.edgeStrength = 0//暂时消失线
-                 
-            }
-            let mouseUp = (e)=>{
-                 
-                //this.updateEdgeStrength()
-                viewer.outlinePass.edgeStrength = oriEdgeStrength
-            }
-            this.transformControls.addEventListener('mouseDown',mouseDown)
-            this.transformControls2.addEventListener('mouseDown',mouseDown)
-            this.transformControls.addEventListener('mouseUp',mouseUp)
-            this.transformControls2.addEventListener('mouseUp',mouseUp)
-            
-            
-        }
-        
-        
-        {
-            
-            this.secondCompass = new Compass(null)
-            
-        }
-        
-        viewer.setControls(viewer.orbitControls)
-        //viewer.mainViewport.view.fixZWhenPan = true
-        viewer.orbitControls.constantlyForward = true
-        
-        
-        viewer.addEventListener('global_single_click',(e)=>{
-            if(
-                this.noNeedSelection  //如模型查看页
-                || viewer.scene.cameraAnimations.some(c=>c.onUpdate) //正在播放
-                || e.drag && e.drag.notPressMouse   //在加测量线
-                || viewer.mainViewport.view.isFlying() //有其他校准
-                || this.split           //分屏中
-                || e.clickElement //触发别的点击事件,如测量时click marker  /* && e.clickElement != e.intersect.object */
-            ){
-                return
-            }
-            
-            if(e.intersect){
-                let object = e.intersect.object || e.intersect.pointcloud
-                let objects = this.getAllObjects()
-                if(objects.includes(object) && this.selected != object){ 
-                    this.selectModel(object) 
-                }else{
-                    //if(!viewer.inputHandler.selection[0]){//正在平移和旋转,不允许取消
-                        this.selectModel(null)
-                    //}
-                }                    
-            }else{
-                //if(!viewer.inputHandler.selection[0]){
-                    this.selectModel(null)
-                //}                
-            }
-        })  
-        
-        viewer.inputHandler.addEventListener('keydown', (e)=>{
-            if((e.event.key).toLowerCase() == "h" ){ 
-                this.fadeOutlineAuto = !this.fadeOutlineAuto
-                this.showModelOutline(this.selected,!!this.selected)
-            } 
-        })
-        viewer.ssaaRenderPass.enabled = false
-        viewer.outlinePass.enabled = true
-        //Potree.settings.intersectWhenHover = false
-        //Potree.Utils.updateVisible(viewer.reticule, 'force', false)
-        
-        viewer.mainViewport.camera.near = 0.05; // too small will result in z-fighting
-        
-        viewer.addEventListener('updateModelBound', (e)=>{
-            if(this.split){ 
-                this.SplitScreen.updateCameraOutOfModel(/* this.selected && [this.selected] */) 
-            } 
-        })
-        
-        
-        {//校准页面拖拽
-            //左右屏都可以拖拽模型,旋转只能左屏
-            let dragInfo  
-            let drag = (e)=>{ 
-                if(this.split &&  this.selected && this.transformState && (e.dragViewport.name == 'top' || this.transformState == 'translate')   ){ 
-                    if(e.type == 'global_mousedown' ){ //开始
-                        //if((e.intersect.object || e.intersect.pointcloud) == this.selected){
-                        if(e.intersect.pointclouds.includes(this.selected) || e.intersect.allElements.some(e=>e.object == this.selected)){
-                            
-                            dragInfo = {}   
-                            //if(this.selected.isPointcloud){ 
-                                viewer.outlinePass.edgeStrength = 0//暂时消失线
-                            //} 
-                        }  
-                    }
-                         
-                    if(e.type == 'global_drag' && dragInfo  ){ 
-                        if(this.transformState == 'translate'){ 
-                        
-                            let moveVec = Potree.Utils.getOrthoCameraMoveVec(e.drag.pointerDelta, e.dragViewport.camera )//最近一次移动向量
-                            this.selected.position.add(moveVec)
-                            
-                            this.selected.dispatchEvent("position_changed")
-                        }else if(this.transformState == 'rotate'){
-                            
-                            let vec = new THREE.Vector3().subVectors(e.intersect.orthoIntersect || e.intersect.location, this.selected.boundCenter).setZ(0)
-                            if(dragInfo.lastVec == void 0){//global_mousedown
-                                dragInfo.lastVec = vec 
-                                return
-                            }
-                            let angle = math.getAngle(dragInfo.lastVec, vec, 'z')   
-                            dragInfo.lastVec = vec
-                            
-                            //this.selected.rotation.z += angle //局部
-                            
-                            
-                            /* object.quaternion.copy( .setFromAxisAngle( new THREE.Vector3(0,0,1), angle ) );
-                            object.quaternion.multiply( quaternionStart ).normalize(); */
-                            let diffQua = new THREE.Quaternion().setFromAxisAngle( new THREE.Vector3(0,0,1), angle )
-                            this.selected.quaternion.premultiply(diffQua) //世界
-                            
-                            
-                            this.selected.dispatchEvent("rotation_changed")
-                        }
-                        
-                        return {stopContinue:true}
-                    } 
-                }
-                
-            }
-            
-            viewer.addEventListener('global_mousedown',  drag) 
-            viewer.addEventListener('global_drag', drag, {importance:10})
-            viewer.addEventListener('global_mousemove', (e)=>{
-                if(this.split && this.transformState && !e.drag && (e.hoverViewport.name == 'top' ||  this.transformState == 'translate')){
-                    
-                    /* if(this.lastHoverViewport != e.hoverViewport){
-                        this.lastHoverViewport = e.hoverViewport
-                        this.transformControls.view = e.hoverViewport.view
-                        this.transformControls.camera = e.hoverViewport.camera
-                        this.transformControls.hideAxis( this.transformState, e.hoverViewport.name == 'top' ? [z] : [x,y]);
-                    } */
-                    
-                    
-                    
-                    
-                    let mouseover =  e.intersect.pointclouds.includes(this.selected) || e.intersect.allElements.some(e=>e.object == this.selected)
-                    //let mouseover = (e.intersect.object || e.intersect.pointcloud) == this.selected
-                    if(mouseover){
-                        if(this.transformState == 'translate'){
-                            viewer.dispatchEvent({
-                                type : "CursorChange", action : "add",  name:"movePointcloud" 
-                            }) 
-                        }else{
-                            viewer.dispatchEvent({
-                                type : "CursorChange", action : "add",  name:"rotatePointcloud" 
-                            }) 
-                        }
-                    }else{
-                        this.clearTranCursor()
-                    }
-                    
-                } 
-            })
-            
-            viewer.addEventListener('global_drop', (e)=>{
-                dragInfo = null
-                this.clearTranCursor()
-                  
-                //this.updateEdgeStrength()
-                viewer.outlinePass.edgeStrength = oriEdgeStrength  
-                
-            })
-        
-        }
-        
-        
-        /* viewer.addEventListener('background_changed',()=>{
-          
-        }) */
-        
-    },
-    
-    
-    clearTranCursor(){
-        viewer.dispatchEvent({
-            type : "CursorChange", action : "remove",  name:"movePointcloud" 
-        })
-        viewer.dispatchEvent({
-            type : "CursorChange", action : "remove",  name:"rotatePointcloud" 
-        })
-    },
-    
-    enterSplit(){ 
-        this.split = true
-        if(this.selected) this.SplitScreen.focusCenter = this.selected.boundCenter //旋转中心。注意 boundCenter不能直接赋值,否则改变后focusCenter也要改
-        else this.SplitScreen.focusCenter = null
-        
-        this.SplitScreen.splitStart(viewportProps)
-        
-        this.beforeSplit = {
-            pointDensity: Potree.settings.pointDensity,
-        }
-        Potree.settings.pointDensity = 'fourViewports' //强制降低点云质量
-         
-        
-        viewer.setControls(viewer.fpControls)  
-         
-        let rightViewport = viewer.viewports.find(e=>e.name == 'right')
-        let topViewport = viewer.viewports.find(e=>e.name == 'top')
-        topViewport.alignment = true
-        rightViewport.rotateSide = true  
-        rightViewport.skyboxFixPos = true
-        rightViewport.skyboxMinZoom = 10
-        rightViewport.skyboxRenderFun = ()=>{// 使cube的一面永远正向镜头。 因侧视图的camera是ortho类型,需要平视mesh才不会拉伸
-            viewer.skybox.scene.children[0].rotation.copy(rightViewport.camera.rotation)
-        }
-        topViewport.skyboxRenderFun = ()=>{
-            viewer.skybox.scene.children[0].rotation.set(0,0,0)
-        }
-         
-        
-        
-        viewer.viewports[1].layersAdd('layer2') 
-        viewer.viewports[0].layersAdd('layer1') 
-        Potree.Utils.setObjectLayers(this.transformControls, 'layer1' ) 
-        this.transformControls.view = viewer.viewports[0].view
-        this.transformControls.camera = viewer.viewports[0].camera
-        this.transformControls._gizmo.hideAxis = {translate:['z'], rotate:['x','y','z'] }
-        this.transformControls2.view = viewer.viewports[1].view
-        this.transformControls2.camera = viewer.viewports[1].camera
-        this.transformControls2._gizmo.hideAxis = {translate:['x','y'], rotate:['x','y','z'] }
-        
-
-        this.secondCompass.changeViewport(viewer.viewports[0])
-        this.secondCompass.setDomPos()
-        this.secondCompass.setDisplay(true)   
-        viewer.compass.changeViewport(viewer.viewports[1])
-        viewer.compass.setDomPos()
-        
-        
-        //this.changeSkyboxGeo(true)
-    },
-    
-    
-    leaveSplit(){
-        this.split = false
-        this.SplitScreen.unSplit()    
-        viewer.setControls(viewer.orbitControls)
-        
-        Potree.settings.pointDensity = this.beforeSplit.pointDensity
-        /* if(this.selected && this.selected.isPointcloud){ 
-            this.showModelOutline(this.selected, true) 
-            this.selected.material.activeAttributeName = "rgba"  
-        } */
-        this.transformControls.camera = viewer.viewports[0].camera
-        this.transformControls.view = viewer.viewports[0].view 
-        this.transformControls._gizmo.hideAxis = {rotate:['e']}
-        Potree.Utils.setObjectLayers(this.transformControls, 'sceneObjects' )  //恢复
-        
-        
-        viewer.compass.changeViewport(viewer.viewports[0]) //恢复 
-        viewer.compass.setDomPos()
-        this.secondCompass.setDisplay(false)
-        
-        
-    },
-    
-    rotateSideCamera(angle){
-        this.SplitScreen.rotateSideCamera(viewer.viewports.find(e=>e.name == 'right'), angle)
-    },
-    
-    setTransformState(state){//校准时
-        this.transformState = state  
-        this.clearTranCursor()       
-    },
-    
-  
-    
-    //---------------------------
-    
-    /* writeToHistory(content){ 
-        if(!this.prepareRecord)return;
-        this.prepareRecord = false
-        this.history.push(content)
-    }, */
-    
-    //---------------------------
-    
-    getAllObjects(){
-        return viewer.objs.children.concat(viewer.scene.pointclouds)
-    },
-    
-    getModel(id){
-        let models = this.getAllObjects()
-        return models.find(e=>e.dataset_id == id)
-    },
-    removeModel(model){
-        if(this.selected == model) this.selectModel(null)
-        let dispose = (e)=>{
-            e.geometry && e.geometry.dispose() 
-            e.material && e.material.dispose()
-        }
-        if(model.isPointcloud){
-            dispose(model)
-            viewer.scene.removePointCloud(model)
-        }else{
-            model.traverse(e=>{
-                dispose(e) 
-            })
-            viewer.objs.remove(model)
-            this.updatePointQuality()
-        }   
-        
-        
-        
-    },
-    
-    selectModel(model, state=true, fitBound, by2d){
-        if(!model) {
-            model = this.selected
-            state = false
-        }
-         
-        if(state){
-            if(this.selected){
-                if(this.selected == model) return
-                else{
-                    let transToolAttached = !!this.transformControls.object
-                    this.selectModel(this.selected, false, fitBound, by2d)
-                    transToolAttached && this.transformControls.attach(model)
-                }
-            }
-            this.selected = model
-             
-            MergeEditor.focusOn(model, 500, !!fitBound)     //通过在场景里点击模型的话,不focus
-              
-           
-            this.showModelOutline(model)
-             
-            //this.updateEdgeStrength()
-            
-            //console.log('selectModel', model)
-            
-        }else{
-            if(this.selected != model)return //model本来就没选中,不需要处理(防止2d先选中新的再取消旧的)
-            this.showModelOutline(model, false)
-             
-            this.selected = null
-            this.transformControls.detach()        //viewer.transformObject(null);
-            //console.log('selectModel', null)
-        } 
-        
-        
-        
-        if(!by2d && model){
-            model.dispatchEvent({type:'changeSelect', selected : state})
-        }
-        
-    },
-    
-    
-    showModelOutline(model, state){ 
-        if(this.fadeOutlineAuto){ 
-            if(state === false){
-                viewer.outlinePass.selectedObjects = []
-                clearTimeout(this.timer)
-                return
-            }
-            
-            viewer.outlinePass.selectedObjects = [model]
-            if(this.timer){
-                clearTimeout(this.timer)
-            }
-            
-            this.timer = setTimeout(()=>{
-                viewer.outlinePass.selectedObjects = []
-                viewer.dispatchEvent('content_changed') 
-            }, 1000)
-        }else{
-            if(state === false){
-                viewer.outlinePass.selectedObjects = []
-            }else{
-                viewer.outlinePass.selectedObjects = [model]
-            } 
-        }
-        viewer.dispatchEvent('content_changed') 
-    },
-    
-    /*updateEdgeStrength(){
-        if(!this.selected)return 
-         if(this.selected.isPointcloud){
-            viewer.outlinePass.edgeStrength = edgeStrengths.pointcloud// / this.selected.material.opacity  
-        }else{
-            viewer.outlinePass.edgeStrength = edgeStrengths.glb
-        }  
-    },*/ 
-    focusOn(objects, duration = 400, fitBound=true, dontLookUp){  
-        if(!(objects instanceof Array)){
-            objects = [objects]
-        }
-        let boundingBox = new THREE.Box3
-        objects.forEach(object=>{
-            boundingBox.union(object.boundingBox.clone().applyMatrix4(object.matrixWorld))
-        })
-         
-        if(fitBound){
-            viewer.focusOnObject({boundingBox}, 'boundingBox', duration, {dontLookUp, dontChangeCamDir:true}) 
-        }else{ 
-        
-            /* 
-            let position = viewer.inputHandler.intersect ? viewer.inputHandler.intersect.location : boundingBox.getCenter(new THREE.Vector3)
-            position && viewer.focusOnObject({position},  'point', duration, {dontChangePos: true})
-             */
-            let position = viewer.inputHandler.intersect ? viewer.inputHandler.intersect.location : boundingBox.getCenter(new THREE.Vector3)
-            if(!position)return
-            
-            
-            /* let targetOld = viewer.mainViewport.view.getPivot()
-            
-            let projected1 = targetOld.clone().project(viewer.mainViewport.camera);
-            let projected2 = position.clone().project(viewer.mainViewport.camera); //使用其z
-			let targetNew = projected1.clone().setZ(projected2.z).unproject(viewer.mainViewport.camera); 
-            viewer.mainViewport.view.lookAt(targetNew) */
-            
-            
-            viewer.mainViewport.view.radius = viewer.mainViewport.camera.position.distanceTo(position)
-            //为了不改画面,不调节方向了,只能调调radius,一定程度将target靠近model
-        }  
-    },
-    
-    
-    moveBoundCenterTo(model,pos){ //使boundCenter在所要的位置 
-        let diff = new THREE.Vector3().subVectors(pos, model.boundCenter) 
-        model.position.add(diff); 
-    },
-    
-    getBoundCenter(model){
-        if(!model.boundCenter) model.boundCenter = new THREE.Vector3
-        model.boundingBox.getCenter(model.boundCenter).applyMatrix4(model.matrixWorld) 
-    },
-    
-    setModelBtmHeight(model, z ){  
-        //无论模型怎么缩放、旋转,都使最低点为z
-        if(z == void 0) z = model.btmHeight; //维持离地高度
-        else model.btmHeight = z;
-        
-        model.updateMatrixWorld()
-        let boundingBox2 = model.boundingBox.clone().applyMatrix4(model.matrixWorld)
-        let size = boundingBox2.getSize(new THREE.Vector3);
-        let center = boundingBox2.getCenter(new THREE.Vector3);
-        let hopeZ = z + size.z / 2  
-        //model.position.z = z + size.z / 2 - center.z 
-        model.position.z += (hopeZ - center.z)
-    },
-    
-    computeBtmHeight(model){ //位移之后重新计算btmHeight
-        model.updateMatrixWorld()
-        let boundingBox2 = model.boundingBox.clone().applyMatrix4(model.matrixWorld)
-        let size = boundingBox2.getSize(new THREE.Vector3);
-        let center = boundingBox2.getCenter(new THREE.Vector3);
-        model.btmHeight = center.z - size.z / 2 
-    },
-    
-    
-    maintainBoundXY(model){ //在旋转和缩放后,立即执行这个函数,使boundCenter保持原位
-         
-        model.updateMatrixWorld()
-        let center1 = model.boundCenter.clone();//还未更新的 
-        this.getBoundCenter(model)//更新
-        let center2 = model.boundCenter.clone();
-        let diff = new THREE.Vector2().subVectors(center1,center2); 
-        model.position.x += diff.x;
-        model.position.y += diff.y;
-        model.boundCenter.copy(center1)
-    }, 
-     
-    
-    
-    maintainBoundCenter(model){
-        model.updateMatrixWorld()
-        let center1 = model.boundCenter.clone();//还未更新的 
-        this.getBoundCenter(model)//更新
-        let center2 = model.boundCenter.clone();
-        let diff = new THREE.Vector3().subVectors(center1,center2); 
-        model.position.add(diff)
-        model.boundCenter.copy(center1)
-    },
-    
-    modelTransformCallback(model){
-        
-        model.updateMatrixWorld() 
-        if(model.matrixWorld.equals(model.lastMatrixWorld))return
-        viewer.scene.measurements.forEach(measure=>{
-            let changed
-            measure.points_datasets.forEach((dataset_id,i)=>{
-                if(dataset_id == model.dataset_id){
-                    changed = true
-                    measure.points[i] = Potree.Utils.datasetPosTransform({fromDataset:true,datasetId:dataset_id, position:measure.dataset_points[i].clone()})
-                    measure.updateMarker(measure.markers[i], measure.points[i])
-                   
-                }
-            })
-            if(changed){//仿transformByPointcloud
-                measure.getPoint2dInfo(measure.points)
-                measure.update() 
-                measure.setSelected(false)//隐藏edgelabel  
-            }
-        }) 
-        
-        model.lastMatrixWorld = model.matrixWorld.clone()
-        viewer.dispatchEvent('content_changed')
-    },
-    
-    
-    changeOpacity(model, opacity){
-         
-        let isRoot = model.dataset_id != void 0  //是否是最外层 
-             
-    
-        if(model.isPointcloud){ 
-            model.changePointOpacity(opacity) 
-            //MergeEditor.updateEdgeStrength()
-        }else{
-            //model.traverse(e=>e.material && setOp(e, opacity))
-            model.traverse(mesh=>{ 
-                if(mesh.material){ 
-                    if(mesh.material.originOpacity == void 0 ){
-                        mesh.material.originOpacity = mesh.material.opacity
-                    }
-                    mesh.material.opacity = mesh.material.originOpacity * opacity
-                    
-                    if(mesh.material.opacity<1){
-                        mesh.material.transparent = true  
-                        /* if(model.isPointcloud){
-                            mesh.changePointOpacity(realOpacity)  
-                        }else{
-                            mesh.material.opacity = realOpacity
-                        } */
-                        
-                        mesh.renderOrder = Potree.config.renderOrders.model+1 
-                        //mesh.material.depthWrite = false
-                    }else{
-                        mesh.material.transparent = false
-                        mesh.renderOrder = Potree.config.renderOrders.model
-                        //mesh.material.depthWrite = true
-                    }
-                    mesh.material.depthWrite = mesh.material.opacity>0.3
-                }
-            })
-        }
-            
-              
-        isRoot && (model.opacity = opacity)//记录在最外层
-        viewer.dispatchEvent('content_changed')
-        
-    },
-    
-    
-    updatePointQuality(){
-        
-        let posCount=0, gltfCount=0     //gltf的怎么获取模型复杂度?暂时只根据个数吧
-        viewer.objs.children.forEach(e=>{
-            if(e.name == 'glb' || e.name == 'obj'){
-                e.traverse((mesh)=>{
-                    if(mesh.geometry){
-                        posCount += mesh.geometry.attributes.position.count
-                    }
-                })
-            }else if(e.name == 'gltf'){
-                gltfCount ++
-            }
-        })
-        let score = posCount + gltfCount * 5000
-        let min = 3, max = 5, minP = 20000, maxP = 1000000;
-        let ratio = max - ( max - min) * THREE.Math.clamp((score - minP)  / (maxP - minP),0,1)  
-                
-        
-        
-        Potree.pointBudget = ratio*1000*1000
-        
-        
-        
-        
-    },
-}   
-    
-    
-    
-  
-    
-    
-export default MergeEditor  
-    
-    
-/*  
-
-note:
-
-要注意getHoveredElements只在getIntersect时才使interactables包含加载的model, 也就是model上不能有使之成为interactables的事件,否则在鼠标hover到模型上开始转动的一瞬间很卡。
-
-
-
-
-
-*/ 

File diff suppressed because it is too large
+ 0 - 1411
src/custom/modules/panoEdit/panoEditor.js


File diff suppressed because it is too large
+ 51 - 793
src/custom/modules/panos/Images360.js


+ 73 - 363
src/custom/modules/panos/Panorama.js

@@ -1,12 +1,11 @@
 import * as THREE from "../../../../libs/three.js/build/three.module.js";
 import {transitions, easing, lerp} from '../../utils/transitions.js'
-import TileUtils from './tile/TileUtils.js' 
-                                                                                   
+                                                                               
 import math from '../../utils/math.js' 
 import {TextSprite} from '../../objects/TextSprite.js'
 import DepthBasicMaterial from "../../materials/DepthBasicMaterial.js"; 
 
-let { PanoRendererEvents, PanoramaEvents, PanoSizeClass} = Potree.defines
+let { } = Potree.defines
 var texLoader = new THREE.TextureLoader()
 
 
@@ -99,117 +98,55 @@ class Panorama extends THREE.EventDispatcher{
             0       pointcloudVisi(隐藏了数据集)       unvisible
          */ 
          
+      
+        this.originPosition = new THREE.Vector3().fromArray(o.dataset_location) 
+        this.originFloorPosition = new THREE.Vector3().fromArray(o.dataset_floor_location)
+        
+        this.originID = parseInt(o.file_id)//"file_id":"00022"对应是原本的4dkk的id --来自vision.txt
+         
+        this.pointcloud = viewer.scene.pointclouds.find(e=>e.dataset_id == o.dataset_id) || viewer.scene.pointclouds[0]
+        this.pointcloud.panos.push(this)
+        
+        //this.sid = this.pointcloud.sceneCode + '|' + this.originID  //不会更改的标记
+        this.sid = this.pointcloud.dataset_id + '|' + this.originID  //不会更改的标记
+        //全景图和Cube的水平采样起始坐标相差90度 
         
-        if(Potree.settings.editType == 'pano'){//漫游点拼合编辑
-            this.uuid = o.uuid  //因为有多个数据集 所以会重复
-            this.index = o.index  //下标, 用于visibles
-            this.pointcloud = viewer.scene.pointclouds.find(e=>e.panoUuid == o.uuid) 
-            this.pointcloud.panos.push(this)
-            this.sid = this.pointcloud.dataset_id + '|' + this.uuid  //不会更改的标记  用于entity.panos里的标记
-            
-            
-            this.panosData = o
-            
-            //数据中原本的位置朝向
-            this.dataPosition = new THREE.Vector3().copy(o.pose.translation) 
-            this.dataQuaternion = new THREE.Quaternion().copy(o.pose.rotation) 
-            this.dataRotation = new THREE.Euler().setFromQuaternion(this.dataQuaternion) 
-            
-            
-            //因为位置朝向随着点云位置改变,所以直接运用到点云上,这里清零
-            this.originPosition = new THREE.Vector3()   //{x: 0, y: 0, z: 0}
-            this.quaternion = new THREE.Quaternion()  //{w: 0, x: 0, y: 0, z: 1}
-            //this.quaternion4dkk = math.convertVisionQuaternion(this.quaternion)//4dkk内使用的quaternion 
-            this.visibles = o.visibles 
-            this.rtkState = o.has_rtk ? o.use_rtk : null 
-            
-            const height = 1.4; //相机高度
-            this.originFloorPosition = this.originPosition.clone()
-            this.originFloorPosition.z -= height
-            
-            
-            /* this.originPosition = new THREE.Vector3().copy(o.pose.translation)  //{x: 0, y: 0, z: 0}
-            this.quaternion = new THREE.Quaternion().copy(o.pose.rotation) //{w: 0, x: 0, y: 0, z: 1}
-            //this.quaternion4dkk = math.convertVisionQuaternion(this.quaternion)//4dkk内使用的quaternion 
-            this.visibles = o.visibles 
-            this.pointcloud = viewer.scene.pointclouds.find(e=>e.dataset_id == o.uuid) 
-            this.pointcloud.panos.push(this)
-            
-            const height = 1.5; //相机高度
-            this.originFloorPosition = this.originPosition.clone()
-            this.originFloorPosition.z -= height
-             */
-            
-            
-        }else{
-            this.originPosition = new THREE.Vector3().fromArray(o.dataset_location) 
-            this.originFloorPosition = new THREE.Vector3().fromArray(o.dataset_floor_location)
-            
-            this.originID = parseInt(o.file_id)//"file_id":"00022"对应是原本的4dkk的id --来自vision.txt
-             
-            this.pointcloud = viewer.scene.pointclouds.find(e=>e.dataset_id == o.dataset_id) || viewer.scene.pointclouds[0]
-            this.pointcloud.panos.push(this)
-            
-            //this.sid = this.pointcloud.sceneCode + '|' + this.originID  //不会更改的标记
-            this.sid = this.pointcloud.dataset_id + '|' + this.originID  //不会更改的标记
-            //全景图和Cube的水平采样起始坐标相差90度 
-            
 
-            /* if(from4dkk){
-                var qua = o.dataset_orientation 
-                
-                var quaternion = new THREE.Quaternion().fromArray(qua)
-                    quaternion = new THREE.Quaternion().multiplyQuaternions(quaternion,  rot901);//整张球幕图要旋转下  因为在4dkk里转过,还原。如果是tiles的不用
-                this.quaternion = new THREE.Quaternion(quaternion.x, -quaternion.z, quaternion.y, quaternion.w) //转化坐标
-                    
-            }else{ */
+        /* if(from4dkk){
+            var qua = o.dataset_orientation 
             
+            var quaternion = new THREE.Quaternion().fromArray(qua)
+                quaternion = new THREE.Quaternion().multiplyQuaternions(quaternion,  rot901);//整张球幕图要旋转下  因为在4dkk里转过,还原。如果是tiles的不用
+            this.quaternion = new THREE.Quaternion(quaternion.x, -quaternion.z, quaternion.y, quaternion.w) //转化坐标
                 
-                var qua = o.dataset_orientation 
-                qua = [qua[1], qua[2], qua[3], qua[0]] 
-                this.quaternion = new THREE.Quaternion().fromArray(qua)
-                this.quaternion4dkk = math.convertVisionQuaternion(this.quaternion)//4dkk内使用的quaternion 
-                this.quaternion2 = this.quaternion.clone()
-                this.quaternion = new THREE.Quaternion().multiplyQuaternions(this.quaternion,  rot90);//全景图和Cube的水平采样起始坐标相差90度,cubeTex转90度
-                
-                this.rotation4dkk = new THREE.Euler().setFromQuaternion(this.quaternion4dkk)
-                
-             //}
-             
-             
-                //this.quaternion1 = Potree.Utils.QuaternionFactory.fromArray(o.dataset_orientation)
-                //同quaternion
-
-          
-            //let xy = this.transform.forward([this.longitude, this.latitude]);  
-            //this.file = `https://4dkk.4dage.com/images/images${Potree.settings.number}/pan/high/${this.id}.jpg`
+        }else{ */
+        
             
-             this.neighbours = [];
+            var qua = o.dataset_orientation 
+            qua = [qua[1], qua[2], qua[3], qua[0]] 
+            this.quaternion = new THREE.Quaternion().fromArray(qua)
+            this.quaternion4dkk = math.convertVisionQuaternion(this.quaternion)//4dkk内使用的quaternion 
+            this.quaternion2 = this.quaternion.clone()
+            this.quaternion = new THREE.Quaternion().multiplyQuaternions(this.quaternion,  rot90);//全景图和Cube的水平采样起始坐标相差90度,cubeTex转90度
             
-        }
+            this.rotation4dkk = new THREE.Euler().setFromQuaternion(this.quaternion4dkk)
+            
+         //} 
+            //this.quaternion1 = Potree.Utils.QuaternionFactory.fromArray(o.dataset_orientation)
+            //同quaternion
+
+      
+        //let xy = this.transform.forward([this.longitude, this.latitude]);  
+        //this.file = `https://4dkk.4dage.com/images/images${Potree.settings.number}/pan/high/${this.id}.jpg`
+        
+         this.neighbours = [];
+        
+         
         this.rotation = new THREE.Euler().setFromQuaternion(this.quaternion) 
         this.build()
         this.transformByPointcloud() //初始化位移
         
-        {//tile
-            this.minimumTiledPanoLoaded = !1;
-            this.highestPartialTileRenderOpCompleted = 0;
-            this.highestFullTileRenderOpCompleted = 0;
-            this.shouldRedrawOnBaseLoaded = !1;
-            this.resolutionPromise = {}
-            this.tiledPanoRenderTarget = null;
-            this.zoomed = !1;
-            
-            
-            
-           
-            images360.panoRenderer.addEventListener(PanoRendererEvents.TileRenderSuccess, this.onTileRendered.bind(this));
-            images360.panoRenderer.addEventListener(PanoRendererEvents.PanoRenderComplete, this.onPanoRendered.bind(this));
-            images360.panoRenderer.addEventListener(PanoRendererEvents.TileRenderFailure, this.onTileRenderFail.bind(this));
-            images360.panoRenderer.addEventListener(PanoRendererEvents.UploadAttemptedForAllTiles, this.onUploadAttemptedForAllTiles.bind(this));
-            
-        }
-        
+         
         
         
         this.addEventListener('hoverOn', (e)=>{//from Map
@@ -246,12 +183,36 @@ class Panorama extends THREE.EventDispatcher{
         //如果当前在全景模式且在这个点,需要切换显示吗? 目前用不到 
     }
 
- 
+    loadTex(){ 
+        if(this.skyboxTex || this.texLoading)return
+        this.texLoading = true
+        let src =  `${Potree.settings.urls.prefix1}\${this.id}.jpg`   //`server\test\SS-t-P1d6CwREny2\${this.id}.jpg`    //`${Potree.settings.urls.prefix1}/${Potree.settings.webSite}/${this.pointcloud.sceneCode}/data/${this.pointcloud.sceneCode}/depthmap/${this.originID}.png`
+        //console.log('开始下载depthImg', this.id)
+        let texture = texLoader.load( src, ()=>{
+            this.skyboxTex = texture
+            this.images360.dispatchEvent({type:'loadedTex', pano:this, loaded:true})
+            this.depthTexLoading = false
+            //viewer.dispatchEvent('content_changed') 
+        },null,(e)=>{//error
+            console.error('loadTex失败, 数据集sceneCode'+ this.pointcloud.sceneCode,  this.id )
+             
+            this.images360.dispatchEvent({type:'loadedTex', pano:this, })
+        });
+        texture.wrapS = THREE.RepeatWrapping;
+        texture.flipY = false 
+        texture.magFilter = THREE.LinearFilter
+        texture.minFilter = THREE.LinearFilter
+	}
+    
+    
+    
     loadDepthImg(){ 
         if(!this.pointcloud.hasDepthTex || this.depthTex || this.depthTexLoading)return
         this.depthTexLoading = true
         let src = //Potree.settings.number == 'SS-t-7DUfWAUZ3V' ?  `${Potree.scriptPath}/data/${Potree.settings.number}/depthMap/${this.originID}.png` :
-                 `${Potree.settings.urls.prefix1}/${Potree.settings.webSite}/${this.pointcloud.sceneCode}/data/${this.pointcloud.sceneCode}/depthmap/${this.originID}.png`
+                 //`${Potree.settings.urls.prefix1}/${Potree.settings.webSite}/${this.pointcloud.sceneCode}/data/${this.pointcloud.sceneCode}/depthmap/${this.originID}.png`
+                 `server\test\SS-t-P1d6CwREny2\depthmap\${this.id}.png`
+        
         //console.log('开始下载depthImg', this.id)
         let texture = texLoader.load( src, ()=>{
             this.depthTex = texture
@@ -398,136 +359,24 @@ class Panorama extends THREE.EventDispatcher{
     
     
     
-    setZoomed(zoomed){
-        this.zoomed = zoomed;
-        Potree.settings.displayMode == 'showPanos' && this.updateSkyboxForZoomLevel(); //放大后换成zoomTarget贴图
-        viewer.dispatchEvent({type:'panoSetZoom', zoomed})
-        
-    }
-    
+     
     
     enter(){ 
-        this.setZoomed(!1),
+       
         viewer.dispatchEvent({type:PanoramaEvents.Enter,  oldPano:old, newPano:this  }  )
         old = this 
         //console.log("enter pano "+ this.id)
     } 
 
-    exit(){ 
-        this.clearWaitDeferreds();
-        this.minimumTiledPanoLoaded = !1;
-        this.tiledPanoRenderTarget = null;
-        this.setZoomed(!1);
-        this.images360.panoRenderer.deactivateTiledPano(this);
-        this.highestPartialTileRenderOpCompleted = 0;
-        this.highestFullTileRenderOpCompleted = 0;
+    exit(){   
         
         //console.log("exit pano "+ this.id)
         
         viewer.dispatchEvent({type:PanoramaEvents.Exit, pano:this}); 
     }
     
-    
-    updateSkyboxForZoomLevel(){
-        if(this.minimumTiledPanoLoaded){
-            this.images360.updateProjectedPanos();
-        }
-         
-    }
-    
-    getSkyboxTexture(){
-     
-        if(this.minimumTiledPanoLoaded)
-        {
-            if(this.zoomed && this.images360.qualityManager.maxRenderTargetSize > this.images360.qualityManager.maxNavPanoSize)//change 如果放大后和不放大都是2k就不用这个
-            {
-                return this.images360.panoRenderer.zoomRenderTarget.texture;   
-            }
-            else
-            {
-                
-                this.tiledPanoRenderTarget.texture.mapping = THREE.UVMapping//add
-                return this.tiledPanoRenderTarget.texture;
-            }
-        }
-        else
-        {
-            return null;
-        }
-         
-    }
-    
-   
-    
-    isLoaded(e){ 
-        if (e && "string" == typeof e)
-            console.error("Wrong panoSize given to Panorama.isLoaded(); a tiled pano uses PanoSizeClass"); 
-        return !!this.minimumTiledPanoLoaded && (!e || this.highestFullTileRenderOpCompleted >= e)//改:原本是:this.highestPartialTileRenderOpCompleted >= e, 希望这代表全部加载完
-     
-    }
-
-    getWaitDeferred(size){//获取不同size的tile贴图的promiss 
-        var t = this.resolutionPromise[this.id];
-        t || (t = {}, this.resolutionPromise[this.id] = t);
-        var i = t[size];
-        return i || (i = {
-            deferred: $.Deferred(),
-            active: !1
-        },
-        t[size] = i),
-        i
-    }
-    
-    clearWaitDeferreds(){
-        var e = this.resolutionPromise[this.id];
-        e || (e = {},
-        this.resolutionPromise[this.id] = e);
-        for (var t in e)
-            if (e.hasOwnProperty(t)) {
-                var i = e[t];
-                i.active = !1,
-                i.deferred = $.Deferred()
-            }
-    }
-    resetWaitDeferred(e){
-        var t = this.getWaitDeferred(e);
-        t.active = !1;
-        t.deferred = $.Deferred();
-    }
-    onTileRendered(ev){  
-        ev.id === this.id && this.dispatchEvent({
-            type:PanoramaEvents.TileLoaded, 
-            size:ev.panoSize, index:ev.tileIndex, count:ev.totalTiles
-        });
-    }
-
-    onPanoRendered(ev) { 
-        if(ev.id === this.id)  
-        {
-            this.minimumTiledPanoLoaded = !0;
-            this.updateSkyboxForZoomLevel();//更新贴图 setProjected
-            ev.panoSize > this.highestPartialTileRenderOpCompleted && (this.highestPartialTileRenderOpCompleted = ev.panoSize);//应该是更新最高获取到的Partial size
-            ev.updateFullComplete && ev.panoSize > this.highestFullTileRenderOpCompleted && (this.highestFullTileRenderOpCompleted = ev.panoSize); //应该是更新最高获取到的Full size
-            //this.dispatchEvent("load", ev.panoSize);
-            viewer.ifAllLoaded( this);
-            this.dispatchEvent({type:PanoramaEvents.LoadComplete, size:ev.panoSize, count:ev.totalTiles});
-        }
-    }
  
-    onTileRenderFail(ev) { 
-        ev.id === this.id && this.dispatchEvent({type:PanoramaEvents.LoadFailed   });
-    }
-    onUploadAttemptedForAllTiles(ev) { 
-        if (ev.id === this.id) {        
-            var n = this.images360.qualityManager.getPanoSize(PanoSizeClass.BASE);
-            if(ev.panoSize === n && this.shouldRedrawOnBaseLoaded) //shouldRedrawOnBaseLoaded一直是false。在4dkk里只有初始点在quickstart后变为true。
-            {
-                this.shouldRedrawOnBaseLoaded = !1;
-                this.panoRenderer.resetRenderStatus(this.id, !0, !1);
-                this.panoRenderer.renderPanoTiles(this.id, null, !0, !0);
-            }
-        }
-    }
+    
 
     
     
@@ -623,145 +472,6 @@ class Panorama extends THREE.EventDispatcher{
 
 
  
-
-Panorama.prototype.loadTiledPano = function() {
-    //var downloads = []  , t = [];
-    var downloaded = {}  , eventAdded = {}, latestPartialRequest = {}; //每个pano对应一组这些
-         
-    return function(size, dirs, fov, o, a, download) {
-        var dir = dirs.datasetsLocal.find(e=>e.datasetId == this.pointcloud.dataset_id).direction;
-        //var dir = dirs
-         
-        
-        null !== o && void 0 !== o || (o = !0),
-        null !== a && void 0 !== a || (a = !0);
-        var l = this.getWaitDeferred(size)
-          , c = l.deferred
-          , h = null
-          , u = null; 
-        fov && ("number" == typeof fov ? h = fov : (h = fov.hFov, u = fov.vFov))  
-        
-        if (!this.isLoaded(size)) {
-            //console.log('loadTiledPano', this.id, size, fov)
-            if (!l.active) {
-                l.active = !0 
-                let name = this.id + ":" + size
-                downloaded[name] = downloaded[name] || []
-                /* 
-                this.downloaded = downloaded
-                this.latestPartialRequest = latestPartialRequest 
-                 */
-                latestPartialRequest[name] = null
-                     
-                if (fov) {
-                    let tileArr = []//add 
-                    var d = TileUtils.matchingTilesInDirection(this, size, dir, h, u, tileArr);
-                    
-                    latestPartialRequest[name] = tileArr
-                    downloaded[name].forEach((e)=>{
-                         let item = latestPartialRequest[name].find(a=>e.faceTileIndex == a.faceTileIndex && e.face == a.face)  
-                         if(item){
-                             item.loaded = true
-                         }
-                    })
-                    if(!latestPartialRequest[name].some(e=>!e.loaded)){//所需要的全部加载成功
-                        //let total = TileUtils.getTileCountForSize(size)
-                        //this.onPanoRendered(this.id, size, total, !0);
-                        c.resolve(size/* , total */);
-                        this.resetWaitDeferred(size)
-                        //console.log('该部分早已经加载好了'+size, this.id)
-                        latestPartialRequest[name] = null
-                    }
-                     
-                    //console.log("Loading partial pano: " + this.id + " with " + d + " tiles")
-                }
-                if(!eventAdded[this.id]) {
-                    eventAdded[this.id] = !0 
-                    
-                    this.addEventListener(PanoramaEvents.LoadComplete, function(ev/* e, t */) {//本次任务全部加载完毕 
-                        
-                        //console.warn('点位(可能部分)下载完成 ', 'id:'+this.id,  'size:'+ev.size ) 
-                        
-                        var i = this.getWaitDeferred(ev.size).deferred;//"pending"为还未完成
-                        i && "pending" === i.state() && this.highestPartialTileRenderOpCompleted >= ev.size && (i.resolve(ev.size, ev.count),
-                        this.resetWaitDeferred(ev.size))//恢复active为false
-                         
-                    }.bind(this)) 
-                    
-                    this.addEventListener(PanoramaEvents.LoadFailed, function(ev) {
-                        var t = this.getWaitDeferred(e).deferred;
-                        t && "pending" === t.state() && this.highestPartialTileRenderOpCompleted >= ev.t && (t.reject(ev.t),
-                        this.resetWaitDeferred(ev.t))//恢复active为false
-                    }.bind(this)) 
-                    
-                    this.addEventListener(PanoramaEvents.TileLoaded, function(ev/* t, i, n */) {//每张加载完时
-                        
-                        //console.log('tileLoaded', 'id:'+this.id,  'size:'+ev.size, 'tileIndex:'+ev.index )
-                        let tileIndex = ev.index
-                        let total = ev.count
-                        let size = ev.size
-                        let name = this.id + ":" + size 
-                        downloaded[name] = downloaded[name] || [] //不是所有的加载都是从loadTiledPano获取的所以会有未定义的情况
-                        
-                        let {faceTileIndex,face} = TileUtils.getTileLocation(size, tileIndex, {}) 
-                        downloaded[name].push({faceTileIndex,face})    
-                        var r = this.getWaitDeferred(size).deferred;
-                        if (r && "pending" === r.state()) { 
-                            r.notify(size, tileIndex, total);
-                            if(latestPartialRequest[name]){
-                                let item = latestPartialRequest[name].find(e=>e.faceTileIndex == faceTileIndex && e.face == face)    
-                                item && (item.loaded = true ) 
-                                
-                                if(!latestPartialRequest[name].some(e=>!e.loaded)){//所需要的局部tiles全部加载成功
-                                    this.onPanoRendered(this.id, size, total, !0); //onPanoRendered还会触发 PanoramaEvents.LoadComplete   
-                                    r.resolve(size, total);
-                                    this.resetWaitDeferred(size)
-                                    //console.log('该部分加载好了'+size, this.id)
-                                    latestPartialRequest[name] = null
-                                }
-                                
-                            } 
-                        } 
-
-                        viewer.dispatchEvent('content_changed') 
-    
-                        
-                        /* var r = this.getWaitDeferred(ev.size).deferred;
-                        if (r && "pending" === r.state()) {
-                            r.notify(ev.size, ev.index, ev.count);
-                             
-                            var o = downloads[this.id + ":" + ev.size];
-                            if(o){//如果有规定下载哪些tile,只需要下载这些tile则LoadComplete
-                                o.tileCount++ 
-                                
-                                if(o.tileCount === o.targetTileCount){//达到下载目标数
-                                    this.onPanoRendered(this.id, ev.size, ev.count, !0);
-                                    r.resolve(ev.size, ev.count);
-                                    this.resetWaitDeferred(ev.size)
-                                }
-                            }
-                        } */
-                    }.bind(this))
-                }
-            }
-            this.images360.tileDownloader.clearForceQueue() 
-            this.images360.tileDownloader.forceQueueTilesForPano(this, size, dir, h, u, download) 
-            this.tiledPanoRenderTarget = this.images360.panoRenderer.activateTiledPano(this, this.images360.qualityManager.getMaxNavPanoSize(), o) 
-            this.images360.panoRenderer.renderPanoTiles(this.id, dirs, a)
-            
-        }else{
-            //console.log('早已经全加载好了' +size, this.id)
-            c.resolve(size)
-        }
-        return c.promise()
-    }
-}()
-
-
-/* 
-
-    经观察发现,navvis的也存在的问题是点云和全景有微小的偏差,导致远处的热点在全景和点云上看位置差别感大,比如一个在路上一个在天空上。
-
-
- */
+ 
+ 
 export default Panorama

File diff suppressed because it is too large
+ 0 - 1235
src/custom/modules/panos/tile/PanoRenderer.js


+ 0 - 176
src/custom/modules/panos/tile/QualityManager.js

@@ -1,176 +0,0 @@
-
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
- 
-import browser from '../../../utils/browser.js' 
-import {settings,config} from '../../../settings.js'
- 
-
-
-let {ModelManagerEvents,PanoSizeClass} = Potree.defines
-
-
-export default class QualityManager {
-    constructor(e, t, i) {
-      
-        this.maxNavPanoSize = -1;
-        this.maxZoomPanoSize = -1;
-        this.devicePixelDensity = e;
-        this.deviceScreenSize = t;
-        this.clientBandwidth = i;
-        this.panoSizeClassMap = {};
-        this.useHighResolutionPanos = !0;  //是否能够使用2k及以上图
-        this.useUltraHighResolutionPanos = !1;
-        this.modelHasUltraHighPanos = !1;
-        this.qualityManager = this;
-        
-        this.maxRenderTargetSize = browser.isMobile() ? 2048 : 4096  //add
-        this.init()
-    }
-
-    init(e ) {
-        //var metadata = store.getters['scene/metadata'] ;//有时候请求不到
-        //if(metadata.sceneSource == 11 || metadata.sceneScheme == 12){
-        /* if(config.tileClass == '1k'){
-            this.useHighResolutionPanos = false    //xzw add 只加载1k
-        } */
-         
-        
-        this.buildPanoSizeClassMap(this.devicePixelDensity, this.deviceScreenSize, this.clientBandwidth);
-        this.ultraHighSize = this.getPanoSize(PanoSizeClass.ULTRAHIGH);
-        this.highSize = this.getPanoSize(PanoSizeClass.HIGH);
-        this.standardSize = this.getPanoSize(PanoSizeClass.STANDARD);
-        this.baseSize = this.getPanoSize(PanoSizeClass.BASE);
-        config.tiling.maxZoomPanoQuality && this.ultraHighSize <= config.tiling.maxZoomPanoQuality && (config.tiling.allowUltraHighResolution = !0);
-        this.highQualityThreshold = browser.valueFromHash("threshold2k", config.windowHeightHighQualityThreshold);
-        this.updateMaximums();
-        //e.on(ModelManagerEvents.ActiveModelChanged, this.onModelChanged.bind(this));
-    }
-
-    updateFromModel(e) {
-        //this.updateHighResolutionSettings(e) 
-        this.updateUltraHighResolutionSettings(e)
-    }
-
-    /* updateHighResolutionSettings(e) {
-        this.useHighResolutionPanos = !0 
-        this.updateMaximums()
-    } */
-
-    updateUltraHighResolutionSettings(e) {
-        if (config.tiling.allowUltraHighResolution && this.modelHasUltraHighPanos) {
-            this.useUltraHighResolutionPanos = !0;
-        } else {
-            this.useUltraHighResolutionPanos = !1;
-        }
-        this.updateMaximums();
-    }
-
-    enableUltraHighQualityMode() {
-        this.modelHasUltraHighPanos = !0;
-        this.updateUltraHighResolutionSettings(null);
-    }
-
-    ultraHighQualityModeEnabled() {
-        return this.modelHasUltraHighPanos
-    }
-
-    onModelChanged(e) {
-        this.updateFromModel(e.model),
-            this.updateMaximums()
-    }
-
-    updateMaximums() {
-        this.maxNavPanoSize = config.tiling.maxNavPanoQuality || this.detectMaxNavPanoSize(),
-        this.maxZoomPanoSize = config.tiling.maxZoomPanoQuality || this.detectMaxZoomPanoSize(),
-        this.maxZoomPanoSize < this.maxNavPanoSize && (this.maxNavPanoSize = this.maxZoomPanoSize)
-    }
-
-    buildPanoSizeClassMap() {
-        this.panoSizeClassMap[PanoSizeClass.BASE] = 512,
-            this.panoSizeClassMap[PanoSizeClass.STANDARD] = 1024,
-            this.panoSizeClassMap[PanoSizeClass.HIGH] = 2048,
-            this.panoSizeClassMap[PanoSizeClass.ULTRAHIGH] = 4096
-    }
-
-    getPanoSize(e) {
-        return this.panoSizeClassMap[e]
-    }
-
-    getMaxPossiblePanoSize() {
-        return this.getPanoSize(PanoSizeClass.ULTRAHIGH)
-    }
-
-    getMaxPanoSize() {
-        return this.maxZoomPanoSize
-    }
-
-    getMaxNavPanoSize() {
-        return this.maxNavPanoSize
-    }
-
-    getMaxZoomPanoSize() {
-        return this.maxZoomPanoSize
-    }
-
-    detectMaxNavPanoSizeClass() {
-        //return this.useHighResolutionPanos ? browser.isMobile() ? PanoSizeClass.STANDARD : window.innerHeight < this.highQualityThreshold ? PanoSizeClass.STANDARD : PanoSizeClass.HIGH : PanoSizeClass.STANDARD
-       /*  if(config.name == 'decor'){
-            return PanoSizeClass.STANDARD
-        }
-        return PanoSizeClass.HIGH  */
-        switch(Potree.settings.navTileClass){  
-            case '1k':
-                return PanoSizeClass.STANDARD;
-                break;
-            case '2k':             
-            default:
-                return PanoSizeClass.HIGH;
-        }
-        
-        
-    }
-
-    detectMaxNavPanoSize() {
-        var e = this.detectMaxNavPanoSizeClass();
-        return this.getPanoSize(e)
-    }
-
-    detectMaxZoomPanoSize() { //获取当前zoomRenderTarget应下载的最高级别
-    
-        //若是有三个级别,每次只需要加载到当前的zoomLevel;而两级时因为有zoomed来判断是使用基本贴图还是zoomRenderTarget,所以只需要返回最大的即可
-            
-        if(this.zoomLevelResolution){//有三个级别
-            if(this.zoomLevelResolution == '4k' && this.useUltraHighResolutionPanos){
-                return this.getPanoSize(PanoSizeClass.ULTRAHIGH);
-            }else if(this.zoomLevelResolution == '1k' || !this.useHighResolutionPanos){
-                return this.getPanoSize(PanoSizeClass.STANDARD);
-            }else{
-                return this.getPanoSize(PanoSizeClass.HIGH);
-            }
-        }else{
-            if (this.useHighResolutionPanos) {
-                /* if (browser.isMobile()) {//手机版如果要2k的将这里去掉
-                    if (settings.tiling.mobileHighQualityOverride) {
-                        return this.getPanoSize(PanoSizeClass.HIGH);
-                    } else {
-                        return this.getPanoSize(PanoSizeClass.STANDARD);
-                    }
-                } else  */if (this.useUltraHighResolutionPanos ) {
-                    return this.getPanoSize(PanoSizeClass.ULTRAHIGH);
-                } else {
-                    return this.getPanoSize(PanoSizeClass.HIGH);
-                }
-            } else {
-                return this.getPanoSize(PanoSizeClass.STANDARD);
-            }
-            
-            
-        }
-        
-    }
-    
-    
-    
-    
-    
-}

+ 0 - 556
src/custom/modules/panos/tile/TileDownloader.js

@@ -1,556 +0,0 @@
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
- 
-import TilePrioritizer from './TilePrioritizer.js'
-import TileUtils from './TileUtils.js' 
- 
- 
-import {settings, config} from '../../../settings.js' 
-import {
-    http
-} from '../../../utils/request.js' 
-
-let {TileDownloaderEvents, DownloadStatus} = Potree.defines
-
-
-window.downloaded = {}
-window.startdownloads = [];
-
-
-
-
-class TileDownloader extends THREE.EventDispatcher{
-    constructor( ) {
-        super()
-        this.panos = null;
-        this.retryMinimumTime = 1e4;
-        this.panoLoadCallbacks = {};
-        this.downloadDescriptors = {};
-        this.priorityQueue = [];
-        this.forceQueue = [];
-        this.activeDownloads = [];
-        this.tilePrioritizer = null;
-        this.refreshInterval = null;
-        this.processPriorityQueue = !1;
-        this.concurrentDownloads = 6;//e.concurrentDownloads || 1;
-        this.downloadTestResults = {};
-
-        this.freeze = Object.freeze({
-            Testing: 1,
-            Success: 2,
-            Fail: 3
-        });
-        
-                                                                                  
-         
-        viewer.addEventListener('pageVisible', (e)=>{//不可见时不refreshUpdateInterval 
-            //console.log('visibilitychange:', state)
-            Potree.Utils.updateVisible(this,  'pageVisible', e.v) 
-            this.judgeStart() 
-        }) 
-        
-        this.visible = true //add   借用Potree.Utils.updateVisible来判断是否start
-        if(Potree.settings.useDepthTex){
-            this.judgeStart()  //开始下载depthTex
-        }else{ 
-            Potree.Utils.updateVisible(this,'showPanos', false ) //默认visible = false
-        }
-        
-    }
-
-    setPanoData(e, t /* , i */) {
-        this.panos = e,
-        this.imagePanos = t 
-          //  this.panoGroupId = i
-    }
-  
-    start() { 
-        this.downloadCubeTex = true 
-        if(!Potree.settings.useDepthTex){
-            Potree.Utils.updateVisible(this,'showPanos', true )
-            this.judgeStart()            
-        }else{
-            //this.refreshInterval || this.judgeStart()
-        }
-    }
-
-    stop() {
-        this.downloadCubeTex = false
-        if(!Potree.settings.useDepthTex){
-            Potree.Utils.updateVisible(this,'showPanos', false )
-            this.judgeStart()
-        } 
-    }
-
-    judgeStart(){//add
-        if(this.visible){
-            //console.log('judgeStart true')
-            this.started = true 
-            //this.refreshUpdateInterval(0)
-        }else{
-            //console.log('judgeStart false')
-            this.started = false
-            //window.clearTimeout(this.refreshInterval)
-        }
-        
-    }
-
-    /* refreshUpdateInterval(e) {
-        e || (e = 0),
-            this.refreshInterval = window.setTimeout(function() {
-                    var e = this.update();
-                    e ? this.refreshUpdateInterval(TileDownloader.ACTIVE_REFRESH_DELAY) : this.refreshUpdateInterval(TileDownloader.IDLE_REFRESH_DELAY)
-                }
-                .bind(this), e)
-    } */
-
-    update() { 
-        if(this.downloadCubeTex){ //可以下载贴图
-            var e = this.forceQueue.length > 0;
-            this.processQueueForDownloading(this.forceQueue);
-            if (this.processPriorityQueue) {  
-                Potree.Common.intervalTool.isWaiting('processPriorityQueue', ()=>{ //延时update,防止崩溃 , 未到时间就拦截(第一次直接执行)
-                    this.queuePrioritizedTilesForPanos(this.panos)   //这句比较耗时 降四倍时大概1-2毫秒
-                }, 66)
-                
-                this.priorityQueue.length > 0 && (e = !0);
-                this.processQueueForDownloading(this.priorityQueue);
-            }
-            //return e 
-        } 
-        Potree.Common.intervalTool.isWaiting('filterDepthTex', ()=>{ 
-            this.tilePrioritizer.filterDepthTex(this.panos)//下载深度图
-        }, 77)
-        
-        
-         
-        
-    }
-
-    
-
-    queuePrioritizedTilesForPanos(e) {
-        this.tilePrioritizer && (this.clearQueue(this.priorityQueue),
-            this.tilePrioritizer.filterAndPrioritize(this.priorityQueue, e, this),
-            this.clearFromQueue(this.priorityQueue, DownloadStatus.None, !0),  //去除state为DownloadStatus.None的(可能是去除已经在下载的)
-            this.setStatusOrRemoveForAllDescriptors(this.priorityQueue, DownloadStatus.Queued))
-    }
-
-    clearQueue(e) {//停止下载并清空
-        this.setStatusForAllDescriptors(e, DownloadStatus.None),
-            e.length = 0
-    }
-    
-    clearForceQueue() {
-        this.clearQueue(this.forceQueue)
-    }
-    
-    clearFromQueue(e, t, i) {
-        for (var n = 0; n < e.length; n++) {
-            var r = e[n];
-            r && (t === r.status && !i || t !== r.status && i) && (e[n] = null)
-        }
-    }
-
-    setStatusForAllDescriptors(e, t) {
-        for (var i = 0; i < e.length; i++) {
-            var n = e[i];
-            n && (n.status = t)
-        }
-    }
-
-    setStatusOrRemoveForAllDescriptors(e, t) {
-        for (var i = 0; i < e.length; i++) {
-            var n = e[i];
-            n && (n.status !== t ? n.status = t : e[i] = null)
-        }
-    }
-
-    getTileDownloadDescriptors(pano, size) {//获取该pano的该size的全部的tile的descriptor
-        var i = this.getAllTileDownloadDescriptorsForPano(pano),
-            n = i[size];
-        return n || (n = this.buildDownloadDescriptorArray(size),//创建的全部是空的
-                i[size] = n,
-                this.initTileDownloadDescriptors(n, pano, size)),//绑定到该pano size
-            n
-    }
-
-    getAllTileDownloadDescriptorsForPano(pano) {//新建空Descriptors
-        var t = this.downloadDescriptors[pano.id];
-        return t || (t = {},
-                this.downloadDescriptors[pano.id] = t),
-            t
-    }
-
-    processQueueForDownloading(e, t) {//执行下载任务
-        this.cleanupActiveDownloads();
-        if(e.length){
-            let concurrentDownloads = Potree.Common.getBestCount('concurrentDownloads',1,6,    1.8, 14/* ,true */) //flying ? (isMobile ? 2 : 3) : 6 
-            
-            if (this.activeDownloads.length < concurrentDownloads || t) {
-                var i = t ? e.length : concurrentDownloads - this.activeDownloads.length;
-
-                for (var n = 0, r = 0; n < i && e.length > 0; r++) {
-                    var o = e.shift();
-                    
-                    
-                    if(o){
-                        //add 为了防止1024的在512前下载完,这里强行等待512下载完毕再开始下载
-                        if(o.panoSize > 512 && !this.isPanoDownloaded(o.pano, 512) ){
-                            //console.log('512的还没下载好呢!')
-                            e.push(o)
-                            break;//一般512的都是连续下载的,所以后面就都不是512了直接中断 
-                        } 
-                        
-                        this.startDownload(o)
-                        n++
-                    }
-                    
-                }
-            }
-        }
-    } 
-    
-    
-    
-    
-    testDownload(panoSize, tileSize, callback) {
-        var n = this.downloadTestResults[panoSize];
-        if (n)
-            return void(n === this.freeze.Success ? callback(!0) : n === this.freeze.Fail && callback(!1));
-        this.downloadTestResults[panoSize] = this.freeze.Testing;
-        var r = this.panos[0],
-            o = this.getTileUrl({pano:r, panoSize, tileSize, tileIndex:0}   /* r.id, panoSize, tileSize, 0 */),
-            a = function(t) {
-                this.downloadTestResults[panoSize] = this.freeze.Success,
-                    callback(!0)
-            }
-            .bind(this),
-            s = function() {
-                this.downloadTestResults[panoSize] = this.freeze.Fail,
-                    callback(!1)
-            }
-            .bind(this);
-        this.loadImage(o, 0, a, s)
-    }
-
-    startDownload(e) {//开始下载啦
-        //console.log('startDownload')
-        
-        startdownloads.push(e) 
-        e.local2SrcFailed = this.local2SrcFailed
-        e.status = DownloadStatus.Downloading;
-        var t = this.getTileUrl(e/* e.pano.id, e.panoSize, e.tileSize, e.tileIndex, e.pano.alignmentType */);//xzw add alignmentType
-        if(!t)return;
-        this.activeDownloads.push(e);
-        this.loadImage(t, TileDownloader.DOWNLOAD_RETRIES, this.downloadComplete.bind(this, e), this.downloadFailed.bind(this, e))
-    }
-
-    downloadFailed(e, t) {
-        //add 
-        if(Potree.settings.isLocal2 && !e.local2SrcFailed){//为了兼容旧的数据src,如果新src没加载成功,就加载旧的
-            e.local2SrcFailed = this.local2SrcFailed = true
-            //this.startDownload(e)//重新下载
-            var t = this.getTileUrl(e); 
-            this.loadImage(t, TileDownloader.DOWNLOAD_RETRIES, this.downloadComplete.bind(this, e), this.downloadFailed.bind(this, e))
- 
-        }
-    }
-
-    downloadComplete(e, t) {//下载成功时
-        //if (e.panoGroupId === this.panoGroupId) {
-            var i = this.getPanoLoadCallbacks(e.pano, e.panoSize);
-            e.status = DownloadStatus.Downloaded,
-                i && i.onProgress && i.onProgress(e.pano, e.panoSize);
-            var n = {
-                panoId: e.pano.id,
-                image: t,
-                tileSize: e.tileSize,
-                panoSize: e.panoSize,
-                tileIndex: e.tileIndex,
-                faceTileIndex: e.faceTileIndex,
-                totalTiles: e.totalTiles,
-                face: e.face,
-                tileX: e.tileX,
-                tileY: e.tileY,
-                direction: e.direction
-            };
-            
-            downloaded[e.pano.id] || (downloaded[e.pano.id]={512:[],1024:[],2048:[]})
-            downloaded[e.pano.id][e.panoSize] || (downloaded[e.pano.id][e.panoSize] = [])
-            downloaded[e.pano.id][e.panoSize].push(e)
-            if(e.panoSize != 512 && downloaded[e.pano.id][512].length<6){
-                console.warn('没下完')
-            }
-            
-            
-            
-            e.image = t,
-            this.dispatchEvent({type:TileDownloaderEvents.TileDownloadSuccess, desc:n} ) 
-            this.isPanoDownloaded(e.pano, e.panoSize) && (n = {
-                    panoId: e.pano.id,
-                    tileSize: e.tileSize,
-                    panoSize: e.panoSize
-                },
-                this.dispatchEvent({type:TileDownloaderEvents.PanoDownloadComplete, desc:n}),
-                i && i.onLoad && i.onLoad(e.pano, e.panoSize))
-        //}
-    }
-
-
-    isPanoDownloaded(e, t) {
-        var i = this.getTileDownloadDescriptors(e, t);
-        if (i.length <= 0)
-            return !1;
-        for (var n = 0; n < i.length; n++) {
-            var r = i[n];
-            if (r.status !== DownloadStatus.Downloaded)
-                return !1
-        }
-        return !0
-    }
-
-    setPanoLoadCallbacks(e, t, i, n, r) {
-        var o = e.id + ":" + this.qualityManager.getPanoSize(t);
-        this.panoLoadCallbacks[o] = {
-            onLoad: i,
-            onFail: n,
-            onProgress: r
-        }
-    }
-
-    getPanoLoadCallbacks(e, t) {
-        var i = e.id + ":" + t;
-        return this.panoLoadCallbacks[i]
-    }
-
-    buildDownloadDescriptorArray(e) {
-        for (var t = TileUtils.getTileCountForSize(e), i = [], n = 0; n < t; n++) {
-            var r = this.buildDownloadDescriptor();
-            i.push(r)
-        }
-        return i
-    }
-
-    buildDownloadDescriptor() {//Descriptor!
-        var e = {
-            panoGroupId: null,
-            pano: null,
-            panoSize: -1,
-            tileSize: -1,
-            tileIndex: -1,
-            totalTiles: -1,
-            faceTileIndex: -1,
-            status: DownloadStatus.None,
-            url: null,
-            image: null,
-            direction: new THREE.Vector3, //该tile在cube中的方向
-            face: -1,
-            cubeFace: -1,
-            tileX: -1,
-            tileY: -1
-        };
-        return e
-    }
-
-    initTileDownloadDescriptors(e, t, i) {
-        for (var n = 0; n < e.length; n++) {
-            var r = e[n];
-            this.initTileDownloadDescriptor(r, t, i, n)
-        }
-    }
-
-    initTileDownloadDescriptor(desc, pano, size, index) {
-        var r = size >= TileUtils.TILE_SIZE ? TileUtils.TILE_SIZE : size;
-        desc.face = TileUtils.getFaceForTile(size, index);//根据顺序得到的face的index
-        desc.cubeFace = TileUtils.mapFaceToCubemapFace(desc.face);//为了贴图而转化的face index
-        //desc.panoGroupId = this.panoGroupId;//就是场景号
-        desc.pano = pano;
-        desc.panoSize = size;
-        desc.tileSize = r;      //瓦片图size 512
-        desc.tileIndex = index;
-        desc.totalTiles = TileUtils.getTileCountForSize(size);
-        desc.status = DownloadStatus.None;
-        desc.image = null;
-        TileUtils.getTileLocation(desc.panoSize, desc.tileIndex, desc);//得到该tile在这个face中的具体位置(tileX等)
-        TileUtils.getTileVector(desc.panoSize, desc.tileSize, desc.cubeFace, desc.tileX, desc.tileY, TileUtils.LocationOnTile.Center, 0, desc.direction);
-    }
-
-    
-
-    getTiles(d, sceneNum, useV4url){
-        if(Potree.settings.isLocal2 && !this.local2SrcFailed || useV4url){//新的地址  scene_view_data/场景码/images/tiles
-            return `${Potree.settings.urls.prefix3}/scene_view_data/${sceneNum}/images/${d}`    
-        }
-        
-        return `${Potree.settings.urls.prefix3}/images/images${sceneNum}/${d}`    
-    }
-
-    loadImage(e, t, i, n) {
-        //自己修改了ajax,把getImage改成了loadImg
-        http.loadImage(e, t).then(function(e) {
-            i(e)
-        }).fail(n)
-    }
-}
-TileDownloader.prototype.forceQueueTilesForPano = function() {//根据条件开始加载tile
-    var e = [],
-        t = [];
-    return function(pano, size, dir, hFov, vFov, download) { 
-        e.length = 0;
-        for (var u = this.getTileDownloadDescriptors(pano, size), d = 0; d < u.length; d++) {
-            var p = u[d];
-            p.status !== DownloadStatus.None && p.status !== DownloadStatus.Queued || e.push(p)
-        }
-        if (dir && e.length > 0) {
-            TilePrioritizer.sortPanoTiles(e, pano, dir) //按最佳方向排序e
-            t.length = 0 
-            TileUtils.matchingTilesInDirection(pano, size, dir, hFov, vFov, t);//得到在符合视野标准的集合t
-            
-            
-            
-            for (var f = 0, g = function(e) {
-                return e.face === m.face && e.faceTileIndex === m.faceTileIndex
-            }; f < e.length;) {  //过滤掉不符合角度要求的
-                var m = e[f],
-                    v = t.findIndex(g);
-                v < 0 ? e.splice(f, 1) : f++
-            }
-        }
-        for (var A = 0; A < e.length; A++){
-            this.forceQueue.push(e[A]);         //装载
-        }
-        /* if(e.length){
-            console.log(e)
-        } */
-        
-        this.setStatusForAllDescriptors(this.forceQueue, DownloadStatus.ForceQueued);
-        this.clearFromQueue(this.priorityQueue, DownloadStatus.ForceQueued, !1);
-        download && this.processQueueForDownloading(this.forceQueue, !0);
-    }
-}()
-
-TileDownloader.prototype.cleanupActiveDownloads = function() {
-    var e = [];
-    return function() {
-        e.length = 0;
-        for (var t = 0; t < this.activeDownloads.length; t++) {
-            var i = this.activeDownloads[t];
-            i.status !== DownloadStatus.Downloaded && i.status !== DownloadStatus.Failed && e.push(i)
-        }
-        this.activeDownloads.length = 0,
-        this.activeDownloads.push.apply(this.activeDownloads, e)
-    }
-}()
-
-TileDownloader.prototype.getTileUrl = function() {
-    var e = {
-            256: "256",
-            512: "512",
-            1024: "1k",
-            2048: "2k",
-            4096: "4k"
-        },
-        t = {
-            face: -1,
-            faceTileIndex: -1,
-            tileX: -1,
-            tileY: -1
-        };
-    
-    return function(o={}  ) {  
-        var id = o.pano.originID, ////////
-            panoSize = o.panoSize,
-            tileSize = o.tileSize,
-            tileIndex = o.tileIndex,
-            sceneCode = o.pano.pointcloud.sceneCode,
-            useV4url = Potree.settings.useV4url && o.pano.pointcloud.datasetData.sceneVersion == 'V4'        //v4的全景图等路径不一样  
-        var metadata = {sceneScheme:10}  
-        
-        
-        TileUtils.getTileLocation(panoSize, tileIndex, t);
-        var s = Math.floor(panoSize / tileSize),
-            l = s * s,
-            h = Math.floor(tileIndex / l),
-            u = "",
-            d = '',  g = '';
-        
-        
-        
-        if(Potree.settings.isLocal){//原始规则
-            //1 === config.tiling.customCompression && (u = "_" + config.tiling["q" + e[panoSize]]);
-            //1 === o.tiling.customCompression && (u = "_" + o.tiling["q" + e[n]]);
-            d = "tiles/" + id + "/" + e[panoSize] + u + "_face" + h + "_" + t.tileX + "_" + t.tileY + ".jpg" 
-            d =  this.getTiles(d, sceneCode, useV4url);
-            g = "?"  
-          
-        }else{//阿里云oss的规则   if (metadata.sceneScheme == 10) 
-            
-            d = 'tiles/4k/' + id + '_skybox' + h + '.jpg?x-oss-process=';
-            if (e[panoSize] == '512') {
-                d += 'image/resize,h_512';
-            } else {
-                //4k的图,移动端是1k,pc端是2k,放大才是4k
-                if (e[panoSize] == '1k' || e[panoSize] == '2k') {  //https://4dkk.4dage.com/images/imagesx4iqYDG3/tiles/4k/122_skybox0.jpg?x-oss-process=image/resize,m_lfit,w_1024/crop,w_512,h_512,x_511,y_0
-                    d += 'image/resize,m_lfit,w_' + panoSize + '/crop,w_512,h_512,';
-                } else {
-                    d = 'tiles/4k/' + id + '_skybox' + h + '.jpg?x-oss-process=image/crop,w_512,h_512,';
-                }
-                //起始位置
-                if (t.tileX == 0) {
-                    d += 'x_0,';
-                } else {
-                    d += 'x_' + (512 * t.tileX /* - 1 */) + ',';
-                }
-
-                if (t.tileY == 0) {
-                    d += 'y_0';
-                } else {
-                    d += 'y_' + (512 * t.tileY /* - 1 */);
-                } 
-            }
-            
-            d = this.getTiles(d, sceneCode, useV4url);
-            g = "&" 
-        } 
-        
-        d += g + 'time='+o.pano.pointcloud.timeStamp  //加后缀
-         
-        return d;
-    }
-}();
-
-TileDownloader.tilegen = true;
-TileDownloader.IDLE_REFRESH_DELAY = 500;
-TileDownloader.ACTIVE_REFRESH_DELAY = 16;
-TileDownloader.DOWNLOAD_RETRIES = 4;
-
-
-
-
-/* 
-源:https://4dkk.4dage.com/images/imagesSS-t-ZZR7oKnlIl
-目标:https://4dkk.4dage.com/scene_view_data/SS-t-ZZR7oKnlIl/images
-
-源:https://4dkk.4dage.com/data/dataSS-t-ZZR7oKnlIl
-目标:https://4dkk.4dage.com/scene_view_data/SS-t-ZZR7oKnlIl/data
-
-源:https://4dkk.4dage.com/video/videoSS-t-ZZR7oKnlIl
-目标:https://4dkk.4dage.com/scene_view_data/SS-t-ZZR7oKnlIl/video
- */
-
-
-// var tileconc = TileDownloader.tilegen ? 6 : 2;
-// publicObjectSet.tileDownloader = new TileDownloader({
-//     concurrentDownloads: tileconc
-// });
-
-// export default new  TileDownloader({
-//     concurrentDownloads: TileDownloader.tilegen ? 6 : 2
-// })
-
-
-/* export default new TileDownloader({
-    concurrentDownloads: TileDownloader.tilegen ? 6 : 2
-}) */
-
-export default TileDownloader

+ 0 - 415
src/custom/modules/panos/tile/TilePrioritizer.js

@@ -1,415 +0,0 @@
- 
-
-import {Images360} from '../Images360.js'
-import TileUtils from './TileUtils.js'
-import cameraLight from '../../../utils/cameraLight.js'
-import math from '../../../utils/math.js'
-import Common from '../../../utils/Common.js' 
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
-
-import browser from '../../../utils/browser.js'
-
-
-
-
-
-let {DownloadStatus} = Potree.defines
-
-var h = Object.freeze({
-    None: 0,
-    DirectionalFOV: 1
-});
-
-var u = function () {
-    var e = function e(t, i) {
-        var n = e._panoSpaceDir,
-            r = e._fovThreshold,
-            o = e._fovThresholdNarrow,
-            a = Math.max(Math.min(n.dot(t.direction), 1), -1),
-            s = Math.max(Math.min(n.dot(i.direction), 1), -1);
-        return t._dot = a,
-            i._dot = s,
-            a >= r && s < r ? -1 : a < r && s >= r ? 1 : a >= o && s < o ? -1 : a < o && s >= o ? 1 : t.panoSize > i.panoSize ? 1 : i.panoSize > t.panoSize ? -1 : -(a - s)
-    };
-    return e._panoSpaceDir = new THREE.Vector3,
-        e._fovThreshold = -1,
-        e._fovThresholdNarrow = -1,
-        e
-}();
-
-export default class TilePrioritizer {//优先级处理序列
-    constructor(e,t, i, o, a) {
-        this.qualityManager = e;
-        this.maxNavQuality = this.qualityManager.getMaxNavPanoSize();
-        this.maxZoomQuality = this.qualityManager.getMaxZoomPanoSize();
-        this.baseSize = t;
-        this.standardSize = i;
-        this.highSize = o;
-        this.ultraHighSize = a;
-        this.priorityCriteria = new TilePrioritizer.PriorityCriteria(null, new THREE.Vector3(0, 0, 0), new THREE.Vector3(0, 0, -1), new THREE.Vector3(0, 0, -1));
-    }
-
-    updateCriteria(e, t, i, n) {//由player更新
-        this.priorityCriteria.pano = e,
-        this.priorityCriteria.cameraPosition.copy(t),
-        //this.priorityCriteria.cameraDir.copy(i),
-        this.priorityCriteria.cameraDirs = i
-        
-        this.priorityCriteria.upcomingPanos = n,
-        this.maxNavQuality = this.qualityManager.getMaxNavPanoSize(),
-        this.maxZoomQuality = this.qualityManager.getMaxZoomPanoSize()
-          
-            
-    }
-
-    canDownloadSize(e) {
-        return this.maxNavQuality >= e || this.maxZoomQuality >= e && this.zoomingActive
-    }
-
-   
-
-
-
-    /* populateNeighborPanos(e, t, i) {
-        i = i || [],
-            i.length = 0;
-        var n = t.getNeighbours(e);
-        for (var r in n)
-            if (n.hasOwnProperty(r)) {
-                var o = t.get(r);
-                if(!o){
-                    console.log(1)
-                }
-                i.push(o)
-            }
-        return i
-    } */
-
-    populateScoredPanos(e, t, i, dirs, a, dontFilterDir) {
-        i = i || [],
-            i.length = 0;
-            
-            
-        var s = [Images360.filters.not(e)],
-            l = [Images360.scoreFunctions.distanceSquared(e), Images360.scoreFunctions.direction(e.position, dirs)],
-            c = Common.sortByScore(t, s, l);  
-        if(!dontFilterDir){
-            s.push(Images360.filters.inPanoDirection(e.position, dirs, TilePrioritizer.DIRECTION_SCORE_STRICTNESS),)
-        }    
-            
-        if (c)
-            for (var h = 0; h < c.length && h < a; h++) {
-                var u = c[h].item;
-                i.push(u)
-            }
-        return i
-    }
-
-    queueTilesForPanos(e, t, i, n, r) {
-        for (var o = 0, a = 0; a < t.length; a++) {
-            var s = t[a],
-                l = this.queueTilesForPano(e, i, s, n);
-            if (o += l > 0 ? 1 : 0,
-                r && o >= r)
-                break
-        }
-        return o
-    }
-
-
-    /* queueTilesInDirectionForPanos(e, t, i, n, r, o, a, s) {//没用到
-        for (var l = 0, c = 0; c < i.length; c++) {
-            var h = i[c],
-                u = this.queueTilesInDirectionForPano(e, t, h, n, o, a);
-            if (l += u > 0 ? 1 : 0,
-                s && l >= s)
-                break
-        }
-        return l
-    }
-    */
-
-    canIncludeDescriptor(e) {
-        return e.status !== DownloadStatus.Downloading && e.status !== DownloadStatus.Downloaded
-    }
-
-    canIncludePano(e, t) {
-        return !e.isLoaded(t)
-    }
-
-    getFOVDotThreshold(e) {
-        return Math.cos(THREE.Math.degToRad(e / 2))
-    }
-
-    setZoomingActive(e) {
-        e !== this.zoomingActive && (this.zoomingActive = e)
-    }
-}
-
-TilePrioritizer.PriorityCriteria = function (e, t, i, n, o) {
-    this.pano = e,
-        this.cameraPosition = (new THREE.Vector3).copy(t),
-        
-        //this.cameraDir = (new THREE.Vector3).copy(i), 
-        this.cameraDirs = [], //
-        
-        this.panoSpaceDir = (new THREE.Vector3).copy(n),
-        this.upcomingPanos = o,
-        this.copy = function (e) {
-            this.pano = e.pano,
-            this.cameraPosition.copy(e.cameraPosition),
-            //this.cameraDir.copy(e.cameraDir),
-            this.cameraDirs = e.cameraDirs
-            
-            this.panoSpaceDir.copy(e.panoSpaceDir),
-            this.upcomingPanos = o
-        },
-        this.zoomingActive = !1
-}
-
-TilePrioritizer.DIRECTIONAL_FOV = 180;
-TilePrioritizer.DIRECTIONAL_FOV_NARROW = 120;
-TilePrioritizer.MAX_SCORED_PANOS_TOCONSIDER = 6;
-TilePrioritizer.MAX_SCORED_PANOS_TOADD = 2;
-TilePrioritizer.MAX_UPCOMING_PANOS_TOADD = 3;
-TilePrioritizer.DIRECTION_SCORE_STRICTNESS = .75;
-TilePrioritizer.appendQueue = function (e, t) {
-    if (e && t)
-        for (var i = 0; i < t.length; i++){
-            e.push(t[i])
-            //console.log(t[i])
-        }
-};
-
-TilePrioritizer.sortPanoTiles = function (descriptors, pano, dir) {
-    if(dir.datasetsLocal)  dir = dir.datasetsLocal.find(e=>e.datasetId == pano.pointcloud.dataset_id).direction;//add
-    u._panoSpaceDir.copy(dir) 
-    TileUtils.getRelativeDirection(pano.quaternion4dkk, u._panoSpaceDir) //应该是将dir根据quaternion转化下
-    u._fovThresholdNarrow = math.getFOVDotThreshold(TilePrioritizer.DIRECTIONAL_FOV_NARROW)
-    u._fovThreshold = math.getFOVDotThreshold(TilePrioritizer.DIRECTIONAL_FOV) 
-    descriptors.sort(u)
-};
-
-TilePrioritizer.insertSortedPanoTile = function (e, t, pano, dir) {
-    if(dir.datasetsLocal)  dir = dir.datasetsLocal.find(e=>e.datasetId == pano.pointcloud.dataset_id).direction;//add
-    u._panoSpaceDir.copy(dir),
-        TileUtils.getRelativeDirection(pano.quaternion4dkk, u._panoSpaceDir),
-        u._fovThresholdNarrow = math.getFOVDotThreshold(TilePrioritizer.DIRECTIONAL_FOV_NARROW),
-        u._fovThreshold = math.getFOVDotThreshold(TilePrioritizer.DIRECTIONAL_FOV);
-    for (var o = -1, a = 0; a < e.length; a++) {
-        var s = u(t, e[a]);
-        if (s <= 0) {
-            o = a;
-            break
-        }
-    }
-    if (o === -1)
-        e[e.length] = t;
-    else {
-        for (var h = e.length; h > o; h--)
-            e[h] = e[h - 1];
-        e[o] = t
-    }
-};
-
-
-
-TilePrioritizer.prototype.filterDepthTex = function (panos ) {// 下载depthTex
-    if(!Potree.settings.useDepthTex || !this.priorityCriteria.pano || viewer.mainViewport.view.isFlying())return
-    
-    let cameraDirLocals = this.priorityCriteria.cameraDirs.vectorForward
-    let nearPanos = [] //用于获得邻近点位序列 
-    
-    this.populateScoredPanos(this.priorityCriteria.pano, panos, nearPanos, cameraDirLocals , Infinity, true);
-    
-    
-     
-    let depTexDlCount = browser.isMobile() ? 1 : 2; 
-    
-    let loadingCount = panos.filter(p=>p.depthTexLoading).length
-    if(loadingCount<depTexDlCount){
-        nearPanos.filter(p=>!p.depthTex).slice(0, depTexDlCount-loadingCount).forEach(p=>p.loadDepthImg())  
-    }
-    this.nearPanos = nearPanos; 
-}
-
-
-
-TilePrioritizer.prototype.filterAndPrioritize = function () {//挑选出优先加载的 pano和tile (有点复杂,没看很懂)
-    var e = [],
-        t = [],
-        i = [];
-    return function (queue, panos, tileDownloader) {
-        //this.populateNeighborPanos(this.priorityCriteria.pano, panos, e);
-         
-        /* let cameraDirLocals = this.priorityCriteria.cameraDirs.map(e=>{ //add
-            var dataset = viewer.scene.pointclouds.find(u=>u.dataset_id == e.datasetId)
-            var matrix = new THREE.Matrix4().copy(dataset.rotateMatrix)
-            var direction = math.convertVector.YupToZup(e.direction)  
-        
-        
-            return {
-                datasetId:e.datasetId,
-                direction: direction.clone().applyMatrix4(matrix)
-            }
-        }) */
-        let cameraDirLocals = this.priorityCriteria.cameraDirs.vectorForward
-         
-        //获得视野范围内的邻近点位序列t
-        this.populateScoredPanos(this.priorityCriteria.pano, panos, t, cameraDirLocals , TilePrioritizer.MAX_SCORED_PANOS_TOCONSIDER);
-        
-        
-        //t.filter(p=>!p.depthTex).slice(0, Potree.config.depTexDlCount).forEach(p=>p.loadDepthImg()) //add
-        
-        var s = this.baseSize //512
-            ,
-            l = this.standardSize //1024
-            ,
-            c = this.highSize //2048
-            ,
-            h = this.ultraHighSize; //4096
-            
-            
-        this.queueTilesForPano(queue, tileDownloader, this.priorityCriteria.pano, s);  //把当前pano的512下载了
-        
-        
-        if (this.priorityCriteria.upcomingPanos) {// 添加即将走到的点(之前用于导览路线)512 tiles
-            this.queueTilesForPanos(queue, this.priorityCriteria.upcomingPanos, tileDownloader, s, TilePrioritizer.MAX_UPCOMING_PANOS_TOADD);
-        }
-        i.length = 0;
-        
-        //把当前pano角度范围内的tile按照分辨率从低到高加入队列
-        
-        if (this.canDownloadSize(l)) {//1024如果在限制范围内的话
-            this.queueTilesInDirectionForPano(i, tileDownloader, this.priorityCriteria.pano, l, this.priorityCriteria.cameraPosition, this.priorityCriteria.cameraDirs, TilePrioritizer.DIRECTIONAL_FOV_NARROW);
-        } 
-        TilePrioritizer.sortPanoTiles(i, this.priorityCriteria.pano, this.priorityCriteria.cameraDirs); //排序
-        TilePrioritizer.appendQueue(queue, i);
-        
-        //添加邻近点t 512的tiles
-        this.queueTilesForPanos(queue, t, tileDownloader, s, TilePrioritizer.MAX_SCORED_PANOS_TOADD);
-        i.length = 0;
-        
-        
-        //NARROW    :
-        if (this.canDownloadSize(c)) {//2048
-            this.queueTilesInDirectionForPano(i, tileDownloader, this.priorityCriteria.pano, c, this.priorityCriteria.cameraPosition, this.priorityCriteria.cameraDirs, TilePrioritizer.DIRECTIONAL_FOV_NARROW);
-        }
-
-        if (this.canDownloadSize(h)) {//4096
-            this.queueTilesInDirectionForPano(i, tileDownloader, this.priorityCriteria.pano, h, this.priorityCriteria.cameraPosition, this.priorityCriteria.cameraDirs, TilePrioritizer.DIRECTIONAL_FOV_NARROW);
-        } 
-        TilePrioritizer.sortPanoTiles(i, this.priorityCriteria.pano, this.priorityCriteria.cameraDirs);//排序
-        TilePrioritizer.appendQueue(queue, i);
-        i.length = 0;
-
-        if (this.canDownloadSize(l)) {//1024
-            this.queueTilesInDirectionForPano(i, tileDownloader, this.priorityCriteria.pano, l, this.priorityCriteria.cameraPosition, this.priorityCriteria.cameraDirs, TilePrioritizer.DIRECTIONAL_FOV);
-        }
-
-        if (this.canDownloadSize(c)) {//2048
-            this.queueTilesInDirectionForPano(i, tileDownloader, this.priorityCriteria.pano, c, this.priorityCriteria.cameraPosition, this.priorityCriteria.cameraDirs, TilePrioritizer.DIRECTIONAL_FOV);
-        }
-
-        if (this.canDownloadSize(h)) {//4096
-            this.queueTilesInDirectionForPano(i, tileDownloader, this.priorityCriteria.pano, h, this.priorityCriteria.cameraPosition, this.priorityCriteria.cameraDirs, TilePrioritizer.DIRECTIONAL_FOV);
-        }
-
-        TilePrioritizer.sortPanoTiles(i, this.priorityCriteria.pano, this.priorityCriteria.cameraDirs);//排序
-        TilePrioritizer.appendQueue(queue, i);
-        
-        
-        
-        this.queueTilesForPanos(queue, e, tileDownloader, s); // 如果前面有populateNeighborPanos的话,这步就是加neibour
-    }
-}()
-TilePrioritizer.prototype.queueTilesInDirectionForPano = function () {
-    var e = {
-            filter: h.DirectionalFOV,
-            direction: new THREE.Vector3,
-            fov: 60
-        },
-        t = new THREE.Vector3;
-    return function (i, n, pano, o, a, dirs, c) {
-        
-        var dir = dirs.datasetsLocal.find(e=>e.datasetId == pano.pointcloud.dataset_id).direction;//add
-        //var dir = dirs
-        
-        t.copy(dir);
-        
-        TileUtils.getRelativeDirection(pano.quaternion4dkk, t);
-        e.direction.copy(t);
-        e.fov = c;
-        return this.filterAndQueueTileDownloadDescriptors(i, n, pano, o, e)
-    }
-}()
-
-TilePrioritizer.prototype.filterAndQueueTileDownloadDescriptors = function () {
-    var e = [];
-    return function (t, i, n, r, o) {
-        var a = i.getTileDownloadDescriptors(n, r);
-        e.length = 0,
-            this.filterTileDownloadDescriptors(n, a, e, o);
-        for (var s = 0, l = 0; l < e.length; l++) {
-            var c = e[l];
-            if (c) {
-                t.push(c);
-                s++;
-            }
-        }
-        return s
-    }
-}()
-
-TilePrioritizer.prototype.filterTileDownloadDescriptors = function () {
-    new THREE.Vector3;
-    return function (e, t, i, n) {
-        var r, o;
-        switch (n.filter) {
-            case h.DirectionalFOV:
-                for (r = 0; r < t.length; r++)
-                    o = t[r],
-                    TileUtils.isTileWithinFOV(o.panoSize, o.tileSize, o.face, o.tileX, o.tileY, n.direction, n.fov) && i.push(o);
-                break;
-            default:
-                for (r = 0; r < t.length; r++)
-                    o = t[r],
-                    i.push(o)
-        }
-        for (r = 0; r < i.length; r++)
-            o = i[r],
-            this.canIncludeDescriptor(o) || (i[r] = null)
-    }
-}()
-TilePrioritizer.prototype.queueTilesForPano = function () {
-    var e = {
-        filter: h.None
-    };
-    return function (t, i, n, r) {
-        return this.filterAndQueueTileDownloadDescriptors(t, i, n, r, e)
-    }
-}()
-
-
-
-/* TilePrioritizer.prototype.queueTilesForPanosInDirection = function () { //没用到
-    var e = new THREE.Vector3;
-    return function (t, i, n, r, o, a, s, l) {
-        for (var h = 0, u = 0; u < n.length; u++) {
-            var d = n[u];
-            e.copy(d.position),
-                e.sub(o),
-                e.normalize();
-            var p = Math.max(Math.min(a.dot(e), 1), -1),
-                f = c.getFOVDotThreshold(s);
-            if (p >= f) {
-                var g = this.queueTilesInDirectionForPano(t, i, d, r, o, a, s);
-                if (h += g > 0 ? 1 : 0,
-                    l && h >= l)
-                    break
-            }
-        }
-        return h
-    }
-}() */
-

+ 0 - 168
src/custom/modules/panos/tile/TileTree.js

@@ -1,168 +0,0 @@
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
-
-
-function Node(e, t) {
-    this.tree = e,  //所属树(TileTree)
-    this.parent = t,
-    this.children = [],
-    this.id = ++u;
-}
-
-function o(e, t, i, r, a, s, l, h) {
-    if (e) {
-        l = l || TileTree.TraversalType.PreOrder;
-        var u = r * c + i;
-        if (l === TileTree.TraversalType.PreOrder && (a && a(e, t, u, i, r),
-                s && s.push(e)),
-            e.children && 0 !== e.children.length) {
-            for (var d = r * c, p = i * c, f = 0; f < c; f++)
-                for (var g = 0; g < c; g++)
-                    o(e.children[g * c + f], t + 1, p + f, d + g, a, s, l, h);
-            l === TileTree.TraversalType.PostOrder && (a && a(e, t, u, i, r),
-                s && s.push(e))
-        }
-    }
-}
-
-function Plant(seed) {
-    seed.root = Branch(seed, null, 0)
-}
-
-function Branch(seed, parent, level) {
-    if (level > seed.levels)
-        return null;
-    var node = new Node(seed, parent);
-    seed.allNodes.push(node);
-    for (var o = 0; o < h; o++)
-        node.children[o] = Branch(seed, node, level + 1);
-    return node
-}
-
-function l(parent, t, level, n, r) {
-    if (!parent)
-        return null;
-    if (0 === level)
-        return parent;
-    if (!parent.children || 0 === parent.children.length)
-        return null;
-    var o = Math.pow(c, level),
-        a = o / c,
-        s = n % a,
-        h = r % a,
-        u = Math.floor(r / a),
-        d = Math.floor(n / a),
-        p = u * c + d,
-        f = parent.children[p];
-    return l(f, t + 1, level - 1, s, h)
-}
-
-
-/*  cube每个面都有一个分层树  用于代表瓦片图的细分?
-
-    树4096的分为三层,每层有4个子节点。(最后一层的四个子节点都是null)
-
- */
- 
- 
-var c = 2,
-    h = c * c; //4个子节点
-var u = 0;
-
-
-
-
-export default class TileTree {
-    constructor(e, t) {
-        this.levels = t,
-        this.tileSize = e,
-        this.root = null,
-        this.allNodes = [],
-        Plant(this);
-    }
-
-    getSubNode(e, t, i) {
-        (!t || e < this.tileSize) && (t = 0),
-        (!i || e < this.tileSize) && (i = 0),
-        e < this.tileSize && (e = this.tileSize);
-        var level = TileTree.getLevelCountForSize(this.tileSize, e),
-            o = l(this.root, 0, level, t, i);
-        return o
-    }
-
-    breadthFirst(e) {//广度优先搜索
-        e = e || {};
-        var t = !!e.nullLevelEnd,
-            i = e.maxLevel,
-            n = e.minLevel,
-            r = e.callback,
-            o = e.saveVisited,
-            a = [],
-            s = {},
-            l = 0,
-            c = 0;
-        for (a.push(this.root),
-            a.push(s); a.length > 0 && !(i && l > i);) {
-            var h = a.shift();
-            if (h === s)
-                (!n || l >= n) && (r && t && r(null),
-                    o && t && o.push(null)),
-                a.length > 0 && a.push(s),
-                l++,
-                c = 0;
-            else {
-                if (h.children)
-                    for (var u = 0; u < h.children.length; u++) {
-                        var d = h.children[u];
-                        d && a.push(h.children[u])
-                    }
-                var p = this.getFaceIndexFromNode(h);
-                (!n || l >= n) && (r && r(h, l, p),
-                    o && o.push(h)),
-                c++
-            }
-        }
-    }
-
-    getFaceIndexFromNode(e) {
-        if (!e)
-            return -1;
-        for (var t = 1, i = e, n = 0, r = 0;;) {
-            var o = i.parent;
-            if (!o)
-                break;
-            for (var a = -1, s = 0; s < o.children.length; s++)
-                o.children[s] === i && (a = s);
-            var l = a % c,
-                h = Math.floor(a / c);
-            n = l * t + n,
-                r = h * t + r,
-                t *= c,
-                i = o
-        }
-        return r * t + n
-    }
-
-    depthFirst(e, t, i) {
-        o(this.root, 0, 0, 0, e, t, i, this.tileSize)
-    }
-}
-
-TileTree.TraversalType = Object.freeze({
-    PreOrder: 0,
-    PostOrder: 1
-});
-
-TileTree.getLevelCountForSize = function(tileSize, size) {//512->0 2024->1
-    var i = 0;
-    for (size < tileSize && (size = tileSize);;) {
-        if (size /= c,
-            size < tileSize)
-            break;
-        i++
-    }
-    return i
-};
-
-TileTree.getSizeForLevel = function(e, t) {
-    return Math.pow(c, t) * e
-};

+ 0 - 283
src/custom/modules/panos/tile/TileUtils.js

@@ -1,283 +0,0 @@
- 
-import MathLight from '../../../utils/MathLight.js'
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
-
-let GLCubeFaces = Potree.defines.GLCubeFaces
-
-var TileUtils = {};
-TileUtils.TILE_SIZE = 512,
-TileUtils.FACES_PER_PANO = 6,
-TileUtils.LocationOnTile = {
-    Center: 0,
-    UpperLeft: 1,
-    UpperRight: 2,
-    LowerRight: 3,
-    LowerLeft: 4
-},
-
-
-/*
- * 获取某tile在cube中的方向 direction (向量起点在cube中心,终点在tile图的指定位置)。spherical通过先求uv,再直接得到dir
- * @param {*} size 面分辨率
- * @param {*} cubeFace 所在面
- * @param {*} Center 在tile上的目标位置,默认为中心,其他位置就是四个顶点
- * @param {*} c 似乎是在tile的缩进百分比,根据所在面的不同,分别向不同方向缩进,但都是向tile的中心
- * @param {*} dir 所求方向
- */
-
-TileUtils.getTileVector = function() {//获取某tile在cube中的方向 direction (向量起点在cube中心,终点在tile图的中心)
-    return function(size, tileSize, cubeFace, tileX, tileY, Center, c, dir) {//c似乎是缩进百分比
-       
-        Center = Center || TileUtils.LocationOnTile.Center;
-        
-        //假设该cube边长为2:
-        var u = size / tileSize
-            , d = tileX / u;
-        tileY = -tileY + (u - 1);
-        var p = tileY / u
-            , f = tileSize / size
-            , g = 2 * f //一个tile的宽度   (乘以2是因为cube边长是2)
-            , m = g / 2
-            , v = 2 * d - 1 + m
-            , A = 2 * p - 1 + m;
-            
-        switch (Center) {//计算在tile中指定位置带来的偏移 
-            case TileUtils.LocationOnTile.UpperLeft:        //1
-                v -= m,
-                A += m,
-                v += c * g; //似乎是向内缩进
-                break;
-            case TileUtils.LocationOnTile.UpperRight:
-                v += m,
-                A += m,
-                A -= c * g;
-                break;
-            case TileUtils.LocationOnTile.LowerRight:
-                v += m,
-                A -= m,
-                v -= c * g;
-                break;
-            case TileUtils.LocationOnTile.LowerLeft:
-                v -= m,
-                A -= m,
-                A += c * g;
-                break;
-            case TileUtils.LocationOnTile.Center:   //0
-        }
-        switch (cubeFace) {
-            case GLCubeFaces.GL_TEXTURE_CUBE_MAP_POSITIVE_X:
-                MathLight.setVector(dir, -1, A, -v);
-                break;
-            case GLCubeFaces.GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
-                MathLight.setVector(dir, 1, A, v);
-                break;
-            case GLCubeFaces.GL_TEXTURE_CUBE_MAP_POSITIVE_Y: //顶面
-                MathLight.setVector(dir, -v, 1, -A);
-                break;
-            case GLCubeFaces.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
-                MathLight.setVector(dir, -v, -1, A);
-                break;
-            case GLCubeFaces.GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
-                MathLight.setVector(dir, -v, A, 1);
-                break;
-            case GLCubeFaces.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
-                MathLight.setVector(dir, v, A, -1)
-        }
-        MathLight.normalize(dir)
-    }
-}(),
-
-/*
- * 获取该tile在第几个面(简易装载法) 
- */
-TileUtils.getFaceForTile = function(size, index) {//获取该tile在第几个面
-    var tileSize = TileUtils.TILE_SIZE;
-    size < TileUtils.TILE_SIZE && (tileSize = size);
-    var n = Math.floor(size / tileSize)
-        , sum = n * n; //得每个面tile总数
-    return Math.floor(index / sum)
-}
-,
-
-
-TileUtils.getTileLocation = function(size, t, result) {
-    var tileSize = TileUtils.TILE_SIZE;
-    size < TileUtils.TILE_SIZE && (tileSize = size);
-    var r = TileUtils.getFaceForTile(size, t)
-        , a = Math.floor(size / tileSize)
-        , s = a * a
-        , l = t - r * s;
-    result.tileX = l % a;
-    result.tileY = Math.floor(l / a);
-    result.face = r;
-    result.faceTileIndex = l;
-    return result
-}
-,
-
-/*
- * 求size分辨率需要多少张tile
- */
-TileUtils.getTileCountForSize = function(e) {
-    if (e <= TileUtils.TILE_SIZE)
-        return TileUtils.FACES_PER_PANO;
-    var t = Math.floor(e / TileUtils.TILE_SIZE)
-        , i = t * t
-        , n = i * TileUtils.FACES_PER_PANO;
-    return n
-}
-,
-TileUtils.getRelativeDirection = function() {
-    var e = new MathLight.Matrix4
-        , t = new MathLight.Quaternion;
-    return function(i, n) {//i是pano.quaternion,  n是camera的direction  
-        t.copy(i),
-        t.inverse(),
-        e.makeRotationFromQuaternion(t),
-        e.applyToVector3(n),
-        MathLight.normalize(n)
-    }
-}(),
-
-/*
- * 根据方向寻找合适的tile加载
- */
-TileUtils.matchingTilesInDirection = function() {
-    var e = new MathLight.Vector3
-        , t = new MathLight.Vector3(0,0,-1)
-        , i = new MathLight.Quaternion
-        , n = function(e, t) {
-            e.push({
-                face: t.face,
-                faceTileIndex: t.faceTileIndex,
-                tileX: t.tileX,
-                tileY: t.tileY
-            })
-        }
-        , a = function() {
-            var e = {
-                face: -1,
-                faceTileIndex: -1,
-                tileX: -1,
-                tileY: -1
-            };
-            return function(size, i, r) {
-                for (var a = TileUtils.getTileCountForSize(size), s = 0, l = 0; l < a; l++)
-                    TileUtils.getTileLocation(size, l, e),
-                    i && !i(e) || (s++,
-                    r && n(r, e));
-                return s
-            }
-    }();
-    return function(pano, size, dir, hFov, vFov, result) {
-        var d = size < TileUtils.TILE_SIZE ? size : TileUtils.TILE_SIZE;
-        //TileUtils.getTileCountForSize(size);
-        if (!hFov && !vFov)
-            return a(size, null, result);
-        var p = !!vFov;
-        vFov = vFov || hFov,
-        vFov = Math.max(0, Math.min(vFov, 360)),
-        hFov = Math.max(0, Math.min(hFov, 360)),
-        MathLight.copyVector(dir, e),
-        TileUtils.getRelativeDirection(pano.quaternion4dkk, e)
-        if(p){//如果有vFov hFov
-            i.setFromUnitVectors(e, t);
-            var f = function(e) {
-                return TileUtils.isTileWithinFrustum(size, d, e.face, e.tileX, e.tileY, i, hFov, vFov)//在视野中的
-            };
-            return a(size, f, result)
-        }
-        var g = function(t) {//如果仅有hFov
-            return TileUtils.isTileWithinFOV(size, d, t.face, t.tileX, t.tileY, e, hFov)
-        };
-        return a(size, g, result)
-    }
-}(),
-
-/*
- * 是否在屏幕范围内
- */ 
-TileUtils.isTileWithinFrustum = function() {
-    var e = new MathLight.Vector3
-        , t = 1e-5;
-    return function(i, n, a, s, l, c, h, u) {
-        for (var d = Math.tan(.5 * u * MathLight.RADIANS_PER_DEGREE), p = -d, f = Math.tan(.5 * h * MathLight.RADIANS_PER_DEGREE), g = -f, m = TileUtils.mapFaceToCubemapFace(a), v = 0, A = 0, y = 0, C = 0, I = 0, E = 0, b = TileUtils.LocationOnTile.Center; b <= TileUtils.LocationOnTile.LowerLeft; b++){
-            TileUtils.getTileVector(i, n, m, s, l, b, 0, e),//get e   //  size, tileSize, cubeFace, tileX, tileY, Center, c, dir
-            MathLight.applyQuaternionToVector(c, e)      
-            if (e.z >= -t)//似乎是在相机背面
-                I++;
-            else { 
-                var w = -1 / e.z
-                    , _ = e.x * w
-                    , T = e.y * w;
-                T > d ? v++ : T < p && A++,  //这四种似乎代表在这个画框之外,如在左、在上、在下、在右
-                _ > f ? y++ : _ < g && C++,
-                E++
-            }
-        }
-        return A !== E && v !== E && y !== E && C !== E  //如果有一项和E相等代表要么是在相机背面要么是tile的四个顶点都画在画布的同一边,所以肯定不在画布上
-    }
-}(),
-
-
-/*
- * 是否在FOV范围内
- */
-TileUtils.isTileWithinFOV = function() {
-    var e = new MathLight.Vector3
-        , t = new MathLight.Vector3(0,1,0)
-        , i = new MathLight.Vector3(1,0,0);
-    return function(panoSize, tileSize, face, tileX, tileY, direction, fov) {//direction是作用了pano.quaternion的camera.direction
-        var d = TileUtils.mapFaceToCubemapFace(face);
-        MathLight.cross(direction, t, i) //get i  好像没用到
-        TileUtils.getTileVector(panoSize, tileSize, d, tileX, tileY, TileUtils.LocationOnTile.Center, 0, e) 
-        if (TileUtils.isWithinFOV(e, direction, fov, null))//先判断tile中心在不在FOV内
-            return !0;
-        for (var p = fov / 360, f = Math.floor(1 / p), g = 0, m = 0; m < f; m++) {
-            for (var v = TileUtils.LocationOnTile.UpperLeft; v <= TileUtils.LocationOnTile.LowerLeft; v++)
-                if (TileUtils.getTileVector(panoSize, tileSize, d, tileX, tileY, v, g, e),
-                TileUtils.isWithinFOV(e, direction, fov, null))
-                    return !0;
-            g += p   //可能是考虑到有可能tile比fov覆盖了fov(虽然一般不可能,除非fov特别小),所以将tile分成若干段,取tile中的点再检测下
-        }
-        return !1
-    }
-}(),
-
-
-TileUtils.isWithinFOV = function() {
-    var e = new MathLight.Vector3
-        , t = new MathLight.Vector3;
-    return function(dir, cameraDir, fov, a) {
-        if (MathLight.copyVector(dir, t),
-        a) {
-            MathLight.copyVector(a, e),
-            MathLight.normalize(e);
-            var s = MathLight.dot(e, dir);
-            e.x *= s,
-            e.y *= s,
-            e.z *= s,
-            MathLight.subVector(t, e)
-        }
-        var l = fov / 2 * MathLight.RADIANS_PER_DEGREE
-            , c = Math.cos(l)
-            , h = MathLight.dot(t, cameraDir);
-        return h >= c
-    }
-}(),
-
-TileUtils.mapFaceToCubemapFace = function() {
-    var e = {
-        0: GLCubeFaces.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
-        1: GLCubeFaces.GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
-        2: GLCubeFaces.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
-        3: GLCubeFaces.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
-        4: GLCubeFaces.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
-        5: GLCubeFaces.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
-    };
-    return function(t) {
-        return e[t]
-    }
-}();
-
-export default TileUtils

+ 0 - 643
src/custom/modules/route/RouteGuider.js

@@ -1,643 +0,0 @@
-
-import * as THREE from "../../../../libs/three.js/build/three.module.js";
-import {Utils} from "../../../utils.js"; 
-import Sprite from '../../objects/Sprite.js'
-import Common from "../../utils/Common.js";
-import browser from '../../utils/browser.js' 
-
-const texLoader = new THREE.TextureLoader()
-const arrowSpacing = 1  //间隔
-const arrowSize = arrowSpacing * 0.5
-const planeGeo = new THREE.PlaneBufferGeometry(1,1);
-
-const sphereSizeInfo = {
-      nearBound : 0.1,   farBound:25, minSize : 50,  maxSize : 200 //scale:arrowSize, restricMeshScale : true,
-}
-//const arrowsShowingCount = 25; //场景里最多展示多少个箭头
-const arrowShowMinDis = 10
-export class RouteGuider extends THREE.EventDispatcher{
-    constructor () {
-		super();
-        
-        this.route = [];
-        this.curve = []
-        this.scenePoints = []
-        this.sceneMeshGroup = new THREE.Object3D;
-        this.mapMeshGroup = new THREE.Object3D;
-        this.generateDeferred;
-        viewer.addEventListener('loadPointCloudDone',this.init.bind(this))
-        
-        this.lastResult;//保存上一个的结果,以便于反向
-        this.datasetIds = [];//起始和终点的datasetId
-    }
-    init(){
-        if(this.inited) return;
-        
-        let zoom, resolution=new THREE.Vector2;
-        viewer.mapViewer.addEventListener('camera_changed', e => {
-            if(!this.routeStart || !this.routeEnd) return   
-            var camera = e.viewport.camera
-            if(camera.zoom != zoom || !resolution.equals(e.viewport.resolution)){
-                Common.intervalTool.isWaiting('routeCameraInterval', ()=>{ //延时update,防止卡顿
-                    if(camera.zoom != zoom || !resolution.equals(e.viewport.resolution)){ 
-                        //console.log('updateMapArrows')
-                        this.updateMapArrows(true)
-                        zoom = camera.zoom; resolution.copy(e.viewport.resolution)   
-                    } 
-                }, browser.isMobile()?500:200)
-            }
-        })
-         
-       
-        viewer.addEventListener('camera_changed', e => {
-            if(!this.routeStart || !this.routeEnd || !e.changeInfo.positionChanged  ) return
-            Common.intervalTool.isWaiting('routeCameraInterval2', ()=>{ //延时update,防止卡顿  
-                this.updateArrowDisplay()  
-            }, 1000)          
-        })
-        
-        
-        
-        var polesMats = {
-            shadowMat: new THREE.MeshBasicMaterial({ 
-                transparent:true, depthTest:false,
-                map: texLoader.load(Potree.resourcePath+'/textures/pano_instruction_bottomMarker.png' )  
-            }),
-            sphereMat : new THREE.MeshBasicMaterial({
-                transparent:true, depthTest:false,
-                map: texLoader.load(Potree.resourcePath+'/textures/whiteCircle.png' )  
-            }), 
-            hatMats:{
-                start:  new THREE.MeshBasicMaterial({
-                    transparent:true, depthTest:false,
-                    map: texLoader.load(Potree.resourcePath+'/textures/pano_instruction_start_route.png' )  
-                }),
-                end:  new THREE.MeshBasicMaterial({
-                    transparent:true, depthTest:false,
-                    map: texLoader.load(Potree.resourcePath+'/textures/pano_instruction_target_reached.png' )  
-                }) 
-            }
-        }
-        polesMats.shadowMat.map.anisotropy = 4 
-        
-        this.poleStart = this.createPole(polesMats, 'start') 
-        this.poleEnd = this.createPole(polesMats, 'end') 
-        
-        this.sceneMeshGroup.add(this.poleStart)
-        this.sceneMeshGroup.add(this.poleEnd)
-        
-        
-        let map = texLoader.load(Potree.resourcePath+'/textures/routePoint_panorama.png' )  
-        map.anisotropy = 4 // 各向异性过滤 .防止倾斜模糊 
-        this.arrow = new THREE.Mesh(planeGeo, new THREE.MeshBasicMaterial({
-            transparent:true,
-            depthTest:false, 
-            map
-        }))
-        this.arrow.scale.set(arrowSize,arrowSize,arrowSize)
-        Potree.Utils.setObjectLayers(this.arrow, 'sceneObjects' )
-         
-        
-        /* this.testArrow = this.arrow.clone();
-        this.testArrow.material = this.arrow.material.clone()
-        this.testArrow.material.color = 'red' */
-        
-        this.arrows = new THREE.Object3D;
-        this.sceneMeshGroup.add(this.arrows)
-        
-        Potree.Utils.setObjectLayers(this.sceneMeshGroup, 'sceneObjects' )
-        //this.sceneMeshGroup.traverse(e=>e.renderOrder = 90)
-        
-        
-        viewer.scene.scene.add(this.sceneMeshGroup);
-        this.sceneMeshGroup.visible = /* this.poleStart.visibile = this.poleEnd.visibile = */ false
-       
-        //-------------map---------------------
-        
-        /* this.mapMarkStart = new THREE.Mesh( planeGeo, new THREE.MeshBasicMaterial({
-            transparent:true, depthTest:false,
-            map: texLoader.load(Potree.resourcePath+'/textures/map_instruction_start_route.png' )  
-        }))
-        this.mapMarkEnd = new THREE.Mesh( planeGeo, new THREE.MeshBasicMaterial({
-            transparent:true, depthTest:false,
-            map: texLoader.load(Potree.resourcePath+'/textures/map_instruction_target_reached.png' )  
-        }))
-        this.mapMarkStart.renderOrder = this.mapMarkEnd.renderOrder = 2//在箭头之上 */
-         
-        let map2 = texLoader.load(Potree.resourcePath+'/textures/routePoint_map_fsna.png' ) 
-        this.mapArrowMats = {
-            default: new THREE.MeshBasicMaterial({
-                transparent:true, depthTest:false,
-                map:map2, 
-            }),
-            
-            fade: new THREE.MeshBasicMaterial({
-                transparent:true, depthTest:false,
-                map:map2, 
-                opacity:0.4
-            }), 
-        }
-        
-        
-        
-        this.mapArrow = new THREE.Mesh( planeGeo, this.mapArrowMats.default) 
-        this.mapArrow.scale.set(arrowSize,arrowSize,arrowSize)
-        this.mapArrows = new THREE.Object3D;
-        this.mapArrows.name = 'mapArrows'
-         
-        
-        
-        this.mapMeshGroup.add(this.mapArrows)
-        this.mapMeshGroup.name = 'mapRouteLayer'
-        this.mapMeshGroup.visible = false
-        
-        viewer.mapViewer.dispatchEvent({type:'add', object:this.mapMeshGroup, name:'route'})
-        this.mapArrow.layers.mask = this.mapArrows.layers.mask // 修改成和map中的layer一样的
-        
-        
-        
-        viewer.modules.SiteModel.bus.addEventListener('FloorChange',()=>{
-            if(this.routeStart && this.routeEnd){
-                this.updateOpacityAtMap()
-            }  
-        }) 
-        this.inited = true
-    }
-    
-    updateOpacityAtMap(){//只有当前楼层的透明度为1
-        var currentFloor = viewer.modules.SiteModel.currentFloor
-        //console.log('updateOpacityAtMap', currentFloor && currentFloor.name)
-        const lift = 0.3 // 因为发送请求时用的是floorPosition的高度,而它可能会到画好的floor之下,所以有误差
-        this.mapArrows.children.forEach((arrow,index)=>{
-            let pos = this.mapPoints[index].clone()
-                pos.z += lift  
-            let inSide = currentFloor && currentFloor.ifContainsPoint(pos)
-            arrow.material = inSide ? this.mapArrowMats.default : this.mapArrowMats.fade
-            //console.log('arrow',index, arrow.material.opacity)
-        }) 
-        
-        viewer.mapViewer.dispatchEvent('content_changed')
-    }//但是如果楼层刚好只框柱相机位置而没框住地面位置就不好了……
-    
-    
-    
-    
-    
-    createPole(polesMats, name){
-        const height = 1.5, sphereCount = 6, shadowSize = 0.5 /* sphereSizeInfo.scale */,  sphereSize = 0.05
-        
-        var group = new THREE.Object3D;
-            group.name = 'pole_'+name
-        var shadow = new THREE.Mesh(planeGeo, polesMats.shadowMat)
-        shadow.scale.set(shadowSize,shadowSize,shadowSize)
-        var sliceDis = height / (sphereCount+1);
-        group.add(shadow) 
-         
-        for(let i=0;i<sphereCount;i++){
-            var sphere = new Sprite({mat: polesMats.sphereMat, renderOrder:3}) 
-            sphere.position.set(0,0,sliceDis*(i+1))
-            sphere.scale.set(sphereSize,sphereSize,sphereSize);
-            sphere.visible = false
-            group.add(sphere)
-        }
-        
-        var hatSphere = new Sprite({mat: polesMats.hatMats[name], sizeInfo:sphereSizeInfo, renderOrder:4}) 
-        sphere.visible = false
-        hatSphere.position.set(0,0,height)
-        hatSphere.scale.copy(shadow.scale)
-        group.add(hatSphere)
-        return group
-    }
-    
-    
-    addTestArrow(){
-        
-    }
-    
-    addArrow(position){ 
-        var arrow = this.arrow.clone()
-        arrow.position.copy(position); 
-        this.arrows.add(arrow); 
-    }
-    addMapArrow(position){ 
-        var mapArrow = this.mapArrow.clone()
-        mapArrow.position.copy(position).setZ(0) 
-        this.mapArrows.add(mapArrow);
-    }
-    
-    
-    setArrowDir(arrows,index){
-        let arrow = arrows[index]
-        var nextOne = arrows[index+1];
-        var nextPos = nextOne ? nextOne.position : this.endPolePos //routeEnd
-        var direction = new THREE.Vector3().subVectors(arrow.position, nextPos).setZ(0);
-        //direction.normalize();
-        //console.log(direction.toArray())
-        var angle = Math.atan2(direction.y, direction.x ) + Math.PI/2 //Math.PI/2是因为贴图本身箭头方向不朝x
-        arrow.rotation.z = angle
-        //console.log(angle)
-    }
-    
-    
-     
-     
-    
-    setRouteStart(pos, dealZ , datasetId  ){
-        if(this.routeStart && pos && this.routeStart.equals(pos)) return //可能重复设置
-        this.routeStart = pos && new THREE.Vector3().copy(pos)  
-        if(dealZ && this.routeStart){
-            this.routeStart.setZ(this.getZAtMap()) 
-            this.bus && this.bus.emit('reposStartMarker', this.routeStart)
-        }
-        console.log('setRouteStart',this.routeStart&&this.routeStart.toArray()) 
-        
-        this.datasetIds[0] = datasetId
-        
-        //this.setStartPole(pos)
-        
-        this.generateRoute()
-        
-        
-    }
-    
-    setStartPole(pos){
-        this.startPolePos = pos
-        this.bus && this.bus.emit('reposStartMarker', pos)
-    }
-     
-    
-    setRouteEnd(pos, dealZ , datasetId  ){ 
-        if(this.routeEnd && pos && this.routeEnd.equals(pos)) return 
-        this.routeEnd = pos && new THREE.Vector3().copy(pos)
-        if(dealZ && this.routeEnd){
-            this.routeEnd.setZ(this.getZAtMap())
-            this.bus && this.bus.emit('reposEndMarker', this.routeEnd)
-        }
-        console.log('setRouteEnd',this.routeEnd&&this.routeEnd.toArray())        
-        this.datasetIds[1] = datasetId
-        //this.setEndPole(pos)
-        this.generateRoute()
-        
-    }
-    
-    
-    getZAtMap(){  
-        
-        //找到position.z与当前高度最接近的漫游点 
-        let result = Common.sortByScore(viewer.images360.panos,[],[e=> -(Math.abs(e.position.z - viewer.images360.position.z)) ])
-        let pano = result && result[0] && result[0].item
-        
-        return pano ? pano.floorPosition.z : viewer.bound.boundingBox.min.z + 1 
-        //若在平面图上画实在得不到当前楼层的,大概率是楼层画得不好,那就只能去获取当前楼层的了
-        
-        //navvis的高度取的是主视图所在楼层的中心高度(可能再高些)
-        
-    }
-    
-    setEndPole(pos){
-        this.endPolePos = pos
-        this.bus && this.bus.emit('reposEndMarker', pos)
-    }
-    
-    getSourceProjectionIndex(route) {//真正的起始
-        var e = route.findIndex(function(t) {
-            return t.instruction && t.instruction.type === 'source_projection_to_navgraph'
-        });
-        return e < 0 ? 0 : e
-    }
-    getDestinationProjectionIndex(route) {//真正的终点
-        var e = route.findIndex(function(t) {
-            return t.instruction && t.instruction.type === "destination_projection_to_navgraph"
-        });
-        return e < 0 ? route.length - 1 : e
-    }
-    
-    generateRoute(){
-        if(!this.routeStart || !this.routeEnd){ 
-            
-            return
-        }
-        
-        
-        //array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
-        
-        
-        let create = ()=>{ 
-            this.routeLength = this.route.reduce((total, currentValue, currentIndex, arr)=>{
-                if(currentIndex == 0)return 0
-                return total + currentValue.distanceTo(arr[currentIndex-1]);
-            },0)
-            let count = Math.max(2,Math.round(this.routeLength / arrowSpacing))//点数
-            
-            const curve = new THREE.CatmullRomCurve3( this.route ); 
-            curve.curveType = 'chordal'//'centripetal'  'catmullrom'这个可能会超出路径外
-            this.curve = curve
-            
-            const scenePoints = curve.getSpacedPoints( count );//更平均
-            //const scenePoints = curve.getPoints( count );
-            scenePoints.splice(0,1);//去掉首尾
-            scenePoints.pop()
-            this.scenePoints = scenePoints
-            
-            this.updateMapArrows() 
-            this.displayRoute()
-            
-            {//map focus on this area
-                
-                const minBound = new THREE.Vector2(1,1)//针对垂直线,在地图上只有一个点
-                let bound = new THREE.Box2;
-                this.route.forEach(e=>{
-                    bound.expandByPoint(e)
-                })
-                let size = bound.getSize(new THREE.Vector2)
-                let markerSize = new THREE.Vector2(115,40) //起始和终点的标识呈长方形
-                let areaSize = viewer.mapViewer.viewports[0].resolution2
-                let areaArea = areaSize.x * areaSize.y
-                if(areaArea> 800 * 400){//是放大的 
-                    markerSize.multiplyScalar(areaArea / (800 * 400) /* / (size.x * size.y) */) 
-                }
-                let margin = size.clone().divide(viewer.mapViewer.viewports[0].resolution2).multiply(markerSize) ///边距 重点是起始和终点的标识占据较大
-                size.add(margin)
-                let center = bound.getCenter(new THREE.Vector2)
-                
-                size.x = Math.max(size.x, minBound.x )
-                size.y = Math.max(size.y, minBound.y )
-                let duration = 1000
-                viewer.mapViewer.moveTo(center, size, duration)
-            }
-            
-            this.bus.emit('gotResult', {dis:this.routeLength})
-            /* this.generateDeferred && this.generateDeferred.resolve({dis:this.routeLength})
-            this.generateDeferred = null */
-        }
-        
-        
-        if(Potree.fileServer){
-            let dealData = (data)=>{
-                
-                if(!data.data){
-                    console.log('没有数据')
-                    let result
-                    if(data && data.code == 4002){
-                        result = data;//正被修改数据集
-                    }else if(this.routeStart.distanceTo(this.routeEnd) < 1){
-                        result = { code: 500, msg: '距离太短,无法规划路线' }
-                    }else{
-                        result = { code: 500, msg: '超出数据集范围,无法规划路线' }
-                    }
-                    this.clearRoute() 
-
-
-                    this.setStartPole(this.routeStart) 
-                    this.setEndPole(this.routeEnd) 
-                    
-                    this.displayRoute() //还是要显示一下起始
-                    this.bus && this.bus.emit('gotResult', result )
-                    
-                    return //this.generateDeferred && this.generateDeferred.resolve()
-                }
-                
-                
-                data = data.data 
-                  
-                this.clearRoute()
-                let length = data.length
-                
-                if(length < 2){//可能距离太短 
-                    console.log('路径点数为'+length+',直接取起点和终点连线') 
-                    this.route = [this.routeStart, this.routeEnd];
-                }else{ 
-                    let startIndex = this.getSourceProjectionIndex(data)
-                    let endIndex = this.getDestinationProjectionIndex(data)
-                    
-                    
-                    let effectiveItems = data.slice(startIndex, endIndex + 1 );//只要点云范围内的点
-                    effectiveItems.forEach((item,i)=>{ 
-                        let pos = viewer.transform.lonlatToLocal.forward(item.location.slice(0))
-                        pos = new THREE.Vector3().fromArray(pos)//.setZ(item.z)
-                        this.route.push(pos)
-                    })
-                    
-                    console.log(this.route)
-                    
-                    
-                }
-                this.setStartPole(this.route[0]) 
-                this.setEndPole(this.route[this.route.length-1]) 
-                
-                create()
-                /*
-                    distance: 0.17581000000000116
-                    distance_to_previous: 0.17581000000000116
-                    id: 567
-                    instruction: {type: 'source_projection_to_navgraph'}
-                    latitude: 22.366605927999238
-                    location: (3) [113.5957510575092, 22.366605927999238, -1.12419]
-                    longitude: 113.5957510575092
-                    z: -1.12419
-                */
-            }
-            
-            
-            
-            
-            if(this.lastResult && (this.lastResult.data || this.lastResult.data.code != 4002)){//正被修改数据集的话要重新计算
-                let data = Common.CloneObject(this.lastResult.data) ,  use;  //直接用上次的结果
-                if(this.lastResult.routeStart.equals(this.routeStart) &&  this.lastResult.routeEnd.equals(this.routeEnd)){//和上次请求相同
-                    use = true 
-                }else if(this.lastResult.routeStart.equals(this.routeEnd) &&  this.lastResult.routeEnd.equals(this.routeStart)){//..反向
-                    use = true
-                    if(data.data){
-                        data.data = this.lastResult.data.data.slice(0).reverse()
-                    }    
-                }
-                if(use){
-                    console.log('直接用上次的结果')
-                    return setTimeout(()=>{dealData(data)}, 1)//延迟是为了等待获得 RouteGuider.generateDeferred
-                       
-                }
-                
-            }
-            
-            
-            
-            
-            let start = this.routeStart.clone();
-            let end = this.routeEnd.clone();
-            let startLonlat = viewer.transform.lonlatToLocal.inverse(start)
-            let endLonlat = viewer.transform.lonlatToLocal.inverse(end)
-            
-            var query = {
-                source_longitude: startLonlat.x,
-                source_latitude: startLonlat.y,
-                source_z: start.z,
-                destination_longitude: endLonlat.x,
-                destination_latitude: endLonlat.y,
-                destination_z: end.z
-            };
-            
-            
-            //let url = `/laser/route/${Potree.settings.number}/getRoute/${this.datasetIds[0]}/${this.datasetIds[1]}?`
-            let url = `/laser/route/${Potree.settings.number}/getRoute/${Potree.settings.originDatasetId}?`
-            for(let i in query){
-                url+= (i + '='+ query[i] +'&')
-            }
-            
-            Potree.fileServer.get(url).then((data)=>{
-                console.log(data.data)
-                if(!this.routeStart || !this.routeEnd)return 
-                
-                this.lastResult = {//保存数据
-                    routeStart : this.routeStart.clone(),
-                    routeEnd: this.routeEnd.clone(),
-                    data,
-                     
-                }
-                
-                dealData(data)
-                
-            })
-            
-            
-        }else{
-            //创个直线
-            /* const sliceDis = 1
-            let dis = this.routeStart.distanceTo(this.routeEnd);
-            let count = Math.max(2,Math.round(dis / sliceDis))//点数
-            let realSlideDis = dis / (count-1);
-            let dir = new THREE.Vector3().subVectors(this.routeEnd, this.routeStart).normalize().multiplyScalar(realSlideDis);
-            this.route = [this.routeStart];
-            for(let i=0;i<count-1;i++){
-                let lastOne = this.route[i];
-                this.route.push(new THREE.Vector3().addVectors(lastOne,dir))
-            }
-            this.route.splice(0,1) //route不用包含收尾 */
-            this.clearRoute()
-            this.route = [this.routeStart, this.routeEnd]
-            create()
-            
-        }
-          
-    }
-    
-    updateMapArrows(ifReset){
-        if(this.route.length == 0)return  
-        var zoom = viewer.mapViewer.camera.zoom
-        let isBig = viewer.mapViewer.viewports[0].resolution.y > 300  
-        let count = Math.max(2,Math.round(this.routeLength * zoom  / arrowSpacing / (isBig?35:30)))//点数
-        
-        if(count == this.mapPoints.length+1)return//没变
-
-        const mapPoints = this.curve.getSpacedPoints( count ); 
-        mapPoints.splice(0,1);//去掉首尾
-        mapPoints.pop() 
-        this.mapPoints = mapPoints
-        
-        
-        var scale = (isBig ? 26 : 22)/zoom
-        this.mapArrow.scale.set(scale,scale,scale) 
-        /* this.mapMarkStart.scale.set(scale,scale,scale) 
-        this.mapMarkEnd.scale.set(scale,scale,scale)  */
-        
-        
-        if(ifReset){//因为缩放而重新排布箭头
-            this.clearRoute({resetMap:true})
-            this.displayRoute({resetMap:true}) 
-        }
-        this.updateOpacityAtMap()
-    }
-    
-    
-    updateArrowDisplay(){//根据当前位置更新显示一定范围内的箭头 
-    
-        if(this.scenePoints.length == 0)return
-        
-        /* var a = Common.sortByScore(this.scenePoints , null, [(point)=>{   //是否还要再requires里限制最远距离?
-            var playerPos = viewer.scene.getActiveCamera().position.clone().setZ(0)
-            
-            var pos = point.clone().setZ(0) 
-            
-            return -pos.distanceTo(playerPos);
-            
-        }]);
-        //获得展示的起始点 
-        let start = a[0].item
-        let startIndex = this.scenePoints.indexOf(start)
-        this.arrows.children.forEach((e,i)=>{
-            if(i<startIndex || i>startIndex+arrowsShowingCount)e.visible = false
-            else e.visible = true
-        }) */
-         
-        let cameraPos = viewer.scene.getActiveCamera().position
-        this.arrows.children.forEach((e,i)=>{
-            if(e.position.distanceTo(cameraPos) < arrowShowMinDis) e.visible = true
-            else e.visible = false
-        })
-        
-        viewer.dispatchEvent('content_changed') 
-    }
-    
-    
-    displayRoute(o={}){
-        if(!o.resetMap){ 
-            
-            this.poleStart.position.copy(this.startPolePos || this.routeStart)
-            this.poleEnd.position.copy(this.endPolePos || this.routeEnd)
-            /* this.mapMarkStart.position.copy(this.routeStart).setZ(0)
-            this.mapMarkEnd.position.copy(this.routeEnd).setZ(0) */
-            this.scenePoints.forEach(e=>this.addArrow(e))
-            this.arrows.children.forEach((e,i)=>this.setArrowDir(this.arrows.children,i));
-        }
-        this.sceneMeshGroup.traverse(e=>e.visible = true)  
-        this.mapMeshGroup.visible = true
-        this.mapPoints.forEach(e=>this.addMapArrow(e))
-        this.mapArrows.children.forEach((e,i)=>this.setArrowDir(this.mapArrows.children,i));
-        viewer.mapViewer.dispatchEvent({'type':'content_changed'})
-        this.updateArrowDisplay()
-    }
-    
-    clearRoute(o={}){
-        if(!o.resetMap){
-            this.routeLength = 0
-            this.route = []
-            this.scenePoints = []
-            this.mapPoints = []
-            let arrows = this.arrows.children.slice(0)
-            arrows.forEach(e=>{
-                this.arrows.remove(e)
-            })
-        } 
-        
-        let mapArrows = this.mapArrows.children.slice(0) 
-        mapArrows.forEach(e=>{
-            this.mapArrows.remove(e)
-        })
-        
-        this.sceneMeshGroup.traverse(e=>e.visible = false)  //包括sprite也要设置,防止update
-        this.mapMeshGroup.visible = false
-        viewer.mapViewer.dispatchEvent({'type':'content_changed'})
-        viewer.dispatchEvent('content_changed') 
-    }
-    
-    clear(){//退出
-        console.log('导航clear') 
-        this.routeStart = null
-        this.routeEnd = null
-        this.clearRoute()
-        
-    }
-}
-
-//大概每十米要花一秒
-
-
-
-/* 
-
-    存在的问题:
-    路径不准确。起始点和终点偏移。
-
-    https://uat-laser.4dkankan.com/routeDebug/   可查整个map的通路点位图
-    
-    
- */

+ 0 - 889
src/custom/modules/siteModel/BuildingBox.js

@@ -1,889 +0,0 @@
-
-import * as THREE from "../../../../libs/three.js/build/three.module.js";
-import {ctrlPolygon} from '../../objects/tool/ctrlPolygon.js'
-import {LineDraw, MeshDraw } from "../../utils/DrawUtil.js";  
-import math  from "../../utils/math.js";
-import Sprite from '../../objects/Sprite.js'
-/* import {config} from '../settings' */
-import searchRings from "../../utils/searchRings.js";
-import DepthBasicMaterial from "../../materials/DepthBasicMaterial.js";
-
-let texLoader = new THREE.TextureLoader() 
-
- 
-let markerMats
-let markerSizeInfo = {width2d:35}
-let color = new THREE.Color('#FFF')
-let faceMats
-let getFaceMat = (name)=>{
-    if(!faceMats){ //navvis材质可以搜gridTexture
-        let gridTex = texLoader.load( Potree.resourcePath+'/textures/gridmap.png' ) 
-            gridTex.wrapS = gridTex.wrapT = THREE.RepeatWrapping   
-            //gridTex.repeat.set(0.5,0.5)//放大一些
-        faceMats = { 
-            dataset: new THREE.MeshStandardMaterial({
-                color:812922,   
-                side:THREE.DoubleSide, 
-                opacity:0.2,
-                transparent:true,  
-                depthTest:false,
-                wireframe:true
-            }),
-            building: new THREE.MeshStandardMaterial({
-                color:812922,  metalness: 0.2, roughness:0.8,
-                side:THREE.DoubleSide, 
-                opacity:0.1,
-                transparent:true,  
-                depthTest:true
-            }),
-            buildingSelect: new THREE.MeshStandardMaterial({
-                color:36582,  metalness: 0, roughness:1,
-                side:THREE.DoubleSide,
-                opacity:0.1,
-                transparent:true,
-                depthTest:true
-            }),
-            floor:  new THREE.MeshStandardMaterial({
-                color:11708469,  metalness: 0.1, roughness:1,
-                side:THREE.DoubleSide,//BackSide,
-                opacity:0.05,
-                transparent:true,
-                depthTest:true, 
-            }),
-             
-            /* floorSelect: new THREE.MeshStandardMaterial({
-                color:16707151,  metalness: 0, roughness:1,
-                side:THREE.DoubleSide,
-                opacity:1,
-                transparent:true,
-                depthTest:true,
-                polygonOffset : true,//是否开启多边形偏移 
-				polygonOffsetFactor : -0.75,//多边形偏移因子
-				polygonOffsetUnits : -4.0,//多边形偏移单位 
-                map: gridTex,
-            }),  */ 
-            floorSelect: new DepthBasicMaterial({
-                map: gridTex,
-                color:16707151,  
-                side:THREE.DoubleSide,//BackSide, 
-                opacity:1,
-                transparent:true, 
-                useDepth : true,
-                /* polygonOffset : true,//是否开启多边形偏移 
-				polygonOffsetFactor : -0.75,//多边形偏移因子
-				polygonOffsetUnits : -4.0,//多边形偏移单位  */
-                
-                clipDistance : 1, occlusionDistance:1, /* occlusionDistance:变为backColor距离, clipDistance:opacity到达0或者1-maxClipFactor时的距离 */  
-                maxClipFactor:0.4, backColor:'#efe' //backColor:"#669988"  ,
-                  
-            }),
-            
-            room: new THREE.MeshStandardMaterial({
-                color:"#ff44ee",  metalness: 0, roughness:1,
-                side:THREE.DoubleSide,//BackSide,
-                opacity:0.08,
-                transparent:true, 
-                depthTest:false, 
-            }), 
-            /* roomSelect: new THREE.MeshStandardMaterial({
-                color:"#ff44ee",  metalness: 0.3, roughness:1,
-                side:THREE.DoubleSide,//BackSide,
-                opacity:1,
-                transparent:true,
-                depthTest:true,
-                polygonOffset : true,//是否开启多边形偏移.(开启是因为和floor重叠了会闪烁)
-				polygonOffsetFactor : -0.75,//多边形偏移因子
-				polygonOffsetUnits : -4.0,//多边形偏移单位  
-                map: gridTex,
-            }), */
-            roomSelect: new DepthBasicMaterial({  
-                map: gridTex,
-                color:"#ff44ee", 
-                side:THREE.DoubleSide,//BackSide, 
-                opacity:1,
-                transparent:true, 
-                useDepth : true,
-                /* polygonOffset : true,//是否开启多边形偏移 
-				polygonOffsetFactor : -0.75,//多边形偏移因子
-				polygonOffsetUnits : -4.0,//多边形偏移单位  */
-                
-                clipDistance : 1, occlusionDistance:0.5, /* occlusionDistance:变为backColor距离, clipDistance:opacity到达0或者1-maxClipFactor时的距离 */  
-                maxClipFactor:0.6, backColor:'#ff88dd'//"#cc99c2"  ,
-                 
-            })
-        }
-    }
-    return faceMats[name]
-}
-
-
-
- 
-
-export class BuildingBox extends ctrlPolygon{//建筑实体,包括building, floor, room
-    constructor(prop) {
-        prop.dimension = '3d'
-        //prop.name = Potree.config.siteModel.names[prop.buildType] + 
-         
-        super('siteModel_'+prop.buildType,  prop);
-        
-         
-        
-        this.midMarkers = []
-        this.buildChildren = []//子实体
-        this.holes = [] //在这创建的hole
-        this.parentHoles = [];//floor从building那得到的当层holes
-        this.mats = {} //材质
-        
-        this.panos = this.panos || [];
-        this.center //中心点
-        
-        if(this.buildType=='floor'){
-            
-            this.points = prop.points = this.buildParent.points;//完全等于建筑的点
-            this.buildParent.holes.forEach(hole=>{//从building获取holes
-                let floorHole = new BuildingBox({
-                    buildType : 'hole', 
-                    buildParent:this,
-                    originHole : hole, //整栋大楼在当层的hole
-                    ifDraw: this.ifDraw  || Potree.settings.drawEntityData
-                });
-                this.parentHoles.push(floorHole)
-                this.add(floorHole) 
-                
-                floorHole.points = hole.points//完全等于建筑的点
-            })
-        } 
-        if(this.buildType == 'room' || this.buildType == 'hole'){
-            this.restrictArea = this.buildParent  //不能超出的区域
-        }
-        if(this.buildParent)this.dontDragFloorHeight = this.buildParent.dontDragFloorHeight
-        
-        
-        if(this.buildType != 'hole'){
-            this.box = this.createBox() //无论是否edit都绘制的原因:为了将在外的点移到在内,需要用mesh来获取intersect
-            this.add(this.box)
-            this.box.visible = !!this.ifDraw
-        }
-        
-        if(this.ifDraw){ //只存储空间模型信息,不绘制
-            
-            {
-                this.lineMesh = LineDraw.createLine([],{color})
-                this.lineMesh.name = 'buildingLines'
-                this.lineMesh.visible = false            
-                this.add(this.lineMesh) 
-                Potree.Utils.setObjectLayers(this.lineMesh, 'bothMapAndScene' ) 
-            }
-            
-            
-            this.addEventListener('dragChange',(e)=>{ //修改中点
-                this.updateTwoMidMarker(e.index)
-            }) 
-            
-        }
-        
-        this.initData(prop)
-        
-        
-    } 
-    
-    
-    initData(prop){
-        if(prop.ifDraw){
-            super.initData(prop) 
-        }else{
-            if(prop.points){
-                this.points = prop.points  
-            }  
-        } 
-    } 
-    
-    intersectPointcloudVolume(pointcloud){//和pointcloud的重叠体积
-        var bound = this.getBound()
-        let bound2 = pointcloud.bound;
-        if(!bound.intersectsBox(bound2)) return 0;
-        
-        
-        let {zMin , zMax} =  this.getRealZ()
-        let min = Math.min(zMin, bound2.min.z);
-        let max = Math.max(zMax, bound2.max.z); 
-        let height1 = zMax - zMin
-        let height2 = bound2.max.z-bound2.min.z
-        let coverHeight = height1 + height2 - (max-min)//重叠高度 <=0是没重叠
-         
-        let boxPoints = pointcloud.getUnrotBoundPoint() //获取tightBound的四个点。 如果是有旋转角度的点云,这个和pointcloud.bound的四个点是不一致的,覆盖面积小于pointcloud.bound
-       
-        let areaWhole = 0  
-        let area1 = this.getArea()
-        let area2 = Math.abs(math.getArea(boxPoints))
-         
-        {//计算points与点云总面积 (但是把hole也加入了面积)(并集,重叠部分只算一次)  
-            let rings = math.getPolygonsMixedRings([this.points, boxPoints] )
-            
-            rings.forEach(e=>{ 
-                areaWhole+=e.area
-            })
-        }
-        
-        let coverHoleArea = 0 //holes与数据集重叠的部分
-        let holes = this.holes.concat(this.parentHoles)
-        let holesArea = 0    //所有holes面积相加
-        let areaHoleWithPointcloud = 0 //hole和点云的面积并集
-        
-        if(holes.length>0){//还要再扣除holes与数据集重叠的部分。其中holes为mix轮廓
-            let outHoles = []//没有重合的holes的外轮廓
-            /* if(holes.length>=2){//合并holes。如果能在绘制时直接合并holes就好啦,这步就转移到那去,但是要删除hole好麻烦
-                  
-                let holes_ = holes.map(e=>e.points)
-                
-                outHoles = math.getPolygonsMixedRings(holes_,  true )
-                outHoles.forEach(e=>{ 
-                    holesArea+=e.area
-                }) 
-                outHoles = outHoles.map(e=>e.points)
-                
-                
-            }else{
-                outHoles = holes.map(e=>e.points)
-                outHoles.forEach(e=> holesArea += Math.abs(math.getArea(e)))                
-            } */
-            holesArea = this.getHolesArea()
-            
-            //holes与数据集重叠的部分
-            
-            {    
-                let polygons = outHoles.concat([boxPoints]) 
-                let rings = math.getPolygonsMixedRings(polygons)
-                rings.forEach(e=>{ 
-                    areaHoleWithPointcloud+=e.area
-                })
-                coverHoleArea = holesArea + area2 - areaHoleWithPointcloud//hole和点云的交集
-            }
-             
-        }
-        
-        
-        let coverArea = area1 + area2 - areaWhole - coverHoleArea; //重叠面积
-         
-        return coverArea * coverHeight
-    }
-    
-    
-    addHole(points=[]){  
-        let prop = {
-            buildType : 'hole',
-            zMin : this.zMin,
-            zMax : this.zMax,
-            points, 
-            buildParent:this,
-            ifDraw: this.ifDraw || Potree.settings.drawEntityData
-        }
-        //hole的zMin zMax跟随buildParent
-        var hole = new BuildingBox(prop);
-        this.holes.push(hole)
-        
-        if(this.buildType == 'building'){//为每一层添加对应的hole
-            this.buildChildren.forEach(floor=>{
-                let floorHole = new BuildingBox({
-                    buildType : 'hole', 
-                    zMin : this.zMin,
-                    zMax : this.zMax,
-                    buildParent:floor,
-                    originHole : hole, //整栋大楼在当层的hole
-                    ifDraw: this.ifDraw  || Potree.settings.drawEntityData
-                });
-                floor.parentHoles.push(floorHole)
-                floor.add(floorHole)
-                floorHole.points = hole.points//完全等于建筑的点
-            })
-            
-        }
-        
-        this.add(hole);//直接加在这,不加meshGroup了
-        this.update() //update box mesh
-        return hole
-        
-        //hole不创建box,只有它的buildParent需要更新box。 但有线条和marker.  hole不在buildChildren里,但有buildParent
-        
-    }
-    
-    
-    removeHole(hole){// 这个hole不会是parentHoles里的。
-        hole.dispose()
-        
-        if(this.buildType == 'building'){ //若是整栋大楼的hole,在每层去除它的对应hole
-            this.buildChildren.forEach(floor=>{ 
-                let holeAtFloor = floor.parentHoles.find(e=>e.originHole == this )
-                let index = floor.parentHoles.indexOf(holeAtFloor)  
-                index > -1 && floor.parentHoles.splice(index, 1)                
-                holeAtFloor.dispose() 
-            })
-        } 
-        
-        let index = this.holes.indexOf(hole)
-        if(index>-1){
-            this.holes.splice(index, 1)
-        }
-        this.remove(hole)
-        this.update()
-    }
-    
-    
-    
-    
-    createBox(){ 
-        var geometry = new THREE.Geometry();
-        
-        
-        
-        this.mats.boxDefault = getFaceMat(this.buildType)  
-        this.mats.boxSelected = getFaceMat(this.buildType+'Select')     
-        
-        
-        var mesh = new THREE.Mesh(geometry, this.mats.boxDefault)
-        mesh.name = 'buildingBox';
-        
-        
-        
-        if(this.buildType == 'floor'){
-            Potree.Utils.setObjectLayers(mesh, 'siteModelMapUnvisi' ) //楼层默认在地图不显示,为了不会叠加透明度
-            //mesh.renderOrder = 1
-        }else{
-            /* if(this.buildType == 'room'){
-                mesh.renderOrder = 2
-            } */
-            Potree.Utils.setObjectLayers(mesh, 'bothMapAndScene' )
-            
-        }
-         
-        
-        
-        //mesh.frustumCulled = false;
-        return mesh
-    }
-    
-    
-    
-    addMarker(o={} ){
-        if(this.buildType=='floor')return; //楼层不需要marker
-        
-        let marker = new Sprite({mat:this.getMarkerMaterial('default'), renderOrder : 3, sizeInfo: markerSizeInfo, dontFixOrient: true, name:"building_marker"} )
-       
-         
-        Potree.Utils.setObjectLayers(marker, 'siteModeOnlyMapVisi' ) 
-        
-        o.marker = marker
-        super.addMarker(o)
-        
-        if(!this.selected)Potree.Utils.updateVisible(marker,'select',false) 
-         
-        let addClickEvent = (e)=>{ 
-            let click = (e) => {   
-                this.dispatchEvent({type:'clickMarker', marker } )  //由entity发送给sitemodel统一处理
-            }; 
-            marker.addEventListener('click', click); 
-            marker.addEventListener('clickSelect', (e)=>{
-                 this.setMarkerSelected(marker, e.state ? 'select' : 'unselect' );  
-            }); 
-            marker.removeEventListener('addHoverEvent',addClickEvent) 
-        }
-        marker.addEventListener('addHoverEvent',addClickEvent)//当非isNew时才添加事件
-        if(!this.isNew){
-            marker.dispatchEvent('addHoverEvent')
-        }
-     
-        return marker
-    }
-    
-    removeMarker(index){
-        super.removeMarker(index);
-        if(!this.isNew){
-            //重新添加midMarkers 
-            this.midMarkers.forEach(e=>this.remove(e));
-            this.midMarkers = [] 
-            this.addMidMarkers() 
-        }
-        
-        this.update();  
-        if(this.points.length == 2 && this.box){//清除原先length>=3时候的
-            this.box.geometry = new THREE.Geometry();
-        } 
-        
-     
-    }
-    
-    addMidMarker(index, point){
-        if(this.buildType=='floor')return; //楼层不需要marker
-        let marker = new Sprite({mat:this.getMarkerMaterial('midPrepare'), sizeInfo: markerSizeInfo, dontFixOrient: true, name:"building_midMarker"} )
-        this.midMarkers = [...this.midMarkers.slice(0,index), marker, ...this.midMarkers.slice(index,this.midMarkers.length)]
-        
-        marker.renderOrder = 3 
-         
-        Potree.Utils.setObjectLayers(marker, 'siteModeOnlyMapVisi' ) 
-        { // Event Listeners  
-            let mouseover = (e) => {
-                this.setMarkerSelected(e.object, 'hover', 'single'); 
-                viewer.dispatchEvent({
-                    type : "CursorChange", action : "add",  name:"markerMove"
-                }) 
-            };
-            let mouseleave = (e) => {
-                this.setMarkerSelected(e.object, 'unhover', 'single');
-                viewer.dispatchEvent({
-                    type : "CursorChange", action : "remove",  name:"markerMove"
-                })
-            }
-            let drag = (e) => {
-                let index = this.midMarkers.indexOf(marker)
-                let newMarker = this.addMarker({index:(index+1), point:marker.position.clone()  }) 
-                this.addMidMarker(index+1, new THREE.Vector3 )
-                this.updateTwoMidMarker(index+1) 
-                this.setMarkerSelected(marker, 'unhover') 
-                viewer.inputHandler.startDragging(newMarker , {/* dragViewport:viewer.mapViewer.viewports[0],  */   } ); //notPressMouse代表不是通过按下鼠标来拖拽.  dragViewport指定了只能在地图上拖拽
-            }
-            marker.addEventListener('drag', drag );
-            //marker.addEventListener('drop', drop);
-            marker.addEventListener('mouseover', mouseover);
-            marker.addEventListener('mouseleave', mouseleave);
-        }
-        this.add(marker)
-        this.updateMarker(marker, point)
-        if(!this.selected)Potree.Utils.updateVisible(marker,'select',false) 
-        return marker
-    }
-    
-    
-    
-    
-    
-    addMidMarkers(){//第一次画好所有marker后,一次性为线段增加中点marker
-        let length = this.points.length
-        this.points.forEach((point,index)=>{
-            let nextPoint = this.points[(index+1)%length]
-            let midPoint = new THREE.Vector3().addVectors(point, nextPoint).multiplyScalar(0.5)
-            this.addMidMarker(index, midPoint )
-        })
-    }
-    
-    updateTwoMidMarker(index){//更新第index个marker两边的midMarker
-        if(!this.midMarkers.length)return
-        let length = this.points.length
-        let last = this.points[(index-1+length)%length] //它之前的marker位置
-        let next = this.points[(index+1)%length];//它之后的marker位置
-        let current = this.points[index]//当前位置 
-        let lastMid = new THREE.Vector3().addVectors(last, current).multiplyScalar(0.5)//上一个中点
-        let nextMid = new THREE.Vector3().addVectors(next, current).multiplyScalar(0.5)//下一个中点
-        let lastMidMarker = this.midMarkers[(index-1+length)%length];
-        let nextMidMarker = this.midMarkers[index]
-        this.updateMarker(lastMidMarker, lastMid) 
-        this.updateMarker(nextMidMarker, nextMid) 
-    }
-    
-     
-    
-    
-    
-    dispose(){//销毁geo、remove from parent
-        super.dispose()
-        this.box && this.box.geometry.dispose();
-        this.lineMesh && this.lineMesh.geometry.dispose();
-        this.holes.forEach(e=>e.dispose()) 
-        this.parentHoles.forEach(e=>e.dispose()) 
-        //this.buildChildren.forEach(e=>e.dispose())
-        this.dispatchEvent('dispose')
-    }
-    
-    
-    
-    updateBox(){
-        if(!this.box)return
-        this.box.geometry.dispose()
-        var shrink = this.buildType == 'room' ? 0.11 : this.buildType == 'floor' ?  0.082 :  0.2   ;//防止mesh重叠冲突(给一个不寻常的数字)  但离远了还是会有点闪烁
-        if(this.points.length >= 3){ 
-            let holes = this.holes.concat(this.parentHoles)
-            let holesPoints = holes.filter(e=>e.points.length>2).map(e=>e.points)
-            this.box.geometry = MeshDraw.getExtrudeGeo(this.points, holesPoints, {
-                depth:this.zMax-this.zMin-shrink,
-                UVGenerator: new MetricUVGenerator()
-            }) 
-            if(this.buildType == 'building' ){
-                this.box.position.z = this.zMin - shrink / 2  
-            }else{
-                this.box.position.z = this.zMin + shrink / 2 
-            }
-             
-        }
-    }
-    
-     
-    
-    update(options={}){ 
-        super.update(this.buildType != 'floor' && options.ifUpdateMarkers)
-        let length = this.points.length
-        
-        
-       
-        {//确保一下一样
-            if(this.originHole){ 
-                this.points = this.originHole.points //完全等于building的hole
-            }
-            if(this.buildType == 'hole'){
-                this.zMin = this.buildParent.zMin;
-                this.zMax = this.buildParent.zMax;
-            } 
-        }
-        
-        
-        
-        if(!options.dontUpdateBox){
-            let boxOwner
-            if(this.buildType == 'hole'){
-                if(this.buildParent.buildType == 'building'){ //若是整栋大楼的hole,在每层都要更新下它的对应hole
-                    this.buildParent.buildChildren.forEach(floor=>{
-                        let holeAtFloor = floor.parentHoles.find(e=>e.originHole == this ) 
-                        holeAtFloor && holeAtFloor.update()  //刚开始创建时还没创建对应的 holeAtFloor会为null
-                    })
-                } 
-                boxOwner = this.buildParent 
-            }else{
-                boxOwner = this
-            }
-            boxOwner.updateBox()
-        }
-        
-        
-        
-        {//update lines
-            
-            let positions = [];
-           
-            this.points.forEach((point, index)=>{
-                
-                //竖线:
-                positions.push(point.clone().setZ(this.zMin), point.clone().setZ(this.zMax))
-                
-                //横线
-                let nextPoint = this.points[(index+1)%length]; 
-                if(!nextPoint)return;//when length==1
-                
-                positions.push(point.clone().setZ(this.zMax), nextPoint.clone().setZ(this.zMax))//上横线
-                positions.push(point.clone().setZ(this.zMin), nextPoint.clone().setZ(this.zMin))//下横线
-            }) 
-            
-            LineDraw.moveLine(this.lineMesh,positions)
-             
-        }
-        
-        if(!options.dontUpdateChildren){
-            if(this.buildType == 'building'  ){
-                this.buildChildren.forEach(floor=>{
-                    floor.points = this.points 
-                    floor.update()
-                })
-                
-            } 
-            
-            { 
-                let holes = this.holes.concat(this.parentHoles) 
-                holes.forEach(hole=> {  
-                    
-                    hole.update({dontUpdateBox:true})//父级更新了box,hole就不需要更新box了
-                }) 
-                    
-            } 
-        
-        } 
-    }
-    
-    
-     
-    
-    
-    
-    getHolesArea(){
-        let holes = this.holes.concat(this.parentHoles)
-        let outHoles, holesArea = 0
-        if(holes.length>=2){//合并holes。如果能在绘制时直接合并holes就好啦,这步就转移到那去,但是要删除hole好麻烦
-              
-            let holes_ = holes.map(e=>e.points)
-            
-            outHoles = math.getPolygonsMixedRings(holes_,  true )
-            outHoles.forEach(e=>{ 
-                holesArea+=e.area
-            }) 
-            outHoles = outHoles.map(e=>e.points)
-            
-            
-        }else{
-            outHoles = holes.map(e=>e.points)
-            outHoles.forEach(e=> holesArea += Math.abs(math.getArea(e)))                
-        }
-        return holesArea
-        
-    }
-    
-    getArea(ifRidOfHoles){//面积
-        //不排除hole
-        return Math.abs(math.getArea(this.points)) - (ifRidOfHoles ? this.getHolesArea() : 0)
-    }
-    
-    getVolume(ifRidOfHoles){//体积
-        let {zMin , zMax} = this.getRealZ()
-        let height = zMax - zMin;
-        if(isNaN(height))height = 0
-        return this.getArea(ifRidOfHoles) * height
-    
-    }
-    
-    getRealZ(){//求真实高度时用到的
-        let zMin , zMax
-        if (this.buildType == 'building') {
-            //building的zMax和zMin一样的所以要算
-            let top = this.buildChildren[this.buildChildren.length - 1]
-            let btm = this.buildChildren[0] 
-            zMin = btm ? btm.zMin : 0  //建好的建筑不加楼的话是0
-            zMax = top ? top.zMax : 0
-        }else if(this.buildType == 'hole'){
-            return this.buildParent.getRealZ()
-        }else{
-            zMin = this.zMin,  zMax = this.zMax
-        }
-        return {zMin,zMax}
-    }
-    
-    
-    /* getDrawZ(){ //画线和box时用到的z
-        let zMin , zMax
-        if(this.buildType == 'hole'){
-             if(this.buildParent.buildType == 'building' && atFloor){ 
-                 zMin = atFloor.zMin,  zMax = atFloor.zMax 
-             }else{
-                 zMin = this.buildParent.zMin,  zMax = this.buildParent.zMax
-             }
-        }else{
-            zMin = this.zMin,  zMax = this.zMax
-        }
-        
-        return {zMin, zMax}
-        
-    } */
-    
-    
-    
-    getBound(){
-        let bound = new THREE.Box3
-         
-        let {zMin , zMax} = this.getRealZ()
-        
-        let points = this.buildType == 'floor' ? this.buildParent.points : this.points
-        points.forEach(p=>{
-            bound.expandByPoint(p.clone().setZ(zMin))
-            bound.expandByPoint(p.clone().setZ(zMax))
-        }) 
-        return bound
-    }
-    
-     
-    getMarkerMaterial(type) {
-        if(!markerMats){
-            markerMats = {  
-                default:    new THREE.MeshBasicMaterial({  
-                    transparent: !0,
-                    color,
-                    opacity: 0.8,
-                    map: texLoader.load(Potree.resourcePath+'/textures/whiteCircle.png' ),  
-                    depthTest:false,
-                    
-                }),
-                midPrepare:    new THREE.MeshBasicMaterial({ //线中心的半透明点  
-                    transparent: !0,
-                    color,
-                    opacity: 0.4,
-                    map: texLoader.load(Potree.resourcePath+'/textures/whiteCircle.png' ), 
-                    depthTest:false,
-                }),  
-                hover:    new THREE.MeshBasicMaterial({   
-                    transparent: !0,
-                    color,
-                    opacity: 1,
-                    map: texLoader.load(Potree.resourcePath+'/textures/whiteCircle.png' ), 
-                    depthTest:false,
-                     
-                }),
-                select:    new THREE.MeshBasicMaterial({   
-                    transparent: !0,
-                    color:new THREE.Color('#00C8AF'),
-                    opacity: 1,
-                    map: texLoader.load(Potree.resourcePath+'/textures/whiteCircle.png' ), 
-                    depthTest:false,
-                     
-                }),   
-            }
-            
-        }
-        return markerMats[type]
-        
-    }
-    
-    
-    setMarkerSelected(marker, state, hoverObject){ 
-        //console.warn(marker.id , state, hoverObject)
-         
-        
-        if(state == 'select'){
-            marker.selected = true
-            marker.material = this.getMarkerMaterial('select')
-        }else if(state == 'unselect'){
-            marker.selected = false
-            marker.material = this.getMarkerMaterial('default')
-        }else{
-            if(marker.selected)return //选中时不允许修改为除了'unselect'以外的状态
-            
-            if(state == 'hover'){
-                marker.material = this.getMarkerMaterial('hover')
-            }else if(state == 'unhover'){
-                if(marker.name.includes('mid')){
-                    marker.material = this.getMarkerMaterial('midPrepare')
-                }else{
-                    marker.material = this.getMarkerMaterial('default')
-                } 
-            }
-        }
-    }
-    
-    
-    select(){
-        //最多再显示一层子级的线,如building不会显示room中的hole的线
-        //box是一直显示的,但会切换材质 
-        
-        /* 
-            选中                  box                                     线
-            
-            building            自己(底盘)选中                 自己, floor不带hole
-        
-            floor               自己选中                         自己, room不带hole
-            
-            room                自己选中                         自己   
-        
-         */  //注:自己的就代表定包括hole,如果有parentHoles的也(building上的hole的对应)
-        
-        
-        //console.log('select '+this.name,   this.selected)
-        
-        if(this.selected)return
-        
-        if(this.box){
-            this.box.material = this.mats.boxSelected;
-        }
-        
-        if(this.buildType == 'building'|| this.buildType == 'floor'){
-            this.buildChildren.forEach(e=>{
-                e.lineMesh.visible = true
-            })
-              
-            if(this.buildType == 'floor'){
-                Potree.Utils.setObjectLayers(this.box, 'bothMapAndScene' ) 
-                Potree.Utils.setObjectLayers(this.buildParent.box, 'siteModelMapUnvisi' ) //当选中floor或room时,building在地图不可见
-            }
-        }else if(this.buildType == 'room'){
-            Potree.Utils.setObjectLayers(this.buildParent.box, 'bothMapAndScene' )
-            Potree.Utils.setObjectLayers(this.buildParent.buildParent.box, 'siteModelMapUnvisi' )
-        }
-        
-        
-        
-        
-        
-        this.lineMesh.visible = true
-        this.markers && this.markers.forEach(e=>Potree.Utils.updateVisible(e,'select',true) )
-        this.midMarkers && this.midMarkers.forEach(e=>e.visible = true)
-        
-        let holes = this.holes.concat(this.parentHoles)
-        holes.forEach(e=>e.select()) 
-        
-        this.selected = true
-        this.dispatchEvent({type:'select'})
-    }
-    
-    
-    unselect(){
-        if(!this.selected)return
-        //console.log('unselect '+this.name  )
-        if(this.box){
-            this.box.material = this.mats.boxDefault;
-        }
-        
-        if(this.buildType == 'building' || this.buildType == 'floor'){ 
-            this.buildChildren.forEach(e=>{  //(这里要保证选中前要先取消选中,否则如选中房间后取消了楼层,房间线就隐藏了)
-                e.lineMesh.visible = false
-            })  
-            
-            if(this.buildType == 'floor'){
-                Potree.Utils.setObjectLayers(this.box, 'siteModelMapUnvisi' ) 
-                Potree.Utils.setObjectLayers(this.buildParent.box, 'bothMapAndScene' ) 
-            }
-            
-        }else if(this.buildType == 'room'){
-            Potree.Utils.setObjectLayers(this.buildParent.box, 'siteModelMapUnvisi' )
-            Potree.Utils.setObjectLayers(this.buildParent.buildParent.box, 'bothMapAndScene' )
-        }
-        
-        this.lineMesh.visible = false
-        this.markers && this.markers.forEach(e=>Potree.Utils.updateVisible(e,'select',false) )
-        this.midMarkers && this.midMarkers.forEach(e=>e.visible = false)
-        
-        let holes = this.holes.concat(this.parentHoles)
-        holes.forEach(e=>e.unselect()) 
-        
-        this.selected = false
-        this.dispatchEvent({type:'unselect'})
-    }
-    
-     
-    
-    
-    ifContainsPoint(position){//看它所定义的空间是否包含某个坐标(要排除hole)
-    
-        let {zMin , zMax} = this.getRealZ()
-        if(position.z < zMin ||  position.z > zMax   ) return
-    
-        let holes = this.holes.concat(this.parentHoles)
-        let holesPoints = holes.filter(e=>e!=this && e.points.length>2).map(e=>e.points) 
-        let inShape = math.isPointInArea(this.points, holesPoints, position) 
-        
-         
-        return !!inShape 
-    }
-     
-}
-
-
-
-
-
-class MetricUVGenerator{
-    constructor(){
-        this.a = new THREE.Vector3,
-        this.b = new THREE.Vector3,
-        this.c = new THREE.Vector3,
-        this.d = new THREE.Vector3
-    }
-    generateTopUV(t, e, n, r, o) {
-        return [new THREE.Vector2(e[3 * n],e[3 * n + 1]), new THREE.Vector2(e[3 * r],e[3 * r + 1]), new THREE.Vector2(e[3 * o],e[3 * o + 1])]
-    }
-    
-    generateSideWallUV(t, e, n, r, o, a) {
-        var s = e;
-        this.a.set(s[3 * n], s[3 * n + 1], s[3 * n + 2]),
-        this.b.set(s[3 * r], s[3 * r + 1], s[3 * r + 2]),
-        this.c.set(s[3 * o], s[3 * o + 1], s[3 * o + 2]),
-        this.d.set(s[3 * a], s[3 * a + 1], s[3 * a + 2]);
-        var c = this.a.x !== this.b.x
-          , l = c ? this.b : this.d
-          , u = this.a.distanceTo(l)
-          , d = l.distanceTo(this.c);
-        return [new THREE.Vector2(this.a.x,0), c ? new THREE.Vector2(this.a.x + u,0) : new THREE.Vector2(this.a.x,d), new THREE.Vector2(this.a.x + u,d), c ? new THREE.Vector2(this.a.x,d) : new THREE.Vector2(this.a.x + u,0)]
-    }
-}
- 

File diff suppressed because it is too large
+ 0 - 1325
src/custom/modules/siteModel/SiteModel.js


+ 0 - 36
src/custom/objects/fireParticle/Tween.js

@@ -1,36 +0,0 @@
-import * as THREE from "../../../../libs/three.js/build/three.module.js";
-import Common  from "../../utils/Common.js";
-
-
-
-class Tween {
-
-    constructor(times, values) {
-      this.times = times || []
-      this.values = values || []
-    }
-  
-    lerp(t) {
-      if(this.times.length == 0) return
-      let i = 0, n = this.times.length
-      while(i < n && t > this.times[i]) i++
-      if(i == 0) return this.values[0]
-      if(i == n) return this.values[n-1]
-      const ratio = (t - this.times[i-1]) / (this.times[i] - this.times[i-1])
-      if(this.values[0] instanceof THREE.Vector3) {
-        return this.values[i-1].clone().lerp(this.values[i], ratio)
-      } else {
-        return this.values[i-1] + ratio * (this.values[i] - this.values[i-1])
-      }
-      
-    }
-    
-    
-    clone () {
-        return Common.CloneClassObject(this)
-	}
-    
-  
-  }
-  
-  export default Tween

+ 0 - 475
src/custom/objects/fireParticle/explode/ExplodeParticle.js

@@ -1,475 +0,0 @@
-import*as THREE from "../../../../../libs/three.js/build/three.module.js";
-import {vertexShader, fragmentShader} from './shader.js'
-import Tween from '../Tween.js'
-import Particle from './Particle.js'
-import {util} from './Util.js'
-import {Shape} from './const.js'
-
-let particleTexture
-
-const getTexture = ()=>{
-    if (!particleTexture) {
-        particleTexture = new THREE.TextureLoader().load(Potree.resourcePath + '/textures/explode.png')
-    }
-    return particleTexture
-}
-const sphereGeo = new THREE.SphereBufferGeometry(1, 10,4);
-const sphereMat = new THREE.MeshBasicMaterial({wireframe:true, color:"#ffffff"})
-
-const defaults = {
-    position: new THREE.Vector3(0,0,1),
-
-    positionShape: Shape.SPHERE,
-
-    positionRange: new THREE.Vector3(1,1,1),
-    //cube
-
-    radius: 1.3,
-    //sphere
-
-    velocityShape: Shape.SPHERE,
-
-    velocity: new THREE.Vector3(0,0,2),
-    //cube
-    velocityRange: new THREE.Vector3(0,0,3),
-    
-    //sphere
-    speed: 0.4, 
-    speedRange: 1,
-
-    size: 0.4,
-    sizeRange: 2,
-    //sizeTween: new Tween( [0, 0.05, 0.3, 0.45], [0, 1, 3, 0.1] ),
-    sizeTween: [[0, 0.04, 0.2, 1],[0.1, 1, 6, 8]] ,
-
-    color: new THREE.Vector3(1.0,1.0,1.0),
-    colorRange: new THREE.Vector3(0,0,0),
-    colorTween: new Tween(),
-
-    opacity: 1.0,
-    opacityRange: 0.0,
-    opacityTween: new Tween([0, 0.06, 0.3, 0.8, 1],[0, 1, 0.3, 0.05, 0]),
-    blendMode: THREE.AdditiveBlending,
-
-    acceleration: 0.5,
-    accelerationRange: 0,
-
-    angle: 0,
-    angleRange: 0,
-    angleVelocity: 0,
-    angleVelocityRange: 0,
-    angleAcceleration: 0,
-    angleAccelerationRange: 0,
-    
-    strength:1,
-    
-    //particlesPerSecond: 8,
-    particleDeathAge: 0.7 , 
-    recycleTimes : 3 , //每个粒子在一次爆炸后循环次数,循环完毕进入particleSpaceTime,等待下一次爆炸.
-    //爆炸时长: particleDeathAge * (recycleTimes+1)
-    particleSpaceTime:   3, //间隔
-    
-    
-}
-
-class ExplodeParticle extends THREE.Points {
-
-    constructor(params) {
-        super()
-         
-
-        this.age = 0
-        this.alive = true
-        //this.deathAge = 60
-        this.loop = true
-
-        this.blendMode = THREE.NormalBlending
-
-        this.setParameters(params)
-        this.createParticles()
-        this.frustumCulled = false//似乎是禁止相机裁剪,否则会在某些角度消失。但是会不会更耗性能呢?
-        //------------------------------------
-
-        this.setSize({viewport:viewer.mainViewport})
-        this.setFov(viewer.fov)
-        
-        let setSize = (e)=>{
-            if(e.viewport.name != "MainView")return
-            this.setSize(e)
-        }
-        let setFov = (e)=>{
-            this.setFov(e.fov) 
-        }
-            
-        /* let reStart = (e)=>{
-            if(e.v){//重新一个个放出粒子,否则会一股脑儿全部出来,因为同时大于粒子周期了一起重新生成出现。
-                setTimeout(()=>{//会先update一次delta为pageUnvisile的时间才触发 
-                    //console.log('归零') 
-                    //this.reStart()
-                },1) 
-            } 
-        } */
-        viewer.addEventListener('resize',setSize) 
-        viewer.addEventListener('fov_changed',setFov)
-        //viewer.addEventListener('pageVisible', reStart)
-        
-        this.addEventListener('dispose',()=>{
-            viewer.removeEventListener('resize',setSize) 
-            viewer.removeEventListener('fov_changed',setFov)
-            //viewer.removeEventListener('pageVisible', reStart)
-        })  
- 
-        
-    }
-    
-    
-    computeParams(){
-        if(this.curve){
-            this.position.copy(this.curve.points[0])
-        }
-         
-         
-         
-        const minSize = 0.8, maxSize = 10, minRadiusBound = 0.2, maxRadiusBound = 20;
-        let size = minSize + (maxSize - minSize) * THREE.Math.smoothstep(this.radius*this.strength , minRadiusBound, maxRadiusBound);
-        
-        this.sizeTween.values = this.defaultSizeTween.values.map(e=> e*size)
-        
-        this.particleCount = Math.ceil( this.strength  * this.radius * 5 /*  * this.radius  * this.radius */  )
-     
-        this.speed = defaults.speed * this.radius;
-        this.speedRange = defaults.speedRange * this.radius;
-     
-        console.log(this.particleCount)
-        
-        {
-            this.boundPoints = []
-            this.boundPoints.push(this.position.clone())    
-            let maxSize = this.sizeTween.values.slice().sort((a,b)=>b-a)[0]  
-            let margin = maxSize * 0.35 + 0.5;  
-            let scale = this.radius+margin
-            let sphere = new THREE.Sphere(this.position, scale)//加上防止剪裁
-            this.boundingSphere = sphere //虽然还是会有一些后续移动的会超出 
-            this.boundingBox = new THREE.Box3().setFromCenterAndSize(this.position, new THREE.Vector3(scale*2,scale*2,scale*2)) 
-            /* if(!this.debugSphere){
-                this.debugSphere = new THREE.Mesh(sphereGeo, sphereMat)
-                this.add(this.debugSphere)
-            } 
-            this.debugSphere.scale.set(scale,scale,scale)  */
-        }
-    }
-    getPointsForBound(){
-        return this.boundPoints; //可以用于expand实时bound的点, 不含particle的size等边距
-    }   
-
-    reStart(){
-        this.age = 0;
-        
-        this.createParticles()  
-    }
-
-
-    setParameters(params) {
-        
-        params = $.extend({}, defaults, params)
-         
-         
-        for (var key in params) { 
-            let value = params[key] 
-            if (key == 'position')
-                this.position.copy(value)
-            else if (value instanceof Array && value[0]instanceof Array){
-                this[key] = new Tween(...value)
-            }else if(value instanceof THREE.Vector3 || value instanceof THREE.Color){
-                this[ key ] = value.clone()
-            }else{
-                this[key] = value;
-            }
-        }
-        
-        
-        this.defaultSizeTween = this.sizeTween.clone()
-        //Object.assign(this, params) 
-
-        this.particles = []
-        this.age = 0.0
-        this.alive = true
-        
-        this.geometry = new THREE.BufferGeometry() 
-        this.computeParams() 
-        this.material = new THREE.ShaderMaterial({
-            uniforms: {
-                u_sampler: {
-                    value: this.texture || getTexture()
-                },
-                heightOfNearPlane: {
-                    type: "f",
-                    value: 0
-                }//相对far ,以确保画面缩放时点的大小也会缩放
-            },
-            vertexShader,
-            fragmentShader,
-            transparent: true,
-            alphaTest: 0.5,
-            depthTest: this.blendMode == THREE.NormalBlending,
-            blending: this.blendMode
-        })
-         
-         
-    }
-
-
-    createParticles() {
-        this.particles = []
-        const count = this.particleCount
-        const positionArray = new Float32Array(count * 3)
-        const colorArray = new Float32Array(count * 3)
-
-        const sizeArray = new Float32Array(count)
-        const angleArray = new Float32Array(count)
-        const opacityArray = new Float32Array(count)
-        const visibleArray = new Float32Array(count)
-
-        for (let i = 0; i < count; i++) {
-            const particle = this.createParticle()
-            /* positionArray[i * 3] = particle.position.x
-            positionArray[i * 3 + 1] = particle.position.y
-            positionArray[i * 3 + 2] = particle.position.z
-            colorArray[i * 3] = particle.color.r
-            colorArray[i * 3 + 1] = particle.color.g
-            colorArray[i * 3 + 2] = particle.color.b
-            sizeArray[i] = particle.size
-            angleArray[i] = particle.angel
-            opacityArray[i] = particle.opacity
-            visibleArray[i] = particle.alive */
-            this.particles[i] = particle
-        }
-        this.geometry.setAttribute('position', new THREE.BufferAttribute(positionArray,3))
-        this.geometry.setAttribute('color', new THREE.BufferAttribute(colorArray,3))
-        this.geometry.setAttribute('angle', new THREE.BufferAttribute(angleArray,1))
-        this.geometry.setAttribute('size', new THREE.BufferAttribute(sizeArray,1))
-        this.geometry.setAttribute('visible', new THREE.BufferAttribute(visibleArray,1))
-        this.geometry.setAttribute('opacity', new THREE.BufferAttribute(opacityArray,1))
-
-        
-
-    }
-    
-    
-    
-     
-
-    createParticle() {
-
-        const particle = new Particle()
-        particle.sizeTween = this.sizeTween
-        particle.colorTween = this.colorTween
-        particle.opacityTween = this.opacityTween
-        particle.deathAge = this.particleDeathAge
-
-        if (this.positionShape == Shape.CUBE) {
-            particle.position = util.randomVector3(new THREE.Vector3, this.positionRange)
-        }
-
-        if (this.positionShape == Shape.SPHERE) {
-            /* const z = 2 * Math.random() - 1
-              const t = Math.PI * 2 * Math.random()
-              const r = Math.sqrt(1 - z*z)
-              const vec3 = new THREE.Vector3(r * Math.cos(t), r * Math.sin(t), z)
-              particle.position = vec3.multiplyScalar(this.radius)  */
-
-            const y = 2 * Math.random() - 1
-            const t = Math.PI * 2 * Math.random();
-            const r = Math.sqrt(1 - y * y);
-            const vec3 = new THREE.Vector3(r * Math.cos(t),y,r * Math.sin(t));
-            particle.position = vec3.multiplyScalar(this.radius)
-
-        }
-
-        if (this.velocityShape == Shape.CUBE) {
-            particle.velocity = util.randomVector3(this.velocity, this.velocityRange)
-
-        }
-
-        if (this.velocityShape == Shape.SPHERE) {
-            const direction = new THREE.Vector3().addVectors(particle.position, new THREE.Vector3(0,0,this.radius*2))//向上升?
-            const speed = util.randomValue(this.speed, this.speedRange)
-            particle.velocity = direction.normalize().multiplyScalar(speed)
-        }
-
-        particle.acceleration = util.randomValue(this.acceleration, this.accelerationRange)
-
-        particle.angle = util.randomValue(this.angle, this.angleRange)
-        particle.angleVelocity = util.randomValue(this.angleVelocity, this.angleVelocityRange)
-        particle.angleAcceleration = util.randomValue(this.angleAcceleration, this.angleAccelerationRange)
-
-        particle.size = util.randomValue(this.size, this.sizeRange)
-
-        const color = util.randomVector3(this.color, this.colorRange)
-        particle.color = new THREE.Color().setHSL(color.x, color.y, color.z)
-
-        particle.opacity = util.randomValue(this.opacity, this.opacityRange)
-     
-
-        return particle
-    }
-
-    update(dt) {
-        if(!Potree.Utils.getObjVisiByReason(this,'force')){//被手动隐藏了
-            return
-        }
-        if(this.delayStartTime>0){ // 爆炸延迟
-            return this.delayStartTime -= dt 
-        }
-        
-        
-        
-        if(!Potree.Utils.isInsideFrustum(this.boundingSphere, viewer.scene.getActiveCamera())){
-            Potree.Utils.updateVisible(this,'isInsideFrustum', false ) //不在视野范围
-            return
-        }else{
-            Potree.Utils.updateVisible(this,'isInsideFrustum', true )
-        }
-        //const timeRatio = 0.5
-        if(dt > 1){
-            console.log('update dt>1', dt)
-        }
-        //dt *= timeRatio
-        let particleDeathAge = this.particleDeathAge/*  * timeRatio */
-        let particleSpaceTime = this.particleSpaceTime /* * timeRatio */
-
-        const recycleIndices = []
-        const recycleAges = []
-        const recycleRebornCount = []
-        
-        const positionArray = this.geometry.attributes.position.array
-        const opacityArray = this.geometry.attributes.opacity.array
-        const visibleArray = this.geometry.attributes.visible.array
-        const colorArray = this.geometry.attributes.color.array
-        const angleArray = this.geometry.attributes.angle.array
-        const sizeArray = this.geometry.attributes.size.array
-
-        for (let i = 0; i < this.particleCount; i++) {
-            const particle = this.particles[i]
-            if (particle.alive) {
-                particle.update(dt)
-                if (particle.age > particleDeathAge) { 
-                    particle.alive = 0.0
-                    if(particle.rebornCount >= this.recycleTimes){
-                        particle.deadAge = particle.age - particleDeathAge //已死亡时间
-                    }else{//直接循环
-                        recycleIndices.push(i)
-                        recycleAges.push(/* ( */particle.age - particleDeathAge/* )%(this.particleDeathAge ) */)
-                        recycleRebornCount.push(particle.rebornCount+1)
-                    }
-                    
-                }
-                positionArray[i * 3] = particle.position.x
-                positionArray[i * 3 + 1] = particle.position.y
-                positionArray[i * 3 + 2] = particle.position.z
-                colorArray[i * 3] = particle.color.r
-                colorArray[i * 3 + 1] = particle.color.g
-                colorArray[i * 3 + 2] = particle.color.b
-                visibleArray[i] = particle.alive
-                opacityArray[i] = particle.opacity
-                angleArray[i] = particle.angle
-                sizeArray[i] = particle.size
-            }else{
-                if(particle.rebornCount >= this.recycleTimes){
-                    if(particle.age > particleDeathAge) {//其他已经死亡的粒子的时间继续增加
-                        particle.deadAge += dt
-                    }
-                }
-            }                
-                
-             
-            
-            if (particle.rebornCount >= this.recycleTimes && particle.age > particleDeathAge) {//已经死亡 
-                if(particle.deadAge >=  particleSpaceTime){//死亡时间超过设定的间隔时间后重启 
-                    recycleIndices.push(i)
-                    let wholeTime = particleDeathAge * (this.recycleTimes+1) + particleSpaceTime 
-                    recycleAges.push((particle.deadAge - particleSpaceTime)% wholeTime ) //剩余时间就是重生后的age
-                    recycleRebornCount.push(0)
-                } 
-            }
-            
-        }
-        
-        
-        
-
-        this.geometry.attributes.size.needsUpdate = true
-        this.geometry.attributes.color.needsUpdate = true
-        this.geometry.attributes.angle.needsUpdate = true
-        this.geometry.attributes.visible.needsUpdate = true
-        this.geometry.attributes.opacity.needsUpdate = true
-        this.geometry.attributes.position.needsUpdate = true
-
-        if (!this.alive)
-            return
-
-        if (this.age < particleDeathAge) {
-            let startIndex = Math.round(this.particleCount * (this.age + 0)/ particleDeathAge)
-            let endIndex = Math.round(this.particleCount * (this.age + dt)/ particleDeathAge)
-            if (endIndex > this.particleCount) {
-                endIndex = this.particleCount
-            }
-            for (let i = startIndex; i < endIndex; i++) {
-                this.particles[i].alive = 1.0
-            }
-        }
-
-
-
-        for (let j = 0; j < recycleIndices.length; j++) {
-            let i = recycleIndices[j]
-            
-            this.particles[i] = this.createParticle()
-            this.particles[i].alive = 1.0  //出生
-            this.particles[i].age = recycleAges[j]  
-            this.particles[i].rebornCount= recycleRebornCount[j]
-            /* if(this.particles[i].age < particleDeathAge){
-                positionArray[i * 3] = this.particles[i].position.x
-                positionArray[i * 3 + 1] = this.particles[i].position.y
-                positionArray[i * 3 + 2] = this.particles[i].position.z
-                visibleArray[i] = particle.alive?
-            } */
-        }
-        this.geometry.attributes.position.needsUpdate = true
-
-        this.age += dt
-
-        if (this.age > this.deathAge && !this.loop) {
-            this.alive = false
-        }
-
-    }
-
-    setSize(e) {
-        let viewport = e.viewport
-        this.screenHeight = viewport.resolution.y
-        this.setPerspective(this.fov, this.screenHeight)
-    }
-
-    setFov(fov) {
-        this.fov = fov
-        this.setPerspective(this.fov, this.screenHeight)
-    }
-
-    setPerspective(fov, height) {
-        //this.uniforms.heightOfNearPlane.value = Math.abs(height / (2 * Math.tan(THREE.Math.degToRad(fov * 0.5))));
-        let far = Math.abs(height / (2 * Math.tan(THREE.Math.degToRad(fov * 0.5))));
-        this.material.uniforms.heightOfNearPlane.value = far
-    }
-    updateGeometry(){ 
-        this.computeParams()
-        this.reStart()  
-    }
-    dispose(){
-        this.geometry.dispose();
-        this.material.dispose();
-        this.dispatchEvent('dispose') 
-    }
-}
-
-export default ExplodeParticle

+ 0 - 57
src/custom/objects/fireParticle/explode/Particle.js

@@ -1,57 +0,0 @@
-// import { vertexShader, fragmentShader } from './shader'
-// import Tween from './tween'
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
-
-const DEG2RAD = Math.PI / 180
-
-class Particle {
-  
-  constructor() {
-    
-    this.position = new THREE.Vector3()
-    this.velocity = new THREE.Vector3()
-     
-    
-    this.angle = 0
-    this.angleVelocity = 0
-    this.angleAcceleration = 0
-    this.size = 16
-    this.color = new THREE.Color()
-    this.opacity = 1
-
-    this.rebornCount = 0//重生次数
-    this.age = 0
-    this.alive = 0 //注意,一开始时是未出生的
-    this.deadAge = 0//已死亡时间
-    this.sizeTween = null
-    this.colorTween = null
-    this.opacityTween = null
-  }
-
-  update(dt) { 
-    //s = s0 + (v0 + at) * t 或 lastS + delta(vt)
-    
-    this.position.add(this.velocity.clone().multiplyScalar(dt))
-    this.velocity.multiplyScalar( 1+this.acceleration*dt )
-    
-    this.angle += this.angleVelocity * DEG2RAD * dt
-    this.angleVelocity += this.angleAcceleration * DEG2RAD * dt
-    this.age += dt
-
-    if(this.sizeTween.times.length > 0) {
-      this.size = this.sizeTween.lerp(this.age/this.deathAge)
-    }
-
-    if(this.colorTween.times.length > 0) {
-      const colorHSL = this.colorTween.lerp(this.age/this.deathAge)
-      this.color = new THREE.Color().setHSL(colorHSL.x, colorHSL.y, colorHSL.z)
-    }
-
-    if(this.opacityTween.times.length > 0) {
-      this.opacity = this.opacityTween.lerp(this.age/this.deathAge)
-    }
-  }
-
-}
-
-export default Particle

+ 0 - 18
src/custom/objects/fireParticle/explode/Util.js

@@ -1,18 +0,0 @@
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
-export class Util {
-    constructor() {}
-
-    randomValue(min, max) {
-        //return min + max * (Math.random() - 0.5)
-        let p = Math.random()
-        return min * p + max * (1-p)
-    }
-
-    randomVector3(min, max) {
-        const rand3 = new THREE.Vector3(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5)
-        return new THREE.Vector3().addVectors(min, new THREE.Vector3().multiplyVectors(max, rand3))
-    }
-}
-
-const util = new Util();
-export { util };

+ 0 - 4
src/custom/objects/fireParticle/explode/const.js

@@ -1,4 +0,0 @@
-export const Shape = {
-    CUBE: 1,
-    SPHERE: 2
-  }

+ 0 - 40
src/custom/objects/fireParticle/explode/shader.js

@@ -1,40 +0,0 @@
-export const vertexShader = `
-  attribute vec3 color;
-  attribute float size;
-  attribute float angle;
-  attribute float opacity;
-  attribute float visible;
-  varying vec4 vColor;
-  varying float vAngle;
-  uniform float heightOfNearPlane;
-  
-  void main() {
-    if(visible > 0.5) {
-      vColor = vec4(color, opacity);
-    } else {
-      vColor = vec4(0.0, 0.0, 0.0, 0.0);
-    }
-    vAngle = angle;
-    vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
-    gl_Position = projectionMatrix * mvPosition;
-    
-    gl_PointSize = ( heightOfNearPlane * size ) / gl_Position.w;
-  }
-` 
-
-export const fragmentShader = `
-  uniform sampler2D u_sampler;
-  varying vec4 vColor;
-  varying float vAngle;
-  void main() {
-    gl_FragColor = vColor;
-    float u = cos(vAngle);
-    float v = sin(vAngle);
-    vec2 uv = vec2(
-      u * (gl_PointCoord.x - 0.5) + v * (gl_PointCoord.y - 0.5) + 0.5, 
-      u * (gl_PointCoord.y - 0.5) - v * (gl_PointCoord.x - 0.5) + 0.5
-    );
-    vec4 texture = texture2D(u_sampler, uv);
-    gl_FragColor = gl_FragColor * texture;
-  }
-`

+ 0 - 274
src/custom/objects/fireParticle/fire/FireParticle.js

@@ -1,274 +0,0 @@
-// import { vertexShader, fragmentShader } from './shaders'
-// import Tween from './tween'
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
-import { vertexShader, fragmentShader } from './shader.js'
-
-let ONE_SPRITE_ROW_LENGTH = 0.25    //对应着色器的0.25
-let texture 
- 
-
-const getTexture = ()=>{
-    if(!texture){
-        texture = new THREE.TextureLoader().load( Potree.resourcePath+'/textures/fire.png')
-    }
-    return texture
-}
-
-const boxGeo = new THREE.BoxBufferGeometry(1,1,1,1);
-const boxMat = new THREE.MeshBasicMaterial({wireframe:true, color:"#ffffff"})
-
-
-
-class FireParticle extends THREE.Points{
-  
-    constructor (prop) {
-        super()
-        
-        for ( var key in prop ){
-            this[key] = prop[key]
-        }
-        
-        
-         
-        this.strength = this.strength || 1
-        
-        
-         
-        this.radius = prop.radius || 1;
-        this.height = prop.height || 5;  
-        
-        this.computeParams()
-        this.geometry = this.createGeometry( this.radius, this.height, this.particleCount );
-         
-        
-        if(this.color == void 0)   this.color = 0xff3200
-        this.createMaterial( );  //小蓝火:0x00338f
-        
-      
-         
-        //---?:
-        this.velocity = new THREE.Vector3()
-        this.acceleration = new THREE.Vector3()
-        
-        this.angle = 0
-        this.angleVelocity = 0
-        this.angleAcceleration = 0
-        this.size = 16
-        
-        this.opacity = 1
-
-        this.age = 0
-        this.alive = 0
-
-        this.sizeTween = null
-        this.colorTween = null
-        this.opacityTween = null
-
-        
-         
-        this.setSize({viewport:viewer.mainViewport})
-        this.setFov(viewer.fov)
-        
-        let setSize = (e)=>{
-            if(e.viewport.name != "MainView")return
-            this.setSize(e)
-        }
-        let setFov = (e)=>{
-            this.setFov(e.fov) 
-        }
-            
-        viewer.addEventListener('resize',setSize) 
-        viewer.addEventListener('fov_changed',setFov)
-          
-        this.addEventListener('dispose',()=>{
-            viewer.removeEventListener('resize',setSize) 
-            viewer.removeEventListener('fov_changed',setFov)
-        })  
-          
-    }
-
- 
-    computeParams(){  
-        let length = (this.curve ? this.curve.wholeLength : 0) + this.radius * 2 //加上首尾的半径
-        
-        
-        const minSize = 0.3, maxSize = 3, minRadiusBound = 0.3, maxRadiusBound = 10;
-        this.size = minSize + (maxSize - minSize) * THREE.Math.smoothstep(this.radius, minRadiusBound, maxRadiusBound);
-        //console.log('fire material  particle size:', size )
-        
-        this.particleCount =  Math.ceil(   length * Math.sqrt(this.strength  * this.height )   * this.radius / (this.size * this.size) *  25  )        
-        //console.log('fire particleCount',this.particleCount)
-    }
-    getPointsForBound(){
-        return this.boundPoints; //可以用于expand实时bound的点, 不含particle的size等边距
-    }
-
-    getBound(points){ // points为生成点(圆心)
-        this.boundPoints = []  
-        let boundingBox = new THREE.Box3()
-        
-         
-        let margin = this.size * 0.13 + 0.3; 
-        
-        points.forEach(bottom=>{ 
-            let top = bottom.clone()
-            top.z +=  this.height 
-            boundingBox.expandByPoint(bottom);
-            boundingBox.expandByPoint(top);
-            this.boundPoints.push(bottom,top)            
-        })
-        let xyExpand = this.radius+margin 
-        boundingBox.expandByVector(new THREE.Vector3(xyExpand,xyExpand,margin)) 
-        this.boundingBox = boundingBox
-        
-        /* if(!this.debugBox){
-            this.debugBox = new THREE.Mesh(boxGeo, boxMat)
-            this.add(this.debugBox)
-        }
-        
-        this.debugBox.scale.copy(boundingBox.getSize(new THREE.Vector3))
-        this.debugBox.position.copy(boundingBox.getCenter(new THREE.Vector3))  */
-         
-    }
-
-
-    createGeometry( radius, height, particleCount){
-        let geometry = new THREE.BufferGeometry()
-         
-        
-        let count , points
-        if(this.positions.length>1){
-             
-            const spaceDis = 0.2;//间隔距离
-            
-            count = Math.ceil(this.curve.wholeLength / spaceDis) + 1 
-            //console.log('count', count)
-            points = this.curve.getSpacedPoints( count );  //得到的数量会比count多一个
-            count = points.length  
-            //得到的点不太均匀,两端容易点少。
-            this.getBound(points) 
-            
-        }else{
-            this.getBound(this.positions) 
-        }
-         
-        
-        var position = new Float32Array(particleCount * 3);
-        var randam = new Float32Array(particleCount);
-        var sprite = new Float32Array(particleCount);
-        var centerHeight = new Float32Array(particleCount);
-        
-        for (var i = 0; i < particleCount; i++) {
-            
-            var center = new THREE.Vector3().copy(this.positions.length>1 ? points[Math.floor(i/particleCount * count)] : this.positions[0])
-            centerHeight[i] = center.z
-            
-            if (i === 0) { 
-                // to avoid going out of Frustum
-                position[i * 3 + 0] = center.x;
-                position[i * 3 + 1] = center.y;
-                position[i * 3 + 2] = center.z;
-            }else{  
-                var r = Math.sqrt(Math.random()) * radius;
-                var angle = Math.random() * 2 * Math.PI;
-                position[i * 3 + 0] = center.x + Math.cos(angle) * r; 
-                position[i * 3 + 1] = center.y + Math.sin(angle) * r;
-                position[i * 3 + 2] = center.z + (radius - r) / radius * height/2 + height/2; //不太明白这句为什么能达到height高度
-               
-                sprite[i] = 0.25 * (Math.random() * 4 | 0);
-                randam[i] = Math.random();
-                //center在底部
-            }
-            
-            
-        }
-        
-        geometry.setAttribute('centerHeight', new THREE.BufferAttribute(centerHeight, 1));
-        geometry.setAttribute('position', new THREE.BufferAttribute(position, 3));
-        geometry.setAttribute('randam', new THREE.BufferAttribute(randam, 1));
-        geometry.setAttribute('sprite', new THREE.BufferAttribute(sprite, 1));
-        return geometry;
-    }
-    
-    
-    
-    
-    updateGeometry(){ 
-        this.computeParams()
-        this.geometry.dispose() 
-        this.geometry = this.createGeometry( this.radius, this.height, this.particleCount )
-        this.material.uniforms.size.value = this.size
-    }
-
-
-
-
-    createMaterial(){
-         
-        
-        const material = new THREE.ShaderMaterial( {
-            uniforms:{
-                color: { type: "c", value: new THREE.Color(this.color) },
-                size: { type: "f", value: this.size},
-                u_sampler: { type: "t", value: getTexture() },
-                time: { type: "f", value: 0.0 },
-                heightOfNearPlane: { type: "f", value:0},  //相对far ,以确保画面缩放时点的大小也会缩放
-                height :{ type: "f", value:this.height}  ,
-            },
-            vertexShader,
-            fragmentShader,
-            blending: THREE.AdditiveBlending, //加法融合模式 glBlendFunc(GL_ONE, GL_ONE)
-            depthTest: true,
-            depthWrite: false,
-            transparent: true
-
-        } ); 
-        this.material = material
-        this.setPerspective(this.fov, this.screenHeight)
-    }
-
-
-    setSize(e){
-        let viewport = e.viewport
-        this.screenHeight = viewport.resolution.y
-        this.setPerspective(this.fov, this.screenHeight)  
-    }
-    
-    setFov(fov){
-        this.fov = fov
-        this.setPerspective(this.fov, this.screenHeight) 
-    }
-    
-    
-    setPerspective(fov, height){
-        //this.uniforms.heightOfNearPlane.value = Math.abs(height / (2 * Math.tan(THREE.Math.degToRad(fov * 0.5))));
-        let far = Math.abs(height / (2 * Math.tan(THREE.Math.degToRad(fov * 0.5))));
-        this.material.uniforms.heightOfNearPlane.value = far 
-    }
-
-    
-    
-    update(delta){
-        if(!Potree.Utils.getObjVisiByReason(this,'force')){//被手动隐藏了
-            return
-        }
-        if(!Potree.Utils.isInsideFrustum(this.boundingBox, viewer.scene.getActiveCamera())){
-            Potree.Utils.updateVisible(this,'isInsideFrustum', false ) //不在视野范围
-            //console.log('unvi')
-            return
-        }else{
-            Potree.Utils.updateVisible(this,'isInsideFrustum', true )
-        } 
-        delta *= 1//更改速度
-        
-        this.material.uniforms.time.value = (this.material.uniforms.time.value + delta) % 1; 
-    }
-    
-    dispose(){
-        this.geometry.dispose();
-        this.material.dispose();
-        this.dispatchEvent('dispose') 
-    }
-}
-
-export default FireParticle

+ 0 - 63
src/custom/objects/fireParticle/fire/shader.js

@@ -1,63 +0,0 @@
-export const vertexShader = `
-    attribute float randam;
-    attribute float sprite;
-    attribute float centerHeight;  //add
-    
-    //uniform float fireHeight;  //add 
-    uniform float time;
-    uniform float size;
-    uniform float heightOfNearPlane;
-    
-    
-    
-    
-    //varying float heightRatio;
-    varying float vSprite;
-    varying float vOpacity; 
-    float PI = 3.14;
-
-    float quadraticIn( float t ) 
-    { 
-        float tt = t * t;
-        return tt * tt; 
-        //变化曲线  越来越快
-    } 
-    
-    void main() {
-        float progress = fract( time + ( 2.0 * randam - 1.0 ) );
-        float progressNeg = 1.0 - progress;
-        float ease = quadraticIn( progress );
-        float influence = sin( PI * ease );
-        //vec3 newPosition = position * vec3( 1.0,  1.0 , ease);
-        vec3 newPosition = position;
-        newPosition.z = (newPosition.z - centerHeight) * ease + centerHeight;
-         
-        gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );
-        gl_PointSize = ( heightOfNearPlane * size ) / gl_Position.w;
-        vOpacity = min( influence * 4.0, 1.0 ) * progressNeg;
-        vSprite = sprite;
-        
-        //heightRatio = (newPosition.z - centerHeight) / fireHeight ;
-        
-    }
-` 
-
-export const fragmentShader = `
-    uniform vec3 color;
-    uniform sampler2D u_sampler;
-
-    varying float vSprite;
-    varying float vOpacity;
-    //varying float heightRatio;
-
-    void main() 
-    {
-        
-       
-        vec2 texCoord = vec2(gl_PointCoord.x * 0.25 + vSprite, gl_PointCoord.y);
-         
-        gl_FragColor = vec4( texture2D( u_sampler, texCoord ).xyz * color * vOpacity, 1.0 );
-          
-         
-    }
-`

+ 0 - 57
src/custom/objects/fireParticle/smoke/Particle.js

@@ -1,57 +0,0 @@
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
-import Tween from '../Tween.js'
-export default class Particle{
-    constructor(prop={}){
-        this.position     = new THREE.Vector3();
-        this.velocity     = new THREE.Vector3(); // units per second
-         
-        this.angle             = 0;
-        this.angleVelocity     = 0; // degrees per second
-        this.angleAcceleration = 0; // degrees per second, per second
-        this.size = 16.0;
-    
-        this.color   = new THREE.Color();
-        this.opacity = 1.0;
-                
-        this.age   = 0;
-        this.alive = 0; // use float instead of boolean for shader purposes	
-        this.lastChangeVage = 0 //add
-
-
-        this.sizeTween    = prop.sizeTween || new Tween( [0, 1], [32, 128] );
-		this.opacityTween = prop.opacityTween || new Tween( [0.8, 2], [0.5, 0] );
-		this.colorTween   = prop.colorTween || new Tween( [0.4, 1], [ new THREE.Vector3(0,0,0.2), new THREE.Vector3(0, 0, 0.5) ] );
-   
-   
-   
-   }
-
-    update(dt)
-    {
-        this.position.add(this.velocity.clone().multiplyScalar(dt))
-        this.velocity.multiplyScalar( 1+this.acceleration*dt )
-        
-        // convert from degrees to radians: 0.01745329251 = Math.PI/180
-        this.angle         += this.angleVelocity     * 0.01745329251 * dt;
-        this.angleVelocity += this.angleAcceleration * 0.01745329251 * dt;
-
-        this.age += dt;
-        
-        // if the tween for a given attribute is nonempty,
-        //  then use it to update the attribute's value
-
-        if ( this.sizeTween.times.length > 0 )
-            this.size = this.sizeTween.lerp( this.age/this.deathAge );
-                    
-        if ( this.colorTween.times.length > 0 )
-        {
-            var colorHSL = this.colorTween.lerp( this.age/this.deathAge );
-            this.color = new THREE.Color().setHSL( colorHSL.x, colorHSL.y, colorHSL.z );
-        }
-        
-        if ( this.opacityTween.times.length > 0 )
-        {
-            this.opacity = this.opacityTween.lerp( this.age/this.deathAge);
-        }
-    }
-}

+ 0 - 594
src/custom/objects/fireParticle/smoke/SmokeParticle.js

@@ -1,594 +0,0 @@
-import * as THREE from "../../../../../libs/three.js/build/three.module.js";
-import Particle from './Particle.js'
-import Tween from '../Tween.js'
-import { vertexShader, fragmentShader } from './shader.js'
-
-const Type = Object.freeze({ "CUBE":1, "SPHERE":2 });
-let particleTexture  
-
-const getTexture = ()=>{
-    if(!particleTexture){
-        particleTexture = new THREE.TextureLoader().load( Potree.resourcePath+'/textures/smokeparticle.png')
-    }
-    return particleTexture
-}
-const boxGeo = new THREE.BoxBufferGeometry(1,1,1,1);
-const boxMat = new THREE.MeshBasicMaterial({wireframe:true, color:"#ffffff"})
-
-
-
-
-const defaults = 
-{
-    positions: [],
-    positionStyle    : "sphere",
-    positionBase     : new THREE.Vector3( 0, 0, 0 ),
- 
-    positionSpread   : new THREE.Vector3( 1, 1, 0), //cube
-     
-    radius   :   1,       // sphere
-        
-    velocityStyle    : 'cube',
-     
-    velocityBase     : new THREE.Vector3( 0,  0,  0.5),     // cube  基础速度
-    velocitySpread   : new THREE.Vector3( 1, 1, 0.3), 
-    
-    accelerationBase : 0.3,             //基础加速度
-    accelerationSpread : 0.6,	
-    
-    //没使用
-    speedBase  : 0.1,       //sphere
-    speedSpread : 0.5,
-          
-    
-
-    angleBase               : 0,
-    angleSpread             : 360,
-    angleVelocityBase       : 1,
-    angleVelocitySpread     : 30,
-    angleAccelerationBase   : 1,
-    angleAccelerationSpread : 5,
-        
-    sizeBase    :   0,  
-    sizeSpread  :   0,
-    sizeTween    : [[0, 0.3,   1], [0.3, 1.4,  6 ]], 
-    
-    
-    colorBase   :   new THREE.Vector3(0.0, 1.0, 0.5), 
-    colorSpread :   new THREE.Vector3(0.0, 0.0, 0.0),
-    colorTween   : new Tween( [0.2, 1], [ new THREE.Vector3(0,0,0.4), new THREE.Vector3(0, 0, 0.1) ] ),
-
-    opacityBase     :   0.1,//1.0,
-    opacitySpread   :   0.2,
-    opacityTween :[ [0, 0.1, 0.9, 1], [0.1, 0.4 , 0.03, 0 ] ], 
-     
-    //particlesPerSecond : 20,
-    strength : 1,
-    particleDeathAge   : 3,  //从底下升起后能持续的时间		
-    //emitterDeathAge    : 60 // time (seconds) at which to stop creating particles.
-    height : 3,
-};
-
-
-const debugSphere = new THREE.Mesh(new THREE.SphereBufferGeometry(0.03, 5,5), new THREE.MeshBasicMaterial({color:'white',depthTest:false}))
-
-export default class SmokeParticle extends THREE.Points{
-    constructor(prop={}) {
-        super()
-        
-         
-        this.blendStyle = THREE.NormalBlending; // false; 
-        this.emitterAge = 0.0;
-        //this.emitterAlive = true;
-       
-        prop = $.extend({}, defaults, prop)
-        for ( var key in prop ){
-            let value = prop[key] 
-            if(value instanceof Array && value[0] instanceof Array ) this[ key ] = new Tween(...value)
-            else if(value instanceof THREE.Vector3 || value instanceof THREE.Color){
-                this[ key ] = value.clone()
-            }else{
-                this[ key ] = value
-            }
-        }
-        
-        this.defaultSizeTween = this.sizeTween.clone()
-        this.defaultOpacityTween = this.opacityTween.clone()
-        
-        
-        this.geometry = new THREE.BufferGeometry()
-        this.computeParams()
-        this.createMaterial()
-        this.createGeometry()
-        
-        this.dynamic = true;
-        this.sortParticles = true; 
-        this.frustumCulled = false//似乎是禁止相机裁剪,否则会在某些角度消失。但是会不会更耗性能呢?
-       
-        prop.position && this.position.copy(prop.position)
-        
-        
-        
-        
-        //---------------------------------------
-        this.setSize({viewport:viewer.mainViewport})
-        this.setFov(viewer.fov)
-        
-        let setSize = (e)=>{
-            if(e.viewport.name != "MainView")return
-            this.setSize(e)
-        }
-        let setFov = (e)=>{
-            this.setFov(e.fov) 
-        }
-        /* let reStart = (e)=>{
-            if(e.v){//重新一个个放出粒子,否则会一股脑儿全部出来,因为同时大于粒子周期了一起重新生成出现。
-                setTimeout(()=>{//会先update一次delta为pageUnvisile的时间才触发 
-                    //console.log('归零') 
-                    //this.reStart()
-                },1) 
-            } 
-        } */
-        viewer.addEventListener('resize',setSize) 
-        viewer.addEventListener('fov_changed',setFov)
-        //viewer.addEventListener('pageVisible', reStart)
-        
-        this.addEventListener('dispose',()=>{
-            viewer.removeEventListener('resize',setSize) 
-            viewer.removeEventListener('fov_changed',setFov)
-            //viewer.removeEventListener('pageVisible', reStart)
-        })   
-        
-    }
-    
-    
-    
-    computeParams(){   
-         
-        let length = (this.curve ? this.curve.wholeLength : 0) + this.radius * 2 //加上首尾的半径
-        //注意:烟最低高度一米, 0<strength<1
-        if(this.positionStyle == 'cube'){
-            this.positionSpread.set(this.radius,this.radius,0)
-        } 
-        this.velocityBase.set(0,0, (this.height - 0.5 * this.accelerationBase * this.particleDeathAge * this.particleDeathAge) / this.particleDeathAge )
-        //let height = this.velocityBase.z * this.particleDeathAge + 0.5 * this.accelerationBase * this.particleDeathAge * this.particleDeathAge;//s = V0 * t + 0.5 * a * t*t ;     
-        this.velocityBase.z = Math.max(0,this.velocityBase.z);
-        this.particleCount =  Math.ceil(  length * Math.sqrt(this.strength * this.height * this.radius )   )  
-        this.particleCount = Math.max(5,this.particleCount)
-        { 
-            const minSize = 1, maxSize = 2, minBound = 0.01, maxBound = 1;
-            let size = minSize + (maxSize - minSize) * THREE.Math.smoothstep( this.strength, minBound, maxBound);
-                
-            this.sizeTween.values = this.defaultSizeTween.values.map(e=> e*size)
-        }
-        { 
-            const minSize = 1 , maxSize = 1.5, minBound = 0.01, maxBound = 1;
-            let opac = minSize + (maxSize - minSize) * THREE.Math.smoothstep( this.strength, minBound, maxBound);
-                
-            this.opacityTween.values = this.defaultOpacityTween.values.map(e=> e*opac )
-        }
-         
-        //console.log('smoke  particleCount',this.particleCount)
-        
-        
-        
-        
-    }
-
-    reStart(){
-        this.emitterAge = 0; 
-        this.createGeometry()  
-    }
-
-
-    updateGeometry(){ 
-        this.computeParams()
-        this.reStart() 
-        
-    }
-    
-    
-    createParticle(center)
-    {
-        var particle = new Particle({
-            sizeTween : this.sizeTween,
-            opacityTween : this.opacityTween,
-            colorTween : this.colorTween,
-        });
-        particle.deathAge = this.particleDeathAge
-        particle.center = center
-         
-        
-        if (this.positionStyle == 'cube')
-            particle.position = this.randomVector3( this.positionBase, this.positionSpread ); 
-        if (this.positionStyle == 'sphere')
-        {
-            /* var z = 2 * Math.random() - 1    
-            var t = Math.PI * 2 * Math.random();
-            var r = Math.sqrt( 1 - z*z ) ;
-            var vec3 = new THREE.Vector3( r * Math.cos(t), r * Math.sin(t), z );
-            particle.position = new THREE.Vector3().addVectors( this.positionBase, vec3.multiplyScalar( this.radius ) );
-           */
-            //怎么改半径
-            let y = 2 * Math.random() - 1    
-            let t = Math.PI * 2 * Math.random();
-            let r = Math.sqrt( 1 - y*y ) ; //因为 r*r = 1-y*y = x*x + z*z = r*r(cos^2 + sin^2 );
-            let lowDownRatio = 0.2 //压低近平面
-            let vec3 = new THREE.Vector3( r * Math.cos(t), y, Math.abs(r * Math.sin(t) ) * lowDownRatio);
-            particle.position = new THREE.Vector3().addVectors( this.positionBase, vec3.multiplyScalar( this.radius ) );
-           
-          
-        } 
-         
-        particle.position.add(center)//add
-         
-         
-         
-         
-         
-        if ( this.velocityStyle == 'cube' )
-        {
-            particle.velocity  = this.randomVector3( this.velocityBase,  this.velocitySpread ); 
-        }
-        if ( this.velocityStyle == 'sphere' )  
-        {
-            //var direction = particle.position.clone()
-            var direction = new THREE.Vector3(0,0,1) //烟应该都是向上的
-            var speed     = this.randomValue( this.speedBase, this.speedSpread );
-            particle.velocity  = direction.normalize().multiplyScalar( speed );
-        }
-        
-        particle.acceleration = this.randomValue( this.accelerationBase, this.accelerationSpread ); 
-
-        particle.angle             = this.randomValue( this.angleBase,             this.angleSpread );
-        particle.angleVelocity     = this.randomValue( this.angleVelocityBase,     this.angleVelocitySpread );
-        particle.angleAcceleration = this.randomValue( this.angleAccelerationBase, this.angleAccelerationSpread );
-
-        particle.size = this.randomValue( this.sizeBase, this.sizeSpread );
-
-        var color = this.randomVector3( this.colorBase, this.colorSpread );
-        particle.color = new THREE.Color().setHSL( color.x, color.y, color.z );
-        
-        particle.opacity = this.randomValue( this.opacityBase, this.opacitySpread );
-
-        particle.age   = 0;
-        particle.alive = 0; // particles initialize as inactive
-        return particle;
-    }			
-
-
-    getPointsForBound(){
-        return this.boundPoints; //可以用于expand实时bound的点, 不含particle的size等边距
-    }
-
-    getBound(points){ // points为生成点(圆心)
-        this.boundPoints = [] 
-        let boundingBox = new THREE.Box3()
-        
-        
-        let maxSize = this.sizeTween.values.slice().sort((a,b)=>b-a)[0]            
-        let margin0 = maxSize * 0.11
-        let margin1 = margin0 + 0.5   ;//保守估计还会飘出这么多距离吧: size + 飘动  
-        
-         
-        points.forEach(bottom=>{ 
-            let top = bottom.clone()
-            top.z +=  this.height 
-            boundingBox.expandByPoint(bottom);
-            boundingBox.expandByPoint(top); 
-            this.boundPoints.push(bottom,top)
-        })
-        let xyExpand = this.radius+margin1 
-        boundingBox.expandByVector(new THREE.Vector3(xyExpand,xyExpand,0))
-        boundingBox.min.z -= margin0 
-        boundingBox.max.z += margin1 
-       
-       
-       
-        this.boundingBox = boundingBox
-        
-        /* if(!this.debugBox){
-            this.debugBox = new THREE.Mesh(boxGeo, boxMat)
-            this.add(this.debugBox)
-        }
-        
-        this.debugBox.scale.copy(boundingBox.getSize(new THREE.Vector3))
-        this.debugBox.position.copy(boundingBox.getCenter(new THREE.Vector3))  */  
-         
-    }
-
-    createGeometry(){
-        this.particleArray = []
-        const positions = [];
-        const colors = [];
-        const alives = [];
-        const opacitys = [];
-        const sizes = [];
-        const angles = [];
-               
-        let count, points;
-        if(this.positions.length>1){
-             
-            const spaceDis = 0.6;//间隔距离
-            
-            count = Math.ceil(this.curve.wholeLength / spaceDis) + 1 
-             
-            points = this.curve.getSpacedPoints( count );  
-            
-            count = points.length
-            
-            /* points.forEach(e=>  { 
-                var sphere = debugSphere.clone();
-                sphere.position.copy(e)
-                viewer.scene.scene.add(sphere)
-            }) */
-            let haventGetPoints = points.slice() 
-            var getRanPoints = function(i){
-                var a = Math.random()
-                let choseIndex = Math.floor(haventGetPoints.length * a)
-                var point = haventGetPoints[choseIndex]
-                if(haventGetPoints.length == 1){
-                    haventGetPoints = points.slice()  
-                }else{
-                    haventGetPoints.splice(choseIndex, 1)
-                }
-                return point
-            }
-            
-            
-            this.getBound(points)
-        }else{
-            this.getBound(this.positions)
-        }
-        
-        
-        
-        
-        
-        for (var i = 0; i < this.particleCount; i++)
-        {
-            var center = new THREE.Vector3().copy(this.positions.length>1 ? getRanPoints(i)  : this.positions[0])
-             
-            //var center = new THREE.Vector3().copy(this.positions.length>1 ? points[Math.floor(i/this.particleCount * count)] : this.positions[0])
-              
-             
-            // remove duplicate code somehow, here and in update function below.
-            this.particleArray[i] = this.createParticle(center);
-            positions[3*i] = this.particleArray[i].position.x
-            positions[3*i+1] = this.particleArray[i].position.y
-            positions[3*i+2] = this.particleArray[i].position.z
-
-            colors[3*i] = this.particleArray[i].color.r 
-            colors[3*i+1] = this.particleArray[i].color.g
-            colors[3*i+2] = this.particleArray[i].color.b
-
-            alives[i] = this.particleArray[i].alive
-            opacitys[i] = this.particleArray[i].opacity
-            sizes[i] = this.particleArray[i].size
-            angles[i] = this.particleArray[i].angle
-        }
-
-        this.geometry.setAttribute( 'position', new THREE.BufferAttribute( new Float32Array(positions), 3  ));
-        this.geometry.setAttribute( 'customColor', new THREE.BufferAttribute( new Float32Array(colors), 3 ) );
-        this.geometry.setAttribute( 'customVisible', new THREE.BufferAttribute( new Float32Array(alives), 1 ) );
-        this.geometry.setAttribute( 'customOpacity', new THREE.BufferAttribute( new Float32Array(opacitys), 1 ) );
-        this.geometry.setAttribute( 'customSize', new THREE.BufferAttribute( new Float32Array(sizes), 1 ) );
-        this.geometry.setAttribute( 'customAngle', new THREE.BufferAttribute( new Float32Array(angles), 1 ) );
-    }
-    
-    createMaterial(){
-        this.material = new THREE.ShaderMaterial( 
-        {
-            uniforms: 
-            {
-                u_sampler:   { type: "t", value: getTexture() },
-                heightOfNearPlane: { type: "f", value:0}  //相对far ,以确保画面缩放时点的大小也会缩放
-            },
-            vertexShader:   vertexShader,vertexShader,
-            fragmentShader: fragmentShader,
-            transparent: true,
-            alphaTest: 0.5, // if having transparency issues, try including: alphaTest: 0.5, 
-            blending: this.blendStyle,
-            depthTest: this.blendStyle != THREE.NormalBlending
-        });
-        
-        
-        this.setPerspective(this.fov, this.screenHeight)
-        
-        
-    }
-    
-
-    update(dt){
-        if(!Potree.Utils.getObjVisiByReason(this,'force')){//被手动隐藏了
-            return
-        }
-        if(!Potree.Utils.isInsideFrustum(this.boundingBox, viewer.scene.getActiveCamera())){
-            Potree.Utils.updateVisible(this,'isInsideFrustum', false ) //不在视野范围
-            //console.log('unvi')
-            return
-        }else{
-            Potree.Utils.updateVisible(this,'isInsideFrustum', true )
-        } 
-        
-        
-        
-        if(dt > 1){
-            console.log('update dt>1', dt)
-        }
-         
-        //dt *= 0.5;
-        
-        const recycleIndices = [];
-        const recycleAges = []
-        
-        
-        const positions = [];
-        const colors = [];
-        const alives = [];
-        const opacitys = [];
-        const sizes = [];
-        const angles = [];
-    
-       
-        
-        
-        
-        
-        for (var i = 0; i < this.particleCount; i++)
-        {
-            if ( this.particleArray[i].alive )
-            {
-                  
-                if ( this.velocityStyle == 'cube' )
-                {        //一定几率改变下方向
-                    let ratio = Math.random()
-                    if(this.particleArray[i].age - this.particleArray[i].lastChangeVage > this.particleDeathAge*ratio  ){
-                        
-                        this.particleArray[i].velocity = this.randomVector3( this.velocityBase, this.velocitySpread ); 
-                        
-                        this.particleArray[i].lastChangeVage = this.particleArray[i].age
-                    }
-                }else{
-                    /* if(this.particleArray[i].age - this.particleArray[i].lastChangeVage > this.particleDeathAge*0.3  ){
-                        if( Math.random()>0.1){//一定几率改变下方向
-                            var speed  = this.randomValue( this.speedBase, this.speedSpread ); 
-                            this.particleArray[i].velocity = this.randomVector3( new THREE.Vector3,   new THREE.Vector3(1,1,1) ); 
-                            this.particleArray[i].velocity.normalize().multiplyScalar( speed );
-                        }
-                        this.particleArray[i].lastChangeVage = this.particleArray[i].age
-                    } */
-                    
-                    
-                }
-                 
-                
-                this.particleArray[i].update(dt);
-
-                // check if particle should expire
-                // could also use: death by size<0 or alpha<0.
-                if ( this.particleArray[i].age > this.particleDeathAge ) 
-                {
-                    this.particleArray[i].alive = 0.0;
-                    recycleIndices.push(i);
-                    recycleAges.push((this.particleArray[i].age - this.particleDeathAge)%(this.particleDeathAge ))
-                } 
-                
-                
-                // update particle properties in shader
-                positions[3*i] = this.particleArray[i].position.x
-                positions[3*i+1] = this.particleArray[i].position.y
-                positions[3*i+2] = this.particleArray[i].position.z
-
-                colors[3*i] = this.particleArray[i].color.r 
-                colors[3*i+1] = this.particleArray[i].color.g
-                colors[3*i+2] = this.particleArray[i].color.b
-
-                alives[i] = this.particleArray[i].alive
-                opacitys[i] = this.particleArray[i].opacity
-                sizes[i] = this.particleArray[i].size
-                angles[i] = this.particleArray[i].angle
-            }		
-        }
-
-        // check if particle emitter is still running
-        //if ( !this.emitterAlive ) return;
-
-        this.geometry.setAttribute( 'position', new THREE.BufferAttribute( new Float32Array(positions), 3 ) );
-        this.geometry.setAttribute( 'customColor', new THREE.BufferAttribute( new Float32Array(colors), 3 ) );
-        this.geometry.setAttribute( 'customVisible', new THREE.BufferAttribute( new Float32Array(alives), 1 ) );
-        this.geometry.setAttribute( 'customOpacity', new THREE.BufferAttribute( new Float32Array(opacitys), 1 ) );
-        this.geometry.setAttribute( 'customSize', new THREE.BufferAttribute( new Float32Array(sizes), 1 ) );
-        this.geometry.setAttribute( 'customAngle', new THREE.BufferAttribute( new Float32Array(angles), 1 ) );
-
-        this.geometry.attributes.customColor.needsUpdate = true;
-        this.geometry.attributes.customVisible.needsUpdate = true;
-        this.geometry.attributes.customOpacity.needsUpdate = true;
-        this.geometry.attributes.customSize.needsUpdate = true;
-        this.geometry.attributes.customAngle.needsUpdate = true;
-
-        // if no particles have died yet, then there are still particles to activate
-        if ( this.emitterAge < this.particleDeathAge ) //开始时一个个放出来
-        {
-            
-            let particlesPerSecond = this.particleCount / this.particleDeathAge
-            // determine indices of particles to activate
-            var startIndex = Math.round( particlesPerSecond * (this.emitterAge +  0) );
-            var endIndex = Math.round( particlesPerSecond * (this.emitterAge + dt) );
-            if  ( endIndex > this.particleCount ) 
-                endIndex = this.particleCount; 
-                
-            for (var i = startIndex; i < endIndex; i++)
-                this.particleArray[i].alive = 1.0;		
-        }
-
-        // if any particles have died while the emitter is still running, we imediately recycle them
-        for (var j = 0; j < recycleIndices.length; j++)
-        {
-            var i = recycleIndices[j]; 
-            this.particleArray[i] = this.createParticle(this.particleArray[i].center);
-            this.particleArray[i].alive = 1.0; // activate right away
-            this.particleArray[i].age = recycleAges[j]
-            positions[3*i] = this.particleArray[i].position.x
-            positions[3*i+1] = this.particleArray[i].position.y
-            positions[3*i+2] = this.particleArray[i].position.z
-        }
-        this.geometry.setAttribute( 'position', new THREE.BufferAttribute( new Float32Array(positions), 3 ) );
-        this.geometry.attributes.position.needsUpdate = true;
-
-        // stop emitter?
-        this.emitterAge += dt;
-        //if ( this.emitterAge > this.emitterDeathAge )  this.emitterAlive = false;
-    }
-
-    randomValue(base, spread)
-    {
-        //return base + spread * (Math.random() - 0.5);
-        let p = Math.random()
-        return base * p + spread * (1-p)
-        
-    }
-
-    randomVector3(base, spread)
-    {
-        var rand3 = new THREE.Vector3( Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5 );
-        return new THREE.Vector3().addVectors( base, new THREE.Vector3().multiplyVectors( spread, rand3 ) );
-    }
-    
-    
-    
-    
-    setSize(e){
-        let viewport = e.viewport
-        this.screenHeight = viewport.resolution.y
-        this.setPerspective(this.fov, this.screenHeight)  
-    }
-    
-    setFov(fov){
-        this.fov = fov
-        this.setPerspective(this.fov, this.screenHeight) 
-    }
-    
-    
-    setPerspective(fov, height){
-        //this.uniforms.heightOfNearPlane.value = Math.abs(height / (2 * Math.tan(THREE.Math.degToRad(fov * 0.5))));
-        let far = Math.abs(height / (2 * Math.tan(THREE.Math.degToRad(fov * 0.5))));
-        this.material.uniforms.heightOfNearPlane.value = far 
-    }
-    
-    dispose(){
-        this.geometry.dispose();
-        this.material.dispose();
-        this.dispatchEvent('dispose') 
-    }
-}
-
-
-/* 
-    改进:如果有必要
-    
-    根据curve中分成的点,分成多个簇,每个簇掌管该部分的可见性和particle的数量。
-    在camera_changed时根据远近修改每个簇的particle的数量,当然不会大于初始创建的个数。多出的随机隐藏。
-
-
- */

+ 0 - 44
src/custom/objects/fireParticle/smoke/shader.js

@@ -1,44 +0,0 @@
-export const vertexShader = `
-    attribute vec3  customColor;
-    attribute float customOpacity;
-    attribute float customSize;
-    attribute float customAngle;
-    attribute float customVisible;  
-    uniform float heightOfNearPlane;
-    
-    
-    varying vec4  vColor;
-    varying float vAngle;
-    void main()
-    {
-        if ( customVisible > 0.5 ) 				
-            vColor = vec4( customColor, customOpacity ); 
-        else							
-            vColor = vec4(0.0, 0.0, 0.0, 0.0);		
-            
-        vAngle = customAngle;
-
-        vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
-        //gl_PointSize = customSize * ( 300.0 / length( mvPosition.xyz ) );     
-        gl_Position = projectionMatrix * mvPosition;
-        gl_PointSize = ( heightOfNearPlane * customSize ) / gl_Position.w;
-        
-        
-    }
-` 
-
-export const fragmentShader = `
-    uniform sampler2D u_sampler;
-    varying vec4 vColor;	
-    varying float vAngle;  
-    void main()
-    {
-        gl_FragColor = vColor;
-        
-        float c = cos(vAngle);
-        float s = sin(vAngle);
-        vec2 rotatedUV = vec2(c * (gl_PointCoord.x - 0.5) + s * (gl_PointCoord.y - 0.5) + 0.5, c * (gl_PointCoord.y - 0.5) - s * (gl_PointCoord.x - 0.5) + 0.5);  
-        vec4 rotatedTexture = texture2D( u_sampler,  rotatedUV );
-        gl_FragColor = gl_FragColor * rotatedTexture;   
-    }
-`

+ 9 - 9
src/custom/potree.shim.js

@@ -49,14 +49,14 @@ var texLoader = new THREE.TextureLoader()
     Potree.browser = browser
 
     /////////// add ////////////////////////////////// 
-    Potree.defines.GLCubeFaces = {
+    /* Potree.defines.GLCubeFaces = {
         GL_TEXTURE_CUBE_MAP_POSITIVE_X: 0,
         GL_TEXTURE_CUBE_MAP_NEGATIVE_X: 1,
         GL_TEXTURE_CUBE_MAP_POSITIVE_Y: 2,
         GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: 3,
         GL_TEXTURE_CUBE_MAP_POSITIVE_Z: 4,
         GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: 5
-    };
+    }; 
 
 
     Potree.defines.PanoSizeClass = {
@@ -66,6 +66,13 @@ var texLoader = new THREE.TextureLoader()
         ULTRAHIGH: 4
     };
 
+    
+
+    Potree.defines.TileDownloaderEvents = {
+        TileDownloadSuccess: "tiledownloader.download.success",
+        TileDownloadFailure: "tiledownloader.download.failure",
+        PanoDownloadComplete: "tiledownloader.pano.download.complete"
+    };*/
     Potree.defines.PanoRendererEvents = {
         PanoRenderComplete: "panorama.render.complete",
         TileRenderFailure: "panorama.tile.render.failed",
@@ -81,13 +88,6 @@ var texLoader = new THREE.TextureLoader()
         MemoryUsageUpdated: "scene-renderer-memory-usage-updated"
     };
 
-
-    Potree.defines.TileDownloaderEvents = {
-        TileDownloadSuccess: "tiledownloader.download.success",
-        TileDownloadFailure: "tiledownloader.download.failure",
-        PanoDownloadComplete: "tiledownloader.pano.download.complete"
-    };
-
     Potree.defines.Vectors = {
         UP: new THREE.Vector3(0,1,0),
         DOWN: new THREE.Vector3(0,-1,0),

+ 30 - 679
src/custom/start.js

@@ -26,14 +26,11 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
     
     let viewer = new Potree.Viewer(dom , mapDom);
     
-    let Alignment = viewer.modules.Alignment
-    
     
   
 	viewer.setEDLEnabled(false);
     viewer.setFOV(Potree.config.view.fov); 
-    //viewer.loadSettingsFromURL(); 
-    
+     
     
      if(!Potree.settings.isOfficial){ 
         viewer.loadGUI(() => {
@@ -126,107 +123,38 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
             viewer.dispatchEvent('allLoaded')
         }
         
-        var transformPointcloud = (pointcloud, dataset)=>{
+        /* var transformPointcloud = (pointcloud, dataset)=>{
             var locationLonLat = dataset.location.slice(0,2)
             
-            /* if(window.AMapWith84){//需要转换
-                locationLonLat = AMapWith84.wgs84ToAMap({x:locationLonLat[0], y:locationLonLat[1]})
-                locationLonLat = [locationLonLat.x,locationLonLat.y] 
-            } */
-           
+            
             //当只有一个dataset时,无论如何transform 点云和漫游点都能对应上。
             var location = viewer.transform.lonlatToLocal.forward(locationLonLat)  //transform.inverse()
             //初始化位置 
             
             viewer.sidebar && viewer.sidebar.addAlignmentButton(pointcloud) 
-            
-            //dataset.orientation = 0
-            
-            Alignment.rotate(pointcloud, null, dataset.orientation)   
-            Alignment.translate(pointcloud, new THREE.Vector3(location[0], location[1], dataset.location[2])) 
-            
+             
             pointcloud.updateMatrixWorld()
             
             
             Potree.Log(`点云${pointcloud.dataset_id}(${pointcloud.name})旋转值:${pointcloud.orientationUser}, 位置${math.toPrecision(pointcloud.translateUser.toArray(),3)}, 经纬度 ${locationLonLat}, spacing ${pointcloud.material.spacing}`,  {font:[null, 13]} )
             
             
-            //-------------------
              
-            //viewer.mapView.showSources(false);  
-        }
+        } */
         
         if(!Potree.settings.originDatasetId)Potree.settings.originDatasetId = data[0].id
         var originDataset =  data.find(e=>e.id == Potree.settings.originDatasetId)  
         
-        {//拿初始数据集作为基准。它的位置是000
-            var locationLonLat = originDataset.location.slice(0,2)
-            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.AMapWith84 && Potree.settings.mapCompany != 'google'){//需要转换, 因本地高德用的lonlat和数据里的84不一样. (google地图在国内也用的高德,国外84)
-                let change = (transform)=>{
-                    let forward = transform.forward
-                    let inverse = transform.inverse;
-                    
-                    transform.forward = function(e){
-                         let needTran = e.x == void 0 
-                         if(needTran)var a1 = {x:e[0],y:e[1]}
-                         else var a1 = e
-                         var a = 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){
-                        let needTran = e.x == void 0
-                        var a = inverse(e)
-                        needTran && (a = {x:a[0],y:a[1]})
-                        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]) 
-                }   
-            }
-            
-            
-            
-            viewer.mapViewer && viewer.mapViewer.mapLayer.maps[0].updateProjection()
-            
-            
-            
-        }
+         
          
         
         data.forEach((dataset,index)=>{  
             if(!ifReload){
                 var datasetCode = dataset.sceneCode || dataset.name //对应4dkk的场景码
-                //var cloudPath = `${Potree.settings.urls.prefix1}/${Potree.settings.webSite}/${datasetCode}/data/${datasetCode}/webcloud/cloud.js` 
-                var cloudPath = `${Potree.settings.urls.prefix1}/${dataset.webBin}`  //webBin添加原因:每次裁剪之类的操作会换路径,因为oss文件缓存太严重,更新慢
+                var cloudPath = //`${Potree.settings.urls.prefix1}/${dataset.webBin}`  //webBin添加原因:每次裁剪之类的操作会换路径,因为oss文件缓存太严重,更新慢
+                `${Potree.settings.urls.prefix1}/webcloud/cloud.js` 
                 
+                 
                 var timeStamp = dataset.updateTime ? dataset.updateTime.replace(/[^0-9]/ig,'') : '';  //每重算一次后缀随updateTime更新一次 
                 //console.warn(dataset.name, 'timeStamp', timeStamp)
                 Potree.loadPointCloud(cloudPath, dataset.name ,datasetCode, timeStamp, e => {
@@ -247,7 +175,7 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
                     material.shape = Potree.PointShape.SQUARE; 
                     pointcloud.color = pointcloud.material.color = dataset.color  
                     pointcloud.timeStamp = timeStamp 
-                    transformPointcloud(pointcloud,dataset)
+                    //transformPointcloud(pointcloud,dataset)
                     scene.addPointCloud(pointcloud);
                     
                     if(!Potree.settings.isOfficial){ 
@@ -276,11 +204,11 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
                     Potree.Log('数据集id变了,自动使用第一个',   {font:['#500'  ]} )
                     pointcloud = viewer.scene.pointclouds[0]
                 }
-                //先归零 
+                /* //先归零 
                 Alignment.translate(pointcloud,  pointcloud.translateUser.clone().negate())
-                Alignment.rotate(pointcloud, null,  - pointcloud.orientationUser)
+                Alignment.rotate(pointcloud, null,  - pointcloud.orientationUser) */
                 
-                transformPointcloud(pointcloud, dataset)
+                //transformPointcloud(pointcloud, dataset)
                  
             } 
                 
@@ -300,35 +228,10 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
      
      
 
-    window.testTransform = function(locationLonLat, location1, location2){
-        proj4.defs("NAVVIS:test", "+proj=tmerc +ellps=WGS84 +lon_0=" + locationLonLat[0].toPrecision(15) + " +lat_0=" + locationLonLat[1].toPrecision(15));
-        
-        let transform = proj4("WGS84", "NAVVIS:test"); //这个ok  navvis里也是这两种转换 见proj4Factory
-        if(location1){//经纬度
-            return transform.forward(location1) 
-        }else{
-            return transform.inverse(location2) 
-        }            
-        
-    }       
+         
 
     window.THREE = THREE
-    window.buttonFunction = function(){
-        
-        
-         
-        viewer.scene.pointclouds.forEach(e=>e.predictNodeMaxLevel())
-               
-        
-        
-        /* 
-        viewer.startScreenshot({type:'measure', measurement:viewer.scene.measurements[0]}) 
-        
-        viewer.modules.RouteGuider.routeStart = new THREE.Vector3(0,0,-1.3)
-        viewer.modules.RouteGuider.routeEnd = new THREE.Vector3(-10,0,-1.3)
-       */
-        
-    }
+    
     
     
     if(Potree.settings.isLocalhost){
@@ -350,7 +253,7 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
     
     
     //--------------------------------
-    if(!number){
+    /* if(!number){
         Potree.settings.boundAddObjs = true
         Potree.settings.intersectOnObjs = true
         
@@ -366,7 +269,7 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
             }
         )  
   
-    }
+    } */
     
     
     
@@ -383,552 +286,23 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
  
  
  
- 
- 
- 
- 
- 
- 
-//=======================================================================
-/* 
-            漫游点编辑
- */
-//=======================================================================
-
-
-export function panoEditStart(dom, number, fileServer){
-    Potree.settings.editType = 'pano'
-    Potree.settings.number = number 
-    
-    Potree.settings.unableNavigate = true
-    Potree.settings.sizeFitToLevel = true//当type为衰减模式时自动根据level调节大小。每长一级,大小就除以2
+window.buttonFunction = function(){
      
-    
-    let viewer = new Potree.Viewer(dom); 
-    let Alignment = viewer.modules.Alignment
-	viewer.setEDLEnabled(false);
-    viewer.setFOV(Potree.config.view.fov); 
-    //viewer.loadSettingsFromURL(); 
-    let datasetLoaded = 0;
-  
-    if(!Potree.settings.isOfficial){ 
-        viewer.loadGUI(() => {
-            viewer.setLanguage('en'); 
-            $("#menu_tools").next().show();
-            $("#panos").show();
-            $("#alignment").show(); 
-            viewer.toggleSidebar();
-        }); 
-        Potree.settings.sizeFitToLevel = true 
-    }
-    
-    var pointcloudLoadDone = function( ){//所有点云cloud.js加载完毕后 
-         
-        
-        
-        viewer.scene.pointclouds.forEach(c=>{
-            transformPointcloud(c)
-        })
-        viewer.images360.loadDone() 
-        viewer.scene.add360Images(viewer.images360); 
-        
-        viewer.updateModelBound()
-        let {boundSize, center} = viewer.bound
-       
-        Potree.Log(`中心点: ${math.toPrecision(center.toArray(),2)}, boundSize: ${math.toPrecision(boundSize.toArray(),2)} ` , {font:[null, 12]} )
-          
-        viewer.scene.view.setView({ 
-            position: center.clone().add(new THREE.Vector3(10,5,10)), 
-            target: center
-        })
-         
-        viewer.dispatchEvent({type:'loadPointCloudDone'})
-    
-        if(!Potree.settings.UserPointDensity){
-            Potree.settings.UserPointDensity = 'panoEdit'//'middle' 
-        }
-         
-        Potree.Log('loadPointCloudDone  点云加载完毕',{font:[null, 10]})  
-        
-        viewer.dispatchEvent('allLoaded');
-    }
-    
-    
-    var transformPointcloud = (pointcloud )=>{ //初始化位置  
-        viewer.sidebar && viewer.sidebar.addAlignmentButton(pointcloud) 
-         
-        let orientation =  pointcloud.panos[0].dataRotation.z + Math.PI
-        
-        let location = pointcloud.panos[0].dataPosition.clone()//.negate()
-        
-        Alignment.rotate(pointcloud, null,  orientation  )   
-        Alignment.translate(pointcloud, location )  
-        
-        pointcloud.updateMatrixWorld()
-          
-    }   
-     
-     
-     
-         
-    
-    let loadPanosDone = Potree.loadPanosDone = (datasetId, panoData )=>{ //一个数据集获取到它的panos后
-        
-        Potree.settings.datasetsPanos[datasetId] = {panoData, panos:[]}
-         
-        console.log('panoData', datasetId, panoData)
-        
-        let panoCount = panoData.length
-        let pointcloudLoaded = 0
-        
-        let datasetsCount = Object.keys(Potree.settings.datasetsPanos).length
-       
-       
-        panoData.forEach((pano, index)=>{
-            //let cloudPath = `${Potree.scriptPath}/data/panoEdit/uuidcloud/${pano.uuid}/cloud.js` 
-            let cloudPath = `${Potree.settings.urls.prefix1}/${Potree.settings.webSite}/${Potree.settings.number}/data/bundle_${Potree.settings.number}/building/uuidcloud/${pano.uuid}/cloud.js`
-            
-            let name = datasetId + '-'+pano.uuid
-            let timeStamp = 0
-            pano.index = index //注意:index不等于uuid,因为有的uuid缺失。但是visibles中存的是下标! 
-            
-            Potree.loadPointCloud(cloudPath, name , name, timeStamp, e => { //开始加载点云
-                let scene = viewer.scene;
-                let pointcloud = e.pointcloud; 
-                let config = Potree.config.material
-                let material = pointcloud.material; 
-                material.minSize =  config.minSize
-                material.maxSize =  config.maxSize   
-                material.pointSizeType = /* 'ADAPTIVE'// */config.pointSizeType //Potree.PointSizeType[config.pointSizeType]//Potree.PointSizeType.ADAPTIVE;//FIXED
-                pointcloud.changePointSize( 0.1 /* config.realPointSize  */   )  //material.size =  config.pointSize;
-                pointcloud.changePointOpacity(1)
-                material.shape = Potree.PointShape.SQUARE; 
-                pointcloud.color = config.pointColor  
-                pointcloud.dataset_id = datasetId;   //多个点云指向一个datasetId
-                pointcloud.panoUuid = pano.uuid
-                pointcloud.timeStamp = timeStamp
-                  
-                //transformPointcloud(pointcloud, pano)
-                scene.addPointCloud(pointcloud);
-                pointcloudLoaded ++;
-                 
-                if(pointcloudLoaded == panoCount ){
-                    datasetLoaded ++
-                    viewer.images360.addPanoData(panoData ,  datasetId )
-                    if(datasetLoaded == datasetsCount){
-                        pointcloudLoadDone()
-                    }
-                    
-                }
-                
-            })
-            
-        })
-        
-    }
-    
-    if(!Potree.settings.isOfficial){ 
-        Potree.settings.datasetsPano = {'testDataset':null}
-        Potree.loadPanosInfo( data=>{loadPanosDone('testDataset',  data.sweepLocations)} )  
-    
-    }
-    
+    viewer.scene.pointclouds.forEach(e=>e.predictNodeMaxLevel()) 
 }
-
-
-
+ 
   
-
-export function mergeEditStart(dom){
-    Potree.settings.editType = 'merge' 
-    Potree.settings.intersectOnObjs = true
-    Potree.settings.boundAddObjs = true
-    Potree.settings.unableNavigate = true
-   
-    
+window.testTransform = function(locationLonLat, location1, location2){
+    proj4.defs("NAVVIS:test", "+proj=tmerc +ellps=WGS84 +lon_0=" + locationLonLat[0].toPrecision(15) + " +lat_0=" + locationLonLat[1].toPrecision(15));
     
-    let viewer = new Potree.Viewer(dom );
-   
-    let Alignment = viewer.modules.Alignment
-     
-	viewer.setEDLEnabled(false);
-    viewer.setFOV(Potree.config.view.fov); 
-    //viewer.loadSettingsFromURL(); 
-    { 
-        viewer.mainViewport.view.position.set(30,30,30) 
-        viewer.mainViewport.view.lookAt(0,0,0)
-        
-        viewer.updateModelBound()//init
-        //this.bound = new THREE.Box3(new THREE.Vector3(-1,-1,-1),new THREE.Vector3(1,1,1))
-        
-        viewer.transformationTool.setModeEnable(['translation','rotation'] )
-        viewer.ssaaRenderPass.sampleLevel = 1 //  sampleLevel为1 的话,ground就不会变黑
+    let transform = proj4("WGS84", "NAVVIS:test"); //这个ok  navvis里也是这两种转换 见proj4Factory
+    if(location1){//经纬度
+        return transform.forward(location1) 
+    }else{
+        return transform.inverse(location2) 
+    }            
         
-        viewer.inputHandler.fixSelection = true //不通过点击屏幕而切换transfrom选中状态
-  
-    }
-    
-    Potree.settings.sizeFitToLevel = true//当type为衰减模式时自动根据level调节大小。每长一级,大小就除以2
-    Potree.loadPointCloudScene = function(url, type, id, title, done, onError){//对应4dkk的场景码
-          
-        let loadCloud = ({cloudPath, sceneName, sceneCode, timeStamp, color } )=>{
-            
-            Potree.loadPointCloud(cloudPath, sceneName , sceneCode, timeStamp, e => {
-                 
-                let scene = viewer.scene;
-                let pointcloud = e.pointcloud; 
-                let config = Potree.config.material
-                let material = pointcloud.material; 
-                
-                material.minSize =  config.minSize
-                material.maxSize =  config.maxSize   
-                material.pointSizeType = config.pointSizeType //Potree.PointSizeType[config.pointSizeType]//Potree.PointSizeType.ADAPTIVE;//FIXED
-                pointcloud.changePointSize(config.realPointSize)  //material.size =  config.pointSize;
-                pointcloud.changePointOpacity(1)
-                material.shape = Potree.PointShape.SQUARE; 
-                color && (pointcloud.color = pointcloud.material.color = color)     
-                pointcloud.timeStamp = timeStamp 
-                //transformPointcloud(pointcloud, originDataset)
-                scene.addPointCloud(pointcloud);
-                 
-                
-                {
-                    
-                    viewer.updateModelBound()
-                    let {boundSize, center} = viewer.bound
-                    viewer.dispatchEvent({type:'loadPointCloudDone'})
-                    if(!Potree.settings.UserPointDensity){
-                        Potree.settings.UserPointDensity = 'high'//'middle' 
-                    }
-                     
-                    Potree.Log('loadPointCloudDone  点云加载完毕',  {font:[null,10] })    
-                } 
-                    
-                /* Potree.loadPanos(dataset.id, (data) => { //暂时不加载panos了,因为没有id 
-                //console.log('loadPanos',dataset.sceneCode, dataset.id, data)
-                viewer.images360.addPanoData(data, dataset.id ) 
-                viewer.images360.loadDone() 
-                viewer.scene.add360Images(viewer.images360);    */   
-                viewer.dispatchEvent('allLoaded')
-                done(pointcloud)
-            },onError) 
-            
-            
-        }
-        
-        if(type == 'laser'){ 
-            let sceneCode = url
-            Potree.loadDatasets((data)=>{ 
-                let originDataset = data.find(e=>e.sceneCode == sceneCode);//只加载初始数据集  
-                let timeStamp = originDataset.updateTime ? originDataset.updateTime.replace(/[^0-9]/ig,'') : '';  //每重算一次后缀随updateTime更新一次 
-                //let cloudPath = `${Potree.settings.urls.prefix1}/${Potree.settings.webSite}/${sceneCode}/data/${sceneCode}/webcloud/cloud.js` 
-                let cloudPath = `${Potree.settings.urls.prefix1}/${originDataset.webBin}`  //webBin添加原因:每次裁剪之类的操作会换路径,因为oss文件缓存太严重,更新慢
-                
-                loadCloud({cloudPath, sceneName:originDataset.sceneName, sceneCode, timeStamp, color:originDataset.color})
-            }, sceneCode, onError)
-        
-        }else{//las or ply  直接用url
-            let name = type + '|' + id + '|' + title
-             
-            if(url instanceof Array){
-                if(url.length == 1){
-                    url = url[0]
-                }else{
-                    console.error('有多个点云?暂时还不支持', url, name)//多个点云要一起移动没想好怎么写
-                }      
-            }
-            
-            let cloudPath = url + '/cloud.js' 
-            loadCloud({cloudPath, sceneName:name, sceneCode:name, timeStamp:'' })
-        }   
-         
-    } 
-    
-    
-    
-    
-    
-    
-    
-    let setMatrix = (pointcloud)=>{//为了漫游点变换,要算一下 类似setMatrix
-                  
-        /* pointcloud.transformMatrix = new THREE.Matrix4().multiplyMatrices(pointcloud.matrix, pointcloud.pos1MatrixInvert)//还原一点位移
-        pointcloud.transformInvMatrix.copy(pointcloud.transformMatrix).invert()
-        
-        pointcloud.rotateMatrix = new THREE.Matrix4().makeRotationFromEuler(pointcloud.rotation);
-        pointcloud.rotateInvMatrix.copy(pointcloud.rotateMatrix).invert()
-        pointcloud.panos.forEach(e=>e.transformByPointcloud()) */
-        //pointcloud.updateBound()
-        //pointcloud.getPanosBound()  
-        viewer.updateModelBound()
-    } 
-
-    let moveModel = (e)=>{//根据鼠标移动的位置改变位置
-          
-        let camera = viewer.mainViewport.camera
-        var origin = new THREE.Vector3(e.pointer.x, e.pointer.y, -1).unproject(camera),
-        end = new THREE.Vector3(e.pointer.x, e.pointer.y, 1).unproject(camera)
-        var dir = end.sub(origin)
-        let planeZ = 0;
-        let r = (planeZ - origin.z)/dir.z
-        let x = r * dir.x + origin.x
-        let y = r * dir.y + origin.y
-        
-        //过后改为根据intersect的点来设置底部高度;这样的话,需要发送高度
-        
-        /*let pos = new THREE.Vector3(x,y,  planeZ  )
-         modelEditing.updateMatrixWorld()   
-        let boundCenter = modelEditing.boundingBox.getCenter(new THREE.Vector3).applyMatrix4(modelEditing.matrixWorld);
-         */
-        MergeEditor.moveBoundCenterTo(modelEditing,new THREE.Vector3(x,y, modelEditing.boundCenter.z))  //使模型中心的xy在鼠标所在位置
-         
-        modelEditing.dispatchEvent("position_changed") 
-         
-    }
-    let cancelMove = ()=>{ 
-        modelEditing = null
-        viewer.removeEventListener('global_mousemove', moveModel); 
-        viewer.removeEventListener('global_click', confirmPos); 
-    }
-    let confirmPos = ()=>{ 
-        MergeEditor.focusOn(modelEditing)
-        cancelMove()  
-        return {stopContinue:true}
-    }
-    
-     
-    
-    let modelType,  modelEditing, MergeEditor = viewer.modules.MergeEditor
-    Potree.addModel = function(prop, done, onProgress, onError){ //加载模型
-         
-    
-        let loadDone = (model)=>{ 
-            model.dataset_id = prop.id //唯一标识
-             
-            if(prop.position){
-                model.position.copy(prop.position)
-            }
-            if(prop.rotation){
-                //model.rotation.setFromVector3(prop.rotation) 
-                model.rotation.copy(prop.rotation) 
-            }
-            if(prop.scale){
-                model.scale.set(prop.scale,prop.scale,prop.scale)
-            }
-              
-            if(model.isPointcloud){
-                model.renderOrder = Potree.config.renderOrders.model;  //same as glb
-            }
-            
-            if(Potree.settings.maintainBtmZ) 
-            {//transform --------维持离地高度和中心点的版本(local ver)
-                let updateBound = ()=>{ 
-                    model.updateMatrixWorld()
-                    viewer.updateModelBound() 
-                }  
-                let maintainBtmZAndCenter = ()=>{ 
-                    MergeEditor.maintainBoundXY(model)
-                    MergeEditor.setModelBtmHeight(model) 
-                    updateBound()
-                    model.dispatchEvent('transformChanged')  
-                }
-                model.addEventListener('position_changed', ()=>{
-                    updateBound()
-                    MergeEditor.getBoundCenter(model);//更新boundcenter
-                    MergeEditor.computeBtmHeight(model)
-                    if(prop.bottomRange && (model.btmHeight > prop.bottomRange.max || model.btmHeight < prop.bottomRange.min)){
-                        model.btmHeight = THREE.Math.clamp(model.btmHeight, prop.bottomRange.min, prop.bottomRange.max)
-                        MergeEditor.setModelBtmHeight(model)
-                        updateBound()
-                    }  
-                    model.dispatchEvent('transformChanged') 
-                })
-                model.addEventListener("rotation_changed", maintainBtmZAndCenter )
-                model.addEventListener("scale_changed", maintainBtmZAndCenter )
-                model.addEventListener('transformChanged', ()=>{
-                    MergeEditor.modelTransformCallback(model)
-                })
-                //离地高度只是boundingbox在transform后的最低点的高度,而非模型transform后的最低点的高度,所以旋转过后看起来不太准确
-            } else
-            
-            {//transform --------维持中心点的版本
-                let updateBound = ()=>{ 
-                    model.updateMatrixWorld()
-                    viewer.updateModelBound() 
-                }  
-                let maintainCenter = ()=>{ 
-                    //MergeEditor.maintainBoundXY(model) 
-                    MergeEditor.maintainBoundCenter(model) 
-                    updateBound()
-                    model.dispatchEvent('transformChanged')  
-                }
-                model.addEventListener('position_changed', ()=>{
-                    updateBound()
-                    MergeEditor.getBoundCenter(model);//更新boundcenter
-            
-                    model.dispatchEvent('transformChanged') 
-                })
-                model.addEventListener("rotation_changed", maintainCenter )
-                model.addEventListener("scale_changed", maintainCenter )
-                model.addEventListener('transformChanged', ()=>{
-                    MergeEditor.modelTransformCallback(model)
-                })
-            
-            } 
-            
-            model.updateMatrixWorld()
-            viewer.updateModelBound()
-            
-            MergeEditor.getBoundCenter(model) //初始化
-            model.lastMatrixWorld = model.matrixWorld.clone()
-            
-            done(model) // 先发送成功,因为2d界面会随机执行changePosition等初始化,然后这边再将模型移到中心地面上
-            
-            
-            if(prop.isFirstLoad){
-                
-                MergeEditor.moveBoundCenterTo(model, new THREE.Vector3(0,0,0))  
-                MergeEditor.setModelBtmHeight(model, 0) //初始加载设置离地高度为0
-                
-                if(prop.mode != 'single'){//如果不是模型展示页,模型会随着鼠标位置移动
-                    viewer.addEventListener('global_mousemove', moveModel); 
-                    viewer.addEventListener('global_click', confirmPos, {importance:3});
-                    modelEditing = model;
-                }
-                model.dispatchEvent("position_changed") 
-            }else{
-                //MergeEditor.setModelBtmHeight(model, prop.bottom || 0) //默认离地高度为0
-                modelEditing = null
-            }
-            
-            
-            model.isPointcloud || MergeEditor.updatePointQuality()
-            
-        }
-        
-         
-        
-        
-        if(prop.type == 'glb'){ 
-        
-            let callback = (object)=>{
-                //focusOnSelect(object, 1000)  
-                object.isModel = true
-                //object.dataset_id = Date.now() //暂时
-                
-                object.traverse(e=>e.material && (e.material.transparent = true))
-              
-                /* object.addEventListener('click',(e)=>{
-                    //只是为了能得到hoverElement识别才加这个侦听
-                }) */
-                 
-                loadDone(object)
-            }
-            
-             
-            let info = { 
-                fileType: prop.type, 
-                id: prop.id,
-                unlit:true,
-                url : prop.url,
-                name : prop.title,
-                /* transform : { 
-                    position : prop.position,
-                    rotation : new THREE.Euler().setFromVector3(prop.rotation), 
-                    scale: new THREE.Vector3(prop.scale,prop.scale,prop.scale),        
-                }  */               
-            }    
-              
-            viewer.loadModel(info , callback, onProgress, onError)
-            
-            
-            
-        }else if(prop.type == 'obsg' || prop.type == 'b3dm'){  //3d tiles  
-        
-            let callback = (object)=>{
-                 
-                object.isModel = true 
-                //透明度怎么办
-                //object.traverse(e=>e.material && (e.material.transparent = true))
-                
-                loadDone(object)
-            }
-        
-            viewer.loadModel({ 
-                fileType: '3dTiles', 
-                id: prop.id,
-                name : prop.title,
-                /* tilesUrl: 'https://4dkk.4dage.com/scene_view_data/SS-Ds19qsmuFA/images/3dtiles/tileset.json',
-                transform : { 
-                    rotation : [Math.PI/2,  0,   0],
-                    position : [0,0,0]  
-                }  
-
-                  tilesUrl: 'https://testgis.4dage.com/LVBADUI_qp/tileset.json',
-                transform : { 
-                    rotation : [0,  0,   0],
-                    position : [0,0,0]  
-                }  */
-                
-                url:prop.url,
-                
-            },callback,onprogress)
-        
-            
-        }else{  
-            
-             //else if(prop.type == 'las' || prop.type == 'ply')
- 
-            Potree.loadPointCloudScene(prop.url, prop.type, prop.modelId, prop.title, (pointcloud)=>{  
-                pointcloud.matrixAutoUpdate = true
-                pointcloud.initialPosition = pointcloud.position.clone()
-                
-                pointcloud.pos1MatrixInvert = new THREE.Matrix4().setPosition(pointcloud.initialPosition).invert()
-                
-                /* let maintainBtmZ = ()=>{
-                    MergeEditor.setModelBtmHeight(pointcloud)
-                    updateMatrix()
-                }
-                let updateMatrix = ()=>{ 
-                    setMatrix(pointcloud) 
-                    pointcloud.dispatchEvent('transformChanged')
-                }
-                pointcloud.addEventListener('position_changed', updateMatrix )  
-                pointcloud.addEventListener("orientation_changed", maintainBtmZ )
-                pointcloud.addEventListener("scale_changed", maintainBtmZ ) */
-                
-                loadDone(pointcloud)
-                /* pointcloud.addEventListener('select',(e)=>{
-                    if(Potree.settings.displayMode == 'showPanos')return
-                    console.log('select',e) 
-                    //viewer.setControls(viewer.orbitControls) 
-                    MergeEditor.focusOnSelect(pointcloud) 
-                    
-                    viewer.outlinePass.selectedObjects = [pointcloud]
-                    return {stopContinue:true}
-                },{importance:1})
-                pointcloud.addEventListener('deselect',(e)=>{
-                    console.log('deselect',e) 
-                    //viewer.setControls(viewer.fpControls)  
-                    viewer.outlinePass.selectedObjects = []
-                }) */
-                
-            }, onError)
-        
-             
-            
-            
-        }
-    }
-    return {THREE}
-}
- 
- 
- 
- 
- 
- 
- 
+}  
  
 var changeLog = ()=>{  
          
@@ -978,27 +352,4 @@ var changeLog = ()=>{
  
  
  
-
-   /* 
-
-
-坐标转换问题:
-
-由于控制点可以随便输入,所以本地和地理位置的转换也是可拉伸的。而navvis的转换是等比由中心展开,
-所以对比两种转化方式时误差较大。
-
-另外地理注册控制点是有参考数据集的,若参考数据集和我放置在0,0,0的数据集一致,就可直接使用,否则要转换。
-
-
-
----------
-
-lonlat和空间坐标其实并非线性关系,因为lonlat其实是角度。当两个数据集在地球两端时,它们之间的夹角都相差180度了。
-所以若要准确展示的话,需要将点云内所有物体,如漫游点,都先获取lonlat再去算local。或者直接将点云整体的transformMatrix考虑上在地球上相对于初始数据集的偏转。
-
-
-   */
-   
-   
-   
-   
+ 

+ 14 - 121
src/custom/viewer/ViewerNew.js

@@ -36,16 +36,9 @@ import {Utils} from "../../utils.js";
 import {BoxVolume} from "../../utils/VolumeNew.js";
 import {VolumeTool} from "../../utils/VolumeTool.js";
 import {Images360} from "../modules/panos/Images360.js";
-import {Clip} from '../modules/clipModel/Clip.js'
-import {Alignment} from "../modules/datasetAlignment/Alignment.js";
-import {SiteModel} from "../modules/siteModel/SiteModel.js";
-import MergeEditor from "../modules/mergeModel/MergeEditor.js";
-import {RouteGuider}  from '../modules/route/RouteGuider.js'
+import {Clip} from '../modules/clipModel/Clip.js' 
 import {Clipping}  from '../modules/clipping/Clipping.js'
-
-import ParticleEditor from '../modules/Particles/ParticleEditor.js'
-import CamAniEditor from '../modules/CameraAnimation/CamAniEditor.js'  
-import PanoEditor  from '../modules/panoEdit/panoEditor.js' 
+  
 
 import {InputHandler} from "../../navigation/InputHandlerNew.js";
 
@@ -94,34 +87,15 @@ export class Viewer extends ViewerBase{
         
         window.viewer = this
         mapArea = mapArea_                 
-        
-        
          
-        if(Potree.settings.editType == "pano" || Potree.settings.editType == "merge"){
-            this.modules = { 
-                Alignment,  
-                SiteModel
-            }
-            Potree.settings.useDepthTex = false
-            
-            if(Potree.settings.editType == "pano" ){
-                this.modules.PanoEditor = PanoEditor
-            }else if(Potree.settings.editType == "merge"){
-                this.modules.MergeEditor = MergeEditor 
-                this.modules.CamAniEditor = CamAniEditor
-            }
+        this.modules = { 
             
-        }else{
-            this.modules = { 
-                Clip,
-                Alignment,
-                SiteModel,
-                RouteGuider : new RouteGuider,
-                clipping: new Clipping,
-                ParticleEditor,
-                CamAniEditor, 
-            }
         }
+        Potree.settings.useDepthTex = false
+        
+       
+            
+        
         {
             Potree.timeCollect = {
                 depthSampler : {minCount:400, median: 25}, //median预置一个中等值,以防止cpu过低的设备首次卡顿  
@@ -433,10 +407,7 @@ export class Viewer extends ViewerBase{
                 this.scene.scene.add(this.magnifier) 
                 this.scene.scene.add(this.reticule)
                 
-                
-                if(Potree.settings.editType != "pano" && Potree.settings.editType != 'merge'){
-                    this.mapViewer = new MapViewer(mapArea/* $('#mapGaode')[0] */)
-                }
+                 
                 
                 this.inputHandler = new InputHandler(this, this.scene.scene);
                 //this.inputHandler.setScene(this.scene);
@@ -524,16 +495,7 @@ export class Viewer extends ViewerBase{
             
             //-----------
             CursorDeal.init(this, this.mapViewer ? [this, this.mapViewer] : [this])//ADD
-            if(Potree.settings.editType == "pano"){
-                this.modules.PanoEditor.init()
-            }else if(Potree.settings.editType == "merge"){
-                this.modules.MergeEditor.init()
-            }else{
-                this.modules.SiteModel.init()
-                this.modules.ParticleEditor.init()
-            }                
-            this.modules.Alignment.init()
-            
+           
             
             
             this.images360 = new Images360(this);
@@ -546,13 +508,7 @@ export class Viewer extends ViewerBase{
                 glbLoader : new GLTFLoader(undefined, this.renderer, Potree.settings.libsUrl ),
                 plyLoader : new PLYLoader( manager ),
             } 
-            //add test
-            /* const environment = new RoomEnvironment();
-            const pmremGenerator = new THREE.PMREMGenerator( this.renderer ); 
-            this.scene.scene.environment = pmremGenerator.fromScene( environment ).texture;
-            */
-            
-            //-----------
+             
             
             
 		}catch(e){
@@ -680,40 +636,6 @@ export class Viewer extends ViewerBase{
         
         
         
-        if(Potree.settings.editType != 'pano' && Potree.settings.editType != 'merge'){
-              
-            this.addEventListener('switchFloorplanSelect',(e)=>{//进入平面图设置后 切换选中的数据集
-                this.selectedFloorplan = e.pointcloud;  //绝对显示
-                this.updateFpVisiDatasets()
-                let pointclouds;
-                if(e.pointcloud){
-                    pointclouds = [e.pointcloud]
-                }else if(this.fpVisiDatasets.length){
-                    pointclouds = this.fpVisiDatasets
-                }
-                
-                pointclouds && this.mapViewer.fitToDatasets(pointclouds) 
-                
-            })
-            
-            
-            
-            
-
-            this.modules.SiteModel.bus.addEventListener('FloorChange',(e)=>{
-                 this.updateFpVisiDatasets()
-                 this.updatePanosVisibles(e.currentFloor)       //问:编辑空间模型时,需不需要改为显示当前选择的楼层。因为若所在楼层和选中的不一致,修改选中楼层的轮廓却改不了marker显示很奇怪,尤其刚好在一个建筑内时。
-            }) 
-            this.mapViewer.mapLayer.addEventListener('floorplanLoaded',()=>{
-                 this.updateCadVisibles(this.fpVisiDatasets, true)   //加载完成后重新更新下
-            })
-                
-            /* this.modules.Clip.bus.addEventListener('updateSelectedDatasets',()=>{
-                 this.updateFpVisiDatasets()
-            }) */
-                
-            
-        }
         
         
         {  
@@ -1069,35 +991,7 @@ export class Viewer extends ViewerBase{
     
     
     
-    updateFpVisiDatasets(){
-          
-        let Clip = this.modules.Clip
-        let SiteModel = this.modules.SiteModel
-        let Alignment = this.modules.Alignment
-        var currentFloor = SiteModel.currentFloor;
-        
-        /* if(Clip.editing){//下载页面已经改为和普通时一样,根据位置判断
-            
-            this.updateCadVisibles(Clip.selectedDatasets)
-              
-        }else  */if(this.selectedFloorplan){//平面图设置中
-            let pointclouds = [this.selectedFloorplan]
-            this.updateCadVisibles(pointclouds)
-        }else if(SiteModel.editing || Alignment.editing){//只显示勾选的,也就是显示的点云的
-            let pointclouds = this.scene.pointclouds.filter(p => Potree.Utils.getObjVisiByReason(p,'datasetSelection')  ); 
-            this.updateCadVisibles(pointclouds)
-            //this.updatePanosVisibles(currentFloor/* , pointclouds */)
-        }else{ 
-            let pointclouds = currentFloor ? this.findPointcloudsAtFloor(currentFloor) : []
-            
-            if(pointclouds.length == 0){//如果当前不在任何楼层或楼层中无数据集,就用当前所在数据集
-                pointclouds = this.atDatasets
-            }
-             
-            this.updateCadVisibles(pointclouds)
-            //this.updatePanosVisibles(currentFloor/* , pointclouds */)
-        }
-    }
+     
     
  
     findPointcloudsAtFloor(entity){//找当前楼层需要显示哪些数据集。
@@ -4198,9 +4092,8 @@ export class Viewer extends ViewerBase{
         
         
         //-------------
-        this.images360.tileDownloader.update() 
-        this.images360.panoRenderer.update()
-        this.images360.getNeighbours()
+        this.images360.update() 
+        
         this.computeShelter()
         //-------------
 		if(this.stats){

+ 0 - 1
src/viewer/PropertyPanels/PropertiesPanel.js

@@ -6,7 +6,6 @@ import {Annotation} from "../../Annotation.js";
 import {Measure} from "../../utils/Measure.js";
 import {Profile} from "../../utils/Profile.js";
 import {Volume, BoxVolume, SphereVolume} from "../../utils/Volume.js";
-import {CameraAnimation} from "../../custom/modules/CameraAnimation/CameraAnimation.js"//"../../modules/CameraAnimation/CameraAnimation.js";
 import {PointSizeType, PointShape, ElevationGradientRepeat} from "../../defines.js";
 import {Gradients} from "../../materials/Gradients.js";
 

+ 0 - 1
src/viewer/sidebarNew.js

@@ -12,7 +12,6 @@ import {Annotation} from "../Annotation.js"
 import {CameraMode, ClipTask, ClipMethod} from "../defines.js"
 import {ScreenBoxSelectTool} from "../utils/ScreenBoxSelectTool.js"
 import {Utils} from "../utils.js"
-import {CameraAnimation} from "../custom/modules/CameraAnimation/CameraAnimation.js"
 import {HierarchicalSlider} from "./HierarchicalSlider.js"
 import {OrientedImage} from "../modules/OrientedImages/OrientedImages.js";
 import {Images360} from "../custom/modules/panos/Images360.js";