How to use getPoseFromTransform method in wpt

Best JavaScript code snippet using wpt

webxr-test.js

Source:webxr-test.js Github

copy

Full Screen

...35 m12, m22, m32, 0,36 m13, m23, m33, 0,37 m14, m24, m34, 1];38}39function getPoseFromTransform(transform) {40 const [px, py, pz] = transform.position;41 const [ox, oy, oz, ow] = transform.orientation;42 return {43 position: {x: px, y: py, z: pz},44 orientation: {x: ox, y: oy, z: oz, w: ow},45 };46}47function composeGFXTransform(fakeTransformInit) {48 return {matrix: getMatrixFromTransform(fakeTransformInit)};49}50class ChromeXRTest {51 constructor() {52 this.mockVRService_ = new MockVRService();53 }54 simulateDeviceConnection(init_params) {55 return Promise.resolve(this.mockVRService_.addRuntime(init_params));56 }57 disconnectAllDevices() {58 this.mockVRService_.removeAllRuntimes();59 return Promise.resolve();60 }61 simulateUserActivation(callback) {62 if (window.top !== window) {63 // test_driver.click only works for the toplevel frame. This alternate64 // Chrome-specific method is sufficient for starting an XR session in an65 // iframe, and is used in platform-specific tests.66 //67 // TODO(https://github.com/web-platform-tests/wpt/issues/20282): use68 // a cross-platform method if available.69 xr_debug('simulateUserActivation', 'use eventSender');70 document.addEventListener('click', callback);71 eventSender.mouseMoveTo(0, 0);72 eventSender.mouseDown();73 eventSender.mouseUp();74 document.removeEventListener('click', callback);75 return;76 }77 const button = document.createElement('button');78 button.textContent = 'click to continue test';79 button.style.display = 'block';80 button.style.fontSize = '20px';81 button.style.padding = '10px';82 button.onclick = () => {83 callback();84 document.body.removeChild(button);85 };86 document.body.appendChild(button);87 test_driver.click(button);88 }89 Debug(name, msg) {90 console.log(new Date().toISOString() + ' DEBUG[' + name + '] ' + msg);91 }92}93// Mocking class definitions94// Mock service implements the VRService mojo interface.95class MockVRService {96 constructor() {97 this.receiver_ = new vrMojom.VRServiceReceiver(this);98 this.runtimes_ = [];99 this.interceptor_ =100 new MojoInterfaceInterceptor(vrMojom.VRService.$interfaceName);101 this.interceptor_.oninterfacerequest =102 e => this.receiver_.$.bindHandle(e.handle);103 this.interceptor_.start();104 }105 // Test methods106 addRuntime(fakeDeviceInit) {107 const runtime = new MockRuntime(fakeDeviceInit, this);108 this.runtimes_.push(runtime);109 if (this.client_) {110 this.client_.onDeviceChanged();111 }112 return runtime;113 }114 removeAllRuntimes() {115 if (this.client_) {116 this.client_.onDeviceChanged();117 }118 this.runtimes_ = [];119 }120 removeRuntime(device) {121 const index = this.runtimes_.indexOf(device);122 if (index >= 0) {123 this.runtimes_.splice(index, 1);124 if (this.client_) {125 this.client_.onDeviceChanged();126 }127 }128 }129 setClient(client) {130 if (this.client_) {131 throw new Error("setClient should only be called once");132 }133 this.client_ = client;134 }135 requestSession(sessionOptions) {136 const requests = [];137 // Request a session from all the runtimes.138 for (let i = 0; i < this.runtimes_.length; i++) {139 requests[i] = this.runtimes_[i].requestRuntimeSession(sessionOptions);140 }141 return Promise.all(requests).then((results) => {142 // Find and return the first successful result.143 for (let i = 0; i < results.length; i++) {144 if (results[i].session) {145 // Construct a dummy metrics recorder146 const metricsRecorderPtr = new vrMojom.XRSessionMetricsRecorderRemote();147 metricsRecorderPtr.$.bindNewPipeAndPassReceiver().handle.close();148 const success = {149 session: results[i].session,150 metricsRecorder: metricsRecorderPtr,151 };152 return {result: {success}};153 }154 }155 // If there were no successful results, returns a null session.156 return {157 result: {failureReason: vrMojom.RequestSessionError.NO_RUNTIME_FOUND}158 };159 });160 }161 exitPresent() {162 return Promise.resolve();163 }164 supportsSession(sessionOptions) {165 const requests = [];166 // Check supports on all the runtimes.167 for (let i = 0; i < this.runtimes_.length; i++) {168 requests[i] = this.runtimes_[i].runtimeSupportsSession(sessionOptions);169 }170 return Promise.all(requests).then((results) => {171 // Find and return the first successful result.172 for (let i = 0; i < results.length; i++) {173 if (results[i].supportsSession) {174 return results[i];175 }176 }177 // If there were no successful results, returns false.178 return {supportsSession: false};179 });180 }181 setFramesThrottled(throttled) {182 this.setFramesThrottledImpl(throttled);183 }184 // May be overridden by specific tests.185 setFramesThrottledImpl(throttled) {}186 // Only handles asynchronous calls to makeXrCompatible. Synchronous calls are187 // not supported in Javascript.188 makeXrCompatible() {189 if (this.runtimes_.length == 0) {190 return {191 xrCompatibleResult: vrMojom.XrCompatibleResult.kNoDeviceAvailable192 };193 }194 return {xrCompatibleResult: vrMojom.XrCompatibleResult.kAlreadyCompatible};195 }196}197class FakeXRAnchorController {198 constructor() {199 // Private properties.200 this.device_ = null;201 this.id_ = null;202 this.dirty_ = true;203 // Properties backing up public attributes / methods.204 this.deleted_ = false;205 this.paused_ = false;206 this.anchorOrigin_ = XRMathHelper.identity();207 }208 get deleted() {209 return this.deleted_;210 }211 pauseTracking() {212 if(!this.paused_) {213 this.paused_ = true;214 this.dirty_ = true;215 }216 }217 resumeTracking() {218 if(this.paused_) {219 this.paused_ = false;220 this.dirty_ = true;221 }222 }223 stopTracking() {224 if(!this.deleted_) {225 this.device_.deleteAnchorController(this.id_);226 this.deleted_ = true;227 this.dirty_ = true;228 }229 }230 setAnchorOrigin(anchorOrigin) {231 this.anchorOrigin_ = getMatrixFromTransform(anchorOrigin);232 this.dirty_ = true;233 }234 // Internal implementation:235 set id(value) {236 this.id_ = value;237 }238 set device(value) {239 this.device_ = value;240 }241 get dirty() {242 return this.dirty_;243 }244 get paused() {245 return this.paused_;246 }247 markProcessed() {248 this.dirty_ = false;249 }250 getAnchorOrigin() {251 return this.anchorOrigin_;252 }253}254// Internal only for now, needs to be moved into WebXR Test API.255class FakeXRHitTestSourceController {256 constructor(id) {257 this.id_ = id;258 this.deleted_ = false;259 }260 get deleted() {261 return this.deleted_;262 }263 // Internal setter:264 set deleted(value) {265 this.deleted_ = value;266 }267}268// Implements XRFrameDataProvider and XRPresentationProvider. Maintains a mock269// for XRPresentationProvider. Implements FakeXRDevice test API.270class MockRuntime {271 // Mapping from string feature names to the corresponding mojo types.272 // This is exposed as a member for extensibility.273 static featureToMojoMap = {274 'viewer': vrMojom.XRSessionFeature.REF_SPACE_VIEWER,275 'local': vrMojom.XRSessionFeature.REF_SPACE_LOCAL,276 'local-floor': vrMojom.XRSessionFeature.REF_SPACE_LOCAL_FLOOR,277 'bounded-floor': vrMojom.XRSessionFeature.REF_SPACE_BOUNDED_FLOOR,278 'unbounded': vrMojom.XRSessionFeature.REF_SPACE_UNBOUNDED,279 'hit-test': vrMojom.XRSessionFeature.HIT_TEST,280 'dom-overlay': vrMojom.XRSessionFeature.DOM_OVERLAY,281 'light-estimation': vrMojom.XRSessionFeature.LIGHT_ESTIMATION,282 'anchors': vrMojom.XRSessionFeature.ANCHORS,283 };284 static sessionModeToMojoMap = {285 "inline": vrMojom.XRSessionMode.kInline,286 "immersive-vr": vrMojom.XRSessionMode.kImmersiveVr,287 "immersive-ar": vrMojom.XRSessionMode.kImmersiveAr,288 };289 static environmentBlendModeToMojoMap = {290 "opaque": vrMojom.XREnvironmentBlendMode.kOpaque,291 "alpha-blend": vrMojom.XREnvironmentBlendMode.kAlphaBlend,292 "additive": vrMojom.XREnvironmentBlendMode.kAdditive,293 };294 static interactionModeToMojoMap = {295 "screen-space": vrMojom.XRInteractionMode.kScreenSpace,296 "world-space": vrMojom.XRInteractionMode.kWorldSpace,297 };298 constructor(fakeDeviceInit, service) {299 this.sessionClient_ = null;300 this.presentation_provider_ = new MockXRPresentationProvider();301 this.pose_ = null;302 this.next_frame_id_ = 0;303 this.bounds_ = null;304 this.send_mojo_space_reset_ = false;305 this.stageParameters_ = null;306 this.stageParametersId_ = 1;307 this.service_ = service;308 this.framesOfReference = {};309 this.input_sources_ = new Map();310 this.next_input_source_index_ = 1;311 // Currently active hit test subscriptons.312 this.hitTestSubscriptions_ = new Map();313 // Currently active transient hit test subscriptions.314 this.transientHitTestSubscriptions_ = new Map();315 // ID of the next subscription to be assigned.316 this.next_hit_test_id_ = 1n;317 this.anchor_controllers_ = new Map();318 // ID of the next anchor to be assigned.319 this.next_anchor_id_ = 1n;320 // Anchor creation callback (initially null, can be set by tests).321 this.anchor_creation_callback_ = null;322 let supportedModes = [];323 if (fakeDeviceInit.supportedModes) {324 supportedModes = fakeDeviceInit.supportedModes.slice();325 if (fakeDeviceInit.supportedModes.length === 0) {326 supportedModes = ["inline"];327 }328 } else {329 // Back-compat mode.330 console.warn("Please use `supportedModes` to signal which modes are supported by this device.");331 if (fakeDeviceInit.supportsImmersive == null) {332 throw new TypeError("'supportsImmersive' must be set");333 }334 supportedModes = ["inline"];335 if (fakeDeviceInit.supportsImmersive) {336 supportedModes.push("immersive-vr");337 }338 }339 this.supportedModes_ = this._convertModesToEnum(supportedModes);340 // Initialize DisplayInfo first to set the defaults, then override with341 // anything from the deviceInit342 if (this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveVr) ||343 this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {344 this.displayInfo_ = this.getImmersiveDisplayInfo();345 } else if (this.supportedModes_.includes(vrMojom.XRSessionMode.kInline)) {346 this.displayInfo_ = this.getNonImmersiveDisplayInfo();347 } else {348 // This should never happen!349 console.error("Device has empty supported modes array!");350 throw new InvalidStateError();351 }352 if (fakeDeviceInit.viewerOrigin != null) {353 this.setViewerOrigin(fakeDeviceInit.viewerOrigin);354 }355 if (fakeDeviceInit.floorOrigin != null) {356 this.setFloorOrigin(fakeDeviceInit.floorOrigin);357 }358 if (fakeDeviceInit.world) {359 this.world_ = fakeDeviceInit.world;360 }361 this.defaultFramebufferScale_ = default_framebuffer_scale;362 this.enviromentBlendMode_ = this._convertBlendModeToEnum(fakeDeviceInit.environmentBlendMode);363 this.interactionMode_ = this._convertInteractionModeToEnum(fakeDeviceInit.interactionMode);364 // This appropriately handles if the coordinates are null365 this.setBoundsGeometry(fakeDeviceInit.boundsCoordinates);366 this.setViews(fakeDeviceInit.views);367 // Need to support webVR which doesn't have a notion of features368 this.setFeatures(fakeDeviceInit.supportedFeatures || []);369 }370 _convertModeToEnum(sessionMode) {371 if (sessionMode in MockRuntime.sessionModeToMojoMap) {372 return MockRuntime.sessionModeToMojoMap[sessionMode];373 }374 throw new TypeError("Unrecognized value for XRSessionMode enum: " + sessionMode);375 }376 _convertModesToEnum(sessionModes) {377 return sessionModes.map(mode => this._convertModeToEnum(mode));378 }379 _convertBlendModeToEnum(blendMode) {380 if (blendMode in MockRuntime.environmentBlendModeToMojoMap) {381 return MockRuntime.environmentBlendModeToMojoMap[blendMode];382 } else {383 if (this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {384 return vrMojom.XREnvironmentBlendMode.kAdditive;385 } else if (this.supportedModes_.includes(386 vrMojom.XRSessionMode.kImmersiveVr)) {387 return vrMojom.XREnvironmentBlendMode.kOpaque;388 }389 }390 }391 _convertInteractionModeToEnum(interactionMode) {392 if (interactionMode in MockRuntime.interactionModeToMojoMap) {393 return MockRuntime.interactionModeToMojoMap[interactionMode];394 } else {395 return vrMojom.XRInteractionMode.kWorldSpace;396 }397 }398 // Test API methods.399 disconnect() {400 this.service_.removeRuntime(this);401 this.presentation_provider_.Close();402 if (this.sessionClient_) {403 this.sessionClient_.$.close();404 this.sessionClient_ = null;405 }406 return Promise.resolve();407 }408 setViews(views) {409 if (views) {410 let changed = false;411 for (let i = 0; i < views.length; i++) {412 if (views[i].eye == 'left') {413 this.displayInfo_.leftEye = this.getEye(views[i]);414 changed = true;415 } else if (views[i].eye == 'right') {416 this.displayInfo_.rightEye = this.getEye(views[i]);417 changed = true;418 }419 }420 if (changed && this.sessionClient_) {421 this.sessionClient_.onChanged(this.displayInfo_);422 }423 }424 }425 setViewerOrigin(origin, emulatedPosition = false) {426 const p = origin.position;427 const q = origin.orientation;428 this.pose_ = {429 orientation: { x: q[0], y: q[1], z: q[2], w: q[3] },430 position: { x: p[0], y: p[1], z: p[2] },431 emulatedPosition: emulatedPosition,432 angularVelocity: null,433 linearVelocity: null,434 angularAcceleration: null,435 linearAcceleration: null,436 inputState: null,437 poseIndex: 0438 };439 }440 clearViewerOrigin() {441 this.pose_ = null;442 }443 simulateVisibilityChange(visibilityState) {444 let mojoState = null;445 switch (visibilityState) {446 case "visible":447 mojoState = vrMojom.XRVisibilityState.VISIBLE;448 break;449 case "visible-blurred":450 mojoState = vrMojom.XRVisibilityState.VISIBLE_BLURRED;451 break;452 case "hidden":453 mojoState = vrMojom.XRVisibilityState.HIDDEN;454 break;455 }456 if (mojoState && this.sessionClient_) {457 this.sessionClient_.onVisibilityStateChanged(mojoState);458 }459 }460 setBoundsGeometry(bounds) {461 if (bounds == null) {462 this.bounds_ = null;463 } else if (bounds.length < 3) {464 throw new Error("Bounds must have a length of at least 3");465 } else {466 this.bounds_ = bounds;467 }468 // We can only set bounds if we have stageParameters set; otherwise, we469 // don't know the transform from local space to bounds space.470 // We'll cache the bounds so that they can be set in the future if the471 // floorLevel transform is set, but we won't update them just yet.472 if (this.stageParameters_) {473 this.stageParameters_.bounds = this.bounds_;474 this.onStageParametersUpdated();475 }476 }477 setFloorOrigin(floorOrigin) {478 if (!this.stageParameters_) {479 this.stageParameters_ = default_stage_parameters;480 this.stageParameters_.bounds = this.bounds_;481 }482 // floorOrigin is passed in as mojoFromFloor.483 this.stageParameters_.mojoFromFloor =484 {matrix: getMatrixFromTransform(floorOrigin)};485 this.onStageParametersUpdated();486 }487 clearFloorOrigin() {488 if (this.stageParameters_) {489 this.stageParameters_ = null;490 this.onStageParametersUpdated();491 }492 }493 onStageParametersUpdated() {494 // Indicate for the frame loop that the stage parameters have been updated.495 this.stageParametersId_++;496 }497 simulateResetPose() {498 this.send_mojo_space_reset_ = true;499 }500 simulateInputSourceConnection(fakeInputSourceInit) {501 const index = this.next_input_source_index_;502 this.next_input_source_index_++;503 const source = new MockXRInputSource(fakeInputSourceInit, index, this);504 this.input_sources_.set(index, source);505 return source;506 }507 setAnchorCreationCallback(callback) {508 this.anchor_creation_callback_ = callback;509 }510 setHitTestSourceCreationCallback(callback) {511 this.hit_test_source_creation_callback_ = callback;512 }513 setLightEstimate(fakeXrLightEstimateInit) {514 if (!fakeXrLightEstimateInit.sphericalHarmonicsCoefficients) {515 throw new TypeError("sphericalHarmonicsCoefficients must be set");516 }517 if (fakeXrLightEstimateInit.sphericalHarmonicsCoefficients.length != 27) {518 throw new TypeError("Must supply all 27 sphericalHarmonicsCoefficients");519 }520 if (fakeXrLightEstimateInit.primaryLightDirection && fakeXrLightEstimateInit.primaryLightDirection.w != 0) {521 throw new TypeError("W component of primaryLightDirection must be 0");522 }523 if (fakeXrLightEstimateInit.primaryLightIntensity && fakeXrLightEstimateInit.primaryLightIntensity.w != 1) {524 throw new TypeError("W component of primaryLightIntensity must be 1");525 }526 // If the primaryLightDirection or primaryLightIntensity aren't set, we need to set them527 // to the defaults that the spec expects. ArCore will either give us everything or nothing,528 // so these aren't nullable on the mojom.529 if (!fakeXrLightEstimateInit.primaryLightDirection) {530 fakeXrLightEstimateInit.primaryLightDirection = { x: 0.0, y: 1.0, z: 0.0, w: 0.0 };531 }532 if (!fakeXrLightEstimateInit.primaryLightIntensity) {533 fakeXrLightEstimateInit.primaryLightIntensity = { x: 0.0, y: 0.0, z: 0.0, w: 1.0 };534 }535 let c = fakeXrLightEstimateInit.sphericalHarmonicsCoefficients;536 this.light_estimate_ = {537 lightProbe: {538 // XRSphereicalHarmonics539 sphericalHarmonics: {540 coefficients: [541 { red: c[0], green: c[1], blue: c[2] },542 { red: c[3], green: c[4], blue: c[5] },543 { red: c[6], green: c[7], blue: c[8] },544 { red: c[9], green: c[10], blue: c[11] },545 { red: c[12], green: c[13], blue: c[14] },546 { red: c[15], green: c[16], blue: c[17] },547 { red: c[18], green: c[19], blue: c[20] },548 { red: c[21], green: c[22], blue: c[23] },549 { red: c[24], green: c[25], blue: c[26] }550 ]551 },552 // Vector3dF553 mainLightDirection: {554 x: fakeXrLightEstimateInit.primaryLightDirection.x,555 y: fakeXrLightEstimateInit.primaryLightDirection.y,556 z: fakeXrLightEstimateInit.primaryLightDirection.z557 },558 // RgbTupleF32559 mainLightIntensity: {560 red: fakeXrLightEstimateInit.primaryLightIntensity.x,561 green: fakeXrLightEstimateInit.primaryLightIntensity.y,562 blue: fakeXrLightEstimateInit.primaryLightIntensity.z563 }564 }565 }566 }567 // Helper methods568 getNonImmersiveDisplayInfo() {569 const displayInfo = this.getImmersiveDisplayInfo();570 displayInfo.capabilities.canPresent = false;571 displayInfo.leftEye = null;572 displayInfo.rightEye = null;573 return displayInfo;574 }575 // Function to generate some valid display information for the device.576 getImmersiveDisplayInfo() {577 return {578 displayName: 'FakeDevice',579 capabilities: {580 hasPosition: false,581 hasExternalDisplay: false,582 canPresent: true,583 maxLayers: 1584 },585 stageParameters: null,586 leftEye: {587 fieldOfView: {588 upDegrees: 48.316,589 downDegrees: 50.099,590 leftDegrees: 50.899,591 rightDegrees: 35.197592 },593 headFromEye: composeGFXTransform({594 position: [-0.032, 0, 0],595 orientation: [0, 0, 0, 1]596 }),597 renderWidth: 20,598 renderHeight: 20599 },600 rightEye: {601 fieldOfView: {602 upDegrees: 48.316,603 downDegrees: 50.099,604 leftDegrees: 50.899,605 rightDegrees: 35.197606 },607 headFromEye: composeGFXTransform({608 position: [0.032, 0, 0],609 orientation: [0, 0, 0, 1]610 }),611 renderWidth: 20,612 renderHeight: 20613 }614 };615 }616 // This function converts between the matrix provided by the WebXR test API617 // and the internal data representation.618 getEye(fakeXRViewInit) {619 let fov = null;620 if (fakeXRViewInit.fieldOfView) {621 fov = {622 upDegrees: fakeXRViewInit.fieldOfView.upDegrees,623 downDegrees: fakeXRViewInit.fieldOfView.downDegrees,624 leftDegrees: fakeXRViewInit.fieldOfView.leftDegrees,625 rightDegrees: fakeXRViewInit.fieldOfView.rightDegrees626 };627 } else {628 const m = fakeXRViewInit.projectionMatrix;629 function toDegrees(tan) {630 return Math.atan(tan) * 180 / Math.PI;631 }632 const leftTan = (1 - m[8]) / m[0];633 const rightTan = (1 + m[8]) / m[0];634 const upTan = (1 + m[9]) / m[5];635 const downTan = (1 - m[9]) / m[5];636 fov = {637 upDegrees: toDegrees(upTan),638 downDegrees: toDegrees(downTan),639 leftDegrees: toDegrees(leftTan),640 rightDegrees: toDegrees(rightTan)641 };642 }643 return {644 fieldOfView: fov,645 headFromEye: composeGFXTransform(fakeXRViewInit.viewOffset),646 renderWidth: fakeXRViewInit.resolution.width,647 renderHeight: fakeXRViewInit.resolution.height648 };649 }650 setFeatures(supportedFeatures) {651 function convertFeatureToMojom(feature) {652 if (feature in MockRuntime.featureToMojoMap) {653 return MockRuntime.featureToMojoMap[feature];654 } else {655 return vrMojom.XRSessionFeature.INVALID;656 }657 }658 this.supportedFeatures_ = [];659 for (let i = 0; i < supportedFeatures.length; i++) {660 const feature = convertFeatureToMojom(supportedFeatures[i]);661 if (feature !== vrMojom.XRSessionFeature.INVALID) {662 this.supportedFeatures_.push(feature);663 }664 }665 }666 // These methods are intended to be used by MockXRInputSource only.667 addInputSource(source) {668 if (!this.input_sources_.has(source.source_id_)) {669 this.input_sources_.set(source.source_id_, source);670 }671 }672 removeInputSource(source) {673 this.input_sources_.delete(source.source_id_);674 }675 // These methods are intended to be used by FakeXRAnchorController only.676 deleteAnchorController(controllerId) {677 this.anchor_controllers_.delete(controllerId);678 }679 // Extension point for non-standard modules.680 _injectAdditionalFrameData(options, frameData) {681 }682 // Mojo function implementations.683 // XRFrameDataProvider implementation.684 getFrameData(options) {685 return new Promise((resolve) => {686 const populatePose = () => {687 const mojo_space_reset = this.send_mojo_space_reset_;688 this.send_mojo_space_reset_ = false;689 if (this.pose_) {690 this.pose_.poseIndex++;691 }692 // Setting the input_state to null tests a slightly different path than693 // the browser tests where if the last input source is removed, the device694 // code always sends up an empty array, but it's also valid mojom to send695 // up a null array.696 let input_state = null;697 if (this.input_sources_.size > 0) {698 input_state = [];699 for (const input_source of this.input_sources_.values()) {700 input_state.push(input_source.getInputSourceState());701 }702 }703 const frameData = {704 pose: this.pose_,705 mojoSpaceReset: mojo_space_reset,706 inputState: input_state,707 timeDelta: {708 // window.performance.now() is in milliseconds, so convert to microseconds.709 microseconds: BigInt(Math.floor(window.performance.now() * 1000)),710 },711 frameId: this.next_frame_id_,712 bufferHolder: null,713 bufferSize: {},714 renderingTimeRatio: 0,715 stageParameters: this.stageParameters_,716 stageParametersId: this.stageParametersId_,717 lightEstimationData: this.light_estimate_718 };719 this.next_frame_id_++;720 this._calculateHitTestResults(frameData);721 this._calculateAnchorInformation(frameData);722 this._injectAdditionalFrameData(options, frameData);723 resolve({frameData});724 };725 if(this.sessionOptions_.mode == vrMojom.XRSessionMode.kInline) {726 // Inline sessions should not have a delay introduced since it causes them727 // to miss a vsync blink-side and delays propagation of changes that happened728 // within a rAFcb by one frame (e.g. setViewerOrigin() calls would take 2 frames729 // to propagate).730 populatePose();731 } else {732 // For immerive sessions, add additional delay to allow for anchor creation733 // promises to run.734 setTimeout(populatePose, 3); // note: according to MDN, the timeout is not exact735 }736 });737 }738 getEnvironmentIntegrationProvider(environmentProviderRequest) {739 if (this.environmentProviderReceiver_) {740 this.environmentProviderReceiver_.$.close();741 }742 this.environmentProviderReceiver_ =743 new vrMojom.XREnvironmentIntegrationProviderReceiver(this);744 this.environmentProviderReceiver_.$.bindHandle(745 environmentProviderRequest.handle);746 }747 setInputSourceButtonListener(listener) { listener.$.close(); }748 // Note that if getEnvironmentProvider hasn't finished running yet this will749 // be undefined. It's recommended that you allow a successful task to post750 // first before attempting to close.751 closeEnvironmentIntegrationProvider() {752 if (this.environmentProviderReceiver_) {753 this.environmentProviderReceiver_.$.close();754 }755 }756 closeDataProvider() {757 this.closeEnvironmentIntegrationProvider();758 this.dataProviderReceiver_.$.close();759 this.sessionOptions_ = null;760 }761 // XREnvironmentIntegrationProvider implementation:762 subscribeToHitTest(nativeOriginInformation, entityTypes, ray) {763 if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {764 // Reject outside of AR.765 return Promise.resolve({766 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,767 subscriptionId : 0n768 });769 }770 if (!this._nativeOriginKnown(nativeOriginInformation)) {771 return Promise.resolve({772 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,773 subscriptionId : 0n774 });775 }776 // Reserve the id for hit test source:777 const id = this.next_hit_test_id_++;778 const hitTestParameters = { isTransient: false, profileName: null };779 const controller = new FakeXRHitTestSourceController(id);780 return this._shouldHitTestSourceCreationSucceed(hitTestParameters, controller)781 .then((succeeded) => {782 if(succeeded) {783 // Store the subscription information as-is (including controller):784 this.hitTestSubscriptions_.set(id, { nativeOriginInformation, entityTypes, ray, controller });785 return Promise.resolve({786 result : vrMojom.SubscribeToHitTestResult.SUCCESS,787 subscriptionId : id788 });789 } else {790 return Promise.resolve({791 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,792 subscriptionId : 0n793 });794 }795 });796 }797 subscribeToHitTestForTransientInput(profileName, entityTypes, ray){798 if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {799 // Reject outside of AR.800 return Promise.resolve({801 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,802 subscriptionId : 0n803 });804 }805 const id = this.next_hit_test_id_++;806 const hitTestParameters = { isTransient: true, profileName: profileName };807 const controller = new FakeXRHitTestSourceController(id);808 // Check if we have hit test source creation callback.809 // If yes, ask it if the hit test source creation should succeed.810 // If no, for back-compat, assume the hit test source creation succeeded.811 return this._shouldHitTestSourceCreationSucceed(hitTestParameters, controller)812 .then((succeeded) => {813 if(succeeded) {814 // Store the subscription information as-is (including controller):815 this.transientHitTestSubscriptions_.set(id, { profileName, entityTypes, ray, controller });816 return Promise.resolve({817 result : vrMojom.SubscribeToHitTestResult.SUCCESS,818 subscriptionId : id819 });820 } else {821 return Promise.resolve({822 result : vrMojom.SubscribeToHitTestResult.FAILURE_GENERIC,823 subscriptionId : 0n824 });825 }826 });827 }828 unsubscribeFromHitTest(subscriptionId) {829 let controller = null;830 if(this.transientHitTestSubscriptions_.has(subscriptionId)){831 controller = this.transientHitTestSubscriptions_.get(subscriptionId).controller;832 this.transientHitTestSubscriptions_.delete(subscriptionId);833 } else if(this.hitTestSubscriptions_.has(subscriptionId)){834 controller = this.hitTestSubscriptions_.get(subscriptionId).controller;835 this.hitTestSubscriptions_.delete(subscriptionId);836 }837 if(controller) {838 controller.deleted = true;839 }840 }841 createAnchor(nativeOriginInformation, nativeOriginFromAnchor) {842 return new Promise((resolve) => {843 if(this.anchor_creation_callback_ == null) {844 resolve({845 result : vrMojom.CreateAnchorResult.FAILURE,846 anchorId : 0n847 });848 return;849 }850 const mojoFromNativeOrigin = this._getMojoFromNativeOrigin(nativeOriginInformation);851 if(mojoFromNativeOrigin == null) {852 resolve({853 result : vrMojom.CreateAnchorResult.FAILURE,854 anchorId : 0n855 });856 return;857 }858 const mojoFromAnchor = XRMathHelper.mul4x4(mojoFromNativeOrigin, nativeOriginFromAnchor);859 const anchorCreationParameters = {860 requestedAnchorOrigin: mojoFromAnchor,861 isAttachedToEntity: false,862 };863 const anchorController = new FakeXRAnchorController();864 this.anchor_creation_callback_(anchorCreationParameters, anchorController)865 .then((result) => {866 if(result) {867 // If the test allowed the anchor creation,868 // store the anchor controller & return success.869 const anchor_id = this.next_anchor_id_;870 this.next_anchor_id_++;871 this.anchor_controllers_.set(anchor_id, anchorController);872 anchorController.device = this;873 anchorController.id = anchor_id;874 resolve({875 result : vrMojom.CreateAnchorResult.SUCCESS,876 anchorId : anchor_id877 });878 } else {879 // The test has rejected anchor creation.880 resolve({881 result : vrMojom.CreateAnchorResult.FAILURE,882 anchorId : 0n883 });884 }885 })886 .catch(() => {887 // The test threw an error, treat anchor creation as failed.888 resolve({889 result : vrMojom.CreateAnchorResult.FAILURE,890 anchorId : 0n891 });892 });893 });894 }895 createPlaneAnchor(planeFromAnchor, planeId) {896 return new Promise((resolve) => {897 // Not supported yet.898 resolve({899 result : vrMojom.CreateAnchorResult.FAILURE,900 anchorId : 0n,901 });902 });903 }904 detachAnchor(anchorId) {}905 // Utility function906 requestRuntimeSession(sessionOptions) {907 return this.runtimeSupportsSession(sessionOptions).then((result) => {908 // The JavaScript bindings convert c_style_names to camelCase names.909 const options = {910 transportMethod:911 vrMojom.XRPresentationTransportMethod.SUBMIT_AS_MAILBOX_HOLDER,912 waitForTransferNotification: true,913 waitForRenderNotification: true,914 waitForGpuFence: false,915 };916 let submit_frame_sink;917 if (result.supportsSession) {918 submit_frame_sink = {919 clientReceiver: this.presentation_provider_.getClientReceiver(),920 provider: this.presentation_provider_.bindProvider(sessionOptions),921 transportOptions: options922 };923 const dataProviderPtr = new vrMojom.XRFrameDataProviderRemote();924 this.dataProviderReceiver_ =925 new vrMojom.XRFrameDataProviderReceiver(this);926 this.dataProviderReceiver_.$.bindHandle(927 dataProviderPtr.$.bindNewPipeAndPassReceiver().handle);928 this.sessionOptions_ = sessionOptions;929 this.sessionClient_ = new vrMojom.XRSessionClientRemote();930 const clientReceiver = this.sessionClient_.$.bindNewPipeAndPassReceiver();931 const enabled_features = [];932 for (let i = 0; i < sessionOptions.requiredFeatures.length; i++) {933 if (this.supportedFeatures_.indexOf(sessionOptions.requiredFeatures[i]) !== -1) {934 enabled_features.push(sessionOptions.requiredFeatures[i]);935 } else {936 return Promise.resolve({session: null});937 }938 }939 for (let i =0; i < sessionOptions.optionalFeatures.length; i++) {940 if (this.supportedFeatures_.indexOf(sessionOptions.optionalFeatures[i]) !== -1) {941 enabled_features.push(sessionOptions.optionalFeatures[i]);942 }943 }944 return Promise.resolve({945 session: {946 submitFrameSink: submit_frame_sink,947 dataProvider: dataProviderPtr,948 clientReceiver: clientReceiver,949 displayInfo: this.displayInfo_,950 enabledFeatures: enabled_features,951 deviceConfig: {952 usesInputEventing: false,953 defaultFramebufferScale: this.defaultFramebufferScale_,954 supportsViewportScaling: true955 },956 enviromentBlendMode: this.enviromentBlendMode_,957 interactionMode: this.interactionMode_958 }959 });960 } else {961 return Promise.resolve({session: null});962 }963 });964 }965 runtimeSupportsSession(options) {966 return Promise.resolve({967 supportsSession: this.supportedModes_.includes(options.mode)968 });969 }970 // Private functions - utilities:971 _nativeOriginKnown(nativeOriginInformation){972 if (nativeOriginInformation.inputSourceId !== undefined) {973 if (!this.input_sources_.has(nativeOriginInformation.inputSourceId)) {974 // Unknown input source.975 return false;976 }977 return true;978 } else if (nativeOriginInformation.referenceSpaceType !== undefined) {979 // Bounded_floor & unbounded ref spaces are not yet supported for AR:980 if (nativeOriginInformation.referenceSpaceType == vrMojom.XRReferenceSpaceType.kUnbounded981 || nativeOriginInformation.referenceSpaceType == vrMojom.XRReferenceSpaceType.kBoundedFloor) {982 return false;983 }984 return true;985 } else {986 // Planes and anchors are not yet supported by the mock interface.987 return false;988 }989 }990 // Private functions - anchors implementation:991 // Modifies passed in frameData to add anchor information.992 _calculateAnchorInformation(frameData) {993 if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {994 return;995 }996 frameData.anchorsData = {allAnchorsIds: [], updatedAnchorsData: []};997 for(const [id, controller] of this.anchor_controllers_) {998 frameData.anchorsData.allAnchorsIds.push(id);999 // Send the entire anchor data over if there was a change since last GetFrameData().1000 if(controller.dirty) {1001 const anchorData = {id};1002 if(!controller.paused) {1003 anchorData.mojoFromAnchor = getPoseFromTransform(1004 XRMathHelper.decomposeRigidTransform(1005 controller.getAnchorOrigin()));1006 }1007 controller.markProcessed();1008 frameData.anchorsData.updatedAnchorsData.push(anchorData);1009 }1010 }1011 }1012 // Private functions - hit test implementation:1013 // Returns a Promise<bool> that signifies whether hit test source creation should succeed.1014 // If we have a hit test source creation callback installed, invoke it and return its result.1015 // If it's not installed, for back-compat just return a promise that resolves to true.1016 _shouldHitTestSourceCreationSucceed(hitTestParameters, controller) {1017 if(this.hit_test_source_creation_callback_) {1018 return this.hit_test_source_creation_callback_(hitTestParameters, controller);1019 } else {1020 return Promise.resolve(true);1021 }1022 }1023 // Modifies passed in frameData to add hit test results.1024 _calculateHitTestResults(frameData) {1025 if (!this.supportedModes_.includes(vrMojom.XRSessionMode.kImmersiveAr)) {1026 return;1027 }1028 frameData.hitTestSubscriptionResults = {results: [],1029 transientInputResults: []};1030 if (!this.world_) {1031 return;1032 }1033 // Non-transient hit test:1034 for (const [id, subscription] of this.hitTestSubscriptions_) {1035 const mojo_from_native_origin = this._getMojoFromNativeOrigin(subscription.nativeOriginInformation);1036 if (!mojo_from_native_origin) continue;1037 const [mojo_ray_origin, mojo_ray_direction] = this._transformRayToMojoSpace(1038 subscription.ray,1039 mojo_from_native_origin1040 );1041 const results = this._hitTestWorld(mojo_ray_origin, mojo_ray_direction, subscription.entityTypes);1042 frameData.hitTestSubscriptionResults.results.push(1043 {subscriptionId: id, hitTestResults: results});1044 }1045 // Transient hit test:1046 const mojo_from_viewer = this._getMojoFromViewer();1047 for (const [id, subscription] of this.transientHitTestSubscriptions_) {1048 const result = {subscriptionId: id,1049 inputSourceIdToHitTestResults: new Map()};1050 // Find all input sources that match the profile name:1051 const matching_input_sources = Array.from(this.input_sources_.values())1052 .filter(input_source => input_source.profiles_.includes(subscription.profileName));1053 for (const input_source of matching_input_sources) {1054 const mojo_from_native_origin = input_source._getMojoFromInputSource(mojo_from_viewer);1055 const [mojo_ray_origin, mojo_ray_direction] = this._transformRayToMojoSpace(1056 subscription.ray,1057 mojo_from_native_origin1058 );1059 const results = this._hitTestWorld(mojo_ray_origin, mojo_ray_direction, subscription.entityTypes);1060 result.inputSourceIdToHitTestResults.set(input_source.source_id_, results);1061 }1062 frameData.hitTestSubscriptionResults.transientInputResults.push(result);1063 }1064 }1065 // Returns 2-element array [origin, direction] of a ray in mojo space.1066 // |ray| is expressed relative to native origin.1067 _transformRayToMojoSpace(ray, mojo_from_native_origin) {1068 const ray_origin = {1069 x: ray.origin.x,1070 y: ray.origin.y,1071 z: ray.origin.z,1072 w: 11073 };1074 const ray_direction = {1075 x: ray.direction.x,1076 y: ray.direction.y,1077 z: ray.direction.z,1078 w: 01079 };1080 const mojo_ray_origin = XRMathHelper.transform_by_matrix(1081 mojo_from_native_origin,1082 ray_origin);1083 const mojo_ray_direction = XRMathHelper.transform_by_matrix(1084 mojo_from_native_origin,1085 ray_direction);1086 return [mojo_ray_origin, mojo_ray_direction];1087 }1088 // Hit tests the passed in ray (expressed as origin and direction) against the mocked world data.1089 _hitTestWorld(origin, direction, entityTypes) {1090 let result = [];1091 for (const region of this.world_.hitTestRegions) {1092 const partial_result = this._hitTestRegion(1093 region,1094 origin, direction,1095 entityTypes);1096 result = result.concat(partial_result);1097 }1098 return result.sort((lhs, rhs) => lhs.distance - rhs.distance).map((hitTest) => {1099 delete hitTest.distance;1100 return hitTest;1101 });1102 }1103 // Hit tests the passed in ray (expressed as origin and direction) against world region.1104 // |entityTypes| is a set of FakeXRRegionTypes.1105 // |region| is FakeXRRegion.1106 // Returns array of XRHitResults, each entry will be decorated with the distance from the ray origin (along the ray).1107 _hitTestRegion(region, origin, direction, entityTypes) {1108 const regionNameToMojoEnum = {1109 "point": vrMojom.EntityTypeForHitTest.POINT,1110 "plane": vrMojom.EntityTypeForHitTest.PLANE,1111 "mesh":null1112 };1113 if (!entityTypes.includes(regionNameToMojoEnum[region.type])) {1114 return [];1115 }1116 const result = [];1117 for (const face of region.faces) {1118 const maybe_hit = this._hitTestFace(face, origin, direction);1119 if (maybe_hit) {1120 result.push(maybe_hit);1121 }1122 }1123 // The results should be sorted by distance and there should be no 2 entries with1124 // the same distance from ray origin - that would mean they are the same point.1125 // This situation is possible when a ray intersects the region through an edge shared1126 // by 2 faces.1127 return result.sort((lhs, rhs) => lhs.distance - rhs.distance)1128 .filter((val, index, array) => index === 0 || val.distance !== array[index - 1].distance);1129 }1130 // Hit tests the passed in ray (expressed as origin and direction) against a single face.1131 // |face|, |origin|, and |direction| are specified in world (aka mojo) coordinates.1132 // |face| is an array of DOMPointInits.1133 // Returns null if the face does not intersect with the ray, otherwise the result is1134 // an XRHitResult with matrix describing the pose of the intersection point.1135 _hitTestFace(face, origin, direction) {1136 const add = XRMathHelper.add;1137 const sub = XRMathHelper.sub;1138 const mul = XRMathHelper.mul;1139 const normalize = XRMathHelper.normalize;1140 const dot = XRMathHelper.dot;1141 const cross = XRMathHelper.cross;1142 const neg = XRMathHelper.neg;1143 //1. Calculate plane normal in world coordinates.1144 const point_A = face.vertices[0];1145 const point_B = face.vertices[1];1146 const point_C = face.vertices[2];1147 const edge_AB = sub(point_B, point_A);1148 const edge_AC = sub(point_C, point_A);1149 const normal = normalize(cross(edge_AB, edge_AC));1150 const numerator = dot(sub(point_A, origin), normal);1151 const denominator = dot(direction, normal);1152 if (Math.abs(denominator) < XRMathHelper.EPSILON) {1153 // Planes are nearly parallel - there's either infinitely many intersection points or 0.1154 // Both cases signify a "no hit" for us.1155 return null;1156 } else {1157 // Single intersection point between the infinite plane and the line (*not* ray).1158 // Need to calculate the hit test matrix taking into account the face vertices.1159 const distance = numerator / denominator;1160 if (distance < 0) {1161 // Line - plane intersection exists, but not the half-line - plane does not.1162 return null;1163 } else {1164 const intersection_point = add(origin, mul(distance, direction));1165 // Since we are treating the face as a solid, flip the normal so that its1166 // half-space will contain the ray origin.1167 const y_axis = denominator > 0 ? neg(normal) : normal;1168 let z_axis = null;1169 const cos_direction_and_y_axis = dot(direction, y_axis);1170 if (Math.abs(cos_direction_and_y_axis) > (1 - XRMathHelper.EPSILON)) {1171 // Ray and the hit test normal are co-linear - try using the 'up' or 'right' vector's projection on the face plane as the Z axis.1172 // Note: this edge case is currently not covered by the spec.1173 const up = {x: 0.0, y: 1.0, z: 0.0, w: 0.0};1174 const right = {x: 1.0, y: 0.0, z: 0.0, w: 0.0};1175 z_axis = Math.abs(dot(up, y_axis)) > (1 - XRMathHelper.EPSILON)1176 ? sub(up, mul(dot(right, y_axis), y_axis)) // `up is also co-linear with hit test normal, use `right`1177 : sub(up, mul(dot(up, y_axis), y_axis)); // `up` is not co-linear with hit test normal, use it1178 } else {1179 // Project the ray direction onto the plane, negate it and use as a Z axis.1180 z_axis = neg(sub(direction, mul(cos_direction_and_y_axis, y_axis))); // Z should point towards the ray origin, not away.1181 }1182 z_axis = normalize(z_axis);1183 const x_axis = normalize(cross(y_axis, z_axis));1184 // Filter out the points not in polygon.1185 if (!XRMathHelper.pointInFace(intersection_point, face)) {1186 return null;1187 }1188 const hitResult = {planeId: 0n};1189 hitResult.distance = distance; // Extend the object with additional information used by higher layers.1190 // It will not be serialized over mojom.1191 const matrix = new Array(16);1192 matrix[0] = x_axis.x;1193 matrix[1] = x_axis.y;1194 matrix[2] = x_axis.z;1195 matrix[3] = 0;1196 matrix[4] = y_axis.x;1197 matrix[5] = y_axis.y;1198 matrix[6] = y_axis.z;1199 matrix[7] = 0;1200 matrix[8] = z_axis.x;1201 matrix[9] = z_axis.y;1202 matrix[10] = z_axis.z;1203 matrix[11] = 0;1204 matrix[12] = intersection_point.x;1205 matrix[13] = intersection_point.y;1206 matrix[14] = intersection_point.z;1207 matrix[15] = 1;1208 hitResult.mojoFromResult = getPoseFromTransform(1209 XRMathHelper.decomposeRigidTransform(matrix));1210 return hitResult;1211 }1212 }1213 }1214 _getMojoFromViewer() {1215 const transform = {1216 position: [1217 this.pose_.position.x,1218 this.pose_.position.y,1219 this.pose_.position.z],1220 orientation: [1221 this.pose_.orientation.x,1222 this.pose_.orientation.y,...

Full Screen

Full Screen

eigen__tools_8h.js

Source:eigen__tools_8h.js Github

copy

Full Screen

1var eigen__tools_8h =2[3 [ "M_PI", "eigen__tools_8h.html#ae71449b1cc6e6250b91f539153a7a0d3", null ],4 [ "point2d_t", "eigen__tools_8h.html#a3a6fb94addf2e652b0cbb96d997a487a", null ],5 [ "pose2d_t", "eigen__tools_8h.html#aa41fef45ded090d62ca79ab9cc4a22b1", null ],6 [ "transform2d_t", "eigen__tools_8h.html#a78415c54cac6f59e7a20ea4f60f467fc", null ],7 [ "convertFromTransform", "eigen__tools_8h.html#a68f377d243e6a92d1cb560fe437fdd38", null ],8 [ "convertToTransform", "eigen__tools_8h.html#a0059c3bf6fc41992c08f37e20bf99945", null ],9 [ "getAngle", "eigen__tools_8h.html#a04db916789e4dea722320faf6db5f3c9", null ],10 [ "getAngleDiffrence", "eigen__tools_8h.html#a789bfba989add7bd529348be5363f529", null ],11 [ "getDisplacement", "eigen__tools_8h.html#a35428cce41a05ce0fdab759dc5c54de2", null ],12 [ "getPoseFromTransform", "eigen__tools_8h.html#a7106831976c91028d6fba7760f7c801d", null ],13 [ "getTransFromPose", "eigen__tools_8h.html#ab1d0a592cbf7da2c312101241139e5a8", null ],14 [ "matToVec2d", "eigen__tools_8h.html#a4000564fe6e2ac902fd0b8d42c5bee90", null ],15 [ "matToVec2d", "eigen__tools_8h.html#a414384ddc2f667c32ac41a8771e1c13e", null ],16 [ "matToVec2d", "eigen__tools_8h.html#abe21bbeec3bf134c12f16e5d506be3de", null ],17 [ "matToVec2d", "eigen__tools_8h.html#a4fd5809d4b679fdeec4e7f08f56028f4", null ],18 [ "normalizeAngle", "eigen__tools_8h.html#a67eca01fd5e8e8808191c6844d8e552d", null ],19 [ "transBtwFrames", "eigen__tools_8h.html#a06571086c158d3983d92eb924516c804", null ],20 [ "transBtwPoses", "eigen__tools_8h.html#a15277f774d432d611fe50f7313c03377", null ],21 [ "transformConcat", "eigen__tools_8h.html#afa17999bff0506cd804e980d4998f266", null ],22 [ "transformPose", "eigen__tools_8h.html#ae5e7c98ae440de9344632e8e159ba13d", null ],23 [ "vecToMat2d", "eigen__tools_8h.html#a4a29b6c11e112e6e730f938e04161c96", null ],24 [ "vecToMat3d", "eigen__tools_8h.html#a97ac9f66a55684a7ba1fcd70343d2a7b", null ]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var pose = wptoolkit.getPoseFromTransform([1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0]);3console.log(pose);4var wptoolkit = require('wptoolkit');5var transform = wptoolkit.getTransformFromPose([0, 0, 0], [0, 0, 0, 1]);6console.log(transform);7var wptoolkit = require('wptoolkit');8var pose = wptoolkit.getPoseFromTransform([1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0]);9console.log(pose);10var wptoolkit = require('wptoolkit');11var transform = wptoolkit.getTransformFromPose([0, 0, 0], [0, 0, 0, 1]);12console.log(transform);13var wptoolkit = require('wptoolkit');14var pose = wptoolkit.getPoseFromTransform([1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0]);15console.log(pose);16var wptoolkit = require('wptoolkit');17var transform = wptoolkit.getTransformFromPose([0, 0, 0], [0, 0, 0, 1]);18console.log(transform);19var wptoolkit = require('wptoolkit');20var pose = wptoolkit.getPoseFromTransform([1,

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var pose = wptools.getPoseFromTransform([1,0,0,0,0,1,0,-1,0,1,0,0,0,0,0,1]);3console.log(pose);4var wptools = require('wptools');5var transform = wptools.getTransformFromPose([1,0,0,0,0,1,0,-1,0,1,0,0,0,0,0,1]);6console.log(transform);7var wptools = require('wptools');8var transform = wptools.getTransformFromPose([1,0,0,0,0,1,0,-1,0,1,0,0,0,0,0,1]);9console.log(transform);10var wptools = require('wptools');11var transform = wptools.getTransformFromPose([1,0,0,0,0,1,0,-1,0,1,0,0,0,0,0,1]);12console.log(transform);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptf = require('wptf');2var pose = wptf.getPoseFromTransform([1,0,0,0,0,1,0,0,0,0,1,0]);3console.log(pose);4var wptf = require('wptf');5var transform = wptf.getTransformFromPose({position:{x:1,y:2,z:3},orientation:{x:0,y:0,z:0,w:1}});6console.log(transform);7var wptf = require('wptf');8var transform = wptf.getTransformFromPose({position:{x:1,y:2,z:3},orientation:{x:0,y:0,z:0,w:1}});9console.log(transform);10var wptf = require('wptf');11var transform = wptf.getTransformFromPose({position:{x:1,y:2,z:3},orientation:{x:0,y:0,z:0,w:1}});12console.log(transform);13var wptf = require('wptf');14var transform = wptf.getTransformFromPose({position:{x:1,y:2,z:3},orientation

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('web-platform-tests');2var assert = require('assert');3var pose = wpt.getPoseFromTransform(1, 2, 3, 4, 5, 6);4assert(pose.position.x == 1);5assert(pose.position.y == 2);6assert(pose.position.z == 3);7assert(pose.orientation.x == 4);8assert(pose.orientation.y == 5);9assert(pose.orientation.z == 6);10assert(pose.orientation.w == 1);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4wpt.getPoseFromTransform(options, function(err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data);9 }10});11var wpt = require('webpagetest');12var options = {13};14wpt.getPoseFromTransform(options, function(err, data) {15 if (err) {16 console.log(err);17 } else {18 console.log(data);19 }20});21var wpt = require('webpagetest');22var options = {23};24wpt.getPoseFromTransform(options, function(err, data) {25 if (err) {26 console.log(err);27 } else {28 console.log(data);29 }30});31var wpt = require('webpagetest');32var options = {33};34wpt.getPoseFromTransform(options, function(err, data) {35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('webpagetest');42var options = {43};44wpt.getPoseFromTransform(options, function(err, data) {45 if (err) {46 console.log(err);47 } else {48 console.log(data);49 }50});51var wpt = require('webpagetest');52var options = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptoolkit = require('wptoolkit');2const fs = require('fs');3const data = fs.readFileSync('test.json');4const dataJson = JSON.parse(data);5var pose = wptoolkit.getPoseFromTransform(dataJson);6console.log(pose);7console.log(pose.position);8console.log(pose.orientation);9console.log(pose.rotation);10console.log(pose.scale);11console.log(pose.euler);12console.log(pose.quaternion);13console.log(pose.matrix);14console.log(pose.up);15console.log(pose.right);16console.log(pose.forward);17console.log(pose.worldUp);18console.log(pose.worldRight);19console.log(pose.worldForward);20console.log(pose.fov);21console.log(pose.near);22console.log(pose.far);23console.log(pose.aspect);24console.log(pose.projectionMatrix);25console.log(pose.viewMatrix);26console.log(pose.viewProjectionMatrix);27console.log(pose.worldMatrix);28console.log(pose.worldViewMatrix);

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