Ver código fonte

add Mesh.getOriginalData accessor

Alexander Rose 3 anos atrás
pai
commit
a1e05387e4

+ 7 - 1
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.

+ 1 - 1
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>

+ 1 - 0
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