@flighthq/lighting 0.5.1-next.815.cc08b93 → 0.5.1-next.903.f434bc2
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/ambientLight.d.ts +2 -1
- package/dist/ambientLight.d.ts.map +1 -1
- package/dist/ambientLight.js +12 -9
- package/dist/ambientLight.js.map +1 -1
- package/dist/areaLight.d.ts +2 -1
- package/dist/areaLight.d.ts.map +1 -1
- package/dist/areaLight.js +47 -44
- package/dist/areaLight.js.map +1 -1
- package/dist/contract.d.ts +6 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +6 -0
- package/dist/contract.js.map +1 -1
- package/dist/directionalLight.d.ts +2 -1
- package/dist/directionalLight.d.ts.map +1 -1
- package/dist/directionalLight.js +41 -39
- 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 +11 -8
- 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 +13 -10
- package/dist/hemisphereLight.js.map +1 -1
- package/dist/pointLight.d.ts +2 -1
- package/dist/pointLight.d.ts.map +1 -1
- package/dist/pointLight.js +41 -38
- package/dist/pointLight.js.map +1 -1
- package/dist/sceneLights.d.ts +2 -1
- package/dist/sceneLights.d.ts.map +1 -1
- package/dist/sceneLights.js +12 -9
- 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 +55 -53
- package/dist/spotLight.js.map +1 -1
- package/package.json +5 -5
- package/src/environment.test.ts +20 -21
- package/src/lightAnalysis.test.ts +29 -7
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/lighting`. The `@fli
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/lighting@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/lighting@0.5.1-next.903.f434bc2](https://github.com/flighthq/flight/tree/f434bc233778d75aeea61995df3a8cfaec459a85/packages/lighting)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/f434bc233778d75aeea61995df3a8cfaec459a85/LICENSE.md)
|
package/dist/ambientLight.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AmbientLight, AmbientLightOptions } from '@flighthq/types/contract';
|
|
1
|
+
import type { AmbientLight, AmbientLightOptions, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
export declare function cloneAmbientLight(source: Readonly<AmbientLight>): AmbientLight;
|
|
3
3
|
export declare function createAmbientLight(options?: Readonly<AmbientLightOptions>): AmbientLight;
|
|
4
|
+
export declare function initializeAmbientLight(out: EntityConstruction<AmbientLight>, options?: Readonly<AmbientLightOptions>): void;
|
|
4
5
|
//# sourceMappingURL=ambientLight.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ambientLight.d.ts","sourceRoot":"","sources":["../src/ambientLight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ambientLight.d.ts","sourceRoot":"","sources":["../src/ambientLight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAItG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,YAAY,CAO9E;AAED,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GAAG,YAAY,CAIxF;AAID,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,kBAAkB,CAAC,YAAY,CAAC,EACrC,OAAO,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GACtC,IAAI,CAMN"}
|
package/dist/ambientLight.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { AmbientLightKind, UnitlessLightUnit } from '@flighthq/types/contract';
|
|
3
3
|
// Independent copy of an ambient light's data. The `kind` discriminant is carried over.
|
|
4
4
|
export function cloneAmbientLight(source) {
|
|
@@ -9,15 +9,18 @@ export function cloneAmbientLight(source) {
|
|
|
9
9
|
intensityUnit: source.intensityUnit,
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
+
export function createAmbientLight(options) {
|
|
13
|
+
const out = allocateEntity();
|
|
14
|
+
initializeAmbientLight(out, options);
|
|
15
|
+
return finishEntity(out);
|
|
16
|
+
}
|
|
12
17
|
// Uniform omnidirectional fill light. Color is packed sRgb-albedo RGBA (0xrrggbbaa); defaults to
|
|
13
18
|
// opaque white at unit intensity. Ambient lights do not cast shadows.
|
|
14
|
-
export function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
kind: AmbientLightKind,
|
|
21
|
-
});
|
|
19
|
+
export function initializeAmbientLight(out, options) {
|
|
20
|
+
out.color = options?.color ?? 0xffffffff;
|
|
21
|
+
out.enabled = options?.enabled ?? true;
|
|
22
|
+
out.intensity = options?.intensity ?? 1;
|
|
23
|
+
out.intensityUnit = options?.intensityUnit ?? UnitlessLightUnit;
|
|
24
|
+
out.kind = AmbientLightKind;
|
|
22
25
|
}
|
|
23
26
|
//# sourceMappingURL=ambientLight.js.map
|
package/dist/ambientLight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ambientLight.js","sourceRoot":"","sources":["../src/ambientLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"ambientLight.js","sourceRoot":"","sources":["../src/ambientLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE/E,wFAAwF;AACxF,MAAM,UAAU,iBAAiB,CAAC,MAA8B;IAC9D,OAAO,kBAAkB,CAAC;QACxB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAuC;IACxE,MAAM,GAAG,GAAG,cAAc,EAAgB,CAAC;IAC3C,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,iGAAiG;AACjG,sEAAsE;AACtE,MAAM,UAAU,sBAAsB,CACpC,GAAqC,EACrC,OAAuC;IAEvC,GAAG,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,UAAU,CAAC;IACzC,GAAG,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC;IACvC,GAAG,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,CAAC,CAAC;IACxC,GAAG,CAAC,aAAa,GAAG,OAAO,EAAE,aAAa,IAAI,iBAAiB,CAAC;IAChE,GAAG,CAAC,IAAI,GAAG,gBAAgB,CAAC;AAC9B,CAAC"}
|
package/dist/areaLight.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AreaLight, AreaLightOptions, Vector3Like } from '@flighthq/types/contract';
|
|
1
|
+
import type { AreaLight, AreaLightOptions, EntityConstruction, Vector3Like } from '@flighthq/types/contract';
|
|
2
2
|
export declare function cloneAreaLight(source: Readonly<AreaLight>): AreaLight;
|
|
3
3
|
export declare function createAreaLight(options?: Readonly<AreaLightOptions>): AreaLight;
|
|
4
|
+
export declare function initializeAreaLight(out: EntityConstruction<AreaLight>, options?: Readonly<AreaLightOptions>): void;
|
|
4
5
|
export declare function setAreaLightOrientation(out: AreaLight, direction: Readonly<Vector3Like>, right: Readonly<Vector3Like>, up: Readonly<Vector3Like>): void;
|
|
5
6
|
//# sourceMappingURL=areaLight.d.ts.map
|
package/dist/areaLight.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"areaLight.d.ts","sourceRoot":"","sources":["../src/areaLight.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"areaLight.d.ts","sourceRoot":"","sources":["../src/areaLight.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI7G,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,CAsBrE;AAED,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,SAAS,CAI/E;AAMD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,kBAAkB,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAwBlH;AAOD,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,EAChC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC5B,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,GACxB,IAAI,CA6BN"}
|
package/dist/areaLight.js
CHANGED
|
@@ -1,60 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { cloneVector3, createVector3, normalizeVector3, setVector3 } from '@flighthq/geometry/contract';
|
|
3
3
|
import { AreaLightKind, UnitlessLightUnit } from '@flighthq/types/contract';
|
|
4
4
|
// Independent copy of an area light's data, including fresh position/direction/right/up vectors.
|
|
5
5
|
export function cloneAreaLight(source) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
const out = allocateEntity();
|
|
7
|
+
out.castsShadow = source.castsShadow;
|
|
8
|
+
out.color = source.color;
|
|
9
|
+
out.decay = source.decay;
|
|
10
|
+
out.direction = cloneVector3(source.direction);
|
|
11
|
+
out.enabled = source.enabled;
|
|
12
|
+
out.intensity = source.intensity;
|
|
13
|
+
out.intensityUnit = source.intensityUnit;
|
|
14
|
+
out.kind = AreaLightKind;
|
|
15
|
+
out.normalBias = source.normalBias;
|
|
16
|
+
out.pcfRadius = source.pcfRadius;
|
|
17
|
+
out.position = cloneVector3(source.position);
|
|
18
|
+
out.range = source.range;
|
|
19
|
+
out.right = cloneVector3(source.right);
|
|
20
|
+
out.shadowBias = source.shadowBias;
|
|
21
|
+
out.shadowFar = source.shadowFar;
|
|
22
|
+
out.shadowMapSize = source.shadowMapSize;
|
|
23
|
+
out.shadowNear = source.shadowNear;
|
|
24
|
+
out.shadowStrength = source.shadowStrength;
|
|
25
|
+
out.up = cloneVector3(source.up);
|
|
26
|
+
return finishEntity(out);
|
|
27
|
+
}
|
|
28
|
+
export function createAreaLight(options) {
|
|
29
|
+
const out = allocateEntity();
|
|
30
|
+
initializeAreaLight(out, options);
|
|
31
|
+
return finishEntity(out);
|
|
27
32
|
}
|
|
28
33
|
// Rectangular area light (LTC-shaded). `position` is the rectangle center, `direction` its facing
|
|
29
34
|
// normal, `right`/`up` its half-extent axes (length encodes half-width/half-height). Color is
|
|
30
35
|
// packed sRgb-albedo RGBA (0xrrggbbaa); defaults to opaque white at unit intensity, at the origin
|
|
31
36
|
// facing down (0, -1, 0), unit-half-extent (1,0,0)/(0,0,1) rectangle, infinite range, shadows off.
|
|
32
|
-
export function
|
|
37
|
+
export function initializeAreaLight(out, options) {
|
|
33
38
|
const position = options?.position;
|
|
34
39
|
const direction = options?.direction;
|
|
35
40
|
const right = options?.right;
|
|
36
41
|
const up = options?.up;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
up: up ? cloneVector3(up) : createVector3(0, 0, 1),
|
|
57
|
-
});
|
|
42
|
+
out.castsShadow = options?.castsShadow ?? false;
|
|
43
|
+
out.color = options?.color ?? 0xffffffff;
|
|
44
|
+
out.decay = options?.decay ?? 2;
|
|
45
|
+
out.direction = direction ? cloneVector3(direction) : createVector3(0, -1, 0);
|
|
46
|
+
out.enabled = options?.enabled ?? true;
|
|
47
|
+
out.intensity = options?.intensity ?? 1;
|
|
48
|
+
out.intensityUnit = options?.intensityUnit ?? UnitlessLightUnit;
|
|
49
|
+
out.kind = AreaLightKind;
|
|
50
|
+
out.normalBias = options?.normalBias ?? 0;
|
|
51
|
+
out.pcfRadius = options?.pcfRadius ?? 0;
|
|
52
|
+
out.position = position ? cloneVector3(position) : createVector3(0, 0, 0);
|
|
53
|
+
out.range = options?.range ?? -1;
|
|
54
|
+
out.right = right ? cloneVector3(right) : createVector3(1, 0, 0);
|
|
55
|
+
out.shadowBias = options?.shadowBias ?? 0;
|
|
56
|
+
out.shadowFar = options?.shadowFar ?? 500;
|
|
57
|
+
out.shadowMapSize = options?.shadowMapSize ?? 1024;
|
|
58
|
+
out.shadowNear = options?.shadowNear ?? 0.5;
|
|
59
|
+
out.shadowStrength = options?.shadowStrength ?? 1;
|
|
60
|
+
out.up = up ? cloneVector3(up) : createVector3(0, 0, 1);
|
|
58
61
|
}
|
|
59
62
|
// Sets the orientation of a rectangular area light by writing normalized `direction`, `right`,
|
|
60
63
|
// and `up` vectors. `direction` is the facing normal; `right`/`up` carry their existing lengths
|
package/dist/areaLight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"areaLight.js","sourceRoot":"","sources":["../src/areaLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"areaLight.js","sourceRoot":"","sources":["../src/areaLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAExG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE5E,iGAAiG;AACjG,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,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G,CAAC,KAAK,CAAC,CAAC,GAAG,gBAAgB,EAC9B,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,gBAAgB,CAC/B,CAAC;QACJ,CAAC;IACH,CAAC;IACD,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QAC7D,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;YACtB,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC;QACnG,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/contract.d.ts
CHANGED
|
@@ -9,4 +9,10 @@ export * from './pointLight';
|
|
|
9
9
|
export * from './sceneForwardLights';
|
|
10
10
|
export * from './sceneLights';
|
|
11
11
|
export * from './spotLight';
|
|
12
|
+
export { initializeHemisphereLight } from './hemisphereLight';
|
|
13
|
+
export { initializeScene3DLights } from './sceneLights';
|
|
14
|
+
export { initializePointLight } from './pointLight';
|
|
15
|
+
export { initializeEnvironment } from './environment';
|
|
16
|
+
export { initializeAreaLight } from './areaLight';
|
|
17
|
+
export { initializeAmbientLight } from './ambientLight';
|
|
12
18
|
//# sourceMappingURL=contract.d.ts.map
|
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/contract.js
CHANGED
|
@@ -9,4 +9,10 @@ export * from './pointLight';
|
|
|
9
9
|
export * from './sceneForwardLights';
|
|
10
10
|
export * from './sceneLights';
|
|
11
11
|
export * from './spotLight';
|
|
12
|
+
export { initializeHemisphereLight } from './hemisphereLight';
|
|
13
|
+
export { initializeScene3DLights } from './sceneLights';
|
|
14
|
+
export { initializePointLight } from './pointLight';
|
|
15
|
+
export { initializeEnvironment } from './environment';
|
|
16
|
+
export { initializeAreaLight } from './areaLight';
|
|
17
|
+
export { initializeAmbientLight } from './ambientLight';
|
|
12
18
|
//# sourceMappingURL=contract.js.map
|
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { DirectionalLight, DirectionalLightOptions } from '@flighthq/types/contract';
|
|
1
|
+
import type { DirectionalLight, DirectionalLightOptions, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
export declare function cloneDirectionalLight(source: Readonly<DirectionalLight>): DirectionalLight;
|
|
3
3
|
export declare function createDirectionalLight(options?: Readonly<DirectionalLightOptions>): DirectionalLight;
|
|
4
|
+
export declare function initializeDirectionalLight(light: EntityConstruction<DirectionalLight>, options?: Readonly<DirectionalLightOptions>): void;
|
|
4
5
|
export declare function setDirectionalLightDirection(out: DirectionalLight, x: number, y: number, z: number): void;
|
|
5
6
|
export declare function setDirectionalLightTarget(out: DirectionalLight, fromX: number, fromY: number, fromZ: number, toX: number, toY: number, toZ: number): void;
|
|
6
7
|
//# sourceMappingURL=directionalLight.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directionalLight.d.ts","sourceRoot":"","sources":["../src/directionalLight.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"directionalLight.d.ts","sourceRoot":"","sources":["../src/directionalLight.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI9G,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,gBAAgB,CAmB1F;AAED,wBAAgB,sBAAsB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,uBAAuB,CAAC,GAAG,gBAAgB,CAIpG;AAKD,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,EAC3C,OAAO,CAAC,EAAE,QAAQ,CAAC,uBAAuB,CAAC,GAC1C,IAAI,CAmBN;AAID,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,gBAAgB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CASzG;AAID,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,IAAI,CAQN"}
|
package/dist/directionalLight.js
CHANGED
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { cloneVector3, createVector3, setVector3 } from '@flighthq/geometry/contract';
|
|
3
3
|
import { DirectionalLightKind, UnitlessLightUnit } from '@flighthq/types/contract';
|
|
4
4
|
// Independent copy of a directional light's data, including a fresh `direction` vector.
|
|
5
5
|
export function cloneDirectionalLight(source) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
const out = allocateEntity();
|
|
7
|
+
out.cascadeCount = source.cascadeCount;
|
|
8
|
+
out.cascadeSplits = source.cascadeSplits.slice();
|
|
9
|
+
out.castsShadow = source.castsShadow;
|
|
10
|
+
out.color = source.color;
|
|
11
|
+
out.direction = cloneVector3(source.direction);
|
|
12
|
+
out.enabled = source.enabled;
|
|
13
|
+
out.intensity = source.intensity;
|
|
14
|
+
out.intensityUnit = source.intensityUnit;
|
|
15
|
+
out.kind = DirectionalLightKind;
|
|
16
|
+
out.normalBias = source.normalBias;
|
|
17
|
+
out.pcfRadius = source.pcfRadius;
|
|
18
|
+
out.shadowBias = source.shadowBias;
|
|
19
|
+
out.shadowFar = source.shadowFar;
|
|
20
|
+
out.shadowMapSize = source.shadowMapSize;
|
|
21
|
+
out.shadowNear = source.shadowNear;
|
|
22
|
+
out.shadowStrength = source.shadowStrength;
|
|
23
|
+
return finishEntity(out);
|
|
24
|
+
}
|
|
25
|
+
export function createDirectionalLight(options) {
|
|
26
|
+
const light = allocateEntity();
|
|
27
|
+
initializeDirectionalLight(light, options);
|
|
28
|
+
return light;
|
|
24
29
|
}
|
|
25
30
|
// Infinitely distant directional light (sun). `direction` is the world-space travel direction
|
|
26
31
|
// of the light; surfaces are lit from -direction. Color is packed sRgb-albedo RGBA (0xrrggbbaa);
|
|
27
32
|
// defaults to opaque white at unit intensity, pointing straight down (0, -1, 0) with shadows off.
|
|
28
|
-
export function
|
|
33
|
+
export function initializeDirectionalLight(light, options) {
|
|
29
34
|
const direction = options?.direction;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
shadowStrength: options?.shadowStrength ?? 1,
|
|
47
|
-
});
|
|
35
|
+
light.cascadeCount = options?.cascadeCount ?? 1;
|
|
36
|
+
light.cascadeSplits = options?.cascadeSplits?.slice() ?? [1];
|
|
37
|
+
light.castsShadow = options?.castsShadow ?? false;
|
|
38
|
+
light.color = options?.color ?? 0xffffffff;
|
|
39
|
+
light.direction = createVector3(0, -1, 0);
|
|
40
|
+
light.enabled = options?.enabled ?? true;
|
|
41
|
+
light.intensity = options?.intensity ?? 1;
|
|
42
|
+
light.intensityUnit = options?.intensityUnit ?? UnitlessLightUnit;
|
|
43
|
+
light.kind = DirectionalLightKind;
|
|
44
|
+
light.normalBias = options?.normalBias ?? 0;
|
|
45
|
+
light.pcfRadius = options?.pcfRadius ?? 0;
|
|
46
|
+
light.shadowBias = options?.shadowBias ?? 0;
|
|
47
|
+
light.shadowFar = options?.shadowFar ?? 500;
|
|
48
|
+
light.shadowMapSize = options?.shadowMapSize ?? 1024;
|
|
49
|
+
light.shadowNear = options?.shadowNear ?? 0.5;
|
|
50
|
+
light.shadowStrength = options?.shadowStrength ?? 1;
|
|
48
51
|
if (direction)
|
|
49
52
|
setDirectionalLightDirection(light, direction.x, direction.y, direction.z);
|
|
50
|
-
return light;
|
|
51
53
|
}
|
|
52
54
|
// Writes a normalized direction into `out.direction`. Normalizes the supplied x/y/z components
|
|
53
55
|
// before storing so the renderer can rely on a unit-length direction. Alias-safe.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directionalLight.js","sourceRoot":"","sources":["../src/directionalLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"directionalLight.js","sourceRoot":"","sources":["../src/directionalLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEtF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,wFAAwF;AACxF,MAAM,UAAU,qBAAqB,CAAC,MAAkC;IACtE,MAAM,GAAG,GAAG,cAAc,EAAoB,CAAC;IAC/C,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;IACvC,GAAG,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IACjD,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACrC,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,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;IACjC,GAAG,CAAC,aAAa,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QACZ,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,GAAG,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC;AAED,yFAAyF;AACzF,sFAAsF;AACtF,MAAM,UAAU,yBAAyB,CACvC,GAAqB,EACrB,KAAa,EACb,KAAa,EACb,KAAa,EACb,GAAW,EACX,GAAW,EACX,GAAW;IAEX,MAAM,EAAE,GAAG,GAAG,GAAG,KAAK,CAAC;IACvB,MAAM,EAAE,GAAG,GAAG,GAAG,KAAK,CAAC;IACvB,MAAM,EAAE,GAAG,GAAG,GAAG,KAAK,CAAC;IACvB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACnD,IAAI,GAAG,GAAG,CAAC,EAAE,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/environment.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Environment, EnvironmentOptions } from '@flighthq/types/contract';
|
|
1
|
+
import type { Environment, EnvironmentOptions, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
export declare function cloneEnvironment(source: Readonly<Environment>): Environment;
|
|
3
3
|
export declare function createEnvironment(options?: Readonly<EnvironmentOptions>): Environment;
|
|
4
|
+
export declare function initializeEnvironment(out: EntityConstruction<Environment>, options?: Readonly<EnvironmentOptions>): void;
|
|
4
5
|
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAKpG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,WAAW,CAE3E;AAED,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,WAAW,CAIrF;AAKD,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,kBAAkB,CAAC,WAAW,CAAC,EACpC,OAAO,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GACrC,IAAI,CAKN"}
|
package/dist/environment.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { EnvironmentKind } from '@flighthq/types/contract';
|
|
3
3
|
// Independent copy of the environment's data. The `environment` cubemap reference is shared, not
|
|
4
4
|
// deep-copied: a Texture is a GPU-backed resource, so the copy aliases the same source.
|
|
5
5
|
export function cloneEnvironment(source) {
|
|
6
6
|
return createEnvironment({ enabled: source.enabled, environment: source.environment, intensity: source.intensity });
|
|
7
7
|
}
|
|
8
|
+
export function createEnvironment(options) {
|
|
9
|
+
const out = allocateEntity();
|
|
10
|
+
initializeEnvironment(out, options);
|
|
11
|
+
return finishEntity(out);
|
|
12
|
+
}
|
|
8
13
|
// Image-based environment lighting + skybox source. `environment` is the radiance cubemap used
|
|
9
14
|
// for the skybox and as the IBL specular/irradiance source; `intensity` scales its contribution.
|
|
10
15
|
// Defaults to no cubemap (null) at unit intensity.
|
|
11
|
-
export function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
kind: EnvironmentKind,
|
|
17
|
-
});
|
|
16
|
+
export function initializeEnvironment(out, options) {
|
|
17
|
+
out.enabled = options?.enabled ?? true;
|
|
18
|
+
out.environment = options?.environment ?? null;
|
|
19
|
+
out.intensity = options?.intensity ?? 1;
|
|
20
|
+
out.kind = EnvironmentKind;
|
|
18
21
|
}
|
|
19
22
|
//# sourceMappingURL=environment.js.map
|
package/dist/environment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,iGAAiG;AACjG,wFAAwF;AACxF,MAAM,UAAU,gBAAgB,CAAC,MAA6B;IAC5D,OAAO,iBAAiB,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;AACtH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAsC;IACtE,MAAM,GAAG,GAAG,cAAc,EAAe,CAAC;IAC1C,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,+FAA+F;AAC/F,iGAAiG;AACjG,mDAAmD;AACnD,MAAM,UAAU,qBAAqB,CACnC,GAAoC,EACpC,OAAsC;IAEtC,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,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,CAAC,CAAC;IACxC,GAAG,CAAC,IAAI,GAAG,eAAe,CAAC;AAC7B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { HemisphereLight, HemisphereLightOptions } from '@flighthq/types/contract';
|
|
1
|
+
import type { HemisphereLight, HemisphereLightOptions, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
export declare function cloneHemisphereLight(source: Readonly<HemisphereLight>): HemisphereLight;
|
|
3
3
|
export declare function createHemisphereLight(options?: Readonly<HemisphereLightOptions>): HemisphereLight;
|
|
4
|
+
export declare function initializeHemisphereLight(out: EntityConstruction<HemisphereLight>, options?: Readonly<HemisphereLightOptions>): void;
|
|
4
5
|
//# sourceMappingURL=hemisphereLight.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hemisphereLight.d.ts","sourceRoot":"","sources":["../src/hemisphereLight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"hemisphereLight.d.ts","sourceRoot":"","sources":["../src/hemisphereLight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI5G,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,eAAe,CAQvF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,sBAAsB,CAAC,GAAG,eAAe,CAIjG;AAKD,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,kBAAkB,CAAC,eAAe,CAAC,EACxC,OAAO,CAAC,EAAE,QAAQ,CAAC,sBAAsB,CAAC,GACzC,IAAI,CAON"}
|
package/dist/hemisphereLight.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { HemisphereLightKind, UnitlessLightUnit } from '@flighthq/types/contract';
|
|
3
3
|
// Independent copy of a hemisphere light's data. The `kind` discriminant is carried over.
|
|
4
4
|
export function cloneHemisphereLight(source) {
|
|
@@ -10,17 +10,20 @@ export function cloneHemisphereLight(source) {
|
|
|
10
10
|
skyColor: source.skyColor,
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
|
+
export function createHemisphereLight(options) {
|
|
14
|
+
const out = allocateEntity();
|
|
15
|
+
initializeHemisphereLight(out, options);
|
|
16
|
+
return finishEntity(out);
|
|
17
|
+
}
|
|
13
18
|
// Gradient ambient: `skyColor` from above, `groundColor` from below, blended by the surface
|
|
14
19
|
// normal's vertical component. Colors are packed sRgb-albedo RGBA (0xrrggbbaa); both default to
|
|
15
20
|
// opaque white at unit intensity. Hemisphere lights do not cast shadows.
|
|
16
|
-
export function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
skyColor: options?.skyColor ?? 0xffffffff,
|
|
24
|
-
});
|
|
21
|
+
export function initializeHemisphereLight(out, options) {
|
|
22
|
+
out.enabled = options?.enabled ?? true;
|
|
23
|
+
out.groundColor = options?.groundColor ?? 0xffffffff;
|
|
24
|
+
out.intensity = options?.intensity ?? 1;
|
|
25
|
+
out.intensityUnit = options?.intensityUnit ?? UnitlessLightUnit;
|
|
26
|
+
out.kind = HemisphereLightKind;
|
|
27
|
+
out.skyColor = options?.skyColor ?? 0xffffffff;
|
|
25
28
|
}
|
|
26
29
|
//# sourceMappingURL=hemisphereLight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hemisphereLight.js","sourceRoot":"","sources":["../src/hemisphereLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
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
|
|
|
1
|
-
import type { PointLight, PointLightOptions } from '@flighthq/types/contract';
|
|
1
|
+
import type { PointLight, PointLightOptions, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
export declare function clonePointLight(source: Readonly<PointLight>): PointLight;
|
|
3
3
|
export declare function createPointLight(options?: Readonly<PointLightOptions>): PointLight;
|
|
4
|
+
export declare function initializePointLight(out: EntityConstruction<PointLight>, options?: Readonly<PointLightOptions>): void;
|
|
4
5
|
//# sourceMappingURL=pointLight.d.ts.map
|
package/dist/pointLight.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointLight.d.ts","sourceRoot":"","sources":["../src/pointLight.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"pointLight.d.ts","sourceRoot":"","sources":["../src/pointLight.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAIlG,wBAAgB,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,UAAU,CAmBxE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,UAAU,CAIlF;AAKD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,kBAAkB,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAkBrH"}
|
package/dist/pointLight.js
CHANGED
|
@@ -1,49 +1,52 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { cloneVector3, createVector3 } from '@flighthq/geometry/contract';
|
|
3
3
|
import { PointLightKind, UnitlessLightUnit } from '@flighthq/types/contract';
|
|
4
4
|
// Independent copy of a point light's data, including a fresh `position` vector.
|
|
5
5
|
export function clonePointLight(source) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
const out = allocateEntity();
|
|
7
|
+
out.castsShadow = source.castsShadow;
|
|
8
|
+
out.color = source.color;
|
|
9
|
+
out.decay = source.decay;
|
|
10
|
+
out.enabled = source.enabled;
|
|
11
|
+
out.intensity = source.intensity;
|
|
12
|
+
out.intensityUnit = source.intensityUnit;
|
|
13
|
+
out.kind = PointLightKind;
|
|
14
|
+
out.normalBias = source.normalBias;
|
|
15
|
+
out.pcfRadius = source.pcfRadius;
|
|
16
|
+
out.position = cloneVector3(source.position);
|
|
17
|
+
out.range = source.range;
|
|
18
|
+
out.shadowBias = source.shadowBias;
|
|
19
|
+
out.shadowFar = source.shadowFar;
|
|
20
|
+
out.shadowMapSize = source.shadowMapSize;
|
|
21
|
+
out.shadowNear = source.shadowNear;
|
|
22
|
+
out.shadowStrength = source.shadowStrength;
|
|
23
|
+
return finishEntity(out);
|
|
24
|
+
}
|
|
25
|
+
export function createPointLight(options) {
|
|
26
|
+
const out = allocateEntity();
|
|
27
|
+
initializePointLight(out, options);
|
|
28
|
+
return finishEntity(out);
|
|
24
29
|
}
|
|
25
30
|
// Omnidirectional point light. `position` is world-space; intensity falls off with distance up
|
|
26
31
|
// to `range` (-1 = infinite). Color is packed sRgb-albedo RGBA (0xrrggbbaa); defaults to opaque
|
|
27
32
|
// white at unit intensity, at the origin, infinite range, shadows off.
|
|
28
|
-
export function
|
|
33
|
+
export function initializePointLight(out, options) {
|
|
29
34
|
const position = options?.position;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
shadowStrength: options?.shadowStrength ?? 1,
|
|
47
|
-
});
|
|
35
|
+
out.castsShadow = options?.castsShadow ?? false;
|
|
36
|
+
out.color = options?.color ?? 0xffffffff;
|
|
37
|
+
out.decay = options?.decay ?? 2;
|
|
38
|
+
out.enabled = options?.enabled ?? true;
|
|
39
|
+
out.intensity = options?.intensity ?? 1;
|
|
40
|
+
out.intensityUnit = options?.intensityUnit ?? UnitlessLightUnit;
|
|
41
|
+
out.kind = PointLightKind;
|
|
42
|
+
out.normalBias = options?.normalBias ?? 0;
|
|
43
|
+
out.pcfRadius = options?.pcfRadius ?? 0;
|
|
44
|
+
out.position = position ? cloneVector3(position) : createVector3(0, 0, 0);
|
|
45
|
+
out.range = options?.range ?? -1;
|
|
46
|
+
out.shadowBias = options?.shadowBias ?? 0;
|
|
47
|
+
out.shadowFar = options?.shadowFar ?? 500;
|
|
48
|
+
out.shadowMapSize = options?.shadowMapSize ?? 1024;
|
|
49
|
+
out.shadowNear = options?.shadowNear ?? 0.5;
|
|
50
|
+
out.shadowStrength = options?.shadowStrength ?? 1;
|
|
48
51
|
}
|
|
49
52
|
//# sourceMappingURL=pointLight.js.map
|
package/dist/pointLight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointLight.js","sourceRoot":"","sources":["../src/pointLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"pointLight.js","sourceRoot":"","sources":["../src/pointLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC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AG,OAAO,EAAE,UAAU,IAAI,GAAG,CAAC;IAC5C,GAAG,CAAC,cAAc,GAAG,OAAO,EAAE,cAAc,IAAI,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/sceneLights.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { Scene3DLights, Scene3DLightsLike } from '@flighthq/types/contract';
|
|
1
|
+
import type { Scene3DLights, Scene3DLightsLike, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
export declare function createScene3DLights(options?: Readonly<Partial<Scene3DLightsLike>>): Scene3DLights;
|
|
3
|
+
export declare function initializeScene3DLights(out: EntityConstruction<Scene3DLights>, options?: Readonly<Partial<Scene3DLightsLike>>): void;
|
|
3
4
|
//# 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,aAAa,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"sceneLights.d.ts","sourceRoot":"","sources":["../src/sceneLights.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAErG,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,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
|
+
export function createScene3DLights(options) {
|
|
3
|
+
const out = allocateEntity();
|
|
4
|
+
initializeScene3DLights(out, options);
|
|
5
|
+
return finishEntity(out);
|
|
6
|
+
}
|
|
2
7
|
// Constructs a `Scene3DLights` draw-argument, filling every absent slot: the single ambient/directional
|
|
3
8
|
// terms default to `null` and the punctual arrays to empty. Prefer this over a bare object literal —
|
|
4
9
|
// a literal that omits a slot passes `undefined` where the packer expects a light-or-null, which the
|
|
@@ -8,13 +13,11 @@ import { createEntity } from '@flighthq/entity/contract';
|
|
|
8
13
|
// `Scene3DLights` is a per-draw argument (lights are not scene members), but the exported `create*`
|
|
9
14
|
// product still carries Flight's Entity shape invariant. That identity does not imply a GPU binding:
|
|
10
15
|
// the packed `Scene3DLightBlock` is what a backend caches, keyed off the render state.
|
|
11
|
-
export function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
spot: options?.spot ?? [],
|
|
18
|
-
});
|
|
16
|
+
export function initializeScene3DLights(out, options) {
|
|
17
|
+
out.ambient = options?.ambient ?? null;
|
|
18
|
+
out.directional = options?.directional ?? null;
|
|
19
|
+
out.hemisphere = options?.hemisphere ?? [];
|
|
20
|
+
out.point = options?.point ?? [];
|
|
21
|
+
out.spot = options?.spot ?? [];
|
|
19
22
|
}
|
|
20
23
|
//# sourceMappingURL=sceneLights.js.map
|
package/dist/sceneLights.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sceneLights.js","sourceRoot":"","sources":["../src/sceneLights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"sceneLights.js","sourceRoot":"","sources":["../src/sceneLights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzE,MAAM,UAAU,mBAAmB,CAAC,OAA8C;IAChF,MAAM,GAAG,GAAG,cAAc,EAAiB,CAAC;IAC5C,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACtC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,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,7 +1,8 @@
|
|
|
1
|
-
import type { SpotLight, SpotLightConeAngles, SpotLightOptions } from '@flighthq/types/contract';
|
|
1
|
+
import type { SpotLight, SpotLightConeAngles, SpotLightOptions, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
export declare function cloneSpotLight(source: Readonly<SpotLight>): SpotLight;
|
|
3
3
|
export declare function createSpotLight(options?: Readonly<SpotLightOptions>): SpotLight;
|
|
4
4
|
export declare function getSpotLightConeDegrees(out: SpotLightConeAngles, source: Readonly<SpotLight>): void;
|
|
5
|
+
export declare function initializeSpotLight(light: EntityConstruction<SpotLight>, options?: Readonly<SpotLightOptions>): void;
|
|
5
6
|
export declare function setSpotLightBlend(out: SpotLight, blend: number): void;
|
|
6
7
|
export declare function setSpotLightCone(out: SpotLight, innerDegrees: number, outerDegrees: number): void;
|
|
7
8
|
export declare function setSpotLightDirection(out: SpotLight, x: number, y: number, z: number): void;
|
package/dist/spotLight.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotLight.d.ts","sourceRoot":"","sources":["../src/spotLight.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"spotLight.d.ts","sourceRoot":"","sources":["../src/spotLight.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAIrH,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,SAAS,CAuBrE;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,CAyBpH;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,62 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { cloneVector3, createVector3, setVector3 } from '@flighthq/geometry/contract';
|
|
3
3
|
import { SpotLightKind, UnitlessLightUnit } from '@flighthq/types/contract';
|
|
4
4
|
// Independent copy of a spot light's data, including fresh `position`/`direction` vectors.
|
|
5
5
|
export function cloneSpotLight(source) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
const out = allocateEntity();
|
|
7
|
+
out.castsShadow = source.castsShadow;
|
|
8
|
+
out.color = source.color;
|
|
9
|
+
out.decay = source.decay;
|
|
10
|
+
out.direction = cloneVector3(source.direction);
|
|
11
|
+
out.enabled = source.enabled;
|
|
12
|
+
out.innerConeCos = source.innerConeCos;
|
|
13
|
+
out.intensity = source.intensity;
|
|
14
|
+
out.intensityUnit = source.intensityUnit;
|
|
15
|
+
out.kind = SpotLightKind;
|
|
16
|
+
out.normalBias = source.normalBias;
|
|
17
|
+
out.outerConeCos = source.outerConeCos;
|
|
18
|
+
out.pcfRadius = source.pcfRadius;
|
|
19
|
+
out.position = cloneVector3(source.position);
|
|
20
|
+
out.range = source.range;
|
|
21
|
+
out.shadowBias = source.shadowBias;
|
|
22
|
+
out.shadowFar = source.shadowFar;
|
|
23
|
+
out.shadowMapSize = source.shadowMapSize;
|
|
24
|
+
out.shadowNear = source.shadowNear;
|
|
25
|
+
out.shadowStrength = source.shadowStrength;
|
|
26
|
+
out.spotBlend = source.spotBlend;
|
|
27
|
+
return finishEntity(out);
|
|
28
28
|
}
|
|
29
|
-
// Cone-restricted point light. `position`/`direction` are world-space; the cone is stored as the
|
|
30
|
-
// precomputed cosines of its inner and outer half-angles (innerConeCos >= outerConeCos). Color is
|
|
31
|
-
// packed sRgb-albedo RGBA (0xrrggbbaa); defaults to opaque white at unit intensity, at the origin
|
|
32
|
-
// facing down (0, -1, 0), 0-degree inner / 45-degree outer cone, infinite range, shadows off.
|
|
33
29
|
export function createSpotLight(options) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const light = createEntity({
|
|
37
|
-
castsShadow: options?.castsShadow ?? false,
|
|
38
|
-
color: options?.color ?? 0xffffffff,
|
|
39
|
-
decay: options?.decay ?? 2,
|
|
40
|
-
direction: direction ? cloneVector3(direction) : createVector3(0, -1, 0),
|
|
41
|
-
enabled: options?.enabled ?? true,
|
|
42
|
-
innerConeCos: 1,
|
|
43
|
-
intensity: options?.intensity ?? 1,
|
|
44
|
-
intensityUnit: options?.intensityUnit ?? UnitlessLightUnit,
|
|
45
|
-
kind: SpotLightKind,
|
|
46
|
-
normalBias: options?.normalBias ?? 0,
|
|
47
|
-
outerConeCos: 1,
|
|
48
|
-
pcfRadius: options?.pcfRadius ?? 0,
|
|
49
|
-
position: position ? cloneVector3(position) : createVector3(0, 0, 0),
|
|
50
|
-
range: options?.range ?? -1,
|
|
51
|
-
shadowBias: options?.shadowBias ?? 0,
|
|
52
|
-
shadowFar: options?.shadowFar ?? 500,
|
|
53
|
-
shadowMapSize: options?.shadowMapSize ?? 1024,
|
|
54
|
-
shadowNear: options?.shadowNear ?? 0.5,
|
|
55
|
-
shadowStrength: options?.shadowStrength ?? 1,
|
|
56
|
-
spotBlend: 0,
|
|
57
|
-
});
|
|
58
|
-
setSpotLightCone(light, options?.innerConeDegrees ?? 0, options?.outerConeDegrees ?? 45);
|
|
59
|
-
setSpotLightBlend(light, options?.spotBlend ?? 0);
|
|
30
|
+
const light = allocateEntity();
|
|
31
|
+
initializeSpotLight(light, options);
|
|
60
32
|
return light;
|
|
61
33
|
}
|
|
62
34
|
// Reads the inner and outer cone half-angles from precomputed cosines and writes them as degrees
|
|
@@ -66,6 +38,36 @@ export function getSpotLightConeDegrees(out, source) {
|
|
|
66
38
|
out.innerDegrees = (Math.acos(source.innerConeCos) * 180) / Math.PI;
|
|
67
39
|
out.outerDegrees = (Math.acos(source.outerConeCos) * 180) / Math.PI;
|
|
68
40
|
}
|
|
41
|
+
// Cone-restricted point light. `position`/`direction` are world-space; the cone is stored as the
|
|
42
|
+
// precomputed cosines of its inner and outer half-angles (innerConeCos >= outerConeCos). Color is
|
|
43
|
+
// packed sRgb-albedo RGBA (0xrrggbbaa); defaults to opaque white at unit intensity, at the origin
|
|
44
|
+
// facing down (0, -1, 0), 0-degree inner / 45-degree outer cone, infinite range, shadows off.
|
|
45
|
+
export function initializeSpotLight(light, options) {
|
|
46
|
+
const position = options?.position;
|
|
47
|
+
const direction = options?.direction;
|
|
48
|
+
light.castsShadow = options?.castsShadow ?? false;
|
|
49
|
+
light.color = options?.color ?? 0xffffffff;
|
|
50
|
+
light.decay = options?.decay ?? 2;
|
|
51
|
+
light.direction = direction ? cloneVector3(direction) : createVector3(0, -1, 0);
|
|
52
|
+
light.enabled = options?.enabled ?? true;
|
|
53
|
+
light.innerConeCos = 1;
|
|
54
|
+
light.intensity = options?.intensity ?? 1;
|
|
55
|
+
light.intensityUnit = options?.intensityUnit ?? UnitlessLightUnit;
|
|
56
|
+
light.kind = SpotLightKind;
|
|
57
|
+
light.normalBias = options?.normalBias ?? 0;
|
|
58
|
+
light.outerConeCos = 1;
|
|
59
|
+
light.pcfRadius = options?.pcfRadius ?? 0;
|
|
60
|
+
light.position = position ? cloneVector3(position) : createVector3(0, 0, 0);
|
|
61
|
+
light.range = options?.range ?? -1;
|
|
62
|
+
light.shadowBias = options?.shadowBias ?? 0;
|
|
63
|
+
light.shadowFar = options?.shadowFar ?? 500;
|
|
64
|
+
light.shadowMapSize = options?.shadowMapSize ?? 1024;
|
|
65
|
+
light.shadowNear = options?.shadowNear ?? 0.5;
|
|
66
|
+
light.shadowStrength = options?.shadowStrength ?? 1;
|
|
67
|
+
light.spotBlend = 0;
|
|
68
|
+
setSpotLightCone(light, options?.innerConeDegrees ?? 0, options?.outerConeDegrees ?? 45);
|
|
69
|
+
setSpotLightBlend(light, options?.spotBlend ?? 0);
|
|
70
|
+
}
|
|
69
71
|
// Writes a normalized penumbra blend. Values outside [0, 1] are clamped rather than rejected so
|
|
70
72
|
// inspector and animation inputs remain safe to apply directly.
|
|
71
73
|
export function setSpotLightBlend(out, blend) {
|
package/dist/spotLight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotLight.js","sourceRoot":"","sources":["../src/spotLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"spotLight.js","sourceRoot":"","sources":["../src/spotLight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE5E,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,C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AI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACnD,IAAI,GAAG,GAAG,CAAC,EAAE,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/lighting",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.903.f434bc2",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/color": "0.5.1-next.
|
|
42
|
-
"@flighthq/entity": "0.5.1-next.
|
|
43
|
-
"@flighthq/geometry": "0.5.1-next.
|
|
44
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/color": "0.5.1-next.903.f434bc2",
|
|
42
|
+
"@flighthq/entity": "0.5.1-next.903.f434bc2",
|
|
43
|
+
"@flighthq/geometry": "0.5.1-next.903.f434bc2",
|
|
44
|
+
"@flighthq/types": "0.5.1-next.903.f434bc2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"typescript": "^5.3.0"
|
package/src/environment.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { createVector2 } from '@flighthq/geometry/contract';
|
|
3
3
|
import type { Texture, Sampler } from '@flighthq/types/contract';
|
|
4
4
|
import { EnvironmentKind } from '@flighthq/types/contract';
|
|
@@ -6,26 +6,25 @@ import { EnvironmentKind } from '@flighthq/types/contract';
|
|
|
6
6
|
import { cloneEnvironment, createEnvironment } from './environment';
|
|
7
7
|
|
|
8
8
|
function createTestCubeTexture(): Texture {
|
|
9
|
-
const sampler
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
9
|
+
const sampler = allocateEntity<any>();
|
|
10
|
+
sampler.anisotropy = 1;
|
|
11
|
+
sampler.magFilter = 'linear';
|
|
12
|
+
sampler.minFilter = 'linear';
|
|
13
|
+
sampler.mipmaps = false;
|
|
14
|
+
sampler.wrapU = 'clamp-to-edge';
|
|
15
|
+
sampler.wrapV = 'clamp-to-edge';
|
|
16
|
+
const out = allocateEntity<any>();
|
|
17
|
+
out.colorSpace = 'linear';
|
|
18
|
+
out.flipX = false;
|
|
19
|
+
out.flipY = false;
|
|
20
|
+
out.sampler = sampler;
|
|
21
|
+
out.dimension = 'cube';
|
|
22
|
+
out.sources = [null, null, null, null, null, null];
|
|
23
|
+
out.uvOffset = createVector2();
|
|
24
|
+
out.uvRotation = 0;
|
|
25
|
+
out.uvScale = createVector2(1, 1);
|
|
26
|
+
out.version = 0;
|
|
27
|
+
return finishEntity(out);
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
describe('cloneEnvironment', () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { createBoundingSphere } from '@flighthq/geometry/contract';
|
|
3
3
|
|
|
4
4
|
import { createAmbientLight } from './ambientLight';
|
|
@@ -161,7 +161,12 @@ describe('getLightLuminance', () => {
|
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
it('returns zero for an open custom kind even when it resembles a colored light', () => {
|
|
164
|
-
const
|
|
164
|
+
const _light = allocateEntity<any>();
|
|
165
|
+
_light.color = 0xffffffff;
|
|
166
|
+
_light.enabled = true;
|
|
167
|
+
_light.intensity = 5;
|
|
168
|
+
_light.kind = 'acme:GlowLight';
|
|
169
|
+
const light = finishEntity(_light);
|
|
165
170
|
expect(getLightLuminance(light)).toBe(0);
|
|
166
171
|
});
|
|
167
172
|
|
|
@@ -288,14 +293,22 @@ describe('isLightCastingShadow', () => {
|
|
|
288
293
|
// is the assertion that separates the two: a truthiness check would accept `undefined` and report
|
|
289
294
|
// this as working.
|
|
290
295
|
it('returns strict false for a custom light kind that declares no castsShadow', () => {
|
|
291
|
-
const
|
|
296
|
+
const _light = allocateEntity<any>();
|
|
297
|
+
_light.color = 0xffffffff;
|
|
298
|
+
_light.intensity = 1;
|
|
299
|
+
_light.kind = 'acme:GlowLight';
|
|
300
|
+
const light = finishEntity(_light);
|
|
292
301
|
expect(isLightCastingShadow(light)).toBe(false);
|
|
293
302
|
});
|
|
294
303
|
|
|
295
304
|
// Guards the return TYPE rather than its truthiness, so the contract cannot regress to `undefined`
|
|
296
305
|
// while every `toBe(false)` assertion still passes by coincidence.
|
|
297
306
|
it('returns a boolean for every light, including custom kinds', () => {
|
|
298
|
-
const
|
|
307
|
+
const _custom = allocateEntity<any>();
|
|
308
|
+
_custom.color = 0xffffffff;
|
|
309
|
+
_custom.intensity = 1;
|
|
310
|
+
_custom.kind = 'acme:GlowLight';
|
|
311
|
+
const custom = finishEntity(_custom);
|
|
299
312
|
expect(typeof isLightCastingShadow(custom)).toBe('boolean');
|
|
300
313
|
expect(typeof isLightCastingShadow(createAmbientLight())).toBe('boolean');
|
|
301
314
|
expect(typeof isLightCastingShadow(createDirectionalLight({ castsShadow: true }))).toBe('boolean');
|
|
@@ -304,8 +317,14 @@ describe('isLightCastingShadow', () => {
|
|
|
304
317
|
// A custom kind that DOES opt in must still be honoured — the fix must not flatten every custom
|
|
305
318
|
// light to false, which would be the easy over-correction.
|
|
306
319
|
it('honours castsShadow on a custom light kind that declares it', () => {
|
|
307
|
-
const
|
|
308
|
-
|
|
320
|
+
const _casting = allocateEntity<any>();
|
|
321
|
+
_casting.castsShadow = true;
|
|
322
|
+
_casting.kind = 'acme:GlowLight';
|
|
323
|
+
const casting = finishEntity(_casting);
|
|
324
|
+
const _notCasting = allocateEntity<any>();
|
|
325
|
+
_notCasting.castsShadow = false;
|
|
326
|
+
_notCasting.kind = 'acme:GlowLight';
|
|
327
|
+
const notCasting = finishEntity(_notCasting);
|
|
309
328
|
expect(isLightCastingShadow(casting)).toBe(true);
|
|
310
329
|
expect(isLightCastingShadow(notCasting)).toBe(false);
|
|
311
330
|
});
|
|
@@ -313,7 +332,10 @@ describe('isLightCastingShadow', () => {
|
|
|
313
332
|
// A non-boolean `castsShadow` is a programmer error, not a configuration; the query still has to
|
|
314
333
|
// return a boolean rather than leaking the foreign value to a caller that declared it cannot get one.
|
|
315
334
|
it('returns a boolean when a custom kind carries a non-boolean castsShadow', () => {
|
|
316
|
-
const
|
|
335
|
+
const _light = allocateEntity<any>();
|
|
336
|
+
_light.castsShadow = 1;
|
|
337
|
+
_light.kind = 'acme:GlowLight';
|
|
338
|
+
const light = finishEntity(_light);
|
|
317
339
|
expect(typeof isLightCastingShadow(light)).toBe('boolean');
|
|
318
340
|
});
|
|
319
341
|
});
|