-
Me_nO_PreN0Likes 0Problem Description
I CAN NOT INPUT IMAGE INTO THE CUBE!
IT SHOW ME THIS ERROR AT CONSOLE TAPE:
THREE.MeshFaceMaterial has been removed. Use an Array instead.
Access to Image at 'file:///C:/Users/Mac's%20Dell/Desktop/THREE/img/2.png' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.
BELOW IS MY CODE
<html><head><title>THREE.js Crash Course</title><style>body{margin:0;}canvas{width: 100%;height: 100%;}</style></head><body><script src="js/three.js"></script><script src="js/OrbitControls.js"></script><script>var scene = new THREE.Scene();var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );var renderer = new THREE.WebGLRenderer();renderer.setSize( window.innerWidth, window.innerHeight );document.body.appendChild( renderer.domElement );window.addEventListener('resize', function(){var width = window.innerWidth;var height = window.innerHeight;renderer.setSize( width, height );camera.aspect = width / height;camera.updateProjectionMatrix();} );controls = new THREE.OrbitControls( camera, renderer.domElement );// create the shapevar geometry = new THREE.BoxGeometry( 1.5, 1.5, 1.5 );var cubeMaterials =[PROBLEM START HEREnew THREE.MeshBasicMaterial({map: new THREE.TextureLoader().load('img/1.png'), side: THREE.DoubleSide}), // RIGHT SIDEnew THREE.MeshPhongMaterial({map: new THREE.TextureLoader().load('img/2.png'), side: THREE.DoubleSide}), // LEFT SIDEnew THREE.MeshLambertMaterial({map: new THREE.TextureLoader().load('img/3.png'), side: THREE.DoubleSide}), // TOP SIDEnew THREE.MeshPhongMaterial({map: new THREE.TextureLoader().load('img/4.png'), side: THREE.DoubleSide}), // BOTTOM SIDEnew THREE.MeshLambertMaterial({map: new THREE.TextureLoader().load('img/5.png'), side: THREE.DoubleSide}), // FRONT SIDEnew THREE.MeshBasicMaterial({map: new THREE.TextureLoader().load('img/6.png'), side: THREE.DoubleSide}), // BACL SIDEEND HERE];// create a material, color or image texturesvar material = new THREE.MeshFaceMaterial( cubeMaterials );var cube = new THREE.Mesh( geometry, material );scene.add( cube );camera.position.z = 3;// game logicvar update = function ( ){//cube.rotation.x += 0.01;//cube.rotation.y += 0.005;};// draw Scenevar render = function ( ){renderer.render( scene, camera );};// run game loop (update, render, repeat)var GameLoop = function ( ){requestAnimationFrame( GameLoop );update();render();};GameLoop( );</script></body></html>
-
Sonar Systems adminLikes 0
This is due to the images being stored locally, this causes security issues. This link will assist you with fixing this https://stackoverflow.com/questions/41965066/access-to-image-from-origin-null-has-been-blocked-by-cors-policy
Login to reply