![]() |
X3D Scene Authoring Hints |
![]() |
Authoring | Coordinate Systems | Credits | Dates | HTML | Images | Inlines/Prototypes | License | Meshes | meta Tags | Naming Conventions | Resources | Scripts | URL Links | Validation | Viewpoints | X3D-Edit | X3D for Web Authors | X3D Resources | Contact
.x3db) format
or putting Web3D examples into version control.
<unit/>
for angle (default radians),
length (default meters),
mass (default kilograms) and
force (default newtons).
<meta name='created' content='1 October 2003'/>
<meta name='revised' content='15 May 2010'/>
10 July 2004
(rather than other forms such as
July 10, 2004
or
10/7/2004).
HTML is the publishing language of the World Wide Web. HTML web pages can embedd or launch X3D scenes.
CoolImage.png vice CoolImage.PNG).CoolImage.jpg.
JPEG is the best choice for photographic images since it captures color gradations exceptionally well.
Be careful to evaluate results when modifying JPEG compression quality, since it is lossy and highest image quality is often best.
Note that
JPEG does not support transparency.
.png or .jpg format, as described above, to ensure the X3D player can display it.
It is often best to save and provide both formats so that the original highest-quality image remains available.
Example:
<ImageTexture DEF='grid'
url='"OahuGrid.png"
"https://savage.nps.edu/Savage/Locations/Hawaii/OahuGrid.png"
"OahuGrid.rgba"
"https://savage.nps.edu/Savage/Locations/Hawaii/OahuGrid.rgba"'/>
Inline, image, audio and video content.
This approach is more maintainable, uses less memory and can reduce file-transfer delays.
IMPORT/EXPORT
connections match.
Inline
tooltips
and
X3D specification
ProtoBody.
ProtoDeclare definitions into additional scenes,
instead copy ExternProtoDeclare/ProtoInstance definitions.
ProtoDeclare,
ProtoInterface and
ProtoBody
field definitions in a ProtoInterface element since that construct is illegal.
ExternProtoDeclare/ProtoInstance definitions
corresponding to each NewNodePrototype.x3d scene.
This encourages authors to avoid copying the ProtoDeclare definitions,
so that a master version remains stable and improvable.
ProtoDeclare annotation tooltips for each ExternProtoDeclare field.
Listing default values used by the prototype can be helpful.
ExternProtoDeclare
tooltips
and
X3D specification
containerField attribute, identifying parent-node field name for this ProtoInstance.
Default value: children.
Example values: color, coord, geometry, fontStyle, proxy, sound, texture, textureTransform.
ProtoInstance operation in the scene defining the original ProtoDeclare, rather than
using an ExternProtoDeclare.
Why - to make sure they work first!
Browser debugging can be more cryptic for externally defined prototypes
and different versions may occur in various remote url addresses, making it difficult to determine
precisely which ExternProtoDeclare is being referenced.
ProtoInstance
tooltips
and
X3D specification
meta tag
is included in archived X3D scenes:
<meta name="license" content="../../license.html">The license is available as license.html and also available in plain-text form as license.txt for embedding in source-code files. Under the terms of this BSD open-source license both commercial & noncommercial uses are permitted, and the contributing authors retain original copyright as appropriate. This license can be adapted for use by other open-source contributors, if desired. Discussion, rationale and references regarding this license are available via the XMSF bugtracker license entry.
meta tags<meta name="description" value="This beautiful model of an actual clean bedroom will impress your mom."/>
<meta name="description" value="This description has a trailing newline character. "/>
<meta name="title"/> (for document name)
and
<meta name="identifier"/> (for document url)
tags, with filename values ending in .x3d
(rather than VRML97 .wrl) extension.
name="value" attributes are defined by the
Dublin Core metadata terms.
meta tag such as
<meta name="generator" content="X3D-Edit, https://savage.nps.edu/X3D-Edit"/>
META "generator" "X3D-Edit, https://savage.nps.edu/X3D-Edit"
.x3d, .x3db encodings: must follow
XML requirements
for ID/IDREF data type.
.x3dv, .wrl encodings: must follow
ClassicVRML Grammar requirements
for Id/IdFirstChar.
Naming of multiple similar autogenerated files: Concatenate the following name components as appropriate. Separate components by period characters, since underscores disappear as part of a url and since hyphens will break across a line.
General notes on naming conventions:
var declaration of variables.
Instead, declare any persistent variables as field definitions in the parent Script node.
true and false to match XML and JavaScript/ECMAscript rules.
Capitalized TRUE and FALSE are only used in VRML syntax.
<Script directOutput='true'> when using SFNode/MFNode fields.
Browser.print(...) rather than a simple print(...) function
when printing to the console.
Browser.print(...) is the form supported by X3D,
print(...) was VRML97 syntax and is now obsolete.
For backwards compatibility, X3dToVrml97.xslt will strip
the preceding Browser. class qualifier when converting scripts to VRLM97.
< and > from undesirable conversions by XML parsers.
Furthermore, it eliminates the need to use < and > escape-character replacements (which make script code nonportable).
Example:
<Script mustEvaluate="true">
<field name="message" type="SFString" accessType="initializeOnly" value="World!"/>
<![CDATA[
ecmascript:
function initialize (timestamp)
{
Browser.print ('Hello ' + message);
}
]]>
</Script>
ecmascript: scripts, first add the following field interface to the Script.
<field accessType="initializeOnly" name="localTraceEnabled" type="SFBool" value="true"/>Then, at end of the CDATA section:
function tracePrint(outputString)
{
if (localTraceEnabled)
Browser.print('[ScriptNameHere] ' + outputString);
}
function forcePrint(outputString)
{
Browser.print('[ScriptNameHere] ' + outputString);
}
This lets the script author use trace-aware output functions as a substitute for Browser.print() as follows.
tracePrint('Only print when localTraceEnabled is true');
forcePrint('Always print: localTraceEnabled=' + localTraceEnabled);
url attribute values:
<ImageTexture url=' "earth-topo.png" "earth-topo-small.gif" "http://www.web3d.org/x3d/content/examples/earth-topo.png" "http://www.web3d.org/x3d/content/examples/earth-topo-small.gif" '/>or, if using the equivalent but more awkward syntax for "double-quoted"
url attribute values:
<ImageTexture url=" "earth-topo.png" "earth-topo-small.gif" "http://www.web3d.org/x3d/content/examples/earth-topo.png" "http://www.web3d.org/x3d/content/examples/earth-topo-small.gif" "/>
url has type MFString.
url tooltipsOne of the biggest benefits of the .x3d file encoding is XML validation. XML checks for well-formed documents, DTD validation and schema validation greatly improve quality assurance (QA) for X3D scenes. This approach exposes many possible errors and helps authors eliminate Garbage In Garbage Out (GIGO) problems.
X3D Specifications: DTD and Schema Validation provides links to the latest approved DTDs, schemas and documentation.
The following sections provides detailed information on the proper file syntax for X3D DTD and XML Schema headers in an .x3d scene. Each version matches the corresponding X3D version (3.0 3.1 3.2 and 3.3). Thanks to X3D stability, each version is backwards compatible. For example, the X3D v3.2 DTD and schema will validate X3D v3.1 or v3.0 content, etc.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN"
"http://www.web3d.org/specifications/x3d-3.3.dtd">
<X3D profile="Immersive" version="3.3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.3.xsd">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
"http://www.web3d.org/specifications/x3d-3.2.dtd">
<X3D profile="Immersive" version="3.2"
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.2.xsd">
There is no Transitional X3D 3.2 or 3.3 Transitional DTD since this approach is no longer needed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN"
"http://www.web3d.org/specifications/x3d-3.1.dtd">
<X3D profile="Immersive" version="3.1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.1.xsd">
The Transitional X3D 3.1 DOCTYPE/DTD was originally used by some tools, but is no longer recommended since it is not portable across different machines.
<?xml version="1.0" encoding="UTF-8"?> <!--Warning: transitional DOCTYPE in source .x3d file--> <!DOCTYPE X3D PUBLIC "http://www.web3d.org/specifications/x3d-3.1.dtd" "file:///www.web3d.org/TaskGroups/x3d/translation/x3d-3.1.dtd"> <X3D profile="Immersive" version="3.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.1.xsd">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"
"http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile="Immersive" version="3.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.0.xsd">
The Transitional X3D 3.0 DOCTYPE/DTD was originally used by some tools, but it is no longer recommended since it is not portable across different machines.
<?xml version="1.0" encoding="UTF-8"?> <!--Warning: transitional DOCTYPE in source .x3d file--> <!DOCTYPE X3D PUBLIC "http://www.web3d.org/specifications/x3d-3.0.dtd" "file:///www.web3d.org/TaskGroups/x3d/translation/x3d-3.0.dtd"> <X3D profile="Immersive" version="3.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.0.xsd">When offline, X3D-Edit 3.1 can only load scenes containing the proper DTD one at a time. When disconnected from the network, click on a scene (or drag & drop the scene onto the X3D-Edit icon) to launch it - the DOCTYPE will be converted to Transitional DTD upon launch, and restored to Final DTD upon normal exit. Alternatively, use a different X3D/XML/text editor or the Transitional X3D DOCTYPE/DTD with X3D-Edit.
C:\www.web3d.org\x3d\content> java X3dDoctypeChecker usage: java X3dDoctypeChecker sceneName.x3d [-setFinalDTD | -setTransitionalDTD]
Developmental versions of all X3D DTDs and schemas are maintained under version control at http://x3d.svn.sourceforge.net/viewvc/x3d/www.web3d.org/specifications
Updated: 3 December 2011
Maintained by
Don Brutzman
(brutzman at nps.edu).
Comments & suggestions are welcome.
These hints were collected while teaching X3D Graphics and writing
X3D for Web Authors.
Online at
http://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html