Production latest code push
This commit is contained in:
parent
bf4767d280
commit
11326bf585
Binary file not shown.
@ -1,3 +1,4 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -8,42 +9,116 @@
|
||||
</head>
|
||||
<body>
|
||||
<a-scene>
|
||||
<!-- Camera and controls -->
|
||||
<!-- Preload Assets -->
|
||||
<a-assets>
|
||||
<img id="skyTexture" src="{% static 'textures/sky.jpg' %}" />
|
||||
<img id="floorTexture" src="https://cdn.aframe.io/a-painter/images/floor.jpg" />
|
||||
</a-assets>
|
||||
|
||||
<!-- Lighting -->
|
||||
<a-entity light="type: ambient; color: #BBB"></a-entity>
|
||||
<a-entity light="type: directional; color: #FFF; intensity: 0.6" position="0 1 0"></a-entity>
|
||||
|
||||
<!-- Camera and Controls -->
|
||||
<a-entity camera look-controls wasd-controls position="0 2 0"></a-entity>
|
||||
|
||||
<!-- Sky -->
|
||||
{% load static %}
|
||||
<a-sky id="sky" src="{% static 'textures/sky.jpg' %}" radius="150"></a-sky>
|
||||
<a-sky id="sky" src="#skyTexture" radius="150"></a-sky>
|
||||
|
||||
<!-- Ground plane -->
|
||||
<a-plane position="0 -0.1 0" rotation="-90 0 0" width="200" height="200" material="src: url(https://cdn.aframe.io/a-painter/images/floor.jpg); repeat: 100 100;"></a-plane>
|
||||
<!-- Ground Plane -->
|
||||
<a-plane position="0 -0.1 0" rotation="-90 0 0" width="200" height="200"
|
||||
material="src: #floorTexture; repeat: 100 100;"></a-plane>
|
||||
|
||||
<!-- Buildings -->
|
||||
<!-- Buildings Group -->
|
||||
<a-entity id="buildings-group">
|
||||
{% for building in city_data.buildings %}
|
||||
<a-entity id="{{ building.id }}" status="{{ building.status }}">
|
||||
<a-text value="Status: {{ building.status }}" position="{{ building.position_x }} {{ building.height }} {{ building.position_z }}" scale="2 2 2"></a-text>
|
||||
<a-box position="{{ building.position_x }} 1 {{ building.position_z }}" width="{{ building.width }}" height="{{ building.height }}" depth="{{ building.depth }}" rotation="0 0 0" color="{{ building.color }}"></a-box>
|
||||
<a-entity id="building{{ building.id }}" status="{{ building.status }}"
|
||||
position="{{ building.position_x }} 1 {{ building.position_z }}"
|
||||
event-set__mouseenter="_event: mouseenter; scale: 1.1 1.1 1.1"
|
||||
event-set__mouseleave="_event: mouseleave; scale: 1 1 1">
|
||||
<a-box width="{{ building.width }}" height="{{ building.height }}" depth="{{ building.depth }}"
|
||||
color="{{ building.color }}"></a-box>
|
||||
<a-text value="Status: {{ building.status }}"
|
||||
position="0 {{ building.height|add:'1' }} 0"
|
||||
scale="1.5 1.5 1.5"></a-text>
|
||||
</a-entity>
|
||||
{% endfor %}
|
||||
</a-entity>
|
||||
|
||||
<!-- Lamps -->
|
||||
<!-- Lamps Group -->
|
||||
<a-entity id="lamps-group">
|
||||
{% for lamp in city_data.lamps %}
|
||||
<a-entity id="{{ lamp.id }}" status="{{ lamp.status }}" position="{{ lamp.position_x }} 1 {{ lamp.position_z }}">
|
||||
<a-text value="Status: {{ lamp.status }}" position="0 {{ lamp.height }} 0" scale="2 2 2"></a-text>
|
||||
<a-cone radius-bottom="0.1" radius-top="0.5" height="{{ lamp.height }}" color="{{ lamp.color }}"></a-cone>
|
||||
<a-entity id="lamp{{ lamp.id }}" status="{{ lamp.status }}"
|
||||
position="{{ lamp.position_x }} 1 {{ lamp.position_z }}"
|
||||
event-set__mouseenter="_event: mouseenter; scale: 1.1 1.1 1.1"
|
||||
event-set__mouseleave="_event: mouseleave; scale: 1 1 1">
|
||||
<a-cone radius-bottom="0.1" radius-top="0.5" height="{{ lamp.height }}"
|
||||
color="{{ lamp.color }}"></a-cone>
|
||||
<a-sphere radius="0.2" color="#FFFFFF" position="0 {{ lamp.height }} 0"></a-sphere>
|
||||
<a-text value="Status: {{ lamp.status }}"
|
||||
position="0 {{ lamp.height|add:'1' }} 0"
|
||||
scale="1.5 1.5 1.5"></a-text>
|
||||
</a-entity>
|
||||
{% endfor %}
|
||||
</a-entity>
|
||||
|
||||
<!-- Trees -->
|
||||
<!-- Trees Group -->
|
||||
<a-entity id="trees-group">
|
||||
{% for tree in city_data.trees %}
|
||||
<a-entity id="{{ tree.id }}" status="{{ tree.status }}" position="{{ tree.position_x }} 1 {{ tree.position_z }}">
|
||||
<a-text value="Status: {{ tree.status }}" position="0 {{ tree.height }} 0" scale="2 2 2"></a-text>
|
||||
<a-cone radius-bottom="{{ tree.radius_bottom }}" radius-top="{{ tree.radius_top }}" height="{{ tree.height }}" color="{{ tree.color_trunk }}"></a-cone>
|
||||
<a-sphere radius="{{ tree.radius_top }}" color="{{ tree.color_leaves }}" position="0 {{ tree.height }} 0"></a-sphere>
|
||||
<a-entity id="tree{{ tree.id }}" status="{{ tree.status }}"
|
||||
position="{{ tree.position_x }} 1 {{ tree.position_z }}"
|
||||
event-set__mouseenter="_event: mouseenter; scale: 1.1 1.1 1.1"
|
||||
event-set__mouseleave="_event: mouseleave; scale: 1 1 1">
|
||||
<a-cone radius-bottom="{{ tree.radius_bottom }}" radius-top="{{ tree.radius_top }}"
|
||||
height="{{ tree.height }}" color="{{ tree.color_trunk }}"></a-cone>
|
||||
<a-sphere radius="{{ tree.radius_top }}" color="{{ tree.color_leaves }}"
|
||||
position="0 {{ tree.height }} 0"></a-sphere>
|
||||
<a-text value="Status: {{ tree.status }}"
|
||||
position="0 {{ tree.height|add:'1' }} 0"
|
||||
scale="1.5 1.5 1.5"></a-text>
|
||||
</a-entity>
|
||||
{% endfor %}
|
||||
</a-entity>
|
||||
|
||||
<!-- Cell Towers Group -->
|
||||
<a-entity id="towers-group">
|
||||
{% for tower in city_data.towers %}
|
||||
<a-entity id="tower{{ tower.id }}" position="{{ tower.position_x }} 0 {{ tower.position_z }}"
|
||||
event-set__mouseenter="_event: mouseenter; scale: 1.1 1.1 1.1"
|
||||
event-set__mouseleave="_event: mouseleave; scale: 1 1 1">
|
||||
<a-cylinder height="{{ tower.height }}" radius="2" color="{{ tower.color }}"></a-cylinder>
|
||||
<a-text value="📡 Tower {{ tower.id }} - {{ tower.status }}"
|
||||
position="0 {{ tower.height|add:'1' }} 0" scale="1.5 1.5 1.5"></a-text>
|
||||
</a-entity>
|
||||
{% endfor %}
|
||||
</a-entity>
|
||||
|
||||
<!-- Fiber Paths Group -->
|
||||
<a-entity id="fiber-paths-group">
|
||||
{% for fiber in city_data.fiber_paths %}
|
||||
<a-entity id="fiber{{ fiber.id }}">
|
||||
<a-line start="{{ fiber.start_x }} 0 {{ fiber.start_z }}"
|
||||
end="{{ fiber.end_x }} 0 {{ fiber.end_z }}"
|
||||
color="{{ fiber.color }}"></a-line>
|
||||
<a-text value="🔗 Fiber Path {{ fiber.id }} - {{ fiber.status }}"
|
||||
position="{{ fiber.start_x }} 1 {{ fiber.start_z }}"
|
||||
scale="1.2 1.2 1.2"></a-text>
|
||||
</a-entity>
|
||||
{% endfor %}
|
||||
</a-entity>
|
||||
|
||||
<!-- Wi-Fi Hotspots Group -->
|
||||
<a-entity id="wifi-group">
|
||||
{% for wifi in city_data.wifi_hotspots %}
|
||||
<a-entity id="wifi{{ wifi.id }}" position="{{ wifi.position_x }} 0 {{ wifi.position_z }}"
|
||||
event-set__mouseenter="_event: mouseenter; scale: 1.1 1.1 1.1"
|
||||
event-set__mouseleave="_event: mouseleave; scale: 1 1 1">
|
||||
<a-sphere radius="2" color="{{ wifi.color }}"></a-sphere>
|
||||
<a-text value="📶 WiFi {{ wifi.id }} - {{ wifi.status }}"
|
||||
position="0 3 0" scale="1.2 1.2 1.2"></a-text>
|
||||
</a-entity>
|
||||
{% endfor %}
|
||||
</a-entity>
|
||||
|
||||
</a-scene>
|
||||
<script src="{% static 'js/lds_city_vr.js' %}"></script>
|
||||
|
57
views.py
57
views.py
@ -7,6 +7,8 @@ def city_digital_twin(request, city_id, innovation_pct=None, technology_pct=None
|
||||
try:
|
||||
if city_id == "random_city":
|
||||
city_data = generate_random_city_data()
|
||||
elif city_id == "com_con":
|
||||
city_data = generate_com_con_city_data()
|
||||
elif city_id == "dream":
|
||||
# Retrieve percentages from GET parameters if not in URL
|
||||
innovation_pct = innovation_pct or request.GET.get('innovation', 0)
|
||||
@ -164,7 +166,6 @@ def triangular_layout(num_elements):
|
||||
return positions
|
||||
|
||||
|
||||
|
||||
def generate_random_city_data(innovation_pct=100, technology_pct=100, science_pct=100, max_position=100, radius=50):
|
||||
num_buildings = random.randint(5, 35)
|
||||
num_lamps = random.randint(5, 100)
|
||||
@ -241,3 +242,57 @@ def generate_random_city_data(innovation_pct=100, technology_pct=100, science_pc
|
||||
'lamps': lamps,
|
||||
'trees': trees,
|
||||
}
|
||||
|
||||
|
||||
def generate_com_con_city_data():
|
||||
"""
|
||||
Generates a telecom-focused digital twin for the hackathon.
|
||||
It includes cell towers, fiber paths, and optimized coverage zones.
|
||||
"""
|
||||
num_towers = random.randint(3, 10)
|
||||
num_fiber_paths = random.randint(5, 15)
|
||||
num_wifi_hotspots = random.randint(5, 20)
|
||||
|
||||
towers = [
|
||||
{
|
||||
'id': i + 1,
|
||||
'status': 'Active' if random.random() > 0.2 else 'Inactive',
|
||||
'position_x': random.uniform(-50, 50),
|
||||
'position_z': random.uniform(-50, 50),
|
||||
'height': random.randint(20, 50),
|
||||
'range': random.randint(500, 1500), # Coverage range in meters
|
||||
'color': '#ff4500' # Orange for telecom towers
|
||||
}
|
||||
for i in range(num_towers)
|
||||
]
|
||||
|
||||
fiber_paths = [
|
||||
{
|
||||
'id': i + 1,
|
||||
'start_x': random.uniform(-50, 50),
|
||||
'start_z': random.uniform(-50, 50),
|
||||
'end_x': random.uniform(-50, 50),
|
||||
'end_z': random.uniform(-50, 50),
|
||||
'status': 'Connected' if random.random() > 0.1 else 'Broken',
|
||||
'color': '#4682b4' # Steel blue for fiber cables
|
||||
}
|
||||
for i in range(num_fiber_paths)
|
||||
]
|
||||
|
||||
wifi_hotspots = [
|
||||
{
|
||||
'id': i + 1,
|
||||
'position_x': random.uniform(-50, 50),
|
||||
'position_z': random.uniform(-50, 50),
|
||||
'status': 'Online' if random.random() > 0.2 else 'Offline',
|
||||
'range': random.randint(100, 300),
|
||||
'color': '#32cd32' # Lime green for Wi-Fi coverage
|
||||
}
|
||||
for i in range(num_wifi_hotspots)
|
||||
]
|
||||
|
||||
return {
|
||||
'towers': towers,
|
||||
'fiber_paths': fiber_paths,
|
||||
'wifi_hotspots': wifi_hotspots
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user