@flighthq/lighting 0.5.1-next.920.da8f530 → 0.6.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 (80) hide show
  1. package/README.md +2 -2
  2. package/dist/.tsbuildinfo.contract +1 -0
  3. package/dist/.tsbuildinfo.runtime +1 -0
  4. package/dist/ambientLight.d.ts +2 -1
  5. package/dist/ambientLight.d.ts.map +1 -1
  6. package/dist/ambientLight.js +3 -3
  7. package/dist/ambientLight.js.map +1 -1
  8. package/dist/areaLight.d.ts +3 -1
  9. package/dist/areaLight.d.ts.map +1 -1
  10. package/dist/areaLight.js +4 -4
  11. package/dist/areaLight.js.map +1 -1
  12. package/dist/contract.d.ts +20 -17
  13. package/dist/contract.d.ts.map +1 -1
  14. package/dist/contract.js +20 -17
  15. package/dist/contract.js.map +1 -1
  16. package/dist/contract.lighting-types.d.ts +2 -0
  17. package/dist/contract.lighting-types.d.ts.map +1 -0
  18. package/dist/contract.lighting-types.js +4 -0
  19. package/dist/contract.lighting-types.js.map +1 -0
  20. package/dist/directionalLight.d.ts +2 -1
  21. package/dist/directionalLight.d.ts.map +1 -1
  22. package/dist/directionalLight.js +3 -3
  23. package/dist/directionalLight.js.map +1 -1
  24. package/dist/environment.d.ts +2 -1
  25. package/dist/environment.d.ts.map +1 -1
  26. package/dist/environment.js +3 -3
  27. package/dist/environment.js.map +1 -1
  28. package/dist/hemisphereLight.d.ts +2 -1
  29. package/dist/hemisphereLight.d.ts.map +1 -1
  30. package/dist/hemisphereLight.js +3 -3
  31. package/dist/hemisphereLight.js.map +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/lightAnalysis.d.ts +2 -1
  37. package/dist/lightAnalysis.d.ts.map +1 -1
  38. package/dist/lightAnalysis.js +1 -1
  39. package/dist/lightAnalysis.js.map +1 -1
  40. package/dist/lightIntensity.d.ts +3 -1
  41. package/dist/lightIntensity.d.ts.map +1 -1
  42. package/dist/lightIntensity.js +19 -1
  43. package/dist/lightIntensity.js.map +1 -1
  44. package/dist/lightProbe.d.ts +69 -0
  45. package/dist/lightProbe.d.ts.map +1 -0
  46. package/dist/lightProbe.js +229 -0
  47. package/dist/lightProbe.js.map +1 -0
  48. package/dist/pointLight.d.ts +2 -1
  49. package/dist/pointLight.d.ts.map +1 -1
  50. package/dist/pointLight.js +8 -4
  51. package/dist/pointLight.js.map +1 -1
  52. package/dist/sceneForwardLights.d.ts +3 -2
  53. package/dist/sceneForwardLights.d.ts.map +1 -1
  54. package/dist/sceneForwardLights.js +25 -9
  55. package/dist/sceneForwardLights.js.map +1 -1
  56. package/dist/sceneLights.d.ts +2 -1
  57. package/dist/sceneLights.d.ts.map +1 -1
  58. package/dist/sceneLights.js +2 -2
  59. package/dist/sceneLights.js.map +1 -1
  60. package/dist/spotLight.d.ts +2 -1
  61. package/dist/spotLight.d.ts.map +1 -1
  62. package/dist/spotLight.js +7 -3
  63. package/dist/spotLight.js.map +1 -1
  64. package/dist/types.d.ts +312 -0
  65. package/dist/types.d.ts.map +1 -0
  66. package/dist/types.js +59 -0
  67. package/dist/types.js.map +1 -0
  68. package/package.json +8 -6
  69. package/src/ambientLight.test.ts +2 -3
  70. package/src/areaLight.test.ts +2 -2
  71. package/src/directionalLight.test.ts +2 -2
  72. package/src/environment.test.ts +7 -7
  73. package/src/hemisphereLight.test.ts +2 -3
  74. package/src/lightAnalysis.test.ts +21 -21
  75. package/src/lightIntensity.test.ts +50 -3
  76. package/src/lightProbe.test.ts +362 -0
  77. package/src/pointLight.test.ts +2 -2
  78. package/src/sceneForwardLights.test.ts +59 -4
  79. package/src/sceneLights.test.ts +5 -5
  80. package/src/spotLight.test.ts +2 -2
@@ -1,9 +1,9 @@
1
1
  import { createBoundingSphere } from '@flighthq/geometry/contract';
2
- import type { Scene3DForwardLightSelection, Scene3DLightsLike } from '@flighthq/types/contract';
3
2
 
4
- import { createPointLight } from './pointLight';
5
- import { selectScene3DForwardLights } from './sceneForwardLights';
6
- import { createSpotLight } from './spotLight';
3
+ import { createPointLight } from './pointLight.ts';
4
+ import { selectScene3DForwardLights } from './sceneForwardLights.ts';
5
+ import { createSpotLight } from './spotLight.ts';
6
+ import type { Scene3DForwardLightSelection, Scene3DLightsLike } from './types.ts';
7
7
 
8
8
  function selection(): Scene3DForwardLightSelection {
9
9
  return { indices: [], point: [], spot: [] };
@@ -145,3 +145,58 @@ describe('selectScene3DForwardLights', () => {
145
145
  expect(out.indices).toEqual([1, 0]);
146
146
  });
147
147
  });
148
+
149
+ describe('selectScene3DForwardLights layer and priority policy', () => {
150
+ it('skips a light whose layerMask does not meet the receiver, freeing its budget slot', () => {
151
+ // The filter has to run BEFORE ranking: a light the receiver cannot see must not occupy a slot a
152
+ // visible light would have taken. Both lights here would otherwise be selected.
153
+ const visible = createPointLight({ intensity: 1, layerMask: 0b01, position: { x: 0, y: 0, z: 0 }, range: -1 });
154
+ const hidden = createPointLight({ intensity: 10, layerMask: 0b10, position: { x: 0, y: 0, z: 0 }, range: -1 });
155
+ const out = selection();
156
+ selectScene3DForwardLights(
157
+ out,
158
+ { ambient: null, directional: null, point: [hidden, visible], spot: [] },
159
+ createBoundingSphere(0, 0, 0, 0),
160
+ 0b01,
161
+ );
162
+ expect(out.point).toHaveLength(1);
163
+ expect(out.point[0]).toBe(visible);
164
+ });
165
+
166
+ it('lights every layer by default, so an unconfigured light is not silently dark', () => {
167
+ const light = createPointLight({ intensity: 1, position: { x: 0, y: 0, z: 0 }, range: -1 });
168
+ const out = selection();
169
+ selectScene3DForwardLights(
170
+ out,
171
+ { ambient: null, directional: null, point: [light], spot: [] },
172
+ createBoundingSphere(0, 0, 0, 0),
173
+ );
174
+ expect(out.point).toHaveLength(1);
175
+ });
176
+
177
+ it('ranks priority above contribution, so a key light outranks a brighter incidental one', () => {
178
+ const key = createPointLight({ intensity: 1, priority: 1, position: { x: 0, y: 0, z: 0 }, range: -1 });
179
+ const brighter = createPointLight({ intensity: 50, position: { x: 0, y: 0, z: 0 }, range: -1 });
180
+ const out = selection();
181
+ selectScene3DForwardLights(
182
+ out,
183
+ { ambient: null, directional: null, point: [brighter, key], spot: [] },
184
+ createBoundingSphere(0, 0, 0, 0),
185
+ );
186
+ expect(out.point[0]).toBe(key);
187
+ });
188
+
189
+ it('falls back to contribution within one priority, preserving the previous order exactly', () => {
190
+ // Every light at the default 0 must reproduce pure-contribution order, which is what makes the
191
+ // field additive rather than a behaviour change for existing scenes.
192
+ const dim = createPointLight({ intensity: 1, position: { x: 0, y: 0, z: 0 }, range: -1 });
193
+ const bright = createPointLight({ intensity: 50, position: { x: 0, y: 0, z: 0 }, range: -1 });
194
+ const out = selection();
195
+ selectScene3DForwardLights(
196
+ out,
197
+ { ambient: null, directional: null, point: [dim, bright], spot: [] },
198
+ createBoundingSphere(0, 0, 0, 0),
199
+ );
200
+ expect(out.point[0]).toBe(bright);
201
+ });
202
+ });
@@ -1,10 +1,10 @@
1
- import { EntityRuntimeKey } from '@flighthq/types/contract';
1
+ import { EntityRuntimeKey } from '@flighthq/entity/contract';
2
2
  import { describe, expect, it } from 'vitest';
3
3
 
4
- import { createAmbientLight } from './ambientLight';
5
- import { createDirectionalLight } from './directionalLight';
6
- import { createPointLight } from './pointLight';
7
- import { createScene3DLights, initializeScene3DLights } from './sceneLights';
4
+ import { createAmbientLight } from './ambientLight.ts';
5
+ import { createDirectionalLight } from './directionalLight.ts';
6
+ import { createPointLight } from './pointLight.ts';
7
+ import { createScene3DLights, initializeScene3DLights } from './sceneLights.ts';
8
8
 
9
9
  describe('createScene3DLights', () => {
10
10
  it('fills every absent slot — singles to null, punctual arrays to empty', () => {
@@ -1,5 +1,4 @@
1
1
  import { createVector3 } from '@flighthq/geometry/contract';
2
- import { CandelaLightUnit, SpotLightKind, UnitlessLightUnit } from '@flighthq/types/contract';
3
2
 
4
3
  import {
5
4
  cloneSpotLight,
@@ -10,7 +9,8 @@ import {
10
9
  setSpotLightCone,
11
10
  setSpotLightDirection,
12
11
  setSpotLightTarget,
13
- } from './spotLight';
12
+ } from './spotLight.ts';
13
+ import { CandelaLightUnit, SpotLightKind, UnitlessLightUnit } from './types.ts';
14
14
 
15
15
  describe('cloneSpotLight', () => {
16
16
  it('creates an independent copy with fresh position and direction vectors', () => {