anim-3d-obj 2.0.0 → 2.0.2

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,11 +1,196 @@
1
1
  # anim-3d-obj
2
2
 
3
- A tiny React component that renders a 3D object (rectangular prism) with configurable faces and built-in animations. You can place text or custom React content on any face.
3
+ A lightweight React component for rendering and animating 3D-like objects using only HTML & CSS.
4
+ No WebGL or heavy 3D libraries required.
4
5
 
5
- ## Install
6
+ ---
7
+
8
+ # React Typescript Cuboid Builder
9
+
10
+ This project allows a user to create Cuboids of any size simply by entering a set of parameters.
11
+ The program does the leg work with regard to calculating translationZ depth and config on the fly.
12
+
13
+ ## Examples
14
+
15
+ - [6 sided Cuboid - animate X360 Y360](https://codesandbox.io/s/anim-3d-obj-all-sides-simple-bf67yg-tzr2v6)
16
+ - [3 sided Object - animate y-axis](https://codesandbox.io/s/anim-3d-obj-3-sides-wobble-y-axis-wglkms)
17
+ - [Double box spin](https://codesandbox.io/s/react-anim-3d-double-box-spin-vbdhg2)
18
+ - [Floating Ribbon](https://codesandbox.io/s/cocky-butterfly-ygwkps)
19
+ - [Parallel divs animated x and y axis in tandem](https://codesandbox.io/s/anim-3d-obj-2-sides-simple-4057y7)
20
+ - [Obj Skeleton](https://codesandbox.io/s/anim-3d-obj-skeleton-5dlk70)
21
+
22
+ `** ANIMATIONS`
23
+
24
+ - `fadeInkf`: fade object in from 0 to 1 Opacity: [demo](https://codesandbox.io/s/anim-3d-obj-fadeinkf-1fozww)
25
+ - `floatX`: float object so is not stationary: [demo](https://codesandbox.io/s/anim-3d-obj-floatx-hzeo42)
26
+ - `floatShadow`: float object + add shadow: [demo](https://codesandbox.io/s/anim-3d-obj-floatshadow-8pp5k0)
27
+ - `pulseSM`: pulse object Small: [demo](https://codesandbox.io/s/anim-3d-obj-pulsesm-k2rjb6)
28
+ - `pulseMD`: pulse object Medium: [demo](https://codesandbox.io/s/anim-3d-obj-pulsemd-sqk2of)
29
+ - `pulseLG`: pulse object Large: [demo](https://codesandbox.io/s/anim-3d-obj-pulselg-qz7x0m)
30
+ - `swing`: Swing component: [demo](https://codesandbox.io/s/anim-3d-obj-swing-snj8li)
31
+ - `swingDecay`: Swing component with decay: [demo](https://codesandbox.io/s/anim-3d-obj-swingdecay-cku0e1)
32
+ - `noAnim`: no animation place holder
33
+
34
+ `X-AXIS Animations`
35
+
36
+ - `X360`: rotate 360 degrees on the x-axis: [demo](https://codesandbox.io/s/anim-3d-obj-x360-7kiuhw)
37
+ - `wobX`: wobble on x-axis (degreesHi <-> degreesLow): [demo](https://codesandbox.io/s/anim-3d-obj-wobx-ldwek7)
38
+ - `fwdx018`: spin object on x-axis from 0 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwd180-v90xyu)
39
+ - `fwdx1836`: spin object on x-axis from 180 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwd1836-mtwuv9)
40
+ - `fwdx09`: spin object on x-axis from 0 degrees to 90 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwd09-84vocn)
41
+ - `fwdx918`: spin object on x-axis from 90 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwd918-6039fj)
42
+ - `fwdx1827`: spin object on x-axis from 180 degrees to 270 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdx1827-qpqhtq)
43
+ - `fwdx2736`: spin object on x-axis from 270 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdx2736-e6c6wg)
44
+
45
+ `Y-AXIS Animations`
46
+
47
+ - `Y360`: rotate 360 degrees on the y-axis: [demo](https://codesandbox.io/s/anim-3d-obj-y360-16lzeb)
48
+ - `wobY`: wobble on y-axis (degreesHi <-> degreesLow): [demo](https://codesandbox.io/s/anim-3d-obj-woby-tkoxms)
49
+ - `fwdy018`: spin object on y-axis from 0 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy180-qpqhtq)
50
+ - `fwdy1836`: spin object on y-axis from 180 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy1836-qpqhtq)
51
+ - `fwdy09`: spin object on y-axis from 0 degrees to 90 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy09-elklgr)
52
+ - `fwdy918`: spin object on y-axis from 90 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy918-gnym88)
53
+ - `fwdy1827`: spin object on y-axis from 180 degrees to 270 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy1827-osskgx)
54
+ - `fwdy2736`: spin object on y-axis from 270 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy2736-rnbs2q)
55
+
56
+ ## Config
57
+
58
+ ### Animations:
59
+
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.
61
+
62
+ ```typescript
63
+ const anim1 = {
64
+ border: "", // while testing reveal the animation wrapper
65
+ degreesHi: -45, // degrees if spin
66
+ degreesLow: 45, // degrees if spin
67
+ delay: 0, // start delay in seconds
68
+ direction: "normal", //normal alternating reverse
69
+ duration: 8, // seconds
70
+ fillMode: "forwards", // none forwards backwards both
71
+ iterationCount: "infinite", // number or infinte
72
+ name: "Y360", // ** ANIMATIONS (above)
73
+ timing: "ease-in-out", // linear ease ease-in-out
74
+ };
75
+ ```
76
+
77
+ ### Faces:
78
+
79
+ This is an array of objects containing the face used for a given component
80
+
81
+ ```javascript
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);
98
+ border:1px solid #ddd`,
99
+ },
100
+ ];
101
+ ```
102
+
103
+ ### Global (face):
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
+
107
+ ```javascript
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
+ };
116
+ ```
117
+
118
+ ![all sides](https://github.com/mdnelles/anim-3d-obj-npm-publisher/blob/4a9769a6386a3b5425ede9a04b346d5461051ae0/ang1.png?raw=true)
119
+
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
6
141
 
7
142
  ```bash
8
- npm i anim-3d-obj
143
+ npm install anim-3d-obj
9
144
  # or
10
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";
11
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.
package/dist/index.cjs ADDED
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+
5
+ // src/components/Obj.tsx
6
+ var Obj = ({
7
+ width = "160px",
8
+ height = "160px",
9
+ depth = "150px",
10
+ perspective = 500,
11
+ perspectiveOrigin = "50% 50%",
12
+ rotation,
13
+ className,
14
+ style,
15
+ global,
16
+ children
17
+ }) => {
18
+ return /* @__PURE__ */ jsxRuntime.jsx(
19
+ "div",
20
+ {
21
+ className,
22
+ style: {
23
+ perspective,
24
+ perspectiveOrigin,
25
+ ...style
26
+ },
27
+ "data-anim-3d-obj": true,
28
+ children
29
+ }
30
+ );
31
+ };
32
+
33
+ exports.Obj = Obj;
34
+ //# sourceMappingURL=index.cjs.map
35
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Obj.tsx"],"names":["jsx"],"mappings":";;;;;AAmBO,IAAM,MAA0B,CAAC;AAAA,EACrC,KAAA,GAAQ,OAAA;AAAA,EACR,MAAA,GAAS,OAAA;AAAA,EACT,KAAA,GAAQ,OAAA;AAAA,EACR,WAAA,GAAc,GAAA;AAAA,EACd,iBAAA,GAAoB,SAAA;AAAA,EACpB,QAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA;AACH,CAAA,KAAM;AAEH,EAAA,uBACGA,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACE,SAAA;AAAA,MACA,KAAA,EAAO;AAAA,QACJ,WAAA;AAAA,QACA,iBAAA;AAAA,QACA,GAAG;AAAA,OACN;AAAA,MACA,kBAAA,EAAgB,IAAA;AAAA,MAGf;AAAA;AAAA,GACJ;AAEN","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport \"./../styles/obj.css\";\n\nexport type ObjProps = {\n width?: string | number;\n height?: string | number;\n depth?: string | number;\n perspective?: string | number;\n perspectiveOrigin?: string;\n rotation?: string; // e.g., \"x 1s linear infinite\"\n className?: string;\n style?: React.CSSProperties;\n global?: {\n css?: string;\n body?: string;\n };\n children?: React.ReactNode;\n};\n\nexport const Obj: React.FC<ObjProps> = ({\n width = \"160px\",\n height = \"160px\",\n depth = \"150px\",\n perspective = 500,\n perspectiveOrigin = \"50% 50%\",\n rotation,\n className,\n style,\n global,\n children,\n}) => {\n // … your existing DOM/CSS 3D layout & animations\n return (\n <div\n className={className}\n style={{\n perspective,\n perspectiveOrigin,\n ...style,\n }}\n data-anim-3d-obj\n >\n {/* faces, wrappers, animations… */}\n {children}\n </div>\n );\n};\n"]}
package/dist/index.css ADDED
@@ -0,0 +1,38 @@
1
+ /* src/styles/obj.css */
2
+ .anim3d-stage {
3
+ position: relative;
4
+ width: max-content;
5
+ height: max-content;
6
+ perspective: 600px;
7
+ perspective-origin: 50% 50%;
8
+ }
9
+ .anim3d-wrapper {
10
+ position: relative;
11
+ transform-style: preserve-3d;
12
+ width: var(--obj-w);
13
+ height: var(--obj-h);
14
+ }
15
+ .anim3d-center {
16
+ position: absolute;
17
+ left: 50%;
18
+ top: 50%;
19
+ width: 2px;
20
+ height: 2px;
21
+ background: #f00;
22
+ transform: translate(-50%, -50%);
23
+ z-index: 10;
24
+ }
25
+ .anim3d-face {
26
+ position: absolute;
27
+ left: 50%;
28
+ top: 50%;
29
+ width: var(--obj-w);
30
+ height: var(--obj-h);
31
+ transform-style: preserve-3d;
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ backface-visibility: visible;
36
+ box-sizing: border-box;
37
+ }
38
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/styles/obj.css"],"sourcesContent":[".anim3d-stage {\n position: relative;\n width: max-content;\n height: max-content;\n perspective: 600px;\n perspective-origin: 50% 50%;\n}\n\n.anim3d-wrapper {\n position: relative;\n transform-style: preserve-3d;\n width: var(--obj-w);\n height: var(--obj-h);\n}\n\n.anim3d-center {\n position: absolute;\n left: 50%;\n top: 50%;\n width: 2px;\n height: 2px;\n background: #f00;\n transform: translate(-50%, -50%);\n z-index: 10;\n}\n\n.anim3d-face {\n position: absolute;\n left: 50%;\n top: 50%;\n width: var(--obj-w);\n height: var(--obj-h);\n transform-style: preserve-3d;\n display: flex;\n align-items: center;\n justify-content: center;\n backface-visibility: visible;\n box-sizing: border-box;\n}\n"],"mappings":";AAAA,CAAC;AACE,YAAU;AACV,SAAO;AACP,UAAQ;AACR,eAAa;AACb,sBAAoB,IAAI;AAC3B;AAEA,CAAC;AACE,YAAU;AACV,mBAAiB;AACjB,SAAO,IAAI;AACX,UAAQ,IAAI;AACf;AAEA,CAAC;AACE,YAAU;AACV,QAAM;AACN,OAAK;AACL,SAAO;AACP,UAAQ;AACR,cAAY;AACZ,aAAW,UAAU,IAAI,EAAE;AAC3B,WAAS;AACZ;AAEA,CAAC;AACE,YAAU;AACV,QAAM;AACN,OAAK;AACL,SAAO,IAAI;AACX,UAAQ,IAAI;AACZ,mBAAiB;AACjB,WAAS;AACT,eAAa;AACb,mBAAiB;AACjB,uBAAqB;AACrB,cAAY;AACf;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,2 +1,20 @@
1
- export { A as AnimationConfig, B as BuiltInAnimName, F as FaceDef, a as FaceName, G as GlobalDef, default as Obj, O as ObjProps } from './components/Obj.mjs';
2
- import 'react';
1
+ import * as React from 'react';
2
+
3
+ type ObjProps = {
4
+ width?: string | number;
5
+ height?: string | number;
6
+ depth?: string | number;
7
+ perspective?: string | number;
8
+ perspectiveOrigin?: string;
9
+ rotation?: string;
10
+ className?: string;
11
+ style?: React.CSSProperties;
12
+ global?: {
13
+ css?: string;
14
+ body?: string;
15
+ };
16
+ children?: React.ReactNode;
17
+ };
18
+ declare const Obj: React.FC<ObjProps>;
19
+
20
+ export { Obj, type ObjProps };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,20 @@
1
- export { A as AnimationConfig, B as BuiltInAnimName, F as FaceDef, a as FaceName, G as GlobalDef, default as Obj, O as ObjProps } from './components/Obj.js';
2
- import 'react';
1
+ import * as React from 'react';
2
+
3
+ type ObjProps = {
4
+ width?: string | number;
5
+ height?: string | number;
6
+ depth?: string | number;
7
+ perspective?: string | number;
8
+ perspectiveOrigin?: string;
9
+ rotation?: string;
10
+ className?: string;
11
+ style?: React.CSSProperties;
12
+ global?: {
13
+ css?: string;
14
+ body?: string;
15
+ };
16
+ children?: React.ReactNode;
17
+ };
18
+ declare const Obj: React.FC<ObjProps>;
19
+
20
+ export { Obj, type ObjProps };
package/dist/index.js CHANGED
@@ -1,232 +1,33 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- Obj: () => Obj_default
24
- });
25
- module.exports = __toCommonJS(src_exports);
1
+ import { jsx } from 'react/jsx-runtime';
26
2
 
