@umituz/web-virtual 1.1.1 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-virtual",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Universal 3D Virtual Environment Engine for Web & React — Offices, Farms, Factories, Schools, Hospitals with 60fps performance, raycasting and interactive entities.",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -26,8 +26,12 @@ import {
26
26
  Send,
27
27
  Loader2,
28
28
  Eye,
29
+ Tag,
30
+ Moon,
31
+ Sun,
32
+ RotateCcw,
29
33
  } from 'lucide-react'
30
- import type { WorldDefinition, WorldEntity, WorldPreset } from '../core/types'
34
+ import type { WorldDefinition, WorldEntity, WorldPreset, PinDisplayMode } from '../core/types'
31
35
  import { VirtualWorld, type VirtualWorldRef } from './VirtualWorld'
32
36
  import { VirtualCommandBar, type PresetMission } from './VirtualCommandBar'
33
37
  import { VirtualRoster } from './VirtualRoster'
@@ -99,11 +103,23 @@ export function DigitalHQView({
99
103
  // Navigation Mode
100
104
  const [activeMode, setActiveMode] = useState<OperationalMode>('office')
101
105
 
102
- // Layout / Sidebar
106
+ // Layout / Sidebar / Toggles (Pure Zen Office Mode by default)
103
107
  const virtualWorldRef = useRef<VirtualWorldRef>(null)
104
- const [showRoster, setShowRoster] = useState(true)
108
+ const [showRoster, setShowRoster] = useState(false)
109
+ const [showCommandBar, setShowCommandBar] = useState(false)
110
+ const [pinMode, setPinMode] = useState<PinDisplayMode>('off')
111
+ const [nightMode, setNightMode] = useState(false)
105
112
  const [isFullscreen, setIsFullscreen] = useState(false)
106
113
 
114
+ // Pin cycle toggle: off -> pins (#1..#17) -> labels (full names) -> off
115
+ const handleCyclePinMode = useCallback(() => {
116
+ setPinMode((prev) => {
117
+ if (prev === 'off') return 'pins'
118
+ if (prev === 'pins') return 'labels'
119
+ return 'off'
120
+ })
121
+ }, [])
122
+
107
123
  // Selection & Report
108
124
  const [internalSelectedId, setInternalSelectedId] = useState<string | null>(null)
109
125
  const [viewingReport, setViewingReport] = useState<VirtualReportData | null>(null)
@@ -179,7 +195,7 @@ export function DigitalHQView({
179
195
  }, [world.entities])
180
196
 
181
197
  return (
182
- <div className={`wv-hq-container ${className}`}>
198
+ <div className={`wv-hq-container ${nightMode ? 'is-night' : ''} ${className}`}>
183
199
  {/* 1. Header Toolbar */}
184
200
  <header className="wv-hq-header">
185
201
  <div className="wv-hq-header-left">
@@ -267,15 +283,66 @@ export function DigitalHQView({
267
283
  )}
268
284
 
269
285
  {activeMode === 'office' && (
270
- <button
271
- type="button"
272
- onClick={handleToggleRoster}
273
- className={`wv-hq-action-btn ${showRoster ? 'is-active' : ''}`}
274
- title={showRoster ? 'Kadro Panelini Gizle' : 'Kadro Panelini Aç'}
275
- >
276
- {showRoster ? <PanelRightClose size={15} /> : <PanelRightOpen size={15} />}
277
- <span className="wv-hide-mobile">Kadro Paneli</span>
278
- </button>
286
+ <>
287
+ {/* Pin Mode 3-Way Cycle Toggle */}
288
+ <button
289
+ type="button"
290
+ onClick={handleCyclePinMode}
291
+ className={`wv-hq-action-btn ${pinMode !== 'off' ? 'is-active' : ''}`}
292
+ title="Etiketleri Değiştir: Kapalı ➔ Numaralar (#) ➔ İsimler"
293
+ >
294
+ <Tag size={14} />
295
+ <span>
296
+ {pinMode === 'off' ? 'Etiketler: Kapalı' : pinMode === 'pins' ? 'Masa No (#)' : 'İsimler'}
297
+ </span>
298
+ </button>
299
+
300
+ {/* Command Bar Toggle */}
301
+ <button
302
+ type="button"
303
+ onClick={() => setShowCommandBar((prev) => !prev)}
304
+ className={`wv-hq-action-btn ${showCommandBar ? 'is-active' : ''}`}
305
+ title={showCommandBar ? 'Görev Panelini Kapat' : 'Görev Panelini Aç'}
306
+ >
307
+ <Terminal size={14} />
308
+ <span className="wv-hide-mobile">Görev Paneli</span>
309
+ </button>
310
+
311
+ {/* Roster Sidebar Toggle */}
312
+ <button
313
+ type="button"
314
+ onClick={handleToggleRoster}
315
+ className={`wv-hq-action-btn ${showRoster ? 'is-active' : ''}`}
316
+ title={showRoster ? 'Kadro Panelini Gizle' : 'Kadro Panelini Aç'}
317
+ >
318
+ {showRoster ? <PanelRightClose size={15} /> : <PanelRightOpen size={15} />}
319
+ <span className="wv-hide-mobile">Kadro ({world.entities.length})</span>
320
+ </button>
321
+
322
+ {/* Lighting Toggle */}
323
+ <button
324
+ type="button"
325
+ onClick={() => {
326
+ const next = !nightMode
327
+ setNightMode(next)
328
+ virtualWorldRef.current?.setNightMode(next)
329
+ }}
330
+ className="wv-hq-icon-btn"
331
+ title={nightMode ? 'Gündüz Moduna Geç (Mimari Beyaz)' : 'Gece Moduna Geç (Akşam Işıkları)'}
332
+ >
333
+ {nightMode ? <Sun size={15} color="#f59e0b" /> : <Moon size={15} />}
334
+ </button>
335
+
336
+ {/* Camera Reset */}
337
+ <button
338
+ type="button"
339
+ onClick={() => virtualWorldRef.current?.resetCamera()}
340
+ className="wv-hq-icon-btn"
341
+ title="Kamerayı Varsayılan İzometrik Açıya Sıfırla"
342
+ >
343
+ <RotateCcw size={15} />
344
+ </button>
345
+ </>
279
346
  )}
280
347
 
281
348
  {!standalone ? (
@@ -351,8 +418,15 @@ export function DigitalHQView({
351
418
  preset={preset}
352
419
  selectedEntityId={activeEntity?.id}
353
420
  onSelectEntity={handleSelect}
354
- defaultPinMode="pins"
355
- showControls={true}
421
+ pinMode={pinMode}
422
+ onChangePinMode={setPinMode}
423
+ nightMode={nightMode}
424
+ onToggleNightMode={() => {
425
+ const next = !nightMode
426
+ setNightMode(next)
427
+ virtualWorldRef.current?.setNightMode(next)
428
+ }}
429
+ showControls={false}
356
430
  showInspector={false}
357
431
  >
358
432
  {/* Floating Bottom Command Bar Overlay */}
@@ -367,6 +441,8 @@ export function DigitalHQView({
367
441
  isDemoMode={isDemoMode}
368
442
  onToggleDemoMode={() => setIsDemoMode(!isDemoMode)}
369
443
  isLaunching={isLaunching}
444
+ isOpen={showCommandBar}
445
+ onToggleOpen={setShowCommandBar}
370
446
  />
371
447
  </VirtualWorld>
372
448
  </div>
@@ -19,6 +19,8 @@ export interface VirtualCommandBarProps {
19
19
  onToggleDemoMode?: () => void
20
20
  isLaunching?: boolean
21
21
  defaultOpen?: boolean
22
+ isOpen?: boolean
23
+ onToggleOpen?: (open: boolean) => void
22
24
  placeholder?: string
23
25
  className?: string
24
26
  }
@@ -34,22 +36,30 @@ export function VirtualCommandBar({
34
36
  isDemoMode = true,
35
37
  onToggleDemoMode,
36
38
  isLaunching = false,
37
- defaultOpen = true,
39
+ defaultOpen = false,
40
+ isOpen: externalIsOpen,
41
+ onToggleOpen,
38
42
  placeholder = "Genel Müdür'e veya bir uzmana görev verin... (Enter ile gönder)",
39
43
  className = '',
40
44
  }: VirtualCommandBarProps): ReactNode {
41
- const [isOpen, setIsOpen] = useState(defaultOpen)
45
+ const [internalIsOpen, setInternalIsOpen] = useState(defaultOpen)
46
+ const isOpen = externalIsOpen !== undefined ? externalIsOpen : internalIsOpen
47
+
48
+ const handleToggle = (open: boolean) => {
49
+ setInternalIsOpen(open)
50
+ if (onToggleOpen) onToggleOpen(open)
51
+ }
42
52
 
43
53
  if (!isOpen) {
44
54
  return (
45
55
  <button
46
56
  type="button"
47
- onClick={() => setIsOpen(true)}
57
+ onClick={() => handleToggle(true)}
48
58
  className="wv-command-collapsed-btn"
49
59
  aria-label="Komut Barını Aç"
50
60
  >
51
61
  <Send size={14} color="#3b82f6" />
52
- <span>Komut ve Görev Barını Aç ▲</span>
62
+ <span>⚡ Görev Paneli ▲</span>
53
63
  </button>
54
64
  )
55
65
  }
@@ -74,7 +84,7 @@ export function VirtualCommandBar({
74
84
 
75
85
  <button
76
86
  type="button"
77
- onClick={() => setIsOpen(false)}
87
+ onClick={() => handleToggle(false)}
78
88
  className="wv-collapse-btn"
79
89
  title="Komut Barını Küçült"
80
90
  >
@@ -36,6 +36,10 @@ export interface VirtualWorldProps {
36
36
  onSelectEntity?: (entity: WorldEntity | null) => void
37
37
  onHoverEntity?: (entity: WorldEntity | null) => void
38
38
  defaultPinMode?: PinDisplayMode
39
+ pinMode?: PinDisplayMode
40
+ onChangePinMode?: (mode: PinDisplayMode) => void
41
+ nightMode?: boolean
42
+ onToggleNightMode?: () => void
39
43
  showControls?: boolean
40
44
  showInspector?: boolean
41
45
  className?: string
@@ -53,7 +57,11 @@ export const VirtualWorld = forwardRef<VirtualWorldRef, VirtualWorldProps>(
53
57
  selectedEntityId,
54
58
  onSelectEntity,
55
59
  onHoverEntity,
56
- defaultPinMode = 'pins',
60
+ defaultPinMode = 'off',
61
+ pinMode: externalPinMode,
62
+ onChangePinMode,
63
+ nightMode: externalNightMode,
64
+ onToggleNightMode: externalToggleNightMode,
57
65
  showControls = true,
58
66
  showInspector = true,
59
67
  className = '',
@@ -69,11 +77,14 @@ export const VirtualWorld = forwardRef<VirtualWorldRef, VirtualWorldProps>(
69
77
  const engineRef = useRef<WorldEngine | null>(null)
70
78
  const pinElementsRef = useRef<Map<string, HTMLElement>>(new Map())
71
79
 
72
- const [nightMode, setNightMode] = useState(false)
73
- const [pinMode, setPinMode] = useState<PinDisplayMode>(defaultPinMode)
80
+ const [internalNightMode, setInternalNightMode] = useState(false)
81
+ const [internalPinMode, setInternalPinMode] = useState<PinDisplayMode>(defaultPinMode)
74
82
  const [fps, setFps] = useState<number>(60)
75
83
  const [internalSelectedEntity, setInternalSelectedEntity] = useState<WorldEntity | null>(null)
76
84
 
85
+ const nightMode = externalNightMode !== undefined ? externalNightMode : internalNightMode
86
+ const pinMode = externalPinMode !== undefined ? externalPinMode : internalPinMode
87
+
77
88
  // Determine active selected entity (controlled or uncontrolled)
78
89
  const activeEntity =
79
90
  selectedEntityId !== undefined
@@ -171,16 +182,29 @@ export const VirtualWorld = forwardRef<VirtualWorldRef, VirtualWorldProps>(
171
182
  }
172
183
  }, [world, preset, handleSelectEntity, onHoverEntity])
173
184
 
185
+ // Sync Night Mode with engine
186
+ useEffect(() => {
187
+ if (engineRef.current) {
188
+ engineRef.current.setNightMode(nightMode)
189
+ }
190
+ }, [nightMode])
191
+
174
192
  // Handle Night Mode Toggle
175
193
  const handleToggleNightMode = useCallback(() => {
176
- setNightMode((prev) => {
177
- const next = !prev
178
- if (engineRef.current) {
179
- engineRef.current.setNightMode(next)
180
- }
181
- return next
182
- })
183
- }, [])
194
+ if (externalToggleNightMode) {
195
+ externalToggleNightMode()
196
+ } else {
197
+ setInternalNightMode((prev) => !prev)
198
+ }
199
+ }, [externalToggleNightMode])
200
+
201
+ const handlePinModeChange = useCallback(
202
+ (newMode: PinDisplayMode) => {
203
+ setInternalPinMode(newMode)
204
+ if (onChangePinMode) onChangePinMode(newMode)
205
+ },
206
+ [onChangePinMode],
207
+ )
184
208
 
185
209
  // Handle Camera Presets
186
210
  const handleCameraPreset = useCallback((presetName: CameraPresetName) => {
@@ -215,7 +239,7 @@ export const VirtualWorld = forwardRef<VirtualWorldRef, VirtualWorldProps>(
215
239
  if (engineRef.current) engineRef.current.resetCamera()
216
240
  },
217
241
  setNightMode: (isNight: boolean) => {
218
- setNightMode(isNight)
242
+ setInternalNightMode(isNight)
219
243
  if (engineRef.current) engineRef.current.setNightMode(isNight)
220
244
  },
221
245
  resize: () => {
@@ -231,7 +255,7 @@ export const VirtualWorld = forwardRef<VirtualWorldRef, VirtualWorldProps>(
231
255
  return (
232
256
  <div
233
257
  ref={containerRef}
234
- className={`wv-container ${className}`}
258
+ className={`wv-container ${nightMode ? 'is-night' : ''} ${className}`}
235
259
  style={style}
236
260
  role="region"
237
261
  aria-label={`${world.name} 3D Sanal Ortamı`}
@@ -253,7 +277,7 @@ export const VirtualWorld = forwardRef<VirtualWorldRef, VirtualWorldProps>(
253
277
  nightMode={nightMode}
254
278
  onToggleNightMode={handleToggleNightMode}
255
279
  pinMode={pinMode}
256
- onChangePinMode={setPinMode}
280
+ onChangePinMode={handlePinModeChange}
257
281
  onSelectCameraPreset={handleCameraPreset}
258
282
  onResetCamera={handleResetCamera}
259
283
  fps={fps}
@@ -58,8 +58,8 @@ export function createEnvironment(options: CreateEnvironmentOptions): WorldDefin
58
58
  glassOpacity: 0.28,
59
59
  accentColor: '#3b82f6',
60
60
  gridColor: '#94a3b8',
61
- backgroundColor: '#0f172a',
62
- nightBackgroundColor: '#020617',
61
+ backgroundColor: '#f8fafc',
62
+ nightBackgroundColor: '#0f172a',
63
63
  ...(preset?.theme || {}),
64
64
  ...(options.theme || {}),
65
65
  }
@@ -37,7 +37,7 @@ export class WorldEngine {
37
37
  const { canvas, world } = options
38
38
 
39
39
  this.scene = new THREE.Scene()
40
- this.scene.background = new THREE.Color(world.theme.backgroundColor || '#0f172a')
40
+ this.scene.background = new THREE.Color(world.theme.backgroundColor || '#f8fafc')
41
41
 
42
42
  this.renderer = new THREE.WebGLRenderer({
43
43
  canvas,
@@ -150,8 +150,8 @@ export class WorldEngine {
150
150
  public setNightMode(isNight: boolean): void {
151
151
  this.lighting.setNightMode(isNight)
152
152
  const bgColor = isNight
153
- ? this.options.world.theme.nightBackgroundColor || '#020617'
154
- : this.options.world.theme.backgroundColor || '#0f172a'
153
+ ? this.options.world.theme.nightBackgroundColor || '#0f172a'
154
+ : this.options.world.theme.backgroundColor || '#f8fafc'
155
155
  this.scene.background = new THREE.Color(bgColor)
156
156
  }
157
157
 
@@ -48,6 +48,22 @@ export function buildOfficeArchitecture(
48
48
  gridHelper.position.set(-W / 2 + openW / 2, 0.004, 0)
49
49
  root.add(gridHelper)
50
50
 
51
+ // Architectural studio podium ground & subtle extended grid
52
+ const groundMat = new THREE.MeshStandardMaterial({
53
+ color: 0xf8fafc,
54
+ roughness: 0.96,
55
+ metalness: 0.04,
56
+ })
57
+ const groundMesh = new THREE.Mesh(new THREE.PlaneGeometry(140, 140), groundMat)
58
+ groundMesh.rotation.x = -Math.PI / 2
59
+ groundMesh.position.set(0, -0.015, 0)
60
+ groundMesh.receiveShadow = true
61
+ root.add(groundMesh)
62
+
63
+ const outerGrid = new THREE.GridHelper(120, 60, 0xe2e8f0, 0xf1f5f9)
64
+ outerGrid.position.set(0, -0.01, 0)
65
+ root.add(outerGrid)
66
+
51
67
  // 2. Outer Perimeter Glass Walls & Dark Structural Columns
52
68
  const H = 3.6
53
69
 
@@ -381,10 +381,10 @@ export const officePreset: WorldPreset = {
381
381
  },
382
382
  lighting: {
383
383
  ambientColor: '#ffffff',
384
- ambientIntensity: 0.85,
385
- sunColor: '#fff5ea',
386
- sunIntensity: 1.1,
387
- sunPosition: [20, 30, 15],
384
+ ambientIntensity: 0.95,
385
+ sunColor: '#fff8f0',
386
+ sunIntensity: 1.2,
387
+ sunPosition: [22, 32, 16],
388
388
  nightAmbientColor: '#1e293b',
389
389
  nightAmbientIntensity: 0.35,
390
390
  nightSunColor: '#60a5fa',
@@ -400,8 +400,8 @@ export const officePreset: WorldPreset = {
400
400
  glassColor: '#93c5fd',
401
401
  glassOpacity: 0.28,
402
402
  accentColor: '#3b82f6',
403
- backgroundColor: '#0f172a',
404
- nightBackgroundColor: '#020617',
403
+ backgroundColor: '#f8fafc',
404
+ nightBackgroundColor: '#0f172a',
405
405
  },
406
406
  zones: DEFAULT_OFFICE_ZONES,
407
407
  defaultEntities: DEFAULT_OFFICE_ENTITIES,