@mml-io/3d-web-client-core 0.1.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/camera/CameraManager.d.ts +23 -0
- package/build/character/Character.d.ts +32 -0
- package/build/character/CharacterManager.d.ts +29 -0
- package/build/character/CharacterMaterial.d.ts +11 -0
- package/build/character/CharacterModel.d.ts +23 -0
- package/build/character/CharacterState.d.ts +21 -0
- package/build/character/LocalController.d.ts +50 -0
- package/build/character/ModelLoader.d.ts +9 -0
- package/build/character/RemoteController.d.ts +20 -0
- package/build/collisions/CollisionsManager.d.ts +17 -0
- package/build/helpers/math-helpers.d.ts +4 -0
- package/build/index.d.ts +9 -0
- package/build/index.js +1476 -0
- package/build/index.js.map +7 -0
- package/build/input/KeyInputManager.d.ts +11 -0
- package/build/mml/MMLCompositionScene.d.ts +18 -0
- package/build/rendering/composer.d.ts +20 -0
- package/build/rendering/post-effects/gauss-grain.d.ts +2 -0
- package/build/rendering/shaders/bayer-dither.d.ts +1 -0
- package/build/rendering/shaders/shader-helpers.d.ts +4 -0
- package/build/rendering/shaders/vertex-shader.d.ts +1 -0
- package/build/time/TimeManager.d.ts +16 -0
- package/package.json +26 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
import { PerspectiveCamera } from "three";
|
2
|
+
export declare class CameraManager {
|
3
|
+
readonly camera: PerspectiveCamera;
|
4
|
+
private dragging;
|
5
|
+
private target;
|
6
|
+
private targetDistance;
|
7
|
+
private maxTargetDistance;
|
8
|
+
private distance;
|
9
|
+
private targetPhi;
|
10
|
+
private phi;
|
11
|
+
private targetTheta;
|
12
|
+
private theta;
|
13
|
+
private hadTarget;
|
14
|
+
constructor();
|
15
|
+
private onResize;
|
16
|
+
private onMouseDown;
|
17
|
+
private onMouseUp;
|
18
|
+
private onMouseMove;
|
19
|
+
private onMouseWheel;
|
20
|
+
setTarget(target: THREE.Vector3): void;
|
21
|
+
private reverseUpdateFromPositions;
|
22
|
+
update(): void;
|
23
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Color, Vector3 } from "three";
|
2
|
+
import { CameraManager } from "../camera/CameraManager";
|
3
|
+
import { CollisionsManager } from "../collisions/CollisionsManager";
|
4
|
+
import { KeyInputManager } from "../input/KeyInputManager";
|
5
|
+
import { TimeManager } from "../time/TimeManager";
|
6
|
+
import { CharacterModel } from "./CharacterModel";
|
7
|
+
import { LocalController } from "./LocalController";
|
8
|
+
export type CharacterDescription = {
|
9
|
+
meshFileUrl: string;
|
10
|
+
idleAnimationFileUrl: string;
|
11
|
+
jogAnimationFileUrl: string;
|
12
|
+
sprintAnimationFileUrl: string;
|
13
|
+
modelScale: number;
|
14
|
+
};
|
15
|
+
export declare class Character {
|
16
|
+
private readonly characterDescription;
|
17
|
+
private readonly id;
|
18
|
+
private readonly isLocal;
|
19
|
+
private readonly modelLoadedCallback;
|
20
|
+
private readonly collisionsManager;
|
21
|
+
private readonly keyInputManager;
|
22
|
+
private readonly cameraManager;
|
23
|
+
private readonly timeManager;
|
24
|
+
controller: LocalController | null;
|
25
|
+
name: string | null;
|
26
|
+
model: CharacterModel | null;
|
27
|
+
color: Color;
|
28
|
+
position: Vector3;
|
29
|
+
constructor(characterDescription: CharacterDescription, id: number, isLocal: boolean, modelLoadedCallback: () => void, collisionsManager: CollisionsManager, keyInputManager: KeyInputManager, cameraManager: CameraManager, timeManager: TimeManager);
|
30
|
+
private load;
|
31
|
+
update(time: number): void;
|
32
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { PositionAndRotation } from "mml-web";
|
2
|
+
import { Group } from "three";
|
3
|
+
import { CameraManager } from "../camera/CameraManager";
|
4
|
+
import { CollisionsManager } from "../collisions/CollisionsManager";
|
5
|
+
import { KeyInputManager } from "../input/KeyInputManager";
|
6
|
+
import { TimeManager } from "../time/TimeManager";
|
7
|
+
import { Character, CharacterDescription } from "./Character";
|
8
|
+
import { CharacterState } from "./CharacterState";
|
9
|
+
import { RemoteController } from "./RemoteController";
|
10
|
+
export declare class CharacterManager {
|
11
|
+
private readonly collisionsManager;
|
12
|
+
private readonly cameraManager;
|
13
|
+
private readonly timeManager;
|
14
|
+
private readonly inputManager;
|
15
|
+
private readonly clientStates;
|
16
|
+
private readonly sendUpdate;
|
17
|
+
private updateLocationHash;
|
18
|
+
loadingCharacters: Map<number, Promise<Character>>;
|
19
|
+
remoteCharacters: Map<number, Character>;
|
20
|
+
remoteCharacterControllers: Map<number, RemoteController>;
|
21
|
+
private characterDescription;
|
22
|
+
character: Character | null;
|
23
|
+
readonly group: Group;
|
24
|
+
constructor(collisionsManager: CollisionsManager, cameraManager: CameraManager, timeManager: TimeManager, inputManager: KeyInputManager, clientStates: Map<number, CharacterState>, sendUpdate: (update: CharacterState) => void);
|
25
|
+
spawnCharacter(characterDescription: CharacterDescription, id: number, isLocal?: boolean): Promise<Character>;
|
26
|
+
getLocalCharacterPositionAndRotation(): PositionAndRotation;
|
27
|
+
clear(): void;
|
28
|
+
update(): void;
|
29
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Color, MeshPhysicalMaterial } from "three";
|
2
|
+
type TUniform<TValue = any> = {
|
3
|
+
value: TValue;
|
4
|
+
};
|
5
|
+
export declare class CharacterMaterial extends MeshPhysicalMaterial {
|
6
|
+
uniforms: Record<string, TUniform>;
|
7
|
+
colorsCube216: Color[];
|
8
|
+
constructor();
|
9
|
+
private generateColorCube;
|
10
|
+
}
|
11
|
+
export {};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { AnimationAction, AnimationMixer, Object3D } from "three";
|
2
|
+
import { CharacterDescription } from "./Character";
|
3
|
+
import { CharacterMaterial } from "./CharacterMaterial";
|
4
|
+
import { AnimationState } from "./CharacterState";
|
5
|
+
export declare class CharacterModel {
|
6
|
+
private readonly characterDescription;
|
7
|
+
private modelLoader;
|
8
|
+
mesh: Object3D | null;
|
9
|
+
material: CharacterMaterial;
|
10
|
+
animations: Record<string, AnimationAction>;
|
11
|
+
animationMixer: AnimationMixer | null;
|
12
|
+
currentAnimation: AnimationState;
|
13
|
+
constructor(characterDescription: CharacterDescription);
|
14
|
+
init(): Promise<void>;
|
15
|
+
updateAnimation(targetAnimation: AnimationState, deltaTime: number): void;
|
16
|
+
hideMaterialByMeshName(meshName: any): void;
|
17
|
+
private setShadows;
|
18
|
+
private applyMaterialToAllSkinnedMeshes;
|
19
|
+
private initAnimationMixer;
|
20
|
+
private loadMainMesh;
|
21
|
+
private setAnimationFromFile;
|
22
|
+
private transitionToAnimation;
|
23
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
export declare enum AnimationState {
|
2
|
+
"idle" = 0,
|
3
|
+
"walking" = 1,
|
4
|
+
"running" = 2,
|
5
|
+
"jumpToAir" = 3,
|
6
|
+
"air" = 4,
|
7
|
+
"airToGround" = 5
|
8
|
+
}
|
9
|
+
export type CharacterState = {
|
10
|
+
id: number;
|
11
|
+
position: {
|
12
|
+
x: number;
|
13
|
+
y: number;
|
14
|
+
z: number;
|
15
|
+
};
|
16
|
+
rotation: {
|
17
|
+
quaternionY: number;
|
18
|
+
quaternionW: number;
|
19
|
+
};
|
20
|
+
state: AnimationState;
|
21
|
+
};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { Line3 } from "three";
|
2
|
+
import { CameraManager } from "../camera/CameraManager";
|
3
|
+
import { CollisionsManager } from "../collisions/CollisionsManager";
|
4
|
+
import { KeyInputManager } from "../input/KeyInputManager";
|
5
|
+
import { TimeManager } from "../time/TimeManager";
|
6
|
+
import { CharacterModel } from "./CharacterModel";
|
7
|
+
import { CharacterState } from "./CharacterState";
|
8
|
+
export declare class LocalController {
|
9
|
+
private readonly model;
|
10
|
+
private readonly id;
|
11
|
+
private readonly collisionsManager;
|
12
|
+
private readonly keyInputManager;
|
13
|
+
private readonly cameraManager;
|
14
|
+
private readonly timeManager;
|
15
|
+
private collisionDetectionSteps;
|
16
|
+
capsuleInfo: {
|
17
|
+
radius: number;
|
18
|
+
segment: Line3;
|
19
|
+
};
|
20
|
+
private characterOnGround;
|
21
|
+
private characterVelocity;
|
22
|
+
private gravity;
|
23
|
+
private upVector;
|
24
|
+
private rotationOffset;
|
25
|
+
private azimuthalAngle;
|
26
|
+
private tempBox;
|
27
|
+
private tempMatrix;
|
28
|
+
private tempSegment;
|
29
|
+
private tempVector;
|
30
|
+
private tempVector2;
|
31
|
+
private jumpInput;
|
32
|
+
private jumpForce;
|
33
|
+
private canJump;
|
34
|
+
private inputDirections;
|
35
|
+
private runInput;
|
36
|
+
private thirdPersonCamera;
|
37
|
+
private speed;
|
38
|
+
private targetSpeed;
|
39
|
+
networkState: CharacterState;
|
40
|
+
constructor(model: CharacterModel, id: number, collisionsManager: CollisionsManager, keyInputManager: KeyInputManager, cameraManager: CameraManager, timeManager: TimeManager);
|
41
|
+
update(): void;
|
42
|
+
private getTargetAnimation;
|
43
|
+
private updateRotationOffset;
|
44
|
+
private updateAzimuthalAngle;
|
45
|
+
private updateRotation;
|
46
|
+
private addScaledVectorToCharacter;
|
47
|
+
private updatePosition;
|
48
|
+
private updateNetworkState;
|
49
|
+
private resetPosition;
|
50
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { AnimationClip, Object3D } from "three";
|
2
|
+
export declare class ModelLoader {
|
3
|
+
private debug;
|
4
|
+
private readonly loadingManager;
|
5
|
+
private readonly fbxLoader;
|
6
|
+
private readonly gltfLoader;
|
7
|
+
constructor();
|
8
|
+
load(fileUrl: string, fileType: "model" | "animation"): Promise<Object3D | AnimationClip | undefined>;
|
9
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { Object3D } from "three";
|
2
|
+
import { Character } from "./Character";
|
3
|
+
import { AnimationState, CharacterState } from "./CharacterState";
|
4
|
+
export declare class RemoteController {
|
5
|
+
readonly character: Character;
|
6
|
+
readonly id: number;
|
7
|
+
characterModel: Object3D | null;
|
8
|
+
private loadManager;
|
9
|
+
private animationMixer;
|
10
|
+
private animations;
|
11
|
+
currentAnimation: AnimationState;
|
12
|
+
private fbxLoader;
|
13
|
+
private gltfLoader;
|
14
|
+
networkState: CharacterState;
|
15
|
+
constructor(character: Character, id: number);
|
16
|
+
update(clientUpdate: CharacterState, time: number, deltaTime: number): void;
|
17
|
+
setAnimationFromFile(animationType: AnimationState, fileName: string): void;
|
18
|
+
private transitionToAnimation;
|
19
|
+
private updateFromNetwork;
|
20
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { MElement } from "mml-web";
|
2
|
+
import { Box3, Group, Line3, Scene } from "three";
|
3
|
+
export declare class CollisionsManager {
|
4
|
+
private debug;
|
5
|
+
private scene;
|
6
|
+
private tempVector;
|
7
|
+
private tempVector2;
|
8
|
+
private collisionMeshState;
|
9
|
+
private collisionTrigger;
|
10
|
+
constructor(scene: Scene);
|
11
|
+
private createCollisionMeshState;
|
12
|
+
addMeshesGroup(group: Group, mElement?: MElement): void;
|
13
|
+
updateMeshesGroup(group: Group): void;
|
14
|
+
removeMeshesGroup(group: Group): void;
|
15
|
+
private applyCollider;
|
16
|
+
applyColliders(tempSegment: Line3, radius: number, boundingBox: Box3): void;
|
17
|
+
}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Vector3 } from "three";
|
2
|
+
export declare const getSpawnPositionInsideCircle: (radius: number, positions: number, id: number, yPos?: number) => Vector3;
|
3
|
+
export declare const round: (n: number, digits: number) => number;
|
4
|
+
export declare const ease: (target: number, n: number, factor: number) => number;
|
package/build/index.d.ts
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
export { CameraManager } from "./camera/CameraManager";
|
2
|
+
export { CharacterDescription } from "./character/Character";
|
3
|
+
export { CharacterManager } from "./character/CharacterManager";
|
4
|
+
export { CharacterState, AnimationState } from "./character/CharacterState";
|
5
|
+
export { KeyInputManager } from "./input/KeyInputManager";
|
6
|
+
export { MMLCompositionScene } from "./mml/MMLCompositionScene";
|
7
|
+
export { Composer } from "./rendering/composer";
|
8
|
+
export { TimeManager } from "./time/TimeManager";
|
9
|
+
export { CollisionsManager } from "./collisions/CollisionsManager";
|