@xeokit/xeokit-sdk 2.4.0-alpha-26 → 2.4.0-alpha-28
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/dist/xeokit-sdk.cjs.js +20 -269
- package/dist/xeokit-sdk.es.js +20 -269
- package/dist/xeokit-sdk.es5.js +10 -37
- package/dist/xeokit-sdk.min.cjs.js +7 -7
- package/dist/xeokit-sdk.min.es.js +7 -7
- package/dist/xeokit-sdk.min.es5.js +6 -6
- package/package.json +1 -1
- package/types/viewer/Viewer.d.ts +28 -0
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -15555,221 +15555,6 @@ function createSampleOffsets(kernelRadius, uvIncrement) {
|
|
|
15555
15555
|
return offsets;
|
|
15556
15556
|
}
|
|
15557
15557
|
|
|
15558
|
-
/*
|
|
15559
|
-
* Canvas2Image v0.1
|
|
15560
|
-
* Copyright (c) 2008 Jacob Seidelin, cupboy@gmail.com
|
|
15561
|
-
* MIT License [http://www.opensource.org/licenses/mit-license.php]
|
|
15562
|
-
*
|
|
15563
|
-
* Modified by @xeolabs to permit vertical flipping, so that snapshot can be taken from WebGL frame buffers,
|
|
15564
|
-
* which vertically flip image data as part of the way that WebGL renders textures.
|
|
15565
|
-
*/
|
|
15566
|
-
|
|
15567
|
-
/**
|
|
15568
|
-
* @private
|
|
15569
|
-
*/
|
|
15570
|
-
const Canvas2Image = (function () {
|
|
15571
|
-
// check if we have canvas support
|
|
15572
|
-
const oCanvas = document.createElement("canvas"), sc = String.fromCharCode;
|
|
15573
|
-
|
|
15574
|
-
// no canvas, bail out.
|
|
15575
|
-
if (!oCanvas.getContext) {
|
|
15576
|
-
return {
|
|
15577
|
-
saveAsBMP: function () {
|
|
15578
|
-
},
|
|
15579
|
-
saveAsPNG: function () {
|
|
15580
|
-
},
|
|
15581
|
-
saveAsJPEG: function () {
|
|
15582
|
-
}
|
|
15583
|
-
}
|
|
15584
|
-
}
|
|
15585
|
-
|
|
15586
|
-
const bHasImageData = !!(oCanvas.getContext("2d").getImageData), bHasDataURL = !!(oCanvas.toDataURL),
|
|
15587
|
-
bHasBase64 = !!(window.btoa);
|
|
15588
|
-
|
|
15589
|
-
// ok, we're good
|
|
15590
|
-
const readCanvasData = function (oCanvas) {
|
|
15591
|
-
const iWidth = parseInt(oCanvas.width), iHeight = parseInt(oCanvas.height);
|
|
15592
|
-
return oCanvas.getContext("2d").getImageData(0, 0, iWidth, iHeight);
|
|
15593
|
-
};
|
|
15594
|
-
|
|
15595
|
-
// base64 encodes either a string or an array of charcodes
|
|
15596
|
-
const encodeData = function (data) {
|
|
15597
|
-
let i, aData, strData = "";
|
|
15598
|
-
|
|
15599
|
-
if (typeof data == "string") {
|
|
15600
|
-
strData = data;
|
|
15601
|
-
} else {
|
|
15602
|
-
aData = data;
|
|
15603
|
-
for (i = 0; i < aData.length; i++) {
|
|
15604
|
-
strData += sc(aData[i]);
|
|
15605
|
-
}
|
|
15606
|
-
}
|
|
15607
|
-
return btoa(strData);
|
|
15608
|
-
};
|
|
15609
|
-
|
|
15610
|
-
// creates a base64 encoded string containing BMP data takes an imagedata object as argument
|
|
15611
|
-
const createBMP = function (oData) {
|
|
15612
|
-
let strHeader = '';
|
|
15613
|
-
const iWidth = oData.width;
|
|
15614
|
-
const iHeight = oData.height;
|
|
15615
|
-
|
|
15616
|
-
strHeader += 'BM';
|
|
15617
|
-
|
|
15618
|
-
let iFileSize = iWidth * iHeight * 4 + 54; // total header size = 54 bytes
|
|
15619
|
-
strHeader += sc(iFileSize % 256);
|
|
15620
|
-
iFileSize = Math.floor(iFileSize / 256);
|
|
15621
|
-
strHeader += sc(iFileSize % 256);
|
|
15622
|
-
iFileSize = Math.floor(iFileSize / 256);
|
|
15623
|
-
strHeader += sc(iFileSize % 256);
|
|
15624
|
-
iFileSize = Math.floor(iFileSize / 256);
|
|
15625
|
-
strHeader += sc(iFileSize % 256);
|
|
15626
|
-
|
|
15627
|
-
strHeader += sc(0, 0, 0, 0, 54, 0, 0, 0); // data offset
|
|
15628
|
-
strHeader += sc(40, 0, 0, 0); // info header size
|
|
15629
|
-
|
|
15630
|
-
let iImageWidth = iWidth;
|
|
15631
|
-
strHeader += sc(iImageWidth % 256);
|
|
15632
|
-
iImageWidth = Math.floor(iImageWidth / 256);
|
|
15633
|
-
strHeader += sc(iImageWidth % 256);
|
|
15634
|
-
iImageWidth = Math.floor(iImageWidth / 256);
|
|
15635
|
-
strHeader += sc(iImageWidth % 256);
|
|
15636
|
-
iImageWidth = Math.floor(iImageWidth / 256);
|
|
15637
|
-
strHeader += sc(iImageWidth % 256);
|
|
15638
|
-
|
|
15639
|
-
let iImageHeight = iHeight;
|
|
15640
|
-
strHeader += sc(iImageHeight % 256);
|
|
15641
|
-
iImageHeight = Math.floor(iImageHeight / 256);
|
|
15642
|
-
strHeader += sc(iImageHeight % 256);
|
|
15643
|
-
iImageHeight = Math.floor(iImageHeight / 256);
|
|
15644
|
-
strHeader += sc(iImageHeight % 256);
|
|
15645
|
-
iImageHeight = Math.floor(iImageHeight / 256);
|
|
15646
|
-
strHeader += sc(iImageHeight % 256);
|
|
15647
|
-
|
|
15648
|
-
strHeader += sc(1, 0, 32, 0); // num of planes & num of bits per pixel
|
|
15649
|
-
strHeader += sc(0, 0, 0, 0); // compression = none
|
|
15650
|
-
|
|
15651
|
-
let iDataSize = iWidth * iHeight * 4;
|
|
15652
|
-
strHeader += sc(iDataSize % 256);
|
|
15653
|
-
iDataSize = Math.floor(iDataSize / 256);
|
|
15654
|
-
strHeader += sc(iDataSize % 256);
|
|
15655
|
-
iDataSize = Math.floor(iDataSize / 256);
|
|
15656
|
-
strHeader += sc(iDataSize % 256);
|
|
15657
|
-
iDataSize = Math.floor(iDataSize / 256);
|
|
15658
|
-
strHeader += sc(iDataSize % 256);
|
|
15659
|
-
|
|
15660
|
-
strHeader += sc(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); // these bytes are not used
|
|
15661
|
-
|
|
15662
|
-
const aImgData = oData.data;
|
|
15663
|
-
let strPixelData = "";
|
|
15664
|
-
let x;
|
|
15665
|
-
let y = iHeight;
|
|
15666
|
-
let iOffsetX;
|
|
15667
|
-
let iOffsetY;
|
|
15668
|
-
let strPixelRow;
|
|
15669
|
-
|
|
15670
|
-
do {
|
|
15671
|
-
iOffsetY = iWidth * (y - 1) * 4;
|
|
15672
|
-
strPixelRow = "";
|
|
15673
|
-
for (x = 0; x < iWidth; x++) {
|
|
15674
|
-
iOffsetX = 4 * x;
|
|
15675
|
-
strPixelRow += sc(
|
|
15676
|
-
aImgData[iOffsetY + iOffsetX + 2], // B
|
|
15677
|
-
aImgData[iOffsetY + iOffsetX + 1], // G
|
|
15678
|
-
aImgData[iOffsetY + iOffsetX], // R
|
|
15679
|
-
aImgData[iOffsetY + iOffsetX + 3] // A
|
|
15680
|
-
);
|
|
15681
|
-
}
|
|
15682
|
-
strPixelData += strPixelRow;
|
|
15683
|
-
} while (--y);
|
|
15684
|
-
|
|
15685
|
-
return encodeData(strHeader + strPixelData);
|
|
15686
|
-
};
|
|
15687
|
-
|
|
15688
|
-
// sends the generated file to the client
|
|
15689
|
-
const saveFile = function (strData) {
|
|
15690
|
-
if (!window.open(strData)) {
|
|
15691
|
-
document.location.href = strData;
|
|
15692
|
-
}
|
|
15693
|
-
};
|
|
15694
|
-
|
|
15695
|
-
const makeDataURI = function (strData, strMime) {
|
|
15696
|
-
return "data:" + strMime + ";base64," + strData;
|
|
15697
|
-
};
|
|
15698
|
-
|
|
15699
|
-
// generates a <img> object containing the imagedata
|
|
15700
|
-
const makeImageObject = function (strSource) {
|
|
15701
|
-
const oImgElement = document.createElement("img");
|
|
15702
|
-
oImgElement.src = strSource;
|
|
15703
|
-
return oImgElement;
|
|
15704
|
-
};
|
|
15705
|
-
|
|
15706
|
-
const scaleCanvas = function (oCanvas, iWidth, iHeight, flipy) {
|
|
15707
|
-
if (iWidth && iHeight) {
|
|
15708
|
-
const oSaveCanvas = document.createElement("canvas");
|
|
15709
|
-
oSaveCanvas.width = iWidth;
|
|
15710
|
-
oSaveCanvas.height = iHeight;
|
|
15711
|
-
oSaveCanvas.style.width = iWidth + "px";
|
|
15712
|
-
oSaveCanvas.style.height = iHeight + "px";
|
|
15713
|
-
const oSaveCtx = oSaveCanvas.getContext("2d");
|
|
15714
|
-
if (flipy) {
|
|
15715
|
-
oSaveCtx.save();
|
|
15716
|
-
oSaveCtx.scale(1.0, -1.0);
|
|
15717
|
-
oSaveCtx.imageSmoothingEnabled = true;
|
|
15718
|
-
oSaveCtx.drawImage(oCanvas, 0, 0, oCanvas.width, oCanvas.height, 0, 0, iWidth, -iHeight);
|
|
15719
|
-
oSaveCtx.restore();
|
|
15720
|
-
} else {
|
|
15721
|
-
oSaveCtx.imageSmoothingEnabled = true;
|
|
15722
|
-
oSaveCtx.drawImage(oCanvas, 0, 0, oCanvas.width, oCanvas.height, 0, 0, iWidth, iHeight);
|
|
15723
|
-
}
|
|
15724
|
-
return oSaveCanvas;
|
|
15725
|
-
}
|
|
15726
|
-
return oCanvas;
|
|
15727
|
-
};
|
|
15728
|
-
|
|
15729
|
-
return {
|
|
15730
|
-
saveAsPNG: function (oCanvas, bReturnImg, iWidth, iHeight, flipy) {
|
|
15731
|
-
if (!bHasDataURL) return false;
|
|
15732
|
-
const oScaledCanvas = scaleCanvas(oCanvas, iWidth, iHeight, flipy);
|
|
15733
|
-
const strMime = "image/png";
|
|
15734
|
-
const strData = oScaledCanvas.toDataURL(strMime);
|
|
15735
|
-
if (bReturnImg) {
|
|
15736
|
-
return makeImageObject(strData);
|
|
15737
|
-
} else {
|
|
15738
|
-
saveFile(strData);
|
|
15739
|
-
}
|
|
15740
|
-
return true;
|
|
15741
|
-
},
|
|
15742
|
-
|
|
15743
|
-
saveAsJPEG: function (oCanvas, bReturnImg, iWidth, iHeight, flipy) {
|
|
15744
|
-
if (!bHasDataURL) return false;
|
|
15745
|
-
const oScaledCanvas = scaleCanvas(oCanvas, iWidth, iHeight, flipy);
|
|
15746
|
-
const strMime = "image/jpeg";
|
|
15747
|
-
const strData = oScaledCanvas.toDataURL(strMime);
|
|
15748
|
-
// check if browser actually supports jpeg by looking for the mime type in the data uri. if not, return false
|
|
15749
|
-
if (strData.indexOf(strMime) != 5) return false;
|
|
15750
|
-
if (bReturnImg) {
|
|
15751
|
-
return makeImageObject(strData);
|
|
15752
|
-
} else {
|
|
15753
|
-
saveFile(strData);
|
|
15754
|
-
}
|
|
15755
|
-
return true;
|
|
15756
|
-
},
|
|
15757
|
-
|
|
15758
|
-
saveAsBMP: function (oCanvas, bReturnImg, iWidth, iHeight, flipy) {
|
|
15759
|
-
if (!(bHasDataURL && bHasImageData && bHasBase64)) return false;
|
|
15760
|
-
const oScaledCanvas = scaleCanvas(oCanvas, iWidth, iHeight, flipy);
|
|
15761
|
-
const strMime = "image/bmp";
|
|
15762
|
-
const oData = readCanvasData(oScaledCanvas), strImgData = createBMP(oData);
|
|
15763
|
-
if (bReturnImg) {
|
|
15764
|
-
return makeImageObject(makeDataURI(strImgData, strMime));
|
|
15765
|
-
} else {
|
|
15766
|
-
saveFile(makeDataURI(strImgData, strMime));
|
|
15767
|
-
}
|
|
15768
|
-
return true;
|
|
15769
|
-
}
|
|
15770
|
-
};
|
|
15771
|
-
})();
|
|
15772
|
-
|
|
15773
15558
|
/**
|
|
15774
15559
|
* @desc Represents a WebGL render buffer.
|
|
15775
15560
|
* @private
|
|
@@ -15967,42 +15752,21 @@ class RenderBuffer {
|
|
|
15967
15752
|
}
|
|
15968
15753
|
|
|
15969
15754
|
readImage(params) {
|
|
15970
|
-
|
|
15971
15755
|
const gl = this.gl;
|
|
15972
15756
|
const imageDataCache = this._getImageDataCache();
|
|
15973
15757
|
const pixelData = imageDataCache.pixelData;
|
|
15974
15758
|
const canvas = imageDataCache.canvas;
|
|
15975
15759
|
const imageData = imageDataCache.imageData;
|
|
15976
15760
|
const context = imageDataCache.context;
|
|
15977
|
-
|
|
15978
15761
|
gl.readPixels(0, 0, this.buffer.width, this.buffer.height, gl.RGBA, gl.UNSIGNED_BYTE, pixelData);
|
|
15979
|
-
|
|
15980
15762
|
imageData.data.set(pixelData);
|
|
15981
15763
|
context.putImageData(imageData, 0, 0);
|
|
15982
|
-
|
|
15983
|
-
|
|
15984
|
-
|
|
15985
|
-
|
|
15986
|
-
const flipy = true; // Account for WebGL texture flipping
|
|
15987
|
-
|
|
15988
|
-
let image;
|
|
15989
|
-
|
|
15990
|
-
switch (format) {
|
|
15991
|
-
case "jpeg":
|
|
15992
|
-
image = Canvas2Image.saveAsJPEG(canvas, true, imageWidth, imageHeight, flipy);
|
|
15993
|
-
break;
|
|
15994
|
-
case "png":
|
|
15995
|
-
image = Canvas2Image.saveAsPNG(canvas, true, imageWidth, imageHeight, flipy);
|
|
15996
|
-
break;
|
|
15997
|
-
case "bmp":
|
|
15998
|
-
image = Canvas2Image.saveAsBMP(canvas, true, imageWidth, imageHeight, flipy);
|
|
15999
|
-
break;
|
|
16000
|
-
default:
|
|
16001
|
-
console.error("Unsupported image format: '" + format + "' - supported types are 'jpeg', 'bmp' and 'png' - defaulting to 'jpeg'");
|
|
16002
|
-
image = Canvas2Image.saveAsJPEG(canvas, true, imageWidth, imageHeight, flipy);
|
|
15764
|
+
let format = params.format || "png";
|
|
15765
|
+
if (format !== "jpeg" && format !== "png" && format !== "bmp") {
|
|
15766
|
+
console.error("Unsupported image format: '" + format + "' - supported types are 'jpeg', 'bmp' and 'png' - defaulting to 'png'");
|
|
15767
|
+
format = "png";
|
|
16003
15768
|
}
|
|
16004
|
-
|
|
16005
|
-
return image.src;
|
|
15769
|
+
return canvas.toDataURL(`image/${format}`);
|
|
16006
15770
|
}
|
|
16007
15771
|
|
|
16008
15772
|
_getImageDataCache() {
|
|
@@ -35072,10 +34836,6 @@ const Renderer$1 = function (scene, options) {
|
|
|
35072
34836
|
pickResult.worldNormal = worldSurfaceNormal;
|
|
35073
34837
|
}
|
|
35074
34838
|
|
|
35075
|
-
// if (params.pickSurfaceNormal !== false) {
|
|
35076
|
-
// gpuPickWorldNormal(pickBuffer, pickable, canvasPos, pickViewMatrix, pickProjMatrix, pickResult);
|
|
35077
|
-
// }
|
|
35078
|
-
|
|
35079
34839
|
pickResult.pickSurfacePrecision = true;
|
|
35080
34840
|
}
|
|
35081
34841
|
|
|
@@ -35464,8 +35224,7 @@ const Renderer$1 = function (scene, options) {
|
|
|
35464
35224
|
*/
|
|
35465
35225
|
this.readSnapshot = function (params) {
|
|
35466
35226
|
const snapshotBuffer = renderBufferManager.getRenderBuffer("snapshot");
|
|
35467
|
-
|
|
35468
|
-
return imageDataURI;
|
|
35227
|
+
return snapshotBuffer.readImage(params);
|
|
35469
35228
|
};
|
|
35470
35229
|
|
|
35471
35230
|
/**
|
|
@@ -84187,9 +83946,11 @@ class TrianglesInstancingLayer {
|
|
|
84187
83946
|
c[1] = quantizedPositions[ic + 1];
|
|
84188
83947
|
c[2] = quantizedPositions[ic + 2];
|
|
84189
83948
|
|
|
84190
|
-
|
|
84191
|
-
|
|
84192
|
-
math.decompressPosition(
|
|
83949
|
+
const { positionsDecodeMatrix } = state.geometry;
|
|
83950
|
+
|
|
83951
|
+
math.decompressPosition(a, positionsDecodeMatrix);
|
|
83952
|
+
math.decompressPosition(b, positionsDecodeMatrix);
|
|
83953
|
+
math.decompressPosition(c, positionsDecodeMatrix);
|
|
84193
83954
|
|
|
84194
83955
|
if (math.rayTriangleIntersect(rtcRayOrigin, rtcRayDir, a, b, c, closestIntersectPos)) {
|
|
84195
83956
|
|
|
@@ -110653,6 +110414,10 @@ class Viewer {
|
|
|
110653
110414
|
* Gets a snapshot of this Viewer's {@link Scene} as a Base64-encoded image which includes
|
|
110654
110415
|
* the HTML elements created by various plugins.
|
|
110655
110416
|
*
|
|
110417
|
+
* The snapshot image is composed of an image of the viewer canvas, overlaid with an image
|
|
110418
|
+
* of the HTML container element belonging to each installed Viewer plugin. Each container
|
|
110419
|
+
* element is only rendered once, so it's OK for plugins to share the same container.
|
|
110420
|
+
*
|
|
110656
110421
|
* #### Usage:
|
|
110657
110422
|
*
|
|
110658
110423
|
* ````javascript
|
|
@@ -110727,24 +110492,10 @@ class Viewer {
|
|
|
110727
110492
|
if (needFinishSnapshot) {
|
|
110728
110493
|
this.endSnapshot();
|
|
110729
110494
|
}
|
|
110730
|
-
|
|
110731
|
-
|
|
110732
|
-
|
|
110733
|
-
|
|
110734
|
-
let image;
|
|
110735
|
-
switch (format) {
|
|
110736
|
-
case "jpeg":
|
|
110737
|
-
image = Canvas2Image.saveAsJPEG(snapshotCanvas, true, imageWidth, imageHeight, flipy);
|
|
110738
|
-
break;
|
|
110739
|
-
case "png":
|
|
110740
|
-
image = Canvas2Image.saveAsPNG(snapshotCanvas, true, imageWidth, imageHeight, flipy);
|
|
110741
|
-
break;
|
|
110742
|
-
case "bmp":
|
|
110743
|
-
image = Canvas2Image.saveAsBMP(snapshotCanvas, true, imageWidth, imageHeight, flipy);
|
|
110744
|
-
break;
|
|
110745
|
-
default:
|
|
110746
|
-
this.error("[Viewer.getSnapshotWithPlugins] Unsupported image format: '" + format + "' - supported types are 'jpeg', 'bmp' and 'png' - defaulting to 'jpeg'");
|
|
110747
|
-
image = Canvas2Image.saveAsJPEG(snapshotCanvas, true, imageWidth, imageHeight, flipy);
|
|
110495
|
+
let format = params.format || "png";
|
|
110496
|
+
if (format !== "jpeg" && format !== "png" && format !== "bmp") {
|
|
110497
|
+
console.error("Unsupported image format: '" + format + "' - supported types are 'jpeg', 'bmp' and 'png' - defaulting to 'png'");
|
|
110498
|
+
format = "png";
|
|
110748
110499
|
}
|
|
110749
110500
|
if (!params.includeGizmos) {
|
|
110750
110501
|
this.sendToPlugins("snapshotFinished");
|
|
@@ -110752,7 +110503,7 @@ class Viewer {
|
|
|
110752
110503
|
if (needFinishSnapshot) {
|
|
110753
110504
|
this.endSnapshot();
|
|
110754
110505
|
}
|
|
110755
|
-
resolve(image
|
|
110506
|
+
resolve(snapshotCanvas.toDataURL(`image/${format}`));
|
|
110756
110507
|
};
|
|
110757
110508
|
|
|
110758
110509
|
for (let i = 0, len = this._plugins.length; i < len; i++) { // Find plugin container elements
|