added clip modes for volumes and profiles
added clip mode disabled
This commit is contained in:
parent
2265fd401f
commit
84e7d819e8
@ -75,12 +75,6 @@ Potree.PointColorType = {
|
||||
COMPOSITE: 50
|
||||
};
|
||||
|
||||
/*Potree.ClipMode = {
|
||||
DISABLED: 0,
|
||||
CLIP_OUTSIDE: 1,
|
||||
HIGHLIGHT_INSIDE: 2
|
||||
};*/
|
||||
|
||||
Potree.TreeType = {
|
||||
OCTREE: 0,
|
||||
KDTREE: 1
|
||||
@ -106,7 +100,6 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
|
||||
this._pointColorType = Potree.PointColorType.RGB;
|
||||
this._useClipBox = false;
|
||||
this.numClipBoxes = 0;
|
||||
//this._clipMode = Potree.ClipMode.DISABLED;
|
||||
this._weighted = false;
|
||||
this._depthMap = null;
|
||||
this._gradient = Potree.Gradients.RAINBOW;
|
||||
@ -179,7 +172,7 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
|
||||
wSourceID: { type: "f", value: 0 },
|
||||
useOrthographicCamera: { type: "b", value: false },
|
||||
orthoRange: { type: "f", value: 10.0 },
|
||||
clipMode: { type: "i", value: 0}
|
||||
clipMode: { type: "i", value: 1}
|
||||
};
|
||||
|
||||
this.defaultAttributeValues.normal = [0,0,0];
|
||||
@ -280,14 +273,6 @@ Potree.PointCloudMaterial = class PointCloudMaterial extends THREE.RawShaderMate
|
||||
defines += "#define color_type_composite\n";
|
||||
}
|
||||
|
||||
/*if(this.clipMode === Potree.ClipMode.DISABLED){
|
||||
defines += "#define clip_disabled\n";
|
||||
}else if(this.clipMode === Potree.ClipMode.CLIP_OUTSIDE){
|
||||
defines += "#define clip_outside\n";
|
||||
}else if(this.clipMode === Potree.ClipMode.HIGHLIGHT_INSIDE){
|
||||
defines += "#define clip_highlight_inside\n";
|
||||
}*/
|
||||
|
||||
if(this._treeType === Potree.TreeType.OCTREE){
|
||||
defines += "#define tree_type_octree\n";
|
||||
}else if(this._treeType === Potree.TreeType.KDTREE){
|
||||
|
||||
@ -457,49 +457,48 @@ void main() {
|
||||
|
||||
gl_PointSize = pointSize;
|
||||
|
||||
//gl_Position = vec4(1000.0, 1000.0, 1000.0, 1.0);
|
||||
|
||||
|
||||
// ---------------------
|
||||
// CLIPPING
|
||||
// ---------------------
|
||||
|
||||
#if defined use_clip_box
|
||||
bool insideAny = false;
|
||||
for(int i = 0; i < max_clip_boxes; i++){
|
||||
if(i == int(clipBoxCount)){
|
||||
break;
|
||||
if(clipMode != 0) {
|
||||
bool insideAny = false;
|
||||
for(int i = 0; i < max_clip_boxes; i++){
|
||||
if(i == int(clipBoxCount)){
|
||||
break;
|
||||
}
|
||||
|
||||
vec4 clipPosition = clipBoxes[i] * modelMatrix * vec4( position, 1.0 );
|
||||
bool inside = -0.5 <= clipPosition.x && clipPosition.x <= 0.5;
|
||||
inside = inside && -0.5 <= clipPosition.y && clipPosition.y <= 0.5;
|
||||
inside = inside && -0.5 <= clipPosition.z && clipPosition.z <= 0.5;
|
||||
insideAny = insideAny || inside;
|
||||
}
|
||||
if(insideAny && clipMode == 2 || !insideAny && clipMode == 3) {
|
||||
gl_Position = vec4(1000.0, 1000.0, 1000.0, 1.0);
|
||||
} else if(clipMode == 1 && insideAny) {
|
||||
vColor.r += 0.5;
|
||||
}
|
||||
|
||||
vec4 clipPosition = clipBoxes[i] * modelMatrix * vec4( position, 1.0 );
|
||||
bool inside = -0.5 <= clipPosition.x && clipPosition.x <= 0.5;
|
||||
inside = inside && -0.5 <= clipPosition.y && clipPosition.y <= 0.5;
|
||||
inside = inside && -0.5 <= clipPosition.z && clipPosition.z <= 0.5;
|
||||
insideAny = insideAny || inside;
|
||||
}
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined use_clip_polygon
|
||||
bool polyInsideAny = false;
|
||||
for(int i = 0; i < max_clip_polygons; i++) {
|
||||
if(i == clipPolygonCount) {
|
||||
break;
|
||||
if(clipMode != 0) {
|
||||
bool polyInsideAny = false;
|
||||
for(int i = 0; i < max_clip_polygons; i++) {
|
||||
if(i == clipPolygonCount) {
|
||||
break;
|
||||
}
|
||||
|
||||
polyInsideAny = polyInsideAny || pointInClipPolygon(position, i);
|
||||
}
|
||||
if(polyInsideAny && clipMode == 2 || !polyInsideAny && clipMode == 3) {
|
||||
gl_Position = vec4(1000.0, 1000.0, 1000.0, 1.0);
|
||||
} else if(clipMode == 1 && polyInsideAny) {
|
||||
vColor.r += 0.5;
|
||||
}
|
||||
|
||||
polyInsideAny = polyInsideAny || pointInClipPolygon(position, i);
|
||||
}
|
||||
if(polyInsideAny && clipMode == 1 || !polyInsideAny && clipMode == 2) {
|
||||
gl_Position = vec4(1000.0, 1000.0, 1000.0, 1.0);
|
||||
} else if(clipMode == 0 && polyInsideAny) {
|
||||
vColor.r += 0.5;
|
||||
}
|
||||
#endif
|
||||
|
||||
//vColor = indices.rgb * 255.0;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
|
||||
|
||||
Potree.ClipMode = {
|
||||
HIGHLIGHT: 0,
|
||||
INSIDE: 1,
|
||||
OUTSIDE: 2
|
||||
DISABLED: 0,
|
||||
HIGHLIGHT: 1,
|
||||
INSIDE: 2,
|
||||
OUTSIDE: 3
|
||||
};
|
||||
|
||||
Potree.ClippingTool = class ClippingTool extends THREE.EventDispatcher{
|
||||
|
||||
@ -85,9 +85,10 @@
|
||||
<li>
|
||||
<label for="optClipMode" class="pv-select-label">Clip mode</label>
|
||||
<select id="optClipMode" name="optClipMode">
|
||||
<option value="0">Highlight</option>
|
||||
<option value="1">Inside</option>
|
||||
<option value="2">Outside</option>
|
||||
<option value="0">Disabled</option>
|
||||
<option value="1">Highlight</option>
|
||||
<option value="2">Inside</option>
|
||||
<option value="3">Outside</option>
|
||||
</select>
|
||||
</li>
|
||||
<div id="clipping_tools_container">
|
||||
|
||||
@ -1759,7 +1759,7 @@ function initClippingTool() {
|
||||
$("#clipping_volumes_container").hide();
|
||||
|
||||
$("#optClipMode").selectmenu();
|
||||
$("#optClipMode").val(0).selectmenu("refresh");
|
||||
$("#optClipMode").val(1).selectmenu("refresh");
|
||||
$("#optClipMode").selectmenu({
|
||||
change: function(event, ui){
|
||||
viewer.clippingTool.setClipMode(parseInt(ui.item.value));
|
||||
|
||||
@ -1634,7 +1634,8 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
this.scene.cameraO.rotation.z = this.scene.view.yaw;
|
||||
}
|
||||
|
||||
{ // update clip boxes
|
||||
{ // update clip boxes
|
||||
// ordinary clip boxes (clip planes)
|
||||
let boxes = this.scene.clipVolumes;
|
||||
|
||||
let clipBoxes = boxes.map( box => {
|
||||
@ -1645,11 +1646,26 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{
|
||||
return {inverse: boxInverse, position: boxPosition};
|
||||
});
|
||||
|
||||
// extraordinary clip boxes (volume, profile)
|
||||
boxes = this.scene.volumes.filter(v => v.clip);
|
||||
for(let profile of this.scene.profiles){
|
||||
boxes = boxes.concat(profile.boxes);
|
||||
}
|
||||
|
||||
clipBoxes = clipBoxes.concat(boxes.map( box => {
|
||||
box.updateMatrixWorld();
|
||||
let boxInverse = new THREE.Matrix4().getInverse(box.matrixWorld);
|
||||
let boxPosition = box.getWorldPosition();
|
||||
return {inverse: boxInverse, position: boxPosition};
|
||||
}));
|
||||
|
||||
// clip polygons
|
||||
let clipPolygons = this.scene.polygonClipVolumes.filter(vol => vol.initialized).map(vol => {
|
||||
let vp = vol.projMatrix.clone().multiply(vol.viewMatrix);
|
||||
return {polygon: vol.markersPosWorld, count: vol.markersPosWorld.length, view: vp};
|
||||
});
|
||||
|
||||
// set clip volumes in material
|
||||
for(let pointcloud of this.scene.pointclouds){
|
||||
pointcloud.material.setClipBoxes(clipBoxes);
|
||||
pointcloud.material.setClipPolygons(clipPolygons, this.clippingTool.maxPolygonVertices);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user