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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | 1x 1524x 762x 762x 29x 3x 3x 3x 3x 3x 26x 24x 24x 24x 24x 29x 29x 29x 762x 762x 762x 2x 2x 2x 2x 2x 762x 762x 762x 762x 762x 762x 2x 762x 762x 762x 1x 762x 762x 762x 762x 762x 1x | import macro from 'vtk.js/Sources/macros'; import Constants from 'vtk.js/Sources/Rendering/Core/Property/Constants'; const { Representation, Interpolation } = Constants; function notImplemented(method) { return () => macro.vtkErrorMacro(`vtkProperty::${method} - NOT IMPLEMENTED`); } // ---------------------------------------------------------------------------- // vtkProperty methods // ---------------------------------------------------------------------------- function vtkProperty(publicAPI, model) { // Set our className model.classHierarchy.push('vtkProperty'); publicAPI.setColor = (r, g, b) => { if (Array.isArray(r)) { if ( model.color[0] !== r[0] || model.color[1] !== r[1] || model.color[2] !== r[2] ) { model.color[0] = r[0]; model.color[1] = r[1]; model.color[2] = r[2]; publicAPI.modified(); } } else if ( model.color[0] !== r || model.color[1] !== g || model.color[2] !== b ) { model.color[0] = r; model.color[1] = g; model.color[2] = b; publicAPI.modified(); } publicAPI.setDiffuseColor(model.color); publicAPI.setAmbientColor(model.color); publicAPI.setSpecularColor(model.color); }; publicAPI.computeCompositeColor = notImplemented('ComputeCompositeColor'); publicAPI.getColor = () => { // Inline computeCompositeColor let norm = 0.0; if (model.ambient + model.diffuse + model.specular > 0) { norm = 1.0 / (model.ambient + model.diffuse + model.specular); } for (let i = 0; i < 3; i++) { model.color[i] = norm * (model.ambient * model.ambientColor[i] + model.diffuse * model.diffuseColor[i] + model.specular * model.specularColor[i]); } return [].concat(model.color); }; publicAPI.setSpecularPower = (specularPower) => { const roughness = 1 / Math.max(1.0, specularPower); if ( model.roughness !== roughness || model.specularPower !== specularPower ) { model.specularPower = specularPower; // Specular power still needs to be set as long as webgl is using it (otherwise testShaderReplacementsClear fails) model.roughness = roughness; publicAPI.modified(); } }; publicAPI.addShaderVariable = notImplemented('AddShaderVariable'); publicAPI.setInterpolationToFlat = () => publicAPI.setInterpolation(Interpolation.FLAT); publicAPI.setInterpolationToGouraud = () => publicAPI.setInterpolation(Interpolation.GOURAUD); publicAPI.setInterpolationToPhong = () => publicAPI.setInterpolation(Interpolation.PHONG); publicAPI.getInterpolationAsString = () => macro.enumToString(Interpolation, model.interpolation); publicAPI.setRepresentationToWireframe = () => publicAPI.setRepresentation(Representation.WIREFRAME); publicAPI.setRepresentationToSurface = () => publicAPI.setRepresentation(Representation.SURFACE); publicAPI.setRepresentationToPoints = () => publicAPI.setRepresentation(Representation.POINTS); publicAPI.getRepresentationAsString = () => macro.enumToString(Representation, model.representation); } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- const DEFAULT_VALUES = { color: [1, 1, 1], ambientColor: [1, 1, 1], diffuseColor: [1, 1, 1], specularColor: [1, 1, 1], edgeColor: [0, 0, 0], ambient: 0, diffuse: 1, metallic: 0, roughness: 0.6, normalStrength: 1, emission: 1, baseIOR: 1.45, specular: 0, specularPower: 1, opacity: 1, interpolation: Interpolation.GOURAUD, representation: Representation.SURFACE, edgeVisibility: false, backfaceCulling: false, frontfaceCulling: false, pointSize: 1, lineWidth: 1, lighting: true, shading: false, materialName: null, }; // ---------------------------------------------------------------------------- export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); macro.setGet(publicAPI, model, [ 'lighting', 'interpolation', 'ambient', 'diffuse', 'metallic', 'roughness', 'normalStrength', 'emission', 'baseIOR', 'specular', 'specularPower', 'opacity', 'edgeVisibility', 'lineWidth', 'pointSize', 'backfaceCulling', 'frontfaceCulling', 'representation', 'diffuseTexture', 'metallicTexture', 'roughnessTexture', 'normalTexture', 'ambientOcclusionTexture', 'emissionTexture', ]); macro.setGetArray( publicAPI, model, ['ambientColor', 'specularColor', 'diffuseColor', 'edgeColor'], 3 ); // Object methods vtkProperty(publicAPI, model); } // ---------------------------------------------------------------------------- export const newInstance = macro.newInstance(extend, 'vtkProperty'); // ---------------------------------------------------------------------------- export default { newInstance, extend, ...Constants }; |