@woosh/meep-engine 2.33.24 → 2.33.28

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 (126) hide show
  1. package/core/binary/BitSet.js +151 -167
  2. package/core/binary/BitSet.spec.js +99 -1
  3. package/core/binary/ValidatingBitSetWrapper.js +81 -0
  4. package/core/bvh2/aabb3/AABB3.js +3 -10
  5. package/core/bvh2/binary/IndexedBinaryBVH.js +1 -1
  6. package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
  7. package/core/bvh2/traversal/__detailed_box_volume_intersection.js +22 -5
  8. package/core/cache/Cache.d.ts +4 -2
  9. package/core/cache/Cache.js +5 -2
  10. package/core/collection/HashMap.d.ts +9 -2
  11. package/core/collection/HashSet.d.ts +7 -2
  12. package/core/collection/HashSet.js +7 -2
  13. package/core/collection/array/binarySearchHighIndex.js +1 -1
  14. package/core/collection/array/copyArray.js +2 -2
  15. package/core/collection/array/typed/typed_array_copy.js +1 -1
  16. package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +3 -3
  17. package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
  18. package/core/geom/3d/shape/AbstractShape3D.js +37 -1
  19. package/core/geom/3d/shape/TransformedShape3D.js +121 -10
  20. package/core/geom/3d/shape/TransformedShape3D.spec.js +33 -0
  21. package/core/geom/3d/shape/UnionShape3D.js +255 -0
  22. package/core/geom/3d/shape/UnitCubeShape3D.js +88 -0
  23. package/core/geom/3d/shape/UnitCubeShape3D.spec.js +42 -0
  24. package/core/geom/3d/shape/UnitSphereShape3D.js +39 -0
  25. package/core/geom/3d/shape/util/compute_signed_distance_gradient_by_sampling.js +48 -0
  26. package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
  27. package/core/geom/random/randomPointInSphere.js +3 -2
  28. package/core/json/resolvePathByArray.js +2 -2
  29. package/core/model/ObservedBoolean.d.ts +2 -0
  30. package/core/parser/simple/Token.d.ts +13 -0
  31. package/core/parser/simple/Token.js +61 -27
  32. package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
  33. package/core/primitives/strings/insert_after_or_replace.js +27 -0
  34. package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
  35. package/editor/tools/FoliagePaintTool.js +4 -4
  36. package/editor/view/ecs/EntityEditor.js +2 -2
  37. package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
  38. package/engine/EngineHarness.js +1 -0
  39. package/engine/animation/AnimationUtils.js +5 -5
  40. package/engine/asset/loaders/GLTFAssetLoader.js +52 -1
  41. package/engine/asset/loaders/image/ImageDecoderWorker.js +4 -3
  42. package/engine/asset/loaders/image/ImageRGBADataAsset.js +3 -2
  43. package/engine/asset/loaders/image/ImageRGBADataLoader.js +3 -3
  44. package/engine/asset/loaders/image/codec/NativeImageDecoder.js +2 -1
  45. package/engine/asset/loaders/image/png/PNG.js +113 -6
  46. package/engine/asset/loaders/image/png/PNGReader.js +5 -0
  47. package/engine/asset/loaders/material/bitmap2sampler_gl.js +1 -1
  48. package/engine/asset/loaders/material/computeImageBitmapEquality.js +6 -1
  49. package/engine/asset/loaders/material/computeTextureEquality.js +40 -49
  50. package/engine/ecs/EntityBuilder.js +25 -5
  51. package/engine/ecs/EntityComponentDataset.js +1 -1
  52. package/engine/ecs/attachment/AttachmentBinding.js +8 -0
  53. package/engine/ecs/attachment/AttachmentSystem.js +4 -0
  54. package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
  55. package/engine/ecs/components/Tag.js +27 -6
  56. package/engine/ecs/foliage/InstancedFoliage.js +277 -266
  57. package/engine/ecs/foliage/ecs/Foliage2System.js +7 -7
  58. package/engine/ecs/foliage/ecs/InstancedMeshComponent.js +37 -0
  59. package/engine/ecs/foliage/ecs/{Foliage2.js → InstancedMeshLayer.js} +3 -45
  60. package/engine/ecs/foliage/ecs/InstancedMeshSerializationAdapter.js +6 -5
  61. package/engine/ecs/foliage/ecs/InstancedMeshUtils.js +7 -6
  62. package/engine/ecs/fow/FogOfWar.js +4 -0
  63. package/engine/ecs/fow/FogOfWarSystem.js +2 -0
  64. package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
  65. package/engine/ecs/storage/binary/BinarySerializationRegistry.js +1 -1
  66. package/engine/ecs/system/AbstractContextSystem.js +1 -1
  67. package/engine/ecs/systems/TagSystem.js +17 -0
  68. package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +12 -16
  69. package/engine/ecs/transform/Transform.js +19 -6
  70. package/engine/graphics/GraphicsEngine.js +11 -6
  71. package/engine/graphics/composit/CompositLayer.js +17 -4
  72. package/engine/graphics/composit/CompositingStages.js +8 -0
  73. package/engine/graphics/composit/LayerCompositer.js +35 -6
  74. package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
  75. package/engine/graphics/ecs/light/Light.js +2 -0
  76. package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
  77. package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
  78. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
  79. package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +14 -72
  80. package/engine/graphics/geometry/instancing/rewriteMaterial.js +70 -0
  81. package/engine/graphics/material/manager/MaterialManager.js +2 -1
  82. package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +6 -4
  83. package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +0 -2
  84. package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
  85. package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
  86. package/engine/graphics/particles/particular/engine/ParticularEngine.js +8 -2
  87. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +14 -25
  88. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
  89. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +90 -2
  90. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +7 -7
  91. package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +15 -12
  92. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -51
  93. package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +81 -48
  94. package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
  95. package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
  96. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +148 -54
  97. package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
  98. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +544 -164
  99. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +15 -10
  100. package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
  101. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
  102. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
  103. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
  104. package/engine/graphics/render/forward_plus/materials/FPlusDebugMaterial.js +3 -3
  105. package/engine/graphics/render/forward_plus/materials/ForwardPlusThreeMaterial.js +1 -1
  106. package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
  107. package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
  108. package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
  109. package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
  110. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +588 -53
  111. package/engine/graphics/render/forward_plus/prototypeLightManager.js +31 -6
  112. package/engine/graphics/render/forward_plus/query/point_light_inside_volume.js +10 -9
  113. package/engine/graphics/shaders/TerrainShader.js +4 -5
  114. package/engine/graphics/shadows/ShadowMapRenderer.js +8 -2
  115. package/engine/graphics/texture/atlas/ManagedTextureAtlas.js +12 -1
  116. package/engine/graphics/texture/sampler/Sampler2D.js +3 -1
  117. package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +1 -1
  118. package/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js +66 -0
  119. package/engine/graphics/util/composeMatrix4.js +33 -23
  120. package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
  121. package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
  122. package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
  123. package/engine/navigation/ecs/components/Path.js +0 -5
  124. package/package.json +1 -1
  125. package/view/minimap/gl/MinimapWorldGL.js +12 -5
  126. package/core/geom/3d/shape/CompositeShape.js +0 -60
@@ -41,6 +41,7 @@ import { randomFloatBetween } from "../../../../core/math/random/randomFloatBetw
41
41
  import Signal from "../../../../core/events/signal/Signal.js";
42
42
  import SimplexNoise from "simplex-noise";
43
43
  import Stats from "three/examples/jsm/libs/stats.module.js";
44
+ import { threeUpdateTransform } from "../../util/threeUpdateTransform.js";
44
45
 
45
46
  const on_render = new Signal();
46
47
 
@@ -50,6 +51,7 @@ const camera = new PerspectiveCamera(30);
50
51
  camera.position.z = 1;
51
52
 
52
53
  camera.layers.enable(3);
54
+ camera.layers.enable(4);
53
55
  // camera.layers.enable(1);
54
56
 
55
57
  camera.near = 1;
@@ -69,6 +71,8 @@ window.lights = lm;
69
71
  const random = seededRandom(0);
70
72
 
71
73
  const scene = new Scene();
74
+ scene.matrixAutoUpdate = false;
75
+ scene.autoUpdate = false;
72
76
 
73
77
  const sphere_geometry = new OctahedronBufferGeometry(1, 2);
74
78
  const sphere_geometry_shell = makeHelperSphereGeometry(1);
@@ -139,6 +143,10 @@ function addKnot(position, scale, rotation) {
139
143
  group.add(mesh);
140
144
  group.add(outline);
141
145
 
146
+ group.matrixAutoUpdate = false;
147
+
148
+ threeUpdateTransform(group);
149
+
142
150
  scene.add(group);
143
151
  }
