feat: add orbiting newag train + improved orbiter logic

This commit is contained in:
tym2k1 2026-02-24 16:49:36 +01:00
parent 098623f86c
commit 6976096d30
No known key found for this signature in database
GPG key ID: 409330E8D7E4BF83
4 changed files with 173501 additions and 22 deletions

View file

@ -8,6 +8,6 @@ Then simply go to [http://0.0.0.0:8080](http://0.0.0.0:8080) in your browser.
# Acknowledgement # Acknowledgement
3D object by @wilyweasel - 3D onion by @wilyweasel
- 3D train by @livelovelaugh.art
Jgs font by Adel Faure. Distributed by velvetyne.fr. - Jgs font by Adel Faure. Distributed by velvetyne.fr.

10772
assets/ciapong_fill.obj Normal file

File diff suppressed because it is too large Load diff

162683
assets/ciapong_stroke.obj Normal file

File diff suppressed because it is too large Load diff

View file

@ -15,9 +15,9 @@ class RotatingOnion {
} }
// Add an orbiting object to the onion // Add an orbiting object to the onion
addOrbitingObject(model, orbitRadius, speed, scale, tiltAngleX, tiltAngleY) { addOrbitingObject(model_fill, model_stroke, orbitRadius, speed, scale, tiltAngleX, tiltAngleY) {
const tiltAngle = { x: tiltAngleX, y: tiltAngleY }; // Pass both X and Y tilt angles const tiltAngle = { x: tiltAngleX, y: tiltAngleY }; // Pass both X and Y tilt angles
this.orbitingObjects.push(new OrbitingObject(this, model, orbitRadius, speed, scale, tiltAngle)); this.orbitingObjects.push(new OrbitingObject(this, model_fill, model_stroke, orbitRadius, speed, scale, tiltAngle));
} }
update() { update() {
@ -70,18 +70,19 @@ class RotatingOnion {
} }
class OrbitingObject { class OrbitingObject {
constructor(parent, model, orbitRadius, speed, scale, tiltAngle) { constructor(parent, model_fill, model_stroke, orbitRadius, speed, scale, tiltAngle) {
this.parent = parent; // The parent object (Onion) this.parent = parent; // The parent object (Onion)
this.model = model this.model_fill = model_fill
this.model_stroke = model_stroke
this.orbitRadius = orbitRadius; this.orbitRadius = orbitRadius;
this.speed = speed; // Orbiting speed (angular speed) this.speed = speed; // Orbiting speed (angular speed)
this.scale = scale; this.scale = scale;
this.rotationAngle_x = random(360); this.rotationAngle_x = random(360);
this.rotationAngle_y = random(360); this.rotationAngle_y = random(360);
this.rotationAngle_z = random(360); this.rotationAngle_z = random(360);
this.rotationSpeed_x = random(0.5, 2); this.rotationSpeed_x = random(0.2, 1);
this.rotationSpeed_y = random(0.5, 2); this.rotationSpeed_y = random(0.2, 1);
this.rotationSpeed_z = random(0.5, 2); this.rotationSpeed_z = random(0.2, 1);
this.angle = random(360); // Start at a random position in the orbit this.angle = random(360); // Start at a random position in the orbit
this.tiltAngle = tiltAngle; this.tiltAngle = tiltAngle;
@ -128,7 +129,11 @@ class OrbitingObject {
rotateZ(this.rotationAngle_z) rotateZ(this.rotationAngle_z)
scale(this.scale); scale(this.scale);
model(this.model); push();
emissiveMaterial(backgroundColor)
model(this.model_fill);
pop();
model(this.model_stroke);
pop(); pop();
} }
} }
@ -180,6 +185,10 @@ class Text3D {
function preload() { function preload() {
onion_stroke = loadModel('./assets/onion_stroke.obj'); onion_stroke = loadModel('./assets/onion_stroke.obj');
onion_fill = loadModel('./assets/onion_fill.obj'); onion_fill = loadModel('./assets/onion_fill.obj');
planet_stroke = loadModel('./assets/planet_stroke.obj');
planet_fill = loadModel('./assets/planet_fill.obj');
train_stroke = loadModel('./assets/ciapong_stroke.obj');
train_fill = loadModel('./assets/ciapong_fill.obj');
font = loadFont('./assets/jgs5.ttf'); font = loadFont('./assets/jgs5.ttf');
} }
@ -206,21 +215,36 @@ function setup() {
onionObj = new RotatingOnion({ x: 0, y: random(360), z: 180 }, globalScaleVar); onionObj = new RotatingOnion({ x: 0, y: random(360), z: 180 }, globalScaleVar);
// Add orbiting objects to the onion // Add orbiting objects to the onion
for (let i = 1.8; i <= 4.8; i += 0.6) { const orbitingModels = [
onionObj.addOrbitingObject( [planet_fill, planet_stroke],
onion_fill, [train_fill, train_stroke],
i, ];
random(0.1, 0.8),
globalScaleVar * 0.0001 * random(1, 6), const orbitingConfigs = [
random(0, 30), { start: 1.8, count: 2, step: 0.6, sizeFactor: random(0.05, 0.2), speedRange: [0.05, 0.4] },
random(0, 30) { start: 3.0, count: 1, step: 0, sizeFactor: 0.2, speedRange: [0.05, 0.4], modelIndex: 1 },
); { start: 3.6, count: 3, step: 0.6, sizeFactor: random(0.1, 0.3), speedRange: [0.1, 0.8] },
} ];
orbitingConfigs.forEach(({ start, count, step, sizeFactor, speedRange, modelIndex = 0 }) => {
for (let i = 0; i < count; i++) {
const [fill, stroke] = orbitingModels[modelIndex];
onionObj.addOrbitingObject(
fill,
stroke,
start + i * step,
random(speedRange[0], speedRange[1]),
sizeFactor,
random(0, 30),
random(0, 30)
);
}
});
} }
function draw() { function draw() {
background(backgroundColor); background(backgroundColor);
orbitControl(); orbitControl(0.7, 0.7, 0.7);
ambientLight(100); ambientLight(100);
shininess(0); shininess(0);
specularMaterial(255, 255, 255); specularMaterial(255, 255, 255);