Best JavaScript code snippet using devicefarmer-stf
2.js
Source:2.js
1import * as THREE from 'three';2import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';3import { ParametricGeometry } from "three/examples/jsm/geometries/ParametricGeometry";4import { GUI } from 'dat.gui';5var scene;6var camera;7var render;8var webglRender;9//var canvasRender;10var controls;11var guiParams;12var ground;13var paramMesh;14var meshMaterial;15var ambientLight;16var spotLight;17var axesHelper;18//var cameraHelper;19document.addEventListener('DOMContentLoaded', function() {20 scene = new THREE.Scene();21 webglRender = new THREE.WebGLRenderer( {antialias: true, alpha: true} ); // antialias antialiasing22 webglRender.setSize(window.innerWidth, window.innerHeight);23 webglRender.setClearColor(0xeeeeee, 1.0);24 webglRender.shadowMap.enabled = true; // Allow shadow casting25 render = webglRender;26 camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.01, 1000); // 214748364727 camera.position.set(-45.5, 68.2, 90.9);28 var target = new THREE.Vector3(10, 0 , 0);29 controls = new OrbitControls(camera, render.domElement);30 controls.target = target;31 camera.lookAt(target);32 document.querySelector('#container').append(render.domElement); // .appendChild(render.domElement);33 window.addEventListener('resize', onWindowResize, false);34 // Add a coordinate axis: X (orange), Y (green), Z (blue)35 axesHelper = new THREE.AxesHelper(60);36 scene.add(axesHelper);37 ambientLight = new THREE.AmbientLight(0x0c0c0c);38 scene.add(ambientLight);39 spotLight = new THREE.SpotLight(0xffffff);40 spotLight.position.set(-20, 250, -50);41 spotLight.target.position.set(30, -40, -20);42 spotLight.shadow.mapSize.width = 5120; // Must be a power of 2, the default value is 51243 spotLight.shadow.mapSize.height = 5120; // Must be a power of 2, the default value is 51244 spotLight.intensity = 0.3;45 spotLight.castShadow = true;46 scene.add(spotLight);47 //cameraHelper = new THREE.CameraHelper(spotLight.shadow.camera);48 //scene.add(cameraHelper);49 // add a ground50 var groundGeometry = new THREE.PlaneGeometry(100, 100, 4, 4);51 var groundMaterial = new THREE.MeshLambertMaterial({color: 0x777777}); // MeshBasicMaterial material cannot receive shadows52 ground = new THREE.Mesh(groundGeometry, groundMaterial);53 ground.rotation.set(-0.5 * Math.PI, 0, 0); // Rotate -90° along the X axis54 ground.receiveShadow = true;55 scene.add(ground);56 /** Used to save those variables that need to be modified */57 guiParams = new function() {58 this.rotationSpeed = 0.02;59 this.slices = 120;60 this.stacks = this.slices;61 }62 /** Define the dat.GUI object and bind several properties of guiParams */63 var gui = new GUI();64 gui.add(guiParams, "slices", 0, 120, 1).onChange(function(e){updateMesh()});65 gui.add(guiParams, "stacks", 0, 120, 1).onChange(function(e){updateMesh()});66 updateMesh();67 renderScene();68});69/** Render the scene */70function renderScene() {71 rotateMesh(); // rotate the object72 requestAnimationFrame(renderScene);73 render.render(scene, camera);74}75/** Triggered when the browser window size changes */76function onWindowResize() {77 camera.aspect = window.innerWidth / window.innerHeight;78 camera.updateProjectionMatrix();79 render.setSize(window.innerWidth, window.innerHeight);80}81/** Rotate object */82var step = 0;83function rotateMesh() {84 step += guiParams.rotationSpeed;85 scene.traverse(function(mesh) {86 if (mesh === paramMesh) {87 //mesh.rotation.x = step;88 mesh.rotation.y = step;89 //mesh.rotation.z = step;90 }91 });92}93function updateMesh() {94 scene.remove(paramMesh);95 // define paramMesh96 var paramGeometry = new ParametricGeometry(radialWave, guiParams.slices, guiParams.stacks);97 var paramMaterial = new THREE.MeshPhongMaterial({color: 0x3399ff, shininess: 40, specular: 0xaaaafff, side: THREE.DoubleSide});98 paramMesh = new THREE.Mesh(paramGeometry, paramMaterial);99 paramMesh.position.set(0, 10, 0);100 scene.add(paramMesh);101}102function radialWave(u, v) {103 var r = 50;104 var x = Math.sin(u) * r;105 var z = Math.sin(v / 2) * 2 * r;106 var y = ( Math.sin(u * 4 * Math.PI) + Math.cos(v * 2 * Math.PI) ) * 2.8;107 return new THREE.Vector3(x, y, z);...
Render.ts
Source:Render.ts
1import { WebglRender } from "./WebglRender";2import { CanvasRender } from "./CanvasRender";3import { setMainRenderFunction } from "../helpers/requestRenderFrame";4import type { Layer } from "../views/Layer";5import { container } from "../inversify.config";6import { injectable } from "inversify";7@injectable()8export class Render {9 private webglRender = container.get(WebglRender);10 private canvasRender = container.get(CanvasRender);11 init(layers: Layer[]) {12 layers.forEach(layer => {13 this.canvasRender.add(layer);14 this.webglRender.add(layer);15 });16 this.canvasRender.prepare();17 this.webglRender.prepare();18 setMainRenderFunction(() => {19 this.canvasRender.draw();20 this.webglRender.draw();21 });22 }...
Using AI Code Generation
1var stf = require('stf')2var device = require('stf').device3var util = require('util')4var client = stf.connect()5client.on('connect', function() {6 console.log('connected')7})8client.on('disconnect', function() {9 console.log('disconnected')10})11client.on('error', function(err) {12 console.error('fatal error: %s', err.stack)13})14client.on('device', function(device) {15 console.log('new device connected: %s', device.serial)16 device.on('present', function() {17 console.log('device %s is present', device.serial)18 })19 device.on('absent', function() {20 console.log('device %s is absent', device.serial)21 })22 device.on('change', function() {23 console.log('device %s changed', device.serial)24 })25 device.on('disconnect', function() {26 console.log('device %s disconnected', device.serial)27 })28 device.on('error', function(err) {29 console.error('device %s error: %s', device.serial, err.stack)30 })31 device.on('uninstall', function() {32 console.log('device %s uninstalled', device.serial)33 })34 device.on('install', function() {35 console.log('device %s installed', device.serial)36 })37 device.on('message', function(channel, message) {38 console.log('device %s message on %s: %s', device.serial, channel, message)39 })40 device.on('image', function(image) {41 console.log('device %s image', device.serial, image)42 })43 device.on('webgl', function(image) {44 console.log('device %s webgl', device.serial, image)45 })46 device.on('logcat', function(message) {47 console.log('device %s logcat: %s', device.serial, message)48 })49 device.on('minicap', function(data) {50 console.log('device %s minicap: %s', device.serial, data)51 })52 device.on('minitouch', function(data) {53 console.log('device %s minitouch: %s', device.serial, data)54 })55 device.on('minitouch-inject', function(data) {56 console.log('device %s minitouch-inject: %s',
Using AI Code Generation
1var stf = require('devicefarmer-stf')2var render = stf.WebGLRender(device)3var canvas = document.getElementById('canvas')4render(canvas, function (err, data) {5 console.log(data)6})7var stf = require('devicefarmer-stf')8var render = stf.WebGLRender(device)9var canvas = document.getElementById('canvas')10render(canvas, function (err, data) {11 console.log(data)12})13var stf = require('devicefarmer-stf')14var render = stf.WebGLRender(device)15var canvas = document.getElementById('canvas')16render(canvas, function (err, data) {17 console.log(data)18})19var stf = require('devicefarmer-stf')20var render = stf.WebGLRender(device)21var canvas = document.getElementById('canvas')
Using AI Code Generation
1var stf = require('devicefarmer-stf');2device.useWebGLRender(function(err, result){3 if(err){4 console.log(err);5 }6 else{7 console.log(result);8 }9});10var stf = require('devicefarmer-stf');11device.useWebRTC(function(err, result){12 if(err){13 console.log(err);14 }15 else{16 console.log(result);17 }18});19var stf = require('devicefarmer-stf');20device.useWebRTC(function(err, result){21 if(err){22 console.log(err);23 }24 else{25 console.log(result);26 }27});28var stf = require('devicefarmer-stf');29device.useWebRTC(function(err, result){30 if(err){31 console.log(err);32 }33 else{34 console.log(result);35 }36});37var stf = require('devicefarmer-stf');38device.useWebRTC(function(err, result){39 if(err){40 console.log(err);41 }42 else{43 console.log(result);44 }45});46var stf = require('devicefarmer-stf');47device.useWebRTC(function(err, result){48 if(err){49 console.log(err);50 }
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!!