zincjs 1.13.0 → 1.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/zinc.frontend.js +1 -1
- package/build/zinc.js +13 -12
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/loaders/JSONLoader.js +12 -4
- package/src/primitives/textureSlides.js +52 -26
- package/src/scene.js +6 -6
- package/src/sceneLoader.js +2 -2
- package/src/shaders/textureSlide.js +5 -1
- package/src/texture/textureArray.js +2 -1
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.13.
|
|
35
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.13.2","description":"ZincJS (Web-based-Zinc-Visualisation)","main":"build/zinc.js","directories":{"doc":"docs"},"files":["package.json","LICENSE","README.md","src/*","build/zinc.js","build/zinc.frontend.js","build/zinc.js.map","webpack.config.js"],"scripts":{"build-bundle":"webpack --config webpack.frontend.js; webpack --config webpack.backend.js","build-backend":"webpack --config webpack.backend.js","test":"npm --prefix ./test install && npm --prefix ./test run test-ci","changelog":"auto-changelog -p --output CHANGELOG.md --template keepachangelog","jsdoc":"jsdoc -c jsdoc_conf.json","version":"npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs","release:beta":"npm version prerelease --preid=beta; npm publish --tag beta","release:minor":"npm version minor; npm publish","release:patch":"npm version patch; npm publish"},"repository":{"type":"git","url":"git+https://github.com/alan-wu/ZincJS.git"},"keywords":["library","webgl","3d","zincjs"],"author":"Alan Wu <alan.wu@auckland.ac.nz>","license":"MIT","bugs":{"url":"https://github.com/alan-wu/ZincJS/issues"},"homepage":"http://alan-wu.github.io/ZincJS/","devDependencies":{"@babel/core":"^7.23.9","@babel/preset-env":"^7.23.9","auto-changelog":"^2.4.0","babel-loader":"^9.1.3","babel-preset-minify":"^0.5.1","file-loader":"^6.2.0","jsdoc":"^4.0.2","raw-loader":"^4.0.2","webpack":"^5.90.3","webpack-cli":"^5.1.4","webpack-node-externals":"^3.0.0"},"dependencies":{"css-element-queries":"^1.2.2","lodash":"^4.17.19","promise-polyfill":"^8.1.3","three":"^0.130.1","three-spritetext":"1.6.2","url-loader":"^4.1.1","url-polyfill":"^1.1.7","webworkify-webpack":"^2.1.5"}}');
|
|
36
36
|
|
|
37
37
|
/***/ }),
|
|
38
38
|
/* 3 */
|
|
@@ -717,7 +717,7 @@ var THREE=__webpack_require__(4),Loader=(__webpack_require__(20).Loader),LoaderU
|
|
|
717
717
|
* @author mrdoob / http://mrdoob.com/
|
|
718
718
|
* @author alteredq / http://alteredqualia.com/
|
|
719
719
|
*/function JSONLoader(manager){"boolean"==typeof manager&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),manager=void 0),this.manager=manager===void 0?DefaultLoadingManager:manager,this.withCredentials=!1,this.paramsString=""}Object.assign(JSONLoader.prototype,{load:function load(url,onLoad,onProgress,onError){var scope=this,texturePath=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:LoaderUtils.extractUrlBase(url),loader=new FileLoader(this.manager),params=url.split("?");//There are parameters, add them to the target
|
|
720
|
-
this.paramsString=2===url.length?paramsStrings[1]:"",loader.setWithCredentials(this.withCredentials),loader.load(url,function(text){var json;try{json=JSON.parse(text)}catch(e){if(console.error("The loader has encountered an error while parsing the content of a resource."),onError)return void onError({responseURL:url})}var metadata=json.metadata;if(metadata!==void 0){var type=metadata.type;if(type!==void 0&&"object"===type.toLowerCase())return void console.error("THREE.JSONLoader: "+url+" should be loaded with THREE.ObjectLoader instead.")}if(scope&&scope.parse){var object=scope.parse(json,texturePath);onLoad(object.geometry,object.materials)}},onProgress,onError)},setTexturePath:function setTexturePath(value){this.texturePath=value},parse:function(){function parseModel(json,geometry){function isBitSet(value,position){return value&1<<position}var i,j,fi,offset,zLength,colorIndex,normalIndex,uvIndex,materialIndex,type,isQuad,hasMaterial,hasFaceVertexUv,hasFaceNormal,hasFaceVertexNormal,hasFaceColor,hasFaceVertexColor,vertex,face,faceA,faceB,hex,normal,uvLayer,uv,u,v,faces=json.faces,vertices=json.vertices,normals=json.normals,colors=json.colors,scale=json.scale,nUvLayers=0;if(void 0!==json.uvs){// disregard empty arrays
|
|
720
|
+
this.paramsString=2===url.length?paramsStrings[1]:"",loader.setWithCredentials(this.withCredentials),loader.load(url,function(text){var json;try{json=JSON.parse(text)}catch(e){if(console.error("The loader has encountered an error while parsing the content of a resource."),onError)return void onError({responseURL:url})}var metadata=json.metadata;if(metadata!==void 0){var type=metadata.type;if(type!==void 0&&"object"===type.toLowerCase())return void console.error("THREE.JSONLoader: "+url+" should be loaded with THREE.ObjectLoader instead.")}if(scope&&scope.parse)try{var object=scope.parse(json,texturePath);onLoad(object.geometry,object.materials)}catch(e){if(console.error("The loader has encountered aon loading the geometry"),console.error(e),onError)return void onError({responseURL:url})}},onProgress,onError)},setTexturePath:function setTexturePath(value){this.texturePath=value},parse:function(){function parseModel(json,geometry){function isBitSet(value,position){return value&1<<position}var i,j,fi,offset,zLength,colorIndex,normalIndex,uvIndex,materialIndex,type,isQuad,hasMaterial,hasFaceVertexUv,hasFaceNormal,hasFaceVertexNormal,hasFaceColor,hasFaceVertexColor,vertex,face,faceA,faceB,hex,normal,uvLayer,uv,u,v,faces=json.faces,vertices=json.vertices,normals=json.normals,colors=json.colors,scale=json.scale,nUvLayers=0;if(void 0!==json.uvs){// disregard empty arrays
|
|
721
721
|
for(i=0;i<json.uvs.length;i++)json.uvs[i].length&&nUvLayers++;for(i=0;i<nUvLayers;i++)geometry.faceVertexUvs[i]=[]}for(offset=0,zLength=vertices.length;offset<zLength;)vertex=new Vector3,vertex.x=vertices[offset++]*scale,vertex.y=vertices[offset++]*scale,vertex.z=vertices[offset++]*scale,geometry.vertices.push(vertex);if(offset=0,zLength=faces.length,json.uvs)for(i=0;i<json.uvs.length;i++){geometry.uvs[i]=[];for(var k=0;k<json.uvs[i].length;k++)geometry.uvs[i][k]=json.uvs[i][k]}if(normals)for(i=0;i<normals.length;i++)geometry.normals[i]=normals[i];if(colors)for(i=0;i<colors.length;i++)geometry.colors[i]=colors[i];for(;offset<zLength;)// console.log("type", type, "bits", isQuad, hasMaterial, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor);
|
|
722
722
|
if(type=faces[offset++],isQuad=isBitSet(type,0),hasMaterial=isBitSet(type,1),hasFaceVertexUv=isBitSet(type,3),hasFaceNormal=isBitSet(type,4),hasFaceVertexNormal=isBitSet(type,5),hasFaceColor=isBitSet(type,6),hasFaceVertexColor=isBitSet(type,7),isQuad){if(faceA=new Face3,faceA.a=faces[offset],faceA.b=faces[offset+1],faceA.c=faces[offset+3],faceB=new Face3,faceB.a=faces[offset+1],faceB.b=faces[offset+2],faceB.c=faces[offset+3],offset+=4,hasMaterial&&(materialIndex=faces[offset++],faceA.materialIndex=materialIndex,faceB.materialIndex=materialIndex),fi=geometry.faces.length,hasFaceVertexUv)for(i=0;i<nUvLayers;i++)for(uvLayer=json.uvs[i],geometry.faceVertexUvs[i][fi]=[],geometry.faceVertexUvs[i][fi+1]=[],j=0;4>j;j++)uvIndex=faces[offset++],u=uvLayer[2*uvIndex],v=uvLayer[2*uvIndex+1],uv=new Vector2(u,v),2!==j&&geometry.faceVertexUvs[i][fi].push(uv),0!==j&&geometry.faceVertexUvs[i][fi+1].push(uv);if(hasFaceNormal&&(normalIndex=3*faces[offset++],faceA.normal.set(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),faceB.normal.copy(faceA.normal)),hasFaceVertexNormal)for(i=0;4>i;i++)normalIndex=3*faces[offset++],normal=new Vector3(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),2!==i&&faceA.vertexNormals.push(normal),0!==i&&faceB.vertexNormals.push(normal);if(hasFaceColor&&(colorIndex=faces[offset++],hex=colors[colorIndex],faceA.color.setHex(hex),faceB.color.setHex(hex)),hasFaceVertexColor)for(i=0;4>i;i++)colorIndex=faces[offset++],hex=colors[colorIndex],2!==i&&faceA.vertexColors.push(new Color(hex)),0!==i&&faceB.vertexColors.push(new Color(hex));geometry.faces.push(faceA),geometry.faces.push(faceB)}else{if(face=new Face3,face.a=faces[offset++],face.b=faces[offset++],face.c=faces[offset++],hasMaterial&&(materialIndex=faces[offset++],face.materialIndex=materialIndex),fi=geometry.faces.length,hasFaceVertexUv)for(i=0;i<nUvLayers;i++)for(uvLayer=json.uvs[i],geometry.faceVertexUvs[i][fi]=[],j=0;3>j;j++)uvIndex=faces[offset++],u=uvLayer[2*uvIndex],v=uvLayer[2*uvIndex+1],uv=new Vector2(u,v),geometry.faceVertexUvs[i][fi].push(uv);if(hasFaceNormal&&(normalIndex=3*faces[offset++],face.normal.set(normals[normalIndex++],normals[normalIndex++],normals[normalIndex])),hasFaceVertexNormal)for(i=0;3>i;i++)normalIndex=3*faces[offset++],normal=new Vector3(normals[normalIndex++],normals[normalIndex++],normals[normalIndex]),face.vertexNormals.push(normal);if(hasFaceColor&&(colorIndex=faces[offset++],face.color.setHex(colors[colorIndex])),hasFaceVertexColor)for(i=0;3>i;i++)colorIndex=faces[offset++],face.vertexColors.push(new Color(colors[colorIndex]));geometry.faces.push(face)}}function parseSkin(json,geometry){var influencesPerVertex=json.influencesPerVertex===void 0?2:json.influencesPerVertex;if(json.skinWeights)for(var i=0,l=json.skinWeights.length;i<l;i+=influencesPerVertex){var x=json.skinWeights[i],y=1<influencesPerVertex?json.skinWeights[i+1]:0,z=2<influencesPerVertex?json.skinWeights[i+2]:0,w=3<influencesPerVertex?json.skinWeights[i+3]:0;geometry.skinWeights.push(new Vector4(x,y,z,w))}if(json.skinIndices)for(var i=0,l=json.skinIndices.length;i<l;i+=influencesPerVertex){var a=json.skinIndices[i],b=1<influencesPerVertex?json.skinIndices[i+1]:0,c=2<influencesPerVertex?json.skinIndices[i+2]:0,d=3<influencesPerVertex?json.skinIndices[i+3]:0;geometry.skinIndices.push(new Vector4(a,b,c,d))}geometry.bones=json.bones,geometry.bones&&0<geometry.bones.length&&(geometry.skinWeights.length!==geometry.skinIndices.length||geometry.skinIndices.length!==geometry.vertices.length)&&console.warn("When skinning, number of vertices ("+geometry.vertices.length+"), skinIndices ("+geometry.skinIndices.length+"), and skinWeights ("+geometry.skinWeights.length+") should match.")}function parseMorphing(json,geometry){var scale=json.scale;if(json.morphTargets!==void 0)for(var i=0,l=json.morphTargets.length;i<l;i++){geometry.morphTargets[i]={},geometry.morphTargets[i].name=json.morphTargets[i].name,geometry.morphTargets[i].vertices=[];for(var vertex,dstVertices=geometry.morphTargets[i].vertices,srcVertices=json.morphTargets[i].vertices,v=0,vl=srcVertices.length;v<vl;v+=3)vertex=new Vector3,vertex.x=srcVertices[v]*scale,vertex.y=srcVertices[v+1]*scale,vertex.z=srcVertices[v+2]*scale,dstVertices.push(vertex)}if(void 0!==json.morphNormals)for(var i=0,l=json.morphNormals.length;i<l;i++)if(geometry.morphTargets[i]){geometry.morphTargets[i].normals=[];for(var normals,dstNormals=geometry.morphTargets[i].normals,srcNormals=json.morphNormals[i].normals,v=0,vl=srcNormals.length;v<vl;v+=3)normals=new Vector3,normals.x=srcNormals[v],normals.y=srcNormals[v+1],normals.z=srcNormals[v+2],dstNormals.push(normals);geometry.morphNormalsReady=!0}if(void 0!==json.morphColors){var i,l,c,cl,dstColors,srcColors,color;for(i=0,l=json.morphColors.length;i<l;i++)for(geometry.morphColors[i]={},geometry.morphColors[i].name=json.morphColors[i].name,geometry.morphColors[i].colors=[],dstColors=geometry.morphColors[i].colors,srcColors=json.morphColors[i].colors,(c=0,cl=srcColors.length);c<cl;c+=3)color=new THREE.Color(16755200),color.setRGB(srcColors[c],srcColors[c+1],srcColors[c+2]),dstColors.push(color)}}function parseAnimations(json,geometry){var outputAnimations=[],animations=[];// parse old style Bone/Hierarchy animations
|
|
723
723
|
json.animation!==void 0&&animations.push(json.animation),json.animations!==void 0&&(json.animations.length?animations=animations.concat(json.animations):animations.push(json.animations));for(var clip,i=0;i<animations.length;i++)clip=AnimationClip.parseAnimation(animations[i],geometry.bones),clip&&outputAnimations.push(clip);// parse implicit morph animations
|
|
@@ -878,7 +878,7 @@ function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var inf
|
|
|
878
878
|
* @param {Object} options.uniforms - Containing the data to be passed into the shaders.
|
|
879
879
|
* @param {String} options.glslVersion - Version of glsl used for compile this shader.
|
|
880
880
|
*
|
|
881
|
-
*/(__webpack_require__(26).Texture).call(this),this.isTextureArray=!0,this.loadFromImages=/*#__PURE__*/function(){var _ref=_asyncToGenerator(function*(srcArrays){var w=1,h=1,d=0;if(srcArrays&&srcArrays.length){_this.isLoading=!0;var image=new Image;image.crossOrigin="Anonymous";for(var data,canvas=document.createElement("canvas"),length=0,dataStacks=Array(srcArrays.length),i=0;i<srcArrays.length;i++)data=yield _this.imageToUint8Array(_this,image,srcArrays[i],canvas),data&&data.array&&(w=data.width,h=data.height,dataStacks[d]=data.array,length+=dataStacks[d].length,d++);var fullArray=new Uint8Array(length);length=0,dataStacks.forEach(data=>{fullArray.set(data,length),length+=data.length}),_this.impl=new THREE.DataTexture2DArray(fullArray,w,h,d),_this.size={width:w,height:h,depth:d},_this.isLoading=!1,_this.impl.needsUpdate=!0}});return function(){return _ref.apply(this,arguments)}}(),this.getMaterial=options=>{if(this.impl){var material;if(!options)material=new THREE.MeshBasicMaterial({color:new THREE.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:THREE.DoubleSide});else if(options.vs&&options.fs){var transparent=!0;options
|
|
881
|
+
*/(__webpack_require__(26).Texture).call(this),this.isTextureArray=!0,this.loadFromImages=/*#__PURE__*/function(){var _ref=_asyncToGenerator(function*(srcArrays){var w=1,h=1,d=0;if(srcArrays&&srcArrays.length){_this.isLoading=!0;var image=new Image;image.crossOrigin="Anonymous";for(var data,canvas=document.createElement("canvas"),length=0,dataStacks=Array(srcArrays.length),i=0;i<srcArrays.length;i++)data=yield _this.imageToUint8Array(_this,image,srcArrays[i],canvas),data&&data.array&&(w=data.width,h=data.height,dataStacks[d]=data.array,length+=dataStacks[d].length,d++);var fullArray=new Uint8Array(length);length=0,dataStacks.forEach(data=>{fullArray.set(data,length),length+=data.length}),_this.impl=new THREE.DataTexture2DArray(fullArray,w,h,d),_this.size={width:w,height:h,depth:d},_this.isLoading=!1,_this.impl.needsUpdate=!0}});return function(){return _ref.apply(this,arguments)}}(),this.getMaterial=options=>{if(this.impl){var material;if(!options)material=new THREE.MeshBasicMaterial({color:new THREE.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:THREE.DoubleSide});else if(options.vs&&options.fs){var transparent=!0;"transparent"in options&&(transparent=options.transparent);var side=THREE.FrontSide;options.side&&(side=options.side),material=new THREE.ShaderMaterial({transparent,uniforms:options.uniforms,vertexShader:options.vs,fragmentShader:options.fs,side}),options.glslVersion&&(material.glslVersion=options.glslVersion)}if(material)return material.needsUpdate=!0,material}}};/**
|
|
882
882
|
* Texture array object for holding array of images into
|
|
883
883
|
* texures unit that can be used by other texture primitives.
|
|
884
884
|
*
|
|
@@ -935,7 +935,7 @@ function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var inf
|
|
|
935
935
|
/* 27 */
|
|
936
936
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
937
937
|
|
|
938
|
-
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;/**
|
|
938
|
+
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 edgesLine=void 0,flipY=!0;/**
|
|
939
939
|
@typedef SLIDE_SETTINGS
|
|
940
940
|
@type {Set}
|
|
941
941
|
@property {String} direction - the value must be x, y or z, specify the
|
|
@@ -955,18 +955,19 @@ function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var
|
|
|
955
955
|
*
|
|
956
956
|
* @param {THREE.Mesh} mesh - Mesh to be modified
|
|
957
957
|
* @param {SLIDE_SETTINGS} slideSettings - Slide settings.
|
|
958
|
-
*/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
|
|
958
|
+
*/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=-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};/**
|
|
959
959
|
* Modify the mesh based on a setting
|
|
960
960
|
*
|
|
961
961
|
* @param {SLIDE_SETTINGS} settings - s.
|
|
962
962
|
*/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
|
|
963
|
-
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:}};/**
|
|
963
|
+
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:}};/**
|
|
964
964
|
* Get the bounding box of this slides.
|
|
965
965
|
* It uses the max and min of the slides position and the
|
|
966
966
|
* transformation to calculate the position of the box.
|
|
967
967
|
*
|
|
968
968
|
* @return {THREE.Box3}.
|
|
969
|
-
*/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.
|
|
969
|
+
*/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
|
|
970
|
+
this.morph.renderOrder=order},this.initialise=(textureData,finishCallback)=>{if(textureData){var locations=textureData.locations;locations&&0<locations.length&&(this.applyTransformation(locations[0].orientation,locations[0].position,locations[0].scale),"flipY"in locations[0]&&(flipY=locations[0].flipY)),this.createSlides(textureData.settings.slides),finishCallback!=null&&"function"==typeof finishCallback&&finishCallback(this)}},this.showEdges=color=>{if(!edgesLine){var geometry=new THREE.BoxGeometry(1,1,1);geometry.translate(.5,.5,.5);var edges=new THREE.EdgesGeometry(geometry);edgesLine=new THREE.LineSegments(edges,new THREE.LineBasicMaterial({color})),this.group.add(edgesLine)}else edgesLine.material.color=color;edgesLine.visible=!0},this.hideEdges=()=>{edgesLine&&(edgesLine.visible=!1)}};/**
|
|
970
971
|
* Provides a class which create a texture stacks in a block
|
|
971
972
|
* with shaders allowing slices of texture to be displayed.
|
|
972
973
|
*
|
|
@@ -982,7 +983,7 @@ var expandBoxWithSettings=(box,settings,vector)=>{switch(settings.direction.valu
|
|
|
982
983
|
/* 28 */
|
|
983
984
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
984
985
|
|
|
985
|
-
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
|
|
986
|
+
var THREE=__webpack_require__(4),glslVersion=THREE.GLSL3,fs="\nprecision highp float;\nprecision highp int;\nprecision highp sampler2DArray;\n\nuniform sampler2DArray diffuse;\nuniform bool discardAlpha;\nin vec3 vUw;\n\nout vec4 outColor;\n\nvoid main() {\n\n vec4 color = texture( diffuse, vUw );\n\n // lighten a bit\n if (discardAlpha && color.a == 0.0) discard;\n\n outColor = vec4( color.rgba );\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},discardAlpha:{value:!0}}};exports.fs=fs,exports.vs=vs,exports.glslVersion=glslVersion,exports.getUniforms=getUniforms;
|
|
986
987
|
|
|
987
988
|
/***/ }),
|
|
988
989
|
/* 29 */
|
|
@@ -1097,11 +1098,11 @@ var THREE=__webpack_require__(4),MarkerCluster=(__webpack_require__(33).MarkerCl
|
|
|
1097
1098
|
* in this scene.
|
|
1098
1099
|
* @returns {Array}
|
|
1099
1100
|
*/this.getDownloadProgress=()=>sceneLoader.getDownloadProgress(),this.onWindowResize=()=>{var wHeight=getDrawingHeight();this.camera.aspect=getDrawingWidth()/wHeight,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,zincCameraControls.onResize(),zincCameraControls.calculateHeightPerPixelAtZeroDepth(wHeight)},this.resetView=()=>{this.onWindowResize(),zincCameraControls.resetView()},this.changeZoomByScrollRateUnit=unit=>{zincCameraControls.changeZoomByScrollRateUnit(unit)};//Setup the camera for this scene, it also initialise the lighting
|
|
1100
|
-
var setupCamera=()=>{this.camera=new THREE.PerspectiveCamera(40,getDrawingWidth()/getDrawingHeight(),0,10),this.ambient=new THREE.AmbientLight(16777215,.2),scene.add(this.ambient),this.directionalLight=new THREE.DirectionalLight(16777215,.8),scene.add(this.directionalLight),zincCameraControls=new((__webpack_require__(43).CameraControls))(this.camera,rendererIn.domElement,rendererIn,this),zincCameraControls.setDirectionalLight(this.directionalLight),zincCameraControls.resetView(),minimap=new((__webpack_require__(49).Minimap))(this)};setupCamera(),this.loadView=settings=>{var viewPort=new Viewport;return viewPort.setFromObject(settings),zincCameraControls.setCurrentCameraSettings(viewPort),!0},this.setupMultipleViews=(defaultView,entries)=>{for(var[name,settings]of Object.entries(entries)){var viewport=new Viewport;viewport.setFromObject(settings),zincCameraControls.addViewport(name,viewport)}zincCameraControls.setDefaultViewport(defaultView)},this.getBoundingBox=()=>rootRegion.getBoundingBox(!0),this.viewAllWithBoundingBox=boundingBox=>{if(boundingBox){var viewport=zincCameraControls.getViewportFromBoundingBox(boundingBox,1);zincCameraControls.setCurrentCameraSettings(viewport),zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight()),markerCluster.markerUpdateRequired=!0}},this.viewAll=()=>{var boundingBox=this.getBoundingBox();this.viewAllWithBoundingBox(boundingBox),markerCluster.markerUpdateRequired=!0},this.forEachGeometry=callbackFunction=>{rootRegion.forEachGeometry(callbackFunction,!0)},this.forEachGlyphset=callbackFunction=>{rootRegion.forEachGlyphset(callbackFunction,!0)},this.forEachPointset=callbackFunction=>{rootRegion.forEachPointset(callbackFunction,!0)},this.forEachLine=callbackFunction=>{rootRegion.forEachLine(callbackFunction,!0)},this.findGeometriesWithGroupName=GroupName=>rootRegion.findGeometriesWithGroupName(GroupName,!0),this.findPointsetsWithGroupName=GroupName=>rootRegion.findPointsetsWithGroupName(GroupName,!0),this.findGlyphsetsWithGroupName=GroupName=>rootRegion.findGlyphsetsWithGroupName(GroupName,!0),this.findLinesWithGroupName=GroupName=>rootRegion.findLinesWithGroupName(GroupName,!0),this.findObjectsWithGroupName=GroupName=>rootRegion.findObjectsWithGroupName(GroupName,!0),this.findObjectsWithAnatomicalId=anatomicalId=>rootRegion.findObjectsWithAnatomicalId(anatomicalId,!0),this.getBoundingBoxOfZincObjects=objectsArray=>{for(var box,boundingBox=void 0,i=0;i<objectsArray.length;i++)box=objectsArray[i].getBoundingBox(),box&&(boundingBox?boundingBox.union(box):boundingBox=box);return boundingBox},this.vectorToScreenXY=point=>{point.project(this.camera);var width=getDrawingWidth(),height=getDrawingHeight(),widthHalf=width/2,heightHalf=height/2;return point.x=point.x*widthHalf+widthHalf,point.y=-(point.y*heightHalf)+heightHalf,point},this.getObjectsScreenXY=zincObjects=>{if(zincObjects&&0<zincObjects.length){var boundingBox=this.getBoundingBoxOfZincObjects(zincObjects),
|
|
1101
|
+
var setupCamera=()=>{this.camera=new THREE.PerspectiveCamera(40,getDrawingWidth()/getDrawingHeight(),0,10),this.ambient=new THREE.AmbientLight(16777215,.2),scene.add(this.ambient),this.directionalLight=new THREE.DirectionalLight(16777215,.8),scene.add(this.directionalLight),zincCameraControls=new((__webpack_require__(43).CameraControls))(this.camera,rendererIn.domElement,rendererIn,this),zincCameraControls.setDirectionalLight(this.directionalLight),zincCameraControls.resetView(),minimap=new((__webpack_require__(49).Minimap))(this)};setupCamera(),this.loadView=settings=>{var viewPort=new Viewport;return viewPort.setFromObject(settings),zincCameraControls.setCurrentCameraSettings(viewPort),!0},this.setupMultipleViews=(defaultView,entries)=>{for(var[name,settings]of Object.entries(entries)){var viewport=new Viewport;viewport.setFromObject(settings),zincCameraControls.addViewport(name,viewport)}zincCameraControls.setDefaultViewport(defaultView)},this.getBoundingBox=()=>rootRegion.getBoundingBox(!0),this.viewAllWithBoundingBox=boundingBox=>{if(boundingBox){var viewport=zincCameraControls.getViewportFromBoundingBox(boundingBox,1);zincCameraControls.setCurrentCameraSettings(viewport),zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight()),markerCluster.markerUpdateRequired=!0}},this.viewAll=()=>{var boundingBox=this.getBoundingBox();this.viewAllWithBoundingBox(boundingBox),markerCluster.markerUpdateRequired=!0},this.forEachGeometry=callbackFunction=>{rootRegion.forEachGeometry(callbackFunction,!0)},this.forEachGlyphset=callbackFunction=>{rootRegion.forEachGlyphset(callbackFunction,!0)},this.forEachPointset=callbackFunction=>{rootRegion.forEachPointset(callbackFunction,!0)},this.forEachLine=callbackFunction=>{rootRegion.forEachLine(callbackFunction,!0)},this.findGeometriesWithGroupName=GroupName=>rootRegion.findGeometriesWithGroupName(GroupName,!0),this.findPointsetsWithGroupName=GroupName=>rootRegion.findPointsetsWithGroupName(GroupName,!0),this.findGlyphsetsWithGroupName=GroupName=>rootRegion.findGlyphsetsWithGroupName(GroupName,!0),this.findLinesWithGroupName=GroupName=>rootRegion.findLinesWithGroupName(GroupName,!0),this.findObjectsWithGroupName=GroupName=>rootRegion.findObjectsWithGroupName(GroupName,!0),this.findObjectsWithAnatomicalId=anatomicalId=>rootRegion.findObjectsWithAnatomicalId(anatomicalId,!0),this.getBoundingBoxOfZincObjects=objectsArray=>{for(var box,boundingBox=void 0,i=0;i<objectsArray.length;i++)box=objectsArray[i].getBoundingBox(),box&&(boundingBox?boundingBox.union(box):boundingBox=box);return boundingBox},this.vectorToScreenXY=point=>{point.project(this.camera);var width=getDrawingWidth(),height=getDrawingHeight(),widthHalf=width/2,heightHalf=height/2;return point.x=point.x*widthHalf+widthHalf,point.y=-(point.y*heightHalf)+heightHalf,point},this.getObjectsScreenXY=zincObjects=>{if(zincObjects&&0<zincObjects.length){var boundingBox=this.getBoundingBoxOfZincObjects(zincObjects),center=new THREE.Vector3;return boundingBox.getCenter(center),this.vectorToScreenXY(center)}},this.getNamedObjectsScreenXY=name=>{var zincObjects=this.findObjectsWithGroupName(name);return this.getObjectsScreenXY(zincObjects)},this.addZincObject=zincObject=>{zincObject&&(rootRegion.addZincObject(zincObject),zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(metaurl,glyphurl,groupName,finishCallback)=>{sceneLoader.loadGlyphsetURL(rootRegion,metaurl,glyphurl,groupName,finishCallback)},this.loadPointsetURL=(url,timeEnabled,morphColour,groupName,finishCallback)=>{sceneLoader.loadPointsetURL(rootRegion,url,timeEnabled,morphColour,groupName,finishCallback)},this.loadLinesURL=(url,timeEnabled,morphColour,groupName,finishCallback)=>{sceneLoader.loadLinesURL(rootRegion,url,timeEnabled,morphColour,groupName,finishCallback)},this.loadSTL=(url,groupName,finishCallback)=>{sceneLoader.loadSTL(rootRegion,url,groupName,finishCallback)},this.loadOBJ=(url,groupName,finishCallback)=>{sceneLoader.loadOBJ(rootRegion,url,groupName,finishCallback)},this.loadMetadataURL=(url,finishCallback,allCompletedCallback,options)=>{sceneLoader.loadMetadataURL(rootRegion,url,finishCallback,allCompletedCallback,options)},this.loadModelsURL=(urls,colours,opacities,timeEnabled,morphColour,finishCallback)=>{sceneLoader.loadModelsURL(rootRegion.urls,colours,opacities,timeEnabled,morphColour,finishCallback)},this.loadViewURL=url=>{sceneLoader.loadViewURL(url)},this.loadFromViewURL=(jsonFilePrefix,finishCallback)=>{sceneLoader.loadFromViewURL(jsonFilePrefix,finishCallback)},this.loadGLTF=(url,finishCallback,allCompletedCallback,options)=>{sceneLoader.loadGLTF(rootRegion,url,finishCallback,allCompletedCallback,options)},this.updateDirectionalLight=()=>{zincCameraControls.updateDirectionalLight()},this.addObject=object=>{scene.add(object)},this.removeObject=object=>{scene.remove(object)},this.getCurrentTime=()=>{if(videoHandler!=null)return videoHandler.getCurrentTime(duration);var time=rootRegion.getCurrentTime();return-1===time?0:time},this.setMorphsTime=time=>{videoHandler!=null&&videoHandler.setMorphTime(time,duration),rootRegion.setMorphTime(time,!0)},this.isTimeVarying=()=>!!(videoHandler&&videoHandler.video&&!videoHandler.video.error)||rootRegion.isTimeVarying(),this.renderGeometries=(playRate,delta,playAnimation)=>{// Let video dictates the progress if one is present
|
|
1101
1102
|
var options={};if(options.camera=zincCameraControls,options.displayMarkers=this.displayMarkers,options.markerCluster=markerCluster,options.markersList=markerCluster.markers,options.ndcToBeUpdated=!1,playAnimation&&(options.markerCluster.markerUpdateRequired=!0),!videoHandler)0==sceneLoader.toBeDownloaded?(options.ndcToBeUpdated=zincCameraControls.update(delta),options.ndcToBeUpdated&&zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight()),rootRegion.renderGeometries(playRate,delta,playAnimation,zincCameraControls,options,!0)):zincCameraControls.update(0);else if(videoHandler.isReadyToPlay()){playAnimation?videoHandler.video.play():videoHandler.video.pause();var currentTime=videoHandler.video.currentTime/videoHandler.getVideoDuration()*duration;0==sceneLoader.toBeDownloaded?(zincCameraControls.setTime(currentTime),options.ndcToBeUpdated=zincCameraControls.update(0),options.ndcToBeUpdated&&zincCameraControls.calculateHeightPerPixelAtZeroDepth(getDrawingHeight()),rootRegion.setMorphTime(currentTime,!0),rootRegion.renderGeometries(0,0,playAnimation,zincCameraControls,options,!0)):zincCameraControls.update(0)}else myPlayRate=0},this.getThreeJSScene=()=>scene,this.setVideoHandler=videoHandlerIn=>{videoHandler||(videoHandler=videoHandlerIn)},this.setAdditionalScenesGroup=scenesGroup=>{scene.add(scenesGroup)};var getWindowsPosition=(align,x_offset,y_offset,width,height,renderer_width,renderer_height)=>{var x=0,y=0;return y=align.includes("top")?renderer_height-height-y_offset:align.includes("bottom")?y_offset:Math.floor((renderer_height-height)/2),x=align.includes("left")?x_offset:align.includes("right")?renderer_width-x_offset-width:Math.floor((renderer_width-width)/2),{x:x,y:y}},renderMinimap=renderer=>{(this.displayMinimap||this.displayMiniAxes)&&(renderer.setScissorTest(!0),renderer.getSize(_markerTarget),this.minimapScissor.updateRequired&&(scissor=getWindowsPosition(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,_markerTarget.x,_markerTarget.y),this.minimapScissor.updateRequired=!1),renderer.setScissor(scissor.x,scissor.y,this.minimapScissor.width,this.minimapScissor.height),renderer.setViewport(scissor.x,scissor.y,this.minimapScissor.width,this.minimapScissor.height),minimap.updateCamera(),this.displayMiniAxes?renderer.render(miniAxesScene,minimap.camera):(scene.add(minimap.mask),renderer.render(scene,minimap.camera),scene.remove(minimap.mask)),renderer.setScissorTest(!1),renderer.setViewport(0,0,_markerTarget.x,_markerTarget.y))};/**
|
|
1102
1103
|
* Render the scene.
|
|
1103
1104
|
* @private
|
|
1104
|
-
*/this.render=renderer=>{this.autoClearFlag&&renderer.clear(),stereoEffectFlag&&stereoEffect?stereoEffect.render(scene,this.camera):(renderer.render(scene,this.camera),renderMinimap(renderer))},this.setInteractiveControlEnable=flag=>{!0==flag?zincCameraControls.enable():zincCameraControls.disable()},this.getZincCameraControls=()=>zincCameraControls,this.getThreeJSScene=()=>scene,this.setDuration=durationIn=>{rootRegion.setDuration(durationIn),duration=durationIn,zincCameraControls.setPathDuration(durationIn),sceneLoader.duration=durationIn},this.getDuration=()=>duration,this.setStereoEffectEnable=stereoFlag=>{!0!=stereoFlag||stereoEffect||(stereoEffect=new __webpack_require__(43).StereoEffect(rendererIn)),rendererIn.setSize(getDrawingWidth(),getDrawingHeight()),this.camera.updateProjectionMatrix(),stereoEffectFlag=stereoFlag},this.objectIsInScene=zincObject=>rootRegion.objectIsInRegion(zincObject,!0),this.alignBoundingBoxToCameraView=(boundingBox,transitionTime)=>{if(boundingBox){boundingBox.getCenter(_v3);var viewport=this.getZincCameraControls().getCurrentViewport(),target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(target,eyePosition).normalize(),newVec2.subVectors(target,
|
|
1105
|
+
*/this.render=renderer=>{this.autoClearFlag&&renderer.clear(),stereoEffectFlag&&stereoEffect?stereoEffect.render(scene,this.camera):(renderer.render(scene,this.camera),renderMinimap(renderer))},this.setInteractiveControlEnable=flag=>{!0==flag?zincCameraControls.enable():zincCameraControls.disable()},this.getZincCameraControls=()=>zincCameraControls,this.getThreeJSScene=()=>scene,this.setDuration=durationIn=>{rootRegion.setDuration(durationIn),duration=durationIn,zincCameraControls.setPathDuration(durationIn),sceneLoader.duration=durationIn},this.getDuration=()=>duration,this.setStereoEffectEnable=stereoFlag=>{!0!=stereoFlag||stereoEffect||(stereoEffect=new __webpack_require__(43).StereoEffect(rendererIn)),rendererIn.setSize(getDrawingWidth(),getDrawingHeight()),this.camera.updateProjectionMatrix(),stereoEffectFlag=stereoFlag},this.objectIsInScene=zincObject=>rootRegion.objectIsInRegion(zincObject,!0),this.alignBoundingBoxToCameraView=(boundingBox,transitionTime)=>{if(boundingBox){boundingBox.getCenter(_v3);var viewport=this.getZincCameraControls().getCurrentViewport(),target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(target,eyePosition).normalize(),newVec2.subVectors(target,_v3).normalize();var newVec3=new THREE.Vector3;newVec3.crossVectors(newVec1,newVec2);var angle=newVec1.angleTo(newVec2);0<transitionTime?(this.getZincCameraControls().rotateCameraTransition(newVec3,angle,transitionTime),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(newVec3,angle),markerCluster.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(boundingBox,scaleRadius,transitionTime)=>{if(boundingBox){var oldViewport=this.getZincCameraControls().getCurrentViewport(),viewport=this.getZincCameraControls().getViewportFromBoundingBox(boundingBox,scaleRadius);0<transitionTime&&(this.getZincCameraControls().cameraTransition(oldViewport,viewport,transitionTime),this.getZincCameraControls().enableCameraTransition()),markerCluster.markerUpdateRequired=!0}},this.alignObjectToCameraView=(zincObject,transitionTime)=>{if(this.objectIsInScene(zincObject)){var boundingBox=zincObject.getBoundingBox();this.alignBoundingBoxToCameraView(boundingBox,transitionTime)}},this.setCameraTargetToObject=zincObject=>{if(this.objectIsInScene(zincObject)){var boundingBox=zincObject.getBoundingBox(),viewport=this.getZincCameraControls().getCurrentViewport();boundingBox.getCenter(_v3);var target=new THREE.Vector3(viewport.targetPosition[0],viewport.targetPosition[1],viewport.targetPosition[2]),eyePosition=new THREE.Vector3(viewport.eyePosition[0],viewport.eyePosition[1],viewport.eyePosition[2]),newVec1=new THREE.Vector3,newVec2=new THREE.Vector3;newVec1.subVectors(eyePosition,target),newVec2.addVectors(_v3,newVec1),viewport.eyePosition[0]=newVec2.x,viewport.eyePosition[1]=newVec2.y,viewport.eyePosition[2]=newVec2.z,viewport.targetPosition[0]=_v3.x,viewport.targetPosition[1]=_v3.y,viewport.targetPosition[2]=_v3.z,this.getZincCameraControls().setCurrentCameraSettings(viewport),markerCluster.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>stereoEffectFlag,this.removeZincObject=zincObject=>{rootRegion.removeZincObject(zincObject),zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this),markerCluster.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{pickableObjectsList.length=0,markerCluster.isEnabled&&pickableObjectsList.push(markerCluster.group),rootRegion.getPickableThreeJSObjects(pickableObjectsList,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||rootRegion.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),pickableObjectsList),this.getNormalisedMinimapCoordinates=(renderer,event)=>{if(this.displayMinimap){var target=new THREE.Vector2;renderer.getSize(target);var offsetY=target.y-event.clientY;if(scissor.x+this.minimapScissor.width>event.clientX&&event.clientX>scissor.x&&scissor.y+this.minimapScissor.height>offsetY&&offsetY>scissor.y){var x=2*((event.clientX-scissor.x)/this.minimapScissor.width)-1,y=2*((offsetY-scissor.y)/this.minimapScissor.height)-1;return{x:x,y:y}}}},this.getMinimapDiffFromNormalised=(x,y)=>minimap?minimap.getDiffFromNormalised(x,y):void 0,this.isWebGL2=()=>rendererIn.isWebGL2(),this.clearAll=()=>{markerCluster.clear(),rootRegion.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),sceneLoader.toBeDwonloaded=0,zincCameraControls&&zincCameraControls.calculateMaxAllowedDistance(this),markerCluster.markerUpdateRequired=!0},this.addMetadataTimeStamp=(key,time)=>{metadata.TimeStamps[key]=convertDurationObjectTomSec(time)},this.getMetadataTag=key=>metadata[key],this.getMetadata=()=>metadata,this.setMetadataTag=(key,value)=>{metadata[key]=value},this.removeMetadataTag=key=>{delete metadata[key]},this.resetMetadata=()=>{metadata=defaultMetadata()},this.resetDuration=()=>{this.setDuration(defaultDuration)};// Turn the object into a readable string {years: years,months: months,
|
|
1105
1106
|
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
1106
1107
|
var convertDurationObjectToString=duration=>[...(duration.years?["".concat(duration.years,"years")]:[]),...(duration.months?["".concat(duration.months,"months")]:[]),...(duration.weeks?["".concat(duration.weeks,"weeks")]:[]),...(duration.days?["".concat(duration.days,"days")]:[]),...(duration.hours?["".concat(duration.hours,"hours")]:[]),...(duration.mins?["".concat(duration.mins,"mins")]:[]),...(duration.secs?["".concat(duration.secs,"secs")]:[])].join(" "),convertDurationObjectTomSec=duration=>duration.years?31536e6*duration.years:0+duration.months?2592e6*duration.months:0+duration.weeks?6048e5*duration.weeks:0+duration.days?864e5*duration.days:0+duration.hours?36e5*duration.hours:0+duration.mins?6e4*duration.mins:0+duration.secs?1e3*duration.secs:0;// Turn the object into a number representing milliesecond {years: years,months: months,
|
|
1107
1108
|
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
@@ -1240,11 +1241,11 @@ var THREE=__webpack_require__(4),resolveURL=(__webpack_require__(5).resolveURL),
|
|
|
1240
1241
|
* [totalsize, totalLoaded and errorDownload] of all the downloads happening
|
|
1241
1242
|
* in this scene.
|
|
1242
1243
|
* @returns {Array}
|
|
1243
|
-
*/this.getDownloadProgress=()=>{var totalSize=0,totalLoaded=0,unknownFound=!1;for(var key in this.progressMap){var progress=this.progressMap[key];totalSize+=progress[1],totalLoaded+=progress[0],0==progress[1]&&(unknownFound=!0)}return unknownFound&&(totalSize=0),[totalSize,totalLoaded,errorDownload]},this.onProgress=id=>xhr=>{this.progressMap[id]=[xhr.loaded,xhr.total]},this.onError=finishCallback=>xhr=>{--this.toBeDownloaded,errorDownload=!0,console.error("There is an issue with external resource
|
|
1244
|
+
*/this.getDownloadProgress=()=>{var totalSize=0,totalLoaded=0,unknownFound=!1;for(var key in this.progressMap){var progress=this.progressMap[key];totalSize+=progress[1],totalLoaded+=progress[0],0==progress[1]&&(unknownFound=!0)}return unknownFound&&(totalSize=0),[totalSize,totalLoaded,errorDownload]},this.onProgress=id=>xhr=>{this.progressMap[id]=[xhr.loaded,xhr.total]},this.onError=finishCallback=>xhr=>{--this.toBeDownloaded,errorDownload=!0,console.error("There is an issue with external resource ".concat(null!==xhr&&void 0!==xhr&&xhr.responseURL?": "+(null===xhr||void 0===xhr?void 0:xhr.responseURL):"","."));finishCallback&&finishCallback({type:"Error",xhr})};var loadMultipleViews=(referenceURL,views)=>{var defaultView=views.Default;if(views.Inline)scene.setupMultipleViews(defaultView,views.Entries);else{var promises=[],_loop=function _loop(key){referenceURL&&(newURL=createNewURL(value,referenceURL),promises.push(new Promise((resolve,reject)=>{// Add parameters if we are sent them
|
|
1244
1245
|
fetch(newURL).then(response=>response.json()).then(data=>resolve({key:key,data:data})).catch(data=>reject(data))})))};for(var[key,value]of Object.entries(views.Entries))_loop(key);Promise.all(promises).then(values=>{var entries={};values.forEach(entry=>{entries[entry.key]=entry.data}),scene.setupMultipleViews(defaultView,entries);var zincCameraControls=scene.getZincCameraControls();zincCameraControls&&zincCameraControls.setCurrentViewport(defaultView),viewLoaded=!0})}};/**
|
|
1245
1246
|
* Load the viewport from an external location provided by the url.
|
|
1246
1247
|
* @param {String} URL - address to the file containing viewport information.
|
|
1247
|
-
*/this.loadViewURL=(url,finishCallback)=>{this.toBeDownloaded+=1;var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState)if(200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.setupMultipleViews("default",{default:viewData}),scene.resetView(),viewLoaded=!0,--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback()}else this.onError()};var requestURL=resolveURL(url);xmlhttp.open("GET",requestURL,!0),xmlhttp.send()},this.loadModelsURL=(region,urls,colours,opacities,timeEnabled,morphColour,finishCallback)=>{var number=urls.length;this.toBeDownloaded+=number;for(var i=0;i<number;i++){var filename=urls[i],colour=(__webpack_require__(0).defaultMaterialColor),opacity=(__webpack_require__(0).defaultOpacity);colours!=null&&colours[i]!=null&&(colour=!!colours[i]),opacities!=null&&opacities[i]!=null&&(opacity=opacities[i]);var localTimeEnabled=0;timeEnabled!=null&&timeEnabled[i]!=null&&(localTimeEnabled=!!timeEnabled[i]);var localMorphColour=0;morphColour!=null&&morphColour[i]!=null&&(localMorphColour=!!morphColour[i]),primitivesLoader.load(resolveURL(filename),meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))}},this.loadFromViewURL=(targetRegion,jsonFilePrefix,finishCallback)=>{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.loadView(viewData);for(var filename,urls=[],filename_prefix=jsonFilePrefix+"_",i=0;i<viewData.numberOfResources;i++)filename=filename_prefix+(i+1)+".json",urls.push(filename);this.loadModelsURL(targetRegion,urls,viewData.colour,viewData.opacity,viewData.timeEnabled,viewData.morphColour,finishCallback)}};var requestURL=resolveURL(jsonFilePrefix+"_view.json");xmlhttp.open("GET",requestURL,!0),xmlhttp.send()};//Internal loader for a regular zinc geometry.
|
|
1248
|
+
*/this.loadViewURL=(url,finishCallback)=>{this.toBeDownloaded+=1;var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState)if(200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.setupMultipleViews("default",{default:viewData}),scene.resetView(),viewLoaded=!0,--this.toBeDownloaded,null!=finishCallback&&"function"==typeof finishCallback&&finishCallback()}else this.onError(finishCallback)({responseURL:url})};var requestURL=resolveURL(url);xmlhttp.open("GET",requestURL,!0),xmlhttp.send()},this.loadModelsURL=(region,urls,colours,opacities,timeEnabled,morphColour,finishCallback)=>{var number=urls.length;this.toBeDownloaded+=number;for(var i=0;i<number;i++){var filename=urls[i],colour=(__webpack_require__(0).defaultMaterialColor),opacity=(__webpack_require__(0).defaultOpacity);colours!=null&&colours[i]!=null&&(colour=!!colours[i]),opacities!=null&&opacities[i]!=null&&(opacity=opacities[i]);var localTimeEnabled=0;timeEnabled!=null&&timeEnabled[i]!=null&&(localTimeEnabled=!!timeEnabled[i]);var localMorphColour=0;morphColour!=null&&morphColour[i]!=null&&(localMorphColour=!!morphColour[i]),primitivesLoader.load(resolveURL(filename),meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))}},this.loadFromViewURL=(targetRegion,jsonFilePrefix,finishCallback)=>{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var viewData=JSON.parse(xmlhttp.responseText);scene.loadView(viewData);for(var filename,urls=[],filename_prefix=jsonFilePrefix+"_",i=0;i<viewData.numberOfResources;i++)filename=filename_prefix+(i+1)+".json",urls.push(filename);this.loadModelsURL(targetRegion,urls,viewData.colour,viewData.opacity,viewData.timeEnabled,viewData.morphColour,finishCallback)}};var requestURL=resolveURL(jsonFilePrefix+"_view.json");xmlhttp.open("GET",requestURL,!0),xmlhttp.send()};//Internal loader for a regular zinc geometry.
|
|
1248
1249
|
var linesloader=(region,localTimeEnabled,localMorphColour,groupName,anatomicalId,renderOrder,lod,finishCallback)=>(geometry,materials)=>{var newLines=new((__webpack_require__(24).Lines)),material=void 0;materials&&materials[0]&&(material=new THREE.LineBasicMaterial({color:materials[0].color.clone()}),1>materials[0].opacity&&(material.transparent=!0),material.opacity=materials[0].opacity,material.morphTargets=localTimeEnabled,material.vertexColors=materials[0].vertexColors);var options={localTimeEnabled:localTimeEnabled,localMorphColour:localMorphColour};if(newLines&&(newLines.createLineSegment(geometry,material,options),newLines.setName(groupName),newLines.anatomicalId=anatomicalId,newLines.setRenderOrder(renderOrder),region.addZincObject(newLines),newLines.setDuration(scene.getDuration()),lod&&lod.levels))for(var[key,value]of Object.entries(lod.levels))newLines.addLOD(primitivesLoader,key,value.URL,value.Index,lod.preload);--this.toBeDownloaded,geometry.dispose(),null!=finishCallback&&"function"==typeof finishCallback&&finishCallback(newLines)};/**
|
|
1249
1250
|
* Load lines into this scene object.
|
|
1250
1251
|
*
|