@woosh/meep-engine 2.110.7 → 2.110.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.
@@ -63807,7 +63807,7 @@ class WorkerBuilder {
63807
63807
  result.push(obj);
63808
63808
  } else if (obj.buffer instanceof ArrayBuffer) {
63809
63809
  result.push(obj.buffer);
63810
- } else if (obj instanceof ImageBitmap) {
63810
+ } else if (typeof ImageBitmap !== "undefined" && obj instanceof ImageBitmap) {
63811
63811
  result.push(obj);
63812
63812
  } else {
63813
63813
  for (var i in obj) {
@@ -76225,6 +76225,19 @@ function murmur3_32(key, seed) {
76225
76225
  return h1 >>> 0;
76226
76226
  }
76227
76227
 
76228
+ /**
76229
+ * Guards against cases where ImageBitmap doesn't exist
76230
+ * @param {*} image
76231
+ * @return {boolean}
76232
+ */
76233
+ function isImageBitmap(image) {
76234
+ /**
76235
+ * check that browser/environment has the class at all to avoid potential exceptions
76236
+ * Required for Safari below version 15.6
76237
+ */
76238
+ return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap;
76239
+ }
76240
+
76228
76241
  /**
76229
76242
  * Transfer bitmap contents to Sampler2D, effectively moving data to CPU, making it readable
76230
76243
  * @param {WebGL2RenderingContext} gl
@@ -76447,15 +76460,14 @@ function computeImageDataHash(image) {
76447
76460
 
76448
76461
  let result = 0;
76449
76462
 
76450
- if (
76451
- // check that browser/environment has the class at all to avoid potential exceptions
76452
- // Required for Safari below version 15.6
76453
- ImageBitmap !== undefined
76454
- && (image instanceof ImageBitmap)
76455
- ) {
76463
+ if (isImageBitmap(image)) {
76464
+
76456
76465
  result = computeImageBitmapHash(image);
76466
+
76457
76467
  } else if (image instanceof HTMLImageElement) {
76468
+
76458
76469
  result = computeStringHash(image.src);
76470
+
76459
76471
  }
76460
76472
 
76461
76473
  let width = 0;
@@ -76652,13 +76664,10 @@ function textureImagesEqual(a, b) {
76652
76664
  return false;
76653
76665
  }
76654
76666
 
76655
- if (
76656
- // check that browser/environment has the class at all to avoid potential exceptions
76657
- // Required for Safari below version 15.6
76658
- ImageBitmap !== undefined
76659
- && (a instanceof ImageBitmap && b instanceof ImageBitmap)
76660
- ) {
76667
+ if (isImageBitmap(a) && isImageBitmap(b)) {
76668
+
76661
76669
  return computeImageBitmapEquality(a, b);
76670
+
76662
76671
  }
76663
76672
 
76664
76673
  if (Array.isArray(a) && Array.isArray(b)) {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.110.7",
8
+ "version": "2.110.8",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -7,6 +7,7 @@ import { ShadedGeometry } from "../../../../engine/graphics/ecs/mesh-v2/ShadedGe
7
7
  import { ShadedGeometrySystem } from "../../../../engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js";
8
8
  import { Gizmo } from "../../../../engine/graphics/render/gizmo/Gizmo.js";
9
9
  import { GizmoRenderingPlugin } from "../../../../engine/graphics/render/gizmo/GizmoRenderingPlugin.js";
10
+ import { randomFloatBetween } from "../../../math/random/randomFloatBetween.js";
10
11
  import { seededRandom } from "../../../math/random/seededRandom.js";
11
12
  import { number_pretty_print } from "../../../primitives/numbers/number_pretty_print.js";
12
13
  import { delay } from "../../../process/delay.js";
@@ -14,8 +15,38 @@ import { AABB3 } from "../aabb/AABB3.js";
14
15
  import { make_justified_point_grid } from "../util/make_justified_point_grid.js";
15
16
  import { build_tetrahedral_mesh_buffer_geometry } from "./build_tetrahedral_mesh_buffer_geometry.js";
16
17
  import { compute_delaunay_tetrahedral_mesh } from "./delaunay/compute_delaunay_tetrahedral_mesh.js";
18
+ import { tetrahedral_mesh_build_from_grid } from "./delaunay/tetrahedral_mesh_build_from_grid.js";
17
19
  import { TetrahedralMesh } from "./TetrahedralMesh.js";
18
20
 
21
+
22
+ /**
23
+ *
24
+ * @param {TetrahedralMesh} tetrahedra
25
+ * @param {number[]} points
26
+ */
27
+ function make_delaunay_grid(tetrahedra, points) {
28
+
29
+ const random = seededRandom();
30
+
31
+ for (let i = 0; i < 600; i++) {
32
+ points.push(
33
+ randomFloatBetween(random, -100, 100),
34
+ randomFloatBetween(random, 0, 150),
35
+ randomFloatBetween(random, -100, 100),
36
+ );
37
+ }
38
+
39
+ make_justified_point_grid(
40
+ new AABB3(-100, 0, -100, 100, 150, 100),
41
+ 20,
42
+ (x, y, z) => {
43
+ points.push(x, y, z);
44
+ }
45
+ );
46
+
47
+ compute_delaunay_tetrahedral_mesh(tetrahedra, points, points.length / 3);
48
+ }
49
+
19
50
  /**
20
51
  *
21
52
  * @param {Engine} engine
@@ -30,51 +61,23 @@ async function main(engine) {
30
61
  const offset = [7.5, 1, 7.5];
31
62
  const scale = [.5, .5, .5];
32
63
 
64
+ /**
65
+ *
66
+ * @type {number[]}
67
+ */
33
68
  const points = [];
34
69
 
35
- // points.push(
36
- // 0, 0, 0,
37
- // 10, 0, 0,
38
- // 10, 0, 10,
39
- // 0, 0, 10,
40
- //
41
- // 0, 10, 0,
42
- // 10, 10, 0,
43
- // 10, 10, 10,
44
- // 0, 10, 10,
45
- // );
46
-
47
- const random = seededRandom();
48
-
49
- // for (let i = 0; i < 600; i++) {
50
- // points.push(
51
- // randomFloatBetween(random, -100, 100),
52
- // randomFloatBetween(random, 0, 150),
53
- // randomFloatBetween(random, -100, 100),
54
- // );
55
- // }
56
-
57
- make_justified_point_grid(
58
- new AABB3(-100, 0, -100, 100, 150, 100),
59
- 20,
60
- (x, y, z) => {
61
- points.push(x, y, z);
62
- }
63
- );
70
+ const tetrahedra = new TetrahedralMesh();
64
71
 
65
72
  await delay(1000);
66
73
 
67
- const tetrahedra = new TetrahedralMesh();
68
74
  console.time('mesh build');
69
- // console.profile('mesh build');
70
- compute_delaunay_tetrahedral_mesh(tetrahedra, points, points.length / 3);
71
- // tetrahedral_mesh_build_from_grid(
72
- // tetrahedra,
73
- // points,
74
- // new AABB3(-100, 0, -100, 100, 100, 100),
75
- // 64, 32, 64
76
- // )
77
- // console.profileEnd('mesh build');
75
+ tetrahedral_mesh_build_from_grid(
76
+ tetrahedra,
77
+ points,
78
+ new AABB3(-10, 0, -10, 10, 10, 10),
79
+ 8, 4, 8
80
+ )
78
81
  console.timeEnd('mesh build');
79
82
  console.log(`Mesh build for ${number_pretty_print(points.length / 3)} points`)
80
83
 
@@ -115,7 +115,7 @@ class WorkerBuilder {
115
115
  result.push(obj);
116
116
  } else if (obj.buffer instanceof ArrayBuffer) {
117
117
  result.push(obj.buffer);
118
- } else if (obj instanceof ImageBitmap) {
118
+ } else if (typeof ImageBitmap !== "undefined" && obj instanceof ImageBitmap) {
119
119
  result.push(obj);
120
120
  } else {
121
121
  for (var i in obj) {
@@ -1 +1 @@
1
- {"version":3,"file":"extractTransferables.d.ts","sourceRoot":"","sources":["../../../../../src/core/process/worker/extractTransferables.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oEAgBC"}
1
+ {"version":3,"file":"extractTransferables.d.ts","sourceRoot":"","sources":["../../../../../src/core/process/worker/extractTransferables.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,oEAgBC"}
@@ -1,3 +1,5 @@
1
+ import { isImageBitmap } from "../../../engine/graphics/texture/isImageBitmap.js";
2
+
1
3
  /**
2
4
  *
3
5
  * @param {*} obj
@@ -11,7 +13,7 @@ export function extractTransferables(obj, result) {
11
13
  result.push(obj);
12
14
  } else if (obj.buffer instanceof ArrayBuffer) {
13
15
  result.push(obj.buffer);
14
- } else if (obj instanceof ImageBitmap) {
16
+ } else if (isImageBitmap(obj)) {
15
17
  result.push(obj);
16
18
  } else {
17
19
  for (let i in obj) {
@@ -1 +1 @@
1
- {"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,gEAFa,OAAO,CAoDnB;AAGD;;;;;GAKG;AACH,sCAJW,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,KACtC,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,GACpC,OAAO,CAmEnB"}
1
+ {"version":3,"file":"computeTextureEquality.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureEquality.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,gEAFa,OAAO,CAoDnB;AAGD;;;;;GAKG;AACH,sCAJW,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,KACtC,8DAAM,EAAE,GAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,GACpC,OAAO,CAgEnB"}
@@ -1,5 +1,6 @@
1
1
  import { fastArrayEquals } from "../../../../core/collection/array/fastArrayEquals.js";
2
2
  import { isTypedArray } from "../../../../core/collection/array/typed/isTypedArray.js";
3
+ import { isImageBitmap } from "../../../graphics/texture/isImageBitmap.js";
3
4
  import { computeImageBitmapEquality } from "./computeImageBitmapEquality.js";
4
5
 
5
6
  //
@@ -93,13 +94,10 @@ export function textureImagesEqual(a, b) {
93
94
  return false;
94
95
  }
95
96
 
96
- if (
97
- // check that browser/environment has the class at all to avoid potential exceptions
98
- // Required for Safari below version 15.6
99
- ImageBitmap !== undefined
100
- && (a instanceof ImageBitmap && b instanceof ImageBitmap)
101
- ) {
97
+ if (isImageBitmap(a) && isImageBitmap(b)) {
98
+
102
99
  return computeImageBitmapEquality(a, b);
100
+
103
101
  }
104
102
 
105
103
  if (Array.isArray(a) && Array.isArray(b)) {
@@ -1 +1 @@
1
- {"version":3,"file":"computeTextureHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureHash.js"],"names":[],"mappings":"AAuBA;;;;GAIG;AACH;;WAHoD,MAAM;YAAQ,MAAM;IAC5D,MAAM,CAuCjB;AA4CD;;;;GAIG;AACH,sCAHW,UAAQ,MAAM,OAAO,GACnB,MAAM,CAqClB"}
1
+ {"version":3,"file":"computeTextureHash.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/asset/loaders/material/computeTextureHash.js"],"names":[],"mappings":"AAwBA;;;;GAIG;AACH;;WAHoD,MAAM;YAAQ,MAAM;IAC5D,MAAM,CAsCjB;AA4CD;;;;GAIG;AACH,sCAHW,UAAQ,MAAM,OAAO,GACnB,MAAM,CAqClB"}
@@ -2,6 +2,7 @@ import { computeHashIntegerArray } from "../../../../core/collection/array/compu
2
2
  import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
3
3
  import { computeHashFloat } from "../../../../core/primitives/numbers/computeHashFloat.js";
4
4
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
5
+ import { isImageBitmap } from "../../../graphics/texture/isImageBitmap.js";
5
6
  import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
6
7
 
7
8
  /**
@@ -35,15 +36,14 @@ export function computeImageDataHash(image) {
35
36
 
36
37
  let result = 0;
37
38
 
38
- if (
39
- // check that browser/environment has the class at all to avoid potential exceptions
40
- // Required for Safari below version 15.6
41
- ImageBitmap !== undefined
42
- && (image instanceof ImageBitmap)
43
- ) {
39
+ if (isImageBitmap(image)) {
40
+
44
41
  result = computeImageBitmapHash(image);
42
+
45
43
  } else if (image instanceof HTMLImageElement) {
44
+
46
45
  result = computeStringHash(image.src);
46
+
47
47
  }
48
48
 
49
49
  let width = 0;
@@ -125,7 +125,7 @@ class Trail2DSystem extends System {
125
125
  */
126
126
  __build_trail(trail, transform) {
127
127
  const segmentsPerSecond = 60;
128
- const maxSegments = 1000;
128
+ const maxSegments = 1024;
129
129
  //instantiation
130
130
 
131
131
  //make a mesh
@@ -1 +1 @@
1
- {"version":3,"file":"MaterialManager.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/material/manager/MaterialManager.js"],"names":[],"mappings":"AAOA;IAGQ;;;;OAIG;IACH,kBAIE;IAEF;;;;OAIG;IACH,gBAIE;IAEF;;;;OAIG;IACH,0BAIE;IAIF;;;;OAIG;IACH,0BAA2B;IAG/B;;;;;OAKG;IACH,2BAEC;IAED;;;;OAIG;IACH,wCAUC;IAED;;;OAGG;IACH,uDAEC;IAED;;;;OAIG;IACH,qDAFa,OAAO,CAYnB;IAED;;;;;OAKG;IACH,kBAcC;IAGD;;;;OAIG;IACH,8CAmCC;CACJ"}
1
+ {"version":3,"file":"MaterialManager.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/material/manager/MaterialManager.js"],"names":[],"mappings":"AAMA;IAGQ;;;;OAIG;IACH,kBAIE;IAEF;;;;OAIG;IACH,gBAIE;IAEF;;;;OAIG;IACH,0BAIE;IAIF;;;;OAIG;IACH,0BAA2B;IAG/B;;;;;OAKG;IACH,2BAEC;IAED;;;;OAIG;IACH,wCAUC;IAED;;;OAGG;IACH,uDAEC;IAED;;;;OAIG;IACH,qDAFa,OAAO,CAYnB;IAED;;;;;OAKG;IACH,kBAcC;IAGD;;;;OAIG;IACH,8CAmCC;CACJ"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Guards against cases where ImageBitmap doesn't exist
3
+ * @param {*} image
4
+ * @return {boolean}
5
+ */
6
+ export function isImageBitmap(image: any): boolean;
7
+ //# sourceMappingURL=isImageBitmap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isImageBitmap.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/texture/isImageBitmap.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,2CAFY,OAAO,CAQlB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Guards against cases where ImageBitmap doesn't exist
3
+ * @param {*} image
4
+ * @return {boolean}
5
+ */
6
+ export function isImageBitmap(image) {
7
+ /**
8
+ * check that browser/environment has the class at all to avoid potential exceptions
9
+ * Required for Safari below version 15.6
10
+ */
11
+ return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap;
12
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"RibbonXPlugin.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonXPlugin.js"],"names":[],"mappings":"AASA;IACI,8BA6BC;IA1BG,WAA2B;IAE3B;;;;OAIG;IACH,+BAKE;IAEF;;;;MAIC;IAED;;;;OAIG;IACH,oBAAwC;IAG5C,sCAIC;IAED,wBAMC;IAED,yBAKC;IAED;;;;OAIG;IACH,0EAIC;IAED;;;;OAIG;IACH,8CAFa,eAAe,CAe3B;IAGD;;;;;OAKG;IACH,yBA8BC;CACJ;6BA9H4B,iCAAiC;wBAL1B,OAAO;gCAOX,sBAAsB"}
1
+ {"version":3,"file":"RibbonXPlugin.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonXPlugin.js"],"names":[],"mappings":"AASA;IACI,8BA6BC;IA1BG,WAA2B;IAE3B;;;;OAIG;IACH,+BAKE;IAEF;;;;MAIC;IAED;;;;OAIG;IACH,oBAAwC;IAG5C,sCAIC;IAED,wBAMC;IAED,yBAKC;IAED;;;;OAIG;IACH,0EAIC;IAED;;;;OAIG;IACH,8CAFa,eAAe,CAe3B;IAGD;;;;;OAKG;IACH,yBAsCC;CACJ;6BAtI4B,iCAAiC;wBAL1B,OAAO;gCAOX,sBAAsB"}
@@ -119,7 +119,15 @@ export class RibbonXPlugin extends EnginePlugin {
119
119
  path: spec.diffuse,
120
120
  type: GameAssetType.Texture,
121
121
  callback: (asset) => {
122
- material.uniforms.uDiffuse.value = asset.create();
122
+ /**
123
+ *
124
+ * @type {Texture}
125
+ */
126
+ const texture = asset.create();
127
+
128
+ texture.generateMipmaps = true;
129
+
130
+ material.uniforms.uDiffuse.value = texture;
123
131
  }, failure: console.warn
124
132
  });
125
133