TheSkrapper Posted November 1, 2018 Share Posted November 1, 2018 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 Quote Link to comment Share on other sites More sharing options...
Guest Posted November 1, 2018 Share Posted November 1, 2018 Hello and welcome! Not sure to completely understand your need but if you want to have a mesh with a scale 1 you can just call mesh.bakeCurrentTransformIntoVertices() (http://doc.babylonjs.com/resources/baking_transformations) Quote Link to comment Share on other sites More sharing options...
TheSkrapper Posted November 1, 2018 Author Share Posted November 1, 2018 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. Quote Link to comment Share on other sites More sharing options...
TheSkrapper Posted November 2, 2018 Author Share Posted November 2, 2018 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); Quote Link to comment Share on other sites More sharing options...
Guest Posted November 2, 2018 Share Posted November 2, 2018 Perfect 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.