I’ve been playing around with some private VPS scans and wanted to be able to easily drop my downloaded mesh file into unity and treat it like any other model. Just for the sake of mocking up my 3D against it in editor or checking out the accuracy of the mesh without needing to localise.
@NNDev made a helpful post explaining how they’d used the tools supplied in the draco repo itself, but it all seemed a bit frustrating and limiting to use. So I wrote a scripted importer for the drc file type.
This means you can drop the unzipped drc file downloaded from the lightship dashboard directly into your project. It will generate the prefab and meshes ready for use.
Unity package downloadable here
The only requirements are that you have the draco plugins and use my slightly edited DracoMeshLoader
script - not the one as it comes from the draco repo.
All of that is included in the linked downloadable package.
I’ve only included the Windows and MacOS draco libraries there because I always intended to use this only as an importer while working in the editor.
The final thing to note is you’ll need to have allow unsafe code
enabled in your project settings.
For those that are interested (and so it’s documented somewhere) the edits I made to the DracoMeshLoader
from the original repo:
- It had a method called
UnityMeshToCamera
which re-centers the mesh around 0,0,0 and seems to apply some scaling. We don’t want this at all when dealing with lightship mesh because each scan looses it’s positioning relative to each other. Plus it takes our mesh out of the 1 unit to 1 meter scale we know and love in Unity. - Added a
RecalculateBounds
call on the mesh before it’s finished being processed - Removed the unnecessary logs
I hope this might help some others, let me know if there are any queries on it, or is anyone else can take it further.