-
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(AxesActor): ability to invert axis
- Loading branch information
1 parent
5359685
commit ed1bc4c
Showing
3 changed files
with
138 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<table> | ||
<tr> | ||
<td>Center axis</td> | ||
<td> | ||
<input class="recenter" type="checkbox" checked /> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>X axis inversion</td> | ||
<td> | ||
<input class="xAxisInvert" type="checkbox" /> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Y axis inversion</td> | ||
<td> | ||
<input class="yAxisInvert" type="checkbox" /> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Z axis inversion</td> | ||
<td> | ||
<input class="zAxisInvert" type="checkbox" /> | ||
</td> | ||
</tr> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import '@kitware/vtk.js/favicon'; | ||
|
||
// Load the rendering pieces we want to use (for both WebGL and WebGPU) | ||
import '@kitware/vtk.js/Rendering/Profiles/Geometry'; | ||
|
||
import macro from '@kitware/vtk.js/macros'; | ||
import vtkAxesActor from 'vtk.js/Sources/Rendering/Core/AxesActor'; | ||
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow'; | ||
|
||
import controlPanel from './controlPanel.html'; | ||
|
||
console.warn( | ||
'Click on index.ts to open source code for this example --------->' | ||
); | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Standard rendering code setup | ||
// ---------------------------------------------------------------------------- | ||
|
||
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ | ||
background: [0.9, 0.9, 0.9], | ||
}); | ||
const renderer = fullScreenRenderer.getRenderer(); | ||
const renderWindow = fullScreenRenderer.getRenderWindow(); | ||
|
||
const axesActor = vtkAxesActor.newInstance(); | ||
renderer.addActor(axesActor); | ||
|
||
renderer.resetCamera(); | ||
renderWindow.render(); | ||
|
||
// ---------------------------------------------------------------------------- | ||
// UI control handling | ||
// ---------------------------------------------------------------------------- | ||
|
||
fullScreenRenderer.addController(controlPanel); | ||
|
||
function updateRendering() { | ||
axesActor.update(); | ||
renderer.resetCameraClippingRange(); | ||
renderWindow.render(); | ||
} | ||
|
||
document.querySelector('.recenter').addEventListener('change', (e) => { | ||
const config = axesActor.getConfig(); | ||
config.recenter = !!e.target.checked; | ||
axesActor.setConfig(config); | ||
updateRendering(); | ||
}); | ||
|
||
document.querySelector('.xAxisInvert').addEventListener('change', (e) => { | ||
axesActor.setXAxisInvert(!!e.target.checked); | ||
updateRendering(); | ||
}); | ||
|
||
document.querySelector('.yAxisInvert').addEventListener('change', (e) => { | ||
axesActor.setYAxisInvert(!!e.target.checked); | ||
updateRendering(); | ||
}); | ||
|
||
document.querySelector('.zAxisInvert').addEventListener('change', (e) => { | ||
axesActor.setZAxisInvert(!!e.target.checked); | ||
updateRendering(); | ||
}); | ||
|
||
// ----------------------------------------------------------- | ||
// Make some variables global so that you can inspect and | ||
// modify objects in your browser's developer console: | ||
// ----------------------------------------------------------- | ||
|
||
global.setLoggerFunction = macro.setLoggerFunction; | ||
global.axesActor = axesActor; | ||
global.renderer = renderer; | ||
global.renderWindow = renderWindow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters