Preventing default action within a passive event listener is not possible because the target is considered passive. This issue is particularly relevant with Three.js Track

I'm currently developing a 3D application using Three.js. One of the key components in this project is implementing a control system for the camera, which I have achieved using TrackballControls. However, as I tried to add an event listener, I encountered a strange error:

Unable to preventDefault inside passive event listener due to target being treated as passive.
. This error message includes a link to more information on the issue from this chromium website

While I understand the cause of the error, I am wondering if there are any workarounds to address this issue. The error seems to be originating from the line of code that reads: event.preventDefault();

Here's a snippet of the relevant code:

var control = new THREE.TrackballControls(camera);
control.addEventListener("change", render);

function render() {
    renderer.render(scene, camera);
}

function update() {
    renderer.render(scene, camera);
    control.update();
    requestAnimationFrame(update);
}

If anyone has encountered this issue before and has found a solution, I would greatly appreciate your assistance. Thank you in advance!

Answer №1

This notification serves as a precautionary measure. It poses no threat to the functionality of the web application.

However, it may be considered bothersome. To disable this alert, follow these steps:

Instead of utilizing the following code:

control.addEventListener("change", render);

insert the following snippet instead:

control.addEventListener("change", render, { passive: false });

Answer №2

Initializing a new instance of THREE.TrackballControls by passing in the camera as an argument:

It is recommended to create TrackballControls using the following syntax:

var control = new THREE.TrackballControls(camera, renderer.domElement);

A recent pull request has been submitted which will make the second parameter of TrackballControls mandatory and disallow the use of document as an argument.

View the PR here

three.js R109

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

Executing Grunt: Setting up a dual Connect and Express server to operate on one port

I'm still fairly new to Grunt and I've been wondering if it's possible to run both servers on the same port simultaneously. I seem to be encountering some issues with this setup, most likely stemming from the Grunt file. I am utilizing grun ...

Selenium Webdriver failing to select menuitem using text, xpath, or ID

Currently, I have some HTML code embedded in a SharePoint page that appears as follows: <span style="display:none"> <menu type='ServerMenu' id="zz28_RptControls" largeIconMode="true"> <ie:menuitem id="zz29_AddColumn" type="optio ...

You are unable to access the array beyond the scope of the function

I am encountering an issue with a function I wrote: function gotData(data){ result = data.val() const urls = Object.keys(result) .filter(key => result[key].last_res > 5) .map(key => ({url: 's/price/ ...

Using onclick events, manipulating innerHTML, and dynamically generating tables

Below is the code snippet: window.onload=function(e){ //Created by Firestar001 var X; var Y; var board=""; var rizzalt=document.getElementById("rezzalt"); var letters = new Array; letters = ["A","B","C","D","E","F","G","H","I","J"]; for(a=0; a<=9 ...

JavaScript code to place variables into an array with included variables

Looking for a solution: const myArray = [] myArray.push( { "bob" : { "banana" : "yellow" } }) console.log(myArray) Output: { "bob": { "banana": "yellow" } } Attempting a modifi ...

Creating Typescript types based on the values of other props: A guide

Can the TypeScript prop type be dynamically changed based on the runtime value of another prop? For instance type MyComponent = { propA: boolean | string propB: typeof propA boolean ? number : string } Is it feasible to determine the prop type of p ...

connect a column from a separate array in pdfmake

In my current project, I am looking to link the values of an array that is different from the one present in the initial two columns. Is this achievable? (The number of partialPrice values aligns with the number of code entries). Despite several attempts ...

How can you convert all nodes of a nested JSON tree into class instances in Angular 2 using Typescript?

I have a Leaf class that I want to use to convert all nodes in a JSON response into instances of Leaf. The structure of the JSON response is as follows: JSON Response { "name":"animal", "state":false, "children":[ { "name" ...

How to access elements in every document fragment

I am facing an issue with a page that contains multiple document fragments. I need to retrieve all elements from the entire page that match a specific selector, like so. document.querySelectorAll('iframe') However, this does not return elements ...

Executing NodeJS custom middleware to show parent function being called

Goal: Showcase the parent function of a middleware function shared = require('./RoutFuctions'); app.post('/link', shared.verifyToken, (req, res) => { ... } In the middleware function exports.verifyToken = functio ...

Playing out the REST endpoint in ExpressJS simulation

Suppose I have set up the following endpoints in my ExpressJS configuration file server.js: // Generic app.post('/mycontext/:_version/:_controller/:_file', (req, res) => { const {_version,_controller,_file} = req.params; const ...

Error: Attempts to access the 'avatar' property of a null value result in a TypeError

I've been attempting to showcase both an avatar and the user name, but I keep encountering this error. Despite trying to declare a user variable to troubleshoot, it's not resolving the issue. Error: Cannot read property 'avatar' of n ...

Preserving the initial input values in a secure manner for future reference, utilizing either an object or a

Recently, I've started revisiting a script I created a while back that checks for changes in a form to prompt a message asking 'Would you like to save your changes?'... One thing that's been on my mind is whether I should store the ori ...

Issue with callback function not triggering after comment deletion in REACT

Although I am successfully able to delete the comment, I am facing an issue where the callback function is not being invoked. My suspicion is that it might be related to how I pass multiple arguments to the function, but I cannot confirm this. Below is th ...

Using Typescript and ThreeJS, include new elements to the environment within the loader

Can someone help me with the following code snippet? export class LandingPageComponent implements OnInit { scene: THREE.Scene; (...) ngOnInit() { this.scene = new THREE.Scene(); var loader = new THREE.JSONLoader(); loader.load("../../assets/fire_lion.j ...

The act of exporting an enum from a user-defined TypeScript path leads to the error message "Module not

I have set up a custom path as explained in this particular discussion. "baseUrl": ".", "paths": { "@library/*": [ "./src/myFolder/*" ], } Within this module, I am exporting an Enum. export enum EN ...

Unable to retrieve the parent element using jQuery

I am facing an issue with my html structure that is generated dynamically through a foreach loop. I have attempted to remove the entire <a> element by accessing it from its ACTIVE HYPERLINK. However, all my efforts seem to be in vain as I am unable t ...

After using res.redirect(`/relative/url`), I encountered a PATCH 404 Not Found response. Any suggestions on resolving this issue?

Issue: I have encountered a problem while trying to update a document saved on MongoDB. I used the following code snippet for updating the document: Blog.findByIdAndUpdate(req.body.id, { 'status': req.body.status }). The updating part works perfe ...

Dealing with errors in a sequelize ORM query: Tips and tricks

Currently, I am implementing Sequelize ORM in my Node/Express project using Typescript. Within the database, there is a 'users' table with a unique column for 'email'. As part of my development process, I am creating a signIn API and ...

I am currently dedicated to enhancing my background transitions and experimenting with creating smooth fade-ins

I'm almost done with my Weather Forecast page for the FCC challenge. However, I'm not satisfied with how the code for swapping the background works. It just doesn't feel right to me. Unfortunately, I can't figure out how to fix it. Addi ...