bugfix model download-button
This commit is contained in:
parent
9be235bc69
commit
2c9f523c06
2 changed files with 16 additions and 3 deletions
|
|
@ -21,7 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
<a class="btn-foot" id="source" target="_blank" href="https://github.com/coderofsalvation/xrfragment-helloworld">➕ clone project</a>
|
<a class="btn-foot" id="source" target="_blank" href="https://github.com/coderofsalvation/xrfragment-helloworld">➕ clone project</a>
|
||||||
<a class="btn-foot" id="embed" target="_blank" onclick="embed()">📺 embed</a>
|
<a class="btn-foot" id="embed" target="_blank" onclick="embed()">📺 embed</a>
|
||||||
<a class="btn-foot" id="model" target="_blank" href="">⬇️ model</a>
|
<a class="btn-foot" id="model" target="_blank" href="example.gltf">⬇️ model</a>
|
||||||
<textarea style="display:none"></textarea>
|
<textarea style="display:none"></textarea>
|
||||||
<a-scene light="defaultLightsEnabled: false">
|
<a-scene light="defaultLightsEnabled: false">
|
||||||
<a-entity id="player" wasd-controls look-controls>
|
<a-entity id="player" wasd-controls look-controls>
|
||||||
|
|
@ -66,6 +66,7 @@
|
||||||
const isExtern = url[0] != '#'
|
const isExtern = url[0] != '#'
|
||||||
const notIsHome = url != $('#home').getAttribute("xrf")
|
const notIsHome = url != $('#home').getAttribute("xrf")
|
||||||
const promise = e.promise() // promisify event
|
const promise = e.promise() // promisify event
|
||||||
|
document.querySelector('#model').setAttribute('href',url.replace(/.*\?/,'') )
|
||||||
if( !renderer.xr.isPresenting ){
|
if( !renderer.xr.isPresenting ){
|
||||||
if( isExtern && notIsHome ){
|
if( isExtern && notIsHome ){
|
||||||
if( !confirm("teleport to "+url+" ?") ) return promise.reject('teleport rejected')
|
if( !confirm("teleport to "+url+" ?") ) return promise.reject('teleport rejected')
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
<a class="btn-foot" id="source" target="_blank" href="https://github.com/coderofsalvation/xrfragment-helloworld">➕ clone project</a>
|
<a class="btn-foot" id="source" target="_blank" href="https://github.com/coderofsalvation/xrfragment-helloworld">➕ clone project</a>
|
||||||
<a class="btn-foot" id="embed" target="_blank" onclick="embed()">📺 embed</a>
|
<a class="btn-foot" id="embed" target="_blank" onclick="embed()">📺 embed</a>
|
||||||
<a class="btn-foot" id="model" target="_blank" href="">⬇️ model</a>
|
<a class="btn-foot" id="model" target="_blank" href="example.gltf">⬇️ model</a>
|
||||||
<textarea style="display:none"></textarea>
|
<textarea style="display:none"></textarea>
|
||||||
|
|
||||||
<script async src="./../../assets/js/alpine.min.js"></script>
|
<script async src="./../../assets/js/alpine.min.js"></script>
|
||||||
|
|
@ -126,7 +126,19 @@
|
||||||
window.XRF = XRF // expose to form
|
window.XRF = XRF // expose to form
|
||||||
|
|
||||||
let file = document.location.search.length > 2 ? document.location.search.substr(1) + document.location.hash : 'example.gltf#pos=1,0,4&rot=0,-30,0'
|
let file = document.location.search.length > 2 ? document.location.search.substr(1) + document.location.hash : 'example.gltf#pos=1,0,4&rot=0,-30,0'
|
||||||
$('#model').setAttribute("href","./../../asset/"+file)
|
|
||||||
|
// optional decoration of href event
|
||||||
|
XRF.addEventListener('href',(e) => {
|
||||||
|
if( e.click ){
|
||||||
|
const { mesh, model, camera, scene, renderer, THREE} = e.XRF
|
||||||
|
const url = e.xrf.string
|
||||||
|
const isExtern = url[0] != '#'
|
||||||
|
const promise = e.promise() // promisify event
|
||||||
|
document.querySelector('#model').setAttribute('href',url.replace(/.*\?/,'') )
|
||||||
|
promise.resolve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
XRF.navigator.to( file )
|
XRF.navigator.to( file )
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue