Spinning a 3D surface about an axis using JavaScript

I'm in need of guidance on what to implement, unsure whether to use vanilla JavaScript or a library.

My goal is for users to view a 3D model building in their browser. The modeling is done in a specific tool and then exported as a sequence of images for a 360° experience. I have successfully implemented this code for the 360° functionality.

In the modeling tool, the camera used to capture the model's images (let's say it's a house) is positioned a few meters above and rotates around the house on a circle. I have access to these camera parameters (height and distance from the model center).

Furthermore, I want to add "hot spots" on this 360 JavaScript image spinner: users should be able to click on different surfaces (kitchen, dining room, room1, room2, etc.) and receive popup data. I have previously accomplished this in 2D using SVG (example here), but unsure how to achieve similar interactivity in a 3D environment. I am considering utilizing three.js for this task, although I may need some assistance as my knowledge of math is limited.

My ideal approach would involve:

  • Drawing a map of the clickable zones (possibly with SVG)
  • Rotating this map based on the same angle as the first picture of the sequence (camera height/distance)
  • Updating the map rotation as the user interacts with the 360 image spinner by computing the angle around the x-axis.

If anyone has suggestions on how I could achieve this or which tools to utilize, I would greatly appreciate it.

Thank you.

Answer №1

Creating a rotating and clickable area in Threejs is a breeze without needing to worry about the mathematical calculations. Simply synchronize the rotation with your image slider's period.

  • The SVGRenderer could be suitable for your project,
  • However, considering the high CPU demands of the linked slider, the WebGLRenderer may offer the best solution by utilizing GPU rendering. In Threejs, the programming differences are minimal or non-existent.
  • If you opt for the WebGLRenderer, it would be more streamlined to handle everything within Threejs. Instead of loading numerous images, simply load a texture and geometry (saving time during the loading process) and achieve a smoother result due to reduced CPU computations.

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

What causes particles to move in reverse when the camera approaches?

I've encountered an issue with my particle system in THREE.JS where the size is set to 40. When the camera gets close to them, they start moving backwards until they disappear. Is this behavior normal? How can I adjust it so that the particles remain ...

What factors outside of the program could potentially lead to the splice function not functioning as expected?

Within my code, I encountered a peculiar issue involving a splice line along with debug lines on both sides. Take a look: const obj = { x:[1,2], y:{t:"!!!"} } const lenBefore = S.groupings.length const ret = S.groupings.splice(gix, 0, obj) console.log(`${ ...

The sorting icon cannot be substituted with jQuery, AJAX, or PHP

Currently, I am working on implementing "sort tables" using ajax, jquery, and PHP. The sorting function is functioning correctly; however, I need to show/hide the "sorting images". At the moment, only one-sided (descending) sorting is operational because I ...

Dynatree experiences sluggish performance when loading over 100 nodes dynamically

How can I improve the loading speed? I am retrieving data from a JSON web service very quickly. However, when I add nodes to the tree using the following code: parentNode.addChild({ key: key, title: value, addClass: cssClass } ...

Extracting a precise data point stored in Mongo database

I have been struggling to extract a specific value from my MongoDB database in node.js. I have tried using both find() and findOne(), but I keep receiving an object-like output in the console. Here is the code snippet: const mongoose = require('mongoo ...

Tips on swapping out a part in ExtJS

Currently, my ExtJS window features a toolbar at the top and loads with a plain Panel at the bottom containing plain HTML. Everything is working smoothly in this setup. However, I now wish to replace this bottom panel (referred to as 'content') w ...

Issue: Nest is unable to determine dependencies for the AwsSnsService (?)

I've been attempting to connect a service from one module to another, but I keep encountering this error message: Error: Nest can't resolve dependencies of the AwsSnsService (?). Please ensure that the argument function() {\n if (klass !== ...

When the onClick event is triggered, my intention is to dynamically insert a new

I'm having trouble adding a new row on each click, as my code keeps replacing the existing row. I attempted moving the if statement outside the addTable function, but it didn't work as expected. I've tried multiple solutions without succes ...

Tips for efficiently managing variable item quantities and orders when making selections from an unsorted list

When extracting innerText properties from list items within a ul element, the length of the list can vary greatly. Certain items like profile name, age, and location are always present, while others such as current term and prior degree may or may not be i ...

Submitting Forms in Django with AJAX for Seamless User Experience

As a newcomer to Python, I might be missing an easy fix. I'm attempting to create a registration form using Jquery with Django. I've been following this tutorial When I click the button, I see a success message in the alert, but nothing gets sa ...

Trouble with closing windows in the in-app browser on Android devices

Is there a method to successfully close the in-app browser? Despite window.close working on iOS devices, it is not effective on Android. I have experimented with alternatives like window.top.close and window.open("", "_self") window.close, but none have ...

Mastering the art of filtering JSON data with multiple conditions using .filter() and .includes() in JavaScript and React

Forgive me if this is a straightforward question, as I am new to the world of programming. My current project involves creating a web application that filters quotes based on specific keywords. The quotes are stored in JSON format, here's a glimpse at ...

Issue encountered when attempting to invoke server-side function using JavaScript

[WebMethod] public static string simple() { Home h = new Home(); h.logout(); return "dfdsf"; } public void logout() { Response.Redirect(Config.Value("logout")); } client side code $('#logout').on('click', function () ...

Is there a way for me to identify when I am "traveling" along the same path?

I want to create a toggle effect where a view is hidden if the user tries to revisit it. This can be useful for showing/hiding modal boxes. Here's the code I attempted: /* Root Instance */ const app = new Vue({ router, watch: { '$route&a ...

Utilizing scope parameters in conjunction with filters

I'm looking for a filtering solution to filter results displayed in a table using ngRepeat. The filter should be based on user input. Currently, I'm implementing it like this: //HTML <input type="search" ng-model="search"> <table> ...

Save the newly added items on the server using socket.io

// Creating a function to convert element to string function elemToString(elem){ return elem.outerHTML } // Create a new child div element with text content and class name let child = document.createElement("div") child.textContent = "bar" child.class ...

Error: Unable to instantiate Razorpay as a constructor

Having some trouble integrating Razorpay with Node TypeScript. The issue appears to be related to the const variable razor. Any help or insights would be greatly appreciated. Thank you! import * as Razorpay from 'razorpay'; const razor = new ...

Find the closest preceding sibling based on the tag

Currently, I have implemented jQuery for hierarchical checkboxes that appears as follows: Here is my HTML structure: <ul class='tristate'> <li> <input type='checkbox' /> <label /> <ul> ...

Incorrect color change on button triggered by onMouse actions and state fluctuations

While creating a user profile on my app, I encountered an issue with button coloring. When I try to add color functionality to the button, it turns red instead of green and remains red even when the mouse is not hovering over it. My goal is to have the but ...

I'm seeing a message in the console that says "Form submission canceled because the form is not connected." Any idea why this is happening?

For the life of me, I can't figure out why this code refuses to run the handleSubmit function. Essentially, the form is supposed to take an input and execute the handleSubmit function upon submission. This function then makes a POST request to an API ...