What are the solutions for resolving overlay problems within three.js?

I am attempting to display an iframe using the CSS3DRenderer from three.js within Angular.

However, I am encountering an issue where I cannot interact with any content (no pointer events).

It appears that the problem lies in the overlapping webgl <div id="webgl">.

When I switch the order of the two divs <div id="css3d"> and <div id="webgl">, the CSS3DObject covers the other content and is not attached to the desired rendering box.

Order:
<div id="css3d">
<div id="webgl">

https://i.sstatic.net/KLgOW.png

Order:
<div id="webgl">
<div id="css3d">

https://i.sstatic.net/Ng2Xe.png

This is how I initialize the CSS3DRenderer:

private _init3DRenderer()
    {
        this._3DRenderer = new CSS3DRenderer();
        this._3DRenderer.setSize(this.css3dContainer.nativeElement.clientWidth, this.css3dContainer.nativeElement.clientHeight);
        this.css3dContainer.nativeElement.appendChild(this._3DRenderer.domElement);
    }

Additionally, I am initializing the WebGLRenderer as follows:

private _initRenderer()
    {
        this._renderer = new WebGLRenderer({ alpha: true, antialias: true });
        this._renderer.setPixelRatio(window.devicePixelRatio);
        this._renderer.setSize(this.webglContainer.nativeElement.clientWidth, this.webglContainer.nativeElement.clientHeight);
        this._renderer.outputEncoding = sRGBEncoding;
        this._renderer.shadowMap.enabled = true;
        this._renderer.shadowMap.type = PCFSoftShadowMap;
        this.webglContainer.nativeElement.appendChild(this._renderer.domElement);
    }

After initialization, I add an object to both the WebG and the iframe.

        const obj = new Object3D();
        let css3dObject = new CSS3DObject(iframe);
        obj.add(css3dObject)


        // create an invisible plane for the DOM element to clip
        // a WebGL geometry.
        var material = new MeshPhongMaterial({
            opacity: 0.1,
            color: new Color(0x000001),
            blending: NoBlending,
            side: DoubleSide,
        });
        var geometry = new BoxGeometry(width, height, 30);
        var mesh = new Mesh(geometry, material);
        mesh.receiveShadow = true;
        obj.add(mesh);

The different renderers share the same scene:

private _render()
    {
        this._renderer?.render(this._scene, this._camera);
        this._3DRenderer?.render(this._scene, this._camera);
    }

HTML template:

<div (window:resize)="onWindowResize($event)"
     #webglContainer
     style="width: 100%; height: 100%; position: absolute;">
</div>
<div #css3dContainer
     style="width: 100%; height: 100%; position: absolute; left: 0; top: 0;">
</div>

Answer №1

I encountered a similar issue. Below is the CSS code for the webgl div:

    pointer-events: none;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to successfully transfer both the event and props together?

For simplifying my code, I created a function that triggers another desired function when the Enter key is pressed. Here's an example of how it works: const handleKeyDown = (event) => { if (event.key === 'Enter') { event.preventDefa ...

How can I send a parameter to an image's onclick event in C# MVC?

Is there a way to pass a parameter to the image onclick event directly in the view? I already know how to do it using a script and the controller, but I'm curious if there's a more direct method. I've spent some time searching on SO and atte ...

Feeling overwhelmed by the potential capabilities of Angular Firestore

Seeking clarification as I am struggling to understand the usage of Angular and Firestore. Recently delved into Google Firebase and attempted CRUD operations with Firestore. What sets apart this library from others? import { Firestore } from '@angul ...

iOS nested elements: surrounding edges reveal parent's background

When viewing nested elements on iDevices, the parent's background is visible, creating a border or outline that is consistent across browsers (tested on Chrome and Safari). It has a similar effect to a bleed in printing. Can someone provide assistance ...

Vue axios encountered a problem: Uncaught (in promise) Error: The request was unsuccessful and returned a status code of

