We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Trying to use THREE.js OBJExporter in Verge3D App

Home Forums Programming Trying to use THREE.js OBJExporter in Verge3D App

Tagged: ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #51295
    carlsky
    Participant

    Hello!

    I am trying to implement .obj exporter in my Verge3D app.
    I have added this code to myawesomeapp.js runCode(app) function:
    https://gist.github.com/jcarletto27/35b19f811c657ec73b0238d78413f88d

    and created a Cube to test the exporter with this code in prepareExternalInterface(app) function:

    var geometry = new v3d.BoxGeometry(1, 1, 1);
    var material = new v3d.MeshBasicMaterial({ color: 0x00ff00 });
    var cube = new v3d.Mesh(geometry, material);
    app.scene.add(cube);
    		
    var exporter = new THREE.OBJExporter();
    console.log(exporter.parse( cube ));

    But the problem is, when I try to export the cube, the following error is encountered:

    Uncaught TypeError: Right-hand side of 'instanceof' is not an object
        at parseMesh (my_awesome_app.js:259:19)
        at my_awesome_app.js:546:7
        at Hi.traverse (v3d.js:1:73935)
        at Ws.traverse (v3d.js:1:74001)
        at THREE.OBJExporter.parse (my_awesome_app.js:542:12)
        at my_awesome_app.js:210:26
        at Ws.traverse (v3d.js:1:73935)
        at app.ExternalInterface.myJSFunction (my_awesome_app.js:209:14)
        at HTMLButtonElement.<anonymous> (visual_logic.js:1577:32)

    Do you know what am I doing wrong ?
    Greetings,
    KK

    #51499

    Hi,

    The exporter script you linked is a bit outdated since it references THREE.Geometry which was removed from Three.js and is not available in Verge3D too. You can use this version of OBJExporter instead: https://github.com/Soft8Soft/verge3d-code-examples/blob/master/js/exporters/OBJExporter.js

    Co-founder and lead developer at Soft8Soft.

    #51507
    carlsky
    Participant

    Ok, it works, but not with morphing.
    Does someone has an OBJExporter code that works with morphing ?
    Or the only way is to write it by myself ?

    Thank you anyway :)
    СПАСИБО

    #51665

    The OBJ format itself doesn’t support morphing. So, you need to use a workaround for that. For example, you can try to export your model several times: as a base shape (all keys set to 0) and as a single morph shape (with the respective key set to 1) – that way you’ll get several obj files that represent morphing. And you also need to think about combining them somehow depending on what you want to use them for.

    Co-founder and lead developer at Soft8Soft.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.