Options
All
  • Public
  • Public/Protected
  • All
Menu

Class InvertedTunnel

Hierarchy

Index

Constructors

Properties

Methods

Object literals

Constructors

constructor

  • new InvertedTunnel(from: vec2, to: vec2, fromRadius: number, toRadius: number): InvertedTunnel

Properties

Readonly from

from: vec2

Readonly fromRadius

fromRadius: number

Readonly to

to: vec2

Readonly toRadius

toRadius: number

Methods

Protected getObjectToSerialize

  • getObjectToSerialize(transform2d: mat2d, transform1d: number): any

minDistance

  • minDistance(target: vec2): number

Object literals

Static descriptor

descriptor: object

empty

empty: InvertedTunnel = new InvertedTunnel(vec2.fromValues(10000, 10000),vec2.fromValues(10000, 10000),0,0)

shaderCombinationSteps

shaderCombinationSteps: number[] = [0, 1, 4, 16, 32]

uniformCountMacroName

uniformCountMacroName: string = "INVERTED_TUNNEL_COUNT"

propertyUniformMapping

propertyUniformMapping: object

from

from: string = "froms"

fromRadius

fromRadius: string = "fromRadii"

toFromDelta

toFromDelta: string = "toFromDeltas"

toRadius

toRadius: string = "toRadii"

sdf

sdf: object

distanceFunctionName

distanceFunctionName: string = "invertedTunnelMinDistance"

isInverted

isInverted: true = true

shader

shader: string = `uniform vec2 froms[INVERTED_TUNNEL_COUNT];uniform vec2 toFromDeltas[INVERTED_TUNNEL_COUNT];uniform float fromRadii[INVERTED_TUNNEL_COUNT];uniform float toRadii[INVERTED_TUNNEL_COUNT];uniform sampler2D noiseTexture;#ifdef WEBGL2_IS_AVAILABLEfloat myTerrain(float h) {return texture(noiseTexture,vec2(h, 0.5))[0] - 0.5;}#elsefloat myTerrain(float h) {return texture2D(noiseTexture,vec2(h, 0.5))[0] - 0.5;}#endiffloat invertedTunnelMinDistance(vec2 target, out float colorIndex) {colorIndex = 3.0;float minDistance = 1000.0;for (int i = 0; i < INVERTED_TUNNEL_COUNT; i++) {vec2 targetFromDelta = target - froms[i];float h = dot(targetFromDelta, toFromDeltas[i])/ dot(toFromDeltas[i], toFromDeltas[i]);float clampedH = clamp(h, 0.0, 1.0);float currentDistance = -mix(fromRadii[i], toRadii[i], clampedH) + distance(targetFromDelta, toFromDeltas[i] * clampedH) - myTerrain(h) / 12.0;minDistance = min(minDistance, currentDistance);}return -minDistance;}`