Skip to content

Commit

Permalink
badger fixes
Browse files Browse the repository at this point in the history
Made the rive js runtime local so it can work offline
Added error catching to the js functions because if they fail then it stops the rust functions from running
Removed the sleep animation and added a blue lazer animation
Removed duplicate logo svg
  • Loading branch information
dpet committed Jun 20, 2024
1 parent 87ae26d commit 9a5a226
Show file tree
Hide file tree
Showing 6 changed files with 6,206 additions and 78 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<link data-trunk rel="copy-dir" href="src/assets/animations" />
<link href="font-awesome/css/all.min.css" rel="stylesheet">

<script src="https://unpkg.com/@rive-app/canvas@2.17.3"></script>
<script data-trunk src="src/assets/js/rive_runtime_2.18.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.9.0/d3.min.js"
integrity="sha512-vc58qvvBdrDR4etbxMdlTt4GBQk1qjvyORR2nrsPsFPyrs+/u5c3+1Ct6upOgdZoIl7eq6k3a1UPDSNAQi/32A=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
Expand Down
Binary file modified src/assets/animations/badger.riv
Binary file not shown.
48 changes: 0 additions & 48 deletions src/assets/animations/simplicity_logo.svg

This file was deleted.

61 changes: 34 additions & 27 deletions src/assets/js/badger.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,51 @@
let riveInstance

export function load_badger(){
riveInstance = new rive.Rive({
src: "/animations/badger.riv",
canvas: document.getElementById("badger-canvas"),
autoplay: true,
artboard: "Artboard",
stateMachines: "State Machine 1",
});
pass_mousemove_events()

try {
riveInstance = new rive.Rive({
src: "/animations/badger.riv",
canvas: document.getElementById("badger-canvas"),
autoplay: true,
artboard: "Artboard",
stateMachines: "State Machine 1",
});
pass_mousemove_events()
}catch(e){console.error(e)}
}

export function lazer_eyes(){
const inputs = riveInstance.stateMachineInputs('State Machine 1');
const lazerTrigger = inputs.find(i => i.name === 'anim_change');
lazerTrigger.fire()
export function laser_eyes(){
try {
const inputs = riveInstance.stateMachineInputs('State Machine 1');
const laserTrigger = inputs.find(i => i.name === 'anim_change');
laserTrigger.fire()
}catch(e){console.error(e)}
}

export async function hide_badger(val){
await new Promise(res => setTimeout(res, 500));
try {
await new Promise(res => setTimeout(res, 500));

const inputs = riveInstance.stateMachineInputs('State Machine 1');
if (inputs){
const hideInput = inputs.find(i => i.name === 'Hide');
hideInput.value = val
}
const inputs = riveInstance.stateMachineInputs('State Machine 1');
if (inputs){
const hideInput = inputs.find(i => i.name === 'Hide');
hideInput.value = val
}
}catch(e){console.error(e)}
}

export async function hide_badger_timed(){
await new Promise(res => setTimeout(res, 500));
try {
await new Promise(res => setTimeout(res, 500));

const inputs = riveInstance.stateMachineInputs('State Machine 1');
if (inputs){
const hideInput = inputs.find(i => i.name === 'Hide');
hideInput.value = true
const inputs = riveInstance.stateMachineInputs('State Machine 1');
if (inputs){
const hideInput = inputs.find(i => i.name === 'Hide');
hideInput.value = true

await new Promise(res => setTimeout(res, 2000));
hideInput.value = false
}
await new Promise(res => setTimeout(res, 2000));
hideInput.value = false
}
}catch(e){console.error(e)}
}

// the input field captures mouse events so a new event
Expand Down
Loading

0 comments on commit 9a5a226

Please sign in to comment.