Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eva-engine/eva-plugin-renderer-live2d
Eva.js Live2D Plugin
https://github.com/eva-engine/eva-plugin-renderer-live2d
live2d
Last synced: about 1 month ago
JSON representation
Eva.js Live2D Plugin
- Host: GitHub
- URL: https://github.com/eva-engine/eva-plugin-renderer-live2d
- Owner: eva-engine
- License: mit
- Created: 2021-11-27T11:08:16.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-27T18:42:34.000Z (about 3 years ago)
- Last Synced: 2024-08-07T08:02:33.901Z (5 months ago)
- Topics: live2d
- Language: TypeScript
- Homepage: https://fanmingfei.github.io/eva-plugin-renderer-live2d/
- Size: 8.59 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Eva.js Live2D Plugin
[Demo](https://fanmingfei.github.io/eva-plugin-renderer-live2d/)
Modify on the basis of [guansss/pixi-live2d-display](https://github.com/guansss/pixi-live2d-display)
```bash
npm i eva-plugin-renderer-live2d
``````js
import { Game, GameObject, resource, RESOURCE_TYPE } from '@eva/eva.js';
import { RendererSystem } from '@eva/plugin-renderer';
import { Live2DSystem, Live2D } from 'eva-plugin-renderer-live2d'resource.addResource([
{
name: 'live2dName',
// @ts-ignore
type: RESOURCE_TYPE.LIVE2D,
src: {
url: {
type: 'data',
data: 'https://cdn.jsdelivr.net/gh/Eikanya/Live2d-model/Live2D/Senko_Normals/senko.model3.json'
}
}
}
]);const game = new Game({
systems: [
new RendererSystem({
canvas: document.querySelector('#canvas'),
width: 750,
height: 1000,
}),
new Live2DSystem(),
],
});const go = new GameObject("aaa", {
size: {
width: 0,
height: 0
},
position: {
x: 0,
y: 0
},
scale: {
x: 0.3,
y: 0.3
}
});
const live2d = go.addComponent(new Live2D({
resource: 'live2dName'
}))
live2d.on('loaded', () => {
// 交互
live2d.model.on('hit', hitAreas => {
console.log(hitAreas)
if (hitAreas.includes('head')) {
console.log('play Anim')
live2d.model.motion('Taphead');
}
});
})game.scene.addChild(go);
```