ohzi-core 13.0.2 → 13.0.4
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 +1 -1
- package/build/index.mjs +1 -1
- package/build/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/BaseApplication.ts +3 -0
- package/src/Debug.ts +1 -1
- package/src/Graphics.ts +0 -1
- package/src/Initializer.ts +1 -1
- package/src/KeyboardInput.ts +8 -8
- package/src/RenderLoop.ts +1 -1
- package/src/camera_controller/CameraController.ts +537 -0
- package/src/camera_controller/movement_mode/CameraMovementMode.ts +22 -0
- package/src/camera_controller/movement_mode/ImmediateMode.ts +60 -0
- package/src/camera_controller/states/common/AbstractCameraState.ts +32 -0
- package/src/camera_controller/states/common/CommonCameraState.ts +207 -0
- package/src/components/mouse_interactors/ObjectRotator.ts +1 -1
- package/src/index.ts +8 -2
- package/src/{components → lib}/Input.ts +8 -21
- package/src/lib/Vector2.ts +49 -0
- package/src/raycast/GroupRaycaster.ts +1 -1
- package/src/raycast/PlaneDragResolver.ts +1 -1
- package/src/raycast/SurfaceDragResolver.ts +1 -1
- package/src/resource_loader/ResourceBatch.ts +1 -1
- package/src/scenes/AbstractScene.ts +13 -7
- package/src/scenes/loading_states/LoadingState.ts +11 -11
- package/src/utilities/CameraUtilities.ts +5 -4
- package/src/utilities/ModelUtilities.ts +1 -1
- package/src/view_components/ViewComponent.ts +1 -1
- package/src/view_components/ViewComponentManager.ts +1 -1
- package/src/view_components/ViewManager.ts +1 -1
- package/src/view_components/transition/ViewStateTransitionHandler.ts +2 -2
- package/types/camera_controller/CameraController.d.ts +88 -0
- package/types/camera_controller/movement_mode/CameraMovementMode.d.ts +6 -0
- package/types/camera_controller/movement_mode/ImmediateMode.d.ts +14 -0
- package/types/camera_controller/states/common/AbstractCameraState.d.ts +8 -0
- package/types/camera_controller/states/common/CommonCameraState.d.ts +24 -0
- package/types/components/mouse_interactors/ObjectRotator.d.ts +1 -1
- package/types/lib/Input.d.ts +41 -0
- package/types/lib/Vector2.d.ts +48 -0
- package/types/raycast/GroupRaycaster.d.ts +1 -1
- package/types/raycast/PlaneDragResolver.d.ts +1 -1
- package/types/raycast/SurfaceDragResolver.d.ts +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { OMath } from '../../utilities/OMath';
|
|
2
|
+
import type { CameraController } from '../CameraController';
|
|
3
|
+
import { CameraMovementMode } from './CameraMovementMode';
|
|
4
|
+
|
|
5
|
+
import { Quaternion, Vector2, Vector3 } from 'three';
|
|
6
|
+
|
|
7
|
+
export class ImmediateMode extends CameraMovementMode
|
|
8
|
+
{
|
|
9
|
+
rotation_speed: Vector2;
|
|
10
|
+
tmp_camera_target_pos: Vector3;
|
|
11
|
+
tmp_forward: Vector3;
|
|
12
|
+
tmp_quat: Quaternion;
|
|
13
|
+
vector_forward_axis: Vector3;
|
|
14
|
+
|
|
15
|
+
constructor()
|
|
16
|
+
{
|
|
17
|
+
super();
|
|
18
|
+
this.rotation_speed = new Vector2();
|
|
19
|
+
|
|
20
|
+
this.vector_forward_axis = new Vector3(0, 0, -1);
|
|
21
|
+
this.tmp_forward = new Vector3();
|
|
22
|
+
|
|
23
|
+
this.tmp_quat = new Quaternion();
|
|
24
|
+
this.tmp_camera_target_pos = new Vector3();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
on_enter(camera_controller: CameraController)
|
|
28
|
+
{
|
|
29
|
+
camera_controller.reference_rotation.copy(camera_controller.camera.quaternion);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
update(camera_controller: CameraController)
|
|
33
|
+
{
|
|
34
|
+
camera_controller.camera.quaternion.copy(camera_controller.reference_rotation);
|
|
35
|
+
|
|
36
|
+
this.tmp_forward.copy(this.vector_forward_axis);
|
|
37
|
+
const dir = this.tmp_forward.applyQuaternion(camera_controller.camera.quaternion);
|
|
38
|
+
|
|
39
|
+
camera_controller.reference_zoom = OMath.clamp(camera_controller.reference_zoom,
|
|
40
|
+
camera_controller.min_zoom, camera_controller.max_zoom);
|
|
41
|
+
|
|
42
|
+
camera_controller.camera.position.copy(camera_controller.reference_position).sub(dir.multiplyScalar(camera_controller.reference_zoom));
|
|
43
|
+
|
|
44
|
+
camera_controller.__last_reference_position.copy(camera_controller.reference_position);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get_target_camera_pos(camera_controller: CameraController)
|
|
48
|
+
{
|
|
49
|
+
this.tmp_quat.copy(camera_controller.reference_rotation);
|
|
50
|
+
this.tmp_forward.copy(this.vector_forward_axis);
|
|
51
|
+
|
|
52
|
+
const dir = this.tmp_forward.applyQuaternion(this.tmp_quat);
|
|
53
|
+
|
|
54
|
+
const zoom = OMath.clamp(camera_controller.reference_zoom,
|
|
55
|
+
camera_controller.min_zoom, camera_controller.max_zoom);
|
|
56
|
+
|
|
57
|
+
this.tmp_camera_target_pos.copy(camera_controller.reference_position).sub(dir.multiplyScalar(zoom));
|
|
58
|
+
return this.tmp_camera_target_pos;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class AbstractCameraState
|
|
2
|
+
{
|
|
3
|
+
constructor()
|
|
4
|
+
{
|
|
5
|
+
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
on_enter(camera_controller: any)
|
|
9
|
+
{
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
on_exit(camera_controller: any)
|
|
14
|
+
{
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
update(camera_controller: any)
|
|
19
|
+
{
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
lock_zoom()
|
|
24
|
+
{
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
unlock_zoom()
|
|
29
|
+
{
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { Vector2 } from 'three';
|
|
2
|
+
|
|
3
|
+
import type { Input } from '../../../lib/Input';
|
|
4
|
+
import type { PerspectiveCamera } from '../../../PerspectiveCamera';
|
|
5
|
+
import { Time } from '../../../Time';
|
|
6
|
+
import { CameraUtilities } from '../../../utilities/CameraUtilities';
|
|
7
|
+
import type { CameraController } from '../../CameraController';
|
|
8
|
+
import { AbstractCameraState } from './AbstractCameraState';
|
|
9
|
+
|
|
10
|
+
export class CommonCameraState extends AbstractCameraState
|
|
11
|
+
{
|
|
12
|
+
azimuth_dir: number;
|
|
13
|
+
forward_dir: number;
|
|
14
|
+
last_point: Vector2;
|
|
15
|
+
right_dir: number;
|
|
16
|
+
rotation_velocity: Vector2;
|
|
17
|
+
shift_key: boolean;
|
|
18
|
+
y_dir: number;
|
|
19
|
+
input: Input
|
|
20
|
+
|
|
21
|
+
constructor(input: Input)
|
|
22
|
+
{
|
|
23
|
+
super();
|
|
24
|
+
|
|
25
|
+
this.input = input;
|
|
26
|
+
|
|
27
|
+
// this.vector_down_axis = new Vector3(0, -1, 0);
|
|
28
|
+
// this.vector_up_axis = new Vector3(0, 1, 0);
|
|
29
|
+
// this.vector_back_axis = new Vector3(0, 0, -1);
|
|
30
|
+
// this.vector_left_axis = new Vector3(-1, 0, 0);
|
|
31
|
+
|
|
32
|
+
this.last_point = new Vector2();
|
|
33
|
+
|
|
34
|
+
this.rotation_velocity = new Vector2();
|
|
35
|
+
|
|
36
|
+
this.forward_dir = 0;
|
|
37
|
+
this.right_dir = 0;
|
|
38
|
+
this.y_dir = 0;
|
|
39
|
+
this.azimuth_dir = 0;
|
|
40
|
+
|
|
41
|
+
this.shift_key = false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
on_enter(camera_controller: CameraController)
|
|
45
|
+
{
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
on_exit(camera_controller: CameraController)
|
|
49
|
+
{
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
update(camera_controller: CameraController)
|
|
53
|
+
{
|
|
54
|
+
this.__check_key_down();
|
|
55
|
+
this.__check_key_up();
|
|
56
|
+
|
|
57
|
+
// this.__move_camera(camera_controller);
|
|
58
|
+
// this.__zoom_camera(camera_controller);
|
|
59
|
+
// this.__rotate_camera(camera_controller);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
__show_camera_position(camera_controller: CameraController)
|
|
63
|
+
{
|
|
64
|
+
if (this.input.left_mouse_button_released)
|
|
65
|
+
{
|
|
66
|
+
console.log({
|
|
67
|
+
x: camera_controller.reference_position.x,
|
|
68
|
+
y: camera_controller.reference_position.y,
|
|
69
|
+
z: camera_controller.reference_position.z,
|
|
70
|
+
orientation: camera_controller.current_orientation,
|
|
71
|
+
tilt: camera_controller.current_tilt,
|
|
72
|
+
azimuth: camera_controller.current_azimuth,
|
|
73
|
+
zoom: camera_controller.reference_zoom,
|
|
74
|
+
fov: (camera_controller.camera as PerspectiveCamera).fov
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
__zoom_camera(camera_controller: CameraController)
|
|
80
|
+
{
|
|
81
|
+
camera_controller.reference_zoom += this.input.zoom_delta * 0.5;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
__rotate_camera(camera_controller: CameraController)
|
|
85
|
+
{
|
|
86
|
+
if (this.input.left_mouse_button_down && this.input.pointer_count === 1)
|
|
87
|
+
{
|
|
88
|
+
const delta = new Vector2(this.input.NDC_delta.x * -24, this.input.NDC_delta.y * -8);
|
|
89
|
+
delta.multiplyScalar(Time.delta_time * 60);
|
|
90
|
+
|
|
91
|
+
this.rotation_velocity.add(delta);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
camera_controller.set_rotation_delta(this.rotation_velocity.y, this.rotation_velocity.x);
|
|
95
|
+
// camera_controller.set_rotation_delta(0, 0, this.azimuth_dir);
|
|
96
|
+
|
|
97
|
+
const blend = 1 - Math.exp(-5 * Time.delta_time);
|
|
98
|
+
this.rotation_velocity.lerp(new Vector2(0, 0), blend);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
__move_camera(camera_controller: CameraController)
|
|
102
|
+
{
|
|
103
|
+
camera_controller.translate_forward(this.forward_dir);
|
|
104
|
+
camera_controller.translate_right(this.right_dir);
|
|
105
|
+
|
|
106
|
+
camera_controller.reference_position.y -= this.y_dir;
|
|
107
|
+
|
|
108
|
+
if (this.input.right_mouse_button_pressed)
|
|
109
|
+
{
|
|
110
|
+
this.last_point.copy(this.input.NDC);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (this.input.right_mouse_button_down) // || (this.input.left_mouse_button_down && this.shift_key)
|
|
114
|
+
{
|
|
115
|
+
const prev_point = CameraUtilities.get_plane_intersection(camera_controller.reference_position, undefined, this.last_point).clone();
|
|
116
|
+
const current_point = CameraUtilities.get_plane_intersection(camera_controller.reference_position, undefined, this.input.NDC).clone();
|
|
117
|
+
current_point.sub(prev_point);
|
|
118
|
+
|
|
119
|
+
camera_controller.reference_position.x -= current_point.x;
|
|
120
|
+
camera_controller.reference_position.y -= current_point.y;
|
|
121
|
+
camera_controller.reference_position.z -= current_point.z;
|
|
122
|
+
this.last_point.copy(this.input.NDC);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
__check_key_down()
|
|
127
|
+
{
|
|
128
|
+
const speed = 0.12;
|
|
129
|
+
|
|
130
|
+
if (this.input.keyboard.is_key_down('KeyW'))
|
|
131
|
+
{
|
|
132
|
+
this.forward_dir = -speed;
|
|
133
|
+
}
|
|
134
|
+
if (this.input.keyboard.is_key_down('KeyS'))
|
|
135
|
+
{
|
|
136
|
+
this.forward_dir = speed;
|
|
137
|
+
}
|
|
138
|
+
if (this.input.keyboard.is_key_down('KeyA'))
|
|
139
|
+
{
|
|
140
|
+
this.right_dir = -speed;
|
|
141
|
+
}
|
|
142
|
+
if (this.input.keyboard.is_key_down('KeyD'))
|
|
143
|
+
{
|
|
144
|
+
this.right_dir = speed;
|
|
145
|
+
}
|
|
146
|
+
if (this.input.keyboard.is_key_down('KeyQ'))
|
|
147
|
+
{
|
|
148
|
+
this.azimuth_dir = speed * 4;
|
|
149
|
+
}
|
|
150
|
+
if (this.input.keyboard.is_key_down('KeyE'))
|
|
151
|
+
{
|
|
152
|
+
this.azimuth_dir = -speed * 4;
|
|
153
|
+
}
|
|
154
|
+
if (this.input.keyboard.is_key_down('KeyZ'))
|
|
155
|
+
{
|
|
156
|
+
this.y_dir = speed;
|
|
157
|
+
}
|
|
158
|
+
if (this.input.keyboard.is_key_down('KeyC'))
|
|
159
|
+
{
|
|
160
|
+
this.y_dir = -speed;
|
|
161
|
+
}
|
|
162
|
+
if (this.input.keyboard.is_key_down('ShiftLeft'))
|
|
163
|
+
{
|
|
164
|
+
this.shift_key = true;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
__check_key_up()
|
|
169
|
+
{
|
|
170
|
+
if (this.input.keyboard.is_key_released('KeyW'))
|
|
171
|
+
{
|
|
172
|
+
this.forward_dir = 0;
|
|
173
|
+
}
|
|
174
|
+
if (this.input.keyboard.is_key_released('KeyS'))
|
|
175
|
+
{
|
|
176
|
+
this.forward_dir = 0;
|
|
177
|
+
}
|
|
178
|
+
if (this.input.keyboard.is_key_released('KeyA'))
|
|
179
|
+
{
|
|
180
|
+
this.right_dir = 0;
|
|
181
|
+
}
|
|
182
|
+
if (this.input.keyboard.is_key_released('KeyD'))
|
|
183
|
+
{
|
|
184
|
+
this.right_dir = 0;
|
|
185
|
+
}
|
|
186
|
+
if (this.input.keyboard.is_key_released('KeyQ'))
|
|
187
|
+
{
|
|
188
|
+
this.azimuth_dir = 0;
|
|
189
|
+
}
|
|
190
|
+
if (this.input.keyboard.is_key_released('KeyE'))
|
|
191
|
+
{
|
|
192
|
+
this.azimuth_dir = 0;
|
|
193
|
+
}
|
|
194
|
+
if (this.input.keyboard.is_key_released('KeyZ'))
|
|
195
|
+
{
|
|
196
|
+
this.y_dir = 0;
|
|
197
|
+
}
|
|
198
|
+
if (this.input.keyboard.is_key_released('KeyC'))
|
|
199
|
+
{
|
|
200
|
+
this.y_dir = 0;
|
|
201
|
+
}
|
|
202
|
+
if (this.input.keyboard.is_key_released('ShiftLeft'))
|
|
203
|
+
{
|
|
204
|
+
this.shift_key = false;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -3,7 +3,7 @@ import { RaycastResolver } from '../../raycast/RaycastResolver';
|
|
|
3
3
|
|
|
4
4
|
import type { Object3D } from 'three';
|
|
5
5
|
import { Quaternion, Vector3 } from 'three';
|
|
6
|
-
import type { Input } from '
|
|
6
|
+
import type { Input } from '../../lib/Input';
|
|
7
7
|
|
|
8
8
|
class ObjectRotator extends RaycastResolver
|
|
9
9
|
{
|
package/src/index.ts
CHANGED
|
@@ -118,10 +118,16 @@ import { ResourceContainer } from './ResourceContainer';
|
|
|
118
118
|
import { Compilator } from './scenes/Compilator';
|
|
119
119
|
import { TransitionManager } from './view_components/TransitionManager';
|
|
120
120
|
|
|
121
|
+
import { CameraController } from './camera_controller/CameraController';
|
|
122
|
+
import { CameraMovementMode } from './camera_controller/movement_mode/CameraMovementMode';
|
|
123
|
+
import { ImmediateMode } from './camera_controller/movement_mode/ImmediateMode';
|
|
124
|
+
import { AbstractCameraState } from './camera_controller/states/common/AbstractCameraState';
|
|
125
|
+
import { CommonCameraState } from './camera_controller/states/common/CommonCameraState';
|
|
126
|
+
|
|
121
127
|
export {
|
|
122
|
-
AbstractLoader, AbstractScene, ActionEvent, ActionInterpolator, ActionSequencer, ActionSequencerBuilder, AddMaterial, ApplicationView, ArrayUtilities, Arrow, AsyncAbstractLoader, AsyncAudiosLoader, AsyncObjectsLoader, AsyncTextureLoader, AsyncTexturesLoader, AudioLoader, BaseApplication, BaseRender, BaseShaderMaterial, BasisLoader, BlitMaterial, Blurrer, Browser, BufferGeometryUtils, CameraManager, CameraUtilities, CanvasDrawer, Capabilities, Compilator, CSSAnimator, Cube, CubemapLoader, DAELoader, Debug, DebugNormalsRender, DrawIOAnimationSheet, DualFilteringBlurMaterial, DualFilteringBlurrer, EasingFunctions, FileLoader,
|
|
128
|
+
AbstractCameraState, AbstractLoader, AbstractScene, ActionEvent, ActionInterpolator, ActionSequencer, ActionSequencerBuilder, AddMaterial, ApplicationView, ArrayUtilities, Arrow, AsyncAbstractLoader, AsyncAudiosLoader, AsyncObjectsLoader, AsyncTextureLoader, AsyncTexturesLoader, AudioLoader, BaseApplication, BaseRender, BaseShaderMaterial, BasisLoader, BlitMaterial, Blurrer, Browser, BufferGeometryUtils, CameraController, CameraManager, CameraMovementMode, CameraUtilities, CanvasDrawer, Capabilities, CommonCameraState, Compilator, CSSAnimator, Cube, CubemapLoader, DAELoader, Debug, DebugNormalsRender, DrawIOAnimationSheet, DualFilteringBlurMaterial, DualFilteringBlurrer, EasingFunctions, FileLoader,
|
|
123
129
|
FontLoader, FrustumPointFitter, GaussianBlurrer, GeometryUtilities, GLTFDRACOLoader, GLTFLoader, GPUParticleSystem, Graphics, Grid, HDRCubeTextureLoader, HDRTextureLoader, HighQualityLoadingState, HorizontalPlane, HTMLUtilities,
|
|
124
|
-
ImageUtilities, Initializer, JSONLoader, KeyboardInput, Line, LoadingState, MedianFilter, MeshSampler,
|
|
130
|
+
ImageUtilities, ImmediateMode, Initializer, JSONLoader, KeyboardInput, Line, LoadingState, MedianFilter, MeshSampler,
|
|
125
131
|
ModelUtilities, NormalAORender,
|
|
126
132
|
NormalRender, NumberInterpolator, ObjectUtilities, OBJLoader, OMath, OrthographicCamera, OrthographicFrustumPointFitter, OS, OScreen, ParticleAttribute,
|
|
127
133
|
ParticlePositionAttribute, PerspectiveCamera, PerspectiveFrustumPointFitter, PointArrayLoader, RegularLoadingState, RenderLoop, ResourceBatch,
|
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
// This interface declare the Input component found in PIT.js
|
|
2
2
|
|
|
3
|
-
import type { Vector2 } from "
|
|
3
|
+
import type { Vector2 } from "./Vector2";
|
|
4
4
|
|
|
5
5
|
export interface Input {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
touch_cooldown: any;
|
|
12
|
-
touch_input_module: any;
|
|
6
|
+
keyboard: {
|
|
7
|
+
is_key_down(key: string): boolean;
|
|
8
|
+
is_key_pressed(key: string): boolean;
|
|
9
|
+
is_key_released(key: string): boolean;
|
|
10
|
+
}
|
|
13
11
|
|
|
14
12
|
init(dom_element: any, sub_region_element: any): void;
|
|
15
|
-
|
|
16
|
-
unbind_events(): void;
|
|
17
|
-
on_wheel(event: any): void;
|
|
18
|
-
on_touchstart(event: any): void;
|
|
19
|
-
on_touchmove(event: any): void;
|
|
20
|
-
on_touchcancel(event: any): void;
|
|
21
|
-
on_touchend(event: any): void;
|
|
22
|
-
on_mousedown(event: any): void;
|
|
23
|
-
on_mousemove(event: any): void;
|
|
24
|
-
on_mouseup(event: any): void;
|
|
25
|
-
on_mouseleave(event: any): void;
|
|
13
|
+
update(): void;
|
|
26
14
|
clear(): void;
|
|
27
15
|
mouse_input_allowed(): boolean;
|
|
28
16
|
set_mouse_input_active(): void;
|
|
@@ -45,8 +33,6 @@ export interface Input {
|
|
|
45
33
|
|
|
46
34
|
pointer_is_over_element(elem: any): boolean;
|
|
47
35
|
|
|
48
|
-
get pointers(): Vector2[];
|
|
49
|
-
get pointer_pos(): Vector2;
|
|
50
36
|
get pointer_pos_delta(): Vector2;
|
|
51
37
|
get NDC(): Vector2;
|
|
52
38
|
get NDC_delta(): Vector2;
|
|
@@ -59,5 +45,6 @@ export interface Input {
|
|
|
59
45
|
get_pointer_pos_delta(index?: number): Vector2;
|
|
60
46
|
get_pointer_NDC(index?: number): Vector2;
|
|
61
47
|
get_pointer_NDC_delta(index?: number): Vector2;
|
|
48
|
+
|
|
62
49
|
dispose(): void;
|
|
63
50
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface Vector2 {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
|
|
5
|
+
set(x: number, y: number): this;
|
|
6
|
+
clone(): Vector2;
|
|
7
|
+
copy(v: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}): this;
|
|
11
|
+
add(v: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}): this;
|
|
15
|
+
sub(v: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}): this;
|
|
19
|
+
multiplyScalar(scalar: number): this;
|
|
20
|
+
divide(v: {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
}): this;
|
|
24
|
+
divideScalar(scalar: number): this;
|
|
25
|
+
dot(v: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}): number;
|
|
29
|
+
cross(v: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}): number;
|
|
33
|
+
lengthSq(): number;
|
|
34
|
+
length(): number;
|
|
35
|
+
normalize(): this;
|
|
36
|
+
angle(): number;
|
|
37
|
+
distanceTo(v: {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}): number;
|
|
41
|
+
distanceToSquared(v: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
}): number;
|
|
45
|
+
lerp(v: {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
}, alpha: number): this;
|
|
49
|
+
}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
+
import type { Object3D } from 'three';
|
|
1
2
|
import { Mesh, Scene } from 'three';
|
|
2
3
|
// import { AvatarSystem } from '../../components/avatar/AvatarSystem';
|
|
3
4
|
|
|
5
|
+
import type { CameraController } from '../camera_controller/CameraController';
|
|
6
|
+
import { CameraManager } from '../CameraManager';
|
|
4
7
|
import { Graphics } from '../Graphics';
|
|
5
|
-
import { CameraManager } from '../index';
|
|
6
8
|
import { HighQualityLoadingState } from './loading_states/HighQualityLoadingState';
|
|
7
9
|
import { LoadingState } from './loading_states/LoadingState';
|
|
8
10
|
import { RegularLoadingState } from './loading_states/RegularLoadingState';
|
|
9
11
|
|
|
10
12
|
class AbstractScene extends Scene
|
|
11
13
|
{
|
|
12
|
-
current_loading_state:
|
|
14
|
+
current_loading_state: LoadingState;
|
|
13
15
|
initialized: boolean;
|
|
14
16
|
is_high_loaded: boolean;
|
|
15
17
|
is_loaded: boolean;
|
|
16
|
-
loading_states:
|
|
18
|
+
loading_states: {
|
|
19
|
+
high: HighQualityLoadingState;
|
|
20
|
+
regular: RegularLoadingState;
|
|
21
|
+
};
|
|
17
22
|
name: string;
|
|
23
|
+
camera_controller: CameraController;
|
|
18
24
|
|
|
19
25
|
constructor({
|
|
20
26
|
name,
|
|
@@ -61,7 +67,7 @@ class AbstractScene extends Scene
|
|
|
61
67
|
|
|
62
68
|
get_objects()
|
|
63
69
|
{
|
|
64
|
-
const objects:
|
|
70
|
+
const objects: Object3D[] = [];
|
|
65
71
|
|
|
66
72
|
this.traverse(child =>
|
|
67
73
|
{
|
|
@@ -133,17 +139,17 @@ class AbstractScene extends Scene
|
|
|
133
139
|
this.initialized = false;
|
|
134
140
|
}
|
|
135
141
|
|
|
136
|
-
set_assets(scene_objects: any, scene_textures: any, scene_sounds: any, custom_loaders
|
|
142
|
+
set_assets(scene_objects: any[], scene_textures: any[], scene_sounds: any[], custom_loaders?: any[], custom_compilators?: Compilator[], custom_data?: any[])
|
|
137
143
|
{
|
|
138
144
|
this.loading_states.regular.set_assets(scene_objects, scene_textures, scene_sounds, custom_loaders, custom_compilators, custom_data);
|
|
139
145
|
}
|
|
140
146
|
|
|
141
|
-
set_high_assets(scene_objects: any, scene_textures: any, scene_sounds: any, custom_loaders
|
|
147
|
+
set_high_assets(scene_objects: any[], scene_textures: any[], scene_sounds: any[], custom_loaders?: any[], custom_compilators?: Compilator[], custom_data?: any[])
|
|
142
148
|
{
|
|
143
149
|
this.loading_states.high.set_assets(scene_objects, scene_textures, scene_sounds, custom_loaders, custom_compilators, custom_data);
|
|
144
150
|
}
|
|
145
151
|
|
|
146
|
-
set_loading_state(state:
|
|
152
|
+
set_loading_state(state: LoadingState)
|
|
147
153
|
{
|
|
148
154
|
this.current_loading_state.on_exit();
|
|
149
155
|
this.current_loading_state = state;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AsyncAbstractLoader } from '../../loaders/AsyncAbstractLoader';
|
|
2
2
|
import { AsyncAudiosLoader } from '../../loaders/AsyncAudiosLoader';
|
|
3
3
|
import { AsyncObjectsLoader } from '../../loaders/AsyncObjectsLoader';
|
|
4
4
|
import { AsyncTexturesLoader } from '../../loaders/AsyncTexturesLoader';
|
|
@@ -14,21 +14,21 @@ export class LoadingState
|
|
|
14
14
|
TexturesCompilator: Compilator;
|
|
15
15
|
callback_called: boolean;
|
|
16
16
|
compilator_manager: CompilatorManager;
|
|
17
|
-
compilators:
|
|
18
|
-
custom_compilators:
|
|
19
|
-
custom_data: any;
|
|
20
|
-
custom_loaders: any;
|
|
21
|
-
loaders:
|
|
17
|
+
compilators: Compilator[];
|
|
18
|
+
custom_compilators: Compilator[];
|
|
19
|
+
custom_data: any[];
|
|
20
|
+
custom_loaders: any[];
|
|
21
|
+
loaders: AsyncAbstractLoader[];
|
|
22
22
|
scene: AbstractScene;
|
|
23
|
-
scene_objects: any;
|
|
24
|
-
scene_sounds: any;
|
|
25
|
-
scene_textures: any;
|
|
23
|
+
scene_objects: any[];
|
|
24
|
+
scene_sounds: any[];
|
|
25
|
+
scene_textures: any[];
|
|
26
26
|
|
|
27
27
|
constructor(scene: AbstractScene, {
|
|
28
28
|
SceneCompilator,
|
|
29
29
|
TexturesCompilator,
|
|
30
30
|
AudiosCompilator
|
|
31
|
-
}:
|
|
31
|
+
}: { SceneCompilator: Compilator, TexturesCompilator: Compilator, AudiosCompilator: Compilator })
|
|
32
32
|
{
|
|
33
33
|
this.scene = scene;
|
|
34
34
|
|
|
@@ -42,7 +42,7 @@ export class LoadingState
|
|
|
42
42
|
this.callback_called = false;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
set_assets(scene_objects: any, scene_textures: any, scene_sounds: any, custom_loaders: any[] = [], custom_compilators:
|
|
45
|
+
set_assets(scene_objects: any[], scene_textures: any[], scene_sounds: any[], custom_loaders: any[] = [], custom_compilators: Compilator[] = [], custom_data: any[] = [])
|
|
46
46
|
{
|
|
47
47
|
this.scene_objects = scene_objects;
|
|
48
48
|
this.scene_textures = scene_textures;
|
|
@@ -4,8 +4,9 @@ import { OMath } from '../utilities/OMath';
|
|
|
4
4
|
|
|
5
5
|
import type { Camera, Object3D } from 'three';
|
|
6
6
|
import { Box3, Matrix4, Plane, Ray, Sphere, Vector3 } from 'three';
|
|
7
|
-
|
|
8
|
-
import type { Input } from '../
|
|
7
|
+
|
|
8
|
+
import type { Input } from '../lib/Input';
|
|
9
|
+
import type { Vector2 } from '../lib/Vector2';
|
|
9
10
|
import type { PerspectiveCamera } from '../PerspectiveCamera';
|
|
10
11
|
import { OrthographicFrustumPointFitter } from './OrthographicFrustumPointFitter';
|
|
11
12
|
import { PerspectiveFrustumPointFitter } from './PerspectiveFrustumPointFitter';
|
|
@@ -90,9 +91,9 @@ class CameraUtilities
|
|
|
90
91
|
const tmp_vec = new Vector3();
|
|
91
92
|
|
|
92
93
|
this.plane.setFromNormalAndCoplanarPoint(plane_normal || this.get_forward_dir(camera), plane_position);
|
|
93
|
-
if (camera.isPerspectiveCamera)
|
|
94
|
+
if ((camera as PerspectiveCamera).isPerspectiveCamera)
|
|
94
95
|
{
|
|
95
|
-
this.ray.set(camera.position, this.unproject_mouse_position(NDC, camera));
|
|
96
|
+
this.ray.set(camera.position, this.unproject_mouse_position(NDC, camera as PerspectiveCamera));
|
|
96
97
|
}
|
|
97
98
|
else
|
|
98
99
|
{
|
|
@@ -7,8 +7,8 @@ class ViewStateTransitionHandler
|
|
|
7
7
|
{
|
|
8
8
|
action_sequencer: ActionSequencer;
|
|
9
9
|
current_state: ViewState;
|
|
10
|
-
current_state_data:
|
|
11
|
-
default_state_data:
|
|
10
|
+
current_state_data: { [key: string]: any };
|
|
11
|
+
default_state_data: { [key: string]: any };
|
|
12
12
|
last_state: ViewState;
|
|
13
13
|
transition_table: TransitionTable;
|
|
14
14
|
transitioning: boolean;
|