ara3d 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/dist/cli.js +1 -1
- package/dist/embed.js +16579 -0
- package/dist/index.js +118 -47
- package/dist/types/packages/cli/src/embed.d.ts +43 -0
- package/dist/types/packages/cli/src/index.d.ts +22 -2
- package/dist/types/packages/cli/src/library/sequence.d.ts +14 -0
- package/package.json +5 -4
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AraCharacter } from './index';
|
|
2
|
+
export declare class AraCharacterElement extends HTMLElement {
|
|
3
|
+
static observedAttributes: string[];
|
|
4
|
+
/** The character on show, once it has loaded. */
|
|
5
|
+
character?: AraCharacter;
|
|
6
|
+
private view?;
|
|
7
|
+
private status;
|
|
8
|
+
private bar;
|
|
9
|
+
private label;
|
|
10
|
+
private building;
|
|
11
|
+
private queued;
|
|
12
|
+
private visible;
|
|
13
|
+
private sequence?;
|
|
14
|
+
constructor();
|
|
15
|
+
connectedCallback(): void;
|
|
16
|
+
disconnectedCallback(): void;
|
|
17
|
+
attributeChangedCallback(name: string, before: string | null, after: string | null): void;
|
|
18
|
+
/** What plays: the animation attribute (one clip, or a sequence such as "walk 3s, wave"), a vehicle's riding clip, or idle. */
|
|
19
|
+
get animation(): string;
|
|
20
|
+
/** The clips the animation uses, each once. */
|
|
21
|
+
private clipIds;
|
|
22
|
+
private on;
|
|
23
|
+
private applyLive;
|
|
24
|
+
private applyExpression;
|
|
25
|
+
private fit;
|
|
26
|
+
/** Frames the character and any vehicle from the front-right. */
|
|
27
|
+
private frame;
|
|
28
|
+
private play;
|
|
29
|
+
private draw;
|
|
30
|
+
/** What to build, from the attributes. */
|
|
31
|
+
private input;
|
|
32
|
+
private options;
|
|
33
|
+
/** Rebuilds the character once, however many attributes changed together. */
|
|
34
|
+
private build;
|
|
35
|
+
private rebuild;
|
|
36
|
+
private show;
|
|
37
|
+
private fail;
|
|
38
|
+
}
|
|
39
|
+
declare global {
|
|
40
|
+
interface HTMLElementTagNameMap {
|
|
41
|
+
'ara-character': AraCharacterElement;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -10,11 +10,23 @@
|
|
|
10
10
|
* Characters are built in a background worker, so the page stays responsive, and exported with the same exporter as
|
|
11
11
|
* the Ara builder and the ara3d CLI. The character data loads from a free CDN by default.
|
|
12
12
|
*/
|
|
13
|
-
import type
|
|
13
|
+
import { type AnimationClip, type AnimationMixer, type Group } from 'three';
|
|
14
14
|
import type { CharacterInput, GenerateOptions } from './library/generate';
|
|
15
15
|
import type { CharacterColors } from './library/colors';
|
|
16
|
+
import { type SequenceStep } from './library/sequence';
|
|
16
17
|
import type { HumanParams } from '../../../src/core/params';
|
|
17
|
-
export type { CharacterColors, CharacterInput, GenerateOptions };
|
|
18
|
+
export type { CharacterColors, CharacterInput, GenerateOptions, SequenceStep };
|
|
19
|
+
/** Options for playSequence(). */
|
|
20
|
+
export interface SequenceOptions {
|
|
21
|
+
/** Seconds each clip blends into the next (default 0.35). */
|
|
22
|
+
fade?: number;
|
|
23
|
+
/** Start again after the last clip (default true). Without it, the last clip keeps playing, or holds its last pose. */
|
|
24
|
+
repeat?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** A sequence that is playing: stop() ends it, leaving the mixer to you. */
|
|
27
|
+
export interface Sequence {
|
|
28
|
+
stop(): void;
|
|
29
|
+
}
|
|
18
30
|
export type CharacterParams = Partial<HumanParams>;
|
|
19
31
|
/** The character data this version uses, served by jsDelivr from the ara3d-data npm package. */
|
|
20
32
|
export declare const DEFAULT_ASSETS_URL: string;
|
|
@@ -34,6 +46,8 @@ export declare const PROPS: {
|
|
|
34
46
|
carried: readonly string[];
|
|
35
47
|
vehicles: readonly string[];
|
|
36
48
|
};
|
|
49
|
+
/** The clip that shows each vehicle in use, such as { motorcycle: 'ride_motorcycle' }. */
|
|
50
|
+
export declare const VEHICLE_CLIPS: Readonly<Record<string, string>>;
|
|
37
51
|
/** Facial expressions for setExpression(). */
|
|
38
52
|
export declare const EXPRESSIONS: readonly string[];
|
|
39
53
|
/** Mouth shapes for lip-sync (the Oculus viseme names that lip-sync tools use), for setMouth(). */
|
|
@@ -75,6 +89,12 @@ export interface AraCharacter {
|
|
|
75
89
|
setFace(weights: Record<string, number>): void;
|
|
76
90
|
/** Natural blinking, on by default; call update() every frame for it to run. */
|
|
77
91
|
blinking: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Plays clips one after another on `mixer`, blending each into the next, such as "walk 3s, wave, cheer x2". A step
|
|
94
|
+
* that loops (walk, idle) plays one cycle unless given a length; others (wave, jump) play once, or a number of times.
|
|
95
|
+
* It moves on as you call mixer.update(), and takes over the mixer's other actions.
|
|
96
|
+
*/
|
|
97
|
+
playSequence(mixer: AnimationMixer, steps: string | readonly SequenceStep[], options?: SequenceOptions): Sequence;
|
|
78
98
|
/** Runs blinking. Call it every frame, after mixer.update(), with the seconds since the last frame. */
|
|
79
99
|
update(delta: number): void;
|
|
80
100
|
/** Frees the GPU memory held by the character and its props. */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Animation sequences, such as "walk 3s, wave, cheer x2": the steps the library's playSequence() and the embed play. */
|
|
2
|
+
/** One step: a clip ID, with an optional length in seconds or a number of times to play it. */
|
|
3
|
+
export type SequenceStep = string | {
|
|
4
|
+
clip: string;
|
|
5
|
+
seconds?: number;
|
|
6
|
+
times?: number;
|
|
7
|
+
};
|
|
8
|
+
export interface ParsedStep {
|
|
9
|
+
id: string;
|
|
10
|
+
seconds?: number;
|
|
11
|
+
times?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Reads "walk 3s, wave, cheer x2" (or an array of steps) into clip IDs with their lengths or counts. */
|
|
14
|
+
export declare function parseSteps(steps: string | readonly SequenceStep[]): ParsedStep[];
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ara3d",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Realistic, rigged and animated 3D characters: a three.js library for
|
|
5
|
-
"keywords": ["3d", "character", "avatar", "glb", "gltf", "fbx", "three", "threejs", "rigged", "animation", "makehuman", "cli", "gamedev"],
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Realistic, rigged and animated 3D characters: a three.js library, an <ara-character> embed for any web page, and a command-line tool (GLB, FBX, OBJ). Free and open source.",
|
|
5
|
+
"keywords": ["web-component", "embed", "3d", "character", "avatar", "glb", "gltf", "fbx", "three", "threejs", "rigged", "animation", "makehuman", "cli", "gamedev"],
|
|
6
6
|
"homepage": "https://ara3dgen.com/docs/library/",
|
|
7
7
|
"repository": { "type": "git", "url": "git+https://github.com/olatunde85/3d-gen.git", "directory": "packages/cli" },
|
|
8
8
|
"bugs": "https://github.com/olatunde85/3d-gen/issues",
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
"bin": { "ara3d": "dist/cli.js" },
|
|
13
13
|
"exports": {
|
|
14
14
|
".": { "types": "./dist/types/packages/cli/src/index.d.ts", "import": "./dist/index.js" },
|
|
15
|
+
"./embed": { "types": "./dist/types/packages/cli/src/embed.d.ts", "import": "./dist/embed.js" },
|
|
15
16
|
"./package.json": "./package.json"
|
|
16
17
|
},
|
|
17
18
|
"types": "./dist/types/packages/cli/src/index.d.ts",
|
|
18
|
-
"sideEffects":
|
|
19
|
+
"sideEffects": ["./dist/embed.js"],
|
|
19
20
|
"files": ["dist"],
|
|
20
21
|
"peerDependencies": { "three": ">=0.160.0" },
|
|
21
22
|
"peerDependenciesMeta": { "three": { "optional": true } },
|