@woosh/meep-engine 2.96.0 → 2.98.0

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 (141) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +892 -687
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +892 -687
  5. package/package.json +1 -1
  6. package/src/core/binary/BitSet.d.ts +2 -2
  7. package/src/core/binary/BitSet.d.ts.map +1 -1
  8. package/src/core/binary/BitSet.js +8 -5
  9. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +1 -1
  10. package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +1 -1
  11. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts.map +1 -1
  12. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js +3 -2
  13. package/src/core/collection/array/arrayQuickSort.js +2 -2
  14. package/src/core/collection/array/array_compute_max.d.ts +9 -0
  15. package/src/core/collection/array/array_compute_max.d.ts.map +1 -0
  16. package/src/core/collection/array/{computeArrayMax.js → array_compute_max.js} +1 -1
  17. package/src/core/collection/array/array_compute_min.d.ts +9 -0
  18. package/src/core/collection/array/array_compute_min.d.ts.map +1 -0
  19. package/src/core/collection/array/{computeArrayMin.js → array_compute_min.js} +1 -1
  20. package/src/core/collection/array/array_compute_min_max.d.ts.map +1 -1
  21. package/src/core/collection/array/array_compute_min_max.js +1 -0
  22. package/src/core/collection/array/array_swap.d.ts.map +1 -1
  23. package/src/core/collection/array/array_swap.js +11 -8
  24. package/src/core/collection/array/array_swap_one.d.ts +8 -0
  25. package/src/core/collection/array/array_swap_one.d.ts.map +1 -0
  26. package/src/core/collection/array/{arraySwapElements.js → array_swap_one.js} +1 -1
  27. package/src/core/collection/array/iterator/AbstractArrayIterator.d.ts.map +1 -0
  28. package/src/core/collection/array/iterator/ArrayIteratorRandom.d.ts.map +1 -0
  29. package/src/core/collection/array/{ArrayIteratorRandom.js → iterator/ArrayIteratorRandom.js} +2 -2
  30. package/src/core/collection/array/iterator/ArrayIteratorSequential.d.ts.map +1 -0
  31. package/src/core/collection/array/randomizeArrayElementOrder.js +2 -2
  32. package/src/core/collection/map/HashMap.js +10 -10
  33. package/src/core/collection/map/ObservedMap.d.ts +7 -4
  34. package/src/core/collection/map/ObservedMap.d.ts.map +1 -1
  35. package/src/core/collection/map/ObservedMap.js +4 -1
  36. package/src/core/collection/queue/Deque.d.ts.map +1 -1
  37. package/src/core/collection/queue/Deque.js +82 -36
  38. package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +10 -10
  39. package/src/core/graph/v2/Graph.d.ts.map +1 -1
  40. package/src/core/graph/v2/Graph.js +9 -0
  41. package/src/core/math/spline/computeNonuniformCaltmullRomSplineDerivative.d.ts +16 -0
  42. package/src/core/math/spline/computeNonuniformCaltmullRomSplineDerivative.d.ts.map +1 -0
  43. package/src/core/math/spline/computeNonuniformCaltmullRomSplineDerivative.js +90 -0
  44. package/src/core/parser/simple/ParserError.d.ts +11 -6
  45. package/src/core/parser/simple/ParserError.d.ts.map +1 -1
  46. package/src/core/parser/simple/ParserError.js +51 -4
  47. package/src/core/parser/simple/Token.d.ts.map +1 -1
  48. package/src/core/parser/simple/Token.js +8 -2
  49. package/src/core/parser/simple/TokenType.d.ts +1 -5
  50. package/src/core/parser/simple/TokenType.d.ts.map +1 -1
  51. package/src/core/parser/simple/TokenType.js +1 -1
  52. package/src/core/parser/simple/readBooleanToken.d.ts.map +1 -1
  53. package/src/core/parser/simple/readBooleanToken.js +6 -1
  54. package/src/core/parser/simple/readHexToken.d.ts.map +1 -1
  55. package/src/core/parser/simple/readHexToken.js +7 -2
  56. package/src/core/parser/simple/readIdentifierToken.d.ts.map +1 -1
  57. package/src/core/parser/simple/readIdentifierToken.js +6 -1
  58. package/src/core/parser/simple/readLiteralToken.d.ts.map +1 -1
  59. package/src/core/parser/simple/readLiteralToken.js +8 -3
  60. package/src/core/parser/simple/readNumberToken.d.ts.map +1 -1
  61. package/src/core/parser/simple/readNumberToken.js +7 -2
  62. package/src/core/parser/simple/readReferenceToken.d.ts.map +1 -1
  63. package/src/core/parser/simple/readReferenceToken.js +6 -1
  64. package/src/core/parser/simple/readStringToken.d.ts.map +1 -1
  65. package/src/core/parser/simple/readStringToken.js +6 -1
  66. package/src/core/parser/simple/readUnsignedIntegerToken.d.ts.map +1 -1
  67. package/src/core/parser/simple/readUnsignedIntegerToken.js +7 -2
  68. package/src/core/parser/simple/skipWhitespace.d.ts.map +1 -1
  69. package/src/core/parser/simple/skipWhitespace.js +8 -0
  70. package/src/core/primitives/strings/string_jaro_distance.d.ts +10 -0
  71. package/src/core/primitives/strings/string_jaro_distance.d.ts.map +1 -0
  72. package/src/core/primitives/strings/string_jaro_distance.js +127 -0
  73. package/src/core/primitives/strings/string_jaro_winkler.d.ts.map +1 -1
  74. package/src/core/primitives/strings/string_jaro_winkler.js +5 -105
  75. package/src/core/primitives/strings/string_repeat.d.ts +9 -0
  76. package/src/core/primitives/strings/string_repeat.d.ts.map +1 -0
  77. package/src/core/primitives/strings/string_repeat.js +26 -0
  78. package/src/engine/asset/AssetManager.d.ts.map +1 -1
  79. package/src/engine/development/performance/RingBufferMetric.d.ts.map +1 -1
  80. package/src/engine/development/performance/RingBufferMetric.js +5 -5
  81. package/src/engine/ecs/terrain/ecs/BuildLightTexture.d.ts.map +1 -1
  82. package/src/engine/ecs/terrain/ecs/BuildLightTexture.js +15 -22
  83. package/src/engine/graphics/ecs/camera/Camera.d.ts.map +1 -1
  84. package/src/engine/graphics/ecs/camera/Camera.js +23 -16
  85. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +142 -10
  86. package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.d.ts.map +1 -1
  87. package/src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js +9 -9
  88. package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.d.ts.map +1 -1
  89. package/src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js +173 -23
  90. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +16 -2
  91. package/src/engine/graphics/filter/ImageFilter.d.ts +2 -2
  92. package/src/engine/graphics/filter/ImageFilter.d.ts.map +1 -1
  93. package/src/engine/graphics/filter/ImageFilter.js +3 -3
  94. package/src/engine/graphics/render/RendererPool.d.ts +14 -1
  95. package/src/engine/graphics/render/RendererPool.d.ts.map +1 -1
  96. package/src/engine/graphics/render/RendererPool.js +43 -1
  97. package/src/engine/graphics/render/forward_plus/LightManager.js +2 -2
  98. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +2 -1
  99. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
  100. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +23 -50
  101. package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts +9 -0
  102. package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts.map +1 -1
  103. package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.js +53 -3
  104. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +3 -3
  105. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts +1 -1
  106. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.d.ts.map +1 -1
  107. package/src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +42 -36
  108. package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.d.ts +3 -0
  109. package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.d.ts.map +1 -0
  110. package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler.js +34 -0
  111. package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler_grid.d.ts +10 -0
  112. package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler_grid.d.ts.map +1 -0
  113. package/src/engine/graphics/texture/sampler/debug/debug_draw_sampler_grid.js +89 -0
  114. package/src/engine/graphics/texture/sampler/debug/prototypeSamplerFiltering.d.ts.map +1 -0
  115. package/src/engine/graphics/texture/sampler/{prototypeSamplerFiltering.js → debug/prototypeSamplerFiltering.js} +105 -113
  116. package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts.map +1 -1
  117. package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +8 -8
  118. package/src/generation/markers/GridActionRuleSet.d.ts.map +1 -1
  119. package/src/generation/markers/GridActionRuleSet.js +5 -5
  120. package/src/core/binary/byteArrayToString.d.ts +0 -9
  121. package/src/core/binary/byteArrayToString.d.ts.map +0 -1
  122. package/src/core/binary/byteArrayToString.js +0 -28
  123. package/src/core/collection/array/AbstractArrayIterator.d.ts.map +0 -1
  124. package/src/core/collection/array/ArrayIteratorRandom.d.ts.map +0 -1
  125. package/src/core/collection/array/ArrayIteratorSequential.d.ts.map +0 -1
  126. package/src/core/collection/array/arrayPickMinElement.d.ts +0 -8
  127. package/src/core/collection/array/arrayPickMinElement.d.ts.map +0 -1
  128. package/src/core/collection/array/arrayPickMinElement.js +0 -43
  129. package/src/core/collection/array/arraySwapElements.d.ts +0 -8
  130. package/src/core/collection/array/arraySwapElements.d.ts.map +0 -1
  131. package/src/core/collection/array/computeArrayMax.d.ts +0 -9
  132. package/src/core/collection/array/computeArrayMax.d.ts.map +0 -1
  133. package/src/core/collection/array/computeArrayMin.d.ts +0 -9
  134. package/src/core/collection/array/computeArrayMin.d.ts.map +0 -1
  135. package/src/engine/graphics/texture/sampler/prototypeSamplerFiltering.d.ts.map +0 -1
  136. /package/src/core/collection/array/{AbstractArrayIterator.d.ts → iterator/AbstractArrayIterator.d.ts} +0 -0
  137. /package/src/core/collection/array/{AbstractArrayIterator.js → iterator/AbstractArrayIterator.js} +0 -0
  138. /package/src/core/collection/array/{ArrayIteratorRandom.d.ts → iterator/ArrayIteratorRandom.d.ts} +0 -0
  139. /package/src/core/collection/array/{ArrayIteratorSequential.d.ts → iterator/ArrayIteratorSequential.d.ts} +0 -0
  140. /package/src/core/collection/array/{ArrayIteratorSequential.js → iterator/ArrayIteratorSequential.js} +0 -0
  141. /package/src/engine/graphics/texture/sampler/{prototypeSamplerFiltering.d.ts → debug/prototypeSamplerFiltering.d.ts} +0 -0
