var cubes = 
const boxGeometry = new THREE.BoxGeometry(1,1,1);
const boxBufferGeometry = BufferGeometryUtils.mergeVertices(new THREE.BufferGeometry().copy(boxGeometry))
var geometry1 = boxBufferGeometry.clone();
var geometry2 = boxBufferGeometry.clone();
var matrix1 = new THREE.Matrix4().makeTranslation(0, 0, 0);
var matrix2 = new THREE.Matrix4().makeTranslation(0, 0, 3);
var mergedGeometry = BufferGeometryUtils.mergeBufferGeometries(cubes);
var mesh = new THREE.Mesh(mergedGeometry, new THREE.MeshStandardMaterial());
The mesh is made this way to avoid having multiple calls.
I’m trying to rotate each cube around each own center Y-axis with just one draw call but I can’t figure out how.
Currently rotating them like this: mesh.rotation.y += 0.01;
The cube that’s located at (0,0,0) rotates around its own center Y-axis which is the same as the world’s origin but the other one at (0, 0, 3) rotates around the world’s origin Y-axis.
I want the one at (0, 0, 3) to stay at (0, 0, 3) and rotate its own center Y-axis.
I’d appreciate if you could provide some working code example.
I know there’s that, but don’t know how to rotate around the local center y-axis.
As I wrote in the topic’s description, a working example is appreciated.
Would you be able to provide some code?
Hey @prisoner849 how would you do this without mat4 being sent as a uniform. What would be the change here to put this on the InstanceAttribute on the shader and avoid 256 max_vertex limit? Would you just need to add a UV Buffer to the matrix of the BatchedMesh and then pass to the shader?
I wanted to use instancedAttribute. Not uniform. My case was a thousands of words. I dont even think calling them words is really appropriate because technically they are just a lot of unique geometries. Instanced was a much cleaner solution.
You really should do a section on Shaders for InstancedAttributes and using merged bufferGeometries with InstancedAttributes. By far one of the more complex usecases that really doesn’t get enough attention.