Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I just got rid of projection matrix and it is the best variant I've got:</p> <pre><code>- (void)adjustTransformationOfLayerWithMarkerId:(NSNumber *)markerId forModelViewMatrix:(NSArray *)modelViewMatrix { CALayer *layer = [self.imageLayers objectForKey:markerId]; ... CATransform3D transform = CATransform3DIdentity; CGFloat *p = (CGFloat *)&amp;transform; for (int i = 0; i &lt; 16; ++i) { *p = [[modelViewMatrix objectAtIndex:i] floatValue]; ++p; } transform.m44 = (transform.m43 &gt; 0) ? transform.m43/kZDistanceWithoutDistortion : 1; CGFloat angle = -M_PI_2; if (self.delegate.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) { angle = M_PI; } if (self.delegate.interfaceOrientation == UIInterfaceOrientationLandscapeRight) { angle = 0; } if (self.delegate.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { angle = M_PI_2; } transform = CATransform3DConcat(transform, CATransform3DMakeRotation(angle, 0, 0, -1)); transform = CATransform3DConcat(CATransform3DMakeScale(-1, 1, 1), transform); // Normalize transformation CGFloat scaleFactor = 1.0f / transform.m44; transform.m41 = transform.m41 * scaleFactor; transform.m42 = transform.m42 * scaleFactor; transform.m43 = transform.m43 * scaleFactor; transform = CATransform3DScale(transform, scaleFactor, scaleFactor, scaleFactor); transform.m44 = 1; BOOL disableAction = YES; ... [CATransaction begin]; [CATransaction setDisableActions:disableAction]; // Disable animation for layer to move faster layer.transform = transform; [CATransaction commit]; } </code></pre> <p>It wasn't absolutely precise, but it was accurate enough for my purposes. Deflection becomes noticeable when x or y displacement were about screen size.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload