How can i use babylon js library in a blazor web assembly application?

I have done the blazor part , it works and is connected to a API to upload the 3d ( or any kind ) of images in the wwwroot folder .
Now i want to somehow use babylon js viewer library to visualise the 3d object ( .STL )

how should i approach this task ?


As far as I can say, you can use Babylon Viewer NPM:
npm install --save babylonjs-viewer
and import to the project:
import 'babylonjs-viewer';

After this you need to define the model and other parameters with the help of html tag (DOM).

Also, you may not need all the functions of the Viewer. You can make your own minified version of Babylon.js according to your needs (thus reducing the overall size of scripts). (For example, if you don’t need to load other 3D formats, you can use only STL loader). More about it here - Tree Shaking (Take What You Need) | Babylon.js Documentation (well, it can be much more complicated than just to use the Viewer :slight_smile:


  • first , i don;t want to use the npm , and instead want to use the CDN instead
  • second , i don;t know what it means to import the viewer , import to where ?

am i missing something here ?
is there any link or git repo to show me how to interact with a lib ?
i am confuse to understand if i have to create another js file and call the functionalities of the viewer inside it , and then warpping that inside c# , or is there any way to use the babylon viewer without any further coding


If you want to use CDN, here it is:
<script src=""></script>
So you just put it in the head of html file and define model with the help of html tag in body.
Seems that you missed Viewer Documentation, which could be a great help for you: