@woosh/meep-engine 2.33.3 → 2.33.8

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 (128) hide show
  1. package/core/bvh2/LeafNode.js +6 -1
  2. package/core/bvh2/aabb3/AABB3.js +21 -1
  3. package/core/bvh2/aabb3/aabb3_intersects_frustum.js +10 -2
  4. package/core/collection/RingBuffer.js +40 -10
  5. package/core/collection/array/copyArray.js +2 -2
  6. package/core/collection/array/typed/typed_array_copy.js +2 -2
  7. package/core/collection/set/compute_set_difference.js +32 -0
  8. package/core/collection/set/compute_set_intersection.js +22 -0
  9. package/core/collection/set/set_remove.js +15 -0
  10. package/core/collection/table/RowFirstTableSpec.js +8 -0
  11. package/core/color/Color.js +1 -0
  12. package/core/color/ColorUtils.js +12 -3
  13. package/core/geom/3d/aabb/aabb3_compute_projected_area.js +6 -4
  14. package/core/geom/3d/aabb/aabb3_estimate_projected_area2.js +59 -0
  15. package/core/geom/3d/aabb/aabb3_from_min_max.js +15 -0
  16. package/core/geom/3d/aabb/aabb3_matrix4_project.js +33 -0
  17. package/core/geom/3d/aabb/aabb3_matrix4_project.spec.js +41 -0
  18. package/core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js +96 -0
  19. package/{engine/graphics/micron/render/v1 → core/geom/3d}/apply_mat4_transform_to_v3_array.js +0 -0
  20. package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_cone_of_2_cones.js +3 -3
  21. package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_cone_of_2_cones.spec.js +1 -1
  22. package/{engine/graphics/micron/build/bounds → core/geom/3d}/compute_bounding_sphere_of_2_spheres.js +3 -3
  23. package/{engine/graphics/micron/util → core/geom/3d}/encode_unit3_hemioct.js +0 -0
  24. package/core/geom/3d/frustum/array_normalize_plane.js +25 -0
  25. package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +60 -0
  26. package/{engine/graphics/micron/util → core/geom/3d}/unit_hemioct.spec.js +1 -1
  27. package/{engine/graphics/micron/build → core}/graph/MultiNode.js +0 -0
  28. package/{engine/graphics/micron/build → core}/graph/SquareMatrix.js +2 -2
  29. package/{engine/graphics/micron/build → core}/graph/SquareMatrix.spec.js +1 -1
  30. package/{engine/graphics/micron/build → core}/graph/WeightedEdge.js +1 -1
  31. package/{engine/graphics/micron/build → core}/graph/build_face_graph_from_mesh.js +2 -2
  32. package/{engine/graphics/micron/build/clustering → core/graph}/cluster_mesh_metis.js +2 -6
  33. package/{engine/graphics/micron/build → core}/graph/coarsen_graph.js +1 -1
  34. package/{engine/graphics/micron/build → core}/graph/coarsen_graph.spec.js +1 -1
  35. package/{engine/graphics/micron/build → core}/graph/eigen/eigen.js +0 -0
  36. package/{engine/graphics/micron/build → core}/graph/eigen/eigen.spec.js +1 -1
  37. package/{engine/graphics/micron/build/hierarchy → core/graph/eigen}/eigen_values_find_spectral_gap.js +0 -0
  38. package/{engine/graphics/micron/build → core}/graph/graph_adjacency_matrix.js +0 -0
  39. package/{engine/graphics/micron/build → core}/graph/graph_compute_disconnected_clusters.js +0 -0
  40. package/{engine/graphics/micron/build → core}/graph/graph_degree_matrix.js +0 -0
  41. package/{engine/graphics/micron/build → core}/graph/graph_k_means_cluster.js +5 -5
  42. package/{engine/graphics/micron/build → core}/graph/graph_laplacian_matrix.js +1 -1
  43. package/{engine/graphics/micron/build → core}/graph/metis/metis.js +2 -2
  44. package/{engine/graphics/micron/build → core}/graph/metis/metis_options.js +0 -0
  45. package/{engine/graphics/micron/build → core}/graph/mn_graph_collapse_weighted_edge.js +0 -0
  46. package/core/process/undo/ActionProcessor.d.ts +2 -0
  47. package/core/process/undo/ActionProcessor.js +59 -1
  48. package/core/process/undo/ActionProcessor.spec.js +59 -0
  49. package/core/process/undo/Mark.js +2 -1
  50. package/engine/Engine.d.ts +2 -0
  51. package/engine/EngineHarness.js +4 -4
  52. package/engine/asset/loaders/material/bitmap2sampler_gl.js +19 -0
  53. package/engine/asset/loaders/material/computeImageBitmapEquality.js +7 -19
  54. package/engine/ecs/transform/Transform.js +2 -1
  55. package/engine/graphics/GraphicsEngine.js +9 -116
  56. package/engine/graphics/ecs/mesh/updateNodeByTransformAndBBB.js +22 -37
  57. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +155 -0
  58. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +68 -0
  59. package/engine/graphics/ecs/mesh-v2/prototypeShadedGeometry.js +31 -0
  60. package/engine/graphics/filter/FlipArrayInPlace.js +25 -0
  61. package/engine/graphics/filter/FlipArrayViaCanvas.js +13 -0
  62. package/engine/graphics/filter/ImageFilter.js +20 -51
  63. package/engine/graphics/{micron → geometry}/aabb3_to_buffer_geometry.js +0 -0
  64. package/engine/graphics/{micron/build → geometry/buffered}/compute_buffer_geometry_byte_size.js +0 -0
  65. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +25 -16
  66. package/engine/graphics/material/SplatMaterial.js +4 -97
  67. package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +2 -6
  68. package/engine/graphics/micron/build/clustering/build_clustering_2.js +2 -2
  69. package/engine/graphics/micron/build/clustering/build_leaf_patches_metis.js +1 -1
  70. package/engine/graphics/micron/build/fill_patch_geometry_data.js +2 -0
  71. package/engine/graphics/micron/build/hierarchy/buildAbstractPatchHierarchy.js +3 -3
  72. package/engine/graphics/micron/build/hierarchy/build_intermediate_patch_topology.js +0 -72
  73. package/engine/graphics/micron/build/hierarchy/build_merge_graph.js +2 -2
  74. package/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +3 -3
  75. package/engine/graphics/micron/build/hierarchy/merge_patches.js +6 -3
  76. package/engine/graphics/micron/build/hierarchy/metis_cluster_clusters.js +1 -1
  77. package/engine/graphics/micron/build/hierarchy/optimize_graph_partitioning_balance.js +1 -1
  78. package/engine/graphics/micron/build/hierarchy/patch_combine.js +2 -2
  79. package/engine/graphics/micron/build/hierarchy/qvdr_build_simplified_clusters.js +2 -1
  80. package/engine/graphics/micron/format/MicronGeometryBufferAttributeSpec.js +1 -1
  81. package/engine/graphics/micron/format/MicronGeometryPatch.js +11 -3
  82. package/engine/graphics/micron/format/MicronVertexDataSpec.js +25 -3
  83. package/engine/graphics/micron/prototypeVirtualGeometry.js +4 -4
  84. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +28 -26
  85. package/engine/graphics/micron/render/culling/{PathCullingSystem.js → PatchCullingSystem.js} +1 -1
  86. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +2 -4
  87. package/engine/graphics/micron/render/refinement/ActivePatchList.js +40 -80
  88. package/engine/graphics/micron/render/refinement/ActivePatchRecord.js +4 -2
  89. package/engine/graphics/micron/render/refinement/RefinementSpec.js +98 -0
  90. package/engine/graphics/micron/render/v1/MaterialVertexSpec.js +21 -0
  91. package/engine/graphics/micron/render/v1/VGThreeRenderer.js +12 -9
  92. package/engine/graphics/micron/render/v1/getTransformedPositionsCached.js +1 -1
  93. package/engine/graphics/render/buffer/buffers/ColorAndDepthFrameBuffer.js +5 -3
  94. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +8 -10
  95. package/engine/graphics/render/forward_plus/LightManager.js +5 -7
  96. package/engine/graphics/render/forward_plus/data/NumericType.js +9 -0
  97. package/engine/graphics/render/forward_plus/{TextureBackedMemoryRegion.js → data/TextureBackedMemoryRegion.js} +11 -190
  98. package/engine/graphics/render/forward_plus/data/channelCountToThreIntegerTextureType.js +16 -0
  99. package/engine/graphics/render/forward_plus/data/computeDataType.js +36 -0
  100. package/engine/graphics/render/forward_plus/data/computeThreeTextureFormat.js +18 -0
  101. package/engine/graphics/render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js +63 -0
  102. package/engine/graphics/render/forward_plus/data/computeThreeTextureTypeFromDataType.js +41 -0
  103. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  104. package/engine/graphics/render/forward_plus/prototypeLightManager.js +1 -1
  105. package/engine/graphics/render/visibility/hiz/buffer/HierarchicalZBuffer.js +198 -0
  106. package/engine/graphics/render/visibility/hiz/buffer/ReductionShader.js +51 -0
  107. package/engine/graphics/render/visibility/hiz/buildCanvasViewFromTexture.js +179 -0
  108. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +435 -0
  109. package/engine/graphics/render/visibility/hiz/query/BatchOcclusionQuery.js +174 -0
  110. package/engine/graphics/render/visibility/hiz/query/QueryShader.js +173 -0
  111. package/engine/graphics/shadows/ShadowMapRenderer.js +12 -2
  112. package/engine/graphics/texture/cubemap/buildCubeURLs.js +13 -0
  113. package/engine/graphics/texture/cubemap/load_environment_map.d.ts +8 -0
  114. package/engine/graphics/texture/cubemap/load_environment_map.js +163 -0
  115. package/engine/graphics/texture/sampler/Sampler2D.js +18 -62
  116. package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +3 -2
  117. package/engine/graphics/texture/sampler/debug/paintSamplerOnHTML.js +3 -2
  118. package/engine/graphics/texture/sampler/differenceSampler.js +31 -0
  119. package/engine/graphics/texture/sampler/typedArrayConstructorByInstance.js +25 -0
  120. package/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -2
  121. package/engine/graphics/texture/virtual/v2/ShaderUsage.js +6 -5
  122. package/engine/graphics/texture/virtual/v2/prototype.js +16 -6
  123. package/engine/plugin/EnginePluginManager.d.ts +9 -0
  124. package/engine/reference/v2/Reference.d.ts +7 -0
  125. package/package.json +1 -1
  126. package/view/minimap/gl/MinimapMarkersGL.js +2 -2
  127. package/engine/graphics/micron/build/clustering/cluster_mesh_vertices.js +0 -3
  128. package/engine/graphics/micron/render/RefinementSpec.js +0 -159
