Skip to content

Commit fce5d35

Browse files
Merge branch 'master' into vtkQuad
2 parents 83c1792 + b771c7d commit fce5d35

File tree

78 files changed

+2259
-825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2259
-825
lines changed

.github/workflows/build-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ jobs:
66
runs-on: ${{ matrix.os }}
77
strategy:
88
matrix:
9-
os: [ubuntu-18.04]
10-
node: [12, 14, 16]
9+
os: [ubuntu-20.04]
10+
node: [14, 16, 18]
1111
name: ${{ matrix.os }} and node ${{ matrix.node }}
1212
steps:
1313
- uses: actions/checkout@v2

.github/workflows/pr-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup node
1313
uses: actions/setup-node@v1
1414
with:
15-
node-version: 12
15+
node-version: 16
1616
- run: npm ci
1717
- name: Enforce code style
1818
run: npm run validate

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
publish:
1212
name: Publish
13-
runs-on: ubuntu-18.04
13+
runs-on: ubuntu-20.04
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v2
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup node
2020
uses: actions/setup-node@v1
2121
with:
22-
node-version: 14
22+
node-version: 16
2323
- name: Install dependencies
2424
run: |
2525
npm ci

Data/pbr/kiara_dawn_4k.jpg

1.6 MB
Loading

Documentation/content/docs/develop_webxr.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ vtk.js supports virtual and augmented reality rendering via the [WebXR device AP
4141
[![VR Cone Example][VrCone]](../examples/VR.html)
4242
[![SkyboxViewer Example][SkyboxViewerVR]](../examples/SkyboxViewer.html?fileURL=https://data.kitware.com/api/v1/file/5ae8a89c8d777f0685796bae/download)
4343
[![XR Volume Example][WebXRVolume]](../examples/WebXRVolume.html)
44+
[![XR Volumetric Example][HeadFullVolume]](../examples/WebXRHeadFullVolumeCVR.html)
45+
[![XR Hybrid Example][ChestCTHybrid]](../examples/WebXRChestCTBlendedCVR.html)
4446

4547
</div>
4648

@@ -53,6 +55,7 @@ vtk.js supports virtual and augmented reality rendering via the [WebXR device AP
5355
[![GeometryViewer Brain Blood Vessels][GeometryViewerBrainBloodVessels]](../examples/GeometryViewer/GeometryViewer.html?fileURL=[https://data.kitware.com/api/v1/file/61f041f14acac99f42c2ff9a/download,https://data.kitware.com/api/v1/file/61f042024acac99f42c2ffa6/download,https://data.kitware.com/api/v1/file/61f042b74acac99f42c30079/download])
5456
[![GeometryViewer Chest CT][GeometryViewerchestCT]](../examples/GeometryViewer/GeometryViewer.html?fileURL=[https://data.kitware.com/api/v1/file/61f044354acac99f42c30276/download,https://data.kitware.com/api/v1/file/61f0440f4acac99f42c30191/download,https://data.kitware.com/api/v1/file/61f044204acac99f42c30267/download])
5557
[![XR Volume Example][WebXRVolume]](../examples/WebXRVolume.html)
58+
[![XR Gradient Example][HeadGradient]](../examples/WebXRHeadGradientCVR.html)
5659

5760
</div>
5861

@@ -75,3 +78,6 @@ While WebXR has broad industry support, it is not yet implemented in all browser
7578
[SkyboxViewerVR]: ../docs/gallery/SkyboxViewerVR.jpg
7679
[VrCone]: ../docs/gallery/VrCone.jpg
7780
[WebXRVolume]: ../docs/gallery/WebXRVolume.png
81+
[HeadFullVolume]: ../docs/gallery/HeadFullVolume.png
82+
[ChestCTHybrid]: ../docs/gallery/ChestCTHybrid.png
83+
[HeadGradient]: ../docs/gallery/HeadGradient.png
1.36 MB
Loading
1 MB
Loading
1 MB
Loading

Examples/Applications/OBJViewer/index.js

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import 'vtk.js/Sources/favicon';
55
// Load the rendering pieces we want to use (for both WebGL and WebGPU)
66
import 'vtk.js/Sources/Rendering/Profiles/Geometry';
77

8-
import JSZip from 'jszip';
8+
import { strFromU8, unzipSync } from 'fflate';
99

1010
import macro from 'vtk.js/Sources/macros';
1111

1212
import HttpDataAccessHelper from 'vtk.js/Sources/IO/Core/DataAccessHelper/HttpDataAccessHelper';
1313
import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow';
1414
import vtkURLExtract from 'vtk.js/Sources/Common/Core/URLExtract';
15+
import { fromArrayBuffer } from 'vtk.js/Sources/Common/Core/Base64';
1516

1617
import vtkOBJReader from 'vtk.js/Sources/IO/Misc/OBJReader';
1718
import vtkMTLReader from 'vtk.js/Sources/IO/Misc/MTLReader';
@@ -50,17 +51,22 @@ function emptyContainer(container) {
5051
}
5152
}
5253

54+
function unpack(zipContent) {
55+
if (zipContent instanceof Blob) {
56+
return zipContent.arrayBuffer().then((ab) => new Uint8Array(ab));
57+
}
58+
if (zipContent instanceof ArrayBuffer) {
59+
return Promise.resolve(new Uint8Array(zipContent));
60+
}
61+
return Promise.reject(new Error('invalid zip content'));
62+
}
63+
5364
function loadZipContent(zipContent, renderWindow, renderer) {
5465
const fileContents = { obj: {}, mtl: {}, img: {} };
55-
const zip = new JSZip();
56-
zip.loadAsync(zipContent).then(() => {
57-
let workLoad = 0;
66+
unpack(zipContent).then((zipArrayBuffer) => {
67+
const decompressedFiles = unzipSync(new Uint8Array(zipArrayBuffer));
5868

5969
function done() {
60-
if (workLoad !== 0) {
61-
return;
62-
}
63-
6470
// Attach images to MTLs
6571
const promises = [];
6672
Object.keys(fileContents.mtl).forEach((mtlFilePath) => {
@@ -108,39 +114,29 @@ function loadZipContent(zipContent, renderWindow, renderer) {
108114
});
109115
}
110116

111-
zip.forEach((relativePath, zipEntry) => {
117+
Object.entries(decompressedFiles).forEach(([relativePath, fileData]) => {
112118
if (relativePath.match(/\.obj$/i)) {
113-
workLoad++;
114-
zipEntry.async('string').then((txt) => {
115-
const reader = vtkOBJReader.newInstance({ splitMode: 'usemtl' });
116-
reader.parseAsText(txt);
117-
fileContents.obj[relativePath] = reader;
118-
workLoad--;
119-
done();
120-
});
119+
const txt = strFromU8(fileData);
120+
const reader = vtkOBJReader.newInstance({ splitMode: 'usemtl' });
121+
reader.parseAsText(txt);
122+
fileContents.obj[relativePath] = reader;
121123
}
122124
if (relativePath.match(/\.mtl$/i)) {
123-
workLoad++;
124-
zipEntry.async('string').then((txt) => {
125-
const reader = vtkMTLReader.newInstance({
126-
interpolateTextures: !userParams.noInterpolation,
127-
});
128-
reader.parseAsText(txt);
129-
fileContents.mtl[relativePath] = reader;
130-
workLoad--;
131-
done();
125+
const txt = strFromU8(fileData);
126+
const reader = vtkMTLReader.newInstance({
127+
interpolateTextures: !userParams.noInterpolation,
132128
});
129+
reader.parseAsText(txt);
130+
fileContents.mtl[relativePath] = reader;
133131
}
134132
if (relativePath.match(/\.jpg$/i) || relativePath.match(/\.png$/i)) {
135-
workLoad++;
136-
zipEntry.async('base64').then((txt) => {
137-
const ext = relativePath.slice(-3).toLowerCase();
138-
fileContents.img[relativePath] = `data:image/${ext};base64,${txt}`;
139-
workLoad--;
140-
done();
141-
});
133+
const txt = fromArrayBuffer(fileData);
134+
const ext = relativePath.slice(-3).toLowerCase();
135+
fileContents.img[relativePath] = `data:image/${ext};base64,${txt}`;
142136
}
143137
});
138+
139+
done();
144140
});
145141
}
146142

Examples/Rendering/PBR/controller.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<p class='device_notification' style='color:red;'></p>
12
<table>
23
<h3>PBR Properties</h3>
34
<tr>
@@ -35,3 +36,33 @@ <h3>PBR Properties</h3>
3536
</td>
3637
</tr>
3738
</table>
39+
<table>
40+
<h3>Environment Properties</h3>
41+
<tr>
42+
<td>
43+
<label>Use Textured Background: </label>
44+
<input class='use_background' type='checkbox' checked='true'/>
45+
</td>
46+
</tr>
47+
<tr>
48+
<td>
49+
<label>Specular Strength: </label>
50+
<input class='e_specular' type='range' min='0.0' max='2.0' value='1.0' step='0.01' oninput="this.nextElementSibling.value = this.value"/>
51+
<output>1.00</output>
52+
</td>
53+
</tr>
54+
<tr>
55+
<td>
56+
<label>Diffuse Strength: </label>
57+
<input class='e_diffuse' type='range' min='0.0' max='2.0' value='1.0' step='0.01' oninput="this.nextElementSibling.value = this.value"/>
58+
<output>1.00</output>
59+
</td>
60+
</tr>
61+
<tr>
62+
<td>
63+
<label>FOV: </label>
64+
<input class='angle' type='range' min='30' max='120' value='30' step='1' oninput="this.nextElementSibling.value = this.value"/>
65+
<output>30</output>
66+
</td>
67+
</tr>
68+
</table>

0 commit comments

Comments
 (0)