{"id":18597846,"url":"https://github.com/liascript/vtk_template","last_synced_at":"2026-01-24T20:18:14.062Z","repository":{"id":114116597,"uuid":"180121323","full_name":"LiaScript/vtk_template","owner":"LiaScript","description":"At template for using VTK.js directly within LiaScript online courses.","archived":false,"fork":false,"pushed_at":"2019-04-08T11:08:24.000Z","size":6895,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-16T14:11:11.676Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LiaScript.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-08T10:01:23.000Z","updated_at":"2019-04-08T11:08:25.000Z","dependencies_parsed_at":"2023-06-13T09:30:21.474Z","dependency_job_id":null,"html_url":"https://github.com/LiaScript/vtk_template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LiaScript/vtk_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaScript%2Fvtk_template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaScript%2Fvtk_template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaScript%2Fvtk_template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaScript%2Fvtk_template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LiaScript","download_url":"https://codeload.github.com/LiaScript/vtk_template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LiaScript%2Fvtk_template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28736503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T19:23:36.361Z","status":"ssl_error","status_checked_at":"2026-01-24T19:23:28.966Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T01:29:37.458Z","updated_at":"2026-01-24T20:18:14.046Z","avatar_url":"https://github.com/LiaScript.png","language":null,"readme":"\u003c!--\nauthor:   André Dietrich\n\nemail:    andre.dietrich@ovgu.de\n\nversion:  0.0.1\n\nlanguage: en\n\nnarrator: US English Female\n\ncomment:  A set of templetes for VTK programming and visualization in LiaScript.\n\nscript:   https://unpkg.com/vtk.js\n\n@VTK.eval\n\u003cscript\u003e\ndocument.getElementById(\"@0\").innerHTML = \"\";\neval(`@input`);\n\u003c/script\u003e\n\n\u003cdiv id=\"@0\" style=\"height: 500px\"\u003e\u003c/div\u003e\n\n@end\n\n\n@VTK.run\n\u003cscript\u003e\ndocument.getElementById(\"@0\").innerHTML = \"\";\neval(`@1`);\n\u003c/script\u003e\n\n\u003cdiv id=\"@0\" style=\"height: 500px\"\u003e\u003c/div\u003e\n\n@end\n\n\n@VTK.load: @VTK._load_(@uid,`@0`)\n\n@VTK._load_\n\u003cscript\u003e\nvar vtkColorTransferFunction = vtk.Rendering.Core.vtkColorTransferFunction;\nvar vtkFullScreenRenderWindow = vtk.Rendering.Misc.vtkFullScreenRenderWindow;\nvar vtkHttpDataSetReader = vtk.IO.Core.vtkHttpDataSetReader;\nvar vtkPiecewiseFunction = vtk.Common.DataModel.vtkPiecewiseFunction;\nvar vtkVolume = vtk.Rendering.Core.vtkVolume;\nvar vtkVolumeMapper = vtk.Rendering.Core.vtkVolumeMapper;\n\nvar view = document.getElementById(\"vtk_@0\");\nview.innerHTML = \"\";\nvar fullScreenRenderer = vtk.Rendering.Misc.vtkFullScreenRenderWindow.newInstance({\n    rootContainer: view,\n    containerStyle: {\n        height: '100%',\n        overflow: 'hidden'\n    },\n    background: [0, 0, 0]\n});\n\nconst renderer = fullScreenRenderer.getRenderer();\nconst renderWindow = fullScreenRenderer.getRenderWindow();\n\nconst reader = vtkHttpDataSetReader.newInstance();\n\nconst actor = vtkVolume.newInstance();\nconst mapper = vtkVolumeMapper.newInstance();\nmapper.setSampleDistance(0.7);\nactor.setMapper(mapper);\n\nconst ctfun = vtkColorTransferFunction.newInstance();\nctfun.addRGBPoint(200.0, 0.4, 0.2, 0.0);\nctfun.addRGBPoint(2000.0, 1.0, 1.0, 1.0);\nconst ofun = vtkPiecewiseFunction.newInstance();\nofun.addPoint(200.0, 0.0);\nofun.addPoint(1200.0, 0.5);\nofun.addPoint(3000.0, 0.8);\nactor.getProperty().setRGBTransferFunction(0, ctfun);\nactor.getProperty().setScalarOpacity(0, ofun);\nactor.getProperty().setScalarOpacityUnitDistance(0, 4.5);\nactor.getProperty().setInterpolationTypeToLinear();\nactor.getProperty().setUseGradientOpacity(0, true);\nactor.getProperty().setGradientOpacityMinimumValue(0, 15);\nactor.getProperty().setGradientOpacityMinimumOpacity(0, 0.0);\nactor.getProperty().setGradientOpacityMaximumValue(0, 100);\nactor.getProperty().setGradientOpacityMaximumOpacity(0, 1.0);\nactor.getProperty().setShade(true);\nactor.getProperty().setAmbient(0.2);\nactor.getProperty().setDiffuse(0.7);\nactor.getProperty().setSpecular(0.3);\nactor.getProperty().setSpecularPower(8.0);\n\nmapper.setInputConnection(reader.getOutputPort());\n\nreader\n  .setUrl(\n    '@1',\n    { fullPath: true, compression: 'zip', loadData: true }\n  )\n  .then(() =\u003e {\n    renderer.addVolume(actor);\n    renderer.resetCamera();\n    renderer.getActiveCamera().zoom(1.5);\n    renderer.getActiveCamera().elevation(70);\n    renderer.updateLightsGeometryToFollowCamera();\n    renderWindow.render();\n  });\n\n\u003c/script\u003e\n\n\u003cdiv id=\"vtk_@0\" style=\"height: 500px\"\u003e\u003c/div\u003e\n\n@end\n\n--\u003e\n\n# VTK_template\n\n                                   --{{0}}--\nThis document defines some basic macros for applying\n[VTKjs](https://kitware.github.io/vtk-js/examples/) in\n[LiaScript](https://LiaScript.github.io), to make VTK programs in Markdown\nexecuteable and editable.\n\n__Try it on LiaScript:__\n\n\u003c!-- hidden = \"true\" --\u003e\n![demo](demo.gif)\n\nhttps://liascript.github.io/course/?https://raw.githubusercontent.com/liaScript/vtk_template/master/README.md\n\n__See the project on Github:__\n\nhttps://github.com/liaScript/vtk_template\n\n                                   --{{1}}--\nThere are three ways to use this template. The easiest way is to use the\n`import` statement and the url of the raw text-file of the master branch or any\nother branch or version. But you can also copy the required functionionality\ndirectly into the header of your Markdown document, see therefor the\n[last slide](#5). And of course, you could also clone this project and change\nit, as you wish.\n\n                                     {{1}}\n1. Load the macros via\n\n   `import: https://raw.githubusercontent.com/liaScript/vtk_template/master/README.md`\n\n2. Copy the definitions into your Project\n\n3. Clone this repository on GitHub\n\n\n## `VTK.eval`\n\n                                   --{{0}}--\nSimply attach the macro `VTK.eval` to your Markdown code-block to make it\nexecutable and editable. This macro requires only one parameter, the id of the\ndiv, that is inserted to be the target for the viewer. You will have to use this\nid in your script again, see line 1.\n\n```js\nvar view = document.getElementById(\"view_cone\");\nvar fullScreenRenderer = vtk.Rendering.Misc.vtkFullScreenRenderWindow.newInstance({\n    rootContainer: view,\n    containerStyle: {\n        height: '100%',\n        overflow: 'hidden'\n    },\n    background: [0, 0, 0]\n});\n\nvar actor  = vtk.Rendering.Core.vtkActor.newInstance();\nvar mapper = vtk.Rendering.Core.vtkMapper.newInstance();\nvar cone   = vtk.Filters.Sources.vtkConeSource.newInstance();\n\nactor.setMapper(mapper);\nmapper.setInputConnection(cone.getOutputPort());\n\nvar renderer = fullScreenRenderer.getRenderer();\nrenderer.addActor(actor);\nrenderer.resetCamera();\n\nvar renderWindow = fullScreenRenderer.getRenderWindow();\nrenderWindow.render();\n```\n@VTK.eval(view_cone)\n\n## `VTK.run`\n\n                                   --{{0}}--\nIf you only want to execute your VTK script, you can use the macro `VTK.run`\nwith the block notation. Simply add it to the head of the of the code-block\ntogether with the id of target div.\n\n```js @VTK.run(view_cone_2)\nvar view = document.getElementById(\"view_cone_2\");\nvar fullScreenRenderer = vtk.Rendering.Misc.vtkFullScreenRenderWindow.newInstance({\n    rootContainer: view,\n    containerStyle: {\n        height: '100%',\n        overflow: 'hidden'\n    },\n    background: [0, 0, 0]\n});\n\nvar actor  = vtk.Rendering.Core.vtkActor.newInstance();\nvar mapper = vtk.Rendering.Core.vtkMapper.newInstance();\nvar cone   = vtk.Filters.Sources.vtkConeSource.newInstance();\n\nactor.setMapper(mapper);\nmapper.setInputConnection(cone.getOutputPort());\n\nvar renderer = fullScreenRenderer.getRenderer();\nrenderer.addActor(actor);\nrenderer.resetCamera();\n\nvar renderWindow = fullScreenRenderer.getRenderWindow();\nrenderWindow.render();\n```\n\n## `VTK.load`\n\n\u003e __Note:__ This might take a while, to load and render the vti data set within the browser.\n\n@VTK.load(https://data.kitware.com/api/v1/file/58e665158d777f16d095fc2e/download)\n\n## Implementation\n\n                                   --{{0}}--\nThe code shows how the macros were implemented. For `@VTK.eval` and `.run` there\nare only basic substitution rules. In case of `@VTK.load` a hidden macro is\ndefined, which is called in the background. It includes only one JavaScript tag\nthat defines how the data from the URL resource gets loaded.\n\n``` html\nscript:   https://unpkg.com/vtk.js\n\n@VTK.eval\n\u003cscript\u003e\ndocument.getElementById(\"@0\").innerHTML = \"\";\neval(`@input`);\n\u003c/script\u003e\n\n\u003cdiv id=\"@0\" style=\"height: 500px\"\u003e\u003c/div\u003e\n\n@end\n\n\n@VTK.run\n\u003cscript\u003e\ndocument.getElementById(\"@0\").innerHTML = \"\";\neval(`@1`);\n\u003c/script\u003e\n\n\u003cdiv id=\"@0\" style=\"height: 500px\"\u003e\u003c/div\u003e\n\n@end\n\n\n@VTK.load: @VTK._load_(@uid,`@0`)\n\n@VTK._load_\n\u003cscript\u003e\nvar vtkColorTransferFunction = vtk.Rendering.Core.vtkColorTransferFunction;\nvar vtkFullScreenRenderWindow = vtk.Rendering.Misc.vtkFullScreenRenderWindow;\nvar vtkHttpDataSetReader = vtk.IO.Core.vtkHttpDataSetReader;\nvar vtkPiecewiseFunction = vtk.Common.DataModel.vtkPiecewiseFunction;\nvar vtkVolume = vtk.Rendering.Core.vtkVolume;\nvar vtkVolumeMapper = vtk.Rendering.Core.vtkVolumeMapper;\n\nvar view = document.getElementById(\"vtk_@0\");\nview.innerHTML = \"\";\nvar fullScreenRenderer = vtk.Rendering.Misc.vtkFullScreenRenderWindow.newInstance({\n    rootContainer: view,\n    containerStyle: {\n        height: '100%',\n        overflow: 'hidden'\n    },\n    background: [0, 0, 0]\n});\n\nconst renderer = fullScreenRenderer.getRenderer();\nconst renderWindow = fullScreenRenderer.getRenderWindow();\n\nconst reader = vtkHttpDataSetReader.newInstance();\n\nconst actor = vtkVolume.newInstance();\nconst mapper = vtkVolumeMapper.newInstance();\nmapper.setSampleDistance(0.7);\nactor.setMapper(mapper);\n\nconst ctfun = vtkColorTransferFunction.newInstance();\nctfun.addRGBPoint(200.0, 0.4, 0.2, 0.0);\nctfun.addRGBPoint(2000.0, 1.0, 1.0, 1.0);\nconst ofun = vtkPiecewiseFunction.newInstance();\nofun.addPoint(200.0, 0.0);\nofun.addPoint(1200.0, 0.5);\nofun.addPoint(3000.0, 0.8);\nactor.getProperty().setRGBTransferFunction(0, ctfun);\nactor.getProperty().setScalarOpacity(0, ofun);\nactor.getProperty().setScalarOpacityUnitDistance(0, 4.5);\nactor.getProperty().setInterpolationTypeToLinear();\nactor.getProperty().setUseGradientOpacity(0, true);\nactor.getProperty().setGradientOpacityMinimumValue(0, 15);\nactor.getProperty().setGradientOpacityMinimumOpacity(0, 0.0);\nactor.getProperty().setGradientOpacityMaximumValue(0, 100);\nactor.getProperty().setGradientOpacityMaximumOpacity(0, 1.0);\nactor.getProperty().setShade(true);\nactor.getProperty().setAmbient(0.2);\nactor.getProperty().setDiffuse(0.7);\nactor.getProperty().setSpecular(0.3);\nactor.getProperty().setSpecularPower(8.0);\n\nmapper.setInputConnection(reader.getOutputPort());\n\nreader\n  .setUrl(\n    '@1',\n    { fullPath: true, compression: 'zip', loadData: true }\n  )\n  .then(() =\u003e {\n    renderer.addVolume(actor);\n    renderer.resetCamera();\n    renderer.getActiveCamera().zoom(1.5);\n    renderer.getActiveCamera().elevation(70);\n    renderer.updateLightsGeometryToFollowCamera();\n    renderWindow.render();\n  });\n\u003c/script\u003e\n\n\u003cdiv id=\"vtk_@0\" style=\"height: 500px\"\u003e\u003c/div\u003e\n\n@end\n```\n\n                                   --{{1}}--\nIf you want to minimize loading effort in your LiaScript project, you can also\ncopy this code and paste it into your main comment header, see the code in the\nraw file of this document.\n\n{{1}} https://raw.githubusercontent.com/liaScript/vtk_template/master/README.md\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliascript%2Fvtk_template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliascript%2Fvtk_template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliascript%2Fvtk_template/lists"}