Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using with vanilla threejs #17

Open
arpu opened this issue Feb 18, 2021 · 7 comments
Open

using with vanilla threejs #17

arpu opened this issue Feb 18, 2021 · 7 comments

Comments

@arpu
Copy link

arpu commented Feb 18, 2021

Hello awesome looking perf tool! is it possible tio use this with vanilla threejs app?

@RenaudRohlinger
Copy link
Member

@arpu Thanks! For the moment I recommend the tool that I based my work on https://github.com/munsocket/gl-bench.
I will work on a vanilla support this year.

@Ben-Mack
Copy link

+1 This tool is very useful (and really nice looking too!), looking forward to use it with vanilla three.js

@ertugrulcetin
Copy link

Can't wait to use it with vanilla three.js!

@RenaudRohlinger
Copy link
Member

Here is a demo by @CodyJasonBennett of r3f working with vanilla.
https://codesandbox.io/s/rw6pdo

Not the best solution at this moment but it works 😄

@CodyJasonBennett
Copy link
Contributor

I updated the box so it works the same as in R3F and with latest versions. It has a start(timestamp) and end(timestamp) method that start and stop measuring in your render loop.

import * as THREE from 'three'
import { createElement } from 'react'
import { extend, createRoot, flushGlobalEffects } from '@react-three/fiber'
import { Perf as R3FPerf } from 'r3f-perf'

export class Perf {
  constructor(renderer, scene, camera) {
    extend(THREE)
    createRoot(renderer.domElement)
      .configure({
        frameloop: 'never',
        gl: renderer,
        camera,
        scene
      })
      .render(createElement(R3FPerf))
  }

  start(timestamp) {
    flushGlobalEffects('before', timestamp)
  }
  end(timestamp) {
    flushGlobalEffects('after', timestamp)
  }
}

//

const perf = new Perf(renderer, scene, camera)

renderer.setAnimationLoop((time) => {
  perf.start(time)
  controls.update()
  renderer.render(scene, camera)
  perf.end(time)
})

@ifg-sam
Copy link

ifg-sam commented Feb 6, 2024

I'm using this and it works great, only every few frames I see my GPU time become NaN and a few other properties go to 0 before returning to their normal number. I can see the same thing in the JSFiddle above. Do you see the same thing? @CodyJasonBennett @RenaudRohlinger

@CodyJasonBennett
Copy link
Contributor

FWIW there's a vanilla port of this https://github.com/TheoTheDev/three-perf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants