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
@@ -1,9 +1,16 @@
1
- import { Mesh } from 'three';
1
+ // @ts-check
2
+ import { Material, Mesh } from 'three'; // eslint-disable-line no-unused-vars
2
3
  import { MeshBasicMaterial } from 'three';
3
4
  import { PlaneGeometry } from 'three';
4
5
 
5
6
  class HorizontalPlane extends Mesh
6
7
  {
8
+ /**
9
+ * @param {number} [width]
10
+ * @param {number} [height]
11
+ * @param {number | string} [color]
12
+ * @param {Material} [material]
13
+ */
7
14
  constructor(width, height, color, material)
8
15
  {
9
16
  width = width || 1;
@@ -2,6 +2,10 @@ import { Mesh, MeshBasicMaterial, SphereGeometry } from 'three';
2
2
 
3
3
  class Sphere extends Mesh
4
4
  {
5
+ /**
6
+ * @param {number} radius
7
+ * @param {number | string} color
8
+ */
5
9
  constructor(radius, color)
6
10
  {
7
11
  color = color || '#FF0000';
@@ -9,6 +13,9 @@ class Sphere extends Mesh
9
13
  const geometry = new SphereGeometry(radius, 64, 64);
10
14
  const material = new MeshBasicMaterial({ color: color });
11
15
  super(geometry, material);
16
+ this.radius = radius;
17
+ this.color = color;
18
+ this.center = this.position;
12
19
  }
13
20
  }
14
21
 
@@ -1,9 +1,16 @@
1
- import { Mesh } from 'three';
1
+ // @ts-check
2
+ import { Material, Mesh } from 'three'; // eslint-disable-line no-unused-vars
2
3
  import { PlaneGeometry } from 'three';
3
4
  import { MeshBasicMaterial } from 'three';
4
5
 
5
6
  class VerticalPlane extends Mesh
6
7
  {
8
+ /**
9
+ * @param {number} [width]
10
+ * @param {number} [height]
11
+ * @param {number | string} [color]
12
+ * @param {Material} [material]
13
+ */
7
14
  constructor(width, height, color, material)
8
15
  {
9
16
  width = width || 1;
@@ -3,7 +3,7 @@ import { BaseRender } from '../render_mode/BaseRender';
3
3
  import { UnrealBloomComposeMaterial } from '../materials/UnrealBloomComposeMaterial';
4
4
  import { AddMaterial } from '../materials/AddMaterial';
5
5
 
6
- import { WebGLRenderTarget } from 'three';
6
+ import { HalfFloatType, LinearSRGBColorSpace, NearestFilter, RGBAFormat, UnsignedByteType, WebGLRenderTarget } from 'three';
7
7
 
8
8
  import { GaussianBlurrer } from '../render_utilities/GaussianBlurrer';
9
9
  import { Graphics } from '../Graphics';
@@ -12,40 +12,61 @@ import { SceneManager } from '../SceneManager';
12
12
 
13
13
  class UnrealBloomRender extends BaseRender
14
14
  {
15
- constructor()
15
+ constructor(use_antialiasing, use_half_float, use_hight_luminosity_pass)
16
16
  {
17
17
  super();
18
18
 
19
- this.bloom_compose_mat = undefined;
20
-
21
- this.main_RT = undefined;
22
- this.blur_RT = undefined;
23
- this.blurrer = undefined;
24
-
25
- this.add_mat = new AddMaterial();
19
+ this.add_mat = new AddMaterial(use_half_float);
20
+
21
+ const rt_settings = {
22
+ samples: use_antialiasing ? 8 : 1,
23
+ type: use_half_float ? HalfFloatType : UnsignedByteType,
24
+ format: RGBAFormat,
25
+ colorSpace: LinearSRGBColorSpace,
26
+ minFilter: NearestFilter,
27
+ magFilter: NearestFilter
28
+ };
29
+ this.main_RT = new WebGLRenderTarget(1, 1, rt_settings);
30
+ this.main_RT.texture.colorSpace = LinearSRGBColorSpace;
31
+ this.main_RT.texture.minFilter = NearestFilter;
32
+ this.main_RT.texture.magFilter = NearestFilter;
33
+
34
+ this.bloom_compose_mat = new UnrealBloomComposeMaterial(5, use_half_float);
35
+ this.blurrer = new GaussianBlurrer(use_half_float);
36
+ this.use_hight_luminosity_pass = use_hight_luminosity_pass;
37
+ this.luminosity_threshold = 0.5;
26
38
  }
27
39
 
28
40
  on_enter()
29
41
  {
30
- this.blurrer = new GaussianBlurrer();
31
- this.main_RT = new WebGLRenderTarget(OScreen.width, OScreen.height);
32
- this.blur_RT = new WebGLRenderTarget(OScreen.width, OScreen.height);
33
-
34
- this.bloom_compose_mat = new UnrealBloomComposeMaterial(5);
35
- this.blurrer = new GaussianBlurrer(5);
36
-
37
42
  this.bloom_compose_mat.set_RT_0(this.blurrer.renderTargetsVertical[0].texture);
38
43
  this.bloom_compose_mat.set_RT_1(this.blurrer.renderTargetsVertical[1].texture);
39
44
  this.bloom_compose_mat.set_RT_2(this.blurrer.renderTargetsVertical[2].texture);
40
45
  this.bloom_compose_mat.set_RT_3(this.blurrer.renderTargetsVertical[3].texture);
41
46
  this.bloom_compose_mat.set_RT_4(this.blurrer.renderTargetsVertical[4].texture);
42
47
 
43
- this.bloom_compose_mat.set_bloom_strength(1);
44
- this.bloom_compose_mat.set_bloom_radius(1);
45
-
46
48
  this.add_mat.set_add_texture(this.blurrer.renderTargetsHorizontal[0].texture);
47
49
  }
48
50
 
51
+ render()
52
+ {
53
+ this.__check_RT_size();
54
+
55
+ Graphics.clear(this.main_RT, CameraManager.current, true, false);
56
+ Graphics.render(SceneManager.current, CameraManager.current, this.main_RT);
57
+
58
+ // // // BLUR
59
+ this.blurrer.blur(this.main_RT, this.use_hight_luminosity_pass);
60
+
61
+ // // Blur compose
62
+ Graphics.material_pass(this.bloom_compose_mat, this.blurrer.renderTargetsHorizontal[0]);
63
+
64
+ // // Additive blend
65
+ // Graphics.clear(undefined, CameraManager.current, true, false);
66
+ // Graphics.render(SceneManager.current, CameraManager.current);
67
+ Graphics.blit(this.main_RT, undefined, this.add_mat);
68
+ }
69
+
49
70
  set_bloom_strength(val)
50
71
  {
51
72
  this.bloom_compose_mat.set_bloom_strength(val);
@@ -53,7 +74,13 @@ class UnrealBloomRender extends BaseRender
53
74
 
54
75
  set_bloom_radius(val)
55
76
  {
56
- this.bloom_compose_mat.set_bloom_radius(val);
77
+ // this.bloom_compose_mat.set_bloom_radius(val);
78
+ this.blurrer.set_radius(val);
79
+ }
80
+
81
+ set_luminosity_threshold(value)
82
+ {
83
+ this.blurrer.set_luminosity_threshold(value);
57
84
  }
58
85
 
59
86
  set_tint_color_0(col_string)
@@ -81,29 +108,11 @@ class UnrealBloomRender extends BaseRender
81
108
  this.bloom_compose_mat.set_tint_color_4(col_string);
82
109
  }
83
110
 
84
- render()
85
- {
86
- this.__check_RT_size();
87
-
88
- Graphics.clear(this.main_RT, CameraManager.current, true, false);
89
- Graphics.render(SceneManager.current, CameraManager.current, this.main_RT);
90
-
91
- // // BLUR
92
- this.blurrer.blur(this.main_RT, true);
93
-
94
- // Blur compose
95
- Graphics.material_pass(this.bloom_compose_mat, this.blurrer.renderTargetsHorizontal[0]);
96
-
97
- // Additive blend
98
- Graphics.blit(this.main_RT, undefined, this.add_mat);
99
- }
100
-
101
111
  __check_RT_size()
102
112
  {
103
113
  if (this.main_RT.width !== OScreen.width || this.main_RT.height !== OScreen.height)
104
114
  {
105
115
  this.main_RT.setSize(OScreen.width, OScreen.height);
106
- this.blur_RT.setSize(OScreen.width, OScreen.height);
107
116
  }
108
117
  }
109
118
  }
@@ -85,13 +85,13 @@ class Blitter
85
85
  this._blit_quad.material.dispose();
86
86
  }
87
87
 
88
- __render(RT)
88
+ __render(dst_RT)
89
89
  {
90
- RT = RT === undefined ? null : RT;
90
+ const RT = dst_RT === undefined ? null : dst_RT;
91
91
 
92
92
  const current_rt = this.renderer.getRenderTarget();
93
93
 
94
- this.renderer.setRenderTarget(RT === undefined ? null : RT);
94
+ this.renderer.setRenderTarget(RT);
95
95
  this.renderer.render(this._blit_scene, this._blit_camera);
96
96
 
97
97
  this.renderer.setRenderTarget(current_rt);
@@ -2,11 +2,11 @@ import { GaussianBlurMaterial } from '../materials/GaussianBlurMaterial';
2
2
  import { LuminosityHighPassMaterial } from '../materials/LuminosityHighPassMaterial';
3
3
  import { Graphics } from '../Graphics';
4
4
 
5
- import { WebGLRenderTarget, LinearFilter, RGBAFormat } from 'three';
5
+ import { WebGLRenderTarget, LinearFilter, RGBAFormat, HalfFloatType, UnsignedByteType, SRGBColorSpace, LinearSRGBColorSpace } from 'three';
6
6
 
7
7
  class GaussianBlurrer
8
8
  {
9
- constructor(nMips = 5)
9
+ constructor(use_half_float = false)
10
10
  {
11
11
  this.current_width = 1;
12
12
  this.current_height = 1;
@@ -14,10 +14,16 @@ class GaussianBlurrer
14
14
  this.separableBlurMaterials = [];
15
15
  this.renderTargetsHorizontal = [];
16
16
  this.renderTargetsVertical = [];
17
-
18
- this.nMips = nMips;
17
+ this.use_half_float = use_half_float;
18
+ this.nMips = 5;
19
19
  this.kernelSizeArray = [3, 5, 7, 9, 11];
20
- this.rt_pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };
20
+ this.rt_pars = {
21
+ minFilter: LinearFilter,
22
+ magFilter: LinearFilter,
23
+ format: RGBAFormat,
24
+ type: use_half_float ? HalfFloatType : UnsignedByteType,
25
+ colorSpace: use_half_float ? LinearSRGBColorSpace : SRGBColorSpace
26
+ };
21
27
 
22
28
  this.renderTargetBright = new WebGLRenderTarget(1, 1, this.rt_pars);
23
29
  this.renderTargetBright.texture.generateMipmaps = false;
@@ -25,24 +31,21 @@ class GaussianBlurrer
25
31
  this.init_materials();
26
32
  this.init_RT();
27
33
 
28
- this.luminosity_high_pass_mat = new LuminosityHighPassMaterial();
34
+ this.luminosity_high_pass_mat = new LuminosityHighPassMaterial(use_half_float);
29
35
  }
30
36
 
31
37
  blur(RT, use_luminosity_high_pass)
32
38
  {
33
39
  this.resize_RT(RT.width, RT.height);
34
40
 
41
+ let inputRenderTarget = RT;
42
+
35
43
  if (use_luminosity_high_pass)
36
44
  {
37
45
  Graphics.blit(RT, this.renderTargetBright, this.luminosity_high_pass_mat);
38
- }
39
- else
40
- {
41
- Graphics.blit(RT, this.renderTargetBright);
46
+ inputRenderTarget = this.renderTargetBright;
42
47
  }
43
48
 
44
- let inputRenderTarget = this.renderTargetBright;
45
-
46
49
  for (let i = 0; i < this.nMips; i++)
47
50
  {
48
51
  const mat = this.separableBlurMaterials[i];
@@ -81,6 +84,9 @@ class GaussianBlurrer
81
84
  hor.texture.generateMipmaps = false;
82
85
  ver.texture.generateMipmaps = false;
83
86
 
87
+ hor.texture.colorSpace = this.rt_pars.colorSpace;
88
+ ver.texture.colorSpace = this.rt_pars.colorSpace;
89
+
84
90
  this.renderTargetsHorizontal.push(hor);
85
91
  this.renderTargetsVertical.push(ver);
86
92
  }
@@ -112,16 +118,29 @@ class GaussianBlurrer
112
118
  }
113
119
  }
114
120
 
115
- init_materials(texture_width, texture_height)
121
+ init_materials()
116
122
  {
117
123
  this.dispose_materials();
118
124
 
119
125
  for (let i = 0; i < this.nMips; i++)
120
126
  {
121
- this.separableBlurMaterials.push(new GaussianBlurMaterial(this.kernelSizeArray[i]));
127
+ this.separableBlurMaterials.push(new GaussianBlurMaterial(this.kernelSizeArray[i], this.use_half_float));
122
128
  }
123
129
  }
124
130
 
131
+ set_radius(value)
132
+ {
133
+ for (let i = 0; i < this.separableBlurMaterials.length; i++)
134
+ {
135
+ this.separableBlurMaterials[i].set_radius(value);
136
+ }
137
+ }
138
+
139
+ set_luminosity_threshold(value)
140
+ {
141
+ this.luminosity_high_pass_mat.set_threshold(value);
142
+ }
143
+
125
144
  dispose_materials()
126
145
  {
127
146
  for (let i = 0; i < this.separableBlurMaterials.length; i++)
@@ -2,8 +2,27 @@ uniform sampler2D _MainTex;
2
2
  uniform sampler2D _SecondTex;
3
3
 
4
4
  varying vec2 vUv;
5
+
6
+ vec4 sampleTex(sampler2D tex, vec2 uv)
7
+ {
8
+ vec4 col = texture2D( tex, uv);
9
+
10
+ #ifndef USE_LINEAR_COLOR_SPACE
11
+ col.rgb = pow(col.rgb, vec3(2.2));
12
+ #endif
13
+
14
+ return col;
15
+ }
5
16
  void main()
6
17
  {
7
- gl_FragColor = texture2D(_MainTex, vUv);
8
- gl_FragColor += texture2D(_SecondTex, vUv);
18
+ vec4 col0 = sampleTex(_MainTex, vUv);
19
+ vec4 col1 = sampleTex(_SecondTex, vUv);
20
+
21
+
22
+ gl_FragColor = col0+col1;
23
+ // gl_FragColor = texture2D(_SecondTex, vUv);
24
+ gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.4545));
25
+
26
+ // gl_FragColor = texture2D(_MainTex, vUv)+texture2D(_SecondTex, vUv);
27
+
9
28
  }
@@ -3,23 +3,42 @@ varying vec2 vUv;
3
3
  uniform sampler2D _MainTex;
4
4
  uniform vec2 texSize;
5
5
  uniform vec2 direction;
6
+ uniform float radius;
6
7
 
7
8
  float gaussianPdf(in float x, in float sigma) {
8
9
  return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
9
10
  }
11
+
12
+ vec4 sampleTex(sampler2D tex, vec2 uv)
13
+ {
14
+ vec4 col = texture2D( tex, uv);
15
+
16
+ #ifndef USE_LINEAR_COLOR_SPACE
17
+ col.rgb = pow(col.rgb, vec3(2.2));
18
+ #endif
19
+
20
+ return col;
21
+ }
22
+
10
23
  void main() {
11
24
  vec2 invSize = 1.0 / texSize;
12
25
  float fSigma = float(SIGMA);
13
26
  float weightSum = gaussianPdf(0.0, fSigma);
14
- vec4 diffuseSum = texture2D( _MainTex, vUv) * weightSum;
27
+ vec4 diffuseSum = sampleTex( _MainTex, vUv) * weightSum;
15
28
  for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
16
29
  float x = float(i);
17
30
  float w = gaussianPdf(x, fSigma);
18
- vec2 uvOffset = direction * invSize * x;
19
- vec4 sample1 = texture2D( _MainTex, vUv + uvOffset);
20
- vec4 sample2 = texture2D( _MainTex, vUv - uvOffset);
31
+ vec2 uvOffset = direction * invSize * x * radius;
32
+ vec4 sample1 = sampleTex( _MainTex, vUv + uvOffset);
33
+ vec4 sample2 = sampleTex( _MainTex, vUv - uvOffset);
21
34
  diffuseSum += (sample1 + sample2) * w;
22
35
  weightSum += 2.0 * w;
23
36
  }
24
37
  gl_FragColor = vec4(diffuseSum/weightSum);
38
+
39
+ #ifndef USE_LINEAR_COLOR_SPACE
40
+ gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.4545));
41
+ #endif
42
+ // #include <colorspace_fragment>
43
+
25
44
  }
