Skip to content
Snippets Groups Projects
Commit a1e05387 authored by Alexander Rose's avatar Alexander Rose
Browse files

add Mesh.getOriginalData accessor

parent d9630362
No related branches found
No related tags found
No related merge requests found
...@@ -177,12 +177,18 @@ export namespace Mesh { ...@@ -177,12 +177,18 @@ export namespace Mesh {
ValueCell.update(mesh.vertexBuffer, v); ValueCell.update(mesh.vertexBuffer, v);
} }
type OriginalData = { export type OriginalData = {
indexBuffer: Uint32Array indexBuffer: Uint32Array
vertexCount: number vertexCount: number
triangleCount: 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. * 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. * Note that normals are copied over and can't be re-created from the new mesh.
......
...@@ -22,7 +22,7 @@ export const MeshSchema = { ...@@ -22,7 +22,7 @@ export const MeshSchema = {
dFlipSided: DefineSpec('boolean'), dFlipSided: DefineSpec('boolean'),
dIgnoreLight: DefineSpec('boolean'), dIgnoreLight: DefineSpec('boolean'),
dXrayShaded: DefineSpec('boolean'), dXrayShaded: DefineSpec('boolean'),
meta: ValueSpec('any') meta: ValueSpec('unknown')
} as const; } as const;
export type MeshSchema = typeof MeshSchema export type MeshSchema = typeof MeshSchema
export type MeshValues = Values<MeshSchema> export type MeshValues = Values<MeshSchema>
......
...@@ -17,6 +17,7 @@ export type ValueKindType = { ...@@ -17,6 +17,7 @@ export type ValueKindType = {
'string': string 'string': string
'boolean': boolean 'boolean': boolean
'any': any 'any': any
'unknown': unknown
'm4': Mat4, 'm4': Mat4,
'float32': Float32Array 'float32': Float32Array
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment