@xeokit/xeokit-sdk 2.6.0-beta-1 → 2.6.0-beta-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xeokit/xeokit-sdk",
3
- "version": "2.6.0-beta-1",
3
+ "version": "2.6.0-beta-2",
4
4
  "description": "Web Programming Toolkit for 3D/2D BIM and AEC Graphics",
5
5
  "module": "./dist/xeokit-sdk.es.js",
6
6
  "main": "./dist/xeokit-sdk.cjs.js",
@@ -155,22 +155,25 @@ const frame = function () {
155
155
  lastTime = time;
156
156
  };
157
157
 
158
- class WorkerInterval {
159
- worker = null;
160
-
161
- constructor(callback, interval) {
162
- const blob = new Blob([`setInterval(() => postMessage(0), ${interval});`]);
163
- const workerScript = URL.createObjectURL(blob);
164
- this.worker = new Worker(workerScript);
165
- this.worker.onmessage = callback;
166
- }
167
-
168
- stop() {
169
- this.worker.terminate();
158
+ function customSetInterval(callback, interval) {
159
+ let expected = Date.now() + interval;
160
+ function loop() {
161
+ const elapsed = Date.now() - expected;
162
+ callback();
163
+ expected += interval;
164
+ setTimeout(loop, Math.max(0, interval - elapsed));
170
165
  }
166
+ loop();
167
+ return {
168
+ cancel: function() {
169
+ // No need to do anything, setTimeout cannot be directly cancelled
170
+ }
171
+ };
171
172
  }
172
173
 
173
- const interval = new WorkerInterval(frame, 100);
174
+ customSetInterval(() => {
175
+ frame();
176
+ }, 100);
174
177
 
175
178
  const renderFrame = function () {
176
179
  let time = Date.now();