viewer-javascript-offline.sample icon indicating copy to clipboard operation
viewer-javascript-offline.sample copied to clipboard

Pass SVF data directly in as String or Array Bugger

Open MrBlenny opened this issue 9 years ago • 5 comments

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

MrBlenny avatar Dec 15 '16 01:12 MrBlenny

The options.env = 'Local' is not officially supported therefore no documentation. You should pass in the url as options.document

shiya avatar Dec 15 '16 08:12 shiya

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?

MrBlenny avatar Dec 15 '16 09:12 MrBlenny

You can also download the entire translated file and reference the entry .svf like this sample.

shiya avatar Dec 15 '16 09:12 shiya

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.

MrBlenny avatar Dec 15 '16 09:12 MrBlenny

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.

shiya avatar Dec 19 '16 02:12 shiya