anim-3d-obj 1.2.9 → 2.0.0

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.
Files changed (47) hide show
  1. package/README.md +7 -103
  2. package/dist/components/Obj.d.mts +50 -0
  3. package/dist/components/Obj.d.ts +50 -0
  4. package/dist/components/Obj.js +231 -0
  5. package/dist/components/Obj.js.map +1 -0
  6. package/dist/components/Obj.mjs +206 -0
  7. package/dist/components/Obj.mjs.map +1 -0
  8. package/dist/index.d.mts +2 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +232 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/index.mjs +205 -0
  13. package/dist/index.mjs.map +1 -0
  14. package/dist/obj-PY72GEW6.css +39 -0
  15. package/package.json +35 -38
  16. package/dist/cjs/components/Face.d.ts +0 -11
  17. package/dist/cjs/components/Face.js +0 -107
  18. package/dist/cjs/components/Obj.d.ts +0 -2
  19. package/dist/cjs/components/Obj.js +0 -31
  20. package/dist/cjs/components/index.d.ts +0 -2
  21. package/dist/cjs/components/index.js +0 -18
  22. package/dist/cjs/components/styles/AnimWrap.d.ts +0 -2
  23. package/dist/cjs/components/styles/AnimWrap.js +0 -90
  24. package/dist/cjs/components/styles/Anims.d.ts +0 -32
  25. package/dist/cjs/components/styles/Anims.js +0 -329
  26. package/dist/cjs/components/styles/Global.d.ts +0 -6
  27. package/dist/cjs/components/styles/Global.js +0 -27
  28. package/dist/cjs/components/styles/Scene.d.ts +0 -10
  29. package/dist/cjs/components/styles/Scene.js +0 -22
  30. package/dist/cjs/index.d.ts +0 -1
  31. package/dist/cjs/index.js +0 -17
  32. package/dist/esm/components/Face.d.ts +0 -11
  33. package/dist/esm/components/Face.js +0 -101
  34. package/dist/esm/components/Obj.d.ts +0 -2
  35. package/dist/esm/components/Obj.js +0 -25
  36. package/dist/esm/components/index.d.ts +0 -2
  37. package/dist/esm/components/index.js +0 -2
  38. package/dist/esm/components/styles/AnimWrap.d.ts +0 -2
  39. package/dist/esm/components/styles/AnimWrap.js +0 -83
  40. package/dist/esm/components/styles/Anims.d.ts +0 -32
  41. package/dist/esm/components/styles/Anims.js +0 -325
  42. package/dist/esm/components/styles/Global.d.ts +0 -6
  43. package/dist/esm/components/styles/Global.js +0 -20
  44. package/dist/esm/components/styles/Scene.d.ts +0 -10
  45. package/dist/esm/components/styles/Scene.js +0 -15
  46. package/dist/esm/index.d.ts +0 -1
  47. package/dist/esm/index.js +0 -1
package/README.md CHANGED
@@ -1,107 +1,11 @@
1
- # React Typescript Cuboid Builder
1
+ # anim-3d-obj
2
2
 
3
- This project allows a user to create Cuboids of any size simply by entering a set of parameters.
4
- The program does the leg work with regard to calculating translationZ depth and config on the fly.
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.
5
4
 
6
- ## Examples
5
+ ## Install
7
6
 
