Jump to content

Resetting base scale


TheSkrapper
 Share

Recommended Posts

Hello,

I'm new to BabylonJS.

Is it possible to scale an object down but then have it think that its new scale is now 1?

I am building an object out of unit cubes (scale 1 base cubes).  I then merge the objects into a new mesh.   Then I want to scale it down to be a new unit sized cube with scale 1.

I will be using this in a recursive fractal routine that resizes the base cube but it expects it to be scale 1.

I hope that makes sense.  I've tried googling but perhaps I don't know the proper terminology.  Thanks for any feedback.

Skrapper

Link to comment
Share on other sites

Thanks for replying Deltakosh,

It looks like that link may be what I am looking for but just to clarify my understanding of scale with merging and burning...

I'm working on an implementation of a Menger Sponge.

If I build a 3x3x3 cube with 27 cubes of scale 1 and merge them then I get a new mesh that at scale 1 is 3x3x3 units large.  I then want to scale it down 1/3 to take up a 1x1x1 unit space.   Then I want to change its ?'identity'? so that when I clone it and set it's scale to 1 it takes up 1x1x1 instead of 3x3x3.

So I will scale the new merged shape down 1/3 and then bake it with the new vertices so that will then be their locations at scale 1 when I clone it.  Am I understanding things correctly?

Sorry for my noobness.

Link to comment
Share on other sites

I was able to scale a larger merged object down 1/3 and then set that as its base 1x scale by using the following code..

let mergedBoxes = BABYLON.Mesh.MergeMeshes([xbox, ybox, zbox], false, true);
var matrix = BABYLON.Matrix.Scaling(1/3, 1/3, 1/3);
mergedBoxes.bakeTransformIntoVertices(matrix);
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...