When merging boxBufferGeometry with BufferGeometry getting null value

Hello All,

I am using BufferGeometryUtils to merge the buffer geometries but i am getting null

BufferGeometryUtils.mergeBufferGeometries( geometries )

Here geometries contain an array

Blockquote
[
{
“metadata”: {
“version”: 4.5,
“type”: “BufferGeometry”,
“generator”: “BufferGeometry.toJSON”
},
“uuid”: “55C9405E-968A-4F91-A76B-985C5E69BF62”,
“type”: “BufferGeometry”,
“data”: {
“attributes”: {
“position”: {
“itemSize”: 3,
“type”: “Float32Array”,
“array”: [
0,
12,
0,
64.80000305175781,
12,
0,
64.80000305175781,
12,
-39.16999816894531,
64.80000305175781,
12,
-39.16999816894531,
0,
12,
-39.16999816894531,
0,
12,
0,
0,
12,
-54.16999816894531,
64.80000305175781,
12,
-54.16999816894531,
64.80000305175781,
12,
-93.33999633789062,
64.80000305175781,
12,
-93.33999633789062,
0,
12,
-93.33999633789062,
0,
12,
-54.16999816894531,
0,
12,
-108.33999633789062,
64.80000305175781,
12,
-108.33999633789062,
64.80000305175781,
12,
-147.50999450683594,
64.80000305175781,
12,
-147.50999450683594,
0,
12,
-147.50999450683594,
0,
12,
-108.33999633789062,
0,
12,
-162.50999450683594,
64.80000305175781,
12,
-162.50999450683594,
64.80000305175781,
12,
-201.67999267578125,
64.80000305175781,
12,
-201.67999267578125,
0,
12,
-201.67999267578125,
0,
12,
-162.50999450683594,
0,
12,
-216.67999267578125,
64.80000305175781,
12,
-216.67999267578125,
64.80000305175781,
12,
-255.85000610351562,
64.80000305175781,
12,
-255.85000610351562,
0,
12,
-255.85000610351562,
0,
12,
-216.67999267578125,
0,
12,
-270.8500061035156,
64.80000305175781,
12,
-270.8500061035156,
64.80000305175781,
12,
-310.0199890136719,
64.80000305175781,
12,
-310.0199890136719,
0,
12,
-310.0199890136719,
0,
12,
-270.8500061035156,
0,
12,
-325.0199890136719,
64.80000305175781,
12,
-325.0199890136719,
64.80000305175781,
12,
-364.19000244140625,
64.80000305175781,
12,
-364.19000244140625,
0,
12,
-364.19000244140625,
0,
12,
-325.0199890136719,
0,
12,
-379.19000244140625,
64.80000305175781,
12,
-379.19000244140625,
64.80000305175781,
12,
-418.3599853515625,
64.80000305175781,
12,
-418.3599853515625,
0,
12,
-418.3599853515625,
0,
12,
-379.19000244140625,
0,
12,
-433.3599853515625,
64.80000305175781,
12,
-433.3599853515625,
64.80000305175781,
12,
-472.5299987792969,
64.80000305175781,
12,
-472.5299987792969,
0,
12,
-472.5299987792969,
0,
12,
-433.3599853515625,
0,
12,
-487.5299987792969,
64.80000305175781,
12,
-487.5299987792969,
64.80000305175781,
12,
-526.7000122070312,
64.80000305175781,
12,
-526.7000122070312,
0,
12,
-526.7000122070312,
0,
12,
-487.5299987792969,
0,
12,
-541.7000122070312,
64.80000305175781,
12,
-541.7000122070312,
64.80000305175781,
12,
-580.8699951171875,
64.80000305175781,
12,
-580.8699951171875,
0,
12,
-580.8699951171875,
0,
12,
-541.7000122070312,
0,
12,
-595.8699951171875,
64.80000305175781,
12,
-595.8699951171875,
64.80000305175781,
12,
-635.0399780273438,
64.80000305175781,
12,
-635.0399780273438,
0,
12,
-635.0399780273438,
0,
12,
-595.8699951171875,
0,
12,
-650.0399780273438,
64.80000305175781,
12,
-650.0399780273438,
64.80000305175781,
12,
-689.2100219726562,
64.80000305175781,
12,
-689.2100219726562,
0,
12,
-689.2100219726562,
0,
12,
-650.0399780273438,
0,
12,
-704.2100219726562,
64.80000305175781,
12,
-704.2100219726562,
64.80000305175781,
12,
-743.3800048828125,
64.80000305175781,
12,
-743.3800048828125,
0,
12,
-743.3800048828125,
0,
12,
-704.2100219726562,
65.80000305175781,
12,
0,
130.60000610351562,
12,
0,
130.60000610351562,
12,
-39.16999816894531,
130.60000610351562,
12,
-39.16999816894531,
65.80000305175781,
12,
-39.16999816894531,
65.80000305175781,
12,
0,
65.80000305175781,
12,
-54.16999816894531,
130.60000610351562,
12,
-54.16999816894531,
130.60000610351562,
12,
-93.33999633789062,
130.60000610351562,
12,
-93.33999633789062,
65.80000305175781,
12,
-93.33999633789062,
65.80000305175781,
12,
-54.16999816894531,
65.80000305175781,
12,
-108.33999633789062,
130.60000610351562,
12,
-108.33999633789062,
130.60000610351562,
12,
-147.50999450683594,
130.60000610351562,
12,
-147.50999450683594,
65.80000305175781,
12,
-147.50999450683594,
65.80000305175781,
12,
-108.33999633789062,
65.80000305175781,
12,
-162.50999450683594,
130.60000610351562,
12,
-162.50999450683594,
130.60000610351562,
12,
-201.67999267578125,
130.60000610351562,
12,
-201.67999267578125,
65.80000305175781,
12,
-201.67999267578125,
65.80000305175781,
12,
-162.50999450683594,
65.80000305175781,
12,
-216.67999267578125,
130.60000610351562,
12,
-216.67999267578125,
130.60000610351562,
12,
-255.85000610351562,
130.60000610351562,
12,
-255.85000610351562,
65.80000305175781,
12,
-255.85000610351562,
65.80000305175781,
12,
-216.67999267578125,
65.80000305175781,
12,
-270.8500061035156,
130.60000610351562,
12,
-270.8500061035156,
130.60000610351562,
12,
-310.0199890136719,
130.60000610351562,
12,
-310.0199890136719,
65.80000305175781,
12,
-310.0199890136719,
65.80000305175781,
12,
-270.8500061035156,
65.80000305175781,
12,
-325.0199890136719,
130.60000610351562,
12,
-325.0199890136719,
130.60000610351562,
12,
-364.19000244140625,
130.60000610351562,
12,
-364.19000244140625,
65.80000305175781,
12,
-364.19000244140625,
65.80000305175781,
12,
-325.0199890136719,
65.80000305175781,
12,
-379.19000244140625,
130.60000610351562,
12,
-379.19000244140625,
130.60000610351562,
12,
-418.3599853515625,
130.60000610351562,
12,
-418.3599853515625,
65.80000305175781,
12,
-418.3599853515625,
65.80000305175781,
12,
-379.19000244140625,
65.80000305175781,
12,
-433.3599853515625,
130.60000610351562,
12,
-433.3599853515625,
130.60000610351562,
12,
-472.5299987792969,
130.60000610351562,
12,
-472.5299987792969,
65.80000305175781,
12,
-472.5299987792969,
65.80000305175781,
12,
-433.3599853515625,
65.80000305175781,
12,
-487.5299987792969,
130.60000610351562,
12,
-487.5299987792969,
130.60000610351562,
12,
-526.7000122070312,
130.60000610351562,
12,
-526.7000122070312,
65.80000305175781,
12,
-526.7000122070312,
65.80000305175781,
12,
-487.5299987792969,
65.80000305175781,
12,
-541.7000122070312,
130.60000610351562,
12,
-541.7000122070312,
130.60000610351562,
12,
-580.8699951171875,
130.60000610351562,
12,
-580.8699951171875,
65.80000305175781,
12,
-580.8699951171875,
65.80000305175781,
12,
-541.7000122070312,
65.80000305175781,
12,
-595.8699951171875,
130.60000610351562,
12,
-595.8699951171875,
130.60000610351562,
12,
-635.0399780273438,
130.60000610351562,
12,
-635.0399780273438,
65.80000305175781,
12,
-635.0399780273438,
65.80000305175781,
12,
-595.8699951171875,
65.80000305175781,
12,
-650.0399780273438,
130.60000610351562,
12,
-650.0399780273438,
130.60000610351562,
12,
-689.2100219726562,
130.60000610351562,
12,
-689.2100219726562,
65.80000305175781,
12,
-689.2100219726562,
65.80000305175781,
12,
-650.0399780273438,
65.80000305175781,
12,
-704.2100219726562,
130.60000610351562,
12,
-704.2100219726562,
130.60000610351562,
12,
-743.3800048828125,
130.60000610351562,
12,
-743.3800048828125,
65.80000305175781,
12,
-743.3800048828125,
65.80000305175781,
12,
-704.2100219726562
],
“normalized”: false
}
}
}
},
{
“metadata”: {
“version”: 4.5,
“type”: “BufferGeometry”,
“generator”: “BufferGeometry.toJSON”
},
“uuid”: “EE6E26A5-CD7A-4174-92A5-7E780D9AE80A”,
“type”: “BoxBufferGeometry”,
“width”: 5,
“height”: 24,
“depth”: 5
}
]

Please let me know whats wrong here

The docs say:
Merges a set of geometries into a single instance. All geometries must have compatible attributes. If merge does not succeed, the method returns null.

All merging geometries have to have the same set of attributes and have to be all indexed or all non-indexed. You can’t merge indexed and non-indexed geometries.

1 Like

So here boxBuffer is an non indexed geometry is there an conversion possible to make them compatible.

I think this is usefull


but how to do this

Looks like your BufferGeometry is non-indexed.
So you can call .toNonIndexed() on BoxBufferGeometry (as that geometry is an indexed one).

No same issue , i tried vise versa too.

And i have the position vector for each geometry i am using it like this

box1.position.copy(position)

box2.position.copy(position)

const mesh = new THREE.Mesh(BufferGeometryUtils.mergeBufferGeometries( [box1.geometry, box2.geometry]), material)

but both the boxes come together

Please can you help me with this position first so i can quickly share a pen for a better help

Thanks