Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encapsulation with Custom Elements #61

Open
AdamSobieski opened this issue Jan 2, 2021 · 2 comments
Open

Encapsulation with Custom Elements #61

AdamSobieski opened this issue Jan 2, 2021 · 2 comments

Comments

@AdamSobieski
Copy link

I would like to propose that the WebXR samples include one or more samples which involve the encapsulation of WebXR with Web components custom elements.

The following example markup shows a custom element (xr-image) which intends to be utilized for declaring one or more 3D images in HTML documents. As envisioned, the 3D images would be stereoscopic 3D, utilizing XR viewer tracking, and could fallback to monoscopic 3D and then to 2D images.

<xr-image src="teapot.gltf" style="width:300px; height:300px; border:1px solid black" />

See also:

@cabanier
Copy link
Member

cabanier commented Jan 2, 2021

I would like to propose that the WebXR samples include one or more samples which involve the encapsulation of WebXR with Web components custom elements.

I don't think this repo is the place for enhancements to the samples.
If you create an example using custom elements and make a PR, @toji can integrate it.

The following example markup shows a custom element (xr-image) which intends to be utilized for declaring one or more 3D images in HTML documents. As envisioned, the 3D images would be stereoscopic 3D, utilizing XR viewer tracking, and could fallback to monoscopic 3D and then to 2D images.

There are no current and afaik no upcoming implementations to enable magic windows.
Until then, it's likely premature to put an example on the immersive website.

@AdamSobieski
Copy link
Author

@cabanier , thank you. For any interested in implementing their own custom element for "magic windows", I found this example from two years ago: https://github.com/immersive-web/webxr-polyfill/blob/master/examples/magic-window.html .

There is a subtopic here which I hope is both relevant and interesting: styling the XR 3D content.

One might look at the xr-image markup example

<xr-image src="teapot.gltf" style="width:300px; height:300px; border:1px solid black" />

and wonder: what precisely should that look like? Is the 3D teapot supposed to appear behind the document, in front of the document, or half-way through the document? How should the bounding cuboid be positioned relative to the document plane? What is the desired position of the teapot relative to its bounding cuboid? How might we specify the dimensions of the bounding cuboid, color the walls of the bounding cuboid, or style the bounding cuboid with a border? How might we precisely describe or style the custom element for XR "magic window" scenarios?

After some preliminary exploration, I found that we can use custom CSS properties for purposes including to style custom elements. Custom CSS properties are prefixed by -- and are case-sensitive.

For example:

<xr-image src="teapot.gltf" style="width:300px; height:300px; --depth:300px; border:1px solid black" />

One could then use the CSSOM getComputedStyle and getPropertyValue to obtain the values of CSS properties including the custom properties.

That said, one could define custom CSS properties to answer the questions presented above. One could also extrapolate a CSS "cuboid model" from the CSS "box model".

Hopefully, these preliminary thoughts about styling XR 3D content, in particular "magic window" custom elements, are of some interest and use to other WebXR participants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants