zincjs 1.16.7 → 1.16.9
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/build/zinc.frontend.js +1 -1
- package/build/zinc.js +24 -16
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/label.js +12 -3
- package/src/primitives/pointset.js +17 -1
- package/src/primitives/textureSlides.js +38 -0
- package/src/shaders/textureSlide.js +15 -9
- package/src/texture/textureArray.js +6 -6
package/build/zinc.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = require("url-polyfill");
|
|
|
32
32
|
/***/ ((module) => {
|
|
33
33
|
|
|
34
34
|
"use strict";
|
|
35
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.16.
|
|
35
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.16.9","description":"ZincJS (Web-based-Zinc-Visualisation)","main":"build/zinc.js","directories":{"doc":"docs"},"files":["package.json","LICENSE","README.md","src/*","build/zinc.js","build/zinc.frontend.js","build/zinc.js.map","webpack.config.js"],"scripts":{"build-bundle":"webpack --config webpack.frontend.js; webpack --config webpack.backend.js","build-backend":"webpack --config webpack.backend.js","test":"npm --prefix ./test install && npm --prefix ./test run test-ci","changelog":"auto-changelog -p --output CHANGELOG.md --template keepachangelog","jsdoc":"jsdoc -c jsdoc_conf.json","version":"npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs","release:beta":"npm version prerelease --preid=beta; npm publish --tag beta","release:minor":"npm version minor; npm publish","release:patch":"npm version patch; npm publish"},"repository":{"type":"git","url":"git+https://github.com/alan-wu/ZincJS.git"},"keywords":["library","webgl","3d","zincjs"],"author":"Alan Wu <alan.wu@auckland.ac.nz>","license":"MIT","bugs":{"url":"https://github.com/alan-wu/ZincJS/issues"},"homepage":"http://alan-wu.github.io/ZincJS/","devDependencies":{"@babel/core":"^7.23.9","@babel/preset-env":"^7.23.9","auto-changelog":"^2.4.0","babel-loader":"^9.1.3","babel-preset-minify":"^0.5.1","file-loader":"^6.2.0","jsdoc":"^4.0.2","raw-loader":"^4.0.2","webpack":"^5.90.3","webpack-cli":"^5.1.4","webpack-node-externals":"^3.0.0"},"dependencies":{"css-element-queries":"^1.2.2","lodash":"^4.17.19","promise-polyfill":"^8.1.3","three":"^0.130.1","three-spritetext":"1.6.2","url-loader":"^4.1.1","url-polyfill":"^1.1.7","webworkify-webpack":"^2.1.5"}}');
|
|
36
36
|
|
|
37
37
|
/***/ }),
|
|
38
38
|
/* 3 */
|
|
@@ -620,7 +620,7 @@ var SpriteText=(__webpack_require__(7)["default"]);/**
|
|
|
620
620
|
* @class
|
|
621
621
|
* @author Alan Wu
|
|
622
622
|
* @return {Label}
|
|
623
|
-
*/exports.Label=function(textIn,colourIn){var text=textIn,sprite=void 0,position=[0,0,0],colour=colourIn,size=1,fontWeight=500;sprite=colourIn?new SpriteText(text,.
|
|
623
|
+
*/exports.Label=function(textIn,colourIn){var text=textIn,sprite=void 0,position=[0,0,0],colour=colourIn,size=1,fontWeight=500;sprite=colourIn?new SpriteText(text,.012,colourIn.getStyle()):new SpriteText(text,.012),sprite.fontFace="Asap",sprite.fontWeight=fontWeight,sprite.material.map.generateMipmaps=!1,sprite.material.sizeAttenuation=!1,sprite.center.x=-.05,sprite.center.y=0;var originalScale=[sprite.scale.x,sprite.scale.y];/**
|
|
624
624
|
* Get the current position in an array containing the x, y and z
|
|
625
625
|
* coordinates.
|
|
626
626
|
*
|
|
@@ -656,6 +656,10 @@ var SpriteText=(__webpack_require__(7)["default"]);/**
|
|
|
656
656
|
*
|
|
657
657
|
* @param {Number} scaling - Scale to be set.
|
|
658
658
|
*/ /**
|
|
659
|
+
* Set visibility of the label.
|
|
660
|
+
*
|
|
661
|
+
* @param {Boolean} flag - Visibility to set
|
|
662
|
+
*/ /**
|
|
659
663
|
* Free up the memory
|
|
660
664
|
*/ /**
|
|
661
665
|
* Get the intrnal sprite.
|
|
@@ -665,7 +669,7 @@ var SpriteText=(__webpack_require__(7)["default"]);/**
|
|
|
665
669
|
* Get the text.
|
|
666
670
|
*
|
|
667
671
|
* @return {String}
|
|
668
|
-
*/this.getPosition=()=>sprite?[sprite.position.x,sprite.position.y,sprite.position.z]:[0,0,0],this.setPosition=(x,y,z)=>{position[0]=x,position[1]=y,position[2]=z,sprite&&sprite.position.set(x,y,z)},this.setColour=colourIn=>{colourIn&&(sprite.color=colourIn.getStyle(),colour=colourIn)},this.setScale=scaling=>{sprite&&0<scaling&&sprite.scale.set(scaling,scaling,1)},this.setDepthTest=flag=>{flag&&flag!==sprite.material.depthTest&&(sprite.material.depthTest=flag)},this.setSize=sizeIn=>{sizeIn&&
|
|
672
|
+
*/this.getPosition=()=>sprite?[sprite.position.x,sprite.position.y,sprite.position.z]:[0,0,0],this.setPosition=(x,y,z)=>{position[0]=x,position[1]=y,position[2]=z,sprite&&sprite.position.set(x,y,z)},this.setColour=colourIn=>{colourIn&&(sprite.color=colourIn.getStyle(),colour=colourIn)},this.setScale=scaling=>{sprite&&0<scaling&&sprite.scale.set(scaling,scaling,1)},this.setDepthTest=flag=>{flag&&flag!==sprite.material.depthTest&&(sprite.material.depthTest=flag)},this.setSize=sizeIn=>{0<sizeIn&&(sprite.scale.x=originalScale[0]*sizeIn,sprite.scale.y=originalScale[1]*sizeIn,size=sizeIn)},this.setFontWeight=fontWeightIn=>{fontWeightIn&&fontWeightIn!==fontWeight&&(sprite.fontWeight=fontWeightIn,fontWeight=fontWeightIn)},this.setText=textIn=>{textIn&&textIn!==sprite.text&&(sprite.text=textIn,text=textIn)},this.setVisibility=flag=>{sprite.visible=flag},this.dispose=()=>{//sprite.dispose();
|
|
669
673
|
},this.getSprite=()=>sprite,this.getString=()=>text};
|
|
670
674
|
|
|
671
675
|
/***/ }),
|
|
@@ -811,7 +815,7 @@ return!!(_this.video&&3<=_this.video.readyState)},function initialise(){document
|
|
|
811
815
|
/* 22 */
|
|
812
816
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
813
817
|
|
|
814
|
-
var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBufferGeometry=(__webpack_require__(5).toBufferGeometry),getCircularTexture=(__webpack_require__(5).getCircularTexture),Label=(__webpack_require__(17).Label),Pointset=function(){(__webpack_require__(10).ZincObject).call(this),this.isPointset=!0;var labelSets=[],labelSize=1,labelDepthTest=!1,fontWeight=500;/**
|
|
818
|
+
var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBufferGeometry=(__webpack_require__(5).toBufferGeometry),getCircularTexture=(__webpack_require__(5).getCircularTexture),Label=(__webpack_require__(17).Label),Pointset=function(){(__webpack_require__(10).ZincObject).call(this),this.isPointset=!0;var labelSets=[],labelSize=1,labelDepthTest=!1,fontWeight=500,labelVisibility=!0;/**
|
|
815
819
|
* Create the pointsets using geometry and material.
|
|
816
820
|
*
|
|
817
821
|
* @param {THREE.Geomtry} geometryIn - Geometry of points to be rendered.
|
|
@@ -821,7 +825,7 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
821
825
|
* time dependent.
|
|
822
826
|
* @param {Boolean} options.localMorphColour - A flag to indicate either the colour is
|
|
823
827
|
* time dependent.
|
|
824
|
-
*/this.createMesh=(geometryIn,materialIn,options)=>{if(geometryIn&&materialIn){var geometry=toBufferGeometry(geometryIn,options),texture=getCircularTexture();materialIn.map=texture;var point=new Points(geometry,materialIn);this.setMesh(point,options.localTimeEnabled,options.localMorphColour)}};var addLabel=(index,coord,labelText,colourHex)=>{if(labelText){var colour=new THREE.Color(colourHex),label=new Label(labelText,colour);label.setPosition(coord[0],coord[1],coord[2]);var sprite=label.getSprite();sprite.material.sizeAttenuation=!1,sprite.material.alphaTest=.5,sprite.material.transparent=!0,sprite.material.depthWrite=!1,sprite.material.depthTest=labelDepthTest,label.setFontWeight(fontWeight),label.setSize(labelSize),this.group.add(sprite),labelSets[index]=label}};/**
|
|
828
|
+
*/this.createMesh=(geometryIn,materialIn,options)=>{if(geometryIn&&materialIn){var geometry=toBufferGeometry(geometryIn,options),texture=getCircularTexture();materialIn.map=texture;var point=new Points(geometry,materialIn);this.setMesh(point,options.localTimeEnabled,options.localMorphColour)}};var addLabel=(index,coord,labelText,colourHex)=>{if(labelText){var colour=new THREE.Color(colourHex),label=new Label(labelText,colour);label.setPosition(coord[0],coord[1],coord[2]);var sprite=label.getSprite();sprite.material.sizeAttenuation=!1,sprite.material.alphaTest=.5,sprite.material.transparent=!0,sprite.material.depthWrite=!1,sprite.material.depthTest=labelDepthTest,label.setFontWeight(fontWeight),label.setSize(labelSize),label.setVisibility(labelVisibility),this.group.add(sprite),labelSets[index]=label}};/**
|
|
825
829
|
* Add points to existing mesh if it exists, otherwise
|
|
826
830
|
* create a new one and add to it.
|
|
827
831
|
* @param {Array} coords -An array of three components coordinates.
|
|
@@ -851,6 +855,10 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
851
855
|
* @param {Number} size - Size to set, default
|
|
852
856
|
* value is 1.
|
|
853
857
|
*/ /**
|
|
858
|
+
* Set visibility of Labels
|
|
859
|
+
*
|
|
860
|
+
* @param {boolean} flag - default value is true
|
|
861
|
+
*/ /**
|
|
854
862
|
* Set the size of the points.
|
|
855
863
|
*
|
|
856
864
|
* @param {Number} size - size to be set.
|
|
@@ -872,7 +880,7 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
872
880
|
*
|
|
873
881
|
* @param {Boolean} flag - Determin either size attenuation
|
|
874
882
|
* should be on or off.
|
|
875
|
-
*/this.addPoints=(coords,labels,colour)=>{if(coords&&0<coords.length){var current=this.drawRange;-1===current&&(current=0);var geometry=this.addVertices(coords),mesh=this.getMorph();if(!mesh){var material=new THREE.PointsMaterial({alphaTest:.5,size:10,color:colour,sizeAttenuation:!1}),options={localTimeEnabled:!1,localMorphColour:!1};geometry.colorsNeedUpdate=!0,this.createMesh(geometry,material,options)}var end=current+coords.length,index=0;if(Array.isArray(labels)&&labels.length===coords.length||"string"==typeof labels){var size=labelSets.length;for(current;current+index<end;){var labelText="string"==typeof labels?labels:labels[index];addLabel(current+index,coords[index],labelText,this._lod._material.color),index++}}this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(hex){this._lod._material.color.setHex(hex),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(hex);for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setColour(this._lod._material.color)},this.setColour=colour=>{this._lod.setColour(colour);for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setColour(this._lod._material.color)},this.setLabelDepthTest=flag=>{labelDepthTest=flag;for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setDepthTest(flag)},this.setLabelFontWeight=fontWeightIn=>{fontWeight=fontWeightIn;for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setFontWeight(fontWeightIn)},this.setLabelSize=size=>{labelSize=size;for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setSize(
|
|
883
|
+
*/this.addPoints=(coords,labels,colour)=>{if(coords&&0<coords.length){var current=this.drawRange;-1===current&&(current=0);var geometry=this.addVertices(coords),mesh=this.getMorph();if(!mesh){var material=new THREE.PointsMaterial({alphaTest:.5,size:10,color:colour,sizeAttenuation:!1}),options={localTimeEnabled:!1,localMorphColour:!1};geometry.colorsNeedUpdate=!0,this.createMesh(geometry,material,options)}var end=current+coords.length,index=0;if(Array.isArray(labels)&&labels.length===coords.length||"string"==typeof labels){var size=labelSets.length;for(current;current+index<end;){var labelText="string"==typeof labels?labels:labels[index];addLabel(current+index,coords[index],labelText,this._lod._material.color),index++}}this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(hex){this._lod._material.color.setHex(hex),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(hex);for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setColour(this._lod._material.color)},this.setColour=colour=>{this._lod.setColour(colour);for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setColour(this._lod._material.color)},this.setLabelDepthTest=flag=>{labelDepthTest=flag;for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setDepthTest(flag)},this.setLabelFontWeight=fontWeightIn=>{fontWeight=fontWeightIn;for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setFontWeight(fontWeightIn)},this.setLabelSize=size=>{labelSize=size;for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setSize(labelSize)},this.displayLabels=flag=>{labelVisibility=flag;for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setVisibility(labelVisibility)},this.setSize=size=>{this.morph&&this.morph.material&&(this.morph.material.size=size,this.morph.material.needsUpdate=!0)},this.setSizeAttenuation=flag=>{this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=flag,this.morph.material.needsUpdate=!0)},this.getVerticesByIndex=function(index){if(0<=index&&this.drawRange>index){var positionAttribute=this.getMorph().geometry.getAttribute("position");return[positionAttribute.getX(index),positionAttribute.getY(index),positionAttribute.getZ(index)]}},this.editVertices=function(coords,i){if(coords&&coords.length){var mesh=this.getMorph(),maxIndex=i+coords.length-1;if(!mesh||0>i||maxIndex>=this.drawRange)return;var positionAttribute=mesh.geometry.getAttribute("position"),index=i;coords.forEach(coord=>{var label=labelSets[index];label&&label.setPosition(coord[0],coord[1],coord[2]),positionAttribute.setXYZ(index++,coord[0],coord[1],coord[2])}),positionAttribute.needsUpdate=!0,this.boundingBoxUpdateRequired=!0}},this.setName=function(groupNameIn){var oldName=this.groupName;Pointset.prototype.setName.call(this,groupNameIn),labelSets.forEach(label=>{label.getString()===oldName&&(null===label||void 0===label||label.setText(groupNameIn))})},this.render=(delta,playAnimation,cameraControls,options)=>{this.morph&&cameraControls&&(this.morph.sizePerPixel=cameraControls.pixelHeight),Pointset.prototype.render.call(this,delta,playAnimation,cameraControls,options)}};/**
|
|
876
884
|
* Provides an object which stores points and provides method which controls its position.
|
|
877
885
|
* This is created when a valid json file containing point is read into a {@link Zinc.Scene}
|
|
878
886
|
* object.
|
|
@@ -937,26 +945,26 @@ var THREE=__webpack_require__(4),toBufferGeometry=(__webpack_require__(5).toBuff
|
|
|
937
945
|
|
|
938
946
|
function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n){return void e(n)}i.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n)}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n)}var a=n.apply(t,e);_next(void 0)})}}var THREE=__webpack_require__(4),TextureArray=function(){var _this=this;/**
|
|
939
947
|
* Read images from an array containg src locations.
|
|
940
|
-
*
|
|
948
|
+
*
|
|
941
949
|
* @async
|
|
942
950
|
* @param {Array} srcArrays - List of source location of the images.
|
|
943
951
|
*/ /**
|
|
944
952
|
* Get and create the material containing shaders and the textures.
|
|
945
953
|
* The texture must be read and ready before calling this function.
|
|
946
|
-
*
|
|
954
|
+
*
|
|
947
955
|
*
|
|
948
956
|
* @param {Object} options - Customise the material with the options object.
|
|
949
|
-
* @param {String} options.fs - string of the fragment shader used for
|
|
957
|
+
* @param {String} options.fs - string of the fragment shader used for
|
|
950
958
|
* visualisation.
|
|
951
|
-
* @param {String} options.vs - string of the vertex shader used for
|
|
959
|
+
* @param {String} options.vs - string of the vertex shader used for
|
|
952
960
|
* visualisation.
|
|
953
961
|
* @param {Object} options.uniforms - Containing the data to be passed into the shaders.
|
|
954
962
|
* @param {String} options.glslVersion - Version of glsl used for compile this shader.
|
|
955
|
-
*
|
|
963
|
+
*
|
|
956
964
|
*/(__webpack_require__(26).Texture).call(this),this.isTextureArray=!0,this.loadFromImages=/*#__PURE__*/function(){var _ref=_asyncToGenerator(function*(srcArrays){var w=1,h=1,d=0;if(srcArrays&&srcArrays.length){_this.isLoading=!0;var image=new Image;image.crossOrigin="Anonymous";for(var data,canvas=document.createElement("canvas"),length=0,dataStacks=Array(srcArrays.length),i=0;i<srcArrays.length;i++)data=yield _this.imageToUint8Array(_this,image,srcArrays[i],canvas),data&&data.array&&(w=data.width,h=data.height,dataStacks[d]=data.array,length+=dataStacks[d].length,d++);var fullArray=new Uint8Array(length);length=0,dataStacks.forEach(data=>{fullArray.set(data,length),length+=data.length}),_this.impl=new THREE.DataTexture2DArray(fullArray,w,h,d),_this.size={width:w,height:h,depth:d},_this.isLoading=!1,_this.impl.needsUpdate=!0}});return function(){return _ref.apply(this,arguments)}}(),this.getMaterial=options=>{if(this.impl){var material;if(!options)material=new THREE.MeshBasicMaterial({color:new THREE.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:THREE.DoubleSide});else if(options.vs&&options.fs){var transparent=!0;"transparent"in options&&(transparent=options.transparent);var side=THREE.FrontSide;options.side&&(side=options.side),material=new THREE.ShaderMaterial({transparent,uniforms:options.uniforms,vertexShader:options.vs,fragmentShader:options.fs,side}),options.glslVersion&&(material.glslVersion=options.glslVersion)}if(material)return material.needsUpdate=!0,material}}};/**
|
|
957
965
|
* Texture array object for holding array of images into
|
|
958
966
|
* texures unit that can be used by other texture primitives.
|
|
959
|
-
*
|
|
967
|
+
*
|
|
960
968
|
* @class
|
|
961
969
|
* @author Alan Wu
|
|
962
970
|
* @return {TextureArray}
|
|
@@ -1010,7 +1018,7 @@ function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n){
|
|
|
1010
1018
|
/* 27 */
|
|
1011
1019
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1012
1020
|
|
|
1013
|
-
function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var t,r=1;r<arguments.length;r++)t=null==arguments[r]?{}:arguments[r],r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))});return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}var THREE=__webpack_require__(4),shader=__webpack_require__(28),TextureSlides=function(textureIn){(__webpack_require__(29).TexturePrimitive).call(this,textureIn),this.isTextureSlides=!0;var textureSettings=[],idTextureMap={};this.morph=new THREE.Group,this.group=this.morph,this.morph.userData=this;var edgesLine=void 0,flipY=!0;/**
|
|
1021
|
+
function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var t,r=1;r<arguments.length;r++)t=null==arguments[r]?{}:arguments[r],r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))});return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}var THREE=__webpack_require__(4),shader=__webpack_require__(28),TextureSlides=function(textureIn){(__webpack_require__(29).TexturePrimitive).call(this,textureIn),this.isTextureSlides=!0;var textureSettings=[],idTextureMap={};this.morph=new THREE.Group,this.group=this.morph,this.morph.userData=this;var edgesLine=void 0,flipY=!0,brightness=0,contrast=1;/**
|
|
1014
1022
|
@typedef SLIDE_SETTINGS
|
|
1015
1023
|
@type {Set}
|
|
1016
1024
|
@property {String} direction - the value must be x, y or z, specify the
|
|
@@ -1034,7 +1042,7 @@ function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var
|
|
|
1034
1042
|
* Modify the mesh based on a setting
|
|
1035
1043
|
*
|
|
1036
1044
|
* @param {SLIDE_SETTINGS} settings - s.
|
|
1037
|
-
*/this.modifySlideSettings=settings=>{settings&&settings.id&&settings.id in idTextureMap&&idTextureMap[settings.id]&&setUniformSlideSettingsOfMesh(idTextureMap[settings.id],settings)},this.createSlide=settings=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&settings&&settings.direction&&void 0!==settings.value){var geometry=new THREE.PlaneGeometry(1,1);geometry.translate(.5,.5,0);var uniforms=shader.getUniforms();uniforms.diffuse.value=this.texture.impl,uniforms.depth.value=this.texture.size.depth,uniforms.flipY.value=flipY;var options={fs:shader.fs,vs:shader.vs,uniforms:uniforms,glslVersion:shader.glslVersion,side:THREE.DoubleSide,transparent:!1},material=this.texture.getMaterial(options);material.needsUpdate=!0;var mesh=new THREE.Mesh(geometry,material);mesh.name=this.groupName,mesh.userData=this;var slideSettings={value:settings.value,direction:settings.direction,id:mesh.id};return textureSettings.push(slideSettings),setUniformSlideSettingsOfMesh(mesh,slideSettings),idTextureMap[mesh.id]=mesh,this.morph.add(mesh),this.boundingBoxUpdateRequired=!0,slideSettings}},this.getTextureSettings=()=>[...textureSettings],this.getTextureSettingsWithId=id=>{for(var i=0;i<textureSettings.length;i++)if(id===textureSettings[i].id)return _objectSpread({},textureSettings[i])},this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=slide=>{slide&&this.removeSlideWithId(slide.id)},this.removeSlideWithId=id=>{if(this.morph&&id in idTextureMap&&idTextureMap[id]){if(this.morph.getObjectById(id)){var slide=idTextureMap[id];this.morph.remove(slide),slide.clear(),slide.geometry&&slide.geometry.dispose(),slide.material&&slide.material.dispose(),this.boundingBoxUpdateRequired=!0}var index=textureSettings.findIndex(item=>item.id===id);-1<index&&textureSettings.splice(index,1)}},this.dispose=()=>{this.morph.children.forEach(slide=>{slide.geometry&&slide.geometry.dispose(),slide.material&&slide.material.dispose()}),(__webpack_require__(29).TexturePrimitive).prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};//Expand the boundingbox with slide settings
|
|
1045
|
+
*/this.modifySlideSettings=settings=>{settings&&settings.id&&settings.id in idTextureMap&&idTextureMap[settings.id]&&setUniformSlideSettingsOfMesh(idTextureMap[settings.id],settings)},this.createSlide=settings=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&settings&&settings.direction&&void 0!==settings.value){var geometry=new THREE.PlaneGeometry(1,1);geometry.translate(.5,.5,0);var uniforms=shader.getUniforms();uniforms.brightness.value=brightness,uniforms.contrast.value=contrast,uniforms.diffuse.value=this.texture.impl,uniforms.depth.value=this.texture.size.depth,uniforms.flipY.value=flipY;var options={fs:shader.fs,vs:shader.vs,uniforms:uniforms,glslVersion:shader.glslVersion,side:THREE.DoubleSide,transparent:!1},material=this.texture.getMaterial(options);material.needsUpdate=!0;var mesh=new THREE.Mesh(geometry,material);mesh.name=this.groupName,mesh.userData=this;var slideSettings={value:settings.value,direction:settings.direction,id:mesh.id};return textureSettings.push(slideSettings),setUniformSlideSettingsOfMesh(mesh,slideSettings),idTextureMap[mesh.id]=mesh,this.morph.add(mesh),this.boundingBoxUpdateRequired=!0,slideSettings}},this.getTextureSettings=()=>[...textureSettings],this.getTextureSettingsWithId=id=>{for(var i=0;i<textureSettings.length;i++)if(id===textureSettings[i].id)return _objectSpread({},textureSettings[i])},this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=slide=>{slide&&this.removeSlideWithId(slide.id)},this.removeSlideWithId=id=>{if(this.morph&&id in idTextureMap&&idTextureMap[id]){if(this.morph.getObjectById(id)){var slide=idTextureMap[id];this.morph.remove(slide),slide.clear(),slide.geometry&&slide.geometry.dispose(),slide.material&&slide.material.dispose(),this.boundingBoxUpdateRequired=!0}var index=textureSettings.findIndex(item=>item.id===id);-1<index&&textureSettings.splice(index,1)}},this.dispose=()=>{this.morph.children.forEach(slide=>{slide.geometry&&slide.geometry.dispose(),slide.material&&slide.material.dispose()}),(__webpack_require__(29).TexturePrimitive).prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};//Expand the boundingbox with slide settings
|
|
1038
1046
|
var expandBoxWithSettings=(box,settings,vector)=>{if(settings)switch(settings.direction.value){case 1:vector.copy(settings.slide.value),box.expandByPoint(vector),vector.setY(1),vector.setZ(1),box.expandByPoint(vector);break;case 2:vector.copy(settings.slide.value),box.expandByPoint(vector),vector.setX(1),vector.setZ(1),box.expandByPoint(vector);break;case 3:vector.copy(settings.slide.value),box.expandByPoint(vector),vector.setX(1),vector.setY(1),box.expandByPoint(vector);break;default:}};/**
|
|
1039
1047
|
* Get the bounding box of this slides.
|
|
1040
1048
|
* It uses the max and min of the slides position and the
|
|
@@ -1042,7 +1050,7 @@ var expandBoxWithSettings=(box,settings,vector)=>{if(settings)switch(settings.di
|
|
|
1042
1050
|
*
|
|
1043
1051
|
* @return {THREE.Box3}.
|
|
1044
1052
|
*/this.getBoundingBox=()=>{if(this.morph&&this.morph.children&&this.morph.visible&&this.boundingBoxUpdateRequired){this.cachedBoundingBox.makeEmpty();var vector=new THREE.Vector3(0,0,0);this.morph.children.forEach(slide=>{expandBoxWithSettings(this.cachedBoundingBox,slide.material.uniforms,vector)}),this.morph.updateMatrixWorld(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(rotation,position,scale)=>{var matrix=new THREE.Matrix4;matrix.set(rotation[0],rotation[1],rotation[2],0,rotation[3],rotation[4],rotation[5],0,rotation[6],rotation[7],rotation[8],0,0,0,0,0);var quaternion=new THREE.Quaternion().setFromRotationMatrix(matrix);this.morph.position.set(...position),this.morph.quaternion.copy(quaternion),this.morph.scale.set(...scale),this.morph.updateMatrix(),this.boundingBoxUpdateRequired=!0},this.setRenderOrder=order=>{//multiilayers
|
|
1045
|
-
this.morph.renderOrder=order},this.initialise=(textureData,finishCallback)=>{if(textureData){var locations=textureData.locations;locations&&0<locations.length&&(this.applyTransformation(locations[0].orientation,locations[0].position,locations[0].scale),"flipY"in locations[0]&&(flipY=locations[0].flipY)),this.createSlides(textureData.settings.slides),finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(this)}},this.showEdges=color=>{if(!edgesLine){var geometry=new THREE.BoxGeometry(1,1,1);geometry.translate(.5,.5,.5);var edges=new THREE.EdgesGeometry(geometry);edgesLine=new THREE.LineSegments(edges,new THREE.LineBasicMaterial({color})),this.group.add(edgesLine)}else edgesLine.material.color=color;edgesLine.visible=!0},this.hideEdges=()=>{edgesLine&&(edgesLine.visible=!1)}};/**
|
|
1053
|
+
this.morph.renderOrder=order},this.initialise=(textureData,finishCallback)=>{if(textureData){var locations=textureData.locations;locations&&0<locations.length&&(this.applyTransformation(locations[0].orientation,locations[0].position,locations[0].scale),"flipY"in locations[0]&&(flipY=locations[0].flipY)),this.createSlides(textureData.settings.slides),finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(this)}},this.showEdges=color=>{if(!edgesLine){var geometry=new THREE.BoxGeometry(1,1,1);geometry.translate(.5,.5,.5);var edges=new THREE.EdgesGeometry(geometry);edgesLine=new THREE.LineSegments(edges,new THREE.LineBasicMaterial({color})),this.group.add(edgesLine)}else edgesLine.material.color=color;edgesLine.visible=!0},this.getBrightness=()=>brightness,this.setBrightness=brightnessIn=>{brightness=brightnessIn,this.morph.children.forEach(mesh=>{var material=mesh.material;if("ShaderMaterial"===material.type){var uniforms=material.uniforms;uniforms.brightness.value=brightness,material.needsUpdate=!0}})},this.getContrast=()=>contrast,this.setContrast=contrastIn=>{0<=contrast&&(contrast=contrastIn,this.morph.children.forEach(mesh=>{var material=mesh.material;if("ShaderMaterial"===material.type){var uniforms=material.uniforms;uniforms.contrast.value=contrast,material.needsUpdate=!0}}))},this.hideEdges=()=>{edgesLine&&(edgesLine.visible=!1)}};/**
|
|
1046
1054
|
* Provides a class which create a texture stacks in a block
|
|
1047
1055
|
* with shaders allowing slices of texture to be displayed.
|
|
1048
1056
|
*
|
|
@@ -1058,7 +1066,7 @@ this.morph.renderOrder=order},this.initialise=(textureData,finishCallback)=>{if(
|
|
|
1058
1066
|
/* 28 */
|
|
1059
1067
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1060
1068
|
|
|
1061
|
-
var THREE=__webpack_require__(4),glslVersion=THREE.GLSL3,fs="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2DArray;\n\nuniform sampler2DArray diffuse;\nuniform bool discardAlpha;\nin vec3 vUw;\n\nout vec4 outColor;\n\nvoid main() {\n\n vec4 color = texture( diffuse, vUw );\n\n //
|
|
1069
|
+
var THREE=__webpack_require__(4),glslVersion=THREE.GLSL3,fs="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2DArray;\n\nuniform sampler2DArray diffuse;\nuniform bool discardAlpha;\nuniform float brightness;\nuniform float contrast;\nin vec3 vUw;\n\nout vec4 outColor;\n\nvoid main() {\n\n vec4 color = texture( diffuse, vUw );\n\n // discard if alpha is zero\n if (discardAlpha && color.a == 0.0) discard;\n // Apply brightness\n vec3 brightenedColor = color.rgb + vec3(brightness);\n // Apply contrast\n vec3 contrastedColor = (brightenedColor - vec3(0.5)) * contrast + vec3(0.5);\n outColor = vec4(contrastedColor, color.a);\n}\n",vs="\nout vec3 vUw;\nuniform float depth;\nuniform vec3 slide;\nuniform int direction;\nuniform bool flipY;\n\nvoid main() {\n\n vec3 slidePos = position.xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position.xyz, 1.0 );\n\n if (direction == 1)\n slidePos = vec3(slide.x, position.y, position.x);\n if (direction == 2)\n slidePos = vec3(position.x, slide.y, position.y);\n if (direction == 3)\n slidePos = vec3(position.x, position.y, slide.z);\n\n if (flipY)\n slidePos.y = 1.0 - slidePos.y;\n\n vUw.xyz = vec3(slidePos.x, slidePos.y, slidePos.z * depth);\n\n}\n",getUniforms=function(){return{brightness:{value:0},contrast:{value:1},depth:{value:1},discardAlpha:{value:!0},diffuse:{value:void 0},direction:{value:1},flipY:{value:!0},slide:{value:new THREE.Vector3(0,0,1)}}};exports.fs=fs,exports.vs=vs,exports.glslVersion=glslVersion,exports.getUniforms=getUniforms;
|
|
1062
1070
|
|
|
1063
1071
|
/***/ }),
|
|
1064
1072
|
/* 29 */
|