Jump to content

Clone/createInstance does not copy the control in Babylon GUI


JYM
 Share

Recommended Posts

So the app is used to display tasks in a calendar. You can click W or S to move forward or backward. Each task has a click button with an alert function attached. Here is a playground link: http://www.babylonjs-playground.com/#1ZH86G#2

The problem I am facing is render optimization. Since there will be tons of tasks to render, I want to use clone function or createInstance function as suggested from documents. But these 2 functions don't work when I want the cloned object to have the click control.

In the playground code: (line 45, createTasks)

1. If you call attachTaskInfoWithFunction(task) upon each cloned task object, it works. But it has a significant performance issue when you want to render more than 400 task meshes. (I'm just rendering 40, you can change the task number on the top)

2. If you call attachTaskInfoWithFunction(task) upon the originalTask and make clones from it, you will lose the click event function.

3. If you call attachTaskInfoWithFunction(task) upon the originalTask and call createInstance on it, you will lose the click event function.

I want to ask with Babylon GUI, is it possible to call clone or createInstance on mesh object while still keep the texture with button click control?

If not, is there any other way to optimize if there are tons of objects to render.

Thanks

Link to comment
Share on other sites

Hello

you should not multiply the number of advancedDynamicTexture. The overall idea is to keep the number as low as possible.

 

Why not using a group of big meshes? And try to add multiple tasks per texture?

Link to comment
Share on other sites

  • 3 weeks later...
On 3/23/2018 at 11:26 AM, Deltakosh said:

Hello

you should not multiply the number of advancedDynamicTexture. The overall idea is to keep the number as low as possible.

 

Why not using a group of big meshes? And try to add multiple tasks per texture?

Because I'm using the Babylon GUI which provides the BABYLON.GUI.AdvancedDynamicTexture.CreateForMesh(task) function. Theoretically, I only need one texture with same button click event handler. Is there a way of apply such GUI texture with button on to all task meshes?

Link to comment
Share on other sites

nope if you want GUI to provide interaction, you have to have one ADT per mesh. But perhaps you may want to add interaction at mesh level instead

Link to comment
Share on other sites

On 4/10/2018 at 7:45 AM, Deltakosh said:

nope if you want GUI to provide interaction, you have to have one ADT per mesh. But perhaps you may want to add interaction at mesh level instead

Adding interaction at mesh level. You mean by applying physics detection to track mouse movement over meshes instead of using GUI button?

In such case, I assume we will use the clone method for meshes. But there is another requirement that each mesh is going to have different text content on it.  Can we have the performance while drawing different text on each mesh?

Link to comment
Share on other sites

Nope I mean by using scene.onPointerDown: it will give you info about mesh under the mouse. Same for scene.onPointerMove (something along these lines: https://www.babylonjs-playground.com/#10EC1H#1)

Regarding drawing different texts it could be a problem if there are too many texts for sure but at least they should only be generated once

 

@JohnK also did a cool demo with a lot of different texts on different meshes but I can't find the demo anymore

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