Last active
July 1, 2018 08:29
-
-
Save benoitemile/3bc75e37d16e55b9110f3933035420b2 to your computer and use it in GitHub Desktop.
vue-babylonjs x nuxt : Asset loading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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