Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dataText.format = gl.RGBA;
dataText.type = gl.FLOAT;
// dataText.uploadData(dataPos, 2, 3);
// console.log(this.sphere.geometry.positions._data.length/3);
console.log(geom);
dataText.uploadData(new Float32Array(prim.positions), 2, 2);
this.gpu = new PingPong({
data: dataText,
width,
height,
timeAdd: 0.001,
renderer: this.webgl,
camera: new G.OrthographicCamera(-1, 1, -1, 1, 0.1, 100),
vs: glslify('./shaders/basic.vert'),
fs: glslify('./shaders/sim.frag'),
uniforms: {
uMouse: [0, 0, 0],
},
});
this.fboHelper.attach(this.gpu.fboOut.colors);
this.sphere = new G.Mesh(geom, new G.Shader(
`
attribute vec3 aPosition;
attribute vec2 aUv;
attribute vec2 aCuvs;
count++;
}
let dataTexture = new G.Texture(gl);
dataTexture.format = gl.RGBA;
dataTexture.type = gl.FLOAT;
dataTexture.uploadData(dataPos, width, height)
this.fboHelper.attach(dataTexture);
this.gpu = new PingPong({
data:dataTexture,
width,
height,
renderer:this.webgl,
camera: new G.OrthographicCamera(-1,1,-1,1,0.1,100),
vs: glslify('./shaders/line/base.vert'),
fs: glslify('./shaders/line/sim.frag'),
uniforms: {
}
})
this.fboHelper.attach(this.gpu.fboOut.colors);
// this.initComposer();
}
initComposer() {
constructor()
{
this.webgl = new G.Webgl();
this.webgl.clearColor('#ffe1d9', 1);
this.webgl.append();
this.camera = new G.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 500);
this.controls = new OrbitalCameraControl(this.camera, 20, window);
this.controls.center = [4, 0, 0];
this.fboHelper = new G.FBOHelper(this.webgl, 256);
// this.cameraShadow = new G.PerspectiveCamera(45, 1, 0.1, 100);
const s = 15;
this.cameraShadow = new G.OrthographicCamera(-s, s, -s, s, 1, 100);
this.cameraShadow.lookAt([0, 50, 0.1], [0, 0, 0], [0, 1, 0]);
this.mvpDepth = mat4.create();
mat4.multiply(this.mvpDepth, this.cameraShadow.projection, this.cameraShadow.view);
const biaMatrix = mat4.fromValues(
0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0,
0.5, 0.5, 0.5, 1.0
);
mat4.multiply(this.mvpDepth, biaMatrix, this.mvpDepth);
this.fbo = new G.FrameBuffer(gl, 1024, 1024, { depth: true });
this.fboHelper.attach(this.fbo.depth);
this.fboHelper.attach(this.fbo.colors);
}
const dataText = new G.Texture(gl);
dataText.format = gl.RGBA;
dataText.type = gl.FLOAT;
dataText.uploadData(dataPos, width, height);
this.gpu = new PingPong({
data: dataText,
width,
height,
timeAdd: 0.001,
renderer: scene.webgl,
camera: new G.OrthographicCamera(-1, 1, -1, 1, 0.1, 100),
vs: glslify('./shaders/basic.vert'),
fs: glslify('./shaders/sim.frag'),
uniforms: {
uMouse: [0, 0, 0],
},
});
const geometry = new G.Geometry();
geometry.addAttribute('positions', pos, true);
geometry.addAttribute('colors', colors, true);
geometry.addAttribute('twouvs', uvs, true);
geometry.addAttribute('sizes', size, true);
const normal = this.normal = new G.Texture(gl);