How to eliminate the yellow box in Three.JS when working with EdgesGeometry, LineSegments, and BoxHelper

Three.js Version: 82

I recently came across an interesting example on the official Three.js website:

In this example, I noticed the presence of yellow boxes surrounding the 3D models. Previously, in version 79, I used THREE.EdgesHelper to outline the 3D objects I created in Blender. However, in version 82, THREE.EdgesHelper was replaced by THREE.EdgesGeometry. I wanted to see a practical demonstration of this change, and the only example I found was the one mentioned above.

While exploring the properties of the line and BoxHelper objects, I couldn't find a solution to remove the yellow boxes.

For reference, here is the JSFiddle link: https://jsfiddle.net/4nbjvmpe/

Below is the code extracted from the JSFiddle:

HTML

<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>

CSS

body {
    background-color: #000;
    margin: 0px;
    overflow: hidden;
}

JavaScript

var mesh, renderer, scene, camera, controls;

init();
animate();

function init() {

    // renderer
    renderer = new THREE.WebGLRenderer();
    renderer.setSize( window.innerWidth, window.innerHeight );
    document.body.appendChild( renderer.domElement );

    // scene
    scene = new THREE.Scene();

    // camera
    camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
    camera.position.set( 20, 20, 20 );

    // controls
    controls = new THREE.OrbitControls( camera );

    // ambient
    scene.add( new THREE.AmbientLight( 0x222222 ) );

    // light
    var light = new THREE.DirectionalLight( 0xffffff, 1 );
    light.position.set( 20, 20, 0 );
    scene.add( light );

    // geometry
    var geometry = new THREE.SphereGeometry( 5, 12, 8 );

    // material
    var material = new THREE.MeshPhongMaterial( {
        color: 0x00ffff, 
        shading: THREE.FlatShading,
        transparent: true,
        opacity: 0.7,
    } );

    // mesh
    mesh = new THREE.Mesh( geometry, material );
    scene.add( mesh );

    // CUSTOM
    // Creation of the outline mesh
    var group = new THREE.Group();
    scene.add( group );
    group.updateMatrixWorld(true);
    var edges = new THREE.EdgesGeometry(geometry);
    var line = new THREE.LineSegments(edges);
    group.add(line);
    line.material.depthTest = true;
    line.material.opacity = 0.25;
    line.material.transparent = false;
    this.outlineMesh = new THREE.BoxHelper(line);
    scene.add(this.outlineMesh);
}

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

Answer №1

If you want to achieve the desired outcome, all you have to do is remove the line

this.outlineMesh = new THREE.BoxHelper(line);
and scene.add(this.outlineMesh); in the code snippet.

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

Waiting in iOS UI Automation for the web view to be prepared and displayed

In my quest to develop an iOS UI Automation javascript with Instruments for automating the process of taking a screenshot in my iOS app, I have turned to the handy tool known as Snapshot. A crucial part of my app involves a webview, and I am keen on captu ...

Using the oidc-client library in Angular to create a customized isLoggedIn() function within *ngIf implementation

Objective: I'm trying to toggle the visibility of a Login and Logout button in an Angular application using IdentityServer4 and OIDC client. Issue: The isLoggedIn function in my code returns undefined before it returns true, causing the *ngIf directi ...

Finding differences between two 24-hour format times using moment.js

Is there a way to compare two times in 24-hour format using the code below? $("#dd_start_timing, #dd_end_timing").on('keyup change keydown', function() { var DutyDayStartTime = $("#dd_start_timing").val().trim();// 13:05 var ...

In JavaScript, when a div element contains an iframe, the click event will not trigger on the div

Check out this sample HTML markup: <div> <iframe></iframe> </div> The iframe is set to fill the outer div. I've added an event handler to the div click event: div.addEventListener("click", function () { console.log( ...

Develop an outline using D3.js for the clipath shape

After successfully creating a shape with a color gradient, I encountered the need for further customization. If you are interested in this topic, check out these related questions: Add multi color gradient for different points in d3.js d3.js scatter plot c ...

Why is it that my website in React crashes when I type rapidly in the TextField component?

Whenever I input text quickly into the TextField in my app, it causes my website to crash and display a blank white screen. Below is the snippet of code causing the problem: TextField Code: <TextField label="Item name" ...

Transferring the bundle files of one Next.js app to another Next.js app

Currently, I manage two distinct Next.js applications that handle separate sets of routes. Additionally, I have developed a custom Next.js server that determines which page to display based on the requested URL. I am interested in utilizing the custom ser ...

Seamless transition of lightbox fading in and out

Looking to create a smooth fade in and out effect for my lightbox using CSS and a bit of JavaScript. I've managed to achieve the fading in part, but now I'm wondering how to make it fade out as well. Here is the CSS code: @-webkit-keyframes Fad ...

Ways to retrieve the identifiers of every child node UL element within a UL container

I am struggling with a basic question related to HTML structure. Here is the code snippet I am working with: <ul> <li> <ul class=t2 id=15> <li class='item'>a<span class='val'>b</ ...

Focus automatically on an input component when the value in the Vuex store is updated in Vue

Here's the code snippet from my component: //template <v-select ref='ItemSearchSelect' :options="options"></v-select> ... //script created: function () { this.$store.subscribe((setFocusSearch, state) => { ...

Opacity cannot be adjusted after upgrading to Three.js version r55 from r52

I am currently in the process of upgrading my application from version r52 to r55. The app utilizes animations (Tweens) for updating lines and also a ParticleSystem. Everything functioned perfectly in r52, with smooth scaling, movement, and opacity changes ...

Issue with jQuery select box (roblaplaca) and its custom scroll bar functionality not functioning as expected

Recently, I implemented the custom select box script from . This script allows for two select boxes, where the second one updates dynamically using AJAX when there is a change in the first select box. Below is a sample of the HTML code: <option>One& ...

Three.js: It seems that THREE.WebGLRenderer detected the image is not a power of two, originally sized at 1600x900. It was resized to 102

As I dive into learning three.js, one of my goals is to incorporate a 16x9 photo into my scene. Below is the snippet of code where I add an Array of images to my scene: const material = new MeshBasicMaterial({ map: loader.load(images[i]), trans ...

Is there a way to detect and handle errors triggered by a callback function?

My component has the following code snippet: this.loginService.login(this.user, () => { this.router.navigateByUrl('/'); }); Additionally, my service contains this method: login(credentials, callback) { co ...

Having difficulties with Vue components displaying in Laravel's blade.php file

Let me share my current setup with you: This is the main "Welcome.blade.php" file where I have included relevant information as the file is quite lengthy: <div id='app'> <router-view></router-view> </div> <script src ...

The v-for directive on a reactive Vuejs array is failing to render its elements

After much searching, I have identified the error and provided a brief explanation in the following paragraph. The code below resolves the error by changing the approach of the code rather than fixing the error itself. By defining the indexes of the array ...

Dealing with Unreliable Data in Scatter Plots using React and HighCharts

Initially, I utilized line charts for my data visualization needs. However, I now require multiple data points on the same X-Axis with tooltips, which has led me to discover HighCharts behavior: "In a line chart, by default, Highcharts will display t ...

Conceal the current component prior to displaying the component associated with Navlink in React Router

Currently, I am in the process of developing a single-page web application using React routing. My goal is to hide the current component before rendering the next component when a NavLink is clicked, similar to how <a href="someLink"> works in HTML. ...

Troubleshooting Timeout Problems with Selebiun Crawler in C#

I am encountering an error while running the following code. public void GetCategoriesSelenium() { string javascript = System.IO.File.ReadAllText(@"GetCategory.js"); CrawlerWebSeleniumJS.ExecuteScript("var finished;"); ...

Twitter typeahead with a dynamic array of strings

Currently, I am making an ajax call to retrieve a list of objects. Once this array of objects is filled, a separate string[] is created with the names of these objects. My goal is to pass this data to Twitter Typeahead using a Bloodhound source. However, ...