#Get Geometry from BatchedMesh

6 messages · Page 1 of 1 (latest)

gritty wind
#

Does anyone ever successfully extract geometry from BatchedMesh with .getGeometryRangeAt ? Why isn't there a method getGeometryAt(geometryId) : BufferGeometry?

gritty wind
#

Get Geometry from BatchedMesh

sacred spoke
#

when you do addInstance() save the instanceID it returns so you can refer to it later .


const geoId= batchedMesh.addGeometry(geometry)
...
const instanceID=batchedMesh.addInstance(geoId)
batchedMesh.setMatrixAt(instanceID, matrix)
batchedMesh.setVisibleAt(instanceID, false)

i guess this getGeometryAt method is not there since we know what geometry was added at which id already ?

gritty wind
#

I need export to GLB only meshes selected by user. I have some trouble to extract geometry from BatchedMesh. I am trying to build mesh from getGeometryRangeAt.

sacred spoke
#

ahh okay ,

console log these two keys

batchedMesh._geometryInfo // key is geometry id and value is the geometry used
batchedMesh._instanceInfo // key is the instance id and value has {"geometryIndex": 0} , use this geometryIndex to get the geometry from the _geometryInfo dictionary

and use batchedMesh.getMatrixAt() to get the transforms used by the geometry

clone the geometry and use geometry.applyMatrix4() to apply the transforms and make a new Mesh from it

gritty wind
#

So I have found solution of my problem. In geometryInfo it's not really geometry stored (missing normal & position) so I need to retrieve this information from batchedMesh attributes position & normal.