I am attempting to project multiple planes onto a sphere, and while successful, I am encountering some unforeseen glitches in the process

Currently, I am working on a school project that involves mapping around 5000 images onto a sphere.

Attached is a flat projection of what I intend to map.

Additionally, I have a spherical model for reference.

Using three.JS and the principle of the Mercator projection, I am encountering an issue where the images rotate, and I am unsure how to resolve it.

Despite extensive research, I have not found a solution to this problem.

Below is the code snippet I am using to position all the images:

drawMeridianCells(scene, rayon) {
    // Code snippet for drawing meridian cells goes here
}

I hope my explanation is clear enough.

Answer №1

It seems like the issue may be arising in the constructor of the Square class, or possibly in the method drawSquare(). There is also a potential problem with the `lookAtZero()` method, as it appears to rotate the shape's normal to point towards zero, but the exact rotation mechanism is unclear.

When creating the squares, it is essential to ensure that one edge aligns with a line of latitude and the other with a line of longitude. Begin by setting the square's center at

var x0 = rayon * (Math.cos(lat) * Math.cos(long));
var y0 = rayon * (Math.cos(lat) * Math.sin(long));
var z0 = rayon * (Math.sin(lat));

The horizontal tangent would be

tx = -Math.sin(long)
ty = Math.cos(long)
tz = 0

and the tangent along the latitude line would be

ux = -Math.cos(lat) * Math.cos(long)
uy = -Math.cos(lat) * Math.cos(long)
uz = Math.sin(lat)

These are calculated by differentiating with respect to longitude and latitude, respectively. They should be unit vectors.

You can then define a rectangle with points

x0 +/- celW * tx  +/-  celH * ux
y0 +/- celW * ty  +/-  celH * uy
z0 +/- celW * tz  +/-  celH * uz

Alternatively, you can generate points by incrementing the latitude and longitude parameters

var x2 = rayon * (Math.cos(lat + lat_inc) * Math.cos(long + long_inc));
var y2 = rayon * (Math.cos(lat + lat_inc) * Math.sin(long + long_inc));
var z2 = rayon * (Math.sin(lat + lat_inc));

This method will result in a trapezium rather than a rectangle.

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

Retrieve the IDs of list elements in order to dynamically update a div using AJAX

I'm facing a bit of a challenge at the moment. I have a webpage that uses jQuery to load three different views: one displaying all categories associated with the user, another showing the image and name of items within the selected category, and a thi ...

I am looking to apply the Normal texture to the Fbx model, but I am encountering issues with the normal not functioning

This is an example. I am in need of a model with both a color map and a normal map. Just like the one seen in Microsoft 3D Viewer. https://i.sstatic.net/DU2vo.png Furthermore, I already have a model with a normal map. My approach involves using the re ...

Index similar to JavaScript-Meadow

Is there a way to create a table of contents like the ones seen on sites such as JavaScript Gardens? How do they determine which section is currently active and are there any recommended JavaScript libraries that can help achieve this functionality? Edit: ...

Maintain course focus when updating

I'm currently working on a to-do list where clicking on an item adds the "checked" class. However, when I refresh the page, everything reverts back to its original state without the checked class. How can I maintain the state of the checked items? I& ...

Creating a read-only DIV using Angular - a step-by-step guide

Is there a simple way to make all clickable elements inside a div read only? For example, in the provided HTML code, these divs act like buttons and I want to disable them from being clicked. Any tips or shortcuts to achieve this? Thank you. #html < ...

Unable to persist information in Firebase's real-time database

I'm having trouble saving data to my firebase database. Although I don't see any errors on the site, the data in firebase remains null and doesn't change no matter what I do. Here is the code snippet. HTML <html> <head> ...

Accessing html form elements using jQuery

I'm having trouble extracting a form using jQuery and haven't been able to find a solution. I've tried several examples, but none of them display the form tags along with their attributes. Here is a sample fiddle that I've created: Sam ...

The issue of NETWORK ERROR cannot be fixed through the use of axios

I'm attempting to communicate with a backend server that is currently offline using axios const backendClient = axios.create({ baseURL : env }); The API call is made here: export const createExpensesRecord = async (createExpenseRecordCmd) => { ...

Sending arrays' values in JavaScript

Here is a list of different groups to choose from: <select multiple="multiple" name="groups[]" id="groups[]" class="myclass"> <option value="1">Employees</option> <option value="2">Vendors</option> <option valu ...

Tips for validating updates in MongooseEnsuring data integrity is

My current Schema does not validate upon updating. Can you please point out where I went wrong and help me fix it? ...

Mandating the inclusion of a directives controller in conjunction with other necessary controllers

Two directives are nested within each other, with one requiring the other using require: '^parentTag' . Both directives have their own controllers. In the parent directive, I can access its controller as the fourth argument in link: function(scop ...

Steps for eliminating QRcode warning in npmjs package

Issue: Warning Message (node:24688) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time (Use `node --trace-warnings ...` to show where the warning was created) Seeking Solution: How can I prevent this warning ...

The div element nested within the button is not visible

Fiddle I am trying to create a unique social button design that resembles the custom Google+ sign-in button: However, I encountered an issue where the second div element (to hold the right part of the button) is not displaying as expected: Here is the c ...

Issue encountered in Vite Preview: Uncaught (in promise) SyntaxError: JSON.parse found an unexpected character at the beginning of the JSON data, line 1 column 1

Encountering the error message Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data when running vite preview after running vite build. https://i.sstatic.net/61Y9t.png Here is my vite.config.js: import { ...

Attempting to alter the background image through the action of clicking on an image using jQuery, HTML, and CSS

I have created custom weather icons like a sun, cloud, and rainy cloud using Photoshop. My goal is to allow users to click on these icons and change the background image of the website's body. However, despite my efforts, clicking on the images does n ...

What could be the reason for the lack of rerendering in this child component?

Currently, I'm delving into ReactJS and attempting to grasp how child component rendering functions. To illustrate, consider the following example: var externalCounterVar = 10 class Counter extends React.Component { constructor(props){ super(pr ...

Node.js Express JS is currently in the process of retrieving a file

I'm currently grappling with an issue while attempting to download a file using express js. Here is the function in question: var download = function(uri, filename, callback) { request .get(uri) .on('response', function (response) { ...

Retrieve the current row by clicking the button

I've been struggling to retrieve a specific value from a row displayed on my PHP webpage. My objective is to obtain the current value from a particular cell in the row, but using getElementsByTagName has not been successful as it only returns an HTMLC ...

Eliminate JSON data that pertains to dates that are either in the past or future

I am working on integrating upcoming classes and past classes components into my application. I have successfully stored the schedule of classes and can retrieve them using backend services. However, I need to display only the upcoming classes in one compo ...

Sending Angular base64 image data to the server

I am encountering an issue while attempting to upload a base64 image from Angular to ExpressJS. The image is being created using html2canvas to generate the base64 representation. When I try to upload the imageData in its current format, I receive an error ...