anim-3d-obj 2.0.9 → 2.0.11

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 CHANGED
@@ -1,3 +1,10 @@
1
+ # anim-3d-obj
2
+
3
+ A lightweight React component for rendering and animating 3D-like objects using only HTML & CSS.
4
+ No WebGL or heavy 3D libraries required.
5
+
6
+ ---
7
+
1
8
  # React Typescript Cuboid Builder
2
9
 
3
10
  This project allows a user to create Cuboids of any size simply by entering a set of parameters.
@@ -25,6 +32,7 @@ The program does the leg work with regard to calculating translationZ depth and
25
32
  - `noAnim`: no animation place holder
26
33
 
27
34
  `X-AXIS Animations`
35
+
28
36
  - `X360`: rotate 360 degrees on the x-axis: [demo](https://codesandbox.io/s/anim-3d-obj-x360-7kiuhw)
29
37
  - `wobX`: wobble on x-axis (degreesHi <-> degreesLow): [demo](https://codesandbox.io/s/anim-3d-obj-wobx-ldwek7)
30
38
  - `fwdx018`: spin object on x-axis from 0 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwd180-v90xyu)
@@ -35,6 +43,7 @@ The program does the leg work with regard to calculating translationZ depth and
35
43
  - `fwdx2736`: spin object on x-axis from 270 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdx2736-e6c6wg)
36
44
 
37
45
  `Y-AXIS Animations`
46
+
38
47
  - `Y360`: rotate 360 degrees on the y-axis: [demo](https://codesandbox.io/s/anim-3d-obj-y360-16lzeb)
39
48
  - `wobY`: wobble on y-axis (degreesHi <-> degreesLow): [demo](https://codesandbox.io/s/anim-3d-obj-woby-tkoxms)
40
49
  - `fwdy018`: spin object on y-axis from 0 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy180-qpqhtq)
@@ -44,8 +53,8 @@ The program does the leg work with regard to calculating translationZ depth and
44
53
  - `fwdy1827`: spin object on y-axis from 180 degrees to 270 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy1827-osskgx)
45
54
  - `fwdy2736`: spin object on y-axis from 270 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy2736-rnbs2q)
46
55
 
47
-
48
56
  ## Config
57
+
49
58
  ### Animations:
50
59
 
51
60
  Animations are optional. Either or both of `anim1` or `anim2` can be applied to the component. Animations are applied to 2 wrapping divs respectively.
@@ -66,42 +75,122 @@ const anim1 = {
66
75
  ```
67
76
 
68
77
  ### Faces:
78
+
69
79
  This is an array of objects containing the face used for a given component
80
+
70
81
  ```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)`,
82
- },
83
- {
84
- name: "right",
85
- body: "RIGHT",
86
- css: `background:rgba(220,220,220,.5);
82
+ export interface FaceType {
83
+ name?: string; // front,back,left,right,top,top_rear,top_front,bottom,bottom_rear,bottom_front
84
+ css?: string | undefined;
85
+ body?: any; // can be JSX Component | string | number
86
+ }
87
+
88
+ const faces: FaceType[] = [
89
+ {
90
+ name: "back",
91
+ body: "BACK",
92
+ css: `background:rgba(22,22,22,.5)`,
93
+ },
94
+ {
95
+ name: "right",
96
+ body: "RIGHT",
97
+ css: `background:rgba(220,220,220,.5);
87
98
  border:1px solid #ddd`,
88
- },
89
- ];
99
+ },
100
+ ];
90
101
  ```
91
102
 
92
103
  ### 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.
104
+
105
+ 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.
106
+
94
107
  ```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
- };
108
+ interface GlobalType {
109
+ css?: string;
110
+ body?: string;
111
+ }
112
+ const global: GlobalType = {
113
+ body: "BODY FOR FACE WHICH DOES NOT CONTAIN BODY",
114
+ css: "color:red",
115
+ };
103
116
  ```
104
117
 
105
118
  ![all sides](https://github.com/mdnelles/anim-3d-obj-npm-publisher/blob/4a9769a6386a3b5425ede9a04b346d5461051ae0/ang1.png?raw=true)
106
119
 
107
- - https://www.npmjs.com/package/anim-3d-obj
120
+ - https://www.npmjs.com/package/anim-3d-obj
121
+
122
+ ---
123
+
124
+ ## Features
125
+
126
+ - 🎨 Pure CSS-based 3D object rendering
127
+ - ⚡ Zero dependencies (other than React)
128
+ - 🛠 Fully customizable width, height, depth, and colors
129
+ - 🌀 Built-in animation support
130
+ - 🌍 SSR-safe (works with Next.js, Remix, etc.)
131
+
132
+ ---
133
+
134
+ ## Peer requirements
135
+
136
+ React 18+. Works in Vite, CRA, Next.js (SSR-safe), Remix, etc.
137
+
138
+ ---
139
+
140
+ ## Installation
141
+
142
+ ```bash
143
+ npm install anim-3d-obj
144
+ # or
145
+ yarn add anim-3d-obj
146
+ # or
147
+ pnpm add anim-3d-obj
148
+
149
+ import React from "react";
150
+ import { Obj } from "anim-3d-obj";
151
+ ```
152
+
153
+ ## Full Example
154
+
155
+ ```bash
156
+ function App() {
157
+ const global = {
158
+ css: "border: 1px solid #00f; color:#00f; backface-visibility: visible; text-align:center; line-height: 120px; font-size: 14px;",
159
+ body: "height: 120px; width: 120px;",
160
+ };
161
+
162
+ return (
163
+ <Obj
164
+ depth="120px"
165
+ height="120px"
166
+ width="120px"
167
+ perspective="800px"
168
+ rotation="x 1s linear infinite"
169
+ global={global}
170
+ >
171
+ Hello 3D
172
+ </Obj>
173
+ );
174
+ }
175
+
176
+ export default App;
177
+ ```
178
+
179
+ # Props
180
+
181
+ The `<Obj />` component accepts the following props:
182
+
183
+ | Prop | Type | Default | Description |
184
+ | ----------- | ------ | --------- | ------------------------------------------------------------------------------ |
185
+ | width | string | "100px" | Width of the object. |
186
+ | height | string | "100px" | Height of the object. |
187
+ | depth | string | "100px" | Depth of the object (3rd dimension). |
188
+ | perspective | string | "600px" | Perspective distance for 3D rendering. |
189
+ | rotation | string | undefined | CSS animation shorthand for rotating the object (e.g. "x 1s linear infinite"). |
190
+ | global | object | {} | Global styles for all faces (css for shared CSS, body for dimensions). |
191
+
192
+ ## Tips
193
+
194
+ - You can pass any React children inside `<Obj> ... </Obj>` to render content on the front face.
195
+ - Combine with CSS variables or Tailwind utilities for theming.
196
+ - Works with server-side rendering (SSR) — no window dependency.