How to use _calculateDepthInformation method in wpt

Best JavaScript code snippet using wpt

webxr-test.js

Source:webxr-test.js Github

copy

Full Screen

...765 };766 this.next_frame_id_++;767 this._calculateHitTestResults(frameData);768 this._calculateAnchorInformation(frameData);769 this._calculateDepthInformation(frameData);770 this._injectAdditionalFrameData(options, frameData);771 resolve({frameData});772 };773 if(this.sessionOptions_.mode == vrMojom.XRSessionMode.kInline) {774 // Inline sessions should not have a delay introduced since it causes them775 // to miss a vsync blink-side and delays propagation of changes that happened776 // within a rAFcb by one frame (e.g. setViewerOrigin() calls would take 2 frames777 // to propagate).778 populatePose();779 } else {780 // For immerive sessions, add additional delay to allow for anchor creation781 // promises to run.782 setTimeout(populatePose, 3); // note: according to MDN, the timeout is not exact783 }784 });785 }786 getEnvironmentIntegrationProvider(environmentProviderRequest) {787 if (this.environmentProviderReceiver_) {788 this.environmentProviderReceiver_.$.close();789 }790 this.environmentProviderReceiver_ =791 new vrMojom.XREnvironmentIntegrationProviderReceiver(this);792 this.environmentProviderReceiver_.$.bindHandle(793 environmentProviderRequest.handle);794 }795 setInputSourceButtonListener(listener) { listener.$.close(); }796 // Note that if getEnvironmentProvider hasn't finished running yet this will797 // be undefined. It's recommended that you allow a successful task to post798 // first before attempting to close.799 closeEnvironmentIntegrationProvider() {800 if (this.environmentProviderReceiver_) {801 this.environmentProviderReceiver_.$.close();802 }803 }804 closeDataProvider() {805 this.closeEnvironmentIntegrationProvider();806 this.dataProviderReceiver_.$.close();807 this.sessionOptions_ = null;808 }809 // XREnvironmentIntegrationProvider implementation:810 subscribeToHitTest(nativeOriginInformation, entityTypes, ray) {811 if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {812 // Reject outside of AR.813 return Promise.resolve({814 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,815 subscriptionId : 0n816 });817 }818 if (!this._nativeOriginKnown(nativeOriginInformation)) {819 return Promise.resolve({820 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,821 subscriptionId : 0n822 });823 }824 // Reserve the id for hit test source:825 const id = this.next_hit_test_id_++;826 const hitTestParameters = { isTransient: false, profileName: null };827 const controller = new FakeXRHitTestSourceController(id);828 return this._shouldHitTestSourceCreationSucceed(hitTestParameters, controller)829 .then((succeeded) => {830 if(succeeded) {831 // Store the subscription information as-is (including controller):832 this.hitTestSubscriptions_.set(id, { nativeOriginInformation, entityTypes, ray, controller });833 return Promise.resolve({834 result : vrMojom.SubscribeToHitTestResult.SUCCESS,835 subscriptionId : id836 });837 } else {838 return Promise.resolve({839 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,840 subscriptionId : 0n841 });842 }843 });844 }845 subscribeToHitTestForTransientInput(profileName, entityTypes, ray){846 if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {847 // Reject outside of AR.848 return Promise.resolve({849 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,850 subscriptionId : 0n851 });852 }853 const id = this.next_hit_test_id_++;854 const hitTestParameters = { isTransient: true, profileName: profileName };855 const controller = new FakeXRHitTestSourceController(id);856 // Check if we have hit test source creation callback.857 // If yes, ask it if the hit test source creation should succeed.858 // If no, for back-compat, assume the hit test source creation succeeded.859 return this._shouldHitTestSourceCreationSucceed(hitTestParameters, controller)860 .then((succeeded) => {861 if(succeeded) {862 // Store the subscription information as-is (including controller):863 this.transientHitTestSubscriptions_.set(id, { profileName, entityTypes, ray, controller });864 return Promise.resolve({865 result : vrMojom.SubscribeToHitTestResult.SUCCESS,866 subscriptionId : id867 });868 } else {869 return Promise.resolve({870 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,871 subscriptionId : 0n872 });873 }874 });875 }876 unsubscribeFromHitTest(subscriptionId) {877 let controller = null;878 if(this.transientHitTestSubscriptions_.has(subscriptionId)){879 controller = this.transientHitTestSubscriptions_.get(subscriptionId).controller;880 this.transientHitTestSubscriptions_.delete(subscriptionId);881 } else if(this.hitTestSubscriptions_.has(subscriptionId)){882 controller = this.hitTestSubscriptions_.get(subscriptionId).controller;883 this.hitTestSubscriptions_.delete(subscriptionId);884 }885 if(controller) {886 controller.deleted = true;887 }888 }889 createAnchor(nativeOriginInformation, nativeOriginFromAnchor) {890 return new Promise((resolve) => {891 if(this.anchor_creation_callback_ == null) {892 resolve({893 result : vrMojom.CreateAnchorResult.FAILURE,894 anchorId : 0n895 });896 return;897 }898 const mojoFromNativeOrigin = this._getMojoFromNativeOrigin(nativeOriginInformation);899 if(mojoFromNativeOrigin == null) {900 resolve({901 result : vrMojom.CreateAnchorResult.FAILURE,902 anchorId : 0n903 });904 return;905 }906 const mojoFromAnchor = XRMathHelper.mul4x4(mojoFromNativeOrigin, nativeOriginFromAnchor);907 const anchorCreationParameters = {908 requestedAnchorOrigin: mojoFromAnchor,909 isAttachedToEntity: false,910 };911 const anchorController = new FakeXRAnchorController();912 this.anchor_creation_callback_(anchorCreationParameters, anchorController)913 .then((result) => {914 if(result) {915 // If the test allowed the anchor creation,916 // store the anchor controller & return success.917 const anchor_id = this.next_anchor_id_;918 this.next_anchor_id_++;919 this.anchor_controllers_.set(anchor_id, anchorController);920 anchorController.device = this;921 anchorController.id = anchor_id;922 resolve({923 result : vrMojom.CreateAnchorResult.SUCCESS,924 anchorId : anchor_id925 });926 } else {927 // The test has rejected anchor creation.928 resolve({929 result : vrMojom.CreateAnchorResult.FAILURE,930 anchorId : 0n931 });932 }933 })934 .catch(() => {935 // The test threw an error, treat anchor creation as failed.936 resolve({937 result : vrMojom.CreateAnchorResult.FAILURE,938 anchorId : 0n939 });940 });941 });942 }943 createPlaneAnchor(planeFromAnchor, planeId) {944 return new Promise((resolve) => {945 // Not supported yet.946 resolve({947 result : vrMojom.CreateAnchorResult.FAILURE,948 anchorId : 0n,949 });950 });951 }952 detachAnchor(anchorId) {}953 // Utility function954 requestRuntimeSession(sessionOptions) {955 return this.runtimeSupportsSession(sessionOptions).then((result) => {956 // The JavaScript bindings convert c_style_names to camelCase names.957 const options = {958 transportMethod:959 vrMojom.XRPresentationTransportMethod.SUBMIT_AS_MAILBOX_HOLDER,960 waitForTransferNotification: true,961 waitForRenderNotification: true,962 waitForGpuFence: false,963 };964 let submit_frame_sink;965 if (result.supportsSession) {966 submit_frame_sink = {967 clientReceiver: this.presentation_provider_.getClientReceiver(),968 provider: this.presentation_provider_.bindProvider(sessionOptions),969 transportOptions: options970 };971 const dataProviderPtr = new vrMojom.XRFrameDataProviderRemote();972 this.dataProviderReceiver_ =973 new vrMojom.XRFrameDataProviderReceiver(this);974 this.dataProviderReceiver_.$.bindHandle(975 dataProviderPtr.$.bindNewPipeAndPassReceiver().handle);976 this.sessionOptions_ = sessionOptions;977 this.sessionClient_ = new vrMojom.XRSessionClientRemote();978 const clientReceiver = this.sessionClient_.$.bindNewPipeAndPassReceiver();979 const enabled_features = [];980 for (let i = 0; i < sessionOptions.requiredFeatures.length; i++) {981 if (this.supportedFeatures_.indexOf(sessionOptions.requiredFeatures[i]) !== -1) {982 enabled_features.push(sessionOptions.requiredFeatures[i]);983 } else {984 return Promise.resolve({session: null});985 }986 }987 for (let i =0; i < sessionOptions.optionalFeatures.length; i++) {988 if (this.supportedFeatures_.indexOf(sessionOptions.optionalFeatures[i]) !== -1) {989 enabled_features.push(sessionOptions.optionalFeatures[i]);990 }991 }992 this.enabledFeatures_ = enabled_features;993 return Promise.resolve({994 session: {995 submitFrameSink: submit_frame_sink,996 dataProvider: dataProviderPtr,997 clientReceiver: clientReceiver,998 displayInfo: this.displayInfo_,999 enabledFeatures: enabled_features,1000 deviceConfig: {1001 usesInputEventing: false,1002 defaultFramebufferScale: this.defaultFramebufferScale_,1003 supportsViewportScaling: true,1004 depthConfiguration:1005 enabled_features.includes(vrMojom.XRSessionFeature.DEPTH) ? {1006 depthUsage: vrMojom.XRDepthUsage.kCPUOptimized,1007 depthDataFormat: vrMojom.XRDepthDataFormat.kLuminanceAlpha,1008 } : null,1009 },1010 enviromentBlendMode: this.enviromentBlendMode_,1011 interactionMode: this.interactionMode_1012 }1013 });1014 } else {1015 return Promise.resolve({session: null});1016 }1017 });1018 }1019 runtimeSupportsSession(options) {1020 let result = this.supportedModes_.includes(options.mode);1021 if (options.requiredFeatures.includes(vrMojom.XRSessionFeature.DEPTH)1022 || options.optionalFeatures.includes(vrMojom.XRSessionFeature.DEPTH)) {1023 result &= options.depthOptions.usagePreferences.includes(vrMojom.XRDepthUsage.kCPUOptimized);1024 result &= options.depthOptions.dataFormatPreferences.includes(vrMojom.XRDepthDataFormat.kLuminanceAlpha);1025 }1026 return Promise.resolve({1027 supportsSession: result,1028 });1029 }1030 // Private functions - utilities:1031 _nativeOriginKnown(nativeOriginInformation){1032 if (nativeOriginInformation.inputSourceSpaceInfo !== undefined) {1033 if (!this.input_sources_.has(nativeOriginInformation.inputSourceSpaceInfo.inputSourceId)) {1034 // Unknown input source.1035 return false;1036 }1037 return true;1038 } else if (nativeOriginInformation.referenceSpaceType !== undefined) {1039 // Bounded_floor & unbounded ref spaces are not yet supported for AR:1040 if (nativeOriginInformation.referenceSpaceType == vrMojom.XRReferenceSpaceType.kUnbounded1041 || nativeOriginInformation.referenceSpaceType == vrMojom.XRReferenceSpaceType.kBoundedFloor) {1042 return false;1043 }1044 return true;1045 } else {1046 // Planes and anchors are not yet supported by the mock interface.1047 return false;1048 }1049 }1050 // Private functions - anchors implementation:1051 // Modifies passed in frameData to add anchor information.1052 _calculateAnchorInformation(frameData) {1053 if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {1054 return;1055 }1056 frameData.anchorsData = {allAnchorsIds: [], updatedAnchorsData: []};1057 for(const [id, controller] of this.anchor_controllers_) {1058 frameData.anchorsData.allAnchorsIds.push(id);1059 // Send the entire anchor data over if there was a change since last GetFrameData().1060 if(controller.dirty) {1061 const anchorData = {id};1062 if(!controller.paused) {1063 anchorData.mojoFromAnchor = getPoseFromTransform(1064 XRMathHelper.decomposeRigidTransform(1065 controller.getAnchorOrigin()));1066 }1067 controller.markProcessed();1068 frameData.anchorsData.updatedAnchorsData.push(anchorData);1069 }1070 }1071 }1072 // Private functions - depth sensing implementation:1073 // Modifies passed in frameData to add anchor information.1074 _calculateDepthInformation(frameData) {1075 if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {1076 return;1077 }1078 if (!this.enabledFeatures_.includes(vrMojom.XRSessionFeature.DEPTH)) {1079 return;1080 }1081 // If we don't have a current depth data, we'll return null1082 // (i.e. no data is not a valid data, so it cannot be "StillValid").1083 if (this.depthSensingData_ == null) {1084 frameData.depthData = null;1085 return;1086 }1087 if(!this.depthSensingDataDirty_) {1088 frameData.depthData = { dataStillValid: {}};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var tree = new YAHOO.widget.TreeView("treeDiv1");2var root = tree.getRoot();3var node1 = new YAHOO.widget.TextNode("Node1", root, false);4var node2 = new YAHOO.widget.TextNode("Node2", root, false);5var node3 = new YAHOO.widget.TextNode("Node3", root, false);6var node4 = new YAHOO.widget.TextNode("Node4", root, false);7var node5 = new YAHOO.widget.TextNode("Node5", root, false);8var node6 = new YAHOO.widget.TextNode("Node6", root, false);9var node7 = new YAHOO.widget.TextNode("Node7", root, false);10var node8 = new YAHOO.widget.TextNode("Node8", root, false);11var node9 = new YAHOO.widget.TextNode("Node9", root, false);12var node10 = new YAHOO.widget.TextNode("Node10", root, false);13var node11 = new YAHOO.widget.TextNode("Node11", root, false);14var node12 = new YAHOO.widget.TextNode("Node12", root, false);15var node13 = new YAHOO.widget.TextNode("Node13", root, false);16var node14 = new YAHOO.widget.TextNode("Node14", root, false);17var node15 = new YAHOO.widget.TextNode("Node15", root, false);18var node16 = new YAHOO.widget.TextNode("Node16", root, false);19var node17 = new YAHOO.widget.TextNode("Node17", root, false);20var node18 = new YAHOO.widget.TextNode("Node18", root, false);21var node19 = new YAHOO.widget.TextNode("Node19", root, false);22var node20 = new YAHOO.widget.TextNode("Node20", root, false);23var node21 = new YAHOO.widget.TextNode("Node21", root, false);24var node22 = new YAHOO.widget.TextNode("Node22", root, false);25var node23 = new YAHOO.widget.TextNode("Node23", root, false);26var node24 = new YAHOO.widget.TextNode("Node24", root, false);27var node25 = new YAHOO.widget.TextNode("Node25", root, false

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3wpt._calculateDepthInformation(url, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('wpt');11var wpt = new WebPageTest('www.webpagetest.org');12wpt._getScript(url, function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2wpt._calculateDepthInformation(testURL, function(err, data){3 if(err){4 console.log("Error: " + err);5 }6 else{7 console.log("Data: " + data);8 }9});10Data: { depth: 0, maxDepth: 0 }11var wpt = require('./wpt.js');12wpt._calculateDepthInformation(testURL, function(err, data){13 if(err){14 console.log("Error: " + err);15 }16 else{17 console.log("Data: " + data);18 }19});20Data: { depth: 0, maxDepth: 1 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var testId = '160331_7W_1M2';4wpt.getTestResults(testId, function(err, data) {5 console.log(data.data.median.firstView);6 console.log(data.data.median.firstView._calculateDepthInformation(data.data.median.firstView));7});8{ loadTime: 1002,

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolbox = require('./wptoolbox.js');2var fs = require('fs');3var data = fs.readFileSync('./test-data.json');4var parsedData = JSON.parse(data);5var depthInfo = wptoolbox._calculateDepthInformation(parsedData);6console.log(depthInfo);7var _calculateDepthInformation = function (data) {8 var depthInfo = {};9 var depth = 0;10 var arrayDepth = 0;11 var arrayLength = 0;12 var arrayLengths = [];13 var calculateDepth = function (obj) {14 depth++;15 for (var key in obj) {16 if (obj.hasOwnProperty(key)) {17 if (typeof obj[key] == 'object') {18 calculateDepth(obj[key]);19 } else {20 if (Array.isArray(obj[key])) {21 arrayDepth++;22 arrayLength = obj[key].length;23 arrayLengths.push(arrayLength);24 }25 }26 }27 }28 depth--;29 };30 calculateDepth(data);31 depthInfo.depth = depth;32 depthInfo.arrayDepth = arrayDepth;33 depthInfo.arrayLengths = arrayLengths;34 return depthInfo;35};36module.exports = {37};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('node-wpt');2var wpt = new wpt('yourwptapikey');3 if(error){4 console.log(error);5 }6 else{7 console.log(data);8 }9});10var wpt = require('node-wpt');11var wpt = new wpt('yourwptapikey');12 if(error){13 console.log(error);14 }15 else{16 console.log(data);17 }18});19 { depth: 12, url: 'https

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