Hey there, I hope everyone is doing great! I encountered an issue with my Vue Axios setup. Uncaught (in promise) Error: Request failed with status code 415 Sharing my code snippet below: authService.Login(user) .then(resp => { ...

Having trouble locating an element in Selenium Chrome using JavaScript

I'm automating a webpage using JavaScript and selenium, which involves clicking on several buttons. To start off, my code establishes a connection with the existing chrome window in the following way: var chrome = require("selenium-webdriver/chro ...

Compile an ASP.NET website into static files such as HTML, CSS, and JavaScript prior to deployment

Can a simple ASP.NET website without ASP webform or .NET controls be precompiled into static files such as HTML, CSS, and JavaScript? I am interested in utilizing the master page feature and Visual Studio IDE intellisense while still being able to deploy ...

Performing three consecutive Ajax requests in a Rails application

Recently, I developed a custom admin system for a local gym to manage payments, attendance, mailing, sales, and more. While everything is functioning smoothly, there seems to be an issue with the attendance feature. Occasionally, when taking attendance, an ...

Even with the implementation of ng-cloak in AngularJS, the footer template continues to blink

I have successfully implemented and displayed templates with data retrieved from a REST service using AngularJS. However, I am facing an issue where the footer template briefly appears at the top of the page while the JSON response is still loading, and th ...

Tips on automatically centering an image within a div as it is resized

I'm currently working on a website that showcases cards featuring Discord users. Each card includes an avatar image within a div element, and when the user hovers over it, the image expands. However, I've noticed that as it expands, it shifts to ...

A guide on modifying the HTML code of a browser element using Python's Selenium

Does anyone have tips on how to edit the HTML code of a browser element using Selenium? I've been struggling to find a solution. Any advice would be greatly appreciated! ...

Determine the length of audio files in a Node.js backend

Currently, I am facing a challenge in calculating the duration or length of an audio file. The process involves uploading the audio file to S3 and then retrieving it in lambda for processing. Despite utilizing a library, I have encountered limitations in ...

Calling an ajax request to view a JSON pyramid structure

My experience with ajax is limited, so I would appreciate detailed answers. I have a Pyramid application where I need to load information via ajax instead of pre-loading it due to feasibility issues. I want to retrieve the necessary information through a ...

Storing POST data securely for a temporary period of time

After retrieving a list of products from a database, everything seems to be functioning properly. However, I am facing an issue when trying to capture the ID when a user clicks on the 'Buy' button. Despite multiple attempts to save the req.body d ...

Effect triggered upon scrolling to the top or bottom of the page

Would greatly appreciate your help in identifying errors in my script. Can someone point out where I might be going wrong? I am using two plugins - the first for custom scrollbar changes, and the second which I have cut and pasted into the first call. Bel ...

Deleting an object with javascript in django: A step-by-step guide

Is there a way to use JavaScript to create a confirmation window before deleting an item? <div class="card-footer"> <a href="{% url 'course_delete' student.slug %}"><button>Delete</button>&l ...

The command `sequelize.sync({force:true}) is running into issues and the log output is coming up empty

I encountered a multitude of questions while working on this particular issue. None of them seemed to have the same problem, and after 20 straight hours of trying to solve it, I'm feeling quite stressed. So, I apologize if I missed a similar issue. Th ...

Using the same ng-model to show distinct values in two separate input fields

I have a form with a dropdown list that loads data using the ng-model="placeid". When a user selects an option from the dropdown, I want to display the selected place's latitude (place.lat) in an input box. Here is the dropdown list code: <select ...

What could be causing the background of the wrapper image not to display?

I am looking to add a background image specifically within the wrapper div on my website. Below is the HTML document: <!DOCTYPE html> <html lang="en"> <head> <meta charset="<?php bloginfo('charset'); ?>"> &l ...

Sending data from one JavaScript file to another (a unique scenario)

I am facing an issue with passing a Javascript variable from one file to another within a Jquery document function. chat.js $(document).ready(function () { var a = "something" } to scripts.js $(document).ready(function () { console.log(a); //g ...