Hello,
I try to load a gtlf file.
I use vitejs
In a fresh install of vitejs i load a simple scene. (i use vue)
Here the component
<template>
<canvas class="Scene" ref="canvas" />
</template>
<script setup>
import { Engine, Scene, Vector3, FreeCamera, HemisphericLight, SphereBuilder, StandardMaterial, SceneLoader } from "@babylonjs/core"
import "@babylonjs/loaders"
import { onMounted, ref } from 'vue'
export const canvas = ref(null)
onMounted(() => {
const engine = new Engine(canvas.value, true, {preserveDrawingBuffer: true, stencil: true})
const scene = new Scene(engine)
const camera = new FreeCamera('camera1', new Vector3(0, 0, 10), scene)
camera.setTarget(Vector3.Zero())
camera.attachControl(canvas.value, false)
const light = new HemisphericLight('light1', new Vector3(0, 1, 0), scene)
const sphere = SphereBuilder.CreateSphere( "sphere", { diameter: 2, segments: 32 }, scene);
engine.runRenderLoop(() => {
scene.render()
})
SceneLoader.ImportMesh(
"",
"https://models.babylonjs.com/CornellBox/",
"cornellBox.glb",
scene,
meshs => {
console.log(mesh)
})
})
</script>
I’ve try a lot a thing, but i never make the gltf import works
I always got
importMesh of undefined from undefined version: undefined, exporter version: undefinedimportMesh has failed JSON parse
Really need some help/advise please
Thanks you