Yazheirx Posted October 28, 2018 Share Posted October 28, 2018 Assuming all I can pass to a function is the major objects (scene, canvas, camera, etc) what is the best way to reference a specific Mesh? I am hopeful that I can create a function with a constructor like: function moveMesh(meshName, scene){ //select the namedMesh victimMesh.position = new BABYLON.Vector3(0,0,0); } I will actually create a key set to animate the Mesh move, but I am not skilled enough in JS to know how to select the child object I want. I know I saw the method in one of the tutorials, but I have watched over 40 hours of tutorials on youtube and can't remember where I saw it. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted October 29, 2018 Share Posted October 29, 2018 You are looking for this: https://doc.babylonjs.com/api/classes/babylon.scene#getmeshbyname The API docs are a great source, but also hopefully you are using an IDE that has intellisense as well (like VS code). function moveMesh(meshName, scene){ let victimMesh = scene.getMeshByName(meshName); // this will throw an exception, if there isn't a mesh with that name victimMesh.position = new BABYLON.Vector3(0,0,0); } Yazheirx 1 Quote Link to comment Share on other sites More sharing options...
Yazheirx Posted October 29, 2018 Author Share Posted October 29, 2018 Thank you that is exactly what I was looking for I am using VS Code, but my intellisense seems to be incomplete. I think that is because I am using a CDN rather than having everything dowloaded. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.