0

I want to create a 360 image view, with Threejs. I've 4 images, 1 is linked in with threejs and the remaining 3 are at the bottom of the page like thumbnails so when I click on the thumbnail the 360 image view should change.

My Codepen, BTW its 360 image is black, its not showing up in codepen, but works fine in localhost. Localhost preview is below. You can see those 3 more images at the bottom.

My localhost image code.

var material = new THREE.MeshBasicMaterial( {
                map: new THREE.TextureLoader().load( 'assets/image3.jpg' )
            } );

Localhost preview

1 Answer 1

1

You simply need to update the sphere's material. Just preload all of the images first and store them as materials. Also, I'm guessing the user is sitting inside your sphere. You need only render the backSide.

//globals
var images = [];

//preload
for (var i = 0; i < numberOfImages; i++) {
var loadImage = new THREE.TextureLoader().load('path/to/image/imageName_'+i, function(texture) {

     var material = new THREE.MeshBasicMaterial({map:texture, side:THREE.BackSide});

     images.push(material);
  }
}

Then on clicking thumbnail, update the material as you do in your load event, choosing the right material from the array and setting the sphere's flat object.material.needsUpdate = true

EDIT : you could also simply store the preloaded textures in the array and update your existing material.map. Don't forget to flag object.material.needsUpdate = true;

Sign up to request clarification or add additional context in comments.

7 Comments

Yeah, the user is sitting inside the sphere. I did not quite get it. sorry, I'm a novice in jQuery. trying to learn. @Hesha
I'll cook up a simple fiddle for you in an hour or so if no one else does.
That's so nice of you. Feel free to fork my codepen if needed. Thank you.
Here's a pen that'll show you one of the gazillion ways to do it. One thing you'll have to be doing : update the material after making changes. I used crap base64 images cause of CORS... Replace them with your images. Best of luck. codepen.io/TheDebOfNight/pen/KaGNYM?editors=0110
It doesn't load a image initially, can it be like there's the 1st image preloaded and then when others clicked it change
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.