1
0
Эх сурвалжийг харах

CityGenerator: Match the car paint mix to New York streets.

Replaces the uniform car palette with a weighted mix sampled from Manhattan street photos: yellow cabs over a mostly grayscale fleet (black livery cars, whites, silvers, graphites), with a dark navy, a burgundy or a bronze only here and there. Also moves the licence plates proud of the bumpers, whose faces shared a plane and z-fought.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mr.doob 3 долоо хоног өмнө
parent
commit
86f0255194

+ 22 - 4
examples/jsm/generators/CityGenerator.js

@@ -230,12 +230,16 @@ class CityGenerator {
 
 		const lights = [], signals = [], cans = [], benches = [], hydrants = [], trees = [], people = [], cars = [];
 
-		// most cars are working vehicles; about a third are yellow cabs
+		// the kerbside mix of a New York street: yellow cabs over an almost
+		// entirely grayscale fleet ( black livery cars, whites, silvers,
+		// graphites ), with a dark navy, a burgundy or a bronze only here and
+		// there. cumulative weights, so common colours repeat like they do kerb
+		// to kerb
 		const carColor = () => {
 
-			if ( random() < 0.34 ) return 0xf5c518;
-			const palette = [ 0xe9e9e6, 0x17191d, 0x9aa0a4, 0x3a3f45, 0x6e7378, 0x7a2420, 0x1d2a46, 0x2f4632 ];
-			return palette[ Math.floor( random() * palette.length ) ];
+			const r = random();
+			for ( const [ threshold, color ] of CAR_COLORS ) if ( r < threshold ) return color;
+			return CAR_COLORS[ CAR_COLORS.length - 1 ][ 1 ];
 
 		};
 
@@ -380,6 +384,20 @@ CityGenerator.defaults = {
 	sidewalkWidth: 5 // walkable strip between the street wall and the curb ( NYC ~15 ft )
 };
 
+// kerbside paint mix sampled from Manhattan street photos: cumulative
+// probability thresholds and the paint they select
+const CAR_COLORS = [
+	[ 0.22, 0xf5c518 ], // yellow cab
+	[ 0.42, 0x111216 ], // black ( livery sedans and SUVs )
+	[ 0.59, 0xe9e8e3 ], // white
+	[ 0.72, 0xb2b5b8 ], // silver
+	[ 0.84, 0x3e4247 ], // graphite
+	[ 0.90, 0x74787c ], // mid grey
+	[ 0.95, 0x1c2a3f ], // dark navy
+	[ 0.98, 0x571f1f ], // burgundy
+	[ 1.01, 0x5c4834 ] // bronze
+];
+
 // derives the block / street dimensions from the parameters
 function cityLayout( parameters ) {
 

+ 4 - 3
examples/jsm/generators/city/CarGenerator.js

@@ -286,10 +286,11 @@ function buildCarGeometry( spec ) {
 		new BoxGeometry( 0.16, 0.09, 0.06 ).rotateY( 0.25 ).translate( mirrorHalfW + 0.06, spec.mirror[ 0 ], spec.mirror[ 1 ] )
 	] );
 
-	// licence plates centred on the bumper faces
+	// licence plates centred on the bumpers, proud of the face so the two
+	// surfaces never share a plane
 	const plates = mergeGeometries( [
-		new BoxGeometry( 0.32, 0.12, 0.02 ).translate( 0, spec.bumperY + 0.02, spec.nose + 0.02 ),
-		new BoxGeometry( 0.32, 0.12, 0.02 ).translate( 0, spec.bumperY + 0.02, spec.tail - 0.02 )
+		new BoxGeometry( 0.32, 0.12, 0.02 ).translate( 0, spec.bumperY + 0.02, spec.nose + 0.035 ),
+		new BoxGeometry( 0.32, 0.12, 0.02 ).translate( 0, spec.bumperY + 0.02, spec.tail - 0.035 )
 	] );
 
 	const darkParts = [ ...wheels, grille ];

粤ICP备19079148号