你能分享三个场景之间的网格吗? [英] Can you share meshes between three.js Scenes?
问题描述
是否可以在场景之间共享网格或几何?
Is it possible to share meshes or geometry between scenes?
我有多个场景应该相同,大,网格,但当我尝试共享网格之间他们我得到了WebGL上下文错误。我怀疑在网格或几何体添加到场景时会在网格或几何上设置一些变量,从而阻止它们在另一个场景中重复使用。
I have multiple scenes which should the same, big, meshes, but when I try to share meshes between them I get WebGL context errors. I suspect that some variables are set on the meshes or geometry when they are added to a scene, thus preventing them from being re-used in another scene.
编辑:
更具体地说,我正在尝试共享在不同场景之间加载了JSONLoader的几何体。即在此示例中,apps是包含场景的应用程序数组:
More specifcally, I'm trying to share geometry that has been loaded with the JSONLoader between different scenes. I.e. in this example 'apps' is an array of Apps with scenes:
var loader = new THREE.JSONLoader();
loader.load('obj/tree/tree.js', function(geometry) {
apps.map(function(app) {
var material = new THREE.MeshBasicMaterial({color: 0xff0000, opacity: 1.0});
var mesh = new THREE.Mesh(geometry, geometry.materials[0]);
app.scene.add(mesh);
});
});
此示例生成WebGL错误:
This example generates WebGL Errors:
WebGL:INVALID_OPERATION:useProgram:对象不是来自此上下文
WebGL :INVALID_OPERATION:uniformMatrix4fv:location不是来自当前程序
WebGL:INVALID_OPERATION:uniform3f:不适用于当前程序的位置
WebGL:INVALID_OPERATION:uniform1f:当前程序的位置
等...
WebGL: INVALID_OPERATION: useProgram: object not from this context
WebGL: INVALID_OPERATION: uniformMatrix4fv: location is not from current program
WebGL: INVALID_OPERATION: uniform3f: location not for current program
WebGL: INVALID_OPERATION: uniform1f: location not for current program
etc...
推荐答案
您可以沿不同的场景共享几何体。
您可以不共享不同场景的网格物体。
你不能在不同的渲染器上共享几何/网格物体/场景。
You can share geometry along different Scenes.
You can't share meshes along different Scenes.
You can't share geometry/meshes/scenes along different Renderers (yet).
这篇关于你能分享三个场景之间的网格吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!