@@ -15,10 +15,22 @@ float lerpBloomFactor(const in float factor) {
15
15
  return mix(factor, mirrorFactor, bloomRadius);
16
16
  }
17
17
 
18
+ vec4 sampleTex(sampler2D tex, vec2 uv)
19
+ {
20
+ vec4 col = texture2D( tex, uv);
21
+ #ifndef USE_LINEAR_COLOR_SPACE
22
+ col.rgb = pow(col.rgb, vec3(2.2));
23
+ #endif
24
+ return col;
25
+ }
18
26
  void main() {
19
- gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
20
- lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
21
- lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
22
- lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
23
- lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
27
+ gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * sampleTex(blurTexture1, vUv) +
28
+ lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * sampleTex(blurTexture2, vUv) +
29
+ lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * sampleTex(blurTexture3, vUv) +
30
+ lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * sampleTex(blurTexture4, vUv) +
31
+ lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * sampleTex(blurTexture5, vUv) );
32
+
33
+ #ifndef USE_LINEAR_COLOR_SPACE
34
+ gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.4545));
35
+ #endif
24
36
  }
@@ -6,9 +6,17 @@ uniform float smoothWidth;
6
6
 
7
7
  varying vec2 vUv;
8
8
 
9
+ vec4 sampleTex(sampler2D tex, vec2 uv)
10
+ {
11
+ vec4 col = texture2D( tex, uv);
12
+ #ifndef USE_LINEAR_COLOR_SPACE
13
+ col.rgb = pow(col.rgb, vec3(2.2));
14
+ #endif
15
+ return col;
16
+ }
9
17
  void main() {
10
18
 
11
- vec4 texel = texture2D( _MainTex, vUv );
19
+ vec4 texel = sampleTex( _MainTex, vUv );
12
20
 
13
21
  vec3 luma = vec3( 0.299, 0.587, 0.114 );
14
22
 
@@ -19,5 +27,12 @@ void main() {
19
27
  float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
20
28
 
21
29
  gl_FragColor = mix( outputColor, texel, alpha );
30
+
31
+ // #include <colorspace_fragment>
32
+
33
+ #ifndef USE_LINEAR_COLOR_SPACE
34
+ gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.4545));
35
+ #endif
36
+
22
37
 
