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

Multiple cameras and renderers per single scene #51

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

geoff-harper
Copy link

@geoff-harper geoff-harper commented Nov 26, 2019

I've put together a fairly quick and primitive implementation of re-using the same point cloud scene in multiple WebGL contexts. Without this change, you have to designate a "key camera" that will determine the point load/unload and the other camera(s) just has to live with what it gets. I took the stance that all passed cameras need to be of the same type for simplicity sake but this could be accounted for. Also that cameras and renderers are 1:1 since that fits my use case. Not sure if this is too different and should be kept as a fork or not so I didn't polish it much

Some things that would need to be improved still are the updateMaterial function that's looking for perspective frustum params, plucking the minDistance and maxScreenPixelRadius efficiently, making a real example, and cleaning up function arguments.

src/potree.ts Outdated
camera: Camera,
renderer: WebGLRenderer,
cameras: Camera[],
renderers: WebGLRenderer[],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho, this should be kept backwards-compatible. We could do something like

cameras = Array.isArray(cameras) ? cameras : [cameras];

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The typing could also be set to

OrthographicCamera | PerspectiveCamera | OrthographicCamera[] | PerspectiveCamera[]

src/potree.ts Outdated
priorityQueue: BinaryHeap<QueueItem>;
} => {
const frustums: Frustum[] = [];
const cameraPositions = [];
const frustums: Frustum[][] = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit worried about the garbage due to creating all these arrays each frame.

@geoff-harper
Copy link
Author

Sorry I typically have prettier fire automatically on commit so I might have left some badly formatted or semicolon-less lines in there

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

Successfully merging this pull request may close these issues.

2 participants