@woosh/meep-engine 2.93.2 → 2.94.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 (110) hide show
  1. package/build/bundle-worker-terrain.js +1 -1
  2. package/build/meep.cjs +296 -233
  3. package/build/meep.min.js +1 -1
  4. package/build/meep.module.js +296 -233
  5. package/package.json +1 -1
  6. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  7. package/src/core/bvh2/bvh3/BVH.js +4 -2
  8. package/src/core/bvh2/bvh3/build_triangle_morton_codes.d.ts.map +1 -1
  9. package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +2 -1
  10. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  11. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +12 -1
  12. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
  13. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +11 -1
  14. package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.d.ts +14 -0
  15. package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.d.ts.map +1 -0
  16. package/src/core/bvh2/bvh3/ebvh_geometry_query_nearest_triangle_ray.js +146 -0
  17. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts +16 -0
  18. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.d.ts.map +1 -0
  19. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray.js +90 -0
  20. package/src/core/color/Color.d.ts.map +1 -1
  21. package/src/core/color/Color.js +17 -7
  22. package/src/core/geom/2d/bvh/BVH2D.d.ts.map +1 -1
  23. package/src/core/geom/2d/bvh/BVH2D.js +24 -29
  24. package/src/core/geom/2d/bvh/BVH2D.spec.js +10 -9
  25. package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.d.ts +2 -0
  26. package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.d.ts.map +1 -0
  27. package/src/core/geom/2d/bvh/bvh2d_query_all_data_by_circle.spec.js +89 -0
  28. package/src/core/geom/2d/quad-tree/QuadTreeNode.spec.js +1 -1
  29. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  30. package/src/core/geom/3d/aabb/AABB3.js +8 -1
  31. package/src/core/geom/3d/aabb/aabb3_array_combine.d.ts.map +1 -1
  32. package/src/core/geom/3d/aabb/aabb3_array_combine.js +5 -0
  33. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentric.js +2 -0
  34. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.d.ts.map +1 -1
  35. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricEdge.js +9 -1
  36. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.d.ts +16 -0
  37. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.d.ts.map +1 -0
  38. package/src/core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js +55 -0
  39. package/src/core/math/build_gaussian_kernel_1d.d.ts +8 -0
  40. package/src/core/math/build_gaussian_kernel_1d.d.ts.map +1 -0
  41. package/src/core/math/build_gaussian_kernel_1d.js +26 -0
  42. package/src/core/math/build_gaussian_kernel_2d.d.ts +10 -0
  43. package/src/core/math/build_gaussian_kernel_2d.d.ts.map +1 -0
  44. package/src/core/math/build_gaussian_kernel_2d.js +55 -0
  45. package/src/core/math/nextOdd.d.ts +8 -0
  46. package/src/core/math/nextOdd.d.ts.map +1 -0
  47. package/src/core/math/nextOdd.js +15 -0
  48. package/src/core/math/nextOdd.spec.d.ts +2 -0
  49. package/src/core/math/nextOdd.spec.d.ts.map +1 -0
  50. package/src/core/math/nextOdd.spec.js +9 -0
  51. package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -1
  52. package/src/engine/animation/clip/ecd_bind_animation_curve.js +7 -3
  53. package/src/engine/animation/curve/prototypeGLTF.js +18 -11
  54. package/src/engine/ecs/Entity.js +1 -1
  55. package/src/engine/ecs/EntityComponentDataset.js +0 -14
  56. package/src/engine/ecs/computeComponentClassName.d.ts +2 -0
  57. package/src/engine/ecs/computeComponentClassName.d.ts.map +1 -0
  58. package/src/engine/ecs/computeComponentClassName.js +13 -0
  59. package/src/engine/graphics/ecs/light/binding/LightBinding.d.ts +2 -0
  60. package/src/engine/graphics/ecs/light/binding/LightBinding.d.ts.map +1 -1
  61. package/src/engine/graphics/ecs/light/binding/LightBinding.js +16 -0
  62. package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.d.ts +13 -2
  63. package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.d.ts.map +1 -1
  64. package/src/engine/graphics/ecs/light/binding/fp/FPLightBinding.js +37 -4
  65. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
  66. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +12 -8
  67. package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
  68. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.d.ts +0 -9
  69. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.d.ts.map +1 -1
  70. package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +100 -129
  71. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
  72. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +6 -4
  73. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +11 -4
  74. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts +2 -2
  75. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +2 -2
  76. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  77. package/src/engine/graphics/texture/sampler/Sampler2D.js +6 -4
  78. package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.d.ts.map +1 -1
  79. package/src/engine/graphics/texture/sampler/convertSampler2D2DataURL.js +1 -2
  80. package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.d.ts +2 -2
  81. package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.d.ts.map +1 -1
  82. package/src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js +3 -3
  83. package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.d.ts.map +1 -1
  84. package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js +5 -31
  85. package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.d.ts +3 -6
  86. package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.d.ts.map +1 -1
  87. package/src/engine/graphics/texture/virtual/VirtualTextureMaterial.js +8 -27
  88. package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.d.ts +4 -0
  89. package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.d.ts.map +1 -1
  90. package/src/engine/graphics/texture/virtual/VirtualTextureMemoryMapping.js +12 -0
  91. package/src/engine/graphics/texture/virtual/VirtualTextureSystem.d.ts +29 -0
  92. package/src/engine/graphics/texture/virtual/VirtualTextureSystem.d.ts.map +1 -0
  93. package/src/engine/graphics/texture/virtual/VirtualTextureSystem.js +102 -0
  94. package/src/engine/graphics/texture/virtual/VirtualTextureUsageUpdater.js +1 -1
  95. package/src/engine/graphics/texture/virtual/prototype.js +221 -79
  96. package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
  97. package/src/generation/filtering/numeric/CellFilterCache.js +7 -7
  98. package/src/generation/filtering/numeric/complex/CellFilterFXAA.d.ts.map +1 -1
  99. package/src/generation/filtering/numeric/complex/CellFilterFXAA.js +9 -6
  100. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts +1 -13
  101. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts.map +1 -1
  102. package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +39 -111
  103. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
  104. package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +6 -5
  105. package/src/generation/grid/generation/util/buildDistanceMapToObjective.d.ts +1 -1
  106. package/src/generation/grid/generation/util/buildDistanceMapToObjective.d.ts.map +1 -1
  107. package/src/generation/grid/generation/util/buildDistanceMapToObjective.js +5 -12
  108. package/src/core/math/makeNextOdd.d.ts +0 -8
  109. package/src/core/math/makeNextOdd.d.ts.map +0 -1
  110. package/src/core/math/makeNextOdd.js +0 -15
@@ -49003,13 +49003,6 @@ function typedArrayToDataType(v) {
49003
49003
  }
49004
49004
  }
49005
49005
 
49006
- /**
49007
- *
49008
- * Produces a proportional mix of 2 values, a*(1-portion) + b*portion
49009
- * Same as lerp
49010
- */
49011
- const mix = lerp$1;
49012
-
49013
49006
  /**
49014
49007
  * Based on code from reddit https://www.reddit.com/r/javascript/comments/jxa8x/bicubic_interpolation/
49015
49008
  * @param {number} t ratio
@@ -49299,6 +49292,7 @@ class Sampler2D {
49299
49292
  }
49300
49293
 
49301
49294
  /**
49295
+ * TODO there is an oversaturation bug in here somewhere, prefer to use linear sampling for now instead
49302
49296
  * Bicubic-filtered sampling
49303
49297
  * @param {number} x
49304
49298
  * @param {number} y
@@ -49487,6 +49481,7 @@ class Sampler2D {
49487
49481
  const q0 = data[i0];
49488
49482
 
49489
49483
  if (x0 === x1 && y0 === y1) {
49484
+ // exactly sampled in the center of the pixel, no interpolation required
49490
49485
  return q0;
49491
49486
  }
49492
49487
 
@@ -49508,10 +49503,10 @@ class Sampler2D {
49508
49503
  const p1 = data[j1];
49509
49504
 
49510
49505
  // perform Bi-Linear interpolation
49511
- const s0 = mix(q0, q1, xd);
49512
- const s1 = mix(p0, p1, xd);
49506
+ const s0 = lerp$1(q0, q1, xd);
49507
+ const s1 = lerp$1(p0, p1, xd);
49513
49508
 
49514
- return mix(s0, s1, yd);
49509
+ return lerp$1(s0, s1, yd);
49515
49510
  }
49516
49511
 
49517
49512
  /**
@@ -52549,8 +52544,10 @@ class BVH {
52549
52544
  * @param {number} index_b
52550
52545
  */
