From 0bd37a3b306ba77038c58a2667dc310ddfbdff92 Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Mon, 14 Oct 2024 11:54:14 +0200 Subject: [PATCH] simplified #pos.js and bugfixed envmapping.js --- src/3rd/js/three/xrf/dynamic/envmapping.js | 3 ++- src/3rd/js/three/xrf/pos.js | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/3rd/js/three/xrf/dynamic/envmapping.js b/src/3rd/js/three/xrf/dynamic/envmapping.js index a006cf2..50b0abe 100644 --- a/src/3rd/js/three/xrf/dynamic/envmapping.js +++ b/src/3rd/js/three/xrf/dynamic/envmapping.js @@ -9,9 +9,10 @@ xrf.addEventListener('navigateLoaded', (opts) => { // Recursive function to traverse the graph function traverseAndSetEnvMap(node, closestAncestorMaterialMap = null) { // Check if the current node has a material - if (node.isMesh && node.material) { + 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; } } diff --git a/src/3rd/js/three/xrf/pos.js b/src/3rd/js/three/xrf/pos.js index 56d17e0..0259ca5 100644 --- a/src/3rd/js/three/xrf/pos.js +++ b/src/3rd/js/three/xrf/pos.js @@ -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 )