Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions ios/RCTConvert+ARKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,8 @@ + (void)setMaterialPropertyContents:(id)property material:(SCNMaterialProperty *
if (property[@"path"]) {
SCNMatrix4 m = SCNMatrix4Identity;

// scenekit has an issue with indexed-colour png's on some devices, so we redraw the image. See for more details: https://stackoverflow.com/questions/40058359/scenekit-some-textures-have-a-red-hue/45824190#45824190

UIImage *correctedImage;
UIImage *inputImage = [UIImage imageNamed:property[@"path"]];
CGFloat width = inputImage.size.width;
CGFloat height = inputImage.size.height;

UIGraphicsBeginImageContext(inputImage.size);
[inputImage drawInRect:(CGRectMake(0, 0, width, height))];
correctedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

material.contents = correctedImage;
// scenekit has an issue with indexed-colour png's on some devices, See for more details: https://stackoverflow.com/questions/40058359/scenekit-some-textures-have-a-red-hue/45824190#45824190 to fix this we could re-implement https://github.com/react-native-ar/react-native-arkit/pull/171 in a more performant way
material.contents = property[@"path"];


if (property[@"wrapS"]) {
Expand Down
7 changes: 5 additions & 2 deletions ios/components/RCTARKitSpriteView.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ @implementation RCTARKitSpriteView {

- (CGAffineTransform)getTransform {
SCNVector3 point = [[ARKit sharedInstance] projectPoint:self.position3D];
CGAffineTransform t = CGAffineTransformMakeTranslation(point.x, point.y);

// the sprite is behind the camera so push it off screen
float yTransform = point.z < 1 ? point.y : 10000;

CGAffineTransform t = CGAffineTransformMakeTranslation(point.x, yTransform);
return t;
}

Expand All @@ -40,7 +44,6 @@ - (void)renderer:(id<SCNSceneRenderer>)renderer updateAtTime:(NSTimeInterval)tim
- (void)setTransformByProject {
CGAffineTransform t = [self getTransform];
[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:self.transitionDuration];
[self setTransform:t];
[UIView commitAnimations];
Expand Down