Best JavaScript code snippet using backstopjs
PolylineShadowVolumeVS.js
Source:PolylineShadowVolumeVS.js
1//This file is automatically rebuilt by the Cesium build process.2define(function() {3 'use strict';4 return "attribute vec3 position3DHigh;\n\5attribute vec3 position3DLow;\n\6\n\7// In 2D and in 3D, texture coordinate normalization component signs encodes:\n\8// * X sign - sidedness relative to right plane\n\9// * Y sign - is negative OR magnitude is greater than 1.0 if vertex is on bottom of volume\n\10#ifndef COLUMBUS_VIEW_2D\n\11attribute vec4 startHiAndForwardOffsetX;\n\12attribute vec4 startLoAndForwardOffsetY;\n\13attribute vec4 startNormalAndForwardOffsetZ;\n\14attribute vec4 endNormalAndTextureCoordinateNormalizationX;\n\15attribute vec4 rightNormalAndTextureCoordinateNormalizationY;\n\16#else\n\17attribute vec4 startHiLo2D;\n\18attribute vec4 offsetAndRight2D;\n\19attribute vec4 startEndNormals2D;\n\20attribute vec2 texcoordNormalization2D;\n\21#endif\n\22\n\23attribute float batchId;\n\24\n\25varying vec4 v_startPlaneNormalEcAndHalfWidth;\n\26varying vec4 v_endPlaneNormalEcAndBatchId;\n\27varying vec4 v_rightPlaneEC;\n\28varying vec4 v_endEcAndStartEcX;\n\29varying vec4 v_texcoordNormalizationAndStartEcYZ;\n\30\n\31// For materials\n\32#ifdef WIDTH_VARYING\n\33varying float v_width;\n\34#endif\n\35#ifdef ANGLE_VARYING\n\36varying float v_polylineAngle;\n\37#endif\n\38\n\39#ifdef PER_INSTANCE_COLOR\n\40varying vec4 v_color;\n\41#endif\n\42\n\43void main()\n\44{\n\45#ifdef COLUMBUS_VIEW_2D\n\46 vec3 ecStart = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, startHiLo2D.xy), vec3(0.0, startHiLo2D.zw))).xyz;\n\47\n\48 vec3 forwardDirectionEC = czm_normal * vec3(0.0, offsetAndRight2D.xy);\n\49 vec3 ecEnd = forwardDirectionEC + ecStart;\n\50 forwardDirectionEC = normalize(forwardDirectionEC);\n\51\n\52 // Right plane\n\53 v_rightPlaneEC.xyz = czm_normal * vec3(0.0, offsetAndRight2D.zw);\n\54 v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart);\n\55\n\56 // start plane\n\57 vec4 startPlaneEC;\n\58 startPlaneEC.xyz = czm_normal * vec3(0.0, startEndNormals2D.xy);\n\59 startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart);\n\60\n\61 // end plane\n\62 vec4 endPlaneEC;\n\63 endPlaneEC.xyz = czm_normal * vec3(0.0, startEndNormals2D.zw);\n\64 endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd);\n\65\n\66 v_texcoordNormalizationAndStartEcYZ.x = abs(texcoordNormalization2D.x);\n\67 v_texcoordNormalizationAndStartEcYZ.y = texcoordNormalization2D.y;\n\68\n\69#else // COLUMBUS_VIEW_2D\n\70 vec3 ecStart = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(startHiAndForwardOffsetX.xyz, startLoAndForwardOffsetY.xyz)).xyz;\n\71 vec3 offset = czm_normal * vec3(startHiAndForwardOffsetX.w, startLoAndForwardOffsetY.w, startNormalAndForwardOffsetZ.w);\n\72 vec3 ecEnd = ecStart + offset;\n\73\n\74 vec3 forwardDirectionEC = normalize(offset);\n\75\n\76 // start plane\n\77 vec4 startPlaneEC;\n\78 startPlaneEC.xyz = czm_normal * startNormalAndForwardOffsetZ.xyz;\n\79 startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart);\n\80\n\81 // end plane\n\82 vec4 endPlaneEC;\n\83 endPlaneEC.xyz = czm_normal * endNormalAndTextureCoordinateNormalizationX.xyz;\n\84 endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd);\n\85\n\86 // Right plane\n\87 v_rightPlaneEC.xyz = czm_normal * rightNormalAndTextureCoordinateNormalizationY.xyz;\n\88 v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart);\n\89\n\90 v_texcoordNormalizationAndStartEcYZ.x = abs(endNormalAndTextureCoordinateNormalizationX.w);\n\91 v_texcoordNormalizationAndStartEcYZ.y = rightNormalAndTextureCoordinateNormalizationY.w;\n\92\n\93#endif // COLUMBUS_VIEW_2D\n\94\n\95 v_endEcAndStartEcX.xyz = ecEnd;\n\96 v_endEcAndStartEcX.w = ecStart.x;\n\97 v_texcoordNormalizationAndStartEcYZ.zw = ecStart.yz;\n\98\n\99#ifdef PER_INSTANCE_COLOR\n\100 v_color = czm_batchTable_color(batchId);\n\101#endif // PER_INSTANCE_COLOR\n\102\n\103 // Compute a normal along which to \"push\" the position out, extending the miter depending on view distance.\n\104 // Position has already been \"pushed\" by unit length along miter normal, and miter normals are encoded in the planes.\n\105 // Decode the normal to use at this specific vertex, push the position back, and then push to where it needs to be.\n\106 vec4 positionRelativeToEye = czm_computePosition();\n\107\n\108 // Check distance to the end plane and start plane, pick the plane that is closer\n\109 vec4 positionEC = czm_modelViewRelativeToEye * positionRelativeToEye; // w = 1.0, see czm_computePosition\n\110 float absStartPlaneDistance = abs(czm_planeDistance(startPlaneEC, positionEC.xyz));\n\111 float absEndPlaneDistance = abs(czm_planeDistance(endPlaneEC, positionEC.xyz));\n\112 vec3 planeDirection = czm_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlaneEC.xyz, endPlaneEC.xyz);\n\113 vec3 upOrDown = normalize(cross(v_rightPlaneEC.xyz, planeDirection)); // Points \"up\" for start plane, \"down\" at end plane.\n\114 vec3 normalEC = normalize(cross(planeDirection, upOrDown)); // In practice, the opposite seems to work too.\n\115\n\116 // Extrude bottom vertices downward for far view distances, like for GroundPrimitives\n\117 upOrDown = cross(forwardDirectionEC, normalEC);\n\118 upOrDown = float(czm_sceneMode == czm_sceneMode3D) * upOrDown;\n\119 upOrDown = float(v_texcoordNormalizationAndStartEcYZ.y > 1.0 || v_texcoordNormalizationAndStartEcYZ.y < 0.0) * upOrDown;\n\120 upOrDown = min(GLOBE_MINIMUM_ALTITUDE, czm_geometricToleranceOverMeter * length(positionRelativeToEye.xyz)) * upOrDown;\n\121 positionEC.xyz += upOrDown;\n\122\n\123 v_texcoordNormalizationAndStartEcYZ.y = czm_branchFreeTernary(v_texcoordNormalizationAndStartEcYZ.y > 1.0, 0.0, abs(v_texcoordNormalizationAndStartEcYZ.y));\n\124\n\125 // Determine distance along normalEC to push for a volume of appropriate width.\n\126 // Make volumes about double pixel width for a conservative fit - in practice the\n\127 // extra cost here is minimal compared to the loose volume heights.\n\128 //\n\129 // N = normalEC (guaranteed \"right-facing\")\n\130 // R = rightEC\n\131 // p = angle between N and R\n\132 // w = distance to push along R if R == N\n\133 // d = distance to push along N\n\134 //\n\135 // N R\n\136 // { \ p| } * cos(p) = dot(N, R) = w / d\n\137 // d\ \ | |w * d = w / dot(N, R)\n\138 // { \| }\n\139 // o---------- polyline segment ---->\n\140 //\n\141 float width = czm_batchTable_width(batchId);\n\142#ifdef WIDTH_VARYING\n\143 v_width = width;\n\144#endif\n\145\n\146 v_startPlaneNormalEcAndHalfWidth.xyz = startPlaneEC.xyz;\n\147 v_startPlaneNormalEcAndHalfWidth.w = width * 0.5;\n\148\n\149 v_endPlaneNormalEcAndBatchId.xyz = endPlaneEC.xyz;\n\150 v_endPlaneNormalEcAndBatchId.w = batchId;\n\151\n\152 width = width * max(0.0, czm_metersPerPixel(positionEC)); // width = distance to push along R\n\153 width = width / dot(normalEC, v_rightPlaneEC.xyz); // width = distance to push along N\n\154\n\155 // Determine if this vertex is on the \"left\" or \"right\"\n\156#ifdef COLUMBUS_VIEW_2D\n\157 normalEC *= sign(texcoordNormalization2D.x);\n\158#else\n\159 normalEC *= sign(endNormalAndTextureCoordinateNormalizationX.w);\n\160#endif\n\161\n\162 positionEC.xyz += width * normalEC;\n\163 gl_Position = czm_depthClampFarPlane(czm_projection * positionEC);\n\164\n\165#ifdef ANGLE_VARYING\n\166 // Approximate relative screen space direction of the line.\n\167 vec2 approxLineDirection = normalize(vec2(forwardDirectionEC.x, -forwardDirectionEC.y));\n\168 approxLineDirection.y = czm_branchFreeTernary(approxLineDirection.x == 0.0 && approxLineDirection.y == 0.0, -1.0, approxLineDirection.y);\n\169 v_polylineAngle = czm_fastApproximateAtan(approxLineDirection.x, approxLineDirection.y);\n\170#endif\n\171}\n\172";...
PolylineShadowVolumeFS.js
Source:PolylineShadowVolumeFS.js
1//This file is automatically rebuilt by the Cesium build process.2define(function() {3 'use strict';4 return "#ifdef GL_EXT_frag_depth\n\5#extension GL_EXT_frag_depth : enable\n\6#endif\n\7\n\8varying vec4 v_startPlaneNormalEcAndHalfWidth;\n\9varying vec4 v_endPlaneNormalEcAndBatchId;\n\10varying vec4 v_rightPlaneEC; // Technically can compute distance for this here\n\11varying vec4 v_endEcAndStartEcX;\n\12varying vec4 v_texcoordNormalizationAndStartEcYZ;\n\13\n\14#ifdef PER_INSTANCE_COLOR\n\15varying vec4 v_color;\n\16#endif\n\17\n\18void main(void)\n\19{\n\20 float logDepthOrDepth = czm_branchFreeTernary(czm_sceneMode == czm_sceneMode2D, gl_FragCoord.z, czm_unpackDepth(texture2D(czm_globeDepthTexture, gl_FragCoord.xy / czm_viewport.zw)));\n\21 vec3 ecStart = vec3(v_endEcAndStartEcX.w, v_texcoordNormalizationAndStartEcYZ.zw);\n\22\n\23 // Discard for sky\n\24 if (logDepthOrDepth == 0.0) {\n\25#ifdef DEBUG_SHOW_VOLUME\n\26 gl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n\27 return;\n\28#else // DEBUG_SHOW_VOLUME\n\29 discard;\n\30#endif // DEBUG_SHOW_VOLUME\n\31 }\n\32\n\33 vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);\n\34 eyeCoordinate /= eyeCoordinate.w;\n\35\n\36 float halfMaxWidth = v_startPlaneNormalEcAndHalfWidth.w * czm_metersPerPixel(eyeCoordinate);\n\37 // Check distance of the eye coordinate against the right-facing plane\n\38 float widthwiseDistance = czm_planeDistance(v_rightPlaneEC, eyeCoordinate.xyz);\n\39\n\40 // Check eye coordinate against the mitering planes\n\41 float distanceFromStart = czm_planeDistance(v_startPlaneNormalEcAndHalfWidth.xyz, -dot(ecStart, v_startPlaneNormalEcAndHalfWidth.xyz), eyeCoordinate.xyz);\n\42 float distanceFromEnd = czm_planeDistance(v_endPlaneNormalEcAndBatchId.xyz, -dot(v_endEcAndStartEcX.xyz, v_endPlaneNormalEcAndBatchId.xyz), eyeCoordinate.xyz);\n\43\n\44 if (abs(widthwiseDistance) > halfMaxWidth || distanceFromStart < 0.0 || distanceFromEnd < 0.0) {\n\45#ifdef DEBUG_SHOW_VOLUME\n\46 gl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n\47 return;\n\48#else // DEBUG_SHOW_VOLUME\n\49 discard;\n\50#endif // DEBUG_SHOW_VOLUME\n\51 }\n\52\n\53 // Check distance of the eye coordinate against start and end planes with normals in the right plane.\n\54 // For computing unskewed lengthwise texture coordinate.\n\55 // Can also be used for clipping extremely pointy miters, but in practice unnecessary because of miter breaking.\n\56\n\57 // aligned plane: cross the right plane normal with miter plane normal, then cross the result with right again to point it more \"forward\"\n\58 vec3 alignedPlaneNormal;\n\59\n\60 // start aligned plane\n\61 alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_startPlaneNormalEcAndHalfWidth.xyz);\n\62 alignedPlaneNormal = normalize(cross(alignedPlaneNormal, v_rightPlaneEC.xyz));\n\63 distanceFromStart = czm_planeDistance(alignedPlaneNormal, -dot(alignedPlaneNormal, ecStart), eyeCoordinate.xyz);\n\64\n\65 // end aligned plane\n\66 alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_endPlaneNormalEcAndBatchId.xyz);\n\67 alignedPlaneNormal = normalize(cross(alignedPlaneNormal, v_rightPlaneEC.xyz));\n\68 distanceFromEnd = czm_planeDistance(alignedPlaneNormal, -dot(alignedPlaneNormal, v_endEcAndStartEcX.xyz), eyeCoordinate.xyz);\n\69\n\70#ifdef PER_INSTANCE_COLOR\n\71 gl_FragColor = v_color;\n\72#else // PER_INSTANCE_COLOR\n\73 // Clamp - distance to aligned planes may be negative due to mitering,\n\74 // so fragment texture coordinate might be out-of-bounds.\n\75 float s = clamp(distanceFromStart / (distanceFromStart + distanceFromEnd), 0.0, 1.0);\n\76 s = (s * v_texcoordNormalizationAndStartEcYZ.x) + v_texcoordNormalizationAndStartEcYZ.y;\n\77 float t = (widthwiseDistance + halfMaxWidth) / (2.0 * halfMaxWidth);\n\78\n\79 czm_materialInput materialInput;\n\80\n\81 materialInput.s = s;\n\82 materialInput.st = vec2(s, t);\n\83 materialInput.str = vec3(s, t, 0.0);\n\84\n\85 czm_material material = czm_getMaterial(materialInput);\n\86 gl_FragColor = vec4(material.diffuse + material.emission, material.alpha);\n\87#endif // PER_INSTANCE_COLOR\n\88\n\89 czm_writeDepthClampedToFarPlane();\n\90}\n\91";...
AllMaterialAppearanceFS.js
Source:AllMaterialAppearanceFS.js
1//This file is automatically rebuilt by the Cesium build process.2define(function() {3 'use strict';4 return "varying vec3 v_positionEC;\n\5varying vec3 v_normalEC;\n\6varying vec3 v_tangentEC;\n\7varying vec3 v_bitangentEC;\n\8varying vec2 v_st;\n\9\n\10void main()\n\11{\n\12 vec3 positionToEyeEC = -v_positionEC;\n\13 mat3 tangentToEyeMatrix = czm_tangentToEyeSpaceMatrix(v_normalEC, v_tangentEC, v_bitangentEC);\n\14\n\15 vec3 normalEC = normalize(v_normalEC);\n\16#ifdef FACE_FORWARD\n\17 normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);\n\18#endif\n\19\n\20 czm_materialInput materialInput;\n\21 materialInput.normalEC = normalEC;\n\22 materialInput.tangentToEyeMatrix = tangentToEyeMatrix;\n\23 materialInput.positionToEyeEC = positionToEyeEC;\n\24 materialInput.st = v_st;\n\25 czm_material material = czm_getMaterial(materialInput);\n\26\n\27#ifdef FLAT\n\28 gl_FragColor = vec4(material.diffuse + material.emission, material.alpha);\n\29#else\n\30 gl_FragColor = czm_phong(normalize(positionToEyeEC), material);\n\31#endif\n\32}\n\33";...
Using AI Code Generation
1module.exports = async (page, scenario) => {2 await require('./loadCookies')(page, scenario);3 var hoverSelector = scenario.hoverSelectors || scenario.hoverSelector;4 var clickSelector = scenario.clickSelectors || scenario.clickSelector;5 if (hoverSelector) {6 for (const hoverSelector of scenario.hoverSelectors) {7 await page.waitForSelector(hoverSelector);8 await page.hover(hoverSelector);9 }10 }11 if (clickSelector) {12 for (const clickSelector of scenario.clickSelectors) {13 await page.waitForSelector(clickSelector);14 await page.click(clickSelector);15 }16 }17 if (postInteractionWait) {18 await page.waitFor(postInteractionWait);19 }20};
Using AI Code Generation
1module.exports = async (page, scenario, vp) => {2 console.log('SCENARIO > ' + scenario.label);3 await require('./loadCookies')(page, scenario);4 await page.evaluate(_ => {5 });6};
Using AI Code Generation
1var backstop = require('backstopjs');2backstop('test', {config: 'backstop.json'});3{4 {5 },6 {7 },8 {9 },10 {11 }12 {13 }14 "paths": {15 },16 "engineOptions": {17 },18}19module.exports = async (page, scenario, vp) => {20 console.log('SCENARIO > ' + scenario.label);21 await require('./loadCookies')(page, scenario);22};
Using AI Code Generation
1var fs = require('fs');2var path = require('path');3var backstopjs = require('backstopjs');4var backstopConfig = require('./backstop.json');5var args = require('yargs').argv;6var scenarios = require('./scenarios.js');7var url = require('./url.js');8var scenario = scenarios.scenarios;9var url = url.url;10var test = {11 {12 },13 {14 },15 {16 },17 {18 }19 "paths": {20 },21 "engineOptions": {22 },23}24for (var i = 0; i < url.length; i++) {25 test.scenarios[i].url = url[i];26}27var testJson = JSON.stringify(test);28fs.writeFileSync('backstop.json', testJson, 'utf-8');29backstopjs('test');
Using AI Code Generation
1module.exports = async (page, scenario, vp) => {2 await require('./loadCookies')(page, scenario);3 await page.evaluate(_ => {4 window.Ec = {5 }6 });7};
Using AI Code Generation
1module.exports = (engine, scenario, vp) => {2 engine.evaluate(function () {3 });4 engine.waitForSelector('.my-class');5 engine.click('.my-class');6 engine.waitForSelector('.my-class-2');7 engine.click('.my-class-2');8};
Using AI Code Generation
1var ec = require('backstopjs/commands/ec');2ec.run({3});4var backstop = require('backstopjs');5backstop('reference', {config: './backstop.json'});6The configuration is a json file. Please see the [BackstopJS Docs](
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!