meshcat-dev / meshcat

Remotely-controllable 3D viewer, built on top of three.js
MIT License
256 stars 48 forks source link

Fix of collada loading #58

Closed VladimirIvan closed 5 years ago

VladimirIvan commented 5 years ago

This is an extension of #57 (excluding the security patches).

ferrolho commented 5 years ago

Testing this in Julia and something seems to be wrong with the transforms:

Screenshot from 2019-07-15 16-08-40

Tried a different model (UR5) and a similar thing happens:

Screenshot from 2019-07-15 16-12-57

VladimirIvan commented 5 years ago

Fixed. THREEJS sneakily modifies the matrix during multiplication so an explicit copy was missing and messing up the transforms.

tkoolen commented 5 years ago

I can confirm that this also works for https://github.com/tkoolen/universal-robot-dae-jl. Thanks, @VladimirIvan!

ferrolho commented 5 years ago

I can also confirm this is working. Tested universal-robot-dae-jl on https://github.com/JuliaRobotics/MeshCatMechanisms.jl/commit/398a8246ea3c1fde63e6dd20f394163d2581fb5f and https://github.com/rdeits/MeshCat.jl/commit/160933c0ae285384da15a9b653010f23046c137d with:

diff --git /deps/build.jl
-const meshcat_sha = "3122cecd5da022ad96bb0c8dc0f811a1bc492350"
-const meshcat_url = "https://github.com/rdeits/meshcat/archive/$meshcat_sha.zip"
+const meshcat_sha = "8e1afae6685e82e2e5c2a7607fa27a12575c5bde"
+const meshcat_url = "https://github.com/VladimirIvan/meshcat/archive/$meshcat_sha.zip"

Result

Screenshot from 2019-07-16 13-20-05

rdeits commented 5 years ago

This is excellent, thank you for the contribution! I'm sorry I've been slow to respond (ironically, all my open-source time has been sucked up by my preparations for JuliaCon), but I'll take a look at this right away.

rdeits commented 5 years ago

Hm, I'm getting errors with a couple of the test scenes. Could you try opening test/meshfile_object_obj.html in a browser and see if you get the same error? I'm seeing:

TypeError: sphere is undefined main.js line 601 > eval:5747:3
    copy three.module.js:5347
    intersectsObject three.module.js:5786
    projectObject three.module.js:22421
    projectObject three.module.js:22466
    projectObject three.module.js:22466
    projectObject three.module.js:22466
    render three.module.js:22224
    render index.js:769
    animate index.js:778
    animate index.js:775

Note that that file loads in the non-minified dist/main.js, so you'll need to ensure your npm run build is going so you get the up-to-date javascript sources.

VladimirIvan commented 5 years ago

The geometry wans't being extracted from the OBJ data structure the same way between _meshfile_object and _meshfile_geometry. Fixed now. Also, turns out that mesh merging was also required for OBJ to collect all the mesh groups. We always used single group meshes so we never found out.

I also fixed the material/texture loading via the resources parameter for DAE. The OBJ test is failing to load the material but it doesn't throw errors/warning anymore.

rdeits commented 5 years ago

Ok, merged! I also updated the OBJ object loading to preserve materials so that all of the tests now pass.