Fix bugs with polygons
This commit is contained in:
parent
c110f110d2
commit
fbd85a667e
3 changed files with 11 additions and 10 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { mat2d, vec2 } from 'gl-matrix';
|
||||
import { mat2d, vec2, vec3, vec4 } from 'gl-matrix';
|
||||
import { codeForColorAccess } from '../../helper/code-for-color-access';
|
||||
import { Drawable } from '../drawable';
|
||||
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||
import { PolygonBase, PolygonFactory } from './polygon-factory';
|
||||
|
|
@ -11,9 +12,9 @@ interface NoisyPolygonBase extends PolygonBase {
|
|||
*/
|
||||
export const NoisyPolygonFactory = (
|
||||
vertexCount: number,
|
||||
colorIndex: number
|
||||
color: vec3 | vec4 | number
|
||||
): typeof PolygonBase & NoisyPolygonBase => {
|
||||
class NoisyPolygon extends PolygonFactory(vertexCount, colorIndex) {
|
||||
class NoisyPolygon extends PolygonFactory(vertexCount, color) {
|
||||
public static descriptor: DrawableDescriptor = {
|
||||
sdf: {
|
||||
shader: `
|
||||
|
|
@ -50,7 +51,7 @@ export const NoisyPolygonFactory = (
|
|||
}
|
||||
|
||||
float noisyPolygon${vertexCount}MinDistance(vec2 target, out vec4 color) {
|
||||
color = readFromPalette(${colorIndex});
|
||||
color = ${codeForColorAccess(color)};
|
||||
|
||||
float minDistance = 100.0;
|
||||
|
||||
|
|
@ -100,12 +101,11 @@ export const NoisyPolygonFactory = (
|
|||
distanceFunctionName: `noisyPolygon${vertexCount}MinDistance`,
|
||||
},
|
||||
propertyUniformMapping: {
|
||||
vertices: `noisyPolygon${vertexCount}Vertices`,
|
||||
length: `noisyPolygon${vertexCount}Lengths`,
|
||||
random: `noisyPolygon${vertexCount}Randoms`,
|
||||
center: `noisyPolygon${vertexCount}Centers`,
|
||||
vertices: `noisyPolygon${vertexCount}Vertices`,
|
||||
},
|
||||
objectCountScaler: 1 / vertexCount,
|
||||
uniformCountMacroName: `NOISY_POLGYON${vertexCount}_COUNT`,
|
||||
shaderCombinationSteps: [0, 1, 2, 3, 8, 16],
|
||||
empty: (new NoisyPolygon(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { mat2d, vec2 } from 'gl-matrix';
|
||||
import { mat2d, vec2, vec3, vec4 } from 'gl-matrix';
|
||||
import { clamp01 } from '../../helper/clamp';
|
||||
import { codeForColorAccess } from '../../helper/code-for-color-access';
|
||||
import { Drawable } from '../drawable';
|
||||
import { DrawableDescriptor } from '../drawable-descriptor';
|
||||
import { EmptyDrawable } from '../empty-drawable';
|
||||
|
|
@ -18,7 +19,7 @@ export class PolygonBase extends EmptyDrawable {
|
|||
*/
|
||||
export const PolygonFactory = (
|
||||
vertexCount: number,
|
||||
colorIndex: number
|
||||
color: vec3 | vec4 | number
|
||||
): typeof PolygonBase => {
|
||||
class Polygon extends PolygonBase {
|
||||
public static descriptor: DrawableDescriptor = {
|
||||
|
|
@ -42,7 +43,7 @@ export const PolygonFactory = (
|
|||
}
|
||||
|
||||
float polygon${vertexCount}MinDistance(vec2 target, out vec4 color) {
|
||||
color = readFromPalette(${colorIndex});
|
||||
color = ${codeForColorAccess(color)};
|
||||
|
||||
float minDistance = 100.0;
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export class UniformArrayAutoScalingProgram implements IProgram {
|
|||
|
||||
public draw(uniforms: { [name: string]: any }): void {
|
||||
const values = this.descriptors.map((d) => {
|
||||
const uniformNames = last(Object.entries(d.propertyUniformMapping));
|
||||
const uniformNames = Object.entries(d.propertyUniformMapping)[0];
|
||||
if (!uniformNames) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue