@woosh/meep-engine 2.48.19 → 2.48.21

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 (117) hide show
  1. package/package.json +1 -1
  2. package/src/core/binary/type/BinaryDataType.d.ts +15 -0
  3. package/src/{engine/graphics/render/forward_plus/data/computeDataType.js → core/binary/type/computeBinaryDataTypeByPrecision.js} +3 -3
  4. package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +62 -0
  5. package/src/core/graph/layout/computeDisconnectedSubGraphs.js +1 -0
  6. package/src/core/process/task/TaskGroup.js +1 -1
  7. package/src/core/process/task/util/task_tree_compute_leaf_tasks.js +21 -0
  8. package/src/engine/graphics/geometry/AttributeSpec.d.ts +2 -2
  9. package/src/engine/graphics/material/optimization/MaterialOptimizationContext.js +1 -3
  10. package/src/engine/graphics/render/forward_plus/LightManager.js +9 -7
  11. package/src/engine/graphics/{micron/render/instanced → texture}/AttributeDataTexture.js +28 -19
  12. package/src/engine/graphics/{render/forward_plus/data → texture}/TextureBackedMemoryRegion.js +8 -8
  13. package/src/engine/graphics/{render/forward_plus/data → texture}/computeThreeTextureFormat.js +2 -2
  14. package/src/engine/graphics/{render/forward_plus/data → texture}/computeThreeTextureInternalFormatFromDataType.js +1 -1
  15. package/src/engine/graphics/{render/forward_plus/data → texture}/computeThreeTextureTypeFromDataType.js +1 -1
  16. package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.js +1 -1
  17. package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.js +1 -3
  18. package/src/generation/GridTaskGroup.js +4 -4
  19. package/src/generation/filtering/numeric/util/populateSampler2DFromCellFilter.js +10 -2
  20. package/src/generation/filtering/numeric/util/sampler_from_filter.js +26 -0
  21. package/src/generation/filtering/numeric/util/visualise_filters_as_grid.js +81 -0
  22. package/src/generation/grid/generation/GridTaskSequence.js +3 -1
  23. package/src/engine/graphics/micron/MICRON_GEOMETRY_FIELD.js +0 -1
  24. package/src/engine/graphics/micron/MICRON_URI_FIELD.js +0 -1
  25. package/src/engine/graphics/micron/build/MICRON_PATCH_SIZE_MAX.js +0 -5
  26. package/src/engine/graphics/micron/build/PatchRepresentation.js +0 -424
  27. package/src/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +0 -311
  28. package/src/engine/graphics/micron/build/build_geometry_info.js +0 -21
  29. package/src/engine/graphics/micron/build/clustering/assignInitialPatchNeighbours.js +0 -63
  30. package/src/engine/graphics/micron/build/clustering/assign_patch_neighbours_from_topology.js +0 -46
  31. package/src/engine/graphics/micron/build/clustering/build_clustering_2.js +0 -37
  32. package/src/engine/graphics/micron/build/clustering/build_leaf_patches.js +0 -326
  33. package/src/engine/graphics/micron/build/clustering/build_leaf_patches_metis.js +0 -76
  34. package/src/engine/graphics/micron/build/clustering/computeBorderLengthChange.js +0 -59
  35. package/src/engine/graphics/micron/build/clustering/computeFaceCurvatureScore.js +0 -57
  36. package/src/engine/graphics/micron/build/clustering/computeOpenFaceFreedom.js +0 -35
  37. package/src/engine/graphics/micron/build/clustering/compute_face_connection_weight.js +0 -35
  38. package/src/engine/graphics/micron/build/clustering/populateOpenFaceNeighboursForPatch.js +0 -56
  39. package/src/engine/graphics/micron/build/clustering/validate_leaf_patch_connectivity.js +0 -44
  40. package/src/engine/graphics/micron/build/compute_micron_buffer_array_constructor.js +0 -24
  41. package/src/engine/graphics/micron/build/compute_vertex_remap_cost.js +0 -29
  42. package/src/engine/graphics/micron/build/debug/build_clustering_info.js +0 -58
  43. package/src/engine/graphics/micron/build/debug/build_graph_info.js +0 -59
  44. package/src/engine/graphics/micron/build/fill_patch_geometry_data.js +0 -270
  45. package/src/engine/graphics/micron/build/hierarchy/buildAbstractPatchHierarchy.js +0 -196
  46. package/src/engine/graphics/micron/build/hierarchy/build_intermediate_patch_topology.js +0 -162
  47. package/src/engine/graphics/micron/build/hierarchy/build_merge_graph.js +0 -89
  48. package/src/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +0 -146
  49. package/src/engine/graphics/micron/build/hierarchy/compute_patches_shared_vertex_count.js +0 -32
  50. package/src/engine/graphics/micron/build/hierarchy/compute_patches_shared_vertices.js +0 -34
  51. package/src/engine/graphics/micron/build/hierarchy/merge_patches.js +0 -581
  52. package/src/engine/graphics/micron/build/hierarchy/metis_cluster_clusters.js +0 -53
  53. package/src/engine/graphics/micron/build/hierarchy/optimize_graph_partitioning_balance.js +0 -515
  54. package/src/engine/graphics/micron/build/hierarchy/patch_combine.js +0 -180
  55. package/src/engine/graphics/micron/build/hierarchy/patch_fill_holes_by_uncollapse.js +0 -60
  56. package/src/engine/graphics/micron/build/hierarchy/patch_stitch_parent_border.js +0 -320
  57. package/src/engine/graphics/micron/build/hierarchy/qvdr_build_simplified_clusters.js +0 -547
  58. package/src/engine/graphics/micron/build/hierarchy/qvdr_build_tree.js +0 -140
  59. package/src/engine/graphics/micron/buildPatchwork.js +0 -68
  60. package/src/engine/graphics/micron/convert_three_object_to_micron.js +0 -179
  61. package/src/engine/graphics/micron/debug/VirtualGeometryStats.js +0 -42
  62. package/src/engine/graphics/micron/format/MICRON_GEOMETRY_PROPERTY_NAME.js +0 -1
  63. package/src/engine/graphics/micron/format/MicronGeometry.d.ts +0 -21
  64. package/src/engine/graphics/micron/format/MicronGeometry.js +0 -334
  65. package/src/engine/graphics/micron/format/MicronGeometryPatch.d.ts +0 -3
  66. package/src/engine/graphics/micron/format/MicronGeometryPatch.js +0 -205
  67. package/src/engine/graphics/micron/format/MicronGeometryPatchOccurance.js +0 -50
  68. package/src/engine/graphics/micron/format/ThreeMicronMesh.d.ts +0 -10
  69. package/src/engine/graphics/micron/format/ThreeMicronMesh.js +0 -45
  70. package/src/engine/graphics/micron/format/VirtualGeometry.js +0 -158
  71. package/src/engine/graphics/micron/format/micron_build_proxy_geometry.js +0 -205
  72. package/src/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +0 -123
  73. package/src/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.spec.js +0 -63
  74. package/src/engine/graphics/micron/format/serialization/collection/geometry_collection_serialization.js +0 -83
  75. package/src/engine/graphics/micron/format/serialization/collection/geometry_collection_serialization.spec.js +0 -51
  76. package/src/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +0 -25
  77. package/src/engine/graphics/micron/format/serialization/deserialize_patch.js +0 -106
  78. package/src/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +0 -18
  79. package/src/engine/graphics/micron/format/serialization/serialize_patch.js +0 -84
  80. package/src/engine/graphics/micron/format/validate_patch_bounds.js +0 -69
  81. package/src/engine/graphics/micron/plugin/GLTFAssetTransformer.js +0 -265
  82. package/src/engine/graphics/micron/plugin/GLTF_MICRON_ID_FIELD.js +0 -5
  83. package/src/engine/graphics/micron/plugin/MicronRenderPlugin.d.ts +0 -8
  84. package/src/engine/graphics/micron/plugin/MicronRenderPlugin.js +0 -150
  85. package/src/engine/graphics/micron/plugin/serialization/BufferGeometrySerializationAdapter.js +0 -176
  86. package/src/engine/graphics/micron/plugin/shaded_geometry/MicronShadedGeometryRenderAdapter.js +0 -216
  87. package/src/engine/graphics/micron/prototypeMicronProxyBuild.js +0 -227
  88. package/src/engine/graphics/micron/prototypeVirtualGeometry.js +0 -911
  89. package/src/engine/graphics/micron/render/PatchCacheKey.js +0 -79
  90. package/src/engine/graphics/micron/render/VIRTUAL_MESH_FLAG.d.ts +0 -1
  91. package/src/engine/graphics/micron/render/VIRTUAL_MESH_FLAG.js +0 -1
  92. package/src/engine/graphics/micron/render/VirtualGeometryBuilder.js +0 -207
  93. package/src/engine/graphics/micron/render/approximateTriangleArea.js +0 -25
  94. package/src/engine/graphics/micron/render/culling/PatchCullingSystem.js +0 -129
  95. package/src/engine/graphics/micron/render/instanced/PatchDataTextures.js +0 -325
  96. package/src/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -175
  97. package/src/engine/graphics/micron/render/instanced/shader/constants.js +0 -3
  98. package/src/engine/graphics/micron/render/instanced/shader/gen_micron_vertex_attribute_texture_name.js +0 -8
  99. package/src/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +0 -250
  100. package/src/engine/graphics/micron/render/makeThreeMeshFromVirtualGeometry.js +0 -37
  101. package/src/engine/graphics/micron/render/refinement/ActivePatchFlags.js +0 -8
  102. package/src/engine/graphics/micron/render/refinement/ActivePatchList.js +0 -241
  103. package/src/engine/graphics/micron/render/refinement/ActivePatchRecord.js +0 -154
  104. package/src/engine/graphics/micron/render/refinement/RefinementSpec.js +0 -84
  105. package/src/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +0 -133
  106. package/src/engine/graphics/micron/render/refinement/is_patch_facing_back.js +0 -43
  107. package/src/engine/graphics/micron/render/refinement/is_patch_visible.js +0 -37
  108. package/src/engine/graphics/micron/render/v1/MaterialContext.js +0 -150
  109. package/src/engine/graphics/micron/render/v1/MaterialVertexSpec.js +0 -115
  110. package/src/engine/graphics/micron/render/v1/MicronRenderContext.js +0 -145
  111. package/src/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +0 -255
  112. package/src/engine/graphics/micron/render/v1/VGThreeRenderer.js +0 -142
  113. package/src/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +0 -54
  114. package/src/engine/graphics/micron/simplifyGeometry.js +0 -26
  115. package/src/engine/graphics/micron/util/patchToBufferGeometry.js +0 -19
  116. /package/src/{engine/graphics/render/forward_plus/data → core/math}/NumericType.js +0 -0
  117. /package/src/engine/graphics/{render/forward_plus/data → texture}/channelCountToThreIntegerTextureType.js +0 -0
