<commit_before>var Window        = require('pex-sys/Window');
var MouseEvent    = require('pex-sys/MouseEvent');
var Mat4          = require('pex-math/Mat4');
var Vec3          = require('pex-math/Vec3');
var createSphere  = require('primitive-sphere');
var Draw          = require('pex-draw/Draw');
var PerspCamera   = require('pex-cam/PerspCamera');
var Arcball       = require('pex-cam/Arcball');
var AABB          = require('pex-geom/AABB');
var Renderer      = require('../Renderer');
var parseObj      = require('geom-parse-obj');
var createSphere  = require('primitive-sphere');
var createCube    = require('primitive-cube');
var Draw          = require('pex-draw');
var isBrowser     = require('is-browser');
var GUI           = require('pex-gui');
var random        = require('pex-random');
var ASSETS_DIR    = isBrowser ? 'Assets' : __dirname + '/Assets';
var parseHdr      = require('./local_modules/parse-hdr');

Window.create({
    settings: {
        type: '3d',
        width: 1280,
        height: 720,
        fullScreen: isBrowser
    },
    resources: {
       //envMap: { binary: ASSETS_DIR + '/textures/envmaps/Hamarikyu_Bridge_B/Hamarikyu_Bridge_B.hdr' },
       envMap: { binary: ASSETS_DIR + '/textures/envmaps/garage/garage.hdr' },
       //envMap: { binary: ASSETS_DIR + '/textures/envmaps/uffizi/uffizi.hdr' },
       // envMap: { image: ASSETS_DIR + '/textures/envmaps/test/test.png' },
    },
    sunPosition: [0, 5, -5],
    elevation: 65,
    azimuth: 0,
    mie: 0.000021,
    elevationMat: Mat4.create(),
    rotationMat: Mat4.create(),
    init: function() {
        try {
        var res = this.getResources();
        var ctx = this.getContext();
        var gui = this.gui = new GUI(ctx, this.getWidth(), this.getHeight());
        this.addEventListener(gui);
        random.seed(0);

        gui.addParam('Sun Elevation', this, 'elevation', { min: -90, max: 180 }, this.updateSunPosition.bind(this));
        var renderer = this.renderer = new Renderer(ctx, this.getWidth(), this.getHeight());
       
        gui.addParam('Exposure', this.renderer._state, 'exposure', { min: 0.01, max: 5});

        if (res.envMap) {
            if (res.envMap.width) {
                var envMapTex = ctx.createTexture2D(res.envMap);
            }
            else { //binary
                var envMapInfo = parseHdr(res.envMap);
                var envMapTex = ctx.createTexture2D(envMapInfo.data, envMapInfo.shape[0], envMapInfo.shape[1], {
                    type: ctx.FLOAT
                });
            }
            gui.addTexture2D('EnvMap', envMapTex);
            renderer._state.skyEnvMap = envMapTex;
        }
        gui.addTexture2D('SkyEnvMap', renderer._skyEnvMapTex, { hdr: true });
        gui.addTextureCube('Reflection Map', renderer._reflectionProbe.getReflectionMap(), { hdr: true });
        gui.addTextureCube('Irradiance Map', renderer._reflectionProbe.getIrradianceMap(), { hdr: true });

        this.camera = new PerspCamera(45, this.getAspectRatio(), 0.1, 20.0);;
        this.camera.lookAt([0,0,5], [0,0,0]);
        renderer.createCameraNode(this.camera);

        this.arcball = new Arcball(this.camera, this.getWidth(), this.getHeight());
        this.addEventListener(this.arcball);

        var sunDir = Vec3.normalize([1, 0.1, 0]);
        this.sunLightNode = renderer.createDirectionalLightNode(sunDir);
        gui.addTexture2D('Shadow Map', this.sunLightNode.light.shadowMap);

        var mesh = this.buildMesh(createCube(0.2, 0.5 + Math.random(), 0.2));<commit_msg>Example properly rendering hdr image<commit_after>var Window        = require('pex-sys/Window');
var MouseEvent    = require('pex-sys/MouseEvent');
var Mat4          = require('pex-math/Mat4');
var Vec3          = require('pex-math/Vec3');
var createSphere  = require('primitive-sphere');
var Draw          = require('pex-draw/Draw');
var PerspCamera   = require('pex-cam/PerspCamera');
var Arcball       = require('pex-cam/Arcball');
var AABB          = require('pex-geom/AABB');
var Renderer      = require('../Renderer');
var parseObj      = require('geom-parse-obj');
var createSphere  = require('primitive-sphere');
var createCube    = require('primitive-cube');
var Draw          = require('pex-draw');
var isBrowser     = require('is-browser');
var GUI           = require('pex-gui');
var random        = require('pex-random');
var ASSETS_DIR    = isBrowser ? 'Assets' : __dirname + '/Assets';
var parseHdr      = require('./local_modules/parse-hdr');

Window.create({
    settings: {
        type: '3d',
        width: 1280,
        height: 720,
        fullScreen: isBrowser
    },
    resources: {
       //envMap: { binary: ASSETS_DIR + '/textures/envmaps/Hamarikyu_Bridge_B/Hamarikyu_Bridge_B.hdr' },
       envMap: { binary: ASSETS_DIR + '/textures/envmaps/garage/garage.hdr' },
       //envMap: { binary: ASSETS_DIR + '/textures/envmaps/uffizi/uffizi.hdr' },
       // envMap: { image: ASSETS_DIR + '/textures/envmaps/test/test.png' },
    },
    sunPosition: [0, 5, -5],
    elevation: 65,
    azimuth: 0,
    mie: 0.000021,
    elevationMat: Mat4.create(),
    rotationMat: Mat4.create(),
    init: function() {
        try {
        var res = this.getResources();
        var ctx = this.getContext();
        var gui = this.gui = new GUI(ctx, this.getWidth(), this.getHeight());
        this.addEventListener(gui);
        random.seed(0);

        gui.addParam('Sun Elevation', this, 'elevation', { min: -90, max: 180 }, this.updateSunPosition.bind(this));
        var renderer = this.renderer = new Renderer(ctx, this.getWidth(), this.getHeight());
       
        gui.addParam('Exposure', this.renderer._state, 'exposure', { min: 0.01, max: 5});

        if (res.envMap) {
            if (res.envMap.width) {
                var envMapTex = ctx.createTexture2D(res.envMap);
            }
            else { //binary
                var envMapInfo = parseHdr(res.envMap);
                var envMapTex = ctx.createTexture2D(envMapInfo.data, envMapInfo.shape[0], envMapInfo.shape[1], {
                    type: ctx.FLOAT
                });
            }
            gui.addTexture2D('EnvMap', envMapTex, { hdr: true });
            renderer._state.skyEnvMap = envMapTex;
        }
        gui.addTexture2D('SkyEnvMap', renderer._skyEnvMapTex, { hdr: true });
        gui.addTextureCube('Reflection Map', renderer._reflectionProbe.getReflectionMap(), { hdr: true });
        gui.addTextureCube('Irradiance Map', renderer._reflectionProbe.getIrradianceMap(), { hdr: true });

        this.camera = new PerspCamera(45, this.getAspectRatio(), 0.1, 20.0);;
        this.camera.lookAt([0,0,5], [0,0,0]);
        renderer.createCameraNode(this.camera);

        this.arcball = new Arcball(this.camera, this.getWidth(), this.getHeight());
        this.addEventListener(this.arcball);

        var sunDir = Vec3.normalize([1, 0.1, 0]);
        this.sunLightNode = renderer.createDirectionalLightNode(sunDir);
        gui.addTexture2D('Shadow Map', this.sunLightNode.light.shadowMap);

        var mesh = this.buildMesh(createCube(0.2, 0.5 + Math.random(), 0.2));
{'fraction_non_alphanumeric': 0.15226569096538137, 'fraction_numerical': 0.019138755980861243, 'mean_word_length': 2.6021287379624938, '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': '713767', 'n_tokens_mistral': 2410, 'n_tokens_neox': 2263, 'n_words': 425}