Created
February 21, 2019 19:14
-
-
Save graphoarty/b5cf553c91742f7b4120c020cb630c06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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