@woosh/meep-engine 2.48.20 → 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 (94) hide show
  1. package/package.json +1 -1
  2. package/src/engine/graphics/micron/MICRON_GEOMETRY_FIELD.js +0 -1
  3. package/src/engine/graphics/micron/MICRON_URI_FIELD.js +0 -1
  4. package/src/engine/graphics/micron/build/MICRON_PATCH_SIZE_MAX.js +0 -5
  5. package/src/engine/graphics/micron/build/PatchRepresentation.js +0 -424
  6. package/src/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +0 -311
  7. package/src/engine/graphics/micron/build/build_geometry_info.js +0 -21
  8. package/src/engine/graphics/micron/build/clustering/assignInitialPatchNeighbours.js +0 -63
  9. package/src/engine/graphics/micron/build/clustering/assign_patch_neighbours_from_topology.js +0 -46
  10. package/src/engine/graphics/micron/build/clustering/build_clustering_2.js +0 -37
  11. package/src/engine/graphics/micron/build/clustering/build_leaf_patches.js +0 -326
  12. package/src/engine/graphics/micron/build/clustering/build_leaf_patches_metis.js +0 -76
  13. package/src/engine/graphics/micron/build/clustering/computeBorderLengthChange.js +0 -59
  14. package/src/engine/graphics/micron/build/clustering/computeFaceCurvatureScore.js +0 -57
  15. package/src/engine/graphics/micron/build/clustering/computeOpenFaceFreedom.js +0 -35
  16. package/src/engine/graphics/micron/build/clustering/compute_face_connection_weight.js +0 -35
  17. package/src/engine/graphics/micron/build/clustering/populateOpenFaceNeighboursForPatch.js +0 -56
  18. package/src/engine/graphics/micron/build/clustering/validate_leaf_patch_connectivity.js +0 -44
  19. package/src/engine/graphics/micron/build/compute_micron_buffer_array_constructor.js +0 -24
  20. package/src/engine/graphics/micron/build/compute_vertex_remap_cost.js +0 -29
  21. package/src/engine/graphics/micron/build/debug/build_clustering_info.js +0 -58
  22. package/src/engine/graphics/micron/build/debug/build_graph_info.js +0 -59
  23. package/src/engine/graphics/micron/build/fill_patch_geometry_data.js +0 -270
  24. package/src/engine/graphics/micron/build/hierarchy/buildAbstractPatchHierarchy.js +0 -196
  25. package/src/engine/graphics/micron/build/hierarchy/build_intermediate_patch_topology.js +0 -162
  26. package/src/engine/graphics/micron/build/hierarchy/build_merge_graph.js +0 -89
  27. package/src/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +0 -146
  28. package/src/engine/graphics/micron/build/hierarchy/compute_patches_shared_vertex_count.js +0 -32
  29. package/src/engine/graphics/micron/build/hierarchy/compute_patches_shared_vertices.js +0 -34
  30. package/src/engine/graphics/micron/build/hierarchy/merge_patches.js +0 -581
  31. package/src/engine/graphics/micron/build/hierarchy/metis_cluster_clusters.js +0 -53
  32. package/src/engine/graphics/micron/build/hierarchy/optimize_graph_partitioning_balance.js +0 -515
  33. package/src/engine/graphics/micron/build/hierarchy/patch_combine.js +0 -180
  34. package/src/engine/graphics/micron/build/hierarchy/patch_fill_holes_by_uncollapse.js +0 -60
  35. package/src/engine/graphics/micron/build/hierarchy/patch_stitch_parent_border.js +0 -320
  36. package/src/engine/graphics/micron/build/hierarchy/qvdr_build_simplified_clusters.js +0 -547
  37. package/src/engine/graphics/micron/build/hierarchy/qvdr_build_tree.js +0 -140
  38. package/src/engine/graphics/micron/buildPatchwork.js +0 -68
  39. package/src/engine/graphics/micron/convert_three_object_to_micron.js +0 -179
  40. package/src/engine/graphics/micron/debug/VirtualGeometryStats.js +0 -42
  41. package/src/engine/graphics/micron/format/MICRON_GEOMETRY_PROPERTY_NAME.js +0 -1
  42. package/src/engine/graphics/micron/format/MicronGeometry.d.ts +0 -21
  43. package/src/engine/graphics/micron/format/MicronGeometry.js +0 -334
  44. package/src/engine/graphics/micron/format/MicronGeometryPatch.d.ts +0 -3
  45. package/src/engine/graphics/micron/format/MicronGeometryPatch.js +0 -205
  46. package/src/engine/graphics/micron/format/MicronGeometryPatchOccurance.js +0 -50
  47. package/src/engine/graphics/micron/format/ThreeMicronMesh.d.ts +0 -10
  48. package/src/engine/graphics/micron/format/ThreeMicronMesh.js +0 -45
  49. package/src/engine/graphics/micron/format/VirtualGeometry.js +0 -158
  50. package/src/engine/graphics/micron/format/micron_build_proxy_geometry.js +0 -205
  51. package/src/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +0 -123
  52. package/src/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.spec.js +0 -63
  53. package/src/engine/graphics/micron/format/serialization/collection/geometry_collection_serialization.js +0 -83
  54. package/src/engine/graphics/micron/format/serialization/collection/geometry_collection_serialization.spec.js +0 -51
  55. package/src/engine/graphics/micron/format/serialization/deserialize_attribute_spec.js +0 -25
  56. package/src/engine/graphics/micron/format/serialization/deserialize_patch.js +0 -106
  57. package/src/engine/graphics/micron/format/serialization/serialize_attribute_spec.js +0 -18
  58. package/src/engine/graphics/micron/format/serialization/serialize_patch.js +0 -84
  59. package/src/engine/graphics/micron/format/validate_patch_bounds.js +0 -69
  60. package/src/engine/graphics/micron/plugin/GLTFAssetTransformer.js +0 -265
  61. package/src/engine/graphics/micron/plugin/GLTF_MICRON_ID_FIELD.js +0 -5
  62. package/src/engine/graphics/micron/plugin/MicronRenderPlugin.d.ts +0 -8
  63. package/src/engine/graphics/micron/plugin/MicronRenderPlugin.js +0 -150
  64. package/src/engine/graphics/micron/plugin/serialization/BufferGeometrySerializationAdapter.js +0 -176
  65. package/src/engine/graphics/micron/plugin/shaded_geometry/MicronShadedGeometryRenderAdapter.js +0 -216
  66. package/src/engine/graphics/micron/prototypeMicronProxyBuild.js +0 -227
  67. package/src/engine/graphics/micron/prototypeVirtualGeometry.js +0 -911
  68. package/src/engine/graphics/micron/render/PatchCacheKey.js +0 -79
  69. package/src/engine/graphics/micron/render/VIRTUAL_MESH_FLAG.d.ts +0 -1
  70. package/src/engine/graphics/micron/render/VIRTUAL_MESH_FLAG.js +0 -1
  71. package/src/engine/graphics/micron/render/VirtualGeometryBuilder.js +0 -207
  72. package/src/engine/graphics/micron/render/approximateTriangleArea.js +0 -25
  73. package/src/engine/graphics/micron/render/culling/PatchCullingSystem.js +0 -129
  74. package/src/engine/graphics/micron/render/instanced/PatchDataTextures.js +0 -329
  75. package/src/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -175
  76. package/src/engine/graphics/micron/render/instanced/shader/constants.js +0 -3
  77. package/src/engine/graphics/micron/render/instanced/shader/gen_micron_vertex_attribute_texture_name.js +0 -8
  78. package/src/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +0 -250
  79. package/src/engine/graphics/micron/render/makeThreeMeshFromVirtualGeometry.js +0 -37
  80. package/src/engine/graphics/micron/render/refinement/ActivePatchFlags.js +0 -8
  81. package/src/engine/graphics/micron/render/refinement/ActivePatchList.js +0 -241
  82. package/src/engine/graphics/micron/render/refinement/ActivePatchRecord.js +0 -154
  83. package/src/engine/graphics/micron/render/refinement/RefinementSpec.js +0 -84
  84. package/src/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +0 -133
  85. package/src/engine/graphics/micron/render/refinement/is_patch_facing_back.js +0 -43
  86. package/src/engine/graphics/micron/render/refinement/is_patch_visible.js +0 -37
  87. package/src/engine/graphics/micron/render/v1/MaterialContext.js +0 -150
  88. package/src/engine/graphics/micron/render/v1/MaterialVertexSpec.js +0 -115
  89. package/src/engine/graphics/micron/render/v1/MicronRenderContext.js +0 -145
  90. package/src/engine/graphics/micron/render/v1/ThreeVirtualGeometryAdapter.js +0 -255
  91. package/src/engine/graphics/micron/render/v1/VGThreeRenderer.js +0 -142
  92. package/src/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +0 -54
  93. package/src/engine/graphics/micron/simplifyGeometry.js +0 -26
  94. package/src/engine/graphics/micron/util/patchToBufferGeometry.js +0 -19
@@ -1,68 +0,0 @@
1
- import { FrontSide, Group, Mesh, MeshBasicMaterial, MeshStandardMaterial } from "three";
2
- import { patchToBufferGeometry } from "./util/patchToBufferGeometry.js";
3
- import { Color } from "../../../core/color/Color.js";
4
- import { seededRandom } from "../../../core/math/random/seededRandom.js";
5
- import { randomFloatBetween } from "../../../core/math/random/randomFloatBetween.js";
6
-
7
- /**
8
- *
9
- * @param {MicronGeometryPatch[]} patches
10
- * @returns {THREE.Object3D}
11
- */
12
- function buildPatchMesh(patches) {
13
- const group = new Group();
14
-
15
-
16
- const n = patches.length;
17
- for (let i = 0; i < n; i++) {
18
- const patch = patches[i];
19
-
20
- const geometry = patchToBufferGeometry(patch);
21
-
22
- const color = new Color();
23
-
24
- const random = seededRandom(patch.hash());
25
-
26
- color.setHSV(random(), randomFloatBetween(random, 0.5, 0.9), randomFloatBetween(random, 0.7, 1));
27
-
28
- // const material = new MeshBasicMaterial({ color: color.toUint(), wireframe: false, side: FrontSide });
29
- const material = new MeshStandardMaterial({ color: 0xAAAAFF, wireframe: false, side: FrontSide });
30
- // material.polygonOffset = true;
31
- // material.polygonOffsetFactor = 1;
32
- const mesh = new Mesh(geometry, material);
33
-
34
- group.add(mesh);
35
-
36
-
37
- const material_wireframe = new MeshBasicMaterial({
38
- color: 0x000000,
39
- wireframe: true,
40
- side: FrontSide,
41
- polygonOffset: true,
42
- polygonOffsetFactor: -4,
43
- polygonOffsetUnits: 0
44
- });
45
-
46
- // group.add(new Mesh(geometry, material_wireframe));
47
- }
48
-
49
- return group;
50
- }
51
-
52
- /**
53
- *
54
- * @param {MicronGeometry} micron
55
- * @returns {Object3D}
56
- */
57
- function buildPatchwork(micron) {
58
- const patches = [];
59
-
60
- micron.root.traverse(p => {
61
- if (p.lod === 0) {
62
- patches.push(p);
63
- }
64
- });
65
-
66
-
67
- return buildPatchMesh(patches);
68
- }
@@ -1,179 +0,0 @@
1
- import { HashMap } from "../../../core/collection/HashMap.js";
2
- import { computeGeometryHash } from "../geometry/buffered/computeGeometryHash.js";
3
- import { computeGeometryEquality } from "../geometry/buffered/computeGeometryEquality.js";
4
- import { buildMicronGeometryFromBufferGeometry } from "./build/buildMicronGeometryFromBufferGeometry.js";
5
- import { ThreeMicronMesh } from "./format/ThreeMicronMesh.js";
6
- import { AsyncMapWrapper } from "../../../core/collection/map/AsyncMapWrapper.js";
7
- import { MICRON_GEOMETRY_FIELD } from "./MICRON_GEOMETRY_FIELD.js";
8
-
9
- /**
10
- *
11
- * @type {HashMap<THREE.BufferGeometry, MicronGeometry>}
12
- */
13
- const default_micron_cache = new AsyncMapWrapper(new HashMap({
14
- keyHashFunction: computeGeometryHash,
15
- keyEqualityFunction: computeGeometryEquality
16
- }));
17
-
18
- const pending_cache = new HashMap({
19
- keyHashFunction: computeGeometryHash,
20
- keyEqualityFunction: computeGeometryEquality
21
- });
22
-
23
- /**
24
- *
25
- * @param {THREE.Object3D} object
26
- * @param {AbstractAsyncMap<THREE.BufferGeometry, MicronGeometry>} micron_cache
27
- * @returns {THREE.Object3D}
28
- */
29
- export async function convert_three_object_to_micron(object, micron_cache = default_micron_cache) {
30
-
31
- const promises = [];
32
-
33
- /**
34
- *
35
- * @param {THREE.BufferGeometry} g
36
- * @returns {MicronGeometry}
37
- */
38
- async function obtain_geometry(g) {
39
- const attached_micron = g[MICRON_GEOMETRY_FIELD];
40
-
41
- if (attached_micron !== undefined && attached_micron.isMicronGeometry) {
42
- // micron geometry is already attached, use it
43
- return attached_micron;
44
- }
45
-
46
- const cached_micron = await micron_cache.get(g);
47
-
48
-
49
- if (cached_micron !== undefined && cached_micron !== null) {
50
-
51
- // set proxy
52
- cached_micron.proxy = g;
53
-
54
- return cached_micron;
55
- }
56
-
57
- const pending = pending_cache.get(g);
58
-
59
- if (pending !== undefined) {
60
- return await pending;
61
- }
62
-
63
- const micron_geometry_promise = buildMicronGeometryFromBufferGeometry(g);
64
-
65
- pending_cache.set(g, micron_geometry_promise);
66
-
67
- promises.push(micron_geometry_promise);
68
-
69
- /**
70
- *
71
- * @type {MicronGeometry}
72
- */
73
- const micron_geometry = await micron_geometry_promise;
74
-
75
- micron_geometry.proxy = g;
76
-
77
- await micron_cache.set(g, micron_geometry);
78
-
79
- return micron_geometry;
80
- }
81
-
82
-
83
- /**
84
- *
85
- * @param {THREE.Mesh} mesh
86
- */
87
- function process_mesh(mesh) {
88
- obtain_geometry(mesh.geometry);
89
- }
90
-
91
- object.traverse(o => {
92
- if (o.isMesh) {
93
- process_mesh(o);
94
- }
95
- });
96
-
97
- await Promise.all(promises);
98
-
99
- /**
100
- *
101
- * @param {THREE.Object3D|THREE.Mesh|THREE.SkinnedMesh} mesh
102
- * @returns {ThreeMicronMesh|THREE.Object3D}
103
- */
104
- async function convert(mesh) {
105
-
106
- if (
107
- mesh.isMesh
108
- && !mesh.isSkinnedMesh // skinned meshes not supported
109
- ) {
110
-
111
- let micronGeometry;
112
- try {
113
- micronGeometry = await obtain_geometry(mesh.geometry);
114
- } catch (e) {
115
- console.error(`Failed to convert geometry to micron, skipping : ${e}`);
116
-
117
- // return original
118
- return mesh;
119
- }
120
-
121
- const micron_mesh = new ThreeMicronMesh(micronGeometry, mesh.material);
122
-
123
- micron_mesh.scale.copy(mesh.scale);
124
- micron_mesh.rotation.copy(mesh.rotation);
125
- micron_mesh.position.copy(mesh.position);
126
-
127
-
128
- micron_mesh.castShadow = mesh.castShadow;
129
- micron_mesh.receiveShadow = mesh.receiveShadow;
130
-
131
- micron_mesh.children = mesh.children;
132
- micron_mesh.matrixAutoUpdate = mesh.matrixAutoUpdate;
133
-
134
- micron_mesh.matrix.copy(mesh.matrix);
135
- micron_mesh.matrixWorld.copy(mesh.matrixWorld);
136
-
137
- return micron_mesh;
138
- } else {
139
- return mesh;
140
- }
141
- }
142
-
143
- /**
144
- *
145
- * @param {THREE.Object3D} x
146
- */
147
- async function convert_object(x) {
148
- const children = x.children;
149
-
150
- for (let i = 0; i < children.length; i++) {
151
- const child = children[i];
152
-
153
- const converted_child = await convert(child);
154
- converted_child.parent = x;
155
-
156
- children[i] = converted_child;
157
-
158
- await convert_object(converted_child);
159
- }
160
-
161
- x.updateMatrix();
162
- }
163
-
164
- let result;
165
-
166
- if (object.isMesh) {
167
- result = await convert(object);
168
- } else {
169
- await convert_object(object);
170
-
171
- result = object;
172
- }
173
-
174
- result.updateWorldMatrix(false, true);
175
-
176
- // console.warn(`Processed geometries ${micron_cache.size}`);
177
-
178
- return result;
179
- }
@@ -1,42 +0,0 @@
1
- import View from "../../../../view/View.js";
2
- import { FrameRunner } from "../../FrameRunner.js";
3
- import LabelView from "../../../../view/common/LabelView.js";
4
- import ObservedString from "../../../../core/model/ObservedString.js";
5
- import { formatNumberByThousands } from "../../../../core/NumberFormat.js";
6
- import LineBuilder from "../../../../core/codegen/LineBuilder.js";
7
-
8
- export class VirtualGeometryStats extends View {
9
- /**
10
- *
11
- * @param {VirtualGeometry} vg
12
- */
13
- constructor(vg) {
14
- super();
15
-
16
- this.el = document.createElement('div');
17
-
18
- const vText = new ObservedString("");
19
-
20
- this.addChild(new LabelView(vText));
21
-
22
- this.__updater = new FrameRunner(() => {
23
- const lb = new LineBuilder();
24
- lb
25
- .add(`Source:`)
26
- .add(` Instances: ${formatNumberByThousands(vg.stats_instance_count)}`)
27
- .add(` Triangles: ${formatNumberByThousands(vg.stats_source_triangle_count)}`)
28
- .add(` Vertices: ${formatNumberByThousands(vg.stats_source_vertex_count)}`)
29
- .add(`Virtual:`)
30
- .add(` Triangles: ${formatNumberByThousands(vg.computeFaceCount())}`)
31
- .add(` Vertices: ${formatNumberByThousands(vg.computeVertexCount())}`)
32
- .add(` Patches: ${formatNumberByThousands(vg.patch_count)}`)
33
- ;
34
-
35
- vText.set(lb.build());
36
- });
37
-
38
- this.on.linked.add(this.__updater.startup, this.__updater);
39
- this.on.unlinked.add(this.__updater.shutdown, this.__updater);
40
- }
41
-
42
- }
@@ -1 +0,0 @@
1
- export const MICRON_GEOMETRY_PROPERTY_NAME = "@micron-geometry";
@@ -1,21 +0,0 @@
1
- import {BufferGeometry} from "three";
2
- import {VertexDataSpec} from "../../geometry/VertexDataSpec";
3
- import {SurfacePoint3} from "../../../../core/geom/3d/SurfacePoint3";
4
- import {MicronGeometryPatch} from "./MicronGeometryPatch";
5
-
6
- export class MicronGeometry {
7
- vertex_spec: VertexDataSpec
8
- public proxy: BufferGeometry
9
-
10
- initialize(): void
11
-
12
- raycast(
13
- destination: SurfacePoint3[], destination_offset: number,
14
- origin_x: number, origin_y: number, origin_z: number,
15
- direction_x: number, direction_y: number, direction_z: number
16
- ): number
17
-
18
- readonly isMicronGeometry: boolean
19
-
20
- readonly patches: MicronGeometryPatch[]
21
- }
@@ -1,334 +0,0 @@
1
- import { VertexDataSpec } from "../../geometry/VertexDataSpec.js";
2
- import { assert } from "../../../../core/assert.js";
3
- import { computeTriangleRayIntersection } from "../../../../core/geom/3d/triangle/computeTriangleRayIntersection.js";
4
- import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
5
- import { aabb3_array_intersects_ray } from "../../../../core/geom/3d/aabb/aabb3_array_intersects_ray.js";
6
- import { sphere_array_intersects_ray } from "../../../../core/geom/3d/sphere/sphere_array_intersects_ray.js";
7
- import { BitSet } from "../../../../core/binary/BitSet.js";
8
- import { micron_build_proxy_geometry } from "./micron_build_proxy_geometry.js";
9
-
10
- let id_counter = 0;
11
-
12
- /**
13
- * @readonly
14
- * @type {MicronGeometryPatch[]}
15
- */
16
- const scratch_traversal_stack = [];
17
-
18
- /**
19
- *
20
- * @type {BitSet}
21
- */
22
- const scratch_traversal_bitset = new BitSet();
23
- scratch_traversal_bitset.preventShrink();
24
-
25
- export class MicronGeometry {
26
- constructor() {
27
- /**
28
- * How many vertices original mesh contains
29
- * @type {number}
30
- */
31
- this.source_vertex_count = 0;
32
- /**
33
- * How many triangles original mesh contains
34
- * @type {number}
35
- */
36
- this.source_triangle_count = 0;
37
-
38
- /**
39
- * How much memory is needed to store the original
40
- * @type {number}
41
- */
42
- this.source_byte_size = 0;
43
-
44
- /**
45
- *
46
- * @type {MicronGeometryPatch|null}
47
- */
48
- this.root = null;
49
-
50
- /**
51
- *
52
- * @type {VertexDataSpec|null}
53
- */
54
- this.vertex_spec = new VertexDataSpec();
55
-
56
- /**
57
- *
58
- * @type {number}
59
- */
60
- this.id = id_counter++;
61
-
62
- /**
63
- *
64
- * @type {MicronGeometryPatch[]}
65
- * @private
66
- */
67
- this.__patches = [];
68
-
69
- /**
70
- * Physical proxy geometry, useful for raycasting and other spatial queries
71
- * @type {THREE.BufferGeometry|null}
72
- * @private
73
- */
74
- this.__proxy = null;
75
- }
76
-
77
- /**
78
- *
79
- * @param {SurfacePoint3[]} destination
80
- * @param {number} destination_offset
81
- * @param {number} origin_x
82
- * @param {number} origin_y
83
- * @param {number} origin_z
84
- * @param {number} direction_x
85
- * @param {number} direction_y
86
- * @param {number} direction_z
87
- * @returns {number}
88
- */
89
- raycast(
90
- destination,
91
- destination_offset,
92
- origin_x, origin_y, origin_z,
93
- direction_x, direction_y, direction_z
94
- ) {
95
- let destination_address = destination_offset;
96
- let i;
97
- let stack_cursor = 1;
98
-
99
- // initialize stack
100
- const stack = scratch_traversal_stack;
101
- stack[0] = this.root;
102
-
103
- const spec = this.vertex_spec;
104
-
105
- const position_attribute_index = spec.getAttributeIndexByName('position');
106
-
107
- // check that position attribute actually exists
108
- assert.isNonNegativeInteger(position_attribute_index, 'position_attribute_index');
109
-
110
- const included_set = scratch_traversal_bitset;
111
- included_set.reset();
112
-
113
- included_set.set(this.root.id, true);
114
-
115
- const temp_hit = new SurfacePoint3();
116
-
117
- while (stack_cursor > 0) {
118
- stack_cursor--;
119
-
120
- const patch = stack[stack_cursor];
121
-
122
-
123
- if (patch.lod === 0) {
124
- // LOD 0 - source geometry
125
-
126
- // cast against bounds
127
-
128
- // sphere test
129
- if (!sphere_array_intersects_ray(patch.bounding_sphere,
130
- origin_x, origin_y, origin_z,
131
- direction_x, direction_y, direction_z
132
- )) {
133
- continue;
134
- }
135
-
136
- // box test
137
- if (!aabb3_array_intersects_ray(
138
- patch.bounding_box,
139
- origin_x, origin_y, origin_z,
140
- direction_x, direction_y, direction_z
141
- )) {
142
- continue;
143
- }
144
-
145
- // raycast against geometry
146
- const indices = patch.face_indices;
147
- const index_count = indices.length;
148
-
149
- const vertices = patch.vertex_attribute_arrays[position_attribute_index];
150
-
151
- for (i = 0; i < index_count;) {
152
- const a = indices[i++];
153
- const b = indices[i++];
154
- const c = indices[i++];
155
-
156
-
157
- const a_address = a * 3;
158
- const b_address = b * 3;
159
- const c_address = c * 3;
160
-
161
-
162
- const ax = vertices[a_address];
163
- const ay = vertices[a_address + 1];
164
- const az = vertices[a_address + 2];
165
-
166
- const bx = vertices[b_address];
167
- const by = vertices[b_address + 1];
168
- const bz = vertices[b_address + 2];
169
-
170
- const cx = vertices[c_address];
171
- const cy = vertices[c_address + 1];
172
- const cz = vertices[c_address + 2];
173
-
174
- if (computeTriangleRayIntersection(
175
- temp_hit,
176
- origin_x, origin_y, origin_z,
177
- direction_x, direction_y, direction_z,
178
- ax, ay, az,
179
- bx, by, bz,
180
- cx, cy, cz
181
- )) {
182
-
183
- const contact = new SurfacePoint3();
184
-
185
- contact.copy(temp_hit);
186
-
187
- destination[destination_address++] = contact;
188
-
189
- }
190
- }
191
-
192
- } else {
193
-
194
- // using group bounds because it's conservative, as we want to be able to hit LOD_0
195
-
196
- // sphere test
197
- if (!sphere_array_intersects_ray(patch.group_bounding_sphere,
198
- origin_x, origin_y, origin_z,
199
- direction_x, direction_y, direction_z
200
- )) {
201
- continue;
202
- }
203
-
204
-
205
- // box test (more expensive, different volume)
206
- if (!aabb3_array_intersects_ray(
207
- patch.group_bounding_box,
208
- origin_x, origin_y, origin_z,
209
- direction_x, direction_y, direction_z
210
- )) {
211
- // no intersection
212
- continue;
213
- }
214
-
215
- // refine more
216
- const children = patch.children;
217
-
218
- const child_count = children.length;
219
-
220
- for (i = 0; i < child_count; i++) {
221
- const child = children[i];
222
-
223
- if (included_set.get(child.id)) {
224
- continue;
225
- }
226
-
227
- // push to stack
228
- stack[stack_cursor++] = child;
229
-
230
- included_set.set(child.id, true);
231
- }
232
- }
233
- }
234
-
235
- return destination_address - destination_offset;
236
- }
237
-
238
- /**
239
- *
240
- * @param {number} lod
241
- * @returns {number}
242
- */
243
- computeLodFaceCount(lod) {
244
- let r = 0;
245
-
246
- const patches = this.patches;
247
- const patch_count = patches.length;
248
- for (let i = 0; i < patch_count; i++) {
249
- const patch = patches[i];
250
-
251
- if (patch.lod !== lod) {
252
- continue;
253
- }
254
-
255
- r += patch.polygon_count;
256
- }
257
-
258
- return r;
259
- }
260
-
261
- get patches() {
262
- return this.__patches;
263
- }
264
-
265
- /**
266
- *
267
- * @param {MicronGeometryPatch[]} v
268
- */
269
- set patches(v) {
270
- this.__patches = v;
271
- }
272
-
273
- /**
274
- * @param {THREE.BufferGeometry} geometry
275
- */
276
- set proxy(geometry) {
277
- this.__proxy = geometry;
278
- }
279
-
280
- /**
281
- *
282
- * @return {THREE.BufferGeometry|null}
283
- */
284
- get proxy() {
285
- return this.__proxy;
286
- }
287
-
288
- /**
289
- * Build geometry proxy from the patches
290
- * @param {number} [fraction] percentage of the original geometry to keep
291
- * @param {number} [min] minimum number of triangles to keep, this will be respected first before percentage value
292
- */
293
- buildProxy(fraction = 0.05, min = 2048) {
294
- const bufferGeometry = micron_build_proxy_geometry(this, fraction, min);
295
-
296
- this.__proxy = bufferGeometry;
297
- }
298
-
299
- computeByteSize() {
300
- let result = 0;
301
-
302
- const patches = this.__patches;
303
- const patch_count = patches.length;
304
-
305
- for (let i = 0; i < patch_count; i++) {
306
- result += patches[i].computeByteSize();
307
- }
308
-
309
- return result;
310
- }
311
-
312
- initialize() {
313
- this.root.traverse(p => {
314
- this.__patches[p.id] = p;
315
- });
316
- }
317
-
318
- /**
319
- *
320
- * @param {number} id
321
- * @returns {MicronGeometryPatch|undefined}
322
- */
323
- getPatchById(id) {
324
- assert.isNonNegativeInteger(id, 'id');
325
-
326
- return this.__patches[id];
327
- }
328
- }
329
-
330
- /**
331
- * @readonly
332
- * @type {boolean}
333
- */
334
- MicronGeometry.prototype.isMicronGeometry = true;
@@ -1,3 +0,0 @@
1
- export class MicronGeometryPatch {
2
- allocate_metadata(buffer: ArrayBuffer, offset: number): number
3
- }