Skip to content

Added CSS3D + WebGL example.#31572

Merged
mrdoob merged 2 commits into
devfrom
css3d
Sep 3, 2025
Merged

Added CSS3D + WebGL example.#31572
mrdoob merged 2 commits into
devfrom
css3d

Conversation

@mrdoob

@mrdoob mrdoob commented Aug 5, 2025

Copy link
Copy Markdown
Owner

Description

Added an example mixing CSS3D and WebGL. Not sure if it's the simplest approach though...

https://raw.githack.com/mrdoob/three.js/128860b66f0c250af933714fc7f77a03ef0b06d7/examples/css3d_mixed.html

Screenshot 2025-08-05 at 9 37 22 PM

@mrdoob mrdoob added this to the r180 milestone Aug 5, 2025
Comment thread examples/css3d_mixed.html Fixed
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Mugen87

Mugen87 commented Aug 6, 2025

Copy link
Copy Markdown
Collaborator

I have noticed the following errors in the browser console:

[Violation] Potential permissions policy violation: fullscreen is not allowed in this document.
[Violation] Potential permissions policy violation: xr-spatial-tracking is not allowed in this document.

They appear not just with rawgit but also when running the demo locally (with HTTPS). It seems it's possible to prevent them locally by adding this line when creating the iFrame.

iframe.allow = 'fullscreen;xr-spatial-tracking';

I wonder why they appear in the first place. Does the browser analyze the JS and realize the engine could make use of WebXR?

@mrxz

mrxz commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

I wonder why they appear in the first place. Does the browser analyze the JS and realize the engine could make use of WebXR?

I believe it's caused by the fact that the Three.js examples page tries to allow the inner iframe both fullscreen and xr-spatial-tracking (examples/index.html#L41). But in this example, it itself is in an iframe that isn't allowed these permissions, so it can't pass these on or grant them.

@Makio64

Makio64 commented Aug 27, 2025

Copy link
Copy Markdown
Contributor

@mrdoob Another example im often asked by client is the opposite usage, all the 3d is done in webgl and texts like tooltips or form input are added on top of them using css3d.

@mrdoob

mrdoob commented Aug 27, 2025

Copy link
Copy Markdown
Owner Author

We have a couple of examples like that (using CSS2DRenderer):

https://threejs.org/examples/?q=css2#css2d_label
https://threejs.org/examples/?q=css2#webgl_loader_pdb

@Makio64

Makio64 commented Aug 27, 2025

Copy link
Copy Markdown
Contributor

@mrdoob actually i didnt realize its a webgl into a css into a webgl scene , i though you did all the canvas and environment in css as well , it works super well !

@mrdoob mrdoob merged commit 4384903 into dev Sep 3, 2025
8 checks passed
@whatisor

whatisor commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Demo looks awesome! Just curious why it stops working since the 3rd layer
image

@mrdoob

mrdoob commented Sep 4, 2025

Copy link
Copy Markdown
Owner Author

Not sure! Just asked Twitter about it.

@mrdoob mrdoob deleted the css3d branch September 4, 2025 04:24
@mrdoob

mrdoob commented Sep 4, 2025

Copy link
Copy Markdown
Owner Author

And... here's the answer.

@mrdoob

mrdoob commented Sep 5, 2025

Copy link
Copy Markdown
Owner Author

Fixed.

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

Successfully merging this pull request may close these issues.

6 participants