Can meshes or geometry be shared across scenes?
I am facing an issue where I have multiple scenes that require the same large meshes, but attempting to share these meshes between scenes results in WebGL context errors. It seems like certain variables are being set on the meshes or geometry when they are added to one scene, preventing them from being reused in another scene.
UPDATE:
Specifically, I am trying to share geometry that has been loaded using the JSONLoader across different scenes. For 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);
});
});
View the complete source code here: https://github.com/bjnortier/three.js/blob/multiple_canvasses_with_json_loader/examples/webgl_multiple_canvases_grid.html
Unfortunately, this approach is resulting in WebGL Errors:
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
and so on...