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

fix: apply clipping planes on newly loaded point clouds #3433

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion viewer/packages/pointclouds/src/PointCloudManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class PointCloudManager {
private readonly _loadingStateHandler: PointCloudLoadingStateHandler;
private readonly _potreeInstance: Potree;
private readonly _pointCloudNodes: PointCloudNode[] = [];
private _globalClippingPlanes: THREE.Plane[] = [];

private readonly _cameraSubject: Subject<THREE.PerspectiveCamera> = new Subject();
private readonly _modelSubject: Subject<{ modelIdentifier: ModelIdentifier; operation: 'add' | 'remove' }> =
Expand Down Expand Up @@ -94,6 +95,7 @@ export class PointCloudManager {
}

set clippingPlanes(planes: THREE.Plane[]) {
this._globalClippingPlanes = planes;
this._pointCloudNodes.forEach(node => node.octree.setGlobalClippingPlane(planes));
this.requestRedraw();
}
Expand Down Expand Up @@ -131,7 +133,10 @@ export class PointCloudManager {
this._loadingStateHandler.onModelAdded();

this._modelSubject.next({ modelIdentifier, operation: 'add' });
this._materialManager.initializeClippingPlanesForPointCloud(modelIdentifier.revealInternalId);
this._materialManager.initializeClippingPlanesForPointCloud(
modelIdentifier.revealInternalId,
this._globalClippingPlanes
);

return pointCloudNode;
}
Expand Down
7 changes: 4 additions & 3 deletions viewer/packages/rendering/src/PointCloudMaterialManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import { PointCloudObjectIdMaps } from './pointcloud-rendering/PointCloudObjectIdMaps';
import { PointCloudMaterial } from './pointcloud-rendering';
import { PointCloudMaterialParameters } from './render-passes/types';
import { Plane } from 'three';

export class PointCloudMaterialManager {
private readonly _modelsMaterialsMap: Map<symbol, PointCloudMaterial> = new Map();
Expand Down Expand Up @@ -38,16 +39,16 @@ export class PointCloudMaterialManager {
return material;
}

initializeClippingPlanesForPointCloud(modelIdentifier: symbol): void {
initializeClippingPlanesForPointCloud(modelIdentifier: symbol, clippingPlanes: Plane[]): void {
const material = this.getModelMaterial(modelIdentifier);

material.clipping = true;
material.clipIntersection = false;
material.clippingPlanes = [];
material.clippingPlanes = [...clippingPlanes];

material.defines = {
...material.defines,
NUM_CLIPPING_PLANES: 0,
NUM_CLIPPING_PLANES: clippingPlanes.length,
UNION_CLIPPING_PLANES: 0
};
}
Expand Down
Loading