ArticleslgStudy

computer science

Three.js

Three.js is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Three.js rather than just read about it. In short: Three.js is a cross-browser JavaScript library and application programming interface (API) used to create and display animated 3D computer graphics in a web browser using WebGL. The source code is hosted in a repository on GitHub.

Three.js — main illustration
Three.js — illustration

Key takeaways

  • Three.js belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Three.js to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Three.js from memory before moving on to harder problems.

Reference excerpt

Three.js is a cross-browser JavaScript library and application programming interface (API) used to create and display animated 3D computer graphics in a web browser using WebGL. The source code is hosted in a repository on GitHub.

Overview Three.js allows the creation of graphical processing unit (GPU)-accelerated 3D animations using the JavaScript language as part of a website without relying on proprietary browser plugins. This is possible due to the advent of WebGL, a low-level graphics API created specifically for the web. High-level libraries such as Three.js, Babylon.js, Verge3D and many more make it possible to author complex 3D computer animations for display in the browser without the effort required for a traditional standalone application or a plugin.

History Three.js was first released by Ricardo Cabello on GitHub in April 2010. The origins of the library can be traced back to his involvement with the demoscene in the early 2000s. The code was originally developed in the ActionScript language used by Adobe Flash, later being ported to JavaScript in 2009. In Cabello's mind, there were two strong points that justified the shift away from ActionScript: Firstly, JavaScript provided greater platform independence. Secondly, applications written in JavaScript would not need to be compiled by the developer beforehand, unlike Flash applications. Additional contributions by Cabello include API design, CanvasRenderer, SVGRenderer, and being responsible for merging the commits by the various contributors into the project. With the advent of WebGL, Paul Brunt was able to implement the new rendering technology quite easily as Three.js was designed with the rendering code as a module rather than in the core itself. Branislav Uličný, an early contributor, started with Three.js in 2010 after having posted a number of WebGL demos on his own site. He wanted WebGL renderer capabilities in Three.js to exceed those of CanvasRenderer or SVGRenderer. His major contributions generally involve materials, shaders, and post-processing. Soon after the introduction of WebGL 1.0 on Firefox 4 in March 2011, Joshua Koo came on board. He built his first Three.js demo for 3D text in September 2011. His contributions frequently relate to geometry generation. Starting from version 118, Three.js uses WebGL 2.0 by default. Three.js has over 2000 contributors on GitHub.

Features Three.js includes the following features:

Effects: Anaglyph, cross-eyed, and parallax barrier. Scenes: add and remove objects at run-time; fog Cameras: perspective and orthographic; controllers: trackball, FPS, path and more Animation: armatures, forward kinematics, inverse kinematics, morph, and keyframe Lights: ambient, direction, point, and spot lights; shadows: cast and receive Materials: Lambert, Phong, smooth shading, textures, and more Shaders: access to full OpenGL Shading Language (GLSL) capabilities: lens flare, depth pass, and extensive post-processing library Objects: meshes, particles, sprites, lines, ribbons, bones, and more - all with Level of detail Geometry: plane, cube, sphere, torus, 3D text, and more; modifiers: lathe, extrude, and tube Import/export: native serialization/deserialization via JSON, glTF, OBJ, USDZ, and more. Utilities: full set of time and 3D math functions including Viewing frustum, matrix, quaternion, UVs, and more Support: API documentation is under construction. A public forum and wiki is in full operation. Examples: Over 150 files of coding examples plus fonts, models, textures, sounds, and other support files Debugging: Stats.js, WebGL Inspector, Three.js Inspector Virtual and Augmented Reality via WebXR Physically based rendering (PBR): support for physically accurate materials like MeshStandardMaterial and MeshPhysicalMaterial Instancing: use of InstancedMesh for efficient rendering of thousands of repeated objects Post-processing: built-in post-processing pipeline with effects such as bloom, depth of field, outline, motion blur, SSAO, and FXAA Built-in editor: graphical scene editor available online for building and exporting 3D scenes Interactive controls: built-in controls such as OrbitControls, DragControls, TransformControls, and PointerLockControls for user interaction and navigation Alternative renderers: in addition to WebGLRenderer, Three.js also provides SVGRenderer and CSS3DRenderer, as well as experimental support for WebGPURenderer. Three.js runs in all browsers with support for WebGL 2.0. Three.js is made available under the MIT License.

See also

Google Chrome Experiments List of WebGL frameworks JavaScript framework JavaScript library

References

Further reading Dirksen, Jos (2013). Learning Three.js: The JavaScript 3D Library for WebGL. UK: Packt Publishing. ISBN 9781782166283. Archived from the original on 2014-07-08. Retrieved 2013-10-22. Parisi, Tony (2012). Webgl Up and Running. Sebastopol: Oreilly & Associates Inc. ISBN 9781449323578. Seidelin, Jacob (2012). HTML5 games : creating fun with HTML5, CSS3, and WebGL. Chichester, West Sussex, U.K: John Wiley & Sons. pp. 412–414. ISBN 978-1119975083. - "Three.js can make game development easier by taking care of low-level details" Williams, James (2012). Learning HTML5 game programming : a hands-on guide to building online games using Canvas, SVG, and WebGL. Upper Saddle River, NJ: Addison-Wesley. pp. 117–120, 123–131, 136, 140–142. ISBN 978-0321767363. Raasch, Jon (2011). Smashing WebKit. Chichester: Wiley. pp. 181, 182, 216. ISBN 978-1119999133.

External links

Official website

Illustrations

Three.js illustration

Worked examples

Example 1 — a first encounter with Three.js

Start with the simplest possible case. Write down what Three.js claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Three.js before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Three.js ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Three.js

In research
Three.js appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Three.js in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Three.js is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2010 software, 3D scenegraph APIs, Cross-platform software, so understanding it makes those chapters shorter.
In everyday life
Look for Three.js outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Three.js” →

How to study Three.js in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Three.js means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Three.js out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Three.js in simple terms?

Three.js is a cross-browser JavaScript library and application programming interface (API) used to create and display animated 3D computer graphics in a web browser using WebGL. The source code is hosted in a repository on GitHub.

Why does Three.js matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Three.js?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Three.js.

Tags

  • 2010 software
  • 3D scenegraph APIs
  • Cross-platform software
  • Free 3D graphics software
  • Graphics libraries
  • JavaScript libraries
  • Software using the MIT license
  • WebGL

Keep exploring