Beg-in / vue-babylonjs

A ready-to-go 3d environment for Vue.js using Babylon.js
https://vuebabylonjs.com
MIT License
463 stars 73 forks source link

v-model binding for Scene does not work - remains uninitialized #18

Open kgeusens opened 5 years ago

kgeusens commented 5 years ago

When using <Scene v-model="myScene" ….>

the myScene data element does not initialize.

The workaround I use is to capture the scene object in the onScene event and store in in myScene. However, in the vue dev tools for chrome, myScene is consistently reported as "unknown object" and can not be explored. Logging myScene to console does show the internals of the scene.

BrainBacon commented 5 years ago

If you use the @scene or @complete events on the component do you have an initialized object? It's probable that you are trying to access that object before it's completely initialized like in a mounted or created hook.

Try something like this:

<template>
  <Scene @scene="onScene">
    <!-- stuff in scene -->
  </Scene>
</template>
<script>
export default {
  methods: {
    onScene(scene) {
      // should be fired when the scene object has been initialized
    },
  },
};
</script>

As for the devtools reporting the object, is it possible that you're binding to a nested object in data? Vue won't react to nested properties. Can you share a minimum reproduction on glitch.com or something similar?

BrainBacon commented 5 years ago

Hey @kgeusens I was able to verify that the scene v-model is not being initialized in the source. I'll patch and let you know when that's released. Apologies for the inconvenience.

johnflux commented 4 years ago

Any progress on this? I just hit this bug too

johnflux commented 4 years ago

If you use the @scene or @complete events on the component do you have an initialized object?

This work around works for me.

BrainBacon commented 4 years ago

@johnflux Yeah the @scene event workaround is the supported solution. There are some general issues with scene v-model binding that may have to wait for Vue@3.0 to solve.

protypangel commented 4 years ago

@BrainBacon I LOVE U SO MUCH FOR YOU COMMENT ON 3 Mar 2019, MY DUDE !!!!!!!!!!!! You really saved my project dude.