BabylonJS and ThreeJS use different programming paradigms?

Hi everyone!

I’m very much beginning to learn BabylonJS after having a fight with ThreeJS and I was seeking a little clarification about the way BabylonJS works.

Am I wrong to see things this way/did I miss something out? But after reading the first chapters of BabylonJS documentation, I feel that it runs on a completely different paradigm than ThreeJS.

ThreeJS feels very imperative/procedural in its way of working. We have an animate function that repeats itself indefinitely where we can interact with our objects.

Maybe I got this wrong but so far, I feel like BabylonJS is procedural? The big deal happens in the createScene function where we create objects and define their behaviors?

I am quite unease with this way of coding and I wondered if it was possible to code in an imperative way using Babylon and if doing so would cost efficiency?

Thank you for your help!

Welcome aboard!

Babylon also has a render loop that repeats indefinitely. The thing is that when using the Playground you don’t see it because this loop is setup by the Playground framework.

Same thing for createScene, it’s a by-product of the Playground: the Playground framework calls this function to create objects and setup the scene. You are responsible to create and populate the scene and return it. The framework will simply call scene.render() in the infinite loop.

1 Like