<commit_before>class App
    constructor: (@options={}) ->
        @debug = true or @options.debug
        #: some log utils
        @log_types =
            e: "error"
            w: "warn"
            i: "info"
        #: default configuration
        @_defaults =
            physics: false
            camera:
                fov: 75
                near: 0.1
                far: 100
            frameRate: 60
            alphaRender: false
            castShadows: true
            controller: Wage.FreeController
            controllerOptions: {}
            handlers:
                mouse: Wage.Mouse
                leap: Wage.Leap
        #: configuration object (filled in with default and user options)
        @config = {}
        #: handle physics only if requested
        @_physiscs = false
        #: to store input devices handlers
        @devices = {}
        #: to store game assets
        @assets =
            sounds: {}
            images: {}
            shaders: {}
            videos: {}
        return this

    onCreate: ->
        return

    preload: (callback) ->
        callback()
        return

    onPrepare: ->
        return

    progressAnimation: (callback) ->
        $('#loader').animate(
            opacity: 0
            'margin-top': "250px"
        1000
        ->
            $('#loader').remove()
            $('body').animate(
                backgroundColor: '#fff'
            200
            callback
            )
            return
        )
        return

    render: ->
        return

    _render: ->
        scope = this
        {scene, camera, world, control, renderer, bind} = Wage
        {audio, lights} = Wage.managers
        #: call updates
        audio.update()
        lights.update()
        # [note] camera entity is updated by world
        world.update()
        control.update()
        #: update scene
        renderer.clear()
        @render()
        renderer.render scene, camera
        rf = bind this, this._render
        #: set next call
        setTimeout( ->
            if scope._physiscs
                scene.simulate()
            requestAnimationFrame rf
            return
        1000 / @config.frameRate)
        return

    add: (mesh, element) ->
        {scene, world} = Wage
        scene.add mesh
        world.entities[mesh.uuid] = element
        return

    remove: (mesh) ->
        {scene, world} = Wage
        scene.remove mesh
        delete world.entities[mesh.uuid]
        return

    _loadConfig: ->
        for key, val of @_defaults
            if @options[key] isnt undefined
                val = @options[key]
            @config[key] = val
        # max fps to 120!
        if @config.frameRate > 120
            @config.frameRate = 120
        #: init devices handlers
        for key, val of @config.handlers
            @devices[key] = new val()
        return

    init: ->
        {screen, world} = Wage
        #: load configuration
        @_loadConfig()
        #: init physics (if requested) and scene
        if @config.physics
            try
                Physijs.scripts.worker = 'workers/physijs_worker.js'
                Wage.scene = new Physijs.Scene()
                @_physiscs = true
            catch e
                @log(e)
        if not @_physiscs
            Wage.scene = new THREE.Scene()
        #: init camera
        Wage.camera = new Wage.Camera(@config.camera).object
        #: init renderer
        renderer = Wage.renderer = new THREE.WebGLRenderer
            alpha: @config.alphaRender
        if @config.castShadows
            renderer.shadowMapEnabled = true
            renderer.shadowMapType = THREE.PCFSoftShadowMap
        renderer.autoClear = false
        renderer.setSize screen.w, screen.h
        document.getElementById('gameContainer').appendChild renderer.domElement
        # TODO game
        #: init controls manager
        Wage.control = new Wage.Control @config.controllerOptions
        for devname, device of @devices
            device.init()
            device.addListeners()
        #: finish init and render
        @onCreate()
        @_render()
        return

    load: ->
        {bind} = Wage
        @progressAnimation bind this, @init
        return

    _prepare: -><commit_msg>Init camera with screen ratio<commit_after>class App
    constructor: (@options={}) ->
        @debug = true or @options.debug
        #: some log utils
        @log_types =
            e: "error"
            w: "warn"
            i: "info"
        #: default configuration
        @_defaults =
            physics: false
            camera:
                fov: 75
                near: 0.1
                far: 100
            frameRate: 60
            alphaRender: false
            castShadows: true
            controller: Wage.FreeController
            controllerOptions: {}
            handlers:
                mouse: Wage.Mouse
                leap: Wage.Leap
        #: configuration object (filled in with default and user options)
        @config = {}
        #: handle physics only if requested
        @_physiscs = false
        #: to store input devices handlers
        @devices = {}
        #: to store game assets
        @assets =
            sounds: {}
            images: {}
            shaders: {}
            videos: {}
        return this

    onCreate: ->
        return

    preload: (callback) ->
        callback()
        return

    onPrepare: ->
        return

    progressAnimation: (callback) ->
        $('#loader').animate(
            opacity: 0
            'margin-top': "250px"
        1000
        ->
            $('#loader').remove()
            $('body').animate(
                backgroundColor: '#fff'
            200
            callback
            )
            return
        )
        return

    render: ->
        return

    _render: ->
        scope = this
        {scene, camera, world, control, renderer, bind} = Wage
        {audio, lights} = Wage.managers
        #: call updates
        audio.update()
        lights.update()
        # [note] camera entity is updated by world
        world.update()
        control.update()
        #: update scene
        renderer.clear()
        @render()
        renderer.render scene, camera
        rf = bind this, this._render
        #: set next call
        setTimeout( ->
            if scope._physiscs
                scene.simulate()
            requestAnimationFrame rf
            return
        1000 / @config.frameRate)
        return

    add: (mesh, element) ->
        {scene, world} = Wage
        scene.add mesh
        world.entities[mesh.uuid] = element
        return

    remove: (mesh) ->
        {scene, world} = Wage
        scene.remove mesh
        delete world.entities[mesh.uuid]
        return

    _loadConfig: ->
        for key, val of @_defaults
            if @options[key] isnt undefined
                val = @options[key]
            @config[key] = val
        # max fps to 120!
        if @config.frameRate > 120
            @config.frameRate = 120
        #: init devices handlers
        for key, val of @config.handlers
            @devices[key] = new val()
        return

    init: ->
        {screen, world} = Wage
        #: load configuration
        @_loadConfig()
        #: init physics (if requested) and scene
        if @config.physics
            try
                Physijs.scripts.worker = 'workers/physijs_worker.js'
                Wage.scene = new Physijs.Scene()
                @_physiscs = true
            catch e
                @log(e)
        if not @_physiscs
            Wage.scene = new THREE.Scene()
        #: init camera
        @config.camera.ratio = screen.ratio
        Wage.camera = new Wage.Camera(@config.camera).object
        #: init renderer
        renderer = Wage.renderer = new THREE.WebGLRenderer
            alpha: @config.alphaRender
        if @config.castShadows
            renderer.shadowMapEnabled = true
            renderer.shadowMapType = THREE.PCFSoftShadowMap
        renderer.autoClear = false
        renderer.setSize screen.w, screen.h
        document.getElementById('gameContainer').appendChild renderer.domElement
        # TODO game
        #: init controls manager
        Wage.control = new Wage.Control @config.controllerOptions
        for devname, device of @devices
            device.init()
            device.addListeners()
        #: finish init and render
        @onCreate()
        @_render()
        return

    load: ->
        {bind} = Wage
        @progressAnimation bind this, @init
        return

    _prepare: ->
{'fraction_non_alphanumeric': 0.09056033480585911, 'fraction_numerical': 0.0076726342710997444, 'mean_word_length': 1.3615152346966786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '5174748', 'n_tokens_mistral': 2327, 'n_tokens_neox': 2198, 'n_words': 606}