trešdiena, 2022. gada 23. novembris

tweening problems with enable3d.io

THIS IS 3D BROWSER GAME CODE that looks almost perfect, it does load the game, load characters in coordinates from database . and it should USE TWEENING functionality for other players besides main player, updating it every second from database, but for some reason function is broken? - originally it works right here - ([https://github.com/.../master/src/examples/use-tweenjs.html](https://github.com/enable3d/enable3d-website/blob/master/src/examples/use-tweenjs.html?fbclid=IwAR2r7ljoNSvbQjQCtwxRG8JIm-2fym4U5UQJOmu9N2L8MZTBKMM_IVGvUvk))

In my code  console.log("notiek tweeens"); and  console.log("inside2", insidecoords);

both get logged and contain needed coordinates for the tween function to work, for some reason it does not affect selected object (this.man). #javascript #enable3d 

gamenew.php - https://pastebin.pl/view/36b614c1

the whole project on github - https://github.com/lv88h/JurmalaStreets3dPSEUDO6



MORALE AND TECHNICAL DIFFICULTIES EXPLAINED:

so these two "methods" I found that should do tweening, first one does not log onUpdate thus does not position.set , nor does tween

const coords = man.position.clone()

const tween = new TWEEN.Tween(coords)
.to({ x: vertibasx, y: vertibasy, z: vertibasz }, 1000)
.easing(TWEEN.Easing.Quadratic.Out)
.onUpdate(() => {
console.log("notiek tween");
man.position.set(coords.x, coords.y, coords.z)
if (man.body) man.body.needUpdate = true
})
TWEEN.update(1000 * 1000)

second one sets position but breaks the game, also logs inside of onUpdate, and if we comment out setting position, nothing tweens 
this.tweens.add({
targets: man.position.clone(),
duration: 100000,
delay: 100,
x: '+=400',
z: '+=400',
onUpdate: () => {
console.log("noteik tween");
this.man.position.set(vertibasx.x, vertibasy.y, vertibasz.z)
}
})

Nav komentāru:

Ierakstīt komentāru