Can GLBufferAttribute be used with index?

Can GLBufferAttribute be used with index?
If so, do anyone know about a working sample?

Only found this one, but its not using setIndex with buffer geometry
https://threejs.org/examples/?q=GLBufferAttribute#webgl_buffergeometry_glbufferattrib

Wanted to see if it was possible to just keep the index on GPU… not browser and GPU.

Any anyone have any tips for me, then thx :slight_smile:

look like I can call .onUpload to dispose the array on browser side.

So I might not need the GLBufferAttribute like I though :slight_smile:

To answer this question: Yes, GLBufferAttribute can be used as the index buffer attribute.

Thx for taking the time to reply.

Have some questions if you have time (Im no expert, so sorry if the questions are weird :joy:)

1:
Do you know of any samples using it, only found on position?

Dont have any sample to show atm, but it gave me all kinds of errors.
I tried something like this, Im I close :slightly_smiling_face:?

const buffer= gl.createBuffer();
gl.bindBuffer( gl.ELEMENT_ARRAY_BUFFER, buffer);
gl.bufferData( gl.ELEMENT_ARRAY_BUFFER, new UintArrayArray( myIndexArr), gl.STATIC_DRAW );
const indexAtt = new THREE.GLBufferAttribute( pos, gl.UNSIGNED_INT, 1, 4, myIndexArr.length);
geometry.setIndex( indexAtt  );

2:
Using the .onUpload solved a lot on clearing memory usage from browser side.
But when I dont use GLBufferAttribute I cant find a good way to get access to the buffer again.

Is there any way we have access to this ?
three.js/WebGLAttributes.js at master · mrdoob/three.js (github.com)

Or is there other way to get the buffer I can use with gl.bindBuffer
Plan was to use gl.bufferSubData to update different parts of a buffer, so I dont need to

From what I can see the WebGlAttributes is just private here:
three.js/WebGLRenderer.js at 2d9a9f0b546aaf22dc0dcbfe56402bee075b9509 · mrdoob/three.js (github.com)

May I ask why do you need access to the raw VBOs in the first place? GLBufferAttribute is only meant for special use cases.

Normally, you should let the engine handle any buffer updates and not work with the WebGL context.

Have large merged geometries, so want to try and get memory usage down, and still be able to modify parts of the buffers/not re-upload entires buffers.
Mostly for setting /hiding parts of merged geometry.

Atm largest model is 1-2gig on gpu, so having that in browser + metadata is starting to get very large.

Good chance what Im trying to do will be slower then replacing entire array :joy:
So prob should try and stick to main api, might be easier to use webgpu in the end.:slightly_smiling_face:
When I think about it I could prob just store the index/attributes in indexdb if I need to read them/not have them in memory.

Maybe webgpu will help a lot and I dont need to merge so much/easier to set colors etc :

Do you know if this is considered ?
BatchedMesh: Proposal · Issue #22376 · mrdoob/three.js (github.com)