Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera facing constraints #158

Merged
merged 4 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
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