@woosh/meep-engine 2.70.0 → 2.72.0

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 (51) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +111 -122
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +111 -122
  5. package/package.json +1 -1
  6. package/src/core/collection/array/array_get_index_in_range.js +1 -1
  7. package/src/core/collection/array/array_swap.js +2 -2
  8. package/src/core/geom/3d/quaternion/quat_encode_to_uint32.js +2 -3
  9. package/src/core/geom/3d/v3_compute_triangle_normal.js +7 -1
  10. package/src/core/geom/vec3/v3_normalize_array.js +27 -0
  11. package/src/core/math/remap.js +5 -1
  12. package/src/core/math/statistics/computeStatisticalPartialMedian.js +1 -1
  13. package/src/core/process/task/Task.js +53 -34
  14. package/src/engine/achievements/AchievementManager.js +19 -19
  15. package/src/engine/animation/curve/compression/prototypeCurveCompression.js +6 -6
  16. package/src/engine/animation/curve/draw/build_plot_entity_from_array.js +11 -6
  17. package/src/engine/ecs/dynamic_actions/DynamicActor.js +5 -10
  18. package/src/engine/ecs/dynamic_actions/DynamicActorSystem.js +82 -89
  19. package/src/engine/ecs/dynamic_actions/RuleExecution.js +10 -12
  20. package/src/engine/ecs/gui/GUIElement.js +44 -61
  21. package/src/engine/ecs/gui/GUIElementSystem.js +26 -24
  22. package/src/engine/ecs/gui/hud/HeadsUpDisplay.js +12 -15
  23. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +15 -15
  24. package/src/engine/ecs/gui/parallax/GuiElementParallax.js +3 -3
  25. package/src/engine/ecs/gui/parallax/GuiElementParallaxSystem.js +2 -2
  26. package/src/engine/ecs/gui/position/ViewportPosition.js +5 -50
  27. package/src/engine/ecs/gui/position/ViewportPositionSerializationAdapter.js +42 -0
  28. package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.js +2 -2
  29. package/src/engine/ecs/transform/TransformSerializationAdapter.js +5 -10
  30. package/src/engine/graphics/geometry/buffered/ComputeNormals.js +11 -26
  31. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +20 -20
  32. package/src/engine/graphics/texture/sprite/prototypeSpriteCutoutGeometry.js +12 -12
  33. package/src/engine/graphics/texture/virtual/v2/NOTES.md +17 -0
  34. package/src/engine/graphics/texture/virtual/v2/ShaderUsage.js +49 -26
  35. package/src/engine/graphics/texture/virtual/v2/UsageDebugView.js +51 -0
  36. package/src/engine/graphics/texture/virtual/v2/UsageMetadata.js +221 -0
  37. package/src/engine/graphics/texture/virtual/v2/UsagePyramidDebugView.js +239 -0
  38. package/src/engine/graphics/texture/virtual/v2/VirtualTextureManager.js +248 -0
  39. package/src/engine/graphics/texture/virtual/v2/prototype.js +104 -31
  40. package/src/engine/navigation/ecs/components/PathSerializationAdapter.js +1 -4
  41. package/src/core/binary/ValidatingBitSetWrapper.js +0 -81
  42. package/src/core/binary/jsonToStringToByteArray.js +0 -27
  43. package/src/core/geom/2d/quad-tree/PointQuadTree.js +0 -478
  44. package/src/core/math/random/makeRangedRandom.js +0 -19
  45. package/src/engine/ecs/components/AreaOfEffect.js +0 -12
  46. package/src/engine/ecs/components/Mortality.js +0 -27
  47. package/src/engine/ecs/systems/AreaOfEffectSystem.js +0 -48
  48. package/src/engine/ecs/terrain/TerrainGeometryBuilder.js +0 -152
  49. package/src/engine/ecs/terrain/ecs/PromiseSamplerHeight.js +0 -66
  50. package/src/engine/ecs/terrain/ecs/TerrainClassifier.js +0 -125
  51. package/src/engine/graphics/texture/sampler/SampleTraverser.js +0 -165
@@ -1,56 +1,108 @@
1
- import * as THREE from "three";
2
- import { fragment, vertex } from "./ShaderUsage.js";
1
+ import { GUI } from "dat.gui";
2
+ import {
3
+ AmbientLight,
4
+ Clock,
5
+ DirectionalLight,
6
+ Mesh,
7
+ MeshStandardMaterial,
8
+ PerspectiveCamera,
9
+ Scene,
10
+ TextureLoader,
11
+ TorusGeometry,
12
+ Vector2,
13
+ WebGLRenderer
14
+ } from "three";
3
15
  import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js";
