How to load texture in jsfiddle

和自甴很熟 提交于 2019-12-24 11:17:17

问题


How to use THREE.ImageUtils.loadTexture() in jsfiddle. I have created a demo [ http://jsfiddle.net/georgeneil/cfrsj/10/ ]. Here I am not able to view the texture. I am getting the points rendered as black.


回答1:


You can base64 encode the image. And then add the string in your code.

Updated jsfiddle: http://jsfiddle.net/cfrsj/11/




回答2:


The problem is you cannot use a texture that is hosted externally. Here is some code I created to put a texture on a plane. I believe I adapted this code from one of mr doob's projects:

img = new Image();
texture = new THREE.Texture(img); 
    img.onload = function() {
    texture.needsUpdate = true;
    makeParticle();
    };
img.src = "http://www.aerotwist.com/tutorials/creating-particles-with-three-js/images/particle.png";

geometry = new THREE.PlaneGeometry( 438, 695, 200 );
material = new THREE.MeshBasicMaterial( {map: texture} );


来源:https://stackoverflow.com/questions/11753720/how-to-load-texture-in-jsfiddle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!