targetCamera Bug

“I used the code new TargetCamera('TargetCamera', Vector3.Zero(), editor.scene!) to create a target camera, but when I saved it as a .babylon file and loaded it, it turned into a free camera.”

Could you share a repro in the playground ? that would help understanding the issue.

then I use “SceneLoader.AppendAsync” to load .babylon file,I found that the ‘targetCamera’ I saved has turned into a ‘freeCamera’ (using getClassName), and it can be moved using the arrow keys, with the view also not fixed, shifting with mouse movements

If I’m understanding the code correctly here, the reason why this is happening is because there is no explicit function set up for the TargetCamera when being imported (via a .babylon file). This means that the Camera will be imported as a UniversalCamera by default. The fix here would be to add a Node constructor function to address this.

Fix is in PR: TargetCamera: Add Node Constructor code for TargetCamera by PolygonalSun · Pull Request #14827 · BabylonJS/Babylon.js (github.com)

Fix is merged