@woosh/meep-engine 2.33.24 → 2.33.25

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 (74) hide show
  1. package/core/bvh2/binary/IndexedBinaryBVH.js +1 -1
  2. package/core/bvh2/traversal/ThreeClippingPlaneComputingBVHVisitor.js +5 -1
  3. package/core/bvh2/traversal/__detailed_box_volume_intersection.js +22 -5
  4. package/core/collection/array/binarySearchHighIndex.js +1 -1
  5. package/core/collection/array/copyArray.js +2 -2
  6. package/core/geom/3d/normal/hemioct/unit_hemioct.spec.js +1 -1
  7. package/core/geom/3d/shape/AbstractShape3D.js +9 -0
  8. package/core/geom/3d/shape/CompositeShape.js +188 -8
  9. package/core/geom/3d/shape/TransformedShape3D.js +58 -2
  10. package/core/geom/3d/shape/UnitCubeShape3D.js +11 -0
  11. package/core/geom/3d/shape/UnitSphereShape3D.js +8 -0
  12. package/core/geom/3d/shape/util/shape_to_visual_entity.js +159 -0
  13. package/core/geom/random/randomPointInSphere.js +3 -2
  14. package/core/json/resolvePathByArray.js +2 -2
  15. package/{engine/graphics/render/forward_plus/materials → core/primitives/strings}/insert_after.js +3 -0
  16. package/core/primitives/strings/insert_after_or_replace.js +27 -0
  17. package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
  18. package/editor/view/ecs/EntityEditor.js +2 -2
  19. package/editor/view/ecs/components/particles/ParticleEmitterController.js +2 -2
  20. package/engine/EngineHarness.js +1 -0
  21. package/engine/animation/AnimationUtils.js +5 -5
  22. package/engine/ecs/EntityBuilder.js +25 -5
  23. package/engine/ecs/attachment/AttachmentBinding.js +8 -0
  24. package/engine/ecs/attachment/AttachmentSystem.js +4 -0
  25. package/engine/ecs/attachment/TransformAttachmentBinding.js +14 -44
  26. package/engine/ecs/components/Tag.js +27 -6
  27. package/engine/ecs/fow/FogOfWar.js +4 -0
  28. package/engine/ecs/fow/FogOfWarSystem.js +2 -0
  29. package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -0
  30. package/engine/ecs/system/AbstractContextSystem.js +1 -1
  31. package/engine/ecs/systems/TagSystem.js +17 -0
  32. package/engine/ecs/transform/Transform.js +19 -6
  33. package/engine/graphics/GraphicsEngine.js +11 -6
  34. package/engine/graphics/composit/CompositLayer.js +17 -4
  35. package/engine/graphics/composit/CompositingStages.js +8 -0
  36. package/engine/graphics/composit/LayerCompositer.js +35 -6
  37. package/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +11 -7
  38. package/engine/graphics/ecs/light/Light.js +2 -0
  39. package/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +5 -1
  40. package/engine/graphics/ecs/mesh-v2/DrawMode.js +5 -0
  41. package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +32 -18
  42. package/engine/graphics/particles/ParticleEmitterLibrary.js +3 -0
  43. package/engine/graphics/particles/ecs/{ParticleEmitterSystem2.js → ParticleEmitterSystem.js} +17 -9
  44. package/engine/graphics/particles/particular/engine/ParticularEngine.js +8 -2
  45. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +14 -25
  46. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js +5 -0
  47. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.js +90 -2
  48. package/engine/graphics/particles/particular/engine/emitter/ParticlePool.spec.js +7 -7
  49. package/engine/graphics/particles/particular/engine/renderers/billboard/BILLBOARD_PARTICLE_SPECIFICATION.js +15 -12
  50. package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +262 -51
  51. package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +80 -46
  52. package/engine/graphics/particles/particular/engine/shader/debugAtlas.js +14 -0
  53. package/engine/graphics/particles/particular/engine/utils/volume/AttributeValue.js +141 -0
  54. package/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +148 -54
  55. package/engine/graphics/particles/particular/engine/utils/volume/lut_to_sampler.js +27 -0
  56. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +542 -165
  57. package/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +12 -6
  58. package/engine/graphics/render/forward_plus/materials/FP_INJECTION_POINT_ACCUMULATION.js +1 -0
  59. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_ACCUMULATION.js +32 -0
  60. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_DECODE_PARS.js +51 -0
  61. package/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_PREAMBLE.js +25 -0
  62. package/engine/graphics/render/forward_plus/materials/fp_build_fragment_shader.js +31 -120
  63. package/engine/graphics/render/forward_plus/materials/fp_build_vertex_lighting_shared.js +35 -0
  64. package/engine/graphics/render/forward_plus/materials/fp_build_vertex_shader.js +4 -5
  65. package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +10 -3
  66. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +588 -53
  67. package/engine/graphics/render/forward_plus/prototypeLightManager.js +29 -4
  68. package/engine/graphics/shaders/TerrainShader.js +4 -5
  69. package/engine/graphics/util/composeMatrix4.js +33 -23
  70. package/engine/graphics/util/decompose_matrix_4_array.js +61 -0
  71. package/engine/intelligence/behavior/ecs/BehaviorComponent.js +30 -14
  72. package/engine/knowledge/database/StaticKnowledgeDataTable.js +6 -1
  73. package/engine/navigation/ecs/components/Path.js +0 -5
  74. package/package.json +1 -1
@@ -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
  }
@@ -298,7 +317,7 @@ function prepare_scene_0() {
298
317
 
299
318
  const bounds_size = 15;
300
319
 
301
- const light_radius = 5;
320
+ const light_radius = 2;
302
321
 
303
322
  for (let i = 0; i < 5000; i++) {
304
323
  const radius = randomFloatBetween(random, light_radius, light_radius);
@@ -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
  });
@@ -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
@@ -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.25",
8
8
  "dependencies": {
9
9
  "fast-levenshtein": "2.0.6",
10
10
  "opentype.js": "1.3.3",