@fps-games/editor 0.1.3-beta.1 → 0.1.3-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/node_modules/@fps-games/babylon-renderer/dist/index.d.ts +5 -0
  2. package/node_modules/@fps-games/babylon-renderer/dist/index.d.ts.map +1 -0
  3. package/node_modules/@fps-games/babylon-renderer/dist/index.js +5 -0
  4. package/node_modules/@fps-games/babylon-renderer/dist/index.js.map +1 -0
  5. package/node_modules/@fps-games/babylon-renderer/dist/lighting/directional-light-angles.d.ts +17 -0
  6. package/node_modules/@fps-games/babylon-renderer/dist/lighting/directional-light-angles.d.ts.map +1 -0
  7. package/node_modules/@fps-games/babylon-renderer/dist/lighting/directional-light-angles.js +64 -0
  8. package/node_modules/@fps-games/babylon-renderer/dist/lighting/directional-light-angles.js.map +1 -0
  9. package/node_modules/@fps-games/babylon-renderer/dist/shadows/planar-shadow-shaders.d.ts +7 -0
  10. package/node_modules/@fps-games/babylon-renderer/dist/shadows/planar-shadow-shaders.d.ts.map +1 -0
  11. package/node_modules/@fps-games/babylon-renderer/dist/shadows/planar-shadow-shaders.js +176 -0
  12. package/node_modules/@fps-games/babylon-renderer/dist/shadows/planar-shadow-shaders.js.map +1 -0
  13. package/node_modules/@fps-games/babylon-renderer/dist/shadows/planar-shadow-system.d.ts +5 -0
  14. package/node_modules/@fps-games/babylon-renderer/dist/shadows/planar-shadow-system.d.ts.map +1 -0
  15. package/node_modules/@fps-games/babylon-renderer/dist/shadows/planar-shadow-system.js +837 -0
  16. package/node_modules/@fps-games/babylon-renderer/dist/shadows/planar-shadow-system.js.map +1 -0
  17. package/node_modules/@fps-games/babylon-renderer/dist/shadows/types.d.ts +96 -0
  18. package/node_modules/@fps-games/babylon-renderer/dist/shadows/types.d.ts.map +1 -0
  19. package/node_modules/@fps-games/babylon-renderer/dist/shadows/types.js +45 -0
  20. package/node_modules/@fps-games/babylon-renderer/dist/shadows/types.js.map +1 -0
  21. package/node_modules/@fps-games/babylon-renderer/package.json +20 -0
  22. package/node_modules/@fps-games/editor-babylon/package.json +5 -5
  23. package/node_modules/@fps-games/editor-browser/package.json +2 -2
  24. package/node_modules/@fps-games/editor-core/package.json +2 -2
  25. package/node_modules/@fps-games/editor-forge-play/package.json +2 -2
  26. package/node_modules/@fps-games/editor-protocol/package.json +1 -1
  27. package/package.json +7 -7
@@ -0,0 +1,5 @@
1
+ export * from './lighting/directional-light-angles';
2
+ export * from './shadows/planar-shadow-system';
3
+ export * from './shadows/planar-shadow-shaders';
4
+ export * from './shadows/types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './lighting/directional-light-angles';
2
+ export * from './shadows/planar-shadow-system';
3
+ export * from './shadows/planar-shadow-shaders';
4
+ export * from './shadows/types';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,17 @@
1
+ export interface BabylonRendererVec3 {
2
+ x: number;
3
+ y: number;
4
+ z: number;
5
+ }
6
+ export declare const DEFAULT_DIRECTIONAL_LIGHT_DIRECTION: BabylonRendererVec3;
7
+ export declare const LIGHT_DIRECTION_HORIZONTAL_MIN_DEG = -180;
8
+ export declare const LIGHT_DIRECTION_HORIZONTAL_MAX_DEG = 180;
9
+ export declare const LIGHT_DIRECTION_ELEVATION_MIN_DEG = -90;
10
+ export declare const LIGHT_DIRECTION_ELEVATION_MAX_DEG = 90;
11
+ export declare function normalizeDirectionVector(direction: BabylonRendererVec3 | undefined, fallback?: BabylonRendererVec3): BabylonRendererVec3;
12
+ export declare function readDirectionalLightAngles(direction: BabylonRendererVec3 | undefined): {
13
+ horizontalAngleDeg: number;
14
+ elevationAngleDeg: number;
15
+ };
16
+ export declare function createDirectionalLightDirectionFromAngles(horizontalAngleDeg: number, elevationAngleDeg: number): BabylonRendererVec3;
17
+ //# sourceMappingURL=directional-light-angles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directional-light-angles.d.ts","sourceRoot":"","sources":["../../src/lighting/directional-light-angles.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,eAAO,MAAM,mCAAmC,EAAE,mBAAiD,CAAC;AACpG,eAAO,MAAM,kCAAkC,OAAO,CAAC;AACvD,eAAO,MAAM,kCAAkC,MAAM,CAAC;AACtD,eAAO,MAAM,iCAAiC,MAAM,CAAC;AACrD,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAEpD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,mBAAmB,GAAG,SAAS,EAC1C,QAAQ,GAAE,mBAAyD,GAClE,mBAAmB,CAgBrB;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,mBAAmB,GAAG,SAAS,GAAG;IACtF,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAMA;AAED,wBAAgB,yCAAyC,CACvD,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,EAAE,MAAM,GACxB,mBAAmB,CAarB"}
@@ -0,0 +1,64 @@
1
+ export const DEFAULT_DIRECTIONAL_LIGHT_DIRECTION = { x: -0.3, y: -1, z: -0.2 };
2
+ export const LIGHT_DIRECTION_HORIZONTAL_MIN_DEG = -180;
3
+ export const LIGHT_DIRECTION_HORIZONTAL_MAX_DEG = 180;
4
+ export const LIGHT_DIRECTION_ELEVATION_MIN_DEG = -90;
5
+ export const LIGHT_DIRECTION_ELEVATION_MAX_DEG = 90;
6
+ export function normalizeDirectionVector(direction, fallback = DEFAULT_DIRECTIONAL_LIGHT_DIRECTION) {
7
+ const candidate = direction && isVec3(direction) ? direction : fallback;
8
+ const length = Math.hypot(candidate.x, candidate.y, candidate.z);
9
+ if (!Number.isFinite(length) || length <= 0.000001) {
10
+ const fallbackLength = Math.hypot(fallback.x, fallback.y, fallback.z) || 1;
11
+ return {
12
+ x: fallback.x / fallbackLength,
13
+ y: fallback.y / fallbackLength,
14
+ z: fallback.z / fallbackLength,
15
+ };
16
+ }
17
+ return {
18
+ x: candidate.x / length,
19
+ y: candidate.y / length,
20
+ z: candidate.z / length,
21
+ };
22
+ }
23
+ export function readDirectionalLightAngles(direction) {
24
+ const normalized = normalizeDirectionVector(direction);
25
+ return {
26
+ horizontalAngleDeg: Math.round(normalizeAngleDegrees(radiansToDegrees(Math.atan2(normalized.z, normalized.x)))),
27
+ elevationAngleDeg: Math.round(radiansToDegrees(Math.asin(clampNumber(-normalized.y, -1, 1)))),
28
+ };
29
+ }
30
+ export function createDirectionalLightDirectionFromAngles(horizontalAngleDeg, elevationAngleDeg) {
31
+ const horizontal = degreesToRadians(normalizeAngleDegrees(horizontalAngleDeg));
32
+ const elevation = degreesToRadians(clampNumber(elevationAngleDeg, LIGHT_DIRECTION_ELEVATION_MIN_DEG, LIGHT_DIRECTION_ELEVATION_MAX_DEG));
33
+ const horizontalLength = Math.cos(elevation);
34
+ return {
35
+ x: roundVectorComponent(horizontalLength * Math.cos(horizontal)),
36
+ y: roundVectorComponent(-Math.sin(elevation)),
37
+ z: roundVectorComponent(horizontalLength * Math.sin(horizontal)),
38
+ };
39
+ }
40
+ function isVec3(value) {
41
+ return typeof value.x === 'number'
42
+ && Number.isFinite(value.x)
43
+ && typeof value.y === 'number'
44
+ && Number.isFinite(value.y)
45
+ && typeof value.z === 'number'
46
+ && Number.isFinite(value.z);
47
+ }
48
+ function radiansToDegrees(value) {
49
+ return (value * 180) / Math.PI;
50
+ }
51
+ function degreesToRadians(value) {
52
+ return (value * Math.PI) / 180;
53
+ }
54
+ function roundVectorComponent(value) {
55
+ return Math.round(value * 1000000) / 1000000;
56
+ }
57
+ function clampNumber(value, min, max) {
58
+ return Math.min(max, Math.max(min, value));
59
+ }
60
+ function normalizeAngleDegrees(value) {
61
+ const normalized = ((((value + 180) % 360) + 360) % 360) - 180;
62
+ return normalized === -180 ? 180 : normalized;
63
+ }
64
+ //# sourceMappingURL=directional-light-angles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directional-light-angles.js","sourceRoot":"","sources":["../../src/lighting/directional-light-angles.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,mCAAmC,GAAwB,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;AACpG,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,GAAG,CAAC;AACvD,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,CAAC;AACtD,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,EAAE,CAAC;AACrD,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAEpD,MAAM,UAAU,wBAAwB,CACtC,SAA0C,EAC1C,WAAgC,mCAAmC;IAEnE,MAAM,SAAS,GAAG,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACjE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,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AC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAa;IAC1C,MAAM,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IAC/D,OAAO,UAAU,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC;AAChD,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const PLANAR_SHADOW_SHADER_NAME = "fpsPlanarShadow";
2
+ export declare function registerPlanarShadowShaders(): void;
3
+ export declare function getPlanarShadowShaderAttributes(): string[];
4
+ export declare function getPlanarShadowShaderUniforms(): string[];
5
+ export declare function getPlanarShadowShaderSamplers(): string[];
6
+ export declare function getPlanarShadowSkeletonDefines(numBones: number, useTexture: boolean, hasExtraInfluence: boolean): string[];
7
+ //# sourceMappingURL=planar-shadow-shaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planar-shadow-shaders.d.ts","sourceRoot":"","sources":["../../src/shadows/planar-shadow-shaders.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAE3D,wBAAgB,2BAA2B,IAAI,IAAI,CAwIlD;AAED,wBAAgB,+BAA+B,IAAI,MAAM,EAAE,CAQ1D;AAED,wBAAgB,6BAA6B,IAAI,MAAM,EAAE,CAcxD;AAED,wBAAgB,6BAA6B,IAAI,MAAM,EAAE,CAExD;AAED,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,OAAO,EACnB,iBAAiB,EAAE,OAAO,GACzB,MAAM,EAAE,CAMV"}
@@ -0,0 +1,176 @@
1
+ import { Effect } from '@babylonjs/core/Materials/effect';
2
+ export const PLANAR_SHADOW_SHADER_NAME = 'fpsPlanarShadow';
3
+ export function registerPlanarShadowShaders() {
4
+ const vertexKey = `${PLANAR_SHADOW_SHADER_NAME}VertexShader`;
5
+ if (Effect.ShadersStore[vertexKey])
6
+ return;
7
+ Effect.ShadersStore[vertexKey] = `
8
+ precision highp float;
9
+
10
+ attribute vec3 position;
11
+
12
+ #ifdef BONE
13
+ attribute vec4 matricesIndices;
14
+ attribute vec4 matricesWeights;
15
+ #ifdef BONETEXTURE
16
+ uniform sampler2D boneSampler;
17
+ uniform float boneTextureWidth;
18
+ #else
19
+ uniform mat4 mBones[BonesPerMesh];
20
+ #endif
21
+ #ifdef BONES_VELOCITY_ENABLED
22
+ attribute vec4 matricesIndicesExtra;
23
+ attribute vec4 matricesWeightsExtra;
24
+ #endif
25
+ #endif
26
+
27
+ uniform mat4 world;
28
+ uniform mat4 viewProjection;
29
+ uniform vec3 u_lightDir;
30
+ uniform vec3 u_planeNormal;
31
+ uniform vec3 u_shadowCenter;
32
+ uniform float u_planeHeight;
33
+ uniform float u_planeBias;
34
+ uniform float u_footprintScale;
35
+
36
+ varying float v_t;
37
+
38
+ #ifdef BONE
39
+ #ifdef BONETEXTURE
40
+ mat4 readMatrixFromRawSampler(sampler2D smp, float index) {
41
+ float offset = index * 4.0;
42
+ float dx = 1.0 / boneTextureWidth;
43
+ vec4 m0 = texture2D(smp, vec2(dx * (offset + 0.5), 0.));
44
+ vec4 m1 = texture2D(smp, vec2(dx * (offset + 1.5), 0.));
45
+ vec4 m2 = texture2D(smp, vec2(dx * (offset + 2.5), 0.));
46
+ vec4 m3 = texture2D(smp, vec2(dx * (offset + 3.5), 0.));
47
+ return mat4(m0, m1, m2, m3);
48
+ }
49
+ #endif
50
+ #endif
51
+
52
+ void main() {
53
+ #ifdef FLAT_SHADOW
54
+ vec3 projPos = (world * vec4(position, 1.0)).xyz;
55
+ v_t = 1.0;
56
+
57
+ vec4 clipPos = viewProjection * vec4(projPos, 1.0);
58
+ clipPos.z -= u_planeBias * 2e-4 * clipPos.w;
59
+
60
+ gl_Position = clipPos;
61
+ return;
62
+ #endif
63
+
64
+ #ifdef BONE
65
+ #ifdef BONETEXTURE
66
+ mat4 m0 = readMatrixFromRawSampler(boneSampler, matricesIndices.x);
67
+ mat4 m1 = readMatrixFromRawSampler(boneSampler, matricesIndices.y);
68
+ mat4 m2 = readMatrixFromRawSampler(boneSampler, matricesIndices.z);
69
+ mat4 m3 = readMatrixFromRawSampler(boneSampler, matricesIndices.w);
70
+ #else
71
+ mat4 m0 = mBones[int(matricesIndices.x)];
72
+ mat4 m1 = mBones[int(matricesIndices.y)];
73
+ mat4 m2 = mBones[int(matricesIndices.z)];
74
+ mat4 m3 = mBones[int(matricesIndices.w)];
75
+ #endif
76
+
77
+ mat4 influence = m0 * matricesWeights.x +
78
+ m1 * matricesWeights.y +
79
+ m2 * matricesWeights.z +
80
+ m3 * matricesWeights.w;
81
+
82
+ #ifdef BONES_VELOCITY_ENABLED
83
+ #ifdef BONETEXTURE
84
+ mat4 m4 = readMatrixFromRawSampler(boneSampler, matricesIndicesExtra.x);
85
+ mat4 m5 = readMatrixFromRawSampler(boneSampler, matricesIndicesExtra.y);
86
+ mat4 m6 = readMatrixFromRawSampler(boneSampler, matricesIndicesExtra.z);
87
+ mat4 m7 = readMatrixFromRawSampler(boneSampler, matricesIndicesExtra.w);
88
+ #else
89
+ mat4 m4 = mBones[int(matricesIndicesExtra.x)];
90
+ mat4 m5 = mBones[int(matricesIndicesExtra.y)];
91
+ mat4 m6 = mBones[int(matricesIndicesExtra.z)];
92
+ mat4 m7 = mBones[int(matricesIndicesExtra.w)];
93
+ #endif
94
+
95
+ influence += m4 * matricesWeightsExtra.x +
96
+ m5 * matricesWeightsExtra.y +
97
+ m6 * matricesWeightsExtra.z +
98
+ m7 * matricesWeightsExtra.w;
99
+ #endif
100
+
101
+ mat4 finalWorld = world * influence;
102
+ vec3 worldPos = (finalWorld * vec4(position, 1.0)).xyz;
103
+ #else
104
+ vec3 worldPos = (world * vec4(position, 1.0)).xyz;
105
+ #endif
106
+
107
+ float denom = dot(u_planeNormal, u_lightDir);
108
+ if (abs(denom) < 1e-5) {
109
+ v_t = -1.0;
110
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
111
+ return;
112
+ }
113
+
114
+ float t = (u_planeHeight - dot(u_planeNormal, worldPos)) / denom;
115
+ v_t = t;
116
+
117
+ vec3 projPos = worldPos + u_lightDir * t;
118
+ projPos = u_shadowCenter + (projPos - u_shadowCenter) * u_footprintScale;
119
+ projPos += u_planeNormal * (u_planeBias * 0.002);
120
+
121
+ vec4 clipPos = viewProjection * vec4(projPos, 1.0);
122
+ clipPos.z -= u_planeBias * 2e-4 * clipPos.w;
123
+
124
+ gl_Position = clipPos;
125
+ }
126
+ `;
127
+ Effect.ShadersStore[`${PLANAR_SHADOW_SHADER_NAME}FragmentShader`] = `
128
+ precision highp float;
129
+
130
+ uniform vec4 u_shadowColor;
131
+ varying float v_t;
132
+
133
+ void main() {
134
+ if (v_t < 0.0) discard;
135
+ gl_FragColor = u_shadowColor;
136
+ }
137
+ `;
138
+ }
139
+ export function getPlanarShadowShaderAttributes() {
140
+ return [
141
+ 'position',
142
+ 'matricesIndices',
143
+ 'matricesWeights',
144
+ 'matricesIndicesExtra',
145
+ 'matricesWeightsExtra',
146
+ ];
147
+ }
148
+ export function getPlanarShadowShaderUniforms() {
149
+ return [
150
+ 'world',
151
+ 'viewProjection',
152
+ 'u_lightDir',
153
+ 'u_planeNormal',
154
+ 'u_shadowCenter',
155
+ 'u_planeHeight',
156
+ 'u_planeBias',
157
+ 'u_footprintScale',
158
+ 'u_shadowColor',
159
+ 'mBones',
160
+ 'boneTextureWidth',
161
+ ];
162
+ }
163
+ export function getPlanarShadowShaderSamplers() {
164
+ return ['boneSampler'];
165
+ }
166
+ export function getPlanarShadowSkeletonDefines(numBones, useTexture, hasExtraInfluence) {
167
+ const defines = ['BONE'];
168
+ if (useTexture)
169
+ defines.push('BONETEXTURE');
170
+ else
171
+ defines.push(`BonesPerMesh ${numBones}`);
172
+ if (hasExtraInfluence)
173
+ defines.push('BONES_VELOCITY_ENABLED');
174
+ return defines;
175
+ }
176
+ //# sourceMappingURL=planar-shadow-shaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planar-shadow-shaders.js","sourceRoot":"","sources":["../../src/shadows/planar-shadow-shaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAE1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,iBAAiB,CAAC;AAE3D,MAAM,UAAU,2BAA2B;IACzC,MAAM,SAAS,GAAG,GAAG,yBAAyB,cAAc,CAAC;IAC7D,IAAI,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC;QAAE,OAAO;IAE3C,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuHlC,CAAC;IAEA,MAAM,CAAC,YAAY,CAAC,GAAG,yBAAyB,gBAAgB,CAAC,GAAG;;;;;;;;;;CAUrE,CAAC;AACF,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,OAAO;QACL,UAAU;QACV,iBAAiB;QACjB,iBAAiB;QACjB,sBAAsB;QACtB,sBAAsB;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,OAAO;QACL,OAAO;QACP,gBAAgB;QAChB,YAAY;QACZ,eAAe;QACf,gBAAgB;QAChB,eAAe;QACf,aAAa;QACb,kBAAkB;QAClB,eAAe;QACf,QAAQ;QACR,kBAAkB;KACnB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,OAAO,CAAC,aAAa,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,QAAgB,EAChB,UAAmB,EACnB,iBAA0B;IAE1B,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,UAAU;QAAE,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;QACvC,OAAO,CAAC,IAAI,CAAC,gBAAgB,QAAQ,EAAE,CAAC,CAAC;IAC9C,IAAI,iBAAiB;QAAE,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAC9D,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { DirectionalLight } from '@babylonjs/core/Lights/directionalLight';
2
+ import type { Scene } from '@babylonjs/core/scene';
3
+ import { type PlanarShadowOptions, type PlanarShadowSystem } from './types';
4
+ export declare function createPlanarShadowSystem(scene: Scene, directionalLight: DirectionalLight, options?: Partial<PlanarShadowOptions>): PlanarShadowSystem;
5
+ //# sourceMappingURL=planar-shadow-system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planar-shadow-system.d.ts","sourceRoot":"","sources":["../../src/shadows/planar-shadow-system.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAY3E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD,OAAO,EAGL,KAAK,mBAAmB,EAExB,KAAK,kBAAkB,EAExB,MAAM,SAAS,CAAC;AAoCjB,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,KAAK,EACZ,gBAAgB,EAAE,gBAAgB,EAClC,OAAO,GAAE,OAAO,CAAC,mBAAmB,CAAM,GACzC,kBAAkB,CAEpB"}