Best JavaScript code snippet using wpt
ControllerGestures.js
Source:ControllerGestures.js
1import * as THREE from './three/three.module.js';2class ControllerGestures extends THREE.EventDispatcher{3 constructor( renderer ){4 super();5 6 if (renderer === undefined){7 console.error('ControllerGestures must be passed a renderer');8 return;9 }10 11 const clock = new THREE.Clock();12 13 this.controller1 = renderer.xr.getController(0);14 this.controller1.userData.gestures = { index: 0 };15 this.controller1.userData.selectPressed = false;16 this.controller1.addEventListener( 'selectstart', onSelectStart );17 this.controller1.addEventListener( 'selectend', onSelectEnd );18 19 this.controller2 = renderer.xr.getController(1);20 this.controller2.userData.gestures = { index: 1 };21 this.controller2.userData.selectPressed = false;22 this.controller2.addEventListener( 'selectstart', onSelectStart );23 this.controller2.addEventListener( 'selectend', onSelectEnd );24 25 this.doubleClickLimit = 0.2;26 this.pressMinimum = 0.4;27 this.right = new THREE.Vector3(1,0,0);28 this.up = new THREE.Vector3(0,1,0);29 30 this.type = 'unknown';31 this.touchCount = 0;32 33 this.clock = clock;34 35 const self = this;36 37 function onSelectStart( ){38 const data = this.userData.gestures;39 40 data.startPosition = undefined;41 data.startTime = clock.getElapsedTime();42 43 if ( self.type.indexOf('tap') == -1) data.taps = 0;44 45 self.type = 'unknown';46 this.userData.selectPressed = true;47 48 self.touchCount++;49 50 console.log( `onSelectStart touchCount: ${ self.touchCount }` );51 }52 53 function onSelectEnd( ){54 const data = this.userData.gestures;55 56 data.endTime = clock.getElapsedTime();57 const startToEnd = data.endTime - data.startTime;58 59 //console.log(`ControllerGestures.onSelectEnd: startToEnd:${startToEnd.toFixed(2)} taps:${data.taps}`);60 61 if (self.type === 'swipe'){62 const direction = ( self.controller1.position.y < data.startPosition.y) ? "DOWN" : "UP";63 self.dispatchEvent( { type:'swipe', direction } );64 self.type = 'unknown';65 }else if (self.type !== "pinch" && self.type !== "rotate" && self.type !== 'pan'){66 if ( startToEnd < self.doubleClickLimit ){67 self.type = "tap";68 data.taps++;69 }else if ( startToEnd > self.pressMinimum ){70 self.dispatchEvent( { type: 'press', position: self.controller1.position, matrixWorld: self.controller1.matrixWorld } );71 self.type = 'unknown';72 }73 }else{74 self.type = 'unknown';75 }76 77 this.userData.selectPressed = false;78 data.startPosition = undefined;79 80 self.touchCount--;81 }82 }83 84 get multiTouch(){85 let result;86 if ( this.controller1 === undefined || this.controller2 === undefined ){ 87 result = false;88 }else{89 result = this.controller1.userData.selectPressed && this.controller2.userData.selectPressed;90 }91 const self = this;92 console.log( `ControllerGestures multiTouch: ${result} touchCount:${self.touchCount}`);93 return result;94 }95 96 get touch(){97 let result;98 if ( this.controller1 === undefined || this.controller2 === undefined ){ 99 result = false;100 }else{101 result = this.controller1.userData.selectPressed || this.controller2.userData.selectPressed;102 }103 //console.log( `ControllerGestures touch: ${result}`);104 return result;105 }106 107 get debugMsg(){108 return this.type;109 }110 111 update(){112 const data1 = this.controller1.userData.gestures;113 const data2 = this.controller2.userData.gestures;114 const currentTime = this.clock.getElapsedTime();115 116 let elapsedTime;117 118 if (this.controller1.userData.selectPressed && data1.startPosition === undefined){119 elapsedTime = currentTime - data1.startTime;120 if (elapsedTime > 0.05 ) data1.startPosition = this.controller1.position.clone();121 }122 123 if (this.controller2.userData.selectPressed && data2.startPosition === undefined){124 elapsedTime = currentTime - data2.startTime;125 if (elapsedTime > 0.05 ) data2.startPosition = this.controller2.position.clone();126 }127 128 if (!this.controller1.userData.selectPressed && this.type === 'tap' ){129 //Only dispatch event after double click limit is passed130 elapsedTime = this.clock.getElapsedTime() - data1.endTime;131 if (elapsedTime > this.doubleClickLimit){132 //console.log( `ControllerGestures.update dispatchEvent taps:${data1.taps}` );133 switch( data1.taps ){134 case 1:135 this.dispatchEvent( { type: 'tap', position: this.controller1.position, matrixWorld: this.controller1.matrixWorld } );136 break;137 case 2:138 this.dispatchEvent( { type: 'doubletap', position: this.controller1.position, matrixWorld: this.controller1.matrixWorld } );139 break;140 case 3:141 this.dispatchEvent( { type: 'tripletap', position: this.controller1.position, matrixWorld: this.controller1.matrixWorld } );142 break;143 case 4:144 this.dispatchEvent( { type: 'quadtap', position: this.controller1.position, matrixWorld: this.controller1.matrixWorld } );145 break;146 }147 this.type = "unknown";148 data1.taps = 0;149 }150 }151 152 if (this.type === 'unknown' && this.touch){153 if (data1.startPosition !== undefined){154 if (this.multiTouch){155 if (data2.startPosition !== undefined){156 //startPosition is undefined for 1/20 sec157 //test for pinch or rotate158 const startDistance = data1.startPosition.distanceTo( data2.startPosition );159 const currentDistance = this.controller1.position.distanceTo( this.controller2.position );160 const delta = currentDistance - startDistance;161 if ( Math.abs(delta) > 0.01 ){162 this.type = 'pinch';163 this.startDistance = this.controller1.position.distanceTo( this.controller2.position );164 this.dispatchEvent( { type: 'pinch', delta: 0, scale: 1, initialise: true } );165 }else{166 const v1 = data2.startPosition.clone().sub( data1.startPosition ).normalize();167 const v2 = this.controller2.position.clone().sub( this.controller1.position ).normalize();168 const theta = v1.angleTo( v2 );169 if (Math.abs(theta) > 0.2){170 this.type = 'rotate';171 this.startVector = v2.clone();172 this.dispatchEvent( { type: 'rotate', theta: 0, initialise: true } );173 }174 }175 }176 }else{177 //test for swipe or pan178 let dist = data1.startPosition.distanceTo( this.controller1.position );179 elapsedTime = this.clock.getElapsedTime() - data1.startTime;180 const velocity = dist/elapsedTime;181 //console.log(`dist:${dist.toFixed(3)} velocity:${velocity.toFixed(3)}`);182 if ( dist > 0.01 && velocity > 0.1 ){183 const v = this.controller1.position.clone().sub( data1.startPosition );184 let maxY = (Math.abs(v.y) > Math.abs(v.x)) && (Math.abs(v.y) > Math.abs(v.z));185 if ( maxY )this.type = "swipe";186 }else if (dist > 0.006 && velocity < 0.03){187 this.type = "pan";188 this.startPosition = this.controller1.position.clone();189 this.dispatchEvent( { type: 'pan', delta: new THREE.Vector3(), initialise: true } );190 }191 }192 }193 }else if (this.type === 'pinch'){194 const currentDistance = this.controller1.position.distanceTo( this.controller2.position );195 const delta = currentDistance - this.startDistance;196 const scale = currentDistance/this.startDistance;197 this.dispatchEvent( { type: 'pinch', delta, scale });198 }else if (this.type === 'rotate'){199 const v = this.controller2.position.clone().sub( this.controller1.position ).normalize();200 let theta = this.startVector.angleTo( v );201 const cross = this.startVector.clone().cross( v );202 if (this.up.dot(cross) > 0) theta = -theta;203 this.dispatchEvent( { type: 'rotate', theta } );204 }else if (this.type === 'pan'){205 const delta = this.controller1.position.clone().sub( this.startPosition );206 this.dispatchEvent( { type: 'pan', delta } );207 }208 }209}...
traceInfo_flag.js
Source:traceInfo_flag.js
1function TraceInfoFlag() {2 this.traceFlag = new Array();3 this.traceFlag["Controller1.cpp:41c33"]=1;4 this.traceFlag["Controller1.cpp:41c56"]=1;5 this.traceFlag["Controller1.cpp:43c50"]=1;6 this.traceFlag["Controller1.cpp:43c56"]=1;7 this.traceFlag["Controller1.cpp:45c33"]=1;8 this.traceFlag["Controller1.cpp:45c56"]=1;9 this.traceFlag["Controller1.cpp:45c62"]=1;10 this.traceFlag["Controller1.cpp:52c23"]=1;11 this.traceFlag["Controller1.cpp:54c31"]=1;12 this.traceFlag["Controller1.cpp:55c43"]=1;13 this.traceFlag["Controller1.cpp:55c49"]=1;14 this.traceFlag["Controller1.cpp:55c54"]=1;15 this.traceFlag["Controller1.cpp:62c19"]=1;16 this.traceFlag["Controller1.cpp:64c26"]=1;17 this.traceFlag["Controller1.cpp:64c28"]=1;18 this.traceFlag["Controller1.cpp:65c23"]=1;19 this.traceFlag["Controller1.cpp:73c19"]=1;20 this.traceFlag["Controller1.cpp:75c26"]=1;21 this.traceFlag["Controller1.cpp:75c28"]=1;22 this.traceFlag["Controller1.cpp:76c23"]=1;23 this.traceFlag["Controller1.cpp:84c19"]=1;24 this.traceFlag["Controller1.cpp:86c26"]=1;25 this.traceFlag["Controller1.cpp:86c28"]=1;26 this.traceFlag["Controller1.cpp:87c23"]=1;27 this.traceFlag["Controller1.cpp:99c33"]=1;28 this.traceFlag["Controller1.cpp:99c56"]=1;29 this.traceFlag["Controller1.cpp:99c74"]=1;30 this.traceFlag["Controller1.cpp:101c33"]=1;31 this.traceFlag["Controller1.cpp:101c56"]=1;32 this.traceFlag["Controller1.cpp:101c74"]=1;33 this.traceFlag["Controller1.cpp:103c33"]=1;34 this.traceFlag["Controller1.cpp:103c56"]=1;35 this.traceFlag["Controller1.cpp:103c74"]=1;36}37top.TraceInfoFlag.instance = new TraceInfoFlag();38function TraceInfoLineFlag() {39 this.lineTraceFlag = new Array();40 this.lineTraceFlag["Controller1.cpp:41"]=1;41 this.lineTraceFlag["Controller1.cpp:42"]=1;42 this.lineTraceFlag["Controller1.cpp:43"]=1;43 this.lineTraceFlag["Controller1.cpp:44"]=1;44 this.lineTraceFlag["Controller1.cpp:45"]=1;45 this.lineTraceFlag["Controller1.cpp:46"]=1;46 this.lineTraceFlag["Controller1.cpp:47"]=1;47 this.lineTraceFlag["Controller1.cpp:52"]=1;48 this.lineTraceFlag["Controller1.cpp:53"]=1;49 this.lineTraceFlag["Controller1.cpp:54"]=1;50 this.lineTraceFlag["Controller1.cpp:55"]=1;51 this.lineTraceFlag["Controller1.cpp:62"]=1;52 this.lineTraceFlag["Controller1.cpp:63"]=1;53 this.lineTraceFlag["Controller1.cpp:64"]=1;54 this.lineTraceFlag["Controller1.cpp:65"]=1;55 this.lineTraceFlag["Controller1.cpp:67"]=1;56 this.lineTraceFlag["Controller1.cpp:73"]=1;57 this.lineTraceFlag["Controller1.cpp:74"]=1;58 this.lineTraceFlag["Controller1.cpp:75"]=1;59 this.lineTraceFlag["Controller1.cpp:76"]=1;60 this.lineTraceFlag["Controller1.cpp:78"]=1;61 this.lineTraceFlag["Controller1.cpp:84"]=1;62 this.lineTraceFlag["Controller1.cpp:85"]=1;63 this.lineTraceFlag["Controller1.cpp:86"]=1;64 this.lineTraceFlag["Controller1.cpp:87"]=1;65 this.lineTraceFlag["Controller1.cpp:89"]=1;66 this.lineTraceFlag["Controller1.cpp:99"]=1;67 this.lineTraceFlag["Controller1.cpp:100"]=1;68 this.lineTraceFlag["Controller1.cpp:101"]=1;69 this.lineTraceFlag["Controller1.cpp:102"]=1;70 this.lineTraceFlag["Controller1.cpp:103"]=1;71 this.lineTraceFlag["Controller1.cpp:104"]=1;72}...
Using AI Code Generation
1var wptController = require('../controllers/wptController');2wptController.controller1(req, res, next);3var wptController = require('../controllers/wptController');4wptController.controller2(req, res, next);5var wptController = require('../controllers/wptController');6wptController.controller3(req, res, next);7var wptController = require('../controllers/wptController');8wptController.controller4(req, res, next);9var wptController = require('../controllers/wptController');10wptController.controller5(req, res, next);11var wptController = require('../controllers/wptController');12wptController.controller6(req, res, next);13var wptController = require('../controllers/wptController');14wptController.controller9(req, res, next);15var wptController = require('../controllers/wptController');16wptController.controller8(req, res, next);17var wptController = require('../controllers/wptController');18wptController.controller9(req, res, next);19var wptController = require('../controllers/wptController');20wptController.controller10(req, res, next);21var wptController = require('../controllers/wptController');22wptController.controller11(req, res, next);23var wptController = require('../controllers/wptController');24wptController.controller12(req, res, next);25var wptController = require('../controllers/wptController');26wptController.controller13(req, res, next);27var wptController = require('../controllers/wptController');28wptController.controller14(req, res, next);29var wptController = require('../
Using AI Code Generation
1var wptController = require('./controllers/wptController');2var wptController = require('./controllers/wptController');3var wptController = require('./controllers/wptController');4exports.controller1 = function(req, res) {5 res.send('controller1');6};7exports.controller2 = function(req, res) {8 res.send('controller2');9};10exports.controller3 = function(req, res) {11 res.send('controller3');12};13module.exports = function(app) {14 var wpt = require('../controllers/wptController');15 app.route('/wpt')16 .get(wpt.controller1)17 .post(wpt.controller2);18 app.route('/wpt/:wptId')19 .get(wpt.controller3);20};
Using AI Code Generation
1var controller1 = require('./wpt.js').controller1;2var controller2 = require('./wpt.js').controller2;3var controller3 = require('./wpt.js').controller3;4controller1();5controller2();6controller3();7exports.controller1 = function(){8 console.log('controller1');9}10exports.controller2 = function(){11 console.log('controller2');12}13exports.controller3 = function(){14 console.log('controller3');15}16var controller = require('./wpt.js');17controller.controller1();18controller.controller2();19controller.controller3();20module.exports = {21 controller1: function(){22 console.log('controller1');23 },24 controller2: function(){25 console.log('controller2');26 },27 controller3: function(){28 console.log('controller3');29 }30}31var controller = require('./wpt.js');32controller();33module.exports = function(){34 console.log('controller1');35}36var controller = require('./wpt.js');37console.log(controller);38module.exports = 'controller1';
Using AI Code Generation
1var wptController = require('..wcontrollerspwptController.js');2wptController.controller1(req, res);3exports.controller1 = function(req, res) {4};5exports.controller2 = function(req, res) {6};7I hope this will help you.tController.controller1(req, res);8exports.controller1 = function(req, res) {9}10var express = require('express');11var router = express.Router();12var wptController = require('../controllers/wptController');13router.get('/', wptController.controller1);14module.exports = router;15var test = require('./routes/test');16app.use('/test', test);17app.use('/controller1', wptController.controller1);18var express = require('express');19var router = express.Router();20var wptController = require('../controllers/wptController');21router.get('/:id', wptController.controller1);22module.exports = router;23var test = require('./routes/test');24app.use('/test', test);25app.use('/controller1', wptController.controller1);
Using AI Code Generation
1var wptController = require('../controllers/wptController.js');2wptController.controller1(req, res);3exports.controller1 = function(req, res) {4};5exports.controller2 = function(req, res) {6};
Using AI Code Generation
1var wptController = require('./wptController.js');2wptController.controller1();3exports.controller1 = function() {4 console.log('controller1');5 var wptModel = require('./wptModel.js');6 wptModel.model1();7}8exports.model1 = function() {9 console.log('model1');10 var wptService = require('./wptService.js');11 wptService.service1();12}13exports.service1 = function() {14 console.log('service1');15 var wptDao = require('./wptDao.js');16 wptDao.dao1();17}18exports.dao1 = function() {19 console.log('dao1');20}21var wptController = require('./wptController.js');22wptController.controller1();23exports.controller1 = function() {24 console.log('controller1');25 var wptModel = require('./wptModel.js');26 wptModel.model1();27}28exports.model1 = function() {29 console.log('model1');30 var wptService = require('./wptService.js');31 wptService.service1();32}33exports.service1 = function() {34 console.log('service1');35 var wptDao = require('./wptDao.js');36 wptDao.dao1();37}
Using AI Code Generation
1const wpt = require('wpt');2const controller1 = wpt.controller1;3controller1.method1();4const wpt = require('wpt');5const controller1 = wpt.controller1;6controller1.method1();7const wpt = require('wpt');8const controller1 = wpt.controller1;9controller1.method1();10const wpt = require('wpt');11const controller1 = wpt.controller1;12controller1.method1();13const wpt = require('wpt');14const controller1 = wpt.controller1;15controller1.method1();16const wpt = require('wpt');17const controller1 = wpt.controller1;18controller1.method1();19const wpt = require('wpt');20const controller1 = wpt.controller1;21controller1.method1();22const wpt = require('wpt');23const controller1 = wpt.controller1;24controller1.method1();
Using AI Code Generation
1var wptController = require('./controllers/wpt_controller');2wptController.controller1();3var wptController = require('./controllers/wpt_controller');4var Wpt = require('./models/wpt');5var wpt = new Wpt({6});7wptController.controller2(wpt);8var wptController = require('./controllers/wpt_controller');9wptController.controller3('wpt_id');10var wptController = require('./controllers/wpt_controller');11wptController.controller4();12var wptController = require('./controllers/wpt_controller');13var Wpt = require('./models/wpt');14var wpt = new Wpt({
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!!