8000 feat: character id support array by neuqzxy · Pull Request #48 · VisActor/VStory · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: character id support array #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions packages/vstory/demo/src/demos/BaseComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,41 @@ export const BaseComponent = () => {
{
id: 'default-chapter',
scenes: [
{
id: 'scene1',
actions: [
{
characterId: [
...new Array(3).fill(0).map((_, i) => 'rect' + (i % 3)),
...new Array(3).fill(0).map((_, i) => 'line' + (i % 3)),
...new Array(3).fill(0).map((_, i) => 'shape' + (i % 3)),
...new Array(3).fill(0).map((_, i) => 'image' + (i % 3)),
...new Array(4).fill(0).map((_, i) => 'text' + (i % 4)),
...new Array(4).fill(0).map((_, i) => 'timeline' + (i % 4))
],
characterActions: [
{
startTime: 0,
action: 'appear',
payload: {
animation: {
duration: 1600
}
}
},
{
startTime: 2000,
action: 'disappear',
payload: {
animation: {
duration: 1600
}
}
}
]
}
]
},
{
id: 'scene0',
actions: [
Expand Down
21 changes: 12 additions & 9 deletions packages/vstory/src/player/scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isNumber } from '@visactor/vutils';
import { isNumber, isString } from '@visactor/vutils';
import type { IActionSpec, IActSpec, ISceneSpec } from '../story/interface';
import { IStory } from '../story/interface';
import type { IActionProcessor } from './processor/interface/action-processor';
Expand Down Expand Up @@ -153,15 +153,18 @@ export class Scheduler implements IScheduler {
let character_st = Infinity;
let character_et = -Infinity;
action.characterActions.forEach(ca => {
const info = this._actionProcessor.getActInfo(action.characterId, ca);
if (!info) {
return;
}
const item = new ActionItem(info.startTime, info.duration, ca, action.characterId);
const characterIdList = isString(action.characterId) ? [action.characterId] : action.characterId;
characterIdList.forEach(characterId => {
const info = this._actionProcessor.getActInfo(characterId, ca);
if (!info) {
return;
}
const item = new ActionItem(info.startTime, info.duration, ca, characterId);

character_st = Math.max(Math.min(item.startTime, character_st), 0);
character_et = Math.max(item.startTime + item.duration, character_et);
actionList.push(item);
character_st = Math.max(Math.min(item.startTime, character_st), 0);
character_et = Math.max(item.startTime + item.duration, character_et);
actionList.push(item);
});
});

scene_st = !actIdx ? character_st : Math.max(Math.min(character_st, scene_st), 0);
Expand Down
2 changes: 1 addition & 1 deletion packages/vstory/src/story/interface/dsl-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface IStorySpec {
}

export interface IActionsLink {
characterId: string;
characterId: string[];
characterActions: IActionSpec[];
}

Expand Down
Loading
0