@agent-os-lab/agent-game-sdk 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -115,6 +115,7 @@ export function applyAgentPose(
|
|
|
115
115
|
function resetPose(mesh: AgentMeshParts): void {
|
|
116
116
|
mesh.visualRoot.position.y = 0;
|
|
117
117
|
mesh.body.rotation.set(0, 0, 0);
|
|
118
|
+
mesh.headRoot.rotation.set(0, 0, 0);
|
|
118
119
|
mesh.head.rotation.set(0, 0, 0);
|
|
119
120
|
mesh.leftArm.rotation.set(0, 0, 0);
|
|
120
121
|
mesh.rightArm.rotation.set(0, 0, 0);
|
|
@@ -150,7 +151,7 @@ function applyPoseMode(
|
|
|
150
151
|
applySeatedLowerBody(mesh);
|
|
151
152
|
mesh.visualRoot.position.y = CHAIR_SEATED_VISUAL_Y;
|
|
152
153
|
mesh.body.rotation.x = -0.1;
|
|
153
|
-
mesh.
|
|
154
|
+
mesh.headRoot.rotation.x = -0.06;
|
|
154
155
|
mesh.leftArm.rotation.x = 0.58 + Math.sin(phase) * 0.18;
|
|
155
156
|
mesh.rightArm.rotation.x = 0.58 - Math.sin(phase) * 0.18;
|
|
156
157
|
mesh.leftArm.rotation.z = -0.08;
|
|
@@ -158,21 +159,21 @@ function applyPoseMode(
|
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
160
161
|
case "thinking":
|
|
161
|
-
mesh.
|
|
162
|
-
mesh.
|
|
162
|
+
mesh.headRoot.rotation.y = Math.sin(elapsedSeconds * 1.2) * 0.35;
|
|
163
|
+
mesh.headRoot.rotation.x = Math.sin(elapsedSeconds * 0.9) * 0.08;
|
|
163
164
|
mesh.body.rotation.z = Math.sin(elapsedSeconds * 1.6) * 0.07;
|
|
164
165
|
return;
|
|
165
166
|
case "meeting":
|
|
166
167
|
applySeatedLowerBody(mesh);
|
|
167
168
|
mesh.visualRoot.position.y = CHAIR_SEATED_VISUAL_Y;
|
|
168
|
-
mesh.
|
|
169
|
+
mesh.headRoot.rotation.x = Math.sin(elapsedSeconds * 2) * 0.08;
|
|
169
170
|
mesh.leftArm.rotation.x = 0.08;
|
|
170
171
|
mesh.rightArm.rotation.x = -0.08;
|
|
171
172
|
return;
|
|
172
173
|
case "waiting":
|
|
173
174
|
applySeatedLowerBody(mesh);
|
|
174
175
|
mesh.visualRoot.position.y = CHAIR_SEATED_VISUAL_Y;
|
|
175
|
-
mesh.
|
|
176
|
+
mesh.headRoot.rotation.y = Math.sin(elapsedSeconds * 0.9) * 0.12;
|
|
176
177
|
return;
|
|
177
178
|
case "resting": {
|
|
178
179
|
const breath = 1 + Math.sin(elapsedSeconds * 1.2) * 0.025;
|
|
@@ -180,7 +181,7 @@ function applyPoseMode(
|
|
|
180
181
|
mesh.visualRoot.position.y = SOFA_SEATED_VISUAL_Y;
|
|
181
182
|
mesh.body.scale.set(1, breath, 1);
|
|
182
183
|
mesh.body.rotation.x = 0.08;
|
|
183
|
-
mesh.
|
|
184
|
+
mesh.headRoot.rotation.z = Math.sin(elapsedSeconds * 0.8) * 0.05;
|
|
184
185
|
return;
|
|
185
186
|
}
|
|
186
187
|
case "idle": {
|
|
@@ -10,6 +10,7 @@ export type AgentMeshParts = {
|
|
|
10
10
|
group: THREE.Group;
|
|
11
11
|
visualRoot: THREE.Group;
|
|
12
12
|
body: THREE.Object3D;
|
|
13
|
+
headRoot: THREE.Object3D;
|
|
13
14
|
head: THREE.Object3D;
|
|
14
15
|
leftEye: THREE.Object3D;
|
|
15
16
|
rightEye: THREE.Object3D;
|
|
@@ -61,6 +62,15 @@ export type AgentBodyPartRenderSpec = {
|
|
|
61
62
|
z: number;
|
|
62
63
|
};
|
|
63
64
|
|
|
65
|
+
const HEAD_ROOT_PART_KEYS = new Set<AgentBodyPartKey>([
|
|
66
|
+
"head",
|
|
67
|
+
"leftEye",
|
|
68
|
+
"rightEye",
|
|
69
|
+
"mouth",
|
|
70
|
+
"hairTop",
|
|
71
|
+
"hairBack",
|
|
72
|
+
]);
|
|
73
|
+
|
|
64
74
|
export function resolveAgentBodyPartRenderSpecs(index: number): AgentBodyPartRenderSpec[] {
|
|
65
75
|
const shirt = agentColors[index % agentColors.length] ?? agentColors[0];
|
|
66
76
|
const skin = skinColors[index % skinColors.length] ?? skinColors[0];
|
|
@@ -90,11 +100,25 @@ export function createAgentMesh(agent: AgentGameOfficeAgent, index: number): Age
|
|
|
90
100
|
group.scale.setScalar(AGENT_MESH_SCALE);
|
|
91
101
|
const visualRoot = new THREE.Group();
|
|
92
102
|
group.add(visualRoot);
|
|
103
|
+
const specs = resolveAgentBodyPartRenderSpecs(index);
|
|
104
|
+
const headSpec = specs.find((part) => part.key === "head");
|
|
105
|
+
if (!headSpec) {
|
|
106
|
+
throw new Error("Agent mesh head part is required");
|
|
107
|
+
}
|
|
108
|
+
const headRoot = new THREE.Group();
|
|
109
|
+
headRoot.position.set(headSpec.x, headSpec.y, headSpec.z);
|
|
110
|
+
visualRoot.add(headRoot);
|
|
93
111
|
const parts = Object.fromEntries(
|
|
94
|
-
|
|
95
|
-
part.key
|
|
96
|
-
|
|
97
|
-
|
|
112
|
+
specs.map((part) => {
|
|
113
|
+
const parent = HEAD_ROOT_PART_KEYS.has(part.key) ? headRoot : visualRoot;
|
|
114
|
+
const x = HEAD_ROOT_PART_KEYS.has(part.key) ? part.x - headSpec.x : part.x;
|
|
115
|
+
const y = HEAD_ROOT_PART_KEYS.has(part.key) ? part.y - headSpec.y : part.y;
|
|
116
|
+
const z = HEAD_ROOT_PART_KEYS.has(part.key) ? part.z - headSpec.z : part.z;
|
|
117
|
+
return [
|
|
118
|
+
part.key,
|
|
119
|
+
addPart(parent, x, y, z),
|
|
120
|
+
];
|
|
121
|
+
}),
|
|
98
122
|
) as Record<AgentBodyPartKey, THREE.Object3D>;
|
|
99
123
|
const activityGlow = createActivityGlow();
|
|
100
124
|
const activityEffects = createAgentActivityEffects();
|
|
@@ -106,6 +130,7 @@ export function createAgentMesh(agent: AgentGameOfficeAgent, index: number): Age
|
|
|
106
130
|
group,
|
|
107
131
|
visualRoot,
|
|
108
132
|
body: parts.body,
|
|
133
|
+
headRoot,
|
|
109
134
|
head: parts.head,
|
|
110
135
|
leftEye: parts.leftEye,
|
|
111
136
|
rightEye: parts.rightEye,
|