File size: 50,758 Bytes
f3bf06b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Agentic Demo - Dynamic Fractals & 3D Control</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
background: linear-gradient(135deg, #0c0c0c 0%, #1a1a2e 50%, #16213e 100%);
font-family: 'Courier New', monospace;
color: #00ff88;
overflow: hidden;
}
.dashboard {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: grid;
grid-template-columns: 300px 1fr 300px;
grid-template-rows: 60px 1fr 200px;
gap: 10px;
padding: 10px;
box-sizing: border-box;
}
.header {
grid-column: 1 / -1;
background: rgba(0, 255, 136, 0.1);
border: 1px solid #00ff88;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
backdrop-filter: blur(10px);
}
.ai-panel {
background: rgba(0, 255, 136, 0.05);
border: 1px solid #00ff88;
border-radius: 8px;
padding: 15px;
backdrop-filter: blur(10px);
overflow-y: auto;
}
.viz-container {
position: relative;
border: 1px solid #00ff88;
border-radius: 8px;
overflow: hidden;
background: rgba(0, 0, 0, 0.3);
}
.control-panel {
grid-column: 1 / -1;
background: rgba(0, 255, 136, 0.05);
border: 1px solid #00ff88;
border-radius: 8px;
padding: 15px;
backdrop-filter: blur(10px);
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 15px;
}
.agent-card {
background: rgba(0, 255, 136, 0.1);
border: 1px solid #00ff88;
border-radius: 4px;
padding: 10px;
margin-bottom: 10px;
transition: all 0.3s ease;
}
.agent-card:hover {
background: rgba(0, 255, 136, 0.2);
transform: translateX(5px);
}
.agent-status {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 8px;
}
.active { background: #00ff88; }
.idle { background: #ffaa00; }
.error { background: #ff4444; }
button {
background: linear-gradient(45deg, #00ff88, #00cc66);
border: none;
border-radius: 4px;
color: #000;
padding: 8px 16px;
font-weight: bold;
cursor: pointer;
transition: all 0.3s ease;
font-family: inherit;
}
button:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 255, 136, 0.3);
}
.code-block {
background: rgba(0, 0, 0, 0.6);
border: 1px solid #333;
border-radius: 4px;
padding: 10px;
font-family: 'Courier New', monospace;
font-size: 12px;
margin: 10px 0;
overflow-x: auto;
}
.log-entry {
background: rgba(0, 255, 136, 0.1);
border-left: 3px solid #00ff88;
padding: 8px;
margin: 5px 0;
border-radius: 0 4px 4px 0;
font-size: 12px;
}
input[type="range"] {
width: 100%;
margin: 10px 0;
}
.fractal-params {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
margin-top: 10px;
}
.param-group {
display: flex;
flex-direction: column;
gap: 5px;
}
label {
font-size: 12px;
color: #00ff88;
}
</style>
</head>
<body>
<div class="dashboard">
<div class="header">
<h1>🤖 AI Agentic Control System</h1>
<div>
<span id="status">🟢 System Active</span>
<span style="margin-left: 20px;">FPS: <span id="fps">60</span></span>
</div>
</div>
<div class="ai-panel">
<h3>🧠 AI Agents</h3>
<div id="agents-container">
<!-- Agents will be populated here -->
</div>
<h4>📊 System Logs</h4>
<div id="logs-container">
<!-- Logs will appear here -->
</div>
</div>
<div class="viz-container">
<canvas id="three-canvas"></canvas>
</div>
<div class="ai-panel">
<h3>🔧 Dynamic Code Engine</h3>
<button onclick="updateFractalCode()">🔄 Evolve Fractal</button>
<button onclick="generateNewSurface()">🌊 New Surface</button>
<div class="code-block" id="current-code">
// Current fractal function
z = z² + c
</div>
<h4>🎯 Active Targets</h4>
<div id="targets-list">
<div class="log-entry">Target: Web App Control</div>
<div class="log-entry">Target: Fractal Evolution</div>
<div class="log-entry">Target: 3D Animation</div>
</div>
</div>
<div class="control-panel">
<div>
<h4>🌀 Fractal Controls</h4>
<div class="fractal-params">
<div class="param-group">
<label>Iterations:</label>
<input type="range" id="iterations" min="10" max="200" value="50">
</div>
<div class="param-group">
<label>Zoom:</label>
<input type="range" id="zoom" min="0.1" max="5" step="0.1" value="1">
</div>
<div class="param-group">
<label>C Real:</label>
<input type="range" id="c-real" min="-2" max="2" step="0.01" value="-0.7">
</div>
<div class="param-group">
<label>C Imag:</label>
<input type="range" id="c-imag" min="-2" max="2" step="0.01" value="0.27">
</div>
</div>
</div>
<div>
<h4>🏙️ City Controls</h4>
<button onclick="addPerson()">🚶 Add Person</button>
<button onclick="addVehicle()">🚗 Add Vehicle</button>
<button onclick="addAnimal()">🐕 Add Animal</button>
<button onclick="toggleTimeSpeed()">⏰ Time Speed</button>
</div>
<div>
<h4>☀️ Day/Night</h4>
<button onclick="forceDayTime()">☀️ Force Day</button>
<button onclick="forceNightTime()">🌙 Force Night</button>
<button onclick="randomizeColors()">🎨 Colors</button>
<button onclick="addControlPoint()">✨ Add Orb</button>
</div>
<div>
<h4>🚀 Agent Actions</h4>
<button onclick="deployAgent('fractal')">🌀 Fractal Agent</button>
<button onclick="deployAgent('visual')">👁️ Visual Agent</button>
<button onclick="deployAgent('control')">🎮 Control Agent</button>
<button onclick="deployAgent('browser')">🌐 Browser Agent</button>
</div>
<div>
<h4>📡 System Status</h4>
<div style="font-size: 12px;">
<div>People: <span id="people-count">8</span></div>
<div>Vehicles: <span id="vehicle-count">9</span></div>
<div>Animals: <span id="animal-count">11</span></div>
<div>Time: <span id="time-cycle">Day</span></div>
</div>
</div>
</div>
</div>
<script>
// AI Agent System
class AIAgent {
constructor(name, type, color) {
this.name = name;
this.type = type;
this.color = color;
this.status = 'idle';
this.tasks = [];
this.lastUpdate = Date.now();
}
execute(task) {
this.status = 'active';
this.tasks.push(task);
addLog(`${this.name}: Executing ${task}`);
// Simulate agent work
setTimeout(() => {
this.status = 'idle';
addLog(`${this.name}: Completed ${task}`);
}, Math.random() * 2000 + 1000);
}
}
// Initialize AI Agents
const agents = [
new AIAgent('Fractal-AI', 'computation', '#00ff88'),
new AIAgent('Visual-AI', 'graphics', '#ff6b6b'),
new AIAgent('Control-AI', 'interface', '#4ecdc4'),
new AIAgent('Browser-AI', 'automation', '#45b7d1')
];
// Three.js Setup
let scene, camera, renderer, fractalMesh, controlPoints = [];
let animationId;
let isAnimating = true;
// City elements
let buildings = [];
let people = [];
let vehicles = [];
let animals = [];
let dayNightCycle = { time: 0, sunLight: null, moonLight: null, ambientLight: null };
function initThreeJS() {
const container = document.getElementById('three-canvas');
const rect = container.parentElement.getBoundingClientRect();
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, rect.width / rect.height, 0.1, 1000);
renderer = new THREE.WebGLRenderer({ canvas: container, alpha: true });
renderer.setSize(rect.width, rect.height);
renderer.setClearColor(0x87CEEB, 1.0); // Sky blue
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
// Setup lighting system
setupLighting();
// Create city environment
createCity();
createPeople();
createVehicles();
createAnimals();
// Create dynamic fractal surface (smaller, positioned as part of city)
createFractalSurface();
camera.position.set(0, 8, 12);
camera.lookAt(0, 0, 0);
animate();
}
function setupLighting() {
// Ambient light
dayNightCycle.ambientLight = new THREE.AmbientLight(0x404040, 0.3);
scene.add(dayNightCycle.ambientLight);
// Sun light
dayNightCycle.sunLight = new THREE.DirectionalLight(0xffffff, 1.0);
dayNightCycle.sunLight.position.set(10, 10, 5);
dayNightCycle.sunLight.castShadow = true;
dayNightCycle.sunLight.shadow.mapSize.width = 2048;
dayNightCycle.sunLight.shadow.mapSize.height = 2048;
scene.add(dayNightCycle.sunLight);
// Moon light
dayNightCycle.moonLight = new THREE.DirectionalLight(0x6666ff, 0.3);
dayNightCycle.moonLight.position.set(-10, 8, -5);
dayNightCycle.moonLight.castShadow = true;
dayNightCycle.moonLight.visible = false;
scene.add(dayNightCycle.moonLight);
}
function createCity() {
// Ground
const groundGeometry = new THREE.PlaneGeometry(20, 20);
const groundMaterial = new THREE.MeshLambertMaterial({ color: 0x444444 });
const ground = new THREE.Mesh(groundGeometry, groundMaterial);
ground.rotation.x = -Math.PI / 2;
ground.receiveShadow = true;
scene.add(ground);
// Create buildings with animated windows
for (let i = 0; i < 12; i++) {
createBuilding(
(Math.random() - 0.5) * 15,
0,
(Math.random() - 0.5) * 15
);
}
// Streets
createStreets();
}
function createBuilding(x, y, z) {
const height = Math.random() * 4 + 2;
const width = Math.random() * 1.5 + 1;
const depth = Math.random() * 1.5 + 1;
// Building structure
const buildingGeometry = new THREE.BoxGeometry(width, height, depth);
const buildingMaterial = new THREE.MeshLambertMaterial({
color: new THREE.Color().setHSL(Math.random() * 0.1 + 0.15, 0.3, 0.4)
});
const building = new THREE.Mesh(buildingGeometry, buildingMaterial);
building.position.set(x, height / 2, z);
building.castShadow = true;
building.receiveShadow = true;
scene.add(building);
// Create windows
const windows = [];
const windowsX = Math.floor(width * 4);
const windowsY = Math.floor(height * 3);
for (let wx = 0; wx < windowsX; wx++) {
for (let wy = 0; wy < windowsY; wy++) {
const windowGeometry = new THREE.PlaneGeometry(0.15, 0.15);
const windowMaterial = new THREE.MeshBasicMaterial({
color: 0x444444,
transparent: true,
opacity: 0.8
});
const window = new THREE.Mesh(windowGeometry, windowMaterial);
window.position.set(
x + (wx - windowsX/2) * 0.2,
y + (wy - windowsY/2) * 0.3 + height/2,
z + width/2 + 0.01
);
window.userData = {
isOn: Math.random() > 0.5,
flickerTimer: Math.random() * 1000
};
windows.push(window);
scene.add(window);
}
}
buildings.push({ structure: building, windows: windows });
}
function createStreets() {
// Main streets
const streetMaterial = new THREE.MeshLambertMaterial({ color: 0x333333 });
// Horizontal street
const hStreetGeometry = new THREE.PlaneGeometry(20, 1);
const hStreet = new THREE.Mesh(hStreetGeometry, streetMaterial);
hStreet.rotation.x = -Math.PI / 2;
hStreet.position.y = 0.01;
scene.add(hStreet);
// Vertical street
const vStreetGeometry = new THREE.PlaneGeometry(1, 20);
const vStreet = new THREE.Mesh(vStreetGeometry, streetMaterial);
vStreet.rotation.x = -Math.PI / 2;
vStreet.position.y = 0.01;
scene.add(vStreet);
}
function createPeople() {
for (let i = 0; i < 8; i++) {
const person = createPerson();
people.push(person);
scene.add(person.group);
}
}
function createPerson() {
const group = new THREE.Group();
// Body
const bodyGeometry = new THREE.CylinderGeometry(0.1, 0.15, 0.4);
const bodyMaterial = new THREE.MeshLambertMaterial({
color: new THREE.Color().setHSL(Math.random(), 0.6, 0.5)
});
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.position.y = 0.4;
group.add(body);
// Head
const headGeometry = new THREE.SphereGeometry(0.08);
const headMaterial = new THREE.MeshLambertMaterial({ color: 0xffdbac });
const head = new THREE.Mesh(headGeometry, headMaterial);
head.position.y = 0.7;
group.add(head);
// Position and movement
const path = createRandomPath();
group.position.copy(path[0]);
group.castShadow = true;
return {
group: group,
path: path,
pathIndex: 0,
speed: Math.random() * 0.02 + 0.01,
walkCycle: 0
};
}
function createVehicles() {
// Cars
for (let i = 0; i < 4; i++) {
const car = createCar();
vehicles.push(car);
scene.add(car.group);
}
// Trucks
for (let i = 0; i < 2; i++) {
const truck = createTruck();
vehicles.push(truck);
scene.add(truck.group);
}
// Bicycles
for (let i = 0; i < 3; i++) {
const bicycle = createBicycle();
vehicles.push(bicycle);
scene.add(bicycle.group);
}
}
function createCar() {
const group = new THREE.Group();
// Car body
const bodyGeometry = new THREE.BoxGeometry(0.8, 0.3, 0.4);
const bodyMaterial = new THREE.MeshLambertMaterial({
color: new THREE.Color().setHSL(Math.random(), 0.8, 0.5)
});
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.position.y = 0.2;
group.add(body);
// Wheels
const wheelGeometry = new THREE.CylinderGeometry(0.08, 0.08, 0.05);
const wheelMaterial = new THREE.MeshLambertMaterial({ color: 0x222222 });
const wheels = [];
const wheelPositions = [
[-0.3, 0.08, -0.15], [0.3, 0.08, -0.15],
[-0.3, 0.08, 0.15], [0.3, 0.08, 0.15]
];
wheelPositions.forEach(pos => {
const wheel = new THREE.Mesh(wheelGeometry, wheelMaterial);
wheel.position.set(...pos);
wheel.rotation.z = Math.PI / 2;
wheels.push(wheel);
group.add(wheel);
});
const path = createVehiclePath();
group.position.copy(path[0]);
group.castShadow = true;
return {
group: group,
wheels: wheels,
path: path,
pathIndex: 0,
speed: Math.random() * 0.05 + 0.03,
type: 'car'
};
}
function createTruck() {
const group = new THREE.Group();
// Truck body
const bodyGeometry = new THREE.BoxGeometry(1.2, 0.5, 0.6);
const bodyMaterial = new THREE.MeshLambertMaterial({ color: 0x8B4513 });
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.position.y = 0.3;
group.add(body);
// Cab
const cabGeometry = new THREE.BoxGeometry(0.4, 0.4, 0.6);
const cabMaterial = new THREE.MeshLambertMaterial({ color: 0x654321 });
const cab = new THREE.Mesh(cabGeometry, cabMaterial);
cab.position.set(-0.5, 0.4, 0);
group.add(cab);
const path = createVehiclePath();
group.position.copy(path[0]);
group.castShadow = true;
return {
group: group,
path: path,
pathIndex: 0,
speed: Math.random() * 0.03 + 0.02,
type: 'truck'
};
}
function createBicycle() {
const group = new THREE.Group();
// Frame
const frameGeometry = new THREE.CylinderGeometry(0.02, 0.02, 0.6);
const frameMaterial = new THREE.MeshLambertMaterial({ color: 0x0066cc });
const frame = new THREE.Mesh(frameGeometry, frameMaterial);
frame.position.y = 0.15;
frame.rotation.z = Math.PI / 6;
group.add(frame);
// Wheels
const wheelGeometry = new THREE.TorusGeometry(0.12, 0.02, 8, 16);
const wheelMaterial = new THREE.MeshLambertMaterial({ color: 0x333333 });
const frontWheel = new THREE.Mesh(wheelGeometry, wheelMaterial);
frontWheel.position.set(0.3, 0.12, 0);
group.add(frontWheel);
const backWheel = new THREE.Mesh(wheelGeometry, wheelMaterial);
backWheel.position.set(-0.3, 0.12, 0);
group.add(backWheel);
const path = createRandomPath();
group.position.copy(path[0]);
group.castShadow = true;
return {
group: group,
wheels: [frontWheel, backWheel],
path: path,
pathIndex: 0,
speed: Math.random() * 0.04 + 0.02,
type: 'bicycle'
};
}
function createAnimals() {
// Dogs
for (let i = 0; i < 3; i++) {
const dog = createDog();
animals.push(dog);
scene.add(dog.group);
}
// Cats
for (let i = 0; i < 2; i++) {
const cat = createCat();
animals.push(cat);
scene.add(cat.group);
}
// Birds
for (let i = 0; i < 6; i++) {
const bird = createBird();
animals.push(bird);
scene.add(bird.group);
}
}
function createDog() {
const group = new THREE.Group();
// Body
const bodyGeometry = new THREE.BoxGeometry(0.3, 0.15, 0.15);
const bodyMaterial = new THREE.MeshLambertMaterial({ color: 0x8B4513 });
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.position.y = 0.1;
group.add(body);
// Head
const headGeometry = new THREE.BoxGeometry(0.12, 0.1, 0.1);
const head = new THREE.Mesh(headGeometry, bodyMaterial);
head.position.set(0.2, 0.12, 0);
group.add(head);
// Tail
const tailGeometry = new THREE.CylinderGeometry(0.02, 0.02, 0.1);
const tail = new THREE.Mesh(tailGeometry, bodyMaterial);
tail.position.set(-0.15, 0.15, 0);
tail.rotation.z = Math.PI / 4;
group.add(tail);
const path = createRandomPath();
group.position.copy(path[0]);
group.castShadow = true;
return {
group: group,
tail: tail,
path: path,
pathIndex: 0,
speed: Math.random() * 0.03 + 0.02,
type: 'dog',
tailWag: 0
};
}
function createCat() {
const group = new THREE.Group();
// Body
const bodyGeometry = new THREE.BoxGeometry(0.25, 0.1, 0.1);
const bodyMaterial = new THREE.MeshLambertMaterial({ color: 0x696969 });
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
body.position.y = 0.08;
group.add(body);
// Head
const headGeometry = new THREE.SphereGeometry(0.05);
const head = new THREE.Mesh(headGeometry, bodyMaterial);
head.position.set(0.15, 0.1, 0);
group.add(head);
const path = createRandomPath();
group.position.copy(path[0]);
group.castShadow = true;
return {
group: group,
path: path,
pathIndex: 0,
speed: Math.random() * 0.025 + 0.015,
type: 'cat'
};
}
function createBird() {
const group = new THREE.Group();
// Body
const bodyGeometry = new THREE.SphereGeometry(0.04);
const bodyMaterial = new THREE.MeshLambertMaterial({
color: new THREE.Color().setHSL(Math.random(), 0.7, 0.6)
});
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
group.add(body);
// Wings
const wingGeometry = new THREE.PlaneGeometry(0.08, 0.03);
const wingMaterial = new THREE.MeshLambertMaterial({
color: bodyMaterial.color,
transparent: true,
opacity: 0.8
});
const leftWing = new THREE.Mesh(wingGeometry, wingMaterial);
leftWing.position.set(-0.05, 0, 0);
leftWing.rotation.z = Math.PI / 6;
group.add(leftWing);
const rightWing = new THREE.Mesh(wingGeometry, wingMaterial);
rightWing.position.set(0.05, 0, 0);
rightWing.rotation.z = -Math.PI / 6;
group.add(rightWing);
group.position.set(
(Math.random() - 0.5) * 15,
Math.random() * 3 + 2,
(Math.random() - 0.5) * 15
);
return {
group: group,
wings: [leftWing, rightWing],
flightPath: Math.random() * Math.PI * 2,
flightRadius: Math.random() * 5 + 2,
height: group.position.y,
speed: Math.random() * 0.02 + 0.01,
wingFlap: 0,
type: 'bird'
};
}
function createRandomPath() {
const path = [];
for (let i = 0; i < 6; i++) {
path.push(new THREE.Vector3(
(Math.random() - 0.5) * 15,
0,
(Math.random() - 0.5) * 15
));
}
return path;
}
function createVehiclePath() {
// Create paths along streets
const paths = [
// Horizontal street
[
new THREE.Vector3(-10, 0, 0),
new THREE.Vector3(10, 0, 0)
],
// Vertical street
[
new THREE.Vector3(0, 0, -10),
new THREE.Vector3(0, 0, 10)
]
];
return paths[Math.floor(Math.random() * paths.length)];
}
function createFractalSurface() {
const geometry = new THREE.PlaneGeometry(2, 2, 32, 32);
const vertices = geometry.attributes.position.array;
// Generate fractal heightmap
for (let i = 0; i < vertices.length; i += 3) {
const x = vertices[i];
const y = vertices[i + 1];
// Mandelbrot-inspired surface
const c_real = parseFloat(document.getElementById('c-real')?.value || -0.7);
const c_imag = parseFloat(document.getElementById('c-imag')?.value || 0.27);
const zoom = parseFloat(document.getElementById('zoom')?.value || 1);
let z_real = x * zoom;
let z_imag = y * zoom;
let iterations = 0;
const maxIter = parseInt(document.getElementById('iterations')?.value || 50);
while (z_real * z_real + z_imag * z_imag < 4 && iterations < maxIter) {
const temp = z_real * z_real - z_imag * z_imag + c_real;
z_imag = 2 * z_real * z_imag + c_imag;
z_real = temp;
iterations++;
}
vertices[i + 2] = (iterations / maxIter) * 0.3 * Math.sin(Date.now() * 0.001 + x + y);
}
geometry.attributes.position.needsUpdate = true;
geometry.computeVertexNormals();
// Dynamic material with time-based colors
const material = new THREE.MeshPhongMaterial({
color: new THREE.Color().setHSL((Date.now() * 0.0001) % 1, 0.7, 0.6),
wireframe: false,
transparent: true,
opacity: 0.6
});
if (fractalMesh) {
scene.remove(fractalMesh);
}
fractalMesh = new THREE.Mesh(geometry, material);
fractalMesh.position.set(5, 0.5, 5); // Position in city as art installation
fractalMesh.rotation.x = -Math.PI / 2;
scene.add(fractalMesh);
}
function updateDayNightCycle() {
dayNightCycle.time += 0.001;
const cycle = (Math.sin(dayNightCycle.time) + 1) / 2; // 0 to 1
// Sun position (spherical path)
const sunAngle = dayNightCycle.time;
const sunRadius = 15;
dayNightCycle.sunLight.position.set(
Math.cos(sunAngle) * sunRadius,
Math.sin(sunAngle) * sunRadius,
5
);
// Moon position (opposite to sun)
const moonAngle = sunAngle + Math.PI;
dayNightCycle.moonLight.position.set(
Math.cos(moonAngle) * sunRadius,
Math.sin(moonAngle) * sunRadius,
-5
);
// Day/night lighting
if (cycle > 0.5) {
// Day time
dayNightCycle.sunLight.visible = true;
dayNightCycle.moonLight.visible = false;
dayNightCycle.sunLight.intensity = cycle;
dayNightCycle.ambientLight.intensity = cycle * 0.5;
// Sky color transition
const skyHue = 0.55; // Blue
const skySaturation = 0.6;
const skyLightness = 0.4 + cycle * 0.4;
renderer.setClearColor(new THREE.Color().setHSL(skyHue, skySaturation, skyLightness));
} else {
// Night time
dayNightCycle.sunLight.visible = false;
dayNightCycle.moonLight.visible = true;
dayNightCycle.moonLight.intensity = (1 - cycle) * 0.3;
dayNightCycle.ambientLight.intensity = (1 - cycle) * 0.2;
// Night sky
const skyHue = 0.65; // Dark blue
const skySaturation = 0.8;
const skyLightness = 0.1 + (1 - cycle) * 0.1;
renderer.setClearColor(new THREE.Color().setHSL(skyHue, skySaturation, skyLightness));
}
}
function updateBuildingWindows() {
const isNight = (Math.sin(dayNightCycle.time) + 1) / 2 < 0.5;
buildings.forEach(building => {
building.windows.forEach(window => {
window.userData.flickerTimer += 16; // ~60fps
// More lights on at night
const lightProbability = isNight ? 0.7 : 0.2;
if (window.userData.flickerTimer > 1000 + Math.random() * 2000) {
window.userData.isOn = Math.random() < lightProbability;
window.userData.flickerTimer = 0;
}
if (window.userData.isOn) {
const warmth = Math.random() * 0.1 + 0.1;
window.material.color.setHSL(warmth, 0.8, 0.6);
window.material.opacity = 0.9;
} else {
window.material.color.setRGB(0.2, 0.2, 0.3);
window.material.opacity = 0.3;
}
});
});
}
function updatePeople() {
people.forEach(person => {
const path = person.path;
const currentPos = path[person.pathIndex];
const nextPos = path[(person.pathIndex + 1) % path.length];
// Move towards next position
const direction = new THREE.Vector3().subVectors(nextPos, currentPos).normalize();
person.group.position.add(direction.multiplyScalar(person.speed));
// Rotation to face movement direction
person.group.lookAt(person.group.position.clone().add(direction));
// Walking animation
person.walkCycle += 0.3;
person.group.children[0].rotation.z = Math.sin(person.walkCycle) * 0.1;
// Check if reached next waypoint
if (person.group.position.distanceTo(nextPos) < 0.2) {
person.pathIndex = (person.pathIndex + 1) % path.length;
}
});
}
function updateVehicles() {
vehicles.forEach(vehicle => {
const path = vehicle.path;
const currentPos = path[vehicle.pathIndex];
const nextPos = path[(vehicle.pathIndex + 1) % path.length];
// Move towards next position
const direction = new THREE.Vector3().subVectors(nextPos, currentPos).normalize();
vehicle.group.position.add(direction.multiplyScalar(vehicle.speed));
// Rotation to face movement direction
vehicle.group.lookAt(vehicle.group.position.clone().add(direction));
// Wheel rotation for cars and bicycles
if (vehicle.wheels) {
vehicle.wheels.forEach(wheel => {
wheel.rotation.x += vehicle.speed * 2;
});
}
// Check if reached next waypoint
if (vehicle.group.position.distanceTo(nextPos) < 0.2) {
vehicle.pathIndex = (vehicle.pathIndex + 1) % path.length;
}
});
}
function updateAnimals() {
animals.forEach(animal => {
if (animal.type === 'bird') {
// Circular flight pattern
animal.flightPath += animal.speed;
animal.group.position.x = Math.cos(animal.flightPath) * animal.flightRadius;
animal.group.position.z = Math.sin(animal.flightPath) * animal.flightRadius;
animal.group.position.y = animal.height + Math.sin(animal.flightPath * 3) * 0.5;
// Wing flapping
animal.wingFlap += 0.5;
const flapAngle = Math.sin(animal.wingFlap) * 0.5;
animal.wings[0].rotation.z = Math.PI / 6 + flapAngle;
animal.wings[1].rotation.z = -Math.PI / 6 - flapAngle;
// Face flight direction
const flightDirection = new THREE.Vector3(
-Math.sin(animal.flightPath),
0,
Math.cos(animal.flightPath)
);
animal.group.lookAt(animal.group.position.clone().add(flightDirection));
} else {
// Ground animals (dogs, cats)
const path = animal.path;
const currentPos = path[animal.pathIndex];
const nextPos = path[(animal.pathIndex + 1) % path.length];
const direction = new THREE.Vector3().subVectors(nextPos, currentPos).normalize();
animal.group.position.add(direction.multiplyScalar(animal.speed));
animal.group.lookAt(animal.group.position.clone().add(direction));
// Special animations
if (animal.type === 'dog' && animal.tail) {
animal.tailWag += 0.4;
animal.tail.rotation.y = Math.sin(animal.tailWag) * 0.5;
}
if (animal.group.position.distanceTo(nextPos) < 0.1) {
animal.pathIndex = (animal.pathIndex + 1) % path.length;
}
}
});
}
function addControlPoint() {
const geometry = new THREE.SphereGeometry(0.1, 16, 16);
const material = new THREE.MeshPhongMaterial({
color: new THREE.Color().setHSL(Math.random(), 0.8, 0.6),
emissive: new THREE.Color().setHSL(Math.random(), 0.3, 0.1)
});
const sphere = new THREE.Mesh(geometry, material);
sphere.position.set(
(Math.random() - 0.5) * 16,
Math.random() * 4 + 2,
(Math.random() - 0.5) * 16
);
sphere.userData = {
velocity: new THREE.Vector3(
(Math.random() - 0.5) * 0.03,
(Math.random() - 0.5) * 0.02,
(Math.random() - 0.5) * 0.03
)
};
sphere.castShadow = true;
controlPoints.push(sphere);
scene.add(sphere);
addLog(`Control point added at (${sphere.position.x.toFixed(2)}, ${sphere.position.y.toFixed(2)})`);
}
function addPerson() {
const person = createPerson();
people.push(person);
scene.add(person.group);
addLog(`New person added to city`);
}
function addVehicle() {
const vehicleType = ['car', 'truck', 'bicycle'][Math.floor(Math.random() * 3)];
let vehicle;
if (vehicleType === 'car') vehicle = createCar();
else if (vehicleType === 'truck') vehicle = createTruck();
else vehicle = createBicycle();
vehicles.push(vehicle);
scene.add(vehicle.group);
addLog(`New ${vehicleType} added to streets`);
}
function addAnimal() {
const animalType = ['dog', 'cat', 'bird'][Math.floor(Math.random() * 3)];
let animal;
if (animalType === 'dog') animal = createDog();
else if (animalType === 'cat') animal = createCat();
else animal = createBird();
animals.push(animal);
scene.add(animal.group);
addLog(`New ${animalType} spotted in city`);
}
function toggleTimeSpeed() {
const currentSpeed = 0.001;
dayNightCycle.timeSpeed = dayNightCycle.timeSpeed === currentSpeed ? currentSpeed * 5 : currentSpeed;
addLog(`Time speed: ${dayNightCycle.timeSpeed === currentSpeed ? 'Normal' : '5x Fast'}`);
}
function forceDayTime() {
dayNightCycle.time = Math.PI / 2; // Noon
addLog('Forced to day time');
}
function forceNightTime() {
dayNightCycle.time = -Math.PI / 2; // Midnight
addLog('Forced to night time');
}
function clearControlPoints() {
controlPoints.forEach(point => scene.remove(point));
controlPoints = [];
addLog('All control points cleared');
}
function animate() {
if (!isAnimating) return;
animationId = requestAnimationFrame(animate);
// Update day/night cycle
updateDayNightCycle();
// Update building windows
updateBuildingWindows();
// Update all moving entities
updatePeople();
updateVehicles();
updateAnimals();
// Update fractal surface
if (fractalMesh) {
fractalMesh.rotation.z += 0.002;
fractalMesh.material.color.setHSL((Date.now() * 0.0001) % 1, 0.7, 0.6);
}
// Animate control points
controlPoints.forEach(point => {
point.position.add(point.userData.velocity);
// Bounce off boundaries
if (Math.abs(point.position.x) > 8) point.userData.velocity.x *= -1;
if (Math.abs(point.position.y - 2) > 4) point.userData.velocity.y *= -1;
if (Math.abs(point.position.z) > 8) point.userData.velocity.z *= -1;
// Add some orbital motion
point.rotation.x += 0.02;
point.rotation.y += 0.03;
});
renderer.render(scene, camera);
// Update FPS
updateFPS();
}
let lastTime = Date.now();
let frameCount = 0;
function updateFPS() {
frameCount++;
const now = Date.now();
if (now - lastTime >= 1000) {
document.getElementById('fps').textContent = frameCount;
frameCount = 0;
lastTime = now;
}
}
// Dynamic Code Engine
const fractalFunctions = [
"z = z² + c",
"z = z³ + c",
"z = sin(z) + c",
"z = |z|² + c",
"z = z² + c + sin(t)",
"z = z*cos(z) + c",
"z = exp(z) + c"
];
function updateFractalCode() {
const newFunction = fractalFunctions[Math.floor(Math.random() * fractalFunctions.length)];
document.getElementById('current-code').innerHTML = `// Current fractal function<br/>${newFunction}`;
createFractalSurface();
agents[0].execute('fractal code evolution');
addLog(`Fractal function updated: ${newFunction}`);
}
function generateNewSurface() {
// Randomize parameters
document.getElementById('c-real').value = (Math.random() - 0.5) * 4;
document.getElementById('c-imag').value = (Math.random() - 0.5) * 4;
document.getElementById('zoom').value = Math.random() * 3 + 0.5;
createFractalSurface();
agents[1].execute('surface generation');
}
function toggleAnimation() {
isAnimating = !isAnimating;
if (isAnimating) {
animate();
addLog('Animation resumed');
} else {
cancelAnimationFrame(animationId);
addLog('Animation paused');
}
}
function randomizeColors() {
if (fractalMesh) {
fractalMesh.material.color.setHSL(Math.random(), 0.7, 0.6);
}
controlPoints.forEach(point => {
point.material.color.setHSL(Math.random(), 0.8, 0.6);
point.material.emissive.setHSL(Math.random(), 0.3, 0.1);
});
agents[1].execute('color randomization');
}
function deployAgent(type) {
const agent = agents.find(a => a.type === type || a.name.toLowerCase().includes(type));
if (agent) {
const tasks = {
fractal: 'fractal computation optimization',
visual: 'visual enhancement protocol',
control: 'interface adaptation',
browser: 'web application orchestration'
};
agent.execute(tasks[type] || 'general task execution');
}
}
// UI Functions
function renderAgents() {
const container = document.getElementById('agents-container');
container.innerHTML = '';
agents.forEach(agent => {
const card = document.createElement('div');
card.className = 'agent-card';
card.innerHTML = `
<div>
<span class="agent-status ${agent.status}"></span>
<strong>${agent.name}</strong>
</div>
<div style="font-size: 12px; color: ${agent.color};">
${agent.type.toUpperCase()} • ${agent.tasks.length} tasks
</div>
`;
container.appendChild(card);
});
}
function addLog(message) {
const container = document.getElementById('logs-container');
const entry = document.createElement('div');
entry.className = 'log-entry';
entry.innerHTML = `<small>${new Date().toLocaleTimeString()}</small><br/>${message}`;
container.appendChild(entry);
// Keep only last 10 logs
while (container.children.length > 10) {
container.removeChild(container.firstChild);
}
container.scrollTop = container.scrollHeight;
}
function updateSystemStats() {
document.getElementById('memory-usage').textContent = `${Math.floor(Math.random() * 30 + 40)}%`;
document.getElementById('cpu-usage').textContent = `${Math.floor(Math.random() * 40 + 20)}%`;
document.getElementById('agent-count').textContent = agents.length;
document.getElementById('target-count').textContent = document.querySelectorAll('#targets-list .log-entry').length;
}
// Event Listeners
document.getElementById('iterations')?.addEventListener('input', createFractalSurface);
document.getElementById('zoom')?.addEventListener('input', createFractalSurface);
document.getElementById('c-real')?.addEventListener('input', createFractalSurface);
document.getElementById('c-imag')?.addEventListener('input', createFractalSurface);
// Initialize System
window.addEventListener('load', () => {
initThreeJS();
renderAgents();
// Add initial control points
for (let i = 0; i < 3; i++) {
setTimeout(() => addControlPoint(), i * 500);
}
// System status updates
setInterval(updateSystemStats, 2000);
setInterval(renderAgents, 1000);
// Auto-evolution
setInterval(() => {
if (Math.random() < 0.1) {
updateFractalCode();
}
}, 5000);
addLog('AI Agentic System initialized');
addLog('3D visualization engine active');
addLog('Dynamic fractal computation online');
addLog('Browser automation ready');
});
// Handle window resize
window.addEventListener('resize', () => {
const container = document.getElementById('three-canvas');
const rect = container.parentElement.getBoundingClientRect();
camera.aspect = rect.width / rect.height;
camera.updateProjectionMatrix();
renderer.setSize(rect.width, rect.height);
});
// Simulate browser automation capabilities
function simulateBrowserAutomation() {
const actions = [
'Opening new browser window',
'Navigating to target application',
'Injecting control scripts',
'Establishing WebSocket connection',
'Monitoring DOM changes',
'Executing automated interactions'
];
let index = 0;
const interval = setInterval(() => {
if (index < actions.length) {
addLog(`Browser Agent: ${actions[index]}`);
index++;
} else {
clearInterval(interval);
addLog('Browser automation sequence complete');
}
}, 1500);
}
// Simulate AI model inference
function simulateAIInference() {
const models = ['text-classification', 'object-detection', 'sentiment-analysis', 'code-generation'];
const model = models[Math.floor(Math.random() * models.length)];
addLog(`Running ${model} inference...`);
setTimeout(() => {
addLog(`${model} inference complete: confidence 0.${Math.floor(Math.random() * 30 + 70)}`);
}, Math.random() * 2000 + 500);
}
// Periodic AI activities
setInterval(simulateAIInference, 8000);
setTimeout(simulateBrowserAutomation, 3000);
</script>
</body>
</html> |