i find a lot of old tutorials using Geometry and merging other Shapes into it. I am mostly able to upgrade them to current three.js versions by using BufferGeometry and change the code a little, like use position.setX(index, value) to manipulate vertextes directly. Also it seems easier now to merge geometries, with the merge method, there is just one simple problem: when i merge a geometry, for example a box, into BufferGeometry, the BufferGeometrys attributes is empty: Edit fiddle - JSFiddle - Code Playground
What am i getting wrong? If i merge a BoxGeometry into an empty BufferGeometry, i would expect the buffer to contain all atributes from the box. it stays empty.
BufferGeometry cannot be resized, so merging just overwrites up to the original vertex or face count. Instead, use BufferGeometryUtils.mergeBufferGeometries to create a new BufferGeometry from an array of inputs.
THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index 1. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.
which is weird because its all boxes, that are just randomly stuffed together to create random building shapes.
Ah, i think they just merge their boxes into empty geometries to get a deep copy of it, but why not just clone it? The old Geometry had that method already.
From the linked Geometry, I can create a single connected mesh. With different materials. In this example I started from, this was especially important. Pino
In the MultiformGeometry example, you can see that you can easily move/rotate the composite mesh using the move/rotate keys.
if you’re merging an array of geometries, there’s no reason to include an empty geometry in the list I think? the geometries do need to be ‘compatible’, having the same types of attributes and indices.