Stats.js shows FPS 0~2, mouvement too slow

Hi, i’m beginner for three.js also using it for BIM project, when i load a gltf file of ~25mb i can barely move the whole object and stats.js monitor shows fps of 0~2 at max
gltf file : https://github.com/xeolabs/xeogl/tree/master/examples/models/gltf/schependomlaan
im using THREE js with vuejs

//package.json
"stats.js": "^0.17.0",
"three": "^0.109.0",

import * as THREE from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';

this.scene = new THREE.Scene();

this.stats = new Stats();
this.stats.showPanel( 0, 1, 2 ); // 0: fps, 1: ms, 2: mb, 3+: custom
let div = document.createElement('div')
div.appendChild(this.stats.dom)

div.style.position = 'absolute';
div.style.top = 0;
div.style.left = 0;
document.getElementsByClassName('gltfViewer')[0].appendChild( div );
// Camera 
this.camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1500 );
this.camera.position.set( this.pos, this.pos, this.pos );
// renderer
this.raycaster = new THREE.Raycaster();
this.renderer = new THREE.WebGLRenderer({ canvas: document.getElementById('gltfViewerCanvas'), alpha: false });
this.renderer.setClearColor( 0xefefef );
this.renderer.setPixelRatio( window.devicePixelRatio );
this.renderer.setSize(window.innerWidth, window.innerHeight);
// adding controls

this.controls = new OrbitControls( this.camera, this.renderer.domElement );
this.controls.dampingFactor = 0.1;
this.controls.rotateSpeed = 0.12;
this.controls.enableDamping = true;
this.controls.update();

window.addEventListener('resize', _ => this.render());
this.controls.addEventListener('change', _ => this.render());

// light
var ambientLight = new THREE.AmbientLight( 0xcccccc );
this.scene.add( ambientLight );

var directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.set( 0, 1, 1 ).normalize();
this.scene.add( directionalLight );
// loading gltf file

// Instantiate a loader
this.gltfLoader = new GLTFLoader();

// Optional: Provide a DRACOLoader instance to decode compressed mesh data
this.dracoLoader = new DRACOLoader();
this.dracoLoader.setDecoderPath( 'three/examples/js/libs/draco' );
this.gltfLoader.setDRACOLoader( this.dracoLoader );

// Load a glTF resource
this.gltfLoader.load( this.src, this.onGLTFLoaded, this.onGLTFLoading, this.onGLTFLoadingError );
//onGLTFLoaded()
this.scene.add( optimizedGltf.scene );
// gltf.scene.getObjectById(404).visible = false;
this.listGltfObjects(gltf);

this.render();
// render ()

this.renderer.render( this.scene, this.camera );
this.stats.update();
// on mounted component :
animate()
// animate() 
this.stats.begin()
this.render();
this.stats.end();

even after applying Draco compression using https://github.com/AnalyticalGraphicsInc/gltf-pipeline nothing changes

/cc

These lines are obsolete when you are using an animation loop. Besides, when the browser window is resized, you normally want to adjust the camera’s aspect ratio and the size of the renderer like so:

function onWindowResize() {

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();

    renderer.setSize( window.innerWidth, window.innerHeight );

}

Okey i’ll try that,
i thought it was a memory issue so i did add these two lines just to fire render function only when needed !

I’ve tried to integrate that, it did double the fps but still too slow ( 1~7 fps )
( it does double fps even for smaller gltf files )

It seems the root cause of your performance problem (too many draw calls) was found at stackoverflow: https://stackoverflow.com/questions/58544126/three-stats-js-shows-fps-02-render-mouvement-too-slow#comment103416702_58544126

2 Likes