@kitware/vtk.js 28.3.0 → 28.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Rendering/Core/Mapper.js
CHANGED
|
@@ -56,6 +56,12 @@ function vtkMapper(publicAPI, model) {
|
|
|
56
56
|
model.forceCompileOnly = v; // make sure we do NOT call modified()
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
publicAPI.setSelectionWebGLIdsToVTKIds = function (selectionWebGLIdsToVTKIds) {
|
|
60
|
+
model.selectionWebGLIdsToVTKIds = selectionWebGLIdsToVTKIds; // make sure we do NOT call modified()
|
|
61
|
+
// this attribute is only used when processing a selection made with the hardware selector
|
|
62
|
+
// the mtime of the mapper doesn't need to be changed
|
|
63
|
+
};
|
|
64
|
+
|
|
59
65
|
publicAPI.createDefaultLookupTable = function () {
|
|
60
66
|
model.lookupTable = vtkLookupTable.newInstance();
|
|
61
67
|
};
|
|
@@ -565,8 +571,8 @@ function extend(publicAPI, model) {
|
|
|
565
571
|
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
566
572
|
|
|
567
573
|
vtkAbstractMapper3D.extend(publicAPI, model, initialValues);
|
|
568
|
-
macro.get(publicAPI, model, ['colorCoordinates', 'colorMapColors', 'colorTextureMap']);
|
|
569
|
-
macro.setGet(publicAPI, model, ['colorByArrayName', 'arrayAccessMode', 'colorMode', 'fieldDataTupleId', 'interpolateScalarsBeforeMapping', 'lookupTable', 'populateSelectionSettings', 'renderTime', 'scalarMode', 'scalarVisibility', '
|
|
574
|
+
macro.get(publicAPI, model, ['colorCoordinates', 'colorMapColors', 'colorTextureMap', 'selectionWebGLIdsToVTKIds']);
|
|
575
|
+
macro.setGet(publicAPI, model, ['colorByArrayName', 'arrayAccessMode', 'colorMode', 'fieldDataTupleId', 'interpolateScalarsBeforeMapping', 'lookupTable', 'populateSelectionSettings', 'renderTime', 'scalarMode', 'scalarVisibility', 'static', 'useLookupTableScalarRange', 'customShaderAttributes' // point data array names that will be transferred to the VBO
|
|
570
576
|
]);
|
|
571
577
|
macro.setGetArray(publicAPI, model, ['scalarRange'], 2);
|
|
572
578
|
CoincidentTopologyHelper.implementCoincidentTopologyMethods(publicAPI, model); // Object methods
|
|
@@ -212,7 +212,7 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
212
212
|
sstring = ['vec3 diffuseL = vec3(0,0,0);', ' vec3 specularL = vec3(0,0,0);', ' float df;'];
|
|
213
213
|
|
|
214
214
|
for (var _lc = 0; _lc < lastLightCount; ++_lc) {
|
|
215
|
-
sstring = sstring.concat([" df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC".concat(_lc, "));"), " diffuseL += ((df".concat(shadowFactor, ") * lightColor").concat(_lc, ");"), " if (dot(normalVCVSOutput, lightDirectionVC".concat(_lc, ") < 0.0)"), ' {', " float sf = pow(
|
|
215
|
+
sstring = sstring.concat([" df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC".concat(_lc, "));"), " diffuseL += ((df".concat(shadowFactor, ") * lightColor").concat(_lc, ");"), " if (dot(normalVCVSOutput, lightDirectionVC".concat(_lc, ") < 0.0)"), ' {', " float sf = sign(df)*pow(max(1e-5,\n dot(reflect(lightDirectionVC".concat(_lc, ",normalVCVSOutput),\n normalize(-vertexVC.xyz))),\n specularPower);"), " specularL += (sf".concat(shadowFactor, " * lightColor").concat(_lc, ");"), ' }']);
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
sstring = sstring.concat([' diffuseL = diffuseL * diffuseColor;', ' specularL = specularL * specularColor;', ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);', ' //VTK::Light::Impl']);
|
|
@@ -229,7 +229,7 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
229
229
|
sstring = ['vec3 diffuseL = vec3(0,0,0);', ' vec3 specularL = vec3(0,0,0);', ' vec3 vertLightDirectionVC;', ' float attenuation;', ' float df;'];
|
|
230
230
|
|
|
231
231
|
for (var _lc3 = 0; _lc3 < lastLightCount; ++_lc3) {
|
|
232
|
-
sstring = sstring.concat([' attenuation = 1.0;', " if (lightPositional".concat(_lc3, " == 0)"), ' {', " vertLightDirectionVC = lightDirectionVC".concat(_lc3, ";"), ' }', ' else', ' {', " vertLightDirectionVC = vertexVC.xyz - lightPositionVC".concat(_lc3, ";"), ' float distanceVC = length(vertLightDirectionVC);', ' vertLightDirectionVC = normalize(vertLightDirectionVC);', ' attenuation = 1.0 /', " (lightAttenuation".concat(_lc3, ".x"), " + lightAttenuation".concat(_lc3, ".y * distanceVC"), " + lightAttenuation".concat(_lc3, ".z * distanceVC * distanceVC);"), ' // per OpenGL standard cone angle is 90 or less for a spot light', " if (lightConeAngle".concat(_lc3, " <= 90.0)"), ' {', " float coneDot = dot(vertLightDirectionVC, lightDirectionVC".concat(_lc3, ");"), ' // if inside the cone', " if (coneDot >= cos(radians(lightConeAngle".concat(_lc3, ")))"), ' {', " attenuation = attenuation * pow(coneDot, lightExponent".concat(_lc3, ");"), ' }', ' else', ' {', ' attenuation = 0.0;', ' }', ' }', ' }', ' df = max(0.0, attenuation*dot(normalVCVSOutput, -vertLightDirectionVC));', " diffuseL += ((df".concat(shadowFactor, ") * lightColor").concat(_lc3, ");"), ' if (dot(normalVCVSOutput, vertLightDirectionVC) < 0.0)', ' {', " float sf = attenuation*pow(
|
|
232
|
+
sstring = sstring.concat([' attenuation = 1.0;', " if (lightPositional".concat(_lc3, " == 0)"), ' {', " vertLightDirectionVC = lightDirectionVC".concat(_lc3, ";"), ' }', ' else', ' {', " vertLightDirectionVC = vertexVC.xyz - lightPositionVC".concat(_lc3, ";"), ' float distanceVC = length(vertLightDirectionVC);', ' vertLightDirectionVC = normalize(vertLightDirectionVC);', ' attenuation = 1.0 /', " (lightAttenuation".concat(_lc3, ".x"), " + lightAttenuation".concat(_lc3, ".y * distanceVC"), " + lightAttenuation".concat(_lc3, ".z * distanceVC * distanceVC);"), ' // per OpenGL standard cone angle is 90 or less for a spot light', " if (lightConeAngle".concat(_lc3, " <= 90.0)"), ' {', " float coneDot = dot(vertLightDirectionVC, lightDirectionVC".concat(_lc3, ");"), ' // if inside the cone', " if (coneDot >= cos(radians(lightConeAngle".concat(_lc3, ")))"), ' {', " attenuation = attenuation * pow(coneDot, lightExponent".concat(_lc3, ");"), ' }', ' else', ' {', ' attenuation = 0.0;', ' }', ' }', ' }', ' df = max(0.0, attenuation*dot(normalVCVSOutput, -vertLightDirectionVC));', " diffuseL += ((df".concat(shadowFactor, ") * lightColor").concat(_lc3, ");"), ' if (dot(normalVCVSOutput, vertLightDirectionVC) < 0.0)', ' {', " float sf = sign(df)*attenuation*pow(max(1e-5,\n dot(reflect(lightDirectionVC".concat(_lc3, ",\n normalVCVSOutput),\n normalize(-vertexVC.xyz))),\n specularPower);"), " specularL += ((sf".concat(shadowFactor, ") * lightColor").concat(_lc3, ");"), ' }']);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
sstring = sstring.concat([' diffuseL = diffuseL * diffuseColor;', ' specularL = specularL * specularColor;', ' gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);', ' //VTK::Light::Impl']);
|
|
@@ -768,13 +768,9 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
768
768
|
model.lightDirection[0] = newLightDirection[0];
|
|
769
769
|
model.lightDirection[1] = newLightDirection[1];
|
|
770
770
|
model.lightDirection[2] = newLightDirection[2];
|
|
771
|
-
model.lightHalfAngle[0] = -model.lightDirection[0];
|
|
772
|
-
model.lightHalfAngle[1] = -model.lightDirection[1];
|
|
773
|
-
model.lightHalfAngle[2] = -model.lightDirection[2] + 1.0;
|
|
774
771
|
normalize(model.lightDirection);
|
|
775
772
|
program.setUniform3fArray("lightColor".concat(numberOfLights), model.lightColor);
|
|
776
773
|
program.setUniform3fArray("lightDirectionVC".concat(numberOfLights), model.lightDirection);
|
|
777
|
-
program.setUniform3fArray("lightHalfAngleVC".concat(numberOfLights), model.lightHalfAngle);
|
|
778
774
|
numberOfLights++;
|
|
779
775
|
}
|
|
780
776
|
} // we are done unless we have positional lights
|
|
@@ -1257,8 +1253,6 @@ var DEFAULT_VALUES = {
|
|
|
1257
1253
|
// used internally
|
|
1258
1254
|
lightColor: [],
|
|
1259
1255
|
// used internally
|
|
1260
|
-
lightHalfAngle: [],
|
|
1261
|
-
// used internally
|
|
1262
1256
|
lightDirection: [],
|
|
1263
1257
|
// used internally
|
|
1264
1258
|
lastHaveSeenDepthRequest: false,
|