added video src's
This commit is contained in:
parent
1a9ba0a56f
commit
4afed5d0c0
5 changed files with 203 additions and 82 deletions
File diff suppressed because one or more lines are too long
|
|
@ -74,11 +74,10 @@ xrf.reset = () => {
|
|||
return true
|
||||
};
|
||||
let nodes = []
|
||||
xrf.scene.traverse( (n) => n.audio ? n.audio.remove() : false )
|
||||
xrf.scene.traverse( (child) => child.isXRF ? nodes.push(child) : false )
|
||||
nodes.map( disposeObject ) // leave non-XRF objects intact
|
||||
xrf.interactive = xrf.InteractiveGroup( xrf.THREE, xrf.renderer, xrf.camera)
|
||||
if( xrf.audio ) xrf.audio.map( (a) => a.remove() )
|
||||
xrf.audio = []
|
||||
xrf.add( xrf.interactive )
|
||||
xrf.layers = 0
|
||||
xrf.emit('reset',{})
|
||||
|
|
|
|||
|
|
@ -61,8 +61,9 @@ let loadAudio = (mimetype) => function(url,opts){
|
|||
}
|
||||
}
|
||||
mesh.add(sound)
|
||||
xrf.audio.push(sound)
|
||||
});
|
||||
|
||||
mesh.audio = sound
|
||||
}
|
||||
|
||||
let audioMimeTypes = [
|
||||
|
|
@ -78,5 +79,5 @@ audioMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadAudio(mim
|
|||
// listen to t XR fragment changes
|
||||
xrf.addEventListener('t', (opts) => {
|
||||
let t = opts.frag.t
|
||||
xrf.audio.map( (a) => a.playXRF(t) )
|
||||
xrf.scene.traverse( (n) => n.audio && n.audio.playXRF ? n.audio.playXRF(t) : false )
|
||||
})
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ xrf.frag.src.type['image/png'] = function(url,opts){
|
|||
let restrictTo3DBoundingBox = mesh.geometry
|
||||
|
||||
let renderEquirect = (texture) => {
|
||||
console.dir(texture)
|
||||
texture.mapping = THREE.EquirectangularReflectionMapping
|
||||
texture.needsUpdate = true
|
||||
texture.wrapS = THREE.RepeatWrapping;
|
||||
|
|
|
|||
38
src/3rd/js/three/xrf/src/video.js
Normal file
38
src/3rd/js/three/xrf/src/video.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
|
||||
let loadVideo = (mimetype) => function(url,opts){
|
||||
let {mesh,src,camera} = opts
|
||||
let {urlObj,dir,file,hash,ext} = xrf.parseUrl(url)
|
||||
let frag = xrf.URI.parse( url )
|
||||
|
||||
let video = mesh.video = document.createElement('video')
|
||||
video.setAttribute("crossOrigin","anonymous")
|
||||
video.setAttribute("playsinline",'')
|
||||
video.addEventListener('loadedmetadata', function(){
|
||||
let texture = new THREE.VideoTexture( video );
|
||||
texture.colorSpace = THREE.SRGBColorSpace;
|
||||
let mat = new xrf.THREE.MeshBasicMaterial()
|
||||
mat.map = texture
|
||||
mesh.material = mat
|
||||
})
|
||||
video.src = url
|
||||
video.playXRF = (t) => {
|
||||
if( t.x == 0 ) video.pause()
|
||||
else{
|
||||
video.playbackRate = Math.abs( t.x ) // html5 video does not support reverseplay :/
|
||||
video.play()
|
||||
}
|
||||
if( t.y != undefined ) video.time = t.y
|
||||
}
|
||||
}
|
||||
|
||||
let videoMimeTypes = [
|
||||
'video/ogg',
|
||||
'video/mp4'
|
||||
]
|
||||
videoMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadVideo(mimetype) )
|
||||
|
||||
// listen to t XR fragment changes
|
||||
xrf.addEventListener('t', (opts) => {
|
||||
let t = opts.frag.t
|
||||
xrf.scene.traverse( (n) => n.video ? n.video.playXRF(t) : false )
|
||||
})
|
||||
Loading…
Add table
Reference in a new issue