Skip to content

Commit 10d095d

Browse files
felixtrzmeta-codesync[bot]
authored andcommitted
fix(xr-input): use r165-style BatchedMesh to fix multiview compatibility on Quest
Summary: https://fb.workplace.com/groups/9002619286444376/permalink/25951799831099723/ Reviewed By: zjm-meta Differential Revision: D91860842 fbshipit-source-id: 2f45e5c440969bfedb20afb96a9073a25997b992
1 parent 1bfb810 commit 10d095d

File tree

2 files changed

+569
-6
lines changed

2 files changed

+569
-6
lines changed

packages/xr-input/src/visual/utils/flex-batched-mesh.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import { BatchedMesh, Group, Material, Matrix4, Mesh, Object3D } from 'three';
8+
import { Group, Material, Matrix4, Mesh, Object3D } from 'three';
9+
import { SimpleBatchedMesh } from './simple-batched-mesh.js';
910

1011
export class FlexBatchedMesh extends Group {
11-
private batchedMeshes = new Map<Material, BatchedMesh>();
12+
private batchedMeshes = new Map<Material, SimpleBatchedMesh>();
1213
private batchedIndices = new Map<Mesh, number>();
1314

1415
constructor(private refMesh: Object3D) {
@@ -34,7 +35,7 @@ export class FlexBatchedMesh extends Group {
3435
materialGroups.get(material)!.push(mesh);
3536
});
3637

37-
// Create a BatchedMesh for each material group
38+
// Create a SimpleBatchedMesh for each material group
3839
materialGroups.forEach((meshes, material) => {
3940
let geometryCount = 0;
4041
let vertexCount = 0;
@@ -46,18 +47,22 @@ export class FlexBatchedMesh extends Group {
4647
geometryCount++;
4748
});
4849

49-
const batchedMesh = new BatchedMesh(
50+
const batchedMesh = new SimpleBatchedMesh(
5051
geometryCount,
5152
vertexCount,
5253
indexCount,
5354
material,
5455
);
56+
// Disable frustum culling - controllers move dynamically and bounding volumes
57+
// may not update correctly, especially in multiview rendering
58+
batchedMesh.frustumCulled = false;
5559
this.batchedMeshes.set(material, batchedMesh);
5660
this.add(batchedMesh);
5761

5862
meshes.forEach((mesh) => {
63+
// SimpleBatchedMesh uses the r165 API where addGeometry returns the ID directly
5964
const geometryId = batchedMesh.addGeometry(mesh.geometry);
60-
this.batchedIndices.set(mesh, batchedMesh.addInstance(geometryId));
65+
this.batchedIndices.set(mesh, geometryId);
6166
});
6267
});
6368
}
@@ -76,7 +81,7 @@ export class FlexBatchedMesh extends Group {
7681
}
7782
});
7883

79-
// Update each BatchedMesh with the new matrices
84+
// Update each SimpleBatchedMesh with the new matrices
8085
this.batchedIndices.forEach((batchedIndex, mesh) => {
8186
const material = mesh.material as Material;
8287
const batchedMesh = this.batchedMeshes.get(material);

0 commit comments

Comments
 (0)