javascript - OBLMTLLoader name of the mesh empty -


i have sort of bug can't explain when use objmtlloader instead of objloader. obj file contains groups load both loaders in different children mesh.

i have in 2 case children of scene three.object3d same number of children: 1837. however, when display object in js console , inspect it:

  • for 1 loads objloader first children has got id 12 , id increases of 1 each new mesh , finish id 1848. makes sense.
  • with same object loads objmtlloader, id missing, in fact first children has 13 id , last children has id equals 5521. , instance here id of 5 first children : 13 16 19 22 25

this may not problem here tricky par of story, aim of project use raycaster in order change color of selected mesh (by clicking on it). display name of selected mesh:

  • with objloader when use raycaster modify color of mesh , display name without problem.
  • but objmtlloader change color of selected mesh without trouble, name of mesh nothing (without character).

the funny think every mesh has name imported in 2 cases.

the thing strange when display id of selected mesh in 2 cases objloader can find in object display in js console id in list of mesh , name correspond objmtlloader id in object3d...

is got idea problem can ?

thanks lot in advance !

update :

i have found part of solution still there strange, here example of structure of 3d model when import three.objmtlloader :

three.group      [...]      children : array[1837]                 0 : three.object3d                         [...]                         name : "the name of part"                         children : array[2]                                       0: three.mesh                                                name : ""                                                children : array[0]                                                [...]                                       1: three.mesh                                                  [...]                           [...]                  1 : three.object3d                  [...] 

in fact raycaster compute intersection three.mesh , name store @ level n-1 mesh. why have no name when try display it. why objloader level n-1 not exist same model 3d load ? in fact objloader structure of object :

three.group     [...]     children : array[1837]                 0 : three.mesh                         [...]                         name : "the name of part"                         children : array[0]                         [...]                 1 : three.mesh                 [...] 

basically, when objloader reads .obj file, creates three.object3d , each group of .obj, creates three.mesh , adds object3d, ignoring usemtl in .obj. you'll have 1 three.mesh per groups in .obj correct name, , it's cool.

objmtlloader, however, doesn't ignore usemtl. , since mesh bound geometry , material, if change material, have create mesh. when sees new groups, create object3d correct name, , object3d's children parts different materials.

if want name of real mesh, want intersect.object.parent.name.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -