forked from ppfun/pixelplanet
fix 3d
This commit is contained in:
parent
9abd199821
commit
dabda64c35
|
@ -122,10 +122,11 @@ class VoxelPainterControls {
|
||||||
storeViewInStateTime = Date.now();
|
storeViewInStateTime = Date.now();
|
||||||
prevTime = Date.now();
|
prevTime = Date.now();
|
||||||
offset = new Vector3();
|
offset = new Vector3();
|
||||||
|
direction = new Vector3();
|
||||||
velocity = new Vector3();
|
velocity = new Vector3();
|
||||||
vec = new Vector3();
|
vec = new Vector3();
|
||||||
// force full update next tick
|
// forcing next update
|
||||||
forceNextUpdate = true;
|
forceNextUpdate = false;
|
||||||
|
|
||||||
constructor(renderer, camera, target, domElement, store) {
|
constructor(renderer, camera, target, domElement, store) {
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
|
@ -178,12 +179,10 @@ class VoxelPainterControls {
|
||||||
|
|
||||||
rotateLeft(angle) {
|
rotateLeft(angle) {
|
||||||
this.sphericalDelta.theta -= angle;
|
this.sphericalDelta.theta -= angle;
|
||||||
this.forceNextUpdate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rotateUp(angle) {
|
rotateUp(angle) {
|
||||||
this.sphericalDelta.phi -= angle;
|
this.sphericalDelta.phi -= angle;
|
||||||
this.forceNextUpdate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// deltaX and deltaY are in pixels; right and down are positive
|
// deltaX and deltaY are in pixels; right and down are positive
|
||||||
|
@ -212,7 +211,6 @@ class VoxelPainterControls {
|
||||||
}
|
}
|
||||||
v.multiplyScalar(distance);
|
v.multiplyScalar(distance);
|
||||||
this.panOffset.add(v);
|
this.panOffset.add(v);
|
||||||
this.forceNextUpdate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -385,7 +383,6 @@ class VoxelPainterControls {
|
||||||
dollyDelta.set(0, (dollyEnd.y / dollyStart.y) ** zoomSpeed);
|
dollyDelta.set(0, (dollyEnd.y / dollyStart.y) ** zoomSpeed);
|
||||||
this.scale /= dollyDelta.y;
|
this.scale /= dollyDelta.y;
|
||||||
dollyStart.copy(dollyEnd);
|
dollyStart.copy(dollyEnd);
|
||||||
this.forceNextUpdate = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTouchMoveDollyPan(event) {
|
handleTouchMoveDollyPan(event) {
|
||||||
|
@ -617,20 +614,23 @@ class VoxelPainterControls {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.forceNextUpdate = false;
|
this.forceNextUpdate = false;
|
||||||
|
|
||||||
|
const delta = (time - this.prevTime) / 1000.0;
|
||||||
this.prevTime = time;
|
this.prevTime = time;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
camera,
|
camera,
|
||||||
|
target,
|
||||||
|
velocity,
|
||||||
|
direction,
|
||||||
|
offset,
|
||||||
|
vec,
|
||||||
|
spherical,
|
||||||
panOffset,
|
panOffset,
|
||||||
|
sphericalDelta,
|
||||||
} = this;
|
} = this;
|
||||||
|
|
||||||
if (isMoving) {
|
if (isMoving) {
|
||||||
const {
|
|
||||||
velocity,
|
|
||||||
vec,
|
|
||||||
} = this;
|
|
||||||
const delta = (time - this.prevTime) / 1000.0;
|
|
||||||
|
|
||||||
velocity.set(-moveU, moveW, moveV)
|
velocity.set(-moveU, moveW, moveV)
|
||||||
.normalize()
|
.normalize()
|
||||||
.multiplyScalar(1000.0 * delta);
|
.multiplyScalar(1000.0 * delta);
|
||||||
|
@ -645,13 +645,6 @@ class VoxelPainterControls {
|
||||||
panOffset.add(vec);
|
panOffset.add(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
|
||||||
target,
|
|
||||||
offset,
|
|
||||||
spherical,
|
|
||||||
sphericalDelta,
|
|
||||||
} = this;
|
|
||||||
|
|
||||||
offset.copy(camera.position).sub(target);
|
offset.copy(camera.position).sub(target);
|
||||||
|
|
||||||
// rotate offset to "y-axis-is-up" space
|
// rotate offset to "y-axis-is-up" space
|
||||||
|
@ -689,13 +682,23 @@ class VoxelPainterControls {
|
||||||
panOffset.set(0, 0, 0);
|
panOffset.set(0, 0, 0);
|
||||||
}
|
}
|
||||||
target.add(panOffset);
|
target.add(panOffset);
|
||||||
|
/*
|
||||||
|
if (scope.target.y < 10.0) {
|
||||||
|
scope.target.y = 10.0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// clamp to boundaries
|
// clamp to boundaries
|
||||||
const bound = state.canvas.canvasSize / 2;
|
const bound = state.canvas.canvasSize / 2;
|
||||||
target.clamp(
|
target.clamp({
|
||||||
{ x: -bound, y: 0, z: -bound },
|
x: -bound,
|
||||||
{ x: bound, y: THREE_CANVAS_HEIGHT, z: bound },
|
y: 0,
|
||||||
);
|
z: -bound,
|
||||||
|
}, {
|
||||||
|
x: bound,
|
||||||
|
y: THREE_CANVAS_HEIGHT,
|
||||||
|
z: bound,
|
||||||
|
});
|
||||||
|
|
||||||
offset.setFromSpherical(spherical);
|
offset.setFromSpherical(spherical);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user