144
152
 
@@ -234,7 +242,10 @@ function addPointLight({
234
242
  const mesh_center_0 = new Mesh(sphere_geometry, new MeshBasicMaterial({
235
243
  color: color_uint
236
244
  }));
245
+ mesh_center_0.layers.disableAll();
246
+ mesh_center_0.layers.set(4);
237
247
  mesh_center_0.scale.setScalar(0.02);
248
+ mesh_center_0.matrixAutoUpdate = false;
238
249
 
239
250
  visual_group.add(mesh_center_0);
240
251
 
@@ -244,6 +255,9 @@ function addPointLight({
244
255
  opacity: 0.033
245
256
  }));
246
257
  mesh_center_1.scale.setScalar(0.1);
258
+ mesh_center_1.layers.disableAll();
259
+ mesh_center_1.layers.set(4);
260
+ mesh_center_1.matrixAutoUpdate = false;
247
261
 
248
262
  visual_group.add(mesh_center_1);
249
263
 
@@ -251,6 +265,9 @@ function addPointLight({
251
265
  visual_group.add(mesh);
252
266
  visual_group.position.set(p.x, p.y, p.z);
253
267
 
268
+ threeUpdateTransform(visual_group);
269
+ visual_group.matrixAutoUpdate = false;
270
+
254
271
  scene.add(visual_group);
255
272
 
256
273
  if (wander) {
@@ -277,6 +294,8 @@ function addPointLight({
277
294
  p.y,
278
295
  p.z,
279
296
  );
297
+
298
+ threeUpdateTransform(visual_group);
280
299
  });
281
300
  }
282
301
  }
@@ -313,12 +332,14 @@ function prepare_scene_0() {
313
332
  );
314
333
  }
315
334
 
335
+ const bounds_size_2 = 15;
336
+
316
337
  for (let i = 0; i < 500; i++) {
317
338
 
318
339
  addKnot([
319
- randomFloatBetween(random, -bounds_size, bounds_size),
320
- randomFloatBetween(random, -bounds_size, bounds_size),
321
- randomFloatBetween(random, -bounds_size, bounds_size)
340
+ randomFloatBetween(random, -bounds_size_2, bounds_size_2),
341
+ randomFloatBetween(random, -bounds_size_2, bounds_size_2),
342
+ randomFloatBetween(random, -bounds_size_2, bounds_size_2)
322
343
  ], 0.5, [
323
344
  randomFloatBetween(random, 0, Math.PI),
324
345
  randomFloatBetween(random, 0, Math.PI),
@@ -454,6 +475,8 @@ function addSponza() {
454
475
 
455
476
  });
456
477
 
478
+ threeUpdateTransform(m_0);
479
+
457
480
  scene.add(m_0);
458
481
 
459
482
  const m_1 = gltf.scene.clone(true);
@@ -466,6 +489,8 @@ function addSponza() {
466
489
 
467
490
  });
468
491
 
492
+ threeUpdateTransform(m_1);
493
+
469
494
  scene.add(m_1);
470
495
 
471
496
  });
@@ -599,7 +624,7 @@ fp_materials.forEach(m => {
599
624
 
600
625
  renderer.getSize(v2);
601
626
 
602
- m.uniforms.resolution.value.set(
627
+ m.uniforms.fp_resolution.value.set(
603
628
  v2.x * window.devicePixelRatio, v2.y * window.devicePixelRatio
604
629
  );
605
630
 
@@ -668,7 +693,7 @@ function animate() {
668
693
  m.uniforms.fp_f_camera_far.value = camera.far;
669
694
 
670
695
 
671
- m.uniforms.resolution.value.set(scratch_v2.x, scratch_v2.y);
696
+ m.uniforms.fp_resolution.value.set(scratch_v2.x, scratch_v2.y);
672
697
  });
673
698
 
674
699
  lightClusterWidget.update();
@@ -735,7 +760,7 @@ function draw_camera_view_planes() {
735
760
  });
736
761
  }
737
762
 
738
- prepare_scene_4();
763
+ prepare_scene_0();
739
764
  animate();
740
765
 
741
766
  // draw_camera_view_planes();
@@ -42,21 +42,22 @@ export function point_light_inside_volume(
42
42
  if (distance < 0) {
43
43
  // center of the sphere is below the plane
44
44
 
45
- if (distance < -radius) {
46
- // sphere is entirely below the plane
45
+ if (distance >= -radius) {
47
46
 
48
- // query_bvh_frustum_from_objects.rejection_sphere_count++;
47
+ // sphere intersects the plane
49
48
 
50
- return false;
51
- }
49
+ outside_plane_count++;
52
50
 
53
- // sphere intersects the plane
51
+ const plane_bit_mask = 1 << j;
54
52
 
55
- outside_plane_count++;
53
+ outside_plane_bitfield |= plane_bit_mask;
54
+ } else {
55
+ // sphere is entirely below the plane
56
56
 
57
- const plane_bit_mask = 1 << j;
57
+ // query_bvh_frustum_from_objects.rejection_sphere_count++;
58
58
 
59
- outside_plane_bitfield |= plane_bit_mask;
59
+ return false;
60
+ }
60
61
  }
61
62
 
62
63
  }
