Checkbox not working in Chrome [Version 101.0.4951.41 (Official Build) (64-bit)]

Update: It appears that the checkboxes in my project are not functioning correctly. Even when a standard checkbox was added to the HTML, it failed to respond to click events.

I am currently developing a dat.gui menu for my THREE.JS project.

You can find my project here: https://codesandbox.io/s/ray-test-km2wru?file=/src/World.js:5581-5741

Upon clicking the checkbox, the equation for the plane should change as shown on lines 144. I have observed that in Chrome, clicking the checkbox does not uncheck it. However, in Firefox, the checkbox successfully toggles the value of planeSpecs.waveXY to false.

  _createPlane() {
    // Dat.GUI controllers
    let planeSpecs = {
      scaler: 1,
      speed: 1,
      waveXY: true
    };
    let planeMat = new THREE.MeshStandardMaterial({
      color: 0x6d6e6d,
      side: THREE.DoubleSide,
      wireframe: true
    });

    // Creates a single plane with wireframe
    let planeGeo = new THREE.PlaneGeometry(25, 25, 200, 200);
    var plane = new THREE.Mesh(planeGeo, planeMat);
    const planeFolder = this._GUI.addFolder("Plane");
    // These scales work
    planeFolder.add(planeSpecs, "scaler", 1, 10);
    planeFolder.add(planeSpecs, "speed", 0.1, 25);


    // This checkbox code doesn't work:
    const waveXYController = this._GUI
      .add(planeSpecs, "waveXY")
      .listen()
      .onChange((newValue) => {
        console.log(newValue);
      });
    planeFolder.open();


    plane.position.y -= 3;
    plane.rotation.set(Math.PI / 2, 0, 0);

    // Animation for the plane
    plane.tick = (delta, elapsedTime) => {
      const { position } = planeGeo.attributes;
      for (let i = 0; i < position.count; i++) {
        let x = position.getX(i);
        let y = position.getY(i);
        let z = position.getZ(i);

        // Change the equation based on checkbox boolean
        z = planeSpecs.waveXY
          ? Math.sin(
              Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) +
                elapsedTime * planeSpecs.speed
            ) * planeSpecs.scaler
          : Math.sin(x + elapsedTime * planeSpecs.speed) * planeSpecs.scaler;
        position.setXYZ(i, x, y, z);
      }
      position.needsUpdate = true;
    };
    return plane;
  }

Based on my research, the method I used to include dat.gui seems to be correct:

I initially posted about this issue on the Three.JS forums, but upon discovering it is a browser-related problem, I decided to share it here instead:

Answer №1

The problem arose from the Orbit Controls plugin in THREE.JS library, which was attaching event listeners to the body element and causing issues with dat.gui's mouse input.

To resolve this issue, it is recommended that the second parameter for OrbitControls be a DOM element.
For example:

new OrbitControls(camera, renderer.domElement);

It should be noted that in the latest versions of three.js, this requirement is now mandatory.

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

Creating a nested object in React's handleChange method: a step-by-step guide

Hey there, I've been working on an onChange function called handleChange for a set of dynamically created inputs. This function receives the event and then performs the following actions: const handleChange = (e) => { const updatedValues = [...va ...

Locate the index and value of the item that has the most recent date

Exploring my API design const dataArr = [{ end_date: '2019-12-16' }, { end_date: '2018-12-16' }]; const latestEntry = dataArr.filter( /* Seeking the index of the item with the most recent date */ ); Interested in vanilla JavaScript ...

Why is it necessary to type in localhost in the address bar when using node.js and socket.io instead of simply opening the client.html file directly?

I am intrigued by this topic. My suspicion is that it may be related to the temporary file created by socket.io, but I'm struggling to fully understand it... ...

The results of an AJAX file upload operation

