ohzi-core 13.3.0 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/README.md +2 -1
  2. package/build/index.mjs +1 -1
  3. package/build/index.mjs.map +1 -1
  4. package/package.json +12 -6
  5. package/src/Capabilities.ts +0 -2
  6. package/src/Debug.ts +38 -33
  7. package/src/Graphics.ts +2 -2
  8. package/src/Initializer.ts +2 -1
  9. package/src/SceneManager.ts +4 -5
  10. package/src/action_sequencer/NumberInterpolator.ts +2 -0
  11. package/src/blitter_index.ts +1 -2
  12. package/src/camera_controller/CameraController.ts +106 -63
  13. package/src/camera_controller/states/common/CommonCameraState.ts +2 -1
  14. package/src/components/AxisHelper.ts +1 -0
  15. package/src/components/Line.ts +35 -27
  16. package/src/components/PlaneHelper.ts +1 -1
  17. package/src/components/Text2D.ts +3 -1
  18. package/src/components/WorldImage.ts +27 -20
  19. package/src/components/sdf_text/SDFTextBatch.ts +16 -26
  20. package/src/dev_bridge/CameraBridge.ts +363 -0
  21. package/src/dev_bridge/CaptureService.ts +256 -0
  22. package/src/dev_bridge/CommandDispatcher.ts +114 -0
  23. package/src/dev_bridge/ConsoleBuffer.ts +286 -0
  24. package/src/dev_bridge/DebugDrawer.ts +399 -0
  25. package/src/dev_bridge/DevBridge.ts +195 -0
  26. package/src/dev_bridge/InputSynthesizer.ts +287 -0
  27. package/src/dev_bridge/PerformanceProbe.ts +118 -0
  28. package/src/dev_bridge/RenderModeRegistry.ts +66 -0
  29. package/src/dev_bridge/SceneEditor.ts +288 -0
  30. package/src/dev_bridge/SceneInspector.ts +388 -0
  31. package/src/dev_bridge/ViewNavigator.ts +101 -0
  32. package/src/dev_bridge/protocol.ts +31 -0
  33. package/src/index.ts +21 -14
  34. package/src/materials/AddMaterial.ts +14 -7
  35. package/src/materials/BlitNodeMaterial.ts +85 -0
  36. package/src/materials/BloomComposeMaterial.ts +21 -9
  37. package/src/materials/BoxBlurMaterial.ts +26 -6
  38. package/src/materials/ClearDepthNormalMaterial.ts +12 -6
  39. package/src/materials/DepthNormalMaterial.ts +25 -14
  40. package/src/materials/DualFilteringBlurMaterial.ts +32 -5
  41. package/src/materials/GaussianBlurMaterial.ts +36 -14
  42. package/src/materials/LineMaterial.ts +52 -0
  43. package/src/materials/LuminosityHighPassMaterial.ts +23 -10
  44. package/src/materials/NormalMaterial.ts +10 -11
  45. package/src/materials/SDFTextMaterial.ts +63 -16
  46. package/src/materials/SSAOComposeMaterial.ts +14 -5
  47. package/src/materials/SSAOMaterial.ts +123 -24
  48. package/src/materials/ScreenSpaceTextureMaterial.ts +19 -31
  49. package/src/materials/UnrealBloomComposeMaterial.ts +41 -32
  50. package/src/materials/WorldImageMaterial.ts +51 -0
  51. package/src/materials/deferred/DeferredPointLightMaterial.ts +45 -14
  52. package/src/materials/deferred/depth_normal_encoding.ts +36 -0
  53. package/src/primitives/Cube.ts +1 -1
  54. package/src/primitives/Sphere.ts +1 -1
  55. package/src/raycast/GroupRaycaster.ts +2 -2
  56. package/src/render_mode/BloomRender.ts +18 -4
  57. package/src/render_mode/DebugNormalsRender.ts +6 -1
  58. package/src/render_mode/DeferredRender.ts +5 -34
  59. package/src/render_mode/NormalAORender.ts +9 -19
  60. package/src/render_mode/UnrealBloomRender.ts +2 -1
  61. package/src/render_mode/VRRender.ts +6 -3
  62. package/src/render_utilities/Blitter.ts +4 -4
  63. package/src/render_utilities/Blurrer.ts +7 -0
  64. package/src/render_utilities/DualFilteringBlurrer.ts +26 -10
  65. package/src/resource_loader/AudioLoader.ts +5 -3
  66. package/src/resource_loader/HDRTextureLoader.ts +1 -1
  67. package/src/scenes/AbstractScene.ts +7 -3
  68. package/src/scenes/Compilator.ts +5 -1
  69. package/src/scenes/loading_states/LoadingState.ts +15 -7
  70. package/src/scenes/loading_states/RegularLoadingState.ts +2 -1
  71. package/src/utilities/CameraUtilities.ts +57 -79
  72. package/src/utilities/HTMLUtilities.ts +2 -1
  73. package/src/utilities/MeshSampler.ts +8 -1
  74. package/src/utilities/OrthographicFrustumPointFitter.ts +53 -4
  75. package/src/view_components/ApplicationView.ts +1 -1
  76. package/src/view_components/ViewComponent.ts +1 -1
  77. package/src/view_components/ViewManager.ts +7 -1
  78. package/src/view_components/transition/DrawIOAnimationSheet.ts +1 -1
  79. package/types/Capabilities.d.ts +0 -1
  80. package/types/SceneManager.d.ts +1 -1
  81. package/types/blitter_index.d.ts +1 -2
  82. package/types/camera_controller/CameraController.d.ts +9 -0
  83. package/types/components/Line.d.ts +3 -2
  84. package/types/components/WorldImage.d.ts +3 -2
  85. package/types/index.d.ts +2 -7
  86. package/types/materials/AddMaterial.d.ts +2 -2
  87. package/types/materials/BlitNodeMaterial.d.ts +18 -0
  88. package/types/materials/BloomComposeMaterial.d.ts +2 -2
  89. package/types/materials/BoxBlurMaterial.d.ts +2 -2
  90. package/types/materials/ClearDepthNormalMaterial.d.ts +2 -2
  91. package/types/materials/DepthNormalMaterial.d.ts +2 -2
  92. package/types/materials/DualFilteringBlurMaterial.d.ts +2 -2
  93. package/types/materials/GaussianBlurMaterial.d.ts +2 -2
  94. package/types/materials/LuminosityHighPassMaterial.d.ts +2 -2
  95. package/types/materials/NormalMaterial.d.ts +2 -2
  96. package/types/materials/SDFTextMaterial.d.ts +2 -2
  97. package/types/materials/SSAOComposeMaterial.d.ts +2 -2
  98. package/types/materials/SSAOMaterial.d.ts +2 -2
  99. package/types/materials/ScreenSpaceTextureMaterial.d.ts +2 -2
  100. package/types/materials/UnrealBloomComposeMaterial.d.ts +2 -2
  101. package/types/materials/deferred/DeferredPointLightMaterial.d.ts +2 -2
  102. package/types/render_mode/DeferredRender.d.ts +0 -2
  103. package/types/render_mode/NormalAORender.d.ts +0 -2
  104. package/types/render_utilities/Blitter.d.ts +2 -2
  105. package/types/render_utilities/DualFilteringBlurrer.d.ts +0 -2
  106. package/types/utilities/CameraUtilities.d.ts +0 -1
  107. package/types/utilities/OrthographicFrustumPointFitter.d.ts +14 -8
  108. package/build/index.module.js +0 -2
  109. package/build/index.module.js.map +0 -1
  110. package/src/components/EdgeMesh.ts +0 -150
  111. package/src/components/GeometryEdgeVisualizer.ts +0 -49
  112. package/src/components/MultiLinePath.ts +0 -25
  113. package/src/components/MultiLineText2D.ts +0 -65
  114. package/src/components/Shape2D.ts +0 -42
  115. package/src/components/Shape3D.ts +0 -38
  116. package/src/gpu_particles/GPUParticleSystem.ts +0 -122
  117. package/src/gpu_particles/ParticleAttribute.ts +0 -110
  118. package/src/gpu_particles/ParticlePositionAttribute.ts +0 -46
  119. package/src/materials/AlphaFilterMaterial.ts +0 -21
  120. package/src/materials/BaseShaderMaterial.ts +0 -20
  121. package/src/materials/BlitMaterial.ts +0 -27
  122. package/src/materials/DeferredRendererComposeMaterial.ts +0 -36
  123. package/src/materials/DisplayNormalTextureMaterial.ts +0 -18
  124. package/src/materials/FXAAMaterial.ts +0 -12
  125. package/src/materials/MedianFilterMaterial.ts +0 -46
  126. package/src/materials/SDFScreenTextMaterial.ts +0 -32
  127. package/src/materials/UnrealBlurMaterial.ts +0 -20
  128. package/src/materials/UnrealComposeMaterial.ts +0 -27
  129. package/src/materials/ViewPositionMaterial.ts +0 -19
  130. package/src/materials/gpu_particles/AttributeUpdateMaterial.ts +0 -35
  131. package/src/materials/gpu_particles/BasicParticleMaterial.ts +0 -25
  132. package/src/materials/gpu_particles/ParticleStorageMaterial.ts +0 -36
  133. package/src/materials/gpu_particles/PositionStorageMaterial.ts +0 -27
  134. package/src/render_utilities/MedianFilter.ts +0 -72
  135. package/src/render_utilities/ViewPositionRenderer.ts +0 -53
  136. package/src/shaders/add/add.frag +0 -28
  137. package/src/shaders/anti_aliasing/fxaa.frag +0 -72
  138. package/src/shaders/basic_color/basic_color.frag +0 -6
  139. package/src/shaders/basic_color/basic_color.vert +0 -10
  140. package/src/shaders/basic_line/basic_line.frag +0 -37
  141. package/src/shaders/basic_line/basic_line.vert +0 -37
  142. package/src/shaders/basic_texture/basic_texture.frag +0 -10
  143. package/src/shaders/basic_texture/basic_texture.vert +0 -17
  144. package/src/shaders/bloom/bloom_compose.frag +0 -22
  145. package/src/shaders/bloom/cheap_bloom_compose.frag +0 -13
  146. package/src/shaders/box_blur/box_blur.frag +0 -24
  147. package/src/shaders/box_blur/compose.frag +0 -31
  148. package/src/shaders/clear/clear_depth_normal.frag +0 -25
  149. package/src/shaders/copy/copy.frag +0 -7
  150. package/src/shaders/copy/copy.vert +0 -6
  151. package/src/shaders/deferred/blit_copy.vert +0 -11
  152. package/src/shaders/deferred/deferred_compose.frag +0 -59
  153. package/src/shaders/deferred/point_light.frag +0 -66
  154. package/src/shaders/deferred/point_light.vert +0 -13
  155. package/src/shaders/depth_normals/debug_normals.frag +0 -48
  156. package/src/shaders/depth_normals/depth_normals.frag +0 -30
  157. package/src/shaders/depth_normals/depth_normals.vert +0 -13
  158. package/src/shaders/dual_filter_blur/alpha_filter.frag +0 -14
  159. package/src/shaders/dual_filter_blur/downsample.frag +0 -21
  160. package/src/shaders/dual_filter_blur/upsample.frag +0 -24
  161. package/src/shaders/edge_visualizer/edge_visualizer.frag +0 -18
  162. package/src/shaders/edge_visualizer/edge_visualizer.vert +0 -16
  163. package/src/shaders/edges/corners.frag +0 -11
  164. package/src/shaders/edges/corners.vert +0 -31
  165. package/src/shaders/edges/edges.frag +0 -7
  166. package/src/shaders/edges/edges.vert +0 -27
  167. package/src/shaders/gaussian_blur/gaussian_blur.frag +0 -44
  168. package/src/shaders/gaussian_blur/unreal_bloom_compose.frag +0 -36
  169. package/src/shaders/gpu_particles/common_utils.glsl +0 -13
  170. package/src/shaders/gpu_particles/generic_storage.frag +0 -6
  171. package/src/shaders/gpu_particles/store/store_position.vert +0 -14
  172. package/src/shaders/gpu_particles/update/basic_update.frag +0 -21
  173. package/src/shaders/gpu_particles/visualize/visualize.frag +0 -11
  174. package/src/shaders/gpu_particles/visualize/visualize.vert +0 -12
  175. package/src/shaders/grid/grid.frag +0 -17
  176. package/src/shaders/grid/grid.vert +0 -10
  177. package/src/shaders/luminosity_high_pass/luminosity_high_pass.frag +0 -38
  178. package/src/shaders/median_filter/median_filter.frag +0 -134
  179. package/src/shaders/normal/normal.frag +0 -6
  180. package/src/shaders/normal/normal.vert +0 -6
  181. package/src/shaders/sdf_text/sdf_screen_text.frag +0 -51
  182. package/src/shaders/sdf_text/sdf_screen_text.vert +0 -42
  183. package/src/shaders/sdf_text/sdf_text.frag +0 -53
  184. package/src/shaders/sdf_text/sdf_text.vert +0 -42
  185. package/src/shaders/ssao/hbao.frag +0 -264
  186. package/src/shaders/ssao/ssao.frag +0 -95
  187. package/src/shaders/ssao/ssao.vert +0 -11
  188. package/src/shaders/ssao/ssao_compose.frag +0 -14
  189. package/src/shaders/transparent_mix/copy.frag +0 -7
  190. package/src/shaders/transparent_mix/transparent_mix.frag +0 -19
  191. package/src/shaders/transparent_mix/transparent_mix.vert +0 -8
  192. package/src/shaders/ui/ss_texture.frag +0 -11
  193. package/src/shaders/ui/ss_texture.vert +0 -32
  194. package/src/shaders/ui/ws_texture.vert +0 -39
  195. package/src/shaders/unreal_blur/unreal_blur.frag +0 -25
  196. package/src/shaders/unreal_blur/unreal_compose.frag +0 -24
  197. package/src/shaders/write_view_position/write_view_position.frag +0 -7
  198. package/src/shaders/write_view_position/write_view_position.vert +0 -9
  199. package/src/types.d.ts +0 -14
  200. package/types/components/EdgeMesh.d.ts +0 -16
  201. package/types/components/GeometryEdgeVisualizer.d.ts +0 -8
  202. package/types/components/MultiLinePath.d.ts +0 -8
  203. package/types/components/MultiLineText2D.d.ts +0 -12
  204. package/types/components/Shape2D.d.ts +0 -7
  205. package/types/components/Shape3D.d.ts +0 -6
  206. package/types/gpu_particles/GPUParticleSystem.d.ts +0 -19
  207. package/types/gpu_particles/ParticleAttribute.d.ts +0 -20
  208. package/types/gpu_particles/ParticlePositionAttribute.d.ts +0 -6
  209. package/types/materials/AlphaFilterMaterial.d.ts +0 -7
  210. package/types/materials/BaseShaderMaterial.d.ts +0 -4
  211. package/types/materials/BlitMaterial.d.ts +0 -4
  212. package/types/materials/DeferredRendererComposeMaterial.d.ts +0 -10
  213. package/types/materials/DisplayNormalTextureMaterial.d.ts +0 -4
  214. package/types/materials/FXAAMaterial.d.ts +0 -5
  215. package/types/materials/MedianFilterMaterial.d.ts +0 -8
  216. package/types/materials/SDFScreenTextMaterial.d.ts +0 -8
  217. package/types/materials/UIElementMaterial.d.ts +0 -4
  218. package/types/materials/UnrealBlurMaterial.d.ts +0 -5
  219. package/types/materials/UnrealComposeMaterial.d.ts +0 -5
  220. package/types/materials/ViewPositionMaterial.d.ts +0 -5
  221. package/types/materials/gpu_particles/AttributeUpdateMaterial.d.ts +0 -8
  222. package/types/materials/gpu_particles/BasicParticleMaterial.d.ts +0 -5
  223. package/types/materials/gpu_particles/ParticleStorageMaterial.d.ts +0 -5
  224. package/types/materials/gpu_particles/PositionStorageMaterial.d.ts +0 -5
  225. package/types/render_utilities/MedianFilter.d.ts +0 -12
  226. package/types/render_utilities/ViewPositionRenderer.d.ts +0 -12
