commit 3ccf96902476e84f096a19433ce01ad541624409
parent 12be05b58a62acfafb6effa30c316ed25e29321b
Author: Martin Kloeckner <mjkloeckner@gmail.com>
Date: Sat, 6 Jul 2024 18:05:49 -0300
add train lights
Diffstat:
3 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/tp/src/scene.js b/tp/src/scene.js
@@ -438,6 +438,27 @@ function buildLoco() {
trainBackCamera.name = "trainBackCamera";
cameras.push(trainBackCamera);
+ // SpotLight(color: Int, intensity: Float, distance: Float, angle: Radians, penumbra: Float, decay: Float)
+ const trainLight = new THREE.SpotLight(0xffffff, 100.0, 2000.0, Math.PI/3, 0.5, 0.5);
+ train.add(trainLight.target);
+ train.add(trainLight);
+ trainLight.position.set(0, 2, 15);
+ trainLight.target.position.set(0, -100, 100);
+ trainLight.target.updateMatrixWorld();
+
+ const trainLight2 = new THREE.SpotLight(0xffffff, 10.0, 4.0, Math.PI/2, 0.5, 0.5);
+ train.add(trainLight2.target);
+ train.add(trainLight2);
+ trainLight2.position.set(0, 5, 20);
+ trainLight2.target.position.set(0, 0, -100);
+ trainLight2.target.updateMatrixWorld();
+
+ const trainLight3 = new THREE.SpotLight(0xffffff, 10.0, 10.0, Math.PI/2, 0.5, 0.5);
+ train.add(trainLight3.target);
+ train.add(trainLight3);
+ trainLight3.position.set(0, 5, 10);
+ trainLight3.target.position.set(0, 0, 100);
+ trainLight3.target.updateMatrixWorld();
train.scale.set(0.145, 0.145, 0.145);
train.visible = settings.showTrain;
diff --git a/tp/src/standalone/train.js b/tp/src/standalone/train.js
@@ -343,6 +343,23 @@ function buildTrain() {
chassis.translateY(-wheelOffset);
+ const lightRad = 1.10;
+ const lightGeometry = new THREE.CylinderGeometry(lightRad, lightRad, 1, 32);
+ lightGeometry.rotateX(Math.PI/2);
+
+ const lightMaterial = new THREE.MeshPhongMaterial({
+ color: 0x393939,
+ side: THREE.DoubleSide,
+ shininess: 100.0,
+ emissive: 0xf6d32d
+ });
+
+ const light = new THREE.Mesh(lightGeometry, lightMaterial);
+ train.add(light)
+ light.position.set(0,
+ steamChamberRad+chassisOffset-lightRad/2-.30,
+ (steamChamberLen+steamChamberEndLen)/2-.3);
+
train.position.set(0, 2, 0);
return train;
}
diff --git a/tp/src/train.js b/tp/src/train.js
@@ -294,6 +294,23 @@ export function buildTrain() {
// chassis.translateY(-wheelOffset);
updateTrainCrankPosition();
+ const lightRad = 1.10;
+ const lightGeometry = new THREE.CylinderGeometry(lightRad, lightRad, 1, 32);
+ lightGeometry.rotateX(Math.PI/2);
+
+ const lightMaterial = new THREE.MeshPhongMaterial({
+ color: 0x393939,
+ side: THREE.DoubleSide,
+ shininess: 100.0,
+ emissive: 0xf6d32d
+ });
+
+ const trainLightLamp = new THREE.Mesh(lightGeometry, lightMaterial);
+ train.add(trainLightLamp)
+ trainLightLamp.position.set(0,
+ steamChamberRad+chassisOffset-lightRad/2-.30,
+ (steamChamberLen+steamChamberEndLen)/2-.3);
+
train.position.set(0, 2, 0);
return train;
}