basic offsetting for clip planes
This commit is contained in:
parent
0b2daf86dd
commit
3bf5cda240
@ -4,13 +4,11 @@ Potree.ClipVolume = class extends THREE.Object3D{
|
||||
|
||||
constructor(axis){
|
||||
super();
|
||||
|
||||
this.axis = axis;
|
||||
|
||||
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;
|
||||
|
||||
if(axis != -1) {
|
||||
@ -101,7 +99,21 @@ 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?
|
||||
}
|
||||
|
||||
this.dispatchEvent({"type": "clip_volume_changed", "volume": this});
|
||||
};
|
||||
|
||||
update(){
|
||||
this.boundingBox = this.box.geometry.boundingBox;
|
||||
|
||||
@ -7,6 +7,7 @@ Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{
|
||||
this.viewer = viewer;
|
||||
|
||||
this.clipInside = false;
|
||||
this.clipOffset = 0.1;
|
||||
|
||||
this.addEventListener("start_inserting_clipping_volume", e => {
|
||||
this.viewer.dispatchEvent({
|
||||
@ -49,10 +50,19 @@ Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{
|
||||
}
|
||||
|
||||
setClipInside(inside) {
|
||||
if(this.clipInside == inside) return;
|
||||
|
||||
this.clipInside = inside;
|
||||
viewer.dispatchEvent({"type": "clipper.clipInside_changed", "viewer": viewer});
|
||||
viewer.dispatchEvent({"type": "clipper.clipInside_changed", "viewer": viewer, "inside": inside});
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
@ -1577,6 +1577,13 @@ function initClippingTool() {
|
||||
</tr>
|
||||
</table>
|
||||
</span>
|
||||
<br />
|
||||
<div class="clip_offset_container">
|
||||
<label for="${volume.name}_offset">Offset</label>
|
||||
<input type="text" id="${volume.name}_offset" name="${volume.name}_offset" value="0.1" />
|
||||
<button id="${volume.name}_neg_offset" class="clip_offset_negative"><</button>
|
||||
<button id="${volume.name}_pos_offset" class="clip_offset_positive">></button>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; margin-top: 12px">
|
||||
<span></span>
|
||||
@ -1587,19 +1594,38 @@ function initClippingTool() {
|
||||
</div>
|
||||
</span>
|
||||
`);
|
||||
|
||||
let clipOffsetInputs = cvItem.find(".clip_offset_container input");
|
||||
clipOffsetInputs.change(function(e) {
|
||||
viewer.clippingTool.setClipOffset(parseInt(e.target.value());
|
||||
});
|
||||
|
||||
let clipOffsetButtonNeg = cvItem.find(".clip_offset_container .clip_offset_negative");
|
||||
let clipOffsetButtonPos = cvItem.find(".clip_offset_container .clip_offset_positive");
|
||||
clipOffsetButtonNeg.click(function(e) {
|
||||
volume.offset(-viewer.clippingTool.clipOffset);
|
||||
});
|
||||
clipOffsetButtonPos.click(function(e) {
|
||||
volume.offset(viewer.clippingTool.clipOffset);
|
||||
});
|
||||
|
||||
let cvRemove = cvItem.find(".clipping_volume_action_remove");
|
||||
cvRemove.click(() => {viewer.scene.removeClipVolume(cv)});
|
||||
|
||||
return cvItem;
|
||||
};
|
||||
|
||||
|
||||
cv.addEventListener("clip_volume_changed", function(event) {
|
||||
let cv = event.volume;
|
||||
let prevCVItem = $("span#" + cv.name);
|
||||
prevCVItem.after(createCVitem(cv));
|
||||
prevCVItem.remove();
|
||||
});
|
||||
|
||||
|
||||
viewer.addEventListener("clipper.clipOffset_changed", function(event){
|
||||
$(".clip_offset_container input").val(viewer.clippingTool.clipOffset);
|
||||
});
|
||||
|
||||
cvList.append(createCVitem(cv));
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user