mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.73k stars 35.38k forks source link

Blender exports just one action #5914

Closed hulf closed 9 years ago

hulf commented 9 years ago

Hi, perhaps someone had the same problem with exporting a model with 2 animations from Blender. I have read that: UPDATE 2: Currently THREE.js exports multiple actions using blender exporter, so this tutorial in not suitable for exporters for THREE.js versions r62 and higher. It should work well with versions r56 up to r61

In my model I have 2 animations: krilo1a, krilo2a. komar1 Both animations work separately and each one gets exported and works komar2 The export looks like this: "bones" : [{"parent":-1,"name":"krilo1a","pos":[0.217062,-0.429841,1.48519],"rotq":[0.589933,0.469901,-0.369392,0.542883],"scl":[1,1,1]}, (I posted the whole line, I thing not only the krilo4a bone data is missing, there also "]" missing at end.)

If I export them together what happens is:

While writing this I was thinking that I should try exporting another JSON with (krilo1a) deleated. This should give me the bone that I could add to the JSON with 2 animations. I will try that as a workaround until hopefully someone has a solution to this.

Thanks in advance.

repsac commented 9 years ago

Already being looked at https://github.com/mrdoob/three.js/issues/5829 https://github.com/mrdoob/three.js/issues/5582#issuecomment-70043430

hulf commented 9 years ago

Thanks, i will check out the threads. I tried to add the missing bone manually, since the animation was already there:

"bones": [{"parent":-1,"name":"krilo1a","pos":[0.217062,-0.429841,1.48519],"rotq":[0.589933,0.469901,-0.369392,0.542883],"scl":[1,1,1]}, {"parent":-1,"name":"krilo4a","pos":[-0.17425,-0.472335,1.50399],"rotq":[0.533728,-0.437982,0.413822,0.593345],"scl":[1,1,1]}],

It doesn't work.

hulf commented 9 years ago

I tried a dev exporter mentioned in this thread: #5829,https://github.com/mrdoob/three.js/archive/dev.zip. The file is not created, output: Traceback (most recent call last): File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\addons\io_threeinit.py", line 567, in execute exporter.export_scene(filepath, settings) File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\addons\io_three\exporterinit.py", line 16, in inner func(filepath, options, _args, *_kwargs) File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\addons\io_three\exporterinit.py", line 47, in exportscene scene.parse() File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\addons\io_three\exporter\scene.py", line 65, in parse self.parse_geometries() File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\addons\io_three\exporter\scene.py", line 151, in parse_geometries geo.parse() File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\addons\io_three\exporter\geometry.py", line 128, in parse self.parse_geometry() File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\addons\io_three\exporter\geometry.py", line 325, in __parse_geometry self.node) File "C:\Program Files\Blender Foundation\Blender\2.72\scripts\addons\io_three\exporter\base_classes.py", line 20, in __setitem raise exceptions.ThreeValueError(msg) io_three.exceptions.ThreeValueError: Value is an invalid data type: <class 'NoneType'> location: :-1

repsac commented 9 years ago

I misread your post and thought you were using the new exporter. FYI; the multiple animations is not yet supported in the new exporter. Am working on that.

Now on to the bones: Would need to see that scene to see how your rig/armature is setup.

Do you have a scene that you can share that recreates this error?

hulf commented 9 years ago

The blender file can be downloaded here: http://s000.tinyupload.com/?file_id=72464802249188189168

repsac commented 9 years ago

Update: https://github.com/mrdoob/three.js/issues/5582#issuecomment-71337806

repsac commented 9 years ago

So I looked at your scene and after addressing what were indeed some bugs that had to be addressed. I will note that your asset is made up of multiple nodes therefore the only export that would work is a scene export. I have not submitted a PR but you can find my branch here https://github.com/repsac/three.js/tree/io_three

hulf commented 9 years ago

I tried exporter v1.1.1 on the same model: "bones": [], "animations": "SphereGeometry.3.animations.json" "metadata": { "uvs": 1, "bones": 0, "vertices": 2061, "colors": 321, "generator": "io_three", "materials": 1, "type": "Geometry", "normals": 1969, "version": 3, "faces": 2218 },

hulf commented 9 years ago

I new version: "generator": "io_three", "version": 4.3. When using this options: 1 I get only a 400KB file, 1 material, no bones. If I select ( SCENE: Scene: on, Materials: on), the exported file is 14MB large, and does not get loaded: if ( mesh ) { console.log ("done")} there is nothing reported in the browser console.

The animations and bones are there. The JSON can be found here: http://s000.tinyupload.com/?file_id=07610071611631289488 Blender file: http://s000.tinyupload.com/?file_id=77429891536449940530

repsac commented 9 years ago

POSE animation exports (introduced in r67) are way bigger than REST exports. I am guessing that has something to do with the other properties like Frame index as time and Frame step were meant to reduce the amount of per-frame data being exported.

Additionally; try unchecking the new option at the bottom Indent JSON. That has had quite a difference.

repsac commented 9 years ago

Using this file https://github.com/mrdoob/three.js/issues/5914#issuecomment-70332640 I was able to export in both REST and POSE positions using the following settings.

Options

Skeletal animations: REST (317.48 KB) http://pastebin.com/5SQ9TSWY

Skeletal animations: POSE (333.60 KB) http://pastebin.com/xax8gPWh

repsac commented 9 years ago

Did some tests and realized that one of the materials is a MeshBasicMaterial

        "type": "MeshBasicMaterial",
        "color": 0,
        "depthTest": true,
        "depthWrite": true,
        "name": "Material",
        "emissive": 0,
        "vertexColors": false,
        "blending": "NormalBlending",
        "uuid": "FC9C3C1C-87E7-3748-8148-105003E5F3D5",
        "ambient": 0

In three this material does not have an ambient or emissive properties but since it is set in the JSON the loader is trying to set these properties. I removed them in the JSON and the scene did load tho the asset itself seems distorted.

hulf commented 9 years ago

Thanks for your efforts.

With your latest io_three:

repsac commented 9 years ago

If exporting Scene then you have to use ObjectLoader(). I disabled textures because none were sent with the file.

hulf commented 9 years ago
repsac commented 9 years ago

I am going to consider this issue resolved since the exporter does export multiple actions again. The asset does load correctly (as far as geometry goes). As far as automatic support of skinned meshes and textures go that is outside the scope of this issue.

screen shot 2015-02-11 at 9 23 18 pm