zincjs 1.7.0 → 1.8.1
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 +34 -14
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/controls.js +22 -1
- package/src/primitives/pointset.js +13 -0
- package/src/region.js +4 -0
- package/src/scene.js +54 -1
- package/src/sceneLoader.js +1 -0
- package/src/three/Points.js +2 -1
- package/src/zinc.js +1 -0
package/build/zinc.js
CHANGED
|
@@ -13,7 +13,7 @@ return /******/ (() => { // webpackBootstrap
|
|
|
13
13
|
/* 0 */
|
|
14
14
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
15
15
|
|
|
16
|
-
__webpack_require__(1);var PACKAGE=__webpack_require__(2),version=PACKAGE.version,Zinc=function(){this.Revision=version,this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.modelPrefix=void 0,this.Geometry=(__webpack_require__(3).Geometry),this.Glyph=(__webpack_require__(16).Glyph),this.Glyphset=(__webpack_require__(18).Glyphset),this.Pointset=(__webpack_require__(22).Pointset),this.Lines=(__webpack_require__(24).Lines),this.TextureArray=(__webpack_require__(25).TextureArray),this.TextureSlides=(__webpack_require__(27).TextureSlides),this.Renderer=(__webpack_require__(30).Renderer),this.Scene=(__webpack_require__(32).Scene),this.GeometryCSG=(__webpack_require__(50).GeometryCSG),this.GlyphsetCSG=(__webpack_require__(56).GlyphsetCSG),this.Viewport=(__webpack_require__(43).Viewport),this.CameraControls=(__webpack_require__(43).CameraControls),this.SmoothCameraTransition=(__webpack_require__(43).SmoothCameraTransition),this.RayCaster=(__webpack_require__(43).RayCaster),this.CameraAutoTumble=(__webpack_require__(43).CameraAutoTumble),this.StereoEffect=(__webpack_require__(43).StereoEffect),this.loadExternalFile=(__webpack_require__(5).loadExternalFile),this.loadExternalFiles=(__webpack_require__(5).loadExternalFiles),this.THREE=__webpack_require__(4)};/**
|
|
16
|
+
__webpack_require__(1);var PACKAGE=__webpack_require__(2),version=PACKAGE.version,Zinc=function(){this.Revision=version,this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.modelPrefix=void 0,this.Geometry=(__webpack_require__(3).Geometry),this.Glyph=(__webpack_require__(16).Glyph),this.Glyphset=(__webpack_require__(18).Glyphset),this.Pointset=(__webpack_require__(22).Pointset),this.Label=(__webpack_require__(17).Label),this.Lines=(__webpack_require__(24).Lines),this.TextureArray=(__webpack_require__(25).TextureArray),this.TextureSlides=(__webpack_require__(27).TextureSlides),this.Renderer=(__webpack_require__(30).Renderer),this.Scene=(__webpack_require__(32).Scene),this.GeometryCSG=(__webpack_require__(50).GeometryCSG),this.GlyphsetCSG=(__webpack_require__(56).GlyphsetCSG),this.Viewport=(__webpack_require__(43).Viewport),this.CameraControls=(__webpack_require__(43).CameraControls),this.SmoothCameraTransition=(__webpack_require__(43).SmoothCameraTransition),this.RayCaster=(__webpack_require__(43).RayCaster),this.CameraAutoTumble=(__webpack_require__(43).CameraAutoTumble),this.StereoEffect=(__webpack_require__(43).StereoEffect),this.loadExternalFile=(__webpack_require__(5).loadExternalFile),this.loadExternalFiles=(__webpack_require__(5).loadExternalFiles),this.THREE=__webpack_require__(4)};/**
|
|
17
17
|
* Provides a global namespace for the Zinc javascript library and some default parameters for it.
|
|
18
18
|
*
|
|
19
19
|
* @namespace
|
|
@@ -32,7 +32,7 @@ module.exports = require("url-polyfill");
|
|
|
32
32
|
/***/ ((module) => {
|
|
33
33
|
|
|
34
34
|
"use strict";
|
|
35
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.
|
|
35
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.8.1","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 */
|
|
@@ -778,7 +778,12 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
778
778
|
*
|
|
779
779
|
* @param {Boolean} flag - Determin either size attenuation
|
|
780
780
|
* should be on or off.
|
|
781
|
-
*/
|
|
781
|
+
*/ /**
|
|
782
|
+
* Turn size attenuation on/off based on the flag.
|
|
783
|
+
*
|
|
784
|
+
* @param {Boolean} flag - Determin either size attenuation
|
|
785
|
+
* should be on or off.
|
|
786
|
+
*/(__webpack_require__(10).ZincObject).call(this),this.isPointset=!0,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)}},this.addPoints=(coords,labels,colour)=>{if(coords&&0<coords.length){var geometry=this.addVertices(coords),mesh=this.getMorph();if(!mesh){var material=new THREE.PointsMaterial({alphaTest:.5,size:10,color:colour,sizeAttenuation:!1});geometry.colorsNeedUpdate=!0,this.createMesh(geometry,material,{localTimeEnabled:!1,localMorphColour:!1})}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.render=(delta,playAnimation,cameraControls,options)=>{this.morph&&(this.morph.sizePerPixel=cameraControls.pixelHeight),Pointset.prototype.render.call(this,delta,playAnimation,cameraControls,options)}};/**
|
|
782
787
|
* Provides an object which stores points and provides method which controls its position.
|
|
783
788
|
* This is created when a valid json file containing point is read into a {@link Zinc.Scene}
|
|
784
789
|
* object.
|
|
@@ -799,8 +804,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
799
804
|
/* harmony export */ });
|
|
800
805
|
/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
|
|
801
806
|
/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(three__WEBPACK_IMPORTED_MODULE_0__);
|
|
802
|
-
var _inverseMatrix=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Matrix4,_ray=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Ray,_sphere=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Sphere,_position=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Vector3,_morphA=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Vector3,_tempA=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Vector3;class Points extends three__WEBPACK_IMPORTED_MODULE_0__.Object3D{constructor(){var geometry=0<arguments.length&&arguments[0]!==void 0?arguments[0]:new three__WEBPACK_IMPORTED_MODULE_0__.BufferGeometry,material=1<arguments.length&&arguments[1]!==void 0?arguments[1]:new three__WEBPACK_IMPORTED_MODULE_0__.PointsMaterial;super(),this.type="Points",this.geometry=geometry,this.material=material,this.updateMorphTargets()}copy(source){return super.copy(source),this.material=source.material,this.geometry=source.geometry,this}raycast(raycaster,intersects){var geometry=this.geometry,matrixWorld=this.matrixWorld,threshold=raycaster.params.Points.threshold,drawRange=geometry.drawRange;// Checking boundingSphere distance to ray
|
|
803
|
-
if(null===geometry.boundingSphere&&geometry.computeBoundingSphere(),_sphere.copy(geometry.boundingSphere),_sphere.applyMatrix4(matrixWorld),_sphere.radius+=threshold,!1!==raycaster.ray.intersectsSphere(_sphere)){_inverseMatrix.copy(matrixWorld).invert(),_ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix);var localThreshold=threshold/((this.scale.x+this.scale.y+this.scale.z)/3),localThresholdSq=localThreshold*localThreshold;if(geometry.isBufferGeometry){var index=geometry.index,attributes=geometry.attributes,positionAttribute=attributes.position,morphPosition=geometry.morphAttributes.position;if(null!==index)for(var a,start=Math.max(0,drawRange.start),end=Math.min(index.count,drawRange.start+drawRange.count),i=start;i<end;i++)a=index.getX(i),calculatePosition(this,positionAttribute,morphPosition,a),testPoint(_position,a,localThresholdSq,matrixWorld,raycaster,intersects,this);else for(var _start=Math.max(0,drawRange.start),_end=Math.min(positionAttribute.count,drawRange.start+drawRange.count),_i=_start;_i<_end;_i++)calculatePosition(this,positionAttribute,morphPosition,_i),testPoint(_position,_i,localThresholdSq,matrixWorld,raycaster,intersects,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}//
|
|
807
|
+
var _inverseMatrix=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Matrix4,_ray=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Ray,_sphere=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Sphere,_position=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Vector3,_morphA=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Vector3,_tempA=/*@__PURE__*/new three__WEBPACK_IMPORTED_MODULE_0__.Vector3;class Points extends three__WEBPACK_IMPORTED_MODULE_0__.Object3D{constructor(){var geometry=0<arguments.length&&arguments[0]!==void 0?arguments[0]:new three__WEBPACK_IMPORTED_MODULE_0__.BufferGeometry,material=1<arguments.length&&arguments[1]!==void 0?arguments[1]:new three__WEBPACK_IMPORTED_MODULE_0__.PointsMaterial;super(),this.type="Points",this.geometry=geometry,this.material=material,this.sizePerPixel=1,this.updateMorphTargets()}copy(source){return super.copy(source),this.material=source.material,this.geometry=source.geometry,this}raycast(raycaster,intersects){var geometry=this.geometry,matrixWorld=this.matrixWorld,threshold=raycaster.params.Points.threshold,drawRange=geometry.drawRange;// Checking boundingSphere distance to ray
|
|
808
|
+
if(null===geometry.boundingSphere&&geometry.computeBoundingSphere(),_sphere.copy(geometry.boundingSphere),_sphere.applyMatrix4(matrixWorld),_sphere.radius+=threshold,!1!==raycaster.ray.intersectsSphere(_sphere)){_inverseMatrix.copy(matrixWorld).invert(),_ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix);var localThreshold=threshold/((this.scale.x+this.scale.y+this.scale.z)/3)*this.material.size*this.sizePerPixel,localThresholdSq=localThreshold*localThreshold;if(geometry.isBufferGeometry){var index=geometry.index,attributes=geometry.attributes,positionAttribute=attributes.position,morphPosition=geometry.morphAttributes.position;if(null!==index)for(var a,start=Math.max(0,drawRange.start),end=Math.min(index.count,drawRange.start+drawRange.count),i=start;i<end;i++)a=index.getX(i),calculatePosition(this,positionAttribute,morphPosition,a),testPoint(_position,a,localThresholdSq,matrixWorld,raycaster,intersects,this);else for(var _start=Math.max(0,drawRange.start),_end=Math.min(positionAttribute.count,drawRange.start+drawRange.count),_i=_start;_i<_end;_i++)calculatePosition(this,positionAttribute,morphPosition,_i),testPoint(_position,_i,localThresholdSq,matrixWorld,raycaster,intersects,this)}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}//
|
|
804
809
|
}updateMorphTargets(){var geometry=this.geometry;if(geometry.isBufferGeometry){var morphAttributes=geometry.morphAttributes,keys=Object.keys(morphAttributes);if(0<keys.length){var morphAttribute=morphAttributes[keys[0]];if(morphAttribute!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var name,m=0,ml=morphAttribute.length;m<ml;m++)name=morphAttribute[m].name||m+"",this.morphTargetInfluences.push(0),this.morphTargetDictionary[name]=m}}}else{var morphTargets=geometry.morphTargets;morphTargets!==void 0&&0<morphTargets.length&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Points.prototype.isPoints=!0;function testPoint(point,index,localThresholdSq,matrixWorld,raycaster,intersects,object){var rayPointDistanceSq=_ray.distanceSqToPoint(point);if(rayPointDistanceSq<localThresholdSq){var intersectPoint=new three__WEBPACK_IMPORTED_MODULE_0__.Vector3;_ray.closestPointToPoint(point,intersectPoint),intersectPoint.applyMatrix4(matrixWorld);var distance=raycaster.ray.origin.distanceTo(intersectPoint);if(distance<raycaster.near||distance>raycaster.far)return;intersects.push({distance:distance,distanceToRay:Math.sqrt(rayPointDistanceSq),point:intersectPoint,index:index,face:null,object:object})}}function calculatePosition(object,position,morphPosition,a){_position.fromBufferAttribute(position,a);var morphInfluences=object.morphTargetInfluences;if(object.material.morphTargets&&morphPosition&&morphInfluences){_morphA.set(0,0,0);for(var i=0,il=morphPosition.length;i<il;i++){var influence=morphInfluences[i],morphAttribute=morphPosition[i];0!==influence&&(_tempA.fromBufferAttribute(morphAttribute,a),_morphA.addScaledVector(_tempA.sub(_position),influence))}_position.add(_morphA)}}
|
|
805
810
|
|
|
806
811
|
/***/ }),
|
|
@@ -1072,17 +1077,17 @@ var THREE=__webpack_require__(4),MarkerCluster=(__webpack_require__(33).MarkerCl
|
|
|
1072
1077
|
* @param {Object} containerIn - Container to create the renderer on.
|
|
1073
1078
|
* @author Alan Wu
|
|
1074
1079
|
* @return {Scene}
|
|
1075
|
-
*/exports.Scene=function(containerIn,rendererIn){var _this=this,container=containerIn,videoHandler=void 0,sceneLoader=new SceneLoader(this),minimap=void 0,zincObjectAddedCallbacks={},zincObjectAddedCallbacks_id=0,scene=new THREE.Scene,rootRegion=new((__webpack_require__(44).Region))(void 0,this);scene.add(rootRegion.getGroup());var tempGroup=new THREE.Group;scene.add(tempGroup),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;var duration=6e3,zincCameraControls=void 0;this.sceneName=void 0;var stereoEffectFlag=!1,stereoEffect=void 0;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:"top-left",updateRequired:!0};var scissor={x:0,y:0},metadata=defaultMetadata(),_markerTarget=new THREE.Vector2,pickableObjectsList=[];this.forcePickableObjectsUpdate=!1,this.uuid=getUniqueId();var markerCluster=new MarkerCluster(this);markerCluster.disable(),scene.add(markerCluster.group);var getDrawingWidth=()=>container?"undefined"==typeof container.clientWidth?container.width:container.clientWidth:0,getDrawingHeight=()=>container?"undefined"==typeof container.clientHeight?container.height:container.clientHeight:0;/**
|
|
1080
|
+
*/exports.Scene=function(containerIn,rendererIn){var _this=this,container=containerIn,videoHandler=void 0,sceneLoader=new SceneLoader(this),minimap=void 0,zincObjectAddedCallbacks={},zincObjectAddedCallbacks_id=0,zincObjectRemovedCallbacks={},zincObjectRemovedCallbacks_id=0,scene=new THREE.Scene,rootRegion=new((__webpack_require__(44).Region))(void 0,this);scene.add(rootRegion.getGroup());var tempGroup=new THREE.Group;scene.add(tempGroup),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;var duration=6e3,zincCameraControls=void 0;this.sceneName=void 0;var stereoEffectFlag=!1,stereoEffect=void 0;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:"top-left",updateRequired:!0};var scissor={x:0,y:0},metadata=defaultMetadata(),_markerTarget=new THREE.Vector2,pickableObjectsList=[];this.forcePickableObjectsUpdate=!1,this.uuid=getUniqueId();var markerCluster=new MarkerCluster(this);markerCluster.disable(),scene.add(markerCluster.group);var getDrawingWidth=()=>container?"undefined"==typeof container.clientWidth?container.width:container.clientWidth:0,getDrawingHeight=()=>container?"undefined"==typeof container.clientHeight?container.height:container.clientHeight:0;/**
|
|
1076
1081
|
* This function returns a three component array, which contains
|
|
1077
1082
|
* [totalsize, totalLoaded and errorDownload] of all the downloads happening
|
|
1078
1083
|
* in this scene.
|
|
1079
1084
|
* @returns {Array}
|
|
1080
|
-
*/this.getDownloadProgress=()=>sceneLoader.getDownloadProgress(),this.onWindowResize=()=>{this.camera.aspect=getDrawingWidth()/
|
|
1081
|
-
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),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)=>{sceneLoader.loadMetadataURL(rootRegion,url,finishCallback,allCompletedCallback)},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
|
|
1082
|
-
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),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),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=>{!0===this.displayMinimap&&(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(),scene.add(minimap.mask),renderer.render(scene,minimap.camera),scene.remove(minimap.mask),renderer.setScissorTest(!1),renderer.setViewport(0,0,_markerTarget.x,_markerTarget.y))};/**
|
|
1085
|
+
*/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
|
|
1086
|
+
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)=>{sceneLoader.loadMetadataURL(rootRegion,url,finishCallback,allCompletedCallback)},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
|
|
1087
|
+
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=>{!0===this.displayMinimap&&(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(),scene.add(minimap.mask),renderer.render(scene,minimap.camera),scene.remove(minimap.mask),renderer.setScissorTest(!1),renderer.setViewport(0,0,_markerTarget.x,_markerTarget.y))};/**
|
|
1083
1088
|
* Render the scene.
|
|
1084
1089
|
* @private
|
|
1085
|
-
*/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){var center=new THREE.Vector3;boundingBox.getCenter(center);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,center).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 center=new THREE.Vector3,boundingBox=zincObject.getBoundingBox(),viewport=this.getZincCameraControls().getCurrentViewport();boundingBox.getCenter(center);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(center,newVec1),viewport.eyePosition[0]=newVec2.x,viewport.eyePosition[1]=newVec2.y,viewport.eyePosition[2]=newVec2.z,viewport.targetPosition[0]=center.x,viewport.targetPosition[1]=center.y,viewport.targetPosition[2]=center.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(),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,
|
|
1090
|
+
*/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){var center=new THREE.Vector3;boundingBox.getCenter(center);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,center).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 center=new THREE.Vector3,boundingBox=zincObject.getBoundingBox(),viewport=this.getZincCameraControls().getCurrentViewport();boundingBox.getCenter(center);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(center,newVec1),viewport.eyePosition[0]=newVec2.x,viewport.eyePosition[1]=newVec2.y,viewport.eyePosition[2]=newVec2.z,viewport.targetPosition[0]=center.x,viewport.targetPosition[1]=center.y,viewport.targetPosition[2]=center.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,
|
|
1086
1091
|
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
1087
1092
|
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,
|
|
1088
1093
|
// weeks: weeks, days: days, hours: hours, mins: mins, secs: secs }
|
|
@@ -1116,12 +1121,24 @@ var convertDurationObjectToString=duration=>[...(duration.years?["".concat(durat
|
|
|
1116
1121
|
*
|
|
1117
1122
|
* @return {Number}
|
|
1118
1123
|
*/ /**
|
|
1124
|
+
* Add a callback function which will be called everytime zinc object is removed.
|
|
1125
|
+
* @param {Function} callbackFunction - callbackFunction to be added.
|
|
1126
|
+
*
|
|
1127
|
+
* @return {Number}
|
|
1128
|
+
*/ /**
|
|
1129
|
+
* Remove a callback function that is previously added to the scene.
|
|
1130
|
+
* @param {Number} id - identifier of the previously added callback function.
|
|
1131
|
+
*/ /**
|
|
1119
1132
|
* Remove a callback function that is previously added to the scene.
|
|
1120
1133
|
* @param {Number} id - identifier of the previously added callback function.
|
|
1121
1134
|
*/ /**
|
|
1122
1135
|
* Clear all zinc object callback function
|
|
1123
1136
|
*/ /**
|
|
1137
|
+
* Clear all zinc object callback function
|
|
1138
|
+
*/ /**
|
|
1124
1139
|
* Used to trigger zinc object added callback
|
|
1140
|
+
*/ /**
|
|
1141
|
+
* Used to trigger zinc object removed callback
|
|
1125
1142
|
*/ /*
|
|
1126
1143
|
* Add temporary points to the scene which can be removed
|
|
1127
1144
|
* with clearTemporaryPrimitives method.
|
|
@@ -1137,7 +1154,7 @@ var convertDurationObjectToString=duration=>[...(duration.years?["".concat(durat
|
|
|
1137
1154
|
* add to specify region and group name.
|
|
1138
1155
|
*/ /*
|
|
1139
1156
|
* Enable marker cluster to work with markers
|
|
1140
|
-
*/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.removeZincObjectAddedCallbacks=id=>{id in zincObjectAddedCallbacks_id&&delete zincObjectAddedCallbacks[id]},this.clearZincObjectAddedCallbacks=()=>{zincObjectAddedCallbacks={},zincObjectAddedCallbacks_id=0},this.triggerObjectAddedCallback=zincObject=>{for(var key in zincObjectAddedCallbacks)zincObjectAddedCallbacks.hasOwnProperty(key)&&zincObjectAddedCallbacks[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);dim.addVectors(box.min,box.max).multiplyScalar(.5);var primitive=region.createGeometryFromThreeJSGeometry(group,boxGeo,colour,opacity,visibility,1e4);return primitive.setPosition(dim.x,dim.y,dim.z),primitive},this.enableMarkerCluster=flag=>{flag?(markerCluster.markerUpdateRequired=!0,markerCluster.enable()):(markerCluster.markerUpdateRequired=!1,markerCluster.disable()),this.forcePickableObjectsUpdate=!0}};
|
|
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);dim.addVectors(box.min,box.max).multiplyScalar(.5);var primitive=region.createGeometryFromThreeJSGeometry(group,boxGeo,colour,opacity,visibility,1e4);return primitive.setPosition(dim.x,dim.y,dim.z),primitive},this.enableMarkerCluster=flag=>{flag?(markerCluster.markerUpdateRequired=!0,markerCluster.enable()):(markerCluster.markerUpdateRequired=!1,markerCluster.disable()),this.forcePickableObjectsUpdate=!0}};
|
|
1141
1158
|
|
|
1142
1159
|
/***/ }),
|
|
1143
1160
|
/* 33 */
|
|
@@ -1711,7 +1728,10 @@ var THREE=__webpack_require__(4),resolveURL=(__webpack_require__(5).resolveURL),
|
|
|
1711
1728
|
*/ /**
|
|
1712
1729
|
* Available click actions are MAIN, AUXILIARY and SECONARY.
|
|
1713
1730
|
* @property {Object}
|
|
1714
|
-
*/CLICK_ACTION.MAIN=STATE.ROTATE,CLICK_ACTION.AUXILIARY=STATE.ZOOM,CLICK_ACTION.SECONDARY=STATE.PAN,this.cameraObject=object,this.domElement=domElement===void 0?document:domElement,this.renderer=renderer,this.scene=scene,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.scrollRate=50;var duration=6e3,enabled=!0,inbuildTime=0,cameraPath=void 0,numberOfCameraPoint=void 0,updateLightWithPathFlag=!1,playRate=500,deviceOrientationControl=void 0,defaultViewport="default",currentMode=MODE.DEFAULT,smoothCameraTransitionObject=void 0,rotateCameraTransitionObject=void 0,cameraAutoTumbleObject=void 0,mouseScroll=0,rotateMode=ROTATE_DIRECTION.FREE;this._state=STATE.NONE;var zincRayCaster;this.targetTouchId=-1;var rect=void 0,_a=new THREE.Vector3,_b=new THREE.Vector3,_c=new THREE.Vector3,_new_b=new THREE.Vector3,_new_c=new THREE.Vector3,_axis=new THREE.Vector3,_v=new THREE.Vector3,_rel_eye=new THREE.Vector3,sceneSphere=new THREE.Sphere,_tempEye=new THREE.Vector3,ndcControl=void 0,maxDist=0,viewports={default:new Viewport};viewports.default.nearPlane=.1,viewports.default.farPlane=2e3,viewports.default.eyePosition=[0,0,0],viewports.default.targetPosition=[0,0,-1],viewports.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new THREE.Vector3(...viewports.default.targetPosition)),this.calculateMaxAllowedDistance=scene=>{var box=scene.getBoundingBox();if(box){box.getBoundingSphere(sceneSphere),maxDist=6*sceneSphere.radius;var currentDist=0;this.cameraObject&&(currentDist=this.cameraObject.position.distanceTo(sceneSphere.center)),maxDist=currentDist>maxDist?currentDist:maxDist}else maxDist=0},this.addViewport=(viewportName,viewport)=>{viewportName&&viewport&&(viewports[viewportName]=viewport)},this.setDefaultViewport=defaultName=>!!(defaultName&&defaultName in viewports)&&(defaultViewport=defaultName,!0),this.getDefaultViewport=()=>defaultViewport,this.getViewportOfName=name=>viewports[name],this.setCurrentViewport=name=>!!(name in viewports)&&(this.setCurrentCameraSettings(viewports[name]),!0),this.setRotationMode=mode=>{switch(mode){case"none":rotateMode=ROTATE_DIRECTION.NONE;break;case"horizontal":rotateMode=ROTATE_DIRECTION.HORIZONTAL;break;case"vertical":rotateMode=ROTATE_DIRECTION.VERTICAL;break;case"free":default:rotateMode=ROTATE_DIRECTION.FREE}},this.onResize=()=>{rect&&(rect=void 0),ndcControl&&ndcControl.setCurrentCameraSettings(this.cameraObject,viewports[defaultViewport])},this.
|
|
1731
|
+
*/CLICK_ACTION.MAIN=STATE.ROTATE,CLICK_ACTION.AUXILIARY=STATE.ZOOM,CLICK_ACTION.SECONDARY=STATE.PAN,this.cameraObject=object,this.domElement=domElement===void 0?document:domElement,this.renderer=renderer,this.scene=scene,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.scrollRate=50,this.pixelHeight=1;var duration=6e3,enabled=!0,inbuildTime=0,cameraPath=void 0,numberOfCameraPoint=void 0,updateLightWithPathFlag=!1,playRate=500,deviceOrientationControl=void 0,defaultViewport="default",currentMode=MODE.DEFAULT,smoothCameraTransitionObject=void 0,rotateCameraTransitionObject=void 0,cameraAutoTumbleObject=void 0,mouseScroll=0,rotateMode=ROTATE_DIRECTION.FREE;this._state=STATE.NONE;var zincRayCaster;this.targetTouchId=-1;var rect=void 0,_a=new THREE.Vector3,_b=new THREE.Vector3,_c=new THREE.Vector3,_new_b=new THREE.Vector3,_new_c=new THREE.Vector3,_axis=new THREE.Vector3,_v=new THREE.Vector3,_rel_eye=new THREE.Vector3,sceneSphere=new THREE.Sphere,_tempEye=new THREE.Vector3,ndcControl=void 0,maxDist=0,viewports={default:new Viewport};viewports.default.nearPlane=.1,viewports.default.farPlane=2e3,viewports.default.eyePosition=[0,0,0],viewports.default.targetPosition=[0,0,-1],viewports.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new THREE.Vector3(...viewports.default.targetPosition)),this.calculateMaxAllowedDistance=scene=>{var box=scene.getBoundingBox();if(box){box.getBoundingSphere(sceneSphere),maxDist=6*sceneSphere.radius;var currentDist=0;this.cameraObject&&(currentDist=this.cameraObject.position.distanceTo(sceneSphere.center)),maxDist=currentDist>maxDist?currentDist:maxDist}else maxDist=0},this.addViewport=(viewportName,viewport)=>{viewportName&&viewport&&(viewports[viewportName]=viewport)},this.setDefaultViewport=defaultName=>!!(defaultName&&defaultName in viewports)&&(defaultViewport=defaultName,!0),this.getDefaultViewport=()=>defaultViewport,this.getViewportOfName=name=>viewports[name],this.setCurrentViewport=name=>!!(name in viewports)&&(this.setCurrentCameraSettings(viewports[name]),!0),this.setRotationMode=mode=>{switch(mode){case"none":rotateMode=ROTATE_DIRECTION.NONE;break;case"horizontal":rotateMode=ROTATE_DIRECTION.HORIZONTAL;break;case"vertical":rotateMode=ROTATE_DIRECTION.VERTICAL;break;case"free":default:rotateMode=ROTATE_DIRECTION.FREE}},this.onResize=()=>{rect&&(rect=void 0),ndcControl&&ndcControl.setCurrentCameraSettings(this.cameraObject,viewports[defaultViewport])},this.getVisibleHeightAtZDepth=depth=>{// compensate for cameras not positioned at z=0
|
|
1732
|
+
var cameraOffset=this.cameraObject.position.z;depth<cameraOffset?depth-=cameraOffset:depth+=cameraOffset;// vertical fov in radians
|
|
1733
|
+
var vFOV=this.cameraObject.fov*Math.PI/180;// Math.abs to ensure the result is always positive
|
|
1734
|
+
return 2*Math.tan(vFOV/2)*Math.abs(depth)},this.calculateHeightPerPixelAtZeroDepth=wHeight=>{var height=this.getVisibleHeightAtZDepth(0);return this.pixelHeight=height/wHeight,this.pixelHeight},this.getNDCFromDocumentCoords=(x,y,positionIn)=>{updateRect(!1);var position=positionIn?positionIn:new THREE.Vector2,out_x=2*((x-rect.left)/rect.width)-1,out_y=2*-((y-rect.top)/rect.height)+1;return position.set(out_x,out_y)},this.getRelativeCoordsFromNDC=(x,y,positionIn)=>{updateRect(!1);var position=positionIn?positionIn:new THREE.Vector2;return position.x=(x+1)*rect.width/2,position.y=(1-y)*rect.height/2,position},this.setMouseButtonAction=(buttonName,actionName)=>{CLICK_ACTION[buttonName]=STATE[actionName]};//Make sure the camera does not travel beyond limit
|
|
1715
1735
|
var checkTravelDistance=()=>{if(0<maxDist){var newDist=_tempEye.distanceTo(sceneSphere.center);return maxDist>newDist||this.cameraObject.position.distanceTo(sceneSphere.center)>newDist}return!0},translateViewport=translation=>{_tempEye.copy(this.cameraObject.position).add(translation),checkTravelDistance()&&(this.cameraObject.target.add(translation),this.cameraObject.position.add(translation),this.updateDirectionalLight())},onDocumentMouseDown=event=>{updateRect(!1);// Check if mouse event hapens inside the minimap
|
|
1716
1736
|
var minimapCoordinates;if(currentMode===MODE.DEFAULT&&(minimapCoordinates=this.scene.getNormalisedMinimapCoordinates(this.renderer,event)),!minimapCoordinates)0==event.button?event.ctrlKey?this._state=CLICK_ACTION.AUXILIARY:event.shiftKey?this._state=CLICK_ACTION.SECONDARY:this._state=CLICK_ACTION.MAIN:1==event.button?(event.preventDefault(),this._state=CLICK_ACTION.AUXILIARY):2==event.button&&(this._state=CLICK_ACTION.SECONDARY),this.pointer_x=event.clientX-rect.left,this.pointer_y=event.clientY-rect.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else{currentMode=MODE.MINIMAP;var translation=this.scene.getMinimapDiffFromNormalised(minimapCoordinates.x,minimapCoordinates.y);translateViewport(translation)}},onDocumentMouseMove=event=>{if(updateRect(!1),this.pointer_x=event.clientX-rect.left,this.pointer_y=event.clientY-rect.top,currentMode===MODE.MINIMAP){var minimapCoordinates=this.scene.getNormalisedMinimapCoordinates(this.renderer,event);if(minimapCoordinates){var translation=this.scene.getMinimapDiffFromNormalised(minimapCoordinates.x,minimapCoordinates.y);translateViewport(translation)}}else this._state===STATE.NONE&&void 0!==zincRayCaster&&zincRayCaster.move(this,event.clientX,event.clientY,this.renderer)},onDocumentMouseUp=event=>{this._state=STATE.NONE,currentMode==MODE.MINIMAP&&(currentMode=MODE.DEFAULT),zincRayCaster!==void 0&&this.pointer_x_start==event.clientX-rect.left&&this.pointer_y_start==event.clientY-rect.top&&zincRayCaster.pick(this,event.clientX,event.clientY,this.renderer)},onDocumentMouseLeave=event=>{this._state=STATE.NONE},onDocumentTouchStart=event=>{updateRect(!1);var len=event.touches.length;if(1==len)this._state=STATE.TOUCH_ROTATE,this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else if(2==len){this._state=STATE.TOUCH_ZOOM;var dx=event.touches[0].clientX-event.touches[1].clientX,dy=event.touches[0].clientY-event.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(dx*dx+dy*dy)}else 3==len&&(this._state=STATE.TOUCH_PAN,this.targetTouchId=event.touches[0].identifier,this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},onDocumentTouchMove=event=>{event.preventDefault(),event.stopPropagation();var len=event.touches.length;if(1==len)this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top;else if(2==len){if(this._state===STATE.TOUCH_ZOOM){var dx=event.touches[0].clientX-event.touches[1].clientX,dy=event.touches[0].clientY-event.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(dx*dx+dy*dy)}}else if(3==len&&this._state===STATE.TOUCH_PAN)for(var i=0;3>i;i++)event.touches[i].identifier==this.targetTouchId&&(this.pointer_x=event.touches[0].clientX-rect.left,this.pointer_y=event.touches[0].clientY-rect.top)},onDocumentTouchEnd=event=>{var len=event.touches.length;this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=STATE.NONE,1==len&&zincRayCaster!==void 0&&this.pointer_x_start==event.touches[0].clientX-rect.left&&this.pointer_y_start==event.touches[0].clientY-rect.top&&zincRayCaster.pick(this.cameraObject,event.touches[0].clientX,event.touches[0].clientY,this.renderer)},onDocumentEnter=()=>{updateRect(!0)},updateRect=forced=>{//Use intersectionObserver to reset the rect for ray tracing.
|
|
1717
1737
|
if(forced||rect===void 0){var observer=new IntersectionObserver(entries=>{for(var entry of entries)rect=entry.boundingClientRect;observer.disconnect()});observer.observe(this.domElement)}},onDocumentWheelEvent=event=>{updateRect(!1),this._state=STATE.SCROLL;var changes=0;0<event.deltaY?changes=this.scrollRate:0>event.deltaY&&(changes=-1*this.scrollRate),mouseScroll+=changes,event.preventDefault(),event.stopImmediatePropagation()},translate=()=>{if("undefined"!=typeof this.cameraObject){var height=rect.height,distance=this.cameraObject.position.distanceTo(this.cameraObject.target),fact=0;this.cameraObject.far>this.cameraObject.near&&distance>=this.cameraObject.near&&distance<=this.cameraObject.far&&(fact=(distance-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),_b.set(this.previous_pointer_x,height-this.previous_pointer_y,0),_c.set(this.previous_pointer_x,height-this.previous_pointer_y,1),_new_b.set(this.pointer_x,height-this.pointer_y,0),_new_c.set(this.pointer_x,height-this.pointer_y,1),_b.unproject(this.cameraObject),_c.unproject(this.cameraObject),_new_b.unproject(this.cameraObject),_new_c.unproject(this.cameraObject);var translate_rate=-.002;_new_b.sub(_b).multiplyScalar(1-fact),_new_c.sub(_c).multiplyScalar(fact),_new_b.add(_new_c).multiplyScalar(translate_rate),translateViewport(_new_b)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(axis,angle)=>{axis.normalize(),_v.copy(this.cameraObject.position).sub(this.cameraObject.target),_rel_eye.copy(_v),_v.normalize(),.8<Math.abs(_v.dot(axis))&&_v.copy(this.cameraObject.up),_b.crossVectors(axis,_v).normalize(),_c.crossVectors(axis,_b);var rel_eyea=axis.dot(_rel_eye),rel_eyeb=_b.dot(_rel_eye),rel_eyec=_c.dot(_rel_eye),upa=axis.dot(this.cameraObject.up),upb=_b.dot(this.cameraObject.up),upc=_c.dot(this.cameraObject.up),cos_angle=Math.cos(angle),sin_angle=Math.sin(angle);return _new_b.set(cos_angle*_b.x+sin_angle*_c.x,cos_angle*_b.y+sin_angle*_c.y,cos_angle*_b.z+sin_angle*_c.z),_new_c.set(cos_angle*_c.x-sin_angle*_b.x,cos_angle*_c.y-sin_angle*_b.y,cos_angle*_c.z-sin_angle*_b.z),_v.copy(this.cameraObject.target),_v.x=_v.x+axis.x*rel_eyea+_new_b.x*rel_eyeb+_new_c.x*rel_eyec,_v.y=_v.y+axis.y*rel_eyea+_new_b.y*rel_eyeb+_new_c.y*rel_eyec,_v.z=_v.z+axis.z*rel_eyea+_new_b.z*rel_eyeb+_new_c.z*rel_eyec,_a.set(axis.x*upa+_new_b.x*upb+_new_c.x*upc,axis.y*upa+_new_b.y*upb+_new_c.y*upc,axis.z*upa+_new_b.z*upb+_new_c.z*upc),{position:_v,up:_a}},this.rotateAboutLookAtpoint=(axis,angle)=>{var returned_values=this.getVectorsFromRotateAboutLookAtPoints(axis,angle);this.cameraObject.position.copy(returned_values.position),this.updateDirectionalLight(),this.cameraObject.up.copy(returned_values.up)};var tumble=()=>{if("undefined"!=typeof this.cameraObject){var width=rect.width,height=rect.height;if(0<width&&0<height){var radius=.25*(width+height),delta_x=0,delta_y=0;(rotateMode===ROTATE_DIRECTION.FREE||rotateMode===ROTATE_DIRECTION.HORIZONTAL)&&(delta_x=this.pointer_x-this.previous_pointer_x),(rotateMode===ROTATE_DIRECTION.FREE||rotateMode===ROTATE_DIRECTION.VERTICAL)&&(delta_y=this.previous_pointer_y-this.pointer_y);var tangent_dist=Math.sqrt(delta_x*delta_x+delta_y*delta_y);if(0<tangent_dist){var dx=1*-delta_y/tangent_dist,dy=1*delta_x/tangent_dist,d=0;// Do not allow rotation on other direction around the origin if rotateMode is not free
|
|
@@ -1851,7 +1871,7 @@ var handleSyncControl=()=>{this._state===STATE.ROTATE||this._state===STATE.TOUCH
|
|
|
1851
1871
|
* Enable syncControl.
|
|
1852
1872
|
*/ /**
|
|
1853
1873
|
* Disable syncControl.
|
|
1854
|
-
*/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
|
|
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
|
|
1855
1875
|
return pickedObjects.length=0,raycaster.intersectObjects(objects,!0,pickedObjects)};this.pick=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&callbackFunction){getIntersectsObject(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)return void zincObject.zoomToCluster(pickedObjects[i].object.clusterIndex);callbackFunction(pickedObjects,x,y)}};var hovered=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&hoverCallbackFunction){if(getIntersectsObject(zincCamera,x,y),lastHoveredDate.setTime(Date.now()),0===pickedObjects.length){//skip hovered callback if the previous one is empty
|
|
1856
1876
|
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};/**
|
|
1857
1877
|
* Object with containg viewport information used in ZincJS.
|
|
@@ -2145,7 +2165,7 @@ var{Group,Matrix4}=__webpack_require__(4),Pointset=(__webpack_require__(22).Poin
|
|
|
2145
2165
|
* Update geometries and glyphsets based on the calculated time.
|
|
2146
2166
|
*/ /**
|
|
2147
2167
|
* Add a new geometry
|
|
2148
|
-
*/tMatrix.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this.pickableUpdateRequired=!0,this.isRegion=!0,this.uuid=getUniqueId(),this.hideAllPrimitives=()=>{children.forEach(child=>child.hideAllPrimitives()),zincObjects.forEach(zincObject=>zincObject.setVisibility(!1))},this.showAllPrimitives=()=>{children.forEach(child=>child.showAllPrimitives()),zincObjects.forEach(zincObject=>zincObject.setVisibility(!0))},this.setVisibility=flag=>{flag!=group.visible&&(group.visible=flag,this.pickableUpdateRequired=!0)},this.getVisibility=()=>group.visible,this.getGroup=()=>group,this.setTransformation=transformation=>{tMatrix.set(...transformation),group.matrix.copy(tMatrix),group.updateMatrixWorld()},this.setName=nameIn=>{nameIn&&""!==nameIn&&(name=nameIn)},this.getName=()=>name,this.getParent=()=>parent,this.getFullSeparatedPath=()=>{var paths=[];if(""!==name){paths.push(name);for(var parentName,p=parent;p!==void 0;)parentName=p.getName(),""!==parentName&&paths.unshift(parentName),p=p.getParent()}return paths},this.getFullPath=()=>{var paths=this.getFullSeparatedPath();if(0<paths.length){var fullPath=paths.shift();return paths.forEach(path=>{fullPath=fullPath.concat("/",path)}),fullPath}return""},this.createChild=nameIn=>{var childRegion=new Region(this,scene);return childRegion.setName(nameIn),children.push(childRegion),group.add(childRegion.getGroup()),childRegion},this.getChildWithName=childName=>{if(childName)for(var lowerChildName=childName.toLowerCase(),i=0;i<children.length;i++)if(children[i].getName().toLowerCase()===lowerChildName)return children[i]},this.findChildFromSeparatedPath=pathArray=>{if(pathArray&&0<pathArray.length&&""===pathArray[0]&&pathArray.shift(),pathArray&&0<pathArray.length){var childRegion=this.getChildWithName(pathArray[0]);return childRegion?(pathArray.shift(),childRegion.findChildFromSeparatedPath(pathArray)):void 0}return this},this.findChildFromPath=path=>{var pathArray=path.split("/");return this.findChildFromSeparatedPath(pathArray)},this.createChildFromSeparatedPath=pathArray=>{if(0<pathArray.length&&""===pathArray[0]&&pathArray.shift(),0<pathArray.length){var childRegion=this.getChildWithName(pathArray[0]);return childRegion||(childRegion=this.createChild(pathArray[0])),pathArray.shift(),childRegion.createChildFromSeparatedPath(pathArray)}return this},this.createChildFromPath=path=>{var pathArray=path.split("/");return this.createChildFromSeparatedPath(pathArray)},this.findOrCreateChildFromPath=path=>{var childRegion=this.findChildFromPath(path);return childRegion||(childRegion=this.createChildFromPath(path)),childRegion},this.addZincObject=zincObject=>{zincObject&&(zincObject.setRegion(this),group.add(zincObject.getGroup()),zincObjects.push(zincObject),this.pickableUpdateRequired=!0,scene&&scene.triggerObjectAddedCallback(zincObject))},this.removeZincObject=zincObject=>{for(var i=0;i<zincObjects.length;i++)if(zincObject===zincObjects[i])return group.remove(zincObject.getGroup()),zincObjects.splice(i,1),
|
|
2168
|
+
*/tMatrix.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this.pickableUpdateRequired=!0,this.isRegion=!0,this.uuid=getUniqueId(),this.hideAllPrimitives=()=>{children.forEach(child=>child.hideAllPrimitives()),zincObjects.forEach(zincObject=>zincObject.setVisibility(!1))},this.showAllPrimitives=()=>{children.forEach(child=>child.showAllPrimitives()),zincObjects.forEach(zincObject=>zincObject.setVisibility(!0))},this.setVisibility=flag=>{flag!=group.visible&&(group.visible=flag,this.pickableUpdateRequired=!0)},this.getVisibility=()=>group.visible,this.getGroup=()=>group,this.setTransformation=transformation=>{tMatrix.set(...transformation),group.matrix.copy(tMatrix),group.updateMatrixWorld()},this.setName=nameIn=>{nameIn&&""!==nameIn&&(name=nameIn)},this.getName=()=>name,this.getParent=()=>parent,this.getFullSeparatedPath=()=>{var paths=[];if(""!==name){paths.push(name);for(var parentName,p=parent;p!==void 0;)parentName=p.getName(),""!==parentName&&paths.unshift(parentName),p=p.getParent()}return paths},this.getFullPath=()=>{var paths=this.getFullSeparatedPath();if(0<paths.length){var fullPath=paths.shift();return paths.forEach(path=>{fullPath=fullPath.concat("/",path)}),fullPath}return""},this.createChild=nameIn=>{var childRegion=new Region(this,scene);return childRegion.setName(nameIn),children.push(childRegion),group.add(childRegion.getGroup()),childRegion},this.getChildWithName=childName=>{if(childName)for(var lowerChildName=childName.toLowerCase(),i=0;i<children.length;i++)if(children[i].getName().toLowerCase()===lowerChildName)return children[i]},this.findChildFromSeparatedPath=pathArray=>{if(pathArray&&0<pathArray.length&&""===pathArray[0]&&pathArray.shift(),pathArray&&0<pathArray.length){var childRegion=this.getChildWithName(pathArray[0]);return childRegion?(pathArray.shift(),childRegion.findChildFromSeparatedPath(pathArray)):void 0}return this},this.findChildFromPath=path=>{var pathArray=path.split("/");return this.findChildFromSeparatedPath(pathArray)},this.createChildFromSeparatedPath=pathArray=>{if(0<pathArray.length&&""===pathArray[0]&&pathArray.shift(),0<pathArray.length){var childRegion=this.getChildWithName(pathArray[0]);return childRegion||(childRegion=this.createChild(pathArray[0])),pathArray.shift(),childRegion.createChildFromSeparatedPath(pathArray)}return this},this.createChildFromPath=path=>{var pathArray=path.split("/");return this.createChildFromSeparatedPath(pathArray)},this.findOrCreateChildFromPath=path=>{var childRegion=this.findChildFromPath(path);return childRegion||(childRegion=this.createChildFromPath(path)),childRegion},this.addZincObject=zincObject=>{zincObject&&(zincObject.setRegion(this),group.add(zincObject.getGroup()),zincObjects.push(zincObject),this.pickableUpdateRequired=!0,scene&&scene.triggerObjectAddedCallback(zincObject))},this.removeZincObject=zincObject=>{for(var i=0;i<zincObjects.length;i++)if(zincObject===zincObjects[i])return group.remove(zincObject.getGroup()),zincObjects.splice(i,1),scene&&scene.triggerObjectRemovedCallback(zincObject),zincObject.dispose(),void(this.pickableUpdateRequired=!0)},this.checkPickableUpdateRequred=transverse=>{if(this.pickableUpdateRequired)return!0;if(transverse)for(var flag=!1,i=0;i<children.length;i++)if(flag=children[i].checkPickableUpdateRequred(transverse),flag)return!0;return!1},this.getPickableThreeJSObjects=(objectsList,transverse)=>(group.visible&&(zincObjects.forEach(zincObject=>{if(zincObject.getGroup()&&zincObject.getGroup().visible){var marker=zincObject.marker;marker&&marker.isEnabled()&&objectsList.push(marker.getMorph()),objectsList.push(zincObject.getGroup())}}),transverse&&children.forEach(childRegion=>{childRegion.getPickableThreeJSObjects(objectsList,transverse)}),this.pickableUpdateRequired=!1),objectsList),this.setDuration=durationIn=>{duration=durationIn,zincObjects.forEach(zincObject=>zincObject.setDuration(durationIn)),children.forEach(childRegion=>childRegion.setDuration(durationIn))},this.getDuration=()=>duration,this.getBoundingBox=transverse=>{var boundingBox1,boundingBox2;return zincObjects.forEach(zincObject=>{boundingBox2=zincObject.getBoundingBox(),boundingBox2&&(null==boundingBox1?boundingBox1=boundingBox2.clone():boundingBox1.union(boundingBox2))}),transverse&&children.forEach(childRegion=>{boundingBox2=childRegion.getBoundingBox(transverse),boundingBox2&&(null==boundingBox1?boundingBox1=boundingBox2.clone():boundingBox1.union(boundingBox2))}),boundingBox1},this.clear=transverse=>{transverse&&children.forEach(childRegion=>childRegion.clear(transverse)),zincObjects.forEach(zincObject=>{group.remove(zincObject.getGroup()),zincObject.dispose()}),children=[],zincObjects=[]},this.objectIsInRegion=(zincObject,transverse)=>{for(var i=0;i<zincObjects.length;i++)if(zincObject===zincObjects[i])return!0;if(transverse)for(var _i=0;_i<children.length;_i++)if(children[_i].objectIsInRegion(zincObject,transverse))return!0;return!1},this.forEachGeometry=(callbackFunction,transverse)=>{zincObjects.forEach(zincObject=>{zincObject.isGeometry&&callbackFunction(zincObject)}),transverse&&children.forEach(childRegion=>childRegion.forEachGeometry(callbackFunction,transverse))},this.forEachGlyphset=(callbackFunction,transverse)=>{zincObjects.forEach(zincObject=>{zincObject.isGlyphset&&callbackFunction(zincObject)}),transverse&&children.forEach(childRegion=>childRegion.forEachGlyphset(callbackFunction,transverse))},this.forEachPointset=(callbackFunction,transverse)=>{zincObjects.forEach(zincObject=>{zincObject.isPointset&&callbackFunction(zincObject)}),transverse&&children.forEach(childRegion=>childRegion.forEachPointset(callbackFunction,transverse))},this.forEachLine=(callbackFunction,transverse)=>{zincObjects.forEach(zincObject=>{zincObject.isLines&&callbackFunction(zincObject)}),transverse&&children.forEach(childRegion=>childRegion.forEachLine(callbackFunction,transverse))},this.findObjectsWithAnatomicalId=(anatomicalId,transverse)=>(zincObjects.forEach(zincObject=>{zincObject.anatomicalId===anatomicalId&&objectsArray.push(zincObject)}),transverse&&children.forEach(childRegion=>{var childObjects=childRegion.findObjectsWithAnatomicalId(anatomicalId,transverse);objectsArray.push(...childObjects)}),objectsArray),this.findObjectsWithGroupName=(groupName,transverse)=>{var objectsArray=[];return zincObjects.forEach(zincObject=>{var lowerObjectName=zincObject.groupName?zincObject.groupName.toLowerCase():zincObject.groupName,lowerGroupName=groupName?groupName.toLowerCase():groupName;lowerObjectName===lowerGroupName&&objectsArray.push(zincObject)}),transverse&&children.forEach(childRegion=>{var childObjects=childRegion.findObjectsWithGroupName(groupName,transverse);objectsArray.push(...childObjects)}),objectsArray},this.findGeometriesWithGroupName=(groupName,transverse)=>{var primitivesArray=this.findObjectsWithGroupName(groupName,transverse),geometriesArray=primitivesArray.filter(primitive=>primitive.isGeometry);return geometriesArray},this.findPointsetsWithGroupName=(groupName,transverse)=>{var primitivesArray=this.findObjectsWithGroupName(groupName,transverse),pointsetsArray=primitivesArray.filter(primitive=>primitive.isPointset);return pointsetsArray},this.findGlyphsetsWithGroupName=(groupName,transverse)=>{var primitivesArray=this.findObjectsWithGroupName(groupName,transverse),glyphsetsArray=primitivesArray.filter(primitive=>primitive.isGlyphset);return glyphsetsArray},this.findLinesWithGroupName=(groupName,transverse)=>{var primitivesArray=this.findObjectsWithGroupName(groupName,transverse),linesArray=primitivesArray.filter(primitive=>primitive.isLines);return linesArray},this.getAllObjects=transverse=>{var objectsArray=[...zincObjects];return transverse&&children.forEach(childRegion=>{var childObjects=childRegion.getAllObjects(transverse);objectsArray.push(...childObjects)}),objectsArray},this.getChildRegions=transverse=>{var objectsArray=[...children];return transverse&&children.forEach(childRegion=>{var childObjects=childRegion.getChildRegions(transverse);objectsArray.push(...childObjects)}),objectsArray},this.getCurrentTime=()=>{if(zincObjects[0]!=null)return zincObjects[0].getCurrentTime();for(var time,i=0;i<children.length;i++)if(time=children[i].getCurrentTime(),-1!==time)return time;return-1},this.setMorphTime=(time,transverse)=>{zincObjects.forEach(zincObject=>{zincObject.setMorphTime(time)}),transverse&&children.forEach(childRegion=>{childRegion.setMorphTime(time)})},this.isTimeVarying=()=>{for(var i=0;i<zincObjects.length;i++)if(zincObjects[i].isTimeVarying())return!0;for(var _i2=0;_i2<children.length;_i2++)if(children[_i2].isTimeVarying())return!0;return!1},this.renderGeometries=(playRate,delta,playAnimation,cameraControls,options,transverse)=>{var _options$markerCluste,allObjects=this.getAllObjects(transverse);// Let video dictates the progress if one is present
|
|
2149
2169
|
allObjects.forEach(zincObject=>{zincObject.render(playRate*delta,playAnimation,cameraControls,options)}),options&&!1===playAnimation&&null!==(_options$markerCluste=options.markerCluster)&&void 0!==_options$markerCluste&&_options$markerCluste.markerUpdateRequired&&options.markerCluster.calculate()},this.createPoints=(groupName,coords,labels,colour)=>{var isNew=!1,zincObjects=this.findObjectsWithGroupName(groupName,!1),index=zincObjects.findIndex(zincObject=>zincObject.isPointset),pointset=-1<index?zincObjects[index]:new Pointset;return pointset.addPoints(coords,labels,colour),-1===index?(pointset.setName(groupName),this.addZincObject(pointset),isNew=!0):this.pickableUpdateRequired=!0,{zincObject:pointset,isNew}},this.createLines=(groupName,coords,colour)=>{var isNew=!1,zincObjects=this.findObjectsWithGroupName(groupName,!1),index=zincObjects.findIndex(zincObject=>zincObject.isLines),lines=-1<index?zincObjects[index]:new Lines2;return lines.addLines(coords,colour),-1===index?(lines.setName(groupName),this.addZincObject(lines),isNew=!0):this.pickableUpdateRequired=!0,{zincObject:lines,isNew}},this.createGeometryFromThreeJSGeometry=(groupName,geometry,colour,opacity,visibility,renderOrder)=>{var zincGeometry=new Geometry,material=new THREE.MeshPhongMaterial({color:colour,morphTargets:!1,morphNormals:!1,transparent:!0,opacity:opacity,side:THREE.DoubleSide});return zincGeometry.createMesh(geometry,material,{localTimeEnabled:!1,localMorphColour:!1}),zincGeometry.getMorph()?(zincGeometry.setVisibility(!1),zincGeometry.setName(groupName),zincGeometry.setRenderOrder(renderOrder),this.addZincObject(zincGeometry),zincGeometry):void 0}};/**
|
|
2150
2170
|
* Provides a hierachical structure to objects, Each region
|
|
2151
2171
|
* may contain multiple child regions and {@link ZincObject}.
|