zincjs 1.16.6 → 1.16.8
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 +46 -20
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/label.js +64 -19
- package/src/primitives/pointset.js +50 -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.8","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,
|
|
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
|
*
|
|
@@ -640,10 +640,22 @@ var SpriteText=(__webpack_require__(7)["default"]);/**
|
|
|
640
640
|
*
|
|
641
641
|
* @param {Number} scaling - Scale to be set.
|
|
642
642
|
*/ /**
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
643
|
+
* Set depth test for sprite object.
|
|
644
|
+
*
|
|
645
|
+
* @param {Boolean} flag - Enable/disable depth test
|
|
646
|
+
*/ /**
|
|
647
|
+
* Set a new text for the label.
|
|
648
|
+
*
|
|
649
|
+
* @param {Number} scaling - Scale to be set.
|
|
650
|
+
*/ /**
|
|
651
|
+
* Set a new text for the label.
|
|
652
|
+
*
|
|
653
|
+
* @param {Number} scaling - Scale to be set.
|
|
654
|
+
*/ /**
|
|
655
|
+
* Set a new text for the label.
|
|
656
|
+
*
|
|
657
|
+
* @param {Number} scaling - Scale to be set.
|
|
658
|
+
*/ /**
|
|
647
659
|
* Free up the memory
|
|
648
660
|
*/ /**
|
|
649
661
|
* Get the intrnal sprite.
|
|
@@ -653,7 +665,7 @@ var SpriteText=(__webpack_require__(7)["default"]);/**
|
|
|
653
665
|
* Get the text.
|
|
654
666
|
*
|
|
655
667
|
* @return {String}
|
|
656
|
-
*/
|
|
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=>{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.dispose=()=>{//sprite.dispose();
|
|
657
669
|
},this.getSprite=()=>sprite,this.getString=()=>text};
|
|
658
670
|
|
|
659
671
|
/***/ }),
|
|
@@ -799,7 +811,7 @@ return!!(_this.video&&3<=_this.video.readyState)},function initialise(){document
|
|
|
799
811
|
/* 22 */
|
|
800
812
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
801
813
|
|
|
802
|
-
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=[];/**
|
|
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;/**
|
|
803
815
|
* Create the pointsets using geometry and material.
|
|
804
816
|
*
|
|
805
817
|
* @param {THREE.Geomtry} geometryIn - Geometry of points to be rendered.
|
|
@@ -809,7 +821,7 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
809
821
|
* time dependent.
|
|
810
822
|
* @param {Boolean} options.localMorphColour - A flag to indicate either the colour is
|
|
811
823
|
* time dependent.
|
|
812
|
-
*/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
|
|
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}};/**
|
|
813
825
|
* Add points to existing mesh if it exists, otherwise
|
|
814
826
|
* create a new one and add to it.
|
|
815
827
|
* @param {Array} coords -An array of three components coordinates.
|
|
@@ -825,6 +837,20 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
825
837
|
*
|
|
826
838
|
* @param {THREE.Color} colour - colour to be set
|
|
827
839
|
*/ /**
|
|
840
|
+
* Turn size attenuation on/off based on the flag.
|
|
841
|
+
*
|
|
842
|
+
* @param {Boolean} flag - Determin either size attenuation
|
|
843
|
+
* should be on or off.
|
|
844
|
+
*/ /**
|
|
845
|
+
* Turn size attenuation on/off based on the flag.
|
|
846
|
+
*
|
|
847
|
+
* @param {Number} fontWeightIn - Default value is 700
|
|
848
|
+
*/ /**
|
|
849
|
+
* Set the size of the label
|
|
850
|
+
*
|
|
851
|
+
* @param {Number} size - Size to set, default
|
|
852
|
+
* value is 1.
|
|
853
|
+
*/ /**
|
|
828
854
|
* Set the size of the points.
|
|
829
855
|
*
|
|
830
856
|
* @param {Number} size - size to be set.
|
|
@@ -846,7 +872,7 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
846
872
|
*
|
|
847
873
|
* @param {Boolean} flag - Determin either size attenuation
|
|
848
874
|
* should be on or off.
|
|
849
|
-
*/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});geometry.colorsNeedUpdate=!0,this.createMesh(geometry,material,
|
|
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(labelSize)},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)}};/**
|
|
850
876
|
* Provides an object which stores points and provides method which controls its position.
|
|
851
877
|
* This is created when a valid json file containing point is read into a {@link Zinc.Scene}
|
|
852
878
|
* object.
|
|
@@ -911,26 +937,26 @@ var THREE=__webpack_require__(4),toBufferGeometry=(__webpack_require__(5).toBuff
|
|
|
911
937
|
|
|
912
938
|
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;/**
|
|
913
939
|
* Read images from an array containg src locations.
|
|
914
|
-
*
|
|
940
|
+
*
|
|
915
941
|
* @async
|
|
916
942
|
* @param {Array} srcArrays - List of source location of the images.
|
|
917
943
|
*/ /**
|
|
918
944
|
* Get and create the material containing shaders and the textures.
|
|
919
945
|
* The texture must be read and ready before calling this function.
|
|
920
|
-
*
|
|
946
|
+
*
|
|
921
947
|
*
|
|
922
948
|
* @param {Object} options - Customise the material with the options object.
|
|
923
|
-
* @param {String} options.fs - string of the fragment shader used for
|
|
949
|
+
* @param {String} options.fs - string of the fragment shader used for
|
|
924
950
|
* visualisation.
|
|
925
|
-
* @param {String} options.vs - string of the vertex shader used for
|
|
951
|
+
* @param {String} options.vs - string of the vertex shader used for
|
|
926
952
|
* visualisation.
|
|
927
953
|
* @param {Object} options.uniforms - Containing the data to be passed into the shaders.
|
|
928
954
|
* @param {String} options.glslVersion - Version of glsl used for compile this shader.
|
|
929
|
-
*
|
|
955
|
+
*
|
|
930
956
|
*/(__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}}};/**
|
|
931
957
|
* Texture array object for holding array of images into
|
|
932
958
|
* texures unit that can be used by other texture primitives.
|
|
933
|
-
*
|
|
959
|
+
*
|
|
934
960
|
* @class
|
|
935
961
|
* @author Alan Wu
|
|
936
962
|
* @return {TextureArray}
|
|
@@ -984,7 +1010,7 @@ function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n){
|
|
|
984
1010
|
/* 27 */
|
|
985
1011
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
986
1012
|
|
|
987
|
-
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;/**
|
|
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,brightness=0,contrast=1;/**
|
|
988
1014
|
@typedef SLIDE_SETTINGS
|
|
989
1015
|
@type {Set}
|
|
990
1016
|
@property {String} direction - the value must be x, y or z, specify the
|
|
@@ -1008,7 +1034,7 @@ function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var
|
|
|
1008
1034
|
* Modify the mesh based on a setting
|
|
1009
1035
|
*
|
|
1010
1036
|
* @param {SLIDE_SETTINGS} settings - s.
|
|
1011
|
-
*/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
|
|
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.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
|
|
1012
1038
|
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:}};/**
|
|
1013
1039
|
* Get the bounding box of this slides.
|
|
1014
1040
|
* It uses the max and min of the slides position and the
|
|
@@ -1016,7 +1042,7 @@ var expandBoxWithSettings=(box,settings,vector)=>{if(settings)switch(settings.di
|
|
|
1016
1042
|
*
|
|
1017
1043
|
* @return {THREE.Box3}.
|
|
1018
1044
|
*/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
|
|
1019
|
-
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)}};/**
|
|
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.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)}};/**
|
|
1020
1046
|
* Provides a class which create a texture stacks in a block
|
|
1021
1047
|
* with shaders allowing slices of texture to be displayed.
|
|
1022
1048
|
*
|
|
@@ -1032,7 +1058,7 @@ this.morph.renderOrder=order},this.initialise=(textureData,finishCallback)=>{if(
|
|
|
1032
1058
|
/* 28 */
|
|
1033
1059
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1034
1060
|
|
|
1035
|
-
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 //
|
|
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;\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;
|
|
1036
1062
|
|
|
1037
1063
|
/***/ }),
|
|
1038
1064
|
/* 29 */
|