From a1e05387e42077f4aee0b7891f8c477f894e5418 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alexander.rose@weirdbyte.de>
Date: Sat, 29 May 2021 15:01:02 -0700
Subject: [PATCH] add Mesh.getOriginalData accessor

---
 src/mol-geo/geometry/mesh/mesh.ts | 8 +++++++-
 src/mol-gl/renderable/mesh.ts     | 2 +-
 src/mol-gl/renderable/schema.ts   | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/mol-geo/geometry/mesh/mesh.ts b/src/mol-geo/geometry/mesh/mesh.ts
index 287b364ac..0c8c2b398 100644
--- a/src/mol-geo/geometry/mesh/mesh.ts
+++ b/src/mol-geo/geometry/mesh/mesh.ts
@@ -177,12 +177,18 @@ export namespace Mesh {
         ValueCell.update(mesh.vertexBuffer, v);
     }
 
-    type OriginalData = {
+    export type OriginalData = {
         indexBuffer: Uint32Array
         vertexCount: number
         triangleCount: number
     }
 
+    /** Meshes may contain some original data in case any processing was done. */
+    export function getOriginalData(x: Mesh | MeshValues) {
+        const { originalData } = 'kind' in x ? x.meta : x.meta.ref.value as Mesh['meta'];
+        return originalData as OriginalData | undefined;
+    }
+
     /**
      * Ensure that each vertices of each triangle have the same group id.
      * Note that normals are copied over and can't be re-created from the new mesh.
diff --git a/src/mol-gl/renderable/mesh.ts b/src/mol-gl/renderable/mesh.ts
index 0e0586c8f..6cf6789a3 100644
--- a/src/mol-gl/renderable/mesh.ts
+++ b/src/mol-gl/renderable/mesh.ts
@@ -22,7 +22,7 @@ export const MeshSchema = {
     dFlipSided: DefineSpec('boolean'),
     dIgnoreLight: DefineSpec('boolean'),
     dXrayShaded: DefineSpec('boolean'),
-    meta: ValueSpec('any')
+    meta: ValueSpec('unknown')
 } as const;
 export type MeshSchema = typeof MeshSchema
 export type MeshValues = Values<MeshSchema>
diff --git a/src/mol-gl/renderable/schema.ts b/src/mol-gl/renderable/schema.ts
index 427bceb06..9c8686e76 100644
--- a/src/mol-gl/renderable/schema.ts
+++ b/src/mol-gl/renderable/schema.ts
@@ -17,6 +17,7 @@ export type ValueKindType = {
     'string': string
     'boolean': boolean
     'any': any
+    'unknown': unknown
 
     'm4': Mat4,
     'float32': Float32Array
-- 
GitLab