Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import macro from 'vtk.js/Sources/macros';
import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor';
import vtkMapper from 'vtk.js/Sources/Rendering/Core/Mapper';
import vtkAbstractRepresentationProxy from 'vtk.js/Sources/Proxy/Core/AbstractRepresentationProxy';
const PROPERTIES_STATE = {
representation: {
'Surface with edges': {
property: { edgeVisibility: true, representation: 2 },
},
Surface: { property: { edgeVisibility: false, representation: 2 } },
Wireframe: { property: { edgeVisibility: false, representation: 1 } },
Points: { property: { edgeVisibility: false, representation: 0 } },
},
};
const PROPERTIES_DEFAULT = {
representation: 'Surface',
};
// ----------------------------------------------------------------------------
// vtkGeometryRepresentationProxy methods
// ----------------------------------------------------------------------------
function vtkGeometryRepresentationProxy(publicAPI, model) {
// Set our className
model.classHierarchy.push('vtkGeometryRepresentationProxy');
// Internals
model.mapper = vtkMapper.newInstance({
interpolateScalarsBeforeMapping: true,
useLookupTableScalarRange: true,
scalarVisibility: false,
});
model.actor = vtkActor.newInstance();
model.property = model.actor.getProperty();
// Auto connect mappers
model.sourceDependencies.push(model.mapper);
// connect rendering pipeline
model.actor.setMapper(model.mapper);
model.actors.push(model.actor);
}
// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
const DEFAULT_VALUES = {
representation: 'Surface',
};
// ----------------------------------------------------------------------------
export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
// Object methods
vtkAbstractRepresentationProxy.extend(publicAPI, model, initialValues);
// Object specific methods
vtkGeometryRepresentationProxy(publicAPI, model);
// Map proxy properties
macro.proxyPropertyState(
publicAPI,
model,
PROPERTIES_STATE,
PROPERTIES_DEFAULT
);
macro.proxyPropertyMapping(publicAPI, model, {
opacity: { modelKey: 'property', property: 'opacity' },
visibility: { modelKey: 'actor', property: 'visibility' },
color: { modelKey: 'property', property: 'diffuseColor' },
interpolateScalarsBeforeMapping: {
modelKey: 'mapper',
property: 'interpolateScalarsBeforeMapping',
},
pointSize: { modelKey: 'property', property: 'pointSize' },
useShadow: { modelKey: 'property', property: 'lighting' },
lineWidth: { modelKey: 'property', property: 'lineWidth' },
useBounds: { modelKey: 'actor', property: 'useBounds' },
});
}
// ----------------------------------------------------------------------------
export const newInstance = macro.newInstance(
extend,
'vtkGeometryRepresentationProxy'
);
// ----------------------------------------------------------------------------
export default { newInstance, extend };
|