@woosh/meep-engine 2.100.3 → 2.102.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 (51) hide show
  1. package/build/meep.cjs +107 -92
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +107 -92
  4. package/package.json +1 -1
  5. package/src/core/__module.d.ts +4 -0
  6. package/src/core/__module.js +4 -0
  7. package/src/core/geom/3d/cone/computeConePlaneSide.js +1 -1
  8. package/src/core/geom/3d/mat4/{allocate_transform_m4.d.ts → allocate_m4.d.ts} +2 -2
  9. package/src/core/geom/3d/mat4/allocate_m4.d.ts.map +1 -0
  10. package/src/core/geom/3d/mat4/{allocate_transform_m4.js → allocate_m4.js} +1 -1
  11. package/src/core/geom/Vector4.d.ts.map +1 -1
  12. package/src/core/geom/Vector4.js +13 -92
  13. package/src/core/geom/vec4/v4_distance_sqr.d.ts +14 -0
  14. package/src/core/geom/vec4/v4_distance_sqr.d.ts.map +1 -0
  15. package/src/core/geom/vec4/v4_distance_sqr.js +20 -0
  16. package/src/core/geom/vec4/v4_dot.d.ts +14 -0
  17. package/src/core/geom/vec4/v4_dot.d.ts.map +1 -0
  18. package/src/core/geom/vec4/v4_dot.js +19 -0
  19. package/src/core/geom/vec4/v4_length_sqr.d.ts +10 -0
  20. package/src/core/geom/vec4/v4_length_sqr.d.ts.map +1 -0
  21. package/src/core/geom/vec4/v4_length_sqr.js +11 -0
  22. package/src/core/geom/vec4/v4_multiply_mat4.d.ts +8 -0
  23. package/src/core/geom/vec4/v4_multiply_mat4.d.ts.map +1 -0
  24. package/src/core/geom/vec4/v4_multiply_mat4.js +42 -0
  25. package/src/engine/ecs/fow/FogOfWar.js +2 -2
  26. package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
  27. package/src/engine/ecs/transform/Transform.js +2 -2
  28. package/src/engine/graphics/FrameRunner.d.ts +5 -13
  29. package/src/engine/graphics/FrameRunner.d.ts.map +1 -1
  30. package/src/engine/graphics/FrameRunner.js +31 -25
  31. package/src/engine/graphics/texture/virtual/tile/VirtualTextureTile.d.ts +4 -0
  32. package/src/engine/graphics/texture/virtual/tile/VirtualTextureTile.d.ts.map +1 -1
  33. package/src/engine/graphics/texture/virtual/tile/VirtualTextureTile.js +4 -0
  34. package/src/engine/graphics/trail/x/NOTES.md +3 -0
  35. package/src/engine/graphics/trail/x/RibbonMaterialX.d.ts +11 -2
  36. package/src/engine/graphics/trail/x/RibbonMaterialX.d.ts.map +1 -1
  37. package/src/engine/graphics/trail/x/RibbonMaterialX.js +28 -13
  38. package/src/engine/graphics/util/projectSphere.js +4 -4
  39. package/src/core/geom/3d/mat4/allocate_transform_m4.d.ts.map +0 -1
  40. package/src/engine/graphics/trail/CodeflowTrailMaterial.d.ts +0 -4
  41. package/src/engine/graphics/trail/CodeflowTrailMaterial.d.ts.map +0 -1
  42. package/src/engine/graphics/trail/CodeflowTrailMaterial.js +0 -134
  43. package/src/engine/graphics/trail/TemporalPath.d.ts +0 -39
  44. package/src/engine/graphics/trail/TemporalPath.d.ts.map +0 -1
  45. package/src/engine/graphics/trail/TemporalPath.js +0 -129
  46. package/src/engine/graphics/trail/TemporalPath.spec.d.ts +0 -2
  47. package/src/engine/graphics/trail/TemporalPath.spec.d.ts.map +0 -1
  48. package/src/engine/graphics/trail/TemporalPath.spec.js +0 -5
  49. package/src/engine/graphics/util/composeMatrix4RotationScale.d.ts +0 -9
  50. package/src/engine/graphics/util/composeMatrix4RotationScale.d.ts.map +0 -1
  51. package/src/engine/graphics/util/composeMatrix4RotationScale.js +0 -14
@@ -1,5 +1,6 @@
1
1
  /**
2
- *
2
+ * Fires a given function every frame. Typical usage is to create an instance, invoke {@link #startup} and once no longer required - invoke {@link #shutdown}
3
+ * Wraps {@link requestAnimationFrame}
3
4
  */
4
5
  export class FrameRunner {
5
6
  /**
@@ -13,22 +14,12 @@ export class FrameRunner {
13
14
  */
14
15
  action: Function;
15
16
  /**
16
- *
17
- * @type {boolean}
18
- */
19
- running: boolean;
20
- /**
21
- *
22
- * @type {number}
23
- */
24
- animationFrameId: number;
25
- /**
26
- *
17
+ * Begins animation loop. Does nothing and returns false if already running.
27
18
  * @returns {boolean}
28
19
  */
29
20
  startup(): boolean;
30
21
  /**
31
- *
22
+ * Stops animation loop. Does nothing and returns false if not currently running.
32
23
  * @returns {boolean}
33
24
  */
34
25
  shutdown(): boolean;
@@ -37,5 +28,6 @@ export class FrameRunner {
37
28
  * @returns {boolean}
38
29
  */
39
30
  isRunning(): boolean;
31
+ #private;
40
32
  }
41
33
  //# sourceMappingURL=FrameRunner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FrameRunner.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics/FrameRunner.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACI;;;OAGG;IACH,8BAgBC;IAfG;;;OAGG;IACH,iBAAoB;IACpB;;;OAGG;IACH,SAFU,OAAO,CAEG;IACpB;;;OAGG;IACH,kBAFU,MAAM,CAEU;IAG9B;;;OAGG;IACH,WAFa,OAAO,CA2BnB;IAED;;;OAGG;IACH,YAFa,OAAO,CAiBnB;IAED;;;OAGG;IACH,aAFa,OAAO,CAInB;CACJ"}
1
+ {"version":3,"file":"FrameRunner.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics/FrameRunner.js"],"names":[],"mappings":"AAMA;;;GAGG;AACH;IAYI;;;OAGG;IACH,8BAMC;IALG;;;OAGG;IACH,iBAAoB;IAGxB;;;OAGG;IACH,WAFa,OAAO,CA2BnB;IAED;;;OAGG;IACH,YAFa,OAAO,CAiBnB;IAED;;;OAGG;IACH,aAFa,OAAO,CAInB;;CACJ"}
@@ -1,9 +1,25 @@
1
+ /**
2
+ *
3
+ * @type {number}
4
+ */
1
5
  let global_count = 0;
2
6
 
3
7
  /**
4
- *
8
+ * Fires a given function every frame. Typical usage is to create an instance, invoke {@link #startup} and once no longer required - invoke {@link #shutdown}
9
+ * Wraps {@link requestAnimationFrame}
5
10
  */
6
11
  export class FrameRunner {
12
+ /**
13
+ *
14
+ * @type {boolean}
15
+ */
16
+ #running = false;
17
+ /**
18
+ *
19
+ * @type {number}
20
+ */
21
+ #animationFrameId = -1;
22
+
7
23
  /**
8
24
  *
9
25
  * @param {function} action
@@ -14,66 +30,56 @@ export class FrameRunner {
14
30
  * @type {Function}
15
31
  */
16
32
  this.action = action;
17
- /**
18
- *
19
- * @type {boolean}
20
- */
21
- this.running = false;
22
- /**
23
- *
24
- * @type {number}
25
- */
26
- this.animationFrameId = -1;
27
33
  }
28
34
 
29
35
  /**
30
- *
36
+ * Begins animation loop. Does nothing and returns false if already running.
31
37
  * @returns {boolean}
32
38
  */
