-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling functions inside scene element (template) #10
Comments
It looks to me like you aren't properly getting a reference to the scene. The way you probably want to do it is use the <template>
<Scene v-model="scene">
<!-- scene stuff in here -->
</Scene>
</template>
<script>
module.exports = {
data() {
return {
scene: null,
};
},
watch: {
scene() {
// scene is now longer null when this is called
},
},
};
</script> You'll probably want to wait until the watcher is called to attach your event listeners though. Another (more complex) way to achieve this is to use the Entity component as a mixin to access |
Thanks , that helps, i am able to get scene reference The above doesnt work as getEngine() is a babylonjs API reference. |
Are you positive you are actually getting a reference to the scene properly? I was able to retrieve the rendering canvas using the BabylonJS API just fine. Here's how I did it: https://glitch.com/edit/#!/vue-babylonjs-canvas |
not really, the error was thrown at this.$scene.getEngine(). sorry, my fault, i think my access to scene was wrong, i cross verified it with your example. it's fine now, as it should be this.scene.getEngine().getRenderingCanvas() I am facing another issue , Thanks for much needed support! |
I looked at your example and it doesn't seem like you're understanding the flow of how the elements are being created. Although it is partially my fault because I don't think the docs do a great job of explaining the lifecycle of these elements. The reason you're having difficulty here is because you're doing everything inside the scene watcher when none of the other components have been created yet. You also have Here is an example: <template>
<Scene v-model="scene">
<Camera type="arcRotate" v-model="camera"></Camera>
<PointLight :position="[0, 2, -1]"></PointLight>
<Box :position="[0, 0, 5]"></Box>
<Ground v-model="ground" :options="{width:100, height:100}">
<Material diffuse="#F00"></Material>
</Ground>
</Scene>
</template>
<script>
export default {
data() {
return {
scene: null,
ground: null,
camera: null
};
},
watch: {
ground() {
this.active();
},
camera() {
this.active();
},
},
methods: {
active() {
if (this.ground && this.camera) {
// this.scene, this.camera, and this.ground are all available now
}
},
},
};
</script> A couple of additional notes regarding your code:
I am starting to realize that I should probably put a help needed discussion board together somewhere as this board should really only be for but reports and feature requests. Unfortunately I can't dedicate a whole lot of time to helping people understand concepts within Vue and Babylonjs. However, with that being said there is a lot that can be done within documentation to make the learning process easier. So, I am going to close this now since there doesn't seem to be any issues with the library itself, but feel free to open an issue or pull request if something isn't clear in the documentation or you are sure you found a bug. |
Yes, the question was completely irrelevant or nothing to do with vue-babylonjs issues here. Myself being a beginner in vuejs accelerated me to post more of my unnecessary queries. I have tried more in babylonjs framework alone and wanted to implement same features in vue-babylonjs because of vue's cool features. I would ask for more documentation or examples on how to use attributes (mainly babylonjs objects) in vue-babylonjs. Please consider this as feedback. The last two comments of your's were really helpful. |
@likithkailas I have released a new version of the plugin that includes a new event on components in this library called |
Hello Brian,
I have implemented following functionalities in the image below using vue-babylon
I have a question, all the other functionalities are working except one,
Other functionalities (which are working fine),
moveBox() --> I am able to control mesh movement through slider
rotateBox() --> I am able to control mesh rotation through slider
changecolor() --> I am able to change mesh color through slider
more information: i am trying to implement the mesh movable(drag and drop) functionality as show here : http://playground.babylonjs.com/#279FW9
can you help me with this issue?
The text was updated successfully, but these errors were encountered: