code stringlengths 0 56.1M | repo_name stringlengths 3 57 | path stringlengths 2 176 | language stringclasses 672 values | license stringclasses 8 values | size int64 0 56.8M |
|---|---|---|---|---|---|
export class ScreenGeometry extends SurfaceGeometry {
constructor(options: any);
cover(scaleX: any, scaleY: any, scaleZ: any, scaleW: any): void;
scaleX: any;
scaleY: any;
scaleZ: any;
scaleW: any;
clip(width: any, height: any, surfaces: any, layers: any): any;
}
import { SurfaceGeometry } from "./surfacegeometry.js";
| cchudzicki/mathbox | build/esm/render/geometry/screengeometry.d.ts | TypeScript | mit | 348 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { SurfaceGeometry } from "./surfacegeometry.js";
import { Vector4 } from "three/src/math/Vector4.js";
/*
Grid Surface in normalized screen space
+----+----+----+----+
| | | | |
+----+----+----+----+
| | | | |
+----+----+----+----+
+----+----+----+----+
| | | | |
+----+----+----+----+
| | | | |
+----+----+----+----+
*/
export class ScreenGeometry extends SurfaceGeometry {
constructor(options) {
options.width = Math.max(2, +options.width != null ? +options.width : 2);
options.height = Math.max(2, +options.height != null ? +options.height : 2);
super(options, false);
if (this.uniforms == null) {
this.uniforms = {};
}
this.uniforms.geometryScale = {
type: "v4",
value: new Vector4(),
};
this.cover();
this.construct(options);
}
cover(scaleX, scaleY, scaleZ, scaleW) {
if (scaleX == null) {
scaleX = 1;
}
this.scaleX = scaleX;
if (scaleY == null) {
scaleY = 1;
}
this.scaleY = scaleY;
if (scaleZ == null) {
scaleZ = 1;
}
this.scaleZ = scaleZ;
if (scaleW == null) {
scaleW = 1;
}
this.scaleW = scaleW;
}
clip(width, height, surfaces, layers) {
if (width == null) {
({ width } = this);
}
if (height == null) {
({ height } = this);
}
if (surfaces == null) {
({ surfaces } = this);
}
if (layers == null) {
({ layers } = this);
}
super.clip(width, height, surfaces, layers);
const invert = (x) => 1 / Math.max(1, x - 1);
return this.uniforms.geometryScale.value.set(invert(width) * this.scaleX, invert(height) * this.scaleY, invert(surfaces) * this.scaleZ, invert(layers) * this.scaleW);
}
}
| cchudzicki/mathbox | build/esm/render/geometry/screengeometry.js | JavaScript | mit | 2,318 |
export class SpriteGeometry extends ClipGeometry {
constructor(options: any);
items: number;
width: number;
height: number;
depth: number;
clip(width: any, height: any, depth: any, items: any): void;
}
import { ClipGeometry } from "./clipgeometry.js";
| cchudzicki/mathbox | build/esm/render/geometry/spritegeometry.d.ts | TypeScript | mit | 276 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS202: Simplify dynamic range loops
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { BufferAttribute } from "three/src/core/BufferAttribute.js";
import { ClipGeometry } from "./clipgeometry.js";
/*
Render points as quads
+----+ +----+ +----+ +----+
| | | | | | | |
+----+ +----+ +----+ +----+
+----+ +----+ +----+ +----+
| | | | | | | |
+----+ +----+ +----+ +----+
+----+ +----+ +----+ +----+
| | | | | | | |
+----+ +----+ +----+ +----+
*/
export class SpriteGeometry extends ClipGeometry {
constructor(options) {
let depth, height, items, width;
super(options);
this._clipUniforms();
this.items = items = +options.items || 2;
this.width = width = +options.width || 1;
this.height = height = +options.height || 1;
this.depth = depth = +options.depth || 1;
const samples = items * width * height * depth;
const points = samples * 4;
const triangles = samples * 2;
this.setIndex(new BufferAttribute(new Uint32Array(triangles * 3), 1));
this.setAttribute("position4", new BufferAttribute(new Float32Array(points * 4), 4));
this.setAttribute("sprite", new BufferAttribute(new Float32Array(points * 2), 2));
const index = this._emitter("index");
const position = this._emitter("position4");
const sprite = this._emitter("sprite");
const quad = [
[-1, -1],
[-1, 1],
[1, -1],
[1, 1],
];
let base = 0;
for (let i = 0, end = samples, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) {
index(base);
index(base + 1);
index(base + 2);
index(base + 1);
index(base + 2);
index(base + 3);
base += 4;
}
for (let z = 0, end1 = depth, asc1 = 0 <= end1; asc1 ? z < end1 : z > end1; asc1 ? z++ : z--) {
for (let y = 0, end2 = height, asc2 = 0 <= end2; asc2 ? y < end2 : y > end2; asc2 ? y++ : y--) {
for (let x = 0, end3 = width, asc3 = 0 <= end3; asc3 ? x < end3 : x > end3; asc3 ? x++ : x--) {
for (let l = 0, end4 = items, asc4 = 0 <= end4; asc4 ? l < end4 : l > end4; asc4 ? l++ : l--) {
for (const v of Array.from(quad)) {
position(x, y, z, l);
sprite(v[0], v[1]);
}
}
}
}
}
this._finalize();
this.clip();
}
clip(width, height, depth, items) {
if (width == null) {
({ width } = this);
}
if (height == null) {
({ height } = this);
}
if (depth == null) {
({ depth } = this);
}
if (items == null) {
({ items } = this);
}
this._clipGeometry(width, height, depth, items);
return this._clipOffsets(6, width, height, depth, items, this.width, this.height, this.depth, this.items);
}
}
| cchudzicki/mathbox | build/esm/render/geometry/spritegeometry.js | JavaScript | mit | 3,484 |
export class StripGeometry extends ClipGeometry {
constructor(options: any);
items: number;
width: number;
height: number;
depth: number;
sides: number;
clip(width: any, height: any, depth: any, items: any): void;
}
import { ClipGeometry } from "./clipgeometry.js";
| cchudzicki/mathbox | build/esm/render/geometry/stripgeometry.d.ts | TypeScript | mit | 294 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS202: Simplify dynamic range loops
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { BufferAttribute } from "three/src/core/BufferAttribute.js";
import { ClipGeometry } from "./clipgeometry.js";
/*
Triangle strips arranged in items, columns and rows
+--+--+--+ +--+--+--+ +--+--+--+ +--+--+--+
| /| /| / | /| /| / | /| /| / | /| /| /
+--+--+/ +--+--+/ +--+--+/ +--+--+/
+--+--+--+ +--+--+--+ +--+--+--+ +--+--+--+
| /| /| / | /| /| / | /| /| / | /| /| /
+--+--+/ +--+--+/ +--+--+/ +--+--+/
+--+--+--+ +--+--+--+ +--+--+--+ +--+--+--+
| /| /| / | /| /| / | /| /| / | /| /| /
+--+--+/ +--+--+/ +--+--+/ +--+--+/
*/
export class StripGeometry extends ClipGeometry {
constructor(options) {
let depth, height, items, sides, width;
super(options);
this._clipUniforms();
this.items = items = +options.items || 2;
this.width = width = +options.width || 1;
this.height = height = +options.height || 1;
this.depth = depth = +options.depth || 1;
this.sides = sides = Math.max(0, items - 2);
const samples = width * height * depth;
const points = items * samples;
const triangles = sides * samples;
this.setIndex(new BufferAttribute(new Uint32Array(triangles * 3), 1));
this.setAttribute("position4", new BufferAttribute(new Float32Array(points * 4), 4));
this.setAttribute("strip", new BufferAttribute(new Float32Array(points * 3), 3));
const index = this._emitter("index");
const position = this._emitter("position4");
const strip = this._emitter("strip");
let base = 0;
for (let i = 0, end = samples, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) {
let o = base;
for (let j = 0, end1 = sides, asc1 = 0 <= end1; asc1 ? j < end1 : j > end1; asc1 ? j++ : j--) {
if (j & 1) {
index(o + 1);
index(o);
index(o + 2);
}
else {
index(o);
index(o + 1);
index(o + 2);
}
o++;
}
base += items;
}
const last = items - 1;
for (let z = 0, end2 = depth, asc2 = 0 <= end2; asc2 ? z < end2 : z > end2; asc2 ? z++ : z--) {
for (let y = 0, end3 = height, asc3 = 0 <= end3; asc3 ? y < end3 : y > end3; asc3 ? y++ : y--) {
for (let x = 0, end4 = width, asc4 = 0 <= end4; asc4 ? x < end4 : x > end4; asc4 ? x++ : x--) {
let f = 1;
position(x, y, z, 0);
strip(1, 2, f);
for (let l = 1, end5 = last, asc5 = 1 <= end5; asc5 ? l < end5 : l > end5; asc5 ? l++ : l--) {
position(x, y, z, l);
strip(l - 1, l + 1, (f = -f));
}
position(x, y, z, last);
strip(last - 2, last - 1, -f);
}
}
}
this._finalize();
this.clip();
}
clip(width, height, depth, items) {
if (width == null) {
({ width } = this);
}
if (height == null) {
({ height } = this);
}
if (depth == null) {
({ depth } = this);
}
if (items == null) {
({ items } = this);
}
const sides = Math.max(0, items - 2);
this._clipGeometry(width, height, depth, items);
return this._clipOffsets(3, width, height, depth, sides, this.width, this.height, this.depth, this.sides);
}
}
| cchudzicki/mathbox | build/esm/render/geometry/stripgeometry.js | JavaScript | mit | 4,025 |
export class SurfaceGeometry extends ClipGeometry {
constructor(options: any, build: any);
construct(options: any): void;
closedX: any;
closedY: any;
width: number | undefined;
height: number | undefined;
surfaces: number | undefined;
layers: number | undefined;
segmentsX: number | undefined;
segmentsY: number | undefined;
clip(width: any, height: any, surfaces: any, layers: any): void;
map(width: any, height: any, surfaces: any, layers: any): any;
}
import { ClipGeometry } from "./clipgeometry.js";
| cchudzicki/mathbox | build/esm/render/geometry/surfacegeometry.d.ts | TypeScript | mit | 553 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS202: Simplify dynamic range loops
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { BufferAttribute } from "three/src/core/BufferAttribute.js";
import { ClipGeometry } from "./clipgeometry.js";
/*
Grid Surface
+----+----+----+----+
| | | | |
+----+----+----+----+
| | | | |
+----+----+----+----+
+----+----+----+----+
| | | | |
+----+----+----+----+
| | | | |
+----+----+----+----+
*/
export class SurfaceGeometry extends ClipGeometry {
constructor(options, build) {
if (build == null) {
build = true;
}
super();
// TODO not great... but use this pattern, maybe, to defer construction if
// options are missing, NOT the boolean.
if (build) {
this.construct(options);
}
}
construct(options) {
let closedX, closedY, height, layers, segmentsX, segmentsY, surfaces, width;
this._clipUniforms();
this.closedX = closedX = options.closedX || false;
this.closedY = closedY = options.closedY || false;
this.width = width = (+options.width || 2) + (closedX ? 1 : 0);
this.height = height = (+options.height || 2) + (closedY ? 1 : 0);
this.surfaces = surfaces = +options.surfaces || 1;
this.layers = layers = +options.layers || 1;
const wrapX = width - (closedX ? 1 : 0);
const wrapY = height - (closedY ? 1 : 0);
this.segmentsX = segmentsX = Math.max(0, width - 1);
this.segmentsY = segmentsY = Math.max(0, height - 1);
const points = width * height * surfaces * layers;
const quads = segmentsX * segmentsY * surfaces * layers;
const triangles = quads * 2;
this.setIndex(new BufferAttribute(new Uint32Array(triangles * 3), 1));
this.setAttribute("position4", new BufferAttribute(new Float32Array(points * 4), 4));
this.setAttribute("surface", new BufferAttribute(new Float32Array(points * 2), 2));
const index = this._emitter("index");
const position = this._emitter("position4");
const surface = this._emitter("surface");
let base = 0;
for (let i = 0, end = surfaces * layers, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) {
for (let j = 0, end1 = segmentsY, asc1 = 0 <= end1; asc1 ? j < end1 : j > end1; asc1 ? j++ : j--) {
for (let k = 0, end2 = segmentsX, asc2 = 0 <= end2; asc2 ? k < end2 : k > end2; asc2 ? k++ : k--) {
index(base);
index(base + 1);
index(base + width);
index(base + width);
index(base + 1);
index(base + width + 1);
base++;
}
base++;
}
base += width;
}
const edgerX = closedX
? () => 0
: function (x) {
if (x === 0) {
return -1;
}
else if (x === segmentsX) {
return 1;
}
else {
return 0;
}
};
const edgerY = closedY
? () => 0
: function (y) {
if (y === 0) {
return -1;
}
else if (y === segmentsY) {
return 1;
}
else {
return 0;
}
};
for (let l = 0, end3 = layers, asc3 = 0 <= end3; asc3 ? l < end3 : l > end3; asc3 ? l++ : l--) {
for (let z = 0, end4 = surfaces, asc4 = 0 <= end4; asc4 ? z < end4 : z > end4; asc4 ? z++ : z--) {
for (let i1 = 0, y = i1, end5 = height, asc5 = 0 <= end5; asc5 ? i1 < end5 : i1 > end5; asc5 ? i1++ : i1--, y = i1) {
if (closedY) {
y = y % wrapY;
}
const edgeY = edgerY(y);
for (let j1 = 0, x = j1, end6 = width, asc6 = 0 <= end6; asc6 ? j1 < end6 : j1 > end6; asc6 ? j1++ : j1--, x = j1) {
if (closedX) {
x = x % wrapX;
}
const edgeX = edgerX(x);
position(x, y, z, l);
surface(edgeX, edgeY);
}
}
}
}
this._finalize();
this.clip();
}
clip(width, height, surfaces, layers) {
if (width == null) {
({ width } = this);
}
if (height == null) {
({ height } = this);
}
if (surfaces == null) {
({ surfaces } = this);
}
if (layers == null) {
({ layers } = this);
}
const segmentsX = Math.max(0, width - 1);
const segmentsY = Math.max(0, height - 1);
this._clipGeometry(width, height, surfaces, layers);
return this._clipOffsets(6, segmentsX, segmentsY, surfaces, layers, this.segmentsX, this.segmentsY, this.surfaces, this.layers);
}
map(width, height, surfaces, layers) {
if (width == null) {
({ width } = this);
}
if (height == null) {
({ height } = this);
}
if (surfaces == null) {
({ surfaces } = this);
}
if (layers == null) {
({ layers } = this);
}
return this._clipMap(width, height, surfaces, layers);
}
}
| cchudzicki/mathbox | build/esm/render/geometry/surfacegeometry.js | JavaScript | mit | 5,886 |
export * from "./scene.js";
export * from "./scene.js";
export * from "./classes.js";
export { RenderFactory as Factory } from "./factory.js";
| cchudzicki/mathbox | build/esm/render/index.d.ts | TypeScript | mit | 143 |
export * from "./scene.js";
export { RenderFactory as Factory } from "./factory.js";
export * from "./scene.js";
export * from "./classes.js";
| cchudzicki/mathbox | build/esm/render/index.js | JavaScript | mit | 143 |
export class Arrow extends Base {
geometry: ArrowGeometry;
material: any;
renders: any[];
}
import { Base } from "./base.js";
import { ArrowGeometry } from "../geometry/arrowgeometry.js";
| cchudzicki/mathbox | build/esm/render/meshes/arrow.d.ts | TypeScript | mit | 200 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { ArrowGeometry } from "../geometry/arrowgeometry.js";
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { Mesh } from "three/src/objects/Mesh.js";
export class Arrow extends Base {
constructor(renderer, shaders, options) {
let f;
super(renderer, shaders, options);
let { uniforms } = options;
const { material, position, color, mask, map, combine, stpq, linear } = options;
if (uniforms == null) {
uniforms = {};
}
const hasStyle = uniforms.styleColor != null;
this.geometry = new ArrowGeometry({
sides: options.sides,
samples: options.samples,
strips: options.strips,
ribbons: options.ribbons,
layers: options.layers,
anchor: options.anchor,
flip: options.flip,
});
this._adopt(uniforms);
this._adopt(this.geometry.uniforms);
const factory = shaders.material();
const v = factory.vertex;
v.pipe(this._vertexColor(color, mask));
v.require(this._vertexPosition(position, material, map, 1, stpq));
v.pipe("arrow.position", this.uniforms);
v.pipe("project.position", this.uniforms);
factory.fragment = f = this._fragmentColor(hasStyle, material, color, mask, map, 1, stpq, combine, linear);
f.pipe("fragment.color", this.uniforms);
const opts = factory.link({
side: DoubleSide,
});
this.material = this._material(opts);
const object = new Mesh(this.geometry, this.material);
object.frustumCulled = false;
object.matrixAutoUpdate = false;
object.userData = opts;
this._raw(object);
this.renders = [object];
}
dispose() {
this.geometry.dispose();
this.material.dispose();
this.renders = this.geometry = this.material = null;
return super.dispose();
}
}
| cchudzicki/mathbox | build/esm/render/meshes/arrow.js | JavaScript | mit | 2,339 |
export class Base extends Renderable {
constructor(renderer: any, shaders: any, options: any);
zUnits: any;
raw(): null;
depth(write: any, test: any): null;
polygonOffset(factor: any, units: any): null;
show(transparent: any, blending: any, order: any): null[];
hide(): null;
_material(options: any): any;
_raw(object: any): void;
_depth(object: any, write: any, test: any): any;
_polygonOffset(object: any, factor: any, units: any): any;
_show(object: any, transparent: any, blending: any, order: any): null;
_hide(object: any): boolean;
_vertexColor(color: any, mask: any): any;
_vertexPosition(position: any, material: any, map: any, channels: any, stpq: any): any;
_fragmentColor(hasStyle: any, material: any, color: any, mask: any, map: any, channels: any, stpq: any, combine: any, linear: any): any;
}
import { Renderable } from "../renderable.js";
| cchudzicki/mathbox | build/esm/render/meshes/base.d.ts | TypeScript | mit | 919 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import * as UGLSL from "../../util/glsl.js";
import { RawShaderMaterial } from "three/src/materials/RawShaderMaterial.js";
import { Renderable } from "../renderable.js";
export class Base extends Renderable {
constructor(renderer, shaders, options) {
super(renderer, shaders, options);
this.zUnits = options.zUnits != null ? options.zUnits : 0;
}
raw() {
for (const object of Array.from(this.renders)) {
this._raw(object);
}
return null;
}
depth(write, test) {
for (const object of Array.from(this.renders)) {
this._depth(object, write, test);
}
return null;
}
polygonOffset(factor, units) {
for (const object of Array.from(this.renders)) {
this._polygonOffset(object, factor, units);
}
return null;
}
show(transparent, blending, order) {
return Array.from(this.renders).map((object) => this._show(object, transparent, blending, order));
}
hide() {
for (const object of Array.from(this.renders)) {
this._hide(object);
}
return null;
}
_material(options) {
const precision = this.renderer.capabilities.precision;
const vertexPrefix = `\
precision ${precision} float;
precision ${precision} int;
uniform mat4 modelMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
uniform mat4 viewMatrix;
uniform mat3 normalMatrix;
uniform vec3 cameraPosition;\
`;
const fragmentPrefix = `\
precision ${precision} float;
precision ${precision} int;
uniform mat4 viewMatrix;
uniform vec3 cameraPosition;\
`;
const shaderOptions = {};
Object.assign(shaderOptions, options);
delete shaderOptions.attributes;
delete shaderOptions.varyings;
delete shaderOptions.inspect;
delete shaderOptions.vertexGraph;
delete shaderOptions.fragmentGraph;
const material = new RawShaderMaterial(shaderOptions);
["vertexGraph", "fragmentGraph", "inspect"].forEach((key) => (material[key] = options[key]));
material.vertexShader = [vertexPrefix, material.vertexShader].join("\n");
material.fragmentShader = [fragmentPrefix, material.fragmentShader].join("\n");
return material;
}
_raw(object) {
object.rotationAutoUpdate = false;
object.frustumCulled = false;
object.matrixAutoUpdate = false;
object.material.defaultAttributeValues = undefined;
}
_depth(object, write, test) {
const m = object.material;
m.depthWrite = write;
return (m.depthTest = test);
}
_polygonOffset(object, factor, units) {
units -= this.zUnits;
const enabled = units !== 0;
const m = object.material;
m.polygonOffset = enabled;
if (enabled) {
m.polygonOffsetFactor = factor;
return (m.polygonOffsetUnits = units);
}
}
_show(object, transparent, blending, order) {
// Force transparent to true to ensure all renderables drawn in order
transparent = true;
const m = object.material;
object.renderOrder = -order;
object.visible = true;
m.transparent = transparent;
m.blending = blending;
return null;
}
_hide(object) {
return (object.visible = false);
}
_vertexColor(color, mask) {
if (!color && !mask) {
return;
}
const v = this.shaders.shader();
if (color) {
v.require(color);
v.pipe("mesh.vertex.color", this.uniforms);
}
if (mask) {
v.require(mask);
v.pipe("mesh.vertex.mask", this.uniforms);
}
return v;
}
_vertexPosition(position, material, map, channels, stpq) {
let defs;
const v = this.shaders.shader();
if (map || (material && material !== true)) {
defs = {};
if (channels > 0 || stpq) {
defs.POSITION_MAP = "";
}
if (channels > 0) {
defs[["POSITION_U", "POSITION_UV", "POSITION_UVW", "POSITION_UVWO"][channels - 1]] = "";
}
if (stpq) {
defs.POSITION_STPQ = "";
}
}
v.require(position);
return v.pipe("mesh.vertex.position", this.uniforms, defs);
}
_fragmentColor(hasStyle, material, color, mask, map, channels, stpq, combine, linear) {
const f = this.shaders.shader();
// metacode is terrible
let join = false;
let gamma = false;
const defs = {};
if (channels > 0) {
defs[["POSITION_U", "POSITION_UV", "POSITION_UVW", "POSITION_UVWO"][channels - 1]] = "";
}
if (stpq) {
defs.POSITION_STPQ = "";
}
if (hasStyle) {
f.pipe("style.color", this.uniforms);
join = true;
if (color || map || material) {
if (!linear || color) {
f.pipe("mesh.gamma.in");
}
gamma = true;
}
}
if (color) {
f.isolate();
f.pipe("mesh.fragment.color", this.uniforms);
if (!linear || join) {
f.pipe("mesh.gamma.in");
}
f.end();
if (join) {
f.pipe(UGLSL.binaryOperator("vec4", "*"));
}
if (linear && join) {
f.pipe("mesh.gamma.out");
}
join = true;
gamma = true;
}
if (map) {
if (!join && combine) {
f.pipe(UGLSL.constant("vec4", "vec4(1.0)"));
}
f.isolate();
f.require(map);
f.pipe("mesh.fragment.map", this.uniforms, defs);
if (!linear) {
f.pipe("mesh.gamma.in");
}
f.end();
if (combine) {
f.pipe(combine);
}
else {
if (join) {
f.pipe(UGLSL.binaryOperator("vec4", "*"));
}
}
join = true;
gamma = true;
}
if (material) {
if (!join) {
f.pipe(UGLSL.constant("vec4", "vec4(1.0)"));
}
if (material === true) {
f.pipe("mesh.fragment.shaded", this.uniforms);
}
else {
f.require(material);
f.pipe("mesh.fragment.material", this.uniforms, defs);
}
gamma = true;
}
if (gamma && !linear) {
f.pipe("mesh.gamma.out");
}
if (mask) {
f.pipe("mesh.fragment.mask", this.uniforms);
if (join) {
f.pipe(UGLSL.binaryOperator("vec4", "*"));
}
}
return f;
}
}
| cchudzicki/mathbox | build/esm/render/meshes/base.js | JavaScript | mit | 7,377 |
export class Debug extends Base {
geometry: any;
material: any;
objects: any[];
}
import { Base } from "./base.js";
| cchudzicki/mathbox | build/esm/render/meshes/debug.d.ts | TypeScript | mit | 128 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { Mesh } from "three/src/objects/Mesh.js";
import { MeshBasicMaterial } from "three/src/materials/MeshBasicMaterial.js";
import { PlaneGeometry } from "three/src/geometries/PlaneGeometry.js";
export class Debug extends Base {
constructor(renderer, shaders, options) {
super(renderer, shaders, options);
this.geometry = new PlaneGeometry(1, 1);
this.material = new MeshBasicMaterial({ map: options.map });
this.material.side = DoubleSide;
const object = new Mesh(this.geometry, this.material);
object.position.x += options.x || 0;
object.position.y += options.y || 0;
object.frustumCulled = false;
object.scale.set(2, 2, 2);
object.__debug = true;
this.objects = [object];
}
dispose() {
this.geometry.dispose();
this.material.dispose();
this.objects = this.geometry = this.material = null;
return super.dispose();
}
}
| cchudzicki/mathbox | build/esm/render/meshes/debug.js | JavaScript | mit | 1,353 |
export class Face extends Base {
geometry: FaceGeometry;
material: any;
renders: any[];
}
import { Base } from "./base.js";
import { FaceGeometry } from "../geometry/facegeometry.js";
| cchudzicki/mathbox | build/esm/render/meshes/face.d.ts | TypeScript | mit | 196 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { FaceGeometry } from "../geometry/facegeometry.js";
import { Mesh } from "three/src/objects/Mesh.js";
export class Face extends Base {
constructor(renderer, shaders, options) {
let f;
super(renderer, shaders, options);
let { uniforms, material } = options;
const { position, color, mask, map, combine, stpq, linear } = options;
if (uniforms == null) {
uniforms = {};
}
if (material == null) {
material = true;
}
const hasStyle = uniforms.styleColor != null;
this.geometry = new FaceGeometry({
items: options.items,
width: options.width,
height: options.height,
depth: options.depth,
});
this._adopt(uniforms);
this._adopt(this.geometry.uniforms);
const factory = shaders.material();
const v = factory.vertex;
v.pipe(this._vertexColor(color, mask));
v.require(this._vertexPosition(position, material, map, 2, stpq));
if (!material) {
v.pipe("face.position", this.uniforms);
}
if (material) {
v.pipe("face.position.normal", this.uniforms);
}
v.pipe("project.position", this.uniforms);
factory.fragment = f = this._fragmentColor(hasStyle, material, color, mask, map, 2, stpq, combine, linear);
f.pipe("fragment.color", this.uniforms);
const opts = factory.link({
side: DoubleSide,
});
this.material = this._material(opts);
const object = new Mesh(this.geometry, this.material);
object.userData = opts;
this._raw(object);
this.renders = [object];
}
dispose() {
this.geometry.dispose();
this.material.dispose();
this.renders = this.geometry = this.material = null;
return super.dispose();
}
}
| cchudzicki/mathbox | build/esm/render/meshes/face.js | JavaScript | mit | 2,346 |
export class Line extends Base {
geometry: LineGeometry;
material: any;
renders: any[];
}
import { Base } from "./base.js";
import { LineGeometry } from "../geometry/linegeometry.js";
| cchudzicki/mathbox | build/esm/render/meshes/line.d.ts | TypeScript | mit | 196 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS104: Avoid inline assignments
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { LineGeometry } from "../geometry/linegeometry.js";
import { Mesh } from "three/src/objects/Mesh.js";
export class Line extends Base {
constructor(renderer, shaders, options) {
let left;
super(renderer, shaders, options);
let { uniforms, stroke, join } = options;
const { material, position, color, mask, map, combine, stpq, linear, clip, proximity, } = options;
if (uniforms == null) {
uniforms = {};
}
stroke = [null, "dotted", "dashed"][stroke];
const hasStyle = uniforms.styleColor != null;
// Line join
join = (left = ["miter", "round", "bevel"][join]) != null ? left : "miter";
const detail = { miter: 1, round: 4, bevel: 2 }[join];
this.geometry = new LineGeometry({
samples: options.samples,
strips: options.strips,
ribbons: options.ribbons,
layers: options.layers,
anchor: options.anchor,
closed: options.closed,
detail,
});
this._adopt(uniforms);
this._adopt(this.geometry.uniforms);
const factory = shaders.material();
const defs = {};
if (stroke) {
defs.LINE_STROKE = "";
}
if (clip) {
defs.LINE_CLIP = "";
}
if (proximity != null) {
defs.LINE_PROXIMITY = "";
}
defs["LINE_JOIN_" + join.toUpperCase()] = "";
if (detail > 1) {
defs["LINE_JOIN_DETAIL"] = detail;
}
const v = factory.vertex;
v.pipe(this._vertexColor(color, mask));
v.require(this._vertexPosition(position, material, map, 2, stpq));
v.pipe("line.position", this.uniforms, defs);
v.pipe("project.position", this.uniforms);
const f = factory.fragment;
if (stroke) {
f.pipe(`fragment.clip.${stroke}`, this.uniforms);
}
if (clip) {
f.pipe("fragment.clip.ends", this.uniforms);
}
if (proximity != null) {
f.pipe("fragment.clip.proximity", this.uniforms);
}
f.pipe(this._fragmentColor(hasStyle, material, color, mask, map, 2, stpq, combine, linear));
f.pipe("fragment.color", this.uniforms);
const opts = factory.link({
side: DoubleSide,
});
this.material = this._material(opts);
const object = new Mesh(this.geometry, this.material);
object.userData = opts;
this._raw(object);
this.renders = [object];
}
dispose() {
this.geometry.dispose();
this.material.dispose();
this.renders = this.geometry = this.material = null;
return super.dispose();
}
}
| cchudzicki/mathbox | build/esm/render/meshes/line.js | JavaScript | mit | 3,222 |
export class MemoScreen extends Screen {
memo: any;
uniforms: {
remapUVScale: {
type: string;
value: any;
};
remapModulus: {
type: string;
value: any;
};
remapModulusInv: {
type: string;
value: any;
};
remapSTPQScale: {
type: string;
value: any;
};
};
cover(width: any, height: any, depth: any, items: any): void;
}
import { Screen } from "./screen.js";
| cchudzicki/mathbox | build/esm/render/meshes/memoscreen.d.ts | TypeScript | mit | 530 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Screen } from "./screen.js";
import { Vector2 } from "three/src/math/Vector2.js";
import { Vector4 } from "three/src/math/Vector4.js";
export class MemoScreen extends Screen {
constructor(renderer, shaders, options) {
const { items, width, height, depth, stpq } = options;
const inv = (x) => 1 / Math.max(1, x);
const inv1 = (x) => 1 / Math.max(1, x - 1);
const uniforms = {
remapUVScale: {
type: "v2",
value: new Vector2(items * width, height * depth),
},
remapModulus: {
type: "v2",
value: new Vector2(items, height),
},
remapModulusInv: {
type: "v2",
value: new Vector2(inv(items), inv(height)),
},
remapSTPQScale: {
type: "v4",
value: new Vector4(inv1(width), inv1(height), inv1(depth), inv1(items)),
},
};
const map = shaders.shader();
map.pipe("screen.map.xyzw", uniforms);
if (options.map != null) {
// Need artifical STPQs because the screen is not the real geometry
if (stpq) {
map.pipe("screen.map.stpq", uniforms);
}
map.pipe(options.map);
}
super(renderer, shaders, { map, linear: true });
this.memo = options;
this.uniforms = uniforms;
for (const object of Array.from(this.renders)) {
object.transparent = false;
}
}
cover(width, height, depth, items) {
if (width == null) {
({ width } = this.memo);
}
if (height == null) {
({ height } = this.memo);
}
if (depth == null) {
({ depth } = this.memo);
}
if (items == null) {
({ items } = this.memo);
}
const inv1 = (x) => 1 / Math.max(1, x - 1);
this.uniforms.remapSTPQScale.value.set(inv1(width), inv1(height), inv1(depth), inv1(items));
const x = width / this.memo.width;
let y = depth / this.memo.depth;
if (this.memo.depth === 1) {
y = height / this.memo.height;
}
return this.geometry.cover(x, y);
}
}
| cchudzicki/mathbox | build/esm/render/meshes/memoscreen.js | JavaScript | mit | 2,689 |
export class Point extends Base {
geometry: SpriteGeometry;
fillMaterial: any;
edgeMaterial: any;
fillObject: any;
edgeObject: any;
renders: any[];
show(transparent: any, blending: any, order: any, depth: any): null;
}
import { Base } from "./base.js";
import { SpriteGeometry } from "../geometry/spritegeometry.js";
| cchudzicki/mathbox | build/esm/render/meshes/point.d.ts | TypeScript | mit | 345 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS104: Avoid inline assignments
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { Mesh } from "three/src/objects/Mesh.js";
import { SpriteGeometry } from "../geometry/spritegeometry.js";
export class Point extends Base {
constructor(renderer, shaders, options) {
let f, left;
super(renderer, shaders, options);
let { uniforms, shape, fill } = options;
const { material, position, color, size, mask, map, combine, linear, optical, stpq, } = options;
if (uniforms == null) {
uniforms = {};
}
shape = +shape != null ? +shape : 0;
if (fill == null) {
fill = true;
}
const hasStyle = uniforms.styleColor != null;
const shapes = [
"circle",
"square",
"diamond",
"up",
"down",
"left",
"right",
];
const passes = [
"circle",
"generic",
"generic",
"generic",
"generic",
"generic",
"generic",
];
const scales = [1.2, 1, 1.414, 1.16, 1.16, 1.16, 1.16];
const pass = passes[shape] != null ? passes[shape] : passes[0];
const _shape = shapes[shape] != null ? shapes[shape] : shapes[0];
const _scale = (left = optical && scales[shape]) != null ? left : 1;
const alpha = fill ? pass : `${pass}.hollow`;
this.geometry = new SpriteGeometry({
items: options.items,
width: options.width,
height: options.height,
depth: options.depth,
});
this._adopt(uniforms);
this._adopt(this.geometry.uniforms);
const defines = { POINT_SHAPE_SCALE: +(_scale + 0.00001) };
// Shared vertex shader
const factory = shaders.material();
const v = factory.vertex;
v.pipe(this._vertexColor(color, mask));
// Point sizing
if (size) {
v.isolate();
v.require(size);
v.require("point.size.varying", this.uniforms);
v.end();
}
else {
v.require("point.size.uniform", this.uniforms);
}
v.require(this._vertexPosition(position, material, map, 2, stpq));
v.pipe("point.position", this.uniforms, defines);
v.pipe("project.position", this.uniforms);
// Shared fragment shader
factory.fragment = f = this._fragmentColor(hasStyle, material, color, mask, map, 2, stpq, combine, linear);
// Split fragment into edge and fill pass for better z layering
const edgeFactory = shaders.material();
edgeFactory.vertex.pipe(v);
f = edgeFactory.fragment.pipe(factory.fragment);
f.require(`point.mask.${_shape}`, this.uniforms);
f.require(`point.alpha.${alpha}`, this.uniforms);
f.pipe("point.edge", this.uniforms);
const fillFactory = shaders.material();
fillFactory.vertex.pipe(v);
f = fillFactory.fragment.pipe(factory.fragment);
f.require(`point.mask.${_shape}`, this.uniforms);
f.require(`point.alpha.${alpha}`, this.uniforms);
f.pipe("point.fill", this.uniforms);
const fillOpts = fillFactory.link({
side: DoubleSide,
});
this.fillMaterial = this._material(fillOpts);
const edgeOpts = edgeFactory.link({
side: DoubleSide,
});
this.edgeMaterial = this._material(edgeOpts);
this.fillObject = new Mesh(this.geometry, this.fillMaterial);
this.edgeObject = new Mesh(this.geometry, this.edgeMaterial);
this._raw(this.fillObject);
this.fillObject.userData = fillOpts;
this._raw(this.edgeObject);
this.edgeObject.userData = edgeOpts;
this.renders = [this.fillObject, this.edgeObject];
}
show(transparent, blending, order, depth) {
this._show(this.edgeObject, true, blending, order, depth);
return this._show(this.fillObject, transparent, blending, order, depth);
}
dispose() {
this.geometry.dispose();
this.edgeMaterial.dispose();
this.fillMaterial.dispose();
this.renders =
this.edgeObject =
this.fillObject =
this.geometry =
this.edgeMaterial =
this.fillMaterial =
null;
return super.dispose();
}
}
| cchudzicki/mathbox | build/esm/render/meshes/point.js | JavaScript | mit | 4,889 |
export class Screen extends Base {
geometry: ScreenGeometry;
material: any;
renders: any[];
}
import { Base } from "./base.js";
import { ScreenGeometry } from "../geometry/screengeometry.js";
| cchudzicki/mathbox | build/esm/render/meshes/screen.d.ts | TypeScript | mit | 204 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { Mesh } from "three/src/objects/Mesh.js";
import { ScreenGeometry } from "../geometry/screengeometry.js";
export class Screen extends Base {
constructor(renderer, shaders, options) {
let f;
super(renderer, shaders, options);
let { uniforms } = options;
const { map, combine, stpq, linear } = options;
if (uniforms == null) {
uniforms = {};
}
const hasStyle = uniforms.styleColor != null;
this.geometry = new ScreenGeometry({
width: options.width,
height: options.height,
});
this._adopt(uniforms);
this._adopt(this.geometry.uniforms);
const factory = shaders.material();
const v = factory.vertex;
v.pipe("raw.position.scale", this.uniforms);
v.fan();
v.pipe("stpq.xyzw.2d", this.uniforms);
v.next();
v.pipe("screen.position", this.uniforms);
v.join();
factory.fragment = f = this._fragmentColor(hasStyle, false, null, null, map, 2, stpq, combine, linear);
f.pipe("fragment.color", this.uniforms);
const opts = factory.link({
side: DoubleSide,
});
this.material = this._material(opts);
const object = new Mesh(this.geometry, this.material);
object.frustumCulled = false;
object.userData = opts;
this._raw(object);
this.renders = [object];
}
dispose() {
this.geometry.dispose();
this.material.dispose();
this.renders = this.geometry = this.material = null;
return super.dispose();
}
}
| cchudzicki/mathbox | build/esm/render/meshes/screen.js | JavaScript | mit | 2,065 |
export class Sprite extends Base {
geometry: SpriteGeometry;
fillMaterial: any;
edgeMaterial: any;
fillObject: any;
edgeObject: any;
renders: any[];
show(transparent: any, blending: any, order: any, depth: any): null;
nreders: any;
}
import { Base } from "./base.js";
import { SpriteGeometry } from "../geometry/spritegeometry.js";
| cchudzicki/mathbox | build/esm/render/meshes/sprite.d.ts | TypeScript | mit | 364 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { Mesh } from "three/src/objects/Mesh.js";
import { SpriteGeometry } from "../geometry/spritegeometry.js";
export class Sprite extends Base {
constructor(renderer, shaders, options) {
let f;
super(renderer, shaders, options);
let { uniforms } = options;
const { material, position, sprite, map, combine, linear, color, mask, stpq, } = options;
if (uniforms == null) {
uniforms = {};
}
const hasStyle = uniforms.styleColor != null;
this.geometry = new SpriteGeometry({
items: options.items,
width: options.width,
height: options.height,
depth: options.depth,
});
this._adopt(uniforms);
this._adopt(this.geometry.uniforms);
// Shared vertex shader
const factory = shaders.material();
const v = factory.vertex;
v.pipe(this._vertexColor(color, mask));
v.require(this._vertexPosition(position, material, map, 2, stpq));
v.require(sprite);
v.pipe("sprite.position", this.uniforms);
v.pipe("project.position", this.uniforms);
// Shared fragment shader
factory.fragment = f = this._fragmentColor(hasStyle, material, color, mask, map, 2, stpq, combine, linear);
// Split fragment into edge and fill pass for better z layering
const edgeFactory = shaders.material();
edgeFactory.vertex.pipe(v);
edgeFactory.fragment.pipe(f);
edgeFactory.fragment.pipe("fragment.transparent", this.uniforms);
const fillFactory = shaders.material();
fillFactory.vertex.pipe(v);
fillFactory.fragment.pipe(f);
fillFactory.fragment.pipe("fragment.solid", this.uniforms);
const fillOpts = fillFactory.link({
side: DoubleSide,
});
this.fillMaterial = this._material(fillOpts);
const edgeOpts = edgeFactory.link({
side: DoubleSide,
});
this.edgeMaterial = this._material(edgeOpts);
this.fillObject = new Mesh(this.geometry, this.fillMaterial);
this.edgeObject = new Mesh(this.geometry, this.edgeMaterial);
this._raw(this.fillObject);
this.fillObject.userData = fillOpts;
this._raw(this.edgeObject);
this.edgeObject.userData = edgeOpts;
this.renders = [this.fillObject, this.edgeObject];
}
show(transparent, blending, order, depth) {
this._show(this.edgeObject, true, blending, order, depth);
return this._show(this.fillObject, transparent, blending, order, depth);
}
dispose() {
this.geometry.dispose();
this.edgeMaterial.dispose();
this.fillMaterial.dispose();
this.nreders =
this.geometry =
this.edgeMaterial =
this.fillMaterial =
this.edgeObject =
this.fillObject =
null;
return super.dispose();
}
}
| cchudzicki/mathbox | build/esm/render/meshes/sprite.js | JavaScript | mit | 3,461 |
export class Strip extends Base {
geometry: StripGeometry;
material: any;
renders: any[];
}
import { Base } from "./base.js";
import { StripGeometry } from "../geometry/stripgeometry.js";
| cchudzicki/mathbox | build/esm/render/meshes/strip.d.ts | TypeScript | mit | 200 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { Mesh } from "three/src/objects/Mesh.js";
import { StripGeometry } from "../geometry/stripgeometry.js";
export class Strip extends Base {
constructor(renderer, shaders, options) {
let f;
super(renderer, shaders, options);
let { uniforms, material } = options;
const { position, color, mask, map, combine, linear, stpq } = options;
if (uniforms == null) {
uniforms = {};
}
if (material == null) {
material = true;
}
const hasStyle = uniforms.styleColor != null;
this.geometry = new StripGeometry({
items: options.items,
width: options.width,
height: options.height,
depth: options.depth,
});
this._adopt(uniforms);
this._adopt(this.geometry.uniforms);
const factory = shaders.material();
const v = factory.vertex;
v.pipe(this._vertexColor(color, mask));
v.require(this._vertexPosition(position, material, map, 2, stpq));
if (!material) {
v.pipe("mesh.position", this.uniforms);
}
if (material) {
v.pipe("strip.position.normal", this.uniforms);
}
v.pipe("project.position", this.uniforms);
factory.fragment = f = this._fragmentColor(hasStyle, material, color, mask, map, 2, stpq, combine, linear);
f.pipe("fragment.color", this.uniforms);
const opts = factory.link({
side: DoubleSide,
});
this.material = this._material(opts);
const object = new Mesh(this.geometry, this.material);
object.userData = opts;
this._raw(object);
this.renders = [object];
}
dispose() {
this.geometry.dispose();
this.material.dispose();
this.renders = this.geometry = this.material = null;
return super.dispose();
}
}
| cchudzicki/mathbox | build/esm/render/meshes/strip.js | JavaScript | mit | 2,351 |
export class Surface extends Base {
geometry: SurfaceGeometry;
material: any;
renders: any[];
}
import { Base } from "./base.js";
import { SurfaceGeometry } from "../geometry/surfacegeometry.js";
| cchudzicki/mathbox | build/esm/render/meshes/surface.d.ts | TypeScript | mit | 208 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Base } from "./base.js";
import { DoubleSide } from "three/src/constants.js";
import { Mesh } from "three/src/objects/Mesh.js";
import { SurfaceGeometry } from "../geometry/surfacegeometry.js";
export class Surface extends Base {
constructor(renderer, shaders, options) {
let defs, f;
super(renderer, shaders, options);
let { uniforms, material } = options;
const { position, color, mask, map, combine, linear, stpq, intUV } = options;
if (uniforms == null) {
uniforms = {};
}
if (material == null) {
material = true;
}
const hasStyle = uniforms.styleColor != null;
this.geometry = new SurfaceGeometry({
width: options.width,
height: options.height,
surfaces: options.surfaces,
layers: options.layers,
closedX: options.closedX,
closedY: options.closedY,
});
this._adopt(uniforms);
this._adopt(this.geometry.uniforms);
const factory = shaders.material();
const v = factory.vertex;
if (intUV) {
defs = { POSITION_UV_INT: "" };
}
v.pipe(this._vertexColor(color, mask));
v.require(this._vertexPosition(position, material, map, 2, stpq));
if (!material) {
v.pipe("surface.position", this.uniforms, defs);
}
if (material) {
v.pipe("surface.position.normal", this.uniforms, defs);
}
v.pipe("project.position", this.uniforms);
factory.fragment = f = this._fragmentColor(hasStyle, material, color, mask, map, 2, stpq, combine, linear);
f.pipe("fragment.color", this.uniforms);
const opts = factory.link({
side: DoubleSide,
});
this.material = this._material(opts);
const object = new Mesh(this.geometry, this.material);
object.userData = opts;
this._raw(object);
this.renders = [object];
}
dispose() {
this.geometry.dispose();
this.material.dispose();
this.renders = this.geometry = this.material = null;
return super.dispose();
}
}
| cchudzicki/mathbox | build/esm/render/meshes/surface.js | JavaScript | mit | 2,548 |
export class Renderable {
constructor(renderer: any, shaders: any);
renderer: any;
shaders: any;
gl: any;
uniforms: {};
dispose(): void;
_adopt(uniforms: any): void;
_set(uniforms: any): void;
}
| cchudzicki/mathbox | build/esm/render/renderable.d.ts | TypeScript | mit | 227 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
export class Renderable {
constructor(renderer, shaders) {
this.renderer = renderer;
this.shaders = shaders;
this.gl = this.renderer.getContext();
if (this.uniforms == null) {
this.uniforms = {};
}
}
dispose() {
this.uniforms = null;
}
_adopt(uniforms) {
for (const key in uniforms) {
const value = uniforms[key];
this.uniforms[key] = value;
}
}
_set(uniforms) {
for (const key in uniforms) {
const value = uniforms[key];
if (this.uniforms[key] != null) {
this.uniforms[key].value = value;
}
}
}
}
| cchudzicki/mathbox | build/esm/render/renderable.js | JavaScript | mit | 1,057 |
export class Scene extends Renderable {
constructor(renderer: any, shaders: any, options: any);
root: MathBox;
scene: any;
pending: any[];
async: number;
scratch: any;
camera: any;
inject(scene: any): any;
unject(): any;
add(object: any): any;
remove(object: any): any;
_add(object: any): any;
_remove(object: any): any;
dispose(): any;
warmup(n: any): number;
render(): any;
toJSON(): any;
}
import { Renderable } from "./renderable.js";
declare class MathBox {
rotationAutoUpdate: boolean;
frustumCulled: boolean;
matrixAutoUpdate: boolean;
}
export {};
| cchudzicki/mathbox | build/esm/render/scene.d.ts | TypeScript | mit | 636 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS202: Simplify dynamic range loops
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import { Object3D } from "three/src/core/Object3D.js";
import { PerspectiveCamera } from "three/src/cameras/PerspectiveCamera.js";
import { Renderable } from "./renderable.js";
import { Scene as ThreeScene } from "three/src/scenes/Scene.js";
import { WebGLRenderTarget } from "three/src/renderers/WebGLRenderTarget.js";
/*
All MathBox renderables sit inside this root, to keep things tidy.
*/
class MathBox extends Object3D {
constructor() {
super();
this.rotationAutoUpdate = false;
this.frustumCulled = false;
this.matrixAutoUpdate = false;
}
}
/*
Holds the root and binds to a THREE.Scene
Will hold objects and inject them a few at a time
to avoid long UI blocks.
Will render injected objects to a 1x1 scratch buffer to ensure availability
*/
export class Scene extends Renderable {
constructor(renderer, shaders, options) {
super(renderer, shaders, options);
this.root = new MathBox();
if ((options != null ? options.scene : undefined) != null) {
this.scene = options.scene;
}
if (this.scene == null) {
this.scene = new ThreeScene();
}
this.pending = [];
this.async = 0;
this.scratch = new WebGLRenderTarget(1, 1);
this.camera = new PerspectiveCamera();
}
inject(scene) {
if (scene != null) {
this.scene = scene;
}
return this.scene.add(this.root);
}
unject() {
return this.scene != null ? this.scene.remove(this.root) : undefined;
}
add(object) {
if (this.async) {
return this.pending.push(object);
}
else {
return this._add(object);
}
}
remove(object) {
this.pending = this.pending.filter((o) => o !== object);
if (object.parent != null) {
return this._remove(object);
}
}
_add(object) {
return this.root.add(object);
}
_remove(object) {
return this.root.remove(object);
}
dispose() {
if (this.root.parent != null) {
return this.unject();
}
}
warmup(n) {
return (this.async = +n || 0);
}
render() {
if (!this.pending.length) {
return;
}
const { children } = this.root;
// Insert up to @async children
const added = [];
for (let i = 0, end = this.async, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) {
const pending = this.pending.shift();
if (!pending) {
break;
}
// Insert new child
this._add(pending);
added.push(added);
}
// Remember current visibility
const visible = children.map(function (o) {
return o.visible;
});
// Force only this child visible
children.map((o) => (o.visible = !Array.from(added).includes(o)));
// Render and throw away
const currentTarget = this.renderer.getRenderTarget();
this.renderer.setRenderTarget(this.scratch);
this.renderer.render(this.scene, this.camera);
this.renderer.setRenderTarget(currentTarget);
// Restore visibility
return children.map((o, i) => (o.visible = visible[i]));
}
toJSON() {
return this.root.toJSON();
}
}
| cchudzicki/mathbox | build/esm/render/scene.js | JavaScript | mit | 3,825 |
export function Factory(snippets: any): any;
| cchudzicki/mathbox | build/esm/shaders/factory.d.ts | TypeScript | mit | 45 |
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
import * as ShaderGraph from "shadergraph";
export const Factory = function (snippets) {
function fetch(name) {
// Built-in library
const s = snippets[name];
if (s != null) {
return s;
}
// Load from <script> tags by ID
const ref = ["#", ".", ":", "["].includes(name[0]);
const sel = ref ? name : `#${name}`;
const element = document.querySelector(sel);
if (element != null && element.tagName === "SCRIPT") {
return element.textContent || element.innerText;
}
throw new Error(`Unknown shader \`${name}\``);
}
return ShaderGraph.load(fetch, { autoInspect: true });
};
| cchudzicki/mathbox | build/esm/shaders/factory.js | JavaScript | mit | 1,050 |
export default /* glsl */ `uniform float worldUnit;
uniform float lineDepth;
uniform float lineWidth;
uniform float focusDepth;
uniform vec4 geometryClip;
uniform float arrowSize;
uniform float arrowSpace;
attribute vec4 position4;
attribute vec3 arrow;
attribute vec2 attach;
// External
vec3 getPosition(vec4 xyzw, float canonical);
void getArrowGeometry(vec4 xyzw, float near, float far, out vec3 left, out vec3 right, out vec3 start) {
right = getPosition(xyzw, 1.0);
left = getPosition(vec4(near, xyzw.yzw), 0.0);
start = getPosition(vec4(far, xyzw.yzw), 0.0);
}
mat4 getArrowMatrix(vec3 left, vec3 right, vec3 start) {
float depth = focusDepth;
if (lineDepth < 1.0) {
// Depth blending
float z = max(0.00001, -right.z);
depth = mix(z, focusDepth, lineDepth);
}
vec3 diff = left - right;
float l = length(diff);
if (l == 0.0) {
return mat4(1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
}
// Construct TBN matrix around shaft
vec3 t = normalize(diff);
vec3 n = normalize(cross(t, t.yzx + vec3(.1, .2, .3)));
vec3 b = cross(n, t);
// Shrink arrows when vector gets too small
// Approach linear scaling with cubic ease the smaller we get
float size = arrowSize * lineWidth * worldUnit * depth * 1.25;
diff = right - start;
l = length(diff) * arrowSpace;
float mini = clamp(1.0 - l / size * .333, 0.0, 1.0);
float scale = 1.0 - mini * mini * mini;
float range = size * scale;
// Size to 2.5:1 ratio
float rangeNB = range / 2.5;
// Anchor at end position
return mat4(vec4(n * rangeNB, 0),
vec4(b * rangeNB, 0),
vec4(t * range, 0),
vec4(right, 1.0));
}
vec3 getArrowPosition() {
vec3 left, right, start;
vec4 p = min(geometryClip, position4);
getArrowGeometry(p, attach.x, attach.y, left, right, start);
mat4 matrix = getArrowMatrix(left, right, start);
return (matrix * vec4(arrow.xyz, 1.0)).xyz;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/arrow.position.js | JavaScript | mit | 2,036 |
declare var _default: "uniform vec4 axisStep;\nuniform vec4 axisPosition;\n\nvec4 getAxisPosition(vec4 xyzw, inout vec4 stpq) {\n return axisStep * xyzw.x + axisPosition;\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/axis.position.d.ts | TypeScript | mit | 204 |
export default /* glsl */ `uniform vec4 axisStep;
uniform vec4 axisPosition;
vec4 getAxisPosition(vec4 xyzw, inout vec4 stpq) {
return axisStep * xyzw.x + axisPosition;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/axis.position.js | JavaScript | mit | 177 |
declare var _default: "uniform mat4 viewMatrix;\n\nvec4 getCartesianPosition(vec4 position, inout vec4 stpq) {\n return viewMatrix * vec4(position.xyz, 1.0);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/cartesian.position.d.ts | TypeScript | mit | 191 |
export default /* glsl */ `uniform mat4 viewMatrix;
vec4 getCartesianPosition(vec4 position, inout vec4 stpq) {
return viewMatrix * vec4(position.xyz, 1.0);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/cartesian.position.js | JavaScript | mit | 165 |
declare var _default: "uniform vec4 basisScale;\nuniform vec4 basisOffset;\nuniform vec4 viewScale;\nuniform vec4 viewOffset;\n\nvec4 getCartesian4Position(vec4 position, inout vec4 stpq) {\n return position * basisScale + basisOffset;\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/cartesian4.position.d.ts | TypeScript | mit | 269 |
export default /* glsl */ `uniform vec4 basisScale;
uniform vec4 basisOffset;
uniform vec4 viewScale;
uniform vec4 viewOffset;
vec4 getCartesian4Position(vec4 position, inout vec4 stpq) {
return position * basisScale + basisOffset;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/cartesian4.position.js | JavaScript | mit | 240 |
declare var _default: "uniform vec4 clampLimit;\n\nvec4 getClampXYZW(vec4 xyzw) {\n return clamp(xyzw, vec4(0.0), clampLimit);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/clamp.position.d.ts | TypeScript | mit | 160 |
export default /* glsl */ `uniform vec4 clampLimit;
vec4 getClampXYZW(vec4 xyzw) {
return clamp(xyzw, vec4(0.0), clampLimit);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/clamp.position.js | JavaScript | mit | 134 |
declare var _default: "vec4 opaqueColor(vec4 color) {\n return vec4(color.rgb, 1.0);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/color.opaque.d.ts | TypeScript | mit | 118 |
export default /* glsl */ `vec4 opaqueColor(vec4 color) {
return vec4(color.rgb, 1.0);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/color.opaque.js | JavaScript | mit | 94 |
declare var _default: "uniform vec4 geometryClip;\nattribute vec4 position4;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvec3 getFacePosition() {\n vec4 p = min(geometryClip, position4);\n return getPosition(p, 1.0);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/face.position.d.ts | TypeScript | mit | 272 |
export default /* glsl */ `uniform vec4 geometryClip;
attribute vec4 position4;
// External
vec3 getPosition(vec4 xyzw, float canonical);
vec3 getFacePosition() {
vec4 p = min(geometryClip, position4);
return getPosition(p, 1.0);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/face.position.js | JavaScript | mit | 241 |
declare var _default: "attribute vec4 position4;\n\n// External\nvec3 getPosition(vec4 xyzw, float canonical);\n\nvarying vec3 vNormal;\nvarying vec3 vLight;\nvarying vec3 vPosition;\n\nvoid getFaceGeometry(vec4 xyzw, out vec3 pos, out vec3 normal) {\n vec3 a, b, c;\n\n a = getPosition(vec4(xyzw.xyz, 0.0), 0.0);\n b = getPosition(vec4(xyzw.xyz, 1.0), 0.0);\n c = getPosition(vec4(xyzw.xyz, 2.0), 0.0);\n\n pos = getPosition(xyzw, 1.0);\n normal = normalize(cross(c - a, b - a));\n}\n\nvec3 getFacePositionNormal() {\n vec3 center, normal;\n\n getFaceGeometry(position4, center, normal);\n vNormal = normal;\n vLight = normalize((viewMatrix * vec4(1.0, 2.0, 2.0, 0.0)).xyz);\n vPosition = -center;\n\n return center;\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/face.position.normal.d.ts | TypeScript | mit | 773 |
export default /* glsl */ `attribute vec4 position4;
// External
vec3 getPosition(vec4 xyzw, float canonical);
varying vec3 vNormal;
varying vec3 vLight;
varying vec3 vPosition;
void getFaceGeometry(vec4 xyzw, out vec3 pos, out vec3 normal) {
vec3 a, b, c;
a = getPosition(vec4(xyzw.xyz, 0.0), 0.0);
b = getPosition(vec4(xyzw.xyz, 1.0), 0.0);
c = getPosition(vec4(xyzw.xyz, 2.0), 0.0);
pos = getPosition(xyzw, 1.0);
normal = normalize(cross(c - a, b - a));
}
vec3 getFacePositionNormal() {
vec3 center, normal;
getFaceGeometry(position4, center, normal);
vNormal = normal;
vLight = normalize((viewMatrix * vec4(1.0, 2.0, 2.0, 0.0)).xyz);
vPosition = -center;
return center;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/face.position.normal.js | JavaScript | mit | 722 |
export default /* glsl */ `/*
Float encoding technique by
Carlos Scheidegger
https://github.com/cscheid/lux/blob/master/src/shade/bits/encode_float.js
Conversion to GLSL by:
http://concord-consortium.github.io/lab/experiments/webgl-gpgpu/script.js
*/
float shift_right(float v, float amt) {
v = floor(v) + 0.5;
return floor(v / exp2(amt));
}
float shift_left(float v, float amt) {
return floor(v * exp2(amt) + 0.5);
}
float mask_last(float v, float bits) {
return mod(v, shift_left(1.0, bits));
}
float extract_bits(float num, float from, float to) {
from = floor(from + 0.5); to = floor(to + 0.5);
return mask_last(shift_right(num, from), to - from);
}
vec4 encode_float(float val) {
if (val == 0.0) return vec4(0, 0, 0, 0);
float valuesign = val > 0.0 ? 0.0 : 1.0;
val = abs(val);
float exponent = floor(log2(val));
float biased_exponent = exponent + 127.0;
float fraction = ((val / exp2(exponent)) - 1.0) * 8388608.0;
float t = biased_exponent / 2.0;
float last_bit_of_biased_exponent = fract(t) * 2.0;
float remaining_bits_of_biased_exponent = floor(t);
float byte4 = extract_bits(fraction, 0.0, 8.0) / 255.0;
float byte3 = extract_bits(fraction, 8.0, 16.0) / 255.0;
float byte2 = (last_bit_of_biased_exponent * 128.0 + extract_bits(fraction, 16.0, 23.0)) / 255.0;
float byte1 = (valuesign * 128.0 + remaining_bits_of_biased_exponent) / 255.0;
return vec4(byte4, byte3, byte2, byte1);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/float.encode.js | JavaScript | mit | 1,465 |
declare var _default: "uniform vec4 indexModulus;\n\nvec4 getSample(vec4 xyzw);\nvec4 getIndex(vec4 xyzw);\n\nvec4 floatPackIndex(vec4 xyzw) {\n vec4 value = getSample(xyzw);\n vec4 index = getIndex(xyzw);\n\n vec4 offset = floor(index + .5) * indexModulus;\n vec2 sum2 = offset.xy + offset.zw;\n float sum = sum2.x + sum2.y;\n return vec4(value.xyz, sum);\n}";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/float.index.pack.d.ts | TypeScript | mit | 393 |
export default /* glsl */ `uniform vec4 indexModulus;
vec4 getSample(vec4 xyzw);
vec4 getIndex(vec4 xyzw);
vec4 floatPackIndex(vec4 xyzw) {
vec4 value = getSample(xyzw);
vec4 index = getIndex(xyzw);
vec4 offset = floor(index + .5) * indexModulus;
vec2 sum2 = offset.xy + offset.zw;
float sum = sum2.x + sum2.y;
return vec4(value.xyz, sum);
}`;
| cchudzicki/mathbox | build/esm/shaders/glsl/float.index.pack.js | JavaScript | mit | 359 |
declare var _default: "vec4 getSample(vec4 xyzw);\n\nfloat floatStretch(vec4 xyzw, float channelIndex) {\n vec4 sample = getSample(xyzw);\n vec2 xy = channelIndex > 1.5 ? sample.zw : sample.xy;\n return mod(channelIndex, 2.0) > .5 ? xy.y : xy.x;\n}";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/float.stretch.d.ts | TypeScript | mit | 279 |
export default /* glsl */ `vec4 getSample(vec4 xyzw);
float floatStretch(vec4 xyzw, float channelIndex) {
vec4 sample = getSample(xyzw);
vec2 xy = channelIndex > 1.5 ? sample.zw : sample.xy;
return mod(channelIndex, 2.0) > .5 ? xy.y : xy.x;
}`;
| cchudzicki/mathbox | build/esm/shaders/glsl/float.stretch.js | JavaScript | mit | 252 |
declare var _default: "varying float vClipStrokeWidth;\nvarying float vClipStrokeIndex;\nvarying vec3 vClipStrokeEven;\nvarying vec3 vClipStrokeOdd;\nvarying vec3 vClipStrokePosition;\n\nvoid clipStrokeFragment() {\n bool odd = mod(vClipStrokeIndex, 2.0) >= 1.0;\n\n vec3 tangent;\n if (odd) {\n tangent = vClipStrokeOdd;\n }\n else {\n tangent = vClipStrokeEven;\n }\n\n float travel = dot(vClipStrokePosition, normalize(tangent)) / vClipStrokeWidth;\n if (mod(travel, 16.0) > 8.0) {\n discard;\n }\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.clip.dashed.d.ts | TypeScript | mit | 553 |
export default /* glsl */ `varying float vClipStrokeWidth;
varying float vClipStrokeIndex;
varying vec3 vClipStrokeEven;
varying vec3 vClipStrokeOdd;
varying vec3 vClipStrokePosition;
void clipStrokeFragment() {
bool odd = mod(vClipStrokeIndex, 2.0) >= 1.0;
vec3 tangent;
if (odd) {
tangent = vClipStrokeOdd;
}
else {
tangent = vClipStrokeEven;
}
float travel = dot(vClipStrokePosition, normalize(tangent)) / vClipStrokeWidth;
if (mod(travel, 16.0) > 8.0) {
discard;
}
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.clip.dashed.js | JavaScript | mit | 510 |
declare var _default: "varying float vClipStrokeWidth;\nvarying float vClipStrokeIndex;\nvarying vec3 vClipStrokeEven;\nvarying vec3 vClipStrokeOdd;\nvarying vec3 vClipStrokePosition;\n\nvoid clipStrokeFragment() {\n bool odd = mod(vClipStrokeIndex, 2.0) >= 1.0;\n\n vec3 tangent;\n if (odd) {\n tangent = vClipStrokeOdd;\n }\n else {\n tangent = vClipStrokeEven;\n }\n\n float travel = dot(vClipStrokePosition, normalize(tangent)) / vClipStrokeWidth;\n if (mod(travel, 4.0) > 2.0) {\n discard;\n }\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.clip.dotted.d.ts | TypeScript | mit | 552 |
export default /* glsl */ `varying float vClipStrokeWidth;
varying float vClipStrokeIndex;
varying vec3 vClipStrokeEven;
varying vec3 vClipStrokeOdd;
varying vec3 vClipStrokePosition;
void clipStrokeFragment() {
bool odd = mod(vClipStrokeIndex, 2.0) >= 1.0;
vec3 tangent;
if (odd) {
tangent = vClipStrokeOdd;
}
else {
tangent = vClipStrokeEven;
}
float travel = dot(vClipStrokePosition, normalize(tangent)) / vClipStrokeWidth;
if (mod(travel, 4.0) > 2.0) {
discard;
}
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.clip.dotted.js | JavaScript | mit | 509 |
declare var _default: "varying vec2 vClipEnds;\n\nvoid clipEndsFragment() {\n if (vClipEnds.x < 0.0 || vClipEnds.y < 0.0) discard;\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.clip.ends.d.ts | TypeScript | mit | 164 |
export default /* glsl */ `varying vec2 vClipEnds;
void clipEndsFragment() {
if (vClipEnds.x < 0.0 || vClipEnds.y < 0.0) discard;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.clip.ends.js | JavaScript | mit | 138 |
declare var _default: "varying float vClipProximity;\n\nvoid clipProximityFragment() {\n if (vClipProximity >= 0.5) discard;\n}";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.clip.proximity.d.ts | TypeScript | mit | 156 |
export default /* glsl */ `varying float vClipProximity;
void clipProximityFragment() {
if (vClipProximity >= 0.5) discard;
}`;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.clip.proximity.js | JavaScript | mit | 131 |
declare var _default: "void setFragmentColor(vec4 color) {\n gl_FragColor = color;\n}";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.color.d.ts | TypeScript | mit | 114 |
export default /* glsl */ `void setFragmentColor(vec4 color) {
gl_FragColor = color;
}`;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.color.js | JavaScript | mit | 91 |
declare var _default: "vec4 fragmentRGBA(vec4 rgba, vec4 stpq) {\n return rgba;\n}";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.map.rgba.d.ts | TypeScript | mit | 111 |
export default /* glsl */ `vec4 fragmentRGBA(vec4 rgba, vec4 stpq) {
return rgba;
}`;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.map.rgba.js | JavaScript | mit | 88 |
declare var _default: "void setFragmentColor(vec4 color) {\n if (color.a < 1.0) discard;\n gl_FragColor = color;\n}";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.solid.d.ts | TypeScript | mit | 145 |
export default /* glsl */ `void setFragmentColor(vec4 color) {
if (color.a < 1.0) discard;
gl_FragColor = color;
}`;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.solid.js | JavaScript | mit | 121 |
declare var _default: "void setFragmentColor(vec4 color) {\n if (color.a >= 1.0) discard;\n gl_FragColor = color;\n}";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.transparent.d.ts | TypeScript | mit | 146 |
export default /* glsl */ `void setFragmentColor(vec4 color) {
if (color.a >= 1.0) discard;
gl_FragColor = color;
}`;
| cchudzicki/mathbox | build/esm/shaders/glsl/fragment.transparent.js | JavaScript | mit | 122 |
declare var _default: "uniform vec4 gridPosition;\nuniform vec4 gridStep;\nuniform vec4 gridAxis;\n\nvec4 sampleData(vec2 xy);\n\nvec4 getGridPosition(vec4 xyzw) {\n vec4 onAxis = gridAxis * sampleData(vec2(xyzw.y, 0.0)).x;\n vec4 offAxis = gridStep * xyzw.x + gridPosition;\n return onAxis + offAxis;\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/grid.position.d.ts | TypeScript | mit | 338 |
export default /* glsl */ `uniform vec4 gridPosition;
uniform vec4 gridStep;
uniform vec4 gridAxis;
vec4 sampleData(vec2 xy);
vec4 getGridPosition(vec4 xyzw) {
vec4 onAxis = gridAxis * sampleData(vec2(xyzw.y, 0.0)).x;
vec4 offAxis = gridStep * xyzw.x + gridPosition;
return onAxis + offAxis;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/grid.position.js | JavaScript | mit | 306 |
declare var _default: "uniform float growScale;\nuniform vec4 growMask;\nuniform vec4 growAnchor;\n\nvec4 getSample(vec4 xyzw);\n\nvec4 getGrowSample(vec4 xyzw) {\n vec4 anchor = xyzw * growMask + growAnchor;\n\n vec4 position = getSample(xyzw);\n vec4 center = getSample(anchor);\n\n return mix(center, position, growScale);\n}";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/grow.position.d.ts | TypeScript | mit | 362 |
export default /* glsl */ `uniform float growScale;
uniform vec4 growMask;
uniform vec4 growAnchor;
vec4 getSample(vec4 xyzw);
vec4 getGrowSample(vec4 xyzw) {
vec4 anchor = xyzw * growMask + growAnchor;
vec4 position = getSample(xyzw);
vec4 center = getSample(anchor);
return mix(center, position, growScale);
}`;
| cchudzicki/mathbox | build/esm/shaders/glsl/grow.position.js | JavaScript | mit | 328 |
declare var _default: "uniform float joinStride;\nuniform float joinStrideInv;\n\nfloat getIndex(vec4 xyzw);\nvec4 getRest(vec4 xyzw);\nvec4 injectIndices(float a, float b);\n\nvec4 getJoinXYZW(vec4 xyzw) {\n\n float a = getIndex(xyzw);\n float b = a * joinStrideInv;\n\n float integer = floor(b);\n float fraction = b - integer;\n \n return injectIndices(fraction * joinStride, integer) + getRest(xyzw);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/join.position.d.ts | TypeScript | mit | 444 |
export default /* glsl */ `uniform float joinStride;
uniform float joinStrideInv;
float getIndex(vec4 xyzw);
vec4 getRest(vec4 xyzw);
vec4 injectIndices(float a, float b);
vec4 getJoinXYZW(vec4 xyzw) {
float a = getIndex(xyzw);
float b = a * joinStrideInv;
float integer = floor(b);
float fraction = b - integer;
return injectIndices(fraction * joinStride, integer) + getRest(xyzw);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/join.position.js | JavaScript | mit | 406 |
declare var _default: "varying float vPixelSize;\n\nvec4 getLabelAlphaColor(vec4 color, vec4 sample) {\n float mask = clamp(sample.r * 1000.0, 0.0, 1.0);\n float alpha = (sample.r - .5) * vPixelSize + .5;\n float a = mask * alpha * color.a;\n if (a <= 0.0) discard;\n return vec4(color.xyz, a);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/label.alpha.d.ts | TypeScript | mit | 332 |
export default /* glsl */ `varying float vPixelSize;
vec4 getLabelAlphaColor(vec4 color, vec4 sample) {
float mask = clamp(sample.r * 1000.0, 0.0, 1.0);
float alpha = (sample.r - .5) * vPixelSize + .5;
float a = mask * alpha * color.a;
if (a <= 0.0) discard;
return vec4(color.xyz, a);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/label.alpha.js | JavaScript | mit | 302 |
declare var _default: "vec2 mapUV(vec4 uvwo, vec4 stpq) {\n return uvwo.xy;\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/label.map.d.ts | TypeScript | mit | 109 |
export default /* glsl */ `vec2 mapUV(vec4 uvwo, vec4 stpq) {
return uvwo.xy;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/label.map.js | JavaScript | mit | 85 |
declare var _default: "uniform float outlineExpand;\nuniform float outlineStep;\nuniform vec3 outlineColor;\n\nvarying float vPixelSize;\n\nconst float PIXEL_STEP = 255.0 / 16.0;\n\nvec4 getLabelOutlineColor(vec4 color, vec4 sample) {\n float ps = vPixelSize * PIXEL_STEP;\n float os = outlineStep;\n\n float sdf = sample.r - .5 + outlineExpand;\n vec2 sdfs = vec2(sdf, sdf + os);\n vec2 alpha = clamp(sdfs * ps + .5, 0.0, 1.0);\n\n if (alpha.y <= 0.0) {\n discard;\n }\n\n vec3 blend = color.xyz;\n if (alpha.y > alpha.x) {\n blend = sqrt(mix(outlineColor * outlineColor, blend * blend, alpha.x));\n }\n \n return vec4(blend, alpha.y * color.a);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/label.outline.d.ts | TypeScript | mit | 700 |
export default /* glsl */ `uniform float outlineExpand;
uniform float outlineStep;
uniform vec3 outlineColor;
varying float vPixelSize;
const float PIXEL_STEP = 255.0 / 16.0;
vec4 getLabelOutlineColor(vec4 color, vec4 sample) {
float ps = vPixelSize * PIXEL_STEP;
float os = outlineStep;
float sdf = sample.r - .5 + outlineExpand;
vec2 sdfs = vec2(sdf, sdf + os);
vec2 alpha = clamp(sdfs * ps + .5, 0.0, 1.0);
if (alpha.y <= 0.0) {
discard;
}
vec3 blend = color.xyz;
if (alpha.y > alpha.x) {
blend = sqrt(mix(outlineColor * outlineColor, blend * blend, alpha.x));
}
return vec4(blend, alpha.y * color.a);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/label.outline.js | JavaScript | mit | 652 |
declare var _default: "uniform vec4 layerScale;\nuniform vec4 layerBias;\n\nvec4 layerPosition(vec4 position, inout vec4 stpq) {\n return layerScale * position + layerBias;\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/layer.position.d.ts | TypeScript | mit | 206 |
export default /* glsl */ `uniform vec4 layerScale;
uniform vec4 layerBias;
vec4 layerPosition(vec4 position, inout vec4 stpq) {
return layerScale * position + layerBias;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/layer.position.js | JavaScript | mit | 179 |
declare var _default: "// External\nvec4 sampleData(vec4 xyzw);\n\nvec4 lerpDepth(vec4 xyzw) {\n float x = xyzw.z;\n float i = floor(x);\n float f = x - i;\n \n vec4 xyzw1 = vec4(xyzw.xy, i, xyzw.w);\n vec4 xyzw2 = vec4(xyzw.xy, i + 1.0, xyzw.w);\n \n vec4 a = sampleData(xyzw1);\n vec4 b = sampleData(xyzw2);\n\n return mix(a, b, f);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/lerp.depth.d.ts | TypeScript | mit | 379 |
export default /* glsl */ `// External
vec4 sampleData(vec4 xyzw);
vec4 lerpDepth(vec4 xyzw) {
float x = xyzw.z;
float i = floor(x);
float f = x - i;
vec4 xyzw1 = vec4(xyzw.xy, i, xyzw.w);
vec4 xyzw2 = vec4(xyzw.xy, i + 1.0, xyzw.w);
vec4 a = sampleData(xyzw1);
vec4 b = sampleData(xyzw2);
return mix(a, b, f);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/lerp.depth.js | JavaScript | mit | 342 |
declare var _default: "// External\nvec4 sampleData(vec4 xyzw);\n\nvec4 lerpHeight(vec4 xyzw) {\n float x = xyzw.y;\n float i = floor(x);\n float f = x - i;\n \n vec4 xyzw1 = vec4(xyzw.x, i, xyzw.zw);\n vec4 xyzw2 = vec4(xyzw.x, i + 1.0, xyzw.zw);\n \n vec4 a = sampleData(xyzw1);\n vec4 b = sampleData(xyzw2);\n\n return mix(a, b, f);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/lerp.height.d.ts | TypeScript | mit | 380 |
export default /* glsl */ `// External
vec4 sampleData(vec4 xyzw);
vec4 lerpHeight(vec4 xyzw) {
float x = xyzw.y;
float i = floor(x);
float f = x - i;
vec4 xyzw1 = vec4(xyzw.x, i, xyzw.zw);
vec4 xyzw2 = vec4(xyzw.x, i + 1.0, xyzw.zw);
vec4 a = sampleData(xyzw1);
vec4 b = sampleData(xyzw2);
return mix(a, b, f);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/lerp.height.js | JavaScript | mit | 343 |
declare var _default: "// External\nvec4 sampleData(vec4 xyzw);\n\nvec4 lerpItems(vec4 xyzw) {\n float x = xyzw.w;\n float i = floor(x);\n float f = x - i;\n \n vec4 xyzw1 = vec4(xyzw.xyz, i);\n vec4 xyzw2 = vec4(xyzw.xyz, i + 1.0);\n \n vec4 a = sampleData(xyzw1);\n vec4 b = sampleData(xyzw2);\n\n return mix(a, b, f);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/lerp.items.d.ts | TypeScript | mit | 365 |
export default /* glsl */ `// External
vec4 sampleData(vec4 xyzw);
vec4 lerpItems(vec4 xyzw) {
float x = xyzw.w;
float i = floor(x);
float f = x - i;
vec4 xyzw1 = vec4(xyzw.xyz, i);
vec4 xyzw2 = vec4(xyzw.xyz, i + 1.0);
vec4 a = sampleData(xyzw1);
vec4 b = sampleData(xyzw2);
return mix(a, b, f);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/lerp.items.js | JavaScript | mit | 328 |
declare var _default: "// External\nvec4 sampleData(vec4 xyzw);\n\nvec4 lerpWidth(vec4 xyzw) {\n float x = xyzw.x;\n float i = floor(x);\n float f = x - i;\n \n vec4 xyzw1 = vec4(i, xyzw.yzw);\n vec4 xyzw2 = vec4(i + 1.0, xyzw.yzw);\n \n vec4 a = sampleData(xyzw1);\n vec4 b = sampleData(xyzw2);\n\n return mix(a, b, f);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/lerp.width.d.ts | TypeScript | mit | 365 |
export default /* glsl */ `// External
vec4 sampleData(vec4 xyzw);
vec4 lerpWidth(vec4 xyzw) {
float x = xyzw.x;
float i = floor(x);
float f = x - i;
vec4 xyzw1 = vec4(i, xyzw.yzw);
vec4 xyzw2 = vec4(i + 1.0, xyzw.yzw);
vec4 a = sampleData(xyzw1);
vec4 b = sampleData(xyzw2);
return mix(a, b, f);
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/lerp.width.js | JavaScript | mit | 328 |
export default /* glsl */ `// Units and calibration
uniform float worldUnit;
uniform float lineWidth;
uniform float lineDepth;
uniform float focusDepth;
// General data index
uniform vec4 geometryClip;
attribute vec4 position4;
// (Start/mid/end -1/0/1, top/bottom -1,1)
attribute vec2 line;
// 0...1 for round or bevel joins
#ifdef LINE_JOIN_DETAIL
attribute float joint;
#else
const float joint = 0.0;
#endif
// Knock out excessively long line segments (e.g. for asymtpotes)
#ifdef LINE_PROXIMITY
uniform float lineProximity;
varying float vClipProximity;
#endif
// Ghetto line stroking (local only, not global)
#ifdef LINE_STROKE
varying float vClipStrokeWidth;
varying float vClipStrokeIndex;
varying vec3 vClipStrokeEven;
varying vec3 vClipStrokeOdd;
varying vec3 vClipStrokePosition;
#endif
// External
vec3 getPosition(vec4 xyzw, float canonical);
// Clip line ends for arrows / decoration
#ifdef LINE_CLIP
uniform float clipRange;
uniform vec2 clipStyle;
uniform float clipSpace;
attribute vec2 strip;
varying vec2 vClipEnds;
void clipEnds(vec4 xyzw, vec3 center, vec3 pos) {
// Sample end of line strip
vec4 xyzwE = vec4(strip.y, xyzw.yzw);
vec3 end = getPosition(xyzwE, 0.0);
// Sample start of line strip
vec4 xyzwS = vec4(strip.x, xyzw.yzw);
vec3 start = getPosition(xyzwS, 0.0);
// Measure length
vec3 diff = end - start;
float l = length(diff) * clipSpace;
// Arrow length (=2.5x radius)
float arrowSize = 1.25 * clipRange * lineWidth * worldUnit;
vClipEnds = vec2(1.0);
if (clipStyle.y > 0.0) {
// Depth blend end
float depth = focusDepth;
if (lineDepth < 1.0) {
float z = max(0.00001, -end.z);
depth = mix(z, focusDepth, lineDepth);
}
// Absolute arrow length
float size = arrowSize * depth;
// Adjust clip range
// Approach linear scaling with cubic ease the smaller we get
float mini = clamp(1.0 - l / size * .333, 0.0, 1.0);
float scale = 1.0 - mini * mini * mini;
float invrange = 1.0 / (size * scale);
// Clip end
diff = end - center;
if(diff == vec3(0.0))
vClipEnds.x = -1.0;
else {
diff = normalize(end - center);
float d = dot(end - pos, diff);
vClipEnds.x = d * invrange - 1.0;
}
}
if (clipStyle.x > 0.0) {
// Depth blend start
float depth = focusDepth;
if (lineDepth < 1.0) {
float z = max(0.00001, -start.z);
depth = mix(z, focusDepth, lineDepth);
}
// Absolute arrow length
float size = arrowSize * depth;
// Adjust clip range
// Approach linear scaling with cubic ease the smaller we get
float mini = clamp(1.0 - l / size * .333, 0.0, 1.0);
float scale = 1.0 - mini * mini * mini;
float invrange = 1.0 / (size * scale);
// Clip start
diff = center - start;
if(diff == vec3(0.0))
vClipEnds.y = -1.0;
else {
diff = normalize(center - start);
float d = dot(pos - start, diff);
vClipEnds.y = d * invrange - 1.0;
}
}
}
#endif
// Adjust left/center/right to be inside near/far z range
const float epsilon = 1e-5;
void fixCenter(inout vec3 left, inout vec3 center, inout vec3 right) {
if (center.z >= 0.0) {
if (left.z < 0.0) {
float d = (center.z + epsilon) / (center.z - left.z);
center = mix(center, left, d);
}
else if (right.z < 0.0) {
float d = (center.z + epsilon) / (center.z - right.z);
center = mix(center, right, d);
}
}
if (left.z >= 0.0) {
if (center.z < 0.0) {
float d = (left.z + epsilon) / (left.z - center.z);
left = mix(left, center, d);
}
}
if (right.z >= 0.0) {
if (center.z < 0.0) {
float d = (right.z + epsilon) / (right.z - center.z);
right = mix(right, center, d);
}
}
}
// Sample the source data in an edge-aware manner
void getLineGeometry(vec4 xyzw, float edge, out vec3 left, out vec3 center, out vec3 right) {
vec4 delta = vec4(1.0, 0.0, 0.0, 0.0);
center = getPosition(xyzw, 1.0);
left = (edge > -0.5) ? getPosition(xyzw - delta, 0.0) : center;
right = (edge < 0.5) ? getPosition(xyzw + delta, 0.0) : center;
}
// Calculate the position for a vertex along the line, including joins
vec3 getLineJoin(float edge, bool odd, vec3 left, vec3 center, vec3 right, float width, float offset, float joint) {
vec2 join = vec2(1.0, 0.0);
fixCenter(left, center, right);
vec4 a = vec4(left.xy, right.xy);
vec4 b = a / vec4(left.zz, right.zz);
vec2 l = b.xy;
vec2 r = b.zw;
vec2 c = center.xy / center.z;
vec4 d = vec4(l, c) - vec4(c, r);
float l1 = dot(d.xy, d.xy);
float l2 = dot(d.zw, d.zw);
if (l1 + l2 > 0.0) {
if (edge > 0.5 || l2 == 0.0) {
vec2 nl = normalize(d.xy);
vec2 tl = vec2(nl.y, -nl.x);
#ifdef LINE_PROXIMITY
vClipProximity = 1.0;
#endif
#ifdef LINE_STROKE
vClipStrokeEven = vClipStrokeOdd = normalize(left - center);
#endif
join = tl;
}
else if (edge < -0.5 || l1 == 0.0) {
vec2 nr = normalize(d.zw);
vec2 tr = vec2(nr.y, -nr.x);
#ifdef LINE_PROXIMITY
vClipProximity = 1.0;
#endif
#ifdef LINE_STROKE
vClipStrokeEven = vClipStrokeOdd = normalize(center - right);
#endif
join = tr;
}
else {
// Limit join stretch for tiny segments
float lmin2 = min(l1, l2) / (width * width);
// Hide line segment if ratio of leg lengths exceeds promixity threshold
#ifdef LINE_PROXIMITY
float lr = l1 / l2;
float rl = l2 / l1;
float ratio = max(lr, rl);
float thresh = lineProximity + 1.0;
vClipProximity = (ratio > thresh * thresh) ? 1.0 : 0.0;
#endif
// Calculate normals/tangents
vec2 nl = normalize(d.xy);
vec2 nr = normalize(d.zw);
// Calculate tangents
vec2 tl = vec2(nl.y, -nl.x);
vec2 tr = vec2(nr.y, -nr.x);
#ifdef LINE_PROXIMITY
// Mix tangents according to leg lengths
vec2 tc = normalize(mix(tl, tr, l1/(l1+l2)));
#else
// Average tangent
vec2 tc = normalize(tl + tr);
#endif
// Miter join
float cosA = dot(nl, tc);
float sinA = max(0.1, abs(dot(tl, tc)));
float factor = cosA / sinA;
float scale = sqrt(1.0 + min(lmin2, factor * factor));
// Stroke normals
#ifdef LINE_STROKE
vec3 stroke1 = normalize(left - center);
vec3 stroke2 = normalize(center - right);
if (odd) {
vClipStrokeEven = stroke1;
vClipStrokeOdd = stroke2;
}
else {
vClipStrokeEven = stroke2;
vClipStrokeOdd = stroke1;
}
#endif
#ifdef LINE_JOIN_MITER
// Apply straight up miter
join = tc * scale;
#endif
#ifdef LINE_JOIN_ROUND
// Slerp bevel join into circular arc
float dotProduct = dot(nl, nr);
float angle = acos(dotProduct);
float sinT = sin(angle);
join = (sin((1.0 - joint) * angle) * tl + sin(joint * angle) * tr) / sinT;
#endif
#ifdef LINE_JOIN_BEVEL
// Direct bevel join between two flat ends
float dotProduct = dot(nl, nr);
join = mix(tl, tr, joint);
#endif
#ifdef LINE_JOIN_DETAIL
// Check if on inside or outside of joint
float crossProduct = nl.x * nr.y - nl.y * nr.x;
if (offset * crossProduct < 0.0) {
// For near-180-degree bends, correct back to a miter to avoid discontinuities
float ratio = clamp(-dotProduct * 2.0 - 1.0, 0.0, 1.0);
// Otherwise collapse the inside vertices into one.
join = mix(tc * scale, join, ratio * ratio * ratio);
}
#endif
}
return vec3(join, 0.0);
}
else {
return vec3(0.0);
}
}
// Calculate final line position
vec3 getLinePosition() {
vec3 left, center, right, join;
// left/center/right
float edge = line.x;
// up/down
float offset = line.y;
// Clip data
vec4 p = min(geometryClip, position4);
edge += max(0.0, position4.x - geometryClip.x);
// Get position + adjacent neighbours
getLineGeometry(p, edge, left, center, right);
#ifdef LINE_STROKE
// Set parameters for line stroke fragment shader
vClipStrokePosition = center;
vClipStrokeIndex = p.x;
bool odd = mod(p.x, 2.0) >= 1.0;
#else
bool odd = true;
#endif
// Divide line width up/down
float width = lineWidth * 0.5;
float depth = focusDepth;
if (lineDepth < 1.0) {
// Depth blending
float z = max(0.00001, -center.z);
depth = mix(z, focusDepth, lineDepth);
}
width *= depth;
// Convert to world units
width *= worldUnit;
// Calculate line join
join = getLineJoin(edge, odd, left, center, right, width, offset, joint);
vec3 pos = center + join * offset * width;
#ifdef LINE_STROKE
vClipStrokeWidth = width;
#endif
#ifdef LINE_CLIP
clipEnds(p, center, pos);
#endif
return pos;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/line.position.js | JavaScript | mit | 8,760 |
declare var _default: "uniform vec2 dataResolution;\nuniform vec2 dataPointer;\n\nvec2 map2DData(vec2 xy) {\n return (xy + dataPointer) * dataResolution;\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/map.2d.data.d.ts | TypeScript | mit | 187 |
export default /* glsl */ `uniform vec2 dataResolution;
uniform vec2 dataPointer;
vec2 map2DData(vec2 xy) {
return (xy + dataPointer) * dataResolution;
}
`;
| cchudzicki/mathbox | build/esm/shaders/glsl/map.2d.data.js | JavaScript | mit | 160 |
declare var _default: "uniform vec2 dataResolution;\nuniform vec2 dataPointer;\n\nvec2 map2DData(vec2 xy) {\n return fract((xy + dataPointer) * dataResolution);\n}\n";
export default _default;
| cchudzicki/mathbox | build/esm/shaders/glsl/map.2d.data.wrap.d.ts | TypeScript | mit | 194 |