zincjs 1.16.3 → 1.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/zinc.frontend.js +1 -1
- package/build/zinc.js +45 -40
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/controls.js +197 -186
- package/src/primitives/lines2.js +4 -3
- package/src/primitives/pointset.js +8 -2
package/build/zinc.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = require("url-polyfill");
|
|
|
32
32
|
/***/ ((module) => {
|
|
33
33
|
|
|
34
34
|
"use strict";
|
|
35
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.16.
|
|
35
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"zincjs","version":"1.16.5","description":"ZincJS (Web-based-Zinc-Visualisation)","main":"build/zinc.js","directories":{"doc":"docs"},"files":["package.json","LICENSE","README.md","src/*","build/zinc.js","build/zinc.frontend.js","build/zinc.js.map","webpack.config.js"],"scripts":{"build-bundle":"webpack --config webpack.frontend.js; webpack --config webpack.backend.js","build-backend":"webpack --config webpack.backend.js","test":"npm --prefix ./test install && npm --prefix ./test run test-ci","changelog":"auto-changelog -p --output CHANGELOG.md --template keepachangelog","jsdoc":"jsdoc -c jsdoc_conf.json","version":"npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs","release:beta":"npm version prerelease --preid=beta; npm publish --tag beta","release:minor":"npm version minor; npm publish","release:patch":"npm version patch; npm publish"},"repository":{"type":"git","url":"git+https://github.com/alan-wu/ZincJS.git"},"keywords":["library","webgl","3d","zincjs"],"author":"Alan Wu <alan.wu@auckland.ac.nz>","license":"MIT","bugs":{"url":"https://github.com/alan-wu/ZincJS/issues"},"homepage":"http://alan-wu.github.io/ZincJS/","devDependencies":{"@babel/core":"^7.23.9","@babel/preset-env":"^7.23.9","auto-changelog":"^2.4.0","babel-loader":"^9.1.3","babel-preset-minify":"^0.5.1","file-loader":"^6.2.0","jsdoc":"^4.0.2","raw-loader":"^4.0.2","webpack":"^5.90.3","webpack-cli":"^5.1.4","webpack-node-externals":"^3.0.0"},"dependencies":{"css-element-queries":"^1.2.2","lodash":"^4.17.19","promise-polyfill":"^8.1.3","three":"^0.130.1","three-spritetext":"1.6.2","url-loader":"^4.1.1","url-polyfill":"^1.1.7","webworkify-webpack":"^2.1.5"}}');
|
|
36
36
|
|
|
37
37
|
/***/ }),
|
|
38
38
|
/* 3 */
|
|
@@ -838,7 +838,7 @@ var THREE=__webpack_require__(4),Points=(__webpack_require__(23).Points),toBuffe
|
|
|
838
838
|
*
|
|
839
839
|
* @param {Boolean} flag - Determin either size attenuation
|
|
840
840
|
* should be on or off.
|
|
841
|
-
*/this.addPoints=(coords,labels,colour)=>{if(coords&&0<coords.length){var current=this.drawRange
|
|
841
|
+
*/this.addPoints=(coords,labels,colour)=>{if(coords&&0<coords.length){var current=this.drawRange;-1===current&&(current=0);var geometry=this.addVertices(coords),mesh=this.getMorph();if(!mesh){var material=new THREE.PointsMaterial({alphaTest:.5,size:10,color:colour,sizeAttenuation:!1});geometry.colorsNeedUpdate=!0,this.createMesh(geometry,material,{localTimeEnabled:!1,localMorphColour:!1})}var end=current+coords.length,index=0;if(Array.isArray(labels)&&labels.length===coords.length||"string"==typeof labels){labelSets.length;for(current;current+index<end;){var labelText="string"==typeof labels?labels:labels[index];addLabel(current+index,coords[index],labelText,this._lod._material.color),index++}}this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(hex){this._lod._material.color.setHex(hex),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(hex);for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setColour(this._lod._material.color)},this.setColour=colour=>{this._lod.setColour(colour);for(var i=0;i<labelSets.length;i++)labelSets[i]&&labelSets[i].setColour(this._lod._material.color)},this.setSize=size=>{this.morph&&this.morph.material&&(this.morph.material.size=size,this.morph.material.needsUpdate=!0)},this.setSizeAttenuation=flag=>{this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=flag,this.morph.material.needsUpdate=!0)},this.getVerticesByIndex=function(index){if(0<=index&&this.drawRange>index){var positionAttribute=this.getMorph().geometry.getAttribute("position");return[positionAttribute.getX(index),positionAttribute.getY(index),positionAttribute.getZ(index)]}},this.editVertices=function(coords,i){if(coords&&coords.length){var mesh=this.getMorph(),maxIndex=i+coords.length-1;if(!mesh||0>i||maxIndex>=this.drawRange)return;var positionAttribute=mesh.geometry.getAttribute("position"),index=i;coords.forEach(coord=>{var label=labelSets[index];label&&label.setPosition(coord[0],coord[1],coord[2]),positionAttribute.setXYZ(index++,coord[0],coord[1],coord[2])}),positionAttribute.needsUpdate=!0,this.boundingBoxUpdateRequired=!0}},this.render=(delta,playAnimation,cameraControls,options)=>{this.morph&&cameraControls&&(this.morph.sizePerPixel=cameraControls.pixelHeight),Pointset.prototype.render.call(this,delta,playAnimation,cameraControls,options)}};/**
|
|
842
842
|
* Provides an object which stores points and provides method which controls its position.
|
|
843
843
|
* This is created when a valid json file containing point is read into a {@link Zinc.Scene}
|
|
844
844
|
* object.
|
|
@@ -1838,44 +1838,49 @@ for(var keyframeIndex,_j3=0;_j3<sourceTrack.times.length;_j3++)keyframeIndex=thi
|
|
|
1838
1838
|
/* 44 */
|
|
1839
1839
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1840
1840
|
|
|
1841
|
-
var THREE=__webpack_require__(4),resolveURL=(__webpack_require__(5).resolveURL),Viewport=function(){this.nearPlane=.168248,this.farPlane=6.82906,this.eyePosition=[.5,-2.86496,.5],this.targetPosition=[.5,.5,.5],this.upVector=[0,0,1];var _this=this;this.setFromObject=_ref=>{var{nearPlane,farPlane,eyePosition,targetPosition,upVector}=_ref;_this.nearPlane=nearPlane,_this.farPlane=farPlane,_this.eyePosition=eyePosition,_this.targetPosition=targetPosition,_this.upVector=upVector}},CameraControls=function(object,domElement,renderer,scene){var MODE={NONE:-1,DEFAULT:0,PATH:1,SMOOTH_CAMERA_TRANSITION:2,AUTO_TUMBLE:3,ROTATE_TRANSITION:4,MINIMAP:5,SYNC_CONTROL:6},STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6,KEYBOARD_ZOOM:7,KEYBOARD_ROTATE:8,KEYBOARD_PAN:9},ROTATE_DIRECTION={NONE:-1,FREE:1,HORIZONTAL:2,VERTICAL:3},KEYBOARD={ARROWLEFT:37,ARROWUP:38,ARROWRIGHT:39,ARROWDOWN:40,NUMPADADD:107,NUMPADSUBTRACT:109,EQUAL:187,MINUS:189},CLICK_ACTION={};/**
|
|
1841
|
+
var THREE=__webpack_require__(4),resolveURL=(__webpack_require__(5).resolveURL),Viewport=function(){this.nearPlane=.168248,this.farPlane=6.82906,this.eyePosition=[.5,-2.86496,.5],this.targetPosition=[.5,.5,.5],this.upVector=[0,0,1];var _this=this;this.setFromObject=_ref=>{var{nearPlane,farPlane,eyePosition,targetPosition,upVector}=_ref;_this.nearPlane=nearPlane,_this.farPlane=farPlane,_this.eyePosition=eyePosition,_this.targetPosition=targetPosition,_this.upVector=upVector}},CameraControls=function(object,domElement,renderer,scene){var MODE={NONE:-1,DEFAULT:0,PATH:1,SMOOTH_CAMERA_TRANSITION:2,AUTO_TUMBLE:3,ROTATE_TRANSITION:4,MINIMAP:5,SYNC_CONTROL:6},STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6,KEYBOARD_ZOOM:7,KEYBOARD_ROTATE:8,KEYBOARD_PAN:9},ROTATE_DIRECTION={NONE:-1,FREE:1,HORIZONTAL:2,VERTICAL:3},KEYBOARD={ARROWLEFT:37,ARROWUP:38,ARROWRIGHT:39,ARROWDOWN:40,NUMPADADD:107,NUMPADSUBTRACT:109,EQUAL:187,MINUS:189},CLICK_ACTION={};/**
|
|
1842
1842
|
* Actions states.
|
|
1843
1843
|
* Available states are NONE, ROTATE, ZOOM, PAN, TOUCH_ROTATE, TOUCH_ZOOM, TOUCH_PAN and SCROLL.
|
|
1844
|
-
* @property {Object}
|
|
1845
|
-
*/ /**
|
|
1844
|
+
* @property {Object}
|
|
1845
|
+
*/ /**
|
|
1846
1846
|
* Available click actions are MAIN, AUXILIARY and SECONARY.
|
|
1847
|
-
* @property {Object}
|
|
1848
|
-
*/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.zoomRate=50,this.rotateRate=50,this.panRate=100,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,zoomSize=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,hasUpdated=!1,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?1.5*currentDist:maxDist}else maxDist=0}
|
|
1847
|
+
* @property {Object}
|
|
1848
|
+
*/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.zoomRate=50,this.rotateRate=50,this.panRate=100,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,zoomSize=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,hasUpdated=!1,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?1.5*currentDist:maxDist}else maxDist=0};var updateNearAndFarPlane=travalDist=>{var ratio=.001;_a.copy(this.cameraObject.position);var length=_a.sub(this.cameraObject.target).length();this.cameraObject.near=Math.max(1e-4,length*ratio),this.cameraObject.far=1e4*this.cameraObject.near};/**
|
|
1849
|
+
* Add a viewport to the list of available named viewports.
|
|
1850
|
+
*
|
|
1851
|
+
* @param {String} name - Name of the viewport
|
|
1852
|
+
* @param {Viewport} viewportName - Viewport to be added
|
|
1853
|
+
*/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
|
|
1849
1854
|
var cameraOffset=this.cameraObject.position.distanceTo(this.cameraObject.target);depth<cameraOffset?depth-=cameraOffset:depth+=cameraOffset;// vertical fov in radians
|
|
1850
1855
|
var vFOV=this.cameraObject.fov*Math.PI/180;// Math.abs to ensure the result is always positive
|
|
1851
1856
|
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]};/**
|
|
1852
|
-
*
|
|
1853
|
-
* @param {HTML} element
|
|
1854
|
-
* @param {Number} index
|
|
1857
|
+
*
|
|
1858
|
+
* @param {HTML} element
|
|
1859
|
+
* @param {Number} index
|
|
1855
1860
|
*/var setCanvasTabindex=(element,index)=>{element instanceof HTMLCanvasElement&&(element.tabIndex=index)},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
|
|
1856
1861
|
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),rect)if(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){var _rect,_rect2;this._state=STATE.TOUCH_ROTATE,this.pointer_x=event.touches[0].clientX-(null===(_rect=rect)||void 0===_rect?void 0:_rect.left),this.pointer_y=event.touches[0].clientY-(null===(_rect2=rect)||void 0===_rect2?void 0:_rect2.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 if(3==len){var _rect3,_rect4;this._state=STATE.TOUCH_PAN,this.targetTouchId=event.touches[0].identifier,this.pointer_x=event.touches[0].clientX-(null===(_rect3=rect)||void 0===_rect3?void 0:_rect3.left),this.pointer_y=event.touches[0].clientY-(null===(_rect4=rect)||void 0===_rect4?void 0:_rect4.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.
|
|
1857
1862
|
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.zoomRate:0>event.deltaY&&(changes=-1*this.zoomRate),zoomSize+=changes,event.preventDefault(),event.stopImmediatePropagation()},onDocumentKeydownEvent=event=>{updateRect(!1);var changes=0;if(event.keyCode===KEYBOARD.EQUAL||event.keyCode===KEYBOARD.MINUS||event.keyCode===KEYBOARD.NUMPADADD||event.keyCode===KEYBOARD.NUMPADSUBTRACT){this._state=STATE.KEYBOARD_ZOOM;var unit=1;event.shiftKey&&(unit*=2),event.keyCode===KEYBOARD.EQUAL||event.keyCode===KEYBOARD.NUMPADADD?changes=-1*(this.zoomRate*unit):(event.keyCode===KEYBOARD.MINUS||event.keyCode===KEYBOARD.NUMPADSUBTRACT)&&(changes=this.zoomRate*unit),zoomSize+=changes}else(event.keyCode===KEYBOARD.ARROWLEFT||event.keyCode===KEYBOARD.ARROWUP||event.keyCode===KEYBOARD.ARROWRIGHT||event.keyCode===KEYBOARD.ARROWDOWN)&&(event.shiftKey?(this._state=STATE.KEYBOARD_ROTATE,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,changes=this.rotateRate):(this._state=STATE.KEYBOARD_PAN,changes=this.panRate),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,event.keyCode===KEYBOARD.ARROWLEFT?this.pointer_x-=changes:event.keyCode===KEYBOARD.ARROWUP?this.pointer_y-=changes:event.keyCode===KEYBOARD.ARROWRIGHT?this.pointer_x+=changes:event.keyCode===KEYBOARD.ARROWDOWN&&(this.pointer_y+=changes));Object.values(KEYBOARD).includes(event.keyCode)&&event.preventDefault()},onDocumentKeyupEvent=event=>{this._state=STATE.NONE},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};//Make sure the camera does not travel beyond limit
|
|
1858
1863
|
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 _rect5,_rect6,width=null===(_rect5=rect)||void 0===_rect5?void 0:_rect5.width,height=null===(_rect6=rect)||void 0===_rect6?void 0:_rect6.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
|
|
1859
|
-
if(rotateMode===ROTATE_DIRECTION.FREE){var _d=dx*(this.pointer_x-.5*(width-1))+dy*(.5*(height-1)-this.pointer_y);_d>radius?_d=radius:_d<-radius&&(_d=-radius)}var phi=Math.acos(d/radius)-.5*Math.PI,angle=this.tumble_rate*tangent_dist/radius;_a.copy(this.cameraObject.position).sub(this.cameraObject.target).normalize(),_b.copy(this.cameraObject.up).normalize(),_c.copy(_b).cross(_a).normalize().multiplyScalar(dx),_b.multiplyScalar(dy),_axis.addVectors(_c,_b).multiplyScalar(Math.cos(phi)),_a.multiplyScalar(Math.sin(phi)),_axis.add(_a),this.rotateAboutLookAtpoint(_axis,-angle)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},calculateZoomDelta=()=>{var delta=0;return this._state===STATE.ZOOM?delta=this.previous_pointer_y-this.pointer_y:this._state===STATE.SCROLL||this._state===STATE.KEYBOARD_ZOOM?delta=zoomSize:(delta=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),delta};this.changeZoomByScrollRateUnit=unit=>{var delta_y=unit*this.zoomRate;this.changeZoomByValue(delta_y)},this.changeZoomByValue=delta_y=>{if("undefined"!=typeof this.cameraObject){var height=rect.height,a=this.cameraObject.position.clone();a.sub(this.cameraObject.target);var dist=a.length(),dy=1.5*delta_y/height
|
|
1864
|
+
if(rotateMode===ROTATE_DIRECTION.FREE){var _d=dx*(this.pointer_x-.5*(width-1))+dy*(.5*(height-1)-this.pointer_y);_d>radius?_d=radius:_d<-radius&&(_d=-radius)}var phi=Math.acos(d/radius)-.5*Math.PI,angle=this.tumble_rate*tangent_dist/radius;_a.copy(this.cameraObject.position).sub(this.cameraObject.target).normalize(),_b.copy(this.cameraObject.up).normalize(),_c.copy(_b).cross(_a).normalize().multiplyScalar(dx),_b.multiplyScalar(dy),_axis.addVectors(_c,_b).multiplyScalar(Math.cos(phi)),_a.multiplyScalar(Math.sin(phi)),_axis.add(_a),this.rotateAboutLookAtpoint(_axis,-angle)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},calculateZoomDelta=()=>{var delta=0;return this._state===STATE.ZOOM?delta=this.previous_pointer_y-this.pointer_y:this._state===STATE.SCROLL||this._state===STATE.KEYBOARD_ZOOM?delta=zoomSize:(delta=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),delta};this.changeZoomByScrollRateUnit=unit=>{var delta_y=unit*this.zoomRate;this.changeZoomByValue(delta_y)},this.changeZoomByValue=delta_y=>{if("undefined"!=typeof this.cameraObject){var height=rect.height,a=this.cameraObject.position.clone();a.sub(this.cameraObject.target);var dist=a.length(),dy=1.5*delta_y/height,travalDist=dist*dy;.01<dist+travalDist&&(a.normalize(),_tempEye.copy(this.cameraObject.position),_tempEye.x+=a.x*travalDist,_tempEye.y+=a.y*travalDist,_tempEye.z+=a.z*travalDist,checkTravelDistance()&&(this.cameraObject.position.copy(_tempEye),this.updateDirectionalLight(),updateNearAndFarPlane(travalDist),hasUpdated=!0))}};var flyZoom=()=>{var delta_y=calculateZoomDelta();this.changeZoomByValue(delta_y),this._state===STATE.ZOOM&&(this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y),(this._state===STATE.SCROLL||this._state===STATE.KEYBOARD_ZOOM)&&(zoomSize=0,this._state=STATE.NONE)};this.setDirectionalLight=directionalLightIn=>{this.directionalLight=directionalLightIn},this.updateDirectionalLight=()=>{0!=this.directionalLight&&this.directionalLight.position.set(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z)},this.enable=function(){enabled=!0,this.domElement&&this.domElement.addEventListener&&(setCanvasTabindex(this.domElement,0),this.domElement.addEventListener("mousedown",onDocumentMouseDown,!1),this.domElement.addEventListener("mousemove",onDocumentMouseMove,!1),this.domElement.addEventListener("mouseup",onDocumentMouseUp,!1),this.domElement.addEventListener("mouseleave",onDocumentMouseLeave,!1),this.domElement.addEventListener("touchstart",onDocumentTouchStart,!1),this.domElement.addEventListener("touchmove",onDocumentTouchMove,!1),this.domElement.addEventListener("touchend",onDocumentTouchEnd,!1),this.domElement.addEventListener("wheel",onDocumentWheelEvent,!1),this.domElement.addEventListener("mouseenter",onDocumentEnter,!1),this.domElement.addEventListener("contextmenu",event=>{event.preventDefault()},!1),this.domElement.addEventListener("keydown",onDocumentKeydownEvent,!1),this.domElement.addEventListener("keyup",onDocumentKeyupEvent,!1))},this.disable=function(){enabled=!1,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener("mousedown",onDocumentMouseDown,!1),this.domElement.removeEventListener("mousemove",onDocumentMouseMove,!1),this.domElement.removeEventListener("mouseup",onDocumentMouseUp,!1),this.domElement.removeEventListener("mouseleave",onDocumentMouseLeave,!1),this.domElement.removeEventListener("touchstart",onDocumentTouchStart,!1),this.domElement.removeEventListener("touchmove",onDocumentTouchMove,!1),this.domElement.removeEventListener("touchend",onDocumentTouchEnd,!1),this.domElement.removeEventListener("wheel",onDocumentWheelEvent,!1),this.domElement.removeEventListener("mouseenter",onDocumentEnter,!1),this.domElement.removeEventListener("contextmenu",event=>{event.preventDefault()},!1),this.domElement.removeEventListener("keydown",onDocumentKeydownEvent,!1),this.domElement.removeEventListener("keyup",onDocumentKeyupEvent,!1),setCanvasTabindex(this.domElement,-1))},this.loadPath=pathData=>{cameraPath=pathData.CameraPath,numberOfCameraPoint=pathData.NumberOfPoints},this.loadPathURL=(path_url,finishCallback)=>{var xmlhttp=new XMLHttpRequest;xmlhttp.onreadystatechange=()=>{if(4==xmlhttp.readyState&&200==xmlhttp.status){var pathData=JSON.parse(xmlhttp.responseText);this.loadPath(pathData),finishCallback!=null&&"function"==typeof finishCallback&&finishCallback()}};var requestURL=resolveURL(path_url);xmlhttp.open("GET",requestURL,!0),xmlhttp.send()},this.setPathDuration=durationIn=>{duration=durationIn,smoothCameraTransitionObject&&smoothCameraTransitionObject.setDuration(duration),rotateCameraTransitionObject&&rotateCameraTransitionObject.setDuration(duration)},this.getPlayRate=()=>playRate,this.setPlayRate=playRateIn=>{playRate=playRateIn};/**
|
|
1860
1865
|
* Update the internal timer by the set amount, this can
|
|
1861
1866
|
* be used to force a time update by setting delta to zero.
|
|
1862
|
-
*
|
|
1867
|
+
*
|
|
1863
1868
|
* @param {Number} delta - The amount of time to increment
|
|
1864
1869
|
* the time by.
|
|
1865
1870
|
*/var updateTime=delta=>{var targetTime=inbuildTime+delta;targetTime>duration&&(targetTime-=duration),inbuildTime=targetTime};/**
|
|
1866
1871
|
* Get the current inbuild time,
|
|
1867
|
-
*
|
|
1872
|
+
*
|
|
1868
1873
|
* @return {Number}
|
|
1869
1874
|
*/this.getTime=()=>inbuildTime,this.setTime=timeIn=>{inbuildTime=timeIn>duration?duration:0>timeIn?0:timeIn},this.getNumberOfTimeFrame=()=>numberOfCameraPoint,this.getCurrentTimeFrame=()=>{if(2<numberOfCameraPoint){var current_time=inbuildTime/duration*(numberOfCameraPoint-1),bottom_frame=Math.floor(current_time),proportion=1-(current_time-bottom_frame),top_frame=Math.ceil(current_time);return bottom_frame==top_frame?bottom_frame==numberOfCameraPoint-1?[bottom_frame-1,top_frame,0]:[bottom_frame,top_frame+1,1]:[bottom_frame,top_frame,proportion]}return 1==numberOfCameraPoint?[0,0,0]:void 0},this.setCurrentTimeFrame=targetTimeFrame=>{2<numberOfCameraPoint&&(inbuildTime=duration*targetTimeFrame/(numberOfCameraPoint-1),0>inbuildTime&&(inbuildTime=0),inbuildTime>duration&&(inbuildTime=duration))};/**
|
|
1870
1875
|
* Update the progress on the path by the specified amount - delta.
|
|
1871
|
-
*
|
|
1876
|
+
*
|
|
1872
1877
|
* @param {Number} delta - The amount of time to increment
|
|
1873
1878
|
*/var updatePath=delta=>{if(currentMode===MODE.PATH&&(updateTime(delta),cameraPath)){for(var time_frame=this.getCurrentTimeFrame(),bottom_frame=time_frame[0],top_frame=time_frame[1],proportion=time_frame[2],bot_pos=[cameraPath[3*bottom_frame],cameraPath[3*bottom_frame+1],cameraPath[3*bottom_frame+2]],top_pos=[cameraPath[3*top_frame],cameraPath[3*top_frame+1],cameraPath[3*top_frame+2]],current_positions=[],i=0;i<bot_pos.length;i++)current_positions.push(proportion*bot_pos[i]+(1-proportion)*top_pos[i]);this.cameraObject.position.set(current_positions[0],current_positions[1],current_positions[2]),this.cameraObject.target.set(top_pos[0],top_pos[1],top_pos[2]),deviceOrientationControl&&this.cameraObject.lookAt(this.cameraObject.target),updateLightWithPathFlag&&(this.directionalLight.position.set(current_positions[0],current_positions[1],current_positions[2]),this.directionalLight.target.position.set(top_pos[0],top_pos[1],top_pos[2]))}};/**
|
|
1874
1879
|
* Force recalculation of the current path.
|
|
1875
1880
|
*/this.calculatePathNow=()=>{updatePath(0)};// handle synchronised control based on information in the idc
|
|
1876
1881
|
var handleSyncControl=()=>{this._state===STATE.ROTATE||this._state===STATE.TOUCH_ROTATE||this._state===STATE.KEYBOARD_ROTATE?tumble():this._state===STATE.PAN||this._state===STATE.TOUCH_PAN||this._state===STATE.KEYBOARD_PAN?(translate(),ndcControl.triggerCallback()):(this._state===STATE.ZOOM||this._state===STATE.TOUCH_ZOOM||this._state===STATE.SCROLL||this._state===STATE.KEYBOARD_ZOOM)&&(ndcControl.zoom(calculateZoomDelta()),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,(this._state===STATE.SCROLL||this._state===STATE.KEYBOARD_ZOOM)&&(this._state=STATE.NONE),zoomSize=0,ndcControl.triggerCallback())};/**
|
|
1877
1882
|
* Update all controls related changes - including calculation of the viewport.
|
|
1878
|
-
*
|
|
1883
|
+
*
|
|
1879
1884
|
* @param {Number} timeChanged - Time eclipse since last called.
|
|
1880
1885
|
*/ /**
|
|
1881
1886
|
* Switch to path mode and begin traveling through the camera path.
|
|
@@ -1883,12 +1888,12 @@ var handleSyncControl=()=>{this._state===STATE.ROTATE||this._state===STATE.TOUCH
|
|
|
1883
1888
|
* Stop playing path and switch back to normal control.
|
|
1884
1889
|
*/ /**
|
|
1885
1890
|
* Check rather the control is currently in path mode.
|
|
1886
|
-
*
|
|
1891
|
+
*
|
|
1887
1892
|
* @return {Boolean}
|
|
1888
1893
|
*/ /**
|
|
1889
1894
|
* Enable directional light update as the camera
|
|
1890
1895
|
* is traveling through path.
|
|
1891
|
-
*
|
|
1896
|
+
*
|
|
1892
1897
|
* @param {Boolean} flag
|
|
1893
1898
|
*/ /**
|
|
1894
1899
|
* Enable rotation using the devices's accelerometer.
|
|
@@ -1900,46 +1905,46 @@ var handleSyncControl=()=>{this._state===STATE.ROTATE||this._state===STATE.TOUCH
|
|
|
1900
1905
|
* Reset the viewport settings to the one provided by default viewport.
|
|
1901
1906
|
*/ /**
|
|
1902
1907
|
* Set the current camera settings with the provided viewport.
|
|
1903
|
-
*
|
|
1908
|
+
*
|
|
1904
1909
|
* @param {Viewport} newViewport - viewport settings.
|
|
1905
1910
|
*/ /**
|
|
1906
1911
|
* Get the viewport based on centre, radius, view_angle and clip distance.
|
|
1907
|
-
*
|
|
1912
|
+
*
|
|
1908
1913
|
* @param {Number} centreX - x coordinate of the centre.
|
|
1909
1914
|
* @param {Number} centreY - y coordinate of the centre.
|
|
1910
1915
|
* @param {Number} centreZ - z coordinate of the centre.
|
|
1911
1916
|
* @param {Number} radius - radius if the viewport.
|
|
1912
1917
|
* @param {Number} view_angle - view angle.
|
|
1913
1918
|
* @param {Number} clip_distance - clip_distance between the near and far plane.
|
|
1914
|
-
*
|
|
1919
|
+
*
|
|
1915
1920
|
* @return {Viewport}
|
|
1916
1921
|
*/ /**
|
|
1917
1922
|
* Get the viewport for the boudning box
|
|
1918
|
-
*
|
|
1923
|
+
*
|
|
1919
1924
|
* @param {Number} boundingBox - y coordinate of the centre.
|
|
1920
1925
|
* @return {Viewport}
|
|
1921
1926
|
*/ /**
|
|
1922
1927
|
* Get the current camera viewport.
|
|
1923
|
-
*
|
|
1928
|
+
*
|
|
1924
1929
|
* @return {Viewport}
|
|
1925
1930
|
*/ /**
|
|
1926
|
-
* Setup a smooth transition object which transition the camera from one
|
|
1927
|
-
* viewport to the other in the specified duration. This will not work if
|
|
1931
|
+
* Setup a smooth transition object which transition the camera from one
|
|
1932
|
+
* viewport to the other in the specified duration. This will not work if
|
|
1928
1933
|
* {@link rotateCameraTransition} is active.
|
|
1929
1934
|
* To use this object, the transition must be enabled using
|
|
1930
1935
|
* {@link enableCameraTransition}.
|
|
1931
|
-
*
|
|
1936
|
+
*
|
|
1932
1937
|
* @param {Viewport} startingViewport - the starting viewport
|
|
1933
1938
|
* @param {Viewport} endingViewport - the viewport ti end the transistion with.
|
|
1934
1939
|
* @param {Number} durationIn - duration of the smooth transition.
|
|
1935
1940
|
*/ /**
|
|
1936
|
-
* Setup a rotate camera transition object which rotate the
|
|
1937
|
-
* camera by the specified the angle in the specified
|
|
1941
|
+
* Setup a rotate camera transition object which rotate the
|
|
1942
|
+
* camera by the specified the angle in the specified
|
|
1938
1943
|
* duration. This will not work if {@link cameraTransition}
|
|
1939
1944
|
* is active.
|
|
1940
1945
|
* To use this object, the transition must be enabled using
|
|
1941
1946
|
* {@link enableCameraTransition}.
|
|
1942
|
-
*
|
|
1947
|
+
*
|
|
1943
1948
|
* @param {THREE.Vector3} axis - the starting viewport
|
|
1944
1949
|
* @param {Number} angle - the viewport ti end the transistion with.
|
|
1945
1950
|
* @param {Number} duration - duration of the smooth transition.
|
|
@@ -1958,8 +1963,8 @@ var handleSyncControl=()=>{this._state===STATE.ROTATE||this._state===STATE.TOUCH
|
|
|
1958
1963
|
* Setup auto tumble object of the camera which will rotate the camera
|
|
1959
1964
|
* around the target as if the user is rotating the camera by mouse/touch
|
|
1960
1965
|
* interaction.
|
|
1961
|
-
* The tumbling will only be enabled with {@link enabelAutoTumble}.
|
|
1962
|
-
*
|
|
1966
|
+
* The tumbling will only be enabled with {@link enabelAutoTumble}.
|
|
1967
|
+
*
|
|
1963
1968
|
* @param {Array} tumbleDirectionIn - direction of the mouse/touch.
|
|
1964
1969
|
* @param {Number} tumbleRateIn - Speed of the tumbling.
|
|
1965
1970
|
* @param {Boolean} stopOnCameraInputIn - Disable the tumbling once the user
|
|
@@ -1972,11 +1977,11 @@ var handleSyncControl=()=>{this._state===STATE.ROTATE||this._state===STATE.TOUCH
|
|
|
1972
1977
|
* Update the autotumble object.
|
|
1973
1978
|
*/ /**
|
|
1974
1979
|
* Check rather autotumble is active.
|
|
1975
|
-
*
|
|
1980
|
+
*
|
|
1976
1981
|
* @return {Boolean}
|
|
1977
1982
|
*/ /**
|
|
1978
1983
|
* Create an internal raycaster object and enable it for picking.
|
|
1979
|
-
*
|
|
1984
|
+
*
|
|
1980
1985
|
* @param {Scene} sceneIn - The scene to pick from, it can be different from the
|
|
1981
1986
|
* camera's scene.
|
|
1982
1987
|
* @param {requestCallback} callbackFunctionIn - The callback for pick event.
|
|
@@ -1986,24 +1991,24 @@ var handleSyncControl=()=>{this._state===STATE.ROTATE||this._state===STATE.TOUCH
|
|
|
1986
1991
|
* Disable raycaster and remove the internal ray caster object.
|
|
1987
1992
|
*/ /**
|
|
1988
1993
|
* Check rather the camera is in syncControl mode.
|
|
1989
|
-
*
|
|
1994
|
+
*
|
|
1990
1995
|
* @return {Boolean}
|
|
1991
1996
|
*/ /**
|
|
1992
1997
|
* Enable syncControl.
|
|
1993
1998
|
*/ /**
|
|
1994
1999
|
* Disable syncControl.
|
|
1995
|
-
*/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||this._state===STATE.KEYBOARD_ROTATE?tumble():this._state===STATE.PAN||this._state===STATE.TOUCH_PAN||this._state===STATE.KEYBOARD_PAN?translate():(this._state===STATE.ZOOM||this._state===STATE.TOUCH_ZOOM||this._state===STATE.SCROLL||this._state===STATE.KEYBOARD_ZOOM)&&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=updated||hasUpdated,hasUpdated=!1,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(),hasUpdated=!0},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},pickableObjects=void 0;this.enable=()=>{enable=!0},this.disable=()=>{enable=!1},this.getIntersectsObject=zincCamera=>{if(hostScene!==scene){var threejsScene=scene.getThreeJSScene();renderer.render(threejsScene,zincCamera.cameraObject)}var objects=pickableObjects?pickableObjects:scene.getPickableThreeJSObjects();//Reset pickedObjects array
|
|
2000
|
+
*/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||this._state===STATE.KEYBOARD_ROTATE?tumble():this._state===STATE.PAN||this._state===STATE.TOUCH_PAN||this._state===STATE.KEYBOARD_PAN?translate():(this._state===STATE.ZOOM||this._state===STATE.TOUCH_ZOOM||this._state===STATE.SCROLL||this._state===STATE.KEYBOARD_ZOOM)&&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=updated||hasUpdated,hasUpdated=!1,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(),hasUpdated=!0},this.getViewportFromCentreAndRadius=(centreX,centreY,centreZ,radius,view_angle,clip_distance)=>{_a.copy(this.cameraObject.position),_a.sub(this.cameraObject.target),_a.normalize();/* look at the centre of the sphere */var localTargetPosition=[centreX,centreY,centreZ],eye_distance=radius/Math.tan(view_angle*Math.PI/360),localEyePosition=[centreX+_a.x*eye_distance,centreY+_a.y*eye_distance,centreZ+_a.z*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},pickableObjects=void 0;this.enable=()=>{enable=!0},this.disable=()=>{enable=!1},this.getIntersectsObject=zincCamera=>{if(hostScene!==scene){var threejsScene=scene.getThreeJSScene();renderer.render(threejsScene,zincCamera.cameraObject)}var objects=pickableObjects?pickableObjects:scene.getPickableThreeJSObjects();//Reset pickedObjects array
|
|
1996
2001
|
return pickedObjects.length=0,raycaster.intersectObjects(objects,!0,pickedObjects)},this.setPickableObjects=zincObjects=>{zincObjects===void 0?pickableObjects=void 0:(pickableObjects=[],zincObjects.forEach(zincObject=>{zincObject.getGroup()&&zincObject.getGroup().visible&&pickableObjects.push(zincObject.getGroup())}))},this.getIntersectsObjectWithOrigin=(zincCamera,origin,direction)=>(raycaster.set(origin,direction),this.getIntersectsObject(zincCamera)),this.getIntersectsObjectWithCamera=(zincCamera,x,y)=>(zincCamera.getNDCFromDocumentCoords(x,y,mouse),raycaster.setFromCamera(mouse,zincCamera.cameraObject),this.getIntersectsObject(zincCamera)),this.pick=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&callbackFunction){this.getIntersectsObjectWithCamera(zincCamera,x,y);for(var zincObject,length=pickedObjects.length,i=0;i<length;i++)if(zincObject=pickedObjects[i].object?pickedObjects[i].object.userData:void 0,zincObject&&zincObject.isMarkerCluster&&zincObject.visible&&zincObject.clusterIsVisible(pickedObjects[i].object.clusterIndex)&&zincObject.zoomToCluster(pickedObjects[i].object.clusterIndex))//Can zoom into cluster
|
|
1997
2002
|
return;callbackFunction(pickedObjects,x,y)}};var hovered=(zincCamera,x,y)=>{if(enabled&&renderer&&scene&&zincCamera&&hoverCallbackFunction){if(this.getIntersectsObjectWithCamera(zincCamera,x,y),lastHoveredDate.setTime(Date.now()),0===pickedObjects.length){//skip hovered callback if the previous one is empty
|
|
1998
2003
|
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};/**
|
|
1999
2004
|
* Object with containg viewport information used in ZincJS.
|
|
2000
|
-
*
|
|
2005
|
+
*
|
|
2001
2006
|
* @class
|
|
2002
2007
|
* @author Alan Wu
|
|
2003
2008
|
* @return {Viewport}
|
|
2004
2009
|
*/ /**
|
|
2005
2010
|
* Provides the basic controls for a scene.
|
|
2006
|
-
*
|
|
2011
|
+
*
|
|
2007
2012
|
* @class
|
|
2008
2013
|
* @author Alan Wu
|
|
2009
2014
|
* @return {CameraControls}
|
|
@@ -2030,7 +2035,7 @@ this.connect=()=>{onScreenOrientationChangeEvent(),"undefined"!=typeof window&&(
|
|
|
2030
2035
|
// Y''
|
|
2031
2036
|
// O
|
|
2032
2037
|
var alpha=scope.deviceOrientation.alpha?THREE.Math.degToRad(scope.deviceOrientation.alpha):0,beta=scope.deviceOrientation.beta?THREE.Math.degToRad(scope.deviceOrientation.beta):0,gamma=scope.deviceOrientation.gamma?THREE.Math.degToRad(scope.deviceOrientation.gamma):0,orient=scope.screenOrientation?THREE.Math.degToRad(scope.screenOrientation):0;setObjectQuaternion(scope.object,alpha,beta,gamma,orient)}},this.dispose=function(){this.disconnect()},this.connect()},NDCCameraControl=function NDCCameraControl(){var camera=void 0,targetCamera=void 0,defaultViewport=void 0,position=new THREE.Vector3,target=new THREE.Vector3,v1=new THREE.Vector3,v2=new THREE.Vector3,eventCallback=void 0;//return top left and size
|
|
2033
|
-
this.setCurrentCameraSettings=(cameraIn,defaultViewportIn)=>{camera=cameraIn.clone(),targetCamera=cameraIn,defaultViewport=defaultViewportIn,camera.near=defaultViewport.nearPlane,defaultViewport.farPlane&&(camera.far=defaultViewport.farPlane),defaultViewport.eyePosition&&camera.position.set(defaultViewport.eyePosition[0],defaultViewport.eyePosition[1],defaultViewport.eyePosition[2]),defaultViewport.upVector&&camera.up.set(defaultViewport.upVector[0],defaultViewport.upVector[1],defaultViewport.upVector[2]),defaultViewport.targetPosition&&(camera.target=new THREE.Vector3(defaultViewport.targetPosition[0],defaultViewport.targetPosition[1],defaultViewport.targetPosition[2]),camera.lookAt(camera.target)),camera.updateProjectionMatrix(),position.copy(camera.position).project(camera),target.copy(camera.target).project(camera)},this.getCurrentPosition=()=>(target.copy(targetCamera.target).project(camera),[target.x,target.y]),this.zoom=delta=>{var scaledDelta=.002*delta,zoom=Math.max(targetCamera.zoom-scaledDelta,1);targetCamera.zoom=zoom,targetCamera.updateProjectionMatrix()},this.zoomToBox=(box,zoom)=>{box.getCenter(v1),v1.project(camera),this.setCenterZoom([v1.x,v1.y],zoom)},this.getPanZoom=()=>({target:this.getCurrentPosition(),zoom:targetCamera.zoom}),this.setCenterZoom=(center,zoom)=>{v1.set(center[0],center[1],target.z).unproject(camera),v2.copy(v1).sub(targetCamera.target),targetCamera.target.copy(v1),targetCamera.lookAt(targetCamera.target),targetCamera.position.add(v2),targetCamera.zoom=zoom,targetCamera.updateProjectionMatrix()},this.setEventCallback=callback=>{(callback===void 0||"function"==typeof callback)&&(eventCallback=callback)},this.triggerCallback=()=>{eventCallback!==void 0&&"function"==typeof eventCallback&&eventCallback()}};/**
|
|
2038
|
+
this.setCurrentCameraSettings=(cameraIn,defaultViewportIn)=>{0==this.near_plane_fly_debt,camera=cameraIn.clone(),targetCamera=cameraIn,defaultViewport=defaultViewportIn,camera.near=defaultViewport.nearPlane,defaultViewport.farPlane&&(camera.far=defaultViewport.farPlane),defaultViewport.eyePosition&&camera.position.set(defaultViewport.eyePosition[0],defaultViewport.eyePosition[1],defaultViewport.eyePosition[2]),defaultViewport.upVector&&camera.up.set(defaultViewport.upVector[0],defaultViewport.upVector[1],defaultViewport.upVector[2]),defaultViewport.targetPosition&&(camera.target=new THREE.Vector3(defaultViewport.targetPosition[0],defaultViewport.targetPosition[1],defaultViewport.targetPosition[2]),camera.lookAt(camera.target)),camera.updateProjectionMatrix(),position.copy(camera.position).project(camera),target.copy(camera.target).project(camera)},this.getCurrentPosition=()=>(target.copy(targetCamera.target).project(camera),[target.x,target.y]),this.zoom=delta=>{var scaledDelta=.002*delta,zoom=Math.max(targetCamera.zoom-scaledDelta,1);targetCamera.zoom=zoom,targetCamera.updateProjectionMatrix()},this.zoomToBox=(box,zoom)=>{box.getCenter(v1),v1.project(camera),this.setCenterZoom([v1.x,v1.y],zoom)},this.getPanZoom=()=>({target:this.getCurrentPosition(),zoom:targetCamera.zoom}),this.setCenterZoom=(center,zoom)=>{v1.set(center[0],center[1],target.z).unproject(camera),v2.copy(v1).sub(targetCamera.target),targetCamera.target.copy(v1),targetCamera.lookAt(targetCamera.target),targetCamera.position.add(v2),targetCamera.zoom=zoom,targetCamera.updateProjectionMatrix()},this.setEventCallback=callback=>{(callback===void 0||"function"==typeof callback)&&(eventCallback=callback)},this.triggerCallback=()=>{eventCallback!==void 0&&"function"==typeof eventCallback&&eventCallback()}};/**
|
|
2034
2039
|
* @author richt / http://richt.me
|
|
2035
2040
|
* @author WestLangley / http://github.com/WestLangley
|
|
2036
2041
|
*
|
|
@@ -2303,7 +2308,7 @@ allObjects.forEach(zincObject=>{zincObject.render(playRate*delta,playAnimation,c
|
|
|
2303
2308
|
|
|
2304
2309
|
var THREE=__webpack_require__(4),toBufferGeometry=(__webpack_require__(5).toBufferGeometry),LineSegments2=(__webpack_require__(47).LineSegments2),LineMaterial=(__webpack_require__(49).LineMaterial),LineSegmentsGeometry=(__webpack_require__(48).LineSegmentsGeometry),Lines2=function(){(__webpack_require__(24).Lines).call(this),this.isLines2=!0;var positions=Array(300);/**
|
|
2305
2310
|
* Create the line segements using geometry and material.
|
|
2306
|
-
*
|
|
2311
|
+
*
|
|
2307
2312
|
* @param {Array} arrayIn - Geometry of lines to be rendered.
|
|
2308
2313
|
* @param {THREE.Material} materialIn - Material to be set for the lines.
|
|
2309
2314
|
* @param {Object} options - Provide various options
|
|
@@ -2313,7 +2318,7 @@ var THREE=__webpack_require__(4),toBufferGeometry=(__webpack_require__(5).toBuff
|
|
|
2313
2318
|
* time dependent.
|
|
2314
2319
|
*/ /**
|
|
2315
2320
|
* Set the width for the lines.
|
|
2316
|
-
*
|
|
2321
|
+
*
|
|
2317
2322
|
* @param {Number} width - Width of the lines.
|
|
2318
2323
|
*/ /**
|
|
2319
2324
|
* Add new vertices into the array
|
|
@@ -2332,7 +2337,7 @@ if(coords.forEach(coord=>{positions[index++]=coord[0],positions[index++]=coord[1
|
|
|
2332
2337
|
* Provides an object which stores lines.
|
|
2333
2338
|
* This is created when a valid json file containing lines is read into a {@link Zinc.Scene}
|
|
2334
2339
|
* object.
|
|
2335
|
-
*
|
|
2340
|
+
*
|
|
2336
2341
|
* @class
|
|
2337
2342
|
* @author Alan Wu
|
|
2338
2343
|
* @return {Lines}
|