string-tune-3d 0.0.6 → 0.0.8

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/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "string-tune-3d",
3
- "version": "0.0.6",
4
- "description": "StringTune-3D is a powerful 3D graphics adapter library that provides a unified interface for working with different 3D engines like Three.js. Part of the StringTune ecosystem, it enables seamless integration and synchronization of 3D objects, scenes, cameras, and lights across various rendering engines.",
3
+ "version": "0.0.8",
4
+ "description": "CSS-driven 3D graphics library that lets you control Three.js objects through CSS custom properties.",
5
5
  "keywords": [
6
6
  "3d",
7
7
  "threejs",
8
8
  "three",
9
+ "css",
10
+ "css-custom-properties",
11
+ "css-first",
12
+ "dom-sync",
13
+ "web-components",
9
14
  "stringtune",
10
15
  "typescript",
11
16
  "3d-graphics",
@@ -64,10 +69,10 @@
64
69
  },
65
70
  "license": "MIT",
66
71
  "peerDependencies": {
67
- "@fiddle-digital/string-tune": "^1.1.45"
72
+ "@fiddle-digital/string-tune": "^1.1.47"
68
73
  },
69
74
  "devDependencies": {
70
- "@fiddle-digital/string-tune": "^1.1.45",
75
+ "@fiddle-digital/string-tune": "^1.1.47",
71
76
  "@types/node": "^20.4.2",
72
77
  "terser": "^5.19.0",
73
78
  "tsup": "^8.4.0",
package/readme.md CHANGED
@@ -1,170 +1,254 @@
1
- # StringTune-3D
1
+ <p align="center">
2
+ <img src="/assets/logo.png" alt="StringTune-3D Logo" width="120" />
3
+ </p>
4
+ <h1 align="center">StringTune-3D</h1>
5
+ <p align="center">
6
+ <strong>CSS-driven 3D graphics for the web</strong>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/string-tune-3d"><img src="https://img.shields.io/npm/v/string-tune-3d?color=blue&label=npm" alt="npm version" /></a>
11
+ <a href="https://github.com/penev-palemiya/StringTune-3D/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-green" alt="License" /></a>
12
+ <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.0-blue?logo=typescript&logoColor=white" alt="TypeScript" /></a>
13
+ <a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-r160+-black?logo=three.js" alt="Three.js" /></a>
14
+ </p>
15
+
16
+ <p align="center">
17
+ <a href="#features">Features</a> •
18
+ <a href="#installation">Installation</a> •
19
+ <a href="#quick-start">Quick Start</a> •
20
+ <a href="https://penev.tech/string-tune-3d/overview">Documentation</a> •
21
+ <a href="#examples">Examples</a>
22
+ </p>
23
+
24
+ ---
25
+
26
+ <p align="center">
27
+ <img src="assets/hero.gif" alt="StringTune-3D Demo" width="600" />
28
+ </p>
2
29
 
3
30
  ## Overview
4
31
 
5
- **StringTune-3D** is a powerful 3D graphics module for the StringTune ecosystem. It provides seamless integration of 3D objects with HTML elements using a simple attribute-based approach. StringTune-3D works exclusively within the StringTune framework and enables automatic synchronization between DOM elements and 3D objects rendered via Three.js.
32
+ **StringTune-3D** is a 3D graphics module for the [StringTune](https://github.com/fiddle-digital/string-tune) ecosystem that lets you control 3D objects through **CSS custom properties**. No imperative Three.js code just HTML attributes and CSS.
6
33
 
7
- > **Important**: StringTune-3D is a module for StringTune and requires the base `@fiddle-digital/string-tune` package to function.
8
-
9
- ### Key Features
34
+ ```html
35
+ <div
36
+ string="3d"
37
+ string-3d="sphere"
38
+ style="
39
+ width: 150px;
40
+ height: 150px;
41
+ --material-color: #667eea;
42
+ --rotate-y: 45;
43
+ --material-metalness: 0.8;
44
+ "
45
+ ></div>
46
+ ```
10
47
 
11
- - **Attribute-Based 3D**: Add 3D objects to your HTML using simple `string-3d` attributes
12
- - **Engine Abstraction**: Currently supports Three.js with more engines planned
13
- - **Automatic Synchronization**: 3D objects automatically follow DOM element positions and transformations
14
- - **Type-Safe**: Built with TypeScript for excellent developer experience
15
- - **Modular Architecture**: Lightweight addition to your StringTune setup
16
- - **Performance-Oriented**: Optimized for smooth 3D rendering
48
+ > **Note**: StringTune-3D requires the base `@fiddle-digital/string-tune` package.
17
49
 
18
- ### Supported 3D Engines
50
+ ---
19
51
 
20
- - **Three.js** - Full support via ThreeJSProvider
52
+ ## Features
21
53
 
22
- ## Installation
54
+ | Feature | Description |
55
+ | ----------------- | -------------------------------------------------------------------- |
56
+ | 🎨 **CSS-First** | Control transforms, materials, and effects via CSS custom properties |
57
+ | 🔄 **Auto-Sync** | 3D objects automatically follow DOM element position and size |
58
+ | 📦 **Primitives** | Box, sphere, plane, cylinder + GLTF/GLB model loading |
59
+ | 💡 **Lighting** | Ambient, directional, point, spot, and hemisphere lights |
60
+ | ✨ **Filters** | Blur, bloom, pixel effects through `--filter` property |
61
+ | 🎭 **Materials** | Basic, standard PBR, and custom shader materials |
62
+ | 🔤 **3D Text** | Extruded text geometry with bevel support |
63
+ | 🌟 **Particles** | Emitter and instanced particle systems |
23
64
 
24
- First, install the base StringTune library:
65
+ ---
25
66
 
26
- ```bash
27
- npm install @fiddle-digital/string-tune
28
- ```
29
-
30
- Then install StringTune-3D:
67
+ ## Installation
31
68
 
32
69
  ```bash
33
- npm install string-tune-3d
70
+ # Install dependencies
71
+ npm install @fiddle-digital/string-tune string-tune-3d three
34
72
  ```
35
73
 
36
- For Three.js support, also install Three.js:
37
-
38
- ```bash
39
- npm install three
40
- ```
74
+ ---
41
75
 
42
76
  ## Quick Start
43
77
 
44
- ### 1. Import Dependencies
78
+ ### 1. Setup
45
79
 
46
80
  ```typescript
47
81
  import { StringTune } from "@fiddle-digital/string-tune";
48
82
  import { String3D, ThreeJSProvider } from "string-tune-3d";
49
83
  import * as THREE from "three";
50
- import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
51
- ```
52
84
 
53
- ### 2. Initialize StringTune with 3D Support
85
+ // Configure Three.js provider
86
+ String3D.setProvider(new ThreeJSProvider(THREE));
54
87
 
55
- ```typescript
56
- // Set the 3D provider (Three.js + model loaders)
57
- String3D.setProvider(
58
- new ThreeJSProvider(THREE, {
59
- gltf: GLTFLoader,
60
- })
61
- );
62
-
63
- // Get StringTune instance and register the 3D module
88
+ // Initialize StringTune with 3D module
64
89
  const stringTune = StringTune.getInstance();
65
- stringTune.use(String3D, { modelLoaderType: "gltf" });
66
-
67
- // Start StringTune
68
- stringTune.start(60); // 60 FPS
90
+ stringTune.use(String3D);
91
+ stringTune.start(60);
69
92
  ```
70
93
 
71
- ### 3. Add 3D Objects in HTML
94
+ ### 2. Add 3D Objects
72
95
 
73
96
  ```html
74
- <!-- 3D Box -->
97
+ <!-- Lighting -->
75
98
  <div
76
- class="shape"
77
99
  string="3d"
78
- string-3d="box"
79
- string-3d-material="standard[#667eea]"
80
- string-3d-opacity="0.5"
81
- >
82
- BOX
83
- </div>
84
-
85
- <!-- Ambient Light -->
100
+ string-3d="ambientLight"
101
+ style="--light-intensity: 0.5"
102
+ ></div>
86
103
  <div
87
104
  string="3d"
88
- string-3d="ambientLight"
89
- string-3d-color="#ffffff"
90
- string-3d-intensity="0.5"
105
+ string-3d="directionalLight"
106
+ style="--light-intensity: 1"
91
107
  ></div>
92
108
 
93
- <!-- Directional Light -->
109
+ <!-- 3D Box -->
94
110
  <div
95
111
  string="3d"
96
- string-3d="directionalLight"
97
- string-3d-color="#ffffff"
98
- string-3d-intensity="1"
112
+ string-3d="box"
113
+ style="
114
+ width: 150px;
115
+ height: 150px;
116
+ --material-type: standard;
117
+ --material-color: #667eea;
118
+ --material-metalness: 0.5;
119
+ --rotate-y: 20;
120
+ "
99
121
  ></div>
100
122
  ```
101
123
 
102
- ### 4. Basic Styling
124
+ ### 3. Animate with CSS
103
125
 
104
126
  ```css
105
- .shape {
106
- width: 200px;
107
- height: 200px;
108
- display: flex;
109
- align-items: center;
110
- justify-content: center;
111
- font-weight: 700;
112
- transition: --rotate-x 0.3s, --rotate-y 0.3s;
127
+ .my-3d-object {
128
+ --rotate-y: 0;
129
+ transition: --rotate-y 0.4s ease;
113
130
  }
114
131
 
115
- .shape:hover {
116
- --rotate-x: 45;
117
- --rotate-y: 45;
132
+ .my-3d-object:hover {
133
+ --rotate-y: 180;
118
134
  }
119
135
  ```
120
136
 
121
- ## Available Attributes
137
+ ---
138
+
139
+ ## Examples
140
+
141
+ ### Metallic Sphere
142
+
143
+ ```html
144
+ <div
145
+ string="3d"
146
+ string-3d="sphere"
147
+ style="
148
+ --material-type: standard;
149
+ --material-color: #c0c0c0;
150
+ --material-metalness: 1;
151
+ --material-roughness: 0.1;
152
+ "
153
+ ></div>
154
+ ```
155
+
156
+ ### Glowing Object with Bloom
122
157
 
123
- ### Core Attributes
158
+ ```html
159
+ <div
160
+ string="3d"
161
+ string-3d="box"
162
+ style="
163
+ --material-emissive: #ff0066;
164
+ --filter: bloom(0.6, 0.3);
165
+ "
166
+ ></div>
167
+ ```
124
168
 
125
- - `string="3d"` - Enables 3D for the element
126
- - `string-3d="<type>"` - Type of 3D object: `box`, `sphere`, `plane`, `ambientLight`, `directionalLight`, etc.
127
- - `string-3d="model"` - Loads a model (e.g. glTF)
169
+ ### Load 3D Model
128
170
 
129
- ### Material & Appearance
171
+ ```html
172
+ <div
173
+ string="3d"
174
+ string-3d="model"
175
+ string-3d-model="/models/robot.glb"
176
+ string-3d-model-fit="contain"
177
+ style="width: 300px; height: 300px;"
178
+ ></div>
179
+ ```
180
+
181
+ ---
182
+
183
+ ## CSS Properties
184
+
185
+ | Property | Description |
186
+ | -------------------------- | ------------------------------ |
187
+ | `--translate-x/y/z` | Position offset |
188
+ | `--rotate-x/y/z` | Rotation in degrees |
189
+ | `--scale`, `--scale-x/y/z` | Scale multipliers |
190
+ | `--opacity` | Transparency (0-1) |
191
+ | `--material-type` | `basic`, `standard`, or custom |
192
+ | `--material-color` | Surface color |
193
+ | `--material-metalness` | Metallic look (0-1) |
194
+ | `--material-roughness` | Surface roughness (0-1) |
195
+ | `--filter` | Post-processing effects |
196
+
197
+ 📖 **[Full CSS Reference →](https://penev.tech/string-tune-3d/reference/css-properties)**
130
198
 
131
- - `string-3d-material="<type>[<color>]"` - Material type: `basic`, `standard`
132
- - `string-3d-color="<color>"` - Object or light color
133
- - `string-3d-opacity="<number>"` - Opacity (0-1)
134
- - `string-3d-metalness="<number>"` - Metalness (standard only)
135
- - `string-3d-roughness="<number>"` - Roughness (standard only)
199
+ ---
136
200
 
137
- ### Lighting
201
+ ## Documentation
138
202
 
139
- - `string-3d-intensity="<number>"` - Light intensity
203
+ | Guide | Description |
204
+ | ------------------------------------------------------------------------------ | --------------------------- |
205
+ | [Installation](https://penev.tech/string-tune-3d/getting-started/installation) | Setup and dependencies |
206
+ | [Quick Start](https://penev.tech/string-tune-3d/getting-started/quick-start) | First 3D scene |
207
+ | [Core Concepts](https://penev.tech/string-tune-3d/getting-started/concepts) | Architecture overview |
208
+ | [CSS Properties](https://penev.tech/string-tune-3d/reference/css-properties) | Complete property reference |
209
+ | [3D Objects](https://penev.tech/string-tune-3d/reference/3d-objects) | Available object types |
210
+ | [Materials](https://penev.tech/string-tune-3d/reference/materials) | Material & texture system |
211
+ | [Lighting](https://penev.tech/string-tune-3d/reference/lighting) | Light types & shadows |
212
+ | [Filters](https://penev.tech/string-tune-3d/reference/filters) | Post-processing effects |
213
+ | [Performance](https://penev.tech/string-tune-3d/advanced/performance) | Optimization tips |
140
214
 
141
- ### Models
215
+ ---
142
216
 
143
- - `string-3d-model="<url>"` - Path to model (e.g. `.gltf`, `.glb`)
144
- - `string-3d-model-loader="<type>"` - Loader override per element (e.g. `gltf`)
145
- - `string-3d-model-scale="<number>"` - Uniform scale (default `1`)
146
- - `string-3d-model-center="true|false"` - Center model at origin (default `false`)
147
- - `string-3d-model-fit="contain|cover"` - Fit model into element bounds (default `contain`)
148
- - `string-3d-model-texture-base="<url>"` - Base path for model texture URLs
149
- - `string-3d-model-textures='{"old.png":"/new.png"}'` - Remap model texture URLs
150
- > Note: Model materials are only overridden when you specify material or map attributes.
217
+ ## Browser Support
151
218
 
152
- ### Textures & Maps
219
+ | Browser | Version |
220
+ | ------- | ------- |
221
+ | Chrome | 56+ |
222
+ | Firefox | 51+ |
223
+ | Safari | 11+ |
224
+ | Edge | 79+ |
225
+
226
+ ---
227
+
228
+ ## Contributing
229
+
230
+ Contributions are welcome! Please read our contributing guidelines before submitting PRs.
231
+
232
+ ```bash
233
+ # Clone and install
234
+ git clone https://github.com/penev-palemiya/StringTune-3D.git
235
+ cd string-tune-3d
236
+ npm install
237
+
238
+ # Build
239
+ npm run build
240
+ ```
153
241
 
154
- - `string-3d-map="<url>"` - Base color map
155
- - `string-3d-normalMap="<url>"` - Normal map
156
- - `string-3d-roughnessMap="<url>"` - Roughness map
157
- - `string-3d-metalnessMap="<url>"` - Metalness map
158
- - `string-3d-aoMap="<url>"` - Ambient occlusion map
159
- - `string-3d-texture-flipY="true|false"` - Flip Y for all maps (default `true`)
160
- - `string-3d-colorSpace="srgb|linear"` - Color space for base color map
242
+ ---
161
243
 
162
244
  ## License
163
245
 
164
246
  MIT © [penev.tech](https://penev.tech)
165
247
 
166
- ## Links
248
+ ---
167
249
 
168
- - [GitHub Repository](https://github.com/penev-palemiya/StringTune-3D)
169
- - [Issues](https://github.com/penev-palemiya/StringTune-3D/issues)
170
- - [StringTune Main Library](https://www.npmjs.com/package/@fiddle-digital/string-tune)
250
+ <p align="center">
251
+ <a href="https://github.com/fiddle-digital/string-tune">StringTune</a> •
252
+ <a href="https://penev.tech/string-tune-3d/overview">Documentation</a> •
253
+ <a href="https://github.com/penev-palemiya/StringTune-3D/issues">Report Bug</a>
254
+ </p>