Adjust the mesh position in THREE.js following the implementation of the EdgesHelper

Despite my attempt to rotate or reposition a mesh following the application of EdgesHelper, the desired effect is not achieved — the mesh remains in its original position. (Interestingly, it works perfectly fine without the EdgesHelper). What could be causing this issue?

var mesh = new THREE.Mesh( geometry, material );
var edges = new THREE.EdgesHelper( mesh, 0xcf0000 );

edges.position.z = 100;
edges.position.x = 100;

scene.add( edges );            

Answer №1

Upon examination of the source code for THREE.EdgesHelper, it appears that the matrixAutoUpdate parameter is configured as false. This configuration prevents the recalculation of position and rotation with each update.

Link to EdgesHelper Source Code

To resolve this issue, toggling the matrixAutoUpdate setting to true should suffice. However, a cleaner approach would be to invoke the .updateMatrix() function after adjusting the position or rotation.

Answer №2

Encountering a similar issue, I decided to implement the following solution:

        egh.matrixAutoUpdate = true;

To ensure both the edge and cube aligned with my coordinates, I utilized:

        var cube = new THREE.Mesh( new THREE.CubeGeometry(width,height,depth), 
                        new THREE.MeshBasicMaterial( {color: 0x00AA00, side:THREE.DoubleSide, opacity: 0.5, transparent: true } ) );
        scene.add(cube);

        var egh = new THREE.EdgesHelper(cube, 0x777777);
        egh.material.linewidth = 1;
        egh.position.x = cube.position.x;
        egh.position.y = cube.position.y;
        egh.position.z = cube.position.z;
        egh.matrixAutoUpdate = true; // this was effective
        scene.add(egh);

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

Retrieve any webpage using AJAX

Hey there! I'm a beginner in AJAX and have a question that may seem basic to some. I understand that you can set up a page to respond to an AJAX call, but is it possible to request any page with AJAX? In other words, can all the functionalities of a ...

Following the same occurrence using varying mouse clicks

I am currently exploring the most effective method for tracking file downloads (specifically, pdf files) on my website using Google Analytics (UA). I understand that by utilizing <a href="book.pdf" onClick="ga('send','event','P ...

What is the best way to reach a link using Selenium?

Challenge : Unable to interact with a link using JavaScript through Selenium. Attempted Solutions: element = driver.find_element_by_css_selector(a {href: "javascript:void(0)"}) resulted in a SyntaxError. element = driver.execute_script("ja ...

Element numbering in Internet Explorer 9 now positioned towards the right bottom corner

Whenever I reload the page, the numbering in the li elements seems to shift towards the bottom-right only in IE9, while it displays correctly on other browsers like Firefox and Chrome. Should I implement a specific fix for IE or have I made an error in my ...

Separating Main Page Content from Sidebar for Independent Scrolling

In the layout of our website, there is a narrow column on the left containing menu options, while the right side is occupied by the main page content. The challenge I am facing is figuring out how to ensure that the page content can scroll independently ...

Why isn't the Full Calendar loading automatically within a Bootstrap Tab?

I have been working on a travel website and incorporated a bootstrap tab feature. In the first tab, I have some content, while in the second tab, I've added a full calendar with JavaScript. Everything seems to be functioning correctly when the full ca ...

The functionality to deselect multiple options in a select box is not functioning properly

There seems to be an issue with removing the selected attribute from the selected values in a jQuery multiselect box. The console is not showing any errors. You can view a working example here The problem lies in this code snippet: $("#mltyslct option ...

Encountering an issue with React where the useContext hook is returning undefined instead of

I am facing an issue where I am attempting to access state and setState from the Store file, but it returns as undefined. Can someone help me understand what is causing this problem and how I can resolve it? import React, {createContext, useState} from &ap ...

Creating dynamic images in JavaScript by assigning URL paths from string variables

Currently, I am utilizing JavaScript to parse through an XML file. One interesting aspect of the XML is that it contains URLs which link to images like this one: http://localhost/pic.jpg Throughout the parsing process, I am storing each URL as a string va ...

Choosing an element in Protractor based on an HTML attribute value that contains a specific text

Having trouble figuring out how to target an element that lacks a standard unique id or class. How can I locate this input element using Protractor? Please note that I am unable to use the ComboBoxInput_Default class because it is shared across multiple p ...

Incorporate an external script into your Vue.js application

Seeking to integrate a simple JavaScript script with an external link to the library into my Vue.js application, I have encountered the following: <script type="text/javascript" src="https://my_site/index.js"></script> <link rel="styleshee ...

The select2 ajax functionality encountered an error: Uncaught TypeError - Unable to access the 'context' property as it is undefined

Trying to make an AJAX request using the Select2 jQuery plugin. The query appears to be functioning properly, but the problem arises when ".context===undefined" is called on the "data" object: Uncaught TypeError: Cannot read property 'context' o ...

Getting a result from a Node.js function that includes a database query

Currently, I am diving into the world of Node.js and delving into working with MySQL connections. There is a particular function that should retrieve a set of rows from the database successfully. However, after retrieving these rows, I am unsure of how to ...

What is the best way to enhance the appearance of labels on my Google Maps using the Google Maps API?

I've created a map that pulls data points from a json file. I've successfully displayed an image as a marker and added a label, but I'm struggling with styling the label. How can I add style to the label without affecting the map or coordina ...

Verify the presence of an email in the database utilizing a custom express-validator for node, express, and mysql

//Endpoint to update the user's email address. apiRouter.post('/update-email', [ check('newEmail') .isEmail().withMessage('Please enter a valid email address') .custom(newEmail=> { db.query(`SELECT user ...

Several dropdowns causing issues with jQuery and Bootstrap functionality

Can anyone help me identify where I might be making a mistake? The issue is with my fee calculator that increments fees as the user progresses through the form. In this scenario, there is a checkbox that, when clicked, is supposed to display a div showing ...

Restrict a class to contain only functions that have a defined signature

Within my application, I have various classes dedicated to generating XML strings. Each of these classes contains specific methods that take input arguments and produce a string output. In order to enforce this structure and prevent the addition of methods ...

Can SailsJS be used exclusively for API processes?

Can SailsJS be used solely as an API? After downloading the Sails project, is it possible to exclude the views and focus only on utilizing Sails as an API? ...

What could be causing my default prop to not be transmitted to the child component in vuejs2?

Having trouble passing a default value to my Leaflet map child component before fetching the desired data from an API endpoint. I tried using country coordinates like latitude and longitude, but it's not working as expected. This is how I attempted t ...

Create a dynamic div element using Jquery that is generated based on text input

I am attempting to dynamically insert a div based on the text within the parent container. My HTML structure is as follows: <div class="listing_detail col-md-4"><strong>Living Room:</strong> Yes</div> <div class="listing_detail ...