@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
package/core/geom/Vector3.js
CHANGED
|
@@ -5,10 +5,15 @@
|
|
|
5
5
|
|
|
6
6
|
import { assert } from "../assert.js";
|
|
7
7
|
import Signal from "../events/signal/Signal.js";
|
|
8
|
-
import { clamp } from "../math/clamp.js";
|
|
9
8
|
import { lerp } from "../math/lerp.js";
|
|
10
9
|
import { computeHashFloat, EPSILON, epsilonEquals } from "../math/MathUtils.js";
|
|
11
10
|
import { sign } from "../math/sign.js";
|
|
11
|
+
import { v3_dot } from "./v3_dot.js";
|
|
12
|
+
import { v3_length_sqr } from "./v3_length_sqr.js";
|
|
13
|
+
import { v3_length } from "./v3_length.js";
|
|
14
|
+
import { v3_angle_between } from "./v3_angle_between.js";
|
|
15
|
+
import { v3_lerp } from "./v3_lerp.js";
|
|
16
|
+
import { v3_slerp } from "./v3_slerp.js";
|
|
12
17
|
|
|
13
18
|
class Vector3 {
|
|
14
19
|
/**
|
|
@@ -442,7 +447,7 @@ class Vector3 {
|
|
|
442
447
|
* @returns {number}
|
|
443
448
|
*/
|
|
444
449
|
angleTo(other) {
|
|
445
|
-
return
|
|
450
|
+
return v3_angle_between(this.x, this.y, this.z, other.x, other.y, other.z);
|
|
446
451
|
}
|
|
447
452
|
|
|
448
453
|
/**
|
|
@@ -534,6 +539,32 @@ class Vector3 {
|
|
|
534
539
|
return this.set(_x, _y, _z);
|
|
535
540
|
}
|
|
536
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Assume current vector holds a direction, transform using a matrix to produce a new directional unit vector
|
|
544
|
+
* @param {THREE.Matrix4} m
|
|
545
|
+
*/
|
|
546
|
+
transformDirection_three(m) {
|
|
547
|
+
|
|
548
|
+
// input: THREE.Matrix4 affine matrix
|
|
549
|
+
// vector interpreted as a direction
|
|
550
|
+
|
|
551
|
+
const x = this.x, y = this.y, z = this.z;
|
|
552
|
+
const e = m.elements;
|
|
553
|
+
|
|
554
|
+
const _x = e[0] * x + e[4] * y + e[8] * z;
|
|
555
|
+
const _y = e[1] * x + e[5] * y + e[9] * z;
|
|
556
|
+
const _z = e[2] * x + e[6] * y + e[10] * z;
|
|
557
|
+
|
|
558
|
+
// normalize the result
|
|
559
|
+
const _l = 1 / v3_length(_x, _y, _z);
|
|
560
|
+
|
|
561
|
+
this.set(
|
|
562
|
+
_x * _l,
|
|
563
|
+
_y * _l,
|
|
564
|
+
_z * _l
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
|
|
537
568
|
/**
|
|
538
569
|
*
|
|
539
570
|
* @param {THREE.Matrix3} m
|
|
@@ -947,20 +978,6 @@ Vector3.back = Object.freeze(new Vector3(0, 0, -1));
|
|
|
947
978
|
Vector3.typeName = "Vector3";
|
|
948
979
|
|
|
949
980
|
|
|
950
|
-
/**
|
|
951
|
-
*
|
|
952
|
-
* @param {number} x0
|
|
953
|
-
* @param {number} y0
|
|
954
|
-
* @param {number} z0
|
|
955
|
-
* @param {number} x1
|
|
956
|
-
* @param {number} y1
|
|
957
|
-
* @param {number} z1
|
|
958
|
-
* @returns {number}
|
|
959
|
-
*/
|
|
960
|
-
export function v3_dot(x0, y0, z0, x1, y1, z1) {
|
|
961
|
-
return (x0 * x1 + y0 * y1 + z0 * z1);
|
|
962
|
-
}
|
|
963
|
-
|
|
964
981
|
/**
|
|
965
982
|
*
|
|
966
983
|
* @param {number} x0
|
|
@@ -973,87 +990,11 @@ export function v3_dot(x0, y0, z0, x1, y1, z1) {
|
|
|
973
990
|
*/
|
|
974
991
|
Vector3._dot = v3_dot;
|
|
975
992
|
|
|
976
|
-
/**
|
|
977
|
-
*
|
|
978
|
-
* @param {number} x0
|
|
979
|
-
* @param {number} y0
|
|
980
|
-
* @param {number} z0
|
|
981
|
-
* @param {number} x1
|
|
982
|
-
* @param {number} y1
|
|
983
|
-
* @param {number} z1
|
|
984
|
-
* @returns {number}
|
|
985
|
-
*/
|
|
986
|
-
export function v3_distance(x0, y0, z0, x1, y1, z1) {
|
|
987
|
-
|
|
988
|
-
return Math.sqrt(v3_distance_sqr(x0, y0, z0, x1, y1, z1));
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
/**
|
|
992
|
-
*
|
|
993
|
-
* @param {number} x0
|
|
994
|
-
* @param {number} y0
|
|
995
|
-
* @param {number} z0
|
|
996
|
-
* @param {number} x1
|
|
997
|
-
* @param {number} y1
|
|
998
|
-
* @param {number} z1
|
|
999
|
-
* @returns {number}
|
|
1000
|
-
*/
|
|
1001
|
-
export function v3_distance_sqr(x0, y0, z0, x1, y1, z1) {
|
|
1002
|
-
const x = x0 - x1;
|
|
1003
|
-
const y = y0 - y1;
|
|
1004
|
-
const z = z0 - z1;
|
|
1005
|
-
|
|
1006
|
-
return x * x + y * y + z * z;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
993
|
|
|
1010
994
|
function v3Length(v) {
|
|
1011
995
|
return v3_length(v.x, v.y, v.z);
|
|
1012
996
|
}
|
|
1013
997
|
|
|
1014
|
-
export function v3_length(x, y, z) {
|
|
1015
|
-
return Math.sqrt(v3_length_sqr(x, y, z));
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
/**
|
|
1019
|
-
*
|
|
1020
|
-
* @param {number} x
|
|
1021
|
-
* @param {number} y
|
|
1022
|
-
* @param {number} z
|
|
1023
|
-
* @return {number}
|
|
1024
|
-
*/
|
|
1025
|
-
export function v3_length_sqr(x, y, z) {
|
|
1026
|
-
return x * x + y * y + z * z;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
/**
|
|
1031
|
-
*
|
|
1032
|
-
* @param {number} x0
|
|
1033
|
-
* @param {number} y0
|
|
1034
|
-
* @param {number} z0
|
|
1035
|
-
* @param {number} x1
|
|
1036
|
-
* @param {number} y1
|
|
1037
|
-
* @param {number} z1
|
|
1038
|
-
* @returns {number}
|
|
1039
|
-
*/
|
|
1040
|
-
export function v3_angleBetween(x0, y0, z0, x1, y1, z1) {
|
|
1041
|
-
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
1042
|
-
|
|
1043
|
-
const magnitude_0 = v3_length(x0, y0, z0);
|
|
1044
|
-
const magnitude_1 = v3_length(x1, y1, z1);
|
|
1045
|
-
|
|
1046
|
-
const l = magnitude_0 * magnitude_1;
|
|
1047
|
-
|
|
1048
|
-
if (l === 0) {
|
|
1049
|
-
// collective magnitude is 0, provide arbitrary angle
|
|
1050
|
-
return 0;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
const theta = clamp(d / l, -1, 1);
|
|
1054
|
-
|
|
1055
|
-
return Math.acos(theta);
|
|
1056
|
-
}
|
|
1057
998
|
|
|
1058
999
|
/**
|
|
1059
1000
|
*
|
|
@@ -1067,70 +1008,4 @@ function v3Lerp(result, a, b, fraction) {
|
|
|
1067
1008
|
v3_lerp(result, a.x, a.y, a.z, b.x, b.y, b.z, fraction);
|
|
1068
1009
|
}
|
|
1069
1010
|
|
|
1070
|
-
/**
|
|
1071
|
-
*
|
|
1072
|
-
* @param {Vector3} result
|
|
1073
|
-
* @param {number} a_x
|
|
1074
|
-
* @param {number} a_y
|
|
1075
|
-
* @param {number} a_z
|
|
1076
|
-
* @param {number} b_x
|
|
1077
|
-
* @param {number} b_y
|
|
1078
|
-
* @param {number} b_z
|
|
1079
|
-
* @param {number} fraction
|
|
1080
|
-
*/
|
|
1081
|
-
function v3_lerp(result, a_x, a_y, a_z, b_x, b_y, b_z, fraction) {
|
|
1082
|
-
|
|
1083
|
-
const x = lerp(a_x, b_x, fraction);
|
|
1084
|
-
const y = lerp(a_y, b_y, fraction);
|
|
1085
|
-
const z = lerp(a_z, b_z, fraction);
|
|
1086
|
-
|
|
1087
|
-
result.set(x, y, z);
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
* Spherical linear interpolation
|
|
1092
|
-
* @see https://en.wikipedia.org/wiki/Slerp
|
|
1093
|
-
* @param {Vector3} result
|
|
1094
|
-
* @param {number} a_x
|
|
1095
|
-
* @param {number} a_y
|
|
1096
|
-
* @param {number} a_z
|
|
1097
|
-
* @param {number} b_x
|
|
1098
|
-
* @param {number} b_y
|
|
1099
|
-
* @param {number} b_z
|
|
1100
|
-
* @param {number} fraction
|
|
1101
|
-
*/
|
|
1102
|
-
export function v3_slerp(
|
|
1103
|
-
result,
|
|
1104
|
-
a_x, a_y, a_z,
|
|
1105
|
-
b_x, b_y, b_z,
|
|
1106
|
-
fraction
|
|
1107
|
-
) {
|
|
1108
|
-
const dot = v3_dot(
|
|
1109
|
-
a_x, a_y, a_z,
|
|
1110
|
-
b_x, b_y, b_z
|
|
1111
|
-
);
|
|
1112
|
-
|
|
1113
|
-
if (dot >= 1 || dot <= -1) {
|
|
1114
|
-
// avoid division by 0, both vectors are pointing in the same direction, use lerp instead
|
|
1115
|
-
v3_lerp(result, a_x, a_y, a_z, b_x, b_y, b_z, fraction);
|
|
1116
|
-
return;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
// compute angle between two vectors
|
|
1120
|
-
const theta = Math.acos(dot);
|
|
1121
|
-
|
|
1122
|
-
const sin_theta = Math.sin(theta);
|
|
1123
|
-
|
|
1124
|
-
const inv_sin_theta = 1 / sin_theta;
|
|
1125
|
-
|
|
1126
|
-
const scale_0 = Math.sin((1 - fraction) * theta) * inv_sin_theta;
|
|
1127
|
-
const scale_1 = Math.sin((fraction) * theta) * inv_sin_theta;
|
|
1128
|
-
|
|
1129
|
-
const x = a_x * scale_0 + b_x * scale_1;
|
|
1130
|
-
const y = a_y * scale_0 + b_y * scale_1;
|
|
1131
|
-
const z = a_z * scale_0 + b_z * scale_1;
|
|
1132
|
-
|
|
1133
|
-
result.set(x, y, z);
|
|
1134
|
-
}
|
|
1135
|
-
|
|
1136
1011
|
export default Vector3;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { v3_dot } from "./v3_dot.js";
|
|
2
|
+
import { v3_length } from "./v3_length.js";
|
|
3
|
+
import { clamp } from "../math/clamp.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {number} x0
|
|
8
|
+
* @param {number} y0
|
|
9
|
+
* @param {number} z0
|
|
10
|
+
* @param {number} x1
|
|
11
|
+
* @param {number} y1
|
|
12
|
+
* @param {number} z1
|
|
13
|
+
* @returns {number}
|
|
14
|
+
*/
|
|
15
|
+
export function v3_angle_between(x0, y0, z0, x1, y1, z1) {
|
|
16
|
+
const d = v3_dot(x0, y0, z0, x1, y1, z1);
|
|
17
|
+
|
|
18
|
+
const magnitude_0 = v3_length(x0, y0, z0);
|
|
19
|
+
const magnitude_1 = v3_length(x1, y1, z1);
|
|
20
|
+
|
|
21
|
+
const l = magnitude_0 * magnitude_1;
|
|
22
|
+
|
|
23
|
+
if (l === 0) {
|
|
24
|
+
// collective magnitude is 0, provide arbitrary angle
|
|
25
|
+
return 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const theta = clamp(d / l, -1, 1);
|
|
29
|
+
|
|
30
|
+
return Math.acos(theta);
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { v3_distance_sqr } from "./v3_distance_sqr.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number} x0
|
|
6
|
+
* @param {number} y0
|
|
7
|
+
* @param {number} z0
|
|
8
|
+
* @param {number} x1
|
|
9
|
+
* @param {number} y1
|
|
10
|
+
* @param {number} z1
|
|
11
|
+
* @returns {number}
|
|
12
|
+
*/
|
|
13
|
+
export function v3_distance(x0, y0, z0, x1, y1, z1) {
|
|
14
|
+
|
|
15
|
+
return Math.sqrt(v3_distance_sqr(x0, y0, z0, x1, y1, z1));
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number} x0
|
|
4
|
+
* @param {number} y0
|
|
5
|
+
* @param {number} z0
|
|
6
|
+
* @param {number} x1
|
|
7
|
+
* @param {number} y1
|
|
8
|
+
* @param {number} z1
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function v3_distance_sqr(x0, y0, z0, x1, y1, z1) {
|
|
12
|
+
const x = x0 - x1;
|
|
13
|
+
const y = y0 - y1;
|
|
14
|
+
const z = z0 - z1;
|
|
15
|
+
|
|
16
|
+
return x * x + y * y + z * z;
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number} x0
|
|
4
|
+
* @param {number} y0
|
|
5
|
+
* @param {number} z0
|
|
6
|
+
* @param {number} x1
|
|
7
|
+
* @param {number} y1
|
|
8
|
+
* @param {number} z1
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function v3_dot(x0, y0, z0, x1, y1, z1) {
|
|
12
|
+
return (x0 * x1 + y0 * y1 + z0 * z1);
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { lerp } from "../math/lerp.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {Vector3} result
|
|
6
|
+
* @param {number} a_x
|
|
7
|
+
* @param {number} a_y
|
|
8
|
+
* @param {number} a_z
|
|
9
|
+
* @param {number} b_x
|
|
10
|
+
* @param {number} b_y
|
|
11
|
+
* @param {number} b_z
|
|
12
|
+
* @param {number} fraction
|
|
13
|
+
*/
|
|
14
|
+
export function v3_lerp(result, a_x, a_y, a_z, b_x, b_y, b_z, fraction) {
|
|
15
|
+
|
|
16
|
+
const x = lerp(a_x, b_x, fraction);
|
|
17
|
+
const y = lerp(a_y, b_y, fraction);
|
|
18
|
+
const z = lerp(a_z, b_z, fraction);
|
|
19
|
+
|
|
20
|
+
result.set(x, y, z);
|
|
21
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { v3_dot } from "./v3_dot.js";
|
|
2
|
+
import { v3_lerp } from "./v3_lerp.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Spherical linear interpolation
|
|
6
|
+
* @see https://en.wikipedia.org/wiki/Slerp
|
|
7
|
+
* @param {Vector3} result
|
|
8
|
+
* @param {number} a_x
|
|
9
|
+
* @param {number} a_y
|
|
10
|
+
* @param {number} a_z
|
|
11
|
+
* @param {number} b_x
|
|
12
|
+
* @param {number} b_y
|
|
13
|
+
* @param {number} b_z
|
|
14
|
+
* @param {number} fraction
|
|
15
|
+
*/
|
|
16
|
+
export function v3_slerp(
|
|
17
|
+
result,
|
|
18
|
+
a_x, a_y, a_z,
|
|
19
|
+
b_x, b_y, b_z,
|
|
20
|
+
fraction
|
|
21
|
+
) {
|
|
22
|
+
const dot = v3_dot(
|
|
23
|
+
a_x, a_y, a_z,
|
|
24
|
+
b_x, b_y, b_z
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
if (dot >= 1 || dot <= -1) {
|
|
28
|
+
// avoid division by 0, both vectors are pointing in the same direction, use lerp instead
|
|
29
|
+
v3_lerp(result, a_x, a_y, a_z, b_x, b_y, b_z, fraction);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// compute angle between two vectors
|
|
34
|
+
const theta = Math.acos(dot);
|
|
35
|
+
|
|
36
|
+
const sin_theta = Math.sin(theta);
|
|
37
|
+
|
|
38
|
+
const inv_sin_theta = 1 / sin_theta;
|
|
39
|
+
|
|
40
|
+
const scale_0 = Math.sin((1 - fraction) * theta) * inv_sin_theta;
|
|
41
|
+
const scale_1 = Math.sin((fraction) * theta) * inv_sin_theta;
|
|
42
|
+
|
|
43
|
+
const x = a_x * scale_0 + b_x * scale_1;
|
|
44
|
+
const y = a_y * scale_0 + b_y * scale_1;
|
|
45
|
+
const z = a_z * scale_0 + b_z * scale_1;
|
|
46
|
+
|
|
47
|
+
result.set(x, y, z);
|
|
48
|
+
}
|
|
@@ -11,6 +11,11 @@ export function computeIntegerArrayHash(data, offset, length) {
|
|
|
11
11
|
|
|
12
12
|
for (let i = offset; i < end; i++) {
|
|
13
13
|
const singleValue = data[i];
|
|
14
|
+
/**
|
|
15
|
+
* Simple hashing scheme, multiplying existing hash by a prime and adding next value
|
|
16
|
+
* (h<<5) - h === h*31
|
|
17
|
+
* @type {number}
|
|
18
|
+
*/
|
|
14
19
|
hash = ((hash << 5) - hash) + singleValue;
|
|
15
20
|
hash |= 0; // Convert to 32bit integer
|
|
16
21
|
}
|
|
@@ -59,8 +59,7 @@ export function computeMaterialHash(material) {
|
|
|
59
59
|
computeTextureHash(material.alphaMap),
|
|
60
60
|
computeHashFloat(material.envMapIntensity),
|
|
61
61
|
computeTextureHash(material.envMap)
|
|
62
|
-
)
|
|
63
|
-
;
|
|
62
|
+
);
|
|
64
63
|
} else if (material.isShaderMaterial) {
|
|
65
64
|
hash ^= material.lights ? 0 : 1;
|
|
66
65
|
}
|
|
@@ -51,6 +51,7 @@ export function computeTextureEquality(a, b) {
|
|
|
51
51
|
const bMipmaps = b.mipmaps;
|
|
52
52
|
|
|
53
53
|
const n = aMipmaps.length;
|
|
54
|
+
|
|
54
55
|
if (n !== bMipmaps.length) {
|
|
55
56
|
return false;
|
|
56
57
|
}
|
|
@@ -72,8 +73,8 @@ export function computeTextureEquality(a, b) {
|
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
75
|
*
|
|
75
|
-
* @param {Image|[]} a
|
|
76
|
-
* @param {Image|[]} b
|
|
76
|
+
* @param {Image|[]|{width:number, height:number}} a
|
|
77
|
+
* @param {Image|[]|{width:number, height:number}} b
|
|
77
78
|
* @returns {boolean}
|
|
78
79
|
*/
|
|
79
80
|
export function textureImagesEqual(a, b) {
|
|
@@ -89,6 +90,14 @@ export function textureImagesEqual(a, b) {
|
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
|
|
93
|
+
if (
|
|
94
|
+
(typeof a.width === "number" && a.width !== b.width)
|
|
95
|
+
|| (typeof a.height === "number" && a.height !== b.height)
|
|
96
|
+
) {
|
|
97
|
+
// dimensions are present, but are inconsistent
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
|
|
92
101
|
if (a instanceof ImageBitmap && b instanceof ImageBitmap) {
|
|
93
102
|
return computeImageBitmapEquality(a, b);
|
|
94
103
|
}
|
|
@@ -148,11 +157,10 @@ export function textureImagesEqual(a, b) {
|
|
|
148
157
|
}
|
|
149
158
|
}
|
|
150
159
|
|
|
151
|
-
//array images are equivalent
|
|
152
|
-
return true;
|
|
153
160
|
}
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
// assume equivalent
|
|
163
|
+
return true;
|
|
156
164
|
}
|
|
157
165
|
|
|
158
166
|
|
|
@@ -3,9 +3,11 @@ import { inverseLerp } from "../../../core/math/inverseLerp.js";
|
|
|
3
3
|
import { IKSolver } from "./IKSolver.js";
|
|
4
4
|
import { findSkeletonBoneByType } from "../../graphics/ecs/mesh/SkeletonUtils.js";
|
|
5
5
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
6
|
-
import Vector3
|
|
6
|
+
import Vector3 from "../../../core/geom/Vector3.js";
|
|
7
7
|
import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
|
|
8
8
|
import { v3_computeOffsetVector } from "./IKMath.js";
|
|
9
|
+
import { v3_dot } from "../../../core/geom/v3_dot.js";
|
|
10
|
+
import { v3_length } from "../../../core/geom/v3_length.js";
|
|
9
11
|
|
|
10
12
|
const boneWorldPosition = new Vector3();
|
|
11
13
|
const boneWorldRotation = new Quaternion();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../../core/assert.js";
|
|
2
|
-
import Vector3
|
|
2
|
+
import Vector3 from "../../../core/geom/Vector3.js";
|
|
3
3
|
import { clamp } from "../../../core/math/clamp.js";
|
|
4
4
|
import { inverseLerp } from "../../../core/math/inverseLerp.js";
|
|
5
5
|
import Quaternion from "../../../core/geom/Quaternion.js";
|
|
@@ -7,6 +7,8 @@ import { findSkeletonBoneByType } from "../../graphics/ecs/mesh/SkeletonUtils.js
|
|
|
7
7
|
import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
|
|
8
8
|
import { IKSolver } from "./IKSolver.js";
|
|
9
9
|
import { v3_computeOffsetVector } from "./IKMath.js";
|
|
10
|
+
import { v3_dot } from "../../../core/geom/v3_dot.js";
|
|
11
|
+
import { v3_length } from "../../../core/geom/v3_length.js";
|
|
10
12
|
|
|
11
13
|
const boneWorldPositionC = new Vector3();
|
|
12
14
|
const boneWorldPositionB = new Vector3();
|
|
@@ -5,7 +5,6 @@ import { Sampler2D } from "../../graphics/texture/sampler/Sampler2D.js";
|
|
|
5
5
|
import { ClampToEdgeWrapping, DataTexture, LinearFilter, RedFormat, UnsignedByteType } from "three";
|
|
6
6
|
import Vector1 from "../../../core/geom/Vector1.js";
|
|
7
7
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
8
|
-
import Vector3 from "../../../core/geom/Vector3.js";
|
|
9
8
|
import { assert } from "../../../core/assert.js";
|
|
10
9
|
import { computeUnsignedDistanceField } from "../../graphics/texture/sampler/distanceField.js";
|
|
11
10
|
import Vector4 from "../../../core/geom/Vector4.js";
|
|
@@ -357,7 +356,7 @@ export class FogOfWar {
|
|
|
357
356
|
}
|
|
358
357
|
|
|
359
358
|
|
|
360
|
-
this.on.textureChanged.
|
|
359
|
+
this.on.textureChanged.send0();
|
|
361
360
|
|
|
362
361
|
//clear flag
|
|
363
362
|
this.textureNeedsUpdate = false;
|
|
@@ -534,7 +533,7 @@ export class FogOfWar {
|
|
|
534
533
|
const sampleX = samplePosition[0];
|
|
535
534
|
const sampleY = samplePosition[1];
|
|
536
535
|
|
|
537
|
-
return this.distanceSampler.readChannel(sampleX|0, sampleY|0, 0);
|
|
536
|
+
return this.distanceSampler.readChannel(sampleX | 0, sampleY | 0, 0);
|
|
538
537
|
}
|
|
539
538
|
|
|
540
539
|
rebuildDistanceField() {
|
|
@@ -85,7 +85,6 @@ class HeadsUpDisplaySystem extends System {
|
|
|
85
85
|
* @private
|
|
86
86
|
*/
|
|
87
87
|
__apply_entity_transformation(hud, transform, vp, element) {
|
|
88
|
-
const position = transform.position;
|
|
89
88
|
const worldOffset = hud.worldOffset;
|
|
90
89
|
|
|
91
90
|
let worldOffsetX = worldOffset.x;
|
|
@@ -107,6 +106,7 @@ class HeadsUpDisplaySystem extends System {
|
|
|
107
106
|
v4.applyQuaternion(transform.rotation);
|
|
108
107
|
}
|
|
109
108
|
|
|
109
|
+
const position = transform.position;
|
|
110
110
|
|
|
111
111
|
v4.add3(position);
|
|
112
112
|
|
|
@@ -11,8 +11,9 @@ import Motion from '../components/Motion.js';
|
|
|
11
11
|
import { Transform } from '../transform/Transform.js';
|
|
12
12
|
import Steering, { SteeringEvents, SteeringFlags } from '../components/Steering.js';
|
|
13
13
|
import { solveQuadratic } from "../../../core/math/MathUtils.js";
|
|
14
|
-
import Vector3
|
|
14
|
+
import Vector3 from "../../../core/geom/Vector3.js";
|
|
15
15
|
import { alignToVector } from "../terrain/ecs/ClingToTerrainSystem.js";
|
|
16
|
+
import { v3_dot } from "../../../core/geom/v3_dot.js";
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
*
|
|
@@ -461,6 +461,10 @@ class Terrain {
|
|
|
461
461
|
this.__material_reference.release();
|
|
462
462
|
|
|
463
463
|
this.tiles.dispose();
|
|
464
|
+
this.splat.dispose();
|
|
465
|
+
this.layers.dispose();
|
|
466
|
+
|
|
467
|
+
this.heightTexture.dispose();
|
|
464
468
|
|
|
465
469
|
this.clearFlag(TerrainFlags.Linked);
|
|
466
470
|
}
|
|
@@ -1045,6 +1049,8 @@ class Terrain {
|
|
|
1045
1049
|
return texture;
|
|
1046
1050
|
});
|
|
1047
1051
|
|
|
1052
|
+
// TODO ensure cleanup when terrain is unlinked
|
|
1053
|
+
|
|
1048
1054
|
return result;
|
|
1049
1055
|
}
|
|
1050
1056
|
|
|
@@ -344,6 +344,24 @@ GraphicsEngine.prototype.start = function () {
|
|
|
344
344
|
};
|
|
345
345
|
|
|
346
346
|
const webGLRenderer = this.renderer = new WebGLRenderer(rendererParameters);
|
|
347
|
+
|
|
348
|
+
let g = 0;
|
|
349
|
+
let t = 0;
|
|
350
|
+
webGLRenderer.info.memory = {
|
|
351
|
+
get geometries() {
|
|
352
|
+
return g;
|
|
353
|
+
},
|
|
354
|
+
set geometries(v) {
|
|
355
|
+
g = v;
|
|
356
|
+
},
|
|
357
|
+
get textures() {
|
|
358
|
+
return t;
|
|
359
|
+
},
|
|
360
|
+
set textures(v) {
|
|
361
|
+
t = v;
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
|
|
347
365
|
//print GPU info
|
|
348
366
|
const GPU_NAME = this.getGPUName();
|
|
349
367
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isValueBetweenInclusive } from "../../../../core/math/MathUtils.js";
|
|
2
2
|
import { frustumFromCamera } from "./CameraSystem.js";
|
|
3
3
|
import { Frustum as ThreeFrustum } from "three";
|
|
4
|
-
import { v3_dot } from "../../../../core/geom/
|
|
4
|
+
import { v3_dot } from "../../../../core/geom/v3_dot.js";
|
|
5
5
|
|
|
6
6
|
const CLIPPING_EPSILON = 0.001;
|
|
7
7
|
|