Kgshop commited on
Commit
4e5b6b5
·
verified ·
1 Parent(s): 7ddbaaa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -250,7 +250,7 @@ EDITOR_TEMPLATE = '''
250
  let currentRotation = 0;
251
  const gridSize = 1;
252
  let levelData = { floors: {}, walls: {}, objects: {}, buildingDefinitions: {}, buildingInstances: [] };
253
- let drawMode = 'single'; // 'single' or 'area'
254
  let isDrawingArea = false;
255
  let areaStartPoint = new THREE.Vector3();
256
 
@@ -599,6 +599,7 @@ EDITOR_TEMPLATE = '''
599
  if (previewMesh) {
600
  scene.remove(previewMesh);
601
  previewMesh.geometry.dispose();
 
602
  previewMesh.material.dispose();
603
  }
604
 
@@ -626,6 +627,7 @@ EDITOR_TEMPLATE = '''
626
  previewMesh = new THREE.Mesh(geometry, material);
627
  previewMesh.userData.isBuilding = false;
628
  }
 
629
  scene.add(previewMesh);
630
  }
631
 
@@ -742,6 +744,7 @@ EDITOR_TEMPLATE = '''
742
  }
743
 
744
  function rotatePreview(direction) {
 
745
  currentRotation += (Math.PI / 2) * direction;
746
  previewMesh.rotation.y = currentRotation;
747
  }
@@ -896,7 +899,7 @@ EDITOR_TEMPLATE = '''
896
 
897
  function togglePlayMode() {
898
  const blocker = document.getElementById('blocker');
899
- if(isPlayMode) { // Exit play mode
900
  isPlayMode = false;
901
  document.exitPointerLock?.();
902
  const uiContainer = document.getElementById('ui-container');
@@ -913,7 +916,7 @@ EDITOR_TEMPLATE = '''
913
  camera.lookAt(0,0,0);
914
  orbitControls.target.set(0, 0, 0);
915
  onWindowResize();
916
- } else { // Enter play mode
917
  blocker.style.display = 'block';
918
  }
919
  }
@@ -973,6 +976,8 @@ EDITOR_TEMPLATE = '''
973
 
974
  clearLevel();
975
  Object.assign(levelData, result.data);
 
 
976
  updateCustomToolsUI();
977
  updateLevelGeometry();
978
  document.getElementById('project-name').value = projectName;
 
250
  let currentRotation = 0;
251
  const gridSize = 1;
252
  let levelData = { floors: {}, walls: {}, objects: {}, buildingDefinitions: {}, buildingInstances: [] };
253
+ let drawMode = 'single';
254
  let isDrawingArea = false;
255
  let areaStartPoint = new THREE.Vector3();
256
 
 
599
  if (previewMesh) {
600
  scene.remove(previewMesh);
601
  previewMesh.geometry.dispose();
602
+ if(previewMesh.material.map) previewMesh.material.map.dispose();
603
  previewMesh.material.dispose();
604
  }
605
 
 
627
  previewMesh = new THREE.Mesh(geometry, material);
628
  previewMesh.userData.isBuilding = false;
629
  }
630
+ previewMesh.rotation.y = currentRotation;
631
  scene.add(previewMesh);
632
  }
633
 
 
744
  }
745
 
746
  function rotatePreview(direction) {
747
+ if (!previewMesh) return;
748
  currentRotation += (Math.PI / 2) * direction;
749
  previewMesh.rotation.y = currentRotation;
750
  }
 
899
 
900
  function togglePlayMode() {
901
  const blocker = document.getElementById('blocker');
902
+ if(isPlayMode) {
903
  isPlayMode = false;
904
  document.exitPointerLock?.();
905
  const uiContainer = document.getElementById('ui-container');
 
916
  camera.lookAt(0,0,0);
917
  orbitControls.target.set(0, 0, 0);
918
  onWindowResize();
919
+ } else {
920
  blocker.style.display = 'block';
921
  }
922
  }
 
976
 
977
  clearLevel();
978
  Object.assign(levelData, result.data);
979
+ if (!levelData.buildingDefinitions) levelData.buildingDefinitions = {};
980
+ if (!levelData.buildingInstances) levelData.buildingInstances = [];
981
  updateCustomToolsUI();
982
  updateLevelGeometry();
983
  document.getElementById('project-name').value = projectName;