Spaces:
Running
Running
Create main.js
Browse files
main.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// CodexReality3D — GUI + CLI Chat Engine (HF Ready)
|
| 2 |
+
|
| 3 |
+
const log = document.getElementById("log");
|
| 4 |
+
const input = document.getElementById("input");
|
| 5 |
+
const canvas = document.getElementById("viewport");
|
| 6 |
+
|
| 7 |
+
function print(msg) {
|
| 8 |
+
log.innerHTML += msg + "<br/>";
|
| 9 |
+
log.scrollTop = log.scrollHeight;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
// ---- Engine State (Simulated Core) ----
|
| 13 |
+
const engine = {
|
| 14 |
+
paused: false,
|
| 15 |
+
psi: 1.0,
|
| 16 |
+
superposition: 0.5,
|
| 17 |
+
|
| 18 |
+
injectPsi(v) {
|
| 19 |
+
this.psi = v;
|
| 20 |
+
print(`Ψ injected → ${v}`);
|
| 21 |
+
},
|
| 22 |
+
|
| 23 |
+
setSuperposition(v) {
|
| 24 |
+
this.superposition = v;
|
| 25 |
+
print(`Superposition set → ${v}`);
|
| 26 |
+
},
|
| 27 |
+
|
| 28 |
+
pause() {
|
| 29 |
+
this.paused = true;
|
| 30 |
+
print("⏸ Simulation paused");
|
| 31 |
+
},
|
| 32 |
+
|
| 33 |
+
resume() {
|
| 34 |
+
this.paused = false;
|
| 35 |
+
print("▶ Simulation resumed");
|
| 36 |
+
}
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
// ---- Command Interpreter ----
|
| 40 |
+
function handleCommand(cmd) {
|
| 41 |
+
const parts = cmd.trim().split(" ");
|
| 42 |
+
const op = parts[0];
|
| 43 |
+
const arg = parseFloat(parts[1]);
|
| 44 |
+
|
| 45 |
+
switch (op) {
|
| 46 |
+
case "help":
|
| 47 |
+
print("Commands:");
|
| 48 |
+
print(" inject <value>");
|
| 49 |
+
print(" superposition <value>");
|
| 50 |
+
print(" pause");
|
| 51 |
+
print(" resume");
|
| 52 |
+
break;
|
| 53 |
+
|
| 54 |
+
case "inject":
|
| 55 |
+
engine.injectPsi(isNaN(arg) ? 1.0 : arg);
|
| 56 |
+
break;
|
| 57 |
+
|
| 58 |
+
case "superposition":
|
| 59 |
+
engine.setSuperposition(isNaN(arg) ? 0.5 : arg);
|
| 60 |
+
break;
|
| 61 |
+
|
| 62 |
+
case "pause":
|
| 63 |
+
engine.pause();
|
| 64 |
+
break;
|
| 65 |
+
|
| 66 |
+
case "resume":
|
| 67 |
+
engine.resume();
|
| 68 |
+
break;
|
| 69 |
+
|
| 70 |
+
default:
|
| 71 |
+
print("Unknown command. Type `help`.");
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// ---- Input Handler ----
|
| 76 |
+
input.addEventListener("keydown", e => {
|
| 77 |
+
if (e.key === "Enter") {
|
| 78 |
+
print(`> ${input.value}`);
|
| 79 |
+
handleCommand(input.value);
|
| 80 |
+
input.value = "";
|
| 81 |
+
}
|
| 82 |
+
});
|
| 83 |
+
|
| 84 |
+
// ---- Boot ----
|
| 85 |
+
print("CodexReality3D Console Ready");
|
| 86 |
+
print("Type `help` to begin.");
|