ohzi-core 6.2.3 → 6.2.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.
Files changed (98) hide show
  1. package/build/index.module.js +1 -1
  2. package/build/index.module.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/CustomBezierCurve.js +2 -2
  5. package/src/Debug.js +28 -28
  6. package/src/EventManager.js +1 -1
  7. package/src/Graphics.js +12 -12
  8. package/src/KeyboardInput.js +1 -1
  9. package/src/OS.js +5 -5
  10. package/src/UI.js +1 -1
  11. package/src/action_sequencer/ActionSequencer.js +12 -12
  12. package/src/action_sequencer/VectorInterpolator.js +1 -1
  13. package/src/canvas_drawer/CanvasDrawer.js +8 -8
  14. package/src/canvas_drawer/MultiLineTextDrawer.js +3 -3
  15. package/src/canvas_drawer/SimpleTextDrawer.js +1 -1
  16. package/src/components/EdgeMesh.js +17 -17
  17. package/src/components/GeometryEdgeVisualizer.js +1 -1
  18. package/src/components/Grid.js +3 -3
  19. package/src/components/Line.js +16 -16
  20. package/src/components/MultiLinePath.js +1 -1
  21. package/src/components/MultiLineText2D.js +1 -1
  22. package/src/components/ObjectAxis.js +3 -3
  23. package/src/components/ObjectOrientedBoundingBox.js +19 -19
  24. package/src/components/Shape2D.js +7 -7
  25. package/src/components/Shape3D.js +5 -5
  26. package/src/components/Text2D.js +3 -3
  27. package/src/components/UIElement.js +2 -2
  28. package/src/components/UpdatableMaterialMesh.js +1 -1
  29. package/src/components/WorldImage.js +4 -4
  30. package/src/components/mouse_interactors/ObjectRotator.js +2 -2
  31. package/src/components/sdf_text/SDFText.js +10 -10
  32. package/src/components/sdf_text/SDFTextBatch.js +24 -24
  33. package/src/components/sdf_text/TextGlyph.js +2 -2
  34. package/src/data_textures/RGBADataTexture.js +1 -1
  35. package/src/data_textures/RGBAFloatDataTexture.js +1 -1
  36. package/src/data_textures/RGBDataTexture.js +1 -1
  37. package/src/data_textures/RGBFloatDataTexture.js +1 -1
  38. package/src/editor/ManipulatorHandle.js +4 -4
  39. package/src/editor/ObjectEditor.js +2 -2
  40. package/src/editor/ObjectManipulator.js +3 -3
  41. package/src/gpu_particles/GPUParticleSystem.js +4 -4
  42. package/src/gpu_particles/ParticleAttribute.js +4 -4
  43. package/src/gpu_particles/ParticlePositionAttribute.js +2 -2
  44. package/src/materials/MedianFilterMaterial.js +1 -1
  45. package/src/materials/SSAOMaterial.js +5 -5
  46. package/src/materials/ScreenSpaceTextureMaterial.js +2 -2
  47. package/src/materials/UnrealBloomComposeMaterial.js +1 -1
  48. package/src/materials/UnrealBlurMaterial.js +1 -1
  49. package/src/materials/UnrealComposeMaterial.js +1 -1
  50. package/src/object_pool/Pool.js +3 -3
  51. package/src/primitives/Arrow.js +6 -6
  52. package/src/primitives/Cube.js +2 -2
  53. package/src/primitives/HorizontalPlane.js +1 -1
  54. package/src/primitives/Sphere.js +2 -2
  55. package/src/primitives/VerticalPlane.js +1 -1
  56. package/src/render_mode/DeferredRender.js +10 -10
  57. package/src/render_mode/PlanarReflectionsRender.js +3 -3
  58. package/src/render_mode/TransparencyMixRender.js +1 -1
  59. package/src/render_utilities/Blitter.js +7 -7
  60. package/src/render_utilities/GaussianBlurrer.js +3 -3
  61. package/src/render_utilities/MedianFilter.js +1 -1
  62. package/src/resource_loader/AbstractLoader.js +1 -1
  63. package/src/resource_loader/BasisLoader.js +1 -1
  64. package/src/resource_loader/CubemapLoader.js +1 -1
  65. package/src/resource_loader/DAELoader.js +1 -1
  66. package/src/resource_loader/DDSLoader.js +1 -1
  67. package/src/resource_loader/FileLoader.js +1 -1
  68. package/src/resource_loader/FontLoader.js +1 -1
  69. package/src/resource_loader/GLTFDRACOLoader.js +1 -1
  70. package/src/resource_loader/GLTFLoader.js +1 -1
  71. package/src/resource_loader/HDRCubeTextureLoader.js +1 -1
  72. package/src/resource_loader/JSONLoader.js +1 -1
  73. package/src/resource_loader/OBJLoader.js +1 -1
  74. package/src/resource_loader/PointArrayLoader.js +6 -6
  75. package/src/resource_loader/RGBETextureLoader.js +1 -1
  76. package/src/resource_loader/SVGLoader.js +1 -1
  77. package/src/resource_loader/TextLoader.js +1 -1
  78. package/src/static_batcher/GeometryBatch.js +20 -20
  79. package/src/static_batcher/GeometryBatcher.js +7 -7
  80. package/src/static_batcher/MeshBatcher.js +8 -8
  81. package/src/utilities/ArrayUtilities.js +4 -4
  82. package/src/utilities/CameraUtilities.js +24 -24
  83. package/src/utilities/EasingFunctions.js +19 -8
  84. package/src/utilities/FrustumPointFitter.js +55 -55
  85. package/src/utilities/GeometryUtilities.js +7 -7
  86. package/src/utilities/ImageUtilities.js +4 -4
  87. package/src/utilities/MeshSampler.js +33 -33
  88. package/src/utilities/ModelUtilities.js +2 -2
  89. package/src/utilities/OMath.js +4 -4
  90. package/src/utilities/ObjectUtilities.js +4 -4
  91. package/src/utilities/OrthographicFrustumPointFitter.js +10 -10
  92. package/src/utilities/PerspectiveFrustumPointFitter.js +55 -55
  93. package/src/view_components/ApplicationView.js +2 -2
  94. package/src/view_components/ViewComponentManager.js +1 -1
  95. package/src/view_components/ViewManager.js +2 -2
  96. package/src/view_components/transition/ActionSequencerBuilder.js +18 -18
  97. package/src/view_components/transition/DrawIOAnimationSheet.js +20 -20
  98. package/src/view_components/transition/TransitionTable.js +1 -1
@@ -14,8 +14,8 @@ class GeometryBatcher
14
14
 
15
15
  batch(buffer_geometries)
16
16
  {
17
- let attr_accessor_uvs = [];
18
- let texture_width = TMath.ceilPowerOfTwo(Math.sqrt(buffer_geometries.length));
17
+ const attr_accessor_uvs = [];
18
+ const texture_width = TMath.ceilPowerOfTwo(Math.sqrt(buffer_geometries.length));
19
19
  // console.log("Store count: " + buffer_geometries.length + ", Texture size: " +texture_width);
20
20
 
21
21
  this.__init_uv_array(attr_accessor_uvs, texture_width);
@@ -24,9 +24,9 @@ class GeometryBatcher
24
24
 
25
25
  for (let i = 0; i < buffer_geometries.length; i++)
26
26
  {
27
- let vertex_count = buffer_geometries[i].getAttribute('position').count;
28
- let y = Math.floor(i / texture_width);
29
- let x = i - texture_width * y;
27
+ const vertex_count = buffer_geometries[i].getAttribute('position').count;
28
+ const y = Math.floor(i / texture_width);
29
+ const x = i - texture_width * y;
30
30
  for (let count = 0; count < vertex_count; count++)
31
31
  {
32
32
  attr_accessor_uvs[uv_index] = (x / texture_width) + 0.5 / texture_width;
@@ -35,8 +35,8 @@ class GeometryBatcher
35
35
  }
36
36
  }
37
37
 
38
- let buffer_attribute = new BufferAttribute(new Float32Array(attr_accessor_uvs), 2);
39
- let buffer_geometry = BufferGeometryUtils.mergeBufferGeometries(buffer_geometries);
38
+ const buffer_attribute = new BufferAttribute(new Float32Array(attr_accessor_uvs), 2);
39
+ const buffer_geometry = BufferGeometryUtils.mergeBufferGeometries(buffer_geometries);
40
40
  buffer_geometry.setAttribute('attr_accessor_uv', buffer_attribute);
41
41
 
42
42
  this.batches.push(new GeometryBatch(buffer_geometry, texture_width));
@@ -8,21 +8,21 @@ export default class MeshBatcher
8
8
  {
9
9
  batch(meshes, material)
10
10
  {
11
- let max_texture_width = 2048;
11
+ const max_texture_width = 2048;
12
12
  // let texture_width = meshes.length % max_texture_width;
13
13
  // let texture_height = Math.ceil(meshes.length / max_texture_width);
14
14
 
15
15
  // console.log("Store count: " + buffer_geometries.length + ", Texture size: " +texture_width);
16
16
 
17
- let geometries = [];
18
- let id_table = {};
17
+ const geometries = [];
18
+ const id_table = {};
19
19
 
20
- let attr_mesh_id = [];
20
+ const attr_mesh_id = [];
21
21
 
22
22
  for (let i = 0; i < meshes.length; i++)
23
23
  {
24
- let mesh = meshes[i];
25
- let vertex_count = mesh.geometry.getAttribute('position').count;
24
+ const mesh = meshes[i];
25
+ const vertex_count = mesh.geometry.getAttribute('position').count;
26
26
 
27
27
  for (let count = 0; count < vertex_count; count++)
28
28
  {
@@ -41,9 +41,9 @@ export default class MeshBatcher
41
41
  }
42
42
  }
43
43
 
44
- let buffer_geometry = BufferGeometryUtils.mergeBufferGeometries(geometries);
44
+ const buffer_geometry = BufferGeometryUtils.mergeBufferGeometries(geometries);
45
45
 
46
- let buffer_attribute = new BufferAttribute(new Float32Array(attr_mesh_id), 1);
46
+ const buffer_attribute = new BufferAttribute(new Float32Array(attr_mesh_id), 1);
47
47
  buffer_geometry.setAttribute('mesh_id', buffer_attribute);
48
48
 
49
49
  return this.create_batched_mesh(id_table, buffer_geometry, material, max_texture_width);
@@ -10,7 +10,7 @@ export default class ArrayUtilities
10
10
 
11
11
  static expand_vec3_array(array, size)
12
12
  {
13
- let items_left_count = size - array.length;
13
+ const items_left_count = size - array.length;
14
14
 
15
15
  for (let i = 0; i < items_left_count; i++)
16
16
  {
@@ -20,7 +20,7 @@ export default class ArrayUtilities
20
20
 
21
21
  static remove_elem(array, elem)
22
22
  {
23
- let index = array.indexOf(elem);
23
+ const index = array.indexOf(elem);
24
24
  if (index > -1)
25
25
  {
26
26
  array.splice(index, 1);
@@ -44,8 +44,8 @@ export default class ArrayUtilities
44
44
 
45
45
  static object_values_to_array(obj)
46
46
  {
47
- let ids = Object.keys(obj);
48
- let arr = [];
47
+ const ids = Object.keys(obj);
48
+ const arr = [];
49
49
  for (let i = 0; i < ids.length; i++)
50
50
  {
51
51
  arr.push(obj[ids[i]]);
@@ -59,11 +59,11 @@ class CameraUtilities
59
59
  camera = camera || CameraManager.current;
60
60
  const tmp_vec = new Vector3();
61
61
 
62
- let v_fov = (camera.fov / 2) * Math.PI / 180;
63
- let h_fov = (2 * Math.atan(Math.tan(v_fov) * camera.aspect)) / 2;
62
+ const v_fov = (camera.fov / 2) * Math.PI / 180;
63
+ const h_fov = (2 * Math.atan(Math.tan(v_fov) * camera.aspect)) / 2;
64
64
 
65
- let distV = Math.tan(v_fov) * camera.far;
66
- let distH = Math.tan(h_fov) * camera.far;
65
+ const distV = Math.tan(v_fov) * camera.far;
66
+ const distH = Math.tan(h_fov) * camera.far;
67
67
 
68
68
  tmp_vec.set(distH * NDC.x, distV * NDC.y, -camera.far).normalize();
69
69
 
@@ -94,36 +94,36 @@ class CameraUtilities
94
94
 
95
95
  fit_points_on_camera(points, zoom_scale = 1)
96
96
  {
97
- let points_sphere = new Sphere().setFromPoints(points);
98
- let world_space_center = points_sphere.center;
99
- let camera_forward = this.get_forward_dir(CameraManager.current).clone();
97
+ const points_sphere = new Sphere().setFromPoints(points);
98
+ const world_space_center = points_sphere.center;
99
+ const camera_forward = this.get_forward_dir(CameraManager.current).clone();
100
100
 
101
- let plane = new Plane().setFromNormalAndCoplanarPoint(camera_forward, world_space_center);
101
+ const plane = new Plane().setFromNormalAndCoplanarPoint(camera_forward, world_space_center);
102
102
 
103
- let points_on_plane = OMath.project_points_on_plane(points, plane);
103
+ const points_on_plane = OMath.project_points_on_plane(points, plane);
104
104
 
105
- let projected_points_center = new Vector3();
105
+ const projected_points_center = new Vector3();
106
106
  let box = new Box3().setFromPoints(points_on_plane);
107
107
  box.getCenter(projected_points_center);
108
108
 
109
- let up = new Vector3(0, 1, 0).applyQuaternion(CameraManager.current.quaternion);
110
- let right = up.clone().cross(camera_forward).normalize();
111
- let mat = new Matrix4().set(right.x, up.x, camera_forward.x, world_space_center.x,
109
+ const up = new Vector3(0, 1, 0).applyQuaternion(CameraManager.current.quaternion);
110
+ const right = up.clone().cross(camera_forward).normalize();
111
+ const mat = new Matrix4().set(right.x, up.x, camera_forward.x, world_space_center.x,
112
112
  right.y, up.y, camera_forward.y, world_space_center.y,
113
113
  right.z, up.z, camera_forward.z, world_space_center.z,
114
114
  0, 0, 0, 1);
115
115
 
116
- let inverse_mat = new Matrix4().getInverse(mat);
116
+ const inverse_mat = new Matrix4().getInverse(mat);
117
117
  for (let i = 0; i < points_on_plane.length; i++)
118
118
  {
119
119
  points_on_plane[i].applyMatrix4(inverse_mat);
120
120
  }
121
121
 
122
- let size = new Vector3();
122
+ const size = new Vector3();
123
123
  box = new Box3().setFromPoints(points_on_plane);
124
124
  box.getSize(size);
125
125
  size.multiplyScalar(zoom_scale);
126
- let projected_center = new Vector3();
126
+ const projected_center = new Vector3();
127
127
  box.getCenter(projected_center);
128
128
 
129
129
  return {
@@ -134,11 +134,11 @@ class CameraUtilities
134
134
 
135
135
  get_zoom_to_fit_rect(width, height)
136
136
  {
137
- let v_fov = (CameraManager.current.fov / 2) * Math.PI / 180;
138
- let h_fov = (2 * Math.atan(Math.tan(v_fov) * CameraManager.current.aspect)) / 2;
137
+ const v_fov = (CameraManager.current.fov / 2) * Math.PI / 180;
138
+ const h_fov = (2 * Math.atan(Math.tan(v_fov) * CameraManager.current.aspect)) / 2;
139
139
 
140
- let distV = height / Math.tan(v_fov);
141
- let distH = width / Math.tan(h_fov);
140
+ const distV = height / Math.tan(v_fov);
141
+ const distH = width / Math.tan(h_fov);
142
142
 
143
143
  return Math.max(Math.abs(distH), Math.abs(distV));
144
144
  }
@@ -149,9 +149,9 @@ class CameraUtilities
149
149
  {
150
150
  bb.getSize(this.tmp_size);
151
151
 
152
- let obj_x = this.tmp_size.x;
153
- let obj_y = this.tmp_size.y;
154
- let object_aspect = obj_x / obj_y;
152
+ const obj_x = this.tmp_size.x;
153
+ const obj_y = this.tmp_size.y;
154
+ const object_aspect = obj_x / obj_y;
155
155
  if (Screen.aspect_ratio / object_aspect > 1)
156
156
  {
157
157
  return Screen.height / obj_y;
@@ -164,7 +164,7 @@ class CameraUtilities
164
164
  else
165
165
  {
166
166
  // return this.fit_points_on_camera([bb.min, bb.max], 1).zoom;
167
- let size = new Vector3();
167
+ const size = new Vector3();
168
168
  bb.getSize(size);
169
169
  return this.get_zoom_to_fit_rect(size.x, size.y);
170
170
  }
@@ -108,9 +108,13 @@ class EasingFunctions
108
108
 
109
109
  ease_in_out_expo(x)
110
110
  {
111
- return x === 0 ? 0 : x === 1 ? 1 : x < 0.5
112
- ? Math.pow(2, 20 * x - 10) / 2
113
- : (2 - Math.pow(2, -20 * x + 10)) / 2;
111
+ return x === 0
112
+ ? 0
113
+ : x === 1
114
+ ? 1
115
+ : x < 0.5
116
+ ? Math.pow(2, 20 * x - 10) / 2
117
+ : (2 - Math.pow(2, -20 * x + 10)) / 2;
114
118
  }
115
119
 
116
120
  ease_in_circ(x)
@@ -160,15 +164,22 @@ class EasingFunctions
160
164
 
161
165
  ease_out_elastic(x)
162
166
  {
163
- return x === 0 ? 0 : x === 1 ? 1
164
- : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * 2.0943950) + 1;
167
+ return x === 0
168
+ ? 0
169
+ : x === 1
170
+ ? 1
171
+ : Math.pow(2, -10 * x) * Math.sin((x * 10 - 0.75) * 2.0943950) + 1;
165
172
  }
166
173
 
167
174
  ease_in_out_elastic(x)
168
175
  {
169
- return x === 0 ? 0 : x === 1 ? 1 : x < 0.5
170
- ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * 1.3962633)) / 2
171
- : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * 1.3962633) / 2 + 1;
176
+ return x === 0
177
+ ? 0
178
+ : x === 1
179
+ ? 1
180
+ : x < 0.5
181
+ ? -(Math.pow(2, 20 * x - 10) * Math.sin((20 * x - 11.125) * 1.3962633)) / 2
182
+ : Math.pow(2, -20 * x + 10) * Math.sin((20 * x - 11.125) * 1.3962633) / 2 + 1;
172
183
  }
173
184
 
174
185
  ease_in_bounce(x)
@@ -11,26 +11,26 @@ export default class FrustumPointFitter
11
11
  {
12
12
  this.sphere.setFromPoints(points);
13
13
 
14
- let v_fov = Math.degToRad(vertical_fov / 2);
15
- let h_fov = (2 * Math.atan(Math.tan(v_fov) * aspect)) / 2;
14
+ const v_fov = Math.degToRad(vertical_fov / 2);
15
+ const h_fov = (2 * Math.atan(Math.tan(v_fov) * aspect)) / 2;
16
16
 
17
- let up_plane_normal = this.get_up_plane_normal(camera_quaternion, v_fov);
18
- let down_plane_normal = this.get_down_plane_normal(camera_quaternion, v_fov);
19
- let left_plane_normal = this.get_left_plane_normal(camera_quaternion, h_fov);
20
- let right_plane_normal = this.get_right_plane_normal(camera_quaternion, h_fov);
17
+ const up_plane_normal = this.get_up_plane_normal(camera_quaternion, v_fov);
18
+ const down_plane_normal = this.get_down_plane_normal(camera_quaternion, v_fov);
19
+ const left_plane_normal = this.get_left_plane_normal(camera_quaternion, h_fov);
20
+ const right_plane_normal = this.get_right_plane_normal(camera_quaternion, h_fov);
21
21
 
22
- let camera_forward_dir = new Vector3(0, 0, -1).applyQuaternion(camera_quaternion);
22
+ const camera_forward_dir = new Vector3(0, 0, -1).applyQuaternion(camera_quaternion);
23
23
 
24
- let sphere_center = this.sphere.center.clone();
24
+ const sphere_center = this.sphere.center.clone();
25
25
 
26
- let pull_back_distance = this.get_distance_to_fit_rect(this.sphere.radius * 2, this.sphere.radius * 2, vertical_fov, aspect);
27
- let far_pos = sphere_center.clone().add(camera_forward_dir.clone().multiplyScalar(pull_back_distance * -1));
26
+ const pull_back_distance = this.get_distance_to_fit_rect(this.sphere.radius * 2, this.sphere.radius * 2, vertical_fov, aspect);
27
+ const far_pos = sphere_center.clone().add(camera_forward_dir.clone().multiplyScalar(pull_back_distance * -1));
28
28
 
29
- let up_plane = new Plane().setFromNormalAndCoplanarPoint(up_plane_normal, far_pos);
30
- let down_plane = new Plane().setFromNormalAndCoplanarPoint(down_plane_normal, far_pos);
29
+ const up_plane = new Plane().setFromNormalAndCoplanarPoint(up_plane_normal, far_pos);
30
+ const down_plane = new Plane().setFromNormalAndCoplanarPoint(down_plane_normal, far_pos);
31
31
 
32
- let left_plane = new Plane().setFromNormalAndCoplanarPoint(left_plane_normal, far_pos);
33
- let right_plane = new Plane().setFromNormalAndCoplanarPoint(right_plane_normal, far_pos);
32
+ const left_plane = new Plane().setFromNormalAndCoplanarPoint(left_plane_normal, far_pos);
33
+ const right_plane = new Plane().setFromNormalAndCoplanarPoint(right_plane_normal, far_pos);
34
34
 
35
35
  this.apply_center_correction_to_pos(far_pos, points, camera_quaternion, up_plane, down_plane, left_plane, right_plane);
36
36
 
@@ -42,16 +42,16 @@ export default class FrustumPointFitter
42
42
 
43
43
  let closest_distance = Infinity;
44
44
 
45
- let inverse_dir = camera_forward_dir.clone().multiplyScalar(pull_back_distance * -2);
45
+ const inverse_dir = camera_forward_dir.clone().multiplyScalar(pull_back_distance * -2);
46
46
  for (let i = 0; i < points.length; i++)
47
47
  {
48
- let line = new Line3(points[i].clone(), points[i].clone().add(inverse_dir));
48
+ const line = new Line3(points[i].clone(), points[i].clone().add(inverse_dir));
49
49
 
50
- let up_line_intersection = new Vector3();
51
- let down_line_intersection = new Vector3();
50
+ const up_line_intersection = new Vector3();
51
+ const down_line_intersection = new Vector3();
52
52
 
53
- let left_line_intersection = new Vector3();
54
- let right_line_intersection = new Vector3();
53
+ const left_line_intersection = new Vector3();
54
+ const right_line_intersection = new Vector3();
55
55
 
56
56
  up_plane.intersectLine(line, up_line_intersection);
57
57
  down_plane.intersectLine(line, down_line_intersection);
@@ -76,16 +76,16 @@ export default class FrustumPointFitter
76
76
  console.log('right intersection not found', i);
77
77
  }
78
78
 
79
- let new_up_distance = points[i].clone().sub(up_line_intersection).length();
80
- let new_down_distance = points[i].clone().sub(down_line_intersection).length();
79
+ const new_up_distance = points[i].clone().sub(up_line_intersection).length();
80
+ const new_down_distance = points[i].clone().sub(down_line_intersection).length();
81
81
 
82
- let new_left_distance = points[i].clone().sub(left_line_intersection).length();
83
- let new_right_distance = points[i].clone().sub(right_line_intersection).length();
82
+ const new_left_distance = points[i].clone().sub(left_line_intersection).length();
83
+ const new_right_distance = points[i].clone().sub(right_line_intersection).length();
84
84
 
85
- let vertical_min = Math.min(new_up_distance, new_down_distance);
86
- let horizontal_min = Math.min(new_left_distance, new_right_distance);
85
+ const vertical_min = Math.min(new_up_distance, new_down_distance);
86
+ const horizontal_min = Math.min(new_left_distance, new_right_distance);
87
87
 
88
- let min = Math.min(vertical_min, horizontal_min);
88
+ const min = Math.min(vertical_min, horizontal_min);
89
89
 
90
90
  if (min < closest_distance)
91
91
  {
@@ -93,16 +93,16 @@ export default class FrustumPointFitter
93
93
  }
94
94
  }
95
95
 
96
- let forward_correction = camera_forward_dir.clone().multiplyScalar(closest_distance);
97
- let closest_position = far_pos.clone().add(forward_correction);
96
+ const forward_correction = camera_forward_dir.clone().multiplyScalar(closest_distance);
97
+ const closest_position = far_pos.clone().add(forward_correction);
98
98
 
99
99
  return closest_position;
100
100
  }
101
101
 
102
102
  apply_center_correction_to_pos(target_pos, points, camera_quaternion, up_plane, down_plane, left_plane, right_plane)
103
103
  {
104
- let vertical_offset = this.get_vertical_correction(points, down_plane, up_plane, camera_quaternion);
105
- let horizontal_offset = this.get_hozirontal_correction(points, left_plane, right_plane, camera_quaternion);
104
+ const vertical_offset = this.get_vertical_correction(points, down_plane, up_plane, camera_quaternion);
105
+ const horizontal_offset = this.get_hozirontal_correction(points, left_plane, right_plane, camera_quaternion);
106
106
 
107
107
  target_pos.add(vertical_offset);
108
108
  target_pos.add(horizontal_offset);
@@ -115,20 +115,20 @@ export default class FrustumPointFitter
115
115
  let closest_up_point = undefined;
116
116
  let closest_down_point = undefined;
117
117
 
118
- let up_dir = new Vector3(0, 1, 0).applyQuaternion(camera_quaternion);
118
+ const up_dir = new Vector3(0, 1, 0).applyQuaternion(camera_quaternion);
119
119
  for (let i = 0; i < points.length; i++)
120
120
  {
121
- let down_line = new Line3(points[i].clone(), points[i].clone().add(up_dir.clone().multiplyScalar(-5000000)));
122
- let up_line = new Line3(points[i].clone(), points[i].clone().add(up_dir.clone().multiplyScalar(5000000)));
121
+ const down_line = new Line3(points[i].clone(), points[i].clone().add(up_dir.clone().multiplyScalar(-5000000)));
122
+ const up_line = new Line3(points[i].clone(), points[i].clone().add(up_dir.clone().multiplyScalar(5000000)));
123
123
 
124
- let down_line_intersection = new Vector3();
125
- let up_line_intersection = new Vector3();
124
+ const down_line_intersection = new Vector3();
125
+ const up_line_intersection = new Vector3();
126
126
 
127
127
  down_plane.intersectLine(down_line, down_line_intersection);
128
128
  up_plane.intersectLine(up_line, up_line_intersection);
129
129
 
130
- let down_dist = down_line_intersection.distanceTo(points[i]);
131
- let up_dist = up_line_intersection.distanceTo(points[i]);
130
+ const down_dist = down_line_intersection.distanceTo(points[i]);
131
+ const up_dist = up_line_intersection.distanceTo(points[i]);
132
132
 
133
133
  if (up_line_intersection.length() < 0.0001)
134
134
  {
@@ -153,7 +153,7 @@ export default class FrustumPointFitter
153
153
 
154
154
  console.log(closest_up_point, closest_down_point);
155
155
 
156
- let correction = (closest_distance_to_up_plane - closest_distance_to_down_plane) / 2;
156
+ const correction = (closest_distance_to_up_plane - closest_distance_to_down_plane) / 2;
157
157
 
158
158
  // console.log("vertical_correction", correction)
159
159
  return up_dir.clone().multiplyScalar(-correction);
@@ -166,21 +166,21 @@ export default class FrustumPointFitter
166
166
  let closest_right_point = undefined;
167
167
  let closest_left_point = undefined;
168
168
 
169
- let right_dir = new Vector3(1, 0, 0).applyQuaternion(camera_quaternion);
169
+ const right_dir = new Vector3(1, 0, 0).applyQuaternion(camera_quaternion);
170
170
 
171
171
  for (let i = 0; i < points.length; i++)
172
172
  {
173
- let left_line = new Line3(points[i].clone(), points[i].clone().add(right_dir.clone().multiplyScalar(-5000000)));
174
- let right_line = new Line3(points[i].clone(), points[i].clone().add(right_dir.clone().multiplyScalar(5000000)));
173
+ const left_line = new Line3(points[i].clone(), points[i].clone().add(right_dir.clone().multiplyScalar(-5000000)));
174
+ const right_line = new Line3(points[i].clone(), points[i].clone().add(right_dir.clone().multiplyScalar(5000000)));
175
175
 
176
- let left_line_intersection = new Vector3();
177
- let right_line_intersection = new Vector3();
176
+ const left_line_intersection = new Vector3();
177
+ const right_line_intersection = new Vector3();
178
178
 
179
179
  left_plane.intersectLine(left_line, left_line_intersection);
180
180
  right_plane.intersectLine(right_line, right_line_intersection);
181
181
 
182
- let left_dist = left_line_intersection.distanceTo(points[i]);
183
- let right_dist = right_line_intersection.distanceTo(points[i]);
182
+ const left_dist = left_line_intersection.distanceTo(points[i]);
183
+ const right_dist = right_line_intersection.distanceTo(points[i]);
184
184
 
185
185
  if (left_line_intersection.length() < 0.0001)
186
186
  {
@@ -203,7 +203,7 @@ export default class FrustumPointFitter
203
203
  }
204
204
  }
205
205
 
206
- let correction = (closest_distance_to_right_plane - closest_distance_to_left_plane) / 2;
206
+ const correction = (closest_distance_to_right_plane - closest_distance_to_left_plane) / 2;
207
207
  // console.log("horizontal_correction", correction)
208
208
 
209
209
  console.log(closest_right_point, closest_left_point);
@@ -213,7 +213,7 @@ export default class FrustumPointFitter
213
213
 
214
214
  get_up_plane_normal(camera_quaternion, v_fov)
215
215
  {
216
- let up_plane_normal = new Vector3(0, -1, 0);
216
+ const up_plane_normal = new Vector3(0, -1, 0);
217
217
  up_plane_normal.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(1, 0, 0), v_fov));
218
218
  up_plane_normal.applyQuaternion(camera_quaternion);
219
219
  return up_plane_normal;
@@ -221,7 +221,7 @@ export default class FrustumPointFitter
221
221
 
222
222
  get_down_plane_normal(camera_quaternion, v_fov)
223
223
  {
224
- let down_plane_normal = new Vector3(0, 1, 0);
224
+ const down_plane_normal = new Vector3(0, 1, 0);
225
225
  down_plane_normal.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(1, 0, 0), -v_fov));
226
226
  down_plane_normal.applyQuaternion(camera_quaternion);
227
227
  return down_plane_normal;
@@ -229,7 +229,7 @@ export default class FrustumPointFitter
229
229
 
230
230
  get_left_plane_normal(camera_quaternion, h_fov)
231
231
  {
232
- let left_plane_normal = new Vector3(1, 0, 0);
232
+ const left_plane_normal = new Vector3(1, 0, 0);
233
233
  left_plane_normal.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(0, 1, 0), h_fov));
234
234
  left_plane_normal.applyQuaternion(camera_quaternion);
235
235
  return left_plane_normal;
@@ -237,7 +237,7 @@ export default class FrustumPointFitter
237
237
 
238
238
  get_right_plane_normal(camera_quaternion, h_fov)
239
239
  {
240
- let right_plane_normal = new Vector3(-1, 0, 0);
240
+ const right_plane_normal = new Vector3(-1, 0, 0);
241
241
  right_plane_normal.applyQuaternion(new Quaternion().setFromAxisAngle(new Vector3(0, 1, 0), -h_fov));
242
242
  right_plane_normal.applyQuaternion(camera_quaternion);
243
243
  return right_plane_normal;
@@ -245,11 +245,11 @@ export default class FrustumPointFitter
245
245
 
246
246
  get_distance_to_fit_rect(width, height, vertical_fov, aspect)
247
247
  {
248
- let v_fov = (vertical_fov / 2) * Math.PI / 180;
249
- let h_fov = (2 * Math.atan(Math.tan(v_fov) * aspect)) / 2;
248
+ const v_fov = (vertical_fov / 2) * Math.PI / 180;
249
+ const h_fov = (2 * Math.atan(Math.tan(v_fov) * aspect)) / 2;
250
250
 
251
- let distV = height / Math.tan(v_fov);
252
- let distH = width / Math.tan(h_fov);
251
+ const distV = height / Math.tan(v_fov);
252
+ const distH = width / Math.tan(h_fov);
253
253
  return Math.max(Math.abs(distH), Math.abs(distV));
254
254
  }
255
255
  }
@@ -5,11 +5,11 @@ export default class GeometryUtilities
5
5
  {
6
6
  static convert_to_non_indexed_geometry(geometry_buffer)
7
7
  {
8
- let indices = geometry_buffer.index;
9
- let positions = geometry_buffer.getAttribute('position');
8
+ const indices = geometry_buffer.index;
9
+ const positions = geometry_buffer.getAttribute('position');
10
10
 
11
- let bar_coordinates = [];
12
- let vertices = [];
11
+ const bar_coordinates = [];
12
+ const vertices = [];
13
13
 
14
14
  for (let i = 0; i < indices.count; i += 3)
15
15
  {
@@ -43,7 +43,7 @@ export default class GeometryUtilities
43
43
  bar_coordinates.push(1);
44
44
  }
45
45
 
46
- let geometry = new BufferGeometry();
46
+ const geometry = new BufferGeometry();
47
47
  // geometry.setAttribute('barycentric', new BufferAttribute( new Float32Array(bar_coordinates), 3 ));
48
48
  geometry.setAttribute('position', new BufferAttribute(new Float32Array(vertices), 3));
49
49
  GeometryUtilities.add_barycentric_attribute(geometry);
@@ -52,8 +52,8 @@ export default class GeometryUtilities
52
52
 
53
53
  static add_barycentric_attribute(non_indexed_geometry_buffer)
54
54
  {
55
- let bar_coordinates = [];
56
- let positions = non_indexed_geometry_buffer.getAttribute('position');
55
+ const bar_coordinates = [];
56
+ const positions = non_indexed_geometry_buffer.getAttribute('position');
57
57
 
58
58
  for (let i = 0; i < positions.count; i += 3)
59
59
  {
@@ -7,11 +7,11 @@ export default class ImageUtilities
7
7
 
8
8
  static get_image_data(image)
9
9
  {
10
- let canvas = document.createElement('canvas');
10
+ const canvas = document.createElement('canvas');
11
11
  canvas.width = image.width;
12
12
  canvas.height = image.height;
13
13
 
14
- let context = canvas.getContext('2d');
14
+ const context = canvas.getContext('2d');
15
15
  context.drawImage(image, 0, 0);
16
16
 
17
17
  return context.getImageData(0, 0, image.width, image.height);
@@ -19,8 +19,8 @@ export default class ImageUtilities
19
19
 
20
20
  static get_pixel(imagedata, x, y)
21
21
  {
22
- let position = (x + imagedata.width * y) * 4;
23
- let data = imagedata.data;
22
+ const position = (x + imagedata.width * y) * 4;
23
+ const data = imagedata.data;
24
24
  return new Vector4(data[position + 0], data[position + 1], data[position + 2], data[position + 3]);
25
25
  }
26
26
  }