Hi! I’m trying limit the camera movement in Y axes, my code:
MouseInput.prototype.pan = function(screenPoint) {
var fromWorldPoint = MouseInput.fromWorldPoint;
var toWorldPoint = MouseInput.toWorldPoint;
var worldDiff = MouseInput.worldDiff;
var lastPos = new pc.Vec3();
// For panning to work at any zoom level, we use screen point to world projection
// to work out how far we need to pan the pivotEntity in world space
var camera = this.entity.camera;
var distance = this.orbitCamera.distance;
var yPos = this.entity.getPosition().y;
var lastYpos = pc.math.clamp(y,0.6,3);
if(lastYpos > 0.6){
this.lastPos = this.entity.getPosition();
camera.screenToWorld(screenPoint.x, screenPoint.y, distance, fromWorldPoint);
camera.screenToWorld(this.lastPoint.x, this.lastPoint.y, distance, toWorldPoint);
worldDiff.sub2(toWorldPoint, fromWorldPoint);
this.orbitCamera.pivotPoint.add(worldDiff);
}else{
console.log("1 "+this.lastPos +" "+ this.entity.getPosition());
this.entity.translate(this.lastPos.x, this.lastPos.y + 0.5, this.lastPos.z);
console.log("2 "+this.lastPos +" "+ this.entity.getPosition());
}
The problem is, when i’m doing pan the Y is lower than the condition and never enter, i’m tried to set a position and don’t work, any idea?
Sorry for my english