@hmcs/sdk 1.0.0
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/README.md +30 -0
- package/dist/app.cjs +63 -0
- package/dist/app.js +63 -0
- package/dist/assets.cjs +52 -0
- package/dist/assets.js +52 -0
- package/dist/audio.cjs +159 -0
- package/dist/audio.js +159 -0
- package/dist/commands.cjs +298 -0
- package/dist/commands.d.ts +852 -0
- package/dist/commands.js +296 -0
- package/dist/coordinates.cjs +69 -0
- package/dist/coordinates.js +69 -0
- package/dist/displays.cjs +38 -0
- package/dist/displays.js +38 -0
- package/dist/effects.cjs +50 -0
- package/dist/effects.js +50 -0
- package/dist/entities.cjs +249 -0
- package/dist/entities.js +249 -0
- package/dist/host.cjs +297 -0
- package/dist/host.js +294 -0
- package/dist/index.cjs +98 -0
- package/dist/index.d.ts +2612 -0
- package/dist/index.js +17 -0
- package/dist/mods.cjs +207 -0
- package/dist/mods.js +207 -0
- package/dist/preferences.cjs +90 -0
- package/dist/preferences.js +90 -0
- package/dist/settings.cjs +46 -0
- package/dist/settings.js +46 -0
- package/dist/shadowPanel.cjs +46 -0
- package/dist/shadowPanel.js +46 -0
- package/dist/signals.cjs +158 -0
- package/dist/signals.js +158 -0
- package/dist/speech.cjs +48 -0
- package/dist/speech.js +48 -0
- package/dist/utils.cjs +13 -0
- package/dist/utils.js +11 -0
- package/dist/vrm.cjs +469 -0
- package/dist/vrm.js +466 -0
- package/dist/webviews.cjs +310 -0
- package/dist/webviews.js +302 -0
- package/package.json +61 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var host = require('./host.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Entities API namespace for managing ECS (Entity Component System) entities.
|
|
7
|
+
*
|
|
8
|
+
* In Desktop Homunculus, everything is represented as entities in Bevy's ECS system.
|
|
9
|
+
* This includes VRM models, bones, UI elements, and other game objects. This namespace
|
|
10
|
+
* provides core functionality for finding entities by name and manipulating their
|
|
11
|
+
* transforms (position, rotation, scale).
|
|
12
|
+
*
|
|
13
|
+
* Key concepts:
|
|
14
|
+
* - **Entity**: A unique identifier in the ECS system
|
|
15
|
+
* - **Name**: Human-readable identifier for entities
|
|
16
|
+
* - **Transform**: Position, rotation, and scale data
|
|
17
|
+
* - **Hierarchy**: Entities can have parent-child relationships
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Find a VRM entity by name
|
|
22
|
+
* const vrmEntity = await entities.findByName("MyCharacter");
|
|
23
|
+
*
|
|
24
|
+
* // Get the current transform (position, rotation, scale)
|
|
25
|
+
* const transform = await entities.transform(vrmEntity);
|
|
26
|
+
* console.log("Position:", transform.translation);
|
|
27
|
+
*
|
|
28
|
+
* // Move the VRM to a new position
|
|
29
|
+
* await entities.setTransform(vrmEntity, {
|
|
30
|
+
* translation: [100, 0, 50]
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Find a bone within a specific VRM
|
|
34
|
+
* const headBone = await entities.findByName("head", { root: vrmEntity });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
exports.entities = void 0;
|
|
38
|
+
(function (entities) {
|
|
39
|
+
/**
|
|
40
|
+
* Gets the current transform (position, rotation, scale) of an entity.
|
|
41
|
+
*
|
|
42
|
+
* The transform defines where the entity is positioned in 3D space,
|
|
43
|
+
* how it's rotated, and its scale factor.
|
|
44
|
+
*
|
|
45
|
+
* @param entity - The entity ID to get the transform for
|
|
46
|
+
* @returns A promise that resolves to the entity's transform data
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const vrmEntity = await entities.findByName("MyCharacter");
|
|
51
|
+
* const transform = await entities.transform(vrmEntity);
|
|
52
|
+
*
|
|
53
|
+
* console.log("Position:", transform.translation);
|
|
54
|
+
* console.log("Rotation:", transform.rotation);
|
|
55
|
+
* console.log("Scale:", transform.scale);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
async function transform(entity) {
|
|
59
|
+
const response = await host.host.get(host.host.createUrl(`entities/${entity}/transform`));
|
|
60
|
+
return await response.json();
|
|
61
|
+
}
|
|
62
|
+
entities.transform = transform;
|
|
63
|
+
/**
|
|
64
|
+
* Updates the transform (position, rotation, scale) of an entity.
|
|
65
|
+
*
|
|
66
|
+
* You can provide a partial transform to update only specific components.
|
|
67
|
+
* For example, you can change just the position while leaving rotation
|
|
68
|
+
* and scale unchanged.
|
|
69
|
+
*
|
|
70
|
+
* @param entity - The entity ID to update
|
|
71
|
+
* @param transform - Partial transform data with the values to update
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* // Move entity to a new position
|
|
76
|
+
* await entities.setTransform(vrmEntity, {
|
|
77
|
+
* translation: [0, 100, 0] // Move up 100 units
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Rotate and scale the entity
|
|
81
|
+
* await entities.setTransform(vrmEntity, {
|
|
82
|
+
* rotation: [0, 0, 0, 1], // Reset rotation to identity
|
|
83
|
+
* scale: [2, 2, 2] // Double the size
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* // Update all transform components at once
|
|
87
|
+
* await entities.setTransform(vrmEntity, {
|
|
88
|
+
* translation: [50, 0, -25],
|
|
89
|
+
* rotation: [0, 0.707, 0, 0.707], // 90 degree Y rotation
|
|
90
|
+
* scale: [1.5, 1.5, 1.5]
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
async function setTransform(entity, transform) {
|
|
95
|
+
await host.host.put(host.host.createUrl(`entities/${entity}/transform`), transform);
|
|
96
|
+
}
|
|
97
|
+
entities.setTransform = setTransform;
|
|
98
|
+
/**
|
|
99
|
+
* Gets the human-readable name of an entity.
|
|
100
|
+
*
|
|
101
|
+
* Most entities in Desktop Homunculus have names that make them easier
|
|
102
|
+
* to identify and work with. VRM models use their character names,
|
|
103
|
+
* bones use standard bone names like "head", "leftHand", etc.
|
|
104
|
+
*
|
|
105
|
+
* @param entity - The entity ID to get the name for
|
|
106
|
+
* @returns A promise that resolves to the entity's name
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const vrmEntity = await entities.findByName("MyCharacter");
|
|
111
|
+
* const name = await entities.name(vrmEntity);
|
|
112
|
+
* console.log("Entity name:", name); // "MyCharacter"
|
|
113
|
+
*
|
|
114
|
+
* // Get bone names
|
|
115
|
+
* const headBone = await entities.findByName("head", { root: vrmEntity });
|
|
116
|
+
* const boneName = await entities.name(headBone);
|
|
117
|
+
* console.log("Bone name:", boneName); // "head"
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
async function name(entity) {
|
|
121
|
+
const response = await host.host.get(host.host.createUrl(`entities/${entity}/name`));
|
|
122
|
+
return await response.json();
|
|
123
|
+
}
|
|
124
|
+
entities.name = name;
|
|
125
|
+
/**
|
|
126
|
+
* Finds an entity by its name, optionally within a specific parent entity.
|
|
127
|
+
*
|
|
128
|
+
* This is the primary method for locating entities in the ECS system.
|
|
129
|
+
* Names are unique within their scope (global or under a specific parent).
|
|
130
|
+
*
|
|
131
|
+
* @param name - The name of the entity to find
|
|
132
|
+
* @param options - Optional search parameters
|
|
133
|
+
* @returns A promise that resolves to the entity ID
|
|
134
|
+
* @throws Will throw an error if no entity with the given name is found
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* // Find a VRM character globally
|
|
139
|
+
* const vrmEntity = await entities.findByName("MyCharacter");
|
|
140
|
+
*
|
|
141
|
+
* // Find a bone within a specific VRM
|
|
142
|
+
* const headBone = await entities.findByName("head", {
|
|
143
|
+
* root: vrmEntity
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // Find UI elements or other named entities
|
|
147
|
+
* const settingsPanel = await entities.findByName("SettingsPanel");
|
|
148
|
+
* const chatWindow = await entities.findByName("ChatWindow");
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
async function findByName(name, options) {
|
|
152
|
+
const response = await host.host.get(host.host.createUrl("entities", {
|
|
153
|
+
name,
|
|
154
|
+
...options,
|
|
155
|
+
}));
|
|
156
|
+
return await response.json();
|
|
157
|
+
}
|
|
158
|
+
entities.findByName = findByName;
|
|
159
|
+
/**
|
|
160
|
+
* Moves an entity to the specified position.
|
|
161
|
+
*
|
|
162
|
+
* Supports two coordinate types:
|
|
163
|
+
* - **World coordinates**: Sets the entity's position directly in 3D world space.
|
|
164
|
+
* `z` is optional — if omitted, the entity keeps its current z position.
|
|
165
|
+
* - **Viewport coordinates**: Screen-space position that is automatically converted
|
|
166
|
+
* to world coordinates internally.
|
|
167
|
+
*
|
|
168
|
+
* @param entity - The entity ID to move
|
|
169
|
+
* @param target - The target position (world or viewport coordinates)
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* // Move to world coordinates
|
|
174
|
+
* await entities.move(vrmEntity, { type: "world", position: [0, 1.5], z: -2 });
|
|
175
|
+
*
|
|
176
|
+
* // Move to world coordinates (keep current z)
|
|
177
|
+
* await entities.move(vrmEntity, { type: "world", position: [0, 1.5] });
|
|
178
|
+
*
|
|
179
|
+
* // Move to a screen position
|
|
180
|
+
* await entities.move(vrmEntity, { type: "viewport", position: [500, 300] });
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
async function move(entity, target) {
|
|
184
|
+
await host.host.post(host.host.createUrl(`entities/${entity}/move`), target);
|
|
185
|
+
}
|
|
186
|
+
entities.move = move;
|
|
187
|
+
/**
|
|
188
|
+
* Smoothly animate an entity's position to a target value.
|
|
189
|
+
*
|
|
190
|
+
* @param entityId - The entity ID to tween
|
|
191
|
+
* @param request - Tween parameters
|
|
192
|
+
* @returns Promise that resolves when the request completes (or when animation finishes if wait=true)
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* await entities.tweenPosition(myEntity, {
|
|
197
|
+
* target: [100, 50, 0],
|
|
198
|
+
* durationMs: 1000,
|
|
199
|
+
* easing: "quadraticInOut",
|
|
200
|
+
* wait: true,
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
async function tweenPosition(entityId, request) {
|
|
205
|
+
await host.host.post(host.host.createUrl(`entities/${entityId}/tween/position`), request);
|
|
206
|
+
}
|
|
207
|
+
entities.tweenPosition = tweenPosition;
|
|
208
|
+
/**
|
|
209
|
+
* Smoothly animate an entity's rotation to a target value.
|
|
210
|
+
*
|
|
211
|
+
* @param entityId - The entity ID to tween
|
|
212
|
+
* @param request - Tween parameters
|
|
213
|
+
* @returns Promise that resolves when the request completes (or when animation finishes if wait=true)
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* await entities.tweenRotation(myEntity, {
|
|
218
|
+
* target: [0, 0, 0.7071, 0.7071], // 90 degrees around Z axis
|
|
219
|
+
* durationMs: 500,
|
|
220
|
+
* easing: "elasticOut",
|
|
221
|
+
* });
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
async function tweenRotation(entityId, request) {
|
|
225
|
+
await host.host.post(host.host.createUrl(`entities/${entityId}/tween/rotation`), request);
|
|
226
|
+
}
|
|
227
|
+
entities.tweenRotation = tweenRotation;
|
|
228
|
+
/**
|
|
229
|
+
* Smoothly animate an entity's scale to a target value.
|
|
230
|
+
*
|
|
231
|
+
* @param entityId - The entity ID to tween
|
|
232
|
+
* @param request - Tween parameters
|
|
233
|
+
* @returns Promise that resolves when the request completes (or when animation finishes if wait=true)
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* await entities.tweenScale(myEntity, {
|
|
238
|
+
* target: [2, 2, 2],
|
|
239
|
+
* durationMs: 800,
|
|
240
|
+
* easing: "bounceOut",
|
|
241
|
+
* wait: false,
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
async function tweenScale(entityId, request) {
|
|
246
|
+
await host.host.post(host.host.createUrl(`entities/${entityId}/tween/scale`), request);
|
|
247
|
+
}
|
|
248
|
+
entities.tweenScale = tweenScale;
|
|
249
|
+
})(exports.entities || (exports.entities = {}));
|
package/dist/entities.js
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { host } from './host.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Entities API namespace for managing ECS (Entity Component System) entities.
|
|
5
|
+
*
|
|
6
|
+
* In Desktop Homunculus, everything is represented as entities in Bevy's ECS system.
|
|
7
|
+
* This includes VRM models, bones, UI elements, and other game objects. This namespace
|
|
8
|
+
* provides core functionality for finding entities by name and manipulating their
|
|
9
|
+
* transforms (position, rotation, scale).
|
|
10
|
+
*
|
|
11
|
+
* Key concepts:
|
|
12
|
+
* - **Entity**: A unique identifier in the ECS system
|
|
13
|
+
* - **Name**: Human-readable identifier for entities
|
|
14
|
+
* - **Transform**: Position, rotation, and scale data
|
|
15
|
+
* - **Hierarchy**: Entities can have parent-child relationships
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Find a VRM entity by name
|
|
20
|
+
* const vrmEntity = await entities.findByName("MyCharacter");
|
|
21
|
+
*
|
|
22
|
+
* // Get the current transform (position, rotation, scale)
|
|
23
|
+
* const transform = await entities.transform(vrmEntity);
|
|
24
|
+
* console.log("Position:", transform.translation);
|
|
25
|
+
*
|
|
26
|
+
* // Move the VRM to a new position
|
|
27
|
+
* await entities.setTransform(vrmEntity, {
|
|
28
|
+
* translation: [100, 0, 50]
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Find a bone within a specific VRM
|
|
32
|
+
* const headBone = await entities.findByName("head", { root: vrmEntity });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
var entities;
|
|
36
|
+
(function (entities) {
|
|
37
|
+
/**
|
|
38
|
+
* Gets the current transform (position, rotation, scale) of an entity.
|
|
39
|
+
*
|
|
40
|
+
* The transform defines where the entity is positioned in 3D space,
|
|
41
|
+
* how it's rotated, and its scale factor.
|
|
42
|
+
*
|
|
43
|
+
* @param entity - The entity ID to get the transform for
|
|
44
|
+
* @returns A promise that resolves to the entity's transform data
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const vrmEntity = await entities.findByName("MyCharacter");
|
|
49
|
+
* const transform = await entities.transform(vrmEntity);
|
|
50
|
+
*
|
|
51
|
+
* console.log("Position:", transform.translation);
|
|
52
|
+
* console.log("Rotation:", transform.rotation);
|
|
53
|
+
* console.log("Scale:", transform.scale);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
async function transform(entity) {
|
|
57
|
+
const response = await host.get(host.createUrl(`entities/${entity}/transform`));
|
|
58
|
+
return await response.json();
|
|
59
|
+
}
|
|
60
|
+
entities.transform = transform;
|
|
61
|
+
/**
|
|
62
|
+
* Updates the transform (position, rotation, scale) of an entity.
|
|
63
|
+
*
|
|
64
|
+
* You can provide a partial transform to update only specific components.
|
|
65
|
+
* For example, you can change just the position while leaving rotation
|
|
66
|
+
* and scale unchanged.
|
|
67
|
+
*
|
|
68
|
+
* @param entity - The entity ID to update
|
|
69
|
+
* @param transform - Partial transform data with the values to update
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* // Move entity to a new position
|
|
74
|
+
* await entities.setTransform(vrmEntity, {
|
|
75
|
+
* translation: [0, 100, 0] // Move up 100 units
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* // Rotate and scale the entity
|
|
79
|
+
* await entities.setTransform(vrmEntity, {
|
|
80
|
+
* rotation: [0, 0, 0, 1], // Reset rotation to identity
|
|
81
|
+
* scale: [2, 2, 2] // Double the size
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* // Update all transform components at once
|
|
85
|
+
* await entities.setTransform(vrmEntity, {
|
|
86
|
+
* translation: [50, 0, -25],
|
|
87
|
+
* rotation: [0, 0.707, 0, 0.707], // 90 degree Y rotation
|
|
88
|
+
* scale: [1.5, 1.5, 1.5]
|
|
89
|
+
* });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
async function setTransform(entity, transform) {
|
|
93
|
+
await host.put(host.createUrl(`entities/${entity}/transform`), transform);
|
|
94
|
+
}
|
|
95
|
+
entities.setTransform = setTransform;
|
|
96
|
+
/**
|
|
97
|
+
* Gets the human-readable name of an entity.
|
|
98
|
+
*
|
|
99
|
+
* Most entities in Desktop Homunculus have names that make them easier
|
|
100
|
+
* to identify and work with. VRM models use their character names,
|
|
101
|
+
* bones use standard bone names like "head", "leftHand", etc.
|
|
102
|
+
*
|
|
103
|
+
* @param entity - The entity ID to get the name for
|
|
104
|
+
* @returns A promise that resolves to the entity's name
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const vrmEntity = await entities.findByName("MyCharacter");
|
|
109
|
+
* const name = await entities.name(vrmEntity);
|
|
110
|
+
* console.log("Entity name:", name); // "MyCharacter"
|
|
111
|
+
*
|
|
112
|
+
* // Get bone names
|
|
113
|
+
* const headBone = await entities.findByName("head", { root: vrmEntity });
|
|
114
|
+
* const boneName = await entities.name(headBone);
|
|
115
|
+
* console.log("Bone name:", boneName); // "head"
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
async function name(entity) {
|
|
119
|
+
const response = await host.get(host.createUrl(`entities/${entity}/name`));
|
|
120
|
+
return await response.json();
|
|
121
|
+
}
|
|
122
|
+
entities.name = name;
|
|
123
|
+
/**
|
|
124
|
+
* Finds an entity by its name, optionally within a specific parent entity.
|
|
125
|
+
*
|
|
126
|
+
* This is the primary method for locating entities in the ECS system.
|
|
127
|
+
* Names are unique within their scope (global or under a specific parent).
|
|
128
|
+
*
|
|
129
|
+
* @param name - The name of the entity to find
|
|
130
|
+
* @param options - Optional search parameters
|
|
131
|
+
* @returns A promise that resolves to the entity ID
|
|
132
|
+
* @throws Will throw an error if no entity with the given name is found
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* // Find a VRM character globally
|
|
137
|
+
* const vrmEntity = await entities.findByName("MyCharacter");
|
|
138
|
+
*
|
|
139
|
+
* // Find a bone within a specific VRM
|
|
140
|
+
* const headBone = await entities.findByName("head", {
|
|
141
|
+
* root: vrmEntity
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* // Find UI elements or other named entities
|
|
145
|
+
* const settingsPanel = await entities.findByName("SettingsPanel");
|
|
146
|
+
* const chatWindow = await entities.findByName("ChatWindow");
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
async function findByName(name, options) {
|
|
150
|
+
const response = await host.get(host.createUrl("entities", {
|
|
151
|
+
name,
|
|
152
|
+
...options,
|
|
153
|
+
}));
|
|
154
|
+
return await response.json();
|
|
155
|
+
}
|
|
156
|
+
entities.findByName = findByName;
|
|
157
|
+
/**
|
|
158
|
+
* Moves an entity to the specified position.
|
|
159
|
+
*
|
|
160
|
+
* Supports two coordinate types:
|
|
161
|
+
* - **World coordinates**: Sets the entity's position directly in 3D world space.
|
|
162
|
+
* `z` is optional — if omitted, the entity keeps its current z position.
|
|
163
|
+
* - **Viewport coordinates**: Screen-space position that is automatically converted
|
|
164
|
+
* to world coordinates internally.
|
|
165
|
+
*
|
|
166
|
+
* @param entity - The entity ID to move
|
|
167
|
+
* @param target - The target position (world or viewport coordinates)
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* // Move to world coordinates
|
|
172
|
+
* await entities.move(vrmEntity, { type: "world", position: [0, 1.5], z: -2 });
|
|
173
|
+
*
|
|
174
|
+
* // Move to world coordinates (keep current z)
|
|
175
|
+
* await entities.move(vrmEntity, { type: "world", position: [0, 1.5] });
|
|
176
|
+
*
|
|
177
|
+
* // Move to a screen position
|
|
178
|
+
* await entities.move(vrmEntity, { type: "viewport", position: [500, 300] });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
async function move(entity, target) {
|
|
182
|
+
await host.post(host.createUrl(`entities/${entity}/move`), target);
|
|
183
|
+
}
|
|
184
|
+
entities.move = move;
|
|
185
|
+
/**
|
|
186
|
+
* Smoothly animate an entity's position to a target value.
|
|
187
|
+
*
|
|
188
|
+
* @param entityId - The entity ID to tween
|
|
189
|
+
* @param request - Tween parameters
|
|
190
|
+
* @returns Promise that resolves when the request completes (or when animation finishes if wait=true)
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* await entities.tweenPosition(myEntity, {
|
|
195
|
+
* target: [100, 50, 0],
|
|
196
|
+
* durationMs: 1000,
|
|
197
|
+
* easing: "quadraticInOut",
|
|
198
|
+
* wait: true,
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
async function tweenPosition(entityId, request) {
|
|
203
|
+
await host.post(host.createUrl(`entities/${entityId}/tween/position`), request);
|
|
204
|
+
}
|
|
205
|
+
entities.tweenPosition = tweenPosition;
|
|
206
|
+
/**
|
|
207
|
+
* Smoothly animate an entity's rotation to a target value.
|
|
208
|
+
*
|
|
209
|
+
* @param entityId - The entity ID to tween
|
|
210
|
+
* @param request - Tween parameters
|
|
211
|
+
* @returns Promise that resolves when the request completes (or when animation finishes if wait=true)
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* await entities.tweenRotation(myEntity, {
|
|
216
|
+
* target: [0, 0, 0.7071, 0.7071], // 90 degrees around Z axis
|
|
217
|
+
* durationMs: 500,
|
|
218
|
+
* easing: "elasticOut",
|
|
219
|
+
* });
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
async function tweenRotation(entityId, request) {
|
|
223
|
+
await host.post(host.createUrl(`entities/${entityId}/tween/rotation`), request);
|
|
224
|
+
}
|
|
225
|
+
entities.tweenRotation = tweenRotation;
|
|
226
|
+
/**
|
|
227
|
+
* Smoothly animate an entity's scale to a target value.
|
|
228
|
+
*
|
|
229
|
+
* @param entityId - The entity ID to tween
|
|
230
|
+
* @param request - Tween parameters
|
|
231
|
+
* @returns Promise that resolves when the request completes (or when animation finishes if wait=true)
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* await entities.tweenScale(myEntity, {
|
|
236
|
+
* target: [2, 2, 2],
|
|
237
|
+
* durationMs: 800,
|
|
238
|
+
* easing: "bounceOut",
|
|
239
|
+
* wait: false,
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
async function tweenScale(entityId, request) {
|
|
244
|
+
await host.post(host.createUrl(`entities/${entityId}/tween/scale`), request);
|
|
245
|
+
}
|
|
246
|
+
entities.tweenScale = tweenScale;
|
|
247
|
+
})(entities || (entities = {}));
|
|
248
|
+
|
|
249
|
+
export { entities };
|