Using multiple images to create a visual in three.js

Looking to create a unique shape or maybe even a word using three.js by incorporating various pictures. Take, for example, the following image:

https://i.sstatic.net/9O1dF.jpg

My plan is to determine the points that will form the desired shape and then place the pictures accordingly. Despite my efforts to find information on this process, I am uncertain about how to locate these points, particularly since the shape could be irregular. Any suggestions or solutions would be greatly appreciated.

Answer №1

It appears there are two possible paths you can take in moving forward:

  1. You have the option to utilize a modeling software such as Blender to create the shape and images, then export the JSON file (view this resource for guidance on setting up the threejs json exporter in blender), followed by using the JSON loader to load it.
  2. Alternatively, you could construct basic geometries of the desired shape using the provided options in threejs like box, circle, etc (see documentation), then apply textures to it as exemplified here.

I hope that one of these approaches meets your requirements.

Answer №2

My approach involves using the canvas to plot the 3D positions of each photo.

I have set up a demonstration with text:

https://jsfiddle.net/2qu6m4h3/

Additionally, I have another demonstration with random shapes:

https://jsfiddle.net/d2th9ekb/

The process involves creating a canvas element for drawing text and then extracting pixel positions from it. These positions are used in a function that arranges cubes in 3D space. Alternatively, sprite objects can be placed instead of cubes to represent each photo. Adjusting the scale property provides spacing between positions as needed.

Below is the code snippet:

// JavaScript code goes here
// This code initializes the setup for canvases and tools
// More details about setup go here

...
// Additional setup for Three.js canvas and tools
// Details on setup continue here

...
// Another section creates a 3D representation based on examined text
// Further explanation and details included

...

// Initializing 3D environment
init3d();
// Initializing text canvas
createTextSourceCanvas("Hello World", ctx);
//
create3dProjectionText(scene, examineText(ctx ,4), ctx.canvas.width, ctx.canvas.height, 1.5);
animate();

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

I am looking to superimpose one rectangle over another rectangle

I am looking to create something similar using CSS and TypeScript/JavaScript: Could someone please guide me on how to achieve this? My attempt with a flex container looks like this: I am new to front-end development. Can anyone point out what I might be ...

How to execute a JavaScript function within a Jinja for loop

I am currently working on an HTML page where the variable schedule contains a series of sequential decimal numbers representing seconds. My goal is to develop a function in JavaScript/jQuery that can convert these decimal numbers into time format. However ...

Is there a way to make the primary button on the previous page function correctly again, just like it did before it was clicked?

Issue Description: I am facing an issue on the order page where I need to link the "Continue" button to a booking page. After reaching the booking page, I expect users to be able to navigate between the two pages seamlessly even when they use the browser& ...

The lambert material is being extended, but unfortunately the opacity feature is not functioning

I am attempting to develop a unique material that builds upon the properties of the lambert shader. However, I am encountering difficulties as setting the mesh to be translucent is not functioning as expected. var shaders = { lambert : THREE.ShaderLib[&ap ...

String ES6 syntax immediately after function

return pool.query`select * from mytable where id = ${value}` How can the code snippet above be rewritten in full JavaScript? I attempted to use: return pool.query(`select * from mytable where id = $(value)`) but it seems like there is a difference. Th ...

How to retrieve multiple person or group values in SharePoint using JavaScript

Names from my SharePoint list are stored with the field names 'People' and 'Responsible', added using a peoplepicker. These fields are of type 'person or group' in SharePoint. In my Service file, I have the following code: ...

What is the best way to retrieve the output of MongoDB's collection.aggregate() within a NodeJS callback function?

In my database, I have a users collection with the following data: { "_id" : ObjectId("5b29ba37cd0b1726068731c3"), "name" : "Gym Dog", "profilePicUrl" : "https://i.imgur.com/mPStaKV.png", "totalProgress" : { "goal" : 300, "progress ...

Error: Invalid argument type

I'm encountering difficulties retrieving data from an API as I delve into learning Angular 2. The error message I am facing is: url.js:106 throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'url', 'string', url); Typ ...

Declaring a Javascript variable within an if statement does not alter the value of the global variable

Currently, I am working on enhancing my HTML projects by using JavaScript to modify the video source. Below is the video element in question. <div> <video id="songVid" onmouseover="controlsVid()"> <source src=&qu ...

What is the best way to restrict the length and number of lines in a textarea based on pixel dimensions?

I am looking to create a textarea where people can select different fonts, such as "sans-serif" and "serif", to type in text. I plan to have buttons labeled "sans-serif" and "serif" that will change the font of the textarea when clicked. However, there ar ...

Ways to conceal buttons according to your 'occupation'?

I am currently developing an application and I would like to have certain buttons displayed based on the user's $job. There are four job roles stored in mysql databases: student teacher staff principal, The signup button should only be visible to te ...

I am experiencing issues with the search feature in angular and node.js that is not functioning properly

Need assistance with debugging this code. I am currently working on adding search functionality to my Angular web page. However, when testing the code in Postman, I keep receiving the message "NO USER FOUND WITH USERNAME: undefined". Additionally, on the w ...

I encountered a response error code 500 from the development server while using my emulator

As I embark on setting up the react-native environment for development, I encounter an error when executing the command react-native run-android. root@pc:~/l3/s2/DevMobMultipltm/Wakapp# ` A series of tasks are carried out including scanning folders for sy ...

Uploading an image using ajax with multer

When using Multer to upload an image file to my Node server, I keep getting 'undefined' when trying to use ajax to send the image. Ajax : image = $("#input-file-img").val() const data = new FormData(); data.appe ...

How to ensure an object is consistently rendered above all others using Three.js

Currently working on adding a dynamic command arrow that follows the cursor on the display. However, I have encountered an issue where it gets obscured by other elements on the screen. Is there a method to adjust the z-buffer or implement a workaround to ...

After my jQuery functions are executed, my CSS rules are loaded

Struggling with the communication between CSS and jQuery, I find myself torn. In CSS, my rules are often very specific, like this: div#container > div#contentLeft { //Code here } However, when I add jQuery to spice up my site, the CSS rules seem to ...

Text-field input experiencing issues with placeholder display

As a beginner in Angular, I may make some mistakes. I created a textField input using a directive in Angular: .directive('textField', function () { return { restrict: 'E', scope: true, require: 'ngModel ...

Can animations be stacked in a queue while using velocity.js?

I'm currently tackling a project involving a push menu. When the content div slides over, the menu buttons come in with a slight animation as they appear on the screen. However, if the user rapidly opens and closes the menu multiple times, the items o ...

Creating Unique Designs with Multiple Shapes and Elements using Clipping Masks

I have a design piece to create that I initially built using three separate square div containers with independent background images. However, this method feels rigid to me as it requires chopping up and restaging a new image each time it needs to be chang ...

using flexbox in react does not automatically resize

I am attempting to create a layout where the screen is split into two sections - one green block taking up 1/4 of the screen and one yellow block taking up 3/4 of the screen using react.js. However, when I tried implementing the code below, both blocks end ...