How to use Babylon with Deno and Fresh?

I’m also trying deno fresh. I didn’t manage to solve the loader plugins import issue yet, but I find the manual register way works.

  1. import the GLTFFileLoader:
import { GLTFFileLoader } from "babylon/loaders/glTF";
  1. register the loader manually:
if (SceneLoader) {
    SceneLoader.RegisterPlugin(new GLTFFileLoader());
}

Then you could use it to load glb file.
You could also check whether the loader is activated or not:

if (SceneLoader.IsPluginForExtensionAvailable('.glb'))
    console.log("GLTF Loader activated");
else
    console.log("No GLTF Loader!!!");

P.S. in your code, you are missing the main render loop to show everthing.

// run the main render loop
this.engine.runRenderLoop(() => {
    this.scene.render();
});

and some more light e.g., HemisphericLight

const _light1: HemisphericLight = new HemisphericLight("light1", new Vector3(1, 1, 0), this.scene);

This is the result:

4 Likes