Skip to content

Commit 9b484fd

Browse files
authored
Merge pull request #48 from HippoAR/rename-shader-to-material
Rename shader to material
2 parents 1483724 + e6c1a46 commit 9b484fd

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
151151
|---|---|
152152
| `pos` | `{ x, y, z }` |
153153
| `shape` | `{ width, height, length, chamfer }` |
154-
| `shader` | `{ color, metalness, roughness }` |
154+
| `material` | `{ color, metalness, roughness }` |
155155

156156
#### [`<ARKit.Sphere />`](https://developer.apple.com/documentation/scenekit/scnsphere)
157157

@@ -161,7 +161,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
161161
|---|---|
162162
| `pos` | `{ x, y, z }` |
163163
| `shape` | `{ radius }` |
164-
| `shader` | `{ color, metalness, roughness }` |
164+
| `material` | `{ color, metalness, roughness }` |
165165

166166
#### [`<ARKit.Cylinder />`](https://developer.apple.com/documentation/scenekit/scncylinder)
167167

@@ -171,7 +171,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
171171
|---|---|
172172
| `pos` | `{ x, y, z }` |
173173
| `shape` | `{ radius, height }` |
174-
| `shader` | `{ color, metalness, roughness }` |
174+
| `material` | `{ color, metalness, roughness }` |
175175

176176
#### [`<ARKit.Cone />`](https://developer.apple.com/documentation/scenekit/scncone)
177177

@@ -181,7 +181,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
181181
|---|---|
182182
| `pos` | `{ x, y, z }` |
183183
| `shape` | `{ topR, bottomR, height }` |
184-
| `shader` | `{ color, metalness, roughness }` |
184+
| `material` | `{ color, metalness, roughness }` |
185185

186186
#### [`<ARKit.Pyramid />`](https://developer.apple.com/documentation/scenekit/scnpyramid)
187187

@@ -191,7 +191,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
191191
|---|---|
192192
| `pos` | `{ x, y, z }` |
193193
| `shape` | `{ width, height, length }` |
194-
| `shader` | `{ color, metalness, roughness }` |
194+
| `material` | `{ color, metalness, roughness }` |
195195

196196
#### [`<ARKit.Tube />`](https://developer.apple.com/documentation/scenekit/scntube)
197197

@@ -201,7 +201,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
201201
|---|---|
202202
| `pos` | `{ x, y, z }` |
203203
| `shape` | `{ innerR, outerR, height }` |
204-
| `shader` | `{ color, metalness, roughness }` |
204+
| `material` | `{ color, metalness, roughness }` |
205205

206206
#### [`<ARKit.Torus />`](https://developer.apple.com/documentation/scenekit/scntorus)
207207

@@ -211,7 +211,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
211211
|---|---|
212212
| `pos` | `{ x, y, z }` |
213213
| `shape` | `{ ringR, pipeR }` |
214-
| `shader` | `{ color, metalness, roughness }` |
214+
| `material` | `{ color, metalness, roughness }` |
215215

216216
#### [`<ARKit.Capsule />`](https://developer.apple.com/documentation/scenekit/scncapsule)
217217

@@ -221,7 +221,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
221221
|---|---|
222222
| `pos` | `{ x, y, z }` |
223223
| `shape` | `{ capR, height }` |
224-
| `shader` | `{ color, metalness, roughness }` |
224+
| `material` | `{ color, metalness, roughness }` |
225225

226226
#### [`<ARKit.Plane />`](https://developer.apple.com/documentation/scenekit/scnplane)
227227

@@ -231,7 +231,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
231231
|---|---|
232232
| `pos` | `{ x, y, z }` |
233233
| `shape` | `{ width, length }` |
234-
| `shader` | `{ color, metalness, roughness }` |
234+
| `material` | `{ color, metalness, roughness }` |
235235

236236
#### [`<ARKit.Text />`](https://developer.apple.com/documentation/scenekit/scntext)
237237

@@ -242,7 +242,7 @@ AppRegistry.registerComponent('ReactNativeARKit', () => ReactNativeARKit);
242242
| `text` | `String` |
243243
| `pos` | `{ x, y, z, angle }` |
244244
| `font` | `{ name, size, depth, chamfer }` |
245-
| `shader` | `{ color, metalness, roughness }` |
245+
| `material` | `{ color, metalness, roughness }` |
246246

247247

248248
#### `<ARKit.Model />`

components/lib/createArComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default (Manager, propTypes = {}) => {
5757
w: PropTypes.number,
5858
}),
5959

60-
shader: PropTypes.shape({
60+
material: PropTypes.shape({
6161
color: PropTypes.string,
6262
metalness: PropTypes.number,
6363
roughness: PropTypes.number,

components/lib/parseColor.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export const normalizeColor = colorRaw => {
99
};
1010

1111
export function parseColorInProps(props) {
12-
if (props && props.shader && props.shader.color) {
12+
if (props && props.material && props.material.color) {
1313
return {
1414
...props,
15-
shader: {
16-
...props.shader,
17-
color: normalizeColor(props.shader.color),
15+
material: {
16+
...props.material,
17+
color: normalizeColor(props.material.color),
1818
},
1919
};
2020
}

ios/RCTARKitGeos.m

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,26 +224,26 @@ - (void)addImage:(NSDictionary *)property {}
224224

225225
- (SCNMaterial *)materialFromProperty:(NSDictionary *)property {
226226
SCNMaterial *material = [SCNMaterial new];
227-
NSDictionary* shader = property[@"shader"];
227+
NSDictionary* material = property[@"material"];
228228

229-
if (shader[@"color"]) {
230-
CGFloat r = [shader[@"color"][@"r"] floatValue];
231-
CGFloat g = [shader[@"color"][@"g"] floatValue];
232-
CGFloat b = [shader[@"color"][@"b"] floatValue];
233-
CGFloat alpha = [shader[@"color"][@"alpha"] floatValue];
229+
if (material[@"color"]) {
230+
CGFloat r = [material[@"color"][@"r"] floatValue];
231+
CGFloat g = [material[@"color"][@"g"] floatValue];
232+
CGFloat b = [material[@"color"][@"b"] floatValue];
233+
CGFloat alpha = [material[@"color"][@"alpha"] floatValue];
234234
UIColor *color = [[UIColor alloc] initWithRed:r green:g blue:b alpha:alpha];
235235
material.diffuse.contents = color;
236236
} else {
237237
material.diffuse.contents = [UIColor whiteColor];
238238
}
239239

240-
if (shader[@"metalness"]) {
240+
if (material[@"metalness"]) {
241241
material.lightingModelName = SCNLightingModelPhysicallyBased;
242-
material.metalness.contents = @([shader[@"metalness"] floatValue]);
242+
material.metalness.contents = @([material[@"metalness"] floatValue]);
243243
}
244-
if (shader[@"roughness"]) {
244+
if (material[@"roughness"]) {
245245
material.lightingModelName = SCNLightingModelPhysicallyBased;
246-
material.roughness.contents = @([shader[@"roughness"] floatValue]);
246+
material.roughness.contents = @([material[@"roughness"] floatValue]);
247247
}
248248

249249
return material;

0 commit comments

Comments
 (0)