<commit_before>// namespace :
var GNOVEL = GNOVEL || {};

(function() {
	"use strict";

	/**
	 * Transition to next scene over certain time
	 * @class Transition
	 * @constructor
	 * @param {time} time for transition to play, in milliseconds
	 **/
	var Transition = function(time, scene, curPageRT, nextPageRT) {
		this.time = time || 400;

		this._width = 1920;
		this._height = 1080;
		this._scene = scene;

		var texture = THREE.ImageUtils.loadTexture("/static/gnovel/res/textures/ui/comic book with panels.png");
		var material = new THREE.MeshBasicMaterial({
			color: 0xffffff,
			transparent: true,
			map: texture
		});

		var plane = new THREE.PlaneBufferGeometry(this._width, this._height);
		this.transitionPanel = new THREE.Mesh(plane, material);
		this.transitionPanel.name = "transitionPanel";
		var transitionPanel = this.transitionPanel;

		var redMaterial = new THREE.MeshBasicMaterial({
			transparent: true,
			map: curPageRT,
		});

		var blueMaterial = new THREE.MeshBasicMaterial({
			// color: 0x0000ff,
			transparent: true,
			map: nextPageRT,
		});
		var plane1 = new THREE.PlaneBufferGeometry(this._width, this._height);
		var plane2 = new THREE.PlaneBufferGeometry(this._width, this._height);

		var curPageBg = new THREE.Mesh(plane1, redMaterial);
		curPageBg.position.setX(-10);
		curPageBg.position.setZ(3);
		curPageBg.scale.set(0.33, 0.33, 1);
		curPageBg.name = "curPageBg";
		transitionPanel.add(curPageBg);
		this._curPageBg = curPageBg;

		var nextPageBg = new THREE.Mesh(plane2, blueMaterial);
		nextPageBg.position.setX(635);
		nextPageBg.position.setZ(3);
		nextPageBg.scale.set(0.33, 0.33, 1);
		nextPageBg.name = "nextPageBg";
		transitionPanel.add(nextPageBg);
		this._nextPageBg = nextPageBg;

		var container = new THREE.Object3D();
		this._container = container;
	};

	/**
	 * Do Transition
	 * @param {currentPage} currentPage, the current page to be tansitioned from
	 * @param {nextPage} the new page to show
	 **/
	Transition.prototype.run = function(currentPage, nextPage, params) {
		if (params.transitionType === GNOVEL.TransitionType.COMIC_SLIDE) {
			this._comicSlide(currentPage, nextPage, params);
		} else {
			this._fade(currentPage, nextPage, params);
		}
	};

	Transition.prototype._fade = function(currentPage, nextPage, params) {
		var duration = this.time;
		var transition = this;
		var gnovelObj = currentPage.getOwner();

		var geometry = new THREE.PlaneBufferGeometry(1920, 1080);
		var material = new THREE.MeshBasicMaterial({
			color: 0x000000,
			transparent: true,
		});
		var transitionBgImg = new THREE.Mesh(geometry, material);
		transitionBgImg.material.opacity = 0;
		transitionBgImg.position.z = 210;

		// fade out current scene
		gnovelObj._scene.add(transitionBgImg);

		this._runOnHierarchy(transitionBgImg, {
			opacity: 1,
		}, {
			duration: duration / 2,
			onComplete: function() {

				params.onSafeToUnload();
				params.onComplete();

				transition._runOnHierarchy(transitionBgImg, {
					opacity: 0,
				}, {
					duration: duration / 2,
					onComplete: function() {
						gnovelObj._scene.remove(transitionBgImg);
					}
				});
			}
		});


	};

	Transition.prototype._comicSlide = function(currentPage, nextPage, params) {
		var duration = this.time;
		var transition = this;
		var transitionPanel = this.transitionPanel;
		var gnovelObj = currentPage.getOwner();
		var scene = this._scene;
		var container = this._container;

		var farZ = -300;
		var leftX = -633;
		var initialScale = 1.65;
		var initialX = 18;
		var toScale = 1.2;
		var initialZ = 270;

		console.log("transition is running");

		// transitionPanel.position.set(0, 0, initialZ);
		// transitionPanel.scale.set(initialScale, initialScale, 1);
		// this._scene.add(transitionPanel);

		var nextPageTexture = THREE.ImageUtils.loadTexture(nextPage.nextPageMaterialPath);
		var nextPageMaterial = new THREE.MeshBasicMaterial({
			transparent: true,
			map: nextPageTexture,
		});
		transitionPanel.children[1].material = nextPageMaterial;

		container.position.set(initialX, 0, initialZ);
		container.scale.set(initialScale, initialScale, 1);
		container.add(transitionPanel);
		this._scene.add(container);
		transitionPanel.position.set(0, 0, 0);

		this._runOnHierarchy(container, {
			opacity: 1
		}, {
			duration: duration,
			onComplete: function() {

				params.onSafeToUnload();

				//zoom out the transition panel
				transition._scale(container, {
					duration: duration,
					easing: TWEEN.Easing.Cubic.Out,
					// z: farZ,
					x: toScale,
					y: toScale,
					onComplete: function() {

						// wait for several second
						transition._wait({<commit_msg>Remove unnecesary code in transition<commit_after>// namespace :
var GNOVEL = GNOVEL || {};

(function() {
	"use strict";

	/**
	 * Transition to next scene over certain time
	 * @class Transition
	 * @constructor
	 * @param {time} time for transition to play, in milliseconds
	 **/
	var Transition = function(time, scene, curPageRT, nextPageRT) {
		this.time = time || 400;

		this._width = 1920;
		this._height = 1080;
		this._scene = scene;

		var texture = THREE.ImageUtils.loadTexture("/static/gnovel/res/textures/ui/comic book with panels.png");
		var material = new THREE.MeshBasicMaterial({
			color: 0xffffff,
			transparent: true,
			map: texture
		});

		var plane = new THREE.PlaneBufferGeometry(this._width, this._height);
		this.transitionPanel = new THREE.Mesh(plane, material);
		this.transitionPanel.name = "transitionPanel";
		var transitionPanel = this.transitionPanel;

		var redMaterial = new THREE.MeshBasicMaterial({
			transparent: true,
			map: curPageRT,
		});

		var blueMaterial = new THREE.MeshBasicMaterial({
			// color: 0x0000ff,
			transparent: true,
			map: nextPageRT,
		});
		var plane1 = new THREE.PlaneBufferGeometry(this._width, this._height);
		var plane2 = new THREE.PlaneBufferGeometry(this._width, this._height);

		var curPageBg = new THREE.Mesh(plane1, redMaterial);
		curPageBg.position.setX(-10);
		curPageBg.position.setZ(3);
		curPageBg.scale.set(0.33, 0.33, 1);
		curPageBg.name = "curPageBg";
		transitionPanel.add(curPageBg);
		this._curPageBg = curPageBg;

		var nextPageBg = new THREE.Mesh(plane2, blueMaterial);
		nextPageBg.position.setX(635);
		nextPageBg.position.setZ(3);
		nextPageBg.scale.set(0.33, 0.33, 1);
		nextPageBg.name = "nextPageBg";
		transitionPanel.add(nextPageBg);
		this._nextPageBg = nextPageBg;

		var container = new THREE.Object3D();
		this._container = container;
	};

	/**
	 * Do Transition
	 * @param {currentPage} currentPage, the current page to be tansitioned from
	 * @param {nextPage} the new page to show
	 **/
	Transition.prototype.run = function(currentPage, nextPage, params) {
		if (params.transitionType === GNOVEL.TransitionType.COMIC_SLIDE) {
			this._comicSlide(currentPage, nextPage, params);
		} else {
			this._fade(currentPage, nextPage, params);
		}
	};

	Transition.prototype._fade = function(currentPage, nextPage, params) {
		var duration = this.time;
		var transition = this;
		var gnovelObj = currentPage.getOwner();

		var geometry = new THREE.PlaneBufferGeometry(1920, 1080);
		var material = new THREE.MeshBasicMaterial({
			color: 0x000000,
			transparent: true,
		});
		var transitionBgImg = new THREE.Mesh(geometry, material);
		transitionBgImg.material.opacity = 0;
		transitionBgImg.position.z = 210;

		// fade out current scene
		gnovelObj._scene.add(transitionBgImg);

		this._runOnHierarchy(transitionBgImg, {
			opacity: 1,
		}, {
			duration: duration / 2,
			onComplete: function() {

				params.onSafeToUnload();
				params.onComplete();

				transition._runOnHierarchy(transitionBgImg, {
					opacity: 0,
				}, {
					duration: duration / 2,
					onComplete: function() {
						gnovelObj._scene.remove(transitionBgImg);
					}
				});
			}
		});


	};

	Transition.prototype._comicSlide = function(currentPage, nextPage, params) {
		var duration = this.time;
		var transition = this;
		var transitionPanel = this.transitionPanel;
		var gnovelObj = currentPage.getOwner();
		var scene = this._scene;
		var container = this._container;

		var farZ = -300;
		var leftX = -633;
		var initialScale = 1.65;
		var initialX = 18;
		var toScale = 1.2;
		var initialZ = 270;

		console.log("transition is running");

		// transitionPanel.position.set(0, 0, initialZ);
		// transitionPanel.scale.set(initialScale, initialScale, 1);
		// this._scene.add(transitionPanel);

		var nextPageTexture = THREE.ImageUtils.loadTexture(nextPage.nextPageMaterialPath);
		this._nextPageBg.material.map = nextPageTexture;

		container.position.set(initialX, 0, initialZ);
		container.scale.set(initialScale, initialScale, 1);
		container.add(transitionPanel);
		this._scene.add(container);
		transitionPanel.position.set(0, 0, 0);

		this._runOnHierarchy(container, {
			opacity: 1
		}, {
			duration: duration,
			onComplete: function() {

				params.onSafeToUnload();

				//zoom out the transition panel
				transition._scale(container, {
					duration: duration,
					easing: TWEEN.Easing.Cubic.Out,
					// z: farZ,
					x: toScale,
					y: toScale,
					onComplete: function() {

						// wait for several second
						transition._wait({
{'fraction_non_alphanumeric': 0.12313392176092405, 'fraction_numerical': 0.019941157240928407, 'mean_word_length': 3.802721088435374, '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': '369744', 'n_tokens_mistral': 3609, 'n_tokens_neox': 2916, 'n_words': 661}