aframevr / aframe

:a: Web framework for building virtual reality experiences.
https://aframe.io/
MIT License
16.61k stars 3.94k forks source link

glTF import from Blender generates deep nesting breaking expected transform in local space #4601

Open tripdragon opened 4 years ago

tripdragon commented 4 years ago

Description:

Ill dig through the component source after this to make my own iff needed. Also I dont know if this is an issue with Blender's implementation of glTF export or if this is the intended method of object import, but its broken to me when using Aframe Inspector

When I export a single object from blender that has a position transform not of 0,0,0 and import into aframe view with a basic <a-entity gltf-model="#vase01"></a-entity> The object lands where it should but i am expecting its transform position to be not 0,0,0 So when I open the Scene Inspector to visually tweak the object I see that its position is 0,0,0 meaning its in localSpace of some parent. And since I can not drill through the parenting in the Aframe Inspector visual tweaks are not workable for say rotations.

In the Chrome web inspector on the dom element I have to dig down with $0.object3D.children[0].children[0].position to get to the actual mesh object with the vector3 position giving values not 0,0,0 but this does not fix the Aframe inspector tool With $0.object3D.type == "Group" $0.object3D.children[0].type == "Scene" $0.object3D.children[0].children[0].type == "Mesh" I know each of these is just an Object3D with extras but a second scene should not be a parent within a group

As a cross test the same file in https://gltf-viewer.donmccurdy.com/ does load the model into the center of the world as expected

debugging link https://pumped-fluffy-llama.glitch.me/ use the Aframe inspector contrl+alt+i

Sample of the gltf file I know I have 4 scenes in here, Maybe Blender export should reduce these, but its gonna be typical workflow for an artist, I make a scene of many, i have an asset in the view somewhere in world space I select an object and export. I expect that when I import I could set an attribute as retain original transforms(position) true:false false defaults to world space 0,0,0 so I can move it around then with other stuff. I can handle this in an onload routine callback but that defeats to instant easy use of Aframe

Sample gltf file { "asset" : { "generator" : "Khronos glTF Blender I/O v1.1.46", "version" : "2.0" }, "scene" : 3, "scenes" : [ { "name" : "Scene" }, { "name" : "Scene.001" }, { "name" : "Scene.002" }, { "name" : "Scene.003", "nodes" : [ 0 ] } ], "nodes" : [ { "mesh" : 0, "name" : "Cube.046", "translation" : [ 0.6578742265701294, 0.5410311222076416, 4.062383651733398 ] } ], "meshes" : [ { "name" : "Cube.002", "primitives" : [ { "attributes" : { "POSITION" : 0, "NORMAL" : 1, "TEXCOORD_0" : 2 }, "indices" : 3 } ] } ], "accessors" : [ { "bufferView" : 0, "componentType" : 5126, "count" : 40, "max" : [ 1.9049890041351318, 1.4015837907791138, 1 ], "min" : [ -1.9856455326080322, -1, -1.0906741619110107 ], "type" : "VEC3" }, { "bufferView" : 1, "componentType" : 5126, "count" : 40, "type" : "VEC3" }, { "bufferView" : 2, "componentType" : 5126, "count" : 40, "type" : "VEC2" }, { "bufferView" : 3, "componentType" : 5123, "count" : 60, "type" : "SCALAR" } ], "bufferViews" : [ { "buffer" : 0, "byteLength" : 480, "byteOffset" : 0 }, { "buffer" : 0, "byteLength" : 480, "byteOffset" : 480 }, { "buffer" : 0, "byteLength" : 320, "byteOffset" : 960 }, { "buffer" : 0, "byteLength" : 120, "byteOffset" : 1280 } ], "buffers" : [ { "byteLength" : 1400, "uri" : "data:application/octet-stream;base64,AACAvwAAgD8AAIC/oin+v8LJ2T7Cydm+oin+v8LJ2T7Cydk+AACAvwAAgD8AAIA/rtbzPxlnsz82m4u/AACAPwAAgL8AAIC/AACAvwAAgL8AAIC/AACAvwAAgD8AAIC/AACAPwAAgL8AAIA/AACAPwAAgL8AAIC/rtbzPxlnsz82m4u/AACAPwAAgD8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIA/AACAPwAAgL8AAIA/AACAPwAAgD8AAIA/AACAvwAAgL8AAIA/AACAvwAAgL8AAIC/AACAPwAAgL8AAIC/AACAPwAAgL8AAIA/AACAvwAAgD8AAIC/AACAvwAAgD8AAIA/AACAPwAAgD8AAIA/rtbzPxlnsz82m4u/oin+v8LJ2T7Cydm+oin+v8LJ2b7Cydm+oin+v8LJ2b7Cydk+oin+v8LJ2T7Cydk+oin+v8LJ2b7Cydm+AACAvwAAgL8AAIC/AACAvwAAgL8AAIA/oin+v8LJ2b7Cydk+AACAvwAAgD8AAIC/AACAvwAAgL8AAIC/oin+v8LJ2b7Cydm+oin+v8LJ2T7Cydm+oin+v8L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AAAAAAAMA+AAAAAAAAID8AAAAAAAAgPwAAAAAAAAEAAgAAAAIAAwAEAAUABgAEAAYABwAIAAkACgALAAgACgAMAA0ADgAMAA4ADwAQABEAEgAQABIAEwAUABUAFgAUABYAFwAYABkAGgAYABoAGwAcAB0AHgAcAB4AHwAgACEAIgAgACIAIwAkACUAJgAnACQAJgA=" } ] }

tripdragon commented 4 years ago

Errrrrmmmm You AND that glTF loader viewer link use THREE's DRACOLoader class of which is the original authors work https://github.com/aframevr/aframe/blob/d866f08ca067fb21647d3640a636ed74fc602f68/src/systems/gltf-model.js#L19

so he's doing some parsing afterwards. I could parse to the first scene and move each mesh to a Group

Sigh Zomg https://discourse.threejs.org/t/how-to-get-actual-mesh-position-in-gltf-scene/11536