What is the best way to display numerous images on a cube face while also organizing them like a gallery wall?

I'm working on creating a unique gallery wall using three.js. Currently, I have successfully rendered an image on each side like this:

My goal is to place multiple images on each wall instead of just one large image. Something similar to this concept:

How can I define arbitrary positions for the additional images?

Below is the code I have been using:

var scene = new THREE.Scene() 
    var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1,1000) 
    console.log(window.innerWidth, window.innerHeight) 
    var renderer = new THREE.WebGLRenderer() 
    renderer.setSize(   window.innerWidth,window.innerHeight) 
    document.body.appendChild(renderer.domElement) 
    //keep object in view when resize window 
    window.addEventListener('resize',   () => {
        let width = window.innerWidth
        let height = window.innerHeight
        renderer.setSize(width, height) 
        camera.aspect = width / height
        camera.updateProjectionMatrix()
    }) 
    controls = new THREE.OrbitControls(camera, renderer.domElement)
    controls.enableZoom = false
    controls.enableRotate = true
    controls.enablePan = false

    var geometry = new THREE.BoxGeometry( 2.5, 2, 4 )

    var cubeDice = [
        new THREE.MeshBasicMaterial({ color: 0x666666, side: THREE.DoubleSide }),
        new THREE.MeshBasicMaterial({ color: 0x666666, side: THREE.DoubleSide }),
        new THREE.MeshBasicMaterial({ color: 0x999999, side: THREE.DoubleSide }),
        new THREE.MeshBasicMaterial({ color: 0x999999, side: THREE.DoubleSide }),
        new THREE.MeshPhongMaterial({ map: new THREE.TextureLoader().load('img/h5_1993.132.jpg'), side: THREE.DoubleSide }),
        new THREE.MeshBasicMaterial({ map: new THREE.TextureLoader().load('img/unnamed.png'), side: THREE.DoubleSide }),
    ]

    // var material = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } ) 
    var material = new THREE.MeshFaceMaterial(cubeDice)
    var cube = new THREE.Mesh( geometry,material ) 
    scene.add( cube ) 

    // //set camera closer 
    camera.position.z = 1
    var update = function(){ 
        cube.rotation.y += .005
    } 
    var render = function(){ renderer.render(scene, camera) } 
    var GameLoop = () => { 
        requestAnimationFrame(GameLoop)
        update()
        render() 
    } 
    GameLoop()

Answer №1

Utilizing MeshFaceMaterial may not achieve your desired outcome as it causes each image to occupy an entire face (a whole wall).

To create separate, movable images on the wall, a more effective approach would be to generate individual smaller meshes for each image and position them in close proximity to the wall. This method allows the image to cover the entire mesh without spanning the entire wall:

https://example.com/image.png

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

SwipeJS is not compatible with a JQuery-Mobile web application

