WebGL单帧“截图"webGL的 [英] WebGL single frame "screenshot" of webGL

查看:93
本文介绍了WebGL单帧“截图"webGL的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试寻找类似的东西,但我没有运气.我正在尝试使用我的 webgl 图像当前状态的屏幕截图打开一个新选项卡.基本上,它是一个 3d 模型,能够更改显示的对象、这些对象的颜色和背景颜色.目前,我正在使用以下内容:

tried searching for something like this, but I've had no luck. I'm trying to open a new tab with a screenshot of the current state of my webgl image. Basically, it's a 3d model, with the ability to change which objects are displayed, the color of those objects, and the background color. Currently, I am using the following:

var screenShot = window.open(renderer.domElement.toDataURL("image/png"), 'DNA_Screen');

这一行成功地打开了一个带有我模型当前图像的新选项卡,但没有显示当前的背景颜色.它也无法正确显示选项卡名称.相反,选项卡名称始终为PNG 1024x768".

This line succeeds in opening a new tab with a current image of my model, but does not display the current background color. It also does not properly display the tab name. Instead, the tab name is always "PNG 1024x768".

有没有办法更改我的 window.open 以显示背景颜色?正确的选项卡名称也很好,但背景颜色是我最关心的问题.

Is there a way to change my window.open such that the background color is shown? The proper tab name would be great as well, but the background color is my biggest concern.

推荐答案

如果你打开没有 URL 的窗口,你可以直接从打开窗口的 JavaScript 访问它的整个 DOM.

If you open the window with no URL you can access it's entire DOM directly from the JavaScript that opened the window.

var w = window.open('', '');

然后您可以设置或添加任何您想要的内容

You can then set or add anything you want

w.document.title = "DNA_screen";
w.document.body.style.backgroundColor = "red";

并添加截图

var img = new Image();
img.src = someCanvas.toDataURL();
w.document.body.appendChild(img);

这篇关于WebGL单帧“截图"webGL的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