使用vtk.js预构建的脚本文件来构建我们的第一个应用程序。
新建vtk.html文件,写入以下内容:
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript" src="https://unpkg.com/@babel/polyfill@7.0.0/dist/polyfill.js"></script>
<script type="text/javascript" src="https://unpkg.com/vtk.js"></script>
<script type="text/javascript">
// --------------------------------------------------------------------------
// Example code
// --------------------------------------------------------------------------
var fullScreenRenderer = vtk.Rendering.Misc.vtkFullScreenRenderWindow.newInstance();
console.log(JSON.stringify(fullScreenRenderer))
var actor = vtk.Rendering.Core.vtkActor.newInstance();
console.log(JSON.stringify(actor))
var mapper = vtk.Rendering.Core.vtkMapper.newInstance();
console.log(JSON.stringify(mapper))
var cone = vtk.Filters.Sources.vtkConeSource.newInstance();
console.log(JSON.stringify(cone))
actor.setMapper(mapper);
mapper.setInputConnection(cone.getOutputPort());
var renderer = fullScreenRenderer.getRenderer();
renderer.addActor(actor);
renderer.resetCamera();
var renderWindow = fullScreenRenderer.getRenderWindow();
renderWindow.render();
</script>
</body>
</html>
保存 运行vtk.html 如下图所示