Skip to content

Instantly share code, notes, and snippets.

@graphoarty
Created February 21, 2019 19:14
Show Gist options
  • Save graphoarty/b5cf553c91742f7b4120c020cb630c06 to your computer and use it in GitHub Desktop.
Save graphoarty/b5cf553c91742f7b4120c020cb630c06 to your computer and use it in GitHub Desktop.
// initialize TextureLoader into loader
var loader = new THREE.TextureLoader();
// call the load function and pass in the parameters
// the first is the URL of the texture image to be loaded
// the second is the function to be called when the texture is loaded
// the texture reference is passed as a reference in this function
// the onError function call is called when there is an error
loader.load(
url = 'textures/360_image.jpg',
onLoad = function (texture) {
// create the MeshLambertMaterial with the texture
var material = new THREE.MeshLambertMaterial({
map: texture
});
// create the sphere with the material and add it to the scene
var geometry = new THREE.SphereBufferGeometry(3, 32, 32);
var sphere = new THREE.Mesh(geometry, material);
sphere.position.set(10, 0, 0)
scene.add(sphere);
// render the scene again
renderer.render(scene, camera);
},
onError = function (err) {
// print error if something goes wrong
console.error('An error happened.');
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment