@woosh/meep-engine 2.33.57 → 2.33.61

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 (95) hide show
  1. package/core/bvh2/aabb3/AABB3.js +4 -1
  2. package/core/bvh2/traversal/traverseBinaryNodeUsingVisitor.js +6 -6
  3. package/core/cache/Cache.js +7 -0
  4. package/core/collection/array/fastArrayEquals.js +17 -0
  5. package/core/collection/array/typed/is_typed_array_equals.js +58 -0
  6. package/core/collection/map/AbstractAsyncMap.js +30 -0
  7. package/core/collection/map/AsyncMapWrapper.js +16 -0
  8. package/core/collection/map/AsyncRemoteHashMap.js +358 -0
  9. package/core/collection/map/CachedAsyncMap.js +34 -0
  10. package/core/geom/3d/SurfacePoint3.js +44 -5
  11. package/core/geom/Vector2.d.ts +2 -0
  12. package/core/geom/Vector4.js +5 -5
  13. package/core/geom/packing/MaxRectangles.js +13 -4
  14. package/core/math/hash/murmur3_32.js +3 -3
  15. package/engine/animation/removeEntityGenericEffect.js +22 -31
  16. package/engine/asset/Asset.js +0 -45
  17. package/engine/asset/AssetDescription.js +51 -0
  18. package/engine/asset/AssetManager.d.ts +7 -0
  19. package/engine/asset/AssetManager.js +98 -2
  20. package/engine/asset/AssetTransformer.d.ts +5 -0
  21. package/engine/asset/AssetTransformer.js +15 -0
  22. package/engine/asset/loaders/GLTFAssetLoader.js +27 -25
  23. package/engine/asset/loaders/material/computeImageBitmapEquality.js +2 -2
  24. package/engine/asset/loaders/material/computeTextureEquality.js +2 -2
  25. package/engine/asset/loaders/material/computeTextureHash.js +7 -13
  26. package/engine/ecs/attachment/AttachmentSystem.js +18 -17
  27. package/engine/ecs/grid/HeightMap2NormalMap.js +1 -1
  28. package/engine/ecs/grid/NormalMap2AOMap.js +1 -1
  29. package/engine/ecs/gui/GUIElement.js +0 -106
  30. package/engine/ecs/gui/GUIElementSerializationAdapter.js +108 -0
  31. package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +60 -45
  32. package/engine/ecs/gui/position/ViewportPositionSystem.js +5 -5
  33. package/engine/ecs/parent/EntityNode.d.ts +20 -0
  34. package/engine/ecs/parent/EntityNode.js +284 -0
  35. package/engine/ecs/parent/FaceEditor.js +137 -0
  36. package/engine/ecs/parent/testCompositionEntityNode.js +153 -0
  37. package/engine/ecs/parent/testHuDPerf.js +123 -0
  38. package/engine/ecs/storage/binary/BinaryClassUpgrader.js +1 -0
  39. package/engine/ecs/terrain/ecs/Terrain.js +14 -5
  40. package/engine/ecs/util/removeComponentsExcept.js +3 -3
  41. package/engine/graphics/GraphicsEngine.js +4 -5
  42. package/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
  43. package/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +0 -1
  44. package/engine/graphics/ecs/camera/topdown/TopDownCameraController.spec.js +8 -0
  45. package/engine/graphics/ecs/light/LightSystem.js +1 -1
  46. package/engine/graphics/ecs/mesh/Mesh.js +5 -5
  47. package/engine/graphics/ecs/mesh/MeshSystem.js +12 -20
  48. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +29 -0
  49. package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +158 -1
  50. package/engine/graphics/ecs/path/PathDisplaySystem.d.ts +3 -1
  51. package/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
  52. package/engine/graphics/ecs/trail2d/Trail2D.js +35 -1
  53. package/engine/graphics/ecs/trail2d/Trail2DSystem.js +26 -19
  54. package/engine/graphics/ecs/trail2d/makeGradientTrail.js +68 -0
  55. package/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +55 -11
  56. package/engine/graphics/micron/convert_three_object_to_micron.js +24 -7
  57. package/engine/graphics/micron/plugin/MicronRenderPlugin.js +107 -4
  58. package/engine/graphics/micron/plugin/serialization/BufferGeometrySerializationAdapter.js +176 -0
  59. package/engine/graphics/micron/render/v1/MaterialContext.js +1 -0
  60. package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +19 -3
  61. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.d.ts +2 -0
  62. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -4
  63. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
  64. package/engine/graphics/render/buffer/simple-fx/DepthLimitedBlur.js +2 -2
  65. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -2
  66. package/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +3 -1
  67. package/engine/graphics/render/frame_graph/FrameGraphBuilder.js +36 -0
  68. package/engine/graphics/render/frame_graph/IRenderContext.js +8 -0
  69. package/engine/graphics/render/frame_graph/RenderPass.js +32 -0
  70. package/engine/graphics/render/frame_graph/RenderPassFlags.js +6 -0
  71. package/engine/graphics/render/frame_graph/RenderPassResources.js +15 -0
  72. package/engine/graphics/render/frame_graph/Resource.js +21 -0
  73. package/engine/graphics/render/frame_graph/ResourceReference.js +14 -0
  74. package/engine/graphics/render/frame_graph/TextureDescriptor.js +30 -0
  75. package/engine/graphics/render/frame_graph/UsageModeType.js +5 -0
  76. package/engine/graphics/render/frame_graph/sample/deferred/GBufferDrawPass.js +27 -0
  77. package/engine/graphics/render/frame_graph/sample/deferred/PresentPass.js +17 -0
  78. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
  79. package/engine/graphics/render/webgpu/sample/_main.ts +650 -0
  80. package/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +67 -0
  81. package/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +38 -0
  82. package/engine/graphics/render/webgpu/sample/fragmentWriteGBuffers.wgsl +21 -0
  83. package/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +34 -0
  84. package/engine/graphics/render/webgpu/sample/main.js +566 -0
  85. package/engine/graphics/render/webgpu/sample/vertexTextureQuad.wgsl +9 -0
  86. package/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +28 -0
  87. package/engine/graphics/shadows/ShadowMapRenderer.js +10 -4
  88. package/engine/graphics/shadows/testShadowMapRendering.js +0 -2
  89. package/engine/graphics/texture/sampler/Sampler2D.js +24 -45
  90. package/engine/{ecs/grid → graphics/texture/sampler}/sampler2DToFloat32Texture.js +1 -1
  91. package/engine/intelligence/behavior/ecs/WaitForEventBehavior.js +3 -0
  92. package/engine/save/storage/IndexedDBStorage.js +8 -1
  93. package/package.json +1 -1
  94. package/samples/terrain/main.js +117 -0
  95. package/engine/ecs/sockets/AttachmentSocketsSystem.js +0 -10
