From d77f177a78872864666249f1106fb0d617df9ed1 Mon Sep 17 00:00:00 2001 From: Federico Zivolo Date: Mon, 2 Aug 2021 18:27:55 +0200 Subject: [PATCH] fix(View): Prevent invalid access when picking --- src/core/View.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/View.js b/src/core/View.js index 10dcaea..cd6c369 100644 --- a/src/core/View.js +++ b/src/core/View.js @@ -493,7 +493,7 @@ export default class View extends Component { const representationIds = []; this.selections.forEach((v) => { const { prop } = v.getProperties(); - const { representationId } = prop.get('representationId'); + const representationId = prop?.get('representationId').representationId; if (representationId) { representationIds.push(representationId); } @@ -511,6 +511,9 @@ export default class View extends Component { return this.selections.map((v) => { const { prop, compositeID, displayPosition } = v.getProperties(); + // Return false to mark this item for removal + if (prop == null) return false; + return { worldPosition: Array.from( this.openglRenderWindow.displayToWorld( @@ -525,7 +528,7 @@ export default class View extends Component { ...prop.get('representationId'), ray, }; - }); + }).filter(Boolean); } return []; }