Chevron Down
Table of Contents
Chevron DownGetting Started
Chevron DownAPI Reference

loadFile, loadImage

Minimal utilities to load files and images in the browser, typically used to initialize textures.


Creating a request to load images.

import {loadImage} from '';
async () {
  const image = await loadImage('image1.png');
  alert("images loaded! Now do something with the image");

Creating a request to load images and create WebGL textures

import {loadImage} from '';
const image = await loadImage('image1.png');
const new Texture2D(gl, {data: image});

You can also load text files

import {loadFile} from '';
const text = await loadFile(url);

For more advanced loading you may want to consider using these can parse complex formats and parsing works on Node.js, browser threads etc.

import {loadFile} from '';
import {OBJLoader} from '';

loadFile(url, OBJLoader).then(data => {
  // Application code here

loadImage(url : String [, options: Object]) : Promise

Enables loading of multiple remote images asynchronously and returns an array with all the images loaded.

const image = await loadImages(url, options);
  • url - (String) strings pointing to image url.

loadFile(url : String [, options: Object]) : Promise

Loads remote data asynchronously via an http request (fetch). The domain serving the data must match the domain where the data is queried.