zincjs 1.16.0 → 1.16.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/build/zinc.frontend.js +1 -1
- package/build/zinc.js +47 -39
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/label.js +13 -10
- package/src/primitives/pointset.js +40 -9
- package/src/primitives/texturePrimitive.js +3 -3
- package/src/primitives/textureSlides.js +6 -6
- package/src/primitives/tubeLines.js +1 -1
- package/src/sceneLoader.js +29 -28
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.2","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 */
|
|
@@ -610,45 +610,45 @@ var THREE=__webpack_require__(4),Glyph=function(geometry,materialIn,idIn,glyphse
|
|
|
610
610
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
611
611
|
|
|
612
612
|
var SpriteText=(__webpack_require__(7)["default"]);/**
|
|
613
|
-
* Bitmap labels, this is used with {@link Glyph} to
|
|
613
|
+
* Bitmap labels, this is used with {@link Glyph} to
|
|
614
614
|
* provide labels.
|
|
615
|
-
*
|
|
615
|
+
*
|
|
616
616
|
* @param {String} textIn - Text to be displayed dwith the label.
|
|
617
617
|
* @param {THREE.Color} colour - Colour to be set for the label.
|
|
618
|
-
*
|
|
618
|
+
*
|
|
619
619
|
* @class
|
|
620
620
|
* @author Alan Wu
|
|
621
621
|
* @return {Label}
|
|
622
622
|
*/exports.Label=function(textIn,colour){var text=textIn,sprite=void 0;/**
|
|
623
623
|
* Get the current position in an array containing the x, y and z
|
|
624
624
|
* coordinates.
|
|
625
|
-
*
|
|
625
|
+
*
|
|
626
626
|
* @return {Array}
|
|
627
627
|
*/ /**
|
|
628
628
|
* Set the position of the label in 3D coordinates.
|
|
629
|
-
*
|
|
629
|
+
*
|
|
630
630
|
* @param {Number} x - x coordinate to be set.
|
|
631
631
|
* @param {Number} y - y coordinate to be set.
|
|
632
632
|
* @param {Number} z - z coordinate to be set.
|
|
633
633
|
*/ /**
|
|
634
634
|
* Set the colour of the label
|
|
635
|
-
*
|
|
635
|
+
*
|
|
636
636
|
* @param {THREE.Color} colour - colour to be set
|
|
637
637
|
*/ /**
|
|
638
638
|
* Scale the label.
|
|
639
|
-
*
|
|
639
|
+
*
|
|
640
640
|
* @param {Number} scaling - Scale to be set.
|
|
641
641
|
*/ /**
|
|
642
642
|
* Free up the memory
|
|
643
643
|
*/ /**
|
|
644
644
|
* Get the intrnal sprite.
|
|
645
|
-
*
|
|
645
|
+
*
|
|
646
646
|
* @return {THREE.Sprite}
|
|
647
647
|
*/ /**
|
|
648
648
|
* Get the text.
|
|
649
|
-
*
|
|
649
|
+
*
|
|
650
650
|
* @return {String}
|
|
651
|
-
*/sprite=colour?new SpriteText(text,.015,colour.getStyle()):new SpriteText(text,.015),sprite.fontFace="Asap",sprite.fontWeight=700,sprite.material.map.generateMipmaps=!1,sprite.material.sizeAttenuation=!1,sprite.center.x=-.05,sprite.center.y=0,this.getPosition=()=>sprite?[sprite.position.x,sprite.position.y,sprite.position.z]:[0,0,0],this.setPosition=(x,y,z)=>{sprite&&sprite.position.set(x,y,z)},this.setColour=colour=>{sprite.color=colour.getStyle()},this.setScale=scaling=>{sprite&&0<scaling&&sprite.scale.set(scaling,scaling,1)},this.dispose=()=>{//sprite.dispose();
|
|
651
|
+
*/sprite=colour?new SpriteText(text,.015,colour.getStyle()):new SpriteText(text,.015),sprite.fontFace="Asap",sprite.fontWeight=700,sprite.material.map.generateMipmaps=!1,sprite.material.sizeAttenuation=!1,sprite.center.x=-.05,sprite.center.y=0,this.getPosition=()=>sprite?[sprite.position.x,sprite.position.y,sprite.position.z]:[0,0,0],this.setPosition=(x,y,z)=>{sprite&&sprite.position.set(x,y,z)},this.setColour=colour=>{console.log(sprite),colour&&(sprite.color=colour.getStyle())},this.setScale=scaling=>{sprite&&0<scaling&&sprite.scale.set(scaling,scaling,1)},this.dispose=()=>{//sprite.dispose();
|
|
652
652
|
},this.getSprite=()=>sprite,this.getString=()=>text};
|
|
653
653
|
|
|
654
654
|
/***/ }),
|
|
@@ -796,7 +796,7 @@ return!!(_this.video&&3<=_this.video.readyState)},function initialise(){document
|
|
|
796
796
|
|
|
797
797
|
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=[];/**
|
|
798
798
|
* Create the pointsets using geometry and material.
|
|
799
|
-
*
|
|
799
|
+
*
|
|
800
800
|
* @param {THREE.Geomtry} geometryIn - Geometry of points to be rendered.
|
|
801
801
|
* @param {THREE.Material} materialIn - Material to be set for the lines.
|
|
802
802
|
* @param {Object} options - Provide various options
|
|
@@ -812,12 +812,20 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
812
812
|
* if the number of coords equals to the number labels provided.
|
|
813
813
|
* @param {Number} colour - A hex value of the colour for the points
|
|
814
814
|
*/ /**
|
|
815
|
+
* Set the colour of the pointset and its label using the hex value
|
|
816
|
+
*
|
|
817
|
+
* @param {Number} hex - hex value of color to be set
|
|
818
|
+
*/ /**
|
|
819
|
+
* Set the colour of the pointset and its label
|
|
820
|
+
*
|
|
821
|
+
* @param {THREE.Color} colour - colour to be set
|
|
822
|
+
*/ /**
|
|
815
823
|
* Set the size of the points.
|
|
816
|
-
*
|
|
824
|
+
*
|
|
817
825
|
* @param {Number} size - size to be set.
|
|
818
826
|
*/ /**
|
|
819
827
|
* Turn size attenuation on/off based on the flag.
|
|
820
|
-
*
|
|
828
|
+
*
|
|
821
829
|
* @param {Boolean} flag - Determin either size attenuation
|
|
822
830
|
* should be on or off.
|
|
823
831
|
*/ /**
|
|
@@ -826,14 +834,14 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
826
834
|
* Edit Vertice in index.
|
|
827
835
|
*/ /**
|
|
828
836
|
* Turn size attenuation on/off based on the flag.
|
|
829
|
-
*
|
|
837
|
+
*
|
|
830
838
|
* @param {Boolean} flag - Determin either size attenuation
|
|
831
839
|
* should be on or off.
|
|
832
|
-
*/this.addPoints=(coords,labels,colour)=>{if(coords&&0<coords.length){var current=this.drawRange-1,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,{localTimeEnabled:!1,localMorphColour:!1})}var end=current+coords.length,index=0;if(Array.isArray(labels)&&labels.length===coords.length||"string"==typeof labels)for(current;current+index<end;){var labelText="string"==typeof labels?labels:labels[index];addLabel(index,coords[index],labelText,colour),index++}this.region&&(this.region.pickableUpdateRequired=!0)}},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.render=(delta,playAnimation,cameraControls,options)=>{this.morph&&cameraControls&&(this.morph.sizePerPixel=cameraControls.pixelHeight),Pointset.prototype.render.call(this,delta,playAnimation,cameraControls,options)}};/**
|
|
840
|
+
*/this.addPoints=(coords,labels,colour)=>{if(coords&&0<coords.length){var current=this.drawRange-1,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,{localTimeEnabled:!1,localMorphColour:!1})}var end=current+coords.length,index=0;if(Array.isArray(labels)&&labels.length===coords.length||"string"==typeof labels)for(current;current+index<end;){var labelText="string"==typeof labels?labels:labels[index];addLabel(index,coords[index],labelText,colour),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.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.render=(delta,playAnimation,cameraControls,options)=>{this.morph&&cameraControls&&(this.morph.sizePerPixel=cameraControls.pixelHeight),Pointset.prototype.render.call(this,delta,playAnimation,cameraControls,options)}};/**
|
|
833
841
|
* Provides an object which stores points and provides method which controls its position.
|
|
834
842
|
* This is created when a valid json file containing point is read into a {@link Zinc.Scene}
|
|
835
843
|
* object.
|
|
836
|
-
*
|
|
844
|
+
*
|
|
837
845
|
* @class
|
|
838
846
|
* @author Alan Wu
|
|
839
847
|
* @return {Pointset}
|
|
@@ -974,12 +982,12 @@ function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var
|
|
|
974
982
|
direction the slide should be facing.
|
|
975
983
|
@property {Number} value - Normalised value of the location on direction.
|
|
976
984
|
@property {String} id - ID of the mesh, it is only available if the settings
|
|
977
|
-
is returned from {@link TextureSlides.createSlide} or
|
|
985
|
+
is returned from {@link TextureSlides.createSlide} or
|
|
978
986
|
{@link TextureSlides.getTextureSettings}.
|
|
979
987
|
*/ /**
|
|
980
988
|
* Create the slides required for visualisation based on the slide settings.
|
|
981
989
|
* The slides themselves are {THREE.PlanGeometry} objects.
|
|
982
|
-
*
|
|
990
|
+
*
|
|
983
991
|
* @param {SLIDE_SETTINGS} slideSettings - An array to each slide settings.
|
|
984
992
|
*/this.createSlides=slideSettings=>{slideSettings.forEach(slide=>this.createSlide(slide))};/**
|
|
985
993
|
* Set the value of the uniforms for a specific mesh in this
|
|
@@ -996,16 +1004,16 @@ var expandBoxWithSettings=(box,settings,vector)=>{if(settings)switch(settings.di
|
|
|
996
1004
|
* Get the bounding box of this slides.
|
|
997
1005
|
* It uses the max and min of the slides position and the
|
|
998
1006
|
* transformation to calculate the position of the box.
|
|
999
|
-
*
|
|
1007
|
+
*
|
|
1000
1008
|
* @return {THREE.Box3}.
|
|
1001
1009
|
*/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
|
|
1002
1010
|
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)}};/**
|
|
1003
1011
|
* Provides a class which create a texture stacks in a block
|
|
1004
1012
|
* with shaders allowing slices of texture to be displayed.
|
|
1005
|
-
*
|
|
1013
|
+
*
|
|
1006
1014
|
* @param {TextureArray} textureIn - An object of texture array
|
|
1007
1015
|
* holding texture information.
|
|
1008
|
-
*
|
|
1016
|
+
*
|
|
1009
1017
|
* @class
|
|
1010
1018
|
* @author Alan Wu
|
|
1011
1019
|
* @return {TextureSlides}
|
|
@@ -1023,20 +1031,20 @@ var THREE=__webpack_require__(4),glslVersion=THREE.GLSL3,fs="\nprecision highp f
|
|
|
1023
1031
|
|
|
1024
1032
|
var THREE=__webpack_require__(4),resolveURL=(__webpack_require__(5).resolveURL),TexturePrimitive=function(textureIn){/**
|
|
1025
1033
|
* Load texture data into this primitves.
|
|
1026
|
-
*
|
|
1034
|
+
*
|
|
1027
1035
|
* @param {Object} textureData - contains the informations about the textures.
|
|
1028
1036
|
* @param {Function} finishCallback - User's function to be called once texture's
|
|
1029
1037
|
* is loaded.
|
|
1030
1038
|
*/ /**
|
|
1031
1039
|
* Initialise a texture based on the provided textureData, this should be used
|
|
1032
1040
|
* internally only.
|
|
1033
|
-
*
|
|
1041
|
+
*
|
|
1034
1042
|
* @param {Object} textureData - contains the informations about the textures.
|
|
1035
1043
|
* @param {Function} finishCallback - User's function to be called once texture's
|
|
1036
1044
|
* is loaded.
|
|
1037
1045
|
*/(__webpack_require__(10).ZincObject).call(this),this.isTexturePrimitive=!0,this.texture=textureIn,this.load=(textureData,finishCallback)=>{if(textureData&&textureData.images&&textureData.images.source){var texture=new((__webpack_require__(25).TextureArray)),imgArray=[];textureData.images.source.forEach(img=>{imgArray.push(resolveURL(img))});var _this=this;texture.loadFromImages(imgArray).then(()=>{_this.texture=texture,_this.initialise(textureData,finishCallback)})}},this.initialise=(textureData,finishCallback)=>{finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(this)}};/**
|
|
1038
1046
|
* Provides a base class object which stores textures and rendering object.
|
|
1039
|
-
*
|
|
1047
|
+
*
|
|
1040
1048
|
* @class
|
|
1041
1049
|
* @author Alan Wu
|
|
1042
1050
|
* @return {TexturePrimitive}
|
|
@@ -1266,7 +1274,7 @@ module.exports = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGlu
|
|
|
1266
1274
|
var THREE=__webpack_require__(4),resolveURL=(__webpack_require__(5).resolveURL),createNewURL=(__webpack_require__(5).createNewURL),isRegionGroup=(__webpack_require__(5).isRegionGroup),STLLoader=(__webpack_require__(36).STLLoader),OBJLoader=(__webpack_require__(37).OBJLoader),PrimitivesLoader=(__webpack_require__(38).PrimitivesLoader);/**
|
|
1267
1275
|
* A helper class to help with reading / importing primitives and
|
|
1268
1276
|
* settings into a {@link Scene}.
|
|
1269
|
-
*
|
|
1277
|
+
*
|
|
1270
1278
|
* @class
|
|
1271
1279
|
* @param {Object} containerIn - Container to create the renderer on.
|
|
1272
1280
|
* @author Alan Wu
|
|
@@ -1275,7 +1283,7 @@ var THREE=__webpack_require__(4),resolveURL=(__webpack_require__(5).resolveURL),
|
|
|
1275
1283
|
* This function returns a three component array, which contains
|
|
1276
1284
|
* [totalsize, totalLoaded and errorDownload] of all the downloads happening
|
|
1277
1285
|
* in this scene.
|
|
1278
|
-
* @returns {Array}
|
|
1286
|
+
* @returns {Array}
|
|
1279
1287
|
*/this.getDownloadProgress=()=>{var totalSize=0,totalLoaded=0,unknownFound=!1;for(var key in this.progressMap){var progress=this.progressMap[key];totalSize+=progress[1],totalLoaded+=progress[0],0==progress[1]&&(unknownFound=!0)}return unknownFound&&(totalSize=0),[totalSize,totalLoaded,errorDownload]},this.onProgress=id=>xhr=>{this.progressMap[id]=[xhr.loaded,xhr.total]},this.onError=finishCallback=>xhr=>{--this.toBeDownloaded,errorDownload=!0,console.error("There is an issue with external resource ".concat(null!==xhr&&void 0!==xhr&&xhr.responseURL?": "+(null===xhr||void 0===xhr?void 0:xhr.responseURL):"","."));finishCallback&&finishCallback({type:"Error",xhr})};var loadMultipleViews=(referenceURL,views)=>{var defaultView=views.Default;if(views.Inline)scene.setupMultipleViews(defaultView,views.Entries);else{var promises=[],_loop=function _loop(key){referenceURL&&(newURL=createNewURL(value,referenceURL),promises.push(new Promise((resolve,reject)=>{// Add parameters if we are sent them
|
|
1280
1288
|
fetch(newURL).then(response=>response.json()).then(data=>resolve({key:key,data:data})).catch(data=>reject(data))})))};for(var[key,value]of Object.entries(views.Entries))_loop(key);Promise.all(promises).then(values=>{var entries={};values.forEach(entry=>{entries[entry.key]=entry.data}),scene.setupMultipleViews(defaultView,entries);var zincCameraControls=scene.getZincCameraControls();zincCameraControls&&zincCameraControls.setCurrentViewport(defaultView),viewLoaded=!0})}};/**
|
|
1281
1289
|
* Load the viewport from an external location provided by the url.
|
|
@@ -1283,7 +1291,7 @@ fetch(newURL).then(response=>response.json()).then(data=>resolve({key:key,data:d
|
|
|
1283
1291
|
*/this.loadViewURL=(url,finishCallback)=>{this.toBeDownloaded+=1;var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState)if(200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.setupMultipleViews("default",{default:viewData}),scene.resetView(),viewLoaded=!0,--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback()}else this.onError(finishCallback)({responseURL:url})};var requestURL=resolveURL(url);xmlhttp.open("GET",requestURL,!0),xmlhttp.send()},this.loadModelsURL=(region,urls,colours,opacities,timeEnabled,morphColour,finishCallback)=>{var number=urls.length;this.toBeDownloaded+=number;for(var i=0;i<number;i++){var filename=urls[i],colour=(__webpack_require__(0).defaultMaterialColor),opacity=(__webpack_require__(0).defaultOpacity);colours!=null&&colours[i]!=null&&(colour=!!colours[i]),opacities!=null&&opacities[i]!=null&&(opacity=opacities[i]);var localTimeEnabled=0;timeEnabled!=null&&timeEnabled[i]!=null&&(localTimeEnabled=!!timeEnabled[i]);var localMorphColour=0;morphColour!=null&&morphColour[i]!=null&&(localMorphColour=!!morphColour[i]),primitivesLoader.load(resolveURL(filename),meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))}},this.loadFromViewURL=(targetRegion,jsonFilePrefix,finishCallback)=>{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.loadView(viewData);for(var filename,urls=[],filename_prefix=jsonFilePrefix+"_",i=0;i<viewData.numberOfResources;i++)filename=filename_prefix+(i+1)+".json",urls.push(filename);this.loadModelsURL(targetRegion,urls,viewData.colour,viewData.opacity,viewData.timeEnabled,viewData.morphColour,finishCallback)}};var requestURL=resolveURL(jsonFilePrefix+"_view.json");xmlhttp.open("GET",requestURL,!0),xmlhttp.send()};//Internal loader for a regular zinc geometry.
|
|
1284
1292
|
var linesloader=(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,lod,tubeLines,finishCallback)=>(geometry,materials)=>{var newLines=tubeLines?new((__webpack_require__(39).TubeLines)):new((__webpack_require__(24).Lines)),material=void 0;materials&&materials[0]&&(material=new THREE.LineBasicMaterial({color:materials[0].color.clone()}),1>materials[0].opacity&&(material.transparent=!0),material.opacity=materials[0].opacity,material.morphTargets=localTimeEnabled,material.vertexColors=materials[0].vertexColors);var options={localTimeEnabled:localTimeEnabled,localMorphColour:localMorphColour};if(newLines&&(newLines.createLineSegment(geometry,material,options),newLines.setName(groupName),newLines.setAnatomicalId(anatomicalId),newLines.setRenderOrder(renderOrder),region.addZincObject(newLines),newLines.setDuration(scene.getDuration()),lod&&lod.levels))for(var[key,value]of Object.entries(lod.levels))newLines.addLOD(primitivesLoader,key,value.URL,value.Index,lod.preload);--this.toBeDownloaded,geometry.dispose(),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newLines)};/**
|
|
1285
1293
|
* Load lines into this scene object.
|
|
1286
|
-
*
|
|
1294
|
+
*
|
|
1287
1295
|
* @param {Boolean} timeEnabled - Indicate if morphing is enabled.
|
|
1288
1296
|
* @param {Boolean} morphColour - Indicate if color morphing is enabled.
|
|
1289
1297
|
* @param {STRING} groupName - name to assign the pointset's groupname to.
|
|
@@ -1293,17 +1301,17 @@ var linesloader=(region,localTimeEnabled,localMorphColour,groupName,anatomicalId
|
|
|
1293
1301
|
//Internal loader for zinc pointset.
|
|
1294
1302
|
/**
|
|
1295
1303
|
* Read a STL file into this scene, the geometry will be presented as
|
|
1296
|
-
* {@link Zinc.Geometry}.
|
|
1297
|
-
*
|
|
1304
|
+
* {@link Zinc.Geometry}.
|
|
1305
|
+
*
|
|
1298
1306
|
* @param {STRING} url - location to the STL file.
|
|
1299
1307
|
* @param {STRING} groupName - name to assign the geometry's groupname to.
|
|
1300
1308
|
* @param {Function} finishCallback - Callback function which will be called
|
|
1301
1309
|
* once the STL geometry is succssfully loaded.
|
|
1302
1310
|
*/this.loadSTL=(region,url,groupName,finishCallback)=>{this.toBeDownloaded+=1;var colour=(__webpack_require__(0).defaultMaterialColor),opacity=(__webpack_require__(0).defaultOpacity),loader=new STLLoader;loader.crossOrigin="Anonymous",loader.load(resolveURL(url),meshloader(region,colour,opacity,!1,!1,groupName,void 0,void 0,void 0,finishCallback))},this.loadOBJ=(region,url,groupName,finishCallback)=>{this.toBeDownloaded+=1;var colour=(__webpack_require__(0).defaultMaterialColor),opacity=(__webpack_require__(0).defaultOpacity),loader=new OBJLoader;loader.crossOrigin="Anonymous",loader.load(resolveURL(url),meshloader(region,colour,opacity,!1,!1,groupName,void 0,void 0,void 0,finishCallback))};/**
|
|
1303
|
-
* Load a geometry into this scene, this is a subsequent called from
|
|
1311
|
+
* Load a geometry into this scene, this is a subsequent called from
|
|
1304
1312
|
* {@link Zinc.Scene#loadMetadataURL}, although it can be used to read
|
|
1305
1313
|
* in geometry into the scene externally.
|
|
1306
|
-
*
|
|
1314
|
+
*
|
|
1307
1315
|
* @param {String} url - regular json model file providing geometry.
|
|
1308
1316
|
* @param {Boolean} timeEnabled - Indicate if geometry morphing is enabled.
|
|
1309
1317
|
* @param {Boolean} morphColour - Indicate if color morphing is enabled.
|
|
@@ -1315,22 +1323,22 @@ var linesloader=(region,localTimeEnabled,localMorphColour,groupName,anatomicalId
|
|
|
1315
1323
|
//allCompletedCallback is called
|
|
1316
1324
|
/**
|
|
1317
1325
|
* Load a pointset into this scene object.
|
|
1318
|
-
*
|
|
1326
|
+
*
|
|
1319
1327
|
* @param {Boolean} timeEnabled - Indicate if morphing is enabled.
|
|
1320
1328
|
* @param {Boolean} morphColour - Indicate if color morphing is enabled.
|
|
1321
1329
|
* @param {STRING} groupName - name to assign the pointset's groupname to.
|
|
1322
1330
|
* @param {Function} finishCallback - Callback function which will be called
|
|
1323
1331
|
* once the glyphset is succssfully load in.
|
|
1324
|
-
*/this.loadPointsetURL=(region,url,timeEnabled,morphColour,groupName,finishCallback,options)=>{var localTimeEnabled=0;this.toBeDownloaded+=1,timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var isInline=!!(options&&options.isInline)&&options.isInline,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0;if(isInline){var object=primitivesLoader.parse(url);pointsetloader(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)(object.geometry,object.materials)}else primitivesLoader.load(url,pointsetloader(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback),this.onProgress(url),this.onError(finishCallback),options.loaderOptions)};var loadTexture=(region,referenceURL,textureData,groupName,finishCallback,options)=>{var isInline=options&&options.isInline?options.isInline:void 0,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0,newTexture=void 0;if(textureData){if(referenceURL&&textureData.images&&textureData.images.source)for(var _newURL,source=textureData.images.source,i=0;i<source.length;i++)_newURL=createNewURL(source[i],referenceURL),textureData.images.source[i]=_newURL;if("slides"===textureData.type&&(newTexture=new((__webpack_require__(27).TextureSlides))),newTexture){newTexture.groupName=groupName;var myCallback=()=>{
|
|
1332
|
+
*/this.loadPointsetURL=(region,url,timeEnabled,morphColour,groupName,finishCallback,options)=>{var localTimeEnabled=0;this.toBeDownloaded+=1,timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var isInline=!!(options&&options.isInline)&&options.isInline,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0;if(isInline){var object=primitivesLoader.parse(url);pointsetloader(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)(object.geometry,object.materials)}else primitivesLoader.load(url,pointsetloader(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback),this.onProgress(url),this.onError(finishCallback),options.loaderOptions)};var loadTexture=(region,referenceURL,textureData,groupName,finishCallback,options)=>{var isInline=options&&options.isInline?options.isInline:void 0,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0,newTexture=void 0;if(textureData){if(referenceURL&&textureData.images&&textureData.images.source)for(var _newURL,source=textureData.images.source,i=0;i<source.length;i++)_newURL=createNewURL(source[i],referenceURL),textureData.images.source[i]=_newURL;if("slides"===textureData.type&&(newTexture=new((__webpack_require__(27).TextureSlides))),newTexture){newTexture.groupName=groupName;var myCallback=()=>{region.addZincObject(newTexture),--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newTexture)};++this.toBeDownloaded,newTexture.load(textureData,myCallback,isInline),newTexture.setAnatomicalId(anatomicalId),newTexture.setRenderOrder(renderOrder)}}},onLoadTextureReady=(region,xmlhttp,groupName,finishCallback,options)=>()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var textureData=JSON.parse(xmlhttp.responseText);loadTexture(region,xmlhttp.responseURL,textureData,groupName,finishCallback,options)}};//Load a glyphset into this scene.
|
|
1325
1333
|
/**
|
|
1326
1334
|
* Load a texture into this scene object.
|
|
1327
|
-
*
|
|
1335
|
+
*
|
|
1328
1336
|
* @param {STRING} groupName - name to assign the pointset's groupname to.
|
|
1329
1337
|
* @param {Function} finishCallback - Callback function which will be called
|
|
1330
1338
|
* once the glyphset is succssfully load in.
|
|
1331
1339
|
*/this.loadTextureURL=(region,url,groupName,finishCallback,options)=>{var isInline=!!(options&&options.isInline)&&options.isInline;if(isInline)loadTexture(region,void 0,url,groupName,finishCallback,options);else{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=onLoadTextureReady(region,xmlhttp,groupName,finishCallback,options),xmlhttp.open("GET",resolveURL(url),!0),xmlhttp.send()}},this.loadGlyphsetURL=(region,metaurl,glyphurl,groupName,finishCallback,options)=>{var isInline=!!(options&&options.isInline)&&options.isInline;if(isInline)loadGlyphset(region,metaurl,glyphurl,groupName,finishCallback,options);else{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=onLoadGlyphsetReady(region,xmlhttp,glyphurl,groupName,finishCallback,options),xmlhttp.open("GET",resolveURL(metaurl),!0),xmlhttp.send()}};/**
|
|
1332
1340
|
* Add a user provided {THREE.Geometry} into the scene as zinc geometry.
|
|
1333
|
-
*
|
|
1341
|
+
*
|
|
1334
1342
|
* @param {Three.Geometry} geometry - The threejs geometry to be added as {@link Zinc.Geometry}.
|
|
1335
1343
|
* @param {THREE.Color} color - Colour to be assigned to this geometry, overrided if materialIn is provided.
|
|
1336
1344
|
* @param {Number} opacity - Opacity to be set for this geometry, overrided if materialIn is provided.
|
|
@@ -1339,7 +1347,7 @@ var linesloader=(region,localTimeEnabled,localMorphColour,groupName,anatomicalId
|
|
|
1339
1347
|
* @param {Boolean} external - Set this to true if morph geometry is present, overrided if materialIn is provided.
|
|
1340
1348
|
* @param {Function} finishCallback - Callback once the geometry has been added succssfully.
|
|
1341
1349
|
* @param {THREE.Material} materialIn - Material to be set for this geometry if it is present.
|
|
1342
|
-
*
|
|
1350
|
+
*
|
|
1343
1351
|
* @returns {Zinc.Geometry}
|
|
1344
1352
|
*/var addZincGeometry=(region,geometryIn,colour,opacity,localTimeEnabled,localMorphColour,finishCallback,materialIn,groupName,renderOrder,anatomicalId)=>{var options={colour:colour,opacity:opacity,localTimeEnabled:localTimeEnabled,localMorphColour:localMorphColour},newGeometry=new((__webpack_require__(3).Geometry));return newGeometry.createMesh(geometryIn,materialIn,options),newGeometry.getMorph()?(newGeometry.setName(groupName),newGeometry.setRenderOrder(renderOrder),newGeometry.setAnatomicalId(anatomicalId),region&®ion.addZincObject(newGeometry),newGeometry.setDuration(scene.getDuration()),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newGeometry),newGeometry.videoHandler&&scene.setVideoHandler(newGeometry.videoHandler),newGeometry):void 0},meshloader=(region,colour,opacity,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,options,finishCallback)=>(geometry,materials)=>{var material;materials&&materials[0]&&(material=materials[0]);var zincGeometry=addZincGeometry(region,geometry,colour,opacity,localTimeEnabled,localMorphColour,void 0,material,groupName,renderOrder,anatomicalId);if(options.lod&&options.lod.levels)for(var[key,value]of Object.entries(options.lod.levels))zincGeometry.addLOD(primitivesLoader,key,value.URL,value.Index,options.lod.preload);--this.toBeDownloaded,geometry.dispose(),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(zincGeometry)},parseDuration=durationString=>{var regex=/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/,[,years,months,weeks,days,hours,mins,secs]=durationString.match(regex);return{years:years,months:months,weeks:weeks,days:days,hours:hours,mins:mins,secs:secs}};//Internal loader for a regular zinc geometry.
|
|
1345
1353
|
//Turn ISO 8601 duration string into an array.
|
|
@@ -1350,7 +1358,7 @@ if(item.Duration){var duration=parseDuration(item.Duration);scene.setDurationFro
|
|
|
1350
1358
|
var readPrimitivesItem=(region,referenceURL,item,order,finishCallback)=>{if(item){var _newURL2=void 0,isInline=!1;item.URL?(_newURL2=item.URL,referenceURL&&(_newURL2=createNewURL(_newURL2,referenceURL))):item.Inline&&(_newURL2=item.Inline.URL,isInline=!0);var lod={};if(item.LOD&&item.LOD.Levels){lod.preload=!!item.LOD.Preload,lod.levels={};for(var[key,value]of Object.entries(item.LOD.Levels))lod.levels[key]={},lod.levels[key].URL=createNewURL(value.URL,referenceURL),lod.levels[key].Index=value.Index}var groupName=item.GroupName;(groupName===void 0||""===groupName)&&(groupName="_Unnamed");var options={loaderOptions:{index:item.Index},isInline:isInline,fileFormat:item.FileFormat,anatomicalId:item.AnatomicalId,compression:item.compression,tubeLines:item.tubeLines,lod:lod,renderOrder:order};switch(item.Type){case"Surfaces":loadSurfaceURL(region,_newURL2,item.MorphVertices,item.MorphColours,groupName,finishCallback,options);break;case"Glyph":var newGeometryURL;isInline?newGeometryURL=item.Inline.GlyphGeometriesURL:(newGeometryURL=item.GlyphGeometriesURL,newGeometryURL=createNewURL(item.GlyphGeometriesURL,referenceURL)),item.DisplayLabels&&(options.displayLabels=!0),this.loadGlyphsetURL(region,_newURL2,newGeometryURL,groupName,finishCallback,options);break;case"Points":this.loadPointsetURL(region,_newURL2,item.MorphVertices,item.MorphColours,groupName,finishCallback,options);break;case"Lines":this.loadLinesURL(region,_newURL2,item.MorphVertices,item.MorphColours,groupName,finishCallback,options);break;case"Texture":this.loadTextureURL(region,_newURL2,groupName,finishCallback,options);break;default:}}},readViewAndSettingsItem=(referenceURL,item,finishCallback)=>{if(item){var _newURL3=void 0,isInline=!1;switch(item.URL?(_newURL3=item.URL,referenceURL&&(_newURL3=createNewURL(item.URL,referenceURL))):item.Inline&&(_newURL3=item.Inline.URL,isInline=!0),item.Type){case"View":isInline?(scene.setupMultipleViews("default",{default:_newURL3}),viewLoaded=!0,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback()):this.loadViewURL(_newURL3,finishCallback);break;case"Settings":this.loadSettings(item);break;default:}}};//Function to read the view item first
|
|
1351
1359
|
/**
|
|
1352
1360
|
* Load GLTF into this scene object.
|
|
1353
|
-
*
|
|
1361
|
+
*
|
|
1354
1362
|
* @param {String} url - URL to the GLTF file
|
|
1355
1363
|
* @param {Function} finishCallback - Callback function which will be called
|
|
1356
1364
|
* once the glyphset is succssfully load in.
|
|
@@ -1361,7 +1369,7 @@ for(var filteredMetada=supplementMetadataInArray(metadata,options),numberOfObjec
|
|
|
1361
1369
|
metadata.Settings&&this.loadSettings(metadata.Settings),metadata.Views&&loadMultipleViews(referenceURL,metadata.Views,referenceURL),metadata.Regions&&loadRegions(targetRegion,referenceURL,metadata.Regions,callback)};/**
|
|
1362
1370
|
* Load a metadata file from the provided URL into this scene. Once
|
|
1363
1371
|
* succssful scene proceeds to read each items into scene for visualisations.
|
|
1364
|
-
*
|
|
1372
|
+
*
|
|
1365
1373
|
* @param {String} url - Location of the metadata file
|
|
1366
1374
|
* @param {Function} finishCallback - Callback function which will be called
|
|
1367
1375
|
* @param {options} Optional settings, it can be used to ignore some regions/groups
|