Tableuraz Posted September 30, 2015 Share Posted September 30, 2015 Hi there, I've got an issue, and I guess "it's not a bug it's a feature", but when applying scaling to an object and setting an other object's parent as the aforementioned object, the scaling of both objects becomes the same, even if parenting is set up after applying scale on the parent.Here is a Playground to demonstrate the issue : Playground linkHere you can see that the sphere's scaling should be (1, 1, 1), the default scaling, but instead it has the same scaling as its parent (2, 3, 5), even if the scaling has been set up before linking those objects.I guess that Babylon sets the scaling matrix of the parent to be the same as its childs (I'll investigate the source code to confirm that), but it shouldn't, every child should have their own scaling matrix, and change their scaling vector relatively according to their parent. That's how I would do it anyway... Thanks in advance for your answers Quote Link to comment Share on other sites More sharing options...
adam Posted September 30, 2015 Share Posted September 30, 2015 The way it is now makes sense to me. Call bakeCurrentTransformIntoVertices before you parent the sphere if you don't want the sphere to scale. http://www.babylonjs-playground.com/#ZY97E#2 Tableuraz 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 30, 2015 Share Posted September 30, 2015 Hi again Tab! Good to see you. Inherited scaling is normal, in BJS... and it can sometimes get in the way. Have you been following this thread? http://www.html5gamedevs.com/topic/17044-evolution-for-out-of-the-box-meshes-creation/ We are now able to create basic objects... pre-scaled (pre-sized). In your example, you used a createGround as your parent, and createGround already let's you size it specifically. But our other basic shapes are getting the same power... http://www.babylonjs-playground.com/#WRH6X#12 (children box2 and sphere2 still inherit scaling, but the scaling on both parents is still 1,1,1... even though they LOOK scaled) So, that is another "feature" that you should know about, too. And thanks, Adam... that's a great solve, too. Be well. Quote Link to comment Share on other sites More sharing options...
Tableuraz Posted September 30, 2015 Author Share Posted September 30, 2015 Hi Wingnut, The ground mesh was just an example, I am not working with basic objects in the web solution I am developping, but rather scaling 1x1x1 complex objects to their real size in meters (they are specific kinds of objects who need exact scaling and can have various sizes). And indeed parents scaling can sometimes get in the way, most of the time I end up unparenting objects and moving them together with my own code, but I just encountered a case where I really need objects parenting. Also, using bakeCurrentTransformIntoVertices generates amazing artefacts and log the following "WebGL: INVALID_OPERATION: vertexAttribPointer: no bound ARRAY_BUFFER" Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 30, 2015 Share Posted September 30, 2015 *nod*... understood. Thanks for the reply. I rarely/never import meshes, but, you have probably seen how our basic shapes have an 'updatable' flag. Does your mesh have that set true? I think it will need to be so... for the bake to work. *shrug* But I'm not sure if that is causing the error. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 30, 2015 Share Posted September 30, 2015 Hello, this is the expected behavior: children inherits the complete parent's matrix including scaling, rotation and position. So in your case if you want to restore child scaling to 1,1,1 you have to use the inverse of parent's scaling:http://www.babylonjs-playground.com/#ZY97E#3 Wingnut, Christopher Stock, que and 1 other 4 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.