Jump to content

Parent-child scaling issue


Tableuraz
 Share

Recommended Posts

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 link

Here 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  :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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