How to use composeGFXTransform method in wpt

Best JavaScript code snippet using wpt

webxr-test.js

Source:webxr-test.js Github

copy

Full Screen

...32 m12, m22, m32, 0,33 m13, m23, m33, 0,34 m14, m24, m34, 1];35}36function composeGFXTransform(fakeTransformInit) {37 let transform = new gfx.mojom.Transform();38 transform.matrix = getMatrixFromTransform(fakeTransformInit);39 return transform;40}41class ChromeXRTest {42 constructor() {43 this.mockVRService_ = new MockVRService(mojo.frameInterfaces);44 }45 simulateDeviceConnection(init_params) {46 return Promise.resolve(this.mockVRService_.addRuntime(init_params));47 }48 disconnectAllDevices() {49 this.mockVRService_.removeAllRuntimes(device);50 return Promise.resolve();51 }52 simulateUserActivation(callback) {53 let button = document.createElement('button');54 button.textContent = 'click to continue test';55 button.style.display = 'block';56 button.style.fontSize = '20px';57 button.style.padding = '10px';58 button.onclick = () => {59 callback();60 document.body.removeChild(button);61 };62 document.body.appendChild(button);63 test_driver.click(button);64 }65}66// Mocking class definitions67// Mock service implements the VRService mojo interface.68class MockVRService {69 constructor() {70 this.bindingSet_ = new mojo.BindingSet(device.mojom.VRService);71 this.runtimes_ = [];72 this.interceptor_ =73 new MojoInterfaceInterceptor(device.mojom.VRService.name, "context", true);74 this.interceptor_.oninterfacerequest = e =>75 this.bindingSet_.addBinding(this, e.handle);76 this.interceptor_.start();77 }78 // Test methods79 addRuntime(fakeDeviceInit) {80 let runtime = new MockRuntime(fakeDeviceInit, this);81 this.runtimes_.push(runtime);82 if (this.client_) {83 this.client_.onDeviceChanged();84 }85 return runtime;86 }87 removeAllRuntimes() {88 if (this.client_) {89 this.client_.onDeviceChanged();90 }91 this.runtimes_ = [];92 }93 removeRuntime(device) {94 let index = this.runtimes_.indexOf(device);95 if (index >= 0) {96 this.runtimes_.splice(index, 1);97 if (this.client_) {98 this.client_.onDeviceChanged();99 }100 }101 }102 setClient(client) {103 if (this.client_) {104 throw new Error("setClient should only be called once");105 }106 this.client_ = client;107 }108 requestSession(sessionOptions, was_activation) {109 let requests = [];110 // Request a session from all the runtimes.111 for (let i = 0; i < this.runtimes_.length; i++) {112 requests[i] = this.runtimes_[i].requestRuntimeSession(sessionOptions);113 }114 return Promise.all(requests).then((results) => {115 // Find and return the first successful result.116 for (let i = 0; i < results.length; i++) {117 if (results[i].session) {118 // Construct a dummy metrics recorder119 let metricsRecorderPtr = new device.mojom.XRSessionMetricsRecorderPtr();120 let metricsRecorderRequest = mojo.makeRequest(metricsRecorderPtr);121 let metricsRecorderBinding = new mojo.Binding(122 device.mojom.XRSessionMetricsRecorder, new MockXRSessionMetricsRecorder(), metricsRecorderRequest);123 let success = {124 session: results[i].session,125 metricsRecorder: metricsRecorderPtr,126 };127 return {128 result: {129 success : success,130 $tag : 0131 }132 };133 }134 }135 // If there were no successful results, returns a null session.136 return {137 result: {138 failureReason : device.mojom.RequestSessionError.NO_RUNTIME_FOUND,139 $tag : 1140 }141 };142 });143 }144 exitPresent() {145 return Promise.resolve();146 }147 supportsSession(sessionOptions) {148 let requests = [];149 // Check supports on all the runtimes.150 for (let i = 0; i < this.runtimes_.length; i++) {151 requests[i] = this.runtimes_[i].runtimeSupportsSession(sessionOptions);152 }153 return Promise.all(requests).then((results) => {154 // Find and return the first successful result.155 for (let i = 0; i < results.length; i++) {156 if (results[i].supportsSession) {157 return results[i];158 }159 }160 // If there were no successful results, returns false.161 return {supportsSession: false};162 });163 };164}165// Implements XRFrameDataProvider and XRPresentationProvider. Maintains a mock166// for XRPresentationProvider.167class MockRuntime {168 // Mapping from string feature names to the corresponding mojo types.169 // This is exposed as a member for extensibility.170 static featureToMojoMap = {171 "viewer": device.mojom.XRSessionFeature.REF_SPACE_VIEWER,172 "local": device.mojom.XRSessionFeature.REF_SPACE_LOCAL,173 "local-floor": device.mojom.XRSessionFeature.REF_SPACE_LOCAL_FLOOR,174 "bounded-floor": device.mojom.XRSessionFeature.REF_SPACE_BOUNDED_FLOOR,175 "unbounded": device.mojom.XRSessionFeature.REF_SPACE_UNBOUNDED };176 constructor(fakeDeviceInit, service) {177 this.sessionClient_ = new device.mojom.XRSessionClientPtr();178 this.presentation_provider_ = new MockXRPresentationProvider();179 this.pose_ = null;180 this.next_frame_id_ = 0;181 this.bounds_ = null;182 this.send_mojo_space_reset_ = false;183 this.service_ = service;184 this.framesOfReference = {};185 this.input_sources_ = [];186 this.next_input_source_index_ = 1;187 // Initialize DisplayInfo first to set the defaults, then override with188 // anything from the deviceInit189 if (fakeDeviceInit.supportsImmersive) {190 this.displayInfo_ = this.getImmersiveDisplayInfo();191 } else {192 this.displayInfo_ = this.getNonImmersiveDisplayInfo();193 }194 if (fakeDeviceInit.supportsEnvironmentIntegration) {195 this.displayInfo_.capabilities.canProvideEnvironmentIntegration = true;196 }197 if (fakeDeviceInit.viewerOrigin != null) {198 this.setViewerOrigin(fakeDeviceInit.viewerOrigin);199 }200 if (fakeDeviceInit.floorOrigin != null) {201 this.setFloorOrigin(fakeDeviceInit.floorOrigin);202 }203 // This appropriately handles if the coordinates are null204 this.setBoundsGeometry(fakeDeviceInit.boundsCoordinates);205 this.setViews(fakeDeviceInit.views);206 // Need to support webVR which doesn't have a notion of features207 this.setFeatures(fakeDeviceInit.supportedFeatures || []);208 }209 // Test API methods.210 disconnect() {211 this.service_.removeRuntime(this);212 this.presentation_provider_.Close();213 if (this.sessionClient_.ptr.isBound()) {214 this.sessionClient_.ptr.reset();215 }216 return Promise.resolve();217 }218 setViews(views) {219 if (views) {220 let changed = false;221 for (let i = 0; i < views.length; i++) {222 if (views[i].eye == 'left') {223 this.displayInfo_.leftEye = this.getEye(views[i]);224 changed = true;225 } else if (views[i].eye == 'right') {226 this.displayInfo_.rightEye = this.getEye(views[i]);227 changed = true;228 }229 }230 if (changed && this.sessionClient_.ptr.isBound()) {231 this.sessionClient_.onChanged(this.displayInfo_);232 }233 }234 }235 setViewerOrigin(origin, emulatedPosition = false) {236 let p = origin.position;237 let q = origin.orientation;238 this.pose_ = {239 orientation: { x: q[0], y: q[1], z: q[2], w: q[3] },240 position: { x: p[0], y: p[1], z: p[2] },241 emulatedPosition: emulatedPosition,242 angularVelocity: null,243 linearVelocity: null,244 angularAcceleration: null,245 linearAcceleration: null,246 inputState: null,247 poseIndex: 0248 };249 }250 clearViewerOrigin() {251 this.pose_ = null;252 }253 simulateVisibilityChange(visibilityState) {254 let mojoState = null;255 switch(visibilityState) {256 case "visible":257 mojoState = device.mojom.XRVisibilityState.VISIBLE;258 break;259 case "visible-blurred":260 mojoState = device.mojom.XRVisibilityState.VISIBLE_BLURRED;261 break;262 case "hidden":263 mojoState = device.mojom.XRVisibilityState.HIDDEN;264 break;265 }266 if (mojoState) {267 this.sessionClient_.onVisibilityStateChanged(mojoState);268 }269 }270 setBoundsGeometry(bounds) {271 if (bounds == null) {272 this.bounds_ = null;273 } else if (bounds.length < 3) {274 throw new Error("Bounds must have a length of at least 3");275 } else {276 this.bounds_ = bounds;277 }278 // We can only set bounds if we have stageParameters set; otherwise, we279 // don't know the transform from local space to bounds space.280 // We'll cache the bounds so that they can be set in the future if the281 // floorLevel transform is set, but we won't update them just yet.282 if (this.displayInfo_.stageParameters) {283 this.displayInfo_.stageParameters.bounds = this.bounds_;284 if (this.sessionClient_.ptr.isBound()) {285 this.sessionClient_.onChanged(this.displayInfo_);286 }287 }288 }289 setFloorOrigin(floorOrigin) {290 if (!this.displayInfo_.stageParameters) {291 this.displayInfo_.stageParameters = default_stage_parameters;292 this.displayInfo_.stageParameters.bounds = this.bounds_;293 }294 this.displayInfo_.stageParameters.standingTransform = new gfx.mojom.Transform();295 this.displayInfo_.stageParameters.standingTransform.matrix =296 getMatrixFromTransform(floorOrigin);297 if (this.sessionClient_.ptr.isBound()) {298 this.sessionClient_.onChanged(this.displayInfo_);299 }300 }301 clearFloorOrigin() {302 if (this.displayInfo_.stageParameters) {303 this.displayInfo_.stageParameters = null;304 if (this.sessionClient_.ptr.isBound()) {305 this.sessionClient_.onChanged(this.displayInfo_);306 }307 }308 }309 simulateResetPose() {310 this.send_mojo_space_reset_ = true;311 }312 simulateInputSourceConnection(fakeInputSourceInit) {313 let index = this.next_input_source_index_;314 this.next_input_source_index_++;315 let source = new MockXRInputSource(fakeInputSourceInit, index, this);316 this.input_sources_.push(source);317 return source;318 }319 // Helper methods320 getNonImmersiveDisplayInfo() {321 let displayInfo = this.getImmersiveDisplayInfo();322 displayInfo.capabilities.canPresent = false;323 displayInfo.leftEye = null;324 displayInfo.rightEye = null;325 return displayInfo;326 }327 // Function to generate some valid display information for the device.328 getImmersiveDisplayInfo() {329 return {330 displayName: 'FakeDevice',331 capabilities: {332 hasPosition: false,333 hasExternalDisplay: false,334 canPresent: true,335 maxLayers: 1336 },337 stageParameters: null,338 leftEye: {339 fieldOfView: {340 upDegrees: 48.316,341 downDegrees: 50.099,342 leftDegrees: 50.899,343 rightDegrees: 35.197344 },345 headFromEye: composeGFXTransform({346 position: [-0.032, 0, 0],347 orientation: [0, 0, 0, 1]348 }),349 renderWidth: 20,350 renderHeight: 20351 },352 rightEye: {353 fieldOfView: {354 upDegrees: 48.316,355 downDegrees: 50.099,356 leftDegrees: 50.899,357 rightDegrees: 35.197358 },359 headFromEye: composeGFXTransform({360 position: [0.032, 0, 0],361 orientation: [0, 0, 0, 1]362 }),363 renderWidth: 20,364 renderHeight: 20365 },366 webxrDefaultFramebufferScale: 0.7,367 };368 }369 // This function converts between the matrix provided by the WebXR test API370 // and the internal data representation.371 getEye(fakeXRViewInit) {372 let fov = null;373 if (fakeXRViewInit.fieldOfView) {374 fov = {375 upDegrees: fakeXRViewInit.fieldOfView.upDegrees,376 downDegrees: fakeXRViewInit.fieldOfView.downDegrees,377 leftDegrees: fakeXRViewInit.fieldOfView.leftDegrees,378 rightDegrees: fakeXRViewInit.fieldOfView.rightDegrees379 };380 } else {381 let m = fakeXRViewInit.projectionMatrix;382 function toDegrees(tan) {383 return Math.atan(tan) * 180 / Math.PI;384 }385 let leftTan = (1 - m[8]) / m[0];386 let rightTan = (1 + m[8]) / m[0];387 let upTan = (1 + m[9]) / m[5];388 let downTan = (1 - m[9]) / m[5];389 fov = {390 upDegrees: toDegrees(upTan),391 downDegrees: toDegrees(downTan),392 leftDegrees: toDegrees(leftTan),393 rightDegrees: toDegrees(rightTan)394 };395 }396 return {397 fieldOfView: fov,398 headFromEye: composeGFXTransform(fakeXRViewInit.viewOffset),399 renderWidth: fakeXRViewInit.resolution.width,400 renderHeight: fakeXRViewInit.resolution.height401 };402 }403 setFeatures(supportedFeatures) {404 function convertFeatureToMojom(feature) {405 if (feature in MockRuntime.featureToMojoMap) {406 return MockRuntime.featureToMojoMap[feature];407 } else {408 return device.mojom.XRSessionFeature.INVALID;409 }410 }411 this.supportedFeatures_ = [];412 for (let i = 0; i < supportedFeatures.length; i++) {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var transform = wptoolkit.composeGFXTransform(1, 2, 3, 4, 5, 6);3console.log(transform);4var wptoolkit = require('wptoolkit');5var transform = wptoolkit.composeGFXTransform(1, 2, 3, 4, 5, 6);6console.log(transform);7var wptoolkit = require('wptoolkit');8var transform = wptoolkit.composeGFXTransform(1, 2, 3, 4, 5, 6);9console.log(transform);10var wptoolkit = require('wptoolkit');11var transform = wptoolkit.composeGFXTransform(1, 2, 3, 4, 5, 6);12console.log(transform);13var wptoolkit = require('wptoolkit');14var transform = wptoolkit.composeGFXTransform(1, 2, 3, 4, 5, 6);15console.log(transform);16var wptoolkit = require('wptoolkit');17var transform = wptoolkit.composeGFXTransform(1, 2, 3, 4, 5, 6);18console.log(transform);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var transform = wptoolkit.composeGFXTransform(1, 0, 0, 1, 100, 100);3console.log(transform);4var wptoolkit = require('wptoolkit');5var transform = wptoolkit.composeGFXTransform(1, 0, 0, 1, 100, 100);6console.log(transform);7var wptoolkit = require('wptoolkit');8var transform = wptoolkit.composeGFXTransform(1, 0, 0, 1, 100, 100);9console.log(transform);10var wptoolkit = require('wptoolkit');11var transform = wptoolkit.composeGFXTransform(1, 0, 0, 1, 100, 100);12console.log(transform);13var wptoolkit = require('wptoolkit');14var transform = wptoolkit.composeGFXTransform(1, 0, 0, 1, 100, 100);15console.log(transform);16var wptoolkit = require('wptoolkit');17var transform = wptoolkit.composeGFXTransform(1, 0, 0, 1, 100, 100);18console.log(transform);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = new wptools();3var transform = wp.composeGFXTransform(10, 10, 10, 10, 10, 10, 10, 10, 10, 10);4console.log(transform);5var wptools = require('wptools');6var wp = new wptools();7var transform = wp.composeGFXTransform(10, 10, 10, 10, 10, 10, 10, 10, 10, 10);8console.log(transform);9var wptools = require('wptools');10var wp = new wptools();11var transform = wp.composeGFXTransform(10, 10, 10, 10, 10, 10, 10, 10, 10, 10);12console.log(transform);13var wptools = require('wptools');14var wp = new wptools();15var transform = wp.composeGFXTransform(10, 10, 10, 10, 10, 10, 10, 10, 10, 10);16console.log(transform);17var wptools = require('wptools');18var wp = new wptools();19var transform = wp.composeGFXTransform(10, 10, 10, 10, 10, 10, 10, 10, 10, 10);20console.log(transform);21var wptools = require('wptools');22var wp = new wptools();23var transform = wp.composeGFXTransform(10, 10, 10, 10, 10, 10, 10, 10, 10, 10);24console.log(transform);25var wptools = require('wptools');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var gfx = wptools.composeGFXTransform(0,0,100,100,0,0,0,0,0,0);3console.log(gfx);4var wptools = require('wptools');5var gfx = wptools.composeGFXTransform(0,0,100,100,0,0,0,0,0,0);6console.log(gfx);7var wptools = require('wptools');8var gfx = wptools.composeGFXTransform(0,0,100,100,0,0,0,0,0,0);9console.log(gfx);10var wptools = require('wptools');11var gfx = wptools.composeGFXTransform(0,0,100,100,0,0,0,0,0,0);12console.log(gfx);13var wptools = require('wptools');14var gfx = wptools.composeGFXTransform(0,0,100,100,0,0,0,0,0,0);15console.log(gfx);16var wptools = require('wptools');17var gfx = wptools.composeGFXTransform(0,0,100,100,0,0,0,0,0,0);18console.log(gfx);19var wptools = require('wptools');20var gfx = wptools.composeGFXTransform(0,0,100,100,0,0,0,0,0,0);21console.log(gfx);22var wptools = require('wptools');23var gfx = wptools.composeGFXTransform(0,0,100,

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var gfx = require('wptoolkit/gfx');3var p1 = {x: 0, y: 0};4var p2 = {x: 0, y: 100};5var p3 = {x: 100, y: 0};6var points = [p1, p2, p3];7var transform = gfx.composeGFXTransform(points);8console.log(transform);9var wptoolkit = require('wptoolkit');10var gfx = require('wptoolkit/gfx');11var p1 = {x: 0, y: 0};12var p2 = {x: 0, y: 100};13var p3 = {x: 100, y: 0};14var points = [p1, p2, p3];15var transform = gfx.composeGFXTransform(points);16var newPoints = gfx.transformPoints(points, transform);17console.log(newPoints);18[ { x: 0, y: 0 }, { x: 0, y: 100 }, { x: 100, y: 0 } ]19var wptoolkit = require('wptoolkit');20var gfx = require('wptoolkit/gfx');21var p1 = {x: 0, y: 0};22var p2 = {x: 0, y: 100};23var p3 = {x: 100, y: 0};24var points = [p1, p2, p3];25var transform = gfx.composeGFXTransform(points);26var rect = {x: 0, y: 0, width: 100, height: 100};27var newRect = gfx.transformRect(rect, transform);28console.log(newRect);29{ x:

Full Screen

Using AI Code Generation

copy

Full Screen

1var srcMatrix = new Matrix();2srcMatrix.setTransform(100, 0, 0, 100, 0, 0);3var destMatrix = new Matrix();4destMatrix.setTransform(100, 0, 0, 100, 100, 100);5var pt = new Point(100, 100);6var matrix = new Matrix();7matrix.composeGFXTransform(srcMatrix, destMatrix);8var pt2 = matrix.transformPoint(pt);9print("pt2: " + pt2);10print("matrix: " + matrix);11importClass(Packages.com.webpdf.toolkit.script.util.Point);12importClass(Packages.com.webpdf.toolkit.script.util.Matrix);13var srcMatrix = new Matrix();14srcMatrix.setTransform(100, 0, 0, 100, 0, 0);15var destMatrix = new Matrix();16destMatrix.setTransform(100, 0, 0, 100, 100, 100);17var pt = new Point(100, 100);18var matrix = new Matrix();19matrix.composeGFXTransform(srcMatrix, destMatrix);20var pt2 = matrix.transformPoint(pt);21print("pt2: " + pt2);22print("matrix: " + matrix);

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful