GLB - asset.resource in asset.resource.initiateRenderEntity() is undefined

Hi all,

May I know what should be in the asset.resource? I’m using this GLB loader sample code form playcanvas:

HTML:

<html>

<script src="https://code.playcanvas.com/playcanvas-latest.js"></script>

<body>

  <canvas id="application-canvas"></canvas>

  <a id="logo" href="https://playcanvas.com/" target="_blank"><img src="http://static.playcanvas.com/images/logo/PLAY_FLAT_ORANGE3_SMALL.png" /></a>

</body>


<script>

Script from
https://playcanvas.github.io/#/loaders/glb

</script>

and trying to use this outsourced GLB file as the URL:

https://ipfs.io/ipfs/QmVWgxQnPT21K6nXSSmosmYRcgfhwBNAMHfsouo5dCNEZ6?filename=BabyElephant_GLB.glb

I keep getting these 2 errors:

  • playcanvas-latest.js:35247 SyntaxError: Unexpected token g in JSON at position 0
  • glb_loader.html:79 Uncaught TypeError: Cannot read properties of undefined (reading ‘instantiateRenderEntity’)

I am new to playcanvas and glb files. I am not sure what should be included in the asset.resource to make initiateRenderEntity() work. This code seems to be stopping my code:

2022-03-22_15h37_17

Any help will be appreciated.

Thanks!

Hi @spike_bump

I would have to look at your project to see the issue as the code looks fine, the elephant glb loads perfectly fine in my project,
https://playcanvas.com/project/784756/overview/dynamic-model-loading

2 Likes

Hi Saad_Haider,

Here is the project file:

GLB test 2 | Editor (playcanvas.com)

I am trying to use it using the code here:

PlayCanvas Examples

When I try to console.log(asset.resource) after loading it from the URL, it returns as undefined and cannot be processed by instantiateRenderEntity();

@spike_bump
Most of the time, the server is taking too long to respond to the request due to which the request times out, but I have your fixed issue in this project, PlayCanvas 3D HTML5 Game Engine

1 Like