-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.coffee
85 lines (78 loc) · 2.21 KB
/
app.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Project Info
## Orientation
Framer.Info =
# title: "Module for sensor"
author: "Jungho Song"
twitter: "@threeword"
description: "
Use the Orientation sensor\n
\n
Github : https://github.com/framer-modules/sensor.framer
"
date: "2016-10-04"
# Project Info
## Motion
# Framer.Info =
# title: "Module for sensor"
# author: "Jungho Song"
# twitter: "@threeword"
# description: "
# Use the Motion sensor\n
# \n
# Github : https://github.com/framer-modules/sensor.framer
# "
# date: "2016-10-04"
# Background
Screen.backgroundColor = "gray"
# Create Cube
#
SIZE = 200
# Cube
cube = new Layer
point: Align.center
size: SIZE
rotationY: 0, rotationX: -30
style:
transformStyle: "preserve-3d"
"-webkit-transform-style": "preserve-3d"
backgroundColor: ""
# Face properties
properties =
size: SIZE
style:
fontSize: "20px", fontWeight: "500", lineHeight: "#{SIZE}px"
textAlign: "center", textTransform: "uppercase"
boxShadow: "inset 0 0 30px rgba(0,0,0,0.2)"
color: "rgba(0,0,0,.5)"
backgroundColor: "rgba(255,255,255,1.1)"
parent: cube
# Front
front = new Layer _.extend _.clone(properties), html: "front", z: 100
# Back
back = new Layer _.extend _.clone(properties), html: "back", z: -100, rotationY: 180
# Top
top = new Layer _.extend _.clone(properties), html: "top", rotationX: 90, y: -100
# Bottom
bottom = new Layer _.extend _.clone(properties), html: "bottom", rotationX: -90, y: 100
# Left
left = new Layer _.extend _.clone(properties), html: "left", rotationY: -90, x: -100
# RightSe
right = new Layer _.extend _.clone(properties), html: "right", rotationY: 90, x: 100
# Module
require 'System'
# Sensor manager
sensorManager = getSystemService(Context.SENSOR_SERVICE)
# Sensor : Orientation
sensorOrientation = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION)
if sensorOrientation
sensorOrientation.smooth = 0.1
sensorOrientation.onChange (event) ->
cube.rotationX = -(event.beta) * 2 + 60
cube.rotationY = (event.gamma) * 2
# Sensor : Motion
# sensorMotion = sensorManager.getDefaultSensor(Sensor.TYPE_MOTION)
# if sensorMotion
# sensorMotion.smooth = 0.005
# sensorMotion.onChange (event) ->
# cube.rotationX -= event.rotationRate.alpha
# cube.rotationY += event.rotationRate.beta