UNPKG

glam

Version:

Experimental WebGL Engine

49 lines (35 loc) 1.03 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.nodeRemoveChild = nodeRemoveChild; exports.default = remove; var _updateTypes = require('./update-types'); var _updateTypes2 = _interopRequireDefault(_updateTypes); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function nodeRemoveChild(scene, graph, parent, child) { var siblings = scene.children(parent); var index = siblings.indexOf(child); if (index >= 0) { // Update types before removing the nodes (0, _updateTypes2.default)(scene, graph, child, "remove"); scene.flags.changed = true; // Remove the links on the graph siblings.splice(index, 1); graph.parent.delete(child); } } function remove(scene, graph, a, b) { var node, child; if (a && b) { node = a; child = b; } else if (a && !b) { node = scene; child = a; } else { throw new Error('Tried to add nothing to the scene.'); } nodeRemoveChild(scene, graph, node, child); return scene; }