[SOLVED] PlayCanvas 1.30.0 seems messed on NPM

I only recently upgraded my playcanvas npm package to 1.30.0 and everything started crashing. Previously I have been using the import from playcanvas as import pc from 'playcanvas' but now it seems to complain that pc is undefined so I sorted this by import * as pc from 'playcanvas' but now I am getting errors from all kind of places. The script fly-camera.js that previously worked fine now reports errors… this.leftStick.identifier reports Cannot read property 'identifier' of undefined yet this is clearly initialised in the TouchInput.prototype.initialize function. It looks like probably it’s not called. I know there have been breaking changes in v 1.29.0 but I can’t figure out how to make this work. ecspecially now that my npm has cached this script and it doesn’t seem to change even when I revert back to my old version of playcanvas.

1 Like

I’ll take a look for you. :smile:

1 Like

So yes, there does seem to be a problem with 1.30.0 on Node. I made this super-simple program:

var pc = require('playcanvas');

console.log(pc.version);

I get:

C:\dev\nodetest>node main.js
internal/encoding.js:396
        throw new ERR_ENCODING_NOT_SUPPORTED(encoding);
        ^

RangeError [ERR_ENCODING_NOT_SUPPORTED]: The "windows-1252" encoding is not supported
e[90m    at new TextDecoder (internal/encoding.js:396:15)e[39m
    at UntarScope (C:\dev\nodetest\node_modules\e[4mplaycanvase[24m\build\playcanvas.js:21009:19)
    at C:\dev\nodetest\node_modules\e[4mplaycanvase[24m\build\playcanvas.js:21219:2
    at C:\dev\nodetest\node_modules\e[4mplaycanvase[24m\build\playcanvas.js:7:65
    at Object.<anonymous> (C:\dev\nodetest\node_modules\e[4mplaycanvase[24m\build\playcanvas.js:10:2)
e[90m    at Module._compile (internal/modules/cjs/loader.js:1158:30)e[39m
e[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)e[39m
e[90m    at Module.load (internal/modules/cjs/loader.js:1002:32)e[39m
e[90m    at Function.Module._load (internal/modules/cjs/loader.js:901:14)e[39m
e[90m    at Module.require (internal/modules/cjs/loader.js:1044:19)e[39m {
  code: e[32m'ERR_ENCODING_NOT_SUPPORTED'e[39m

If, in the playcanvas.js, I change this (at line 21007):

		if (typeof TextDecoder !== 'undefined') {
			utfDecoder = new TextDecoder('utf-8');
			asciiDecoder = new TextDecoder('windows-1252');
		} else {
			console.warn('TextDecoder not supported - pc.Untar module will not work');
		}

To:

		try {
			utfDecoder = new TextDecoder('utf-8');
			asciiDecoder = new TextDecoder('windows-1252');
		}
		catch (err) {
			console.warn('TextDecoder not supported - pc.Untar module will not work');
		}

…then it works fine. I’ll submit a proper fix to the codebase tomorrow.

As for the camera-fly.js script, ensure there are no occurrences of pc.input. This was officially removed from the engine in 1.29.0 after being deprecated about 6 years ago. (Plenty of time to upgrade code). :wink:

Hi, I have a similar issue.

When I update the package from v1.27.0 to v1.30.0.

Versions

  • Node.js : 14.2.0
  • Next.js : 9.4.4
  • playcanvas :v1.30.0

Error

Uncaught ReferenceError: pc is not defined
    at Object.createShaderDefinition (playcanvas.js?35ee:5212)
    at ProgramLibrary.getProgram (playcanvas.js?35ee:48679)
    at StandardMaterial.updateShader (playcanvas.js?35ee:48505)
    at ForwardRenderer.updateShader (playcanvas.js?35ee:12189)
    at ForwardRenderer.renderForward (playcanvas.js?35ee:12290)
    at ForwardRenderer.renderComposition (playcanvas.js?35ee:13139)
    at Application.render (playcanvas.js?35ee:46727)
    at eval (playcanvas.js?35ee:47308)

error line

playcanvas.js:5212

attributes["vertex_texCoord" + i] = pc["SEMANTIC_TEXCOORD" + i];

and

Error

playcanvas.js?35ee:7015 Uncaught ReferenceError: pc is not defined
    at Texture.get (playcanvas.js?35ee:7015)
    at GraphicsDevice.setTextureParameters (playcanvas.js?35ee:50269)
    at GraphicsDevice.setTexture (playcanvas.js?35ee:50324)
    at GraphicsDevice.draw (playcanvas.js?35ee:50415)
    at ForwardRenderer.drawInstance (playcanvas.js?35ee:11971)
    at ForwardRenderer.renderForward (playcanvas.js?35ee:12427)
    at ForwardRenderer.renderComposition (playcanvas.js?35ee:13139)
    at Application.render (playcanvas.js?35ee:46727)
    at eval (playcanvas.js?35ee:47308)

error line

playcanvas.js:7015

return pc.math.powerOfTwo(this._width) && pc.math.powerOfTwo(this._height);

Apologies for this. I’ve submitted this PR to fix the problem in 1.30.0:

We’ll deploy this early next week. Please continue to use your last known good engine version until then.

1 Like

OK, if you update to version 1.31.0, this should be fixed. See release notes:

Thank you!
My project worked fine!

1 Like