I am trying to merge two gltf assets and I am using the sayduck gltf pipeline to achieve it. The problem is that I need one of the assets to be away from the other assets. eg. cat (0, 0, 0) and dog (10, 0, 0) so as to place them side by side for comparison
I have tried using three.js on the server side (node.js) and it is a bit hard to get the gltf parser to work on the server side. It would be great if it is achievable without using three.js.
You won't need to use a 3D rendering library like threejs to edit a glTF file serverside. For the simplest case (repositioning an object in a .gltf
file), you could just do:
const fs = require('fs');
// Read and parse file.
const gltfContent = fs.readFileSync('file.gltf', {encoding: 'utf8'});
const gltf = JSON.parse(gltfContent);
// Edit glTF asset.
const node = gltf.nodes.filter((n) => n.name === 'Cat')[0];
node.translation = [10, 0, 5];
// Write to disk.
fs.writeFileSync('file.gltf', JSON.stringify(gltf));
For more complex changes to a file, you'll want to either use an existing parsing/writing tool or learn about the glTF specification.