<commit_before>/// <reference path="../../../typings/threejs/three.d.ts" />
/// <reference path="../../../node_modules/rx/ts/rx.all.d.ts" />

import * as THREE from "three";
import * as rx from "rx";

import {IUI, Shaders, GlScene} from "../../UI";
import {ICurrentState} from "../../State";
import {Container, Navigator} from "../../Viewer";
import {Transform, Camera} from "../../Geo";
import {Node} from "../../Graph";

export class GlUI implements IUI {
    private container: Container;
    private navigator: Navigator;

    private stateSubscription: rx.IDisposable;

    private renderer: THREE.WebGLRenderer;
    private needsRender: boolean;
    private camera: THREE.PerspectiveCamera;
    private imagePlaneScene: GlScene;

    private imagePlaneDistance: number = 200;

    private currentKey: string;
    private previousKey: string;

    constructor (container: Container, navigator: Navigator) {
        this.container = container;
        this.navigator = navigator;

        this.currentKey = null;
        this.previousKey = null;

        this.needsRender = false;
    }

    public activate(): void {
        this.renderer = new THREE.WebGLRenderer();

        let width: number = this.container.element.offsetWidth;
        this.renderer.setSize(width, width * 3 / 4);
        this.renderer.setClearColor(new THREE.Color(0x202020), 1.0);
        this.renderer.sortObjects = false;

        this.renderer.domElement.style.width = "100%";
        this.renderer.domElement.style.height = "100%";
        this.container.element.appendChild(this.renderer.domElement);

        this.camera = new THREE.PerspectiveCamera(50, 4 / 3, 0.4, 10000);
        this.imagePlaneScene = new GlScene();

        this.stateSubscription = this.navigator.stateService2.currentState.subscribe(
            this.onStateChanged.bind(this));
    }

    public deactivate(): void {
        this.stateSubscription.dispose();
    }

    private onStateChanged(state: ICurrentState): void {
        this.updateImagePlanes(state);
        this.updateCamera(state.camera);

        this.render(state.alpha);
    }

    private updateImagePlanes(state: ICurrentState): void {
        if (state.currentNode == null || state.currentNode.key === this.currentKey) {
            return;
        }

        this.previousKey = state.previousNode != null ? state.previousNode.key : null;
        if (this.previousKey != null) {
            if (this.previousKey !== this.currentKey) {<commit_msg>Check if alpha has changed in GlUI.<commit_after>/// <reference path="../../../typings/threejs/three.d.ts" />
/// <reference path="../../../node_modules/rx/ts/rx.all.d.ts" />

import * as THREE from "three";
import * as rx from "rx";

import {IUI, Shaders, GlScene} from "../../UI";
import {ICurrentState} from "../../State";
import {Container, Navigator} from "../../Viewer";
import {Transform, Camera} from "../../Geo";
import {Node} from "../../Graph";

export class GlUI implements IUI {
    private container: Container;
    private navigator: Navigator;

    private stateSubscription: rx.IDisposable;

    private renderer: THREE.WebGLRenderer;
    private needsRender: boolean;
    private lastAlpha: number;
    private camera: THREE.PerspectiveCamera;
    private imagePlaneScene: GlScene;

    private imagePlaneDistance: number = 200;

    private currentKey: string;
    private previousKey: string;

    constructor (container: Container, navigator: Navigator) {
        this.container = container;
        this.navigator = navigator;

        this.currentKey = null;
        this.previousKey = null;

        this.needsRender = false;
    }

    public activate(): void {
        this.renderer = new THREE.WebGLRenderer();

        let width: number = this.container.element.offsetWidth;
        this.renderer.setSize(width, width * 3 / 4);
        this.renderer.setClearColor(new THREE.Color(0x202020), 1.0);
        this.renderer.sortObjects = false;

        this.renderer.domElement.style.width = "100%";
        this.renderer.domElement.style.height = "100%";
        this.container.element.appendChild(this.renderer.domElement);

        this.camera = new THREE.PerspectiveCamera(50, 4 / 3, 0.4, 10000);
        this.imagePlaneScene = new GlScene();

        this.stateSubscription = this.navigator.stateService2.currentState.subscribe(
            this.onStateChanged.bind(this));
    }

    public deactivate(): void {
        this.stateSubscription.dispose();
    }

    private onStateChanged(state: ICurrentState): void {
        this.updateImagePlanes(state);
        this.updateAlpha(state.alpha);
        this.updateCamera(state.camera);

        this.render(state.alpha);
    }

    private updateAlpha(alpha: number): void {
        if (this.lastAlpha !== alpha) {
            this.needsRender = true;
        }

        this.lastAlpha = alpha;
    }

    private updateImagePlanes(state: ICurrentState): void {
        if (state.currentNode == null || state.currentNode.key === this.currentKey) {
            return;
        }

        this.previousKey = state.previousNode != null ? state.previousNode.key : null;
        if (this.previousKey != null) {
            if (this.previousKey !== this.currentKey) {
{'fraction_non_alphanumeric': 0.13261786124952088, 'fraction_numerical': 0.012265235722499043, 'mean_word_length': 2.7040454222853088, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6497093', 'n_tokens_mistral': 1544, 'n_tokens_neox': 1468, 'n_words': 339}