52551
52546
  node_set_combined_aabb(destination, index_a, index_b) {
52547
+
52552
52548
  const address_a = ELEMENT_WORD_COUNT * index_a;
52553
52549
  const address_b = ELEMENT_WORD_COUNT * index_b;
52550
+ const address_destination = ELEMENT_WORD_COUNT * destination;
52554
52551
 
52555
52552
  const float32 = this.__data_float32;
52556
52553
 
@@ -52578,7 +52575,6 @@ class BVH {
52578
52575
  const b_z1 = float32[address_b + 5];
52579
52576
  const z1 = max2(a_z1, b_z1);
52580
52577
 
52581
- const address_destination = destination * ELEMENT_WORD_COUNT;
52582
52578
 
52583
52579
  float32[address_destination] = x0;
52584
52580
  float32[address_destination + 1] = y0;
@@ -53321,6 +53317,95 @@ function clamp01(value) {
53321
53317
  }
53322
53318
  }
53323
53319
 
53320
+ /**
53321
+ * Returns lowest value out of 3 supplied
53322
+ * @param {number} a
53323
+ * @param {number} b
53324
+ * @param {number} c
53325
+ * @returns {number}
53326
+ */
53327
+ function min3(a, b, c) {
53328
+
53329
+ let v = a;
53330
+ if (v > b) {
53331
+ v = b;
53332
+ }
53333
+ if (v > c) {
53334
+ v = c;
53335
+ }
53336
+ return v;
53337
+ }
53338
+
53339
+ /**
53340
+ * Convert a decimal value to hex
53341
+ * @param {number} c generally expects b byte value, 0-255
53342
+ * @returns {string} zero-padded value, for example instead of "0", will return "00" and instead of "F" will return "0F"
53343
+ */
53344
+ function dec2hex(c) {
53345
+ const hex = Math.round(c).toString(16);
53346
+ return hex.length === 1 ? "0" + hex : hex;
53347
+ }
53348
+
53349
+ /**
53350
+ * Takes values in 0..255 range
53351
+ * @param {number} r
53352
+ * @param {number} g
53353
+ * @param {number} b
53354
+ * @returns {string}
53355
+ */
53356
+ function rgb2hex(r, g, b) {
53357
+
53358
+ return dec2hex(r) + dec2hex(g) + dec2hex(b);
53359
+ }
53360
+
53361
+ /**
53362
+ *
53363
+ * @param {number} r 0 to 255
53364
+ * @param {number} g 0 to 255
53365
+ * @param {number} b 0 to 255
53366
+ * @returns {{h: number, s: number, v: number}}
53367
+ */
53368
+ function rgb2hsv(r, g, b) {
53369
+
53370
+ const _r = uint82float(r);
53371
+ const _g = uint82float(g);
53372
+ const _b = uint82float(b);
53373
+
53374
+
53375
+ const max = Math.max(_r, _g, _b);
53376
+ const min = Math.min(_r, _g, _b);
53377
+
53378
+ let h, s, v = max;
53379
+
53380
+ const d = max - min;
53381
+
53382
+ s = max === 0 ? 0 : d / max;
53383
+
53384
+ if (max === min) {
53385
+ h = 0; // achromatic
53386
+ } else {
53387
+ switch (max) {
53388
+ case _r:
53389
+ h = (_g - _b) / d + (_g < _b ? 6 : 0);
53390
+ break;
53391
+ case _g:
53392
+ h = (_b - _r) / d + 2;
53393
+ break;
53394
+ case _b:
53395
+ h = (_r - _g) / d + 4;
53396
+ break;
53397
+ }
53398
+
53399
+ h /= 6;
53400
+ }
53401
+
53402
+ return {
53403
+ h,
53404
+ s,
53405
+ v
53406
+ };
53407
+ }
53408
+
53324
53409
  /**
53325
53410
  *
53326
53411
  * @param {number} h from 0 to 1
@@ -53495,73 +53580,6 @@ function parse_color(c) {
53495
53580
  return result;
53496
53581
  }
53497
53582
 
53498
- /**
53499
- * Returns lowest value out of 3 supplied
53500
- * @param {number} a
53501
- * @param {number} b
53502
- * @param {number} c
53503
- * @returns {number}
53504
- */
53505
- function min3(a, b, c) {
53506
-
53507
- let v = a;
53508
- if (v > b) {
53509
- v = b;
53510
- }
53511
- if (v > c) {
53512
- v = c;
53513
- }
53514
- return v;
53515
- }
53516
-
53517
- /**
53518
- *
53519
- * @param {number} r 0 to 255
53520
- * @param {number} g 0 to 255
53521
- * @param {number} b 0 to 255
53522
- * @returns {{h: number, s: number, v: number}}
53523
- */
53524
- function rgb2hsv(r, g, b) {
53525
-
53526
- const _r = uint82float(r);
53527
- const _g = uint82float(g);
53528
- const _b = uint82float(b);
53529
-
53530
-
53531
- const max = Math.max(_r, _g, _b);
53532
- const min = Math.min(_r, _g, _b);
53533
-
53534
- let h, s, v = max;
53535
-
53536
- const d = max - min;
53537
-
53538
- s = max === 0 ? 0 : d / max;
53539
-
53540
- if (max === min) {
53541
- h = 0; // achromatic
53542
- } else {
53543
- switch (max) {
53544
- case _r:
53545
- h = (_g - _b) / d + (_g < _b ? 6 : 0);
53546
- break;
53547
- case _g:
53548
- h = (_b - _r) / d + 2;
53549
- break;
53550
- case _b:
53551
- h = (_r - _g) / d + 4;
53552
- break;
53553
- }
53554
-
53555
- h /= 6;
53556
- }
53557
-
53558
- return {
53559
- h,
53560
- s,
53561
- v
53562
- };
53563
- }
53564
-
53565
53583
  /**
53566
53584
  *
53567
53585
  * @param {number} r in 0..1 range
@@ -53580,28 +53598,6 @@ function rgb2uint24(r, g, b) {
53580
53598
  ;
53581
53599
  }
53582
53600
 
53583
- /**
53584
- * Convert a decimal value to hex
53585
- * @param {number} c generally expects b byte value, 0-255
53586
- * @returns {string} zero-padded value, for example instead of "0", will return "00" and instead of "F" will return "0F"
53587
- */
53588
- function dec2hex(c) {
53589
- const hex = Math.round(c).toString(16);
53590
- return hex.length === 1 ? "0" + hex : hex;
53591
- }
53592
-
53593
- /**
53594
- * Takes values in 0..255 range
53595
- * @param {number} r
53596
- * @param {number} g
53597
- * @param {number} b
53598
- * @returns {string}
53599
- */
53600
- function rgb2hex(r, g, b) {
53601
-
53602
- return dec2hex(r) + dec2hex(g) + dec2hex(b);
53603
- }
53604
-
53605
53601
  function convert(c) {
53606
53602
  return (c < 0.0031308) ? c * 12.92 : 1.055 * (Math.pow(c, 0.41666)) - 0.055;
53607
53603
  }
@@ -53650,7 +53646,7 @@ class Color {
53650
53646
  * @param {number} r value from 0 to 1
53651
53647
  * @param {number} g value from 0 to 1
53652
53648
  * @param {number} b value from 0 to 1
53653
- * @param {number} [a] value from 0 to 1
53649
+ * @param {number} [a] value from 0 to 1 Alpha channel (transparency)
53654
53650
  */
53655
53651
  constructor(r = 0, g = 0, b = 0, a = 1) {
53656
53652
  /**
@@ -53750,6 +53746,14 @@ class Color {
53750
53746
  this.a = v;
53751
53747
  }
53752
53748
 
53749
+ /**
53750
+ * Pretending to be an array
53751
+ * @return {number}
53752
+ */
53753
+ get length() {
53754
+ return 4;
53755
+ }
53756
+
53753
53757
  /**
53754
53758
  *
53755
53759
  * @param {number} r
@@ -54019,6 +54023,7 @@ class Color {
54019
54023
  * @param {number} value
54020
54024
  */
54021
54025
  fromUint(value) {
54026
+
54022
54027
  const r = value >> 16;
54023
54028
  const g = (value >> 8) & 0xFF;
54024
54029
  const b = (value) & 0xFF;
@@ -56343,7 +56348,7 @@ class AABB3 {
56343
56348
  * @param {number} y
56344
56349
  * @param {number} z
56345
56350
  */
56346
- _translate(x,y,z){
56351
+ _translate(x, y, z) {
56347
56352
  this.setBounds(
56348
56353
  this.x0 + x, this.y0 + y, this.z0 + z,
56349
56354
  this.x1 + x, this.y1 + y, this.z1 + z
@@ -56956,7 +56961,14 @@ class AABB3 {
56956
56961
  * @readonly
56957
56962
  * @type {boolean}
56958
56963
  */
56959
- AABB3.prototype.isAABB3 = true;
56964
+ AABB3.prototype.isAABB3 = true;
56965
+
56966
+ /**
56967
+ * Pretending to be an array
56968
+ * @readonly
56969
+ * @type {number}
56970
+ */
56971
+ AABB3.prototype.length = 6;
56960
56972
 
56961
56973
  /**
56962
56974
  *
@@ -72626,7 +72638,7 @@ class Entity {
72626
72638
  const component = this.getComponent(klass);
72627
72639
 
72628
72640
  if (component === null) {
72629
- throw new Error(`Component of given class not found`);
72641
+ throw new Error(`Component of given class '${computeComponentClassName(klass)}' not found`);
72630
72642
  }
72631
72643
 
72632
72644
  return component;
@@ -111131,6 +111143,101 @@ class SystemEntityContext {
111131
111143
  }
111132
111144
  }
111133
111145
 
111146
+ class PointLight extends AbstractLight {
111147
+ constructor() {
111148
+ super();
111149
+
111150
+ /**
111151
+ * @readonly
111152
+ * @type {Vector3}
111153
+ */
111154
+ this.position = new Vector3$1();
111155
+
111156
+ /**
111157
+ *
111158
+ * @type {Vector1}
111159
+ */
111160
+ this.radius = new Vector1(1);
111161
+
111162
+ /**
111163
+ * @readonly
111164
+ * @type {Color}
111165
+ */
111166
+ this.color = new Color(1, 1, 1);
111167
+
111168
+ /**
111169
+ *
111170
+ * @type {Vector1}
111171
+ */
111172
+ this.intensity = new Vector1(1);
111173
+ }
111174
+
111175
+ getCenter(result) {
111176
+ this.position.writeToArray(result, 0);
111177
+ }
111178
+
111179
+ getAABB(result) {
111180
+ const r = this.radius.getValue();
111181
+ const p = this.position;
111182
+
111183
+ const center_x = p.x;
111184
+ const center_y = p.y;
111185
+ const center_z = p.z;
111186
+
111187
+ result[0] = center_x - r;
111188
+ result[1] = center_y - r;
111189
+ result[2] = center_z - r;
111190
+
111191
+ result[3] = center_x + r;
111192
+ result[4] = center_y + r;
111193
+ result[5] = center_z + r;
111194
+ }
111195
+
111196
+ onDimensionChanged(listener, context) {
111197
+ this.position.onChanged.add(listener, context);
111198
+ this.radius.onChanged.add(listener, context);
111199
+ }
111200
+
111201
+ offDimensionChanged(listener, context) {
111202
+ this.position.onChanged.remove(listener, context);
111203
+ this.radius.onChanged.remove(listener, context);
111204
+ }
111205
+
111206
+ /**
111207
+ *
111208
+ * @param {number[]|Float32Array|Float64Array} destination
111209
+ * @param {number} address
111210
+ * @returns {number} number of used slots
111211
+ */
111212
+ toArray(destination, address) {
111213
+ const position = this.position;
111214
+
111215
+ destination[address] = position.x;
111216
+ destination[address + 1] = position.y;
111217
+ destination[address + 2] = position.z;
111218
+
111219
+ destination[address + 3] = this.radius.getValue();
111220
+
111221
+ const color = this.color;
111222
+
111223
+ destination[address + 4] = color.r;
111224
+ destination[address + 5] = color.g;
111225
+ destination[address + 6] = color.b;
111226
+
111227
+ destination[address + 7] = this.intensity.getValue();
111228
+
111229
+ return 8;
111230
+ }
111231
+ }
111232
+
111233
+ /**
111234
+ * @readonly
111235
+ * @type {boolean}
111236
+ */
111237
+ PointLight.prototype.isPointLight = true;
111238
+
111239
+ PointLight.prototype.ENCODED_SLOT_COUNT = 8;
111240
+
111134
111241
  class LightBinding {
111135
111242
  constructor() {
111136
111243
  /**
@@ -111147,6 +111254,14 @@ class LightBinding {
111147
111254
  this.__c_light = null;
111148
111255
  }
111149
111256
 
111257
+ get scaled_distance() {
111258
+ const scale = this.__c_transform.scale;
111259
+ const scale_magnitude = max3(scale.x, scale.y, scale.z);
111260
+ const light_radius = this.__c_light.distance.getValue();
111261
+
111262
+ return light_radius * scale_magnitude;
111263
+ }
111264
+
111150
111265
  set component_transform(v) {
111151
111266
  this.__c_transform = v;
111152
111267
  }
@@ -111170,6 +111285,7 @@ class LightBinding {
111170
111285
  link(ctx) {
111171
111286
  this.__c_transform.position.onChanged.add(this.__apply_position, this);
111172
111287
  this.__c_transform.rotation.onChanged.add(this.__apply_rotation, this);
111288
+ this.__c_transform.rotation.onChanged.add(this.__apply_scale, this);
111173
111289
 
111174
111290
  const l = this.__c_light;
111175
111291
 
@@ -111195,6 +111311,7 @@ class LightBinding {
111195
111311
 
111196
111312
  this.__apply_position();
111197
111313
  this.__apply_rotation();
111314
+ this.__apply_scale();
111198
111315
 
111199
111316
  this.applySettings(ctx.system.settings);
111200
111317
  }
@@ -111206,6 +111323,7 @@ class LightBinding {
111206
111323
  unlink(ctx) {
111207
111324
  this.__c_transform.position.onChanged.remove(this.__apply_position, this);
111208
111325
  this.__c_transform.rotation.onChanged.remove(this.__apply_rotation, this);
111326
+ this.__c_transform.rotation.onChanged.remove(this.__apply_scale, this);
111209
111327
 
111210
111328
  this.__c_light.intensity.onChanged.remove(this.__apply_intensity, this);
111211
111329
  this.__c_light.color.onChanged.remove(this.__apply_color, this);
@@ -111223,6 +111341,10 @@ class LightBinding {
111223
111341
 
111224
111342
  }
111225
111343
 
111344
+ __apply_scale(){
111345
+
111346
+ }
111347
+
111226
111348
  __apply_intensity() {
111227
111349
 
111228
111350
  }
@@ -111248,106 +111370,22 @@ class LightBinding {
111248
111370
  }
111249
111371
  }
111250
111372
 
111251
- class PointLight extends AbstractLight {
111373
+ class FPLightBinding extends LightBinding {
111252
111374
  constructor() {
111253
111375
  super();
111254
111376
 
111255
- /**
111256
- * @readonly
111257
- * @type {Vector3}
111258
- */
111259
- this.position = new Vector3$1();
111260
-
111261
111377
  /**
111262
111378
  *
111263
- * @type {Vector1}
111264
- */
111265
- this.radius = new Vector1(1);
111266
-
111267
- /**
111268
- * @readonly
111269
- * @type {Color}
111379
+ * @type {PointLight|null}
111380
+ * @private
111270
111381
  */
111271
- this.color = new Color(1, 1, 1);
111382
+ this.__light = null;
111272
111383
 
111273
111384
  /**
111274
111385
  *
111275
- * @type {Vector1}
111386
+ * @type {SignalBinding[]}
111276
111387
  */
111277
- this.intensity = new Vector1(1);
111278
- }
111279
-
111280
- getCenter(result) {
111281
- this.position.writeToArray(result, 0);
111282
- }
111283
-
111284
- getAABB(result) {
111285
- const r = this.radius.getValue();
111286
- const p = this.position;
111287
-
111288
- const center_x = p.x;
111289
- const center_y = p.y;
111290
- const center_z = p.z;
111291
-
111292
- result[0] = center_x - r;
111293
- result[1] = center_y - r;
111294
- result[2] = center_z - r;
111295
-
111296
- result[3] = center_x + r;
111297
- result[4] = center_y + r;
111298
- result[5] = center_z + r;
111299
- }
111300
-
111301
- onDimensionChanged(listener, context) {
111302
- this.position.onChanged.add(listener, context);
111303
- this.radius.onChanged.add(listener, context);
111304
- }
111305
-
111306
- offDimensionChanged(listener, context) {
111307
- this.position.onChanged.remove(listener, context);
111308
- this.radius.onChanged.remove(listener, context);
111309
- }
111310
-
111311
- /**
111312
- *
111313
- * @param {number[]|Float32Array|Float64Array} destination
111314
- * @param {number} address
111315
- * @returns {number} number of used slots
111316
- */
111317
- toArray(destination, address) {
111318
- const position = this.position;
111319
-
111320
- destination[address] = position.x;
111321
- destination[address + 1] = position.y;
111322
- destination[address + 2] = position.z;
111323
-
111324
- destination[address + 3] = this.radius.getValue();
111325
-
111326
- const color = this.color;
111327
-
111328
- destination[address + 4] = color.r;
111329
- destination[address + 5] = color.g;
111330
- destination[address + 6] = color.b;
111331
-
111332
- destination[address + 7] = this.intensity.getValue();
111333
-
111334
- return 8;
111335
- }
111336
- }
111337
-
111338
- /**
111339
- * @readonly
111340
- * @type {boolean}
111341
- */
111342
- PointLight.prototype.isPointLight = true;
111343
-
111344
- PointLight.prototype.ENCODED_SLOT_COUNT = 8;
111345
-
111346
- class FPLightBinding extends LightBinding {
111347
- constructor() {
111348
- super();
111349
-
111350
- this.__light = null;
111388
+ this.bindings = [];
111351
111389
  }
111352
111390
 
111353
111391
  /**
@@ -111359,6 +111397,10 @@ class FPLightBinding extends LightBinding {
111359
111397
  return ctx.system.__plugin.getValue();
111360
111398
  }
111361
111399
 
111400
+ #updateDistance() {
111401
+ this.__light.radius.set(this.scaled_distance);
111402
+ }
111403
+
111362
111404
  link(ctx) {
111363
111405
  /**
111364
111406
  *
@@ -111371,11 +111413,17 @@ class FPLightBinding extends LightBinding {
111371
111413
  const pl = new PointLight();
111372
111414
 
111373
111415
  const cLight = this.__c_light;
111416
+ const cTransform = this.__c_transform;
111417
+
111418
+ this.bindings.push(
111419
+ new SignalBinding(cLight.distance.onChanged, this.#updateDistance, this),
111420
+ new SignalBinding(cTransform.scale.onChanged, this.#updateDistance, this)
111421
+ );
111374
111422
 
111375
111423
  pl.intensity = cLight.intensity;
111376
111424
  pl.color = cLight.color;
111377
- pl.radius = cLight.distance;
111378
- pl.position = this.__c_transform.position;
111425
+
111426
+ pl.position = cTransform.position;
111379
111427
 
111380
111428
  /**
111381
111429
  *
@@ -111384,9 +111432,15 @@ class FPLightBinding extends LightBinding {
111384
111432
  */
111385
111433
  cLight.__fp_light = pl;
111386
111434
 
111435
+ this.__light = pl;
111436
+
111437
+ this.#updateDistance();
111438
+
111387
111439
  lightManager.addLight(pl);
111388
111440
 
111389
- this.__light = pl;
111441
+ for (let i = 0; i < this.bindings.length; i++) {
111442
+ this.bindings[i].link();
111443
+ }
111390
111444
  }
111391
111445
 
111392
111446
  unlink(ctx) {
@@ -111399,7 +111453,47 @@ class FPLightBinding extends LightBinding {
111399
111453
  const lightManager = fp.getLightManager();
111400
111454
 
111401
111455
  lightManager.removeLight(this.__light);
111456
+
111457
+ for (let i = 0; i < this.bindings.length; i++) {
111458
+ this.bindings[i].unlink();
111459
+ }
111460
+ this.bindings.splice(0, this.bindings.length);
111461
+ }
111462
+ }
111463
+
111464
+ class ShadowMap {
111465
+ constructor() {
111466
+ /**
111467
+ *
111468
+ * @type {CameraView[]}
111469
+ */
111470
+ this.views = [];
111471
+
111472
+
111473
+ }
111474
+ }
111475
+
111476
+ /**
111477
+ *
111478
+ * @param {Light} component
111479
+ * @param {Quaternion} r
111480
+ */
111481
+ function applyRotation(component, r) {
111482
+ const l = component.__threeObject;
111483
+
111484
+ r.toEulerAnglesXYZ(l.rotation);
111485
+
111486
+ if (l.target !== undefined) {
111487
+
111488
+ const targetPosition = l.target.position;
111489
+
111490
+ targetPosition.set(0, 0, 1).applyQuaternion(r);
111491
+ targetPosition.set(l.position.x + targetPosition.x, l.position.y + targetPosition.y, l.position.z + targetPosition.z);
111492
+
111493
+ l.target.updateMatrixWorld(true);
111402
111494
  }
111495
+
111496
+ threeUpdateTransform(component.__threeObject);
111403
111497
  }
111404
111498
 
111405
111499
  /**
@@ -111451,41 +111545,6 @@ function threeEnsureLightObject(component, cache) {
111451
111545
  }
111452
111546
  }
111453
111547
 
111454
- /**
111455
- *
111456
- * @param {Light} component
111457
- * @param {Quaternion} r
111458
- */
111459
- function applyRotation(component, r) {
111460
- const l = component.__threeObject;
111461
-
111462
- r.toEulerAnglesXYZ(l.rotation);
111463
-
111464
- if (l.target !== undefined) {
111465
-
111466
- const targetPosition = l.target.position;
111467
-
111468
- targetPosition.set(0, 0, 1).applyQuaternion(r);
111469
- targetPosition.set(l.position.x + targetPosition.x, l.position.y + targetPosition.y, l.position.z + targetPosition.z);
111470
-
111471
- l.target.updateMatrixWorld(true);
111472
- }
111473
-
111474
- threeUpdateTransform(component.__threeObject);
111475
- }
111476
-
111477
- class ShadowMap {
111478
- constructor() {
111479
- /**
111480
- *
111481
- * @type {CameraView[]}
111482
- */
111483
- this.views = [];
111484
-
111485
-
111486
- }
111487
- }
111488
-
111489
111548
  const shadow_scene = new Scene$1();
111490
111549
  shadow_scene.autoUpdate = false;
111491
111550
  shadow_scene.matrixAutoUpdate = false;
@@ -111625,7 +111684,7 @@ class ThreeLightBinding extends LightBinding {
111625
111684
  }
111626
111685
 
111627
111686
  __apply_distance(v) {
111628
- this.__three_getLight().distance = this.__c_light.distance.getValue();
111687
+ this.__three_getLight().distance = this.scaled_distance;
111629
111688
  }
111630
111689
 
111631
111690
  __apply_angle() {
@@ -111792,6 +111851,10 @@ class ThreeLightBinding extends LightBinding {
111792
111851
  applyRotation(this.__c_light, this.__c_transform.rotation);
111793
111852
  }
111794
111853
 
111854
+ __apply_scale() {
111855
+ this.__three_getLight().distance = this.scaled_distance;
111856
+ }
111857
+
111795
111858
  applySettings(settings) {
111796
111859
  const light = this.__three_getLight();
111797
111860