Home › Forums › Programming › Trying to use THREE.js OBJExporter in Verge3D App
- This topic has 3 replies, 2 voices, and was last updated 3 years, 7 months ago by
Ivan Lyubovnikov.
-
AuthorPosts
-
2022-04-23 at 11:07 am #51295
carlsky
ParticipantHello!
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/35b19f811c657ec73b0238d78413f88dand 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,
KK2022-04-29 at 2:05 pm #51499
Ivan LyubovnikovStaffHi,
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.
2022-04-29 at 7:37 pm #51507carlsky
ParticipantOk, 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 :)
СПАСИБО2022-05-04 at 2:58 pm #51665
Ivan LyubovnikovStaffThe 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.
-
AuthorPosts
- You must be logged in to reply to this topic.
