Skip to content

Commit a8f2911

Browse files
committed
fix(PBR): enable PBR with setInterpolationToPBR
1 parent 5508c8d commit a8f2911

19 files changed

Lines changed: 228 additions & 219 deletions

File tree

Examples/Rendering/PBR/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ import vtkOBJReader from '@kitware/vtk.js/IO/Misc/OBJReader';
1010
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
1111
import vtkTexture from '@kitware/vtk.js/Rendering/Core/Texture';
1212
import vtkPolyDataNormals from '@kitware/vtk.js/Filters/Core/PolyDataNormals';
13-
13+
import vtkProperty from '@kitware/vtk.js/Rendering/Core/Property';
1414
import vtkFPSMonitor from '@kitware/vtk.js/Interaction/UI/FPSMonitor';
15-
1615
import GUI from 'lil-gui';
1716

17+
const { Shading } = vtkProperty;
18+
1819
// ----------------------------------------------------------------------------
1920
// Standard rendering code setup
2021
// ----------------------------------------------------------------------------
@@ -108,6 +109,7 @@ reader.setUrl(`${__BASE_PATH__}/data/pbr/helmet.obj`).then(async () => {
108109

109110
// Setting default values
110111
actor.setPosition(0.0, 0.0, 0.0);
112+
actor.getProperty().setInterpolation(Shading.PBR);
111113
actor.getProperty().setRoughness(1.0);
112114
actor.getProperty().setEmission(0.6);
113115
actor.getProperty().setMetallic(1.0);

Sources/Common/Core/AnimationCue/test/testAnimationCue.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import test from 'tape';
2-
import vtkAnimationCue from '../index';
3-
import { CueState } from '../Constants';
2+
import vtkAnimationCue from 'vtk.js/Sources/Common/Core/AnimationCue';
43

54
test('vtkAnimationCue: Basic instantiation', (t) => {
65
const cue = vtkAnimationCue.newInstance();

Sources/Common/Core/AnimationMixer/test/testAnimationMixer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ test('vtkAnimationMixer: Non-skeletal animation bindings', (t) => {
2626

2727
const registered = mixer.setAnimationBinding(
2828
'custom',
29-
[animation],
3029
(updates, context) => {
3130
applied.push({ updates, context });
32-
}
31+
},
32+
[animation]
3333
);
3434

3535
t.ok(registered);
@@ -67,10 +67,10 @@ test('vtkAnimationMixer: Uses the first animation only', (t) => {
6767

6868
const registered = mixer.setAnimationBinding(
6969
'selected',
70-
[animation1, animation2],
7170
(updates, context) => {
7271
applied.push({ updates, context });
73-
}
72+
},
73+
[animation1, animation2]
7474
);
7575

7676
t.ok(registered);

Sources/Common/Core/AnimationScene/test/testAnimationScene.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'tape';
2-
import vtkAnimationCue from '../../AnimationCue/index';
3-
import vtkAnimationScene from '../index';
2+
import vtkAnimationCue from 'vtk.js/Sources/Common/Core/AnimationCue';
3+
import vtkAnimationScene from 'vtk.js/Sources/Common/Core/AnimationScene';
44

55
test('vtkAnimationScene: Basic instantiation', (t) => {
66
const scene = vtkAnimationScene.newInstance();

Sources/Common/DataModel/AnimationClip/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ function vtkAnimationClip(publicAPI, model) {
3434

3535
// Recalculate duration
3636
model.duration = 0;
37-
for (const track of model.tracks) {
37+
model.tracks.forEach((track) => {
3838
if (track.getDuration() > model.duration) {
3939
model.duration = track.getDuration();
4040
}
41-
}
41+
});
4242

4343
publicAPI.modified();
4444
}
@@ -74,7 +74,8 @@ function vtkAnimationClip(publicAPI, model) {
7474
* @return {vtkAnimationTrack | null}
7575
*/
7676
publicAPI.getTrackByName = (name) => {
77-
for (const track of model.tracks) {
77+
for (let i = 0; i < model.tracks.length; i++) {
78+
const track = model.tracks[i];
7879
if (track.getName() === name) {
7980
return track;
8081
}

Sources/Common/DataModel/AnimationClip/test/testAnimationClip.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import test from 'tape';
22
import vtkAnimationTrack from 'vtk.js/Sources/Common/DataModel/AnimationTrack';
33
import vtkAnimationClip from 'vtk.js/Sources/Common/DataModel/AnimationClip';
4-
import {
5-
TrackType,
6-
InterpolationMode,
7-
} from 'vtk.js/Sources/Common/DataModel/AnimationTrack/Constants';
4+
import { TrackType } from 'vtk.js/Sources/Common/DataModel/AnimationTrack/Constants';
85

96
test('vtkAnimationClip: Basic instantiation', (t) => {
107
const clip = vtkAnimationClip.newInstance();

Sources/Common/DataModel/Armature/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -562,14 +562,14 @@ function vtkArmature(publicAPI, model) {
562562

563563
for (let ti = 0; ti < tracks.length; ti++) {
564564
const track = tracks[ti];
565-
if (track.getBoneIndex() !== i) continue;
565+
if (track.getBoneIndex() === i) {
566+
const trackType = track.getTrackType();
567+
const value = track.evaluate(time);
566568

567-
const trackType = track.getTrackType();
568-
const value = track.evaluate(time);
569-
570-
if (trackType === 0) t = value;
571-
else if (trackType === 1) r = value;
572-
else if (trackType === 2) s = value;
569+
if (trackType === 0) t = value;
570+
else if (trackType === 1) r = value;
571+
else if (trackType === 2) s = value;
572+
}
573573
}
574574

575575
const offset = i * 16;

Sources/Filters/Sources/ArmatureSource/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ function vtkArmatureSource(publicAPI, model) {
4747
const lines = vtkCellArray.newInstance();
4848

4949
// Generate joint points and bone links
50-
let lineCount = 0;
5150
for (let i = 0; i < boneCount; i++) {
5251
const bone = skeleton.getBone(i);
5352
const parentIdx = bone.parentIndex;
@@ -62,7 +61,6 @@ function vtkArmatureSource(publicAPI, model) {
6261
// If has parent, draw line from parent to this bone
6362
if (parentIdx !== -1) {
6463
lines.insertNextCell([parentIdx, i]);
65-
lineCount++;
6664
}
6765
}
6866

0 commit comments

Comments
 (0)