Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Implement support for texture properties
  • Loading branch information
bnjm committed Feb 20, 2018
commit 88c2b8d8bf0ddc4fff5503b99ca858a882c89bd7
47 changes: 47 additions & 0 deletions ios/RCTConvert+ARKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"]];
}
Expand Down