Creating a grid surrounding a box using Three.js

I have recently designed a box buffer geometry with dimensions of 8x8x8. To enhance its appearance, I am looking to add a grid around it that aligns with these dimensions (specifically having 64 squares on each side). Does anyone know of any effective methods to achieve this in three.js? My current approach involves generating 16 intersecting lines for each face of the cube, but I find this to be cumbersome and detrimental to performance.

Answer №1

To achieve this effect, one way is to follow this technique:

Alternatively, a simpler method is to either create your own grid texture or find one on Google Image search, ideally in a power of 2 size like 64x64, 128x128, or 256x256.

You can then use this as the map for a MeshBasicMaterial()

texture = new THREE.TextureLoader().load('yourGridTextureImage.jpg') texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.repeat.set( 4, 4 );

Add it to the scene using: new THREE.Mesh(new THREE.PlaneGeometry(64,64),new THREE.MeshBasicMaterial({map: texture}))

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

Prevent Child Elements from Overstretching Container with Bootstrap Flex

I'm working on a layout where all elements can be viewed without the need for scrolling. Any panels that require more space should be scrollable. In the following example, I want the contents of main-left to be scrollable without stretching the entire ...

jQuery ajax doesn't function properly on the server, it only works locally

When I send a jQuery Ajax request from my front-end to the back-end to retrieve values for calculations, it works perfectly on my local web server. However, when I try it online, all I get is a result of 0 in my calculations, indicating that the Ajax respo ...

Issue encountered in Ionic/React/Typescript - Incorrect props supplied to React.FC<'erroneous props provided here'>

Having struggled with this issue for a while now without any success, I have searched through numerous questions here but none seem to address my specific case. Therefore, I kindly request your assistance. I am encountering difficulties passing props thro ...

Developing a web-based form using an ES6 module

I'm currently experimenting with an ES6 webpage to design a simple webpage featuring just an email form. The form includes fields for Name, Email, and Subject, a message text box, and a send button that is linked to a PHP script to deliver the email ( ...

Ways to soften a section of a canvas component?

What is the simplest way to apply a blur effect to a specific portion of my canvas element? I am utilizing the JavaScript 3D Library known as three.js. This library simplifies the use of WebGL. While they offer examples of blur and depth of field effects, ...

What is the most efficient method of converting an object into a list without resorting to a double for loop?

Within my code, there is an object named 'times' which contains another object labeled '20102'. This inner object has a collection of three sub-objects structured like so: times: { 20102: [ { name:'jane', age:12 }, ...

Guide to dynamically inserting an audio file into a div with jQuery

I am looking to dynamically insert an audio file. Below are the declared tags: <div> <audio id="myaudio"> </audio> </div> Now, I am trying to add the source dynamically. Can anyone help me with how to add it to the div or audi ...

Using Three.js to connect an array of materials to a indexed BufferGeometry

I created a BufferGeometry triangular prism with 6 vertices and added indexes to make 8 faces (2 triangles per square plane). After setting up 5 groups, each side of the prism is represented by a group. The object displays correctly when I assign a singl ...

"Troubleshooting JS issue: Unable to get index of element in multid

I'm currently facing an issue with trying to locate the index of a number within a 2d array. The console is throwing an error that says: Uncaught TypeError: block[((a * 10) + c)].indexOf is not a function I suspect the problem lies in how I am acces ...

JavaScript - How can I prevent receiving multiple alerts during long polling success?

After following a video tutorial on implementing long polling, I managed to get it working. However, I encountered an issue where my alert message pops up multiple times even though I only receive one response from the server. I was under the impression th ...

React-Redux Error: The function this.props.AppendCharacter is not defined

I have been looking for a solution to my issue but couldn't find anything that matches it. I am working on creating a calculator app using React & Redux, and whenever I click on one of the number buttons, I receive an error message saying "this.props. ...

The TouchableOpacity function is triggered every time I press on the Textinput

Every time I press on a text input field, the login function is called This is the touchable statement: <TouchableOpacity style={InputFieldStyle.submitButton} onPress={this.login(this.state.email, this.state.password)}> <Text ...

Encountering an issue while integrating React three fiber library and attempting to utilize TextGeometry

Currently, I am utilizing React in conjunction with react-three fiber and typescript in an attempt to create basic 3D text. I have encountered the following error: THREE.TextGeometry has been relocated to /examples/jsm/geometries/TextGeometry.js Below is ...

Tips for displaying the initial slide when a tab is loaded on a multi-tab webpage

I have a total of four tabs, with the first tab containing a slideshow. On page load, I am successfully triggering the first tab, but for some reason, the first slide in the slideshow within that tab is displaying a blank image. I'm struggling to find ...

"Utilize gulp-connect to store the root as an array

The gulp-connect documentation mentions that options.root can accept either an array or string. My situation involves having a build directory that I want to use as the root, along with a separate sources directory where all my source maps are located. Is ...

Can you explain the significance of the 'X-Bandwidth-Est 3' error message that states, "Refused to get unsafe header"?

I'm currently facing an issue with all the websites I am working on where I keep encountering the following error: Refused to get unsafe header "X-Bandwidth-Est 3" in base.js. This error seems to be related to a YouTube file named base.js, but after ...

When trying to reference a vanilla JavaScript file in TypeScript, encountering the issue of the file not being recognized

I have been attempting to import a file into TypeScript that resembles a typical js file intended for use in a script tag. Despite my efforts, I have not found success with various methods. // global.d.ts declare module 'myfile.js' Within the re ...

The error message "Blazor WebAssembly JSRuntime.InvokeVoidAsync - blazor.webassembly.js:1 Uncaught (in promise) TypeError: Converting circular structure to JSON" indicates that

I have implemented the drawio-integration project in my Blazor WebAssembly application. https://github.com/jgraph/drawio-integration This is how the simple helloworld sample appears: <img onclick='DiagramEditor.editElement(this);' src=" ...

Mapping custom colors to paths in D3 Sunburst visualizations can add a vibrant and unique touch

Currently, I am in the process of developing a D3 Sunburst Vue component and utilizing the npm package vue-d3-sunburst for this purpose. To access the documentation for the package, please visit: https://www.npmjs.com/package/vue-d3-sunburst The document ...

How to Retrieve a Specific Line with jQuery

Could jQuery be used to retrieve the offset of the first letter in the 5th visual line of a block's content? I am referring to the visual line determined by the browser, not the line seen in the source code. ...