diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6b9bbcc --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +*.usdz filter=lfs diff=lfs merge=lfs -text +*.glb filter=lfs diff=lfs merge=lfs -text +*.hdr filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text diff --git a/autoplay-loop.html b/autoplay-loop.html new file mode 100644 index 0000000..cc1d6e3 --- /dev/null +++ b/autoplay-loop.html @@ -0,0 +1,36 @@ + + +
+ + + +
+ If a model contains an animation track, it will be available to play once
+ the model has loaded. autoplay
will trigger the playback
+ automatically, and loop
will loop the content, irrespective
+ of whether the playback was started via the JavaScript
+ play()
or the attribute.
+
+<model autoplay loop alt="A model of a teapot with a hidden creature"> + <source src="./teapot.usdz" type="model/vnd.usdz+zip" /> + <source src="./teapot.glb" type="model/gltf-binary" /> +</model> ++
+ A model's DOMMatrixReadOnly entityTransform
can be set to
+ display a certain side, or to automatically animate the content.
+
+<model alt="A model of a teapot"> + <source src="./teapot.usdz" type="model/vnd.usdz+zip" /> + <source src="./teapot.glb" type="model/gltf-binary" /> +</model> ++
+let initialTransform; +const model = document.querySelector('model'); +await model.ready; +initialTransform = model.entityTransform.translate(0,0,-0.05); +requestAnimationFrame(update); + +function update() { + try { + const angleY = performance.now()/10; + model.entityTransform = initialTransform.rotate(0, angleY,0); + } catch(error) { + console.warn("failed to set transform", error); + } + requestAnimationFrame(update); +} ++ +
+ Set the background with CSS. Note that because the model exists in a plane + conceptually behind the page, it is not recommended to support a + transparent background. +
++<model alt="A model of a teapot"> + <source src="./teapot.usdz" type="model/vnd.usdz+zip" /> + <source src="./teapot.glb" type="model/gltf-binary" /> +</model> ++
+model { + background-color:blue; +} ++ +
+<model alt="A model of a teapot" data-src="./teapot.usdz" data-type="model/vnd.usdz+zip"> +</model> ++
+const model = document.querySelector('model'); +const {src, type} = model.dataset; +const bytes = await (await fetch(src)).bytes(); +const srcString = URL.createObjectURL(new Blob([bytes], {type})); +model.setAttribute('src', srcString); ++ +
+ <model alt="A model of a teapot"> + <source src="./teapot.usdz" type="model/vnd.usdz+zip" /> + <source src="./teapot.glb" type="model/gltf-binary" /> + </model> ++ +
+ after model.ready
promise is resolved, a model can report its
+ DOMPoint boundingBoxExtents
and
+ DOMPoint boundingBoxCenter
.
+
+ When a model has an animation, its currentTime
attribute can
+ be read and written to update the animation's progress.
+
model.currentTime = 2.5;+ +
+ Use of the environmentmap
attribute to set a custom image-based light (IBL) resource.
+ Note that while the resource may be an image in any format, the dynamic range requirements for an IBL
+ mean that it is strongly recommended to use a raw, high-dynamic range (HDR) format like
+ the Radiance RGBE .hdr
format, or the OpenEXR .exr
format. Resources are assumed
+ to be presented in the equirectangular projection.
+
+<model environmentmap="night.hdr" alt="a teapot in a dark environment"> + <source src="./teapot.usdz" type="model/vnd.usdz+zip" /> + <source src="./teapot.glb" type="model/gltf-binary" /> + <img src="./teapot-fallback-ibl.jpg" alt="An image of a model of a teapot lit by a dark environment" > +</model> ++
- This specification does neat stuff. -
-- This is an unofficial proposal. -
-- See ReSpec's user guide - for how toget started! -
-