I am currently attempting to integrate SwipeJS (www.swipejs.com) into my JQuery-Mobile website. <script src="bin/js/swipe.js"></script> <style> /* Swipe 2 required styles */ .swipe { overflow: hidden; ...

What is the best way to display a unique image in a div based on the size of the

Being new to web design, I have a question about creating a webpage with a large image in the center like on GitHub's Windows page. How can I work with the image inside that particular div or area based on different screen sizes? Is it possible to mak ...

The issue of `Console.log` displaying as undefined arises after subscribing to a provider in Ionic3

In the process of implementing the Spotify api into my Ionic 3 app, I encountered an issue where the data retrieved appears as undefined when attempting to log it. Let me share some code and delve deeper into the problem. Here is the function getData() tha ...

Struggles encountered while configuring React

I'm in need of assistance with setting up React, even though I have both Node and npm installed. When I enter the following command: npx create-react-app new-test-react --use-npm I encounter the following error message: npm ERR! code ENOTFOUND npm E ...

Why isn't my onClick event functioning as expected?

I used the handleClick function in an onClick event, but it's showing an error (this is not defined). var Buttons = React.createClass({ getInitialState() { return { field: ':P ' } }, handleClick(field ...

NodeJS: The functionality of my node files relies on the variables defined in another file

For my nodejs app, I have created a script called app.js that serves as the entry point. This script initializes both the expressjs app and the http server. To clarify: The modules mentioned are not npm modules; they are custom files that I have written m ...

How to load MTL files from local storage using Three.js in Chrome

I'm encountering an issue when attempting to load MTL files using Three.js on Chrome. While everything runs smoothly on Safari, I keep running into a cross-origin request error in Chrome when working with local files. I'm at a loss on how to reso ...

The assets path is the directory within the installed package that houses the main application files following the completion of a

I have a Vue.js UI component that is internally built using webpack. This reusable UI component library references its images as shown below: <img src="./assets/logo.png"/> <img src="./assets/edit-icon.svg"/>   <i ...

Can Backbone be used to retrieve a local JSON file?

I have a simple and validated local JSON file that I am trying to fetch using Backbone.js. Here is the snippet of Backbone.js code: MyModel = Backbone.Model.extend({ defaults:{ name: '', age: 0 } }); MyCollection =Backbo ...

Executing scripts within various node project directories using npm

Creating Concurrent NPM Scripts In my main project, I have several node projects nested as subdirectories. Each of these projects has its own node_modules directories and package.json files. My goal is to define an npm script in the main project's pa ...

How do I use regex to grab all the text between two specific headers?

I need help extracting text between two specific headings. I attempted to create a regex for this purpose, but it's not quite capturing what I want. Currently, it includes the heading and paragraph, but misses the last heading. My Current Regex: /^& ...

In React Native, changing the translation of an element causes it to shift below all other elements, regardless of

Check out this sandbox project: I'm trying to create a simple animation using translation in React Native, but I'm facing an issue where when I move the element to the right and down, it goes under other elements. However, if I move it left and ...

I possess a variety of poppers and desire for the opened one to close when another one is opened

Having built a component that generates 6 unique experiences, each with its own popper containing images, I am struggling to figure out how to modify my code so that one popper closes when another is clicked. Here is the current setup: This is the compone ...

"An issue with the setTimeout function in React is leading to the page constantly refreshing

My buddies and I are in the process of developing a React App. The main goal is to identify the currently logged-in user, then send a post request to fetch everyone in the same "room" as them and display this information on the app upon page load. However, ...

Is the custom attribute event being triggered too soon?

My Unique Component Creation Journey I have meticulously crafted a custom component to enhance the navigation of my application. The core structure consists of an ul element, with each li item dynamically generated based on the contents of the router&apo ...

Struggling to configure an input field using ExtJS

I am trying to use an onChange event to update an input field with the selected option. Below is my code: HTML: <select id="builds" onchange="setBuild()"> <option value="select">Select</option> ... </select> <input ty ...

What is the best way to send a JavaScript array to a Perl script using AJAX?

Is it possible to convert a JavaScript array passed via AJAX into a Perl array? Accessing in Perl: @searchType = $cgi->param('searchType'); print @searchType[0]; Result: employee,admin,users,accounts It appears that the first value in the ...

What is the best method for updating audio from a source in Vue.js?

Forgive me if this is a silly question, but I'm still learning the ropes here. I may be going about this in all the wrong ways! I created a backend that learns from a text file and generates sentences along with an audio version of those sentences. I ...

AFrame: keeping an element's world position and rotation intact while reparenting

I am attempting to reassign a child element (entity) to another parent while preserving its position, rotation, and possibly size in the scene. Ideally, I would like to implement a component (let's call it "reparent") that can be added to an entity to ...

Transferring array data between two distinct click actions

Is there a way to transfer values between click events in jQuery? For example, on the first click event I want to add or remove values from an array based on whether a checkbox is checked. Then, on the second click I would like to iterate through all the ...