@@ -3,13 +3,13 @@
3
3
  */
4
4
 
5
5
 
6
- import Vector4 from "../../../../core/geom/Vector4.js";
7
6
  import { clamp } from "../../../../core/math/clamp.js";
8
7
  import { max2 } from "../../../../core/math/max2.js";
9
8
  import { min2 } from "../../../../core/math/min2.js";
10
9
  import { mix } from "../../../../core/math/mix.js";
11
10
  import { BlendingType } from "./BlendingType.js";
12
11
  import { assert } from "../../../../core/assert.js";
12
+ import { typedArrayConstructorByInstance } from "./typedArrayConstructorByInstance.js";
13
13
 
14
14
  function v2CrossMag(ax, ay, bx, by) {
15
15
  return ax * by - ay * bx;
@@ -1319,8 +1319,8 @@ Sampler2D.prototype.fill = function (x, y, width, height, value) {
1319
1319
  * @param {number} value
1320
1320
  */
1321
1321
  Sampler2D.prototype.writeChannel = function (x, y, channel, value) {
1322
- assert.typeOf(x, "number", "x");
1323
- assert.typeOf(y, "number", "y");
1322
+ assert.isNumber(x, "x");
1323
+ assert.isNumber(y, "y");
1324
1324
 
1325
1325
  assert.greaterThanOrEqual(x, 0);
1326
1326
  assert.greaterThanOrEqual(y, 0);
@@ -1385,32 +1385,6 @@ Sampler2D.prototype.traverseCircle = function (centerX, centerY, radius, visitor
1385
1385
  }
1386
1386
  };
1387
1387
 
1388
- export function arrayConstructorByInstance(a) {
1389
- if (a instanceof Int8Array) {
1390
- return Int8Array;
1391
- } else if (a instanceof Int16Array) {
1392
- return Int16Array;
1393
- } else if (a instanceof Int32Array) {
1394
- return Int32Array;
1395
- } else if (a instanceof Uint8Array) {
1396
- return Uint8Array;
1397
- } else if (a instanceof Uint8ClampedArray) {
1398
- return Uint8ClampedArray;
1399
- } else if (a instanceof Uint16Array) {
1400
- return Uint16Array;
1401
- } else if (a instanceof Uint32Array) {
1402
- return Uint32Array;
1403
- } else if (a instanceof Float32Array) {
1404
- return Float32Array;
1405
- } else if (a instanceof Float64Array) {
1406
- return Float64Array;
1407
- } else if (Array.isArray(a)) {
1408
- return Array;
1409
- } else {
1410
- throw new TypeError(`Unsupported array type`);
1411
- }
1412
- }
1413
-
1414
1388
  /**
1415
1389
  *
1416
1390
  * @param {number} x
@@ -1419,31 +1393,40 @@ export function arrayConstructorByInstance(a) {
1419
1393
  */
1420
1394
  Sampler2D.prototype.resize = function (x, y, preserveData = true) {
1421
1395
 
1396
+ const _w = this.width;
1397
+ const _h = this.height;
1398
+
1399
+ if (_w === x && _h === y) {
1400
+ // size didn't change
1401
+ return;
1402
+ }
1403
+
1422
1404
  const itemSize = this.itemSize;
1405
+
1423
1406
  const length = x * y * itemSize;
1424
1407
 
1425
1408
  const oldData = this.data;
1426
1409
 
1427
- const Constructor = arrayConstructorByInstance(oldData);
1410
+ const Constructor = typedArrayConstructorByInstance(oldData);
1428
1411
 
1429
1412
  const newData = new Constructor(length);
1430
1413
 
1431
1414
  if (preserveData) {
1432
1415
  //copy old data
1433
- if (x === this.width) {
1416
+ if (x === _w) {
1434
1417
  // number of columns is preserved, we can just copy the old data across
1435
1418
  newData.set(oldData.subarray(0, Math.min(oldData.length, length)));
1436
1419
  } else {
1437
1420
  //we need to copy new data row-by-row
1438
- const rowCount = min2(y, this.height);
1421
+ const rowCount = min2(y, _h);
1439
1422
 
1440
- const columnCount = min2(x, this.width);
1423
+ const columnCount = min2(x, _w);
1441
1424
 
1442
1425
  for (let i = 0; i < rowCount; i++) {
1443
1426
  for (let j = 0; j < columnCount; j++) {
1444
1427
 
1445
1428
  const targetItemAddress = (i * x + j) * itemSize;
1446
- const sourceItemAddress = (i * this.width + j) * itemSize;
1429
+ const sourceItemAddress = (i * _w + j) * itemSize;
1447
1430
 
1448
1431
  for (let k = 0; k < itemSize; k++) {
1449
1432
 
@@ -1457,6 +1440,7 @@ Sampler2D.prototype.resize = function (x, y, preserveData = true) {
1457
1440
 
1458
1441
  this.width = x;
1459
1442
  this.height = y;
1443
+
1460
1444
  this.data = newData;
1461
1445
  };
1462
1446
 
@@ -1563,31 +1547,3 @@ Sampler2D.prototype.traverseOrthogonalNeighbours = function (x, y, visitor, this
1563
1547
  }
1564
1548
  };
1565
1549
 
1566
- /**
1567
- *
1568
- * @param {Sampler2D} sampler0
1569
- * @param {Sampler2D} sampler1
1570
- * @returns {Sampler2D}
1571
- */
1572
- export function differenceSampler(sampler0, sampler1) {
1573
- let v0 = new Vector4();
1574
- let v1 = new Vector4();
1575
- //
1576
- const width = sampler0.width;
1577
- const height = sampler0.height;
1578
- //
1579
- const difference = new Float32Array(width * height);
1580
- for (let y = 0; y < height; y++) {
1581
- for (let x = 0; x < width; x++) {
1582
- v0 = sampler0.get(x, y, v0);
1583
- v1 = sampler1.get(x, y, v1);
1584
- v0.normalize();
1585
- v1.normalize();
1586
- //check distance
1587
- difference[x + y * width] = 1 - v0.dot(v1);
1588
- }
1589
- }
1590
- //
1591
- const sampleD = new Sampler2D(difference, 1, width, height);
1592
- return sampleD;
1593
- }
@@ -1,7 +1,8 @@
1
1
  import { WebGLRendererPool } from "../../render/RendererPool.js";
2
- import ImageFilter, { flipArrayInPlace } from "../../filter/ImageFilter.js";
2
+ import ImageFilter from "../../filter/ImageFilter.js";
3
3
  import { Sampler2D } from "./Sampler2D.js";
4
4
  import CopyShader from "../../postprocess/threejs/shaders/CopyShader.js";
5
+ import { flipArrayInPlace } from "../../filter/FlipArrayInPlace.js";
5
6
 
6
7
 
7
8
  const DEFAULT_TEXTURE_WIDTH = 512;
@@ -65,7 +66,7 @@ export function convertTexture2Sampler2D(texture, width, height, flipY = true) {
65
66
  value: texture,
66
67
  type: 't'
67
68
  },
68
- "opacity": { value: 1.0 }
69
+ opacity: { value: 1.0 }
69
70
  }
70
71
  });
71
72
 
@@ -1,6 +1,7 @@
1
- import { arrayConstructorByInstance, Sampler2D } from "../Sampler2D.js";
1
+ import { Sampler2D } from "../Sampler2D.js";
2
2
  import { scaleSampler2D } from "../scaleSampler2D.js";
3
3
  import convertSampler2D2Canvas from "../Sampler2D2Canvas.js";
4
+ import { typedArrayConstructorByInstance } from "../typedArrayConstructorByInstance.js";
4
5
 
5
6
  /**
6
7
  *
@@ -14,7 +15,7 @@ export function paintSamplerOnHTML(s, x, y, scale, offset) {
14
15
 
15
16
  const d = 180;
16
17
 
17
- const target = new Sampler2D(arrayConstructorByInstance(s.data), s.itemSize, d, d);
18
+ const target = new Sampler2D(typedArrayConstructorByInstance(s.data), s.itemSize, d, d);
18
19
 
19
20
  scaleSampler2D(s, target);
20
21
 
@@ -0,0 +1,31 @@
1
+ import Vector4 from "../../../../core/geom/Vector4.js";
2
+ import { Sampler2D } from "./Sampler2D.js";
3
+
4
+ /**
5
+ *
6
+ * @param {Sampler2D} sampler0
7
+ * @param {Sampler2D} sampler1
8
+ * @returns {Sampler2D}
9
+ */
10
+ export function differenceSampler(sampler0, sampler1) {
11
+ let v0 = new Vector4();
12
+ let v1 = new Vector4();
13
+ //
14
+ const width = sampler0.width;
15
+ const height = sampler0.height;
16
+ //
17
+ const difference = new Float32Array(width * height);
18
+ for (let y = 0; y < height; y++) {
19
+ for (let x = 0; x < width; x++) {
20
+ v0 = sampler0.get(x, y, v0);
21
+ v1 = sampler1.get(x, y, v1);
22
+ v0.normalize();
23
+ v1.normalize();
24
+ //check distance
25
+ difference[x + y * width] = 1 - v0.dot(v1);
26
+ }
27
+ }
28
+ //
29
+ const sampleD = new Sampler2D(difference, 1, width, height);
30
+ return sampleD;
31
+ }
@@ -0,0 +1,25 @@
1
+ export function typedArrayConstructorByInstance(a) {
2
+ if (a instanceof Int8Array) {
3
+ return Int8Array;
4
+ } else if (a instanceof Int16Array) {
5
+ return Int16Array;
6
+ } else if (a instanceof Int32Array) {
7
+ return Int32Array;
8
+ } else if (a instanceof Uint8Array) {
9
+ return Uint8Array;
10
+ } else if (a instanceof Uint8ClampedArray) {
11
+ return Uint8ClampedArray;
12
+ } else if (a instanceof Uint16Array) {
13
+ return Uint16Array;
14
+ } else if (a instanceof Uint32Array) {
15
+ return Uint32Array;
16
+ } else if (a instanceof Float32Array) {
17
+ return Float32Array;
18
+ } else if (a instanceof Float64Array) {
19
+ return Float64Array;
20
+ } else if (Array.isArray(a)) {
21
+ return Array;
22
+ } else {
23
+ throw new TypeError(`Unsupported array type`);
24
+ }
25
+ }
@@ -1,6 +1,7 @@
1
- import { arrayConstructorByInstance, Sampler2D } from "../Sampler2D.js";
1
+ import { Sampler2D } from "../Sampler2D.js";
2
2
  import { scaleSampler2D } from "../scaleSampler2D.js";
3
3
  import convertSampler2D2Canvas from "../Sampler2D2Canvas.js";
4
+ import { typedArrayConstructorByInstance } from "../typedArrayConstructorByInstance.js";
4
5
 
5
6
  /**
6
7
  *
@@ -15,7 +16,7 @@ import convertSampler2D2Canvas from "../Sampler2D2Canvas.js";
15
16
  export function drawSamplerHTML(parentNode, sampler, x, y, scale, offset, size) {
16
17
 
17
18
 
18
- const target = new Sampler2D(arrayConstructorByInstance(sampler.data), sampler.itemSize, size, size);
19
+ const target = new Sampler2D(typedArrayConstructorByInstance(sampler.data), sampler.itemSize, size, size);
19
20
 
20
21
  scaleSampler2D(sampler, target);
21
22
 
@@ -14,27 +14,28 @@ function vertex() {
14
14
  function fragment() {
15
15
  return `
16
16
  uniform vec4 u_mt_tex; // [ width, height, tileSize, id ]
17
+ uniform vec2 u_mt_params; // [ bias, maxLevel, xx, xx ]
18
+ varying vec2 vUv;
19
+
17
20
  float MTCalculateMipLevel( const in vec2 uv, const in float bias ) {
18
21
  vec2 dx = dFdx( uv * u_mt_tex.x );
19
22
  vec2 dy = dFdy( uv * u_mt_tex.y );
20
23
  return log2( max( dot( dx, dx ), dot( dy, dy ) ) ) / 2.0 + bias;
21
24
  }
22
25
 
23
- uniform vec2 u_mt_params; // [ bias, maxLevel, xx, xx ]
24
26
  vec4 MTCalculateTileKeyRGBA( const in vec2 uv ) {
25
27
  float level = clamp( floor( MTCalculateMipLevel( uv, u_mt_params.x ) ), 0.0, u_mt_params.y );
26
28
  vec2 texIS = uv.xy * u_mt_tex.xy; // [0-1]x[0-1] -> [0-texwidth]x[0-texheight]
27
29
  vec2 texLS = texIS / exp2( level ); // -> [0-levelwidth]x[0-levelheight]
28
30
  vec2 texTS = floor( texLS / u_mt_tex.z ); // -> [0->tileswide]x[0-tileshigh]
29
- return vec4( u_mt_params.y - level, texTS.xy, u_mt_tex.w ) / 255.0; // [ texId, level, tileX, tileY ] -> RGBA
31
+ return vec4( u_mt_params.y - level, texTS.xy, u_mt_tex.w ) / 255.0; // [ level, tileX, tileY, texId ] -> RGBA
30
32
  }
31
33
 
32
- varying vec2 vUv;
33
34
 
34
35
  void main(){
35
36
  vec4 tile = MTCalculateTileKeyRGBA(vUv);
36
37
  // gl_FragColor = tile;
37
- gl_FragColor = vec4(mix(0.1,1.0,tile.x*255.0), tile.yz*64.0, 1.0);
38
+ gl_FragColor = vec4(mix(0.1,1.0,tile.x*255.0/u_mt_params.y), tile.yz*64.0, 1.0);
38
39
  // gl_FragColor = MTCalculateTileKeyRGBA(vUv);
39
40
  // gl_FragColor = vec4(1.0);
40
41
  }
@@ -44,4 +45,4 @@ void main(){
44
45
  export {
45
46
  vertex,
46
47
  fragment
47
- };
48
+ };
@@ -1,5 +1,6 @@
1
1
  import * as THREE from "three";
2
2
  import { fragment, vertex } from "./ShaderUsage.js";
3
+ import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
3
4
 
4
5
  let camera, renderer, clock, scene;
5
6
 
@@ -22,7 +23,14 @@ function init() {
22
23
  const textureLoader = new THREE.TextureLoader();
23
24
 
24
25
  uniforms = {
25
- "u_mt_params": { value: new THREE.Vector2(0.1, 5) },
26
+ "u_mt_params": { value: new THREE.Vector2(0.1, 6) },
27
+ /**
28
+ * Format: VT_WIDTH, VT_HEIGHT, VT_TILE_SIZE, VT_ID
29
+ * - VT_WIDTH : width of the virtual texture
30
+ * - VT_HEIGHT : height of the virtual texture
31
+ * - VT_TILE_SIZE : resolution of a single tile
32
+ * - VT_ID : multiple different virtual textures may be used, this identifies current texture
33
+ */
26
34
  "u_mt_tex": { value: new THREE.Vector4(16384, 16384, 256, 1) }
27
35
  };
28
36
 
@@ -30,11 +38,11 @@ function init() {
30
38
 
31
39
  const material = new THREE.ShaderMaterial({
32
40
 
33
- uniforms: uniforms,
34
- vertexShader: vertex(),
35
- fragmentShader: fragment()
41
+ uniforms: uniforms,
42
+ vertexShader: vertex(),
43
+ fragmentShader: fragment()
36
44
 
37
- });
45
+ });
38
46
 
39
47
  mesh = new THREE.Mesh(new THREE.TorusGeometry(size, 0.3, 30, 30), material);
40
48
  mesh.rotation.x = 0.3;
@@ -57,6 +65,8 @@ function init() {
57
65
 
58
66
  window.addEventListener("resize", onWindowResize);
59
67
 
68
+ new OrbitControls(camera, renderer.domElement);
69
+
60
70
  }
61
71
 
62
72
  function onWindowResize() {
@@ -88,4 +98,4 @@ function render() {
88
98
  renderer.clear();
89
99
  renderer.render(scene, camera)
90
100
 
91
- }
101
+ }
@@ -0,0 +1,9 @@
1
+ import {Reference} from "../reference/v2/Reference";
2
+
3
+ interface Type<T> extends Function {
4
+ new(...args: any[]): T;
5
+ }
6
+
7
+ export class EnginePluginManager {
8
+ acquire<T>(klass: Type<T>): Promise<Reference<T>>
9
+ }
@@ -0,0 +1,7 @@
1
+ export class Reference<T> {
2
+ getValue(): T | null
3
+
4
+ release(): void
5
+
6
+ bind(v: T): void
7
+ }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "productName": "Meep",
5
5
  "description": "production-ready JavaScript game engine based on Entity Component System Architecture",
6
6
  "author": "Alexander Goldring",
7
- "version": "2.33.3",
7
+ "version": "2.33.8",
8
8
  "dependencies": {
9
9
  "fast-levenshtein": "2.0.6",
10
10
  "opentype.js": "1.3.3",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DataTexture,
3
- LinearFilter,
4
3
  LinearMipMapLinearFilter,
4
+ NearestFilter,
5
5
  NormalBlending,
6
6
  Points,
7
7
  RGBAFormat,
@@ -82,7 +82,7 @@ function buildMaterial() {
82
82
  dataTexture.flipY = false;
83
83
  dataTexture.generateMipmaps = true;
84
84
  dataTexture.minFilter = LinearMipMapLinearFilter;
85
- dataTexture.magFilter = LinearFilter;
85
+ dataTexture.magFilter = NearestFilter;
86
86
 
87
87
  const uniforms = {
88
88
  atlas: {
@@ -1,3 +0,0 @@
1
- export function cluster_mesh_vertices(mesh, max_face_count){
2
-
3
- }
@@ -1,159 +0,0 @@
1
- import Vector2 from "../../../../core/geom/Vector2.js";
2
- import { Matrix4 } from "three";
3
- import { mat4 } from "gl-matrix";
4
- import { v3_length } from "../../../../core/geom/Vector3.js";
5
-
6
- /**
7
- * Normalize a plane in-place
8
- * @param {number[]} source
9
- * @param {number} source_offset
10
- */
11
- function array_normalize_plane(source, source_offset) {
12
- const _x = source[source_offset];
13
- const _y = source[source_offset + 1];
14
- const _z = source[source_offset + 2];
15
-
16
- const length = v3_length(_x, _y, _z);
17
-
18
- const inverseNormalLength = 1.0 / length;
19
-
20
- /*
21
- By re-using values already in the registers instead of using *= we save a few extra READ ops
22
- */
23
- source[source_offset] = _x * inverseNormalLength;
24
- source[source_offset + 1] = _y * inverseNormalLength;
25
- source[source_offset + 2] = _z * inverseNormalLength;
26
-
27
- source[source_offset + 3] *= inverseNormalLength;
28
- }
29
-
30
- /**
31
- *
32
- * @param {number[]|Float32Array} frustum_planes
33
- * @param {number[]} me
34
- */
35
- function array_setFromProjectionMatrix(frustum_planes, me) {
36
-
37
- const me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3];
38
- const me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7];
39
- const me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11];
40
- const me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15];
41
-
42
- frustum_planes[0] = me3 - me0;
43
- frustum_planes[1] = me7 - me4;
44
- frustum_planes[2] = me11 - me8;
45
- frustum_planes[3] = me15 - me12;
46
-
47
- frustum_planes[4] = me3 + me0;
48
- frustum_planes[5] = me7 + me4;
49
- frustum_planes[6] = me11 + me8;
50
- frustum_planes[7] = me15 + me12;
51
-
52
- frustum_planes[8] = me3 + me1;
53
- frustum_planes[9] = me7 + me5;
54
- frustum_planes[10] = me11 + me9;
55
- frustum_planes[11] = me15 + me13;
56
-
57
- frustum_planes[12] = me3 - me1;
58
- frustum_planes[13] = me7 - me5;
59
- frustum_planes[14] = me11 - me9;
60
- frustum_planes[15] = me15 - me13;
61
-
62
- frustum_planes[16] = me3 - me2;
63
- frustum_planes[17] = me7 - me6;
64
- frustum_planes[18] = me11 - me10;
65
- frustum_planes[19] = me15 - me14;
66
-
67
- frustum_planes[20] = me3 + me2;
68
- frustum_planes[21] = me7 + me6;
69
- frustum_planes[22] = me11 + me10;
70
- frustum_planes[23] = me15 + me14;
71
-
72
- // normalize plane
73
- array_normalize_plane(frustum_planes, 0);
74
- array_normalize_plane(frustum_planes, 4);
75
- array_normalize_plane(frustum_planes, 8);
76
- array_normalize_plane(frustum_planes, 12);
77
- array_normalize_plane(frustum_planes, 16);
78
- array_normalize_plane(frustum_planes, 20);
79
- }
80
-
81
- export class RefinementSpec {
82
- constructor() {
83
-
84
- /**
85
- * Viewport resolution
86
- * @type {Vector2}
87
- */
88
- this.resolution = new Vector2();
89
-
90
- /**
91
- * Number of pixels in the viewport
92
- * @type {number}
93
- */
94
- this.viewport_area = 0;
95
-
96
- /**
97
- * How much error to accept when deciding to subdivide a cluster
98
- * Measured in pixels
99
- * Higher value will result in better performance but more visible artifacts
100
- * @type {number}
101
- */
102
- this.error_threshold = 1;
103
-
104
- /**
105
- * Object-space camera frustum
106
- * Frustum planes in compact form
107
- * @type {Float32Array}
108
- */
109
- this.frustum_f32 = new Float32Array(24);
110
-
111
- /**
112
- * Model world transform
113
- * @type {Float32Array|number[]|mat4}
114
- */
115
- this.transform = new Float32Array(16);
116
-
117
- /**
118
- * Contains transformation from camera space to object space
119
- * @type {Float32Array|number[]|mat4}
120
- */
121
- this.projection_matrix = new Float32Array(16);
122
-
123
- /**
124
- * FOV in radians
125
- * @type {number}
126
- */
127
- this.focal_length = 0;
128
-
129
- /**
130
- * Object-space camera position
131
- * @type {Float32Array}
132
- */
133
- this.view_position = new Float32Array(3);
134
- }
135
-
136
- get frustum() {
137
- throw new Error('deprecated, use .frustum_f32 instead');
138
- }
139
-
140
- /**
141
- *
142
- * @param {Matrix4} transform world-space object transform
143
- * @param {Matrix4} matrix_world_inverse camera's world inverse matrix
144
- * @param {Matrix4} matrix_projection camera's projection matrix
145
- */
146
- build(transform, matrix_world_inverse, matrix_projection) {
147
- const _transform = this.transform;
148
- _transform.set(transform.elements);
149
-
150
- // build projection matrix
151
- const projection_matrix = this.projection_matrix;
152
-
153
- mat4.multiply(projection_matrix, matrix_world_inverse.elements, _transform);
154
- mat4.multiply(projection_matrix, matrix_projection.elements, projection_matrix);
155
-
156
- // compute view frustum in model-space
157
- array_setFromProjectionMatrix(this.frustum_f32, projection_matrix);
158
- }
159
- }