-
Notifications
You must be signed in to change notification settings - Fork 25
Getting started
XML3D with xml3d.js potentially runs on any browser with WebGL support. However, in practice we only test support for the following browsers:
- Chrome
- Firefox
Interested in adding support for other browsers? Just contact us!
To make XML3D work, all you need to do is include the xml3d.js library in your XHTML document.
Just make sure, that you include xml3d.js as the very first js library in your document, like so:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- Your usual header stuff, but NO <script> -->
<script src="http://www.xml3d.org/xml3d/script/xml3d.js"></script>
<!-- Other <script> tags -->
</head>
Important things to remember:
- xml3d.js currently only works in XHTML documents
- Always add the xml3d.js library first for all JavaScript libraries! (Yes, even before jquery.)
XML3D is an extension to HTML. Just as you write HTML for text and images like so:
<p>
This is some generic paragraph <span>with a twist</span>
<img src="yayColors.png" alt="and an image" />
</p>
You can write XML3D for 3D content:
<p>Following this paragraphs we will break the second dimension!</p>
<xml3d xmlns="http://www.xml3d.org/2009/xml3d" >
<mesh src="yayVertices.xml" />
</xml3d>
<p>... did you see it?</p>
- All XML3D elements inside of XHTML use the http://www.xml3d.org/2009/xml3d namespace
- All 3D content is declared inside an
<xml3d>
element, which defines the canvas through which the 3D scene is displayed. - The
<xml3d>
element is displayed as an inline-block element like<canvas>
and can be styled exactly the same way.
Beyond that it's all about understanding the set of XML3D elements. Good news: there are only few of them. Currently less then 20.
- Tutorial: XML3D - the basics
- Browse our XML3D examples and look at the source code
- Read the specification
If a standard navigation mode is sufficient for your web application, you can include the camera controller that comes with xml3d.js:
<script src="http://www.xml3d.org/xml3d/script/xml3d.js"></script>
<script src="http://www.xml3d.org/xml3d/script/tools/camera.js"></script>