better debugging on localhost/ip-adresses
This commit is contained in:
parent
47cf6031c8
commit
8c087c26c7
8 changed files with 40 additions and 18 deletions
|
|
@ -5,7 +5,13 @@ var xrf = {}
|
|||
|
||||
xrf.init = function(opts){
|
||||
opts = opts || {}
|
||||
|
||||
xrf.debug = document.location.hostname.match(/^(localhost|[0-9])/) ? true : false
|
||||
if( !xrf.debug ){
|
||||
console.log("add #debug=[0-9] to URL to see XR Fragment debuglog")
|
||||
xrf.debug = parseInt( ( document.location.hash.match(/debug=([0-9])/) || [0,'0'] )[1] )
|
||||
}
|
||||
|
||||
xrf.Parser.debug = xrf.debug
|
||||
xrf.detectCameraRig(opts)
|
||||
for ( let i in opts ) xrf[i] = opts[i]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ xrf.model = {}
|
|||
xrf.mixers = []
|
||||
|
||||
xrf.init = ((init) => function(opts){
|
||||
console.log("add #debug to URL to see XR Fragment debuglog")
|
||||
let scene = new opts.THREE.Group()
|
||||
opts.scene.add(scene)
|
||||
opts.scene = scene
|
||||
|
|
@ -62,9 +61,9 @@ xrf.parseModel = function(model,url){
|
|||
xrf.getLastModel = () => xrf.model.last
|
||||
|
||||
xrf.reset = () => {
|
||||
// remove mixers
|
||||
xrf.mixers.map( (m) => m.stop()) // stop animations *TODO* move to t.js
|
||||
xrf.mixers = []
|
||||
|
||||
// allow others to reset certain events
|
||||
xrf.emit('reset',{})
|
||||
|
||||
const disposeObject = (obj) => {
|
||||
if (obj.children.length > 0) obj.children.forEach((child) => disposeObject(child));
|
||||
|
|
@ -78,17 +77,11 @@ xrf.reset = () => {
|
|||
return true
|
||||
};
|
||||
let nodes = []
|
||||
xrf.scene.traverse( (n) => n.audio && (n.audio.playXRF({x:0})) && (n.audio.remove()) ) // *TODO* move to src/audio.js
|
||||
xrf.scene.traverse( (child) => child.isXRF && (nodes.push(child)) )
|
||||
nodes.map( disposeObject ) // leave non-XRF objects intact
|
||||
xrf.interactive = xrf.interactiveGroup( xrf.THREE, xrf.renderer, xrf.camera)
|
||||
xrf.add( xrf.interactive )
|
||||
xrf.layers = 0
|
||||
|
||||
// allow others to reset certain events
|
||||
xrf.emit('reset',{})
|
||||
// set the player to position 0,0,0
|
||||
xrf.camera.position.set(0,0,0)
|
||||
}
|
||||
|
||||
xrf.parseUrl = (url) => {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,14 @@ xrf.frag.pos = function(v, opts){
|
|||
camera.position.z = pos.z
|
||||
}
|
||||
|
||||
if( xrf.debug ) console.log(`#pos.js: setting camera to position ${pos.x},${pos.y},${pos.z}`)
|
||||
|
||||
xrf.frag.pos.last = pos // remember
|
||||
|
||||
camera.updateMatrixWorld()
|
||||
}
|
||||
|
||||
xrf.addEventListener('reset', (opts) => {
|
||||
// set the player to position 0,0,0
|
||||
xrf.camera.position.set(0,0,0)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
xrf.frag.rot = function(v, opts){
|
||||
let { frag, mesh, model, camera, scene, renderer, THREE} = opts
|
||||
console.log(" └ setting camera rotation to "+v.string)
|
||||
if( xrf.debug ) console.log("#rot.js: setting camera rotation to "+v.string)
|
||||
if( !model.isSRC ){
|
||||
camera.rotation.set(
|
||||
v.x * Math.PI / 180,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ xrf.frag.src = function(v, opts){
|
|||
opts.isPortal = xrf.frag.src.renderAsPortal(mesh)
|
||||
opts.isSRC = true
|
||||
|
||||
if(xrf.debug) console.log(`src.js: instancing ${opts.isLocal?'local':'remote'} object ${url}`)
|
||||
|
||||
if( opts.isLocal ){
|
||||
xrf.frag.src.localSRC(url,srcFrag,opts) // local
|
||||
}else xrf.frag.src.externalSRC(url,srcFrag,opts) // external file
|
||||
|
|
|
|||
|
|
@ -68,10 +68,17 @@ let loadAudio = (mimetype) => function(url,opts){
|
|||
// autoplay if user already requested play
|
||||
let autoplay = mesh.audio && mesh.audio.autoplay
|
||||
mesh.audio = sound
|
||||
if( autoplay ) xrf.hashbus.pub(mesh.audio.autoplay)
|
||||
if( autoplay ){
|
||||
xrf.hashbus.pub(mesh.audio.autoplay)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// stop playing audio when loading another scene
|
||||
xrf.addEventListener('reset', () => {
|
||||
xrf.scene.traverse( (n) => n.audio && (n.audio.playXRF({x:0})) && (n.audio.remove()) )
|
||||
})
|
||||
|
||||
let audioMimeTypes = [
|
||||
'audio/wav',
|
||||
'audio/mpeg',
|
||||
|
|
@ -87,7 +94,8 @@ xrf.addEventListener('t', (opts) => {
|
|||
let t = opts.frag.t
|
||||
xrf.scene.traverse( (n) => {
|
||||
if( !n.audio ) return
|
||||
if( !n.audio.playXRF ) n.audio.autoplay = t
|
||||
else n.audio.playXRF(t)
|
||||
if( !n.audio.playXRF ){
|
||||
n.audio.autoplay = t
|
||||
}else n.audio.playXRF(t)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ xrf.portalNonEuclidian = function(opts){
|
|||
mesh.portal.stencilObjects.children = stencilObjects
|
||||
|
||||
xrf.portalNonEuclidian.stencilRef += 1 // each portal has unique stencil id
|
||||
console.log(`enabling portal for object '${mesh.name}' (stencilRef:${mesh.portal.stencilRef})`)
|
||||
if( xrf.debug ) console.log(`enabling portal for object '${mesh.name}' (stencilRef:${mesh.portal.stencilRef})`)
|
||||
|
||||
return this
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ xrf.portalNonEuclidian = function(opts){
|
|||
let cam = xrf.camera.getCam ? xrf.camera.getCam() : camera
|
||||
cam.getWorldPosition(cameraPosition)
|
||||
cam.getWorldDirection(cameraDirection)
|
||||
if( cameraPosition.distanceTo(newPos) > 10.0 ) return // dont render far portals
|
||||
if( cameraPosition.distanceTo(newPos) > 15.0 ) return // dont render far portals
|
||||
|
||||
// init
|
||||
if( !mesh.portal.isLocal || mesh.portal.isLens ) stencilObject.visible = true
|
||||
|
|
|
|||
|
|
@ -158,9 +158,15 @@ xrf.addEventListener('dynamicKey', (opts) => {
|
|||
match.map( (w) => {
|
||||
w.nodes.map( (node) => {
|
||||
if( node.isCamera ){
|
||||
console.log("setting camera to "+node.name)
|
||||
console.log("switching camera to cam: "+node.name)
|
||||
xrf.model.camera = node
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// remove mixers and stop mixers when loading another scene
|
||||
xrf.addEventListener('reset', (opts) => {
|
||||
xrf.mixers.map( (m) => m.stop())
|
||||
xrf.mixers = []
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue