basic clip volumes
This commit is contained in:
parent
fd6f71ba02
commit
1f49ab01a4
7
TODO.txt
7
TODO.txt
@ -7,6 +7,9 @@ TODO orthographic cameras:
|
||||
|
||||
TODO clipping:
|
||||
|
||||
- move clipbox to clipper, remove from measurements
|
||||
- polygon clipping (define polygon in screenspace)
|
||||
- profile clipping
|
||||
- profile clipping
|
||||
- resize after 1st click
|
||||
- x, y, z planes
|
||||
- do clipping (shader)
|
||||
- properties
|
||||
@ -6,44 +6,13 @@ Potree.ClipVolume = class extends THREE.Object3D{
|
||||
|
||||
this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1;
|
||||
|
||||
this.name = "volume_" + this.constructor.counter;
|
||||
|
||||
this._clip = args.clip || false;
|
||||
this._modifiable = args.modifiable || true;
|
||||
|
||||
this.name = "clip_volume_" + this.constructor.counter;
|
||||
|
||||
let boxGeometry = new THREE.BoxGeometry(1, 1, 1);
|
||||
boxGeometry.computeBoundingBox();
|
||||
|
||||
let boxFrameGeometry = new THREE.Geometry();
|
||||
{
|
||||
let l = 0.1;
|
||||
|
||||
// corner vertices
|
||||
let v = [
|
||||
[-0.5, -0.5, -0.5],
|
||||
[-0.5, -0.5, +0.5],
|
||||
[-0.5, +0.5, -0.5],
|
||||
[-0.5, +0.5, +0.5],
|
||||
[+0.5, -0.5, -0.5],
|
||||
[+0.5, -0.5, +0.5],
|
||||
[+0.5, +0.5, -0.5],
|
||||
[+0.5, +0.5, +0.5]
|
||||
];
|
||||
//
|
||||
//// create a cross at each corner with cross length l
|
||||
//for(let b of v){
|
||||
//
|
||||
// let b1 = [ b[0] - l * Math.sign(b[0]), b[1], b[2] ];
|
||||
// let b2 = [ b[0], b[1] - l * Math.sign(b[1]), b[2] ];
|
||||
// let b3 = [ b[0], b[1], b[2] - l * Math.sign(b[2]) ];
|
||||
//
|
||||
// // create the 3 lines that a cross consists of
|
||||
// for(let d of [b, b1, b, b2, b, b3]){
|
||||
// boxFrameGeometry.vertices.push(new THREE.Vector3().fromArray(d));
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
{
|
||||
// bottom
|
||||
boxFrameGeometry.vertices.push(new THREE.Vector3(-0.5, -0.5, 0.5));
|
||||
boxFrameGeometry.vertices.push(new THREE.Vector3(0.5, -0.5, 0.5));
|
||||
@ -89,7 +58,7 @@ Potree.ClipVolume = class extends THREE.Object3D{
|
||||
//this.frame.mode = THREE.Lines;
|
||||
this.add(this.frame);
|
||||
|
||||
this.label = new Potree.TextSprite("0");
|
||||
/*this.label = new Potree.TextSprite("0");
|
||||
this.label.setBorderColor({r:0, g:255, b:0, a:0.0});
|
||||
this.label.setBackgroundColor({r:0, g:255, b:0, a:0.0});
|
||||
this.label.material.depthTest = false;
|
||||
@ -110,7 +79,7 @@ Potree.ClipVolume = class extends THREE.Object3D{
|
||||
this.label.children[ i ].updateMatrixWorld( true );
|
||||
}
|
||||
};
|
||||
|
||||
*/
|
||||
{ // event listeners
|
||||
this.addEventListener("select", e => {});
|
||||
this.addEventListener("deselect", e => {});
|
||||
@ -118,22 +87,13 @@ Potree.ClipVolume = class extends THREE.Object3D{
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
getVolume(){
|
||||
return Math.abs(this.scale.x * this.scale.y * this.scale.z);
|
||||
}
|
||||
|
||||
update(){
|
||||
this.boundingBox = this.box.geometry.boundingBox;
|
||||
this.boundingSphere = this.boundingBox.getBoundingSphere();
|
||||
|
||||
if(this._clip){
|
||||
this.box.visible = false;
|
||||
this.label.visible = false;
|
||||
}else{
|
||||
this.box.visible = true;
|
||||
this.label.visible = true;
|
||||
}
|
||||
this.box.visible = false;
|
||||
//this.label.visible = false;
|
||||
};
|
||||
|
||||
raycast(raycaster, intersects){
|
||||
@ -150,24 +110,4 @@ Potree.ClipVolume = class extends THREE.Object3D{
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
get clip(){
|
||||
return this._clip;
|
||||
}
|
||||
|
||||
set clip(value){
|
||||
this._clip = value;
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
get modifieable(){
|
||||
return this._modifiable;
|
||||
}
|
||||
|
||||
set modifieable(value){
|
||||
this._modifiable = value;
|
||||
|
||||
this.update();
|
||||
}
|
||||
};
|
||||
@ -3,19 +3,49 @@ Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{
|
||||
|
||||
constructor(viewer){
|
||||
super();
|
||||
|
||||
|
||||
this.viewer = viewer;
|
||||
|
||||
this.clipInside = false;
|
||||
|
||||
this.sceneVolume = new THREE.Scene();
|
||||
this.sceneVolume.name = "scene_clip_volume";
|
||||
|
||||
this.addEventListener("start_inserting_clipping_volume", e => {
|
||||
this.viewer.dispatchEvent({
|
||||
type: "cancel_insertions"
|
||||
});
|
||||
});
|
||||
|
||||
this.sceneVolume = new THREE.Scene();
|
||||
this.sceneVolume.name = "scene_clip_volume";
|
||||
this.viewer.inputHandler.registerInteractiveScene(this.sceneVolume);
|
||||
|
||||
this.onRemove = e => {
|
||||
this.sceneVolume.remove(e.volume);
|
||||
};
|
||||
|
||||
this.onAdd = e => {
|
||||
this.sceneVolume.add(e.volume);
|
||||
};
|
||||
|
||||
this.viewer.inputHandler.addEventListener("delete", e => {
|
||||
let volumes = e.selection.filter(e => (e instanceof Potree.ClipVolume));
|
||||
volumes.forEach(e => this.viewer.scene.removeClipVolume(e));
|
||||
});
|
||||
}
|
||||
|
||||
setScene(scene){
|
||||
if(this.scene === scene){
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.scene){
|
||||
this.scene.removeEventListeners("clip_volume_added", this.onAdd);
|
||||
this.scene.removeEventListeners("clip_volume_removed", this.onRemove);
|
||||
}
|
||||
|
||||
this.scene = scene;
|
||||
|
||||
this.scene.addEventListener("clip_volume_added", this.onAdd);
|
||||
this.scene.addEventListener("clip_volume_removed", this.onRemove);
|
||||
}
|
||||
|
||||
setClipInside(inside) {
|
||||
@ -28,6 +58,7 @@ Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{
|
||||
this.dispatchEvent({"type": "start_inserting_clipping_volume"});
|
||||
|
||||
this.viewer.scene.addClipVolume(clipVolume);
|
||||
//this.sceneVolume.add(clipVolume);
|
||||
|
||||
let cancel = {
|
||||
callback: null
|
||||
@ -45,10 +76,10 @@ Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{
|
||||
if(I){
|
||||
clipVolume.position.copy(I.location);
|
||||
|
||||
var wp = clipVolume.getWorldPosition().applyMatrix4(camera.matrixWorldInverse);
|
||||
/*var wp = clipVolume.getWorldPosition().applyMatrix4(camera.matrixWorldInverse);
|
||||
var pp = new THREE.Vector4(wp.x, wp.y, wp.z).applyMatrix4(camera.projectionMatrix);
|
||||
var w = Math.abs((wp.z / 10));
|
||||
clipVolume.scale.set(w,w,w);
|
||||
clipVolume.scale.set(w,w,w);*/
|
||||
}
|
||||
};
|
||||
|
||||
@ -71,6 +102,10 @@ Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{
|
||||
|
||||
this.viewer.inputHandler.startDragging(clipVolume);
|
||||
}
|
||||
|
||||
update() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Potree.ClippingTool.ClipMode = {
|
||||
|
||||
@ -1522,8 +1522,8 @@ function initClippingTool() {
|
||||
|
||||
let cvRemove = cvItem.find(".clipping_volume_action_remove");
|
||||
cvRemove.click(() => {viewer.scene.removeClipVolume(cv)});
|
||||
|
||||
cvList.append(cvItem);
|
||||
|
||||
});
|
||||
|
||||
viewer.scene.addEventListener("clip_volume_removed", function(event) {
|
||||
|
||||
@ -431,7 +431,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
this.renderer = null;
|
||||
|
||||
this.scene = null;
|
||||
this.clippingTool = new Potree.ClippingTool(this);
|
||||
this.clippingTool = null;
|
||||
|
||||
this.inputHandler = null;
|
||||
|
||||
@ -456,6 +456,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
this.measuringTool = new Potree.MeasuringTool(this);
|
||||
this.profileTool = new Potree.ProfileTool(this);
|
||||
this.volumeTool = new Potree.VolumeTool(this);
|
||||
this.clippingTool = new Potree.ClippingTool(this);
|
||||
this.transformationTool = new Potree.TransformationTool(this);
|
||||
|
||||
this.createControls();
|
||||
@ -463,6 +464,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
this.measuringTool.setScene(this.scene);
|
||||
this.profileTool.setScene(this.scene);
|
||||
this.volumeTool.setScene(this.scene);
|
||||
this.clippingTool.setScene(this.scene);
|
||||
|
||||
let onPointcloudAdded = (e) => {
|
||||
if(this.scene.pointclouds.length === 1){
|
||||
@ -477,6 +479,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
this.measuringTool.setScene(e.scene);
|
||||
this.profileTool.setScene(e.scene);
|
||||
this.volumeTool.setScene(e.scene);
|
||||
this.clippingTool.setScene(this.scene);
|
||||
|
||||
if(!e.scene.hasEventListener("pointcloud_added", onPointcloudAdded)){
|
||||
e.scene.addEventListener("pointcloud_added", onPointcloudAdded);
|
||||
@ -1849,6 +1852,10 @@ class PotreeRenderer{
|
||||
|
||||
viewer.volumeTool.update();
|
||||
viewer.renderer.render(viewer.volumeTool.sceneVolume, activeCam);
|
||||
|
||||
viewer.clippingTool.update();
|
||||
viewer.renderer.render(viewer.clippingTool.sceneVolume, activeCam);
|
||||
|
||||
viewer.renderer.render(viewer.controls.sceneControls, activeCam);
|
||||
|
||||
viewer.renderer.clearDepth();
|
||||
@ -1995,6 +2002,7 @@ class EDLRenderer{
|
||||
|
||||
|
||||
viewer.renderer.render(viewer.volumeTool.sceneVolume, camera, this.rtColor);
|
||||
viewer.renderer.render(viewer.clippingTool.sceneVolume, camera, this.rtColor);
|
||||
|
||||
{ // EDL OCCLUSION PASS
|
||||
this.edlMaterial.uniforms.screenWidth.value = width;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user