Skip to content

Commit

Permalink
Merge pull request facebookarchive#180 from b3ll/scenekit_pls
Browse files Browse the repository at this point in the history
SceneKit Support
  • Loading branch information
Kimon Tsinteris committed Oct 28, 2014
2 parents 203464a + d5b7d89 commit a8aec4f
Show file tree
Hide file tree
Showing 10 changed files with 508 additions and 10 deletions.
11 changes: 7 additions & 4 deletions Configuration/Platform/Compiler.xcconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
//
// Copyright (c) 2014-present, Facebook, Inc.
// All rights reserved.
//
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.
//
//

// Don't warn on implicit property synthesis
CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
Expand Down Expand Up @@ -33,4 +33,7 @@ CLANG_CXX_LIBRARY = libc++
CLANG_ENABLE_OBJC_ARC = YES

// Allow #import'ing code generated headers from DERIVED_FILE_DIR.
HEADER_SEARCH_PATHS = $(inherited) $(DERIVED_FILE_DIR)
HEADER_SEARCH_PATHS = $(inherited) $(DERIVED_FILE_DIR)

// Weakly Link SceneKit
OTHER_LDFLAGS = $(inherited) -weak_framework SceneKit
31 changes: 31 additions & 0 deletions pop/POPAnimatableProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,35 @@ extern NSString * const kPOPTabBarBarTintColor;
*/
extern NSString * const kPOPLabelTextColor;

/**
Common SceneKit property names.
*/
extern NSString * const kPOPSCNNodePosition;
extern NSString * const kPOPSCNNodePositionX;
extern NSString * const kPOPSCNNodePositionY;
extern NSString * const kPOPSCNNodePositionZ;
extern NSString * const kPOPSCNNodeTranslation;
extern NSString * const kPOPSCNNodeTranslationX;
extern NSString * const kPOPSCNNodeTranslationY;
extern NSString * const kPOPSCNNodeTranslationZ;
extern NSString * const kPOPSCNNodeRotation;
extern NSString * const kPOPSCNNodeRotationX;
extern NSString * const kPOPSCNNodeRotationY;
extern NSString * const kPOPSCNNodeRotationZ;
extern NSString * const kPOPSCNNodeRotationW;
extern NSString * const kPOPSCNNodeEulerAngles;
extern NSString * const kPOPSCNNodeEulerAnglesX;
extern NSString * const kPOPSCNNodeEulerAnglesY;
extern NSString * const kPOPSCNNodeEulerAnglesZ;
extern NSString * const kPOPSCNNodeOrientation;
extern NSString * const kPOPSCNNodeOrientationX;
extern NSString * const kPOPSCNNodeOrientationY;
extern NSString * const kPOPSCNNodeOrientationZ;
extern NSString * const kPOPSCNNodeOrientationW;
extern NSString * const kPOPSCNNodeScale;
extern NSString * const kPOPSCNNodeScaleX;
extern NSString * const kPOPSCNNodeScaleY;
extern NSString * const kPOPSCNNodeScaleZ;
extern NSString * const kPOPSCNNodeScaleXY;

#endif
312 changes: 312 additions & 0 deletions pop/POPAnimatableProperty.mm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

#import <QuartzCore/QuartzCore.h>

#if SCENEKIT_SDK_AVAILABLE
#import <SceneKit/SceneKit.h>
#endif

#import <pop/POPLayerExtras.h>

#if TARGET_OS_IPHONE
Expand Down Expand Up @@ -110,6 +114,35 @@
//UILabel
NSString * const kPOPLabelTextColor = @"label.textColor";

//SceneKit
NSString * const kPOPSCNNodePosition = @"scnode.position";
NSString * const kPOPSCNNodePositionX = @"scnnode.position.x";
NSString * const kPOPSCNNodePositionY = @"scnnode.position.y";
NSString * const kPOPSCNNodePositionZ = @"scnnode.position.z";
NSString * const kPOPSCNNodeTranslation = @"scnnode.translation";
NSString * const kPOPSCNNodeTranslationX = @"scnnode.translation.x";
NSString * const kPOPSCNNodeTranslationY = @"scnnode.translation.y";
NSString * const kPOPSCNNodeTranslationZ = @"scnnode.translation.z";
NSString * const kPOPSCNNodeRotation = @"scnnode.rotation";
NSString * const kPOPSCNNodeRotationX = @"scnnode.rotation.x";
NSString * const kPOPSCNNodeRotationY = @"scnnode.rotation.y";
NSString * const kPOPSCNNodeRotationZ = @"scnnode.rotation.z";
NSString * const kPOPSCNNodeRotationW = @"scnnode.rotation.w";
NSString * const kPOPSCNNodeEulerAngles = @"scnnode.eulerAngles";
NSString * const kPOPSCNNodeEulerAnglesX = @"scnnode.eulerAngles.x";
NSString * const kPOPSCNNodeEulerAnglesY = @"scnnode.eulerAngles.y";
NSString * const kPOPSCNNodeEulerAnglesZ = @"scnnode.eulerAngles.z";
NSString * const kPOPSCNNodeOrientation = @"scnnode.orientation";
NSString * const kPOPSCNNodeOrientationX = @"scnnode.orientation.x";
NSString * const kPOPSCNNodeOrientationY = @"scnnode.orientation.y";
NSString * const kPOPSCNNodeOrientationZ = @"scnnode.orientation.z";
NSString * const kPOPSCNNodeOrientationW = @"scnnode.orientation.w";
NSString * const kPOPSCNNodeScale = @"scnnode.scale";
NSString * const kPOPSCNNodeScaleX = @"scnnode.scale.x";
NSString * const kPOPSCNNodeScaleY = @"scnnode.scale.y";
NSString * const kPOPSCNNodeScaleZ = @"scnnode.scale.z";
NSString * const kPOPSCNNodeScaleXY = @"scnnode.scale.xy";

/**
State structure internal to static animatable property.
*/
Expand Down Expand Up @@ -498,7 +531,286 @@
},
0.01
},

#if SCENEKIT_SDK_AVAILABLE

/* SceneKit */

{kPOPSCNNodePosition,
^(SCNNode *obj, CGFloat values[]) {
values_from_vec3(values, obj.position);
},
^(SCNNode *obj, const CGFloat values[]) {
obj.position = values_to_vec3(values);
},
kPOPThresholdScale
},

{kPOPSCNNodePositionX,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.position.x;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.position = SCNVector3Make(values[0], obj.position.y, obj.position.z);
},
kPOPThresholdScale
},

{kPOPSCNNodePositionY,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.position.y;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.position = SCNVector3Make(obj.position.x, values[0], obj.position.z);
},
kPOPThresholdScale
},

{kPOPSCNNodePositionZ,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.position.z;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.position = SCNVector3Make(obj.position.x, obj.position.y, values[0]);
},
kPOPThresholdScale
},

{kPOPSCNNodeTranslation,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.transform.m41;
values[1] = obj.transform.m42;
values[2] = obj.transform.m43;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.transform = SCNMatrix4MakeTranslation(values[0], values[1], values[2]);
},
kPOPThresholdScale
},

{kPOPSCNNodeTranslationX,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.transform.m41;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.transform = SCNMatrix4MakeTranslation(values[0], obj.transform.m42, obj.transform.m43);
},
kPOPThresholdScale
},

{kPOPSCNNodeTranslationY,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.transform.m42;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.transform = SCNMatrix4MakeTranslation(obj.transform.m41, values[0], obj.transform.m43);
},
kPOPThresholdScale
},

{kPOPSCNNodeTranslationY,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.transform.m43;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.transform = SCNMatrix4MakeTranslation(obj.transform.m41, obj.transform.m42, values[0]);
},
kPOPThresholdScale
},

{kPOPSCNNodeRotation,
^(SCNNode *obj, CGFloat values[]) {
values_from_vec4(values, obj.rotation);
},
^(SCNNode *obj, const CGFloat values[]) {
obj.rotation = values_to_vec4(values);
},
kPOPThresholdScale
},

{kPOPSCNNodeRotationX,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.rotation.x;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.rotation = SCNVector4Make(1.0, obj.rotation.y, obj.rotation.z, values[0]);
},
kPOPThresholdScale
},

{kPOPSCNNodeRotationY,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.rotation.y;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.rotation = SCNVector4Make(obj.rotation.x, 1.0, obj.rotation.z, values[0]);
},
kPOPThresholdScale
},

{kPOPSCNNodeRotationZ,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.rotation.z;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.rotation = SCNVector4Make(obj.rotation.x, obj.rotation.y, 1.0, values[0]);
},
kPOPThresholdScale
},

{kPOPSCNNodeRotationW,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.rotation.w;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.rotation = SCNVector4Make(obj.rotation.x, obj.rotation.y, obj.rotation.z, values[0]);
},
kPOPThresholdScale
},

{kPOPSCNNodeEulerAngles,
^(SCNNode *obj, CGFloat values[]) {
values_from_vec3(values, obj.eulerAngles);
},
^(SCNNode *obj, const CGFloat values[]) {
obj.eulerAngles = values_to_vec3(values);
},
kPOPThresholdScale
},

{kPOPSCNNodeEulerAnglesX,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.eulerAngles.x;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.eulerAngles = SCNVector3Make(values[0], obj.eulerAngles.y, obj.eulerAngles.z);
},
kPOPThresholdScale
},

{kPOPSCNNodeEulerAnglesY,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.eulerAngles.y;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.eulerAngles = SCNVector3Make(obj.eulerAngles.x, values[0], obj.eulerAngles.z);
},
kPOPThresholdScale
},

{kPOPSCNNodeEulerAnglesZ,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.eulerAngles.z;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.eulerAngles = SCNVector3Make(obj.eulerAngles.x, obj.eulerAngles.y, values[0]);
},
kPOPThresholdScale
},

{kPOPSCNNodeOrientation,
^(SCNNode *obj, CGFloat values[]) {
values_from_vec4(values, obj.orientation);
},
^(SCNNode *obj, const CGFloat values[]) {
obj.orientation = values_to_vec4(values);
},
kPOPThresholdScale
},

{kPOPSCNNodeOrientationX,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.orientation.x;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.orientation = SCNVector4Make(values[0], obj.orientation.y, obj.orientation.z, obj.orientation.w);
},
kPOPThresholdScale
},

{kPOPSCNNodeOrientationY,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.orientation.y;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.orientation = SCNVector4Make(obj.orientation.x, values[0], obj.orientation.z, obj.orientation.w);
},
kPOPThresholdScale
},

{kPOPSCNNodeOrientationZ,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.orientation.z;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.orientation = SCNVector4Make(obj.orientation.x, obj.orientation.y, values[0], obj.orientation.w);
},
kPOPThresholdScale
},

{kPOPSCNNodeOrientationW,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.orientation.w;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.orientation = SCNVector4Make(obj.orientation.x, obj.orientation.y, obj.orientation.z, values[0]);
},
kPOPThresholdScale
},

{kPOPSCNNodeScale,
^(SCNNode *obj, CGFloat values[]) {
values_from_vec3(values, obj.scale);
},
^(SCNNode *obj, const CGFloat values[]) {
obj.scale = values_to_vec3(values);
},
kPOPThresholdScale
},

{kPOPSCNNodeScaleX,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.scale.x;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.scale = SCNVector3Make(values[0], obj.scale.y, obj.scale.z);
},
kPOPThresholdScale
},

{kPOPSCNNodeScaleY,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.scale.y;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.position = SCNVector3Make(obj.scale.x, values[0], obj.scale.z);
},
kPOPThresholdScale
},

{kPOPSCNNodeScaleZ,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.scale.z;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.scale = SCNVector3Make(obj.scale.x, obj.scale.y, values[0]);
},
kPOPThresholdScale
},

{kPOPSCNNodeScaleXY,
^(SCNNode *obj, CGFloat values[]) {
values[0] = obj.scale.x;
values[1] = obj.scale.y;
},
^(SCNNode *obj, const CGFloat values[]) {
obj.scale = SCNVector3Make(values[0], values[1], obj.scale.z);
},
kPOPThresholdScale
},

#endif

#if TARGET_OS_IPHONE

/* UIView */
Expand Down
Loading

0 comments on commit a8aec4f

Please sign in to comment.