-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from TiborUdvari/fix/p5-v1.10.0
Fix to work with p5 v1.10.0
- Loading branch information
Showing
9 changed files
with
485 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import './p5xr/core/p5overrides'; | ||
import p5vr from './p5xr/p5vr/p5vr'; | ||
import p5ar from './p5xr/p5ar/p5ar'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { lineVert, lineFrag } from '../shaders/lineShader'; | ||
import compareVersions from '../utilities/versionComparator'; | ||
|
||
/** | ||
* Override default p5 line shader to avoid issue in v1.10.0 | ||
* https://github.com/processing/p5.js/issues/7200 | ||
* @private | ||
* @ignore | ||
*/ | ||
const overrideLineVertShader = compareVersions(p5.VERSION, '1.10.0') >= 0; | ||
if (overrideLineVertShader) { | ||
console.log('p5.xr: overriding p5 v1.10.x line vert shader for v1.9.4'); | ||
p5.RendererGL.prototype._getLineShader = function () { | ||
if (!this._customLineShader) { | ||
this._customLineShader = new p5.Shader( | ||
this, | ||
this._webGL2CompatibilityPrefix('vert', 'mediump') + lineVert, | ||
this._webGL2CompatibilityPrefix('frag', 'mediump') + lineFrag, | ||
); | ||
} | ||
|
||
return this._customLineShader; | ||
}; | ||
} | ||
|
||
const overrideMatrixCopy = compareVersions(p5.VERSION, '1.9.2') >= 0; | ||
if (overrideMatrixCopy) { | ||
console.log( | ||
'p5.xr: Overriding camera copy so linePerspective works with push pop', | ||
); | ||
const originalCopy = p5.Camera.prototype.copy; | ||
|
||
p5.Camera.prototype.copy = function () { | ||
const copiedCamera = originalCopy.call(this); | ||
copiedCamera.useLinePerspective = this.useLinePerspective; | ||
return copiedCamera; | ||
}; | ||
|
||
const originalSet = p5.Camera.prototype.set; | ||
p5.Camera.prototype.set = function (cam) { | ||
originalSet.call(this, cam); | ||
this.useLinePerspective = cam.useLinePerspective; | ||
return this; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.