I’m trying to move my oversized plyground scene into my actual codebase and run it locally, however when I try and create a shadow generator (new BABYLON.ShadowGenerator(1024, light, true);) the following is thrown:
babylon.js?633b:16 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘textureFloatRender’)
at new e (babylon.js?633b:16)
at Function.eval (babylon.ts?7878:839)
at Generator.next (<anonymous>)
at eval (babylon.ts:14)
at new Promise (<anonymous>)
at __awaiter (babylon.ts:10)
at Function.CreateScene (babylon.ts?7878:819)
at VueComponent.created (HomeBase.vue?be5d:36)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at callHook (vue.runtime.esm.js?2b0e:4219)
textureFloatRender is a caps that is read by engine.getCaps().textureFloatRender.
Your error message means that engine.getCaps() is undefined, which is not really possible as the caps are filled in the engine constructor. However, if you don’t pass a canvas to this constructor, there’s an early exit and the caps won’t be filled, so I guess it’s your problem (your are passing a null/undefined canvas).
Suggestion: Constructors should throw when invalid params are provided. Objects should guard their state in that regard, and exceptions during construction can be far more helpful than unexpected consequences far removed from construction.
Are you accepting PRs for that kinda stuff?
Man, I would have saved so many hours of debugging if I even had a hint that I was passing an undefined canvas in…