When stacking multiple geometries and utilizing EdgesHelper, edges may be inadvertently omitted

Having just started experimenting with three.js, I'm not entirely sure if I've made an error in my approach.

You can view my demo here (use the left and right arrow keys to navigate):

The issue I'm facing is that the "inner edges" are not visible: https://i.sstatic.net/i01fE.png

My goal is to create a "blocky" aesthetic using solid shapes with highlighted borders.

  • So far, the most effective method I've discovered is utilizing BoxGeometry with a basic material and applying the outline with EdgesHelper.
  • The shape parameter simply consists of a series of coordinates.
  • I am uncertain about merging the resulting meshes together as I've been doing (this allows for easy removal from the scene later on and hasn't caused any issues thus far).

Below is the code snippet:

function draw_shape(shape, offset, colour) {
        var mesh = new THREE.Mesh();
        for (var i = 0; i < shape.length; i++) {
            var geometry = new THREE.BoxGeometry(BLOCKSIZE, BLOCKSIZE, BLOCKSIZE);
            var material = new THREE.MeshBasicMaterial({ color: colour });
            var tmp = new THREE.Mesh(geometry, material);
            tmp.position.x = shape[i][0] * BLOCKSIZE - offset[0];
            tmp.position.y = shape[i][1] * BLOCKSIZE - offset[1];
            tmp.position.z = shape[i][2] * BLOCKSIZE - offset[2];
            mesh.add(tmp)
            var outline = new THREE.EdgesHelper(tmp, 0x000000);
            outline.material.linewidth = 2;
            mesh.add(outline);
        }
        return mesh;
}

Thank you in advance for any assistance!

Answer №1

So here's my solution:

let cuboid = new THREE.BoxGeometry(BLOCKSIZE - 1, BLOCKSIZE - 1, BLOCKSIZE - 1);

By reducing the box dimensions by 1 unit each, I created a slight gap between them. Initially, this made the layout look unappealing due to the noticeable gap.

However, upon revisiting this approach, I decided to increase the BLOCKSIZE significantly while simultaneously adjusting the camera position accordingly (i.e., increasing BLOCKSIZE from 30 to 90 and moving the camera from approximately 200 to 600).

The outcome proved to be much more visually pleasing.

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

Display title upon hovering over image linked to mysql with php

Is there a way to display the image title when hovering over images connected to MySQL using PHP? Below is the code I have been using: <div class="galleryko"> <?php $data = mysql_query("SELECT * FROM tbl_gallery_featured")?> <div clas ...

What is the best way to trigger a flash animation on the front end?

CODE: login.ejs <script> req.flash('success_msg', 'You have logged in'); </script> header.ejs <div class = "alertMessage"> <% if (success_msg != false){ %> <span class="alert alert-success ...

Combining shapes in three.js

I've encountered a scenario where my scene consists of multiple meshes, each with different shapes and sizes. By looping through each mesh and utilizing geometry.merge(), I successfully created a new mesh from the geometries in the scene. The challe ...

I recently developed a T3 stack project and am currently attempting to configure a next JS middleware, however, I am encountering issues with it not triggering as expected

Having issues with my T3 stack app where the next js middleware is not triggering. I've placed a middelware.ts file in the root directory. middleware.ts // middleware.ts import { NextResponse } from "next/server"; import type { NextRequest ...

I'm experiencing a roadblock due to ng-submit not functioning as expected, failing to execute when clicked

I'm currently enrolled in an online course and I've hit a roadblock with one of my assignments. The assignment involves a form with a submit button that triggers certain code upon clicking. However, when I click the submit button, the code doesn& ...

Encountering Errors with Multiple Controllers in my Angular JS App

As a beginner in Angular JS, I understand that the declaration below is necessary in the js file to make angular JS Controller work: var app = angular.module('myApp', []); app.controller('ctrlOne', function(){ }); However, I recently ...

In Javascript, when declaring a variable, check if a field is filled and assign its value if so; otherwise, set a default value

In the code snippet below, there are some rows with a nested field value present and some without. I am attempting to assign a value if the field is present, otherwise I want to set it as 'false'. Despite using the double pipe operator to handle ...

Chrome Browser: Issue with CSS and JavaScript transitions not functioning correctly

I have three images named img1, img2, and img3. Initially, their position is set to -50% absolute top right and left. When I change the position to static with a transition of 2s, they should move to the center. Issue: During the transition, there is snap ...

Assign a title property in Vuejs only if the returned data from binding evaluates to true

Just starting out with vuejs and I have a question. How can I set the title based on a value returned from a specific method only if this value is true? Below is my code snippet: <td v-bind="value = getName(id)" :title="value.age" > {{value.na ...

What is the best way to distinguish between my HTML form submission and my JavaScript form modification process?

I am facing a dilemma with the layout of my form and table on the webpage. The structure is as follows: +-------------------------------------------------+ | FORM | | +------------------------------------------- ...

When tab switching occurs, the alert box fails to be processed by the browser

When using the alert(message) function, it will display an alert box with a message and an OK button. It will also pause the execution of any code that follows until the OK button is clicked. However, I have noticed a peculiar situation where switching tab ...

Stop the infiltration of emotions into your style

Utilizing the JsonForms React Component to dynamically generate an HTML form in my web application. The framework I am using handles all view rendering on the server side. To integrate this component, I compiled a small react component by running npm run b ...

The long press event is not being detected in phonegap-android

There is an issue I am experiencing with phonegap-android. The functionality is such that when you touch on text *(on an html page)*, a plugin will be called and a dialog box will appear where you can enter some text. However, when I do a long click on ...

The type x cannot be assigned to the parameter '{ x: any; }'

Currently learning Angular and Typescript but encountering an error. It seems to be related to specifying the type, but I'm unsure of the exact issue. Still new at this, so any guidance is appreciated! src/app/shopping-list-new/shopping-edit/shopp ...

Unable to access array in the result of a Node.js Mongoose find populate operation

I have the following code in my backend: ad = await Ad.find({'company': companyId}).populate('creator'); When I console.log(ad), this is what I get: [ { connections: [], status: 1, _id: 6047c711b1f8cf1c98b2227c, title ...

Vue2 is not compatible with the vue-email-editor component

I checked out the official website to install the vue-email-editor. Here is the link for the unlayer vue-email-editor component However, I encountered the following error: vue.runtime.esm.js?c320:4573 [Vue warn]: Error in render: "TypeError: (0 , ...

Utilizing AJAX to retrieve data from a PHP function

Seeking to display the output of an AJAX call; This is my PHP code: if(isset($_POST['date']) ) { echo "<input type='radio' id='date'/>"; } And here's my AJAX code: $.ajax( { type: "POST", url: "sched ...

Acquiring JSON data within a JavaScript function using PHP

Requesting assistance on reading a JSON value using the code below, to retrieve data based on the $movieID. <script> function bookBTN(x) { <?php $url = 'http://movie.com/movieOne?seatNum=' . x; $jsonURL = file_get_ ...

Is there a way to identify when the back button on an Android device is pressed while using a

I am currently working on a Progressive Web App with Vue.js. I am aware that Cordova has the capability to handle the back button on Android/iOS devices (not the browser's back button) which is good news. Does anyone know how I can detect this in Vue ...

Tips for avoiding the freezing of bootstrap-select scroll when a large number of options are present

I have integrated a bootstrap-select with a total of 1000 options. However, I am encountering an issue where when I attempt to scroll down the list of options, it only goes down approximately 60 options and then freezes in that position. Can anyone provi ...