Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions images/bounding-box.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
147 changes: 146 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

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.

dispatch a `load` event upon the successful fetching and
presentation of the resource data. If the asset fails to resolve,
for instance due to an invalid URL, a failure to retrieve the bytes,
or a failure in the parsing process, the element will dispatch an
`error` event.
</p>
<h3>
Processing model contents
</h3>
<p data-cite="infra geometry-1" >
A 3D asset file contains positional data for the surfaces and objects
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
[[\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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "specified" by who? (can we change this to active voice?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to reflect that rendering contexts generally compute it this way - it may need to be called out as non-normative or otherwise an observation of the state of the art.

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>
Expand All @@ -115,7 +169,7 @@ <h3>
document:
</p>
<pre class="html">
&lt;model src="3d-assets/car"&gt;&lt;/model&gt;
&lt;model src="3d-assets/teapot"&gt;&lt;/model&gt;
</pre>
<p>
By using content negotiation the user agent relies on the server to
Expand All @@ -125,18 +179,109 @@ <h3>
<h3>
Enabling interactivity
</h3>
<aside class="example">
<p>
The following example shows how to enable the interactive rotation of
a model in a document:
</p>
<pre class="html">
&lt;model <b>interactive</b> src="3d-assets/teapot"&gt;&lt;/model&gt;
</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`:
</p>
<pre class="html">
&lt;model src="3d-assets/teapot"&gt;&lt;/model&gt;
&lt;script&gt;
let model = document.querySelector('model');

function update() {
requestAnimationFrame(update);
model.entityTransform = new DOMMatrix().rotate(0, performance.now()/10, 0);
}

requestAnimationFrame(update);
&lt;/script&gt;
</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">
&lt;model&gt;
&lt;source src="3d-assets/teapot.usdz" type="model/vnd.pixar.usd"&gt;
&lt;source src="3d-assets/teapot.gltf" type="model/gltf-binary"&gt;
&lt;/model&gt;
</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">
&lt;model&gt;
&lt;source src="3d-assets/teapot"&gt;
&lt;img src="images/teapot-fallback-thumbnail.png"&gt;
&lt;/model&gt;
</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">
&lt;model environmentmap="images/teahouse-interior-1k.hdr"&gt;
&lt;source src="3d-assets/teapot" &gt;
&lt;/model&gt;
</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">

&lt;figure&gt;
&lt;model alt="A gray, ceramic teapot with an innovative spout" &gt;
Copy link
Contributor

@marcoscaceres marcoscaceres Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we should get rid of alt=... the html around it or inside the element provides way better and more accessible fallback content (eg., <figurecaption>).

&lt;source src="3d-assets/teapot"&gt;
&lt;/model&gt;
&lt;figcaption&gt;Note the innovative spout&lt;/figcaption&gt;
&lt;/figure&gt;
</pre>
</aside>
<aside class="issue" data-number="23"></aside>
</section>
<section>
Expand Down