zincjs 1.8.3 → 1.8.5
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 +31 -18
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/controls.js +14 -5
- package/src/primitives/label.js +2 -1
- package/src/primitives/lines2.js +1 -3
- package/src/primitives/pointset.js +80 -10
- package/src/primitives/textureSlides.js +29 -2
- package/src/scene.js +55 -1
- package/src/shaders/textureSlide.js +4 -5
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.8.
|
|
35
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.8.5","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 */
|
|
@@ -752,7 +752,7 @@ return!!(_this.video&&3<=_this.video.readyState)},function initialise(){document
|
|
|
752
752
|
/* 22 */
|
|
753
753
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
754
754
|
|
|
755
|
-
var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBufferGeometry=(__webpack_require__(5).toBufferGeometry),getCircularTexture=(__webpack_require__(5).getCircularTexture),Pointset=function(){
|
|
755
|
+
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=[];/**
|
|
756
756
|
* Create the pointsets using geometry and material.
|
|
757
757
|
*
|
|
758
758
|
* @param {THREE.Geomtry} geometryIn - Geometry of points to be rendered.
|
|
@@ -762,11 +762,11 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
762
762
|
* time dependent.
|
|
763
763
|
* @param {Boolean} options.localMorphColour - A flag to indicate either the colour is
|
|
764
764
|
* time dependent.
|
|
765
|
-
*/
|
|
765
|
+
*/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=!1,this.group.add(sprite),labelSets[index]=label}};/**
|
|
766
766
|
* Add points to existing mesh if it exists, otherwise
|
|
767
767
|
* create a new one and add to it.
|
|
768
768
|
* @param {Array} coords -An array of three components coordinates.
|
|
769
|
-
* @param {Array} labels - An array of strings, these are only added
|
|
769
|
+
* @param {Array|String} labels - An array of strings, these are only added
|
|
770
770
|
* if the number of coords equals to the number labels provided.
|
|
771
771
|
* @param {Number} colour - A hex value of the colour for the points
|
|
772
772
|
*/ /**
|
|
@@ -779,11 +779,15 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
779
779
|
* @param {Boolean} flag - Determin either size attenuation
|
|
780
780
|
* should be on or off.
|
|
781
781
|
*/ /**
|
|
782
|
-
*
|
|
783
|
-
|
|
784
|
-
*
|
|
785
|
-
|
|
786
|
-
|
|
782
|
+
* Get vertices at index
|
|
783
|
+
*/ /**
|
|
784
|
+
* Edit Vertice in index.
|
|
785
|
+
*/ /**
|
|
786
|
+
* Turn size attenuation on/off based on the flag.
|
|
787
|
+
*
|
|
788
|
+
* @param {Boolean} flag - Determin either size attenuation
|
|
789
|
+
* should be on or off.
|
|
790
|
+
*/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)}};/**
|
|
787
791
|
* Provides an object which stores points and provides method which controls its position.
|
|
788
792
|
* This is created when a valid json file containing point is read into a {@link Zinc.Scene}
|
|
789
793
|
* object.
|
|
@@ -921,7 +925,7 @@ function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var inf
|
|
|
921
925
|
/* 27 */
|
|
922
926
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
923
927
|
|
|
924
|
-
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 flipY=!0;/**
|
|
928
|
+
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(obj,key,value){return key=_toPropertyKey(key),key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}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 flipY=!0;/**
|
|
925
929
|
@typedef SLIDE_SETTINGS
|
|
926
930
|
@type {Set}
|
|
927
931
|
@property {String} direction - the value must be x, y or z, specify the
|
|
@@ -941,11 +945,11 @@ var THREE=__webpack_require__(4),shader=__webpack_require__(28),TextureSlides=fu
|
|
|
941
945
|
*
|
|
942
946
|
* @param {THREE.Mesh} mesh - Mesh to be modified
|
|
943
947
|
* @param {SLIDE_SETTINGS} slideSettings - Slide settings.
|
|
944
|
-
*/var setUniformSlideSettingsOfMesh=(mesh,settings)=>{var material=mesh.material,uniforms=material.uniforms;switch(settings.direction){case"x":uniforms.direction.value=1,uniforms.slide.value.set(settings.value,0,0);break;case"y":uniforms.direction.value=2,uniforms.slide.value.set(0,settings.value,0);break;case"z":uniforms.direction.value=3,uniforms.slide.value.set(0,0,settings.value);break;default:}material.needsUpdate=!0,this.boundingBoxUpdateRequired=!0};/**
|
|
948
|
+
*/var setUniformSlideSettingsOfMesh=(mesh,settings)=>{var material=mesh.material,uniforms=material.uniforms;switch(mesh.rotation.x=0,mesh.rotation.y=0,mesh.rotation.z=0,mesh.position.x=0,mesh.position.y=0,mesh.position.z=0,settings.direction){case"x":var rotation=flipY?-Math.PI/2:Math.PI/2;mesh.rotation.y=rotation,uniforms.direction.value=1,uniforms.slide.value.set(settings.value,0,0),mesh.position.x=settings.value;break;case"y":mesh.rotation.x=Math.PI/2,uniforms.direction.value=2,uniforms.slide.value.set(0,settings.value,0),mesh.position.y=settings.value;break;case"z":uniforms.direction.value=3,uniforms.slide.value.set(0,0,settings.value),mesh.position.z=settings.value;break;default:}material.needsUpdate=!0,this.boundingBoxUpdateRequired=!0};/**
|
|
945
949
|
* Modify the mesh based on a setting
|
|
946
950
|
*
|
|
947
951
|
* @param {SLIDE_SETTINGS} settings - s.
|
|
948
|
-
*/this.modifySlideSettings=settings=>{settings&&settings.id&&settings.id in idTextureMap&&idTextureMap[settings.id]&&setUniformSlideSettingsOfMesh(idTextureMap[settings.id],settings)},this.createSlide=settings=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&settings&&settings.direction&&void 0!==settings.value){var geometry=new THREE.PlaneGeometry(1,1);geometry.translate(.5,.5,0);var uniforms=shader.getUniforms();uniforms.diffuse.value=this.texture.impl,uniforms.depth.value=this.texture.size.depth,uniforms.flipY.value=flipY;var options={fs:shader.fs,vs:shader.vs,uniforms:uniforms,glslVersion:shader.glslVersion,side:THREE.DoubleSide,transparent:!1},material=this.texture.getMaterial(options);material.needsUpdate=!0;var mesh=new THREE.Mesh(geometry,material),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.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
|
|
952
|
+
*/this.modifySlideSettings=settings=>{settings&&settings.id&&settings.id in idTextureMap&&idTextureMap[settings.id]&&setUniformSlideSettingsOfMesh(idTextureMap[settings.id],settings)},this.createSlide=settings=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&settings&&settings.direction&&void 0!==settings.value){var geometry=new THREE.PlaneGeometry(1,1);geometry.translate(.5,.5,0);var uniforms=shader.getUniforms();uniforms.diffuse.value=this.texture.impl,uniforms.depth.value=this.texture.size.depth,uniforms.flipY.value=flipY;var options={fs:shader.fs,vs:shader.vs,uniforms:uniforms,glslVersion:shader.glslVersion,side:THREE.DoubleSide,transparent:!1},material=this.texture.getMaterial(options);material.needsUpdate=!0;var mesh=new THREE.Mesh(geometry,material);mesh.name=this.groupName,mesh.userData=this;var slideSettings={value:settings.value,direction:settings.direction,id:mesh.id};return textureSettings.push(slideSettings),setUniformSlideSettingsOfMesh(mesh,slideSettings),idTextureMap[mesh.id]=mesh,this.morph.add(mesh),this.boundingBoxUpdateRequired=!0,slideSettings}},this.getTextureSettings=()=>[...textureSettings],this.getTextureSettingsWithId=id=>{for(var i=0;i<textureSettings.length;i++)if(id===textureSettings[i].id)return _objectSpread({},textureSettings[i])},this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=slide=>{slide&&this.removeSlideWithId(slide.id)},this.removeSlideWithId=id=>{if(this.morph&&id in idTextureMap&&idTextureMap[id]){if(this.morph.getObjectById(id)){var slide=idTextureMap[id];this.morph.remove(slide),slide.clear(),slide.geometry&&slide.geometry.dispose(),slide.material&&slide.material.dispose(),this.boundingBoxUpdateRequired=!0}var index=textureSettings.findIndex(item=>item.id===id);-1<index&&textureSettings.splice(index,1)}},this.dispose=()=>{this.morph.children.forEach(slide=>{slide.geometry&&slide.geometry.dispose(),slide.material&&slide.material.dispose()}),(__webpack_require__(29).TexturePrimitive).prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};//Expand the boundingbox with slide settings
|
|
949
953
|
var expandBoxWithSettings=(box,settings,vector)=>{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:}};/**
|
|
950
954
|
* Get the bounding box of this slides.
|
|
951
955
|
* It uses the max and min of the slides position and the
|
|
@@ -968,7 +972,7 @@ var expandBoxWithSettings=(box,settings,vector)=>{switch(settings.direction.valu
|
|
|
968
972
|
/* 28 */
|
|
969
973
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
970
974
|
|
|
971
|
-
var THREE=__webpack_require__(4),glslVersion=THREE.GLSL3,fs="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2DArray;\n\nuniform sampler2DArray diffuse;\nin vec3 vUw;\n\nout vec4 outColor;\n\nvoid main() {\n\n vec4 color = texture( diffuse, vUw );\n\n // lighten a bit\n outColor = vec4( color.rgb + .2, 1.0 );\n\n}\n",vs="\nout vec3 vUw;\nuniform float depth;\nuniform vec3 slide;\nuniform int direction;\nuniform bool flipY;\n\nvoid main() {\n\n vec3 slidePos = position.xyz;\n\n if (direction == 1)\n slidePos = vec3(slide.x, position.
|
|
975
|
+
var THREE=__webpack_require__(4),glslVersion=THREE.GLSL3,fs="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2DArray;\n\nuniform sampler2DArray diffuse;\nin vec3 vUw;\n\nout vec4 outColor;\n\nvoid main() {\n\n vec4 color = texture( diffuse, vUw );\n\n // lighten a bit\n outColor = vec4( color.rgb + .2, 1.0 );\n\n}\n",vs="\nout vec3 vUw;\nuniform float depth;\nuniform vec3 slide;\nuniform int direction;\nuniform bool flipY;\n\nvoid main() {\n\n vec3 slidePos = position.xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position.xyz, 1.0 );\n\n if (direction == 1)\n slidePos = vec3(slide.x, position.y, position.x);\n if (direction == 2)\n slidePos = vec3(position.x, slide.y, position.y);\n if (direction == 3)\n slidePos = vec3(position.x, position.y, slide.z);\n\n if (flipY) \n slidePos.y = 1.0 - slidePos.y;\n\n vUw.xyz = vec3(slidePos.x, slidePos.y, slidePos.z * depth);\n\n}\n",getUniforms=function(){return{diffuse:{value:void 0},depth:{value:1},slide:{value:new THREE.Vector3(0,0,1)},direction:{value:1},flipY:{value:!0}}};exports.fs=fs,exports.vs=vs,exports.glslVersion=glslVersion,exports.getUniforms=getUniforms;
|
|
972
976
|
|
|
973
977
|
/***/ }),
|
|
974
978
|
/* 29 */
|
|
@@ -1151,10 +1155,19 @@ var convertDurationObjectToString=duration=>[...(duration.years?["".concat(durat
|
|
|
1151
1155
|
* Remove all temporary primitives.
|
|
1152
1156
|
*/ /*
|
|
1153
1157
|
* Create primitive based on the bounding box of scene and
|
|
1158
|
+
* add to specify region and group name.
|
|
1159
|
+
*/ /*
|
|
1160
|
+
* Create primitive based on the bounding box of scene and
|
|
1154
1161
|
* add to specify region and group name.
|
|
1155
1162
|
*/ /*
|
|
1156
1163
|
* Enable marker cluster to work with markers
|
|
1157
|
-
*/this.setDurationFromObject=duration=>{var string=convertDurationObjectToString(duration),millisec=convertDurationObjectTomSec(duration);this.setMetadataTag("Duration",string),this.setDuration(millisec)},this.setOriginalDurationFromObject=duration=>{var string=convertDurationObjectToString(duration);this.setMetadataTag("OriginalDuration",string)},this.exportGLTF=binary=>{var exporter=new SceneExporter(this);return exporter.exportGLTF(binary)},this.getRootRegion=()=>rootRegion,this.createLines=(regionPath,groupName,coords,colour)=>{var region=rootRegion.findChildFromPath(regionPath);return void 0===region&&(region=rootRegion.createChildFromPath(regionPath)),region.createLines(groupName,coords,colour)},this.createPoints=(regionPath,groupName,coords,labels,colour)=>{var region=rootRegion.findChildFromPath(regionPath);return void 0===region&&(region=rootRegion.createChildFromPath(regionPath)),region.createPoints(groupName,coords,labels,colour)},this.addZincObjectAddedCallbacks=callbackFunction=>(++zincObjectAddedCallbacks_id,zincObjectAddedCallbacks[zincObjectAddedCallbacks_id]=callbackFunction,zincObjectAddedCallbacks_id),this.addZincObjectRemovedCallbacks=callbackFunction=>(++zincObjectRemovedCallbacks_id,zincObjectRemovedCallbacks[zincObjectRemovedCallbacks_id]=callbackFunction,zincObjectRemovedCallbacks_id),this.removeZincObjectAddedCallbacks=id=>{id in zincObjectAddedCallbacks_id&&delete zincObjectAddedCallbacks[id]},this.removeZincObjectRemovedCallbacks=id=>{id in zincObjectRemovedCallbacks_id&&delete zincObjectRemovedCallbacks[id]},this.clearZincObjectAddedCallbacks=()=>{zincObjectAddedCallbacks={},zincObjectAddedCallbacks_id=0},this.clearZincObjectRemovedCallbacks=()=>{zincObjectRemovedCallbacks={},zincObjectRemovedCallbacks_id=0},this.triggerObjectAddedCallback=zincObject=>{for(var key in zincObjectAddedCallbacks)zincObjectAddedCallbacks.hasOwnProperty(key)&&zincObjectAddedCallbacks[key](zincObject)},this.triggerObjectRemovedCallback=zincObject=>{for(var key in zincObjectRemovedCallbacks)zincObjectRemovedCallbacks.hasOwnProperty(key)&&zincObjectRemovedCallbacks[key](zincObject)},this.addTemporaryPoints=(coords,colour)=>{var geometry=createBufferGeometry(coords.length,coords),material=new THREE.PointsMaterial({alphaTest:.5,size:15,color:colour,sizeAttenuation:!1}),texture=getCircularTexture();material.map=texture;var point=new((__webpack_require__(23).Points))(geometry,material);return tempGroup.add(point),point},this.addTemporaryLines=(coords,colour)=>{var geometry=createBufferGeometry(coords.length,coords),material=new THREE.LineBasicMaterial({color:colour}),line=new((__webpack_require__(12).LineSegments))(geometry,material);return tempGroup.add(line),line},this.removeTemporaryPrimitive=object=>{tempGroup.remove(object),object.geometry.dispose(),object.material.dispose()},this.clearTemporaryPrimitives=()=>{var children=tempGroup.children;children.forEach(child=>{child.geometry.dispose(),child.material.dispose()}),tempGroup.clear()},this.addBoundingBoxPrimitive=function(regionPath,group,colour,opacity,visibility){var boundingBox=5<arguments.length&&void 0!==arguments[5]?arguments[5]:void 0,region=rootRegion.findChildFromPath(regionPath);void 0===region&&(region=rootRegion.createChildFromPath(regionPath));var box=boundingBox?boundingBox:_this.getBoundingBox(),dim=new THREE.Vector3().subVectors(box.max,box.min),boxGeo=new THREE.BoxGeometry(dim.x,dim.y,dim.z)
|
|
1164
|
+
*/this.setDurationFromObject=duration=>{var string=convertDurationObjectToString(duration),millisec=convertDurationObjectTomSec(duration);this.setMetadataTag("Duration",string),this.setDuration(millisec)},this.setOriginalDurationFromObject=duration=>{var string=convertDurationObjectToString(duration);this.setMetadataTag("OriginalDuration",string)},this.exportGLTF=binary=>{var exporter=new SceneExporter(this);return exporter.exportGLTF(binary)},this.getRootRegion=()=>rootRegion,this.createLines=(regionPath,groupName,coords,colour)=>{var region=rootRegion.findChildFromPath(regionPath);return void 0===region&&(region=rootRegion.createChildFromPath(regionPath)),region.createLines(groupName,coords,colour)},this.createPoints=(regionPath,groupName,coords,labels,colour)=>{var region=rootRegion.findChildFromPath(regionPath);return void 0===region&&(region=rootRegion.createChildFromPath(regionPath)),region.createPoints(groupName,coords,labels,colour)},this.addZincObjectAddedCallbacks=callbackFunction=>(++zincObjectAddedCallbacks_id,zincObjectAddedCallbacks[zincObjectAddedCallbacks_id]=callbackFunction,zincObjectAddedCallbacks_id),this.addZincObjectRemovedCallbacks=callbackFunction=>(++zincObjectRemovedCallbacks_id,zincObjectRemovedCallbacks[zincObjectRemovedCallbacks_id]=callbackFunction,zincObjectRemovedCallbacks_id),this.removeZincObjectAddedCallbacks=id=>{id in zincObjectAddedCallbacks_id&&delete zincObjectAddedCallbacks[id]},this.removeZincObjectRemovedCallbacks=id=>{id in zincObjectRemovedCallbacks_id&&delete zincObjectRemovedCallbacks[id]},this.clearZincObjectAddedCallbacks=()=>{zincObjectAddedCallbacks={},zincObjectAddedCallbacks_id=0},this.clearZincObjectRemovedCallbacks=()=>{zincObjectRemovedCallbacks={},zincObjectRemovedCallbacks_id=0},this.triggerObjectAddedCallback=zincObject=>{for(var key in zincObjectAddedCallbacks)zincObjectAddedCallbacks.hasOwnProperty(key)&&zincObjectAddedCallbacks[key](zincObject)},this.triggerObjectRemovedCallback=zincObject=>{for(var key in zincObjectRemovedCallbacks)zincObjectRemovedCallbacks.hasOwnProperty(key)&&zincObjectRemovedCallbacks[key](zincObject)},this.addTemporaryPoints=(coords,colour)=>{var geometry=createBufferGeometry(coords.length,coords),material=new THREE.PointsMaterial({alphaTest:.5,size:15,color:colour,sizeAttenuation:!1}),texture=getCircularTexture();material.map=texture;var point=new((__webpack_require__(23).Points))(geometry,material);return tempGroup.add(point),point},this.addTemporaryLines=(coords,colour)=>{var geometry=createBufferGeometry(coords.length,coords),material=new THREE.LineBasicMaterial({color:colour}),line=new((__webpack_require__(12).LineSegments))(geometry,material);return tempGroup.add(line),line},this.removeTemporaryPrimitive=object=>{tempGroup.remove(object),object.geometry.dispose(),object.material.dispose()},this.clearTemporaryPrimitives=()=>{var children=tempGroup.children;children.forEach(child=>{child.geometry.dispose(),child.material.dispose()}),tempGroup.clear()},this.addBoundingBoxPrimitive=function(regionPath,group,colour,opacity,visibility){var boundingBox=5<arguments.length&&void 0!==arguments[5]?arguments[5]:void 0,region=rootRegion.findChildFromPath(regionPath);void 0===region&&(region=rootRegion.createChildFromPath(regionPath));var box=boundingBox?boundingBox:_this.getBoundingBox(),dim=new THREE.Vector3().subVectors(box.max,box.min),boxGeo=new THREE.BoxGeometry(dim.x,dim.y,dim.z),primitive=region.createGeometryFromThreeJSGeometry(group,boxGeo,colour,opacity,visibility,1e4);return dim.addVectors(box.min,box.max).multiplyScalar(.5),primitive.setPosition(dim.x,dim.y,dim.z),primitive},this.addSlicesPrimitive=function(regionPath,groups,colours,opacity,visibility){var boundingBox=5<arguments.length&&arguments[5]!==void 0?arguments[5]:void 0;if(groups&&3<=groups.length&&colours&&3<=colours.length){var region=rootRegion.findChildFromPath(regionPath);void 0===region&&(region=rootRegion.createChildFromPath(regionPath));var box=boundingBox?boundingBox:_this.getBoundingBox(),dim=new THREE.Vector3().subVectors(box.max,box.min),primitives=[],index=0;return["x","y","z"].forEach(direction=>{var planeGeo;switch(direction){//YZ plane
|
|
1165
|
+
case"x":planeGeo=new THREE.PlaneGeometry(dim.z,dim.y),planeGeo.rotateY(Math.PI/2);// code block
|
|
1166
|
+
break;//XZ plane
|
|
1167
|
+
case"y":planeGeo=new THREE.PlaneGeometry(dim.x,dim.z),planeGeo.rotateX(Math.PI/2);// code block
|
|
1168
|
+
break;//XY plane
|
|
1169
|
+
case"z":planeGeo=new THREE.PlaneGeometry(dim.x,dim.y);// code block
|
|
1170
|
+
break;default:}var primitive=region.createGeometryFromThreeJSGeometry(groups[index],planeGeo,colours[index],opacity,visibility,10001);primitives.push(primitive),index++}),dim.addVectors(box.min,box.max).multiplyScalar(.5),primitives.forEach(primitive=>{primitive.setPosition(dim.x,dim.y,dim.z)}),primitives}},this.enableMarkerCluster=flag=>{flag?(markerCluster.markerUpdateRequired=!0,markerCluster.enable()):(markerCluster.markerUpdateRequired=!1,markerCluster.disable()),this.forcePickableObjectsUpdate=!0}};
|
|
1158
1171
|
|
|
1159
1172
|
/***/ }),
|
|
1160
1173
|
/* 33 */
|
|
@@ -1871,8 +1884,8 @@ var handleSyncControl=()=>{this._state===STATE.ROTATE||this._state===STATE.TOUCH
|
|
|
1871
1884
|
* Enable syncControl.
|
|
1872
1885
|
*/ /**
|
|
1873
1886
|
* Disable syncControl.
|
|
1874
|
-
*/this.update=timeChanged=>{var delta=timeChanged*playRate,controlEnabled=enabled,updated=!0;return currentMode===MODE.PATH?updatePath(delta):currentMode===MODE.SMOOTH_CAMERA_TRANSITION&&smoothCameraTransitionObject?(smoothCameraTransitionObject.update(delta),smoothCameraTransitionObject.isTransitionCompleted()&&(null==smoothCameraTransitionObject,currentMode=MODE.DEFAULT),controlEnabled=!1):currentMode===MODE.ROTATE_CAMERA_TRANSITION&&rotateCameraTransitionObject?(rotateCameraTransitionObject.update(delta),rotateCameraTransitionObject.isTransitionCompleted()&&(null==rotateCameraTransitionObject,currentMode=MODE.DEFAULT),controlEnabled=!1):currentMode===MODE.AUTO_TUMBLE&&cameraAutoTumbleObject?cameraAutoTumbleObject.update(delta):currentMode===MODE.SYNC_CONTROL&&ndcControl?(handleSyncControl(),controlEnabled=!1):updated=!1,controlEnabled&&(this._state!==STATE.NONE&&(updated=!0),this._state===STATE.ROTATE||this._state===STATE.TOUCH_ROTATE?tumble():this._state===STATE.PAN||this._state===STATE.TOUCH_PAN?translate():(this._state===STATE.ZOOM||this._state===STATE.TOUCH_ZOOM||this._state===STATE.SCROLL)&&flyZoom(),this._state!==STATE.NONE&¤tMode===MODE.AUTO_TUMBLE&&cameraAutoTumbleObject&&cameraAutoTumbleObject.stopOnCameraInput,this._state===STATE.SCROLL&&(this._state=STATE.NONE)),deviceOrientationControl?(updated=!0,deviceOrientationControl.update()):this.cameraObject.lookAt(this.cameraObject.target),updated},this.playPath=()=>{currentMode=MODE.PATH},this.stopPath=()=>{currentMode=MODE.DEFAULT},this.isPlayingPath=()=>currentMode===MODE.PATH,this.enableDirectionalLightUpdateWithPath=flag=>{updateLightWithPathFlag=flag},this.enableDeviceOrientation=()=>{deviceOrientationControl||(deviceOrientationControl=new ModifiedDeviceOrientationControls(this.cameraObject))},this.disableDeviceOrientation=()=>{deviceOrientationControl&&(deviceOrientationControl.dispose(),deviceOrientationControl=void 0)},this.isDeviceOrientationEnabled=()=>!!deviceOrientationControl,this.resetView=()=>{var viewport=viewports[defaultViewport];this.cameraObject.near=viewport.nearPlane,this.cameraObject.far=viewport.farPlane,this.cameraObject.position.set(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),this.cameraObject.target.set(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),this.cameraObject.up.set(viewport.upVector[0],viewport.upVector[1],viewport.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setCurrentCameraSettings=newViewport=>{newViewport.nearPlane&&(this.cameraObject.near=newViewport.nearPlane),newViewport.farPlane&&(this.cameraObject.far=newViewport.farPlane),newViewport.eyePosition&&this.cameraObject.position.set(newViewport.eyePosition[0],newViewport.eyePosition[1],newViewport.eyePosition[2]),newViewport.targetPosition&&this.cameraObject.target.set(newViewport.targetPosition[0],newViewport.targetPosition[1],newViewport.targetPosition[2]),newViewport.upVector&&this.cameraObject.up.set(newViewport.upVector[0],newViewport.upVector[1],newViewport.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.getViewportFromCentreAndRadius=(centreX,centreY,centreZ,radius,view_angle,clip_distance)=>{var eyex=this.cameraObject.position.x-this.cameraObject.target.x,eyey=this.cameraObject.position.y-this.cameraObject.target.y,eyez=this.cameraObject.position.z-this.cameraObject.target.z,fact=1/Math.sqrt(eyex*eyex+eyey*eyey+eyez*eyez);eyex*=fact,eyey*=fact,eyez*=fact;/* look at the centre of the sphere */var localTargetPosition=[centreX,centreY,centreZ],eye_distance=radius/Math.tan(view_angle*Math.PI/360),localEyePosition=[centreX+eyex*eye_distance,centreY+eyey*eye_distance,centreZ+eyez*eye_distance],localFarPlane=eye_distance+clip_distance,localNearPlane=0,nearClippingFactor=.95;/* shift the eye position to achieve the desired view_angle */localNearPlane=clip_distance>nearClippingFactor*eye_distance?(1-nearClippingFactor)*eye_distance:eye_distance-clip_distance;var newViewport=new Viewport;return newViewport.nearPlane=localNearPlane,newViewport.farPlane=localFarPlane,newViewport.eyePosition=localEyePosition,newViewport.targetPosition=localTargetPosition,newViewport.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],newViewport},this.getViewportFromBoundingBox=(boundingBox,radiusScale)=>{var radius=boundingBox.min.distanceTo(boundingBox.max)/2*radiusScale,centreX=(boundingBox.min.x+boundingBox.max.x)/2,centreY=(boundingBox.min.y+boundingBox.max.y)/2,centreZ=(boundingBox.min.z+boundingBox.max.z)/2,clip_factor=4,viewport=this.getViewportFromCentreAndRadius(centreX,centreY,centreZ,radius,40,radius*clip_factor);return viewport},this.getCurrentViewport=()=>{var currentViewport=new Viewport;return currentViewport.nearPlane=this.cameraObject.near,currentViewport.farPlane=this.cameraObject.far,currentViewport.eyePosition[0]=this.cameraObject.position.x,currentViewport.eyePosition[1]=this.cameraObject.position.y,currentViewport.eyePosition[2]=this.cameraObject.position.z,currentViewport.targetPosition[0]=this.cameraObject.target.x,currentViewport.targetPosition[1]=this.cameraObject.target.y,currentViewport.targetPosition[2]=this.cameraObject.target.z,currentViewport.upVector[0]=this.cameraObject.up.x,currentViewport.upVector[1]=this.cameraObject.up.y,currentViewport.upVector[2]=this.cameraObject.up.z,currentViewport},this.getDefaultEyePosition=()=>eyePosition,this.getDefaultTargetPosition=()=>targetPosition,this.cameraTransition=(startingViewport,endingViewport,durationIn)=>{rotateCameraTransitionObject==null&&(smoothCameraTransitionObject=new SmoothCameraTransition(startingViewport,endingViewport,this,durationIn))},this.rotateCameraTransition=(axis,angle,duration)=>{smoothCameraTransitionObject==null&&(rotateCameraTransitionObject=new RotateCameraTransition(axis,angle,this,duration))},this.enableCameraTransition=()=>{smoothCameraTransitionObject&&(currentMode=MODE.SMOOTH_CAMERA_TRANSITION),rotateCameraTransitionObject&&(currentMode=MODE.ROTATE_CAMERA_TRANSITION)},this.pauseCameraTransition=()=>{currentMode=MODE.DEFAULT},this.stopCameraTransition=()=>{currentMode=MODE.DEFAULT,smoothCameraTransitionObject=void 0,rotateCameraTransitionObject=void 0},this.isTransitioningCamera=()=>currentMode===MODE.SMOOTH_CAMERA_TRANSITION||currentMode===MODE.ROTATE_CAMERA_TRANSITION,this.autoTumble=(tumbleDirectionIn,tumbleRateIn,stopOnCameraInputIn)=>{cameraAutoTumbleObject=new CameraAutoTumble(tumbleDirectionIn,tumbleRateIn,stopOnCameraInputIn,this)},this.enableAutoTumble=()=>{currentMode=MODE.AUTO_TUMBLE},this.stopAutoTumble=()=>{currentMode=MODE.DEFAULT,cameraAutoTumbleObject=void 0},this.updateAutoTumble=()=>{cameraAutoTumbleObject&&(cameraAutoTumbleObject.requireUpdate=!0)},this.isAutoTumble=()=>currentMode===MODE.AUTO_TUMBLE,this.enableRaycaster=(sceneIn,callbackFunctionIn,hoverCallbackFunctionIn)=>{zincRayCaster==null&&(zincRayCaster=new RayCaster(sceneIn,this.scene,callbackFunctionIn,hoverCallbackFunctionIn,this.renderer))},this.disableRaycaster=()=>{zincRayCaster.disable(),zincRayCaster=void 0},this.isSyncControl=()=>currentMpde===MODE.SYNC_CONTROL,this.enableSyncControl=()=>(currentMode=MODE.SYNC_CONTROL,ndcControl||(ndcControl=new NDCCameraControl),ndcControl.setCurrentCameraSettings(this.cameraObject,viewports[defaultViewport]),ndcControl),this.disableSyncControl=()=>{currentMode=MODE.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},SmoothCameraTransition=function SmoothCameraTransition(startingViewport,endingViewport,targetCameraIn,durationIn){var startingEyePosition=startingViewport.eyePosition,startingTargetPosition=startingViewport.targetPosition,startingUp=startingViewport.upVector,endingEyePosition=endingViewport.eyePosition,endingTargetPosition=endingViewport.targetPosition,endingUp=endingViewport.upVector,targetCamera=targetCameraIn,duration=durationIn,inbuildTime=0,enabled=!0,updateLightWithPathFlag=!0,completed=!1;targetCamera.near=Math.min(startingViewport.nearPlane,endingViewport.nearPlane),targetCamera.far=Math.max(startingViewport.farPlane,endingViewport.farPlane),targetCamera.cameraObject.up.set(endingViewport.upVector[0],endingViewport.upVector[1],endingViewport.upVector[2]),this.setDuration=newDuration=>{duration=newDuration};var updateTime=delta=>{var targetTime=inbuildTime+delta;targetTime>duration&&(targetTime=duration),inbuildTime=targetTime},updateCameraSettings=()=>{var ratio=inbuildTime/duration,eyePosition=[startingEyePosition[0]*(1-ratio)+endingEyePosition[0]*ratio,startingEyePosition[1]*(1-ratio)+endingEyePosition[1]*ratio,startingEyePosition[2]*(1-ratio)+endingEyePosition[2]*ratio],targetPosition=[startingTargetPosition[0]*(1-ratio)+endingTargetPosition[0]*ratio,startingTargetPosition[1]*(1-ratio)+endingTargetPosition[1]*ratio,startingTargetPosition[2]*(1-ratio)+endingTargetPosition[2]*ratio],upVector=[startingUp[0]*(1-ratio)+endingUp[0]*ratio,startingUp[1]*(1-ratio)+endingUp[1]*ratio,startingUp[2]*(1-ratio)+endingUp[2]*ratio];targetCamera.cameraObject.position.set(eyePosition[0],eyePosition[1],eyePosition[2]),targetCamera.cameraObject.target.set(targetPosition[0],targetPosition[1],targetPosition[2])};this.update=delta=>{!1===this.enabled||(updateTime(delta),updateCameraSettings(),inbuildTime==duration&&(completed=!0))},this.isTransitionCompleted=()=>completed},RotateCameraTransition=function RotateCameraTransition(axisIn,angleIn,targetCameraIn,durationIn){var axis=axisIn,angle=angleIn,targetCamera=targetCameraIn,duration=durationIn,inbuildTime=0,enabled=!0,ratio=inbuildTime/duration,completed=!1;this.setDuration=newDuration=>{duration=newDuration};var updateCameraSettings=delta=>{var previousTime=inbuildTime,targetTime=inbuildTime+delta;targetTime>duration&&(targetTime=duration),inbuildTime=targetTime;var actualDelta=inbuildTime-previousTime,ratio=actualDelta/duration,alpha=ratio*angle;targetCamera.rotateAboutLookAtpoint(axis,alpha)};this.update=delta=>{!1===this.enabled||(updateCameraSettings(delta),inbuildTime==duration&&(completed=!0))},this.isTransitionCompleted=()=>completed},RayCaster=function RayCaster(sceneIn,hostSceneIn,callbackFunctionIn,hoverCallbackFunctionIn,rendererIn){var scene=sceneIn,hostScene=hostSceneIn,renderer=rendererIn,callbackFunction=callbackFunctionIn,hoverCallbackFunction=hoverCallbackFunctionIn,enabled=!0,raycaster=new THREE.Raycaster;raycaster.params.Line.threshold=.1,raycaster.params.Points.threshold=1;var mouse=new THREE.Vector2,awaiting=!1,lastHoveredDate=new Date,lastHoveredEmpty=!1,timeDiff=0,pickedObjects=[],lastPosition={zincCamera:void 0,x:-1,y:-1};this.enable=()=>{enable=!0},this.disable=()=>{enable=!1};var getIntersectsObject=(zincCamera,x,y)=>{if(zincCamera.getNDCFromDocumentCoords(x,y,mouse),hostScene!==scene){var threejsScene=scene.getThreeJSScene();renderer.render(threejsScene,zincCamera.cameraObject)}raycaster.setFromCamera(mouse,zincCamera.cameraObject);var objects=scene.getPickableThreeJSObjects();//Reset pickedObjects array
|
|
1875
|
-
return pickedObjects.length=0,raycaster.intersectObjects(objects,!0,pickedObjects)};this.pick=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&callbackFunction){
|
|
1887
|
+
*/this.update=timeChanged=>{var delta=timeChanged*playRate,controlEnabled=enabled,updated=!0;return currentMode===MODE.PATH?updatePath(delta):currentMode===MODE.SMOOTH_CAMERA_TRANSITION&&smoothCameraTransitionObject?(smoothCameraTransitionObject.update(delta),smoothCameraTransitionObject.isTransitionCompleted()&&(null==smoothCameraTransitionObject,currentMode=MODE.DEFAULT),controlEnabled=!1):currentMode===MODE.ROTATE_CAMERA_TRANSITION&&rotateCameraTransitionObject?(rotateCameraTransitionObject.update(delta),rotateCameraTransitionObject.isTransitionCompleted()&&(null==rotateCameraTransitionObject,currentMode=MODE.DEFAULT),controlEnabled=!1):currentMode===MODE.AUTO_TUMBLE&&cameraAutoTumbleObject?cameraAutoTumbleObject.update(delta):currentMode===MODE.SYNC_CONTROL&&ndcControl?(handleSyncControl(),controlEnabled=!1):updated=!1,controlEnabled&&(this._state!==STATE.NONE&&(updated=!0),this._state===STATE.ROTATE||this._state===STATE.TOUCH_ROTATE?tumble():this._state===STATE.PAN||this._state===STATE.TOUCH_PAN?translate():(this._state===STATE.ZOOM||this._state===STATE.TOUCH_ZOOM||this._state===STATE.SCROLL)&&flyZoom(),this._state!==STATE.NONE&¤tMode===MODE.AUTO_TUMBLE&&cameraAutoTumbleObject&&cameraAutoTumbleObject.stopOnCameraInput,this._state===STATE.SCROLL&&(this._state=STATE.NONE)),deviceOrientationControl?(updated=!0,deviceOrientationControl.update()):this.cameraObject.lookAt(this.cameraObject.target),updated},this.playPath=()=>{currentMode=MODE.PATH},this.stopPath=()=>{currentMode=MODE.DEFAULT},this.isPlayingPath=()=>currentMode===MODE.PATH,this.enableDirectionalLightUpdateWithPath=flag=>{updateLightWithPathFlag=flag},this.enableDeviceOrientation=()=>{deviceOrientationControl||(deviceOrientationControl=new ModifiedDeviceOrientationControls(this.cameraObject))},this.disableDeviceOrientation=()=>{deviceOrientationControl&&(deviceOrientationControl.dispose(),deviceOrientationControl=void 0)},this.isDeviceOrientationEnabled=()=>!!deviceOrientationControl,this.resetView=()=>{var viewport=viewports[defaultViewport];this.cameraObject.near=viewport.nearPlane,this.cameraObject.far=viewport.farPlane,this.cameraObject.position.set(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),this.cameraObject.target.set(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),this.cameraObject.up.set(viewport.upVector[0],viewport.upVector[1],viewport.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setCurrentCameraSettings=newViewport=>{newViewport.nearPlane&&(this.cameraObject.near=newViewport.nearPlane),newViewport.farPlane&&(this.cameraObject.far=newViewport.farPlane),newViewport.eyePosition&&this.cameraObject.position.set(newViewport.eyePosition[0],newViewport.eyePosition[1],newViewport.eyePosition[2]),newViewport.targetPosition&&this.cameraObject.target.set(newViewport.targetPosition[0],newViewport.targetPosition[1],newViewport.targetPosition[2]),newViewport.upVector&&this.cameraObject.up.set(newViewport.upVector[0],newViewport.upVector[1],newViewport.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.getViewportFromCentreAndRadius=(centreX,centreY,centreZ,radius,view_angle,clip_distance)=>{var eyex=this.cameraObject.position.x-this.cameraObject.target.x,eyey=this.cameraObject.position.y-this.cameraObject.target.y,eyez=this.cameraObject.position.z-this.cameraObject.target.z,fact=1/Math.sqrt(eyex*eyex+eyey*eyey+eyez*eyez);eyex*=fact,eyey*=fact,eyez*=fact;/* look at the centre of the sphere */var localTargetPosition=[centreX,centreY,centreZ],eye_distance=radius/Math.tan(view_angle*Math.PI/360),localEyePosition=[centreX+eyex*eye_distance,centreY+eyey*eye_distance,centreZ+eyez*eye_distance],localFarPlane=eye_distance+clip_distance,localNearPlane=0,nearClippingFactor=.95;/* shift the eye position to achieve the desired view_angle */localNearPlane=clip_distance>nearClippingFactor*eye_distance?(1-nearClippingFactor)*eye_distance:eye_distance-clip_distance;var newViewport=new Viewport;return newViewport.nearPlane=localNearPlane,newViewport.farPlane=localFarPlane,newViewport.eyePosition=localEyePosition,newViewport.targetPosition=localTargetPosition,newViewport.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],newViewport},this.getViewportFromBoundingBox=(boundingBox,radiusScale)=>{var radius=boundingBox.min.distanceTo(boundingBox.max)/2*radiusScale,centreX=(boundingBox.min.x+boundingBox.max.x)/2,centreY=(boundingBox.min.y+boundingBox.max.y)/2,centreZ=(boundingBox.min.z+boundingBox.max.z)/2,clip_factor=4,viewport=this.getViewportFromCentreAndRadius(centreX,centreY,centreZ,radius,40,radius*clip_factor);return viewport},this.getCurrentViewport=()=>{var currentViewport=new Viewport;return currentViewport.nearPlane=this.cameraObject.near,currentViewport.farPlane=this.cameraObject.far,currentViewport.eyePosition[0]=this.cameraObject.position.x,currentViewport.eyePosition[1]=this.cameraObject.position.y,currentViewport.eyePosition[2]=this.cameraObject.position.z,currentViewport.targetPosition[0]=this.cameraObject.target.x,currentViewport.targetPosition[1]=this.cameraObject.target.y,currentViewport.targetPosition[2]=this.cameraObject.target.z,currentViewport.upVector[0]=this.cameraObject.up.x,currentViewport.upVector[1]=this.cameraObject.up.y,currentViewport.upVector[2]=this.cameraObject.up.z,currentViewport},this.getDefaultEyePosition=()=>eyePosition,this.getDefaultTargetPosition=()=>targetPosition,this.cameraTransition=(startingViewport,endingViewport,durationIn)=>{rotateCameraTransitionObject==null&&(smoothCameraTransitionObject=new SmoothCameraTransition(startingViewport,endingViewport,this,durationIn))},this.rotateCameraTransition=(axis,angle,duration)=>{smoothCameraTransitionObject==null&&(rotateCameraTransitionObject=new RotateCameraTransition(axis,angle,this,duration))},this.enableCameraTransition=()=>{smoothCameraTransitionObject&&(currentMode=MODE.SMOOTH_CAMERA_TRANSITION),rotateCameraTransitionObject&&(currentMode=MODE.ROTATE_CAMERA_TRANSITION)},this.pauseCameraTransition=()=>{currentMode=MODE.DEFAULT},this.stopCameraTransition=()=>{currentMode=MODE.DEFAULT,smoothCameraTransitionObject=void 0,rotateCameraTransitionObject=void 0},this.isTransitioningCamera=()=>currentMode===MODE.SMOOTH_CAMERA_TRANSITION||currentMode===MODE.ROTATE_CAMERA_TRANSITION,this.autoTumble=(tumbleDirectionIn,tumbleRateIn,stopOnCameraInputIn)=>{cameraAutoTumbleObject=new CameraAutoTumble(tumbleDirectionIn,tumbleRateIn,stopOnCameraInputIn,this)},this.enableAutoTumble=()=>{currentMode=MODE.AUTO_TUMBLE},this.stopAutoTumble=()=>{currentMode=MODE.DEFAULT,cameraAutoTumbleObject=void 0},this.updateAutoTumble=()=>{cameraAutoTumbleObject&&(cameraAutoTumbleObject.requireUpdate=!0)},this.isAutoTumble=()=>currentMode===MODE.AUTO_TUMBLE,this.enableRaycaster=(sceneIn,callbackFunctionIn,hoverCallbackFunctionIn)=>{zincRayCaster==null&&(zincRayCaster=new RayCaster(sceneIn,this.scene,callbackFunctionIn,hoverCallbackFunctionIn,this.renderer))},this.disableRaycaster=()=>{zincRayCaster.disable(),zincRayCaster=void 0},this.isSyncControl=()=>currentMpde===MODE.SYNC_CONTROL,this.enableSyncControl=()=>(currentMode=MODE.SYNC_CONTROL,ndcControl||(ndcControl=new NDCCameraControl),ndcControl.setCurrentCameraSettings(this.cameraObject,viewports[defaultViewport]),ndcControl),this.disableSyncControl=()=>{currentMode=MODE.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},SmoothCameraTransition=function SmoothCameraTransition(startingViewport,endingViewport,targetCameraIn,durationIn){var startingEyePosition=startingViewport.eyePosition,startingTargetPosition=startingViewport.targetPosition,startingUp=startingViewport.upVector,endingEyePosition=endingViewport.eyePosition,endingTargetPosition=endingViewport.targetPosition,endingUp=endingViewport.upVector,targetCamera=targetCameraIn,duration=durationIn,inbuildTime=0,enabled=!0,updateLightWithPathFlag=!0,completed=!1;targetCamera.near=Math.min(startingViewport.nearPlane,endingViewport.nearPlane),targetCamera.far=Math.max(startingViewport.farPlane,endingViewport.farPlane),targetCamera.cameraObject.up.set(endingViewport.upVector[0],endingViewport.upVector[1],endingViewport.upVector[2]),this.setDuration=newDuration=>{duration=newDuration};var updateTime=delta=>{var targetTime=inbuildTime+delta;targetTime>duration&&(targetTime=duration),inbuildTime=targetTime},updateCameraSettings=()=>{var ratio=inbuildTime/duration,eyePosition=[startingEyePosition[0]*(1-ratio)+endingEyePosition[0]*ratio,startingEyePosition[1]*(1-ratio)+endingEyePosition[1]*ratio,startingEyePosition[2]*(1-ratio)+endingEyePosition[2]*ratio],targetPosition=[startingTargetPosition[0]*(1-ratio)+endingTargetPosition[0]*ratio,startingTargetPosition[1]*(1-ratio)+endingTargetPosition[1]*ratio,startingTargetPosition[2]*(1-ratio)+endingTargetPosition[2]*ratio],upVector=[startingUp[0]*(1-ratio)+endingUp[0]*ratio,startingUp[1]*(1-ratio)+endingUp[1]*ratio,startingUp[2]*(1-ratio)+endingUp[2]*ratio];targetCamera.cameraObject.position.set(eyePosition[0],eyePosition[1],eyePosition[2]),targetCamera.cameraObject.target.set(targetPosition[0],targetPosition[1],targetPosition[2])};this.update=delta=>{!1===this.enabled||(updateTime(delta),updateCameraSettings(),inbuildTime==duration&&(completed=!0))},this.isTransitionCompleted=()=>completed},RotateCameraTransition=function RotateCameraTransition(axisIn,angleIn,targetCameraIn,durationIn){var axis=axisIn,angle=angleIn,targetCamera=targetCameraIn,duration=durationIn,inbuildTime=0,enabled=!0,ratio=inbuildTime/duration,completed=!1;this.setDuration=newDuration=>{duration=newDuration};var updateCameraSettings=delta=>{var previousTime=inbuildTime,targetTime=inbuildTime+delta;targetTime>duration&&(targetTime=duration),inbuildTime=targetTime;var actualDelta=inbuildTime-previousTime,ratio=actualDelta/duration,alpha=ratio*angle;targetCamera.rotateAboutLookAtpoint(axis,alpha)};this.update=delta=>{!1===this.enabled||(updateCameraSettings(delta),inbuildTime==duration&&(completed=!0))},this.isTransitionCompleted=()=>completed},RayCaster=function RayCaster(sceneIn,hostSceneIn,callbackFunctionIn,hoverCallbackFunctionIn,rendererIn){var scene=sceneIn,hostScene=hostSceneIn,renderer=rendererIn,callbackFunction=callbackFunctionIn,hoverCallbackFunction=hoverCallbackFunctionIn,enabled=!0,raycaster=new THREE.Raycaster;raycaster.params.Line.threshold=.1,raycaster.params.Points.threshold=1;var mouse=new THREE.Vector2,awaiting=!1,lastHoveredDate=new Date,lastHoveredEmpty=!1,timeDiff=0,pickedObjects=[],lastPosition={zincCamera:void 0,x:-1,y:-1};this.enable=()=>{enable=!0},this.disable=()=>{enable=!1},this.getIntersectsObject=zincCamera=>{if(hostScene!==scene){var threejsScene=scene.getThreeJSScene();renderer.render(threejsScene,zincCamera.cameraObject)}var objects=scene.getPickableThreeJSObjects();//Reset pickedObjects array
|
|
1888
|
+
return pickedObjects.length=0,raycaster.intersectObjects(objects,!0,pickedObjects)},this.getIntersectsObjectWithOrigin=(zincCamera,origin,direction)=>(raycaster.set(origin,direction),this.getIntersectsObject(zincCamera));var getIntersectsObjectWithCamera=(zincCamera,x,y)=>(zincCamera.getNDCFromDocumentCoords(x,y,mouse),raycaster.setFromCamera(mouse,zincCamera.cameraObject),this.getIntersectsObject(zincCamera));this.pick=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&callbackFunction){getIntersectsObjectWithCamera(zincCamera,x,y);for(var zincObject,length=pickedObjects.length,i=0;i<length;i++)if(zincObject=pickedObjects[i].object?pickedObjects[i].object.userData:void 0,zincObject&&zincObject.isMarkerCluster&&zincObject.visible&&zincObject.clusterIsVisible(pickedObjects[i].object.clusterIndex))return void zincObject.zoomToCluster(pickedObjects[i].object.clusterIndex);callbackFunction(pickedObjects,x,y)}};var hovered=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&hoverCallbackFunction){if(getIntersectsObjectWithCamera(zincCamera,x,y),lastHoveredDate.setTime(Date.now()),0===pickedObjects.length){//skip hovered callback if the previous one is empty
|
|
1876
1889
|
if(lastHoveredEmpty)return;lastHoveredEmpty=!0}else lastHoveredEmpty=!1;hoverCallbackFunction(pickedObjects,x,y)}};this.move=(zincCamera,x,y)=>{enabled&&renderer&&scene&&zincCamera&&hoverCallbackFunction&&(scene.displayMarkers?hovered(zincCamera,x,y):(lastPosition.zincCamera=zincCamera,lastPosition.x=x,lastPosition.y=y,!awaiting&&(timeDiff=lastHoveredDate?Date.now()-lastHoveredDate.getTime():250,250<=timeDiff?hovered(zincCamera,x,y):(awaiting=!0,setTimeout(awaitMove(lastPosition),timeDiff)))))};var awaitMove=lastPosition=>function(){awaiting=!1,hovered(lastPosition.zincCamera,lastPosition.x,lastPosition.y)}},CameraAutoTumble=function CameraAutoTumble(tumbleDirectionIn,tumbleRateIn,stopOnCameraInputIn,targetCameraIn){var tumbleAxis=new THREE.Vector3,angle=-tumbleRateIn,targetCamera=targetCameraIn,enabled=!0,updateLightWithPathFlag=!0,tumbleDirection=tumbleDirectionIn;this.stopOnCameraInput=stopOnCameraInputIn,this.requireUpdate=!0;var b=new THREE.Vector3,c=new THREE.Vector3,computeTumbleAxisAngle=tumbleDirection=>{var tangent_dist=Math.sqrt(tumbleDirection[0]*tumbleDirection[0]+tumbleDirection[1]*tumbleDirection[1]),width=4*Math.abs(tumbleDirection[0]),height=4*Math.abs(tumbleDirection[1]),radius=.25*(width+height),dx=-tumbleDirection[1]/tangent_dist,dy=tumbleDirection[0]/tangent_dist,d=dx*tumbleDirection[0]+dy*-tumbleDirection[1];d>radius?d=radius:d<-radius&&(d=-radius);var phi=Math.acos(d/radius)-.5*Math.PI;/* get axis to rotate about */tumbleAxis.copy(targetCamera.cameraObject.position).sub(targetCamera.cameraObject.target).normalize(),b.copy(targetCamera.cameraObject.up).normalize(),c.crossVectors(b,tumbleAxis).normalize().multiplyScalar(dx),b.multiplyScalar(dy),b.add(c).multiplyScalar(Math.cos(phi)),tumbleAxis.multiplyScalar(Math.sin(phi)).add(b)};this.update=delta=>{!1===this.enabled||(this.requireUpdate&&(computeTumbleAxisAngle(tumbleDirection),this.requireUpdate=!1),targetCamera.rotateAboutLookAtpoint(tumbleAxis,angle*delta/1e3))}},StereoCameraZoomFixed=function StereoCameraZoomFixed(){this.type="StereoCamera",this.aspect=1,this.cameraL=new THREE.PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new THREE.PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1};/**
|
|
1877
1890
|
* Object with containg viewport information used in ZincJS.
|
|
1878
1891
|
*
|
|
@@ -2179,7 +2192,7 @@ allObjects.forEach(zincObject=>{zincObject.render(playRate*delta,playAnimation,c
|
|
|
2179
2192
|
/* 45 */
|
|
2180
2193
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2181
2194
|
|
|
2182
|
-
var THREE=__webpack_require__(4),
|
|
2195
|
+
var THREE=__webpack_require__(4),toBufferGeometry=(__webpack_require__(5).toBufferGeometry),LineSegments2=(__webpack_require__(46).LineSegments2),LineMaterial=(__webpack_require__(48).LineMaterial),LineSegmentsGeometry=(__webpack_require__(47).LineSegmentsGeometry),Lines2=function(){(__webpack_require__(24).Lines).call(this),this.isLines2=!0;var positions=Array(300);/**
|
|
2183
2196
|
* Create the line segements using geometry and material.
|
|
2184
2197
|
*
|
|
2185
2198
|
* @param {Array} arrayIn - Geometry of lines to be rendered.
|
|
@@ -2206,7 +2219,7 @@ var THREE=__webpack_require__(4),createBufferGeometry=(__webpack_require__(5).cr
|
|
|
2206
2219
|
|
|
2207
2220
|
* @param {Number} colour - A hex value of the colour for the points
|
|
2208
2221
|
*/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.
|
|
2209
|
-
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.
|
|
2222
|
+
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)}};/**
|
|
2210
2223
|
* Provides an object which stores lines.
|
|
2211
2224
|
* This is created when a valid json file containing lines is read into a {@link Zinc.Scene}
|
|
2212
2225
|
* object.
|