Jump to content

User Data in mesh object?


Xanmia
 Share

Recommended Posts

I would agree with Dad72 and others to create a class to add tags to scene objects - only for the reason that this should simplify many processes as well as scene optimizaion - and also the potential to use these "tags" in addition or possibly instead of global variables - to allow more versatility to call and operate on element properties - which I have often found limitations when using extensions or other functions which require variations in script formatting - where I've too often been unable to affect some scene element's properties without having to reformat my script.

 

And to DK, your proposal for function and usage of mesh "tags" appears complete to me at first glance, and I can not think of anymore to add to the description of how you might implement this feature into the babylon.js framework - although I haven't yet read all of the posts in this thread, so I hope I'm not to pre-mature in offering my opinion. Although I know that if this is the case, I will certainly hear about it shortly.

 

If this is not yet a formal request on the Babylon feature request site, then please make the request and provide the link, so that I may add my name to the request - as I'm certain others will also.

 

Cheers,

 

DB

Link to comment
Share on other sites

Dad72,

 

I definately had overlooked this, and athough I realized this was an old post, I hadn't enquired to see if tags had been already introduced - as I didn't realize how old this post was. However, this is no excuse, as I could have easily looked at the dates and realized I was reading posts 18+ months old - which is about how old I feel right now in my age at grasping the BJS framework and available features almost 2 years old now.

 

Thank you for not making me look like a complete idiot, as I have been very good at doing this myself - and would have been such an easy target. So I owe you one (at least), and will use much more caution in the future before I open up my big mouth and spout out such jibberish. I'll crawl back into my hole now. :huh:

Link to comment
Share on other sites

  • 7 months later...
On 4/8/2014 at 4:32 PM, Deltakosh said:

I won't add .userData because we are all using javascript and so we can add custom properties whenever we want. tags are important to organize objects but userData is just user data :)

I agree, but if I use TypeScript I can't just add a property.

And the Tag system in my perspective is not efficient for what I need.

I need a reference/pointer whatever to connect my Babylon object/mesh to my Game Object.

Can anyone help me ? 

Link to comment
Share on other sites

Hi @JBP, welcome to the Babylon.js forum!  I am certainly no BJS expert or a Typescript user... but I thought I would share the following BabylonJS Playground demo.  It does lots of "lookups" - various ways to find references to mesh, lights, cameras, etc.  It uses the BJS built-in arrays... scene.lights, scene.cameras, scene.meshes, and even a user-made array called allpoles.

http://playground.babylonjs.com/#AAZIU#0

That playground demo also does some basic animation... using the handy scene.beforeRender property and a function within.  You might wish to view your browser's F12 Dev Tools to view the JS console.  There are some reports being sent there.

Maybe this helps.  Perhaps I'm off-topic.  Others may understand the issue better than I.  Can you give us more details about your concerns?  Thanks.

Again, welcome to the forum.... good to have you with us.  Be well.

Link to comment
Share on other sites

Hi @Wingnut thanks for the reply, but at I need is a way to reference/point to a Game Object from a Babylon Mesh.

For example there is a collision between two meshes and I need to subtract energy from a game object, I know witch meshes collided but from the meshes I can't go directly to the game object.

At least in TypeScript I think.

Link to comment
Share on other sites

I keep a list of game objects using the game object's mesh uniqueid as a key.  It looks something like this:

gameObjectsByMesh = [];

addGameObject(gameObj){

   this.gameObjectsByMeshID[gameObj.mesh.uniqueId] = gameObj;

}

getGameObjectByMesh(mesh){

   return this.gameObjectsByMeshID[mesh.uniqueId];

}

Link to comment
Share on other sites

1 hour ago, adam said:

I keep a list of game objects using the game object's mesh uniqueid as a key.  It looks something like this:

gameObjectsByMesh = [];

addGameObject(gameObj){

   this.gameObjectsByMeshID[gameObj.mesh.uniqueId] = gameObj;

}

getGameObjectByMesh(mesh){

   return this.gameObjectsByMeshID[mesh.uniqueId];

}

Thanks for the tip.

 

12 minutes ago, JCPalmer said:

Or,


mesh["feet"] = "stink";

 

Thanks for the tip.

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...