Open capnm opened 5 years ago
Implementing this without adding scaling to the transform matrices would be great. Otherwise we end up using crazy scale numbers in engine.
@Wahooney The unit scale in core glTF 2.0 is locked to 1 meter scale. I could imagine a glTF Extension being written to support other scales, but in general the intention was that various glTF models should all be authored to the same scale, the same up vector, etc., so they all work together nicely.
Assuming an implementation by scaling all locations (as opposed to inserting a node at the roots), the following case significantly complicates things
For example, one mesh instantiated in two scenes with different unit scales would need to be exported as two meshes (but ideally sharing everything except the POSITION
accessors).
This is frustrating because even individually these conditions are probably uncommon but this one case causes lots of complexity.
For the importer side, if #423 is done so that everything is always placed in one Blender scene, this would be much easier (currently in 2.8 everything is already placed in one Blender scene, but that's apparently just to workaround a bug).
By the way, this is an issue for framerate (ie. frame to second unit conversion) too.
I guess an initial implementation could just use the unit scale for the current scene at the time of import/export. On the importer side, I can say that would be easy to implement.
This is now done for the importer.
For the exporter, first step would be someone should refactor so that all coordinate conversions are done by functions like location_blender_to_gltf
(or convert_swizzle_location
or whatever you want to call it). Grepping for gltf2_blender_export_keys.YUP
will help find places that need to be changed.
Then those functions can be updated to take into account the unit scale.
hi i would also like to second that every time i export for web AR, the scale messed up crazy large. I hv to set world scale to 0.00001 in theory to get it right but blender cant handle such scale(the smallest world scale i can get to is 0.0001). I have to apply all modifiers, set world scale to the smallest world scale i can get to is 0.0001, and manually down scale it by 0.01 in order to export things to web AR with meaningful scale.
The exporter and importer does not take into account the Blender scenes "Unit Scale" and exports and imports objects in a wrong size. It only works correctly if the scene unit scale is 1.0.