simplified #pos.js and bugfixed envmapping.js
This commit is contained in:
parent
b7f3c91b7f
commit
0bd37a3b30
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue