Closed Oeffner closed 2 years ago
I don't think there's anything like that currently, though happy to review/merge a PR that adds the appropriate signal! One possible workaround is to use absolute values for clip planes?
https://github.com/nglviewer/ngl/blob/master/examples/scripts/test/clipping-absolute.js
Thanks @fredludlow for your reply. I don't really have a pull request but I did find a workaround that does the job for me. What I'm doing is to call autoView(time) for the component I want to display. Even if I set it to a certain time it may take a while before that function starts its background work if the data represented by the component is large. So I made a workaround which can be outlined as follows:
` async function SetAutoview(mycomponent, time) { if (mycomponent == null) return;
mycomponent.autoView(time);
while (true) { if (stage.viewer.camera.position.z == mycomponent.getZoom()) { onFinishedSetAutoView(); return; } await sleep(200); } }; ` getZoom() defines what stage.viewer.camera.position.z eventually is gonna be. Once that has been achieved by autoView(time) The onFinishedSetAutoView() function which I have define elsewhere is then triggered and thus works as a reliable signal I believe.
Thanks for the example - still might be nice to do it with an explicit API at some point too :)
I am displaying NGL components which occasionally can be take some time to load and render. I note from https://github.com/nglviewer/ngl/issues/657 that stage.tasks.onZeroOnce(callback) will fire once the model has been loaded. Is there a similar signal for when the model or component has actually been rendered? I would like to calculate clip planes based on camera.position. But camera position is not valid until the model has been rendered. So a signal fired to that effect would be very useful.