@mml-io/3d-web-client-core 0.11.0 → 0.12.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/build/character/Character.d.ts +8 -4
- package/build/character/CharacterManager.d.ts +8 -5
- package/build/character/CharacterMaterial.d.ts +1 -1
- package/build/character/CharacterModel.d.ts +8 -3
- package/build/character/CharacterModelLoader.d.ts +2 -1
- package/build/character/LocalController.d.ts +20 -7
- package/build/collisions/CollisionsManager.d.ts +4 -4
- package/build/index.d.ts +1 -1
- package/build/index.js +404 -211
- package/build/index.js.map +3 -3
- package/package.json +9 -8
@@ -5,16 +5,20 @@ import { CharacterModelLoader } from "./CharacterModelLoader";
|
|
5
5
|
import { CharacterSpeakingIndicator } from "./CharacterSpeakingIndicator";
|
6
6
|
import { AnimationState } from "./CharacterState";
|
7
7
|
import { CharacterTooltip } from "./CharacterTooltip";
|
8
|
-
export type
|
9
|
-
meshFileUrl: string;
|
8
|
+
export type AnimationConfig = {
|
10
9
|
idleAnimationFileUrl: string;
|
11
10
|
jogAnimationFileUrl: string;
|
12
11
|
sprintAnimationFileUrl: string;
|
13
12
|
airAnimationFileUrl: string;
|
14
|
-
|
13
|
+
};
|
14
|
+
export type CharacterDescription = {
|
15
|
+
meshFileUrl?: string;
|
16
|
+
mmlCharacterUrl?: string;
|
17
|
+
mmlCharacterString?: string;
|
15
18
|
};
|
16
19
|
export declare class Character extends Group {
|
17
20
|
private readonly characterDescription;
|
21
|
+
private readonly animationConfig;
|
18
22
|
private readonly characterModelLoader;
|
19
23
|
private readonly characterId;
|
20
24
|
private readonly modelLoadedCallback;
|
@@ -24,7 +28,7 @@ export declare class Character extends Group {
|
|
24
28
|
color: Color;
|
25
29
|
tooltip: CharacterTooltip | null;
|
26
30
|
speakingIndicator: CharacterSpeakingIndicator | null;
|
27
|
-
constructor(characterDescription: CharacterDescription, characterModelLoader: CharacterModelLoader, characterId: number, modelLoadedCallback: () => void, cameraManager: CameraManager, composer: Composer);
|
31
|
+
constructor(characterDescription: CharacterDescription, animationConfig: AnimationConfig, characterModelLoader: CharacterModelLoader, characterId: number, modelLoadedCallback: () => void, cameraManager: CameraManager, composer: Composer);
|
28
32
|
private load;
|
29
33
|
updateAnimation(targetAnimation: AnimationState): void;
|
30
34
|
update(time: number, deltaTime: number): void;
|
@@ -5,7 +5,7 @@ import { CollisionsManager } from "../collisions/CollisionsManager";
|
|
5
5
|
import { KeyInputManager } from "../input/KeyInputManager";
|
6
6
|
import { Composer } from "../rendering/composer";
|
7
7
|
import { TimeManager } from "../time/TimeManager";
|
8
|
-
import { Character, CharacterDescription } from "./Character";
|
8
|
+
import { AnimationConfig, Character, CharacterDescription } from "./Character";
|
9
9
|
import { CharacterModelLoader } from "./CharacterModelLoader";
|
10
10
|
import { CharacterState } from "./CharacterState";
|
11
11
|
import { RemoteController } from "./RemoteController";
|
@@ -18,20 +18,23 @@ export declare class CharacterManager {
|
|
18
18
|
private readonly keyInputManager;
|
19
19
|
private readonly clientStates;
|
20
20
|
private readonly sendUpdate;
|
21
|
+
private readonly animationConfig;
|
22
|
+
private readonly characterDescription;
|
21
23
|
private updateLocationHash;
|
22
24
|
readonly headTargetOffset: Vector3;
|
23
25
|
private id;
|
24
26
|
remoteCharacters: Map<number, Character>;
|
25
27
|
remoteCharacterControllers: Map<number, RemoteController>;
|
26
|
-
private
|
27
|
-
localCharacter: Character | null;
|
28
|
+
private localCharacterSpawned;
|
28
29
|
private localController;
|
30
|
+
localCharacter: Character | null;
|
29
31
|
private cameraOffsetTarget;
|
30
32
|
private cameraOffset;
|
31
33
|
private speakingCharacters;
|
32
34
|
readonly group: Group;
|
33
|
-
constructor(composer: Composer, characterModelLoader: CharacterModelLoader, collisionsManager: CollisionsManager, cameraManager: CameraManager, timeManager: TimeManager, keyInputManager: KeyInputManager, clientStates: Map<number, CharacterState>, sendUpdate: (update: CharacterState) => void);
|
34
|
-
|
35
|
+
constructor(composer: Composer, characterModelLoader: CharacterModelLoader, collisionsManager: CollisionsManager, cameraManager: CameraManager, timeManager: TimeManager, keyInputManager: KeyInputManager, clientStates: Map<number, CharacterState>, sendUpdate: (update: CharacterState) => void, animationConfig: AnimationConfig, characterDescription: CharacterDescription);
|
36
|
+
spawnLocalCharacter(characterDescription: CharacterDescription, id: number, spawnPosition?: Vector3, spawnRotation?: Euler): void;
|
37
|
+
spawnRemoteCharacter(characterDescription: CharacterDescription, id: number, spawnPosition?: Vector3, spawnRotation?: Euler): void;
|
35
38
|
getLocalCharacterPositionAndRotation(): PositionAndRotation;
|
36
39
|
clear(): void;
|
37
40
|
setSpeakingCharacter(id: number, value: boolean): void;
|
@@ -5,7 +5,7 @@ type TUniform<TValue = any> = {
|
|
5
5
|
export declare class CharacterMaterial extends MeshPhysicalMaterial {
|
6
6
|
uniforms: Record<string, TUniform>;
|
7
7
|
colorsCube216: Color[];
|
8
|
-
constructor();
|
8
|
+
constructor(color?: Color);
|
9
9
|
private generateColorCube;
|
10
10
|
update(): void;
|
11
11
|
}
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { AnimationAction, AnimationMixer, Bone, Object3D } from "three";
|
2
|
-
import { CharacterDescription } from "./Character";
|
2
|
+
import { AnimationConfig, CharacterDescription } from "./Character";
|
3
3
|
import { CharacterMaterial } from "./CharacterMaterial";
|
4
4
|
import { CharacterModelLoader } from "./CharacterModelLoader";
|
5
5
|
import { AnimationState } from "./CharacterState";
|
6
6
|
export declare class CharacterModel {
|
7
7
|
private readonly characterDescription;
|
8
|
+
private readonly animationConfig;
|
8
9
|
private characterModelLoader;
|
9
10
|
mesh: Object3D | null;
|
10
11
|
material: CharacterMaterial;
|
@@ -12,11 +13,15 @@ export declare class CharacterModel {
|
|
12
13
|
animations: Record<string, AnimationAction>;
|
13
14
|
animationMixer: AnimationMixer | null;
|
14
15
|
currentAnimation: AnimationState;
|
15
|
-
constructor(characterDescription: CharacterDescription, characterModelLoader: CharacterModelLoader);
|
16
|
+
constructor(characterDescription: CharacterDescription, animationConfig: AnimationConfig, characterModelLoader: CharacterModelLoader);
|
16
17
|
init(): Promise<void>;
|
18
|
+
private applyCustomMaterial;
|
17
19
|
updateAnimation(targetAnimation: AnimationState): void;
|
18
|
-
private
|
20
|
+
private setMainMesh;
|
21
|
+
private composeMMLCharacter;
|
22
|
+
private loadCharacterFromDescription;
|
19
23
|
private loadMainMesh;
|
24
|
+
private cleanAnimationClips;
|
20
25
|
private setAnimationFromFile;
|
21
26
|
private transitionToAnimation;
|
22
27
|
update(time: number): void;
|
@@ -6,6 +6,7 @@ export declare class CharacterModelLoader {
|
|
6
6
|
private modelCache;
|
7
7
|
private ongoingLoads;
|
8
8
|
constructor(maxCacheSize?: number, debug?: boolean);
|
9
|
-
load(fileUrl: string, fileType: "model"
|
9
|
+
load(fileUrl: string, fileType: "model"): Promise<Object3D | undefined>;
|
10
|
+
load(fileUrl: string, fileType: "animation"): Promise<AnimationClip | undefined>;
|
10
11
|
private loadFromUrl;
|
11
12
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Line3 } from "three";
|
1
|
+
import { Line3, Quaternion, Vector3 } from "three";
|
2
2
|
import { CameraManager } from "../camera/CameraManager";
|
3
3
|
import { CollisionsManager } from "../collisions/CollisionsManager";
|
4
4
|
import { KeyInputManager } from "../input/KeyInputManager";
|
@@ -12,13 +12,10 @@ export declare class LocalController {
|
|
12
12
|
private readonly keyInputManager;
|
13
13
|
private readonly cameraManager;
|
14
14
|
private readonly timeManager;
|
15
|
-
private collisionDetectionSteps;
|
16
15
|
capsuleInfo: {
|
17
16
|
radius: number;
|
18
17
|
segment: Line3;
|
19
18
|
};
|
20
|
-
private maxWalkSpeed;
|
21
|
-
private maxRunSpeed;
|
22
19
|
private gravity;
|
23
20
|
private jumpForce;
|
24
21
|
private coyoteTimeThreshold;
|
@@ -28,6 +25,7 @@ export declare class LocalController {
|
|
28
25
|
private characterWasOnGround;
|
29
26
|
private characterAirborneSince;
|
30
27
|
private currentHeight;
|
28
|
+
private currentSurfaceAngle;
|
31
29
|
private characterVelocity;
|
32
30
|
private vectorUp;
|
33
31
|
private vectorDown;
|
@@ -35,9 +33,21 @@ export declare class LocalController {
|
|
35
33
|
private azimuthalAngle;
|
36
34
|
private tempMatrix;
|
37
35
|
private tempSegment;
|
36
|
+
private tempQuaternion;
|
37
|
+
private tempEuler;
|
38
38
|
private tempVector;
|
39
39
|
private tempVector2;
|
40
|
+
private tempVector3;
|
40
41
|
private rayCaster;
|
42
|
+
private surfaceTempQuaternion;
|
43
|
+
private surfaceTempQuaternion2;
|
44
|
+
private surfaceTempVector1;
|
45
|
+
private surfaceTempVector2;
|
46
|
+
private surfaceTempVector3;
|
47
|
+
private surfaceTempVector4;
|
48
|
+
private surfaceTempVector5;
|
49
|
+
private surfaceTempRay;
|
50
|
+
private lastFrameSurfaceState;
|
41
51
|
private forward;
|
42
52
|
private backward;
|
43
53
|
private left;
|
@@ -46,18 +56,21 @@ export declare class LocalController {
|
|
46
56
|
private jump;
|
47
57
|
private anyDirection;
|
48
58
|
private conflictingDirections;
|
49
|
-
private speed;
|
50
|
-
private targetSpeed;
|
51
59
|
networkState: CharacterState;
|
52
60
|
constructor(character: Character, id: number, collisionsManager: CollisionsManager, keyInputManager: KeyInputManager, cameraManager: CameraManager, timeManager: TimeManager);
|
61
|
+
private updateControllerState;
|
53
62
|
update(): void;
|
54
63
|
private getTargetAnimation;
|
55
64
|
private updateRotationOffset;
|
56
65
|
private updateAzimuthalAngle;
|
57
66
|
private computeAngularDifference;
|
58
67
|
private updateRotation;
|
59
|
-
private
|
68
|
+
private applyControls;
|
60
69
|
private updatePosition;
|
70
|
+
getMovementFromSurfaces(userPosition: Vector3, deltaTime: number): {
|
71
|
+
rotation: Quaternion;
|
72
|
+
position: Vector3;
|
73
|
+
} | null;
|
61
74
|
private updateNetworkState;
|
62
75
|
private resetPosition;
|
63
76
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MElement } from "mml-web";
|
2
|
-
import { Group, Line3, Matrix4, Ray, Scene } from "three";
|
2
|
+
import { Group, Line3, Matrix4, Ray, Scene, Vector3 } from "three";
|
3
3
|
import { MeshBVH } from "three-mesh-bvh";
|
4
|
-
type CollisionMeshState = {
|
4
|
+
export type CollisionMeshState = {
|
5
5
|
matrix: Matrix4;
|
6
6
|
source: Group;
|
7
7
|
meshBVH: MeshBVH;
|
@@ -14,6 +14,7 @@ export declare class CollisionsManager {
|
|
14
14
|
private tempVector;
|
15
15
|
private tempVector2;
|
16
16
|
private tempVector3;
|
17
|
+
private tempQuaternion;
|
17
18
|
private tempRay;
|
18
19
|
private tempMatrix;
|
19
20
|
private tempMatrix2;
|
@@ -24,7 +25,7 @@ export declare class CollisionsManager {
|
|
24
25
|
collisionMeshState: Map<Group, CollisionMeshState>;
|
25
26
|
private collisionTrigger;
|
26
27
|
constructor(scene: Scene);
|
27
|
-
|
28
|
+
raycastFirst(ray: Ray): [number, Vector3, CollisionMeshState] | null;
|
28
29
|
private createCollisionMeshState;
|
29
30
|
addMeshesGroup(group: Group, mElement?: MElement): void;
|
30
31
|
updateMeshesGroup(group: Group): void;
|
@@ -32,4 +33,3 @@ export declare class CollisionsManager {
|
|
32
33
|
private applyCollider;
|
33
34
|
applyColliders(tempSegment: Line3, radius: number): void;
|
34
35
|
}
|
35
|
-
export {};
|
package/build/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export { CameraManager } from "./camera/CameraManager";
|
2
|
-
export { CharacterDescription } from "./character/Character";
|
2
|
+
export { CharacterDescription, AnimationConfig } from "./character/Character";
|
3
3
|
export { CharacterManager } from "./character/CharacterManager";
|
4
4
|
export * from "./character/url-position";
|
5
5
|
export * from "./helpers/math-helpers";
|