Skip to content

Commit

Permalink
feat: updated the sm schema, need to test (#87)
Browse files Browse the repository at this point in the history
* feat: updated the sm schema, need to test

* chore: fixed tests

* chore: fixed lint
  • Loading branch information
samuelOsborne authored Oct 24, 2024
1 parent f2a1db8 commit bd17668
Show file tree
Hide file tree
Showing 11 changed files with 620 additions and 293 deletions.
208 changes: 171 additions & 37 deletions apps/node/script.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -134,63 +134,197 @@ async function createExplodingPigeon() {
})
.addStateMachine({
descriptor: {
id: 'pigeon_fsm',
initial: 0, // The index of the state to start at
id: "explodingPigeon",
initial: "pigeonRunning"
},
states: [
{
name: "pigeon",
type: "PlaybackState",
mode: "Forward",
speed: 1,
use_frame_interpolation: true,
autoplay: true,
name: "pigeonRunning",
animationId: "",
loop: true,
marker: "bird"
autoplay: true,
segment: "bird",
transitions: [
{
type: "Transition",
toState: "explosion",
guards: [
{
type: "Event",
triggerName: "explode"
}
]
}
]
},
{
name: "explosion",
type: "PlaybackState",
mode: "Forward",
name: "explosion",
animationId: "",
loop: false,
autoplay: true,
speed: 0.5,
segment: "explosion",
transitions: [
{
type: "Transition",
toState: "feathersFalling",
guards: [
{
type: "Event",
triggerName: "rainFeathers"
}
]
}
]
},
{
type: "PlaybackState",
name: "feathersFalling",
animationId: "",
loop: false,
marker: 'explosion',
autoplay: true,
segment: "feathers",
transitions: [
{
type: "Transition",
toState: "pigeonRunning",
guards: [
{
type: "Event",
triggerName: "restart"
}
]
}
]
}
],
listeners: [
{
type: "PointerDown",
actions: [
{
type: "Fire",
triggerName: "explode"
}
]
},
{
name: "feathers",
type: "OnComplete",
stateName: "explosion",
actions: [
{
type: "Fire",
triggerName: "rainFeathers"
}
]
},
{
type: "PointerDown",
actions: [
{
type: "Fire",
triggerName: "restart"
}
]
}
],
triggers: [
{
type: "Event",
name: "explode"
},
{
type: "Event",
name: "rainFeathers"
},
{
type: "Event",
name: "restart"
}
]
})
.addStateMachine({
descriptor: {
id: "pigeonWithoutExplosion",
initial: "pigeonRunning"
},
states: [
{
type: "PlaybackState",
name: "pigeonRunning",
animationId: "",
loop: true,
autoplay: true,
speed: 1,
segment: "bird",
transitions: [
{
type: "Transition",
toState: "feathersFalling",
guards: [
{
type: "Event",
triggerName: "explode"
}
]
}
]
},
{
type: "PlaybackState",
name: "feathersFalling",
animationId: "",
loop: false,
marker: 'feathers',
autoplay: true,
segment: "feathers",
transitions: [
{
type: "Transition",
toState: "pigeonRunning",
guards: [
{
type: "Event",
triggerName: "restart"
}
]
}
]
}
],
transitions: [
listeners: [
{
type: "Transition",
from_state: 0,
to_state: 1,
string_event: {
value: "explosion"
},
// on_pointer_down_event: {},
type: "PointerDown",
actions: [
{
type: "Fire",
triggerName: "explode"
}
]
},
{
type: "Transition",
from_state: 1,
to_state: 2,
on_complete_event: {},
type: "PointerDown",
actions: [
{
type: "Fire",
triggerName: "restart"
}
]
}
],
triggers: [
{
type: "Event",
name: "explode"
},
{
type: "Transition",
from_state: 2,
to_state: 0,
on_complete_event: {},
type: "Event",
name: "rainFeathers"
},
],
listeners: [],
context_variables: []
{
type: "Event",
name: "restart"
}
]
})
.build()
.then((value) => {
Expand Down Expand Up @@ -1115,7 +1249,7 @@ async function debugScenario() {

// debugScenario();

// createExplodingPigeon();
createExplodingPigeon();
// createListenersAnimation();
// create_pigeon_fsm_eq_guard();
// create_pigeon_gt_gte_guard();
Expand All @@ -1124,9 +1258,9 @@ async function debugScenario() {


/** Sun moon toggle button */
create_toggle_button();
// create_toggle_button();

/** Coffee drinker sync to scroll. Recreate the animation on the Interactivity homepage */
/* lottiefiles.com/interactivity */
create_sync_animation();
// create_sync_animation();

5 changes: 1 addition & 4 deletions packages/dotlottie-js/src/common/dotlottie-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* Copyright 2023 Design Barn Inc.
*/

/* eslint-disable @typescript-eslint/naming-convention */

import type { Animation as AnimationType } from '@lottie-animation-community/lottie-types';
import type { ZipOptions } from 'fflate';

Expand Down Expand Up @@ -613,9 +611,8 @@ export class DotLottieCommon {
const stateOption = {
states: stateMachine.states,
descriptor: { id: stateMachine.id, initial: stateMachine.initial },
transitions: stateMachine.transitions,
listeners: stateMachine.listeners,
context_variables: stateMachine.contextVariables,
triggers: stateMachine.triggers,
zipOptions: stateMachine.zipOptions,
};

Expand Down
Loading

0 comments on commit bd17668

Please sign in to comment.