WebGL单帧“屏幕截图” webGL [英] WebGL single frame "screenshot" of webGL

查看:1098
本文介绍了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天全站免登陆