8
- - [6 sided Cuboid - animate X360 Y360](https://codesandbox.io/s/anim-3d-obj-all-sides-simple-bf67yg-tzr2v6)
9
- - [3 sided Object - animate y-axis](https://codesandbox.io/s/anim-3d-obj-3-sides-wobble-y-axis-wglkms)
10
- - [Double box spin](https://codesandbox.io/s/react-anim-3d-double-box-spin-vbdhg2)
11
- - [Floating Ribbon](https://codesandbox.io/s/cocky-butterfly-ygwkps)
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
-
15
- `** ANIMATIONS`
16
-
17
- - `fadeInkf`: fade object in from 0 to 1 Opacity: [demo](https://codesandbox.io/s/anim-3d-obj-fadeinkf-1fozww)
18
- - `floatX`: float object so is not stationary: [demo](https://codesandbox.io/s/anim-3d-obj-floatx-hzeo42)
19
- - `floatShadow`: float object + add shadow: [demo](https://codesandbox.io/s/anim-3d-obj-floatshadow-8pp5k0)
20
- - `pulseSM`: pulse object Small: [demo](https://codesandbox.io/s/anim-3d-obj-pulsesm-k2rjb6)
21
- - `pulseMD`: pulse object Medium: [demo](https://codesandbox.io/s/anim-3d-obj-pulsemd-sqk2of)
22
- - `pulseLG`: pulse object Large: [demo](https://codesandbox.io/s/anim-3d-obj-pulselg-qz7x0m)
23
- - `swing`: Swing component: [demo](https://codesandbox.io/s/anim-3d-obj-swing-snj8li)
24
- - `swingDecay`: Swing component with decay: [demo](https://codesandbox.io/s/anim-3d-obj-swingdecay-cku0e1)
25
- - `noAnim`: no animation place holder
26
-
27
- `X-AXIS Animations`
28
- - `X360`: rotate 360 degrees on the x-axis: [demo](https://codesandbox.io/s/anim-3d-obj-x360-7kiuhw)
29
- - `wobX`: wobble on x-axis (degreesHi <-> degreesLow): [demo](https://codesandbox.io/s/anim-3d-obj-wobx-ldwek7)
30
- - `fwdx018`: spin object on x-axis from 0 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwd180-v90xyu)
31
- - `fwdx1836`: spin object on x-axis from 180 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwd1836-mtwuv9)
32
- - `fwdx09`: spin object on x-axis from 0 degrees to 90 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwd09-84vocn)
33
- - `fwdx918`: spin object on x-axis from 90 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwd918-6039fj)
34
- - `fwdx1827`: spin object on x-axis from 180 degrees to 270 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdx1827-qpqhtq)
35
- - `fwdx2736`: spin object on x-axis from 270 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdx2736-e6c6wg)
36
-
37
- `Y-AXIS Animations`
38
- - `Y360`: rotate 360 degrees on the y-axis: [demo](https://codesandbox.io/s/anim-3d-obj-y360-16lzeb)
39
- - `wobY`: wobble on y-axis (degreesHi <-> degreesLow): [demo](https://codesandbox.io/s/anim-3d-obj-woby-tkoxms)
40
- - `fwdy018`: spin object on y-axis from 0 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy180-qpqhtq)
41
- - `fwdy1836`: spin object on y-axis from 180 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy1836-qpqhtq)
42
- - `fwdy09`: spin object on y-axis from 0 degrees to 90 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy09-elklgr)
43
- - `fwdy918`: spin object on y-axis from 90 degrees to 180 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy918-gnym88)
44
- - `fwdy1827`: spin object on y-axis from 180 degrees to 270 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy1827-osskgx)
45
- - `fwdy2736`: spin object on y-axis from 270 degrees to 360 degrees: [demo](https://codesandbox.io/s/anim-3d-obj-fwdy2736-rnbs2q)
46
-
47
-
48
- ## Config
49
- ### Animations:
50
-
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.
52
-
53
- ```typescript
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
65
- };
7
+ ```bash
8
+ npm i anim-3d-obj
9
+ # or
10
+ yarn add anim-3d-obj
66
11
  ```
67
-
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)`,
82
- },
83
- {
84
- name: "right",
85
- body: "RIGHT",
86
- css: `background:rgba(220,220,220,.5);
87
- border:1px solid #ddd`,
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
- };
103
- ```
104
-
105
- ![all sides](https://github.com/mdnelles/anim-3d-obj-npm-publisher/blob/4a9769a6386a3b5425ede9a04b346d5461051ae0/ang1.png?raw=true)
106
-
107
- - https://www.npmjs.com/package/anim-3d-obj
@@ -0,0 +1,50 @@
1
+ import React, { CSSProperties, ReactNode } from 'react';
2
+
3
+ type AnimationDirection = "normal" | "reverse" | "alternate" | "alternate-reverse";
4
+ type AnimationFill = "none" | "forwards" | "backwards" | "both";
5
+ type AnimationPlayState = "running" | "paused";
6
+ type TimingFn = "linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out" | string;
7
+ type BuiltInAnimName = "Y360" | "X360" | "Z360" | "rockY" | "rockX";
8
+ type AnimationConfig = {
9
+ name: BuiltInAnimName | string;
10
+ degreesHi?: number;
11
+ degreesLow?: number;
12
+ duration?: number;
13
+ delay?: number;
14
+ iterationCount?: number | "infinite";
15
+ direction?: AnimationDirection;
16
+ timing?: TimingFn;
17
+ fillMode?: AnimationFill;
18
+ animationPlayState?: AnimationPlayState;
19
+ };
20
+ type FaceName = "front" | "back" | "left" | "right" | "top" | "bottom" | "top_rear" | "top_front" | "bottom_rear" | "bottom_front";
21
+ type FaceDef = {
22
+ name: FaceName | string;
23
+ css?: string;
24
+ style?: CSSProperties;
25
+ body?: ReactNode | string;
26
+ className?: string;
27
+ };
28
+ type GlobalDef = {
29
+ css?: string;
30
+ style?: CSSProperties;
31
+ body?: ReactNode | string;
32
+ };
33
+ type ObjProps = {
34
+ width?: number;
35
+ height?: number;
36
+ depth?: number;
37
+ perspective?: number;
38
+ perspectiveOrigin?: string;
39
+ faces?: FaceDef[];
40
+ global?: GlobalDef;
41
+ anim1?: AnimationConfig;
42
+ anim2?: AnimationConfig;
43
+ showCenterDiv?: boolean;
44
+ className?: string;
45
+ style?: CSSProperties;
46
+ };
47
+
48
+ declare const Obj: React.FC<ObjProps>;
49
+
50
+ export { type AnimationConfig as A, type BuiltInAnimName as B, type FaceDef as F, type GlobalDef as G, type ObjProps as O, Obj, type FaceName as a, Obj as default };
@@ -0,0 +1,50 @@
1
+ import React, { CSSProperties, ReactNode } from 'react';
2
+
3
+ type AnimationDirection = "normal" | "reverse" | "alternate" | "alternate-reverse";
4
+ type AnimationFill = "none" | "forwards" | "backwards" | "both";
5
+ type AnimationPlayState = "running" | "paused";
6
+ type TimingFn = "linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out" | string;
7
+ type BuiltInAnimName = "Y360" | "X360" | "Z360" | "rockY" | "rockX";
8
+ type AnimationConfig = {
9
+ name: BuiltInAnimName | string;
10
+ degreesHi?: number;
11
+ degreesLow?: number;
12
+ duration?: number;
13
+ delay?: number;
14
+ iterationCount?: number | "infinite";
15
+ direction?: AnimationDirection;
16
+ timing?: TimingFn;
17
+ fillMode?: AnimationFill;
18
+ animationPlayState?: AnimationPlayState;
19
+ };
20
+ type FaceName = "front" | "back" | "left" | "right" | "top" | "bottom" | "top_rear" | "top_front" | "bottom_rear" | "bottom_front";
21
+ type FaceDef = {
22
+ name: FaceName | string;
23
+ css?: string;
24
+ style?: CSSProperties;
25
+ body?: ReactNode | string;
26
+ className?: string;
27
+ };
28
+ type GlobalDef = {
29
+ css?: string;
30
+ style?: CSSProperties;
31
+ body?: ReactNode | string;
32
+ };
33
+ type ObjProps = {
34
+ width?: number;
35
+ height?: number;
36
+ depth?: number;
37
+ perspective?: number;
38
+ perspectiveOrigin?: string;
39
+ faces?: FaceDef[];
40
+ global?: GlobalDef;
41
+ anim1?: AnimationConfig;
42
+ anim2?: AnimationConfig;
43
+ showCenterDiv?: boolean;
44
+ className?: string;
45
+ style?: CSSProperties;
46
+ };
47
+
48
+ declare const Obj: React.FC<ObjProps>;
49
+
50
+ export { type AnimationConfig as A, type BuiltInAnimName as B, type FaceDef as F, type GlobalDef as G, type ObjProps as O, Obj, type FaceName as a, Obj as default };
@@ -0,0 +1,231 @@
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/components/Obj.tsx
21
+ var Obj_exports = {};
22
+ __export(Obj_exports, {
23
+ Obj: () => Obj,
24
+ default: () => Obj_default
25
+ });
26
+ module.exports = __toCommonJS(Obj_exports);
27
+ var import_react = require("react");
28
+
29
+ // src/keyframes.ts
30
+ function ensureStyleTag() {
31
+ let tag = document.getElementById(
32
+ "anim3d-keyframes"
33
+ );
34
+ if (!tag) {
35
+ tag = document.createElement("style");
36
+ tag.id = "anim3d-keyframes";
37
+ document.head.appendChild(tag);
38
+ }
39
+ return tag;
40
+ }
41
+ function inject(css) {
42
+ if (typeof document === "undefined") return;
43
+ const tag = ensureStyleTag();
44
+ tag.appendChild(document.createTextNode(css));
45
+ }
46
+ function builtInKeyframes(name, cfg) {
47
+ const hi = cfg.degreesHi ?? 15;
48
+ const lo = cfg.degreesLow ?? -15;
49
+ switch (name) {
50
+ case "Y360":
51
+ return `@keyframes Y360 { from { transform: rotateY(0deg) } to { transform: rotateY(360deg) } }`;
52
+ case "X360":
53
+ return `@keyframes X360 { from { transform: rotateX(0deg) } to { transform: rotateX(360deg) } }`;
54
+ case "Z360":
55
+ return `@keyframes Z360 { from { transform: rotateZ(0deg) } to { transform: rotateZ(360deg) } }`;
56
+ case "rockY":
57
+ return `@keyframes rockY { 0%{ transform: rotateY(${lo}deg) } 50%{ transform: rotateY(${hi}deg) } 100%{ transform: rotateY(${lo}deg) } }`;
58
+ case "rockX":
59
+ return `@keyframes rockX { 0%{ transform: rotateX(${lo}deg) } 50%{ transform: rotateX(${hi}deg) } 100%{ transform: rotateX(${lo}deg) } }`;
60
+ default:
61
+ return "";
62
+ }
63
+ }
64
+ function resolveAnimation(cfg) {
65
+ if (!cfg) return null;
66
+ const name = cfg.name;
67
+ const builtIn = builtInKeyframes(name, cfg);
68
+ if (builtIn) {
69
+ const marker = `/*kf-${name}*/`;
70
+ if (typeof document !== "undefined") {
71
+ const tag = ensureStyleTag();
72
+ if (!tag.innerHTML.includes(marker)) {
73
+ inject(`${builtIn}
74
+ ${marker}`);
75
+ }
76
+ }
77
+ return name;
78
+ }
79
+ return name;
80
+ }
81
+ function toAnimationShorthand(cfg) {
82
+ const name = resolveAnimation(cfg);
83
+ if (!cfg || !name) return null;
84
+ const dur = (cfg.duration ?? 10) + "s";
85
+ const delay = (cfg.delay ?? 0) + "s";
86
+ const iter = cfg.iterationCount ?? "infinite";
87
+ const dir = cfg.direction ?? "normal";
88
+ const timing = cfg.timing ?? "linear";
89
+ const fill = cfg.fillMode ?? "forwards";
90
+ const play = cfg.animationPlayState ?? "running";
91
+ return `${name} ${dur} ${timing} ${delay} ${iter} ${dir} ${fill} ${play}`;
92
+ }
93
+
94
+ // src/components/Obj.tsx
95
+ var import_obj = require("../obj-PY72GEW6.css");
96
+ var import_jsx_runtime = require("react/jsx-runtime");
97
+ function faceTransform(name, w, h, d) {
98
+ const z = d / 2;
99
+ switch (name) {
100
+ case "front":
101
+ return `translate3d(-50%, -50%, ${z}px)`;
102
+ case "back":
103
+ return `translate3d(-50%, -50%, ${-z}px) rotateY(180deg)`;
104
+ case "left":
105
+ return `translate3d(-50%, -50%, 0) rotateY(-90deg) translateZ(${w / 2}px)`;
106
+ case "right":
107
+ return `translate3d(-50%, -50%, 0) rotateY(90deg) translateZ(${w / 2}px)`;
108
+ case "top":
109
+ return `translate3d(-50%, -50%, 0) rotateX(90deg) translateZ(${h / 2}px)`;
110
+ case "bottom":
111
+ return `translate3d(-50%, -50%, 0) rotateX(-90deg) translateZ(${h / 2}px)`;
112
+ // legacy/extra – position near top/bottom, front/back edges
113
+ case "top_front":
114
+ return `translate3d(-50%, -50%, ${z / 2}px) rotateX(75deg)`;
115
+ case "top_rear":
116
+ return `translate3d(-50%, -50%, ${-z / 2}px) rotateX(105deg)`;
117
+ case "bottom_front":
118
+ return `translate3d(-50%, -50%, ${z / 2}px) rotateX(-75deg)`;
119
+ case "bottom_rear":
120
+ return `translate3d(-50%, -50%, ${-z / 2}px) rotateX(-105deg)`;
121
+ default:
122
+ return `translate3d(-50%, -50%, ${z}px)`;
123
+ }
124
+ }
125
+ function mergeStyles(inlineCSS, style) {
126
+ const out = { ...style ?? {} };
127
+ if (inlineCSS) {
128
+ inlineCSS.split(";").map((s) => s.trim()).filter(Boolean).forEach((rule) => {
129
+ const [k, v] = rule.split(":");
130
+ if (!k || !v) return;
131
+ const key = k.trim().replace(/-([a-z])/g, (_, c) => c.toUpperCase());
132
+ out[key] = v.trim();
133
+ });
134
+ }
135
+ return out;
136
+ }
137
+ function Face({
138
+ w,
139
+ h,
140
+ d,
141
+ face,
142
+ global
143
+ }) {
144
+ const base = (0, import_react.useMemo)(
145
+ () => mergeStyles(global?.css, global?.style),
146
+ [global]
147
+ );
148
+ const merged = (0, import_react.useMemo)(
149
+ () => ({ ...base, ...mergeStyles(face.css, face.style) }),
150
+ [base, face.css, face.style]
151
+ );
152
+ const content = face.body ?? global?.body ?? null;
153
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
154
+ "div",
155
+ {
156
+ className: `anim3d-face ${face.className ?? ""}`,
157
+ style: {
158
+ transform: faceTransform(face.name, w, h, d),
159
+ ...merged
160
+ },
161
+ "data-face": face.name,
162
+ children: typeof content === "string" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: content }) : content
163
+ }
164
+ );
165
+ }
166
+ var Obj = ({
167
+ width = 160,
168
+ height = 160,
169
+ depth = 150,
170
+ perspective = 500,
171
+ perspectiveOrigin = "50% 50%",
172
+ faces = [
173
+ { name: "front", body: "FRONT" },
174
+ { name: "back", body: "BACK" },
175
+ { name: "left", body: "LEFT" },
176
+ { name: "right", body: "RIGHT" },
177
+ { name: "top", body: "TOP" },
178
+ { name: "bottom", body: "BOTTOM" }
179
+ ],
180
+ global,
181
+ anim1,
182
+ anim2,
183
+ showCenterDiv = false,
184
+ className,
185
+ style
186
+ }) => {
187
+ const resolvedAnim1 = toAnimationShorthand(anim1);
188
+ const resolvedAnim2 = toAnimationShorthand(anim2);
189
+ const animation = [resolvedAnim1, resolvedAnim2].filter(Boolean).join(", ");
190
+ const stageStyle = {
191
+ perspective: `${perspective}px`,
192
+ perspectiveOrigin
193
+ };
194
+ const wrapperStyle = {
195
+ // consumed by CSS var
196
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
197
+ // @ts-ignore
198
+ "--obj-w": `${width}px`,
199
+ "--obj-h": `${height}px`,
200
+ width,
201
+ height,
202
+ "animation": animation || void 0
203
+ };
204
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
205
+ "div",
206
+ {
207
+ className: `anim3d-stage ${className ?? ""}`,
208
+ style: { ...stageStyle, ...style },
209
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "anim3d-wrapper", style: wrapperStyle, children: [
210
+ showCenterDiv && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "anim3d-center" }),
211
+ faces.map((f, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
212
+ Face,
213
+ {
214
+ w: width,
215
+ h: height,
216
+ d: depth,
217
+ face: f,
218
+ global
219
+ },
220
+ `${f.name}-${i}`
221
+ ))
222
+ ] })
223
+ }
224
+ );
225
+ };
226
+ var Obj_default = Obj;
227
+ // Annotate the CommonJS export names for ESM import in node:
228
+ 0 && (module.exports = {
229
+ Obj
230
+ });
231
+ //# sourceMappingURL=Obj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/Obj.tsx","../../src/keyframes.ts"],"sourcesContent":["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;AAAA;AAAA,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;A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ChD,QAAM,YAAY,CAAC,eAAe,aAAa,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AAE1E,QAAM,aAA4B;AAAA,IAC/B,aAAa,GAAG,WAAW;AAAA,IAC3B;AAAA,EACH;AAEA,QAAM,eAA8B;AAAA;AAAA;AAAA;AAAA,IAIjC,WAAW,GAAG,KAAK;AAAA,IACnB,WAAW,GAAG,MAAM;AAAA,IACpB;AAAA,IACA;AAAA,IACA,aAAa,aAAa;AAAA,EAC7B;AAEA,SACG;AAAA,IAAC;AAAA;AAAA,MACE,WAAW,gBAAgB,aAAa,EAAE;AAAA,MAC1C,OAAO,EAAE,GAAG,YAAY,GAAG,MAAM;AAAA,MAEjC,uDAAC,SAAI,WAAU,kBAAiB,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":[]}
@@ -0,0 +1,206 @@
1
+ // src/components/Obj.tsx
2
+ import { useMemo } from "react";
3
+
4
+ // src/keyframes.ts
5
+ function ensureStyleTag() {
6
+ let tag = document.getElementById(
7
+ "anim3d-keyframes"
8
+ );
9
+ if (!tag) {
10
+ tag = document.createElement("style");
11
+ tag.id = "anim3d-keyframes";
12
+ document.head.appendChild(tag);
13
+ }
14
+ return tag;
15
+ }
16
+ function inject(css) {
17
+ if (typeof document === "undefined") return;
18
+ const tag = ensureStyleTag();
19
+ tag.appendChild(document.createTextNode(css));
20
+ }
21
+ function builtInKeyframes(name, cfg) {
22
+ const hi = cfg.degreesHi ?? 15;
23
+ const lo = cfg.degreesLow ?? -15;
24
+ switch (name) {
25
+ case "Y360":
26
+ return `@keyframes Y360 { from { transform: rotateY(0deg) } to { transform: rotateY(360deg) } }`;
27
+ case "X360":
28
+ return `@keyframes X360 { from { transform: rotateX(0deg) } to { transform: rotateX(360deg) } }`;
29
+ case "Z360":
30
+ return `@keyframes Z360 { from { transform: rotateZ(0deg) } to { transform: rotateZ(360deg) } }`;
31
+ case "rockY":
32
+ return `@keyframes rockY { 0%{ transform: rotateY(${lo}deg) } 50%{ transform: rotateY(${hi}deg) } 100%{ transform: rotateY(${lo}deg) } }`;
33
+ case "rockX":
34
+ return `@keyframes rockX { 0%{ transform: rotateX(${lo}deg) } 50%{ transform: rotateX(${hi}deg) } 100%{ transform: rotateX(${lo}deg) } }`;
35
+ default:
36
+ return "";
37
+ }
38
+ }
39
+ function resolveAnimation(cfg) {
40
+ if (!cfg) return null;
41
+ const name = cfg.name;
42
+ const builtIn = builtInKeyframes(name, cfg);
43
+ if (builtIn) {
44
+ const marker = `/*kf-${name}*/`;
45
+ if (typeof document !== "undefined") {
46
+ const tag = ensureStyleTag();
47
+ if (!tag.innerHTML.includes(marker)) {
48
+ inject(`${builtIn}
49
+ ${marker}`);
50
+ }
51
+ }
52
+ return name;
53
+ }
54
+ return name;
55
+ }
56
+ function toAnimationShorthand(cfg) {
57
+ const name = resolveAnimation(cfg);
58
+ if (!cfg || !name) return null;
59
+ const dur = (cfg.duration ?? 10) + "s";
60
+ const delay = (cfg.delay ?? 0) + "s";
61
+ const iter = cfg.iterationCount ?? "infinite";
62
+ const dir = cfg.direction ?? "normal";
63
+ const timing = cfg.timing ?? "linear";
64
+ const fill = cfg.fillMode ?? "forwards";
65
+ const play = cfg.animationPlayState ?? "running";
66
+ return `${name} ${dur} ${timing} ${delay} ${iter} ${dir} ${fill} ${play}`;
67
+ }
68
+
69
+ // src/components/Obj.tsx
70
+ import "../obj-PY72GEW6.css";
71
+ import { jsx, jsxs } from "react/jsx-runtime";
72
+ function faceTransform(name, w, h, d) {
73
+ const z = d / 2;
74
+ switch (name) {
75
+ case "front":
76
+ return `translate3d(-50%, -50%, ${z}px)`;
77
+ case "back":
78
+ return `translate3d(-50%, -50%, ${-z}px) rotateY(180deg)`;
79
+ case "left":
80
+ return `translate3d(-50%, -50%, 0) rotateY(-90deg) translateZ(${w / 2}px)`;
81
+ case "right":
82
+ return `translate3d(-50%, -50%, 0) rotateY(90deg) translateZ(${w / 2}px)`;
83
+ case "top":
84
+ return `translate3d(-50%, -50%, 0) rotateX(90deg) translateZ(${h / 2}px)`;
85
+ case "bottom":
86
+ return `translate3d(-50%, -50%, 0) rotateX(-90deg) translateZ(${h / 2}px)`;
87
+ // legacy/extra – position near top/bottom, front/back edges
88
+ case "top_front":
89
+ return `translate3d(-50%, -50%, ${z / 2}px) rotateX(75deg)`;
90
+ case "top_rear":
91
+ return `translate3d(-50%, -50%, ${-z / 2}px) rotateX(105deg)`;
92
+ case "bottom_front":
93
+ return `translate3d(-50%, -50%, ${z / 2}px) rotateX(-75deg)`;
94
+ case "bottom_rear":
95
+ return `translate3d(-50%, -50%, ${-z / 2}px) rotateX(-105deg)`;
96
+ default:
97
+ return `translate3d(-50%, -50%, ${z}px)`;
98
+ }
99
+ }
100
+ function mergeStyles(inlineCSS, style) {
101
+ const out = { ...style ?? {} };
102
+ if (inlineCSS) {
103
+ inlineCSS.split(";").map((s) => s.trim()).filter(Boolean).forEach((rule) => {
104
+ const [k, v] = rule.split(":");
105
+ if (!k || !v) return;
106
+ const key = k.trim().replace(/-([a-z])/g, (_, c) => c.toUpperCase());
107
+ out[key] = v.trim();
108
+ });
109
+ }
110
+ return out;
111
+ }
112
+ function Face({
113
+ w,
114
+ h,
115
+ d,
116
+ face,
117
+ global
118
+ }) {
119
+ const base = useMemo(
120
+ () => mergeStyles(global?.css, global?.style),
121
+ [global]
122
+ );
123
+ const merged = useMemo(
124
+ () => ({ ...base, ...mergeStyles(face.css, face.style) }),
125
+ [base, face.css, face.style]
126
+ );
127
+ const content = face.body ?? global?.body ?? null;
128
+ return /* @__PURE__ */ jsx(
129
+ "div",
130
+ {
131
+ className: `anim3d-face ${face.className ?? ""}`,
132
+ style: {
133
+ transform: faceTransform(face.name, w, h, d),
134
+ ...merged
135
+ },
136
+ "data-face": face.name,
137
+ children: typeof content === "string" ? /* @__PURE__ */ jsx("span", { children: content }) : content
138
+ }
139
+ );
140
+ }
141
+ var Obj = ({
142
+ width = 160,
143
+ height = 160,
144
+ depth = 150,
145
+ perspective = 500,
146
+ perspectiveOrigin = "50% 50%",
147
+ faces = [
148
+ { name: "front", body: "FRONT" },
149
+ { name: "back", body: "BACK" },
150
+ { name: "left", body: "LEFT" },
151
+ { name: "right", body: "RIGHT" },
152
+ { name: "top", body: "TOP" },
153
+ { name: "bottom", body: "BOTTOM" }
154
+ ],
155
+ global,
156
+ anim1,
157
+ anim2,
158
+ showCenterDiv = false,
159
+ className,
160
+ style
161
+ }) => {
162
+ const resolvedAnim1 = toAnimationShorthand(anim1);
163
+ const resolvedAnim2 = toAnimationShorthand(anim2);
164
+ const animation = [resolvedAnim1, resolvedAnim2].filter(Boolean).join(", ");
165
+ const stageStyle = {
166
+ perspective: `${perspective}px`,
167
+ perspectiveOrigin
168
+ };
169
+ const wrapperStyle = {
170
+ // consumed by CSS var
171
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
172
+ // @ts-ignore
173
+ "--obj-w": `${width}px`,
174
+ "--obj-h": `${height}px`,
175
+ width,
176
+ height,
177
+ "animation": animation || void 0
178
+ };
179
+ return /* @__PURE__ */ jsx(
180
+ "div",
181
+ {
182
+ className: `anim3d-stage ${className ?? ""}`,
183
+ style: { ...stageStyle, ...style },
184
+ children: /* @__PURE__ */ jsxs("div", { className: "anim3d-wrapper", style: wrapperStyle, children: [
185
+ showCenterDiv && /* @__PURE__ */ jsx("div", { className: "anim3d-center" }),
186
+ faces.map((f, i) => /* @__PURE__ */ jsx(
187
+ Face,
188
+ {
189
+ w: width,
190
+ h: height,
191
+ d: depth,
192
+ face: f,
193
+ global
194
+ },
195
+ `${f.name}-${i}`
196
+ ))
197
+ ] })
198
+ }
199
+ );
200
+ };
201
+ var Obj_default = Obj;
202
+ export {
203
+ Obj,
204
+ Obj_default as default
205
+ };
206
+ //# sourceMappingURL=Obj.mjs.map