javascript - threejs traverse an object onClick -



javascript - threejs traverse an object onClick -

i want add together wireframe object onclick button, using traverse it, working fine in objmtlloder, if seek separate function below onclick button cause

object undefined

function wireframe(object){ //alert('hhhhhh'); object.traverse( function ( kid ) { if ( kid instanceof three.mesh ) { //child.geometry.computefacenormals(); var geometry = child.geometry; //console.log(geometry); //geometry.dynamic = true; material = child.material; mesh = new three.mesh(geometry, material); scene.add(mesh); var usewireframe = true; if (usewireframe) { mesh.traverse(function (child) { if (child instanceof three.mesh) { //child.material.wireframe = true; var wfh = new three.wireframehelper( mesh, 0xffffff ); wfh.material.wireframe = true; wfh.material.linewidth = 2; // looks much improve if pc back upwards scene.add( wfh ); } }); } } }); }

can traverse on object onclick, possible ?? why getting error ??

there couple of ways add together wireframe appearance object. 1 add together three.wireframehelper scene. have done ladybug model , when user presses on button add() wireframe scene , when user presses off button remove() wireframe object scene.

with male model (the 1 not work) wanted object material , go , alter that.

you should load model normally:

// asynchronous loading // add together name object can search later. var loader = new three.objmtlloader(); loader.load( 'obj/male02/male02.obj', 'obj/male02/male02_dds.mtl', function ( object ) { object.name = 'name want'; scene.add ( object ) } ); function wireframe() { var object = scene.getobjectbyname ("name want", true); // recursive search object.traverse ( function (child) { if (child instanceof three.mesh) child.material.wireframe = true; } }

javascript three.js

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -