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.
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.