Skip to content

saveObj() bug? #7905

Open
Open
@ErnestSuyver

Description

@ErnestSuyver

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • p5.strands
  • WebGL
  • DevOps, Build process, Unit testing
  • Internationalization (i18n)
  • Friendly Errors
  • Other (specify if possible)

p5.js version

2.0.3

Web browser and version

Firefox 139.0.4 (aarch64)

Operating system

macOS 15.5

Steps to reproduce this

intro

When trying to export an ".obj" file from a p5 sketch, the console throws an error. Claims it doesn't recognize a "fn" function.

Could this be related to line 415-416 in https://github.com/processing/p5.js/blob/v2.0.3/src/webgl/p5.Geometry.js?

const blob = new Blob([objStr], { type: 'text/plain' });
    fn.downloadFile(blob, fileName , 'obj');

Steps:

  1. WEBGL renderer
  2. buildGeometry() in setup()
  3. saveObj() in keyPressed()
  4. When pressing the key ("s" in this case), the console given an error
  5. Swapping the CNV version for a local minified one makes no difference. Also, buildGeometry does not seem to work for older p5 versions.

Snippet:

let myModel;

function setup() {
  createCanvas(400, 400, WEBGL);
  
  myModel = buildGeometry(() => {  

    blah blah

  });
 
}

function draw() {
  
  model(myModel);
}

function keyPressed() {
  if (key === 's') {
    myModel.saveObj(); 
  }
}

console error

Uncaught ReferenceError: fn is not defined
saveObj http://127.0.0.1:5500/p5.min.js:1
keyPressed http://127.0.0.1:5500/sketch.js:60
_onkeydown http://127.0.0.1:5500/p5.min.js:1
e http://127.0.0.1:5500/p5.min.js:1
p5 http://127.0.0.1:5500/p5.min.js:1
promise callback*p5< http://127.0.0.1:5500/p5.min.js:1
http://127.0.0.1:5500/p5.min.js:1
p5.min.js:1:179337
saveObj http://127.0.0.1:5500/p5.min.js:1
keyPressed http://127.0.0.1:5500/sketch.js:60
_onkeydown http://127.0.0.1:5500/p5.min.js:1
(Async: EventListener.handleEvent)
e http://127.0.0.1:5500/p5.min.js:1
p5 http://127.0.0.1:5500/p5.min.js:1
(Async: promise callback)
p5 http://127.0.0.1:5500/p5.min.js:1
http://127.0.0.1:5500/p5.min.js:1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Ready for Work

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions