Files
cocos4/cocos/core/assets/morph.ts
T
2020-09-28 16:52:52 +08:00

89 lines
1.9 KiB
TypeScript

/**
* @packageDocumentation
* @hidden
*/
import { GFXAttributeName, GFXDevice, GFXDescriptorSet } from '../gfx';
import { Mesh } from './mesh';
import { StdMorphRendering } from './morph-rendering';
import { IMacroPatch } from '../renderer';
export interface Morph {
/**
* Morph data of each sub-mesh.
*/
subMeshMorphs: (SubMeshMorph | null)[];
/**
* Common initial weights of each sub-mesh.
*/
weights?: number[];
/**
* Name of each target of each sub-mesh morph.
* This field is only meaningful if every sub-mesh has the same number of targets.
*/
targetNames?: string[];
}
export interface MorphTarget {
/**
* Displacement of each target attribute.
*/
displacements: Mesh.IBufferView[];
}
export interface SubMeshMorph {
/**
* Attributes to morph.
*/
attributes: GFXAttributeName[];
/**
* Targets.
*/
targets: MorphTarget[];
/**
* Initial weights of each target.
*/
weights?: number[];
}
export function createMorphRendering (mesh: Mesh, gfxDevice: GFXDevice): MorphRendering | null {
return new StdMorphRendering(mesh, gfxDevice);
}
/**
* Class which control rendering of a morph resource.
*/
export interface MorphRendering {
createInstance (): MorphRenderingInstance;
}
/**
* This rendering instance of a morph resource.
*/
export interface MorphRenderingInstance {
/**
* Sets weights of targets of specified sub mesh.
* @param subMeshIndex
* @param weights
*/
setWeights (subMeshIndex: number, weights: number[]): void;
/**
* Adapts pipeline state to do the rendering.
* @param subMeshIndex
* @param pipelineState
*/
adaptPipelineState (subMeshIndex: number, descriptorSet: GFXDescriptorSet): void;
requiredPatches (subMeshIndex: number): IMacroPatch[] | undefined;
/**
* Destroy the rendering instance.
*/
destroy (): void;
}