1.0.3 • Published 1 year ago

@infra7/glsl-extract v1.0.3

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

@infra7/glsl-extract

A GLSL parameters extractor.

Example

Online Demo

Installation

$ npm i -S @infra7/glsl-extract

API

ExtractGLSL(source: string): Result;

interface Item {
  name: string;
  type: string;
}

interface Result {
  uniform:   Item[];
  attribute: Item[];
  varying:   Item[];
  in:        Item[];
  out:       Item[];
}

Example

import { ExtractGLSL } from '.';

const source = `
precision highp float;

attribute vec2 aPosition;
attribute vec4 aColor;
varying   vec4 vColor;

uniform   mat3 uViewMatrix;
uniform   mat3 uLocalMatrix;

void main() {
  vColor = aColor;
  vec3 coord = uViewMatrix * uLocalMatrix * vec3(aPosition, 1.0);
  gl_Position = vec4(coord.xy, 0.0, 1.0);
}
`;

const result = ExtractGLSL(source);

Result

npm.io

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago