-
Notifications
You must be signed in to change notification settings - Fork 14
Expand and revise examples section #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
e1ec3a2
d4850aa
c762cf4
f9a657b
7c0993b
5420d3a
b77cce9
3ad1e88
5e037a9
f636735
b5bfa2a
9fabdc7
aacf9b3
d83b03f
97f2282
b2a7762
25db3a0
96a1258
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,60 @@ <h3> | |
<h2> | ||
Examples | ||
</h2> | ||
<h3> | ||
Loading and parsing | ||
</h3> | ||
<p> | ||
A model element whose source path resolves to a valid resource | ||
dispatch a `load` event upon the successful fetching and | ||
presentation of the resource data. If the asset fails to resolve, | ||
zachernuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
for instance due to an invalid URL, a failure to retrieve the bytes, | ||
zachernuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
or a failure in the parsing process, the element will dispatch an | ||
zachernuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
`error` event. | ||
</p> | ||
zachernuk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<h3> | ||
Processing model contents | ||
</h3> | ||
<p data-cite="infra geometry-1" > | ||
A 3D asset file contains positional data for the surfaces and objects | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The text in this section feels more like spec text than an example (it's a bit uncommon to talk about how the internals work in an example)... I wonder if we should move this or actually simplify all this into an example of usage? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @marcoscaceres I think it's not example content at all, yeah - I'll pull it out of this PR. Is there a good section name / description of this kind of content you'd recommend instead? |
||
within it. Following the successful processing of a model resource, the | ||
{{model/boundingBox}} attribute references a | ||
zachernuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
[[\DOMBoundingBoxReadOnly]] internal slot, which | ||
is a nullable [=map=] of whose values are {{DOMPoint}}s. | ||
The slot contains four entries: | ||
</p> | ||
<dl data-cite="infra geometry-1"> | ||
<dt>"min"</dt> | ||
<dd>A {{DOMPoint}} representing the minimum dimension, in world | ||
space, that the contents of a model occupies.</dd> | ||
<dt>"max"</dt> | ||
<dd>A {{DOMPoint}} representing the maximum dimension, in world | ||
space, that the contents of a model occupies.</dd> | ||
<dt>"center"</dt> | ||
<dd>A {{DOMPoint}} representing the mean of the min and max | ||
dimensions, in world space, of the bounding box that the contents of | ||
a model occupies.</dd> | ||
<dt>"radius"</dt> | ||
<dd>A floating-point number representing the radius of effective | ||
bounding sphere from the center of the box. | ||
</dd> | ||
</dl> | ||
<p> | ||
If a model does not contain a valid resource, the [[\DOMBoundingBoxReadOnly]] internal slot is null. | ||
</p> | ||
</p> | ||
<figure> | ||
<img alt="" src= | ||
"images/bounding-box.svg"> | ||
<figcaption>Visual aid demonstrating the extent of an object's bounding box</figcaption> | ||
</figure> | ||
<aside class="note"> | ||
The bounding box and sphere is often computed based on the visible object | ||
hierarchy on the first animation frame (if an animation is present), | ||
and according only to the geometry information directly specified. | ||
|
||
While animation effects and geometric displacement based on material | ||
data can alter these values, it is not required to integrate them. | ||
</aside> | ||
<h3> | ||
Adding a model to a document | ||
</h3> | ||
|
@@ -115,7 +169,7 @@ <h3> | |
document: | ||
</p> | ||
<pre class="html"> | ||
<model src="3d-assets/car"></model> | ||
<model src="3d-assets/teapot"></model> | ||
</pre> | ||
<p> | ||
By using content negotiation the user agent relies on the server to | ||
|
@@ -125,18 +179,109 @@ <h3> | |
<h3> | ||
Enabling interactivity | ||
</h3> | ||
<aside class="example"> | ||
zachernuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
<p> | ||
The following example shows how to enable the interactive rotation of | ||
a model in a document: | ||
</p> | ||
<pre class="html"> | ||
<model <b>interactive</b> src="3d-assets/teapot"></model> | ||
</pre> | ||
<p> | ||
See [interactive mode] for more details on the circumstances of | ||
interactive mode. | ||
</p> | ||
</aside> | ||
<aside class="issue" data-number="20"></aside> | ||
<h3> | ||
Programmatic view control | ||
</h3> | ||
<aside class="example"> | ||
<p> | ||
The following example shows how to use the Javascript API to control | ||
the `entityTransform`: | ||
zachernuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
</p> | ||
<pre class="html"> | ||
<model src="3d-assets/teapot"></model> | ||
<script> | ||
let model = document.querySelector('model'); | ||
zachernuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
function update() { | ||
requestAnimationFrame(update); | ||
model.entityTransform = new DOMMatrix().rotate(0, performance.now()/10, 0); | ||
zachernuk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
|
||
requestAnimationFrame(update); | ||
</script> | ||
</pre> | ||
<p data-cite="infra geometry-1"> | ||
See {{DOMMatrix}} for more details on the methods available for | ||
modifying the view transform. | ||
</p> | ||
</aside> | ||
<h3> | ||
Supporting multiple formats | ||
</h3> | ||
<aside class="example"> | ||
<p> | ||
The following example shows how to select from a list of potential | ||
source formats: | ||
</p> | ||
<pre class="html"> | ||
<model> | ||
<source src="3d-assets/teapot.usdz" type="model/vnd.pixar.usd"> | ||
<source src="3d-assets/teapot.gltf" type="model/gltf-binary"> | ||
</model> | ||
</pre> | ||
</aside> | ||
<aside class="issue" data-number="21"></aside> | ||
<h3> | ||
Providing fallback content for legacy user agents | ||
</h3> | ||
<aside class="example"> | ||
<p> | ||
The following example shows the inclusion of fallback content: | ||
</p> | ||
<pre class="html"> | ||
<model> | ||
<source src="3d-assets/teapot"> | ||
<img src="images/teapot-fallback-thumbnail.png"> | ||
</model> | ||
</pre> | ||
</aside> | ||
<aside class="issue" data-number="22"></aside> | ||
<h3> | ||
Providing an image-based light (IBL) | ||
</h3> | ||
<aside class="example"> | ||
<p> | ||
The following example shows the inclusion of a custom image-based | ||
light | ||
</p> | ||
<pre class="html"> | ||
<model environmentmap="images/teahouse-interior-1k.hdr"> | ||
<source src="3d-assets/teapot" > | ||
</model> | ||
</pre> | ||
</aside> | ||
<h3> | ||
Making `model` accessible | ||
</h3> | ||
<aside class="example"> | ||
<p> | ||
The following example shows the inclusion of descriptive language | ||
characterizing the appearance of the model: | ||
</p> | ||
<pre class="html"> | ||
|
||
<figure> | ||
<model alt="A gray, ceramic teapot with an innovative spout" > | ||
|
||
<source src="3d-assets/teapot"> | ||
</model> | ||
<figcaption>Note the innovative spout</figcaption> | ||
</figure> | ||
</pre> | ||
</aside> | ||
<aside class="issue" data-number="23"></aside> | ||
</section> | ||
<section> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there's a lot of value to adding this example here because it's so limited (plus it doesn't really deal with "loading or parsing", just very simple error handling). Consider that, like any event handling element, the element will deal (in one way or another) with all these event handler attributes:
https://html.spec.whatwg.org/#event-handlers-on-elements,-document-objects,-and-window-objects
Also, if we end up treating these elements as akin to media elements, then we might end up using these error codes, etc.:
https://html.spec.whatwg.org/#error-codes
I'd be inclined to either rename this section "Error handling" or removing it entirely until we figure out if model is a media element.