@woosh/meep-engine 2.33.67 → 2.33.68

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.
@@ -25,15 +25,9 @@ export function computeTriangleRayIntersection(
25
25
  result,
26
26
  origin_x, origin_y, origin_z,
27
27
  direction_x, direction_y, direction_z,
28
- ax,
29
- ay,
30
- az,
31
- bx,
32
- by,
33
- bz,
34
- cx,
35
- cy,
36
- cz
28
+ ax, ay, az,
29
+ bx, by, bz,
30
+ cx, cy, cz
37
31
  ) {
38
32
 
39
33
  // edge1 = a - b
@@ -79,21 +79,32 @@ export class ClippingPlaneContainmentComputingVisitor extends GeometrySpatialAcc
79
79
 
80
80
  const index3 = index * 3;
81
81
 
82
- const a = this.__buffer_indices[index3] * 3;
83
- const b = this.__buffer_indices[index3 + 1] * 3;
84
- const c = this.__buffer_indices[index3 + 2] * 3;
82
+ const indices = this.__buffer_indices;
85
83
 
86
- const ax = this.__buffer_vertices[a];
87
- const ay = this.__buffer_vertices[a + 1];
88
- const az = this.__buffer_vertices[a + 2];
84
+ const a = indices[index3];
85
+ const b = indices[index3 + 1];
86
+ const c = indices[index3 + 2];
89
87
 
90
- const bx = this.__buffer_vertices[b];
91
- const by = this.__buffer_vertices[b + 1];
92
- const bz = this.__buffer_vertices[b + 2];
88
+ const vertices = this.__buffer_vertices;
93
89
 
94
- const cx = this.__buffer_vertices[c];
95
- const cy = this.__buffer_vertices[c + 1];
96
- const cz = this.__buffer_vertices[c + 2];
90
+ const stride = this.__buffer_vertex_stride;
91
+ const offset = this.__buffer_position_offset;
92
+
93
+ const a_address = a * stride + offset;
94
+ const b_address = b * stride + offset;
95
+ const c_address = c * stride + offset;
96
+
97
+ const ax = vertices[a_address];
98
+ const ay = vertices[a_address + 1];
99
+ const az = vertices[a_address + 2];
100
+
101
+ const bx = vertices[b_address];
102
+ const by = vertices[b_address + 1];
103
+ const bz = vertices[b_address + 2];
104
+
105
+ const cx = vertices[c_address];
106
+ const cy = vertices[c_address + 1];
107
+ const cz = vertices[c_address + 2];
97
108
 
98
109
  for (let i = 0; i < plane_count; i++) {
99
110
  const plane = planes[i];
@@ -108,15 +119,9 @@ export class ClippingPlaneContainmentComputingVisitor extends GeometrySpatialAcc
108
119
  plane_normal_y,
109
120
  plane_normal_z,
110
121
  plane_constant,
111
- ax,
112
- ay,
113
- az,
114
- bx,
115
- by,
116
- bz,
117
- cx,
118
- cy,
119
- cz
122
+ ax, ay, az,
123
+ bx, by, bz,
124
+ cx, cy, cz
120
125
  );
121
126
 
122
127
  if (side === -3) {
@@ -163,12 +168,8 @@ export class ClippingPlaneContainmentComputingVisitor extends GeometrySpatialAcc
163
168
  plane_normal_z,
164
169
  plane_constant,
165
170
 
166
- x0,
167
- y0,
168
- z0,
169
- x1,
170
- y1,
171
- z1
171
+ x0, y0, z0,
172
+ x1, y1, z1
172
173
  );
173
174
 
174
175
  if (side === -2) {
@@ -1,6 +1,6 @@
1
1
  import { IndexedBinaryBVHVisitor } from "../../../../../core/bvh2/binary/IndexedBinaryBVHVisitor.js";
2
2
 
3
- export class GeometrySpatialAcceleratorVisitor extends IndexedBinaryBVHVisitor{
3
+ export class GeometrySpatialAcceleratorVisitor extends IndexedBinaryBVHVisitor {
4
4
  constructor() {
5
5
  super();
6
6
 
@@ -25,6 +25,20 @@ export class GeometrySpatialAcceleratorVisitor extends IndexedBinaryBVHVisitor{
25
25
  */
26
26
  this.__buffer_vertices = null;
27
27
 
28
+ /**
29
+ *
30
+ * @type {number}
31
+ * @protected
32
+ */
33
+ this.__buffer_vertex_stride = 3;
34
+
35
+ /**
36
+ *
37
+ * @type {number}
38
+ * @protected
39
+ */
40
+ this.__buffer_position_offset = 0;
41
+
28
42
  /**
29
43
  * @protected
30
44
  * @type {IndexedBinaryBVH}
@@ -47,7 +61,20 @@ export class GeometrySpatialAcceleratorVisitor extends IndexedBinaryBVHVisitor{
47
61
  this.geometry = geometry;
48
62
 
49
63
  this.__buffer_indices = geometry.getIndex().array;
50
- this.__buffer_vertices = geometry.getAttribute('position').array;
64
+
65
+ const position_attribute = geometry.getAttribute('position');
66
+
67
+ if (position_attribute.isInterleavedBufferAttribute) {
68
+ const data = position_attribute.data;
69
+
70
+ this.__buffer_vertices = data.array;
71
+ this.__buffer_vertex_stride = data.stride;
72
+ this.__buffer_position_offset = position_attribute.offset;
73
+ } else {
74
+ this.__buffer_vertices = position_attribute.array;
75
+ this.__buffer_vertex_stride = 3;
76
+ this.__buffer_position_offset = 0;
77
+ }
51
78
  }
52
79
 
53
80
  }
@@ -96,21 +96,32 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
96
96
 
97
97
  const index3 = index * 3;
98
98
 
99
- const a = this.__buffer_indices[index3] * 3;
100
- const b = this.__buffer_indices[index3 + 1] * 3;
101
- const c = this.__buffer_indices[index3 + 2] * 3;
99
+ const indices = this.__buffer_indices;
102
100
 
103
- const ax = this.__buffer_vertices[a];
104
- const ay = this.__buffer_vertices[a + 1];
105
- const az = this.__buffer_vertices[a + 2];
101
+ const a = indices[index3];
102
+ const b = indices[index3 + 1];
103
+ const c = indices[index3 + 2];
106
104
 
107
- const bx = this.__buffer_vertices[b];
108
- const by = this.__buffer_vertices[b + 1];
109
- const bz = this.__buffer_vertices[b + 2];
105
+ const vertices = this.__buffer_vertices;
110
106
 
111
- const cx = this.__buffer_vertices[c];
112
- const cy = this.__buffer_vertices[c + 1];
113
- const cz = this.__buffer_vertices[c + 2];
107
+ const stride = this.__buffer_vertex_stride;
108
+ const offset = this.__buffer_position_offset;
109
+
110
+ const a_address = a * stride + offset;
111
+ const b_address = b * stride + offset;
112
+ const c_address = c * stride + offset;
113
+
114
+ const ax = vertices[a_address];
115
+ const ay = vertices[a_address + 1];
116
+ const az = vertices[a_address + 2];
117
+
118
+ const bx = vertices[b_address];
119
+ const by = vertices[b_address + 1];
120
+ const bz = vertices[b_address + 2];
121
+
122
+ const cx = vertices[c_address];
123
+ const cy = vertices[c_address + 1];
124
+ const cz = vertices[c_address + 2];
114
125
 
115
126
  if (computeTriangleRayIntersection(
116
127
  this.__temp_hit,
@@ -120,15 +131,9 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
120
131
  rayDirection.x,
121
132
  rayDirection.y,
122
133
  rayDirection.z,
123
- ax,
124
- ay,
125
- az,
126
- bx,
127
- by,
128
- bz,
129
- cx,
130
- cy,
131
- cz
134
+ ax, ay, az,
135
+ bx, by, bz,
136
+ cx, cy, cz
132
137
  )) {
133
138
  const d = this.__temp_hit.position.distanceSqrTo(rayOrigin);
134
139
 
@@ -154,12 +159,8 @@ export class RaycastNearestHitComputingVisitor extends GeometrySpatialAccelerato
154
159
  const z1 = data[address + 5];
155
160
 
156
161
  return intersectRay(
157
- x0,
158
- y0,
159
- z0,
160
- x1,
161
- y1,
162
- z1,
162
+ x0, y0, z0,
163
+ x1, y1, z1,
163
164
 
164
165
  rayOrigin.x,
165
166
  rayOrigin.y,
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "productName": "Meep",
6
6
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.33.67",
8
+ "version": "2.33.68",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",