spoint 0.1.40 → 0.1.42

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/client/app.js CHANGED
@@ -1,4 +1,8 @@
1
1
  import * as THREE from 'three'
2
+ import { computeBoundsTree, disposeBoundsTree, acceleratedRaycast } from 'three-mesh-bvh'
3
+ THREE.BufferGeometry.prototype.computeBoundsTree = computeBoundsTree
4
+ THREE.BufferGeometry.prototype.disposeBoundsTree = disposeBoundsTree
5
+ THREE.Mesh.prototype.raycast = acceleratedRaycast
2
6
  import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js'
3
7
  import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js'
4
8
  import { VRMLoaderPlugin, VRMUtils } from '@pixiv/three-vrm'
@@ -953,7 +957,7 @@ function loadEntityModel(entityId, entityState) {
953
957
  if (c.isMesh) {
954
958
  c.castShadow = true
955
959
  c.receiveShadow = true
956
- if (!c.isSkinnedMesh) { c.matrixAutoUpdate = false; colliders.push(c) }
960
+ if (!c.isSkinnedMesh) { c.matrixAutoUpdate = false; c.geometry.computeBoundsTree(); colliders.push(c) }
957
961
  if (c.material) { c.material.shadowSide = THREE.DoubleSide; c.material.roughness = 1; c.material.metalness = 0; if (c.material.specularIntensity !== undefined) c.material.specularIntensity = 0 }
958
962
  }
959
963
  })
package/client/camera.js CHANGED
@@ -27,7 +27,7 @@ function isDescendant(obj, ancestor) {
27
27
  const _boneWorldPos = new THREE.Vector3()
28
28
  const _boneForward = new THREE.Vector3()
29
29
  const _fpsRayOrigin = new THREE.Vector3()
30
- const _fpsRayDirs = [[0,0,0],[0,0,0],[0,0,0],[0,1,0],[0,-1,0]]
30
+ const _fpsRayDir = new THREE.Vector3()
31
31
 
32
32
  export function createCameraController(camera, scene) {
33
33
  let yaw = 0, pitch = 0, zoomIndex = 2, camInitialized = false
@@ -153,29 +153,23 @@ export function createCameraController(camera, scene) {
153
153
  if (headBone && !headBoneHidden) { headBone.scale.set(0, 0, 0); headBoneHidden = true }
154
154
  const wallDist = 0.35
155
155
  fpsRayTimer += frameDt
156
- const doFpsRaycast = fpsRayTimer >= 0.05
157
- if (doFpsRaycast && envMeshes.length) {
156
+ if (fpsRayTimer >= 0.05 && envMeshes.length) {
158
157
  fpsRayTimer = 0
159
158
  _fpsRayOrigin.copy(camera.position)
160
- _fpsRayDirs[0][0] = fwdX; _fpsRayDirs[0][1] = fwdY; _fpsRayDirs[0][2] = fwdZ
161
- _fpsRayDirs[1][0] = rightX; _fpsRayDirs[1][1] = 0; _fpsRayDirs[1][2] = rightZ
162
- _fpsRayDirs[2][0] = -rightX; _fpsRayDirs[2][1] = 0; _fpsRayDirs[2][2] = -rightZ
163
- for (const d of _fpsRayDirs) {
164
- camDir.set(-d[0], -d[1], -d[2])
165
- camRaycaster.set(_fpsRayOrigin, camDir)
166
- camRaycaster.far = wallDist
167
- camRaycaster.near = 0
168
- const hits = camRaycaster.intersectObjects(envMeshes, true)
169
- for (const hit of hits) {
170
- if (localMesh && isDescendant(hit.object, localMesh)) continue
171
- const push = wallDist - hit.distance
172
- if (push > 0) {
173
- camera.position.x += d[0] * push
174
- camera.position.y += d[1] * push
175
- camera.position.z += d[2] * push
176
- }
177
- break
159
+ _fpsRayDir.set(-fwdX, -fwdY, -fwdZ)
160
+ camRaycaster.set(_fpsRayOrigin, _fpsRayDir)
161
+ camRaycaster.far = wallDist
162
+ camRaycaster.near = 0
163
+ const hits = camRaycaster.intersectObjects(envMeshes, true)
164
+ for (const hit of hits) {
165
+ if (localMesh && isDescendant(hit.object, localMesh)) continue
166
+ const push = wallDist - hit.distance
167
+ if (push > 0) {
168
+ camera.position.x += fwdX * push
169
+ camera.position.y += fwdY * push
170
+ camera.position.z += fwdZ * push
178
171
  }
172
+ break
179
173
  }
180
174
  }
181
175
  camera.lookAt(camera.position.x + fwdX, camera.position.y + fwdY, camera.position.z + fwdZ)
package/client/index.html CHANGED
@@ -13,6 +13,7 @@
13
13
  "three": "https://esm.sh/three@0.171.0",
14
14
  "three/addons/": "https://esm.sh/three@0.171.0/examples/jsm/",
15
15
  "@pixiv/three-vrm": "https://esm.sh/@pixiv/three-vrm@3?external=three",
16
+ "three-mesh-bvh": "/vendor/three-mesh-bvh.module.js",
16
17
  "webjsx": "https://esm.sh/webjsx@0.0.73",
17
18
  "webjsx/jsx-runtime": "https://esm.sh/webjsx@0.0.73/jsx-runtime"
18
19
  }