BabylonJS / Spector.js

Explore and Troubleshoot your WebGL scenes with ease.
http://spector.babylonjs.com
MIT License
1.3k stars 169 forks source link

Capture frame like WebGL Inspector does on loading #44

Closed PatchedPixels closed 7 years ago

PatchedPixels commented 7 years ago

I have scene where I am not animating, I would like spector to work in similar manner like WebGL inspector works i.e. on refreshing or loading of page, it captures frames and all webgl calls that were made as well as any color attachments that were used/generated. Is that possible? This tool looks great but it doesn't seems to work with my custom framework. My custom framework only draws static scenes (we don't animate), WebGL inspector (https://benvanik.github.io/WebGL-Inspector/) works as long as our code is webgl 1.0 , something similar to webgl inspector but with all features of spector will be great.

sebavan commented 7 years ago

This works if you use the embedded version. you can call the relevant methods manually to create your capture based on your specific timing:

var SPECTOR = require("spectorjs"); var spector = new SPECTOR.Spector(); spector.displayUI();

// Go in capture mode. spector.captureCanvas(YOURCANVASELEMENT);

// Only if you do not rely on requestAnimationFrame spector.onFrameStart();

// Your code to render here.

// Only if you do not rely on requestAnimationFrame spector.onFrameEnd();

This should work in your case but unfortunately I can not do in the extension if it does not rely on RAF.

sebavan commented 7 years ago

Did it work for you @PatchedPixels ?

woutware commented 10 months ago

@sebavan It worked! I'm a javascript noob, so I didn't manage to get require() to work quickly, but I replaced it with

<script type="text/javascript" src="https://spectorcdn.babylonjs.com/spector.bundle.js"></script>  

and then it worked.

Would have been nice if the spector.js pages mentioned it is by default intended to render loops, and if you don't have a render loop, you need to add your code snippet to your javascript.