Commit aad5441
fix(xr-input): skip visual init when asset load fails to avoid TypeError
Summary:
When the GLTF asset for an XR input visual (controller or hand) fails to load — common in offline / firewalled / slow-network environments since the default `assetPath` is `https://cdn.jsdelivr.net/.../<profile>/<handedness>.glb` — `XRInputVisualAdapter.createVisual` falls back to `new Group()` for `gltf.scene`, then unconditionally constructs the visual subclass and calls `init()`. `AnimatedHand.init()` and `AnimatedControllerHand`'s constructor both immediately dereference asset-only nodes (`getObjectByProperty('type','SkinnedMesh')!`, `getObjectByName('wrist')!`, joint bones), so they throw:
`TypeError: Cannot set properties of undefined (setting 'frustumCulled')`
and the visual is left half-constructed in the cache for the rest of the session.
Bail out of `createVisual` before construction when the load returned no usable model. Log a single warning. The single caller (`connectVisual` in the same file) already does `if (visual && ...)` so widening the return type to `Promise<T | undefined>` is type-safe and runtime-equivalent. Input still tracks; only the rendered visual is absent.
Removes the now-unreachable `if (visual.model.children.length === 0) { visual.model.visible = false }` post-init block, which only existed to paper over the same empty-fallback case after the crash window. The new shape also stops caching a broken visual so subsequent connects can re-attempt the load.
Reviewed By: zjm-meta
Differential Revision: D105652667
fbshipit-source-id: fa27b9af2818f343f451d0ca0fc8cf1addaadee51 parent 88c8a7a commit aad5441
1 file changed
Lines changed: 11 additions & 7 deletions
Lines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
171 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
| |||
0 commit comments