Skip to content

Commit ce88f65

Browse files
authored
make getCameraTarget consistent with getCameraOrbit (#4895)
* make getCameraTarget consistent with getCameraOrbit * reenable tests * fix tests? * fix more tests * fix more tests * fix more flaky tests * fix more flaky tests * skip flaky tests * skip another flaky test
1 parent 953cd4a commit ce88f65

File tree

4 files changed

+194
-185
lines changed

4 files changed

+194
-185
lines changed

packages/model-viewer/src/features/controls.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export declare interface ControlsInterface {
266266
disableZoom: boolean;
267267
disablePan: boolean;
268268
disableTap: boolean;
269-
a11y: A11yTranslationsInterface | string | null;
269+
a11y: A11yTranslationsInterface|string|null;
270270
getCameraOrbit(): SphericalPosition;
271271
getCameraTarget(): Vector3D;
272272
getFieldOfView(): number;
@@ -378,7 +378,7 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
378378
@property({type: Number, attribute: 'interpolation-decay'})
379379
interpolationDecay: number = DECAY_MILLISECONDS;
380380

381-
@property() a11y: A11yTranslationsInterface | string | null = null;
381+
@property() a11y: A11yTranslationsInterface|string|null = null;
382382

383383
protected[$promptElement] =
384384
this.shadowRoot!.querySelector('.interaction-prompt') as HTMLElement;
@@ -430,7 +430,7 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
430430
getCameraTarget(): Vector3D {
431431
return toVector3D(
432432
this[$renderer].isPresenting ? this[$renderer].arRenderer.target :
433-
this[$scene].getTarget());
433+
this[$scene].getDynamicTarget());
434434
}
435435

436436
getFieldOfView(): number {
@@ -835,23 +835,22 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
835835
[$updateAria]() {
836836
const {theta, phi} =
837837
this[$controls]!.getCameraSpherical(this[$lastSpherical]);
838-
838+
839839
const azimuthalQuadrant =
840840
(4 + Math.floor(((theta % TAU) + QUARTER_PI) / HALF_PI)) % 4;
841-
841+
842842
const polarTrient = Math.floor(phi / THIRD_PI);
843-
843+
844844
const azimuthalQuadrantLabel =
845845
AZIMUTHAL_QUADRANT_LABELS[azimuthalQuadrant];
846846
const polarTrientLabel = POLAR_TRIENT_LABELS[polarTrient];
847847
const position = `${polarTrientLabel}${azimuthalQuadrantLabel}`;
848-
848+
849849
const key = position as keyof A11yTranslationsInterface;
850850
if (key in this[$a11y]) {
851851
this[$updateStatus](this[$a11y][key]);
852852
} else {
853-
this[$updateStatus](
854-
`View from stage ${position}`);
853+
this[$updateStatus](`View from stage ${position}`);
855854
}
856855
}
857856

@@ -924,7 +923,8 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
924923
};
925924

926925
[$onPointerChange] = (event: PointerChangeEvent) => {
927-
this[$container].classList.toggle('pointer-tumbling', event.type === 'pointer-change-start');
926+
this[$container].classList.toggle(
927+
'pointer-tumbling', event.type === 'pointer-change-start');
928928
};
929929

930930
[$updateA11y]() {
@@ -936,7 +936,9 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
936936
console.warn('Error parsing a11y JSON:', error);
937937
}
938938
} else if (this.a11y.length > 0) {
939-
console.warn('Error not supported format, should be a JSON string:', this.a11y);
939+
console.warn(
940+
'Error not supported format, should be a JSON string:',
941+
this.a11y);
940942
} else {
941943
this[$a11y] = <A11yTranslationsInterface>{};
942944
}
@@ -945,7 +947,7 @@ export const ControlsMixin = <T extends Constructor<ModelViewerElementBase>>(
945947
} else {
946948
this[$a11y] = <A11yTranslationsInterface>{};
947949
}
948-
950+
949951
this[$userInputElement].setAttribute('aria-label', this[$ariaLabel]);
950952
}
951953
}

0 commit comments

Comments
 (0)