spoint 0.1.43 → 0.1.44
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/animation.js +15 -13
- package/client/app.js +3 -4
- package/package.json +1 -1
package/client/animation.js
CHANGED
|
@@ -123,21 +123,23 @@ function normalizeClips(gltf, vrmVersion, vrmHumanoid) {
|
|
|
123
123
|
return clips
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
let
|
|
127
|
-
let
|
|
126
|
+
let _gltfPromise = null
|
|
127
|
+
let _normalizedCache = null
|
|
128
|
+
|
|
129
|
+
export function preloadAnimationLibrary() {
|
|
130
|
+
if (_gltfPromise) return _gltfPromise
|
|
131
|
+
_gltfPromise = new GLTFLoader().loadAsync('/anim-lib.glb')
|
|
132
|
+
return _gltfPromise
|
|
133
|
+
}
|
|
128
134
|
|
|
129
135
|
export async function loadAnimationLibrary(vrmVersion, vrmHumanoid) {
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
_animLibCache = { normalizedClips }
|
|
138
|
-
return _animLibCache
|
|
139
|
-
})()
|
|
140
|
-
return _animLibPromise
|
|
136
|
+
if (_normalizedCache) return _normalizedCache
|
|
137
|
+
const gltf = await preloadAnimationLibrary()
|
|
138
|
+
if (_normalizedCache) return _normalizedCache
|
|
139
|
+
const normalizedClips = normalizeClips(gltf, vrmVersion || '1', vrmHumanoid)
|
|
140
|
+
console.log(`[anim] Loaded animation library (${normalizedClips.size} clips):`, [...normalizedClips.keys()])
|
|
141
|
+
_normalizedCache = { normalizedClips }
|
|
142
|
+
return _normalizedCache
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
export function createPlayerAnimator(vrm, allClips, vrmVersion, animConfig = {}) {
|
package/client/app.js
CHANGED
|
@@ -9,7 +9,7 @@ import { VRMLoaderPlugin, VRMUtils } from '@pixiv/three-vrm'
|
|
|
9
9
|
import { PhysicsNetworkClient, InputHandler, MSG } from '/src/index.client.js'
|
|
10
10
|
import { createElement, applyDiff } from 'webjsx'
|
|
11
11
|
import { createCameraController } from './camera.js'
|
|
12
|
-
import { loadAnimationLibrary, createPlayerAnimator } from './animation.js'
|
|
12
|
+
import { loadAnimationLibrary, preloadAnimationLibrary, createPlayerAnimator } from './animation.js'
|
|
13
13
|
import { initFacialSystem } from './facial-animation.js'
|
|
14
14
|
import { VRButton } from 'three/addons/webxr/VRButton.js'
|
|
15
15
|
import { XRControllerModelFactory } from 'three/addons/webxr/XRControllerModelFactory.js'
|
|
@@ -713,16 +713,15 @@ function detectVrmVersion(buffer) {
|
|
|
713
713
|
|
|
714
714
|
function initAssets(playerModelUrl) {
|
|
715
715
|
loadingMgr.setStage('DOWNLOAD')
|
|
716
|
-
|
|
716
|
+
preloadAnimationLibrary()
|
|
717
717
|
assetsReady = loadingMgr.fetchWithProgress(playerModelUrl).then(async b => {
|
|
718
718
|
vrmBuffer = b
|
|
719
719
|
loadingMgr.setStage('PROCESS')
|
|
720
|
-
animAssets = await
|
|
720
|
+
animAssets = await loadAnimationLibrary(detectVrmVersion(b), null)
|
|
721
721
|
assetsLoaded = true
|
|
722
722
|
checkAllLoaded()
|
|
723
723
|
}).catch(err => {
|
|
724
724
|
console.warn('[assets] player model unavailable:', err.message)
|
|
725
|
-
animLibPromise.then(r => { animAssets = r }).catch(() => {})
|
|
726
725
|
assetsLoaded = true
|
|
727
726
|
checkAllLoaded()
|
|
728
727
|
})
|