Skip to content

Commit

Permalink
fix repetitions and pingpong update bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadbaghaei committed Jan 22, 2025
1 parent 4b2e77b commit cceb8c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/model-viewer/src/features/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export const AnimationMixin = <T extends Constructor<ModelViewerElementBase>>(
LoopPingPong :
(repetitions === 1 ? LoopOnce : LoopRepeat);

const needsToStop = !!options.repetitions;
const needsToStop = !!options.repetitions || "pingpong" in options;

this[$scene].appendAnimation(
animationName ? animationName : this.animationName,
Expand Down
5 changes: 4 additions & 1 deletion packages/model-viewer/src/three-components/ModelScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import {NeutralToneMapping, AnimationAction, AnimationActionLoopStyles, AnimationClip, AnimationMixer, AnimationMixerEventMap, Box3, Camera, Euler, Event as ThreeEvent, LoopOnce, LoopPingPong, LoopRepeat, Material, Matrix3, Mesh, Object3D, PerspectiveCamera, Raycaster, Scene, Sphere, Texture, ToneMapping, Triangle, Vector2, Vector3, WebGLRenderer, XRTargetRaySpace} from 'three';
import {AnimationAction, AnimationActionLoopStyles, AnimationClip, AnimationMixer, AnimationMixerEventMap, Box3, Camera, Euler, Event as ThreeEvent, LoopOnce, LoopPingPong, LoopRepeat, Material, Matrix3, Mesh, NeutralToneMapping, Object3D, PerspectiveCamera, Raycaster, Scene, Sphere, Texture, ToneMapping, Triangle, Vector2, Vector3, WebGLRenderer, XRTargetRaySpace} from 'three';
import {CSS2DRenderer} from 'three/examples/jsm/renderers/CSS2DRenderer.js';
import {reduceVertices} from 'three/examples/jsm/utils/SceneUtils.js';

Expand Down Expand Up @@ -907,6 +907,9 @@ export class ModelScene extends Scene {
}

if (!action.isRunning()) {
if (action.time == animationClip.duration) {
action.stop();
}
action.setLoop(loopMode, repetitionCount);
action.paused = false;
action.enabled = true;
Expand Down

0 comments on commit cceb8c1

Please sign in to comment.