Skip to content

Commit

Permalink
ts and related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
igorDykhta committed Apr 8, 2021
1 parent d5bd93e commit 476a3fb
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 45 deletions.
27 changes: 0 additions & 27 deletions modules/shadertools/src/lib/assembe-shaders.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion modules/shadertools/src/lib/assemble-shaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion modules/shadertools/src/lib/inject-shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 begining 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 begining 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {ShaderModule} from '../../types';
import {ShaderPass} from '../../types';

/**
Expand Down
4 changes: 2 additions & 2 deletions modules/shadertools/src/modules/image-warp-filters/swirl.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ShaderModule} from '../../types';
import {ShaderPass} from '../../types';

/**
* Warps a circular region of the image in a swirl.
Expand All @@ -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;
2 changes: 1 addition & 1 deletion modules/shadertools/src/modules/picking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion modules/shadertools/src/utils/webgl-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
Expand Down
11 changes: 11 additions & 0 deletions modules/webgl/src/classes/clear.d.ts
Original file line number Diff line number Diff line change
@@ -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}
);
2 changes: 2 additions & 0 deletions modules/webgl/src/classes/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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]} = {}
Expand Down
2 changes: 1 addition & 1 deletion modules/webgl/src/classes/framebuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export default class Framebuffer extends Resource {
}

drawBuffers.forEach((value, drawBuffer) => {
clearBuffer({drawBuffer, value});
clearBuffer(this.gl, {drawBuffer, value});
});

// @ts-ignore
Expand Down
10 changes: 0 additions & 10 deletions modules/webgl/src/classes/texture-2d-array.d.ts

This file was deleted.

14 changes: 14 additions & 0 deletions modules/webgl/src/webgl-utils/texture-utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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 TextureToCloneType = Texture2D | TextureCube | Texture3D;

export function cloneTextureFrom<TextureType extends TextureToCloneType>(
refTexture: TextureType,
overrides?: any
): TextureType;

export function toFramebuffer(texture: Texture, opts?: FramebufferProps): Framebuffer;
2 changes: 2 additions & 0 deletions modules/webgl/src/webgl-utils/texture-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 476a3fb

Please sign in to comment.