zincjs 1.16.9 → 1.17.0
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 +19 -11
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/lines2.js +4 -0
- package/src/primitives/pointset.js +24 -1
- package/src/primitives/textureSlides.js +18 -0
- package/src/primitives/zincObject.js +19 -0
- package/src/sceneLoader.js +9 -1
- package/src/utilities.js +45 -0
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.
|
|
35
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.17.0","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 */
|
|
@@ -138,7 +138,11 @@ var cons=Uint8Array;newIndices.length>=Math.pow(2,8)&&(cons=Uint16Array),newIndi
|
|
|
138
138
|
* comparePath will be used to compare both region and group if it
|
|
139
139
|
* is a single string without /
|
|
140
140
|
*/function isRegionGroup(regionPath,groupName,comparePath){if(comparePath){var region=regionPath?regionPath:"",group=groupName?groupName:"",n=comparePath.lastIndexOf("/");if(-1<n){var r=void 0,g=void 0;if(r=comparePath.substring(0,n),g=comparePath.substring(n+1),("*"===r||"**"===r||r.toLowerCase()===region.toLowerCase())&&("*"===g||"**"===g||g.toLowerCase()===group.toLowerCase()))return!0}else//one single value if one of the region / group matches
|
|
141
|
-
if(region.toLowerCase()===comparePath.toLowerCase()||group.toLowerCase()===comparePath.toLowerCase())return!0}return!1}
|
|
141
|
+
if(region.toLowerCase()===comparePath.toLowerCase()||group.toLowerCase()===comparePath.toLowerCase())return!0}return!1}function removeVertexAtIndex(geometry,index,maintainLength){var positionAttribute=geometry.getAttribute("position"),normalAttribute=geometry.getAttribute("normal");// Also update other attributes
|
|
142
|
+
if(positionAttribute){// e.g., 3 for x, y, z
|
|
143
|
+
// Helper to remove elements from a typed array
|
|
144
|
+
var itemSize=positionAttribute.itemSize,start=index*itemSize,deleteCount=itemSize,removed=!1,removeElements=(attribute,name)=>{var removed=!1,array=Array.from(attribute.array);if(array.length>=start+deleteCount){array.splice(start,deleteCount),maintainLength&&array.concat(Array(deleteCount).fill(0)),removed=!0;var newArray=new Float32Array(array);geometry.setAttribute(name,new THREE.BufferAttribute(newArray,itemSize)),geometry.getAttribute(name).needsUpdate=!0}// Create new BufferAttribute with the modified array
|
|
145
|
+
return removed};return removed=removeElements(positionAttribute,"position"),normalAttribute&&removeElements(normalAttribute,"normal"),null!==geometry.index&&console.warn("Removing vertices from indexed geometry requires index buffer recalculation."),removed}}exports.getBoundingBox=getBoundingBox,exports.createNewURL=createNewURL,exports.createBufferGeometry=createBufferGeometry,exports.getCircularTexture=getCircularTexture,exports.resolveURL=resolveURL,exports.loadExternalFile=loadExternalFile,exports.loadExternalFiles=loadExternalFiles,exports.PhongToToon=PhongToToon,exports.createNewSpriteText=createNewSpriteText,exports.isRegionGroup=isRegionGroup,exports.removeVertexAtIndex=removeVertexAtIndex;
|
|
142
146
|
|
|
143
147
|
/***/ }),
|
|
144
148
|
/* 6 */
|
|
@@ -265,7 +269,7 @@ module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABz
|
|
|
265
269
|
/* 10 */
|
|
266
270
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
267
271
|
|
|
268
|
-
var THREE=__webpack_require__(4),createBufferGeometry=(__webpack_require__(5).createBufferGeometry),resolveURL=(__webpack_require__(5).resolveURL),uniqueiId=0,getUniqueId=function(){return"pr"+uniqueiId++},ZincObject=function(){// THREE.Mesh
|
|
272
|
+
var THREE=__webpack_require__(4),createBufferGeometry=(__webpack_require__(5).createBufferGeometry),removeVertexAtIndex=(__webpack_require__(5).removeVertexAtIndex),resolveURL=(__webpack_require__(5).resolveURL),uniqueiId=0,getUniqueId=function(){return"pr"+uniqueiId++},ZincObject=function(){// THREE.Mesh
|
|
269
273
|
/**
|
|
270
274
|
* Groupname given to this geometry.
|
|
271
275
|
*/ /**
|
|
@@ -438,6 +442,8 @@ this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new THREE
|
|
|
438
442
|
*/ /**
|
|
439
443
|
* Add lod from an url into the lod object.
|
|
440
444
|
*/ /**
|
|
445
|
+
* Add lod from an url into the lod object.
|
|
446
|
+
*/ /**
|
|
441
447
|
* Set the objects position.
|
|
442
448
|
*/ /**
|
|
443
449
|
* Set the objects scale.
|
|
@@ -448,7 +454,7 @@ this._lod.setVertexColors(vertexColors)},ZincObject.prototype.getColour=function
|
|
|
448
454
|
return this.getBoundingBox(),position.copy(this.center),position},ZincObject.prototype.getBoundingBox=function(){if(this.visible){var morph=this._lod.getCurrentMorph();if(morph&&morph.visible)return this.boundingBoxUpdateRequired&&((__webpack_require__(5).getBoundingBox)(morph,this.cachedBoundingBox,this._b1,this._v1,this._v2),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),this.boundingBoxUpdateRequired=!1),this.cachedBoundingBox}},ZincObject.prototype.dispose=function(){//multilayyers
|
|
449
455
|
this._lod.dispose(),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.group=void 0,this.clipAction=void 0,this.groupName=void 0},ZincObject.prototype.markerIsRequired=function(options){return!!(this.visible&&("on"===this.markerMode||options&&options.displayMarkers&&"inherited"===this.markerMode))},ZincObject.prototype.updateMarker=function(playAnimation,options){if(!1==playAnimation&&this.markerIsRequired(options)){var ndcToBeUpdated=options.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new((__webpack_require__(14).Marker))(this),this.markerUpdateRequired=!0),this.markerUpdateRequired){var position=this.getClosestVertex(!1);position&&(this.marker.setPosition(position.x,position.y,position.z),this.markerUpdateRequired=!1)}this.marker.isEnabled()||(options.markersList&&!(this.marker.uuid in options.markersList)&&(ndcToBeUpdated=!0,options.markersList[this.marker.uuid]=this.marker),this.marker.enable(),this.group.add(this.marker.morph)),this.marker.setNumber(this.markerNumber),this.markerImgURL?this.marker.loadUserSprite(this.markerImgURL):this.marker.setDefaultSprite(),options&&options.camera&&(ndcToBeUpdated||options.markerCluster.markerUpdateRequired)&&(this.marker.updateNDC(options.camera.cameraObject),options.markerCluster.markerUpdateRequired=!0)}}else this.marker&&this.marker.isEnabled()&&(this.marker.disable(),this.group.remove(this.marker.morph),options.markersList&&this.marker.uuid in options.markersList&&(options.markerCluster.markerUpdateRequired=!0,delete options.markersList[this.marker.uuid])),this.markerUpdateRequired=!0},ZincObject.prototype.processMarkerVisual=function(min,max){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(min,max)},ZincObject.prototype.initiateMorphColor=function(){1==this.morphColour&&this._lod.updateMorphColorAttribute(!1)},ZincObject.prototype.setRenderOrder=function(renderOrder){//multiilayers
|
|
450
456
|
this._lod.setRenderOrder(renderOrder)},ZincObject.prototype.getClosestVertexDOMElementCoords=function(scene){if(scene&&scene.camera){var inView=!0,position=this.getClosestVertex(!0);return position.project(scene.camera),position.z=Math.min(Math.max(position.z,0),1),(1<position.x||-1>position.x||1<position.y||-1>position.y)&&(inView=!1),scene.getZincCameraControls().getRelativeCoordsFromNDC(position.x,position.y,position),{position,inView}}},ZincObject.prototype.setMarkerMode=function(mode,options){mode!==this.markerMode&&(this.markerMode="on"===mode||"off"===mode?mode:"inherited",this.region&&(this.region.pickableUpdateRequired=!0)),options&&(this.markerNumber=options.number,this.markerImgURL=options.imgURL)},ZincObject.prototype.render=function(delta,playAnimation,cameraControls,options){if(this.visible&&!(this.timeEnabled&&playAnimation)&&this._lod.update(cameraControls,this.center),!0==playAnimation){if(this.clipAction&&this.isTimeVarying())this.mixer.update(delta);else{var targetTime=this.inbuildTime+delta;targetTime>this.duration&&(targetTime-=this.duration),this.inbuildTime=targetTime}//multilayers
|
|
451
|
-
this.visible&&0!=delta&&(this.boundingBoxUpdateRequired=!0,1==this.morphColour&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(playAnimation,options)},ZincObject.prototype.addLOD=function(loader,level,url,index,preload){this._lod.addLevelFromURL(loader,level,url,index,preload)},ZincObject.prototype.addVertices=function(coords){var mesh=this.getMorph(),geometry=void 0;if(!mesh)geometry=createBufferGeometry(500,coords),this.drawRange=coords.length;else if(-1<this.drawRange){var positionAttribute=mesh.geometry.getAttribute("position");coords.forEach(coord=>{positionAttribute.setXYZ(this.drawRange,coord[0],coord[1],coord[2]),++this.drawRange}),positionAttribute.needsUpdate=!0,mesh.geometry.setDrawRange(0,this.drawRange),mesh.geometry.computeBoundingBox(),mesh.geometry.computeBoundingSphere(),geometry=mesh.geoemtry,this.boundingBoxUpdateRequired=!0}return geometry},ZincObject.prototype.setPosition=function(x,y,z){var group=this.getGroup();group&&(group.position.set(x,y,z),group.matrixWorldNeedsUpdate=!0,group.updateMatrix(),group.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},ZincObject.prototype.loadAdditionalSources=function(primitivesLoader){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))},ZincObject.prototype.setScaleAll=function(scale){var group=this.getGroup();group&&(group.scale.set(scale,scale,scale),group.updateMatrix(),this.boundingBoxUpdateRequired=!0)},exports.ZincObject=ZincObject;
|
|
457
|
+
this.visible&&0!=delta&&(this.boundingBoxUpdateRequired=!0,1==this.morphColour&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(playAnimation,options)},ZincObject.prototype.addLOD=function(loader,level,url,index,preload){this._lod.addLevelFromURL(loader,level,url,index,preload)},ZincObject.prototype.addVertices=function(coords){var mesh=this.getMorph(),geometry=void 0;if(!mesh)geometry=createBufferGeometry(500,coords),this.drawRange=coords.length;else if(-1<this.drawRange){var positionAttribute=mesh.geometry.getAttribute("position");coords.forEach(coord=>{positionAttribute.setXYZ(this.drawRange,coord[0],coord[1],coord[2]),++this.drawRange}),positionAttribute.needsUpdate=!0,mesh.geometry.setDrawRange(0,this.drawRange),mesh.geometry.computeBoundingBox(),mesh.geometry.computeBoundingSphere(),geometry=mesh.geoemtry,this.boundingBoxUpdateRequired=!0}return geometry},ZincObject.prototype.deleteVertices=function(index){var mesh=this.getMorph();return!!(null!==mesh&&void 0!==mesh&&mesh.geometry&&this.drawRange>=index&&removeVertexAtIndex(mesh.geometry,index,!0))&&(--this.drawRange,mesh.geometry.setDrawRange(0,this.drawRange),mesh.geometry.computeBoundingBox(),mesh.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0)},ZincObject.prototype.setPosition=function(x,y,z){var group=this.getGroup();group&&(group.position.set(x,y,z),group.matrixWorldNeedsUpdate=!0,group.updateMatrix(),group.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},ZincObject.prototype.loadAdditionalSources=function(primitivesLoader){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))},ZincObject.prototype.setScaleAll=function(scale){var group=this.getGroup();group&&(group.scale.set(scale,scale,scale),group.updateMatrix(),this.boundingBoxUpdateRequired=!0)},exports.ZincObject=ZincObject;
|
|
452
458
|
|
|
453
459
|
/***/ }),
|
|
454
460
|
/* 11 */
|
|
@@ -825,7 +831,7 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
825
831
|
* time dependent.
|
|
826
832
|
* @param {Boolean} options.localMorphColour - A flag to indicate either the colour is
|
|
827
833
|
* time dependent.
|
|
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}};/**
|
|
834
|
+
*/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}},removeLabel=index=>{var label=labelSets[index];if(label){var sprite=label.getSprite();this.group.remove(sprite),label.dispose(),labelSets.splice(index,1)}};/**
|
|
829
835
|
* Add points to existing mesh if it exists, otherwise
|
|
830
836
|
* create a new one and add to it.
|
|
831
837
|
* @param {Array} coords -An array of three components coordinates.
|
|
@@ -872,6 +878,8 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
872
878
|
*/ /**
|
|
873
879
|
* Edit Vertice in index.
|
|
874
880
|
*/ /**
|
|
881
|
+
* Delete a vertex in index.
|
|
882
|
+
*/ /**
|
|
875
883
|
* Set the name for this ZincObject.
|
|
876
884
|
*
|
|
877
885
|
* @param {String} groupNameIn - Name to be set.
|
|
@@ -880,7 +888,7 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
880
888
|
*
|
|
881
889
|
* @param {Boolean} flag - Determin either size attenuation
|
|
882
890
|
* should be on or off.
|
|
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)}};/**
|
|
891
|
+
*/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,mesh.geometry.computeBoundingBox(),mesh.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}},this.deleteVertices=function(index){var removed=Pointset.prototype.deleteVertices.call(this,index);return removed&&removeLabel(index),this.drawRange},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)}};/**
|
|
884
892
|
* Provides an object which stores points and provides method which controls its position.
|
|
885
893
|
* This is created when a valid json file containing point is read into a {@link Zinc.Scene}
|
|
886
894
|
* object.
|
|
@@ -1018,7 +1026,7 @@ function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n){
|
|
|
1018
1026
|
/* 27 */
|
|
1019
1027
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1020
1028
|
|
|
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;/**
|
|
1029
|
+
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,discardAlpha=!0;/**
|
|
1022
1030
|
@typedef SLIDE_SETTINGS
|
|
1023
1031
|
@type {Set}
|
|
1024
1032
|
@property {String} direction - the value must be x, y or z, specify the
|
|
@@ -1042,7 +1050,7 @@ function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var
|
|
|
1042
1050
|
* Modify the mesh based on a setting
|
|
1043
1051
|
*
|
|
1044
1052
|
* @param {SLIDE_SETTINGS} settings - s.
|
|
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
|
|
1053
|
+
*/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.discardAlpha.value=discardAlpha,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
|
|
1046
1054
|
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:}};/**
|
|
1047
1055
|
* Get the bounding box of this slides.
|
|
1048
1056
|
* It uses the max and min of the slides position and the
|
|
@@ -1050,7 +1058,7 @@ var expandBoxWithSettings=(box,settings,vector)=>{if(settings)switch(settings.di
|
|
|
1050
1058
|
*
|
|
1051
1059
|
* @return {THREE.Box3}.
|
|
1052
1060
|
*/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
|
|
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)}};/**
|
|
1061
|
+
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.isAlphaPixelDiscarded=()=>discardAlpha,this.discardAlphaPixel=flag=>{discardAlpha=flag,this.morph.children.forEach(mesh=>{var material=mesh.material;if("ShaderMaterial"===material.type){var uniforms=material.uniforms;uniforms.discardAlpha.value=discardAlpha,material.needsUpdate=!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)}};/**
|
|
1054
1062
|
* Provides a class which create a texture stacks in a block
|
|
1055
1063
|
* with shaders allowing slices of texture to be displayed.
|
|
1056
1064
|
*
|
|
@@ -1340,7 +1348,7 @@ var linesloader=(region,localTimeEnabled,localMorphColour,groupName,anatomicalId
|
|
|
1340
1348
|
* @param {STRING} groupName - name to assign the pointset's groupname to.
|
|
1341
1349
|
* @param {Function} finishCallback - Callback function which will be called
|
|
1342
1350
|
* once the glyphset is succssfully load in.
|
|
1343
|
-
*/this.loadLinesURL=(region,url,timeEnabled,morphColour,groupName,finishCallback,options)=>{var localTimeEnabled=0;this.toBeDownloaded+=1;var isInline=!!(null!==options&&void 0!==options&&options.isInline)&&options.isInline,anatomicalId=null!==options&&void 0!==options&&options.anatomicalId?options.anatomicalId:void 0,renderOrder=null!==options&&void 0!==options&&options.renderOrder?options.renderOrder:void 0;timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var tubeLines=options.tubeLines&&!localTimeEnabled&&!localMorphColour;if(isInline){var object=primitivesLoader.parse(url);linesloader(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,options.lod,tubeLines,finishCallback)(object.geometry,object.materials)}else primitivesLoader.load(url,linesloader(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,options.lod,tubeLines,finishCallback),this.onProgress(url),this.onError(finishCallback),options.loaderOptions)};var loadGlyphset=(region,glyphsetData,glyphurl,groupName,finishCallback,options)=>{var isInline=options&&options.isInline?options.isInline:void 0,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,displayLabels=options&&options.displayLabels?options.displayLabels:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0,newGlyphset=new((__webpack_require__(18).Glyphset));newGlyphset.setDuration(scene.getDuration()),newGlyphset.groupName=groupName;var myCallback=()=>{--this.toBeDownloaded,finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(newGlyphset)};++this.toBeDownloaded,isInline?newGlyphset.load(glyphsetData,glyphurl,myCallback,isInline,displayLabels):newGlyphset.load(glyphsetData,resolveURL(glyphurl),myCallback,isInline,displayLabels),newGlyphset.setAnatomicalId(anatomicalId),newGlyphset.setRenderOrder(renderOrder),region.addZincObject(newGlyphset)},onLoadGlyphsetReady=(region,xmlhttp,glyphurl,groupName,finishCallback,options)=>()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var glyphsetData=JSON.parse(xmlhttp.responseText);loadGlyphset(region,glyphsetData,glyphurl,groupName,finishCallback,options)}},pointsetloader=(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)=>(geometry,materials)=>{var newPointset=new((__webpack_require__(22).Pointset)),material=new THREE.PointsMaterial({alphaTest:.5,size:10,sizeAttenuation:!1});materials&&materials[0]&&(1>materials[0].opacity&&(material.transparent=!0),material.opacity=materials[0].opacity,material.color=materials[0].color,material.morphTargets=localTimeEnabled,material.vertexColors=materials[0].vertexColors);var options={};options.localTimeEnabled=localTimeEnabled,options.localMorphColour=localMorphColour,newPointset&&(newPointset.createMesh(geometry,material,options),newPointset.setName(groupName),newPointset.setAnatomicalId(anatomicalId),region.addZincObject(newPointset),newPointset.setDuration(scene.getDuration()),newPointset.setRenderOrder(renderOrder)),geometry.dispose(),--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newPointset)};//Load a glyphset into this scene.
|
|
1351
|
+
*/this.loadLinesURL=(region,url,timeEnabled,morphColour,groupName,finishCallback,options)=>{var localTimeEnabled=0;this.toBeDownloaded+=1;var isInline=!!(null!==options&&void 0!==options&&options.isInline)&&options.isInline,anatomicalId=null!==options&&void 0!==options&&options.anatomicalId?options.anatomicalId:void 0,renderOrder=null!==options&&void 0!==options&&options.renderOrder?options.renderOrder:void 0;timeEnabled!=null&&(localTimeEnabled=!!timeEnabled);var localMorphColour=0;morphColour!=null&&(localMorphColour=!!morphColour);var tubeLines=options.tubeLines&&!localTimeEnabled&&!localMorphColour;if(isInline){var object=primitivesLoader.parse(url);linesloader(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,options.lod,tubeLines,finishCallback)(object.geometry,object.materials)}else primitivesLoader.load(url,linesloader(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,options.lod,tubeLines,finishCallback),this.onProgress(url),this.onError(finishCallback),options.loaderOptions)};var loadGlyphset=(region,glyphsetData,glyphurl,groupName,finishCallback,options)=>{var isInline=options&&options.isInline?options.isInline:void 0,anatomicalId=options&&options.anatomicalId?options.anatomicalId:void 0,displayLabels=options&&options.displayLabels?options.displayLabels:void 0,renderOrder=options&&options.renderOrder?options.renderOrder:void 0,newGlyphset=new((__webpack_require__(18).Glyphset));newGlyphset.setDuration(scene.getDuration()),newGlyphset.groupName=groupName;var myCallback=()=>{--this.toBeDownloaded,finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(newGlyphset)};++this.toBeDownloaded,isInline?newGlyphset.load(glyphsetData,glyphurl,myCallback,isInline,displayLabels):newGlyphset.load(glyphsetData,resolveURL(glyphurl),myCallback,isInline,displayLabels),newGlyphset.setAnatomicalId(anatomicalId),newGlyphset.setRenderOrder(renderOrder),region.addZincObject(newGlyphset)},onLoadGlyphsetReady=(region,xmlhttp,glyphurl,groupName,finishCallback,options)=>()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var glyphsetData=JSON.parse(xmlhttp.responseText);if(Array.isArray(glyphsetData)){var _options$loaderOption,index=null===options||void 0===options||null===(_options$loaderOption=options.loaderOptions)||void 0===_options$loaderOption?void 0:_options$loaderOption.index;void 0!==index&&glyphsetData.length>index&&(glyphsetData=glyphsetData[index])}loadGlyphset(region,glyphsetData,glyphurl,groupName,finishCallback,options)}},pointsetloader=(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,finishCallback)=>(geometry,materials)=>{var newPointset=new((__webpack_require__(22).Pointset)),material=new THREE.PointsMaterial({alphaTest:.5,size:10,sizeAttenuation:!1});materials&&materials[0]&&(1>materials[0].opacity&&(material.transparent=!0),material.opacity=materials[0].opacity,material.color=materials[0].color,material.morphTargets=localTimeEnabled,material.vertexColors=materials[0].vertexColors);var options={};options.localTimeEnabled=localTimeEnabled,options.localMorphColour=localMorphColour,newPointset&&(newPointset.createMesh(geometry,material,options),newPointset.setName(groupName),newPointset.setAnatomicalId(anatomicalId),region.addZincObject(newPointset),newPointset.setDuration(scene.getDuration()),newPointset.setRenderOrder(renderOrder)),geometry.dispose(),--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newPointset)};//Load a glyphset into this scene.
|
|
1344
1352
|
//Internal loader for zinc pointset.
|
|
1345
1353
|
/**
|
|
1346
1354
|
* Read a STL file into this scene, the geometry will be presented as
|
|
@@ -2375,7 +2383,7 @@ var THREE=__webpack_require__(4),toBufferGeometry=(__webpack_require__(5).toBuff
|
|
|
2375
2383
|
|
|
2376
2384
|
* @param {Number} colour - A hex value of the colour for the points
|
|
2377
2385
|
*/this.createLineSegment=(arrayIn,materialIn,options)=>{if(arrayIn&&materialIn){var linesGeometry=new LineSegmentsGeometry;linesGeometry.setPositions(arrayIn),linesGeometry.colorsNeedUpdate=!0;var line=new LineSegments2(linesGeometry,materialIn);line.scale.set(1,1,1),line.computeLineDistances(),this.setMesh(line,options.localTimeEnabled,options.localMorphColour)}},this.setWidth=width=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=width,this.morph.material.needsUpdate=!0)},this.addVertices=function(coords){if(coords&&coords.length){var mesh=this.getMorph();mesh||(this.drawRange=0);var index=3*this.drawRange;//fill the rest of the array.
|
|
2378
|
-
if(coords.forEach(coord=>{positions[index++]=coord[0],positions[index++]=coord[1],positions[index++]=coord[2],this.drawRange++}),!mesh)for(;300>index;)positions[index++]=coords[0][0],positions[index++]=coords[0][1],positions[index++]=coords[0][2];mesh&&(mesh.geometry.setPositions(positions),mesh.computeLineDistances(),this.boundingBoxUpdateRequired=!0)}return positions},this.getVerticesByFaceIndex=function(faceIndex){var vIndex=3*(2*faceIndex),mesh=this.getMorph();if(mesh&&3*this.drawRange>vIndex){var position=mesh.geometry.getAttribute("instanceStart");return[[position.data.array[vIndex],position.data.array[++vIndex],position.data.array[++vIndex]],[position.data.array[++vIndex],position.data.array[++vIndex],position.data.array[++vIndex]]]}return[]},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 index=3*i;for(coords.forEach(coord=>{positions[index++]=coord[0],positions[index++]=coord[1],positions[index++]=coord[2]}),index=3*this.drawRange;300>index;)positions[index++]=coords[0][0],positions[index++]=coords[0][1],positions[index++]=coords[0][2];mesh.geometry.setPositions(positions),mesh.computeLineDistances(),this.boundingBoxUpdateRequired=!0}return positions},this.addLines=(coords,colour)=>{if(coords&&0<coords.length){this.addVertices(coords);var mesh=this.getMorph();if(!mesh){var material=new LineMaterial({color:colour,linewidth:1,vertexColors:!1,worldUnits:!1});material.resolution.set(window.innerWidth,window.innerHeight);this.createLineSegment(positions,material,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}},this.render=()=>{var material=this.getMorph().material;material.resolution.set(window.innerWidth,window.innerHeight)}};/**
|
|
2386
|
+
if(coords.forEach(coord=>{positions[index++]=coord[0],positions[index++]=coord[1],positions[index++]=coord[2],this.drawRange++}),!mesh)for(;300>index;)positions[index++]=coords[0][0],positions[index++]=coords[0][1],positions[index++]=coords[0][2];mesh&&(mesh.geometry.setPositions(positions),mesh.computeLineDistances(),mesh.geometry.computeBoundingBox(),mesh.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0)}return positions},this.getVerticesByFaceIndex=function(faceIndex){var vIndex=3*(2*faceIndex),mesh=this.getMorph();if(mesh&&3*this.drawRange>vIndex){var position=mesh.geometry.getAttribute("instanceStart");return[[position.data.array[vIndex],position.data.array[++vIndex],position.data.array[++vIndex]],[position.data.array[++vIndex],position.data.array[++vIndex],position.data.array[++vIndex]]]}return[]},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 index=3*i;for(coords.forEach(coord=>{positions[index++]=coord[0],positions[index++]=coord[1],positions[index++]=coord[2]}),index=3*this.drawRange;300>index;)positions[index++]=coords[0][0],positions[index++]=coords[0][1],positions[index++]=coords[0][2];mesh.geometry.setPositions(positions),mesh.computeLineDistances(),mesh.geometry.computeBoundingBox(),mesh.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}return positions},this.addLines=(coords,colour)=>{if(coords&&0<coords.length){this.addVertices(coords);var mesh=this.getMorph();if(!mesh){var material=new LineMaterial({color:colour,linewidth:1,vertexColors:!1,worldUnits:!1});material.resolution.set(window.innerWidth,window.innerHeight);this.createLineSegment(positions,material,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}},this.render=()=>{var material=this.getMorph().material;material.resolution.set(window.innerWidth,window.innerHeight)}};/**
|
|
2379
2387
|
* Provides an object which stores lines.
|
|
2380
2388
|
* This is created when a valid json file containing lines is read into a {@link Zinc.Scene}
|
|
2381
2389
|
* object.
|