akhaliq HF staff commited on
Commit
c46930f
·
verified ·
1 Parent(s): 4851b06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -95,6 +95,9 @@ with demo:
95
  emojiCtx.textBaseline = 'middle';
96
  emojiCtx.fillText('🤗', 128, 128);
97
  const emojiTexture = new THREE.CanvasTexture(emojiCanvas);
 
 
 
98
  const faceGeometry = new THREE.SphereGeometry(0.8, 32, 32);
99
  const faceMaterial = new THREE.MeshLambertMaterial({ map: emojiTexture });
100
  const face = new THREE.Mesh(faceGeometry, faceMaterial);
@@ -104,8 +107,8 @@ with demo:
104
  face.lane = 0; // -1, 0, 1
105
  face.jumping = false;
106
 
107
- // Ensure initial rotation faces the user
108
- face.rotation.y = Math.PI; // Rotate 180 degrees to face backward initially
109
 
110
  // Collectibles
111
  const gpuCanvas = document.createElement('canvas');
@@ -243,8 +246,10 @@ with demo:
243
  }
244
  }
245
 
246
- // Face the user (camera)
247
- face.lookAt(camera.position);
 
 
248
 
249
  // Spawn items
250
  spawnItems();
 
95
  emojiCtx.textBaseline = 'middle';
96
  emojiCtx.fillText('🤗', 128, 128);
97
  const emojiTexture = new THREE.CanvasTexture(emojiCanvas);
98
+ // Ensure texture is not flipped or rotated incorrectly
99
+ emojiTexture.flipY = false; // Explicitly set to false to maintain correct orientation
100
+
101
  const faceGeometry = new THREE.SphereGeometry(0.8, 32, 32);
102
  const faceMaterial = new THREE.MeshLambertMaterial({ map: emojiTexture });
103
  const face = new THREE.Mesh(faceGeometry, faceMaterial);
 
107
  face.lane = 0; // -1, 0, 1
108
  face.jumping = false;
109
 
110
+ // Ensure initial rotation faces the user (backward, toward camera)
111
+ face.rotation.y = Math.PI; // Rotate 180 degrees around y-axis to face backward
112
 
113
  // Collectibles
114
  const gpuCanvas = document.createElement('canvas');
 
246
  }
247
  }
248
 
249
+ // Face the user (camera) explicitly
250
+ const targetPosition = camera.position.clone();
251
+ targetPosition.y = face.position.y; // Match height to avoid tilting
252
+ face.lookAt(targetPosition);
253
 
254
  // Spawn items
255
  spawnItems();