blob: aede31d4706744053738cb1f21fe9ee5c4564508 [file] [edit]
<!DOCTYPE html> <!-- webkit-test-runner [ SpatialPortalEnabled=true ModelElementEnabled=true ModelProcessEnabled=true allowTestOnlyIPC=true ] -->
<html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../model-element/resources/model-utils.js"></script>
<script src="resources/spatial-portal-utils.js"></script>
<style>
.portal { spatial: portal; width: 40cm; height: 20cm; portal-transform: none; }
</style>
<body>
<script>
'use strict';
internals.disableModelLoadDelaysForTesting();
const centeredCube = "2x2x2-center.usdz";
const offsetCube = "2x2x2-at-100x50x200.usdz";
promise_test(async t => {
const narrowPortal = createPortal(t);
const narrowModel = appendModel(narrowPortal, centeredCube);
const widePortal = createPortal(t, { width: "80cm" });
const wideModel = appendModel(widePortal, centeredCube);
await narrowModel.ready;
await wideModel.ready;
const narrowTransform = await waitForPortalTransform(narrowPortal, portalTransformIsResolved, "narrow portal");
const wideTransform = await waitForPortalTransform(widePortal, portalTransformIsResolved, "wide portal");
assert_3d_matrix_approx_equals(narrowTransform, wideTransform);
}, `portal-transform: none is independent of the portal's size`);
promise_test(async t => {
const portal = createPortal(t);
const model = appendModel(portal, offsetCube);
await model.ready;
const transform = await waitForPortalTransform(portal, portalTransformIsResolved, "portal");
assert_3d_matrix_approx_equals(transform, new DOMMatrixReadOnly().translate(-100, -50, -201));
}, `portal-transform: none still centers the portal's content`);
</script>
</body>
</html>