tentone / potree-core

Potree point cloud viewer library core components for easier integration in a three.js project.
https://tentone.github.io/potree-core/
Other
171 stars 53 forks source link

Not working in Firefox: "document.currentScript is null" #10

Closed leefsmp closed 4 years ago

leefsmp commented 4 years ago

Working perfectly in Chrome and Safari, getting following error in Firefox:

Screen Shot 2019-10-13 at 14 02 51

OS: MacOS High Sierra 10.13.3

tentone commented 4 years ago

Hello

It should be supported by FF https://developer.mozilla.org/en-US/docs/Web/API/Document/currentScript

I will take a look at it, thanks a lot for reporting this bug.

tentone commented 4 years ago

Seems to be working without any errors on firefox. Can you please provide some additional details?

adad

leefsmp commented 4 years ago

I'm using webpack if that makes any difference... the demo at https://tentone.github.io/potree-core is also working in FF on my side.

tentone commented 4 years ago

Yeah that is possible the problem anyway you can override the location of the workers on the Potree.Global.workerPath attribute.

Just set it to the path where you have the decode workers.

leefsmp commented 4 years ago

Doing that already:

import {
  loadPointCloud,
  PointColorType,
  PointSizeType,
  PointShape,
  Global,
  Group
} from 'potree-core/build/potree.module'

const PotreeCore = {
  loadPointCloud,
  PointColorType,
  PointSizeType,
  PointShape,
  Global,
  Group
}

// ...

initialize () {
  // ... 
  PotreeCore.Global.workerPath = '/resources/potree' //contains folder /workers
}
tentone commented 4 years ago

I have added an additional check to make sure that the currentScript exists before using it. Should be enough to prevent the error.

You will still need to set the workerPath pointing to the correct location (relative to your doc path or web server root)

leefsmp commented 4 years ago

Working now, thanks a lot for your prompt replies and the great lib!

tentone commented 4 years ago

No problem happy to be of use. Thanks a lot for reporting the problem.