Skip to content

Instantly share code, notes, and snippets.

@menduz
Created June 27, 2018 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save menduz/c19dcd076f7c18e7be134ed28cca869a to your computer and use it in GitHub Desktop.
Save menduz/c19dcd076f7c18e7be134ed28cca869a to your computer and use it in GitHub Desktop.
animation in dcl
// 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