@zappar/zappar-cv 3.0.1-beta.1 → 3.0.1-beta.11
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/additional.d.ts +0 -2
- package/lib/cameramodel.d.ts +1 -1
- package/lib/cameramodel.js +3 -3
- package/lib/drawpointswithtype.d.ts +1 -1
- package/lib/drawpointswithtype.js +11 -13
- package/lib/drawquad.d.ts +2 -0
- package/lib/drawquad.js +99 -0
- package/lib/gen/zappar-bridge.d.ts +5 -2
- package/lib/gen/zappar-client.js +103 -55
- package/lib/gen/zappar-cwrap.js +37 -26
- package/lib/gen/zappar-native.d.ts +5 -4
- package/lib/gen/zappar-server.js +63 -43
- package/lib/gen/zappar.d.ts +7 -4
- package/lib/html-element-source.js +1 -1
- package/lib/index-standalone.js +1 -1
- package/lib/mstp-camera-source.js +2 -1
- package/lib/native.js +248 -36
- package/lib/options.d.ts +1 -0
- package/lib/tracing/jsontracer.d.ts +14 -0
- package/lib/tracing/jsontracer.js +37 -0
- package/lib/tracing/performancetracer.d.ts +11 -0
- package/lib/tracing/performancetracer.js +17 -0
- package/lib/tracing/sharedtracer.d.ts +2 -0
- package/lib/tracing/sharedtracer.js +8 -0
- package/lib/tracing/usertimingtracer.d.ts +10 -0
- package/lib/tracing/usertimingtracer.js +30 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/worker-server.js +3 -3
- package/lib/zappar-cv.js +1 -1
- package/lib/zappar-cv.wasm +0 -0
- package/package.json +8 -16
- package/umd/{ad30381eac4454d1944a.wasm → 16b5486666b5c5ea1d08.wasm} +0 -0
- package/umd/751.zappar-cv.js +1 -1
- package/umd/867.zappar-cv.js +1 -1
- package/umd/zappar-cv-ceres.worker.js +1 -0
- 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-beta.
|
|
21
|
+
<script src="https://libs.zappar.com/zappar-cv/3.0.1-beta.11/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-beta.
|
|
25
|
+
[https://libs.zappar.com/zappar-cv/3.0.1-beta.11/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.0.1-beta.11/zappar-cv.zip)
|
package/lib/additional.d.ts
CHANGED
|
@@ -23,8 +23,6 @@ export interface Additional {
|
|
|
23
23
|
pipeline_draw_face_project(pipeline: zappar_pipeline_t, drawwMatrix: Float32Array, vertices: Float32Array, uvMatrix: Float32Array, uvs: Float32Array, indices: Uint16Array, texture: WebGLTexture): void;
|
|
24
24
|
pipeline_camera_frame_data_raw_enabled_set(pipeline: zappar_pipeline_t, enabled: boolean): void;
|
|
25
25
|
pipeline_camera_frame_data_raw(pipeline: zappar_pipeline_t): Promise<CameraFrameData | undefined>;
|
|
26
|
-
pipeline_camera_frame_data_width(pipeline: zappar_pipeline_t): number;
|
|
27
|
-
pipeline_camera_frame_data_height(pipeline: zappar_pipeline_t): number;
|
|
28
26
|
draw_plane(gl: WebGLRenderingContext, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array, texture: string): void;
|
|
29
27
|
draw_grid(gl: WebGLRenderingContext, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array): void;
|
|
30
28
|
draw_axis(gl: WebGLRenderingContext, projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array): void;
|
package/lib/cameramodel.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function projectionMatrixFromModelAndSize(params: Float32Array, cameraDataWidth: number, cameraDataHeight: number, screenWidth: number, screenHeight: number, near?: number, far?: number): Float32Array;
|
|
2
2
|
export declare function cameraRotationForScreenOrientation(isUserFacing: boolean): number;
|
package/lib/cameramodel.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mat4, vec3 } from "gl-matrix";
|
|
2
2
|
import { profile } from "./profile";
|
|
3
|
-
export function
|
|
4
|
-
let cam_x =
|
|
5
|
-
let cam_y =
|
|
3
|
+
export function projectionMatrixFromModelAndSize(params, cameraDataWidth, cameraDataHeight, screenWidth, screenHeight, near = 0.01, far = 100.0) {
|
|
4
|
+
let cam_x = cameraDataWidth;
|
|
5
|
+
let cam_y = cameraDataHeight;
|
|
6
6
|
let projection = mat4.create();
|
|
7
7
|
mat4.frustum(projection, near * (-0.5 - params[2]) / params[0], near * (cam_x - 0.5 - params[2]) / params[0], near * (cam_y - 0.5 - params[3]) / params[1], near * (-0.5 - params[3]) / params[1], near, far);
|
|
8
8
|
// Flip camera y axis (before any other transformations) - converts from
|
|
@@ -64,7 +64,7 @@ export class PointsWithTypeDraw {
|
|
|
64
64
|
gl.vertexAttribPointer(shader.attr_position, 2, gl.FLOAT, false, 0, 0);
|
|
65
65
|
gl.enableVertexAttribArray(shader.attr_position);
|
|
66
66
|
gl.bindBuffer(gl.ARRAY_BUFFER, typebo);
|
|
67
|
-
gl.
|
|
67
|
+
gl.vertexAttribPointer(shader.attr_type, 1, gl.UNSIGNED_BYTE, false, 0, 0);
|
|
68
68
|
gl.enableVertexAttribArray(shader.attr_type);
|
|
69
69
|
gl.drawArrays(gl.POINTS, 0, points.length / 2);
|
|
70
70
|
gl.disableVertexAttribArray(shader.attr_type);
|
|
@@ -112,37 +112,35 @@ export class PointsWithTypeDraw {
|
|
|
112
112
|
return this._shader;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
let vertexShaderSrc =
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
in uint aType;
|
|
115
|
+
let vertexShaderSrc = `
|
|
116
|
+
attribute vec2 pos;
|
|
117
|
+
attribute float aType;
|
|
119
118
|
uniform mat4 skinTexTransform;
|
|
120
119
|
uniform float pointSize;
|
|
121
120
|
|
|
122
|
-
|
|
121
|
+
varying vec4 vColor;
|
|
123
122
|
|
|
124
123
|
void main()
|
|
125
124
|
{
|
|
126
125
|
gl_Position = skinTexTransform * vec4(pos, 0.0, 1.0);
|
|
127
126
|
vColor = vec4(1.0, 0.0, 0.0, 1.0);
|
|
128
|
-
if (aType ==
|
|
127
|
+
if (aType == 1.0) {
|
|
129
128
|
vColor = vec4(1.0, 0.7, 0.0, 1.0);
|
|
130
|
-
} else if (aType >=
|
|
129
|
+
} else if (aType >= 4.0) {
|
|
131
130
|
vColor = vec4(0.0, 0.0, 1.0, 1.0);
|
|
132
|
-
} else if (aType >
|
|
131
|
+
} else if (aType > 1.0) {
|
|
133
132
|
vColor = vec4(0.0, 1.0, 0.0, 1.0);
|
|
134
133
|
}
|
|
135
134
|
gl_PointSize = pointSize;
|
|
136
135
|
}`;
|
|
137
|
-
let fragmentShaderSrc =
|
|
136
|
+
let fragmentShaderSrc = `
|
|
138
137
|
precision highp float;
|
|
139
138
|
|
|
140
|
-
|
|
141
|
-
out vec4 outColor;
|
|
139
|
+
varying vec4 vColor;
|
|
142
140
|
|
|
143
141
|
void main()
|
|
144
142
|
{
|
|
145
|
-
|
|
143
|
+
gl_FragColor = vColor;
|
|
146
144
|
}`;
|
|
147
145
|
function cameraRotationForScreenOrientation() {
|
|
148
146
|
if (window.screen.orientation && !profile.forceWindowOrientation) {
|
package/lib/drawquad.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { compileShader, linkProgram } from "./shader";
|
|
2
|
+
let shader;
|
|
3
|
+
let vbo;
|
|
4
|
+
export function disposeDrawQuad() {
|
|
5
|
+
shader = undefined;
|
|
6
|
+
vbo = undefined;
|
|
7
|
+
}
|
|
8
|
+
function generate(gl) {
|
|
9
|
+
if (vbo)
|
|
10
|
+
return vbo;
|
|
11
|
+
vbo = gl.createBuffer();
|
|
12
|
+
if (!vbo)
|
|
13
|
+
throw new Error("Unable to create buffer object");
|
|
14
|
+
let coords = [
|
|
15
|
+
-0.5, 0.5, 0,
|
|
16
|
+
-0.5, -0.5, 0,
|
|
17
|
+
0.5, 0.5, 0,
|
|
18
|
+
0.5, -0.5, 0
|
|
19
|
+
];
|
|
20
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
|
|
21
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(coords), gl.STATIC_DRAW);
|
|
22
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
23
|
+
return vbo;
|
|
24
|
+
}
|
|
25
|
+
export function drawQuad(gl, projectionMatrix, modelviewMatrix, color) {
|
|
26
|
+
let shader = getShader(gl);
|
|
27
|
+
let v = generate(gl);
|
|
28
|
+
gl.useProgram(shader.prog);
|
|
29
|
+
gl.uniformMatrix4fv(shader.unif_projection, false, projectionMatrix);
|
|
30
|
+
gl.uniformMatrix4fv(shader.unif_modelView, false, modelviewMatrix);
|
|
31
|
+
gl.uniform4fv(shader.unif_color, color);
|
|
32
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, v);
|
|
33
|
+
gl.vertexAttribPointer(shader.attr_position, 3, gl.FLOAT, false, 3 * 4, 0);
|
|
34
|
+
gl.enableVertexAttribArray(shader.attr_position);
|
|
35
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
36
|
+
gl.disableVertexAttribArray(shader.attr_position);
|
|
37
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
38
|
+
}
|
|
39
|
+
let vertexShaderSrc = `
|
|
40
|
+
#ifndef GL_ES
|
|
41
|
+
#define highp
|
|
42
|
+
#define mediump
|
|
43
|
+
#define lowp
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
uniform mat4 projMatrix;
|
|
47
|
+
uniform mat4 modelViewMatrix;
|
|
48
|
+
attribute vec4 position;
|
|
49
|
+
|
|
50
|
+
void main()
|
|
51
|
+
{
|
|
52
|
+
gl_Position = projMatrix * modelViewMatrix * position;
|
|
53
|
+
}`;
|
|
54
|
+
let fragmentShaderSrc = `
|
|
55
|
+
#define highp mediump
|
|
56
|
+
#ifdef GL_ES
|
|
57
|
+
// define default precision for float, vec, mat.
|
|
58
|
+
precision highp float;
|
|
59
|
+
#else
|
|
60
|
+
#define highp
|
|
61
|
+
#define mediump
|
|
62
|
+
#define lowp
|
|
63
|
+
#endif
|
|
64
|
+
|
|
65
|
+
uniform vec4 color;
|
|
66
|
+
|
|
67
|
+
void main()
|
|
68
|
+
{
|
|
69
|
+
gl_FragColor = color;
|
|
70
|
+
}`;
|
|
71
|
+
function getShader(gl) {
|
|
72
|
+
if (shader)
|
|
73
|
+
return shader;
|
|
74
|
+
let prog = gl.createProgram();
|
|
75
|
+
if (!prog)
|
|
76
|
+
throw new Error("Unable to create program");
|
|
77
|
+
let vertexShader = compileShader(gl, gl.VERTEX_SHADER, vertexShaderSrc);
|
|
78
|
+
let fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, fragmentShaderSrc);
|
|
79
|
+
gl.attachShader(prog, vertexShader);
|
|
80
|
+
gl.attachShader(prog, fragmentShader);
|
|
81
|
+
linkProgram(gl, prog);
|
|
82
|
+
let unif_projection = gl.getUniformLocation(prog, "projMatrix");
|
|
83
|
+
if (!unif_projection)
|
|
84
|
+
throw new Error("Unable to get uniform location projMatrix");
|
|
85
|
+
let unif_modelView = gl.getUniformLocation(prog, "modelViewMatrix");
|
|
86
|
+
if (!unif_modelView)
|
|
87
|
+
throw new Error("Unable to get uniform location modelViewMatrix");
|
|
88
|
+
let unif_color = gl.getUniformLocation(prog, "color");
|
|
89
|
+
if (!unif_color)
|
|
90
|
+
throw new Error("Unable to get uniform location color");
|
|
91
|
+
shader = {
|
|
92
|
+
prog,
|
|
93
|
+
unif_modelView,
|
|
94
|
+
unif_projection,
|
|
95
|
+
unif_color,
|
|
96
|
+
attr_position: gl.getAttribLocation(prog, "position"),
|
|
97
|
+
};
|
|
98
|
+
return shader;
|
|
99
|
+
}
|
|
@@ -61,6 +61,8 @@ export interface zappar {
|
|
|
61
61
|
pipeline_frame_update(o: zappar_pipeline_t): void;
|
|
62
62
|
pipeline_frame_number(o: zappar_pipeline_t): number;
|
|
63
63
|
pipeline_camera_model(o: zappar_pipeline_t): Float32Array;
|
|
64
|
+
pipeline_camera_data_width(o: zappar_pipeline_t): number;
|
|
65
|
+
pipeline_camera_data_height(o: zappar_pipeline_t): number;
|
|
64
66
|
pipeline_camera_frame_user_data(o: zappar_pipeline_t): number;
|
|
65
67
|
pipeline_camera_frame_submit(o: zappar_pipeline_t, data: ArrayBuffer, width: number, height: number, user_data: number, camera_to_device_transform: Float32Array, camera_model: Float32Array, user_facing: boolean, timestampSeconds: number): void;
|
|
66
68
|
pipeline_camera_frame_camera_attitude(o: zappar_pipeline_t): Float32Array;
|
|
@@ -164,9 +166,10 @@ export interface zappar {
|
|
|
164
166
|
custom_anchor_create(pipeline: zappar_pipeline_t, worldtracker: zappar_world_tracker_t, id: string): zappar_custom_anchor_t;
|
|
165
167
|
custom_anchor_destroy(o: zappar_custom_anchor_t): void;
|
|
166
168
|
custom_anchor_status(o: zappar_custom_anchor_t): anchor_status_t;
|
|
167
|
-
|
|
168
|
-
custom_anchor_enabled(o: zappar_custom_anchor_t): boolean;
|
|
169
|
+
custom_anchor_pose_version(o: zappar_custom_anchor_t): number;
|
|
169
170
|
custom_anchor_pose_raw(o: zappar_custom_anchor_t): Float32Array;
|
|
170
171
|
custom_anchor_pose_set_from_camera_offset_raw(o: zappar_custom_anchor_t, x: number, y: number, z: number, orientation: transform_orientation_t): void;
|
|
171
172
|
custom_anchor_pose_set_from_anchor_offset(o: zappar_custom_anchor_t, anchor_id: string, x: number, y: number, z: number, orientation: transform_orientation_t): void;
|
|
173
|
+
custom_anchor_pose_set(o: zappar_custom_anchor_t, pose: Float32Array): void;
|
|
174
|
+
custom_anchor_pose_set_with_parent(o: zappar_custom_anchor_t, pose: Float32Array, anchor_id: string): void;
|
|
172
175
|
}
|