我创建了一个矩形并在其上加载了一个纹理。
var boardText = new THREE.ImageUtils.loadTexture("myTexture.jpg");
var geometry = new THREE.BoxGeometry(70, 35, 2);
var material = new THREE.MeshPhongMaterial({map : boardText,
side:THREE.DoubleSide});
var board = new THREE.Mesh( geometry, material);
board.receiveShadow = true;
board.castShadow = true;
scene.add(board);
board.rotation.x = -1.57;
board.position.y = 1;
var spotLight = new THREE.SpotLight( 0xffffff );
spotLight.position.set(-70, 30, 50);
spotLight.castShadow = true;
spotLight.shadowDarkness = 0.5;
spotLight.shadowCameraNear = 5;
spotLight.shadowCameraFar = 150;
scene.add( spotLight );
它在Firefox,Safari和Internet Explorer下运行正常,但如果我在GoogleChrome和Opera上运行它,纹理就不会被加载。
在控制台上,错误显示:
Uncaught SecurityError:无法执行' texImage2D'上 ' WebGLRenderingContext':来自的跨原始图像 file:/// C:/Users/fdai3744/Desktop/Project/Holz_Texturs_B_03921.jpg may 没有加载。 2885three.min.js:565
警告说:
THREE.WebGLRenderer:纹理不是两个人的力量。 Texture.minFilter 应设置为THREE.NearestFilter或THREE.LinearFilter。 ( myTexture.jpg)
我不知道自己能改变什么。