@xeokit/xeokit-sdk 2.4.0-alpha-42 → 2.4.0-alpha-43
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
CHANGED
|
@@ -16550,9 +16550,18 @@ class RenderBuffer {
|
|
|
16550
16550
|
const canvas = imageDataCache.canvas;
|
|
16551
16551
|
const imageData = imageDataCache.imageData;
|
|
16552
16552
|
const context = imageDataCache.context;
|
|
16553
|
-
|
|
16553
|
+
const { width, height } = this.buffer;
|
|
16554
|
+
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixelData);
|
|
16554
16555
|
imageData.data.set(pixelData);
|
|
16555
16556
|
context.putImageData(imageData, 0, 0);
|
|
16557
|
+
|
|
16558
|
+
// flip Y
|
|
16559
|
+
context.save();
|
|
16560
|
+
context.globalCompositeOperation = 'copy';
|
|
16561
|
+
context.scale(1, -1);
|
|
16562
|
+
context.drawImage(canvas, 0, -height, width, height);
|
|
16563
|
+
context.restore();
|
|
16564
|
+
|
|
16556
16565
|
let format = params.format || "png";
|
|
16557
16566
|
if (format !== "jpeg" && format !== "png" && format !== "bmp") {
|
|
16558
16567
|
console.error("Unsupported image format: '" + format + "' - supported types are 'jpeg', 'bmp' and 'png' - defaulting to 'png'");
|
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -16546,9 +16546,18 @@ class RenderBuffer {
|
|
|
16546
16546
|
const canvas = imageDataCache.canvas;
|
|
16547
16547
|
const imageData = imageDataCache.imageData;
|
|
16548
16548
|
const context = imageDataCache.context;
|
|
16549
|
-
|
|
16549
|
+
const { width, height } = this.buffer;
|
|
16550
|
+
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixelData);
|
|
16550
16551
|
imageData.data.set(pixelData);
|
|
16551
16552
|
context.putImageData(imageData, 0, 0);
|
|
16553
|
+
|
|
16554
|
+
// flip Y
|
|
16555
|
+
context.save();
|
|
16556
|
+
context.globalCompositeOperation = 'copy';
|
|
16557
|
+
context.scale(1, -1);
|
|
16558
|
+
context.drawImage(canvas, 0, -height, width, height);
|
|
16559
|
+
context.restore();
|
|
16560
|
+
|
|
16552
16561
|
let format = params.format || "png";
|
|
16553
16562
|
if (format !== "jpeg" && format !== "png" && format !== "bmp") {
|
|
16554
16563
|
console.error("Unsupported image format: '" + format + "' - supported types are 'jpeg', 'bmp' and 'png' - defaulting to 'png'");
|
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -4383,7 +4383,8 @@ gl.bindFramebuffer(gl.FRAMEBUFFER,framebuf);if(!gl.isFramebuffer(framebuf)){thro
|
|
|
4383
4383
|
*
|
|
4384
4384
|
* @returns {HTMLCanvasElement}
|
|
4385
4385
|
*/},{key:"readImageAsCanvas",value:function readImageAsCanvas(){var gl=this.gl;var imageDataCache=this._getImageDataCache();var pixelData=imageDataCache.pixelData;var canvas=imageDataCache.canvas;var imageData=imageDataCache.imageData;var context=imageDataCache.context;gl.readPixels(0,0,this.buffer.width,this.buffer.height,gl.RGBA,gl.UNSIGNED_BYTE,pixelData);var width=this.buffer.width;var height=this.buffer.height;var halfHeight=height/2|0;// the | 0 keeps the result an int
|
|
4386
|
-
var bytesPerRow=width*4;var temp=new Uint8Array(width*4);for(var y=0;y<halfHeight;++y){var topOffset=y*bytesPerRow;var bottomOffset=(height-y-1)*bytesPerRow;temp.set(pixelData.subarray(topOffset,topOffset+bytesPerRow));pixelData.copyWithin(topOffset,bottomOffset,bottomOffset+bytesPerRow);pixelData.set(temp,bottomOffset);}imageData.data.set(pixelData);context.putImageData(imageData,0,0);return canvas;}},{key:"readImage",value:function readImage(params){var gl=this.gl;var imageDataCache=this._getImageDataCache();var pixelData=imageDataCache.pixelData;var canvas=imageDataCache.canvas;var imageData=imageDataCache.imageData;var context=imageDataCache.context;gl.readPixels(0,0,
|
|
4386
|
+
var bytesPerRow=width*4;var temp=new Uint8Array(width*4);for(var y=0;y<halfHeight;++y){var topOffset=y*bytesPerRow;var bottomOffset=(height-y-1)*bytesPerRow;temp.set(pixelData.subarray(topOffset,topOffset+bytesPerRow));pixelData.copyWithin(topOffset,bottomOffset,bottomOffset+bytesPerRow);pixelData.set(temp,bottomOffset);}imageData.data.set(pixelData);context.putImageData(imageData,0,0);return canvas;}},{key:"readImage",value:function readImage(params){var gl=this.gl;var imageDataCache=this._getImageDataCache();var pixelData=imageDataCache.pixelData;var canvas=imageDataCache.canvas;var imageData=imageDataCache.imageData;var context=imageDataCache.context;var _this$buffer=this.buffer,width=_this$buffer.width,height=_this$buffer.height;gl.readPixels(0,0,width,height,gl.RGBA,gl.UNSIGNED_BYTE,pixelData);imageData.data.set(pixelData);context.putImageData(imageData,0,0);// flip Y
|
|
4387
|
+
context.save();context.globalCompositeOperation='copy';context.scale(1,-1);context.drawImage(canvas,0,-height,width,height);context.restore();var format=params.format||"png";if(format!=="jpeg"&&format!=="png"&&format!=="bmp"){console.error("Unsupported image format: '"+format+"' - supported types are 'jpeg', 'bmp' and 'png' - defaulting to 'png'");format="png";}return canvas.toDataURL("image/".concat(format));}},{key:"_getImageDataCache",value:function _getImageDataCache(){var type=arguments.length>0&&arguments[0]!==undefined?arguments[0]:Uint8Array;var multiplier=arguments.length>1&&arguments[1]!==undefined?arguments[1]:4;var bufferWidth=this.buffer.width;var bufferHeight=this.buffer.height;var imageDataCache=this._imageDataCache;if(imageDataCache){if(imageDataCache.width!==bufferWidth||imageDataCache.height!==bufferHeight){this._imageDataCache=null;imageDataCache=null;}}if(!imageDataCache){var _canvas=document.createElement('canvas');var context=_canvas.getContext('2d');_canvas.width=bufferWidth;_canvas.height=bufferHeight;imageDataCache={pixelData:new type(bufferWidth*bufferHeight*multiplier),canvas:_canvas,context:context,imageData:context.createImageData(bufferWidth,bufferHeight),width:bufferWidth,height:bufferHeight};this._imageDataCache=imageDataCache;}imageDataCache.context.resetTransform();// Prevents strange scale-accumulation effect with html2canvas
|
|
4387
4388
|
return imageDataCache;}},{key:"unbind",value:function unbind(){var gl=this.gl;gl.bindFramebuffer(gl.FRAMEBUFFER,null);this.bound=false;}},{key:"getTexture",value:function getTexture(){var self=this;return this._texture||(this._texture={renderBuffer:this,bind:function bind(unit){if(self.buffer&&self.buffer.texture){self.gl.activeTexture(self.gl["TEXTURE"+unit]);self.gl.bindTexture(self.gl.TEXTURE_2D,self.buffer.texture);return true;}return false;},unbind:function unbind(unit){if(self.buffer&&self.buffer.texture){self.gl.activeTexture(self.gl["TEXTURE"+unit]);self.gl.bindTexture(self.gl.TEXTURE_2D,null);}}});}},{key:"hasDepthTexture",value:function hasDepthTexture(){return this._hasDepthTexture;}},{key:"getDepthTexture",value:function getDepthTexture(){if(!this._hasDepthTexture){return null;}var self=this;return this._depthTexture||(this._dethTexture={renderBuffer:this,bind:function bind(unit){if(self.buffer&&self.buffer.depthTexture){self.gl.activeTexture(self.gl["TEXTURE"+unit]);self.gl.bindTexture(self.gl.TEXTURE_2D,self.buffer.depthTexture);return true;}return false;},unbind:function unbind(unit){if(self.buffer&&self.buffer.depthTexture){self.gl.activeTexture(self.gl["TEXTURE"+unit]);self.gl.bindTexture(self.gl.TEXTURE_2D,null);}}});}},{key:"destroy",value:function destroy(){if(this.allocated){var _gl2=this.gl;_gl2.deleteTexture(this.buffer.texture);_gl2.deleteTexture(this.buffer.depthTexture);_gl2.deleteFramebuffer(this.buffer.framebuf);_gl2.deleteRenderbuffer(this.buffer.renderbuf);this.allocated=false;this.buffer=null;this.bound=false;}this._imageDataCache=null;this._texture=null;this._depthTexture=null;}}]);return RenderBuffer;}();/**
|
|
4388
4389
|
* @private
|
|
4389
4390
|
*/var RenderBufferManager=/*#__PURE__*/function(){function RenderBufferManager(scene){_classCallCheck(this,RenderBufferManager);this.scene=scene;this._renderBuffersBasic={};this._renderBuffersScaled={};}_createClass(RenderBufferManager,[{key:"getRenderBuffer",value:function getRenderBuffer(id,options){var renderBuffers=this.scene.canvas.resolutionScale===1.0?this._renderBuffersBasic:this._renderBuffersScaled;var renderBuffer=renderBuffers[id];if(!renderBuffer){renderBuffer=new RenderBuffer(this.scene.canvas.canvas,this.scene.canvas.gl,options);renderBuffers[id]=renderBuffer;}return renderBuffer;}},{key:"destroy",value:function destroy(){for(var id in this._renderBuffersBasic){this._renderBuffersBasic[id].destroy();}for(var _id in this._renderBuffersScaled){this._renderBuffersScaled[_id].destroy();}}}]);return RenderBufferManager;}();/**
|