@@ -3,18 +3,18 @@
3
3
  */
4
4
 
5
5
 
6
- import {Frustum} from 'three';
7
- import {assert} from "../../../../core/assert.js";
8
- import {plane3_compute_ray_intersection} from "../../../../core/geom/3d/plane/plane3_compute_ray_intersection.js";
9
- import {v3_distance_above_plane} from "../../../../core/geom/vec3/v3_distance_above_plane.js";
6
+ import { Frustum } from 'three';
7
+ import { assert } from "../../../../core/assert.js";
8
+ import { plane3_compute_ray_intersection } from "../../../../core/geom/3d/plane/plane3_compute_ray_intersection.js";
9
+ import { v3_distance_above_plane } from "../../../../core/geom/vec3/v3_distance_above_plane.js";
10
10
  import Vector1 from "../../../../core/geom/Vector1.js";
11
11
  import Vector3 from "../../../../core/geom/Vector3.js";
12
12
  import ObservedBoolean from "../../../../core/model/ObservedBoolean.js";
13
13
  import ObservedEnum from "../../../../core/model/ObservedEnum.js";
14
- import {frustum_from_camera} from "./frustum_from_camera.js";
15
- import {invertQuaternionOrientation} from "./InvertQuaternionOrientation.js";
16
- import {ProjectionType} from "./ProjectionType.js";
17
- import {unprojectPoint} from "./unprojectPoint.js";
14
+ import { frustum_from_camera } from "./frustum_from_camera.js";
15
+ import { invertQuaternionOrientation } from "./InvertQuaternionOrientation.js";
16
+ import { ProjectionType } from "./ProjectionType.js";
17
+ import { unprojectPoint } from "./unprojectPoint.js";
18
18
 
