feat: add orbiting newag train + improved orbiter logic
This commit is contained in:
parent
098623f86c
commit
6976096d30
|
|
@ -8,6 +8,6 @@ Then simply go to [http://0.0.0.0:8080](http://0.0.0.0:8080) in your browser.
|
|||
|
||||
# Acknowledgement
|
||||
|
||||
3D object by @wilyweasel
|
||||
|
||||
Jgs font by Adel Faure. Distributed by velvetyne.fr.
|
||||
- 3D onion by @wilyweasel
|
||||
- 3D train by @livelovelaugh.art
|
||||
- Jgs font by Adel Faure. Distributed by velvetyne.fr.
|
||||
|
|
|
|||
10772
assets/ciapong_fill.obj
Normal file
10772
assets/ciapong_fill.obj
Normal file
File diff suppressed because it is too large
Load diff
162683
assets/ciapong_stroke.obj
Normal file
162683
assets/ciapong_stroke.obj
Normal file
File diff suppressed because it is too large
Load diff
62
sketch.js
62
sketch.js
|
|
@ -15,9 +15,9 @@ class RotatingOnion {
|
|||
}
|
||||
|
||||
// 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
|
||||
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() {
|
||||
|
|
@ -70,18 +70,19 @@ class RotatingOnion {
|
|||
}
|
||||
|
||||
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.model = model
|
||||
this.model_fill = model_fill
|
||||
this.model_stroke = model_stroke
|
||||
this.orbitRadius = orbitRadius;
|
||||
this.speed = speed; // Orbiting speed (angular speed)
|
||||
this.scale = scale;
|
||||
this.rotationAngle_x = random(360);
|
||||
this.rotationAngle_y = random(360);
|
||||
this.rotationAngle_z = random(360);
|
||||
this.rotationSpeed_x = random(0.5, 2);
|
||||
this.rotationSpeed_y = random(0.5, 2);
|
||||
this.rotationSpeed_z = random(0.5, 2);
|
||||
this.rotationSpeed_x = random(0.2, 1);
|
||||
this.rotationSpeed_y = random(0.2, 1);
|
||||
this.rotationSpeed_z = random(0.2, 1);
|
||||
|
||||
this.angle = random(360); // Start at a random position in the orbit
|
||||
this.tiltAngle = tiltAngle;
|
||||
|
|
@ -128,7 +129,11 @@ class OrbitingObject {
|
|||
rotateZ(this.rotationAngle_z)
|
||||
|
||||
scale(this.scale);
|
||||
model(this.model);
|
||||
push();
|
||||
emissiveMaterial(backgroundColor)
|
||||
model(this.model_fill);
|
||||
pop();
|
||||
model(this.model_stroke);
|
||||
pop();
|
||||
}
|
||||
}
|
||||
|
|
@ -180,6 +185,10 @@ class Text3D {
|
|||
function preload() {
|
||||
onion_stroke = loadModel('./assets/onion_stroke.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');
|
||||
}
|
||||
|
||||
|
|
@ -206,21 +215,36 @@ function setup() {
|
|||
onionObj = new RotatingOnion({ x: 0, y: random(360), z: 180 }, globalScaleVar);
|
||||
|
||||
// Add orbiting objects to the onion
|
||||
for (let i = 1.8; i <= 4.8; i += 0.6) {
|
||||
onionObj.addOrbitingObject(
|
||||
onion_fill,
|
||||
i,
|
||||
random(0.1, 0.8),
|
||||
globalScaleVar * 0.0001 * random(1, 6),
|
||||
random(0, 30),
|
||||
random(0, 30)
|
||||
);
|
||||
}
|
||||
const orbitingModels = [
|
||||
[planet_fill, planet_stroke],
|
||||
[train_fill, train_stroke],
|
||||
];
|
||||
|
||||
const orbitingConfigs = [
|
||||
{ start: 1.8, count: 2, step: 0.6, sizeFactor: random(0.05, 0.2), speedRange: [0.05, 0.4] },
|
||||
{ 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() {
|
||||
background(backgroundColor);
|
||||
orbitControl();
|
||||
orbitControl(0.7, 0.7, 0.7);
|
||||
ambientLight(100);
|
||||
shininess(0);
|
||||
specularMaterial(255, 255, 255);
|
||||
|
|
|
|||
Loading…
Reference in a new issue