Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/dev/core/src/Bones/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ export class Skeleton implements IAnimatable {
return this._uniqueId;
}

/**
* Gets or sets an object used to store user defined information for the skeleton
*/
public metadata: any = null;

/**
* Creates a new skeleton
* @param name defines the skeleton name
Expand Down Expand Up @@ -648,6 +653,7 @@ export class Skeleton implements IAnimatable {
const result = new Skeleton(name, id || name, this._scene);

result.needInitialSkinMatrix = this.needInitialSkinMatrix;
result.metadata = this.metadata;

for (let index = 0; index < this.bones.length; index++) {
const source = this.bones[index];
Expand Down Expand Up @@ -706,6 +712,7 @@ export class Skeleton implements IAnimatable {
*/
public dispose() {
this._meshesWithPoseMatrix.length = 0;
this.metadata = null;

// Animations
this.getScene().stopAnimation(this);
Expand Down Expand Up @@ -745,6 +752,10 @@ export class Skeleton implements IAnimatable {

serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;

if (this.metadata) {
serializationObject.metadata = this.metadata;
}

for (let index = 0; index < this.bones.length; index++) {
const bone = this.bones[index];
const parent = bone.getParent();
Expand Down Expand Up @@ -805,6 +816,10 @@ export class Skeleton implements IAnimatable {

skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;

if (parsedSkeleton.metadata) {
skeleton.metadata = parsedSkeleton.metadata;
}

let index: number;
for (index = 0; index < parsedSkeleton.bones.length; index++) {
const parsedBone = parsedSkeleton.bones[index];
Expand Down
15 changes: 15 additions & 0 deletions packages/dev/core/src/Morph/morphTargetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ export class MorphTargetManager implements IDisposable {
);
}

/**
* Gets or sets an object used to store user defined information for the MorphTargetManager
*/
public metadata: any = null;

/**
* Gets the active target at specified index. An active target is a target with an influence > 0
* @param index defines the index to check
Expand Down Expand Up @@ -425,6 +430,7 @@ export class MorphTargetManager implements IDisposable {
copy.enableUVMorphing = this.enableUVMorphing;
copy.enableUV2Morphing = this.enableUV2Morphing;
copy.enableColorMorphing = this.enableColorMorphing;
copy.metadata = this.metadata;

return copy;
}
Expand All @@ -443,6 +449,10 @@ export class MorphTargetManager implements IDisposable {
serializationObject.targets.push(target.serialize());
}

if (this.metadata) {
serializationObject.metadata = this.metadata;
}

return serializationObject;
}

Expand Down Expand Up @@ -660,6 +670,7 @@ export class MorphTargetManager implements IDisposable {
}

this._targetStoreTexture = null;
this.metadata = null;

// Remove from scene
if (this._scene) {
Expand Down Expand Up @@ -694,6 +705,10 @@ export class MorphTargetManager implements IDisposable {
result.addTarget(MorphTarget.Parse(targetData, scene));
}

if (serializationObject.metadata) {
result.metadata = serializationObject.metadata;
}

return result;
}
}
13 changes: 13 additions & 0 deletions packages/dev/core/src/Particles/gpuParticleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ export class GPUParticleSystem extends BaseParticleSystem implements IDisposable
/** Gets or sets a matrix to use to compute projection */
public defaultProjectionMatrix: Matrix;

/**
* Gets or sets an object used to store user defined information for the particle system
*/
public metadata: any = null;

/**
* Creates a Point Emitter for the particle system (emits directly from the emitter position)
* @param direction1 Particles are emitted between the direction1 and direction2 from within the box
Expand Down Expand Up @@ -2124,6 +2129,10 @@ export class GPUParticleSystem extends BaseParticleSystem implements IDisposable
serializationObject.preventAutoStart = this.preventAutoStart;
serializationObject.worldOffset = this.worldOffset.asArray();

if (this.metadata) {
serializationObject.metadata = this.metadata;
}

return serializationObject;
}

Expand Down Expand Up @@ -2193,6 +2202,10 @@ export class GPUParticleSystem extends BaseParticleSystem implements IDisposable
particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
}

if (parsedParticleSystem.metadata) {
particleSystem.metadata = parsedParticleSystem.metadata;
}

if (!doNotStart && !particleSystem.preventAutoStart) {
particleSystem.start();
}
Expand Down
13 changes: 13 additions & 0 deletions packages/dev/core/src/Particles/particleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ export class ParticleSystem extends ThinParticleSystem {
return this._attractors.slice(0);
}

/**
* Gets or sets an object used to store user defined information for the particle system
*/
public metadata: any = null;

/**
* Add an attractor to the particle system. Attractors are used to change the direction of the particles in the system.
* @param attractor The attractor to add to the particle system
Expand Down Expand Up @@ -829,6 +834,10 @@ export class ParticleSystem extends ThinParticleSystem {
particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
}

if (parsedParticleSystem.metadata) {
particleSystem.metadata = parsedParticleSystem.metadata;
}

if (!doNotStart && !particleSystem.preventAutoStart) {
particleSystem.start();
}
Expand All @@ -851,6 +860,10 @@ export class ParticleSystem extends ThinParticleSystem {
serializationObject.preventAutoStart = this.preventAutoStart;
serializationObject.worldOffset = this.worldOffset.asArray();

if (this.metadata) {
serializationObject.metadata = this.metadata;
}

// SubEmitters
if (this.subEmitters) {
serializationObject.subEmitters = [];
Expand Down