Adam_A
December 6, 2023, 9:49pm
1
Hi, i built an app using the following code:
var northView = function() {
var cam = scene.activeCamera;
var targetEndPos = new BABYLON.Vector3(-200, 65, 35);
var camEndPos = new BABYLON.Vector3(-200, 205, 0);
var speed = 145;
var ease = new BABYLON.CircleEase();
ease.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT);
BABYLON.Animation.CreateAndStartAnimation(‘pos’, cam, ‘position’ , speed, 220, cam.position, camEndPos, 0, ease);
scene.activeCamera.useAutoRotationBehavior = false;
};
Out of the blue, ‘position’ is now inactive, only ‘target’ works, why is that?
sebavan
December 6, 2023, 10:04pm
2
A repro would be great but I guess your camera type does not have a property “position”
Adam_A
December 6, 2023, 10:24pm
3
Thanks, the app worked 100% up until 2 days ago - as if the platform changed.
Now the code is not working. But - it does work if i use ‘target’ …
BABYLON.Animation.CreateAndStartAnimation(‘tar’, cam, ‘target’, speed, 100, cam.target, targetEndPos, 0, ease);
See below:
//HTML MENU
var buttonbox = document.createElement(‘div’);
buttonbox.id = “buttonbox”;
buttonbox.style.position = “absolute”;
buttonbox.style.top = “135px”;
buttonbox.style.left = “90%”;
buttonbox.style.border = “none”;
buttonbox.style.padding = “1pt”;
buttonbox.style.paddingRight = “1pt”;
buttonbox.style.width = “140px”;
buttonbox.style.display = “block”;
document.body.appendChild(buttonbox);
var tTag = document.createElement('div');
tTag.id = "viewsTitle";
tTag.textContent = "Select a View:";
tTag.style.textAlign = "left";
tTag.style.border = "none";
tTag.style.marginLeft = "1.5pt";
tTag.style.marginTop = "3pt";
tTag.style.marginBottom = "2pt";
tTag.style.backgroundColor = "#333333";
tTag.style.width = "120px";
tTag.style.fontSize = "0.6em";
tTag.style.color = "white";
buttonbox.appendChild(tTag);
var b3 = document.createElement('button');
b3.id = "viewsButton";
b3.textContent = "N";
b3.style.display = "block";
b3.style.width = "100%";
b3.style.fontSize = "0.7em";
buttonbox.appendChild(b3);
b3.onclick = function() {
northView();
}
//NORTH VIEW ACTION
var northView = function() {
var cam = scene.activeCamera;
var targetEndPos = new BABYLON.Vector3(-200, 65, 35);
var camEndPos = new BABYLON.Vector3(-200, 205, 0);
var speed = 145;
var ease = new BABYLON.CircleEase();
ease.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT);
BABYLON.Animation.CreateAndStartAnimation(‘pos’, cam, ‘radius’, speed, 220, cam, camEndPos, 0, ease);
//BABYLON.Animation.CreateAndStartAnimation (‘tar’, cam, ‘target’, speed, 100, cam.target, targetEndPos, 0, ease);
scene.activeCamera.useAutoRotationBehavior = false;
};
sebavan
December 7, 2023, 12:13am
4
@Evgeni_Popov might it be related to your anim changes ?
cause if it is the case the fix would be deployed tomorrow @Adam_A
sebavan
December 7, 2023, 12:14am
5
Adam_A
December 7, 2023, 1:37am
6
I actually found a solution:
BABYLON.ArcRotateCamera.prototype.spinTo = function (whichprop, targetval, speed) {
var ease = new BABYLON.CubicEase();
ease.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT);
BABYLON.Animation.CreateAndStartAnimation(‘’,
this,
whichprop,
speed,
120,
this[whichprop],
targetval,
BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT,
ease);
};
var northView = function() {
//camera.spinTo("target", new BABYLON.Vector3(0,0,0), 60);
camera.spinTo("alpha", 8, 120 );
camera.spinTo("beta", 2, 120 );
camera.spinTo("radius", -60, 120);
camera.spinTo("target", new BABYLON.Vector3(0,3,0), 120);
scene.activeCamera.useAutoRotationBehavior = false;
};
1 Like