Skip to content

Commit

Permalink
Adding docs (google#1609)
Browse files Browse the repository at this point in the history
* add everything to docs.json

* hide subcategories of sections not in view

* added normal files over sans things like loading/model format

* add model formats to loading

* added sticky header to examples

* rough fix for sidebar reflowing

* change defaults to object instead of list
  • Loading branch information
chrismgeorge authored Oct 7, 2020
1 parent f057f7a commit b974dc7
Show file tree
Hide file tree
Showing 16 changed files with 2,687 additions and 127 deletions.
644 changes: 581 additions & 63 deletions packages/modelviewer.dev/data/docs.json

Large diffs are not rendered by default.

166 changes: 166 additions & 0 deletions packages/modelviewer.dev/data/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,142 @@
{
"htmlId": "demo-container-5",
"name": "Cycling Posters"
},
{
"htmlId": "demo-container-6",
"name": "glTF Model"
},
{
"htmlId": "demo-container-7",
"name": "GLB Model"
},
{
"htmlId": "demo-container-8",
"name": "DRACO Support"
},
{
"htmlId": "demo-container-9",
"name": "USDZ Model"
},
{
"htmlId": "demo-container-10",
"name": "No Model"
},
{
"htmlId": "demo-container-11",
"name": "Cycling Models"
}
]
},
{
"name": "Augmented Reality",
"htmlName": "augmentedreality",
"examples": [
{
"htmlId": "demo-container-1",
"name": "WebXR"
},
{
"htmlId": "demo-container-2",
"name": "AR"
},
{
"htmlId": "demo-container-3",
"name": "Scene Viewer"
},
{
"htmlId": "demo-container-4",
"name": "Custom Button"
},
{
"htmlId": "demo-container-5",
"name": "Transparent Background"
}
]
},
{
"name": "Staging & Cameras",
"htmlName": "stagingandcameras",
"examples": [
{
"htmlId": "demo-container-1",
"name": "Enable Interaction"
},
{
"htmlId": "demo-container-2",
"name": "Camera Orbit"
},
{
"htmlId": "demo-container-3",
"name": "Orbit and Scroll"
},
{
"htmlId": "demo-container-4",
"name": "Interpolation"
},
{
"htmlId": "demo-container-5",
"name": "Default Target"
},
{
"htmlId": "demo-container-6",
"name": "Camera Target"
},
{
"htmlId": "demo-container-7",
"name": "Other Interactions"
}
]
},
{
"name": "Annotations",
"htmlName": "annotations",
"examples": [
{
"htmlId": "demo-container-1",
"name": "Add Hotspots"
}
]
},
{
"name": "Lighting & Env",
"htmlName": "lightingandenv",
"examples": [
{
"htmlId": "demo-container-1",
"name": "HDR skybox-image"
},
{
"htmlId": "demo-container-2",
"name": "Lit Model"
},
{
"htmlId": "demo-container-3",
"name": "Unlit Model"
},
{
"htmlId": "demo-container-4",
"name": "Environment Lighting"
},
{
"htmlId": "demo-container-5",
"name": "Skybox and Environment"
},
{
"htmlId": "demo-container-6",
"name": "Render Exposure"
},
{
"htmlId": "demo-container-7",
"name": "Shadows"
},
{
"htmlId": "demo-container-8",
"name": "Another HDR Examples"
},
{
"htmlId": "demo-container-9",
"name": "LDR environment-image"
}
]
},
Expand All @@ -46,5 +182,35 @@
"name": "Paused"
}
]
},
{
"name": "Scene Graph",
"htmlName": "scenegraph",
"examples": [
{
"htmlId": "demo-container-1",
"name": "Change Color"
},
{
"htmlId": "demo-container-2",
"name": "Change Material"
},
{
"htmlId": "demo-container-3",
"name": "Swap Textures"
},
{
"htmlId": "demo-container-4",
"name": "Swap Textures 2"
},
{
"htmlId": "demo-container-5",
"name": "Exporter"
},
{
"htmlId": "demo-container-5",
"name": "Exporter w/ Options"
}
]
}
]
5 changes: 5 additions & 0 deletions packages/modelviewer.dev/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
<div class="outer-content">
<div id="toggle"></div>
<div id="loading-docs"></div>
<div id="augmentedreality-docs"></div>
<div id="stagingandcameras-docs"></div>
<div id="annotations-docs"></div>
<div id="lightingandenv-docs"></div>
<div id="animation-docs"></div>
<div id="scenegraph-docs"></div>
</div>

<script type="module" src="../examples/built/docs-and-examples.js">
Expand Down
6 changes: 0 additions & 6 deletions packages/modelviewer.dev/examples/animation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@
</head>
<body>

<style>
html {
scroll-padding-top: 0px;
}
</style>

<div class="examples-page">
<div class="sidebar" id="sidenav"></div>
<div id="toggle"></div>
Expand Down
164 changes: 164 additions & 0 deletions packages/modelviewer.dev/examples/annotations/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<!--
/* @license
* Copyright 2020 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>&lt;model-viewer&gt; Annotations</title>
<meta charset="utf-8">
<meta name="description" content="&lt;model-viewer&gt; annotation examples">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" href="../../styles/examples.css" rel="stylesheet" />
<link type="text/css" href="../../styles/docs.css" rel="stylesheet" />
<link rel="shortcut icon" type="image/png" href="../../assets/favicon.png"/>
<script src="../../node_modules/resize-observer-polyfill/dist/ResizeObserver.js"></script>

<!-- The following libraries and polyfills are recommended to maximize browser support -->

<!-- 🚨 REQUIRED: Web Components polyfill to support Edge and Firefox < 63 -->
<script src="../../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>

<!-- 💁 OPTIONAL: Intersection Observer polyfill for better performance in Safari and IE11 -->
<script src="../../node_modules/intersection-observer/intersection-observer.js"></script>

<!-- 💁 OPTIONAL: Resize Observer polyfill improves resize behavior in non-Chrome browsers -->
<script src="../../node_modules/resize-observer-polyfill/dist/ResizeObserver.js"></script>

<!-- 💁 OPTIONAL: The :focus-visible polyfill removes the focus ring for some input types -->
<script src="../../node_modules/focus-visible/dist/focus-visible.js" defer></script>

</head>
<body>

<div class="examples-page">
<div class="sidebar" id="sidenav"></div>
<div id="toggle"></div>
<div class="examples-container">
<div class="sample">
<div id="demo-container-1" class="demo"></div>
<div class="content">
<div class="wrapper">
<h4 id="intro"><span class="font-medium">Annotations. </span></h4>
<p>
Use &lt;model-viewer&gt; to make your models interactive.
This page showcases how you can add hotspots to your scene. Child elements are hotspots if their slot begins with "hotspot".
The data-position attribute specifies the 3D position of the hotspot in model coordinates, using the same format as the
camera-target attribute. The data-normal attribute specifies the normal vector defining the "front" of the hotspot.
When this normal is pointed away from the viewer, the hotspot's opacity becomes --min-hotspot-opacity. The
<a href="tester.html">interactive example</a> lets you drag and drop your own models and add hotspots by clicking
and displays the corresponding position and normal attributes which you can copy into your own page.
</p>
<p>
You can also specify an attribute to be toggled when the hotspot changes between hidden and visible with data-visibility-attribute.
For example, if you set data-visibility-attribute="visible", then &lt;model-viewer&gt; will toggle the data-visible attribute on
that hotspot element. This makes it easier to write CSS that styles a hotspot based on its visibility.
</p>
<p>
When a hotspot's visibility changes, it will dispatch a "hotspot-visibility" event, and event.detail.visible will be true or false
depending on whether the hotspot is facing the camera.
</p>
<div class="heading">
<h2 class="demo-title">Add hotspots</h2>
<h4></h4>
</div>
<example-snippet stamp-to="demo-container-1" highlight-as="html">
<template>
<style>
button{
display: block;
width: 20px;
height: 20px;
border-radius: 10px;
border: none;
background-color: blue;
box-sizing: border-box;
}

button[slot="hotspot-hand"]{
--min-hotspot-opacity: 0;
background-color: red;
}

button[slot="hotspot-foot"]:not([data-visible]) {
background-color: transparent;
border: 3px solid blue;
}

#annotation{
background-color: #888888;
position: absolute;
transform: translate(10px, 10px);
border-radius: 10px;
padding: 10px;
}
/* This keeps child nodes hidden while the element loads */
:not(:defined) > * {
display: none;
}
</style>
<model-viewer id="hotspot-demo" ar ar-modes="webxr" camera-controls src="../../shared-assets/models/Astronaut.glb" style="--poster-color:#ffffff00;" alt="A 3D model of an astronaut.">
<button slot="hotspot-visor" data-position="0 1.75 0.35" data-normal="0 0 1"></button>
<button slot="hotspot-hand" data-position="-0.54 0.93 0.1" data-normal="-0.73 0.05 0.69">
<div id="annotation">This hotspot disappears completely</div>
</button>
<button slot="hotspot-foot" data-position="0.16 0.1 0.17" data-normal="-0.07 0.97 0.23" data-visibility-attribute="visible"></button>
<div id="annotation">This annotation is fixed in screen-space</div>
</model-viewer>
</template>
</example-snippet>
</div>
</div>
</div>

<div class="footer">
<ul>
<li class="attribution">
<a href="https://poly.google.com/view/dLHpzNdygsg">Astronaut</a> by <a href="https://poly.google.com/user/4aEd8rQgKu2">Poly</a>,
licensed under <a href="https://creativecommons.org/licenses/by/2.0/">CC-BY</a>.
</li>
</ul>
<div style="margin-top:24px;" class="copyright">©Copyright 2019 Google Inc. Licensed under the Apache License 2.0.</div>
<div><a href="https://github.com/google/model-viewer">Github</a><a href="https://model-viewer.glitch.me/">Glitch</a><a href="https://github.com/google/model-viewer/issues">Bug report</a></div>
</div>
</div>
</div>

<script type="module" src="../../examples/built/docs-and-examples.js">
</script>
<script type="module">
(() => { init('examples-annotations'); })();
</script>


<!-- Documentation-specific dependencies: -->
<script type="module"
src="../built/dependencies.js">
</script>
<script nomodule
src="../built/dependencies-legacy.js">
</script>

<!-- Loads <model-viewer> only on modern browsers: -->
<script type="module"
src="../../node_modules/@google/model-viewer/dist/model-viewer.js">
</script>

<!-- Loads <model-viewer> only on old browsers like IE11: -->
<script nomodule
src="../../node_modules/@google/model-viewer/dist/model-viewer-legacy.js">
</script>
</body>
</html>
Loading

0 comments on commit b974dc7

Please sign in to comment.