What’s up all,
I am newbie who is struggling with loading an image to wrap all six sides of boxMaterial. I am using the basic boxMaterial code (below) from the documentation to draw the box. I also use the documents ImageLoader code to no effecct. Please help. been three days trying to figure this out.
Yhanks
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var geometry = new THREE.BoxGeometry(1, 1, 1);
var material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
var cube = new THREE.Mesh(geometry, material);
scene.add(cube);
//var pLight = new THREE.PointLight(0xffffff, 1);
//pLight.position.set(4, 4, 2);
//scene.add(pLight);
camera.position.z = 2;
var animate = function () {
requestAnimationFrame(animate);
cube.rotation.x += 0.02;
cube.rotation.y += 0.02;
renderer.render(scene, camera);
};
animate();
ImageLoader code below: (not in use just her for reference)
// instantiate a loader
const loader = new THREE.ImageLoader();
// load a image resource
loader.load(
// resource URL
‘textures/skyboxsun25degtest.png’,
// onLoad callback
function ( image ) {
// use the image, e.g. draw part of it on a canvas
const canvas = document.createElement( 'canvas' );
const context = canvas.getContext( '2d' );
context.drawImage( image, 100, 100 );
},
// onProgress callback currently not supported
undefined,
// onError callback
function () {
console.error( 'An error happened.' );
}
);