@woosh/meep-engine 2.33.19 → 2.33.23

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 (104) hide show
  1. package/core/assert.js +3 -1
  2. package/core/bvh2/traversal/__detailed_box_volume_intersection.js +11 -8
  3. package/core/collection/HashMap.js +66 -22
  4. package/core/geom/3d/CircleMath.js +4 -4
  5. package/core/geom/3d/cone/computeConeBoundingBox.js +4 -4
  6. package/core/geom/3d/{compute_bounding_cone_of_2_cones.js → cone/compute_bounding_cone_of_2_cones.js} +3 -3
  7. package/core/geom/3d/{compute_bounding_cone_of_2_cones.spec.js → cone/compute_bounding_cone_of_2_cones.spec.js} +1 -1
  8. package/core/geom/3d/frustum/array_setFromProjectionMatrix.js +1 -1
  9. package/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +10 -2
  10. package/core/geom/3d/{encode_unit3_hemioct.js → normal/hemioct/encode_unit3_hemioct.js} +0 -0
  11. package/core/geom/3d/{unit_hemioct.spec.js → normal/hemioct/unit_hemioct.spec.js} +1 -1
  12. package/core/geom/3d/normal/lamber_azimuth/transform.js +61 -0
  13. package/core/geom/3d/normal/spherical/sphere_map_transform.js +77 -0
  14. package/core/geom/3d/{lerp_planes_to_array.js → plane/lerp_planes_to_array.js} +1 -3
  15. package/core/geom/3d/plane/plane3_lerp.js +3 -1
  16. package/core/geom/3d/plane/plane3_slerp.js +4 -1
  17. package/core/geom/3d/{plane_computeConvex3PlaneIntersection.js → plane/plane_computeConvex3PlaneIntersection.js} +14 -16
  18. package/core/geom/3d/topology/TopoTriangle.js +1 -1
  19. package/core/geom/3d/topology/TopoVertex.js +1 -1
  20. package/core/geom/3d/topology/bounds/computeTraingleClusterNormalBoundingCone.js +2 -2
  21. package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
  22. package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
  23. package/core/geom/3d/triangle/computeTrianglePlaneSide.js +1 -1
  24. package/core/geom/3d/triangle/computeTriangleRayIntersection.js +1 -1
  25. package/core/geom/3d/voxel/DenseBitVolume3D.js +87 -0
  26. package/core/geom/3d/voxel/buildVolumeFromProjectedGeometry.js +23 -0
  27. package/core/geom/LineSegment.js +3 -1
  28. package/core/geom/Matrix4.js +2 -1
  29. package/core/geom/Plane.js +15 -10
  30. package/core/geom/Quaternion.js +2 -1
  31. package/core/geom/Vector3.d.ts +2 -0
  32. package/core/geom/Vector3.js +33 -158
  33. package/core/geom/Vector3.spec.js +2 -1
  34. package/core/geom/v3_angle_between.js +31 -0
  35. package/core/geom/v3_distance.js +16 -0
  36. package/core/geom/v3_distance_sqr.js +17 -0
  37. package/core/geom/v3_dot.js +13 -0
  38. package/core/geom/v3_length.js +5 -0
  39. package/core/geom/v3_length_sqr.js +10 -0
  40. package/core/geom/v3_lerp.js +21 -0
  41. package/core/geom/v3_slerp.js +48 -0
  42. package/core/primitives/array/computeIntegerArrayHash.js +6 -1
  43. package/engine/asset/loaders/material/computeImageBitmapEquality.js +11 -0
  44. package/engine/asset/loaders/material/computeImageBitmapHash.js +22 -28
  45. package/engine/asset/loaders/material/computeMaterialHash.js +1 -2
  46. package/engine/asset/loaders/material/computeTextureEquality.js +13 -5
  47. package/engine/ecs/animation/OneBoneSurfaceAlignmentSolver.js +3 -1
  48. package/engine/ecs/animation/TwoBoneInverseKinematicsSolver.js +3 -1
  49. package/engine/ecs/fow/FogOfWar.js +2 -3
  50. package/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +1 -1
  51. package/engine/ecs/systems/SteeringSystem.js +2 -1
  52. package/engine/ecs/terrain/ecs/Terrain.js +6 -0
  53. package/engine/ecs/terrain/ecs/layers/TerrainLayers.js +5 -0
  54. package/engine/ecs/terrain/ecs/splat/SplatMapping.js +5 -0
  55. package/engine/ecs/util/hideEntityGracefully.js +18 -0
  56. package/engine/graphics/GraphicsEngine.js +1 -0
  57. package/engine/graphics/camera/testClippingPlaneComputation.js +2 -2
  58. package/engine/graphics/ecs/camera/CameraClippingPlaneComputer.js +1 -1
  59. package/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +0 -53
  60. package/engine/graphics/ecs/path/testPathDisplaySystem.js +98 -98
  61. package/engine/graphics/ecs/trail2d/Trail2D.js +17 -4
  62. package/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts +2 -3
  63. package/engine/graphics/ecs/trail2d/Trail2DSystem.js +34 -118
  64. package/engine/graphics/geometry/bvh/buffered/BVHGeometryRaycaster.js +2 -1
  65. package/engine/graphics/micron/build/clustering/computeFaceCurvatureScore.js +1 -1
  66. package/engine/graphics/micron/build/clustering/compute_face_connection_weight.js +1 -1
  67. package/engine/graphics/micron/build/hierarchy/computePatchMergeScore.js +1 -1
  68. package/engine/graphics/micron/build/hierarchy/patch_combine.js +1 -1
  69. package/engine/graphics/micron/render/refinement/is_patch_facing_back.js +2 -2
  70. package/engine/graphics/particles/particular/engine/ParticularEngine.js +4 -2
  71. package/engine/graphics/particles/particular/engine/emitter/PARTICULAR_PARTICLE_SPECIFICATION.js +20 -0
  72. package/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js +40 -97
  73. package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +12 -2
  74. package/engine/graphics/particles/particular/engine/emitter/computeEmissionFunction.js +37 -0
  75. package/engine/graphics/particles/particular/engine/emitter/distance_to_camera.js +25 -0
  76. package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +7 -25
  77. package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +2 -2
  78. package/engine/graphics/render/forward_plus/LightManager.js +10 -2
  79. package/engine/graphics/render/forward_plus/computeFrustumCorners.js +15 -33
  80. package/engine/graphics/render/forward_plus/plugin/MaterialTransformer.js +12 -2
  81. package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
  82. package/engine/graphics/render/forward_plus/prototypeLightManager.js +96 -95
  83. package/engine/graphics/render/forward_plus/queryBVH_Frustum.js +18 -6
  84. package/engine/graphics/render/layers/RenderLayerUtils.js +8 -5
  85. package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
  86. package/engine/graphics/texture/atlas/AtlasPatch.js +7 -2
  87. package/engine/graphics/texture/atlas/TextureAtlas.js +18 -14
  88. package/engine/graphics/texture/sampler/Sampler2D.js +8 -7
  89. package/engine/graphics/texture/sampler/scaleSampler2D.js +7 -10
  90. package/engine/graphics/trail/x/RibbonMaterialX.js +3 -3
  91. package/engine/graphics/trail/x/RibbonX.js +17 -2
  92. package/engine/graphics/trail/x/RibbonXPlugin.js +51 -1
  93. package/engine/graphics/util/projectSphere.js +1 -1
  94. package/engine/grid/components/GridObstacle.js +2 -9
  95. package/engine/navigation/ecs/components/Path.js +2 -1
  96. package/engine/network/convertPathToURL.js +2 -2
  97. package/engine/reference/v2/Reference.js +6 -0
  98. package/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +3 -2
  99. package/generation/markers/GridCellActionPlaceMarker.js +13 -1
  100. package/generation/markers/MarkerNode.js +6 -0
  101. package/generation/theme/ThemeEngine.js +4 -1
  102. package/package.json +3 -3
  103. package/view/View.js +4 -2
  104. package/view/minimap/gl/MinimapMarkersGL.js +13 -1
@@ -68,6 +68,7 @@ function ParticleLayer() {
68
68
  * @type {number}
69
69
  */
70
70
  this.emissionRate = 1;
71
+
71
72
  /**
72
73
  * When layer is added - it will immediately emit this number of particles
73
74
  * @type {number}
@@ -97,6 +98,11 @@ function ParticleLayer() {
97
98
  * @type {ConicRay}
98
99
  */
99
100
  this.particleVelocityDirection = new ConicRay();
101
+
102
+ /**
103
+ *
104
+ * @type {NumericInterval}
105
+ */
100
106
  this.particleSpeed = new NumericInterval(0, 0);
101
107
 
102
108
  /**
@@ -111,7 +117,6 @@ function ParticleLayer() {
111
117
  */
112
118
  this.isEmitting = true;
113
119
 
114
-
115
120
  /**
116
121
  * Simulation steps that are to be applied
117
122
  * @type {List<SimulationStepDefinition>}
@@ -173,7 +178,12 @@ ParticleLayer.prototype.computePointBoundingBox = function (result) {
173
178
  //displace by current position
174
179
  const position = this.position;
175
180
 
176
- computeConeBoundingBox(aabb3, position.x, position.y, position.z, direction.x, direction.y, direction.z, particleVelocityDirection.angle, maxDisplacement);
181
+ computeConeBoundingBox(
182
+ aabb3,
183
+ position.x, position.y, position.z,
184
+ direction.x, direction.y, direction.z,
185
+ particleVelocityDirection.angle, maxDisplacement
186
+ );
177
187
 
178
188
  x0 = aabb3.x0;
179
189
  y0 = aabb3.y0;
@@ -0,0 +1,37 @@
1
+ import { EmissionShapeType } from "./EmissionShapeType.js";
2
+ import { randomPointInPoint } from "../../../../../../core/geom/random/randomPointInPoint.js";
3
+ import { EmissionFromType } from "./EmissionFromType.js";
4
+ import { randomPointInSphere } from "../../../../../../core/geom/random/randomPointInSphere.js";
5
+ import { randomPointOnSphere } from "../../../../../../core/geom/random/randomPointOnSphere.js";
6
+ import { randomPointInBox } from "../../../../../../core/geom/random/randomPointInBox.js";
7
+ import { randomPointOnBox } from "../../../../../../core/geom/random/randomPointOnBox.js";
8
+
9
+ /**
10
+ *
11
+ * @param {EmissionFromType} emissionType
12
+ * @param {EmissionShapeType} emissionShape
13
+ * @returns {function(random: function, result:Vector3):void}
14
+ */
15
+ export function computeEmissionFunction(emissionType, emissionShape) {
16
+ if (emissionShape === EmissionShapeType.Point) {
17
+ return randomPointInPoint;
18
+ } else if (emissionShape === EmissionShapeType.Sphere) {
19
+ if (emissionType === EmissionFromType.Volume) {
20
+ return randomPointInSphere;
21
+ } else if (emissionType === EmissionFromType.Shell) {
22
+ return randomPointOnSphere;
23
+ } else {
24
+ throw new TypeError('Unsupported EmissionFrom Type');
25
+ }
26
+ } else if (emissionShape === EmissionShapeType.Box) {
27
+ if (emissionType === EmissionFromType.Volume) {
28
+ return randomPointInBox;
29
+ } else if (emissionType === EmissionFromType.Shell) {
30
+ return randomPointOnBox;
31
+ } else {
32
+ throw new TypeError('Unsupported EmissionFrom Type');
33
+ }
34
+ } else {
35
+ throw new TypeError('Unsupported emission shape');
36
+ }
37
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ *
3
+ * @param {number} index
4
+ * @param {number[]|Float32Array} positionArray
5
+ * @param {Vector3} planeNormal
6
+ * @return {number}
7
+ */
8
+ export function distance_to_camera(index, positionArray, planeNormal) {
9
+ const address = index * 3;
10
+
11
+ // extract position components of the particle
12
+ const x = positionArray[address];
13
+ const y = positionArray[address + 1];
14
+ const z = positionArray[address + 2];
15
+
16
+ const planeNormalX = planeNormal.x;
17
+ const planeNormalY = planeNormal.y;
18
+ const planeNormalZ = planeNormal.z;
19
+
20
+ // compute dot product
21
+ const dot = x * planeNormalX + y * planeNormalY + z * planeNormalZ;
22
+
23
+ // use dot product instead of the actual distance to save computation. Difference is going to be constant
24
+ return dot;
25
+ }
@@ -115,6 +115,8 @@ export class ShaderManager {
115
115
  anisotropy: 0
116
116
  });
117
117
 
118
+ this.spriteTexture.name = 'Sprite sheet';
119
+
118
120
  /**
119
121
  *
120
122
  * @type {Texture|null}
@@ -284,37 +286,14 @@ export class ShaderManager {
284
286
 
285
287
  console.warn('Recomputing hashes ... ');
286
288
 
287
- this.recordGraveyard.updateHashes();
288
- this.materialMap.updateHashes();
289
+ this.recordGraveyard.rebuild();
290
+ this.materialMap.rebuild();
289
291
  }
290
292
 
291
293
  this.materialMap.delete(bestKey);
292
294
  }
293
295
  }
294
296
 
295
- /**
296
- *
297
- * @param {MaterialRecord} entry
298
- */
299
- destroyMaterialRecord(entry) {
300
-
301
- const parameters = entry.parameters.asArray();
302
-
303
- //remove parameters from parameter sheet
304
- for (let i = 0; i < parameters.length; i++) {
305
- const particleParameter = parameters[i];
306
- this.parameterSheet.remove(particleParameter);
307
- }
308
-
309
- //unlink signal bindings
310
- entry.signalBindings.forEach(function (binding) {
311
- binding.unlink();
312
- });
313
-
314
- //decommission material
315
- entry.material.dispose();
316
- }
317
-
318
297
  /**
319
298
  *
320
299
  * @param {ParticleEmitter} emitter
@@ -369,6 +348,7 @@ export class ShaderManager {
369
348
  const cameraNear = camera.near;
370
349
  const cameraFar = camera.far;
371
350
 
351
+ // TODO use a shader uniform structure to avoid iteration
372
352
  this.materialMap.forEach(function (entry) {
373
353
  const uniforms = entry.material.uniforms;
374
354
 
@@ -386,6 +366,7 @@ export class ShaderManager {
386
366
  setDepthTexture(texture) {
387
367
  this.depthTexture = texture;
388
368
 
369
+ // TODO use a shader uniform structure to avoid iteration
389
370
  this.materialMap.forEach(function (entry) {
390
371
  const material = entry.material;
391
372
  material.uniforms.tDepth.value = texture;
@@ -400,6 +381,7 @@ export class ShaderManager {
400
381
  setViewportSize(x, y) {
401
382
  this.viewportSize.set(x, y);
402
383
 
384
+ // TODO use a shader uniform structure to avoid iteration
403
385
  this.materialMap.forEach(function (entry) {
404
386
  entry.material.uniforms.resolution.value.set(x, y);
405
387
  });
@@ -108,7 +108,7 @@ function makeConfig(engine) {
108
108
  new ClingToTerrainSystem(),
109
109
  new TerrainSystem(graphics, assetManager),
110
110
  new WaterSystem(graphics),
111
- new Trail2DSystem(graphics, assetManager),
111
+ new Trail2DSystem(engine),
112
112
  new Foliage2System(assetManager, graphics),
113
113
  new ViewportPositionSystem(graphics.viewport.size),
114
114
  new GridPosition2TransformSystem(),
@@ -326,7 +326,7 @@ function main(engine) {
326
326
  position: {
327
327
  x: 60 + i * 10,
328
328
  y: 0,
329
- z: 30 + j*10
329
+ z: 30 + j * 10
330
330
  },
331
331
  scale: {
332
332
  x: 1,
@@ -508,6 +508,7 @@ export class LightManager {
508
508
  let lookup_address_offset = 0;
509
509
  let i_x_0, i_y_0, i_z_0;
510
510
 
511
+ // clear cache
511
512
  LOOKUP_CACHE.fill(0xFFFFFFFF);
512
513
 
513
514
  for (i_z_0 = 0; i_z_0 < tr_z; i_z_0++) {
@@ -529,7 +530,6 @@ export class LightManager {
529
530
  read_plane_pair(cluster_planes, y_plane_index_offset_0, scratch_frustum_planes, 8);
530
531
 
531
532
  for (i_x_0 = 0; i_x_0 < tr_x; i_x_0++) {
532
- const i_x_1 = i_x_0 + 1;
533
533
 
534
534
  // construct x planes
535
535
 
@@ -551,6 +551,8 @@ export class LightManager {
551
551
  const frustum_point_index_011 = i_z_1 * tr_xy_1 + i_y_1 * tr_x_1 + i_x_0;
552
552
  read_frustum_corner(cluster_frustum_points, frustum_point_index_011, scratch_corners, 9);
553
553
 
554
+ const i_x_1 = i_x_0 + 1;
555
+
554
556
  const frustum_point_index_100 = i_z_0 * tr_xy_1 + i_y_0 * tr_x_1 + i_x_1;
555
557
  read_frustum_corner(cluster_frustum_points, frustum_point_index_100, scratch_corners, 12);
556
558
 
@@ -565,7 +567,13 @@ export class LightManager {
565
567
 
566
568
 
567
569
  // at this point we have a fully constructed cluster, we can query lights within the cluster
568
- const match_count = queryBVH_Frustum(scratch_light_nodes, 0, bvh, scratch_frustum_planes, scratch_corners);
570
+ const match_count = queryBVH_Frustum(
571
+ scratch_light_nodes,
572
+ 0,
573
+ bvh,
574
+ scratch_frustum_planes,
575
+ scratch_corners
576
+ );
569
577
 
570
578
  const tile_index = (i_z_0 * tile_slice_size) + (i_y_0 * tr_x) + (tr_x - i_x_1);
571
579
 
@@ -1,14 +1,4 @@
1
- import Vector3 from "../../../../core/geom/Vector3.js";
2
- import { plane_three_computeConvex3PlaneIntersection } from "../../../../core/geom/3d/plane_computeConvex3PlaneIntersection.js";
3
-
4
- const v_000 = new Vector3();
5
- const v_001 = new Vector3();
6
- const v_010 = new Vector3();
7
- const v_011 = new Vector3();
8
- const v_100 = new Vector3();
9
- const v_101 = new Vector3();
10
- const v_110 = new Vector3();
11
- const v_111 = new Vector3();
1
+ import { plane_three_computeConvex3PlaneIntersection } from "../../../../core/geom/3d/plane/plane_computeConvex3PlaneIntersection.js";
12
2
 
13
3
  /**
14
4
  *
@@ -18,68 +8,60 @@ const v_111 = new Vector3();
18
8
  export function computeFrustumCorners(result, planes) {
19
9
 
20
10
  const plane_x0 = planes[0];
21
- const plane_x1 = planes[1];
22
-
23
11
  const plane_y0 = planes[2];
24
- const plane_y1 = planes[3];
25
-
26
12
  const plane_z0 = planes[4];
27
- const plane_z1 = planes[5];
28
13
 
29
- plane_three_computeConvex3PlaneIntersection(v_000,
14
+ plane_three_computeConvex3PlaneIntersection(result, 0,
30
15
  plane_x0,
31
16
  plane_y0,
32
17
  plane_z0
33
18
  );
34
19
 
35
- plane_three_computeConvex3PlaneIntersection(v_001,
20
+ const plane_z1 = planes[5];
21
+
22
+ plane_three_computeConvex3PlaneIntersection(result, 3,
36
23
  plane_x0,
37
24
  plane_y0,
38
25
  plane_z1
39
26
  );
40
27
 
41
- plane_three_computeConvex3PlaneIntersection(v_010,
28
+ const plane_y1 = planes[3];
29
+
30
+ plane_three_computeConvex3PlaneIntersection(result, 6,
42
31
  plane_x0,
43
32
  plane_y1,
44
33
  plane_z0
45
34
  );
46
35
 
47
- plane_three_computeConvex3PlaneIntersection(v_011,
36
+ plane_three_computeConvex3PlaneIntersection(result, 9,
48
37
  plane_x0,
49
38
  plane_y1,
50
39
  plane_z1
51
40
  );
52
41
 
53
- plane_three_computeConvex3PlaneIntersection(v_100,
42
+ const plane_x1 = planes[1];
43
+
44
+ plane_three_computeConvex3PlaneIntersection(result, 12,
54
45
  plane_x1,
55
46
  plane_y0,
56
47
  plane_z0
57
48
  );
58
49
 
59
- plane_three_computeConvex3PlaneIntersection(v_101,
50
+ plane_three_computeConvex3PlaneIntersection(result, 15,
60
51
  plane_x1,
61
52
  plane_y0,
62
53
  plane_z1
63
54
  );
64
55
 
65
- plane_three_computeConvex3PlaneIntersection(v_110,
56
+ plane_three_computeConvex3PlaneIntersection(result, 18,
66
57
  plane_x1,
67
58
  plane_y1,
68
59
  plane_z0
69
60
  );
70
61
 
71
- plane_three_computeConvex3PlaneIntersection(v_111,
62
+ plane_three_computeConvex3PlaneIntersection(result, 21,
72
63
  plane_x1,
73
64
  plane_y1,
74
65
  plane_z1
75
66
  );
76
-
77
- v_000.writeToArray(result, 0);
78
- v_001.writeToArray(result, 3);
79
- v_010.writeToArray(result, 6);
80
- v_011.writeToArray(result, 9);
81
- v_100.writeToArray(result, 12);
82
- v_101.writeToArray(result, 15);
83
- v_110.writeToArray(result, 18);
84
- v_111.writeToArray(result, 21);
85
67
  }
@@ -61,12 +61,22 @@ export class MaterialTransformer extends AbstractMaterialTransformer {
61
61
  }
62
62
 
63
63
  transform(source) {
64
+ let result = source;
65
+
64
66
  if (isLitMaterial(source)) {
65
67
 
66
- source.onBeforeCompile = composeCompile(source.onBeforeCompile, this.__on_before_compile);
68
+ result = source.clone();
69
+ // inherit uniforms directly
70
+
71
+ if (source.isShaderMaterial) {
72
+ result.uniforms = source.uniforms;
73
+ result.defines = source.defines;
74
+ }
75
+
76
+ result.onBeforeCompile = composeCompile(source.onBeforeCompile, this.__on_before_compile);
67
77
 
68
78
  }
69
79
 
70
- return source;
80
+ return result;
71
81
  }
72
82
  }
@@ -125,7 +125,7 @@ function makeConfig(engine) {
125
125
  new ClingToTerrainSystem(),
126
126
  new TerrainSystem(graphics, assetManager),
127
127
  new WaterSystem(graphics),
128
- new Trail2DSystem(graphics, assetManager),
128
+ new Trail2DSystem(engine),
129
129
  new Foliage2System(assetManager, graphics),
130
130
  new ViewportPositionSystem(graphics.viewport.size),
131
131
  new GridPosition2TransformSystem(),
@@ -98,10 +98,10 @@ function getFPStandard() {
98
98
  }
99
99
 
100
100
  const material_fp_standard = new FPlusStandardMaterial({
101
- color: 0xFFFF00,
102
- polygonOffset: true,
103
- depthWrite: false
104
- });
101
+ color: 0xFFFF00,
102
+ polygonOffset: true,
103
+ depthWrite: false
104
+ });
105
105
 
106
106
  fp_materials.push(material_fp_standard);
107
107
 
@@ -200,14 +200,14 @@ function addPointLight(position, radius, color, intensity = 1) {
200
200
  lm.addLight(light);
201
201
 
202
202
  const sphere_material = new LineBasicMaterial({
203
- depthTest: true,
204
- depthWrite: false,
205
- transparent: true,
206
- linewidth: 1,
207
- fog: false,
208
- color: light.color.toUint(),
209
- opacity: min2(intensity, 1)
210
- });
203
+ depthTest: true,
204
+ depthWrite: false,
205
+ transparent: true,
206
+ linewidth: 1,
207
+ fog: false,
208
+ color: light.color.toUint(),
209
+ opacity: min2(intensity, 1)
210
+ });
211
211
 
212
212
  const mesh = new Line(sphere_geometry, sphere_material);
213
213
 
@@ -233,39 +233,41 @@ function prepare_scene_0() {
233
233
 
234
234
  controls.minDistance = 2;
235
235
 
236
- for (let i = 0; i < 500; i++) {
237
- const radius = randomFloatBetween(random, 4, 4);
236
+ const bounds_size = 15;
237
+
238
+ for (let i = 0; i < 5000; i++) {
239
+ const radius = randomFloatBetween(random, 2, 2);
238
240
  const intensity = randomFloatBetween(random, 2, 2);
239
241
  addPointLight([
240
- randomFloatBetween(random, -20, 20),
241
- randomFloatBetween(random, -20, 20),
242
- randomFloatBetween(random, -20, 20),
243
- ],
244
- radius,
245
- `hsv(${random().toFixed(4)}, 0.8, 1)`,
246
- intensity
242
+ randomFloatBetween(random, -bounds_size, bounds_size),
243
+ randomFloatBetween(random, -bounds_size, bounds_size),
244
+ randomFloatBetween(random, -bounds_size, bounds_size),
245
+ ],
246
+ radius,
247
+ `hsv(${random().toFixed(4)}, 0.8, 1)`,
248
+ intensity
247
249
  );
248
250
  }
249
251
 
250
252
  for (let i = 0; i < 500; i++) {
251
253
 
252
254
  addKnot([
253
- randomFloatBetween(random, -20, 20),
254
- randomFloatBetween(random, -20, 20),
255
- randomFloatBetween(random, -20, 20)
256
- ], 0.5, [
257
- randomFloatBetween(random, 0, Math.PI),
258
- randomFloatBetween(random, 0, Math.PI),
259
- randomFloatBetween(random, 0, Math.PI)
260
- ]);
255
+ randomFloatBetween(random, -bounds_size, bounds_size),
256
+ randomFloatBetween(random, -bounds_size, bounds_size),
257
+ randomFloatBetween(random, -bounds_size, bounds_size)
258
+ ], 0.5, [
259
+ randomFloatBetween(random, 0, Math.PI),
260
+ randomFloatBetween(random, 0, Math.PI),
261
+ randomFloatBetween(random, 0, Math.PI)
262
+ ]);
261
263
  }
262
264
  }
263
265
 
264
266
  function prepare_scene_1() {
265
267
  addPointLight([
266
- 0, 0, -3
267
- ], 1,
268
- 0xFF0000
268
+ 0, 0, -3
269
+ ], 1,
270
+ 0xFF0000
269
271
  );
270
272
 
271
273
  // tight planes around the light
@@ -278,9 +280,9 @@ function prepare_scene_1() {
278
280
 
279
281
  function prepare_scene_3() {
280
282
  addPointLight([
281
- 0, 0, -4
282
- ], 1,
283
- 0xFF0000
283
+ 0, 0, -4
284
+ ], 1,
285
+ 0xFF0000
284
286
  );
285
287
 
286
288
  // tight planes around the light
@@ -288,8 +290,8 @@ function prepare_scene_3() {
288
290
  camera.far = 7;
289
291
 
290
292
  addKnot([
291
- 0, 0, -4
292
- ], 1, [0, 0, 0]);
293
+ 0, 0, -4
294
+ ], 1, [0, 0, 0]);
293
295
 
294
296
  // camera.position.set(0, 0, 0);
295
297
  camera.lookAt(0, 0, -5);
@@ -297,16 +299,16 @@ function prepare_scene_3() {
297
299
 
298
300
  function prepare_scene_2() {
299
301
  addPointLight([
300
- 1.5, 0, -4
301
- ], 1.5,
302
- 0xFF0000,
303
- 1
302
+ 1.5, 0, -4
303
+ ], 1.5,
304
+ 0xFF0000,
305
+ 1
304
306
  );
305
307
  addPointLight([
306
- -1.5, 0, -4
307
- ], 1.5,
308
- 0x00FF00,
309
- 1
308
+ -1.5, 0, -4
309
+ ], 1.5,
310
+ 0x00FF00,
311
+ 1
310
312
  );
311
313
 
312
314
  addKnot([0, 0, -5], 1, [0, 0, 0]);
@@ -324,16 +326,16 @@ function prepare_scene_5() {
324
326
 
325
327
 
326
328
  addPointLight([
327
- 1.5 + offset.x, 0 + offset.y, -4 + offset.z
328
- ], 1.5,
329
- 0xFF0000,
330
- 10
329
+ 1.5 + offset.x, 0 + offset.y, -4 + offset.z
330
+ ], 1.5,
331
+ 0xFF0000,
332
+ 10
331
333
  );
332
334
  addPointLight([
333
- -1.5 + offset.x, 0 + offset.y, -4 + offset.z
334
- ], 1.5,
335
- 0x00FF00,
336
- 10
335
+ -1.5 + offset.x, 0 + offset.y, -4 + offset.z
336
+ ], 1.5,
337
+ 0x00FF00,
338
+ 10
337
339
  );
338
340
 
339
341
  addKnot(
@@ -355,7 +357,6 @@ function prepare_scene_5() {
355
357
  }
356
358
 
357
359
 
358
-
359
360
  function addSponza() {
360
361
  const loader = new GLTFLoader();
361
362
 
@@ -420,13 +421,13 @@ function prepare_scene_4() {
420
421
  for (let i = 0; i < 2000; i++) {
421
422
  const radius = randomFloatBetween(random, 2, 2);
422
423
  addPointLight([
423
- randomFloatBetween(random, -18, 18),
424
- randomFloatBetween(random, -3, 16),
425
- randomFloatBetween(random, -11, 11),
426
- ],
427
- radius,
428
- `hsv(${random().toFixed(4)}, 0.8, 1)`,
429
- randomFloatBetween(random, 3, 3)
424
+ randomFloatBetween(random, -18, 18),
425
+ randomFloatBetween(random, -3, 16),
426
+ randomFloatBetween(random, -11, 11),
427
+ ],
428
+ radius,
429
+ `hsv(${random().toFixed(4)}, 0.8, 1)`,
430
+ randomFloatBetween(random, 3, 3)
430
431
  );
431
432
  }
432
433
 
@@ -460,13 +461,13 @@ function prepare_scene_6() {
460
461
 
461
462
 
462
463
  addPointLight([
463
- 11,
464
- 1,
465
- 0,
466
- ],
467
- 2,
468
- `hsv(0.5, 0.8, 1)`,
469
- 3
464
+ 11,
465
+ 1,
466
+ 0,
467
+ ],
468
+ 2,
469
+ `hsv(0.5, 0.8, 1)`,
470
+ 3
470
471
  );
471
472
 
472
473
  //
@@ -488,9 +489,9 @@ function prepare_scene_6() {
488
489
 
489
490
  function prepare_scene_7() {
490
491
  addSpotLight([
491
- 0, 0, -3
492
- ], [0, 0, 1],
493
- 0xFF0000
492
+ 0, 0, -3
493
+ ], [0, 0, 1],
494
+ 0xFF0000
494
495
  );
495
496
 
496
497
  // tight planes around the light
@@ -513,8 +514,8 @@ console.log("done");
513
514
 
514
515
 
515
516
  const renderer = new WebGLRenderer({
516
- antialias: true
517
- });
517
+ antialias: true
518
+ });
518
519
  // renderer.shadowMap.type = VSMShadowMap;
519
520
  // renderer.shadowMap.enabled = true;
520
521
  renderer.sortObjects = false;
@@ -679,32 +680,32 @@ renderer.domElement.addEventListener(MouseEvents.DoubleClick, () => {
679
680
  });
680
681
 
681
682
  domify(lightClusterWidget.domElement).css({
682
- position: "absolute",
683
- zIndex: 2,
684
- bottom: 0,
685
- right: 0
686
- });
683
+ position: "absolute",
684
+ zIndex: 2,
685
+ bottom: 0,
686
+ right: 0
687
+ });
687
688
 
688
689
  document.body.appendChild(lightClusterWidget.domElement);
689
690
 
690
691
  const debugger_button = new ButtonView({
691
- action() {
692
- if (screenGrid.domElement.parentNode !== null) {
693
- document.body.removeChild(screenGrid.domElement);
694
- } else {
695
- document.body.appendChild(screenGrid.domElement);
696
- }
697
- },
698
- name: "debugger",
699
- css: {
700
- position: "absolute",
701
- color: "white",
702
- background: "rgba(0,0,0,0.5)",
703
- zIndex: 2,
704
- top: 0,
705
- left: 0
706
- }
707
- });
692
+ action() {
693
+ if (screenGrid.domElement.parentNode !== null) {
694
+ document.body.removeChild(screenGrid.domElement);
695
+ } else {
696
+ document.body.appendChild(screenGrid.domElement);
697
+ }
698
+ },
699
+ name: "debugger",
700
+ css: {
701
+ position: "absolute",
702
+ color: "white",
703
+ background: "rgba(0,0,0,0.5)",
704
+ zIndex: 2,
705
+ top: 0,
706
+ left: 0
707
+ }
708
+ });
708
709
 
709
710
  debugger_button.link();
710
711