Skip to content

initPmapperShader doesn't work properly #8

@tym2k1

Description

@tym2k1

When importing the library there's a warning of

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://cdn.statically.io/gh/jdeboi/p5.mapper@main/src/surfaces/Bezier/shader.frag. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 301.

Trying to use functions like createProjectionMapper thus doesn't work.

A fix that worked was using the library locally and applying a patch (if applying change the dirname to fit ur dir structure)

diff --git a/dist/p5.mapper.min.js b/dist/p5.mapper.min.js
index 38eb0e5f3ac2..5a2a8cf19d27 100644
--- a/dist/p5.mapper.min.js
+++ b/dist/p5.mapper.min.js
@@ -3505,9 +3505,9 @@ p5.prototype.isDragging = function (surface) {

 p5.prototype.initPMapperShader = function () {
   // TODO - is there a better way to do this?
-  // const filePath = "../../src/surfaces/Bezier/shader";
+  const filePath = "<dir_name_under_I_imported_the_lib>/src/surfaces/Bezier/shader";
   // const filePath = "https://cdn.jsdelivr.net/gh/jdeboi/p5.mapper/src/surfaces/Bezier/shader"
-  var filePath = "https://cdn.statically.io/gh/jdeboi/p5.mapper/main/src/surfaces/Bezier/shader";
+  // var filePath = "https://cdn.statically.io/gh/jdeboi/p5.mapper/main/src/surfaces/Bezier/shader";
   this.loadShader(filePath + ".vert", filePath + ".frag", function (bezShader) {
     return pMapper.preload(bezShader);
   });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions