@woosh/meep-engine 2.33.20 → 2.33.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.
- package/core/bvh2/traversal/__detailed_box_volume_intersection.js +1 -1
- package/core/collection/HashMap.js +66 -22
- package/core/geom/3d/CircleMath.js +4 -4
- package/core/geom/3d/cone/computeConeBoundingBox.js +4 -4
- package/core/geom/3d/{compute_bounding_cone_of_2_cones.js → cone/compute_bounding_cone_of_2_cones.js} +3 -3
- package/core/geom/3d/{compute_bounding_cone_of_2_cones.spec.js → cone/compute_bounding_cone_of_2_cones.spec.js} +1 -1
- package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +1 -1
- package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- package/core/geom/3d/{encode_unit3_hemioct.js → normal/hemioct/encode_unit3_hemioct.js} +0 -0
- package/core/geom/3d/{unit_hemioct.spec.js → normal/hemioct/unit_hemioct.spec.js} +1 -1
- package/core/geom/3d/normal/lamber_azimuth/transform.js +61 -0
- package/core/geom/3d/normal/spherical/sphere_map_transform.js +77 -0
- package/core/geom/3d/{lerp_planes_to_array.js → plane/lerp_planes_to_array.js} +1 -3
- package/core/geom/3d/plane/plane3_lerp.js +3 -1
- package/core/geom/3d/plane/plane3_slerp.js +4 -1
- package/core/geom/3d/{plane_computeConvex3PlaneIntersection.js → plane/plane_computeConvex3PlaneIntersection.js} +1 -2
- package/core/geom/3d/topology/TopoTriangle.js +1 -1
- package/core/geom/3d/topology/TopoVertex.js +1 -1
- package/core/geom/3d/topology/bounds/computeTraingleClusterNormalBoundingCone.js +2 -2
- package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
- package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
- package/core/geom/3d/triangle/computeTrianglePlaneSide.js +1 -1
- package/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -1
- package/core/geom/LineSegment.js +3 -1
- package/core/geom/Matrix4.js +2 -1
- package/core/geom/Plane.js +1 -1
- package/core/geom/Quaternion.js +2 -1
- package/core/geom/Vector3.d.ts +2 -0
- package/core/geom/Vector3.js +33 -158
- package/core/geom/Vector3.spec.js +2 -1
- package/core/geom/v3_angle_between.js +31 -0
- package/core/geom/v3_distance.js +16 -0
- package/core/geom/v3_distance_sqr.js +17 -0
- package/core/geom/v3_dot.js +13 -0
- package/core/geom/v3_length.js +5 -0
- package/core/geom/v3_length_sqr.js +10 -0
- package/core/geom/v3_lerp.js +21 -0
- package/core/geom/v3_slerp.js +48 -0
- package/core/primitives/array/computeIntegerArrayHash.js +5 -0
- package/engine/asset/loaders/material/computeMaterialHash.js +1 -2
- package/engine/asset/loaders/material/computeTextureEquality.js +13 -5
- package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +3 -1
- package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +3 -1
- package/engine/ecs/fow/FogOfWar.js +2 -3
- package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +1 -1
- package/engine/ecs/systems/SteeringSystem.js +2 -1
- package/engine/ecs/terrain/ecs/Terrain.js +6 -0
- package/engine/ecs/terrain/ecs/layers/TerrainLayers.js +5 -0
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +5 -0
- package/engine/graphics/GraphicsEngine.js +18 -0
- package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
- package/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +0 -53
- package/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +2 -1
- package/engine/graphics/micron/build/clustering/computeFaceCurvatureScore.js +1 -1
- package/engine/graphics/micron/build/clustering/compute_face_connection_weight.js +1 -1
- package/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +1 -1
- package/engine/graphics/micron/build/hierarchy/patch_combine.js +1 -1
- package/engine/graphics/micron/render/refinement/is_patch_facing_back.js +2 -2
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +7 -25
- package/engine/graphics/render/forward_plus/computeFrustumCorners.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +12 -2
- package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +1 -1
- package/engine/graphics/render/layers/RenderLayerUtils.js +1 -1
- package/engine/graphics/texture/atlas/TextureAtlas.js +16 -12
- package/engine/graphics/util/projectSphere.js +1 -1
- package/engine/navigation/ecs/components/Path.js +2 -1
- package/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +3 -2
- package/generation/markers/GridCellActionPlaceMarker.js +13 -1
- package/generation/markers/MarkerNode.js +6 -0
- package/generation/theme/ThemeEngine.js +3 -0
- package/package.json +1 -1
- package/view/minimap/gl/MinimapMarkersGL.js +13 -1
|
@@ -4,7 +4,7 @@ import { computePointDistanceToPlane, plane3_computeLineSegmentIntersection } fr
|
|
|
4
4
|
import { aabb3_corner_edge_mapping } from "../aabb3/aabb3_corner_edge_mapping.js";
|
|
5
5
|
import { aabb3_edge_corner_mapping } from "../aabb3/aabb3_edge_corner_mapping.js";
|
|
6
6
|
import { __process_point_if_within_planes } from "./__process_point_if_within_planes.js";
|
|
7
|
-
import { plane_computeConvex3PlaneIntersection } from "../../geom/3d/plane_computeConvex3PlaneIntersection.js";
|
|
7
|
+
import { plane_computeConvex3PlaneIntersection } from "../../geom/3d/plane/plane_computeConvex3PlaneIntersection.js";
|
|
8
8
|
import { EPSILON } from "../../math/MathUtils.js";
|
|
9
9
|
import Vector3 from "../../geom/Vector3.js";
|
|
10
10
|
|
|
@@ -26,6 +26,18 @@ class MapEntry {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @readonly
|
|
31
|
+
* @type {number}
|
|
32
|
+
*/
|
|
33
|
+
const DEFAULT_INITIAL_CAPACITY = 16;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @readonly
|
|
37
|
+
* @type {number}
|
|
38
|
+
*/
|
|
39
|
+
const DEFAULT_LOAD_FACTOR = 0.75;
|
|
40
|
+
|
|
29
41
|
/**
|
|
30
42
|
* Implements part of {@link Map} interface
|
|
31
43
|
* @template K,V
|
|
@@ -36,10 +48,14 @@ export class HashMap {
|
|
|
36
48
|
* @template K, V
|
|
37
49
|
* @param {function(K):number} [keyHashFunction]
|
|
38
50
|
* @param {function(K,K):boolean} [keyEqualityFunction]
|
|
51
|
+
* @param {number} [capacity] initial number of buckets in the hash table
|
|
52
|
+
* @param {number} [loadFactor] a measure of how full the hash table is allowed to get before its capacity is automatically increased
|
|
39
53
|
*/
|
|
40
54
|
constructor({
|
|
41
55
|
keyHashFunction = invokeObjectHash,
|
|
42
|
-
keyEqualityFunction = invokeObjectEquals
|
|
56
|
+
keyEqualityFunction = invokeObjectEquals,
|
|
57
|
+
capacity = DEFAULT_INITIAL_CAPACITY,
|
|
58
|
+
loadFactor = DEFAULT_LOAD_FACTOR
|
|
43
59
|
} = {}) {
|
|
44
60
|
assert.typeOf(keyHashFunction, 'function', 'keyHashFunction');
|
|
45
61
|
assert.typeOf(keyEqualityFunction, 'function', 'keyEqualityFunction');
|
|
@@ -69,14 +85,21 @@ export class HashMap {
|
|
|
69
85
|
* @type {number}
|
|
70
86
|
* @private
|
|
71
87
|
*/
|
|
72
|
-
this.__bucket_count =
|
|
88
|
+
this.__bucket_count = capacity;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* How full the table can get before number of buckets is increased
|
|
92
|
+
* @type {number}
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
this.__load_factor = loadFactor;
|
|
73
96
|
}
|
|
74
97
|
|
|
75
98
|
/**
|
|
76
99
|
* Proportion between actual number of records in the map and the bucket count (number of potential hashes)
|
|
77
100
|
* @returns {number}
|
|
78
101
|
*/
|
|
79
|
-
|
|
102
|
+
getCurrentLoad() {
|
|
80
103
|
return this.size / this.__bucket_count;
|
|
81
104
|
}
|
|
82
105
|
|
|
@@ -133,7 +156,7 @@ export class HashMap {
|
|
|
133
156
|
this.__bucket_count = count;
|
|
134
157
|
if (this.size > 0) {
|
|
135
158
|
// re-hash
|
|
136
|
-
this.
|
|
159
|
+
this.rebuild();
|
|
137
160
|
}
|
|
138
161
|
}
|
|
139
162
|
|
|
@@ -167,31 +190,49 @@ export class HashMap {
|
|
|
167
190
|
let bucket = this.records[bucket_index];
|
|
168
191
|
|
|
169
192
|
if (bucket === undefined) {
|
|
170
|
-
|
|
193
|
+
|
|
194
|
+
// bucket for this value doesn't exist
|
|
195
|
+
|
|
196
|
+
bucket = [];
|
|
197
|
+
|
|
171
198
|
this.records[bucket_index] = bucket;
|
|
172
199
|
|
|
173
|
-
|
|
200
|
+
} else {
|
|
174
201
|
|
|
175
|
-
|
|
176
|
-
}
|
|
202
|
+
// bucket exists
|
|
177
203
|
|
|
178
|
-
|
|
204
|
+
const bucketSize = bucket.length;
|
|
179
205
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
206
|
+
//check if key already exists
|
|
207
|
+
for (let i = 0; i < bucketSize; i++) {
|
|
208
|
+
const entry = bucket[i];
|
|
183
209
|
|
|
184
|
-
|
|
185
|
-
if (entryKey === key || this.keyEqualityFunction(entryKey, key)) {
|
|
210
|
+
const entryKey = entry.key;
|
|
186
211
|
|
|
187
|
-
|
|
188
|
-
|
|
212
|
+
if (entryKey === key || this.keyEqualityFunction(entryKey, key)) {
|
|
213
|
+
|
|
214
|
+
entry.value = value;
|
|
215
|
+
return;
|
|
216
|
+
|
|
217
|
+
}
|
|
189
218
|
|
|
190
219
|
}
|
|
220
|
+
|
|
191
221
|
}
|
|
192
222
|
|
|
193
223
|
bucket.push(new MapEntry(key, value));
|
|
194
|
-
|
|
224
|
+
|
|
225
|
+
const old_size = this.size;
|
|
226
|
+
const new_size = old_size + 1;
|
|
227
|
+
this.size = new_size;
|
|
228
|
+
|
|
229
|
+
// compute actual current load
|
|
230
|
+
const load = new_size / this.__bucket_count;
|
|
231
|
+
|
|
232
|
+
if (load > this.__load_factor) {
|
|
233
|
+
// increase table size
|
|
234
|
+
this.setBucketCount(this.__bucket_count * 2);
|
|
235
|
+
}
|
|
195
236
|
}
|
|
196
237
|
|
|
197
238
|
/**
|
|
@@ -308,20 +349,22 @@ export class HashMap {
|
|
|
308
349
|
}
|
|
309
350
|
|
|
310
351
|
/**
|
|
311
|
-
*
|
|
352
|
+
* Rebuild table, useful for when table is resized or hashes of stored keys change
|
|
312
353
|
*/
|
|
313
|
-
|
|
354
|
+
rebuild() {
|
|
314
355
|
|
|
315
356
|
let h, i, l;
|
|
316
357
|
|
|
317
358
|
const records = this.records;
|
|
318
359
|
|
|
319
360
|
for (h in records) {
|
|
361
|
+
const stored_bucket_index = parseInt(h);
|
|
362
|
+
|
|
320
363
|
if (!records.hasOwnProperty(h)) {
|
|
321
364
|
continue;
|
|
322
365
|
}
|
|
323
366
|
|
|
324
|
-
const bucket = records[
|
|
367
|
+
const bucket = records[stored_bucket_index];
|
|
325
368
|
|
|
326
369
|
for (i = 0, l = bucket.length; i < l; i++) {
|
|
327
370
|
/**
|
|
@@ -333,7 +376,6 @@ export class HashMap {
|
|
|
333
376
|
const raw_hash = this.keyHashFunction(entry.key);
|
|
334
377
|
const actual_bucket_index = this.__compute_bucket_index(raw_hash);
|
|
335
378
|
|
|
336
|
-
const stored_bucket_index = parseInt(h);
|
|
337
379
|
|
|
338
380
|
if (actual_bucket_index !== stored_bucket_index) {
|
|
339
381
|
//remove entry from the bucket
|
|
@@ -345,15 +387,17 @@ export class HashMap {
|
|
|
345
387
|
|
|
346
388
|
if (bucket.length === 0) {
|
|
347
389
|
//delete empty bucket
|
|
348
|
-
delete records[
|
|
390
|
+
delete records[stored_bucket_index];
|
|
349
391
|
}
|
|
350
392
|
|
|
351
393
|
const newBucket = records[actual_bucket_index];
|
|
394
|
+
|
|
352
395
|
if (newBucket === undefined) {
|
|
353
396
|
records[actual_bucket_index] = [entry];
|
|
354
397
|
} else {
|
|
355
398
|
newBucket.push(entry);
|
|
356
399
|
}
|
|
400
|
+
|
|
357
401
|
}
|
|
358
402
|
}
|
|
359
403
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v3_angle_between } from "../v3_angle_between.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* NOTE: based on https://stackoverflow.com/questions/2592011/bounding-boxes-for-circle-and-arcs-in-3d
|
|
@@ -12,9 +12,9 @@ import { v3_angleBetween } from "../Vector3.js";
|
|
|
12
12
|
* @param {number} radius
|
|
13
13
|
*/
|
|
14
14
|
export function computeCircleBoundingBox(result, centerX, centerY, centerZ, normalX, normalY, normalZ, radius) {
|
|
15
|
-
const ax =
|
|
16
|
-
const ay =
|
|
17
|
-
const az =
|
|
15
|
+
const ax = v3_angle_between(normalX, normalY, normalZ, 1, 0, 0);
|
|
16
|
+
const ay = v3_angle_between(normalX, normalY, normalZ, 0, 1, 0);
|
|
17
|
+
const az = v3_angle_between(normalX, normalY, normalZ, 0, 0, 1);
|
|
18
18
|
|
|
19
19
|
const rX = Math.sin(ax) * radius;
|
|
20
20
|
const rY = Math.sin(ay) * radius;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { max2 } from "../../../math/max2.js";
|
|
2
2
|
import { min2 } from "../../../math/min2.js";
|
|
3
|
-
import {
|
|
3
|
+
import { v3_angle_between } from "../../v3_angle_between.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* NOTE: used stackoverflow answer as a basis for circle part: https://stackoverflow.com/questions/2592011/bounding-boxes-for-circle-and-arcs-in-3d
|
|
@@ -15,9 +15,9 @@ import { v3_angleBetween } from "../../Vector3.js";
|
|
|
15
15
|
* @param {number} length
|
|
16
16
|
*/
|
|
17
17
|
export function computeConeBoundingBox(result, originX, originY, originZ, directionX, directionY, directionZ, angle, length) {
|
|
18
|
-
const ax =
|
|
19
|
-
const ay =
|
|
20
|
-
const az =
|
|
18
|
+
const ax = v3_angle_between(directionX, directionY, directionZ, 1, 0, 0);
|
|
19
|
+
const ay = v3_angle_between(directionX, directionY, directionZ, 0, 1, 0);
|
|
20
|
+
const az = v3_angle_between(directionX, directionY, directionZ, 0, 0, 1);
|
|
21
21
|
|
|
22
22
|
//compute radius of the base of the cone
|
|
23
23
|
const radius = length * Math.tan(angle);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import Vector3 from "
|
|
5
|
-
import Quaternion, { quat3_createFromAxisAngle } from "
|
|
6
|
-
import { max2 } from "
|
|
4
|
+
import Vector3 from "../../Vector3.js";
|
|
5
|
+
import Quaternion, { quat3_createFromAxisAngle } from "../../Quaternion.js";
|
|
6
|
+
import { max2 } from "../../../math/max2.js";
|
|
7
7
|
|
|
8
8
|
const tangent = new Vector3();
|
|
9
9
|
|
|
@@ -2,7 +2,7 @@ import { ray_computeNearestPointToPoint } from "../../LineSegment.js";
|
|
|
2
2
|
import { computePlanePlaneIntersection, computePointDistanceToPlane } from "../../Plane.js";
|
|
3
3
|
import Vector3 from "../../Vector3.js";
|
|
4
4
|
import { plane3_projectPoint } from "../plane/plane3_projectPoint.js";
|
|
5
|
-
import { plane_three_computeConvex3PlaneIntersection } from "../plane_computeConvex3PlaneIntersection.js";
|
|
5
|
+
import { plane_three_computeConvex3PlaneIntersection } from "../plane/plane_computeConvex3PlaneIntersection.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
File without changes
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { v2_dot } from "../../../Vector2.js";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
@source https://aras-p.info/texts/CompactNormalStorage.html
|
|
5
|
+
@source https://en.wikipedia.org/wiki/Lambert_azimuthal_equal-area_projection
|
|
6
|
+
|
|
7
|
+
half2 encode (half3 n, float3 view)
|
|
8
|
+
{
|
|
9
|
+
half f = sqrt(8*n.z+8);
|
|
10
|
+
return n.xy / f + 0.5;
|
|
11
|
+
}
|
|
12
|
+
half3 decode (half4 enc, float3 view)
|
|
13
|
+
{
|
|
14
|
+
half2 fenc = enc*4-2;
|
|
15
|
+
half f = dot(fenc,fenc);
|
|
16
|
+
half g = sqrt(1-f/4);
|
|
17
|
+
half3 n;
|
|
18
|
+
n.xy = fenc*g;
|
|
19
|
+
n.z = 1-f/2;
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {number[]} output
|
|
27
|
+
* @param {number} output_offset
|
|
28
|
+
* @param {number} x
|
|
29
|
+
* @param {number} y
|
|
30
|
+
* @param {number} z
|
|
31
|
+
*/
|
|
32
|
+
export function encode_unit_to_azimuth(output, output_offset, x, y, z) {
|
|
33
|
+
const f = Math.sqrt(8 * z + 8);
|
|
34
|
+
|
|
35
|
+
output[output_offset] = x / f + 0.5;
|
|
36
|
+
output[output_offset + 1] = y / f + 0.5;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {number[]} output
|
|
42
|
+
* @param {number} output_offset
|
|
43
|
+
* @param {number} x range [-1,1]
|
|
44
|
+
* @param {number} y range [-1,1]
|
|
45
|
+
*/
|
|
46
|
+
export function decode_azimuth_to_unit(output, output_offset, x, y) {
|
|
47
|
+
const fenc_x = x * 4 - 2;
|
|
48
|
+
const fenc_y = y * 4 - 2;
|
|
49
|
+
|
|
50
|
+
const f = v2_dot(fenc_x, fenc_y, fenc_x, fenc_y);
|
|
51
|
+
|
|
52
|
+
const g = Math.sqrt(1 - f / 4);
|
|
53
|
+
|
|
54
|
+
const n_x = fenc_x * g;
|
|
55
|
+
const n_y = fenc_y * g;
|
|
56
|
+
const n_z = 1 - f / 2;
|
|
57
|
+
|
|
58
|
+
output[output_offset] = n_x;
|
|
59
|
+
output[output_offset + 1] = n_y;
|
|
60
|
+
output[output_offset + 2] = n_z;
|
|
61
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { v2_magnitude } from "../../../Vector2.js";
|
|
2
|
+
import { v3_dot } from "../../../v3_dot.js";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
@source https://aras-p.info/texts/CompactNormalStorage.html#method04spheremap
|
|
6
|
+
@source Siggraph 99
|
|
7
|
+
@source Cry Engine 3, presented by Martin Mittring in "A bit more Deferred"
|
|
8
|
+
|
|
9
|
+
half2 encode (half3 n, float3 view)
|
|
10
|
+
{
|
|
11
|
+
half2 enc = normalize(n.xy) * (sqrt(-n.z*0.5+0.5));
|
|
12
|
+
enc = enc*0.5+0.5;
|
|
13
|
+
return enc;
|
|
14
|
+
}
|
|
15
|
+
half3 decode (half4 enc, float3 view)
|
|
16
|
+
{
|
|
17
|
+
half4 nn = enc*half4(2,2,0,0) + half4(-1,-1,1,-1);
|
|
18
|
+
half l = dot(nn.xyz,-nn.xyw);
|
|
19
|
+
nn.z = l;
|
|
20
|
+
nn.xy *= sqrt(l);
|
|
21
|
+
return nn.xyz * 2 + half3(0,0,-1);
|
|
22
|
+
}
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Encode v3 to v2
|
|
28
|
+
* @param {number[]} output
|
|
29
|
+
* @param {number} output_offset
|
|
30
|
+
* @param {number} x
|
|
31
|
+
* @param {number} y
|
|
32
|
+
* @param {number} z
|
|
33
|
+
*/
|
|
34
|
+
export function encode_unit_to_spheremap(output, output_offset, x, y, z) {
|
|
35
|
+
const length_xy = v2_magnitude(x, y);
|
|
36
|
+
|
|
37
|
+
const norm_xy_x = x / length_xy;
|
|
38
|
+
const norm_xy_y = y / length_xy;
|
|
39
|
+
|
|
40
|
+
const z_factor = Math.sqrt(-z * 0.5 - 0.5) * 0.5;
|
|
41
|
+
|
|
42
|
+
const enc_x = norm_xy_x * z_factor + 0.5;
|
|
43
|
+
const enc_y = norm_xy_y * z_factor + 0.5;
|
|
44
|
+
|
|
45
|
+
output[output_offset] = enc_x;
|
|
46
|
+
output[output_offset + 1] = enc_y;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {number[]} output
|
|
51
|
+
* @param {number} output_offset
|
|
52
|
+
* @param {number} x range [-1,1]
|
|
53
|
+
* @param {number} y range [-1,1]
|
|
54
|
+
*/
|
|
55
|
+
function decode_spheremap_to_unit(output, output_offset, x, y) {
|
|
56
|
+
const nn4_x = x * 2 - 1;
|
|
57
|
+
const nn4_y = y * 2 - 1;
|
|
58
|
+
const nn4_z = 1;
|
|
59
|
+
const nn4_w = -1;
|
|
60
|
+
|
|
61
|
+
const l = v3_dot(nn4_x, nn4_y, nn4_z, -nn4_x, -nn4_y, -nn4_w);
|
|
62
|
+
|
|
63
|
+
const nn_z = l;
|
|
64
|
+
|
|
65
|
+
const l_sqrt = Math.sqrt(l);
|
|
66
|
+
|
|
67
|
+
const nn_x = nn4_x * l_sqrt;
|
|
68
|
+
const nn_y = nn4_y * l_sqrt;
|
|
69
|
+
|
|
70
|
+
const _x = nn_x * 2;
|
|
71
|
+
const _y = nn_y * 2;
|
|
72
|
+
const _z = nn_z * 2 - 1;
|
|
73
|
+
|
|
74
|
+
output[output_offset] = _x;
|
|
75
|
+
output[output_offset + 1] = _y;
|
|
76
|
+
output[output_offset + 2] = _z;
|
|
77
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { lerp } from "../../../math/lerp.js";
|
|
2
|
-
import Vector3
|
|
2
|
+
import Vector3 from "../../Vector3.js";
|
|
3
3
|
import { plane3_intersect_plane } from "./plane3_intersect_plane.js";
|
|
4
|
+
import { v3_dot } from "../../v3_dot.js";
|
|
5
|
+
import { v3_length } from "../../v3_length.js";
|
|
4
6
|
|
|
5
7
|
const v0 = new Vector3();
|
|
6
8
|
const v1 = new Vector3();
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { lerp } from "../../../math/lerp.js";
|
|
2
2
|
import { EPSILON } from "../../../math/MathUtils.js";
|
|
3
|
-
import Vector3
|
|
3
|
+
import Vector3 from "../../Vector3.js";
|
|
4
|
+
import { v3_dot } from "../../v3_dot.js";
|
|
5
|
+
import { v3_length_sqr } from "../../v3_length_sqr.js";
|
|
6
|
+
import { v3_slerp } from "../../v3_slerp.js";
|
|
4
7
|
|
|
5
8
|
const e = new Vector3();
|
|
6
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { v3_length } from "../../Vector3.js";
|
|
2
1
|
import { array_replace_all } from "../../../collection/array/array_replace_all.js";
|
|
3
2
|
import { array_push_if_unique } from "../../../collection/array/array_push_if_unique.js";
|
|
4
3
|
import { assert } from "../../../assert.js";
|
|
5
4
|
import { array_remove_first } from "../../../collection/array/array_remove_first.js";
|
|
6
5
|
import { vec3 } from "gl-matrix";
|
|
6
|
+
import { v3_length } from "../../v3_length.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { v3_distance } from "../../Vector3.js";
|
|
2
1
|
import { assert } from "../../../assert.js";
|
|
3
2
|
import { array_push_if_unique } from "../../../collection/array/array_push_if_unique.js";
|
|
4
3
|
import { array_remove_first } from "../../../collection/array/array_remove_first.js";
|
|
4
|
+
import { v3_distance } from "../../v3_distance.js";
|
|
5
5
|
|
|
6
6
|
export class TopoVertex {
|
|
7
7
|
constructor() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Miniball } from "../../../packing/miniball/Miniball.js";
|
|
2
2
|
import { PointSet } from "../../../packing/miniball/PointSet.js";
|
|
3
3
|
import { ConicRay } from "../../../ConicRay.js";
|
|
4
|
-
import { v3_angleBetween } from "../../../Vector3.js";
|
|
5
4
|
import { array_copy } from "../../../../collection/array/copyArray.js";
|
|
6
5
|
import { min2 } from "../../../../math/min2.js";
|
|
6
|
+
import { v3_angle_between } from "../../../v3_angle_between.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Using Shirman and Abi-Ezzi method, compute bounding sphere of points, then build a cone from that
|
|
@@ -66,7 +66,7 @@ export function computeTraingleClusterNormalBoundingCone(result, faces) {
|
|
|
66
66
|
const normal_y = normal_data[i3];
|
|
67
67
|
const normal_z = normal_data[i3];
|
|
68
68
|
|
|
69
|
-
const angle =
|
|
69
|
+
const angle = v3_angle_between(
|
|
70
70
|
normal_x, normal_y, normal_z,
|
|
71
71
|
result_direction.x, result_direction.y, result_direction.z
|
|
72
72
|
);
|
package/core/geom/LineSegment.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Created by Alex on 18/03/14.
|
|
3
3
|
*/
|
|
4
4
|
import { clamp } from "../math/clamp.js";
|
|
5
|
-
import Vector3
|
|
5
|
+
import Vector3 from "./Vector3.js";
|
|
6
|
+
import { v3_dot } from "./v3_dot.js";
|
|
7
|
+
import { v3_distance_sqr } from "./v3_distance_sqr.js";
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
const SMALL_NUM = 1e-9;
|
package/core/geom/Matrix4.js
CHANGED
package/core/geom/Plane.js
CHANGED
package/core/geom/Quaternion.js
CHANGED
|
@@ -10,7 +10,8 @@ import { clamp } from "../math/clamp.js";
|
|
|
10
10
|
import { copysign } from "../math/copysign.js";
|
|
11
11
|
import { lerp } from "../math/lerp.js";
|
|
12
12
|
import { EPSILON, epsilonEquals, PI2, PI_HALF } from "../math/MathUtils.js";
|
|
13
|
-
import Vector3
|
|
13
|
+
import Vector3 from "./Vector3.js";
|
|
14
|
+
import { v3_dot } from "./v3_dot.js";
|
|
14
15
|
|
|
15
16
|
const matrix = new ThreeMatrix4();
|
|
16
17
|
|