msub2 / silk-brush-2021

An effort to port Tilt Brush to WebXR.
Apache License 2.0
47 stars 5 forks source link

Sketch exporting #11

Closed msub2 closed 3 years ago

msub2 commented 3 years ago

Get gltf export working

msub2 commented 3 years ago

Seems like by default it'll try to export a gltf file, which is good, but it's missing a reference to the exportManifest in the Support folder

User-visible error: glTF export failed
Detail: Could not find a part of the path "/http:/Support/exportManifest.json".
UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:LogFormat(LogType, String, Object[])
UnityEngine.Debug:LogErrorFormat(String, Object[])
TiltBrush.OutputWindowScript:Error(ControllerName, String, Object)
TiltBrush.OutputWindowScript:Error(String, Object)
TiltBrush.ExportGlTF:ExportHelper(SceneStatePayload, String, Boolean, Boolean, Int32, Boolean)
TiltBrush.ExportGlTF:ExportBrushStrokes(String, AxisConvention, Boolean, Boolean, Boolean, Int32, Boolean)
TiltBrush.Export:ExportScene()
TiltBrush.<>c:<ExportCoroutine>b__309_0()
System.Action:Invoke()
TiltBrush.<AsCoroutine>d__42:MoveNext()
TiltBrush.<RunInCompositor>d__36:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
msub2 commented 3 years ago

Moved the Support folder to Resources and am using Resources.Load to grab the exportManifest, export now seems to be completing successfully. Next step is to somehow retrieve the exported file from IndexedDB.

msub2 commented 3 years ago

Finally exported a sketch in browser by getting the contents.buffer of the IndexedDB key for the file! Just needs to be put into a .jslib and called during the export process now.

msub2 commented 3 years ago

Need to try iterating with cursor to list stores at export time and search for our sketch

Event {isTrusted: true, type: "success", target: IDBRequest, currentTarget: IDBRequest, eventPhase: 2, …}
bubbles: false
cancelBubble: false
cancelable: false
composed: false
currentTarget: null
defaultPrevented: false
eventPhase: 0
isTrusted: true
path: []
returnValue: true
srcElement: IDBRequest {result: IDBCursorWithValue, error: null, source: IDBObjectStore, transaction: IDBTransaction, readyState: "done", …}
target: IDBRequest
error: null
onerror: null
onsuccess: ƒ (event)
readyState: "done"
result: IDBCursorWithValue
direction: "next"
key: "/idbfs/3fc9fd88b57f147258ef6113e42e775c"
primaryKey: "/idbfs/3fc9fd88b57f147258ef6113e42e775c"
request: IDBRequest {result: IDBCursorWithValue, error: null, source: IDBObjectStore, transaction: IDBTransaction, readyState: "done", …}
source: IDBObjectStore {name: "FILE_DATA", keyPath: null, indexNames: DOMStringList, transaction: IDBTransaction, autoIncrement: false}
value: {timestamp: Mon Feb 08 2021 04:07:24 GMT-0500 (Eastern Standard Time), mode: 16877}
__proto__: IDBCursorWithValue
source: IDBObjectStore {name: "FILE_DATA", keyPath: null, indexNames: DOMStringList, transaction: IDBTransaction, autoIncrement: false}
transaction: IDBTransaction {objectStoreNames: DOMStringList, mode: "readonly", db: IDBDatabase, error: null, onabort: null, …}
__proto__: IDBRequest
timeStamp: 452703.8500001654
type: "success"
__proto__: Event
msub2 commented 3 years ago

Apparently the solution was to wait a few seconds for IDB before trying to access the model. Basic export is now working, any further work will be tracked in separate issues

msub2 commented 3 years ago

And of course after leaving it for a few days and rebuilding with no changes to the export code, it no longer works. Back to the drawing board I guess. Will look into implementing browserfs and seeing if it's more stable

msub2 commented 3 years ago

It looks like it's technically still working, just that the original method seems to be inconsistent.

msub2 commented 3 years ago

Added exported models to files page on site as a backup if download fails