freealise commited on
Commit
1a65e7f
1 Parent(s): 1c2fc5a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -618,7 +618,7 @@ async(p, d, n)=>{
618
  if(objectUrl) {
619
  window.URL.revokeObjectURL(objectUrl);
620
  }
621
- var serializedScene = BABYLON.SceneSerializer.Serialize(scene);
622
  var strMesh = JSON.stringify(serializedScene);
623
  if (filename.toLowerCase().lastIndexOf(".babylon") !== filename.length - 8 || filename.length < 9){
624
  filename += ".babylon";
@@ -637,6 +637,20 @@ async(p, d, n)=>{
637
  if (BABYLON && BABYLON.Engine.LastCreatedScene) {
638
  BABYLON.Engine.LastCreatedScene.onAfterRenderObservable.add(function() { //onDataLoadedObservable
639
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
  var bg = JSON.parse(document.getElementById("bgcolor").getElementsByTagName("textarea")[0].value);
641
  BABYLON.Engine.LastCreatedScene.getEngine().setHardwareScalingLevel(1.0);
642
  for (var i=0; i<bg.length; i++) {
 
618
  if(objectUrl) {
619
  window.URL.revokeObjectURL(objectUrl);
620
  }
621
+ var serializedScene = BABYLON.SceneSerializer.SerializeMesh(scene);
622
  var strMesh = JSON.stringify(serializedScene);
623
  if (filename.toLowerCase().lastIndexOf(".babylon") !== filename.length - 8 || filename.length < 9){
624
  filename += ".babylon";
 
637
  if (BABYLON && BABYLON.Engine.LastCreatedScene) {
638
  BABYLON.Engine.LastCreatedScene.onAfterRenderObservable.add(function() { //onDataLoadedObservable
639
 
640
+ var then = new Date().getTime();
641
+ var now, delta;
642
+ const interval = 1000 / 25;
643
+ const tolerance = 0.1;
644
+ BABYLON.Engine.LastCreatedScene.getEngine().stopRenderLoop();
645
+ BABYLON.Engine.LastCreatedScene.getEngine().runRenderLoop(function () {
646
+ now = new Date().getTime();
647
+ delta = now - then;
648
+ then = now - (delta % interval);
649
+ if (delta >= interval - tolerance) {
650
+ BABYLON.Engine.LastCreatedScene.render();
651
+ }
652
+ });
653
+
654
  var bg = JSON.parse(document.getElementById("bgcolor").getElementsByTagName("textarea")[0].value);
655
  BABYLON.Engine.LastCreatedScene.getEngine().setHardwareScalingLevel(1.0);
656
  for (var i=0; i<bg.length; i++) {