indirectBatchGeometryId

@three-blocks/coreWebGPU
indirectBatchGeometryId(batchMesh : IndirectBatchedMesh, idNode : Node<int>) : Node<int>

Access the geometry ID for a given instance in an {@link IndirectBatchedMesh}.

Use this to apply different material effects per geometry type (e.g., different colors for boxes vs spheres in the same batched mesh).

Example: Per-geometry-type coloring

Parameters
The batched mesh instance.
idNodeoptionalNode<int>
Instance id to sample. If not provided, resolves automatically using survivorIdSB.
Returns
Node<int> — Geometry ID for the instance.
Example
import { IndirectBatchedMesh, indirectBatch, indirectBatchGeometryId } from '@three-blocks/core';
import { vec3 } from 'three/tsl';
import { MeshStandardNodeMaterial } from 'three/webgpu';

const material = new MeshStandardNodeMaterial();
const mesh = new IndirectBatchedMesh(1000, 10000, 30000, material);

const boxId = mesh.addGeometry(new BoxGeometry(1, 1, 1));
const sphereId = mesh.addGeometry(new SphereGeometry(0.5));

// Color based on geometry type
const geomId = indirectBatchGeometryId(mesh);
const colors = uniformArray([
	new THREE.Vector3(1.0, 0.3, 0.2),  // Red for boxes
	new THREE.Vector3(0.2, 0.8, 0.4),  // Green for spheres
	new THREE.Vector3(0.3, 0.5, 1.0)   // Blue for cones
], 'vec3');
material.colorNode = vec4(colors.element(geomId), 1.0);