|
@@ -51,28 +51,30 @@ import cameraLight from "../utils/cameraLight.js";
|
|
|
import math from "../utils/math.js";
|
|
|
|
|
|
import {UoMService} from '../utils/UnitConvert'
|
|
|
-
|
|
|
-
|
|
|
+import {RouteGuider} from '../navigation/RouteGuider'
|
|
|
+
|
|
|
+let mapArea;
|
|
|
|
|
|
export class Viewer extends ViewerBase{
|
|
|
|
|
|
- constructor(domElement, args = {}){
|
|
|
+ constructor(domElement, mapArea_, args = {}){
|
|
|
super(domElement,args);
|
|
|
window.viewer = this
|
|
|
this.modules = { //add
|
|
|
Clip : Clip,
|
|
|
- Alignment : Alignment
|
|
|
-
|
|
|
+ Alignment : Alignment,
|
|
|
+ RouteGuider : new RouteGuider
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//add --------
|
|
|
+
|
|
|
this.navigateMode = 'free' // 'panorama'; 'free'自由模式是只显示点云或者未进入到漫游点,
|
|
|
this.isEdit = true
|
|
|
CursorDeal.attachToViewer(this)//ADD
|
|
|
this.unitConvert = new UoMService();
|
|
|
-
|
|
|
+ mapArea = mapArea_
|
|
|
//-------------
|
|
|
|
|
|
|
|
@@ -89,82 +91,58 @@ export class Viewer extends ViewerBase{
|
|
|
</div>`);
|
|
|
$(domElement).append(this.elMessages);
|
|
|
|
|
|
- try{
|
|
|
-
|
|
|
- { // generate missing dom hierarchy
|
|
|
- if ($(domElement).find('#potree_map').length === 0) {
|
|
|
- let potreeMap = $(`
|
|
|
- <div id="potree_map" class="mapBox" style="position: absolute; left: 50px; top: 50px; width: 400px; height: 400px; display: none">
|
|
|
- <div id="potree_map_header" style="position: absolute; width: 100%; height: 25px; top: 0px; background-color: rgba(0,0,0,0.5); z-index: 1000; border-top-left-radius: 3px; border-top-right-radius: 3px;">
|
|
|
- </div>
|
|
|
- <div id="potree_map_content" class="map" style="position: absolute; z-index: 100; top: 25px; width: 100%; height: calc(100% - 25px); border: 2px solid rgba(0,0,0,0.5); box-sizing: border-box;"></div>
|
|
|
- </div>
|
|
|
- `);
|
|
|
- $(domElement).append(potreeMap);
|
|
|
- }
|
|
|
-
|
|
|
- if ($(domElement).find('#potree_description').length === 0) {
|
|
|
- let potreeDescription = $(`<div id="potree_description" class="potree_info_text"></div>`);
|
|
|
- $(domElement).append(potreeDescription);
|
|
|
- }
|
|
|
-
|
|
|
- if ($(domElement).find('#potree_annotations').length === 0) {
|
|
|
- let potreeAnnotationContainer = $(`
|
|
|
- <div id="potree_annotation_container"
|
|
|
- style="position: absolute; z-index: 100000; width: 100%; height: 100%; pointer-events: none;"></div>`);
|
|
|
- $(domElement).append(potreeAnnotationContainer);
|
|
|
- }
|
|
|
-
|
|
|
- if ($(domElement).find('#potree_quick_buttons').length === 0) {
|
|
|
- let potreeMap = $(`
|
|
|
- <div id="potree_quick_buttons" class="quick_buttons_container" style="">
|
|
|
- </div>
|
|
|
- `);
|
|
|
-
|
|
|
- // {
|
|
|
- // let imgMenuToggle = document.createElement('img');
|
|
|
- // imgMenuToggle.src = new URL(Potree.resourcePath + '/icons/menu_button.svg').href;
|
|
|
- // imgMenuToggle.onclick = this.toggleSidebar;
|
|
|
- // // imgMenuToggle.classList.add('potree_menu_toggle');
|
|
|
-
|
|
|
- // potreeMap.append(imgMenuToggle);
|
|
|
- // }
|
|
|
-
|
|
|
- // {
|
|
|
- // let imgMenuToggle = document.createElement('img');
|
|
|
- // imgMenuToggle.src = new URL(Potree.resourcePath + '/icons/menu_button.svg').href;
|
|
|
- // imgMenuToggle.onclick = this.toggleSidebar;
|
|
|
- // // imgMenuToggle.classList.add('potree_menu_toggle');
|
|
|
-
|
|
|
- // potreeMap.append(imgMenuToggle);
|
|
|
- // }
|
|
|
-
|
|
|
- // {
|
|
|
- // let imgMenuToggle = document.createElement('img');
|
|
|
- // imgMenuToggle.src = new URL(Potree.resourcePath + '/icons/menu_button.svg').href;
|
|
|
- // imgMenuToggle.onclick = this.toggleSidebar;
|
|
|
- // // imgMenuToggle.classList.add('potree_menu_toggle');
|
|
|
+
|
|
|
+
|
|
|
+ try{
|
|
|
+
|
|
|
+ if(!Potree.settings.isOfficial)
|
|
|
+ { // generate missing dom hierarchy
|
|
|
+ if ($(domElement).find('#potree_map').length === 0) {
|
|
|
+ let potreeMap = $(`
|
|
|
+ <div id="potree_map" class="mapBox" style="position: absolute; left: 50px; top: 50px; width: 400px; height: 400px; display: none">
|
|
|
+ <div id="potree_map_header" style="position: absolute; width: 100%; height: 25px; top: 0px; background-color: rgba(0,0,0,0.5); z-index: 1000; border-top-left-radius: 3px; border-top-right-radius: 3px;">
|
|
|
+ </div>
|
|
|
+ <div id="potree_map_content" class="map" style="position: absolute; z-index: 100; top: 25px; width: 100%; height: calc(100% - 25px); border: 2px solid rgba(0,0,0,0.5); box-sizing: border-box;"></div>
|
|
|
+ </div>
|
|
|
+ `);
|
|
|
+ $(domElement).append(potreeMap);
|
|
|
+ }
|
|
|
|
|
|
- // potreeMap.append(imgMenuToggle);
|
|
|
- // }
|
|
|
+ if ($(domElement).find('#potree_description').length === 0) {
|
|
|
+ let potreeDescription = $(`<div id="potree_description" class="potree_info_text"></div>`);
|
|
|
+ $(domElement).append(potreeDescription);
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ if ($(domElement).find('#potree_annotations').length === 0) {
|
|
|
+ let potreeAnnotationContainer = $(`
|
|
|
+ <div id="potree_annotation_container"
|
|
|
+ style="position: absolute; z-index: 100000; width: 100%; height: 100%; pointer-events: none;"></div>`);
|
|
|
+ $(domElement).append(potreeAnnotationContainer);
|
|
|
+ }
|
|
|
|
|
|
- $(domElement).append(potreeMap);
|
|
|
- }
|
|
|
-
|
|
|
- //add
|
|
|
- {
|
|
|
- $(domElement).append($("<div id='potree_labels'></div>"))
|
|
|
-
|
|
|
- let mapArea = $("<div id='mapGaode'></div>")
|
|
|
- $(domElement).append(mapArea)
|
|
|
-
|
|
|
-
|
|
|
+ if ($(domElement).find('#potree_quick_buttons').length === 0) {
|
|
|
+ let potreeMap = $(`
|
|
|
+ <div id="potree_quick_buttons" class="quick_buttons_container" style="">
|
|
|
+ </div>
|
|
|
+ `);
|
|
|
+
|
|
|
+ $(domElement).append(potreeMap);
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ //add
|
|
|
+ {
|
|
|
+
|
|
|
+ if(!mapArea){
|
|
|
+ $(domElement).append($("<div id='potree_labels'></div>"))
|
|
|
+
|
|
|
+ mapArea = $("<div id='mapGaode'></div>")
|
|
|
+ $(domElement).append(mapArea)
|
|
|
+ mapArea = mapArea[0]
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- if(!Potree.settings.isOfficial){
|
|
|
let domRoot = this.renderer.domElement.parentElement;
|
|
|
let elAttach = $("<input type='button' value='test'></input>");
|
|
|
elAttach.css({
|
|
@@ -181,245 +159,246 @@ export class Viewer extends ViewerBase{
|
|
|
});
|
|
|
domRoot.appendChild(elAttach[0]);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.pointCloudLoadedCallback = args.onPointCloudLoaded || function () {};
|
|
|
|
|
|
- // if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
|
|
- // defaultSettings.navigation = "Orbit";
|
|
|
- // }
|
|
|
+
|
|
|
+ this.pointCloudLoadedCallback = args.onPointCloudLoaded || function () {};
|
|
|
|
|
|
- this.server = null;
|
|
|
+ // if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
|
|
|
+ // defaultSettings.navigation = "Orbit";
|
|
|
+ // }
|
|
|
|
|
|
- this.fov = 60;
|
|
|
- this.isFlipYZ = false;
|
|
|
- this.useDEMCollisions = false;
|
|
|
- this.generateDEM = false;
|
|
|
- this.minNodeSize = 30;
|
|
|
- this.edlStrength = 1.0;
|
|
|
- this.edlRadius = 1.4;
|
|
|
- this.edlOpacity = 1.0;
|
|
|
- this.useEDL = false;
|
|
|
- this.description = "";
|
|
|
+ this.server = null;
|
|
|
|
|
|
- this.classifications = ClassificationScheme.DEFAULT;
|
|
|
+ this.fov = 60;
|
|
|
+ this.isFlipYZ = false;
|
|
|
+ this.useDEMCollisions = false;
|
|
|
+ this.generateDEM = false;
|
|
|
+ this.minNodeSize = 30;
|
|
|
+ this.edlStrength = 1.0;
|
|
|
+ this.edlRadius = 1.4;
|
|
|
+ this.edlOpacity = 1.0;
|
|
|
+ this.useEDL = false;
|
|
|
+ this.description = "";
|
|
|
|
|
|
- this.moveSpeed = 10;
|
|
|
+ this.classifications = ClassificationScheme.DEFAULT;
|
|
|
|
|
|
- this.lengthUnit = LengthUnits.METER;
|
|
|
- this.lengthUnitDisplay = LengthUnits.METER;
|
|
|
+ this.moveSpeed = 10;
|
|
|
|
|
|
- this.showBoundingBox = false;
|
|
|
- this.showAnnotations = true;
|
|
|
- this.freeze = false;
|
|
|
- this.clipTask = ClipTask.HIGHLIGHT;
|
|
|
- this.clipMethod = ClipMethod.INSIDE_ANY;
|
|
|
+ this.lengthUnit = LengthUnits.METER;
|
|
|
+ this.lengthUnitDisplay = LengthUnits.METER;
|
|
|
|
|
|
- this.elevationGradientRepeat = ElevationGradientRepeat.CLAMP;
|
|
|
+ this.showBoundingBox = false;
|
|
|
+ this.showAnnotations = true;
|
|
|
+ this.freeze = false;
|
|
|
+ this.clipTask = ClipTask.HIGHLIGHT;
|
|
|
+ this.clipMethod = ClipMethod.INSIDE_ANY;
|
|
|
|
|
|
- this.filterReturnNumberRange = [0, 7];
|
|
|
- this.filterNumberOfReturnsRange = [0, 7];
|
|
|
- this.filterGPSTimeRange = [-Infinity, Infinity];
|
|
|
- this.filterPointSourceIDRange = [0, 65535];
|
|
|
+ this.elevationGradientRepeat = ElevationGradientRepeat.CLAMP;
|
|
|
|
|
|
- this.potreeRenderer = null;
|
|
|
- this.edlRenderer = null;
|
|
|
- this.pRenderer = null;
|
|
|
+ this.filterReturnNumberRange = [0, 7];
|
|
|
+ this.filterNumberOfReturnsRange = [0, 7];
|
|
|
+ this.filterGPSTimeRange = [-Infinity, Infinity];
|
|
|
+ this.filterPointSourceIDRange = [0, 65535];
|
|
|
|
|
|
- this.scene = null;
|
|
|
- this.sceneVR = null;
|
|
|
- this.overlay = null;
|
|
|
- this.overlayCamera = null;
|
|
|
+ this.potreeRenderer = null;
|
|
|
+ this.edlRenderer = null;
|
|
|
+ this.pRenderer = null;
|
|
|
|
|
|
- this.inputHandler = null;
|
|
|
- this.controls = null;
|
|
|
+ this.scene = null;
|
|
|
+ this.sceneVR = null;
|
|
|
+ this.overlay = null;
|
|
|
+ this.overlayCamera = null;
|
|
|
|
|
|
- this.clippingTool = null;
|
|
|
- this.transformationTool = null;
|
|
|
- this.navigationCube = null;
|
|
|
- this.compass = null;
|
|
|
-
|
|
|
- this.skybox = null;
|
|
|
- this.clock = new THREE.Clock();
|
|
|
- this.background = null;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(args.noDragAndDrop){
|
|
|
-
|
|
|
- }else{
|
|
|
- this.initDragAndDrop();
|
|
|
- }
|
|
|
-
|
|
|
- if(typeof Stats !== "undefined"){
|
|
|
- this.stats = new Stats();
|
|
|
- this.stats.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom
|
|
|
- document.body.appendChild( this.stats.dom );
|
|
|
- }
|
|
|
-
|
|
|
- {
|
|
|
- let canvas = this.renderer.domElement;
|
|
|
- canvas.addEventListener("webglcontextlost", (e) => {
|
|
|
- console.log(e);
|
|
|
- this.postMessage("WebGL context lost. \u2639");
|
|
|
-
|
|
|
- let gl = this.renderer.getContext();
|
|
|
- let error = gl.getError();
|
|
|
- console.log(error);
|
|
|
- }, false);
|
|
|
- }
|
|
|
-
|
|
|
- {
|
|
|
- this.overlay = new THREE.Scene();
|
|
|
- this.overlayCamera = new THREE.OrthographicCamera(
|
|
|
- 0, 1,
|
|
|
- 1, 0,
|
|
|
- -1000, 1000
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- this.pRenderer = new Renderer(this.renderer);
|
|
|
-
|
|
|
- {
|
|
|
- let near = 2.5;
|
|
|
- let far = 10.0;
|
|
|
- let fov = 90;
|
|
|
-
|
|
|
- this.shadowTestCam = new THREE.PerspectiveCamera(90, 1, near, far);
|
|
|
- this.shadowTestCam.position.set(3.50, -2.80, 8.561);
|
|
|
- this.shadowTestCam.lookAt(new THREE.Vector3(0, 0, 4.87));
|
|
|
- }
|
|
|
-
|
|
|
+ this.inputHandler = null;
|
|
|
+ this.controls = null;
|
|
|
|
|
|
- let scene = new Scene(this.renderer);
|
|
|
-
|
|
|
- { // create VR scene
|
|
|
- this.sceneVR = new THREE.Scene();
|
|
|
+ this.clippingTool = null;
|
|
|
+ this.transformationTool = null;
|
|
|
+ this.navigationCube = null;
|
|
|
+ this.compass = null;
|
|
|
+
|
|
|
+ this.skybox = null;
|
|
|
+ this.clock = new THREE.Clock();
|
|
|
+ this.background = null;
|
|
|
|
|
|
- // let texture = new THREE.TextureLoader().load(`${Potree.resourcePath}/images/vr_controller_help.jpg`);
|
|
|
+
|
|
|
|
|
|
- // let plane = new THREE.PlaneBufferGeometry(1, 1, 1, 1);
|
|
|
- // let infoMaterial = new THREE.MeshBasicMaterial({map: texture});
|
|
|
- // let infoNode = new THREE.Mesh(plane, infoMaterial);
|
|
|
- // infoNode.position.set(-0.5, 1, 0);
|
|
|
- // infoNode.scale.set(0.4, 0.3, 1);
|
|
|
- // infoNode.lookAt(0, 1, 0)
|
|
|
- // this.sceneVR.add(infoNode);
|
|
|
+
|
|
|
+
|
|
|
+ if(args.noDragAndDrop){
|
|
|
+
|
|
|
+ }else{
|
|
|
+ this.initDragAndDrop();
|
|
|
+ }
|
|
|
|
|
|
- // window.infoNode = infoNode;
|
|
|
- }
|
|
|
+ if(typeof Stats !== "undefined"){
|
|
|
+ this.stats = new Stats();
|
|
|
+ this.stats.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom
|
|
|
+ document.body.appendChild( this.stats.dom );
|
|
|
+ }
|
|
|
|
|
|
- this.setScene(scene);
|
|
|
+ {
|
|
|
+ let canvas = this.renderer.domElement;
|
|
|
+ canvas.addEventListener("webglcontextlost", (e) => {
|
|
|
+ console.log(e);
|
|
|
+ this.postMessage("WebGL context lost. \u2639");
|
|
|
+
|
|
|
+ let gl = this.renderer.getContext();
|
|
|
+ let error = gl.getError();
|
|
|
+ console.log(error);
|
|
|
+ }, false);
|
|
|
+ }
|
|
|
|
|
|
- {
|
|
|
- this.inputHandler = new InputHandler(this, this.scene.scene);
|
|
|
- //this.inputHandler.setScene(this.scene);
|
|
|
- //this.inputHandler.addInputListener(this);//add
|
|
|
+ {
|
|
|
+ this.overlay = new THREE.Scene();
|
|
|
+ this.overlayCamera = new THREE.OrthographicCamera(
|
|
|
+ 0, 1,
|
|
|
+ 1, 0,
|
|
|
+ -1000, 1000
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
+ this.pRenderer = new Renderer(this.renderer);
|
|
|
|
|
|
+ {
|
|
|
+ let near = 2.5;
|
|
|
+ let far = 10.0;
|
|
|
+ let fov = 90;
|
|
|
+
|
|
|
+ this.shadowTestCam = new THREE.PerspectiveCamera(90, 1, near, far);
|
|
|
+ this.shadowTestCam.position.set(3.50, -2.80, 8.561);
|
|
|
+ this.shadowTestCam.lookAt(new THREE.Vector3(0, 0, 4.87));
|
|
|
+ }
|
|
|
|
|
|
- this.clippingTool = new ClippingTool(this);
|
|
|
- this.transformationTool = new TransformationTool(this);
|
|
|
- this.navigationCube = new NavigationCube(this);
|
|
|
- this.navigationCube.visible = false;
|
|
|
|
|
|
- this.compass = new Compass(this);
|
|
|
-
|
|
|
+ let scene = new Scene(this.renderer);
|
|
|
|
|
|
- //add----------
|
|
|
- this.magnifier = new Magnifier(this);
|
|
|
- this.reticule = new Reticule(this)
|
|
|
- this.scene.scene.add(this.magnifier)
|
|
|
- this.scene.scene.add(this.reticule)
|
|
|
- this.mainViewport = new Viewport( this.scene.view, this.scene.cameraP, {
|
|
|
- left:0, bottom:0, width:1, height: 1, name:'MainView'
|
|
|
- })
|
|
|
- this.viewports = [this.mainViewport]
|
|
|
-
|
|
|
-
|
|
|
- this.mapViewer = new MapViewer($('#mapGaode')[0])
|
|
|
- //-----------
|
|
|
-
|
|
|
-
|
|
|
- this.createControls();
|
|
|
+ { // create VR scene
|
|
|
+ this.sceneVR = new THREE.Scene();
|
|
|
|
|
|
- this.clippingTool.setScene(this.scene);
|
|
|
-
|
|
|
- let onPointcloudAdded = (e) => {
|
|
|
- if (this.scene.pointclouds.length === 1) {
|
|
|
- let speed = e.pointcloud.boundingBox.getSize(new THREE.Vector3()).length();
|
|
|
- speed = speed / 2000;
|
|
|
- this.setMoveSpeed(speed);
|
|
|
- }
|
|
|
- };
|
|
|
+ // let texture = new THREE.TextureLoader().load(`${Potree.resourcePath}/images/vr_controller_help.jpg`);
|
|
|
|
|
|
- let onVolumeRemoved = (e) => {
|
|
|
- this.inputHandler.deselect(e.volume);
|
|
|
- };
|
|
|
+ // let plane = new THREE.PlaneBufferGeometry(1, 1, 1, 1);
|
|
|
+ // let infoMaterial = new THREE.MeshBasicMaterial({map: texture});
|
|
|
+ // let infoNode = new THREE.Mesh(plane, infoMaterial);
|
|
|
+ // infoNode.position.set(-0.5, 1, 0);
|
|
|
+ // infoNode.scale.set(0.4, 0.3, 1);
|
|
|
+ // infoNode.lookAt(0, 1, 0)
|
|
|
+ // this.sceneVR.add(infoNode);
|
|
|
|
|
|
- this.addEventListener('scene_changed', (e) => {
|
|
|
- this.inputHandler.setScene(e.scene);
|
|
|
- this.clippingTool.setScene(this.scene);
|
|
|
-
|
|
|
- if(!e.scene.hasEventListener("pointcloud_added", onPointcloudAdded)){
|
|
|
- e.scene.addEventListener("pointcloud_added", onPointcloudAdded);
|
|
|
- }
|
|
|
+ // window.infoNode = infoNode;
|
|
|
+ }
|
|
|
|
|
|
- if(!e.scene.hasEventListener("volume_removed", onPointcloudAdded)){
|
|
|
- e.scene.addEventListener("volume_removed", onVolumeRemoved);
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
+ this.setScene(scene);
|
|
|
|
|
|
- this.scene.addEventListener("volume_removed", onVolumeRemoved);
|
|
|
- this.scene.addEventListener('pointcloud_added', onPointcloudAdded);
|
|
|
- }
|
|
|
+ {
|
|
|
+ this.inputHandler = new InputHandler(this, this.scene.scene);
|
|
|
+ //this.inputHandler.setScene(this.scene);
|
|
|
+ //this.inputHandler.addInputListener(this);//add
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.clippingTool = new ClippingTool(this);
|
|
|
+ this.transformationTool = new TransformationTool(this);
|
|
|
+ this.navigationCube = new NavigationCube(this);
|
|
|
+ this.navigationCube.visible = false;
|
|
|
|
|
|
- { // set defaults
|
|
|
- this.setFOV(60);
|
|
|
- this.setEDLEnabled(false);
|
|
|
- this.setEDLRadius(1.4);
|
|
|
- this.setEDLStrength(0.4);
|
|
|
- this.setEDLOpacity(1.0);
|
|
|
- this.setClipTask(ClipTask.HIGHLIGHT);
|
|
|
- this.setClipMethod(ClipMethod.INSIDE_ANY);
|
|
|
- this.setPointBudget(1*1000*1000);
|
|
|
- this.setShowBoundingBox(false);
|
|
|
- this.setFreeze(false);
|
|
|
- this.setControls(this.fpControls/* orbitControls */);
|
|
|
- this.setBackground('gradient');
|
|
|
+ this.compass = new Compass(this);
|
|
|
+
|
|
|
+
|
|
|
+ //add----------
|
|
|
+ this.magnifier = new Magnifier(this);
|
|
|
+ this.reticule = new Reticule(this)
|
|
|
+ this.scene.scene.add(this.magnifier)
|
|
|
+ this.scene.scene.add(this.reticule)
|
|
|
+ this.mainViewport = new Viewport( this.scene.view, this.scene.cameraP, {
|
|
|
+ left:0, bottom:0, width:1, height: 1, name:'MainView'
|
|
|
+ })
|
|
|
+ this.viewports = [this.mainViewport]
|
|
|
+
|
|
|
+
|
|
|
+ this.mapViewer = new MapViewer(mapArea/* $('#mapGaode')[0] */)
|
|
|
+ //-----------
|
|
|
+
|
|
|
+
|
|
|
+ this.createControls();
|
|
|
|
|
|
- this.scaleFactor = 1;
|
|
|
+ this.clippingTool.setScene(this.scene);
|
|
|
+
|
|
|
+ let onPointcloudAdded = (e) => {
|
|
|
+ if (this.scene.pointclouds.length === 1) {
|
|
|
+ let speed = e.pointcloud.boundingBox.getSize(new THREE.Vector3()).length();
|
|
|
+ speed = speed / 2000;
|
|
|
+ this.setMoveSpeed(speed);
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- this.loadSettingsFromURL();
|
|
|
- }
|
|
|
+ let onVolumeRemoved = (e) => {
|
|
|
+ this.inputHandler.deselect(e.volume);
|
|
|
+ };
|
|
|
|
|
|
- // start rendering!
|
|
|
- //if(args.useDefaultRenderLoop === undefined || args.useDefaultRenderLoop === true){
|
|
|
- //requestAnimationFrame(this.loop.bind(this));
|
|
|
- //}
|
|
|
+ this.addEventListener('scene_changed', (e) => {
|
|
|
+ this.inputHandler.setScene(e.scene);
|
|
|
+ this.clippingTool.setScene(this.scene);
|
|
|
+
|
|
|
+ if(!e.scene.hasEventListener("pointcloud_added", onPointcloudAdded)){
|
|
|
+ e.scene.addEventListener("pointcloud_added", onPointcloudAdded);
|
|
|
+ }
|
|
|
|
|
|
- this.renderer.setAnimationLoop(this.loop.bind(this));
|
|
|
+ if(!e.scene.hasEventListener("volume_removed", onPointcloudAdded)){
|
|
|
+ e.scene.addEventListener("volume_removed", onVolumeRemoved);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
|
|
|
- this.loadGUI = this.loadGUI.bind(this);
|
|
|
+ this.scene.addEventListener("volume_removed", onVolumeRemoved);
|
|
|
+ this.scene.addEventListener('pointcloud_added', onPointcloudAdded);
|
|
|
+ }
|
|
|
|
|
|
- this.annotationTool = new AnnotationTool(this);
|
|
|
- this.measuringTool = new MeasuringTool(this);
|
|
|
- this.profileTool = new ProfileTool(this);
|
|
|
- this.volumeTool = new VolumeTool(this);
|
|
|
+ { // set defaults
|
|
|
+ this.setFOV(60);
|
|
|
+ this.setEDLEnabled(false);
|
|
|
+ this.setEDLRadius(1.4);
|
|
|
+ this.setEDLStrength(0.4);
|
|
|
+ this.setEDLOpacity(1.0);
|
|
|
+ this.setClipTask(ClipTask.HIGHLIGHT);
|
|
|
+ this.setClipMethod(ClipMethod.INSIDE_ANY);
|
|
|
+ this.setPointBudget(1*1000*1000);
|
|
|
+ this.setShowBoundingBox(false);
|
|
|
+ this.setFreeze(false);
|
|
|
+ this.setControls(this.fpControls/* orbitControls */);
|
|
|
+ this.setBackground('gradient');
|
|
|
+
|
|
|
+ this.scaleFactor = 1;
|
|
|
+
|
|
|
+ this.loadSettingsFromURL();
|
|
|
+ }
|
|
|
+
|
|
|
+ // start rendering!
|
|
|
+ //if(args.useDefaultRenderLoop === undefined || args.useDefaultRenderLoop === true){
|
|
|
+ //requestAnimationFrame(this.loop.bind(this));
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ this.renderer.setAnimationLoop(this.loop.bind(this));
|
|
|
+
|
|
|
+ this.loadGUI = this.loadGUI.bind(this);
|
|
|
+
|
|
|
+ this.annotationTool = new AnnotationTool(this);
|
|
|
+ this.measuringTool = new MeasuringTool(this);
|
|
|
+ this.profileTool = new ProfileTool(this);
|
|
|
+ this.volumeTool = new VolumeTool(this);
|
|
|
|
|
|
}catch(e){
|
|
|
this.onCrash(e);
|
|
|
}
|
|
|
|
|
|
- {
|
|
|
+ {//add
|
|
|
let pointDensity = ''
|
|
|
Object.defineProperty(Potree.settings , "pointDensity",{
|
|
|
get: function() {
|
|
@@ -1391,8 +1370,8 @@ export class Viewer extends ViewerBase{
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- this.mapView = new MapView(this);
|
|
|
- this.mapView.init();
|
|
|
+ /* this.mapView = new MapView(this);
|
|
|
+ this.mapView.init(); */
|
|
|
|
|
|
i18n.init({
|
|
|
lng: 'en',
|
|
@@ -1887,8 +1866,8 @@ export class Viewer extends ViewerBase{
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- this.viewports.forEach(e=>{//判断camera画面是否改变
|
|
|
- if(e.hasChanged()){
|
|
|
+ /* this.viewports.forEach(e=>{//判断camera画面是否改变
|
|
|
+ if(e.cameraChanged()){
|
|
|
this.dispatchEvent({
|
|
|
type: "camera_changed",
|
|
|
camera: e.camera,
|
|
@@ -1896,8 +1875,10 @@ export class Viewer extends ViewerBase{
|
|
|
})
|
|
|
|
|
|
}
|
|
|
- })
|
|
|
-
|
|
|
+ }) */
|
|
|
+
|
|
|
+ this.cameraChanged()//判断camera画面是否改变
|
|
|
+
|
|
|
/* {//判断camera画面是否改变
|
|
|
if(this._previousCamera === undefined){
|
|
|
this._previousCamera = this.scene.getActiveCamera().clone();
|
|
@@ -2006,7 +1987,7 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
|
|
|
|
|
|
- if(isViewport)return
|
|
|
+ //if(isViewport)return
|
|
|
const tStart = performance.now();
|
|
|
const campos = camera.position;
|
|
|
let closestImage = Infinity;
|
|
@@ -2019,7 +2000,14 @@ export class Viewer extends ViewerBase{
|
|
|
}
|
|
|
const tEnd = performance.now();
|
|
|
|
|
|
- if(result.lowestSpacing !== Infinity){
|
|
|
+
|
|
|
+ //改:不根据点云修改视野near far
|
|
|
+ var near = camera.near, far = camera.far
|
|
|
+ if(Potree.settings.limitFar){
|
|
|
+ camera.near = 0.1;
|
|
|
+ camera.far = Potree.settings.cameraFar;
|
|
|
+ }else if(result.lowestSpacing !== Infinity){
|
|
|
+
|
|
|
let near = result.lowestSpacing * 10.0;
|
|
|
let far = -this.getBoundingBox().applyMatrix4(camera.matrixWorldInverse).min.z;
|
|
|
|
|
@@ -2035,13 +2023,16 @@ export class Viewer extends ViewerBase{
|
|
|
camera.near = near;
|
|
|
camera.far = far;
|
|
|
}else{
|
|
|
- // don't change near and far in this case
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- if(this.scene.cameraMode == CameraMode.ORTHOGRAPHIC) {
|
|
|
+ if(this.scene.cameraMode == CameraMode.ORTHOGRAPHIC) {//???
|
|
|
camera.near = -camera.far;
|
|
|
}
|
|
|
-
|
|
|
+ if(near != camera.near || far != camera.far){
|
|
|
+ camera.updateProjectionMatrix()
|
|
|
+ }
|
|
|
+ //注:pointcloud.visibleNodes会随着near far自动更新
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2358,7 +2349,7 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
|
|
|
if(!params.magnifier){//为什么要在点云之后渲染,否则透明失效 、 会被点云覆盖
|
|
|
- this.setCameraLayers(camera, ['marker','reticule']) //透明贴图层 skybox 、reticule marker 不能遮住测量线
|
|
|
+ this.setCameraLayers(camera, ['marker','reticule','route']) //透明贴图层 skybox 、reticule marker 不能遮住测量线
|
|
|
this.renderer.render(this.scene.scene, camera);
|
|
|
}
|
|
|
this.dispatchEvent({type: "render.pass.scene", viewer: viewer});
|