svelte-babylon
svelte-babylon copied to clipboard
Q: why must the import be done in onMount?
I'm wondering why we can't just do:
<script>
import BABYLON from 'babylonjs'
</script>
instead of
onMount(async () => {
const babylonjs = await import('babylonjs');
BABYLON = babylonjs.default;
});
?
It's for SSR compatibility. Babylon can't run on node server, onMount only runs in the client.
On Thu, Jun 17, 2021, 8:57 AM Noel da Costa @.***> wrote:
I'm wondering why we can't just do:
instead of
onMount(async () => { const babylonjs = await import('babylonjs'); BABYLON = babylonjs.default; });
?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SectorXUSA/svelte-babylon/issues/14, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATGFLT5CEDS55ISPLNJWCTTTHWKDANCNFSM463T2DUA .
But that actually reminds me, Babylon has partial server side rendering now. It can ship generated scenes from the server to the client. I will add that to the TODO.