Pass SVF data directly in as String or Array Bugger
Is it possible to directly pass in svf data as a string or array buffer (instead of setting document to a url)?
For example:
http({
url: 'http://developer-autodesk.github.io/translated-models/shaver/0.svf',
responseType: 'arraybuffer'
}).then(response => {
const viewer = new Autodesk.Viewing.Private.GuiViewer3D(this.refs.cadCanvas);
console.log(response.data);
const options = {
'env' : 'Local',
'document' : response.data
};
Autodesk.Viewing.Initializer(options, function() {
viewer.start(options.document, options);
});
})
Unfortunately I could not find any documentation on options.env = 'Local' here
The options.env = 'Local' is not officially supported therefore no documentation.
You should pass in the url as options.document
So there is no way to pass in the data directly? Passing a url is not really an option in my use case 😢
Are there any other workarounds? Maybe something like a blob-url would work?
You can also download the entire translated file and reference the entry .svf like this sample.
I cannot reference a local file or a url in my application.
I was hoping I could use a blob url (as follows)
http({
url: 'http://developer-autodesk.github.io/translated-models/shaver/0.svf',
responseType: 'blob'
}).then(response => {
const viewer = new Autodesk.Viewing.Private.GuiViewer3D(this.refs.cadCanvas);
const blobUrl = URL.createObjectURL(response.data);
const options = {
'env' : 'Local',
'document' : blobUrl
};
Autodesk.Viewing.Initializer(options, function() {
viewer.start(options.document, options);
});
})
Unfortunately, this throws an error.
Uncaught TypeError: l is not a constructor
e.loadModel @ viewer3D.min.js?v=v2.10:27
a.loadModel @ viewer3D.min.js?v=v2.10:29
e.start @ viewer3D.min.js?v=v2.10:27
(anonymous function) @ AutodeskLocalViewer.jsx?9ecd:18
I suppose I will have to modify the source code to allow the passing in of data directly if it is not already possible.
Would you share with us your solution when you do? Honestly don't think we've thought of making it possible to not pass in an url.