@pmndrs/viverse 0.2.5 → 0.2.7
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/dist/action/definitions.d.ts +11 -0
- package/dist/action/definitions.js +18 -0
- package/dist/action/index.d.ts +1 -11
- package/dist/action/index.js +1 -18
- package/dist/action/keyboard.d.ts +1 -1
- package/dist/action/keyboard.js +2 -1
- package/dist/action/pointer-capture.js +1 -1
- package/dist/action/pointer-lock.js +1 -1
- package/dist/action/pointer.d.ts +1 -1
- package/dist/action/pointer.js +1 -1
- package/dist/action/screen-joystick.js +1 -1
- package/dist/action/screen-jump-button.js +1 -1
- package/dist/animation/bone-map.d.ts +2 -3
- package/dist/animation/bone-map.js +2 -2
- package/dist/animation/index.js +4 -4
- package/dist/model/index.d.ts +4 -1
- package/dist/model/index.js +10 -2
- package/dist/model/vrm.d.ts +1 -1
- package/dist/model/vrm.js +1 -1
- package/dist/simple-character/apply-input-options.d.ts +1 -1
- package/dist/simple-character/index.d.ts +5 -98
- package/dist/simple-character/index.js +2 -1
- package/dist/simple-character/state/jump-down.d.ts +1 -1
- package/dist/simple-character/state/jump-forward.d.ts +1 -1
- package/dist/simple-character/state/jump-loop.d.ts +1 -1
- package/dist/simple-character/state/jump-start.d.ts +1 -1
- package/dist/simple-character/state/jump-up.d.ts +1 -1
- package/dist/simple-character/state/movement.d.ts +1 -1
- package/dist/simple-character/types.d.ts +99 -0
- package/dist/simple-character/types.js +1 -0
- package/dist/simple-character/update-input-velocity.d.ts +1 -1
- package/dist/simple-character/update-rotation.d.ts +1 -1
- package/dist/utils.d.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventAction, StateAction } from './action.js';
|
|
2
|
+
export declare function BooleanOr(...values: Array<boolean>): boolean;
|
|
3
|
+
export declare const MoveForwardAction: StateAction<number>;
|
|
4
|
+
export declare const MoveBackwardAction: StateAction<number>;
|
|
5
|
+
export declare const MoveLeftAction: StateAction<number>;
|
|
6
|
+
export declare const MoveRightAction: StateAction<number>;
|
|
7
|
+
export declare const RunAction: StateAction<boolean>;
|
|
8
|
+
export declare const JumpAction: EventAction<unknown>;
|
|
9
|
+
export declare const ZoomAction: EventAction<number>;
|
|
10
|
+
export declare const RotateYawAction: EventAction<number>;
|
|
11
|
+
export declare const RotatePitchAction: EventAction<number>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventAction, StateAction } from './action.js';
|
|
2
|
+
export function BooleanOr(...values) {
|
|
3
|
+
let value = false;
|
|
4
|
+
for (let i = 0; i < values.length; i++) {
|
|
5
|
+
value ||= values[i];
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
const sum = (...values) => values.reduce((a, b) => a + b, 0);
|
|
10
|
+
export const MoveForwardAction = new StateAction(Math.max, 0);
|
|
11
|
+
export const MoveBackwardAction = new StateAction(Math.max, 0);
|
|
12
|
+
export const MoveLeftAction = new StateAction(Math.max, 0);
|
|
13
|
+
export const MoveRightAction = new StateAction(Math.max, 0);
|
|
14
|
+
export const RunAction = new StateAction(BooleanOr, false);
|
|
15
|
+
export const JumpAction = new EventAction();
|
|
16
|
+
export const ZoomAction = new EventAction(sum, 0);
|
|
17
|
+
export const RotateYawAction = new EventAction(sum, 0);
|
|
18
|
+
export const RotatePitchAction = new EventAction(sum, 0);
|
package/dist/action/index.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import { EventAction, StateAction } from './action.js';
|
|
2
|
-
export declare function BooleanOr(...values: Array<boolean>): boolean;
|
|
3
|
-
export declare const MoveForwardAction: StateAction<number>;
|
|
4
|
-
export declare const MoveBackwardAction: StateAction<number>;
|
|
5
|
-
export declare const MoveLeftAction: StateAction<number>;
|
|
6
|
-
export declare const MoveRightAction: StateAction<number>;
|
|
7
|
-
export declare const RunAction: StateAction<boolean>;
|
|
8
|
-
export declare const JumpAction: EventAction<unknown>;
|
|
9
|
-
export declare const ZoomAction: EventAction<number>;
|
|
10
|
-
export declare const RotateYawAction: EventAction<number>;
|
|
11
|
-
export declare const RotatePitchAction: EventAction<number>;
|
|
12
1
|
export * from './pointer-lock.js';
|
|
13
2
|
export * from './pointer-capture.js';
|
|
14
3
|
export * from './pointer.js';
|
|
@@ -16,3 +5,4 @@ export * from './keyboard.js';
|
|
|
16
5
|
export * from './screen-joystick.js';
|
|
17
6
|
export * from './screen-jump-button.js';
|
|
18
7
|
export * from './action.js';
|
|
8
|
+
export * from './definitions.js';
|
package/dist/action/index.js
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import { EventAction, StateAction } from './action.js';
|
|
2
|
-
export function BooleanOr(...values) {
|
|
3
|
-
let value = false;
|
|
4
|
-
for (let i = 0; i < values.length; i++) {
|
|
5
|
-
value ||= values[i];
|
|
6
|
-
}
|
|
7
|
-
return value;
|
|
8
|
-
}
|
|
9
|
-
const sum = (...values) => values.reduce((a, b) => a + b, 0);
|
|
10
|
-
export const MoveForwardAction = new StateAction(Math.max, 0);
|
|
11
|
-
export const MoveBackwardAction = new StateAction(Math.max, 0);
|
|
12
|
-
export const MoveLeftAction = new StateAction(Math.max, 0);
|
|
13
|
-
export const MoveRightAction = new StateAction(Math.max, 0);
|
|
14
|
-
export const RunAction = new StateAction(BooleanOr, false);
|
|
15
|
-
export const JumpAction = new EventAction();
|
|
16
|
-
export const ZoomAction = new EventAction(sum, 0);
|
|
17
|
-
export const RotateYawAction = new EventAction(sum, 0);
|
|
18
|
-
export const RotatePitchAction = new EventAction(sum, 0);
|
|
19
1
|
export * from './pointer-lock.js';
|
|
20
2
|
export * from './pointer-capture.js';
|
|
21
3
|
export * from './pointer.js';
|
|
@@ -23,3 +5,4 @@ export * from './keyboard.js';
|
|
|
23
5
|
export * from './screen-joystick.js';
|
|
24
6
|
export * from './screen-jump-button.js';
|
|
25
7
|
export * from './action.js';
|
|
8
|
+
export * from './definitions.js';
|
package/dist/action/keyboard.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StateAction } from './action.js';
|
|
2
|
+
import { JumpAction, MoveBackwardAction, MoveForwardAction, MoveLeftAction, MoveRightAction, RunAction, } from './definitions.js';
|
|
2
3
|
export class KeyboardActionBinding {
|
|
3
4
|
pressedKeys = new Set();
|
|
4
5
|
writer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RotatePitchAction, RotateYawAction, ZoomAction } from './
|
|
1
|
+
import { RotatePitchAction, RotateYawAction, ZoomAction } from './definitions.js';
|
|
2
2
|
export class PointerLockRotateZoomActionBindings {
|
|
3
3
|
rotationSpeed; // default 0.4
|
|
4
4
|
zoomSpeed; // default 0.0001
|
package/dist/action/pointer.d.ts
CHANGED
package/dist/action/pointer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MoveForwardAction, MoveBackwardAction, MoveLeftAction, MoveRightAction, RunAction
|
|
1
|
+
import { MoveForwardAction, MoveBackwardAction, MoveLeftAction, MoveRightAction, RunAction } from './definitions.js';
|
|
2
2
|
const DefaultDeadZonePx = 24;
|
|
3
3
|
const DefaultRunDistancePx = 46;
|
|
4
4
|
const JoystickRadius = 56;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { VRMHumanBoneName } from '@pixiv/three-vrm';
|
|
2
1
|
import { AnimationClip, Object3D } from 'three';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
2
|
+
import type { BoneMap } from '../utils.js';
|
|
3
|
+
export declare function applyAnimationBoneMap(clip: AnimationClip, clipScene: Object3D | undefined, boneMap: BoneMap): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function applyAnimationBoneMap(clip, clipScene, boneMap) {
|
|
2
2
|
for (const track of clip.tracks) {
|
|
3
3
|
const [clipBoneName, propertyName] = track.name.split('.');
|
|
4
4
|
const clipBone = clipScene?.getObjectByName(clipBoneName);
|
|
5
|
-
const normalizedBoneName =
|
|
5
|
+
const normalizedBoneName = boneMap?.[clipBoneName] ?? clipBoneName;
|
|
6
6
|
if (clipBone != null) {
|
|
7
7
|
clipBone.name = normalizedBoneName;
|
|
8
8
|
}
|
package/dist/animation/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Euler, Quaternion, QuaternionKeyframeTrack, Vector3, VectorKeyframeTrac
|
|
|
3
3
|
import { BVHLoader } from 'three/examples/jsm/loaders/BVHLoader.js';
|
|
4
4
|
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader.js';
|
|
5
5
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
6
|
-
import {
|
|
6
|
+
import { applyAnimationBoneMap } from './bone-map.js';
|
|
7
7
|
import _bvhBoneMap from './bvh-bone-map.json';
|
|
8
8
|
import { resolveDefaultCharacterAnimationUrl } from './default.js';
|
|
9
9
|
import { applyMask } from './mask.js';
|
|
@@ -27,9 +27,9 @@ export function fixModelAnimationClip(model, clip, clipScene, removeXZMovement)
|
|
|
27
27
|
let restRoot;
|
|
28
28
|
let restRootParent;
|
|
29
29
|
if (!(model instanceof VRM)) {
|
|
30
|
-
restRoot = model.scene.getObjectByName('
|
|
30
|
+
restRoot = model.scene.getObjectByName('rest_hips')?.parent;
|
|
31
31
|
if (restRoot == null) {
|
|
32
|
-
throw new Error(`Model
|
|
32
|
+
throw new Error(`Model hips.parent not found.`);
|
|
33
33
|
}
|
|
34
34
|
restRootParent = restRoot?.parent;
|
|
35
35
|
restRoot.parent = null;
|
|
@@ -248,7 +248,7 @@ export async function loadCharacterAnimation(model, url, type, removeXZMovement
|
|
|
248
248
|
}
|
|
249
249
|
const [clip] = clips;
|
|
250
250
|
if (boneMap != null) {
|
|
251
|
-
|
|
251
|
+
applyAnimationBoneMap(clip, clipScene, boneMap);
|
|
252
252
|
}
|
|
253
253
|
if (mask != null) {
|
|
254
254
|
applyMask(clip, mask);
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { AnimationAction, AnimationMixer, Object3D, Quaternion } from 'three';
|
|
2
|
+
import type { BoneMap } from '../utils.js';
|
|
3
|
+
import type { VRMHumanBoneName } from '@pixiv/three-vrm';
|
|
2
4
|
export { VRMHumanBoneName } from '@pixiv/three-vrm';
|
|
3
5
|
export * from './vrm.js';
|
|
4
6
|
export type CharacterModelOptions = {
|
|
5
7
|
readonly type?: 'vrm' | 'gltf';
|
|
8
|
+
readonly boneMap?: Record<string, VRMHumanBoneName>;
|
|
6
9
|
readonly url?: string;
|
|
7
10
|
/**
|
|
8
11
|
* allows to apply an rotation offset when placing objects as children of the character's bones
|
|
@@ -25,4 +28,4 @@ export type CharacterModel = {
|
|
|
25
28
|
currentAnimations: Map<string | undefined, AnimationAction>;
|
|
26
29
|
boneRotationOffset?: Quaternion;
|
|
27
30
|
};
|
|
28
|
-
export declare function loadCharacterModel(url?: string, type?: Exclude<CharacterModelOptions, boolean>['type'], boneRotationOffset?: Quaternion, castShadow?: boolean, receiveShadow?: boolean): Promise<CharacterModel>;
|
|
31
|
+
export declare function loadCharacterModel(url?: string, type?: Exclude<CharacterModelOptions, boolean>['type'], boneRotationOffset?: Quaternion, castShadow?: boolean, receiveShadow?: boolean, boneMap?: BoneMap): Promise<CharacterModel>;
|
package/dist/model/index.js
CHANGED
|
@@ -7,9 +7,16 @@ export function flattenCharacterModelOptions(options) {
|
|
|
7
7
|
if (options == null) {
|
|
8
8
|
return [];
|
|
9
9
|
}
|
|
10
|
-
return [
|
|
10
|
+
return [
|
|
11
|
+
options.url,
|
|
12
|
+
options.type,
|
|
13
|
+
options.boneRotationOffset,
|
|
14
|
+
options.castShadow,
|
|
15
|
+
options.receiveShadow,
|
|
16
|
+
options.boneMap,
|
|
17
|
+
];
|
|
11
18
|
}
|
|
12
|
-
export async function loadCharacterModel(url, type, boneRotationOffset, castShadow = true, receiveShadow = true) {
|
|
19
|
+
export async function loadCharacterModel(url, type, boneRotationOffset, castShadow = true, receiveShadow = true, boneMap) {
|
|
13
20
|
let result;
|
|
14
21
|
if (url == null) {
|
|
15
22
|
//prepare loading the default model
|
|
@@ -38,6 +45,7 @@ export async function loadCharacterModel(url, type, boneRotationOffset, castShad
|
|
|
38
45
|
}
|
|
39
46
|
result.boneRotationOffset = boneRotationOffset;
|
|
40
47
|
result.scene.traverse((obj) => {
|
|
48
|
+
obj.name = boneMap?.[obj.name] ?? obj.name;
|
|
41
49
|
obj.frustumCulled = false;
|
|
42
50
|
if (castShadow) {
|
|
43
51
|
obj.castShadow = true;
|
package/dist/model/vrm.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VRM } from '@pixiv/three-vrm';
|
|
2
2
|
import { Object3D, Object3DEventMap } from 'three';
|
|
3
|
-
import { GLTFLoader } from 'three/examples/jsm/
|
|
3
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
4
4
|
export declare const vrmaLoader: GLTFLoader;
|
|
5
5
|
export declare function loadVrmCharacterModel(url: string): Promise<VRM & {
|
|
6
6
|
scene: Object3D<Object3DEventMap & {
|
package/dist/model/vrm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VRMLoaderPlugin, VRMUtils } from '@pixiv/three-vrm';
|
|
2
2
|
import { VRMAnimationLoaderPlugin } from '@pixiv/three-vrm-animation';
|
|
3
|
-
import { GLTFLoader } from 'three/examples/jsm/
|
|
3
|
+
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
4
4
|
export const vrmaLoader = new GLTFLoader();
|
|
5
5
|
vrmaLoader.register((parser) => new VRMLoaderPlugin(parser, { autoUpdateHumanBones: true }));
|
|
6
6
|
vrmaLoader.register((parser) => new VRMAnimationLoaderPlugin(parser));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SimpleCharacterActionBindingOptions } from './
|
|
1
|
+
import { SimpleCharacterActionBindingOptions } from './types.js';
|
|
2
2
|
export declare function applySimpleCharacterActionBindingOptions(actionBindingsList: Array<unknown>, options?: SimpleCharacterActionBindingOptions): void;
|
|
@@ -1,102 +1,8 @@
|
|
|
1
1
|
import { Group, Object3D, Object3DEventMap, AnimationAction } from 'three';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export type SimpleCharacterState = {
|
|
7
|
-
camera: Object3D;
|
|
8
|
-
model?: CharacterModel;
|
|
9
|
-
physics: BvhCharacterPhysics;
|
|
10
|
-
lastJump: number;
|
|
11
|
-
};
|
|
12
|
-
export type SimpleCharacterMovementOptions = {
|
|
13
|
-
/**
|
|
14
|
-
* @default true
|
|
15
|
-
*/
|
|
16
|
-
jump?: {
|
|
17
|
-
/**
|
|
18
|
-
* @default 0.2
|
|
19
|
-
*/
|
|
20
|
-
delay?: number;
|
|
21
|
-
/**
|
|
22
|
-
* @default 0.1
|
|
23
|
-
*/
|
|
24
|
-
bufferTime?: number;
|
|
25
|
-
/**
|
|
26
|
-
* @default 8
|
|
27
|
-
*/
|
|
28
|
-
speed?: number;
|
|
29
|
-
} | boolean;
|
|
30
|
-
/**
|
|
31
|
-
* @default true
|
|
32
|
-
*/
|
|
33
|
-
walk?: {
|
|
34
|
-
speed?: number;
|
|
35
|
-
} | boolean;
|
|
36
|
-
/**
|
|
37
|
-
* @default true
|
|
38
|
-
*/
|
|
39
|
-
run?: {
|
|
40
|
-
speed?: number;
|
|
41
|
-
} | boolean;
|
|
42
|
-
};
|
|
43
|
-
export type SimpleCharacterAnimationOptions = {
|
|
44
|
-
readonly walk?: CharacterAnimationOptions;
|
|
45
|
-
readonly run?: CharacterAnimationOptions;
|
|
46
|
-
readonly idle?: CharacterAnimationOptions;
|
|
47
|
-
readonly jumpUp?: CharacterAnimationOptions;
|
|
48
|
-
readonly jumpLoop?: CharacterAnimationOptions;
|
|
49
|
-
readonly jumpDown?: CharacterAnimationOptions;
|
|
50
|
-
readonly jumpForward?: CharacterAnimationOptions;
|
|
51
|
-
/**
|
|
52
|
-
* @default "movement"
|
|
53
|
-
*/
|
|
54
|
-
yawRotationBasedOn?: 'camera' | 'movement';
|
|
55
|
-
/**
|
|
56
|
-
* @default 10
|
|
57
|
-
*/
|
|
58
|
-
maxYawRotationSpeed?: number;
|
|
59
|
-
/**
|
|
60
|
-
* @default 0.1
|
|
61
|
-
*/
|
|
62
|
-
crossFadeDuration?: number;
|
|
63
|
-
};
|
|
64
|
-
export type SimpleCharacterActionBindingOptions = {
|
|
65
|
-
screenJoystickRunDistancePx?: number;
|
|
66
|
-
screenJoystickDeadZonePx?: number;
|
|
67
|
-
pointerCaptureRotationSpeed?: number;
|
|
68
|
-
pointerCaptureZoomSpeed?: number;
|
|
69
|
-
pointerLockRotationSpeed?: number;
|
|
70
|
-
pointerLockZoomSpeed?: number;
|
|
71
|
-
keyboardRequiresPointerLock?: boolean;
|
|
72
|
-
keyboardMoveForwardKeys?: Array<string>;
|
|
73
|
-
keyboardMoveBackwardKeys?: Array<string>;
|
|
74
|
-
keyboardMoveLeftKeys?: Array<string>;
|
|
75
|
-
keyboardMoveRightKeys?: Array<string>;
|
|
76
|
-
keyboardRunKeys?: Array<string>;
|
|
77
|
-
keyboardJumpKeys?: Array<string>;
|
|
78
|
-
};
|
|
79
|
-
export type SimpleCharacterOptions = {
|
|
80
|
-
/**
|
|
81
|
-
* @deprecated use actionBindings instead
|
|
82
|
-
*/
|
|
83
|
-
readonly input?: ReadonlyArray<{
|
|
84
|
-
new (domElement: HTMLElement, abortSignal: AbortSignal): any;
|
|
85
|
-
}>;
|
|
86
|
-
readonly actionBindings?: ReadonlyArray<{
|
|
87
|
-
new (domElement: HTMLElement, abortSignal: AbortSignal): any;
|
|
88
|
-
}>;
|
|
89
|
-
/**
|
|
90
|
-
* @deprecated use actionBindingOptions instead
|
|
91
|
-
*/
|
|
92
|
-
inputOptions?: SimpleCharacterActionBindingOptions;
|
|
93
|
-
actionBindingOptions?: SimpleCharacterActionBindingOptions;
|
|
94
|
-
movement?: SimpleCharacterMovementOptions;
|
|
95
|
-
readonly model?: CharacterModelOptions | boolean;
|
|
96
|
-
physics?: BvhCharacterPhysicsOptions;
|
|
97
|
-
cameraBehavior?: CharacterCameraBehaviorOptions;
|
|
98
|
-
readonly animation?: SimpleCharacterAnimationOptions;
|
|
99
|
-
};
|
|
2
|
+
import { CharacterCameraBehavior } from '../camera.js';
|
|
3
|
+
import { CharacterModel } from '../model/index.js';
|
|
4
|
+
import { BvhCharacterPhysics, BvhPhysicsWorld } from '../physics/index.js';
|
|
5
|
+
import { SimpleCharacterOptions, SimpleCharacterState } from './types.js';
|
|
100
6
|
export declare class SimpleCharacter extends Group<Object3DEventMap & {
|
|
101
7
|
loaded: {};
|
|
102
8
|
}> implements SimpleCharacterState {
|
|
@@ -122,3 +28,4 @@ export declare class SimpleCharacter extends Group<Object3DEventMap & {
|
|
|
122
28
|
export * from './update-input-velocity.js';
|
|
123
29
|
export * from './update-rotation.js';
|
|
124
30
|
export * from './apply-input-options.js';
|
|
31
|
+
export * from './types.js';
|
|
@@ -4,7 +4,7 @@ import { Group, Vector3 } from 'three';
|
|
|
4
4
|
import { applySimpleCharacterActionBindingOptions } from './apply-input-options.js';
|
|
5
5
|
import { KeyboardLocomotionActionBindings, PointerCaptureRotateZoomActionBindings, ScreenJoystickLocomotionActionBindings, ScreenButtonJumpActionBindings, } from '../action/index.js';
|
|
6
6
|
import { CharacterCameraBehavior } from '../camera.js';
|
|
7
|
-
import { loadCharacterModel, flattenCharacterModelOptions
|
|
7
|
+
import { loadCharacterModel, flattenCharacterModelOptions } from '../model/index.js';
|
|
8
8
|
import { BvhCharacterPhysics } from '../physics/index.js';
|
|
9
9
|
import { shouldJump } from '../utils.js';
|
|
10
10
|
import { loadSimpleCharacterJumpDownState } from './state/jump-down.js';
|
|
@@ -106,3 +106,4 @@ export class SimpleCharacter extends Group {
|
|
|
106
106
|
export * from './update-input-velocity.js';
|
|
107
107
|
export * from './update-rotation.js';
|
|
108
108
|
export * from './apply-input-options.js';
|
|
109
|
+
export * from './types.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type GraphTimelineState } from '@pmndrs/timeline';
|
|
2
|
-
import type { SimpleCharacterState, SimpleCharacterOptions } from '../
|
|
2
|
+
import type { SimpleCharacterState, SimpleCharacterOptions } from '../types.js';
|
|
3
3
|
export declare function loadSimpleCharacterJumpDownState<T>(state: SimpleCharacterState, options: SimpleCharacterOptions): Promise<GraphTimelineState<T>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GraphTimelineState } from '@pmndrs/timeline';
|
|
2
2
|
import { AnimationAction } from 'three';
|
|
3
|
-
import { SimpleCharacterState, SimpleCharacterOptions } from '../
|
|
3
|
+
import { SimpleCharacterState, SimpleCharacterOptions } from '../types.js';
|
|
4
4
|
export declare function loadSimpleCharacterJumpForwardAction(state: SimpleCharacterState, options: SimpleCharacterOptions): Promise<AnimationAction>;
|
|
5
5
|
export declare function loadSimpleCharacterJumpForwardState<T>(jumpForward: AnimationAction, state: SimpleCharacterState, options: SimpleCharacterOptions): Promise<GraphTimelineState<T>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type GraphTimelineState } from '@pmndrs/timeline';
|
|
2
|
-
import type { SimpleCharacterOptions, SimpleCharacterState } from '../
|
|
2
|
+
import type { SimpleCharacterOptions, SimpleCharacterState } from '../types.js';
|
|
3
3
|
export declare function loadSimpleCharacterJumpLoopState<T>(state: SimpleCharacterState, options: SimpleCharacterOptions): Promise<GraphTimelineState<T>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { GraphTimelineState } from '@pmndrs/timeline';
|
|
2
2
|
import { AnimationAction } from 'three';
|
|
3
|
-
import type { SimpleCharacterOptions, SimpleCharacterState } from '../
|
|
3
|
+
import type { SimpleCharacterOptions, SimpleCharacterState } from '../types.js';
|
|
4
4
|
export declare function loadSimpleCharacterJumpStartState<T>(jumpUp: AnimationAction, jumpForward: AnimationAction, state: SimpleCharacterState, options: SimpleCharacterOptions): Promise<GraphTimelineState<T>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphTimelineState } from '@pmndrs/timeline';
|
|
2
2
|
import { AnimationAction } from 'three';
|
|
3
|
-
import { SimpleCharacterState, SimpleCharacterOptions } from '../
|
|
3
|
+
import { SimpleCharacterState, SimpleCharacterOptions } from '../types.js';
|
|
4
4
|
export declare function loadSimpleCharacterJumpUpAction(state: SimpleCharacterState, options: SimpleCharacterOptions): Promise<AnimationAction>;
|
|
5
5
|
export declare function loadSimpleCharacterJumpUpState<T>(jumpUp: AnimationAction, state: SimpleCharacterState, options: SimpleCharacterOptions): Promise<GraphTimelineState<T>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type GraphTimelineState } from '@pmndrs/timeline';
|
|
2
|
-
import type { SimpleCharacterOptions, SimpleCharacterState } from '../
|
|
2
|
+
import type { SimpleCharacterOptions, SimpleCharacterState } from '../types.js';
|
|
3
3
|
export declare function loadSimpleCharacterMovingState<T>(state: SimpleCharacterState, options: SimpleCharacterOptions): Promise<GraphTimelineState<T>>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Object3D } from 'three';
|
|
2
|
+
import { CharacterAnimationOptions } from '../animation/index.js';
|
|
3
|
+
import { CharacterCameraBehaviorOptions } from '../camera.js';
|
|
4
|
+
import { CharacterModel, CharacterModelOptions } from '../model/index.js';
|
|
5
|
+
import { BvhCharacterPhysics, BvhCharacterPhysicsOptions } from '../physics/index.js';
|
|
6
|
+
export type SimpleCharacterState = {
|
|
7
|
+
camera: Object3D;
|
|
8
|
+
model?: CharacterModel;
|
|
9
|
+
physics: BvhCharacterPhysics;
|
|
10
|
+
lastJump: number;
|
|
11
|
+
};
|
|
12
|
+
export type SimpleCharacterMovementOptions = {
|
|
13
|
+
/**
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
jump?: {
|
|
17
|
+
/**
|
|
18
|
+
* @default 0.2
|
|
19
|
+
*/
|
|
20
|
+
delay?: number;
|
|
21
|
+
/**
|
|
22
|
+
* @default 0.1
|
|
23
|
+
*/
|
|
24
|
+
bufferTime?: number;
|
|
25
|
+
/**
|
|
26
|
+
* @default 8
|
|
27
|
+
*/
|
|
28
|
+
speed?: number;
|
|
29
|
+
} | boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
walk?: {
|
|
34
|
+
speed?: number;
|
|
35
|
+
} | boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
run?: {
|
|
40
|
+
speed?: number;
|
|
41
|
+
} | boolean;
|
|
42
|
+
};
|
|
43
|
+
export type SimpleCharacterAnimationOptions = {
|
|
44
|
+
readonly walk?: CharacterAnimationOptions;
|
|
45
|
+
readonly run?: CharacterAnimationOptions;
|
|
46
|
+
readonly idle?: CharacterAnimationOptions;
|
|
47
|
+
readonly jumpUp?: CharacterAnimationOptions;
|
|
48
|
+
readonly jumpLoop?: CharacterAnimationOptions;
|
|
49
|
+
readonly jumpDown?: CharacterAnimationOptions;
|
|
50
|
+
readonly jumpForward?: CharacterAnimationOptions;
|
|
51
|
+
/**
|
|
52
|
+
* @default "movement"
|
|
53
|
+
*/
|
|
54
|
+
yawRotationBasedOn?: 'camera' | 'movement';
|
|
55
|
+
/**
|
|
56
|
+
* @default 10
|
|
57
|
+
*/
|
|
58
|
+
maxYawRotationSpeed?: number;
|
|
59
|
+
/**
|
|
60
|
+
* @default 0.1
|
|
61
|
+
*/
|
|
62
|
+
crossFadeDuration?: number;
|
|
63
|
+
};
|
|
64
|
+
export type SimpleCharacterActionBindingOptions = {
|
|
65
|
+
screenJoystickRunDistancePx?: number;
|
|
66
|
+
screenJoystickDeadZonePx?: number;
|
|
67
|
+
pointerCaptureRotationSpeed?: number;
|
|
68
|
+
pointerCaptureZoomSpeed?: number;
|
|
69
|
+
pointerLockRotationSpeed?: number;
|
|
70
|
+
pointerLockZoomSpeed?: number;
|
|
71
|
+
keyboardRequiresPointerLock?: boolean;
|
|
72
|
+
keyboardMoveForwardKeys?: Array<string>;
|
|
73
|
+
keyboardMoveBackwardKeys?: Array<string>;
|
|
74
|
+
keyboardMoveLeftKeys?: Array<string>;
|
|
75
|
+
keyboardMoveRightKeys?: Array<string>;
|
|
76
|
+
keyboardRunKeys?: Array<string>;
|
|
77
|
+
keyboardJumpKeys?: Array<string>;
|
|
78
|
+
};
|
|
79
|
+
export type SimpleCharacterOptions = {
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated use actionBindings instead
|
|
82
|
+
*/
|
|
83
|
+
readonly input?: ReadonlyArray<{
|
|
84
|
+
new (domElement: HTMLElement, abortSignal: AbortSignal): any;
|
|
85
|
+
}>;
|
|
86
|
+
readonly actionBindings?: ReadonlyArray<{
|
|
87
|
+
new (domElement: HTMLElement, abortSignal: AbortSignal): any;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated use actionBindingOptions instead
|
|
91
|
+
*/
|
|
92
|
+
inputOptions?: SimpleCharacterActionBindingOptions;
|
|
93
|
+
actionBindingOptions?: SimpleCharacterActionBindingOptions;
|
|
94
|
+
movement?: SimpleCharacterMovementOptions;
|
|
95
|
+
readonly model?: CharacterModelOptions | boolean;
|
|
96
|
+
physics?: BvhCharacterPhysicsOptions;
|
|
97
|
+
cameraBehavior?: CharacterCameraBehaviorOptions;
|
|
98
|
+
readonly animation?: SimpleCharacterAnimationOptions;
|
|
99
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
|
-
import type { SimpleCharacterMovementOptions } from './
|
|
2
|
+
import type { SimpleCharacterMovementOptions } from './types.js';
|
|
3
3
|
import type { BvhCharacterPhysics } from '../physics/index.js';
|
|
4
4
|
export declare function updateSimpleCharacterVelocity(camera: Object3D, physics: BvhCharacterPhysics, options?: SimpleCharacterMovementOptions): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
2
|
import { BvhCharacterPhysics } from '../physics/index.js';
|
|
3
|
-
import type { SimpleCharacterAnimationOptions } from './
|
|
3
|
+
import type { SimpleCharacterAnimationOptions } from './types.js';
|
|
4
4
|
export declare function updateSimpleCharacterRotation(delta: number, physics: BvhCharacterPhysics, camera: Object3D, model: {
|
|
5
5
|
scene: Object3D;
|
|
6
6
|
}, options?: SimpleCharacterAnimationOptions): true | undefined;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { CharacterModel } from './model/index.js';
|
|
1
|
+
import type { CharacterModel, VRMHumanBoneName } from './model/index.js';
|
|
2
2
|
import type { BvhCharacterPhysics } from './physics/index.js';
|
|
3
3
|
import type { AnimationAction } from 'three';
|
|
4
|
+
export type BoneMap = Record<string, VRMHumanBoneName>;
|
|
4
5
|
export declare function getIsMobileMediaQuery(): MediaQueryList | undefined;
|
|
5
6
|
export declare function isMobile(): boolean;
|
|
6
7
|
export type StartAnimationOptions = {
|