Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipping in world space #113

Open
berry4u opened this issue May 24, 2022 · 4 comments
Open

Clipping in world space #113

berry4u opened this issue May 24, 2022 · 4 comments

Comments

@berry4u
Copy link

berry4u commented May 24, 2022

can anyone give hints about clipping in world space by using IClipBox?
There's no code sample about it.

Thanks a lot

@fahadm
Copy link
Collaborator

fahadm commented Jun 3, 2022

I mean the IClipbox basically just works in world space, just populate the scale (diagonal of your matrix) and the position of your matrix (that is passed to the IClipBox), the position of the matrix will represent the position of the clip box and scale will determine its size in x,y and z. (note the Clipbox will have its centered around the matrix position)

@berry4u
Copy link
Author

berry4u commented Jul 17, 2022

Thank you for answering.
Despite making many attempts I could not get clipping to work.
Could you please post a code snippet?

@berry4u
Copy link
Author

berry4u commented Aug 15, 2022

OK, now it works.
However, I noticed that an important clipmode is missing such as CLIP_INSIDE (very useful when overlapping point clouds with other models) despite being proposed here (https://github.com/pnext/three-loader/pull/43/files/a528b88ea4ae1100e389b2553075704b57022337) along with other improvements.
is there any advancement on it?

@mandre96
Copy link

mandre96 commented Sep 9, 2023

I Wasn't able to make ClipBox Work.

When I activate it it clips all the point cloud, even tho I created a box geometry and assign it correctly to the IClipBox.

`
//Creates Geometry
const boxGeometry = new THREE.BoxGeometry(1, 1, 1);
boxGeometry.computeBoundingBox();

    const boxFrameGeometry = this.generateBoxFrameGeometry();
    const planeFrameGeometry = this.generatePlaneFrameGeometry();
  
    this._material = new THREE.MeshBasicMaterial( {
		color: 0x00ff00, 
		transparent: true, 
		opacity: 0.3,
		depthTest: true, 
		depthWrite: false} );
    
    //Box Mesh
    this._box = new THREE.Mesh(boxGeometry, this._material);
    this._box.geometry.computeBoundingBox();
    this.add(this._box);

    //Box Frame
    this._frame = new THREE.LineSegments( boxFrameGeometry, new THREE.LineBasicMaterial({color: 0x000000}));
	this.add(this._frame);
	this._planeFrame = new THREE.LineSegments( planeFrameGeometry, new THREE.LineBasicMaterial({color: 0xff0000}));
	this.add(this._planeFrame);

	// set default thickness
	this.setScaleZ(0.1);
    
    const mat = this._box.matrix.clone();
    const inverse = mat.invert();
    
    this._clipBox = {box: this._box.geometry.boundingBox!, inverse:inverse , matrix:this._box.matrix, position: this.position};
    }

public update(): void {
this._box.geometry.computeBoundingBox();
const mat = this._box.matrix.clone();
const inverse = mat.invert();

    //updates clipbox
    this._clipBox.box = this._box.geometry.boundingBox!;
    this._clipBox.inverse = inverse;
	this._clipBox.position = this.position;

}

`

In my Large Clouds Manager:

`
public setClipMode(value:ClipMode)
{
for (let index = 0; index < this._largeScaleClouds.length; index++) {
const potreeCloud = this._largeScaleClouds[index];
potreeCloud.material.clipMode = value
}
}

/**

  • Sets clip boxes for all scene
  • @param clipBoxes
    */
    public setClipBoxes(clipBoxes:IClipBox[]){
    for (let index = 0; index < this._largeScaleClouds.length; index++) {
    const potreeCloud = this._largeScaleClouds[index];
    potreeCloud.material.setClipBoxes(clipBoxes);
    }
    }

`

Highlight inside:

https://freeimage.host/i/J9vqlUX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants