Skip to content

Method refactor like setUniform, RenderPass, etc #275

@Absulit

Description

@Absulit

There are a lot of methods with a high number of parameters; something that was convenient in the past has become a bit too much now that some of these methods have a lot of parameters

Main Points Class

setUniform(name, value, structName = null) 
setStorage(name, structName, read, shaderType = GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE, arrayData = null) 
setStorageMap(name, arrayData, structName, read = false, shaderType = GPUShaderStage.VERTEX | GPUShaderStage.FRAGMENT | GPUShaderStage.COMPUTE) 

RenderPass Class

constructor(vertexShader, fragmentShader, computeShader, workgroupCountX, workgroupCountY, workgroupCountZ, init)


setCube(
    name,
    coordinate = { x: 0, y: 0, z: 0 },
    dimensions = { width: 1, height: 1, depth: 1 },
    color = { r: 1, g: 0, b: 1, a: 0 }
)

among others

The idea here would be to apply two changes
1- pass a config object as only parameter
2- use also a Builder Pattern, to call separate methods and leave the others as default

const r0 = new RenderPass({...}) // here all its attributes or none
r0.setVertexShader(vertexvar)
  .setFragmentShader(fragmentvar)
  .setWorkGroupCountX(8)

points.setCube().setName('myCube')

A note here to review #277, because of the new points.params / points.uniforms, we need a Uniforms class to make sure the user doesn't overwrite the uniform accidentally. Using maybe Proxy.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions