@woosh/meep-engine 2.41.0 → 2.42.1
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/assert.js +2 -2
- package/core/collection/array/array_swap.js +3 -3
- package/core/collection/map/AsyncLoadingCache.js +47 -0
- package/core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.js +1 -1
- package/core/geom/3d/apply_mat4_transform_to_v3_array.js +2 -4
- package/core/geom/3d/sphere/sphere_radius_sqr_from_v3_array_transformed.js +28 -0
- package/core/geom/Quaternion.js +14 -0
- package/core/math/statistics/computeSampleSize_Cochran.js +3 -3
- package/editor/ecs/component/editors/geom/QuaternionEditor.js +12 -5
- package/engine/Engine.js +6 -1
- package/engine/EngineBootstrapper.js +2 -1
- package/engine/EngineHarness.js +13 -3
- package/engine/asset/AssetManager.js +97 -7
- package/engine/development/performance/AbstractMetric.js +1 -0
- package/engine/development/performance/RingBufferMetric.js +25 -4
- package/engine/ecs/EntityBuilder.js +29 -4
- package/engine/ecs/transform/Transform.js +23 -3
- package/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +17 -1
- package/engine/graphics/ecs/decal/v2/Decal.d.ts +11 -0
- package/engine/graphics/ecs/decal/v2/Decal.js +50 -0
- package/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts +8 -0
- package/engine/graphics/ecs/decal/v2/FPDecalSystem.js +201 -0
- package/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +278 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +8 -1
- package/engine/graphics/ecs/mesh-v2/allocate_v3.js +37 -0
- package/engine/graphics/ecs/mesh-v2/build_three_object.js +4 -0
- package/engine/graphics/geometry/MikkT/AddTriToGroup.js +10 -0
- package/engine/graphics/geometry/MikkT/AssignRecur.js +84 -0
- package/engine/graphics/geometry/MikkT/AvgTSpace.js +38 -0
- package/engine/graphics/geometry/MikkT/Build4RuleGroups.js +96 -0
- package/engine/graphics/geometry/MikkT/BuildNeighborsFast.js +137 -0
- package/engine/graphics/geometry/MikkT/CalcTexArea.js +31 -0
- package/engine/graphics/geometry/MikkT/CompareSubGroups.js +26 -0
- package/engine/graphics/geometry/MikkT/DegenEpilogue.js +220 -0
- package/engine/graphics/geometry/MikkT/DegenPrologue.js +115 -0
- package/engine/graphics/geometry/MikkT/EvalTspace.js +128 -0
- package/engine/graphics/geometry/MikkT/GenerateInitialVerticesIndexList.js +48 -0
- package/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.js +184 -0
- package/engine/graphics/geometry/MikkT/GenerateTSpaces.js +226 -0
- package/engine/graphics/geometry/MikkT/GetEdge.js +45 -0
- package/engine/graphics/geometry/MikkT/GetNormal.js +16 -0
- package/engine/graphics/geometry/MikkT/GetPosition.js +25 -0
- package/engine/graphics/geometry/MikkT/GetTexCoord.js +18 -0
- package/engine/graphics/geometry/MikkT/InitTriInfo.js +180 -0
- package/engine/graphics/geometry/MikkT/Length.js +10 -0
- package/engine/graphics/geometry/MikkT/MakeIndex.js +18 -0
- package/engine/graphics/geometry/MikkT/MikkTSpace.js +197 -2068
- package/engine/graphics/geometry/MikkT/NormalizeSafe.js +21 -0
- package/engine/graphics/geometry/MikkT/NotZero.js +10 -0
- package/engine/graphics/geometry/MikkT/QuickSort.js +54 -0
- package/engine/graphics/geometry/MikkT/QuickSortEdges.js +71 -0
- package/engine/graphics/geometry/MikkT/SSubGroup.js +15 -0
- package/engine/graphics/geometry/MikkT/STSpace.js +36 -0
- package/engine/graphics/geometry/MikkT/constants/GROUP_WITH_ANY.js +1 -0
- package/engine/graphics/geometry/MikkT/constants/INTERNAL_RND_SORT_SEED.js +1 -0
- package/engine/graphics/geometry/MikkT/constants/MARK_DEGENERATE.js +1 -0
- package/engine/graphics/geometry/MikkT/constants/ORIENT_PRESERVING.js +1 -0
- package/engine/graphics/geometry/MikkT/constants/QUAD_ONE_DEGEN_TRI.js +1 -0
- package/engine/graphics/geometry/MikkT/m_getNormal.js +16 -0
- package/engine/graphics/geometry/MikkT/m_getNumFaces.js +8 -0
- package/engine/graphics/geometry/MikkT/m_getNumVerticesOfFace.js +11 -0
- package/engine/graphics/geometry/MikkT/m_getPosition.js +20 -0
- package/engine/graphics/geometry/MikkT/m_getTexCoord.js +16 -0
- package/engine/graphics/geometry/MikkT/m_setTSpace.js +35 -0
- package/engine/graphics/geometry/MikkT/m_setTSpaceBasic.js +22 -0
- package/engine/graphics/geometry/MikkT/malloc.js +16 -0
- package/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.js +52 -0
- package/engine/graphics/geometry/buffered/computeGeometryEquality.js +1 -1
- package/engine/graphics/geometry/buffered/computeGeometryHash.js +1 -1
- package/engine/graphics/impostors/octahedral/ImpostorBaker.js +28 -14
- package/engine/graphics/impostors/octahedral/ImpostorDescription.js +6 -0
- package/engine/graphics/impostors/octahedral/README.md +1 -0
- package/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere.js +25 -22
- package/engine/graphics/impostors/octahedral/bake/compute_bounding_sphere_radius_only.js +37 -0
- package/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +30 -1
- package/engine/graphics/impostors/octahedral/grid/HemiOctahedralUvEncoder.js +1 -1
- package/engine/graphics/impostors/octahedral/prototypeBaker.js +121 -22
- package/engine/graphics/impostors/octahedral/shader/BakeShaderStandard.js +46 -7
- package/engine/graphics/impostors/octahedral/shader/ImpostorShaderV0.js +349 -0
- package/engine/graphics/impostors/octahedral/shader/ImpostorShaderV1.js +74 -0
- package/engine/graphics/impostors/octahedral/shader/glsl/v1/common.glsl +209 -0
- package/engine/graphics/impostors/octahedral/shader/glsl/v1/flagment.glsl +80 -0
- package/engine/graphics/impostors/octahedral/shader/glsl/v1/vertex.glsl +350 -0
- package/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +1 -1
- package/engine/graphics/render/forward_plus/LightManager.js +17 -7
- package/engine/graphics/render/forward_plus/data/TextureBackedMemoryRegion.js +7 -1
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +13 -5
- package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +3 -1
- package/engine/graphics/render/forward_plus/model/Decal.js +19 -2
- package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +14 -2
- package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +2 -2
- package/engine/graphics/texture/sampler/Sampler2D.js +10 -10
- package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +117 -11
- package/engine/graphics/texture/sampler/resize/sampler2d_downsample_mipmap.js +66 -0
- package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +2 -2
- package/engine/intelligence/behavior/util/RotationBehavior.js +69 -0
- package/generation/example/filters/SampleGroundMoistureFilter.js +5 -5
- package/package.json +1 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { GROUP_WITH_ANY } from "./constants/GROUP_WITH_ANY.js";
|
|
2
|
+
import { vec3 } from "gl-matrix";
|
|
3
|
+
import { GetPosition } from "./GetPosition.js";
|
|
4
|
+
import { GetTexCoord } from "./GetTexCoord.js";
|
|
5
|
+
import { ORIENT_PRESERVING } from "./constants/ORIENT_PRESERVING.js";
|
|
6
|
+
import { NotZero } from "./NotZero.js";
|
|
7
|
+
import { fabsf } from "../../../../core/math/fabsf.js";
|
|
8
|
+
import { Length } from "./Length.js";
|
|
9
|
+
import { MARK_DEGENERATE } from "./constants/MARK_DEGENERATE.js";
|
|
10
|
+
import { CalcTexArea } from "./CalcTexArea.js";
|
|
11
|
+
import { BuildNeighborsFast } from "./BuildNeighborsFast.js";
|
|
12
|
+
|
|
13
|
+
const t1 = vec3.create();
|
|
14
|
+
const t2 = vec3.create();
|
|
15
|
+
const t3 = vec3.create();
|
|
16
|
+
|
|
17
|
+
const d1 = vec3.create();
|
|
18
|
+
const d2 = vec3.create();
|
|
19
|
+
|
|
20
|
+
const vOs = vec3.create();
|
|
21
|
+
const vOt = vec3.create();
|
|
22
|
+
|
|
23
|
+
const v1 = vec3.create();
|
|
24
|
+
const v2 = vec3.create();
|
|
25
|
+
const v3 = vec3.create();
|
|
26
|
+
|
|
27
|
+
const v_temp_0 = vec3.create();
|
|
28
|
+
const v_temp_1 = vec3.create();
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {STriInfo[]} pTriInfos
|
|
33
|
+
* @param {number[]|Int32Array} piTriListIn
|
|
34
|
+
* @param {SMikkTSpaceContext} pContext
|
|
35
|
+
* @param {number} iNrTrianglesIn
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
export function InitTriInfo(pTriInfos, piTriListIn, pContext, iNrTrianglesIn) {
|
|
39
|
+
let f = 0, i = 0, t = 0;
|
|
40
|
+
// pTriInfos[f].iFlag is cleared in GenerateInitialVerticesIndexList() which is called before this function.
|
|
41
|
+
|
|
42
|
+
// generate neighbor info list
|
|
43
|
+
for (f = 0; f < iNrTrianglesIn; f++) {
|
|
44
|
+
const tri = pTriInfos[f];
|
|
45
|
+
|
|
46
|
+
for (i = 0; i < 3; i++) {
|
|
47
|
+
|
|
48
|
+
tri.FaceNeighbors[i] = -1;
|
|
49
|
+
tri.AssignedGroup[i] = null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
tri.vOs[0] = 0.0;
|
|
53
|
+
tri.vOs[1] = 0.0;
|
|
54
|
+
tri.vOs[2] = 0.0;
|
|
55
|
+
|
|
56
|
+
tri.vOt[0] = 0.0;
|
|
57
|
+
tri.vOt[1] = 0.0;
|
|
58
|
+
tri.vOt[2] = 0.0;
|
|
59
|
+
|
|
60
|
+
tri.fMagS = 0;
|
|
61
|
+
tri.fMagT = 0;
|
|
62
|
+
|
|
63
|
+
// assumed bad
|
|
64
|
+
tri.iFlag |= GROUP_WITH_ANY;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// evaluate first order derivatives
|
|
69
|
+
for (f = 0; f < iNrTrianglesIn; f++) {
|
|
70
|
+
// initial values
|
|
71
|
+
const f3 = f * 3;
|
|
72
|
+
|
|
73
|
+
GetPosition(v1,0, pContext, piTriListIn[f3 + 0]);
|
|
74
|
+
GetPosition(v2,0, pContext, piTriListIn[f3 + 1]);
|
|
75
|
+
GetPosition(v3,0, pContext, piTriListIn[f3 + 2]);
|
|
76
|
+
|
|
77
|
+
GetTexCoord(t1, pContext, piTriListIn[f3 + 0]);
|
|
78
|
+
GetTexCoord(t2, pContext, piTriListIn[f3 + 1]);
|
|
79
|
+
GetTexCoord(t3, pContext, piTriListIn[f3 + 2]);
|
|
80
|
+
|
|
81
|
+
const t21x = t2[0] - t1[0];
|
|
82
|
+
const t21y = t2[1] - t1[1];
|
|
83
|
+
|
|
84
|
+
const t31x = t3[0] - t1[0];
|
|
85
|
+
const t31y = t3[1] - t1[1];
|
|
86
|
+
|
|
87
|
+
vec3.sub(d1, v2, v1);
|
|
88
|
+
vec3.sub(d2, v3, v1);
|
|
89
|
+
|
|
90
|
+
const fSignedAreaSTx2 = t21x * t31y - t21y * t31x;
|
|
91
|
+
//assert(fSignedAreaSTx2!=0);
|
|
92
|
+
|
|
93
|
+
vec3.scale(v_temp_0, d1, t31y);
|
|
94
|
+
vec3.scale(v_temp_1, d2, t21y);
|
|
95
|
+
vec3.sub(vOs, v_temp_0, v_temp_1); // eq 18
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
vec3.scale(v_temp_0, d1, -t31x);
|
|
99
|
+
vec3.scale(v_temp_1, d2, t21x);
|
|
100
|
+
vec3.add(vOt, v_temp_0, v_temp_1); // eq 19
|
|
101
|
+
|
|
102
|
+
const tri_info = pTriInfos[f];
|
|
103
|
+
tri_info.iFlag |= (fSignedAreaSTx2 > 0 ? ORIENT_PRESERVING : 0);
|
|
104
|
+
|
|
105
|
+
if (NotZero(fSignedAreaSTx2)) {
|
|
106
|
+
const fAbsArea = fabsf(fSignedAreaSTx2);
|
|
107
|
+
|
|
108
|
+
const fLenOs = Length(vOs);
|
|
109
|
+
const fLenOt = Length(vOt);
|
|
110
|
+
|
|
111
|
+
const fS = (tri_info.iFlag & ORIENT_PRESERVING) === 0 ? (-1.0) : 1.0;
|
|
112
|
+
|
|
113
|
+
if (NotZero(fLenOs)) {
|
|
114
|
+
vec3.scale(tri_info.vOs, vOs, fS / fLenOs);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (NotZero(fLenOt)) {
|
|
118
|
+
vec3.scale(tri_info.vOt, vOt, fS / fLenOt);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// evaluate magnitudes prior to normalization of vOs and vOt
|
|
122
|
+
tri_info.fMagS = fLenOs / fAbsArea;
|
|
123
|
+
tri_info.fMagT = fLenOt / fAbsArea;
|
|
124
|
+
|
|
125
|
+
// if this is a good triangle
|
|
126
|
+
if (NotZero(tri_info.fMagS) && NotZero(tri_info.fMagT)) {
|
|
127
|
+
tri_info.iFlag &= (~GROUP_WITH_ANY);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// force otherwise healthy quads to a fixed orientation
|
|
133
|
+
while (t < (iNrTrianglesIn - 1)) {
|
|
134
|
+
const tri_0 = pTriInfos[t];
|
|
135
|
+
const tri_1 = pTriInfos[t + 1];
|
|
136
|
+
|
|
137
|
+
const iFO_a = tri_0.iOrgFaceNumber;
|
|
138
|
+
const iFO_b = tri_1.iOrgFaceNumber;
|
|
139
|
+
|
|
140
|
+
if (iFO_a === iFO_b) {
|
|
141
|
+
// this is a quad
|
|
142
|
+
const bIsDeg_a = (tri_0.iFlag & MARK_DEGENERATE) !== 0;
|
|
143
|
+
const bIsDeg_b = (tri_1.iFlag & MARK_DEGENERATE) !== 0;
|
|
144
|
+
|
|
145
|
+
// bad triangles should already have been removed by
|
|
146
|
+
// DegenPrologue(), but just in case check bIsDeg_a and bIsDeg_a are false
|
|
147
|
+
if ((bIsDeg_a || bIsDeg_b) === false) {
|
|
148
|
+
const bOrientA = (tri_0.iFlag & ORIENT_PRESERVING) !== 0;
|
|
149
|
+
const bOrientB = (tri_1.iFlag & ORIENT_PRESERVING) !== 0;
|
|
150
|
+
|
|
151
|
+
// if this happens the quad has extremely bad mapping!!
|
|
152
|
+
if (bOrientA !== bOrientB) {
|
|
153
|
+
//printf("found quad with bad mapping\n");
|
|
154
|
+
let bChooseOrientFirstTri = false;
|
|
155
|
+
|
|
156
|
+
if ((tri_1.iFlag & GROUP_WITH_ANY) !== 0) {
|
|
157
|
+
bChooseOrientFirstTri = true;
|
|
158
|
+
} else if (CalcTexArea(pContext, piTriListIn, t * 3) >= CalcTexArea(pContext, piTriListIn, (t + 1) * 3 + 0)) {
|
|
159
|
+
bChooseOrientFirstTri = true;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// force match
|
|
163
|
+
const t0 = bChooseOrientFirstTri ? tri_0 : tri_1;
|
|
164
|
+
const t1 = bChooseOrientFirstTri ? tri_1 : tri_0;
|
|
165
|
+
t1.iFlag &= (~ORIENT_PRESERVING); // clear first
|
|
166
|
+
t1.iFlag |= (t0.iFlag & ORIENT_PRESERVING); // copy bit
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
t += 2;
|
|
170
|
+
} else {
|
|
171
|
+
++t;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// match up edge pairs
|
|
176
|
+
|
|
177
|
+
const pEdges = new Float32Array(iNrTrianglesIn * 3 * 3);
|
|
178
|
+
BuildNeighborsFast(pTriInfos, pEdges, piTriListIn, iNrTrianglesIn);
|
|
179
|
+
|
|
180
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number} iFace
|
|
6
|
+
* @param {number} iVert
|
|
7
|
+
* @returns {number}
|
|
8
|
+
*/
|
|
9
|
+
export function MakeIndex(iFace, iVert) {
|
|
10
|
+
assert.greaterThanOrEqual(iVert, 0);
|
|
11
|
+
assert.lessThan(iVert, 4);
|
|
12
|
+
assert.greaterThanOrEqual(iFace, 0);
|
|
13
|
+
|
|
14
|
+
assert.isNonNegativeInteger(iFace,'iFace');
|
|
15
|
+
assert.isNonNegativeInteger(iVert,'iVert');
|
|
16
|
+
|
|
17
|
+
return (iFace << 2) | (iVert & 0x3);
|
|
18
|
+
}
|