@@ -187,24 +187,24 @@ + (SVGBezierPath *)svgStringToBezier:(NSString *)pathString {
187187
188188+ (void )setChamferProfilePathSvg : (SCNShape *)geometry properties : (NSDictionary *)shape {
189189 if (shape[@" chamferProfilePathSvg" ]) {
190-
191-
192- SVGBezierPath * path = [self svgStringToBezier: shape[@" chamferProfilePathSvg" ]];
193- if (shape[@" chamferProfilePathFlatness" ]) {
194- path.flatness = [shape[@" chamferProfilePathFlatness" ] floatValue ];
195- }
196- // normalize path
197- CGRect boundingBox = path.bounds ;
198- if (path.bounds .size .width !=0 && path.bounds .size .height != 0 ) {
199- CGFloat scaleX = 1 /boundingBox.size .width ;
200- CGFloat scaleY = scaleY = 1 /boundingBox.size .height ;
201190
202- CGAffineTransform transform = CGAffineTransformMakeScale (scaleX, scaleY);
203- [path applyTransform: transform];
204- geometry.chamferProfile = path;
205- } else {
206- NSLog (@" Invalid chamferProfilePathFlatness" );
207- }
191+
192+ SVGBezierPath * path = [self svgStringToBezier: shape[@" chamferProfilePathSvg" ]];
193+ if (shape[@" chamferProfilePathFlatness" ]) {
194+ path.flatness = [shape[@" chamferProfilePathFlatness" ] floatValue ];
195+ }
196+ // normalize path
197+ CGRect boundingBox = path.bounds ;
198+ if (path.bounds .size .width !=0 && path.bounds .size .height != 0 ) {
199+ CGFloat scaleX = 1 /boundingBox.size .width ;
200+ CGFloat scaleY = scaleY = 1 /boundingBox.size .height ;
201+
202+ CGAffineTransform transform = CGAffineTransformMakeScale (scaleX, scaleY);
203+ [path applyTransform: transform];
204+ geometry.chamferProfile = path;
205+ } else {
206+ NSLog (@" Invalid chamferProfilePathFlatness" );
207+ }
208208 }
209209
210210}
@@ -305,6 +305,17 @@ + (SCNLight *)SCNLight:(id)json {
305305}
306306
307307
308+ + (void )setMaterialPropertyContents : (id )property material : (SCNMaterialProperty *)material {
309+ if (property[@" path" ]) {
310+ material.contents = property[@" path" ];
311+ } else if (property[@" color" ]) {
312+ material.contents = [self UIColor: property[@" color" ]];
313+ }
314+ if (property[@" intensity" ]) {
315+ material.intensity = [property[@" intensity" ] floatValue ];
316+ }
317+ }
318+
308319+ (void )setMaterialProperties : (SCNMaterial *)material properties : (id )json {
309320 if (json[@" doubleSided" ]) {
310321 material.doubleSided = [json[@" doubleSided" ] boolValue ];
@@ -321,8 +332,21 @@ + (void)setMaterialProperties:(SCNMaterial *)material properties:(id)json {
321332 }
322333
323334 if (json[@" diffuse" ]) {
324- material.diffuse .contents = [self UIColor: json[@" diffuse" ]];
335+ [self setMaterialPropertyContents: json[@" diffuse" ] material: material.diffuse];
336+ }
337+
338+ if (json[@" normal" ]) {
339+ [self setMaterialPropertyContents: json[@" normal" ] material: material.normal];
340+ }
341+
342+ if (json[@" displacement" ]) {
343+ [self setMaterialPropertyContents: json[@" displacement" ] material: material.displacement];
344+ }
345+
346+ if (json[@" specular" ]) {
347+ [self setMaterialPropertyContents: json[@" specular" ] material: material.specular];
325348 }
349+
326350 if (json[@" transparency" ]) {
327351 material.transparency = [json[@" transparency" ] floatValue ];
328352 }
@@ -357,7 +381,6 @@ + (void)setMaterialProperties:(SCNMaterial *)material properties:(id)json {
357381 material.doubleSided = [json[@" doubleSided" ] boolValue ];
358382 }
359383
360-
361384 if (json[@" litPerPixel" ]) {
362385 material.litPerPixel = [json[@" litPerPixel" ] boolValue ];
363386 }
0 commit comments