Jump to content

Accessing objects in the JSON


mrmdes
 Share

Recommended Posts

Hi people!

Babylonjs is an amazing bit of code and I am extremely grateful for it's very existence. Thank you for creating it and releasing it for free.

Now... I am feeling a bit silly for asking this but I seem to have hit a bit of a road block.

How do I access objects on the JSON so that I can instruct a camera to move to them smoothly ( to set as the central focus in the camera's rotational sphere ) and look at them while they are moving towards them.

If fact, how do I access JSON items full stop?  I know the names of the items in my JSON as I created it in blender and loaded it in the babylonjs editor but I can not seem to call them from code at all. I am also able to load it in BabylonJS. It is all there, ready to go but ... I ... CANT .... PLAY .... WITH .... IT ;-(

What is the best way to address these items in JS?

I can create a new mesh like basic cube and interact with it by following all of the super helpful tutorials and am considering just loading my scene as separate objs but I am thinking this could be a lot of potentially unnecessary extra work.

Thank you very much in advance. I want to become a pro at BabylonJS but just need to get over this first hurdle! :-)

-----

EDIT: I figured out the above and it was so simple that I feel like a complete dunce!

I was tempted to delete this post to save my pride but I think it is worth leaving around for any other noobs to find!

If you create a box in JS in babylonjs eg:

var movingbox = BABYLON.Mesh.CreateBox("box", 3.0, newScene);

You can move the box on the x like this:

movingbox.position.x = -5;

If your models is part of the Json this works exactly the same way but you must call your model first:

staticbox = scene.getMeshByName("staticbox");

-----

While I am in an asking sort of mood: can I call an action created in the action editor from JS? I have managed to do all sorts of other camera related bits from an overlaid html UI I have created.

Marc

Link to comment
Share on other sites

Thank you very much for the reply.

That is amazing! It's so simple. I found a way to do what I wanted in JS without needing access to the action in the end. For future projects, this will be a lot quicker and very useful. :-)

Another quick one.... Can I protect my files somehow? If I didn't want someone downloading and re-using my JSON for instance?

 

Cheers,

 

Marc

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...