Playcanvas & fxhash

@yaustar you might have seen this coming :wink:

so i was trying the sandbox at fxhash to see if it would work with playcanvas. it actually looks quite good, but there is a problem with loading assets. i’ve tried the following project which cotains just one png but the problem also appears for glb’s and other assets.

https://playcanvas.com/project/917974/overview/hash

image

for me it seems as if it’s just not getting the paths right. i’ve probably overlooked something totally obvious.

Is the work in branch? If so, it can’t be publicly accessed

@yaustar sorry how you mean ‘in branch’?

On public projects users that haven’t been added with read access, can only see the master branch.

If you have additional branches in that project, they aren’t publicly visible.

@Leonidas

uhmm … i wasn’t aware … i can’t get it to work anyways %) … i can’t see the scene with another account too … it is nothing more than an empty project with a plane having a material with one texture on it. which doesn’t load …

I tried the project and it seems to work for me, have you fixed it? This is what I see, and no errors in the console.

If it still does not work for you, please see the Network tab in chrome to see if you can learns something there.

@mvaligursky

yep … now upload it to fxhash sandbox :wink:

Oh wait, are you saying that the project doesn’t work on Fxhash?

If that’s what you are saying, how do we access the build on fxhash?

@yaustar … you need to upload it as a zip here: fxhash — sandbox
there needs to be this codesnippet in the head of the index:

<script id="fxhash-snippet">
  //---- do not edit the following code (you can indent as you wish)
  let alphabet = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
  var fxhash = "oo" + Array(49).fill(0).map(_=>alphabet[(Math.random()*alphabet.length)|0]).join('')
  let b58dec = str=>[...str].reduce((p,c)=>p*alphabet.length+alphabet.indexOf(c)|0, 0)
  let fxhashTrunc = fxhash.slice(2)
  let regex = new RegExp(".{" + ((fxhashTrunc.length/4)|0) + "}", 'g')
  let hashes = fxhashTrunc.match(regex).map(h => b58dec(h))
  let sfc32 = (a, b, c, d) => {
    return () => {
      a |= 0; b |= 0; c |= 0; d |= 0
      var t = (a + b | 0) + d | 0
      d = d + 1 | 0
      a = b ^ b >>> 9
      b = c + (c << 3) | 0
      c = c << 21 | c >>> 11
      c = c + t | 0
      return (t >>> 0) / 4294967296
    }
  }
  var fxrand = sfc32(...hashes)
  // true if preview mode active, false otherwise
  // you can append preview=1 to the URL to simulate preview active
  var isFxpreview = new URLSearchParams(window.location.search).get('preview') === "1"
  // call this method to trigger the preview
  function fxpreview() {
    console.log("fxhash: TRIGGER PREVIEW")
  }
  //---- /do not edit the following code
</script>

the app appearently works but it wouldn’t load any assets… it’s most likely just a path issue

PlayCanvas apps are meant to ran on webservers as the asset requests make a network request.

It doesn’t look like fx(hash) does that. It’s almost as though it’s running it from a local storage or similar?

As long as size of the app is relatively small, you could try converting it to a playable ad which inlines assets as base64 data. There are some limitations with this which are listed in the tool’s readme here: https://github.com/playcanvas/playcanvas-rest-api-tools#converting-a-project-into-a-single-html-file

Flappy Bird test with the playable ad format:

1 Like

@yaustar idk if it’s different after minting. i minted a vr app on teia marketplace recently and it worked fine from ipfs. but thanks so far i’m going to further investigate and try out the base64 approach.