Skip to content

Commit

Permalink
Fix 3D model animations.
Browse files Browse the repository at this point in the history
  • Loading branch information
D8H committed Nov 23, 2023
1 parent 77e76b2 commit 4b4f4e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Extensions/3D/Model3DRuntimeObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ namespace gdjs {
);
}

if (this.isNeedingLifecycleFunctions()) {
this.getLifecycleSleepState().wakeUp();
}

// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
this.onCreated();
}
Expand Down Expand Up @@ -194,6 +198,10 @@ namespace gdjs {
}
}

isNeedingLifecycleFunctions(): boolean {
return super.isNeedingLifecycleFunctions() || this._animations.length > 0;
}

update(instanceContainer: gdjs.RuntimeInstanceContainer): void {
const elapsedTime = this.getElapsedTime() / 1000;
this._renderer.updateAnimation(elapsedTime * this._animationSpeedScale);
Expand Down
4 changes: 4 additions & 0 deletions Extensions/TileMap/tilemapruntimeobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ namespace gdjs {
);
this._updateTileMap();

if (this.isNeedingLifecycleFunctions()) {
this.getLifecycleSleepState().wakeUp();
}

// *ALWAYS* call `this.onCreated()` at the very end of your object constructor.
this.onCreated();
}
Expand Down
6 changes: 2 additions & 4 deletions GDJS/Runtime/runtimeobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,11 @@ namespace gdjs {
);
this._totalForce = new gdjs.Force(0, 0, 0);
this._behaviorsTable = new Hashtable();
this._timers = new Hashtable();
this._lifecycleSleepState = new gdjs.ObjectSleepState(
this,
() => this.isNeedingLifecycleFunctions(),
this.isNeedingLifecycleFunctions()
? gdjs.ObjectSleepState.State.AWake
: gdjs.ObjectSleepState.State.ASleep
gdjs.ObjectSleepState.State.ASleep
);
this._rtreeAABB = {
source: this,
Expand Down Expand Up @@ -276,7 +275,6 @@ namespace gdjs {
}
this._behaviorsTable.put(autoData.name, behavior);
}
this._timers = new Hashtable();
}

//Common members functions related to the object and its runtimeScene :
Expand Down

0 comments on commit 4b4f4e8

Please sign in to comment.