royibernthal Posted July 11, 2016 Share Posted July 11, 2016 Is there a way to add a child to ScreenSpaceCanvas2D after its already been constructed? I tried this for instance but it doesn't seem to be the direction: var text = new BABYLON.Text2D("Test", { id: "text", marginAlignment: "h: center, v:center", fontName: "20pt Arial", }); ui.children.push(text); text.parent = ui; //TypeError: setting a property that has only a getter Quote Link to comment Share on other sites More sharing options...
Temechon Posted July 11, 2016 Share Posted July 11, 2016 Something like this maybe ? http://babylonjs-playground.com/#2AVSFH#55 Press a key to add a new text. Edit : without a group here: http://babylonjs-playground.com/#2AVSFH#56 royibernthal 1 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted July 11, 2016 Author Share Posted July 11, 2016 Is there a way without specifying the children or parent in any constructor? In other words, add child to parent after both are already constructed. Quote Link to comment Share on other sites More sharing options...
Temechon Posted July 11, 2016 Share Posted July 11, 2016 I don't think so... But you can always build a group dynamically. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted July 11, 2016 Author Share Posted July 11, 2016 What do you mean? Quote Link to comment Share on other sites More sharing options...
Temechon Posted July 11, 2016 Share Posted July 11, 2016 You can create the canvas and the text2D. When you decide to add it, build a group2D with parent=canvas, and set the text2D as a child. royibernthal 1 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted July 11, 2016 Author Share Posted July 11, 2016 I understand, true. Thanks Nabroski 1 Quote Link to comment Share on other sites More sharing options...
Nabroski Posted July 11, 2016 Share Posted July 11, 2016 Hello maybe this helps you:http://www.babylonjs-playground.com/#23N1H9#7http://www.babylonjs-playground.com/#23N1H9#9 Best Quote Link to comment Share on other sites More sharing options...
Nockawa Posted July 12, 2016 Share Posted July 12, 2016 23 hours ago, royibernthal said: Is there a way without specifying the children or parent in any constructor? In other words, add child to parent after both are already constructed. Hello, no unfortunately right now it's all at construction time because the relation is immutable...I know this is a limitation, I've just created a trello card to remember about it and develop it when I'll have the time to. https://trello.com/c/0KTDa7mM Quote Link to comment Share on other sites More sharing options...
royibernthal Posted July 12, 2016 Author Share Posted July 12, 2016 2 hours ago, Nockawa said: Hello, no unfortunately right now it's all at construction time because the relation is immutable...I know this is a limitation, I've just created a trello card to remember about it and develop it when I'll have the time to. https://trello.com/c/0KTDa7mM Hi, that's good to know thanks. I don't know how the engine works under the hood so it might not be an option, but it'd be great if scene wouldn't have to be passed in 3D constructors as well. Quote Link to comment Share on other sites More sharing options...
Nockawa Posted July 13, 2016 Share Posted July 13, 2016 7 hours ago, royibernthal said: Hi, that's good to know thanks. I don't know how the engine works under the hood so it might not be an option, but it'd be great if scene wouldn't have to be passed in 3D constructors as well. Well, this is a totally different thing. I'm not sure it will happen one day but I can't speak on the behalf of @Deltakosh. Scene objects are tightly coupled to the scene itself, making them independent would be a pretty big rework for a small benefit, I'm not sure it's worth the shot. royibernthal 1 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.