@flighthq/scene2d-gl 0.3.1-next.780.12e6944 → 0.3.1-next.794.0bfc53e
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/glNode2D.d.ts.map +1 -1
- package/dist/glNode2D.js +12 -0
- package/dist/glNode2D.js.map +1 -1
- package/package.json +19 -19
- package/src/glNode2D.test.ts +21 -0
package/dist/glNode2D.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glNode2D.d.ts","sourceRoot":"","sources":["../src/glNode2D.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAItG,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,GAAG,IAAI,CAEtF;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"glNode2D.d.ts","sourceRoot":"","sources":["../src/glNode2D.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAItG,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,GAAG,IAAI,CAEtF;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CA8C1E;AAED,eAAO,MAAM,wBAAwB,EAAE,eAGtC,CAAC"}
|
package/dist/glNode2D.js
CHANGED
|
@@ -6,6 +6,18 @@ export function drawGlScene2D(_state, _renderProxy) {
|
|
|
6
6
|
// Plain display objects have no visual geometry of their own.
|
|
7
7
|
}
|
|
8
8
|
export function renderGlScene2D(state, source) {
|
|
9
|
+
const gl = state.gl;
|
|
10
|
+
// The 2D pass establishes the state it draws under rather than depending on a context-lifetime
|
|
11
|
+
// invariant. These were previously taken on trust from createGlRenderState, which runs once per state,
|
|
12
|
+
// so correctness rested on every pass that exists — or is ever added — leaving them alone. That is not
|
|
13
|
+
// a bug count, it is an unenforceable precondition: the 3D path already does this correctly by setting
|
|
14
|
+
// depth and cull per draw, and the 2D path was the only one paying for the difference.
|
|
15
|
+
// Culling is the destructive one and it does not degrade, it erases: the 2D quad is wound
|
|
16
|
+
// (x0,y0)(x1,y0)(x1,y1) in a y-down space that the projection flips, making it a BACK face under the
|
|
17
|
+
// CCW default, so a single-sided 3D draw earlier in the frame removes all 2D content.
|
|
18
|
+
gl.disable(gl.CULL_FACE);
|
|
19
|
+
gl.disable(gl.DEPTH_TEST);
|
|
20
|
+
gl.enable(gl.BLEND);
|
|
9
21
|
const tempStack = getGlRenderStateRuntime(state).tempStack;
|
|
10
22
|
const clipHooks = state.displayObjectClipHooks;
|
|
11
23
|
let stackLength = 1;
|
package/dist/glNode2D.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glNode2D.js","sourceRoot":"","sources":["../src/glNode2D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,UAAU,aAAa,CAAC,MAAqB,EAAE,YAA2B;IAC9E,8DAA8D;AAChE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAoB,EAAE,MAAc;IAClE,MAAM,SAAS,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC;IAC3D,MAAM,SAAS,GAAG,KAAK,CAAC,sBAAsB,CAAC;I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IAAI,IAAI,KAAK,SAAS;YAAE,SAAS;QAEjC,SAAS,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAEzC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;YAAE,SAAS;QAE1C,SAAS,EAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACnC,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;YACpD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACtB,KAAK,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC9C,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAW,CAAC;gBACnD,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9B,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAoB;IACvD,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,aAAa;CACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/scene2d-gl",
|
|
3
|
-
"version": "0.3.1-next.
|
|
3
|
+
"version": "0.3.1-next.794.0bfc53e",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,24 +38,24 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/color": "0.3.1-next.
|
|
42
|
-
"@flighthq/scene2d": "0.3.1-next.
|
|
43
|
-
"@flighthq/scene2d-canvas": "0.3.1-next.
|
|
44
|
-
"@flighthq/geometry": "0.3.1-next.
|
|
45
|
-
"@flighthq/image": "0.3.1-next.
|
|
46
|
-
"@flighthq/log": "0.3.1-next.
|
|
47
|
-
"@flighthq/node": "0.3.1-next.
|
|
48
|
-
"@flighthq/path": "0.3.1-next.
|
|
49
|
-
"@flighthq/registry": "0.3.1-next.
|
|
50
|
-
"@flighthq/render": "0.3.1-next.
|
|
51
|
-
"@flighthq/render-gl": "0.3.1-next.
|
|
52
|
-
"@flighthq/shape": "0.3.1-next.
|
|
53
|
-
"@flighthq/text": "0.3.1-next.
|
|
54
|
-
"@flighthq/textinput": "0.3.1-next.
|
|
55
|
-
"@flighthq/textlayout": "0.3.1-next.
|
|
56
|
-
"@flighthq/texture": "0.3.1-next.
|
|
57
|
-
"@flighthq/types": "0.3.1-next.
|
|
58
|
-
"@flighthq/velocity": "0.3.1-next.
|
|
41
|
+
"@flighthq/color": "0.3.1-next.794.0bfc53e",
|
|
42
|
+
"@flighthq/scene2d": "0.3.1-next.794.0bfc53e",
|
|
43
|
+
"@flighthq/scene2d-canvas": "0.3.1-next.794.0bfc53e",
|
|
44
|
+
"@flighthq/geometry": "0.3.1-next.794.0bfc53e",
|
|
45
|
+
"@flighthq/image": "0.3.1-next.794.0bfc53e",
|
|
46
|
+
"@flighthq/log": "0.3.1-next.794.0bfc53e",
|
|
47
|
+
"@flighthq/node": "0.3.1-next.794.0bfc53e",
|
|
48
|
+
"@flighthq/path": "0.3.1-next.794.0bfc53e",
|
|
49
|
+
"@flighthq/registry": "0.3.1-next.794.0bfc53e",
|
|
50
|
+
"@flighthq/render": "0.3.1-next.794.0bfc53e",
|
|
51
|
+
"@flighthq/render-gl": "0.3.1-next.794.0bfc53e",
|
|
52
|
+
"@flighthq/shape": "0.3.1-next.794.0bfc53e",
|
|
53
|
+
"@flighthq/text": "0.3.1-next.794.0bfc53e",
|
|
54
|
+
"@flighthq/textinput": "0.3.1-next.794.0bfc53e",
|
|
55
|
+
"@flighthq/textlayout": "0.3.1-next.794.0bfc53e",
|
|
56
|
+
"@flighthq/texture": "0.3.1-next.794.0bfc53e",
|
|
57
|
+
"@flighthq/types": "0.3.1-next.794.0bfc53e",
|
|
58
|
+
"@flighthq/velocity": "0.3.1-next.794.0bfc53e"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@flighthq/bitmaptext": "*",
|
package/src/glNode2D.test.ts
CHANGED
|
@@ -36,6 +36,27 @@ describe('drawGlScene2D', () => {
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
describe('renderGlScene2D', () => {
|
|
39
|
+
it('establishes its own cull, depth, and blend state rather than inheriting it from a previous 3D pass', () => {
|
|
40
|
+
const state = makeState();
|
|
41
|
+
const gl = state.gl;
|
|
42
|
+
// Real WebGL2 confirms the consequence this guards: Flight's 2D quad is wound (x0,y0)(x1,y0)(x1,y1)
|
|
43
|
+
// in a y-down space that the projection flips, so it is a BACK face under the CCW default. Drawing
|
|
44
|
+
// it with CULL_FACE left enabled by the 3D mesh path erases 2D content entirely — 2304 lit pixels
|
|
45
|
+
// become 0. Depth testing is the same class: a stale 3D depth buffer rejects 2D fragments.
|
|
46
|
+
// Seeded to the exact hostile state a prior 3D pass leaves: cull and depth on, blend off. Starting
|
|
47
|
+
// from the API default would make "sets what it needs" indistinguishable from "changed nothing".
|
|
48
|
+
const enabled = new Set<number>([gl.CULL_FACE, gl.DEPTH_TEST]);
|
|
49
|
+
(gl.isEnabled as ReturnType<typeof vi.fn>).mockImplementation((cap: number) => enabled.has(cap));
|
|
50
|
+
(gl.enable as ReturnType<typeof vi.fn>).mockImplementation((cap: number) => enabled.add(cap));
|
|
51
|
+
(gl.disable as ReturnType<typeof vi.fn>).mockImplementation((cap: number) => enabled.delete(cap));
|
|
52
|
+
|
|
53
|
+
renderGlScene2D(state, createDisplayObject());
|
|
54
|
+
|
|
55
|
+
expect(enabled.has(gl.CULL_FACE)).toBe(false);
|
|
56
|
+
expect(enabled.has(gl.DEPTH_TEST)).toBe(false);
|
|
57
|
+
expect(enabled.has(gl.BLEND)).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
|
|
39
60
|
it('does not throw for an empty display object', () => {
|
|
40
61
|
const state = makeState();
|
|
41
62
|
const obj = createDisplayObject();
|