forked from ppfun/pixelplanet
fix flashing on refresh
fix 3D canvas showing as 2D on refresh allow access to the 2D representation by pressing P when viewing 3D canvas
This commit is contained in:
parent
ba20d6fcf3
commit
1fce6cccc3
|
@ -272,9 +272,9 @@ export default function canvasReducer(
|
||||||
size: canvasSize,
|
size: canvasSize,
|
||||||
sd: canvasStartDate,
|
sd: canvasStartDate,
|
||||||
ident: canvasIdent,
|
ident: canvasIdent,
|
||||||
v: is3D,
|
|
||||||
colors,
|
colors,
|
||||||
} = canvas;
|
} = canvas;
|
||||||
|
const is3D = !!canvas.v;
|
||||||
// get previous view, scale and viewscale if possible
|
// get previous view, scale and viewscale if possible
|
||||||
let viewscale = DEFAULT_SCALE;
|
let viewscale = DEFAULT_SCALE;
|
||||||
let scale = DEFAULT_SCALE;
|
let scale = DEFAULT_SCALE;
|
||||||
|
@ -336,7 +336,7 @@ export default function canvasReducer(
|
||||||
}
|
}
|
||||||
const canvas = canvases[canvasId];
|
const canvas = canvases[canvasId];
|
||||||
const clrIgnore = canvas.cli || 0;
|
const clrIgnore = canvas.cli || 0;
|
||||||
const is3D = !!canvases.v;
|
const is3D = !!canvas.v;
|
||||||
const {
|
const {
|
||||||
size: canvasSize,
|
size: canvasSize,
|
||||||
sd: canvasStartDate,
|
sd: canvasStartDate,
|
||||||
|
|
|
@ -57,6 +57,15 @@ export default (store) => (next) => (action) => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'TOGGLE_HIDDEN_CANVASES': {
|
||||||
|
const renderer = getRenderer();
|
||||||
|
const { is3D } = state.canvas;
|
||||||
|
if (is3D) {
|
||||||
|
initRenderer(store, !renderer.is3D);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'SET_HISTORICAL_TIME': {
|
case 'SET_HISTORICAL_TIME': {
|
||||||
const {
|
const {
|
||||||
historicalDate,
|
historicalDate,
|
||||||
|
|
|
@ -34,25 +34,25 @@ const SCALE_THREASHOLD = Math.min(
|
||||||
|
|
||||||
|
|
||||||
class Renderer {
|
class Renderer {
|
||||||
is3D: false;
|
is3D = false;
|
||||||
//
|
//
|
||||||
canvasId: number = null;
|
canvasId = null;
|
||||||
chunkLoader: Object = null;
|
chunkLoader = null;
|
||||||
//--
|
//--
|
||||||
centerChunk;
|
centerChunk;
|
||||||
tiledScale: number;
|
tiledScale;
|
||||||
tiledZoom: number;
|
tiledZoom;
|
||||||
hover: boolean;
|
hover;
|
||||||
//--
|
//--
|
||||||
viewport: HTMLCanvasElement = null;
|
viewport = null;
|
||||||
store;
|
store;
|
||||||
//--
|
//--
|
||||||
forceNextRender: boolean;
|
forceNextRender;
|
||||||
forceNextSubrender: boolean;
|
forceNextSubrender;
|
||||||
canvas: HTMLCanvasElement;
|
canvas;
|
||||||
lastFetch: number;
|
lastFetch;
|
||||||
//--
|
//--
|
||||||
oldHistoricalTime: string;
|
oldHistoricalTime;
|
||||||
|
|
||||||
constructor(store) {
|
constructor(store) {
|
||||||
this.centerChunk = [null, null];
|
this.centerChunk = [null, null];
|
||||||
|
@ -159,7 +159,7 @@ class Renderer {
|
||||||
this.updateScale(this.store.getState());
|
this.updateScale(this.store.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
getColorIndexOfPixel(cx, cy, historical: boolean = false) {
|
getColorIndexOfPixel(cx, cy, historical = false) {
|
||||||
if (historical) {
|
if (historical) {
|
||||||
const state = this.store.getState();
|
const state = this.store.getState();
|
||||||
const {
|
const {
|
||||||
|
@ -232,9 +232,9 @@ class Renderer {
|
||||||
|
|
||||||
|
|
||||||
renderPixel(
|
renderPixel(
|
||||||
i: number,
|
i,
|
||||||
j: number,
|
j,
|
||||||
offset: number,
|
offset,
|
||||||
color,
|
color,
|
||||||
notify,
|
notify,
|
||||||
) {
|
) {
|
||||||
|
@ -273,9 +273,9 @@ class Renderer {
|
||||||
|
|
||||||
|
|
||||||
isChunkInView(
|
isChunkInView(
|
||||||
cz: number,
|
cz,
|
||||||
cx: number,
|
cx,
|
||||||
cy: number,
|
cy,
|
||||||
) {
|
) {
|
||||||
if (cz !== this.tiledZoom) {
|
if (cz !== this.tiledZoom) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* 3D Renderer for VoxelCanvas
|
* 3D Renderer for VoxelCanvas
|
||||||
*
|
*
|
||||||
* @flow
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
|
@ -31,27 +30,27 @@ class Renderer {
|
||||||
//--
|
//--
|
||||||
store;
|
store;
|
||||||
//--
|
//--
|
||||||
scene: Object;
|
scene;
|
||||||
camera: Object;
|
camera;
|
||||||
rollOverMesh: Object;
|
rollOverMesh;
|
||||||
objects: Array<Object>;
|
objects;
|
||||||
loadedChunks: Array<Object>;
|
loadedChunks;
|
||||||
plane: Object;
|
plane;
|
||||||
oobGeometry: Object;
|
oobGeometry;
|
||||||
oobMaterial: Object;
|
oobMaterial;
|
||||||
//--
|
//--
|
||||||
controls: Object;
|
controls;
|
||||||
threeRenderer: Object;
|
threeRenderer;
|
||||||
// temp variables for mouse events
|
// temp variables for mouse events
|
||||||
mouse;
|
mouse;
|
||||||
mouseMoveStart;
|
mouseMoveStart;
|
||||||
raycaster;
|
raycaster;
|
||||||
pressTime: number;
|
pressTime;
|
||||||
pressCdTime: number;
|
pressCdTime;
|
||||||
multitap: number;
|
multitap;
|
||||||
//--
|
//--
|
||||||
chunkLoader: ChunkLoader = null;
|
chunkLoader = null;
|
||||||
forceNextRender: boolean = false;
|
forceNextRender = false;
|
||||||
|
|
||||||
constructor(store) {
|
constructor(store) {
|
||||||
this.store = store;
|
this.store = store;
|
||||||
|
@ -274,10 +273,10 @@ class Renderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderPixel(
|
renderPixel(
|
||||||
i: number,
|
i,
|
||||||
j: number,
|
j,
|
||||||
offset: number,
|
offset,
|
||||||
color: number,
|
color,
|
||||||
) {
|
) {
|
||||||
const { chunkLoader } = this;
|
const { chunkLoader } = this;
|
||||||
if (chunkLoader) {
|
if (chunkLoader) {
|
||||||
|
@ -469,7 +468,7 @@ class Renderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
placeVoxel(x: number, y: number, z: number, color: number = null) {
|
placeVoxel(x, y, z, color = null) {
|
||||||
const {
|
const {
|
||||||
store,
|
store,
|
||||||
} = this;
|
} = this;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user