@@ -1,150 +0,0 @@
1
- import corners_frag from '../shaders/edges/corners.frag';
2
- import corners_vert from '../shaders/edges/corners.vert';
3
- import edge_line_frag from '../shaders/edges/edges.frag';
4
- import edge_line_vert from '../shaders/edges/edges.vert';
5
-
6
- import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js';
7
-
8
- import type { BufferGeometry , InterleavedBufferAttribute} from 'three';
9
- import { BufferAttribute, Color, EdgesGeometry, LineBasicMaterial, LineSegments, Mesh, Object3D, PlaneGeometry, ShaderMaterial, Vector3 } from 'three';
10
-
11
- class EdgeMesh extends Object3D
12
- {
13
- corners_material: ShaderMaterial;
14
- corners_mesh: Mesh;
15
- edges_material: ShaderMaterial;
16
- edges_mesh: Mesh;
17
-
18
- constructor(buffer_geometry: BufferGeometry, thickness: number, color: string)
19
- {
20
- super();
21
- thickness = thickness || 0.1;
22
- color = color || '#555555';
23
- this.edges_material = new ShaderMaterial({
24
- uniforms: {
25
- _Thickness: { value: thickness },
26
- _Color: { value: new Color(color) }
27
- },
28
- vertexShader: edge_line_vert,
29
- fragmentShader: edge_line_frag,
30
- transparent: true,
31
- depthWrite: false
32
- });
33
-
34
- this.corners_material = new ShaderMaterial({
35
- uniforms: {
36
- _Thickness: { value: thickness },
37
- _Color: { value: new Color(color) }
38
- },
39
- vertexShader: corners_vert,
40
- fragmentShader: corners_frag,
41
- transparent: true,
42
- depthWrite: false
43
- });
44
-
45
- const edges_geometry = this.__get_edges_geometry(this.__get_edges(buffer_geometry));
46
- const corners_geometry = this.__get_corners_geometry(buffer_geometry.getAttribute('position'));
47
-
48
- this.edges_mesh = new Mesh(edges_geometry, this.edges_material);
49
- this.corners_mesh = new Mesh(corners_geometry, this.corners_material);
50
-
51
- this.edges_mesh.frustumCulled = false;
52
- this.corners_mesh.frustumCulled = false;
53
- this.add(this.edges_mesh);
54
- this.add(this.corners_mesh);
55
- }
56
-
57
- __get_edges(cube_geometry: BufferGeometry): Vector3[]
58
- {
59
- const edges = new EdgesGeometry(cube_geometry);
60
- const line = new LineSegments(edges, new LineBasicMaterial());
61
- const points_array = line.geometry.attributes.position.array;
62
-
63
- const points = [];
64
- for (let i = 0; i < points_array.length; i += 3)
65
- {
66
- points.push(new Vector3(points_array[i], points_array[i + 1], points_array[i + 2]));
67
- }
68
- return points;
69
- }
70
-
71
- update(time: number): void
72
- {
73
-
74
- }
75
-
76
- __get_edges_geometry(points: Vector3[])
77
- {
78
- const buffer_geometries = [];
79
- for (let i = 0; i < points.length; i += 2)
80
- {
81
- const dir = points[i + 1].clone().sub(points[i]).normalize();
82
- const geometry = new PlaneGeometry(1, 1);
83
- const vertices = geometry.getAttribute('position');
84
- // top right
85
- vertices.array[0] = points[i].x;
86
- vertices.array[1] = points[i].y;
87
- vertices.array[2] = points[i].z;
88
- // top left
89
- vertices.array[3] = points[i].x;
90
- vertices.array[4] = points[i].y;
91
- vertices.array[5] = points[i].z;
92
-
93
- // bottom right
94
- vertices.array[6] = points[i + 1].x;
95
- vertices.array[7] = points[i + 1].y;
96
- vertices.array[8] = points[i + 1].z;
97
- // bottom left
98
- vertices.array[9] = points[i + 1].x;
99
- vertices.array[10] = points[i + 1].y;
100
- vertices.array[11] = points[i + 1].z;
101
-
102
- const dirs = [];
103
- for (let d = 0; d < vertices.count; d++)
104
- {
105
- dirs.push(dir.x);
106
- dirs.push(dir.y);
107
- dirs.push(dir.z);
108
- }
109
- const dir_array = new Float32Array(dirs);
110
- geometry.setAttribute('tangent', new BufferAttribute(dir_array, 3));
111
- buffer_geometries.push(geometry);
112
- }
113
-
114
- return BufferGeometryUtils.mergeGeometries(buffer_geometries);
115
- }
116
-
117
- __get_corners_geometry(geometry_vertices: BufferAttribute | InterleavedBufferAttribute): BufferGeometry
118
- {
119
- const circle_buffer_geometries = [];
120
- for (let i = 0; i < geometry_vertices.count; i++)
121
- {
122
- const plane_geometry = new PlaneGeometry(1, 1);
123
- const plane_vertices = plane_geometry.getAttribute('position');
124
- const w_pos = [];
125
- for (let d = 0; d < plane_vertices.count; d++)
126
- {
127
- w_pos.push(geometry_vertices.array[i * 3 + 0]);
128
- w_pos.push(geometry_vertices.array[i * 3 + 1]);
129
- w_pos.push(geometry_vertices.array[i * 3 + 2]);
130
- }
131
- const pos_array = new Float32Array(w_pos);
132
- plane_geometry.setAttribute('w_pos', new BufferAttribute(pos_array, 3));
133
- circle_buffer_geometries.push(plane_geometry);
134
- }
135
- return BufferGeometryUtils.mergeGeometries(circle_buffer_geometries);
136
- }
137
-
138
- set_visible(boolean: boolean): void
139
- {
140
- this.edges_mesh.visible = boolean;
141
- this.corners_mesh.visible = boolean;
142
- }
143
-
144
- dispose(): void
145
- {
146
-
147
- }
148
- }
149
-
150
- export { EdgeMesh };
@@ -1,49 +0,0 @@
1
- import edge_visualizer_frag from '../shaders/edge_visualizer/edge_visualizer.frag';
2
- import edge_visualizer_vert from '../shaders/edge_visualizer/edge_visualizer.vert';
3
-
4
- import { GeometryUtilities } from '../utilities/GeometryUtilities';
5
-
6
- import type { BufferGeometry } from 'three';
7
- import { Color, Mesh, ShaderMaterial } from 'three';
8
-
9
- class GeometryEdgeVisualizer extends Mesh
10
- {
11
- material: ShaderMaterial;
12
-
13
- constructor(geometry: BufferGeometry, line_color?: string | number)
14
- {
15
- line_color = line_color || '#91EE91';
16
-
17
- const material = new ShaderMaterial({
18
- uniforms: {
19
- _Color: { value: new Color('#CC3333') },
20
- _LineColor: { value: new Color(line_color) },
21
- _Alpha: { value: 1 },
22
- _DepthOffset: { value: 0.001 },
23
- _Thickness: { value: 2.5 }
24
- },
25
- vertexShader: edge_visualizer_vert,
26
- fragmentShader: edge_visualizer_frag,
27
- transparent: true,
28
- depthWrite: false
29
- });
30
-
31
- let non_indexed_geometry = geometry;
32
- if (non_indexed_geometry.index)
33
- {
34
- non_indexed_geometry = GeometryUtilities.convert_to_non_indexed_geometry(geometry);
35
- }
36
-
37
- GeometryUtilities.add_barycentric_attribute(non_indexed_geometry);
38
-
39
- super(non_indexed_geometry, material);
40
- this.material = material;
41
- }
42
-
43
- hide_faces(): void
44
- {
45
- this.material.uniforms._Alpha.value = 0;
46
- }
47
- }
48
-
49
- export { GeometryEdgeVisualizer };
@@ -1,25 +0,0 @@
1
- import { Line } from './Line';
2
-
3
- import type { Vector3 } from 'three';
4
- import { Object3D } from 'three';
5
-
6
- class MultiLinePath extends Object3D
7
- {
8
- paths: Line[];
9
-
10
- constructor(paths: Array<Vector3[]>)
11
- {
12
- super();
13
-
14
- this.paths = [];
15
-
16
- for (let i = 0; i < paths.length; i++)
17
- {
18
- const line = new Line(paths[i]);
19
- this.paths.push(line);
20
- this.add(line);
21
- }
22
- }
23
- }
24
-
25
- export { MultiLinePath };
@@ -1,65 +0,0 @@
1
- import { Text2D } from './Text2D';
2
-
3
- import { Object3D, Vector2 } from 'three';
4
-
5
- class MultiLineText2D extends Object3D
6
- {
7
- text_array: Text2D[];
8
-
9
- constructor(text_array: string[], font?: string, color?: string | number, pivot?: Vector2, is_static?: boolean)
10
- {
11
- super();
12
-
13
- font = font || '200px Arial';
14
- color = color || '#000000';
15
- pivot = pivot || new Vector2();
16
-
17
- this.text_array = [];
18
-
19
- for (let i = 0; i < text_array.length; i++)
20
- {
21
- const text2D = new Text2D(text_array[i], font, color, pivot);
22
- this.text_array.push(text2D);
23
- this.add(text2D);
24
- }
25
-
26
- this.update_text_positions();
27
- }
28
-
29
- update_text_positions()
30
- {
31
- for (let i = 0; i < this.text_array.length; i++)
32
- {
33
- this.text_array[i].position.y = -this.text_array[i].size.y * i;
34
- }
35
- }
36
-
37
- set texts(text_array)
38
- {
39
- for (let i = 0; i < this.text_array.length; i++)
40
- {
41
- this.text_array[i].text = text_array[i];
42
- }
43
- }
44
-
45
- set size(value)
46
- {
47
- for (let i = 0; i < this.text_array.length; i++)
48
- {
49
- this.text_array[i].size.set(value, value, value);
50
- }
51
- this.update_text_positions();
52
- }
53
-
54
- get texts(): string[]
55
- {
56
- return [];
57
- }
58
-
59
- get size()
60
- {
61
- return 1;
62
- }
63
- }
64
-
65
- export { MultiLineText2D };
@@ -1,42 +0,0 @@
1
- import { GeometryEdgeVisualizer } from './GeometryEdgeVisualizer';
2
-
3
- import type { Vector2 } from 'three';
4
- import { Mesh, MeshBasicMaterial, Shape, ShapeGeometry } from 'three';
5
-
6
- class Shape2D extends Mesh
7
- {
8
- constructor(points_2D: Vector2[], show_edges: boolean)
9
- {
10
- const shape = new Shape(points_2D);
11
- const geometry = new ShapeGeometry(shape);
12
- geometry.rotateX(3.14 / 2);
13
-
14
- const material = new MeshBasicMaterial({ color: 0xff0000 });
15
- super(geometry, material);
16
- this.invert_normals(geometry);
17
-
18
- if (show_edges)
19
- {
20
- const edge_mesh = new GeometryEdgeVisualizer(geometry);
21
- edge_mesh.hide_faces();
22
- edge_mesh.material.depthTest = false;
23
- this.add(edge_mesh);
24
- }
25
- }
26
-
27
- invert_normals(geometry: ShapeGeometry)
28
- {
29
- const indices = geometry.index.array;
30
- for (let i = 0; i < indices.length; i += 3)
31
- {
32
- const x = indices[i + 0];
33
- const z = indices[i + 2];
34
-
35
- indices[i + 0] = z;
36
- indices[i + 2] = x;
37
- }
38
- geometry.computeVertexNormals();
39
- }
40
- }
41
-
42
- export { Shape2D };
@@ -1,38 +0,0 @@
1
- import { GeometryEdgeVisualizer } from './GeometryEdgeVisualizer';
2
-
3
- import type { Vector2 } from 'three';
4
- import { ExtrudeGeometry, Mesh, MeshNormalMaterial, Shape } from 'three';
5
-
6
- class Shape3D extends Mesh
7
- {
8
- constructor(points_2D: Vector2[], show_edges: boolean, height?: number)
9
- {
10
- const shape = new Shape(points_2D);
11
- height = height || 1;
12
-
13
- const extrudeSettings = {
14
- steps: 2,
15
- depth: height,
16
- bevelEnabled: false,
17
- bevelThickness: 1,
18
- bevelSize: 1,
19
- bevelSegments: 1
20
- };
21
-
22
- const geometry = new ExtrudeGeometry(shape, extrudeSettings);
23
- geometry.rotateX(3.14 / 2);
24
- geometry.translate(0, height, 0);
25
-
26
- const material = new MeshNormalMaterial();
27
- super(geometry, material);
28
-
29
- if (show_edges)
30
- {
31
- const edge_mesh = new GeometryEdgeVisualizer(geometry, '#FF0000');
32
- edge_mesh.hide_faces();
33
- this.add(edge_mesh);
34
- }
35
- }
36
- }
37
-
38
- export { Shape3D };
@@ -1,122 +0,0 @@
1
- import { BufferAttribute, BufferGeometry, InstancedBufferAttribute, InstancedBufferGeometry, Mesh, Object3D, PlaneGeometry, Points, Scene } from 'three';
2
- import { ParticleAttribute } from './ParticleAttribute';
3
-
4
- class GPUParticleSystem extends Object3D
5
- {
6
- attribute_writter_mesh: Points;
7
- attribute_writter_scene: Scene;
8
- attributes: ParticleAttribute[];
9
- mesh: Mesh;
10
-
11
- constructor(particle_count: number, material: any)
12
- {
13
- super();
14
- this.attributes = [];
15
-
16
- this.mesh = this.build_point_mesh(particle_count, material);
17
- this.add(this.mesh);
18
-
19
- this.attribute_writter_mesh = this.build_attribute_writter_mesh(particle_count);
20
- this.attribute_writter_scene = new Scene();
21
- this.attribute_writter_scene.add(this.attribute_writter_mesh);
22
- }
23
-
24
- add_texture_attribute(buffer_attribute: ParticleAttribute)
25
- {
26
- this.attributes.push(buffer_attribute);
27
- }
28
-
29
- add_update_attribute_array(name: string, array: Float32Array, item_size: number)
30
- {
31
- this.attribute_writter_mesh.geometry.setAttribute(name, new BufferAttribute(array, item_size, false));
32
- }
33
-
34
- add_attribute_array(name: string, array: Float32Array, item_size: number)
35
- {
36
- this.mesh.geometry.setAttribute(name, new InstancedBufferAttribute(array, item_size, false));
37
- }
38
-
39
- update()
40
- {
41
- const mat = this.mesh.material;
42
-
43
- if (Array.isArray(mat)) {
44
- mat.forEach(m => m.dispose());
45
- } else {
46
- mat.dispose();
47
- }
48
-
49
- for (let i = 0; i < this.attributes.length; i++)
50
- {
51
- this.attributes[i].update(this.attribute_writter_scene);
52
- }
53
- }
54
-
55
- dispose()
56
- {
57
- this.mesh.geometry.dispose();
58
-
59
- const mat = this.mesh.material;
60
-
61
- if (Array.isArray(mat)) {
62
- mat.forEach(m => m.dispose());
63
- } else {
64
- mat.dispose();
65
- }
66
- }
67
-
68
- build_point_mesh(instance_count = 1, material: any)
69
- {
70
- const geo = new PlaneGeometry();
71
-
72
- const instanced_geo = new InstancedBufferGeometry();
73
- instanced_geo.setAttribute('position', geo.getAttribute('position'));
74
- instanced_geo.index = geo.index;
75
-
76
- instanced_geo.setAttribute('storage_uv', this.build_uv_storage_attribute(instance_count));
77
- instanced_geo.instanceCount = instance_count;
78
- const mesh = new Mesh(instanced_geo, material);
79
- mesh.frustumCulled = false;
80
- return mesh;
81
- }
82
-
83
- build_attribute_writter_mesh(particle_count: any)
84
- {
85
- const { width, height } = ParticleAttribute.calculate_resolution(particle_count);
86
-
87
- const uvs = new Float32Array(particle_count * 3);
88
-
89
- for (let i = 0; i < particle_count; i++)
90
- {
91
- const x = i % width;
92
- const y = Math.floor(i / width);
93
- uvs[i * 3 + 0] = (x + 0.5) / width;
94
- uvs[i * 3 + 1] = (y + 0.5) / height;
95
- uvs[i * 3 + 2] = i;
96
- }
97
- const geo = new BufferGeometry();
98
- geo.setAttribute('position', new BufferAttribute(uvs, 3, false));
99
-
100
- const points = new Points(geo);
101
- points.frustumCulled = false;
102
- return points;
103
- }
104
-
105
- build_uv_storage_attribute(particle_count: any)
106
- {
107
- const { width, height } = ParticleAttribute.calculate_resolution(particle_count);
108
-
109
- const uvs = new Float32Array(particle_count * 2);
110
-
111
- for (let i = 0; i < particle_count; i++)
112
- {
113
- const x = i % width;
114
- const y = Math.floor(i / width);
115
- uvs[i * 2 + 0] = (x + 0.5) / width;
116
- uvs[i * 2 + 1] = (y + 0.5) / height;
117
- }
118
- return new InstancedBufferAttribute(uvs, 2, false);
119
- }
120
- }
121
-
122
- export { GPUParticleSystem };
@@ -1,110 +0,0 @@
1
- import { Graphics } from '../Graphics';
2
-
3
- import type { BufferAttribute, BufferGeometry, Scene } from 'three';
4
- import { FloatType, HalfFloatType, Mesh, NearestFilter, NoColorSpace, RenderTarget, RGBAFormat } from 'three';
5
- import { Capabilities } from '../Capabilities';
6
-
7
- class ParticleAttribute
8
- {
9
- name: any;
10
- read: RenderTarget;
11
- update_material: any;
12
- write: RenderTarget;
13
-
14
- constructor(attr_name: string, update_material: any)
15
- {
16
- this.read = undefined;
17
- this.write = undefined;
18
-
19
- this.name = attr_name;
20
-
21
- this.update_material = update_material;
22
- }
23
-
24
- init_from_geometry(geometry: BufferGeometry)
25
- {
26
- // overrided by inheritance
27
- }
28
-
29
- init_from_attribute(particle_attribute: ParticleAttribute)
30
- {
31
-
32
- }
33
-
34
- build_RT(particle_count: number)
35
- {
36
- const resolution = ParticleAttribute.calculate_resolution(particle_count);
37
- const options = {
38
- minFilter: NearestFilter,
39
- magFilter: NearestFilter,
40
- format: RGBAFormat,
41
- colorScape: NoColorSpace,
42
- type: Capabilities.fp_textures_available ? FloatType : HalfFloatType,
43
- stencilBuffer: false,
44
- depthBuffer: false
45
- };
46
-
47
- return new RenderTarget(resolution.width, resolution.height, options);
48
- }
49
-
50
- static calculate_resolution(particle_count: number)
51
- {
52
- const width = Math.min(particle_count, 512);
53
- const height = Math.max(1, Math.ceil(particle_count / width));
54
- return { width, height };
55
- }
56
-
57
- swap_RT()
58
- {
59
- const tmp = this.read;
60
- this.read = this.write;
61
- this.write = tmp;
62
- }
63
-
64
- update(attribute_writter_scene: Scene)
65
- {
66
- if (this.update_material)
67
- {
68
- this.update_material.update();
69
-
70
- if (attribute_writter_scene.children[0] instanceof Mesh)
71
- {
72
- attribute_writter_scene.children[0].material = this.update_material;
73
- }
74
-
75
- this.update_material.uniforms._MainTex.value = this.read.texture;
76
- Graphics.render(attribute_writter_scene, undefined, this.write);
77
-
78
- if (attribute_writter_scene.children[0] instanceof Mesh)
79
- {
80
- attribute_writter_scene.children[0].material = undefined;
81
- }
82
-
83
- this.swap_RT();
84
- }
85
- }
86
-
87
- store_geometry_attribute_in_RT(attribute: BufferAttribute, RT: RenderTarget, storage_material: any, attribute_writter_scene: Scene)
88
- {
89
- if (attribute_writter_scene.children[0] instanceof Mesh)
90
- {
91
- attribute_writter_scene.children[0].geometry.setAttribute('data', attribute);
92
- attribute_writter_scene.children[0].material = storage_material;
93
- }
94
-
95
- Graphics.render(attribute_writter_scene, undefined, RT);
96
-
97
- if (attribute_writter_scene.children[0] instanceof Mesh)
98
- {
99
- attribute_writter_scene.children[0].geometry.deleteAttribute('data');
100
- attribute_writter_scene.children[0].material = undefined;
101
- }
102
- }
103
-
104
- get_texture()
105
- {
106
- return this.read.texture;
107
- }
108
- }
109
-
110
- export { ParticleAttribute };
@@ -1,46 +0,0 @@
1
- import type { BufferGeometry, RenderTarget, Scene, Vector3 } from 'three';
2
- import { BufferAttribute } from 'three';
3
-
4
- import { ParticleAttribute } from '../gpu_particles/ParticleAttribute';
5
- import { ParticleStorageMaterial } from '../materials/gpu_particles/ParticleStorageMaterial';
6
-
7
- class ParticlePositionAttribute extends ParticleAttribute
8
- {
9
- read: RenderTarget;
10
- write: RenderTarget;
11
-
12
- constructor(update_material: any)
13
- {
14
- super('_Position', update_material);
15
- }
16
-
17
- store_geometry(geometry: BufferGeometry, attribute_writter_scene: Scene)
18
- {
19
- const pos_attr = geometry.getAttribute('position');
20
- this.read = this.build_RT(pos_attr.count);
21
- this.write = this.build_RT(pos_attr.count);
22
-
23
- const mat = new ParticleStorageMaterial();
24
- this.store_geometry_attribute_in_RT(geometry.getAttribute('position') as BufferAttribute, this.read, mat, attribute_writter_scene);
25
- }
26
-
27
- store_positions(positions: Array<Vector3>, attribute_writter_scene: Scene)
28
- {
29
- this.read = this.build_RT(positions.length);
30
- this.write = this.build_RT(positions.length);
31
-
32
- const arr = new Float32Array(positions.length * 4);
33
-
34
- for (let i = 0; i < positions.length; i++)
35
- {
36
- arr[i * 4 + 0] = positions[i].x;
37
- arr[i * 4 + 1] = positions[i].y;
38
- arr[i * 4 + 2] = positions[i].z;
39
- arr[i * 4 + 3] = (Math.random() * 2 - 1) * 10;
40
- }
41
- const mat = new ParticleStorageMaterial();
42
- this.store_geometry_attribute_in_RT(new BufferAttribute(arr, 4), this.read, mat, attribute_writter_scene);
43
- }
44
- }
45
-
46
- export { ParticlePositionAttribute };
@@ -1,21 +0,0 @@
1
- import { BlitMaterial } from './BlitMaterial';
2
-
3
- import frag from '../shaders/dual_filter_blur/alpha_filter.frag';
4
-
5
- export class AlphaFilterMaterial extends BlitMaterial
6
- {
7
- constructor()
8
- {
9
- super(frag);
10
- }
11
-
12
- set offset(value: number)
13
- {
14
- this.uniforms._Offset.value = value;
15
- }
16
-
17
- get offset(): number
18
- {
19
- return this.uniforms._Offset.value as number;
20
- }
21
- }
@@ -1,20 +0,0 @@
1
- import basic_frag from '../shaders/basic_color/basic_color.frag';
2
- import basic_vert from '../shaders/basic_color/basic_color.vert';
3
-
4
- import { Color, ShaderMaterial } from 'three';
5
-
6
- class BaseShaderMaterial extends ShaderMaterial
7
- {
8
- constructor(vert: string, frag: string, uniforms?: { [uniform: string]: { value: any } })
9
- {
10
- super({
11
- vertexShader: vert || basic_vert,
12
- fragmentShader: frag || basic_frag,
13
- uniforms: uniforms ?? {
14
- _Color: { value: new Color('#FF0000') }
15
- }
16
- });
17
- }
18
- }
19
-
20
- export { BaseShaderMaterial };