//let getQueryParam = function(name) { // name = name.replace(/[\[\]]/g, "\\$&"); // let regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"), // results = regex.exec(window.location.href); // if (!results) return null; // if (!results[2]) return ''; // return decodeURIComponent(results[2].replace(/\+/g, " ")); //} Potree.View = class{ constructor(){ this.position = new THREE.Vector3(0, 0, 0); this.yaw = Math.PI / 4; this._pitch = -Math.PI / 4; this.radius = 1; this.maxPitch = Math.PI / 2; this.minPitch = -Math.PI / 2; this.navigationMode = Potree.OrbitControls; } clone(){ let c = new Potree.View(); c.yaw = this.yaw; c._pitch = this.pitch; c.radius = this.radius; c.maxPitch = this.maxPitch; c.minPitch = this.minPitch; c.navigationMode = this.navigationMode; return c; } get pitch(){ return this._pitch; } set pitch(angle){ this._pitch = Math.max(Math.min(angle, this.maxPitch), this.minPitch); } get direction(){ let dir = new THREE.Vector3(0, 1, 0); dir.applyAxisAngle(new THREE.Vector3(1, 0, 0), this.pitch); dir.applyAxisAngle(new THREE.Vector3(0, 0, 1), this.yaw); return dir; } set direction(dir){ let yaw = Math.atan2(dir.y, dir.x) - Math.PI / 2; let pitch = Math.atan2(dir.z, Math.sqrt(dir.x * dir.x + dir.y * dir.y)); this.yaw = yaw; this.pitch = pitch; } lookAt(t){ let V = new THREE.Vector3().subVectors(t, this.position); let radius = V.length(); let dir = V.normalize(); this.radius = radius; this.direction = dir; } getPivot(){ return new THREE.Vector3().addVectors(this.position, this.direction.multiplyScalar(this.radius)); } getSide(){ let side = new THREE.Vector3(1, 0, 0); side.applyAxisAngle(new THREE.Vector3(0, 0, 1), this.yaw); return side; } pan(x, y){ let dir = new THREE.Vector3(0, 1, 0); dir.applyAxisAngle(new THREE.Vector3(1, 0, 0), this.pitch); dir.applyAxisAngle(new THREE.Vector3(0, 0, 1), this.yaw); //let side = new THREE.Vector3(1, 0, 0); //side.applyAxisAngle(new THREE.Vector3(0, 0, 1), this.yaw); let side = this.getSide(); let up = side.clone().cross(dir); let pan = side.multiplyScalar(x).add(up.multiplyScalar(y)); this.position = this.position.add(pan); //this.target = this.target.add(pan); } translate(x, y, z){ let dir = new THREE.Vector3(0, 1, 0); dir.applyAxisAngle(new THREE.Vector3(1, 0, 0), this.pitch); dir.applyAxisAngle(new THREE.Vector3(0, 0, 1), this.yaw); let side = new THREE.Vector3(1, 0, 0); side.applyAxisAngle(new THREE.Vector3(0, 0, 1), this.yaw); let up = side.clone().cross(dir); let t = side.multiplyScalar(x) .add(dir.multiplyScalar(y)) .add(up.multiplyScalar(z)); this.position = this.position.add(t); } translateWorld(x, y, z){ this.position.x += x; this.position.y += y; this.position.z += z; } }; Potree.Scene = class extends THREE.EventDispatcher{ constructor(){ super(); this.annotations = new Potree.Annotation(); this.scene = new THREE.Scene(); this.scenePointCloud = new THREE.Scene(); this.sceneBG = new THREE.Scene(); this.camera = new THREE.PerspectiveCamera(this.fov, 1, 0.1, 1000*1000); this.cameraBG = new THREE.Camera(); this.pointclouds = []; this.referenceFrame; this.measurements = []; this.profiles = []; this.volumes = []; this.fpControls; this.orbitControls; this.earthControls; this.geoControls; this.inputHandler; this.view = new Potree.View(); this.directionalLight = null; this.initialize(); } addPointCloud(pointcloud){ this.pointclouds.push(pointcloud); this.scenePointCloud.add(pointcloud); this.dispatchEvent({ type: "pointcloud_added", pointcloud: pointcloud }); }; addVolume(volume){ this.volumes.push(volume); this.dispatchEvent({ "type": "volume_added", "scene": this, "volume": volume }); }; removeVolume(volume){ let index = this.volumes.indexOf(volume); if (index > -1) { this.volumes.splice(index, 1); this.dispatchEvent({ "type": "volume_removed", "scene": this, "volume": volume }); } }; addMeasurement(measurement){ measurement.lengthUnit = this.lengthUnit; this.measurements.push(measurement); this.dispatchEvent({ "type": "measurement_added", "scene": this, "measurement": measurement }); }; removeMeasurement(measurement){ let index = this.measurements.indexOf(measurement); if (index > -1) { this.measurements.splice(index, 1); this.dispatchEvent({ "type": "measurement_removed", "scene": this, "measurement": measurement }); } } addProfile(profile){ this.profiles.push(profile); this.dispatchEvent({ "type": "profile_added", "scene": this, "profile": profile }); } removeProfile(profile){ let index = this.profiles.indexOf(profile); if (index > -1) { this.profiles.splice(index, 1); this.dispatchEvent({ "type": "profile_removed", "scene": this, "profile": profile }); } } removeAllMeasurements(){ while(this.measurements.length > 0){ this.removeMeasurement(this.measurements[0]); } while(this.profiles.length > 0){ this.removeProfile(this.profiles[0]); } while(this.volumes.length > 0){ this.removeVolume(this.volumes[0]); } } initialize(){ this.referenceFrame = new THREE.Object3D(); this.referenceFrame.matrixAutoUpdate = false; this.scenePointCloud.add(this.referenceFrame); this.camera.up.set(0, 0, 1); this.camera.position.set(1000, 1000, 1000); //this.camera.rotation.y = -Math.PI / 4; //this.camera.rotation.x = -Math.PI / 6; this.directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); this.directionalLight.position.set( 10, 10, 10 ); this.directionalLight.lookAt( new THREE.Vector3(0, 0, 0)); this.scenePointCloud.add( this.directionalLight ); let light = new THREE.AmbientLight( 0x555555 ); // soft white light this.scenePointCloud.add( light ); let grid = Potree.utils.createGrid(5, 5, 2); this.scene.add(grid); {// background // var texture = THREE.ImageUtils.loadTexture( Potree.resourcePath + '/textures/background.gif' ); let texture = Potree.utils.createBackgroundTexture(512, 512); texture.minFilter = texture.magFilter = THREE.NearestFilter; texture.minFilter = texture.magFilter = THREE.LinearFilter; let bg = new THREE.Mesh( new THREE.PlaneBufferGeometry(2, 2, 0), new THREE.MeshBasicMaterial({ map: texture }) ); bg.material.depthTest = false; bg.material.depthWrite = false; this.sceneBG.add(bg); } {// lights { let light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 10, 10, 1 ); light.target.position.set( 0, 0,0 ); this.scene.add(light); } { let light = new THREE.DirectionalLight( 0xffffff ); light.position.set( -10, 10, 1 ); light.target.position.set( 0, 0,0 ); this.scene.add(light); } { let light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0, -10, 20 ); light.target.position.set( 0, 0,0 ); this.scene.add(light); } } } addAnnotation(position, args = {}){ if(position instanceof Array){ args.position = new THREE.Vector3().fromArray(position); }else if(position instanceof THREE.Vector3){ args.position = position; } let annotation = new Potree.Annotation(args); this.annotations.add(annotation); } getAnnotations(){ return this.annotations; }; }; Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ constructor(domElement, args){ super(); let a = args || {}; this.pointCloudLoadedCallback = a.onPointCloudLoaded || function(){}; this.renderArea = domElement; //if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { // defaultSettings.navigation = "Orbit"; //} this.server = null; this.fov = 60; this.clipMode = Potree.ClipMode.HIGHLIGHT_INSIDE; this.isFlipYZ = false; this.useDEMCollisions = false; this.generateDEM = false; this.minNodeSize = 100; this.directionalLight; this.edlStrength = 1.0; this.edlRadius = 1.4; this.useEDL = false; this.classifications = { 0: { visible: true, name: "never classified" }, 1: { visible: true, name: "unclassified" }, 2: { visible: true, name: "ground" }, 3: { visible: true, name: "low vegetation" }, 4: { visible: true, name: "medium vegetation"}, 5: { visible: true, name: "high vegetation" }, 6: { visible: true, name: "building" }, 7: { visible: true, name: "low point(noise)" }, 8: { visible: true, name: "key-point" }, 9: { visible: true, name: "water" }, 12: { visible: true, name: "overlap" } }; this.moveSpeed = 10; this.LENGTH_UNITS = { METER : {code: "m"}, FEET: {code: "ft"}, INCH: {code: "\u2033"} }; this.lengthUnit = this.LENGTH_UNITS.METER; this.showBoundingBox = false; this.showAnnotations = true; this.freeze = false; this.mapView; this.progressBar = new ProgressBar(); this.stats = new Stats(); //this.stats.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom //document.body.appendChild( this.stats.dom ); //this.stats.dom.style.left = "100px"; this.potreeRenderer = null; this.edlRenderer = null; this.renderer = null; this.scene = null; this.inputHandler = null; this.measuringTool = null; this.profileTool = null; this.volumeTool = null; this.transformationTool = null; this.skybox = null; this.clock = new THREE.Clock(); this.background = null; this.initThree(); let scene = new Potree.Scene(this.renderer); this.setScene(scene); { this.inputHandler = new Potree.InputHandler(this); this.inputHandler.setScene(this.scene); this.measuringTool = new Potree.MeasuringTool(this); this.profileTool = new Potree.ProfileTool(this); this.volumeTool = new Potree.VolumeTool(this); this.transformationTool = new Potree.TransformationTool(this); this.createControls(); this.measuringTool.setScene(this.scene); this.profileTool.setScene(this.scene); this.volumeTool.setScene(this.scene); let onPointcloudAdded = (e) => { if(this.scene.pointclouds.length === 1){ let speed = e.pointcloud.boundingBox.getSize().length(); speed = speed / 5; this.setMoveSpeed(speed); } }; this.addEventListener("scene_changed", (e) => { this.inputHandler.setScene(e.scene); this.measuringTool.setScene(e.scene); this.profileTool.setScene(e.scene); this.volumeTool.setScene(e.scene); if(!e.scene.hasEventListener("pointcloud_added", onPointcloudAdded)){ e.scene.addEventListener("pointcloud_added", onPointcloudAdded); } }); this.scene.addEventListener("pointcloud_added", onPointcloudAdded); } {// set defaults this.setFOV(60); this.setEDLEnabled(false); this.setEDLRadius(1.4); this.setEDLStrength(1.0); this.setClipMode(Potree.ClipMode.HIGHLIGHT_INSIDE); this.setPointBudget(1*1000*1000); this.setShowBoundingBox(false); this.setFreeze(false); this.setNavigationMode(Potree.OrbitControls); this.setBackground("gradient"); this.scaleFactor = 1; this.loadSettingsFromURL(); } // start rendering! requestAnimationFrame(this.loop.bind(this)); } //------------------------------------------------------------------------------------ // Viewer API //------------------------------------------------------------------------------------ setScene(scene){ if(scene === this.scene){ return; } let oldScene = this.scene; this.scene = scene; this.dispatchEvent({ type: "scene_changed", oldScene: oldScene, scene: scene }); { // Annotations $(".annotation").detach(); //for(let annotation of this.scene.annotations){ // this.renderArea.appendChild(annotation.domElement[0]); //} this.scene.annotations.traverse(annotation => { this.renderArea.appendChild(annotation.domElement[0]); }); if(!this.onAnnotationAdded){ this.onAnnotationAdded = e => { //console.log("annotation added: " + e.annotation.title); e.annotation.traverse(node => { this.renderArea.appendChild(node.domElement[0]); node.scene = this.scene; }); }; } this.scene.annotations.addEventListener("annotation_added", this.onAnnotationAdded); if(oldScene){ oldScene.annotations.removeEventListener("annotation_added", this.onAnnotationAdded); } } }; getControls(navigationMode){ if(navigationMode === Potree.OrbitControls){ return this.orbitControls; }else if(navigationMode === Potree.FirstPersonControls){ return this.fpControls; }else if(navigationMode === Potree.EarthControls){ return this.earthControls; }else{ return null; } } getMinNodeSize(){ return this.minNodeSize; }; setMinNodeSize(value){ if(this.minNodeSize !== value){ this.minNodeSize = value; this.dispatchEvent({"type": "minnodesize_changed", "viewer": this}); } }; getBackground(){ return this.background; }; setBackground(bg){ if(this.background === bg){ return; } this.background = bg; this.dispatchEvent({"type": "background_changed", "viewer": this}); } setDescription(value){ $('#potree_description')[0].innerHTML = value; }; setNavigationMode(value){ this.scene.view.navigationMode = value; }; setShowBoundingBox(value){ if(this.showBoundingBox !== value){ this.showBoundingBox = value; this.dispatchEvent({"type": "show_boundingbox_changed", "viewer": this}); } }; getShowBoundingBox(){ return showBoundingBox; }; setMoveSpeed(value){ if(this.moveSpeed !== value){ this.moveSpeed = value; this.dispatchEvent({"type": "move_speed_changed", "viewer": this, "speed": value}); } }; getMoveSpeed(){ return this.moveSpeed; }; setWeightClassification(w){ for(let i = 0; i < this.scene.pointclouds.length; i++) { this.scene.pointclouds[i].material.weightClassification = w; this.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": this}); } }; setFreeze(value){ if(this.freeze != value){ this.freeze = value; this.dispatchEvent({"type": "freeze_changed", "viewer": this}); } }; getFreeze(){ return this.freeze; }; setPointBudget(value){ if(Potree.pointBudget !== value){ Potree.pointBudget = parseInt(value); this.dispatchEvent({"type": "point_budget_changed", "viewer": this}); } }; getPointBudget(){ return Potree.pointBudget; }; setShowAnnotations(value){ if(this.showAnnotations !== value){ this.showAnnotations = value; this.dispatchEvent({"type": "show_annotations_changed", "viewer": this}); } } getShowAnnotations(){ return this.showAnnotations; } setClipMode(clipMode){ if(this.clipMode !== clipMode){ this.clipMode = clipMode; this.dispatchEvent({"type": "clip_mode_changed", "viewer": this}); } }; getClipMode(){ return this.clipMode; }; setDEMCollisionsEnabled(value){ if(this.useDEMCollisions !== value){ this.useDEMCollisions = value; this.dispatchEvent({"type": "use_demcollisions_changed", "viewer": this}); }; }; getDEMCollisionsEnabled(){ return this.useDEMCollisions; }; setEDLEnabled(value){ if(this.useEDL != value){ this.useEDL = value; this.dispatchEvent({"type": "use_edl_changed", "viewer": this}); } }; getEDLEnabled(){ return this.useEDL; }; setEDLRadius(value){ if(this.edlRadius !== value){ this.edlRadius = value; this.dispatchEvent({"type": "edl_radius_changed", "viewer": this}); } }; getEDLRadius(){ return this.edlRadius; }; setEDLStrength(value){ if(this.edlStrength !== value){ this.edlStrength = value; this.dispatchEvent({"type": "edl_strength_changed", "viewer": this}); } }; getEDLStrength(){ return this.edlStrength; }; setFOV(value){ if(this.fov !== value){ this.fov = value; this.dispatchEvent({"type": "fov_changed", "viewer": this}); } }; getFOV(){ return this.fov; }; disableAnnotations(){ this.scene.annotations.traverse(annotation => { annotation.domElement.css("pointer-events", "none"); //return annotation.visible; }); }; enableAnnotations(){ this.scene.annotations.traverse(annotation => { annotation.domElement.css("pointer-events", "auto"); //return annotation.visible; }); }; setClassificationVisibility(key, value){ if(!this.classifications[key]){ this.classifications[key] = {visible: value, name: "no name"}; this.dispatchEvent({"type": "classification_visibility_changed", "viewer": this}); }else if(this.classifications[key].visible !== value){ this.classifications[key].visible = value; this.dispatchEvent({"type": "classification_visibility_changed", "viewer": this}); } }; setLengthUnit(value) { switch(value) { case "m": this.lengthUnit = this.LENGTH_UNITS.METER; break; case "ft": this.lengthUnit = this.LENGTH_UNITS.FEET; break; case "in": this.lengthUnit = this.LENGTH_UNITS.INCH; break; } this.dispatchEvent({"type": "length_unit_changed", "viewer": this}); } toMaterialID(materialName){ if(materialName === "RGB"){ return Potree.PointColorType.RGB; }else if(materialName === "Color"){ return Potree.PointColorType.COLOR; }else if(materialName === "Elevation"){ return Potree.PointColorType.HEIGHT; }else if(materialName === "Intensity"){ return Potree.PointColorType.INTENSITY; }else if(materialName === "Intensity Gradient"){ return Potree.PointColorType.INTENSITY_GRADIENT; }else if(materialName === "Classification"){ return Potree.PointColorType.CLASSIFICATION; }else if(materialName === "Return Number"){ return Potree.PointColorType.RETURN_NUMBER; }else if(materialName === "Source"){ return Potree.PointColorType.SOURCE; }else if(materialName === "Level of Detail"){ return Potree.PointColorType.LOD; }else if(materialName === "Point Index"){ return Potree.PointColorType.POINT_INDEX; }else if(materialName === "Normal"){ return Potree.PointColorType.NORMAL; }else if(materialName === "Phong"){ return Potree.PointColorType.PHONG; }else if(materialName === "RGB and Elevation"){ return Potree.PointColorType.RGB_HEIGHT; }else if(materialName === "Composite"){ return Potree.PointColorType.COMPOSITE; } }; toMaterialName(materialID){ if(materialID === Potree.PointColorType.RGB){ return "RGB"; }else if(materialID === Potree.PointColorType.COLOR){ return "Color"; }else if(materialID === Potree.PointColorType.HEIGHT){ return "Elevation"; }else if(materialID === Potree.PointColorType.INTENSITY){ return "Intensity"; }else if(materialID === Potree.PointColorType.INTENSITY_GRADIENT){ return "Intensity Gradient"; }else if(materialID === Potree.PointColorType.CLASSIFICATION){ return "Classification"; }else if(materialID === Potree.PointColorType.RETURN_NUMBER){ return "Return Number"; }else if(materialID === Potree.PointColorType.SOURCE){ return "Source"; }else if(materialID === Potree.PointColorType.LOD){ return "Level of Detail"; }else if(materialID === Potree.PointColorType.POINT_INDEX){ return "Point Index"; }else if(materialID === Potree.PointColorType.NORMAL){ return "Normal"; }else if(materialID === Potree.PointColorType.PHONG){ return "Phong"; }else if(materialID === Potree.PointColorType.RGB_HEIGHT){ return "RGB and Elevation"; }else if(materialID === Potree.PointColorType.COMPOSITE){ return "Composite"; } }; zoomTo(node, factor){ //this.scene.camera.zoomTo(node, factor); let view = this.scene.view; let camera = this.scene.camera.clone(); camera.position.copy(view.position); camera.lookAt(view.getPivot()); camera.updateMatrixWorld(); camera.zoomTo(node, factor); let bs; if(node.boundingSphere){ bs = node.boundingSphere; }else if(node.geometry && node.geometry.boundingSphere){ bs = node.geometry.boundingSphere; }else{ bs = node.boundingBox.getBoundingSphere(); } bs = bs.clone().applyMatrix4(node.matrixWorld); view.position.copy(camera.position); view.radius = view.position.distanceTo(bs.center); //let target = bs.center; //target.z = target.z - bs.radius * 0.8; //view.lookAt(target); this.dispatchEvent({"type": "zoom_to", "viewer": this}); }; showAbout(){ $(function() { $( "#about-panel" ).dialog(); }); }; getBoundingBox(pointclouds){ pointclouds = pointclouds || this.scene.pointclouds; let box = new THREE.Box3(); this.scene.scenePointCloud.updateMatrixWorld(true); this.scene.referenceFrame.updateMatrixWorld(true); for(let pointcloud of this.scene.pointclouds){ pointcloud.updateMatrixWorld(true); let pointcloudBox = pointcloud.pcoGeometry.tightBoundingBox ? pointcloud.pcoGeometry.tightBoundingBox : pointcloud.boundingBox; let boxWorld = Potree.utils.computeTransformedBoundingBox(pointcloudBox, pointcloud.matrixWorld) box.union(boxWorld); } return box; }; fitToScreen(factor = 1){ let box = this.getBoundingBox(this.scene.pointclouds); let node = new THREE.Object3D(); node.boundingBox = box; this.zoomTo(node, factor); }; setTopView(){ this.scene.view.yaw = 0; this.scene.view.pitch = -Math.PI / 2; this.fitToScreen(); }; setFrontView(){ this.scene.view.yaw = 0; this.scene.view.pitch = 0; this.fitToScreen(); }; setLeftView(){ this.scene.view.yaw = -Math.PI / 2; this.scene.view.pitch = 0; this.fitToScreen(); }; setRightView(){ this.scene.view.yaw = Math.PI / 2; this.scene.view.pitch = 0; this.fitToScreen(); }; flipYZ(){ this.isFlipYZ = !this.isFlipYZ // TODO flipyz console.log("TODO"); } loadSettingsFromURL(){ if(Potree.utils.getParameterByName("pointSize")){ this.setPointSize(parseFloat(Potree.utils.getParameterByName("pointSize"))); } if(Potree.utils.getParameterByName("FOV")){ this.setFOV(parseFloat(Potree.utils.getParameterByName("FOV"))); } if(Potree.utils.getParameterByName("opacity")){ this.setOpacity(parseFloat(Potree.utils.getParameterByName("opacity"))); } if(Potree.utils.getParameterByName("edlEnabled")){ let enabled = Potree.utils.getParameterByName("edlEnabled") === "true"; this.setEDLEnabled(enabled); } if(Potree.utils.getParameterByName("edlRadius")){ this.setEDLRadius(parseFloat(Potree.utils.getParameterByName("edlRadius"))); } if(Potree.utils.getParameterByName("edlStrength")){ this.setEDLStrength(parseFloat(Potree.utils.getParameterByName("edlStrength"))); } if(Potree.utils.getParameterByName("clipMode")){ let clipMode = Potree.utils.getParameterByName("clipMode"); if(clipMode === "HIGHLIGHT_INSIDE"){ this.setClipMode(Potree.ClipMode.HIGHLIGHT_INSIDE); }else if(clipMode === "CLIP_OUTSIDE"){ this.setClipMode(Potree.ClipMode.CLIP_OUTSIDE); }else if(clipMode === "DISABLED"){ this.setClipMode(Potree.ClipMode.DISABLED); } } if(Potree.utils.getParameterByName("pointBudget")){ this.setPointBudget(parseFloat(Potree.utils.getParameterByName("pointBudget"))); } if(Potree.utils.getParameterByName("showBoundingBox")){ let enabled = Potree.utils.getParameterByName("showBoundingBox") === "true"; if(enabled){ this.setShowBoundingBox(true); }else{ this.setShowBoundingBox(false); } } if(Potree.utils.getParameterByName("material")){ let material = Potree.utils.getParameterByName("material"); this.setMaterial(material); } if(Potree.utils.getParameterByName("pointSizing")){ let sizing = Potree.utils.getParameterByName("pointSizing"); this.setPointSizing(sizing); } if(Potree.utils.getParameterByName("quality")){ let quality = Potree.utils.getParameterByName("quality"); this.setQuality(quality); } if(Potree.utils.getParameterByName("position")){ let value = Potree.utils.getParameterByName("position"); value = value.replace("[", "").replace("]", ""); let tokens = value.split(";"); let x = parseFloat(tokens[0]); let y = parseFloat(tokens[1]); let z = parseFloat(tokens[2]); this.scene.view.position.set(x, y, z); } if(Potree.utils.getParameterByName("target")){ let value = Potree.utils.getParameterByName("target"); value = value.replace("[", "").replace("]", ""); let tokens = value.split(";"); let x = parseFloat(tokens[0]); let y = parseFloat(tokens[1]); let z = parseFloat(tokens[2]); this.scene.view.lookAt(new THREE.Vector3(x, y, z)); } if(Potree.utils.getParameterByName("background")){ let value = Potree.utils.getParameterByName("background"); this.setBackground(value); } //if(Potree.utils.getParameterByName("elevationRange")){ // let value = Potree.utils.getParameterByName("elevationRange"); // value = value.replace("[", "").replace("]", ""); // let tokens = value.split(";"); // let x = parseFloat(tokens[0]); // let y = parseFloat(tokens[1]); // // this.setElevationRange(x, y); // //this.scene.view.target.set(x, y, z); //} }; //------------------------------------------------------------------------------------ // Viewer Internals //------------------------------------------------------------------------------------ createControls(){ { // create FIRST PERSON CONTROLS this.fpControls = new Potree.FirstPersonControls(this); this.fpControls.enabled = false; this.fpControls.addEventListener("start", this.disableAnnotations.bind(this)); this.fpControls.addEventListener("end", this.enableAnnotations.bind(this)); //this.fpControls.addEventListener("double_click_move", (event) => { // let distance = event.targetLocation.distanceTo(event.position); // this.setMoveSpeed(Math.pow(distance, 0.4)); //}); //this.fpControls.addEventListener("move_speed_changed", (event) => { // this.setMoveSpeed(this.fpControls.moveSpeed); //}); } //{ // create GEO CONTROLS // this.geoControls = new Potree.GeoControls(this.scene.camera, this.renderer.domElement); // this.geoControls.enabled = false; // this.geoControls.addEventListener("start", this.disableAnnotations.bind(this)); // this.geoControls.addEventListener("end", this.enableAnnotations.bind(this)); // this.geoControls.addEventListener("move_speed_changed", (event) => { // this.setMoveSpeed(this.geoControls.moveSpeed); // }); //} { // create ORBIT CONTROLS this.orbitControls = new Potree.OrbitControls(this); this.orbitControls.enabled = false; this.orbitControls.addEventListener("start", this.disableAnnotations.bind(this)); this.orbitControls.addEventListener("end", this.enableAnnotations.bind(this)); } { // create EARTH CONTROLS this.earthControls = new Potree.EarthControls(this); this.earthControls.enabled = false; this.earthControls.addEventListener("start", this.disableAnnotations.bind(this)); this.earthControls.addEventListener("end", this.enableAnnotations.bind(this)); } }; toggleSidebar(){ let renderArea = $('#potree_render_area'); let sidebar = $('#potree_sidebar_container'); let isVisible = renderArea.css("left") !== "0px"; if(isVisible){ renderArea.css("left", "0px"); }else{ renderArea.css("left", "300px"); } }; toggleMap(){ //let map = $('#potree_map'); //map.toggle(100); if(this.mapView){ this.mapView.toggle(); } }; loadGUI(callback){ let sidebarContainer = $('#potree_sidebar_container'); sidebarContainer.load(new URL(Potree.scriptPath + "/sidebar.html").href, () => { sidebarContainer.css("width", "300px"); sidebarContainer.css("height", "100%"); 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"); let imgMapToggle = document.createElement("img"); imgMapToggle.src = new URL(Potree.resourcePath + "/icons/map_icon.png").href; imgMapToggle.style.display = "none"; imgMapToggle.onclick = e => {this.toggleMap()}; imgMapToggle.id = "potree_map_toggle"; viewer.renderArea.insertBefore(imgMapToggle, viewer.renderArea.children[0]); viewer.renderArea.insertBefore(imgMenuToggle, viewer.renderArea.children[0]); this.mapView = new Potree.MapView(this); this.mapView.init(); i18n.init({ lng: 'en', resGetPath: Potree.resourcePath + '/lang/__lng__/__ns__.json', preload: ['en', 'fr', 'de', 'jp'], getAsync: true, debug: false }, function(t) { // Start translation once everything is loaded $("body").i18n(); }); $(function() { initSidebar(); }); let elProfile = $('