Increase the thickness of a THREE.LineSegments to enhance its appearance

Currently, I'm working on enhancing the visualization of paths using Three.JS. Despite successfully incorporating numerous lines into the scene with the correct vertices and desired material, I am facing difficulty due to their lack of visibility. Is there a way to transform a line segment into a tube-like structure without the need to start anew or alter the type of geometry being utilized?

Apologies if my terminology is off, but essentially, I aim to convert a generated THREE.LineSegments() into a thicker 3D line. Below is an excerpt from my code:

var geo = new THREE.BufferGeometry();
geo.addAttribute('position', new THREE.BufferAttribute(new Float32Array(2*numTravelVertices), 3));
var travelVertices = geo.attributes.position.array;
var vertIndex = 0;
this.set('travelVertices', travelVertices);

<add vertex indicies for points on the path>

geo.rotateX(-Math.PI / 2);
var mat = new THREE.LineBasicMaterial({color: parseInt(this.get('travelColor')), transparent: false});
var lineSegments = new THREE.LineSegments(geo, new THREE.MultiMaterial([mat]));

Answer №1

To create thicker lines, adjust the linewidth parameter of the LineBasicMaterial:

material.linewidth = 4; // the default is 1

However, please note that this feature may not work on certain Windows platforms. An alternative solution is to utilize the third-party library THREE.MeshLine, which achieves thick line rendering by drawing a series of triangles.

While THREE.TubeGeometry can also be used, it may not offer the same level of performance as MeshLine.

Version: three.js r.82

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

What is the process for integrating this graph using highcharts?

Check out this link for more information on investment decision-making. There is a visually appealing graph and pie chart featured in the section about Investment Decision-Making in 2016. After noticing that it was created using Highcharts, I wanted to c ...

The function window.ethereum.addListener does not exist

I've encountered an issue with my listener: if (window.ethereum) { window.ethereum.addListener('accountsChanged', async () => { await doSomething(); }); } Strangely, some users are reporting an error: window.ethereum.addListener ...

What is the best way to store textarea information into a session using the jQuery AJAX post method in Codeigniter?

I am having trouble saving the text from a textarea to the Controller session using jQuery AJAX post method in Codeigniter Smarty. I am unable to save the data to the session. Can someone please provide me with guidance and a detailed example of how to ach ...

"Implementation of Google+ button causing the appearance of a horizontal scrollbar

Adding Facebook and Twitter sharing buttons was easy, but now I'm having trouble with Google+. No matter where I place the code on my page (using a Bootstrap grid), it always adds 2-3 pixels on the right side, creating a horizontal scrollbar: <div ...

Unable to load JSON data model

I have been working on loading a JSON model and displaying it on the canvas, but I am encountering an issue where nothing is being drawn on the screen. Even when I try to use an alert inside the loader.load callback, the alert never shows up because the ca ...

The 'Component' you are trying to use cannot be rendered as a JSX component in Next.js

Take a look at the code in _app.tsx: function MyApp({ Component, pageProps }: AppProps) { return <Component {...pageProps} /> } An error is popping up during the project build process: Type error: 'Component' cannot be used as a JSX comp ...

Extracting data from a JSON object using Angular

Recently, I've been delving into the world of AngularJS and encountered a hurdle with LocalStorage. After spending numerous hours trying to figure out how to save data locally, I believe I have finally got it working as intended. Now, my next challeng ...

Incorporating ZeroClipboard or ZClip (button for copying to clipboard) using JQuery's Ajax functionality

Seeking to implement a 'copy to clipboard' feature triggered by clicking. However, I am facing a challenge as this functionality needs to be integrated with other content loaded using Ajax. Many plugins that achieve the same use Flash to bypass ...

Is it possible for setting the height of a div container to disable clicks within the div

There is a peculiar issue I am facing. I have an input button within 3 nested divs, with the outermost one having the id "container". Strangely, when I specify the height of "container", the click events for inputs with ids "switch" and "next" do not work ...

This TypeScript error occurs when trying to assign a value of type 'null' to a parameter that expects a type of 'Error | PromiseLike<Error | undefined> | undefined'

Currently, I am making use of the Mobx Persist Store plugin which allows me to store MobX Store data locally. Although the documentation does not provide a TypeScript version, I made modifications to 2 lines of code (one in the readStore function and anot ...

Best way to convert a list to JSON in Django?

When it comes to graphing data with Google Charts using Javascript, I encountered a challenge of passing an array of data values. The structure of the array is straightforward, typically resembling: [["Plankton", 725], ["MrKrabs", 681], ["Spongebob", 671 ...

Using sinon.js version 1.10, jQuery version 2.1, and making synchronous requests

I have been attempting to simulate a server using sinon.js and calling it with jQuery.ajax, but I am facing issues getting it to work. Here is the code snippet: $(function() { var server = sinon.fakeServer.create(); server.respondWith('POST&apo ...

Combining audio files together with Node.JS

Edit: The initial question was deemed too broad, so I have simplified it to focus on one main query: How can I seamlessly play a sequence of audio files within a web page (specifically using React) without any gaps between each play? I have taken an aud ...

An unexpected 'u' token was encountered in the JSON data at the beginning while parsing with NextJS from the router.query

I have successfully passed data through the URL path from my main page to my quotes page component in NextJS 13. However, I encountered an error when trying to refresh the page. Quotes Page Component import React from 'react' import { useRouter ...

Using AppCtrl's variable in another controller

Consider the following HTML code snippet: <html ng-app ng-controller="AppCtrl"> <head> <script src="http://code.angularjs.org/1.0.6/angular.min.js"></script> <script src="script.js"></script> </head ...

In Firefox mobile, a fixed positioned element will move with the page until the scrolling comes to a halt

I am facing an issue with a CSS element set to position: fixed. While it works perfectly on desktop browsers, it behaves poorly on mobile browsers, especially Firefox. The main problem is that the fixed element scrolls along with the page and then abrupt ...

Each time the page is refreshed, the objects in Three.js load in varying positions due to the OBJMTLloader

My scene is populated with various objects: var objectInfo = [ {"objURL":"3D/Barrel/barrel.obj", "mtlURL":"3D/Barrel/barrel.mtl","xPOS":0,"yPOS":-2,"zPOS":-260,"xROT":0,"yROT":0,"zROT":0,"scaleX":0.6,"scaleY":0.6,"scaleZ":0.6}, {"objURL":"3D/Sofa/sofa.obj ...

What is the best way to prevent drag functionality in a block?

Is there a way to prevent dragging in the block? View the complete example <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(fu ...

React Hook Form: When Submitting, Transform Date Object into String Date within an Array

Below is the data I am working with: { status: "Reserved", label: "Note", title: "Login Fragment - Navigation component With Coroutine", shareWith: "", notification_method: "Every Morning", notification_method_specific_time: Sat ...

Converting N-API object to C++ basic data types through reading

I've been working on a N-API module by customizing the ObjectWrap boilerplate provided in generator-napi-module. So far, I have successfully passed an array containing objects with string, number, and boolean properties from native C++ code to JavaScr ...