Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Commit

Permalink
Implement support for texture properties
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjm committed Feb 21, 2018
1 parent 842407a commit 0d23357
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions ios/RCTConvert+ARKit.m
Original file line number Diff line number Diff line change
@@ -306,8 +306,55 @@ + (SCNLight *)SCNLight:(id)json {


+ (void)setMaterialPropertyContents:(id)property material:(SCNMaterialProperty *)material {

if (property[@"path"]) {
SCNMatrix4 m = SCNMatrix4Identity;
material.contents = property[@"path"];

if (property[@"wrapS"]) {
material.wrapS = (SCNWrapMode) [property[@"wrapS"] integerValue];
}

if (property[@"wrapT"]) {
material.wrapT = (SCNWrapMode) [property[@"wrapT"] integerValue];
}

if (property[@"wrap"]) {
material.wrapT = (SCNWrapMode) [property[@"wrapT"] integerValue];
material.wrapS = (SCNWrapMode) [property[@"wrapS"] integerValue];
}

if (property[@"translation"]) {
float x = [property[@"translation"][@"x"] floatValue];
float y = [property[@"translation"][@"y"] floatValue];
float z = [property[@"translation"][@"z"] floatValue];

m = SCNMatrix4Mult(m, SCNMatrix4MakeTranslation(x, y, z));
}

if (property[@"rotation"]) {
float angle = [property[@"rotation"][@"angle"] floatValue];
float x = [property[@"rotation"][@"x"] floatValue];
float y = [property[@"rotation"][@"y"] floatValue];
float z = [property[@"rotation"][@"z"] floatValue];

m = SCNMatrix4Mult(m, SCNMatrix4MakeRotation(angle, x, y, z));
}

if (property[@"scale"]) {

NSLog(@"%@", property[@"scale"]);

float x = [property[@"scale"][@"x"] floatValue];
float y = [property[@"scale"][@"y"] floatValue];
float z = [property[@"scale"][@"z"] floatValue];

m = SCNMatrix4Mult(m, SCNMatrix4MakeScale(x, y, z));
}

material.contentsTransform = m;


} else if (property[@"color"]) {
material.contents = [self UIColor:property[@"color"]];
}

0 comments on commit 0d23357

Please sign in to comment.