I refer to the gpu multiPickAsync in the document to do the occlusion detection of the annotation. Every time I click to add an annotation, the pickList is updated, and at the position of the annotation, I clone a sphere so that the gpu can pick it up. When I add the first one, I can see that there is a mesh in the array of detection results. This mesh is the sphere I cloned. After this, I continue to add annotations, but the pick result returns an array containing null. Am I overlooking something? I tried to reproduce it in PG, but it works fine in PG
here is source code from project:
when click i will do
const annotation = new Sprite(`sprite-${this.currentIndex}`, spriteManager!);
annotation.position.copyFrom(pos);
annotation.cellIndex = this.currentIndex;
annotation.isPickable = false;
const validateSkinning = (pickInfo.pickedMesh as Mesh).validateSkinning();
const transformBox = new TransformNode('transformBox');
transformBox.position.copyFrom(pos);
const detectMesh = baseSphere.clone(`detectMesh-${this.currentIndex}`);
detectedList.push(detectMesh);
private async handleDetected() {
const { picker, detectedList, scene } = this;
const canvas = RenderMgr.shared.canvas!;
const rect = canvas.getBoundingClientRect();
const width = rect.width;
const height = rect.height;
const viewPort = this.camera.viewport.toGlobal(width, height);
const transformMatrix = scene.getTransformMatrix();
const xy: IVector2Like[] = [];
detectedList.forEach((item) => {
const screenPosition = Vector3.Project(item.getAbsolutePosition(), Matrix.Identity(), transformMatrix, viewPort);
const x = screenPosition.x >> 0;
const y = screenPosition.y >> 0;
xy.push({ x, y });
});
const result = await picker.multiPickAsync(xy);
console.log('result', result?.meshes);
}
Here is PG:https://playground.babylonjs.com/#W2D1C2#22