Commit 9fe8a648 authored by Piotr Bialecki's avatar Piotr Bialecki Committed by Commit Bot

CL followup - run ESLint, throw from math helper

- ran ESLint on webxr-test.js and xr-internal-device-mocking.js
- xr-internal-device-mocking.js now stores the
  `MockRuntime._injectAdditionalFrameData()` before overwriting it with
  its own implementation, and calls the original implementation as the
  first step
- throw instead of console.warn when math helper encounters unexpected
  combinations of .w component

Changes: 
Change-Id: I94c015b5c89cfbc0e1a4b90db6ec44a198f4ce05
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008073
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Auto-Submit: Piotr Bialecki <bialpio@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732977}
parent 665fc90a
......@@ -23,7 +23,7 @@ class XRMathHelper {
// .w is treated here like an entity type, 1 signifies points, 0 signifies vectors.
// point - point, point - vector, vector - vector are ok, vector - point is not.
if (lhs.w != rhs.w && lhs.w == 0.0) {
console.warn("vector - point not allowed: " + toString(lhs) + "-" + toString(rhs));
throw new Error("vector - point not allowed: " + toString(lhs) + "-" + toString(rhs));
}
return {x : lhs.x - rhs.x, y : lhs.y - rhs.y, z : lhs.z - rhs.z, w : lhs.w - rhs.w};
......@@ -31,7 +31,7 @@ class XRMathHelper {
static add(lhs, rhs) {
if (lhs.w == rhs.w && lhs.w == 1.0) {
console.warn("point + point not allowed", p1, p2);
throw new Error("point + point not allowed", p1, p2);
}
return {x : lhs.x + rhs.x, y : lhs.y + rhs.y, z : lhs.z + rhs.z, w : lhs.w + rhs.w};
......@@ -39,7 +39,7 @@ class XRMathHelper {
static cross(lhs, rhs) {
if (lhs.w != 0.0 || rhs.w != 0.0) {
console.warn("cross product not allowed: " + toString(lhs) + "x" + toString(rhs));
throw new Error("cross product not allowed: " + toString(lhs) + "x" + toString(rhs));
}
return {
......@@ -52,7 +52,7 @@ class XRMathHelper {
static dot(lhs, rhs) {
if (lhs.w != 0 || rhs.w != 0) {
console.warn("dot product not allowed: " + toString(lhs) + "x" + toString(rhs));
throw new Error("dot product not allowed: " + toString(lhs) + "x" + toString(rhs));
}
return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z;
......@@ -60,7 +60,7 @@ class XRMathHelper {
static mul(scalar, vector) {
if (vector.w != 0) {
console.warn("scalar * vector not allowed", scalar, vector);
throw new Error("scalar * vector not allowed", scalar, vector);
}
return {x : vector.x * scalar, y : vector.y * scalar, z : vector.z * scalar, w : vector.w};
......
......@@ -4,7 +4,7 @@
// https://github.com/immersive-web/webxr-test-api
let default_standing = new gfx.mojom.Transform();
const default_standing = new gfx.mojom.Transform();
default_standing.matrix = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
......@@ -15,26 +15,26 @@ const default_stage_parameters = {
};
function getMatrixFromTransform(transform) {
let x = transform.orientation[0];
let y = transform.orientation[1];
let z = transform.orientation[2];
let w = transform.orientation[3];
const x = transform.orientation[0];
const y = transform.orientation[1];
const z = transform.orientation[2];
const w = transform.orientation[3];
let m11 = 1.0 - 2.0 * (y * y + z * z);
let m21 = 2.0 * (x * y + z * w);
let m31 = 2.0 * (x * z - y * w);
const m11 = 1.0 - 2.0 * (y * y + z * z);
const m21 = 2.0 * (x * y + z * w);
const m31 = 2.0 * (x * z - y * w);
let m12 = 2.0 * (x * y - z * w);
let m22 = 1.0 - 2.0 * (x * x + z * z);
let m32 = 2.0 * (y * z + x * w);
const m12 = 2.0 * (x * y - z * w);
const m22 = 1.0 - 2.0 * (x * x + z * z);
const m32 = 2.0 * (y * z + x * w);
let m13 = 2.0 * (x * z + y * w);
let m23 = 2.0 * (y * z - x * w);
let m33 = 1.0 - 2.0 * (x * x + y * y);
const m13 = 2.0 * (x * z + y * w);
const m23 = 2.0 * (y * z - x * w);
const m33 = 1.0 - 2.0 * (x * x + y * y);
let m14 = transform.position[0];
let m24 = transform.position[1];
let m34 = transform.position[2];
const m14 = transform.position[0];
const m24 = transform.position[1];
const m34 = transform.position[2];
// Column-major linearized order is expected.
return [m11, m21, m31, 0,
......@@ -44,7 +44,7 @@ function getMatrixFromTransform(transform) {
}
function composeGFXTransform(fakeTransformInit) {
let transform = new gfx.mojom.Transform();
const transform = new gfx.mojom.Transform();
transform.matrix = getMatrixFromTransform(fakeTransformInit);
return transform;
}
......@@ -64,7 +64,7 @@ class ChromeXRTest {
}
simulateUserActivation(callback) {
let button = document.createElement('button');
const button = document.createElement('button');
button.textContent = 'click to continue test';
button.style.display = 'block';
button.style.fontSize = '20px';
......@@ -95,7 +95,7 @@ class MockVRService {
// Test methods
addRuntime(fakeDeviceInit) {
let runtime = new MockRuntime(fakeDeviceInit, this);
const runtime = new MockRuntime(fakeDeviceInit, this);
this.runtimes_.push(runtime);
if (this.client_) {
......@@ -114,7 +114,7 @@ class MockVRService {
}
removeRuntime(device) {
let index = this.runtimes_.indexOf(device);
const index = this.runtimes_.indexOf(device);
if (index >= 0) {
this.runtimes_.splice(index, 1);
if (this.client_) {
......@@ -132,7 +132,7 @@ class MockVRService {
}
requestSession(sessionOptions, was_activation) {
let requests = [];
const requests = [];
// Request a session from all the runtimes.
for (let i = 0; i < this.runtimes_.length; i++) {
requests[i] = this.runtimes_[i].requestRuntimeSession(sessionOptions);
......@@ -143,12 +143,12 @@ class MockVRService {
for (let i = 0; i < results.length; i++) {
if (results[i].session) {
// Construct a dummy metrics recorder
let metricsRecorderPtr = new device.mojom.XRSessionMetricsRecorderPtr();
let metricsRecorderRequest = mojo.makeRequest(metricsRecorderPtr);
let metricsRecorderBinding = new mojo.Binding(
const metricsRecorderPtr = new device.mojom.XRSessionMetricsRecorderPtr();
const metricsRecorderRequest = mojo.makeRequest(metricsRecorderPtr);
const metricsRecorderBinding = new mojo.Binding(
device.mojom.XRSessionMetricsRecorder, new MockXRSessionMetricsRecorder(), metricsRecorderRequest);
let success = {
const success = {
session: results[i].session,
metricsRecorder: metricsRecorderPtr,
};
......@@ -177,7 +177,7 @@ class MockVRService {
}
supportsSession(sessionOptions) {
let requests = [];
const requests = [];
// Check supports on all the runtimes.
for (let i = 0; i < this.runtimes_.length; i++) {
requests[i] = this.runtimes_[i].runtimeSupportsSession(sessionOptions);
......@@ -194,7 +194,7 @@ class MockVRService {
// If there were no successful results, returns false.
return {supportsSession: false};
});
};
}
}
// Implements XRFrameDataProvider and XRPresentationProvider. Maintains a mock
......@@ -207,7 +207,8 @@ class MockRuntime {
"local": device.mojom.XRSessionFeature.REF_SPACE_LOCAL,
"local-floor": device.mojom.XRSessionFeature.REF_SPACE_LOCAL_FLOOR,
"bounded-floor": device.mojom.XRSessionFeature.REF_SPACE_BOUNDED_FLOOR,
"unbounded": device.mojom.XRSessionFeature.REF_SPACE_UNBOUNDED };
"unbounded": device.mojom.XRSessionFeature.REF_SPACE_UNBOUNDED,
};
static sessionModeToMojoMap = {
"inline": device.mojom.XRSessionMode.kInline,
......@@ -239,18 +240,18 @@ class MockRuntime {
let supportedModes = [];
if (fakeDeviceInit.supportedModes) {
supportedModes = fakeDeviceInit.supportedModes.slice();
if(fakeDeviceInit.supportedModes.length === 0) {
if (fakeDeviceInit.supportedModes.length === 0) {
supportedModes = ["inline"];
}
} else {
// Back-compat mode.
console.warn("Please use `supportedModes` to signal which modes are supported by this device.");
if(fakeDeviceInit.supportsImmersive == null) {
if (fakeDeviceInit.supportsImmersive == null) {
throw new TypeError("'supportsImmersive' must be set");
}
supportedModes = ["inline"];
if(fakeDeviceInit.supportsImmersive) {
if (fakeDeviceInit.supportsImmersive) {
supportedModes.push("immersive-vr");
}
}
......@@ -259,8 +260,8 @@ class MockRuntime {
// Initialize DisplayInfo first to set the defaults, then override with
// anything from the deviceInit
if(this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveVr)
|| this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
if (this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveVr)
|| this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
this.displayInfo_ = this.getImmersiveDisplayInfo();
} else if (this.supportedModes_.includes(device.mojom.XRSessionMode.kInline)) {
this.displayInfo_ = this.getNonImmersiveDisplayInfo();
......@@ -292,8 +293,9 @@ class MockRuntime {
}
_convertModeToEnum(sessionMode) {
if(sessionMode in MockRuntime.sessionModeToMojoMap)
if (sessionMode in MockRuntime.sessionModeToMojoMap) {
return MockRuntime.sessionModeToMojoMap[sessionMode];
}
throw new TypeError("Unrecognized value for XRSessionMode enum: " + sessionMode);
}
......@@ -333,8 +335,8 @@ class MockRuntime {
}
setViewerOrigin(origin, emulatedPosition = false) {
let p = origin.position;
let q = origin.orientation;
const p = origin.position;
const q = origin.orientation;
this.pose_ = {
orientation: { x: q[0], y: q[1], z: q[2], w: q[3] },
position: { x: p[0], y: p[1], z: p[2] },
......@@ -354,7 +356,7 @@ class MockRuntime {
simulateVisibilityChange(visibilityState) {
let mojoState = null;
switch(visibilityState) {
switch (visibilityState) {
case "visible":
mojoState = device.mojom.XRVisibilityState.VISIBLE;
break;
......@@ -422,17 +424,17 @@ class MockRuntime {
}
simulateInputSourceConnection(fakeInputSourceInit) {
let index = this.next_input_source_index_;
const index = this.next_input_source_index_;
this.next_input_source_index_++;
let source = new MockXRInputSource(fakeInputSourceInit, index, this);
const source = new MockXRInputSource(fakeInputSourceInit, index, this);
this.input_sources_.set(index, source);
return source;
}
// Helper methods
getNonImmersiveDisplayInfo() {
let displayInfo = this.getImmersiveDisplayInfo();
const displayInfo = this.getImmersiveDisplayInfo();
displayInfo.capabilities.canPresent = false;
displayInfo.leftEye = null;
......@@ -497,16 +499,16 @@ class MockRuntime {
rightDegrees: fakeXRViewInit.fieldOfView.rightDegrees
};
} else {
let m = fakeXRViewInit.projectionMatrix;
const m = fakeXRViewInit.projectionMatrix;
function toDegrees(tan) {
return Math.atan(tan) * 180 / Math.PI;
}
let leftTan = (1 - m[8]) / m[0];
let rightTan = (1 + m[8]) / m[0];
let upTan = (1 + m[9]) / m[5];
let downTan = (1 - m[9]) / m[5];
const leftTan = (1 - m[8]) / m[0];
const rightTan = (1 + m[8]) / m[0];
const upTan = (1 + m[9]) / m[5];
const downTan = (1 - m[9]) / m[5];
fov = {
upDegrees: toDegrees(upTan),
......@@ -536,7 +538,7 @@ class MockRuntime {
this.supportedFeatures_ = [];
for (let i = 0; i < supportedFeatures.length; i++) {
let feature = convertFeatureToMojom(supportedFeatures[i]);
const feature = convertFeatureToMojom(supportedFeatures[i]);
if (feature !== device.mojom.XRSessionFeature.INVALID) {
this.supportedFeatures_.push(feature);
}
......@@ -545,7 +547,7 @@ class MockRuntime {
// These methods are intended to be used by MockXRInputSource only.
addInputSource(source) {
if(!this.input_sources_.has(source.source_id_)) {
if (!this.input_sources_.has(source.source_id_)) {
this.input_sources_.set(source.source_id_, source);
}
}
......@@ -554,14 +556,16 @@ class MockRuntime {
this.input_sources_.delete(source.source_id_);
}
// Mojo function implementations.
// Extension point for non-standard modules.
_injectAdditionalFrameData(options, frameData) {
}
// Mojo function implementations.
// XRFrameDataProvider implementation.
getFrameData(options) {
let mojo_space_reset = this.send_mojo_space_reset_;
const mojo_space_reset = this.send_mojo_space_reset_;
this.send_mojo_space_reset_ = false;
if (this.pose_) {
this.pose_.poseIndex++;
......@@ -574,18 +578,18 @@ class MockRuntime {
let input_state = null;
if (this.input_sources_.size > 0) {
input_state = [];
for (let input_source of this.input_sources_.values()) {
for (const input_source of this.input_sources_.values()) {
input_state.push(input_source.getInputSourceState());
}
}
// Convert current document time to monotonic time.
let now = window.performance.now() / 1000.0;
let diff = now - internals.monotonicTimeToZeroBasedDocumentTime(now);
const diff = now - internals.monotonicTimeToZeroBasedDocumentTime(now);
now += diff;
now *= 1000000;
let frameData = {
const frameData = {
pose: this.pose_,
mojoSpaceReset: mojo_space_reset,
inputState: input_state,
......@@ -597,10 +601,10 @@ class MockRuntime {
bufferSize: {},
};
this._injectAdditionalFrameData(options, frameData);
this._calculateHitTestResults(frameData);
this._injectAdditionalFrameData(options, frameData);
return Promise.resolve({
frameData: frameData,
});
......@@ -630,7 +634,7 @@ class MockRuntime {
// XREnvironmentIntegrationProvider implementation:
subscribeToHitTest(nativeOriginInformation, entityTypes, ray) {
if(!this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
if (!this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
// Reject outside of AR.
return Promise.resolve({
result : device.mojom.SubscribeToHitTestResult.FAILED,
......@@ -638,18 +642,18 @@ class MockRuntime {
});
}
if(nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.inputSourceId) {
if(!this.input_sources_.has(nativeOriginInformation.inputSourceId)) {
if (nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.inputSourceId) {
if (!this.input_sources_.has(nativeOriginInformation.inputSourceId)) {
// Reject - unknown input source ID.
return Promise.resolve({
result : device.mojom.SubscribeToHitTestResult.FAILED,
subscriptionId : 0
});
}
} else if(nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.referenceSpaceCategory) {
} else if (nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.referenceSpaceCategory) {
// Bounded_floor & unbounded ref spaces are not yet supported for AR:
if(nativeOriginInformation.referenceSpaceCategory == device.mojom.XRReferenceSpaceCategory.UNBOUNDED
|| nativeOriginInformation.referenceSpaceCategory == device.mojom.XRReferenceSpaceCategory.BOUNDED_FLOOR) {
if (nativeOriginInformation.referenceSpaceCategory == device.mojom.XRReferenceSpaceCategory.UNBOUNDED
|| nativeOriginInformation.referenceSpaceCategory == device.mojom.XRReferenceSpaceCategory.BOUNDED_FLOOR) {
return Promise.resolve({
result : device.mojom.SubscribeToHitTestResult.FAILED,
subscriptionId : 0
......@@ -677,7 +681,7 @@ class MockRuntime {
requestRuntimeSession(sessionOptions) {
return this.runtimeSupportsSession(sessionOptions).then((result) => {
// The JavaScript bindings convert c_style_names to camelCase names.
let options = new device.mojom.XRPresentationTransportOptions();
const options = new device.mojom.XRPresentationTransportOptions();
options.transportMethod =
device.mojom.XRPresentationTransportMethod.SUBMIT_AS_MAILBOX_HOLDER;
options.waitForTransferNotification = true;
......@@ -691,15 +695,15 @@ class MockRuntime {
transportOptions: options
};
let dataProviderPtr = new device.mojom.XRFrameDataProviderPtr();
let dataProviderRequest = mojo.makeRequest(dataProviderPtr);
const dataProviderPtr = new device.mojom.XRFrameDataProviderPtr();
const dataProviderRequest = mojo.makeRequest(dataProviderPtr);
this.dataProviderBinding_ = new mojo.Binding(
device.mojom.XRFrameDataProvider, this, dataProviderRequest);
let clientReceiver = mojo.makeRequest(this.sessionClient_);
const clientReceiver = mojo.makeRequest(this.sessionClient_);
let enabled_features = [];
for(let i = 0; i < sessionOptions.requiredFeatures.length; i++) {
const enabled_features = [];
for (let i = 0; i < sessionOptions.requiredFeatures.length; i++) {
if (this.supportedFeatures_.indexOf(sessionOptions.requiredFeatures[i]) !== -1) {
enabled_features.push(sessionOptions.requiredFeatures[i]);
} else {
......@@ -738,7 +742,7 @@ class MockRuntime {
// Modifies passed in frameData to add hit test results.
_calculateHitTestResults(frameData) {
if(!this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
if (!this.supportedModes_.includes(device.mojom.XRSessionMode.kImmersiveAr)) {
return;
}
......@@ -746,14 +750,14 @@ class MockRuntime {
frameData.hitTestSubscriptionResults.results = [];
frameData.hitTestSubscriptionResults.transientInputResults = [];
if(!this.world_) {
if (!this.world_) {
return;
}
// Non-transient hit test:
for(const [id, subscription] of this.hitTestSubscriptions_) {
for (const [id, subscription] of this.hitTestSubscriptions_) {
const mojo_from_native_origin = this._getMojoFromNativeOrigin(subscription.nativeOriginInformation);
if(!mojo_from_native_origin) continue;
if (!mojo_from_native_origin) continue;
const ray_origin = {x: subscription.ray.origin.x, y: subscription.ray.origin.y, z: subscription.ray.origin.z, w: 1};
const ray_direction = {x: subscription.ray.direction.x, y: subscription.ray.direction.y, z: subscription.ray.direction.z, w: 0};
......@@ -775,7 +779,7 @@ class MockRuntime {
_hitTestWorld(origin, direction, entityTypes) {
let result = [];
for(const region of this.world_.hitTestRegions) {
for (const region of this.world_.hitTestRegions) {
const partial_result = this._hitTestRegion(
region,
origin, direction,
......@@ -785,7 +789,7 @@ class MockRuntime {
}
return result.sort((lhs, rhs) => lhs.distance - rhs.distance);
};
}
// Hit tests the passed in ray (expressed as origin and direction) against world region.
// |entityTypes| is a set of FakeXRRegionTypes.
......@@ -798,14 +802,14 @@ class MockRuntime {
"mesh":null
};
if(!entityTypes.includes(regionNameToMojoEnum[region.type])) {
if (!entityTypes.includes(regionNameToMojoEnum[region.type])) {
return [];
}
const result = [];
for(const face of region.faces) {
for (const face of region.faces) {
const maybe_hit = this._hitTestFace(face, origin, direction);
if(maybe_hit) {
if (maybe_hit) {
result.push(maybe_hit);
}
}
......@@ -845,7 +849,7 @@ class MockRuntime {
const numerator = dot(sub(point_A, origin), normal);
const denominator = dot(direction, normal);
if(Math.abs(denominator) < 0.0001) {
if (Math.abs(denominator) < 0.0001) {
// Planes are nearly parallel - there's either infinitely many intersection points or 0.
// Both cases signify a "no hit" for us.
return null;
......@@ -853,7 +857,7 @@ class MockRuntime {
// Single intersection point between the infinite plane and the line (*not* ray).
// Need to calculate the hit test matrix taking into account the face vertices.
const distance = numerator / denominator;
if(distance < 0) {
if (distance < 0) {
// Line - plane intersection exists, but not the half-line - plane does not.
return null;
} else {
......@@ -864,7 +868,7 @@ class MockRuntime {
let z_axis = null;
const cos_direction_and_y_axis = dot(direction, y_axis);
if(Math.abs(cos_direction_and_y_axis) > 0.9999) {
if (Math.abs(cos_direction_and_y_axis) > 0.9999) {
// Ray and the hit test normal are co-linear - try using the 'up' or 'right' vector's projection on the face plane as the Z axis.
// Note: this edge case is currently not covered by the spec.
const up = {x: 0.0, y: 1.0, z: 0.0, w: 0.0};
......@@ -881,7 +885,7 @@ class MockRuntime {
const x_axis = normalize(cross(y_axis, z_axis));
// Filter out the points not in polygon.
if(!XRMathHelper.pointInFace(intersection_point, face)) {
if (!XRMathHelper.pointInFace(intersection_point, face)) {
return null;
}
......@@ -928,20 +932,20 @@ class MockRuntime {
];
};
if(nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.inputSourceId) {
if(!this.input_sources_.has(nativeOriginInformation.inputSourceId)) {
if (nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.inputSourceId) {
if (!this.input_sources_.has(nativeOriginInformation.inputSourceId)) {
return null;
} else {
const inputSource = this.input_sources_.get(nativeOriginInformation.inputSourceId);
return inputSource.mojo_from_input_.matrix;
}
} else if(nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.referenceSpaceCategory) {
switch(nativeOriginInformation.referenceSpaceCategory) {
} else if (nativeOriginInformation.$tag == device.mojom.XRNativeOriginInformation.Tags.referenceSpaceCategory) {
switch (nativeOriginInformation.referenceSpaceCategory) {
case device.mojom.XRReferenceSpaceCategory.LOCAL:
return identity();
case device.mojom.XRReferenceSpaceCategory.LOCAL_FLOOR:
if(this.displayInfo_ == null || this.displayInfo_.stageParameters == null
|| this.displayInfo_.stageParameters.standingTransform == null) {
if (this.displayInfo_ == null || this.displayInfo_.stageParameters == null
|| this.displayInfo_.stageParameters.standingTransform == null) {
console.warn("Standing transform not available.");
return null;
}
......@@ -1097,10 +1101,10 @@ class MockXRInputSource {
return;
}
let supported_button_map = {};
const supported_button_map = {};
this.gamepad_ = this.getEmptyGamepad();
for (let i = 0; i < supportedButtons.length; i++) {
let buttonType = supportedButtons[i].buttonType;
const buttonType = supportedButtons[i].buttonType;
this.supported_buttons_.push(buttonType);
supported_button_map[buttonType] = supportedButtons[i];
}
......@@ -1127,7 +1131,7 @@ class MockXRInputSource {
pressed: false,
touched: false,
value: 0
}
};
}
}
......@@ -1143,8 +1147,8 @@ class MockXRInputSource {
throw new Error("Tried to update state on an unsupported button");
}
let buttonIndex = this.getButtonIndex(buttonState.buttonType);
let axesStartIndex = this.getAxesStartIndex(buttonState.buttonType);
const buttonIndex = this.getButtonIndex(buttonState.buttonType);
const axesStartIndex = this.getAxesStartIndex(buttonState.buttonType);
if (buttonIndex == -1) {
throw new Error("Unknown Button Type!");
......@@ -1162,7 +1166,7 @@ class MockXRInputSource {
// Helpers for Mojom
getInputSourceState() {
let input_state = new device.mojom.XRInputSourceState();
const input_state = new device.mojom.XRInputSourceState();
input_state.sourceId = this.source_id_;
......@@ -1180,7 +1184,7 @@ class MockXRInputSource {
input_state.emulatedPosition = this.emulated_position_;
if (this.desc_dirty_) {
let input_desc = new device.mojom.XRInputSourceDescription();
const input_desc = new device.mojom.XRInputSourceDescription();
switch (this.target_ray_mode_) {
case 'gaze':
......@@ -1223,7 +1227,7 @@ class MockXRInputSource {
getEmptyGamepad() {
// Mojo complains if some of the properties on Gamepad are null, so set
// everything to reasonable defaults that tests can override.
let gamepad = new device.mojom.Gamepad();
const gamepad = new device.mojom.Gamepad();
gamepad.connected = true;
gamepad.id = "";
gamepad.timestamp = 0;
......@@ -1252,8 +1256,8 @@ class MockXRInputSource {
return;
}
let buttonIndex = this.getButtonIndex(buttonState.buttonType);
let axesStartIndex = this.getAxesStartIndex(buttonState.buttonType);
const buttonIndex = this.getButtonIndex(buttonState.buttonType);
const axesStartIndex = this.getAxesStartIndex(buttonState.buttonType);
if (buttonIndex == -1) {
throw new Error("Unknown Button Type!");
......@@ -1314,8 +1318,8 @@ class MockXRPresentationProvider {
}
bindProvider(request) {
let providerPtr = new device.mojom.XRPresentationProviderPtr();
let providerRequest = mojo.makeRequest(providerPtr);
const providerPtr = new device.mojom.XRPresentationProviderPtr();
const providerRequest = mojo.makeRequest(providerPtr);
this.binding_.close();
......@@ -1356,7 +1360,7 @@ class MockXRPresentationProvider {
// This is a temporary workaround for the fact that spinning up webxr before
// the mojo interceptors are created will cause the interceptors to not get
// registered, so we have to create this before we query xr;
let XRTest = new ChromeXRTest();
const XRTest = new ChromeXRTest();
// This test API is also used to run Chrome's internal legacy VR tests; however,
// those fail if navigator.xr has been used. Those tests will set a bool telling
......
......@@ -11,9 +11,9 @@ MockRuntime.prototype.setHitTestResults = function(results) {
// XREnvironmentIntegrationProvider implementation
MockRuntime.prototype.requestHitTest = function(ray) {
var hit_results = this.hittest_results_;
let hit_results = this.hittest_results_;
if (!hit_results) {
var hit = new device.mojom.XRHitResult();
const hit = new device.mojom.XRHitResult();
// No change to the underlying matrix/leaving it null results in identity.
hit.hitMatrix = new gfx.mojom.Transform();
......@@ -30,7 +30,10 @@ MockRuntime.prototype.getMissingFrameCount = function() {
return this.presentation_provider_.missing_frame_count_;
};
MockRuntime.prototype._injectAdditionalFrameData_preLightEstimation = MockRuntime.prototype._injectAdditionalFrameData;
MockRuntime.prototype._injectAdditionalFrameData = function(options, frameData) {
this._injectAdditionalFrameData_preLightEstimation(options, frameData);
if (!options || !options.includeLightingEstimationData) {
return;
}
......@@ -38,7 +41,7 @@ MockRuntime.prototype._injectAdditionalFrameData = function(options, frameData)
frameData.lightEstimationData = {
lightProbe: {
sphericalHarmonics: {
coefficients: new Array(9).fill().map((x, i) => { return { red: i, green: i, blue: i }; }),
coefficients: new Array(9).fill().map((x, i) => ({ red: i, green: i, blue: i })),
},
mainLightDirection: { x: 0, y: 1, z: 0 },
mainLightIntensity: { red: 1, green: 1, blue: 1 },
......@@ -82,7 +85,7 @@ MockXRInputSource.prototype.getInputSourceStateCommon =
MockXRInputSource.prototype.getInputSourceState;
MockXRInputSource.prototype.getInputSourceState = function() {
let input_state = this.getInputSourceStateCommon();
const input_state = this.getInputSourceStateCommon();
console.log('getInputSourceState this.overlay_pointer_position_=' + JSON.stringify(this.overlay_pointer_position_));
if (this.overlay_pointer_position_) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment