@umituz/web-virtual 2.0.1 → 2.1.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.
- package/README.md +44 -1
- package/package.json +1 -1
- package/src/components/VirtualWorld.tsx +14 -0
- package/src/core/environment.test.ts +1 -1
- package/src/core/types.ts +24 -1
- package/src/engine/index.ts +1 -0
- package/src/engine/random.ts +25 -0
- package/src/engine/renderer.ts +30 -1
- package/src/entities/animals/AnimalBuilder.test.ts +82 -0
- package/src/entities/animals/AnimalBuilder.ts +219 -0
- package/src/entities/animals/index.ts +1 -0
- package/src/entities/architecture/FarmArchitectureBuilder.ts +370 -0
- package/src/entities/index.ts +4 -0
- package/src/entities/nature/CropFieldBuilder.test.ts +119 -0
- package/src/entities/nature/CropFieldBuilder.ts +123 -0
- package/src/entities/nature/FenceBuilder.ts +108 -0
- package/src/entities/nature/PondBuilder.ts +87 -0
- package/src/entities/nature/TreeBuilder.ts +176 -0
- package/src/entities/nature/index.ts +4 -0
- package/src/entities/vehicles/TractorBuilder.ts +132 -0
- package/src/entities/vehicles/index.ts +1 -0
- package/src/presets/farmPreset.ts +186 -66
- package/src/styles/virtual.css +4 -0
|
@@ -1,52 +1,82 @@
|
|
|
1
1
|
import * as THREE from 'three'
|
|
2
2
|
import type { WorldPreset, WorldSlot, WorldZone } from '../core/types'
|
|
3
|
-
import {
|
|
3
|
+
import { createCropPlot } from '../entities/nature/CropFieldBuilder'
|
|
4
|
+
import { createTree, createTreeRow, applyWindSway } from '../entities/nature/TreeBuilder'
|
|
5
|
+
import { createFence } from '../entities/nature/FenceBuilder'
|
|
6
|
+
import { createPond } from '../entities/nature/PondBuilder'
|
|
7
|
+
import { createHerd } from '../entities/animals/AnimalBuilder'
|
|
8
|
+
import { createTractor } from '../entities/vehicles/TractorBuilder'
|
|
9
|
+
import {
|
|
10
|
+
createBarn,
|
|
11
|
+
createSilo,
|
|
12
|
+
createGreenhouse,
|
|
13
|
+
createMachineShed,
|
|
14
|
+
createCoop,
|
|
15
|
+
} from '../entities/architecture/FarmArchitectureBuilder'
|
|
4
16
|
|
|
5
17
|
export const DEFAULT_FARM_ZONES: WorldZone[] = [
|
|
6
18
|
{
|
|
7
19
|
id: 'greenhouse',
|
|
8
|
-
name: '
|
|
20
|
+
name: 'Greenhouse',
|
|
9
21
|
color: '#22c55e',
|
|
10
|
-
description: '
|
|
11
|
-
cameraFocus: [-
|
|
22
|
+
description: 'Climate-controlled growing area with benches and irrigation.',
|
|
23
|
+
cameraFocus: [-13, 1.2, -4],
|
|
12
24
|
},
|
|
13
25
|
{
|
|
14
26
|
id: 'crop_fields',
|
|
15
|
-
name: '
|
|
27
|
+
name: 'Crop Fields',
|
|
16
28
|
color: '#84cc16',
|
|
17
|
-
description: '
|
|
18
|
-
cameraFocus: [
|
|
29
|
+
description: 'Open planting beds at varying growth stages.',
|
|
30
|
+
cameraFocus: [4, 0.8, -6],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'pasture',
|
|
34
|
+
name: 'Pasture',
|
|
35
|
+
color: '#a3e635',
|
|
36
|
+
description: 'Grazing herds and the watering pond.',
|
|
37
|
+
cameraFocus: [4, 0.8, 8],
|
|
19
38
|
},
|
|
20
39
|
{
|
|
21
40
|
id: 'barn_storage',
|
|
22
|
-
name: '
|
|
41
|
+
name: 'Barn & Storage',
|
|
23
42
|
color: '#b45309',
|
|
24
|
-
description: '
|
|
25
|
-
cameraFocus: [
|
|
43
|
+
description: 'Barn, silo and the machinery yard.',
|
|
44
|
+
cameraFocus: [-9, 1.4, 8],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'poultry',
|
|
48
|
+
name: 'Poultry Yard',
|
|
49
|
+
color: '#f59e0b',
|
|
50
|
+
description: 'Coop and free-range chicken run.',
|
|
51
|
+
cameraFocus: [-15, 0.8, 10],
|
|
26
52
|
},
|
|
27
53
|
]
|
|
28
54
|
|
|
29
55
|
export const FARM_SLOTS: WorldSlot[] = [
|
|
30
|
-
{ id: 'slot-1', label: 'Greenhouse station', position: [-
|
|
31
|
-
{ id: 'slot-2', label: 'Crop field unit', position: [
|
|
32
|
-
{ id: 'slot-3', label: '
|
|
56
|
+
{ id: 'slot-1', label: 'Greenhouse station', position: [-13, 0, -4], zoneId: 'greenhouse', pinNumber: 1, avatarColor: '#15803d' },
|
|
57
|
+
{ id: 'slot-2', label: 'Crop field unit', position: [4, 0, -6], zoneId: 'crop_fields', pinNumber: 2 },
|
|
58
|
+
{ id: 'slot-3', label: 'Pasture station', position: [4, 0, 8], zoneId: 'pasture', pinNumber: 3, avatarColor: '#65a30d' },
|
|
59
|
+
{ id: 'slot-4', label: 'Barn & logistics station', position: [-9, 0, 8], zoneId: 'barn_storage', pinNumber: 4, avatarColor: '#b45309' },
|
|
60
|
+
{ id: 'slot-5', label: 'Poultry station', position: [-15, 0, 10], zoneId: 'poultry', pinNumber: 5, avatarColor: '#f59e0b' },
|
|
33
61
|
]
|
|
34
62
|
|
|
35
|
-
|
|
36
63
|
export const farmPreset: WorldPreset = {
|
|
37
64
|
id: 'preset-farm',
|
|
38
65
|
name: 'Smart Agriculture & Greenhouse Complex',
|
|
39
66
|
type: 'farm',
|
|
40
|
-
description:
|
|
67
|
+
description:
|
|
68
|
+
'Agricultural farm with greenhouses, staged crop plots, grazing herds, a pond, machinery yard and a poultry run.',
|
|
41
69
|
dimensions: {
|
|
42
|
-
width:
|
|
43
|
-
height:
|
|
44
|
-
depth:
|
|
70
|
+
width: 44,
|
|
71
|
+
height: 10,
|
|
72
|
+
depth: 30,
|
|
45
73
|
},
|
|
46
74
|
camera: {
|
|
47
|
-
position: [
|
|
48
|
-
target: [
|
|
75
|
+
position: [30, 22, 30],
|
|
76
|
+
target: [-2, 0, 1],
|
|
49
77
|
fov: 42,
|
|
78
|
+
minDistance: 6,
|
|
79
|
+
maxDistance: 80,
|
|
50
80
|
},
|
|
51
81
|
lighting: {
|
|
52
82
|
ambientColor: '#f0fdf4',
|
|
@@ -65,63 +95,153 @@ export const farmPreset: WorldPreset = {
|
|
|
65
95
|
glassColor: '#bbf7d0',
|
|
66
96
|
glassOpacity: 0.22,
|
|
67
97
|
accentColor: '#22c55e',
|
|
68
|
-
backgroundColor: '#
|
|
69
|
-
nightBackgroundColor: '#
|
|
98
|
+
backgroundColor: '#cfe4d8',
|
|
99
|
+
nightBackgroundColor: '#0a1420',
|
|
70
100
|
},
|
|
71
101
|
zones: DEFAULT_FARM_ZONES,
|
|
72
102
|
slots: FARM_SLOTS,
|
|
73
103
|
|
|
74
|
-
buildScene: (scene
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const groundGeo = new THREE.PlaneGeometry(40, 25)
|
|
79
|
-
const soilMat = materials.getDarkSlate(options.theme?.floorColor || '#365314')
|
|
80
|
-
const ground = new THREE.Mesh(groundGeo, soilMat)
|
|
104
|
+
buildScene: (scene, options) => {
|
|
105
|
+
// 1. Ground — grass plane with a soil work strip
|
|
106
|
+
const grassMat = new THREE.MeshStandardMaterial({ color: '#679a4c', roughness: 1 })
|
|
107
|
+
const ground = new THREE.Mesh(new THREE.PlaneGeometry(46, 32), grassMat)
|
|
81
108
|
ground.rotation.x = -Math.PI / 2
|
|
82
109
|
ground.receiveShadow = true
|
|
83
110
|
scene.add(ground)
|
|
84
111
|
|
|
85
|
-
// 2.
|
|
86
|
-
const
|
|
87
|
-
|
|
112
|
+
// 2. Crop fields — four plots at staggered growth stages
|
|
113
|
+
const plots: Array<{ x: number; z: number; growth: number; color: string; rows: number }> = [
|
|
114
|
+
{ x: 1, z: -9, growth: 0.85, color: '#5d8a2a', rows: 6 },
|
|
115
|
+
{ x: 10, z: -9, growth: 0.45, color: '#7ba72f', rows: 5 },
|
|
116
|
+
{ x: 1, z: -1, growth: 0.2, color: '#8fbf3f', rows: 6 },
|
|
117
|
+
{ x: 10, z: -1, growth: 0.65, color: '#4d7c0f', rows: 5 },
|
|
118
|
+
]
|
|
119
|
+
for (const plot of plots) {
|
|
120
|
+
const p = createCropPlot({
|
|
121
|
+
width: 7.5,
|
|
122
|
+
depth: 6,
|
|
123
|
+
rows: plot.rows,
|
|
124
|
+
growth: plot.growth,
|
|
125
|
+
cropColor: plot.color,
|
|
126
|
+
seed: 5 + plot.x + plot.z,
|
|
127
|
+
})
|
|
128
|
+
p.position.set(plot.x, 0, plot.z)
|
|
129
|
+
scene.add(p)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 3. Greenhouse with interior benches
|
|
133
|
+
scene.add(
|
|
134
|
+
createGreenhouse({
|
|
135
|
+
width: 9,
|
|
136
|
+
depth: 6.4,
|
|
137
|
+
position: [-13, 0, -5.5],
|
|
138
|
+
benches: [
|
|
139
|
+
{ color: '#3f8f3a', growth: 0.7 },
|
|
140
|
+
{ color: '#58a34e', growth: 0.5 },
|
|
141
|
+
{ color: '#77b852', growth: 0.9 },
|
|
142
|
+
],
|
|
143
|
+
}),
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
// 4. Pasture — fenced paddock, cow herd, sheep, pond with ripples
|
|
147
|
+
const paddock = createFence({
|
|
148
|
+
points: [
|
|
149
|
+
[-1, 0, 4.5],
|
|
150
|
+
[12.5, 0, 4.5],
|
|
151
|
+
[12.5, 0, 13],
|
|
152
|
+
[-1, 0, 13],
|
|
153
|
+
[-1, 0, 4.5],
|
|
154
|
+
],
|
|
155
|
+
})
|
|
156
|
+
scene.add(paddock)
|
|
88
157
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
158
|
+
scene.add(
|
|
159
|
+
createHerd({
|
|
160
|
+
species: 'cow',
|
|
161
|
+
count: 5,
|
|
162
|
+
area: { width: 9, depth: 5.5 },
|
|
163
|
+
center: [2.5, 0, 8.2],
|
|
164
|
+
registerTick: options.registerTick,
|
|
165
|
+
}),
|
|
92
166
|
)
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ghGroup.add(dome)
|
|
104
|
-
scene.add(ghGroup)
|
|
105
|
-
|
|
106
|
-
// 3. Barn / Storage building
|
|
107
|
-
const barnGroup = new THREE.Group()
|
|
108
|
-
barnGroup.position.set(0, 0, 7)
|
|
109
|
-
const barnWalls = new THREE.Mesh(
|
|
110
|
-
new THREE.BoxGeometry(14, 4, 8),
|
|
111
|
-
materials.getWallMaterial('#7f1d1d'),
|
|
167
|
+
scene.add(
|
|
168
|
+
createHerd({
|
|
169
|
+
species: 'sheep',
|
|
170
|
+
count: 6,
|
|
171
|
+
area: { width: 4, depth: 4 },
|
|
172
|
+
center: [9, 0, 10.5],
|
|
173
|
+
scale: 0.9,
|
|
174
|
+
seed: 41,
|
|
175
|
+
registerTick: options.registerTick,
|
|
176
|
+
}),
|
|
112
177
|
)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
178
|
+
|
|
179
|
+
const pond = createPond({
|
|
180
|
+
radius: 2.4,
|
|
181
|
+
position: [9.4, 0, 6.2],
|
|
182
|
+
registerTick: options.registerTick,
|
|
183
|
+
})
|
|
184
|
+
scene.add(pond)
|
|
185
|
+
|
|
186
|
+
// 5. Barnyard — barn, silo, machine shed, working tractor
|
|
187
|
+
scene.add(createBarn({ width: 9, depth: 6.5, position: [-9, 0, 8.5] }))
|
|
188
|
+
scene.add(createSilo({ radius: 1.3, height: 5.5, position: [-14.4, 0, 8.5] }))
|
|
189
|
+
scene.add(
|
|
190
|
+
createMachineShed({ width: 8, depth: 5, position: [-8.5, 0, 14], rotationY: Math.PI }),
|
|
121
191
|
)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
192
|
+
|
|
193
|
+
const tractorWorking = createTractor({
|
|
194
|
+
status: 'running',
|
|
195
|
+
implement: 'mower',
|
|
196
|
+
registerTick: options.registerTick,
|
|
197
|
+
})
|
|
198
|
+
tractorWorking.position.set(6.5, 0, -4.5)
|
|
199
|
+
tractorWorking.rotation.y = -Math.PI / 2
|
|
200
|
+
scene.add(tractorWorking)
|
|
201
|
+
|
|
202
|
+
const tractorParked = createTractor({
|
|
203
|
+
bodyColor: '#1d6fb8',
|
|
204
|
+
status: 'idle',
|
|
205
|
+
implement: 'trailer',
|
|
206
|
+
})
|
|
207
|
+
tractorParked.position.set(-6.2, 0, 13.8)
|
|
208
|
+
tractorParked.rotation.y = Math.PI
|
|
209
|
+
scene.add(tractorParked)
|
|
210
|
+
|
|
211
|
+
// 6. Poultry yard
|
|
212
|
+
scene.add(createCoop({ position: [-15.5, 0, 12.5], rotationY: 0.5 }))
|
|
213
|
+
scene.add(
|
|
214
|
+
createHerd({
|
|
215
|
+
species: 'chicken',
|
|
216
|
+
count: 7,
|
|
217
|
+
area: { width: 3.4, depth: 3 },
|
|
218
|
+
center: [-14.6, 0, 14.6],
|
|
219
|
+
seed: 77,
|
|
220
|
+
registerTick: options.registerTick,
|
|
221
|
+
}),
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
// 7. Windbreak tree rows swaying in the breeze
|
|
225
|
+
const northRow = createTreeRow({ count: 8, spacing: 3.2, axis: 'x', shape: 'broad', height: 4.6, season: 'summer' })
|
|
226
|
+
northRow.position.set(0, 0, -14.5)
|
|
227
|
+
scene.add(northRow)
|
|
228
|
+
applyWindSway(northRow, options.registerTick, { intensity: 0.022, speed: 1.2 })
|
|
229
|
+
|
|
230
|
+
const eastRow = createTreeRow({ count: 5, spacing: 3.2, axis: 'z', shape: 'conifer', height: 5.2 })
|
|
231
|
+
eastRow.position.set(16.5, 0, 2)
|
|
232
|
+
scene.add(eastRow)
|
|
233
|
+
applyWindSway(eastRow, options.registerTick, { intensity: 0.016, speed: 0.9, phase: 1.9 })
|
|
234
|
+
|
|
235
|
+
// A few orchard-style round trees near the greenhouse
|
|
236
|
+
for (const [tx, tz] of [
|
|
237
|
+
[-17.5, 0.5],
|
|
238
|
+
[-17.5, 3.5],
|
|
239
|
+
[-16, -10.5],
|
|
240
|
+
] as const) {
|
|
241
|
+
const tree = createTree({ shape: 'round', height: 3.6, season: 'autumn', seed: tx * 7 + tz })
|
|
242
|
+
tree.position.set(tx, 0, tz)
|
|
243
|
+
scene.add(tree)
|
|
244
|
+
applyWindSway(tree, options.registerTick, { intensity: 0.02, speed: 1.5, phase: tx })
|
|
245
|
+
}
|
|
126
246
|
},
|
|
127
247
|
}
|
package/src/styles/virtual.css
CHANGED
|
@@ -1335,6 +1335,10 @@
|
|
|
1335
1335
|
flex: 1;
|
|
1336
1336
|
width: 100%;
|
|
1337
1337
|
height: 100%;
|
|
1338
|
+
/* Flex items default to min-width:auto, so the pixel-sized 3D canvas
|
|
1339
|
+
inside blocks shrinking and pushes the roster sidebar off-screen.
|
|
1340
|
+
Allow the wrapper to shrink so sidebars stay in the viewport. */
|
|
1341
|
+
min-width: 0;
|
|
1338
1342
|
}
|
|
1339
1343
|
|
|
1340
1344
|
.wv-hq-loading-overlay {
|