@@ -12,9 +12,10 @@ import Vector2 from "../Vector2.js";
12
12
  * @param {AABB2[]} boxes
13
13
  */
14
14
  function removeRedundantBoxesArray(boxes) {
15
+ let i, j;
15
16
  let numBoxes = boxes.length;
16
17
 
17
- loop_a: for (let i = 0; i < numBoxes; i++) {
18
+ loop_a: for (i = 0; i < numBoxes; i++) {
18
19
  const a = boxes[i];
19
20
 
20
21
  const ax0 = a.x0;
@@ -22,7 +23,7 @@ function removeRedundantBoxesArray(boxes) {
22
23
  const ax1 = a.x1;
23
24
  const ay1 = a.y1;
24
25
 
25
- for (let j = i + 1; j < numBoxes; j++) {
26
+ for (j = i + 1; j < numBoxes; j++) {
26
27
  const b = boxes[j];
27
28
 
28
29
  const bx0 = b.x0;
@@ -157,7 +158,7 @@ function findBestContainer(width, height, boxes, costFunction) {
157
158
  let best = null;
158
159
  let bestScore = Number.POSITIVE_INFINITY;
159
160
 
160
- boxes.traversePreOrder(node => {
161
+ const visitor = (node) => {
161
162
 
162
163
  if (node.getWidth() < width) {
163
164
  //too small, don't traverse deeper
@@ -195,7 +196,11 @@ function findBestContainer(width, height, boxes, costFunction) {
195
196
  best = box;
196
197
  }
197
198
  }
198
- });
199
+
200
+ return true;
201
+ };
202
+
203
+ boxes.traversePreOrder(visitor);
199
204
 
200
205
  return best;
201
206
  }
@@ -337,6 +342,10 @@ export class MaxRectanglesPacker {
337
342
  this.free = new QuadTreeNode(0, 0, width, height);
338
343
  this.free.add(null, 0, 0, width, height);
339
344
 
345
+ /**
346
+ *
347
+ * @type {AABB2[]}
348
+ */
340
349
  this.boxes = [];
341
350
  }
342
351
 
@@ -9,9 +9,9 @@ export function murmur3_32(key, seed) {
9
9
  let k1;
10
10
  let i = 0;
11
11
 
12
- const bytes = key.length;
12
+ const key_length = key.length;
13
13
 
14
- while (i < bytes) {
14
+ while (i < key_length) {
15
15
  k1 = key[i];
16
16
  ++i;
17
17
 
@@ -26,7 +26,7 @@ export function murmur3_32(key, seed) {
26
26
  }
27
27
 
28
28
  // mix in array length
29
- h1 ^= bytes;
29
+ h1 ^= key_length;
30
30
 
31
31
  h1 ^= h1 >>> 16;
32
32
  h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16));
@@ -3,22 +3,7 @@ import { ParticleEmitter } from "../graphics/particles/particular/engine/emitter
3
3
 
4
4
  const lib = {
5
5
  'cloud-puff': {
6
- "position": {
7
- "x": 56.41791044776119,
8
- "y": -8.887834661270745,
9
- "z": 223.65671641791042
10
- },
11
- "scale": {
12
- "x": 1,
13
- "y": 1,
14
- "z": 1
15
- },
16
- "rotation": {
17
- "x": 0,
18
- "y": 0,
19
- "z": 0,
20
- "w": 1
21
- },
6
+ "receiveLight": true,
22
7
  "parameters": [
23
8
  {
24
9
  "name": "scale",
@@ -80,24 +65,24 @@ const lib = {
80
65
  "track": {
81
66
  "itemSize": 4,
82
67
  "data": [
83
- 0.9803921568627451,
84
- 0.9803921568627451,
85
- 0.9803921568627451,
86
- 0.3,
68
+ 0.6,
69
+ 0.6,
70
+ 0.6,
71
+ 0,
87
72
 
88
- 0.9882352941176471,
89
- 0.9882352941176471,
90
- 0.9882352941176471,
91
- 0.9880952380952381,
73
+ 0.6,
74
+ 0.6,
75
+ 0.6,
76
+ 1,
92
77
 
93
- 0.9882352941176471,
94
- 0.9882352941176471,
95
- 0.9882352941176471,
78
+ 0.6,
79
+ 0.6,
80
+ 0.6,
96
81
  0.5,
97
82
 
98
- 0.9882352941176471,
99
- 0.9882352941176471,
100
- 0.9882352941176471,
83
+ 0.6,
84
+ 0.6,
85
+ 0.6,
101
86
  0
102
87
  ],
103
88
  "positions": [
@@ -155,7 +140,13 @@ export function removeEntityGenericEffect(
155
140
  }
156
141
  ) {
157
142
 
158
- const emitter = ParticleEmitter.fromJSON(lib[particles]);
143
+ const particle_json = lib[particles];
144
+
145
+ if (particle_json === undefined) {
146
+ throw new Error(`Unsupported particle ID '${particles}'`);
147
+ }
148
+
149
+ const emitter = ParticleEmitter.fromJSON(particle_json);
159
150
 
160
151
  const result = removeEntityWithEffect({
161
152
  entity,
@@ -4,51 +4,6 @@
4
4
  * @param {string} type
5
5
  * @constructor
6
6
  */
7
- import { assert } from "../../core/assert.js";
8
- import { computeStringHash } from "../../core/primitives/strings/computeStringHash.js";
9
- import { computeHashIntegerArray } from "../../core/collection/array/computeHashIntegerArray.js";
10
-
11
- export class AssetDescription {
12
- /**
13
- *
14
- * @param {string} path
15
- * @param {string} type
16
- * @constructor
17
- */
18
- constructor(path, type) {
19
- assert.typeOf(path, 'string', 'path');
20
- assert.typeOf(type, 'string', 'type');
21
-
22
- /**
23
- * @type {string}
24
- */
25
- this.path = path;
26
- /**
27
- * @type {string}
28
- */
29
- this.type = type;
30
- }
31
-
32
- /**
33
- *
34
- * @param {AssetDescription} other
35
- * @returns {boolean}
36
- */
37
- equals(other) {
38
- return this.path === other.path && this.type === other.type;
39
- }
40
-
41
- /**
42
- *
43
- * @returns {number}
44
- */
45
- hash() {
46
- return computeHashIntegerArray(
47
- computeStringHash(this.path),
48
- computeStringHash(this.type)
49
- );
50
- }
51
- }
52
7
 
53
8
 
54
9
  export class Asset {
@@ -0,0 +1,51 @@
1
+ import { assert } from "../../core/assert.js";
2
+ import { computeHashIntegerArray } from "../../core/collection/array/computeHashIntegerArray.js";
3
+ import { computeStringHash } from "../../core/primitives/strings/computeStringHash.js";
4
+
5
+ export class AssetDescription {
6
+ /**
7
+ *
8
+ * @param {string} path
9
+ * @param {string} type
10
+ * @constructor
11
+ */
12
+ constructor(path, type) {
13
+ assert.isString(path, 'path');
14
+ assert.isString(type, 'type');
15
+
16
+ /**
17
+ * @type {string}
18
+ */
19
+ this.path = path;
20
+ /**
21
+ * @type {string}
22
+ */
23
+ this.type = type;
24
+ }
25
+
26
+ /**
27
+ *
28
+ * @param {AssetDescription} other
29
+ * @returns {boolean}
30
+ */
31
+ equals(other) {
32
+ return this.path === other.path
33
+ && this.type === other.type
34
+ ;
35
+ }
36
+
37
+ /**
38
+ *
39
+ * @returns {number}
40
+ */
41
+ hash() {
42
+ return computeHashIntegerArray(
43
+ computeStringHash(this.path),
44
+ computeStringHash(this.type)
45
+ );
46
+ }
47
+
48
+ toString() {
49
+ return `{ type: '${this.type}', path: '${this.path}' }`;
50
+ }
51
+ }
@@ -1,6 +1,7 @@
1
1
  import {AssetLoader} from "./loaders/AssetLoader";
2
2
  import {Asset} from "./Asset";
3
3
  import {CrossOriginConfig} from "./CORS/CrossOriginConfig";
4
+ import {AssetTransformer} from "./AssetTransformer";
4
5
 
5
6
  export class AssetManager {
6
7
  public readonly crossOriginConfig: CrossOriginConfig
@@ -12,4 +13,10 @@ export class AssetManager {
12
13
  public clear(): void
13
14
 
14
15
  public registerLoader<T>(type: string, loader: AssetLoader<T>): Promise<void>
16
+
17
+ public unregisterLoader(type: string): Promise<void>
18
+
19
+ public registerTransformer<T extends Asset<X>, X = any>(type: string, transformer: AssetTransformer<T>): void
20
+
21
+ public unregisterTransformer<T extends Asset<X>, X = any>(type: string, transformer: AssetTransformer<T>): boolean
15
22
  }
@@ -5,12 +5,13 @@
5
5
 
6
6
  import BoundedValue from "../../core/model/BoundedValue.js";
7
7
  import { ObservedMap } from "../../core/collection/ObservedMap.js";
8
- import { AssetDescription } from "./Asset.js";
9
8
  import { HashMap } from "../../core/collection/HashMap.js";
10
9
  import { extractAssetListFromManager } from "./preloader/extractAssetListFromManager.js";
11
10
  import { assert } from "../../core/assert.js";
12
11
  import { HashSet } from "../../core/collection/HashSet.js";
13
12
  import { CrossOriginConfig } from "./CORS/CrossOriginConfig.js";
13
+ import { array_remove_element } from "../../core/collection/array/array_remove_element.js";
14
+ import { AssetDescription } from "./AssetDescription.js";
14
15
 
15
16
  /**
16
17
  *
@@ -62,6 +63,13 @@ function AssetManager(engine) {
62
63
  */
63
64
  this.loaders = {};
64
65
 
66
+ /**
67
+ * After asset is loaded, a chain of transforms can be applied to it, these are registered here
68
+ * Transformers are executed in the order in which they are added
69
+ * @type {Object<AssetTransformer[]>}
70
+ */
71
+ this.transformers = {};
72
+
65
73
  /**
66
74
  * Named links to specific assets. Useful to later re-mapping assets and having meaningful names for them
67
75
  * @type {Map<string, AssetDescription>}
@@ -209,7 +217,30 @@ AssetManager.prototype.submitRequest = function (path, type, request) {
209
217
  const assets = this.assets;
210
218
  const failures = this.failures;
211
219
 
212
- function success(asset) {
220
+ /**
221
+ *
222
+ * @param {Asset} loaded_asset
223
+ */
224
+ const success = async (loaded_asset) => {
225
+ let asset = loaded_asset;
226
+
227
+ // apply transform chain
228
+ const transformers = this.transformers[type];
229
+ if (transformers !== undefined) {
230
+ const transformer_count = transformers.length;
231
+ for (let i = 0; i < transformer_count; i++) {
232
+ const transformer = transformers[i];
233
+
234
+ const transformed_asset = await transformer.transform(asset);
235
+
236
+ if (typeof transformed_asset !== "object") {
237
+ console.error('Transformer produced invalid result. Ignoring result.', transformer, assetDescription);
238
+ } else {
239
+ asset = transformed_asset;
240
+ }
241
+ }
242
+ }
243
+
213
244
  //link asset description
214
245
  asset.description = assetDescription;
215
246
 
@@ -298,6 +329,71 @@ AssetManager.prototype.getLoaderByType = function (type) {
298
329
  return this.loaders[type];
299
330
  };
300
331
 
332
+ /**
333
+ *
334
+ * @param {string} type
335
+ * @return {AssetDescription[]}
336
+ * @private
337
+ */
338
+ AssetManager.prototype.__getLoadedAssetDescriptorsByType = function (type) {
339
+ const loaded_assets = Array.from(this.assets.keys());
340
+ return loaded_assets.filter(t => t.type === type);
341
+ }
342
+
343
+ /**
344
+ * @template T
345
+ * @param {string} type
346
+ * @param {AssetTransformer<T>} transformer
347
+ */
348
+ AssetManager.prototype.registerTransformer = function (type, transformer) {
349
+ let transformers = this.transformers[type];
350
+
351
+ if (transformers === undefined) {
352
+ transformers = [];
353
+
354
+ this.transformers[type] = transformers;
355
+ }
356
+
357
+ transformers.push(transformer);
358
+
359
+ // check for loaded assets
360
+ const matching_assets = this.__getLoadedAssetDescriptorsByType(type);
361
+
362
+ if (matching_assets.length > 0) {
363
+ console.warn(`Following assets of matching type '${type}' are already loaded and transform is not applied to them:\n\t${matching_assets.join('\n\t')}`);
364
+ }
365
+
366
+ };
367
+
368
+ /**
369
+ * @template T
370
+ * @param {string} type
371
+ * @param {AssetTransformer<T>} transformer
372
+ */
373
+ AssetManager.prototype.unregisterTransformer = function (type, transformer) {
374
+
375
+ const transformers = this.transformers[type];
376
+
377
+ if (transformers === undefined) {
378
+ // not found
379
+ return false;
380
+ }
381
+
382
+ if (!array_remove_element(transformers, 0, transformers.length, transformer)) {
383
+ // not found
384
+ return false;
385
+ }
386
+
387
+ // check for loaded assets
388
+ const matching_assets = this.__getLoadedAssetDescriptorsByType(type);
389
+
390
+ if (matching_assets.length > 0) {
391
+ console.warn(`Following assets of matching type '${type}' are already loaded and transform was probably already applied to them:\n\t${matching_assets.join('\n\t')}`);
392
+ }
393
+
394
+ return true;
395
+ }
396
+
301
397
  /**
302
398
  * @template T
303
399
  * @param {string} type
@@ -0,0 +1,5 @@
1
+ import {Asset} from "./Asset";
2
+
3
+ export class AssetTransformer<A extends Asset<T>, T = any> {
4
+ transform(source: A): Promise<A>
5
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Applies a transformation to an asset. Such as performing mesh simplification for example.
3
+ * Transformation is executed by the {@link AssetManager}
4
+ * @template {Asset<T>} A
5
+ * @template T
6
+ */
7
+ export class AssetTransformer {
8
+ /**
9
+ * @param {A} source
10
+ * @returns {A}
11
+ */
12
+ async transform(source) {
13
+ throw new Error('Not Implemented');
14
+ }
15
+ }
@@ -19,7 +19,6 @@ import { CrossOriginKind } from "../CORS/CrossOriginKind.js";
19
19
  import { computeObjectBoundingSphere } from "./gltf/computeObjectBoundingSphere.js";
20
20
  import { isMesh } from "./gltf/isMesh.js";
21
21
  import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader.js";
22
- import { convert_three_object_to_micron } from "../../graphics/micron/convert_three_object_to_micron.js";
23
22
  import { HashSet } from "../../../core/collection/HashSet.js";
24
23
  import { computeGeometryHash } from "./geometry/geometry/computeGeometryHash.js";
25
24
  import { computeGeometryEquality } from "./geometry/geometry/computeGeometryEquality.js";
@@ -173,11 +172,20 @@ export class GLTFAssetLoader extends AssetLoader {
173
172
  this.loader = loader;
174
173
 
175
174
  /**
176
- *
175
+ * Asset optimization flag
176
+ * Whether or not geometry de-duping should be done
177
177
  * @type {boolean}
178
178
  * @private
179
179
  */
180
- this.__enable_micron = true;
180
+ this.__enable_geometry_cache = false;
181
+
182
+ /**
183
+ * Asset optimization flag
184
+ * Whether or not texture de-duping should be done
185
+ * @type {boolean}
186
+ * @private
187
+ */
188
+ this.__enable_texture_cache = false;
181
189
 
182
190
  /**
183
191
  *
@@ -216,7 +224,7 @@ export class GLTFAssetLoader extends AssetLoader {
216
224
  * @param {boolean} v
217
225
  */
218
226
  set is_micron_enabled(v) {
219
- this.__enable_micron = v;
227
+ console.warn('Deprecated. Handled by the MicronRenderPlugin. Remove usage, no further action required');
220
228
  }
221
229
 
222
230
  /**
@@ -224,7 +232,7 @@ export class GLTFAssetLoader extends AssetLoader {
224
232
  * @returns {boolean}
225
233
  */
226
234
  get is_micron_enabled() {
227
- return this.__enable_micron;
235
+ throw new Error('Deprecated. Handled by the MicronRenderPlugin. Remove usage, no further action required. To check for presence of micron, check plugins instead.');
228
236
  }
229
237
 
230
238
  async link(assetManager, engine) {
@@ -275,14 +283,15 @@ export class GLTFAssetLoader extends AssetLoader {
275
283
  alphaTest: object.material.alphaTest
276
284
  });
277
285
 
278
- object.customDepthMaterial = materialCache.acquire(depthMaterial);
286
+ if (this.__enable_texture_cache) {
287
+ object.customDepthMaterial = materialCache.acquire(depthMaterial);
288
+ }
279
289
  }
280
290
  }
281
291
 
282
292
 
283
293
  load(path, success, failure, progress) {
284
294
  const loader = this.loader;
285
- const geometry_cache = this.__geometry_cache;
286
295
  const texture_cache = this.__texture_cache;
287
296
 
288
297
 
@@ -290,19 +299,24 @@ export class GLTFAssetLoader extends AssetLoader {
290
299
  *
291
300
  * @param {THREE.Mesh|THREE.SkinnedMesh} mesh
292
301
  */
293
- async function processMesh(mesh) {
302
+ const processMesh = async (mesh) => {
294
303
  let geometry = mesh.geometry;
295
304
 
296
305
  if (geometry === undefined) {
297
306
  throw new Error(`No geometry found`);
298
307
  }
299
308
 
300
- // replace geometry
301
- geometry = geometry_cache.ensure(geometry);
302
- mesh.geometry = geometry;
309
+ if (this.__enable_geometry_cache) {
310
+ // replace geometry
311
+ geometry = this.__geometry_cache.ensure(geometry);
312
+ mesh.geometry = geometry;
313
+ }
314
+
303
315
 
304
- // replace textures from cache
305
- replace_material_textures_from_cache(mesh.material, texture_cache);
316
+ if (this.__enable_texture_cache) {
317
+ // replace textures from cache
318
+ replace_material_textures_from_cache(mesh.material, texture_cache);
319
+ }
306
320
 
307
321
  const isSkinned = mesh.isSkinnedMesh === true;
308
322
 
@@ -431,18 +445,6 @@ export class GLTFAssetLoader extends AssetLoader {
431
445
  asset.animations = animations;
432
446
  }
433
447
 
434
- // build micron mesh
435
- if (
436
- this.__enable_micron
437
- && (asset.animations === undefined || asset.animations.length === 0)
438
- ) {
439
- // TODO deal with animations
440
- const micron_root = await convert_three_object_to_micron(root.clone());
441
- micron_root.boundingSphere = root.boundingSphere;
442
-
443
- asset.micron = micron_root;
444
- }
445
-
446
448
  success(asset);
447
449
  }, function (xhr) {
448
450
  //dispatch progress callback
@@ -1,7 +1,7 @@
1
1
  import { Sampler2D } from "../../../graphics/texture/sampler/Sampler2D.js";
2
2
  import { assert } from "../../../../core/assert.js";
3
- import { isArrayEqualStrict } from "../../../../core/collection/array/isArrayEqualStrict.js";
4
3
  import { bitmap2sampler_gl } from "./bitmap2sampler_gl.js";
4
+ import { fastArrayEquals } from "../../../../core/collection/array/fastArrayEquals.js";
5
5
 
6
6
  /**
7
7
  *
@@ -114,5 +114,5 @@ export function computeImageBitmapEquality(a, b) {
114
114
 
115
115
  const b_s = obtainSampler(b, ctx);
116
116
 
117
- return isArrayEqualStrict(a_s.data, b_s.data);
117
+ return fastArrayEquals(a_s.data, b_s.data);
118
118
  }
@@ -1,5 +1,5 @@
1
1
  import { computeImageBitmapEquality } from "./computeImageBitmapEquality.js";
2
- import { isArrayEqualStrict } from "../../../../core/collection/array/isArrayEqualStrict.js";
2
+ import { fastArrayEquals } from "../../../../core/collection/array/fastArrayEquals.js";
3
3
 
4
4
  //
5
5
 
@@ -184,5 +184,5 @@ function textureMipmapEqual(a, b) {
184
184
  return true;
185
185
  }
186
186
 
187
- return isArrayEqualStrict(aData, bData);
187
+ return fastArrayEquals(aData, bData);
188
188
  }
@@ -1,7 +1,7 @@
1
- import { max2 } from "../../../../core/math/max2.js";
2
1
  import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
3
2
  import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
4
3
  import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
4
+ import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
5
5
 
6
6
  /**
7
7
  *
@@ -59,6 +59,7 @@ export function computeImageDataHash(image) {
59
59
  */
60
60
  function computeSpecificHash(texture) {
61
61
  let dataHash = 0;
62
+ let i;
62
63
 
63
64
  if (texture.image !== null && texture.image !== undefined) {
64
65
 
@@ -73,25 +74,18 @@ function computeSpecificHash(texture) {
73
74
  if (Array.isArray(mipmaps)) {
74
75
  const nMipmaps = mipmaps.length;
75
76
 
76
- for (let i = 0; i < nMipmaps; i++) {
77
+ for (i = 0; i < nMipmaps; i++) {
77
78
  const mipmap = mipmaps[i];
78
79
 
79
- if (mipmap.width > 16) {
80
- continue;
81
- }
82
-
83
80
  const data = mipmap.data;
84
-
85
81
  const dataSize = data.length;
86
82
 
87
- const dataStride = max2(1, Math.floor(dataSize / 31));
88
-
89
- for (let i = 0; i < dataSize; i += dataStride) {
90
- const datum = data[i];
91
-
92
- dataHash = ((dataHash << 5) - dataHash) + datum;
83
+ if (dataSize > 1024) {
84
+ continue;
93
85
  }
94
86
 
87
+ dataHash = ((dataHash << 5) - dataHash) + murmur3_32(data, 1337);
88
+
95
89
  break;
96
90
  }
97
91
 
@@ -6,7 +6,6 @@ import { assert } from "../../../core/assert.js";
6
6
  import Mesh from "../../graphics/ecs/mesh/Mesh.js";
7
7
  import { BoneAttachmentBinding } from "./BoneAttachmentBinding.js";
8
8
  import { TransformAttachmentBinding } from "./TransformAttachmentBinding.js";
9
- import { MeshSystem } from "../../graphics/ecs/mesh/MeshSystem.js";
10
9
 
11
10
  /**
12
11
  * @readonly
@@ -318,10 +317,10 @@ export class AttachmentSystem extends System {
318
317
 
319
318
  /**
320
319
  *
321
- * @param {Mesh} mesh
322
320
  * @param {number} entity
321
+ * @private
323
322
  */
324
- visitVisibleMesh(mesh, entity) {
323
+ __update_entity(entity) {
325
324
  const bindings = this.parentBindingIndex.get(entity);
326
325
 
327
326
  if (bindings !== undefined) {
@@ -335,25 +334,27 @@ export class AttachmentSystem extends System {
335
334
  }
336
335
  }
337
336
 
337
+ /**
338
+ *
339
+ * @param {Mesh} mesh
340
+ * @param {number} entity
341
+ */
342
+ visitComponent(mesh, entity) {
343
+ this.__update_entity(entity);
344
+ }
345
+
338
346
  update(timeDelta) {
339
347
  //process wait queue
340
348
  this.processWaiting();
341
349
 
342
- /**
343
- *
344
- * @type {MeshSystem}
345
- */
346
- const meshSystem = this.entityManager.getSystem(MeshSystem);
350
+ const em = this.entityManager;
347
351
 
348
- meshSystem.traverseVisible(this.visitVisibleMesh, this);
352
+ const ecd = em.dataset;
349
353
 
350
- }
351
- }
354
+ if (ecd === null) {
355
+ return;
356
+ }
352
357
 
353
- /**
354
- *
355
- * @param {AttachmentBinding} binding
356
- */
357
- function updateBinding(binding) {
358
- binding.update();
358
+ ecd.traverseComponents(Attachment, this.visitComponent, this);
359
+ }
359
360
  }