This can be confusing! Here's the complete breakdown:
What it is: The actual 3D orb component (JavaScript/Three.js) When to use: ALWAYS - this is the engine that makes everything work Works with:
- ✅ Vanilla HTML
- ✅ React
- ✅ Vue
- ✅ Any framework
Size: ~13 KB Dependencies: Three.js (peer dependency)
// This file contains the actual Web Component class
class FloatingOrb extends HTMLElement {
// All the Three.js 3D magic happens here
}
customElements.define('floating-orb', FloatingOrb);What it is: Makes the web component easy to use in React
When to use: ONLY if you're using React
Depends on: floating-orb.js
Size: ~4 KB Dependencies: React, PropTypes
// This wraps the web component for React
import FloatingOrb from './FloatingOrb';
function App() {
return <FloatingOrb color="#fafafa" size={300} />;
}What it is: Working examples showing how to use the component When to use: For testing or learning Types:
floating-orb-standalone.html- Single orb demodemo-floating-orb.html- Multiple orbs demofloating_orb_perfect_chrome.html- Chrome material demo
Your Project/
├── index.html ← Your page
└── floating-orb.js ← Include this
In your HTML:
<script type="module" src="floating-orb.js"></script>
<floating-orb color="#fafafa" size="500"></floating-orb>Files needed: 1 file (floating-orb.js)
Your Project/
├── src/
│ ├── App.jsx ← Your React app
│ ├── FloatingOrb.jsx ← React wrapper
│ └── floating-orb.js ← Core component
└── package.json
In your React app:
import FloatingOrb from './FloatingOrb';
function App() {
return <FloatingOrb color="#fafafa" size={500} />;
}Files needed: 2 files (floating-orb.js + FloatingOrb.jsx)
Your Project/
├── floating-orb-standalone.html ← Just open this in browser!
Files needed: 1 file (standalone HTML has everything built-in)
┌─────────────────────────────────────────────────┐
│ YOUR PROJECT │
├─────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ │
│ │ React App │ (If using React) │
│ │ (App.jsx) │ │
│ └──────┬───────┘ │
│ │ uses │
│ ↓ │
│ ┌──────────────────┐ │
│ │ FloatingOrb.jsx │ (React wrapper) │
│ │ (Optional) │ │
│ └──────┬───────────┘ │
│ │ imports │
│ ↓ │
│ ┌──────────────────┐ │
│ │ floating-orb.js │ ← CORE ENGINE │
│ │ (Required) │ (Three.js magic) │
│ └──────┬───────────┘ │
│ │ uses │
│ ↓ │
│ ┌──────────────────┐ │
│ │ Three.js │ (3D library) │
│ │ (from npm) │ │
│ └──────────────────┘ │
│ │
└─────────────────────────────────────────────────┘
- Format: React JavaScript
- Used in: React projects
- Can run alone? ❌ NO - needs React build system
- Example:
FloatingOrb.jsx
- Format: ES6 Modules
- Used in: Vanilla JS, React, Vue, etc.
- Can run alone? ✅ YES (in modern browsers)
- Example:
floating-orb.js
- Format: Complete web pages
- Used in: Testing, demos, standalone
- Can run alone? ✅ YES (just double-click!)
- Example:
floating-orb-standalone.html
Include ALL these files:
floating-orb-component/
├── src/
│ ├── floating-orb.js ← Core (13 KB)
│ └── FloatingOrb.jsx ← React wrapper (4 KB)
├── examples/
│ ├── vanilla-demo.html ← HTML demo
│ ├── react-demo.jsx ← React demo
│ └── floating-orb-standalone.html ← Quick test
├── docs/
│ ├── README.md ← Installation guide
│ ├── API.md ← API reference
│ └── FILE-GUIDE.md ← This file!
├── package.json ← npm config
└── LICENSE ← MIT License
Customers get:
- ✅ Core component (works everywhere)
- ✅ React wrapper (optional)
- ✅ 3 working demos
- ✅ Complete documentation
- ✅ npm-ready package
Q: Do I need both .js and .jsx?
A: Only if using React. Vanilla JS just needs .js
Q: Can I use .html files in production?
A: No - they're for demos. Use .js or .jsx files
Q: Which file has the 3D code?
A: floating-orb.js - all the Three.js magic is here
Q: Do I need to install Three.js?
A: Yes - it's a peer dependency. Run: npm install three
Q: What's the difference between demos? A: Different lighting/materials. All use the same core engine
For HTML:
<script type="module" src="floating-orb.js"></script>
<floating-orb></floating-orb>For React:
import FloatingOrb from './FloatingOrb';
<FloatingOrb />That's it! 🎉