Maybe a ridiculous follow up question.
I had started my project a while ago so I was just going to pick it back up now but my last build is at r124 .
I see a lot of discussion on changing, THREE.Geometry to THREE.BufferGeometry. Is it not as simple as search and replace? Or does the complexity really apply if you have a lot of new code using the old function?
Where should I start? The structure of my folders is a bit different so it seems I just have to go one-by-one with the latest update and check for conflicts?
Thanks for replying so quickly guys! does that mean I should replace āTHREE.BufferGeometry().merge()ā with ā THREE.BufferGeometryUtils.mergeBufferGeometries() ?
or is `BufferGeometryUtilsā not part of the core ?
Yes, please use BufferGeometryUtils.mergeBufferGeometries(). And yes, BufferGeometryUtils is no part of the core. But you can import it from the examples directory. If you are working with the npm package, the ES6 import looks like so:
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js';
Thank you, iāve made the necessary changes but I run into the error: āCannot read properties of undefined (reading 'index')ā
which seems to originate from the BufferGeometryUtils.js file in line
28 : const isIndexed = geometries[ 0 ].index !== null;
could this be because the geometry Iām attempting to merge is not indexed?
Hereās a snippet of my code related to the issue for some context:
let cubeGeom = new THREE.BoxBufferGeometry()
let cubeMat = new THREE.MeshLambertMaterial()
let cubeMesh = new THREE.Mesh(cubeGeom, cubeMat);
BufferGeometryUtils.mergeBufferGeometries(cubeMesh.geometry, cubeMesh.matrix);
iāve omitted the parameter values in the parenthesis to make this reply shorter
The mergeBufferGeometries method takes an array of geometries as its first argument, and the second argument is usually false. āMergingā a single geometry would be the same as calling .clone() on that geometry. Any geometries given must all have the same data layout, i.e. either all or none should be indexed.