/* * Copyright 2013, kaj dijkstra , * Author, Kaj Dijkstra. * All rights reserved. * */ var cubeSamplerID = 0; import {math} from './math.js'; /** * light **/ class samplerCube{ constructor() { this.textures = []; this.cubeTexture = gl.createTexture(); this.id = ++kepler.samplerId;//+engine.samplerCubeID this.FLIP_Y = true; this.MIN_FILTER = gl.LINEAR; this.MAG_FILTER = gl.LINEAR; this.WRAP_S = gl.REPEAT; this.WRAP_T = gl.REPEAT; this.datatype = gl.RGB; this.format = gl.RGB; this.internalFormat = gl.RGB; this.target = gl.TEXTURE_CUBE_MAP; this.type = gl.UNSIGNED_BYTE; this.alpha = 1.0; this.binded = false; this.anisotropic = false; } setViewport( viewport ){ this.viewport = viewport; this.gl = viewport.gl; } setTarget(target) { var faces = [ gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z ]; for(var c =0; c 1 ? this.gl.LINEAR_MIPMAP_LINEAR : this.gl.LINEAR // this.gl.texParameteri(this.target, this.gl.TEXTURE_WRAP_S, this.WRAP_S); // this.gl.texParameteri(this.target, this.gl.TEXTURE_WRAP_T, this.WRAP_T); this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR); this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR); this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE); this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE); //this.gl.generateMipmap(this.gl.TEXTURE_2D); } else { this.gl.texParameteri(this.target, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR); this.gl.texParameteri(this.target, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE); this.gl.texParameteri(this.target, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE); } } this.gl.bindTexture(this.target, null); this.binded = true; } } export {samplerCube as default};