Skip to content

Official Stable Release of Version 0.8.0

Compare
Choose a tag to compare
@jonobr1 jonobr1 released this 10 Jan 20:14
· 350 commits to dev since this release

Version 0.8.0 introduces a port of the previously EcmaScript 5 syntax and brings it to modern day JavaScript coding practices with EcmaScript 6 features supported in all major browsers.

📋 This is a more-or-less entire rewrite of Two.js to use EcmaScript 6 features. In particular:

  • const / let instead of var for tighter scoping
  • class construction instead of prototypical modifications
  • Expanded classification of classes. For instance:
    • Two.Events is now a class
    • Two.Element is a new base class of Two.Shape, Two.Gradient, and anything else that can be queried in the scenegraph
  • Where possible functions are named instead of anonymous
  • Removes all MakeObservable methods in favor of Object.defineProperty invocations on constructor
  • Module imports are through typical exports and except for the root Two.js class, not with default. So you'll need to import specific modules like so:
import { Vector } from 'two.js/src/vector.js';
var v = new Vector();

🏁 These changes allow for improved:

  • TypeScript Declarations (fully expanded and invoked through TypeScript's types compiler)
  • Improved documentation
  • Code legibility and OOP style
  • More legible performance debugging
    • Easier to identify culprit functions in Chrome et al. performance debug consoles
  • And improved SVG interpretation

⚠️ These changes break:

  • Loose interoperability between Two.Vector and Two.Anchor. For any curve, it's required you use anchors instead of vectors now.

🗒️ All tests and first party examples are passing with documentation updated on two.js.org/docs