Galacean 效果 Spine 插件
使用量
简单导入
import { Player } from '@galacean/effects';
import '@galacean/effects-plugin-spine';
获取斯宾克资源列表
import type { SpineDataCache } from '@galacean/effects-plugin-spine';
const comp = await player.play(scene);
const item = comp.getItemByName('itemName');
const spineData: SpineDataCache = item.spineDataCache;
获取动画列表 / 皮肤列表
- 获取函数
const comp = await new Player().loadScene(scene);
const item = comp.getItemByName('itemName');
const { skeletonData } = item.spineDataCache;
const animationList = getAnimationList(skeletonData);
const skinList = getSkinList(skeletonData);
- 开始后,您可以在
spineDataCache。 。 。 .
const comp = await new Player().loadScene(scene);
const item = comp.getItemByName('itemName')
const { skinList, animationList } = item.spineDataCache;
获取特定动画的持续时间
const animationDuration = getAnimationDuration(skeletonData, animationName);
获取纹理创建选项
import { getTextureOptions } from '@galacean/effects-plugin-spine';
const { magFilter, minFilter, wrapS, wrapT, pma } = getTextureOptions(atlasBuffer);
设定动画混合持续时间
- 设定动画的默认组合持续时间( 应在
player.play(中文(简体) )
const comp = await new Player().loadScene(scene);
const item = comp.getItemByName(name);
item.setDefaultMixDuration(mix);
- 设定特定过渡的混合时间( 应在
player.play(中文(简体) )
const comp = await new Player().loadScene(scene);
const item = comp.getItemByName(name);
item.setMixDuration(animationOut, animationIn, mix);
设定播放速度
const comp = await new Player().loadScene(scene);
const item = comp.getItemByName(name);
item.setSpeed(speed);
设置动画
- 设定一个动画
const comp = await new Player().loadScene(scene);
const item = comp.getItemByName(name);
item.setAnimation(animationName, speed);
- 设定一组动画
const comp = await new Player().loadScene(scene);
const item = comp.getItemByName(name);
const animationList = [animationName1, animationName2, animationName3];
item.setAnimation(animationList, speed);
发展
开始
# demo
pnpm --filter @galacean/effects-plugin-spine dev
在浏览器中打开:http://localhost:8081/demo/
框架比较测试
浏览器打开: http://localhost:8081/test/