2.8.1 • Published 4 months ago

@galacean/mars-plugin-spine v2.8.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

Mars 骨骼动画插件

使用

React demo (Smallfish)

https://code.alipay.com/shixian.cr/spine-demo

简单引入

import { MarsPlayer } from '@galacean/mars-player';
import '@galacean/mars-plugin-spine';

获取 spine 资源列表

import type { SpineResource } from '@galacean/mars-plugin-spine';

const comp = await player.play(scene);
const spineData: SpineResource[] = comp.loaderData.spineDatas;

获取动画列表/皮肤列表

  1. 使用函数获取
const comp = await new MarsPlayer().loadScene(scene);
const item = comp.getItemByName(name)
const { skeletonData } = item.spineDataCache;
const animationList = getAnimationList(skeletonData);
const skinList = getSkinList(skeletonData);
  1. spineDatas 数组中获取
const comp = await new MarsPlayer().loadScene(scene);
const { skinList, animationList } = comp.loaderData.spineDatas[index];

获取指定动画时长

const animationDuration = getAnimationDuration(skeletonData, animationName);

获取创建纹理的参数

import { getTextureOptions } from '@galacean/mars-plugin-spine';

const { magFilter, minFilter, wrapS, wrapT, pma } = getTextureOptions(atlasBuffer);

设置动画 mix 时间

  1. 设置动画的默认 mix 时间 (需要在 `player.play 前调用)
const comp = await new MarsPlayer().loadScene(scene);
const item = comp.getItemByName(name);

item.setDefaultMixDuration(mix);
  1. 设置指定动作的 mix 时间 (需要在 `player.play 前调用)
const comp = await new MarsPlayer().loadScene(scene);
const item = comp.getItemByName(name);

item.setMixDuration(animationOut, animationIn, mix);

设置播放速度

const comp = await new MarsPlayer().loadScene(scene);
const item = comp.getItemByName(name);

item.setSpeed(speed);

设置动画

  1. 设置单个动画
const comp = await new MarsPlayer().loadScene(scene);
const item = comp.getItemByName(name);

item.setAnimation(animationName, speed);
  1. 设置一组动画
const comp = await new MarsPlayer().loadScene(scene);
const item = comp.getItemByName(name);
const animationList = [animationName1, animationName2, animationName3];

item.setAnimation(animationList, speed);

本地开发

开始开发

# demo
pnpm --filter @galacean/mars-plugin-spine dev

浏览器打开:http://localhost:8081/demo/

帧对比测试

浏览器打开:http://localhost:8081/test/

2.8.1

4 months ago

2.8.0

4 months ago

2.8.0-alpha.18

4 months ago

2.8.0-alpha.19

4 months ago

2.8.0-alpha.17

4 months ago

2.8.0-alpha.15

4 months ago

2.8.0-alpha.16

4 months ago

2.8.0-alpha.14

4 months ago

2.8.0-alpha.13

4 months ago

2.8.0-alpha.12

4 months ago

2.8.0-alpha.11

4 months ago

2.8.0-alpha.10

4 months ago

2.8.0-alpha.9

4 months ago

2.8.0-alpha.8

4 months ago

2.7.4

4 months ago

2.8.0-alpha.7

4 months ago

2.7.3

5 months ago

2.8.0-alpha.6

5 months ago

2.7.3-alpha.0

5 months ago

2.8.0-alpha.5

5 months ago

2.8.0-alpha.4

5 months ago

2.8.0-alpha.3

5 months ago

2.7.2

5 months ago

2.8.0-alpha.2

5 months ago

2.8.0-alpha.1

5 months ago

2.7.1

5 months ago

2.8.0-alpha.0

5 months ago

2.7.0

5 months ago

2.6.0

6 months ago

2.5.1

6 months ago

2.5.0

6 months ago

2.4.10

6 months ago

2.4.9

6 months ago

2.4.8

6 months ago

2.4.7

6 months ago

2.4.6

6 months ago

2.4.5

6 months ago

2.4.4

6 months ago

2.4.4-alpha.0

7 months ago

2.4.3

7 months ago

2.4.2

7 months ago

2.4.1

7 months ago

2.3.7-alpha.0

7 months ago

2.4.0-alpha.18

7 months ago

2.4.0-alpha.17

7 months ago

2.4.0-alpha.16

7 months ago

2.4.0-alpha.15

7 months ago

2.5.0-alpha.0

7 months ago

2.4.0-alpha.14

7 months ago

2.3.6

7 months ago

2.4.0-alpha.13

7 months ago

2.4.0-alpha.12

7 months ago

2.4.0-alpha.11

7 months ago

2.3.5

7 months ago

2.4.0-alpha.10

7 months ago

2.4.0-alpha.9

7 months ago

2.4.0-alpha.7

7 months ago

2.4.0-alpha.6

7 months ago

2.4.0-alpha.5

7 months ago

2.3.4

7 months ago

2.4.0-alpha.4

8 months ago

2.4.0-alpha.3

8 months ago

2.4.0-alpha.2

8 months ago

2.3.3-alpha.2

8 months ago

2.3.3-alpha.1

8 months ago

2.4.0-alpha.1

8 months ago

2.3.3-alpha.0

8 months ago

2.3.3

8 months ago

2.3.2

8 months ago

2.3.1

8 months ago

2.3.0

8 months ago

2.2.0

9 months ago

2.1.4-alpha.0

9 months ago

2.1.3

9 months ago

2.1.2

9 months ago

2.1.1

9 months ago

2.1.0

9 months ago

2.1.0-beta.0

10 months ago