UNPKG

bytev-charts

Version:

基于echarts和JavaScript及ES6封装的一个可以直接调用的图表组件库,内置主题设计,简单快捷,且支持用户自定义配置; npm 安装方式: npm install bytev-charts 若启动提示还需额外install插件,则运行 npm install @babel/runtime-corejs2 即可;

120 lines (106 loc) 3.97 kB
import "core-js/modules/es.regexp.exec.js"; import "core-js/modules/es.string.replace.js"; var VRButton = { createButton: function createButton(renderer, options) { if (options) { console.error('THREE.VRButton: The "options" parameter has been removed. Please set the reference space type via renderer.xr.setReferenceSpaceType() instead.'); } function /*device*/ showEnterVR() { var currentSession = null; function onSessionStarted(session) { session.addEventListener('end', onSessionEnded); renderer.xr.setSession(session); button.textContent = 'EXIT VR'; currentSession = session; } function /*event*/ onSessionEnded() { currentSession.removeEventListener('end', onSessionEnded); button.textContent = 'ENTER VR'; currentSession = null; } // button.style.display = ''; button.style.cursor = 'pointer'; button.style.left = 'calc(50% - 50px)'; button.style.width = '100px'; button.textContent = 'ENTER VR'; button.onmouseenter = function () { button.style.opacity = '1.0'; }; button.onmouseleave = function () { button.style.opacity = '0.5'; }; button.onclick = function () { if (currentSession === null) { // WebXR's requestReferenceSpace only works if the corresponding feature // was requested at session creation time. For simplicity, just ask for // the interesting ones as optional features, but be aware that the // requestReferenceSpace call will fail if it turns out to be unavailable. // ('local' is always available for immersive sessions and doesn't need to // be requested separately.) var sessionInit = { optionalFeatures: ['local-floor', 'bounded-floor', 'hand-tracking'] }; navigator.xr.requestSession('immersive-vr', sessionInit).then(onSessionStarted); } else { currentSession.end(); } }; } function disableButton() { button.style.display = ''; button.style.cursor = 'auto'; button.style.left = 'calc(50% - 75px)'; button.style.width = '150px'; button.onmouseenter = null; button.onmouseleave = null; button.onclick = null; } function showWebXRNotFound() { disableButton(); button.textContent = 'VR NOT SUPPORTED'; } function stylizeElement(element) { element.style.position = 'absolute'; element.style.bottom = '20px'; element.style.padding = '12px 6px'; element.style.border = '1px solid #fff'; element.style.borderRadius = '4px'; element.style.background = 'rgba(0,0,0,0.1)'; element.style.color = '#fff'; element.style.font = 'normal 13px sans-serif'; element.style.textAlign = 'center'; element.style.opacity = '0.5'; element.style.outline = 'none'; element.style.zIndex = '999'; } if ('xr' in navigator) { var button = document.createElement('button'); button.id = 'VRButton'; button.style.display = 'none'; stylizeElement(button); navigator.xr.isSessionSupported('immersive-vr').then(function (supported) { supported ? showEnterVR() : showWebXRNotFound(); }); return button; } else { var message = document.createElement('a'); if (window.isSecureContext === false) { message.href = document.location.href.replace(/^http:/, 'https:'); message.innerHTML = 'WEBXR NEEDS HTTPS'; // TODO Improve message } else { message.href = 'https://immersiveweb.dev/'; message.innerHTML = 'WEBXR NOT AVAILABLE'; } message.style.left = 'calc(50% - 90px)'; message.style.width = '180px'; message.style.textDecoration = 'none'; stylizeElement(message); return message; } } }; export { VRButton };