How can we generate three planes in geometric space that are perpendicular to the x, y, and z

I have been tasked with creating three plane geometries in a scene, one perpendicular to the x-axis, one perpendicular to the y-axis, and one perpendicular to the z-axis. The desired result should somewhat resemble this image: https://i.sstatic.net/L1K6G.png Below is the code I have written for achieving this:

public displayPlaneGeometries() {
        console.log(this.hScene)
        const geometryX = new th.PlaneGeometry(1, 1);
        const geometryY = new th.PlaneGeometry(1, 1);
        const geometryZ = new th.PlaneGeometry(1, 1);
        const material = new th.MeshBasicMaterial({
            color: 0xa6cfe2,
            side: th.DoubleSide,
            transparent: true,
            opacity: 0.5,
            depthWrite: false,
        });
        const planeX = new th.Mesh(geometryX, material);
        const planeY = new th.Mesh(geometryY, material);
        const planeZ = new th.Mesh(geometryZ, material);
        planeX.position.set(1, 0, 0);
        planeY.position.set(0, 1, 0)
        planeZ.position.set(0, 0, 1)
        material.transparent = true
        this.hScene.add(planeX, planeY, planeZ);
    }

Unfortunately, the output does not match the desired image, appearing like this: https://i.sstatic.net/PIEAN.png I am seeking advice on how to make the planes intersect at the center as shown in the image I uploaded above. How can I ensure that when added to the scene, they appear intersecting at the central point? Thank you for any assistance you can provide.

Answer №1

It is unnecessary to alter the position of the planes as they all need to pass through 0, 0, 0. However, adjustments to their rotation are required if alignment along various axes is desired.

const planeGeometry = new THREE.PlaneGeometry(1, 1);
const planeMaterial = new THREE.MeshBasicMaterial({
    color: 0xa6cfe2,
    side: THREE.DoubleSide,
    transparent: true,
    opacity: 0.5,
    depthWrite: false,
});
const planeXY = new THREE.Mesh(planeGeometry, planeMaterial);
const planeXZ = new THREE.Mesh(planeGeometry, planeMaterial);
const planeYZ = new THREE.Mesh(planeGeometry, planeMaterial);

// The default plane already occupies the XY plane
planeXY.rotation.set(0, 0, 0);

// Rotate around the x-axis to occupy the XZ plane
planeXZ.rotation.set(Math.PI / 2, 0, 0);

// Rotate around the y-axis to occupy the YZ plane
planeYZ.rotation.set(0, Math.PI / 2, 0);

There is also no necessity to create separate geometries for the three planes. Utilizing the same geometry for all three instances is a more efficient approach.

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

Triggering a click event in React when a link is clicked

