@zappar/zappar-cv 3.0.1-alpha.14 → 3.0.1-alpha.16
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/lib/deserializer.d.ts +1 -0
- package/lib/deserializer.js +9 -0
- package/lib/drawgrid.js +5 -2
- package/lib/drawpointswithtype.d.ts +13 -0
- package/lib/drawpointswithtype.js +190 -0
- package/lib/drawpolygon.d.ts +5 -0
- package/lib/drawpolygon.js +94 -0
- package/lib/gen/zappar-bridge.d.ts +7 -0
- package/lib/gen/zappar-client.js +105 -11
- package/lib/gen/zappar-cwrap.js +67 -0
- package/lib/gen/zappar-native.d.ts +7 -0
- package/lib/gen/zappar-server.js +48 -11
- package/lib/gen/zappar.d.ts +7 -0
- package/lib/html-element-source.d.ts +3 -0
- package/lib/html-element-source.js +25 -1
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/worker-server.js +1 -1
- package/lib/zappar-cv.js +1 -1
- package/lib/zappar-cv.wasm +0 -0
- package/package.json +1 -1
- package/umd/{f3b68cdcdf971ab7e1b7.wasm → 6cf17bab4f58a189fc94.wasm} +0 -0
- package/umd/751.zappar-cv.js +1 -1
- package/umd/867.zappar-cv.js +1 -1
- package/umd/zappar-cv.js +1 -1
- package/umd/zappar-cv.worker.js +1 -1
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ npm i @zappar/zappar-cv
|
|
|
18
18
|
|
|
19
19
|
You can use our CDN from within your HTML:
|
|
20
20
|
```
|
|
21
|
-
<script src="https://libs.zappar.com/zappar-cv/3.0.1-alpha.
|
|
21
|
+
<script src="https://libs.zappar.com/zappar-cv/3.0.1-alpha.16/zappar-cv.js"></script>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Or you can download and host our standalone JavaScript bundle:
|
|
25
|
-
[https://libs.zappar.com/zappar-cv/3.0.1-alpha.
|
|
25
|
+
[https://libs.zappar.com/zappar-cv/3.0.1-alpha.16/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.0.1-alpha.16/zappar-cv.zip)
|
package/lib/deserializer.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface Message {
|
|
|
8
8
|
type: () => number;
|
|
9
9
|
matrix4x4: () => Float32Array;
|
|
10
10
|
matrix3x3: () => Float32Array;
|
|
11
|
+
ucharArray: () => Uint8Array;
|
|
11
12
|
floatArray: () => Float32Array;
|
|
12
13
|
identityCoefficients: () => Float32Array;
|
|
13
14
|
expressionCoefficients: () => Float32Array;
|
package/lib/deserializer.js
CHANGED
|
@@ -40,6 +40,15 @@ export class MessageDeserializer {
|
|
|
40
40
|
this._startOffset++;
|
|
41
41
|
return ret.buffer;
|
|
42
42
|
},
|
|
43
|
+
ucharArray: () => {
|
|
44
|
+
let len = this._i32View[this._startOffset++];
|
|
45
|
+
let ret = new Uint8Array(len);
|
|
46
|
+
ret.set(this._u8View.subarray(this._startOffset * 4, this._startOffset * 4 + len));
|
|
47
|
+
this._startOffset += (ret.byteLength >> 2);
|
|
48
|
+
if ((ret.byteLength & 3) !== 0)
|
|
49
|
+
this._startOffset++;
|
|
50
|
+
return ret;
|
|
51
|
+
},
|
|
43
52
|
floatArray: () => {
|
|
44
53
|
let len = this._i32View[this._startOffset++];
|
|
45
54
|
let ret = new Float32Array(len);
|
package/lib/drawgrid.js
CHANGED
|
@@ -2,6 +2,7 @@ import { compileShader, linkProgram } from "./shader";
|
|
|
2
2
|
let shader;
|
|
3
3
|
let vbo;
|
|
4
4
|
let uvbo;
|
|
5
|
+
const gridSize = 10;
|
|
5
6
|
export function disposeDrawGrid() {
|
|
6
7
|
shader = undefined;
|
|
7
8
|
vbo = undefined;
|
|
@@ -19,6 +20,7 @@ function generate(gl) {
|
|
|
19
20
|
0.5, 0, 0.5,
|
|
20
21
|
0.5, 0, -0.5
|
|
21
22
|
];
|
|
23
|
+
coords = coords.map(entry => entry * gridSize);
|
|
22
24
|
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
23
25
|
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(coords), gl.STATIC_DRAW);
|
|
24
26
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
@@ -36,6 +38,7 @@ function generateUVBO(gl) {
|
|
|
36
38
|
1, 1,
|
|
37
39
|
1, 0
|
|
38
40
|
];
|
|
41
|
+
coords = coords.map(entry => entry * gridSize);
|
|
39
42
|
gl.bindBuffer(gl.ARRAY_BUFFER, uvbo);
|
|
40
43
|
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(coords), gl.STATIC_DRAW);
|
|
41
44
|
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
@@ -97,8 +100,8 @@ uniform sampler2D skinSampler;
|
|
|
97
100
|
|
|
98
101
|
void main()
|
|
99
102
|
{
|
|
100
|
-
vec2 pixels =
|
|
101
|
-
if ((int(mod(pixels.x,
|
|
103
|
+
vec2 pixels = 500.0 * vTextureCoord + 0.5;
|
|
104
|
+
if ((int(mod(pixels.x, 50.0)) == 0) || (int(mod(pixels.y, 50.0)) == 0)) {
|
|
102
105
|
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
103
106
|
} else {
|
|
104
107
|
discard;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class PointsWithTypeDraw {
|
|
2
|
+
private _gl;
|
|
3
|
+
private _vbo;
|
|
4
|
+
private _typebo;
|
|
5
|
+
private _shader;
|
|
6
|
+
constructor(_gl: WebGL2RenderingContext);
|
|
7
|
+
dispose(): void;
|
|
8
|
+
private _generate;
|
|
9
|
+
private _generateTypes;
|
|
10
|
+
drawPoints(screenWidth: number, screenHeight: number, dataWidth: number, dataHeight: number, points: Float32Array, mirror: boolean, type: Uint8Array, pointSize: number): void;
|
|
11
|
+
private _getCameraShader;
|
|
12
|
+
}
|
|
13
|
+
export declare function getPointsDataMatrix(frameWidth: number, frameHeight: number, screenWidth: number, screenHeight: number, mirror: boolean): Float32Array;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { profile } from "./profile";
|
|
2
|
+
import { compileShader, linkProgram } from "./shader";
|
|
3
|
+
import { mat4 } from "gl-matrix";
|
|
4
|
+
let identity = mat4.create();
|
|
5
|
+
export class PointsWithTypeDraw {
|
|
6
|
+
constructor(_gl) {
|
|
7
|
+
this._gl = _gl;
|
|
8
|
+
}
|
|
9
|
+
dispose() {
|
|
10
|
+
if (this._vbo)
|
|
11
|
+
this._gl.deleteBuffer(this._vbo);
|
|
12
|
+
this._vbo = undefined;
|
|
13
|
+
if (this._shader)
|
|
14
|
+
this._gl.deleteProgram(this._shader.prog);
|
|
15
|
+
this._shader = undefined;
|
|
16
|
+
}
|
|
17
|
+
_generate(gl, points) {
|
|
18
|
+
if (!this._vbo)
|
|
19
|
+
this._vbo = gl.createBuffer();
|
|
20
|
+
if (!this._vbo)
|
|
21
|
+
throw new Error("Unable to create buffer object");
|
|
22
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._vbo);
|
|
23
|
+
gl.bufferData(gl.ARRAY_BUFFER, points, gl.DYNAMIC_DRAW);
|
|
24
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
25
|
+
return this._vbo;
|
|
26
|
+
}
|
|
27
|
+
_generateTypes(gl, points) {
|
|
28
|
+
if (!this._typebo)
|
|
29
|
+
this._typebo = gl.createBuffer();
|
|
30
|
+
if (!this._typebo)
|
|
31
|
+
throw new Error("Unable to create buffer object");
|
|
32
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._typebo);
|
|
33
|
+
gl.bufferData(gl.ARRAY_BUFFER, points, gl.DYNAMIC_DRAW);
|
|
34
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
35
|
+
return this._typebo;
|
|
36
|
+
}
|
|
37
|
+
drawPoints(screenWidth, screenHeight, dataWidth, dataHeight, points, mirror, type, pointSize) {
|
|
38
|
+
if (points.length === 0)
|
|
39
|
+
return; // points = new Float32Array([0, 1, 0, 1]);
|
|
40
|
+
let gl = this._gl;
|
|
41
|
+
const reenableDepthTest = gl.isEnabled(gl.DEPTH_TEST);
|
|
42
|
+
const reenableScissorTest = gl.isEnabled(gl.SCISSOR_TEST);
|
|
43
|
+
const reenableCullFace = gl.isEnabled(gl.CULL_FACE);
|
|
44
|
+
const reenableStencilTest = gl.isEnabled(gl.STENCIL_TEST);
|
|
45
|
+
const reenableBlend = gl.isEnabled(gl.BLEND);
|
|
46
|
+
const previousBoundTexture = gl.getParameter(gl.TEXTURE_BINDING_2D);
|
|
47
|
+
const previousBoundFramebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
|
|
48
|
+
const previousProgram = gl.getParameter(gl.CURRENT_PROGRAM);
|
|
49
|
+
const previousActiveTexture = gl.getParameter(gl.ACTIVE_TEXTURE);
|
|
50
|
+
gl.disable(gl.DEPTH_TEST);
|
|
51
|
+
gl.disable(gl.SCISSOR_TEST);
|
|
52
|
+
gl.disable(gl.CULL_FACE);
|
|
53
|
+
gl.disable(gl.STENCIL_TEST);
|
|
54
|
+
gl.disable(gl.BLEND);
|
|
55
|
+
let shader = this._getCameraShader(gl);
|
|
56
|
+
let vbo = this._generate(gl, points);
|
|
57
|
+
let typebo = this._generateTypes(gl, type);
|
|
58
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
59
|
+
gl.useProgram(shader.prog);
|
|
60
|
+
gl.uniform1f(shader.unif_pointSize, pointSize);
|
|
61
|
+
gl.uniformMatrix4fv(shader.unif_skinTexTransform, false, getPointsDataMatrix(dataWidth, dataHeight, screenWidth, screenHeight, mirror));
|
|
62
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
63
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
64
|
+
gl.vertexAttribPointer(shader.attr_position, 2, gl.FLOAT, false, 0, 0);
|
|
65
|
+
gl.enableVertexAttribArray(shader.attr_position);
|
|
66
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, typebo);
|
|
67
|
+
gl.vertexAttribIPointer(shader.attr_type, 1, gl.UNSIGNED_BYTE, 0, 0);
|
|
68
|
+
gl.enableVertexAttribArray(shader.attr_type);
|
|
69
|
+
gl.drawArrays(gl.POINTS, 0, points.length / 2);
|
|
70
|
+
gl.disableVertexAttribArray(shader.attr_type);
|
|
71
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
72
|
+
gl.disableVertexAttribArray(shader.attr_position);
|
|
73
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, previousBoundFramebuffer);
|
|
74
|
+
gl.useProgram(previousProgram);
|
|
75
|
+
gl.bindTexture(gl.TEXTURE_2D, previousBoundTexture);
|
|
76
|
+
gl.activeTexture(previousActiveTexture);
|
|
77
|
+
if (reenableBlend)
|
|
78
|
+
gl.enable(gl.BLEND);
|
|
79
|
+
if (reenableCullFace)
|
|
80
|
+
gl.enable(gl.CULL_FACE);
|
|
81
|
+
if (reenableDepthTest)
|
|
82
|
+
gl.enable(gl.DEPTH_TEST);
|
|
83
|
+
if (reenableScissorTest)
|
|
84
|
+
gl.enable(gl.SCISSOR_TEST);
|
|
85
|
+
if (reenableStencilTest)
|
|
86
|
+
gl.enable(gl.STENCIL_TEST);
|
|
87
|
+
}
|
|
88
|
+
_getCameraShader(gl) {
|
|
89
|
+
if (this._shader)
|
|
90
|
+
return this._shader;
|
|
91
|
+
let prog = gl.createProgram();
|
|
92
|
+
if (!prog)
|
|
93
|
+
throw new Error("Unable to create program");
|
|
94
|
+
let vertexShader = compileShader(gl, gl.VERTEX_SHADER, vertexShaderSrc);
|
|
95
|
+
let fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentShaderSrc);
|
|
96
|
+
gl.attachShader(prog, vertexShader);
|
|
97
|
+
gl.attachShader(prog, fragmentShader);
|
|
98
|
+
linkProgram(gl, prog);
|
|
99
|
+
let unif_skinTexTransform = gl.getUniformLocation(prog, "skinTexTransform");
|
|
100
|
+
if (!unif_skinTexTransform)
|
|
101
|
+
throw new Error("Unable to get uniform location skinTexTransform");
|
|
102
|
+
let unif_pointSize = gl.getUniformLocation(prog, "pointSize");
|
|
103
|
+
if (!unif_pointSize)
|
|
104
|
+
throw new Error("Unable to get uniform location pointSize");
|
|
105
|
+
this._shader = {
|
|
106
|
+
prog,
|
|
107
|
+
unif_skinTexTransform,
|
|
108
|
+
unif_pointSize,
|
|
109
|
+
attr_position: gl.getAttribLocation(prog, "pos"),
|
|
110
|
+
attr_type: gl.getAttribLocation(prog, "aType"),
|
|
111
|
+
};
|
|
112
|
+
return this._shader;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
let vertexShaderSrc = `#version 300 es
|
|
116
|
+
|
|
117
|
+
in vec2 pos;
|
|
118
|
+
in uint aType;
|
|
119
|
+
uniform mat4 skinTexTransform;
|
|
120
|
+
uniform float pointSize;
|
|
121
|
+
|
|
122
|
+
out vec4 vColor;
|
|
123
|
+
|
|
124
|
+
void main()
|
|
125
|
+
{
|
|
126
|
+
gl_Position = skinTexTransform * vec4(pos, 0.0, 1.0);
|
|
127
|
+
vColor = vec4(1.0, 0.0, 0.0, 1.0);
|
|
128
|
+
if (aType == 1u) {
|
|
129
|
+
vColor = vec4(1.0, 0.7, 0.0, 1.0);
|
|
130
|
+
} else if (aType >= 4u) {
|
|
131
|
+
vColor = vec4(0.0, 0.0, 1.0, 1.0);
|
|
132
|
+
} else if (aType > 1u) {
|
|
133
|
+
vColor = vec4(0.0, 1.0, 0.0, 1.0);
|
|
134
|
+
}
|
|
135
|
+
gl_PointSize = pointSize;
|
|
136
|
+
}`;
|
|
137
|
+
let fragmentShaderSrc = `#version 300 es
|
|
138
|
+
precision highp float;
|
|
139
|
+
|
|
140
|
+
in vec4 vColor;
|
|
141
|
+
out vec4 outColor;
|
|
142
|
+
|
|
143
|
+
void main()
|
|
144
|
+
{
|
|
145
|
+
outColor = vColor;
|
|
146
|
+
}`;
|
|
147
|
+
function cameraRotationForScreenOrientation() {
|
|
148
|
+
if (window.screen.orientation && !profile.forceWindowOrientation) {
|
|
149
|
+
switch (window.screen.orientation.type) {
|
|
150
|
+
case "portrait-primary":
|
|
151
|
+
return 270;
|
|
152
|
+
case "landscape-secondary":
|
|
153
|
+
return 180;
|
|
154
|
+
case "portrait-secondary":
|
|
155
|
+
return 90;
|
|
156
|
+
default:
|
|
157
|
+
return 0;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else if (window.orientation !== undefined) {
|
|
161
|
+
switch (window.orientation) {
|
|
162
|
+
case 0: return 270;
|
|
163
|
+
case 90: return 0;
|
|
164
|
+
case 180: return 90;
|
|
165
|
+
case -90: return 180;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
170
|
+
export function getPointsDataMatrix(frameWidth, frameHeight, screenWidth, screenHeight, mirror) {
|
|
171
|
+
let ret = mat4.create();
|
|
172
|
+
let trans = mat4.create();
|
|
173
|
+
// Translate to centre UV coords
|
|
174
|
+
mat4.fromTranslation(trans, [-0.5 * frameWidth, -0.5 * frameHeight, 0]);
|
|
175
|
+
mat4.multiply(ret, trans, ret);
|
|
176
|
+
mat4.fromScaling(trans, [2 / frameWidth, 2 / -frameHeight, 1]);
|
|
177
|
+
mat4.multiply(ret, trans, ret);
|
|
178
|
+
if (mirror) {
|
|
179
|
+
mat4.fromScaling(trans, [-1, 1, 1]);
|
|
180
|
+
mat4.multiply(ret, trans, ret);
|
|
181
|
+
}
|
|
182
|
+
let screenAspect = screenWidth > screenHeight ? (screenWidth / screenHeight) : (screenHeight / screenWidth);
|
|
183
|
+
let frameAspect = frameWidth / frameHeight;
|
|
184
|
+
mat4.fromScaling(trans, [1, screenAspect / frameAspect, 1]);
|
|
185
|
+
mat4.multiply(ret, trans, ret);
|
|
186
|
+
// Apply rotation back into ZCV's landscape space
|
|
187
|
+
mat4.fromRotation(trans, cameraRotationForScreenOrientation() * Math.PI / 180.0, [0, 0, 1]);
|
|
188
|
+
mat4.multiply(ret, trans, ret);
|
|
189
|
+
return ret;
|
|
190
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { compileShader, linkProgram } from "./shader";
|
|
2
|
+
let shader;
|
|
3
|
+
export class PolygonDraw {
|
|
4
|
+
_generate(gl, points) {
|
|
5
|
+
if (!this._vbo) {
|
|
6
|
+
this._vbo = gl.createBuffer();
|
|
7
|
+
}
|
|
8
|
+
if (!this._vbo)
|
|
9
|
+
throw new Error("Unable to create buffer object");
|
|
10
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._vbo);
|
|
11
|
+
gl.bufferData(gl.ARRAY_BUFFER, points, gl.DYNAMIC_DRAW);
|
|
12
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
13
|
+
return this._vbo;
|
|
14
|
+
}
|
|
15
|
+
drawPolygon(gl, projectionMatrix, cameraMatrix, targetMatrix, points) {
|
|
16
|
+
let shader = getShader(gl);
|
|
17
|
+
let v = this._generate(gl, points);
|
|
18
|
+
gl.disable(gl.DEPTH_TEST);
|
|
19
|
+
gl.disable(gl.SCISSOR_TEST);
|
|
20
|
+
gl.disable(gl.CULL_FACE);
|
|
21
|
+
gl.disable(gl.STENCIL_TEST);
|
|
22
|
+
gl.disable(gl.BLEND);
|
|
23
|
+
gl.useProgram(shader.prog);
|
|
24
|
+
gl.uniformMatrix4fv(shader.unif_proj, false, projectionMatrix);
|
|
25
|
+
gl.uniformMatrix4fv(shader.unif_camera, false, cameraMatrix);
|
|
26
|
+
gl.uniformMatrix4fv(shader.unif_matrix, false, targetMatrix);
|
|
27
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, v);
|
|
28
|
+
gl.vertexAttribPointer(shader.attr_position, 2, gl.FLOAT, false, 0, 0);
|
|
29
|
+
gl.enableVertexAttribArray(shader.attr_position);
|
|
30
|
+
gl.drawArrays(gl.LINE_LOOP, 0, points.length / 2);
|
|
31
|
+
gl.disableVertexAttribArray(shader.attr_position);
|
|
32
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
let vertexShaderSrc = `
|
|
36
|
+
#ifndef GL_ES
|
|
37
|
+
#define highp
|
|
38
|
+
#define mediump
|
|
39
|
+
#define lowp
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
uniform mat4 projMatrix;
|
|
43
|
+
uniform mat4 cameraMatrix;
|
|
44
|
+
uniform mat4 modelViewMatrix;
|
|
45
|
+
attribute vec2 position;
|
|
46
|
+
|
|
47
|
+
void main()
|
|
48
|
+
{
|
|
49
|
+
gl_Position = projMatrix * cameraMatrix * modelViewMatrix * vec4(position.x, 0.0, position.y, 1.0);
|
|
50
|
+
}`;
|
|
51
|
+
let fragmentShaderSrc = `
|
|
52
|
+
#define highp mediump
|
|
53
|
+
#ifdef GL_ES
|
|
54
|
+
// define default precision for float, vec, mat.
|
|
55
|
+
precision highp float;
|
|
56
|
+
#else
|
|
57
|
+
#define highp
|
|
58
|
+
#define mediump
|
|
59
|
+
#define lowp
|
|
60
|
+
#endif
|
|
61
|
+
|
|
62
|
+
void main()
|
|
63
|
+
{
|
|
64
|
+
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
|
65
|
+
}`;
|
|
66
|
+
function getShader(gl) {
|
|
67
|
+
if (shader)
|
|
68
|
+
return shader;
|
|
69
|
+
let prog = gl.createProgram();
|
|
70
|
+
if (!prog)
|
|
71
|
+
throw new Error("Unable to create program");
|
|
72
|
+
let vertexShader = compileShader(gl, gl.VERTEX_SHADER, vertexShaderSrc);
|
|
73
|
+
let fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentShaderSrc);
|
|
74
|
+
gl.attachShader(prog, vertexShader);
|
|
75
|
+
gl.attachShader(prog, fragmentShader);
|
|
76
|
+
linkProgram(gl, prog);
|
|
77
|
+
let unif_proj = gl.getUniformLocation(prog, "projMatrix");
|
|
78
|
+
if (!unif_proj)
|
|
79
|
+
throw new Error("Unable to get uniform location projMatrix");
|
|
80
|
+
let unif_matrix = gl.getUniformLocation(prog, "modelViewMatrix");
|
|
81
|
+
if (!unif_matrix)
|
|
82
|
+
throw new Error("Unable to get uniform location modelViewMatrix");
|
|
83
|
+
let unif_camera = gl.getUniformLocation(prog, "cameraMatrix");
|
|
84
|
+
if (!unif_camera)
|
|
85
|
+
throw new Error("Unable to get uniform location cameraMatrix");
|
|
86
|
+
shader = {
|
|
87
|
+
prog,
|
|
88
|
+
unif_matrix,
|
|
89
|
+
unif_proj,
|
|
90
|
+
unif_camera,
|
|
91
|
+
attr_position: gl.getAttribLocation(prog, "position"),
|
|
92
|
+
};
|
|
93
|
+
return shader;
|
|
94
|
+
}
|
|
@@ -123,8 +123,13 @@ export interface zappar {
|
|
|
123
123
|
world_tracker_enabled(o: zappar_world_tracker_t): boolean;
|
|
124
124
|
world_tracker_enabled_set(o: zappar_world_tracker_t, enabled: boolean): void;
|
|
125
125
|
world_tracker_quality(o: zappar_world_tracker_t): number;
|
|
126
|
+
world_tracker_plane_detection_enabled(o: zappar_world_tracker_t): boolean;
|
|
127
|
+
world_tracker_plane_detection_enabled_set(o: zappar_world_tracker_t, plane_detection_enabled: boolean): void;
|
|
126
128
|
world_tracker_plane_count(o: zappar_world_tracker_t): number;
|
|
127
129
|
world_tracker_plane_pose_raw(o: zappar_world_tracker_t, indx: number): Float32Array;
|
|
130
|
+
world_tracker_plane_visible(o: zappar_world_tracker_t, indx: number): boolean;
|
|
131
|
+
world_tracker_plane_polygon_data_size(o: zappar_world_tracker_t, indx: number): number;
|
|
132
|
+
world_tracker_plane_polygon_data(o: zappar_world_tracker_t, indx: number): Float32Array;
|
|
128
133
|
world_tracker_world_anchor_valid(o: zappar_world_tracker_t): boolean;
|
|
129
134
|
world_tracker_world_anchor_pose_raw(o: zappar_world_tracker_t): Float32Array;
|
|
130
135
|
world_tracker_ground_anchor_valid(o: zappar_world_tracker_t): boolean;
|
|
@@ -134,6 +139,8 @@ export interface zappar {
|
|
|
134
139
|
world_tracker_tracks_data_enabled_set(o: zappar_world_tracker_t, tracks_data_enabled: boolean): void;
|
|
135
140
|
world_tracker_tracks_data_size(o: zappar_world_tracker_t): number;
|
|
136
141
|
world_tracker_tracks_data(o: zappar_world_tracker_t): Float32Array;
|
|
142
|
+
world_tracker_tracks_type_data_size(o: zappar_world_tracker_t): number;
|
|
143
|
+
world_tracker_tracks_type_data(o: zappar_world_tracker_t): Uint8Array;
|
|
137
144
|
world_tracker_projections_data_enabled(o: zappar_world_tracker_t): boolean;
|
|
138
145
|
world_tracker_projections_data_enabled_set(o: zappar_world_tracker_t, projections_data_enabled: boolean): void;
|
|
139
146
|
world_tracker_projections_data_size(o: zappar_world_tracker_t): number;
|
package/lib/gen/zappar-client.js
CHANGED
|
@@ -680,8 +680,12 @@ export class zappar_client {
|
|
|
680
680
|
let newId = (this._latestId++);
|
|
681
681
|
let s = {
|
|
682
682
|
enabled: true,
|
|
683
|
+
plane_detection_enabled: true,
|
|
683
684
|
plane_count: 0,
|
|
684
685
|
plane_pose: [],
|
|
686
|
+
plane_visible: [],
|
|
687
|
+
plane_polygon_data: [],
|
|
688
|
+
plane_polygon_data_size: [],
|
|
685
689
|
world_anchor_valid: false,
|
|
686
690
|
world_anchor_pose: new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
|
|
687
691
|
ground_anchor_valid: false,
|
|
@@ -689,6 +693,8 @@ export class zappar_client {
|
|
|
689
693
|
tracks_data_enabled: false,
|
|
690
694
|
tracks_data: new Float32Array([]),
|
|
691
695
|
tracks_data_size: 0,
|
|
696
|
+
tracks_type_data: new Uint8Array([]),
|
|
697
|
+
tracks_type_data_size: 0,
|
|
692
698
|
projections_data_enabled: false,
|
|
693
699
|
projections_data: new Float32Array([]),
|
|
694
700
|
projections_data_size: 0,
|
|
@@ -731,6 +737,21 @@ export class zappar_client {
|
|
|
731
737
|
throw new Error("This object has been destroyed");
|
|
732
738
|
return s.quality;
|
|
733
739
|
},
|
|
740
|
+
world_tracker_plane_detection_enabled: (o) => {
|
|
741
|
+
let s = this._world_tracker_state_by_instance.get(o);
|
|
742
|
+
if (!s)
|
|
743
|
+
throw new Error("This object has been destroyed");
|
|
744
|
+
return s.plane_detection_enabled;
|
|
745
|
+
},
|
|
746
|
+
world_tracker_plane_detection_enabled_set: (o, plane_detection_enabled) => {
|
|
747
|
+
let s = this._world_tracker_state_by_instance.get(o);
|
|
748
|
+
if (!s)
|
|
749
|
+
throw new Error("This object has been destroyed");
|
|
750
|
+
this.serializer.sendMessage(48, m => {
|
|
751
|
+
m.type(o);
|
|
752
|
+
m.bool(plane_detection_enabled);
|
|
753
|
+
});
|
|
754
|
+
},
|
|
734
755
|
world_tracker_plane_count: (o) => {
|
|
735
756
|
let s = this._world_tracker_state_by_instance.get(o);
|
|
736
757
|
if (!s)
|
|
@@ -743,6 +764,24 @@ export class zappar_client {
|
|
|
743
764
|
throw new Error("This object has been destroyed");
|
|
744
765
|
return s.plane_pose[indx];
|
|
745
766
|
},
|
|
767
|
+
world_tracker_plane_visible: (o, indx) => {
|
|
768
|
+
let s = this._world_tracker_state_by_instance.get(o);
|
|
769
|
+
if (!s)
|
|
770
|
+
throw new Error("This object has been destroyed");
|
|
771
|
+
return s.plane_visible[indx];
|
|
772
|
+
},
|
|
773
|
+
world_tracker_plane_polygon_data_size: (o, indx) => {
|
|
774
|
+
let s = this._world_tracker_state_by_instance.get(o);
|
|
775
|
+
if (!s)
|
|
776
|
+
throw new Error("This object has been destroyed");
|
|
777
|
+
return s.plane_polygon_data_size[indx];
|
|
778
|
+
},
|
|
779
|
+
world_tracker_plane_polygon_data: (o, indx) => {
|
|
780
|
+
let s = this._world_tracker_state_by_instance.get(o);
|
|
781
|
+
if (!s)
|
|
782
|
+
throw new Error("This object has been destroyed");
|
|
783
|
+
return s.plane_polygon_data[indx];
|
|
784
|
+
},
|
|
746
785
|
world_tracker_world_anchor_valid: (o) => {
|
|
747
786
|
let s = this._world_tracker_state_by_instance.get(o);
|
|
748
787
|
if (!s)
|
|
@@ -771,7 +810,7 @@ export class zappar_client {
|
|
|
771
810
|
let s = this._world_tracker_state_by_instance.get(o);
|
|
772
811
|
if (!s)
|
|
773
812
|
throw new Error("This object has been destroyed");
|
|
774
|
-
this.serializer.sendMessage(
|
|
813
|
+
this.serializer.sendMessage(49, m => {
|
|
775
814
|
m.type(o);
|
|
776
815
|
});
|
|
777
816
|
},
|
|
@@ -785,7 +824,7 @@ export class zappar_client {
|
|
|
785
824
|
let s = this._world_tracker_state_by_instance.get(o);
|
|
786
825
|
if (!s)
|
|
787
826
|
throw new Error("This object has been destroyed");
|
|
788
|
-
this.serializer.sendMessage(
|
|
827
|
+
this.serializer.sendMessage(50, m => {
|
|
789
828
|
m.type(o);
|
|
790
829
|
m.bool(tracks_data_enabled);
|
|
791
830
|
});
|
|
@@ -802,6 +841,18 @@ export class zappar_client {
|
|
|
802
841
|
throw new Error("This object has been destroyed");
|
|
803
842
|
return s.tracks_data;
|
|
804
843
|
},
|
|
844
|
+
world_tracker_tracks_type_data_size: (o) => {
|
|
845
|
+
let s = this._world_tracker_state_by_instance.get(o);
|
|
846
|
+
if (!s)
|
|
847
|
+
throw new Error("This object has been destroyed");
|
|
848
|
+
return s.tracks_type_data_size;
|
|
849
|
+
},
|
|
850
|
+
world_tracker_tracks_type_data: (o) => {
|
|
851
|
+
let s = this._world_tracker_state_by_instance.get(o);
|
|
852
|
+
if (!s)
|
|
853
|
+
throw new Error("This object has been destroyed");
|
|
854
|
+
return s.tracks_type_data;
|
|
855
|
+
},
|
|
805
856
|
world_tracker_projections_data_enabled: (o) => {
|
|
806
857
|
let s = this._world_tracker_state_by_instance.get(o);
|
|
807
858
|
if (!s)
|
|
@@ -812,7 +863,7 @@ export class zappar_client {
|
|
|
812
863
|
let s = this._world_tracker_state_by_instance.get(o);
|
|
813
864
|
if (!s)
|
|
814
865
|
throw new Error("This object has been destroyed");
|
|
815
|
-
this.serializer.sendMessage(
|
|
866
|
+
this.serializer.sendMessage(51, m => {
|
|
816
867
|
m.type(o);
|
|
817
868
|
m.bool(projections_data_enabled);
|
|
818
869
|
});
|
|
@@ -1029,7 +1080,7 @@ export class zappar_client {
|
|
|
1029
1080
|
inst.anchor_pose[indx] = msg.matrix4x4();
|
|
1030
1081
|
break;
|
|
1031
1082
|
}
|
|
1032
|
-
case
|
|
1083
|
+
case 34: {
|
|
1033
1084
|
let handle = msg.type();
|
|
1034
1085
|
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1035
1086
|
if (!inst)
|
|
@@ -1059,7 +1110,8 @@ export class zappar_client {
|
|
|
1059
1110
|
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1060
1111
|
if (!inst)
|
|
1061
1112
|
return;
|
|
1062
|
-
|
|
1113
|
+
let indx = msg.int();
|
|
1114
|
+
inst.plane_visible[indx] = msg.bool();
|
|
1063
1115
|
break;
|
|
1064
1116
|
}
|
|
1065
1117
|
case 28: {
|
|
@@ -1067,10 +1119,20 @@ export class zappar_client {
|
|
|
1067
1119
|
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1068
1120
|
if (!inst)
|
|
1069
1121
|
return;
|
|
1070
|
-
|
|
1122
|
+
let indx = msg.int();
|
|
1123
|
+
inst.plane_polygon_data_size[indx] = msg.int();
|
|
1071
1124
|
break;
|
|
1072
1125
|
}
|
|
1073
|
-
case
|
|
1126
|
+
case 29: {
|
|
1127
|
+
let handle = msg.type();
|
|
1128
|
+
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1129
|
+
if (!inst)
|
|
1130
|
+
return;
|
|
1131
|
+
let indx = msg.int();
|
|
1132
|
+
inst.plane_polygon_data[indx] = msg.floatArray();
|
|
1133
|
+
break;
|
|
1134
|
+
}
|
|
1135
|
+
case 30: {
|
|
1074
1136
|
let handle = msg.type();
|
|
1075
1137
|
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1076
1138
|
if (!inst)
|
|
@@ -1078,7 +1140,23 @@ export class zappar_client {
|
|
|
1078
1140
|
inst.world_anchor_valid = msg.bool();
|
|
1079
1141
|
break;
|
|
1080
1142
|
}
|
|
1143
|
+
case 31: {
|
|
1144
|
+
let handle = msg.type();
|
|
1145
|
+
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1146
|
+
if (!inst)
|
|
1147
|
+
return;
|
|
1148
|
+
inst.world_anchor_pose = msg.matrix4x4();
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1081
1151
|
case 30: {
|
|
1152
|
+
let handle = msg.type();
|
|
1153
|
+
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1154
|
+
if (!inst)
|
|
1155
|
+
return;
|
|
1156
|
+
inst.world_anchor_valid = msg.bool();
|
|
1157
|
+
break;
|
|
1158
|
+
}
|
|
1159
|
+
case 33: {
|
|
1082
1160
|
let handle = msg.type();
|
|
1083
1161
|
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1084
1162
|
if (!inst)
|
|
@@ -1086,7 +1164,7 @@ export class zappar_client {
|
|
|
1086
1164
|
inst.ground_anchor_pose = msg.matrix4x4();
|
|
1087
1165
|
break;
|
|
1088
1166
|
}
|
|
1089
|
-
case
|
|
1167
|
+
case 37: {
|
|
1090
1168
|
let handle = msg.type();
|
|
1091
1169
|
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1092
1170
|
if (!inst)
|
|
@@ -1094,7 +1172,7 @@ export class zappar_client {
|
|
|
1094
1172
|
inst.tracks_data_size = msg.int();
|
|
1095
1173
|
break;
|
|
1096
1174
|
}
|
|
1097
|
-
case
|
|
1175
|
+
case 36: {
|
|
1098
1176
|
let handle = msg.type();
|
|
1099
1177
|
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1100
1178
|
if (!inst)
|
|
@@ -1102,7 +1180,23 @@ export class zappar_client {
|
|
|
1102
1180
|
inst.tracks_data = msg.floatArray();
|
|
1103
1181
|
break;
|
|
1104
1182
|
}
|
|
1105
|
-
case
|
|
1183
|
+
case 39: {
|
|
1184
|
+
let handle = msg.type();
|
|
1185
|
+
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1186
|
+
if (!inst)
|
|
1187
|
+
return;
|
|
1188
|
+
inst.tracks_type_data_size = msg.int();
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
case 38: {
|
|
1192
|
+
let handle = msg.type();
|
|
1193
|
+
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1194
|
+
if (!inst)
|
|
1195
|
+
return;
|
|
1196
|
+
inst.tracks_type_data = msg.ucharArray();
|
|
1197
|
+
break;
|
|
1198
|
+
}
|
|
1199
|
+
case 42: {
|
|
1106
1200
|
let handle = msg.type();
|
|
1107
1201
|
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1108
1202
|
if (!inst)
|
|
@@ -1110,7 +1204,7 @@ export class zappar_client {
|
|
|
1110
1204
|
inst.projections_data_size = msg.int();
|
|
1111
1205
|
break;
|
|
1112
1206
|
}
|
|
1113
|
-
case
|
|
1207
|
+
case 41: {
|
|
1114
1208
|
let handle = msg.type();
|
|
1115
1209
|
let inst = this._world_tracker_state_by_instance.get(handle);
|
|
1116
1210
|
if (!inst)
|