diff --git a/Examples/Volume/VolumeMapperLightAndShadow/index.js b/Examples/Volume/VolumeMapperLightAndShadow/index.js index 8fadc10aaec..832670993eb 100644 --- a/Examples/Volume/VolumeMapperLightAndShadow/index.js +++ b/Examples/Volume/VolumeMapperLightAndShadow/index.js @@ -13,7 +13,6 @@ import HttpDataAccessHelper from '@kitware/vtk.js/IO/Core/DataAccessHelper/HttpD import vtkVolumeController from '@kitware/vtk.js/Interaction/UI/VolumeController'; import vtkBoundingBox from '@kitware/vtk.js/Common/DataModel/BoundingBox'; import vtkFPSMonitor from '@kitware/vtk.js/Interaction/UI/FPSMonitor'; -import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData'; import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor'; import vtkSphereSource from '@kitware/vtk.js/Filters/Sources/SphereSource'; @@ -87,18 +86,6 @@ function createVolumeShadowViewer(rootContainer, fileContents) { actor.setMapper(mapper); mapper.addInputData(source); - for (let i = 0; i < 0; ++i) { - const otherImageData = vtkImageData.newInstance(); - otherImageData.setPointData(source.getPointData()); - otherImageData.setDimensions(...source.getDimensions()); - otherImageData.setSpacing(...source.getSpacing()); - otherImageData.setOrigin(...source.getOrigin()); - otherImageData.setDirection(...source.getDirection()); - otherImageData.setOrigin(...[120 * (i + 1), 0, 0]); - mapper.addInputData(otherImageData); - actor.setProperty(actorProperty, 1 + i); - } - // Add one positional light const bounds = actor.getBounds(); const center = vtkBoundingBox.getCenter(bounds); diff --git a/Sources/Rendering/Core/ImageSlice/index.d.ts b/Sources/Rendering/Core/ImageSlice/index.d.ts index 70f1eec0cea..71e3466a68f 100755 --- a/Sources/Rendering/Core/ImageSlice/index.d.ts +++ b/Sources/Rendering/Core/ImageSlice/index.d.ts @@ -35,16 +35,6 @@ export interface vtkImageSlice extends vtkProp3D { */ getIsOpaque(): boolean; - /** - * - */ - getProperty(): vtkImageProperty; - - /** - * - */ - getProperties(): vtkImageProperty[]; - /** * */ @@ -123,19 +113,6 @@ export interface vtkImageSlice extends vtkProp3D { */ setMapper(mapper: vtkAbstractImageMapper): boolean; - /** - * - * @param {vtkImageProperty} property The vtkImageProperty instance. - */ - setProperty(property: vtkImageProperty): boolean; - - /** - * Set the actor properties array - * Each element of the array corresponds to a mapper input port - * @param {vtkImageProperty[]} properties - */ - setProperties(properties: vtkImageProperty[]): boolean; - /** * * @param {boolean} forceOpaque If true, render during opaque pass even if opacity value is below 1.0. @@ -147,6 +124,13 @@ export interface vtkImageSlice extends vtkProp3D { * @param {boolean} forceTranslucent If true, render during translucent pass even if opacity value is 1.0. */ setForceTranslucent(forceTranslucent: boolean): boolean; + + // Inherited from vtkProp3D, but takes a vtkImageProperty instead of a generic vtkObject + getProperty(mapperInputPort?: number): vtkImageProperty; + getProperties(): vtkImageProperty[]; + setProperty(mapperInputPort: number, property: vtkImageProperty): boolean; + setProperty(property: vtkImageProperty): boolean; + setProperties(properties: vtkImageProperty[]): boolean; } /** diff --git a/Sources/Rendering/Core/Prop3D/index.js b/Sources/Rendering/Core/Prop3D/index.js index 6abb5b65909..a35aeb8a9f9 100644 --- a/Sources/Rendering/Core/Prop3D/index.js +++ b/Sources/Rendering/Core/Prop3D/index.js @@ -238,7 +238,15 @@ function vtkProp3D(publicAPI, model) { return model.properties[mapperInputPort]; }; - publicAPI.setProperty = (property, mapperInputPort = 0) => { + publicAPI.setProperty = (firstArg, secondArg) => { + // Two options for argument layout: + // - (mapperInputPort, property) + // - (property) + const useInputPortArgument = Number.isInteger(firstArg); + const [mapperInputPort, property] = useInputPortArgument + ? [firstArg, secondArg] + : [0, firstArg]; + if (model.properties[mapperInputPort] === property) { return false; } diff --git a/Sources/Rendering/Core/Volume/index.d.ts b/Sources/Rendering/Core/Volume/index.d.ts index d1de3a75137..395a596e171 100755 --- a/Sources/Rendering/Core/Volume/index.d.ts +++ b/Sources/Rendering/Core/Volume/index.d.ts @@ -29,18 +29,6 @@ export interface vtkVolume extends vtkProp3D { */ getVolumes(): vtkVolume[]; - /** - * Get the volume property for the specified mapper input port, which defaults to 0 - * @param {number} mapperInputPort Defaults to 0 - */ - getProperty(mapperInputPort?: number): vtkVolumeProperty; - - /** - * Get the volume properties array - * Each element of the array corresponds to a mapper input port - */ - getProperties(): vtkVolumeProperty[]; - /** * Get the `Modified Time` which is a monotonic increasing integer * global for all vtkObjects. @@ -71,18 +59,11 @@ export interface vtkVolume extends vtkProp3D { */ setMapper(mapper: vtkVolumeMapper): boolean; - /** - * Set the volume property for the specified mapper input port, which defaults to 0 - * @param {vtkVolumeProperty} property - * @param {number} mapperInputPort Defaults to 0 - */ - setProperty(property: vtkVolumeProperty, mapperInputPort?: number): boolean; - - /** - * Set the volume properties array - * Each element of the array corresponds to a mapper input port - * @param {vtkVolumeProperty[]} properties - */ + // Inherited from vtkProp3D, but takes a vtkVolumeProperty instead of a generic vtkObject + getProperty(mapperInputPort?: number): vtkVolumeProperty; + getProperties(): vtkVolumeProperty[]; + setProperty(mapperInputPort: number, property: vtkVolumeProperty): boolean; + setProperty(property: vtkVolumeProperty): boolean; setProperties(properties: vtkVolumeProperty[]): boolean; } diff --git a/Sources/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js b/Sources/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js index d36122e7040..b7a03f3df76 100644 --- a/Sources/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js +++ b/Sources/Rendering/OpenGL/RenderWindow/resourceSharingHelper.js @@ -11,7 +11,10 @@ export function getTransferFunctionHash( } export function getImageDataHash(image, scalars) { - return `${image.getMTime()}A${scalars.getMTime()}`; + // Don't use the image data, as the scalars will define the texture + // If using the image data in the hash, it will cause issues when two image data + // using the same scalars are in the same mapper (for example the VolumeMapper) + return `${scalars.getMTime()}`; } export default { getTransferFunctionHash, getImageDataHash };