Skip to content

Inconsistent return value type from FileLoader.load() #10712

@takahirox

Description

@takahirox
Description of the problem

FileLoader.load() returns three types of return value.

  1. XMLHttpRequest instance when cache doesn't hit and url is not data: URI
  2. cached data when cache hits
  3. undefined when url is data: URI

As for me it'd be kinda confusing to users because the return value type
depends on the cache state and url type.
Another confusing thing is it returns cached(loaded) data synchronously
before it calls manager.itemEnd() when cache hits.

I like consistent design,
I want loaded/cached data only to be asynchronously passed to user via onLoad callback.

So how about returning null when 2. and 3.?
Or any other ideas?

Three.js version
  • Dev
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • Linux
  • Android
  • IOS
Hardware Requirements (graphics card, VR Device, ...)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions