javascript - Three JS object load, put a color to an object -


i'm trying put color object in 3 js. tried alot of different things didnt work.

var objectloader = new three.objectloader(); objectloader.load("hoesje/hoesje.json", function ( object ) {     scene.add( object ); }); 

i hope can me out, thanks.

var loader = new three.objloader(); loader.addeventlistener( 'load', function ( event ) {     var object = event.content;     object.traverse( function ( child ) {         if ( child instanceof three.mesh )             child.material.color.setrgb (1, 0, 0);     });     scene.add( object ); }); loader.load( 'hoes.obj' ); 

but error : typeerror: loader.addeventlistener not function

var loader = new three.objloader(); loader.load( 'load', function ( event ) {     var object = event.content;     object.traverse( function ( child ) {         if ( child instanceof three.mesh )             child.material.color.setrgb (1, 0, 0);     });     scene.add( object ); }); loader.load( 'hoes.obj' ); 

i did change .addeventlistener .load give me follow error ns_error_dom_bad_uri: access restricted uri denied

    var objectloader = new three.objectloader(); objectloader.load("hoesje/hoesje.json", function ( object ) { scene.add( object ); } ); 

the code above working code load model in threejs, in code implent function change color..any ideas?

i dont know threejs looking @ code , issue seems adding event listener. why not use methods objloader has:

var loader = new three.objloader(); loader.load('hoes.obj', function(object) {     object.traverse( function ( child ) {         if ( child instanceof three.mesh )             child.material.color.setrgb (1, 0, 0);     });     scene.add( object ); }) 

edit in responde op's edit. .load() method:
.load ( url, onload, onprogress, onerror )

url — required
onload — called when load completes. argument loaded object3d.
onprogress — called while load progresses. argument xmlhttprequest instance, contain .total , .loaded bytes.
onerror — called when load errors.

given code below loader.load( 'load', function ( event )

load not seem url.
function(event) -- not event - loaded object3d.
why in answer above instead of creating eventlistener , trying trigger it, load() method called .obj resource.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -