简体   繁体   English

React / Webpack中的p5 image()友好错误消息

[英]p5 image() friendly error message in React / Webpack

I am refactoring a p5 sketch as part of a React/Redux build and am getting the following friendly error message from p5 concerning arguments passed to the p.image() function (note: I am using p5 in instance mode ). 我正在重构一个p5草图,作为React / Redux构建的一部分,并从p5得到以下友好的错误消息,该错误消息涉及传递给p.image()函数的参数(注意:我在实例模式下使用p5)。

p5.js says: image() was expecting p5.Image|p5.Element for parameter #0 (zero-based index), received p5.Element instead at webpack-internal:///239:103:9. [http://p5js.org/reference/#p5/image]

The video argument the message seems to refer to, is a p5.MediaElement returned from p.createCapture( p.VIDEO ) - ie webcam stream. 视频参数的消息似乎是指,是p5.MediaElement从返回p.createCapture( p.VIDEO ) -即网络摄像头流。 I have had no issues when using the same function calls in a static context. 在静态上下文中使用相同的函数调用时,我没有任何问题。

The p.image call sits within the following code block: p.image调用位于以下代码块内:

const noiseX = p.noise(xoff)*(canvWidth+vWidth);
const noiseY = p.noise(yoff)*(canvHeight+vHeight);
xoff+=visualSettings.perlinScale.active;
yoff+=visualSettings.perlinScale.active;
p.image(video, noiseX-vWidth, noiseY-vHeight, vWidth, vHeight);

The sketch still runs as expected, but I would like to resolve the issues appropriately (besides, the error sits within the draw cycle which is really irritating). 草图仍然可以按预期运行,但是我想适当地解决问题(此外,错误位于绘制周期内,这确实很烦人)。

It is unclear as to what is required to resolve the issue since the friendly error message says it was 'expecting a p5.Image or p5.Element' and has 'received p5.Element instead' . 目前尚不清楚解决该问题所需的内容,因为友好的错误消息指出它“正在使用p5.Image或p5.Element”,并且已“接收了p5.Element” Any clarification anyone can provide would be much appreciated. 任何人都可以提供任何澄清将不胜感激。

The issue here relates to a bug in p5 0.6.0. 这里的问题与p5 0.6.0中的错误有关。 Will be fixed in an upcoming release of p5. 将在即将发布的p5中修复

In the meantime, the error msg can be hidden by setting p5.disableFriendlyErrors = true; 同时,可以通过设置p5.disableFriendlyErrors = true;来隐藏错误消息p5.disableFriendlyErrors = true; or using the minified version of p5 (which has friendly error msgs hidden by default). 或使用缩小版本的p5(默认情况下会隐藏友好错误消息)。

Special thanks to GoToLoop for the help via the Processing forum discussion . 特别感谢GoToLoop通过Processing论坛的讨论所提供的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM