Is it possible to apply rotation/scale/position on THREE.Object3D - three.js

Using blender Im used to apply any transformations to object with CTRL+A; so object becomes zero transformations (rotation/scale/position). Then I can transform object from scratch not worring about previous transformations.
Is there any way to do the same in THREE.JS? Something like THREE.Object3D.commitTransforms()?
blender

You should be able to achieve the intended effect by using BufferGeometry.applyMatrix() and passing the Object3D.matrixWorld into it. This will bake the world transformation into the geometry.
However, you have to manually reset Object3D.position, Object3D.scale and Object3D.rotation.
three.js R109.

Related

Is it possible to name rotations/joints in threejs and how is it possible to set them?

I am doing a bit of work with threejs. And now just wondering if it was possible to name rotations or joints.
So it seems possible to write code like:
arm.rotateZ( 180 ).name="ARM_ANGLE";
But then how does one subsequently access and set the same rotation?
I know in x3d it is possible to do this, so was thinking it would be possible to do as well in threejs. In x3d, one can define a reference as:
<Transform DEF="ArmAngle" rotation="0 0 1 3.19">
And then later define a route to reference it like:
<ROUTE fromNode='spinarm' fromField='value_changed' toNode='ArmAngle' toField='set_rotation'></ROUTE>
What you are describing sounds like animation keys or transform key frames.
You can define these in a modeller like Blender and export them or generate them programatically.
But generally, what you are describing from x3d would have to be a layer built on top of three if you really want that style of interface, but honestly, it's pretty straightforward to use the scene graph style of manipulation.. i.e. finding an object and setting its position and rotation.. OR defining an animation in a modeller and then calling that animation. The advantage of using animations is that you can then blend between them.
You CAN name Objects in three.. so for instance you could name your arm.. and then find it using scene.getObjectByName("arm"). getObjectByName is a method of all Object3Ds.

Original skeleton position (Fbx import)

I was thinking that you need a deformer to read the clusters etc to be able to get the original (usually T pose) position of the skeleton.
Also FBX supports poses etc but never had a file that implemented it.
But my surprise was that importing an fbx file into 3dsmax without any mesh inside if I uncheck "animation" I get the T pose.
Any idea about it?
Thank you in adavnce
FbxCluster has GetTransformMatrix and GetTransformLinkMatrix. The former returns the original transform of the bone (that should be used to initialize the skinning), and the latter the corresponding orientation of the skinned node. Additionally, the skin node can also have "geometric rotation". I don't think there's anything more than that.

Blender MakeHuman to Three.js

I'm trying to integrate a animated 3D character in a Web navigator.
I use MakeHuman 1.02 to create a character which I import in Blender 2.74 in .mhx format.
I retarget to a BVH using the MakeWalk plugin for Blender. It's for the motion.
When I try to export the character in .json format (three.js), the following error appears :
MakeHuman is not a valid mesh object.
A mesh object is an object that we can modify properties or vertices, isn't it ?
I try others format like .dae format (collada) but it seems that the navigators doesn't find the skeleton and the textures of the character (even if they are in the same directory) necessary for the character's motion.
How to get the character like a mesh object ? Or somebody knows another process to success ?
Like Erica pointed out, you need to have a mesh selected to export it. The problem with this is it doesn't seem to work if you have multiple meshes. Only one will export. This is a problem when using MakeHuman because their clothes are separate meshes.
One way to fix this is to select all meshes and combine them into one (I believe that's CTRL + J). However, you'd have to somehow merge all your texture files into one big one and I have no idea how to do that.
What I do is to export the entire scene. Then it doesn't matter what is selected. All meshes get exported. You can load it using either the ColladaLoader, which I would recommend since you're retargeting to a BVH (worked great for me), or the new ObjectLoader.
If you have your own Scene object on the page that you want to use, you can still load the scene created by the exporter, traverse it to get the items you care about, and add those items to your scene that will display on the page.

How do I convert a ms3d model to three.js?

I'm trying to convert this model to the three.js model format:
http://tf3dm.com/3d-model/ninja-48864.html
Here's what i've tried so far:
I've imported the ms3d file in blender using the default addon. In blender, animations and mesh look correct; however, bones are only rendered as lines. Then I exported it to js using the three.js exporter. This results in a correct mesh, but the animation is not correctly exported. Only bone positions are exported (which are only rarely used in this specific model), NO rotations at all (except for a few identity quaternions).
It seems I have to modify the model in blender somehow, but since I'm a complete novice in 3d modelling, I'm kind of lost. I've also looked at other questions regarding blender+three.js but none of the tips (apply location/rotation/scale etc.) made a difference. It might also be a bug in the three.js exporter.
Can anybody help me do the conversion, one way or the other?
A nice Python utility is available for converting ms3d format to JSON format.
The link is: https://github.com/pyalot/parse-3d-files/blob/master/ms3d/convert.py
You can easily render this JSON model using THREE.JSONLoader() in three.js
Thanks.

exporting Bump and Specular maps

I have seen the new MeshPhongMaterial Bump and Specular highlights, and can't wait to get them into my game engine.
Currently i am using the python converter to convert an OBJ file into a .js file. However release 51 exporter doesn't seem to handle these materials.
I am also concerned that most of my meshes have 2 or more materials, and are using MeshFaceMaterial.
Will changing to MeshPhongMaterial break the multiple textures?
Should i use a different exporter to achieve this?
What is the best workflow to convert from .3ds files with Bump and Specular maps?
Should i wait a while for this topic to settle down?
I'm assuming you already use a diffuse texture (Lambert material perhaps?) and as such have also exported texture coordinates.
You can add mapBump and mapSpecular properties manually to the materials in question in the .js model file. They are strings pointing to the textures just like mapDiffuse. Also change the shading property to "Phong", and you should be good to go, though you might also want to tweak specularCoef and colorSpecular material properties.
Simply switching material type won't break the face materials.

Resources