spoint 0.1.56 → 0.1.58

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.
Files changed (2) hide show
  1. package/client/camera.js +16 -0
  2. package/package.json +1 -1
package/client/camera.js CHANGED
@@ -152,6 +152,7 @@ export function createCameraController(camera, scene) {
152
152
  }
153
153
  if (headBone && !headBoneHidden) { headBone.scale.set(0, 0, 0); headBoneHidden = true }
154
154
  const wallDist = 0.35
155
+ const fwdWallDist = 0.25
155
156
  fpsRayTimer += frameDt
156
157
  if (fpsRayTimer >= 0.05 && envMeshes.length) {
157
158
  fpsRayTimer = 0
@@ -171,6 +172,21 @@ export function createCameraController(camera, scene) {
171
172
  }
172
173
  break
173
174
  }
175
+ _fpsRayDir.set(fwdX, fwdY, fwdZ)
176
+ camRaycaster.set(camera.position, _fpsRayDir)
177
+ camRaycaster.far = fwdWallDist
178
+ camRaycaster.near = 0
179
+ const fwdHits = camRaycaster.intersectObjects(envMeshes, true)
180
+ for (const hit of fwdHits) {
181
+ if (localMesh && isDescendant(hit.object, localMesh)) continue
182
+ const push = fwdWallDist - hit.distance
183
+ if (push > 0) {
184
+ camera.position.x -= fwdX * push
185
+ camera.position.y -= fwdY * push
186
+ camera.position.z -= fwdZ * push
187
+ }
188
+ break
189
+ }
174
190
  }
175
191
  camera.lookAt(camera.position.x + fwdX, camera.position.y + fwdY, camera.position.z + fwdZ)
176
192
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spoint",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
4
4
  "description": "Physics and netcode SDK for multiplayer game servers",
5
5
  "type": "module",
6
6
  "main": "src/index.js",