16
+ import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
17
+ import EmptyView from "../../../../../view/elements/EmptyView.js";
18
+ import { UsagePyramidDebugView } from "./UsagePyramidDebugView.js";
19
+ import { VirtualTextureManager } from "./VirtualTextureManager.js";
20
+
21
+ let camera,
22
+ /**
23
+ * @type {WebGLRenderer}
24
+ */
25
+ renderer,
26
+ clock,
27
+ /**
28
+ * @type {Scene}
29
+ */
30
+ scene;
31
+
32
+ let mesh;
33
+
34
+ const virtualTextureManager = new VirtualTextureManager();
35
+ virtualTextureManager.setTextureParameters(
36
+ // 2048,
37
+ 16384,
38
+ 128,
39
+ 3
40
+ );
41
+
42
+ const container_view = new EmptyView();
43
+ //
44
+ // const usageDebugView = new UsageDebugView();
45
+ // container_view.addChild(usageDebugView);
46
+
47
+ // const TEXTURE_URL = "data/textures/utility/uv_map_reference.png";
48
+ // const TEXTURE_URL = "data/textures/utility/4096x4096TexelDensityTexture1.png";
49
+ // const TEXTURE_URL = "data/textures/utility/Lenna.png";
50
+ // const TEXTURE_URL = "data/textures/utility/TESTIMAGES/SAMPLING/8BIT/RGB/2448x2448/SRC/img_2448x2448_3x8bit_SRC_RGB_cards_a.png";
51
+ const TEXTURE_URL = "data/models/LowPolyTownshipSet/Town_Hall//diffuse_2048.png";
52
+
53
+ const usagePyramidDebugView = new UsagePyramidDebugView();
54
+ usagePyramidDebugView.setImageURL(TEXTURE_URL);
4
55
 
5
- let camera, renderer, clock, scene;
56
+ container_view.addChild(usagePyramidDebugView);
6
57
 
7
- let uniforms, mesh;
58
+ const options = {
59
+ spin: true
60
+ };
8
61
 
9
62
  init();
10
63
  animate();
11
64
 
65
+
66
+ function makeTorus() {
67
+ const size = 0.65;
68
+ mesh = new Mesh(new TorusGeometry(size, 0.3, 30, 30), new MeshStandardMaterial({
69
+ roughness: 0.4,
70
+ map: new TextureLoader().load(TEXTURE_URL)
71
+ }));
72
+ mesh.rotation.x = 0.3;
73
+ }
74
+
12
75
  function init() {
13
76
 
14
77
  const container = document.body;
15
78
 
16
- camera = new THREE.PerspectiveCamera(35, window.innerWidth / window.innerHeight, 1, 3000);
17
- camera.position.z = 4;
79
+ container.style.margin = "0";
18
80
 
19
- scene = new THREE.Scene();
81
+ container.appendChild(container_view.el);
82
+ container_view.link();
20
83
 
21
- clock = new THREE.Clock();
84
+ camera = new PerspectiveCamera(35, window.innerWidth / window.innerHeight, 0.1, 300);
85
+ camera.position.z = 4;
22
86
 
23
- const textureLoader = new THREE.TextureLoader();
87
+ scene = new Scene();
24
88
 
25
- uniforms = {
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
- */
34
- "u_mt_tex": { value: new THREE.Vector4(16384, 16384, 256, 1) }
35
- };
89
+ clock = new Clock();
36
90
 
37
- const size = 0.65;
38
91
 
39
- const material = new THREE.ShaderMaterial({
92
+ new GLTFLoader().load("data/models/LowPolyTownshipSet/Town_Hall/model.gltf", (gltf) => {
40
93
 
41
- uniforms: uniforms,
42
- vertexShader: vertex(),
43
- fragmentShader: fragment()
94
+ mesh = gltf.scene;
95
+ scene.add(mesh);
44
96
 
45
97
  });
46
98
 
47
- mesh = new THREE.Mesh(new THREE.TorusGeometry(size, 0.3, 30, 30), material);
48
- mesh.rotation.x = 0.3;
49
- scene.add(mesh);
99
+ scene.add(new DirectionalLight(0xFFFFFF, 0.7));
100
+ scene.add(new AmbientLight(0xFFFFFF, 0.2));
101
+
50
102
 
51
103
  //
52
104
 
53
- renderer = new THREE.WebGLRenderer({ antialias: true });
105
+ renderer = new WebGLRenderer({ antialias: true });
54
106
  renderer.setPixelRatio(window.devicePixelRatio);
55
107
  container.appendChild(renderer.domElement);
56
108
  renderer.autoClear = false;
@@ -67,6 +119,14 @@ function init() {
67
119
 
68
120
  new OrbitControls(camera, renderer.domElement);
69
121
 
122
+
123
+ const gui = new GUI();
124
+
125
+ Object.keys(options).forEach(key => {
126
+ gui.add(options, key);
127
+ });
128
+
129
+
70
130
  }
71
131
 
72
132
  function onWindowResize() {
@@ -92,10 +152,23 @@ function render() {
92
152
 
93
153
  const delta = 5 * clock.getDelta();
94
154
 
95
- mesh.rotation.y += 0.0125 * delta;
96
- mesh.rotation.x += 0.05 * delta;
155
+ if (options.spin && mesh !== undefined) {
156
+ mesh.rotation.y += 0.0125 * delta;
157
+ mesh.rotation.x += 0.05 * delta;
158
+ }
159
+
160
+ const view_port_size = renderer.getSize(new Vector2());
161
+ view_port_size.multiplyScalar(renderer.getPixelRatio());
162
+
163
+
164
+ virtualTextureManager.setViewportResolution(view_port_size.x, view_port_size.y);
165
+ virtualTextureManager.updateUsage(renderer, scene, camera);
97
166
 
98
167
  renderer.clear();
99
168
  renderer.render(scene, camera)
100
169
 
170
+ // usageDebugView.usage = virtualTextureManager.usage_metadata;
171
+
172
+ usagePyramidDebugView.setTextureParameters(virtualTextureManager.texture_resolution, virtualTextureManager.tile_resolution);
173
+ usagePyramidDebugView.usage = virtualTextureManager.usage_metadata;
101
174
  }
@@ -1,5 +1,5 @@
1
- import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
2
1
  import Vector3 from "../../../../core/geom/Vector3.js";
2
+ import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
3
3
  import Path from "./Path.js";
4
4
 
5
5
 
@@ -54,8 +54,5 @@ export class PathSerializationAdapter extends BinaryClassSerializationAdapter {
54
54
 
55
55
  value.setPosition(i, x, y, z);
56
56
  }
57
-
58
- // mark length for update
59
- value.__length = -1;
60
57
  }
61
58
  }
@@ -1,81 +0,0 @@
1
- //
2
-
3
- /**
4
- * Debug tool to verify correct behavior of a BitSet
5
- */
6
- export class ValidatingBitSetWrapper {
7
- /**
8
- *
9
- * @param {BitSet} source
10
- */
11
- constructor(source) {
12
- this.__source = source;
13
- }
14
-
15
- preventShrink() {
16
- this.__source.preventShrink();
17
- }
18
-
19
- setShrinkFactor(x) {
20
- this.__source.setShrinkFactor(x);
21
- }
22
-
23
- setCapacity(x) {
24
- this.__source.setCapacity(x);
25
- }
26
-
27
- size() {
28
- return this.__source.size();
29
- }
30
-
31
- capacity() {
32
- return this.__source.capacity();
33
- }
34
-
35
- previousSetBit(i) {
36
- const bit = this.__source.previousSetBit(i);
37
-
38
- if (bit !== -1 && (this.__source.get(bit) !== true || bit > i)) {
39
- debugger;
40
- }
41
-
42
- return bit;
43
- }
44
-
45
- nextSetBit(i) {
46
- const bit = this.__source.nextSetBit(i);
47
-
48
- if (bit !== -1 && (this.__source.get(bit) !== true || bit < i)) {
49
- debugger;
50
- }
51
-
52
- return bit;
53
- }
54
-
55
- nextClearBit(i) {
56
- const bit = this.__source.nextClearBit(i);
57
-
58
- if (bit !== -1 && (this.__source.get(bit) !== false || bit < i)) {
59
- debugger;
60
- }
61
-
62
- return bit;
63
- }
64
-
65
- set(x, y) {
66
- this.__source.set(x, y);
67
- }
68
-
69
- clear(i) {
70
- this.__source.clear(i);
71
- }
72
-
73
- get(i) {
74
- return this.__source.get(i);
75
- }
76
-
77
-
78
- reset() {
79
- this.__source.reset();
80
- }
81
- }
@@ -1,27 +0,0 @@
1
- import {stringifyStream} from "../json/JsonUtils.js";
2
-
3
- /**
4
- *
5
- * @param {Object} json
6
- * @returns {number[]}
7
- */
8
- function jsonToStringToByteArray(json) {
9
- const output = [];
10
- let p = 0;
11
-
12
- function addToOutput(str) {
13
- for (let i = 0; i < str.length; i++) {
14
- let c = str.charCodeAt(i);
15
- while (c > 0xff) {
16
- output[p++] = c & 0xff;
17
- c >>= 8;
18
- }
19
- output[p++] = c;
20
- }
21
- }
22
-
23
- stringifyStream(json, addToOutput);
24
- return output;
25
- }
26
-
27
- export {jsonToStringToByteArray};