@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.
- package/README.md +2 -2
- package/dist/.tsbuildinfo.contract +1 -0
- package/dist/.tsbuildinfo.runtime +1 -0
- package/dist/ambientLight.d.ts +2 -1
- package/dist/ambientLight.d.ts.map +1 -1
- package/dist/ambientLight.js +3 -3
- package/dist/ambientLight.js.map +1 -1
- package/dist/areaLight.d.ts +3 -1
- package/dist/areaLight.d.ts.map +1 -1
- package/dist/areaLight.js +4 -4
- package/dist/areaLight.js.map +1 -1
- package/dist/contract.d.ts +20 -17
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +20 -17
- package/dist/contract.js.map +1 -1
- package/dist/contract.lighting-types.d.ts +2 -0
- package/dist/contract.lighting-types.d.ts.map +1 -0
- package/dist/contract.lighting-types.js +4 -0
- package/dist/contract.lighting-types.js.map +1 -0
- package/dist/directionalLight.d.ts +2 -1
- package/dist/directionalLight.d.ts.map +1 -1
- package/dist/directionalLight.js +3 -3
- package/dist/directionalLight.js.map +1 -1
- package/dist/environment.d.ts +2 -1
- package/dist/environment.d.ts.map +1 -1
- package/dist/environment.js +3 -3
- package/dist/environment.js.map +1 -1
- package/dist/hemisphereLight.d.ts +2 -1
- package/dist/hemisphereLight.d.ts.map +1 -1
- package/dist/hemisphereLight.js +3 -3
- package/dist/hemisphereLight.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lightAnalysis.d.ts +2 -1
- package/dist/lightAnalysis.d.ts.map +1 -1
- package/dist/lightAnalysis.js +1 -1
- package/dist/lightAnalysis.js.map +1 -1
- package/dist/lightIntensity.d.ts +3 -1
- package/dist/lightIntensity.d.ts.map +1 -1
- package/dist/lightIntensity.js +19 -1
- package/dist/lightIntensity.js.map +1 -1
- package/dist/lightProbe.d.ts +69 -0
- package/dist/lightProbe.d.ts.map +1 -0
- package/dist/lightProbe.js +229 -0
- package/dist/lightProbe.js.map +1 -0
- package/dist/pointLight.d.ts +2 -1
- package/dist/pointLight.d.ts.map +1 -1
- package/dist/pointLight.js +8 -4
- package/dist/pointLight.js.map +1 -1
- package/dist/sceneForwardLights.d.ts +3 -2
- package/dist/sceneForwardLights.d.ts.map +1 -1
- package/dist/sceneForwardLights.js +25 -9
- package/dist/sceneForwardLights.js.map +1 -1
- package/dist/sceneLights.d.ts +2 -1
- package/dist/sceneLights.d.ts.map +1 -1
- package/dist/sceneLights.js +2 -2
- package/dist/sceneLights.js.map +1 -1
- package/dist/spotLight.d.ts +2 -1
- package/dist/spotLight.d.ts.map +1 -1
- package/dist/spotLight.js +7 -3
- package/dist/spotLight.js.map +1 -1
- package/dist/types.d.ts +312 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +59 -0
- package/dist/types.js.map +1 -0
- package/package.json +8 -6
- package/src/ambientLight.test.ts +2 -3
- package/src/areaLight.test.ts +2 -2
- package/src/directionalLight.test.ts +2 -2
- package/src/environment.test.ts +7 -7
- package/src/hemisphereLight.test.ts +2 -3
- package/src/lightAnalysis.test.ts +21 -21
- package/src/lightIntensity.test.ts +50 -3
- package/src/lightProbe.test.ts +362 -0
- package/src/pointLight.test.ts +2 -2
- package/src/sceneForwardLights.test.ts +59 -4
- package/src/sceneLights.test.ts +5 -5
- package/src/spotLight.test.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getLightContributionAtBoundingSphere } from './lightAnalysis.js';
|
|
2
|
+
import { ALL_LIGHT_LAYERS, MAX_FORWARD_LIGHTS } from './types.js';
|
|
3
3
|
// Selects the strongest point and spot contributors for one object's forward-light budget. Each
|
|
4
4
|
// family has its own MAX_FORWARD_LIGHTS budget, matching the shader's separate fixed arrays and
|
|
5
5
|
// counts. Ranking uses descriptor-side shader-equivalent attenuation at `bounds`; equal scores
|
|
@@ -8,11 +8,11 @@ import { getLightContributionAtBoundingSphere } from './lightAnalysis';
|
|
|
8
8
|
//
|
|
9
9
|
// `out.point` and `out.spot` are reused mutable arrays. All inputs are read into fixed-size scratch
|
|
10
10
|
// before either output array is changed, so `out` may alias `lights`.
|
|
11
|
-
export function selectScene3DForwardLights(out, lights, bounds) {
|
|
11
|
+
export function selectScene3DForwardLights(out, lights, bounds, receiverLayerMask = ALL_LIGHT_LAYERS) {
|
|
12
12
|
const points = lights.point;
|
|
13
13
|
const spots = lights.spot;
|
|
14
|
-
const pointCount = selectStrongestLights(points, bounds, scratchSelectedPointLights, scratchSelectedPointIndices, scratchSelectedPointScores);
|
|
15
|
-
const spotCount = selectStrongestLights(spots, bounds, scratchSelectedSpotLights, scratchSelectedSpotIndices, scratchSelectedSpotScores);
|
|
14
|
+
const pointCount = selectStrongestLights(points, bounds, receiverLayerMask, scratchSelectedPointLights, scratchSelectedPointIndices, scratchSelectedPointScores, scratchSelectedPointPriorities);
|
|
15
|
+
const spotCount = selectStrongestLights(spots, bounds, receiverLayerMask, scratchSelectedSpotLights, scratchSelectedSpotIndices, scratchSelectedSpotScores, scratchSelectedSpotPriorities);
|
|
16
16
|
const outPoints = out.point;
|
|
17
17
|
const outSpots = out.spot;
|
|
18
18
|
const outIndices = out.indices;
|
|
@@ -30,22 +30,34 @@ export function selectScene3DForwardLights(out, lights, bounds) {
|
|
|
30
30
|
outSpots.push(scratchSelectedSpotLights[i]);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function selectStrongestLights(lights, bounds, selectedLights, selectedIndices, selectedScores) {
|
|
33
|
+
function selectStrongestLights(lights, bounds, receiverLayerMask, selectedLights, selectedIndices, selectedScores, selectedPriorities) {
|
|
34
34
|
let selectedCount = 0;
|
|
35
35
|
if (lights === undefined)
|
|
36
36
|
return selectedCount;
|
|
37
37
|
for (let inputIndex = 0; inputIndex < lights.length; inputIndex++) {
|
|
38
38
|
const light = lights[inputIndex];
|
|
39
|
+
// Layer scoping filters BEFORE ranking: a light the receiver cannot see must not occupy a budget
|
|
40
|
+
// slot a light it can see would have taken.
|
|
41
|
+
if ((light.layerMask & receiverLayerMask) === 0)
|
|
42
|
+
continue;
|
|
39
43
|
const score = getLightContributionAtBoundingSphere(light, bounds);
|
|
40
44
|
if (!(score > 0))
|
|
41
45
|
continue;
|
|
46
|
+
const priority = light.priority;
|
|
42
47
|
let insertAt = selectedCount;
|
|
43
48
|
while (insertAt > 0) {
|
|
44
49
|
const previous = insertAt - 1;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
// Priority outranks contribution, and contribution breaks ties within one priority. With every
|
|
51
|
+
// light at the default 0 this reduces to the previous pure-contribution order exactly, which is
|
|
52
|
+
// what makes the field additive rather than a behaviour change.
|
|
53
|
+
if (priority < selectedPriorities[previous])
|
|
48
54
|
break;
|
|
55
|
+
if (priority === selectedPriorities[previous]) {
|
|
56
|
+
if (score < selectedScores[previous])
|
|
57
|
+
break;
|
|
58
|
+
if (score === selectedScores[previous] && inputIndex > selectedIndices[previous])
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
49
61
|
insertAt--;
|
|
50
62
|
}
|
|
51
63
|
if (insertAt >= MAX_FORWARD_LIGHTS)
|
|
@@ -55,10 +67,12 @@ function selectStrongestLights(lights, bounds, selectedLights, selectedIndices,
|
|
|
55
67
|
selectedLights[i] = selectedLights[i - 1];
|
|
56
68
|
selectedIndices[i] = selectedIndices[i - 1];
|
|
57
69
|
selectedScores[i] = selectedScores[i - 1];
|
|
70
|
+
selectedPriorities[i] = selectedPriorities[i - 1];
|
|
58
71
|
}
|
|
59
72
|
selectedLights[insertAt] = light;
|
|
60
73
|
selectedIndices[insertAt] = inputIndex;
|
|
61
74
|
selectedScores[insertAt] = score;
|
|
75
|
+
selectedPriorities[insertAt] = priority;
|
|
62
76
|
selectedCount = nextCount;
|
|
63
77
|
}
|
|
64
78
|
return selectedCount;
|
|
@@ -66,7 +80,9 @@ function selectStrongestLights(lights, bounds, selectedLights, selectedIndices,
|
|
|
66
80
|
const scratchSelectedPointIndices = new Int32Array(MAX_FORWARD_LIGHTS);
|
|
67
81
|
const scratchSelectedPointLights = new Array(MAX_FORWARD_LIGHTS);
|
|
68
82
|
const scratchSelectedPointScores = new Float64Array(MAX_FORWARD_LIGHTS);
|
|
83
|
+
const scratchSelectedPointPriorities = new Float64Array(MAX_FORWARD_LIGHTS);
|
|
69
84
|
const scratchSelectedSpotIndices = new Int32Array(MAX_FORWARD_LIGHTS);
|
|
70
85
|
const scratchSelectedSpotLights = new Array(MAX_FORWARD_LIGHTS);
|
|
71
86
|
const scratchSelectedSpotScores = new Float64Array(MAX_FORWARD_LIGHTS);
|
|
87
|
+
const scratchSelectedSpotPriorities = new Float64Array(MAX_FORWARD_LIGHTS);
|
|
72
88
|
//# sourceMappingURL=sceneForwardLights.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sceneForwardLights.js","sourceRoot":"","sources":["../src/sceneForwardLights.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sceneForwardLights.js","sourceRoot":"","sources":["../src/sceneForwardLights.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAElE,gGAAgG;AAChG,gGAAgG;AAChG,+FAA+F;AAC/F,8FAA8F;AAC9F,WAAW;AACX,EAAE;AACF,oGAAoG;AACpG,sEAAsE;AACtE,MAAM,UAAU,0BAA0B,CACxC,GAAiC,EACjC,MAAmC,EACnC,MAAoC,EACpC,iBAAiB,GAAW,gBAAgB;IAE5C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1B,MAAM,UAAU,GAAG,qBAAqB,CACtC,MAAM,EACN,MAAM,EACN,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flighthq/entity/contract';
|
|
2
|
+
import type { Scene3DLights, Scene3DLightsLike } from './types.ts';
|
|
2
3
|
export declare function createScene3DLights(options?: Readonly<Partial<Scene3DLightsLike>>): Scene3DLights;
|
|
3
4
|
export declare function initializeScene3DLights(out: EntityConstruction<Scene3DLights>, options?: Readonly<Partial<Scene3DLightsLike>>): void;
|
|
4
5
|
//# sourceMappingURL=sceneLights.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sceneLights.d.ts","sourceRoot":"","sources":["../src/sceneLights.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sceneLights.d.ts","sourceRoot":"","sources":["../src/sceneLights.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEnE,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,aAAa,CAIjG;AAWD,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,kBAAkB,CAAC,aAAa,CAAC,EACtC,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAC7C,IAAI,CAMN"}
|
package/dist/sceneLights.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { allocateEntity
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
2
|
export function createScene3DLights(options) {
|
|
3
3
|
const out = allocateEntity();
|
|
4
4
|
initializeScene3DLights(out, options);
|
|
5
|
-
return
|
|
5
|
+
return out;
|
|
6
6
|
}
|
|
7
7
|
// Constructs a `Scene3DLights` draw-argument, filling every absent slot: the single ambient/directional
|
|
8
8
|
// terms default to `null` and the punctual arrays to empty. Prefer this over a bare object literal —
|
package/dist/sceneLights.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sceneLights.js","sourceRoot":"","sources":["../src/sceneLights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"sceneLights.js","sourceRoot":"","sources":["../src/sceneLights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAK3D,MAAM,UAAU,mBAAmB,CAAC,OAA8C;IAChF,MAAM,GAAG,GAAG,cAAc,EAAiB,CAAC;IAC5C,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wGAAwG;AACxG,qGAAqG;AACrG,qGAAqG;AACrG,yFAAyF;AACzF,qGAAqG;AACrG,EAAE;AACF,oGAAoG;AACpG,qGAAqG;AACrG,uFAAuF;AACvF,MAAM,UAAU,uBAAuB,CACrC,GAAsC,EACtC,OAA8C;IAE9C,GAAG,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC;IACvC,GAAG,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC;IAC/C,GAAG,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;IAC3C,GAAG,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC;IACjC,GAAG,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;AACjC,CAAC"}
|
package/dist/spotLight.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EntityConstruction } from '@flighthq/entity/contract';
|
|
2
|
+
import type { SpotLight, SpotLightConeAngles, SpotLightOptions } from './types.ts';
|
|
2
3
|
export declare function cloneSpotLight(source: Readonly<SpotLight>): SpotLight;
|
|
3
4
|
export declare function createSpotLight(options?: Readonly<SpotLightOptions>): SpotLight;
|
|
4
5
|
export declare function getSpotLightConeDegrees(out: SpotLightConeAngles, source: Readonly<SpotLight>): void;
|
package/dist/spotLight.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotLight.d.ts","sourceRoot":"","sources":["../src/spotLight.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spotLight.d.ts","sourceRoot":"","sources":["../src/spotLight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAGpE,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAInF,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,CAyBrE;AAED,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAI/E;AAKD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAGnG;AAMD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,IAAI,CA2BpH;AAID,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAErE;AAKD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAGjG;AAID,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAQ3F;AAKD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAY1G"}
|
package/dist/spotLight.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { allocateEntity
|
|
1
|
+
import { allocateEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { cloneVector3, createVector3, setVector3 } from '@flighthq/geometry/contract';
|
|
3
|
-
import { SpotLightKind, UnitlessLightUnit } from '
|
|
3
|
+
import { ALL_LIGHT_LAYERS, SpotLightKind, UnitlessLightUnit } from './types.js';
|
|
4
4
|
// Independent copy of a spot light's data, including fresh `position`/`direction` vectors.
|
|
5
5
|
export function cloneSpotLight(source) {
|
|
6
6
|
const out = allocateEntity();
|
|
@@ -12,6 +12,8 @@ export function cloneSpotLight(source) {
|
|
|
12
12
|
out.innerConeCos = source.innerConeCos;
|
|
13
13
|
out.intensity = source.intensity;
|
|
14
14
|
out.intensityUnit = source.intensityUnit;
|
|
15
|
+
out.layerMask = source.layerMask;
|
|
16
|
+
out.priority = source.priority;
|
|
15
17
|
out.kind = SpotLightKind;
|
|
16
18
|
out.normalBias = source.normalBias;
|
|
17
19
|
out.outerConeCos = source.outerConeCos;
|
|
@@ -24,7 +26,7 @@ export function cloneSpotLight(source) {
|
|
|
24
26
|
out.shadowNear = source.shadowNear;
|
|
25
27
|
out.shadowStrength = source.shadowStrength;
|
|
26
28
|
out.spotBlend = source.spotBlend;
|
|
27
|
-
return
|
|
29
|
+
return out;
|
|
28
30
|
}
|
|
29
31
|
export function createSpotLight(options) {
|
|
30
32
|
const light = allocateEntity();
|
|
@@ -53,6 +55,8 @@ export function initializeSpotLight(light, options) {
|
|
|
53
55
|
light.innerConeCos = 1;
|
|
54
56
|
light.intensity = options?.intensity ?? 1;
|
|
55
57
|
light.intensityUnit = options?.intensityUnit ?? UnitlessLightUnit;
|
|
58
|
+
light.layerMask = options?.layerMask ?? ALL_LIGHT_LAYERS;
|
|
59
|
+
light.priority = options?.priority ?? 0;
|
|
56
60
|
light.kind = SpotLightKind;
|
|
57
61
|
light.normalBias = options?.normalBias ?? 0;
|
|
58
62
|
light.outerConeCos = 1;
|
package/dist/spotLight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotLight.js","sourceRoot":"","sources":["../src/spotLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"spotLight.js","sourceRoot":"","sources":["../src/spotLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGtF,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEhF,2FAA2F;AAC3F,MAAM,UAAU,cAAc,CAAC,MAA2B;IACxD,MAAM,GAAG,GAAG,cAAc,EAAa,CAAC;IACxC,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACrC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IACzB,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IACzB,GAAG,CAAC,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC/C,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC7B,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;IACvC,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACjC,GAAG,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;IACzC,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACjC,GAAG,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAC/B,G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AE,CAAC;QACZ,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import type { EntityRaw, EntityRuntime, EntityWithoutRuntime, Kind } from '@flighthq/entity/contract';
|
|
2
|
+
import type { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
3
|
+
import type { AabbLike, Vector3, Vector3Like } from '@flighthq/geometry/contract';
|
|
4
|
+
import type { Texture } from '@flighthq/texture/contract';
|
|
5
|
+
interface LightingEntity extends EntityRaw {
|
|
6
|
+
[EntityRuntimeKey]: EntityRuntime | undefined;
|
|
7
|
+
}
|
|
8
|
+
export type LightUnit = 'Candela' | 'Lumen' | 'Lux' | 'Unitless';
|
|
9
|
+
export declare const CandelaLightUnit = "Candela";
|
|
10
|
+
export declare const LumenLightUnit = "Lumen";
|
|
11
|
+
export declare const LuxLightUnit = "Lux";
|
|
12
|
+
export declare const UnitlessLightUnit = "Unitless";
|
|
13
|
+
export declare const ALL_LIGHT_LAYERS = -1;
|
|
14
|
+
export interface Light extends LightingEntity {
|
|
15
|
+
kind: Kind;
|
|
16
|
+
}
|
|
17
|
+
export interface PhotometricLightLike {
|
|
18
|
+
intensity: number;
|
|
19
|
+
intensityUnit: LightUnit;
|
|
20
|
+
}
|
|
21
|
+
export interface SpotLightConeAngles {
|
|
22
|
+
innerDegrees: number;
|
|
23
|
+
outerDegrees: number;
|
|
24
|
+
}
|
|
25
|
+
export interface AmbientLight extends Light {
|
|
26
|
+
color: number;
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
intensity: number;
|
|
29
|
+
intensityUnit: LightUnit;
|
|
30
|
+
kind: 'AmbientLight';
|
|
31
|
+
}
|
|
32
|
+
export declare const AmbientLightKind = "AmbientLight";
|
|
33
|
+
export interface AmbientLightOptions {
|
|
34
|
+
color?: number;
|
|
35
|
+
enabled?: boolean;
|
|
36
|
+
intensity?: number;
|
|
37
|
+
intensityUnit?: LightUnit;
|
|
38
|
+
}
|
|
39
|
+
export interface AreaLight extends Light {
|
|
40
|
+
castsShadow: boolean;
|
|
41
|
+
color: number;
|
|
42
|
+
decay: number;
|
|
43
|
+
direction: Vector3;
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
intensity: number;
|
|
46
|
+
intensityUnit: LightUnit;
|
|
47
|
+
kind: 'AreaLight';
|
|
48
|
+
normalBias: number;
|
|
49
|
+
pcfRadius: number;
|
|
50
|
+
position: Vector3;
|
|
51
|
+
range: number;
|
|
52
|
+
right: Vector3;
|
|
53
|
+
shadowBias: number;
|
|
54
|
+
shadowFar: number;
|
|
55
|
+
shadowMapSize: number;
|
|
56
|
+
shadowNear: number;
|
|
57
|
+
shadowStrength: number;
|
|
58
|
+
up: Vector3;
|
|
59
|
+
}
|
|
60
|
+
export declare const AreaLightKind = "AreaLight";
|
|
61
|
+
export interface AreaLightOptions {
|
|
62
|
+
castsShadow?: boolean;
|
|
63
|
+
color?: number;
|
|
64
|
+
decay?: number;
|
|
65
|
+
direction?: Readonly<Vector3Like>;
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
intensity?: number;
|
|
68
|
+
intensityUnit?: LightUnit;
|
|
69
|
+
normalBias?: number;
|
|
70
|
+
pcfRadius?: number;
|
|
71
|
+
position?: Readonly<Vector3Like>;
|
|
72
|
+
range?: number;
|
|
73
|
+
right?: Readonly<Vector3Like>;
|
|
74
|
+
shadowBias?: number;
|
|
75
|
+
shadowFar?: number;
|
|
76
|
+
shadowMapSize?: number;
|
|
77
|
+
shadowNear?: number;
|
|
78
|
+
shadowStrength?: number;
|
|
79
|
+
up?: Readonly<Vector3Like>;
|
|
80
|
+
}
|
|
81
|
+
export interface DirectionalLight extends Light {
|
|
82
|
+
cascadeCount: number;
|
|
83
|
+
cascadeSplits: number[];
|
|
84
|
+
castsShadow: boolean;
|
|
85
|
+
color: number;
|
|
86
|
+
direction: Vector3;
|
|
87
|
+
enabled: boolean;
|
|
88
|
+
intensity: number;
|
|
89
|
+
intensityUnit: LightUnit;
|
|
90
|
+
kind: 'DirectionalLight';
|
|
91
|
+
normalBias: number;
|
|
92
|
+
pcfRadius: number;
|
|
93
|
+
shadowBias: number;
|
|
94
|
+
shadowFar: number;
|
|
95
|
+
shadowMapSize: number;
|
|
96
|
+
shadowNear: number;
|
|
97
|
+
shadowStrength: number;
|
|
98
|
+
}
|
|
99
|
+
export declare const DirectionalLightKind = "DirectionalLight";
|
|
100
|
+
export declare const DIRECTIONAL_SHADOW_MAP_SIZE = 1024;
|
|
101
|
+
export declare const MAX_DIRECTIONAL_SHADOW_PCF_RADIUS = 2;
|
|
102
|
+
export interface DirectionalLightOptions {
|
|
103
|
+
cascadeCount?: number;
|
|
104
|
+
cascadeSplits?: readonly number[];
|
|
105
|
+
castsShadow?: boolean;
|
|
106
|
+
color?: number;
|
|
107
|
+
direction?: Readonly<Vector3Like>;
|
|
108
|
+
enabled?: boolean;
|
|
109
|
+
intensity?: number;
|
|
110
|
+
intensityUnit?: LightUnit;
|
|
111
|
+
normalBias?: number;
|
|
112
|
+
pcfRadius?: number;
|
|
113
|
+
shadowBias?: number;
|
|
114
|
+
shadowFar?: number;
|
|
115
|
+
shadowMapSize?: number;
|
|
116
|
+
shadowNear?: number;
|
|
117
|
+
shadowStrength?: number;
|
|
118
|
+
}
|
|
119
|
+
export interface HemisphereLight extends Light {
|
|
120
|
+
enabled: boolean;
|
|
121
|
+
groundColor: number;
|
|
122
|
+
intensity: number;
|
|
123
|
+
intensityUnit: LightUnit;
|
|
124
|
+
kind: 'HemisphereLight';
|
|
125
|
+
skyColor: number;
|
|
126
|
+
}
|
|
127
|
+
export declare const HemisphereLightKind = "HemisphereLight";
|
|
128
|
+
export interface HemisphereLightOptions {
|
|
129
|
+
enabled?: boolean;
|
|
130
|
+
groundColor?: number;
|
|
131
|
+
intensity?: number;
|
|
132
|
+
intensityUnit?: LightUnit;
|
|
133
|
+
skyColor?: number;
|
|
134
|
+
}
|
|
135
|
+
export interface PointLight extends Light {
|
|
136
|
+
castsShadow: boolean;
|
|
137
|
+
color: number;
|
|
138
|
+
decay: number;
|
|
139
|
+
enabled: boolean;
|
|
140
|
+
intensity: number;
|
|
141
|
+
intensityUnit: LightUnit;
|
|
142
|
+
layerMask: number;
|
|
143
|
+
priority: number;
|
|
144
|
+
kind: 'PointLight';
|
|
145
|
+
normalBias: number;
|
|
146
|
+
pcfRadius: number;
|
|
147
|
+
position: Vector3;
|
|
148
|
+
range: number;
|
|
149
|
+
shadowBias: number;
|
|
150
|
+
shadowFar: number;
|
|
151
|
+
shadowMapSize: number;
|
|
152
|
+
shadowNear: number;
|
|
153
|
+
shadowStrength: number;
|
|
154
|
+
}
|
|
155
|
+
export declare const PointLightKind = "PointLight";
|
|
156
|
+
export interface PointLightOptions {
|
|
157
|
+
castsShadow?: boolean;
|
|
158
|
+
layerMask?: number;
|
|
159
|
+
priority?: number;
|
|
160
|
+
color?: number;
|
|
161
|
+
decay?: number;
|
|
162
|
+
enabled?: boolean;
|
|
163
|
+
intensity?: number;
|
|
164
|
+
intensityUnit?: LightUnit;
|
|
165
|
+
normalBias?: number;
|
|
166
|
+
pcfRadius?: number;
|
|
167
|
+
position?: Readonly<Vector3Like>;
|
|
168
|
+
range?: number;
|
|
169
|
+
shadowBias?: number;
|
|
170
|
+
shadowFar?: number;
|
|
171
|
+
shadowMapSize?: number;
|
|
172
|
+
shadowNear?: number;
|
|
173
|
+
shadowStrength?: number;
|
|
174
|
+
}
|
|
175
|
+
export interface SpotLight extends Light {
|
|
176
|
+
castsShadow: boolean;
|
|
177
|
+
color: number;
|
|
178
|
+
decay: number;
|
|
179
|
+
direction: Vector3;
|
|
180
|
+
enabled: boolean;
|
|
181
|
+
innerConeCos: number;
|
|
182
|
+
intensity: number;
|
|
183
|
+
intensityUnit: LightUnit;
|
|
184
|
+
layerMask: number;
|
|
185
|
+
priority: number;
|
|
186
|
+
kind: 'SpotLight';
|
|
187
|
+
normalBias: number;
|
|
188
|
+
outerConeCos: number;
|
|
189
|
+
pcfRadius: number;
|
|
190
|
+
position: Vector3;
|
|
191
|
+
range: number;
|
|
192
|
+
shadowBias: number;
|
|
193
|
+
shadowFar: number;
|
|
194
|
+
shadowMapSize: number;
|
|
195
|
+
shadowNear: number;
|
|
196
|
+
shadowStrength: number;
|
|
197
|
+
spotBlend: number;
|
|
198
|
+
}
|
|
199
|
+
export declare const SpotLightKind = "SpotLight";
|
|
200
|
+
export interface SpotLightOptions {
|
|
201
|
+
castsShadow?: boolean;
|
|
202
|
+
layerMask?: number;
|
|
203
|
+
priority?: number;
|
|
204
|
+
color?: number;
|
|
205
|
+
decay?: number;
|
|
206
|
+
direction?: Readonly<Vector3Like>;
|
|
207
|
+
enabled?: boolean;
|
|
208
|
+
innerConeDegrees?: number;
|
|
209
|
+
intensity?: number;
|
|
210
|
+
intensityUnit?: LightUnit;
|
|
211
|
+
normalBias?: number;
|
|
212
|
+
outerConeDegrees?: number;
|
|
213
|
+
pcfRadius?: number;
|
|
214
|
+
position?: Readonly<Vector3Like>;
|
|
215
|
+
range?: number;
|
|
216
|
+
shadowBias?: number;
|
|
217
|
+
shadowFar?: number;
|
|
218
|
+
shadowMapSize?: number;
|
|
219
|
+
shadowNear?: number;
|
|
220
|
+
shadowStrength?: number;
|
|
221
|
+
spotBlend?: number;
|
|
222
|
+
}
|
|
223
|
+
export interface Environment extends Light {
|
|
224
|
+
enabled: boolean;
|
|
225
|
+
environment: Texture | null;
|
|
226
|
+
intensity: number;
|
|
227
|
+
kind: 'Environment';
|
|
228
|
+
}
|
|
229
|
+
export declare const EnvironmentKind = "Environment";
|
|
230
|
+
export interface EnvironmentOptions {
|
|
231
|
+
enabled?: boolean;
|
|
232
|
+
environment?: Texture | null;
|
|
233
|
+
intensity?: number;
|
|
234
|
+
}
|
|
235
|
+
export declare const LIGHT_PROBE_SH_FLOATS = 27;
|
|
236
|
+
/**
|
|
237
|
+
* One spherical-harmonic radiance sample at a point in space — the unit a probe grid interpolates
|
|
238
|
+
* between. A probe stores what light arrives at its position from every direction, compressed to the
|
|
239
|
+
* nine L2 SH coefficients that capture the low-frequency part of that sphere.
|
|
240
|
+
*
|
|
241
|
+
* `shCoefficients` is exactly `LIGHT_PROBE_SH_FLOATS` floats: nine consecutive RGB triplets, one per
|
|
242
|
+
* coefficient, ordered by band — index 0 is l=0 (m=0), indices 1..3 are l=1 (m=-1,0,1), indices 4..8
|
|
243
|
+
* are l=2 (m=-2..2). Within a triplet the order is R, G, B. Values are LINEAR radiance, not packed
|
|
244
|
+
* sRgb: nine 8-bit colors could not carry the high dynamic range a probe exists to record, which is
|
|
245
|
+
* why this is the one lighting descriptor whose color is floats rather than a packed RGBA integer.
|
|
246
|
+
*
|
|
247
|
+
* The coefficients are a projection of radiance. Turning them into diffuse irradiance requires a
|
|
248
|
+
* cosine convolution that `evaluateLightProbeSh` does NOT apply — see that function.
|
|
249
|
+
*/
|
|
250
|
+
export interface LightProbe extends LightingEntity {
|
|
251
|
+
enabled: boolean;
|
|
252
|
+
position: Vector3;
|
|
253
|
+
shCoefficients: Float32Array;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* A regular 3D lattice of probes covering an axis-aligned box — the simplest spatial structure for
|
|
257
|
+
* "what light reaches this point", and what `sampleLightProbeGrid` interpolates.
|
|
258
|
+
*
|
|
259
|
+
* `probes` is indexed X-fastest then Y then Z: `index = x + y * resolution.x + z * resolution.x *
|
|
260
|
+
* resolution.y`, and its length must equal `resolution.x * resolution.y * resolution.z`. Probes sit ON
|
|
261
|
+
* the bounds, not at cell centres: along each axis the first probe is at `bounds.min` and the last at
|
|
262
|
+
* `bounds.max`, so an axis with resolution 1 places its single probe at `bounds.min` and covers the
|
|
263
|
+
* whole extent uniformly.
|
|
264
|
+
*/
|
|
265
|
+
export interface LightProbeGrid extends LightingEntity {
|
|
266
|
+
bounds: AabbLike;
|
|
267
|
+
enabled: boolean;
|
|
268
|
+
probes: readonly LightProbe[];
|
|
269
|
+
resolution: Vector3Like;
|
|
270
|
+
}
|
|
271
|
+
export interface Scene3DForwardLightSelection {
|
|
272
|
+
indices: number[];
|
|
273
|
+
point: Readonly<PointLight>[];
|
|
274
|
+
spot: Readonly<SpotLight>[];
|
|
275
|
+
}
|
|
276
|
+
export interface Scene3DForwardLightSelectionExplanation {
|
|
277
|
+
pointLightCount: number;
|
|
278
|
+
reason: 'selection-prepared' | 'selection-required' | 'within-budget';
|
|
279
|
+
selectionPrepared: boolean;
|
|
280
|
+
spotLightCount: number;
|
|
281
|
+
}
|
|
282
|
+
export interface Scene3DLights extends LightingEntity {
|
|
283
|
+
ambient: Readonly<AmbientLight> | null;
|
|
284
|
+
directional: Readonly<DirectionalLight> | null;
|
|
285
|
+
hemisphere?: readonly Readonly<HemisphereLight>[];
|
|
286
|
+
point?: readonly Readonly<PointLight>[];
|
|
287
|
+
spot?: readonly Readonly<SpotLight>[];
|
|
288
|
+
}
|
|
289
|
+
export type Scene3DLightsLike = EntityWithoutRuntime<Scene3DLights>;
|
|
290
|
+
export interface Scene3DLightBlock {
|
|
291
|
+
ambientCount: number;
|
|
292
|
+
data: Float32Array<ArrayBuffer>;
|
|
293
|
+
directionalCount: number;
|
|
294
|
+
hemisphereCount: number;
|
|
295
|
+
pointCount: number;
|
|
296
|
+
spotCount: number;
|
|
297
|
+
version: number;
|
|
298
|
+
}
|
|
299
|
+
export declare const MAX_FORWARD_LIGHTS = 4;
|
|
300
|
+
export declare const SCENE_LIGHT_DIRECTIONAL_DIRECTION_OFFSET = 0;
|
|
301
|
+
export declare const SCENE_LIGHT_DIRECTIONAL_RADIANCE_OFFSET = 4;
|
|
302
|
+
export declare const SCENE_LIGHT_AMBIENT_RADIANCE_OFFSET = 8;
|
|
303
|
+
export declare const SCENE_LIGHT_HEAD_FLOATS = 12;
|
|
304
|
+
export declare const SCENE_LIGHT_POINT_OFFSET = 12;
|
|
305
|
+
export declare const SCENE_LIGHT_POINT_STRIDE = 8;
|
|
306
|
+
export declare const SCENE_LIGHT_SPOT_OFFSET: number;
|
|
307
|
+
export declare const SCENE_LIGHT_SPOT_STRIDE = 16;
|
|
308
|
+
export declare const SCENE_LIGHT_HEMISPHERE_OFFSET: number;
|
|
309
|
+
export declare const SCENE_LIGHT_HEMISPHERE_STRIDE = 12;
|
|
310
|
+
export declare const SCENE_LIGHT_BLOCK_FLOATS: number;
|
|
311
|
+
export {};
|
|
312
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACtG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE1D,UAAU,cAAe,SAAQ,SAAS;IACxC,CAAC,gBAAgB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CAC/C;AAED,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,CAAC;AACjE,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,cAAc,UAAU,CAAC;AACtC,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,iBAAiB,aAAa,CAAC;AAK5C,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAqBnC,MAAM,WAAW,KAAM,SAAQ,cAAc;IAC3C,IAAI,EAAE,IAAI,CAAC;CACZ;AAUD,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;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K,CAAC;AAI1C,eAAO,MAAM,wBAAwB,KAA0B,CAAC;AAChE,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAI1C,eAAO,MAAM,uBAAuB,QAA2E,CAAC;AAChH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAI1C,eAAO,MAAM,6BAA6B,QAAyE,CAAC;AACpH,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAGhD,eAAO,MAAM,wBAAwB,QAC+C,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The lighting-owned contracts.
|
|
2
|
+
export const CandelaLightUnit = 'Candela';
|
|
3
|
+
export const LumenLightUnit = 'Lumen';
|
|
4
|
+
export const LuxLightUnit = 'Lux';
|
|
5
|
+
export const UnitlessLightUnit = 'Unitless';
|
|
6
|
+
// Every receiver layer at once — the mask an unconfigured light carries, so a light that was never
|
|
7
|
+
// scoped lights the whole scene. All bits set rather than 0, because 0 is the mask that lights NOTHING
|
|
8
|
+
// and would turn "I did not configure this" into "this light is off" with no diagnostic.
|
|
9
|
+
export const ALL_LIGHT_LAYERS = -1;
|
|
10
|
+
export const AmbientLightKind = 'AmbientLight';
|
|
11
|
+
export const AreaLightKind = 'AreaLight';
|
|
12
|
+
export const DirectionalLightKind = 'DirectionalLight';
|
|
13
|
+
// Both GPU backends allocate directional shadow maps at this square resolution. Keeping the resource
|
|
14
|
+
// dimension in the shared contract makes the depth pass, receiver-bias conversion, and cross-backend
|
|
15
|
+
// raster witnesses agree from one source of truth.
|
|
16
|
+
export const DIRECTIONAL_SHADOW_MAP_SIZE = 1024;
|
|
17
|
+
// Directional PCF uses a square (2r+1)^2 comparison kernel. Renderers truncate authored radii to an
|
|
18
|
+
// integer and clamp them to this cap, keeping the worst case at 25 comparisons on both GL and WGPU.
|
|
19
|
+
// Radius 0 is one comparison tap; radius 1 is a 3x3 kernel; radius 2 is a 5x5 kernel.
|
|
20
|
+
export const MAX_DIRECTIONAL_SHADOW_PCF_RADIUS = 2;
|
|
21
|
+
export const HemisphereLightKind = 'HemisphereLight';
|
|
22
|
+
export const PointLightKind = 'PointLight';
|
|
23
|
+
export const SpotLightKind = 'SpotLight';
|
|
24
|
+
export const EnvironmentKind = 'Environment';
|
|
25
|
+
// The number of floats in a probe's `shCoefficients`: 9 L2 spherical-harmonic coefficients, each an
|
|
26
|
+
// RGB triplet. Exported because callers allocating their own scratch buffer for `sampleLightProbeGrid`
|
|
27
|
+
// need the exact length, and a wrong-sized buffer is otherwise a silent partial write.
|
|
28
|
+
export const LIGHT_PROBE_SH_FLOATS = 27;
|
|
29
|
+
// The forward-lighting cap: the maximum number of each punctual light type (point/spot/hemisphere)
|
|
30
|
+
// a single drawScene3D applies in one pass. A spec constant, NOT an inlined literal: it sizes both the
|
|
31
|
+
// Scene3DLightBlock.data layout below (CPU packer) AND the shader's `#define MAX_FORWARD_LIGHTS` + fixed
|
|
32
|
+
// uniform-array declarations, which must agree byte-for-byte. Excess lights beyond the cap are
|
|
33
|
+
// dropped at pack time. Clustered Forward+ (a later phase) raises the effective count behind the same
|
|
34
|
+
// constant. Four each is a deliberate forward-renderer budget; grow here and both sides follow.
|
|
35
|
+
export const MAX_FORWARD_LIGHTS = 4;
|
|
36
|
+
// std140 float offsets/strides within Scene3DLightBlock.data. Each record is vec4-aligned (4-float
|
|
37
|
+
// lanes). The CPU packer (packScene3DLightBlock) and every backend shader/binder read the same layout
|
|
38
|
+
// from these constants so the two never drift. Head block (directional + ambient) = 12 floats:
|
|
39
|
+
// directional { direction.xyz @0, _pad, radiance.rgb @4, _pad } (8 floats)
|
|
40
|
+
// ambient { radiance.rgb @8, _pad } (4 floats)
|
|
41
|
+
export const SCENE_LIGHT_DIRECTIONAL_DIRECTION_OFFSET = 0;
|
|
42
|
+
export const SCENE_LIGHT_DIRECTIONAL_RADIANCE_OFFSET = 4;
|
|
43
|
+
export const SCENE_LIGHT_AMBIENT_RADIANCE_OFFSET = 8;
|
|
44
|
+
export const SCENE_LIGHT_HEAD_FLOATS = 12;
|
|
45
|
+
// point[i]: { position.xyz, range }, { radiance.rgb, invSqrRange } — 2 vec4 = 8 floats. `invSqrRange`
|
|
46
|
+
// is 1/range^2 (0 for infinite range) driving the smooth inverse-square range cutoff in the shader.
|
|
47
|
+
export const SCENE_LIGHT_POINT_OFFSET = SCENE_LIGHT_HEAD_FLOATS;
|
|
48
|
+
export const SCENE_LIGHT_POINT_STRIDE = 8;
|
|
49
|
+
// spot[i]: point's two vec4 + { direction.xyz, _pad } + { cosInner, cosOuter, _pad, _pad } — 4 vec4
|
|
50
|
+
// = 16 floats. The cone falloff smoothsteps between the precomputed inner/outer cosines.
|
|
51
|
+
export const SCENE_LIGHT_SPOT_OFFSET = SCENE_LIGHT_POINT_OFFSET + SCENE_LIGHT_POINT_STRIDE * MAX_FORWARD_LIGHTS;
|
|
52
|
+
export const SCENE_LIGHT_SPOT_STRIDE = 16;
|
|
53
|
+
// hemisphere[i]: { skyRadiance.rgb, _pad }, { groundRadiance.rgb, _pad }, { up.xyz, _pad } — 3 vec4
|
|
54
|
+
// = 12 floats. `up` is packed world-up (0,1,0); the shader blends sky/ground by dot(normal, up).
|
|
55
|
+
export const SCENE_LIGHT_HEMISPHERE_OFFSET = SCENE_LIGHT_SPOT_OFFSET + SCENE_LIGHT_SPOT_STRIDE * MAX_FORWARD_LIGHTS;
|
|
56
|
+
export const SCENE_LIGHT_HEMISPHERE_STRIDE = 12;
|
|
57
|
+
// Total float length of a Scene3DLightBlock.data buffer sized for MAX_FORWARD_LIGHTS of every type.
|
|
58
|
+
export const SCENE_LIGHT_BLOCK_FLOATS = SCENE_LIGHT_HEMISPHERE_OFFSET + SCENE_LIGHT_HEMISPHERE_STRIDE * MAX_FORWARD_LIGHTS;
|
|
59
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAYhC,MAAM,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,uCAAuC,GAAG,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,sGAAsG;AACtG,oGAAoG;AACpG,MAAM,CAAC,MAAM,wBAAwB,GAAG,uBAAuB,CAAC;AAChE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAE1C,oGAAoG;AACpG,yFAAyF;AACzF,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,GAAG,wBAAwB,GAAG,kBAAkB,CAAC;AAChH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAE1C,oGAAoG;AACpG,iGAAiG;AACjG,MAAM,CAAC,MAAM,6BAA6B,GAAG,uBAAuB,GAAG,uBAAuB,GAAG,kBAAkB,CAAC;AACpH,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AAEhD,oGAAoG;AACpG,MAAM,CAAC,MAAM,wBAAwB,GACnC,6BAA6B,GAAG,6BAA6B,GAAG,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/lighting",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,19 +32,21 @@
|
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsc -b",
|
|
34
34
|
"clean": "tsc -b --clean",
|
|
35
|
+
"generate": "tsx ../../scripts/generate-rust-package.ts --crate flight-lighting --package lighting",
|
|
36
|
+
"generate:check": "tsx ../../scripts/generate-rust-package.ts --crate flight-lighting --package lighting --check",
|
|
35
37
|
"test": "vitest run --config vitest.config.ts",
|
|
36
38
|
"test:watch": "vitest --watch --config vitest.config.ts",
|
|
37
39
|
"prepack": "npm run clean && npm run clean:dist && npm run build",
|
|
38
40
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
|
-
"@flighthq/color": "0.
|
|
42
|
-
"@flighthq/entity": "0.
|
|
43
|
-
"@flighthq/geometry": "0.
|
|
44
|
-
"@flighthq/
|
|
43
|
+
"@flighthq/color": "0.6.0",
|
|
44
|
+
"@flighthq/entity": "0.6.0",
|
|
45
|
+
"@flighthq/geometry": "0.6.0",
|
|
46
|
+
"@flighthq/texture": "0.6.0"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
|
-
"typescript": "^
|
|
49
|
+
"typescript": "^7.0.2"
|
|
48
50
|
},
|
|
49
51
|
"description": "Light descriptors: ambient/directional/point/spot/hemisphere/area and environment",
|
|
50
52
|
"sideEffects": false
|