awacke1 commited on
Commit
badfc89
ยท
verified ยท
1 Parent(s): 9c98a20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -143,11 +143,11 @@ def load_aframe_and_extras():
143
  case 'rotateCW':
144
  rotVelocity.y = Math.max(rotVelocity.y - rotAccel, -maxRotSpeed);
145
  break;
146
- case 'rollCCW':
147
- rotVelocity.z = Math.min(rotVelocity.z + rotAccel, maxRotSpeed);
148
  break;
149
- case 'rollCW':
150
- rotVelocity.z = Math.max(rotVelocity.z - rotAccel, -maxRotSpeed);
151
  break;
152
  case 'forward':
153
  var cam = document.querySelector('[camera]');
@@ -227,8 +227,8 @@ def load_aframe_and_extras():
227
  case '9': moveCamera('angle4'); break;
228
  case 'q': flyCamera('rotateCCW'); break;
229
  case 'e': flyCamera('rotateCW'); break;
230
- case 'z': flyCamera('rollCCW'); break;
231
- case 'c': flyCamera('rollCW'); break;
232
  case 'a': flyCamera('moveLeft'); break;
233
  case 'd': flyCamera('moveRight'); break;
234
  case 'w': flyCamera('forward'); break;
@@ -280,9 +280,9 @@ def generate_tilemap(files, dirpath, gw=8, gh=8):
280
  elif ext in img_exts:
281
  assets += f'<img id="{stem}" src="data:image/{ext};base64,{data}">'
282
  elif ext in vid_exts:
283
- assets += (f'<video id="{stem}" '
284
  f'src="data:video/mp4;base64,{data}" '
285
- 'loop autoplay muted></video>')
286
  assets += "</a-assets>"
287
 
288
  # ๐Ÿž๏ธ 4.2 Build the Scene: Lay out the tiles and models! ๐Ÿก
@@ -290,9 +290,13 @@ def generate_tilemap(files, dirpath, gw=8, gh=8):
290
  model_counts = {f: 0 for f in models} # Track spawned model counts ๐Ÿ“Š
291
  if vids:
292
  v = vids[0]; s = Path(v).stem
293
- entities += (f'<a-video src="#{s}" width="{gw}" height="{gh}" '
 
 
 
 
294
  f'rotation="-90 0 0" position="0 0.05 0" '
295
- 'loop autoplay></a-video>')
296
  else:
297
  sx = -gw/2; sz = -gh/2
298
  for i in range(gw):
@@ -339,7 +343,7 @@ def main():
339
  accept_multiple_files=True
340
  )
341
  st.markdown("### ๐Ÿ“‹ Uploaded Model Files")
342
- directory = st.text_input("Path:", ".", key="dir")
343
  if os.path.isdir(directory):
344
  files = [f for f in os.listdir(directory) if f.split('.')[-1] in ['obj', 'glb', 'gltf']]
345
  if files:
 
143
  case 'rotateCW':
144
  rotVelocity.y = Math.max(rotVelocity.y - rotAccel, -maxRotSpeed);
145
  break;
146
+ case 'pitchUp':
147
+ rotVelocity.x = Math.max(rotVelocity.x - rotAccel, -maxRotSpeed);
148
  break;
149
+ case 'pitchDown':
150
+ rotVelocity.x = Math.min(rotVelocity.x + rotAccel, maxRotSpeed);
151
  break;
152
  case 'forward':
153
  var cam = document.querySelector('[camera]');
 
227
  case '9': moveCamera('angle4'); break;
228
  case 'q': flyCamera('rotateCCW'); break;
229
  case 'e': flyCamera('rotateCW'); break;
230
+ case 'z': flyCamera('pitchUp'); break;
231
+ case 'c': flyCamera('pitchDown'); break;
232
  case 'a': flyCamera('moveLeft'); break;
233
  case 'd': flyCamera('moveRight'); break;
234
  case 'w': flyCamera('forward'); break;
 
280
  elif ext in img_exts:
281
  assets += f'<img id="{stem}" src="data:image/{ext};base64,{data}">'
282
  elif ext in vid_exts:
283
+ assets += (f'<video id="{stem}" preload="auto" '
284
  f'src="data:video/mp4;base64,{data}" '
285
+ 'loop="true" autoplay="true" muted="true" playsinline webkit-playsinline></video>')
286
  assets += "</a-assets>"
287
 
288
  # ๐Ÿž๏ธ 4.2 Build the Scene: Lay out the tiles and models! ๐Ÿก
 
290
  model_counts = {f: 0 for f in models} # Track spawned model counts ๐Ÿ“Š
291
  if vids:
292
  v = vids[0]; s = Path(v).stem
293
+ // ๐Ÿ“น Adjust video dimensions to cover the tilemap while preserving aspect ratio ๐ŸŽฅ
294
+ // Assume a common video aspect ratio (16:9) and scale to fit 8x8 tilemap
295
+ const videoWidth = 8; // Match tilemap width
296
+ const videoHeight = 8; // Match tilemap height (square to fit tilemap)
297
+ entities += (f'<a-video src="#{s}" width="{videoWidth}" height="{videoHeight}" '
298
  f'rotation="-90 0 0" position="0 0.05 0" '
299
+ 'material="shader:flat; src:#{s}" loop="true" autoplay="true"></a-video>')
300
  else:
301
  sx = -gw/2; sz = -gh/2
302
  for i in range(gw):
 
343
  accept_multiple_files=True
344
  )
345
  st.markdown("### ๐Ÿ“‹ Uploaded Model Files")
346
+ directory = st.text_input("", ".", key="dir", placeholder="Enter directory path (e.g., '.')")
347
  if os.path.isdir(directory):
348
  files = [f for f in os.listdir(directory) if f.split('.')[-1] in ['obj', 'glb', 'gltf']]
349
  if files: