Skip to content

Instantly share code, notes, and snippets.

@benoitemile
Last active July 1, 2018 08:29
Show Gist options
  • Save benoitemile/3bc75e37d16e55b9110f3933035420b2 to your computer and use it in GitHub Desktop.
Save benoitemile/3bc75e37d16e55b9110f3933035420b2 to your computer and use it in GitHub Desktop.
vue-babylonjs x nuxt : Asset loading
<template>
<no-ssr>
<div>
<Scene v-model="productScene">
<Property
name="clearColor"
color="#fff"/>
<Camera
v-model="camera"
:radius="2500"
type="arcRotate" />
</Scene>
</div>
</no-ssr>
</template>
<script>
import Vue from 'vue';
import vb from 'vue-babylonjs';
import 'babylonjs-loaders';
Vue.use(vb);
export default {
data() {
return {
productScene: null,
camera: null,
};
},
watch: {
productScene() {
const scene = this.productScene;
this.BABYLON.SceneLoader.ShowLoadingScreen = false;
this.BABYLON.SceneLoader.Append(
'/path/to/model/',
'model-requested.obj',
scene,
(newScene) => {
this.productScene = newScene;
this.productScene.createDefaultCameraOrLight(true, true, true);
this.productScene.activeCamera.alpha += Math.PI;
},
);
},
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment