How to freeze the camera

Hello,

I need to know if it’s possible to freeze the camera manually ? and how.

I have a function who rotate around a target to take screenshots, I want to freeze the camera before those operations to avoid seeing the camera make all the rotations, make these movements transparent.

Hello @VerandaLouis,
Could you maybe share some of your code to better understand what you’re doing and what you’re trying to achieve?
From what you wrote I wonder if you could do like:

  1. move camera to precise position A
  2. take a snapshot
  3. move camera to precise position B
  4. take a snapshot
    … etc.

Do you have a PG. I don’t really understand this part

Should I understand that you can continue moving the camera while taking the screenshot? Why?
Else, I believe simply detaching the controls on SS capture and re-attaching after save/commit would have done the trick.

1 Like

@neu5

From what you wrote I wonder if you could do like:

  1. move camera to precise position A
  2. take a snapshot
  3. move camera to precise position B
  4. take a snapshot
    … etc.

Yes I already do this, I want to add :

    1. Freeze the camera
  • end. Unfreese the camera

@mawa

Should I understand that you can continue moving the camera while taking the screenshot? Why?
Else, I believe simply detaching the controls on SS capture and re-attaching after save/commit would have done the trick.

No no I just need to visually freeze the camera to prevent the user from seeing the camera move between each screenshot.
I tried the solution you suggested, without success.

You will maybe see what I mean with the following PG :

Okey, I think I understand what you need.
I think maybe you can use second camera?
One for the user and second one just for taking the screenshots?

2 Likes

Actually, ArcRotate camera doesn’t change its position in your code, only alpha and beta values. The camera position is always the same.
I am still wondering what you are trying to achieve…

@labris If it’s what I think it is - open @VerandaLouis PG and press “space”.
You will see the box spinning for a while - taking screenshots process.
I think @VerandaLouis wants to prevent the user seeing that.

1 Like

Yes that’s it

1 Like

I think maybe you can use second camera?
One for the user and second one just for taking the screenshots?

I correct the PG with this solution and it work pretty well, It just look special to have to reattach the active camera each time, any idea for improvement?

1 Like

You can simplify your function to take alpha and beta values from array in a loop.

Do you always have fixed positions of the screenshots?
I tried something like

but it looks like you need to have those
scene.activeCamera = camera;
I’m not sure if it’s not a bug that the BABYLON.Tools.CreateScreenshot is not cleaning after itself.

Hey, as @labris said you can simplify your screenshot taking function - put variables in the array and loop over them.
I looked into the source code

and it looks like the cameras are switching properly.
I’m not sure about this line:

In this case we “refresh” the provided camera (eg. screenshotCamera) and not scene’s active camera (eg. camera)
Someone from the BabylonJS team is needed here :slight_smile: (it would be nice to have one mention like @ _ BabylonJSTeam ? because I don’t want to mention by name)

Summoning at least one: @RaananW :wink:

That’s interesting. It seems like the previous camera is not being assigned back. I also think you are right about this line, but will have to investigate and make sure it works as expected.

1 Like

You can @ moderators, but I don’t think that’s so useful as not everyone on the team checks the forum daily (it’s mostly me, Raanan and Seb and the rest pops in when needed)… aaand I just figured out you can mention groups, so I created @GeneralQuestions for this :slight_smile:

2 Likes

PR up to address that: Don’t alter the scene’s active cameras in the middle of taking a scre… by carolhmj · Pull Request #13040 · BabylonJS/Babylon.js (github.com)

By looking at the code I can’t tell if it’s doing what it should be doing :slight_smile:
But maybe there a way to check if in this case everything work fine? Is it possible to run some PG with custom build (like this PR)?

You should be able to access the Playground with this version of the code by accessing Babylon.js Playground (babylonjs.com) (it’s not available now as I think it needs to run the build)

1 Like

Hey, I didn’t manage to check it before and it’s not available anymore under the link you have had provided.
When we can check the PG with the new code? Or is there any other way to check it now?

Oh sorry, it’s not available at the moment as we found a case where it wouldn’t work, so we’ll have to update the code :sweat_smile:

1 Like

Hi,

I’ve upgraded my function by using a loop, i had already tried this with a forEach but it caused asynchrony problems, i newly “discover”/understood the for of loop that is a better solution with async functions.

Note : the box on the PG show strange things when space is pressed (launch the function), did i miss something ?