diff --git a/TODO.txt b/TODO.txt index 47dac434..8512e910 100644 --- a/TODO.txt +++ b/TODO.txt @@ -10,4 +10,8 @@ TODO clipping: - polygon clipping (define polygon in screenspace) - profile clipping - resize after 1st click - - properties \ No newline at end of file + - visualize local coordinate system of plane + - properties + + width/length/thickness spinner + + translate locally/globally + + rotate locally/globally \ No newline at end of file diff --git a/src/PointCloudOctree.js b/src/PointCloudOctree.js index efd7d9c9..bfddce9b 100644 --- a/src/PointCloudOctree.js +++ b/src/PointCloudOctree.js @@ -689,7 +689,7 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ pickMaterial.maxSize = this.material.maxSize; pickMaterial.classification = this.material.classification; - if(pickOutsideClipRegion){ + /*if(pickOutsideClipRegion){ pickMaterial.clipMode = Potree.ClipMode.DISABLED; }else{ pickMaterial.clipMode = this.material.clipMode; @@ -698,7 +698,7 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ }else{ pickMaterial.setClipBoxes([]); } - } + }*/ this.updateMaterial(pickMaterial, nodes, camera, renderer); diff --git a/src/arena4d/PointCloudArena4D.js b/src/arena4d/PointCloudArena4D.js index 071a5b0c..2e82618c 100644 --- a/src/arena4d/PointCloudArena4D.js +++ b/src/arena4d/PointCloudArena4D.js @@ -398,7 +398,7 @@ Potree.PointCloudArena4D.prototype.pick = function(renderer, camera, ray, params pickMaterial.maxSize = this.material.maxSize; pickMaterial.classification = this.material.classification; - if(pickOutsideClipRegion){ + /*if(pickOutsideClipRegion){ pickMaterial.clipMode = Potree.ClipMode.DISABLED; }else{ pickMaterial.clipMode = this.material.clipMode; @@ -407,7 +407,7 @@ Potree.PointCloudArena4D.prototype.pick = function(renderer, camera, ray, params }else{ pickMaterial.setClipBoxes([]); } - } + }*/ this.updateMaterial(pickMaterial, nodes, camera, renderer); diff --git a/src/materials/PointCloudMaterial.js b/src/materials/PointCloudMaterial.js index 612e8f21..c71182f6 100644 --- a/src/materials/PointCloudMaterial.js +++ b/src/materials/PointCloudMaterial.js @@ -75,11 +75,11 @@ Potree.PointColorType = { COMPOSITE: 50 }; -Potree.ClipMode = { +/*Potree.ClipMode = { DISABLED: 0, CLIP_OUTSIDE: 1, HIGHLIGHT_INSIDE: 2 -}; +};*/ Potree.TreeType = { OCTREE: 0, @@ -171,7 +171,7 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate wSourceID: { type: "f", value: 0 }, useOrthographicCamera: { type: "b", value: false }, orthoRange: { type: "f", value: 10.0 }, - clipInside: { type: "b", value: false} + clipMode: { type: "i", value: 0} }; this.defaultAttributeValues.normal = [0,0,0]; @@ -396,12 +396,12 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate } - get clipInside() { - return this.uniforms.clipInside.value; + get clipMode() { + return this.uniforms.clipMode.value; } - set clipInside(inside) { - this.uniforms.clipInside.value = inside; + set clipMode(mode) { + this.uniforms.clipMode.value = mode; } diff --git a/src/materials/shaders/pointcloud.vs b/src/materials/shaders/pointcloud.vs index 26e34c74..e2306255 100644 --- a/src/materials/shaders/pointcloud.vs +++ b/src/materials/shaders/pointcloud.vs @@ -33,7 +33,7 @@ uniform float near; uniform float far; uniform float orthoRange; -uniform bool clipInside; +uniform int clipMode; #if defined use_clip_box uniform mat4 clipBoxes[max_clip_boxes]; #endif @@ -424,8 +424,10 @@ void main() { inside = inside && -0.5 <= clipPosition.z && clipPosition.z <= 0.5; insideAny = insideAny || inside; } - if(insideAny && clipInside || !insideAny && !clipInside) { + if(insideAny && clipMode == 1 || !insideAny && clipMode == 2) { gl_Position = vec4(1000.0, 1000.0, 1000.0, 1.0); + } else if(clipMode == 0 && insideAny) { + vColor.r += 0.5; } /*if(!insideAny){ diff --git a/src/utils/ClipVolume.js b/src/utils/ClipVolume.js index 8eefcc57..229cbb8f 100644 --- a/src/utils/ClipVolume.js +++ b/src/utils/ClipVolume.js @@ -2,24 +2,24 @@ Potree.ClipVolume = class extends THREE.Object3D{ - constructor(axis){ + constructor(args){ super(); this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1; this.name = "clip_volume_" + this.constructor.counter; - this.axis = axis; - this.volWidth = 0.1; + this.clipOffset = 0.001; + this.clipRotOffset = 1; - if(axis != -1) { - this.scale.set(1, 1, 1); - if(axis == Potree.ClipVolume.Axis.X) - this.scale.x = this.volWidth; - else if(axis == Potree.ClipVolume.Axis.Y) - this.scale.y = this.volWidth; - else if(axis == Potree.ClipVolume.Axis.Z) - this.scale.z = this.volWidth; - } + this.scale.z = 0.1; + + let alpha = args.alpha || 0; + let beta = args.beta || 0; + let gamma = args.gamma || 0; + + this.rotation.x = alpha; + this.rotation.y = beta; + this.rotation.z = gamma; let boxGeometry = new THREE.BoxGeometry(1, 1, 1); boxGeometry.computeBoundingBox(); @@ -101,20 +101,78 @@ Potree.ClipVolume = class extends THREE.Object3D{ this.update(); }; - offset(value) { - if(this.axis == Potree.ClipVolume.Axis.X) { - this.position.x = this.position.x + value; - } else if(this.axis == Potree.ClipVolume.Axis.Y) { - this.position.y = this.position.y + value; - } else if(this.axis == Potree.ClipVolume.Axis.Z) { - this.position.z = this.position.z + value; - } else { - // TODO, offset box? - } + setClipOffset(offset) { + if(this.clipOffset == offset) return; + + this.clipOffset = offset; + this.dispatchEvent({"type": "clip_volume_changed", "viewer": viewer, "volume": this}); + } + + setClipRotOffset(offset) { + if(this.clipRotOffset == offset) return; + + this.clipRotOffset = offset; + this.dispatchEvent({"type": "clip_volume_changed", "viewer": viewer, "volume": this}); + } + + offset(args) { + let cs = args.cs || null; + let axis = args.axis || null; + let dir = args.dir || null; + + if(!cs || !axis || !dir) return; + + if(axis == "x") { + if(cs == "local") { + + } else if(cs == "global") { + this.position.x = this.position.x + dir * this.clipOffset; + } + }else if(axis == "y") { + if(cs == "local") { + + } else if(cs == "global") { + this.position.y = this.position.y + dir * this.clipOffset; + } + }else if(axis == "z") { + if(cs == "local") { + + } else if(cs == "global") { + this.position.z = this.position.z + dir * this.clipOffset; + } + } + this.dispatchEvent({"type": "clip_volume_changed", "viewer": viewer, "volume": this}); + } + + rotate(args) { + let cs = args.cs || null; + let axis = args.axis || null; + let dir = args.dir || null; + + if(!cs || !axis || !dir) return; + + if(axis == "x") { + if(cs == "local") { + + } else if(cs == "global") { + this.rotation.x = this.rotation.x + dir * this.clipRotOffset * Math.PI/180; + } + }else if(axis == "y") { + if(cs == "local") { + + } else if(cs == "global") { + this.rotation.y = this.rotation.y + dir * this.clipRotOffset * Math.PI/180; + } + }else if(axis == "z") { + if(cs == "local") { + + } else if(cs == "global") { + this.rotation.z = this.rotation.z + dir * this.clipRotOffset * Math.PI/180; + } + } + this.dispatchEvent({"type": "clip_volume_changed", "viewer": viewer, "volume": this}); + } - this.dispatchEvent({"type": "clip_volume_changed", "volume": this}); - }; - update(){ this.boundingBox = this.box.geometry.boundingBox; this.boundingSphere = this.boundingBox.getBoundingSphere(); @@ -138,9 +196,3 @@ Potree.ClipVolume = class extends THREE.Object3D{ } }; }; - -Potree.ClipVolume.Axis = { - X: 0, - Y: 1, - Z: 2 -}; \ No newline at end of file diff --git a/src/utils/ClippingTool.js b/src/utils/ClippingTool.js index 604a4c38..4965e77a 100644 --- a/src/utils/ClippingTool.js +++ b/src/utils/ClippingTool.js @@ -1,4 +1,11 @@ + +Potree.ClipMode = { + HIGHLIGHT: 0, + INSIDE: 1, + OUTSIDE: 2 +}; + Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{ constructor(viewer){ @@ -6,8 +13,7 @@ Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{ this.viewer = viewer; - this.clipInside = false; - this.clipOffset = 0.1; + this.clipMode = Potree.ClipMode.HIGHLIGHT; this.addEventListener("start_inserting_clipping_volume", e => { this.viewer.dispatchEvent({ @@ -49,25 +55,15 @@ Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{ this.scene.addEventListener("clip_volume_removed", this.onRemove); } - setClipInside(inside) { - if(this.clipInside == inside) return; + setClipMode(mode) { + if(this.clipMode == mode) return; - this.clipInside = inside; - viewer.dispatchEvent({"type": "clipper.clipInside_changed", "viewer": viewer, "inside": inside}); + this.clipMode = mode; + viewer.dispatchEvent({"type": "clipper.clipMode_changed", "viewer": viewer, "mode": mode}); } - setClipOffset(offset) { - if(this.clipOffset == offset) return; - - this.clipOffset = offset; - viewer.dispatchEvent({"type": "clipper.clipOffset_changed", "viewer": viewer, "offset": offset}); - } - - startInsertion(args = {}) { - let axis = -1; - if(args.axis + 1) - axis = args.axis; - let clipVolume = new Potree.ClipVolume(axis); + startInsertion(args = {}) { + let clipVolume = new Potree.ClipVolume(args); this.dispatchEvent({"type": "start_inserting_clipping_volume"}); @@ -164,11 +160,4 @@ Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{ update() { } -}; - -Potree.ClippingTool.ClipMode = { - NONE: 0, - BOX: 1, - POLYGON: 2, - PROFILE: 3 }; \ No newline at end of file diff --git a/src/viewer/potree.css b/src/viewer/potree.css index a598e27c..16746194 100644 --- a/src/viewer/potree.css +++ b/src/viewer/potree.css @@ -769,3 +769,16 @@ label:hover{ +/* Clipping sidebar */ +.cv_btn_offset { + width: 20px; + margin: 0px 5px; +} + +.cv_btn_offset_incr { + +} + +.cv_btn_offset_decr { + +} \ No newline at end of file diff --git a/src/viewer/sidebar.html b/src/viewer/sidebar.html index 242876f9..e9c2d0ad 100644 --- a/src/viewer/sidebar.html +++ b/src/viewer/sidebar.html @@ -111,10 +111,11 @@