Skip to content

Commit 764855a

Browse files
authored
Merge pull request #118 from HippoAR/opacity-transparency
add opacity and transparency
2 parents a7f4cb8 + 53bc05d commit 764855a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

components/lib/createArComponent.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
castsShadow,
1313
categoryBitMask,
1414
eulerAngles,
15+
opacity,
1516
orientation,
1617
position,
1718
renderingOrder,
@@ -42,6 +43,7 @@ const PROP_TYPES_NODE = {
4243
categoryBitMask,
4344
castsShadow,
4445
renderingOrder,
46+
opacity,
4547
};
4648

4749
const NODE_PROPS = keys(PROP_TYPES_NODE);

components/lib/propTypes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export const shadowMode = PropTypes.oneOf(values(ARKitManager.ShadowMode));
5858
export const colorBufferWriteMask = PropTypes.oneOf(
5959
values(ARKitManager.ColorMask),
6060
);
61+
62+
export const opacity = PropTypes.number;
63+
6164
export const material = PropTypes.shape({
6265
color,
6366
metalness: PropTypes.number,
@@ -69,5 +72,6 @@ export const material = PropTypes.shape({
6972
colorBufferWriteMask,
7073
doubleSided: PropTypes.bool,
7174
litPerPixel: PropTypes.bool,
75+
transparency: PropTypes.number,
7276
fillMode,
7377
});

ios/RCTConvert+ARKit.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ + (void)setMaterialProperties:(SCNMaterial *)material properties:(id)json {
323323
if (json[@"diffuse"]) {
324324
material.diffuse.contents = [self UIColor:json[@"diffuse"]];
325325
}
326+
if (json[@"transparency"]) {
327+
material.transparency = [json[@"transparency"] floatValue];
328+
}
326329

327330
if (json[@"metalness"]) {
328331
material.lightingModelName = SCNLightingModelPhysicallyBased;
@@ -353,6 +356,7 @@ + (void)setMaterialProperties:(SCNMaterial *)material properties:(id)json {
353356
material.doubleSided = [json[@"doubleSided"] boolValue];
354357
}
355358

359+
356360
if(json[@"litPerPixel"]) {
357361
material.litPerPixel = [json[@"litPerPixel"] boolValue];
358362
}
@@ -401,6 +405,10 @@ + (void)setNodeProperties:(SCNNode *)node properties:(id)json {
401405
if (json[@"rotation"]) {
402406
node.rotation = [self SCNVector4:json[@"rotation"]];
403407
}
408+
409+
if (json[@"opacity"]) {
410+
node.opacity = [json[@"opacity"] floatValue];
411+
}
404412
}
405413

406414

0 commit comments

Comments
 (0)