Skip to content

Commit 6e4ef53

Browse files
v9.4: Apply culling
Apply culling feature from v8 to hide balls not in viewport. Culling is important to run with a large number of balls. But CSS animation will re-start immediately when it becomes visible => out of sync animation when scrolling, like screenshot 'v9.4-1K balls'
1 parent 3531076 commit 6e4ef53

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

index_3d_css.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
'use strict';
7474
window.onload = function () {
7575
// Adjustment parameters (target: 60FPS)
76-
const CULL_ENABLED = false;
76+
const CULL_ENABLED = true;
7777
const MOVERS_COUNT = 1000;
7878
var updateFunc = update_v8; // to select different algorithm
7979
//----------------------------------------------------------------------------------------------
@@ -100,6 +100,7 @@
100100
(function init() {
101101
initButtonHandler();
102102
generateBalls();
103+
if (CULL_ENABLED) rAF(updateFunc);
103104
})();
104105
//----------------------------------------------------------------------------------------------
105106
function initButtonHandler () {
@@ -152,8 +153,6 @@
152153
function hide (m) { hidden.appendChild(movers[m]); }
153154
//----------------------------------------------------------------------------------------------
154155
function update_v8(timestamp) {
155-
if (!CULL_ENABLED) return;
156-
157156
var scrollY = window.scrollY;
158157
var minVisibleM = Math.floor(getMinVisibleY(scrollY) / OFFSET);
159158
var maxVisibleM = Math.ceil(getMaxVisibleY(scrollY) / OFFSET);
1 MB
Loading

0 commit comments

Comments
 (0)