"Grow mighty worlds from little acorns."
The Acorn language is designed to make it easier and faster to build immersive, sharable 3-D worlds using just one approachable, powerful, extensible language. Acorn binds together all aspects of a Web3D scene: the look and location of its parts, how they behave and how people interact with them.
If you are new to 3-D or programming, you will appreciate how approachable Acorn is. It uses common-sense words, minimizes distracting punctuation, and employs straightforward, consistent rules. It allows you to get started with a few powerful techniques, and then grow your knowledge bit by bit as your skill and confidence grows. If you are eager to start learning, skip the rest of this introduction and dive in to the first chapter or find a helpful introductory tutorial.
The rest of this introduction highlights several of Acorn's more useful features in more detail.
All The World's a Stage
Imagine that a scene in your world is like a stage setting for a play. Perhaps a wall divides the stage, separating a meadow from the overgrown garden. A locked, metal door traps anyone within the garden who does not have its key. The moon casts a tiny glow on two lovers sneaking towards the wall from opposite sides.
For Acorn, these are all Parts: both lovers, the moon, the wall, the door and the key. They are parts of the scene, which is itself a part in a world with many scenes. Acorn invests much of its 3-D magic in the humble, but flexible Part.
Every part has its own content and behavior.
- A part's content consists of an ordered list of its sub-parts (for example, the objects in a scene) as well as a dictionary of its named properties (such as its position, size, shape or coloring). Which properties are specified can vary from one part to another, even for two parts of the same type. A property's value can be as simple as a number or a symbol, or something more complex, such as a list or part.
- A part's behavior is typically established by its type.
A type is a library of named, procedural methods that specify how parts of that type are rendered and how they behave.
Thus, our scene's moon might be a Light, able to illuminate other scene parts.
The wall is an unmoving Thing, whose shape takes up space and provides an obstacle.
The key is an Item which can be carried and used.
The lovers are Avatars, whose actions are controlled by people.
Web3D provides a basic collection of 3-D part types, called the World Object Model (WOM). Each of its part types (e.g., Light, Thing, Scene and World) acts like a factory, manufacturing ready-to-use parts for the 3-D world. A lot of the complicated stuff needed to manage 3-D worlds is buried within these types, offering a lot of power at a low cost to the world builder.
Furthermore, Acorn enables each world to define and use its own custom-built part types, building off of the capabilities provided by the WOM. Acorn also allows any part to define its own custom behavior, distinct from other parts of the same type. Two robots in a scene might look identical and yet have wildly different behavior, if desired. Unlike other Items, the garden key might be designed to vanish after being used five times.
The content and behavior of each and every part within a world can be hierarchically specified in a very straightforward, readable manner using Acorn's builder grammar. Static content generally only requires literal numbers, symbols and (perhaps) some procedural methods. Procedurally-generated content can make use of variables, expressions and even embedded control structures.
New parts can be added at any time. Any aspect of any existing part can be altered at any time. Acorn's extensible part selector makes it easy to select and manipulate the specific parts in the world that match the specified criteria.
Plays Well With Others
Acorn not only helps custom craft modular bricks, it also offers powerful Internet-based mechanisms for snapping those bricks together. Making Acorn Internet-savvy is essential for accomplishing Web3D's open-world vision:
- Acorn encourages every part in a world to be a URL-named resource on the Internet, rather than trying to cram an entire world into a single Acorn program. Each part uses the appropriate part URLs to references each of its sub-parts and other related parts. When a user enters a world, the Web3D browser begins with the Acorn program resource for the world. By following all link references, the browser ultimately finds and loads all of the world's various parts, thereby snapping them together.
- Acorn also offers 2-way binding, another valuable form of part connectivity. Each part automatically synchronizes its property values with other parts that need the most current values. This is commonly used to connect a 3D part to a 2D panel used to view or change some of the part's values. For example, an panel might show the items an avatar is carrying, allowing someone to equip or drop one of these items. 2-way binding ensures that as things change both the panel and the avatar continue to have the same accurate info about what the avatar is carrying.
Acorn's built-in Internet connectivity and 2-way binding capabilities grant the world builder many benefits with little extra work:
- A world can make use of parts found anywhere on the Internet, not just the 3D world's server. In this way, worlds can incorporate creatures, furniture, dwellings, world-to-world portals, and even specialized part types licensed for use by other artists.
- A world server not only provides the most up-to-date part information when requested, it can automatically keep every client device updated any time changes are made to the part. Synchronized server updates makes it possible for multiple people to use their own devices to explore the same changeable world together.
- Resources can be cached on the local device to reduce performance "lag", yet automatically age out when used infrequently.
- Servers can manage security and licensing arrangements on a part-by-part basis.
One Language to Rule Them All
By this point, developers of interactive web sites should be experiencing deja vu all over again, as all the Acorn features discussed so far are a part of their tool suites. The difference is that Acorn does in one language what otherwise requires multiple languages and libraries:
- To specify content (only), one must use HTML, XML or JSON, each with different strengths and weaknesses. HTML and XML encode everything as text, requiring conversion (as needed) for other types of data. JSON handles multiple data structures, but requires translation so they can be integrated and rendered with HTML. Language extensions (e.g., Handlebars) are required to support procedurally-generated content. None of the content languages natively provide procedural capabilities.
Doesn't that seem unnecessarily complicated to you? All those layers of software wrestling each other's differences just steepens the learning curve and makes everyone's job unnecessarily difficult.
Such complexity can be defended by explaining each of the historical steps it took to evolve the web to what it has become. But if we are going to embark on a new and more complicated three-dimensional journey, we need a more approachable synthesis of what we have learned over the last 25 years. Acorn is the result of distilling and re-bottling the "good parts" of the world-wide web into something simple, expressive and powerful, leaving behind the legacy artifacts that add no value.
With one readable, world-building language, we can:
- efficiently assemble static AND procedurally-generated content (beyond XML and JSON).
- make it easy to select and change qualifying parts using extensible criteria (beyond XPath and CSS selectors)
- provide built-in part synchronization, without having to pick and learn a framework extension
- define interactivity and behavior in a modular, part-oriented manner, side-by-side with the content
What makes Acorn distinctive is not its capabilities, but the way it marries them together, powerfully and seamlessly.
Fast and Furious
Let's switch gears, and talk about speed.
Responsive performance is critical to widespread acceptance of 3-D world exploration. Visitors want their virtual worlds to unfold and interact in a smooth and responsive way. Unfortunately, the price one pays for Acorn's dynamic language flexibility is that it can never perform as well as a compiled language like C/C++.
Fortunately, the architecture of Web3D and Acorn greatly minimizes this handicap:
- The performance-critical code is written in C/C++, not Acorn. This includes the 3-D graphics engine, physics engine, the Acorn virtual machine and the WOM.
- Type extensions (similar to the WOM types) can also be written in C. This means that any scene's Acorn code is a thin layer on top of a high performance foundation.
- To further improve performance, the Acorn Virtual Machine uses a lightweight interpreter to execute pre-compiled Acorn code. It also supports multi-threading and an incremental garbage collector to reduce the likelihood of "lag spikes".
- Acorn enables asynchronous and predictive loading of part resources as needed to reduce load-time delays