simplified #pos.js and bugfixed envmapping.js

This commit is contained in:
Leon van Kammen 2024-10-14 11:54:14 +02:00
parent b7f3c91b7f
commit 0bd37a3b30
2 changed files with 3 additions and 5 deletions

View File

@ -12,6 +12,7 @@ xrf.addEventListener('navigateLoaded', (opts) => {
if (node.isMesh && node.material ) {
if (node.material.map && closestAncestorMaterialMap) {
// If the node has a material map, set the closest ancestor material map
node.material = node.material.clone() // dont affect objects which share same material
node.material.envMap = closestAncestorMaterialMap;
}
}

View File

@ -6,10 +6,7 @@ xrf.frag.pos = function(v, opts){
if( pos.x == undefined ){
let obj = scene.getObjectByName(v.string)
if( !obj ) return console.warn("#pos="+v.string+" not found")
let worldPos = new THREE.Vector3()
obj.getWorldPosition(worldPos)
camera.position.copy(worldPos)
obj.attach(camera) // instead of add() [keeps camera animations intact]
obj.add(camera)
camera.position.set(0,0,0)
let c = camera.rotation
c.set( c.x, obj.rotation.y, c.z )