Package Exports
- manny
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (manny) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Manny
npm package for importing @mannynotfound into your website. manny will be represented as a 3D model loaded with three.js and appended to an element in the DOM.
Live Demo
https://mannynotfound.github.io/
Usage
As a module
npm install mannyimport Manny from 'manny';
// render to the DOM
const manny = new Manny({
container: '#container',
useBackground: true,
});
// do specific action once
manny.do('bellydance');
// do specific action on loop
manny.do('agony', { loop: true });
// do all actions on loop
manny.doTheMost();As a library
<html>
<head></head>
<body>
<div id="container"></div>
<script src="https://cdn.jsdelivr.net/npm/manny/lib/manny.js" type="text/javascript"></script>
<script>
var manny = new Manny({ container: '#container' });
manny.doTheMost();
</script>
</body>
</html>Module options
| Prop | Type | Default | Description |
|---|---|---|---|
| container | string | 'body' | dom query selector for element to append manny |
| useBackground | boolean | false | if true, renders a white room and grid floor around manny |
Actions
manny is using the mixamo rig and a curated portion of their animation library with convenient aliases. By default, manny comes with wave and idle. Any other actions will be fetched from the action library cdn, added to the manny instance and start playing.
Actions are called with the do function:
manny.do('wave'); // loaded by default
manny.do('fly'); // fetched from cdn library + applied to manny instancedo options
| Prop | Type | Default | Description |
|---|---|---|---|
| loop | boolean | false | if true, will loop action until new action is chosen |
manny.do('bellydance', { loop: true });For a full list of available animations, check the library fixture.
Events
manny's do function returns a promise that can be used to listen to the completion of an action. The promise
will resolve with an "event" containing the type, action, target and direction. For example:
manny.do('victory').then(event => {
console.log(event.type); // "finished"
console.log(event.action); // three.js AnimationAction instance
console.log(event.target); // three.js AnimationMixer instance
console.log(event.direction); // 1
showVictoryText('Good job!');
});note: this can be used with { loop: true } but will only fire the first time the action is completed
Running Locally
npm run devGo to localhost:8080 to see the local test application.