kcl-samples → stylized-mini-bus
stylized-mini-bus

KCL
// Stylized Mini-Bus // A simplified, parametric 3-D model of a compact van or mini-bus, intended for use as a low-poly prop in real-time engines, visualization scenes, or rapid prototyping. // The model includes: // - A solid chassis block forming the vehicle’s base // - Front and rear fenders with wheel cut-outs // - Four detachable wheels (tire + hubcap) // - A large cabin volume with sloped windshield and tapered rear // - A flat slab roof // - Circular headlights and rectangular taillights // // All major dimensions are parameterized for quick adjustments. // The geometry emphasizes clarity and stylization over realism, // making it suitable for stylized games, educational demos, or design mockups. // Set units and version @settings(defaultLengthUnit = m, kclVersion = 1.0) // Chassis dimensions chassisLength = 3.7 // total vehicle length chassisWidth = 1.8 // total vehicle width chassisHeight = 0.4 // height of main chassis block // Wheel configuration wheelBase = chassisLength * 0.7 // distance between front and rear wheels wheelDiameter = 0.7 // outer diameter of tire wheelWidth = chassisWidth * 0.15 // width of tire // Fender geometry fenderInset = 0.1 // horizontal gap between chassis and fender fenderLength = chassisLength + fenderInset * 2 // overall fender span along length fenderWidth = chassisWidth + fenderInset * 2 // overall fender span across width fenderHeight = 0.35 // height of the fender block // Elevation levels groundClearance = 0.4 // vertical gap between ground and bottom of fender chassisElevation = groundClearance + fenderHeight // bottom of the main chassis // Hood and cabin hoodLength = 0 // front hood segment length cabinElevation = chassisElevation + chassisHeight // vertical start of cabin cabinHeight = 1 // total cabin height windPanelShift = 0.5 // slant of windshield rearPanelShift = 0.3 // slant of rear cabin wall cabinLength = chassisLength - windPanelShift - rearPanelShift // cabin segment along the length // Front lights headlightsElevation = chassisElevation + chassisHeight / 2 headlightsDistance = chassisWidth * 0.75 headlightsSize = chassisHeight * 0.8 lightDepth = 0.05 // extrusion depth for headlights and taillights // Rear lights taillightsOffset = chassisHeight * 0.2 taillightsHeight = chassisHeight - (taillightsOffset * 2) taillightsWidth = taillightsHeight * 1.5 taillightsElevation = chassisElevation + taillightsOffset taillightsDistance = chassisWidth - (taillightsOffset * 2) - taillightsWidth taillightsSize = chassisHeight * 0.8 // Roof roofElevation = cabinElevation + cabinHeight // roof base height roofHeight = 0.1 // thickness of the roof block // Reference planes chassisPlane = offsetPlane(XZ, offset = chassisWidth / 2) // profile plane for chassis and cabin fenderPlane = offsetPlane(XZ, offset = chassisWidth / 2 + fenderInset) // profile plane for outer fenders // Fenders // Protective side covers that house the wheels. // Positioned slightly wider than the chassis to suggest ruggedness. fenderProfile = startProfile(fenderPlane, at = [-fenderLength / 2, groundClearance]) |> yLine(length = fenderHeight) |> xLine(length = fenderLength) |> yLine(length = -fenderHeight) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close() fenderBody = extrude([fenderProfile], length = -chassisWidth - (fenderInset * 2)) |> appearance(%, color = "#e0e0e0") // Wheel Cutouts // Hexagonal recesses subtracted from the fenders to make space for the wheels. fn makeWheelCutout(size) { wheelSketch = startSketchOn(XZ) cutOutProfile = polygon( wheelSketch, radius = size * 0.75, numSides = 6, center = [0, size / 2], ) cutOutVoid = extrude(cutOutProfile, length = -wheelWidth * 1.5) return cutOutVoid } frontLeftCutout = makeWheelCutout(size = wheelDiameter) |> translate(x = -wheelBase / 2, y = -fenderWidth / 2, z = 0) rearLeftCutout = makeWheelCutout(size = wheelDiameter) |> translate(x = wheelBase / 2, y = -fenderWidth / 2, z = 0) frontRightCutout = makeWheelCutout(size = wheelDiameter) |> rotate( %, roll = 0, pitch = 0, yaw = 180, ) |> translate(x = wheelBase / 2, y = -fenderWidth / 2, z = 0) rearRightCutout = makeWheelCutout(size = wheelDiameter) |> rotate( %, roll = 0, pitch = 0, yaw = 180, ) |> translate(x = -wheelBase / 2, y = -fenderWidth / 2, z = 0) fenderWithCutouts = subtract( [fenderBody], tools = [ frontLeftCutout, rearLeftCutout, frontRightCutout, rearRightCutout ], ) |> appearance(%, color = "#e3e3e3") // Chassis // The main structural body of the vehicle, sitting above the fenders. // Defines the base frame on which the cabin and roof are mounted. chassisProfile = startProfile(chassisPlane, at = [-chassisLength / 2, chassisElevation]) |> yLine(length = chassisHeight) |> xLine(length = chassisLength) |> yLine(length = -chassisHeight) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close() chassis = extrude([chassisProfile], length = -chassisWidth) |> appearance(%, color = "#ff2e82") // bright pink body // Cabin (main body volume) // Represents the entire upper body of the mini-bus, // with a sloped front (windshield) and tapered rear wall for style. cabinSideProfile = startProfile( chassisPlane, at = [ -chassisLength / 2 + hoodLength, cabinElevation ], ) |> line(end = [windPanelShift, cabinHeight]) |> xLine(length = cabinLength) |> line(end = [rearPanelShift, -cabinHeight]) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close() cabinBody = extrude([cabinSideProfile], length = -chassisWidth) |> appearance(%, color = "#9ce8f2") // Roof // Flat rectangular panel capping the top of the cabin. // Simplified to a thin block for a toy-like appearance. roofProfile = startProfile( chassisPlane, at = [ hoodLength + windPanelShift - (chassisLength / 2), roofElevation ], ) |> yLine(length = roofHeight) |> xLine(length = cabinLength) |> yLine(length = -roofHeight) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close() roof = extrude([roofProfile], length = -chassisWidth) |> appearance(%, color = "#ff2e82") // bright pink body // Wheels // Cylindrical wheels with a central hubcap detail. // Created as separate parts and positioned under the fender cutouts. fn wheelFn(diameter, width) { wheelSketch = startSketchOn(XZ) wheelProfile = circle(wheelSketch, center = [0, diameter / 2], radius = diameter / 2) |> subtract2d(%, tool = circle(wheelSketch, center = [0, diameter / 2], radius = diameter / 4)) wheelTireBody = extrude(wheelProfile, length = -wheelWidth) |> appearance(%, color = "#141414") diskProfile = circle(wheelSketch, center = [0, diameter / 2], radius = diameter / 4) diskBody = extrude(diskProfile, length = -wheelWidth) |> appearance(%, color = "#d1d1d1") return [wheelTireBody, diskBody] } wheelFrontLeft = wheelFn(diameter = wheelDiameter, width = wheelWidth) |> translate(x = -wheelBase / 2, y = -fenderWidth / 2, z = 0) wheelRearLeft = wheelFn(diameter = wheelDiameter, width = wheelWidth) |> translate(x = wheelBase / 2, y = -fenderWidth / 2, z = 0) wheelFrontRight = wheelFn(diameter = wheelDiameter, width = wheelWidth) |> rotate( %, roll = 0, pitch = 0, yaw = 180, ) |> translate(x = wheelBase / 2, y = -fenderWidth / 2, z = 0) wheelRearRight = wheelFn(diameter = wheelDiameter, width = wheelWidth) |> rotate( %, roll = 0, pitch = 0, yaw = 180, ) |> translate(x = -wheelBase / 2, y = -fenderWidth / 2, z = 0) // Headlights // Two circular front lights mounted on the front face of the chassis. headlightsPlane = offsetPlane(YZ, offset = -chassisLength / 2) headlightsSketch = startSketchOn(headlightsPlane) headlightsProfile = circle( headlightsSketch, center = [ headlightsDistance / 2, headlightsElevation ], radius = headlightsSize / 2, ) |> patternLinear2d( %, instances = 2, distance = headlightsDistance, axis = [-1, 0], ) headlightsBody = extrude(headlightsProfile, length = -lightDepth) |> appearance(%, color = "#ededed") // Taillights // Two rectangular rear lights mounted on the back face of the chassis. taillightsPlane = offsetPlane(YZ, offset = chassisLength / 2) taillightsSketch = startSketchOn(taillightsPlane) taillightsProfile = startProfile( taillightsSketch, at = [ -chassisWidth / 2 + taillightsOffset, taillightsElevation ], ) |> yLine(length = taillightsHeight) |> xLine(length = taillightsWidth) |> yLine(length = -taillightsHeight) |> line(endAbsolute = [profileStartX(%), profileStartY(%)]) |> close() |> patternLinear2d( %, instances = 2, distance = taillightsDistance, axis = [1, 0], ) taillightsBody = extrude(taillightsProfile, length = lightDepth) |> appearance(%, color = "#ff0000")