Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/rodrigobasilio2022/vtk-js
Browse files Browse the repository at this point in the history
…into feat/VolumePicker
  • Loading branch information
rodrigobasilio2022 committed Oct 27, 2023
2 parents 1839b16 + d61d2e4 commit 4f1d762
Show file tree
Hide file tree
Showing 42 changed files with 535 additions and 810 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04]
node: [14, 16, 18]
node: [18, 20]
name: ${{ matrix.os }} and node ${{ matrix.node }}
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 20
- run: npm ci
- name: Enforce code style
run: npm run validate
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 20
- name: Install dependencies
run: |
npm ci
Expand Down
7 changes: 7 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## From 28.x to 29

- **getOpenGLRenderWindow**: `getOpenGLRenderWindow` has been renamed to `getApiSpecificRenderWindow` in `vtkFullScreenRenderWindow`, `vtkGenericRenderWindow` and `vtkViewProxy` to support WebGL and WebGPU backend. ([#2816](https://github.com/Kitware/vtk-js/pull/2816))
- **WidgetManager**: Deprecated APIs have been fully removed. ([#2910](https://github.com/Kitware/vtk-js/pull/2910))
- **OpenGLRenderWindow**: WebXR API has been moved into a WebXR RenderWindowHelper. ([#2924](https://github.com/Kitware/vtk-js/pull/2924))
- **DistanceWidget**: Removed from vtk.js in favor of vtkLineWidget ([#2945](https://github.com/Kitware/vtk-js/pull/2945))

## From 27.x to 28

- **vtkManipulator.handleEvent**: Change all `handleEvent` signatures of manipulators. Used to be `handleEvent(callData, glRenderWindow): vec3`, it is now `handleEvent(callData, glRenderWindow): { worldCoords: Nullable<vec3>, worldDirection?: mat3 }`.
Expand Down
15 changes: 9 additions & 6 deletions Examples/Applications/GeometryViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import vtkScalarBarActor from '@kitware/vtk.js/Rendering/Core/ScalarBarActor';
import vtkColorMaps from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps';
import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkWebXRRenderWindowHelper from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
import vtkURLExtract from '@kitware/vtk.js/Common/Core/URLExtract';
import vtkXMLPolyDataReader from '@kitware/vtk.js/IO/XML/XMLPolyDataReader';
import vtkFPSMonitor from '@kitware/vtk.js/Interaction/UI/FPSMonitor';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/OpenGL/RenderWindow/Constants';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper/Constants';

// Force DataAccessHelper to have access to various data source
import '@kitware/vtk.js/IO/Core/DataAccessHelper/HtmlDataAccessHelper';
Expand All @@ -36,6 +37,7 @@ let autoInit = true;
let background = [0, 0, 0];
let fullScreenRenderWindow;
let renderWindow;
let xrRenderWindowHelper;
let renderer;
let scalarBarActor;

Expand Down Expand Up @@ -162,6 +164,9 @@ function createViewer(container) {
});
renderer = fullScreenRenderWindow.getRenderer();
renderWindow = fullScreenRenderWindow.getRenderWindow();
xrRenderWindowHelper = vtkWebXRRenderWindowHelper.newInstance({
renderWindow: fullScreenRenderWindow.getApiSpecificRenderWindow(),
});
renderWindow.getInteractor().setDesiredUpdateRate(15);

container.appendChild(rootControllerContainer);
Expand Down Expand Up @@ -252,7 +257,7 @@ function createPipeline(fileName, fileContents) {

if (
navigator.xr !== undefined &&
fullScreenRenderWindow.getApiSpecificRenderWindow().getXrSupported() &&
xrRenderWindowHelper.getXrSupported() &&
requestedXrSessionType !== null
) {
controlContainer.appendChild(immersionSelector);
Expand Down Expand Up @@ -431,17 +436,15 @@ function createPipeline(fileName, fileContents) {

function toggleXR() {
if (immersionSelector.textContent.startsWith('Start')) {
fullScreenRenderWindow
.getApiSpecificRenderWindow()
.startXR(requestedXrSessionType);
xrRenderWindowHelper.startXR(requestedXrSessionType);
immersionSelector.textContent = [
XrSessionTypes.HmdAR,
XrSessionTypes.MobileAR,
].includes(requestedXrSessionType)
? 'Exit AR'
: 'Exit VR';
} else {
fullScreenRenderWindow.getApiSpecificRenderWindow().stopXR();
xrRenderWindowHelper.stopXR();
immersionSelector.textContent = [
XrSessionTypes.HmdAR,
XrSessionTypes.MobileAR,
Expand Down
17 changes: 10 additions & 7 deletions Examples/Applications/SkyboxViewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import HttpDataAccessHelper from '@kitware/vtk.js/IO/Core/DataAccessHelper/HttpD
import macro from '@kitware/vtk.js/macros';
import vtkDeviceOrientationToCamera from '@kitware/vtk.js/Interaction/Misc/DeviceOrientationToCamera';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkWebXRRenderWindowHelper from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper';
import vtkSkybox from '@kitware/vtk.js/Rendering/Core/Skybox';
import vtkSkyboxReader from '@kitware/vtk.js/IO/Misc/SkyboxReader';
import vtkURLExtract from '@kitware/vtk.js/Common/Core/URLExtract';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/OpenGL/RenderWindow/Constants';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper/Constants';

// Force DataAccessHelper to have access to various data source
import '@kitware/vtk.js/IO/Core/DataAccessHelper/HtmlDataAccessHelper';
Expand Down Expand Up @@ -157,6 +158,9 @@ function createVisualization(container, mapReader) {
containerStyle: { height: '100%', width: '100%', position: 'absolute' },
});
const renderWindow = fullScreenRenderer.getRenderWindow();
const xrRenderWindowHelper = vtkWebXRRenderWindowHelper.newInstance({
renderWindow: fullScreenRenderer.getApiSpecificRenderWindow(),
});
const mainRenderer = fullScreenRenderer.getRenderer();
const interactor = fullScreenRenderer.getInteractor();
const actor = vtkSkybox.newInstance();
Expand Down Expand Up @@ -202,6 +206,7 @@ function createVisualization(container, mapReader) {
// add vr option button if supported
if (
navigator.xr !== undefined &&
xrRenderWindowHelper.getXrSupported() &&
navigator.xr.isSessionSupported('immersive-vr')
) {
const button = document.createElement('button');
Expand All @@ -213,12 +218,10 @@ function createVisualization(container, mapReader) {
document.querySelector('body').appendChild(button);
button.addEventListener('click', () => {
if (button.textContent === 'Send To VR') {
fullScreenRenderer
.getApiSpecificRenderWindow()
.startXR(XrSessionTypes.HmdVR);
xrRenderWindowHelper.startXR(XrSessionTypes.HmdVR);
button.textContent = 'Return From VR';
} else {
fullScreenRenderer.getApiSpecificRenderWindow().stopXR();
xrRenderWindowHelper.stopXR();
button.textContent = 'Send To VR';
}
});
Expand Down Expand Up @@ -270,8 +273,8 @@ function createVisualization(container, mapReader) {
}

if (grid) {
console.log(fullScreenRenderer.getOpenGLRenderWindow().getSize());
createGrid(...fullScreenRenderer.getOpenGLRenderWindow().getSize());
console.log(fullScreenRenderer.getApiSpecificRenderWindow().getSize());
createGrid(...fullScreenRenderer.getApiSpecificRenderWindow().getSize());
}
}

Expand Down
16 changes: 8 additions & 8 deletions Examples/Geometry/AR/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import vtkCalculator from '@kitware/vtk.js/Filters/General/Calculator';
import vtkConeSource from '@kitware/vtk.js/Filters/Sources/ConeSource';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkWebXRRenderWindowHelper from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
import vtkURLExtract from '@kitware/vtk.js/Common/Core/URLExtract';
import { AttributeTypes } from '@kitware/vtk.js/Common/DataModel/DataSetAttributes/Constants';
import { FieldDataTypes } from '@kitware/vtk.js/Common/DataModel/DataSet/Constants';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/OpenGL/RenderWindow/Constants';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper/Constants';

// Force DataAccessHelper to have access to various data source
import '@kitware/vtk.js/IO/Core/DataAccessHelper/HtmlDataAccessHelper';
Expand All @@ -36,6 +37,9 @@ const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
});
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
const xrRenderWindowHelper = vtkWebXRRenderWindowHelper.newInstance({
renderWindow: fullScreenRenderer.getApiSpecificRenderWindow(),
});

// ----------------------------------------------------------------------------
// Example code
Expand Down Expand Up @@ -87,18 +91,14 @@ renderWindow.render();

fullScreenRenderer.addController(controlPanel);
const arbutton = document.querySelector('.arbutton');
arbutton.disabled = !fullScreenRenderer
.getApiSpecificRenderWindow()
.getXrSupported();
arbutton.disabled = !xrRenderWindowHelper.getXrSupported();

arbutton.addEventListener('click', (e) => {
if (arbutton.textContent === 'Start AR') {
fullScreenRenderer
.getApiSpecificRenderWindow()
.startXR(requestedXrSessionType);
xrRenderWindowHelper.startXR(requestedXrSessionType);
arbutton.textContent = 'Exit AR';
} else {
fullScreenRenderer.getApiSpecificRenderWindow().stopXR();
xrRenderWindowHelper.stopXR();
arbutton.textContent = 'Start AR';
}
});
Expand Down
12 changes: 7 additions & 5 deletions Examples/Geometry/LookingGlass/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import vtkCalculator from '@kitware/vtk.js/Filters/General/Calculator';
import vtkConeSource from '@kitware/vtk.js/Filters/Sources/ConeSource';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkWebXRRenderWindowHelper from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
import { AttributeTypes } from '@kitware/vtk.js/Common/DataModel/DataSetAttributes/Constants';
import { FieldDataTypes } from '@kitware/vtk.js/Common/DataModel/DataSet/Constants';
import { XrSessionTypes } from 'vtk.js/Sources/Rendering/OpenGL/RenderWindow/Constants';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper/Constants';

// Force DataAccessHelper to have access to various data source
import '@kitware/vtk.js/IO/Core/DataAccessHelper/HtmlDataAccessHelper';
Expand Down Expand Up @@ -42,6 +43,9 @@ const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
});
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
const xrRenderWindowHelper = vtkWebXRRenderWindowHelper.newInstance({
renderWindow: fullScreenRenderer.getApiSpecificRenderWindow(),
});

// ----------------------------------------------------------------------------
// Example code
Expand Down Expand Up @@ -110,12 +114,10 @@ resolutionChange.addEventListener('input', (e) => {

vrbutton.addEventListener('click', (e) => {
if (vrbutton.textContent === 'Send To Looking Glass') {
fullScreenRenderer
.getApiSpecificRenderWindow()
.startXR(XrSessionTypes.LookingGlassVR);
xrRenderWindowHelper.startXR(XrSessionTypes.LookingGlassVR);
vrbutton.textContent = 'Return From Looking Glass';
} else {
fullScreenRenderer.getApiSpecificRenderWindow().stopXR();
xrRenderWindowHelper.stopXR();
vrbutton.textContent = 'Send To Looking Glass';
}
});
Expand Down
12 changes: 7 additions & 5 deletions Examples/Geometry/VR/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import vtkCalculator from '@kitware/vtk.js/Filters/General/Calculator';
import vtkConeSource from '@kitware/vtk.js/Filters/Sources/ConeSource';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkWebXRRenderWindowHelper from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
import { AttributeTypes } from '@kitware/vtk.js/Common/DataModel/DataSetAttributes/Constants';
import { FieldDataTypes } from '@kitware/vtk.js/Common/DataModel/DataSet/Constants';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/OpenGL/RenderWindow/Constants';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper/Constants';

// Force DataAccessHelper to have access to various data source
import '@kitware/vtk.js/IO/Core/DataAccessHelper/HtmlDataAccessHelper';
Expand Down Expand Up @@ -46,6 +47,9 @@ const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
});
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
const XRHelper = vtkWebXRRenderWindowHelper.newInstance({
renderWindow: fullScreenRenderer.getApiSpecificRenderWindow(),
});

// ----------------------------------------------------------------------------
// Example code
Expand Down Expand Up @@ -114,12 +118,10 @@ resolutionChange.addEventListener('input', (e) => {

vrbutton.addEventListener('click', (e) => {
if (vrbutton.textContent === 'Send To VR') {
fullScreenRenderer
.getApiSpecificRenderWindow()
.startXR(XrSessionTypes.HmdVR);
XRHelper.startXR(XrSessionTypes.HmdVR);
vrbutton.textContent = 'Return From VR';
} else {
fullScreenRenderer.getApiSpecificRenderWindow().stopXR();
XRHelper.stopXR();
vrbutton.textContent = 'Send To VR';
}
});
Expand Down
15 changes: 8 additions & 7 deletions Examples/Volume/WebXRChestCTBlendedCVR/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '@kitware/vtk.js/IO/Core/DataAccessHelper/JSZipDataAccessHelper';

import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkWebXRRenderWindowHelper from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper';
import HttpDataAccessHelper from '@kitware/vtk.js/IO/Core/DataAccessHelper/HttpDataAccessHelper';
import vtkPiecewiseFunction from '@kitware/vtk.js/Common/DataModel/PiecewiseFunction';
import vtkURLExtract from '@kitware/vtk.js/Common/Core/URLExtract';
Expand All @@ -18,7 +19,7 @@ import vtkVolumeMapper from '@kitware/vtk.js/Rendering/Core/VolumeMapper';
import vtkXMLImageDataReader from '@kitware/vtk.js/IO/XML/XMLImageDataReader';
import vtkImageReslice from '@kitware/vtk.js/Imaging/Core/ImageReslice';
import vtkMath from '@kitware/vtk.js/Common/Core/Math';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/OpenGL/RenderWindow/Constants';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper/Constants';

import './WebXRVolume.module.css';

Expand All @@ -32,6 +33,9 @@ const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
});
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
const xrRenderWindowHelper = vtkWebXRRenderWindowHelper.newInstance({
renderWindow: fullScreenRenderer.getApiSpecificRenderWindow(),
});

// ----------------------------------------------------------------------------
// Set up pipeline objects
Expand Down Expand Up @@ -118,10 +122,7 @@ HttpDataAccessHelper.fetchBinary(fileURL).then((fileContents) => {
let enterText = 'XR not available!';
const exitText = 'Exit XR';
xrButton.textContent = enterText;
if (
navigator.xr !== undefined &&
fullScreenRenderer.getApiSpecificRenderWindow().getXrSupported()
) {
if (navigator.xr !== undefined && xrRenderWindowHelper.getXrSupported()) {
navigator.xr.isSessionSupported('immersive-ar').then((arSupported) => {
if (arSupported) {
xrSessionType = XrSessionTypes.MobileAR;
Expand All @@ -140,10 +141,10 @@ HttpDataAccessHelper.fetchBinary(fileURL).then((fileContents) => {
}
xrButton.addEventListener('click', () => {
if (xrButton.textContent === enterText) {
fullScreenRenderer.getApiSpecificRenderWindow().startXR(xrSessionType);
xrRenderWindowHelper.startXR(xrSessionType);
xrButton.textContent = exitText;
} else {
fullScreenRenderer.getApiSpecificRenderWindow().stopXR();
xrRenderWindowHelper.stopXR();
xrButton.textContent = enterText;
}
});
Expand Down
17 changes: 8 additions & 9 deletions Examples/Volume/WebXRHeadFullVolumeCVR/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '@kitware/vtk.js/IO/Core/DataAccessHelper/JSZipDataAccessHelper';

import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkWebXRRenderWindowHelper from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper';
import HttpDataAccessHelper from '@kitware/vtk.js/IO/Core/DataAccessHelper/HttpDataAccessHelper';
import vtkPiecewiseFunction from '@kitware/vtk.js/Common/DataModel/PiecewiseFunction';
import vtkURLExtract from '@kitware/vtk.js/Common/Core/URLExtract';
Expand All @@ -18,7 +19,7 @@ import vtkVolumeMapper from '@kitware/vtk.js/Rendering/Core/VolumeMapper';
import vtkXMLImageDataReader from '@kitware/vtk.js/IO/XML/XMLImageDataReader';
import vtkImageReslice from '@kitware/vtk.js/Imaging/Core/ImageReslice';
import vtkMath from '@kitware/vtk.js/Common/Core/Math';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/OpenGL/RenderWindow/Constants';
import { XrSessionTypes } from '@kitware/vtk.js/Rendering/WebXR/RenderWindowHelper/Constants';

import './WebXRVolume.module.css';

Expand All @@ -32,6 +33,9 @@ const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
});
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
const xrRenderWindowHelper = vtkWebXRRenderWindowHelper.newInstance({
renderWindow: fullScreenRenderer.getApiSpecificRenderWindow(),
});

// ----------------------------------------------------------------------------
// Set up pipeline objects
Expand Down Expand Up @@ -149,10 +153,7 @@ HttpDataAccessHelper.fetchBinary(fileURL).then((fileContents) => {
let enterText = 'XR not available!';
const exitText = 'Exit XR';
xrButton.textContent = enterText;
if (
navigator.xr !== undefined &&
fullScreenRenderer.getApiSpecificRenderWindow().getXrSupported()
) {
if (navigator.xr !== undefined && xrRenderWindowHelper.getXrSupported()) {
enterText =
requestedXrSessionType === XrSessionTypes.MobileAR
? 'Start AR'
Expand All @@ -161,12 +162,10 @@ HttpDataAccessHelper.fetchBinary(fileURL).then((fileContents) => {
}
xrButton.addEventListener('click', () => {
if (xrButton.textContent === enterText) {
fullScreenRenderer
.getApiSpecificRenderWindow()
.startXR(requestedXrSessionType);
xrRenderWindowHelper.startXR(requestedXrSessionType);
xrButton.textContent = exitText;
} else {
fullScreenRenderer.getApiSpecificRenderWindow().stopXR();
xrRenderWindowHelper.stopXR();
xrButton.textContent = enterText;
}
});
Expand Down
Loading

0 comments on commit 4f1d762

Please sign in to comment.