From 3c61b2dfe13e07440d49be3f442fd8a64186c3a5 Mon Sep 17 00:00:00 2001 From: Vincent Marchetti Date: Mon, 19 Aug 2024 10:32:10 -0400 Subject: [PATCH] rewrote the Camera.LookAt get accessor to ensure that when the Camera as a body resource does not define a value for a LookAt property, then the value returned is null --- src/Camera.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Camera.ts b/src/Camera.ts index 26052b8f..d7c1063e 100644 --- a/src/Camera.ts +++ b/src/Camera.ts @@ -69,17 +69,20 @@ export class Camera extends AnnotationBody { * with an id matching the id of an Annotation instance. **/ getLookAt() : object | PointSelector | null { - let rawObj = this.getPropertyAsObject("lookAt" ) - if ( ! rawObj) return null; + let rawObj = this.getPropertyAsObject("lookAt" ) ?? null; + if ( rawObj == null ) return null; - let rawType = (rawObj["type"] || rawObj["@type"]) - if (rawType == "Annotation"){ + let rawType = (rawObj["type"] || rawObj["@type"]) ?? null; + if (rawType == null ) return null; + + if (rawType == "Annotation") return rawObj; - } - if (rawType == "PointSelector"){ + else if (rawType == "PointSelector") return new PointSelector(rawObj); + else{ + console.error('unidentified value of lookAt ${rawType}'); + return null; } - throw new Error('unidentified value of lookAt ${rawType}'); } get LookAt() : object | null {return this.getLookAt();}