Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

3.2 KB
Raw Blame
import {createResourceScope} from './resource-scope.mjs';
import {createFleetRowing} from './fleet-rowing.mjs';
import {createShoreFleet} from './shore-fleet.mjs';
import {createEquipmentArrival} from './runtime/landing-v11/src/ship-equipment.mjs';
import {createLateLandingPlan} from './late-landing-plan.mjs';
export async function createLateLandings(T,{rosters,resources,boundsMode='cached',regroupMode='off',formationIdleMode,walkingMode,walkingOffscreenMode,poseDraw='reference',lookupMode='reference',poseMode='subtree'}){
 const scope=createResourceScope();try{if(!['off','packed'].includes(regroupMode))throw Error('Invalid later regroup mode');
 const timeline=createEquipmentArrival({profile:resources.profile,queueDuration:resources.data.duration,landedAngle:resources.data.landing.angle}),plan=createLateLandingPlan(rosters,resources.data.actors,{joinOffset:timeline.sample(0).offset,shipY:resources.record.ship.position[1]}),rows=scope.use(await createFleetRowing(T,{rosters,resources,poseDraw,sampleShip:plan.sampleApproach}),'offshore rows'),shore=scope.use(await createShoreFleet(T,{rosters:plan.rosters,resources,poseDraw,lookupMode,poseMode,regroupMode,rowAll:true,boundsMode,formationIdleMode,walkingMode,walkingOffscreenMode,lateRegroup:regroupMode==='packed'}),'later shore'),group=new T.Group();const duration=regroupMode==='packed'?plan.handoffTime+shore.duration:plan.duration(timeline.duration);group.name='later-landing-wave';group.add(rows.group,shore.group);let time=-1,owner;
 function update(next){owner=plan.owner(next);time=next;rows.update(next);if(owner==='landing')shore.update(next-plan.handoffTime);rows.group.visible=owner==='rowing';shore.group.visible=owner==='landing';}
 function applyVisibility(culler){if(owner==='rowing')rows.applyVisibility(culler);else shore.applyVisibility(culler);}
 update(0);applyVisibility(null);
 return {group,update,applyVisibility,prepareView:shore.prepareView,playbackPhase:()=>time<plan.handoffTime?'Later fleet approaching':time>=duration?(regroupMode==='packed'?'Later reserves formed':'Landings complete'):'Later crews landing and regrouping',duration,verifyBindings:()=>shore.verifyBindings(),stats(){const r=rows.stats(),s=shore.stats();return {...r,time,visibleShips:owner==='landing'?s.visibleShips:r.visibleShips,characterRigEvaluations:owner==='landing'?s.ships.reduce((n,v)=>n+v.rigEvaluations,0):0,crewBatches:owner==='landing'?s.partBatches:r.crewBatches,scope:regroupMode==='packed'?'Four later ships approach outer bays, unload, then march to translated flank reserves with shared distant walking and GPU formation idles.':'Four later ships approach outer bays, then row/coast, lower planks and unload into shore staging.',owner,lateLandings:true,counts:owner==='landing'?s.counts:{rowing:112},actors:owner==='landing'?s.actors:undefined,ships:owner==='landing'?s.ships.map(v=>({id:v.id,position:[v.placement[0],v.placement[1]+resources.record.ship.position[1],v.placement[2]],yaw:v.frame.yaw,state:Object.keys(v.counts).find(k=>v.counts[k]>0),actorIds:v.actors.map(a=>a.id)})):r.ships,landing:owner==='landing'?s:null,berths:plan.rosters.map(v=>({id:v.id,frame:v.frame})),duration,performanceQualification:false};},dispose:scope.close};
 }catch(error){return scope.fail(error);}
}