Camera.update() es6 treeShaking?

Hello everyone,

my question is short but I can’t figure it out on my own:

What dependency do I have to import to be able to use camera.update()?

Thank you very much :slight_smile:

That depends on the camera you are using, but if you are importing the camera you actually want to use it will be imported automatically.

Do you have any issues with tree shaking and the camera class?

I am using arcRotateCamera:

import { ArcRotateCamera } from “@babylonjs/core/Cameras/arcRotateCamera”

I try to render the scene on demand. To do that I have to call camera.update() in the render loop to check if there are new inputs. But this doesn’t work if I just import the camera. If I import the whole package it works fine:

import { ArcRotateCamera } from “@babylonjs/core”

First one would be cleaner, of course :slight_smile:

What exactly doesn’t work? does it fail silently? does it show any error in the console? can you reproduce this somehow and provide a code example?

Since I only want to render the scene if the user made some inputs I call camera.update() in renderLoop:

If I import the camera via the full path “@babylonjs/core/Cameras/arcRotateCamera” I can’t interact with the scene. So I assume that camera.update() is the problem here. I noticed that it works fine if I import gamepadManager in addition to the camera:

import { GamepadManager } from “@babylonjs/core/Gamepads/gamepadManager”

I don’t know why that works.

The console doesn’t show any errors.

Is that the only import in your app?

Sounds like this should just work, @samevision, do you have a repro we could look at ?

1 Like

No I import a lot of modules but all by their specific path. Everything works fine except for camera.update().

How would you recommend to create a repro with treeshaking? I will try so set it up on git and will post it here later.

Nothing special is happening in camera.update. And if there was something missing you should have seen a warning in the console. Needs to be debugged…

I am not sure how you build your project, but that would be the best way :slight_smile: build your project with sourcemaps, or provide the repository if possible. that would help a lot.

1 Like

Sharing the repo on Github will be by far the fastest way to troubleshoot for us