Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate Model and View Matrices. #6761

Merged
merged 35 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2d9b090
separate model and view matrices
deveshidwivedi Jan 18, 2024
6eab6f7
Merge branch 'processing:main' into model-view
deveshidwivedi Jan 18, 2024
7267e59
Update package.json
deveshidwivedi Jan 18, 2024
0520b09
Merge branch 'processing:main' into model-view
deveshidwivedi Jan 19, 2024
c1d972f
Update p5.Shader.js
deveshidwivedi Jan 21, 2024
ee1962a
Update p5.Camera.js
deveshidwivedi Jan 21, 2024
35b5133
Update p5.Framebuffer.js
deveshidwivedi Jan 21, 2024
639c8cf
Update p5.RendererGL.js
deveshidwivedi Jan 21, 2024
85fff06
Update p5.Shader.js
deveshidwivedi Jan 21, 2024
d1d429d
reset method created
deveshidwivedi Jan 21, 2024
25e0ac3
Merge branch 'processing:main' into model-view
deveshidwivedi Jan 21, 2024
5dc6ccf
use .set method for matrix updates
deveshidwivedi Jan 24, 2024
7605bd3
use .set method for matrix updates
deveshidwivedi Jan 24, 2024
1a42091
Update p5.RendererGL.Retained.js
deveshidwivedi Jan 24, 2024
03e3ca7
Merge branch 'processing:main' into model-view
deveshidwivedi Jan 25, 2024
84800e2
Revert "Update package.json"
deveshidwivedi Jan 25, 2024
6571b07
Update package.json
deveshidwivedi Jan 26, 2024
2d9d70e
updated files
deveshidwivedi Jan 26, 2024
164f22b
Merge branch 'model-view' of https://github.com/deveshidwivedi/p5.js …
deveshidwivedi Jan 26, 2024
87bcde2
updated this._renderer. to this.
deveshidwivedi Jan 26, 2024
2ceca4e
undo changes to package-lock.json
deveshidwivedi Jan 27, 2024
f5baf36
updated to separate model and view
deveshidwivedi Feb 1, 2024
f851186
updated files
deveshidwivedi Feb 2, 2024
3fd2f4c
Update p5.RendererGL.Retained.js
deveshidwivedi Feb 2, 2024
88a91b0
Merge branch 'processing:main' into model-view
deveshidwivedi Feb 2, 2024
f70241b
Merge branch 'main' of https://github.com/deveshidwivedi/p5.js into m…
deveshidwivedi Feb 3, 2024
ac8bd07
fix errors
deveshidwivedi Feb 7, 2024
e06ee71
Merge branch 'processing:main' into model-view
deveshidwivedi Feb 7, 2024
a7ae6be
Merge branch 'model-view' of https://github.com/deveshidwivedi/p5.js …
deveshidwivedi Feb 7, 2024
b9828a7
updated tests
deveshidwivedi Feb 15, 2024
c97433a
updated files for failing tests
deveshidwivedi Feb 16, 2024
aee44d2
Merge branch 'processing:main' into model-view
deveshidwivedi Mar 30, 2024
0de03bb
update to fix failing tests
deveshidwivedi Mar 30, 2024
a8ebc4a
Merge branch 'main' into model-view
davepagurek May 21, 2024
9f2cdd1
Fix test
davepagurek May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/webgl/GeometryBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,9 @@ class GeometryBuilder {
* transformations.
*/
addGeometry(input) {
this.renderer.uMVMatrix =
this.renderer.uModelMatrix.mult(this.renderer.uViewMatrix);
this.hasTransform = !this.renderer.uMVMatrix.mat4
deveshidwivedi marked this conversation as resolved.
Show resolved Hide resolved
.every((v, i) => v === this.identityMatrix.mat4[i]);

if (this.hasTransform) {
this.renderer.uNMatrix.inverseTranspose(this.renderer.uMVMatrix);
this.renderer.uNMatrix.inverseTranspose(this.renderer.uModelMatrix);
}

let startIdx = this.geometry.vertices.length;
Expand Down
6 changes: 3 additions & 3 deletions test/unit/webgl/p5.Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,13 @@ suite('p5.Camera', function() {

// Confirmation that the argument camera and the matrix of the camera
// that received set() match
assert.deepEqual(copyCam.cameraMatrix.mat4, myCam.cameraMatrix.mat4);
deveshidwivedi marked this conversation as resolved.
Show resolved Hide resolved
assert.deepEqual(copyCam.modelMatrix.mat4, myCam.modelMatrix.mat4);
assert.deepEqual(copyCam.projMatrix.mat4, myCam.projMatrix.mat4);
// If the set()ed camera is active,
// the renderer's matrix will also change.
assert.deepEqual(
copyCam.cameraMatrix.mat4,
myp5._renderer.uMVMatrix.mat4
copyCam.modelMatrix.mat4,
deveshidwivedi marked this conversation as resolved.
Show resolved Hide resolved
myp5._renderer.uModelMatrix.mat4
);
assert.deepEqual(
copyCam.projMatrix.mat4,
Expand Down
16 changes: 13 additions & 3 deletions test/unit/webgl/p5.RendererGL.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,13 +593,23 @@ suite('p5.RendererGL', function() {
suite('push() and pop() work in WEBGL Mode', function() {
test('push/pop and translation works as expected in WEBGL Mode', function(done) {
myp5.createCanvas(100, 100, myp5.WEBGL);
var modelView = myp5._renderer.uMVMatrix.copy();
var modelMatrixBefore = myp5._renderer.uModelMatrix.copy();
var viewMatrixBefore = myp5._renderer.uViewMatrix.copy();

myp5.push();
myp5.rotateX(Math.random(0, 100));
myp5.translate(20, 100, 5);
assert.notEqual(modelView.mat4, myp5._renderer.uMVMatrix.mat4);
// Check if the model matrix has changed
assert.notDeepEqual(modelMatrixBefore.mat4,
myp5._renderer.uModelMatrix.mat4);
// Check if the view matrix has changed
assert.deepEqual(viewMatrixBefore.mat4,
deveshidwivedi marked this conversation as resolved.
Show resolved Hide resolved
myp5._renderer.uViewMatrix.mat4);
myp5.pop();
assert.deepEqual(modelView.mat4, myp5._renderer.uMVMatrix.mat4);
// Check if both the model and view matrices are restored after popping
assert.deepEqual(modelMatrixBefore.mat4,
myp5._renderer.uModelMatrix.mat4);
assert.deepEqual(viewMatrixBefore.mat4, myp5._renderer.uViewMatrix.mat4);
done();
});

Expand Down
12 changes: 8 additions & 4 deletions test/unit/webgl/p5.Shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ suite('p5.Shader', function() {
var expectedAttributes = ['aPosition', 'aNormal', 'aTexCoord'];

var expectedUniforms = [
'uModelViewMatrix',
'uModelMatrix',
deveshidwivedi marked this conversation as resolved.
Show resolved Hide resolved
'uViewMatrix',
'uProjectionMatrix',
'uNormalMatrix',
'uAmbientLightCount',
Expand Down Expand Up @@ -108,7 +109,8 @@ suite('p5.Shader', function() {
var expectedAttributes = ['aPosition'];

var expectedUniforms = [
'uModelViewMatrix',
'uModelMatrix',
'uViewMatrix',
'uProjectionMatrix',
'uMaterialColor'
];
Expand All @@ -124,7 +126,8 @@ suite('p5.Shader', function() {
var expectedAttributes = ['aPosition', 'aVertexColor'];

var expectedUniforms = [
'uModelViewMatrix',
'uModelMatrix',
'uViewMatrix',
'uProjectionMatrix',
/*'uResolution',*/
'uPointSize'
Expand All @@ -141,7 +144,8 @@ suite('p5.Shader', function() {
var expectedAttributes = ['aPosition', 'aNormal'];

var expectedUniforms = [
'uModelViewMatrix',
'uModelMatrix',
'uViewMatrix',
'uProjectionMatrix',
'uNormalMatrix'
];
Expand Down
Loading