I
I
Igor2016-06-03 23:49:53
JavaScript
Igor, 2016-06-03 23:49:53

Why doesn't texture work in three.js: loader.addEventListener('load',function(event){?

var cub_texture,loader;

   cub_texture= new THREE.Texture();
   loader= new THREE.ImageLoader();


   loader.addEventListener('load',function(event){
    cub_texture.image=event.content;
    cub_texture.needsUpdate=true;
   });
   
   loader.load('./img/textBox.jpg');

   var cub_material = new THREE.MeshBasicMaterial({map:cub_texture,overdraw:true});

linewire.ru/t/TreeTest20clsess
How to do it right?
loader.load(''./img/textBox.jpg'',function(event){
    cub_texture.image=event.content;
    cub_texture.needsUpdate=true;
   });

I tried that, but it doesn't work either.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Игорь, 2016-06-04
@IgorBee

var cube_geometry = new THREE.CubeGeometry(100, 100, 100);
    cube_two_texture = new THREE.TextureLoader().load( 'img.jpg' );//load texture
   var cube_two_material = new THREE.MeshBasicMaterial({map: cube_two_texture});
   var cube_two = new THREE.Mesh(cube_geometry, cube_two_material);
   cube_two.position.y = -200;
   scene.add(cube_two);

Вот как надо.
тот принцы что выше он устарел.

H
hazik76, 2016-06-17
@hazik76

Еще наткнулся на трабл - не подгружается в хроме локально, загрузил на сервак, заработало!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question