meshFor method
shape's mesh, for an entity scaled by scale (which counts only
for a texture tiled per metre); null when it has no triangles.
Implementation
GpuPrimitive? meshFor(Primitive3D shape, Vector3 scale) {
final uv = tilesInMetres(shape) ? _metres(scale) : ShapeUv.natural;
final key = (shape.shapeKey, uv.key);
final known = _meshes[key];
if (known != null) {
known.used = _frame;
return known.value;
}
final mesh = shape.buildMesh(uv);
if (mesh.triangleCount == 0) return null;
final gpu = uploader.uploadPrimitive(mesh.toPrimitive());
_meshes[key] = _Entry(gpu, _frame);
return gpu;
}