I'm working on a glTF, precisely I'm trying to animate a "static" mesh exported from Blender directly acting on its JSON. In doing so, I'm following the logic used in this tutorial , where a triangle is animated adding a new buffer, containing only data regarding time and rotation coordinates. Along with the new buffer, also the animations array, the bufferviews related to the new buffer, and the new accessors are added to animate the initial static triangle .
Right now, I'm trying to animate a plane, working on the input JSON obtained by simply creating the plane in Blender and exporting it in the glTF format. Using the same data URI seen in the previously mentioned tutorial regarding the rotating triangle:
{ "byteLength": 100, "uri": "data:application/octet-stream;base64,AAAAAAAAgD4AAAA/AABAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAD0/TQ/9P00PwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAPT9ND/0/TS/AAAAAAAAAAAAAAAAAACAPw==" }
I've been able to apply successfully that rotation to the plane .
The problem is that, always following the same logic, I'm having hard times in creating animations different from the one that is used in the tutorial so, basically I'm having problems in creating data URI containing information about time and animation. The procedure I'm using in creating those data URIs, consists of writing times and coordinates in a file saved with no extension (to have a generic binary data application/octet-stream) , and then converting this file in a data URI with an online converter .
Here you can see how I write the file to be converted in data URI that contains coordinates and time, and here you can see how the translation written in previous link doesn't work in the initial glTF of the plane. I suppose the error is the way i write the time and coordinates. How should I write those coordinates and time to be converted in data URI to be properly read and executed by the glTF?
I've even tried to separate time and coordinates by creating two different buffers, one referring to time and one referring to animation, to avoid the problem of making mistakes in setting the byteOffset property in the accessors referring to animation and time.
Here you can see the code of a translation applied to the same plane using the two new buffers referring to time and translation.
The structure of the starting file, later converted in data URI, containing information regarding time follows:
(0.0),
(0.25),
(0.5),
(0.75),
(1.0)
The structure of the starting file, later converted in data URI, containing the translation coordinates follows:
{ 0.0, 0.0, 0.0 },
{ 2.0, 0.0, 0.0 },
{ 6.0, 0.0, 0.0 },
{ 6.0, 2.0, 0.0 },
{ 8.0, 4.0, 0.0 }
Thanks in advance for your help :)