ohzi-core 9.5.2 → 10.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/build/index.module.js +1 -1
- package/build/index.module.js.map +1 -1
- package/package.json +4 -23
- package/src/Initializer.js +4 -6
- package/src/RenderLoop.js +4 -4
- package/src/UI.js +3 -3
- package/src/components/mouse_interactors/ObjectRotator.js +8 -7
- package/src/editor/ManipulatorHandle.js +4 -3
- package/src/editor/ObjectEditor.js +5 -5
- package/src/editor/ObjectManipulator.js +10 -10
- package/src/index.js +2 -2
- package/src/raycast/GroupRaycaster.js +3 -3
- package/src/raycast/PlaneDragResolver.js +5 -4
- package/src/raycast/SurfaceDragResolver.js +6 -5
- package/src/utilities/CameraUtilities.js +4 -3
- package/types/Initializer.d.ts +1 -1
- package/types/KeyboardInput.d.ts +1 -1
- package/types/RenderLoop.d.ts +2 -1
- package/types/UI.d.ts +2 -1
- package/types/action_sequencer/ActionSequencer.d.ts +1 -0
- package/types/index.d.ts +2 -2
- package/types/raycast/PlaneDragResolver.d.ts +1 -0
- package/types/raycast/SurfaceDragResolver.d.ts +1 -1
- package/types/utilities/CameraUtilities.d.ts +2 -1
- package/src/Input.js +0 -67
- package/types/Input.d.ts +0 -183
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ohzi-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "OHZI Core Library",
|
|
5
5
|
"source": "src/index.js",
|
|
6
6
|
"module": "build/index.module.js",
|
|
@@ -13,18 +13,8 @@
|
|
|
13
13
|
"package.json"
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
|
-
"preinstall": "yarn
|
|
17
|
-
"
|
|
18
|
-
"setup-pit-submodule": "git submodule update --init pit",
|
|
19
|
-
|
|
20
|
-
"update-submodules": "yarn update-pit",
|
|
21
|
-
"update-pit": "node update_submodule.mjs pit-js pit",
|
|
22
|
-
|
|
23
|
-
"config-hooks": "yarn config-core-hooks && yarn config-submodule-hooks",
|
|
24
|
-
"config-core-hooks": "git config core.hooksPath git_hooks",
|
|
25
|
-
"config-submodule-hooks": "yarn config-pit-hooks",
|
|
26
|
-
"config-pit-hooks": "cd pit && git config core.hooksPath git_hooks && cd ..",
|
|
27
|
-
|
|
16
|
+
"preinstall": "yarn config-hooks",
|
|
17
|
+
"config-hooks": "git config core.hooksPath git_hooks",
|
|
28
18
|
"build": "rollup -c",
|
|
29
19
|
"create-tag": "cross-var git tag -a \"v$npm_package_version\" -m \"Release Version $npm_package_version\" && cross-var git push origin \"v$npm_package_version\"",
|
|
30
20
|
"update-version": "cross-var echo \"v$npm_package_version\" > .version",
|
|
@@ -53,7 +43,6 @@
|
|
|
53
43
|
"registry": "https://registry.npmjs.org/"
|
|
54
44
|
},
|
|
55
45
|
"dependencies": {
|
|
56
|
-
"pit-js": "2.0.1",
|
|
57
46
|
"three": "0.148.0"
|
|
58
47
|
},
|
|
59
48
|
"devDependencies": {
|
|
@@ -64,13 +53,5 @@
|
|
|
64
53
|
"rollup-plugin-terser": "^7.0.2",
|
|
65
54
|
"standardx": "^7.0.0",
|
|
66
55
|
"typescript": "^4.4.3"
|
|
67
|
-
}
|
|
68
|
-
"standardx": {
|
|
69
|
-
"ignore": [
|
|
70
|
-
"/pit/"
|
|
71
|
-
]
|
|
72
|
-
},
|
|
73
|
-
"workspaces": [
|
|
74
|
-
"pit"
|
|
75
|
-
]
|
|
56
|
+
}
|
|
76
57
|
}
|
package/src/Initializer.js
CHANGED
|
@@ -5,7 +5,6 @@ import { Configuration } from './Configuration';
|
|
|
5
5
|
import { Debug } from './Debug';
|
|
6
6
|
import { EventManager } from './EventManager';
|
|
7
7
|
import { Graphics } from './Graphics';
|
|
8
|
-
import { Input } from './Input';
|
|
9
8
|
import { OS } from './OS';
|
|
10
9
|
import { OScreen } from './OScreen';
|
|
11
10
|
import { ReflectionPlaneContext } from './ReflectionPlaneContext';
|
|
@@ -22,15 +21,15 @@ class Initializer
|
|
|
22
21
|
{
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
init(canvas,
|
|
24
|
+
init(canvas, context_attributes, input)
|
|
26
25
|
{
|
|
27
26
|
CameraManager.init();
|
|
28
|
-
CameraUtilities.init();
|
|
27
|
+
CameraUtilities.init(input);
|
|
29
28
|
Capabilities.init();
|
|
30
29
|
Configuration.init();
|
|
31
30
|
EventManager.init();
|
|
32
31
|
GeometryBatcher.init();
|
|
33
|
-
|
|
32
|
+
|
|
34
33
|
OS.init();
|
|
35
34
|
Browser.init();
|
|
36
35
|
ReflectionPlaneContext.init();
|
|
@@ -38,7 +37,7 @@ class Initializer
|
|
|
38
37
|
SceneManager.init();
|
|
39
38
|
OScreen.init();
|
|
40
39
|
Time.init();
|
|
41
|
-
UI.init();
|
|
40
|
+
UI.init(input);
|
|
42
41
|
|
|
43
42
|
Graphics.init(canvas, context_attributes);
|
|
44
43
|
Debug.init();
|
|
@@ -47,7 +46,6 @@ class Initializer
|
|
|
47
46
|
dispose(render_loop)
|
|
48
47
|
{
|
|
49
48
|
Graphics.dispose();
|
|
50
|
-
Input.dispose();
|
|
51
49
|
SceneManager.dispose();
|
|
52
50
|
|
|
53
51
|
render_loop.dispose();
|
package/src/RenderLoop.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Time } from './Time';
|
|
2
|
-
import { Input } from './Input';
|
|
3
2
|
import { UI } from './UI';
|
|
4
3
|
import { Debug } from './Debug';
|
|
5
4
|
import { BaseApplication } from './BaseApplication';
|
|
@@ -8,12 +7,13 @@ import { ViewComponentManager } from './view_components/ViewComponentManager';
|
|
|
8
7
|
|
|
9
8
|
class RenderLoop
|
|
10
9
|
{
|
|
11
|
-
constructor(target_application, graphics)
|
|
10
|
+
constructor(target_application, graphics, input)
|
|
12
11
|
{
|
|
13
12
|
target_application = target_application || new BaseApplication();
|
|
14
13
|
|
|
15
14
|
this.target_application = target_application;
|
|
16
15
|
this.graphics = graphics;
|
|
16
|
+
this.input = input;
|
|
17
17
|
|
|
18
18
|
this.is_running = false;
|
|
19
19
|
this.frames_passed = 0;
|
|
@@ -33,7 +33,7 @@ class RenderLoop
|
|
|
33
33
|
this.target_application.on_post_start();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
this.input.update();
|
|
37
37
|
|
|
38
38
|
this.target_application.update();
|
|
39
39
|
ViewManager.update();
|
|
@@ -53,7 +53,7 @@ class RenderLoop
|
|
|
53
53
|
this.target_application.on_frame_end();
|
|
54
54
|
this.frames_passed++;
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
this.input.clear();
|
|
57
57
|
UI.clear();
|
|
58
58
|
Debug.clear();
|
|
59
59
|
}
|
package/src/UI.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Input } from './Input';
|
|
2
1
|
import { CameraManager } from './CameraManager';
|
|
3
2
|
import { Graphics } from './Graphics';
|
|
4
3
|
|
|
@@ -8,8 +7,9 @@ import { OrthographicCamera } from 'three';
|
|
|
8
7
|
|
|
9
8
|
class UI
|
|
10
9
|
{
|
|
11
|
-
init()
|
|
10
|
+
init(input)
|
|
12
11
|
{
|
|
12
|
+
this.input = input;
|
|
13
13
|
this.ui_elements = [];
|
|
14
14
|
this._tmp_normalized_pos = new Vector2();
|
|
15
15
|
this.ss_scene = new Scene();
|
|
@@ -61,7 +61,7 @@ class UI
|
|
|
61
61
|
// this.ss_camera.right = -OScreen.bottom / 2;
|
|
62
62
|
this.ss_camera.updateProjectionMatrix();
|
|
63
63
|
|
|
64
|
-
this._tmp_normalized_pos.copy(
|
|
64
|
+
this._tmp_normalized_pos.copy(this.input.NDC);
|
|
65
65
|
for (let i = 0; i < this.ui_elements.length; i++)
|
|
66
66
|
{
|
|
67
67
|
this.ui_elements[i].update_state(this._tmp_normalized_pos);
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { RaycastResolver } from '../../raycast/RaycastResolver';
|
|
2
2
|
import { GroupRaycaster } from '../../raycast/GroupRaycaster';
|
|
3
|
-
import { Input } from '../../Input';
|
|
4
3
|
|
|
5
4
|
import { Vector3 } from 'three';
|
|
6
5
|
import { Quaternion } from 'three';
|
|
7
6
|
|
|
8
7
|
class ObjectRotator extends RaycastResolver
|
|
9
8
|
{
|
|
10
|
-
constructor(object)
|
|
9
|
+
constructor(object, input)
|
|
11
10
|
{
|
|
12
11
|
super();
|
|
13
12
|
|
|
13
|
+
this.input = input;
|
|
14
|
+
|
|
14
15
|
this.is_mouse_over = false;
|
|
15
16
|
this.rotation_active = false;
|
|
16
17
|
|
|
17
18
|
this.object = object;
|
|
18
|
-
this.group_raycaster = new GroupRaycaster([object], this);
|
|
19
|
+
this.group_raycaster = new GroupRaycaster([object], this, undefined, this.input);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
on_enter(intersected_object)
|
|
@@ -37,21 +38,21 @@ class ObjectRotator extends RaycastResolver
|
|
|
37
38
|
{
|
|
38
39
|
this.group_raycaster.update();
|
|
39
40
|
|
|
40
|
-
if (this.is_mouse_over &&
|
|
41
|
+
if (this.is_mouse_over && this.input.left_mouse_button_down)
|
|
41
42
|
{
|
|
42
43
|
this.rotation_active = true;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
// left button no longer being pressed
|
|
46
|
-
if (!
|
|
47
|
+
if (!this.input.left_mouse_button_down)
|
|
47
48
|
{
|
|
48
49
|
this.rotation_active = false;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
if (this.rotation_active)
|
|
52
53
|
{
|
|
53
|
-
const rot_x = new Quaternion().setFromAxisAngle(new Vector3(0, 1, 0),
|
|
54
|
-
const rot_y = new Quaternion().setFromAxisAngle(new Vector3(1, 0, 0),
|
|
54
|
+
const rot_x = new Quaternion().setFromAxisAngle(new Vector3(0, 1, 0), this.input.NDC_delta.x);
|
|
55
|
+
const rot_y = new Quaternion().setFromAxisAngle(new Vector3(1, 0, 0), this.input.NDC_delta.y);
|
|
55
56
|
|
|
56
57
|
this.object.quaternion.multiply(rot_x);
|
|
57
58
|
rot_y.multiply(this.object.quaternion);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CameraManager } from '../CameraManager';
|
|
2
|
-
import { Input } from '../Input';
|
|
3
2
|
|
|
4
3
|
import { ArrowHelper } from 'three';
|
|
5
4
|
import { Vector2 } from 'three';
|
|
@@ -13,10 +12,12 @@ import { OMath } from '../utilities/OMath';
|
|
|
13
12
|
|
|
14
13
|
class ManipulatorHandle extends Object3D
|
|
15
14
|
{
|
|
16
|
-
constructor(direction, color)
|
|
15
|
+
constructor(direction, color, input)
|
|
17
16
|
{
|
|
18
17
|
super();
|
|
19
18
|
|
|
19
|
+
this.input = input;
|
|
20
|
+
|
|
20
21
|
const length = 10;
|
|
21
22
|
this.arrow_helper = new ArrowHelper(direction, new Vector3(0, 0, 0), length, color, undefined, 1);
|
|
22
23
|
this.add(this.arrow_helper);
|
|
@@ -47,7 +48,7 @@ class ManipulatorHandle extends Object3D
|
|
|
47
48
|
|
|
48
49
|
is_mouse_over()
|
|
49
50
|
{
|
|
50
|
-
this.raycaster.setFromCamera(
|
|
51
|
+
this.raycaster.setFromCamera(this.input.NDC, CameraManager.current);
|
|
51
52
|
this.raycast_result = this.raycaster.intersectObject(this.box_collider);
|
|
52
53
|
if (this.raycast_result.length > 0)
|
|
53
54
|
{
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Input } from '../Input';
|
|
2
1
|
import { ObjectManipulator } from './ObjectManipulator';
|
|
3
2
|
import { ObjectPicker } from './ObjectPicker';
|
|
4
3
|
|
|
@@ -6,16 +5,17 @@ import { Raycaster } from 'three';
|
|
|
6
5
|
|
|
7
6
|
class ObjectEditor
|
|
8
7
|
{
|
|
9
|
-
constructor(renderer, scene, camera)
|
|
8
|
+
constructor(renderer, scene, camera, input)
|
|
10
9
|
{
|
|
11
10
|
this.raycaster = new Raycaster();
|
|
12
11
|
|
|
13
12
|
this.selected_object = undefined;
|
|
14
|
-
this.object_manipulator = new ObjectManipulator();
|
|
13
|
+
this.object_manipulator = new ObjectManipulator(input);
|
|
15
14
|
this.object_picker = new ObjectPicker(renderer, scene, camera);
|
|
16
15
|
|
|
17
16
|
this.scene = scene;
|
|
18
17
|
this.camera = camera;
|
|
18
|
+
this.input = input;
|
|
19
19
|
|
|
20
20
|
this.selectable_objects = [];
|
|
21
21
|
|
|
@@ -31,9 +31,9 @@ class ObjectEditor
|
|
|
31
31
|
|
|
32
32
|
update()
|
|
33
33
|
{
|
|
34
|
-
if (
|
|
34
|
+
if (this.input.left_mouse_button_pressed)
|
|
35
35
|
{
|
|
36
|
-
const x = this.object_picker.pick(
|
|
36
|
+
const x = this.object_picker.pick(this.input.NDC, this.selectable_objects);
|
|
37
37
|
if (x !== 0)
|
|
38
38
|
{
|
|
39
39
|
const selected_obj = this.selectable_objects[x - 1];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ManipulatorHandle } from '../editor/ManipulatorHandle';
|
|
2
|
-
import { Input } from '../Input';
|
|
3
2
|
import { EventManager } from '../EventManager';
|
|
4
3
|
|
|
5
4
|
import { Object3D } from 'three';
|
|
@@ -8,14 +7,15 @@ import { Vector3 } from 'three';
|
|
|
8
7
|
|
|
9
8
|
class ObjectManipulator extends Object3D
|
|
10
9
|
{
|
|
11
|
-
constructor()
|
|
10
|
+
constructor(input)
|
|
12
11
|
{
|
|
13
12
|
super();
|
|
13
|
+
this.input = input;
|
|
14
14
|
this.target_obj = undefined;
|
|
15
15
|
|
|
16
|
-
this.up_handle = new ManipulatorHandle(new Vector3(0, 1, 0), 0x00ff00);
|
|
17
|
-
this.right_handle = new ManipulatorHandle(new Vector3(1, 0, 0), 0xff0000);
|
|
18
|
-
this.forward_handle = new ManipulatorHandle(new Vector3(0, 0, 1), 0x0000ff);
|
|
16
|
+
this.up_handle = new ManipulatorHandle(new Vector3(0, 1, 0), 0x00ff00, input);
|
|
17
|
+
this.right_handle = new ManipulatorHandle(new Vector3(1, 0, 0), 0xff0000, input);
|
|
18
|
+
this.forward_handle = new ManipulatorHandle(new Vector3(0, 0, 1), 0x0000ff, input);
|
|
19
19
|
|
|
20
20
|
this.add(this.up_handle);
|
|
21
21
|
this.add(this.right_handle);
|
|
@@ -46,14 +46,14 @@ class ObjectManipulator extends Object3D
|
|
|
46
46
|
this.tmp_displacement_vector.copy(this.active_handle.direction);
|
|
47
47
|
if (this.use_vertical_translation)
|
|
48
48
|
{
|
|
49
|
-
this.tmp_displacement_vector.multiplyScalar(-
|
|
49
|
+
this.tmp_displacement_vector.multiplyScalar(-this.input.NDC_delta.y);
|
|
50
50
|
}
|
|
51
51
|
else
|
|
52
52
|
{
|
|
53
|
-
this.tmp_displacement_vector.multiplyScalar(
|
|
53
|
+
this.tmp_displacement_vector.multiplyScalar(this.input.NDC_delta.x);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
this.tmp_displacement_vector.multiplyScalar(
|
|
56
|
+
this.tmp_displacement_vector.multiplyScalar(this.input.NDC_delta.length() * 250 * this.translation_sign);
|
|
57
57
|
this.position.add(this.tmp_displacement_vector);
|
|
58
58
|
|
|
59
59
|
this.tmp_local_pos.copy(this.position);
|
|
@@ -86,7 +86,7 @@ class ObjectManipulator extends Object3D
|
|
|
86
86
|
|
|
87
87
|
check_active_handle()
|
|
88
88
|
{
|
|
89
|
-
if (
|
|
89
|
+
if (this.input.left_mouse_button_down && this.active_handle === undefined)
|
|
90
90
|
{
|
|
91
91
|
if (this.right_handle.is_mouse_over())
|
|
92
92
|
{
|
|
@@ -103,7 +103,7 @@ class ObjectManipulator extends Object3D
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
if (
|
|
106
|
+
if (this.input.left_mouse_button_released)
|
|
107
107
|
{
|
|
108
108
|
this.active_handle = undefined;
|
|
109
109
|
}
|
package/src/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import { Debug } from './Debug';
|
|
|
19
19
|
import { DebugNormalsRender } from './render_mode/DebugNormalsRender';
|
|
20
20
|
import { EventManager } from './EventManager';
|
|
21
21
|
import { Graphics } from './Graphics';
|
|
22
|
-
import {
|
|
22
|
+
import { KeyboardInput } from './KeyboardInput';
|
|
23
23
|
import { Initializer } from './Initializer';
|
|
24
24
|
import { NormalAORender } from './render_mode/NormalAORender';
|
|
25
25
|
import { NormalRender } from './render_mode/NormalRender';
|
|
@@ -131,7 +131,7 @@ export {
|
|
|
131
131
|
DebugNormalsRender,
|
|
132
132
|
EventManager,
|
|
133
133
|
Graphics,
|
|
134
|
-
|
|
134
|
+
KeyboardInput,
|
|
135
135
|
Initializer,
|
|
136
136
|
NormalAORender,
|
|
137
137
|
NormalRender,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CameraManager } from '../CameraManager';
|
|
2
|
-
import { Input } from '../Input';
|
|
3
2
|
import { RaycastResolver } from './RaycastResolver';
|
|
4
3
|
import { IdleState } from './states/IdleState';
|
|
5
4
|
|
|
@@ -7,11 +6,12 @@ import { Raycaster } from 'three';
|
|
|
7
6
|
|
|
8
7
|
class GroupRaycaster
|
|
9
8
|
{
|
|
10
|
-
constructor(raycastee_group, raycast_resolver, camera)
|
|
9
|
+
constructor(raycastee_group, raycast_resolver, camera, input)
|
|
11
10
|
{
|
|
12
11
|
this.camera = camera || CameraManager.current;
|
|
13
12
|
this.raycast_resolver = raycast_resolver || new RaycastResolver();
|
|
14
13
|
this.raycastee_group = raycastee_group || [];
|
|
14
|
+
this.input = input;
|
|
15
15
|
|
|
16
16
|
this.raycaster = new Raycaster();
|
|
17
17
|
this.current_state = new IdleState();
|
|
@@ -25,7 +25,7 @@ class GroupRaycaster
|
|
|
25
25
|
|
|
26
26
|
update()
|
|
27
27
|
{
|
|
28
|
-
this.raycaster.setFromCamera(
|
|
28
|
+
this.raycaster.setFromCamera(this.input.NDC, this.camera);
|
|
29
29
|
this.current_intersections = this.raycaster.intersectObjects(this.raycastee_group);
|
|
30
30
|
this.current_state.update(this);
|
|
31
31
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { PlaneRaycaster } from './PlaneRaycaster';
|
|
2
2
|
import { PlaneRaycastResolver } from './PlaneRaycastResolver';
|
|
3
|
-
import { Input } from '../Input';
|
|
4
3
|
|
|
5
4
|
class PlaneDragResolver extends PlaneRaycastResolver
|
|
6
5
|
{
|
|
7
|
-
constructor()
|
|
6
|
+
constructor(input)
|
|
8
7
|
{
|
|
9
8
|
super();
|
|
10
9
|
this._drag_started = false;
|
|
11
10
|
this._plane_raycaster = new PlaneRaycaster(this);
|
|
11
|
+
|
|
12
|
+
this.input = input;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
// @virtual
|
|
@@ -38,13 +39,13 @@ class PlaneDragResolver extends PlaneRaycastResolver
|
|
|
38
39
|
// @virtual
|
|
39
40
|
on_drag_button_pressed()
|
|
40
41
|
{
|
|
41
|
-
return
|
|
42
|
+
return this.input.left_mouse_button_pressed;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
// @virtual
|
|
45
46
|
on_drag_button_released()
|
|
46
47
|
{
|
|
47
|
-
return
|
|
48
|
+
return this.input.left_mouse_button_released;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
on_hover(intersection_point)
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { RaycastResolver } from './RaycastResolver';
|
|
2
2
|
import { GroupRaycaster } from './GroupRaycaster';
|
|
3
|
-
import { Input } from '../Input';
|
|
4
3
|
|
|
5
4
|
class SurfaceDragResolver extends RaycastResolver
|
|
6
5
|
{
|
|
7
|
-
constructor(surface_mesh)
|
|
6
|
+
constructor(surface_mesh, input)
|
|
8
7
|
{
|
|
9
8
|
super();
|
|
10
9
|
this._drag_started = false;
|
|
11
|
-
this._group_raycaster = new GroupRaycaster([surface_mesh], this);
|
|
10
|
+
this._group_raycaster = new GroupRaycaster([surface_mesh], this, undefined, input);
|
|
11
|
+
|
|
12
|
+
this.input = input;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
// @virtual
|
|
@@ -42,7 +43,7 @@ class SurfaceDragResolver extends RaycastResolver
|
|
|
42
43
|
|
|
43
44
|
on_hover(intersected_object, intersection_data)
|
|
44
45
|
{
|
|
45
|
-
if (
|
|
46
|
+
if (this.input.left_mouse_button_released && this._drag_started)
|
|
46
47
|
{
|
|
47
48
|
this._drag_started = false;
|
|
48
49
|
this.on_drag_end();
|
|
@@ -53,7 +54,7 @@ class SurfaceDragResolver extends RaycastResolver
|
|
|
53
54
|
this.on_drag_move(intersection_data.point);
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
if (
|
|
57
|
+
if (this.input.left_mouse_button_pressed)
|
|
57
58
|
{
|
|
58
59
|
this.on_drag_start(intersection_data.point);
|
|
59
60
|
this._drag_started = true;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CameraManager } from '../CameraManager';
|
|
2
|
-
import { Input } from '../Input';
|
|
3
2
|
import { OMath } from '../utilities/OMath';
|
|
4
3
|
import { OScreen } from '../OScreen';
|
|
5
4
|
|
|
@@ -12,7 +11,7 @@ import { Box3 } from 'three';
|
|
|
12
11
|
|
|
13
12
|
class CameraUtilities
|
|
14
13
|
{
|
|
15
|
-
init()
|
|
14
|
+
init(input)
|
|
16
15
|
{
|
|
17
16
|
this.tmp_mat = new Matrix4();
|
|
18
17
|
this.plane = new Plane();
|
|
@@ -20,6 +19,8 @@ class CameraUtilities
|
|
|
20
19
|
|
|
21
20
|
this.tmp_size = new Vector3();
|
|
22
21
|
this.tmp_unproj = new Vector3();
|
|
22
|
+
|
|
23
|
+
this.input = input;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
get_up_dir(camera)
|
|
@@ -73,7 +74,7 @@ class CameraUtilities
|
|
|
73
74
|
get_plane_intersection(plane_position, plane_normal, NDC, camera)
|
|
74
75
|
{
|
|
75
76
|
camera = camera || CameraManager.current;
|
|
76
|
-
NDC = NDC ||
|
|
77
|
+
NDC = NDC || this.input.NDC;
|
|
77
78
|
|
|
78
79
|
const tmp_vec = new Vector3();
|
|
79
80
|
|
package/types/Initializer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { initializer as Initializer };
|
|
2
2
|
declare const initializer: Initializer;
|
|
3
3
|
declare class Initializer {
|
|
4
|
-
init(canvas: any,
|
|
4
|
+
init(canvas: any, context_attributes: any, input: any): void;
|
|
5
5
|
dispose(render_loop: any): void;
|
|
6
6
|
}
|
package/types/KeyboardInput.d.ts
CHANGED
package/types/RenderLoop.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export class RenderLoop {
|
|
2
|
-
constructor(target_application: any, graphics: any);
|
|
2
|
+
constructor(target_application: any, graphics: any, input: any);
|
|
3
3
|
target_application: any;
|
|
4
4
|
graphics: any;
|
|
5
|
+
input: any;
|
|
5
6
|
is_running: boolean;
|
|
6
7
|
frames_passed: number;
|
|
7
8
|
update(): void;
|
package/types/UI.d.ts
CHANGED
|
@@ -30,4 +30,5 @@ export class ActionSequencer {
|
|
|
30
30
|
is_channel_redefined(channel_name: any): boolean;
|
|
31
31
|
__linear_map_01(value: any, from_range_start_value: any, from_range_end_value: any): number;
|
|
32
32
|
__get_current_keyframe(channel_name: any, time: any): any;
|
|
33
|
+
__get_playback_speed(): number;
|
|
33
34
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { Debug } from "./Debug";
|
|
|
14
14
|
import { DebugNormalsRender } from "./render_mode/DebugNormalsRender";
|
|
15
15
|
import { EventManager } from "./EventManager";
|
|
16
16
|
import { Graphics } from "./Graphics";
|
|
17
|
-
import {
|
|
17
|
+
import { KeyboardInput } from "./KeyboardInput";
|
|
18
18
|
import { Initializer } from "./Initializer";
|
|
19
19
|
import { NormalAORender } from "./render_mode/NormalAORender";
|
|
20
20
|
import { NormalRender } from "./render_mode/NormalRender";
|
|
@@ -100,4 +100,4 @@ import { TextureLoader } from "./resource_loader/TextureLoader";
|
|
|
100
100
|
import { VideoLoader } from "./resource_loader/VideoLoader";
|
|
101
101
|
import { ResourceBatch } from "./resource_loader/ResourceBatch";
|
|
102
102
|
import { ResourceContainer } from "./ResourceContainer";
|
|
103
|
-
export { AbstractLoader, ActionSequencerBuilder, ApplicationView, BaseApplication, BaseShaderMaterial, Browser, CameraManager, Capabilities, CanvasDrawer, Configuration, CSSAnimator, DrawIOAnimationSheet, Debug, DebugNormalsRender, EventManager, Graphics,
|
|
103
|
+
export { AbstractLoader, ActionSequencerBuilder, ApplicationView, BaseApplication, BaseShaderMaterial, Browser, CameraManager, Capabilities, CanvasDrawer, Configuration, CSSAnimator, DrawIOAnimationSheet, Debug, DebugNormalsRender, EventManager, Graphics, KeyboardInput, Initializer, NormalAORender, NormalRender, VRRender, UnrealBloomRender, OrthographicCamera, OS, PerspectiveCamera, RenderLoop, SceneManager, OScreen, Screen, SimpleTextDrawer, Time, UI, BlitMaterial, AddMaterial, UnrealBloomComposeMaterial, BaseRender, ArrayUtilities, CameraUtilities, EasingFunctions, FrustumPointFitter, GeometryUtilities, HTMLUtilities, ImageUtilities, OMath, MeshSampler, ModelUtilities, ObjectUtilities, StringUtilities, TimeUtilities, Validation, ViewComponent, ViewComponentManager, ViewManager, Grid, Line, Text2D, TransitionTable, UIElement, SDFTextBatch, UpdatableMaterialMesh, WorldImage, Arrow, Cube, HorizontalPlane, Sphere, VerticalPlane, ActionSequencer, ActionEvent, ActionInterpolator, NumberInterpolator, VectorInterpolator, ViewContext, MedianFilter, GaussianBlurrer, Blurrer, DualFilteringBlurrer, GPUParticleSystem, ParticleAttribute, ParticlePositionAttribute, PerspectiveFrustumPointFitter, OrthographicFrustumPointFitter, DualFilteringBlurMaterial, BufferGeometryUtils, MeshBatcher, AudioLoader, BasisLoader, CubemapLoader, DAELoader, FileLoader, FontLoader, GLTFLoader, GLTFDRACOLoader, HDRCubeTextureLoader, JSONLoader, OBJLoader, PointArrayLoader, RGBETextureLoader, TextLoader, AsyncTextureLoader, TextureLoader, VideoLoader, ResourceBatch, ResourceContainer };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export { camera_utilities as CameraUtilities };
|
|
2
2
|
declare const camera_utilities: CameraUtilities;
|
|
3
3
|
declare class CameraUtilities {
|
|
4
|
-
init(): void;
|
|
4
|
+
init(input: any): void;
|
|
5
5
|
tmp_mat: any;
|
|
6
6
|
plane: any;
|
|
7
7
|
ray: any;
|
|
8
8
|
tmp_size: any;
|
|
9
9
|
tmp_unproj: any;
|
|
10
|
+
input: any;
|
|
10
11
|
get_up_dir(camera: any): any;
|
|
11
12
|
get_forward_dir(camera: any): any;
|
|
12
13
|
get_right_dir(camera: any): any;
|
package/src/Input.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { InputController } from 'pit-js';
|
|
2
|
-
import { KeyboardInput } from './KeyboardInput';
|
|
3
|
-
|
|
4
|
-
class Input extends InputController
|
|
5
|
-
{
|
|
6
|
-
constructor()
|
|
7
|
-
{
|
|
8
|
-
super();
|
|
9
|
-
|
|
10
|
-
this.clicked = false;
|
|
11
|
-
this.captured_NDC = { x: 0, y: 0 };
|
|
12
|
-
this.current_NDC_delta = { x: 0, y: 0 };
|
|
13
|
-
|
|
14
|
-
this.keyboard = new KeyboardInput();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
init(container, keyboard_input_container)
|
|
18
|
-
{
|
|
19
|
-
super.init(container);
|
|
20
|
-
|
|
21
|
-
this.keyboard.init(keyboard_input_container);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
dispose()
|
|
25
|
-
{
|
|
26
|
-
super.dispose();
|
|
27
|
-
|
|
28
|
-
this.keyboard.dispose();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
update()
|
|
32
|
-
{
|
|
33
|
-
if (this.left_mouse_button_pressed)
|
|
34
|
-
{
|
|
35
|
-
this.captured_NDC.x = this.NDC.x;
|
|
36
|
-
this.captured_NDC.y = this.NDC.y;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (this.left_mouse_button_down)
|
|
40
|
-
{
|
|
41
|
-
this.current_NDC_delta.x += Math.abs(this.NDC_delta.x);
|
|
42
|
-
this.current_NDC_delta.y += Math.abs(this.NDC_delta.y);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (this.left_mouse_button_released)
|
|
46
|
-
{
|
|
47
|
-
if (this.current_NDC_delta.x < 0.001 || this.current_NDC_delta.y < 0.001)
|
|
48
|
-
{
|
|
49
|
-
this.clicked = true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.current_NDC_delta = { x: 0, y: 0 };
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
clear()
|
|
57
|
-
{
|
|
58
|
-
super.clear();
|
|
59
|
-
|
|
60
|
-
this.clicked = false;
|
|
61
|
-
|
|
62
|
-
this.keyboard.clear();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const input = new Input();
|
|
67
|
-
export { input as Input };
|