glsl-token-inject-block

WebJar for glsl-token-inject-block

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

glsl-token-inject-block
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

glsl-token-inject-block
WebJar for glsl-token-inject-block
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/Jam3/glsl-token-inject-block

Download glsl-token-inject-block

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/glsl-token-inject-block/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>glsl-token-inject-block</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/glsl-token-inject-block/
implementation 'org.webjars.npm:glsl-token-inject-block:1.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/glsl-token-inject-block/
implementation ("org.webjars.npm:glsl-token-inject-block:1.1.0")
'org.webjars.npm:glsl-token-inject-block:jar:1.1.0'
<dependency org="org.webjars.npm" name="glsl-token-inject-block" rev="1.1.0">
  <artifact name="glsl-token-inject-block" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='glsl-token-inject-block', version='1.1.0')
)
libraryDependencies += "org.webjars.npm" % "glsl-token-inject-block" % "1.1.0"
[org.webjars.npm/glsl-token-inject-block "1.1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

glsl-token-inject-block

unstable

Injects a "block" of GLSL tokens into a shader, after any #version, #extension and precision statements. This will pad the new tokens with the necessary amount of newlines (but no more).

This module ignores token line, column and position.

Example

Your source:

var tokenizer = require('glsl-tokenizer')
var inject = require('glsl-token-inject-block')
var stringify = require('glsl-token-string')

var tokens = tokenizer(shaderInput)
var newToken = { 
  type: 'preprocessor', 
  data: '#define FOOBAR' 
}

var source = stringify(inject(tokens, newToken))
console.log(source)

The following shader input:

// some comment
#version 300 es
#extension SOME_EXTENSION : enable

void main() {}

Results in the following injected define:

// some comment
#version 300 es
#extension SOME_EXTENSION : enable
#define FOOBAR

void main() {}

Usage

NPM

tokens = inject(tokens, newTokens)

For the given shader source (tokens), injects newTokens into them, assuming the new tokens are a "block" of code that should be placed on its own line.

newTokens can be a single token object, or an array of token objects.

Modifies tokens in place and returns it.

License

MIT, see LICENSE.md for details.

org.webjars.npm

Jam3

We create modern experiences for tomorrow’s brands

Versions

Version
1.1.0