ohzi-core 12.2.0 → 12.3.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.
Files changed (285) hide show
  1. package/build/index.mjs +1 -1
  2. package/build/index.mjs.map +1 -1
  3. package/package.json +2 -1
  4. package/src/BaseApplication.js +11 -2
  5. package/src/Browser.js +10 -3
  6. package/src/CameraManager.js +5 -0
  7. package/src/Capabilities.js +1 -0
  8. package/src/CustomBezierCurve.js +12 -0
  9. package/src/Debug.js +99 -5
  10. package/src/Graphics.js +86 -6
  11. package/src/Initializer.js +5 -0
  12. package/src/KeyboardInput.js +40 -1
  13. package/src/OS.js +1 -1
  14. package/src/OScreen.js +19 -4
  15. package/src/OrthographicCamera.js +13 -0
  16. package/src/PerspectiveCamera.js +11 -0
  17. package/src/ReflectionPlaneContext.js +5 -1
  18. package/src/RenderLayers.js +1 -1
  19. package/src/RenderLoop.js +9 -0
  20. package/src/RenderOrder.js +1 -1
  21. package/src/ResourceContainer.js +21 -0
  22. package/src/SceneManager.js +14 -4
  23. package/src/Screen.js +71 -0
  24. package/src/Time.js +4 -0
  25. package/src/UI.js +16 -1
  26. package/src/action_sequencer/ActionEvent.js +6 -1
  27. package/src/action_sequencer/ActionInterpolator.js +16 -2
  28. package/src/action_sequencer/ActionSequencer.js +65 -2
  29. package/src/action_sequencer/NumberInterpolator.js +15 -0
  30. package/src/action_sequencer/VectorInterpolator.js +13 -1
  31. package/src/blitter_index.js +1 -0
  32. package/src/canvas_drawer/CanvasDrawer.js +37 -4
  33. package/src/canvas_drawer/MultiLineTextDrawer.js +8 -1
  34. package/src/canvas_drawer/SimpleTextDrawer.js +7 -1
  35. package/src/components/AudioClip.js +11 -1
  36. package/src/components/AxisHelper.js +1 -1
  37. package/src/components/BaseObject.js +8 -5
  38. package/src/components/EdgeMesh.js +30 -2
  39. package/src/components/GeometryEdgeVisualizer.js +10 -1
  40. package/src/components/Grid.js +4 -0
  41. package/src/components/Line.js +31 -7
  42. package/src/components/MultiLinePath.js +9 -5
  43. package/src/components/MultiLineText2D.js +13 -2
  44. package/src/components/ObjectAxis.js +5 -0
  45. package/src/components/ObjectOrientedBoundingBox.js +26 -1
  46. package/src/components/PlaneHelper.js +1 -1
  47. package/src/components/Shape2D.js +11 -3
  48. package/src/components/Shape3D.js +10 -4
  49. package/src/components/Text2D.js +11 -3
  50. package/src/components/UIElement.js +40 -4
  51. package/src/components/UpdatableMaterialMesh.js +11 -3
  52. package/src/components/WorldImage.js +10 -2
  53. package/src/index.js +3 -1
  54. package/src/loaders/AsyncAbstractLoader.js +16 -0
  55. package/src/loaders/AsyncObjectsLoader.js +6 -0
  56. package/src/materials/AddMaterial.js +2 -2
  57. package/src/materials/GaussianBlurMaterial.js +9 -1
  58. package/src/materials/LuminosityHighPassMaterial.js +8 -1
  59. package/src/materials/UnrealBloomComposeMaterial.js +3 -2
  60. package/src/primitives/Arrow.js +6 -0
  61. package/src/primitives/Cube.js +6 -1
  62. package/src/primitives/HorizontalPlane.js +8 -1
  63. package/src/primitives/Sphere.js +7 -0
  64. package/src/primitives/VerticalPlane.js +8 -1
  65. package/src/render_mode/UnrealBloomRender.js +47 -38
  66. package/src/render_utilities/Blitter.js +3 -3
  67. package/src/render_utilities/GaussianBlurrer.js +33 -14
  68. package/src/shaders/add/add.frag +21 -2
  69. package/src/shaders/gaussian_blur/gaussian_blur.frag +23 -4
  70. package/src/shaders/gaussian_blur/unreal_bloom_compose.frag +17 -5
  71. package/src/shaders/luminosity_high_pass/luminosity_high_pass.frag +16 -1
  72. package/src/ui/ui_element_state/OnIdle.js +5 -0
  73. package/src/ui/ui_element_state/OnMouseEnter.js +11 -0
  74. package/src/ui/ui_element_state/OnMouseExit.js +5 -0
  75. package/src/ui/ui_element_state/OnMouseHover.js +13 -0
  76. package/src/ui/ui_element_state/UIElementState.js +17 -3
  77. package/src/utilities/EasingFunctions.js +5 -0
  78. package/types/BaseApplication.d.ts +18 -11
  79. package/types/Browser.d.ts +20 -19
  80. package/types/CameraManager.d.ts +14 -13
  81. package/types/Capabilities.d.ts +8 -8
  82. package/types/CustomBezierCurve.d.ts +19 -7
  83. package/types/Debug.d.ts +198 -37
  84. package/types/Graphics.d.ts +143 -61
  85. package/types/Initializer.d.ts +10 -6
  86. package/types/KeyboardInput.d.ts +65 -20
  87. package/types/OS.d.ts +20 -20
  88. package/types/OScreen.d.ts +37 -22
  89. package/types/OrthographicCamera.d.ts +20 -6
  90. package/types/PerspectiveCamera.d.ts +18 -6
  91. package/types/ReflectionPlaneContext.d.ts +13 -8
  92. package/types/RenderLayers.d.ts +6 -6
  93. package/types/RenderLoop.d.ts +132 -14
  94. package/types/RenderOrder.d.ts +8 -8
  95. package/types/ResourceContainer.d.ts +29 -10
  96. package/types/SceneManager.d.ts +15 -12
  97. package/types/Screen.d.ts +27 -0
  98. package/types/Time.d.ts +29 -24
  99. package/types/UI.d.ts +92 -18
  100. package/types/action_sequencer/ActionEvent.d.ts +12 -7
  101. package/types/action_sequencer/ActionInterpolator.d.ts +18 -5
  102. package/types/action_sequencer/ActionSequencer.d.ts +104 -36
  103. package/types/action_sequencer/NumberInterpolator.d.ts +18 -9
  104. package/types/action_sequencer/VectorInterpolator.d.ts +13 -7
  105. package/types/blitter_index.d.ts +6 -6
  106. package/types/canvas_drawer/CanvasDrawer.d.ts +51 -13
  107. package/types/canvas_drawer/MultiLineTextDrawer.d.ts +13 -5
  108. package/types/canvas_drawer/SimpleTextDrawer.d.ts +13 -6
  109. package/types/components/AudioClip.d.ts +25 -13
  110. package/types/components/AxisHelper.d.ts +6 -6
  111. package/types/components/BaseObject.d.ts +12 -5
  112. package/types/components/EdgeMesh.d.ts +42 -13
  113. package/types/components/GeometryEdgeVisualizer.d.ts +12 -4
  114. package/types/components/Grid.d.ts +4 -2
  115. package/types/components/Line.d.ts +42 -16
  116. package/types/components/MultiLinePath.d.ts +10 -4
  117. package/types/components/MultiLineText2D.d.ts +22 -10
  118. package/types/components/ObjectAxis.d.ts +8 -3
  119. package/types/components/ObjectOrientedBoundingBox.d.ts +45 -18
  120. package/types/components/PlaneHelper.d.ts +6 -6
  121. package/types/components/Shape2D.d.ts +14 -4
  122. package/types/components/Shape3D.d.ts +10 -3
  123. package/types/components/Text2D.d.ts +21 -13
  124. package/types/components/UIElement.d.ts +87 -52
  125. package/types/components/UpdatableMaterialMesh.d.ts +12 -4
  126. package/types/components/WorldImage.d.ts +23 -13
  127. package/types/components/mouse_interactors/ObjectRotator.d.ts +12 -0
  128. package/types/components/sdf_text/SDFText.d.ts +35 -30
  129. package/types/components/sdf_text/SDFTextBatch.d.ts +12 -12
  130. package/types/components/sdf_text/TextGlyph.d.ts +8 -6
  131. package/types/data_textures/CustomDataTexture.d.ts +11 -11
  132. package/types/data_textures/RGBADataTexture.d.ts +4 -4
  133. package/types/data_textures/RGBAFloatDataTexture.d.ts +4 -4
  134. package/types/data_textures/RGBDataTexture.d.ts +4 -4
  135. package/types/data_textures/RGBFloatDataTexture.d.ts +4 -4
  136. package/types/editor/ManipulatorHandle.d.ts +23 -14
  137. package/types/editor/ObjectEditor.d.ts +18 -16
  138. package/types/editor/ObjectManipulator.d.ts +23 -19
  139. package/types/editor/ObjectPicker.d.ts +19 -16
  140. package/types/gpu_particles/GPUParticleSystem.d.ts +22 -15
  141. package/types/gpu_particles/ParticleAttribute.d.ts +19 -18
  142. package/types/gpu_particles/ParticlePositionAttribute.d.ts +6 -6
  143. package/types/html_utilities/CSSAnimator.d.ts +31 -31
  144. package/types/html_utilities/css_animator_states/Animating.d.ts +8 -8
  145. package/types/html_utilities/css_animator_states/Idle.d.ts +6 -6
  146. package/types/index.d.ts +110 -108
  147. package/types/loaders/AsyncAbstractLoader.d.ts +41 -27
  148. package/types/loaders/AsyncAudiosLoader.d.ts +6 -5
  149. package/types/loaders/AsyncObjectsLoader.d.ts +6 -6
  150. package/types/loaders/AsyncTexturesLoader.d.ts +9 -8
  151. package/types/loaders/assets_loader/AssetLoader.d.ts +4 -0
  152. package/types/loaders/assets_loader/AsyncAssetsLoaderWorker.d.ts +1 -0
  153. package/types/loaders/assets_loader/ResourceBatch.d.ts +14 -0
  154. package/types/loaders/assets_loader/ResourceContainer.d.ts +9 -0
  155. package/types/loaders/assets_loader/ResourceLoaderChecker.d.ts +8 -0
  156. package/types/materials/AddMaterial.d.ts +5 -5
  157. package/types/materials/AlphaFilterMaterial.d.ts +6 -6
  158. package/types/materials/BaseShaderMaterial.d.ts +4 -3
  159. package/types/materials/BlitMaterial.d.ts +4 -3
  160. package/types/materials/BloomComposeMaterial.d.ts +4 -7
  161. package/types/materials/BoxBlurMaterial.d.ts +4 -4
  162. package/types/materials/ClearAlphaMaterial.d.ts +3 -3
  163. package/types/materials/ClearColorMaterial.d.ts +7 -7
  164. package/types/materials/ClearDepthNormalMaterial.d.ts +4 -4
  165. package/types/materials/DeferredRendererComposeMaterial.d.ts +7 -7
  166. package/types/materials/DepthNormalMaterial.d.ts +6 -4
  167. package/types/materials/DisplayNormalTextureMaterial.d.ts +4 -4
  168. package/types/materials/DualFilteringBlurMaterial.d.ts +4 -4
  169. package/types/materials/FXAAMaterial.d.ts +3 -3
  170. package/types/materials/GaussianBlurMaterial.d.ts +6 -6
  171. package/types/materials/LuminosityHighPassMaterial.d.ts +4 -4
  172. package/types/materials/MedianFilterMaterial.d.ts +7 -6
  173. package/types/materials/NormalMaterial.d.ts +4 -2
  174. package/types/materials/SDFScreenTextMaterial.d.ts +9 -11
  175. package/types/materials/SDFTextMaterial.d.ts +10 -12
  176. package/types/materials/SSAOComposeMaterial.d.ts +4 -4
  177. package/types/materials/SSAOMaterial.d.ts +8 -6
  178. package/types/materials/ScreenSpaceTextureMaterial.d.ts +7 -7
  179. package/types/materials/UIElementMaterial.d.ts +4 -7
  180. package/types/materials/UnrealBloomComposeMaterial.d.ts +16 -16
  181. package/types/materials/UnrealBlurMaterial.d.ts +4 -4
  182. package/types/materials/UnrealComposeMaterial.d.ts +4 -4
  183. package/types/materials/ViewPositionMaterial.d.ts +4 -3
  184. package/types/materials/deferred/DeferredPointLightMaterial.d.ts +9 -10
  185. package/types/materials/gpu_particles/AttributeUpdateMaterial.d.ts +7 -0
  186. package/types/materials/gpu_particles/BasicParticleMaterial.d.ts +4 -0
  187. package/types/materials/gpu_particles/ParticleStorageMaterial.d.ts +4 -2
  188. package/types/materials/gpu_particles/PositionStorageMaterial.d.ts +3 -4
  189. package/types/object_pool/Pool.d.ts +10 -10
  190. package/types/primitives/Arrow.d.ts +15 -8
  191. package/types/primitives/Cube.d.ts +10 -3
  192. package/types/primitives/HorizontalPlane.d.ts +11 -3
  193. package/types/primitives/Sphere.d.ts +11 -3
  194. package/types/primitives/VerticalPlane.d.ts +11 -3
  195. package/types/raycast/GroupRaycaster.d.ts +15 -13
  196. package/types/raycast/PlaneDragResolver.d.ts +16 -15
  197. package/types/raycast/PlaneRaycastResolver.d.ts +5 -5
  198. package/types/raycast/PlaneRaycaster.d.ts +9 -7
  199. package/types/raycast/RaycastResolver.d.ts +5 -5
  200. package/types/raycast/SurfaceDragResolver.d.ts +15 -13
  201. package/types/raycast/states/BaseState.d.ts +5 -5
  202. package/types/raycast/states/IdleState.d.ts +3 -5
  203. package/types/raycast/states/OnRaycastEnter.d.ts +3 -5
  204. package/types/raycast/states/OnRaycastExit.d.ts +3 -4
  205. package/types/raycast/states/OnRaycastHover.d.ts +3 -5
  206. package/types/render_mode/BaseRender.d.ts +7 -7
  207. package/types/render_mode/BloomRender.d.ts +12 -10
  208. package/types/render_mode/DebugNormalsRender.d.ts +3 -3
  209. package/types/render_mode/DeferredRender.d.ts +13 -9
  210. package/types/render_mode/NormalAORender.d.ts +18 -17
  211. package/types/render_mode/NormalRender.d.ts +3 -3
  212. package/types/render_mode/OutlineRender.d.ts +25 -20
  213. package/types/render_mode/PlanarReflectionsRender.d.ts +19 -13
  214. package/types/render_mode/UnrealBloomRender.d.ts +21 -20
  215. package/types/render_mode/VRRender.d.ts +4 -4
  216. package/types/render_utilities/Blitter.d.ts +19 -15
  217. package/types/render_utilities/Blurrer.d.ts +9 -8
  218. package/types/render_utilities/DepthAndNormalsRenderer.d.ts +11 -10
  219. package/types/render_utilities/DualFilteringBlurrer.d.ts +18 -17
  220. package/types/render_utilities/GaussianBlurrer.d.ts +27 -26
  221. package/types/render_utilities/MedianFilter.d.ts +11 -9
  222. package/types/render_utilities/ViewPositionRenderer.d.ts +10 -9
  223. package/types/resource_loader/AbstractLoader.d.ts +21 -21
  224. package/types/resource_loader/AsyncTextureLoader.d.ts +11 -11
  225. package/types/resource_loader/AudioLoader.d.ts +9 -9
  226. package/types/resource_loader/BasisLoader.d.ts +6 -6
  227. package/types/resource_loader/CubemapLoader.d.ts +8 -7
  228. package/types/resource_loader/DAELoader.d.ts +7 -6
  229. package/types/resource_loader/DDSLoader.d.ts +7 -6
  230. package/types/resource_loader/FileLoader.d.ts +7 -6
  231. package/types/resource_loader/FontLoader.d.ts +7 -6
  232. package/types/resource_loader/GLTFDRACOLoader.d.ts +7 -6
  233. package/types/resource_loader/GLTFLoader.d.ts +7 -6
  234. package/types/resource_loader/HDRCubeTextureLoader.d.ts +8 -7
  235. package/types/resource_loader/JSONLoader.d.ts +5 -4
  236. package/types/resource_loader/OBJLoader.d.ts +7 -6
  237. package/types/resource_loader/PointArrayLoader.d.ts +9 -7
  238. package/types/resource_loader/RGBETextureLoader.d.ts +7 -6
  239. package/types/resource_loader/ResourceBatch.d.ts +13 -13
  240. package/types/resource_loader/SVGLoader.d.ts +7 -6
  241. package/types/resource_loader/TextLoader.d.ts +7 -6
  242. package/types/resource_loader/TextureLoader.d.ts +4 -4
  243. package/types/resource_loader/VideoLoader.d.ts +4 -4
  244. package/types/scenes/AbstractScene.d.ts +32 -32
  245. package/types/scenes/loading_states/CompilatorManager.d.ts +8 -8
  246. package/types/scenes/loading_states/HighQualityLoadingState.d.ts +3 -3
  247. package/types/scenes/loading_states/LoadingState.d.ts +31 -31
  248. package/types/scenes/loading_states/RegularLoadingState.d.ts +5 -5
  249. package/types/static_batcher/BatchedMesh.d.ts +16 -15
  250. package/types/static_batcher/GeometryBatch.d.ts +41 -37
  251. package/types/static_batcher/GeometryBatcher.d.ts +9 -9
  252. package/types/static_batcher/MeshBatcher.d.ts +5 -5
  253. package/types/ui/ui_element_position/ScreenSpacePosition.d.ts +5 -4
  254. package/types/ui/ui_element_position/WorldSpacePosition.d.ts +7 -5
  255. package/types/ui/ui_element_state/OnIdle.d.ts +9 -3
  256. package/types/ui/ui_element_state/OnMouseEnter.d.ts +3 -3
  257. package/types/ui/ui_element_state/OnMouseExit.d.ts +3 -3
  258. package/types/ui/ui_element_state/OnMouseHover.d.ts +8 -4
  259. package/types/ui/ui_element_state/UIElementState.d.ts +17 -5
  260. package/types/utilities/ArrayUtilities.d.ts +7 -7
  261. package/types/utilities/CameraUtilities.d.ts +40 -36
  262. package/types/utilities/EasingFunctions.d.ts +36 -35
  263. package/types/utilities/FrustumPointFitter.d.ts +14 -14
  264. package/types/utilities/GeometryUtilities.d.ts +5 -4
  265. package/types/utilities/HTMLUtilities.d.ts +6 -6
  266. package/types/utilities/ImageUtilities.d.ts +5 -4
  267. package/types/utilities/MeshSampler.d.ts +20 -20
  268. package/types/utilities/ModelUtilities.d.ts +15 -15
  269. package/types/utilities/OMath.d.ts +21 -21
  270. package/types/utilities/ObjectUtilities.d.ts +7 -7
  271. package/types/utilities/OrthographicFrustumPointFitter.d.ts +8 -7
  272. package/types/utilities/PerspectiveFrustumPointFitter.d.ts +14 -12
  273. package/types/utilities/StringUtilities.d.ts +6 -6
  274. package/types/utilities/TimeUtilities.d.ts +3 -3
  275. package/types/utilities/Validation.d.ts +6 -6
  276. package/types/view_components/ApplicationView.d.ts +13 -13
  277. package/types/view_components/TransitionManager.d.ts +20 -20
  278. package/types/view_components/ViewComponent.d.ts +15 -15
  279. package/types/view_components/ViewComponentManager.d.ts +13 -13
  280. package/types/view_components/ViewManager.d.ts +22 -23
  281. package/types/view_components/ViewState.d.ts +14 -14
  282. package/types/view_components/transition/ActionSequencerBuilder.d.ts +16 -16
  283. package/types/view_components/transition/DrawIOAnimationSheet.d.ts +17 -17
  284. package/types/view_components/transition/TransitionTable.d.ts +8 -8
  285. package/types/view_components/transition/ViewStateTransitionHandler.d.ts +19 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohzi-core",
3
- "version": "12.2.0",
3
+ "version": "12.3.0",
4
4
  "description": "OHZI Interactive Core Library",
5
5
  "source": "src/index.js",
6
6
  "module": "build/index.mjs",
@@ -53,6 +53,7 @@
53
53
  ]
54
54
  },
55
55
  "devDependencies": {
56
+ "@types/three": "0.166.0",
56
57
  "rollup": "^2.44.0",
57
58
  "rollup-plugin-glslify": "^1.2.0",
58
59
  "rollup-plugin-sourcemaps": "^0.6.3",
@@ -1,12 +1,21 @@
1
+ import { RenderLoop } from './RenderLoop'; // eslint-disable-line no-unused-vars
2
+
3
+ // @ts-check
1
4
  class BaseApplication
2
5
  {
3
6
  on_post_start()
4
7
  {}
5
8
 
6
- on_enter()
9
+ /**
10
+ * @param {RenderLoop} [loop]
11
+ */
12
+ on_enter(loop) // eslint-disable-line no-unused-vars
7
13
  {}
8
14
 
9
- on_exit()
15
+ /**
16
+ * @param {RenderLoop} [loop]
17
+ */
18
+ on_exit(loop) // eslint-disable-line no-unused-vars
10
19
  {}
11
20
 
12
21
  before_update()
package/src/Browser.js CHANGED
@@ -1,4 +1,4 @@
1
-
1
+ // @ts-check
2
2
  class Browser
3
3
  {
4
4
  async init()
@@ -17,9 +17,11 @@ class Browser
17
17
  case this.agent.indexOf('edg') > -1:
18
18
  this.browser_name = 'edge_chromium';
19
19
  break;
20
+ // @ts-ignore
20
21
  case this.agent.indexOf('opr') > -1 && !!window.opr:
21
22
  this.browser_name = 'opera';
22
23
  break;
24
+ // @ts-ignore
23
25
  case this.agent.indexOf('chrome') > -1 && !!window.chrome:
24
26
  this.browser_name = 'chrome';
25
27
  break;
@@ -55,6 +57,11 @@ class Browser
55
57
  return this.browser_name === 'chrome';
56
58
  }
57
59
 
60
+ get is_firefox()
61
+ {
62
+ return this.browser_name === 'firefox';
63
+ }
64
+
58
65
  get is_edge()
59
66
  {
60
67
  return this.browser_name === 'edge_ie';
@@ -83,8 +90,8 @@ class Browser
83
90
  get_version()
84
91
  {
85
92
  const ua = navigator.userAgent;
86
- let tem = '';
87
- let version = 0;
93
+ let tem = [];
94
+ let version = '0';
88
95
 
89
96
  let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
90
97
 
@@ -1,3 +1,6 @@
1
+ // @ts-check
2
+ import { PerspectiveCamera } from './PerspectiveCamera'; // eslint-disable-line no-unused-vars
3
+
1
4
  class CameraManager
2
5
  {
3
6
  init()
@@ -12,6 +15,7 @@ class CameraManager
12
15
  this._current = camera;
13
16
  }
14
17
 
18
+ /** @type {PerspectiveCamera} */
15
19
  get current()
16
20
  {
17
21
  return this._current;
@@ -22,6 +26,7 @@ class CameraManager
22
26
  this._spectator = camera;
23
27
  }
24
28
 
29
+ /** @type {PerspectiveCamera} */
25
30
  get spectator()
26
31
  {
27
32
  return this._spectator;
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  class Capabilities
2
3
  {
3
4
  init()
@@ -1,7 +1,11 @@
1
+ // @ts-check
1
2
  import { Vector3 } from 'three';
2
3
 
3
4
  class CustomBezierCurve
4
5
  {
6
+ /**
7
+ * @param {Vector3[]} points
8
+ */
5
9
  constructor(points)
6
10
  {
7
11
  this.original_points = [];
@@ -13,6 +17,10 @@ class CustomBezierCurve
13
17
  }
14
18
  }
15
19
 
20
+ /**
21
+ * @param {number} point_amount
22
+ * @returns {Vector3[]}
23
+ */
16
24
  build(point_amount)
17
25
  {
18
26
  const curve = [];
@@ -23,6 +31,10 @@ class CustomBezierCurve
23
31
  return curve;
24
32
  }
25
33
 
34
+ /**
35
+ * @param {number} t
36
+ * @returns {Vector3}
37
+ */
26
38
  get_point_at(t)
27
39
  {
28
40
  for (let i = 0; i < this.original_points.length; i++)
package/src/Debug.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import { AxisHelper } from './components/AxisHelper';
2
3
 
3
4
  import { SceneManager } from './SceneManager';
@@ -5,10 +6,11 @@ import { Cube } from './primitives/Cube';
5
6
  import { Sphere } from './primitives/Sphere';
6
7
  import { Arrow } from './primitives/Arrow';
7
8
  import { OScreen } from './OScreen';
9
+ import { Graphics } from './Graphics'; // eslint-disable-line no-unused-vars
8
10
  import { ScreenSpaceTextureMaterial } from './materials/ScreenSpaceTextureMaterial';
9
11
  import { PerspectiveCamera } from './PerspectiveCamera';
10
12
 
11
- import { Vector3 } from 'three';
13
+ import { RenderTarget, Texture, Vector2, Vector3, WebGLRenderer } from 'three'; // eslint-disable-line no-unused-vars
12
14
  import { LineBasicMaterial } from 'three';
13
15
  import { BufferGeometry } from 'three';
14
16
  import { Line } from 'three';
@@ -22,8 +24,9 @@ import { Scene } from 'three';
22
24
  import { CatmullRomCurve3 } from 'three';
23
25
  import { SphereGeometry } from 'three';
24
26
  import { MeshBasicMaterial } from 'three';
25
-
27
+ // @ts-ignore
26
28
  import basic_color_vert from './shaders/basic_color/basic_color.vert';
29
+ // @ts-ignore
27
30
  import basic_color_frag from './shaders/basic_color/basic_color.frag';
28
31
  import { CameraManager } from './CameraManager';
29
32
 
@@ -35,6 +38,7 @@ class Debug
35
38
  this.Vector3_zero = new Vector3(0, 0, 0);
36
39
  this.canvas_renderer = undefined;
37
40
 
41
+ /** @type { Mesh<PlaneGeometry, ScreenSpaceTextureMaterial>[] } */
38
42
  this.display_texture_meshes = [];
39
43
 
40
44
  this.ctx = undefined;
@@ -43,6 +47,12 @@ class Debug
43
47
  this.camera.clear_alpha = 0;
44
48
  }
45
49
 
50
+ /**
51
+ * @param {Vector3} origin
52
+ * @param {Vector3} dir
53
+ * @param {number | string} color
54
+ * @returns {Arrow}
55
+ */
46
56
  draw_arrow(origin, dir, color = 0xff0000)
47
57
  {
48
58
  const arrow = new Arrow(color, dir.length(), dir.clone().normalize());
@@ -58,11 +68,20 @@ class Debug
58
68
  return axis;
59
69
  }
60
70
 
71
+ /**
72
+ * @param {RenderTarget} RT
73
+ */
61
74
  set_debug_RT(RT)
62
75
  {
63
76
  this.rt_debug = RT;
64
77
  }
65
78
 
79
+ /**
80
+ * @param {Vector2 | Vector3} position_2d
81
+ * @param {number} width
82
+ * @param {number} height
83
+ * @param {number | string} color
84
+ */
66
85
  draw_rectangle(position_2d, width, height, color)
67
86
  {
68
87
  width = width || 100;
@@ -80,6 +99,11 @@ class Debug
80
99
  }
81
100
  }
82
101
 
102
+ /**
103
+ * @param {Vector3 | Vector2} from
104
+ * @param {Vector3 | Vector2} to
105
+ * @param {number | string} color
106
+ */
83
107
  draw_line_2D(from, to, color)
84
108
  {
85
109
  this.ctx.strokeStyle = color || 'rgba(255, 0, 0, 1)';
@@ -90,6 +114,11 @@ class Debug
90
114
  this.ctx.stroke();
91
115
  }
92
116
 
117
+ /**
118
+ * @param {Vector3[]} points
119
+ * @param {number | string} color
120
+ * @returns {Line}
121
+ */
93
122
  draw_line(points, color = 0xff0000)
94
123
  {
95
124
  const material = new LineBasicMaterial({
@@ -104,6 +133,12 @@ class Debug
104
133
  return line;
105
134
  }
106
135
 
136
+ /**
137
+ * @param {Vector3} pos
138
+ * @param {number} size
139
+ * @param {number | string} color
140
+ * @returns {Cube}
141
+ */
107
142
  draw_cube(pos, size, color)
108
143
  {
109
144
  size = size || 1;
@@ -116,6 +151,14 @@ class Debug
116
151
  return cube;
117
152
  }
118
153
 
154
+ /**
155
+ * @param {Vector3} from
156
+ * @param {Vector3} to
157
+ * @param {number} height
158
+ * @param {number | string} color
159
+ * @param {number} depth
160
+ * @returns {Cube}
161
+ */
119
162
  draw_oriented_cube(from, to, height = 1, color = '#FF0000', depth = 0.1)
120
163
  {
121
164
  const size = from.distanceTo(to);
@@ -138,7 +181,14 @@ class Debug
138
181
  return cube;
139
182
  }
140
183
 
141
- draw_plane(width, height, color)
184
+ /**
185
+ *
186
+ * @param {number} [width]
187
+ * @param {number} [height]
188
+ * @param {number | string} [color]
189
+ * @returns
190
+ */
191
+ draw_plane(width, height, color) // eslint-disable-line no-unused-vars
142
192
  {
143
193
  const geometry = new PlaneGeometry(width, height);
144
194
  const material = new ShaderMaterial({
@@ -157,6 +207,12 @@ class Debug
157
207
  return plane;
158
208
  }
159
209
 
210
+ /**
211
+ * @param {Vector3} pos
212
+ * @param {number} size
213
+ * @param {number | string} color
214
+ * @returns {Box3Helper}
215
+ */
160
216
  draw_empty_cube(pos, size, color)
161
217
  {
162
218
  size = size || 1;
@@ -168,6 +224,12 @@ class Debug
168
224
  return helper;
169
225
  }
170
226
 
227
+ /**
228
+ * @param {Vector3} pos
229
+ * @param {number} size
230
+ * @param {number | string} color
231
+ * @returns {Sphere}
232
+ */
171
233
  draw_sphere(pos, size, color)
172
234
  {
173
235
  size = size || 1;
@@ -180,7 +242,14 @@ class Debug
180
242
  return sphere;
181
243
  }
182
244
 
183
- draw_point_array(input_points, open = false, color = 0xff0000)
245
+ /**
246
+ *
247
+ * @param {Vector3[]} input_points
248
+ * @param {boolean} open
249
+ * @param {number | string} color
250
+ * @returns {Line}
251
+ */
252
+ draw_point_array(input_points, open = false, color = 0xff0000) // eslint-disable-line no-unused-vars
184
253
  {
185
254
  const catmull = new CatmullRomCurve3(input_points, open);
186
255
  catmull.updateArcLengths();
@@ -190,6 +259,11 @@ class Debug
190
259
  return line_helper;
191
260
  }
192
261
 
262
+ /**
263
+ * @param {Sphere} sphere
264
+ * @param {number | string} color
265
+ * @returns {Mesh}
266
+ */
193
267
  draw_sphere_helper(sphere, color)
194
268
  {
195
269
  color = color || 0xff0000;
@@ -201,6 +275,9 @@ class Debug
201
275
  return sphere_mesh;
202
276
  }
203
277
 
278
+ /**
279
+ * @param {Sphere} sphere
280
+ */
204
281
  draw_math_sphere(sphere)
205
282
  {
206
283
  const geometry = new SphereGeometry(sphere.radius, 32, 32);
@@ -218,12 +295,20 @@ class Debug
218
295
  SceneManager.current.add(sphere1);
219
296
  }
220
297
 
298
+ /**
299
+ * @param {Box3} bb
300
+ */
221
301
  draw_bounding_box(bb)
222
302
  {
223
303
  const helper = new Box3Helper(bb, 0xffff00);
224
304
  SceneManager.current.add(helper);
225
305
  }
226
306
 
307
+ /**
308
+ * @param {Vector3[]} curve
309
+ * @param {object} options
310
+ * @param {number} options.offset
311
+ */
227
312
  draw_curve(curve, options)
228
313
  {
229
314
  const offset = new Vector3(0, 0, 0);
@@ -234,10 +319,16 @@ class Debug
234
319
 
235
320
  for (let i = 0; i < curve.length - 1; i++)
236
321
  {
237
- this.draw_line(curve[i].clone().add(offset), curve[i + 1].clone().add(offset));
322
+ this.draw_line([curve[i].clone().add(offset), curve[i + 1].clone().add(offset)]);
238
323
  }
239
324
  }
240
325
 
326
+ /**
327
+ * @param {Texture} tex
328
+ * @param {number} w
329
+ * @param {number} h
330
+ * @returns {Mesh}
331
+ */
241
332
  draw_texture(tex, w, h)
242
333
  {
243
334
  const mesh = new Mesh(new PlaneGeometry(1, 1), new ScreenSpaceTextureMaterial());
@@ -248,6 +339,9 @@ class Debug
248
339
  return mesh;
249
340
  }
250
341
 
342
+ /**
343
+ * @param {Graphics} graphics
344
+ */
251
345
  render(graphics)
252
346
  {
253
347
  for (let i = 0; i < this.display_texture_meshes.length; i++)
package/src/Graphics.js CHANGED
@@ -1,6 +1,10 @@
1
+ // @ts-check
2
+ import { BaseApplication } from './BaseApplication'; // eslint-disable-line no-unused-vars
1
3
  import { CameraManager } from './CameraManager';
2
4
  import { Capabilities } from './Capabilities';
3
5
  import { OScreen } from './OScreen';
6
+ import { OrthographicCamera } from './OrthographicCamera'; // eslint-disable-line no-unused-vars
7
+ import { PerspectiveCamera } from './PerspectiveCamera'; // eslint-disable-line no-unused-vars
4
8
  import { SceneManager } from './SceneManager';
5
9
 
6
10
  import { BaseRender } from './render_mode/BaseRender';
@@ -15,13 +19,22 @@ import {
15
19
  NoBlending,
16
20
  RGBAFormat,
17
21
  ShaderMaterial,
18
- WebGLRenderTarget
22
+ WebGLRenderTarget,
23
+ Material, Object3D, Scene // eslint-disable-line no-unused-vars
19
24
  } from 'three';
20
25
 
21
26
  import { WebGLRenderer } from 'three';
22
27
 
23
28
  class Graphics
24
29
  {
30
+ /**
31
+ * @param {Object} options
32
+ * @param {HTMLCanvasElement} options.canvas
33
+ * @param {Record<string, any>} options.core_attributes
34
+ * @param {Record<string, any>} options.context_attributes
35
+ * @param {Record<string, any>} options.threejs_attributes
36
+ * @param {number} options.dpr
37
+ */
25
38
  init({ canvas, core_attributes, context_attributes, threejs_attributes, dpr })
26
39
  {
27
40
  this._renderer = undefined;
@@ -53,6 +66,7 @@ class Graphics
53
66
  stencil: false
54
67
  };
55
68
 
69
+ /** @type {Record<string, any>} */
56
70
  this.threejs_attributes = {
57
71
  logarithmicDepthBuffer: false
58
72
  };
@@ -128,6 +142,9 @@ class Graphics
128
142
  return this.depth_and_normals_renderer.render_target;
129
143
  }
130
144
 
145
+ /**
146
+ * @param {BaseRender} new_state
147
+ */
131
148
  set_state(new_state)
132
149
  {
133
150
  // console.log('VIEWAPI - map render mode switch to: ' + new_state.constructor.name);
@@ -165,6 +182,12 @@ class Graphics
165
182
  }
166
183
  }
167
184
 
185
+ /**
186
+ * @param {Scene} [scene]
187
+ * @param {PerspectiveCamera | OrthographicCamera} [camera]
188
+ * @param {WebGLRenderTarget} [RT]
189
+ * @param {Material} [override_mat]
190
+ */
168
191
  render(scene, camera, RT, override_mat)
169
192
  {
170
193
  this.__apply_override_material(scene, override_mat);
@@ -176,6 +199,12 @@ class Graphics
176
199
  this.__apply_override_material(scene, undefined);
177
200
  }
178
201
 
202
+ /**
203
+ * @param {Scene} scene
204
+ * @param {PerspectiveCamera} camera
205
+ * @param {WebGLRenderTarget} RT
206
+ * @param {Material} override_mat
207
+ */
179
208
  compile(scene, camera, RT, override_mat)
180
209
  {
181
210
  this.__apply_override_material(scene, override_mat);
@@ -187,6 +216,14 @@ class Graphics
187
216
  this.__apply_override_material(scene, undefined);
188
217
  }
189
218
 
219
+ /**
220
+ * @param {Scene} scene
221
+ * @param {PerspectiveCamera} camera
222
+ * @param {WebGLRenderTarget} RT
223
+ * @param {Material} override_mat
224
+ * @param {Scene} target_scene
225
+ * @returns {Promise<Object3D>}
226
+ */
190
227
  async compile_async(scene, camera, RT, override_mat, target_scene)
191
228
  {
192
229
  this.__apply_override_material(scene, override_mat);
@@ -200,28 +237,36 @@ class Graphics
200
237
  return promise;
201
238
  }
202
239
 
240
+ /**
241
+ * @param {BaseApplication | Scene | {render:()=>void}} scene
242
+ */
203
243
  render_scene(scene)
204
244
  {
205
- if (scene.on_pre_render)
245
+ if ('on_pre_render' in scene)
206
246
  {
207
247
  scene.on_pre_render();
208
248
  }
209
249
 
210
- if (scene.render)
250
+ if ('render' in scene)
211
251
  {
212
252
  scene.render();
213
253
  }
214
254
  else
215
255
  {
256
+ // @ts-ignore
216
257
  this.render(scene, undefined);
217
258
  }
218
259
 
219
- if (scene.on_post_render)
260
+ if ('on_post_render' in scene)
220
261
  {
221
262
  scene.on_post_render();
222
263
  }
223
264
  }
224
265
 
266
+ /**
267
+ * @param {Scene} scene
268
+ * @param {Material} mat
269
+ */
225
270
  __apply_override_material(scene, mat)
226
271
  {
227
272
  mat = mat === undefined ? null : mat;
@@ -235,11 +280,21 @@ class Graphics
235
280
  }
236
281
  }
237
282
 
283
+ /**
284
+ * @param {WebGLRenderTarget} RT
285
+ * @param {import('three').TypedArray} buffer
286
+ */
238
287
  readback_RT(RT, buffer)
239
288
  {
240
289
  this._renderer.readRenderTargetPixels(RT, 0, 0, RT.width, RT.height, buffer);
241
290
  }
242
291
 
292
+ /**
293
+ * @param {WebGLRenderTarget} RT
294
+ * @param {PerspectiveCamera} camera
295
+ * @param {boolean} clear_depth
296
+ * @param {boolean} clear_stencil
297
+ */
243
298
  clear(RT, camera, clear_depth, clear_stencil)
244
299
  {
245
300
  this._renderer.setRenderTarget(RT === undefined ? null : RT);
@@ -254,6 +309,10 @@ class Graphics
254
309
  !!clear_stencil);
255
310
  }
256
311
 
312
+ /**
313
+ * @param {ResizeObserverEntry[]} entries
314
+ * @param {number} dpr
315
+ */
257
316
  on_resize(entries, dpr)
258
317
  {
259
318
  for (const entry of entries)
@@ -273,11 +332,20 @@ class Graphics
273
332
  }
274
333
  }
275
334
 
335
+ /**
336
+ * @param {Material} mat
337
+ * @param {WebGLRenderTarget} dst
338
+ */
276
339
  material_pass(mat, dst)
277
340
  {
278
341
  this.blitter.material_pass(mat, dst);
279
342
  }
280
343
 
344
+ /**
345
+ * @param {WebGLRenderTarget} src_RT
346
+ * @param {WebGLRenderTarget} dst_RT
347
+ * @param {Material} mat
348
+ */
281
349
  blit(src_RT, dst_RT, mat)
282
350
  {
283
351
  if (mat)
@@ -290,11 +358,20 @@ class Graphics
290
358
  }
291
359
  }
292
360
 
361
+ /**
362
+ * @param {WebGLRenderTarget} dst_RT
363
+ * @param {Material} mat
364
+ */
293
365
  blit_clear_with_material(dst_RT, mat)
294
366
  {
295
367
  this.blitter.blit_clear_with_material(dst_RT, mat);
296
368
  }
297
369
 
370
+ /**
371
+ * @param {BlobCallback} blob_callback
372
+ * @param {number} width
373
+ * @param {number} height
374
+ */
298
375
  take_screenshot(blob_callback, width = OScreen.width, height = OScreen.height)
299
376
  {
300
377
  // const ctx = this;
@@ -308,8 +385,8 @@ class Graphics
308
385
  const tile_width = 1024;
309
386
  const tile_height = 1024;
310
387
 
311
- const divisions_x = parseInt(Math.ceil(new_width / tile_width));
312
- const divisions_y = parseInt(Math.ceil(new_height / tile_height));
388
+ const divisions_x = Math.ceil(new_width / tile_width);
389
+ const divisions_y = Math.ceil(new_height / tile_height);
313
390
 
314
391
  OScreen.update_size(tile_width, tile_height);
315
392
  const old_dpr = this._renderer.getPixelRatio();
@@ -355,6 +432,9 @@ class Graphics
355
432
  CameraManager.current.updateMatrixWorld(true);
356
433
  }
357
434
 
435
+ /**
436
+ * @param {Blob} blob
437
+ */
358
438
  download_screenshot(blob)
359
439
  {
360
440
  const link = document.createElement('a');
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import { Browser } from './Browser';
2
3
  import { CameraManager } from './CameraManager';
3
4
  import { Capabilities } from './Capabilities';
@@ -12,6 +13,7 @@ import { GeometryBatcher } from './static_batcher/GeometryBatcher';
12
13
  import { Time } from './Time';
13
14
  import { UI } from './UI';
14
15
  import { CameraUtilities } from './utilities/CameraUtilities';
16
+ import { RenderLoop } from './index'; // eslint-disable-line no-unused-vars
15
17
 
16
18
  class Initializer
17
19
  {
@@ -38,6 +40,9 @@ class Initializer
38
40
  Debug.init();
39
41
  }
40
42
 
43
+ /**
44
+ * @param {RenderLoop} render_loop
45
+ */
41
46
  dispose(render_loop)
42
47
  {
43
48
  Graphics.dispose();