27
3
  // src/components/Obj.tsx
28
- var import_react = require("react");
29
-
30
- // src/keyframes.ts
31
- function ensureStyleTag() {
32
- let tag = document.getElementById(
33
- "anim3d-keyframes"
34
- );
35
- if (!tag) {
36
- tag = document.createElement("style");
37
- tag.id = "anim3d-keyframes";
38
- document.head.appendChild(tag);
39
- }
40
- return tag;
41
- }
42
- function inject(css) {
43
- if (typeof document === "undefined") return;
44
- const tag = ensureStyleTag();
45
- tag.appendChild(document.createTextNode(css));
46
- }
47
- function builtInKeyframes(name, cfg) {
48
- const hi = cfg.degreesHi ?? 15;
49
- const lo = cfg.degreesLow ?? -15;
50
- switch (name) {
51
- case "Y360":
52
- return `@keyframes Y360 { from { transform: rotateY(0deg) } to { transform: rotateY(360deg) } }`;
53
- case "X360":
54
- return `@keyframes X360 { from { transform: rotateX(0deg) } to { transform: rotateX(360deg) } }`;
55
- case "Z360":
56
- return `@keyframes Z360 { from { transform: rotateZ(0deg) } to { transform: rotateZ(360deg) } }`;
57
- case "rockY":
58
- return `@keyframes rockY { 0%{ transform: rotateY(${lo}deg) } 50%{ transform: rotateY(${hi}deg) } 100%{ transform: rotateY(${lo}deg) } }`;
59
- case "rockX":
60
- return `@keyframes rockX { 0%{ transform: rotateX(${lo}deg) } 50%{ transform: rotateX(${hi}deg) } 100%{ transform: rotateX(${lo}deg) } }`;
61
- default:
62
- return "";
63
- }
64
- }
65
- function resolveAnimation(cfg) {
66
- if (!cfg) return null;
67
- const name = cfg.name;
68
- const builtIn = builtInKeyframes(name, cfg);
69
- if (builtIn) {
70
- const marker = `/*kf-${name}*/`;
71
- if (typeof document !== "undefined") {
72
- const tag = ensureStyleTag();
73
- if (!tag.innerHTML.includes(marker)) {
74
- inject(`${builtIn}
75
- ${marker}`);
76
- }
77
- }
78
- return name;
79
- }
80
- return name;
81
- }
82
- function toAnimationShorthand(cfg) {
83
- const name = resolveAnimation(cfg);
84
- if (!cfg || !name) return null;
85
- const dur = (cfg.duration ?? 10) + "s";
86
- const delay = (cfg.delay ?? 0) + "s";
87
- const iter = cfg.iterationCount ?? "infinite";
88
- const dir = cfg.direction ?? "normal";
89
- const timing = cfg.timing ?? "linear";
90
- const fill = cfg.fillMode ?? "forwards";
91
- const play = cfg.animationPlayState ?? "running";
92
- return `${name} ${dur} ${timing} ${delay} ${iter} ${dir} ${fill} ${play}`;
93
- }
94
-
95
- // src/components/Obj.tsx
96
- var import_obj = require("./obj-PY72GEW6.css");
97
- var import_jsx_runtime = require("react/jsx-runtime");
98
- function faceTransform(name, w, h, d) {
99
- const z = d / 2;
100
- switch (name) {
101
- case "front":
102
- return `translate3d(-50%, -50%, ${z}px)`;
103
- case "back":
104
- return `translate3d(-50%, -50%, ${-z}px) rotateY(180deg)`;
105
- case "left":
106
- return `translate3d(-50%, -50%, 0) rotateY(-90deg) translateZ(${w / 2}px)`;
107
- case "right":
108
- return `translate3d(-50%, -50%, 0) rotateY(90deg) translateZ(${w / 2}px)`;
109
- case "top":
110
- return `translate3d(-50%, -50%, 0) rotateX(90deg) translateZ(${h / 2}px)`;
111
- case "bottom":
112
- return `translate3d(-50%, -50%, 0) rotateX(-90deg) translateZ(${h / 2}px)`;
113
- // legacy/extra – position near top/bottom, front/back edges
114
- case "top_front":
115
- return `translate3d(-50%, -50%, ${z / 2}px) rotateX(75deg)`;
116
- case "top_rear":
117
- return `translate3d(-50%, -50%, ${-z / 2}px) rotateX(105deg)`;
118
- case "bottom_front":
119
- return `translate3d(-50%, -50%, ${z / 2}px) rotateX(-75deg)`;
120
- case "bottom_rear":
121
- return `translate3d(-50%, -50%, ${-z / 2}px) rotateX(-105deg)`;
122
- default:
123
- return `translate3d(-50%, -50%, ${z}px)`;
124
- }
125
- }
126
- function mergeStyles(inlineCSS, style) {
127
- const out = { ...style ?? {} };
128
- if (inlineCSS) {
129
- inlineCSS.split(";").map((s) => s.trim()).filter(Boolean).forEach((rule) => {
130
- const [k, v] = rule.split(":");
131
- if (!k || !v) return;
132
- const key = k.trim().replace(/-([a-z])/g, (_, c) => c.toUpperCase());
133
- out[key] = v.trim();
134
- });
135
- }
136
- return out;
137
- }
138
- function Face({
139
- w,
140
- h,
141
- d,
142
- face,
143
- global
144
- }) {
145
- const base = (0, import_react.useMemo)(
146
- () => mergeStyles(global?.css, global?.style),
147
- [global]
148
- );
149
- const merged = (0, import_react.useMemo)(
150
- () => ({ ...base, ...mergeStyles(face.css, face.style) }),
151
- [base, face.css, face.style]
152
- );
153
- const content = face.body ?? global?.body ?? null;
154
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
155
- "div",
156
- {
157
- className: `anim3d-face ${face.className ?? ""}`,
158
- style: {
159
- transform: faceTransform(face.name, w, h, d),
160
- ...merged
161
- },
162
- "data-face": face.name,
163
- children: typeof content === "string" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: content }) : content
164
- }
165
- );
166
- }
167
4
  var Obj = ({
168
- width = 160,
169
- height = 160,
170
- depth = 150,
5
+ width = "160px",
6
+ height = "160px",
7
+ depth = "150px",
171
8
  perspective = 500,
172
9
  perspectiveOrigin = "50% 50%",
173
- faces = [
174
- { name: "front", body: "FRONT" },
175
- { name: "back", body: "BACK" },
176
- { name: "left", body: "LEFT" },
177
- { name: "right", body: "RIGHT" },
178
- { name: "top", body: "TOP" },
179
- { name: "bottom", body: "BOTTOM" }
180
- ],
181
- global,
182
- anim1,
183
- anim2,
184
- showCenterDiv = false,
10
+ rotation,
185
11
  className,
186
- style
12
+ style,
13
+ global,
14
+ children
187
15
  }) => {
188
- const resolvedAnim1 = toAnimationShorthand(anim1);
189
- const resolvedAnim2 = toAnimationShorthand(anim2);
190
- const animation = [resolvedAnim1, resolvedAnim2].filter(Boolean).join(", ");
191
- const stageStyle = {
192
- perspective: `${perspective}px`,
193
- perspectiveOrigin
194
- };
195
- const wrapperStyle = {
196
- // consumed by CSS var
197
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
198
- // @ts-ignore
199
- "--obj-w": `${width}px`,
200
- "--obj-h": `${height}px`,
201
- width,
202
- height,
203
- "animation": animation || void 0
204
- };
205
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
16
+ return /* @__PURE__ */ jsx(
206
17
  "div",
207
18
  {
208
- className: `anim3d-stage ${className ?? ""}`,
209
- style: { ...stageStyle, ...style },
210
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "anim3d-wrapper", style: wrapperStyle, children: [
211
- showCenterDiv && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "anim3d-center" }),
212
- faces.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
213
- Face,
214
- {
215
- w: width,
216
- h: height,
217
- d: depth,
218
- face: f,
219
- global
220
- },
221
- `${f.name}-${i}`
222
- ))
223
- ] })
19
+ className,
20
+ style: {
21
+ perspective,
22
+ perspectiveOrigin,
23
+ ...style
24
+ },
25
+ "data-anim-3d-obj": true,
26
+ children
224
27
  }
225
28
  );
226
29
  };
227
- var Obj_default = Obj;
228
- // Annotate the CommonJS export names for ESM import in node:
229
- 0 && (module.exports = {
230
- Obj
231
- });
30
+
31
+ export { Obj };
32
+ //# sourceMappingURL=index.js.map
232
33
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/components/Obj.tsx","../src/keyframes.ts"],"sourcesContent":["export { default as Obj } from \"./components/Obj\";\nexport type {\n ObjProps,\n FaceDef,\n GlobalDef,\n AnimationConfig,\n FaceName,\n BuiltInAnimName,\n} from \"./types\";\n","import React, { useMemo } from \"react\";\nimport type { CSSProperties, ReactNode } from \"react\";\nimport { FaceDef, GlobalDef, ObjProps, FaceName } from \"../types\";\nimport { toAnimationShorthand } from \"../keyframes\";\nimport \"../styles/obj.css\";\n\n/** Map face name -> transform so it sits on a rectangular prism */\nfunction faceTransform(name: string, w: number, h: number, d: number): string {\n const z = d / 2;\n switch (name as FaceName) {\n case \"front\":\n return `translate3d(-50%, -50%, ${z}px)`;\n case \"back\":\n return `translate3d(-50%, -50%, ${-z}px) rotateY(180deg)`;\n case \"left\":\n return `translate3d(-50%, -50%, 0) rotateY(-90deg) translateZ(${\n w / 2\n }px)`;\n case \"right\":\n return `translate3d(-50%, -50%, 0) rotateY(90deg) translateZ(${\n w / 2\n }px)`;\n case \"top\":\n return `translate3d(-50%, -50%, 0) rotateX(90deg) translateZ(${\n h / 2\n }px)`;\n case \"bottom\":\n return `translate3d(-50%, -50%, 0) rotateX(-90deg) translateZ(${\n h / 2\n }px)`;\n // legacy/extra – position near top/bottom, front/back edges\n case \"top_front\":\n return `translate3d(-50%, -50%, ${z / 2}px) rotateX(75deg)`;\n case \"top_rear\":\n return `translate3d(-50%, -50%, ${-z / 2}px) rotateX(105deg)`;\n case \"bottom_front\":\n return `translate3d(-50%, -50%, ${z / 2}px) rotateX(-75deg)`;\n case \"bottom_rear\":\n return `translate3d(-50%, -50%, ${-z / 2}px) rotateX(-105deg)`;\n default:\n return `translate3d(-50%, -50%, ${z}px)`;\n }\n}\n\n/** Merge legacy CSS string + style object */\nfunction mergeStyles(inlineCSS?: string, style?: CSSProperties): CSSProperties {\n const out: CSSProperties = { ...(style ?? {}) };\n if (inlineCSS) {\n // naive parser: split by ;, then key:value\n inlineCSS\n .split(\";\")\n .map((s) => s.trim())\n .filter(Boolean)\n .forEach((rule) => {\n const [k, v] = rule.split(\":\");\n if (!k || !v) return;\n const key = k\n .trim()\n .replace(/-([a-z])/g, (_, c) => c.toUpperCase());\n (out as any)[key] = v.trim();\n });\n }\n return out;\n}\n\nfunction Face({\n w,\n h,\n d,\n face,\n global,\n}: {\n w: number;\n h: number;\n d: number;\n face: FaceDef;\n global?: GlobalDef;\n}) {\n const base = useMemo(\n () => mergeStyles(global?.css, global?.style),\n [global]\n );\n const merged = useMemo(\n () => ({ ...base, ...mergeStyles(face.css, face.style) }),\n [base, face.css, face.style]\n );\n\n const content: ReactNode = face.body ?? global?.body ?? null;\n\n return (\n <div\n className={`anim3d-face ${face.className ?? \"\"}`}\n style={{\n transform: faceTransform(face.name, w, h, d),\n ...merged,\n }}\n data-face={face.name}\n >\n {typeof content === \"string\" ? <span>{content}</span> : content}\n </div>\n );\n}\n\nconst Obj: React.FC<ObjProps> = ({\n width = 160,\n height = 160,\n depth = 150,\n perspective = 500,\n perspectiveOrigin = \"50% 50%\",\n faces = [\n { name: \"front\", body: \"FRONT\" },\n { name: \"back\", body: \"BACK\" },\n { name: \"left\", body: \"LEFT\" },\n { name: \"right\", body: \"RIGHT\" },\n { name: \"top\", body: \"TOP\" },\n { name: \"bottom\", body: \"BOTTOM\" },\n ],\n global,\n anim1,\n anim2,\n showCenterDiv = false,\n className,\n style,\n}) => {\n const resolvedAnim1 = toAnimationShorthand(anim1);\n const resolvedAnim2 = toAnimationShorthand(anim2);\n const animation = [resolvedAnim1, resolvedAnim2].filter(Boolean).join(\", \");\n\n const stageStyle: CSSProperties = {\n perspective: `${perspective}px`,\n perspectiveOrigin,\n };\n\n const wrapperStyle: CSSProperties = {\n // consumed by CSS var\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n \"--obj-w\": `${width}px`,\n \"--obj-h\": `${height}px`,\n width,\n height,\n \"animation\": animation || undefined,\n };\n\n return (\n <div\n className={`anim3d-stage ${className ?? \"\"}`}\n style={{ ...stageStyle, ...style }}\n >\n <div className='anim3d-wrapper' style={wrapperStyle as any}>\n {showCenterDiv && <div className='anim3d-center' />}\n {faces.map((f, i) => (\n <Face\n key={`${f.name}-${i}`}\n w={width}\n h={height}\n d={depth}\n face={f}\n global={global}\n />\n ))}\n </div>\n </div>\n );\n};\n\nexport default Obj;\nexport { Obj };\n","import type { AnimationConfig } from \"./types\";\n\nlet counter = 0;\nconst uid = () => (++counter).toString(36);\n\n/** Create (or reuse) a <style> tag for dynamic keyframes */\nfunction ensureStyleTag(): HTMLStyleElement {\n let tag = document.getElementById(\n \"anim3d-keyframes\"\n ) as HTMLStyleElement | null;\n if (!tag) {\n tag = document.createElement(\"style\");\n tag.id = \"anim3d-keyframes\";\n document.head.appendChild(tag);\n }\n return tag;\n}\n\nfunction inject(css: string) {\n if (typeof document === \"undefined\") return; // SSR\n const tag = ensureStyleTag();\n tag.appendChild(document.createTextNode(css));\n}\n\n/** Keyframes text for built-ins */\nfunction builtInKeyframes(name: string, cfg: AnimationConfig) {\n const hi = cfg.degreesHi ?? 15;\n const lo = cfg.degreesLow ?? -15;\n switch (name) {\n case \"Y360\":\n return `@keyframes Y360 { from { transform: rotateY(0deg) } to { transform: rotateY(360deg) } }`;\n case \"X360\":\n return `@keyframes X360 { from { transform: rotateX(0deg) } to { transform: rotateX(360deg) } }`;\n case \"Z360\":\n return `@keyframes Z360 { from { transform: rotateZ(0deg) } to { transform: rotateZ(360deg) } }`;\n case \"rockY\":\n return `@keyframes rockY { 0%{ transform: rotateY(${lo}deg) } 50%{ transform: rotateY(${hi}deg) } 100%{ transform: rotateY(${lo}deg) } }`;\n case \"rockX\":\n return `@keyframes rockX { 0%{ transform: rotateX(${lo}deg) } 50%{ transform: rotateX(${hi}deg) } 100%{ transform: rotateX(${lo}deg) } }`;\n default:\n // Custom names: let authors supply their own @keyframes in global CSS with that name.\n return \"\";\n }\n}\n\n/** Returns a concrete animation-name and ensures keyframes exist (for built-ins) */\nexport function resolveAnimation(cfg?: AnimationConfig): string | null {\n if (!cfg) return null;\n const name = cfg.name;\n const builtIn = builtInKeyframes(name, cfg);\n if (builtIn) {\n // Ensure single injection per built-in name\n const marker = `/*kf-${name}*/`;\n if (typeof document !== \"undefined\") {\n const tag = ensureStyleTag();\n if (!tag.innerHTML.includes(marker)) {\n inject(`${builtIn}\\n${marker}`);\n }\n }\n return name; // use built-in name as animation-name\n }\n // custom: use author-provided @keyframes by name\n return name;\n}\n\n/** Build the full CSS animation shorthand from a config and resolved name */\nexport function toAnimationShorthand(cfg?: AnimationConfig): string | null {\n const name = resolveAnimation(cfg);\n if (!cfg || !name) return null;\n const dur = (cfg.duration ?? 10) + \"s\";\n const delay = (cfg.delay ?? 0) + \"s\";\n const iter = cfg.iterationCount ?? \"infinite\";\n const dir = cfg.direction ?? \"normal\";\n const timing = cfg.timing ?? \"linear\";\n const fill = cfg.fillMode ?? \"forwards\";\n const play = cfg.animationPlayState ?? \"running\";\n // name duration timing delay iteration-count direction fill-mode play-state\n return `${name} ${dur} ${timing} ${delay} ${iter} ${dir} ${fill} ${play}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA+B;;;ACM/B,SAAS,iBAAmC;AACzC,MAAI,MAAM,SAAS;AAAA,IAChB;AAAA,EACH;AACA,MAAI,CAAC,KAAK;AACP,UAAM,SAAS,cAAc,OAAO;AACpC,QAAI,KAAK;AACT,aAAS,KAAK,YAAY,GAAG;AAAA,EAChC;AACA,SAAO;AACV;AAEA,SAAS,OAAO,KAAa;AAC1B,MAAI,OAAO,aAAa,YAAa;AACrC,QAAM,MAAM,eAAe;AAC3B,MAAI,YAAY,SAAS,eAAe,GAAG,CAAC;AAC/C;AAGA,SAAS,iBAAiB,MAAc,KAAsB;AAC3D,QAAM,KAAK,IAAI,aAAa;AAC5B,QAAM,KAAK,IAAI,cAAc;AAC7B,UAAQ,MAAM;AAAA,IACX,KAAK;AACF,aAAO;AAAA,IACV,KAAK;AACF,aAAO;AAAA,IACV,KAAK;AACF,aAAO;AAAA,IACV,KAAK;AACF,aAAO,6CAA6C,EAAE,kCAAkC,EAAE,mCAAmC,EAAE;AAAA,IAClI,KAAK;AACF,aAAO,6CAA6C,EAAE,kCAAkC,EAAE,mCAAmC,EAAE;AAAA,IAClI;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OAAO,cACnC;AAAA,yBAAiB,4CAAC,SAAI,WAAU,iBAAgB;AAAA,QAChD,MAAM,IAAI,CAAC,GAAG,MACZ;AAAA,UAAC;AAAA;AAAA,YAEE,GAAG;AAAA,YACH,GAAG;AAAA,YACH,GAAG;AAAA,YACH,MAAM;AAAA,YACN;AAAA;AAAA,UALK,GAAG,EAAE,IAAI,IAAI,CAAC;AAAA,QAMtB,CACF;AAAA,SACJ;AAAA;AAAA,EACH;AAEN;AAEA,IAAO,cAAQ;","names":[]}
1
+ {"version":3,"sources":["../src/components/Obj.tsx"],"names":[],"mappings":";;;AAmBO,IAAM,MAA0B,CAAC;AAAA,EACrC,KAAA,GAAQ,OAAA;AAAA,EACR,MAAA,GAAS,OAAA;AAAA,EACT,KAAA,GAAQ,OAAA;AAAA,EACR,WAAA,GAAc,GAAA;AAAA,EACd,iBAAA,GAAoB,SAAA;AAAA,EACpB,QAAA;AAAA,EACA,SAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA;AACH,CAAA,KAAM;AAEH,EAAA,uBACG,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACE,SAAA;AAAA,MACA,KAAA,EAAO;AAAA,QACJ,WAAA;AAAA,QACA,iBAAA;AAAA,QACA,GAAG;AAAA,OACN;AAAA,MACA,kBAAA,EAAgB,IAAA;AAAA,MAGf;AAAA;AAAA,GACJ;AAEN","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport \"./../styles/obj.css\";\n\nexport type ObjProps = {\n width?: string | number;\n height?: string | number;\n depth?: string | number;\n perspective?: string | number;\n perspectiveOrigin?: string;\n rotation?: string; // e.g., \"x 1s linear infinite\"\n className?: string;\n style?: React.CSSProperties;\n global?: {\n css?: string;\n body?: string;\n };\n children?: React.ReactNode;\n};\n\nexport const Obj: React.FC<ObjProps> = ({\n width = \"160px\",\n height = \"160px\",\n depth = \"150px\",\n perspective = 500,\n perspectiveOrigin = \"50% 50%\",\n rotation,\n className,\n style,\n global,\n children,\n}) => {\n // … your existing DOM/CSS 3D layout & animations\n return (\n <div\n className={className}\n style={{\n perspective,\n perspectiveOrigin,\n ...style,\n }}\n data-anim-3d-obj\n >\n {/* faces, wrappers, animations… */}\n {children}\n </div>\n );\n};\n"]}