Can you share grids between three.js scripts?

Can I share meshes or geometry between scenes?

I have several scenes that should be the same, large, grids, but when I try to split the cells between them, I get WebGL contextual errors. I suspect that some variables are set on grids or geometry when they are added to the scene, which prevents them from being reused in another scene.

EDIT:

More specifically, I am trying to use the geometry loaded by JSONLoader between different scenes. That is, in this example, “apps” is an array of applications 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); }); }); 

Full source here: https://github.com/bjnortier/three.js/blob/multiple_canvasses_with_json_loader/examples/webgl_multiple_canvases_grid.html

This example generates WebGL errors:

WebGL: INVALID_OPERATION: useProgram: object not from this context
WebGL: INVALID_OPERATION: uniformMatrix4fv: location not from the current program
WebGL: INVALID_OPERATION: uniform3f: location not for current program
WebGL: INVALID_OPERATION: uniform1f: location not for current program
etc.

+4
source share
1 answer

You can share geometry along different scenes.
You cannot share grids along different scenes.
You cannot share geometry / grids / scenes across different Renderers (for now).

+12
source

All Articles