33
39
  startup() {
34
- if (this.running) {
40
+ if (this.#running) {
35
41
  return false;
36
42
  }
37
43
 
38
- console.warn(`FrameFunner.started[${global_count}]`);
44
+ // console.warn(`FrameFunner.started[${global_count}]`);
39
45
 
40
46
  global_count++;
41
47
 
42
- this.running = true;
48
+ this.#running = true;
43
49
 
44
50
  const cycle = () => {
45
- if (!this.running) {
51
+ if (!this.#running) {
46
52
  //not supposed to be running, bail
47
53
  return;
48
54
  }
49
55
 
50
56
  this.action();
51
57
 
52
- this.animationFrameId = requestAnimationFrame(cycle);
58
+ this.#animationFrameId = requestAnimationFrame(cycle);
53
59
  }
54
60
 
55
- this.animationFrameId = requestAnimationFrame(cycle);
61
+ this.#animationFrameId = requestAnimationFrame(cycle);
56
62
 
57
63
  return true;
58
64
  }
59
65
 
60
66
  /**
61
- *
67
+ * Stops animation loop. Does nothing and returns false if not currently running.
62
68
  * @returns {boolean}
63
69
  */
64
70
  shutdown() {
65
- if (!this.running) {
71
+ if (!this.#running) {
66
72
  return false;
67
73
  }
68
74
 
69
75
  global_count--;
70
76
 
71
- console.warn(`FrameFunner.stopped[${global_count}]`);
77
+ // console.warn(`FrameFunner.stopped[${global_count}]`);
72
78
 
73
- this.running = false;
74
- cancelAnimationFrame(this.animationFrameId);
79
+ this.#running = false;
80
+ cancelAnimationFrame(this.#animationFrameId);
75
81
 
76
- this.animationFrameId = -1;
82
+ this.#animationFrameId = -1;
77
83
 
78
84
  return true;
79
85
  }
@@ -83,6 +89,6 @@ export class FrameRunner {
83
89
  * @returns {boolean}
84
90
  */
85
91
  isRunning() {
86
- return this.running;
92
+ return this.#running;
87
93
  }
88
94
  }
@@ -4,6 +4,10 @@ export class VirtualTextureTile {
4
4
  * @type {number}
5
5
  */
6
6
  finder_print: number;
7
+ /**
8
+ *
9
+ * @type {number}
10
+ */
7
11
  last_used_time: number;
8
12
  /**
9
13
  * Currently occupied page slot, only valid when page is resident
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualTextureTile.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/texture/virtual/tile/VirtualTextureTile.js"],"names":[],"mappings":"AAAA;IAEI;;;OAGG;IACH,cAFU,MAAM,CAEC;IAEjB,uBAAmB;IAEnB;;;OAGG;IACH,WAFU,MAAM,CAED;IAEf;;;OAGG;IACH,MAFU,YAAU,IAAI,CAEZ;IAEZ;;;;OAIG;IACH,cAHW,kBAAkB,GAChB,OAAO,CAInB;IAED,eAEC;CACJ"}
1
+ {"version":3,"file":"VirtualTextureTile.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/texture/virtual/tile/VirtualTextureTile.js"],"names":[],"mappings":"AAAA;IAEI;;;OAGG;IACH,cAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,gBAFU,MAAM,CAEG;IAEnB;;;OAGG;IACH,WAFU,MAAM,CAED;IAEf;;;OAGG;IACH,MAFU,YAAU,IAAI,CAEZ;IAEZ;;;;OAIG;IACH,cAHW,kBAAkB,GAChB,OAAO,CAInB;IAED,eAEC;CACJ"}
@@ -6,6 +6,10 @@ export class VirtualTextureTile {
6
6
  */
7
7
  finder_print = 0;
8
8
 
9
+ /**
10
+ *
11
+ * @type {number}
12
+ */
9
13
  last_used_time = 0;
10
14
 
11
15
  /**
@@ -0,0 +1,3 @@
1
+ Useful links:
2
+
3
+ * https://github.com/pyalot/webgl-trails
@@ -1,7 +1,16 @@
1
1
  export class RibbonMaterialX extends ShaderMaterial {
2
2
  constructor(params: any);
3
- set resolution(arg: any);
4
- get resolution(): any;
3
+ /**
4
+ *
5
+ * @param {Vector2} v2
6
+ */
7
+ set resolution(arg: Vector2);
8
+ /**
9
+ *
10
+ * @return {Vector2}
11
+ */
12
+ get resolution(): Vector2;
5
13
  }
6
14
  import { ShaderMaterial } from "three";
15
+ import { Vector2 } from "three";
7
16
  //# sourceMappingURL=RibbonMaterialX.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RibbonMaterialX.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonMaterialX.js"],"names":[],"mappings":"AAgGA;IACI,yBAwBC;IAED,yBAEC;IAED,sBAEC;CACJ;+BAlImE,OAAO"}
1
+ {"version":3,"file":"RibbonMaterialX.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/trail/x/RibbonMaterialX.js"],"names":[],"mappings":"AAuGA;IACI,yBAwBC;IAED;;;OAGG;IACH,6BAEC;IAED;;;OAGG;IACH,0BAEC;CACJ;+BAjJmE,OAAO;wBAAP,OAAO"}
@@ -23,23 +23,29 @@ const vertexShader = `
23
23
  }
24
24
 
25
25
  vec2 project(vec4 device){
26
- vec3 device_normal = device.xyz/device.w;
26
+ vec3 device_normal = device.xyz / device.w;
27
27
  vec2 clip_pos = (device_normal*0.5+0.5).xy;
28
28
  return clip_pos * resolution;
29
29
  }
30
30
 
31
31
  vec4 unproject(vec2 screen, float z, float w){
32
- vec2 clip_pos = screen/resolution;
32
+ vec2 clip_pos = screen / resolution;
33
33
  vec2 device_normal = clip_pos*2.0-1.0;
34
- return vec4(device_normal*w, z, w);
34
+ return vec4( device_normal * w, z, w);
35
35
  }
36
36
 
37
37
  float estimateScale(vec3 position, vec2 sPosition){
38
- vec4 view_pos = modelViewMatrix * vec4(position, 1.0);
38
+
39
+ vec4 view_pos = modelViewMatrix * vec4( position, 1.0 );
40
+
39
41
  float halfWidth = thickness*0.5;
40
- vec4 scale_pos = view_pos - vec4(normalize(view_pos.xy)*halfWidth, 0.0, 0.0);
42
+
43
+ vec4 scale_pos = view_pos - vec4( normalize(view_pos.xy) * halfWidth, 0.0, 0.0);
44
+
41
45
  vec2 screen_scale_pos = project(projectionMatrix * scale_pos);
42
- return distance(sPosition, screen_scale_pos);
46
+
47
+ return distance( sPosition, screen_scale_pos );
48
+
43
49
  }
44
50
 
45
51
  void main(){
@@ -52,25 +58,26 @@ const vertexShader = `
52
58
  vec2 normal1 = normalize(sLast - sCurrent);
53
59
  vec2 normal2 = normalize(sCurrent - sNext);
54
60
 
55
- vec2 normal = (normal1 + normal2)*0.5;
61
+ // vector between two segments
62
+ vec2 normal = (normal1 + normal2) * 0.5;
56
63
 
57
64
  float offset_signed = off*2.0 - 1.0;
58
65
 
59
- vUv = vec2(uv_offset, offset_signed*0.5+0.5);
66
+ vUv = vec2(uv_offset, off);
60
67
 
61
- float relativeAge = clamp(age/maxAge, 0.0, 1.0);
68
+ float relativeAge = clamp(age / maxAge, 0.0, 1.0);
62
69
 
63
- vColor = vec4(color/ 255.0, alpha);
70
+ vColor = vec4( color / 255.0, alpha );
64
71
 
65
72
  vec2 dir = vec2(normal.y, -normal.x) * offset_signed;
66
73
 
67
- float angular_compensation = max( normal.x*normal.x + normal.y*normal.y, 0.25 );
74
+ float angular_compensation = max( normal.x * normal.x + normal.y * normal.y, 0.25 );
68
75
 
69
76
  float visual_size = resolution.y * projectionMatrix[1][1] * thickness*0.5 / dCurrent.w;
70
77
 
71
78
  float scale = visual_size / angular_compensation;
72
79
 
73
- vec2 pos = sCurrent + dir*scale;
80
+ vec2 pos = sCurrent + dir * scale;
74
81
 
75
82
  gl_Position = unproject(pos, dCurrent.z, dCurrent.w);
76
83
  }
@@ -101,7 +108,7 @@ export class RibbonMaterialX extends ShaderMaterial {
101
108
  vertexShader,
102
109
  uniforms: {
103
110
  resolution: {
104
- value: new Vector2(120, 600)
111
+ value: new Vector2(600, 600)
105
112
  },
106
113
  uDiffuse: {
107
114
  type: 't',
@@ -121,10 +128,18 @@ export class RibbonMaterialX extends ShaderMaterial {
121
128
  this.setValues(params);
122
129
  }
123
130
 
131
+ /**
132
+ *
133
+ * @param {Vector2} v2
134
+ */
124
135
  set resolution(v2) {
125
136
  this.uniforms.resolution.value.set(v2.x, v2.y);
126
137
  }
127
138
 
139
+ /**
140
+ *
141
+ * @return {Vector2}
142
+ */
128
143
  get resolution() {
129
144
  return this.uniforms.resolution.value;
130
145
  }
@@ -1,6 +1,6 @@
1
1
  import { assert } from "../../../core/assert.js";
2
- import { v4_applyMatrix4 } from "../../../core/geom/Vector4.js";
3
2
  import { v3_dot } from "../../../core/geom/vec3/v3_dot.js";
3
+ import { v4_multiply_mat4 } from "../../../core/geom/vec4/v4_multiply_mat4.js";
4
4
 
5
5
  const v4 = [];
6
6
 
@@ -21,7 +21,7 @@ export function projectSphere(sph, cam, fl) {
21
21
  v4[3] = 1;
22
22
 
23
23
  //transform to camera space
24
- v4_applyMatrix4(v4, v4, cam.elements);
24
+ v4_multiply_mat4(v4, v4, cam.elements);
25
25
 
26
26
  const r2 = sph.w * sph.w;
27
27
 
@@ -50,7 +50,7 @@ export function v3_compute_perspective_divide(v3, matrix) {
50
50
  v4[3] = 1;
51
51
 
52
52
  //transform sphere center to camera space
53
- v4_applyMatrix4(v4, v4, matrix);
53
+ v4_multiply_mat4(v4, v4, matrix);
54
54
 
55
55
  const v4_w = v4[3];
56
56
 
@@ -73,7 +73,7 @@ export function compute_projected_sphere_radius_sqr(fl, matrix, sph) {
73
73
  v4[3] = 1;
74
74
 
75
75
  //transform sphere center to camera space
76
- v4_applyMatrix4(v4, v4, matrix);
76
+ v4_multiply_mat4(v4, v4, matrix);
77
77
 
78
78
  const r2 = sph[3] * sph[3];
79
79
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"allocate_transform_m4.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/mat4/allocate_transform_m4.js"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,yCAFa,YAAY,CAgBxB"}
@@ -1,4 +0,0 @@
1
- export default CodeflowMaterial;
2
- declare function CodeflowMaterial(): ShaderMaterial;
3
- import { ShaderMaterial } from 'three';
4
- //# sourceMappingURL=CodeflowTrailMaterial.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CodeflowTrailMaterial.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/trail/CodeflowTrailMaterial.js"],"names":[],"mappings":";AAoGA,oDA+BC;+BA3H4E,OAAO"}
@@ -1,134 +0,0 @@
1
- /**
2
- * Borrowed from https://github.com/pyalot/webgl-trails
3
- * Created by Alex on 14/06/2017.
4
- * @author Alex Goldring
5
- * @author pyalot
6
- */
7
-
8
-
9
- import { DoubleSide, NormalBlending, ShaderMaterial, Vector2, Vector4 } from 'three';
10
-
11
- const vertexShader = `
12
- varying vec2 vUv;
13
- varying float vOpacity;
14
-
15
- attribute vec3 last, next;
16
- attribute float off;
17
- attribute float uvOffset;
18
- attribute float age;
19
-
20
- uniform vec2 viewport;
21
- uniform float width;
22
- uniform float maxAge;
23
- uniform float time;
24
-
25
- float pi = 3.141592653589793;
26
-
27
- vec4 transform(vec3 coord){
28
- return projectionMatrix * modelViewMatrix * vec4(coord, 1.0);
29
- }
30
-
31
- vec2 project(vec4 device){
32
- vec3 device_normal = device.xyz/device.w;
33
- vec2 clip_pos = (device_normal*0.5+0.5).xy;
34
- return clip_pos * viewport;
35
- }
36
-
37
- vec4 unproject(vec2 screen, float z, float w){
38
- vec2 clip_pos = screen/viewport;
39
- vec2 device_normal = clip_pos*2.0-1.0;
40
- return vec4(device_normal*w, z, w);
41
- }
42
-
43
- float estimateScale(vec3 position, vec2 sPosition){
44
- vec4 view_pos = modelViewMatrix * vec4(position, 1.0);
45
- float halfWidth = width*0.5;
46
- vec4 scale_pos = view_pos - vec4(normalize(view_pos.xy)*halfWidth, 0.0, 0.0);
47
- vec2 screen_scale_pos = project(projectionMatrix * scale_pos);
48
- return distance(sPosition, screen_scale_pos);
49
- }
50
-
51
- float curvatureCorrection(vec2 a, vec2 b){
52
- float p = a.x*b.y - a.y*b.x;
53
- float c = atan(p, dot(a,b))/pi;
54
- return clamp(c, -1.0, 1.0);
55
- }
56
-
57
- void main(){
58
- vec2 sLast = project(transform(last.xyz));
59
- vec2 sNext = project(transform(next.xyz));
60
-
61
- vec4 dCurrent = transform(position.xyz);
62
- vec2 sCurrent = project(dCurrent);
63
-
64
- vec2 normal1 = normalize(sLast - sCurrent);
65
- vec2 normal2 = normalize(sCurrent - sNext);
66
- vec2 normal = (normal1 + normal2)*0.5;
67
- vUv = vec2(uvOffset*0.7, off*0.5+0.5);
68
-
69
- float relativeAge = clamp(age/maxAge, 0.0, 1.0);
70
- vOpacity = 1.0 - relativeAge;
71
-
72
- vec2 dir = vec2(normal.y, -normal.x)*off;
73
-
74
- float scale = estimateScale(position.xyz, sCurrent);
75
- vec2 pos = sCurrent + dir*scale;
76
-
77
- gl_Position = unproject(pos, dCurrent.z, dCurrent.w);
78
- }
79
- `;
80
-
81
- const fragmentShader = `
82
- varying vec2 vUv;
83
- varying float vOpacity;
84
- uniform vec4 color;
85
-
86
- uniform sampler2D uTexture;
87
-
88
- void main(){
89
- vec4 diffuseColor = color;
90
- diffuseColor.a *= vOpacity;
91
-
92
- #ifdef USE_TEXTURE
93
- vec4 texel = texture2D(uTexture, vUv);
94
- diffuseColor *= texel;
95
- #endif
96
-
97
- gl_FragColor = diffuseColor;
98
- }
99
- `;
100
-
101
- function CodeflowMaterial() {
102
- const uniforms = {
103
- uTexture: { type: "t", value: null },
104
- viewport: { type: "v2", value: new Vector2(800, 600) },
105
- width: { type: "f", value: 5 },
106
- time: { type: "f", value: 0 },
107
- maxAge: { type: "f", value: 1 },
108
- color: { type: "v4", value: new Vector4(1, 1, 1, 1) }
109
- };
110
-
111
- const side = DoubleSide;
112
-
113
- const shaderMaterial = new ShaderMaterial({
114
- uniforms: uniforms,
115
- vertexShader: vertexShader,
116
- fragmentShader: fragmentShader,
117
- side: side,
118
- blending: NormalBlending,
119
- lights: false,
120
- depthTest: true,
121
- depthWrite: false,
122
- transparent: true,
123
- defines: {
124
- USE_TEXTURE: false
125
- }
126
- });
127
-
128
- shaderMaterial.needsUpdate = true;
129
-
130
- //shaderMaterial.defaultAttributeValues.tangent = [0, 1, 0];
131
- return shaderMaterial;
132
- }
133
-
134
- export default CodeflowMaterial;
@@ -1,39 +0,0 @@
1
- /**
2
- * Keeps tracks of a moving point for a given time window
3
- */
4
- export class TemporalPath {
5
- /**
6
- * How long to track the points for
7
- * @type {number}
8
- */
9
- memory: number;
10
- /**
11
- *
12
- * @type {number}
13
- */
14
- time: number;
15
- /**
16
- *
17
- * @type {RowFirstTable}
18
- */
19
- data: RowFirstTable;
20
- updateSequence(): void;
21
- /**
22
- *
23
- * @param {number} timeDelta
24
- */
25
- update(timeDelta: number): void;
26
- /**
27
- * @returns {number}
28
- */
29
- computeLength(): number;
30
- /**
31
- *
32
- * @param {number} x
33
- * @param {number} y
34
- * @param {number} z
35
- */
36
- append(x: number, y: number, z: number): void;
37
- }
38
- import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
39
- //# sourceMappingURL=TemporalPath.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemporalPath.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/trail/TemporalPath.js"],"names":[],"mappings":"AAWA;;GAEG;AACH;IACI;;;OAGG;IACH,QAFU,MAAM,CAEL;IAEX;;;OAGG;IACH,MAFU,MAAM,CAEP;IAET;;;OAGG;IACH,MAFU,aAAa,CAEc;IAErC,uBAoBC;IAED;;;OAGG;IACH,kBAFW,MAAM,QAMhB;IAED;;OAEG;IACH,iBAFa,MAAM,CA4ClB;IAED;;;;;OAKG;IACH,UAJW,MAAM,KACN,MAAM,KACN,MAAM,QAShB;CACJ;8BA9H6B,iDAAiD"}
@@ -1,129 +0,0 @@
1
- import { RowFirstTable } from "../../../core/collection/table/RowFirstTable.js";
2
- import { BinaryDataType } from "../../../core/binary/type/BinaryDataType.js";
3
- import { RowFirstTableSpec } from "../../../core/collection/table/RowFirstTableSpec.js";
4
-
5
- const TABLE_SPEC = RowFirstTableSpec.get([
6
- // time
7
- BinaryDataType.Float32,
8
- // position XYZ
9
- BinaryDataType.Float32, BinaryDataType.Float32, BinaryDataType.Float32
10
- ]);
11
-
12
- /**
13
- * Keeps tracks of a moving point for a given time window
14
- */
15
- export class TemporalPath {
16
- /**
17
- * How long to track the points for
18
- * @type {number}
19
- */
20
- memory = 0;
21
-
22
- /**
23
- *
24
- * @type {number}
25
- */
26
- time = 0;
27
-
28
- /**
29
- *
30
- * @type {RowFirstTable}
31
- */
32
- data = new RowFirstTable(TABLE_SPEC);
33
-
34
- updateSequence() {
35
- const sequence = this.data;
36
- //determine if position sequence can be cropped
37
- const numRecords = sequence.length;
38
-
39
- if (numRecords === 0) {
40
- return;
41
- }
42
-
43
- const lastUsefulMemory = this.time - this.memory;
44
-
45
- let i = 0;
46
-
47
- while (i < numRecords && sequence.readCellValue(i, 0) < lastUsefulMemory) {
48
- i++;
49
- }
50
-
51
- if (i > 0) {
52
- sequence.removeRows(0, i);
53
- }
54
- }
55
-
56
- /**
57
- *
58
- * @param {number} timeDelta
59
- */
60
- update(timeDelta) {
61
- this.time += timeDelta;
62
-
63
- this.updateSequence();
64
- }
65
-
66
- /**
67
- * @returns {number}
68
- */
69
- computeLength() {
70
-
71
- let i;
72
- const numRecords = this.data.length;
73
-
74
- if (numRecords === 0) {
75
- return 0;
76
- }
77
-
78
- let _x, _y, _z;
79
-
80
- this.data.getRow(0, tempSequenceRecord);
81
-
82
- _x = tempSequenceRecord[1];
83
- _y = tempSequenceRecord[2];
84
- _z = tempSequenceRecord[3];
85
-
86
-
87
- let result = 0;
88
-
89
- for (i = 1; i < numRecords; i++) {
90
- this.data.getRow(i, tempSequenceRecord);
91
-
92
- const x = tempSequenceRecord[1];
93
- const y = tempSequenceRecord[2];
94
- const z = tempSequenceRecord[3];
95
-
96
- const dX = x - _x;
97
- const dY = y - _y;
98
- const dZ = z - _z;
99
-
100
- const d = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
101
-
102
- result += d;
103
-
104
- //remember current coordinates
105
- _x = x;
106
- _y = y;
107
- _z = z;
108
- }
109
-
110
- return result;
111
- }
112
-
113
- /**
114
- *
115
- * @param {number} x
116
- * @param {number} y
117
- * @param {number} z
118
- */
119
- append(x, y, z) {
120
- tempSequenceRecord[0] = this.time;
121
- tempSequenceRecord[1] = x;
122
- tempSequenceRecord[2] = y;
123
- tempSequenceRecord[3] = z;
124
-
125
- this.data.addRow(tempSequenceRecord);
126
- }
127
- }
128
-
129
- const tempSequenceRecord = [];
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TemporalPath.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemporalPath.spec.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/trail/TemporalPath.spec.js"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { TemporalPath } from "./TemporalPath.js";
2
-
3
- test("constructor does not throw", () => {
4
- expect(() => new TemporalPath()).not.toThrow();
5
- });