-
+
@@ -63,7 +64,7 @@
:rotation="[-Math.PI / 2, 0, 0]"
:scale="[0.75 * scale, 0.75 * scale, 0.75 * scale]"
>
-
+
+
@@ -161,9 +163,9 @@ const nametagText = computed(() => props.nametag)
const { fontSize: nametagFontSize } = useDynamicFontSize({
containerElement: skinPreviewContainer,
text: nametagText,
- baseFontSize: 2,
+ baseFontSize: 1.8,
minFontSize: 1.25,
- maxFontSize: 4,
+ maxFontSize: 2,
padding: 24,
fontFamily: 'inherit',
})
@@ -190,6 +192,7 @@ const actions = ref>({})
const clock = new THREE.Clock()
const currentAnimation = ref('')
const randomAnimationTimer = ref(null)
+const lastRandomAnimation = ref('')
const { baseAnimation, randomAnimations } = toRefs(props.animationConfig)
@@ -282,18 +285,36 @@ function playAnimation(name: string) {
function setupRandomAnimationLoop() {
const interval = props.animationConfig.randomAnimationInterval || 10000
- randomAnimationTimer.value = window.setInterval(() => {
- if (randomAnimations.value.length > 0) {
- if (currentAnimation.value === baseAnimation.value) {
- const randomIndex = Math.floor(Math.random() * randomAnimations.value.length)
- const randomAnimationName = randomAnimations.value[randomIndex]
+ function scheduleNextAnimation() {
+ if (randomAnimationTimer.value) {
+ clearTimeout(randomAnimationTimer.value)
+ }
+
+ randomAnimationTimer.value = window.setTimeout(() => {
+ if (randomAnimations.value.length > 0 && currentAnimation.value === baseAnimation.value) {
+ const availableAnimations = randomAnimations.value.filter(
+ (anim) => anim !== lastRandomAnimation.value,
+ )
+
+ // If all animations have been used, reset and use the full list
+ const animationsToChooseFrom =
+ availableAnimations.length > 0 ? availableAnimations : randomAnimations.value
+
+ const randomIndex = Math.floor(Math.random() * animationsToChooseFrom.length)
+ const randomAnimationName = animationsToChooseFrom[randomIndex]
if (actions.value[randomAnimationName]) {
+ lastRandomAnimation.value = randomAnimationName
playRandomAnimation(randomAnimationName)
}
+ } else {
+ // If not in base animation, wait and try again
+ scheduleNextAnimation()
}
- }
- }, interval)
+ }, interval)
+ }
+
+ scheduleNextAnimation()
}
function playRandomAnimation(name: string) {
@@ -334,6 +355,9 @@ function playRandomAnimation(name: string) {
baseAction.fadeIn(transitionDuration)
baseAction.play()
currentAnimation.value = baseAnimation.value
+
+ // Schedule the next random animation after returning to base
+ setupRandomAnimationLoop()
}
}
}
@@ -528,7 +552,7 @@ function createRadialTexture(size: number): THREE.CanvasTexture {
canvas.width = canvas.height = size
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D
const grad = ctx.createRadialGradient(size / 2, size / 2, 0, size / 2, size / 2, size / 2)
- grad.addColorStop(0, 'rgba(119,119,119,0.15)')
+ grad.addColorStop(0, 'rgba(119,119,119,0.1)')
grad.addColorStop(0.9, 'rgba(255,255,255,0)')
ctx.fillStyle = grad
ctx.fillRect(0, 0, size, size)
@@ -578,7 +602,7 @@ watch(
() => props.animationConfig,
(newConfig) => {
if (randomAnimationTimer.value) {
- clearInterval(randomAnimationTimer.value)
+ clearTimeout(randomAnimationTimer.value)
randomAnimationTimer.value = null
}
@@ -612,7 +636,7 @@ onBeforeMount(async () => {
onUnmounted(() => {
if (randomAnimationTimer.value) {
- clearInterval(randomAnimationTimer.value)
+ clearTimeout(randomAnimationTimer.value)
}
if (mixer.value) {
diff --git a/packages/utils/three/skin-rendering.ts b/packages/utils/three/skin-rendering.ts
index e8d75ef05..1d83db586 100644
--- a/packages/utils/three/skin-rendering.ts
+++ b/packages/utils/three/skin-rendering.ts
@@ -71,6 +71,7 @@ export function applyTexture(model: THREE.Object3D, texture: THREE.Texture): voi
mat.metalness = 0
mat.color.set(0xffffff)
mat.toneMapped = false
+ mat.flatShading = true
mat.roughness = 1
mat.needsUpdate = true
mat.depthTest = true
@@ -100,6 +101,7 @@ export function applyCapeTexture(
mat.metalness = 0
mat.color.set(0xffffff)
mat.toneMapped = false
+ mat.flatShading = true
mat.roughness = 1
mat.needsUpdate = true
mat.depthTest = true