Just started with Babylon.js & JS (in general). I was able to load a mesh using *.CreateGroundFromHeightMap and display it locally on my own system, but the result lacked the detail contained in my larger STL models (~500GB).
I wanted to practice loading smaller (~5 to 100MB) STL models from my local machine to see if my scripting is correct, but I haven’t been getting anywhere. I was able to read several STL import issues on this forum along with the documentation related to “ImportMesh”, but I haven’t had success troubleshooting the issue. The worst part is there are no errors, just a white screen when it loads to “http://localhost:5173/”. I’m also unable to right-click the browser window to select “Console” to confirm it even loads. I can’t be sure if this means the model is failing to load.
I’m used to Python and MathLab so I’m not sure how to display my script. I’ll start by showing my main.js where we can assume “LunarSurfaceBlock.STL” is any arbitrary *.stl model:
import * as BABYLON from ‘@babylonjs/core’;
import ‘@babylonjs/loaders/STL/stlFileLoader’;const canvas = document.getElementById(‘renderCanvas’);
const engine = new BABYLON.Engine(canvas);
const createScene = function() {
const scene = new BABYLON.Scene(engine);const box = new BABYLON.SceneLoader.ImportMesh(“./”,“LunarSurfaceBlock.STL”, scene);
//BABYLON.STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES = true;
//const box = new BABYLON.MeshBuilder.CreateGroundFromHeightMap(
//‘’,
//‘/untitled.png’,
// {
// height: 10,
// width: 10,
// subdivisions: 750
// },
// );const camera = new BABYLON.ArcRotateCamera(“Camera”, 3 * Math.PI / 2, Math.PI / 2.5, 5, BABYLON.Vector3.Zero(), scene);
camera.attachControl(canvas. true);
camera.wheelPrecision = 10;const light = new BABYLON.DirectionalLight(‘DirectionalLight’, new BABYLON.Vector3(0, -1, -5), scene);
light.intensity = 0.5;return scene;
}const scene = createScene();
engine.runRenderLoop(function() {
scene.render();
});window.addEventListener(‘resize’, function() {
engine.resize();
})
Thank you in advance for any assistance making progress with this. I’m enjoying Babylon.js!