xeolabs / xeogl

A WebGL-based 3D engine for technical visualization. Not actively maintained.
http://xeogl.org
Other
1.15k stars 264 forks source link

Scene clear() broken #278

Closed xeolabs closed 5 years ago

xeolabs commented 5 years ago

Describe the bug Calling myScene.clear() destroys components that we should not destroy, like xeogl.Camera, xeogl.Viewport, xeogl.Canvas````.

To Reproduce

var myScene = new xeogl.Scene();
var myMesh = new xeogl.Mesh(myScene); // Gets default box geometry etc
myScene.destroy(); // Destroys all components, including xeogl.Camera, xeogl.Canvas, xeogl.Viewport, etc.

With the xeogl.Canvas getting destroyed, we also lose the HTML canvas and the WebGL context, which crashes xeogl.

Expected behavior

var myScene = new xeogl.Scene();
var myMesh = new xeogl.Mesh(myScene); 

// At this point we have a mesh with the default box geometry

myScene.destroy(); 

// Atthis point, myScene.camera, myScene.viewport, myScene.canvas
// should all still exist (not destroyed)

var myMesh2 = new xeogl.Mesh(myScene);

// At this point we once more have a mesh with the default box geometry

Desktop (please complete the following information):

Smartphone (please complete the following information):