svētdiena, 2022. gada 31. jūlijs

how does javascript fixes this issue of threejs or enable3d? (PSEUDO CODE)

class MainScene extends Scene3D {

async create() {

for (let step = 0; step < skins.length; step++) {

setInterval(greet, 8000);
            this.man = new ExtendedObject3D()
            this.man.name = 'man'
            this.man.rotateY(Math.PI + 0.1) // a hack
            this.man.add(man)
function greet() {
this.man.position.set(vertibasx, vertibasy, vertibasz)
                // CANNOT ACCESS THIS.MAN.POSITION
}

}
}
}

//this does not work too

class MainScene extends Scene3D {

async create() {

for (let step = 0; step < skins.length; step++) {
        this.man = new ExtendedObject3D()
        this.man.name = 'man'
        this.man.rotateY(Math.PI + 0.1) // a hack
        this.man.add(man)
    }
setInterval(greet, 8000);

function greet() {
this.man.position.set(vertibasx, vertibasy, vertibasz)
                // CANNOT ACCESS THIS.MAN.POSITION
}

}
}


HOW DOES JAVASCRIPT FIXES THIS. ISSUE?.


*****************************************
BIG FIX THAT STILL LEADS TO ERROR DUE THREEJS


class MainScene extends Scene3D {

async create() {

for (let step = 0; step < skins.length; step++) {
this.man = new ExtendedObject3D()
this.man.name = 'man'
this.man.rotateY(Math.PI + 0.1) // a hack
this.man.add(man)
let that = this.man;
}
setInterval(greet, 8000);

function greet() {
that.position.set(vertibasx, vertibasy, vertibasz)
                
//THIS LEADS TO WHITE SCREEN AS GREET HAPPENS, CONSOLE
                //LOGS HERE, BUT POSITION CANNOT BE SET EVERY 8 SECONDS
}

}
}

**********************************






for example ----



class MainScene extends Scene3D {

async create() {

for (let step = 0; step < skins.length; step++) {
        this.man = new ExtendedObject3D()
        this.man.name = 'man'
        this.man.rotateY(Math.PI + 0.1) // a hack
        this.man.add(man)
            window.localStorage.setItem('x', vertibasx);             window.localStorage.setItem('y', vertibasy);             window.localStorage.setItem('z', vertibasz);
        }


        console.log("try", window.localStorage.getItem('x'));

        ///leaves undefined "try"

setInterval(greet, 8000);

function greet() {
this.man.position.set(vertibasx, vertibasy, vertibasz)
                // CANNOT ACCESS THIS.MAN.POSITION
}

}
}





Nav komentāru:

Ierakstīt komentāru