trsh Posted May 11, 2020 Share Posted May 11, 2020 (edited) The below code just makes the triangle disapear: const app = new PIXI.Application(); document.body.appendChild(app.view); const geometry = new PIXI.Geometry() .addAttribute('aVertexPosition', [-100, -50, 100, -50, 0, 100]); const shader = PIXI.Shader.from(` precision mediump float; attribute vec2 aVertexPosition; uniform mat3 translationMatrix; uniform mat3 projectionMatrix; void main() { gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); }`, `precision mediump float; void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); } `); const triangle = new PIXI.Mesh(geometry, shader); triangle.position.set(400, 300); app.stage.addChild(triangle); const buffer = geometry.getBuffer('aVertexPosition'); app.ticker.add((delta) => { //triangle.rotation += 0.01; buffer.update([-100, -50, 100, -50, 0, 140]); }); Edited May 11, 2020 by trsh Solved Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted May 11, 2020 Share Posted May 11, 2020 i think you have to use Float32Array in that case. Add `new Float32Array([...])` there. Alternative: change elements in existing array in buffer (buffer.data or buffer._data i dont remember) and then call update() Quote Link to comment Share on other sites More sharing options...
trsh Posted May 11, 2020 Author Share Posted May 11, 2020 41 minutes ago, ivan.popelyshev said: i think you have to use Float32Array in that case. Add `new Float32Array([...])` there. Alternative: change elements in existing array in buffer (buffer.data or buffer._data i dont remember) and then call update() Yeah it requires new Float32Array in any case. Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.