@kitware/vtk.js 21.1.4 → 21.2.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/Common/Transform/LandmarkTransform.d.ts +1 -1
- package/Filters/General/ImageCropFilter.js +3 -4
- package/Filters/Sources/Arrow2DSource.d.ts +14 -13
- package/Filters/Sources/ArrowSource.d.ts +9 -8
- package/Filters/Sources/CircleSource.d.ts +15 -14
- package/Filters/Sources/ConeSource.d.ts +18 -17
- package/Filters/Sources/CubeSource.d.ts +19 -19
- package/Filters/Sources/Cursor3D.d.ts +19 -16
- package/Filters/Sources/CylinderSource.d.ts +15 -14
- package/Filters/Sources/LineSource.d.ts +1 -1
- package/Filters/Sources/PlaneSource.d.ts +29 -28
- package/Filters/Sources/PointSource.d.ts +9 -8
- package/Filters/Sources/SphereSource.d.ts +9 -8
- package/IO/Geometry/STLReader.js +2 -2
- package/Rendering/Core/AbstractMapper.js +1 -0
- package/Rendering/Core/Light.d.ts +277 -234
- package/Rendering/Core/Property.d.ts +43 -43
- package/Rendering/Core/Property2D.d.ts +21 -5
- package/Rendering/Core/RenderWindowInteractor.js +7 -7
- package/Rendering/Core/Volume.d.ts +9 -0
- package/Rendering/OpenGL/ImageMapper.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper.js +5 -17
- package/Rendering/OpenGL/RenderWindow.js +190 -106
- package/Rendering/OpenGL/ShaderProgram.js +0 -12
- package/_virtual/rollup-plugin-web-worker-loader__helper__browser__createInlineWorkerFactory.js +17 -0
- package/_virtual/rollup-plugin-web-worker-loader__helper__funcToSource.js +18 -0
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +698 -2
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +274 -2
- package/interfaces.d.ts +66 -24
- package/package.json +2 -2
- package/types.d.ts +4 -1
- package/_virtual/rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +0 -31
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
4
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
5
|
+
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
3
6
|
import macro from '../../macros.js';
|
|
4
7
|
import { registerViewConstructor } from '../Core/RenderWindow.js';
|
|
5
8
|
import vtkForwardPass from './ForwardPass.js';
|
|
9
|
+
import vtkHardwareSelector from './HardwareSelector.js';
|
|
10
|
+
import vtkShaderCache from './ShaderCache.js';
|
|
11
|
+
import vtkTextureUnitManager from './TextureUnitManager.js';
|
|
6
12
|
import vtkViewNodeFactory from './ViewNodeFactory.js';
|
|
7
13
|
import vtkRenderPass from '../SceneGraph/RenderPass.js';
|
|
8
|
-
import vtkShaderCache from './ShaderCache.js';
|
|
9
14
|
import vtkRenderWindowViewNode from '../SceneGraph/RenderWindowViewNode.js';
|
|
10
|
-
import vtkTextureUnitManager from './TextureUnitManager.js';
|
|
11
|
-
import vtkHardwareSelector from './HardwareSelector.js';
|
|
12
|
-
import { VtkDataTypes } from '../../Common/Core/DataArray/Constants.js';
|
|
13
15
|
|
|
14
16
|
var vtkDebugMacro = macro.vtkDebugMacro,
|
|
15
17
|
vtkErrorMacro = macro.vtkErrorMacro;
|
|
16
|
-
var IS_CHROME = navigator.userAgent.indexOf('Chrome') !== -1;
|
|
17
18
|
var SCREENSHOT_PLACEHOLDER = {
|
|
18
19
|
position: 'absolute',
|
|
19
20
|
top: 0,
|
|
@@ -211,7 +212,12 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
211
212
|
depth: true,
|
|
212
213
|
alpha: true
|
|
213
214
|
};
|
|
214
|
-
var result = null;
|
|
215
|
+
var result = null; // Do we have webxr support
|
|
216
|
+
|
|
217
|
+
if (navigator.xr !== undefined && navigator.xr.isSessionSupported('immersive-vr')) {
|
|
218
|
+
publicAPI.invokeHaveVRDisplay();
|
|
219
|
+
}
|
|
220
|
+
|
|
215
221
|
var webgl2Supported = typeof WebGL2RenderingContext !== 'undefined';
|
|
216
222
|
model.webgl2 = false;
|
|
217
223
|
|
|
@@ -227,22 +233,6 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
227
233
|
if (!result) {
|
|
228
234
|
vtkDebugMacro('using webgl1');
|
|
229
235
|
result = model.canvas.getContext('webgl', options) || model.canvas.getContext('experimental-webgl', options);
|
|
230
|
-
} // Do we have webvr support
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (navigator.getVRDisplays) {
|
|
234
|
-
navigator.getVRDisplays().then(function (displays) {
|
|
235
|
-
if (displays.length > 0) {
|
|
236
|
-
// take the first display for now
|
|
237
|
-
model.vrDisplay = displays[0]; // set the clipping ranges
|
|
238
|
-
|
|
239
|
-
model.vrDisplay.depthNear = 0.01; // meters
|
|
240
|
-
|
|
241
|
-
model.vrDisplay.depthFar = 100.0; // meters
|
|
242
|
-
|
|
243
|
-
publicAPI.invokeHaveVRDisplay();
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
236
|
} // prevent default context lost handler
|
|
247
237
|
|
|
248
238
|
|
|
@@ -251,84 +241,180 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
251
241
|
}, false);
|
|
252
242
|
model.canvas.addEventListener('webglcontextrestored', publicAPI.restoreContext, false);
|
|
253
243
|
return result;
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
publicAPI.startVR = function () {
|
|
257
|
-
model.oldCanvasSize = model.size.slice();
|
|
244
|
+
}; // Request an XR session on the user device with WebXR,
|
|
245
|
+
// typically in response to a user request such as a button press
|
|
258
246
|
|
|
259
|
-
if (model.vrDisplay.capabilities.canPresent) {
|
|
260
|
-
model.vrDisplay.requestPresent([{
|
|
261
|
-
source: model.canvas
|
|
262
|
-
}]).then(function () {
|
|
263
|
-
if (model.el && model.vrDisplay.capabilities.hasExternalDisplay && model.hideCanvasInVR) {
|
|
264
|
-
model.el.style.display = 'none';
|
|
265
|
-
}
|
|
266
247
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
var height = Math.floor(Math.max(leftEye.renderHeight, rightEye.renderHeight));
|
|
272
|
-
publicAPI.setSize(width, height);
|
|
273
|
-
} else {
|
|
274
|
-
publicAPI.setSize(model.vrResolution);
|
|
275
|
-
}
|
|
248
|
+
publicAPI.startXR = function () {
|
|
249
|
+
if (navigator.xr === undefined) {
|
|
250
|
+
throw new Error('WebXR is not available');
|
|
251
|
+
}
|
|
276
252
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
model.renderable.getInteractor().switchToVRAnimation();
|
|
281
|
-
model.vrSceneFrame = model.vrDisplay.requestAnimationFrame(publicAPI.vrRender); // If Broswer is chrome we need to request animation again to canvas update
|
|
253
|
+
if (!navigator.xr.isSessionSupported('immersive-vr')) {
|
|
254
|
+
throw new Error('VR display is not available');
|
|
255
|
+
}
|
|
282
256
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
}).catch(function () {
|
|
287
|
-
console.error('failed to requestPresent');
|
|
257
|
+
if (model.xrSession === null) {
|
|
258
|
+
navigator.xr.requestSession('immersive-vr').then(publicAPI.enterXR, function () {
|
|
259
|
+
throw new Error('Failed to create VR session!');
|
|
288
260
|
});
|
|
289
261
|
} else {
|
|
290
|
-
|
|
262
|
+
throw new Error('VR Session already exists!');
|
|
291
263
|
}
|
|
292
|
-
};
|
|
264
|
+
}; // When an XR session is available, set up the XRWebGLLayer
|
|
265
|
+
// and request the first animation frame for the device
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
publicAPI.enterXR = /*#__PURE__*/function () {
|
|
269
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(xrSession) {
|
|
270
|
+
var gl, glLayer;
|
|
271
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
272
|
+
while (1) {
|
|
273
|
+
switch (_context.prev = _context.next) {
|
|
274
|
+
case 0:
|
|
275
|
+
model.xrSession = xrSession;
|
|
276
|
+
model.oldCanvasSize = model.size.slice();
|
|
277
|
+
|
|
278
|
+
if (!(model.xrSession !== null)) {
|
|
279
|
+
_context.next = 14;
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
gl = publicAPI.get3DContext();
|
|
284
|
+
_context.next = 6;
|
|
285
|
+
return gl.makeXRCompatible();
|
|
286
|
+
|
|
287
|
+
case 6:
|
|
288
|
+
glLayer = new global.XRWebGLLayer(model.xrSession, gl);
|
|
289
|
+
publicAPI.setSize(glLayer.framebufferWidth, glLayer.framebufferHeight);
|
|
290
|
+
model.xrSession.updateRenderState({
|
|
291
|
+
baseLayer: glLayer
|
|
292
|
+
});
|
|
293
|
+
model.xrSession.requestReferenceSpace('local').then(function (refSpace) {
|
|
294
|
+
model.xrReferenceSpace = refSpace;
|
|
295
|
+
});
|
|
296
|
+
model.renderable.getInteractor().switchToXRAnimation();
|
|
297
|
+
model.xrSceneFrame = model.xrSession.requestAnimationFrame(publicAPI.xrRender);
|
|
298
|
+
_context.next = 15;
|
|
299
|
+
break;
|
|
293
300
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
model.vrDisplay.exitPresent();
|
|
297
|
-
model.vrDisplay.cancelAnimationFrame(model.vrSceneFrame);
|
|
298
|
-
publicAPI.setSize.apply(publicAPI, _toConsumableArray(model.oldCanvasSize));
|
|
301
|
+
case 14:
|
|
302
|
+
throw new Error('Failed to enter VR with a null xrSession.');
|
|
299
303
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
304
|
+
case 15:
|
|
305
|
+
case "end":
|
|
306
|
+
return _context.stop();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}, _callee);
|
|
310
|
+
}));
|
|
303
311
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
312
|
+
return function (_x) {
|
|
313
|
+
return _ref.apply(this, arguments);
|
|
314
|
+
};
|
|
315
|
+
}();
|
|
316
|
+
|
|
317
|
+
publicAPI.stopXR = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
318
|
+
var gl, ren;
|
|
319
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
320
|
+
while (1) {
|
|
321
|
+
switch (_context2.prev = _context2.next) {
|
|
322
|
+
case 0:
|
|
323
|
+
if (!(navigator.xr === undefined)) {
|
|
324
|
+
_context2.next = 2;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return _context2.abrupt("return");
|
|
329
|
+
|
|
330
|
+
case 2:
|
|
331
|
+
if (!(model.xrSession !== null)) {
|
|
332
|
+
_context2.next = 10;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
model.xrSession.cancelAnimationFrame(model.xrSceneFrame);
|
|
337
|
+
model.renderable.getInteractor().returnFromXRAnimation();
|
|
338
|
+
gl = publicAPI.get3DContext();
|
|
339
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
340
|
+
_context2.next = 9;
|
|
341
|
+
return model.xrSession.end().catch(function (error) {
|
|
342
|
+
if (!(error instanceof DOMException)) {
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
});
|
|
309
346
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (!model.vrDisplay.isPresenting) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
347
|
+
case 9:
|
|
348
|
+
model.xrSession = null;
|
|
315
349
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
};
|
|
350
|
+
case 10:
|
|
351
|
+
publicAPI.setSize.apply(publicAPI, _toConsumableArray(model.oldCanvasSize)); // Reset to default canvas
|
|
352
|
+
|
|
353
|
+
ren = model.renderable.getRenderers()[0];
|
|
354
|
+
ren.getActiveCamera().setProjectionMatrix(null);
|
|
355
|
+
ren.resetCamera();
|
|
356
|
+
ren.setViewport(0.0, 0, 1.0, 1.0);
|
|
357
|
+
publicAPI.traverseAllPasses();
|
|
358
|
+
|
|
359
|
+
case 16:
|
|
360
|
+
case "end":
|
|
361
|
+
return _context2.stop();
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}, _callee2);
|
|
365
|
+
}));
|
|
366
|
+
|
|
367
|
+
publicAPI.xrRender = /*#__PURE__*/function () {
|
|
368
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(t, frame) {
|
|
369
|
+
var xrSession, xrPose, gl, glLayer, ren;
|
|
370
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
371
|
+
while (1) {
|
|
372
|
+
switch (_context3.prev = _context3.next) {
|
|
373
|
+
case 0:
|
|
374
|
+
xrSession = frame.session;
|
|
375
|
+
model.xrSceneFrame = model.xrSession.requestAnimationFrame(publicAPI.xrRender);
|
|
376
|
+
xrPose = frame.getViewerPose(model.xrReferenceSpace);
|
|
377
|
+
|
|
378
|
+
if (xrPose) {
|
|
379
|
+
gl = publicAPI.get3DContext();
|
|
380
|
+
glLayer = xrSession.renderState.baseLayer;
|
|
381
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, glLayer.framebuffer);
|
|
382
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
383
|
+
gl.clear(gl.DEPTH_BUFFER_BIT); // get the first renderer
|
|
384
|
+
|
|
385
|
+
ren = model.renderable.getRenderers()[0]; // Do a render pass for each eye
|
|
386
|
+
|
|
387
|
+
xrPose.views.forEach(function (view) {
|
|
388
|
+
var viewport = glLayer.getViewport(view);
|
|
389
|
+
gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
|
|
390
|
+
|
|
391
|
+
if (view.eye === 'left') {
|
|
392
|
+
ren.setViewport(0, 0, 0.5, 1.0);
|
|
393
|
+
} else if (view.eye === 'right') {
|
|
394
|
+
ren.setViewport(0.5, 0, 1.0, 1.0);
|
|
395
|
+
} else {
|
|
396
|
+
// No handling for non-eye viewport
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
ren.getActiveCamera().computeViewParametersFromPhysicalMatrix(view.transform.inverse.matrix);
|
|
401
|
+
ren.getActiveCamera().setProjectionMatrix(view.projectionMatrix);
|
|
402
|
+
publicAPI.traverseAllPasses();
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
case 4:
|
|
407
|
+
case "end":
|
|
408
|
+
return _context3.stop();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}, _callee3);
|
|
412
|
+
}));
|
|
413
|
+
|
|
414
|
+
return function (_x2, _x3) {
|
|
415
|
+
return _ref3.apply(this, arguments);
|
|
416
|
+
};
|
|
417
|
+
}();
|
|
332
418
|
|
|
333
419
|
publicAPI.restoreContext = function () {
|
|
334
420
|
var rp = vtkRenderPass.newInstance();
|
|
@@ -486,13 +572,13 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
486
572
|
publicAPI.captureNextImage = function () {
|
|
487
573
|
var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'image/png';
|
|
488
574
|
|
|
489
|
-
var
|
|
490
|
-
|
|
491
|
-
resetCamera =
|
|
492
|
-
|
|
493
|
-
size =
|
|
494
|
-
|
|
495
|
-
scale =
|
|
575
|
+
var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
576
|
+
_ref4$resetCamera = _ref4.resetCamera,
|
|
577
|
+
resetCamera = _ref4$resetCamera === void 0 ? false : _ref4$resetCamera,
|
|
578
|
+
_ref4$size = _ref4.size,
|
|
579
|
+
size = _ref4$size === void 0 ? null : _ref4$size,
|
|
580
|
+
_ref4$scale = _ref4.scale,
|
|
581
|
+
scale = _ref4$scale === void 0 ? 1 : _ref4$scale;
|
|
496
582
|
|
|
497
583
|
if (model.deleted) {
|
|
498
584
|
return null;
|
|
@@ -519,9 +605,9 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
519
605
|
publicAPI.modified(); // restore the saved camera parameters, if applicable
|
|
520
606
|
|
|
521
607
|
if (model._screenshot.cameras) {
|
|
522
|
-
model._screenshot.cameras.forEach(function (
|
|
523
|
-
var restoreParamsFn =
|
|
524
|
-
arg =
|
|
608
|
+
model._screenshot.cameras.forEach(function (_ref5) {
|
|
609
|
+
var restoreParamsFn = _ref5.restoreParamsFn,
|
|
610
|
+
arg = _ref5.arg;
|
|
525
611
|
return restoreParamsFn(arg);
|
|
526
612
|
});
|
|
527
613
|
} // Trigger a render at the original size
|
|
@@ -568,8 +654,8 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
|
|
|
568
654
|
// the params from all active cameras, in case there happen to be
|
|
569
655
|
// linked cameras among the renderers.
|
|
570
656
|
|
|
571
|
-
model._screenshot.cameras.forEach(function (
|
|
572
|
-
var resetCameraFn =
|
|
657
|
+
model._screenshot.cameras.forEach(function (_ref6) {
|
|
658
|
+
var resetCameraFn = _ref6.resetCameraFn;
|
|
573
659
|
return resetCameraFn();
|
|
574
660
|
});
|
|
575
661
|
} // Trigger a render at the custom size
|
|
@@ -688,11 +774,9 @@ var DEFAULT_VALUES = {
|
|
|
688
774
|
webgl2: false,
|
|
689
775
|
defaultToWebgl2: true,
|
|
690
776
|
// attempt webgl2 on by default
|
|
691
|
-
vrResolution: [2160, 1200],
|
|
692
|
-
queryVRSize: false,
|
|
693
|
-
hideCanvasInVR: true,
|
|
694
777
|
activeFramebuffer: null,
|
|
695
|
-
|
|
778
|
+
xrSession: null,
|
|
779
|
+
xrReferenceSpace: null,
|
|
696
780
|
imageFormat: 'image/png',
|
|
697
781
|
useOffScreen: false,
|
|
698
782
|
useBackgroundImage: false
|
|
@@ -736,12 +820,12 @@ function extend(publicAPI, model) {
|
|
|
736
820
|
macro.event(publicAPI, model, 'haveVRDisplay'); // Build VTK API
|
|
737
821
|
|
|
738
822
|
macro.get(publicAPI, model, ['shaderCache', 'textureUnitManager', 'webgl2', 'vrDisplay', 'useBackgroundImage']);
|
|
739
|
-
macro.setGet(publicAPI, model, ['initialized', 'context', 'canvas', 'renderPasses', 'notifyStartCaptureImage', 'defaultToWebgl2', 'cursor', '
|
|
823
|
+
macro.setGet(publicAPI, model, ['initialized', 'context', 'canvas', 'renderPasses', 'notifyStartCaptureImage', 'defaultToWebgl2', 'cursor', 'useOffScreen', // might want to make this not call modified as
|
|
740
824
|
// we change the active framebuffer a lot. Or maybe
|
|
741
825
|
// only mark modified if the size or depth
|
|
742
826
|
// of the buffer has changed
|
|
743
827
|
'activeFramebuffer']);
|
|
744
|
-
macro.setGetArray(publicAPI, model, ['size'
|
|
828
|
+
macro.setGetArray(publicAPI, model, ['size'], 2); // Object methods
|
|
745
829
|
|
|
746
830
|
vtkOpenGLRenderWindow(publicAPI, model);
|
|
747
831
|
} // ----------------------------------------------------------------------------
|
|
@@ -421,18 +421,6 @@ function vtkShaderProgram(publicAPI, model) {
|
|
|
421
421
|
return true;
|
|
422
422
|
};
|
|
423
423
|
|
|
424
|
-
publicAPI.setUniform4fv = function (name, count, v) {
|
|
425
|
-
var location = publicAPI.findUniform(name);
|
|
426
|
-
|
|
427
|
-
if (location === -1) {
|
|
428
|
-
model.error = "Could not set uniform ".concat(name, " . No such uniform.");
|
|
429
|
-
return false;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
model.context.uniform4fv(location, v);
|
|
433
|
-
return true;
|
|
434
|
-
};
|
|
435
|
-
|
|
436
424
|
publicAPI.findUniform = function (name) {
|
|
437
425
|
if (!name || !model.linked) {
|
|
438
426
|
return -1;
|
package/_virtual/rollup-plugin-web-worker-loader__helper__browser__createInlineWorkerFactory.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { f as funcToSource } from './rollup-plugin-web-worker-loader__helper__funcToSource.js';
|
|
2
|
+
|
|
3
|
+
function createURL(fn, sourcemapArg) {
|
|
4
|
+
var lines = funcToSource(fn, sourcemapArg);
|
|
5
|
+
var blob = new Blob(lines, { type: 'application/javascript' });
|
|
6
|
+
return URL.createObjectURL(blob);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function createInlineWorkerFactory(fn, sourcemapArg) {
|
|
10
|
+
var url;
|
|
11
|
+
return function WorkerFactory(options) {
|
|
12
|
+
url = url || createURL(fn, sourcemapArg);
|
|
13
|
+
return new Worker(url, options);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { createInlineWorkerFactory as c };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function funcToSource(fn, sourcemapArg) {
|
|
2
|
+
var sourcemap = sourcemapArg === undefined ? null : sourcemapArg;
|
|
3
|
+
var source = fn.toString();
|
|
4
|
+
var lines = source.split('\n');
|
|
5
|
+
lines.pop();
|
|
6
|
+
lines.shift();
|
|
7
|
+
var blankPrefixLength = lines[0].search(/\S/);
|
|
8
|
+
var regex = /(['"])__worker_loader_strict__(['"])/g;
|
|
9
|
+
for (var i = 0, n = lines.length; i < n; ++i) {
|
|
10
|
+
lines[i] = lines[i].substring(blankPrefixLength).replace(regex, '$1use strict$2') + '\n';
|
|
11
|
+
}
|
|
12
|
+
if (sourcemap) {
|
|
13
|
+
lines.push('\/\/# sourceMappingURL=' + sourcemap + '\n');
|
|
14
|
+
}
|
|
15
|
+
return lines;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { funcToSource as f };
|