xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
715 stars 286 forks source link

Can't fetch xkt file from api call #557

Closed vadimt2 closed 3 years ago

vadimt2 commented 3 years ago

When i'm trying to get it from the api with the same path, and i do get the file i get this issue: pako.js?ac9a:792 Uncaught incorrect header check `axios.get("./models/xkt/duplex/duplex.xkt").then((response) => { const blob = new Blob([response.data], { type: "application/*; charset=utf-8", }); const url = window.URL.createObjectURL(blob);

let duplex = xktLoader.load({ id: index + "", src: url, metaModelSrc: "./metaModels/duplex/metaModel.json", edges: true, saoEnabled: true, excludeUnclassifiedObjects: false, });`

When i'm using it hard coded with the path it's working: let duplex= xktLoader.load({ id: index + "", src: "./models/xkt/duplex/duplex.xkt", metaModelSrc: "./metaModels/duplex/metaModel.json", edges: true, saoEnabled: true, excludeUnclassifiedObjects: false, });

vadimt2 commented 3 years ago

If some one will have the same issue, this is the answer: ` fetch("./models/xkt/duplex/duplex.xkt").then(response => { // .then((body) => { // console.log(body); response.blob().then(function(myBlob) { console.log(myBlob);

  //     const blob = new Blob([response.url], {
  //   type: "application/*; charset=utf-8",
  // });
  const url = URL.createObjectURL(myBlob);

    xktLoader.load({
      id: "duplex",
      src: url,
      metaModelSrc: "./metaModels/duplex/metaModel.json",
      edges: true,
      saoEnabled: true,
      excludeUnclassifiedObjects: false,
    });
  });

`

and for axios: axios.get( "urlPath...", { responseType: 'blob' }) .then((myBlob) => { and make it straight to object url