<commit_before>
/**
 * Module dependencies
 */

var loop = require('./loop');
var Entity = require('./entity');
var Emitter = require('component/emitter');
var Interactions = require('./interactions');
var assign = require('sindresorhus/object-assign');

/**
 * Expose `Scene`
 *
 * @type {Function}
 */

module.exports = Scene;

/**
 * A scene renders a component tree to an element
 * and manages the lifecycle and events each frame.
 *
 * TODO: move interactions here
 *
 * @param {HTMLElement} container
 * @param {Entity} entity
 */

function Scene(container, Component, props) {
  this.container = container;
  this.interactions = new Interactions(container);
  this.loop = loop(this.tick.bind(this));
  this.entity = new Entity(Component, props, this);
  this.entity.appendTo(this.container);
}

assign(Scene.prototype, Emitter.prototype);

/**
 * Force update all the components
 */

Scene.prototype.forceUpdate = function(){
  this.entity.update(true);
  this.emit('update');
};

/**
 * Schedule this component to be updated on the next frame.
 *
 * @param {Function} done
 * @return {void}
 */

Scene.prototype.update = function(){
  this.entity.update();
  this.emit('update');
};

/**
 * Set new props on the component and trigger a re-render.
 *
 * TODO: could we use promises instead of callbacks?
 *
 * @param {Object} newProps
 * @param {Function} [done]
 */

Scene.prototype.setProps = function(newProps, done){
  if (done) this.once('update', done);
  this.entity.setProps(newProps);
};

/**
 * Remove the component from the DOM.
 */

Scene.prototype.remove = function(){
  this.loop.pause();
  this.entity.remove();
  this.interactions.remove();
};

/**
 * Is this scene dirty and needs a re-render?
 *
 * @return {Boolean}
 */

Scene.prototype.shouldUpdate = function(){
  return this.entity.isDirty();
};

/**
 * This gets called every frame of the browser
 * so we can update the tree efficiently.
 */

Scene.prototype.tick = function(){
  if (this.shouldUpdate()) this.update();
};<commit_msg>Fixed loop<commit_after>
/**
 * Module dependencies
 */

var loop = require('./loop');
var Entity = require('./entity');
var Emitter = require('component/emitter');
var Interactions = require('./interactions');
var assign = require('sindresorhus/object-assign');

/**
 * Expose `Scene`
 *
 * @type {Function}
 */

module.exports = Scene;

/**
 * A scene renders a component tree to an element
 * and manages the lifecycle and events each frame.
 *
 * TODO: move interactions here
 *
 * @param {HTMLElement} container
 * @param {Entity} entity
 */

function Scene(container, Component, props) {
  this.container = container;
  this.interactions = new Interactions(container);
  this.entity = new Entity(Component, props, this);
  this.entity.appendTo(this.container);
  this.loop = loop(this.tick.bind(this));
}

assign(Scene.prototype, Emitter.prototype);

/**
 * Force update all the components
 */

Scene.prototype.forceUpdate = function(){
  this.entity.update(true);
  this.emit('update');
};

/**
 * Schedule this component to be updated on the next frame.
 *
 * @param {Function} done
 * @return {void}
 */

Scene.prototype.update = function(){
  this.entity.update();
  this.emit('update');
};

/**
 * Set new props on the component and trigger a re-render.
 *
 * TODO: could we use promises instead of callbacks?
 *
 * @param {Object} newProps
 * @param {Function} [done]
 */

Scene.prototype.setProps = function(newProps, done){
  if (done) this.once('update', done);
  this.entity.setProps(newProps);
};

/**
 * Remove the component from the DOM.
 */

Scene.prototype.remove = function(){
  this.loop.pause();
  this.entity.remove();
  this.interactions.remove();
};

/**
 * Is this scene dirty and needs a re-render?
 *
 * @return {Boolean}
 */

Scene.prototype.shouldUpdate = function(){
  return this.entity.isDirty();
};

/**
 * This gets called every frame of the browser
 * so we can update the tree efficiently.
 */

Scene.prototype.tick = function(){
  if (this.shouldUpdate()) this.update();
};
{'fraction_non_alphanumeric': 0.155373541821792, 'fraction_numerical': 0.0, 'mean_word_length': 3.9266503667481665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2312347', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1215, 'n_words': 351}