@umituz/web-virtual 0.0.0-stage → 1.0.1
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/LICENSE +21 -0
- package/README.md +63 -2
- package/package.json +78 -4
- package/src/components/EntityInspector.tsx +224 -0
- package/src/components/EntityPins.tsx +67 -0
- package/src/components/VirtualWorld.tsx +229 -0
- package/src/components/WorldControls.tsx +143 -0
- package/src/components/index.ts +4 -0
- package/src/core/environment.test.ts +55 -0
- package/src/core/environment.ts +120 -0
- package/src/core/events.ts +50 -0
- package/src/core/index.ts +4 -0
- package/src/core/registry.ts +80 -0
- package/src/core/types.ts +170 -0
- package/src/engine/camera.ts +111 -0
- package/src/engine/index.ts +6 -0
- package/src/engine/lighting.ts +81 -0
- package/src/engine/materials.ts +215 -0
- package/src/engine/performance.ts +79 -0
- package/src/engine/raycaster.ts +51 -0
- package/src/engine/renderer.ts +227 -0
- package/src/entities/architecture/OfficeArchitectureBuilder.ts +172 -0
- package/src/entities/furniture/DeskBuilder.ts +280 -0
- package/src/entities/index.ts +4 -0
- package/src/entities/people/AvatarBuilder.ts +116 -0
- package/src/entities/props/PlantBuilder.ts +58 -0
- package/src/index.ts +6 -0
- package/src/presets/factoryPreset.ts +168 -0
- package/src/presets/farmPreset.ts +158 -0
- package/src/presets/hospitalPreset.ts +117 -0
- package/src/presets/index.ts +5 -0
- package/src/presets/officePreset.ts +415 -0
- package/src/presets/schoolPreset.ts +111 -0
- package/src/styles/virtual.css +190 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Sun,
|
|
4
|
+
Moon,
|
|
5
|
+
RotateCcw,
|
|
6
|
+
Compass,
|
|
7
|
+
Maximize2,
|
|
8
|
+
Minimize2,
|
|
9
|
+
Tag,
|
|
10
|
+
MapPin,
|
|
11
|
+
EyeOff,
|
|
12
|
+
} from 'lucide-react'
|
|
13
|
+
import type { PinDisplayMode } from '../core/types'
|
|
14
|
+
import type { CameraPresetName } from '../engine/camera'
|
|
15
|
+
|
|
16
|
+
export interface WorldControlsProps {
|
|
17
|
+
nightMode: boolean
|
|
18
|
+
onToggleNightMode: () => void
|
|
19
|
+
pinMode: PinDisplayMode
|
|
20
|
+
onChangePinMode: (mode: PinDisplayMode) => void
|
|
21
|
+
onSelectCameraPreset: (preset: CameraPresetName) => void
|
|
22
|
+
onResetCamera: () => void
|
|
23
|
+
isFullscreen?: boolean
|
|
24
|
+
onToggleFullscreen?: () => void
|
|
25
|
+
fps?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function WorldControls({
|
|
29
|
+
nightMode,
|
|
30
|
+
onToggleNightMode,
|
|
31
|
+
pinMode,
|
|
32
|
+
onChangePinMode,
|
|
33
|
+
onSelectCameraPreset,
|
|
34
|
+
onResetCamera,
|
|
35
|
+
isFullscreen,
|
|
36
|
+
onToggleFullscreen,
|
|
37
|
+
fps,
|
|
38
|
+
}: WorldControlsProps): ReactNode {
|
|
39
|
+
return (
|
|
40
|
+
<div className="wv-controls-toolbar" role="toolbar" aria-label="3D Görünüm Kontrolleri">
|
|
41
|
+
{/* Camera Presets */}
|
|
42
|
+
<button
|
|
43
|
+
type="button"
|
|
44
|
+
className="wv-btn wv-btn-icon"
|
|
45
|
+
title="İzometrik Görünüm"
|
|
46
|
+
onClick={() => onSelectCameraPreset('isometric')}
|
|
47
|
+
>
|
|
48
|
+
<Compass size={16} />
|
|
49
|
+
</button>
|
|
50
|
+
|
|
51
|
+
<button
|
|
52
|
+
type="button"
|
|
53
|
+
className="wv-btn"
|
|
54
|
+
title="Üstten Bakış"
|
|
55
|
+
onClick={() => onSelectCameraPreset('top')}
|
|
56
|
+
>
|
|
57
|
+
Üst
|
|
58
|
+
</button>
|
|
59
|
+
|
|
60
|
+
<button
|
|
61
|
+
type="button"
|
|
62
|
+
className="wv-btn wv-btn-icon"
|
|
63
|
+
title="Kamerayı Sıfırla"
|
|
64
|
+
onClick={onResetCamera}
|
|
65
|
+
>
|
|
66
|
+
<RotateCcw size={15} />
|
|
67
|
+
</button>
|
|
68
|
+
|
|
69
|
+
<div className="wv-divider" />
|
|
70
|
+
|
|
71
|
+
{/* Pin Mode Toggle */}
|
|
72
|
+
<button
|
|
73
|
+
type="button"
|
|
74
|
+
className={`wv-btn ${pinMode === 'pins' ? 'is-active' : ''}`}
|
|
75
|
+
title="Minimal İğneler (Sayılar)"
|
|
76
|
+
onClick={() => onChangePinMode('pins')}
|
|
77
|
+
>
|
|
78
|
+
<MapPin size={14} style={{ marginRight: 4 }} />
|
|
79
|
+
İğneler
|
|
80
|
+
</button>
|
|
81
|
+
|
|
82
|
+
<button
|
|
83
|
+
type="button"
|
|
84
|
+
className={`wv-btn ${pinMode === 'labels' ? 'is-active' : ''}`}
|
|
85
|
+
title="Detaylı Kartlar"
|
|
86
|
+
onClick={() => onChangePinMode('labels')}
|
|
87
|
+
>
|
|
88
|
+
<Tag size={14} style={{ marginRight: 4 }} />
|
|
89
|
+
Etiketler
|
|
90
|
+
</button>
|
|
91
|
+
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
className={`wv-btn wv-btn-icon ${pinMode === 'off' ? 'is-active' : ''}`}
|
|
95
|
+
title="Etiketleri Gizle"
|
|
96
|
+
onClick={() => onChangePinMode('off')}
|
|
97
|
+
>
|
|
98
|
+
<EyeOff size={15} />
|
|
99
|
+
</button>
|
|
100
|
+
|
|
101
|
+
<div className="wv-divider" />
|
|
102
|
+
|
|
103
|
+
{/* Day / Night Toggle */}
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
className="wv-btn wv-btn-icon"
|
|
107
|
+
title={nightMode ? 'Gündüz Moduna Geç' : 'Gece Moduna Geç'}
|
|
108
|
+
onClick={onToggleNightMode}
|
|
109
|
+
>
|
|
110
|
+
{nightMode ? <Sun size={16} color="#f59e0b" /> : <Moon size={16} />}
|
|
111
|
+
</button>
|
|
112
|
+
|
|
113
|
+
{/* Fullscreen Toggle */}
|
|
114
|
+
{onToggleFullscreen && (
|
|
115
|
+
<button
|
|
116
|
+
type="button"
|
|
117
|
+
className="wv-btn wv-btn-icon"
|
|
118
|
+
title={isFullscreen ? 'Tam Ekrandan Çık' : 'Tam Ekran'}
|
|
119
|
+
onClick={onToggleFullscreen}
|
|
120
|
+
>
|
|
121
|
+
{isFullscreen ? <Minimize2 size={16} /> : <Maximize2 size={16} />}
|
|
122
|
+
</button>
|
|
123
|
+
)}
|
|
124
|
+
|
|
125
|
+
{/* FPS Counter */}
|
|
126
|
+
{fps !== undefined && (
|
|
127
|
+
<>
|
|
128
|
+
<div className="wv-divider" />
|
|
129
|
+
<span
|
|
130
|
+
style={{
|
|
131
|
+
fontSize: 10,
|
|
132
|
+
fontFamily: 'monospace',
|
|
133
|
+
color: fps >= 55 ? '#4ade80' : fps >= 30 ? '#facc15' : '#f87171',
|
|
134
|
+
padding: '0 6px',
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
{fps} FPS
|
|
138
|
+
</span>
|
|
139
|
+
</>
|
|
140
|
+
)}
|
|
141
|
+
</div>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { createEnvironment, validateEnvironment } from './environment'
|
|
3
|
+
import { officePreset, farmPreset, factoryPreset, schoolPreset, hospitalPreset } from '../presets/index'
|
|
4
|
+
|
|
5
|
+
describe('Environment Factory & Presets', () => {
|
|
6
|
+
it('creates an environment using officePreset', () => {
|
|
7
|
+
const world = createEnvironment({
|
|
8
|
+
preset: officePreset,
|
|
9
|
+
name: 'Nexora Agency HQ',
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
expect(world.name).toBe('Nexora Agency HQ')
|
|
13
|
+
expect(world.type).toBe('office')
|
|
14
|
+
expect(world.dimensions.width).toBe(36)
|
|
15
|
+
expect(world.zones.length).toBe(6)
|
|
16
|
+
expect(world.entities.length).toBe(17)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('creates an environment using farmPreset', () => {
|
|
20
|
+
const world = createEnvironment({
|
|
21
|
+
preset: farmPreset,
|
|
22
|
+
name: 'Organic Farm Valley',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
expect(world.type).toBe('farm')
|
|
26
|
+
expect(world.zones.length).toBe(3)
|
|
27
|
+
expect(world.entities.length).toBe(3)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('creates an environment using factoryPreset', () => {
|
|
31
|
+
const world = createEnvironment({
|
|
32
|
+
preset: factoryPreset,
|
|
33
|
+
name: 'Auto Plant 4',
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
expect(world.type).toBe('factory')
|
|
37
|
+
expect(world.entities.length).toBe(3)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('validates environment entity ids and positions', () => {
|
|
41
|
+
expect(() => {
|
|
42
|
+
validateEnvironment({
|
|
43
|
+
id: '',
|
|
44
|
+
type: 'test',
|
|
45
|
+
name: 'Invalid World',
|
|
46
|
+
dimensions: { width: 10, height: 10, depth: 10 },
|
|
47
|
+
camera: { position: [0, 0, 0], target: [0, 0, 0] },
|
|
48
|
+
lighting: {},
|
|
49
|
+
theme: { name: 'test' },
|
|
50
|
+
zones: [],
|
|
51
|
+
entities: [],
|
|
52
|
+
})
|
|
53
|
+
}).toThrow('WorldDefinition must have a valid id')
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
WorldDefinition,
|
|
3
|
+
CreateEnvironmentOptions,
|
|
4
|
+
WorldEntity,
|
|
5
|
+
} from './types'
|
|
6
|
+
|
|
7
|
+
export function createEnvironment(options: CreateEnvironmentOptions): WorldDefinition {
|
|
8
|
+
const preset = options.preset
|
|
9
|
+
|
|
10
|
+
const id = options.id || preset?.id || `world-${Date.now()}`
|
|
11
|
+
const type = options.type || preset?.type || 'generic'
|
|
12
|
+
const name = options.name || preset?.name || 'Virtual World'
|
|
13
|
+
const description = options.description || preset?.description
|
|
14
|
+
|
|
15
|
+
const dimensions = options.dimensions || preset?.dimensions || {
|
|
16
|
+
width: 50,
|
|
17
|
+
height: 10,
|
|
18
|
+
depth: 30,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const camera = {
|
|
22
|
+
position: [26, 24, 26] as [number, number, number],
|
|
23
|
+
target: [0, 0, 0] as [number, number, number],
|
|
24
|
+
fov: 40,
|
|
25
|
+
near: 0.1,
|
|
26
|
+
far: 200,
|
|
27
|
+
enableDamping: true,
|
|
28
|
+
dampingFactor: 0.05,
|
|
29
|
+
minDistance: 8,
|
|
30
|
+
maxDistance: 65,
|
|
31
|
+
maxPolarAngle: Math.PI / 2 - 0.05,
|
|
32
|
+
...(preset?.camera || {}),
|
|
33
|
+
...(options.camera || {}),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const lighting = {
|
|
37
|
+
ambientColor: '#ffffff',
|
|
38
|
+
ambientIntensity: 0.85,
|
|
39
|
+
sunColor: '#fff5ea',
|
|
40
|
+
sunIntensity: 1.1,
|
|
41
|
+
sunPosition: [20, 30, 15] as [number, number, number],
|
|
42
|
+
nightAmbientColor: '#1e293b',
|
|
43
|
+
nightAmbientIntensity: 0.35,
|
|
44
|
+
nightSunColor: '#60a5fa',
|
|
45
|
+
nightSunIntensity: 0.4,
|
|
46
|
+
shadows: true,
|
|
47
|
+
...(preset?.lighting || {}),
|
|
48
|
+
...(options.lighting || {}),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const theme = {
|
|
52
|
+
name: 'default',
|
|
53
|
+
floorColor: '#f1f5f9',
|
|
54
|
+
woodFloorColor: '#c29b71',
|
|
55
|
+
wallColor: '#cbd5e1',
|
|
56
|
+
wallFrameColor: '#1e293b',
|
|
57
|
+
glassColor: '#93c5fd',
|
|
58
|
+
glassOpacity: 0.28,
|
|
59
|
+
accentColor: '#3b82f6',
|
|
60
|
+
gridColor: '#94a3b8',
|
|
61
|
+
backgroundColor: '#0f172a',
|
|
62
|
+
nightBackgroundColor: '#020617',
|
|
63
|
+
...(preset?.theme || {}),
|
|
64
|
+
...(options.theme || {}),
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const zones = options.zones || preset?.zones || []
|
|
68
|
+
|
|
69
|
+
// If user provided entities, use them; otherwise if preset has defaults, use those
|
|
70
|
+
let entities: WorldEntity[] = []
|
|
71
|
+
if (options.entities && options.entities.length > 0) {
|
|
72
|
+
entities = options.entities
|
|
73
|
+
} else if (preset?.defaultEntities) {
|
|
74
|
+
entities = preset.defaultEntities
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const world: WorldDefinition = {
|
|
78
|
+
id,
|
|
79
|
+
type,
|
|
80
|
+
name,
|
|
81
|
+
description,
|
|
82
|
+
dimensions,
|
|
83
|
+
camera,
|
|
84
|
+
lighting,
|
|
85
|
+
theme,
|
|
86
|
+
zones,
|
|
87
|
+
entities,
|
|
88
|
+
metadata: options.metadata || {},
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
validateEnvironment(world)
|
|
92
|
+
return world
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function validateEnvironment(world: WorldDefinition): void {
|
|
96
|
+
if (!world.id) {
|
|
97
|
+
throw new Error('WorldDefinition must have a valid id')
|
|
98
|
+
}
|
|
99
|
+
if (!world.name) {
|
|
100
|
+
throw new Error('WorldDefinition must have a valid name')
|
|
101
|
+
}
|
|
102
|
+
if (world.dimensions.width <= 0 || world.dimensions.depth <= 0) {
|
|
103
|
+
throw new Error('World dimensions width and depth must be positive numbers')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const idSet = new Set<string>()
|
|
107
|
+
for (const entity of world.entities) {
|
|
108
|
+
if (!entity.id) {
|
|
109
|
+
throw new Error('Every entity must have a non-empty id')
|
|
110
|
+
}
|
|
111
|
+
if (idSet.has(entity.id)) {
|
|
112
|
+
console.warn(`[web-virtual] Warning: Duplicate entity ID "${entity.id}" found in environment.`)
|
|
113
|
+
}
|
|
114
|
+
idSet.add(entity.id)
|
|
115
|
+
|
|
116
|
+
if (!Array.isArray(entity.position) || entity.position.length !== 3) {
|
|
117
|
+
throw new Error(`Entity "${entity.id}" must have a valid [x, y, z] position tuple`)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { WorldEntity, EntitySelectedEvent } from './types'
|
|
2
|
+
|
|
3
|
+
export type VirtualEventListener<T> = (data: T) => void
|
|
4
|
+
|
|
5
|
+
export class VirtualEventEmitter {
|
|
6
|
+
private listeners: Map<string, Set<VirtualEventListener<any>>> = new Map()
|
|
7
|
+
|
|
8
|
+
on<T>(event: string, listener: VirtualEventListener<T>): () => void {
|
|
9
|
+
if (!this.listeners.has(event)) {
|
|
10
|
+
this.listeners.set(event, new Set())
|
|
11
|
+
}
|
|
12
|
+
this.listeners.get(event)!.add(listener)
|
|
13
|
+
return () => this.off(event, listener)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
off<T>(event: string, listener: VirtualEventListener<T>): void {
|
|
17
|
+
const set = this.listeners.get(event)
|
|
18
|
+
if (set) {
|
|
19
|
+
set.delete(listener)
|
|
20
|
+
if (set.size === 0) {
|
|
21
|
+
this.listeners.delete(event)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
emit<T>(event: string, data: T): void {
|
|
27
|
+
const set = this.listeners.get(event)
|
|
28
|
+
if (set) {
|
|
29
|
+
for (const listener of set) {
|
|
30
|
+
try {
|
|
31
|
+
listener(data)
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error(`[web-virtual] Error in event listener for "${event}":`, err)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
clear(): void {
|
|
40
|
+
this.listeners.clear()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface VirtualEvents {
|
|
45
|
+
'entity:select': EntitySelectedEvent
|
|
46
|
+
'entity:hover': { entity: WorldEntity | null; position?: [number, number, number] }
|
|
47
|
+
'entity:action': { entity: WorldEntity; actionId: string }
|
|
48
|
+
'camera:move': { position: [number, number, number]; target: [number, number, number] }
|
|
49
|
+
'world:ready': { worldId: string }
|
|
50
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { WorldEntity, WorldZone, WorldDefinition } from './types'
|
|
2
|
+
|
|
3
|
+
export class EntityRegistry {
|
|
4
|
+
private entities: Map<string, WorldEntity> = new Map()
|
|
5
|
+
private zones: Map<string, WorldZone> = new Map()
|
|
6
|
+
private entityZoneIndex: Map<string, Set<string>> = new Map()
|
|
7
|
+
|
|
8
|
+
constructor(world?: WorldDefinition) {
|
|
9
|
+
if (world) {
|
|
10
|
+
this.loadWorld(world)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
loadWorld(world: WorldDefinition): void {
|
|
15
|
+
this.clear()
|
|
16
|
+
for (const zone of world.zones) {
|
|
17
|
+
this.zones.set(zone.id, zone)
|
|
18
|
+
}
|
|
19
|
+
for (const entity of world.entities) {
|
|
20
|
+
this.registerEntity(entity)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
registerEntity(entity: WorldEntity): void {
|
|
25
|
+
this.entities.set(entity.id, entity)
|
|
26
|
+
if (entity.zoneId) {
|
|
27
|
+
if (!this.entityZoneIndex.has(entity.zoneId)) {
|
|
28
|
+
this.entityZoneIndex.set(entity.zoneId, new Set())
|
|
29
|
+
}
|
|
30
|
+
this.entityZoneIndex.get(entity.zoneId)!.add(entity.id)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getEntity(id: string): WorldEntity | undefined {
|
|
35
|
+
return this.entities.get(id)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getEntities(): WorldEntity[] {
|
|
39
|
+
return Array.from(this.entities.values())
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
getZone(id: string): WorldZone | undefined {
|
|
43
|
+
return this.zones.get(id)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
getZones(): WorldZone[] {
|
|
47
|
+
return Array.from(this.zones.values())
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getEntitiesByZone(zoneId: string): WorldEntity[] {
|
|
51
|
+
const ids = this.entityZoneIndex.get(zoneId)
|
|
52
|
+
if (!ids) return []
|
|
53
|
+
return Array.from(ids)
|
|
54
|
+
.map((id) => this.entities.get(id))
|
|
55
|
+
.filter((e): e is WorldEntity => e !== undefined)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
updateEntity(id: string, partial: Partial<WorldEntity>): WorldEntity | undefined {
|
|
59
|
+
const existing = this.entities.get(id)
|
|
60
|
+
if (!existing) return undefined
|
|
61
|
+
const updated: WorldEntity = { ...existing, ...partial }
|
|
62
|
+
this.registerEntity(updated)
|
|
63
|
+
return updated
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
removeEntity(id: string): boolean {
|
|
67
|
+
const existing = this.entities.get(id)
|
|
68
|
+
if (!existing) return false
|
|
69
|
+
if (existing.zoneId && this.entityZoneIndex.has(existing.zoneId)) {
|
|
70
|
+
this.entityZoneIndex.get(existing.zoneId)!.delete(id)
|
|
71
|
+
}
|
|
72
|
+
return this.entities.delete(id)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
clear(): void {
|
|
76
|
+
this.entities.clear()
|
|
77
|
+
this.zones.clear()
|
|
78
|
+
this.entityZoneIndex.clear()
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
export type Vector3Tuple = [number, number, number]
|
|
2
|
+
|
|
3
|
+
export type EntityType =
|
|
4
|
+
| 'person'
|
|
5
|
+
| 'actor'
|
|
6
|
+
| 'object'
|
|
7
|
+
| 'equipment'
|
|
8
|
+
| 'vehicle'
|
|
9
|
+
| 'building'
|
|
10
|
+
| 'structure'
|
|
11
|
+
| 'zone'
|
|
12
|
+
| (string & {})
|
|
13
|
+
|
|
14
|
+
export type EntityStatus =
|
|
15
|
+
| 'idle'
|
|
16
|
+
| 'running'
|
|
17
|
+
| 'working'
|
|
18
|
+
| 'awaiting_approval'
|
|
19
|
+
| 'completed'
|
|
20
|
+
| 'failed'
|
|
21
|
+
| 'offline'
|
|
22
|
+
| (string & {})
|
|
23
|
+
|
|
24
|
+
export interface WorldEntity {
|
|
25
|
+
id: string
|
|
26
|
+
type: EntityType
|
|
27
|
+
name: string
|
|
28
|
+
role?: string
|
|
29
|
+
department?: string
|
|
30
|
+
zoneId?: string
|
|
31
|
+
description?: string
|
|
32
|
+
status?: EntityStatus
|
|
33
|
+
position: Vector3Tuple
|
|
34
|
+
rotation?: Vector3Tuple
|
|
35
|
+
scale?: Vector3Tuple
|
|
36
|
+
avatarColor?: string
|
|
37
|
+
avatarHair?: string
|
|
38
|
+
deskColor?: string
|
|
39
|
+
pinNumber?: number | string
|
|
40
|
+
pinLabel?: string
|
|
41
|
+
metadata?: Record<string, unknown>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface WorldZone {
|
|
45
|
+
id: string
|
|
46
|
+
name: string
|
|
47
|
+
color?: string
|
|
48
|
+
description?: string
|
|
49
|
+
bounds?: {
|
|
50
|
+
minX: number
|
|
51
|
+
maxX: number
|
|
52
|
+
minZ: number
|
|
53
|
+
maxZ: number
|
|
54
|
+
}
|
|
55
|
+
cameraFocus?: Vector3Tuple
|
|
56
|
+
metadata?: Record<string, unknown>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface CameraConfiguration {
|
|
60
|
+
position: Vector3Tuple
|
|
61
|
+
target: Vector3Tuple
|
|
62
|
+
fov?: number
|
|
63
|
+
near?: number
|
|
64
|
+
far?: number
|
|
65
|
+
enableDamping?: boolean
|
|
66
|
+
dampingFactor?: number
|
|
67
|
+
minDistance?: number
|
|
68
|
+
maxDistance?: number
|
|
69
|
+
maxPolarAngle?: number
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface LightingConfiguration {
|
|
73
|
+
ambientColor?: string
|
|
74
|
+
ambientIntensity?: number
|
|
75
|
+
sunColor?: string
|
|
76
|
+
sunIntensity?: number
|
|
77
|
+
sunPosition?: Vector3Tuple
|
|
78
|
+
nightAmbientColor?: string
|
|
79
|
+
nightAmbientIntensity?: number
|
|
80
|
+
nightSunColor?: string
|
|
81
|
+
nightSunIntensity?: number
|
|
82
|
+
shadows?: boolean
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface WorldTheme {
|
|
86
|
+
name: string
|
|
87
|
+
floorColor?: string
|
|
88
|
+
woodFloorColor?: string
|
|
89
|
+
wallColor?: string
|
|
90
|
+
wallFrameColor?: string
|
|
91
|
+
glassColor?: string
|
|
92
|
+
glassOpacity?: number
|
|
93
|
+
accentColor?: string
|
|
94
|
+
gridColor?: string
|
|
95
|
+
gridSize?: [number, number]
|
|
96
|
+
backgroundColor?: string
|
|
97
|
+
nightBackgroundColor?: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface WorldCapabilities {
|
|
101
|
+
supportsRaycasting?: boolean
|
|
102
|
+
supportsDayNight?: boolean
|
|
103
|
+
supportsAnimations?: boolean
|
|
104
|
+
supportsLOD?: boolean
|
|
105
|
+
supportsDynamicLabels?: boolean
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface WorldDefinition {
|
|
109
|
+
id: string
|
|
110
|
+
type: string
|
|
111
|
+
name: string
|
|
112
|
+
description?: string
|
|
113
|
+
dimensions: {
|
|
114
|
+
width: number
|
|
115
|
+
height: number
|
|
116
|
+
depth: number
|
|
117
|
+
}
|
|
118
|
+
camera: CameraConfiguration
|
|
119
|
+
lighting: LightingConfiguration
|
|
120
|
+
theme: WorldTheme
|
|
121
|
+
zones: WorldZone[]
|
|
122
|
+
entities: WorldEntity[]
|
|
123
|
+
capabilities?: WorldCapabilities
|
|
124
|
+
metadata?: Record<string, unknown>
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface CreateEnvironmentOptions {
|
|
128
|
+
preset?: WorldPreset
|
|
129
|
+
id?: string
|
|
130
|
+
type?: string
|
|
131
|
+
name?: string
|
|
132
|
+
description?: string
|
|
133
|
+
dimensions?: {
|
|
134
|
+
width: number
|
|
135
|
+
height: number
|
|
136
|
+
depth: number
|
|
137
|
+
}
|
|
138
|
+
camera?: Partial<CameraConfiguration>
|
|
139
|
+
lighting?: Partial<LightingConfiguration>
|
|
140
|
+
theme?: Partial<WorldTheme>
|
|
141
|
+
zones?: WorldZone[]
|
|
142
|
+
entities?: WorldEntity[]
|
|
143
|
+
metadata?: Record<string, unknown>
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface WorldPreset {
|
|
147
|
+
id: string
|
|
148
|
+
name: string
|
|
149
|
+
type: string
|
|
150
|
+
description?: string
|
|
151
|
+
dimensions: {
|
|
152
|
+
width: number
|
|
153
|
+
height: number
|
|
154
|
+
depth: number
|
|
155
|
+
}
|
|
156
|
+
camera: CameraConfiguration
|
|
157
|
+
lighting: LightingConfiguration
|
|
158
|
+
theme: WorldTheme
|
|
159
|
+
zones: WorldZone[]
|
|
160
|
+
defaultEntities?: WorldEntity[]
|
|
161
|
+
buildScene?: (scene: import('three').Scene, options: { nightMode?: boolean; theme?: WorldTheme }) => void
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export type PinDisplayMode = 'pins' | 'labels' | 'off'
|
|
165
|
+
|
|
166
|
+
export interface EntitySelectedEvent {
|
|
167
|
+
entity: WorldEntity
|
|
168
|
+
position: Vector3Tuple
|
|
169
|
+
screenPosition?: { x: number; y: number }
|
|
170
|
+
}
|