hytopia 0.1.75 → 0.1.76
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/docs/server.collider.md +2 -2
- package/docs/server.collider.setrelativeposition.md +5 -1
- package/docs/server.collider.setrelativerotation.md +5 -1
- package/docs/server.player.id.md +2 -2
- package/docs/server.player.md +3 -3
- package/docs/server.player.username.md +1 -1
- package/examples/custom-ui/assets/ui/index.html +68 -85
- package/examples/hole-in-wall-game/assets/ui/index.html +2 -1
- package/examples/hole-in-wall-game/index.ts +2 -2
- package/package.json +1 -1
- package/server.api.json +5 -5
- package/server.d.ts +15 -5
- package/server.js +1 -1
package/docs/server.collider.md
CHANGED
@@ -618,7 +618,7 @@ Sets the on collision callback for the collider.
|
|
618
618
|
|
619
619
|
</td><td>
|
620
620
|
|
621
|
-
Sets the
|
621
|
+
Sets the position of the collider relative to its parent rigid body or the world origin.
|
622
622
|
|
623
623
|
|
624
624
|
</td></tr>
|
@@ -632,7 +632,7 @@ Sets the relative position of the collider to its parent rigid body.
|
|
632
632
|
|
633
633
|
</td><td>
|
634
634
|
|
635
|
-
Sets the relative rotation of the collider.
|
635
|
+
Sets the relative rotation of the collider to its parent rigid body or the world origin.
|
636
636
|
|
637
637
|
|
638
638
|
</td></tr>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
## Collider.setRelativePosition() method
|
6
6
|
|
7
|
-
Sets the
|
7
|
+
Sets the position of the collider relative to its parent rigid body or the world origin.
|
8
8
|
|
9
9
|
**Signature:**
|
10
10
|
|
@@ -51,3 +51,7 @@ The relative position of the collider.
|
|
51
51
|
|
52
52
|
void
|
53
53
|
|
54
|
+
## Remarks
|
55
|
+
|
56
|
+
Colliders can be added as a child of a rigid body, or to the world directly. This position is relative to the parent rigid body or the world origin.
|
57
|
+
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
## Collider.setRelativeRotation() method
|
6
6
|
|
7
|
-
Sets the relative rotation of the collider.
|
7
|
+
Sets the relative rotation of the collider to its parent rigid body or the world origin.
|
8
8
|
|
9
9
|
**Signature:**
|
10
10
|
|
@@ -51,3 +51,7 @@ The relative rotation of the collider.
|
|
51
51
|
|
52
52
|
void
|
53
53
|
|
54
|
+
## Remarks
|
55
|
+
|
56
|
+
Colliders can be added as a child of a rigid body, or to the world directly. This rotation is relative to the parent rigid body or the world origin.
|
57
|
+
|
package/docs/server.player.id.md
CHANGED
package/docs/server.player.md
CHANGED
@@ -74,12 +74,12 @@ The camera for the player.
|
|
74
74
|
|
75
75
|
</td><td>
|
76
76
|
|
77
|
-
|
77
|
+
string
|
78
78
|
|
79
79
|
|
80
80
|
</td><td>
|
81
81
|
|
82
|
-
The unique
|
82
|
+
The unique HYTOPIA UUID for the player.
|
83
83
|
|
84
84
|
|
85
85
|
</td></tr>
|
@@ -142,7 +142,7 @@ string
|
|
142
142
|
|
143
143
|
</td><td>
|
144
144
|
|
145
|
-
The username for the player.
|
145
|
+
The unique HYTOPIA username for the player.
|
146
146
|
|
147
147
|
|
148
148
|
</td></tr>
|
@@ -1,91 +1,74 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<script>
|
2
|
+
// Handle received data from server
|
3
|
+
hytopia.onData(data => {
|
4
|
+
if (data.type === 'playerList') {
|
5
|
+
const { list } = data;
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
with `npm install hytopia-ui` and then import it as
|
10
|
-
`import hytopia from 'hytopia-ui';`
|
11
|
-
-->
|
12
|
-
<script src="https://unpkg.com/hytopia-ui@latest/dist/index.umd.js"></script>
|
7
|
+
// Update player count
|
8
|
+
document.getElementById('player-count').textContent = `Players Connected: ${list.length}`;
|
13
9
|
|
14
|
-
|
15
|
-
document.
|
16
|
-
|
17
|
-
hytopia.ui.onData = data => {
|
18
|
-
if (data.type === 'playerList') {
|
19
|
-
const { list } = data;
|
10
|
+
// Clear and rebuild player list
|
11
|
+
const playerListElement = document.getElementById('player-list');
|
12
|
+
playerListElement.innerHTML = '';
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
// Add each player to the list
|
29
|
-
list.forEach(player => {
|
30
|
-
const pos = player.position;
|
31
|
-
const playerRow = document.createElement('div');
|
32
|
-
playerRow.className = 'player-row';
|
33
|
-
playerRow.textContent = `${player.username}: x:${pos.x.toFixed(1)}, y:${pos.y.toFixed(1)}, z:${pos.z.toFixed(1)}`;
|
34
|
-
playerListElement.appendChild(playerRow);
|
35
|
-
});
|
36
|
-
}
|
37
|
-
}
|
38
|
-
|
39
|
-
// Send data to server on teleport btn press
|
40
|
-
document.getElementById('teleport-btn').addEventListener('click', () => {
|
41
|
-
// We can send any arbitrary object to the server. We as the developer define
|
42
|
-
// whatever schema we want to use for data between client and server.
|
43
|
-
// For now we'll just use a "type" property we made up so the server knows
|
44
|
-
// what to do with the data.
|
45
|
-
hytopia.ui.sendData({ type: 'teleport' });
|
46
|
-
});
|
14
|
+
// Add each player to the list
|
15
|
+
list.forEach(player => {
|
16
|
+
const pos = player.position;
|
17
|
+
const playerRow = document.createElement('div');
|
18
|
+
playerRow.className = 'player-row';
|
19
|
+
playerRow.textContent = `${player.username}: x:${pos.x.toFixed(1)}, y:${pos.y.toFixed(1)}, z:${pos.z.toFixed(1)}`;
|
20
|
+
playerListElement.appendChild(playerRow);
|
47
21
|
});
|
48
|
-
|
22
|
+
}
|
23
|
+
});
|
24
|
+
|
25
|
+
// Send data to server on teleport btn press
|
26
|
+
document.getElementById('teleport-btn').addEventListener('click', () => {
|
27
|
+
// We can send any arbitrary object to the server. We as the developer define
|
28
|
+
// whatever schema we want to use for data between client and server.
|
29
|
+
// For now we'll just use a "type" property we made up so the server knows
|
30
|
+
// what to do with the data.
|
31
|
+
hytopia.sendData({ type: 'teleport' });
|
32
|
+
});
|
33
|
+
</script>
|
49
34
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
35
|
+
<div id="player-panel">
|
36
|
+
<div id="player-count">Players Connected: 0</div>
|
37
|
+
<div id="player-list"></div>
|
38
|
+
<button id="teleport-btn">Click to Teleport!</button>
|
39
|
+
</div>
|
55
40
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
</body>
|
91
|
-
</html>
|
41
|
+
<style>
|
42
|
+
#player-panel {
|
43
|
+
position: absolute;
|
44
|
+
right: 20px;
|
45
|
+
top: 20px;
|
46
|
+
background-color: rgba(0, 0, 0, 0.7);
|
47
|
+
color: white;
|
48
|
+
padding: 15px;
|
49
|
+
border-radius: 8px;
|
50
|
+
min-width: 200px;
|
51
|
+
font-family: Arial, sans-serif;
|
52
|
+
letter-spacing: 0.5px;
|
53
|
+
}
|
54
|
+
.player-row {
|
55
|
+
margin: 8px 0;
|
56
|
+
}
|
57
|
+
#teleport-btn {
|
58
|
+
width: 100%;
|
59
|
+
padding: 8px;
|
60
|
+
margin-top: 15px;
|
61
|
+
background-color: #4CAF50;
|
62
|
+
color: white;
|
63
|
+
border: none;
|
64
|
+
border-radius: 4px;
|
65
|
+
cursor: pointer;
|
66
|
+
font-family: Arial, sans-serif;
|
67
|
+
font-weight: bold;
|
68
|
+
text-transform: uppercase;
|
69
|
+
letter-spacing: 1px;
|
70
|
+
}
|
71
|
+
#teleport-btn:hover {
|
72
|
+
background-color: #45a049;
|
73
|
+
}
|
74
|
+
</style>
|
@@ -62,10 +62,11 @@
|
|
62
62
|
const gameCountdownStartTime = data.gameCountdownStartTime;
|
63
63
|
const countdownSeconds = data.countdown;
|
64
64
|
|
65
|
+
let timeLeft = countdownSeconds;
|
65
66
|
const updateCountdown = () => {
|
66
67
|
if (timeLeft > 0 && gameState === 'starting') {
|
67
68
|
const now = Date.now();
|
68
|
-
|
69
|
+
timeLeft = Math.max(0, Math.ceil((gameCountdownStartTime + (countdownSeconds * 1000) - now) / 1000));
|
69
70
|
updateGameStatus(`GAME STARTING IN ${timeLeft}...`);
|
70
71
|
setTimeout(updateCountdown, 1000);
|
71
72
|
}
|
@@ -98,8 +98,8 @@ function onPlayerJoin(world: World, player: Player) {
|
|
98
98
|
playerEntity.spawn(world, GAME_CONFIG.POSITIONS.PLAYER_SPAWN);
|
99
99
|
|
100
100
|
playerEntity.setCollisionGroupsForSolidColliders({
|
101
|
-
belongsTo: [CollisionGroup.
|
102
|
-
collidesWith: [CollisionGroup.BLOCK, CollisionGroup.ENTITY_SENSOR, GAME_CONFIG.WALL_COLLISION_GROUP],
|
101
|
+
belongsTo: [CollisionGroup.PLAYER],
|
102
|
+
collidesWith: [CollisionGroup.BLOCK, CollisionGroup.ENTITY, CollisionGroup.ENTITY_SENSOR, GAME_CONFIG.WALL_COLLISION_GROUP],
|
103
103
|
});
|
104
104
|
|
105
105
|
playerEntity.setCollisionGroupsForSensorColliders({
|
package/package.json
CHANGED
package/server.api.json
CHANGED
@@ -7626,7 +7626,7 @@
|
|
7626
7626
|
{
|
7627
7627
|
"kind": "Method",
|
7628
7628
|
"canonicalReference": "server!Collider#setRelativePosition:member(1)",
|
7629
|
-
"docComment": "/**\n * Sets the
|
7629
|
+
"docComment": "/**\n * Sets the position of the collider relative to its parent rigid body or the world origin.\n *\n * @remarks\n *\n * Colliders can be added as a child of a rigid body, or to the world directly. This position is relative to the parent rigid body or the world origin.\n *\n * @param position - The relative position of the collider.\n */\n",
|
7630
7630
|
"excerptTokens": [
|
7631
7631
|
{
|
7632
7632
|
"kind": "Content",
|
@@ -7675,7 +7675,7 @@
|
|
7675
7675
|
{
|
7676
7676
|
"kind": "Method",
|
7677
7677
|
"canonicalReference": "server!Collider#setRelativeRotation:member(1)",
|
7678
|
-
"docComment": "/**\n * Sets the relative rotation of the collider.\n *\n * @param rotation - The relative rotation of the collider.\n */\n",
|
7678
|
+
"docComment": "/**\n * Sets the relative rotation of the collider to its parent rigid body or the world origin.\n *\n * @remarks\n *\n * Colliders can be added as a child of a rigid body, or to the world directly. This rotation is relative to the parent rigid body or the world origin.\n *\n * @param rotation - The relative rotation of the collider.\n */\n",
|
7679
7679
|
"excerptTokens": [
|
7680
7680
|
{
|
7681
7681
|
"kind": "Content",
|
@@ -16956,7 +16956,7 @@
|
|
16956
16956
|
{
|
16957
16957
|
"kind": "Property",
|
16958
16958
|
"canonicalReference": "server!Player#id:member",
|
16959
|
-
"docComment": "/**\n * The unique
|
16959
|
+
"docComment": "/**\n * The unique HYTOPIA UUID for the player.\n */\n",
|
16960
16960
|
"excerptTokens": [
|
16961
16961
|
{
|
16962
16962
|
"kind": "Content",
|
@@ -16964,7 +16964,7 @@
|
|
16964
16964
|
},
|
16965
16965
|
{
|
16966
16966
|
"kind": "Content",
|
16967
|
-
"text": "
|
16967
|
+
"text": "string"
|
16968
16968
|
},
|
16969
16969
|
{
|
16970
16970
|
"kind": "Content",
|
@@ -17128,7 +17128,7 @@
|
|
17128
17128
|
{
|
17129
17129
|
"kind": "Property",
|
17130
17130
|
"canonicalReference": "server!Player#username:member",
|
17131
|
-
"docComment": "/**\n * The username for the player.\n */\n",
|
17131
|
+
"docComment": "/**\n * The unique HYTOPIA username for the player.\n */\n",
|
17132
17132
|
"excerptTokens": [
|
17133
17133
|
{
|
17134
17134
|
"kind": "Content",
|
package/server.d.ts
CHANGED
@@ -983,12 +983,22 @@ export declare class Collider {
|
|
983
983
|
*/
|
984
984
|
setOnCollision(callback: CollisionCallback | undefined): void;
|
985
985
|
/**
|
986
|
-
* Sets the relative rotation of the collider.
|
986
|
+
* Sets the relative rotation of the collider to its parent rigid body or the world origin.
|
987
|
+
*
|
988
|
+
* @remarks
|
989
|
+
* Colliders can be added as a child of a rigid body, or to the world directly. This rotation
|
990
|
+
* is relative to the parent rigid body or the world origin.
|
991
|
+
*
|
987
992
|
* @param rotation - The relative rotation of the collider.
|
988
993
|
*/
|
989
994
|
setRelativeRotation(rotation: QuaternionLike): void;
|
990
995
|
/**
|
991
|
-
* Sets the
|
996
|
+
* Sets the position of the collider relative to its parent rigid body or the world origin.
|
997
|
+
*
|
998
|
+
* @remarks
|
999
|
+
* Colliders can be added as a child of a rigid body, or to the world directly. This position
|
1000
|
+
* is relative to the parent rigid body or the world origin.
|
1001
|
+
*
|
992
1002
|
* @param position - The relative position of the collider.
|
993
1003
|
*/
|
994
1004
|
setRelativePosition(position: Vector3Like): void;
|
@@ -2157,9 +2167,9 @@ export declare type MoveOptions = {
|
|
2157
2167
|
* @public
|
2158
2168
|
*/
|
2159
2169
|
export declare class Player {
|
2160
|
-
/** The unique
|
2161
|
-
readonly id:
|
2162
|
-
/** The username for the player. */
|
2170
|
+
/** The unique HYTOPIA UUID for the player. */
|
2171
|
+
readonly id: string;
|
2172
|
+
/** The unique HYTOPIA username for the player. */
|
2163
2173
|
readonly username: string;
|
2164
2174
|
/** The camera for the player. */
|
2165
2175
|
readonly camera: PlayerCamera;
|