This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from gmusicapi.api import Api | |
from getpass import getpass | |
import sys | |
def init(): | |
api = Api() | |
logged_in = False | |
attempts = 0 |
![dog.jpg](https://gist.github.com/makihiro/477de47b4c215c40ca138c6a4f83e6c4/raw/743dc0123aa6de5aa036d5abc72e2d1167c16fde/dog.jpg)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import, print_function | |
import os | |
import time | |
from io import BytesIO | |
import numpy as np | |
import requests | |
from matplotlib import pyplot as plt | |
from PIL import Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//L99-103 | |
if (navigator.xr) { | |
navigator.xr.isSessionSupported('immersive-ar') | |
.then((supported) => { | |
// XRデバイスが有効でimmersive-arがサポートされていれば、XRボタンを有効にする処理 | |
xrButton.enabled = supported; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//L99-103 | |
if (navigator.xr) { | |
navigator.xr.isSessionSupported('immersive-ar') | |
.then((supported) => { | |
// XRデバイスが有効でimmersive-arがサポートされていれば、XRボタンを有効にする処理 | |
xrButton.enabled = supported; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//L107-113 | |
function onRequestSession() { | |
return navigator.xr.requestSession('immersive-ar', {requiredFeatures: ['local', 'hit-test']}) | |
.then((session) => { | |
// XRセッションを開始する処理 | |
// requiredFeaturesでhit-testを要求 | |
xrButton.setSession(session); | |
onSessionStarted(session); //onSessionStartedのコール | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//L135-146,onSessionStarted内 | |
session.requestReferenceSpace('viewer').then((refSpace) => { | |
xrViewerSpace = refSpace; | |
session.requestHitTestSource({ space: xrViewerSpace }).then((hitTestSource) => { | |
xrHitTestSource = hitTestSource; //hit testの要求 | |
}); | |
}); | |
session.requestReferenceSpace('local').then((refSpace) => { | |
xrRefSpace = refSpace; | |
session.requestAnimationFrame(onXRFrame); //Render loop処理のコール |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//L198-211,onXRFrame内 | |
if (xrHitTestSource && pose) { | |
let hitTestResults = frame.getHitTestResults(xrHitTestSource); | |
if (hitTestResults.length > 0) { | |
//hit testを行い、hit testの結果が得られたら、バーチャルオブジェクト(reticle)を可視にセットする処理。表示位置はpose情報から取得 | |
let pose = hitTestResults[0].getPose(xrRefSpace); | |
reticle.visible = true; | |
reticle.matrix = pose.transform.matrix; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addARObjectAt(matrix) { | |
let newFlower = arObject.clone(); | |
newFlower.visible = true; | |
newFlower.matrix = matrix; | |
scene.addNode(newFlower); //sceneに仮想オブジェクトnewFlowerを追加 | |
flowers.push(newFlower); | |
if (flowers.length > MAX_FLOWERS) { | |
let oldFlower = flowers.shift(); | |
scene.removeNode(oldFlower); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//L155-157 | |
function onSessionEnded(event) { | |
xrButton.setSession(null); | |
} |
OlderNewer