Схема просмотра модели - PullRequest
0 голосов
/ 27 мая 2020
<!doctype html>
<html>

<head>
    <meta charset="utf-8">


</head>

<body>
    <script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.js"></script>
<script nomodule src="https://unpkg.com/@google/model-viewer/dist/model-viewer-legacy.js"></script>
<!-- Use it like any other HTML element -->
<model-viewer src="shared-assets/models/Astronaut.glb" alt="A 3D model of an astronaut" auto-rotate camera-controls></model-viewer>
</body>

</html>

Когда вы нажимаете на средство просмотра модели, появляется контур, я не могу удалить контур из model-viewer как его удалить?

When you click on model viewer the outline appears

Edit

/**
 * This is mixin function is designed to be applied to a class that inherits
 * from HTMLElement. It makes it easy for a custom element to coordinate with
 * the :focus-visible polyfill.
 *
 * @param {Function} SuperClass The base class implementation to decorate with
 * implementation that coordinates with the :focus-visible polyfill
 */
export function FocusVisiblePolyfillMixin(SuperClass) {
  var coordinateWithPolyfill = function(instance) {
    // If there is no shadow root, there is no need to coordinate with the
    // polyfill. If we already coordinated with the polyfill, we can skip
    // subsequent invokcations:
    if (
      instance.shadowRoot == null ||
      instance.hasAttribute('data-js-focus-visible')
    ) {
      return;
    }

    // The polyfill might already be loaded. If so, we can apply it to the
    // shadow root immediately:
    if (self.applyFocusVisiblePolyfill) {
      self.applyFocusVisiblePolyfill(instance.shadowRoot);
    } else {
      // Otherwise, wait for the polyfill to be loaded lazily. It might never
      // be loaded, but if it is then we can apply it to the shadow root at
      // the appropriate time by waiting for the ready event:
      self.addEventListener(
        'focus-visible-polyfill-ready',
        function() {
          self.applyFocusVisiblePolyfill(instance.shadowRoot);
        },
        { once: true }
      );
    }
  };

  // IE11 doesn't natively support custom elements or JavaScript class syntax
  // The mixin implementation assumes that the user will take the appropriate
  // steps to support both:
  return class extends SuperClass {
    // Attempt to coordinate with the polyfill when connected to the document:
    connectedCallback() {
      super.connectedCallback && super.connectedCallback();
      coordinateWithPolyfill(this);
    }
  };
}

Итак, я добавил это в имя файла focus-visible.js

добавил это в html

<body>
    <!-- The :focus-visible polyfill removes the focus ring for some input types -->
    <script src="focus-visible.js" defer></script>
    <script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.js"></script>
    <script nomodule src="https://unpkg.com/@google/model-viewer/dist/model-viewer-legacy.js"></script>
    <!-- Use it like any other HTML element -->
    <model-viewer src="shared-assets/models/Astronaut.glb" alt="A 3D model of an astronaut" auto-rotate camera-controls>
    </model-viewer>
</body>

и это в css :focus-visible polyfill{ outline: none; }

Я что-то не так делаю?

Ответы [ 3 ]

1 голос
/ 17 июля 2020

Я только что разместил нижеприведенный комментарий в репо, но оставил его здесь для всех, кто столкнется с этой проблемой в будущем.

просто убедитесь, что фокус-видимый. js включен в твоя страница. Вероятно, вы начали свою страницу просмотра моделей со старого примера, в котором его не было.

возьмите его из репозитория или по этой ссылке: https://unpkg.com/focus-visible@5.1.0 / dist / focus-visible. js

0 голосов
/ 31 мая 2020

Требует, чтобы этот скрипт был добавлен в соответствии с официальной документацией программы просмотра моделей

<script src="./_model-viewer_ Interactive Example_files/focus-visible.js.download" defer=""></script>
0 голосов
/ 27 мая 2020

Похоже, что это постоянная проблема с model-viewer, поскольку она все еще находится в разработке. Я бы go оставил отзыв на их странице github или посмотрю, совпадает ли с этой проблемой с вашей.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...