vue-babylonjs icon indicating copy to clipboard operation
vue-babylonjs copied to clipboard

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

Open kgeusens opened this issue 5 years ago • 6 comments

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.

kgeusens avatar Jan 23 '19 08:01 kgeusens

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 avatar Mar 03 '19 01:03 BrainBacon

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.

BrainBacon avatar Mar 05 '19 00:03 BrainBacon

Any progress on this? I just hit this bug too

johnflux avatar Dec 12 '19 07:12 johnflux

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

This work around works for me.

johnflux avatar Dec 12 '19 07:12 johnflux

@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 [email protected] to solve.

BrainBacon avatar Dec 13 '19 19:12 BrainBacon

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

protypangel avatar Sep 29 '20 13:09 protypangel