23
38
  }
@@ -1,3 +1,4 @@
1
+ import { UIElement } from '../../components/UIElement'; // eslint-disable-line no-unused-vars
1
2
  import { UIElementState } from './UIElementState';
2
3
 
3
4
  class OnIdle extends UIElementState
@@ -7,6 +8,10 @@ class OnIdle extends UIElementState
7
8
  super();
8
9
  }
9
10
 
11
+ /**
12
+ * @param {UIElement} ui_element
13
+ * @param {Vector2} normalized_mouse_position
14
+ */
10
15
  update(ui_element, normalized_mouse_position)
11
16
  {
12
17
  if (ui_element.is_mouse_over(normalized_mouse_position))
@@ -1,3 +1,6 @@
1
+ // @ts-check
2
+ import { Vector2 } from 'three'; // eslint-disable-line no-unused-vars
3
+ import { UIElement } from '../../components/UIElement'; // eslint-disable-line no-unused-vars
1
4
  import { UIElementState } from './UIElementState';
2
5
 
3
6
  class OnMouseEnter extends UIElementState
@@ -7,11 +10,19 @@ class OnMouseEnter extends UIElementState
7
10
  super();
8
11
  }
9
12
 
13
+ /**
14
+ *
15
+ * @param {UIElement} ui_element
16
+ */
10
17
  on_enter(ui_element)
11
18
  {
12
19
  ui_element.on_mouse_enter();
13
20
  }
14
21
 
22
+ /**
23
+ * @param {UIElement} ui_element
24
+ * @param {Vector2} normalized_mouse_position
25
+ */
15
26
  update(ui_element, normalized_mouse_position)
16
27
  {
17
28
  if (ui_element.is_mouse_over(normalized_mouse_position))
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+ import { UIElement } from '../../components/UIElement'; // eslint-disable-line no-unused-vars
1
3
  import { UIElementState } from './UIElementState';
2
4
 
3
5
  class OnMouseExit extends UIElementState
@@ -7,6 +9,9 @@ class OnMouseExit extends UIElementState
7
9
  super();
8
10
  }
9
11
 
12
+ /**
13
+ * @param {UIElement} ui_element
14
+ */
10
15
  on_enter(ui_element)
11
16
  {
12
17
  ui_element.on_mouse_exit();
@@ -1,3 +1,6 @@
1
+ // @ts-check
2
+ import { Vector2 } from 'three'; // eslint-disable-line no-unused-vars
3
+ import { UIElement } from '../../components/UIElement'; // eslint-disable-line no-unused-vars
1
4
  import { UIElementState } from './UIElementState';
2
5
 
3
6
  class OnMouseHover extends UIElementState
@@ -7,11 +10,18 @@ class OnMouseHover extends UIElementState
7
10
  super();
8
11
  }
9
12
 
13
+ /**
14
+ * @param {UIElement} ui_element
15
+ */
10
16
  on_enter(ui_element)
11
17
  {
12
18
  this.__trigger_on_hover(ui_element);
13
19
  }
14
20
 
21
+ /**
22
+ * @param {UIElement} ui_element
23
+ * @param {Vector2} normalized_mouse_position
24
+ */
15
25
  update(ui_element, normalized_mouse_position)
16
26
  {
17
27
  if (ui_element.is_mouse_over(normalized_mouse_position))
@@ -24,6 +34,9 @@ class OnMouseHover extends UIElementState
24
34
  }
25
35
  }
26
36
 
37
+ /**
38
+ * @param {UIElement} ui_element
39
+ */
27
40
  __trigger_on_hover(ui_element)
28
41
  {
29
42
  ui_element.on_mouse_hover();
@@ -1,3 +1,7 @@
1
+ // @ts-check
2
+ import { Vector2 } from 'three'; // eslint-disable-line no-unused-vars
3
+ import { UIElement } from '../../components/UIElement'; // eslint-disable-line no-unused-vars
4
+
1
5
  class UIElementState
2
6
  {
3
7
  constructor()
@@ -5,15 +9,25 @@ class UIElementState
5
9
 
6
10
  }
7
11
 
8
- update(ui_element, normalized_mouse_position)
12
+ /**
13
+ * @param {UIElement} ui_element
14
+ * @param {Vector2} normalized_mouse_position
15
+ */
16
+ update(ui_element, normalized_mouse_position) // eslint-disable-line no-unused-vars
9
17
  {
10
18
 
11
19
  }
12
20
 
13
- on_enter(ui_element)
21
+ /**
22
+ * @param {UIElement} ui_element
23
+ */
24
+ on_enter(ui_element) // eslint-disable-line no-unused-vars
14
25
  {}
15
26
 
16
- on_exit(ui_element)
27
+ /**
28
+ * @param {UIElement} ui_element
29
+ */
30
+ on_exit(ui_element) // eslint-disable-line no-unused-vars
17
31
  {}
18
32
  }
