Kitware / vtk-js

Visualization Toolkit for the Web
https://kitware.github.io/vtk-js/
BSD 3-Clause "New" or "Revised" License
1.23k stars 371 forks source link

How to achieve vtkjs convert stl #2956

Open CHONGE opened 11 months ago

CHONGE commented 11 months ago

Feature Request

HttpDataAccessHelper.fetchBinary( ${__BASE_PATH__}/data/StanfordOil.vtkjs, {} ).then((zipContent) => { const dataAccessHelper = DataAccessHelper.get('zip', { zipContent, callback: (zip) => { // 读取自己数据 // writerReader.parseAsArrayBuffer(zip); // maps.byteLength = maps.buffer.byteLength; const sceneImporter = vtkHttpSceneLoader.newInstance({ renderer, dataAccessHelper, });

  sceneImporter.setUrl('index.json');
  sceneImporter.onReady(() => {
    console.log(sceneImporter.getScene());
    sceneImporter.getScene()[0].actor.setVisibility(false);
    const source = sceneImporter.getScene()[0].source;
    cutter.setInputConnection(source.getOutputPort());
    cubeMapper.setInputConnection(source.getOutputPort());
    renderer.resetCamera();
    updatePlaneFunction();
  });
  const blob = new Blob([zipContent],{type:'application/octet-steam' });
  const a = window.document.createElement('a');
  a.href = window.URL.createObjectURL(blob, {
    type: 'application/octet-steam',
  });
  a.download = 'test.stl';
  a.text = 'Download';
  a.style.position = 'absolute';
  a.style.left = '50%';
  a.style.bottom = '10px';
  document.body.appendChild(a);
  a.style.background = 'white';
  a.style.padding = '5px';
},

}); });

Motivation and Detailed Description

The exported stl file format is incorrect,Ask for help, thanks

daker commented 10 months ago

hello, this is not the correct way to export to STL format, you need to use STLWriter