@nova-lab/core 1.1.2-dev.255 → 1.2.1-dev.258
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/dist/2d/lighting.js +226 -191
- package/dist/2d.js +1 -1
- package/dist/{NovaTextSelectionService-CPRzGqvI.js → NovaTextSelectionService-Bdi0AqZ5.js} +199 -189
- package/dist/core.js +1 -1
- package/dist/model/lighting/LightingRenderer2D.d.ts +1 -0
- package/dist/model/lighting/NovaLighting2D.d.ts +1 -0
- package/dist/model/lighting/lighting-shaders.d.ts +1 -1
- package/dist/model/lighting/lighting.types.d.ts +5 -0
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { D as o, a as s, N as t, b as r, R as n, S as N, c as v, d as i, e as c, f as d, g as l, h as p, i as S, j as m, k as R, m as u, n as C, r as A, l as T, o as h, p as E, q as g, s as P, t as y, u as f, v as M } from "./NovaNode-CBZ-Ol-W.js";
|
|
2
|
-
import { A as b, C as _, a as x, E as D, G as O, N as B, b as V, c as G, d as L, e as k, f as F, g as H, h as j, i as z, j as q, k as K, l as Y, m as U, n as W, o as w, p as J, q as Q, r as X, s as Z, t as $, u as aa, v as ea, w as oa, x as sa, y as ta, z as ra, B as na, D as Na, F as va, H as ia, I as ca, J as da, J as la, K as pa, L as Sa, M as ma, O as Ra, P as ua, Q as Ca, R as Aa, S as Ta, T as ha, U as Ea, V as ga, W as Pa, X as ya, Y as fa, Z as Ma, _ as Ia, $ as ba, a0 as _a, a1 as xa, a2 as Da, a3 as Oa, a4 as Ba, a5 as Va, a6 as Ga, a7 as La, a8 as ka, a9 as Fa, aa as Ha, ab as ja, ac as za, ad as qa, ae as Ka, af as Ya, ag as Ua, ah as Wa, ai as wa, aj as Ja, ak as Qa, al as Xa, am as Za, an as $a, ao as ae, ap as ee, aq as oe, ar as se, as as te, at as re, au as ne, av as Ne, aw as ve, ax as ie, ay as ce, az as de, aA as le, aB as pe, aC as Se, aD as me, aE as Re, aF as ue, aG as Ce, aH as Ae, aI as Te, aJ as he, aK as Ee, aL as ge, aM as Pe, aN as ye, aO as fe, aP as Me, aQ as Ie, aR as be, aS as _e, aT as xe, aU as De, aV as Oe, aW as Be, aX as Ve, aY as Ge, aZ as Le, a_ as ke, a$ as Fe, b0 as He, b1 as je, b2 as ze, b3 as qe, b4 as Ke, b5 as Ye, b6 as Ue, b7 as We, b8 as we } from "./NovaTextSelectionService-
|
|
2
|
+
import { A as b, C as _, a as x, E as D, G as O, N as B, b as V, c as G, d as L, e as k, f as F, g as H, h as j, i as z, j as q, k as K, l as Y, m as U, n as W, o as w, p as J, q as Q, r as X, s as Z, t as $, u as aa, v as ea, w as oa, x as sa, y as ta, z as ra, B as na, D as Na, F as va, H as ia, I as ca, J as da, J as la, K as pa, L as Sa, M as ma, O as Ra, P as ua, Q as Ca, R as Aa, S as Ta, T as ha, U as Ea, V as ga, W as Pa, X as ya, Y as fa, Z as Ma, _ as Ia, $ as ba, a0 as _a, a1 as xa, a2 as Da, a3 as Oa, a4 as Ba, a5 as Va, a6 as Ga, a7 as La, a8 as ka, a9 as Fa, aa as Ha, ab as ja, ac as za, ad as qa, ae as Ka, af as Ya, ag as Ua, ah as Wa, ai as wa, aj as Ja, ak as Qa, al as Xa, am as Za, an as $a, ao as ae, ap as ee, aq as oe, ar as se, as as te, at as re, au as ne, av as Ne, aw as ve, ax as ie, ay as ce, az as de, aA as le, aB as pe, aC as Se, aD as me, aE as Re, aF as ue, aG as Ce, aH as Ae, aI as Te, aJ as he, aK as Ee, aL as ge, aM as Pe, aN as ye, aO as fe, aP as Me, aQ as Ie, aR as be, aS as _e, aT as xe, aU as De, aV as Oe, aW as Be, aX as Ve, aY as Ge, aZ as Le, a_ as ke, a$ as Fe, b0 as He, b1 as je, b2 as ze, b3 as qe, b4 as Ke, b5 as Ye, b6 as Ue, b7 as We, b8 as we } from "./NovaTextSelectionService-Bdi0AqZ5.js";
|
|
3
3
|
import { N as Qe, R as Xe, c as Ze, a as $e, b as ao, d as eo, e as oo, f as so, g as to, h as ro, i as no, j as No, k as vo, l as io, m as co, n as lo, o as po, r as So, p as mo, s as Ro, q as uo } from "./NovaRenderCommandWriter-CWQRa42y.js";
|
|
4
4
|
import { b as Ao, a as To, c as ho, d as Eo, e as go, p as Po, f as yo, s as fo, t as Mo, u as Io } from "./nova-color-parser-BCN_rFRN.js";
|
|
5
5
|
import { N as _o, a as xo, c as Do, b as Oo, d as Bo, e as Vo, f as Go, g as Lo, h as ko, i as Fo, j as Ho, k as jo, l as zo, m as qo, n as Ko, o as Yo, r as Uo } from "./NovaAssetRegistry-p2QlCwvT.js";
|
|
@@ -5,6 +5,7 @@ export interface LightingFrame2D {
|
|
|
5
5
|
lights: LightState2D[];
|
|
6
6
|
occluders: Readonly<NovaLightOccluderOptions2D>[];
|
|
7
7
|
receivers: Readonly<NovaLightReceiverOptions2D>[];
|
|
8
|
+
ignoredOccluders: ReadonlyMap<Readonly<NovaLightReceiverOptions2D>, number>;
|
|
8
9
|
receiverRevision: number;
|
|
9
10
|
ambient: readonly number[];
|
|
10
11
|
bounds: NovaLightingBounds2D;
|
|
@@ -7,6 +7,7 @@ import { NovaDirectionalLightOptions2D, NovaLightingHandle2D, NovaLightingOption
|
|
|
7
7
|
export declare class NovaLighting2D {
|
|
8
8
|
private readonly _lights;
|
|
9
9
|
private readonly _occluders;
|
|
10
|
+
private readonly _occluderValues;
|
|
10
11
|
private readonly _receivers;
|
|
11
12
|
private readonly _renderer;
|
|
12
13
|
private readonly _options;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const lightingVertex2D = "#version 300 es\nprecision highp float;\nout vec2 uv;\nvoid main(){\n vec2 p=vec2(float((gl_VertexID<<1)&2),float(gl_VertexID&2));\n uv=vec2(p.x,1.-p.y);\n gl_Position=vec4(p*2.-1.,0.,1.);\n}";
|
|
2
|
-
export declare const lightingFragment2D = "#version 300 es\nprecision highp float;\nprecision highp int;\nin vec2 uv;\nout vec4 outColor;\nuniform sampler2D heights;\nuniform highp sampler2D geometry;\nuniform vec4 bounds;\nuniform vec3 ambient;\nuniform float groundScale, maxHeight;\nuniform int lightCount, casterCount;\nuniform vec4 positions[8], colors[8], directions[8], cones[8], shadows[8];\nfloat cross2(vec2 a,vec2 b){return a.x*b.y-a.y*b.x;}\nbool blocked(vec3 p,vec3 end,int layers){\n vec3 d=end-p;\n for(int c=0;c<64;c++){\n if(c>=casterCount)break;\n vec4 h=texelFetch(geometry,ivec2(0,c),0);\n if((int(h.z)&layers)==0)continue;\n vec4 bb=texelFetch(geometry,ivec2(9,c),0);\n if(any(lessThan(max(p.xy,end.xy),bb.xy))||any(greaterThan(min(p.xy,end.xy),bb.zw)))continue;\n float lo=.001, hi=.999;\n if(abs(d.z)<.00001){if(p.z<h.y||p.z>h.y+h.x)continue;}\n else{\n float a=(h.y-p.z)/d.z,b=(h.y+h.x-p.z)/d.z;\n lo=max(lo,min(a,b));hi=min(hi,max(a,b));\n }\n int n=int(h.w);\n for(int i=0;i<8;i++){\n if(i>=n||lo>hi)break;\n vec2 a=texelFetch(geometry,ivec2(i+1,c),0).xy;\n vec2 b=texelFetch(geometry,ivec2((i+1)%n+1,c),0).xy;\n float f=cross2(b-a,p.xy-a),g=cross2(b-a,d.xy);\n if(abs(g)<.00001){if(f<0.){hi=-1.;break;}}\n else if(g>0.)lo=max(lo,-f/g);\n else hi=min(hi,-f/g);\n }\n if(lo<hi)return true;\n }\n return false;\n}\nvoid main(){\n vec2 screen=bounds.xy+uv*bounds.zw;\n vec4 field=texture(heights,uv);\n if(
|
|
2
|
+
export declare const lightingFragment2D = "#version 300 es\nprecision highp float;\nprecision highp int;\nin vec2 uv;\nout vec4 outColor;\nuniform sampler2D heights;\nuniform highp sampler2D geometry;\nuniform vec4 bounds;\nuniform vec3 ambient;\nuniform float groundScale, maxHeight;\nuniform int lightCount, casterCount, categoricalField;\nuniform vec4 positions[8], colors[8], directions[8], cones[8], shadows[8];\nfloat cross2(vec2 a,vec2 b){return a.x*b.y-a.y*b.x;}\nbool blocked(vec3 p,vec3 end,int layers,int ignored){\n vec3 d=end-p;\n for(int c=0;c<64;c++){\n if(c>=casterCount)break;\n if(c==ignored)continue;\n vec4 h=texelFetch(geometry,ivec2(0,c),0);\n if((int(h.z)&layers)==0)continue;\n vec4 bb=texelFetch(geometry,ivec2(9,c),0);\n if(any(lessThan(max(p.xy,end.xy),bb.xy))||any(greaterThan(min(p.xy,end.xy),bb.zw)))continue;\n float lo=.001, hi=.999;\n if(abs(d.z)<.00001){if(p.z<h.y||p.z>h.y+h.x)continue;}\n else{\n float a=(h.y-p.z)/d.z,b=(h.y+h.x-p.z)/d.z;\n lo=max(lo,min(a,b));hi=min(hi,max(a,b));\n }\n int n=int(h.w);\n for(int i=0;i<8;i++){\n if(i>=n||lo>hi)break;\n vec2 a=texelFetch(geometry,ivec2(i+1,c),0).xy;\n vec2 b=texelFetch(geometry,ivec2((i+1)%n+1,c),0).xy;\n float f=cross2(b-a,p.xy-a),g=cross2(b-a,d.xy);\n if(abs(g)<.00001){if(f<0.){hi=-1.;break;}}\n else if(g>0.)lo=max(lo,-f/g);\n else hi=min(hi,-f/g);\n }\n if(lo<hi)return true;\n }\n return false;\n}\nvoid main(){\n vec2 screen=bounds.xy+uv*bounds.zw;\n vec4 field=texture(heights,uv);\n ivec2 size=textureSize(heights,0);\n vec4 material=categoricalField>0?texelFetch(heights,clamp(ivec2(uv*vec2(size)),ivec2(0),size-1),0):field;\n if(material.b>(categoricalField>0?.99:.5)){outColor=vec4(vec3(64./255.),1.);return;}\n float z=field.r*maxHeight;\n int receiverLayers=int(round(material.g*255.));\n int ignored=categoricalField>0?int(round(material.b*255.))-1:-1;\n vec3 p=vec3(screen.x,(screen.y+z)/groundScale,z);\n vec3 light=ambient;\n for(int i=0;i<8;i++){\n if(i>=lightCount)break;\n int layers=int(cones[i].z);\n if((layers&receiverLayers)==0)continue;\n bool directional=positions[i].w<.5;\n vec3 end=directional?p-directions[i].xyz*shadows[i].w:positions[i].xyz;\n float amount=colors[i].w;\n if(!directional){\n vec3 delta=p-end;\n float dist=length(delta);\n if(dist>=directions[i].w)continue;\n amount*=pow(max(0.,1.-dist/directions[i].w),cones[i].w);\n if(positions[i].w>1.5)amount*=smoothstep(cones[i].y,cones[i].x,dot(delta/max(dist,.00001),directions[i].xyz));\n }\n if(amount<.00001)continue;\n if(shadows[i].x>0.){\n float visibility=0.;\n float radius=shadows[i].y*(directional?shadows[i].w:1.);\n int samples=radius>0.?8:1;\n for(int s=0;s<8;s++){\n if(s>=samples)break;\n float angle=float(s)*2.39996323;\n vec2 disk=vec2(cos(angle),sin(angle))*sqrt((float(s)+.5)/8.);\n vec3 target=end+vec3(disk*radius,0.);\n visibility+=blocked(p,target,layers,ignored)?0.:1./float(samples);\n }\n amount*=mix(1.,visibility,shadows[i].x);\n }\n light+=colors[i].rgb*amount;\n }\n // 1 maps EXACTLY to byte 64: the neutral baseline does not introduce a seam.\n outColor=vec4(clamp(light*(64./255.),0.,1.),1.);\n}";
|
|
3
3
|
export declare const lightingComposite2D = "#version 300 es\nprecision highp float;\nin vec2 uv;\nout vec4 outColor;\nuniform sampler2D albedo, illumination;\nvec3 linearRGB(vec3 c){return mix(c/12.92,pow((c+.055)/1.055,vec3(2.4)),step(vec3(.04045),c));}\nvec3 srgb(vec3 c){return mix(c*12.92,1.055*pow(max(c,vec3(0.)),vec3(1./2.4))-.055,step(vec3(.0031308),c));}\nvoid main(){\n vec4 art=texture(albedo,uv);\n vec3 irradiance=texture(illumination,vec2(uv.x,1.-uv.y)).rgb*(255./64.);\n outColor=vec4(srgb(clamp(linearRGB(art.rgb)*irradiance,0.,1.)),art.a);\n}";
|
|
@@ -64,6 +64,11 @@ export interface NovaLightOccluderOptions2D {
|
|
|
64
64
|
enabled?: boolean;
|
|
65
65
|
}
|
|
66
66
|
export interface NovaLightReceiverOptions2D {
|
|
67
|
+
/**
|
|
68
|
+
* Skip this same-scene proxy for this receiver only; it still shadows the world.
|
|
69
|
+
* A disposed/disabled/culled proxy no longer excludes anything. Foreign handles reject.
|
|
70
|
+
*/
|
|
71
|
+
ignoreOccluder?: NovaLightingHandle2D<NovaLightOccluderOptions2D>;
|
|
67
72
|
/** Borrowed alpha silhouette. The engine never closes this image. */
|
|
68
73
|
image: CanvasImageSource;
|
|
69
74
|
/** Projected image bounds; top-of-image height ramps down to its bottom. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nova-lab/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1
|
|
4
|
+
"version": "1.2.1-dev.258",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
"example:courier": "vite --config examples/courier/vite.config.ts",
|
|
216
216
|
"example:fps": "vite --config examples/fps/vite.config.ts",
|
|
217
217
|
"example:rpg": "vite --config examples/rpg/vite.config.ts",
|
|
218
|
-
"lint:release": "eslint src
|
|
218
|
+
"lint:release": "eslint src/model/render/backends/webgl/NovaWebGLFrameRenderer.ts",
|
|
219
219
|
"test:release": "node node_modules/vitest/vitest.mjs run --maxWorkers=1 --exclude \"**/benchmarks/**\" --exclude \"**/*.bench.*\" --exclude \"**/*.performance.*\" --exclude \"**/performance/**\" --config vite.config.ts"
|
|
220
220
|
},
|
|
221
221
|
"peerDependencies": {
|