Thanks for your feedback.
At the moment I tried your suggestion to add the assetsInclude option to the vite config file.
However this couldn’t help unfortunately.
export default defineConfig({
resolve: {
alias: {
'~/': `${path.resolve(__dirname, 'src')}/`,
},
},
assetsInclude: ['**/*.gltf', '**/*.glb'],
plugins: [
...
This is the code I have for testing purposes:
<script setup lang="ts">
import {
ArcRotateCamera,
Engine,
HemisphericLight,
Mesh,
MeshBuilder,
Scene,
SceneLoader,
StandardMaterial,
Texture,
Vector3,
Vector4,
} from '@babylonjs/core'
import '@babylonjs/loaders/glTF'
import { GLTFLoader } from '@babylonjs/loaders/glTF/2.0/glTFLoader'
import model from './../assets/EPSI.glb'
import textFile from './../assets/EpsilonCitiesLogo.png'
const router = useRouter()
const { t } = useI18n()
const cnvs = ref(null)
const log = (object: any) => {
console.log(object) // eslint-disable-line no-console
}
log('cnvs started')
const setupRenderLoop = (engine: Engine, scene: Scene) => {
engine.runRenderLoop(() => {
scene.render()
})
}
const createScene = (scene: Scene, canvas: HTMLBodyElement) => {
const camera = new ArcRotateCamera('Camera', -Math.PI / 2, Math.PI / 2, 3, Vector3.Zero())
camera.attachControl(canvas, true)
const light = new HemisphericLight('light', new Vector3(1, 1, 0), scene)
const f = new Vector4(0, 0, 0.5, 1) // front image = half the whole image along the width
const b = new Vector4(0.5, 0, 1, 1) // back image = second half along the width
const mat = new StandardMaterial('')
mat.diffuseTexture = new Texture(textFile)
// const plane = MeshBuilder.CreatePlane('plane', { frontUVs: f, backUVs: b, sideOrientation: Mesh.DOUBLESIDE })
// plane.material = mat
// SceneLoader.Append('', model, scene, model => log(model))
SceneLoader.Append('', './../assets/EPSI.glb', scene, model => log(model))
SceneLoader.ImportMesh(
'',
'https://raw.githubusercontent.com/BabylonJS/MeshesLibrary/master/',
'PBR_Spheres.glb',
scene,
(meshes) => {
scene.createDefaultCameraOrLight(true, true, true)
scene.createDefaultEnvironment()
})
// SceneLoader.ImportMesh('', 'https://babylon.sfo3.digitaloceanspaces.com/', 'gifts.glb', scene, model => log(model))
}
onMounted(() => {
const engine = new Engine(cnvs.value)
const scene = new Scene(engine)
const resize = () => {
engine.resize()
}
window.addEventListener('resize', resize)
createScene(scene, cnvs.value!)
setupRenderLoop(engine, scene)
})
</script>
<template>
<p>CNVS Viewport</p>
<div>
<button
btn m="3 t6" text-sm
@click="router.back()"
>
{{ t('button.back') }}
</button>
</div>
<canvas ref="cnvs" class="absolute top-0 h-screen w-full !outline-none bg-rose-300" />
<img src="./../assets/EpsilonCitiesLogo.png" class="inline-block py-10 z-50" alt="">
<nav-chapter />
</template>
Giving me the following:
So you can see the external asset is properly being loaded.
But as @westonsoftware mentioned the glb seems to be omitted?
Also my ts gives this as an error:
And my autocomplete path intellisense indicates the file is there to be sure there is no mistake in file path. Also the model works correctly when exported through the bjs exporter in 3Ds Max, it loads in the bjs sandbox without any issue.
Thanks again