19
19
  /**
20
20
  * @class
@@ -164,10 +164,14 @@ export class Camera {
164
164
  * @param {Camera|THREE.PerspectiveCamera|THREE.OrthographicCamera} camera
165
165
  * @param {number} x
166
166
  * @param {number} y
167
- * @param {Vector3} source
168
- * @param {Vector3} direction
167
+ * @param {Vector3} out_source
168
+ * @param {Vector3} out_direction
169
169
  */
170
- static projectRay(camera, x, y, source, direction) {
170
+ static projectRay(
171
+ camera,
172
+ x, y,
173
+ out_source, out_direction
174
+ ) {
171
175
  assert.defined(camera, "camera");
172
176
  assert.defined(camera.position, "Camera.position");
173
177
 
@@ -182,7 +186,10 @@ export class Camera {
182
186
  // assert.ok(y <= 1, `Y(=${y}) must be less than or equal to 1.0, not a clip-space coordinate`);
183
187
 
184
188
  if (camera.isPerspectiveCamera || camera.isOrthographicCamera) {
185
- scratch_v3_1.setFromMatrixPosition(camera.matrixWorld.elements);
189
+ const m4_world = camera.matrixWorld.elements;
190
+ const m4_projection_inverse = camera.projectionMatrixInverse.elements;
191
+
192
+ scratch_v3_1.setFromMatrixPosition(m4_world);
186
193
 
187
194
  scratch_v3_0.set(x, y, 0.5);
188
195
 
@@ -191,16 +198,16 @@ export class Camera {
191
198
  unprojectPoint(
192
199
  scratch_v3_0,
193
200
  scratch_v3_0,
194
- camera.projectionMatrixInverse.elements,
195
- camera.matrixWorld.elements
201
+ m4_projection_inverse,
202
+ m4_world
196
203
  );
197
204
 
198
205
  //get direction
199
206
  scratch_v3_0.sub(scratch_v3_1);
200
207
  scratch_v3_0.normalize();
201
208
 
202
- source.copy(scratch_v3_1);
203
- direction.copy(scratch_v3_0);
209
+ out_source.copy(scratch_v3_1);
210
+ out_direction.copy(scratch_v3_0);
204
211
 
205
212
  } else {
206
213
  throw new Error('Unsupported camera type');
@@ -1,3 +1,4 @@
1
+ import { MeshStandardMaterial, OctahedronBufferGeometry } from "three";
1
2
  import '../../../../../../../../css/game.scss';
2
3
  import FacingDirectionSystem from "../../../../../../model/game/ecs/system/FacingDirectionSystem.js";
3
4
  import { makeEngineOptionsModel } from "../../../../../../model/game/options/makeEngineOptionsModel.js";
@@ -47,6 +48,7 @@ import Highlight from "../highlight/Highlight.js";
47
48
  import MeshHighlightSystem from "../highlight/system/MeshHighlightSystem.js";
48
49
  import { ShadedGeometryHighlightSystem } from "../highlight/system/ShadedGeometryHighlightSystem.js";
49
50
  import LightSystem from "../light/LightSystem.js";
51
+ import { ShadedGeometry } from "../mesh-v2/ShadedGeometry.js";
50
52
  import { ShadedGeometrySystem } from "../mesh-v2/ShadedGeometrySystem.js";
51
53
  import Mesh from "../mesh/Mesh.js";
52
54
  import { MeshSystem } from "../mesh/MeshSystem.js";
@@ -412,7 +414,35 @@ function makePath({
412
414
  return new Entity()
413
415
  .add(_p)
414
416
  .add(pathDisplay)
415
- .add(Highlight.fromOne(0, 1, 1, 1));
417
+ // .add(Highlight.fromOne(0, 1, 1, 1));
418
+
419
+ }
420
+
421
+ /**
422
+ *
423
+ * @param {Path} path
424
+ * @param {EntityComponentDataset} ecd
425
+ */
426
+ function drawControlPoints(path, ecd) {
427
+
428
+ const point_count = path.getPointCount();
429
+
430
+ const geo = new OctahedronBufferGeometry(1, 3);
431
+ const mat = new MeshStandardMaterial({});
432
+
433
+ for (let i = 0; i < point_count; i++) {
434
+ const t = new Transform();
435
+
436
+ t.scale.setScalar(0.4);
437
+
438
+ path.getPosition(i, t.position);
439
+
440
+ new Entity()
441
+ .add(t)
442
+ .add(ShadedGeometry.from(geo, mat))
443
+ .build(ecd)
444
+ }
445
+
416
446
 
417
447
  }
418
448
 
@@ -424,18 +454,120 @@ function main(engine) {
424
454
  const cam = ecd.getAnyComponent(Camera);
425
455
  // cam.component.projectionType.set(ProjectionType.Orthographic);
426
456
 
457
+ const points = [
458
+ 84,
459
+ 20,
460
+ 100,
461
+ 68.36000061035156,
462
+ 5.840000152587891,
463
+ 31.1200008392334,
464
+ 69.01000213623047,
465
+ 8,
466
+ 24.020000457763672,
467
+ 88.19000244140625,
468
+ 35,
469
+ 22.729999542236328,
470
+ 114.80999755859375,
471
+ 35,
472
+ 10.970000267028809,
473
+ 71,
474
+ 35,
475
+ -69.01000213623047,
476
+ -31.809999465942383,
477
+ 25,
478
+ -27.850000381469727,
479
+ -11.130000114440918,
480
+ 25,
481
+ 30.770000457763672,
482
+ 20.75,
483
+ 25,
484
+ 6.539999961853027,
485
+ 13.0600004196167,
486
+ 25,
487
+ -6.28000020980835,
488
+ 7.75,
489
+ 17.760000228881836,
490
+ 14.109999656677246,
491
+ 4.260000228881836,
492
+ 10.529999732971191,
493
+ 8.869999885559082,
494
+ -5.96999979019165,
495
+ 8.079999923706055,
496
+ -2.180000066757202,
497
+ -5.369999885559082,
498
+ 6.059999942779541,
499
+ -12.010000228881836,
500
+ -9.359999656677246,
501
+ 6.059999942779541,
502
+ -12.369999885559082,
503
+ -10.579999923706055,
504
+ 4.789999961853027,
505
+ -15.300000190734863,
506
+ -9.130000114440918,
507
+ 4.639999866485596,
508
+ -16.350000381469727,
509
+ -9.119999885559082,
510
+ 4.639999866485596,
511
+ -16.360000610351562,
512
+ -9.109999656677246,
513
+ 4.639999866485596,
514
+ -16.360000610351562,
515
+ -9.100000381469727,
516
+ 4.630000114440918,
517
+ -16.360000610351562,
518
+ -4.429999828338623,
519
+ 5,
520
+ -9.720000267028809,
521
+ -7.309999942779541,
522
+ 5,
523
+ 6.059999942779541,
524
+ -4.170000076293945,
525
+ 0.1599999964237213,
526
+ 10.720000267028809,
527
+ -1.4600000381469727,
528
+ 0.1599999964237213,
529
+ 12.109999656677246,
530
+ -0.4399999976158142,
531
+ 0.1599999964237213,
532
+ 19.25,
533
+ 0.5099999904632568,
534
+ 0.1599999964237213,
535
+ 21.65999984741211,
536
+ 2,
537
+ 0.1599999964237213,
538
+ 21.56999969482422,
539
+ 7.880000114440918,
540
+ 2.859999895095825,
541
+ 21.610000610351562,
542
+ 12.039999961853027,
543
+ 2.859999895095825,
544
+ 21.860000610351562,
545
+ 14.369999885559082,
546
+ 3.2100000381469727,
547
+ 21.760000228881836,
548
+ 14.1899995803833,
549
+ 4.440000057220459,
550
+ 25.639999389648438,
551
+ 14.130000114440918,
552
+ 5.53000020980835,
553
+ 29.149999618530273,
554
+ 15.15999984741211,
555
+ 7.159999847412109,
556
+ 29.899999618530273,
557
+ 19.540000915527344,
558
+ 700,
559
+ 51.060001373291016
560
+ ];
561
+
427
562
  makePath({
428
- points: [
429
- 3, 1, 1,
430
- 3, 1, 3,
431
- 7, 1, 3,
432
- 7, 1, 7,
433
- 3, 1, 7,
434
- 3, 1, 8
435
- ],
436
- interp: InterpolationType.Linear
563
+ points: points,
564
+ interp: InterpolationType.CatmullRom
437
565
  }).build(ecd);
438
566
 
567
+ drawControlPoints(Path.fromJSON({
568
+ points
569
+ }), ecd);
570
+
439
571
  makePath({
440
572
  points: [
441
573
  17.600000381469727, 3.2100000381469727, -16.34000015258789,
@@ -1 +1 @@
1
- {"version":3,"file":"TubePathBuilder.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js"],"names":[],"mappings":"AAoFA;IAEQ;;;OAGG;IACH,OAFU,gBAAc,IAAI,CAEX;IAEjB;;;OAGG;IACH,MAFU,OAAK,IAAI,CAEH;IAEhB;;;OAGG;IACH,WAFU,kBAAgB,IAAI,CAET;IAErB;;;OAGG;IACH,cAFU,eAAa,IAAI,CAEH;IAG5B,yBAEC;IAED,2BAEC;IAED,2BAEC;IAED,yCAEC;IAED;;;OAGG;IACH,mBAFW,MAAM,EAAE,QAyElB;CACJ;mBAzMkB,8BAA8B"}
1
+ {"version":3,"file":"TubePathBuilder.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/TubePathBuilder.js"],"names":[],"mappings":"AAoFA;IAEQ;;;OAGG;IACH,OAFU,gBAAc,IAAI,CAEX;IAEjB;;;OAGG;IACH,MAFU,OAAK,IAAI,CAEH;IAEhB;;;OAGG;IACH,WAFU,kBAAgB,IAAI,CAET;IAErB;;;OAGG;IACH,cAFU,eAAa,IAAI,CAEH;IAG5B,yBAEC;IAED,2BAEC;IAED,2BAEC;IAED,yCAEC;IAED;;;OAGG;IACH,mBAFW,MAAM,EAAE,QAyElB;CACJ;mBAvMkB,8BAA8B"}
@@ -1,17 +1,17 @@
1
1
  import { BufferGeometry, MeshBasicMaterial, MeshMatcapMaterial, MeshStandardMaterial } from "three";
2
- import { InterpolationType } from "../../../../../navigation/ecs/components/InterpolationType.js";
2
+ import { assert } from "../../../../../../core/assert.js";
3
+ import { m3_rm_compose_transform } from "../../../../../../core/geom/mat3/m3_rm_compose_transform.js";
4
+ import { GameAssetType } from "../../../../../asset/GameAssetType.js";
3
5
  import Entity from "../../../../../ecs/Entity.js";
4
6
  import { Transform } from "../../../../../ecs/transform/Transform.js";
5
- import { TubeMaterialType } from "../TubeMaterialType.js";
6
- import { GameAssetType } from "../../../../../asset/GameAssetType.js";
7
- import { build_geometry_linear } from "./build_geometry_linear.js";
8
- import { build_geometry_catmullrom } from "./build_geometry_catmullrom.js";
7
+ import { InterpolationType } from "../../../../../navigation/ecs/components/InterpolationType.js";
9
8
  import { ShadedGeometry } from "../../../mesh-v2/ShadedGeometry.js";
10
9
  import { ShadedGeometryFlags } from "../../../mesh-v2/ShadedGeometryFlags.js";
11
- import { fix_shape_normal_order } from "./fix_shape_normal_order.js";
10
+ import { TubeMaterialType } from "../TubeMaterialType.js";
11
+ import { build_geometry_catmullrom } from "./build_geometry_catmullrom.js";
12
+ import { build_geometry_linear } from "./build_geometry_linear.js";
12
13
  import { compute_smooth_profile_normals } from "./compute_smooth_profile_normals.js";
13
- import { assert } from "../../../../../../core/assert.js";
14
- import { m3_rm_compose_transform } from "../../../../../../core/geom/mat3/m3_rm_compose_transform.js";
14
+ import { fix_shape_normal_order } from "./fix_shape_normal_order.js";
15
15
 
16
16
  /**
17
17
  *
@@ -61,7 +61,7 @@ function make_material(style, am) {
61
61
  } else if (material_type === TubeMaterialType.Standard) {
62
62
  material_def = new MeshStandardMaterial({
63
63
  metalness: style.material.metalness,
64
- roughness: style.material.roughness
64
+ roughness: style.material.roughness,
65
65
  });
66
66
  } else if (material_type === TubeMaterialType.Matcap) {
67
67
 
@@ -1 +1 @@
1
- {"version":3,"file":"build_geometry_catmullrom.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,mFAPW,MAAM,EAAE,gBACR,MAAM,EAAE,GAAC,YAAY,mBACrB,MAAM,EAAE,iBACR,MAAM,eACN,MAAM,GACL,MAAM,cAAc,CA4D/B"}
1
+ {"version":3,"file":"build_geometry_catmullrom.d.ts","sourceRoot":"","sources":["../../../../../../../../src/engine/graphics/ecs/path/tube/build/build_geometry_catmullrom.js"],"names":[],"mappings":"AAmFA;;;;;;;;;;GAUG;AACH,mFAPW,MAAM,EAAE,gBACR,MAAM,EAAE,GAAC,YAAY,mBACrB,MAAM,EAAE,iBACR,MAAM,eACN,MAAM,GACL,MAAM,cAAc,CAoI/B"}
@@ -1,7 +1,85 @@
1
+ import { v3_dot } from "../../../../../../core/geom/vec3/v3_dot.js";
2
+ import { clamp } from "../../../../../../core/math/clamp.js";
3
+ import { max2 } from "../../../../../../core/math/max2.js";
4
+ import {
5
+ computeNonuniformCaltmullRomSplineDerivative
6
+ } from "../../../../../../core/math/spline/computeNonuniformCaltmullRomSplineDerivative.js";
7
+ import { PathNormalType } from "../PathNormalType.js";
1
8
  import { computeFrenetFrames } from "./computeFrenetFrames.js";
2
9
  import { makeTubeGeometry } from "./makeTubeGeometry.js";
3
- import Vector3 from "../../../../../../core/geom/Vector3.js";
4
- import { PathNormalType } from "../PathNormalType.js";
10
+
11
+
12
+ const scratch_array_0 = [];
13
+ const scratch_array_1 = [];
14
+ const scratch_array_2 = [];
15
+ const scratch_array_3 = [];
16
+
17
+ /**
18
+ *
19
+ * @param {number[]} positions
20
+ * @param {number[]} derivatives
21
+ * @param {number} result_offset
22
+ * @param {Path} path
23
+ * @param {number} offset
24
+ */
25
+ function sample_path(positions, derivatives, result_offset, path, offset) {
26
+
27
+
28
+ if (!path.find_index_and_normalized_distance(scratch_array_0, offset)) {
29
+ return 0;
30
+ }
31
+
32
+
33
+ /**
34
+ *
35
+ * @type {number}
36
+ */
37
+ const i1 = scratch_array_0[0];
38
+
39
+ /**
40
+ *
41
+ * @type {number}
42
+ */
43
+ const t = scratch_array_0[1];
44
+
45
+
46
+ const input_length = path.getPointCount();
47
+
48
+ const max_index = input_length - 1;
49
+
50
+ const i0 = clamp(i1 - 1, 0, max_index);
51
+ const i2 = clamp(i1 + 1, 0, max_index);
52
+ const i3 = clamp(i1 + 2, 0, max_index);
53
+
54
+ path.readPositionToArray(i0, scratch_array_0, 0);
55
+ path.readPositionToArray(i1, scratch_array_1, 0);
56
+ path.readPositionToArray(i2, scratch_array_2, 0);
57
+ path.readPositionToArray(i3, scratch_array_3, 0);
58
+
59
+ computeNonuniformCaltmullRomSplineDerivative(
60
+ positions, result_offset,
61
+ derivatives, result_offset,
62
+ scratch_array_0, scratch_array_1, scratch_array_2, scratch_array_3,
63
+ 3, t, 0.5
64
+ );
65
+
66
+ // normalize derivative
67
+ const dx = derivatives[result_offset];
68
+ const dy = derivatives[result_offset + 1];
69
+ const dz = derivatives[result_offset + 2];
70
+
71
+ const mag = Math.hypot(dx, dy, dz);
72
+
73
+ if (mag !== 0) {
74
+ const inv_mag = 1 / mag;
75
+
76
+ derivatives[result_offset] = dx * inv_mag;
77
+ derivatives[result_offset + 1] = dy * inv_mag;
78
+ derivatives[result_offset + 2] = dz * inv_mag;
79
+ }
80
+
81
+ return i1;
82
+ }
5
83
 
6
84
  /**
7
85
  *
@@ -25,51 +103,123 @@ export function build_geometry_catmullrom(
25
103
  // resample curve
26
104
  const total_points = Math.ceil(point_count * style.resolution);
27
105
 
28
- const path_length = path.length;
106
+ const reference_step_size = 1 / max2(0.00001, style.resolution);
107
+ const reference_min_step_size = reference_step_size * 0.25;
29
108
 
30
- const point = new Vector3();
109
+ let step_size = reference_step_size;
31
110
 
32
- const points_f32 = [];
111
+ const path_length = path.length;
33
112
 
113
+ const sample_positions_f32 = [];
114
+ const sample_derivatives_f32 = [];
34
115
 
35
116
  let added_points = 0;
36
- let i;
37
117
 
38
118
  // initial segment
39
- path.sample_catmull_rom(point, segment_start * path_length);
40
-
41
- point.writeToArray(points_f32, added_points * 3);
119
+ let last_knot_index = sample_path(
120
+ sample_positions_f32,
121
+ sample_derivatives_f32,
122
+ added_points * 3,
123
+ path,
124
+ segment_start * path_length
125
+ );
42
126
 
43
127
  added_points++;
44
128
 
45
- const max_i = segment_end * (total_points - 1);
46
- for (i = Math.ceil(segment_start * total_points + 0.0001); i < max_i; i++) {
47
- // TODO initial i value can potentially result in sample being produced before the "segment start"
48
- const t = i / (total_points - 1);
49
-
50
- path.sample_catmull_rom(point, path_length * t);
51
-
52
- point.writeToArray(points_f32, added_points * 3);
129
+ let current_offset = segment_start * path_length;
130
+
131
+ let step_resized_direction = 0;
132
+
133
+ const absolute_end_offset = segment_end * path_length;
134
+
135
+ for (; current_offset < absolute_end_offset; current_offset += step_size) {
136
+
137
+
138
+ const point_address = added_points * 3;
139
+
140
+ const knot_index = sample_path(
141
+ sample_positions_f32,
142
+ sample_derivatives_f32,
143
+ point_address,
144
+ path,
145
+ current_offset
146
+ );
147
+
148
+ // check difference with previous derivative
149
+ const previous_point_index = added_points - 1;
150
+ const previous_point_address = previous_point_index * 3;
151
+
152
+ // derivatives are basically normals, and dot product is has Cosine value of angle between two vectors
153
+ const dot = v3_dot(
154
+ sample_derivatives_f32[previous_point_address], sample_derivatives_f32[previous_point_address + 1], sample_derivatives_f32[previous_point_address + 2],
155
+ sample_derivatives_f32[point_address], sample_derivatives_f32[point_address + 1], sample_derivatives_f32[point_address + 2]
156
+ );
157
+
158
+ // angular difference results in larger visual error for longer runs
159
+ const error_size = (1 - dot) * step_size;
160
+
161
+ if (
162
+ (step_size > reference_min_step_size)
163
+ && (
164
+ (
165
+ // check if we jumped over a knot, so that we can sample down to get closer to it
166
+ knot_index > last_knot_index
167
+ && step_size > reference_min_step_size
168
+ )
169
+ || (
170
+ error_size * 10 > reference_min_step_size
171
+ && step_resized_direction <= 0
172
+ )
173
+ || (
174
+ // check if we're getting too close to the end of the segment, this lets us create a nice end
175
+ current_offset + step_size > absolute_end_offset
176
+ )
177
+ )
178
+ ) {
179
+
180
+ // step looks to be too large
181
+ current_offset -= step_size;
182
+ step_size *= 0.5;
183
+ step_resized_direction = -1;
184
+ continue; // retry
185
+
186
+ } else if (
187
+ error_size < 0.02
188
+ && step_resized_direction >= 0
189
+ ) {
190
+
191
+ // step looks to be too small
192
+ current_offset -= step_size;
193
+ step_size *= 2;
194
+ step_resized_direction = 1;
195
+ continue; // retry
196
+
197
+ }
198
+
199
+ // reset adaptive step direction
200
+ step_resized_direction = 0;
201
+ // remember the last knot, so we know when we get to the end of the segment
202
+ last_knot_index = knot_index;
53
203
 
54
204
  added_points++
55
205
  }
56
206
 
57
- if (segment_end - ((i - 1) / (total_points - 1)) > 0.0001) {
207
+ if ((absolute_end_offset - current_offset + step_size) > 0.0001) {
58
208
  // end
59
209
 
60
- path.sample_catmull_rom(point, segment_end * path_length);
61
-
62
- point.writeToArray(points_f32, added_points * 3);
210
+ sample_path(sample_positions_f32, sample_derivatives_f32, added_points * 3, path, absolute_end_offset);
63
211
 
64
212
  added_points++;
65
213
  }
66
214
 
215
+ // console.log(`Total Points ${added_points}`) // DEBUG info
216
+
67
217
  const normal_hint = style.path_normal_type === PathNormalType.FixedStart ? style.path_normal : undefined;
68
218
 
69
- const frames = computeFrenetFrames(points_f32, false, normal_hint);
219
+ const frames = computeFrenetFrames(sample_positions_f32, false, normal_hint);
70
220
 
71
221
  return makeTubeGeometry(
72
- points_f32, frames.normals, frames.binormals, frames.tangents,
222
+ sample_positions_f32, frames.normals, frames.binormals, frames.tangents,
73
223
  shape, shape_normal, shape.length / 2, shape_transform, false, style.cap_type
74
224
  );
75
225
  }
@@ -2,7 +2,7 @@ import FacingDirectionSystem from "../../../../../../../model/game/ecs/system/Fa
2
2
  import { makeEngineOptionsModel } from "../../../../../../../model/game/options/makeEngineOptionsModel.js";
3
3
  import { enableEditor } from "../../../../../../editor/enableEditor.js";
4
4
  import Vector3 from "../../../../../core/geom/Vector3.js";
5
- import { pingpong } from "../../../../../core/math/pingpong.js";
5
+ import { clamp01 } from "../../../../../core/math/clamp01.js";
6
6
  import { computeCatmullRomSpline } from "../../../../../core/math/spline/computeCatmullRomSpline.js";
7
7
  import { CanvasView } from "../../../../../view/elements/CanvasView.js";
8
8
  import { GameAssetType } from "../../../../asset/GameAssetType.js";
@@ -64,6 +64,7 @@ import { PathDisplaySpec } from "../PathDisplaySpec.js";
64
64
  import { PathDisplaySystem } from "../PathDisplaySystem.js";
65
65
  import { PathDisplayType } from "../PathDisplayType.js";
66
66
  import { RibbonPathStyle } from "../ribbon/RibbonPathStyle.js";
67
+ import { CapType } from "./CapType.js";
67
68
  import { MatcapMaterialDefinition } from "./MatcapMaterialDefinition.js";
68
69
  import { TubeMaterialType } from "./TubeMaterialType.js";
69
70
  import { TubePathStyle } from "./TubePathStyle.js";
@@ -308,6 +309,8 @@ function sample_style_tube() {
308
309
  style.material.texture = "data/textures/matcap/nidorx/3E2335_D36A1B_8E4A2E_2842A5.jpg";
309
310
 
310
311
  style.width = 0.1;
312
+ style.resolution = 50;
313
+ style.cap_type = CapType.None;
311
314
 
312
315
  style.path_mask = [
313
316
  0, 1,
@@ -370,7 +373,18 @@ function main(engine) {
370
373
  new Entity()
371
374
  .add(BehaviorComponent.looping_function((delta) => {
372
375
  time += delta * 0.01;
373
- tube_style.path_mask[1] = pingpong(time, 1);
376
+
377
+ const segment_count = 23;
378
+
379
+ tube_style.path_mask = [];
380
+ for (let i = 0; i < segment_count; i++) {
381
+ const offset_start = (i / (segment_count - 1) + time) % 1;
382
+ const offset_end = offset_start + 1 / (segment_count * 1.5);
383
+
384
+ tube_style.path_mask.push(
385
+ clamp01(offset_start), clamp01(offset_end)
386
+ );
387
+ }
374
388
 
375
389
  path_entity.sendEvent(PathEvents.Changed);
376
390
  }))
@@ -5,7 +5,7 @@ export default processTexture;
5
5
  * @param {number} width
6
6
  * @param {number} height
7
7
  * @param {{vertexShader?:string,fragmentShader:string, uniforms?:Object, defines?:Object}} processShader
8
- * @param {Uint8Array} [destination]
8
+ * @param {Uint8Array|Uint8ClampedArray} [destination]
9
9
  * @return {{array: Uint8Array, renderer: WebGLRenderer}}
10
10
  */
11
11
  declare function processTexture(renderer: WebGLRenderer, width: number, height: number, processShader: {
@@ -13,7 +13,7 @@ declare function processTexture(renderer: WebGLRenderer, width: number, height:
13
13
  fragmentShader: string;
14
14
  uniforms?: any;
15
15
  defines?: any;
16
- }, destination?: Uint8Array): {
16
+ }, destination?: Uint8Array | Uint8ClampedArray): {
17
17
  array: Uint8Array;
18
18
  renderer: WebGLRenderer;
19
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ImageFilter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/filter/ImageFilter.js"],"names":[],"mappings":";AASA;;;;;;;;GAQG;AACH,gEANW,MAAM,UACN,MAAM,iBACN;IAAC,YAAY,CAAC,EAAC,MAAM,CAAC;IAAA,cAAc,EAAC,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAQ;IAAC,OAAO,CAAC,MAAO;CAAC,gBAC/E,UAAU,GACT;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,gBAAe;CAAC,CAiEvD"}
1
+ {"version":3,"file":"ImageFilter.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/filter/ImageFilter.js"],"names":[],"mappings":";AASA;;;;;;;;GAQG;AACH,gEANW,MAAM,UACN,MAAM,iBACN;IAAC,YAAY,CAAC,EAAC,MAAM,CAAC;IAAA,cAAc,EAAC,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAQ;IAAC,OAAO,CAAC,MAAO;CAAC,gBAC/E,UAAU,GAAC,iBAAiB,GAC3B;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,gBAAe;CAAC,CAiEvD"}
@@ -4,8 +4,8 @@
4
4
 
5
5
 
6
6
  import { DoubleSide, LinearFilter, Mesh, OrthographicCamera, Scene, ShaderMaterial, WebGLRenderTarget } from 'three';
7
- import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js";
8
7
  import { FULL_SCREEN_QUAD_VERTEX_SHADER } from "../FULL_SCREEN_QUAD_VERTEX_SHADER.js";
8
+ import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js";
9
9
 
10
10
  /**
11
11
  *
@@ -13,7 +13,7 @@ import { FULL_SCREEN_QUAD_VERTEX_SHADER } from "../FULL_SCREEN_QUAD_VERTEX_SHADE
13
13
  * @param {number} width
14
14
  * @param {number} height
15
15
  * @param {{vertexShader?:string,fragmentShader:string, uniforms?:Object, defines?:Object}} processShader
16
- * @param {Uint8Array} [destination]
16
+ * @param {Uint8Array|Uint8ClampedArray} [destination]
17
17
  * @return {{array: Uint8Array, renderer: WebGLRenderer}}
18
18
  */
19
19
  function processTexture(
@@ -24,7 +24,7 @@ function processTexture(
24
24
  destination
25
25
  ) {
26
26
  if (destination === undefined) {
27
- destination = new Uint8Array(width * height * 4);
27
+ destination = new Uint8ClampedArray(width * height * 4);
28
28
  }
29
29
 
30
30
  //make a webgl renderer with orthographic camera
@@ -1,13 +1,26 @@
1
1
  export class WebGLRendererPool {
2
2
  static global: WebGLRendererPool;
3
3
  used: Set<any>;
4
- get(options: any): WebGLRenderer;
4
+ get(): WebGLRenderer;
5
5
  /**
6
6
  *
7
7
  * @param {THREE.WebGLRenderer} renderer
8
8
  * @returns {boolean}
9
9
  */
10
10
  release(renderer: THREE.WebGLRenderer): boolean;
11
+ /**
12
+ * After callback returns, renderer is released back into the pool
13
+ * @template T
14
+ * @param {function(renderer:WebGLRenderer):T} callback
15
+ * @param {*} [thisArg]
16
+ */
17
+ use<T>(callback: any, thisArg?: any): any;
18
+ /**
19
+ * @template T
20
+ * @param {function(renderer:WebGLRenderer):Promise<T>} callback
21
+ * @param {*} [thisArg]
22
+ */
23
+ useAsync<T_1>(callback: any, thisArg?: any): Promise<void>;
11
24
  }
12
25
  import { WebGLRenderer } from 'three';
13
26
  //# sourceMappingURL=RendererPool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RendererPool.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/render/RendererPool.js"],"names":[],"mappings":"AAGA;IAuCI,iCAAwC;IArCxC,eAAiB;IAEjB,iCAcC;IAED;;;;OAIG;IACH,kBAHW,mBAAmB,GACjB,OAAO,CAcnB;CAGJ;8BA3C6B,OAAO"}
1
+ {"version":3,"file":"RendererPool.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/render/RendererPool.js"],"names":[],"mappings":"AAGA;IAiFI,iCAAwC;IA/ExC,eAAiB;IAEjB,qBAcC;IAED;;;;OAIG;IACH,kBAHW,mBAAmB,GACjB,OAAO,CAcnB;IAED;;;;;OAKG;IACH,0CAkBC;IAED;;;;OAIG;IACH,2DASC;CAGJ;8BArF6B,OAAO"}