added environment map support for aframe

This commit is contained in:
Leon van Kammen 2024-07-10 10:02:07 +00:00
parent 5250e1d4cc
commit da5fa1d1f8
6 changed files with 15754 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/*
* v0.5.1 generated at Tue Jul 9 04:28:50 PM UTC 2024
* v0.5.1 generated at Wed Jul 10 10:00:28 AM UTC 2024
* https://xrfragment.org
* SPDX-License-Identifier: MPL-2.0
*/
@ -4105,6 +4105,33 @@ let videoMimeTypes = [
'video/mp4'
]
videoMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadVideo(mimetype) )
// poor man's way to move forward using hand gesture pinch
window.AFRAME.registerComponent('envmap', {
schema:{
src: {type: "string"}
},
init: function(){
const loader = new THREE.TextureLoader();
const onLoad = (texture) => {
texture.colorSpace = THREE.SRGBColorSpace;
texture.mapping = THREE.EquirectangularReflectionMapping;
xrf.scene.environment = texture
xrf.scene.texture = texture
}
new THREE.TextureLoader().load( this.data.src, onLoad, null, console.error );
xrf.addEventListener('navigateLoaded', () => {
xrf.scene.traverse( (n) => {
if( n.material && n.material.isMeshPhysicalMaterial){
console.dir(n.material)
n.material.envMap = xrf.scene.environment
}
})
})
},
})
window.AFRAME.registerComponent('href', {
schema: {
},

View File

@ -1,5 +1,5 @@
/*
* v0.5.1 generated at Tue Jul 9 04:28:50 PM UTC 2024
* v0.5.1 generated at Wed Jul 10 10:00:28 AM UTC 2024
* https://xrfragment.org
* SPDX-License-Identifier: MPL-2.0
*/
@ -4103,6 +4103,33 @@ let videoMimeTypes = [
'video/mp4'
]
videoMimeTypes.map( (mimetype) => xrf.frag.src.type[ mimetype ] = loadVideo(mimetype) )
// poor man's way to move forward using hand gesture pinch
window.AFRAME.registerComponent('envmap', {
schema:{
src: {type: "string"}
},
init: function(){
const loader = new THREE.TextureLoader();
const onLoad = (texture) => {
texture.colorSpace = THREE.SRGBColorSpace;
texture.mapping = THREE.EquirectangularReflectionMapping;
xrf.scene.environment = texture
xrf.scene.texture = texture
}
new THREE.TextureLoader().load( this.data.src, onLoad, null, console.error );
xrf.addEventListener('navigateLoaded', () => {
xrf.scene.traverse( (n) => {
if( n.material && n.material.isMeshPhysicalMaterial){
console.dir(n.material)
n.material.envMap = xrf.scene.environment
}
})
})
},
})
window.AFRAME.registerComponent('href', {
schema: {
},

15670
dist/xrfragment.module.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* v0.5.1 generated at Tue Jul 9 04:28:50 PM UTC 2024
* v0.5.1 generated at Wed Jul 10 10:00:28 AM UTC 2024
* https://xrfragment.org
* SPDX-License-Identifier: MPL-2.0
*/

View File

@ -1,5 +1,5 @@
/*
* v0.5.1 generated at Tue Jul 9 04:28:50 PM UTC 2024
* v0.5.1 generated at Wed Jul 10 10:00:28 AM UTC 2024
* https://xrfragment.org
* SPDX-License-Identifier: MPL-2.0
*/

View File

@ -0,0 +1,26 @@
// poor man's way to move forward using hand gesture pinch
window.AFRAME.registerComponent('envmap', {
schema:{
src: {type: "string"}
},
init: function(){
const loader = new THREE.TextureLoader();
const onLoad = (texture) => {
texture.colorSpace = THREE.SRGBColorSpace;
texture.mapping = THREE.EquirectangularReflectionMapping;
xrf.scene.environment = texture
xrf.scene.texture = texture
}
new THREE.TextureLoader().load( this.data.src, onLoad, null, console.error );
xrf.addEventListener('navigateLoaded', () => {
xrf.scene.traverse( (n) => {
if( n.material && n.material.isMeshPhysicalMaterial){
n.material.envMap = xrf.scene.environment
}
})
})
},
})