spoint 0.1.44 → 0.1.45
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/LoadingManager.js +3 -1
- package/client/app.js +11 -2
- package/package.json +1 -1
package/client/LoadingManager.js
CHANGED
|
@@ -79,6 +79,8 @@ export class LoadingManager extends EventTarget {
|
|
|
79
79
|
const response = await fetch(url)
|
|
80
80
|
if (!response.ok) throw new Error(`HTTP ${response.status}`)
|
|
81
81
|
const contentLength = parseInt(response.headers.get('content-length') || '0', 10)
|
|
82
|
+
const isGzip = (response.headers.get('content-encoding') || '').includes('gzip')
|
|
83
|
+
const useTotal = contentLength > 0 && !isGzip
|
|
82
84
|
const reader = response.body.getReader()
|
|
83
85
|
const chunks = []
|
|
84
86
|
let receivedLength = 0
|
|
@@ -88,7 +90,7 @@ export class LoadingManager extends EventTarget {
|
|
|
88
90
|
if (done) break
|
|
89
91
|
chunks.push(value)
|
|
90
92
|
receivedLength += value.length
|
|
91
|
-
if (
|
|
93
|
+
if (useTotal) {
|
|
92
94
|
this.updateProgress(receivedLength, contentLength)
|
|
93
95
|
}
|
|
94
96
|
}
|
package/client/app.js
CHANGED
|
@@ -977,8 +977,9 @@ function loadEntityModel(entityId, entityState) {
|
|
|
977
977
|
fitShadowFrustum()
|
|
978
978
|
pendingLoads.delete(entityId)
|
|
979
979
|
if (!environmentLoaded) { environmentLoaded = true; checkAllLoaded() }
|
|
980
|
+
if (firstSnapshotEntityPending.has(entityId)) { firstSnapshotEntityPending.delete(entityId); if (firstSnapshotEntityPending.size === 0) checkAllLoaded() }
|
|
980
981
|
if (loadingScreenHidden) renderer.compileAsync(scene, camera).catch(() => renderer.compile(scene, camera))
|
|
981
|
-
}, (progress) => { if (progress.total > 0) console.log('[gltf]', url, Math.round(progress.loaded / progress.total * 100) + '%') }, (err) => { console.error('[gltf]', url, err); pendingLoads.delete(entityId) })
|
|
982
|
+
}, (progress) => { if (progress.total > 0) console.log('[gltf]', url, Math.round(Math.min(progress.loaded, progress.total) / progress.total * 100) + '%') }, (err) => { console.error('[gltf]', url, err); pendingLoads.delete(entityId); if (firstSnapshotEntityPending.has(entityId)) { firstSnapshotEntityPending.delete(entityId); if (firstSnapshotEntityPending.size === 0) checkAllLoaded() } })
|
|
982
983
|
}
|
|
983
984
|
|
|
984
985
|
function renderAppUI(state) {
|
|
@@ -1026,7 +1027,13 @@ const client = new PhysicsNetworkClient({
|
|
|
1026
1027
|
}
|
|
1027
1028
|
rebuildEntityHierarchy(smoothState.entities)
|
|
1028
1029
|
latestState = state
|
|
1029
|
-
if (!firstSnapshotReceived) {
|
|
1030
|
+
if (!firstSnapshotReceived) {
|
|
1031
|
+
firstSnapshotReceived = true
|
|
1032
|
+
for (const e of smoothState.entities) {
|
|
1033
|
+
if (e.model && !entityMeshes.has(e.id)) firstSnapshotEntityPending.add(e.id)
|
|
1034
|
+
}
|
|
1035
|
+
checkAllLoaded()
|
|
1036
|
+
}
|
|
1030
1037
|
},
|
|
1031
1038
|
onPlayerJoined: (id) => { if (!playerMeshes.has(id)) createPlayerVRM(id) },
|
|
1032
1039
|
onPlayerLeft: (id) => removePlayerMesh(id),
|
|
@@ -1091,6 +1098,7 @@ let inputLoopId = null
|
|
|
1091
1098
|
let loadingScreenHidden = false
|
|
1092
1099
|
let environmentLoaded = false
|
|
1093
1100
|
let firstSnapshotReceived = false
|
|
1101
|
+
const firstSnapshotEntityPending = new Set()
|
|
1094
1102
|
let lastShootState = false
|
|
1095
1103
|
let lastHealth = 100
|
|
1096
1104
|
|
|
@@ -1123,6 +1131,7 @@ function checkAllLoaded() {
|
|
|
1123
1131
|
if (!assetsLoaded) return
|
|
1124
1132
|
if (!environmentLoaded) return
|
|
1125
1133
|
if (!firstSnapshotReceived) return
|
|
1134
|
+
if (firstSnapshotEntityPending.size > 0) return
|
|
1126
1135
|
loadingMgr.setStage('INIT')
|
|
1127
1136
|
loadingMgr.complete()
|
|
1128
1137
|
loadingScreenHidden = true
|