Commit fc142e7
authored
Create abstraction layer over the inspector gizmo layer (#17177)
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/](https://sandbox.babylonjs.com/?asset=https://playground.babylonjs.com/scenes/skull.babylon)
and load a model, then open the inspector and click this button:
<img width="536" height="220" alt="image"
src="https://github.com/user-attachments/assets/638ce37e-f310-40f8-a424-e557f35ab062"
/>
A message will appear on screen: `Script error. Check the developer
console.` (nothing appears in console).
The actual issue stems from this error:
```log
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:
https://github.com/BabylonJS/Babylon.js/blob/197d8f6728cc57e46df8e63eaab776a023e5a3ff/packages/dev/inspector/src/components/sceneExplorer/entities/sceneTreeItemComponent.tsx#L185-L187
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.1 parent 1c96319 commit fc142e7
File tree
5 files changed
+56
-37
lines changed- packages/dev/inspector/src
- components/sceneExplorer/entities
5 files changed
+56
-37
lines changedLines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
77 | | - | |
78 | | - | |
| 77 | + | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 43 | + | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
Lines changed: 14 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | | - | |
26 | 24 | | |
| 25 | + | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
56 | | - | |
57 | | - | |
| 55 | + | |
| 56 | + | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
| |||
85 | 84 | | |
86 | 85 | | |
87 | 86 | | |
88 | | - | |
89 | | - | |
90 | | - | |
| 87 | + | |
| 88 | + | |
91 | 89 | | |
92 | 90 | | |
93 | 91 | | |
| |||
100 | 98 | | |
101 | 99 | | |
102 | 100 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 101 | + | |
| 102 | + | |
106 | 103 | | |
107 | 104 | | |
108 | 105 | | |
| |||
181 | 178 | | |
182 | 179 | | |
183 | 180 | | |
184 | | - | |
185 | | - | |
| 181 | + | |
186 | 182 | | |
187 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
188 | 186 | | |
189 | 187 | | |
190 | 188 | | |
| |||
266 | 264 | | |
267 | 265 | | |
268 | 266 | | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | 267 | | |
274 | 268 | | |
275 | 269 | | |
276 | 270 | | |
277 | 271 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 272 | + | |
284 | 273 | | |
285 | 274 | | |
286 | | - | |
| 275 | + | |
287 | 276 | | |
288 | 277 | | |
289 | | - | |
290 | 278 | | |
291 | 279 | | |
292 | 280 | | |
| |||
312 | 300 | | |
313 | 301 | | |
314 | 302 | | |
315 | | - | |
316 | | - | |
| 303 | + | |
317 | 304 | | |
318 | 305 | | |
319 | 306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
538 | 539 | | |
539 | 540 | | |
540 | 541 | | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
| 542 | + | |
545 | 543 | | |
546 | 544 | | |
547 | 545 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments