anim-3d-obj 1.1.74 → 1.1.225
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -74
- package/ang1.png +0 -0
- package/babel.config.json +18 -0
- package/jestconfig.json +8 -0
- package/package.json +44 -36
- package/public/ang2.png +0 -0
- package/public/ang3.png +0 -0
- package/public/angl1.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/src/components/Face.tsx +95 -0
- package/src/components/Obj.tsx +53 -0
- package/src/components/index.ts +4 -0
- package/src/components/styles/Anim.d.ts +17 -0
- package/src/components/styles/AnimWrap.tsx +90 -0
- package/{dist/esm/components/styles/Anims.js → src/components/styles/Anims.ts} +82 -60
- package/src/components/styles/Global.tsx +28 -0
- package/src/components/styles/Scene.tsx +37 -0
- package/src/components/types.d.ts +42 -0
- package/tsconfig.json +20 -0
- package/dist/cjs/components/Face.d.ts +0 -11
- package/dist/cjs/components/Face.js +0 -106
- package/dist/cjs/components/Obj.d.ts +0 -2
- package/dist/cjs/components/Obj.js +0 -31
- package/dist/cjs/components/index.d.ts +0 -2
- package/dist/cjs/components/index.js +0 -18
- package/dist/cjs/components/styles/AnimWrap.d.ts +0 -2
- package/dist/cjs/components/styles/AnimWrap.js +0 -88
- package/dist/cjs/components/styles/Anims.d.ts +0 -32
- package/dist/cjs/components/styles/Anims.js +0 -329
- package/dist/cjs/components/styles/Global.d.ts +0 -6
- package/dist/cjs/components/styles/Global.js +0 -27
- package/dist/cjs/components/styles/Scene.d.ts +0 -10
- package/dist/cjs/components/styles/Scene.js +0 -22
- package/dist/cjs/index.js +0 -17
- package/dist/esm/components/Face.d.ts +0 -11
- package/dist/esm/components/Face.js +0 -100
- package/dist/esm/components/Obj.d.ts +0 -2
- package/dist/esm/components/Obj.js +0 -25
- package/dist/esm/components/index.d.ts +0 -2
- package/dist/esm/components/index.js +0 -2
- package/dist/esm/components/styles/AnimWrap.d.ts +0 -2
- package/dist/esm/components/styles/AnimWrap.js +0 -81
- package/dist/esm/components/styles/Anims.d.ts +0 -32
- package/dist/esm/components/styles/Global.d.ts +0 -6
- package/dist/esm/components/styles/Global.js +0 -20
- package/dist/esm/components/styles/Scene.d.ts +0 -10
- package/dist/esm/components/styles/Scene.js +0 -15
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -1
- /package/{dist/cjs/index.d.ts → src/index.ts} +0 -0
package/README.md
CHANGED
|
@@ -4,32 +4,13 @@ This project allows a user to create Cuboids of any size simply by entering a se
|
|
|
4
4
|
The program does the leg work with regard to calculating translationZ depth and config on the fly.
|
|
5
5
|
|
|
6
6
|
## Examples
|
|
7
|
-
|
|
7
|
+
- [Obj Skeleton](https://codesandbox.io/s/anim-3d-obj-skeleton-5dlk70)
|
|
8
8
|
- [6 sided Cuboid - animate X360 Y360](https://codesandbox.io/s/anim-3d-obj-all-sides-simple-bf67yg-tzr2v6)
|
|
9
9
|
- [3 sided Object - animate y-axis](https://codesandbox.io/s/anim-3d-obj-3-sides-wobble-y-axis-wglkms)
|
|
10
10
|
- [Double box spin](https://codesandbox.io/s/react-anim-3d-double-box-spin-vbdhg2)
|
|
11
11
|
- [Floating Ribbon](https://codesandbox.io/s/cocky-butterfly-ygwkps)
|
|
12
12
|
- [Parallel divs animated x and y axis in tandem](https://codesandbox.io/s/anim-3d-obj-2-sides-simple-4057y7)
|
|
13
|
-
- [Obj Skeleton](https://codesandbox.io/s/anim-3d-obj-skeleton-5dlk70)
|
|
14
13
|
|
|
15
|
-
## Config
|
|
16
|
-
|
|
17
|
-
Animations are optional. Either or both of `anim1` or `anim2` can be applied to the component.
|
|
18
|
-
|
|
19
|
-
```typescript
|
|
20
|
-
const anim1 = {
|
|
21
|
-
border: "", // while testing reveal the animation wrapper
|
|
22
|
-
degreesHi: -45, // degrees if spin
|
|
23
|
-
degreesLow: 45, // degrees if spin
|
|
24
|
-
delay: 0, // start delay in seconds
|
|
25
|
-
direction: "normal", //normal alternating reverse
|
|
26
|
-
duration: 8, // seconds
|
|
27
|
-
fillMode: "forwards", // none forwards backwards both
|
|
28
|
-
iterationCount: "infinite", // number or infinte
|
|
29
|
-
name: "Y360", // ** ANIMATIONS
|
|
30
|
-
timing: "ease-in-out", // linear ease ease-in-out
|
|
31
|
-
};
|
|
32
|
-
```
|
|
33
14
|
|
|
34
15
|
`** ANIMATIONS`
|
|
35
16
|
|
|
@@ -43,7 +24,6 @@ const anim1 = {
|
|
|
43
24
|
- `swingDecay`: Swing component with decay: [demo](https://codesandbox.io/s/anim-3d-obj-swingdecay-cku0e1)
|
|
44
25
|
- `noAnim`: no animation place holder
|
|
45
26
|
|
|
46
|
-
|
|
47
27
|
`X-AXIS Animations`
|
|
48
28
|
- `X360`: rotate 360 degrees on the x-axis: [demo](https://codesandbox.io/s/anim-3d-obj-x360-7kiuhw)
|
|
49
29
|
- `wobX`: wobble on x-axis (degreesHi <-> degreesLow): [demo](https://codesandbox.io/s/anim-3d-obj-wobx-ldwek7)
|
|
@@ -63,68 +43,65 @@ const anim1 = {
|
|
|
63
43
|
- `fwdy918`: spin object on y-axis from 90 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy918-gnym88)
|
|
64
44
|
- `fwdy1827`: spin object on y-axis from 180 degrees to 270 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy1827-osskgx)
|
|
65
45
|
- `fwdy2736`: spin object on y-axis from 270 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy2736-rnbs2q)
|
|
66
|
-
-
|
|
67
46
|
|
|
68
47
|
|
|
69
|
-
|
|
48
|
+
## Config
|
|
49
|
+
### Animations:
|
|
70
50
|
|
|
71
|
-
|
|
51
|
+
Animations are optional. Either or both of `anim1` or `anim2` can be applied to the component. Animations are applied to 2 wrapping divs respectively.
|
|
72
52
|
|
|
73
53
|
```typescript
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
backface-visibility: visible;
|
|
86
|
-
font-family: Arial, Helvetica, sans-serif;
|
|
87
|
-
border-radius:5px;
|
|
88
|
-
`,
|
|
89
|
-
body: " ",
|
|
54
|
+
const anim1 = {
|
|
55
|
+
border: "", // while testing reveal the animation wrapper
|
|
56
|
+
degreesHi: -45, // degrees if spin
|
|
57
|
+
degreesLow: 45, // degrees if spin
|
|
58
|
+
delay: 0, // start delay in seconds
|
|
59
|
+
direction: "normal", //normal alternating reverse
|
|
60
|
+
duration: 8, // seconds
|
|
61
|
+
fillMode: "forwards", // none forwards backwards both
|
|
62
|
+
iterationCount: "infinite", // number or infinte
|
|
63
|
+
name: "Y360", // ** ANIMATIONS (above)
|
|
64
|
+
timing: "ease-in-out", // linear ease ease-in-out
|
|
90
65
|
};
|
|
91
66
|
```
|
|
92
67
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
background: rgb(2,0,36);
|
|
108
|
-
color:white;
|
|
109
|
-
text-align: center;
|
|
110
|
-
line-height:8;`
|
|
111
|
-
body: " ",
|
|
112
|
-
},
|
|
113
|
-
right: {
|
|
114
|
-
css: ``,
|
|
115
|
-
body: " ",
|
|
68
|
+
### Faces:
|
|
69
|
+
This is an array of objects containing the face used for a given component
|
|
70
|
+
```javascript
|
|
71
|
+
export interface FaceType {
|
|
72
|
+
name?: string; // front,back,left,right,top,top_rear,top_front,bottom,bottom_rear,bottom_front
|
|
73
|
+
css?: string | undefined;
|
|
74
|
+
body?: any; // can be JSX Component | string | number
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const faces: FaceType[] = [
|
|
78
|
+
{
|
|
79
|
+
name: "back",
|
|
80
|
+
body: "BACK",
|
|
81
|
+
css: `background:rgba(22,22,22,.5)`,
|
|
116
82
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
body:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
css: `
|
|
123
|
-
background-color:rgba(141,191,249,1);
|
|
124
|
-
-webkit-box-shadow: 0px 0px 23px 18px #858585;
|
|
125
|
-
box-shadow: 0px 0px 23px 18px #858585;
|
|
126
|
-
`,
|
|
83
|
+
{
|
|
84
|
+
name: "right",
|
|
85
|
+
body: "RIGHT",
|
|
86
|
+
css: `background:rgba(220,220,220,.5);
|
|
87
|
+
border:1px solid #ddd`,
|
|
127
88
|
},
|
|
89
|
+
];
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Global (face):
|
|
93
|
+
If the name parameter in the faces array is indicated (ie: "front") but `css` and / or `body` are not. The `global default`(below) will satisfy those parameters.
|
|
94
|
+
```javascript
|
|
95
|
+
interface GlobalType {
|
|
96
|
+
css?: string;
|
|
97
|
+
body?: string;
|
|
98
|
+
}
|
|
99
|
+
const global: GlobalType = {
|
|
100
|
+
body: "BODY FOR FACE WHICH DOES NOT CONTAIN BODY",
|
|
101
|
+
css: 'color:red'
|
|
102
|
+
};
|
|
128
103
|
```
|
|
129
|
-
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
130
107
|
- https://www.npmjs.com/package/anim-3d-obj
|
package/ang1.png
ADDED
|
Binary file
|
package/jestconfig.json
ADDED
package/package.json
CHANGED
|
@@ -1,49 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
1
|
{
|
|
12
2
|
"name": "anim-3d-obj",
|
|
3
|
+
"version": "1.1.225",
|
|
4
|
+
"private": false,
|
|
13
5
|
"repository": {
|
|
14
6
|
"type": "git",
|
|
15
7
|
"url": "https://github.com/mdnelles/anim-3d-obj-npm-publisher.git"
|
|
16
8
|
},
|
|
17
|
-
"homepage": "https://github.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"main": "dist/cjs/index.js",
|
|
21
|
-
"module": "dist/esm/index.js",
|
|
22
|
-
"files": [
|
|
23
|
-
"dist"
|
|
24
|
-
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "rm -rf dist/ && prettier --write src/ && npm run build:esm && npm run build:cjs",
|
|
27
|
-
"build:esm": "tsc",
|
|
28
|
-
"build:cjs": "tsc --module CommonJS --outDir dist/cjs"
|
|
29
|
-
},
|
|
30
|
-
"author": "mdnelles",
|
|
31
|
-
"license": "MIT",
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@types/node": "^18.11.9",
|
|
34
|
-
"@types/react": "^18.0.25",
|
|
35
|
-
"@types/react-dom": "^18.0.8",
|
|
36
|
-
"@types/styled-components": "^5.1.26",
|
|
9
|
+
"homepage": "https://mdnelles.github.io/a3o-playground",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@reduxjs/toolkit": "^1.9.5",
|
|
37
12
|
"react": "^18.2.0",
|
|
38
13
|
"react-dom": "^18.2.0",
|
|
39
|
-
"
|
|
14
|
+
"react-scripts": "5.0.1",
|
|
15
|
+
"styled-components": "^6.0.4"
|
|
40
16
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
17
|
+
"scripts": {
|
|
18
|
+
"start": "react-scripts start",
|
|
19
|
+
"build": "rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files",
|
|
20
|
+
"build:ra": "react-scripts build",
|
|
21
|
+
"test": "react-scripts test",
|
|
22
|
+
"eject": "react-scripts eject"
|
|
44
23
|
},
|
|
45
|
-
"
|
|
46
|
-
"
|
|
24
|
+
"eslintConfig": {
|
|
25
|
+
"extends": [
|
|
26
|
+
"react-app",
|
|
27
|
+
"react-app/jest"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"browserslist": {
|
|
31
|
+
"production": [
|
|
32
|
+
">0.2%",
|
|
33
|
+
"not dead",
|
|
34
|
+
"not op_mini all"
|
|
35
|
+
],
|
|
36
|
+
"development": [
|
|
37
|
+
"last 1 chrome version",
|
|
38
|
+
"last 1 firefox version",
|
|
39
|
+
"last 1 safari version"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@babel/cli": "^7.22.9",
|
|
44
|
+
"@babel/core": "^7.22.9",
|
|
45
|
+
"@babel/preset-env": "^7.22.9",
|
|
46
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
47
|
+
"@testing-library/react": "^14.0.0",
|
|
48
|
+
"@testing-library/user-event": "^14.4.3",
|
|
49
|
+
"@types/jest": "^29.5.3",
|
|
50
|
+
"@types/node": "^20.4.2",
|
|
51
|
+
"@types/react": "^18.2.15",
|
|
52
|
+
"@types/react-dom": "^18.2.7",
|
|
53
|
+
"@types/styled-components": "^5.1.26",
|
|
54
|
+
"typescript": "^5.1.6"
|
|
47
55
|
},
|
|
48
56
|
"keywords": [
|
|
49
57
|
"React",
|
package/public/ang2.png
ADDED
|
Binary file
|
package/public/ang3.png
ADDED
|
Binary file
|
package/public/angl1.png
ADDED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<meta name="theme-color" content="#000000" />
|
|
8
|
+
<meta
|
|
9
|
+
name="description"
|
|
10
|
+
content="Web site created using create-react-app"
|
|
11
|
+
/>
|
|
12
|
+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
|
+
<!--
|
|
14
|
+
manifest.json provides metadata used when your web app is installed on a
|
|
15
|
+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
16
|
+
-->
|
|
17
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
18
|
+
<!--
|
|
19
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
|
20
|
+
It will be replaced with the URL of the `public` folder during the build.
|
|
21
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
|
22
|
+
|
|
23
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
24
|
+
work correctly both with client-side routing and a non-root public URL.
|
|
25
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
|
26
|
+
-->
|
|
27
|
+
<title>React Redux App</title>
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
31
|
+
<div id="root"></div>
|
|
32
|
+
<!--
|
|
33
|
+
This HTML file is a template.
|
|
34
|
+
If you open it directly in the browser, you will see an empty page.
|
|
35
|
+
|
|
36
|
+
You can add webfonts, meta tags, or analytics to this file.
|
|
37
|
+
The build step will place the bundled scripts into the <body> tag.
|
|
38
|
+
|
|
39
|
+
To begin the development, run `npm start` or `yarn start`.
|
|
40
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
|
41
|
+
-->
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "React App",
|
|
3
|
+
"name": "Create React App Sample",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "favicon.ico",
|
|
7
|
+
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
+
"type": "image/x-icon"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"src": "logo192.png",
|
|
12
|
+
"type": "image/png",
|
|
13
|
+
"sizes": "192x192"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"src": "logo512.png",
|
|
17
|
+
"type": "image/png",
|
|
18
|
+
"sizes": "512x512"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"start_url": ".",
|
|
22
|
+
"display": "standalone",
|
|
23
|
+
"theme_color": "#000000",
|
|
24
|
+
"background_color": "#ffffff"
|
|
25
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { FaceProps } from "./types";
|
|
3
|
+
|
|
4
|
+
export default function Face(props: FaceProps): JSX.Element {
|
|
5
|
+
let display = true;
|
|
6
|
+
let {
|
|
7
|
+
depth = 10,
|
|
8
|
+
global = { css: "", body: "" },
|
|
9
|
+
height = 10,
|
|
10
|
+
face,
|
|
11
|
+
width = 100,
|
|
12
|
+
} = props;
|
|
13
|
+
|
|
14
|
+
let transform;
|
|
15
|
+
let tranz = +height / 2;
|
|
16
|
+
const body = face.body ? face.body : global.body;
|
|
17
|
+
|
|
18
|
+
////////////////////////////////////////////////////////////////////////////// BOTTOM
|
|
19
|
+
if (face.name === "bottom") {
|
|
20
|
+
tranz = +height - +depth / 2;
|
|
21
|
+
height = +depth;
|
|
22
|
+
transform = `transform: rotateX(-90deg) translateZ(${tranz}px);`;
|
|
23
|
+
} else if (face.name === "bottom_rear") {
|
|
24
|
+
tranz = +height - +depth / 2;
|
|
25
|
+
height = +depth;
|
|
26
|
+
transform = `transform: rotateX(-90deg) translateZ(${tranz}px) translateY(${height}px) `;
|
|
27
|
+
} else if (face.name === "bottom_front") {
|
|
28
|
+
tranz = +height - +depth / 2;
|
|
29
|
+
height = +depth;
|
|
30
|
+
transform = `transform: rotateX(-90deg) translateZ(${tranz}px) translateY(${-height}px) `;
|
|
31
|
+
|
|
32
|
+
////////////////////////////////////////////////////////////////////////////// TOPS
|
|
33
|
+
} else if (face.name === "top") {
|
|
34
|
+
height = +depth;
|
|
35
|
+
if (!!depth) tranz = +depth / 2;
|
|
36
|
+
transform = `transform: rotateX(90deg) translateZ(${tranz}px);`;
|
|
37
|
+
} else if (face.name === "top_rear") {
|
|
38
|
+
height = +depth;
|
|
39
|
+
if (!!depth) tranz = +depth / 2;
|
|
40
|
+
transform = `transform: rotateX(90deg) translateZ(${tranz}px) translateY(-${
|
|
41
|
+
tranz * 2
|
|
42
|
+
}px) `;
|
|
43
|
+
} else if (face.name === "top_front") {
|
|
44
|
+
height = +depth;
|
|
45
|
+
if (!!depth) tranz = +depth / 2;
|
|
46
|
+
|
|
47
|
+
transform = `transform: rotateX(90deg) translateZ(${tranz}px) translateY(${
|
|
48
|
+
tranz * 2
|
|
49
|
+
}px) `;
|
|
50
|
+
} else if (face.name === "front") {
|
|
51
|
+
if (!!depth) tranz = +depth / 2;
|
|
52
|
+
transform = `transform: rotateY(0deg) translateZ(${tranz}px);`;
|
|
53
|
+
} else if (face.name === "back") {
|
|
54
|
+
if (!!depth) tranz = +depth / 2;
|
|
55
|
+
transform = `transform: rotateY(180deg) translateZ(${tranz}px);`;
|
|
56
|
+
} else if (face.name === "right") {
|
|
57
|
+
if (height > width && !depth) {
|
|
58
|
+
tranz = -(+height / 2 - +width);
|
|
59
|
+
width = +height;
|
|
60
|
+
} else if (width > height && !depth) {
|
|
61
|
+
tranz = +height / 2;
|
|
62
|
+
height = +width;
|
|
63
|
+
} else {
|
|
64
|
+
tranz = +width - +depth / 2;
|
|
65
|
+
width = +depth;
|
|
66
|
+
}
|
|
67
|
+
transform = `transform: rotateY(90deg) translateZ(${tranz}px);`;
|
|
68
|
+
// topr is to of Ribbon which points back
|
|
69
|
+
} else if (face.name === "left") {
|
|
70
|
+
if (height > width && !depth) {
|
|
71
|
+
tranz = -(+height / 2 - +width);
|
|
72
|
+
width = +height;
|
|
73
|
+
} else if (width > height && !depth) {
|
|
74
|
+
tranz = +height / 2;
|
|
75
|
+
height = +width;
|
|
76
|
+
} else {
|
|
77
|
+
tranz = +depth / 2;
|
|
78
|
+
width = +depth;
|
|
79
|
+
}
|
|
80
|
+
transform = `transform: rotateY(-90deg) translateZ(${tranz}px);`;
|
|
81
|
+
} else {
|
|
82
|
+
//console.log(face.name + " is not a recognized face.name");
|
|
83
|
+
display = false;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const Specs: any = styled.section`
|
|
87
|
+
${face.css || global.css}
|
|
88
|
+
width: ${width}px;
|
|
89
|
+
position: absolute;
|
|
90
|
+
height: ${height}px;
|
|
91
|
+
${transform}
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
return display ? <Specs>{body}</Specs> : <></>;
|
|
95
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ObjWrapper } from "./styles/Global";
|
|
2
|
+
import { AnimWrap } from "./styles/AnimWrap";
|
|
3
|
+
import { SceneStyle } from "./styles/Scene";
|
|
4
|
+
import Face from "./Face";
|
|
5
|
+
import { FaceType, ObjProps } from "./types";
|
|
6
|
+
import React from "react";
|
|
7
|
+
|
|
8
|
+
export default function Obj(props: ObjProps): JSX.Element {
|
|
9
|
+
let {
|
|
10
|
+
anim1,
|
|
11
|
+
anim2,
|
|
12
|
+
width = 5,
|
|
13
|
+
height = 5,
|
|
14
|
+
depth = 5,
|
|
15
|
+
global = {},
|
|
16
|
+
faces,
|
|
17
|
+
perspective,
|
|
18
|
+
perspectiveOrigin,
|
|
19
|
+
zIndex,
|
|
20
|
+
} = props;
|
|
21
|
+
|
|
22
|
+
// process config
|
|
23
|
+
const buildFace = (face: FaceType): any => {
|
|
24
|
+
const details = {
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
depth,
|
|
28
|
+
face,
|
|
29
|
+
global,
|
|
30
|
+
};
|
|
31
|
+
return <Face {...details} key={face.name} />;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<SceneStyle
|
|
36
|
+
width={width}
|
|
37
|
+
height={height}
|
|
38
|
+
perspective={perspective}
|
|
39
|
+
perspectiveOrigin={perspectiveOrigin}
|
|
40
|
+
zIndex={zIndex}
|
|
41
|
+
>
|
|
42
|
+
<AnimWrap animSpecs={anim1}>
|
|
43
|
+
<AnimWrap animSpecs={anim2}>
|
|
44
|
+
<ObjWrapper>
|
|
45
|
+
{faces && faces[0]
|
|
46
|
+
? faces.map((face) => (face.name ? buildFace(face) : null))
|
|
47
|
+
: null}
|
|
48
|
+
</ObjWrapper>
|
|
49
|
+
</AnimWrap>
|
|
50
|
+
</AnimWrap>
|
|
51
|
+
</SceneStyle>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface AnimStylesProps {
|
|
2
|
+
children?: any;
|
|
3
|
+
animSpecs?: any;
|
|
4
|
+
}
|
|
5
|
+
export interface AnimSpecsType {
|
|
6
|
+
border?: string | undefined;
|
|
7
|
+
degreesHi?: number | undefined;
|
|
8
|
+
degreesLow?: number | undefined;
|
|
9
|
+
delay?: number | undefined;
|
|
10
|
+
direction?: string | undefined;
|
|
11
|
+
duration?: number | string | undefined;
|
|
12
|
+
fillMode?: string | undefined;
|
|
13
|
+
iterationCount?: number | string | undefined;
|
|
14
|
+
animationPlayState?: string;
|
|
15
|
+
name?: string | undefined;
|
|
16
|
+
timing?: string | undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { AnimStylesProps } from "./Anim";
|
|
3
|
+
import { allAnims } from "./Anims";
|
|
4
|
+
|
|
5
|
+
export const AnimWrap = (props: AnimStylesProps) => {
|
|
6
|
+
const { children, animSpecs } = props;
|
|
7
|
+
const AS: any = animSpecs;
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
X360,
|
|
11
|
+
Y360,
|
|
12
|
+
fadeInkf,
|
|
13
|
+
wobY,
|
|
14
|
+
wobX,
|
|
15
|
+
fwdx018,
|
|
16
|
+
fwdx1836,
|
|
17
|
+
fwdx09,
|
|
18
|
+
fwdx918,
|
|
19
|
+
fwdx1827,
|
|
20
|
+
fwdx2736,
|
|
21
|
+
fwdy018,
|
|
22
|
+
fwdy1836,
|
|
23
|
+
fwdy09,
|
|
24
|
+
fwdy918,
|
|
25
|
+
fwdy1827,
|
|
26
|
+
fwdy2736,
|
|
27
|
+
floatX,
|
|
28
|
+
floatShadow,
|
|
29
|
+
pulseSM,
|
|
30
|
+
pulseMD,
|
|
31
|
+
pulseLG,
|
|
32
|
+
swing,
|
|
33
|
+
swingDecay,
|
|
34
|
+
noAnim,
|
|
35
|
+
} = allAnims({ degreesHi: AS.degreesHi, degreesLow: AS.degreesLow });
|
|
36
|
+
|
|
37
|
+
let theAnim: string | any = "noAnim";
|
|
38
|
+
|
|
39
|
+
if (AS.name === "X360") theAnim = X360;
|
|
40
|
+
else if (AS.name === "Y360") theAnim = Y360;
|
|
41
|
+
else if (AS.name === "fadeInkf") theAnim = fadeInkf;
|
|
42
|
+
else if (AS.name === "wobX") theAnim = wobX;
|
|
43
|
+
else if (AS.name === "wobY") theAnim = wobY;
|
|
44
|
+
else if (AS.name === "fwdx018") theAnim = fwdx018;
|
|
45
|
+
else if (AS.name === "fwdx1836") theAnim = fwdx1836;
|
|
46
|
+
else if (AS.name === "fwdx09") theAnim = fwdx09;
|
|
47
|
+
else if (AS.name === "fwdx918") theAnim = fwdx918;
|
|
48
|
+
else if (AS.name === "fwdx1827") theAnim = fwdx1827;
|
|
49
|
+
else if (AS.name === "fwdx2736") theAnim = fwdx2736;
|
|
50
|
+
else if (AS.name === "fwdy018") theAnim = fwdy018;
|
|
51
|
+
else if (AS.name === "fwdy1836") theAnim = fwdy1836;
|
|
52
|
+
else if (AS.name === "fwdy09") theAnim = fwdy09;
|
|
53
|
+
else if (AS.name === "fwdy918") theAnim = fwdy918;
|
|
54
|
+
else if (AS.name === "fwdy1827") theAnim = fwdy1827;
|
|
55
|
+
else if (AS.name === "fwdy2736") theAnim = fwdy2736;
|
|
56
|
+
else if (AS.name === "floatX") theAnim = floatX;
|
|
57
|
+
else if (AS.name === "floatShadow") theAnim = floatShadow;
|
|
58
|
+
else if (AS.name === "pulseSM") theAnim = pulseSM;
|
|
59
|
+
else if (AS.name === "pulseMD") theAnim = pulseMD;
|
|
60
|
+
else if (AS.name === "pulseLG") theAnim = pulseLG;
|
|
61
|
+
else if (AS.name === "swing") theAnim = swing;
|
|
62
|
+
else if (AS.name === "swingDecay") theAnim = swingDecay;
|
|
63
|
+
else theAnim = noAnim;
|
|
64
|
+
|
|
65
|
+
const AnimWrapDiv: any = styled.div`
|
|
66
|
+
width: 100%;
|
|
67
|
+
height: 100%;
|
|
68
|
+
position: relative;
|
|
69
|
+
transform-style: preserve-3d;
|
|
70
|
+
border: ${AS.border};
|
|
71
|
+
-webkit-animation-duration: ${AS.duration}s;
|
|
72
|
+
animation-duration: ${AS.duration}s;
|
|
73
|
+
-webkit-animation-iteration-count: ${AS.iterationCount};
|
|
74
|
+
animation-iteration-count: ${AS.iterationCount};
|
|
75
|
+
-webkit-animation-name: ${theAnim};
|
|
76
|
+
animation-name: ${theAnim};
|
|
77
|
+
-webkit-animation-fill-mode: ${AS.fillMode};
|
|
78
|
+
animation-fill-mode: ${AS.fillMode};
|
|
79
|
+
-webkit-animation-play-state: ${AS.animationPlayState};
|
|
80
|
+
animation-play-state: ${AS.animationPlayState};
|
|
81
|
+
animation-direction: ${AS.direction};
|
|
82
|
+
-webkit-animation-direction: ${AS.direction};
|
|
83
|
+
-webkit-animation-timing-function: ${AS.timing};
|
|
84
|
+
animation-timing-function: ${AS.timing};
|
|
85
|
+
-webkit-animation-delay: ${AS.delay}s;
|
|
86
|
+
animation-delay: ${AS.delay}s;
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
return <AnimWrapDiv>{children}</AnimWrapDiv>;
|
|
90
|
+
};
|