Currently, I am utilizing an AJAX File Uploader from the following link: The code I am using is as follows: function ajaxFileUpload() { $('input[type=file]').each(function () { if ($(this).val() == "") { return true; ...

Is there a way to capture the click event of a dynamically generated row within a panel?

Could you please advise on how to capture the click event of a row that is generated within a panel? I have successfully captured events for rows generated on a page using the , but now I need assistance with capturing events from rows within a panel. I c ...

Verifying the presence of an object in an array based on its value using TypeScript

Having the following dataset: roles = [ {roleId: "69801", role: "ADMIN"} {roleId: "69806", role: "SUPER_ADMIN"} {roleId: "69805", role: "RB"} {roleId: "69804", role: "PILOTE"} {roleId: "69808", role: "VENDEUR"} {roleId: "69807", role: "SUPER_RB"} ] The o ...

What is causing my Rails Controller to anticipate JSON when receiving the format.js call?

While trying to add a new Sale_Contact to my Rails app using a Bootstrap 3 modal and AJAX, I encountered a problem. Despite receiving a 200 OK code from the server and successfully adding the Object to the database, the lack of JSON being returned caused a ...

MUI: How can I resolve the issue of TextField not supporting the number type with maxLength restriction?

I am currently facing an issue with applying maxLength to the TextField component when the type is set to number. Here is my code snippet: const CustomTextField = ({ label, value, maxLength, required, disabled, handleChange, ha ...

The data is not being successfully transmitted to the controller method through the AJAX call

In my JavaScript file, I have the following code: $(document).ready(function () { $('#add-be-submit').click(function (event) { event.preventDefault(); $.ajax({ type: 'POST', url: '/snapdragon/blog/new&apos ...

Nested loops in JavaScript can be combined with promises to efficiently handle

I am facing a challenge in looping through an array that contains another array as one of the parameters. My goal is to iterate through this nested array according to specific requirements, and then execute a function once the parent loop is finished. Can ...

Error: $this.text is throwing a TypeError and is not working as a function

Upon examining the code below: var $this = $(this).children('div.submenu1').children('a.subtile')[0], title = $this.text(), name = $this.attr('node').val; An error is encountered: Uncaught TypeError: $this.text is not a fun ...

Effects of incorporating unnecessary packages on Vue.js performance

In my Vue.js component, I have imported the module useI18n from "vue-i18n" but have not utilized it anywhere within the component. Concerned about how this could affect performance, particularly in terms of bundle size and load times. Will importing a mod ...

Can an entire object be bound to a model in an Angular controller function?

In TypeScript, I have defined the following Interface: interface Person { Id: number; FirstName: string; LastName: string; Age: number; } Within a .html partial file, there is an Angular directive ng-submit="submit()" on a form element. A ...

Monitoring page reload with JavaScript

Here is an example of tabbed content: <div class="tab"> <button class="tablinks" onclick="openCity(event, 'NewYork')" id="defaultOpen">New York</button> <button class="tablinks" onclick="openCity(event, 'LosAngeles& ...

issue with duplicating DOM element using function

My situation is unique from the one described in this post. The code mentioned there is not functioning as expected when clicking the clone button. I have even provided a video explanation of how that code works. Unfortunately, I haven't received any ...

Grouping an array of dynamic objects by a property value in react js / javascript: A step-by-step guide

There is an object in the following format: [{"genericName":"genesName test","genericId":3,"code":"generics"},{"genericName":"genesName fhfghsd","genericId":8,"code": ...

How to utilize hbs variable in an external JavaScript file

Currently, I am utilizing hbs (express handlebars) to display a page. I am interested in retrieving some variables from chat.hbs and accessing them in an external file named chat.js on the client side. Server Side res.render('chat', {chatr ...

What is the process for creating a unit test case for a button's onClick event with Jest?

In my attempt to unit test the onClick event of a button in a component, I encountered some challenges. Specifically, I am unsure how to properly test the onClick event when it triggers a function like Add(value). App.js function App(){ const[value,set ...

Tips for combining Nuxt with Vue Cli 3

section: My current setup involves utilizing Nuxt.js to set up my Vue application. I'm curious if it's feasible to incorporate Nuxt into a Vue Cli 3 project in order to leverage the advantages of both platforms. Surprisingly, there doesn't ...

Tips for assigning a value to an Option element when the selection changes in JSP

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http- ...