Created
June 27, 2018 19:28
-
-
Save menduz/c19dcd076f7c18e7be134ed28cca869a to your computer and use it in GitHub Desktop.
animation in dcl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// tslint:disable:ter-indent | |
import { ScriptableScene, createElement } from 'metaverse-api' | |
export default class SharkAnimation extends ScriptableScene { | |
state = { | |
bitestate: 0 | |
} | |
async sceneDidMount() { | |
this.eventSubscriber.on(`muhshark_click`, xxx => { | |
// tslint:disable-next-line:no-console | |
console.log(xxx) | |
this.clickedOnShark() | |
}) | |
} | |
clickedOnShark() { | |
this.setState({ bitestate: (this.state.bitestate + 1) % 4 }) | |
} | |
async render() { | |
return ( | |
<scene> | |
<box id="muhshark" position={{ x: 5, y: 0, z: 5 }} /> | |
<gltf-model | |
position={{ x: 5, y: 3, z: 5 }} | |
scale={0.5} | |
src="models/shark_anim.gltf" | |
skeletalAnimation={ | |
[ | |
[ | |
{ clip: 'shark_skeleton_bite', weight: 0.1, playing: true, loop: true }, | |
{ clip: 'shark_skeleton_swim', weight: 0.2, playing: true, loop: true } | |
], | |
[ | |
{ clip: 'shark_skeleton_bite', weight: 0, playing: true }, | |
{ clip: 'shark_skeleton_swim', weight: 1, playing: true } | |
], | |
[ | |
{ clip: 'shark_skeleton_bite', weight: 1, playing: true }, | |
{ clip: 'shark_skeleton_swim', weight: 0.7, playing: true } | |
], | |
[ | |
{ clip: 'shark_skeleton_bite', weight: 1, playing: false }, | |
{ clip: 'shark_skeleton_swim', weight: 0.7, playing: true } | |
] | |
][this.state.bitestate] | |
} | |
/> | |
<gltf-model | |
id="box-animated" | |
position={{ x: 2, y: 0, z: -2 }} | |
src="models/BoxAnimated.gltf" | |
skeletalAnimation={[{ clip: 0, playing: true }]} | |
/> | |
</scene> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment