UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

66 lines (65 loc) 1.78 kB
import Light from "../Light.mjs"; import cubemapUtil from "../util/cubemap.mjs"; var AmbientCubemapLight = Light.extend({ cubemap: null, castShadow: false, _normalDistribution: null, _brdfLookup: null }, { type: "AMBIENT_CUBEMAP_LIGHT", prefilter: function(renderer, size) { if (!renderer.getGLExtension("EXT_shader_texture_lod")) { console.warn("Device not support textureCubeLodEXT"); return; } if (!this._brdfLookup) { this._normalDistribution = cubemapUtil.generateNormalDistribution(); this._brdfLookup = cubemapUtil.integrateBRDF(renderer, this._normalDistribution); } var cubemap = this.cubemap; if (cubemap.__prefiltered) { return; } var result = cubemapUtil.prefilterEnvironmentMap( renderer, cubemap, { encodeRGBM: true, width: size, height: size }, this._normalDistribution, this._brdfLookup ); this.cubemap = result.environmentMap; this.cubemap.__prefiltered = true; cubemap.dispose(renderer); }, getBRDFLookup: function() { return this._brdfLookup; }, uniformTemplates: { ambientCubemapLightColor: { type: "3f", value: function(instance) { var color = instance.color; var intensity = instance.intensity; return [color[0] * intensity, color[1] * intensity, color[2] * intensity]; } }, ambientCubemapLightCubemap: { type: "t", value: function(instance) { return instance.cubemap; } }, ambientCubemapLightBRDFLookup: { type: "t", value: function(instance) { return instance._brdfLookup; } } } }); var AmbientCubemapLight$1 = AmbientCubemapLight; export { AmbientCubemapLight$1 as default };