ohzi-core 6.2.3 → 6.3.2
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 +1 -1
- package/src/CustomBezierCurve.js +2 -2
- package/src/Debug.js +28 -28
- package/src/EventManager.js +1 -1
- package/src/Graphics.js +12 -12
- package/src/KeyboardInput.js +1 -1
- package/src/OS.js +5 -5
- package/src/UI.js +1 -1
- package/src/action_sequencer/ActionSequencer.js +17 -12
- package/src/action_sequencer/VectorInterpolator.js +1 -1
- package/src/canvas_drawer/CanvasDrawer.js +8 -8
- package/src/canvas_drawer/MultiLineTextDrawer.js +3 -3
- package/src/canvas_drawer/SimpleTextDrawer.js +1 -1
- package/src/components/EdgeMesh.js +17 -17
- package/src/components/GeometryEdgeVisualizer.js +1 -1
- package/src/components/Grid.js +3 -3
- package/src/components/Line.js +16 -16
- package/src/components/MultiLinePath.js +1 -1
- package/src/components/MultiLineText2D.js +1 -1
- package/src/components/ObjectAxis.js +3 -3
- package/src/components/ObjectOrientedBoundingBox.js +19 -19
- package/src/components/Shape2D.js +7 -7
- package/src/components/Shape3D.js +5 -5
- package/src/components/Text2D.js +3 -3
- package/src/components/UIElement.js +2 -2
- package/src/components/UpdatableMaterialMesh.js +1 -1
- package/src/components/WorldImage.js +4 -4
- package/src/components/mouse_interactors/ObjectRotator.js +2 -2
- package/src/components/sdf_text/SDFText.js +10 -10
- package/src/components/sdf_text/SDFTextBatch.js +24 -24
- package/src/components/sdf_text/TextGlyph.js +2 -2
- package/src/data_textures/RGBADataTexture.js +1 -1
- package/src/data_textures/RGBAFloatDataTexture.js +1 -1
- package/src/data_textures/RGBDataTexture.js +1 -1
- package/src/data_textures/RGBFloatDataTexture.js +1 -1
- package/src/editor/ManipulatorHandle.js +4 -4
- package/src/editor/ObjectEditor.js +2 -2
- package/src/editor/ObjectManipulator.js +3 -3
- package/src/gpu_particles/GPUParticleSystem.js +4 -4
- package/src/gpu_particles/ParticleAttribute.js +4 -4
- package/src/gpu_particles/ParticlePositionAttribute.js +2 -2
- package/src/materials/MedianFilterMaterial.js +1 -1
- package/src/materials/SSAOMaterial.js +5 -5
- package/src/materials/ScreenSpaceTextureMaterial.js +2 -2
- package/src/materials/UnrealBloomComposeMaterial.js +1 -1
- package/src/materials/UnrealBlurMaterial.js +1 -1
- package/src/materials/UnrealComposeMaterial.js +1 -1
- package/src/object_pool/Pool.js +3 -3
- package/src/primitives/Arrow.js +6 -6
- package/src/primitives/Cube.js +2 -2
- package/src/primitives/HorizontalPlane.js +1 -1
- package/src/primitives/Sphere.js +2 -2
- package/src/primitives/VerticalPlane.js +1 -1
- package/src/render_mode/DeferredRender.js +10 -10
- package/src/render_mode/PlanarReflectionsRender.js +3 -3
- package/src/render_mode/TransparencyMixRender.js +1 -1
- package/src/render_utilities/Blitter.js +7 -7
- package/src/render_utilities/GaussianBlurrer.js +3 -3
- package/src/render_utilities/MedianFilter.js +1 -1
- package/src/resource_loader/AbstractLoader.js +1 -1
- package/src/resource_loader/BasisLoader.js +1 -1
- package/src/resource_loader/CubemapLoader.js +1 -1
- package/src/resource_loader/DAELoader.js +1 -1
- package/src/resource_loader/DDSLoader.js +1 -1
- package/src/resource_loader/FileLoader.js +1 -1
- package/src/resource_loader/FontLoader.js +1 -1
- package/src/resource_loader/GLTFDRACOLoader.js +1 -1
- package/src/resource_loader/GLTFLoader.js +1 -1
- package/src/resource_loader/HDRCubeTextureLoader.js +1 -1
- package/src/resource_loader/JSONLoader.js +1 -1
- package/src/resource_loader/OBJLoader.js +1 -1
- package/src/resource_loader/PointArrayLoader.js +6 -6
- package/src/resource_loader/RGBETextureLoader.js +1 -1
- package/src/resource_loader/SVGLoader.js +1 -1
- package/src/resource_loader/TextLoader.js +1 -1
- package/src/static_batcher/GeometryBatch.js +20 -20
- package/src/static_batcher/GeometryBatcher.js +7 -7
- package/src/static_batcher/MeshBatcher.js +8 -8
- package/src/utilities/ArrayUtilities.js +4 -4
- package/src/utilities/CameraUtilities.js +24 -24
- package/src/utilities/EasingFunctions.js +19 -8
- package/src/utilities/FrustumPointFitter.js +55 -55
- package/src/utilities/GeometryUtilities.js +7 -7
- package/src/utilities/ImageUtilities.js +4 -4
- package/src/utilities/MeshSampler.js +33 -33
- package/src/utilities/ModelUtilities.js +2 -2
- package/src/utilities/OMath.js +4 -4
- package/src/utilities/ObjectUtilities.js +4 -4
- package/src/utilities/OrthographicFrustumPointFitter.js +10 -10
- package/src/utilities/PerspectiveFrustumPointFitter.js +55 -55
- package/src/view_components/ApplicationView.js +2 -2
- package/src/view_components/ViewComponent.js +26 -2
- package/src/view_components/ViewComponentManager.js +11 -1
- package/src/view_components/ViewManager.js +20 -2
- package/src/view_components/transition/ActionSequencerBuilder.js +18 -18
- package/src/view_components/transition/DrawIOAnimationSheet.js +20 -20
- package/src/view_components/transition/TransitionTable.js +1 -1
- package/src/view_components/transition/ViewStateTransitionHandler.js +2 -1
|
@@ -8,38 +8,38 @@ class MeshSampler
|
|
|
8
8
|
|
|
9
9
|
sample(buffer_geometry, sample_count)
|
|
10
10
|
{
|
|
11
|
-
|
|
11
|
+
const face_areas = [];
|
|
12
12
|
|
|
13
13
|
let min_area = 99999999;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const vertices = buffer_geometry.getAttribute('position');
|
|
16
|
+
const normals = buffer_geometry.getAttribute('normal');
|
|
17
|
+
const indices = buffer_geometry.index;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const faces = [];
|
|
20
20
|
|
|
21
21
|
for (let i = 0; i < indices.count; i += 3)
|
|
22
22
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const index_0 = indices.array[i + 0];
|
|
24
|
+
const index_1 = indices.array[i + 1];
|
|
25
|
+
const index_2 = indices.array[i + 2];
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const v1 = new Vector3();
|
|
28
28
|
v1.x = vertices.getX(index_0);
|
|
29
29
|
v1.y = vertices.getY(index_0);
|
|
30
30
|
v1.z = vertices.getZ(index_0);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
const v2 = new Vector3();
|
|
33
33
|
v2.x = vertices.getX(index_1);
|
|
34
34
|
v2.y = vertices.getY(index_1);
|
|
35
35
|
v2.z = vertices.getZ(index_1);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
const v3 = new Vector3();
|
|
38
38
|
v3.x = vertices.getX(index_2);
|
|
39
39
|
v3.y = vertices.getY(index_2);
|
|
40
40
|
v3.z = vertices.getZ(index_2);
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const face = {
|
|
43
43
|
a: v1,
|
|
44
44
|
b: v2,
|
|
45
45
|
c: v3
|
|
@@ -47,48 +47,48 @@ class MeshSampler
|
|
|
47
47
|
|
|
48
48
|
if (normals)
|
|
49
49
|
{
|
|
50
|
-
|
|
50
|
+
const n1 = new Vector3();
|
|
51
51
|
n1.x = normals.getX(index_0);
|
|
52
52
|
n1.y = normals.getY(index_0);
|
|
53
53
|
n1.z = normals.getZ(index_0);
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
const n2 = new Vector3();
|
|
56
56
|
n2.x = normals.getX(index_1);
|
|
57
57
|
n2.y = normals.getY(index_1);
|
|
58
58
|
n2.z = normals.getZ(index_1);
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
const n3 = new Vector3();
|
|
61
61
|
n3.x = normals.getX(index_2);
|
|
62
62
|
n3.y = normals.getY(index_2);
|
|
63
63
|
n3.z = normals.getZ(index_2);
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
const normal = n1.clone().add(n2).add(n3).normalize();
|
|
66
66
|
face.normal = normal;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
faces.push(face);
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
const area = this.get_face_area(face);
|
|
72
72
|
min_area = Math.min(area, min_area);
|
|
73
73
|
face_areas.push(area);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
const normalized_faces_array = this.get_uniform_face_distribution(face_areas, min_area, faces);
|
|
77
|
+
const selected_faces = this.select_random_faces(normalized_faces_array, sample_count);
|
|
78
|
+
const sampled_data = this.sample_data_from_faces(selected_faces);
|
|
79
79
|
return sampled_data;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
sample_data_from_faces(faces)
|
|
83
83
|
{
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const sampled_points = [];
|
|
85
|
+
const sampled_normals = [];
|
|
86
86
|
for (let i = 0; i < faces.length; i++)
|
|
87
87
|
{
|
|
88
|
-
|
|
88
|
+
const face = faces[i];
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
const w1 = Math.random();
|
|
91
|
+
const w2 = Math.random();
|
|
92
92
|
|
|
93
93
|
sampled_points.push(this.sample_point_in_face(w1, w2, face.a, face.b, face.c).clone());
|
|
94
94
|
if (face.normal)
|
|
@@ -101,11 +101,11 @@ class MeshSampler
|
|
|
101
101
|
|
|
102
102
|
select_random_faces(faces, amount)
|
|
103
103
|
{
|
|
104
|
-
|
|
104
|
+
const selected_faces = [];
|
|
105
105
|
for (let i = 0; i < amount; i++)
|
|
106
106
|
{
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
const random = Math.floor(Math.random() * faces.length);
|
|
108
|
+
const selected_face = faces[random];
|
|
109
109
|
|
|
110
110
|
selected_faces.push(selected_face);
|
|
111
111
|
}
|
|
@@ -115,11 +115,11 @@ class MeshSampler
|
|
|
115
115
|
|
|
116
116
|
get_uniform_face_distribution(face_areas, minimum_area, faces)
|
|
117
117
|
{
|
|
118
|
-
|
|
118
|
+
const extended_triangle_indices = [];
|
|
119
119
|
for (let i = 0; i < face_areas.length; i++)
|
|
120
120
|
{
|
|
121
121
|
face_areas[i] /= minimum_area;
|
|
122
|
-
|
|
122
|
+
const repetitions_needed = Math.floor(Math.round(face_areas[i]));
|
|
123
123
|
for (let j = 0; j < repetitions_needed; j++)
|
|
124
124
|
{
|
|
125
125
|
extended_triangle_indices.push(faces[i]);
|
|
@@ -130,8 +130,8 @@ class MeshSampler
|
|
|
130
130
|
|
|
131
131
|
get_face_area(face)
|
|
132
132
|
{
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
const vec1 = face.b.clone().sub(face.a);
|
|
134
|
+
const vec2 = face.c.clone().sub(face.a);
|
|
135
135
|
return vec1.cross(vec2).length() / 2;
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -143,7 +143,7 @@ class MeshSampler
|
|
|
143
143
|
w2 = 1.0 - w2;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
const w3 = 1.0 - (w1 + w2);
|
|
147
147
|
|
|
148
148
|
return v1.clone().multiplyScalar(w1).add(v2.clone().multiplyScalar(w2)).add(v3.clone().multiplyScalar(w3));
|
|
149
149
|
}
|
|
@@ -21,7 +21,7 @@ class ModelUtilities
|
|
|
21
21
|
|
|
22
22
|
get_geometries(scene)
|
|
23
23
|
{
|
|
24
|
-
|
|
24
|
+
const geometries = [];
|
|
25
25
|
|
|
26
26
|
this.get_mesh(scene, (child) =>
|
|
27
27
|
{
|
|
@@ -86,7 +86,7 @@ class ModelUtilities
|
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
for (
|
|
89
|
+
for (const name in skinnedMeshes)
|
|
90
90
|
{
|
|
91
91
|
const skinnedMesh = skinnedMeshes[name];
|
|
92
92
|
const skeleton = skinnedMesh.skeleton;
|
package/src/utilities/OMath.js
CHANGED
|
@@ -49,8 +49,8 @@ export default class OMath
|
|
|
49
49
|
|
|
50
50
|
static project_points_on_plane(points, plane)
|
|
51
51
|
{
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const projected_point = new Vector3();
|
|
53
|
+
const points_on_plane = [];
|
|
54
54
|
for (let i = 0; i < points.length; i++)
|
|
55
55
|
{
|
|
56
56
|
plane.projectPoint(points[i], projected_point);
|
|
@@ -123,7 +123,7 @@ export default class OMath
|
|
|
123
123
|
|
|
124
124
|
static points_average(points)
|
|
125
125
|
{
|
|
126
|
-
|
|
126
|
+
const center = points[0].clone();
|
|
127
127
|
for (let i = 1; i < points.length; i++)
|
|
128
128
|
{
|
|
129
129
|
center.add(points[i]);
|
|
@@ -134,7 +134,7 @@ export default class OMath
|
|
|
134
134
|
|
|
135
135
|
static get_random_color()
|
|
136
136
|
{
|
|
137
|
-
|
|
137
|
+
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f'];
|
|
138
138
|
|
|
139
139
|
let col = '#';
|
|
140
140
|
col += arr[Math.floor(Math.random() * 16)];
|
|
@@ -17,7 +17,7 @@ export default class ObjectUtilities
|
|
|
17
17
|
obj['@attributes'] = {};
|
|
18
18
|
for (let j = 0; j < xml.attributes.length; j++)
|
|
19
19
|
{
|
|
20
|
-
|
|
20
|
+
const attribute = xml.attributes.item(j);
|
|
21
21
|
obj['@attributes'][attribute.nodeName] = attribute.nodeValue;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -32,8 +32,8 @@ export default class ObjectUtilities
|
|
|
32
32
|
{
|
|
33
33
|
for (let i = 0; i < xml.childNodes.length; i++)
|
|
34
34
|
{
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const item = xml.childNodes.item(i);
|
|
36
|
+
const nodeName = item.nodeName;
|
|
37
37
|
if (typeof (obj[nodeName]) === 'undefined')
|
|
38
38
|
{
|
|
39
39
|
obj[nodeName] = this.xml_to_json(item);
|
|
@@ -42,7 +42,7 @@ export default class ObjectUtilities
|
|
|
42
42
|
{
|
|
43
43
|
if (typeof (obj[nodeName].push) === 'undefined')
|
|
44
44
|
{
|
|
45
|
-
|
|
45
|
+
const old = obj[nodeName];
|
|
46
46
|
obj[nodeName] = [];
|
|
47
47
|
obj[nodeName].push(old);
|
|
48
48
|
}
|
|
@@ -9,22 +9,22 @@ export default class OrthographicFrustumPointFitter
|
|
|
9
9
|
|
|
10
10
|
fit_points(points, camera_quaternion, vertical_fov, aspect)
|
|
11
11
|
{
|
|
12
|
-
|
|
12
|
+
const inverse_camera_quat = camera_quaternion.clone().inverse();
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const inverted_points = [];
|
|
15
15
|
|
|
16
16
|
for (let i = 0; i < points.length; i++)
|
|
17
17
|
{
|
|
18
18
|
inverted_points.push(points[i].clone().applyQuaternion(inverse_camera_quat));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const box = new Box3().setFromPoints(inverted_points);
|
|
22
|
+
const size = new Vector3();
|
|
23
23
|
box.getSize(size);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const distance = this.get_distance_to_fit_rect(size.x / 2, size.y / 2, vertical_fov, aspect);
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const center = new Vector3();
|
|
28
28
|
box.getCenter(center);
|
|
29
29
|
|
|
30
30
|
center.applyQuaternion(camera_quaternion);
|
|
@@ -37,11 +37,11 @@ export default class OrthographicFrustumPointFitter
|
|
|
37
37
|
|
|
38
38
|
get_distance_to_fit_rect(width, height, vertical_fov, aspect)
|
|
39
39
|
{
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const v_fov = (vertical_fov / 2) * Math.PI / 180;
|
|
41
|
+
const h_fov = (2 * Math.atan(Math.tan(v_fov) * aspect)) / 2;
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const distV = height / Math.tan(v_fov);
|
|
44
|
+
const distH = width / Math.tan(h_fov);
|
|
45
45
|
return Math.max(Math.abs(distH), Math.abs(distV));
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -10,26 +10,26 @@ export default class PerspectiveFrustumPointFitter
|
|
|
10
10
|
{
|
|
11
11
|
this.sphere.setFromPoints(points);
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const v_fov = TMath.degToRad(vertical_fov / 2);
|
|
14
|
+
const h_fov = (2 * Math.atan(Math.tan(v_fov) * aspect)) / 2;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const up_plane_normal = this.get_up_plane_normal(camera_quaternion, v_fov);
|
|
17
|
+
const down_plane_normal = this.get_down_plane_normal(camera_quaternion, v_fov);
|
|
18
|
+
const left_plane_normal = this.get_left_plane_normal(camera_quaternion, h_fov);
|
|
19
|
+
const right_plane_normal = this.get_right_plane_normal(camera_quaternion, h_fov);
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const camera_forward_dir = new Vector3(0, 0, -1).applyQuaternion(camera_quaternion);
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
const sphere_center = this.sphere.center.clone();
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const pull_back_distance = this.get_distance_to_fit_rect(this.sphere.radius * 2, this.sphere.radius * 2, vertical_fov, aspect);
|
|
26
|
+
const far_pos = sphere_center.clone().add(camera_forward_dir.clone().multiplyScalar(pull_back_distance * -1));
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const up_plane = new Plane().setFromNormalAndCoplanarPoint(up_plane_normal, far_pos);
|
|
29
|
+
const down_plane = new Plane().setFromNormalAndCoplanarPoint(down_plane_normal, far_pos);
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const left_plane = new Plane().setFromNormalAndCoplanarPoint(left_plane_normal, far_pos);
|
|
32
|
+
const right_plane = new Plane().setFromNormalAndCoplanarPoint(right_plane_normal, far_pos);
|
|
33
33
|
|
|
34
34
|
this.apply_center_correction_to_pos(far_pos, points, camera_quaternion, up_plane, down_plane, left_plane, right_plane);
|
|
35
35
|
|
|
@@ -41,16 +41,16 @@ export default class PerspectiveFrustumPointFitter
|
|
|
41
41
|
|
|
42
42
|
let closest_distance = Infinity;
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
const inverse_dir = camera_forward_dir.clone().multiplyScalar(pull_back_distance * -2);
|
|
45
45
|
for (let i = 0; i < points.length; i++)
|
|
46
46
|
{
|
|
47
|
-
|
|
47
|
+
const line = new Line3(points[i].clone(), points[i].clone().add(inverse_dir));
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const up_line_intersection = new Vector3();
|
|
50
|
+
const down_line_intersection = new Vector3();
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const left_line_intersection = new Vector3();
|
|
53
|
+
const right_line_intersection = new Vector3();
|
|
54
54
|
|
|
55
55
|
up_plane.intersectLine(line, up_line_intersection);
|
|
56
56
|
down_plane.intersectLine(line, down_line_intersection);
|
|
@@ -75,16 +75,16 @@ export default class PerspectiveFrustumPointFitter
|
|
|
75
75
|
console.log('right intersection not found', i);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
const new_up_distance = points[i].clone().sub(up_line_intersection).length();
|
|
79
|
+
const new_down_distance = points[i].clone().sub(down_line_intersection).length();
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
const new_left_distance = points[i].clone().sub(left_line_intersection).length();
|
|
82
|
+
const new_right_distance = points[i].clone().sub(right_line_intersection).length();
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const vertical_min = Math.min(new_up_distance, new_down_distance);
|
|
85
|
+
const horizontal_min = Math.min(new_left_distance, new_right_distance);
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
const min = Math.min(vertical_min, horizontal_min);
|
|
88
88
|
|
|
89
89
|
if (min < closest_distance)
|
|
90
90
|
{
|
|
@@ -92,16 +92,16 @@ export default class PerspectiveFrustumPointFitter
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const forward_correction = camera_forward_dir.clone().multiplyScalar(closest_distance);
|
|
96
|
+
const closest_position = far_pos.clone().add(forward_correction);
|
|
97
97
|
|
|
98
98
|
return closest_position;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
apply_center_correction_to_pos(target_pos, points, camera_quaternion, up_plane, down_plane, left_plane, right_plane)
|
|
102
102
|
{
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
const vertical_offset = this.get_vertical_correction(points, down_plane, up_plane, camera_quaternion);
|
|
104
|
+
const horizontal_offset = this.get_horizontal_correction(points, left_plane, right_plane, camera_quaternion);
|
|
105
105
|
|
|
106
106
|
target_pos.add(vertical_offset);
|
|
107
107
|
target_pos.add(horizontal_offset);
|
|
@@ -114,20 +114,20 @@ export default class PerspectiveFrustumPointFitter
|
|
|
114
114
|
// let closest_up_point = undefined;
|
|
115
115
|
// let closest_down_point = undefined;
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
const up_dir = new Vector3(0, 1, 0).applyQuaternion(camera_quaternion);
|
|
118
118
|
for (let i = 0; i < points.length; i++)
|
|
119
119
|
{
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
const down_line = new Line3(points[i].clone(), points[i].clone().add(up_dir.clone().multiplyScalar(-5000000)));
|
|
121
|
+
const up_line = new Line3(points[i].clone(), points[i].clone().add(up_dir.clone().multiplyScalar(5000000)));
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const down_line_intersection = new Vector3();
|
|
124
|
+
const up_line_intersection = new Vector3();
|
|
125
125
|
|
|
126
126
|
down_plane.intersectLine(down_line, down_line_intersection);
|
|
127
127
|
up_plane.intersectLine(up_line, up_line_intersection);
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
const down_dist = down_line_intersection.distanceTo(points[i]);
|
|
130
|
+
const up_dist = up_line_intersection.distanceTo(points[i]);
|
|
131
131
|
|
|
132
132
|
if (up_line_intersection.length() < 0.0001)
|
|
133
133
|
{
|
|
@@ -150,7 +150,7 @@ export default class PerspectiveFrustumPointFitter
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
const correction = (closest_distance_to_up_plane - closest_distance_to_down_plane) / 2;
|
|
154
154
|
|
|
155
155
|
// console.log("vertical_correction", correction)
|
|
156
156
|
return up_dir.clone().multiplyScalar(-correction);
|
|
@@ -163,21 +163,21 @@ export default class PerspectiveFrustumPointFitter
|
|
|
163
163
|
// let closest_right_point = undefined;
|
|
164
164
|
// let closest_left_point = undefined;
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
const right_dir = new Vector3(1, 0, 0).applyQuaternion(camera_quaternion);
|
|
167
167
|
|
|
168
168
|
for (let i = 0; i < points.length; i++)
|
|
169
169
|
{
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
const left_line = new Line3(points[i].clone(), points[i].clone().add(right_dir.clone().multiplyScalar(-5000000)));
|
|
171
|
+
const right_line = new Line3(points[i].clone(), points[i].clone().add(right_dir.clone().multiplyScalar(5000000)));
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
const left_line_intersection = new Vector3();
|
|
174
|
+
const right_line_intersection = new Vector3();
|
|
175
175
|
|
|
176
176
|
left_plane.intersectLine(left_line, left_line_intersection);
|
|
177
177
|
right_plane.intersectLine(right_line, right_line_intersection);
|
|
178
178
|
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
const left_dist = left_line_intersection.distanceTo(points[i]);
|
|
180
|
+
const right_dist = right_line_intersection.distanceTo(points[i]);
|
|
181
181
|
|
|
182
182
|
if (left_line_intersection.length() < 0.0001)
|
|
183
183
|
{
|
|
@@ -200,7 +200,7 @@ export default class PerspectiveFrustumPointFitter
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
const correction = (closest_distance_to_right_plane - closest_distance_to_left_plane) / 2;
|
|
204
204
|
// console.log("horizontal_correction", correction)
|
|
205
205
|
|
|
206
206
|
return right_dir.clone().multiplyScalar(-correction);
|
|
@@ -208,7 +208,7 @@ export default class PerspectiveFrustumPointFitter
|
|
|
208
208
|
|
|
209
209
|
get_up_plane_normal(camera_quaternion, v_fov)
|
|
210
210
|
{
|
|
211
|
-
|
|
211
|
+
const up_plane_normal = new Vector3(0, -1, 0);
|
|
212
212
|
up_plane_normal.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(1, 0, 0), v_fov));
|
|
213
213
|
up_plane_normal.applyQuaternion(camera_quaternion);
|
|
214
214
|
return up_plane_normal;
|
|
@@ -216,7 +216,7 @@ export default class PerspectiveFrustumPointFitter
|
|
|
216
216
|
|
|
217
217
|
get_down_plane_normal(camera_quaternion, v_fov)
|
|
218
218
|
{
|
|
219
|
-
|
|
219
|
+
const down_plane_normal = new Vector3(0, 1, 0);
|
|
220
220
|
down_plane_normal.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(1, 0, 0), -v_fov));
|
|
221
221
|
down_plane_normal.applyQuaternion(camera_quaternion);
|
|
222
222
|
return down_plane_normal;
|
|
@@ -224,7 +224,7 @@ export default class PerspectiveFrustumPointFitter
|
|
|
224
224
|
|
|
225
225
|
get_left_plane_normal(camera_quaternion, h_fov)
|
|
226
226
|
{
|
|
227
|
-
|
|
227
|
+
const left_plane_normal = new Vector3(1, 0, 0);
|
|
228
228
|
left_plane_normal.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(0, 1, 0), h_fov));
|
|
229
229
|
left_plane_normal.applyQuaternion(camera_quaternion);
|
|
230
230
|
return left_plane_normal;
|
|
@@ -232,7 +232,7 @@ export default class PerspectiveFrustumPointFitter
|
|
|
232
232
|
|
|
233
233
|
get_right_plane_normal(camera_quaternion, h_fov)
|
|
234
234
|
{
|
|
235
|
-
|
|
235
|
+
const right_plane_normal = new Vector3(-1, 0, 0);
|
|
236
236
|
right_plane_normal.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(0, 1, 0), -h_fov));
|
|
237
237
|
right_plane_normal.applyQuaternion(camera_quaternion);
|
|
238
238
|
return right_plane_normal;
|
|
@@ -240,11 +240,11 @@ export default class PerspectiveFrustumPointFitter
|
|
|
240
240
|
|
|
241
241
|
get_distance_to_fit_rect(width, height, vertical_fov, aspect)
|
|
242
242
|
{
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
const v_fov = (vertical_fov / 2) * Math.PI / 180;
|
|
244
|
+
const h_fov = (2 * Math.atan(Math.tan(v_fov) * aspect)) / 2;
|
|
245
245
|
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
const distV = height / Math.tan(v_fov);
|
|
247
|
+
const distH = width / Math.tan(h_fov);
|
|
248
248
|
return Math.max(Math.abs(distH), Math.abs(distV));
|
|
249
249
|
}
|
|
250
250
|
}
|
|
@@ -12,9 +12,9 @@ export default class ApplicationView extends ViewState
|
|
|
12
12
|
this.container = container;
|
|
13
13
|
this.url = url;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const transition_data = new DrawIOAnimationSheet().parse(ResourceContainer.get(`${name}_data`));
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const transitions = [
|
|
18
18
|
{
|
|
19
19
|
to: name,
|
|
20
20
|
data: transition_data
|
|
@@ -6,6 +6,7 @@ export default class ViewComponent
|
|
|
6
6
|
{
|
|
7
7
|
this.name = name;
|
|
8
8
|
this.container = container;
|
|
9
|
+
this.hidden = true;
|
|
9
10
|
|
|
10
11
|
ViewComponentManager.register_component(this);
|
|
11
12
|
}
|
|
@@ -18,6 +19,8 @@ export default class ViewComponent
|
|
|
18
19
|
{
|
|
19
20
|
this.container.classList.remove('hidden');
|
|
20
21
|
ViewComponentManager.enable_component(this);
|
|
22
|
+
|
|
23
|
+
this.hidden = false;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
update()
|
|
@@ -28,10 +31,31 @@ export default class ViewComponent
|
|
|
28
31
|
{
|
|
29
32
|
this.container.classList.add('hidden');
|
|
30
33
|
ViewComponentManager.disable_component(this);
|
|
34
|
+
|
|
35
|
+
this.hidden = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
set_opacity(current_state_data)
|
|
39
|
+
{
|
|
40
|
+
this.container.style.opacity = current_state_data[`${this.name}_opacity`];
|
|
41
|
+
this.toggle_hidden();
|
|
31
42
|
}
|
|
32
43
|
|
|
33
|
-
|
|
44
|
+
toggle_hidden()
|
|
34
45
|
{
|
|
35
|
-
this.container.style.opacity
|
|
46
|
+
if (this.container.style.opacity > 0.001)
|
|
47
|
+
{
|
|
48
|
+
if (this.hidden)
|
|
49
|
+
{
|
|
50
|
+
this.on_enter();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
{
|
|
55
|
+
if (!this.hidden)
|
|
56
|
+
{
|
|
57
|
+
this.on_exit();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
36
60
|
}
|
|
37
61
|
}
|
|
@@ -10,7 +10,9 @@ class ViewComponentManager
|
|
|
10
10
|
|
|
11
11
|
update()
|
|
12
12
|
{
|
|
13
|
-
|
|
13
|
+
this.__set_components_opacities();
|
|
14
|
+
|
|
15
|
+
for (const component of this.enabled_components)
|
|
14
16
|
{
|
|
15
17
|
component.update(ViewManager.transition_handler.current_state_data);
|
|
16
18
|
}
|
|
@@ -53,6 +55,14 @@ class ViewComponentManager
|
|
|
53
55
|
console.error('[ViewComponentManager.get] no component found for: ', component_name);
|
|
54
56
|
return undefined;
|
|
55
57
|
}
|
|
58
|
+
|
|
59
|
+
__set_components_opacities()
|
|
60
|
+
{
|
|
61
|
+
for (let i = 0; i < this.components.length; i++)
|
|
62
|
+
{
|
|
63
|
+
this.components[i].set_opacity(ViewManager.transition_handler.current_state_data);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
export default new ViewComponentManager();
|
|
@@ -9,6 +9,8 @@ class ViewManager
|
|
|
9
9
|
|
|
10
10
|
this.transition_table = new TransitionTable();
|
|
11
11
|
this.transition_handler = new ViewStateTransitionHandler(this.transition_table);
|
|
12
|
+
|
|
13
|
+
this.view_change_subscribers = [];
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
update()
|
|
@@ -20,13 +22,29 @@ class ViewManager
|
|
|
20
22
|
|
|
21
23
|
go_to_view(view_name, change_url = true, skip = false)
|
|
22
24
|
{
|
|
23
|
-
|
|
25
|
+
const v = this.get(view_name);
|
|
24
26
|
this.transition_handler.go_to_state(v, skip);
|
|
25
27
|
|
|
26
28
|
if (change_url)
|
|
27
29
|
{
|
|
28
30
|
this.__change_browser_url(v.url);
|
|
29
31
|
}
|
|
32
|
+
|
|
33
|
+
this.notify_view_change(view_name);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
subscribe_to_view_change(subscriber)
|
|
37
|
+
{
|
|
38
|
+
this.view_change_subscribers.push(subscriber);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
notify_view_change(view_name)
|
|
42
|
+
{
|
|
43
|
+
for (let i = 0; i < this.view_change_subscribers.length; i++)
|
|
44
|
+
{
|
|
45
|
+
const subscriber = this.view_change_subscribers[i];
|
|
46
|
+
subscriber.on_view_change(view_name);
|
|
47
|
+
}
|
|
30
48
|
}
|
|
31
49
|
|
|
32
50
|
register_view(view)
|
|
@@ -58,7 +76,7 @@ class ViewManager
|
|
|
58
76
|
|
|
59
77
|
set_view(view_name)
|
|
60
78
|
{
|
|
61
|
-
|
|
79
|
+
const view = this.get(view_name);
|
|
62
80
|
|
|
63
81
|
this.transition_handler.set_state(view);
|
|
64
82
|
}
|