diff --git a/src/labels/label.js b/src/labels/label.js index 1a5f784b9..0c4ce4c8f 100644 --- a/src/labels/label.js +++ b/src/labels/label.js @@ -130,10 +130,11 @@ Label.add = function (label, bboxes) { }; Label.id = 0; -Label.id_prefix = ''; // id prefix scoped to worker thread +Label.id_prefix = 0; // id prefix scoped to worker thread +Label.id_multiplier = 0; // multiplier to keep label ids distinct across threads Label.nextLabelId = function () { - return Label.id_prefix + '/' + (Label.id++); + return Label.id_prefix + ((Label.id++) * Label.id_multiplier); }; Label.epsilon = 0.9999; // tolerance around collision boxes, prevent perfectly adjacent objects from colliding diff --git a/src/scene/scene_worker.js b/src/scene/scene_worker.js index d694a7302..26d5efdfa 100644 --- a/src/scene/scene_worker.js +++ b/src/scene/scene_worker.js @@ -39,6 +39,7 @@ const SceneWorker = Object.assign(self, { this.style_manager = new StyleManager(); this.importExternalScripts(external_scripts); Label.id_prefix = worker_id; + Label.id_multiplier = num_workers; return worker_id; },