I noticed something strange with a component I created that is quite simple. import React, {Component} from 'react'; const Logo = ({onClick}) => { return ( <a name="home" onClick={onClick} className="logo"> <span classN ...

Node.js server application encountering errors such as path.join issues

When I run my server.js file, it starts off well with the main starting page being loaded up. However, I encounter an error when I try to enter a nickname to enter any room and click on the Create chat room button. As I am new to building node.js apps, I n ...

Focusing on maximizing the potential of individual elements within an array

I have an array of values and I am looking to create a new array where specific values are assigned based on the values in the original array. For instance: My initial array: var values = [1, 2, 3, 4] The new array I want: [red, green, blue, black] I ...

How to resolve 404 error for HTML files in Angular 4's "basic deployment" strategy?

I have been attempting to deploy my application following the instructions in the "Simplest deployment possible" section of the angular guide. Starting from a project created using the quick start setup, I made changes to the files index.html, main.ts, and ...

Tips for Accessing the TextInput Content in React Native

My code is currently experiencing a bug where I am getting an undefined object type when trying to console log user input. Below is the code snippet I am working with. Can you help me identify and correct the issue? export default function App() { con ...

What is the best way to remove a particular element from an array stored in Local Storage?

Currently working on a web application that features a grade calculator allowing users to add and delete grades, all saved in local storage. However, encountering an issue where attempting to delete a specific grade ends up removing the most recently add ...

Leveraging React Hooks for managing the Data Provider and Data Context functionality

Currently, I am revamping my DataProvider by upgrading it from a class component to a functional component utilizing React Hooks. I suspect that the issue lies in how I am setting up my context consumer, but I am struggling to find an effective way to tes ...

Error encountered in Azure Pipelines build task: Failure due to requirement for initialization

When I directly invoke index.js using node, everything works fine. However, when running the Mocha tests, the task fails with a "Must initialize" error message. This is how my tasks index.ts code looks like: import * as path from "path"; import tl = requ ...

Optimize your mobile experience by creating a notification menu that is scrollable and fixed in position

Recently, I purchased Moltran, but encountered a major issue: The notification menu disappears on mobile devices, which is not ideal for me. After some research, I discovered that removing the hidden-xs class from the li notification element can solve this ...

Stop Bootstrap Modal from displaying with the help of an ajax error

Is there a way to prevent the Modal from appearing when an ajax call returns an error? I've tried using the code snippet below, but it didn't work for me. Here's how my ajax call is set up: $.ajax({ url: url, data: data, dataTyp ...

Creating a concise TypeScript declaration file for an established JavaScript library

I'm interested in utilizing the neat-csv library, however, I have encountered an issue with it not having a typescript definition file available. Various blogs suggest creating a basic definition file as a starting point: declare var neatCsv: any; M ...

mysql nodejs function is returning a null value

Kindly review the contents of the dbfn.js file /*This is the database function file*/ var db = require('./connection'); function checkConnection(){ if(db){ console.log('We are connected to the Database server'.bgGreen); ...

Properly passing props to child components in React with TypeScript. Resolve Error ts(2322)

I am facing an issue where my code works perfectly in Javascript, but encounters problems when converted to Typescript. Despite the complexity of the question, it actually boils down to a simple query. I just wanted to share the functional JS code as a sol ...

Navigating the diverse types of React HTML DOM events within a function concatenation

Question: Is it possible to merge different HTML DOM event types in Typescript? (I am aware of the option to split my function into two separate functions to avoid this error, but I would like to find another solution) Here is an example of my component ...

Tips for efficiently deconstructing JSON arrays, objects, and nested arrays

I'm attempting to destructure a JSON file with the following structure: [ { "Bags": [ { "id": 1, "name": "Michael Kors Bag", "price": 235, "imgURL" ...

What is the best way to upload images in Vue.js without using base64 formatting?

Is there a way to upload an image file without it being base64 encoded? I currently can only achieve base64 format when trying to upload an image. How can I modify the code to allow for regular file uploads? <script> submitBox = new Vue({ el: "#su ...

Cease all playback of audio immediately

My goal is to ensure that any audio that has been played previously stops before a new audio clip starts playing. This will prevent overlapping clips on elements that may trigger the audio file multiple times. I have attempted to pause and reset the curre ...

Mongoose consistently fails to properly save dates

I have created a Mongoose model and included a birthdate field in the following way: birthdate: { type: Date, required: [true, "Please enter a birthdate"], lowercase: true, validate: [isDate, "Please enter a valid birthdate&q ...

Retrieve the data-src attribute from the lightGallery plugin

I have integrated the lightgallery plugin into my website from Currently, I am struggling to retrieve the data-src value when an image is clicked. The basic HTML structure is as shown below: <div id="work-grid" class="grid wow fadeIn animated"> ...

Learn how to showcase a modal pop-up in AngularJS by utilizing the ng-if directive

Hello, I am new to working with AngularJS. My question is how can I display a modal pop-up box when the ng-if statement evaluates to false? Can you please provide guidance on how to solve this issue? Here is an example of the code snippet in HTML: <di ...