@@ -121,7 +121,6 @@ function fragment() {
121
121
  uniform float opacity;
122
122
 
123
123
  varying vec3 vViewPosition;
124
-
125
124
 
126
125
 
127
126
  #include <common>
@@ -364,10 +363,10 @@ function fragment() {
364
363
 
365
364
  vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
366
365
 
367
- pc_fragColor = vec4( outgoingLight, diffuseColor.a );
366
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );
368
367
 
369
368
  #if defined( TONE_MAPPING )
370
- pc_fragColor.rgb = toneMapping( pc_fragColor.rgb );
369
+ gl_FragColor.rgb = toneMapping( pc_fragColor.rgb );
371
370
  #endif
372
371
 
373
372
  //encode fragment
@@ -378,12 +377,12 @@ function fragment() {
378
377
  #else
379
378
  float fogFactor = smoothstep( fogNear, fogFar, fogDepth );
380
379
  #endif
381
- pc_fragColor.rgb = mix( pc_fragColor.rgb, fogColor, fogFactor );
380
+ gl_FragColor.rgb = mix( pc_fragColor.rgb, fogColor, fogFactor );
382
381
  #endif
383
382
 
384
383
  #ifdef PREMULTIPLIED_ALPHA
385
384
  // Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.
386
- pc_fragColor.rgb *= pc_fragColor.a;
385
+ gl_FragColor.rgb *= pc_fragColor.a;
387
386
  #endif
388
387
 
389
388
  #ifdef DITHERING
@@ -173,13 +173,19 @@ export class ShadowMapRenderer {
173
173
 
174
174
  if (shadow.map === null) {
175
175
 
176
- const pars = { format: RGBAFormat };
176
+ const pars = {
177
+ format: RGBAFormat,
178
+ scissorTest: false,
179
+ stencilBuffer: false
180
+ };
177
181
 
178
182
  if (!shadow.isPointLightShadow && renderer.shadowMap.type === VSMShadowMap) {
179
183
  pars.minFilter = LinearFilter;
180
184
  pars.magFilter = LinearFilter;
181
185
 
182
- shadow.mapPass = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);
186
+ shadow.mapPass = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, Object.assign({
187
+ depthBuffer: false
188
+ }, pars));
183
189
 
184
190
  } else {
185
191
  pars.minFilter = NearestFilter;
@@ -6,6 +6,7 @@ import { GameAssetType } from "../../../asset/GameAssetType.js";
6
6
  import { HashMap } from "../../../../core/collection/HashMap.js";
7
7
  import { strictEquals } from "../../../../core/function/Functions.js";
8
8
  import { computeStringHash } from "../../../../core/primitives/strings/computeStringHash.js";
9
+ import { copy_Sampler2D_channel_data } from "../sampler/copy_Sampler2D_channel_data.js";
9
10
 
10
11
  const CACHE_SIZE = 4194304;
11
12
 
@@ -139,10 +140,20 @@ export class ManagedAtlas {
139
140
 
140
141
  const image = asset.create();
141
142
 
143
+ const source = new Sampler2D(image.data, image.itemSize, image.width, image.height);
142
144
  //assert.equal(atlas.patches.filter(p => p.sampler.data === image.data).length, 0, "Atlas already contains this asset data");
143
145
 
144
146
  //build sampler
145
- const sampler = new Sampler2D(image.data, 4, image.width, image.height);
147
+ let sampler;
148
+
149
+ if (source.itemSize !== 4) {
150
+ // source image is not in RGBA layout, resample
151
+ sampler = Sampler2D.uint8(4, image.width, image.height);
152
+ copy_Sampler2D_channel_data(source, sampler)
153
+ } else {
154
+ sampler = source;
155
+ }
156
+
146
157
  const patch = atlas.add(sampler);
147
158
 
148
159
  //record active patch
@@ -164,11 +164,13 @@ export function Sampler2D(data = [], itemSize = 1, width = 0, height = 0) {
164
164
  * @type {Number}
165
165
  */
166
166
  this.height = height;
167
+
167
168
  /**
168
- *
169
+ * Number of channels
169
170
  * @type {Number}
170
171
  */
171
172
  this.itemSize = itemSize;
173
+
172
174
  /**
173
175
  *
174
176
  * @type {Array<number>|Uint8Array|Uint16Array|Int8Array|Float32Array|Float64Array}
@@ -17,7 +17,7 @@ const DEFAULT_TEXTURE_HEIGHT = 512;
17
17
  * @return {Sampler2D}
18
18
  */
19
19
  export function convertTexture2Sampler2D(texture, width, height, flipY = true) {
20
-
20
+ // TODO take channel count into account
21
21
 
22
22
  if (width === undefined || height === undefined) {
23
23
 
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Allows copying data from one sampler to another with unequal number of channels (a.itemSize !== b.itemSize)
3
+ * @example convert RGBA to RGB or R to RGB
4
+ * @param {Sampler2D} source
5
+ * @param {Sampler2D} destination
6
+ */
7
+ export function copy_Sampler2D_channel_data(source, destination) {
8
+ if (source.width !== destination.width || source.height !== destination.height) {
9
+ throw new Error('Source and destination dimensions do not match');
10
+ }
11
+
12
+ const source_item_size = source.itemSize;
13
+ const destination_item_size = destination.itemSize;
14
+
15
+ const pixel_count = source.width * source.height;
16
+
17
+ const destination_data = destination.data;
18
+ const source_data = source.data;
19
+
20
+ let i, j;
21
+
22
+ if (source_item_size === destination_item_size) {
23
+ // just copy data chunk
24
+ destination_data.set(source_data);
25
+
26
+ } else if (source_item_size > destination_item_size) {
27
+
28
+ for (i = 0; i < pixel_count; i++) {
29
+ const source_sample_offset = i * source_item_size;
30
+ const destination_sample_offset = i * destination_item_size;
31
+
32
+ for (j = 0; j < destination_item_size; j++) {
33
+ destination_data[destination_sample_offset + j] = source_data[source_sample_offset + j];
34
+ }
35
+ }
36
+
37
+ } else if (source_item_size === 3 && destination_item_size === 4) {
38
+ // RGB -> RGBA
39
+ for (i = 0; i < pixel_count; i++) {
40
+ const i3 = i * 3;
41
+ const i4 = i * 4;
42
+
43
+ destination_data[i4] = source_data[i3];
44
+ destination_data[i4 + 1] = source_data[i3 + 1];
45
+ destination_data[i4 + 2] = source_data[i3 + 2];
46
+
47
+ destination_data[i4] = 255; // fill alpha
48
+ }
49
+ } else if (source_item_size === 2 && destination_item_size === 4) {
50
+ //RA -> RGBA
51
+ for (i = 0; i < pixel_count; i++) {
52
+ const i2 = i * 2;
53
+ const i4 = i * 4;
54
+
55
+ const r = source_data[i2];
56
+
57
+ destination_data[i4] = r;
58
+ destination_data[i4 + 1] = r;
59
+ destination_data[i4 + 2] = r;
60
+
61
+ destination_data[i4 + 3] = source_data[i2 + 1]; // fill alpha
62
+ }
63
+ } else {
64
+ throw new Error('Unsupported channel layout combination');
65
+ }
66
+ }
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  *
3
- * @param {Matrix4} result
3
+ * @param {number[]|Float32Array|mat4} result
4
4
  * @param {Vector3} position
5
5
  * @param {Quaternion} rotation
6
6
  * @param {Vector3} scale
7
7
  */
8
- export function composeMatrix4(result, position, rotation, scale) {
9
- const te = result.elements;
10
-
8
+ export function compose_matrix4_array(result, position, rotation, scale) {
11
9
  const x = rotation.x;
12
10
  const y = rotation.y;
13
11
  const z = rotation.z;
@@ -33,23 +31,35 @@ export function composeMatrix4(result, position, rotation, scale) {
33
31
  const sy = scale.y;
34
32
  const sz = scale.z;
35
33
 
36
- te[0] = (1 - (yy + zz)) * sx;
37
- te[1] = (xy + wz) * sx;
38
- te[2] = (xz - wy) * sx;
39
- te[3] = 0;
40
-
41
- te[4] = (xy - wz) * sy;
42
- te[5] = (1 - (xx + zz)) * sy;
43
- te[6] = (yz + wx) * sy;
44
- te[7] = 0;
45
-
46
- te[8] = (xz + wy) * sz;
47
- te[9] = (yz - wx) * sz;
48
- te[10] = (1 - (xx + yy)) * sz;
49
- te[11] = 0;
50
-
51
- te[12] = position.x;
52
- te[13] = position.y;
53
- te[14] = position.z;
54
- te[15] = 1;
34
+ result[0] = (1 - (yy + zz)) * sx;
35
+ result[1] = (xy + wz) * sx;
36
+ result[2] = (xz - wy) * sx;
37
+ result[3] = 0;
38
+
39
+ result[4] = (xy - wz) * sy;
40
+ result[5] = (1 - (xx + zz)) * sy;
41
+ result[6] = (yz + wx) * sy;
42
+ result[7] = 0;
43
+
44
+ result[8] = (xz + wy) * sz;
45
+ result[9] = (yz - wx) * sz;
46
+ result[10] = (1 - (xx + yy)) * sz;
47
+ result[11] = 0;
48
+
49
+ result[12] = position.x;
50
+ result[13] = position.y;
51
+ result[14] = position.z;
52
+ result[15] = 1;
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @param {Matrix4} result
58
+ * @param {Vector3} position
59
+ * @param {Quaternion} rotation
60
+ * @param {Vector3} scale
61
+ */
62
+ export function composeMatrix4(result, position, rotation, scale) {
63
+ const te = result.elements;
64
+ compose_matrix4_array(te, position, rotation, scale);
55
65
  }
@@ -0,0 +1,61 @@
1
+ /**
2
+ *
3
+ * @param {number[]} m
4
+ * @param {Vector3} position
5
+ * @param {Quaternion} rotation
6
+ * @param {Vector3} scale
7
+ */
8
+ export function decompose_matrix_4_array(m, position, rotation, scale) {
9
+ const m11 = m[0];
10
+ const m12 = m[1];
11
+ const m13 = m[2];
12
+
13
+ const m21 = m[4];
14
+ const m22 = m[5];
15
+ const m23 = m[6];
16
+
17
+ const m31 = m[8];
18
+ const m32 = m[9];
19
+ const m33 = m[10];
20
+
21
+ const scale_x = Math.hypot(m11, m12, m13);
22
+ const scale_y = Math.hypot(m21, m22, m23);
23
+ const scale_z = Math.hypot(m31, m32, m33);
24
+
25
+ // extract rotation
26
+ const is1 = 1 / scale_x;
27
+ const is2 = 1 / scale_y;
28
+ const is3 = 1 / scale_z;
29
+
30
+ const sm11 = m11 * is1;
31
+ const sm12 = m12 * is1;
32
+ const sm13 = m13 * is1;
33
+
34
+ const sm21 = m21 * is2;
35
+ const sm22 = m22 * is2;
36
+ const sm23 = m23 * is2;
37
+
38
+ const sm31 = m31 * is3;
39
+ const sm32 = m32 * is3;
40
+ const sm33 = m33 * is3;
41
+
42
+ // write out results
43
+
44
+ position.set(
45
+ m[12],
46
+ m[13],
47
+ m[14]
48
+ );
49
+
50
+ scale.set(
51
+ scale_x,
52
+ scale_y,
53
+ scale_z
54
+ );
55
+
56
+ rotation.__setFromRotationMatrix(
57
+ sm11, sm21, sm31,
58
+ sm12, sm22, sm32,
59
+ sm13, sm23, sm33
60
+ );
61
+ }
@@ -1,5 +1,7 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
2
  import { ClockChannelType } from "./ClockChannelType.js";
3
+ import { RepeatBehavior } from "../decorator/RepeatBehavior.js";
4
+ import { ActionBehavior } from "../primitive/ActionBehavior.js";
3
5
 
4
6
  export const BehaviorComponentFlag = {
5
7
  AllowSleep: 1
@@ -25,24 +27,38 @@ export class BehaviorComponent {
25
27
  */
26
28
  this.flags = 0;
27
29
  }
28
- }
29
30
 
30
- /**
31
- *
32
- * @param {Behavior} b
33
- * @returns {BehaviorComponent}
34
- */
35
- BehaviorComponent.fromOne = function (b) {
36
- assert.notEqual(b, undefined, 'behavior is undefined');
37
- assert.notEqual(b, null, 'behavior is null');
38
- assert.equal(b.isBehavior, true, 'b.isBehavior !== true');
39
31
 
40
- const result = new BehaviorComponent();
32
+ /**
33
+ *
34
+ * @param {function} f
35
+ * @param {*} [thisArg]
36
+ * @returns {BehaviorComponent}
37
+ */
38
+ static looping_function(f, thisArg) {
39
+ return BehaviorComponent.fromOne(RepeatBehavior.from(
40
+ new ActionBehavior(f, thisArg)
41
+ ));
42
+ }
41
43
 
42
- result.list.push(b);
44
+ /**
45
+ *
46
+ * @param {Behavior} b
47
+ * @returns {BehaviorComponent}
48
+ */
49
+ static fromOne(b) {
50
+ assert.notEqual(b, undefined, 'behavior is undefined');
51
+ assert.notEqual(b, null, 'behavior is null');
52
+ assert.equal(b.isBehavior, true, 'b.isBehavior !== true');
43
53
 
44
- return result;
45
- };
54
+ const result = new BehaviorComponent();
55
+
56
+ result.list.push(b);
57
+
58
+ return result;
59
+
60
+ }
61
+ }
46
62
 
47
63
  /**
48
64
  * @readonly
@@ -222,7 +222,7 @@ export class StaticKnowledgeDataTable {
222
222
  } catch (e) {
223
223
 
224
224
  let id;
225
- //attempt to extract talent ID
225
+ //attempt to extract item ID
226
226
  try {
227
227
  id = datum.id;
228
228
  } catch (e) {
@@ -243,6 +243,11 @@ export class StaticKnowledgeDataTable {
243
243
  return;
244
244
  }
245
245
 
246
+ if (this.contains(id)) {
247
+ console.error(`Duplicate id '${id}'`);
248
+ return;
249
+ }
250
+
246
251
  this.__json.set(id, datum);
247
252
 
248
253
  const added = this.add(element);
@@ -270,11 +270,6 @@ class Path {
270
270
  copy(other) {
271
271
  this.__data.copy(other.__data);
272
272
  this.interpolation = other.interpolation;
273
-
274
- // Traversal variables
275
- this.markerOffset = other.markerOffset;
276
- this.markerIndex = other.markerIndex;
277
- this.markerDistanceToNext = other.markerDistanceToNext;
278
273
  }
279
274
 
280
275
  /**
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.24",
7
+ "version": "2.33.28",
8
8
  "dependencies": {
9
9
  "fast-levenshtein": "2.0.6",
10
10
  "opentype.js": "1.3.3",
@@ -171,13 +171,20 @@ export class MinimapWorldGL {
171
171
  }
172
172
 
173
173
  update() {
174
- this.layers.forEach(o => {
175
- o.update(this.camera);
176
- if (o.needsRender) {
174
+ const layers = this.layers;
175
+ const layer_count = layers.length;
176
+
177
+ for (let i = 0; i < layer_count; i++) {
178
+ const layer = layers[i];
179
+
180
+ layer.update(this.camera);
181
+
182
+ if (layer.needsRender) {
177
183
  this.renderNeedsUpdate = true;
178
- o.needsRender = false;
184
+ layer.needsRender = false;
179
185
  }
180
- });
186
+
187
+ }
181
188
 
182
189
  if (this.renderNeedsUpdate) {
183
190
  this.render();
@@ -1,60 +0,0 @@
1
- import { AbstractShape3D } from "./AbstractShape3D.js";
2
- import { weightedRandomFromArray } from "../../../collection/array/weightedRandomFromArray.js";
3
-
4
-
5
- const scratch_array = [];
6
-
7
- /**
8
- *
9
- * @param {AbstractShape3D} shape
10
- * @return {number}
11
- */
12
- function getVolume(shape) {
13
- return shape.volume;
14
- }
15
-
16
- export class CompositeShape extends AbstractShape3D {
17
- constructor() {
18
- super();
19
-
20
- /**
21
- *
22
- * @type {AbstractShape3D[]}
23
- */
24
- this.children = [];
25
- }
26
-
27
- get volume() {
28
- let r = 0;
29
-
30
- const children = this.children;
31
- const child_count = children.length;
32
- for (let i = 0; i < child_count; i++) {
33
- const child = children[i];
34
-
35
- r += child.volume;
36
- }
37
-
38
- return r;
39
- }
40
-
41
- get surface_area(){
42
- let r = 0;
43
-
44
- const children = this.children;
45
- const child_count = children.length;
46
- for (let i = 0; i < child_count; i++) {
47
- const child = children[i];
48
-
49
- r += child.surface_area;
50
- }
51
-
52
- return r;
53
- }
54
-
55
- sample_random_point_in_volume(result, result_offset, random) {
56
- const child = weightedRandomFromArray(this.children, random, getVolume);
57
-
58
- return child.sample_random_point_in_volume(result, result_offset, random);
59
- }
60
- }