dir.by  
Поиск >>

Компьютер, программы
→
Three.js - JavaScript library for drawing graphics 3D in the pages HTML
 Create a file js with an object containing export variables and functions. This is an example of using a self-calling unnamed function | standard ES5 
  JavaScript     Create a new file my.js
(function (global, factory) {

     (factory(global.MY_OBJECT = {}));

}(this, (function (exports) {

     var a = 8;
     function ShowValue(val)
     {
          alert(val);
     }

     // exports
     exports.b = 10;
     exports.ShowValue = ShowValue;

})));
Create a file for verification html
  Html     Create a new file test.html
<!DOCTYPE html>
<html>

     <head>
          <title>Example</title>
          <meta charset="utf-8">
     </head>

     <body>

          <!-- loading the library my.js -->
          <script src="my.js"></script>

          <script>
               MY_OBJECT.ShowValue(23);
               // on the screen we will see 23
          </script>

     </body>
</html>
This principle is used by the library Three.js
  JavaScript     File Three.js
(function (global, factory) {
     typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
     typeof define === 'function' && define.amd ? define(['exports'], factory) :
     (factory((global.THREE = {})));
}(this, (function (exports) { 'use strict';

     ...

     exports.CanvasRenderer = CanvasRenderer;
     exports.SceneUtils = SceneUtils;
     exports.LensFlare = LensFlare;
    
})));
 
← Previous topic
Example "Reflection balls (effects anaglyph)" library Three.js
 
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

 
• What the Three.js and how to download?
• Example "Flying cubes" library Three.js
• Example "Roller coaster (roller coaster)" library Three.js
• Example "Rotating cube with texture (rotate cube)" library Three.js
• Example "We spin the picture ourselves svg (svg image)" library Three.js
• Example "The moon revolves around the earth (moon rotate around earth)" library Three.js
• Example "Drawing a picture with 3D cubes (interactive voxel painter)" library Three.js
• Example "Reflection balls (effects anaglyph)" library Three.js
• Create your own file .js The file contains an object with export variables and functions

  Ваши вопросы присылайте по почте: info@dir.by