19
33
 
@@ -1,3 +1,4 @@
1
+
1
2
  class EasingFunctions
2
3
  {
3
4
  constructor()
@@ -223,4 +224,8 @@ class EasingFunctions
223
224
  }
224
225
  }
225
226
 
227
+ /**
228
+ * @typedef {'linear'|'triangular'|'ease_in_sine'|'ease_out_sine'|'ease_in_out_sine'|'ease_in_cubic'|'ease_out_cubic'|'ease_in_out_cubic'|'ease_in_quad'|'ease_out_quad'|'ease_in_out_quad'|'ease_in_quart'|'ease_out_quart'|'ease_in_out_quart'|'ease_in_quint'|'ease_out_quint'|'ease_in_out_quint'|'ease_in_expo'|'ease_out_expo'|'ease_in_out_expo'|'ease_in_circ'|'ease_out_circ'|'ease_in_out_circ'|'ease_in_back'|'ease_out_back'|'ease_in_out_back'|'ease_in_elastic'|'ease_out_elastic'|'ease_in_out_elastic'|'ease_in_bounce'|'ease_out_bounce'|'ease_in_out_bounce'|'heartbeat'} EasingFunctionType
229
+ */
230
+
226
231
  export { EasingFunctions };
@@ -1,11 +1,18 @@
1
- export class BaseApplication {
2
- on_post_start(): void;
3
- on_enter(): void;
4
- on_exit(): void;
5
- before_update(): void;
6
- update(): void;
7
- fixed_update(): void;
8
- on_post_render(): void;
9
- on_pre_render(): void;
10
- on_frame_end(): void;
11
- }
1
+ export class BaseApplication {
2
+ on_post_start(): void;
3
+ /**
4
+ * @param {RenderLoop} [loop]
5
+ */
6
+ on_enter(loop?: RenderLoop): void;
7
+ /**
8
+ * @param {RenderLoop} [loop]
9
+ */
10
+ on_exit(loop?: RenderLoop): void;
11
+ before_update(): void;
12
+ update(): void;
13
+ fixed_update(): void;
14
+ on_post_render(): void;
15
+ on_pre_render(): void;
16
+ on_frame_end(): void;
17
+ }
18
+ import { RenderLoop } from "./RenderLoop";
@@ -1,19 +1,20 @@
1
- export { browser as Browser };
2
- declare const browser: Browser;
3
- declare class Browser {
4
- init(): Promise<void>;
5
- browser_name: string;
6
- agent: string;
7
- has_web_xr_support: boolean;
8
- is_vr: any;
9
- version: number;
10
- get name(): string;
11
- get is_safari(): boolean;
12
- get is_chrome(): boolean;
13
- get is_edge(): boolean;
14
- get is_edge_chromium(): boolean;
15
- get has_webm(): boolean;
16
- get has_hvec(): boolean;
17
- get preferred_video_extension(): "webm" | "hvec.mp4" | "mp4";
18
- get_version(): number;
19
- }
1
+ export { browser as Browser };
2
+ declare const browser: Browser;
3
+ declare class Browser {
4
+ init(): Promise<void>;
5
+ browser_name: string;
6
+ agent: string;
7
+ has_web_xr_support: boolean;
8
+ is_vr: boolean;
9
+ version: number;
10
+ get name(): string;
11
+ get is_safari(): boolean;
12
+ get is_chrome(): boolean;
13
+ get is_firefox(): boolean;
14
+ get is_edge(): boolean;
15
+ get is_edge_chromium(): boolean;
16
+ get has_webm(): boolean;
17
+ get has_hvec(): boolean;
18
+ get preferred_video_extension(): "webm" | "hvec.mp4" | "mp4";
19
+ get_version(): number;
20
+ }