@cristiancosano/pallet-builder 0.1.1 → 0.1.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 +93 -93
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
# 📦 @cristiancosano/pallet-builder
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modular system for 3D logistics visualization based on React and React Three Fiber.
|
|
4
4
|
|
|
5
|
-
## 🎯
|
|
5
|
+
## 🎯 Description
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
React component library that allows building interactive 3D scenes to visualize logistics operations such as warehouses, pallets, boxes, and shipping containers.
|
|
8
8
|
|
|
9
|
-
## ✨
|
|
9
|
+
## ✨ Features
|
|
10
10
|
|
|
11
|
-
- 🧱 **
|
|
12
|
-
- 🎨 **
|
|
13
|
-
- 📐 **
|
|
14
|
-
- 🔄 **Real-time**:
|
|
15
|
-
- 📊 **
|
|
16
|
-
- 🎯 **
|
|
11
|
+
- 🧱 **Modular System**: Clean architecture with separation between core logic and visualization
|
|
12
|
+
- 🎨 **Declarative Components**: Simple API based on React components
|
|
13
|
+
- 📐 **Industry Standards**: Support for EURO, ISO, and custom pallets
|
|
14
|
+
- 🔄 **Real-time**: Interactive 3D visualization with camera controls
|
|
15
|
+
- 📊 **Validations**: Business logic to validate dimensions, weights, and occupancy
|
|
16
|
+
- 🎯 **Agnostic**: Core in pure TypeScript without dependencies on visualization frameworks
|
|
17
17
|
|
|
18
|
-
## 🚀
|
|
18
|
+
## 🚀 Quick Start
|
|
19
19
|
|
|
20
|
-
###
|
|
20
|
+
### Installation
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
pnpm install
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
###
|
|
26
|
+
### Development
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
pnpm dev
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Open [http://localhost:5173](http://localhost:5173) to view the demo.
|
|
33
33
|
|
|
34
|
-
## 📖
|
|
34
|
+
## 📖 Basic Usage
|
|
35
35
|
|
|
36
36
|
```tsx
|
|
37
37
|
import { Warehouse, Pallet, Box } from '@cristiancosano/pallet-builder';
|
|
38
38
|
|
|
39
|
-
function
|
|
39
|
+
function MyLogisticsApp() {
|
|
40
40
|
return (
|
|
41
41
|
<Warehouse width={5000} depth={5000} showGrid>
|
|
42
42
|
|
|
@@ -45,7 +45,7 @@ function MiAppLogistica() {
|
|
|
45
45
|
dimensions={[400, 300, 200]}
|
|
46
46
|
position={[0, 0, 0]}
|
|
47
47
|
color="orange"
|
|
48
|
-
label="
|
|
48
|
+
label="Box 1"
|
|
49
49
|
/>
|
|
50
50
|
</Pallet>
|
|
51
51
|
|
|
@@ -62,16 +62,16 @@ function MiAppLogistica() {
|
|
|
62
62
|
}
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
## 🏗️
|
|
65
|
+
## 🏗️ Architecture
|
|
66
66
|
|
|
67
|
-
### Core (TypeScript
|
|
67
|
+
### Core (Pure TypeScript)
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
Framework-agnostic business logic:
|
|
70
70
|
|
|
71
71
|
```typescript
|
|
72
72
|
import { BoxEntity, PalletEntity, ContainerEntity } from '@cristiancosano/pallet-builder';
|
|
73
73
|
|
|
74
|
-
//
|
|
74
|
+
// Create a pallet with validations
|
|
75
75
|
const pallet = new PalletEntity({
|
|
76
76
|
id: 'pallet-1',
|
|
77
77
|
type: 'EURO',
|
|
@@ -86,95 +86,95 @@ const pallet = new PalletEntity({
|
|
|
86
86
|
]
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
//
|
|
89
|
+
// Validate configuration
|
|
90
90
|
const validation = pallet.validate();
|
|
91
|
-
console.log('
|
|
92
|
-
console.log('
|
|
91
|
+
console.log('Total weight:', pallet.getTotalWeight(), 'kg');
|
|
92
|
+
console.log('Occupancy:', pallet.getOccupancyRate(), '%');
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
###
|
|
95
|
+
### Components (React + R3F)
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
3D visual components built with React Three Fiber:
|
|
98
98
|
|
|
99
|
-
- **`<Warehouse>`**:
|
|
100
|
-
- **`<Pallet>`**:
|
|
101
|
-
- **`<Box>`**:
|
|
102
|
-
- **`<CameraControls>`**:
|
|
99
|
+
- **`<Warehouse>`**: Main container of the 3D scene
|
|
100
|
+
- **`<Pallet>`**: Represents a pallet with support for EURO, ISO, or custom
|
|
101
|
+
- **`<Box>`**: Box/package positionable inside a pallet
|
|
102
|
+
- **`<CameraControls>`**: Camera controls (orbit, first person, etc.)
|
|
103
103
|
|
|
104
|
-
## 📐
|
|
104
|
+
## 📐 Pallet Standards
|
|
105
105
|
|
|
106
106
|
### EUR-Pallet (EURO)
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
107
|
+
- Dimensions: 800 x 1200 x 144 mm
|
|
108
|
+
- Maximum weight: 1500 kg
|
|
109
|
+
- Maximum height: 2200 mm
|
|
110
110
|
|
|
111
111
|
### ISO Pallet (ISO)
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
-
|
|
112
|
+
- Dimensions: 1000 x 1200 x 144 mm
|
|
113
|
+
- Maximum weight: 2000 kg
|
|
114
|
+
- Maximum height: 2200 mm
|
|
115
115
|
|
|
116
116
|
### Custom
|
|
117
|
-
-
|
|
118
|
-
-
|
|
117
|
+
- Customizable dimensions
|
|
118
|
+
- Flexible configuration
|
|
119
119
|
|
|
120
|
-
## 🎨
|
|
120
|
+
## 🎨 Available Components
|
|
121
121
|
|
|
122
122
|
### Warehouse
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
Main container that creates the 3D scene with lighting and controls.
|
|
125
125
|
|
|
126
126
|
```tsx
|
|
127
127
|
<Warehouse
|
|
128
128
|
width={5000} // mm
|
|
129
129
|
depth={5000} // mm
|
|
130
|
-
height={3000} // mm (
|
|
131
|
-
showGrid={true} //
|
|
130
|
+
height={3000} // mm (optional)
|
|
131
|
+
showGrid={true} // Show ground grid
|
|
132
132
|
backgroundColor="#f0f0f0"
|
|
133
133
|
>
|
|
134
|
-
{/*
|
|
134
|
+
{/* Content */}
|
|
135
135
|
</Warehouse>
|
|
136
136
|
```
|
|
137
137
|
|
|
138
138
|
### Pallet
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
Represents a standard or custom pallet.
|
|
141
141
|
|
|
142
142
|
```tsx
|
|
143
143
|
<Pallet
|
|
144
144
|
id="pallet-1"
|
|
145
145
|
type="EURO" // 'EURO' | 'ISO' | 'CUSTOM'
|
|
146
|
-
position={[0, 0, 0]} // [x, y, z]
|
|
147
|
-
rotation={[0, 0, 0]} // [x, y, z]
|
|
146
|
+
position={[0, 0, 0]} // [x, y, z] in mm
|
|
147
|
+
rotation={[0, 0, 0]} // [x, y, z] in radians
|
|
148
148
|
color="#8B4513"
|
|
149
149
|
showDimensions={false}
|
|
150
|
-
customDimensions={[1000, 144, 1200]} //
|
|
150
|
+
customDimensions={[1000, 144, 1200]} // For CUSTOM
|
|
151
151
|
>
|
|
152
|
-
{/*
|
|
152
|
+
{/* Boxes */}
|
|
153
153
|
</Pallet>
|
|
154
154
|
```
|
|
155
155
|
|
|
156
156
|
### Box
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
Box or package inside a pallet.
|
|
159
159
|
|
|
160
160
|
```tsx
|
|
161
161
|
<Box
|
|
162
|
-
dimensions={[400, 300, 200]} // [
|
|
163
|
-
position={[0, 0, 0]} // [x, y, z]
|
|
162
|
+
dimensions={[400, 300, 200]} // [width, height, depth] in mm
|
|
163
|
+
position={[0, 0, 0]} // [x, y, z] inside the pallet
|
|
164
164
|
color="#ff6b35"
|
|
165
|
-
label="
|
|
165
|
+
label="Box 1"
|
|
166
166
|
onClick={() => console.log('Click!')}
|
|
167
167
|
onHover={(hovered) => console.log(hovered)}
|
|
168
168
|
/>
|
|
169
169
|
```
|
|
170
170
|
|
|
171
|
-
## 🎨
|
|
171
|
+
## 🎨 Customization with AspectConfig
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
The `AspectConfig` system allows customizing the visual appearance of each component individually.
|
|
174
174
|
|
|
175
|
-
###
|
|
175
|
+
### Global Configuration
|
|
176
176
|
|
|
177
|
-
Define
|
|
177
|
+
Define default values for all components:
|
|
178
178
|
|
|
179
179
|
```tsx
|
|
180
180
|
import { ConfigurationProvider, PalletBuilder, Box } from '@cristiancosano/pallet-builder';
|
|
@@ -199,32 +199,32 @@ function App() {
|
|
|
199
199
|
}
|
|
200
200
|
```
|
|
201
201
|
|
|
202
|
-
###
|
|
202
|
+
### Component-level Customization
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
Each pallet or box can have its own texture, model, or color:
|
|
205
205
|
|
|
206
206
|
```tsx
|
|
207
207
|
<PalletBuilder
|
|
208
208
|
palletType="EURO"
|
|
209
209
|
palletAspect={{ textureUrl: '/textures/dark_wood.png' }}
|
|
210
210
|
>
|
|
211
|
-
{/*
|
|
211
|
+
{/* Box with custom color */}
|
|
212
212
|
<Box
|
|
213
213
|
dimensions={[400, 300, 200]}
|
|
214
214
|
position={[0, 0, 0]}
|
|
215
215
|
aspect={{ color: '#00d9ff' }}
|
|
216
|
-
label="
|
|
216
|
+
label="Blue Box"
|
|
217
217
|
/>
|
|
218
218
|
|
|
219
|
-
{/*
|
|
219
|
+
{/* Box with custom texture */}
|
|
220
220
|
<Box
|
|
221
221
|
dimensions={[400, 300, 200]}
|
|
222
222
|
position={[400, 0, 0]}
|
|
223
223
|
aspect={{ textureUrl: '/textures/cardboard.png' }}
|
|
224
|
-
label="
|
|
224
|
+
label="Cardboard Box"
|
|
225
225
|
/>
|
|
226
226
|
|
|
227
|
-
{/*
|
|
227
|
+
{/* Box with custom 3D model */}
|
|
228
228
|
<Box
|
|
229
229
|
dimensions={[400, 300, 200]}
|
|
230
230
|
position={[0, 0, 400]}
|
|
@@ -232,62 +232,62 @@ Cada pallet o caja puede tener su propia textura, modelo o color:
|
|
|
232
232
|
modelUrl: '/objects/custom_box.glb',
|
|
233
233
|
textureUrl: '/textures/metal.png'
|
|
234
234
|
}}
|
|
235
|
-
label="
|
|
235
|
+
label="Metal Box"
|
|
236
236
|
/>
|
|
237
237
|
</PalletBuilder>
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
-
###
|
|
240
|
+
### Default 3D Models and Textures
|
|
241
241
|
|
|
242
|
-
|
|
242
|
+
The library comes configured with default models and textures:
|
|
243
243
|
|
|
244
244
|
**Pallets:**
|
|
245
|
-
-
|
|
246
|
-
-
|
|
245
|
+
- Model: `/objects/pallet.glb`
|
|
246
|
+
- Texture: `/textures/pallet_planks.png`
|
|
247
247
|
|
|
248
|
-
**
|
|
249
|
-
-
|
|
250
|
-
-
|
|
248
|
+
**Boxes:**
|
|
249
|
+
- Model: `/objects/box.glb`
|
|
250
|
+
- Texture: `/textures/crate_roughness.png`
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
You can use your own GLB models and textures by customizing the global configuration or using the `aspect` prop on each individual component.
|
|
253
253
|
|
|
254
|
-
**
|
|
254
|
+
**Priority**: `aspect prop` > `ConfigurationProvider` > `defaults`
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
See [docs/guides/aspect-customization.md](./docs/guides/aspect-customization.md) for full examples.
|
|
257
257
|
|
|
258
258
|
## 🔮 Roadmap
|
|
259
259
|
|
|
260
|
-
- [ ] **`<Truck>`**:
|
|
261
|
-
- [ ] **`<Container>`**:
|
|
262
|
-
- [ ] **
|
|
263
|
-
- [ ] **
|
|
264
|
-
- [ ] **
|
|
265
|
-
- [ ] **Multiplayer**:
|
|
260
|
+
- [ ] **`<Truck>`**: Component for truck visualization
|
|
261
|
+
- [ ] **`<Container>`**: Shipping container
|
|
262
|
+
- [ ] **Optimization Algorithms**: Automatic placement suggestions
|
|
263
|
+
- [ ] **Export**: Generate reports and visualizations
|
|
264
|
+
- [ ] **Physics**: Weight and stability simulation
|
|
265
|
+
- [ ] **Multiplayer**: Real-time collaboration
|
|
266
266
|
|
|
267
|
-
## 📚
|
|
267
|
+
## 📚 Documentation
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
Check the `/docs` folder for more information:
|
|
270
270
|
|
|
271
|
-
- [
|
|
272
|
-
- [
|
|
273
|
-
- [
|
|
271
|
+
- [3D Components Guide](./docs/guides/3d-components-development.md)
|
|
272
|
+
- [Domain Model](./docs/context/domain-model.md)
|
|
273
|
+
- [Coding Conventions](./docs/context/coding-conventions.md)
|
|
274
274
|
|
|
275
|
-
## 🤝
|
|
275
|
+
## 🤝 Contributing
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
See [CONTRIBUTING.md](./docs/guides/contributing.md)
|
|
278
278
|
|
|
279
|
-
##
|
|
279
|
+
## 📄 Attributions
|
|
280
280
|
|
|
281
|
-
|
|
281
|
+
This project uses third-party assets:
|
|
282
282
|
|
|
283
283
|
- **HDR Environment Map**: [HDRI Haven/Poly Haven](https://polyhaven.com/) (CC0 License) via [pmndrs/drei-assets](https://github.com/pmndrs/drei-assets)
|
|
284
284
|
|
|
285
|
-
|
|
285
|
+
See [ATTRIBUTIONS.md](./ATTRIBUTIONS.md) for full details.
|
|
286
286
|
|
|
287
|
-
##
|
|
287
|
+
## 📄 License
|
|
288
288
|
|
|
289
289
|
MIT © Cristian Cosano
|
|
290
290
|
|
|
291
291
|
---
|
|
292
292
|
|
|
293
|
-
**
|
|
293
|
+
**Made with ❤️ using React Three Fiber**
|
package/package.json
CHANGED