zincjs 1.16.5 → 1.16.7
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 +42 -8
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/label.js +65 -8
- package/src/primitives/pointset.js +65 -1
- package/src/utilities.js +8 -8
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.7","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 */
|
|
@@ -85,12 +85,12 @@ module.exports = require("three");
|
|
|
85
85
|
/* 5 */
|
|
86
86
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
var THREE=__webpack_require__(4),THREEGeometry=(__webpack_require__(6).Geometry),SpriteText=(__webpack_require__(7)["default"]);function resolveURL(url){var actualURL=url,prefix=(__webpack_require__(0).modelPrefix);if(prefix){"/"!=prefix[prefix.length-1]&&(prefix+="/");/^(?:[a-z]+:)?\/\//i.test(url)||(actualURL=prefix+url)}return actualURL}function createNewURL(target,reference){var getNewURL=(target,reference)=>{try{var newURL=new URL(target,reference).href;//Make sure the target url does not contain parameters
|
|
89
89
|
if(target&&2>target.split("?").length){var paramsStrings=reference.split("?");//There are parameters, add them to the target
|
|
90
90
|
2===paramsStrings.length&&(newURL=newURL+"?"+paramsStrings[1])}return newURL}catch(_unused){console.error("There is an issue creating the url link with: ".concat(target,"."))}};if(!Array.isArray(target))return getNewURL(target,reference);var urls=[];return target.forEach(url=>{urls.push(getNewURL(url,reference))}),urls}/*
|
|
91
91
|
* Calculate the bounding box of a mesh, values will be
|
|
92
92
|
* set for cachedBox, b1, v1 and v2 and they need to be
|
|
93
|
-
* defined.
|
|
93
|
+
* defined.
|
|
94
94
|
*/function getBoundingBox(mesh,cachedBox,b1,v1,v2){var influences=mesh.morphTargetInfluences,attributes=void 0;mesh.geometry&&(attributes=mesh.geometry.morphAttributes);var found=!1;if(influences&&attributes&&attributes.position){v1.set(0,0,0),v2.set(0,0,0);for(var i=0;i<influences.length;i++)0<influences[i]&&(found=!0,b1.setFromArray(attributes.position[i].array),v1.add(b1.min.multiplyScalar(influences[i])),v2.add(b1.max.multiplyScalar(influences[i])));found&&cachedBox.set(v1,v2)}found||cachedBox.setFromBufferAttribute(mesh.geometry.attributes.position),mesh.updateWorldMatrix(!0,!0),cachedBox.applyMatrix4(mesh.matrixWorld)}//Convenient function
|
|
95
95
|
function loadExternalFile(url,data,callback,errorCallback){// Set up an asynchronous request
|
|
96
96
|
var request=new XMLHttpRequest;// Hook the event that gets called as the request progresses
|
|
@@ -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,.015,colourIn.getStyle()):new SpriteText(text,.015),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,6 +640,22 @@ var SpriteText=(__webpack_require__(7)["default"]);/**
|
|
|
640
640
|
*
|
|
641
641
|
* @param {Number} scaling - Scale to be set.
|
|
642
642
|
*/ /**
|
|
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
|
+
*/ /**
|
|
643
659
|
* Free up the memory
|
|
644
660
|
*/ /**
|
|
645
661
|
* Get the intrnal sprite.
|
|
@@ -649,7 +665,7 @@ var SpriteText=(__webpack_require__(7)["default"]);/**
|
|
|
649
665
|
* Get the text.
|
|
650
666
|
*
|
|
651
667
|
* @return {String}
|
|
652
|
-
*/
|
|
668
|
+
*/this.getPosition=()=>sprite?[sprite.position.x,sprite.position.y,sprite.position.z]:[0,0,0],this.setPosition=(x,y,z)=>{position[0]=x,position[1]=y,position[2]=z,sprite&&sprite.position.set(x,y,z)},this.setColour=colourIn=>{colourIn&&(sprite.color=colourIn.getStyle(),colour=colourIn)},this.setScale=scaling=>{sprite&&0<scaling&&sprite.scale.set(scaling,scaling,1)},this.setDepthTest=flag=>{flag&&flag!==sprite.material.depthTest&&(sprite.material.depthTest=flag)},this.setSize=sizeIn=>{sizeIn&&sizeIn!==size&&(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();
|
|
653
669
|
},this.getSprite=()=>sprite,this.getString=()=>text};
|
|
654
670
|
|
|
655
671
|
/***/ }),
|
|
@@ -795,7 +811,7 @@ return!!(_this.video&&3<=_this.video.readyState)},function initialise(){document
|
|
|
795
811
|
/* 22 */
|
|
796
812
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
797
813
|
|
|
798
|
-
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;/**
|
|
799
815
|
* Create the pointsets using geometry and material.
|
|
800
816
|
*
|
|
801
817
|
* @param {THREE.Geomtry} geometryIn - Geometry of points to be rendered.
|
|
@@ -805,7 +821,7 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
805
821
|
* time dependent.
|
|
806
822
|
* @param {Boolean} options.localMorphColour - A flag to indicate either the colour is
|
|
807
823
|
* time dependent.
|
|
808
|
-
*/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}};/**
|
|
809
825
|
* Add points to existing mesh if it exists, otherwise
|
|
810
826
|
* create a new one and add to it.
|
|
811
827
|
* @param {Array} coords -An array of three components coordinates.
|
|
@@ -821,6 +837,20 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
821
837
|
*
|
|
822
838
|
* @param {THREE.Color} colour - colour to be set
|
|
823
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
|
+
*/ /**
|
|
824
854
|
* Set the size of the points.
|
|
825
855
|
*
|
|
826
856
|
* @param {Number} size - size to be set.
|
|
@@ -834,11 +864,15 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
834
864
|
*/ /**
|
|
835
865
|
* Edit Vertice in index.
|
|
836
866
|
*/ /**
|
|
867
|
+
* Set the name for this ZincObject.
|
|
868
|
+
*
|
|
869
|
+
* @param {String} groupNameIn - Name to be set.
|
|
870
|
+
*/ /**
|
|
837
871
|
* Turn size attenuation on/off based on the flag.
|
|
838
872
|
*
|
|
839
873
|
* @param {Boolean} flag - Determin either size attenuation
|
|
840
874
|
* should be on or off.
|
|
841
|
-
*/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(size)},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)}};/**
|
|
842
876
|
* Provides an object which stores points and provides method which controls its position.
|
|
843
877
|
* This is created when a valid json file containing point is read into a {@link Zinc.Scene}
|
|
844
878
|
* object.
|