1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
// assert_equals can fail when comparing floats due to precision errors, so
// use assert_approx_equals with this constant instead
const FLOAT_EPSILON = 0.001;
// Identity matrix
const IDENTITY_MATRIX = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1];
const IDENTITY_TRANSFORM = {
position: [0, 0, 0],
orientation: [0, 0, 0, 1],
};
// A valid pose matrix/transform for when we don't care about specific values
// Note that these two should be identical, just different representations
const VALID_POSE_MATRIX = [0, 1, 0, 0,
0, 0, 1, 0,
1, 0, 0, 0,
1, 1, 1, 1];
const VALID_POSE_TRANSFORM = {
position: [1, 1, 1],
orientation: [0.5, 0.5, 0.5, 0.5]
};
const VALID_PROJECTION_MATRIX =
[1, 0, 0, 0, 0, 1, 0, 0, 3, 2, -1, -1, 0, 0, -0.2, 0];
// This is a decomposed version of the above.
const VALID_FIELD_OF_VIEW = {
upDegrees: 71.565,
downDegrees: -45,
leftDegrees:-63.4349,
rightDegrees: 75.9637
};
// A valid input grip matrix for when we don't care about specific values
const VALID_GRIP = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
4, 3, 2, 1];
const VALID_GRIP_TRANSFORM = {
position: [4, 3, 2],
orientation: [0, 0, 0, 1]
};
// A valid input pointer offset for when we don't care about specific values
const VALID_POINTER = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 1, 1];
const VALID_POINTER_TRANSFORM = {
position: [0, 0, 1],
orientation: [0, 0, 0, 1]
};
// A Valid Local to floor matrix/transform for when we don't care about specific
// values. Note that these should be identical, just different representations.
const VALID_FLOOR_ORIGIN_MATRIX = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
1, 1.65, -1, 1];
const VALID_FLOOR_ORIGIN = {
position: [-1.0, -1.65, 1.0],
orientation: [0, 0, 0, 1]
};
const VALID_BOUNDS = [
{ x: 3.0, z: -2.0 },
{ x: 3.5, z: 0.0 },
{ x: 3.0, z: 2.0 },
{ x: -3.0, z: 2.0 },
{ x: -3.5, z: 0.0 },
{ x: -3.0, z: -2.0 }
];
const VALID_RESOLUTION = {
width: 200,
height: 200
};
const LEFT_OFFSET = {
position: [-0.1, 0, 0],
orientation: [0, 0, 0, 1]
};
const RIGHT_OFFSET = {
position: [0.1, 0, 0],
orientation: [0, 0, 0, 1]
};
const VALID_VIEWS = [{
eye:"left",
projectionMatrix: VALID_PROJECTION_MATRIX,
viewOffset: LEFT_OFFSET,
resolution: VALID_RESOLUTION
}, {
eye:"right",
projectionMatrix: VALID_PROJECTION_MATRIX,
viewOffset: RIGHT_OFFSET,
resolution: VALID_RESOLUTION
},
];
const NON_IMMERSIVE_VIEWS = [{
eye: "none",
projectionMatrix: VALID_PROJECTION_MATRIX,
viewOffset: IDENTITY_TRANSFORM,
resolution: VALID_RESOLUTION,
}
];
const ALL_FEATURES = [
'viewer',
'local',
'local-floor',
'bounded-floor',
'unbounded',
'hit-test',
'dom-overlay',
'light-estimation',
];
const TRACKED_IMMERSIVE_DEVICE = {
supportsImmersive: true,
supportedModes: [ "inline", "immersive-vr"],
views: VALID_VIEWS,
viewerOrigin: IDENTITY_TRANSFORM,
supportedFeatures: ALL_FEATURES
};
const IMMERSIVE_AR_DEVICE = {
supportsImmersive: true,
supportedModes: [ "inline", "immersive-ar"],
views: VALID_VIEWS,
viewerOrigin: IDENTITY_TRANSFORM,
supportedFeatures: ALL_FEATURES
};
const VALID_NON_IMMERSIVE_DEVICE = {
supportsImmersive: false,
supportedModes: ["inline"],
views: NON_IMMERSIVE_VIEWS,
viewerOrigin: IDENTITY_TRANSFORM,
supportedFeatures: ALL_FEATURES
};
const VALID_CONTROLLER = {
handedness: "none",
targetRayMode: "tracked-pointer",
pointerOrigin: VALID_POINTER_TRANSFORM,
profiles: []
};
const RIGHT_CONTROLLER = {
handedness: "right",
targetRayMode: "tracked-pointer",
pointerOrigin: VALID_POINTER_TRANSFORM,
profiles: []
};
const SCREEN_CONTROLLER = {
handedness: "none",
targetRayMode: "screen",
pointerOrigin: VALID_POINTER_TRANSFORM,
profiles: []
};
|