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 Format extends Operator { init(): boolean; atlas: any; buffer: any; used: any; time: any; filled: boolean | undefined; textShader(shader: any): any; textIsSDF(): boolean; textHeight(): any; clockParent: any; unmake(): null | undefined; update(): any; change(changed: any, touched: any, init: any): any; through: any; } import { Operator } from "../operator/operator.js";
cchudzicki/mathbox
build/esm/primitives/types/text/format.d.ts
TypeScript
mit
440
// 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 * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { FloatType, NearestFilter } from "three/src/constants.js"; import { Operator } from "../operator/operator.js"; export class Format extends Operator { static initClass() { this.traits = [ "node", "bind", "operator", "texture", "text", "format", "font", ]; this.defaults = { minFilter: "linear", magFilter: "linear", }; } init() { super.init(); this.atlas = this.buffer = this.used = this.time = null; return (this.filled = false); } sourceShader(shader) { return this.buffer.shader(shader); } textShader(shader) { return this.atlas.shader(shader); } textIsSDF() { return this.props.sdf > 0; } textHeight() { return this.props.detail; } make() { // Bind to attached data sources # super() this._helpers.bind.make([{ to: "operator.source", trait: "raw" }]); // Read sampling parameters let { minFilter, magFilter, type } = this.props; // Read font parameters const { font, style, variant, weight, detail, sdf } = this.props; // Prepare text atlas this.atlas = this._renderables.make("textAtlas", { font, size: detail, style, variant, weight, outline: sdf, minFilter, magFilter, type, }); // Underlying data buffer needs no filtering minFilter = NearestFilter; magFilter = NearestFilter; type = FloatType; // Fetch geometry dimensions const dims = this.bind.source.getDimensions(); const { items, width, height, depth } = dims; // Create voxel buffer for text atlas coords this.buffer = this._renderables.make("voxelBuffer", { width, height, depth, channels: 4, items, minFilter, magFilter, type, }); // Hook buffer emitter to map atlas text const { atlas } = this; const { emit } = this.buffer.streamer; this.buffer.streamer.emit = (t) => atlas.map(t, emit); // Grab parent clock this.clockParent = this._inherit("clock"); return this._listen("root", "root.update", this.update); } made() { super.made(); return this.resize(); } unmake() { super.unmake(); if (this.buffer) { this.buffer.dispose(); this.buffer = null; } if (this.atlas) { this.atlas.dispose(); return (this.atlas = null); } } update() { if ((this.filled && !this.props.live) || !this.through) { return; } this.time = this.clockParent.getTime(); const { used } = this; this.atlas.begin(); this.used = this.through(); this.buffer.write(this.used); this.atlas.end(); this.filled = true; if (used !== this.used) { return this.trigger({ type: "source.resize", }); } } change(changed, touched, init) { if (touched["font"]) { return this.rebuild(); } if (changed["format.expr"] || changed["format.digits"] || changed["format.data"] || init) { let map; let { expr } = this.props; const { digits, data } = this.props; if (expr == null) { if (data != null) { expr = (x, y, z, w, i) => data[i]; } else { expr = (x) => x; } } const { length } = expr; if (digits != null) { expr = ((expr) => (x, y, z, w, i, j, k, l, t, d) => +expr(x, y, z, w, i, j, k, l, t, d).toPrecision(digits))(expr); } // Stream raw source data and format it with expression if (length > 8) { map = (emit, x, y, z, w, i, j, k, l, _t, _d) => { return emit(expr(x, y, z, w, i, j, k, l, this.time.clock, this.time.step)); }; } else { map = (emit, x, y, z, w, i, j, k, l) => { return emit(expr(x, y, z, w, i, j, k, l)); }; } return (this.through = this.bind.source .rawBuffer() .through(map, this.buffer)); } } } Format.initClass();
cchudzicki/mathbox
build/esm/primitives/types/text/format.js
JavaScript
mit
5,122
export * from "./text.js"; export * from "./format.js"; export * from "./label.js"; export * from "./retext.js";
cchudzicki/mathbox
build/esm/primitives/types/text/index.d.ts
TypeScript
mit
113
export * from "./text.js"; export * from "./format.js"; export * from "./label.js"; export * from "./retext.js";
cchudzicki/mathbox
build/esm/primitives/types/text/index.js
JavaScript
mit
113
export class Label extends Primitive { make(): any; spriteScale: any; outlineStep: any; outlineExpand: any; sprite: any; unmake(): null; resize(): any; change(changed: any, touched: any, _init: any): number | void; } import { Primitive } from "../../primitive.js";
cchudzicki/mathbox
build/esm/primitives/types/text/label.d.ts
TypeScript
mit
297
// 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 * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UJS from "../../../util/js.js"; import { Primitive } from "../../primitive.js"; export class Label extends Primitive { static initClass() { this.traits = [ "node", "bind", "object", "visible", "style", "label", "attach", "geometry", "position", ]; } make() { let color; super.make(); // Bind to attached objects this._helpers.bind.make([ { to: "label.text", trait: "text" }, { to: "geometry.points", trait: "source" }, { to: "geometry.colors", trait: "source" }, ]); if (this.bind.points == null) { return; } if (this.bind.text == null) { return; } // Fetch geometry/text dimensions const pointDims = this.bind.points.getDimensions(); const textDims = this.bind.text.getDimensions(); const textIsSDF = this.bind.text.textIsSDF(); const items = Math.min(pointDims.items, textDims.items); const width = Math.min(pointDims.width, textDims.width); const height = Math.min(pointDims.height, textDims.height); const depth = Math.min(pointDims.depth, textDims.depth); // Build shader to sample position data // and transform into screen space let position = this.bind.points.sourceShader(this._shaders.shader()); position = this._helpers.position.pipeline(position); // Build shader to sample text geometry data const sprite = this.bind.text.sourceShader(this._shaders.shader()); // Build shader to sample text image data const map = this._shaders.shader().pipe("label.map"); map.pipe(this.bind.text.textShader(this._shaders.shader())); // Build shader to resolve text data const labelUniforms = { spriteDepth: this.node.attributes["attach.depth"], spriteOffset: this.node.attributes["attach.offset"], spriteSnap: this.node.attributes["attach.snap"], spriteScale: this._attributes.make(this._types.number()), outlineStep: this._attributes.make(this._types.number()), outlineExpand: this._attributes.make(this._types.number()), outlineColor: this.node.attributes["label.background"], }; this.spriteScale = labelUniforms.spriteScale; this.outlineStep = labelUniforms.outlineStep; this.outlineExpand = labelUniforms.outlineExpand; const snippet = textIsSDF ? "label.outline" : "label.alpha"; const combine = this._shaders.shader().pipe(snippet, labelUniforms); // Build color lookup if (this.bind.colors) { color = this._shaders.shader(); this.bind.colors.sourceShader(color); } // Build transition mask lookup const mask = this._helpers.object.mask(); // Prepare bound uniforms const styleUniforms = this._helpers.style.uniforms(); const unitUniforms = this._inherit("unit").getUnitUniforms(); // Make sprite renderable const uniforms = UJS.merge(unitUniforms, styleUniforms, labelUniforms); this.sprite = this._renderables.make("sprite", { uniforms, width, height, depth, items, position, sprite, map, combine, color, mask, linear: true, }); this._helpers.visible.make(); return this._helpers.object.make([this.sprite]); } unmake() { this._helpers.bind.unmake(); this._helpers.visible.unmake(); this._helpers.object.unmake(); return (this.sprite = null); } resize() { // Fetch geometry/text dimensions const pointDims = this.bind.points.getActiveDimensions(); const textDims = this.bind.text.getActiveDimensions(); const items = Math.min(pointDims.items, textDims.items); const width = Math.min(pointDims.width, textDims.width); const height = Math.min(pointDims.height, textDims.height); const depth = Math.min(pointDims.depth, textDims.depth); return this.sprite.geometry.clip(width, height, depth, items); } change(changed, touched, _init) { if (touched["geometry"] || changed["label.text"]) { return this.rebuild(); } if (this.bind.points == null) { return; } const { size } = this.props; const { outline } = this.props; const { expand } = this.props; const height = this.bind.text.textHeight(); const scale = size / height; this.outlineExpand.value = ((expand / scale) * 16) / 255; this.outlineStep.value = ((outline / scale) * 16) / 255; return (this.spriteScale.value = scale); } } Label.initClass();
cchudzicki/mathbox
build/esm/primitives/types/text/label.js
JavaScript
mit
5,403
export class Retext extends Resample { textShader(shader: any): any; textIsSDF(): boolean; textHeight(): any; } import { Resample } from "../operator/resample.js";
cchudzicki/mathbox
build/esm/primitives/types/text/retext.d.ts
TypeScript
mit
176
// 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 * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Resample } from "../operator/resample.js"; export class Retext extends Resample { static initClass() { this.traits = [ "node", "bind", "operator", "resample", "sampler:x", "sampler:y", "sampler:z", "sampler:w", "include", "text", ]; } init() { return (this.sourceSpec = [{ to: "operator.source", trait: "text" }]); } textShader(shader) { return this.bind.source.textShader(shader); } textIsSDF() { return ((this.bind.source != null ? this.bind.source.props.sdf : undefined) > 0); } textHeight() { return this.bind.source != null ? this.bind.source.props.detail : undefined; } } Retext.initClass();
cchudzicki/mathbox
build/esm/primitives/types/text/retext.js
JavaScript
mit
1,230
export class Text extends Voxel { init(): null; atlas: any; textShader(shader: any): any; textIsSDF(): boolean; textHeight(): any; make(): (text: any) => any; minFilter: any; magFilter: any; type: any; } import { Voxel } from "../data/voxel.js";
cchudzicki/mathbox
build/esm/primitives/types/text/text.d.ts
TypeScript
mit
282
// 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 * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UData from "../../../util/data.js"; import { FloatType, NearestFilter } from "three/src/constants.js"; import { Buffer } from "../data/buffer.js"; import { Voxel } from "../data/voxel.js"; export class Text extends Voxel { static initClass() { this.traits = [ "node", "buffer", "active", "data", "texture", "voxel", "text", "font", ]; this.defaults = { minFilter: "linear", magFilter: "linear", }; this.finals = { channels: 1 }; } init() { super.init(); return (this.atlas = null); } textShader(shader) { return this.atlas.shader(shader); } textIsSDF() { return this.props.sdf > 0; } textHeight() { return this.props.detail; } make() { // Read sampling parameters let { minFilter, magFilter, type } = this.props; // Read font parameters const { font, style, variant, weight, detail, sdf } = this.props; // Prepare text atlas this.atlas = this._renderables.make("textAtlas", { font, size: detail, style, variant, weight, outline: sdf, minFilter, magFilter, type, }); // Underlying data buffer needs no filtering this.minFilter = NearestFilter; this.magFilter = NearestFilter; this.type = FloatType; // Skip voxel::make(), as we need 4 channels internally in our buffer to store sprite x/y/w/h per string Buffer.prototype.make.call(this); // Read sampling parameters minFilter = this.minFilter != null ? this.minFilter : this.props.minFilter; magFilter = this.magFilter != null ? this.magFilter : this.props.magFilter; type = this.type != null ? this.type : this.props.type; // Read given dimensions const { width } = this.props; const { height } = this.props; const { depth } = this.props; const reserveX = this.props.bufferWidth; const reserveY = this.props.bufferHeight; const reserveZ = this.props.bufferDepth; const { channels } = this.props; const { items } = this.props; let dims = (this.spec = { channels, items, width, height, depth }); this.items = dims.items; this.channels = dims.channels; // Init to right size if data supplied const { data } = this.props; dims = UData.getDimensions(data, dims); const { space } = this; space.width = Math.max(reserveX, dims.width || 1); space.height = Math.max(reserveY, dims.height || 1); space.depth = Math.max(reserveZ, dims.depth || 1); // Create text voxel buffer this.buffer = this._renderables.make(this.storage, { width: space.width, height: space.height, depth: space.depth, channels: 4, items, minFilter, magFilter, type, }); // Hook buffer emitter to map atlas text const { atlas } = this; const { emit } = this.buffer.streamer; return (this.buffer.streamer.emit = (text) => atlas.map(text, emit)); } unmake() { super.unmake(); if (this.atlas) { this.atlas.dispose(); return (this.atlas = null); } } update() { this.atlas.begin(); super.update(); return this.atlas.end(); } change(changed, touched, init) { if (touched["font"]) { return this.rebuild(); } return super.change(changed, touched, init); } } Text.initClass();
cchudzicki/mathbox
build/esm/primitives/types/text/text.js
JavaScript
mit
4,234
export class Clock extends Parent { init(): { now: number; time: number; delta: number; clock: number; step: number; }; skew: number | undefined; last: any; time: { now: number; time: number; delta: number; clock: number; step: number; } | undefined; make(): any; reset(): number; tick(e: any): any; getTime(): { now: number; time: number; delta: number; clock: number; step: number; } | undefined; } import { Parent } from "../base/parent.js";
cchudzicki/mathbox
build/esm/primitives/types/time/clock.d.ts
TypeScript
mit
609
// 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 * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Parent } from "../base/parent.js"; export class Clock extends Parent { static initClass() { this.traits = ["node", "clock", "seek", "play"]; } init() { this.skew = 0; this.last = 0; return (this.time = { now: +new Date() / 1000, time: 0, delta: 0, clock: 0, step: 0, }); } make() { // Listen to parent clock return this._listen("clock", "clock.tick", this.tick); } reset() { return (this.skew = 0); } tick(e) { const { from, to, speed, seek, pace, delay, realtime } = this.props; const parent = this._inherit("clock").getTime(); const time = realtime ? parent.time : parent.clock; const delta = realtime ? parent.delta : parent.step; const ratio = speed / pace; this.skew += delta * (ratio - 1); if (this.last > time) { this.skew = 0; } this.time.now = parent.now + this.skew; this.time.time = parent.time; this.time.delta = parent.delta; const clock = seek != null ? seek : parent.clock + this.skew; this.time.clock = Math.min(to, from + Math.max(0, clock - delay * ratio)); this.time.step = delta * ratio; this.last = time; return this.trigger(e); } getTime() { return this.time; } } Clock.initClass();
cchudzicki/mathbox
build/esm/primitives/types/time/clock.js
JavaScript
mit
1,849
export * from "./clock.js"; export * from "./now.js";
cchudzicki/mathbox
build/esm/primitives/types/time/index.d.ts
TypeScript
mit
54
export * from "./clock.js"; export * from "./now.js";
cchudzicki/mathbox
build/esm/primitives/types/time/index.js
JavaScript
mit
54
export class Now extends Parent { init(): { now: number; time: number; delta: number; clock: number; step: number; }; now: number | undefined; skew: any; time: { now: number; time: number; delta: number; clock: number; step: number; } | undefined; make(): any; clockParent: any; unmake(): null; change(changed: any, _touched: any, _init: any): 0 | undefined; tick(e: any): any; getTime(): { now: number; time: number; delta: number; clock: number; step: number; } | undefined; } import { Parent } from "../base/parent.js";
cchudzicki/mathbox
build/esm/primitives/types/time/now.d.ts
TypeScript
mit
695
// 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 * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Parent } from "../base/parent.js"; export class Now extends Parent { static initClass() { this.traits = ["node", "clock", "now"]; } init() { let now; this.now = now = +new Date() / 1000; this.skew = 0; return (this.time = { now, time: 0, delta: 0, clock: 0, step: 0, }); } make() { // Listen to parent clock this.clockParent = this._inherit("clock"); return this._listen("clock", "clock.tick", this.tick); } unmake() { return (this.clockParent = null); } change(changed, _touched, _init) { if (changed["date.now"]) { return (this.skew = 0); } } tick(e) { const { seek, pace, speed } = this.props; const parent = this.clockParent.getTime(); this.skew += (parent.step * pace) / speed; if (seek != null) { this.skew = seek; } this.time.now = this.time.time = this.time.clock = (this.props.now != null ? this.props.now : this.now) + this.skew; this.time.delta = this.time.step = parent.delta; return this.trigger(e); } getTime() { return this.time; } } Now.initClass();
cchudzicki/mathbox
build/esm/primitives/types/time/now.js
JavaScript
mit
1,746
export declare const Traits: { node: { id: import("./types_typed").Type<import("./types_typed").Optional<string>, string | null>; classes: import("./types_typed").Type<import("./types_typed").Optional<string | string[]>, string[]>; }; entity: { active: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; object: { visible: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; unit: { scale: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; fov: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; focus: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; span: { range: import("./types_typed").Type<unknown, unknown>; }; view: { range: import("./types_typed").Type<unknown[], unknown[]>; }; view3: { position: any; quaternion: any; rotation: any; scale: any; eulerOrder: import("./types_typed").Type<import("./types_typed").Optional<string | import("./types_typed").Axes[]>, number[]>; }; view4: { position: any; scale: any; }; layer: { depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; fit: any; }; vertex: { pass: any; }; fragment: { pass: any; gamma: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; transform3: { position: any; quaternion: any; rotation: any; eulerOrder: import("./types_typed").Type<import("./types_typed").Optional<string | import("./types_typed").Axes[]>, number[]>; scale: any; matrix: any; }; transform4: { position: any; scale: any; matrix: any; }; camera: { proxy: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; position: import("./types_typed").Type<unknown, unknown>; quaternion: import("./types_typed").Type<unknown, unknown>; rotation: import("./types_typed").Type<unknown, unknown>; lookAt: import("./types_typed").Type<unknown, unknown>; up: import("./types_typed").Type<unknown, unknown>; eulerOrder: import("./types_typed").Type<import("./types_typed").Optional<string | import("./types_typed").Axes[]>, number[]>; fov: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; }; polar: { bend: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; helix: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; spherical: { bend: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; stereographic: { bend: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; interval: { axis: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Axes>, number>; }; area: { axes: import("./types_typed").Type<import("./types_typed").Optional<string | import("./types_typed").Axes[]>, number[]>; }; volume: { axes: import("./types_typed").Type<import("./types_typed").Optional<string | import("./types_typed").Axes[]>, number[]>; }; origin: { origin: any; }; scale: { divide: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; unit: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; base: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; mode: any; start: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; end: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; zero: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; factor: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; nice: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; grid: { lineX: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; lineY: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; crossed: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; closedX: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; closedY: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; axis: { detail: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; crossed: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; data: { data: import("./types_typed").Type<unknown, unknown>; expr: import("./types_typed").Type<unknown, unknown>; bind: import("./types_typed").Type<unknown, unknown>; live: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; buffer: { channels: import("./types_typed").Type<import("./types_typed").Optional<2 | 1 | 3 | 4>, 2 | 1 | 3 | 4>; items: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; fps: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; hurry: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; limit: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; realtime: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; observe: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; aligned: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; sampler: { centered: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; padding: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; array: { width: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; bufferWidth: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; history: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; matrix: { width: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; height: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; history: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; bufferWidth: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; bufferHeight: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; voxel: { width: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; height: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; bufferWidth: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; bufferHeight: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; bufferDepth: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; resolve: { expr: import("./types_typed").Type<unknown, unknown>; items: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; style: { opacity: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; color: any; blending: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").BlendingModes>, import("./types_typed").BlendingModes>; zWrite: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; zTest: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; zIndex: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; zBias: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; zOrder: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; }; geometry: { points: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props>>; colors: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props> | null>; }; point: { size: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; sizes: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props> | null>; shape: any; optical: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; fill: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; line: { width: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; join: any; stroke: any; proximity: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; closed: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; mesh: { fill: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; shaded: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; map: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props> | null>; lineBias: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; strip: { line: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; face: { line: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; arrow: { size: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; start: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; end: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; ticks: { normal: any; size: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; epsilon: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; attach: { offset: any; snap: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; format: { digits: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; data: import("./types_typed").Type<unknown, unknown>; expr: import("./types_typed").Type<unknown, unknown>; live: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; font: { font: any; style: import("./types_typed").Type<import("./types_typed").Optional<string>, string>; variant: import("./types_typed").Type<import("./types_typed").Optional<string>, string>; weight: import("./types_typed").Type<import("./types_typed").Optional<string>, string>; detail: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; sdf: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; label: { text: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props>>; size: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; outline: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; expand: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; background: any; }; overlay: { opacity: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; zIndex: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; dom: { points: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props>>; html: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props>>; size: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; outline: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; zoom: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; color: import("./types_typed").Type<unknown, unknown>; attributes: import("./types_typed").Type<unknown, unknown>; pointerEvents: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; texture: { minFilter: any; magFilter: any; type: any; }; shader: { sources: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props> | null>; language: import("./types_typed").Type<import("./types_typed").Optional<string>, string>; code: import("./types_typed").Type<import("./types_typed").Optional<string>, string>; uniforms: import("./types_typed").Type<unknown, unknown>; }; include: { shader: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props>>; }; operator: { source: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props>>; }; spread: { unit: any; items: import("./types_typed").Type<unknown, unknown>; width: import("./types_typed").Type<unknown, unknown>; height: import("./types_typed").Type<unknown, unknown>; depth: import("./types_typed").Type<unknown, unknown>; alignItems: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Alignments>, import("./types_typed").Alignments>; alignWidth: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Alignments>, import("./types_typed").Alignments>; alignHeight: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Alignments>, import("./types_typed").Alignments>; alignDepth: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Alignments>, import("./types_typed").Alignments>; }; grow: { scale: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; items: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Alignments>, import("./types_typed").Alignments | null>; width: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Alignments>, import("./types_typed").Alignments | null>; height: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Alignments>, import("./types_typed").Alignments | null>; depth: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Alignments>, import("./types_typed").Alignments | null>; }; split: { order: import("./types_typed").Type<import("./types_typed").Optional<string | import("./types_typed").Axes[]>, number[]>; axis: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Axes>, number | null>; length: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; overlap: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; join: { order: import("./types_typed").Type<import("./types_typed").Optional<string | import("./types_typed").Axes[]>, number[]>; axis: import("./types_typed").Type<import("./types_typed").Optional<import("./types_typed").Axes>, number | null>; overlap: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; swizzle: { order: import("./types_typed").Type<import("./types_typed").Optional<string | import("./types_typed").Axes[]>, number[]>; }; transpose: { order: import("./types_typed").Type<import("./types_typed").Optional<string | import("./types_typed").Axes[]>, number[]>; }; repeat: { items: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; width: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; height: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; slice: { items: import("./types_typed").Type<unknown, unknown>; width: import("./types_typed").Type<unknown, unknown>; height: import("./types_typed").Type<unknown, unknown>; depth: import("./types_typed").Type<unknown, unknown>; }; lerp: { size: any; items: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; width: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; height: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; }; subdivide: { items: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; width: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; height: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; bevel: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; lerp: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; resample: { indices: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; channels: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; sample: any; size: any; items: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; width: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; height: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; }; readback: { type: any; expr: import("./types_typed").Type<unknown, unknown>; data: any; channels: import("./types_typed").Type<import("./types_typed").Optional<2 | 1 | 3 | 4>, 2 | 1 | 3 | 4>; items: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; width: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; height: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; depth: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; }; root: { speed: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; camera: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props>>; }; inherit: { source: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props>>; traits: import("./types_typed").Type<import("./types_typed").Optional<string>[], string[]>; }; rtt: { size: any; width: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; height: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; history: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; compose: { alpha: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; present: { index: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; directed: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; length: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; slide: { order: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; steps: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; early: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; late: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; from: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; to: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; }; transition: { stagger: any; enter: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; exit: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; delay: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; delayEnter: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; delayExit: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; duration: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; durationEnter: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; durationExit: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; }; move: { from: any; to: any; }; seek: { seek: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; }; track: { target: import("./types_typed").Type<import("./types_typed").Optional<string | import("../../types").MathboxNode<keyof import("../../types").Props>>, string | import("../../types").MathboxNode<keyof import("../../types").Props>>; script: any; ease: any; }; trigger: { trigger: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; step: { playback: any; stops: import("./types_typed").Type<import("./types_typed").Optional<number>[] | null, number[] | null>; delay: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; duration: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; pace: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; speed: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; rewind: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; skip: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; realtime: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; play: { delay: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; pace: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; speed: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; from: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; to: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; realtime: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; loop: import("./types_typed").Type<import("./types_typed").Optional<boolean>, boolean>; }; now: { now: import("./types_typed").Type<unknown, unknown>; seek: import("./types_typed").Type<import("./types_typed").Optional<number>, number | null>; pace: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; speed: import("./types_typed").Type<import("./types_typed").Optional<number>, number>; }; };
cchudzicki/mathbox
build/esm/primitives/types/traits.d.ts
TypeScript
mit
27,151
// TODO: This file was created by bulk-decaffeinate. // Sanity-check the conversion and remove this comment. import { Types } from "./types_typed"; export const Traits = { node: { id: Types.nullable(Types.string()), classes: Types.classes(), }, entity: { active: Types.bool(true), }, object: { visible: Types.bool(true), }, unit: { scale: Types.nullable(Types.number()), fov: Types.nullable(Types.number()), focus: Types.nullable(Types.number(1), true), }, span: { range: Types.nullable(Types.vec2(-1, 1)), }, view: { range: Types.array(Types.vec2(-1, 1), 4), }, view3: { position: Types.vec3(), quaternion: Types.quat(), rotation: Types.vec3(), scale: Types.vec3(1, 1, 1), eulerOrder: Types.swizzle("xyz"), }, view4: { position: Types.vec4(), scale: Types.vec4(1, 1, 1, 1), }, layer: { depth: Types.number(1), fit: Types.fit("y"), }, vertex: { pass: Types.vertexPass(), }, fragment: { pass: Types.fragmentPass(), gamma: Types.bool(false), }, transform3: { position: Types.vec3(), quaternion: Types.quat(), rotation: Types.vec3(), eulerOrder: Types.swizzle("xyz"), scale: Types.vec3(1, 1, 1), matrix: Types.mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), }, transform4: { position: Types.vec4(), scale: Types.vec4(1, 1, 1, 1), matrix: Types.mat4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), }, camera: { proxy: Types.bool(false), position: Types.nullable(Types.vec3()), quaternion: Types.nullable(Types.quat()), rotation: Types.nullable(Types.vec3()), lookAt: Types.nullable(Types.vec3()), up: Types.nullable(Types.vec3()), eulerOrder: Types.swizzle("xyz"), fov: Types.nullable(Types.number(1)), }, //ortho: Types.nullable(Types.number(0)) polar: { bend: Types.number(1), helix: Types.number(0), }, spherical: { bend: Types.number(1), }, stereographic: { bend: Types.number(1), }, interval: { axis: Types.axis(), }, area: { axes: Types.swizzle([1, 2], 2), }, volume: { axes: Types.swizzle([1, 2, 3], 3), }, origin: { origin: Types.vec4(), }, scale: { divide: Types.number(10), unit: Types.number(1), base: Types.number(10), mode: Types.scale(), start: Types.bool(true), end: Types.bool(true), zero: Types.bool(true), factor: Types.positive(Types.number(1)), nice: Types.bool(true), }, grid: { lineX: Types.bool(true), lineY: Types.bool(true), crossed: Types.bool(false), closedX: Types.bool(false), closedY: Types.bool(false), }, axis: { detail: Types.int(1), crossed: Types.bool(false), }, data: { data: Types.nullable(Types.data()), expr: Types.nullable(Types.emitter()), bind: Types.nullable(Types.func()), live: Types.bool(true), }, buffer: { channels: Types.enum(4, [1, 2, 3, 4]), items: Types.int(1), fps: Types.nullable(Types.int(60)), hurry: Types.int(5), limit: Types.int(60), realtime: Types.bool(false), observe: Types.bool(false), aligned: Types.bool(false), }, sampler: { centered: Types.bool(false), padding: Types.number(0), }, array: { width: Types.nullable(Types.positive(Types.int(1), true)), bufferWidth: Types.int(1), history: Types.int(1), }, matrix: { width: Types.nullable(Types.positive(Types.int(1), true)), height: Types.nullable(Types.positive(Types.int(1), true)), history: Types.int(1), bufferWidth: Types.int(1), bufferHeight: Types.int(1), }, voxel: { width: Types.nullable(Types.positive(Types.int(1), true)), height: Types.nullable(Types.positive(Types.int(1), true)), depth: Types.nullable(Types.positive(Types.int(1), true)), bufferWidth: Types.int(1), bufferHeight: Types.int(1), bufferDepth: Types.int(1), }, resolve: { expr: Types.nullable(Types.func()), items: Types.int(1), }, style: { opacity: Types.positive(Types.number(1)), color: Types.color(), blending: Types.blending(), zWrite: Types.bool(true), zTest: Types.bool(true), zIndex: Types.positive(Types.round()), zBias: Types.number(0), zOrder: Types.nullable(Types.int()), }, geometry: { points: Types.select(), colors: Types.nullable(Types.select()), }, point: { size: Types.positive(Types.number(4)), sizes: Types.nullable(Types.select()), shape: Types.shape(), optical: Types.bool(true), fill: Types.bool(true), depth: Types.number(1), }, line: { width: Types.positive(Types.number(2)), depth: Types.positive(Types.number(1)), join: Types.join(), stroke: Types.stroke(), proximity: Types.nullable(Types.number(Infinity)), closed: Types.bool(false), }, mesh: { fill: Types.bool(true), shaded: Types.bool(false), map: Types.nullable(Types.select()), lineBias: Types.number(5), }, strip: { line: Types.bool(false), }, face: { line: Types.bool(false), }, arrow: { size: Types.number(3), start: Types.bool(false), end: Types.bool(false), }, ticks: { normal: Types.vec3(0, 0, 1), size: Types.positive(Types.number(10)), epsilon: Types.positive(Types.number(0.001)), }, attach: { offset: Types.vec2(0, -20), snap: Types.bool(false), depth: Types.number(0), }, format: { digits: Types.nullable(Types.positive(Types.number(3))), data: Types.nullable(Types.data()), expr: Types.nullable(Types.func()), live: Types.bool(true), }, font: { font: Types.font("sans-serif"), style: Types.string(), variant: Types.string(), weight: Types.string(), detail: Types.number(24), sdf: Types.number(5), }, label: { text: Types.select(), size: Types.number(16), outline: Types.number(2), expand: Types.number(0), background: Types.color(1, 1, 1), }, overlay: { opacity: Types.number(1), zIndex: Types.positive(Types.round(0)), }, dom: { points: Types.select(), html: Types.select(), size: Types.number(16), outline: Types.number(2), zoom: Types.number(1), color: Types.nullable(Types.color()), attributes: Types.nullable(Types.object()), pointerEvents: Types.bool(false), }, texture: { minFilter: Types.filter("nearest"), magFilter: Types.filter("nearest"), type: Types.type("float"), }, shader: { sources: Types.nullable(Types.select()), language: Types.string("glsl"), code: Types.string(), uniforms: Types.nullable(Types.object()), }, include: { shader: Types.select(), }, operator: { source: Types.select(), }, spread: { unit: Types.mapping(), items: Types.nullable(Types.vec4()), width: Types.nullable(Types.vec4()), height: Types.nullable(Types.vec4()), depth: Types.nullable(Types.vec4()), alignItems: Types.anchor(), alignWidth: Types.anchor(), alignHeight: Types.anchor(), alignDepth: Types.anchor(), }, grow: { scale: Types.number(1), items: Types.nullable(Types.anchor()), width: Types.nullable(Types.anchor()), height: Types.nullable(Types.anchor()), depth: Types.nullable(Types.anchor()), }, split: { order: Types.transpose("wxyz"), axis: Types.nullable(Types.axis()), length: Types.int(1), overlap: Types.int(0), }, join: { order: Types.transpose("wxyz"), axis: Types.nullable(Types.axis()), overlap: Types.int(0), }, swizzle: { order: Types.swizzle(), }, transpose: { order: Types.transpose(), }, repeat: { items: Types.number(1), width: Types.number(1), height: Types.number(1), depth: Types.number(1), }, slice: { items: Types.nullable(Types.vec2()), width: Types.nullable(Types.vec2()), height: Types.nullable(Types.vec2()), depth: Types.nullable(Types.vec2()), }, lerp: { size: Types.mapping("absolute"), items: Types.nullable(Types.number()), width: Types.nullable(Types.number()), height: Types.nullable(Types.number()), depth: Types.nullable(Types.number()), }, subdivide: { items: Types.nullable(Types.positive(Types.int(), true)), width: Types.nullable(Types.positive(Types.int(), true)), height: Types.nullable(Types.positive(Types.int(), true)), depth: Types.nullable(Types.positive(Types.int(), true)), bevel: Types.number(1), lerp: Types.bool(true), }, resample: { indices: Types.number(4), channels: Types.number(4), sample: Types.mapping(), size: Types.mapping("absolute"), items: Types.nullable(Types.number()), width: Types.nullable(Types.number()), height: Types.nullable(Types.number()), depth: Types.nullable(Types.number()), }, readback: { type: Types.type("float"), expr: Types.nullable(Types.func()), data: Types.data(), channels: Types.enum(4, [1, 2, 3, 4]), items: Types.nullable(Types.int()), width: Types.nullable(Types.int()), height: Types.nullable(Types.int()), depth: Types.nullable(Types.int()), }, root: { speed: Types.number(1), camera: Types.select("[camera]"), }, inherit: { source: Types.select(), traits: Types.array(Types.string()), }, rtt: { size: Types.mapping("absolute"), width: Types.nullable(Types.number()), height: Types.nullable(Types.number()), history: Types.int(1), }, compose: { alpha: Types.bool(false), }, present: { index: Types.int(1), directed: Types.bool(true), length: Types.number(0), }, slide: { order: Types.nullable(Types.int(0)), steps: Types.number(1), early: Types.int(0), late: Types.int(0), from: Types.nullable(Types.int(0)), to: Types.nullable(Types.int(1)), }, transition: { stagger: Types.vec4(), enter: Types.nullable(Types.number(1)), exit: Types.nullable(Types.number(1)), delay: Types.number(0), delayEnter: Types.nullable(Types.number(0)), delayExit: Types.nullable(Types.number(0)), duration: Types.number(0.3), durationEnter: Types.nullable(Types.number(0)), durationExit: Types.nullable(Types.number(0)), }, move: { from: Types.vec4(), to: Types.vec4(), }, seek: { seek: Types.nullable(Types.number(0)), }, track: { target: Types.select(), script: Types.object({}), ease: Types.ease("cosine"), }, trigger: { trigger: Types.nullable(Types.int(1), true), }, step: { playback: Types.ease("linear"), stops: Types.nullable(Types.array(Types.number())), delay: Types.number(0), duration: Types.number(0.3), pace: Types.number(0), speed: Types.number(1), rewind: Types.number(2), skip: Types.bool(true), realtime: Types.bool(false), }, play: { delay: Types.number(0), pace: Types.number(1), speed: Types.number(1), from: Types.number(0), to: Types.number(Infinity), realtime: Types.bool(false), loop: Types.bool(false), }, now: { now: Types.nullable(Types.timestamp()), seek: Types.nullable(Types.number(0)), pace: Types.number(1), speed: Types.number(1), }, };
cchudzicki/mathbox
build/esm/primitives/types/traits.js
JavaScript
mit
12,658
export class Fragment extends Transform { make(): any; unmake(): any; } import { Transform } from "./transform.js";
cchudzicki/mathbox
build/esm/primitives/types/transform/fragment.d.ts
TypeScript
mit
124
// 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 * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Transform } from "./transform.js"; export class Fragment extends Transform { static initClass() { this.traits = ["node", "include", "fragment", "bind"]; } make() { // Bind to attached shader return this._helpers.bind.make([ { to: "include.shader", trait: "shader", optional: true }, ]); } unmake() { return this._helpers.bind.unmake(); } change(changed, touched, _init) { if (touched["include"] || changed["fragment.gamma"]) { return this.rebuild(); } } fragment(shader, pass) { if (this.bind.shader != null) { if (pass === this.props.pass) { if (this.props.gamma) { shader.pipe("mesh.gamma.out"); } shader.pipe(this.bind.shader.shaderBind()); shader.split(); if (this.props.gamma) { shader.pipe("mesh.gamma.in"); } shader.pass(); } } return super.fragment(shader, pass); } } Fragment.initClass();
cchudzicki/mathbox
build/esm/primitives/types/transform/fragment.js
JavaScript
mit
1,542
export * from "./transform.js"; export * from "./transform3.js"; export * from "./transform4.js"; export * from "./vertex.js"; export * from "./fragment.js"; export * from "./layer.js"; export * from "./mask.js";
cchudzicki/mathbox
build/esm/primitives/types/transform/index.d.ts
TypeScript
mit
213
export * from "./transform.js"; export * from "./transform3.js"; export * from "./transform4.js"; export * from "./vertex.js"; export * from "./fragment.js"; export * from "./layer.js"; export * from "./mask.js";
cchudzicki/mathbox
build/esm/primitives/types/transform/index.js
JavaScript
mit
213
export class Layer extends Transform { make(): { layerScale: any; layerBias: any; }; uniforms: { layerScale: any; layerBias: any; } | undefined; update(): any; change(changed: any, touched: any, init: any): any; } import { Transform } from "./transform.js";
cchudzicki/mathbox
build/esm/primitives/types/transform/layer.d.ts
TypeScript
mit
314
// 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 * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Transform } from "./transform.js"; export class Layer extends Transform { static initClass() { this.traits = ["node", "vertex", "layer"]; } make() { this._listen("root", "root.resize", this.update); return (this.uniforms = { layerScale: this._attributes.make(this._types.vec4()), layerBias: this._attributes.make(this._types.vec4()), }); } update() { const camera = this._inherit("root").getCamera(); const aspect = camera.aspect != null ? camera.aspect : 1; const fov = camera.fov != null ? camera.fov : 1; const pitch = Math.tan((fov * Math.PI) / 360); const _enum = this.node.attributes["layer.fit"].enum; let { fit } = this.props; const { depth } = this.props; // Convert contain/cover into x/y switch (fit) { case _enum.contain: fit = aspect > 1 ? _enum.y : _enum.x; break; case _enum.cover: fit = aspect > 1 ? _enum.x : _enum.y; break; } // Fit x/y switch (fit) { case _enum.x: this.uniforms.layerScale.value.set(pitch * aspect, pitch * aspect); break; case _enum.y: this.uniforms.layerScale.value.set(pitch, pitch); break; } return this.uniforms.layerBias.value.set(0, 0, -depth, 0); } change(changed, touched, init) { if (changed["layer.fit"] || changed["layer.depth"] || init) { return this.update(); } } // End transform chain here without applying camera view vertex(shader, pass) { if (pass === 2) { return shader.pipe("layer.position", this.uniforms); } if (pass === 3) { return shader.pipe("root.position"); } return shader; } } Layer.initClass();
cchudzicki/mathbox
build/esm/primitives/types/transform/layer.js
JavaScript
mit
2,366
export class Mask extends Parent { make(): any; unmake(): any; mask(shader: any): any; } import { Parent } from "../base/parent.js";
cchudzicki/mathbox
build/esm/primitives/types/transform/mask.d.ts
TypeScript
mit
145
// 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 * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining * DS104: Avoid inline assignments * DS206: Consider reworking classes to avoid initClass * 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 { Parent } from "../base/parent.js"; export class Mask extends Parent { static initClass() { this.traits = ["node", "include", "mask", "bind"]; } make() { // Bind to attached shader return this._helpers.bind.make([ { to: "include.shader", trait: "shader", optional: true }, ]); } unmake() { return this._helpers.bind.unmake(); } change(changed, touched, _init) { if (touched["include"]) { return this.rebuild(); } } mask(shader) { let left, s; if (this.bind.shader != null) { if (shader) { s = this._shaders.shader(); s.pipe(UGLSL.identity("vec4")); s.fan(); s.pipe(shader); s.next(); s.pipe(this.bind.shader.shaderBind()); s.end(); s.pipe("float combine(float a, float b) { return min(a, b); }"); } else { s = this._shaders.shader(); s.pipe(this.bind.shader.shaderBind()); } } else { s = shader; } return (left = __guard__(this._inherit("mask"), (x) => x.mask(s))) != null ? left : s; } } Mask.initClass(); function __guard__(value, transform) { return typeof value !== "undefined" && value !== null ? transform(value) : undefined; }
cchudzicki/mathbox
build/esm/primitives/types/transform/mask.js
JavaScript
mit
2,066
export class Transform extends Parent { vertex(shader: any, pass: any): any; fragment(shader: any, pass: any): any; } import { Parent } from "../base/parent.js";
cchudzicki/mathbox
build/esm/primitives/types/transform/transform.d.ts
TypeScript
mit
170
// 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 * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining * DS104: Avoid inline assignments * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Parent } from "../base/parent.js"; export class Transform extends Parent { static initClass() { this.traits = ["node", "vertex", "fragment"]; } vertex(shader, pass) { let left; return (left = __guard__(this._inherit("vertex"), (x) => x.vertex(shader, pass))) != null ? left : shader; } fragment(shader, pass) { let left; return (left = __guard__(this._inherit("fragment"), (x) => x.fragment(shader, pass))) != null ? left : shader; } } Transform.initClass(); function __guard__(value, xform) { return typeof value !== "undefined" && value !== null ? xform(value) : undefined; }
cchudzicki/mathbox
build/esm/primitives/types/transform/transform.js
JavaScript
mit
1,263
export class Transform3 extends Transform { make(): (position: any, rotation: any, quaternion: any, scale: any, matrix: any, eulerOrder: any) => any; uniforms: { transformMatrix: any; } | undefined; composer: ((position: any, rotation: any, quaternion: any, scale: any, matrix: any, eulerOrder: any) => any) | undefined; unmake(): boolean; change(changed: any, touched: any, init: any): any; } import { Transform } from "./transform.js";
cchudzicki/mathbox
build/esm/primitives/types/transform/transform3.d.ts
TypeScript
mit
470
// 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 * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UThree from "../../../util/three.js"; import { Transform } from "./transform.js"; export class Transform3 extends Transform { static initClass() { this.traits = ["node", "vertex", "transform3"]; } make() { this.uniforms = { transformMatrix: this._attributes.make(this._types.mat4()), }; return (this.composer = UThree.transformComposer()); } unmake() { return delete this.uniforms; } change(changed, touched, init) { if (changed["transform3.pass"]) { return this.rebuild(); } if (!touched["transform3"] && !init) { return; } const p = this.props.position; const q = this.props.quaternion; const r = this.props.rotation; const s = this.props.scale; const m = this.props.matrix; const e = this.props.eulerOrder; return (this.uniforms.transformMatrix.value = this.composer(p, r, q, s, m, e)); } vertex(shader, pass) { if (pass === this.props.pass) { shader.pipe("transform3.position", this.uniforms); } return super.vertex(shader, pass); } } Transform3.initClass();
cchudzicki/mathbox
build/esm/primitives/types/transform/transform3.js
JavaScript
mit
1,577
export class Transform4 extends Transform { make(): any; uniforms: { transformMatrix: any; transformOffset: any; } | undefined; transformMatrix: any; unmake(): boolean; change(changed: any, touched: any, init: any): any; } import { Transform } from "./transform.js";
cchudzicki/mathbox
build/esm/primitives/types/transform/transform4.d.ts
TypeScript
mit
307
// 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 * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Transform } from "./transform.js"; export class Transform4 extends Transform { static initClass() { this.traits = ["node", "vertex", "transform4"]; } make() { this.uniforms = { transformMatrix: this._attributes.make(this._types.mat4()), transformOffset: this.node.attributes["transform4.position"], }; return (this.transformMatrix = this.uniforms.transformMatrix.value); } unmake() { return delete this.uniforms; } change(changed, touched, init) { if (changed["transform4.pass"]) { return this.rebuild(); } if (!touched["transform4"] && !init) { return; } const s = this.props.scale; const m = this.props.matrix; const t = this.transformMatrix; t.copy(m); return t.scale(s); } vertex(shader, pass) { if (pass === this.props.pass) { shader.pipe("transform4.position", this.uniforms); } return super.vertex(shader, pass); } } Transform4.initClass();
cchudzicki/mathbox
build/esm/primitives/types/transform/transform4.js
JavaScript
mit
1,455
export class Vertex extends Transform { make(): any; unmake(): any; } import { Transform } from "./transform.js";
cchudzicki/mathbox
build/esm/primitives/types/transform/vertex.d.ts
TypeScript
mit
122
// 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 * DS206: Consider reworking classes to avoid initClass * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Transform } from "./transform.js"; export class Vertex extends Transform { static initClass() { this.traits = ["node", "include", "vertex", "bind"]; } make() { // Bind to attached shader return this._helpers.bind.make([ { to: "include.shader", trait: "shader", optional: true }, ]); } unmake() { return this._helpers.bind.unmake(); } change(changed, touched, _init) { if (touched["include"]) { return this.rebuild(); } } vertex(shader, pass) { if (this.bind.shader != null) { if (pass === this.props.pass) { shader.pipe(this.bind.shader.shaderBind()); } } return super.vertex(shader, pass); } } Vertex.initClass();
cchudzicki/mathbox
build/esm/primitives/types/transform/vertex.js
JavaScript
mit
1,223
export const Types: any;
cchudzicki/mathbox
build/esm/primitives/types/types.d.ts
TypeScript
mit
25
// 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 * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining * DS104: Avoid inline assignments * 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 * as UData from "../../util/data.js"; import * as UJS from "../../util/js.js"; import { ByteType, FloatType, IntType, LinearFilter, LinearMipMapLinearFilter, LinearMipMapNearestFilter, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, ShortType, UnsignedByteType, UnsignedIntType, UnsignedShortType, } from "three/src/constants.js"; import { Color } from "three/src/math/Color.js"; import { Matrix3 } from "three/src/math/Matrix3.js"; import { Matrix4 } from "three/src/math/Matrix4.js"; import { Quaternion } from "three/src/math/Quaternion.js"; import { Vector2 } from "three/src/math/Vector2.js"; import { Vector3 } from "three/src/math/Vector3.js"; import { Vector4 } from "three/src/math/Vector4.js"; // Property types // // The weird calling convention is for double-buffering the values // while validating compound types like arrays and nullables. // // validate: (value, target, invalid) -> // // # Option 1: Call invalid() to reject // return invalid() if value < 0 // // # Option 2: Change target in-place // target.set(value) // return target // // # Option 3: Return new value // return +value // const _Types = { array(type, size, value = null) { const lerp = type.lerp ? function (a, b, target, f) { const l = Math.min(a.length, b.length); for (let i = 0, end = l, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { target[i] = type.lerp(a[i], b[i], target[i], f); } return target; } : undefined; const op = type.op ? function (a, b, target, op) { const l = Math.min(a.length, b.length); for (let i = 0, end = l, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { target[i] = type.op(a[i], b[i], target[i], op); } return target; } : undefined; if (value != null && !(value instanceof Array)) { value = [value]; } return { uniform() { if (type.uniform) { return type.uniform() + "v"; } else { return undefined; } }, make() { if (value != null) { return value.slice(); } if (!size) { return []; } return __range__(0, size, false).map((_i) => type.make()); }, validate(value, target, invalid) { if (!(value instanceof Array)) { value = [value]; } const l = (target.length = size ? size : value.length); for (let i = 0, end = l, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { const input = value[i] != null ? value[i] : type.make(); target[i] = type.validate(input, target[i], invalid); } return target; }, equals(a, b) { const al = a.length; const bl = b.length; if (al !== bl) { return false; } const l = Math.min(al, bl); for (let i = 0, end = l, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { if (!(typeof type.equals === "function" ? type.equals(a[i], b[i]) : undefined)) { return false; } } return true; }, lerp, op, clone(v) { return Array.from(v).map((x) => type.clone(x)); }, }; }, letters(type, size, value = null) { if (value != null) { if (value === "" + value) { value = value.split(""); } for (let i = 0; i < value.length; i++) { const v = value[i]; value[i] = type.validate(v, v); } } const array = Types.array(type, size, value); return { uniform() { return array.uniform(); }, make() { return array.make(); }, validate(value, target, invalid) { if (value === "" + value) { value = value.split(""); } return array.validate(value, target, invalid); }, equals(a, b) { return array.equals(a, b); }, clone: array.clone, }; }, nullable(type, make) { if (make == null) { make = false; } let value = make ? type.make() : null; const emitter = type.emitter ? function (expr1, expr2) { if (expr2 == null) { return expr1; } if (expr1 == null) { return expr2; } return type.emitter(expr1, expr2); } : undefined; const lerp = type.lerp ? function (a, b, target, f) { if (a === null || b === null) { if (f < 0.5) { return a; } else { return b; } } if (target == null) { target = type.make(); } value = type.lerp(a, b, target, f); return target; } : undefined; const op = type.op ? function (a, b, target, op) { if (a === null || b === null) { return null; } if (target == null) { target = type.make(); } value = type.op(a, b, target, op); return value; } : undefined; return { make() { return value; }, validate(value, target, invalid) { if (value === null) { return value; } if (target === null) { target = type.make(); } return type.validate(value, target, invalid); }, uniform() { return typeof type.uniform === "function" ? type.uniform() : undefined; }, equals(a, b) { let left; const an = a === null; const bn = b === null; if (an && bn) { return true; } if (an ^ bn) { return false; } return (left = typeof type.equals === "function" ? type.equals(a, b) : undefined) != null ? left : a === b; }, lerp, op, emitter, }; }, enum(value, keys, map) { let key; if (keys == null) { keys = []; } if (map == null) { map = {}; } let i = 0; const values = {}; for (key of Array.from(keys)) { if (key !== +key) { if (map[key] == null) { map[key] = i++; } } } for (key of Array.from(keys)) { if (key === +key) { values[key] = key; } } for (key in map) { i = map[key]; values[i] = true; } if (values[value] == null) { value = map[value]; } return { enum() { return map; }, make() { return value; }, validate(value, target, invalid) { const v = values[value] ? value : map[value]; if (v != null) { return v; } return invalid(); }, }; }, enumber(value, keys, map) { if (map == null) { map = {}; } const _enum = Types.enum(value, keys, map); return { enum: _enum.enum, uniform() { return "f"; }, make() { let left; return (left = _enum.make()) != null ? left : +value; }, validate(value, target, invalid) { if (value === +value) { return value; } return _enum.validate(value, target, invalid); }, op(a, b, target, op) { return op(a, b); }, }; }, select(value) { if (value == null) { value = "<"; } value; return { make() { return value; }, validate(value, target, invalid) { if (typeof value === "string") { return value; } if (typeof value === "object") { return value; } return invalid(); }, }; }, bool(value) { value = !!value; return { uniform() { return "f"; }, make() { return value; }, validate(value, _target, _invalid) { return !!value; }, }; }, int(value) { if (value == null) { value = 0; } value = +Math.round(value); return { uniform() { return "i"; }, make() { return value; }, validate(value, target, invalid) { let x; if (value !== (x = +value)) { return invalid(); } return Math.round(x) || 0; }, op(a, b, target, op) { return op(a, b); }, }; }, round(value) { if (value == null) { value = 0; } value = +Math.round(value); return { uniform() { return "f"; }, make() { return value; }, validate(value, target, invalid) { let x; if (value !== (x = +value)) { return invalid(); } return Math.round(x) || 0; }, op(a, b, target, op) { return op(a, b); }, }; }, number(value) { if (value == null) { value = 0; } return { uniform() { return "f"; }, make() { return +value; }, validate(value, target, invalid) { let x; if (value !== (x = +value)) { return invalid(); } return x || 0; }, op(a, b, target, op) { return op(a, b); }, }; }, positive(type, strict) { if (strict == null) { strict = false; } return { uniform: type.uniform, make: type.make, validate(value, target, invalid) { value = type.validate(value, target, invalid); if (value < 0 || (strict && value <= 0)) { return invalid(); } return value; }, op(a, b, target, op) { return op(a, b); }, }; }, string(value) { if (value == null) { value = ""; } return { make() { return "" + value; }, validate(value, target, invalid) { let x; if (value !== (x = "" + value)) { return invalid(); } return x; }, }; }, func() { return { make() { return function () { }; }, validate(value, target, invalid) { if (typeof value === "function") { return value; } return invalid(); }, }; }, emitter() { return { make() { return (emit) => emit(1, 1, 1, 1); }, validate(value, target, invalid) { if (typeof value === "function") { return value; } return invalid(); }, emitter(a, b) { return UData.getLerpEmitter(a, b); }, }; }, object(value) { return { make() { return value != null ? value : {}; }, validate(value, target, invalid) { if (typeof value === "object") { return value; } return invalid(); }, clone(v) { return JSON.parse(JSON.stringify(v)); }, }; }, timestamp(value = null) { if (typeof value === "string") { value = Date.parse(value); } return { uniform() { return "f"; }, make() { return value != null ? value : +new Date(); }, validate(value, target, invalid) { value = Date.parse(value); if (value !== +value) { return invalid(); } return value; }, op(a, b, target, op) { return op(a, b); }, }; }, vec2(x, y) { if (x == null) { x = 0; } if (y == null) { y = 0; } const defaults = [x, y]; return { uniform() { return "v2"; }, make() { return new Vector2(x, y); }, validate(value, target, invalid) { if (value === +value) { value = [value]; } if (value instanceof Vector2) { target.copy(value); } else if (value instanceof Array) { value = value.concat(defaults.slice(value.length)); target.set.apply(target, value); } else if (value != null) { const xx = value.x != null ? value.x : x; const yy = value.y != null ? value.y : y; target.set(xx, yy); } else { return invalid(); } return target; }, equals(a, b) { return a.x === b.x && a.y === b.y; }, op(a, b, target, op) { target.x = op(a.x, b.x); target.y = op(a.y, b.y); return target; }, }; }, ivec2(x, y) { if (x == null) { x = 0; } if (y == null) { y = 0; } const vec2 = Types.vec2(x, y); const { validate } = vec2; vec2.validate = function (value, target, invalid) { validate(value, target, invalid); target.x = Math.round(target.x); target.y = Math.round(target.y); return target; }; return vec2; }, vec3(x, y, z) { if (x == null) { x = 0; } if (y == null) { y = 0; } if (z == null) { z = 0; } const defaults = [x, y, z]; return { uniform() { return "v3"; }, make() { return new Vector3(x, y, z); }, validate(value, target, invalid) { if (value === +value) { value = [value]; } if (value instanceof Vector3) { target.copy(value); } else if (value instanceof Array) { value = value.concat(defaults.slice(value.length)); target.set.apply(target, value); } else if (value != null) { const xx = value.x != null ? value.x : x; const yy = value.y != null ? value.y : y; const zz = value.z != null ? value.z : z; target.set(xx, yy, zz); } else { return invalid(); } return target; }, equals(a, b) { return a.x === b.x && a.y === b.y && a.z === b.z; }, op(a, b, target, op) { target.x = op(a.x, b.x); target.y = op(a.y, b.y); target.z = op(a.z, b.z); return target; }, }; }, ivec3(x, y, z) { if (x == null) { x = 0; } if (y == null) { y = 0; } if (z == null) { z = 0; } const vec3 = Types.vec3(x, y, z); const { validate } = vec3; vec3.validate = function (value, target, invalid) { validate(value, target, invalid); target.x = Math.round(target.x); target.y = Math.round(target.y); target.z = Math.round(target.z); return target; }; return vec3; }, vec4(x, y, z, w) { if (x == null) { x = 0; } if (y == null) { y = 0; } if (z == null) { z = 0; } if (w == null) { w = 0; } const defaults = [x, y, z, w]; return { uniform() { return "v4"; }, make() { return new Vector4(x, y, z, w); }, validate(value, target, invalid) { if (value === +value) { value = [value]; } if (value instanceof Vector4) { target.copy(value); } else if (value instanceof Array) { value = value.concat(defaults.slice(value.length)); target.set.apply(target, value); } else if (value != null) { const xx = value.x != null ? value.x : x; const yy = value.y != null ? value.y : y; const zz = value.z != null ? value.z : z; const ww = value.w != null ? value.w : w; target.set(xx, yy, zz, ww); } else { return invalid(); } return target; }, equals(a, b) { return a.x === b.x && a.y === b.y && a.z === b.z && a.w === b.w; }, op(a, b, target, op) { target.x = op(a.x, b.x); target.y = op(a.y, b.y); target.z = op(a.z, b.z); target.w = op(a.w, b.w); return target; }, }; }, ivec4(x, y, z, w) { if (x == null) { x = 0; } if (y == null) { y = 0; } if (z == null) { z = 0; } if (w == null) { w = 0; } const vec4 = Types.vec4(x, y, z, w); const { validate } = vec4; vec4.validate = function (value, target, invalid) { validate(value, target, invalid); target.x = Math.round(target.x); target.y = Math.round(target.y); target.z = Math.round(target.z); target.w = Math.round(target.w); return target; }; return vec4; }, mat3(n11, n12, n13, n21, n22, n23, n31, n32, n33) { if (n11 == null) { n11 = 1; } if (n12 == null) { n12 = 0; } if (n13 == null) { n13 = 0; } if (n21 == null) { n21 = 0; } if (n22 == null) { n22 = 1; } if (n23 == null) { n23 = 0; } if (n31 == null) { n31 = 0; } if (n32 == null) { n32 = 0; } if (n33 == null) { n33 = 1; } const defaults = [n11, n12, n13, n21, n22, n23, n31, n32, n33]; return { uniform() { return "m4"; }, make() { const m = new Matrix3(); m.set(n11, n12, n13, n21, n22, n23, n31, n32, n33); return m; }, validate(value, target, invalid) { if (value instanceof Matrix3) { target.copy(value); } else if (value instanceof Array) { value = value.concat(defaults.slice(value.length)); target.set.apply(target, value); } else { return invalid(); } return target; }, }; }, mat4(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) { if (n11 == null) { n11 = 1; } if (n12 == null) { n12 = 0; } if (n13 == null) { n13 = 0; } if (n14 == null) { n14 = 0; } if (n21 == null) { n21 = 0; } if (n22 == null) { n22 = 1; } if (n23 == null) { n23 = 0; } if (n24 == null) { n24 = 0; } if (n31 == null) { n31 = 0; } if (n32 == null) { n32 = 0; } if (n33 == null) { n33 = 1; } if (n34 == null) { n34 = 0; } if (n41 == null) { n41 = 0; } if (n42 == null) { n42 = 0; } if (n43 == null) { n43 = 0; } if (n44 == null) { n44 = 1; } const defaults = [ n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44, ]; return { uniform() { return "m4"; }, make() { const m = new Matrix4(); m.set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44); return m; }, validate(value, target, invalid) { if (value instanceof Matrix4) { target.copy(value); } else if (value instanceof Array) { value = value.concat(defaults.slice(value.length)); target.set.apply(target, value); } else { return invalid(); } return target; }, }; }, quat(x, y, z, w) { if (x == null) { x = 0; } if (y == null) { y = 0; } if (z == null) { z = 0; } if (w == null) { w = 1; } const vec4 = Types.vec4(x, y, z, w); return { uniform() { return "v4"; }, make() { return new Quaternion(); }, validate(value, target, invalid) { if (value instanceof Quaternion) { target.copy(value); } else { target = vec4.validate(value, target, invalid); } target.normalize(); return target; }, equals(a, b) { return a.x === b.x && a.y === b.y && a.z === b.z && a.w === b.w; }, op(a, b, target, op) { target.x = op(a.x, b.x); target.y = op(a.y, b.y); target.z = op(a.z, b.z); target.w = op(a.w, b.w); target.normalize(); return target; }, lerp(a, b, target, f) { if (target.slerpQuaternions) { // NOTE: slerpQuaternions replaced the static slerp method in three.js // r127. This switch removes the deprecation warning and keeps the // project three.js compatible across this version. target.slerpQuaternions(a, b, f); } else { Quaternion.slerp(a, b, target, f); } return target; }, }; }, color(r, g, b) { if (r == null) { r = 0.5; } if (g == null) { g = 0.5; } if (b == null) { b = 0.5; } const defaults = [r, g, b]; return { uniform() { return "c"; }, make() { return new Color(r, g, b); }, validate(value, target, invalid) { if (value === "" + value) { value = new Color().setStyle(value); } else if (value === +value) { value = new Color(value); } if (value instanceof Color) { target.copy(value); } else if (value instanceof Array) { value = value.concat(defaults.slice(value.length)); target.setRGB.apply(target, value); } else if (value != null) { const rr = value.r != null ? value.r : r; const gg = value.g != null ? value.g : g; const bb = value.b != null ? value.b : b; target.set(rr, gg, bb); } else { return invalid(); } return target; }, equals(a, b) { return a.r === b.r && a.g === b.g && a.b === b.b; }, op(a, b, target, op) { target.r = op(a.r, b.r); target.g = op(a.g, b.g); target.b = op(a.b, b.b); return target; }, }; }, axis(value, allowZero) { let v; if (value == null) { value = 1; } if (allowZero == null) { allowZero = false; } const map = { x: 1, y: 2, z: 3, w: 4, W: 1, H: 2, D: 3, I: 4, zero: 0, null: 0, width: 1, height: 2, depth: 3, items: 4, }; const range = allowZero ? [0, 1, 2, 3, 4] : [1, 2, 3, 4]; if ((v = map[value]) != null) { value = v; } return { make() { return value; }, validate(value, target, invalid) { let left; if ((v = map[value]) != null) { value = v; } value = (left = Math.round(value)) != null ? left : 0; if (Array.from(range).includes(value)) { return value; } return invalid(); }, }; }, transpose(order) { if (order == null) { order = [1, 2, 3, 4]; } const looseArray = Types.letters(Types.axis(null, false), 0, order); const axesArray = Types.letters(Types.axis(null, false), 4, order); return { make() { return axesArray.make(); }, validate(value, target, invalid) { let temp = [1, 2, 3, 4]; looseArray.validate(value, temp, invalid); if (temp.length < 4) { const missing = [1, 2, 3, 4].filter((x) => temp.indexOf(x) === -1); temp = temp.concat(missing); } const unique = Array.from(temp).map((letter, i) => temp.indexOf(letter) === i); if (unique.indexOf(false) < 0) { return axesArray.validate(temp, target, invalid); } return invalid(); }, equals: axesArray.equals, clone: axesArray.clone, }; }, swizzle(order, size = null) { if (order == null) { order = [1, 2, 3, 4]; } if (size == null) { size = order.length; } order = order.slice(0, size); const looseArray = Types.letters(Types.axis(null, false), 0, order); const axesArray = Types.letters(Types.axis(null, true), size, order); return { make() { return axesArray.make(); }, validate(value, target, invalid) { let temp = order.slice(); looseArray.validate(value, temp, invalid); if (temp.length < size) { temp = temp.concat([0, 0, 0, 0]).slice(0, size); } return axesArray.validate(temp, target, invalid); }, equals: axesArray.equals, clone: axesArray.clone, }; }, classes() { const stringArray = Types.array(Types.string()); return { make() { return stringArray.make(); }, validate(value, target, invalid) { if (value === "" + value) { value = value.split(" "); } value = value.filter((x) => !!x.length); return stringArray.validate(value, target, invalid); }, equals: stringArray.equals, clone: stringArray.clone, }; }, blending(value) { if (value == null) { value = "normal"; } const keys = ["no", "normal", "add", "subtract", "multiply", "custom"]; return Types.enum(value, keys); }, filter(value) { if (value == null) { value = "nearest"; } const map = { nearest: NearestFilter, nearestMipMapNearest: NearestMipMapNearestFilter, nearestMipMapLinear: NearestMipMapLinearFilter, linear: LinearFilter, linearMipMapNearest: LinearMipMapNearestFilter, linearMipmapLinear: LinearMipMapLinearFilter, }; return Types.enum(value, [], map); }, type(value) { if (value == null) { value = "unsignedByte"; } const map = { unsignedByte: UnsignedByteType, byte: ByteType, short: ShortType, unsignedShort: UnsignedShortType, int: IntType, unsignedInt: UnsignedIntType, float: FloatType, }; return Types.enum(value, [], map); }, scale(value) { if (value == null) { value = "linear"; } const keys = ["linear", "log"]; return Types.enum(value, keys); }, mapping(value) { if (value == null) { value = "relative"; } const keys = ["relative", "absolute"]; return Types.enum(value, keys); }, indexing(value) { if (value == null) { value = "original"; } const keys = ["original", "final"]; return Types.enum(value, keys); }, shape(value) { if (value == null) { value = "circle"; } const keys = ["circle", "square", "diamond", "up", "down", "left", "right"]; return Types.enum(value, keys); }, join(value) { if (value == null) { value = "miter"; } const keys = ["miter", "round", "bevel"]; return Types.enum(value, keys); }, stroke(value) { if (value == null) { value = "solid"; } const keys = ["solid", "dotted", "dashed"]; return Types.enum(value, keys); }, vertexPass(value) { if (value == null) { value = "view"; } const keys = ["data", "view", "world", "eye"]; return Types.enum(value, keys); }, fragmentPass(value) { if (value == null) { value = "light"; } const keys = ["color", "light", "rgba"]; return Types.enum(value, keys); }, ease(value) { if (value == null) { value = "linear"; } const keys = ["linear", "cosine", "binary", "hold"]; return Types.enum(value, keys); }, fit(value) { if (value == null) { value = "contain"; } const keys = ["x", "y", "contain", "cover"]; return Types.enum(value, keys); }, anchor(value) { if (value == null) { value = "middle"; } const map = { first: 1, middle: 0, last: -1, }; return Types.enumber(value, [], map); }, transitionState(value) { if (value == null) { value = "enter"; } const map = { enter: -1, visible: 0, exit: 1, }; return Types.enumber(value, [], map); }, font(value) { if (value == null) { value = "sans-serif"; } const parse = UJS.parseQuoted; if (!(value instanceof Array)) { value = parse(value); } const stringArray = Types.array(Types.string(), 0, value); return { make() { return stringArray.make(); }, validate(value, target, invalid) { try { if (!(value instanceof Array)) { value = parse(value); } } catch (error) { return invalid(); } value = value.filter((x) => !!x.length); return stringArray.validate(value, target, invalid); }, equals: stringArray.equals, clone: stringArray.clone, }; }, data(value) { if (value == null) { value = []; } return { make() { return []; }, validate(value, target, invalid) { if (value instanceof Array) { return value; } else if ((value != null ? value.length : undefined) != null) { return value; } else { return invalid(); } }, emitter(a, b) { return UData.getLerpThunk(a, b); }, }; }, }; const decorate = function (types) { for (const k in types) { const type = types[k]; types[k] = ((type) => function () { const t = type.apply(type, arguments); if (t.validate == null) { t.validate = (v) => v != null; } if (t.equals == null) { t.equals = (a, b) => a === b; } if (t.clone == null) { t.clone = function (v) { let left; return (left = __guardMethod__(v, "clone", (o) => o.clone())) != null ? left : v; }; } return t; })(type); } return types; }; export const Types = decorate(_Types); function __range__(left, right, inclusive) { const range = []; const ascending = left < right; const end = !inclusive ? right : ascending ? right + 1 : right - 1; for (let i = left; ascending ? i < end : i > end; ascending ? i++ : i--) { range.push(i); } return range; } function __guardMethod__(obj, methodName, transform) { if (typeof obj !== "undefined" && obj !== null && typeof obj[methodName] === "function") { return transform(obj, methodName); } else { return undefined; } }
cchudzicki/mathbox
build/esm/primitives/types/types.js
JavaScript
mit
38,531
/** * Manual typings for types.js. * * Why not name this types.d.ts? Because then it won't be included in the build, * see https://stackoverflow.com/a/56440335/2747370. dts files are good for * specifying types that are only consumed in our source code, but no good for * specifying types that should be included in the output. */ import type { MathboxNode } from "../../types"; declare type OnInvalid = () => void; declare type Validate<In, Out> = (value: In, target: unknown, invalid: OnInvalid) => Out; export interface Type<In, Out> { validate: Validate<In, Out>; make(): Out; } export declare type Optional<T> = T | null | undefined; export declare type BlendingModes = "no" | "normal" | "add" | "subtract" | "multiply" | "custom"; export declare type Axes = "x" | "y" | "z" | "w" | "W" | "H" | "D" | "I" | "width" | "height" | "depth" | "items" | 1 | 2 | 3 | 4; export declare type AxesWithZero = Axes | 0 | "zero" | "null"; /** * Values 'left' and 'right' correspond to -1 and +1, respectively. */ export declare type Alignments = "left" | "middle" | "right" | number; /** * If specified as a number, should range between -1 ("enter") to +1 ("exit"). */ export declare type TransitionStates = "enter" | "visible" | "exiit" | number; export declare type TypeGenerators = { nullable<I, O>(type: Type<I, O>): Type<null | I, null | O>; nullable<I, O>(type: Type<I, O>, make: true): Type<null | I, O>; array<I, O>(type: Type<I, O>, size?: number, value?: O): Type<I[], O[]>; string(defaultValue?: string): Type<Optional<string>, string>; bool(defaultValue?: boolean): Type<Optional<boolean>, boolean>; number(defaultValue?: number): Type<Optional<number>, number>; enum<E extends string | number>(value: E, keys: E[], map?: Record<E, number>): Type<Optional<E>, E>; enumber<E extends string | number>(value: E | number, keys: E[], map?: Record<E, number>): Type<Optional<E | number>, E | number>; classes(): Type<Optional<string | string[]>, string[]>; blending(defaultValue?: BlendingModes): Type<Optional<BlendingModes>, BlendingModes>; anchor(defaultValue?: Alignments): Type<Optional<Alignments>, Alignments>; transitionState(defaultValue?: TransitionStates): Type<Optional<TransitionStates>, TransitionStates>; axis(value?: Axes, allowZero?: false): Type<Optional<Axes>, number>; axis(value: AxesWithZero, allowZero: true): Type<Optional<AxesWithZero>, number>; select(defaultValue?: string): Type<Optional<string | MathboxNode>, string | MathboxNode>; letters<I, O>(type: Type<I, O>, size?: number, value?: string): Type<Optional<string | I[]>, O[]>; int(value?: number): Type<Optional<number>, number>; round(value?: number): Type<Optional<number>, number>; positive<I, O extends number>(type: Type<I, O>, strict?: boolean): Type<I, O>; func: any; emitter: any; object: any; timestamp: any; vec2: any; ivec2: any; vec3: any; ivec3: any; vec4: any; ivec4: any; mat3: any; mat4: any; quat: any; color: any; transpose(order?: string | Axes[]): Type<Optional<string | Axes[]>, number[]>; swizzle(order?: string | Axes[], size?: number): Type<Optional<string | Axes[]>, number[]>; filter: any; type: any; scale: any; mapping: any; indexing: any; shape: any; join: any; stroke: any; vertexPass: any; fragmentPass: any; ease: any; fit: any; font: any; data: any; }; export declare const Types: TypeGenerators; export {};
cchudzicki/mathbox
build/esm/primitives/types/types_typed.d.ts
TypeScript
mit
3,538
import { Types as TypesUntyped } from "./types"; export const Types = TypesUntyped;
cchudzicki/mathbox
build/esm/primitives/types/types_typed.js
JavaScript
mit
84
export class Cartesian extends View { make(): void; uniforms: { viewMatrix: any; } | undefined; viewMatrix: any; composer: ((position: any, rotation: any, quaternion: any, scale: any, matrix: any, eulerOrder: any) => any) | undefined; unmake(): void; } import { View } from "./view.js";
cchudzicki/mathbox
build/esm/primitives/types/view/cartesian.d.ts
TypeScript
mit
319
// 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 * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UThree from "../../../util/three.js"; import { View } from "./view.js"; export class Cartesian extends View { static initClass() { this.traits = ["node", "object", "visible", "view", "view3", "vertex"]; } make() { super.make(); this.uniforms = { viewMatrix: this._attributes.make(this._types.mat4()) }; this.viewMatrix = this.uniforms.viewMatrix.value; this.composer = UThree.transformComposer(); } unmake() { super.unmake(); delete this.viewMatrix; delete this.objectMatrix; delete this.uniforms; } change(changed, touched, init) { if (!touched["view"] && !touched["view3"] && !init) { return; } const p = this.props.position; const s = this.props.scale; const q = this.props.quaternion; const r = this.props.rotation; const g = this.props.range; const e = this.props.eulerOrder; const { x } = g[0]; const y = g[1].x; const z = g[2].x; const dx = g[0].y - x || 1; const dy = g[1].y - y || 1; const dz = g[2].y - z || 1; // Forward transform this.viewMatrix.set(2 / dx, 0, 0, -(2 * x + dx) / dx, 0, 2 / dy, 0, -(2 * y + dy) / dy, 0, 0, 2 / dz, -(2 * z + dz) / dz, 0, 0, 0, 1); const transformMatrix = this.composer(p, r, q, s, null, e); this.viewMatrix.multiplyMatrices(transformMatrix, this.viewMatrix); if (changed["view.range"]) { this.trigger({ type: "view.range", }); } } vertex(shader, pass) { if (pass === 1) { shader.pipe("cartesian.position", this.uniforms); } return super.vertex(shader, pass); } } Cartesian.initClass();
cchudzicki/mathbox
build/esm/primitives/types/view/cartesian.js
JavaScript
mit
2,166
export class Cartesian4 extends View { uniforms: { basisOffset: any; basisScale: any; } | undefined; basisScale: any; basisOffset: any; unmake(): boolean; change(changed: any, touched: any, init: any): any; } import { View } from "./view.js";
cchudzicki/mathbox
build/esm/primitives/types/view/cartesian4.d.ts
TypeScript
mit
283
// 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 * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { View } from "./view.js"; export class Cartesian4 extends View { static initClass() { this.traits = ["node", "object", "visible", "view", "view4", "vertex"]; } make() { super.make(); this.uniforms = { basisOffset: this._attributes.make(this._types.vec4()), basisScale: this._attributes.make(this._types.vec4()), }; this.basisScale = this.uniforms.basisScale.value; return (this.basisOffset = this.uniforms.basisOffset.value); } unmake() { super.unmake(); delete this.basisScale; delete this.basisOffset; return delete this.uniforms; } change(changed, touched, init) { if (!touched["view"] && !touched["view4"] && !init) { return; } const p = this.props.position; const s = this.props.scale; const g = this.props.range; const { x } = g[0]; const y = g[1].x; const z = g[2].x; const w = g[3].x; const dx = g[0].y - x || 1; const dy = g[1].y - y || 1; const dz = g[2].y - z || 1; const dw = g[3].y - w || 1; const mult = function (a, b) { a.x *= b.x; a.y *= b.y; a.z *= b.z; return (a.w *= b.w); }; // 4D axis adjustment this.basisScale.set(2 / dx, 2 / dy, 2 / dz, 2 / dw); this.basisOffset.set(-(2 * x + dx) / dx, -(2 * y + dy) / dy, -(2 * z + dz) / dz, -(2 * w + dw) / dw); // 4D scale mult(this.basisScale, s); mult(this.basisOffset, s); // 4D position this.basisOffset.add(p); if (changed["view.range"]) { return this.trigger({ type: "view.range", }); } } vertex(shader, pass) { if (pass === 1) { shader.pipe("cartesian4.position", this.uniforms); } return super.vertex(shader, pass); } } Cartesian4.initClass();
cchudzicki/mathbox
build/esm/primitives/types/view/cartesian4.js
JavaScript
mit
2,364
export * from "./view.js"; export * from "./cartesian.js"; export * from "./cartesian4.js"; export * from "./polar.js"; export * from "./spherical.js"; export * from "./stereographic.js"; export * from "./stereographic4.js";
cchudzicki/mathbox
build/esm/primitives/types/view/index.d.ts
TypeScript
mit
225
export * from "./view.js"; export * from "./cartesian.js"; export * from "./cartesian4.js"; export * from "./polar.js"; export * from "./spherical.js"; export * from "./stereographic.js"; export * from "./stereographic4.js";
cchudzicki/mathbox
build/esm/primitives/types/view/index.js
JavaScript
mit
225
export class Polar extends View { make(): number; uniforms: { polarBend: any; polarHelix: any; polarFocus: any; polarAspect: any; viewMatrix: any; } | undefined; viewMatrix: any; composer: ((position: any, rotation: any, quaternion: any, scale: any, matrix: any, eulerOrder: any) => any) | undefined; aspect: number | undefined; unmake(): boolean; helix: any; bend: any; focus: number | undefined; } import { View } from "./view.js";
cchudzicki/mathbox
build/esm/primitives/types/view/polar.d.ts
TypeScript
mit
514
// 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 * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UAxis from "../../../util/axis.js"; import * as UThree from "../../../util/three.js"; import { Vector2 } from "three/src/math/Vector2.js"; import { View } from "./view.js"; export class Polar extends View { static initClass() { this.traits = [ "node", "object", "visible", "view", "view3", "polar", "vertex", ]; } make() { super.make(); const { types } = this._attributes; this.uniforms = { polarBend: this.node.attributes["polar.bend"], polarHelix: this.node.attributes["polar.helix"], polarFocus: this._attributes.make(types.number()), polarAspect: this._attributes.make(types.number()), viewMatrix: this._attributes.make(types.mat4()), }; this.viewMatrix = this.uniforms.viewMatrix.value; this.composer = UThree.transformComposer(); return (this.aspect = 1); } unmake() { super.unmake(); delete this.viewMatrix; delete this.objectMatrix; delete this.aspect; return delete this.uniforms; } change(changed, touched, init) { let aspect, bend, focus; if (!touched["view"] && !touched["view3"] && !touched["polar"] && !init) { return; } this.helix = this.props.helix; this.bend = bend = this.props.bend; this.focus = focus = bend > 0 ? 1 / bend - 1 : 0; const p = this.props.position; const s = this.props.scale; const q = this.props.quaternion; const r = this.props.rotation; const g = this.props.range; const e = this.props.eulerOrder; const { x } = g[0]; let y = g[1].x; const z = g[2].x; const dx = g[0].y - x || 1; let dy = g[1].y - y || 1; const dz = g[2].y - z || 1; const sx = s.x; const sy = s.y; // Watch for negative scales. const idx = dx > 0 ? 1 : -1; // Recenter viewport on origin the more it's bent [y, dy] = Array.from(UAxis.recenterAxis(y, dy, bend)); // Adjust viewport range for polar transform. // As the viewport goes polar, the X-range is interpolated to the Y-range instead, // creating a square/circular viewport. const ady = Math.abs(dy); const fdx = dx + (ady * idx - dx) * bend; const sdx = fdx / sx; const sdy = dy / sy; this.aspect = aspect = Math.abs(sdx / sdy); this.uniforms.polarFocus.value = focus; this.uniforms.polarAspect.value = aspect; // Forward transform this.viewMatrix.set(2 / fdx, 0, 0, -(2 * x + dx) / dx, 0, 2 / dy, 0, -(2 * y + dy) / dy, 0, 0, 2 / dz, -(2 * z + dz) / dz, 0, 0, 0, 1 //, ); const transformMatrix = this.composer(p, r, q, s, null, e); this.viewMatrix.multiplyMatrices(transformMatrix, this.viewMatrix); if (changed["view.range"] || touched["polar"]) { this.trigger({ type: "view.range", }); } } vertex(shader, pass) { if (pass === 1) { shader.pipe("polar.position", this.uniforms); } return super.vertex(shader, pass); } axis(dimension) { const range = this.props.range[dimension - 1]; let min = range.x; let max = range.y; // Correct Y extents during polar warp. if (dimension === 2 && this.bend > 0) { max = Math.max(Math.abs(max), Math.abs(min)); min = Math.max(-this.focus / this.aspect, min); } return new Vector2(min, max); } } Polar.initClass();
cchudzicki/mathbox
build/esm/primitives/types/view/polar.js
JavaScript
mit
4,135
export class Spherical extends View { make(): number; uniforms: { sphericalBend: any; sphericalFocus: any; sphericalAspectX: any; sphericalAspectY: any; sphericalScaleY: any; viewMatrix: any; } | undefined; viewMatrix: any; composer: ((position: any, rotation: any, quaternion: any, scale: any, matrix: any, eulerOrder: any) => any) | undefined; aspectX: number | undefined; aspectY: number | undefined; unmake(): boolean; change(changed: any, touched: any, init: any): any; bend: any; focus: number | undefined; scaleY: number | undefined; } import { View } from "./view.js";
cchudzicki/mathbox
build/esm/primitives/types/view/spherical.d.ts
TypeScript
mit
673
// 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 * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UAxis from "../../../util/axis.js"; import * as UThree from "../../../util/three.js"; import { Vector2 } from "three/src/math/Vector2.js"; import { View } from "./view.js"; export class Spherical extends View { static initClass() { this.traits = [ "node", "object", "visible", "view", "view3", "spherical", "vertex", ]; } make() { super.make(); this.uniforms = { sphericalBend: this.node.attributes["spherical.bend"], sphericalFocus: this._attributes.make(this._types.number()), sphericalAspectX: this._attributes.make(this._types.number()), sphericalAspectY: this._attributes.make(this._types.number()), sphericalScaleY: this._attributes.make(this._types.number()), viewMatrix: this._attributes.make(this._types.mat4()), }; this.viewMatrix = this.uniforms.viewMatrix.value; this.composer = UThree.transformComposer(); this.aspectX = 1; return (this.aspectY = 1); } unmake() { super.unmake(); delete this.viewMatrix; delete this.objectMatrix; delete this.aspectX; delete this.aspectY; return delete this.uniforms; } change(changed, touched, init) { let aspectX, aspectY, bend, focus, scaleY; if (!touched["view"] && !touched["view3"] && !touched["spherical"] && !init) { return; } this.bend = bend = this.props.bend; this.focus = focus = bend > 0 ? 1 / bend - 1 : 0; const p = this.props.position; const s = this.props.scale; const q = this.props.quaternion; const r = this.props.rotation; const g = this.props.range; const e = this.props.eulerOrder; const { x } = g[0]; let y = g[1].x; let z = g[2].x; const dx = g[0].y - x || 1; let dy = g[1].y - y || 1; let dz = g[2].y - z || 1; const sx = s.x; const sy = s.y; const sz = s.z; // Recenter viewport on origin the more it's bent [y, dy] = Array.from(UAxis.recenterAxis(y, dy, bend)); [z, dz] = Array.from(UAxis.recenterAxis(z, dz, bend)); // Watch for negative scales. const idx = dx > 0 ? 1 : -1; const idy = dy > 0 ? 1 : -1; // Adjust viewport range for spherical transform. // As the viewport goes spherical, the X/Y-ranges are interpolated to the Z-range, // creating a perfectly spherical viewport. const adz = Math.abs(dz); const fdx = dx + (adz * idx - dx) * bend; const fdy = dy + (adz * idy - dy) * bend; const sdx = fdx / sx; const sdy = fdy / sy; const sdz = dz / sz; this.aspectX = aspectX = Math.abs(sdx / sdz); this.aspectY = aspectY = Math.abs(sdy / sdz / aspectX); // Scale Y coordinates before transforming, but cap at aspectY/alpha to prevent from poking through the poles mid-transform. // See shaders/glsl/spherical.position.glsl const aspectZ = (((dy / dx) * sx) / sy) * 2; // Factor of 2 due to the fact that in the Y direction we only go 180º from pole to pole. this.scaleY = scaleY = Math.min(aspectY / bend, 1 + (aspectZ - 1) * bend); this.uniforms.sphericalBend.value = bend; this.uniforms.sphericalFocus.value = focus; this.uniforms.sphericalAspectX.value = aspectX; this.uniforms.sphericalAspectY.value = aspectY; this.uniforms.sphericalScaleY.value = scaleY; // Forward transform this.viewMatrix.set(2 / fdx, 0, 0, -(2 * x + dx) / dx, 0, 2 / fdy, 0, -(2 * y + dy) / dy, 0, 0, 2 / dz, -(2 * z + dz) / dz, 0, 0, 0, 1 //, ); const transformMatrix = this.composer(p, r, q, s, null, e); this.viewMatrix.multiplyMatrices(transformMatrix, this.viewMatrix); if (changed["view.range"] || touched["spherical"]) { return this.trigger({ type: "view.range", }); } } vertex(shader, pass) { if (pass === 1) { shader.pipe("spherical.position", this.uniforms); } return super.vertex(shader, pass); } axis(dimension) { const range = this.props.range[dimension - 1]; let min = range.x; let max = range.y; // Correct Z extents during polar warp. if (dimension === 3 && this.bend > 0) { max = Math.max(Math.abs(max), Math.abs(min)); min = Math.max(-this.focus / this.aspectX + 0.001, min); } return new Vector2(min, max); } } Spherical.initClass();
cchudzicki/mathbox
build/esm/primitives/types/view/spherical.js
JavaScript
mit
5,183
export class Stereographic extends View { make(): (position: any, rotation: any, quaternion: any, scale: any, matrix: any, eulerOrder: any) => any; uniforms: { stereoBend: any; viewMatrix: any; } | undefined; viewMatrix: any; composer: ((position: any, rotation: any, quaternion: any, scale: any, matrix: any, eulerOrder: any) => any) | undefined; unmake(): boolean; change(changed: any, touched: any, init: any): any; bend: any; } import { View } from "./view.js";
cchudzicki/mathbox
build/esm/primitives/types/view/stereographic.d.ts
TypeScript
mit
514
// 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 * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UAxis from "../../../util/axis.js"; import * as UThree from "../../../util/three.js"; import { View } from "./view.js"; export class Stereographic extends View { static initClass() { this.traits = [ "node", "object", "visible", "view", "view3", "stereographic", "vertex", ]; } make() { super.make(); this.uniforms = { stereoBend: this.node.attributes["stereographic.bend"], viewMatrix: this._attributes.make(this._types.mat4()), }; this.viewMatrix = this.uniforms.viewMatrix.value; return (this.composer = UThree.transformComposer()); } unmake() { super.unmake(); delete this.viewMatrix; delete this.rotationMatrix; return delete this.uniforms; } change(changed, touched, init) { let bend; if (!touched["view"] && !touched["view3"] && !touched["stereographic"] && !init) { return; } this.bend = bend = this.props.bend; const p = this.props.position; const s = this.props.scale; const q = this.props.quaternion; const r = this.props.rotation; const g = this.props.range; const e = this.props.eulerOrder; const { x } = g[0]; const y = g[1].x; let z = g[2].x; const dx = g[0].y - x || 1; const dy = g[1].y - y || 1; let dz = g[2].y - z || 1; // Recenter viewport on projection point the more it's bent [z, dz] = Array.from(UAxis.recenterAxis(z, dz, bend, 1)); this.uniforms.stereoBend.value = bend; // Forward transform this.viewMatrix.set(2 / dx, 0, 0, -(2 * x + dx) / dx, 0, 2 / dy, 0, -(2 * y + dy) / dy, 0, 0, 2 / dz, -(2 * z + dz) / dz, 0, 0, 0, 1 //, ); const transformMatrix = this.composer(p, r, q, s, null, e); this.viewMatrix.multiplyMatrices(transformMatrix, this.viewMatrix); if (changed["view.range"] || touched["stereographic"]) { return this.trigger({ type: "view.range", }); } } vertex(shader, pass) { if (pass === 1) { shader.pipe("stereographic.position", this.uniforms); } return super.vertex(shader, pass); } } Stereographic.initClass();
cchudzicki/mathbox
build/esm/primitives/types/view/stereographic.js
JavaScript
mit
2,844
export class Stereographic4 extends View { make(): void; uniforms: { basisOffset: any; basisScale: any; stereoBend: any; } | undefined; basisScale: any; basisOffset: any; unmake(): void; bend: any; } import { View } from "./view.js";
cchudzicki/mathbox
build/esm/primitives/types/view/stereographic4.d.ts
TypeScript
mit
286
// 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 * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UAxis from "../../../util/axis.js"; import { View } from "./view.js"; export class Stereographic4 extends View { static initClass() { this.traits = [ "node", "object", "visible", "view", "view4", "stereographic", "vertex", ]; } make() { super.make(); this.uniforms = { basisOffset: this._attributes.make(this._types.vec4()), basisScale: this._attributes.make(this._types.vec4()), stereoBend: this.node.attributes["stereographic.bend"], }; this.basisScale = this.uniforms.basisScale.value; this.basisOffset = this.uniforms.basisOffset.value; } unmake() { super.unmake(); delete this.basisScale; delete this.basisOffset; delete this.uniforms; } change(changed, touched, init) { let bend; if (!touched["view"] && !touched["view4"] && !touched["stereographic"] && !init) { return; } this.bend = bend = this.props.bend; const p = this.props.position; const s = this.props.scale; const g = this.props.range; const { x } = g[0]; const y = g[1].x; const z = g[2].x; let w = g[3].x; const dx = g[0].y - x || 1; const dy = g[1].y - y || 1; const dz = g[2].y - z || 1; let dw = g[3].y - w || 1; const mult = function (a, b) { a.x *= b.x; a.y *= b.y; a.z *= b.z; a.w *= b.w; }; // Recenter viewport on projection point the more it's bent [w, dw] = Array.from(UAxis.recenterAxis(w, dw, bend, 1)); // 4D axis adjustment this.basisScale.set(2 / dx, 2 / dy, 2 / dz, 2 / dw); this.basisOffset.set(-(2 * x + dx) / dx, -(2 * y + dy) / dy, -(2 * z + dz) / dz, -(2 * w + dw) / dw); // 4D scale mult(this.basisScale, s); mult(this.basisOffset, s); // 4D position this.basisOffset.add(p); if (changed["view.range"] || touched["stereographic"]) { this.trigger({ type: "view.range", }); } } vertex(shader, pass) { if (pass === 1) { shader.pipe("stereographic4.position", this.uniforms); } return super.vertex(shader, pass); } } Stereographic4.initClass();
cchudzicki/mathbox
build/esm/primitives/types/view/stereographic4.js
JavaScript
mit
2,904
export class View extends Transform { make(): any; unmake(): any; axis(dimension: any): any; } import { Transform } from "../transform/transform.js";
cchudzicki/mathbox
build/esm/primitives/types/view/view.d.ts
TypeScript
mit
162
// 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 * DS206: Consider reworking classes to avoid initClass * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Transform } from "../transform/transform.js"; export class View extends Transform { static initClass() { this.traits = ["node", "object", "visible", "view", "vertex"]; } make() { return this._helpers.visible.make(); } unmake() { return this._helpers.visible.unmake(); } axis(dimension) { return this.props.range[dimension - 1]; } } View.initClass();
cchudzicki/mathbox
build/esm/primitives/types/view/view.js
JavaScript
mit
785
export class ArrayBuffer_ extends DataBuffer { constructor(renderer: any, shaders: any, options: any); history: any; wrap: boolean; build(_options: any): { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; }; index: any; pad: number | undefined; setActive(i: any): number; fill(): number; write(n: any): number; } import { DataBuffer } from "./databuffer.js";
cchudzicki/mathbox
build/esm/render/buffer/arraybuffer.d.ts
TypeScript
mit
602
// 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 UData from "../../util/data.js"; import { DataBuffer } from "./databuffer.js"; /* * 1D + history array */ export class ArrayBuffer_ extends DataBuffer { constructor(renderer, shaders, options) { const width = options.width || 1; const history = options.history || 1; options.width = width; options.height = history; options.depth = 1; super(renderer, shaders, options, false); this.width = width; this.history = history; this.samples = width; this.wrap = history > 1; this.build(options); } build(_options) { super.build(); this.index = 0; this.pad = 0; return (this.streamer = this.generate(this.data)); } setActive(i) { return (this.pad = Math.max(0, this.width - i)); } fill() { const { callback } = this; if (typeof callback.reset === "function") { callback.reset(); } const { emit, count, done, reset } = this.streamer; reset(); const limit = this.samples - this.pad; let i = 0; while (!done() && i < limit && callback(emit, i++) !== false) { true; } return Math.floor(count() / this.items); } write(n) { if (n == null) { n = this.samples; } n *= this.items; this.texture.write(this.data, 0, this.index, n, 1); this.dataPointer.set(0.5, this.index + 0.5); this.index = (this.index + this.history - 1) % this.history; return (this.filled = Math.min(this.history, this.filled + 1)); } through(callback, target) { let dst, src; const { consume, done } = (src = this.streamer); const { emit } = (dst = target.streamer); let i = 0; let pipe = () => consume((x, y, z, w) => callback(emit, x, y, z, w, i)); pipe = UData.repeatCall(pipe, this.items); return () => { src.reset(); dst.reset(); const limit = this.samples - this.pad; i = 0; while (!done() && i < limit) { pipe(); i++; } return src.count(); }; } }
cchudzicki/mathbox
build/esm/render/buffer/arraybuffer.js
JavaScript
mit
2,609
export class Atlas extends Renderable { constructor(renderer: any, shaders: any, options: any, build: any); width: any; height: any; channels: any; backed: any; samples: number; shader(shader: any): any; build(options: any): number; klass: typeof DataTexture | undefined; texture: DataTexture | undefined; reset(): number; rows: any[] | undefined; bottom: any; resize(width: any, height: any): number; collapse(row: any): null | undefined; last: any; allocate(key: any, width: any, height: any, emit: any): any; read(): any; write(data: any, x: any, y: any, w: any, h: any): any; data: any; } import { Renderable } from "../renderable.js"; import { DataTexture } from "./texture/datatexture.js";
cchudzicki/mathbox
build/esm/render/buffer/atlas.d.ts
TypeScript
mit
776
// 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 * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining * DS104: Avoid inline assignments * 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 { BackedTexture } from "./texture/backedtexture.js"; import { DataTexture } from "./texture/datatexture.js"; import { Renderable } from "../renderable.js"; import { Vector2 } from "three/src/math/Vector2.js"; /* * Dynamic sprite atlas * * - Allocates variable-sized sprites in rows * - Will grow itself when full */ export class Atlas extends Renderable { constructor(renderer, shaders, options, build) { if (build == null) { build = true; } super(renderer, shaders); if (this.width == null) { this.width = options.width || 512; } if (this.height == null) { this.height = options.height || 512; } if (this.channels == null) { this.channels = options.channels || 4; } if (this.backed == null) { this.backed = options.backed || false; } this.samples = this.width * this.height; if (build) { this.build(options); } } shader(shader) { shader.pipe("map.2d.data", this.uniforms); shader.pipe("sample.2d", this.uniforms); if (this.channels < 4) { shader.pipe(UGLSL.swizzleVec4(["0000", "x000", "xw00", "xyz0"][this.channels])); } return shader; } build(options) { let klass; this.klass = klass = this.backed ? BackedTexture : DataTexture; this.texture = new klass(this.renderer, this.width, this.height, this.channels, options); this.uniforms = { dataPointer: { type: "v2", value: new Vector2(0, 0), }, }; this._adopt(this.texture.uniforms); return this.reset(); } reset() { this.rows = []; return (this.bottom = 0); } resize(width, height) { if (!this.backed) { throw new Error("Cannot resize unbacked texture atlas"); } if (width > 2048 && height > 2048) { console.warn(`Giant text atlas ${width}x${height}.`); } else { console.info(`Resizing text atlas ${width}x${height}.`); } this.texture.resize(width, height); this.width = width; this.height = height; return (this.samples = width * height); } collapse(row) { let left; const { rows } = this; rows.splice(rows.indexOf(row), 1); this.bottom = (left = __guard__(rows[rows.length - 1], (x) => x.bottom)) != null ? left : 0; if (this.last === row) { return (this.last = null); } } allocate(key, width, height, emit) { const w = this.width; const h = this.height; const max = height * 2; if (width > w) { this.resize(w * 2, h * 2); this.last = null; // Try again return this.allocate(key, width, height, emit); } // See if we can append to the last used row (fast code path) let row = this.last; if (row != null) { if (row.height >= height && row.height < max && row.width + width <= w) { row.append(key, width, height, emit); return; } } // Scan all rows and append to the first suitable one (slower code path) let bottom = 0; let index = -1; let top = 0; for (let i = 0; i < this.rows.length; i++) { // Measure gap between rows // Note suitable holes for later row = this.rows[i]; const gap = row.top - bottom; if (gap >= height && index < 0) { index = i; top = bottom; } ({ bottom } = row); if (row.height >= height && row.height < max && row.width + width <= w) { row.append(key, width, height, emit); this.last = row; return; } } // New row (slowest path) if (index >= 0) { // Fill a gap row = new Row(top, height); this.rows.splice(index, 0, row); //console.log 'fill gap', row } else { // Append to bottom top = bottom; bottom += height; // Resize if atlas is full if (bottom >= h) { this.resize(w * 2, h * 2); this.last = null; // Try again return this.allocate(key, width, height, emit); } // Add new row to the end row = new Row(top, height); this.rows.push(row); this.bottom = bottom; } row.append(key, width, height, emit); this.last = row; } read() { return this.texture.textureObject; } write(data, x, y, w, h) { return this.texture.write(data, x, y, w, h); } dispose() { this.texture.dispose(); this.data = null; return super.dispose(); } } class Row { constructor(top, height) { this.top = top; this.bottom = top + height; this.width = 0; this.height = height; this.alive = 0; this.keys = []; } append(key, width, height, emit) { const x = this.width; const y = this.top; this.alive++; this.width += width; this.keys.push(key); return emit(this, x, y); } } function __guard__(value, transform) { return typeof value !== "undefined" && value !== null ? transform(value) : undefined; }
cchudzicki/mathbox
build/esm/render/buffer/atlas.js
JavaScript
mit
6,226
export class Buffer extends Renderable { constructor(renderer: any, shaders: any, options: any); items: any; samples: any; channels: any; callback: any; update(): void; setActive(_i: any, _j: any, _k: any, _l: any): void; setCallback(callback: any): void; write(): void; fill(): void; generate(data: any): { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; }; } import { Renderable } from "../renderable.js";
cchudzicki/mathbox
build/esm/render/buffer/buffer.d.ts
TypeScript
mit
660
// 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 UData from "../../util/data.js"; import { Renderable } from "../renderable.js"; /* * Base class for sample buffers */ export class Buffer extends Renderable { constructor(renderer, shaders, options) { super(renderer, shaders); if (this.items == null) { this.items = options.items || 1; } if (this.samples == null) { this.samples = options.samples || 1; } if (this.channels == null) { this.channels = options.channels || 4; } if (this.callback == null) { this.callback = options.callback || function () { }; } } dispose() { return super.dispose(); } update() { const n = this.fill(); this.write(n); return n; } setActive(_i, _j, _k, _l) { } setCallback(callback) { this.callback = callback; } write() { } fill() { } generate(data) { return UData.getStreamer(data, this.samples, this.channels, this.items); } }
cchudzicki/mathbox
build/esm/render/buffer/buffer.js
JavaScript
mit
1,402
export class DataBuffer extends Buffer { constructor(renderer: any, shaders: any, options: any, build: any); width: any; height: any; depth: any; shader(shader: any, indices: any): any; build(options: any): void; data: Float32Array | null | undefined; texture: DataTexture | undefined; filled: number | undefined; used: any; dataPointer: any; streamer: { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; } | undefined; getFilled(): number | undefined; setCallback(callback: any): number; copy(data: any): void; write(n: any): void; through(callback: any, target: any): () => any; } import { Buffer } from "./buffer.js"; import { DataTexture } from "./texture/datatexture.js";
cchudzicki/mathbox
build/esm/render/buffer/databuffer.d.ts
TypeScript
mit
951
// 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 * as UData from "../../util/data.js"; import * as UGLSL from "../../util/glsl.js"; import { Buffer } from "./buffer.js"; import { DataTexture } from "./texture/datatexture.js"; import { Vector2 } from "three/src/math/Vector2.js"; /* * Data buffer on the GPU * - Stores samples (1-n) x items (1-n) x channels (1-4) * - Provides generic sampler shader * - Provides generic copy/write handler * => specialized into Array/Matrix/VoxelBuffer */ export class DataBuffer extends Buffer { constructor(renderer, shaders, options, build) { if (build == null) { build = true; } const width = options.width || 1; const height = options.height || 1; const depth = options.depth || 1; const samples = width * height * depth; if (!options.samples) { options.samples = samples; } super(renderer, shaders, options); this.width = width; this.height = height; this.depth = depth; if (this.samples == null) { this.samples = samples; } if (build) { this.build(options); } } shader(shader, indices) { if (indices == null) { indices = 4; } if (this.items > 1 || this.depth > 1) { if (indices !== 4) { shader.pipe(UGLSL.extendVec(indices, 4)); } shader.pipe("map.xyzw.texture", this.uniforms); } else { if (indices !== 2) { shader.pipe(UGLSL.truncateVec(indices, 2)); } } const wrap = this.wrap ? ".wrap" : ""; shader.pipe(`map.2d.data${wrap}`, this.uniforms); shader.pipe("sample.2d", this.uniforms); if (this.channels < 4) { shader.pipe(UGLSL.swizzleVec4(["0000", "x000", "xw00", "xyz0"][this.channels])); } return shader; } build(options) { this.data = new Float32Array(this.samples * this.channels * this.items); this.texture = new DataTexture(this.renderer, this.items * this.width, this.height * this.depth, this.channels, options); this.filled = 0; this.used = 0; this._adopt(this.texture.uniforms); this._adopt({ dataPointer: { type: "v2", value: new Vector2() }, textureItems: { type: "f", value: this.items }, textureHeight: { type: "f", value: this.height }, }); this.dataPointer = this.uniforms.dataPointer.value; this.streamer = this.generate(this.data); } dispose() { this.data = null; this.texture.dispose(); return super.dispose(); } getFilled() { return this.filled; } setCallback(callback) { this.callback = callback; return (this.filled = 0); } copy(data) { const n = Math.min(data.length, this.samples * this.channels * this.items); const d = this.data; for (let i = 0, end = n, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { d[i] = data[i]; } this.write(Math.ceil(n / this.channels / this.items)); } write(n) { if (n == null) { n = this.samples; } let height = n / this.width; n *= this.items; const width = height < 1 ? n : this.items * this.width; height = Math.ceil(height); this.texture.write(this.data, 0, 0, width, height); this.dataPointer.set(0.5, 0.5); this.filled = 1; this.used = n; } through(callback, target) { let dst, src; const { consume, done } = (src = this.streamer); const { emit } = (dst = target.streamer); let i = 0; let pipe = () => consume((x, y, z, w) => callback(emit, x, y, z, w, i)); pipe = UData.repeatCall(pipe, this.items); return () => { src.reset(); dst.reset(); const limit = this.used; i = 0; while (!done() && i < limit) { pipe(); i++; } return src.count(); }; } }
cchudzicki/mathbox
build/esm/render/buffer/databuffer.js
JavaScript
mit
4,563
export class ItemBuffer extends DataBuffer { build(_options: any): { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; }; pad: { x: number; y: number; z: number; w: number; } | undefined; setActive(i: any, j: any, k: any, l: any): number[]; fill(): number; } import { DataBuffer } from "./databuffer.js";
cchudzicki/mathbox
build/esm/render/buffer/itembuffer.d.ts
TypeScript
mit
563
// 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 * DS104: Avoid inline assignments * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { DataBuffer } from "./databuffer.js"; /* * 4D array */ export class ItemBuffer extends DataBuffer { build(_options) { super.build(); this.pad = { x: 0, y: 0, z: 0, w: 0 }; return (this.streamer = this.generate(this.data)); } getFilled() { return this.filled; } setActive(i, j, k, l) { let ref; return (([this.pad.x, this.pad.y, this.pad.z, this.pad.w] = Array.from((ref = [ this.width - i, this.height - j, this.depth - k, this.items - l, ]))), ref); } fill() { let j, k, l, repeat; const { callback } = this; if (typeof callback.reset === "function") { callback.reset(); } const { emit, skip, count, done, reset } = this.streamer; reset(); const n = this.width; let m = this.height; const p = this.items; const padX = this.pad.x; const padY = this.pad.y; const padW = this.pad.w; const limit = (this.samples - this.pad.z * n * m) * p; let i = (j = k = l = m = 0); if (padX > 0 || padY > 0 || padW > 0) { while (!done() && m < limit) { m++; repeat = callback(emit, i, j, k, l); if (++l === p - padW) { skip(padW); l = 0; if (++i === n - padX) { skip(p * padX); i = 0; if (++j === m - padY) { skip(p * n * padY); j = 0; k++; } } } if (repeat === false) { break; } } } else { while (!done() && m < limit) { m++; repeat = callback(emit, i, j, k, l); if (++l === p) { l = 0; if (++i === n) { i = 0; if (++j === m) { j = 0; k++; } } } if (repeat === false) { break; } } } return Math.floor(count() / this.items); } }
cchudzicki/mathbox
build/esm/render/buffer/itembuffer.js
JavaScript
mit
2,850
export class MatrixBuffer extends DataBuffer { constructor(renderer: any, shaders: any, options: any); history: any; samples: number; wrap: boolean; build(_options: any): { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; }; index: any; pad: { x: number; y: number; } | undefined; setActive(i: any, j: any): number[]; fill(): number; write(n: any): number; } import { DataBuffer } from "./databuffer.js";
cchudzicki/mathbox
build/esm/render/buffer/matrixbuffer.d.ts
TypeScript
mit
672
// 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 * DS104: Avoid inline assignments * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UData from "../../util/data.js"; import { DataBuffer } from "./databuffer.js"; /* * 2D + history array */ export class MatrixBuffer extends DataBuffer { constructor(renderer, shaders, options) { const width = options.width || 1; const height = options.height || 1; const history = options.history || 1; options.depth = history; super(renderer, shaders, options, false); this.width = width; this.height = height; this.history = history; this.samples = width * height; this.wrap = history > 1; this.build(options); } build(_options) { super.build(); this.index = 0; this.pad = { x: 0, y: 0 }; return (this.streamer = this.generate(this.data)); } getFilled() { return this.filled; } setActive(i, j) { let ref; return (([this.pad.x, this.pad.y] = Array.from((ref = [Math.max(0, this.width - i), Math.max(0, this.height - j)]))), ref); } fill() { let j, k, repeat; const { callback } = this; if (typeof callback.reset === "function") { callback.reset(); } const { emit, skip, count, done, reset } = this.streamer; reset(); const n = this.width; const pad = this.pad.x; const limit = this.samples - this.pad.y * n; let i = (j = k = 0); if (pad) { while (!done() && k < limit) { k++; repeat = callback(emit, i, j); if (++i === n - pad) { skip(pad); i = 0; j++; } if (repeat === false) { break; } } } else { while (!done() && k < limit) { k++; repeat = callback(emit, i, j); if (++i === n) { i = 0; j++; } if (repeat === false) { break; } } } return Math.floor(count() / this.items); } write(n) { if (n == null) { n = this.samples; } n *= this.items; const width = this.width * this.items; const height = Math.ceil(n / width); this.texture.write(this.data, 0, this.index * this.height, width, height); this.dataPointer.set(0.5, this.index * this.height + 0.5); this.index = (this.index + this.history - 1) % this.history; return (this.filled = Math.min(this.history, this.filled + 1)); } through(callback, target) { let dst, j, src; const { consume, skip, done } = (src = this.streamer); const { emit } = (dst = target.streamer); let i = (j = 0); let pipe = () => consume((x, y, z, w) => callback(emit, x, y, z, w, i, j)); pipe = UData.repeatCall(pipe, this.items); return () => { let k; src.reset(); dst.reset(); const n = this.width; const pad = this.pad.x; const limit = this.samples - this.pad.y * n; i = j = k = 0; if (pad) { while (!done() && k < limit) { k++; pipe(); if (++i === n - pad) { skip(pad); i = 0; j++; } } } else { while (!done() && k < limit) { k++; pipe(); if (++i === n) { i = 0; j++; } } } return src.count(); }; } }
cchudzicki/mathbox
build/esm/render/buffer/matrixbuffer.js
JavaScript
mit
4,347
export class Memo extends RenderToTexture { items: any; channels: any; width: any; _width: number; height: any; _height: number; depth: any; shaderAbsolute(shader: any): any; } import { RenderToTexture } from "./rendertotexture.js";
cchudzicki/mathbox
build/esm/render/buffer/memo.d.ts
TypeScript
mit
265
// 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 { RGBAFormat } from "three/src/constants.js"; import { RenderToTexture } from "./rendertotexture.js"; /* * Wrapped RTT for memoizing 4D arrays back to a 2D texture */ export class Memo extends RenderToTexture { constructor(renderer, shaders, options) { let _height, _width; const items = options.items || 1; const channels = options.channels || 4; const width = options.width || 1; const height = options.height || 1; const depth = options.depth || 1; //options.format = [null, THREE.LuminanceFormat, THREE.LuminanceAlphaFormat, THREE.RGBFormat, THREE.RGBAFormat][@channels] options.format = RGBAFormat; options.width = _width = items * width; options.height = _height = height * depth; options.frames = 1; delete options.items; delete options.depth; delete options.channels; super(renderer, shaders, options); if (this.items == null) { this.items = items; } if (this.channels == null) { this.channels = channels; } if (this.width == null) { this.width = width; } this._width = _width; if (this.height == null) { this.height = height; } this._height = _height; if (this.depth == null) { this.depth = depth; } this._adopt({ textureItems: { type: "f", value: this.items }, textureHeight: { type: "f", value: this.height }, }); } shaderAbsolute(shader) { if (shader == null) { shader = this.shaders.shader(); } shader.pipe("map.xyzw.texture", this.uniforms); return super.shaderAbsolute(shader, 1, 2); } } //shader.pipe Util.GLSL.swizzleVec4 ['0000', 'x000', 'xw00', 'xyz0'][@channels] if @channels < 4
cchudzicki/mathbox
build/esm/render/buffer/memo.js
JavaScript
mit
2,244
export class PushBuffer extends Buffer { width: any; height: any; depth: any; build(_options: any): { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; }; data: any[] | null | undefined; filled: number | undefined; pad: { x: number; y: number; z: number; } | undefined; streamer: { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; } | undefined; getFilled(): number | undefined; setActive(i: any, j: any, k: any): number[]; read(): any[] | null | undefined; copy(data: any): any[]; fill(): any; } import { Buffer } from "./buffer.js";
cchudzicki/mathbox
build/esm/render/buffer/pushbuffer.d.ts
TypeScript
mit
1,028
// 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 * DS104: Avoid inline assignments * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import { Buffer } from "./buffer.js"; /* * Buffer for CPU-side use */ export class PushBuffer extends Buffer { constructor(renderer, shaders, options) { const width = options.width || 1; const height = options.height || 1; const depth = options.depth || 1; const samples = width * height * depth; if (!options.samples) { options.samples = samples; } super(renderer, shaders, options); this.width = width; this.height = height; this.depth = depth; if (this.samples == null) { this.samples = samples; } this.build(options); } build(_options) { this.data = []; this.data.length = this.samples; this.filled = 0; this.pad = { x: 0, y: 0, z: 0 }; return (this.streamer = this.generate(this.data)); } dispose() { this.data = null; return super.dispose(); } getFilled() { return this.filled; } setActive(i, j, k) { let ref; return (([this.pad.x, this.pad.y, this.pad.z] = Array.from((ref = [this.width - i, this.height - j, this.depth - k]))), ref); } read() { return this.data; } copy(data) { const n = Math.min(data.length, this.samples); const d = this.data; return __range__(0, n, false).map((i) => (d[i] = data[i])); } fill() { let j, k, l, repeat; const { callback } = this; if (typeof callback.reset === "function") { callback.reset(); } const { emit, skip, count, done, reset } = this.streamer; reset(); const n = this.width; const m = this.height; const padX = this.pad.x; const padY = this.pad.y; const limit = this.samples - this.pad.z * n * m; let i = (j = k = l = 0); if (padX > 0 || padY > 0) { while (!done() && l < limit) { l++; repeat = callback(emit, i, j, k); if (++i === n - padX) { skip(padX); i = 0; if (++j === m - padY) { skip(n * padY); j = 0; k++; } } if (repeat === false) { break; } } } else { while (!done() && l < limit) { l++; repeat = callback(emit, i, j, k); if (++i === n) { i = 0; if (++j === m) { j = 0; k++; } } if (repeat === false) { break; } } } this.filled = 1; return count(); } } function __range__(left, right, inclusive) { const range = []; const ascending = left < right; const end = !inclusive ? right : ascending ? right + 1 : right - 1; for (let i = left; ascending ? i < end : i > end; ascending ? i++ : i--) { range.push(i); } return range; }
cchudzicki/mathbox
build/esm/render/buffer/pushbuffer.js
JavaScript
mit
3,673
export class Readback extends Renderable { constructor(renderer: any, shaders: any, options: any); items: any; channels: any; width: any; height: any; depth: any; type: any; stpq: any; isFloat: boolean; active: { items: number; width: number; height: number; depth: number; } | null; sampled: { items: number; width: number; height: number; depth: number; } | null; rect: { w: number; h: number; } | null; pad: { x: number; y: number; z: number; w: number; } | null; build(options: any): number[] | undefined; floatMemo: Memo | null | undefined; floatCompose: MemoScreen | null | undefined; byteMemo: Memo | null | undefined; byteCompose: MemoScreen | null | undefined; samples: number | undefined; bytes: Uint8Array | undefined; floats: Float32Array | undefined; data: Uint8Array | Float32Array | undefined; streamer: { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; } | undefined; stretch: any; isIndexed: boolean | undefined; generate(data: any): { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; }; setActive(items: any, width: any, height: any, depth: any): number[] | undefined; update(camera: any): number | undefined; post(): void; readFloat(n: any): any; readByte(n: any): any; setCallback(callback: any): void; emitter: any; callback(callback: any): any; iterate(): number; dispose(): null; } import { Renderable } from "../renderable.js"; import { Memo } from "./memo.js"; import { MemoScreen } from "../meshes/memoscreen.js";
cchudzicki/mathbox
build/esm/render/buffer/readback.d.ts
TypeScript
mit
2,127
// 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 * DS104: Avoid inline assignments * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UData from "../../util/data.js"; import * as UGLSL from "../../util/glsl.js"; import { FloatType, UnsignedByteType } from "three/src/constants.js"; import { Memo } from "./memo.js"; import { MemoScreen } from "../meshes/memoscreen.js"; import { Renderable } from "../renderable.js"; import { Vector4 } from "three/src/math/Vector4.js"; /* * Readback up to 4D array of up to 4D data from GL */ export class Readback extends Renderable { constructor(renderer, shaders, options) { super(renderer, shaders); if (this.items == null) { this.items = options.items || 1; } if (this.channels == null) { this.channels = options.channels || 4; } if (this.width == null) { this.width = options.width || 1; } if (this.height == null) { this.height = options.height || 1; } if (this.depth == null) { this.depth = options.depth || 1; } if (this.type == null) { this.type = options.type || FloatType; } if (this.stpq == null) { this.stpq = options.stpq || false; } this.isFloat = this.type === FloatType; this.active = this.sampled = this.rect = this.pad = null; this.build(options); /* * log precision gl = @gl for name, pass of {Vertex: gl.VERTEX_SHADER, Fragment: gl.FRAGMENT_SHADER} bits = for prec in [gl.LOW_FLOAT, gl.MEDIUM_FLOAT, gl.HIGH_FLOAT] gl.getShaderPrecisionFormat(pass, prec).precision console.log name, 'shader precision', bits */ } build(options) { let channels, encoder, stretch; const { map } = options; const { indexer } = options; const isIndexed = indexer != null && !indexer.empty(); let { stpq } = this; const { items, width, height, depth } = this; let sampler = map; if (isIndexed) { // Preserve original xyzw offset of datapoint to tie it back to the source // Modulus to pack xyzw into a single integer index this._adopt({ indexModulus: { type: "v4", value: new Vector4(items, items * width, items * width * height, 1), }, }); // Build shader to pack XYZ + index into a single RGBA sampler = this.shaders.shader(); sampler.require(map); sampler.require(indexer); //sampler.require UGLSL.identity 'vec4' sampler.pipe("float.index.pack", this.uniforms); } if (this.isFloat && this.channels > 1) { // Memoize multi-channel float data into float buffer first this.floatMemo = new Memo(this.renderer, this.shaders, { items, channels: 4, width, height, depth, history: 0, type: FloatType, }); this.floatCompose = new MemoScreen(this.renderer, this.shaders, { map: sampler, items, width, height, depth, stpq, }); this.floatMemo.adopt(this.floatCompose); // Second pass won't need texture coordinates stpq = false; // Replace sampler with memoized sampler sampler = this.shaders.shader(); this.floatMemo.shaderAbsolute(sampler); } if (this.isFloat) { // Encode float data into byte buffer stretch = this.channels; channels = 4; // one 32-bit float per pixel } else { // Render byte data directly stretch = 1; channels = this.channels; } if (stretch > 1) { // Stretch horizontally, sampling once per channel encoder = this.shaders.shader(); encoder.pipe(UGLSL.mapByte2FloatOffset(stretch)); encoder.require(sampler); encoder.pipe("float.stretch"); encoder.pipe("float.encode"); sampler = encoder; } else if (this.isFloat) { // Direct sampling encoder = this.shaders.shader(); encoder.pipe(sampler); encoder.pipe(UGLSL.truncateVec(4, 1)); encoder.pipe("float.encode"); sampler = encoder; } // Memoize byte data this.byteMemo = new Memo(this.renderer, this.shaders, { items: items * stretch, channels: channels, width, height, depth, history: 0, type: UnsignedByteType, }); this.byteCompose = new MemoScreen(this.renderer, this.shaders, { map: sampler, items: items * stretch, width, height, depth, stpq, }); this.byteMemo.adopt(this.byteCompose); // CPU-side buffers const w = items * width * stretch; const h = height * depth; this.samples = this.width * this.height * this.depth; this.bytes = new Uint8Array(w * h * 4); // non-RGBA render target not supported if (this.isFloat) { this.floats = new Float32Array(this.bytes.buffer); } this.data = this.isFloat ? this.floats : this.bytes; this.streamer = this.generate(this.data); this.active = { items: 0, width: 0, height: 0, depth: 0 }; this.sampled = { items: 0, width: 0, height: 0, depth: 0 }; this.rect = { w: 0, h: 0 }; this.pad = { x: 0, y: 0, z: 0, w: 0 }; this.stretch = stretch; this.isIndexed = isIndexed; return this.setActive(items, width, height, depth); } generate(data) { return UData.getStreamer(data, this.samples, 4, this.items); } // non-RGBA render target not supported setActive(items, width, height, depth) { let ref; if (items === this.active.items && width === this.active.width && height === this.active.height && depth === this.active.depth) { return; } // Actively sampled area [ this.active.items, this.active.width, this.active.height, this.active.depth, ] = Array.from([items, width, height, depth]); // Render only necessary samples in RTTs if (this.floatCompose != null) { this.floatCompose.cover(width, height, depth); } if (this.byteCompose != null) { this.byteCompose.cover(width * this.stretch, height, depth); } // Calculate readback buffer geometry ({ items } = this); ({ width } = this.active); height = this.depth === 1 ? this.active.height : this.height; ({ depth } = this.active); const w = items * width * this.stretch; const h = height * depth; // Calculate array paddings on readback [ this.sampled.items, this.sampled.width, this.sampled.height, this.sampled.depth, ] = Array.from([items, width, height, depth]); [this.rect.w, this.rect.h] = Array.from([w, h]); return (([this.pad.x, this.pad.y, this.pad.z, this.pad.w] = Array.from((ref = [ this.sampled.width - this.active.width, this.sampled.height - this.active.height, this.sampled.depth - this.active.depth, this.sampled.items - this.active.items, ]))), ref); } update(camera) { if (this.floatMemo != null) { this.floatMemo.render(camera); } return this.byteMemo != null ? this.byteMemo.render(camera) : undefined; } post() { const currentTarget = this.renderer.getRenderTarget(); this.renderer.setRenderTarget(this.byteMemo.target.targets[0]); this.gl.readPixels(0, 0, this.rect.w, this.rect.h, this.gl.RGBA, this.gl.UNSIGNED_BYTE, this.bytes); this.renderer.setRenderTarget(currentTarget); } readFloat(n) { return this.floatMemo != null ? this.floatMemo.read(n) : undefined; } readByte(n) { return this.byteMemo != null ? this.byteMemo.read(n) : undefined; } setCallback(callback) { this.emitter = this.callback(callback); } callback(callback) { if (!this.isIndexed) { return callback; } const n = this.width; const m = this.height; const p = this.items; // Decode packed index const f = function (x, y, z, w) { let idx = w; const ll = idx % p; idx = (idx - ll) / p; const ii = idx % n; idx = (idx - ii) / n; const jj = idx % m; idx = (idx - jj) / m; const kk = idx; return callback(x, y, z, w, ii, jj, kk, ll); }; f.reset = () => typeof callback.reset === "function" ? callback.reset() : undefined; return f; } iterate() { let j, k, l; let emit = this.emitter; if (typeof emit.reset === "function") { emit.reset(); } const { consume, skip, count, done, reset } = this.streamer; reset(); const n = this.sampled.width | 0; let m = this.sampled.height | 0; const o = this.sampled.depth | 0; const p = this.sampled.items | 0; const padX = this.pad.x | 0; const padY = this.pad.y | 0; const padZ = this.pad.z | 0; const padW = this.pad.w | 0; const limit = n * m * p * (o - padZ); if (!this.isIndexed) { const callback = emit; emit = (x, y, z, w) => callback(x, y, z, w, i, j, k, l); } let i = (j = k = l = m = 0); while (!done() && m < limit) { m++; const repeat = consume(emit); if (++l === p - padW) { skip(padX); l = 0; if (++i === n - padX) { skip(p * padX); i = 0; if (++j === m - padY) { skip(p * n * padY); j = 0; k++; } } } if (repeat === false) { break; } } return Math.floor(count() / p); } dispose() { if (this.floatMemo != null) { this.floatMemo.unadopt(this.floatCompose); } if (this.floatMemo != null) { this.floatMemo.dispose(); } if (this.floatCompose != null) { this.floatCompose.dispose(); } if (this.byteMemo != null) { this.byteMemo.unadopt(this.byteCompose); } if (this.byteMemo != null) { this.byteMemo.dispose(); } if (this.byteCompose != null) { this.byteCompose.dispose(); } return (this.floatMemo = this.byteMemo = this.floatCompose = this.byteCompose = null); } }
cchudzicki/mathbox
build/esm/render/buffer/readback.js
JavaScript
mit
11,832
export class RenderToTexture extends Renderable { constructor(renderer: any, shaders: any, options: any); scene: any; camera: any; shaderRelative(shader: any): any; shaderAbsolute(shader: any, frames: any, indices: any): any; build(options: any): number; target: RenderTarget | undefined; filled: number | undefined; adopt(renderable: any): any[]; unadopt(renderable: any): any[]; render(camera: any): number | undefined; read(frame: any): any; getFrames(): any; getFilled(): number | undefined; } import { Renderable } from "../renderable.js"; import { RenderTarget } from "./texture/rendertarget.js";
cchudzicki/mathbox
build/esm/render/buffer/rendertotexture.d.ts
TypeScript
mit
659
// 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 { PerspectiveCamera } from "three/src/cameras/PerspectiveCamera.js"; import { RenderTarget } from "./texture/rendertarget.js"; import { Renderable } from "../renderable.js"; import { Scene } from "three/src/scenes/Scene.js"; import { Vector2 } from "three/src/math/Vector2.js"; import { Vector3 } from "three/src/math/Vector3.js"; /* * Render-To-Texture with history */ export class RenderToTexture extends Renderable { constructor(renderer, shaders, options) { super(renderer, shaders); this.scene = options.scene != null ? options.scene : new Scene(); this.camera = options.camera; this.build(options); } shaderRelative(shader) { if (shader == null) { shader = this.shaders.shader(); } return shader.pipe("sample.2d", this.uniforms); } shaderAbsolute(shader, frames, indices) { if (frames == null) { frames = 1; } if (indices == null) { indices = 4; } if (shader == null) { shader = this.shaders.shader(); } if (frames <= 1) { if (indices > 2) { shader.pipe(UGLSL.truncateVec(indices, 2)); } shader.pipe("map.2d.data", this.uniforms); return shader.pipe("sample.2d", this.uniforms); } else { const sample2DArray = UGLSL.sample2DArray(Math.min(frames, this.target.frames)); if (indices < 4) { shader.pipe(UGLSL.extendVec(indices, 4)); } shader.pipe("map.xyzw.2dv"); shader.split(); shader.pipe("map.2d.data", this.uniforms); shader.pass(); return shader.pipe(sample2DArray, this.uniforms); } } build(options) { if (!this.camera) { this.camera = new PerspectiveCamera(); this.camera.position.set(0, 0, 3); this.camera.lookAt(new Vector3()); } if (typeof this.scene.inject === "function") { this.scene.inject(); } this.target = new RenderTarget(this.gl, options.width, options.height, options.frames, options); this.target.warmup((target) => this.renderer.setRenderTarget(target)); this.renderer.setRenderTarget(null); this._adopt(this.target.uniforms); this._adopt({ dataPointer: { type: "v2", value: new Vector2(0.5, 0.5), }, }); return (this.filled = 0); } adopt(renderable) { return Array.from(renderable.renders).map((object) => this.scene.add(object)); } unadopt(renderable) { return Array.from(renderable.renders).map((object) => this.scene.remove(object)); } render(camera) { if (camera == null) { ({ camera } = this); } const currentTarget = this.renderer.getRenderTarget(); this.renderer.setRenderTarget(this.target.write); this.renderer.render(this.scene.scene != null ? this.scene.scene : this.scene, camera); this.renderer.setRenderTarget(currentTarget); this.target.cycle(); if (this.filled < this.target.frames) { return this.filled++; } } read(frame) { if (frame == null) { frame = 0; } return this.target.reads[Math.abs(frame)]; } getFrames() { return this.target.frames; } getFilled() { return this.filled; } dispose() { if (typeof this.scene.unject === "function") { this.scene.unject(); } this.scene = this.camera = null; this.target.dispose(); return super.dispose(); } }
cchudzicki/mathbox
build/esm/render/buffer/rendertotexture.js
JavaScript
mit
4,208
export class TextAtlas extends Atlas { constructor(renderer: any, shaders: any, options: any); font: any; size: any; style: any; variant: any; weight: any; outline: number; gamma: number; scratchW: number; scratchH: number; build(options: any): any; canvas: HTMLCanvasElement | undefined; context: CanvasRenderingContext2D | null | undefined; lineHeight: number | undefined; maxWidth: number | undefined; colors: string[] | undefined; scratch: Uint8Array | undefined; _allocate: any; _write: any; reset(): {}; mapped: {} | undefined; begin(): number[]; end(): void; map(text: any, emit: any): any; draw(text: any): number | undefined; } import { Atlas } from "./atlas.js";
cchudzicki/mathbox
build/esm/render/buffer/textatlas.d.ts
TypeScript
mit
773
// 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 * DS104: Avoid inline assignments * 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 { Atlas } from "./atlas.js"; import { UnsignedByteType } from "three/src/constants.js"; const SCRATCH_SIZE = 512 / 16; /* * Dynamic text atlas * - Stores entire strings as sprites * - Renders alpha mask (fast) or signed distance field (slow) * - Emits (x,y,width,height) pointers into the atlas */ export class TextAtlas extends Atlas { constructor(renderer, shaders, options) { let left; if (!options.width) { options.width = 256; } if (!options.height) { options.height = 256; } options.type = UnsignedByteType; options.channels = 1; options.backed = true; super(renderer, shaders, options, false); this.font = options.font != null ? options.font : ["sans-serif"]; this.size = options.size || 24; this.style = options.style != null ? options.style : "normal"; this.variant = options.variant != null ? options.variant : "normal"; this.weight = options.weight != null ? options.weight : "normal"; this.outline = (left = +(options.outline != null ? options.outline : 5)) != null ? left : 0; this.gamma = 1; if (typeof navigator !== "undefined") { const ua = navigator.userAgent; if (ua.match(/Chrome/) && ua.match(/OS X/)) { this.gamma = 0.5; } } this.scratchW = this.scratchH = 0; this.build(options); } build(options) { super.build(options); // Prepare line-height with room for outline let lineHeight = 16; lineHeight = this.size; lineHeight += 4 + 2 * Math.min(1, this.outline); const maxWidth = SCRATCH_SIZE * lineHeight; // Prepare scratch canvas const canvas = document.createElement("canvas"); canvas.width = maxWidth; canvas.height = lineHeight; const quote = (str) => `${str.replace(/(['"\\])/g, "\\$1")}`; const font = this.font.map(quote).join(", "); const context = canvas.getContext("2d"); context.font = `${this.style} ${this.variant} ${this.weight} ${this.size}px ${font}`; context.fillStyle = "#FF0000"; context.textAlign = "left"; context.textBaseline = "bottom"; context.lineJoin = "round"; // debug: show scratch canvas /* document.body.appendChild canvas canvas.setAttribute('style', "position: absolute; top: 0; left: 0; z-index: 100; border: 1px solid red; background: rgba(255,0,255,.25);") */ // Cache hex colors for distance field rendering const colors = []; const dilate = this.outline * 3; for (let i = 0, end = dilate, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { // 8 rgb levels = 1 step = .5 pixel increase const hex = ("00" + Math.max(0, -i * 8 + 128 - !i * 8).toString(16)).slice(-2); colors.push("#" + hex + hex + hex); } const scratch = new Uint8Array(maxWidth * lineHeight * 2); this.canvas = canvas; this.context = context; this.lineHeight = lineHeight; this.maxWidth = maxWidth; this.colors = colors; this.scratch = scratch; this._allocate = this.allocate.bind(this); return (this._write = this.write.bind(this)); } reset() { super.reset(); return (this.mapped = {}); } begin() { return Array.from(this.rows).map((row) => (row.alive = 0)); } end() { const { mapped } = this; for (const row of Array.from(this.rows.slice())) { if (row.alive === 0) { for (const key of Array.from(row.keys)) { delete mapped[key]; } this.collapse(row); } } } map(text, emit) { // See if already mapped into atlas const { mapped } = this; const c = mapped[text]; if (c != null) { c.row.alive++; return emit(c.x, c.y, c.w, c.h); } // Draw text (don't recurse stack in @draw so it can be optimized cleanly) this.draw(text); const data = this.scratch; const w = this.scratchW; const h = this.scratchH; // Allocate and write into atlas const allocate = this._allocate; const write = this._write; return allocate(text, w, h, function (row, x, y) { mapped[text] = { x, y, w, h, row }; write(data, x, y, w, h); return emit(x, y, w, h); }); } draw(text) { let data, i, j; let w = this.width; const h = this.lineHeight; const o = this.outline; const ctx = this.context; const dst = this.scratch; const max = this.maxWidth; const { colors } = this; // Bottom aligned const x = o + 1; const y = Math.round(h * 1.05 - 1); // Measure text const m = ctx.measureText(text); w = Math.min(max, Math.ceil(m.width + 2 * x + 1)); // Clear scratch area ctx.clearRect(0, 0, w, h); if (this.outline === 0) { // Alpha sprite (fast) let asc, end; ctx.fillText(text, x, y); ({ data } = ctx.getImageData(0, 0, w, h)); j = 3; // Skip to alpha channel for (i = 0, end = data.length / 4, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { //dst[i] = 255 * (i%2); # test pattern to check pixel perfect alignment dst[i] = data[j]; j += 4; } this.scratchW = w; return (this.scratchH = h); } else { // Signed distance field sprite (approximation) (slow) // Draw strokes of decreasing width to create nested outlines (absolute distance) let asc1, start; let asc2, end1; ctx.globalCompositeOperation = "source-over"; for (start = o + 1, i = start, asc1 = start <= 1; asc1 ? i <= 1 : i >= 1; asc1 ? i++ : i--) { j = i > 1 ? i * 2 - 2 : i; // Eliminate odd strokes once past > 1px, don't need the detail ctx.strokeStyle = colors[j - 1]; ctx.lineWidth = j; ctx.strokeText(text, x, y); } //console.log 'stroke', j, j+.5, colors[j] // Fill center with multiply blend #FF0000 to mark inside/outside ctx.globalCompositeOperation = "multiply"; ctx.fillText(text, x, y); // Pull image data ({ data } = ctx.getImageData(0, 0, w, h)); j = 0; const { gamma } = this; for (i = 0, end1 = data.length / 4, asc2 = 0 <= end1; asc2 ? i < end1 : i > end1; asc2 ? i++ : i--) { // Get value + mask const a = data[j]; let mask = a ? data[j + 1] / a : 1; if (gamma === 0.5) { mask = Math.sqrt(mask); } mask = Math.min(1, Math.max(0, mask)); // Blend between positive/outside and negative/inside const b = 256 - a; const c = b + (a - b) * mask; // Clamp // (slight expansion to hide errors around the transition) dst[i] = Math.max(0, Math.min(255, c + 2)); j += 4; } // Debug: copy back into canvas // // TODO hide behind debug flag or delete. /* j = 0 for i in [0...data.length / 4] v = dst[i] *data[j] = v *data[j+1] = v data[j+2] = v data[j+3] = 255 j += 4 ctx.putImageData(imageData, 0, 0); */ this.scratchW = w; return (this.scratchH = h); } } }
cchudzicki/mathbox
build/esm/render/buffer/textatlas.js
JavaScript
mit
8,528
export class BackedTexture extends DataTexture { data: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array; resize(width: any, height: any): any; } import { DataTexture } from "./datatexture.js";
cchudzicki/mathbox
build/esm/render/buffer/texture/backedtexture.d.ts
TypeScript
mit
244
// 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 { DataTexture } from "./datatexture.js"; /* Manually allocated GL texture for data streaming, locally backed. Allows partial updates via subImage. Contains local copy of its data to allow quick resizing without gl.copyTexImage2d (which requires render-to-framebuffer) */ export class BackedTexture extends DataTexture { constructor(renderer, width, height, channels, options) { super(renderer, width, height, channels, options); this.data = new this.ctor(this.n); } resize(width, height) { const old = this.data; const oldWidth = this.width; const oldHeight = this.height; this.width = width; this.height = height; this.n = width * height * this.channels; this.data = new this.ctor(this.n); const { gl } = this; const state = this.renderer.state; state.bindTexture(gl.TEXTURE_2D, this.texture); gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); gl.texImage2D(gl.TEXTURE_2D, 0, this.format, width, height, 0, this.format, this.type, this.data); this.uniforms.dataResolution.value.set(1 / width, 1 / height); return this.write(old, 0, 0, oldWidth, oldHeight); } write(src, x, y, w, h) { let j; const { width } = this; const dst = this.data; const { channels } = this; let i = 0; if (width === w && x === 0) { j = y * w * channels; const n = w * h * channels; while (i < n) { dst[j++] = src[i++]; } } else { const stride = width * channels; const ww = w * channels; const xx = x * channels; let yy = y; const yh = y + h; while (yy < yh) { let k = 0; j = xx + yy * stride; while (k++ < ww) { dst[j++] = src[i++]; } yy++; } } return super.write(src, x, y, w, h); } dispose() { this.data = null; return super.dispose(); } }
cchudzicki/mathbox
build/esm/render/buffer/texture/backedtexture.js
JavaScript
mit
2,426
export class DataTexture { constructor(renderer: any, width: any, height: any, channels: any, options: any); renderer: any; width: any; height: any; channels: any; n: number; gl: any; minFilter: any; magFilter: any; type: any; ctor: Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | undefined; build(options: any): void; texture: any; format: any; format3: any; data: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | undefined; textureObject: any; textureProperties: any; uniforms: { dataResolution: { type: string; value: any; }; dataTexture: { type: string; value: any; }; } | undefined; write(data: any, x: any, y: any, w: any, h: any): any; dispose(): null; }
cchudzicki/mathbox
build/esm/render/buffer/texture/datatexture.d.ts
TypeScript
mit
998
// 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 CONST from "three/src/constants.js"; import * as UThree from "../../../util/three.js"; import { Texture } from "three/src/textures/Texture.js"; import { Vector2 } from "three/src/math/Vector2.js"; /* Manually allocated GL texture for data streaming. Allows partial updates via subImage. */ export class DataTexture { constructor(renderer, width, height, channels, options) { this.renderer = renderer; this.width = width; this.height = height; this.channels = channels; this.n = this.width * this.height * this.channels; const gl = this.renderer.getContext(); this.gl = gl; const minFilter = (options != null ? options.minFilter : undefined) != null ? options != null ? options.minFilter : undefined : CONST.NearestFilter; const magFilter = (options != null ? options.magFilter : undefined) != null ? options != null ? options.magFilter : undefined : CONST.NearestFilter; const type = (options != null ? options.type : undefined) != null ? options != null ? options.type : undefined : CONST.FloatType; this.minFilter = UThree.paramToGL(gl, minFilter); this.magFilter = UThree.paramToGL(gl, magFilter); this.type = UThree.paramToGL(gl, type); this.ctor = UThree.paramToArrayStorage(type); this.build(options); } build(options) { const { gl } = this; const state = this.renderer.state; // Make GL texture this.texture = gl.createTexture(); this.format = [null, gl.LUMINANCE, gl.LUMINANCE_ALPHA, gl.RGB, gl.RGBA][this.channels]; this.format3 = [ null, CONST.LuminanceFormat, CONST.LuminanceAlphaFormat, CONST.RGBFormat, CONST.RGBAFormat, ][this.channels]; state.bindTexture(gl.TEXTURE_2D, this.texture); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this.minFilter); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this.magFilter); // Attach empty data this.data = new this.ctor(this.n); gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); gl.texImage2D(gl.TEXTURE_2D, 0, this.format, this.width, this.height, 0, this.format, this.type, this.data); // Make wrapper texture object. this.textureObject = new Texture(new Image(), CONST.UVMapping, CONST.ClampToEdgeWrapping, CONST.ClampToEdgeWrapping, options != null ? options.minFilter : undefined, options != null ? options.magFilter : undefined); // Pre-init texture to trick WebGLRenderer this.textureProperties = this.renderer.properties.get(this.textureObject); this.textureProperties.__webglInit = true; this.textureProperties.__webglTexture = this.texture; this.textureObject.format = this.format3; this.textureObject.type = CONST.FloatType; this.textureObject.unpackAlignment = 1; this.textureObject.flipY = false; this.textureObject.generateMipmaps = false; // Create uniforms this.uniforms = { dataResolution: { type: "v2", value: new Vector2(1 / this.width, 1 / this.height), }, dataTexture: { type: "t", value: this.textureObject, }, }; } write(data, x, y, w, h) { const { gl } = this; const state = this.renderer.state; // Write to rectangle state.bindTexture(gl.TEXTURE_2D, this.texture); gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false); return gl.texSubImage2D(gl.TEXTURE_2D, 0, x, y, w, h, this.format, this.type, data); } dispose() { this.gl.deleteTexture(this.texture); this.textureProperties.__webglInit = false; this.textureProperties.__webglTexture = null; this.textureProperties = null; return (this.textureObject = this.texture = null); } }
cchudzicki/mathbox
build/esm/render/buffer/texture/datatexture.js
JavaScript
mit
4,756
export class RenderTarget { constructor(gl: any, width: any, height: any, frames: any, options: any); gl: any; options: any; width: any; height: any; frames: any; buffers: any; build(): void; targets: any; reads: any; write: any; uniforms: { dataResolution: { type: string; value: any; }; dataTexture: { type: string; value: any; }; dataTextures: { type: string; value: any; }; } | undefined; cycle(): void; warmup(callback: any): void[]; dispose(): null; }
cchudzicki/mathbox
build/esm/render/buffer/texture/rendertarget.d.ts
TypeScript
mit
642
// 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 * DS205: Consider reworking code to avoid use of IIFEs * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ /* Virtual RenderTarget that cycles through multiple frames Provides easy access to past rendered frames @reads[] and @write contain WebGLRenderTargets whose internal pointers are rotated automatically */ import { NearestFilter, RGBAFormat, UnsignedByteType, } from "three/src/constants.js"; import { Vector2 } from "three/src/math/Vector2.js"; import { WebGLRenderTarget } from "three/src/renderers/WebGLRenderTarget.js"; export class RenderTarget { constructor(gl, width, height, frames, options) { this.gl = gl; if (options == null) { options = {}; } if (options.minFilter == null) { options.minFilter = NearestFilter; } if (options.magFilter == null) { options.magFilter = NearestFilter; } if (options.format == null) { options.format = RGBAFormat; } if (options.type == null) { options.type = UnsignedByteType; } this.options = options; this.width = width || 1; this.height = height || 1; this.frames = frames || 1; this.buffers = this.frames + 1; this.build(); } build() { let i; const make = () => new WebGLRenderTarget(this.width, this.height, this.options); this.targets = (() => { let asc, end; const result = []; for (i = 0, end = this.buffers, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { result.push(make()); } return result; })(); const acc = []; this.targets.forEach((target) => acc.push(target.texture)); this.reads = acc; this.write = this.targets[this.buffers - 1]; // Texture access uniforms this.uniforms = { dataResolution: { type: "v2", value: new Vector2(1 / this.width, 1 / this.height), }, dataTexture: { type: "t", value: this.reads[0], }, dataTextures: { type: "tv", value: this.reads, }, }; } cycle() { this.targets.unshift(this.targets.pop()); this.write = this.targets[this.buffers - 1]; this.reads.unshift(this.reads.pop()); this.uniforms.dataTexture.value = this.reads[0]; } warmup(callback) { return (() => { const result = []; for (let i = 0, end = this.buffers, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { callback(this.write); result.push(this.cycle()); } return result; })(); } dispose() { for (const target of Array.from(this.targets)) { target.dispose(); } return (this.targets = this.reads = this.write = null); } }
cchudzicki/mathbox
build/esm/render/buffer/texture/rendertarget.js
JavaScript
mit
3,420
export class VoxelBuffer extends DataBuffer { build(_options: any): { emit: ((x: any, y: any, z: any, w: any) => void) | undefined; consume: ((emit: any) => void) | undefined; skip: ((n: any) => void) | undefined; count: () => any; done: () => boolean; reset: () => number; }; pad: { x: number; y: number; z: number; } | undefined; setActive(i: any, j: any, k: any): number[]; fill(): number; } import { DataBuffer } from "./databuffer.js";
cchudzicki/mathbox
build/esm/render/buffer/voxelbuffer.d.ts
TypeScript
mit
537
// 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 * DS104: Avoid inline assignments * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ import * as UData from "../../util/data.js"; import { DataBuffer } from "./databuffer.js"; // // 3D array // export class VoxelBuffer extends DataBuffer { build(_options) { super.build(); this.pad = { x: 0, y: 0, z: 0 }; return (this.streamer = this.generate(this.data)); } setActive(i, j, k) { let ref; return (([this.pad.x, this.pad.y, this.pad.z] = Array.from((ref = [ Math.max(0, this.width - i), Math.max(0, this.height - j), Math.max(0, this.depth - k), ]))), ref); } fill() { let j, k, l, repeat; const { callback } = this; if (typeof callback.reset === "function") { callback.reset(); } const { emit, skip, count, done, reset } = this.streamer; reset(); const n = this.width; const m = this.height; const padX = this.pad.x; const padY = this.pad.y; const limit = this.samples - this.pad.z * n * m; let i = (j = k = l = 0); if (padX > 0 || padY > 0) { while (!done() && l < limit) { l++; repeat = callback(emit, i, j, k); if (++i === n - padX) { skip(padX); i = 0; if (++j === m - padY) { skip(n * padY); j = 0; k++; } } if (repeat === false) { break; } } } else { while (!done() && l < limit) { l++; repeat = callback(emit, i, j, k); if (++i === n) { i = 0; if (++j === m) { j = 0; k++; } } if (repeat === false) { break; } } } return Math.floor(count() / this.items); } through(callback, target) { // must be identical sized buffers w/ identical active areas let dst, j, k, src; const { consume, done, skip } = (src = this.streamer); const { emit } = (dst = target.streamer); let i = (j = k = 0); let pipe = () => consume((x, y, z, w) => callback(emit, x, y, z, w, i, j, k)); pipe = UData.repeatCall(pipe, this.items); return () => { let l; src.reset(); dst.reset(); const n = this.width; const m = this.height; const padX = this.pad.x; const padY = this.pad.y; const limit = this.samples - this.pad.z * n * m; i = j = k = l = 0; if (padX > 0 || padY > 0) { while (!done() && l < limit) { l++; pipe(); if (++i === n - padX) { skip(padX); i = 0; if (++j === m - padY) { skip(n * padY); j = 0; k++; } } } } else { while (!done() && l < limit) { l++; pipe(); if (++i === n) { i = 0; if (++j === m) { j = 0; k++; } } } } return src.count(); }; } }
cchudzicki/mathbox
build/esm/render/buffer/voxelbuffer.js
JavaScript
mit
4,129
export namespace Classes { export { Sprite as sprite }; export { Point as point }; export { Line as line }; export { Surface as surface }; export { Face as face }; export { Strip as strip }; export { Arrow as arrow }; export { Screen as screen }; export { MemoScreen as memoScreen }; export { Debug as debug }; export { DataBuffer as dataBuffer }; export { ArrayBuffer_ as arrayBuffer }; export { MatrixBuffer as matrixBuffer }; export { VoxelBuffer as voxelBuffer }; export { PushBuffer as pushBuffer }; export { RenderToTexture as renderToTexture }; export { Memo as memo }; export { Readback as readback }; export { Atlas as atlas }; export { TextAtlas as textAtlas }; export { Scene as scene }; } import { Sprite } from "./meshes/sprite.js"; import { Point } from "./meshes/point.js"; import { Line } from "./meshes/line.js"; import { Surface } from "./meshes/surface.js"; import { Face } from "./meshes/face.js"; import { Strip } from "./meshes/strip.js"; import { Arrow } from "./meshes/arrow.js"; import { Screen } from "./meshes/screen.js"; import { MemoScreen } from "./meshes/memoscreen.js"; import { Debug } from "./meshes/debug.js"; import { DataBuffer } from "./buffer/databuffer.js"; import { ArrayBuffer_ } from "./buffer/arraybuffer.js"; import { MatrixBuffer } from "./buffer/matrixbuffer.js"; import { VoxelBuffer } from "./buffer/voxelbuffer.js"; import { PushBuffer } from "./buffer/pushbuffer.js"; import { RenderToTexture } from "./buffer/rendertotexture.js"; import { Memo } from "./buffer/memo.js"; import { Readback } from "./buffer/readback.js"; import { Atlas } from "./buffer/atlas.js"; import { TextAtlas } from "./buffer/textatlas.js"; import { Scene } from "./scene.js";
cchudzicki/mathbox
build/esm/render/classes.d.ts
TypeScript
mit
1,786
import { ArrayBuffer_ } from "./buffer/arraybuffer.js"; import { Arrow } from "./meshes/arrow.js"; import { Atlas } from "./buffer/atlas.js"; import { DataBuffer } from "./buffer/databuffer.js"; import { Debug } from "./meshes/debug.js"; import { Face } from "./meshes/face.js"; import { Line } from "./meshes/line.js"; import { MatrixBuffer } from "./buffer/matrixbuffer.js"; import { Memo } from "./buffer/memo.js"; import { MemoScreen } from "./meshes/memoscreen.js"; import { Point } from "./meshes/point.js"; import { PushBuffer } from "./buffer/pushbuffer.js"; import { Readback } from "./buffer/readback.js"; import { RenderToTexture } from "./buffer/rendertotexture.js"; import { Scene } from "./scene.js"; import { Screen } from "./meshes/screen.js"; import { Sprite } from "./meshes/sprite.js"; import { Strip } from "./meshes/strip.js"; import { Surface } from "./meshes/surface.js"; import { TextAtlas } from "./buffer/textatlas.js"; import { VoxelBuffer } from "./buffer/voxelbuffer.js"; export const Classes = { sprite: Sprite, point: Point, line: Line, surface: Surface, face: Face, strip: Strip, arrow: Arrow, screen: Screen, memoScreen: MemoScreen, debug: Debug, dataBuffer: DataBuffer, arrayBuffer: ArrayBuffer_, matrixBuffer: MatrixBuffer, voxelBuffer: VoxelBuffer, pushBuffer: PushBuffer, renderToTexture: RenderToTexture, memo: Memo, readback: Readback, atlas: Atlas, textAtlas: TextAtlas, scene: Scene, };
cchudzicki/mathbox
build/esm/render/classes.js
JavaScript
mit
1,512
export class RenderFactory { constructor(classes: any, renderer: any, shaders: any); classes: any; renderer: any; shaders: any; getTypes(): string[]; make(type: any, options: any): any; }
cchudzicki/mathbox
build/esm/render/factory.d.ts
TypeScript
mit
212
// 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 */ export class RenderFactory { constructor(classes, renderer, shaders) { this.classes = classes; this.renderer = renderer; this.shaders = shaders; } getTypes() { return Object.keys(this.classes); } make(type, options) { return new this.classes[type](this.renderer, this.shaders, options); } }
cchudzicki/mathbox
build/esm/render/factory.js
JavaScript
mit
661
export class ArrowGeometry extends ClipGeometry { constructor(options: any); sides: number; samples: number; strips: number; ribbons: number; layers: number; flip: any; anchor: any; clip(samples: any, strips: any, ribbons: any, layers: any): void; } import { ClipGeometry } from "./clipgeometry.js";
cchudzicki/mathbox
build/esm/render/geometry/arrowgeometry.d.ts
TypeScript
mit
336
// 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"; /* Cones to attach as arrowheads on line strips .....> .....> .....> .....> .....> .....> .....> .....> .....> .....> .....> .....> */ export class ArrowGeometry extends ClipGeometry { constructor(options) { let anchor, flip, k, layers, ribbons, samples, sides, strips; let asc, end; super(options); this._clipUniforms(); this.sides = sides = +options.sides || 12; this.samples = samples = +options.samples || 2; this.strips = strips = +options.strips || 1; this.ribbons = ribbons = +options.ribbons || 1; this.layers = layers = +options.layers || 1; this.flip = flip = options.flip != null ? options.flip : false; this.anchor = anchor = options.anchor != null ? options.anchor : flip ? 0 : samples - 1; const arrows = strips * ribbons * layers; const points = (sides + 2) * arrows; const triangles = sides * 2 * arrows; this.setIndex(new BufferAttribute(new Uint32Array(triangles * 3), 1)); this.setAttribute("position4", new BufferAttribute(new Float32Array(points * 4), 4)); this.setAttribute("arrow", new BufferAttribute(new Float32Array(points * 3), 3)); this.setAttribute("attach", new BufferAttribute(new Float32Array(points * 2), 2)); const index = this._emitter("index"); const position = this._emitter("position4"); const arrow = this._emitter("arrow"); const attach = this._emitter("attach"); const circle = []; for (k = 0, end = sides, asc = 0 <= end; asc ? k < end : k > end; asc ? k++ : k--) { const angle = (k / sides) * 2 * Math.PI; circle.push([Math.cos(angle), Math.sin(angle), 1]); } let base = 0; for (let i = 0, end1 = arrows, asc1 = 0 <= end1; asc1 ? i < end1 : i > end1; asc1 ? i++ : i--) { let asc2, end2; const tip = base++; const back = tip + sides + 1; for (k = 0, end2 = sides, asc2 = 0 <= end2; asc2 ? k < end2 : k > end2; asc2 ? k++ : k--) { const a = base + (k % sides); const b = base + ((k + 1) % sides); index(tip); index(a); index(b); index(b); index(a); index(back); } base += sides + 1; } const step = flip ? 1 : -1; const far = flip ? samples - 1 : 0; const near = anchor + step; const x = anchor; for (let l = 0, end3 = layers, asc3 = 0 <= end3; asc3 ? l < end3 : l > end3; asc3 ? l++ : l--) { for (let z = 0, end4 = ribbons, asc4 = 0 <= end4; asc4 ? z < end4 : z > end4; asc4 ? z++ : z--) { for (let y = 0, end5 = strips, asc5 = 0 <= end5; asc5 ? y < end5 : y > end5; asc5 ? y++ : y--) { let asc6, end6; position(x, y, z, l); arrow(0, 0, 0); attach(near, far); for (k = 0, end6 = sides, asc6 = 0 <= end6; asc6 ? k < end6 : k > end6; asc6 ? k++ : k--) { position(x, y, z, l); const c = circle[k]; arrow(c[0], c[1], c[2]); attach(near, far); } position(x, y, z, l); arrow(0, 0, 1); attach(near, far); } } } this._finalize(); this.clip(); } clip(samples, strips, ribbons, layers) { let quads; if (samples == null) { ({ samples } = this); } if (strips == null) { ({ strips } = this); } if (ribbons == null) { ({ ribbons } = this); } if (layers == null) { ({ layers } = this); } this._clipGeometry(samples, strips, ribbons, layers); if (samples > this.anchor) { const dims = [layers, ribbons, strips]; const maxs = [this.layers, this.ribbons, this.strips]; quads = this.sides * this._reduce(dims, maxs); } else { quads = 0; } return this._offsets([ { start: 0, count: quads * 6, materialIndex: 0, }, ]); } }
cchudzicki/mathbox
build/esm/render/geometry/arrowgeometry.js
JavaScript
mit
4,931
export class ClipGeometry extends Geometry { _clipUniforms(): { type: string; value: any; }; geometryClip: any; geometryResolution: any; mapSize: any; _clipGeometry(width: any, height: any, depth: any, items: any): any; _clipMap(mapWidth: any, mapHeight: any, mapDepth: any, mapItems: any): any; _clipOffsets(factor: any, width: any, height: any, depth: any, items: any, _width: any, _height: any, _depth: any, _items: any): void; } import { Geometry } from "./geometry.js";
cchudzicki/mathbox
build/esm/render/geometry/clipgeometry.d.ts
TypeScript
mit
523
// 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 { Geometry } from "./geometry.js"; import { Vector4 } from "three/src/math/Vector4.js"; // Instanced geometry that is clippable along 4 dimensions export class ClipGeometry extends Geometry { _clipUniforms() { this.geometryClip = new Vector4(1e10, 1e10, 1e10, 1e10); this.geometryResolution = new Vector4(); this.mapSize = new Vector4(); if (this.uniforms == null) { this.uniforms = {}; } this.uniforms.geometryClip = { type: "v4", value: this.geometryClip, }; this.uniforms.geometryResolution = { type: "v4", value: this.geometryResolution, }; return (this.uniforms.mapSize = { type: "v4", value: this.mapSize, }); } _clipGeometry(width, height, depth, items) { const c = (x) => Math.max(0, x - 1); const r = (x) => 1 / Math.max(1, x - 1); this.geometryClip.set(c(width), c(height), c(depth), c(items)); return this.geometryResolution.set(r(width), r(height), r(depth), r(items)); } _clipMap(mapWidth, mapHeight, mapDepth, mapItems) { return this.mapSize.set(mapWidth, mapHeight, mapDepth, mapItems); } _clipOffsets(factor, width, height, depth, items, _width, _height, _depth, _items) { const dims = [depth, height, width, items]; const maxs = [_depth, _height, _width, _items]; const elements = this._reduce(dims, maxs); return this._offsets([ { start: 0, count: elements * factor, materialIndex: 0, }, ]); } }
cchudzicki/mathbox
build/esm/render/geometry/clipgeometry.js
JavaScript
mit
2,036
export class FaceGeometry 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/facegeometry.d.ts
TypeScript
mit
293
// 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"; /* (flat) Triangle fans arranged in items, columns and rows +-+ +-+ +-+ +-+ |\\\ |\\\ |\\\ |\\\ +-+-+ +-+-+ +-+-+ +-+-+ +-+ +-+ +-+ +-+ |\\\ |\\\ |\\\ |\\\ +-+-+ +-+-+ +-+-+ +-+-+ +-+ +-+ +-+ +-+ |\\\ |\\\ |\\\ |\\\ +-+-+ +-+-+ +-+-+ +-+-+ */ export class FaceGeometry 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)); const index = this._emitter("index"); const position = this._emitter("position4"); let base = 0; for (let i = 0, end = samples, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { for (let j = 0, end1 = sides, asc1 = 0 <= end1; asc1 ? j < end1 : j > end1; asc1 ? j++ : j--) { index(base); index(base + j + 1); index(base + j + 2); } base += items; } 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--) { for (let l = 0, end5 = items, asc5 = 0 <= end5; asc5 ? l < end5 : l > end5; asc5 ? l++ : l--) { position(x, y, z, l); } } } } 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/facegeometry.js
JavaScript
mit
3,220
export class Geometry { uniforms: {}; groups: any[]; _reduce(dims: any, maxs: any): any; _emitter(name: any): ((a: any, b: any, c: any, d: any) => void) | null; _finalize(): void; _offsets(offsets: any): void; }
cchudzicki/mathbox
build/esm/render/geometry/geometry.d.ts
TypeScript
mit
236
// 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 { BufferGeometry } from "three/src/core/BufferGeometry.js"; export class Geometry extends BufferGeometry { constructor() { super(); new BufferGeometry(this); if (this.uniforms == null) { this.uniforms = {}; } if (this.groups == null) { this.groups = []; } } _reduce(dims, maxs) { let multiple = false; for (let i = 0; i < dims.length; i++) { const dim = dims[i]; const max = maxs[i]; if (multiple) { dims[i] = max; } if (dim > 1) { multiple = true; } } return dims.reduce((a, b) => a * b); } _emitter(name) { const attribute = name == "index" ? this.getIndex() : this.getAttribute(name); const dimensions = attribute.itemSize; const { array } = attribute; let offset = 0; const one = function (a) { array[offset++] = a; }; const two = function (a, b) { array[offset++] = a; array[offset++] = b; }; const three = function (a, b, c) { array[offset++] = a; array[offset++] = b; array[offset++] = c; }; const four = function (a, b, c, d) { array[offset++] = a; array[offset++] = b; array[offset++] = c; array[offset++] = d; }; return [null, one, two, three, four][dimensions]; } _finalize() { return; } _offsets(offsets) { this.groups = offsets; } }
cchudzicki/mathbox
build/esm/render/geometry/geometry.js
JavaScript
mit
2,086
export * from "./geometry.js"; export * from "./arrowgeometry.js"; export * from "./facegeometry.js"; export * from "./linegeometry.js"; export * from "./screengeometry.js"; export * from "./spritegeometry.js"; export * from "./stripgeometry.js"; export * from "./surfacegeometry.js";
cchudzicki/mathbox
build/esm/render/geometry/index.d.ts
TypeScript
mit
285
export * from "./geometry.js"; export * from "./arrowgeometry.js"; export * from "./facegeometry.js"; export * from "./linegeometry.js"; export * from "./screengeometry.js"; export * from "./spritegeometry.js"; export * from "./stripgeometry.js"; export * from "./surfacegeometry.js";
cchudzicki/mathbox
build/esm/render/geometry/index.js
JavaScript
mit
285
export class LineGeometry extends ClipGeometry { constructor(options: any); closed: any; samples: number; strips: number; ribbons: number; layers: number; detail: number; joints: number; vertices: number; segments: number; clip(samples: any, strips: any, ribbons: any, layers: any): void; } import { ClipGeometry } from "./clipgeometry.js";
cchudzicki/mathbox
build/esm/render/geometry/linegeometry.d.ts
TypeScript
mit
385
// 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"; /* Line strips arranged in columns and rows +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ */ export class LineGeometry extends ClipGeometry { constructor(options) { let closed, detail, edge, joint, joints, l, layers, ribbons, samples, segments, strips, vertices, x, y, z; super(options); this._clipUniforms(); this.closed = closed = options.closed || false; this.samples = samples = (+options.samples || 2) + (closed ? 1 : 0); this.strips = strips = +options.strips || 1; this.ribbons = ribbons = +options.ribbons || 1; this.layers = layers = +options.layers || 1; this.detail = detail = +options.detail || 1; const lines = samples - 1; this.joints = joints = detail - 1; this.vertices = vertices = (lines - 1) * joints + samples; this.segments = segments = (lines - 1) * joints + lines; const wrap = samples - (closed ? 1 : 0); const points = vertices * strips * ribbons * layers * 2; const quads = segments * strips * ribbons * 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("line", new BufferAttribute(new Float32Array(points * 2), 2)); this.setAttribute("strip", new BufferAttribute(new Float32Array(points * 2), 2)); if (detail > 1) { this.setAttribute("joint", new BufferAttribute(new Float32Array(points), 1)); } const index = this._emitter("index"); const position = this._emitter("position4"); const line = this._emitter("line"); const strip = this._emitter("strip"); if (detail > 1) { joint = this._emitter("joint"); } let base = 0; for (let i = 0, end = ribbons * layers, asc = 0 <= end; asc ? i < end : i > end; asc ? i++ : i--) { for (let j = 0, end1 = strips, asc1 = 0 <= end1; asc1 ? j < end1 : j > end1; asc1 ? j++ : j--) { for (let k = 0, end2 = segments, asc2 = 0 <= end2; asc2 ? k < end2 : k > end2; asc2 ? k++ : k--) { // note implied - 1 index(base); index(base + 1); index(base + 2); index(base + 2); index(base + 1); index(base + 3); base += 2; } base += 2; } } const edger = closed ? () => 0 : function (x) { if (x === 0) { return -1; } else if (x === samples - 1) { return 1; } else { return 0; } }; if (detail > 1) { let asc3, end3; for (l = 0, end3 = layers, asc3 = 0 <= end3; asc3 ? l < end3 : l > end3; asc3 ? l++ : l--) { let asc4, end4; for (z = 0, end4 = ribbons, asc4 = 0 <= end4; asc4 ? z < end4 : z > end4; asc4 ? z++ : z--) { let asc5, end5; for (y = 0, end5 = strips, asc5 = 0 <= end5; asc5 ? y < end5 : y > end5; asc5 ? y++ : y--) { let asc6, end6, i1; for (i1 = 0, x = i1, end6 = samples, asc6 = 0 <= end6; asc6 ? i1 < end6 : i1 > end6; asc6 ? i1++ : i1--, x = i1) { if (closed) { x = x % wrap; } edge = edger(x); if (edge !== 0) { position(x, y, z, l); position(x, y, z, l); line(edge, 1); line(edge, -1); strip(0, segments); strip(0, segments); joint(0.5); joint(0.5); } else { for (let m = 0, end7 = detail, asc7 = 0 <= end7; asc7 ? m < end7 : m > end7; asc7 ? m++ : m--) { position(x, y, z, l); position(x, y, z, l); line(edge, 1); line(edge, -1); strip(0, segments); strip(0, segments); joint(m / joints); joint(m / joints); } } } } } } } else { let asc8, end8; for (l = 0, end8 = layers, asc8 = 0 <= end8; asc8 ? l < end8 : l > end8; asc8 ? l++ : l--) { let asc9, end9; for (z = 0, end9 = ribbons, asc9 = 0 <= end9; asc9 ? z < end9 : z > end9; asc9 ? z++ : z--) { let asc10, end10; for (y = 0, end10 = strips, asc10 = 0 <= end10; asc10 ? y < end10 : y > end10; asc10 ? y++ : y--) { let asc11, end11, j1; for (j1 = 0, x = j1, end11 = samples, asc11 = 0 <= end11; asc11 ? j1 < end11 : j1 > end11; asc11 ? j1++ : j1--, x = j1) { if (closed) { x = x % wrap; } edge = edger(x); position(x, y, z, l); position(x, y, z, l); line(edge, 1); line(edge, -1); strip(0, segments); strip(0, segments); } } } } } this._finalize(); this.clip(); } clip(samples, strips, ribbons, layers) { if (samples == null) { samples = this.samples - this.closed; } if (strips == null) { ({ strips } = this); } if (ribbons == null) { ({ ribbons } = this); } if (layers == null) { ({ layers } = this); } let segments = Math.max(0, samples - (this.closed ? 0 : 1)); const vertices = samples + (samples - 2) * this.joints; segments = vertices - 1; this._clipGeometry(vertices, strips, ribbons, layers); return this._clipOffsets(6, segments, strips, ribbons, layers, this.segments, this.strips, this.ribbons, this.layers); } }
cchudzicki/mathbox
build/esm/render/geometry/linegeometry.js
JavaScript
mit
7,440