spoint 0.1.48 → 0.1.50

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.
@@ -0,0 +1,83 @@
1
+ const ASSET_BASE = 'https://raw.githubusercontent.com/anEntrypoint/assets/main'
2
+
3
+ const JUNK_MODELS = [
4
+ `${ASSET_BASE}/dumpster_b076662a_v1.glb`,
5
+ `${ASSET_BASE}/garbage_can_6b3d052b_v1.glb`,
6
+ `${ASSET_BASE}/fire_hydrant_ba0175c1_v1.glb`,
7
+ `${ASSET_BASE}/crushed_oil_barrel_e450f43f_v1.glb`,
8
+ ]
9
+
10
+ const HALF = 12
11
+ const WALL_H = 3
12
+ const WALL_T = 0.5
13
+
14
+ const WALLS = [
15
+ { id: 'arena-wall-n', x: 0, y: WALL_H / 2, z: -HALF, hx: HALF, hy: WALL_H / 2, hz: WALL_T / 2 },
16
+ { id: 'arena-wall-s', x: 0, y: WALL_H / 2, z: HALF, hx: HALF, hy: WALL_H / 2, hz: WALL_T / 2 },
17
+ { id: 'arena-wall-e', x: HALF, y: WALL_H / 2, z: 0, hx: WALL_T / 2, hy: WALL_H / 2, hz: HALF },
18
+ { id: 'arena-wall-w', x: -HALF, y: WALL_H / 2, z: 0, hx: WALL_T / 2, hy: WALL_H / 2, hz: HALF },
19
+ ]
20
+
21
+ const PROPS = [
22
+ { model: 0, x: -6, z: -6, rot: 0.5 },
23
+ { model: 0, x: 7, z: 5, rot: 2.1 },
24
+ { model: 1, x: -8, z: 3, rot: 1.0 },
25
+ { model: 1, x: 5, z: -7, rot: 3.2 },
26
+ { model: 1, x: 3, z: 8, rot: 0.3 },
27
+ { model: 2, x: -4, z: -9, rot: 1.5 },
28
+ { model: 2, x: 9, z: -3, rot: 4.0 },
29
+ { model: 3, x: -7, z: 7, rot: 0.8 },
30
+ { model: 3, x: 6, z: 2, rot: 2.7 },
31
+ { model: 3, x: -3, z: -5, rot: 1.2 },
32
+ ]
33
+
34
+ export default {
35
+ server: {
36
+ setup(ctx) {
37
+ ctx.state.ids = ctx.state.ids || []
38
+ if (ctx.state.ids.length > 0) return
39
+
40
+ // Ground (this entity itself)
41
+ ctx.entity.custom = { mesh: 'box', color: 0x5a7a4a, roughness: 1, sx: HALF * 2, sy: 0.5, sz: HALF * 2 }
42
+ ctx.physics.setStatic(true)
43
+ ctx.physics.addBoxCollider([HALF, 0.25, HALF])
44
+
45
+ // Walls - each gets box-static app which adds its own collider
46
+ for (const w of WALLS) {
47
+ const e = ctx.world.spawn(w.id, {
48
+ position: [w.x, w.y, w.z],
49
+ app: 'box-static',
50
+ config: { hx: w.hx, hy: w.hy, hz: w.hz, color: 0x7a6a5a, roughness: 0.9 }
51
+ })
52
+ if (e) ctx.state.ids.push(w.id)
53
+ }
54
+
55
+ // Props from remote asset repo (static, convex hull from model)
56
+ for (let i = 0; i < PROPS.length; i++) {
57
+ const p = PROPS[i]
58
+ const id = `arena-prop-${i}`
59
+ const a = p.rot / 2
60
+ const e = ctx.world.spawn(id, {
61
+ model: JUNK_MODELS[p.model],
62
+ position: [p.x, 0, p.z],
63
+ rotation: [0, Math.sin(a), 0, Math.cos(a)],
64
+ app: 'prop-static'
65
+ })
66
+ if (e) ctx.state.ids.push(id)
67
+ }
68
+
69
+ ctx.debug.log(`[arena] setup: ground + ${WALLS.length} walls + ${PROPS.length} props`)
70
+ },
71
+
72
+ teardown(ctx) {
73
+ for (const id of ctx.state.ids || []) ctx.world.destroy(id)
74
+ ctx.state.ids = []
75
+ }
76
+ },
77
+
78
+ client: {
79
+ render(ctx) {
80
+ return { position: ctx.entity.position, rotation: ctx.entity.rotation, custom: ctx.entity.custom }
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,24 @@
1
+ export default {
2
+ server: {
3
+ setup(ctx) {
4
+ const c = ctx.config
5
+ if (c.color !== undefined) {
6
+ ctx.entity.custom = {
7
+ mesh: 'box',
8
+ color: c.color,
9
+ roughness: c.roughness ?? 0.9,
10
+ sx: (c.hx ?? 1) * 2,
11
+ sy: (c.hy ?? 1) * 2,
12
+ sz: (c.hz ?? 1) * 2
13
+ }
14
+ }
15
+ ctx.physics.setStatic(true)
16
+ ctx.physics.addBoxCollider([c.hx ?? 1, c.hy ?? 1, c.hz ?? 1])
17
+ }
18
+ },
19
+ client: {
20
+ render(ctx) {
21
+ return { position: ctx.entity.position, rotation: ctx.entity.rotation, custom: ctx.entity.custom }
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,15 @@
1
+ export default {
2
+ server: {
3
+ setup(ctx) {
4
+ ctx.physics.setStatic(true)
5
+ if (ctx.entity.model) {
6
+ ctx.physics.addConvexFromModel(0)
7
+ }
8
+ }
9
+ },
10
+ client: {
11
+ render(ctx) {
12
+ return { position: ctx.entity.position, rotation: ctx.entity.rotation, model: ctx.entity.model }
13
+ }
14
+ }
15
+ }
@@ -62,6 +62,8 @@ export default {
62
62
  { id: 'game', position: [0, 0, 0], app: 'tps-game' },
63
63
  { id: 'power-crates', position: [0, 0, 0], app: 'power-crate' },
64
64
  { id: 'interact-box', position: [-100, 3, -100], app: 'interactable' }
65
+ // To use the primitive arena instead of schwust.glb, replace above with:
66
+ // { id: 'arena', position: [0, 0, 0], app: 'arena' }
65
67
  ],
66
68
  playerModel: './apps/tps-game/cleetus.vrm',
67
69
  spawnPoint: [-35, 3, -65]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spoint",
3
- "version": "0.1.48",
3
+ "version": "0.1.50",
4
4
  "description": "Physics and netcode SDK for multiplayer game servers",
5
5
  "type": "module",
6
6
  "main": "src/index.js",