/
mapping-list.ts
44 lines (37 loc) · 1.36 KB
/
mapping-list.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { ExtensionProperty, IProperty, Nullable, PropertyType } from '@gltf-transform/core';
import { KHR_MATERIALS_VARIANTS } from '../constants';
import type { Mapping } from './mapping';
interface IMappingList extends IProperty {
mappings: Mapping[];
}
/**
* # MappingList
*
* List of material variant {@link Mapping}s. See {@link MaterialsVariants}.
*/
export class MappingList extends ExtensionProperty<IMappingList> {
public static EXTENSION_NAME = KHR_MATERIALS_VARIANTS;
public declare extensionName: typeof KHR_MATERIALS_VARIANTS;
public declare propertyType: 'MappingList';
public declare parentTypes: [PropertyType.PRIMITIVE];
protected init(): void {
this.extensionName = KHR_MATERIALS_VARIANTS;
this.propertyType = 'MappingList';
this.parentTypes = [PropertyType.PRIMITIVE];
}
protected getDefaults(): Nullable<IMappingList> {
return Object.assign(super.getDefaults() as IProperty, { mappings: [] });
}
/** Adds a {@link Mapping} to this mapping. */
public addMapping(mapping: Mapping): this {
return this.addRef('mappings', mapping);
}
/** Removes a {@link Mapping} from the list for this {@link Primitive}. */
public removeMapping(mapping: Mapping): this {
return this.removeRef('mappings', mapping);
}
/** Lists {@link Mapping}s in this {@link Primitive}. */
public listMappings(): Mapping[] {
return this.listRefs('mappings');
}
}