Skip to content

Commit

Permalink
Merge pull request #158 from archilogic-com/billboard-sprites
Browse files Browse the repository at this point in the history
Camera facing constraints
  • Loading branch information
macrozone authored Feb 27, 2018
2 parents db686e2 + 9622978 commit 2b039a0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ Most 3d object have these common properties
| `transition` | `{duration: 1}` | Some property changes can be animated like in css transitions. Currently you can specify the duration (in seconds). |
| `renderingOrder` | Number | Order in which object is rendered. Usefull to place elements "behind" others, although they are nearer. |
| `categoryBitMask` | Number / bitmask | control which lights affect this object |
| `castsShadow` | `boolean` | whether this object casts hadows |
| `castsShadow` | `boolean` | whether this object casts shadows |
| `constraint` | `ARKit.Constraint.{ BillboardAxisAll \| BillboardAxisX \| BillboardAxisY \| BillboardAxisZ \| None }` | Constrains the node to always point to the camera |

*New experimental feature:*

Expand Down
2 changes: 2 additions & 0 deletions components/lib/createArComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
renderingOrder,
rotation,
scale,
constraint,
transition,
} from './propTypes';
import addAnimatedSupport from './addAnimatedSupport';
Expand Down Expand Up @@ -45,6 +46,7 @@ const PROP_TYPES_NODE = {
castsShadow,
renderingOrder,
opacity,
constraint,
};

const NODE_PROPS = keys(PROP_TYPES_NODE);
Expand Down
2 changes: 2 additions & 0 deletions components/lib/propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export const colorBufferWriteMask = PropTypes.oneOf(

export const opacity = animatableNumber;

export const constraint = PropTypes.oneOf(values(ARKitManager.Constraint));

export const wrapMode = PropTypes.oneOf(values(ARKitManager.WrapMode));

export const materialProperty = PropTypes.shape({
Expand Down
7 changes: 7 additions & 0 deletions ios/RCTARKitManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ - (NSDictionary *)constantsToExport
@"Clamp": [@(SCNWrapModeClamp) stringValue],
@"Repeat": [@(SCNWrapModeRepeat) stringValue],
@"Mirror": [@(SCNWrapModeMirror) stringValue],
},
@"Constraint": @{
@"None": @"0",
@"BillboardAxisAll": [@(SCNBillboardAxisAll) stringValue],
@"BillboardAxisX": [@(SCNBillboardAxisX) stringValue],
@"BillboardAxisY": [@(SCNBillboardAxisY) stringValue],
@"BillboardAxisZ": [@(SCNBillboardAxisZ) stringValue],
}
};
}
Expand Down
5 changes: 5 additions & 0 deletions ios/RCTConvert+ARKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,11 @@ + (void)setNodeProperties:(SCNNode *)node properties:(id)json {
if (json[@"castsShadow"]) {
node.castsShadow = [json[@"castsShadow"] boolValue];
}
if (json[@"constraint"]) {
SCNBillboardConstraint *constraint = [SCNBillboardConstraint billboardConstraint];
constraint.freeAxes = [json[@"constraint"] integerValue];
node.constraints = @[constraint];
}
if(json[@"transition"]) {
NSDictionary * transition =json[@"transition"];
if(transition[@"duration"]) {
Expand Down

0 comments on commit 2b039a0

Please sign in to comment.