mirror of
https://github.com/visgl/luma.gl.git
synced 2026-02-01 14:33:49 +00:00
chore(typescript): minor typescript changes (#1459)
This commit is contained in:
parent
d5bd93ef6b
commit
666ca3bf69
27
modules/shadertools/src/lib/assembe-shaders.d.ts
vendored
27
modules/shadertools/src/lib/assembe-shaders.d.ts
vendored
@ -1,27 +0,0 @@
|
||||
export type HookFunction = {
|
||||
vs: string;
|
||||
fs: string;
|
||||
};
|
||||
|
||||
export type AssembleShaderOptions = {
|
||||
id: string;
|
||||
source: any;
|
||||
type: any;
|
||||
modules: any[];
|
||||
defines?: object;
|
||||
hookFunctions?: HookFunction[];
|
||||
inject?: object;
|
||||
transpileToGLSL100?: boolean;
|
||||
prologue?: boolean;
|
||||
log: any;
|
||||
};
|
||||
|
||||
export function assembleShaders(
|
||||
gl: WebGLRenderingContext,
|
||||
opts: AssembleShaderOptions
|
||||
): {
|
||||
gl: WebGLRenderingContext;
|
||||
vs: string;
|
||||
fs: string;
|
||||
getUniforms: any;
|
||||
};
|
||||
@ -59,7 +59,7 @@ function assembleShader(
|
||||
// Extract any version directive string from source.
|
||||
// TODO : keep all pre-processor statements at the begining of the shader.
|
||||
if (sourceLines[0].indexOf('#version ') === 0) {
|
||||
glslVersion = 300; // TODO - regexp that matches atual version number
|
||||
glslVersion = 300; // TODO - regexp that matches actual version number
|
||||
versionLine = sourceLines[0];
|
||||
coreSource = sourceLines.slice(1).join('\n');
|
||||
} else {
|
||||
|
||||
@ -35,27 +35,31 @@ export default function injectShader(source, type, inject, injectStandardStubs =
|
||||
source = source.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
||||
}
|
||||
break;
|
||||
// main code is injected at the end of main function
|
||||
// inject code at the beginning of the main function
|
||||
case 'vs:#main-start':
|
||||
if (isVertex) {
|
||||
source = source.replace(REGEX_START_OF_MAIN, match => match + fragmentString);
|
||||
}
|
||||
break;
|
||||
// inject code at the end of main function
|
||||
case 'vs:#main-end':
|
||||
if (isVertex) {
|
||||
source = source.replace(REGEX_END_OF_MAIN, match => fragmentString + match);
|
||||
}
|
||||
break;
|
||||
// declarations are injected before the main function
|
||||
case 'fs:#decl':
|
||||
if (!isVertex) {
|
||||
source = source.replace(DECLARATION_INJECT_MARKER, fragmentString);
|
||||
}
|
||||
break;
|
||||
// inject code at the beginning of the main function
|
||||
case 'fs:#main-start':
|
||||
if (!isVertex) {
|
||||
source = source.replace(REGEX_START_OF_MAIN, match => match + fragmentString);
|
||||
}
|
||||
break;
|
||||
// inject code at the end of main function
|
||||
case 'fs:#main-end':
|
||||
if (!isVertex) {
|
||||
source = source.replace(REGEX_END_OF_MAIN, match => fragmentString + match);
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import {ShaderModule} from '../../types';
|
||||
import {ShaderPass} from '../../types';
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import {ShaderModule} from '../../types';
|
||||
import {ShaderPass} from '../../types';
|
||||
|
||||
/**
|
||||
* Warps a circular region of the image in a swirl.
|
||||
@ -7,4 +7,4 @@ import {ShaderModule} from '../../types';
|
||||
* @param angle The angle in radians that the pixels in the center of
|
||||
* the circular region will be rotated by.
|
||||
*/
|
||||
export const swirl: ShaderModule;
|
||||
export const swirl: ShaderPass;
|
||||
|
||||
@ -51,7 +51,7 @@ main() {
|
||||
|
||||
### getUniforms
|
||||
|
||||
`getUniforms` takes an object takes a set of key/value pairs, returns an object with key/value pairs representing the uniforms that the `picking` module shaders need.
|
||||
`getUniforms` takes an object with key/value pairs, returns an object with key/value pairs representing the uniforms that the `picking` module shaders need.
|
||||
|
||||
`getUniforms(opts)`
|
||||
opts can contain following keys:
|
||||
|
||||
@ -81,7 +81,7 @@ const compiledGlslExtensions = {};
|
||||
* gl : WebGL context
|
||||
* cap : Key of WEBGL_FEATURES object identifying the extension
|
||||
* opts :
|
||||
* behavior : behavor of extension to be tested, by defualt `enable` is used
|
||||
* behavior : behavior of extension to be tested, by defualt `enable` is used
|
||||
* Returns : true, if shader is compiled successfully, false otherwise
|
||||
*/
|
||||
export function canCompileGLGSExtension(gl, cap, opts = {}) {
|
||||
|
||||
11
modules/webgl/src/classes/clear.d.ts
vendored
Normal file
11
modules/webgl/src/classes/clear.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import Framebuffer from './framebuffer';
|
||||
|
||||
export function clear(
|
||||
gl: WebGLRenderingContext,
|
||||
options?: {framebuffer?: Framebuffer; color?: any; depth?: any; stencil?: any}
|
||||
): void;
|
||||
|
||||
export function clearBuffer(
|
||||
gl: any,
|
||||
options?: {framebuffer?: Framebuffer; buffer?: any; drawBuffer?: any; value?: any}
|
||||
);
|
||||
@ -15,6 +15,7 @@ const GL_DEPTH_STENCIL = 0x84f9;
|
||||
const ERR_ARGUMENTS = 'clear: bad arguments';
|
||||
|
||||
// Optionally clears depth, color and stencil buffers
|
||||
/** @type {import('./clear').clear} */
|
||||
export function clear(gl, {framebuffer = null, color = null, depth = null, stencil = null} = {}) {
|
||||
const parameters = {};
|
||||
|
||||
@ -54,6 +55,7 @@ export function clear(gl, {framebuffer = null, color = null, depth = null, stenc
|
||||
}
|
||||
|
||||
// WebGL2 - clear a specific drawing buffer
|
||||
/** @type {import('./clear').clearBuffer} */
|
||||
export function clearBuffer(
|
||||
gl,
|
||||
{framebuffer = null, buffer = GL_COLOR, drawBuffer = 0, value = [0, 0, 0, 0]} = {}
|
||||
|
||||
@ -289,7 +289,7 @@ export default class Framebuffer extends Resource {
|
||||
}
|
||||
|
||||
drawBuffers.forEach((value, drawBuffer) => {
|
||||
clearBuffer({drawBuffer, value});
|
||||
clearBuffer(this.gl, {drawBuffer, value});
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
|
||||
10
modules/webgl/src/classes/texture-2d-array.d.ts
vendored
10
modules/webgl/src/classes/texture-2d-array.d.ts
vendored
@ -1,10 +0,0 @@
|
||||
import Texture, {TextureProps} from './texture';
|
||||
|
||||
export type Texture2DArrayProps = TextureProps & {
|
||||
};
|
||||
|
||||
export default class Texture2DArray extends Texture {
|
||||
static isSupported(gl: WebGLRenderingContext, opts?: object): boolean;
|
||||
|
||||
constructor(gl: WebGLRenderingContext, props?: Texture2DArrayProps);
|
||||
}
|
||||
11
modules/webgl/src/webgl-utils/texture-utils.d.ts
vendored
Normal file
11
modules/webgl/src/webgl-utils/texture-utils.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
import Texture2D from '../classes/texture-2d';
|
||||
import TextureCube from '../classes/texture-cube';
|
||||
import Texture3D from '../classes/texture-3d';
|
||||
import Texture from '../classes/texture';
|
||||
import Framebuffer, {FramebufferProps} from '../classes/framebuffer';
|
||||
|
||||
type TextureType = Texture2D | TextureCube | Texture3D;
|
||||
|
||||
export function cloneTextureFrom<T extends TextureType>(refTexture: T, overrides?: any): T;
|
||||
|
||||
export function toFramebuffer(texture: Texture, opts?: FramebufferProps): Framebuffer;
|
||||
@ -7,6 +7,7 @@ import GL from '@luma.gl/constants';
|
||||
import {assert} from '../utils';
|
||||
|
||||
// Clone a new texture object from a reference texture object.
|
||||
/** @type {import('./texture-utils').cloneTextureFrom} */
|
||||
export function cloneTextureFrom(refTexture, overrides) {
|
||||
assert(
|
||||
refTexture instanceof Texture2D ||
|
||||
@ -37,6 +38,7 @@ export function cloneTextureFrom(refTexture, overrides) {
|
||||
|
||||
// Wraps a given texture into a framebuffer object, that can be further used
|
||||
// to read data from the texture object.
|
||||
/** @type {import('./texture-utils').toFramebuffer} */
|
||||
export function toFramebuffer(texture, opts) {
|
||||
const {gl, width, height, id} = texture;
|
||||
const framebuffer = new Framebuffer(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user