Opened 4 years ago

Closed 4 years ago

#6403 closed enhancement (fixed)

Add a centering option when saving GLTF

Reported by: phil.cruz@… Owned by: Tom Goddard
Priority: moderate Milestone:
Component: Input/Output Version:
Keywords: Cc: Elaine Meng
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Phil Cruz mentioned in today's NIAID / ChimeraX meeting that he needed to shift the origin for a ChimeraX RNA polymerase model exported as GLTF because it was positioned far from 0,0,0 and the GLTF viewer he was using wanted to center and rotate about 0,0,0. Elaine explained how to fix this problem with the "move" command after determining the coordinates of the center.

Would be useful if the GLTF export could shift the scene so 0,0,0 is at the center of the bounding box of the models. Maybe this should even be the default.

Another case where recentering is sometimes desirable is solvating a protein for MD where the box solvating code is happier if the molecule is centered at 0,0,0.

Change History (2)

comment:1 by Tom Goddard, 4 years ago

There already is a "center" option when saving GLTF. For example,

save test.glb center 0,0,0

puts the center of the bounding box of the scene at 0,0,0 in the exported GLTF.

There was a bug in this "center" option causing it to give an error. It must have not been used in a long long time. I fixed that bug, available in tonight's daily build.

I am not able to test if this solves the problem Phil Cruz mentioned because both uncentered and centered GLTF files in BabylonJS Sandbox work fine with the GLTF centered in the view and rotating about its center. So it must have been some other GLTF viewer that had problems with center being far from 0,0,0.

Phil can you test the "center" option with the GLTF viewer that has trouble with scenes centered far from the origin? And can you advise if you think "center 0,0,0" should be the default when saving GLTF?

comment:2 by Tom Goddard, 4 years ago

Cc: Elaine Meng added
Resolution: fixed
Status: assignedclosed

Fixed.

Made the "center" option for the save command for GLTF format accept true, false or x,y,z and the new default is true. Formerly only x,y,z was accepted and the default was that the scene was written with coordinates matching the ChimeraX scene coordinates (equivalent to the current "center false").

The center true option is the same as "center 0,0,0". If "center x,y,z" is used then the GLTF output has the center of the scene bounding box have position x,y,z in the GLTF file.

Note: See TracTickets for help on using tickets.