var THREE = require('three');
var defaultTexture = require('./particle-texture.js');
var vertexShader = require('./particle-vertex-shader.js');
var fragmentShader = require('./particle-fragment-shader.js');
// var fixTexture = require('./index.png');
//var color = require ('/home/ubuntu/Training/pm-master/src/galaxy/native/defaultnode.js');
// //var defaultnode = require('./src/galaxy/native/defaultnode.js');
module.exports = createParticleMaterial;
// var texture = new THREE.Texture();
// var imageLoader = new THREE.ImageLoader(manager);
// createParticleMaterial(0xff00ff);
// var texture = THREE.ImageUtils.loadTexture("/home/ubuntu/Training/pm-master/node_modules/unrender/lib/index.png");
//
// texture.needsUpdate = true;
// imageLoader.load("index.png",function (image){
// texture.image = image;
// texture.needsUpdate = true;
// });
//obj.mesh.material.uniforms.texture.value = THREE.ImageUtils.loadTexture(defaultTexture);
var texture = new THREE.ImageLoader.load("aaaa.jpg");
//obj.mesh.material.uniforms.texture.needsUpdate = true;
texture.needsUpdate = true;
function createParticleMaterial() {
var attributes = {
size: {
type: 'f',
value: null
},
customColor: {
type: 'c',
value: null
}
};
var uniforms = {
color: {
type:"c",
value :new THREE.Color(0xffffff)
},
texture: {
type: "t",
value: texture
}
}
var material = new THREE.ShaderMaterial({
uniforms: uniforms,
attributes: attributes,
vertexShader: vertexShader,
fragmentShader: fragmentShader,
transparent: false
});
return material;
}
What revision of Three.js do you use?
You should load your texture like this:
var loader = new THREE.TextureLoader();
var texture = loader.load( 'aaaa.jpg' );
No need to set needsUpdate
to true. This happens automatically by TextureLoader
when the texture is fully loaded.