fix: close California play and asset acceptance gaps
This commit is contained in:
@@ -64,6 +64,14 @@ describe("procedural actor assets", () => {
|
||||
assert.ok(size.y <= DOG_METRICS.height + 0.08, `height ${size.y}`);
|
||||
assert.ok(size.z >= DOG_METRICS.length - 0.1, `length ${size.z}`);
|
||||
assert.equal(rig.root.userData.actorType, "anonymous-dog");
|
||||
for (const side of ["left", "right"] as const) {
|
||||
const eye = rig.root.getObjectByName(`dog.eye.${side}`);
|
||||
const catchlight = rig.root.getObjectByName(`dog.eye-catchlight.${side}`);
|
||||
assert.ok(eye instanceof THREE.Mesh);
|
||||
assert.ok(catchlight instanceof THREE.Mesh);
|
||||
assert.ok(eye.getWorldPosition(new THREE.Vector3()).z < 0, `${side} eye faces -Z`);
|
||||
assert.ok(catchlight.getWorldPosition(new THREE.Vector3()).z < eye.getWorldPosition(new THREE.Vector3()).z);
|
||||
}
|
||||
|
||||
const clone = cloneDog(rig);
|
||||
assertSharedResources(rig.root, clone.root);
|
||||
|
||||
@@ -24,6 +24,8 @@ describe("procedural electric aircraft", () => {
|
||||
it("builds an original metre-scale fixed wing facing -Z with articulated parts", () => {
|
||||
const rig = buildElectricAircraft();
|
||||
assert.equal(rig.root.name, "electric-aircraft");
|
||||
assert.equal(rig.root.userData.forwardAxis, "-Z");
|
||||
assert.equal(rig.root.userData.aircraftModel, "electric-vtail");
|
||||
assert.equal(rig.fans.length, 2);
|
||||
assert.equal(rig.ownsMaterials, true);
|
||||
assert.ok(ELECTRIC_AIRCRAFT_METRICS.wingspan > ELECTRIC_AIRCRAFT_METRICS.length);
|
||||
@@ -32,10 +34,36 @@ describe("procedural electric aircraft", () => {
|
||||
assert.ok(size.x > 10);
|
||||
assert.ok(size.z > 7);
|
||||
assert.ok(size.y > 1.5);
|
||||
assert.ok(rig.leftAileron.position.z <= 0.6, "left aileron remains attached to tapered trailing edge");
|
||||
assert.ok(rig.rightAileron.position.z <= 0.6, "right aileron remains attached to tapered trailing edge");
|
||||
const wing = rig.root.getObjectByName("electric-aircraft:wing");
|
||||
assert.ok(wing instanceof THREE.Mesh);
|
||||
const normals = wing.geometry.getAttribute("normal");
|
||||
assert.ok(normals && Array.from({ length: normals.count }, (_, index) => normals.getY(index)).every((y) => y > 0),
|
||||
"wing front faces point toward the chase/flyover camera");
|
||||
disposeElectricAircraft(rig);
|
||||
assert.equal(rig.root.children.length, 0);
|
||||
});
|
||||
|
||||
it("distributes every fan blade evenly around its hub", () => {
|
||||
const rig = buildElectricAircraft();
|
||||
for (const fan of rig.fans) {
|
||||
const blades = fan.children.filter((child) => child.name.includes(":blade-"));
|
||||
assert.equal(blades.length, 5);
|
||||
const centroid = blades.reduce(
|
||||
(sum, blade) => sum.add(blade.position),
|
||||
new THREE.Vector3(),
|
||||
).multiplyScalar(1 / blades.length);
|
||||
assert.ok(centroid.length() < 1e-12, `fan centroid ${centroid.toArray()}`);
|
||||
for (const blade of blades) {
|
||||
assert.ok(Math.abs(blade.position.length() - 0.3) < 1e-12);
|
||||
const radial = new THREE.Vector3(0, 1, 0).applyQuaternion(blade.quaternion);
|
||||
assert.ok(radial.angleTo(blade.position.clone().normalize()) < 1e-7);
|
||||
}
|
||||
}
|
||||
disposeElectricAircraft(rig);
|
||||
});
|
||||
|
||||
it("animates opposing ailerons, V-tail surfaces, and electric fans", () => {
|
||||
const rig = buildElectricAircraft();
|
||||
setAircraftControlSurfaces(rig, { roll: 0.8, pitch: 0.5, yaw: -0.4 });
|
||||
@@ -174,6 +202,12 @@ describe("aircraft controller", () => {
|
||||
assert.throws(() => new AircraftController({
|
||||
route: [{ id: "bad", lat: Number.NaN, lng: 0, altitudeM: 1_000 }],
|
||||
}), /waypoints/);
|
||||
assert.throws(() => new AircraftController({
|
||||
route: [{ id: "outside-california", lat: 45, lng: -118, altitudeM: 1_000 }],
|
||||
}), /waypoints/);
|
||||
assert.throws(() => new AircraftController({
|
||||
route: [{ id: "above-envelope", lat: 37, lng: -122, altitudeM: 8_000 }],
|
||||
}), /waypoints/);
|
||||
assert.throws(() => new AircraftController({
|
||||
envelope: {
|
||||
minLat: 40,
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
normalizeVehicleActions,
|
||||
replayVehicleInputs,
|
||||
} from "../transport/vehicleController.ts";
|
||||
import { buildRoutePath, sampleRoute } from "../transport/vehicleSim.ts";
|
||||
|
||||
describe("vehicle controller", () => {
|
||||
it("normalizes arbitrary adapter input into safe device-neutral actions", () => {
|
||||
@@ -161,6 +162,37 @@ describe("vehicle controller", () => {
|
||||
assert.equal(controller.state().elapsedSteps, 0);
|
||||
});
|
||||
|
||||
it("preserves the authored Bay endpoint across completion restore and reverse handoff", () => {
|
||||
const route = buildRoutePath(CALIFORNIA_TRANSPORT, "la-sf-us-101");
|
||||
const endpoint = sampleRoute(route, route.lengthM);
|
||||
assert.ok(Math.abs(endpoint.lat - 37.7749) < 1e-9);
|
||||
assert.ok(Math.abs(endpoint.lng - -122.4194) < 1e-9);
|
||||
|
||||
const restored = new VehicleController(CALIFORNIA_TRANSPORT, {
|
||||
routeId: "la-sf-us-101",
|
||||
initialDistanceM: route.lengthM,
|
||||
});
|
||||
assert.equal(restored.state().progress, 1);
|
||||
assert.ok(Math.abs(restored.state().lat - endpoint.lat) < 1e-12);
|
||||
assert.ok(Math.abs(restored.state().lng - endpoint.lng) < 1e-12);
|
||||
|
||||
restored.setRoute("la-sf-i-5", true);
|
||||
assert.equal(restored.state().progress, 1);
|
||||
assert.ok(Math.abs(restored.state().lat - 37.7749) < 1e-9);
|
||||
assert.ok(Math.abs(restored.state().lng - -122.4194) < 1e-9);
|
||||
|
||||
const southbound = new VehicleController(CALIFORNIA_TRANSPORT, {
|
||||
routeId: "la-sf-i-5",
|
||||
direction: -1,
|
||||
initialSpeedMps: 20,
|
||||
});
|
||||
assert.equal(southbound.state().progress, 1);
|
||||
const before = southbound.state().distanceM;
|
||||
southbound.stepFixed({ throttle: 0.5 });
|
||||
assert.ok(southbound.state().distanceM < before);
|
||||
assert.ok(southbound.state().progress < 1 && southbound.state().progress > 0.99);
|
||||
});
|
||||
|
||||
it("compresses corridor progress without changing vehicle dynamics", () => {
|
||||
const normal = new VehicleController(CALIFORNIA_TRANSPORT, {
|
||||
routeId: "la-sf-us-101",
|
||||
|
||||
Reference in New Issue
Block a user