Coder Social home page Coder Social logo

getkey / gstatsjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exponenta/gstatsjs

0.0 0.0 1.0 60 KB

Graphics statistic (DrawCalls and TextureCount) for WebGL

Home Page: https://exponenta.github.io/gstatsjs/

License: GNU General Public License v3.0

HTML 18.72% JavaScript 31.95% TypeScript 49.33%

gstatsjs's People

Contributors

exponenta avatar getkey avatar

Watchers

 avatar  avatar

Forkers

laino

gstatsjs's Issues

Pixi v6 support

Hi @getkey , can we add support to pixi v6 in this package . Currently having to npm i --force due to the conficting peer dependency version in this package.

Cannot find module 'gstats' or its corresponding type declarations.

Hi @getkey and thanks for answering on eXponenta#7

Your example appears wrong, because you aren't doing anything with the statsAdapter object. I finally got it working with React, sharing my component here:

// eslint-disable-next-line import/no-extraneous-dependencies
import Stats from "stats.js";
import React, { useEffect, useMemo } from "react";
// @ts-ignore
import { PIXIHooks, StatsJSAdapter } from "gstats";
import { useApp, useTick } from "@inlet/react-pixi";

// @ts-ignore gross, but needed by gstat
window.Stats = Stats;

/** @SR
 * development env only component to show FPS/RAM/GRAM stats
 *  *
 * FPS: Frames rendered in the last second. The higher the number the better.
 * MS:  Milliseconds needed to render a frame. The lower the number the better.
 * MB:  MBytes of allocated memory. (Run Chrome with --enable-precise-memory-info)
 * DC: DrawPasses
 * TC: Texture count
 */
const DebugStatsView: React.FC = () => {
  const app = useApp();
  const stats = useMemo(() => new StatsJSAdapter(new PIXIHooks(app)), [app]);

  useTick(() => stats?.update());
  useEffect(() => {
    const domElement = stats.stats.dom || stats.stats.domElement;
    domElement.style.top = "";
    domElement.style.bottom = "0px";
    return stats.stats && document.body.appendChild(domElement);
  }, [stats.stats]);
  return null;
};

export default DebugStatsView;

Note: couldn't use portals because of a react-pixi error react-pixi: PixiFiber does not support text nodes as children of a Pixi component

Anyways, there seems to be a problem with the npm package, this is the only lib in my ~150 libs project that tsserver cannot find, not sure what this is about.

Using gstats 0.1.0.
I'll keep the ts-ignore until this is fixed :) Thanks again for making this package!

Edit: while webpack somehow manages to pick of the package and use it locally, my tests are broken with error Cannot find module 'gstats' from 'src/components/DebugStatsView.tsx'. I'd really like to be able to confirm that gstats is loaded from my tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.