UNPKG

@google/model-viewer

Version:

Easily display interactive 3D models on the web and in AR!

181 lines (167 loc) 4.61 kB
/* * Copyright 2018 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. */ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { html, LitElement, property } from 'lit-element'; const DEFAULT_DIMENSIONS = { width: 0, height: 0 }; export class RenderingScenario extends LitElement { constructor() { super(...arguments); this.name = ''; this.goldens = []; this.dimensions = DEFAULT_DIMENSIONS; this.exclude = []; } get basePath() { if (!this.name) { return ''; } return `./results/${this.name}`; } render() { const { basePath } = this; const { width } = this.dimensions; const images = [{ name: 'model-viewer', description: '<model-viewer> (this version)', file: 'model-viewer.png' }].concat(this.goldens) .filter(golden => !this.exclude.includes(golden.name)) .map(golden => html ` <div class="screenshot"> <header> <h2>${golden.description}</h2> </header> <div class="check"></div> <img data-id="${this.name} ${golden.name}" style="width:${width}px" src="${basePath}/${golden.file}"> </div>`); return html ` <style> :host { display: inline-flex; flex-direction: column; flex: 0 1 auto; position: relative; margin: 1em; padding: 1em; border-radius: 3px; box-shadow: 0px 2px 8px rgba(100, 100, 100, 0.2); background-color: #fff; color: #555; font-family: Google Sans, sans-serif; } h1 { font-size: 1.5em; margin: 0.166em 0.33em 0.33em; } .screenshot > header { display: block; position: absolute; width: 100%; bottom: 1em; left: 0; text-align: center; pointer-events: none; } h2 { font-size: 1em; display: inline-block; box-sizing: border-box; border-radius: 3px; padding: 0.25em 0.5em; margin: 0; background-color: rgba(255, 255, 255, 0.75); pointer-events: none; } #screenshots { display: flex; flex-direction: row; width: 100%; align-items: center; justify-content: center; flex-wrap: wrap; } .screenshot { box-sizing: border-box; display: flex; position: relative; flex-direction: column; object-fit: contain; margin: 0.5em; transition: transform 0.3s; } .screenshot > img { max-width: 256px; flex: 0 0 0; } .check { display: flex; position: absolute; align-items: center; justify-content: center; box-sizing: bborder-box; top: 0.5em;; right: 0.5em; width: 1em; height: 1em; border-radius: 2em; border: 2px solid #fff; background-color: #f8f8f8; } .selected .check { background-color: #37474f; } .selected .check:after { content: ''; display: block; width: 0.25em; height: 0.5em; border: solid #fff; border-width: 0 2px 2px 0; transform: translate(-0em, -0.1em) rotate(45deg); } .selected { transform: translateY(-0.5em) scale(1.025); box-shadow: 0px 6px 12px rgba(100, 100, 100, 0.2); } </style> <h1>${this.name}</h1> <div id="screenshots"> ${images} </div>`; } } __decorate([ property({ type: String }) ], RenderingScenario.prototype, "name", void 0); __decorate([ property({ type: Object }) ], RenderingScenario.prototype, "goldens", void 0); __decorate([ property({ type: Object }) ], RenderingScenario.prototype, "dimensions", void 0); __decorate([ property({ type: Array }) ], RenderingScenario.prototype, "exclude", void 0); customElements.define('rendering-scenario', RenderingScenario); //# sourceMappingURL=rendering-scenario.js.map