At times, 3D lines have a tendency to vanish

I am working on creating a 3D line chart using data.

If you'd like to see it in action, check out this Demo.

Here is the specific section of code that generates the lines:

     parentTransform = new THREE.Object3D();
            var _color = d3.scale.category10();
            for (var i = 5; i > 0; i--) {
                var material = new THREE.LineBasicMaterial({
                    color: _color(i), linewidth: 50
                });
                var PI2 = Math.PI * 2;

                var geometry = new THREE.Geometry();
                var k = -10;
                    for (var j = 0; j < 80; j=j+10) {
                        var _x = j;
                        var _y = (Math.floor(Math.random() * (50 - 10 + 1)) + 10);
                        var _z = i*5;

                        geometry.vertices.push(new THREE.Vector3(_x,_y,_z));
                        var _point = new THREE.SphereGeometry(0.8);
                        var material = new THREE.MeshBasicMaterial( {color: _color(i)} );
                        var sphere = new THREE.Mesh( _point, material );
                        sphere.position.set(_x,_y,_z);
                        parentTransform.add( sphere );
                    };           
                var line = new THREE.Line(geometry, material);
                line.material.linewidth = 2;
                parentTransform.add(line);
            };
            scene.add( parentTransform );

Sometimes when I rotate or zoom, the lines disappear and only the points remain visible.

I also wanted to add three axis walls, any assistance would be greatly appreciated as I have experience with d3.js but I'm new to Three.js.

Answer №1

Two instances of the variable material are being declared, causing you to unintentionally pass MeshBasicMaterial instead of LineBasicMaterial to the THREE.Line constructor.

This issue is specific to version r.71 of three.js.

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

Utilize a personalized hyperlink to encase an Instagram embed

I'm currently trying to display a list of Instagram embeds, but I'd like users to be able to visit a display page before being directed to the actual Instagram embed page. My idea is to enclose each Instagram embed within a hyperlink for this pu ...

Exploring the capabilities of the Vuejs EventBus

I've been struggling with this issue for quite some time now, but I just can't seem to get it right! I've looked at various examples online, but none of them seem to solve the problem. Every time I run my test, I keep getting this error: Ex ...

Execute and generate a continuous loop in JavaScript

I successfully implemented an image slider using pure PHP, but encountered issues when integrating it into Yii framework. The images were not loading due to the following reasons: - JavaScript block was not loading image numbers. - I am unsure how to load ...

Maintaining a security token across multiple requests

A prototype application is being developed with the following features: An HTML website integrated with knockoutjs Communication with Web API services using jQuery/Ajax The goal is to restrict access to services only to authorized users. Security measur ...

Analyzing a JSON Structure Containing Numerous Sub-Objects

<script type="text/javascript" src="http://static.stackmob.com/js/2.5.3-crypto-sha1-hmac.js"></script> <script type="text/javascript"> $j.ajax({ dataType : 'json', url : "/api/core/v2/groups/", //or any other res ...

How can you switch between CSS styles using JQuery?

Is there a way to change CSS properties every time I click using jQuery? I couldn't find any information on this specific topic. Can someone guide me on how to achieve this with jQuery? I want the background color to change each time it is clicked. W ...

Vue.js video player component displays at a width of 100 pixels

I recently started implementing the vue-video-player library into my project. However, I'm facing an issue where the player renders at a width of only 100px. I'm not sure why this is happening or how to adjust it. After going through the documen ...

Encountering an issue in my Next.js application with the app router where I am unable to read properties of undefined, specifically in relation to '

As I develop a basic Rest API in Next.js, my goal is to display "Hello world" in the console for a post api. export const POST = (req: Request) => { console.log('hello world'); }; The error message that appears in my terminal is as follows: ...

Retrieve the text content and identification value from each list item

I've found myself in a frustrating situation where I have an unordered list structured like this: var liList = $("#first").find("li"); var append = ""; for(var i =0; i< liList.length; i++){ var item = $(liList); append += "<option value ...

I am experiencing a problem with using the .focus() method with an input field

When my window loads, I want the cursor in this input to be blinking and ready for typing. I have tried using jQuery to make this happen, but for some reason I can't get the .focus() function to work properly. Check out my code on JSFiddle This is t ...

Tips for positioning a grid at the center of a MaterialUI layout

I am struggling to position 3 paper elements in the center of both the vertical and horizontal axes on the screen. Despite applying various CSS rules and properties, the height of the HTML element consistently shows as 76 pixels when inspected in the con ...

Trouble encountered when using RxJS zip and pipe together

In my Angular Resolver, I am facing a scenario where I need to wait for two server calls. The catch is that the second server call is optional and can be skipped based on user input. This data retrieval process is crucial for loading the next page seamless ...

Tips for saving data after reading lines in Node.js

I am working on a project where I need to read data from an external text file into my function. How can I efficiently store each line of the file as a separate variable? const fs = require("fs"); const readline = require("readline"); const firstVariable ...

The data from req.body is mysteriously missing from Postman

When sending the post request, I used raw and json format... Here is the header configuration This is the code: //app.js const port = process.env.PORT || 3000; const express = require ('express'); const app = express(); const jsonParser = re ...

The array containing JSON objects enclosed within curly braces is causing a syntax error

Given a variable containing data that looks like an "array" with JSON Objects inside (even though it is not actually formatted as an array, starting and ending with curly braces): {"x1","x2"},{"y1","y2"},{"z1","z2"} How can I transform this so that the i ...

Angular directive ng-template serves as a component type

In the code snippet below, <!DOCTYPE html> <html> <head> ..... </head> <body ng-app="app"> <script type="text/ng-template" id="my-info-msg.html"> <s ...

JavaScript is experiencing an error where it cannot define a function, rendering it unable to generate a JSON object due to its inability to recognize that the

I've created a JavaScript script function that holds cart items for ordering food. This function takes two parameters: ID and price. Here is a snippet of my script file: <script> function addtocart(mitem, mprice) { var price = ...

Guide on how to refresh the 'id' after a set period using Ajax technology

I am having an issue with reloading/refreshing a specific table in order to fetch updated database information. The problem is that when I try to refresh only the table, the entire page reloads instead. However, I have managed to identify the 'id&apos ...

What factors contribute to a one-hour discrepancy between two time stamps, deviating from the anticipated value?

Let's consider the dates '2022-04-01' and '2022-05-15'. When I calculated their deviation using Chrome devtools, here are the results: https://i.stack.imgur.com/tSZvk.png The calculated result is 3801600000. However, when my frie ...

JXBrowser comparable

In a Java project of mine, I have been utilizing JXBrowser to showcase Google Maps for route tracing purposes. However, the license for JXBrowser has recently expired after just one month. Unfortunately, simply requesting another license is not an option ...