Is it possible to share meshes or geometry between scenes?
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.
EDIT:
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);
});
});
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 is not from current program
WebGL: INVALID_OPERATION: uniform3f: location not for current program
WebGL: INVALID_OPERATION: uniform1f: location not for current program
etc...
A Three. js Mesh is a base class that inherits from Object3d and is used to instantiate polygonal objects by combining a Geometry with a Material. Mesh is also the base class for the more advanced MorphAnimMesh and SkinnedMesh classes.
js. Three. js is a cross-browser JavaScript library and application programming interface (API) used to create and display animated 3D computer graphics in a web browser using WebGL.
Scenes allow you to set up what and where is to be rendered by three. js. This is where you place objects, lights and cameras.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With