@woosh/meep-engine 2.33.13 → 2.33.17

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.
@@ -62,8 +62,8 @@ function codeToURL(code) {
62
62
 
63
63
  let blob;
64
64
 
65
- if (window !== undefined) {
66
- if (window.Blob !== undefined) {
65
+ if (typeof window === 'object') {
66
+ if (typeof window.Blob !== "undefined") {
67
67
  blob = new Blob([code], { type: js_mime });
68
68
  } else {
69
69
  // Backwards-compatibility
@@ -13,26 +13,17 @@ import { build_geometry_info } from "./build_geometry_info.js";
13
13
  import { build_leaf_patches_metis } from "./clustering/build_leaf_patches_metis.js";
14
14
  import { compute_buffer_geometry_byte_size } from "../../geometry/buffered/compute_buffer_geometry_byte_size.js";
15
15
 
16
-
17
16
  /**
18
- *
19
- * @param {MicronGeometryBufferAttributeSpec[]} attributes
17
+ * Returns current time in milliseconds
18
+ * Wrapper to ensure support of both web as well as node.js
19
+ * @return {number}
20
20
  */
21
- function buildVertexDataTypeMap(attributes) {
22
-
23
- const data_types = [];
24
-
25
- for (let i = 0; i < attributes.length; i++) {
26
- const spec = attributes[i];
27
-
28
- const itemSize = spec.itemSize;
29
-
30
- for (let j = 0; j < itemSize; j++) {
31
- data_types.push(spec.type);
32
- }
21
+ function current_time_millis() {
22
+ if (typeof performance !== 'undefined') {
23
+ return performance.now();
24
+ } else {
25
+ return Date.now();
33
26
  }
34
-
35
- return data_types;
36
27
  }
37
28
 
38
29
  /**
@@ -141,7 +132,7 @@ export async function buildMicronGeometryFromBufferGeometry(input) {
141
132
 
142
133
  // TODO drop patches with 0 volume (degenerate triangles)
143
134
 
144
- const t_build_leaf_patches_start = performance.now();
135
+ const t_build_leaf_patches_start = current_time_millis();
145
136
 
146
137
  const patches = await build_leaf_patches_metis(
147
138
  topoMesh,
@@ -152,7 +143,7 @@ export async function buildMicronGeometryFromBufferGeometry(input) {
152
143
  );
153
144
 
154
145
  if (PRINT_VERBOSE_STATS) {
155
- console.log(`build leaf patches: ${(performance.now() - t_build_leaf_patches_start)}ms`);
146
+ console.log(`build leaf patches: ${(current_time_millis() - t_build_leaf_patches_start)}ms`);
156
147
 
157
148
 
158
149
  console.log(build_clustering_info(patches));
@@ -167,11 +158,11 @@ export async function buildMicronGeometryFromBufferGeometry(input) {
167
158
  // console.timeEnd('assign initial neighbours');
168
159
 
169
160
 
170
- const t_build_hierarchy_start = performance.now();
161
+ const t_build_hierarchy_start = current_time_millis();
171
162
  const root = await buildAbstractPatchHierarchy(patches);
172
163
 
173
164
  if (PRINT_VERBOSE_STATS) {
174
- console.log(`build hierarchy: ${(performance.now() - t_build_hierarchy_start)}ms`);
165
+ console.log(`build hierarchy: ${(current_time_millis() - t_build_hierarchy_start)}ms`);
175
166
  }
176
167
 
177
168
  // console.profile('simplification');
@@ -35,8 +35,23 @@ export function convertPathToURL(path) {
35
35
  } else if (ENVIRONMENT_IS_WORKER) {
36
36
  scope = self;
37
37
  } else if (ENVIRONMENT_IS_NODE) {
38
+
39
+ let normalized_path = `${process.cwd()}/${path}`.replace(/\\/g, '/');
40
+
41
+ // remove multiple sequential slashes
42
+ normalized_path = normalized_path.replace(/\/+/g, '/');
43
+
44
+ if (normalized_path[0] !== '/') {
45
+ // Windows drive letter must be prefixed with a slash.
46
+ normalized_path = `/${normalized_path}`;
47
+ }
48
+
38
49
  scope = {
39
- location: new URL(import.meta.url)
50
+ location: {
51
+ pathname: normalized_path,
52
+ host: '',
53
+ protocol: 'file:'
54
+ }
40
55
  };
41
56
  } else {
42
57
  throw new Error('Unknown environment');
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.13",
7
+ "version": "2.33.17",
8
8
  "dependencies": {
9
9
  "fast-levenshtein": "2.0.6",
10
10
  "opentype.js": "1.3.3",