lythreeframe 1.3.13 → 2.0.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/dist/bundle.cjs.js +90 -60
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +84 -64
- package/dist/bundle.esm.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/src/AssetManagement/AssetManager.d.ts +14 -10
- package/dist/src/Frame/Controller.d.ts +2 -0
- package/dist/src/Frame/Parameters/ViewportParameters.d.ts +1 -0
- package/dist/src/Frame/Viewport.d.ts +2 -1
- package/dist/src/Frame/World.d.ts +3 -0
- package/dist/src/Object/Components/2D/CSS3DWebPanelComponent.d.ts +26 -0
- package/dist/src/Object/Components/Mesh/Line/CurveComponent.d.ts +13 -0
- package/dist/src/Object/Components/Text/Text3DComponent.d.ts +56 -0
- package/dist/src/Object/PawnV2/FirstPerson.d.ts +38 -5
- package/dist/src/Object/PawnV2/Oribital.d.ts +38 -15
- package/dist/src/Object/PawnV2/Pawn.d.ts +12 -11
- package/dist/src/Object/PawnV2/Spectator.d.ts +19 -0
- package/dist/src/Object/PawnV2/TransformControl.d.ts +7 -3
- package/dist/src/Physics/BoxColliderComponent.d.ts +22 -0
- package/dist/src/Physics/CapsuleColliderComponent.d.ts +40 -0
- package/dist/src/Physics/ColliderComponent.d.ts +62 -0
- package/dist/src/Physics/CollisionTypes.d.ts +17 -0
- package/dist/src/Physics/MeshColliderComponent.d.ts +46 -0
- package/dist/src/Physics/PhysicsWorld.d.ts +31 -0
- package/dist/src/Physics/SphereColliderComponent.d.ts +14 -0
- package/dist/src/Physics/index.d.ts +9 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,9 @@ export { LevelComponent } from "./src/Object/Components/Level/LevelComponent";
|
|
|
42
42
|
export { DirectionalLightComponent } from "./src/Object/Components/Light/DirectionalLight/DirectionalLightComponent";
|
|
43
43
|
export { AmbientLightComponent } from './src/Object/Components/Light/AmbientLight/AmbientLightComponent';
|
|
44
44
|
export { LabelComponent } from "./src/Object/Components/2D/2DComponent";
|
|
45
|
+
export { CSS3DWebPanelComponent } from "./src/Object/Components/2D/CSS3DWebPanelComponent";
|
|
46
|
+
export { Text3DComponent } from "./src/Object/Components/Text/Text3DComponent";
|
|
47
|
+
export type { Text3DOptions } from "./src/Object/Components/Text/Text3DComponent";
|
|
45
48
|
export { SkyComponent } from "./src/Object/Components/Sky/SkyComponent";
|
|
46
49
|
export type { SkyComponentParam } from "./src/Object/Components/Sky/SkyComponent";
|
|
47
50
|
export { DefaultSkyParam } from "./src/Object/Components/Sky/SkyComponent";
|
|
@@ -66,8 +69,12 @@ export type { LensFlareParam } from "./src/PostProcess/Param/LensFlare";
|
|
|
66
69
|
export { PostProcessManager } from "./src/Frame/Rendering/PostProcess";
|
|
67
70
|
export { Orbital } from "./src/Object/PawnV2/Oribital";
|
|
68
71
|
export { FirstPerson } from "./src/Object/PawnV2/FirstPerson";
|
|
72
|
+
export { Spectator } from "./src/Object/PawnV2/Spectator";
|
|
73
|
+
export { Pawn } from "./src/Object/PawnV2/Pawn";
|
|
69
74
|
export type { ITransforming } from "./src/Object/PawnV2/TransformControl";
|
|
70
75
|
export type { TransformType } from "./src/Object/PawnV2/TransformControl";
|
|
71
76
|
export type { TransformGizmoOptions } from "./src/Object/PawnV2/TransformControl";
|
|
72
77
|
export { TransformGizmo } from "./src/Object/PawnV2/TransformControl";
|
|
73
78
|
export { ThreeObjectLibrary } from "./src/Library/ResourceLibrary";
|
|
79
|
+
export { PhysicsWorld, ColliderComponent, BoxColliderComponent, SphereColliderComponent, CapsuleColliderComponent, MeshColliderComponent, CollisionResponse, CollisionChannel, CollisionShapeType } from "./src/Physics";
|
|
80
|
+
export type { LineTraceHitResult, PhysicsHitResult, CollisionResponseMap } from "./src/Physics";
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import { BufferGeometry, LoadingManager, Material, Mesh, Texture } from
|
|
2
|
-
import { SceneComponent } from
|
|
3
|
-
import { TAssetPointer } from
|
|
4
|
-
import { DRACOLoader, GLTF, GLTFLoader } from 'three/examples/jsm/Addons.js';
|
|
5
|
-
import { Object3D } from
|
|
6
|
-
import { ThreeJsApp } from
|
|
7
|
-
import { MaterialAssetPointer } from
|
|
8
|
-
import { TextureAssetPointer } from
|
|
9
|
-
import { GeometryAssetPointer } from
|
|
1
|
+
import { BufferGeometry, LoadingManager, Material, Mesh, Texture } from 'three/webgpu';
|
|
2
|
+
import { SceneComponent } from '../Object/Components/SceneComponent';
|
|
3
|
+
import { TAssetPointer } from './AssetPointer/AssetPointer';
|
|
4
|
+
import { DRACOLoader, GLTF, GLTFLoader, KTX2Loader } from 'three/examples/jsm/Addons.js';
|
|
5
|
+
import { Object3D } from 'three/webgpu';
|
|
6
|
+
import { ThreeJsApp } from '../ThreeJsApp';
|
|
7
|
+
import { MaterialAssetPointer } from './AssetPointer/Assets/MaterialAssetPointer';
|
|
8
|
+
import { TextureAssetPointer } from './AssetPointer/Assets/TextureAssetPointer';
|
|
9
|
+
import { GeometryAssetPointer } from './AssetPointer/Assets/GeometryAssetPointer';
|
|
10
10
|
export declare class AssetManager {
|
|
11
11
|
protected geometryAssets: Map<string, GeometryAssetPointer>;
|
|
12
12
|
protected textureAssets: Map<string, TextureAssetPointer>;
|
|
13
13
|
protected materialAssets: Map<string, MaterialAssetPointer>;
|
|
14
|
-
protected
|
|
14
|
+
protected static _dracoLoader: DRACOLoader | null;
|
|
15
|
+
protected static _ktx2Loader: KTX2Loader | null;
|
|
15
16
|
protected readonly gltfLoader: GLTFLoader;
|
|
16
17
|
protected readonly loadingManager: LoadingManager;
|
|
17
18
|
protected app: ThreeJsApp;
|
|
18
19
|
constructor(app: ThreeJsApp);
|
|
19
20
|
get LoadingManager(): LoadingManager;
|
|
21
|
+
get KTX2Loader(): KTX2Loader | null;
|
|
20
22
|
init(): Promise<void>;
|
|
23
|
+
setupKTX2Loader(transcoderPath: string): Promise<void>;
|
|
21
24
|
setupDracoLoader(dracoPath: string): void;
|
|
22
25
|
convertThreeObjectToLYObject(parentLYComponent: SceneComponent, threejsObject: Object3D): SceneComponent | null;
|
|
23
26
|
collectResourcesAndReferences(object: Object3D): void;
|
|
@@ -31,5 +34,6 @@ export declare class AssetManager {
|
|
|
31
34
|
addTextureAsset(asset: Texture, referenceCount?: number): TextureAssetPointer;
|
|
32
35
|
addGeometryAsset(asset: BufferGeometry, referenceCount?: number): GeometryAssetPointer;
|
|
33
36
|
releaseAsset(asset: BufferGeometry | Material | Texture): void;
|
|
37
|
+
dispose(): void;
|
|
34
38
|
clearAssets(): void;
|
|
35
39
|
}
|
|
@@ -53,6 +53,7 @@ export declare class Controller {
|
|
|
53
53
|
protected _app: ThreeJsApp;
|
|
54
54
|
protected _pawn: Pawn | null;
|
|
55
55
|
protected raycaster: Raycaster;
|
|
56
|
+
protected _switchPawnTween: gsap.core.Tween | null;
|
|
56
57
|
protected hoveringComponent: SceneComponent | null;
|
|
57
58
|
protected hoveringActor: Actor | null;
|
|
58
59
|
protected prepareClickComponent: SceneComponent | null;
|
|
@@ -102,6 +103,7 @@ export declare class Controller {
|
|
|
102
103
|
constructor(app: ThreeJsApp);
|
|
103
104
|
init(): void;
|
|
104
105
|
updateCamera(): void;
|
|
106
|
+
switchPawn(pawn: Pawn, cameraMoveTime?: number): Promise<void>;
|
|
105
107
|
tick(deltaTime: number): void;
|
|
106
108
|
destroy(): void;
|
|
107
109
|
protected onPointerMoveEvent(event: MouseEvent): void;
|
|
@@ -13,6 +13,7 @@ export declare class Viewport {
|
|
|
13
13
|
get app(): ThreeJsApp;
|
|
14
14
|
private _renderer;
|
|
15
15
|
private labelRenderer;
|
|
16
|
+
private css3dRenderer;
|
|
16
17
|
protected _app: ThreeJsApp | null;
|
|
17
18
|
private resizeObserver;
|
|
18
19
|
private _outerContainer;
|
|
@@ -23,6 +24,7 @@ export declare class Viewport {
|
|
|
23
24
|
constructor(app: ThreeJsApp, viewportParam: ViewportParam, rendererParam: RendererParameters, postProcessParam: PostProcessParam);
|
|
24
25
|
protected createRenderer(rendererParam: RendererParameters): void;
|
|
25
26
|
protected createLabelRenderer(): void;
|
|
27
|
+
protected createCSS3DRenderer(): void;
|
|
26
28
|
protected createUILayer(): void;
|
|
27
29
|
init(): void;
|
|
28
30
|
protected setupPostProcess(): void;
|
|
@@ -45,7 +47,6 @@ export declare class Viewport {
|
|
|
45
47
|
setShadowMapType(type: ShadowMapType): void;
|
|
46
48
|
setToneMapping(toneMapping: ToneMapping): void;
|
|
47
49
|
setToneMappingExposure(exposure: number): void;
|
|
48
|
-
setLogarithmicDepthBufferEnabled(enabled: boolean): void;
|
|
49
50
|
setDepth(depth: boolean): void;
|
|
50
51
|
setStencil(stencil: boolean): void;
|
|
51
52
|
destroy(): void;
|
|
@@ -5,12 +5,15 @@ import { Controller } from "./Controller";
|
|
|
5
5
|
import { Actor } from "../Object/Actor";
|
|
6
6
|
import { LevelActor } from "../Object/Actors/Level/LevelActor";
|
|
7
7
|
import { WorldParam } from "./Parameters/WorldParameter";
|
|
8
|
+
import { PhysicsWorld } from "../Physics/PhysicsWorld";
|
|
8
9
|
export declare class World {
|
|
9
10
|
get scene(): Scene;
|
|
10
11
|
get viewport(): Viewport;
|
|
11
12
|
get controller(): Controller;
|
|
12
13
|
get rootActor(): LevelActor;
|
|
14
|
+
get physics(): PhysicsWorld;
|
|
13
15
|
protected _rootActor: LevelActor | null;
|
|
16
|
+
protected _physics: PhysicsWorld;
|
|
14
17
|
protected app: ThreeJsApp;
|
|
15
18
|
protected actors: Set<Actor>;
|
|
16
19
|
protected tickableActors: Set<Actor>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CSS3DObject } from "three/examples/jsm/Addons.js";
|
|
2
|
+
import { Mesh } from "three";
|
|
3
|
+
import { SceneComponent } from "../SceneComponent";
|
|
4
|
+
import { ThreeJsApp } from "../../../ThreeJsApp";
|
|
5
|
+
export declare class CSS3DWebPanelComponent extends SceneComponent {
|
|
6
|
+
get threeObject(): CSS3DObject;
|
|
7
|
+
set threeObject(newThreeObject: CSS3DObject);
|
|
8
|
+
protected obj: CSS3DObject;
|
|
9
|
+
private wrapper;
|
|
10
|
+
private iframe;
|
|
11
|
+
private targetMesh;
|
|
12
|
+
private readonly meshes;
|
|
13
|
+
private readonly depthMaskMeshes;
|
|
14
|
+
private readonly alphaPunchMeshes;
|
|
15
|
+
private tickFunc;
|
|
16
|
+
private readonly cameraWorldPos;
|
|
17
|
+
private readonly panelWorldPos;
|
|
18
|
+
private readonly rayDir;
|
|
19
|
+
private readonly raycaster;
|
|
20
|
+
private occlusionCandidates;
|
|
21
|
+
constructor(app: ThreeJsApp, meshes: Mesh[], rawUrl: string, uuid?: string);
|
|
22
|
+
protected createDefaultObject(): CSS3DObject;
|
|
23
|
+
private setupMasks;
|
|
24
|
+
private setupOcclusionTick;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CatmullRomCurve3, Line, Vector3 } from "three/webgpu";
|
|
2
|
+
import { SceneComponent } from "../../SceneComponent";
|
|
3
|
+
import { ThreeJsApp } from "../../../../ThreeJsApp";
|
|
4
|
+
export declare class CurveComponent extends SceneComponent {
|
|
5
|
+
private curve;
|
|
6
|
+
protected createDefaultObject(): Line;
|
|
7
|
+
constructor(app: ThreeJsApp, uuid?: string);
|
|
8
|
+
setPoints(points: Vector3[], closed?: boolean, curveType?: 'centripetal' | 'chordal' | 'catmullrom', tension?: number): void;
|
|
9
|
+
getPointAt(u: number): Vector3 | null;
|
|
10
|
+
getTangentAt(u: number): Vector3 | null;
|
|
11
|
+
getLength(): number;
|
|
12
|
+
getCurve(): CatmullRomCurve3 | null;
|
|
13
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Object3D } from "three/webgpu";
|
|
2
|
+
import { SceneComponent } from "../SceneComponent";
|
|
3
|
+
import { ThreeJsApp } from "../../../ThreeJsApp";
|
|
4
|
+
export interface Text3DOptions {
|
|
5
|
+
text?: string;
|
|
6
|
+
fontUrl?: string;
|
|
7
|
+
size?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
curveSegments?: number;
|
|
10
|
+
bevelEnabled?: boolean;
|
|
11
|
+
bevelThickness?: number;
|
|
12
|
+
bevelSize?: number;
|
|
13
|
+
bevelOffset?: number;
|
|
14
|
+
bevelSegments?: number;
|
|
15
|
+
color?: string;
|
|
16
|
+
sideColor?: string;
|
|
17
|
+
isUnlit?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class Text3DComponent extends SceneComponent {
|
|
20
|
+
private _text;
|
|
21
|
+
private _fontUrl;
|
|
22
|
+
private _size;
|
|
23
|
+
private _height;
|
|
24
|
+
private _curveSegments;
|
|
25
|
+
private _bevelEnabled;
|
|
26
|
+
private _bevelThickness;
|
|
27
|
+
private _bevelSize;
|
|
28
|
+
private _bevelOffset;
|
|
29
|
+
private _bevelSegments;
|
|
30
|
+
private _color;
|
|
31
|
+
private _sideColor;
|
|
32
|
+
private _isUnlit;
|
|
33
|
+
private _font;
|
|
34
|
+
private _mesh;
|
|
35
|
+
private _group;
|
|
36
|
+
private static _fontLoader;
|
|
37
|
+
private static _fontCache;
|
|
38
|
+
constructor(app: ThreeJsApp, options?: Text3DOptions, uuid?: string);
|
|
39
|
+
protected createDefaultObject(): Object3D;
|
|
40
|
+
get text(): string;
|
|
41
|
+
set text(value: string);
|
|
42
|
+
get color(): string;
|
|
43
|
+
set color(value: string);
|
|
44
|
+
get sideColor(): string;
|
|
45
|
+
set sideColor(value: string);
|
|
46
|
+
get size(): number;
|
|
47
|
+
set size(value: number);
|
|
48
|
+
get height(): number;
|
|
49
|
+
set height(value: number);
|
|
50
|
+
get fontUrl(): string;
|
|
51
|
+
set fontUrl(value: string);
|
|
52
|
+
private loadFontAndRefresh;
|
|
53
|
+
private refreshGeometry;
|
|
54
|
+
private updateMaterial;
|
|
55
|
+
destroy(): void;
|
|
56
|
+
}
|
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
import { Pawn } from "./Pawn";
|
|
2
|
-
import {
|
|
2
|
+
import { ThreeJsApp } from "../../ThreeJsApp";
|
|
3
3
|
import { Vector3, Quaternion } from "three/webgpu";
|
|
4
|
+
import { SceneComponent } from "../Components/SceneComponent";
|
|
4
5
|
export declare class FirstPerson extends Pawn {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
moveSpeed: number;
|
|
7
|
+
lookSpeed: number;
|
|
8
|
+
enableGravity: boolean;
|
|
9
|
+
gravity: number;
|
|
10
|
+
eyeHeight: number;
|
|
11
|
+
private _verticalVelocity;
|
|
12
|
+
private _yaw;
|
|
13
|
+
private _pitch;
|
|
14
|
+
private _targetPos;
|
|
15
|
+
private _clickMarker;
|
|
16
|
+
private _moveForward;
|
|
17
|
+
private _moveBackward;
|
|
18
|
+
private _moveLeft;
|
|
19
|
+
private _moveRight;
|
|
20
|
+
private _moveUp;
|
|
21
|
+
private _moveDown;
|
|
22
|
+
private _isRightDragging;
|
|
23
|
+
constructor(app: ThreeJsApp);
|
|
24
|
+
protected constructRootComponent(): SceneComponent;
|
|
25
|
+
landToGround(): void;
|
|
26
|
+
possess(): void;
|
|
27
|
+
unpossess(): void;
|
|
28
|
+
getTargetCameraState(): {
|
|
7
29
|
position: Vector3;
|
|
8
30
|
quaternion: Quaternion;
|
|
9
|
-
|
|
10
|
-
|
|
31
|
+
};
|
|
32
|
+
private onContextMenu;
|
|
33
|
+
private onBlur;
|
|
34
|
+
private onMouseDown;
|
|
35
|
+
private onMouseUp;
|
|
36
|
+
private onClick;
|
|
37
|
+
private onPointerLockChange;
|
|
38
|
+
private onMouseMove;
|
|
39
|
+
private setCameraDraggingState;
|
|
40
|
+
private onKeyDown;
|
|
41
|
+
private onKeyUp;
|
|
42
|
+
tick(deltaTime: number): void;
|
|
43
|
+
private updateCameraFromPawn;
|
|
11
44
|
}
|
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
import { Pawn } from "./Pawn";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Euler, Quaternion, Vector3 } from "three";
|
|
2
|
+
import { Euler, Quaternion, Vector3 } from "three/webgpu";
|
|
3
|
+
import { ThreeJsApp } from "../../ThreeJsApp";
|
|
5
4
|
export declare class Orbital extends Pawn {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
distance: number;
|
|
6
|
+
minDistance: number;
|
|
7
|
+
maxDistance: number;
|
|
8
|
+
rotateSpeed: number;
|
|
9
|
+
zoomSpeed: number;
|
|
10
|
+
minPolarAngle: number;
|
|
11
|
+
maxPolarAngle: number;
|
|
12
|
+
minAzimuthAngle: number;
|
|
13
|
+
maxAzimuthAngle: number;
|
|
14
|
+
enableDamping: boolean;
|
|
15
|
+
dampingFactor: number;
|
|
16
|
+
private _isDragging;
|
|
17
|
+
private _lastPointerPosition;
|
|
18
|
+
private _targetPosition;
|
|
19
|
+
private _targetQuaternion;
|
|
20
|
+
private _targetDistance;
|
|
21
|
+
private _focusTween;
|
|
22
|
+
constructor(app: ThreeJsApp);
|
|
12
23
|
possess(): void;
|
|
13
|
-
|
|
14
|
-
onChange(): void;
|
|
15
|
-
focusTo(targetPos: Vector3, targetQuat: Quaternion | Euler, distance: number, time: number, onGoing?: (() => void) | null, onFinished?: (() => void) | null): void;
|
|
16
|
-
getFocuingData(): {
|
|
24
|
+
getTargetCameraState(): {
|
|
17
25
|
position: Vector3;
|
|
18
26
|
quaternion: Quaternion;
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
};
|
|
28
|
+
private updateCameraFromPawn;
|
|
29
|
+
unpossess(): void;
|
|
30
|
+
private onContextMenu;
|
|
31
|
+
private onPointerDown;
|
|
32
|
+
private onPointerMove;
|
|
33
|
+
private onPointerUp;
|
|
34
|
+
private setCameraDraggingState;
|
|
35
|
+
private onWheel;
|
|
36
|
+
tick(deltaTime: number): void;
|
|
37
|
+
setPosition(position: Vector3): void;
|
|
38
|
+
setPosition(x: number, y: number, z: number): void;
|
|
39
|
+
setRotation(rotation: Euler): void;
|
|
40
|
+
setRotation(x: number, y: number, z: number): void;
|
|
41
|
+
setQuaternion(quat: Quaternion): void;
|
|
42
|
+
setQuaternion(x: number, y: number, z: number, w: number): void;
|
|
43
|
+
focusTo(targetPos: Vector3, targetQuat: Quaternion | Euler, distance: number, time: number, onGoing?: (() => void) | null, onFinished?: (() => void) | null): void;
|
|
21
44
|
stopFocusing(): void;
|
|
22
45
|
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { Euler, Quaternion, Vector3 } from "three";
|
|
1
|
+
import { Euler, Quaternion, Vector3 } from "three/webgpu";
|
|
2
2
|
import { Controller } from "../../Frame/Controller";
|
|
3
|
-
|
|
3
|
+
import { Actor } from "../Actor";
|
|
4
|
+
import { ThreeJsApp } from "../../ThreeJsApp";
|
|
5
|
+
export declare abstract class Pawn extends Actor {
|
|
4
6
|
get camera(): import("three").PerspectiveCamera | import("three").OrthographicCamera;
|
|
7
|
+
get enabled(): boolean;
|
|
5
8
|
set enabled(value: boolean);
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
protected _enabled: boolean;
|
|
10
|
+
static inputFilter: () => boolean;
|
|
8
11
|
protected controller: Controller;
|
|
9
|
-
protected
|
|
10
|
-
protected constructor(controller: Controller);
|
|
12
|
+
protected constructor(app: ThreeJsApp);
|
|
11
13
|
tick(_deltaTime: number): void;
|
|
12
14
|
possess(): void;
|
|
13
15
|
unpossess(): void;
|
|
14
|
-
|
|
15
|
-
stopFocusing(): void;
|
|
16
|
-
getFocuingData(): {
|
|
16
|
+
abstract getTargetCameraState(): {
|
|
17
17
|
position: Vector3;
|
|
18
18
|
quaternion: Quaternion;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
};
|
|
20
|
+
focusTo(_targetPos: Vector3, _targetQuat: Quaternion | Euler, _distance: number, _time: number, _onGoing?: (() => void) | null, _onFinished?: (() => void) | null): void;
|
|
21
|
+
stopFocusing(): void;
|
|
21
22
|
destroy(): void;
|
|
22
23
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Pawn } from "./Pawn";
|
|
2
|
+
import { ThreeJsApp } from "../../ThreeJsApp";
|
|
3
|
+
import { Vector3, Quaternion } from "three/webgpu";
|
|
4
|
+
import { SceneComponent } from "../Components/SceneComponent";
|
|
5
|
+
export declare class Spectator extends Pawn {
|
|
6
|
+
moveSpeed: number;
|
|
7
|
+
lookSpeed: number;
|
|
8
|
+
eyeHeight: number;
|
|
9
|
+
constructor(app: ThreeJsApp);
|
|
10
|
+
protected constructRootComponent(): SceneComponent;
|
|
11
|
+
possess(): void;
|
|
12
|
+
unpossess(): void;
|
|
13
|
+
getTargetCameraState(): {
|
|
14
|
+
position: Vector3;
|
|
15
|
+
quaternion: Quaternion;
|
|
16
|
+
};
|
|
17
|
+
tick(deltaTime: number): void;
|
|
18
|
+
private updateCameraFromPawn;
|
|
19
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Pawn } from "./Pawn";
|
|
2
|
-
import { Matrix4, Scene } from "three/webgpu";
|
|
2
|
+
import { Matrix4, Scene, Vector3, Quaternion } from "three/webgpu";
|
|
3
3
|
import { TransformControls } from "three/examples/jsm/controls/TransformControls.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ThreeJsApp } from "../../ThreeJsApp";
|
|
5
5
|
export interface TransformType {
|
|
6
6
|
rotate: "X" | "Y" | "Z" | "E" | "XY" | "YZ" | "XZ" | "XYZ" | "XYZE" | null;
|
|
7
7
|
scale: "X" | "Y" | "Z" | "E" | "XY" | "YZ" | "XZ" | "XYZ" | "XYZE" | null;
|
|
@@ -34,11 +34,15 @@ export declare class TransformGizmo extends Pawn {
|
|
|
34
34
|
protected onChangeEvent: () => void;
|
|
35
35
|
protected onUpdateFunction: (() => void) | null;
|
|
36
36
|
protected onDraggingFunction: ((event: boolean) => void) | null;
|
|
37
|
-
constructor(
|
|
37
|
+
constructor(app: ThreeJsApp, options?: TransformGizmoOptions);
|
|
38
38
|
/** Get the scene where gizmo should be added */
|
|
39
39
|
private getTargetScene;
|
|
40
40
|
possess(): void;
|
|
41
41
|
unpossess(): void;
|
|
42
|
+
getTargetCameraState(): {
|
|
43
|
+
position: Vector3;
|
|
44
|
+
quaternion: Quaternion;
|
|
45
|
+
};
|
|
42
46
|
refresh(): void;
|
|
43
47
|
protected onChange(): void;
|
|
44
48
|
protected onDraggingChanged(event: {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Box3, Mesh, Object3D, Vector3 } from "three/webgpu";
|
|
2
|
+
import { ThreeJsApp } from "../ThreeJsApp";
|
|
3
|
+
import { ColliderComponent } from "./ColliderComponent";
|
|
4
|
+
export declare class BoxColliderComponent extends ColliderComponent {
|
|
5
|
+
get halfExtents(): Vector3;
|
|
6
|
+
protected _halfExtents: Vector3;
|
|
7
|
+
protected _debugMesh: Mesh | null;
|
|
8
|
+
constructor(app: ThreeJsApp, halfExtents?: Vector3, uuid?: string);
|
|
9
|
+
getWorldAABB(out?: Box3): Box3;
|
|
10
|
+
protected createDebugObject(): Object3D | null;
|
|
11
|
+
protected destroyDebugObject(_debugObject: Object3D): void;
|
|
12
|
+
protected onDebugTick(_deltaTime: number): void;
|
|
13
|
+
raycast(origin: Vector3, dir: Vector3, maxDistance: number): {
|
|
14
|
+
point: Vector3;
|
|
15
|
+
normal: Vector3;
|
|
16
|
+
distance: number;
|
|
17
|
+
} | null;
|
|
18
|
+
protected intersectRayAabbRaw(origin: Vector3, dir: Vector3, min: Vector3, max: Vector3): {
|
|
19
|
+
t: number;
|
|
20
|
+
normal: Vector3;
|
|
21
|
+
} | null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Box3, Mesh, Object3D, Vector3 } from "three/webgpu";
|
|
2
|
+
import { ThreeJsApp } from "../ThreeJsApp";
|
|
3
|
+
import { ColliderComponent } from "./ColliderComponent";
|
|
4
|
+
export declare class CapsuleColliderComponent extends ColliderComponent {
|
|
5
|
+
get radius(): number;
|
|
6
|
+
get halfHeight(): number;
|
|
7
|
+
protected _radius: number;
|
|
8
|
+
protected _halfHeight: number;
|
|
9
|
+
protected _debugRoot: Object3D | null;
|
|
10
|
+
protected _debugCylinder: Mesh | null;
|
|
11
|
+
protected _debugTop: Mesh | null;
|
|
12
|
+
protected _debugBottom: Mesh | null;
|
|
13
|
+
protected readonly _tmpA: Vector3;
|
|
14
|
+
protected readonly _tmpB: Vector3;
|
|
15
|
+
protected readonly _tmpBA: Vector3;
|
|
16
|
+
protected readonly _tmpOA: Vector3;
|
|
17
|
+
protected readonly _tmpPoint: Vector3;
|
|
18
|
+
protected readonly _tmpNormal: Vector3;
|
|
19
|
+
constructor(app: ThreeJsApp, radius?: number, halfHeight?: number, uuid?: string);
|
|
20
|
+
getWorldAABB(out?: Box3): Box3;
|
|
21
|
+
raycast(origin: Vector3, dir: Vector3, maxDistance: number): {
|
|
22
|
+
point: Vector3;
|
|
23
|
+
normal: Vector3;
|
|
24
|
+
distance: number;
|
|
25
|
+
} | null;
|
|
26
|
+
protected raycastSphere(origin: Vector3, dir: Vector3, maxDistance: number, center: Vector3, radius: number): {
|
|
27
|
+
point: Vector3;
|
|
28
|
+
normal: Vector3;
|
|
29
|
+
distance: number;
|
|
30
|
+
} | null;
|
|
31
|
+
protected makeSphereHit(origin: Vector3, dir: Vector3, t: number, center: Vector3): {
|
|
32
|
+
point: Vector3;
|
|
33
|
+
normal: Vector3;
|
|
34
|
+
distance: number;
|
|
35
|
+
};
|
|
36
|
+
protected createDebugObject(): Object3D | null;
|
|
37
|
+
protected destroyDebugObject(_debugObject: Object3D): void;
|
|
38
|
+
protected onDebugTick(_deltaTime: number): void;
|
|
39
|
+
protected onDebugStyleChanged(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Box3, Object3D, Vector3 } from "three/webgpu";
|
|
2
|
+
import { Delegate } from "../Delegate";
|
|
3
|
+
import { ThreeJsApp } from "../ThreeJsApp";
|
|
4
|
+
import { SceneComponent } from "../Object/Components/SceneComponent";
|
|
5
|
+
import { World } from "../Frame/World";
|
|
6
|
+
import { CollisionChannel, CollisionResponse } from "./CollisionTypes";
|
|
7
|
+
export type CollisionResponseMap = Partial<Record<CollisionChannel, CollisionResponse>>;
|
|
8
|
+
export interface PhysicsHitResult {
|
|
9
|
+
self: ColliderComponent;
|
|
10
|
+
other: ColliderComponent;
|
|
11
|
+
point: Vector3;
|
|
12
|
+
normal: Vector3;
|
|
13
|
+
penetrationDepth: number;
|
|
14
|
+
}
|
|
15
|
+
export declare abstract class ColliderComponent extends SceneComponent {
|
|
16
|
+
get debugEnabled(): boolean;
|
|
17
|
+
set debugEnabled(value: boolean);
|
|
18
|
+
get debugColor(): number;
|
|
19
|
+
set debugColor(value: number);
|
|
20
|
+
get debugOpacity(): number;
|
|
21
|
+
set debugOpacity(value: number);
|
|
22
|
+
get collisionEnabled(): boolean;
|
|
23
|
+
set collisionEnabled(value: boolean);
|
|
24
|
+
get generateOverlapEvents(): boolean;
|
|
25
|
+
set generateOverlapEvents(value: boolean);
|
|
26
|
+
get generateHitEvents(): boolean;
|
|
27
|
+
set generateHitEvents(value: boolean);
|
|
28
|
+
get objectType(): CollisionChannel;
|
|
29
|
+
set objectType(value: CollisionChannel);
|
|
30
|
+
get onBeginOverlapDelegate(): Delegate<[ColliderComponent]>;
|
|
31
|
+
get onEndOverlapDelegate(): Delegate<[ColliderComponent]>;
|
|
32
|
+
get onHitDelegate(): Delegate<[PhysicsHitResult]>;
|
|
33
|
+
protected _collisionEnabled: boolean;
|
|
34
|
+
protected _generateOverlapEvents: boolean;
|
|
35
|
+
protected _generateHitEvents: boolean;
|
|
36
|
+
protected _objectType: CollisionChannel;
|
|
37
|
+
protected _responseMap: CollisionResponseMap;
|
|
38
|
+
protected _onBeginOverlapDelegate: Delegate<[ColliderComponent]>;
|
|
39
|
+
protected _onEndOverlapDelegate: Delegate<[ColliderComponent]>;
|
|
40
|
+
protected _onHitDelegate: Delegate<[PhysicsHitResult]>;
|
|
41
|
+
protected _registeredInWorld: boolean;
|
|
42
|
+
protected _debugEnabled: boolean;
|
|
43
|
+
protected _debugColor: number;
|
|
44
|
+
protected _debugOpacity: number;
|
|
45
|
+
protected _debugObject: Object3D | null;
|
|
46
|
+
constructor(app: ThreeJsApp, uuid?: string);
|
|
47
|
+
setCollisionResponse(channel: CollisionChannel, response: CollisionResponse): void;
|
|
48
|
+
setCollisionResponses(map: CollisionResponseMap): void;
|
|
49
|
+
getCollisionResponse(channel: CollisionChannel): CollisionResponse;
|
|
50
|
+
getMutualResponse(other: ColliderComponent): CollisionResponse;
|
|
51
|
+
abstract getWorldAABB(out?: Box3): Box3;
|
|
52
|
+
tick(deltaTime: number): void;
|
|
53
|
+
onAddedToWorld(world: World): void;
|
|
54
|
+
destroy(): void;
|
|
55
|
+
protected getDebugAttachParent(): Object3D | null;
|
|
56
|
+
protected createDebugObject(): Object3D | null;
|
|
57
|
+
protected destroyDebugObject(_debugObject: Object3D): void;
|
|
58
|
+
protected onDebugTick(_deltaTime: number): void;
|
|
59
|
+
protected onDebugStyleChanged(): void;
|
|
60
|
+
protected enableDebug(): void;
|
|
61
|
+
protected disableDebug(): void;
|
|
62
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum CollisionResponse {
|
|
2
|
+
Ignore = "Ignore",
|
|
3
|
+
Overlap = "Overlap",
|
|
4
|
+
Block = "Block"
|
|
5
|
+
}
|
|
6
|
+
export declare enum CollisionChannel {
|
|
7
|
+
WorldStatic = "WorldStatic",
|
|
8
|
+
WorldDynamic = "WorldDynamic",
|
|
9
|
+
Pawn = "Pawn",
|
|
10
|
+
Visibility = "Visibility",
|
|
11
|
+
Camera = "Camera",
|
|
12
|
+
Trigger = "Trigger"
|
|
13
|
+
}
|
|
14
|
+
export declare enum CollisionShapeType {
|
|
15
|
+
Sphere = "Sphere",
|
|
16
|
+
Box = "Box"
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Box3, Matrix4, Mesh, MeshBasicMaterial, Object3D, Vector3 } from "three/webgpu";
|
|
2
|
+
import { ThreeJsApp } from "../ThreeJsApp";
|
|
3
|
+
import { ColliderComponent } from "./ColliderComponent";
|
|
4
|
+
export declare class MeshColliderComponent extends ColliderComponent {
|
|
5
|
+
get sourceObject(): Object3D<import("three").Object3DEventMap> | null;
|
|
6
|
+
protected _sourceObject: Object3D | null;
|
|
7
|
+
protected _mesh: Mesh | null;
|
|
8
|
+
protected _debugEntries: Array<{
|
|
9
|
+
parent: Object3D;
|
|
10
|
+
obj: Object3D;
|
|
11
|
+
}>;
|
|
12
|
+
protected _debugMaterial: MeshBasicMaterial | null;
|
|
13
|
+
protected readonly _tmpAabb: Box3;
|
|
14
|
+
protected readonly _tmpMat: Matrix4;
|
|
15
|
+
protected readonly _tmpCorner: Vector3;
|
|
16
|
+
protected readonly _tmpBoxCorner: Array<Vector3>;
|
|
17
|
+
protected readonly _tmpA: Vector3;
|
|
18
|
+
protected readonly _tmpB: Vector3;
|
|
19
|
+
protected readonly _tmpC: Vector3;
|
|
20
|
+
protected readonly _tmpEdge1: Vector3;
|
|
21
|
+
protected readonly _tmpEdge2: Vector3;
|
|
22
|
+
protected readonly _tmpP: Vector3;
|
|
23
|
+
protected readonly _tmpT: Vector3;
|
|
24
|
+
protected readonly _tmpQ: Vector3;
|
|
25
|
+
protected readonly _tmpN: Vector3;
|
|
26
|
+
constructor(app: ThreeJsApp, sourceObject?: Object3D | null, uuid?: string);
|
|
27
|
+
setSourceObject(sourceObject: Object3D | null): void;
|
|
28
|
+
private mergeGeometries;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
getWorldAABB(out?: Box3): Box3;
|
|
31
|
+
raycast(origin: Vector3, dir: Vector3, maxDistance: number): {
|
|
32
|
+
point: Vector3;
|
|
33
|
+
normal: Vector3;
|
|
34
|
+
distance: number;
|
|
35
|
+
} | null;
|
|
36
|
+
protected intersectRayAabb(origin: Vector3, dir: Vector3, maxDistance: number, box: Box3): boolean;
|
|
37
|
+
protected intersectRayTriangle(origin: Vector3, dir: Vector3, a: Vector3, b: Vector3, c: Vector3, maxDistance: number): {
|
|
38
|
+
point: Vector3;
|
|
39
|
+
normal: Vector3;
|
|
40
|
+
distance: number;
|
|
41
|
+
} | null;
|
|
42
|
+
protected getDebugAttachParent(): Object3D | null;
|
|
43
|
+
protected createDebugObject(): Object3D | null;
|
|
44
|
+
protected destroyDebugObject(_debugObject: Object3D): void;
|
|
45
|
+
protected onDebugStyleChanged(): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Box3, Vector3 } from "three/webgpu";
|
|
2
|
+
import { CollisionChannel } from "./CollisionTypes";
|
|
3
|
+
import { ColliderComponent, PhysicsHitResult } from "./ColliderComponent";
|
|
4
|
+
export interface LineTraceHitResult {
|
|
5
|
+
collider: ColliderComponent;
|
|
6
|
+
point: Vector3;
|
|
7
|
+
normal: Vector3;
|
|
8
|
+
distance: number;
|
|
9
|
+
blocking: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class PhysicsWorld {
|
|
12
|
+
protected colliders: Set<ColliderComponent>;
|
|
13
|
+
protected previousOverlapPairs: Map<string, [ColliderComponent, ColliderComponent]>;
|
|
14
|
+
protected previousBlockPairs: Map<string, [ColliderComponent, ColliderComponent]>;
|
|
15
|
+
protected _debugDrawEnabled: boolean;
|
|
16
|
+
get debugDrawEnabled(): boolean;
|
|
17
|
+
set debugDrawEnabled(value: boolean);
|
|
18
|
+
registerCollider(collider: ColliderComponent): void;
|
|
19
|
+
unregisterCollider(collider: ColliderComponent): void;
|
|
20
|
+
clear(): void;
|
|
21
|
+
lineTraceSingle(start: Vector3, end: Vector3, traceChannel?: CollisionChannel, ignoreCollider?: ColliderComponent): LineTraceHitResult | null;
|
|
22
|
+
lineTraceMulti(start: Vector3, end: Vector3, traceChannel?: CollisionChannel, ignoreCollider?: ColliderComponent): LineTraceHitResult[];
|
|
23
|
+
tick(_deltaTime: number): void;
|
|
24
|
+
protected computeAabbHit(self: ColliderComponent, other: ColliderComponent, a: Box3, b: Box3): PhysicsHitResult;
|
|
25
|
+
protected getPairKey(a: ColliderComponent, b: ColliderComponent): string;
|
|
26
|
+
protected intersectRayAabb(origin: Vector3, dir: Vector3, maxDistance: number, box: Box3): {
|
|
27
|
+
point: Vector3;
|
|
28
|
+
normal: Vector3;
|
|
29
|
+
distance: number;
|
|
30
|
+
} | null;
|
|
31
|
+
}
|