MyWebAR Knowledge Base
Language Eng
Language Eng
  • Knowledge base for MyWebAR developers
  • GETTING STARTED
    • Signing Up
    • Dashboard Overview
    • Editor Overview
  • PLANS AND SUBSCRIPTIONS
    • Free 14-Day Trial
    • Upgrading Your Plan
    • Commercial Plans
    • Plans for Education
  • CREATING WEBAR PROJECTS
    • Project Types
    • Multi-Image Projects (Books)
    • Adding Objects
    • How to add a 3D model from the library of 3D models
    • How to add 3D models from Sketchfab
    • Object Properties
    • Buttons and Actions
    • Video Playback
    • 3D Animations
    • Project Analytics
    • How to make a good trackable image for augmented reality
    • Optimizing And Preparing 3D Models For Loading
    • How to work with plugins
    • How to make AR portal in MyWebAR
    • Video Tutorials
  • WEBAR CUSTOMIZATION
    • Custom WebAR Domain
    • Using External File Server
    • WebAR Embedding
  • PRO EDITOR
    • How the Pro Editor works
      • Interface Description
      • Basic features
    • Current restrictions
      • An Example Of Integration Of A Ready-Made Script
      • Particle Creation In The Pro Editor
      • Working With Video
      • Working With 3D Object Animations
    • Code placement requirements
      • Working With The Camera
      • UI Creation
      • Loading objects using the basic class - loader
    • The Cases
      • Adding Images
      • Lens Flare Effect
Powered by GitBook
On this page
  1. PRO EDITOR
  2. Code placement requirements

Loading objects using the basic class - loader

PreviousUI CreationNextThe Cases

Last updated 3 years ago

Always, when loading any objects, be it materials, 3D models and the like, a special type of THREE.js library objects called loader has to be used.

You can read more about loaders here.

The loader is used to add, for example, material to the scene from the outside.

An example of using a loader is adding a texture to a plane (line 6):

let loader = new THREE.ImageLoader;

let planeGeometry = new THREE.PlaneGeometry(20, 5, 10, 10);
let planeMaterial = new THREE.MeshBasicMaterial({
	//Использование загрузчика
	map: loader.load("https://mywebar-a.akamaihd.net/1330/20322/Mywebar.png?hash=028902a08ce058c1a17f57b40d423ca9"),
	side:THREE.DoubleSide
});
plane = new THREE.Mesh(planeGeometry, planeMaterial);

So what are the limitations of using the loader?

Files cannot be imported from all servers. The server from which you import your file must allow resource sharing and have Access-Control-Allow-Origin. What it is, is written here.

If the server does not allow resource sharing, you will see the following error in the console:

As it can be seen above, the link to the image from Google.Drive does not pass validation, due to which the scene cannot be launched and errors appear.