UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

234 lines (233 loc) 8.54 kB
import type { Nullable } from "../types.js"; import type { IDisposable, Scene } from "../scene.js"; import { MorphTarget } from "./morphTarget.js"; import type { Effect } from "../Materials/effect.js"; import { RawTexture2DArray } from "../Materials/Textures/rawTexture2DArray.js"; import type { IAssetContainer } from "../IAssetContainer.js"; /** * This class is used to deform meshes using morphing between different targets * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets */ export declare class MorphTargetManager implements IDisposable { /** Enable storing morph target data into textures when set to true (true by default) */ static EnableTextureStorage: boolean; /** Maximum number of active morph targets supported in the "vertex attribute" mode (i.e., not the "texture" mode) */ static MaxActiveMorphTargetsInVertexAttributeMode: number; private _targets; private _targetInfluenceChangedObservers; private _targetDataLayoutChangedObservers; private _activeTargets; private _scene; private _influences; private _supportsPositions; private _supportsNormals; private _supportsTangents; private _supportsUVs; private _supportsUV2s; private _supportsColors; private _vertexCount; private _uniqueId; private _tempInfluences; private _canUseTextureForTargets; private _blockCounter; private _mustSynchronize; private _forceUpdateWhenUnfrozen; /** @internal */ _textureVertexStride: number; /** @internal */ _textureWidth: number; /** @internal */ _textureHeight: number; /** @internal */ _morphTargetTextureIndices: Float32Array; /** @internal */ _parentContainer: Nullable<IAssetContainer>; /** @internal */ _targetStoreTexture: Nullable<RawTexture2DArray>; /** * Gets or sets a boolean indicating if influencers must be optimized (eg. recompiling the shader if less influencers are used) */ optimizeInfluencers: boolean; /** * Gets or sets a boolean indicating if positions must be morphed */ enablePositionMorphing: boolean; /** * Gets or sets a boolean indicating if normals must be morphed */ enableNormalMorphing: boolean; /** * Gets or sets a boolean indicating if tangents must be morphed */ enableTangentMorphing: boolean; /** * Gets or sets a boolean indicating if UV must be morphed */ enableUVMorphing: boolean; /** * Gets or sets a boolean indicating if UV2 must be morphed */ enableUV2Morphing: boolean; /** * Gets or sets a boolean indicating if colors must be morphed */ enableColorMorphing: boolean; /** * Sets a boolean indicating that adding new target or updating an existing target will not update the underlying data buffers */ set areUpdatesFrozen(block: boolean); get areUpdatesFrozen(): boolean; /** * Creates a new MorphTargetManager * @param scene defines the current scene */ constructor(scene?: Nullable<Scene>); private _numMaxInfluencers; /** * Gets or sets the maximum number of influencers (targets) (default value: 0). * Setting a value for this property can lead to a smoother experience, as only one shader will be compiled, which will use this value as the maximum number of influencers. * If you leave the value at 0 (default), a new shader will be compiled every time the number of active influencers changes. This can cause problems, as compiling a shader takes time. * If you assign a non-zero value to this property, you need to ensure that this value is greater than the maximum number of (active) influencers you'll need for this morph manager. * Otherwise, the number of active influencers will be truncated at the value you set for this property, which can lead to unexpected results. * Note that this property has no effect if "useTextureToStoreTargets" is false. */ get numMaxInfluencers(): number; set numMaxInfluencers(value: number); /** * Gets the unique ID of this manager */ get uniqueId(): number; /** * Gets the number of vertices handled by this manager */ get vertexCount(): number; /** * Gets a boolean indicating if this manager supports morphing of positions */ get supportsPositions(): boolean; /** * Gets a boolean indicating if this manager supports morphing of normals */ get supportsNormals(): boolean; /** * Gets a boolean indicating if this manager supports morphing of tangents */ get supportsTangents(): boolean; /** * Gets a boolean indicating if this manager supports morphing of texture coordinates */ get supportsUVs(): boolean; /** * Gets a boolean indicating if this manager supports morphing of texture coordinates 2 */ get supportsUV2s(): boolean; /** * Gets a boolean indicating if this manager supports morphing of colors */ get supportsColors(): boolean; /** * Gets a boolean indicating if this manager has data for morphing positions */ get hasPositions(): boolean; /** * Gets a boolean indicating if this manager has data for morphing normals */ get hasNormals(): boolean; /** * Gets a boolean indicating if this manager has data for morphing tangents */ get hasTangents(): boolean; /** * Gets a boolean indicating if this manager has data for morphing texture coordinates */ get hasUVs(): boolean; /** * Gets a boolean indicating if this manager has data for morphing texture coordinates 2 */ get hasUV2s(): boolean; /** * Gets a boolean indicating if this manager has data for morphing colors */ get hasColors(): boolean; /** * Gets the number of targets stored in this manager */ get numTargets(): number; /** * Gets the number of influencers (ie. the number of targets with influences > 0) */ get numInfluencers(): number; /** * Gets the list of influences (one per target) */ get influences(): Float32Array; private _useTextureToStoreTargets; /** * Gets or sets a boolean indicating that targets should be stored as a texture instead of using vertex attributes (default is true). * Please note that this option is not available if the hardware does not support it */ get useTextureToStoreTargets(): boolean; set useTextureToStoreTargets(value: boolean); /** * Gets a boolean indicating that the targets are stored into a texture (instead of as attributes) */ get isUsingTextureForTargets(): boolean; /** * Gets the active target at specified index. An active target is a target with an influence > 0 * @param index defines the index to check * @returns the requested target */ getActiveTarget(index: number): MorphTarget; /** * Gets the target at specified index * @param index defines the index to check * @returns the requested target */ getTarget(index: number): MorphTarget; /** * Gets the first target with the specified name * @param name defines the name to check * @returns the requested target */ getTargetByName(name: string): Nullable<MorphTarget>; /** * Add a new target to this manager * @param target defines the target to add */ addTarget(target: MorphTarget): void; /** * Removes a target from the manager * @param target defines the target to remove */ removeTarget(target: MorphTarget): void; /** * @internal */ _bind(effect: Effect): void; /** * Clone the current manager * @returns a new MorphTargetManager */ clone(): MorphTargetManager; /** * Serializes the current manager into a Serialization object * @returns the serialized object */ serialize(): any; private _syncActiveTargets; /** * Synchronize the targets with all the meshes using this morph target manager */ synchronize(): void; /** * Release all resources */ dispose(): void; /** * Creates a new MorphTargetManager from serialized data * @param serializationObject defines the serialized data * @param scene defines the hosting scene * @returns the new MorphTargetManager */ static Parse(serializationObject: any, scene: Scene): MorphTargetManager; }