[File] [PATCH] [PATCH] of Magdir/gltf for binary glTF assets

yakoyoku at gmail.com yakoyoku at gmail.com
Thu Apr 8 21:08:34 UTC 2021


From: Martin Reboredo <yakoyoku at gmail.com>

Hi,
while editing games/demos with the Godot engine which supports the official glTF format [1] from the Khronos Group, `file(1)` seems to only
recognize the `*.gltf` files (JSON data as the spec dictates) but the binary `*.glb` files get the usual `data` and
`application/octet-stream`.

The GLB File Format Specification [2], which mentions to use the `model/gltf-binary` MIME type, describes the following layout for the
binary files:

 0                   1
 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+
| magic |version|  len  |
+-+-+-+-+-+-+-+-+-+-+-+-+
|        chunk#0        |
|          ...          |
+-+-+-+-+-+-+-+-+-+-+-+-+
|        chunk#1        |
|          ...          |
+-+-+-+-+-+-+-+-+-+-+-+-+

Where `magic` is the ASCII string `glTF`, `version` the glTF version, `len` the length in bytes of the glTF asset. These three fields are
also shared with the `KHR_binary_glTF` glTF 1.0 extension [3].

Links:
- 1: https://github.com/KhronosGroup/glTF
- 2: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification
- 3: https://github.com/KhronosGroup/glTF/tree/master/extensions/1.0/Khronos/KHR_binary_glTF

Best Regards,
    -> Martin Reboredo

Signed-off-by: Martin Reboredo <yakoyoku at gmail.com>
---
 magic/Magdir/gltf | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 magic/Magdir/gltf

diff --git a/magic/Magdir/gltf b/magic/Magdir/gltf
new file mode 100644
index 00000000..751d7f43
--- /dev/null
+++ b/magic/Magdir/gltf
@@ -0,0 +1,12 @@
+
+#------------------------------------------------------------------------------
+# $File: gltf,v 1.0 2021/04/08 21:58:26 christos Exp $
+# gltf:  file(1) magic for glTF assets
+#
+# glTF (GL Transmission Format). The specification is at
+# https://github.com/KhronosGroup/glTF
+
+0	string		glTF		glTF binary asset
+>4	lelong		x		\b, version %d
+>8	lelong		x		\b, length %d bytes.
+!:mime	model/gltf-binary
-- 
2.30.2



More information about the File mailing list