Jello with clock

by Chantal Roth

HTML

<div id="container"></div>
<script async src="https://unpkg.com/es-module-shims@1.6.3/dist/es-module-shims.js"></script>

<script type="importmap">
  {
    "imports": {
      "three": "https://unpkg.com/three@0.150.1/build/three.module.js",
      "three/addons/": "https://unpkg.com/three@0.150.1/examples/jsm/"
    }
  }
</script>
<style>
body {
  margin: 0;
  overflow: hidden;
  background-color: #000;
}
#container {
  width: 100%;
  height: 100vh;
}
</style>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

let container, camera, scene, renderer, controls;
let jelloMesh, gridMesh, probeMesh;
let jelloOriginalPos, gridOriginalPos;
let clock = new THREE.Clock();

// --- Clocks Globals ---
let labClockObj, insideClockObj;        // Mechanical
let labLightClockObj, insideLightClockObj; // Light Clocks
let properTimeAccumulated = 0;
let lastCoordinateTime = 0;

// Matrix DOM elements
let matrixDiv, matrixContainer, matrixTitle;
let matrixCells = [];

// Simulation Parameters
const params = {
    color: 0x00aaff,
    opacity: 0.5,
    shininess: 90,
    
    // Visual Toggles
    showGrid: false,
    showMetric: true,
    clockType: 'Mechanical', // Options: 'Mechanical', 'Light Clock'
    tensorMode: '4D Spacetime',

    // Probe Position (Where we measure)
    probeX: 0.5,
    probeY: 0.5,
    probeZ: 0.5,

    // Static Deformations (Relativity)
    stretchX: 1.0, stretchY: 1.0, stretchZ: 1.0,
    bendX: 0.0, bendY: 0.0, bendZ: 0.0,
    twist: 0.0, 
    
    // Dynamic Jiggles
    waveEnabled: false, waveSpeed: 2.0, waveFrequency: 2.0, waveAmplitude: 0.1,
    pulseEnabled: false, pulseSpeed: 3.0, pulseFrequency: 1.5, pulseAmplitude: 0.05,
    wobbleEnabled: false, wobbleSpeed: 4.0, wobbleAmplitude: 0.2,
    twistWaveEnabled: false, twistWaveSpeed: 3.0,...