@@ -1,255 +0,0 @@
1
- import { BufferAttribute, BufferGeometry, DynamicDrawUsage } from "three";
2
- import Signal from "../../../../../core/events/signal/Signal.js";
3
- import {
4
- DataType2TypedArrayConstructorMapping
5
- } from "../../../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
6
- import { getTransformedPositionsCached } from "./getTransformedPositionsCached.js";
7
- import { Color } from "../../../../../core/color/Color.js";
8
- import { seededRandom } from "../../../../../core/math/random/seededRandom.js";
9
- import { randomFloatBetween } from "../../../../../core/math/random/randomFloatBetween.js";
10
-
11
-
12
- const scratch_random = seededRandom(0);
13
- const scratch_color = new Color();
14
-
15
- export class ThreeVirtualGeometryAdapter {
16
- constructor() {
17
- this.buffer_geometry = new BufferGeometry();
18
-
19
- this.__vertex_capacity = -1;
20
- this.__face_capacity = -1;
21
-
22
- /**
23
- *
24
- * @type {VertexDataSpec}
25
- * @private
26
- */
27
- this.__vertex_spec = null;
28
-
29
- /**
30
- *
31
- * @type {Signal}
32
- */
33
- this.onRebuild = new Signal();
34
-
35
- /**
36
- *
37
- * @type {boolean}
38
- * @private
39
- */
40
- this.__enable_debug_attribute_patch_vertex_color = true;
41
- }
42
-
43
- /**
44
- *
45
- * @param {number} vertex_count
46
- * @param {number} face_count
47
- */
48
- resizeGeometry(vertex_count, face_count) {
49
- if (this.__face_capacity < face_count || this.__vertex_capacity < vertex_count) {
50
-
51
-
52
- this.rebuildBufferGeometry(vertex_count, face_count);
53
- }
54
- this.buffer_geometry.setDrawRange(0, face_count * 3);
55
- }
56
-
57
- /**
58
- *
59
- * @param {number} vertex_count
60
- * @param {number} face_count
61
- */
62
- rebuildBufferGeometry(vertex_count, face_count) {
63
-
64
- this.buffer_geometry.dispose();
65
-
66
- const geometry = new BufferGeometry();
67
-
68
- const index_buffer = new BufferAttribute(new Uint32Array(face_count * 3), 1, false);
69
- index_buffer.setUsage(DynamicDrawUsage);
70
- geometry.setIndex(index_buffer);
71
-
72
- const vertexSpec = this.__vertex_spec;
73
- const vertexAttributeSpecs = vertexSpec.attributes;
74
-
75
- for (let i = 0; i < vertexAttributeSpecs.length; i++) {
76
- const attribute_spec = vertexAttributeSpecs[i];
77
-
78
- const array = new DataType2TypedArrayConstructorMapping[attribute_spec.type](vertex_count * attribute_spec.itemSize);
79
-
80
- const attribute = new BufferAttribute(array, attribute_spec.itemSize, attribute_spec.normalized);
81
- attribute.setUsage(DynamicDrawUsage);
82
-
83
- geometry.setAttribute(attribute_spec.name, attribute);
84
- }
85
-
86
- if (this.__enable_debug_attribute_patch_vertex_color) {
87
- //
88
- const colors_array = new Uint8Array(vertex_count * 3);
89
- geometry.setAttribute('color', new BufferAttribute(colors_array, 3, true));
90
- }
91
-
92
- this.__face_capacity = face_count;
93
- this.__vertex_capacity = vertex_count;
94
-
95
- this.buffer_geometry = geometry;
96
-
97
- this.onRebuild.send0();
98
- }
99
-
100
-
101
- /**
102
- *
103
- * @param {VirtualGeometry} vg
104
- */
105
- build(vg) {
106
- const face_count = vg.computeFaceCount();
107
- const vertex_count = vg.computeVertexCount();
108
-
109
- this.resizeGeometry(vertex_count, face_count);
110
-
111
- const geometry = this.buffer_geometry;
112
-
113
- const attribute_index = geometry.getIndex();
114
- attribute_index.needsUpdate = true;
115
- attribute_index.updateRange.offset = 0;
116
- attribute_index.updateRange.count = face_count * 3;
117
-
118
-
119
- const vertex_attribute_specs = this.__vertex_spec.attributes;
120
- const vertex_attribute_spec_count = vertex_attribute_specs.length;
121
-
122
- // map attributes by index for faster access
123
- const geometry_attributes = [];
124
- for (let i = 0; i < vertex_attribute_specs.length; i++) {
125
- const attributeSpec = vertex_attribute_specs[i];
126
- const geometry_attribute = geometry.getAttribute(attributeSpec.name);
127
- geometry_attribute.needsUpdate = true;
128
- geometry_attribute.updateRange.offset = 0;
129
- geometry_attribute.updateRange.count = vertex_count * geometry_attribute.itemSize;
130
-
131
- geometry_attributes.push(geometry_attribute);
132
- }
133
-
134
- // populate
135
- let face_cursor = 0;
136
- let vertex_cursor = 0;
137
-
138
- /*
139
- WebGL offers gl_VertexID attribute: https://webgl2fundamentals.org/webgl/lessons/webgl-drawing-without-data.html
140
- can use gl_VertexID to figure out which patch a triangle/vertex belongs to
141
- inside transform shader, apply matrix transform to the patch geometry
142
- can use textures to store some extra data if we don't want to touch geometry unnecessarily
143
- */
144
- // TODO do a transform feedback pass, store patch info in a texture
145
-
146
- const patches = vg.patches;
147
- const patch_count = vg.patch_count;
148
-
149
- const destination_index_attribute_array = attribute_index.array;
150
-
151
- // fill indices
152
- for (let patch_index = 0; patch_index < patch_count; patch_index++) {
153
- const occurrence = patches[patch_index];
154
-
155
- const patch = occurrence.patch;
156
- const patch_face_count = patch.polygon_count;
157
- const patch_vertex_count = patch.vertex_count;
158
- const face_indices = patch.face_indices;
159
-
160
- const patch_index_size = patch_face_count * 3;
161
- const face_cursor_3 = face_cursor * 3;
162
-
163
- for (let i = 0; i < patch_index_size; i++) {
164
- const source_vertex_index = face_indices[i];
165
- const remapped_vertex_index = source_vertex_index + vertex_cursor;
166
-
167
- destination_index_attribute_array[face_cursor_3 + i] = remapped_vertex_index;
168
- }
169
-
170
- face_cursor += patch_face_count;
171
- vertex_cursor += patch_vertex_count;
172
- }
173
-
174
- for (let i = 0; i < vertex_attribute_spec_count; i++) {
175
- const attributeSpec = vertex_attribute_specs[i];
176
-
177
- const itemSize = attributeSpec.itemSize;
178
-
179
- const geometryAttribute = geometry_attributes[i];
180
-
181
-
182
- const destination_attribute_array = geometryAttribute.array;
183
- vertex_cursor = 0;
184
-
185
- for (let patch_index = 0; patch_index < patch_count; patch_index++) {
186
- const occurrence = patches[patch_index];
187
-
188
- const patch = occurrence.patch;
189
-
190
- const patch_vertex_count = patch.vertex_count;
191
-
192
- const vertex_array_start_offset = vertex_cursor * itemSize;
193
-
194
- // fill vertex data
195
- const source_attribute_array = patch.vertex_attribute_arrays[i];
196
-
197
- let transformed_attribute_array;
198
- if (attributeSpec.name === 'position') {
199
- transformed_attribute_array = getTransformedPositionsCached(occurrence, i);
200
- } else {
201
- transformed_attribute_array = source_attribute_array;
202
- }
203
-
204
- destination_attribute_array.set(transformed_attribute_array, vertex_array_start_offset);
205
-
206
- // update cursors
207
- vertex_cursor += patch_vertex_count;
208
- }
209
-
210
-
211
- }
212
-
213
-
214
- if (this.__enable_debug_attribute_patch_vertex_color) {
215
- vertex_cursor = 0;
216
- const color_attribute = geometry.getAttribute('color');
217
- const colors_array = color_attribute.array;
218
-
219
- for (let patch_index = 0; patch_index < patch_count; patch_index++) {
220
- const occurrence = patches[patch_index];
221
-
222
- const patch = occurrence.patch;
223
-
224
- const patch_vertex_count = patch.vertex_count;
225
-
226
- const vertex_array_start_offset = vertex_cursor * 3;
227
-
228
- // compute color
229
-
230
- scratch_random.setCurrentSeed(occurrence.hash());
231
-
232
- scratch_color.setHSL(scratch_random(), randomFloatBetween(scratch_random, 0.5, 0.9), 0.5);
233
-
234
- const r = Math.round(scratch_color.r * 255);
235
- const g = Math.round(scratch_color.g * 255);
236
- const b = Math.round(scratch_color.b * 255);
237
-
238
- for (let i = 0; i < patch_vertex_count; i++) {
239
- const i3 = i * 3 + vertex_array_start_offset;
240
- colors_array[i3] = r;
241
- colors_array[i3 + 1] = g;
242
- colors_array[i3 + 2] = b;
243
- }
244
- // update cursors
245
- vertex_cursor += patch_vertex_count;
246
- }
247
-
248
- color_attribute.needsUpdate = true;
249
- color_attribute.updateRange.offset = 0;
250
- color_attribute.updateRange.count = vertex_count * 3;
251
-
252
- }
253
-
254
- }
255
- }
@@ -1,142 +0,0 @@
1
- import Vector2 from "../../../../../core/geom/Vector2.js";
2
- import { MaterialContext } from "./MaterialContext.js";
3
- import { array_copy } from "../../../../../core/collection/array/copyArray.js";
4
- import { MicronRenderContext } from "./MicronRenderContext.js";
5
- import { MaterialVertexSpec, MaterialVertexSpecFlags } from "./MaterialVertexSpec.js";
6
-
7
- /**
8
- *
9
- * @type {MaterialVertexSpec}
10
- */
11
- const scratch_mvc = new MaterialVertexSpec();
12
-
13
- export class VGThreeRenderer {
14
- constructor() {
15
- /**
16
- *
17
- * @type {Object3D[]}
18
- * @private
19
- */
20
- this.__inputs = [];
21
-
22
- this.ctx = new MicronRenderContext();
23
-
24
- this.on = {
25
- /**
26
- * @type {Signal<MaterialContext>}
27
- */
28
- contextAdded: this.ctx.on.contextAdded
29
- };
30
- }
31
-
32
- get geometry() {
33
- return this.ctx.geometry;
34
- }
35
-
36
- /**
37
- * Enable/disable wireframe rendering
38
- * @param {boolean} x
39
- */
40
- set wireframe(x) {
41
- this.ctx.wireframe = x;
42
- }
43
-
44
- /**
45
- *
46
- * @param {THREE.Scene} scene
47
- */
48
- attach(scene) {
49
- this.__inputs.push(scene);
50
- this.ctx.builder.appendToScene([scene]);
51
- }
52
-
53
- attachMany(objects, object_count = objects.length) {
54
- array_copy(objects, 0, this.__inputs, this.__inputs.length, objects.length);
55
- this.ctx.builder.appendToScene(objects);
56
- }
57
-
58
- clear() {
59
- this.__inputs = [];
60
- this.ctx.builder.clearScene();
61
- }
62
-
63
- __prepare_contexts() {
64
- // clear contexts
65
- const render_context = this.ctx;
66
- const contexts = render_context.__contexts_array;
67
- const context_count = contexts.length;
68
-
69
- for (let i = 0; i < context_count; i++) {
70
- const ctx = contexts[i];
71
-
72
- ctx.instances.clear();
73
- }
74
-
75
- const processObject = (o) => {
76
- if (o.isMicronMesh) {
77
- /**
78
- *
79
- * @type {ThreeMicronMesh}
80
- */
81
- const m = o;
82
-
83
- scratch_mvc.material = m.material;
84
- scratch_mvc.spec = m.geometry.vertex_spec;
85
- scratch_mvc.writeFlag(MaterialVertexSpecFlags.CastShadow, m.castShadow);
86
- scratch_mvc.writeFlag(MaterialVertexSpecFlags.ReceiveShadow, m.receiveShadow);
87
-
88
- const ctx = render_context.obtain_material(scratch_mvc);
89
-
90
- ctx.instances.add(o.instance_id);
91
- }
92
- };
93
-
94
- const inputs = this.__inputs;
95
- const input_count = inputs.length;
96
-
97
- for (let i = 0; i < input_count; i++) {
98
- const input_object = inputs[i];
99
-
100
- input_object.traverse(processObject);
101
- }
102
-
103
- }
104
-
105
- render() {
106
- this.ctx.render();
107
- }
108
-
109
-
110
- /**
111
- *
112
- * @param {THREE.WebGLRenderer} renderer
113
- * @param {THREE.PerspectiveCamera|THREE.OrthographicCamera|THREE.Camera} camera
114
- */
115
- update(renderer, camera) {
116
- this.__prepare_contexts();
117
-
118
- const resolution = new Vector2();
119
- let pixelRatio = 1;
120
-
121
- /**
122
- *
123
- * @type {THREE.RenderTarget}
124
- */
125
- const render_target = renderer.getRenderTarget();
126
-
127
- if (render_target !== null) {
128
- resolution.set(render_target.width, render_target.height);
129
- } else {
130
- renderer.getSize(resolution);
131
- pixelRatio = renderer.getPixelRatio();
132
- }
133
-
134
- const vg_builder = this.ctx.builder;
135
-
136
- vg_builder.resolution.set(resolution.x * pixelRatio, resolution.y * pixelRatio);
137
- vg_builder.setMatricesFromCamera(camera);
138
- vg_builder.setOutput(this.ctx.geometry);
139
-
140
- vg_builder.build();
141
- }
142
- }
@@ -1,54 +0,0 @@
1
- import { PatchCacheKey } from "../PatchCacheKey.js";
2
- import { apply_mat4_transform_to_v3_array } from "../../../../../core/geom/3d/apply_mat4_transform_to_v3_array.js";
3
- import { Cache } from "../../../../../core/cache/Cache.js";
4
- import { invokeObjectHash } from "../../../../../core/model/object/invokeObjectHash.js";
5
- import { invokeObjectEquals } from "../../../../../core/model/object/invokeObjectEquals.js";
6
-
7
- /**
8
- *
9
- * @type {Cache<PatchCacheKey, Float32Array>}
10
- */
11
- export const transformed_position_cache = new Cache({
12
- keyHashFunction: invokeObjectHash,
13
- keyEqualityFunction: invokeObjectEquals,
14
- valueWeigher(array) {
15
- return array.length * 4
16
- },
17
- maxWeight: 100 * 1024 * 1024 //100Mb
18
- });
19
- transformed_position_cache.onEvicted.add(PatchCacheKey.pool.release, PatchCacheKey.pool);
20
- const scratch_cache_key = new PatchCacheKey();
21
-
22
- /**
23
- *
24
- * @param {MicronGeometryPatchOccurrence} occurrence
25
- * @param {number} attribute_index
26
- * @returns {Float32Array}
27
- */
28
- export function getTransformedPositionsCached(occurrence, attribute_index) {
29
- // we assume that cache misses will be less frequent, so we use an additional fixed key for faster cache queries
30
- scratch_cache_key.fromPatchOccurrence(occurrence);
31
-
32
- const existing = transformed_position_cache.get(scratch_cache_key);
33
-
34
- if (existing !== null) {
35
- // cache hit
36
- return existing;
37
- }
38
-
39
- // create key to be stored in cache
40
- const key = PatchCacheKey.pool.get();
41
- key.copy(scratch_cache_key);
42
-
43
- const patch = occurrence.patch;
44
- const source_array = patch.vertex_attribute_arrays[attribute_index];
45
-
46
- const destination = new Float32Array(source_array.length);
47
-
48
- apply_mat4_transform_to_v3_array(source_array, 0, destination, 0, patch.vertex_count, occurrence.transform.elements);
49
-
50
- // store in cache
51
- transformed_position_cache.put(key, destination);
52
-
53
- return destination;
54
- }
@@ -1,26 +0,0 @@
1
- import { TopoMesh } from "../../../core/geom/3d/topology/struct/TopoMesh.js";
2
- import { simplifyTopoMesh } from "../../../core/geom/3d/topology/simplify/simplifyTopoMesh.js";
3
- import {
4
- topo_mesh_to_three_buffer_geometry
5
- } from "../../../core/geom/3d/topology/topo_mesh_to_three_buffer_geometry.js";
6
-
7
- /**
8
- *
9
- * @param {BufferGeometry} input
10
- * @param {number} target
11
- * @return {BufferGeometry}
12
- */
13
- function simplifyGeometry(input, target) {
14
- const position_attribute = input.getAttribute("position");
15
- const index_attribute = input.index;
16
-
17
- const topo = new TopoMesh();
18
-
19
- topo.build(position_attribute.array, index_attribute.array);
20
-
21
- // expandConnectivityByLocality(topo);
22
-
23
- simplifyTopoMesh(topo, target);
24
-
25
- return topo_mesh_to_three_buffer_geometry(topo);
26
- }
@@ -1,19 +0,0 @@
1
- import { BufferAttribute, BufferGeometry, InterleavedBuffer, InterleavedBufferAttribute } from "three";
2
-
3
- /**
4
- *
5
- * @param {MicronGeometryPatch} patch
6
- * @returns {BufferGeometry}
7
- */
8
- export function patchToBufferGeometry(patch) {
9
- const geometry = new BufferGeometry();
10
-
11
- geometry.setIndex(new BufferAttribute(patch.face_indices, 1, false))
12
-
13
- const interleavedBuffer = new InterleavedBuffer(new Float32Array(patch.vertex_attribute_data), 3);
14
- const position_attribute = new InterleavedBufferAttribute(interleavedBuffer, 3, 0, false);
15
- geometry.setAttribute("position", position_attribute);
16
- geometry.computeVertexNormals();
17
-
18
- return geometry;
19
- }