JYM Posted March 22, 2018 Share Posted March 22, 2018 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 Quote Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2018 Share Posted March 23, 2018 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? Quote Link to comment Share on other sites More sharing options...
JYM Posted April 10, 2018 Author Share Posted April 10, 2018 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? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 10, 2018 Share Posted April 10, 2018 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 Quote Link to comment Share on other sites More sharing options...
JYM Posted April 11, 2018 Author Share Posted April 11, 2018 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? Quote Link to comment Share on other sites More sharing options...
Guest Posted April 11, 2018 Share Posted April 11, 2018 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 Quote Link to comment Share on other sites More sharing options...
JohnK Posted April 11, 2018 Share Posted April 11, 2018 This one? Since SPS is used you need to check http://doc.babylonjs.com/how_to/solid_particle_system#pickable-particles for clickable labels. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
JYM Posted April 12, 2018 Author Share Posted April 12, 2018 @Deltakosh Thanks. The demo really helps. Quote Link to comment Share on other sites More sharing options...
JYM Posted April 12, 2018 Author Share Posted April 12, 2018 @JohnK I'll take a look into it. 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.