@flighthq/displayobject-gl 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/glBitmap.d.ts +4 -0
- package/dist/glBitmap.d.ts.map +1 -0
- package/dist/glBitmap.js +106 -0
- package/dist/glBitmap.js.map +1 -0
- package/dist/glCache.d.ts +30 -0
- package/dist/glCache.d.ts.map +1 -0
- package/dist/glCache.js +185 -0
- package/dist/glCache.js.map +1 -0
- package/dist/glClip.d.ts +3 -0
- package/dist/glClip.d.ts.map +1 -0
- package/dist/glClip.js +46 -0
- package/dist/glClip.js.map +1 -0
- package/dist/glClipContours.d.ts +4 -0
- package/dist/glClipContours.d.ts.map +1 -0
- package/dist/glClipContours.js +148 -0
- package/dist/glClipContours.js.map +1 -0
- package/dist/glClipRectangle.d.ts +4 -0
- package/dist/glClipRectangle.d.ts.map +1 -0
- package/dist/glClipRectangle.js +68 -0
- package/dist/glClipRectangle.js.map +1 -0
- package/dist/glColorTransformMaterial.d.ts +4 -0
- package/dist/glColorTransformMaterial.d.ts.map +1 -0
- package/dist/glColorTransformMaterial.js +116 -0
- package/dist/glColorTransformMaterial.js.map +1 -0
- package/dist/glDefaultMaterial.d.ts +4 -0
- package/dist/glDefaultMaterial.d.ts.map +1 -0
- package/dist/glDefaultMaterial.js +20 -0
- package/dist/glDefaultMaterial.js.map +1 -0
- package/dist/glDisplayObject.d.ts +5 -0
- package/dist/glDisplayObject.d.ts.map +1 -0
- package/dist/glDisplayObject.js +41 -0
- package/dist/glDisplayObject.js.map +1 -0
- package/dist/glDisplayObjectRegistration.d.ts +25 -0
- package/dist/glDisplayObjectRegistration.d.ts.map +1 -0
- package/dist/glDisplayObjectRegistration.js +51 -0
- package/dist/glDisplayObjectRegistration.js.map +1 -0
- package/dist/glMaterials.d.ts +4 -0
- package/dist/glMaterials.d.ts.map +1 -0
- package/dist/glMaterials.js +97 -0
- package/dist/glMaterials.js.map +1 -0
- package/dist/glParticleEmitter.d.ts +4 -0
- package/dist/glParticleEmitter.d.ts.map +1 -0
- package/dist/glParticleEmitter.js +258 -0
- package/dist/glParticleEmitter.js.map +1 -0
- package/dist/glQuadBatch.d.ts +3 -0
- package/dist/glQuadBatch.d.ts.map +1 -0
- package/dist/glQuadBatch.js +88 -0
- package/dist/glQuadBatch.js.map +1 -0
- package/dist/glRichText.d.ts +9 -0
- package/dist/glRichText.d.ts.map +1 -0
- package/dist/glRichText.js +149 -0
- package/dist/glRichText.js.map +1 -0
- package/dist/glScale9Mapper.d.ts +3 -0
- package/dist/glScale9Mapper.d.ts.map +1 -0
- package/dist/glScale9Mapper.js +37 -0
- package/dist/glScale9Mapper.js.map +1 -0
- package/dist/glScale9Shape.d.ts +9 -0
- package/dist/glScale9Shape.d.ts.map +1 -0
- package/dist/glScale9Shape.js +118 -0
- package/dist/glScale9Shape.js.map +1 -0
- package/dist/glShape.d.ts +4 -0
- package/dist/glShape.d.ts.map +1 -0
- package/dist/glShape.js +125 -0
- package/dist/glShape.js.map +1 -0
- package/dist/glShapeMesh.d.ts +9 -0
- package/dist/glShapeMesh.d.ts.map +1 -0
- package/dist/glShapeMesh.js +90 -0
- package/dist/glShapeMesh.js.map +1 -0
- package/dist/glSprite.d.ts +3 -0
- package/dist/glSprite.d.ts.map +1 -0
- package/dist/glSprite.js +28 -0
- package/dist/glSprite.js.map +1 -0
- package/dist/glSpriteBatch.d.ts +11 -0
- package/dist/glSpriteBatch.d.ts.map +1 -0
- package/dist/glSpriteBatch.js +241 -0
- package/dist/glSpriteBatch.js.map +1 -0
- package/dist/glSpriteRenderer.d.ts +3 -0
- package/dist/glSpriteRenderer.d.ts.map +1 -0
- package/dist/glSpriteRenderer.js +50 -0
- package/dist/glSpriteRenderer.js.map +1 -0
- package/dist/glTestHelper.d.ts +9 -0
- package/dist/glTestHelper.d.ts.map +1 -0
- package/dist/glTestHelper.js +17 -0
- package/dist/glTestHelper.js.map +1 -0
- package/dist/glTextInput.d.ts +4 -0
- package/dist/glTextInput.d.ts.map +1 -0
- package/dist/glTextInput.js +43 -0
- package/dist/glTextInput.js.map +1 -0
- package/dist/glTextLabel.d.ts +4 -0
- package/dist/glTextLabel.d.ts.map +1 -0
- package/dist/glTextLabel.js +130 -0
- package/dist/glTextLabel.js.map +1 -0
- package/dist/glTilemap.d.ts +3 -0
- package/dist/glTilemap.d.ts.map +1 -0
- package/dist/glTilemap.js +74 -0
- package/dist/glTilemap.js.map +1 -0
- package/dist/glUniformColorTransformMaterial.d.ts +4 -0
- package/dist/glUniformColorTransformMaterial.d.ts.map +1 -0
- package/dist/glUniformColorTransformMaterial.js +56 -0
- package/dist/glUniformColorTransformMaterial.js.map +1 -0
- package/dist/glVelocity.d.ts +22 -0
- package/dist/glVelocity.d.ts.map +1 -0
- package/dist/glVelocity.js +319 -0
- package/dist/glVelocity.js.map +1 -0
- package/dist/glVideo.d.ts +6 -0
- package/dist/glVideo.d.ts.map +1 -0
- package/dist/glVideo.js +60 -0
- package/dist/glVideo.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/moduleMockTestHelper.d.ts +15 -0
- package/dist/moduleMockTestHelper.d.ts.map +1 -0
- package/dist/moduleMockTestHelper.js +25 -0
- package/dist/moduleMockTestHelper.js.map +1 -0
- package/package.json +51 -0
- package/src/glBitmap.test.ts +128 -0
- package/src/glCache.test.ts +230 -0
- package/src/glClip.test.ts +101 -0
- package/src/glClipContours.test.ts +61 -0
- package/src/glClipRectangle.test.ts +47 -0
- package/src/glColorTransformMaterial.test.ts +45 -0
- package/src/glDefaultMaterial.test.ts +19 -0
- package/src/glDisplayObject.test.ts +85 -0
- package/src/glDisplayObjectRegistration.test.ts +130 -0
- package/src/glMaterials.test.ts +91 -0
- package/src/glParticleEmitter.test.ts +98 -0
- package/src/glQuadBatch.test.ts +132 -0
- package/src/glRichText.test.ts +135 -0
- package/src/glScale9Mapper.test.ts +20 -0
- package/src/glScale9Shape.test.ts +90 -0
- package/src/glShape.test.ts +115 -0
- package/src/glShapeMesh.test.ts +64 -0
- package/src/glSprite.test.ts +79 -0
- package/src/glSpriteBatch.test.ts +153 -0
- package/src/glSpriteRenderer.test.ts +75 -0
- package/src/glTextInput.test.ts +51 -0
- package/src/glTextLabel.test.ts +151 -0
- package/src/glTilemap.test.ts +127 -0
- package/src/glUniformColorTransformMaterial.test.ts +24 -0
- package/src/glVelocity.test.ts +155 -0
- package/src/glVideo.test.ts +65 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { noopRendererData } from '@flighthq/render';
|
|
2
|
+
import { resolveGlMaterialRenderer } from '@flighthq/render-gl';
|
|
3
|
+
import { getGlRenderStateRuntime } from '@flighthq/render-gl';
|
|
4
|
+
import { BatchFormat } from '@flighthq/types';
|
|
5
|
+
import { ensureGlQuadBatchShader, packGlSpriteBatchMaterialInstance, prepareGlSpriteBatchWrite } from './glSpriteBatch';
|
|
6
|
+
const INSTANCE_FLOATS = 13;
|
|
7
|
+
function submitGlTilemap(state, tilemapNode) {
|
|
8
|
+
const runtime = getGlRenderStateRuntime(state);
|
|
9
|
+
const source = tilemapNode.source;
|
|
10
|
+
const { tileset, columns, rows, tiles } = source.data;
|
|
11
|
+
if (tileset === null)
|
|
12
|
+
return;
|
|
13
|
+
const atlas = tileset.atlas;
|
|
14
|
+
if (atlas === null || atlas.image === null || atlas.image.source === null)
|
|
15
|
+
return;
|
|
16
|
+
if (columns === 0 || rows === 0)
|
|
17
|
+
return;
|
|
18
|
+
ensureGlQuadBatchShader(state);
|
|
19
|
+
const material = tilemapNode.material;
|
|
20
|
+
const materialRenderer = resolveGlMaterialRenderer(state, material);
|
|
21
|
+
if (materialRenderer === null)
|
|
22
|
+
return;
|
|
23
|
+
const nodeMaterialData = tilemapNode.materialData;
|
|
24
|
+
const perTileMaterialData = source.data.materialData;
|
|
25
|
+
const startCount = runtime.spriteBatchCount;
|
|
26
|
+
const base = prepareGlSpriteBatchWrite(state, atlas.image.source, tilemapNode.blendMode, material, materialRenderer, columns * rows);
|
|
27
|
+
const regions = atlas.regions;
|
|
28
|
+
const numRegions = regions.length;
|
|
29
|
+
const { tileWidth, tileHeight } = tileset;
|
|
30
|
+
const iw = 1 / (atlas.image.width || 1);
|
|
31
|
+
const ih = 1 / (atlas.image.height || 1);
|
|
32
|
+
const instanceData = runtime.spriteBatchInstanceData;
|
|
33
|
+
const pt = tilemapNode.transform2D;
|
|
34
|
+
const pa = pt.a, pb = pt.b, pc = pt.c, pd = pt.d, ptx = pt.tx, pty = pt.ty;
|
|
35
|
+
const alpha = tilemapNode.alpha;
|
|
36
|
+
let writeBase = base;
|
|
37
|
+
let drawCount = 0;
|
|
38
|
+
for (let row = 0; row < rows; row++) {
|
|
39
|
+
for (let col = 0; col < columns; col++) {
|
|
40
|
+
const id = tiles[row * columns + col];
|
|
41
|
+
if (id < 0 || id >= numRegions)
|
|
42
|
+
continue;
|
|
43
|
+
const region = regions[id];
|
|
44
|
+
if (region.width <= 0 || region.height <= 0)
|
|
45
|
+
continue;
|
|
46
|
+
const dx = col * tileWidth;
|
|
47
|
+
const dy = row * tileHeight;
|
|
48
|
+
instanceData[writeBase] = pa;
|
|
49
|
+
instanceData[writeBase + 1] = pb;
|
|
50
|
+
instanceData[writeBase + 2] = pc;
|
|
51
|
+
instanceData[writeBase + 3] = pd;
|
|
52
|
+
instanceData[writeBase + 4] = pa * dx + pc * dy + ptx;
|
|
53
|
+
instanceData[writeBase + 5] = pb * dx + pd * dy + pty;
|
|
54
|
+
instanceData[writeBase + 6] = tileWidth;
|
|
55
|
+
instanceData[writeBase + 7] = tileHeight;
|
|
56
|
+
instanceData[writeBase + 8] = region.x * iw;
|
|
57
|
+
instanceData[writeBase + 9] = region.y * ih;
|
|
58
|
+
instanceData[writeBase + 10] = (region.x + region.width) * iw;
|
|
59
|
+
instanceData[writeBase + 11] = (region.y + region.height) * ih;
|
|
60
|
+
instanceData[writeBase + 12] = alpha;
|
|
61
|
+
const md = perTileMaterialData?.[row * columns + col] ?? nodeMaterialData;
|
|
62
|
+
packGlSpriteBatchMaterialInstance(state, md, startCount + drawCount);
|
|
63
|
+
writeBase += INSTANCE_FLOATS;
|
|
64
|
+
drawCount++;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
runtime.spriteBatchCount += drawCount;
|
|
68
|
+
}
|
|
69
|
+
export const defaultGlTilemapRenderer = {
|
|
70
|
+
format: BatchFormat.Quad,
|
|
71
|
+
createData: noopRendererData,
|
|
72
|
+
submit: submitGlTilemap,
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=glTilemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glTilemap.js","sourceRoot":"","sources":["../src/glTilemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,uBAAuB,EAAE,iCAAiC,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAExH,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,SAAS,eAAe,CAAC,KAAoB,EAAE,WAA0B;IACvE,MAAM,OAAO,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,WAAW,CAAC,MAAiB,CAAC;IAC7C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;IAEtD,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,KA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G,EAAE,GAAG,GAAG,CAAC;YACtD,YAAY,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC;YACxC,YAAY,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;YACzC,YAAY,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;YAC5C,YAAY,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;YAC5C,YAAY,CAAC,SAAS,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YAC9D,YAAY,CAAC,SAAS,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;YAC/D,YAAY,CAAC,SAAS,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;YACrC,MAAM,EAAE,GAAG,mBAAmB,EAAE,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,CAAC,IAAI,gBAAgB,CAAC;YAC1E,iCAAiC,CAAC,KAAK,EAAE,EAAE,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;YACrE,SAAS,IAAI,eAAe,CAAC;YAC7B,SAAS,EAAE,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,CAAC,gBAAgB,IAAI,SAAS,CAAC;AACxC,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAmB;IACtD,MAAM,EAAE,WAAW,CAAC,IAAI;IACxB,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,eAAe;CACxB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GlMaterialRenderer, GlRenderState } from '@flighthq/types';
|
|
2
|
+
export declare function registerGlUniformColorTransformMaterial(state: GlRenderState): void;
|
|
3
|
+
export declare const uniformColorTransformGlMaterialRenderer: GlMaterialRenderer;
|
|
4
|
+
//# sourceMappingURL=glUniformColorTransformMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glUniformColorTransformMaterial.d.ts","sourceRoot":"","sources":["../src/glUniformColorTransformMaterial.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAA2C,MAAM,iBAAiB,CAAC;AA6ClH,wBAAgB,uCAAuC,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAElF;AAKD,eAAO,MAAM,uCAAuC,EAAE,kBAyBrD,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createGlProgram } from '@flighthq/render-gl';
|
|
2
|
+
import { registerGlMaterialRenderer } from '@flighthq/render-gl';
|
|
3
|
+
import { getGlRenderStateRuntime } from '@flighthq/render-gl';
|
|
4
|
+
import { UniformColorTransformMaterialKind } from '@flighthq/types';
|
|
5
|
+
import { bindGlQuadBatchBaseAttributes, QUAD_BATCH_VS, setGlQuadBatchWorldAndTexture, useGlQuadBatchProgram, } from './glSpriteBatch';
|
|
6
|
+
const UNIFORM_CT_FS = `#version 300 es
|
|
7
|
+
precision mediump float;
|
|
8
|
+
in vec2 v_texCoord;
|
|
9
|
+
in float v_alpha;
|
|
10
|
+
uniform sampler2D u_texture;
|
|
11
|
+
uniform vec4 u_ctMult;
|
|
12
|
+
uniform vec4 u_ctOff;
|
|
13
|
+
out vec4 fragColor;
|
|
14
|
+
void main() {
|
|
15
|
+
vec4 color = texture(u_texture, v_texCoord) * clamp(v_alpha, 0.0, 1.0);
|
|
16
|
+
if (color.a <= 0.0) discard;
|
|
17
|
+
color = vec4(color.rgb / color.a, color.a);
|
|
18
|
+
color = clamp(color * u_ctMult + u_ctOff, vec4(0.0), vec4(1.0));
|
|
19
|
+
fragColor = vec4(color.rgb * color.a, color.a);
|
|
20
|
+
}`;
|
|
21
|
+
function ensureGlUniformColorTransformShader(state) {
|
|
22
|
+
const runtime = getGlRenderStateRuntime(state);
|
|
23
|
+
if (runtime.uniformColorTransformShader)
|
|
24
|
+
return runtime.uniformColorTransformShader;
|
|
25
|
+
const gl = state.gl;
|
|
26
|
+
const program = createGlProgram(gl, QUAD_BATCH_VS, UNIFORM_CT_FS, 'Uniform color-transform material');
|
|
27
|
+
runtime.uniformColorTransformShader = {
|
|
28
|
+
program,
|
|
29
|
+
locCorner: 0,
|
|
30
|
+
locWorldMatrix: gl.getUniformLocation(program, 'u_world'),
|
|
31
|
+
locTexture: gl.getUniformLocation(program, 'u_texture'),
|
|
32
|
+
locColorMultiplier: gl.getUniformLocation(program, 'u_ctMult'),
|
|
33
|
+
locColorOffset: gl.getUniformLocation(program, 'u_ctOff'),
|
|
34
|
+
};
|
|
35
|
+
return runtime.uniformColorTransformShader;
|
|
36
|
+
}
|
|
37
|
+
export function registerGlUniformColorTransformMaterial(state) {
|
|
38
|
+
registerGlMaterialRenderer(state, UniformColorTransformMaterialKind, uniformColorTransformGlMaterialRenderer);
|
|
39
|
+
}
|
|
40
|
+
// Per-batch color transform: the value lives on the material and uploads as a uniform shared by the
|
|
41
|
+
// whole batch. Uses its own shader (the base vertex shader + a color-transform fragment shader) so
|
|
42
|
+
// the default quad-batch shader carries no color-transform record.
|
|
43
|
+
export const uniformColorTransformGlMaterialRenderer = {
|
|
44
|
+
instanceFloatCount: 0,
|
|
45
|
+
bind(state, material) {
|
|
46
|
+
const shader = ensureGlUniformColorTransformShader(state);
|
|
47
|
+
useGlQuadBatchProgram(state, shader.program);
|
|
48
|
+
setGlQuadBatchWorldAndTexture(state, shader.locWorldMatrix, shader.locTexture);
|
|
49
|
+
const gl = state.gl;
|
|
50
|
+
const ct = material.colorTransform;
|
|
51
|
+
gl.uniform4f(shader.locColorMultiplier, ct.redMultiplier, ct.greenMultiplier, ct.blueMultiplier, ct.alphaMultiplier);
|
|
52
|
+
gl.uniform4f(shader.locColorOffset, ct.redOffset / 255, ct.greenOffset / 255, ct.blueOffset / 255, ct.alphaOffset / 255);
|
|
53
|
+
bindGlQuadBatchBaseAttributes(state, shader.locCorner);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=glUniformColorTransformMaterial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glUniformColorTransformMaterial.js","sourceRoot":"","sources":["../src/glUniformColorTransformMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EACL,6BAA6B,EAC7B,aAAa,EACb,6BAA6B,EAC7B,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,aAAa,GAAG;;;;;;;;;;;;;;EAcpB,CAAC;AAEH,SAAS,mCAAmC,CAAC,KAAoB;IAC/D,MAAM,OAAO,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,OAAO,CAAC,2BAA2B;QAAE,OAAO,OAAO,CAAC,2BAA2B,CAAC;IAEpF,MAAM,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IACpB,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE,kCAAkC,CAAC,CAAC;IAEtG,OAAO,CAAC,2BAA2B,GAAG;QACpC,OAAO;QACP,SAAS,EAAE,CAAC;QACZ,cAAc,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAE;QAC1D,UAAU,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAE;QACxD,kBAAkB,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAE;QAC/D,cAAc,EAAE,EA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elocityField } from '@flighthq/types';
|
|
2
|
+
/** Allocates an rgba16f render target sized to hold a signed, sub-pixel screen-space velocity buffer. */
|
|
3
|
+
export declare function createGlVelocityTarget(state: GlRenderState, width: number, height: number): GlRenderTarget;
|
|
4
|
+
export declare const defaultGlDisplayObjectVelocityWriter: GlVelocityWriter;
|
|
5
|
+
export declare const defaultGlParticleEmitterVelocityWriter: GlVelocityWriter;
|
|
6
|
+
export declare const defaultGlQuadBatchVelocityWriter: GlVelocityWriter;
|
|
7
|
+
/**
|
|
8
|
+
* Draws one velocity quad: a device-pixel rect (x, y, width, height) filled with (velocityX, velocityY)
|
|
9
|
+
* in node units (scaled by pixelRatio here). The velocity program must be current — the velocity pass
|
|
10
|
+
* sets it up before dispatching writers. Writers call this once per covered region (once for a display
|
|
11
|
+
* object's bounds; once per instance for a batch).
|
|
12
|
+
*/
|
|
13
|
+
export declare function drawGlVelocityQuad(ctx: Readonly<GlVelocityContext>, x: number, y: number, width: number, height: number, velocityX: number, velocityY: number): void;
|
|
14
|
+
export declare function getGlVelocityWriter(state: GlRenderState, kind: Kind): GlVelocityWriter | null;
|
|
15
|
+
export declare function registerGlVelocityWriter(state: GlRenderState, kind: Kind, writer: GlVelocityWriter): void;
|
|
16
|
+
/**
|
|
17
|
+
* Walks `root`'s subtree and writes every moving renderable's velocity into `target`, dispatching the
|
|
18
|
+
* registered GlVelocityWriter for each node's kind. Nodes whose kind has no writer are skipped; the
|
|
19
|
+
* cleared (0,0,0,0) background means zero velocity. Restores the previously bound framebuffer.
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderGlVelocity<Traits extends object>(state: GlRenderState, root: Readonly<Transform2DNode<Traits>>, field: VelocityField, target: Readonly<GlRenderTarget>): void;
|
|
22
|
+
//# sourceMappingURL=glVelocity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glVelocity.d.ts","sourceRoot":"","sources":["../src/glVelocity.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,IAAI,EAKJ,eAAe,EAEf,aAAa,EACd,MAAM,iBAAiB,CAAC;AAgBzB,yGAAyG;AACzG,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAE1G;AAID,eAAO,MAAM,oCAAoC,EAAE,gBAOlD,CAAC;AAWF,eAAO,MAAM,sCAAsC,EAAE,gBA6DpD,CAAC;AAeF,eAAO,MAAM,gCAAgC,EAAE,gBAwF9C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,QAAQ,CAAC,iBAAiB,CAAC,EAChC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,IAAI,CAUN;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,GAAG,gBAAgB,GAAG,IAAI,CAE7F;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAOzG;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,MAAM,EACpD,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,EACvC,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,GAC/B,IAAI,CA2BN"}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { ensureNodeWorldBoundsRectangle, ensureNodeWorldTransformMatrix, getNodeChildAt, getNodeChildCount, getNodeWorldBoundsRectangle, getNodeWorldTransformMatrix, } from '@flighthq/node';
|
|
2
|
+
import { createGlProgram } from '@flighthq/render-gl';
|
|
3
|
+
import { getGlRenderStateRuntime } from '@flighthq/render-gl';
|
|
4
|
+
import { createGlRenderTarget } from '@flighthq/render-gl';
|
|
5
|
+
import { EntityRuntimeKey } from '@flighthq/types';
|
|
6
|
+
import { getVelocity } from '@flighthq/velocity';
|
|
7
|
+
// Gl velocity-buffer production. Velocity is tied to the draw, so production is per-kind: the velocity
|
|
8
|
+
// pass walks the scene and dispatches a registered GlVelocityWriter for each node's kind, which draws
|
|
9
|
+
// that kind's velocity into the bound rgba16f target. The DisplayObject writer covers a node's world
|
|
10
|
+
// bounds with its (single) velocity; batched kinds register their own writer to emit per-instance
|
|
11
|
+
// velocity. The generic velocity DATA comes from a render-agnostic VelocityField (@flighthq/velocity);
|
|
12
|
+
// this module is only the render-side hook.
|
|
13
|
+
//
|
|
14
|
+
// ENCODING: velocity is written in device pixels per frame (node-unit velocity × pixelRatio), y-down,
|
|
15
|
+
// into R/G of an rgba16f target (signed, sub-pixel). B is reserved; A=1 marks a covered texel so consumers
|
|
16
|
+
// distinguish it from the cleared (0,0,0,0) zero-velocity background. World bounds are device-pixel,
|
|
17
|
+
// top-left origin, y-down; drawGlVelocityQuad maps a rect into clip space, flipping y.
|
|
18
|
+
/** Allocates an rgba16f render target sized to hold a signed, sub-pixel screen-space velocity buffer. */
|
|
19
|
+
export function createGlVelocityTarget(state, width, height) {
|
|
20
|
+
return createGlRenderTarget(state, { width, height, format: 'rgba16f' });
|
|
21
|
+
}
|
|
22
|
+
// The default writer for plain display-object nodes: cover the node's world bounds with its velocity.
|
|
23
|
+
// Batched/instanced kinds (QuadBatch, particles) register a writer that emits per-instance velocity.
|
|
24
|
+
export const defaultGlDisplayObjectVelocityWriter = (ctx, node) => {
|
|
25
|
+
getVelocity(ctx.field, node, _scratchVelocity);
|
|
26
|
+
if (_scratchVelocity.x === 0 && _scratchVelocity.y === 0)
|
|
27
|
+
return;
|
|
28
|
+
const spatial = node;
|
|
29
|
+
ensureNodeWorldBoundsRectangle(spatial);
|
|
30
|
+
const bounds = getNodeWorldBoundsRectangle(spatial);
|
|
31
|
+
drawGlVelocityQuad(ctx, bounds.x, bounds.y, bounds.width, bounds.height, _scratchVelocity.x, _scratchVelocity.y);
|
|
32
|
+
};
|
|
33
|
+
// The ParticleEmitter writer emits PER-PARTICLE velocity: each particle moves on its own vector (a
|
|
34
|
+
// fountain fans outward), so one emitter-wide vector would be wrong — a user who wants the whole emitter
|
|
35
|
+
// to share a velocity attaches it to a parent node instead, which the DisplayObject writer covers. The
|
|
36
|
+
// per-particle world rect is reconstructed exactly as the particle renderer composes its quad: a [0,1]
|
|
37
|
+
// corner scaled by the atlas region, rotated/scaled by the particle's (cos,sin)·scale and offset by its
|
|
38
|
+
// position, then mapped by the emitter world transform (skipped when worldSpace puts particles in world
|
|
39
|
+
// space already). Velocity stays in node units; drawGlVelocityQuad applies pixelRatio (matching the
|
|
40
|
+
// other writers; a non-unit emitter scale or worldSpace under hiDpi is the same approximation as
|
|
41
|
+
// QuadBatch). Skips particles with zero velocity and emitters without a populated velocities array.
|
|
42
|
+
export const defaultGlParticleEmitterVelocityWriter = (ctx, node) => {
|
|
43
|
+
const emitter = node;
|
|
44
|
+
const { atlas, ids, particleCount, transforms, velocities, worldSpace } = emitter.data;
|
|
45
|
+
if (atlas === null || particleCount === 0 || velocities.length < particleCount * 2)
|
|
46
|
+
return;
|
|
47
|
+
const regions = atlas.regions;
|
|
48
|
+
const numRegions = regions.length;
|
|
49
|
+
let wa = 1;
|
|
50
|
+
let wb = 0;
|
|
51
|
+
let wc = 0;
|
|
52
|
+
let wd = 1;
|
|
53
|
+
let wtx = 0;
|
|
54
|
+
let wty = 0;
|
|
55
|
+
if (!worldSpace) {
|
|
56
|
+
ensureNodeWorldTransformMatrix(node);
|
|
57
|
+
const transform = getNodeWorldTransformMatrix(node);
|
|
58
|
+
wa = transform.a;
|
|
59
|
+
wb = transform.b;
|
|
60
|
+
wc = transform.c;
|
|
61
|
+
wd = transform.d;
|
|
62
|
+
wtx = transform.tx;
|
|
63
|
+
wty = transform.ty;
|
|
64
|
+
}
|
|
65
|
+
for (let i = 0; i < particleCount; i++) {
|
|
66
|
+
const velocityX = velocities[i * 2];
|
|
67
|
+
const velocityY = velocities[i * 2 + 1];
|
|
68
|
+
if (velocityX === 0 && velocityY === 0)
|
|
69
|
+
continue;
|
|
70
|
+
const id = ids[i];
|
|
71
|
+
if (id < 0 || id >= numRegions)
|
|
72
|
+
continue;
|
|
73
|
+
const region = regions[id];
|
|
74
|
+
const rw = region.width;
|
|
75
|
+
const rh = region.height;
|
|
76
|
+
if (rw <= 0 || rh <= 0)
|
|
77
|
+
continue;
|
|
78
|
+
const tt = i * 4;
|
|
79
|
+
const px = transforms[tt];
|
|
80
|
+
const py = transforms[tt + 1];
|
|
81
|
+
const rotation = transforms[tt + 2];
|
|
82
|
+
const scale = transforms[tt + 3];
|
|
83
|
+
const cosScale = Math.cos(rotation) * scale;
|
|
84
|
+
const sinScale = Math.sin(rotation) * scale;
|
|
85
|
+
let minX = Infinity;
|
|
86
|
+
let minY = Infinity;
|
|
87
|
+
let maxX = -Infinity;
|
|
88
|
+
let maxY = -Infinity;
|
|
89
|
+
for (let c = 0; c < 4; c++) {
|
|
90
|
+
const lx = (c & 1) * rw;
|
|
91
|
+
const ly = (c >> 1) * rh;
|
|
92
|
+
const rx = cosScale * lx - sinScale * ly + px;
|
|
93
|
+
const ry = sinScale * lx + cosScale * ly + py;
|
|
94
|
+
const wx = worldSpace ? rx : wa * rx + wc * ry + wtx;
|
|
95
|
+
const wy = worldSpace ? ry : wb * rx + wd * ry + wty;
|
|
96
|
+
if (wx < minX)
|
|
97
|
+
minX = wx;
|
|
98
|
+
if (wx > maxX)
|
|
99
|
+
maxX = wx;
|
|
100
|
+
if (wy < minY)
|
|
101
|
+
minY = wy;
|
|
102
|
+
if (wy > maxY)
|
|
103
|
+
maxY = wy;
|
|
104
|
+
}
|
|
105
|
+
drawGlVelocityQuad(ctx, minX, minY, maxX - minX, maxY - minY, velocityX, velocityY);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
// The QuadBatch writer emits PER-INSTANCE velocity: a batch's quads move independently and are not nodes,
|
|
109
|
+
// so a single node-level velocity over the whole batch would smear every quad with the same motion vector.
|
|
110
|
+
// When the batch carries a per-instance velocity array (QuadBatchRuntime.instanceVelocities, filled by
|
|
111
|
+
// whatever drives the quads) we draw one velocity quad per instance, each over that instance's own
|
|
112
|
+
// world-space region. Each instance's world rect is reconstructed exactly as the Gl batch renderer
|
|
113
|
+
// composes it: the batch's world transform (transform2D) applied to the per-instance local transform, then
|
|
114
|
+
// the axis-aligned bounds of the transformed region. This is the same world space the DisplayObject writer
|
|
115
|
+
// passes (the node's logical world bounds), so drawGlVelocityQuad maps both consistently. Velocity stays
|
|
116
|
+
// in node units; the helper applies pixelRatio.
|
|
117
|
+
//
|
|
118
|
+
// Fallback: when no per-instance velocity array is present, cover the batch's world bounds with one coarse
|
|
119
|
+
// velocity read from the field, exactly like the DisplayObject writer. The per-instance path above is the
|
|
120
|
+
// precise one; this coarse path exists so a batch without tracked instance velocity still contributes.
|
|
121
|
+
export const defaultGlQuadBatchVelocityWriter = (ctx, node) => {
|
|
122
|
+
const batch = node;
|
|
123
|
+
const data = batch.data;
|
|
124
|
+
const runtime = node[EntityRuntimeKey];
|
|
125
|
+
const instanceVelocities = runtime.instanceVelocities;
|
|
126
|
+
const { atlas, ids, instanceCount, transforms, transformType } = data;
|
|
127
|
+
// Precise per-instance path: requires the velocity array and a resolvable region per instance.
|
|
128
|
+
if (instanceVelocities !== null && atlas !== null && instanceCount > 0) {
|
|
129
|
+
const regions = atlas.regions;
|
|
130
|
+
const numRegions = regions.length;
|
|
131
|
+
ensureNodeWorldTransformMatrix(node);
|
|
132
|
+
const transform = getNodeWorldTransformMatrix(node);
|
|
133
|
+
const pa = transform.a;
|
|
134
|
+
const pb = transform.b;
|
|
135
|
+
const pc = transform.c;
|
|
136
|
+
const pd = transform.d;
|
|
137
|
+
const ptx = transform.tx;
|
|
138
|
+
const pty = transform.ty;
|
|
139
|
+
const isVector2 = transformType === 'vector2';
|
|
140
|
+
for (let i = 0; i < instanceCount; i++) {
|
|
141
|
+
const velocityX = instanceVelocities[i * 2];
|
|
142
|
+
const velocityY = instanceVelocities[i * 2 + 1];
|
|
143
|
+
if (velocityX === 0 && velocityY === 0)
|
|
144
|
+
continue;
|
|
145
|
+
const id = ids[i];
|
|
146
|
+
if (id < 0 || id >= numRegions)
|
|
147
|
+
continue;
|
|
148
|
+
const region = regions[id];
|
|
149
|
+
const w = region.width;
|
|
150
|
+
const h = region.height;
|
|
151
|
+
if (w <= 0 || h <= 0)
|
|
152
|
+
continue;
|
|
153
|
+
// World-space instance transform = batch world transform ∘ per-instance local transform.
|
|
154
|
+
let wa;
|
|
155
|
+
let wb;
|
|
156
|
+
let wc;
|
|
157
|
+
let wd;
|
|
158
|
+
let wtx;
|
|
159
|
+
let wty;
|
|
160
|
+
if (isVector2) {
|
|
161
|
+
const dx = transforms[i * 2];
|
|
162
|
+
const dy = transforms[i * 2 + 1];
|
|
163
|
+
wa = pa;
|
|
164
|
+
wb = pb;
|
|
165
|
+
wc = pc;
|
|
166
|
+
wd = pd;
|
|
167
|
+
wtx = pa * dx + pc * dy + ptx;
|
|
168
|
+
wty = pb * dx + pd * dy + pty;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
const o = i * 6;
|
|
172
|
+
const la = transforms[o];
|
|
173
|
+
const lb = transforms[o + 1];
|
|
174
|
+
const lc = transforms[o + 2];
|
|
175
|
+
const ld = transforms[o + 3];
|
|
176
|
+
const ltx = transforms[o + 4];
|
|
177
|
+
const lty = transforms[o + 5];
|
|
178
|
+
wa = pa * la + pc * lb;
|
|
179
|
+
wb = pb * la + pd * lb;
|
|
180
|
+
wc = pa * lc + pc * ld;
|
|
181
|
+
wd = pb * lc + pd * ld;
|
|
182
|
+
wtx = pa * ltx + pc * lty + ptx;
|
|
183
|
+
wty = pb * ltx + pd * lty + pty;
|
|
184
|
+
}
|
|
185
|
+
// Axis-aligned world bounds of the transformed region (the four region corners).
|
|
186
|
+
const x0 = wtx;
|
|
187
|
+
const y0 = wty;
|
|
188
|
+
const x1 = wa * w + wtx;
|
|
189
|
+
const y1 = wb * w + wty;
|
|
190
|
+
const x2 = wc * h + wtx;
|
|
191
|
+
const y2 = wd * h + wty;
|
|
192
|
+
const x3 = wa * w + wc * h + wtx;
|
|
193
|
+
const y3 = wb * w + wd * h + wty;
|
|
194
|
+
const minX = Math.min(x0, x1, x2, x3);
|
|
195
|
+
const minY = Math.min(y0, y1, y2, y3);
|
|
196
|
+
const maxX = Math.max(x0, x1, x2, x3);
|
|
197
|
+
const maxY = Math.max(y0, y1, y2, y3);
|
|
198
|
+
drawGlVelocityQuad(ctx, minX, minY, maxX - minX, maxY - minY, velocityX, velocityY);
|
|
199
|
+
}
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
// Coarse fallback: one velocity over the whole batch's world bounds, matching the DisplayObject writer.
|
|
203
|
+
getVelocity(ctx.field, node, _scratchVelocity);
|
|
204
|
+
if (_scratchVelocity.x === 0 && _scratchVelocity.y === 0)
|
|
205
|
+
return;
|
|
206
|
+
const spatial = node;
|
|
207
|
+
ensureNodeWorldBoundsRectangle(spatial);
|
|
208
|
+
const bounds = getNodeWorldBoundsRectangle(spatial);
|
|
209
|
+
drawGlVelocityQuad(ctx, bounds.x, bounds.y, bounds.width, bounds.height, _scratchVelocity.x, _scratchVelocity.y);
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Draws one velocity quad: a device-pixel rect (x, y, width, height) filled with (velocityX, velocityY)
|
|
213
|
+
* in node units (scaled by pixelRatio here). The velocity program must be current — the velocity pass
|
|
214
|
+
* sets it up before dispatching writers. Writers call this once per covered region (once for a display
|
|
215
|
+
* object's bounds; once per instance for a batch).
|
|
216
|
+
*/
|
|
217
|
+
export function drawGlVelocityQuad(ctx, x, y, width, height, velocityX, velocityY) {
|
|
218
|
+
const program = ensureGlVelocityProgram(ctx.state);
|
|
219
|
+
const gl = ctx.state.gl;
|
|
220
|
+
const clipX0 = (x / ctx.width) * 2 - 1;
|
|
221
|
+
const clipY0 = 1 - (y / ctx.height) * 2;
|
|
222
|
+
const clipWidth = (width / ctx.width) * 2;
|
|
223
|
+
const clipHeight = -((height / ctx.height) * 2);
|
|
224
|
+
gl.uniform4f(program.locClipRect, clipX0, clipY0, clipWidth, clipHeight);
|
|
225
|
+
gl.uniform2f(program.locVelocity, velocityX * ctx.pixelRatio, velocityY * ctx.pixelRatio);
|
|
226
|
+
gl.drawArrays(gl.TRIANGLES, 0, 6);
|
|
227
|
+
}
|
|
228
|
+
export function getGlVelocityWriter(state, kind) {
|
|
229
|
+
return _velocityWriters.get(state)?.get(kind) ?? null;
|
|
230
|
+
}
|
|
231
|
+
export function registerGlVelocityWriter(state, kind, writer) {
|
|
232
|
+
let writers = _velocityWriters.get(state);
|
|
233
|
+
if (writers === undefined) {
|
|
234
|
+
writers = new Map();
|
|
235
|
+
_velocityWriters.set(state, writers);
|
|
236
|
+
}
|
|
237
|
+
writers.set(kind, writer);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Walks `root`'s subtree and writes every moving renderable's velocity into `target`, dispatching the
|
|
241
|
+
* registered GlVelocityWriter for each node's kind. Nodes whose kind has no writer are skipped; the
|
|
242
|
+
* cleared (0,0,0,0) background means zero velocity. Restores the previously bound framebuffer.
|
|
243
|
+
*/
|
|
244
|
+
export function renderGlVelocity(state, root, field, target) {
|
|
245
|
+
const runtime = getGlRenderStateRuntime(state);
|
|
246
|
+
const gl = state.gl;
|
|
247
|
+
const program = ensureGlVelocityProgram(state);
|
|
248
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, target.framebuffer);
|
|
249
|
+
gl.viewport(0, 0, target.width, target.height);
|
|
250
|
+
gl.disable(gl.BLEND);
|
|
251
|
+
gl.clearColor(0, 0, 0, 0);
|
|
252
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
253
|
+
gl.useProgram(program.program);
|
|
254
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, program.quadBuffer);
|
|
255
|
+
gl.enableVertexAttribArray(program.locCorner);
|
|
256
|
+
gl.vertexAttribPointer(program.locCorner, 2, gl.FLOAT, false, 0, 0);
|
|
257
|
+
const ctx = {
|
|
258
|
+
state,
|
|
259
|
+
field,
|
|
260
|
+
width: target.width,
|
|
261
|
+
height: target.height,
|
|
262
|
+
pixelRatio: state.pixelRatio,
|
|
263
|
+
};
|
|
264
|
+
visitGlVelocity(ctx, root);
|
|
265
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, runtime.currentFramebuffer);
|
|
266
|
+
gl.disableVertexAttribArray(program.locCorner);
|
|
267
|
+
}
|
|
268
|
+
function ensureGlVelocityProgram(state) {
|
|
269
|
+
let program = _velocityPrograms.get(state);
|
|
270
|
+
if (program !== undefined)
|
|
271
|
+
return program;
|
|
272
|
+
const gl = state.gl;
|
|
273
|
+
const glProgram = createGlProgram(gl, VELOCITY_VERTEX_SRC, VELOCITY_FRAGMENT_SRC, 'Velocity');
|
|
274
|
+
const quadBuffer = gl.createBuffer();
|
|
275
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, quadBuffer);
|
|
276
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]), gl.STATIC_DRAW);
|
|
277
|
+
program = {
|
|
278
|
+
program: glProgram,
|
|
279
|
+
quadBuffer,
|
|
280
|
+
locCorner: gl.getAttribLocation(glProgram, 'a_corner'),
|
|
281
|
+
locClipRect: gl.getUniformLocation(glProgram, 'u_clipRect'),
|
|
282
|
+
locVelocity: gl.getUniformLocation(glProgram, 'u_velocity'),
|
|
283
|
+
};
|
|
284
|
+
_velocityPrograms.set(state, program);
|
|
285
|
+
return program;
|
|
286
|
+
}
|
|
287
|
+
function visitGlVelocity(ctx, node) {
|
|
288
|
+
const writer = getGlVelocityWriter(ctx.state, node.kind);
|
|
289
|
+
if (writer !== null)
|
|
290
|
+
writer(ctx, node);
|
|
291
|
+
const count = getNodeChildCount(node);
|
|
292
|
+
for (let i = 0; i < count; i++) {
|
|
293
|
+
const child = getNodeChildAt(node, i);
|
|
294
|
+
if (child !== null)
|
|
295
|
+
visitGlVelocity(ctx, child);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// u_clipRect = (clipX0, clipY0, clipWidth, clipHeight). a_corner is the unit-quad corner [0..1]; the
|
|
299
|
+
// covered rect is reconstructed per vertex so no per-node matrix upload is needed.
|
|
300
|
+
const VELOCITY_VERTEX_SRC = `#version 300 es
|
|
301
|
+
in vec2 a_corner;
|
|
302
|
+
uniform vec4 u_clipRect;
|
|
303
|
+
void main() {
|
|
304
|
+
vec2 clip = u_clipRect.xy + a_corner * u_clipRect.zw;
|
|
305
|
+
gl_Position = vec4(clip, 0.0, 1.0);
|
|
306
|
+
}`;
|
|
307
|
+
const VELOCITY_FRAGMENT_SRC = `#version 300 es
|
|
308
|
+
precision highp float;
|
|
309
|
+
uniform vec2 u_velocity;
|
|
310
|
+
out vec4 fragColor;
|
|
311
|
+
void main() {
|
|
312
|
+
fragColor = vec4(u_velocity, 0.0, 1.0);
|
|
313
|
+
}`;
|
|
314
|
+
const _scratchVelocity = { x: 0, y: 0 };
|
|
315
|
+
// Lazily compiled velocity program per render state, and the per-kind writer registry. WeakMaps so both
|
|
316
|
+
// release when the state is GC'd.
|
|
317
|
+
const _velocityPrograms = new WeakMap();
|
|
318
|
+
const _velocityWriters = new WeakMap();
|
|
319
|
+
//# sourceMappingURL=glVelocity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glVelocity.js","sourceRoot":"","sources":["../src/glVelocity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,8BAA8B,EAC9B,cAAc,EACd,iBAAiB,EACjB,2BAA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S,EAAE,YAAY,CAAE;QAC5D,WAAW,EAAE,EAAE,CAAC,kBAAkB,CAAC,SAAS,EAAE,YAAY,CAAE;KAC7D,CAAC;IACF,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,eAAe,CACtB,GAAgC,EAChC,IAAuC;IAEvC,MAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,MAAM,KAAK,IAAI;QAAE,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAEvC,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACtC,IAAI,KAAK,KAAK,IAAI;YAAE,eAAe,CAAC,GAAG,EAAE,KAAqD,CAAC,CAAC;IAClG,CAAC;AACH,CAAC;AAUD,qGAAqG;AACrG,mFAAmF;AACnF,MAAM,mBAAmB,GAAG;;;;;;EAM1B,CAAC;AAEH,MAAM,qBAAqB,GAAG;;;;;;EAM5B,CAAC;AAEH,MAAM,gBAAgB,GAAe,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAEpD,wGAAwG;AACxG,kCAAkC;AAClC,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAAoC,CAAC;AAC1E,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA8C,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DisplayObjectRenderer, GlRenderState, Renderable, RendererData, RenderProxy2D } from '@flighthq/types';
|
|
2
|
+
export declare function createGlVideoData(_state: GlRenderState, _source: Renderable): RendererData;
|
|
3
|
+
export declare function destroyGlVideoData(state: GlRenderState, data: RendererData): void;
|
|
4
|
+
export declare function drawGlVideo(state: GlRenderState, renderProxy: RenderProxy2D): void;
|
|
5
|
+
export declare const defaultGlVideoRenderer: DisplayObjectRenderer;
|
|
6
|
+
//# sourceMappingURL=glVideo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glVideo.d.ts","sourceRoot":"","sources":["../src/glVideo.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,YAAY,EACZ,aAAa,EAEd,MAAM,iBAAiB,CAAC;AAUzB,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,GAAG,YAAY,CAE1F;AAID,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI,CASjF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,GAAG,IAAI,CAqClF;AAED,eAAO,MAAM,sBAAsB,EAAE,qBAIpC,CAAC"}
|
package/dist/glVideo.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createGlTexture, drawGlQuad, useGlProgram } from '@flighthq/render-gl';
|
|
2
|
+
import { getGlRenderStateRuntime } from '@flighthq/render-gl';
|
|
3
|
+
import { resolveGlShader } from '@flighthq/render-gl';
|
|
4
|
+
import { flushGlSpriteBatch } from './glSpriteBatch';
|
|
5
|
+
export function createGlVideoData(_state, _source) {
|
|
6
|
+
return { lastElement: null };
|
|
7
|
+
}
|
|
8
|
+
// Frees the GPU texture uploaded for this video's element when the node is torn down via
|
|
9
|
+
// disposeDisplayObjectRender. The element-keyed textureCache entry would otherwise leak.
|
|
10
|
+
export function destroyGlVideoData(state, data) {
|
|
11
|
+
const runtime = getGlRenderStateRuntime(state);
|
|
12
|
+
const { lastElement } = data;
|
|
13
|
+
if (lastElement === null)
|
|
14
|
+
return;
|
|
15
|
+
const texture = runtime.textureCache.get(lastElement);
|
|
16
|
+
if (texture !== undefined) {
|
|
17
|
+
state.gl.deleteTexture(texture);
|
|
18
|
+
runtime.textureCache.delete(lastElement);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function drawGlVideo(state, renderProxy) {
|
|
22
|
+
const runtime = getGlRenderStateRuntime(state);
|
|
23
|
+
flushGlSpriteBatch(state);
|
|
24
|
+
const source = renderProxy.source;
|
|
25
|
+
const element = source.data.source?.element;
|
|
26
|
+
if (element === undefined || element === null || element.readyState < 2)
|
|
27
|
+
return;
|
|
28
|
+
const vw = element.videoWidth;
|
|
29
|
+
const vh = element.videoHeight;
|
|
30
|
+
if (vw === 0 || vh === 0)
|
|
31
|
+
return;
|
|
32
|
+
if (renderProxy.rendererData !== null) {
|
|
33
|
+
renderProxy.rendererData.lastElement = element;
|
|
34
|
+
}
|
|
35
|
+
const gl = state.gl;
|
|
36
|
+
const { textureCache } = runtime;
|
|
37
|
+
const shader = resolveGlShader(state, renderProxy);
|
|
38
|
+
useGlProgram(state, shader);
|
|
39
|
+
state.applyBlendMode?.(state, renderProxy.blendMode);
|
|
40
|
+
let texture = textureCache.get(element);
|
|
41
|
+
if (!texture) {
|
|
42
|
+
texture = createGlTexture(state);
|
|
43
|
+
textureCache.set(element, texture);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
47
|
+
runtime.currentTexture = texture;
|
|
48
|
+
}
|
|
49
|
+
// Upload current frame every time — video content changes each frame.
|
|
50
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
|
|
51
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, element);
|
|
52
|
+
shader.bind(gl, state, renderProxy);
|
|
53
|
+
drawGlQuad(state, 0, 0, vw, vh, 0, 0, 1, 1);
|
|
54
|
+
}
|
|
55
|
+
export const defaultGlVideoRenderer = {
|
|
56
|
+
createData: createGlVideoData,
|
|
57
|
+
destroyData: destroyGlVideoData,
|
|
58
|
+
submit: drawGlVideo,
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=glVideo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glVideo.js","sourceRoot":"","sources":["../src/glVideo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAUtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAQrD,MAAM,UAAU,iBAAiB,CAAC,MAAqB,EAAE,OAAmB;IAC1E,OAAO,EAAE,WAAW,EAAE,IAAI,EAA6B,CAAC;AAC1D,CAAC;AAED,yFAAyF;AACzF,yFAAyF;AACzF,MAAM,UAAU,kBAAkB,CAAC,KAAoB,EAAE,IAAkB;IACzE,MAAM,OAAO,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,EAAE,WAAW,EAAE,GAAG,IAA8B,CAAC;IACvD,IAAI,WAAW,KAAK,IAAI;QAAE,OAAO;IACjC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACtD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,KAAK,CAAC,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAChC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAoB,EAAE,WAA0B;IAC1E,MAAM,OAAO,GAAG,uBAAuB,CAAC,KAA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IACxE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;IACzD,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAE7E,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACpC,UAAU,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAA0B;IAC3D,UAAU,EAAE,iBAAiB;IAC7B,WAAW,EAAE,kBAAkB;IAC/B,MAAM,EAAE,WAAW;CACpB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from './glBitmap';
|
|
2
|
+
export * from './glCache';
|
|
3
|
+
export * from './glClip';
|
|
4
|
+
export * from './glClipContours';
|
|
5
|
+
export * from './glClipRectangle';
|
|
6
|
+
export * from './glColorTransformMaterial';
|
|
7
|
+
export * from './glDefaultMaterial';
|
|
8
|
+
export * from './glDisplayObject';
|
|
9
|
+
export * from './glDisplayObjectRegistration';
|
|
10
|
+
export * from './glMaterials';
|
|
11
|
+
export * from './glParticleEmitter';
|
|
12
|
+
export * from './glQuadBatch';
|
|
13
|
+
export * from './glRichText';
|
|
14
|
+
export * from './glScale9Mapper';
|
|
15
|
+
export * from './glScale9Shape';
|
|
16
|
+
export * from './glShape';
|
|
17
|
+
export * from './glShapeMesh';
|
|
18
|
+
export * from './glSprite';
|
|
19
|
+
export * from './glSpriteBatch';
|
|
20
|
+
export * from './glSpriteRenderer';
|
|
21
|
+
export * from './glTextInput';
|
|
22
|
+
export * from './glTextLabel';
|
|
23
|
+
export * from './glTilemap';
|
|
24
|
+
export * from './glUniformColorTransformMaterial';
|
|
25
|
+
export * from './glVelocity';
|
|
26
|
+
export * from './glVideo';
|
|
27
|
+
export { defaultCanvasBeginBitmapFill as defaultGlBeginBitmapFill, defaultCanvasBeginFill as defaultGlBeginFill, defaultCanvasBeginGradientFill as defaultGlBeginGradientFill, defaultCanvasCubicCurveTo as defaultGlCubicCurveTo, defaultCanvasCurveTo as defaultGlCurveTo, defaultCanvasDrawCircle as defaultGlDrawCircle, defaultCanvasDrawEllipse as defaultGlDrawEllipse, defaultCanvasDrawRectangle as defaultGlDrawRectangle, defaultCanvasDrawRoundRectangle as defaultGlDrawRoundRectangle, defaultCanvasEndFill as defaultGlEndFill, defaultCanvasLineStyle as defaultGlLineStyle, defaultCanvasLineTo as defaultGlLineTo, defaultCanvasMoveTo as defaultGlMoveTo, defaultCanvasShapeCommands as defaultGlShapeCommands, registerCanvasShapeCommands as registerGlShapeCommands, } from '@flighthq/displayobject-canvas';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,iB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