Skip to content

Commit 6c9b986

Browse files
sankheshfloryst
authored andcommitted
test(mapper2d): example for scalar coloring with Mapper2D
1 parent bdc7e01 commit 6c9b986

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Examples/Rendering/Actor2D/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,34 @@ mapper2D.setInputConnection(filter.getOutputPort());
8888
const c = vtkCoordinate.newInstance();
8989
c.setCoordinateSystemToWorld();
9090
mapper2D.setTransformCoordinate(c);
91-
mapper2D.setScalarVisibility(false);
91+
mapper2D.setScalarVisibility(true);
92+
mapper2D.setScalarMode(2);
93+
const mapper2 = vtkMapper2D.newInstance();
94+
mapper2.setInputConnection(coneSource.getOutputPort());
95+
mapper2.setTransformCoordinate(c);
96+
mapper2.setScalarVisibility(false);
9297

9398
const actor = vtkActor.newInstance();
9499
actor.setMapper(mapper);
100+
actor.getProperty().setRepresentationToWireframe();
95101
actor.getProperty().setEdgeVisibility(true);
96102
actor.getProperty().setEdgeColor([0.5, 0, 0.6]);
97103
actor.getProperty().setLineWidth(3);
98104
const actor2D = vtkActor2D.newInstance();
99105
actor2D.setMapper(mapper2D);
100106
actor2D.getProperty().setColor([1, 0, 0]);
101-
actor2D.getProperty().setOpacity(0.5);
107+
actor2D.getProperty().setOpacity(0.75);
102108
actor2D.getProperty().setLineWidth(3);
103109
actor2D.getProperty().setDisplayLocation(DisplayLocation.FOREGROUND);
104110
actor2D.getProperty().setRepresentation(Representation.SURFACE);
111+
const actor2 = vtkActor2D.newInstance();
112+
actor2.setMapper(mapper2);
113+
actor2.getProperty().setOpacity(0.3);
105114

106115
renderer.addActor(actor);
107116
renderer.addActor2D(actor2D);
117+
renderer.addActor2D(actor2);
118+
actor2D.setLayerNumber(2);
108119
renderer.resetCamera();
109120
renderWindow.render();
110121
fpsMonitor.update();

Sources/Rendering/Core/Actor2D/test/testActor2D.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test.onlyIfWebGL('Test Actor2D', (t) => {
4040

4141
const actor2D = gc.registerResource(vtkActor2D.newInstance());
4242
actor2D.getProperty().setColor([0.5, 0.8, 0]);
43-
actor2D.getProperty().setOpacity(0.3);
43+
actor2D.getProperty().setOpacity(0.5);
4444
actor2D.getProperty().setDisplayLocation(DisplayLocation.FOREGROUND);
4545
actor2D.getProperty().setRepresentation(Representation.SURFACE);
4646
actor2D.setLayerNumber(2);

Sources/Rendering/OpenGL/PolyDataMapper2D/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
350350
'//VTK::Color::Impl',
351351
colorImpl.concat([
352352
' diffuseColor = vertexColorVSOutput.rgb;',
353-
' ambientColor = vertexColorVSOutput.rgb;',
354353
' opacity = opacity*vertexColorVSOutput.a;',
355354
])
356355
).result;

0 commit comments

Comments
 (0)