Skip to content

Conversation

kv-bh
Copy link
Contributor

@kv-bh kv-bh commented Sep 19, 2025

This change fixes some issues with the inspector due to its gizmoManager being treated as an any type.

Issue Description

To see the issue this is attempting to address, go to https://sandbox.babylonjs.com/ and load a model, then open the inspector and click this button:
image

A message will appear on screen: Script error. Check the developer console. (nothing appears in console).

The actual issue stems from this error:

sceneTreeItemComponent.tsx:185  Uncaught TypeError: Cannot read properties of null (reading 'gizmoManager')
// or
sceneTreeItemComponent.tsx:187  Uncaught TypeError: Cannot set properties of null (setting 'coordinatesMode')

Which leads to here:

const manager: GizmoManager = scene.reservedDataStore.gizmoManager;
// flip coordinate system
manager.coordinatesMode = this.state.isInWorldCoodinatesMode ? GizmoCoordinatesMode.Local : GizmoCoordinatesMode.World;

The issue being that this assumes that this value has been initialized, which in this case it has not been.

Change Description

This change makes all access to the Inspector's gizmoManager use one of two helper functions: one for getting and optionally creating, and one for disposing. This abstracts the type-unsafety of the any types to one file, rather than spreading them across ~10 different locations.

This code should not make any changes to when the inspector creates the gizmoManager, as the code path to create it should only be activated in the place where it was originally created.

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 19, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 19, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 19, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 19, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 19, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 22, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 22, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Sep 22, 2025

@ryantrem
Copy link
Member

Looks good! @kv-bh just a heads up though, we are working on a full re-write of the inspector which we will announce soon (just for awareness in case there are any other improvements you had in mind for inspector v1 code!).

@kv-bh
Copy link
Contributor Author

kv-bh commented Sep 22, 2025

Looks good! @kv-bh just a heads up though, we are working on a full re-write of the inspector which we will announce soon (just for awareness in case there are any other improvements you had in mind for inspector v1 code!).

I did notice there was an "inspector-v2" in the source code, so that would explain that. I don't have any plans to make any other adjustments, this was just something I noticed in my travels through the codebase. Thanks for the heads up!

@deltakosh deltakosh merged commit fc142e7 into BabylonJS:master Sep 22, 2025
19 checks passed
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.

4 participants