Buckets:
ktongue/docker_container / simsite /frontend /node_modules /three /src /renderers /webgl /WebGLCubeMaps.js
| import { CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping } from '../../constants.js'; | |
| import { WebGLCubeRenderTarget } from '../WebGLCubeRenderTarget.js'; | |
| function WebGLCubeMaps( renderer ) { | |
| let cubemaps = new WeakMap(); | |
| function mapTextureMapping( texture, mapping ) { | |
| if ( mapping === EquirectangularReflectionMapping ) { | |
| texture.mapping = CubeReflectionMapping; | |
| } else if ( mapping === EquirectangularRefractionMapping ) { | |
| texture.mapping = CubeRefractionMapping; | |
| } | |
| return texture; | |
| } | |
| function get( texture ) { | |
| if ( texture && texture.isTexture ) { | |
| const mapping = texture.mapping; | |
| if ( mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping ) { | |
| if ( cubemaps.has( texture ) ) { | |
| const cubemap = cubemaps.get( texture ).texture; | |
| return mapTextureMapping( cubemap, texture.mapping ); | |
| } else { | |
| const image = texture.image; | |
| if ( image && image.height > 0 ) { | |
| const renderTarget = new WebGLCubeRenderTarget( image.height / 2 ); | |
| renderTarget.fromEquirectangularTexture( renderer, texture ); | |
| cubemaps.set( texture, renderTarget ); | |
| texture.addEventListener( 'dispose', onTextureDispose ); | |
| return mapTextureMapping( renderTarget.texture, texture.mapping ); | |
| } else { | |
| // image not yet ready. try the conversion next frame | |
| return null; | |
| } | |
| } | |
| } | |
| } | |
| return texture; | |
| } | |
| function onTextureDispose( event ) { | |
| const texture = event.target; | |
| texture.removeEventListener( 'dispose', onTextureDispose ); | |
| const cubemap = cubemaps.get( texture ); | |
| if ( cubemap !== undefined ) { | |
| cubemaps.delete( texture ); | |
| cubemap.dispose(); | |
| } | |
| } | |
| function dispose() { | |
| cubemaps = new WeakMap(); | |
| } | |
| return { | |
| get: get, | |
| dispose: dispose | |
| }; | |
| } | |
| export { WebGLCubeMaps }; | |
Xet Storage Details
- Size:
- 1.91 kB
- Xet hash:
- f0edd1c48deea42dddbfeef800c3e87c2b83c8c8941c00700b953f607692e1ee
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.