6

I have a 3D model that was loaded as an obj file into Three.js. The model itself is a furniture.

enter image description here

The problem is, that furniture material is dynamic and is different in size (thickness). I need to have to able to made thickness of material bigger, but the total size of the model can't be changed. So scaling isn't an option.

Is there a way I can resize parts of the model (few specific meshes) and doesn't compromise the structure of mesh itself ? I need to change thickness of the structure, but internal parts of the model shouldn't change.

The only solution I can think of is to change scale of some of the meshes and then to change global position of the other meshes based on that. Is this the right way ?

object.traverse(function(child) {
    if (child instanceof THREE.Mesh) {
        // resize and reposition some of the meshes
    }
});

Possible ways to solve it:

  1. Bones
  2. Deformation
1
  • let me understand problem. You are using Obj file and selectively increase and decrease size of some part without changing the mesh. Since you are using material (*.mtl ) file you have pre-defined texture co-ordinate now you want to change those also with algo whoooosppp tricky why doing ( some how we can read the vertices point from obj and give user flexibility for increase decrease but what about texture ) You can add new UI scenario in app where you merge external plane what you say on this Commented Jul 16, 2016 at 19:46

3 Answers 3

3
+25

Well, if all of the meshes are separate primitives, then you can just change the scale of each part you want to change along one axis, and just set up anchor points to constrain to the outside. So for pieces on the border, you scale the empty object that they're attached to so that they maintain the outer shell.

EG:

 OOOOOO
OMMMMMMO
OMmmmmMO
OMmmmmMO
OMMMMMMO
 OOOOOO

where O is an Object3D carrying the adjacent Mesh-M, and the m's represent meshes that are scaled themselves. This way if you adjust the scale of all 'm's and 'O's, the outer shell stays in place,

But you're on the right track with the traversal. You'll just have to do this. For an easy way to traverse, I would give everything you want to change some attribute in their .userData object. Because in some cases you'll want to scale empty objects (O) (so that you can effectively move the anchor point) whereas at others you'll want to scale the meshes in place (m). So it's not purely a mesh based operation (since meshes want to scale from their center). Doing some tagging makes the traversal simpler:

object.traverse(function(child){
    if(child instanceof THREE.Mesh){
        if(child.userData.isScalable){
            //do the scaling.
        }
    }
});

and if you set up the heirarchy and .userData tagging correctly, then you just scale things and you keep the outer shell.

Is this what you're asking? because the question is unclear.

Sign up to request clarification or add additional context in comments.

6 Comments

I need to resize only few parts of the model, without compromising it's structure. (in simple words)
then this solution will work. it won't kill your UV mapping to scale the meshes/objects/groups. Give it a try and then mark as answered
first of all, changing scale of the mesh will automatically reposition it and mess up the whole model. Also, it won't resize other meshes connected to current mesh. So many unanswered questions.. I don't see where the solution is, honestly..
Well you have to re-organize the child-parent heirarchy of your model for this to work, because yes, if it's not seperated into individual parts, then, there is no operation that you can perform to intelligently change the scale of any of the components. If this is something you made in CAD for example, you'll need to re-export as a series of parts. You can't do anything with the whole model to change this. There's no way around it.
dropbox.com/s/xl7amq2x26bybdw/main.obj?dl=0 it's just a obj file imported from the Blender.
|
3

You could use Clara.io, it is built on top of ThreeJS and allows for you to run operators on geometry that you setup in Clara.io scenes. There is a thickness operator in Clara.io that you can use.

Documentation here: http://clara.io/learn/sdk/interactive-experiences

Anything you can do in the Clara.io editor you can do in an interactive-embed.

1 Comment

will I be able to change thickness of single mesh without breaking the model structure ?
0

You can use your method of changing different meshes sizes and other positions, but when you use object.scale.set( x, y, z ); the browser has to change the scale of the model for every frame rendered. So if you use this for lots of meshes, it can decrease your game's performance. The best way to go would be to use a 3d editor like Blender. It is easier and more efficient.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.