简体   繁体   English

将Three.js画布与Custombox一起使用

[英]Using a three.js canvas with Custombox

I am using three.js to create a 360 panorama on a page. 我正在使用three.js在页面上创建360度全景。
I have several thumbnails on the page and clicking on a thumbnail does two things. 我在页面上有几个缩略图,单击缩略图有两件事。 It swaps in the correct texture to the panorama canvas (this works), and then creates a custombox modal with the canvas in the custombox. 它将正确的纹理交换到全景画布(此方法有效),然后在custombox中使用画布创建一个custombox模态。

This isn't working. 这不起作用。 What I am seeing is that the original canvas element still exists in the DOM and is working. 我看到的是原始的canvas元素仍然存在于DOM中并且正在工作。 And in the custombox there is a second canvas element, but it appears to be empty and has no functionality. 并且在custombox中有第二个canvas元素,但是它似乎是空的并且没有任何功能。

Am I misunderstanding how the canvas element works that makes it not possible for it to appear in a modal dialog box? 我是否误解了canvas元素的工作方式,使得它不可能出现在模式对话框中?

Im assuming, without any code presented that your target for CustomBox is an ID of the div which contains your canvas, or the canvas itself. 我假设没有提供任何代码,CustomBox的目标是包含画布或画布本身的div的ID。 In this case CustomBox is going to clone your div/canvas. 在这种情况下,CustomBox将克隆您的div /画布。 You'll see all the constituent parts needed, but three.js doesn't know about them because you passed the original div to the renderer when it was instantiated. 您将看到所需的所有组成部分,但是three.js并不了解它们,因为您在实例化原始div时将原始div传递给了渲染器。 The render() call you're using takes the following parameters: 您正在使用的render()调用采用以下参数:

.render ( scene, camera, renderTarget, forceClear )

Since the render can point to a new renderTarget as the third parameter, I would start here, and pass in a unique ID of the new canvas being shown by CustomBox. 由于渲染可以指向新的renderTarget作为第三个参数,因此我将从此处开始,并传入CustomBox显示的新画布的唯一ID。 There is plenty of methods available: https://threejs.org/docs/#api/renderers/WebGLRenderer such as getRenderTarget so you can see which canvas is currently getting drawn to as well, and importantly setRenderTarget() which may also be useful to you. 有很多可用的方法: https ://threejs.org/docs/#api/renderers/WebGLRenderer(例如getRenderTarget),这样您就可以看到当前正在绘制的画布,重要的是setRenderTarget()可能也有用给你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM